!function(){"use strict";function c(e){var t=this;"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("
"+e.signature+"
"),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim())}),this.$mailboxes)&&c.$Mailbox.$unwrapCollection(this,c.$q.when({mailboxes:this.$mailboxes})).then(function(e){t.$mailboxes=e})}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){angular.isDefined(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"+e.signature+""),e.textSignature=_.map(t.contents(),"textContent").join(" ").trim()):e.textSignature="",e.textSignature},c.prototype.$hasCertificate=function(){return this.security&&this.security.hasCertificate},c.prototype.$certificate=function(){var t=this;return this.$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,s;e.maxQuota?(t=Math.round(1e4*e.usedSpace/e.maxQuota)/100,s=l("quotasFormat").formatted(t,Math.round(e.maxQuota/10.24)/100)):e.maxMessages&&(t=Math.round(1e4*e.messagesCount/e.maxMessages)/100,s=l("messageQuotasFormat").formatted(t,e.maxMessages)),this.$quota={percent:t,description:s}},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(t){var s={},n=[],i=[],a=!1;return angular.forEach(this,function(e,t){"constructor"!=t&&"identities"!=t&&"$"!=t[0]&&(s[t]=angular.copy(e))}),t&&(_.forEach(this.$mailboxes,function(e){i.push(e.$omit(t))}),s.$mailboxes=i),_.forEach(this.identities,function(e){e.isReadOnly&&!t||n.push(_.pick(e,["email","fullName","replyTo","signature","isDefault"])),e.isDefault&&(a=e)}),s.identities=n,a&&s.forceDefaultIdentity||delete s.forceDefaultIdentity,s}}(),function(){"use strict";function u(e,t){this.$account=e,"function"!=typeof t.then?(this.init(t),this.name&&!this.path&&(e=u.$$resource.create("createFolder",this.name),this.$unwrap(e))):this.$unwrap(t)}u.$factory=["$q","$timeout","$log","$rootScope","sgSettings","Resource","Message","Acl","Preferences","sgMailbox_PRELOAD","sgMailbox_BATCH_DELETE_LIMIT",function(e,t,s,n,i,a,o,r,l,c,d){return angular.extend(u,{$q:e,$timeout:t,$log:s,$rootScope:n,$$resource:new a(i.activeUser("folderURL")+"Mail",i.activeUser()),$Message:o,$$Acl:r,$Preferences:l,$query:{sort:"arrival",asc:0},selectedFolder:null,$refreshTimeout:null,$virtualMode:!1,$virtualPath:!1,$searchMode:!1,PRELOAD:c,BATCH_DELETE_LIMIT:d}),l.settings.Mail.SortingState&&(u.$query.sort=l.settings.Mail.SortingState[0],u.$query.asc=parseInt(l.settings.Mail.SortingState[1])),u}];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",u.$factory),u.$find=function(e,t){t=t&&t.all?this.$$resource.fetch(e.id.toString(),"viewAll"):this.$$resource.fetch(e.id.toString(),"view");return u.$unwrapCollection(e,t)},u.$unwrapCollection=function(n,e){function i(e,t){t.isSentFolder=t.isSentFolder||"sent"==t.type,t.isDraftsFolder=t.isDraftsFolder||"draft"==t.type;for(var s=0;s{"subject_or_from"!=e.searchBy&&"subject_or_to"!=e.searchBy&&"contains"!=e.searchBy&&"body"!=e.searchBy&&"from"!=e.searchBy&&"to"!=e.searchBy&&"subject"!=e.searchBy||e.searchInput.split(" ").forEach(e=>{e=e.trim().toLowerCase();this.$highlightWords.includes(e)||this.$highlightWords.push(e)})})),angular.extend(i,{sortingAttributes:u.$query}),angular.isDefined(t)?(i.filters=_.reject(angular.copy(t),function(e){return!e.searchInput||0===e.searchInput.length}),_.forEach(i.filters,function(e){var t=e.searchBy.match(/(\w+)_or_(\w+)/);t&&(i.sortingAttributes.match="OR",e.searchBy=t[1],(e=angular.copy(e)).searchBy=t[2],i.filters.push(e))})):e||this.$flaggedOnly||this.$unseenOnly||!this.$syncToken||(n="changes",i.syncToken=this.$syncToken),this.$unseenOnly&&(i.unseenOnly=1),this.$flaggedOnly&&(i.flaggedOnly=1),_.filter(_.keys(this.$filteredLabels),function(e){return!!s.$filteredLabels[e]})),t=(e.length&&(i.labels=e),u.$virtualMode||(e=u.$Preferences.defaults.SOGoRefreshViewCheck)&&"manually"!=e&&(t=angular.bind(this,u.prototype.$filter,null,t),u.$refreshTimeout=u.$timeout(t,1e3*e.timeInterval())),u.$$resource.post(this.id,n,i));return this.$unwrap(t)},u.prototype.$loadMessage=function(e){var t,s,n=this.uidsMap[e],i=this.$messages.length,a=!1;if(angular.isDefined(this.uidsMap[e])&&nr.uids.length-1)&&(c.$topIndex=0),r.syncToken&&(c.$syncToken=r.syncToken),r.deleted&&(_.forEachRight(r.deleted,function(e,t){e=c.uidsMap[e.toString()];(e<0||!c.$messages[e])&&r.deleted.splice(t,1)}),r.deleted.length)&&c.$_deleteMessages(r.deleted),r.changed){var i,o=0;if(_.forEach(r.changed,function(e){angular.isUndefined(c.uidsMap[e.toString()])&&(c.uidsMap[e]=o,c.$messages.splice(o,0,{uid:e}),n=!0,o++)}),0",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":this[e][0].name||this[e][0].email||"")),punycode.toUnicode(n)},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"}),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]))}),"html"==r.$Preferences.defaults.SOGoMailComposeMessageType&&n.text&&0")),_.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()+">"}))}),_.isEmpty(n)||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.$compose=function(){return this.$newDraft("compose")},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=(t=(t=(t=(t=(t=(t=e.text).replace(/<\/?html[^>]*>/g,"")).replace(/<\/?body[^>]*>/g,"")).replace(/]*>.*<\/meta>/g,"")).replace(/]*>.*<\/link>/g,"")).replace(/]*>.*<\/base>/g,"")).replace(/]*>.*<\/title>/g,""),e.text=t),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.punycode=function(e){var t=/<(.*)>|^([\w\-\.@]+)$/gm.exec(e),s=e;return t&&0','
',' '," arrow_back"," ",' image','
',' '," file_download"," ","
",'
',' '," navigate_before"," ",' ',' '," navigate_next"," ","
",'
','
',' ',"
","
",""].join(""),trapFocus:!0,clickOutsideToClose:!0,escapeToClose:!0,focusOnOpen:!0,onOpenComplete:function(){s.show=!0,_.forEach(u.$document.find("sg-image-gallery")[0].getElementsByClassName("sg-image-thumbnail"),function(e){var t=e.children[0];angular.element(t).one("load",function(){t.naturalWidtht.scrollTop+t.clientHeight)&&document.querySelectorAll(".md-virtual-repeat-scroller")[1].scrollTo({top:C*e-(t.clientHeight-C)/2,behavior:"smooth"})}function P(e){var t;M.selectedFolder.hasSelectedMessage()&&0<=(t=E(e))&&M.toggleMessageSelection(e,M.selectedFolder.$messages[t])}function k(e){var t;M.selectedFolder.hasSelectedMessage()&&0<=(t=D(e))&&M.toggleMessageSelection(e,M.selectedFolder.$messages[t])}function T(){return y.$virtualMode?M.selectedFolder.$mailboxes:[M.selectedFolder]}function O(e,t){var s,n,i=t;M.mode.multiple=M.selectedFolder.selectedCount(),e&&(0{e.setHighlightWords([])}),M.mode.search=!1,M.selectedFolder.$filter(M.service.$query).then(function(){M.selectedFolder.$selectedMessage&&(M.selectedFolder.$topIndex=M.selectedFolder.uidsMap[M.selectedFolder.$selectedMessage])})},this.composeWindowEnabled=function(){return $.defaults.SOGoMailComposeWindowEnabled},this.openInPopup=function(e,t){var s=[f.baseURL(),"UIxMailPopupView#!/Mail",this.account.id],n=this.account.id+"/"+Math.random(0,1e3);e&&(s.push(g(g(e.$mailbox.path))),s.push(e.uid),n=e.$absolutePath()),t&&(n+="/"+t,s.push(t)),s=s.join("/"),i.open(s,n,["resizable=1","scrollbars=1","toolbar=0","location=0","directories=0","status=0","menubar=0","copyhistory=0"].join(","))},this.closePopup=function(){i.document.body.classList.contains("popup")&&i.close()},this._showMailEditorInPopup=function(e,t,s){return!(f.isPopup||"popup"!=$.defaults.SOGoMailComposeWindow&&!s||(this.openInPopup(e,t),0))},this.newMessage=function(t,e){this._showMailEditorInPopup(null,"new",e)||this.account.$newMessage().then(function(e){F(t,e)})},this.selectMessage=function(e){(y.$virtualMode?(M.isLoadingMessage=!0,o.go("mail.account.virtualMailbox.message",{mailboxId:g(g(e.$mailbox.path)),messageId:e.uid}).then(function(){}).catch(e=>{console.error(e)})):(M.isLoadingMessage=!0,o.go("mail.account.mailbox.message",{mailboxId:g(g(e.$mailbox.path)),messageId:e.uid}).then(function(){}).catch(e=>{console.error(e)}))).finally(()=>{M.isLoadingMessage=!1,M.nextAction&&(M.nextAction.m(M.nextAction.p),M.nextAction=null)})},this.toggleMessageSelection=function(e,t){var s,n,i,a=M.selectedFolder;if(!(t=t||a.selectedMessage()))return!0;if(t.selected=!t.selected,e.shiftKey&&0{e=e.trim().toLowerCase();this.highlightWords.includes(e)||this.highlightWords.push(e)})},this.reset=function(){this.highlightWords=[],this.searchForm={from:"",to:"",contains:"",notContains:"",subject:"",body:"",date:"anytime",dateStart:new Date,dateEnd:new Date,bcc:"",size:"",sizeOperator:">",sizeUnit:"mb",attachements:0,favorite:0,unseen:0,tags:{searchText:"",selected:""},flags:[]}},this.addSearchParameters=function(){if(this.search.params=[],this.highlightWords=[],this.searchForm.from&&0="));break;case"last30days":n.setDate(n.getDate()-30),t=this.formatDate(n),this.search.params.push(this.newSearchParam("date",t,">="));break;case"last6month":n.setMonth(n.getMonth()-6),t=this.formatDate(n),this.search.params.push(this.newSearchParam("date",t,">="));break;case"before":t=this.formatDate(this.searchForm.dateStart),this.search.params.push(this.newSearchParam("date",t,"<"));break;case"after":t=this.formatDate(this.searchForm.dateStart),this.search.params.push(this.newSearchParam("date",t,">="));break;case"between":t=this.formatDate(this.searchForm.dateStart),e=this.formatDate(this.searchForm.dateEnd),this.search.params.push(this.newSearchDateBetweenParam(t,e))}}this.searchForm.size&&0{}),F.virtualMailbox.setMailboxes(t),F.virtualMailbox.startSearch(F.search.match,F.search.params),"mail.account.virtualMailbox"!=d.$current.name&&d.go("mail.account.virtualMailbox",{accountId:F.accounts[0].id}))},this.formatDate=function(e){return e.getFullYear()+"-"+(e.getMonth()+1).toString().padStart(2,"0")+"-"+e.getDate().toString().padStart(2,"0")},this.changeDate=function(){"between"==this.searchForm.date&&this.searchForm.dateStart>this.searchForm.dateEnd&&(this.searchForm.dateEnd=this.searchForm.dateStart)},this.newSearchParam=function(e,t,s=">"){if(t.length&&e.length){var n=0;switch(t.startsWith("!")&&(t=t.substring(n=1).trim()),e){case"size":return{searchBy:e,searchInput:t,negative:n,operator:s,sizeUnit:this.searchForm.sizeUnit};case"date":return{searchBy:e,searchInput:t,negative:n,operator:s};default:return{searchBy:e,searchInput:t,negative:n}}}},this.newSearchDateBetweenParam=function(e,t){return{searchBy:"date_between",searchInput:"*",dateFrom:e,dateTo:t,negative:0}},this.newSearchFlagsParam=function(){return{searchBy:"flags",searchInput:"*",flags:F.searchForm.flags,negative:0}},this.toggleAccountState=function(e){e.$expanded=!e.$expanded,this.debounceSaveState||(this.debounceSaveState=a.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 b({id:s.id,name:s.name}),n.close=function(){t.hide()},n.account.$getMailboxes({reload:!0,all:!0}).then(function(){n.loading=!1})}u.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(){F.advancedSearchPanelVisible||(F.advancedSearchPanelVisible=!0,y.selectedFolder.path&&(y.$virtualPath=y.selectedFolder.path),o(g["gt-md"])||r("left").close(),u.show({template:document.getElementById("advancedSearch").innerHTML,parent:angular.element(document.body),controller:function(){this.$onInit=function(){this.mainController=F,this.mailbox=y,this.message=C},this.closeDialog=function(){u.hide(),F.advancedSearchPanelVisible=!1},this.search=function(){this.mainController.addSearchParameters(),u.hide(),F.advancedSearchPanelVisible=!1}},controllerAs:"dialogCtrl",clickOutsideToClose:!1,escapeToClose:!1}))},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.showCleanMailboxPanel=function(s,c){o(g["gt-md"])||r("left").close(),u.show({template:document.getElementById("cleanMailbox").innerHTML,parent:angular.element(document.body),controller:function(){var r=this;this.$onInit=function(){this.mainController=F,this.folder=s,this.isMailbox=!s,this.name=s?s.$displayName:c.name,this.loading=!1,this.date=null,this.form={filterDuration:"3m",permanentlyDelete:!1,confirmDelete:!1,filterDurationDate:null};var e=new Date,t=new Date(e);t.setMonth(e.getMonth()-3),this.maxDate=t},r.closeDialog=function(){u.hide()},r.isLoading=function(){return this.loading},r.isWarningDisplayed=function(){return this.form&&this.form.permanentlyDelete},r.isApplyDisabled=function(){return!(!this.loading&&(!this.form.permanentlyDelete||this.form.permanentlyDelete&&this.form.confirmDelete)&&("custom"!=this.form.filterDuration||"custom"==this.form.filterDuration&&this.form.filterDurationDate))},r.apply=function(){var e,t=[];if(c){for(e=0;ee.length?(n=_.difference(s,e),_.forEach(n,function(e){F.message.addTag(e)})):s.lengths.$lastVisibleIndex&&(s.$topIndex=t-(s.$lastVisibleIndex-s.$topIndex))})):i.go("mail.account.mailbox").then(function(){n=null,delete s.$selectedMessage})}catch(e){}}F.closePopup()}i=e.messageCtrl?(s=e.mailboxCtrl.selectedFolder,n=e.messageCtrl.message,e.messageCtrl.$state):(s=g,n=m,c),w.$virtualMode&&(s=w.selectedFolder),F.mailInDeletion=n.uid,s.$deleteMessages([n]).then(t,function(e){D(y.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(){D(null)})}).finally(function(){D(null)}))})},this._showMailEditorInPopup=function(e){return!$.isPopup&&"popup"==v.defaults.SOGoMailComposeWindow&&(this.openInPopup(e),!0)},this.close=function(){var e=w.$virtualMode?"mail.account.virtualMailbox":"mail.account.mailbox";c.go(e).then(function(){F.message=null,delete g.$selectedMessage})},this.reply=function(e){this._showMailEditorInPopup("reply")||k(e,this.message.$reply())},this.replyAll=function(e){this._showMailEditorInPopup("replyall")||k(e,this.message.$replyAll())},this.forward=function(e){this._showMailEditorInPopup("forward")||k(e,this.message.$forward())},this.edit=function(e){this._showMailEditorInPopup("edit")||this.message.$editableContent().then(function(){k(e,F.message)})},this.compose=function(e){this._showMailEditorInPopup("compose")||k(e,this.message.$compose())},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&&(s+="/"+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){k(t,e)})},this.toggleRawSource=function(e){this.showRawSource||this.message.$rawSource?this.showRawSource=!this.showRawSource:C.$$resource.post(this.message.id,"viewsource").then(function(e){F.message.$rawSource=e,F.showRawSource=!0})},this.activateRawContent=function(e){this.openInPopup("viewRaw")},this.print=function(e){n.print()},this.convertToEvent=function(e){return T(e,"appointment")},this.convertToTask=function(e){return T(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,n,t,s,i,a,o,r,c,d,u,h,g,m,f,p,$,b,y){var v=this;function M(){var e,t={};try{n.opener&&"$mailboxController"in n.opener&&"selectedFolder"in n.opener.$mailboxController&&(n.opener.$mailboxController.selectedFolder.id==d.$mailbox.id?(t.draftMailboxCtrl=n.opener.$mailboxController,"$messageController"in n.opener&&n.opener.$messageController.message.uid==d.uid&&(t.draftMessageCtrl=n.opener.$messageController)):d.origin&&(e=d.origin.message,n.opener.$mailboxController.selectedFolder.$id()==e.$mailbox.$id())&&(t.originMailboxCtrl=n.opener.$mailboxController))}catch(e){}return t}function x(){v.uploader.url=v.message.$absolutePath({asDraft:!0,withResourcePath:!0})+"/save"}function w(){var e,t,s=v.message.editable.attachmentAttrs;if(s)for(e=0;e",n="
( )?[ \n]?"," "):(n=t="\n"," "),i="above"==this.signaturePlacement?2:1,(v.isNew()&&1===y.defaults.SOGoMailUseSignatureOnNew||!v.isNew()&&1===y.defaults.SOGoMailUseSignatureOnForward&&v.message&&v.message.origin&&v.message.origin.action&&"forward"===v.message.origin.action||!v.isNew()&&1===y.defaults.SOGoMailUseSignatureOnReply&&v.message&&v.message.origin&&v.message.origin.action&&"reply"===v.message.origin.action)&&(o=e&&e.signature?t.repeat(i)+"--"+a+t+e.signature:"",!_.find(this.identities,function(e,t){if(e.signature)try{var s=new RegExp("("+n+"){"+i+"}--"+a+n+e.signature.replace(/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&"));if(0<=v.message.editable.text.search(s))return v.message.editable.text=v.message.editable.text.replace(s,o),!0}catch(e){return v.message.editable.text+=o,!0}return!1}))&&0 |
',' '," "," ",'

'," {{$ctrl.mailbox.$icon}}",' ',' ',"

",' ',' '," ",' more_vert'].join(""),controller:"sgMailboxListItemController",controllerAs:"$ctrl"}})}(),function(){function e(t,e,s,n){var i=this,a=0;this.$onInit=function(){var e=["uid","isread","isflagged","flags","loading"];"draft"!=(this.MailboxService=n).selectedFolder.type&&"templates"!=n.selectedFolder.type||e.push("subject"),t.$watch(function(){return i.message?[_.pick(i.message,e)]:null},function(e,t){i.message&&i.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"),n.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")},t.$on("listRefreshed",function(){s(function(){e.parent()[0]&&e.parent()[0].parentElement&&e.parent()[0].parentElement.parentElement&&(e.parent()[0].parentElement.parentElement.scrollTop=a)},0)}),t.$on("beforeListRefresh",function(){e.parent()[0]&&e.parent()[0].parentElement&&e.parent()[0].parentElement.parentElement&&(a=e.parent()[0].parentElement.parentElement.scrollTop)})}e.$inject=["$scope","$element","$timeout","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,r){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')).css("background-color",d.service.$tags[a][1]),s.append(i))}d.mailboxNameElement&&(d.mailboxNameElement.innerHTML=d.message.$mailbox.$displayName),d.defineSubjectAndSenderElements(),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.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.defineSubjectAndSenderElements=function(){d&&d.message&&!d.message.loading&&(d.subjectElement.innerHTML=d.message.getHighlightSubject(),d.MailboxService.selectedFolder.isSentFolder||d.MailboxService.selectedFolder.isDraftsFolder?d.senderElement.innerHTML=d.message.highlightSearchTerms(d.message.$shortAddress("to",r.defaults.SOGoMailDisplayFullEmail),!0):d.senderElement.innerHTML=d.message.highlightSearchTerms(d.message.$shortAddress("from",r.defaults.SOGoMailDisplayFullEmail),!0))},this.$doCheck=function(){d.defineSubjectAndSenderElements()},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","Preferences"],angular.module("SOGo.MailerUI").controller("sgMessageListItemMainController",e).directive("sgMessageListItemMain",function(){return{restrict:"C",require:"^^sgMessageListItem",scope:{},template:['
','
',"
",' \x3c!-- mailbox --\x3e',' error'," \x3c!-- sender or recipient --\x3e","
",'
\x3c!-- date --\x3e
',"
",'
','
\x3c!-- categories --\x3e
','
\x3c!-- subject --\x3e
','
\x3c!-- size --\x3e
',' ',' expand_more'," ","
","
",'
',' star',' reply',' forward',' attach_file',"
",'
',' \x3c!-- message loading progress --\x3e',"
"].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