define("app/services/indexService",["angular","cjt/io/api","cjt/util/query","cjt/io/whm-v1-request","cjt/io/whm-v1"],(function(e,t,n,o){var r=e.module("App");function a(e,n){var r={get_domains:function(){return n.data.domains},remove_account:function(n){var r=e.defer(),a=new o.Class;return a.initialize("","removeacct"),a.addArgument("user",n.username),a.addArgument("keepdns",n.keep_dns?"1":"0"),t.promise(a.getRunArguments()).done((function(e){(e=e.parsedResponse).status?r.resolve(e):r.reject(e.error)})),r.promise},get_account_summary:function(n){var r=e.defer(),a=new o.Class;return a.initialize("","accountsummary"),a.addArgument("user",n),t.promise(a.getRunArguments()).done((function(e){(e=e.parsedResponse).status?r.resolve(e):r.reject(e.error)})),r.promise}};return r}return a.$inject=["$q","PAGE"],r.factory("indexService",a)})),define("app/views/RemoveController",["lodash","angular","cjt/util/locale","uiBootstrap","cjt/directives/toggleSortDirective","cjt/directives/searchDirective","cjt/directives/pageSizeDirective","cjt/filters/startFromFilter","cjt/decorators/paginationDecorator"],(function(e,t,n){var o=t.module("App");return o.controller("ModalInstanceCtrl",["$scope","$uibModalInstance","selected_accounts",function(e,t,o){e.selected_accounts=o.map((function(e){return e.username})),e.get_selected_accounts_text=function(){return n.maketext("Check this box to acknowledge that you are aware that this will permanently delete the following accounts: [list_and_quoted,_1]",e.selected_accounts)},e.closeModal=function(){t.close()},e.runIt=function(){t.close(!0)}}]),o.controller("RemoveController",["$scope","$filter","$routeParams","indexService","growl","$uibModal",function(o,r,a,c,u,s){var i=function(t){u.error(e.escape(t))},l=c.get_domains(),m=[];t.forEach(l,(function(e,t){m.push({username:e.username,owner:e.owner,domain:t,suspended:e.suspended?n.maketext("Suspended"):n.maketext("Active"),selected:!1,keep_dns:!1})})),o.accounts=m,o.removing_multiple_accounts=!1,o.confirming_accounts_removal=!1,o.show_only_suspended_accounts=!1,o.meta={sortReverse:!1,sortBy:"username",sortDirection:"desc",maxPages:5,totalItems:o.accounts.length,currentPage:1,pageSize:10,pageSizes:[10,20,50,100],start:0,limit:10,filterValue:""},o.showPager=!0,o.LOCALE=n,o.removal_queue=[];var d={filter:r("filter"),orderBy:r("orderBy"),startFrom:r("startFrom"),limitTo:r("limitTo")};function _(){var e=o.removal_queue.shift(),t=u.info(n.maketext("Starting removal of “[_1]”",e.username));return c.remove_account(e).then((function(){return t.setText(n.maketext("Successfully removed “[_1]”",e.username)),t.severity="success",e.removing=!1,o.accounts=r("filter")(o.accounts,(function(t,n){return t.username!==e.username||(o.accounts[n].removing=!1,!1)})),o.fetch(),o.removal_queue.length?_():(o.removing_multiple_accounts=!1,!0)}),(function(t){e.removing=!1,i(t),o.clear_removal_queue(),o.removing_multiple_accounts=!1}))}o.sortList=function(){o.fetch()},o.selectPage=function(){o.fetch()},o.selectPageSize=function(){o.fetch()},o.request_delete_account=function(e){return e.delete_requested=!0,!!e.summary||(e.requesting_summary=!0,c.get_account_summary(e.username).then((function(t){e.summary=t.data.pop()}),i).finally((function(){e.requesting_summary=!1})))},o.request_multi_delete_confirmation=function(){s.open({templateUrl:"updateModalContent.tmpl",controller:"ModalInstanceCtrl",resolve:{selected_accounts:o.get_selected_accounts}}).result.then((function(e){if(e)return o.confirming_accounts_removal=!1,o.remove_selected()}))},o.searchList=function(){o.fetch()},o.remove=function(e){if(o.removal_queue.push(e),e.removing=!0,1===o.removal_queue.length)return o.remove_next_queued();u.info(n.maketext("The system has added the account [_1] to the removal queue.",e.username)),e.delete_requested=!1},o.get_selected_accounts=function(){return o.selected_accounts=r("filter")(o.accounts,{selected:1}),0===o.selected_accounts.length&&o.confirming_accounts_removal&&(o.confirming_accounts_removal=!1),o.selected_accounts},o.get_selected_account_names=function(){var e=[],n=o.get_selected_accounts();return t.forEach(n,(function(t){e.push(t.username)})),e},o.remove_next_queued=function(){if(!o.removing_multiple_accounts)return o.removing_multiple_accounts=!0,_()},o.get_table_showing_text=function(){return n.maketext("Showing [numf,_1] - [numf,_2] of [quant,_3,item,items]",o.meta.start,o.meta.limit,o.meta.totalItems)},o.selected_account_name_string=function(){return n.maketext("[list_and_quoted,_1]",o.get_selected_account_names())},o.cancel_removal_label=function(){return n.maketext("Cancel account removals ([_1])",o.removal_queue.length)},o.clear_removal_queue=function(){var e=[];t.forEach(o.removal_queue,(function(t){t.removing=!1,e.push(t.username)})),o.removal_queue=[];var r=d.filter(o.accounts,{removing:!0}).map((function(e){return e.username}));e.length&&u.info(n.maketext("The system will not remove the following [numerate,_1,user,users]: [list_and_quoted,_1]",e)),r.length&&u.warning(n.maketext("The system cannot abort the deletion of the following [numerate,_1,user,users]: [list_and_quoted,_1]",r))},o.remove_selected=function(){var e=o.get_selected_accounts();e.length&&(t.forEach(e,(function(e){e.removing=!0,e.selected=0,o.removal_queue.push(e)})),o.account_checkbox_control=!1,o.remove_next_queued(),o.update_selected())},o.toggleCheckAll=function(e,t,n){e.forEach((function(o,r){"selected"===t&&n&&e[r].removing||(e[r][t]=n?1:0)})),o.update_selected()},o.update_selected=function(){o.get_selected_accounts()};o.wrappedDeleteText=function(e){return n.maketext("Are you sure you want to remove the account “[_1]”?",e)+"<br />"+n.maketext("This will permanently remove all of the user’s data from the system.")},o.get_suspended_accounts=function(){return r("filter")(o.accounts,{suspended:n.maketext("Suspended")})},o.fetch=function(){var e=[];if(e=""!==o.meta.filterValue?d.filter(o.accounts,o.meta.filterValue,!1):o.accounts,o.show_only_suspended_accounts&&(e=o.get_suspended_accounts()),""!==o.meta.sortDirection&&""!==o.meta.sortBy&&(e=d.orderBy(e,o.meta.sortBy,"asc"===o.meta.sortDirection)),o.meta.totalItems=e.length,o.meta.totalItems>function(e){for(var t=e[0],n=0;n<e.length;n++)t=e[n]<t?e[n]:t;return t}(o.meta.pageSizes)){var t=(o.meta.currentPage-1)*o.meta.pageSize,n=o.meta.pageSize;e=d.limitTo(d.startFrom(e,t),n),o.showPager=!0,o.meta.start=t+1,o.meta.limit=t+e.length}else o.showPager=!1,0===e.length?o.meta.start=0:o.meta.start=1,o.meta.limit=e.length;return o.filteredAccounts=e,o.update_selected(),e},a.user&&t.forEach(o.accounts,(function(e){e.username===a.user&&(o.meta.filterValue=e.username,o.request_delete_account(e))})),o.fetch()}])})),define("app/index",["angular","cjt/core","cjt/modules","uiBootstrap","ngRoute"],(function(e,t){return function(){return e.module("App",["cjt2.config.whm.configProvider","ngRoute","ui.bootstrap","angular-growl","cjt2.whm"]),require(["cjt/bootstrap","uiBootstrap","app/services/indexService","app/views/RemoveController"],(function(n){var o=e.module("App");o.value("PAGE",PAGE),o.config(["growlProvider","$httpProvider",function(e,t){e.globalReversedOrder(!0),e.globalTimeToLive({success:-1,warning:-1,info:-1,error:-1}),t.useApplyAsync(!0)}]),o.controller("BaseController",["$rootScope","$scope","$route","$location",function(e,t,n,o){t.loading=!1,e.$on("$routeChangeStart",(function(){t.loading=!0})),e.$on("$routeChangeSuccess",(function(){t.loading=!1})),e.$on("$routeChangeError",(function(){t.loading=!1})),t.current_route_matches=function(e){return o.path().match(e)},t.go=function(e){o.path(e)}}]),o.config(["$routeProvider",function(e){e.when("/:user?",{controller:"RemoveController",templateUrl:t.buildFullPath("killacct/views/RemoveView.ptt"),resolve:{}}),e.otherwise({redirectTo:"/"})}]),n(document)}))}}));