From 29f579dc4e7178ef4d3aa8a16d987711247f79ab Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Mon, 5 May 2014 22:09:23 +0400 Subject: [PATCH] Imap ESEARCH/ESORT helper --- dev/ViewModels/MailBoxMessageViewViewModel.js | 2 +- .../0.0.0/app/libraries/MailSo/Base/Utils.php | 54 +++++++++++- .../app/libraries/MailSo/Imap/ImapClient.php | 86 +++++++++++++++---- .../app/libraries/MailSo/Mail/MailClient.php | 45 ++++++---- .../0.0.0/app/libraries/RainLoop/Actions.php | 3 +- .../libraries/RainLoop/Config/Application.php | 3 +- rainloop/v/0.0.0/static/js/app.js | 2 +- rainloop/v/0.0.0/static/js/app.min.js | 2 +- 8 files changed, 159 insertions(+), 38 deletions(-) diff --git a/dev/ViewModels/MailBoxMessageViewViewModel.js b/dev/ViewModels/MailBoxMessageViewViewModel.js index bf4cc8c39..d1b8c480c 100644 --- a/dev/ViewModels/MailBoxMessageViewViewModel.js +++ b/dev/ViewModels/MailBoxMessageViewViewModel.js @@ -331,7 +331,7 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) }); oDom - .on('click', '.messageView .messageItem', function () { + .on('click', '.messageView .messageItem .messageItemHeader', function () { if (oData.useKeyboardShortcuts() && self.message()) { self.message.focused(true); diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php b/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php index 4c3699739..4dd9c1a10 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Base/Utils.php @@ -1180,7 +1180,7 @@ class Utils } /** - * @param string $sString + * @param string $sUtfString * * @return bool */ @@ -1259,7 +1259,7 @@ class Utils * * @return array */ - public static function ExpandFetchSequence($sSequence) + public static function ParseFetchSequence($sSequence) { $aResult = array(); $sSequence = \trim($sSequence); @@ -1287,6 +1287,56 @@ class Utils return $aResult; } + /** + * @param array $aSequence + * + * @return string + */ + public static function PrepearFetchSequence($aSequence) + { + $aResult = array(); + if (\is_array($aSequence) && 0 < \count($aSequence)) + { + $iStart = null; + $iPrev = null; + + foreach ($aSequence as $sItem) + { + // simple protection + if (false !== \strpos($sItem, ':')) + { + $aResult[] = $sItem; + continue; + } + + $iItem = (int) $sItem; + if (null === $iStart || null === $iPrev) + { + $iStart = $iItem; + $iPrev = $iItem; + continue; + } + + if ($iPrev === $iItem - 1) + { + $iPrev = $iItem; + } + else + { + $aResult[] = $iStart === $iPrev ? $iStart : $iStart.':'.$iPrev; + $iStart = $iItem; + $iPrev = $iItem; + } + } + + if (null !== $iStart && null !== $iPrev) + { + $aResult[] = $iStart === $iPrev ? $iStart : $iStart.':'.$iPrev; + } + } + + return \implode(',', $aResult); + } /** * diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index 31d1a6ff4..2e2244ad5 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -1035,16 +1035,17 @@ class ImapClient extends \MailSo\Net\NetClient } } - $aReturn = array_reverse($aReturn); return $aReturn; } /** + * @param bool $bSort = false * @param string $sSearchCriterias = 'ALL' - * @param array $aSearchReturn = null + * @param array $aSearchOrSortReturn = null * @param bool $bReturnUid = true * @param string $sLimit = '' * @param string $sCharset = '' + * @param array $aSortTypes = null * * @return array * @@ -1052,47 +1053,66 @@ class ImapClient extends \MailSo\Net\NetClient * @throws \MailSo\Net\Exceptions\Exception * @throws \MailSo\Imap\Exceptions\Exception */ - public function MessageSimpleESearch($sSearchCriterias = 'ALL', $aSearchReturn = null, $bReturnUid = true, $sLimit = '', $sCharset = '') + private function simpleESearchOrESortHelper($bSort = false, $sSearchCriterias = 'ALL', $aSearchOrSortReturn = null, $bReturnUid = true, $sLimit = '', $sCharset = '', $aSortTypes = null) { $sCommandPrefix = ($bReturnUid) ? 'UID ' : ''; $sSearchCriterias = 0 === \strlen($sSearchCriterias) || '*' === $sSearchCriterias ? 'ALL' : $sSearchCriterias; - if (!$this->IsSupported('ESEARCH')) + $sCmd = $bSort ? 'SORT': 'SEARCH'; + if ($bSort && (!\is_array($aSortTypes) || 0 === \count($aSortTypes) || !$this->IsSupported('SORT'))) { $this->writeLogException( new \MailSo\Base\Exceptions\InvalidArgumentException(), \MailSo\Log\Enumerations\Type::ERROR, true); } - if (!\is_array($aSearchReturn) || 0 === \count($aSearchReturn)) + if (!$this->IsSupported($bSort ? 'ESORT' : 'ESEARCH')) { - $aSearchReturn = array('ALL'); + $this->writeLogException( + new \MailSo\Base\Exceptions\InvalidArgumentException(), + \MailSo\Log\Enumerations\Type::ERROR, true); + } + + if (!\is_array($aSearchOrSortReturn) || 0 === \count($aSearchOrSortReturn)) + { + $aSearchOrSortReturn = array('ALL'); } $aRequest = array(); - if (0 < \strlen($sCharset)) + if ($bSort) { - $aRequest[] = 'CHARSET'; - $aRequest[] = \strtoupper($sCharset); + $aRequest[] = 'RETURN'; + $aRequest[] = $aSearchOrSortReturn; + + $aRequest[] = $aSortTypes; + $aRequest[] = \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? 'US-ASCII' : 'UTF-8'; + } + else + { + if (0 < \strlen($sCharset)) + { + $aRequest[] = 'CHARSET'; + $aRequest[] = \strtoupper($sCharset); + } + + $aRequest[] = 'RETURN'; + $aRequest[] = $aSearchOrSortReturn; } - $aRequest[] = 'RETURN'; - $aRequest[] = $aSearchReturn; - $aRequest[] = $sSearchCriterias; - + if (0 < \strlen($sLimit)) { $aRequest[] = $sLimit; } - $this->SendRequest($sCommandPrefix.('SEARCH'), $aRequest); + $this->SendRequest($sCommandPrefix.$sCmd, $aRequest); $sRequestTag = $this->getCurrentTag(); $aResult = array(); $aResponse = $this->parseResponseWithValidation(); - + if (\is_array($aResponse)) { $oImapResponse = null; @@ -1132,6 +1152,42 @@ class ImapClient extends \MailSo\Net\NetClient return $aResult; } + /** + * @param string $sSearchCriterias = 'ALL' + * @param array $aSearchReturn = null + * @param bool $bReturnUid = true + * @param string $sLimit = '' + * @param string $sCharset = '' + * + * @return array + * + * @throws \MailSo\Base\Exceptions\InvalidArgumentException + * @throws \MailSo\Net\Exceptions\Exception + * @throws \MailSo\Imap\Exceptions\Exception + */ + public function MessageSimpleESearch($sSearchCriterias = 'ALL', $aSearchReturn = null, $bReturnUid = true, $sLimit = '', $sCharset = '') + { + return $this->simpleESearchOrESortHelper(false, $sSearchCriterias, $aSearchReturn, $bReturnUid, $sLimit, $sCharset); + } + + /** + * @param array $aSortTypes + * @param string $sSearchCriterias = 'ALL' + * @param array $aSearchReturn = null + * @param bool $bReturnUid = true + * @param string $sLimit = '' + * + * @return array + * + * @throws \MailSo\Base\Exceptions\InvalidArgumentException + * @throws \MailSo\Net\Exceptions\Exception + * @throws \MailSo\Imap\Exceptions\Exception + */ + public function MessageSimpleESort($aSortTypes, $sSearchCriterias = 'ALL', $aSearchReturn = null, $bReturnUid = true, $sLimit = '') + { + return $this->simpleESearchOrESortHelper(true, $sSearchCriterias, $aSearchReturn, $bReturnUid, $sLimit, '', $aSortTypes); + } + /** * @param string $sSearchCriterias * @param bool $bReturnUid = true diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index 729e9233b..ae9fcf0a5 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -239,8 +239,8 @@ class MailClient : \MailSo\Imap\Enumerations\StoreAction::REMOVE_FLAGS_SILENT ; - $sIndexRange = \implode(',', $aIndexRange); - $this->oImapClient->MessageStoreFlag($sIndexRange, $bIndexIsUid, array($sMessageFlag), $sStoreAction); + $this->oImapClient->MessageStoreFlag(\MailSo\Base\Utils::PrepearFetchSequence($aIndexRange), + $bIndexIsUid, array($sMessageFlag), $sStoreAction); } } @@ -536,7 +536,7 @@ class MailClient $this->oImapClient->FolderSelect($sFolder); - $sIndexRange = \implode(',', $aIndexRange); + $sIndexRange = \MailSo\Base\Utils::PrepearFetchSequence($aIndexRange); $this->oImapClient->MessageStoreFlag($sIndexRange, $bIndexIsUid, array(\MailSo\Imap\Enumerations\MessageFlag::DELETED), @@ -576,11 +576,14 @@ class MailClient if ($bUseMoveSupported && $this->oImapClient->IsSupported('MOVE')) { - $this->oImapClient->MessageMove($sToFolder, \implode(',', $aIndexRange), $bIndexIsUid); + $this->oImapClient->MessageMove($sToFolder, + \MailSo\Base\Utils::PrepearFetchSequence($aIndexRange), $bIndexIsUid); } else { - $this->oImapClient->MessageCopy($sToFolder, \implode(',', $aIndexRange), $bIndexIsUid); + $this->oImapClient->MessageCopy($sToFolder, + \MailSo\Base\Utils::PrepearFetchSequence($aIndexRange), $bIndexIsUid); + $this->MessageDelete($sFromFolder, $aIndexRange, $bIndexIsUid, true); } @@ -608,7 +611,8 @@ class MailClient } $this->oImapClient->FolderSelect($sFromFolder); - $this->oImapClient->MessageCopy($sToFolder, \implode(',', $aIndexRange), $bIndexIsUid); + $this->oImapClient->MessageCopy($sToFolder, + \MailSo\Base\Utils::PrepearFetchSequence($aIndexRange), $bIndexIsUid); return $this; } @@ -806,7 +810,7 @@ class MailClient \MailSo\Imap\Enumerations\FetchType::INDEX, \MailSo\Imap\Enumerations\FetchType::UID, \MailSo\Imap\Enumerations\FetchType::FLAGS - ), \implode(',', $aUids), true); + ), \MailSo\Base\Utils::PrepearFetchSequence($aUids), true); if (\is_array($aFetchResponse) && 0 < \count($aFetchResponse)) { @@ -1469,7 +1473,7 @@ class MailClient \MailSo\Imap\Enumerations\FetchType::FLAGS, \MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE, $this->getEnvelopeOrHeadersRequestString() - ), \implode(',', $aRequestIndexOrUids), $bIndexAsUid); + ), \MailSo\Base\Utils::PrepearFetchSequence($aRequestIndexOrUids), $bIndexAsUid); if (\is_array($aFetchResponse) && 0 < \count($aFetchResponse)) { @@ -1520,7 +1524,7 @@ class MailClient * @param bool $bUseSortIfSupported = false * @param bool $bUseThreadSortIfSupported = false * @param array $aExpandedThreadsUids = array() - * @param bool $bUseESearchOrESortRequest = true + * @param bool $bUseESearchOrESortRequest = false * * @return \MailSo\Mail\MessageCollection * @@ -1530,7 +1534,7 @@ class MailClient */ public function MessageList($sFolderName, $iOffset = 0, $iLimit = 10, $sSearch = '', $sPrevUidNext = '', $oCacher = null, $bUseSortIfSupported = false, $bUseThreadSortIfSupported = false, $aExpandedThreadsUids = array(), - $bUseESearchOrESortRequest = true) + $bUseESearchOrESortRequest = false) { $sSearch = \trim($sSearch); if (!\MailSo\Base\Validator::RangeInt($iOffset, 0) || @@ -1623,12 +1627,17 @@ class MailClient { if ($bESortSupported) { - // TODO - $aIndexOrUids = $this->oImapClient->MessageSimpleSort(array('ARRIVAL'), $sSearchCriterias, $bIndexAsUid); + $aESorthData = $this->oImapClient->MessageSimpleESort(array('ARRIVAL'), $sSearchCriterias, array('ALL'), $bIndexAsUid, ''); + if (isset($aESorthData['ALL'])) + { + $aIndexOrUids = \MailSo\Base\Utils::ParseFetchSequence($aESorthData['ALL']); + $aIndexOrUids = \array_reverse($aIndexOrUids); + } + unset($aESorthData); } else { - $aIndexOrUids = $this->oImapClient->MessageSimpleSort(array('ARRIVAL'), $sSearchCriterias, $bIndexAsUid); + $aIndexOrUids = $this->oImapClient->MessageSimpleSort(array('REVERSE ARRIVAL'), $sSearchCriterias, $bIndexAsUid); } } else @@ -1642,8 +1651,10 @@ class MailClient $aESearchData = $this->oImapClient->MessageSimpleESearch($sSearchCriterias, array('ALL'), $bIndexAsUid, '', 'UTF-8'); if (isset($aESearchData['ALL'])) { - $aIndexOrUids = \MailSo\Base\Utils::ExpandFetchSequence($aESearchData['ALL']); + $aIndexOrUids = \MailSo\Base\Utils::ParseFetchSequence($aESearchData['ALL']); + $aIndexOrUids = \array_reverse($aIndexOrUids); } + unset($aESearchData); } else { @@ -1664,8 +1675,10 @@ class MailClient $aESearchData = $this->oImapClient->MessageSimpleESearch($sSearchCriterias, array('ALL'), $bIndexAsUid); if (isset($aESearchData['ALL'])) { - $aIndexOrUids = \MailSo\Base\Utils::ExpandFetchSequence($aESearchData['ALL']); + $aIndexOrUids = \MailSo\Base\Utils::ParseFetchSequence($aESearchData['ALL']); + $aIndexOrUids = \array_reverse($aIndexOrUids); } + unset($aESearchData); } else { @@ -1686,7 +1699,7 @@ class MailClient $oCacher); $aIndexOrUids = $this->compileLineThreadUids($aThreads, $aLastCollapsedThreadUids, $aExpandedThreadsUids, 0); - $iMessageCount = count($aIndexOrUids); + $iMessageCount = \count($aIndexOrUids); } else { diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 3be44a87d..19b590ff0 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -3959,7 +3959,8 @@ class Actions ($this->Config()->Get('cache', 'enable', true) && $this->Config()->Get('cache', 'server_uids', false)) ? $this->Cacher() : null, !!$this->Config()->Get('labs', 'use_imap_sort', false), $bUseThreads, - $aExpandedThreadUid + $aExpandedThreadUid, + !!$this->Config()->Get('labs', 'use_imap_esearch_esort', false) ); } catch (\Exception $oException) diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 5fe79c212..3e0e530ea 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -225,7 +225,8 @@ Enables caching in the system'), 'allow_html_editor_source_button' => array(false), 'use_app_debug_js' => array(false), 'use_app_debug_css' => array(false), - 'use_imap_sort' => array(false), + 'use_imap_sort' => array(true), + 'use_imap_esearch_esort' => array(false), 'use_imap_force_selection' => array(false), 'use_imap_list_subscribe' => array(true), 'use_imap_thread' => array(true), diff --git a/rainloop/v/0.0.0/static/js/app.js b/rainloop/v/0.0.0/static/js/app.js index ddbfc9d9b..9a8209fa9 100644 --- a/rainloop/v/0.0.0/static/js/app.js +++ b/rainloop/v/0.0.0/static/js/app.js @@ -13362,7 +13362,7 @@ MailBoxMessageViewViewModel.prototype.onBuild = function (oDom) }); oDom - .on('click', '.messageView .messageItem', function () { + .on('click', '.messageView .messageItem .messageItemHeader', function () { if (oData.useKeyboardShortcuts() && self.message()) { self.message.focused(true); diff --git a/rainloop/v/0.0.0/static/js/app.min.js b/rainloop/v/0.0.0/static/js/app.min.js index 4cce196c7..3f10d5183 100644 --- a/rainloop/v/0.0.0/static/js/app.min.js +++ b/rainloop/v/0.0.0/static/js/app.min.js @@ -5,6 +5,6 @@ return b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|128<>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/rn/g,"n");for(var b="",c=0;cd?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=Array(),y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;o/g,">").replace(/")},Bb.draggeblePlace=function(){return b('
 
').appendTo("#rl-hidden")},Bb.defautOptionsAfterRender=function(a,c){c&&!Bb.isUnd(c.disabled)&&a&&b(a).toggleClass("disabled",c.disabled).prop("disabled",c.disabled)},Bb.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+Bb.fakeMd5()+"__",j=b("#"+d);a[i]=function(){if(h&&h.document.body&&j&&j[0]){var d=b(h.document.body);b("#rl-content",d).html(j.html()),b("html",h.document).addClass("external "+b("html").attr("class")),Bb.i18nToNode(d),t.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write(''+Bb.encodeHtml(e)+'
'),h.document.close(),g=h.document.createElement("script"),g.type="text/javascript",g.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}",h.document.getElementsByTagName("head")[0].appendChild(g)},Bb.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=Bb.isUnd(d)?1e3:Bb.pInt(d),function(e,f,g,i,j){b.call(c,f&&f.Result?zb.SaveSettingsStep.TrueResult:zb.SaveSettingsStep.FalseResult),a&&a.call(c,e,f,g,i,j),h.delay(function(){b.call(c,zb.SaveSettingsStep.Idle)},d)}},Bb.settingsSaveHelperSimpleFunction=function(a,b){return Bb.settingsSaveHelperFunction(null,a,b,1e3)},Bb.htmlToPlain=function(a){var c="",d="> ",e=function(){if(arguments&&1\n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1]*>(.|[\s\S\r\n]*)<\/div>/gim,f),a="\n"+b.trim(a)+"\n"),a}return""},g=function(){return arguments&&1/g,">"):""},h=function(){if(arguments&&1/gim,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/]*>/gim,"\n_______________________________\n\n").replace(/]*>/gim,"").replace(/]*>(.|[\s\S\r\n]*)<\/div>/gim,f).replace(/]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/]*>(.|[\s\S\r\n]*)<\/a>/gim,h).replace(/ /gi," ").replace(/<[^>]*>/gm,"").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&").replace(/&\w{2,6};/gi,""),c.replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__(.|[\s\S\r\n]*)__bq__end__/gm,e).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")},Bb.plainToHtml=function(a){return a.toString().replace(/&/g,"&").replace(/>/g,">").replace(/")},Bb.resizeAndCrop=function(b,c,d){var e=new a.Image;e.onload=function(){var a=[0,0],b=document.createElement("canvas"),e=b.getContext("2d");b.width=c,b.height=c,a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width],e.fillStyle="#fff",e.fillRect(0,0,c,c),e.drawImage(this,a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,c,c),d(b.toDataURL("image/jpeg"))},e.src=b},Bb.computedPagenatorHelper=function(a,b){return function(){var c=0,d=0,e=2,f=[],g=a(),h=b(),i=function(a,b,c){var d={current:a===g,name:Bb.isUnd(c)?a.toString():c.toString(),custom:Bb.isUnd(c)?!1:!0,title:Bb.isUnd(c)?"":a.toString(),value:a.toString()};(Bb.isUnd(b)?0:!b)?f.unshift(d):f.push(d)};if(h>1||h>0&&g>h){for(g>h?(i(h),c=h,d=h):((3>=g||g>=h-2)&&(e+=2),i(g),c=g,d=g);e>0;)if(c-=1,d+=1,c>0&&(i(c,!1),e--),h>=d)i(d,!0),e--;else if(0>=c)break;3===c?i(2,!1):c>3&&i(Math.round((c-1)/2),!1,"..."),h-2===d?i(h-1,!0):h-2>d&&i(Math.round((h+d)/2),!0,"..."),c>1&&i(1,!1),h>d&&i(h,!0)}return f}},Bb.selectElement=function(b){if(a.getSelection){var c=a.getSelection();c.removeAllRanges();var d=document.createRange();d.selectNodeContents(b),c.addRange(d)}else if(document.selection){var e=document.body.createTextRange();e.moveToElementText(b),e.select()}},Bb.disableKeyFilter=function(){a.key&&(j.filter=function(){return Ob.data().useKeyboardShortcuts()})},Bb.restoreKeyFilter=function(){a.key&&(j.filter=function(a){if(Ob.data().useKeyboardShortcuts()){var b=a.target||a.srcElement,c=b?b.tagName:"";return c=c.toUpperCase(),!("INPUT"===c||"SELECT"===c||"TEXTAREA"===c||b&&"DIV"===c&&"editorHtmlArea"===b.className&&b.contentEditable)}return!1})},Bb.detectDropdownVisibility=h.debounce(function(){Eb.dropdownVisibility(!!h.find(Gb,function(a){return a.hasClass("open")}))},50),Db={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return Db.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Db._utf8_encode(a);j>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+this._keyStr.charAt(e)+this._keyStr.charAt(f)+this._keyStr.charAt(g)+this._keyStr.charAt(h);return i},decode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!==g&&(i+=String.fromCharCode(c)),64!==h&&(i+=String.fromCharCode(d));return Db._utf8_decode(i)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0,d=a.length,e=0;d>c;c++)e=a.charCodeAt(c),128>e?b+=String.fromCharCode(e):e>127&&2048>e?(b+=String.fromCharCode(e>>6|192),b+=String.fromCharCode(63&e|128)):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128),b+=String.fromCharCode(63&e|128));return b},_utf8_decode:function(a){for(var b="",c=0,d=0,e=0,f=0;cd?(b+=String.fromCharCode(d),c++):d>191&&224>d?(e=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&e),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&e)<<6|63&f),c+=3);return b}},c.bindingHandlers.tooltip={init:function(a,d){if(!Eb.bMobileDevice){var e=b(a),f=e.data("tooltip-class")||"",g=e.data("tooltip-placement")||"top";e.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:g,trigger:"hover",title:function(){return e.is(".disabled")||Eb.dropdownVisibility()?"":''+Bb.i18n(c.utils.unwrapObservable(d()))+""}}).click(function(){e.tooltip("hide")}),Eb.dropdownVisibility.subscribe(function(a){a&&e.tooltip("hide")})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a),e=d.data("tooltip-class")||"",f=d.data("tooltip-placement")||"top";d.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:f,title:function(){return d.is(".disabled")||Eb.dropdownVisibility()?"":''+c()()+""}}).click(function(){d.tooltip("hide")}),Eb.dropdownVisibility.subscribe(function(a){a&&d.tooltip("hide")})}},c.bindingHandlers.tooltip3={init:function(a){var c=b(a);c.tooltip({container:"body",trigger:"hover manual",title:function(){return c.data("tooltip3-data")||""}}),Eb.dropdownVisibility.subscribe(function(a){a&&c.tooltip("hide")}),Mb.click(function(){c.tooltip("hide")})},update:function(a,d){var e=c.utils.unwrapObservable(d());""===e?b(a).data("tooltip3-data","").tooltip("hide"):b(a).data("tooltip3-data",e).tooltip("show")}},c.bindingHandlers.registrateBootstrapDropdown={init:function(a){Gb.push(b(a))}},c.bindingHandlers.openDropdownTrigger={update:function(a,d){if(c.utils.unwrapObservable(d())){var e=b(a);e.hasClass("open")||(e.find(".dropdown-toggle").dropdown("toggle"),Bb.detectDropdownVisibility()),d()(!1)}}},c.bindingHandlers.dropdownCloser={init:function(a){b(a).closest(".dropdown").on("click",".e-item",function(){b(a).dropdown("toggle")})}},c.bindingHandlers.popover={init:function(a,d){b(a).popover(c.utils.unwrapObservable(d()))}},c.bindingHandlers.csstext={init:function(a,d){a&&a.styleSheet&&!Bb.isUnd(a.styleSheet.cssText)?a.styleSheet.cssText=c.utils.unwrapObservable(d()):b(a).text(c.utils.unwrapObservable(d()))},update:function(a,d){a&&a.styleSheet&&!Bb.isUnd(a.styleSheet.cssText)?a.styleSheet.cssText=c.utils.unwrapObservable(d()):b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.resizecrop={init:function(a){b(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,c){c()(),b(a).resizecrop({width:"100",height:"100"})}},c.bindingHandlers.onEnter={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&13===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.onEsc={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&27===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.clickOnTrue={update:function(a,d){c.utils.unwrapObservable(d())&&b(a).click()}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Eb.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("shown",function(){Bb.windowResize()}).find(".close").click(function(){d()(!1)})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){Bb.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),Bb.i18nToNode(a)}},c.bindingHandlers.link={update:function(a,d){b(a).attr("href",c.utils.unwrapObservable(d()))}},c.bindingHandlers.title={update:function(a,d){b(a).attr("title",c.utils.unwrapObservable(d()))}},c.bindingHandlers.textF={init:function(a,d){b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.initDom={init:function(a,b){b()(a)}},c.bindingHandlers.initResizeTrigger={init:function(a,d){var e=c.utils.unwrapObservable(d());b(a).css({height:e[1],"min-height":e[1]})},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=Bb.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=Bb.pInt(e[2]),g=Lb.height()-h,g>f&&(f=g),b(a).css({height:f,"min-height":f}))}},c.bindingHandlers.appendDom={update:function(a,d){b(a).hide().empty().append(c.utils.unwrapObservable(d())).show()}},c.bindingHandlers.draggable={init:function(d,e,f){if(!Eb.bMobileDevice){var g=100,h=3,i=f(),j=i&&i.droppableSelector?i.droppableSelector:"",k={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};j&&(k.drag=function(c){b(j).each(function(){var d=null,e=null,f=b(this),i=f.offset(),j=i.top+f.height();a.clearInterval(f.data("timerScroll")),f.data("timerScroll",!1),c.pageX>=i.left&&c.pageX<=i.left+f.width()&&(c.pageY>=j-g&&c.pageY<=j&&(d=function(){f.scrollTop(f.scrollTop()+h),Bb.windowResize()},f.data("timerScroll",a.setInterval(d,10)),d()),c.pageY>=i.top&&c.pageY<=i.top+g&&(e=function(){f.scrollTop(f.scrollTop()-h),Bb.windowResize()},f.data("timerScroll",a.setInterval(e,10)),e()))})},k.stop=function(){b(j).each(function(){a.clearInterval(b(this).data("timerScroll")),b(this).data("timerScroll",!1)})}),k.helper=function(a){return e()(a&&a.target?c.dataFor(a.target):null,!!a.shiftKey)},b(d).draggable(k).on("mousedown",function(){Bb.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Eb.bMobileDevice){var e=c(),f=d(),g=f&&f.droppableOver?f.droppableOver:null,h=f&&f.droppableOut?f.droppableOut:null,i={tolerance:"pointer",hoverClass:"droppableHover"};e&&(i.drop=function(a,b){e(a,b)},g&&(i.over=function(a,b){g(a,b)}),h&&(i.out=function(a,b){h(a,b)}),b(a).droppable(i))}}},c.bindingHandlers.nano={init:function(a){Eb.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text],input[type=email],input[type=password],select,textarea")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.append('  ').addClass("settings-saved-trigger"):c.addClass("settings-saved-trigger-input")},update:function(a,d){var e=c.utils.unwrapObservable(d()),f=b(a);if("custom"===f.data("save-trigger-type"))switch(e.toString()){case"1":f.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case"0":f.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case"-2":f.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:f.find(".animated").hide().end().find(".error,.success").removeClass("visible")}else switch(e.toString()){case"1":f.addClass("success").removeClass("error");break;case"0":f.addClass("error").removeClass("success");break;case"-2":break;default:f.removeClass("error success")}}},c.bindingHandlers.emailsTags={init:function(a,c){var d=b(a),e=c();d.inputosaurus({parseOnBlur:!0,inputDelimiters:[",",";"],autoCompleteSource:function(a,b){Ob.getAutocomplete(a.term,function(a){b(h.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return h.map(a,function(a){var b=Bb.trim(a),c=null;return""!==b?(c=new u,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:h.bind(function(a){d.data("EmailsTagsValue",a.target.value),e(a.target.value)},this)}),e.subscribe(function(a){d.data("EmailsTagsValue")!==a&&(d.val(a),d.data("EmailsTagsValue",a),d.inputosaurus("refresh"))}),e.focusTrigger&&e.focusTrigger.subscribe(function(){d.inputosaurus("focus")})}},c.bindingHandlers.command={init:function(a,d,e,f){var g=b(a),h=d();if(!h||!h.enabled||!h.canExecute)throw new Error("You are not using command function");g.addClass("command"),c.bindingHandlers[g.is("form")?"submit":"click"].init.apply(f,arguments)},update:function(a,c){var d=!0,e=b(a),f=c();d=f.enabled(),e.toggleClass("command-not-enabled",!d),d&&(d=f.canExecute(),e.toggleClass("command-can-not-be-execute",!d)),e.toggleClass("command-disabled disable disabled",!d).toggleClass("no-disabled",!!d),(e.is("input")||e.is("button"))&&e.prop("disabled",!d)}},c.extenders.trimmer=function(a){var b=c.computed({read:a,write:function(b){a(Bb.trim(b.toString()))},owner:this});return b(a()),b},c.extenders.reversible=function(a){var b=a();return a.commit=function(){b=a()},a.reverse=function(){a(b)},a.commitedValue=function(){return b},a},c.extenders.toggleSubscribe=function(a,b){return a.subscribe(b[1],b[0],"beforeChange"),a.subscribe(b[2],b[0]),a},c.extenders.falseTimeout=function(b,c){return b.iTimeout=0,b.subscribe(function(d){d&&(a.clearTimeout(b.iTimeout),b.iTimeout=a.setTimeout(function(){b(!1),b.iTimeout=0},Bb.pInt(c)))}),b},c.observable.fn.validateNone=function(){return this.hasError=c.observable(!1),this},c.observable.fn.validateEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=Bb.trim(a),this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateSimpleEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=Bb.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),Bb.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},k.prototype.root=function(){return this.sBase},k.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},k.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},k.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},k.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},k.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},k.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},k.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},k.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},k.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},k.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},k.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},k.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},k.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},k.prototype.settings=function(a){var b=this.sBase+"settings";return Bb.isUnd(a)||""===a||(b+="/"+a),b},k.prototype.admin=function(a){var b=this.sBase;switch(a){case"AdminDomains":b+="domains";break;case"AdminSecurity":b+="security";break;case"AdminLicensing":b+="licensing"}return b},k.prototype.mailBox=function(a,b,c){b=Bb.isNormal(b)?Bb.pInt(b):1,c=Bb.pString(c);var d=this.sBase+"mailbox/";return""!==a&&(d+=encodeURI(a)),b>1&&(d=d.replace(/[\/]+$/,""),d+="/p"+b),""!==c&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(c)),d},k.prototype.phpInfo=function(){return this.sServer+"Info"},k.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},k.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},k.prototype.exportContactsVcf=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsVcf/"},k.prototype.exportContactsCsv=function(){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ContactsCsv/"},k.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},k.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},k.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},k.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},k.prototype.openPgpJs=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/js/openpgp.min.js"},k.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},k.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},k.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},Cb.oViewModelsHooks={},Cb.oSimpleHooks={},Cb.regViewModelHook=function(a,b){b&&(b.__hookName=a)},Cb.addHook=function(a,b){Bb.isFunc(b)&&(Bb.isArray(Cb.oSimpleHooks[a])||(Cb.oSimpleHooks[a]=[]),Cb.oSimpleHooks[a].push(b))},Cb.runHook=function(a,b){Bb.isArray(Cb.oSimpleHooks[a])&&(b=b||[],h.each(Cb.oSimpleHooks[a],function(a){a.apply(null,b)}))},Cb.mainSettingsGet=function(a){return Ob?Ob.settingsGet(a):null},Cb.remoteRequest=function(a,b,c,d,e,f){Ob&&Ob.remote().defaultRequest(a,b,c,d,e,f)},Cb.settingsGet=function(a,b){var c=Cb.mainSettingsGet("Plugins");return c=c&&Bb.isUnd(c[a])?null:c[a],c?Bb.isUnd(c[b])?null:c[b]:null},l.prototype.blurTrigger=function(){if(this.fOnBlur){var b=this;a.clearTimeout(b.iBlurTimer),b.iBlurTimer=a.setTimeout(function(){b.fOnBlur()},200)}},l.prototype.focusTrigger=function(){this.fOnBlur&&a.clearTimeout(this.iBlurTimer)},l.prototype.isHtml=function(){return this.editor?"wysiwyg"===this.editor.mode:!1},l.prototype.checkDirty=function(){return this.editor?this.editor.checkDirty():!1},l.prototype.resetDirty=function(){this.editor&&this.editor.resetDirty()},l.prototype.getData=function(){return this.editor?"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain?this.editor.__plain.getRawData():this.editor.getData():""},l.prototype.modeToggle=function(a){this.editor&&(a?"plain"===this.editor.mode&&this.editor.setMode("wysiwyg"):"wysiwyg"===this.editor.mode&&this.editor.setMode("plain"))},l.prototype.setHtml=function(a,b){this.editor&&(this.modeToggle(!0),this.editor.setData(a),b&&this.focus())},l.prototype.setPlain=function(a,b){if(this.editor){if(this.modeToggle(!1),"plain"===this.editor.mode&&this.editor.plugins.plain&&this.editor.__plain)return this.editor.__plain.setRawData(a);this.editor.setData(a),b&&this.focus()}},l.prototype.init=function(){if(this.$element&&this.$element[0]){var b=this,c=Eb.oHtmlEditorDefaultConfig,d=Ob.settingsGet("Language"),e=!!Ob.settingsGet("AllowHtmlEditorSourceButton");e&&c.toolbarGroups&&!c.toolbarGroups.__SourceInited&&(c.toolbarGroups.__SourceInited=!0,c.toolbarGroups.push({name:"document",groups:["mode","document","doctools"]})),c.language=Eb.oHtmlEditorLangsMap[d]||"en",b.editor=a.CKEDITOR.appendTo(b.$element[0],c),b.editor.on("key",function(a){return a&&a.data&&9===a.data.keyCode?!1:void 0}),b.editor.on("blur",function(){b.blurTrigger()}),b.editor.on("mode",function(){b.blurTrigger(),b.fOnModeChange&&b.fOnModeChange("plain"!==b.editor.mode)}),b.editor.on("focus",function(){b.focusTrigger()}),b.fOnReady&&b.editor.on("instanceReady",function(){b.editor.setKeystroke(a.CKEDITOR.CTRL+65,"selectAll"),b.fOnReady(),b.__resizable=!0,b.resize()})}},l.prototype.focus=function(){this.editor&&this.editor.focus()},l.prototype.blur=function(){this.editor&&this.editor.focusManager.blur(!0)},l.prototype.resize=function(){this.editor&&this.__resizable&&this.editor.resize(this.$element.width(),this.$element.innerHeight())},l.prototype.clear=function(a){this.setHtml("",a)},m.prototype.itemSelected=function(a){this.isListChecked()?a||(this.oCallbacks.onItemSelect||this.emptyFunction)(a||null):a&&(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},m.prototype.goDown=function(a){this.newSelectPosition(zb.EventKeyCode.Down,!1,a)},m.prototype.goUp=function(a){this.newSelectPosition(zb.EventKeyCode.Up,!1,a)},m.prototype.init=function(a,d,e){if(this.oContentVisible=a,this.oContentScrollable=d,e=e||"all",this.oContentVisible&&this.oContentScrollable){var f=this;b(this.oContentVisible).on("selectstart",function(a){a&&a.preventDefault&&a.preventDefault()}).on("click",this.sItemSelector,function(a){f.actionClick(c.dataFor(this),a)}).on("click",this.sItemCheckedSelector,function(a){var b=c.dataFor(this);b&&(a&&a.shiftKey?f.actionClick(b,a):(f.focusedItem(b),b.checked(!b.checked())))}),j("enter",e,function(){return f.focusedItem()&&!f.focusedItem().selected()?(f.actionClick(f.focusedItem()),!1):!0}),j("ctrl+up, command+up, ctrl+down, command+down",e,function(){return!1}),j("up, shift+up, down, shift+down, home, end, pageup, pagedown, insert, space",e,function(a,b){if(a&&b&&b.shortcut){var c=0;switch(b.shortcut){case"up":case"shift+up":c=zb.EventKeyCode.Up;break;case"down":case"shift+down":c=zb.EventKeyCode.Down;break;case"insert":c=zb.EventKeyCode.Insert;break;case"space":c=zb.EventKeyCode.Space;break;case"home":c=zb.EventKeyCode.Home;break;case"end":c=zb.EventKeyCode.End;break;case"pageup":c=zb.EventKeyCode.PageUp;break;case"pagedown":c=zb.EventKeyCode.PageDown}if(c>0)return f.newSelectPosition(c,j.shift),!1}})}},m.prototype.autoSelect=function(a){this.bAutoSelect=!!a},m.prototype.getItemUid=function(a){var b="",c=this.oCallbacks.onItemGetUid||null;return c&&a&&(b=c(a)),b.toString()},m.prototype.newSelectPosition=function(a,b,c){var d=0,e=10,f=!1,g=!1,i=null,j=this.list(),k=j?j.length:0,l=this.focusedItem();if(k>0)if(l){if(l)if(zb.EventKeyCode.Down===a||zb.EventKeyCode.Up===a||zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a)h.each(j,function(b){if(!g)switch(a){case zb.EventKeyCode.Up:l===b?g=!0:i=b;break;case zb.EventKeyCode.Down:case zb.EventKeyCode.Insert:f?(i=b,g=!0):l===b&&(f=!0)}});else if(zb.EventKeyCode.Home===a||zb.EventKeyCode.End===a)zb.EventKeyCode.Home===a?i=j[0]:zb.EventKeyCode.End===a&&(i=j[j.length-1]);else if(zb.EventKeyCode.PageDown===a){for(;k>d;d++)if(l===j[d]){d+=e,d=d>k-1?k-1:d,i=j[d];break}}else if(zb.EventKeyCode.PageUp===a)for(d=k;d>=0;d--)if(l===j[d]){d-=e,d=0>d?0:d,i=j[d];break}}else zb.EventKeyCode.Down===a||zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a||zb.EventKeyCode.Home===a||zb.EventKeyCode.PageUp===a?i=j[0]:(zb.EventKeyCode.Up===a||zb.EventKeyCode.End===a||zb.EventKeyCode.PageDown===a)&&(i=j[j.length-1]);i?(this.focusedItem(i),l&&(b?(zb.EventKeyCode.Up===a||zb.EventKeyCode.Down===a)&&l.checked(!l.checked()):(zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a)&&l.checked(!l.checked())),!this.bAutoSelect&&!c||this.isListChecked()||zb.EventKeyCode.Space===a||this.selectedItem(i),this.scrollToFocused()):l&&(!b||zb.EventKeyCode.Up!==a&&zb.EventKeyCode.Down!==a?(zb.EventKeyCode.Insert===a||zb.EventKeyCode.Space===a)&&l.checked(!l.checked()):l.checked(!l.checked()),this.focusedItem(l))},m.prototype.scrollToFocused=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=20,c=b(this.sItemFocusedSelector,this.oContentScrollable),d=c.position(),e=this.oContentVisible.height(),f=c.outerHeight();return d&&(d.top<0||d.top+f>e)?(this.oContentScrollable.scrollTop(d.top<0?this.oContentScrollable.scrollTop()+d.top-a:this.oContentScrollable.scrollTop()+d.top-e+f+a),!0):!1},m.prototype.scrollToTop=function(a){return this.oContentVisible&&this.oContentScrollable?(a?this.oContentScrollable.scrollTop(0):this.oContentScrollable.stop().animate({scrollTop:0},200),!0):!1},m.prototype.eventClickFunction=function(a,b){var c=this.getItemUid(a),d=0,e=0,f=null,g="",h=!1,i=!1,j=[],k=!1;if(b&&b.shiftKey&&""!==c&&""!==this.sLastUid&&c!==this.sLastUid)for(j=this.list(),k=a.checked(),d=0,e=j.length;e>d;d++)f=j[d],g=this.getItemUid(f),h=!1,(g===this.sLastUid||g===c)&&(h=!0),h&&(i=!i),(i||h)&&f.checked(k);this.sLastUid=""===c?"":c},m.prototype.actionClick=function(a,b){if(a){var c=!0,d=this.getItemUid(a);b&&(!b.shiftKey||b.ctrlKey||b.altKey?!b.ctrlKey||b.shiftKey||b.altKey||(c=!1,this.focusedItem(a),this.selectedItem()&&a!==this.selectedItem()&&this.selectedItem().checked(!0),a.checked(!a.checked())):(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b),this.focusedItem(a))),c&&(this.focusedItem(a),this.selectedItem(a))}},m.prototype.on=function(a,b){this.oCallbacks[a]=b},n.supported=function(){return!0},n.prototype.set=function(a,c){var d=b.cookie(yb.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(yb.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},n.prototype.get=function(a){var c=b.cookie(yb.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Bb.isUnd(d[a])?d[a]:null}catch(e){}return d},o.supported=function(){return!!a.localStorage},o.prototype.set=function(b,c){var d=a.localStorage[yb.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[yb.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},o.prototype.get=function(b){var c=a.localStorage[yb.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Bb.isUnd(d[b])?d[b]:null}catch(e){}return d},p.prototype.oDriver=null,p.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},p.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},q.prototype.bootstart=function(){},r.prototype.sPosition="",r.prototype.sTemplate="",r.prototype.viewModelName="",r.prototype.viewModelDom=null,r.prototype.viewModelTemplate=function(){return this.sTemplate},r.prototype.viewModelPosition=function(){return this.sPosition},r.prototype.cancelCommand=r.prototype.closeCommand=function(){},r.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=Ob.data().keyScope(),Ob.data().keyScope(this.sDefaultKeyScope)},r.prototype.restoreKeyScope=function(){Ob.data().keyScope(this.sCurrentKeyScope) },r.prototype.registerPopupEscapeKey=function(){var a=this;Lb.on("keydown",function(b){return b&&zb.EventKeyCode.Esc===b.keyCode&&a.modalVisibility&&a.modalVisibility()?(Bb.delegateRun(a,"cancelCommand"),!1):!0})},s.prototype.oCross=null,s.prototype.sScreenName="",s.prototype.aViewModels=[],s.prototype.viewModels=function(){return this.aViewModels},s.prototype.screenName=function(){return this.sScreenName},s.prototype.routes=function(){return null},s.prototype.__cross=function(){return this.oCross},s.prototype.__start=function(){var a=this.routes(),b=null,c=null;Bb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||Bb.emptyFunction,this),b=d.create(),h.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},t.constructorEnd=function(a){Bb.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},t.prototype.sDefaultScreenName="",t.prototype.oScreens={},t.prototype.oBoot=null,t.prototype.oCurrentScreen=null,t.prototype.hideLoading=function(){b("#rl-loading").hide()},t.prototype.routeOff=function(){e.changed.active=!1},t.prototype.routeOn=function(){e.changed.active=!0},t.prototype.setBoot=function(a){return Bb.isNormal(a)&&(this.oBoot=a),this},t.prototype.screen=function(a){return""===a||Bb.isUnd(this.oScreens[a])?null:this.oScreens[a]},t.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),i=null;a.__builded=!0,a.__vm=e,e.data=Ob.data(),e.viewModelName=a.__name,g&&1===g.length?(i=b("
").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(g),e.viewModelDom=i,a.__dom=i,"Popups"===f&&(e.cancelCommand=e.closeCommand=Bb.createCommand(e,function(){Hb.hideScreenPopup(a)}),e.modalVisibility.subscribe(function(a){var b=this;a?(this.viewModelDom.show(),this.storeAndSetKeyScope(),Ob.popupVisibilityNames.push(this.viewModelName),Bb.delegateRun(this,"onFocus",[],500)):(Bb.delegateRun(this,"onHide"),this.restoreKeyScope(),Ob.popupVisibilityNames.remove(this.viewModelName),h.delay(function(){b.viewModelDom.hide()},300))},e)),Cb.runHook("view-model-pre-build",[a.__name,e,i]),c.applyBindings(e,i[0]),Bb.delegateRun(e,"onBuild",[i]),e&&"Popups"===f&&!e.bDisabeCloseOnEsc&&e.registerPopupEscapeKey(),Cb.runHook("view-model-post-build",[a.__name,e,i])):Bb.log("Cannot find view model position: "+f)}return a?a.__vm:null},t.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},t.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__vm.modalVisibility(!1),Cb.runHook("view-model-on-hide",[a.__name,a.__vm]))},t.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__vm.modalVisibility(!0),Bb.delegateRun(a.__vm,"onShow",b||[]),Cb.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},t.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===Bb.pString(a)&&(a=this.sDefaultScreenName),""!==a&&(d=this.screen(a),d||(d=this.screen(this.sDefaultScreenName),d&&(b=a+"/"+b,a=this.sDefaultScreenName)),d&&d.__started&&(d.__builded||(d.__builded=!0,Bb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),Bb.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(Bb.delegateRun(c.oCurrentScreen,"onHide"),Bb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),Bb.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(Bb.delegateRun(c.oCurrentScreen,"onShow"),Cb.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),Bb.isNonEmptyArray(c.oCurrentScreen.viewModels())&&h.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),Bb.delegateRun(a.__vm,"onShow"),Bb.delegateRun(a.__vm,"onFocus",[],200),Cb.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},t.prototype.startScreens=function(a){b("#rl-content").css({visibility:"hidden"}),h.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),h.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),Cb.runHook("screen-pre-start",[a.screenName(),a]),Bb.delegateRun(a,"onStart"),Cb.runHook("screen-post-start",[a.screenName(),a]))},this);var c=d.create();c.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,h.bind(this.screenOnRoute,this)),e.initialized.add(c.parse,c),e.changed.add(c.parse,c),e.init(),b("#rl-content").css({visibility:"visible"}),h.delay(function(){Kb.removeClass("rl-started-trigger").addClass("rl-started")},50)},t.prototype.setHash=function(a,b,c){a="#"===a.substr(0,1)?a.substr(1):a,a="/"===a.substr(0,1)?a.substr(1):a,c=Bb.isUnd(c)?!1:!!c,(Bb.isUnd(b)?1:!b)?(e.changed.active=!0,e[c?"replaceHash":"setHash"](a),e.setHash(a)):(e.changed.active=!1,e[c?"replaceHash":"setHash"](a),e.changed.active=!0)},t.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},Hb=new t,u.newInstanceFromJson=function(a){var b=new u;return b.initByJson(a)?b:null},u.prototype.name="",u.prototype.email="",u.prototype.privateType=null,u.prototype.clear=function(){this.email="",this.name="",this.privateType=null},u.prototype.validate=function(){return""!==this.name||""!==this.email},u.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},u.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},u.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=zb.EmailType.Facebook),null===this.privateType&&(this.privateType=zb.EmailType.Default)),this.privateType},u.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},u.prototype.parse=function(a){this.clear(),a=Bb.trim(a);var b=/(?:"([^"]+)")? ?,]+)>?,? ?/g,c=b.exec(a);c?(this.name=c[1]||"",this.email=c[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)},u.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=Bb.trim(a.Name),this.email=Bb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},u.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=Bb.isUnd(b)?!1:!!b,c=Bb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+Bb.encodeHtml(this.name)+"":c?Bb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=Bb.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+Bb.encodeHtml(d)+""+Bb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=Bb.encodeHtml(d))):b&&(d=''+Bb.encodeHtml(this.email)+""))),d},u.prototype.mailsoParse=function(a){if(a=Bb.trim(a),""===a)return!1;for(var b=function(a,b,c){a+="";var d=a.length;return 0>b&&(b+=d),d="undefined"==typeof c?d:0>c?c+d:c+b,b>=a.length||0>b||b>d?!1:a.slice(b,d)},c=function(a,b,c,d){return 0>c&&(c+=a.length),d=void 0!==d?d:a.length,0>d&&(d=d+a.length-c),a.slice(0,c)+b.substr(0,d)+b.slice(d)+a.slice(c+d)},d="",e="",f="",g=!1,h=!1,i=!1,j=null,k=0,l=0,m=0;m0&&0===d.length&&(d=b(a,0,m)),h=!0,k=m);break;case">":h&&(l=m,e=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,h=!1);break;case"(":g||h||i||(i=!0,k=m);break;case")":i&&(l=m,f=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,i=!1);break;case"\\":m++}m++}return 0===e.length&&(j=a.match(/[^@\s]+@\S+/i),j&&j[0]?e=j[0]:d=a),e.length>0&&0===d.length&&0===f.length&&(d=a.replace(e,"")),e=Bb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=Bb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=Bb.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},u.prototype.inputoTagLine=function(){return 0+$/,""),b=!0),b},x.prototype.isImage=function(){return-1e;e++)d.push(a[e].toLine(b,c));return d.join(", ")},z.initEmailsFromJson=function(a){var b=0,c=0,d=null,e=[];if(Bb.isNonEmptyArray(a))for(b=0,c=a.length;c>b;b++)d=u.newInstanceFromJson(a[b]),d&&e.push(d);return e},z.replyHelper=function(a,b,c){if(a&&0d;d++)Bb.isUnd(b[a[d].email])&&(b[a[d].email]=!0,c.push(a[d]))},z.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(zb.MessagePriority.Normal),this.fromEmailString(""),this.toEmailsString(""),this.senderEmailsString(""),this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.newForAnimation(!1),this.deleted(!1),this.unseen(!1),this.flagged(!1),this.answered(!1),this.forwarded(!1),this.isReadReceipt(!1),this.selected(!1),this.checked(!1),this.hasAttachments(!1),this.attachmentsMainType(""),this.body=null,this.isRtl(!1),this.isHtml(!1),this.hasImages(!1),this.attachments([]),this.isPgpSigned(!1),this.isPgpEncrypted(!1),this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.None),this.pgpSignedVerifyUser(""),this.priority(zb.MessagePriority.Normal),this.readReceipt(""),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(0),this.threads([]),this.threadsLen(0),this.hasUnseenSubMessage(!1),this.hasFlaggedSubMessage(!1),this.lastInCollapsedThread(!1),this.lastInCollapsedThreadLoading(!1)},z.prototype.computeSenderEmail=function(){var a=Ob.data().sentFolder(),b=Ob.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())},z.prototype.initByJson=function(a){var b=!1;return a&&"Object/Message"===a["@Object"]&&(this.folderFullNameRaw=a.Folder,this.uid=a.Uid,this.hash=a.Hash,this.requestHash=a.RequestHash,this.size(Bb.pInt(a.Size)),this.from=z.initEmailsFromJson(a.From),this.to=z.initEmailsFromJson(a.To),this.cc=z.initEmailsFromJson(a.Cc),this.bcc=z.initEmailsFromJson(a.Bcc),this.replyTo=z.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(Bb.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.fromEmailString(z.emailsToLine(this.from,!0)),this.toEmailsString(z.emailsToLine(this.to,!0)),this.parentUid(Bb.pInt(a.ParentThread)),this.threads(Bb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(Bb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},z.prototype.initUpdateByMessageJson=function(a){var b=!1,c=zb.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=Bb.pInt(a.Priority),this.priority(-1b;b++)d=x.newInstanceFromJson(a["@Collection"][b]),d&&(""!==d.cidWithOutTags&&0+$/,""),b=h.find(c,function(b){return a===b.cidWithOutTags})),b||null},z.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();return Bb.isNonEmptyArray(c)&&(b=h.find(c,function(b){return a===b.contentLocation})),b||null},z.prototype.messageId=function(){return this.sMessageId},z.prototype.inReplyTo=function(){return this.sInReplyTo},z.prototype.references=function(){return this.sReferences},z.prototype.fromAsSingleEmail=function(){return Bb.isArray(this.from)&&this.from[0]?this.from[0].email:""},z.prototype.viewLink=function(){return Ob.link().messageViewLink(this.requestHash)},z.prototype.downloadLink=function(){return Ob.link().messageDownloadLink(this.requestHash)},z.prototype.replyEmails=function(a){var b=[],c=Bb.isUnd(a)?{}:a;return z.replyHelper(this.replyTo,c,b),0===b.length&&z.replyHelper(this.from,c,b),b},z.prototype.replyAllEmails=function(a){var b=[],c=[],d=Bb.isUnd(a)?{}:a;return z.replyHelper(this.replyTo,d,b),0===b.length&&z.replyHelper(this.from,d,b),z.replyHelper(this.to,d,b),z.replyHelper(this.cc,d,c),[b,c]},z.prototype.textBodyToString=function(){return this.body?this.body.html():""},z.prototype.attachmentsToStringLine=function(){var a=h.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0=0&&e&&!f&&d.attr("src",e)}),c&&a.setTimeout(function(){d.print()},100))})},z.prototype.printMessage=function(){this.viewPopupMessage(!0)},z.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},z.prototype.populateByMessageListItem=function(a){return this.folderFullNameRaw=a.folderFullNameRaw,this.uid=a.uid,this.hash=a.hash,this.requestHash=a.requestHash,this.subject(a.subject()),this.size(a.size()),this.dateTimeStampInUTC(a.dateTimeStampInUTC()),this.priority(a.priority()),this.fromEmailString(a.fromEmailString()),this.toEmailsString(a.toEmailsString()),this.emails=a.emails,this.from=a.from,this.to=a.to,this.cc=a.cc,this.bcc=a.bcc,this.replyTo=a.replyTo,this.unseen(a.unseen()),this.flagged(a.flagged()),this.answered(a.answered()),this.forwarded(a.forwarded()),this.isReadReceipt(a.isReadReceipt()),this.selected(a.selected()),this.checked(a.checked()),this.hasAttachments(a.hasAttachments()),this.attachmentsMainType(a.attachmentsMainType()),this.moment(a.moment()),this.body=null,this.priority(zb.MessagePriority.Normal),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid(a.parentUid()),this.threads(a.threads()),this.threadsLen(a.threadsLen()),this.computeSenderEmail(),this},z.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=Bb.isUnd(a)?!1:a,this.hasImages(!1),this.body.data("rl-has-images",!1),b("[data-x-src]",this.body).each(function(){a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",b(this).attr("data-x-src")).removeAttr("data-x-src"):b(this).attr("src",b(this).attr("data-x-src")).removeAttr("data-x-src")}),b("[data-x-style-url]",this.body).each(function(){var a=Bb.trim(b(this).attr("style"));a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+b(this).attr("data-x-style-url")).removeAttr("data-x-style-url")}),a&&(b("img.lazy",this.body).addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b(".RL-MailMessageView .messageView .messageItem .content")[0]}),Lb.resize()),Bb.windowResize(500))},z.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){this.body.data("rl-init-internal-images",!0),a=Bb.isUnd(a)?!1:a;var c=this;b("[data-x-src-cid]",this.body).each(function(){var d=c.findAttachmentByCid(b(this).attr("data-x-src-cid"));d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-src-location]",this.body).each(function(){var d=c.findAttachmentByContentLocation(b(this).attr("data-x-src-location"));d||(d=c.findAttachmentByCid(b(this).attr("data-x-src-location"))),d&&d.download&&(a&&b(this).is("img")?b(this).addClass("lazy").attr("data-original",d.linkPreview()):b(this).attr("src",d.linkPreview()))}),b("[data-x-style-cid]",this.body).each(function(){var a="",d="",e=c.findAttachmentByCid(b(this).attr("data-x-style-cid"));e&&e.linkPreview&&(d=b(this).attr("data-x-style-cid-name"),""!==d&&(a=Bb.trim(b(this).attr("style")),a=""===a?"":";"===a.substr(-1)?a+" ":a+"; ",b(this).attr("style",a+d+": url('"+e.linkPreview()+"')")))}),a&&!function(a,b){h.delay(function(){a.addClass("lazy-inited").lazyload({threshold:400,effect:"fadeIn",skip_invisible:!1,container:b})},300)}(b("img.lazy",c.body),b(".RL-MailMessageView .messageView .messageItem .content")[0]),Bb.windowResize(500)}},z.prototype.storeDataToDom=function(){this.body&&(this.body.data("rl-is-rtl",!!this.isRtl()),this.body.data("rl-is-html",!!this.isHtml()),this.body.data("rl-has-images",!!this.hasImages()),this.body.data("rl-plain-raw",this.plainRaw),Ob.data().allowOpenPGP()&&(this.body.data("rl-plain-pgp-signed",!!this.isPgpSigned()),this.body.data("rl-plain-pgp-encrypted",!!this.isPgpEncrypted()),this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser())))},z.prototype.storePgpVerifyDataToDom=function(){this.body&&Ob.data().allowOpenPGP()&&(this.body.data("rl-pgp-verify-status",this.pgpSignedVerifyStatus()),this.body.data("rl-pgp-verify-user",this.pgpSignedVerifyUser()))},z.prototype.fetchDataToDom=function(){this.body&&(this.isRtl(!!this.body.data("rl-is-rtl")),this.isHtml(!!this.body.data("rl-is-html")),this.hasImages(!!this.body.data("rl-has-images")),this.plainRaw=Bb.pString(this.body.data("rl-plain-raw")),Ob.data().allowOpenPGP()?(this.isPgpSigned(!!this.body.data("rl-plain-pgp-signed")),this.isPgpEncrypted(!!this.body.data("rl-plain-pgp-encrypted")),this.pgpSignedVerifyStatus(this.body.data("rl-pgp-verify-status")),this.pgpSignedVerifyUser(this.body.data("rl-pgp-verify-user"))):(this.isPgpSigned(!1),this.isPgpEncrypted(!1),this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.None),this.pgpSignedVerifyUser("")))},z.prototype.verifyPgpSignedClearMessage=function(){if(this.isPgpSigned()){var c=[],d=null,e=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",f=Ob.data().findPublicKeysByEmail(e),g=null,i=null,j="";this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.Error),this.pgpSignedVerifyUser("");try{d=a.openpgp.cleartext.readArmored(this.plainRaw),d&&d.getText&&(this.pgpSignedVerifyStatus(f.length?zb.SignedVerifyStatus.Unverified:zb.SignedVerifyStatus.UnknownPublicKeys),c=d.verify(f),c&&0').text(j)).html(),Pb.empty(),this.replacePlaneTextBody(j)))))}catch(k){}this.storePgpVerifyDataToDom()}},z.prototype.decryptPgpEncryptedMessage=function(c){if(this.isPgpEncrypted()){var d=[],e=null,f=null,g=this.from&&this.from[0]&&this.from[0].email?this.from[0].email:"",i=Ob.data().findPublicKeysByEmail(g),j=Ob.data().findSelfPrivateKey(c),k=null,l=null,m="";this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.Error),this.pgpSignedVerifyUser(""),j||this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.UnknownPrivateKey);try{e=a.openpgp.message.readArmored(this.plainRaw),e&&j&&e.decrypt&&(this.pgpSignedVerifyStatus(zb.SignedVerifyStatus.Unverified),f=e.decrypt(j),f&&(d=f.verify(i),d&&0').text(m)).html(),Pb.empty(),this.replacePlaneTextBody(m)))}catch(n){}this.storePgpVerifyDataToDom()}},z.prototype.replacePlaneTextBody=function(a){this.body&&this.body.html(a).addClass("b-text-part plain")},z.prototype.flagHash=function(){return[this.deleted(),this.unseen(),this.flagged(),this.answered(),this.forwarded(),this.isReadReceipt()].join("")},A.newInstanceFromJson=function(a){var b=new A;return b.initByJson(a)?b.initComputed():null},A.prototype.initComputed=function(){return this.hasSubScribedSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.subScribed()&&!a.isSystemFolder()})},this),this.canBeEdited=c.computed(function(){return zb.FolderType.User===this.type()&&this.existen&&this.selectable},this),this.visible=c.computed(function(){var a=this.subScribed(),b=this.hasSubScribedSubfolders();return a||b&&(!this.existen||!this.selectable)},this),this.isSystemFolder=c.computed(function(){return zb.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return a&&!b||!this.selectable&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){Bb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){Bb.isPosNumeric(a,!0)?this.privateMessageCountUnread(a):this.privateMessageCountUnread.valueHasMutated()},owner:this}),this.printableUnreadCount=c.computed(function(){var a=this.messageCountAll(),b=this.messageCountUnread(),c=this.type();if(zb.FolderType.Inbox===c&&Ob.data().foldersInboxUnreadCount(b),a>0){if(zb.FolderType.Draft===c)return""+a;if(b>0&&zb.FolderType.Trash!==c&&zb.FolderType.Archive!==c&&zb.FolderType.SentItems!==c)return""+b}return""},this),this.canBeDeleted=c.computed(function(){var a=this.isSystemFolder();return!a&&0===this.subFolders().length&&"INBOX"!==this.fullNameRaw},this),this.canBeSubScribed=c.computed(function(){return!this.isSystemFolder()&&this.selectable&&"INBOX"!==this.fullNameRaw},this),this.visible.subscribe(function(){Bb.timeOutAction("folder-list-folder-visibility-change",function(){Lb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){Eb.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case zb.FolderType.Inbox:b=Bb.i18n("FOLDER_LIST/INBOX_NAME");break;case zb.FolderType.SentItems:b=Bb.i18n("FOLDER_LIST/SENT_NAME");break;case zb.FolderType.Draft:b=Bb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case zb.FolderType.Spam:b=Bb.i18n("FOLDER_LIST/SPAM_NAME");break;case zb.FolderType.Trash:b=Bb.i18n("FOLDER_LIST/TRASH_NAME");break;case zb.FolderType.Archive:b=Bb.i18n("FOLDER_LIST/ARCHIVE_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){Eb.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case zb.FolderType.Inbox:a="("+Bb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case zb.FolderType.SentItems:a="("+Bb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case zb.FolderType.Draft:a="("+Bb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case zb.FolderType.Spam:a="("+Bb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case zb.FolderType.Trash:a="("+Bb.i18n("FOLDER_LIST/TRASH_NAME")+")";break;case zb.FolderType.Archive:a="("+Bb.i18n("FOLDER_LIST/ARCHIVE_NAME")+")"}return(""!==a&&"("+c+")"===a||"(inbox)"===a.toLowerCase())&&(a=""),a},this),this.collapsed=c.computed({read:function(){return!this.hidden()&&this.collapsedPrivate()},write:function(a){this.collapsedPrivate(a)},owner:this}),this.hasUnreadMessages=c.computed(function(){return 0"},C.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},C.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+Bb.quoteName(a)+'" <'+this.email()+">"},D.prototype.index=0,D.prototype.id="",D.prototype.guid="",D.prototype.user="",D.prototype.email="",D.prototype.armor="",D.prototype.isPrivate=!1,Bb.extendAsViewModel("PopupsFolderClearViewModel",E),E.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},E.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},Bb.extendAsViewModel("PopupsFolderCreateViewModel",F),F.prototype.sNoParentText="",F.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(Bb.trim(a))},F.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.folderName.focused(!1)},F.prototype.onShow=function(){this.clearPopup()},F.prototype.onFocus=function(){this.folderName.focused(!0)},Bb.extendAsViewModel("PopupsFolderSystemViewModel",G),G.prototype.sChooseOnText="",G.prototype.sUnuseText="",G.prototype.onShow=function(a){var b="";switch(a=Bb.isUnd(a)?zb.SetSystemFoldersNotification.None:a){case zb.SetSystemFoldersNotification.Sent:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case zb.SetSystemFoldersNotification.Draft:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case zb.SetSystemFoldersNotification.Spam:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case zb.SetSystemFoldersNotification.Trash:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH");break;case zb.SetSystemFoldersNotification.Archive:b=Bb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE")}this.notification(b)},Bb.extendAsViewModel("PopupsComposeViewModel",H),H.prototype.openOpenPgpPopup=function(){if(this.allowOpenPGP()&&this.oEditor&&!this.oEditor.isHtml()){var a=this;Hb.showScreenPopup(O,[function(b){a.editor(function(a){a.setPlain(b)})},this.oEditor.getData(),this.currentIdentityResultEmail(),this.to(),this.cc(),this.bcc()])}},H.prototype.reloadDraftFolder=function(){var a=Ob.data().draftFolder();""!==a&&(Ob.cache().setFolderHash(a,""),Ob.data().currentFolderFullNameRaw()===a?Ob.reloadMessageList(!0):Ob.folderInformation(a))},H.prototype.findIdentityIdByMessage=function(a,b){var c={},d="",e=function(a){return a&&a.email&&c[a.email]?(d=c[a.email],!0):!1};if(this.bAllowIdentities&&h.each(this.identities(),function(a){c[a.email()]=a.id}),c[Ob.data().accountEmail()]=Ob.data().accountEmail(),b)switch(a){case zb.ComposeType.Empty:d=Ob.data().accountEmail();break;case zb.ComposeType.Reply:case zb.ComposeType.ReplyAll:case zb.ComposeType.Forward:case zb.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case zb.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}else d=Ob.data().accountEmail();return d},H.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},H.prototype.formattedFrom=function(a){var b=Ob.data().displayName(),c=Ob.data().accountEmail();return""===b?c:(Bb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+Bb.quoteName(b)+'" <'+c+">"},H.prototype.sendMessageResponse=function(b,c){var d=!1,e="";this.sending(!1),zb.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&Bb.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&zb.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(Bb.trim(Bb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(e=Bb.getNotification(c&&c.ErrorCode?c.ErrorCode:zb.Notification.CantSendMessage,c&&c.ErrorMessage?c.ErrorMessage:""),this.sendError(!0),a.alert(e||Bb.getNotification(zb.Notification.CantSendMessage)))),this.reloadDraftFolder()},H.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),zb.StorageResultType.Success===b&&c&&c.Result&&c.Result.NewFolder&&c.Result.NewUid&&(this.bFromDraft&&(e=Ob.data().message(),e&&this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid&&Ob.data().message(null)),this.draftFolder(c.Result.NewFolder),this.draftUid(c.Result.NewUid),this.modalVisibility()&&(this.savedTime(Math.round((new a.Date).getTime()/1e3)),this.savedOrSendingText(0c;c++)e.push(a[c].toLine(!!b));return e.join(", ")};if(c=c||null,c&&Bb.isNormal(c)&&(v=Bb.isArray(c)&&1===c.length?c[0]:Bb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(w,v))),this.reset(),Bb.isNonEmptyArray(d)&&this.to(x(d)),""!==w&&v){switch(j=v.fullFormatDateValue(),k=v.subject(),u=v.aDraftInfo,l=b(v.body).clone(),Bb.removeBlockquoteSwitcher(l),m=l.html(),w){case zb.ComposeType.Empty:break;case zb.ComposeType.Reply:this.to(x(v.replyEmails(p))),this.subject(Bb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.sReferences);break;case zb.ComposeType.ReplyAll:o=v.replyAllEmails(p),this.to(x(o[0])),this.cc(x(o[1])),this.subject(Bb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.references());break;case zb.ComposeType.Forward:this.subject(Bb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.sReferences);break;case zb.ComposeType.ForwardAsAttachment:this.subject(Bb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Bb.trim(this.sInReplyTo+" "+v.sReferences);break;case zb.ComposeType.Draft:this.to(x(v.to)),this.cc(x(v.cc)),this.bcc(x(v.bcc)),this.bFromDraft=!0,this.draftFolder(v.folderFullNameRaw),this.draftUid(v.uid),this.subject(k),this.prepearMessageAttachments(v,w),this.aDraftInfo=Bb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences;break;case zb.ComposeType.EditAsNew:this.to(x(v.to)),this.cc(x(v.cc)),this.bcc(x(v.bcc)),this.subject(k),this.prepearMessageAttachments(v,w),this.aDraftInfo=Bb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences}switch(w){case zb.ComposeType.Reply:case zb.ComposeType.ReplyAll:f=v.fromToLine(!1,!0),n=Bb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="

"+n+":

"+m+"

";break;case zb.ComposeType.Forward:f=v.fromToLine(!1,!0),g=v.toToLine(!1,!0),i=v.ccToLine(!1,!0),m="


"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+Bb.encodeHtml(j)+"
"+Bb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+Bb.encodeHtml(k)+"

"+m;break;case zb.ComposeType.ForwardAsAttachment:m=""}s&&""!==r&&zb.ComposeType.EditAsNew!==w&&zb.ComposeType.Draft!==w&&(m=this.convertSignature(r,x(v.from,!0))+"
"+m),this.editor(function(a){a.setHtml(m,!1),v.isHtml()||a.modeToggle(!1)})}else zb.ComposeType.Empty===w?(m=this.convertSignature(r),this.editor(function(a){a.setHtml(m,!1),zb.EditorDefaultType.Html!==Ob.data().editorDefaultType()&&a.modeToggle(!1)})):Bb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});t=this.getAttachmentsDownloadsForUpload(),Bb.isNonEmptyArray(t)&&Ob.remote().messageUploadAttachments(function(a,b){if(zb.StorageResultType.Success===a&&b&&b.Result){var c=null,d="";if(!e.viewModelVisibility())for(d in b.Result)b.Result.hasOwnProperty(d)&&(c=e.getAttachmentById(b.Result[d]),c&&c.tempName(d))}else e.setMessageAttachmentFailedDowbloadText()},t),this.triggerForResize()},H.prototype.onFocus=function(){""===this.to()?this.to.focusTrigger(!this.to.focusTrigger()):this.oEditor&&this.oEditor.focus(),this.triggerForResize()},H.prototype.editorResize=function(){this.oEditor&&this.oEditor.resize()},H.prototype.tryToClosePopup=function(){var a=this;Hb.showScreenPopup(S,[Bb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&Bb.delegateRun(a,"closeCommand")}])},H.prototype.onBuild=function(){this.initUploader();var a=this,c=null;j("ctrl+q, command+q",zb.KeyState.Compose,function(){return a.identitiesDropdownTrigger(!0),!1}),j("ctrl+s, command+s",zb.KeyState.Compose,function(){return a.saveCommand(),!1}),j("ctrl+enter, command+enter",zb.KeyState.Compose,function(){return a.sendCommand(),!1}),j("esc",zb.KeyState.Compose,function(){return a.tryToClosePopup(),!1}),Lb.on("resize",function(){a.triggerForResize()}),this.dropboxEnabled()&&(c=document.createElement("script"),c.type="text/javascript",c.src="https://www.dropbox.com/static/api/1/dropins.js",b(c).attr("id","dropboxjs").attr("data-app-key",Ob.settingsGet("DropboxApiKey")),document.body.appendChild(c))},H.prototype.getAttachmentById=function(a){for(var b=this.attachments(),c=0,d=b.length;d>c;c++)if(b[c]&&a===b[c].id)return b[c];return null},H.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=Bb.pInt(Ob.settingsGet("AttachmentLimit")),c=new g({action:Ob.link().upload(),name:"uploader",queueSize:2,multipleSizeLimit:50,disableFolderDragAndDrop:!1,clickElement:this.composeUploaderButton(),dragAndDropElement:this.composeUploaderDropPlace()});c?(c.on("onDragEnter",h.bind(function(){this.dragAndDropOver(!0)},this)).on("onDragLeave",h.bind(function(){this.dragAndDropOver(!1)},this)).on("onBodyDragEnter",h.bind(function(){this.dragAndDropVisible(!0)},this)).on("onBodyDragLeave",h.bind(function(){this.dragAndDropVisible(!1)},this)).on("onProgress",h.bind(function(b,c,d){var e=null;Bb.isUnd(a[b])?(e=this.getAttachmentById(b),e&&(a[b]=e)):e=a[b],e&&e.progress(" - "+Math.floor(c/d*100)+"%")},this)).on("onSelect",h.bind(function(a,d){this.dragAndDropOver(!1);var e=this,f=Bb.isUnd(d.FileName)?"":d.FileName.toString(),g=Bb.isNormal(d.Size)?Bb.pInt(d.Size):null,h=new y(a,f,g);return h.cancel=function(a){return function(){e.attachments.remove(function(b){return b&&b.id===a}),c&&c.cancel(a)}}(a),this.attachments.push(h),g>0&&b>0&&g>b?(h.error(Bb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;Bb.isUnd(a[b])?(c=this.getAttachmentById(b),c&&(a[b]=c)):c=a[b],c&&(c.waiting(!1),c.uploading(!0))},this)).on("onComplete",h.bind(function(b,c,d){var e="",f=null,g=null,h=this.getAttachmentById(b);g=c&&d&&d.Result&&d.Result.Attachment?d.Result.Attachment:null,f=d&&d.Result&&d.Result.ErrorCode?d.Result.ErrorCode:null,null!==f?e=Bb.getUploadErrorDescByCode(f):g||(e=Bb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&00&&d>0&&f>d?(e.uploading(!1),e.error(Bb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Ob.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),zb.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(Bb.getUploadErrorDescByCode(zb.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},H.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=Bb.isNonEmptyArray(a.attachments())?a.attachments():[],e=0,f=d.length,g=null,h=null,i=!1,j=function(a){return function(){c.attachments.remove(function(b){return b&&b.id===a})}};if(zb.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case zb.ComposeType.Reply:case zb.ComposeType.ReplyAll:i=h.isLinked;break;case zb.ComposeType.Forward:case zb.ComposeType.Draft:case zb.ComposeType.EditAsNew:i=!0}i=!0,i&&(g=new y(h.download,h.fileName,h.estimatedSize,h.isInline,h.isLinked,h.cid,h.contentLocation),g.fromMessage=!0,g.cancel=j(h.download),g.waiting(!1).uploading(!0),this.attachments.push(g))}}},H.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},H.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(Bb.getUploadErrorDescByCode(zb.UploadErrorCode.FileNoUploaded))},this)},H.prototype.isEmptyForm=function(a){a=Bb.isUnd(a)?!0:!!a;var b=a?0===this.attachments().length:0===this.attachmentsInReady().length;return 0===this.to().length&&0===this.cc().length&&0===this.bcc().length&&0===this.subject().length&&b&&(!this.oEditor||""===this.oEditor.getData())},H.prototype.reset=function(){this.to(""),this.cc(""),this.bcc(""),this.replyTo(""),this.subject(""),this.requestReadReceipt(!1),this.aDraftInfo=null,this.sInReplyTo="",this.bFromDraft=!1,this.sReferences="",this.sendError(!1),this.sendSuccessButSaveError(!1),this.savedError(!1),this.savedTime(0),this.savedOrSendingText(""),this.emptyToError(!1),this.showCcAndBcc(!1),this.attachments([]),this.dragAndDropOver(!1),this.dragAndDropVisible(!1),this.draftFolder(""),this.draftUid(""),this.sending(!1),this.saving(!1),this.oEditor&&this.oEditor.clear(!1)},H.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},H.prototype.triggerForResize=function(){this.resizer(!this.resizer()),this.editorResizeThrottle()},Bb.extendAsViewModel("PopupsContactsViewModel",I),I.prototype.getPropertyPlceholder=function(a){var b="";switch(a){case zb.ContactPropertyType.LastName:b="CONTACTS/PLACEHOLDER_ENTER_LAST_NAME";break;case zb.ContactPropertyType.FirstName:b="CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME";break;case zb.ContactPropertyType.Nick:b="CONTACTS/PLACEHOLDER_ENTER_NICK_NAME"}return b},I.prototype.addNewProperty=function(a,b){this.viewProperties.push(new w(a,b||"","",!0,this.getPropertyPlceholder(a)))},I.prototype.addNewOrFocusProperty=function(a,b){var c=h.find(this.viewProperties(),function(b){return a===b.type()});c?c.focused(!0):this.addNewProperty(a,b)},I.prototype.addNewEmail=function(){this.addNewProperty(zb.ContactPropertyType.Email,"Home")},I.prototype.addNewPhone=function(){this.addNewProperty(zb.ContactPropertyType.Phone,"Mobile")},I.prototype.addNewWeb=function(){this.addNewProperty(zb.ContactPropertyType.Web)},I.prototype.addNewNickname=function(){this.addNewOrFocusProperty(zb.ContactPropertyType.Nick)},I.prototype.addNewNotes=function(){this.addNewOrFocusProperty(zb.ContactPropertyType.Note)},I.prototype.addNewBirthday=function(){this.addNewOrFocusProperty(zb.ContactPropertyType.Birthday)},I.prototype.exportVcf=function(){Ob.download(Ob.link().exportContactsVcf())},I.prototype.exportCsv=function(){Ob.download(Ob.link().exportContactsCsv())},I.prototype.initUploader=function(){if(this.importUploaderButton()){var b=new g({action:Ob.link().uploadContacts(),name:"uploader",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,disableDragAndDrop:!0,disableMultiple:!0,disableDocumentDropPrevent:!0,clickElement:this.importUploaderButton()});b&&b.on("onStart",h.bind(function(){this.contacts.importing(!0)},this)).on("onComplete",h.bind(function(b,c,d){this.contacts.importing(!1),this.reloadContactList(),b&&c&&d&&d.Result||a.alert(Bb.i18n("CONTACTS/ERROR_IMPORT_FILE"))},this))}},I.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,c=this.currentContact(),d=this.contacts().length,e=this.contactsCheckedOrSelected();0=d&&(this.bDropPageAfterDelete=!0),h.delay(function(){h.each(e,function(a){b.remove(a)})},500))},I.prototype.deleteSelectedContacts=function(){00?d:0),b.contactsCount(d),b.contacts(e),b.viewClearSearch(""!==b.search()),b.contacts.loading(!1)},c,yb.Defaults.ContactsPerPage,this.search())},I.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable,zb.KeyState.ContactList);var d=this;j("delete",zb.KeyState.ContactList,function(){return d.deleteCommand(),!1}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(Bb.pInt(a.value)),d.reloadContactList())}),this.initUploader()},I.prototype.onShow=function(){Hb.routeOff(),this.reloadContactList(!0)},I.prototype.onHide=function(){Hb.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},Bb.extendAsViewModel("PopupsAdvancedSearchViewModel",J),J.prototype.buildSearchStringValue=function(a){return-1 li"),e=c&&("tab"===c.shortcut||"right"===c.shortcut),f=d.index(d.filter(".active"));return!e&&f>0?f--:e&&f-1&&g.eq(e).removeClass("focused"),38===f&&e>0?e--:40===f&&e1?" ("+(100>a?a:"99+")+")":""},Z.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},Z.prototype.moveSelectedMessagesToFolder=function(a){return this.canBeMoved()&&Ob.moveMessagesToFolder(Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),a),!1},Z.prototype.dragAndDronHelper=function(a,b){a&&a.checked(!0);var c=Bb.draggeblePlace();return c.data("rl-folder",Ob.data().currentFolderFullNameRaw()),c.data("rl-uids",Ob.data().messageListCheckedOrSelectedUidsWithSubMails()),c.data("rl-copy",b?"1":"0"),c.find(".text").text((b?"+":"")+""+Ob.data().messageListCheckedOrSelectedUidsWithSubMails().length),c},Z.prototype.onMessageResponse=function(a,b,c){var d=Ob.data();d.hideMessageBodies(),d.messageLoading(!1),zb.StorageResultType.Success===a&&b&&b.Result?d.setMessage(b,c):zb.StorageResultType.Unload===a?(d.message(null),d.messageError("")):zb.StorageResultType.Abort!==a&&(d.message(null),d.messageError(Bb.getNotification(b&&b.ErrorCode?b.ErrorCode:zb.Notification.UnknownError)))},Z.prototype.populateMessageBody=function(a){a&&(Ob.remote().message(this.onMessageResponse,a.folderFullNameRaw,a.uid)?Ob.data().messageLoading(!0):Bb.log("Error: Unknown message request: "+a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))},Z.prototype.setAction=function(a,b,c){var d=[],e=null,f=Ob.cache(),g=0;if(Bb.isUnd(c)&&(c=Ob.data().messageListChecked()),d=h.map(c,function(a){return a.uid}),""!==a&&01048576?(a.alert(Bb.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(){this.customThemeUploaderProgress(!0)},this)).on("onComplete",h.bind(function(b,c,d){c&&d&&d.Result?this.customThemeImg(d.Result):a.alert(Bb.getUploadErrorDescByCode(d&&d.ErrorCode?d.ErrorCode:zb.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},Bb.addSettingsViewModel(lb,"SettingsOpenPGP","SETTINGS_LABELS/LABEL_OPEN_PGP_NAME","openpgp"),lb.prototype.addOpenPgpKey=function(){Hb.showScreenPopup(L)},lb.prototype.generateOpenPgpKey=function(){Hb.showScreenPopup(N)},lb.prototype.viewOpenPgpKey=function(a){a&&Hb.showScreenPopup(M,[a])},lb.prototype.deleteOpenPgpKey=function(a){a&&a.deleteAccess()&&(this.openPgpKeyForDeletion(null),a&&Ob.data().openpgpKeyring&&(this.openpgpkeys.remove(function(b){return a===b}),Ob.data().openpgpKeyring[a.isPrivate?"privateKeys":"publicKeys"].removeForId(a.guid),Ob.data().openpgpKeyring.store(),Ob.reloadOpenPgpKeys()))},mb.prototype.populateDataOnStart=function(){var a=Bb.pInt(Ob.settingsGet("Layout")),b=Ob.settingsGet("Languages"),c=Ob.settingsGet("Themes");Bb.isArray(b)&&this.languages(b),Bb.isArray(c)&&this.themes(c),this.mainLanguage(Ob.settingsGet("Language")),this.mainTheme(Ob.settingsGet("Theme")),this.allowCustomTheme(!!Ob.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!Ob.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!Ob.settingsGet("AllowIdentities")),this.allowGravatar(!!Ob.settingsGet("AllowGravatar")),this.determineUserLanguage(!!Ob.settingsGet("DetermineUserLanguage")),this.allowThemes(!!Ob.settingsGet("AllowThemes")),this.allowCustomLogin(!!Ob.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!Ob.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!Ob.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(Ob.settingsGet("EditorDefaultType")),this.showImages(!!Ob.settingsGet("ShowImages")),this.contactsAutosave(!!Ob.settingsGet("ContactsAutosave")),this.interfaceAnimation(Ob.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(Ob.settingsGet("MPP")),this.desktopNotifications(!!Ob.settingsGet("DesktopNotifications")),this.useThreads(!!Ob.settingsGet("UseThreads")),this.replySameFolder(!!Ob.settingsGet("ReplySameFolder")),this.useCheckboxesInList(!!Ob.settingsGet("UseCheckboxesInList")),this.layout(zb.Layout.SidePreview),-10&&(c=this.messagesBodiesDom(),c&&(c.find(".rl-cache-class").each(function(){var c=b(this);d>c.data("rl-cache-count")&&(c.addClass("rl-cache-purge"),a++)}),a>0&&h.delay(function(){c.find(".rl-cache-purge").remove() +},Z.prototype.printableMessageCountForDeletion=function(){var a=this.messageListCheckedOrSelectedUidsWithSubMails().length;return a>1?" ("+(100>a?a:"99+")+")":""},Z.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},Z.prototype.moveSelectedMessagesToFolder=function(a){return this.canBeMoved()&&Ob.moveMessagesToFolder(Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),a),!1},Z.prototype.dragAndDronHelper=function(a,b){a&&a.checked(!0);var c=Bb.draggeblePlace();return c.data("rl-folder",Ob.data().currentFolderFullNameRaw()),c.data("rl-uids",Ob.data().messageListCheckedOrSelectedUidsWithSubMails()),c.data("rl-copy",b?"1":"0"),c.find(".text").text((b?"+":"")+""+Ob.data().messageListCheckedOrSelectedUidsWithSubMails().length),c},Z.prototype.onMessageResponse=function(a,b,c){var d=Ob.data();d.hideMessageBodies(),d.messageLoading(!1),zb.StorageResultType.Success===a&&b&&b.Result?d.setMessage(b,c):zb.StorageResultType.Unload===a?(d.message(null),d.messageError("")):zb.StorageResultType.Abort!==a&&(d.message(null),d.messageError(Bb.getNotification(b&&b.ErrorCode?b.ErrorCode:zb.Notification.UnknownError)))},Z.prototype.populateMessageBody=function(a){a&&(Ob.remote().message(this.onMessageResponse,a.folderFullNameRaw,a.uid)?Ob.data().messageLoading(!0):Bb.log("Error: Unknown message request: "+a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))},Z.prototype.setAction=function(a,b,c){var d=[],e=null,f=Ob.cache(),g=0;if(Bb.isUnd(c)&&(c=Ob.data().messageListChecked()),d=h.map(c,function(a){return a.uid}),""!==a&&01048576?(a.alert(Bb.i18n("SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(){this.customThemeUploaderProgress(!0)},this)).on("onComplete",h.bind(function(b,c,d){c&&d&&d.Result?this.customThemeImg(d.Result):a.alert(Bb.getUploadErrorDescByCode(d&&d.ErrorCode?d.ErrorCode:zb.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},Bb.addSettingsViewModel(lb,"SettingsOpenPGP","SETTINGS_LABELS/LABEL_OPEN_PGP_NAME","openpgp"),lb.prototype.addOpenPgpKey=function(){Hb.showScreenPopup(L)},lb.prototype.generateOpenPgpKey=function(){Hb.showScreenPopup(N)},lb.prototype.viewOpenPgpKey=function(a){a&&Hb.showScreenPopup(M,[a])},lb.prototype.deleteOpenPgpKey=function(a){a&&a.deleteAccess()&&(this.openPgpKeyForDeletion(null),a&&Ob.data().openpgpKeyring&&(this.openpgpkeys.remove(function(b){return a===b}),Ob.data().openpgpKeyring[a.isPrivate?"privateKeys":"publicKeys"].removeForId(a.guid),Ob.data().openpgpKeyring.store(),Ob.reloadOpenPgpKeys()))},mb.prototype.populateDataOnStart=function(){var a=Bb.pInt(Ob.settingsGet("Layout")),b=Ob.settingsGet("Languages"),c=Ob.settingsGet("Themes");Bb.isArray(b)&&this.languages(b),Bb.isArray(c)&&this.themes(c),this.mainLanguage(Ob.settingsGet("Language")),this.mainTheme(Ob.settingsGet("Theme")),this.allowCustomTheme(!!Ob.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!Ob.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!Ob.settingsGet("AllowIdentities")),this.allowGravatar(!!Ob.settingsGet("AllowGravatar")),this.determineUserLanguage(!!Ob.settingsGet("DetermineUserLanguage")),this.allowThemes(!!Ob.settingsGet("AllowThemes")),this.allowCustomLogin(!!Ob.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!Ob.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!Ob.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(Ob.settingsGet("EditorDefaultType")),this.showImages(!!Ob.settingsGet("ShowImages")),this.contactsAutosave(!!Ob.settingsGet("ContactsAutosave")),this.interfaceAnimation(Ob.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(Ob.settingsGet("MPP")),this.desktopNotifications(!!Ob.settingsGet("DesktopNotifications")),this.useThreads(!!Ob.settingsGet("UseThreads")),this.replySameFolder(!!Ob.settingsGet("ReplySameFolder")),this.useCheckboxesInList(!!Ob.settingsGet("UseCheckboxesInList")),this.layout(zb.Layout.SidePreview),-10&&(c=this.messagesBodiesDom(),c&&(c.find(".rl-cache-class").each(function(){var c=b(this);d>c.data("rl-cache-count")&&(c.addClass("rl-cache-purge"),a++)}),a>0&&h.delay(function(){c.find(".rl-cache-purge").remove() },300)))},nb.prototype.populateDataOnStart=function(){mb.prototype.populateDataOnStart.call(this),this.accountEmail(Ob.settingsGet("Email")),this.accountIncLogin(Ob.settingsGet("IncLogin")),this.accountOutLogin(Ob.settingsGet("OutLogin")),this.projectHash(Ob.settingsGet("ProjectHash")),this.displayName(Ob.settingsGet("DisplayName")),this.replyTo(Ob.settingsGet("ReplyTo")),this.signature(Ob.settingsGet("Signature")),this.signatureToAll(!!Ob.settingsGet("SignatureToAll")),this.enableTwoFactor(!!Ob.settingsGet("EnableTwoFactor")),this.lastFoldersHash=Ob.local().get(zb.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Ob.settingsGet("RemoteSuggestions"),this.devEmail=Ob.settingsGet("DevEmail"),this.devLogin=Ob.settingsGet("DevLogin"),this.devPassword=Ob.settingsGet("DevPassword")},nb.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&Bb.isNormal(c)&&""!==c){if(Bb.isArray(d)&&03)i(Ob.link().notificationMailIcon(),Ob.data().accountEmail(),Bb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Ob.link().notificationMailIcon(),z.emailsToLine(z.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Ob.cache().setFolderUidNext(b,c)}},nb.prototype.folderResponseParseRec=function(a,b){var c=0,d=0,e=null,f=null,g="",h=[],i=[];for(c=0,d=b.length;d>c;c++)e=b[c],e&&(g=e.FullNameRaw,f=Ob.cache().getFolderFromCacheList(g),f||(f=A.newInstanceFromJson(e),f&&(Ob.cache().setFolderToCacheList(g,f),Ob.cache().setFolderFullNameRaw(f.fullNameHash,g))),f&&(f.collapsed(!Bb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Ob.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),Bb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),Bb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&Bb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},nb.prototype.setFolders=function(a){var b=[],c=!1,d=Ob.data(),e=function(a){return""===a||yb.Values.UnuseOptionValue===a||null!==Ob.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Bb.isArray(a.Result["@Collection"])&&(Bb.isUnd(a.Result.Namespace)||(d.namespace=a.Result.Namespace),this.threading(!!Ob.settingsGet("UseImapThread")&&a.Result.IsThreadsSupported&&!0),b=this.folderResponseParseRec(d.namespace,a.Result["@Collection"]),d.folderList(b),a.Result.SystemFolders&&""==""+Ob.settingsGet("SentFolder")+Ob.settingsGet("DraftFolder")+Ob.settingsGet("SpamFolder")+Ob.settingsGet("TrashFolder")+Ob.settingsGet("ArchiveFolder")+Ob.settingsGet("NullFolder")&&(Ob.settingsSet("SentFolder",a.Result.SystemFolders[2]||null),Ob.settingsSet("DraftFolder",a.Result.SystemFolders[3]||null),Ob.settingsSet("SpamFolder",a.Result.SystemFolders[4]||null),Ob.settingsSet("TrashFolder",a.Result.SystemFolders[5]||null),Ob.settingsSet("ArchiveFolder",a.Result.SystemFolders[12]||null),c=!0),d.sentFolder(e(Ob.settingsGet("SentFolder"))),d.draftFolder(e(Ob.settingsGet("DraftFolder"))),d.spamFolder(e(Ob.settingsGet("SpamFolder"))),d.trashFolder(e(Ob.settingsGet("TrashFolder"))),d.archiveFolder(e(Ob.settingsGet("ArchiveFolder"))),c&&Ob.remote().saveSystemFolders(Bb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),ArchiveFolder:d.archiveFolder(),NullFolder:"NullFolder"}),Ob.local().set(zb.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},nb.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},nb.prototype.getNextFolderNames=function(a){a=Bb.isUnd(a)?!1:!!a;var b=[],c=10,d=f().unix(),e=d-300,g=[],i=function(b){h.each(b,function(b){b&&"INBOX"!==b.fullNameRaw&&b.selectable&&b.existen&&e>b.interval&&(!a||b.subScribed())&&g.push([b.interval,b.fullNameRaw]),b&&0b[0]?1:0}),h.find(g,function(a){var e=Ob.cache().getFolderFromCacheList(a[1]);return e&&(e.interval=d,b.push(a[1])),c<=b.length}),h.uniq(b)},nb.prototype.removeMessagesFromList=function(a,b,c,d){c=Bb.isNormal(c)?c:"",d=Bb.isUnd(d)?!1:!!d,b=h.map(b,function(a){return Bb.pInt(a)});var e=0,f=Ob.data(),g=Ob.cache(),i=f.messageList(),j=Ob.cache().getFolderFromCacheList(a),k=""===c?null:g.getFolderFromCacheList(c||""),l=f.currentFolderFullNameRaw(),m=f.message(),n=l===a?h.filter(i,function(a){return a&&-10&&j.messageCountUnread(0<=j.messageCountUnread()-e?j.messageCountUnread()-e:0)),k&&(k.messageCountAll(k.messageCountAll()+b.length),e>0&&k.messageCountUnread(k.messageCountUnread()+e),k.actionBlink(!0)),0').hide().addClass("rl-cache-class"),g.data("rl-cache-count",++Eb.iMessageBodyCacheCount),Bb.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,g.html(a.Result.Html.toString()).addClass("b-text-part html")):Bb.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,j=a.Result.Plain.toString(),(n.isPgpSigned()||n.isPgpEncrypted())&&Ob.data().allowOpenPGP()&&Bb.isNormal(a.Result.PlainRaw)&&(n.plainRaw=Bb.pString(a.Result.PlainRaw),l=/---BEGIN PGP MESSAGE---/.test(n.plainRaw),l||(k=/-----BEGIN PGP SIGNED MESSAGE-----/.test(n.plainRaw)&&/-----BEGIN PGP SIGNATURE-----/.test(n.plainRaw)),Pb.empty(),k&&n.isPgpSigned()?j=Pb.append(b('
').text(n.plainRaw)).html():l&&n.isPgpEncrypted()&&(j=Pb.append(b('
').text(n.plainRaw)).html()),Pb.empty(),n.isPgpSigned(k),n.isPgpEncrypted(l)),g.html(j).addClass("b-text-part plain")):d=!1,n.isHtml(!!d),n.hasImages(!!e),n.pgpSignedVerifyStatus(zb.SignedVerifyStatus.None),n.pgpSignedVerifyUser(""),a.Result.Rtl&&(n.isRtl(!0),g.addClass("rtl-text-part")),n.body=g,n.body&&m.append(n.body),n.storeDataToDom(),f&&n.showInternalImages(!0),n.hasImages()&&this.showImages()&&n.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()),this.messageActiveDom(n.body),this.hideMessageBodies(),n.body.show(),g&&Bb.initBlockquoteSwitcher(g)),Ob.cache().initMessageFlagsFromCache(n),n.unseen()&&Ob.setMessageSeen(n),Bb.windowResize())},nb.prototype.calculateMessageListHash=function(a){return h.map(a,function(a){return""+a.hash+"_"+a.threadsLen()+"_"+a.flagHash()}).join("|")},nb.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Bb.isArray(a.Result["@Collection"])){var c=Ob.data(),d=Ob.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=f().unix(),m=c.staticMessageList,n=null,o=null,p=null,q=0,r=!1;for(i=Bb.pInt(a.Result.MessageResultCount),j=Bb.pInt(a.Result.Offset),Bb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),p=Ob.cache().getFolderFromCacheList(Bb.isNormal(a.Result.Folder)?a.Result.Folder:""),p&&!b&&(p.interval=l,Ob.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),Bb.isNormal(a.Result.MessageCount)&&p.messageCountAll(a.Result.MessageCount),Bb.isNormal(a.Result.MessageUnseenCount)&&(Bb.pInt(p.messageCountUnread())!==Bb.pInt(a.Result.MessageUnseenCount)&&(r=!0),p.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(p.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),r&&p&&Ob.cache().clearMessageFlagsFromCacheByFolder(p.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)n=a.Result["@Collection"][g],n&&"Object/Message"===n["@Object"]&&(o=m[g],o&&o.initByJson(n)||(o=z.newInstanceFromJson(n)),o&&(d.hasNewMessageAndRemoveFromCache(o.folderFullNameRaw,o.uid)&&5>=q&&(q++,o.newForAnimation(!0)),o.deleted(!1),b?Ob.cache().initMessageFlagsFromCache(o):Ob.cache().storeMessageFlagsToCache(o),o.lastInCollapsedThread(e&&-1(new a.Date).getTime()-l),n&&i.oRequests[n]&&(i.oRequests[n].__aborted&&(e="abort"),i.oRequests[n]=null),i.defaultResponse(c,n,e,b,f,d)}),n&&00?(this.defaultRequest(a,"Message",{},null,"Message/"+Db.urlsafe_encode([b,c,Ob.data().projectHash(),Ob.data().threading()&&Ob.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},pb.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},pb.prototype.folderInformation=function(a,b,c){var d=!0,e=Ob.cache(),f=[];Bb.isArray(c)&&0
").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+f.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(g),e.data=Ob.data(),e.viewModelDom=i,e.__rlSettingsData=f.__rlSettingsData,f.__dom=i,f.__builded=!0,f.__vm=e,c.applyBindings(e,i[0]),Bb.delegateRun(e,"onBuild",[i])):Bb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(Bb.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Bb.delegateRun(d.oCurrentSubScreen,"onShow"),Bb.delegateRun(d.oCurrentSubScreen,"onFocus",[],200),h.each(d.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)}),b("#rl-content .b-settings .b-content .content").scrollTop(0)),Bb.windowResize()})):Hb.setHash(Ob.link().settings(),!1,!0)},sb.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Bb.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},sb.prototype.onBuild=function(){h.each(Fb.settings,function(a){a&&a.__rlSettingsData&&!h.find(Fb["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!h.find(Fb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},sb.prototype.routes=function(){var a=h.find(Fb.settings,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",c={subname:/^(.*)$/,normalize_:function(a,c){return c.subname=Bb.isUnd(c.subname)?b:Bb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(tb.prototype,s.prototype),tb.prototype.onShow=function(){Ob.setTitle("")},h.extend(ub.prototype,s.prototype),ub.prototype.oLastRoute={},ub.prototype.setNewTitle=function(){var a=Ob.data().accountEmail(),b=Ob.data().foldersInboxUnreadCount();Ob.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+Bb.i18n("TITLES/MAILBOX"))},ub.prototype.onShow=function(){this.setNewTitle(),Ob.data().keyScope(zb.KeyState.MessageList)},ub.prototype.onRoute=function(a,b,c,d){if(Bb.isUnd(d)?1:!d){var e=Ob.data(),f=Ob.cache().getFolderFullNameRaw(a),g=Ob.cache().getFolderFromCacheList(f);g&&(e.currentFolder(g).messageListPage(b).messageListSearch(c),zb.Layout.NoPreview===e.layout()&&e.message()&&(e.message(null),e.messageFullScreenMode(!1)),Ob.reloadMessageList())}else zb.Layout.NoPreview!==Ob.data().layout()||Ob.data().message()||Ob.historyBack()},ub.prototype.onStart=function(){var a=Ob.data(),b=function(){Bb.windowResize()};(Ob.settingsGet("AllowAdditionalAccounts")||Ob.settingsGet("AllowIdentities"))&&Ob.accountsAndIdentities(),h.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&Ob.folderInformation("INBOX")},1e3),h.delay(function(){Ob.quota()},5e3),h.delay(function(){Ob.remote().appDelayStart(Bb.emptyFunction)},35e3),Kb.toggleClass("rl-no-preview-pane",zb.Layout.NoPreview===a.layout()),a.folderList.subscribe(b),a.messageList.subscribe(b),a.message.subscribe(b),a.layout.subscribe(function(a){Kb.toggleClass("rl-no-preview-pane",zb.Layout.NoPreview===a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},ub.prototype.routes=function(){var a=function(){return["Inbox",1,"",!0]},b=function(a,b){return b[0]=Bb.pString(b[0]),b[1]=Bb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=Bb.pString(b[2]),""===a&&(b[0]="Inbox",b[1]=1),[decodeURI(b[0]),b[1],decodeURI(b[2]),!1]},c=function(a,b){return b[0]=Bb.pString(b[0]),b[1]=Bb.pString(b[1]),""===a&&(b[0]="Inbox"),[decodeURI(b[0]),1,decodeURI(b[1]),!1]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:b}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)$/,{normalize_:b}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:c}],[/^message-preview$/,{normalize_:a}],[/^([^\/]*)$/,{normalize_:b}]]},h.extend(vb.prototype,sb.prototype),vb.prototype.onShow=function(){Ob.setTitle(this.sSettingsTitle),Ob.data().keyScope(zb.KeyState.Settings)},h.extend(wb.prototype,q.prototype),wb.prototype.oSettings=null,wb.prototype.oPlugins=null,wb.prototype.oLocal=null,wb.prototype.oLink=null,wb.prototype.oSubs={},wb.prototype.download=function(b){var c=null,d=null,e=navigator.userAgent.toLowerCase();return e&&(e.indexOf("chrome")>-1||e.indexOf("chrome")>-1)&&(c=document.createElement("a"),c.href=b,document.createEvent&&(d=document.createEvent("MouseEvents"),d&&d.initEvent&&c.dispatchEvent))?(d.initEvent("click",!0,!0),c.dispatchEvent(d),!0):(Eb.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},wb.prototype.link=function(){return null===this.oLink&&(this.oLink=new k),this.oLink},wb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new p),this.oLocal},wb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=Bb.isNormal(Ib)?Ib:{}),Bb.isUnd(this.oSettings[a])?null:this.oSettings[a]},wb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=Bb.isNormal(Ib)?Ib:{}),this.oSettings[a]=b},wb.prototype.setTitle=function(b){b=(Bb.isNormal(b)&&0l;l++)q.push({id:e[l][0],name:e[l][1],system:!1,seporator:!1,disabled:!1});for(o=!0,l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&(o&&0l;l++)n=c[l],(n.subScribed()||!n.existen)&&(h?h.call(null,n):!0)&&(zb.FolderType.User===n.type()||!j||0