!function(){"use strict";function e(e,d){e.state("mail",{url:"/Mail",views:{mailboxes:{templateUrl:"UIxMailMainFrame",controller:"MailboxesController",controllerAs:"app"}},resolve:{stateAccounts:t}}).state("mail.account",{url:"/:accountId",abstract:!0,views:{mailbox:{template:"<ui-view/>"}},resolve:{stateAccount:a}}).state("mail.account.virtualMailbox",{url:"/virtual",views:{"mailbox@mail":{templateUrl:"UIxMailFolderTemplate",controller:"MailboxController",controllerAs:"mailbox"}},resolve:{stateMailbox:i}}).state("mail.account.virtualMailbox.message",{url:"/:mailboxId/:messageId",views:{message:{templateUrl:"UIxMailViewTemplate",controller:"MessageController",controllerAs:"viewer"}},resolve:{stateMailbox:n,stateMessages:l,stateMessage:s},onEnter:c,onExit:u}).state("mail.account.inbox",{url:"/inbox",onEnter:r}).state("mail.account.mailbox",{url:"/:mailboxId",views:{"mailbox@mail":{templateUrl:"UIxMailFolderTemplate",controller:"MailboxController",controllerAs:"mailbox"}},resolve:{stateMailbox:o,stateMessages:l}}).state("mail.account.mailbox.message",{url:"/:messageId",views:{message:{templateUrl:"UIxMailViewTemplate",controller:"MessageController",controllerAs:"viewer"}},onEnter:c,onExit:u,resolve:{stateMessage:s}}),d.otherwise("/Mail/0/inbox")}function t(e,t,a){var o=a.$findAll(e.mailAccounts),r=[];return angular.forEach(o,function(e,t){var a=e.$getMailboxes();0===t?r.push(a.then(function(t){return e})):r.push(e)}),t.all(r)}function a(e,t){return _.find(t,function(t){return t.id==e.accountId})}function o(e,t,a,o,r,l){var i,n,s=r(a.mailboxId);return n=function(e){var t=_.find(e,function(e){return e.path==s});return t||angular.forEach(e,function(e){!t&&e.children&&e.children.length>0&&(t=n(e.children))}),t},l.selectedFolder&&!l.$virtualMode&&(l.selectedFolder.$isLoading=!0),i=n(o.$mailboxes),i?(i.$topIndex=0,i.selectFolder(),i):e.reject("Mailbox doesn't exist")}function r(e,t,a){return e.injector().getAsync("stateAccount").then(function(o){return o.$mailboxes.length>0?e.router.stateService.target("mail.account.mailbox",{accountId:o.id,mailboxId:t(o.$mailboxes[0].path)}):(a.selectedFolder=!1,e.router.stateService.target("mail"))})}function l(e,t,a,o){return a.$virtualMode?[]:o?o.$filter().catch(function(){return e.reject("Mailbox not found")}):e.reject("Mailbox doesn't exist")}function i(e,t){return t.$virtualMode?t.selectedFolder:e.reject("No virtual mailbox defined")}function n(e,t,a,o){var r=a(o.mailboxId);return t.$virtualMode?(t.selectedFolder.resetSelectedMessage(),_.find(t.selectedFolder.$mailboxes,function(e){return e.path==r})):e.reject("No virtual mailbox defined for message")}function s(e,t,a,o,r,l){var i;if(i=_.find(r.$messages,function(e){return e.uid==parseInt(a.messageId)}))return i.$reload({useCache:!0});o.go("mail.account.mailbox",{accountId:r.$account.id,mailboxId:t(r.path)})}function c(e,t){t.selectedMessage=parseInt(e.messageId)}function u(e){delete e.selectedMessage}function d(e,t,a,o,r){e.DebugEnabled||o.defaultErrorHandler(function(){}),t.onError({to:"mail.**"},function(e){"mail"!=e.to().name&&!e.ignored()&&e.error().message.indexOf("superseded")<0&&(a.error("transition error to "+e.to().name),r.selectedFolder=!1,o.go("mail"))})}angular.module("SOGo.MailerUI",["ngCookies","ui.router","ck","angularFileUpload","SOGo.Common","SOGo.ContactsUI","SOGo.SchedulerUI","ngAnimate","SOGo.PreferencesUI"]).config(e).run(d),e.$inject=["$stateProvider","$urlRouterProvider"],t.$inject=["$window","$q","Account"],a.$inject=["$stateParams","stateAccounts"],o.$inject=["$q","$state","$stateParams","stateAccount","decodeUriFilter","Mailbox"],r.$inject=["$transition$","encodeUriFilter","Mailbox"],l.$inject=["$q","$state","Mailbox","stateMailbox"],i.$inject=["$q","Mailbox"],n.$inject=["$q","Mailbox","decodeUriFilter","$stateParams"],s.$inject=["Mailbox","encodeUriFilter","$stateParams","$state","stateMailbox","stateMessages"],c.$inject=["$stateParams","stateMailbox"],u.$inject=["stateMailbox"],d.$inject=["$window","$transitions","$log","$state","Mailbox"]}();
//# sourceMappingURL=Mailer.js.map