!function(){"use strict";function e(e,t){e.state("app",{url:"/addressbooks",abstract:!0,views:{addressbooks:{templateUrl:"UIxContactFoldersView",controller:"AddressBooksController",controllerAs:"app"}},resolve:{stateAddressbooks:o}}).state("app.addressbook",{url:"/:addressbookId",views:{addressbook:{templateUrl:"addressbook",controller:"AddressBookController",controllerAs:"addressbook"}},resolve:{stateAddressbook:s}}).state("app.addressbook.new",{url:"/{contactType:(?:card|list)}/new",params:{refs:{array:!0}},views:{card:{templateUrl:"UIxContactEditorTemplate",controller:"CardController",controllerAs:"editor"}},resolve:{stateCard:r}}).state("app.addressbook.card",{url:"/:cardId",abstract:!0,views:{card:{template:""}},resolve:{stateCard:d},onEnter:n,onExit:i}).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"}}}),t.rules.otherwise({state:"app.addressbook",params:{addressbookId:"personal"}})}function o(e){return e.$findAll(window.contactFolders)}function s(e,t,o,s){s=_.find(s.$findAll(),function(e){return e.id==o.addressbookId});return s?(delete s.selectedCard,s.$reload(),s):e.reject("Addressbook "+o.addressbookId+" not found")}function r(e,t,o){var s="v"+e.contactType,e=new o({pid:e.addressbookId,c_component:s,refs:e.refs});return t.selectedCard=!0,e}function d(t,o,s){return s.$futureAddressBookData.then(function(){var e=_.find(s.$cards,function(e){return e.id==o.cardId});if(e)return e.$reload();t.go("app.addressbook")})}function n(e,t){t.selectedCard=e.cardId}function i(e){delete s.selectedCard}function t(e,t,o,s){e.DebugEnabled||s.defaultErrorHandler(function(){}),o.onError({to:"app.**"},function(e){"app"==e.to().name||e.ignored()||(t.error("transition error to "+e.to().name+": "+e.error().detail),s.go("app.addressbook",{addressbookId:"personal"}))})}angular.module("SOGo.ContactsUI",["ngCookies","ui.router","angularFileUpload","sgCkeditor","SOGo.Common","SOGo.PreferencesUI","SOGo.MailerUI"]).config(e).run(t),e.$inject=["$stateProvider","$urlServiceProvider"],o.$inject=["AddressBook"],s.$inject=["$q","$state","$stateParams","AddressBook"],r.$inject=["$stateParams","stateAddressbook","Card"],d.$inject=["$state","$stateParams","stateAddressbook"],n.$inject=["$stateParams","stateAddressbook"],i.$inject=["stateAddressbook"],t.$inject=["$window","$log","$transitions","$state"]}(),function(){"use strict";function e(n,i,e,a,t,c,u,o,h,s,r,d,f,p,m,g){var $,k=this,C=[];function b(e){var t=k.selectedFolder.$selectedCardIndex();return angular.isDefined(t)?(t--,0"],"to"),e.stopPropagation(),e.preventDefault()},this.newMessageWithSelectedCards=function(e,t){var o=this.selectedFolder,s=_.filter(this.selectedFolder.$cards,function(e){return e.selected}),r=[],d=[];_.forEach(s,function(t){t.$isList({expandable:!0})?angular.isDefined(t.refs)&&t.refs.length?_.forEach(t.refs,function(e){e.email.length&&d.push(e.$shortFormat())}):r.push(t.$reload().then(function(e){_.forEach(e.refs,function(e){e.email.length&&d.push(e.$shortFormat())})})):t.$loaded==h.STATUS.LOADED?t.c_mail&&d.push(t.$shortFormat()):o.$loadCard(t)&&r.push(o.$futureHeadersData.then(function(){var e=o.idsMap[t.id];!angular.isDefined(e)||(e=o.$cards[e]).c_mail&&d.push(e.$shortFormat())}))}),i.all(r).then(function(){(d=_.uniq(d)).length&&k.newMessage(e,d,t)})},this.newListWithSelectedCards=function(){var e=_.filter(this.selectedFolder.$cards,function(e){return e.selected}),t=[],o=[];_.forEach(e,function(e){e.$isList({expandable:!0})?angular.isDefined(e.refs)&&e.refs.length?_.forEach(e.refs,function(e){e.email.length&&o.push(e)}):t.push(e.$reload().then(function(e){_.forEach(e.refs,function(e){e.email.length&&o.push(e)})})):e.$$email&&e.$$email.length&&o.push(e)}),i.all(t).then(function(){(o=_.uniqBy(_.map(o,function(e){return{reference:e.id||e.reference,email:e.$$email||e.email}}),"reference")).length&&a.go("app.addressbook.new",{contactType:"list",refs:o})})}}e.$inject=["$scope","$q","$window","$state","$timeout","$mdDialog","$mdToast","Account","Card","AddressBook","sgFocus","Dialog","sgSettings","sgHotkeys","stateAddressbooks","stateAddressbook"],angular.module("SOGo.ContactsUI").controller("AddressBookController",e)}(),function(){"use strict";function e(o,a,e,t,s,r,d,n,c,i,u,h,f,p,m,g,$,k,C,b,v){var w=this,y=[];this.$onInit=function(){var t;this.activeUser=C.activeUser,this.service=$,this.saving=!1,t=y,_.forEach(["backspace","delete"],function(e){t.push(p.createHotkey({key:e,description:l("Delete selected card or address book"),callback:function(){$.selectedFolder&&!$.selectedFolder.hasSelectedCard()&&confirmDelete()}}))}),_.forEach(t,function(e){p.registerHotkey(e)})},this.$onDestroy=function(){_.forEach(y,function(e){p.deregisterHotkey(e)})},this.select=function(e,t){a.params.addressbookId!=t.id&&this.editMode!=t.id&&(this.editMode=!1,$.$query.value="",i(f["gt-md"])||u("left").close(),a.go("app.addressbook",{addressbookId:t.id}))},this.newAddressbook=function(){k.prompt(l("New Addressbook..."),l("Name of the Address Book")).then(function(e){var t=new $({name:e,isEditable:!0,isRemote:!1,owner:UserLogin});t.$id().then(function(){$.$add(t)}).catch(_.noop)})},this.edit=function(e){e.isRemote||(this.editMode=e.id,this.originalAddressbook=e.$omit(),m("addressBookName_"+e.id))},this.revertEditing=function(e){e.name=this.originalAddressbook.name,this.editMode=!1},this.save=function(e){var t=e.name;!this.saving&&t&&0",'
',' error_outline'," "+l("Select a vCard or LDIF file.")+"","
",""].join(""),position:"top right",hideDelay:3e3}),e}this.uploader=new h({url:ApplicationBaseURL+[t.id,"import"].join("/"),autoUpload:!0,queueLimit:1,filters:[{name:o,fn:o}],onSuccessItem:function(e,t,o,s){var r;d.hide(),0===t.imported?r=l("No card was imported."):(r=l("A total of %{0} cards were imported in the addressbook.",t.imported),$.selectedFolder.$reload()),c.show(c.simple().textContent(r).position("top right").hideDelay(3e3))},onErrorItem:function(e,t,o,s){c.show({template:["",'
',' error_outline'," "+l("An error occured while importing contacts.")+"","
","
"].join(""),position:"top right",hideDelay:3e3})}}),this.close=function(){d.hide()}}n.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:"UIxContactsImportDialog",controller:o,controllerAs:"$CardsImportDialogController",locals:{folder:t}}),o.$inject=["scope","$mdDialog","folder"]},this.showLinks=function(e){function t(e,t){this.addressbook=t,this.close=function(){e.hide()}}(e.urls?o.when():$.$reloadAll()).then(function(){n.show({parent:angular.element(document.body),clickOutsideToClose:!0,escapeToClose:!0,templateUrl:e.id+"/links",controller:t,controllerAs:"links",locals:{addressbook:e}})}),t.$inject=["$mdDialog","addressbook"]},this.showProperties=function(e){function t(e,t,o){var s=this;s.addressbook=new $(o.$omit()),s.saveProperties=function(){s.addressbook.$save().then(function(){o.init(s.addressbook.$omit()),t.hide()})},s.close=function(){t.cancel()}}n.show({templateUrl:e.id+"/properties",controller:t,controllerAs:"properties",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAddressBook:e}}).catch(function(){}),t.$inject=["$scope","$mdDialog","srcAddressBook"]},this.share=function(e){e.$acl.$users().then(function(){n.show({templateUrl:e.id+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:e.$acl.users,User:b,folder:e}})})},this.subscribeToFolder=function(e){$.$subscribe(e.owner,e.name).then(function(e){c.show(c.simple().textContent(l("Successfully subscribed to address book")).position("top right").hideDelay(3e3))})},this.isDroppableFolder=function(e,t){return t.id!=e.id&&(t.isOwned||t.acls.objectCreator)},this.dragSelectedCards=function(e,t,o){var s,r,d=t.id,n=!1,i=e.$selectedCards();0===i.length&&(i=[e.$selectedCard()]),(t=_.filter(i,function(e){return e.$isCard()})).length!=i.length&&c.show(c.simple().textContent(l("Lists can't be moved or copied.")).position("top right").hideDelay(2e3)),t.length&&("copy"==o?(s=e.$copyCards(t,d),r=l("%{0} card(s) copied",t.length)):(s=e.$moveCards(t,d),r=l("%{0} card(s) moved",t.length),t=_.map(t,"id"),n=e.selectedCard&&0<=t.indexOf(e.selectedCard)),s.then(function(){n&&a.go("app.addressbook"),c.show(c.simple().textContent(r).position("top right").hideDelay(2e3))}))}}e.$inject=["$q","$state","$scope","$rootScope","$stateParams","$timeout","$window","$mdDialog","$mdToast","$mdMedia","$mdSidenav","FileUploader","sgConstant","sgHotkeys","sgFocus","Card","AddressBook","Dialog","sgSettings","User","stateAddressbooks"],angular.module("SOGo.ContactsUI").controller("AddressBooksController",e)}(),function(){"use strict";function e(e,t,o,s,r,d,n,i,a,c,u,h,f){var p,m=this,g=[];m.card=f,m.currentFolder=d.selectedFolder,m.allEmailTypes=n.$EMAIL_TYPES,m.allTelTypes=n.$TEL_TYPES,m.allUrlTypes=n.$URL_TYPES,m.allAddressTypes=n.$ADDRESS_TYPES,m.categories={},m.userFilterResults=[],m.showRawSource=!1,p=g,_.forEach(["backspace","delete"],function(e){p.push(a.createHotkey({key:e,description:l("Delete"),callback:function(e){m.currentFolder.acls.objectEraser&&0===m.currentFolder.$selectedCount()&&m.confirmDelete(),e.preventDefault()}}))}),_.forEach(p,function(e){a.registerHotkey(e)}),m.card.hasCertificate&&m.card.$certificate().then(function(e){m.certificate=e},function(){delete m.card.hasCertificate}),e.$on("$destroy",function(){_.forEach(g,function(e){a.deregisterHotkey(e)})}),this.transformCategory=function(e){return angular.isString(e)?{value:e}:e},this.removeAttribute=function(e,t,o){this.card.$delete(t,o),e.$setDirty()},this.addOrg=function(){var e=this.card.$addOrg({value:""});c("org_"+e)},this.addBirthday=function(){this.card.birthday=new Date},this.addScreenName=function(){this.card.$addScreenName("")},this.addEmail=function(){var e=this.card.$addEmail("");c("email_"+e)},this.addPhone=function(){var e=this.card.$addPhone("");c("phone_"+e)},this.addUrl=function(){var e=this.card.$addUrl("","https://www.fsf.org/");c("url_"+e)},this.canAddCustomField=function(){return _.keys(this.customFields).length<4},this.addCustomField=function(){angular.isDefined(this.card.customFields)||(this.card.customFields={});var e=_.pullAll(["1","2","3","4"],_.keys(this.customFields));this.card.customFields[e[0]]=""},this.deleteCustomField=function(e){delete this.card.customFields[e]},this.addAddress=function(){var e=this.card.$addAddress("","","","","","","","");c("address_"+e)},this.userFilter=function(e,t){return e.length"+o.$fullname()+""),{ok:l("Delete")}).then(function(){d.selectedFolder.$deleteCards([o]).then(function(){close()},function(e,t){i.alert(l("Warning"),l('An error occured while deleting the card "%{0}".',o.$fullname()))})})},this.toggleRawSource=function(e){this.showRawSource||this.rawSource?this.showRawSource=!this.showRawSource:n.$$resource.post(this.currentFolder.id+"/"+this.card.id,"raw").then(function(e){m.rawSource=e,m.showRawSource=!0})}}e.$inject=["$scope","$timeout","$window","$mdDialog","sgSettings","AddressBook","Card","Dialog","sgHotkeys","sgFocus","$state","$stateParams","stateCard"],angular.module("SOGo.ContactsUI").controller("CardController",e)}(),function(){"use strict";angular.module("SOGo.Common").directive("sgAddress",function(){return{restrict:"A",scope:{data:"=sgAddress"},controller:["$scope",function(e){e.addressLines=function(e){var t=[],o=[];return e.street&&t.push(e.street),e.street2&&t.push(e.street2),e.locality&&o.push(e.locality),e.region&&o.push(e.region),0")}}],template:'
'}})}(); //# sourceMappingURL=Contacts.js.map