!function(){"use strict";functiona(a,h){a.state("app",{url:"/addressbooks",abstract:!0,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:b}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:c}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:d}}).state("app.addressbook.card",{url:"/:cardId",abstract:!0,views:{card:{template:"<ui-view/>"}},resolve:{stateCard:e},onEnter:f,onExit:g}).state("app.addressbook.card.view",{url:"/view",views:{"card@app.addressbook":{templateUrl:"UIxContactViewTemplate",controller:"CardController",controllerAs:"editor"}}}).state("app.addressbook.card.editor",{url:"/edit",views:{"card@app.addressbook":{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}}}),h.otherwise("/addressbooks/personal")}functionb(a){returna.$findAll(window.contactFolders)}functionc(a,b,c,d){vare=_.find(d.$findAll(),function(a){returna.id==c.addressbookId});returne?(deletee.selectedCard,e.$reload(),e):a.reject("Addressbook "+c.addressbookId+" not found")}functiond(a,b,c){vard="v"+a.contactType,e=newc({pid:a.addressbookId,c_component:d});returnb.selectedCard=!0,e}functione(a,b,c){vard;return(d=_.find(c.$cards,function(a){returna.id==b.cardId}))?d.$reload():voida.go("app.addressbook")}functionf(a,b){b.selectedCard=a.cardId}functiong(a){deletec.selectedCard}functionh(a,b,c){a.$on("$stateChangeError",function(a,d,e,f,g,h){b.error(h),c.go("app.addressbook",{addressbookId:"personal"})}),a.$on("$routeChangeError",function(a,c,d,e){b.error(a,c,d,e)})}angular.module("SOGo.ContactsUI",["ngCookies","ui.router","angularFileUpload","ck","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(a).run(h),a.$inject=["$stateProvider","$urlRouterProvider"],b.$inject=["AddressBook"],c.$inject=["$q","$state","$stateParams","AddressBook"],d.$inject=["$stateParams","stateAddressbook","Card"],e.$inject=["$state","$stateParams","stateAddressbook"],f.$inject=["$stateParams","stateAddressbook"],g.$inject=["stateAddressbook"],h.$inject=["$rootScope","$log","$state"]}(),function(){"use strict";functiona(a,b,c,d,e,f,g,h,i,j,k,m,n,o){functionp(a){d.go("app.addressbook.card.view",{cardId:a.id})}functionq(a,b){b.selected=!b.selected,E.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}functionr(a){d.go("app.addressbook.new",{contactType:a})}functions(){_.forEach(E.selectedFolder.$cards,function(a){a.selected=!1}),E.mode.multiple=0}functiont(){k.confirm(l("Warning"),l("Are you sure you want to delete the selected contacts?"),{ok:l("Delete")}).then(function(){vara=_.filter(E.selectedFolder.$cards,function(a){returna.selected});E.selectedFolder.$deleteCards(a).then(function(){E.mode.multiple=0,E.selectedFolder.selectedCard||d.go("app.addressbook")})})}functionu(a,b){varc,e,f,h,i,j,k;c=E.selectedFolder,i=!1,e=c.$selectedCards(),f=_.filter(e,function(a){returna.$isCard()}),f.length!=e.length&&g.show(g.simple().content(l("Lists can't be moved or copied.")).position("top right").hideDelay(2e3)),f.length&&("copy"==a?(j=c.$copyCards(f,b),k=l("%{0} card(s) copied",f.length)):(j=c.$moveCards(f,b),k=l("%{0} card(s) moved",f.length),h=_.map(f,"id"),i=c.selectedCard&&h.indexOf(c.selectedCard)>=0),j.then(function(){i&&d.go("app.addressbook"),g.show(g.simple().content(k).position("top right").hideDelay(2e3))}))}functionv(a){u("copy",a)}functionw(a){u("move",a)}functionx(){_.forEach(E.selectedFolder.$cards,function(a){a.selected=!0}),E.mode.multiple=E.selectedFolder.$cards.length}functiony(a){E.selectedFolder.$filter("",{sort:a})}functionz(a){returnj.$query.sort==a}functionA(){E.mode.search=!1,E.selectedFolder.$filter("")}functionB(a,b){h.$findAll().then(function(c){vard=_.find(c,function(a){if(0===a.id)returna