"use strict";var DROPPER_ROUTES={backend:"/",expired:"/expired",default:"/"};angular.module("controls",[]),angular.module("app",["ngRoute","controls","oc.lazyLoad","datetime","colorpicker.module",angularDragula(angular)]),angular.module("app").controller("AppCtrl",["$scope","$rootScope","$location","rootScopeLegacy","core","$ocLazyLoad","$element","$q","$timeout","$route",function(e,r,o,n,t,a,i,s,c,l){e.ready=!1,n.$install(r);var collectResources=function(e,r){for(var o=[],n=0;n<r.length;n++){var t=r[n];t&&t.length&&o.push({type:e,path:t})}return o},reloadInjects=function(){var e=s.defer(),r=[],o=[];return t.resources&&t.resources.conditionals&&(o=o.concat(collectResources("js",t.resources.conditionals))),t.resources&&t.resources.adminScripts&&(r=r.concat(collectResources("js",t.resources.adminScripts))),t.resources&&t.resources.adminStylesheets&&(r=r.concat(collectResources("css",t.resources.adminStylesheets))),console.log("INJECTING SCRIPT FILES...",o),function(e){if(!e||!e.length){var r=s.defer();return r.resolve(),r.promise}var o=[];return $.each(e,(function(e,r){var n=s.defer();o.push(n.promise),$.ajax({url:r.path,dataType:"script",scriptCharset:"utf-8",cache:!0,success:function(e){n.resolve(e)},error:function(e){n.reject(e)}})})),s.all(o)}(o).then((function(){console.log("DONE INJECTING SCRIPT FILES"),console.log("INJECTING MODULES...",r),function(e){if(!e||!e.length){var r=s.defer();return r.resolve(),r.promise}var o=[{files:e,cache:!0,insertBefore:"#content",serie:!0,charset:"utf-8"}];return a.load(o)}(r).then((function(){console.log("DONE INJECTING MODULES"),c((function(){e.resolve()}))}),(function(r){e.reject("MODULE INJECTION ERROR",r)}))}),(function(r){e.reject(),console.error("SCRIPT INJECTION ERROR",r)})),e.promise};t.fn.onReloading((function(){return reloadInjects()}));var d=[DROPPER_ROUTES.default,DROPPER_ROUTES.backend,DROPPER_ROUTES.expired];t.fn.onReload((function(r){var n=o.path();e.ready=!0,t.dropperLicense&&t.dropperLicense.isValid?(n===DROPPER_ROUTES.expired&&(n=DROPPER_ROUTES.default),o.path(d.indexOf(n)>=0?n:DROPPER_ROUTES.default)):o.path(DROPPER_ROUTES.expired)})),e.$on("$routeChangeStart",(function(r,n,a){var i=o.path();t.dropperLicense&&!1===t.dropperLicense.isValid?e.$root.$evalAsync((function(){o.path(DROPPER_ROUTES.expired)})):t.dropperLicense&&!0===t.dropperLicense.isValid&&(i===DROPPER_ROUTES.expired&&(i=DROPPER_ROUTES.default),e.$root.$evalAsync((function(){o.path(d.indexOf(i)>=0?i:DROPPER_ROUTES.default)})))})),window.jtlStylesheetsRemoved||($('head link[rel="stylesheet"]').each((function(){var e=$(this).attr("href");e.indexOf("templates/css/menu.css")<0&&e.indexOf("jquery")<0&&$(this).remove()})),window.jtlStylesheetsRemoved=!0),t.fn.loadSettings().then((function(){t.fn.reload()}))}]),angular.module("app").config(["$routeProvider","$locationProvider",function(e,r){var o=(new Date).getTime(),n=!!window.kk_frontend_mode,t=n?"frontendeditorview":"mainview",a=n?"FrontendEditorViewCtrl":"MainViewCtrl";e.when(DROPPER_ROUTES.expired,{templateUrl:window.kk_admin_url+"js/views/expired.html.js?"+o,controller:"ExpiredCtrl"}),e.when(DROPPER_ROUTES.default,{templateUrl:window.kk_admin_url+"js/views/"+t+".html.js?"+o,controller:a})}]);