!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,p){functionq(a){a.push(n.createHotkey({key:l("key_create_card"),description:l("Create a new address book card"),callback:angular.bind(K,t,"card")})),a.push(n.createHotkey({key:l("key_create_list"),description:l("Create a new list"),callback:angular.bind(K,t,"list")})),a.push(n.createHotkey({key:"space",description:l("Toggle item"),callback:s})),a.push(n.createHotkey({key:"up",description:l("View next item"),callback:v})),a.push(n.createHotkey({key:"down",description:l("View previous item"),callback:w})),a.push(n.createHotkey({key:"shift+up",description:l("Add next item to selection"),callback:x})),a.push(n.createHotkey({key:"shift+down",description:l("Add previous item to selection"),callback:y})),a.push(n.createHotkey({key:"backspace",description:l("Delete selected card or address book"),callback:z})),_.forEach(a,function(a){n.registerHotkey(a)})}functionr(a){d.go("app.addressbook.card.view",{cardId:a.id})}functions(a,b){b||(b=K.selectedFolder.$selectedCard()),b.selected=!b.selected,K.mode.multiple+=b.selected?1:-1,a.preventDefault(),a.stopPropagation()}functiont(a){d.go("app.addressbook.new",{contactType:a})}functionu(){_.forEach(K.selectedFolder.$cards,function(a){a.selected=!1}),K.mode.multiple=0}functionv(a){varb=K.selectedFolder.$selectedCardIndex();returnangular.isDefined(b)?b--:b=K.selectedFolder.$cards.length()-1,b>-1&&r(K.selectedFolder.$cards[b]),K.selectedFolder.$topIndex>0&&K.selectedFolder.$topIndex--,a.preventDefault(),b}functionw(a){varb=K.selectedFolder.$selectedCardIndex();returnangular.isDefined(b)?b++:b=0,b<K.selectedFolder.$cards.length?r(K.selectedFolder.$cards[b]):b=-1