!function(){"use strict";functione(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")}functiont(e,t,a){varo=a.$findAll(e.mailAccounts),r=[];returnangular.forEach(o,function(e,t){vara=e.$getMailboxes();0===t?r.push(a.then(function(t){returne})):r.push(e)}),t.all(r)}functiona(e,t){return_.find(t,function(t){returnt.id==e.accountId})}functiono(e,t,a,o,r,l){vari,n,s=r(a.mailboxId);returnn=function(e){vart=_.find(e,function(e){returne.path==s});returnt||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")}functionr(e,t,a){returne.injector().getAsync("stateAccount").then(function(o){returno.$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"))})}functionl(e,t,a,o){returna.$virtualMode?[]:o?o.$filter().catch(function(){returne.reject("Mailbox not found")}):e.reject("Mailbox doesn't exist")}functioni(e,t){returnt.$virtualMode?t.selectedFolder:e.reject("No virtual mailbox defined")}functionn(e,t,a,o){varr=a(o.mailboxId);returnt.$virtualMode?(t.selectedFolder.resetSelectedMessage(),_.find(t.selectedFolder.$mailboxes,function(e){returne.path==r})):e.reject("No virtual mailbox defined for message")}functions(e,t,a,o,r,l){vari;if(i=_.find(r.$messages,function(e){returne.uid==parseInt(a.messageId)}))returni.$reload({useCache:!0});o.go("mail.account.mailbox",{accountId:r.$account.id,mailboxId:t(r.path)})}functionc(e,t){t.selectedMessage=parseInt(e.messageId)}functionu(e){deletee.selectedMessage}functiond(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"]}();