let Merge = require('broccoli-merge-trees');
let Concat = require('broccoli-concat');
var Uglify = require('broccoli-uglify-sourcemap');
let helpers = require('../build-helpers');

let files = [
  "node_modules/jquery/dist/jquery.js",
  "node_modules/jquery-migrate/dist/jquery-migrate.js",
  "node_modules/jquery-ujs/src/rails.js",
  "global/libs/object-create-null.js",
  "node_modules/cookie_js/cookie.js",
  "node_modules/underscore/underscore.js",
  "node_modules/rsvp/dist/rsvp.js",
  "node_modules/jquery-ui/ui/version.js",
  "node_modules/jquery-ui/ui/data.js",
  "node_modules/jquery-ui/ui/ie.js",
  "node_modules/jquery-ui/ui/keycode.js",
  "node_modules/jquery-ui/ui/plugin.js",
  "node_modules/jquery-ui/ui/scroll-parent.js",
  "node_modules/jquery-ui/ui/unique-id.js",
  "node_modules/jquery-ui/ui/widget.js",
  "node_modules/jquery-ui/ui/widgets/mouse.js",
  "node_modules/jquery-ui/ui/position.js",
  "node_modules/jquery-ui/ui/safe-active-element.js",
  "node_modules/jquery-ui/ui/widgets/draggable.js",
  "node_modules/jquery-ui/ui/widgets/resizable.js",
  "node_modules/jquery-ui/ui/widgets/autocomplete.js",
  "node_modules/jquery-ui/ui/widgets/button.js",
  "node_modules/jquery-ui/ui/widgets/datepicker.js",
  "node_modules/jquery-ui/ui/widgets/menu.js",
  "node_modules/jquery-ui/ui/widgets/slider.js",
  "node_modules/jquery-outside-events/jquery.ba-outside-events.js",
  "global/vendor/jquery.tipsy.js",
  "global/vendor/jquery.placeholder.js",
  "node_modules/zeroclipboard/ZeroClipboard.js",
  "global/vendor.jquery.ba-hashchange.min.js",
  "global/vendor/jquery.imagesloaded.js",
  "global/vendor/jquery.masonry.js",
  "global/vendor/jquery.masonry.ordered.js",
  "global/vendor/jquery.countdown.js",
  "global/vendor/jquery.drag-events.js",
  "node_modules/noty/js/noty/jquery.noty.js",
  "node_modules/noty/js/noty/layouts/bottomCenter.js",
  "node_modules/noty/js/noty/themes/default.js",
  "node_modules/noty/js/noty/layouts/top.js",
  "node_modules/crypto-js/core.js",
  "node_modules/crypto-js/sha1.js",
  "node_modules/mustache/mustache.js",
  "node_modules/icanhaz/ICanHaz-no-mustache.js",
  "global/vendor/spin.js",
  "global/vendor/jquery.spin.js",
  "node_modules/URIjs/src/URI.js",
  "global/libs/flyout.js",
  "node_modules/swfobject-umd/swfobject/swfobject.js",
  "global/vendor/date.js",
  "node_modules/minixperiment-client-js/dist/minixperiment.client.js",
  "node_modules/minixperiment-client-js/dist/minixperiment.providers.local.js",
  "global/libs/jquery.autocomplete-hashtag.js",
  "node_modules/moment/moment.js",
  "node_modules/moment-range/dist/moment-range.js",
  "node_modules/moment-range/dist/moment-range.js",
  "global/libs/util.js",
  "global/libs/jquery.util.js",
  "global/libs/google_ads.js",
  "global/libs/player.js",
  "global/libs/notifications_tracker.js",
  "global/libs/login.js",
  "global/libs/overlay.js",
  "global/libs/legacy-columns.js",
  "global/libs/popout_window.js",
  "global/libs/popup.js",
  "global/libs/tabify.js",
  "global/libs/dropdownify.js",
  "global/libs/gameselector.js",
  "global/libs/emoticon_picker.js",
  "global/libs/mobile_notification.js",
  "global/libs/on_popout_close.js",
  "global/twitch/core.js",
  "global/twitch/storage.js",
  "global/twitch/api.js",
  "global/twitch/user.js",
  "global/twitch/uri.js",
  "global/twitch/identifiers.js",
  "global/twitch/experiments.js",
  "global/twitch/player/index.js",
  "global/twitch/player/flash_player.js",
  "global/libs/chromecast_sender.js",
  "global/twitch/player/flash_player_2.js",
  "global/twitch/player/ad_feedback_menu.js",
  "global/twitch/player/ads_controller.js",
  "global/twitch/player/chromecast.js",
  "global/twitch/player/context_loader.js",
  "global/twitch/player/event_handler.js",
  "global/twitch/player/event_controller.js",
  "global/twitch/player/html5_player.js",
  "global/twitch/ads/index.js",
  "global/twitch/ads/ext.js",
  "global/twitch/asyncAds.js",
  "global/twitch/banners.js",
  "global/twitch/cache.js",
  "global/twitch/dashboard.js",
  "global/twitch/display.js",
  "global/twitch/email_notifier.js",
  "global/twitch/geo.js",
  "global/twitch/hls.js",
  "global/twitch/language.js",
  "global/twitch/loader.js",
  "global/twitch/logout.js",
  "global/twitch/notifications.js",
  "global/twitch/sentinel.js",
  "global/twitch/stats.js",
  "global/vendor/base64.js",
  "global/vendor/mixpanel.js",
  "global/libs/spade.js",
  "global/twitch/tracking.js",
  "global/twitch/index.js",
  "global/libs/eu_cookie_notification.js",
  "global/libs/csrf_protection.js",
  "global/libs/common.js",
  "global/vendor/jquery.trackpad-scroll-emulator.js"
];

let tree = new Concat('.', {
  outputFile: '/global.js',
  headerFiles: files
});

if (helpers.env === 'production') {
  tree = new Uglify(tree);
}

module.exports = tree;
