'use strict';

var angular = require('angular');
require('./vendor/angular-route.min.js');
var _ = require('lodash');

// Create a module for the extensions.
var fenrirExtensions = angular.module('fenrir.extensions', []);

// Services.
require('./extensions/templateLocatorService')(fenrirExtensions);
require('./common/messagesService')(fenrirExtensions);
require('./common/gameService')(fenrirExtensions);
require('./editor/selectionService')(fenrirExtensions);
require('./editor/toolbarService')(fenrirExtensions);
require('./editor/infoPanelService')(fenrirExtensions);
require('./editor/editorCanvasService')(fenrirExtensions);

// Directives.
require('./editor/toolbarButton')(fenrirExtensions);
require('./editor/infoPanel')(fenrirExtensions);

// Load the extensions.
_.each(window.fenrirExtensions, function(path) {
  require(path)(fenrirExtensions);
});

// Create a module for the app itself.
var fenrir = angular.module('fenrir', ['ngRoute', 'fenrir.extensions']);

require('./config')(fenrir);

// Services.
require('./common/api')(fenrir);

// Directives.
require('./common/messagesContainer')(fenrir);
require('./common/filePicker')(fenrir);
require('./editor/editorCanvas')(fenrir);
require('./editor/toolbar')(fenrir);
require('./editor/infoPanelContainer')(fenrir);

// Controllers.
require('./mainMenu/mainMenuController')(fenrir);
require('./editor/editorController')(fenrir);
require('./settings/settingsController')(fenrir);
