2 lines
84 KiB
JavaScript
2 lines
84 KiB
JavaScript
!function(){"use strict";function c(e){"function"!=typeof e.then&&(angular.extend(this,e),_.forEach(this.identities,function(e){var t;e.fullName&&e.email?e.full=e.fullName+" <"+e.email+">":e.email?e.full="<"+e.email+">":e.full="",e.signature&&(t=angular.element("<div>"+e.signature+"</div>"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim())}),c.$log.debug("Account: "+JSON.stringify(e,void 0,2)))}c.$factory=["$q","$timeout","$log","sgSettings","Resource","Preferences","Mailbox","Message",function(e,t,s,n,i,a,o,r){return angular.extend(c,{$q:e,$timeout:t,$log:s,$$resource:new i(n.activeUser("folderURL")+"Mail",n.activeUser()),$Preferences:a,$Mailbox:o,$Message:r}),c}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").factory("Account",c.$factory),c.$findAll=function(e){return e?c.$unwrapCollection(e):c.$accounts?c.$q.when(c.$accounts):c.$$resource.fetch("","mailAccounts").then(function(e){return c.$unwrapCollection(e)})},c.$unwrapCollection=function(e){var s=[];return angular.forEach(e,function(e,t){e.id=t,s[t]=new c(e)}),c.$accounts=s},c.refreshUnseenCount=function(e){var t,s=1===c.$Preferences.defaults.SOGoMailFetchAllUnseenCountFolders,n=c.$Preferences.defaults.SOGoRefreshViewCheck;if(s)t=[];else{if(!e)throw Error("SOGoMailFetchAllUnseenCountFolders is disabled and no folders list provided");t=e}_.forEach(c.$accounts,function(e){s?_.forEach(e.$$flattenMailboxes,function(e){t.push(e.id)}):(_.includes(t,e.id+"/folderINBOX")||t.push(e.id+"/folderINBOX"),_.forEach(e.$$flattenMailboxes,function(e){angular.isDefined(e.unseenCount)&&!_.includes(t,e.id)&&t.push(e.id)}))}),c.$$resource.post("","unseenCount",{mailboxes:t}).then(function(t){_.forEach(c.$accounts,function(e){_.forEach(e.$$flattenMailboxes,function(e){t[e.id]&&(e.unseenCount=t[e.id])})})}),n&&"manually"!=n&&(c.$refreshUnseenCount&&c.$timeout.cancel(c.$refreshUnseenCount),c.$refreshUnseenCount=c.$timeout(angular.bind(this,c.refreshUnseenCount,e),1e3*n.timeInterval()))},c.prototype.getLength=function(){return this.$expanded?this.$flattenMailboxes().length:0},c.prototype.getItemAtIndex=function(e){var t=this.$flattenMailboxes();return 0<=e&&e<t.length?t[e]:null},c.prototype.$getMailboxes=function(e){var a=this,t=e&&e.reload;return this.$mailboxes&&!t?c.$q.when(this.$mailboxes):(!t&&this.$futureMailboxesData||(this.$futureMailboxesData=c.$Mailbox.$find(this,e).then(function(e){var s=a.$flattenMailboxes({all:!0});a.$mailboxes=e,a.$expanded=!1;var n=function(e){_.forEach(e,function(e){var t=_.find(s,["id",e.id]);t&&(e.unseenCount=t.unseenCount),e.children&&0<e.children.length&&n(e.children)})};n(a.$mailboxes);var t,i=function(e){_.forEach(e,function(e){e.$expanded=0<=t.indexOf("/"+e.id),e.children&&0<e.children.length&&i(e.children)})};if(c.$Preferences.settings.Mail.ExpandedFolders){if(angular.isString(c.$Preferences.settings.Mail.ExpandedFolders))try{t=angular.fromJson(c.$Preferences.settings.Mail.ExpandedFolders)}catch(e){c.$log.warn("Can't parse list of expanded folders. String was: "+c.$Preferences.settings.Mail.ExpandedFolders),t=[]}else t=c.$Preferences.settings.Mail.ExpandedFolders;a.$expanded=0<=t.indexOf("/"+a.id),0<t.length&&i(a.$mailboxes)}return c.$accounts&&(a.$expanded|=1==c.$accounts.length),a.$flattenMailboxes({reload:!0}),a.$mailboxes})),this.$futureMailboxesData)},c.prototype.$flattenMailboxes=function(t){var s=[],n=[],i=function(e){_.forEach(e,function(e){s.push(e),(t&&t.all||e.$expanded)&&e.children&&0<e.children.length&&i(e.children)})};return!this.$$flattenMailboxes||t&&(t.reload||t.all)?(i(this.$mailboxes),t&&t.all||(this.$$flattenMailboxes=s,t&&t.saveState&&(_.forEach(c.$accounts,function(e){e.$expanded&&n.push("/"+e.id),_.reduce(e.$$flattenMailboxes,function(e,t){return t.$expanded&&e.push("/"+t.id),e},n)}),c.$$resource.post(null,"saveFoldersState",n)))):s=this.$$flattenMailboxes,s},c.prototype.$getMailboxByType=function(s){var n=function(e){var t=_.find(e,function(e){return e.type==s});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=n(e.children))}),t};return n(this.$mailboxes)},c.prototype.$getMailboxByPath=function(s){var n=function(e){var t=_.find(e,function(e){return e.path==s});return t||angular.forEach(e,function(e){!t&&e.children&&0<e.children.length&&(t=n(e.children))}),t};return n(this.$mailboxes)},c.prototype.$newMailbox=function(e,t){var s=this;return c.$$resource.post(e.toString(),"createFolder",{name:t}).then(function(){s.$getMailboxes({reload:!0})})},c.prototype.getTextSignature=function(e){var t;return e.signature?(t=angular.element("<div>"+e.signature+"</div>"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()):e.textSignature="",e.textSignature},c.prototype.$certificate=function(){var t=this;return this.security&&this.security.hasCertificate?this.$$certificate?c.$q.when(this.$$certificate):c.$$resource.fetch(this.id.toString(),"certificate").then(function(e){return t.$$certificate=e}):c.$q.reject()},c.prototype.$removeCertificate=function(){var e=this;return c.$$resource.fetch(this.id.toString(),"removeCertificate").then(function(){e.security.hasCertificate=!1})},c.prototype.updateQuota=function(e){var t=Math.round(1e4*e.usedSpace/e.maxQuota)/100,e=l("quotasFormat").formatted(t,Math.round(e.maxQuota/10.24)/100);this.$quota={percent:t,description:e}},c.prototype.$newMessage=function(n){var i=this;return c.$$resource.fetch(this.id.toString(),"compose").then(function(e){return c.$log.debug("New message (compose): "+JSON.stringify(e,void 0,2)),new c.$Message(e.accountId,i.$getMailboxByPath(e.mailboxPath),e)}).then(function(s){return c.$$resource.fetch(s.$absolutePath({asDraft:!0}),"edit").then(function(e){var t=c.$Preferences.defaults.AuxiliaryMailAccounts[i.id];return t.security&&(t.security.alwaysSign&&(e.sign=!0),t.security.alwaysEncrypt&&(e.encrypt=!0)),c.$log.debug("New message (edit): "+JSON.stringify(e,void 0,2)),angular.extend(s.editable,e),s.isNew=!0,n&&n.mailto&&(angular.isObject(n.mailto)?angular.extend(s.editable,n.mailto):s.$parseMailto(n.mailto)),s})})},c.prototype.$addDelegate=function(e){var t=this,s=c.$q.defer(),n={uid:e.uid};return!e.uid||-1<_.indexOf(_.map(this.delegates,"uid"),e.uid)?s.resolve():c.$$resource.fetch(this.id.toString(),"addDelegate",n).then(function(){t.delegates.push(e),s.resolve(t.users)},function(e,t){s.reject(l("An error occured, please try again."))}),s.promise},c.prototype.$removeDelegate=function(t){var s=this,e={uid:t};return c.$$resource.fetch(this.id.toString(),"removeDelegate",e).then(function(){var e=_.indexOf(_.map(s.delegates,"uid"),t);0<=e&&s.delegates.splice(e,1)})},c.prototype.$omit=function(){var s={},t=[],n=!1;return angular.forEach(this,function(e,t){"constructor"!=t&&"identities"!=t&&"$"!=t[0]&&(s[t]=angular.copy(e))}),_.forEach(this.identities,function(e){e.isReadOnly||t.push(_.pick(e,["email","fullName","replyTo","signature","isDefault"])),e.isDefault&&(n=e)}),s.identities=t,n&&s.forceDefaultIdentity||delete s.forceDefaultIdentity,s}}(),function(){"use strict";function d(e,t){this.$account=e,"function"!=typeof t.then?(this.init(t),this.name&&!this.path&&(e=d.$$resource.create("createFolder",this.name),this.$unwrap(e))):this.$unwrap(t)}d.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Acl","Preferences","sgMailbox_PRELOAD","sgMailbox_BATCH_DELETE_LIMIT",function(e,t,s,n,i,a,o,r,l,c){return angular.extend(d,{$q:e,$timeout:t,$log:s,$$resource:new i(n.activeUser("folderURL")+"Mail",n.activeUser()),$Message:a,$$Acl:o,$Preferences:r,$query:{sort:"arrival",asc:0},selectedFolder:null,$refreshTimeout:null,$virtualMode:!1,$virtualPath:!1,PRELOAD:l,BATCH_DELETE_LIMIT:c}),r.settings.Mail.SortingState&&(d.$query.sort=r.settings.Mail.SortingState[0],d.$query.asc=parseInt(r.settings.Mail.SortingState[1])),d}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMailbox_PRELOAD",{LOOKAHEAD:50,SIZE:100}).constant("sgMailbox_BATCH_DELETE_LIMIT",1e3).factory("Mailbox",d.$factory),d.$find=function(e,t){t=t&&t.all?this.$$resource.fetch(e.id.toString(),"viewAll"):this.$$resource.fetch(e.id.toString(),"view");return d.$unwrapCollection(e,t)},d.$unwrapCollection=function(n,e){var s=[],i=function(e,t){t.isSentFolder=t.isSentFolder||"sent"==t.type;for(var s=0;s<t.children.length;s++)t.children[s].level=e,t.children[s]=new d(n,t.children[s]),t.isSentFolder&&(t.children[s].isSentFolder=!0),i(e+1,t.children[s])};return e.then(function(e){return d.$timeout(function(){return angular.forEach(e.mailboxes,function(e,t){e.level=0;e=new d(n,e);i(1,e),s.push(e)}),e.quotas&&n.updateQuota(e.quotas),s})})},d.$absolutePath=function(e,t){var s=[];return(s=t?_.map(t.split("/"),function(e){return"folder"+e.asCSSIdentifier()}):s).splice(0,0,e),s.join("/")},d.prototype.init=function(e){(angular.isUndefined(this.uidsMap)||e.headers)&&(this.$isLoading=!0,this.$messages=[],this.uidsMap={},this.$visibleMessages=this.$messages,this.$selectedMessages=[]),angular.extend(this,e),this.path&&(this.id=this.$id(),this.$acl=new d.$$Acl("Mail/"+this.id),this.threaded&&(this.$collapsedThreads=[],d.$Preferences.settings.Mail.threadsCollapsed&&d.$Preferences.settings.Mail.threadsCollapsed["/"+this.id]&&(this.$collapsedThreads=d.$Preferences.settings.Mail.threadsCollapsed["/"+this.id]))),this.$displayName=this.name,this.type&&(this.$isEditable=this.isEditable(),this.$isSpecial=!0,"inbox"==this.type?(this.$displayName=l("InboxFolderName"),this.$icon="inbox"):"draft"==this.type?(this.$displayName=l("DraftsFolderName"),this.$icon="drafts"):"sent"==this.type?(this.$displayName=l("SentFolderName"),this.$icon="send"):"trash"==this.type?(this.$displayName=l("TrashFolderName"),this.$icon="delete"):"junk"==this.type?(this.$displayName=l("JunkFolderName"),this.$icon="thumb_down"):"additional"==this.type?this.$icon="folder_shared":(this.$isSpecial=!1,this.$icon="folder")),this.$isNoInferiors=this.isNoInferiors(),angular.isUndefined(this.$shadowData)&&(this.$shadowData=this.$omit())},d.prototype.selectFolder=function(){d.$virtualMode||(d.selectedFolder=this)},d.prototype.getLength=function(){return this.$visibleMessages.length},d.prototype.getItemAtIndex=function(e){var t;return 0<=e&&e<this.$visibleMessages.length?(t=this.$visibleMessages[e],this.$lastVisibleIndex=Math.max(0,e-3),this.$loadMessage(t.uid),t):null},d.prototype.$id=function(){return d.$absolutePath(this.$account.id,this.path)},d.prototype.selectedMessages=function(e){return e&&e.updateCache&&(this.$selectedMessages=_.filter(this.$messages,function(e){return e.selected})),this.$selectedMessages},d.prototype.selectedCount=function(){return this.$selectedMessages.length},d.prototype.$unselectMessages=function(){_.forEach(this.$selectedMessages,function(e){e.selected=!1}),this.$selectedMessages=[]},d.prototype.isSelectedMessage=function(e){return this.$selectedMessage==e},d.prototype.selectedMessage=function(){var t=this;return _.find(this.$messages,function(e){return e.uid==t.$selectedMessage})},d.prototype.$selectedMessageIndex=function(){return this.uidsMap[this.$selectedMessage]},d.prototype.hasSelectedMessage=function(){return angular.isDefined(this.$selectedMessage)},d.prototype.$filter=function(e,t){var s="view",n={};angular.isDefined(this.unseenCount)||(this.unseenCount=0),this.$isLoading=!0,d.$refreshTimeout&&d.$timeout.cancel(d.$refreshTimeout),e&&angular.extend(d.$query,e),angular.extend(n,{sortingAttributes:d.$query}),angular.isDefined(t)?(n.filters=_.reject(angular.copy(t),function(e){return!e.searchInput||0===e.searchInput.length}),_.forEach(n.filters,function(e){var t=e.searchBy.match(/(\w+)_or_(\w+)/);t&&(n.sortingAttributes.match="OR",e.searchBy=t[1],(e=angular.copy(e)).searchBy=t[2],n.filters.push(e))})):!e&&this.$syncToken&&(s="changes",n.syncToken=this.$syncToken),d.$virtualMode||(e=d.$Preferences.defaults.SOGoRefreshViewCheck)&&"manually"!=e&&(t=angular.bind(this,d.prototype.$filter,null,t),d.$refreshTimeout=d.$timeout(t,1e3*e.timeInterval()));s=d.$$resource.post(this.id,s,n);return this.$unwrap(s)},d.prototype.$loadMessage=function(e){var t,s,n,i=this.uidsMap[e],a=this.$messages.length,o=!1;if(angular.isDefined(this.uidsMap[e])&&i<this.$messages.length&&(angular.isDefined(this.$messages[i].subject)&&(o=!0),t=Math.min(i+d.PRELOAD.LOOKAHEAD,a-1),angular.isDefined(this.$messages[t].subject)||angular.isDefined(this.$messages[t].loading)?(n=Math.max(i-d.PRELOAD.LOOKAHEAD,0),angular.isDefined(this.$messages[n].subject)||angular.isDefined(this.$messages[n].loading)||(t=i,i=Math.max(i-d.PRELOAD.SIZE,0))):t=Math.min(i+d.PRELOAD.SIZE,a-1),!angular.isDefined(this.$messages[i].subject)&&!angular.isDefined(this.$messages[i].loading)||!angular.isDefined(this.$messages[t].subject)&&!angular.isDefined(this.$messages[t].loading))){for(s=[];i<t&&i<a;i++)angular.isDefined(this.$messages[i].subject)||this.$messages[i].loading?t++:(s.push(this.$messages[i].uid),this.$messages[i].loading=!0);s.length&&(d.$log.debug("Loading UIDs "+s.join(" ")),n=d.$$resource.post(this.id,"headers",{uids:s}),this.$unwrapHeaders(n))}return o},d.prototype.isEditable=function(){return"folder"==this.type},d.prototype.isNoInferiors=function(){return 0<=this.flags.indexOf("noinferiors")},d.prototype.isNoSelect=function(){return 0<=this.flags.indexOf("noselect")},d.prototype.getClassName=function(e){return!1},d.prototype.$rename=function(){var n,e,i,a,o=this;return this.name==this.$shadowData.name?d.$q.when():(e=(n=function(e,t){var s=null;return _.find(t,function(e){return e.path==o.path})?s=e:angular.forEach(t,function(e){!s&&e.children&&0<e.children.length&&(s=n(e,e.children))}),s})(null,this.$account.$mailboxes),i=null===e?this.$account.$mailboxes:e.children,a=_.indexOf(_.map(i,"id"),this.id),this.$save().then(function(e){var t=o.path;o.init(e),i.splice(a,1),e=_.find(i,function(e){return"folder"==e.type&&0<e.name.localeCompare(o.name)}),a=e?_.indexOf(_.map(i,"id"),e.id):i.length,i.splice(a,0,o);var s=new RegExp("^"+t),n=function(e){_.forEach(e.children,function(e){e.path=e.path.replace(s,o.path),e.id=e.$id(),n(e)})};n(o)}))},d.prototype.$compact=function(){var t=this;return d.$$resource.post(this.id,"expunge").then(function(e){return e.quotas&&t.$account.updateQuota(e.quotas),!0})},d.prototype.$canFolderAs=function(){return"folder"==this.type},d.prototype.$setFolderAs=function(e){return d.$$resource.post(this.id,"setAs"+e+"Folder")},d.prototype.$emptyTrash=function(){var t=this;return d.$$resource.post(this.id,"emptyTrash").then(function(e){t.$messages=[],t.uidsMap={},t.unseenCount=0,angular.isDefined(t.children)&&t.children.length&&t.$account.$getMailboxes({reload:!0}),e.quotas&&t.$account.updateQuota(e.quotas)})},d.prototype.$markAsRead=function(){var e=this;return d.$$resource.post(this.id,"markRead").then(function(){e.unseenCount=0,_.forEach(e.$messages,function(e){e.isread=!0})})},d.prototype.$flagMessages=function(e,t,s){s={msgUIDs:_.map(e,"uid"),flags:t,operation:s};return d.$$resource.post(this.id,"addOrRemoveLabel",s).then(function(){return e})},d.prototype.saveSelectedMessages=function(){var e=_.filter(this.$messages,function(e){return e.selected}),e=_.map(e,"uid");l("Saved Messages.zip");return d.$$resource.download(this.id,"saveMessages",{uids:e})},d.prototype.exportFolder=function(){var e={filename:this.name+".zip"};return d.$$resource.open(this.id,"exportFolder",null,e)},d.prototype.$delete=function(e){var t=this;return d.$$resource.post(this.id,"delete",e).then(function(){return t.$account.$getMailboxes({reload:!0}),!0})},d.prototype.$_deleteMessages=function(n){var i=this,a=this.$messages.length;return _.forEachRight(this.$messages,function(t,e){var s=_.findIndex(n,function(e){return t.uid==e});-1<s?(n.splice(s,1),delete i.uidsMap[t.uid],t.uid==i.$selectedMessage&&delete i.$selectedMessage,i.$messages.splice(e,1),e<a&&(a=e)):i.uidsMap[t.uid]-=n.length}),this.threaded&&this.updateVisibleMessages(),a},d.prototype.$deleteMessages=function(e,i){var a,o=this,r=d.BATCH_DELETE_LIMIT;return a=_.map(e,"uid"),function t(e,s){var n=a.slice(e,s),e={uids:n};return i&&angular.extend(e,i),d.$$resource.post(o.id,"batchDelete",e).then(function(e){return e.unseenCount&&(o.unseenCount=e.unseenCount),s<a.length?(o.$_deleteMessages(n),t(s,Math.min(s+r,a.length))):(e.quotas&&o.$account.updateQuota(e.quotas),o.$_deleteMessages(n))})}(0,Math.min(r,a.length)).then(function(e){return o.$selectedMessages=[],e})},d.prototype.$markOrUnMarkMessagesAsJunk=function(e){var t=_.map(e,"uid"),e="junk"==this.type?"markMessagesAsNotJunk":"markMessagesAsJunk";return d.$$resource.post(this.id,e,{uids:t})},d.prototype.$copyMessages=function(e,t){var s=this,e=_.map(e,"uid");return d.$$resource.post(this.id,"copyMessages",{uids:e,folder:t}).then(function(e){e.quotas&&s.$account.updateQuota(e.quotas)})},d.prototype.$moveMessages=function(e,t){var s=this,n=_.map(e,"uid");return d.$$resource.post(this.id,"moveMessages",{uids:n,folder:t}).then(function(e){return e.unseenCount&&(s.unseenCount=e.unseenCount),s.$selectedMessages=[],s.$_deleteMessages(n)})},d.prototype.$reset=function(){var s=this;angular.forEach(this.$shadowData,function(e,t){delete s[t]}),angular.extend(this,this.$shadowData),this.$shadowData=this.$omit()},d.prototype.$move=function(e){var t=this;return d.$$resource.post(this.id,"move",{parent:e}).finally(function(){return t.$account.$getMailboxes({reload:!0}),!0})},d.prototype.$save=function(){var t=this;return d.$$resource.save(this.id,this.$omit()).then(function(e){return t.$shadowData=t.$omit(),d.$log.debug(JSON.stringify(e,void 0,2)),e},function(e){return d.$log.error(JSON.stringify(e.data,void 0,2)),t.$reset(),e.data})},d.prototype.$newMailbox=function(e,t){return this.$account.$newMailbox(e,t)},d.prototype.$omit=function(){var s={};return angular.forEach(this,function(e,t){"constructor"!=t&&"children"!=t&&"headers"!=t&&"uids"!=t&&"uidsMap"!=t&&"$"!=t[0]&&(s[t]=e)}),s},d.prototype.updateVisibleMessages=function(){var s=!1;this.threaded&&(this.$visibleMessages=_.filter(this.$messages,function(e,t){return e.first?s=e.collapsed:e.level<0&&(s=!1),e.first||!1===s}))},d.prototype.$unwrap=function(e){var l=this,c=d.$q.defer();return this.$futureMailboxData=e,this.$futureMailboxData.then(function(o){var r=_.map(l.$selectedMessages,"uid");d.$timeout(function(){var a,e,s,t;if((!o.uids||l.$topIndex>o.uids.length-1)&&(l.$topIndex=0),o.syncToken&&(l.$syncToken=o.syncToken),o.deleted&&(_.forEachRight(o.deleted,function(e,t){e=l.uidsMap[e.toString()];(e<0||!l.$messages[e])&&o.deleted.splice(t,1)}),o.deleted.length&&l.$_deleteMessages(o.deleted)),o.changed){var n,i=0;if(_.forEach(o.changed,function(e){angular.isUndefined(l.uidsMap[e.toString()])&&(l.uidsMap[e]=i,l.$messages.splice(i,0,{uid:e}),i++)}),0<i){for(n=i;n<l.$messages.length;n++)t=l.$messages[n],l.uidsMap[t.uid]+=i;l.threaded&&l.updateVisibleMessages()}}o.unseenCount&&(l.unseenCount=o.unseenCount),o.uids&&(d.$log.debug("unwrapping "+o.uids.length+" messages"),l.init(o),l.threaded&&(a=l.uids[0],l.uids.splice(0,1)),_.reduce(l.uids,function(e,t,s){var n;if(l.threaded)if(1===(n=_.zipObject(a,t)).first){for(var i=1;l.uids[s+i]&&0<=l.uids[s+i][1]&&1!==l.uids[s+i][2];)i++;n.count=i,n.collapsed=!1,0<=l.$collapsedThreads.indexOf(n.uid.toString())&&(n.collapsed=!0)}else!isNaN(n.level)&&0<=n.level&&(n.threadMember=!0);else n={uid:t};return l.uidsMap[n.uid]=s,n.selected=-1<r.indexOf(n.uid),e.push(n),e},l.$messages)),o.headers&&(s=_.invokeMap(o.headers.splice(0,1)[0],"toLowerCase"),e=o.headers,_.forEach(e,function(e){var t=_.zipObject(s,e),e=l.uidsMap[t.uid.toString()];l.$messages[e]instanceof d.$Message||(l.$messages[e]=new d.$Message(l.$account.id,l,l.$messages[e],!0)),l.$messages[e].init(t)})),d.$log.debug("mailbox "+l.id+" ready"),l.$isLoading=!1,c.resolve(l.$messages)})},function(e){d.$log.error(e),angular.extend(l,e),l.isError=!0,l.$isLoading=!1,c.reject()}),c.promise},d.prototype.$unwrapHeaders=function(e){var n=this;e.then(function(e){d.$timeout(function(){var t,s;0<e.length&&(t=_.invokeMap(e[0],"toLowerCase"),e.splice(0,1),_.forEach(e,function(e){e=_.zipObject(t,e),s=n.uidsMap[e.uid.toString()],angular.isDefined(s)&&(n.$messages[s]instanceof d.$Message||(n.$messages[s]=new d.$Message(n.$account.id,n,n.$messages[s],!0)),n.$messages[s].init(e))}),n.threaded&&n.updateVisibleMessages())})})},d.prototype.$updateSubscribe=function(){var e=this.subscribed?"subscribe":"unsubscribe";d.$$resource.post(this.id,e)}}(),function(){"use strict";function r(e,t,s,n){this.accountId=e,this.$mailbox=t,this.$hasUnsafeContent=!1,this.$loadUnsafeContent=!1,this.editable={to:[],cc:[],bcc:[]},this.selected=!1,"function"!=typeof s.then?(!angular.isUndefined(n)&&n||this.init(s),this.uid=parseInt(s.uid),this.selected=!!s.selected,this.level=parseInt(s.level),this.first=1===parseInt(s.first),this.flags=[],this.first?(this.threadCount=parseInt(s.count),this.collapsed=!0===s.collapsed):!isNaN(this.level)&&0<=this.level&&(this.threadMember=!0)):this.$unwrap(s)}r.$factory=["$q","$timeout","$log","sgSettings","sgMessage_STATUS","Resource","Preferences",function(e,t,s,n,i,a,o){return angular.extend(r,{STATUS:i,$q:e,$timeout:t,$log:s,$$resource:new a(n.activeUser("folderURL")+"Mail",n.activeUser()),$Preferences:o,$avatar:angular.bind(o,o.avatar)}),o.defaults.SOGoMailLabelsColors?r.$tags=o.defaults.SOGoMailLabelsColors:r.$tags={},o.defaults.SOGoMailDisplayRemoteInlineImages&&"always"==o.defaults.SOGoMailDisplayRemoteInlineImages&&(r.$displayRemoteInlineImages=!0),r}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMessage_STATUS",{NOT_LOADED:0,DELAYED_LOADING:1,LOADING:2,LOADED:3,DELAYED_MS:300}).factory("Message",r.$factory),r.filterTags=function(e,s){var n=new RegExp(e,"i"),i=[];return _.forEach(_.keys(r.$tags),function(e){var t=r.$tags[e];-1!=t[0].search(n)&&(_.includes(s,e)||i.push({name:e,description:t[0],color:t[1]}))}),i},r.prototype.init=function(e){var s=this;angular.extend(this,e),this.$formatFullAddresses(),this.$loadUnsafeContent=!1,_.forEach(this.flags,function(e,t){"$"==e.charAt(0)&&s.flags.splice(t,1,"_"+e)})},r.prototype.$absolutePath=function(e){var t=this,s=this.id;function n(){var e=_.map(t.$mailbox.path.split("/"),function(e){return"folder"+e.asCSSIdentifier()});return e.splice(0,0,t.accountId),e.join("/")}return(angular.isUndefined(this.id)||e&&e.nocache)&&(this.id=n()+"/"+this.uid,s=this.id),e&&e.asDraft&&this.draftId&&(s=n()+"/"+this.draftId),s=e&&e.withResourcePath?r.$$resource.path(s):s},r.prototype.$setUID=function(e){var t,s=this.uid||-1,n=this;s!=parseInt(e)&&(this.uid=parseInt(e),this.$absolutePath({nocache:!0}),-1<s?(s=s.toString(),angular.isDefined(this.$mailbox.uidsMap[s])&&(t=this.$mailbox.uidsMap[s],this.$mailbox.uidsMap[e]=t,delete this.$mailbox.uidsMap[s],this.$mailbox.$messages[t].uid=this.uid,_.forEach(["from","to","subject"],function(e){n.$mailbox.$messages[t][e]=n.editable[e]}))):this.$mailbox.constructor.selectedFolder&&"draft"==this.$mailbox.constructor.selectedFolder.type&&this.$mailbox.constructor.selectedFolder.$filter())},r.prototype.$formatFullAddresses=function(){var t=this,s=_.map(t.$mailbox.$account.identities,"email");_.forEach(["from","to","cc","bcc","reply-to"],function(e){_.forEach(t[e],function(e){e.name&&e.name!=e.email?(e.full=e.name+" <"+e.email+">",e.name.length<10?e.shortname=e.name:e.name.split(" ").length&&(e.shortname=_.first(_.last(e.name.split(/, */)).split(/ +/)).replace("'",""))):e.email&&(e.full="<"+e.email+">",e.shortname=e.email.split("@")[0]),e.image=r.$avatar(e.email,32),0<=_.indexOf(s,e.email)&&(e.shortname=l("me"))})})},r.prototype.$shortRecipients=function(s){var t=this,n=[],i=0,a=0;return _.forEach(["to","cc","bcc"],function(e){a+=t[e]?t[e].length:0,_.forEach(t[e],function(e,t){i<s&&n.push(e.shortname),i++})}),s<a&&n.push(l("and %{0} more...",a-s)),n.join(", ")},r.prototype.$shortAddress=function(e){var t="";return t=this[e]&&0<this[e].length?this[e][0].name||this[e][0].email||"":t},r.prototype.allowReplyAll=function(){var n=_.map(this.$mailbox.$account.identities,"email"),e=_.reduce(["to","cc","bcc","reply-to"],_.bind(function(e,t){var s=0;return this[t]?(s=this[t].length,_.forEach(this[t],function(e){0<=_.indexOf(n,e.email)&&s--}),e+s):e},this),0);return!this.isDraft&&1<e},r.prototype.loadUnsafeContent=function(){this.$loadUnsafeContent=!0,delete this.$parts},r.prototype.$content=function(){var e=this,t=[],s=function(a){a.msgclass="msg-attachment-other","UIxMailPartAlternativeViewer"==a.type?s(_.find(a.content,function(e){return a.preferredPart==e.contentType})):angular.isArray(a.content)?("UIxMailPartSignedViewer"==a.type&&1===a["supports-smime"]?e.signed={valid:a.valid,certificate:a.certificates[a.certificates.length-1],message:a.message}:"UIxMailPartEncryptedViewer"==a.type&&(a.encrypted&&(e.encrypted={valid:a.decrypted},a.decrypted?e.encrypted.message=l("This message is encrypted"):e.encrypted.message=l("This message can't be decrypted. Please make sure you have uploaded your S/MIME certificate from the mail preferences module.")),a.opaqueSigned&&(e.signed={valid:a.valid,certificate:a.certificates[a.certificates.length-1],message:a.message})),_.forEach(a.content,function(e){s(e)})):(angular.isUndefined(a.safeContent)&&(a.safeContent=a.content,e.$hasUnsafeContent|=-1<a.safeContent.indexOf(" unsafe-")),"UIxMailPartHTMLViewer"==a.type?(a.html=!0,e.$loadUnsafeContent||r.$displayRemoteInlineImages?(angular.isUndefined(a.unsafeContent)&&(a.unsafeContent=document.createElement("div"),a.unsafeContent.innerHTML=a.safeContent,angular.forEach(["src","data","classid","background","style"],function(e){for(var t,s,n=a.unsafeContent.querySelectorAll("[unsafe-"+e+"]"),i=0;i<n.length;i++)s=(t=angular.element(n[i])).attr("unsafe-"+e),t.attr(e,s),t.removeAttr("unsafe-"+e)}),e.$hasUnsafeContent=!1),a.content=a.unsafeContent.innerHTML):a.content=a.safeContent):"UIxMailPartICalViewer"==a.type||"UIxMailPartImageViewer"==a.type||"UIxMailPartLinkViewer"==a.type?("UIxMailPartImageViewer"==a.type?a.msgclass="msg-attachment-image":"UIxMailPartLinkViewer"==a.type&&(a.msgclass="msg-attachment-link"),a.compile=!0):(a.html=!0,a.content=a.safeContent),t.push(a))};return this.$parts||(this.parts&&s(this.parts),this.$parts=t)},r.prototype.$editableContent=function(){var s=this;return r.$$resource.fetch(this.$absolutePath(),"edit").then(function(e){return angular.extend(s,e),r.$$resource.fetch(s.$absolutePath({asDraft:!0}),"edit").then(function(t){var e=_.find(s.$mailbox.$account.identities,function(e){return t.from&&-1!==t.from.toLowerCase().indexOf(e.email)});e&&(t.from=e.full);e=r.$Preferences.defaults.AuxiliaryMailAccounts[s.$mailbox.$account.id];return e.security&&(e.security.alwaysSign&&(t.sign=!0),e.security.alwaysEncrypt&&(t.encrypt=!0)),r.$log.debug("editable = "+JSON.stringify(t,void 0,2)),angular.extend(s.editable,t),t.text})})},r.prototype.$plainContent=function(){return r.$$resource.fetch(this.$absolutePath(),"viewplain")},r.prototype.addTag=function(e){return this.$addOrRemoveTag("add",e)},r.prototype.removeTag=function(e){return this.$addOrRemoveTag("remove",e)},r.prototype.$addOrRemoveTag=function(e,t){e={operation:e,msgUIDs:[this.uid],flags:t.replace(/^_\$/,"$")};if(t)return r.$$resource.post(this.$mailbox.$id(),"addOrRemoveLabel",e)},r.prototype.$imipAction=function(e,t,s){var n=this;r.$$resource.post([this.$absolutePath(),e].join("/"),t,s).then(function(e){r.$timeout(function(){n.$reload()})})},r.prototype.$sendMDN=function(){return this.shouldAskReceipt=0,r.$$resource.post(this.$absolutePath(),"sendMDN")},r.prototype.$deleteAttachment=function(t){var e={filename:t},s=this;r.$$resource.fetch(this.$absolutePath({asDraft:!0}),"deleteAttachment",e).then(function(e){r.$timeout(function(){s.editable.attachmentAttrs=_.filter(s.editable.attachmentAttrs,function(e){return e.filename!=t})})})},r.prototype.toggleFlag=function(){var t=this,e="markMessageFlagged";return this.isflagged&&(e="markMessageUnflagged"),r.$$resource.post(this.$absolutePath(),e).then(function(e){r.$timeout(function(){t.isflagged=!t.isflagged})})},r.prototype.toggleThread=function(){var e=this,t="markMessageCollapse";return this.collapsed&&(t="markMessageUncollapse"),this.collapsed=!this.collapsed,e.$mailbox.updateVisibleMessages(),r.$$resource.post(this.$absolutePath(),t).catch(function(){this.collapsed=!this.collapsed,e.$mailbox.updateVisibleMessages()})},r.prototype.$isLoading=function(){return this.$loaded==r.STATUS.LOADING},r.prototype.$reload=function(e){var t=this;return e&&e.useCache&&this.$futureMessageData?(this.isread||r.$$resource.fetch(this.$absolutePath(),"markMessageRead").then(function(){r.$timeout(function(){t.isread=!0,t.$mailbox.unseenCount--})}),this):(e=r.$$resource.fetch(this.$absolutePath(e),"view"),this.$unwrap(e))},r.prototype.$parseMailto=function(s){var e,n,i=/^mailto:([^\?]+)/.exec(s);i&&(e=_.map(decodeURIComponent(i[1]).split(","),function(e){return"<"+e.trim()+">"}),n={to:e},_.forEach(["subject","body"],function(e){var t=new RegExp(e+"=([^&]+)");e="body"==e?"text":e,(i=t.exec(s))&&(n[e]=decodeURIComponent(i[1]))}),_.forEach(["cc","bcc"],function(e){var t=new RegExp(e+"=([^&]+)");(i=t.exec(s))&&(n[e]=_.map(decodeURIComponent(i[1]).split(","),function(e){return"<"+e.trim()+">"}))}),angular.extend(this.editable,n))},r.prototype.$reply=function(){return this.$newDraft("reply")},r.prototype.$replyAll=function(){return this.$newDraft("replyall")},r.prototype.$forward=function(){return this.$newDraft("forward")},r.prototype.$newDraft=function(n){var i=this;return r.$$resource.fetch(this.$absolutePath(),n).then(function(e){var t,s;return r.$log.debug("New "+n+": "+JSON.stringify(e,void 0,2)),t=i.$mailbox.$account.$getMailboxByPath(e.mailboxPath),s=new r(e.accountId,t,e),r.$$resource.fetch(s.$absolutePath({asDraft:!0}),"edit").then(function(e){r.$log.debug("New "+n+": "+JSON.stringify(e,void 0,2)+" original UID: "+i.uid);var t=r.$Preferences.defaults.AuxiliaryMailAccounts[i.$mailbox.$account.id];return t.security&&(t.security.alwaysSign&&(e.sign=!0),t.security.alwaysEncrypt&&(e.encrypt=!0)),e.isHTML&&((t=angular.element("<div>"+e.text+"</div>")).find("meta").remove(),t.find("link").remove(),t.find("base").remove(),t.find("title").remove(),e.text=t.html()),angular.extend(s.editable,e),s.origin={message:i,action:n},s})})},r.prototype.$save=function(){var t=this,e=this.$omit();return r.$log.debug("save = "+JSON.stringify(e,void 0,2)),r.$$resource.save(this.$absolutePath({asDraft:!0}),e).then(function(e){r.$log.debug("save = "+JSON.stringify(e,void 0,2)),t.$setUID(e.uid),t.$reload(),t.isNew=!1})},r.prototype.$send=function(){var t=this,e=this.$omit();return r.$log.debug("send = "+JSON.stringify(e,void 0,2)),r.$$resource.post(this.$absolutePath({asDraft:!0}),"send",e).then(function(e){return"success"==e.status?(angular.isDefined(t.origin)&&(t.origin.action.startsWith("reply")?t.origin.message.isanswered=!0:"forward"==t.origin.action&&(t.origin.message.isforwarded=!0)),e):r.$q.reject(e.data)})},r.prototype.$unwrap=function(e){var t=this;return this.$loaded=r.STATUS.DELAYED_LOADING,r.$timeout(function(){t.$loaded!=r.STATUS.LOADED&&(t.$loaded=r.STATUS.LOADING)},r.STATUS.DELAYED_MS),this.$futureMessageData=e.then(function(e){return 0===t.isread&&(t.isread=!0,t.$mailbox.unseenCount--),r.$timeout(function(){return delete t.$parts,t.$loaded=r.STATUS.LOADED,t.init(e),t})}),this.$futureMessageData},r.prototype.$omit=function(e){var s={},n=e&&e.privateAttributes,e=n?this:this.editable;return angular.forEach(e,function(e,t){_.includes(["to","cc","bcc"],t)&&!n?s[t]=_.map(e,function(e){return e.toString()}):("constructor"!=t&&"$"!=t[0]||n)&&(s[t]=e)}),s},r.prototype.download=function(){var e={uids:[this.uid]},t={filename:this.subject+".zip"};return r.$$resource.download(this.$mailbox.id,"saveMessages",e,t)},r.prototype.downloadAttachments=function(){var e={filename:l("attachments")+"-"+this.uid+".zip"};return r.$$resource.download(this.$absolutePath(),"archiveAttachments",null,e)}}(),function(){"use strict";function d(){this.show=!1,this.message=null,this.elements=[]}d.$factory=["$document","$timeout","$mdPanel","sgHotkeys",function(e,t,s,n){return angular.extend(d,{$document:e,$timeout:t,$mdPanel:s,sgHotkeys:n}),new d}],d.prototype.setMessage=function(e){this.message=e},d.prototype.registerImage=function(e){this.elements.push(e)},d.prototype.registerHotkeys=function(e){this.keys=[d.sgHotkeys.createHotkey({key:"left",description:l("View previous item"),callback:angular.bind(e,e.previousImage)}),d.sgHotkeys.createHotkey({key:"right",description:l("View next item"),callback:angular.bind(e,e.nextImage)})],_.forEach(this.keys,function(e){d.sgHotkeys.registerHotkey(e)})},d.prototype.showGallery=function(e,t){var s=this,n=d.$mdPanel,i=angular.element(this.message.$content()[t].content).find("img")[0].src,a=_.filter(this.message.attachmentAttrs,function(e){return 0===e.mimetype.indexOf("image/")}),o=_.findIndex(a,function(e){return 0<=e.url.indexOf(i)});angular.element(d.$document[0].body).addClass("sg-image-gallery-backdrop");var r=n.newPanelPosition().absolute(),t=n.newPanelAnimation().openFrom(e.target).duration(100).withAnimation(n.animation.FADE),e={attachTo:angular.element(document.body),locals:{lastIndex:a.length-1,images:a,selectedIndex:o,selectedImage:a[o]},bindToController:!0,controller:c,controllerAs:"$panelCtrl",position:r,animation:t,targetEvent:e,fullscreen:!0,hasBackdrop:!0,template:['<sg-image-gallery layout="column">',' <div class="md-toolbar-tools" layout="row" layout-align="space-between center">',' <md-button class="md-icon-button"',' aria-label="'+l("Close")+'"',' ng-click="$panelCtrl.close()">'," <md-icon>arrow_back</md-icon>"," </md-button>",' <md-icon class="md-primary">image</md-icon>',' <div md-truncate class="md-flex" ng-bind="$panelCtrl.selectedImage.filename"></div>',' <md-button class="md-icon-button"',' aria-label="'+l("Save Attachment")+'"',' ng-href="{{$panelCtrl.selectedImage.urlAsAttachment}}">'," <md-icon>file_download</md-icon>"," </md-button>"," </div>",' <div class="md-flex" layout="row" layout-align="space-between center">',' <md-button class="md-icon-button" ng-click="$panelCtrl.previousImage()"',' ng-disabled="$panelCtrl.selectedIndex == 0">'," <md-icon>navigate_before</md-icon>"," </md-button>",' <img class="sg-image" ng-src="{{$panelCtrl.selectedImage.url}}">',' <md-button class="md-icon-button" ng-click="$panelCtrl.nextImage()"',' ng-disabled="$panelCtrl.selectedIndex == $panelCtrl.lastIndex">'," <md-icon>navigate_next</md-icon>"," </md-button>"," </div>",' <div class="sg-image-thumbnails">',' <div class="sg-image-thumbnail" ng-repeat="image in ::$panelCtrl.images">',' <img class="sg-hide" ng-src="{{::image.url}}" ng-click="$panelCtrl.selectImage($index)">'," </div>"," </div>","</sg-image-gallery>"].join(""),trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0,onOpenComplete:function(){s.show=!0,_.forEach(d.$document.find("sg-image-gallery")[0].getElementsByClassName("sg-image-thumbnail"),function(e){var t=e.children[0];angular.element(t).one("load",function(){t.naturalWidth<t.naturalHeight&&t.classList.add("portrait")}),d.$timeout(function(){t.classList.remove("sg-hide")},1e3)})},onDomRemoved:function(){angular.element(d.$document[0].body).removeClass("sg-image-gallery-backdrop"),s.show=!1,_.forEach(s.hotkeys,function(e){d.sgHotkeys.deregisterHotkey(e)})}};function c(e){(e.$ctrl=this).close=function(){e.close()},this.selectImage=function(e){this.selectedIndex=e,this.selectedImage=this.images[e]},this.nextImage=function(){this.selectedIndex!=this.lastIndex&&this.selectImage(this.selectedIndex+1)},this.previousImage=function(){0<this.selectedIndex&&this.selectImage(this.selectedIndex-1)}}n.open(e).then(function(e){s.registerHotkeys(e.$ctrl)}),c.$inject=["mdPanelRef"]},angular.module("SOGo.MailerUI").factory("ImageGallery",d.$factory)}(),function(){"use strict";function l(e){this.$account=e}l.$factory=["$q","$timeout","$log","sgSettings","Resource","Message","Mailbox","sgMailbox_PRELOAD",function(e,t,s,n,i,a,o,r){return angular.extend(l,{$q:e,$timeout:t,$log:s,$$resource:new i(n.activeUser("folderURL")+"Mail",n.activeUser()),$Message:o,selectedFolder:null,PRELOAD:r}),l}];try{angular.module("SOGo.MailerUI")}catch(e){angular.module("SOGo.MailerUI",["SOGo.Common"])}angular.module("SOGo.MailerUI").constant("sgMailbox_PRELOAD",{LOOKAHEAD:50,SIZE:100}).factory("VirtualMailbox",l.$factory),l.$absolutePath=function(e){return[e,"virtual"].join("/")},l.prototype.init=function(e){this.$isLoading=!1,this.$mailboxes=[],this.uidsMap={},angular.extend(this,e),this.id=this.$id()},l.prototype.setMailboxes=function(e){this.$mailboxes=e,_.forEach(this.$mailboxes,function(e){e.$messages=[],e.uidsMap={}})},l.prototype.startSearch=function(t,s){var n=this,i=l.$q.when();this.$isLoading=!0,_.forEach(this.$mailboxes,function(e){i=i.then(function(){if(n.$isLoading)return l.$log.debug("searching mailbox "+e.path),e.$filter({sort:"date",asc:!1,match:t},s)})}),i.finally(function(){n.$isLoading=!1})},l.prototype.stopSearch=function(){l.$log.debug("stopping search..."),this.$isLoading=!1},l.prototype.selectFolder=function(){},l.prototype.resetSelectedMessage=function(){_.forEach(this.$mailboxes,function(e){delete e.$selectedMessage})},l.prototype.hasSelectedMessage=function(){return angular.isDefined(_.find(this.$mailboxes,function(e){return angular.isDefined(e.$selectedMessage)}))},l.prototype.isSelectedMessage=function(t,s){return angular.isDefined(_.find(this.$mailboxes,function(e){return e.path==s&&e.$selectedMessage==t}))},l.prototype.getLength=function(){var t=0;return angular.isDefined(this.$mailboxes)&&_.forEach(this.$mailboxes,function(e){t+=e.$messages.length}),t},l.prototype.getItemAtIndex=function(e){var t,s,n,i,a;if(angular.isDefined(this.$mailboxes)&&0<=e)for(s=t=0;s<this.$mailboxes.length;s++)for(i=this.$mailboxes[s],n=0;n<i.$messages.length;t++,n++)if(t==e&&(a=i.$messages[n],i.$loadMessage(a.uid)))return a;return null},l.prototype.$id=function(){return l.$absolutePath(this.$account.id)},l.prototype.$selectedMessageIndex=function(){var t=0,e=_.find(this.$mailboxes,function(e){return!!angular.isDefined(e.$selectedMessage)||(t+=e.getLength(),!1)});return t+e.uidsMap[e.$selectedMessage]},l.prototype.selectedMessages=function(){return _.filter(_.transform(this.$mailboxes,function(e,t){e[t.id]=t.$selectedMessages},{}),function(e){return 0<_.size(e)})},l.prototype.selectedCount=function(){return _.sum(_.invokeMap(this.$mailboxes,"selectedCount"))},l.prototype.$flagMessages=function(e,t,s){var n={flags:t,operation:s},i=[],a=[];return _.forEach(e,function(e,t){var s;0<e.length&&(s=_.map(e,"uid"),i.push(e),s=l.$$resource.post(t,"addOrRemoveLabel",_.assign(n,{msgUIDs:s})),a.push(s))}),l.$q.all(a).then(function(){return _.flatten(i)})},l.prototype.$deleteMessages=function(e){var s=this,n=[];if(_.isArray(e)&&1===e.length){var t=e[0],i=t.$mailbox;return i.$deleteMessages([t]).then(function(e){var t=0;return _.find(s.$mailboxes,function(e){return e.id===i.id||(t+=e.getLength(),!1)}),t+e})}return _.forEach(e,function(e,t){0<e.length&&(e=e[0].$mailbox.$deleteMessages(e),n.push(e))}),l.$q.all(n)},l.prototype.$markOrUnMarkMessagesAsJunk=function(e){var s=[];return _.forEach(e,function(e,t){0<e.length&&(e=e[0].$mailbox.$markOrUnMarkMessagesAsJunk(e),s.push(e))}),l.$q.all(s)},l.prototype.$copyMessages=function(e,s){var n=[];return _.forEach(e,function(e,t){0<e.length&&(e=e[0].$mailbox.$copyMessages(e,s),n.push(e))}),l.$q.all(n)},l.prototype.$moveMessages=function(e,s){var n=[];return _.forEach(e,function(e,t){0<e.length&&(e=e[0].$mailbox.$moveMessages(e,s),n.push(e))}),l.$q.all(n)},l.prototype.$comact=function(){return!0}}(),function(){"use strict";function e(i,a,e,o,r,c,d,s,n,u,h,g,f,t,m,p,$,b){var v,y=this,M=angular.element(i.document).find("title").attr("sg-default")||"SOGo",x=[];function C(e){return!!b.$virtualMode||y.selectedFolder.$compact()}function w(e){var t=y.selectedFolder.$selectedMessageIndex();return angular.isDefined(t)?(t--,0<y.selectedFolder.$topIndex&&y.selectedFolder.$topIndex--):(t=y.selectedFolder.getLength()-1,y.selectedFolder.$topIndex=y.selectedFolder.getLength()),-1<t&&y.selectMessage(y.selectedFolder.getItemAtIndex(t)),e.preventDefault(),t}function I(e){var t=y.selectedFolder.$selectedMessageIndex();return angular.isDefined(t)?(t++,y.selectedFolder.$topIndex<y.selectedFolder.getLength()&&y.selectedFolder.$topIndex++):t=0,t<y.selectedFolder.getLength()?y.selectMessage(y.selectedFolder.getItemAtIndex(t)):t=-1,e.preventDefault(),t}function E(e){var t;y.selectedFolder.hasSelectedMessage()&&0<=(t=w(e))&&y.toggleMessageSelection(e,y.selectedFolder.$messages[t])}function S(e){var t;y.selectedFolder.hasSelectedMessage()&&0<=(t=I(e))&&y.toggleMessageSelection(e,y.selectedFolder.$messages[t])}function F(){return b.$virtualMode?y.selectedFolder.$mailboxes:[y.selectedFolder]}function A(e,t){var s,n,i=t;y.mode.multiple=y.selectedFolder.selectedCount(),e&&(0<t&&(s=y.selectedFolder.$messages[--i]),t<y.selectedFolder.$messages.length&&(n=y.selectedFolder.$messages[t]),s?s.isread&&n&&!n.isread&&(i=t,s=n):n&&(i=t,s=n),s?(y.selectedFolder.$topIndex=i,r.go("mail.account.mailbox.message",{messageId:s.uid})):r.go("mail.account.mailbox"))}v={subject:"Subject",from:"From",date:"Date",size:"Size",arrival:"Order Received"},this.$onInit=function(){var t;i.$mailboxController=y,this.service=b,this.accounts=s,this.account=n,this.selectedFolder=u,this.messageDialog=null,this.mode={search:!1,multiple:0},(t=x).push(h.createHotkey({key:l("hotkey_search"),description:l("Search"),callback:y.searchMode})),t.push(h.createHotkey({key:l("hotkey_compose"),description:l("Write a new message"),callback:function(e){null===y.messageDialog&&y.newMessage(e)}})),t.push(h.createHotkey({key:l("hotkey_junk"),description:l("Mark the selected messages as junk"),callback:y.markOrUnMarkMessagesAsJunk})),t.push(h.createHotkey({key:"space",description:l("Toggle item"),callback:y.toggleMessageSelection})),t.push(h.createHotkey({key:"shift+space",description:l("Toggle range of items"),callback:y.toggleMessageSelection})),t.push(h.createHotkey({key:"up",description:l("View next item"),callback:w,preventInClass:["sg-mail-part"]})),t.push(h.createHotkey({key:"down",description:l("View previous item"),callback:I,preventInClass:["sg-mail-part"]})),t.push(h.createHotkey({key:"shift+up",description:l("Add next item to selection"),callback:E,preventInClass:["sg-mail-part"]})),t.push(h.createHotkey({key:"shift+down",description:l("Add previous item to selection"),callback:S,preventInClass:["sg-mail-part"]})),_.forEach(["backspace","delete"],function(e){t.push(h.createHotkey({key:e,description:l("Delete selected message or folder"),callback:y.confirmDeleteSelectedMessages}))}),_.forEach(t,function(e){h.registerHotkey(e)}),angular.element(i).on("beforeunload",C),a.$on("$destroy",function(){angular.element(i).off("beforeunload",C),_.forEach(x,function(e){h.deregisterHotkey(e)})}),a.$watch(function(){return y.selectedFolder.unseenCount},function(e){var t="";e&&(t+="("+e+") "),t+=y.selectedFolder.$displayName,i.document.title=t+=" | "+M})},this.centerIsClose=function(e){return this.selectedFolder.hasSelectedMessage()&&!!e},this.sort=function(e){if(!e)return v[y.service.$query.sort];y.selectedFolder.$filter({sort:e})},this.sortedBy=function(e){return b.$query.sort==e},this.ascending=function(){return b.$query.asc},this.refresh=function(){p.pollInbox(),this.selectedFolder.$filter()},this.searchMode=function(e){y.mode.search=!0,t("search"),e&&e.preventDefault()},this.cancelSearch=function(){y.mode.search=!1,y.selectedFolder.$filter(y.service.$query).then(function(){y.selectedFolder.$selectedMessage&&e(function(){y.selectedFolder.$topIndex=y.selectedFolder.uidsMap[y.selectedFolder.$selectedMessage]})})},this.composeWindowEnabled=function(){return p.defaults.SOGoMailComposeWindowEnabled},this.newMessage=function(e,t){var s,n=o.defer();null===y.messageDialog&&(t||"popup"==p.defaults.SOGoMailComposeWindow?(t=[f.baseURL(),"UIxMailPopupView#!/Mail",y.account.id,g(g(y.selectedFolder.path)),"new"].join("/"),s=y.selectedFolder.$id()+"/"+Math.random(0,1e3),i.open(t,s,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))):(s=y.account.$newMessage(),y.messageDialog=c.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",onComplete:function(e,t){return n.resolve(t)},locals:{stateParent:a,stateAccount:y.account,stateMessage:s,onCompletePromise:function(){return n.promise}}}).catch(_.noop).finally(function(){y.messageDialog=null})))},this.selectMessage=function(e){b.$virtualMode?r.go("mail.account.virtualMailbox.message",{mailboxId:g(e.$mailbox.path),messageId:e.uid}):r.go("mail.account.mailbox.message",{messageId:e.uid})},this.toggleMessageSelection=function(e,t){var s,n,i,a=y.selectedFolder;if(!(t=t||a.selectedMessage()))return!0;if(t.selected=!t.selected,e.shiftKey&&0<a.selectedCount()){for(n=(s=a.uidsMap[t.uid])-2;0<=n&&!a.$messages[n].selected;)n--;if(n<0)for(n=s+2;n<a.getLength()&&!a.$messages[n].selected;)n++;if(0<=n&&n<a.getLength())for(i=Math.min(s,n);i<=Math.max(s,n);i++)a.$messages[i].selected=!0}a.selectedMessages({updateCache:!0}),y.mode.multiple=y.selectedFolder.selectedCount(),e.preventDefault(),e.stopPropagation()},this.confirmDeleteSelectedMessages=function(e){var s=y.selectedFolder.selectedMessages();null===y.messageDialog&&0<_.size(s)&&(y.messageDialog=m.confirm(l("Confirmation"),l("Are you sure you want to delete the selected messages?"),{ok:l("Delete")}).then(function(){var t=y.selectedFolder.hasSelectedMessage();y.selectedFolder.$deleteMessages(s).then(function(e){b.$virtualMode?t&&r.go("mail.account.virtualMailbox"):A(t,e)},function(e){y.messageDialog=m.confirm(l("Warning"),l("The messages could not be moved to the trash folder. Would you like to delete them immediately?"),{ok:l("Delete")}).then(function(){y.selectedFolder.$deleteMessages(s,{withoutTrash:!0}).then(function(e){b.$virtualMode?t&&r.go("mail.account.virtualMailbox"):A(t,e)}).finally(function(){y.messageDialog=null})})})}).finally(function(){y.messageDialog=null})),e.preventDefault()},this.markOrUnMarkMessagesAsJunk=function(){var t=y.selectedFolder.hasSelectedMessage(),s=y.selectedFolder.selectedMessages();0===_.size(s)&&t&&(s=[y.selectedFolder.selectedMessage()]),0<_.size(s)&&y.selectedFolder.$markOrUnMarkMessagesAsJunk(s).then(function(){var e="/"+y.account.id+"/folderINBOX";"junk"!=y.selectedFolder.type&&(e="/"+y.account.$getMailboxByType("junk").id),y.selectedFolder.$moveMessages(s,e).then(function(e){b.$virtualMode?t&&r.go("mail.account.virtualMailbox"):A(t,e)})})},this.copySelectedMessages=function(e){var t=y.selectedFolder.selectedMessages();0<_.size(t)&&y.selectedFolder.$copyMessages(t,"/"+e).then(function(){d.show(d.simple().textContent(l("%{0} message(s) copied",y.selectedFolder.selectedCount())).position("top right").hideDelay(2e3))})},this.moveSelectedMessages=function(e){var t=y.selectedFolder.hasSelectedMessage(),s=y.selectedFolder.selectedMessages(),n=y.selectedFolder.selectedCount();0<_.size(s)&&y.selectedFolder.$moveMessages(s,"/"+e).then(function(e){d.show(d.simple().textContent(l("%{0} message(s) moved",n)).position("top right").hideDelay(2e3)),b.$virtualMode?t&&r.go("mail.account.virtualMailbox"):A(t,e)})},this.selectAll=function(){var n=0;_.forEach(F(),function(e){var t=0,s=e.$messages.length;for(e.$selectedMessages=[];t<s;t++)e.$messages[t].selected=!0,e.$selectedMessages.push(e.$messages[t]);n+=s}),y.mode.multiple=n},this.unselectMessages=function(){_.forEach(F(),function(e){e.$selectedMessages=[],_.forEach(e.$messages,function(e){e.selected=!1})}),y.mode.multiple=0},this.markSelectedMessagesAsFlagged=function(){var e=y.selectedFolder.selectedMessages();0<_.size(e)&&y.selectedFolder.$flagMessages(e,"\\Flagged","add").then(function(e){_.forEach(e,function(e){e.isflagged=!0})})},this.markSelectedMessagesAsUnread=function(){var e=y.selectedFolder.selectedMessages();0<_.size(e)&&y.selectedFolder.$flagMessages(e,"seen","remove").then(function(e){_.forEach(e,function(e){e.isread&&e.$mailbox.unseenCount++,e.isread=!1})})},this.markSelectedMessagesAsRead=function(){var e=y.selectedFolder.selectedMessages();0<_.size(e)&&y.selectedFolder.$flagMessages(e,"seen","add").then(function(e){_.forEach(e,function(e){e.isread||e.$mailbox.unseenCount--,e.isread=!0})})}}function t(e){return e[0].controller.prototype.resetScroll=function(){"messagesList"==this.$element.parent().attr("id")?this.updateSize():this.scrollTo(0)},e}e.$inject=["$window","$scope","$timeout","$q","$state","$mdDialog","$mdToast","stateAccounts","stateAccount","stateMailbox","sgHotkeys","encodeUriFilter","sgSettings","sgFocus","Dialog","Preferences","Account","Mailbox"],angular.module("SOGo.MailerUI").controller("MailboxController",e),t.$inject=["$delegate"],angular.module("material.components.virtualRepeat").decorator("mdVirtualRepeatContainerDirective",t)}(),function(){"use strict";function e(e,c,t,s,n,i,a,o,r,d,u,h,g,f,m,p,$,b,v,y,M,x){var C,w,I=this,E=[];this.$onInit=function(){var t;this.service=b,this.accounts=x,this.currentSearchParam="",this.search={options:{"":"",subject:l("Enter Subject"),from:l("Enter From"),to:l("Enter To"),cc:l("Enter Cc"),body:l("Enter Body")},subfolders:1,match:"AND",params:[]},this.showSubscribedOnly=M.defaults.SOGoMailShowSubscribedFoldersOnly,$.refreshUnseenCount(n.unseenCountFolders),t=E,_.forEach(["backspace","delete"],function(e){t.push(p.createHotkey({key:e,description:l("Delete selected message or folder"),callback:function(){b.selectedFolderController&&b.selectedFolder&&b.selectedFolder.$isEditable&&!b.selectedFolder.hasSelectedMessage()&&0===b.selectedFolder.$selectedCount()&&b.selectedFolderController.confirmDelete(b.selectedFolder)}}))}),_.forEach(t,function(e){p.registerHotkey(e)}),e.$on("$destroy",function(){_.forEach(E,function(e){p.deregisterHotkey(e)})})},this.hideAdvancedSearch=function(){I.service.$virtualPath=!1,I.service.$virtualMode=!1,C=I.accounts[0],w=I.searchPreviousMailbox,c.go("mail.account.mailbox",{accountId:C.id,mailboxId:g(w.path)})},this.toggleAdvancedSearch=function(){var e,t,s;b.selectedFolder.$isLoading?I.virtualMailbox.stopSearch():(t=[],s=function(e){_.forEach(e,function(e){e.isNoSelect()||t.push(e),e.children&&0<e.children.length&&s(e.children)})},I.virtualMailbox=new v(I.accounts[0]),b.$virtualMode||(I.searchPreviousMailbox=b.selectedFolder),b.selectedFolder=I.virtualMailbox,b.$virtualMode=!0,b.$virtualPath.length?(e=I.accounts[0].$getMailboxByPath(b.$virtualPath),t.push(e),I.search.subfolders&&e.children.length&&s(e.children)):t=_.filter(I.accounts[0].$flattenMailboxes({all:!0}),function(e){return!e.isNoSelect()}),I.virtualMailbox.setMailboxes(t),I.virtualMailbox.startSearch(I.search.match,I.search.params),"mail.account.virtualMailbox"!=c.$current.name&&c.go("mail.account.virtualMailbox",{accountId:I.accounts[0].id}))},this.addSearchParam=function(e){return this.currentSearchParam=e,h("advancedSearch"),!1},this.newSearchParam=function(e){if(e.length&&this.currentSearchParam.length){var t=0,s=this.currentSearchParam;return e.startsWith("!")&&(e=e.substring(t=1).trim()),this.currentSearchParam="",{searchBy:s,searchInput:e,negative:t}}},this.toggleAccountState=function(e){e.$expanded=!e.$expanded,this.debounceSaveState||(this.debounceSaveState=i.debounce(function(){e.$flattenMailboxes({reload:!0,saveState:!0})},1e3)),this.debounceSaveState()},this.subscribe=function(e){function t(e,t,s){var n=this;n.loading=!0,n.filter={name:""},n.account=new $({id:s.id,name:s.name}),n.close=function(){t.hide()},n.account.$getMailboxes({reload:!0,all:!0}).then(function(){n.loading=!1})}r.show({templateUrl:e.id+"/subscribe",controller:t,controllerAs:"subscriptions",clickOutsideToClose:!0,escapeToClose:!0,locals:{srcAccount:e}}).finally(function(){e.$getMailboxes({reload:!0})}),t.$inject=["$scope","$mdDialog","srcAccount"]},this.showAdvancedSearch=function(){b.$virtualPath="",a(u["gt-md"])||o("left").close()},this.newFolder=function(e){f.prompt(l("New Folder..."),l("Enter the new name of your folder")).then(function(s){e.$newMailbox(e.id,s).then(function(){},function(e,t){f.alert(l('An error occured while creating the mailbox "%{0}".',s),l(e.error))})})},this.delegate=function(e){function t(e,t,s,n){var i=this;i.users=n.delegates,i.account=n,i.userToAdd="",i.searchText="",i.userFilter=function(e){return s.$filter(e,n.delegates)},i.closeModal=function(){t.hide()},i.removeUser=function(e){n.$removeDelegate(e.uid).catch(function(e,t){f.alert(l("Warning"),l("An error occured, please try again."))})},i.addUser=function(e){e&&n.$addDelegate(e).then(function(){i.userToAdd="",i.searchText=""},function(e){f.alert(l("Warning"),e)})}}r.show({templateUrl:e.id+"/delegation",controller:t,controllerAs:"delegate",clickOutsideToClose:!0,escapeToClose:!0,locals:{User:y,account:e}}),t.$inject=["$scope","$mdDialog","User","account"]},this.isDroppableFolder=function(e,t){return t.id!=e.id&&!t.isNoSelect()},this.dragSelectedMessages=function(e,t,s){var n,i,a,o="/"+t.id,r=e.selectedMessages();0===r.length&&(r=[e.selectedMessage()]),t=_.map(r,"uid"),n=e.$selectedMessage&&0<=t.indexOf(e.$selectedMessage),a="copy"==s?(i=e.$copyMessages(r,o),l("%{0} message(s) copied",r.length)):(i=e.$moveMessages(r,o),l("%{0} message(s) moved",r.length)),i.then(function(){n&&c.go("mail.account.mailbox"),d.show(d.simple().textContent(a).position("top right").hideDelay(2e3))})}}e.$inject=["$scope","$state","$transitions","$timeout","$window","$mdUtil","$mdMedia","$mdSidenav","$mdDialog","$mdToast","sgConstant","sgFocus","encodeUriFilter","Dialog","sgSettings","sgHotkeys","Account","Mailbox","VirtualMailbox","User","Preferences","stateAccounts"],angular.module("SOGo.MailerUI").controller("MailboxesController",e)}(),function(){"use strict";function e(n,i,a,c,d,o,r,u,s,h,g,f,m,p,$,b,t,v,y,M,x,e,C,w,I,E){var S=this,F=[];function A(e){return i.mailbox?(0<arguments.length&&(i.mailbox.messageDialog=e),i.mailbox.messageDialog):null}function k(e){return function(){if(null===A())return e.apply(S,arguments)}}function D(){var e,t={};return n.opener&&"$mailboxController"in n.opener&&"selectedFolder"in n.opener.$mailboxController&&n.opener.$mailboxController.selectedFolder.$id()==g.$id()&&(e=n.opener.$mailboxController,t.mailboxCtrl=e,"$messageController"in n.opener&&n.opener.$messageController.message.uid==f.uid&&(e=n.opener.$messageController,t.messageCtrl=e)),t}function O(e,t){var s;null===A()&&(s=a.defer(),A(o.show({parent:angular.element(document.body),targetEvent:e,clickOutsideToClose:!1,escapeToClose:!1,templateUrl:"UIxMailEditor",controller:"MessageEditorController",controllerAs:"editor",onComplete:function(e,t){return s.resolve(t)},locals:{stateParent:i,stateAccount:S.account,stateMessage:t,onCompletePromise:function(){return s.promise}}}).catch(_.noop).finally(function(){A(null),S.closePopup()})))}function P(s,n){S.message.$plainContent().then(function(e){var t={pid:M.$defaultCalendar(),type:n,summary:e.subject,comment:e.content},e=new x(t),t=[$.activeUser("folderURL"),"Calendar","UIx"+n.capitalize()+"EditorTemplate"].join("/");return o.show({parent:angular.element(document.body),targetEvent:s,clickOutsideToClose:!0,escapeToClose:!0,templateUrl:t,controller:"ComponentEditorController",controllerAs:"editor",locals:{stateComponent:e}})})}this.$onInit=function(){var t,e=!1;n.$messageController=S,b.setMessage(f),this.$state=c,this.accounts=s,this.account=h,this.mailbox=g,this.message=f,this.service=w,this.tags={searchText:"",selected:""},this.showFlags=f.flags&&0<f.flags.length,this.$alwaysShowDetailedRecipients=(!f.to||f.to.length<5)&&(!f.cc||f.cc.length<5),this.$showDetailedRecipients=this.$alwaysShowDetailedRecipients,this.showRawSource=!1,(t=F).push(m.createHotkey({key:l("hotkey_reply"),description:l("Reply to the message"),callback:k(angular.bind(S,S.reply))})),t.push(m.createHotkey({key:l("hotkey_replyall"),description:l("Reply to sender and all recipients"),callback:k(angular.bind(S,S.replyAll))})),t.push(m.createHotkey({key:l("hotkey_forward"),description:l("Forward selected message"),callback:k(angular.bind(S,S.forward))})),t.push(m.createHotkey({key:l("hotkey_flag"),description:l("Flagged"),callback:k(angular.bind(f,f.toggleFlag))})),_.forEach(["backspace","delete"],function(e){t.push(m.createHotkey({key:e,callback:k(function(e){0===S.mailbox.selectedCount()&&S.deleteMessage(),e.preventDefault()})}))}),_.forEach(t,function(e){m.registerHotkey(e)});try{e=n.opener&&"$mailboxController"in n.opener}catch(e){}e?(i.$watchCollection(function(){return S.message.flags},function(e,t){var s;(e||t)&&(s=D()).messageCtrl&&s.messageCtrl.service.$timeout(function(){s.messageCtrl.showFlags=!0,s.messageCtrl.message.flags=e})}),i.$watch(function(){return S.message.isflagged},function(e,t){var s=D();s.mailboxCtrl&&s.mailboxCtrl.service.$timeout(function(){_.find(s.mailboxCtrl.selectedFolder.$messages,{uid:S.message.uid}).isflagged=e})})):i.$watchCollection(function(){return S.message.flags},function(e,t){var s,n;(e||t)&&(s=e||[],t=t||[],_.forEach(s,function(e,t){angular.isObject(e)&&(s[t]=e.name)}),s.length>t.length?(n=_.difference(s,t),_.forEach(n,function(e){S.message.addTag(e)})):s.length<t.length&&(n=_.difference(t,s),_.forEach(n,function(e){S.message.removeTag(e)})))}),i.$on("$destroy",function(){_.forEach(F,function(e){m.deregisterHotkey(e)})})},this.addFlags=function(e){e.stopPropagation(),e.preventDefault(),this.showFlags=!0,t("flags")},this.toggleDetailedRecipients=function(e){this.$showDetailedRecipients=!this.$showDetailedRecipients,e.stopPropagation(),e.preventDefault()},this.focusChip=function(e){for(var t=e.target;"MD-CHIP"!==t.tagName;)t=t.parentNode;t.classList.add("md-focused")},this.blurChip=function(e){for(var t=e.target;"MD-CHIP"!==t.tagName;)t=t.parentNode;t.classList.remove("md-focused"),e.relatedTarget&&"MD-CHIP-TEMPLATE"===e.relatedTarget.tagName&&S.panel.close()},this.selectRecipient=function(e,t){I.$findAll([]);var s=t.target,n=r.newPanelPosition().relativeTo(s).addPanelPosition(r.xPosition.ALIGN_START,r.yPosition.ALIGN_TOPS),i=r.newPanelAnimation().openFrom(s).duration(100).withAnimation(r.animation.FADE),i={attachTo:angular.element(document.body),locals:{recipient:e,addressbooks:I.$addressbooks,subscriptions:I.$subscriptions,newMessage:angular.bind(this,this.newMessage)},bindToController:!0,controller:a,controllerAs:"$menuCtrl",position:n,animation:i,targetEvent:t,templateUrl:"UIxMailViewRecipientMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!1};function a(n,e,i){this.onKeyDown=function(e){9===e.which&&n.close()},this.newCard=function(e,t){var s=new E({pid:t,c_cn:e.name,emails:[{value:e.email}]});s.$id().then(function(e){s.$save().then(function(){i.show(i.simple().textContent(l("Successfully created card")).position("top right").hideDelay(2e3))})}),n.close()}}r.open(i).then(function(e){(S.panel=e).panelEl.one("click",function(){e.close()})}),a.$inject=["mdPanelRef","$state","$mdToast"],"A"===s.tagName&&(t.stopPropagation(),t.preventDefault())},this.filterMailtoLinks=function(e){var t;"A"==e.target.tagName&&"href"in e.target.attributes&&(t=e.target.attributes.href.value,/^mailto:([^\?]+)/.exec(t)&&(delete e.target.attributes.target,this.newMessage(e,t)))},this.deleteMessage=function(){var s,n,i,a,o,e=D(),r=this.service.$timeout;function t(e){var t=e;if(n=null,angular.isDefined(i)){0<e&&(a=s.getItemAtIndex(--t)),e<s.getLength()&&(o=s.getItemAtIndex(e)),a?a.isread&&o&&!o.isread&&(t=e,a=o):o&&(t=e,a=o);try{a&&d(u["gt-md"])?(C.$virtualMode?i.go("mail.account.virtualMailbox.message",{mailboxId:p(a.$mailbox.path),messageId:a.uid}):i.go("mail.account.mailbox.message",{messageId:a.uid}),r(function(){t<s.$topIndex?s.$topIndex=t:t>s.$lastVisibleIndex&&(s.$topIndex=t-(s.$lastVisibleIndex-s.$topIndex))})):i.go("mail.account.mailbox").then(function(){n=null,delete s.$selectedMessage})}catch(e){}}S.closePopup()}i=e.messageCtrl?(s=e.mailboxCtrl.selectedFolder,n=e.messageCtrl.message,e.messageCtrl.$state):(s=g,n=f,c),(s=C.$virtualMode?C.selectedFolder:s).$deleteMessages([n]).then(t,function(e){A(v.confirm(l("Warning"),l("The message could not be moved to the trash folder. Would you like to delete it immediately?"),{ok:l("Delete")}).then(function(){s.$deleteMessages([n],{withoutTrash:!0}).then(t).finally(function(){A(null)})}).finally(function(){A(null)}))})},this._showMailEditorInPopup=function(e){return!$.isPopup&&"popup"==y.defaults.SOGoMailComposeWindow&&(this.openInPopup(e),!0)},this.close=function(){var e=C.$virtualMode?"mail.account.virtualMailbox":"mail.account.mailbox";c.go(e).then(function(){S.message=null,delete g.$selectedMessage})},this.reply=function(e){this._showMailEditorInPopup("reply")||O(e,this.message.$reply())},this.replyAll=function(e){this._showMailEditorInPopup("replyall")||O(e,this.message.$replyAll())},this.forward=function(e){this._showMailEditorInPopup("forward")||O(e,this.message.$forward())},this.edit=function(e){this._showMailEditorInPopup("edit")||this.message.$editableContent().then(function(){O(e,S.message)})},this.openInPopup=function(e){var t=[$.baseURL(),"UIxMailPopupView#!/Mail",this.message.accountId,p(p(this.message.$mailbox.path)),this.message.uid].join("/"),s=this.message.$absolutePath();e&&(t+="/"+e),n.open(t,s,["width=680","height=520","resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))},this.closePopup=function(){n.document.body.classList.contains("popup")&&n.close()},this.newMessage=function(t,e){"A"===t.target.tagName&&(t.stopPropagation(),t.preventDefault()),this.account.$newMessage({mailto:e}).then(function(e){O(t,e)})},this.toggleRawSource=function(e){this.showRawSource||this.message.$rawSource?this.showRawSource=!this.showRawSource:w.$$resource.post(this.message.id,"viewsource").then(function(e){S.message.$rawSource=e,S.showRawSource=!0})},this.print=function(e){n.print()},this.convertToEvent=function(e){return P(e,"appointment")},this.convertToTask=function(e){return P(e,"task")}}e.$inject=["$window","$scope","$q","$state","$mdMedia","$mdDialog","$mdPanel","sgConstant","stateAccounts","stateAccount","stateMailbox","stateMessage","sgHotkeys","encodeUriFilter","sgSettings","ImageGallery","sgFocus","Dialog","Preferences","Calendar","Component","Account","Mailbox","Message","AddressBook","Card"],angular.module("SOGo.MailerUI").controller("MessageController",e)}(),function(){"use strict";function e(e,s,t,n,i,a,o,r,c,d,u,h,g,f,m,p,$,b,v){var y=this;function M(){var e,t={};try{s.opener&&"$mailboxController"in s.opener&&"selectedFolder"in s.opener.$mailboxController&&("draft"==s.opener.$mailboxController.selectedFolder.type?(t.draftMailboxCtrl=s.opener.$mailboxController,"$messageController"in s.opener&&s.opener.$messageController.message.uid==u.uid&&(t.draftMessageCtrl=s.opener.$messageController)):u.origin&&(e=u.origin.message,s.opener.$mailboxController.selectedFolder.$id()==e.$mailbox.$id()&&(t.originMailboxCtrl=s.opener.$mailboxController)))}catch(e){}return t}function x(){y.uploader.url=y.message.$absolutePath({asDraft:!0,withResourcePath:!0})+"/save"}function C(){var e,t,s=y.message.editable.attachmentAttrs;if(s)for(e=0;e<s.length;e++)t={name:s[e].filename,type:s[e].mimetype,size:parseInt(s[e].size)},(t=new r.FileItem(y.uploader,t)).progress=100,t.isUploaded=!0,t.isSuccess=!0,t.inlineUrl=s[e].url,y.uploader.queue.push(t)}function w(e,t){e.isUploading?y.uploader.cancelItem(e):(y.message.$deleteAttachment(e.file.name),e.remove());t=s.document.getElementById(t);t&&angular.element(t).prop("value",null)}function I(){y.autosave&&f.cancel(y.autosave),y.message.isNew&&y.message.attachmentAttrs&&y.message.$mailbox.$deleteMessages([y.message]),a.cancel()}function E(){y.isFullscreen=!y.isFullscreen}function S(e){return $.$filterAll(e).then(function(e){var t=[];return _.forEach(_.invokeMap(e,"explode"),function(e){_.forEach(e,function(e){t.push(e)})}),_.uniqBy(t,function(e){return e.$$fullname+" "+e.$$email})})}function F(){y.message.$save(),v.defaults.SOGoMailAutoSave&&(y.autosave=f(y.autosaveDrafts,1e3*v.defaults.SOGoMailAutoSave*60))}this.$onInit=function(){e.isPopup=c.isPopup,this.account=d,this.autocomplete={to:{},cc:{},bcc:{}},this.autosave=null,this.autosaveDrafts=F,this.cancel=I,this.contactFilter=S,this.isFullscreen=!1,this.hideBcc=0===u.editable.bcc.length,this.hideCc=0===u.editable.cc.length,this.identities=d.identities,this.fromIdentity=u.editable.from,this.identitySearchText="",this.message=u,this.recipientSeparatorKeys=[n.KEY_CODE.ENTER,n.KEY_CODE.TAB,n.KEY_CODE.COMMA,n.KEY_CODE.SEMICOLON],this.removeAttachment=w,this.sendState=!1,this.toggleFullscreen=E,this.firstFocus=!0,y.uploader=new r({url:y.message.$absolutePath({asDraft:!0,withResourcePath:!0})+"/save",autoUpload:!0,alias:"attachments",removeAfterUpload:!1,onSuccessItem:function(e,t,s,n){y.message.$setUID(t.uid),y.message.$reload(),e.inlineUrl=t.lastAttachmentAttrs[0].url,e.file.name=t.lastAttachmentAttrs[0].filename},onCancelItem:function(e,t,s,n){y.message.$deleteAttachment(e.file.name),this.removeFromQueue(e)},onErrorItem:function(e,t,s,n){o.show(o.simple().textContent(l('Error while uploading the file "%{0}":',e.file.name)+" "+(t.message?l(t.message):"")).position("top right").action(l("OK")).hideDelay(!1)),this.removeFromQueue(e)}}),v.defaults.SOGoMailAutoSave&&(this.autosave=f(this.autosaveDrafts,1e3*v.defaults.SOGoMailAutoSave*60)),this.localeCode=v.defaults.LocaleCode,this.ckConfig={language:v.defaults.LocaleCode},this.composeType=v.defaults.SOGoMailComposeMessageType,this.signaturePlacement=v.defaults.SOGoMailSignaturePlacement,this.replyPlacement=v.defaults.SOGoMailReplyPlacement,this.message.origin&&"forward"==this.message.origin.action&&(this.replyPlacement="above"),e.$on("$destroy",function(){y.uploader.destroy()}),"reply"==t.actionName?u.$reply().then(function(e){y.message=e,y.fromIdentity=e.editable.from,y.hideCc=!e.editable.cc||0===e.editable.cc.length,y.hideBcc=!e.editable.bcc||0===e.editable.bcc.length,x()}):"replyall"==t.actionName?u.$replyAll().then(function(e){y.message=e,y.fromIdentity=e.editable.from,y.hideCc=!e.editable.cc||0===e.editable.cc.length,y.hideBcc=!e.editable.bcc||0===e.editable.bcc.length,x()}):"forward"==t.actionName?u.$forward().then(function(e){y.message=e,y.fromIdentity=e.editable.from,x(),C()}):angular.isDefined(u)&&(this.message=u,x(),C())},this.save=function(){var t=M();this.message.$save().then(function(e){y.message.$rawSource=null,t.draftMailboxCtrl&&t.draftMailboxCtrl.selectedFolder.$filter().then(function(){t.draftMessageCtrl&&t.draftMessageCtrl.$state.go("mail.account.mailbox.message",{messageId:y.message.uid})}),o.show(o.simple().textContent(l("Your email has been saved")).position("top right").hideDelay(3e3))})},this.send=function(){this.sendState="sending",this.autosave&&f.cancel(this.autosave),this.message.$send().then(function(e){var t=M();y.sendState="sent",t.draftMailboxCtrl&&t.draftMailboxCtrl.selectedFolder.$filter().then(function(){t.draftMessageCtrl&&t.draftMessageCtrl.close()}),t.originMailboxCtrl&&t.originMailboxCtrl.selectedFolder.$filter(),o.show(o.simple().textContent(l("Your email has been sent")).position("top right").hideDelay(3e3)),f(a.hide,1e3)},function(e){f(function(){y.sendState="error",y.errorMessage=e.data?e.data.message:e.statusText})})},this.addRecipient=function(e,t){var s,n,i,a,o=/([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)/i,r=this.message.editable[t];if(angular.isString(e)){for(a="",i=0;i<e.length;i++)(9==e.charCodeAt(i)||32==e.charCodeAt(i)||44==e.charCodeAt(i)||59==e.charCodeAt(i))&&o.test(a)&&r.indexOf(a)<0?(r.push(a),a=""):a+=e.charAt(i);return a&&r.indexOf(a)<0&&r.push(a),null}return e.$isList({expandable:!0})?angular.isDefined(e.refs)&&e.refs.length?_.forEach(e.refs,function(e){e.email.length&&r.indexOf(e.$shortFormat())<0&&r.push(e.$shortFormat())}):(n=b.$find(e.container,e.c_name)).$id().then(function(e){_.forEach(n.refs,function(e){e.email.length&&r.indexOf(e.$shortFormat())<0&&r.push(e.$shortFormat())})}):e.$isGroup({expandable:!0})?(s={toString:function(){return e.$shortFormat()},isExpandable:!0,members:[]},e.$members().then(function(e){s.members=e})):s=e.$shortFormat(),s||null},this.setFromIdentity=function(e){var t,s,n,i;if(e&&e.full)this.message.editable.from=e.full;else if(e&&e.length)return;n="html"==this.composeType?(t="<br />",s="<br ?/>[ \n]?"," "):(s=t="\n"," "),i=e&&e.signature?t+t+"--"+n+t+e.signature:"",!_.find(this.identities,function(e,t){if(e.signature){e=new RegExp(s+s+"--"+n+s+e.signature.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&"));if(0<=y.message.editable.text.search(e))return y.message.editable.text=y.message.editable.text.replace(e,i),!0}return!1})&&0<i.length&&(this.isNew()||"above"!=this.signaturePlacement?this.message.editable.text+=i:(e=this.message.editable.text.search(new RegExp(s+".+?:( ?"+s+'){2}(> |<blockquote type="cite")')),this.message.editable.text=0<=e?this.message.editable.text.slice(0,e)+i+this.message.editable.text.slice(e):i+this.message.editable.text))},this.identitySearch=function(e){var t=e||"";return _.filter(d.identities,function(e){return 0<=e.full.toLowerCase().indexOf(t.toLowerCase())})},this.expandGroup=function(e,t){var s,n=this.message.editable[t],i=n.indexOf(e);for(n.splice(i,1),s=0;s<e.members.length;s++){var a=e.members[s].$shortFormat();n.indexOf(a)<0&&n.splice(i+s,0,e.members[s].$shortFormat())}},this.isNew=function(){return void 0===this.message.origin},this.onTextFocus=function(e){var a=e.target;this.firstFocus&&(h().then(function(e){var t,s=angular.element(a).val(),n=/\n-- \n/.test(s),i=0;"above"==y.replyPlacement?(a.setCaretTo(0),e.find("md-dialog-content")[0].scrollTop=0):(n&&-1<(t=s.lastIndexOf("-- "))&&(i=s.length-t),e=s.length-i,i=t=e,-1<(s=s).indexOf("\r\n")&&(i-=(t=s.replace(/\r\n/g,"\n").slice(0,t).match(/\n/g))?t.length-1:0),e=i,n&&(e-=2),a.setCaretTo(e))}),this.firstFocus=!1)},this.onHTMLReady=function(e){this.isNew()||h().then(function(){e.focus()})},this.onHTMLFocus=function(r){this.firstFocus&&(h().then(function(e){var t,s="above"==y.replyPlacement,n=r.getSelection(),i=n.getRanges(),a=r.document.getBody().getChildren();if(s)t=a.getItem(0);else for(t=a.getItem(a.count()-1);;){var o=t.getPrevious();if(null===o)break;if(/--(%20|%A0|%C2%A0)/.test(encodeURI(o.getText()))){t=o.getPrevious().getPrevious();break}t=o}n.selectElement(t),s&&n.scrollIntoView(),(i=n.getRanges())[0].collapse(!0),n.selectRanges(i),s||n.scrollIntoView()}),this.firstFocus=!1)}}function t(e,t){e.closeToast=function(){t.hide()}}e.$inject=["$scope","$window","$stateParams","$mdConstant","$mdUtil","$mdDialog","$mdToast","FileUploader","stateParent","stateAccount","stateMessage","onCompletePromise","encodeUriFilter","$timeout","sgFocus","Dialog","AddressBook","Card","Preferences"],t.$inject=["$scope","$mdToast"],angular.module("SOGo.MailerUI").controller("SendMessageToastController",t).controller("MessageEditorController",e)}(),function(){function e(e,t,s,n,i,a,o,r){var l=[];this.$postLink=function(){this.quotaElement=_.find(e.find("div"),function(e){return e.classList.contains("sg-quota")})},this.addMailboxController=function(e){l.push(e)},this.selectFolder=function(e){o.selectedFolderController=e,null===o.selectedFolder||(e=_.find(l,function(e){return e.mailbox.id==o.selectedFolder.id}))&&e.unselectFolder(),n(a["gt-md"])||i("left").close()}}e.$inject=["$element","$transitions","$state","$mdMedia","$mdSidenav","sgConstant","Mailbox","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgAccountController",e).directive("sgAccountSection",function(){return{restrict:"C",scope:{},controller:"sgAccountController"}})}(),function(){"use strict";function e(s,t){var n=this;s.delegateInvitation=!1,s.delegatedTo="",s.searchText="",s.userFilter=function(e){return t.$filter(e)},s.iCalendarAction=function(e){var t;"delegate"==e&&(t={receiveUpdates:!1,delegatedTo:s.delegatedTo.c_email}),s.viewer.message.$imipAction(n.pathToAttachment,e,t)}}e.$inject=["$scope","User"],angular.module("SOGo.MailerUI").controller("sgImipController",e).directive("sgImip",function(){return{restrict:"A",link:function(e,t,s,n){n.pathToAttachment=s.sgImipPath},controller:"sgImipController"}})}(),function(){function e(e,t,s,n,a,i,o,r,c,d,u,h){var g=this;this.$onInit=function(){this.$element=t,this.editMode=!1,this.accountController.addMailboxController(this)},this.$postLink=function(){this.selectableElement=t.find("div")[0],this.clickableElement=t.find("p")[0],this.inputContainer=t.find("md-input-container")[0],this.inputElement=t.find("input")[0],this.moreOptionsButton=_.last(t.find("md-icon")),null!==u.selectedFolder&&u.selectedFolder.id==this.mailbox.id&&this.accountController.selectFolder(this)},this.childLevel=function(){return"sg-child-level-"+this.mailbox.level},this.selectFolder=function(e){this.editMode||this.mailbox==u.selectedFolder||this.mailbox.isNoSelect()||(u.$virtualPath=!1,u.$virtualMode=!1,this.accountController.selectFolder(this),e&&(s.go("mail.account.mailbox",{accountId:this.mailbox.$account.id,mailboxId:h(h(this.mailbox.path))}),e.stopPropagation(),e.preventDefault()))},this.unselectFolder=function(){t[0].classList.remove("md-bg")},this.editFolder=function(e){e.stopPropagation(),e.preventDefault(),this.editMode=!0,this.inputElement.value=this.mailbox.name,this.clickableElement.classList.add("ng-hide"),this.inputContainer.classList.remove("ng-hide"),e.srcEvent&&"touchend"==e.srcEvent.type?n(function(){g.inputElement.select(),g.inputElement.focus()},200):(this.inputElement.select(),this.inputElement.focus()),this.panel&&this.panel.close()},this.saveFolder=function(e){this.inputElement.disabled||(this.mailbox.name=this.inputElement.value,this.inputElement.disabled=!0,this.mailbox.$rename().then(function(e){g.editMode=!1,g.inputContainer.classList.add("ng-hide"),g.clickableElement.classList.remove("ng-hide")}).finally(function(){g.inputElement.disabled=!1}))},this.revertEditing=function(){this.editMode=!1,this.clickableElement.classList.remove("ng-hide"),this.inputContainer.classList.add("ng-hide"),this.inputElement.value=this.mailbox.name},this.confirmDelete=function(){d.confirm(l("Warning"),l("Do you really want to move this folder into the trash ?"),{ok:l("Delete")}).then(function(){g.mailbox.$delete().then(function(){s.go("mail.account.inbox")},function(e){d.confirm(l("Warning"),l("The mailbox could not be moved to the trash folder. Would you like to delete it immediately?"),{ok:l("Delete")}).then(function(){g.mailbox.$delete({withoutTrash:!0}).then(function(){s.go("mail.account.inbox")},function(e){d.alert(l('An error occured while deleting the mailbox "%{0}".',g.mailbox.name),l(e.error))})})})})},this.showMenu=function(e){var t=i.newPanelPosition().relativeTo(this.moreOptionsButton).addPanelPosition(i.xPosition.ALIGN_START,i.yPosition.ALIGN_TOPS),s=i.newPanelAnimation().openFrom(this.moreOptionsButton).duration(100).withAnimation(i.animation.FADE),e={attachTo:angular.element(document.body),locals:{itemCtrl:this,folder:this.mailbox,editFolder:angular.bind(this,this.editFolder),confirmDelete:angular.bind(this,this.confirmDelete)},bindToController:!0,controller:n,controllerAs:"$menuCtrl",position:t,animation:s,targetEvent:e,templateUrl:"UIxMailFolderMenu",trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0};function n(t,e,s,n){var i=this;this.markFolderRead=function(){this.folder.$markAsRead()},this.newFolder=function(){d.prompt(l("New Folder..."),l("Enter the new name of your folder")).then(function(s){i.folder.$newMailbox(i.folder.id,s).then(function(){},function(e,t){d.alert(l('An error occured while creating the mailbox "%{0}".',s),l(e.error))})})},this.compactFolder=function(){this.folder.$compact().then(function(){a.show(a.simple().textContent(l("Folder compacted")).position("top right").hideDelay(3e3))})},this.emptyTrashFolder=function(){this.folder.$emptyTrash().then(function(){a.show(a.simple().textContent(l("Trash emptied")).position("top right").hideDelay(3e3))})},this.showAdvancedSearch=function(){u.$virtualPath=this.folder.path,o(c["gt-md"])||r("left").close()},this.share=function(){var e=angular.bind(this.folder.constructor.$$resource,this.folder.constructor.$$resource.encodeURL);this.folder.$acl.$users().then(function(){s.show({templateUrl:e(i.folder.id).join("/")+"/UIxAclEditor",controller:"AclController",controllerAs:"acl",clickOutsideToClose:!0,escapeToClose:!0,locals:{usersWithACL:i.folder.$acl.users,User:n,folder:i.folder}})})},this.setFolderAs=function(e){this.folder.$setFolderAs(e).then(function(){i.folder.$account.$getMailboxes({reload:!0})})},this.isParentOf=function(n){var i=function(e){if(!(e.children&&0<e.children.length))return e.path==n;for(var t=0;t<e.children.length;t++){var s=e.children[t];if(s.children&&0<s.children.length){if(i(s))return!0}else if(s.path==n)return!0}};return i(this.folder)},this.moveFolder=function(e){this.folder.$move(e),t.close()}}i.open(e).then(function(e){(g.panel=e).panelEl.one("click",function(){e.close()})}),n.$inject=["mdPanelRef","$state","$mdDialog","User"]}}e.$inject=["$scope","$element","$state","$timeout","$mdToast","$mdPanel","$mdMedia","$mdSidenav","sgConstant","Dialog","Mailbox","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgMailboxListItemController",e).directive("sgMailboxListItem",function(){return{restrict:"C",require:{accountController:"^^sgAccountSection"},scope:{},bindToController:{mailbox:"=sgMailbox"},template:[' <div class="sg-child-level-0"',' ng-class="$ctrl.childLevel()">',' <md-checkbox class="sg-folder"',' ng-class="$ctrl.mailbox.$icon"',' aria-label="'+l("Expanded")+'"',' ng-model="$ctrl.mailbox.$expanded"',' ng-disabled="$ctrl.mailbox.children.length == 0"',' ng-change="$ctrl.mailbox.$account.$flattenMailboxes({ reload: true, saveState: true })">'," </md-checkbox>"," </div>",' <p class="sg-item-name"',' ng-click="$ctrl.selectFolder($event)"',' ng-dblclick="$ctrl.editFolder($event)">'," <md-icon ng-class=\"{ 'sg-opacity-70': $ctrl.mailbox.isNoSelect() }\">{{$ctrl.mailbox.$icon}}</md-icon>",' <span ng-bind="$ctrl.mailbox.$displayName"></span>',' <span class="sg-counter-badge ng-hide"',' ng-show="$ctrl.mailbox.unseenCount"',' ng-bind="$ctrl.mailbox.unseenCount"></span>'," </p>",' <md-input-container class="md-flex ng-hide">',' <input class="sg-item-name" type="text"',' aria-label="'+l("Enter the new name of your folder")+'"',' ng-blur="$ctrl.saveFolder($event)"',' sg-enter="$ctrl.saveFolder($event)"',' sg-escape="$ctrl.revertEditing()" />'," </md-input-container>",' <md-icon class="md-menu md-secondary-container" ng-click="$ctrl.showMenu($event)" aria-label="'+l("Options")+'">more_vert</md-icon>'].join(""),controller:"sgMailboxListItemController",controllerAs:"$ctrl"}})}(),function(){function e(t,e,s){var n=this;this.$onInit=function(){var e=["uid","isread","isflagged","flags","loading"];"draft"==(this.MailboxService=s).selectedFolder.type&&e.push("subject"),t.$watch(function(){return n.message?[_.pick(n.message,e)]:null},function(e,t){n.message&&n.onUpdate()},!0)},this.onUpdate=function(){this.message.loading?e.addClass("sg-skeleton"):(e.removeClass("sg-skeleton"),this.message.isread?e.removeClass("unread"):e.addClass("unread"),s.selectedFolder.isSelectedMessage(this.message.uid,this.message.$mailbox.path)?e.addClass("md-default-theme md-accent md-bg md-hue-2"):e.removeClass("md-default-theme md-accent md-bg md-hue-2"))},this.setVisibility=function(e,t){t?e.classList.remove("ng-hide"):e.classList.add("ng-hide")}}e.$inject=["$scope","$element","Mailbox"],angular.module("SOGo.MailerUI").controller("sgMessageListItemController",e).directive("sgMessageListItem",function(){return{restrict:"C",scope:{},bindToController:{message:"=sgMessage"},controller:"sgMessageListItemController"}})}(),function(){function e(n,l,e,t,c,s,i,a,o){var d=this;this.$postLink=function(){var t,e,s,o,r;this.parentController=n.parentController,o=this.parentController.onUpdate,r=this.parentController.setVisibility,_.forEach(l.find("div"),function(e){e.classList.contains("sg-tile-content")?t=angular.element(e):e.classList.contains("sg-tile-icons")&&(s=angular.element(e))}),e=t.find("button")[0],this.threadButton=e,e=angular.element(e),this.threadIconElement=e.find("md-icon")[0],this.threadCountElement=e.find("span")[0],this.priorityIconElement=t.find("md-icon")[0],i.$virtualMode&&(this.mailboxNameElement=t.find("span")[0],this.mailboxNameElement.classList.remove("ng-hide")),this.senderElement=t.find("span")[1],_.forEach(t.find("div"),function(e){e.classList.contains("sg-tile-subject")?d.subjectElement=e:e.classList.contains("sg-tile-size")?d.sizeElement=e:e.classList.contains("sg-tile-date")&&(d.dateElement=e)}),_.forEach(s.find("md-icon"),function(e){"star"==e.textContent?d.flagIconElement=e:"reply"==e.textContent?d.answerIconElement=e:"forward"==e.textContent?d.forwardIconElement=e:"attach_file"==e.textContent&&(d.attachmentIconElement=e)}),this.parentController.onUpdate=function(){var e;if(d.message=d.parentController.message,!d.message.loading){var t=l[0].querySelector(".sg-category-dot-container"),s=angular.element(t),n=c.nodesToArray(t.querySelectorAll(".sg-category-dot"));for(_.forEach(n,function(e){t.removeChild(e)}),e=0;e<d.message.flags.length&&e<5;e++){var i,a=d.message.flags[e];d.service.$tags[a]&&((i=angular.element('<div class="sg-category-dot"></div>')).css("background-color",d.service.$tags[a][1]),s.append(i))}d.mailboxNameElement&&(d.mailboxNameElement.innerHTML=d.message.$mailbox.$displayName),d.MailboxService.selectedFolder.isSentFolder?d.senderElement.innerHTML=d.message.$shortAddress("to").encodeEntities():d.senderElement.innerHTML=d.message.$shortAddress("from").encodeEntities(),d.message.priority&&d.message.priority.level<3?(d.priorityIconElement.classList.remove("ng-hide"),d.message.priority.level<2?d.priorityIconElement.classList.add("md-warn"):d.priorityIconElement.classList.remove("md-warn")):d.priorityIconElement.classList.add("ng-hide"),d.message.first?(d.threadButton.classList.remove("ng-hide"),d.threadCountElement.innerHTML=d.message.threadCount,d.message.collapsed&&d.threadIconElement.classList.remove("md-rotate-180-ccw")):d.threadButton.classList.add("ng-hide"),d.subjectElement.innerHTML=d.message.subject.encodeEntities(),d.sizeElement.innerHTML=d.message.size,d.dateElement.innerHTML=d.message.relativedate,r(d.flagIconElement,d.message.isflagged),r(d.answerIconElement,d.message.isanswered),r(d.forwardIconElement,d.message.isforwarded),r(d.attachmentIconElement,d.message.hasattachment)}angular.bind(d.parentController,o)()},this.service=a,this.MailboxService=i},this.toggleThread=function(){this.message.collapsed?this.threadIconElement.classList.add("md-rotate-180-ccw"):this.threadIconElement.classList.remove("md-rotate-180-ccw"),this.message.toggleThread()}}e.$inject=["$scope","$element","$parse","$state","$mdUtil","$mdToast","Mailbox","Message","encodeUriFilter"],angular.module("SOGo.MailerUI").controller("sgMessageListItemMainController",e).directive("sgMessageListItemMain",function(){return{restrict:"C",require:"^^sgMessageListItem",scope:{},template:['<div class="sg-tile-content">',' <div class="sg-md-subhead">'," <div>",' <span class="sg-label-outline ng-hide">\x3c!-- mailbox --\x3e</span>',' <md-icon class="ng-hide">error</md-icon>'," <span>\x3c!-- sender or recipient --\x3e</span>"," </div>",' <div class="sg-tile-date">\x3c!-- date --\x3e</div>'," </div>",' <div class="sg-md-body">',' <div class="sg-category-dot-container">\x3c!-- categories --\x3e</div>',' <div class="sg-tile-subject">\x3c!-- subject --\x3e</div>',' <div class="sg-tile-size">\x3c!-- size --\x3e</div>',' <md-button class="sg-tile-btn md-secondary ng-hide" md-colors="::{ color: \'accent-600\'}" ng-click="$ctrl.toggleThread()">',' <md-icon class="md-rotate-180-ccw" md-colors="::{ color: \'accent-600\'}">expand_more</md-icon><span></span>'," </md-button>"," </div>","</div>",'<div class="sg-tile-icons">',' <md-icon class="ng-hide sg-icon-star">star</md-icon>',' <md-icon class="ng-hide">reply</md-icon>',' <md-icon class="ng-hide">forward</md-icon>',' <md-icon class="ng-hide">attach_file</md-icon>',"</div>",'<div class="sg-progress-linear-bottom">',' <md-progress-linear class="md-accent"',' md-mode="indeterminate"',' ng-disabled="!$ctrl.message.$isLoading()">\x3c!-- message loading progress --\x3e</md-progress-linear>',"</div>"].join(""),link:function(e,t,s,n){e.parentController=n},controller:"sgMessageListItemMainController",controllerAs:"$ctrl"}})}(),function(){"use strict";function e(e,t){var s=this;this.$postLink=function(){t.registerImage(e),e.on("click",this.showImage)},this.showImage=function(e){"IMG"==e.target.tagName&&t.showGallery(e,s.partIndex)}}e.$inject=["$element","ImageGallery"],angular.module("SOGo.MailerUI").directive("sgZoomableImage",function(){return{restrict:"A",bindToController:{partIndex:"=sgZoomableImage"},controller:e}})}();
|
|
//# sourceMappingURL=Mailer.services.js.map
|