require.config({
  waitSeconds: 45,
  urlArgs: 'bust=' + new Date().getTime(), // Prevent cache
  baseUrl: 'lib',

  // alias libraries paths
  paths: {
    jquery: 'jquery/dist/jquery.min',
    'jquery-file-download': 'jquery-file-download/src/Scripts/jquery.fileDownload',
    angular: 'angular/angular.min',
    'angular-route': 'angular-route/angular-route.min',
    'angular-cookies': 'angular-cookies/angular-cookies.min',
    'angular-sanitize': 'angular-sanitize/angular-sanitize.min',
    'angular-animate': 'angular-animate/angular-animate.min',
    'angular-ui-route': 'angular-ui-router/release/angular-ui-router.min',
    'angular-ui-route-event': 'angular-ui-router/release/stateEvents.min',
    'ui-bootstrap4': 'ui-bootstrap4/dist/ui-bootstrap-tpls',
    'ng-toast': 'ng-toast/dist/ngToast.min',
    'ng-file-upload': 'ng-file-upload/dist/ng-file-upload.min',
    'oclazy-load': 'oclazyload/dist/ocLazyLoad',
    lodash: 'lodash/lodash.min',
    bootstrap: 'bootstrap/dist/js/bootstrap.min',
    'angular-file-saver': 'angular-file-saver/dist/angular-file-saver.bundle.min',
    ngclipboard: 'ngclipboard/dist/ngclipboard.min',
    moment: 'moment/min/moment.min',
    moment_locale: 'moment/min/moment-with-locales',
    'angular-chart': 'angular-chart.js/dist/angular-chart.min',
    chart: 'chart.js/dist/Chart.bundle.min',
    // Multiple language
    'ng-translate': 'angular-translate/dist/angular-translate.min',
    'ng-translate-loader-static-files':
      'angular-translate-loader-static-files/angular-translate-loader-static-files.min',
    'angular-bootstrap-contextmenu': 'angular-bootstrap-contextmenu/contextMenu',
    // APP libs
    directives: '../core/common/directives',
    constant: '../core/common/constant',
    utils: '../core/common/utils',
    session: '../core/common/session',
    // Load this at the final
    app: '../app',
    'angular-recaptcha': 'angular-recaptcha/release/angular-recaptcha.min',

    // load config server (local/dev/prod)
    // 'config_server': '../core/config/simc-server',
    config_server: '../core/config/dev-server',
    // config_server: '../core/config/prod-server',
    'jquery-easing': '../vendor/jquery.easing.min',
    daterangepicker: 'daterangepicker/daterangepicker',
    angular_daterangepicker: 'angular-daterangepicker/js/angular-daterangepicker.min',
  },

  shim: {
    angular: {
      exports: 'angular',
    },
    'angular-route': ['angular'],
    'angular-cookies': ['angular'],
    'angular-sanitize': ['angular'],
    'angular-animate': ['angular'],
    'angular-ui-route': ['angular'],
    'angular-ui-route-event': ['angular', 'angular-ui-route'],
    'ui-bootstrap4': ['angular', 'angular-animate'],
    'ng-toast': ['angular', 'angular-sanitize'],
    'ng-file-upload': ['angular'],
    'angular-file-saver': ['angular'],
    'angular-bootstrap-contextmenu': ['angular'],
    ngclipboard: ['angular'],
    moment: ['jquery'],
    'oclazy-load': ['angular'],
    'ng-translate': ['angular', 'angular-sanitize'],
    'ng-translate-loader-static-files': ['angular', 'angular-sanitize', 'ng-translate'],
    'jquery-file-download': ['jquery'],
    'angular-chart': ['angular'],
    chart: ['angular'],
    // 'bootstrap-bundle': ['jquery', 'popper'],
    bootstrap: ['jquery'],
    directives: ['angular'],
    constant: ['angular'],
    utils: ['angular', 'moment', 'moment_locale'],
    session: ['angular'],
    config_server: ['angular'],
    'angular-recaptcha': ['angular'],
    daterangepicker: ['jquery', 'utils'],
    angular_daterangepicker: ['daterangepicker', 'angular'],
    app: [
      'angular',
      'angular-route',
      'angular-ui-route-event',
      'angular-cookies',
      'angular-sanitize',
      'angular-animate',
      'ng-toast',
      'ng-file-upload',
      'angular-bootstrap-contextmenu',
      'angular-file-saver',
      'oclazy-load',
      'angular-ui-route',
      'ui-bootstrap4',
      'ng-translate',
      'ng-translate-loader-static-files',
      'directives',
      'constant',
      'utils',
      'session',
      'lodash',
      'bootstrap',
      'jquery-file-download',
      'ngclipboard',
      'angular-chart',
      'chart',
      'config_server',
      'angular-recaptcha',
    ],
  },
  priority: [
    'jquery',
    'angular',
    'moment',
    'angular-route',
    'angular-sanitize',
    'ng-translate',
    'ng-translate-loader-static-files',
  ],
});

require(['app', 'angular_daterangepicker'], function () {
  angular.element().ready(function () {
    // bootstrap the app manually
    angular.bootstrap(document, ['angularJSApp']);
  });
});
