snappymail/rainloop/v/0.0.0/static/js/app.min.js
2014-04-09 20:01:41 +04:00

10 lines
No EOL
254 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! RainLoop Webmail Main Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
!function(a,b,c,d,e,f,g,h,i,j){"use strict";function k(){this.sBase="#/",this.sCdnStaticDomain=Ob.settingsGet("CdnStaticDomain"),this.sVersion=Ob.settingsGet("Version"),this.sSpecSuffix=Ob.settingsGet("AuthAccountHash")||"0",this.sServer=(Ob.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function l(a,c,d,e){var f=this;f.editor=null,f.iBlurTimer=0,f.fOnBlur=c||null,f.fOnReady=d||null,f.fOnModeChange=e||null,f.$element=b(a),f.init()}function m(a,b,d,e,f,g){this.list=a,this.listChecked=c.computed(function(){return h.filter(this.list(),function(a){return a.checked()})},this),this.isListChecked=c.computed(function(){return 0<this.listChecked().length},this),this.lastSelectedItem=c.observable(null),this.focusedItem=c.observable(null),this.selectedItem=b,this.listChecked.subscribe(function(a){0<a.length?this.selectedItem(null):this.bAutoSelect&&this.lastSelectedItem()&&this.selectedItem(this.lastSelectedItem())},this),this.selectedItem.subscribe(function(a){a&&(this.bAutoSelect&&this.lastSelectedItem(a),this.isListChecked()&&h.each(this.listChecked(),function(a){a.checked(!1)}))},this),this.selectedItem.extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]}),this.focusedItem.extend({toggleSubscribe:[null,function(a){a&&a.focused(!1)},function(a){a&&a.focused(!0)}]}),this.oContentVisible=null,this.oContentScrollable=null,this.sItemSelector=d,this.sItemSelectedSelector=e,this.sItemCheckedSelector=f,this.sItemFocusedSelector=g,this.sLastUid="",this.oCallbacks={},this.iSelectTimer=0,this.bUseKeyboard=!0,this.bAutoSelect=!0,this.emptyFunction=function(){},this.useItemSelectCallback=!0,this.selectedItem.subscribe(function(a){a&&(this.sLastUid=this.getItemUid(a),this.focusedItem(a)),this.useItemSelectCallback&&(a?this.selectItemCallbacks(a):this.selectItemCallbacks(null))},this),this.focusedItem.subscribe(function(a){a&&(this.sLastUid=this.getItemUid(a))},this);var i=[],j=null,k=null;this.list.subscribe(function(){var a=this,b=this.list();Cb.isArray(b)&&h.each(b,function(b){b.checked()&&i.push(a.getItemUid(b)),null===j&&b.focused()&&(j=a.getItemUid(b)),null===k&&b.selected()&&(k=a.getItemUid(b))})},this,"beforeChange"),this.list.subscribe(function(a){this.useItemSelectCallback=!1;var b=this,c=!1,d=0;this.focusedItem(null),this.selectedItem(null),Cb.isArray(a)&&(d=i.length,h.each(a,function(a){var e=b.getItemUid(a);d>0&&-1<Cb.inArray(e,i)&&(c=!0,a.checked(!0),d--),null!==j&&j===e&&(b.focusedItem(a),j=null),c||null===k||k!==e||(b.selectedItem(a),k=null)})),this.useItemSelectCallback=!0,i=[],j=null,k=null},this),this.selectItemCallbacksThrottle=h.debounce(this.selectItemCallbacks,300)}function n(){}function o(){}function p(){}function q(){var a=[o,n],b=h.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function r(){}function s(a,b){this.bDisabeCloseOnEsc=!1,this.sPosition=Cb.pString(a),this.sTemplate=Cb.pString(b),this.sDefaultKeyScope=Ab.KeyState.None,this.sCurrentKeyScope=this.sDefaultKeyScope,this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function t(a,b){this.sScreenName=a,this.aViewModels=Cb.isArray(b)?b:[]}function u(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null}function v(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function w(){this.idContact=0,this.idContactStr="",this.display="",this.properties=[],this.readOnly=!1,this.scopeType=Ab.ContactScopeType.Default,this.focused=c.observable(!1),this.selected=c.observable(!1),this.checked=c.observable(!1),this.deleted=c.observable(!1),this.shared=c.observable(!1)}function x(a,b,d,e){this.type=c.observable(Cb.isUnd(a)?Ab.ContactPropertyType.Unknown:a),this.focused=c.observable(Cb.isUnd(d)?!1:!!d),this.value=c.observable(Cb.pString(b)),this.placeholder=c.observable(e||""),this.placeholderValue=c.computed(function(){var a=this.placeholder();return a?Cb.i18n(a):""},this)}function y(){this.mimeType="",this.fileName="",this.estimatedSize=0,this.friendlySize="",this.isInline=!1,this.isLinked=!1,this.cid="",this.cidWithOutTags="",this.contentLocation="",this.download="",this.folder="",this.uid="",this.mimeIndex=""}function z(a,b,d,e,f,g,h){this.id=a,this.isInline=Cb.isUnd(e)?!1:!!e,this.isLinked=Cb.isUnd(f)?!1:!!f,this.CID=Cb.isUnd(g)?"":g,this.contentLocation=Cb.isUnd(h)?"":h,this.fromMessage=!1,this.fileName=c.observable(b),this.size=c.observable(Cb.isUnd(d)?null:d),this.tempName=c.observable(""),this.progress=c.observable(""),this.error=c.observable(""),this.waiting=c.observable(!0),this.uploading=c.observable(!1),this.enabled=c.observable(!0),this.friendlySize=c.computed(function(){var a=this.size();return null===a?"":Cb.friendlySize(this.size())},this)}function A(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject=c.observable(""),this.size=c.observable(0),this.dateTimeStampInUTC=c.observable(0),this.priority=c.observable(Ab.MessagePriority.Normal),this.fromEmailString=c.observable(""),this.toEmailsString=c.observable(""),this.senderEmailsString=c.observable(""),this.emails=[],this.from=[],this.to=[],this.cc=[],this.bcc=[],this.replyTo=[],this.newForAnimation=c.observable(!1),this.deleted=c.observable(!1),this.unseen=c.observable(!1),this.flagged=c.observable(!1),this.answered=c.observable(!1),this.forwarded=c.observable(!1),this.isReadReceipt=c.observable(!1),this.focused=c.observable(!1),this.selected=c.observable(!1),this.checked=c.observable(!1),this.hasAttachments=c.observable(!1),this.attachmentsMainType=c.observable(""),this.moment=c.observable(f()),this.attachmentIconClass=c.computed(function(){var a="";if(this.hasAttachments())switch(a="icon-attachment",this.attachmentsMainType()){case"image":a="icon-image";break;case"archive":a="icon-file-zip";break;case"doc":a="icon-file-text"}return a},this),this.fullFormatDateValue=c.computed(function(){return A.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this),this.fullFormatDateValue=c.computed(function(){return A.calculateFullFromatDateValue(this.dateTimeStampInUTC())},this),this.momentDate=Cb.createMomentDate(this),this.momentShortDate=Cb.createMomentShortDate(this),this.dateTimeStampInUTC.subscribe(function(a){var b=f().unix();this.moment(f.unix(a>b?b:a))},this),this.body=null,this.plainRaw="",this.isRtl=c.observable(!1),this.isHtml=c.observable(!1),this.hasImages=c.observable(!1),this.attachments=c.observableArray([]),this.isPgpSigned=c.observable(!1),this.isPgpEncrypted=c.observable(!1),this.pgpSignedVerifyStatus=c.observable(Ab.SignedVerifyStatus.None),this.pgpSignedVerifyUser=c.observable(""),this.priority=c.observable(Ab.MessagePriority.Normal),this.readReceipt=c.observable(""),this.aDraftInfo=[],this.sMessageId="",this.sInReplyTo="",this.sReferences="",this.parentUid=c.observable(0),this.threads=c.observableArray([]),this.threadsLen=c.observable(0),this.hasUnseenSubMessage=c.observable(!1),this.hasFlaggedSubMessage=c.observable(!1),this.lastInCollapsedThread=c.observable(!1),this.lastInCollapsedThreadLoading=c.observable(!1),this.threadsLenResult=c.computed(function(){var a=this.threadsLen();return 0===this.parentUid()&&a>0?a+1:""},this)}function B(){this.name=c.observable(""),this.fullName="",this.fullNameRaw="",this.fullNameHash="",this.delimiter="",this.namespace="",this.deep=0,this.selectable=!1,this.existen=!0,this.isNamespaceFolder=!1,this.isGmailFolder=!1,this.isUnpaddigFolder=!1,this.interval=0,this.type=c.observable(Ab.FolderType.User),this.focused=c.observable(!1),this.selected=c.observable(!1),this.edited=c.observable(!1),this.collapsed=c.observable(!0),this.subScribed=c.observable(!0),this.subFolders=c.observableArray([]),this.deleteAccess=c.observable(!1),this.actionBlink=c.observable(!1).extend({falseTimeout:1e3}),this.nameForEdit=c.observable(""),this.name.subscribe(function(a){this.nameForEdit(a)},this),this.edited.subscribe(function(a){a&&this.nameForEdit(this.name())},this),this.privateMessageCountAll=c.observable(0),this.privateMessageCountUnread=c.observable(0),this.collapsedPrivate=c.observable(!0)}function C(a,b){this.email=a,this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(b)}function D(a,b,d){this.id=a,this.email=c.observable(b),this.name=c.observable(""),this.replyTo=c.observable(""),this.bcc=c.observable(""),this.deleteAccess=c.observable(!1),this.canBeDalete=c.observable(d)}function E(a,b,d,e,f,g,h){this.index=a,this.id=d,this.guid=b,this.user=e,this.email=f,this.armor=h,this.isPrivate=!!g,this.deleteAccess=c.observable(!1)}function F(){s.call(this,"Popups","PopupsFolderClear"),this.selectedFolder=c.observable(null),this.clearingProcess=c.observable(!1),this.clearingError=c.observable(""),this.folderFullNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.printableFullName():""},this),this.folderNameForClear=c.computed(function(){var a=this.selectedFolder();return a?a.localName():""},this),this.dangerDescHtml=c.computed(function(){return Cb.i18n("POPUPS_CLEAR_FOLDER/DANGER_DESC_HTML_1",{FOLDER:this.folderNameForClear()})},this),this.clearCommand=Cb.createCommand(this,function(){var a=this,b=this.selectedFolder();b&&(Ob.data().message(null),Ob.data().messageList([]),this.clearingProcess(!0),Ob.cache().setFolderHash(b.fullNameRaw,""),Ob.remote().folderClear(function(b,c){a.clearingProcess(!1),Ab.StorageResultType.Success===b&&c&&c.Result?(Ob.reloadMessageList(!0),a.cancelCommand()):c&&c.ErrorCode?a.clearingError(Cb.getNotification(c.ErrorCode)):a.clearingError(Cb.getNotification(Ab.Notification.MailServerError))},b.fullNameRaw))},function(){var a=this.selectedFolder(),b=this.clearingProcess();return!b&&null!==a}),u.constructorEnd(this)}function G(){s.call(this,"Popups","PopupsFolderCreate"),Cb.initOnStartOrLangChange(function(){this.sNoParentText=Cb.i18n("POPUPS_CREATE_FOLDER/SELECT_NO_PARENT")},this),this.folderName=c.observable(""),this.folderName.focused=c.observable(!1),this.selectedParentValue=c.observable(zb.Values.UnuseOptionValue),this.parentFolderSelectList=c.computed(function(){var a=Ob.data(),b=[],c=null,d=null,e=a.folderList(),f=function(a){return a?a.isSystemFolder()?a.name()+" "+a.manageFolderSystemName():a.name():""};return b.push(["",this.sNoParentText]),""!==a.namespace&&(c=function(b){return a.namespace!==b.fullNameRaw.substr(0,a.namespace.length)}),Ob.folderListOptionsBuilder([],e,[],b,null,c,d,f)},this),this.createFolder=Cb.createCommand(this,function(){var a=Ob.data(),b=this.selectedParentValue();""===b&&1<a.namespace.length&&(b=a.namespace.substr(0,a.namespace.length-1)),a.foldersCreating(!0),Ob.remote().folderCreate(function(a,b){Ob.data().foldersCreating(!1),Ab.StorageResultType.Success===a&&b&&b.Result?Ob.folders():Ob.data().foldersListError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"))},this.folderName(),b),this.cancelCommand()},function(){return this.simpleFolderNameValidation(this.folderName())}),this.defautOptionsAfterRender=Cb.defautOptionsAfterRender,u.constructorEnd(this)}function H(){s.call(this,"Popups","PopupsFolderSystem"),Cb.initOnStartOrLangChange(function(){this.sChooseOnText=Cb.i18n("POPUPS_SYSTEM_FOLDERS/SELECT_CHOOSE_ONE"),this.sUnuseText=Cb.i18n("POPUPS_SYSTEM_FOLDERS/SELECT_UNUSE_NAME")},this),this.notification=c.observable(""),this.folderSelectList=c.computed(function(){return Ob.folderListOptionsBuilder([],Ob.data().folderList(),Ob.data().folderListSystemNames(),[["",this.sChooseOnText],[zb.Values.UnuseOptionValue,this.sUnuseText]])},this);var a=Ob.data(),b=this,d=null,e=null;this.sentFolder=a.sentFolder,this.draftFolder=a.draftFolder,this.spamFolder=a.spamFolder,this.trashFolder=a.trashFolder,this.archiveFolder=a.archiveFolder,d=h.debounce(function(){Ob.settingsSet("SentFolder",b.sentFolder()),Ob.settingsSet("DraftFolder",b.draftFolder()),Ob.settingsSet("SpamFolder",b.spamFolder()),Ob.settingsSet("TrashFolder",b.trashFolder()),Ob.settingsSet("ArchiveFolder",b.archiveFolder()),Ob.remote().saveSystemFolders(Cb.emptyFunction,{SentFolder:b.sentFolder(),DraftFolder:b.draftFolder(),SpamFolder:b.spamFolder(),TrashFolder:b.trashFolder(),ArchiveFolder:b.archiveFolder(),NullFolder:"NullFolder"})},1e3),e=function(){Ob.settingsSet("SentFolder",b.sentFolder()),Ob.settingsSet("DraftFolder",b.draftFolder()),Ob.settingsSet("SpamFolder",b.spamFolder()),Ob.settingsSet("TrashFolder",b.trashFolder()),Ob.settingsSet("ArchiveFolder",b.archiveFolder()),d()},this.sentFolder.subscribe(e),this.draftFolder.subscribe(e),this.spamFolder.subscribe(e),this.trashFolder.subscribe(e),this.archiveFolder.subscribe(e),this.defautOptionsAfterRender=Cb.defautOptionsAfterRender,u.constructorEnd(this)}function I(){s.call(this,"Popups","PopupsCompose"),this.oEditor=null,this.aDraftInfo=null,this.sInReplyTo="",this.bFromDraft=!1,this.sReferences="",this.bAllowIdentities=Ob.settingsGet("AllowIdentities");var b=this,d=Ob.data(),e=function(a){!1===b.showCcAndBcc()&&0<a.length&&b.showCcAndBcc(!0)};this.allowOpenPGP=d.allowOpenPGP,this.resizer=c.observable(!1).extend({throttle:50}),this.to=c.observable(""),this.to.focusTrigger=c.observable(!1),this.cc=c.observable(""),this.bcc=c.observable(""),this.replyTo=c.observable(""),this.subject=c.observable(""),this.isHtml=c.observable(!1),this.requestReadReceipt=c.observable(!1),this.sendError=c.observable(!1),this.sendSuccessButSaveError=c.observable(!1),this.savedError=c.observable(!1),this.savedTime=c.observable(0),this.savedOrSendingText=c.observable(""),this.emptyToError=c.observable(!1),this.showCcAndBcc=c.observable(!1),this.cc.subscribe(e,this),this.bcc.subscribe(e,this),this.draftFolder=c.observable(""),this.draftUid=c.observable(""),this.sending=c.observable(!1),this.saving=c.observable(!1),this.attachments=c.observableArray([]),this.attachmentsInProcess=this.attachments.filter(function(a){return a&&""===a.tempName()}),this.attachmentsInReady=this.attachments.filter(function(a){return a&&""!==a.tempName()}),this.attachments.subscribe(function(){this.triggerForResize()},this),this.isDraftFolderMessage=c.computed(function(){return""!==this.draftFolder()&&""!==this.draftUid()},this),this.composeUploaderButton=c.observable(null),this.composeUploaderDropPlace=c.observable(null),this.dragAndDropEnabled=c.observable(!1),this.dragAndDropOver=c.observable(!1).extend({throttle:1}),this.dragAndDropVisible=c.observable(!1).extend({throttle:1}),this.attacheMultipleAllowed=c.observable(!1),this.addAttachmentEnabled=c.observable(!1),this.composeEditorArea=c.observable(null),this.identities=Ob.data().identities,this.currentIdentityID=c.observable(""),this.currentIdentityString=c.observable(""),this.currentIdentityResultEmail=c.observable(""),this.identitiesOptions=c.computed(function(){var a=[{optValue:d.accountEmail(),optText:this.formattedFrom(!1)}];return h.each(d.identities(),function(b){a.push({optValue:b.id,optText:b.formattedNameForCompose()})}),a},this),c.computed(function(){var a="",b="",c=null,d=this.identities(),e=this.currentIdentityID();return this.bAllowIdentities&&e&&e!==Ob.data().accountEmail()&&(c=h.find(d,function(a){return a&&e===a.id}),a=c?c.formattedNameForCompose():"",b=c?c.formattedNameForEmail():"",""===a&&d[0])?(this.currentIdentityID(d[0].id),""):(""===a&&(a=this.formattedFrom(!1),b=this.formattedFrom(!0)),this.currentIdentityString(a),this.currentIdentityResultEmail(b),a)},this),this.to.subscribe(function(a){this.emptyToError()&&0<a.length&&this.emptyToError(!1)},this),this.editorResizeThrottle=h.throttle(h.bind(this.editorResize,this),100),this.resizer.subscribe(function(){this.editorResizeThrottle()},this),this.canBeSended=c.computed(function(){return!this.sending()&&!this.saving()&&0===this.attachmentsInProcess().length&&0<this.to().length},this),this.canBeSendedOrSaved=c.computed(function(){return!this.sending()&&!this.saving()},this),this.deleteCommand=Cb.createCommand(this,function(){Ob.deleteMessagesFromFolderWithoutCheck(this.draftFolder(),[this.draftUid()]),Hb.hideScreenPopup(I)},function(){return this.isDraftFolderMessage()}),this.sendMessageResponse=h.bind(this.sendMessageResponse,this),this.saveMessageResponse=h.bind(this.saveMessageResponse,this),this.sendCommand=Cb.createCommand(this,function(){var a=Cb.trim(this.to()),b=Ob.data().sentFolder(),c=[];0===a.length?this.emptyToError(!0):(Ob.data().replySameFolder()&&Cb.isArray(this.aDraftInfo)&&3===this.aDraftInfo.length&&Cb.isNormal(this.aDraftInfo[2])&&0<this.aDraftInfo[2].length&&(b=this.aDraftInfo[2]),""===b?Hb.showScreenPopup(H,[Ab.SetSystemFoldersNotification.Sent]):(this.sendError(!1),this.sending(!0),Cb.isArray(this.aDraftInfo)&&3===this.aDraftInfo.length&&(c=Ob.cache().getMessageFlagsFromCache(this.aDraftInfo[2],this.aDraftInfo[1]),c&&("forward"===this.aDraftInfo[0]?c[3]=!0:c[2]=!0,Ob.cache().setMessageFlagsToCache(this.aDraftInfo[2],this.aDraftInfo[1],c),Ob.reloadFlagsCurrentMessageListAndMessageFromCache(),Ob.cache().setFolderHash(this.aDraftInfo[2],""))),b=zb.Values.UnuseOptionValue===b?"":b,Ob.cache().setFolderHash(this.draftFolder(),""),Ob.cache().setFolderHash(b,""),Ob.remote().sendMessage(this.sendMessageResponse,this.draftFolder(),this.draftUid(),b,this.currentIdentityResultEmail(),a,this.cc(),this.bcc(),this.subject(),this.oEditor?this.oEditor.isHtml():!1,this.oEditor?this.oEditor.getData():"",this.prepearAttachmentsForSendOrSave(),this.aDraftInfo,this.sInReplyTo,this.sReferences,this.requestReadReceipt())))},this.canBeSendedOrSaved),this.saveCommand=Cb.createCommand(this,function(){Ob.data().draftFolderNotEnabled()?Hb.showScreenPopup(H,[Ab.SetSystemFoldersNotification.Draft]):(this.savedError(!1),this.saving(!0),Ob.cache().setFolderHash(Ob.data().draftFolder(),""),Ob.remote().saveMessage(this.saveMessageResponse,this.draftFolder(),this.draftUid(),Ob.data().draftFolder(),this.currentIdentityResultEmail(),this.to(),this.cc(),this.bcc(),this.subject(),this.oEditor?this.oEditor.isHtml():!1,this.oEditor?this.oEditor.getData():"",this.prepearAttachmentsForSendOrSave(),this.aDraftInfo,this.sInReplyTo,this.sReferences))},this.canBeSendedOrSaved),Ob.sub("interval.1m",function(){!this.modalVisibility()||Ob.data().draftFolderNotEnabled()||this.isEmptyForm(!1)||this.saving()||this.sending()||this.savedError()||this.saveCommand()},this),this.showCcAndBcc.subscribe(function(){this.triggerForResize()},this),this.dropboxEnabled=c.observable(Ob.settingsGet("DropboxApiKey")?!0:!1),this.dropboxCommand=Cb.createCommand(this,function(){return a.Dropbox&&a.Dropbox.choose({success:function(a){a&&a[0]&&a[0].link&&b.addDropboxAttachment(a[0])},linkType:"direct",multiselect:!1}),!0},function(){return this.dropboxEnabled()}),this.driveEnabled=c.observable(!1),this.driveCommand=Cb.createCommand(this,function(){return!0},function(){return this.driveEnabled()}),this.bDisabeCloseOnEsc=!0,this.sDefaultKeyScope=Ab.KeyState.Compose,u.constructorEnd(this)}function J(){s.call(this,"Popups","PopupsContacts");var a=this,b=Ab.ContactPropertyType,d=[b.FirstName,b.LastName],e=[b.EmailPersonal,b.EmailBussines,b.EmailOther],f=[b.PhonePersonal,b.PhoneBussines,b.PhoneOther,b.MobilePersonal,b.MobileBussines,b.MobileOther,b.FaxPesonal,b.FaxBussines,b.FaxOther],g=[b.Facebook,b.Skype,b.GitHub],i=function(b){b&&0<b.length&&a.viewProperties.removeAll(b)};this.search=c.observable(""),this.contactsCount=c.observable(0),this.contacts=c.observableArray([]),this.contacts.loading=c.observable(!1).extend({throttle:200}),this.contacts.importing=c.observable(!1).extend({throttle:200}),this.currentContact=c.observable(null),this.importUploaderButton=c.observable(null),this.contactsSharingIsAllowed=!!Ob.settingsGet("ContactsSharingIsAllowed"),this.contactsPage=c.observable(1),this.contactsPageCount=c.computed(function(){var a=Math.ceil(this.contactsCount()/zb.Defaults.ContactsPerPage);return 0>=a?1:a},this),this.contactsPagenator=c.computed(Cb.computedPagenatorHelper(this.contactsPage,this.contactsPageCount)),this.emptySelection=c.observable(!0),this.viewClearSearch=c.observable(!1),this.viewID=c.observable(""),this.viewIDStr=c.observable(""),this.viewReadOnly=c.observable(!1),this.viewScopeType=c.observable(Ab.ContactScopeType.Default),this.viewProperties=c.observableArray([]),this.viewSaveTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.viewPropertiesNames=this.viewProperties.filter(function(a){return-1<Cb.inArray(a.type(),d)}),this.viewPropertiesEmails=this.viewProperties.filter(function(a){return-1<Cb.inArray(a.type(),e)}),this.shareIcon=c.computed(function(){return Ab.ContactScopeType.ShareAll===this.viewScopeType()?"icon-earth":"icon-share"},this),this.shareToNone=c.computed(function(){return Ab.ContactScopeType.ShareAll!==this.viewScopeType()},this),this.shareToAll=c.computed(function(){return Ab.ContactScopeType.ShareAll===this.viewScopeType()},this),this.viewHasNonEmptyRequaredProperties=c.computed(function(){var a=this.viewPropertiesNames(),b=this.viewPropertiesEmails(),c=function(a){return""!==Cb.trim(a.value())};return!(!h.find(a,c)&&!h.find(b,c))},this),this.viewPropertiesPhones=this.viewProperties.filter(function(a){return-1<Cb.inArray(a.type(),f)}),this.viewPropertiesOther=this.viewProperties.filter(function(a){return-1<Cb.inArray(a.type(),g)}),this.viewPropertiesEmailsNonEmpty=this.viewPropertiesNames.filter(function(a){return""!==Cb.trim(a.value())}),this.viewPropertiesEmailsEmptyAndOnFocused=this.viewPropertiesEmails.filter(function(a){var b=a.focused();return""===Cb.trim(a.value())&&!b}),this.viewPropertiesPhonesEmptyAndOnFocused=this.viewPropertiesPhones.filter(function(a){var b=a.focused();return""===Cb.trim(a.value())&&!b}),this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(function(a){i(a)}),this.viewPropertiesPhonesEmptyAndOnFocused.subscribe(function(a){i(a)}),this.viewSaving=c.observable(!1),this.useCheckboxesInList=Ob.data().useCheckboxesInList,this.search.subscribe(function(){this.reloadContactList()},this),this.contacts.subscribe(function(){Cb.windowResize()},this),this.viewProperties.subscribe(function(){Cb.windowResize()},this),this.contactsChecked=c.computed(function(){return h.filter(this.contacts(),function(a){return a.checked()})},this),this.contactsCheckedOrSelected=c.computed(function(){var a=this.contactsChecked(),b=this.currentContact();return h.union(a,b?[b]:[])},this),this.contactsCheckedOrSelectedUids=c.computed(function(){return h.map(this.contactsCheckedOrSelected(),function(a){return a.idContact})},this),this.selector=new m(this.contacts,this.currentContact,".e-contact-item .actionHandle",".e-contact-item.selected",".e-contact-item .checkboxItem",".e-contact-item.focused"),this.selector.on("onItemSelect",h.bind(function(a){this.populateViewContact(a?a:null)},this)),this.selector.on("onItemGetUid",function(a){return a?a.generateUid():""}),this.newCommand=Cb.createCommand(this,function(){this.populateViewContact(null),this.currentContact(null)}),this.deleteCommand=Cb.createCommand(this,function(){this.deleteSelectedContacts(),this.emptySelection(!0)},function(){return 0<this.contactsCheckedOrSelected().length}),this.newMessageCommand=Cb.createCommand(this,function(){var a=this.contactsCheckedOrSelected(),b=[];Cb.isNonEmptyArray(a)&&(b=h.map(a,function(a){if(a){var b=a.getNameAndEmailHelper(),c=b?new v(b[0],b[1]):null;if(c&&c.validate())return c}return null}),b=h.compact(b)),Cb.isNonEmptyArray(b)&&(Hb.hideScreenPopup(J),Hb.showScreenPopup(I,[Ab.ComposeType.Empty,null,b]))},function(){return 0<this.contactsCheckedOrSelected().length}),this.clearCommand=Cb.createCommand(this,function(){this.search("")}),this.saveCommand=Cb.createCommand(this,function(){this.viewSaving(!0),this.viewSaveTrigger(Ab.SaveSettingsStep.Animate);var b=Cb.fakeMd5(),c=[];h.each(this.viewProperties(),function(a){a.type()&&""!==Cb.trim(a.value())&&c.push([a.type(),a.value()])}),Ob.remote().contactSave(function(c,d){var e=!1;a.viewSaving(!1),Ab.StorageResultType.Success===c&&d&&d.Result&&d.Result.RequestUid===b&&0<Cb.pInt(d.Result.ResultID)&&(""===a.viewID()&&a.viewID(Cb.pInt(d.Result.ResultID)),""===a.viewIDStr()&&a.viewIDStr(Cb.pString(d.Result.ResultIDStr)),a.reloadContactList(),e=!0),h.delay(function(){a.viewSaveTrigger(e?Ab.SaveSettingsStep.TrueResult:Ab.SaveSettingsStep.FalseResult)},300),e&&(a.watchDirty(!1),h.delay(function(){a.viewSaveTrigger(Ab.SaveSettingsStep.Idle)},1e3))},b,this.viewID(),this.viewIDStr(),this.viewScopeType(),c)},function(){var a=this.viewHasNonEmptyRequaredProperties(),b=this.viewReadOnly();return!this.viewSaving()&&a&&!b}),this.bDropPageAfterDelete=!1,this.watchDirty=c.observable(!1),this.watchHash=c.observable(!1),this.viewHash=c.computed(function(){return""+a.viewScopeType()+" - "+h.map(a.viewProperties(),function(a){return a.value()}).join("")}),this.viewHash.subscribe(function(){!this.watchHash()||this.viewReadOnly()||this.watchDirty()||this.watchDirty(!0)},this),this.sDefaultKeyScope=Ab.KeyState.ContactList,u.constructorEnd(this)}function K(){s.call(this,"Popups","PopupsAdvancedSearch"),this.fromFocus=c.observable(!1),this.from=c.observable(""),this.to=c.observable(""),this.subject=c.observable(""),this.text=c.observable(""),this.selectedDateValue=c.observable(-1),this.hasAttachments=c.observable(!1),this.starred=c.observable(!1),this.unseen=c.observable(!1),this.searchCommand=Cb.createCommand(this,function(){var a=this.buildSearchString();""!==a&&Ob.data().mainMessageListSearch(a),this.cancelCommand()}),u.constructorEnd(this)}function L(){s.call(this,"Popups","PopupsAddAccount"),this.email=c.observable(""),this.login=c.observable(""),this.password=c.observable(""),this.emailError=c.observable(!1),this.loginError=c.observable(!1),this.passwordError=c.observable(!1),this.email.subscribe(function(){this.emailError(!1)},this),this.login.subscribe(function(){this.loginError(!1)},this),this.password.subscribe(function(){this.passwordError(!1)},this),this.allowCustomLogin=c.observable(!1),this.submitRequest=c.observable(!1),this.submitError=c.observable(""),this.emailFocus=c.observable(!1),this.loginFocus=c.observable(!1),this.addAccountCommand=Cb.createCommand(this,function(){return this.emailError(""===Cb.trim(this.email())),this.passwordError(""===Cb.trim(this.password())),this.emailError()||this.passwordError()?!1:(this.submitRequest(!0),Ob.remote().accountAdd(h.bind(function(a,b){this.submitRequest(!1),Ab.StorageResultType.Success===a&&b&&"AccountAdd"===b.Action?b.Result?(Ob.accountsAndIdentities(),this.cancelCommand()):b.ErrorCode&&this.submitError(Cb.getNotification(b.ErrorCode)):this.submitError(Cb.getNotification(Ab.Notification.UnknownError))},this),this.email(),this.login(),this.password()),!0)},function(){return!this.submitRequest()}),this.loginFocus.subscribe(function(a){a&&""===this.login()&&""!==this.email()&&this.login(this.email())},this),u.constructorEnd(this)}function M(){s.call(this,"Popups","PopupsAddOpenPgpKey"),this.key=c.observable(""),this.key.error=c.observable(!1),this.key.focus=c.observable(!1),this.key.subscribe(function(){this.key.error(!1)},this),this.addOpenPgpKeyCommand=Cb.createCommand(this,function(){var a=Cb.trim(this.key()),b=Ob.data().openpgpKeyring;return this.key.error(""===a),!b||this.key.error()?!1:(b.importKey(a),b.store(),Ob.reloadOpenPgpKeys(),Cb.delegateRun(this,"cancelCommand"),!0)}),u.constructorEnd(this)}function N(){s.call(this,"Popups","PopupsViewOpenPgpKey"),this.key=c.observable(""),this.keyDom=c.observable(null),u.constructorEnd(this)}function O(){s.call(this,"Popups","PopupsGenerateNewOpenPgpKey"),this.email=c.observable(""),this.email.focus=c.observable(""),this.email.error=c.observable(!1),this.name=c.observable(""),this.password=c.observable(""),this.keyBitLength=c.observable(2048),this.submitRequest=c.observable(!1),this.email.subscribe(function(){this.email.error(!1)},this),this.generateOpenPgpKeyCommand=Cb.createCommand(this,function(){var b=this,c="",d=null,e=Ob.data().openpgpKeyring;return this.email.error(""===Cb.trim(this.email())),!e||this.email.error()?!1:(c=this.email(),""!==this.name()&&(c=this.name()+" <"+c+">"),this.submitRequest(!0),h.delay(function(){d=a.openpgp.generateKeyPair(1,Cb.pInt(b.keyBitLength()),c,Cb.trim(b.password())),d&&d.privateKeyArmored&&(e.importKey(d.privateKeyArmored),e.importKey(d.publicKeyArmored),e.store(),Ob.reloadOpenPgpKeys(),Cb.delegateRun(b,"cancelCommand")),b.submitRequest(!1)},100),!0)}),u.constructorEnd(this)}function P(){s.call(this,"Popups","PopupsComposeOpenPgp"),this.notification=c.observable(""),this.sign=c.observable(!0),this.encrypt=c.observable(!0),this.password=c.observable(""),this.password.focus=c.observable(!0),this.from=c.observable(""),this.to=c.observableArray([]),this.text=c.observable(""),this.resultCallback=null,this.submitRequest=c.observable(!1),this.doCommand=Cb.createCommand(this,function(){var b=this,c=!0,d=Ob.data(),e=null,f=[];this.submitRequest(!0),c&&this.sign()&&""===this.from()&&(this.notification("Please specify FROM email address"),c=!1),c&&this.sign()&&(e=d.findPrivateKeyByEmail(this.from(),this.password()),e||(this.notification('No private key found for "'+this.from()+'" email'),c=!1)),c&&this.encrypt()&&0===this.to().length&&(this.notification("Please specify at least one recipient"),c=!1),c&&this.encrypt()&&(f=[],h.each(this.to(),function(a){var e=d.findPublicKeysByEmail(a);0===e.length&&c&&(b.notification('No public key found for "'+a+'" email'),c=!1),f=f.concat(e)}),!c||0!==f.length&&this.to().length===f.length||(c=!1)),h.delay(function(){if(b.resultCallback&&c)try{e&&0===f.length?b.resultCallback(a.openpgp.signClearMessage([e],b.text())):e&&0<f.length?b.resultCallback(a.openpgp.signAndEncryptMessage(f,e,b.text())):!e&&0<f.length&&b.resultCallback(a.openpgp.encryptMessage(f,b.text()))}catch(d){b.notification("OpenPGP error: "+d),c=!1}c&&b.cancelCommand(),b.submitRequest(!1)},10)},function(){return!this.submitRequest()&&(this.sign()||this.encrypt())}),u.constructorEnd(this)}function Q(){s.call(this,"Popups","PopupsIdentity"),this.id="",this.edit=c.observable(!1),this.owner=c.observable(!1),this.email=c.observable("").validateEmail(),this.email.focused=c.observable(!1),this.name=c.observable(""),this.name.focused=c.observable(!1),this.replyTo=c.observable("").validateSimpleEmail(),this.replyTo.focused=c.observable(!1),this.bcc=c.observable("").validateSimpleEmail(),this.bcc.focused=c.observable(!1),this.submitRequest=c.observable(!1),this.submitError=c.observable(""),this.addOrEditIdentityCommand=Cb.createCommand(this,function(){return this.email.hasError()||this.email.hasError(""===Cb.trim(this.email())),this.email.hasError()?(this.owner()||this.email.focused(!0),!1):this.replyTo.hasError()?(this.replyTo.focused(!0),!1):this.bcc.hasError()?(this.bcc.focused(!0),!1):(this.submitRequest(!0),Ob.remote().identityUpdate(h.bind(function(a,b){this.submitRequest(!1),Ab.StorageResultType.Success===a&&b?b.Result?(Ob.accountsAndIdentities(),this.cancelCommand()):b.ErrorCode&&this.submitError(Cb.getNotification(b.ErrorCode)):this.submitError(Cb.getNotification(Ab.Notification.UnknownError))},this),this.id,this.email(),this.name(),this.replyTo(),this.bcc()),!0)},function(){return!this.submitRequest()}),this.label=c.computed(function(){return Cb.i18n("POPUPS_IDENTITIES/"+(this.edit()?"TITLE_UPDATE_IDENTITY":"TITLE_ADD_IDENTITY"))},this),this.button=c.computed(function(){return Cb.i18n("POPUPS_IDENTITIES/"+(this.edit()?"BUTTON_UPDATE_IDENTITY":"BUTTON_ADD_IDENTITY"))},this),u.constructorEnd(this)}function R(){s.call(this,"Popups","PopupsLanguages"),this.exp=c.observable(!1),this.languages=c.computed(function(){return h.map(Ob.data().languages(),function(a){return{key:a,selected:c.observable(!1),fullName:Cb.convertLangName(a)}})}),Ob.data().mainLanguage.subscribe(function(){this.resetMainLanguage()},this),u.constructorEnd(this)}function S(){s.call(this,"Popups","PopupsTwoFactorTest");var a=this;this.code=c.observable(""),this.code.focused=c.observable(!1),this.code.status=c.observable(null),this.testing=c.observable(!1),this.testCode=Cb.createCommand(this,function(){this.testing(!0),Ob.remote().testTwoFactor(function(b,c){a.testing(!1),a.code.status(Ab.StorageResultType.Success===b&&c&&c.Result?!0:!1)
},this.code())},function(){return""!==this.code()&&!this.testing()}),u.constructorEnd(this)}function T(){s.call(this,"Popups","PopupsAsk"),this.askDesc=c.observable(""),this.yesButton=c.observable(""),this.noButton=c.observable(""),this.yesFocus=c.observable(!1),this.noFocus=c.observable(!1),this.fYesAction=null,this.fNoAction=null,this.bDisabeCloseOnEsc=!0,this.sDefaultKeyScope=Ab.KeyState.PopupAsk,this.sKeyScope=Ab.KeyState.MessageList,u.constructorEnd(this)}function U(){s.call(this,"Popups","PopupsKeyboardShortcutsHelp"),u.constructorEnd(this)}function V(){s.call(this,"Center","Login");var b=Ob.data();this.email=c.observable(""),this.login=c.observable(""),this.password=c.observable(""),this.signMe=c.observable(!1),this.additionalCode=c.observable(""),this.additionalCode.error=c.observable(!1),this.additionalCode.focused=c.observable(!1),this.additionalCode.visibility=c.observable(!1),this.logoImg=Cb.trim(Ob.settingsGet("LoginLogo")),this.loginDescription=Cb.trim(Ob.settingsGet("LoginDescription")),this.logoCss=Cb.trim(Ob.settingsGet("LoginCss")),this.emailError=c.observable(!1),this.loginError=c.observable(!1),this.passwordError=c.observable(!1),this.emailFocus=c.observable(!1),this.loginFocus=c.observable(!1),this.submitFocus=c.observable(!1),this.email.subscribe(function(){this.emailError(!1),this.additionalCode(""),this.additionalCode.visibility(!1)},this),this.login.subscribe(function(){this.loginError(!1)},this),this.password.subscribe(function(){this.passwordError(!1)},this),this.additionalCode.subscribe(function(){this.additionalCode.error(!1)},this),this.additionalCode.visibility.subscribe(function(){this.additionalCode.error(!1)},this),this.submitRequest=c.observable(!1),this.submitError=c.observable(""),this.allowCustomLogin=b.allowCustomLogin,this.allowLanguagesOnLogin=b.allowLanguagesOnLogin,this.langRequest=c.observable(!1),this.mainLanguage=b.mainLanguage,this.bSendLanguage=!1,this.mainLanguageFullName=c.computed(function(){return Cb.convertLangName(this.mainLanguage())},this),this.signMeType=c.observable(Ab.LoginSignMeType.Unused),this.signMeType.subscribe(function(a){this.signMe(Ab.LoginSignMeType.DefaultOn===a)},this),this.signMeVisibility=c.computed(function(){return Ab.LoginSignMeType.Unused!==this.signMeType()},this),this.submitCommand=Cb.createCommand(this,function(){return this.emailError(""===Cb.trim(this.email())),this.passwordError(""===Cb.trim(this.password())),this.additionalCode.visibility()&&this.additionalCode.error(""===Cb.trim(this.additionalCode())),this.emailError()||this.passwordError()||this.additionalCode.error()?!1:(this.submitRequest(!0),Ob.remote().login(h.bind(function(a,b){Ab.StorageResultType.Success===a&&b&&"Login"===b.Action?b.Result?b.TwoFactorAuth?(this.additionalCode(""),this.additionalCode.visibility(!0),this.additionalCode.focused(!0),this.submitRequest(!1)):Ob.loginAndLogoutReload():b.ErrorCode?(this.submitRequest(!1),this.submitError(Cb.getNotification(b.ErrorCode)),""===this.submitError()&&this.submitError(Cb.getNotification(Ab.Notification.UnknownError))):this.submitRequest(!1):(this.submitRequest(!1),this.submitError(Cb.getNotification(Ab.Notification.UnknownError)))},this),this.email(),this.login(),this.password(),!!this.signMe(),this.bSendLanguage?this.mainLanguage():"",this.additionalCode.visibility()?this.additionalCode():""),!0)},function(){return!this.submitRequest()}),this.facebookLoginEnabled=c.observable(!1),this.facebookCommand=Cb.createCommand(this,function(){return a.open(Ob.link().socialFacebook(),"Facebook","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes"),!0},function(){return!this.submitRequest()&&this.facebookLoginEnabled()}),this.googleLoginEnabled=c.observable(!1),this.googleCommand=Cb.createCommand(this,function(){return a.open(Ob.link().socialGoogle(),"Google","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes"),!0},function(){return!this.submitRequest()&&this.googleLoginEnabled()}),this.twitterLoginEnabled=c.observable(!1),this.twitterCommand=Cb.createCommand(this,function(){return a.open(Ob.link().socialTwitter(),"Twitter","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes"),!0},function(){return!this.submitRequest()&&this.twitterLoginEnabled()}),this.loginFocus.subscribe(function(a){a&&""===this.login()&&""!==this.email()&&this.login(this.email())},this),this.socialLoginEnabled=c.computed(function(){var a=this.facebookLoginEnabled(),b=this.googleLoginEnabled(),c=this.twitterLoginEnabled();return a||b||c},this),u.constructorEnd(this)}function W(){s.call(this,"Right","SystemDropDown");var a=Ob.data();this.accounts=a.accounts,this.accountEmail=a.accountEmail,this.accountsLoading=a.accountsLoading,this.allowAddAccount=Ob.settingsGet("AllowAdditionalAccounts"),this.loading=c.computed(function(){return this.accountsLoading()},this),this.accountClick=h.bind(this.accountClick,this)}function X(){W.call(this),u.constructorEnd(this)}function Y(){W.call(this),u.constructorEnd(this)}function Z(){s.call(this,"Left","MailFolderList"),this.folderList=Ob.data().folderList,this.folderListSystem=Ob.data().folderListSystem,this.foldersChanging=Ob.data().foldersChanging,this.iDropOverTimer=0,this.allowContacts=!!Ob.settingsGet("ContactsIsAllowed"),u.constructorEnd(this)}function $(){s.call(this,"Right","MailMessageList"),this.sLastUid=null,this.bPrefetch=!1,this.emptySubjectValue="";var a=Ob.data();this.popupVisibility=Ob.popupVisibility,this.message=a.message,this.messageList=a.messageList,this.currentMessage=a.currentMessage,this.isMessageSelected=a.isMessageSelected,this.messageListSearch=a.messageListSearch,this.messageListError=a.messageListError,this.folderMenuForMove=a.folderMenuForMove,this.useCheckboxesInList=a.useCheckboxesInList,this.mainMessageListSearch=a.mainMessageListSearch,this.messageListEndFolder=a.messageListEndFolder,this.messageListChecked=a.messageListChecked,this.messageListCheckedOrSelected=a.messageListCheckedOrSelected,this.messageListCheckedOrSelectedUidsWithSubMails=a.messageListCheckedOrSelectedUidsWithSubMails,this.messageListCompleteLoadingThrottle=a.messageListCompleteLoadingThrottle,Cb.initOnStartOrLangChange(function(){this.emptySubjectValue=Cb.i18n("MESSAGE_LIST/EMPTY_SUBJECT_TEXT")},this),this.userQuota=a.userQuota,this.userUsageSize=a.userUsageSize,this.userUsageProc=a.userUsageProc,this.dragOver=c.observable(!1).extend({throttle:1}),this.dragOverEnter=c.observable(!1).extend({throttle:1}),this.dragOverArea=c.observable(null),this.dragOverBodyArea=c.observable(null),this.messageListItemTemplate=c.computed(function(){return Ab.Layout.NoPreview!==a.layout()?"MailMessageListItem":"MailMessageListItemNoPreviewPane"}),this.messageListSearchDesc=c.computed(function(){var b=a.messageListEndSearch();return""===b?"":Cb.i18n("MESSAGE_LIST/SEARCH_RESULT_FOR",{SEARCH:b})}),this.messageListPagenator=c.computed(Cb.computedPagenatorHelper(a.messageListPage,a.messageListPageCount)),this.checkAll=c.computed({read:function(){return 0<Ob.data().messageListChecked().length},write:function(a){a=!!a,h.each(Ob.data().messageList(),function(b){b.checked(a)})}}),this.inputMessageListSearchFocus=c.observable(!1),this.sLastSearchValue="",this.inputProxyMessageListSearch=c.computed({read:this.mainMessageListSearch,write:function(a){this.sLastSearchValue=a},owner:this}),this.isIncompleteChecked=c.computed(function(){var a=Ob.data().messageList().length,b=Ob.data().messageListChecked().length;return a>0&&b>0&&a>b},this),this.hasMessages=c.computed(function(){return 0<this.messageList().length},this),this.hasCheckedOrSelectedLines=c.computed(function(){return 0<this.messageListCheckedOrSelected().length},this),this.isSpamFolder=c.computed(function(){return a.spamFolder()===this.messageListEndFolder()&&""!==a.spamFolder()},this),this.isSpamDisabled=c.computed(function(){return zb.Values.UnuseOptionValue===a.spamFolder()},this),this.isTrashFolder=c.computed(function(){return a.trashFolder()===this.messageListEndFolder()&&""!==a.trashFolder()},this),this.isDraftFolder=c.computed(function(){return a.draftFolder()===this.messageListEndFolder()&&""!==a.draftFolder()},this),this.isSentFolder=c.computed(function(){return a.sentFolder()===this.messageListEndFolder()&&""!==a.sentFolder()},this),this.isArchiveFolder=c.computed(function(){return a.archiveFolder()===this.messageListEndFolder()&&""!==a.archiveFolder()},this),this.isArchiveDisabled=c.computed(function(){return zb.Values.UnuseOptionValue===Ob.data().archiveFolder()},this),this.canBeMoved=this.hasCheckedOrSelectedLines,this.clearCommand=Cb.createCommand(this,function(){Hb.showScreenPopup(F,[Ob.data().currentFolder()])}),this.multyForwardCommand=Cb.createCommand(this,function(){Hb.showScreenPopup(I,[Ab.ComposeType.ForwardAsAttachment,Ob.data().messageListCheckedOrSelected()])},this.canBeMoved),this.deleteWithoutMoveCommand=Cb.createCommand(this,function(){Ob.deleteMessagesFromFolder(Ab.FolderType.Trash,Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),!1)},this.canBeMoved),this.deleteCommand=Cb.createCommand(this,function(){Ob.deleteMessagesFromFolder(Ab.FolderType.Trash,Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),!0)},this.canBeMoved),this.archiveCommand=Cb.createCommand(this,function(){Ob.deleteMessagesFromFolder(Ab.FolderType.Archive,Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),!0)},this.canBeMoved),this.spamCommand=Cb.createCommand(this,function(){Ob.deleteMessagesFromFolder(Ab.FolderType.Spam,Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),!0)},this.canBeMoved),this.moveCommand=Cb.createCommand(this,Cb.emptyFunction,this.canBeMoved),this.reloadCommand=Cb.createCommand(this,function(){Ob.data().messageListCompleteLoadingThrottle()||Ob.reloadMessageList(!1,!0)}),this.quotaTooltip=h.bind(this.quotaTooltip,this),this.selector=new m(this.messageList,this.currentMessage,".messageListItem .actionHandle",".messageListItem.selected",".messageListItem .checkboxMessage",".messageListItem.focused"),this.selector.on("onItemSelect",h.bind(function(b){b?(a.message(a.staticMessageList.populateByMessageListItem(b)),this.populateMessageBody(a.message()),Ab.Layout.NoPreview===a.layout()&&(Hb.setHash(Ob.link().messagePreview(),!0),a.message.focused(!0))):a.message(null)},this)),this.selector.on("onItemGetUid",function(a){return a?a.generateUid():""}),a.layout.subscribe(function(a){this.selector.autoSelect(Ab.Layout.NoPreview!==a)},this),a.layout.valueHasMutated(),Ob.sub("mailbox.message-list.selector.go-down",function(){this.selector.goDown(!0)},this).sub("mailbox.message-list.selector.go-up",function(){this.selector.goUp(!0)},this),u.constructorEnd(this)}function _(){s.call(this,"Right","MailMessageView");var a="",b=Ob.data(),d=this,e=function(a){return Cb.createCommand(d,function(){this.replyOrforward(a)},d.canBeRepliedOrForwarded)};this.oMessageScrollerDom=null,this.keyScope=b.keyScope,this.message=b.message,this.currentMessage=b.currentMessage,this.messageLoading=b.messageLoading,this.messageLoadingThrottle=b.messageLoadingThrottle,this.messagesBodiesDom=b.messagesBodiesDom,this.useThreads=b.useThreads,this.replySameFolder=b.replySameFolder,this.layout=b.layout,this.usePreviewPane=b.usePreviewPane,this.isMessageSelected=b.isMessageSelected,this.messageActiveDom=b.messageActiveDom,this.messageError=b.messageError,this.fullScreenMode=b.messageFullScreenMode,this.showFullInfo=c.observable(!1),this.messageDomFocused=c.observable(!1),this.messageVisibility=c.computed(function(){return!this.messageLoadingThrottle()&&!!this.message()},this),this.message.subscribe(function(a){!a&&this.currentMessage()&&this.currentMessage(null)},this),this.canBeRepliedOrForwarded=this.messageVisibility,this.closeMessage=Cb.createCommand(this,function(){Ab.Layout.NoPreview===b.layout()?Ob.historyBack():b.message(null)}),this.replyCommand=e(Ab.ComposeType.Reply),this.replyAllCommand=e(Ab.ComposeType.ReplyAll),this.forwardCommand=e(Ab.ComposeType.Forward),this.forwardAsAttachmentCommand=e(Ab.ComposeType.ForwardAsAttachment),this.editAsNewCommand=e(Ab.ComposeType.EditAsNew),this.messageVisibilityCommand=Cb.createCommand(this,Cb.emptyFunction,this.messageVisibility),this.messageEditCommand=Cb.createCommand(this,function(){this.editMessage()},this.messageVisibility),this.deleteCommand=Cb.createCommand(this,function(){this.message()&&Ob.deleteMessagesFromFolder(Ab.FolderType.Trash,this.message().folderFullNameRaw,[this.message().uid],!0)},this.messageVisibility),this.deleteWithoutMoveCommand=Cb.createCommand(this,function(){this.message()&&Ob.deleteMessagesFromFolder(Ab.FolderType.Trash,Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),!1)},this.messageVisibility),this.archiveCommand=Cb.createCommand(this,function(){this.message()&&Ob.deleteMessagesFromFolder(Ab.FolderType.Archive,this.message().folderFullNameRaw,[this.message().uid],!0)},this.messageVisibility),this.spamCommand=Cb.createCommand(this,function(){this.message()&&Ob.deleteMessagesFromFolder(Ab.FolderType.Spam,this.message().folderFullNameRaw,[this.message().uid],!0)},this.messageVisibility),this.viewSubject=c.observable(""),this.viewFromShort=c.observable(""),this.viewToShort=c.observable(""),this.viewFrom=c.observable(""),this.viewTo=c.observable(""),this.viewCc=c.observable(""),this.viewBcc=c.observable(""),this.viewDate=c.observable(""),this.viewMoment=c.observable(""),this.viewLineAsCcc=c.observable(""),this.viewViewLink=c.observable(""),this.viewDownloadLink=c.observable(""),this.viewUserPic=c.observable(zb.DataImages.UserDotPic),this.viewUserPicVisible=c.observable(!1),this.viewPgpPassword=c.observable(""),this.viewPgpSignedVerifyStatus=c.computed(function(){return this.message()?this.message().pgpSignedVerifyStatus():Ab.SignedVerifyStatus.None},this),this.viewPgpSignedVerifyUser=c.computed(function(){return this.message()?this.message().pgpSignedVerifyUser():""},this),this.message.subscribe(function(b){this.messageActiveDom(null),this.viewPgpPassword(""),b&&(this.viewSubject(b.subject()),this.viewFromShort(b.fromToLine(!0,!0)),this.viewToShort(b.toToLine(!0,!0)),this.viewFrom(b.fromToLine(!1)),this.viewTo(b.toToLine(!1)),this.viewCc(b.ccToLine(!1)),this.viewBcc(b.bccToLine(!1)),this.viewDate(b.fullFormatDateValue()),this.viewMoment(b.momentDate()),this.viewLineAsCcc(b.lineAsCcc()),this.viewViewLink(b.viewLink()),this.viewDownloadLink(b.downloadLink()),a=Ob.cache().getUserPic(b.fromAsSingleEmail()),a!==this.viewUserPic()&&(this.viewUserPicVisible(!1),this.viewUserPic(zb.DataImages.UserDotPic),""!==a&&(this.viewUserPicVisible(!0),this.viewUserPic(a))))},this),this.fullScreenMode.subscribe(function(a){a?Kb.addClass("rl-message-fullscreen"):Kb.removeClass("rl-message-fullscreen"),Cb.windowResize()}),this.messageLoadingThrottle.subscribe(function(a){a&&Cb.windowResize()}),this.messageActiveDom.subscribe(function(){this.scrollMessageToTop()},this),this.goUpCommand=Cb.createCommand(this,function(){Ob.pub("mailbox.message-list.selector.go-up")}),this.goDownCommand=Cb.createCommand(this,function(){Ob.pub("mailbox.message-list.selector.go-down")}),u.constructorEnd(this)}function ab(a){s.call(this,"Left","SettingsMenu"),this.menu=a.menu,u.constructorEnd(this)}function bb(){s.call(this,"Right","SettingsPane"),u.constructorEnd(this)}function cb(){var a=Ob.data();this.mainLanguage=a.mainLanguage,this.mainMessagesPerPage=a.mainMessagesPerPage,this.mainMessagesPerPageArray=zb.Defaults.MessagesPerPageArray,this.editorDefaultType=a.editorDefaultType,this.showImages=a.showImages,this.interfaceAnimation=a.interfaceAnimation,this.useDesktopNotifications=a.useDesktopNotifications,this.threading=a.threading,this.useThreads=a.useThreads,this.replySameFolder=a.replySameFolder,this.layout=a.layout,this.usePreviewPane=a.usePreviewPane,this.useCheckboxesInList=a.useCheckboxesInList,this.allowLanguagesOnSettings=a.allowLanguagesOnSettings,this.isDesktopNotificationsSupported=c.computed(function(){return Ab.DesktopNotifications.NotSupported!==a.desktopNotificationsPermisions()}),this.isDesktopNotificationsDenied=c.computed(function(){return Ab.DesktopNotifications.NotSupported===a.desktopNotificationsPermisions()||Ab.DesktopNotifications.Denied===a.desktopNotificationsPermisions()}),this.mainLanguageFullName=c.computed(function(){return Cb.convertLangName(this.mainLanguage())},this),this.languageTrigger=c.observable(Ab.SaveSettingsStep.Idle).extend({throttle:100}),this.mppTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.isAnimationSupported=Fb.bAnimationSupported}function db(){var a=Ob.data();this.contactsAutosave=a.contactsAutosave,this.showPassword=c.observable(!1),this.allowContactsSync=!!Ob.settingsGet("ContactsSyncIsAllowed"),this.contactsSyncServer=Ob.settingsGet("ContactsSyncServer"),this.contactsSyncUser=Ob.settingsGet("ContactsSyncUser"),this.contactsSyncPass=Ob.settingsGet("ContactsSyncPassword"),this.contactsSyncPabUrl=Ob.settingsGet("ContactsSyncPabUrl")}function eb(){var a=Ob.data();this.accounts=a.accounts,this.processText=c.computed(function(){return a.accountsLoading()?Cb.i18n("SETTINGS_ACCOUNTS/LOADING_PROCESS"):""},this),this.visibility=c.computed(function(){return""===this.processText()?"hidden":"visible"},this),this.accountForDeletion=c.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]})}function fb(){var a=Ob.data();this.editor=null,this.displayName=a.displayName,this.signature=a.signature,this.signatureToAll=a.signatureToAll,this.replyTo=a.replyTo,this.signatureDom=c.observable(null),this.displayNameTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.replyTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.signatureTrigger=c.observable(Ab.SaveSettingsStep.Idle)}function gb(){var a=Ob.data();this.editor=null,this.displayName=a.displayName,this.signature=a.signature,this.signatureToAll=a.signatureToAll,this.replyTo=a.replyTo,this.signatureDom=c.observable(null),this.displayNameTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.replyTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.signatureTrigger=c.observable(Ab.SaveSettingsStep.Idle),this.identities=a.identities,this.processText=c.computed(function(){return a.identitiesLoading()?Cb.i18n("SETTINGS_IDENTITIES/LOADING_PROCESS"):""},this),this.visibility=c.computed(function(){return""===this.processText()?"hidden":"visible"},this),this.identityForDeletion=c.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]})}function hb(){this.processing=c.observable(!1),this.clearing=c.observable(!1),this.viewUser=c.observable(""),this.viewEnable=c.observable(!1),this.viewEnable.subs=!0,this.twoFactorStatus=c.observable(!1),this.viewSecret=c.observable(""),this.viewBackupCodes=c.observable(""),this.viewUrl=c.observable(""),this.bFirst=!0,this.viewTwoFactorStatus=c.computed(function(){return Fb.langChangeTrigger(),Cb.i18n(this.twoFactorStatus()?"SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC":"SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC")},this),this.onResult=h.bind(this.onResult,this)}function ib(){var a=Ob.data();this.googleEnable=a.googleEnable,this.googleActions=a.googleActions,this.googleLoggined=a.googleLoggined,this.googleUserName=a.googleUserName,this.facebookEnable=a.facebookEnable,this.facebookActions=a.facebookActions,this.facebookLoggined=a.facebookLoggined,this.facebookUserName=a.facebookUserName,this.twitterEnable=a.twitterEnable,this.twitterActions=a.twitterActions,this.twitterLoggined=a.twitterLoggined,this.twitterUserName=a.twitterUserName,this.connectGoogle=Cb.createCommand(this,function(){this.googleLoggined()||Ob.googleConnect()},function(){return!this.googleLoggined()&&!this.googleActions()}),this.disconnectGoogle=Cb.createCommand(this,function(){Ob.googleDisconnect()}),this.connectFacebook=Cb.createCommand(this,function(){this.facebookLoggined()||Ob.facebookConnect()},function(){return!this.facebookLoggined()&&!this.facebookActions()}),this.disconnectFacebook=Cb.createCommand(this,function(){Ob.facebookDisconnect()}),this.connectTwitter=Cb.createCommand(this,function(){this.twitterLoggined()||Ob.twitterConnect()},function(){return!this.twitterLoggined()&&!this.twitterActions()}),this.disconnectTwitter=Cb.createCommand(this,function(){Ob.twitterDisconnect()})}function jb(){this.changeProcess=c.observable(!1),this.passwordUpdateError=c.observable(!1),this.passwordUpdateSuccess=c.observable(!1),this.currentPassword=c.observable(""),this.newPassword=c.observable(""),this.currentPassword.subscribe(function(){this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1)},this),this.newPassword.subscribe(function(){this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1)},this),this.saveNewPasswordCommand=Cb.createCommand(this,function(){this.changeProcess(!0),this.passwordUpdateError(!1),this.passwordUpdateSuccess(!1),Ob.remote().changePassword(this.onChangePasswordResponse,this.currentPassword(),this.newPassword())},function(){return!this.changeProcess()&&""!==this.currentPassword()&&""!==this.newPassword()}),this.onChangePasswordResponse=h.bind(this.onChangePasswordResponse,this)}function kb(){var a=Ob.data();this.foldersListError=a.foldersListError,this.folderList=a.folderList,this.processText=c.computed(function(){var a=Ob.data(),b=a.foldersLoading(),c=a.foldersCreating(),d=a.foldersDeleting(),e=a.foldersRenaming();return c?Cb.i18n("SETTINGS_FOLDERS/CREATING_PROCESS"):d?Cb.i18n("SETTINGS_FOLDERS/DELETING_PROCESS"):e?Cb.i18n("SETTINGS_FOLDERS/RENAMING_PROCESS"):b?Cb.i18n("SETTINGS_FOLDERS/LOADING_PROCESS"):""},this),this.visibility=c.computed(function(){return""===this.processText()?"hidden":"visible"},this),this.folderForDeletion=c.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]}),this.folderForEdit=c.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.edited(!1)},function(a){a&&a.canBeEdited()&&a.edited(!0)}]}),this.useImapSubscribe=!!Ob.settingsGet("UseImapSubscribe")}function lb(){var d=this,e=Ob.data();this.mainTheme=e.mainTheme,this.customThemeType=c.observable(Ob.settingsGet("CustomThemeType")),this.customThemeImg=c.observable(Ob.settingsGet("CustomThemeImg")),this.themesObjects=c.observableArray([]),this.customThemeUploaderProgress=c.observable(!1),this.customThemeUploaderButton=c.observable(null),this.showCustomThemeConfig=c.computed(function(){return"Custom"===this.mainTheme()},this),this.showCustomThemeConfig.subscribe(function(){Cb.windowResize()}),this.themeTrigger=c.observable(Ab.SaveSettingsStep.Idle).extend({throttle:100}),this.oLastAjax=null,this.iTimer=0,Ob.data().theme.subscribe(function(c){h.each(this.themesObjects(),function(a){a.selected(c===a.name)});var e=b("#rlThemeLink"),f=b("#rlThemeStyle"),g=e.attr("href");g||(g=f.attr("data-href")),g&&(g=g.toString().replace(/\/-\/[^\/]+\/\-\//,"/-/"+c+"/-/"),g=g.toString().replace(/\/Css\/[^\/]+\/User\//,"/Css/"+("Custom"===c&&a.__rlah?a.__rlah()||"0":"0")+"/User/"),"Json/"!==g.substring(g.length-5,g.length)&&(g+="Json/"),a.clearTimeout(d.iTimer),d.themeTrigger(Ab.SaveSettingsStep.Animate),this.oLastAjax&&this.oLastAjax.abort&&this.oLastAjax.abort(),this.oLastAjax=b.ajax({url:g,dataType:"json"}).done(function(a){a&&Cb.isArray(a)&&2===a.length&&(!e||!e[0]||f&&f[0]||(f=b('<style id="rlThemeStyle"></style>'),e.after(f),e.remove()),f&&f[0]&&(f.attr("data-href",g).attr("data-theme",a[0]),f&&f[0]&&f[0].styleSheet&&!Cb.isUnd(f[0].styleSheet.cssText)?f[0].styleSheet.cssText=a[1]:f.text(a[1])),d.themeTrigger(Ab.SaveSettingsStep.TrueResult))}).always(function(){d.iTimer=a.setTimeout(function(){d.themeTrigger(Ab.SaveSettingsStep.Idle)},1e3),d.oLastAjax=null})),Ob.remote().saveSettings(null,{Theme:c})},this)}function mb(){this.openpgpkeys=Ob.data().openpgpkeys,this.openpgpkeysPublic=Ob.data().openpgpkeysPublic,this.openpgpkeysPrivate=Ob.data().openpgpkeysPrivate,this.openPgpKeyForDeletion=c.observable(null).extend({falseTimeout:3e3}).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&a.deleteAccess(!0)}]})}function nb(){this.keyScope=c.observable(Ab.KeyState.All),this.keyScope.subscribe(function(a){Ab.KeyState.Compose===a?Cb.disableKeyFilter():Cb.restoreKeyFilter(),j.setScope(a)}),Cb.initDataConstructorBySettings(this)}function ob(){nb.call(this);var a=function(a){return function(){var b=Ob.cache().getFolderFromCacheList(a());b&&b.type(Ab.FolderType.User)}},d=function(a){return function(b){var c=Ob.cache().getFolderFromCacheList(b);c&&c.type(a)}};this.devEmail="",this.devLogin="",this.devPassword="",this.accountEmail=c.observable(""),this.accountIncLogin=c.observable(""),this.accountOutLogin=c.observable(""),this.projectHash=c.observable(""),this.threading=c.observable(!1),this.lastFoldersHash="",this.remoteSuggestions=!1,this.sentFolder=c.observable(""),this.draftFolder=c.observable(""),this.spamFolder=c.observable(""),this.trashFolder=c.observable(""),this.archiveFolder=c.observable(""),this.sentFolder.subscribe(a(this.sentFolder),this,"beforeChange"),this.draftFolder.subscribe(a(this.draftFolder),this,"beforeChange"),this.spamFolder.subscribe(a(this.spamFolder),this,"beforeChange"),this.trashFolder.subscribe(a(this.trashFolder),this,"beforeChange"),this.archiveFolder.subscribe(a(this.archiveFolder),this,"beforeChange"),this.sentFolder.subscribe(d(Ab.FolderType.SentItems),this),this.draftFolder.subscribe(d(Ab.FolderType.Draft),this),this.spamFolder.subscribe(d(Ab.FolderType.Spam),this),this.trashFolder.subscribe(d(Ab.FolderType.Trash),this),this.archiveFolder.subscribe(d(Ab.FolderType.Archive),this),this.draftFolderNotEnabled=c.computed(function(){return""===this.draftFolder()||zb.Values.UnuseOptionValue===this.draftFolder()},this),this.displayName=c.observable(""),this.signature=c.observable(""),this.signatureToAll=c.observable(!1),this.replyTo=c.observable(""),this.enableTwoFactor=c.observable(!1),this.accounts=c.observableArray([]),this.accountsLoading=c.observable(!1).extend({throttle:100}),this.identities=c.observableArray([]),this.identitiesLoading=c.observable(!1).extend({throttle:100}),this.namespace="",this.folderList=c.observableArray([]),this.foldersListError=c.observable(""),this.foldersLoading=c.observable(!1),this.foldersCreating=c.observable(!1),this.foldersDeleting=c.observable(!1),this.foldersRenaming=c.observable(!1),this.foldersChanging=c.computed(function(){var a=this.foldersLoading(),b=this.foldersCreating(),c=this.foldersDeleting(),d=this.foldersRenaming();return a||b||c||d},this),this.foldersInboxUnreadCount=c.observable(0),this.currentFolder=c.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]}),this.currentFolderFullNameRaw=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this),this.currentFolderFullName=c.computed(function(){return this.currentFolder()?this.currentFolder().fullName:""},this),this.currentFolderFullNameHash=c.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this),this.currentFolderName=c.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this),this.folderListSystemNames=c.computed(function(){var a=["INBOX"],b=this.folderList(),c=this.sentFolder(),d=this.draftFolder(),e=this.spamFolder(),f=this.trashFolder(),g=this.archiveFolder();return Cb.isArray(b)&&0<b.length&&(""!==c&&zb.Values.UnuseOptionValue!==c&&a.push(c),""!==d&&zb.Values.UnuseOptionValue!==d&&a.push(d),""!==e&&zb.Values.UnuseOptionValue!==e&&a.push(e),""!==f&&zb.Values.UnuseOptionValue!==f&&a.push(f),""!==g&&zb.Values.UnuseOptionValue!==g&&a.push(g)),a},this),this.folderListSystem=c.computed(function(){return h.compact(h.map(this.folderListSystemNames(),function(a){return Ob.cache().getFolderFromCacheList(a)}))},this),this.folderMenuForMove=c.computed(function(){return Ob.folderListOptionsBuilder(this.folderListSystem(),this.folderList(),[this.currentFolderFullNameRaw()],null,null,null,null,function(a){return a?a.localName():""})},this),this.staticMessageList=[],this.messageList=c.observableArray([]),this.messageListCount=c.observable(0),this.messageListSearch=c.observable(""),this.messageListPage=c.observable(1),this.messageListThreadFolder=c.observable(""),this.messageListThreadUids=c.observableArray([]),this.messageListThreadFolder.subscribe(function(){this.messageListThreadUids([])},this),this.messageListEndSearch=c.observable(""),this.messageListEndFolder=c.observable(""),this.messageListPageCount=c.computed(function(){var a=Math.ceil(this.messageListCount()/this.messagesPerPage());return 0>=a?1:a},this),this.mainMessageListSearch=c.computed({read:this.messageListSearch,write:function(a){Hb.setHash(Ob.link().mailBox(this.currentFolderFullNameHash(),1,Cb.trim(a.toString())))},owner:this}),this.messageListError=c.observable(""),this.messageListLoading=c.observable(!1),this.messageListIsNotCompleted=c.observable(!1),this.messageListCompleteLoadingThrottle=c.observable(!1).extend({throttle:200}),this.messageListCompleteLoading=c.computed(function(){var a=this.messageListLoading(),b=this.messageListIsNotCompleted();return a||b},this),this.messageListCompleteLoading.subscribe(function(a){this.messageListCompleteLoadingThrottle(a)},this),this.messageList.subscribe(h.debounce(function(a){h.each(a,function(a){a.newForAnimation()&&a.newForAnimation(!1)})},500)),this.staticMessageList=new A,this.message=c.observable(null),this.messageLoading=c.observable(!1),this.messageLoadingThrottle=c.observable(!1).extend({throttle:50}),this.message.focused=c.observable(!1),this.message.subscribe(function(a){a?Ab.Layout.NoPreview===this.layout()&&this.message.focused(!0):(this.message.focused(!1),this.hideMessageBodies())},this),this.message.focused.subscribe(function(a){Ob.data().keyScope(a?Ab.KeyState.MessageView:Ab.KeyState.MessageList)}),this.messageLoading.subscribe(function(a){this.messageLoadingThrottle(a)},this),this.messageFullScreenMode=c.observable(!1),this.messageError=c.observable(""),this.messagesBodiesDom=c.observable(null),this.messagesBodiesDom.subscribe(function(a){!a||a instanceof jQuery||this.messagesBodiesDom(b(a))},this),this.messageActiveDom=c.observable(null),this.isMessageSelected=c.computed(function(){return null!==this.message()},this),this.currentMessage=c.observable(null),this.messageListChecked=c.computed(function(){return h.filter(this.messageList(),function(a){return a.checked()})},this),this.messageListCheckedOrSelected=c.computed(function(){var a=this.messageListChecked(),b=this.currentMessage();return h.union(a,b?[b]:[])},this),this.messageListCheckedOrSelectedUidsWithSubMails=c.computed(function(){var a=[];return h.each(this.messageListCheckedOrSelected(),function(b){b&&(a.push(b.uid),0<b.threadsLen()&&0===b.parentUid()&&b.lastInCollapsedThread()&&(a=h.union(a,b.threads())))}),a},this),this.userQuota=c.observable(0),this.userUsageSize=c.observable(0),this.userUsageProc=c.computed(function(){var a=this.userQuota(),b=this.userUsageSize();return a>0?Math.ceil(b/a*100):0},this),this.useKeyboardShortcuts=c.observable(!0),this.allowOpenPGP=c.observable(!1),this.openpgpkeys=c.observableArray([]),this.openpgpKeyring=null,this.openpgpkeysPublic=this.openpgpkeys.filter(function(a){return!(!a||a.isPrivate)}),this.openpgpkeysPrivate=this.openpgpkeys.filter(function(a){return!(!a||!a.isPrivate)}),this.googleActions=c.observable(!1),this.googleLoggined=c.observable(!1),this.googleUserName=c.observable(""),this.facebookActions=c.observable(!1),this.facebookLoggined=c.observable(!1),this.facebookUserName=c.observable(""),this.twitterActions=c.observable(!1),this.twitterLoggined=c.observable(!1),this.twitterUserName=c.observable(""),this.customThemeType=c.observable(Ab.CustomThemeType.Light),this.purgeMessageBodyCacheThrottle=h.throttle(this.purgeMessageBodyCache,3e4)
}function pb(){this.oRequests={}}function qb(){pb.call(this),this.oRequests={}}function rb(){this.oEmailsPicsHashes={},this.oServices={}}function sb(){rb.call(this),this.oFoldersCache={},this.oFoldersNamesCache={},this.oFolderHashCache={},this.oFolderUidNextCache={},this.oMessageListHashCache={},this.oMessageFlagsCache={},this.oNewMessage={},this.oRequestedMessage={}}function tb(a){t.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function ub(){t.call(this,"login",[V])}function vb(){t.call(this,"mailbox",[X,Z,$,_]),this.oLastRoute={}}function wb(){tb.call(this,[Y,ab,bb]),Cb.initOnStartOrLangChange(function(){this.sSettingsTitle=Cb.i18n("TITLES/SETTINGS")},this,function(){Ob.setTitle(this.sSettingsTitle)})}function xb(){r.call(this),this.oSettings=null,this.oPlugins=null,this.oLocal=null,this.oLink=null,this.oSubs={},this.isLocalAutocomplete=!0,this.popupVisibilityNames=c.observableArray([]),this.popupVisibility=c.computed(function(){return 0<this.popupVisibilityNames().length},this),this.iframe=b('<iframe style="display:none" src="javascript:;" />').appendTo("body"),Lb.on("error",function(a){Ob&&a&&a.originalEvent&&a.originalEvent.message&&-1===Cb.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&Ob.remote().jsError(Cb.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",Kb.attr("class"),Cb.microtime()-Fb.now)})}function yb(){xb.call(this),this.oData=null,this.oRemote=null,this.oCache=null,this.oMoveCache={},this.quotaDebounce=h.debounce(this.quota,3e4),this.moveOrDeleteResponseHelper=h.bind(this.moveOrDeleteResponseHelper,this),this.messagesMoveTrigger=h.debounce(this.messagesMoveTrigger,500),a.setInterval(function(){Ob.pub("interval.30s")},3e4),a.setInterval(function(){Ob.pub("interval.1m")},6e4),a.setInterval(function(){Ob.pub("interval.2m")},12e4),a.setInterval(function(){Ob.pub("interval.3m")},18e4),a.setInterval(function(){Ob.pub("interval.5m")},3e5),a.setInterval(function(){Ob.pub("interval.10m")},6e5),b.wakeUp(function(){Ob.remote().jsVersion(function(b,c){Ab.StorageResultType.Success===b&&c&&!c.Result&&(a.parent&&Ob.settingsGet("InIframe")?a.parent.location.reload():a.location.reload())},Ob.settingsGet("Version"))},{},36e5)}var zb={},Ab={},Bb={},Cb={},Db={},Eb={},Fb={},Gb={settings:[],"settings-removed":[],"settings-disabled":[]},Hb=null,Ib=a.rainloopAppData||{},Jb=a.rainloopI18N||{},Kb=b("html"),Lb=b(a),Mb=b(a.document),Nb=a.Notification&&a.Notification.requestPermission?a.Notification:null,Ob=null,Pb=b("<div></div>");Fb.now=(new Date).getTime(),Fb.momentTrigger=c.observable(!0),Fb.langChangeTrigger=c.observable(!0),Fb.iAjaxErrorCount=0,Fb.iTokenErrorCount=0,Fb.iMessageBodyCacheCount=0,Fb.bUnload=!1,Fb.sUserAgent=(navigator.userAgent||"").toLowerCase(),Fb.bIsiOSDevice=-1<Fb.sUserAgent.indexOf("iphone")||-1<Fb.sUserAgent.indexOf("ipod")||-1<Fb.sUserAgent.indexOf("ipad"),Fb.bIsAndroidDevice=-1<Fb.sUserAgent.indexOf("android"),Fb.bMobileDevice=Fb.bIsiOSDevice||Fb.bIsAndroidDevice,Fb.bDisableNanoScroll=Fb.bMobileDevice,Fb.bAllowPdfPreview=!Fb.bMobileDevice,Fb.bAnimationSupported=!Fb.bMobileDevice&&Kb.hasClass("csstransitions"),Fb.sAnimationType="",Fb.oHtmlEditorDefaultConfig={title:!1,stylesSet:!1,customConfig:"",contentsCss:"",toolbarGroups:[{name:"spec"},{name:"styles"},{name:"basicstyles",groups:["basicstyles","cleanup"]},{name:"colors"},{name:"paragraph",groups:["list","indent","blocks","align"]},{name:"links"},{name:"insert"},{name:"others"}],removePlugins:"contextmenu",removeButtons:"Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll",removeDialogTabs:"link:advanced;link:target;image:advanced",extraPlugins:"plain",allowedContent:!0,autoParagraph:!1,enterMode:a.CKEDITOR.ENTER_BR,shiftEnterMode:a.CKEDITOR.ENTER_BR,font_defaultLabel:"Arial",fontSize_defaultLabel:"13",fontSize_sizes:"10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px"},Fb.oHtmlEditorLangsMap={de:"de",es:"es",fr:"fr",hu:"hu",is:"is",it:"it",ko:"ko","ko-kr":"ko",lv:"lv",nl:"nl",no:"no",pl:"pl",pt:"pt","pt-pt":"pt","pt-br":"pt-br",ru:"ru",ro:"ro",zh:"zh","zh-cn":"zh-cn"},Fb.bAllowPdfPreview&&navigator&&navigator.mimeTypes&&(Fb.bAllowPdfPreview=!!h.find(navigator.mimeTypes,function(a){return a&&"application/pdf"===a.type})),zb.Defaults={},zb.Values={},zb.DataImages={},zb.Defaults.MessagesPerPage=20,zb.Defaults.ContactsPerPage=20,zb.Defaults.MessagesPerPageArray=[10,20,30,50,100],zb.Defaults.DefaultAjaxTimeout=2e4,zb.Defaults.SearchAjaxTimeout=12e4,zb.Defaults.SendMessageAjaxTimeout=2e5,zb.Defaults.SaveMessageAjaxTimeout=2e5,zb.Values.UnuseOptionValue="__UNUSE__",zb.Values.GmailFolderName="[Gmail]",zb.Values.ClientSideCookieIndexName="rlcsc",zb.Values.ImapDefaulPort=143,zb.Values.ImapDefaulSecurePort=993,zb.Values.SmtpDefaulPort=25,zb.Values.SmtpDefaulSecurePort=465,zb.Values.MessageBodyCacheLimit=15,zb.Values.AjaxErrorLimit=7,zb.Values.TokenErrorLimit=10,zb.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",zb.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",Ab.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"},Ab.State={Empty:10,Login:20,Auth:30},Ab.StateType={Webmail:0,Admin:1},Ab.KeyState={All:"all",None:"none",ContactList:"contact-list",MessageList:"message-list",MessageView:"message-view",Compose:"compose",PopupAsk:"popup-ask"},Ab.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,Archive:15,User:99},Ab.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"},Ab.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2},Ab.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft",EditAsNew:"editasnew"},Ab.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99},Ab.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4,Archive:5},Ab.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3,FolderListSize:4},Ab.EventKeyCode={Backspace:8,Tab:9,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Space:32,Insert:45,Delete:46,A:65,S:83},Ab.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3},Ab.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6},Ab.DesktopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9},Ab.MessagePriority={Low:5,Normal:3,High:1},Ab.EditorDefaultType={Html:"Html",Plain:"Plain"},Ab.CustomThemeType={Light:"Light",Dark:"Dark"},Ab.ServerSecure={None:0,SSL:1,TLS:2},Ab.SearchDateType={All:-1,Days3:3,Days7:7,Month:30},Ab.EmailType={Defailt:0,Facebook:1,Google:2},Ab.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0},Ab.InterfaceAnimation={None:"None",Normal:"Normal",Full:"Full"},Ab.Layout={NoPreview:0,SidePreview:1,BottomPreview:2},Ab.ContactScopeType={Default:0,ShareAll:2},Ab.SignedVerifyStatus={UnknownPublicKeys:-4,UnknownPrivateKey:-3,Unverified:-2,Error:-1,None:0,Success:1},Ab.ContactPropertyType={Unknown:0,FullName:10,FirstName:15,LastName:16,MiddleName:16,Nick:18,NamePrefix:20,NameSuffix:21,EmailPersonal:30,EmailBussines:31,PhonePersonal:50,PhoneBussines:51,MobilePersonal:60,MobileBussines:61,FaxPesonal:70,FaxBussines:71,Facebook:90,Skype:91,GitHub:92,Note:110,Custom:250},Ab.Notification={InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,AccountNotAllowed:110,AccountTwoFactorAuthRequired:120,AccountTwoFactorAuthError:121,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantCopyMessage:205,CantSaveMessage:301,CantSendMessage:302,InvalidRecipients:303,CantCreateFolder:400,CantRenameFolder:401,CantDeleteFolder:402,CantSubscribeFolder:403,CantUnsubscribeFolder:404,CantDeleteNonEmptyFolder:405,CantSaveSettings:501,CantSavePluginSettings:502,DomainAlreadyExists:601,CantInstallPackage:701,CantDeletePackage:702,InvalidPluginPackage:703,UnsupportedPluginPackage:704,LicensingServerIsUnavailable:710,LicensingExpired:711,LicensingBanned:712,DemoSendMessageError:750,AccountAlreadyExists:801,MailServerError:901,ClientViewError:902,UnknownNotification:999,UnknownError:999},Cb.trim=b.trim,Cb.inArray=b.inArray,Cb.isArray=h.isArray,Cb.isFunc=h.isFunction,Cb.isUnd=h.isUndefined,Cb.isNull=h.isNull,Cb.emptyFunction=function(){},Cb.isNormal=function(a){return!Cb.isUnd(a)&&!Cb.isNull(a)},Cb.windowResize=h.debounce(function(b){Cb.isUnd(b)?Lb.resize():a.setTimeout(function(){Lb.resize()},b)},50),Cb.isPosNumeric=function(a,b){return Cb.isNormal(a)?(Cb.isUnd(b)?0:!b)?/^[1-9]+[0-9]*$/.test(a.toString()):/^[0-9]*$/.test(a.toString()):!1},Cb.pInt=function(b){return Cb.isNormal(b)&&""!==b?a.parseInt(b,10):0},Cb.pString=function(a){return Cb.isNormal(a)?""+a:""},Cb.isNonEmptyArray=function(a){return Cb.isArray(a)&&0<a.length},Cb.exportPath=function(b,c,d){for(var e=null,f=b.split("."),g=d||a;f.length&&(e=f.shift());)f.length||Cb.isUnd(c)?g=g[e]?g[e]:g[e]={}:g[e]=c},Cb.pImport=function(a,b,c){a[b]=c},Cb.pExport=function(a,b,c){return Cb.isUnd(a[b])?c:a[b]},Cb.encodeHtml=function(a){return Cb.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},Cb.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=Cb.isUnd(b)?100:b;e.length>b;)d=e.substring(0,b),f=d.lastIndexOf(" "),g=d.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),c+=d.substring(0,f)+"\n",e=e.substring(f+1);return c+e},Cb.timeOutAction=function(){var b={};return function(c,d,e){Cb.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),Cb.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),Cb.audio=function(){var b=!1;return function(c,d){if(!1===b)if(Fb.bIsiOSDevice)b=null;else{var e=!1,f=!1,g=a.Audio?new a.Audio:null;g&&g.canPlayType&&g.play?(e=""!==g.canPlayType('audio/mpeg; codecs="mp3"'),e||(f=""!==g.canPlayType('audio/ogg; codecs="vorbis"')),e||f?(b=g,b.preload="none",b.loop=!1,b.autoplay=!1,b.muted=!1,b.src=e?c:d):b=null):b=null}return b}}(),Cb.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},Cb.i18n=function(a,b,c){var d="",e=Cb.isUnd(Jb[a])?Cb.isUnd(c)?a:c:Jb[a];if(!Cb.isUnd(b)&&!Cb.isNull(b))for(d in b)Cb.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},Cb.i18nToNode=function(a){h.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(Cb.i18n(c)):(c=a.data("i18n-html"),c&&a.html(Cb.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",Cb.i18n(c)),c=a.data("i18n-title"),c&&a.attr("title",Cb.i18n(c)))})})},Cb.i18nToDoc=function(){a.rainloopI18N&&(Jb=a.rainloopI18N||{},Cb.i18nToNode(Mb),Fb.langChangeTrigger(!Fb.langChangeTrigger())),a.rainloopI18N={}},Cb.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?Fb.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&Fb.langChangeTrigger.subscribe(a,b)},Cb.inFocus=function(){var a=document.activeElement;return a&&("INPUT"===a.tagName||"TEXTAREA"===a.tagName||"IFRAME"===a.tagName||"DIV"===a.tagName&&"editorHtmlArea"===a.className&&a.contentEditable)},Cb.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},Cb.removeSelection=function(){if(a&&a.getSelection){var b=a.getSelection();b&&b.removeAllRanges&&b.removeAllRanges()}else document&&document.selection&&document.selection.empty&&document.selection.empty()},Cb.replySubjectAdd=function(b,c,d){var e=null,f=Cb.trim(c);return f=null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||Cb.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||Cb.isUnd(e[1])||Cb.isUnd(e[2])||Cb.isUnd(e[3])?b+": "+c:e[1]+(Cb.pInt(e[2])+1)+e[3]:b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),f=(Cb.isUnd(d)?!0:d)?Cb.fixLongSubject(f):f},Cb.fixLongSubject=function(a){var b=0,c=null;a=Cb.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||Cb.isUnd(c[0]))&&(c=null),c&&(b=0,b+=Cb.isUnd(c[2])?1:0+Cb.pInt(c[2]),b+=Cb.isUnd(c[4])?1:0+Cb.pInt(c[4]),a=a.replace(/^Re(\[[\d]+\]|):[\s]{0,3}Re(\[[\d]+\]|):/gi,"Re"+(b>0?"["+b+"]":"")+":"));while(c);return a=a.replace(/[\s]+/," ")},Cb.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},Cb.friendlySize=function(a){return a=Cb.pInt(a),a>=1073741824?Cb.roundNumber(a/1073741824,1)+"GB":a>=1048576?Cb.roundNumber(a/1048576,1)+"MB":a>=1024?Cb.roundNumber(a/1024,0)+"KB":a+"B"},Cb.log=function(b){a.console&&a.console.log&&a.console.log(b)},Cb.getNotification=function(a,b){return a=Cb.pInt(a),Ab.Notification.ClientViewError===a&&b?b:Cb.isUnd(Bb[a])?"":Bb[a]},Cb.initNotificationLanguage=function(){Bb[Ab.Notification.InvalidToken]=Cb.i18n("NOTIFICATIONS/INVALID_TOKEN"),Bb[Ab.Notification.AuthError]=Cb.i18n("NOTIFICATIONS/AUTH_ERROR"),Bb[Ab.Notification.AccessError]=Cb.i18n("NOTIFICATIONS/ACCESS_ERROR"),Bb[Ab.Notification.ConnectionError]=Cb.i18n("NOTIFICATIONS/CONNECTION_ERROR"),Bb[Ab.Notification.CaptchaError]=Cb.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),Bb[Ab.Notification.SocialFacebookLoginAccessDisable]=Cb.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),Bb[Ab.Notification.SocialTwitterLoginAccessDisable]=Cb.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),Bb[Ab.Notification.SocialGoogleLoginAccessDisable]=Cb.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),Bb[Ab.Notification.DomainNotAllowed]=Cb.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),Bb[Ab.Notification.AccountNotAllowed]=Cb.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),Bb[Ab.Notification.AccountTwoFactorAuthRequired]=Cb.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),Bb[Ab.Notification.AccountTwoFactorAuthError]=Cb.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),Bb[Ab.Notification.CantGetMessageList]=Cb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),Bb[Ab.Notification.CantGetMessage]=Cb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),Bb[Ab.Notification.CantDeleteMessage]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),Bb[Ab.Notification.CantMoveMessage]=Cb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),Bb[Ab.Notification.CantCopyMessage]=Cb.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),Bb[Ab.Notification.CantSaveMessage]=Cb.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),Bb[Ab.Notification.CantSendMessage]=Cb.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),Bb[Ab.Notification.InvalidRecipients]=Cb.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),Bb[Ab.Notification.CantCreateFolder]=Cb.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),Bb[Ab.Notification.CantRenameFolder]=Cb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),Bb[Ab.Notification.CantDeleteFolder]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),Bb[Ab.Notification.CantDeleteNonEmptyFolder]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),Bb[Ab.Notification.CantSubscribeFolder]=Cb.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),Bb[Ab.Notification.CantUnsubscribeFolder]=Cb.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),Bb[Ab.Notification.CantSaveSettings]=Cb.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),Bb[Ab.Notification.CantSavePluginSettings]=Cb.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),Bb[Ab.Notification.DomainAlreadyExists]=Cb.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),Bb[Ab.Notification.CantInstallPackage]=Cb.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),Bb[Ab.Notification.CantDeletePackage]=Cb.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),Bb[Ab.Notification.InvalidPluginPackage]=Cb.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),Bb[Ab.Notification.UnsupportedPluginPackage]=Cb.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),Bb[Ab.Notification.LicensingServerIsUnavailable]=Cb.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),Bb[Ab.Notification.LicensingExpired]=Cb.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),Bb[Ab.Notification.LicensingBanned]=Cb.i18n("NOTIFICATIONS/LICENSING_BANNED"),Bb[Ab.Notification.DemoSendMessageError]=Cb.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),Bb[Ab.Notification.AccountAlreadyExists]=Cb.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),Bb[Ab.Notification.MailServerError]=Cb.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),Bb[Ab.Notification.UnknownNotification]=Cb.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),Bb[Ab.Notification.UnknownError]=Cb.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},Cb.getUploadErrorDescByCode=function(a){var b="";switch(Cb.pInt(a)){case Ab.UploadErrorCode.FileIsTooBig:b=Cb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case Ab.UploadErrorCode.FilePartiallyUploaded:b=Cb.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case Ab.UploadErrorCode.FileNoUploaded:b=Cb.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case Ab.UploadErrorCode.MissingTempFolder:b=Cb.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case Ab.UploadErrorCode.FileOnSaveingError:b=Cb.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case Ab.UploadErrorCode.FileType:b=Cb.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=Cb.i18n("UPLOAD/ERROR_UNKNOWN")}return b},Cb.delegateRun=function(a,b,c,d){a&&a[b]&&(d=Cb.pInt(d),0>=d?a[b].apply(a,Cb.isArray(c)?c:[]):h.delay(function(){a[b].apply(a,Cb.isArray(c)?c:[])},d))},Cb.killCtrlAandS=function(b){if(b=b||a.event,b&&b.ctrlKey&&!b.shiftKey&&!b.altKey){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(d===Ab.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;d===Ab.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},Cb.createCommand=function(a,b,d){var e=b?function(){return e.canExecute&&e.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments)),!1}:function(){};return e.enabled=c.observable(!0),d=Cb.isUnd(d)?!0:d,e.canExecute=Cb.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},Cb.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(Ab.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(Ab.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),Fb.sAnimationType=Ab.InterfaceAnimation.Full,b.allowThemes=c.observable(!0),b.allowCustomLogin=c.observable(!1),b.allowLanguagesOnSettings=c.observable(!0),b.allowLanguagesOnLogin=c.observable(!0),b.desktopNotifications=c.observable(!1),b.useThreads=c.observable(!0),b.replySameFolder=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.layout=c.observable(Ab.Layout.SidePreview),b.usePreviewPane=c.computed(function(){return Ab.Layout.NoPreview!==b.layout()}),b.interfaceAnimation.subscribe(function(a){if(Fb.bMobileDevice||a===Ab.InterfaceAnimation.None)Kb.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),Fb.sAnimationType=Ab.InterfaceAnimation.None;else switch(a){case Ab.InterfaceAnimation.Full:Kb.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),Fb.sAnimationType=a;break;case Ab.InterfaceAnimation.Normal:Kb.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),Fb.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=Ab.DesktopNotifications.NotSupported;if(Nb&&Nb.permission)switch(Nb.permission.toLowerCase()){case"granted":c=Ab.DesktopNotifications.Allowed;break;case"denied":c=Ab.DesktopNotifications.Denied;break;case"default":c=Ab.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&Ab.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();Ab.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):Ab.DesktopNotifications.NotAllowed===c?Nb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),Ab.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()?b.desktopNotifications()?b.desktopNotifications.valueHasMutated():b.desktopNotifications(!0):b.desktopNotifications()?b.desktopNotifications(!1):b.desktopNotifications.valueHasMutated()}):b.desktopNotifications(!1)}else b.desktopNotifications(!1)}}),b.language=c.observable(""),b.languages=c.observableArray([]),b.mainLanguage=c.computed({read:b.language,write:function(a){a!==b.language()?-1<Cb.inArray(a,b.languages())?b.language(a):0<b.languages().length&&b.language(b.languages()[0]):b.language.valueHasMutated()}}),b.theme=c.observable(""),b.themes=c.observableArray([]),b.mainTheme=c.computed({read:b.theme,write:function(a){if(a!==b.theme()){var c=b.themes();-1<Cb.inArray(a,c)?b.theme(a):0<c.length&&b.theme(c[0])}else b.theme.valueHasMutated()}}),b.allowCustomTheme=c.observable(!1),b.allowAdditionalAccounts=c.observable(!1),b.allowIdentities=c.observable(!1),b.determineUserLanguage=c.observable(!1),b.messagesPerPage=c.observable(zb.Defaults.MessagesPerPage),b.mainMessagesPerPage=b.messagesPerPage,b.mainMessagesPerPage=c.computed({read:b.messagesPerPage,write:function(a){-1<Cb.inArray(Cb.pInt(a),zb.Defaults.MessagesPerPageArray)?a!==b.messagesPerPage()&&b.messagesPerPage(a):b.messagesPerPage.valueHasMutated()}}),b.facebookEnable=c.observable(!1),b.facebookAppID=c.observable(""),b.facebookAppSecret=c.observable(""),b.twitterEnable=c.observable(!1),b.twitterConsumerKey=c.observable(""),b.twitterConsumerSecret=c.observable(""),b.googleEnable=c.observable(!1),b.googleClientID=c.observable(""),b.googleClientSecret=c.observable(""),b.dropboxEnable=c.observable(!1),b.dropboxApiKey=c.observable(""),b.contactsIsAllowed=c.observable(!1)},Cb.createMomentDate=function(a){return Cb.isUnd(a.moment)&&(a.moment=c.observable(f())),c.computed(function(){return Fb.momentTrigger(),this.moment().fromNow()},a)},Cb.createMomentShortDate=function(a){return c.computed(function(){var a="",b=f(),c=this.moment(),d=this.momentDate();return a=4>=b.diff(c,"hours")?d:b.format("L")===c.format("L")?Cb.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?Cb.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},Cb.isFolderExpanded=function(a){var b=Ob.local().get(Ab.ClientSideKeyName.ExpandedFolders);return h.isArray(b)&&-1!==h.indexOf(b,a)},Cb.setExpandedFolder=function(a,b){var c=Ob.local().get(Ab.ClientSideKeyName.ExpandedFolders);h.isArray(c)||(c=[]),b?(c.push(a),c=h.uniq(c)):c=h.without(c,a),Ob.local().set(Ab.ClientSideKeyName.ExpandedFolders,c)},Cb.initLayoutResizer=function(a,c,d){var e=b(a),f=b(c),g=Ob.local().get(d)||null,h=function(a,b){b&&b.size&&b.size.width&&(Ob.local().set(d,b.size.width),f.css({left:""+b.size.width+"px"}))};null!==g&&(e.css({width:""+g+"px"}),f.css({left:""+g+"px"})),e.resizable({helper:"ui-resizable-helper",minWidth:120,maxWidth:400,handles:"e",stop:h})},Cb.initBlockquoteSwitcher=function(a){if(a){var c=b("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===b(this).parent().closest("blockquote",a).length});c&&0<c.length&&c.each(function(){var a=b(this),c=a.height();(0===c||c>100)&&(a.addClass("rl-bq-switcher hidden-bq"),b('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>').insertBefore(a).click(function(){a.toggleClass("hidden-bq"),Cb.windowResize()}).after("<br />").before("<br />"))})}},Cb.removeBlockquoteSwitcher=function(a){a&&(b(a).find("blockquote.rl-bq-switcher").each(function(){b(this).removeClass("rl-bq-switcher hidden-bq")}),b(a).find(".rlBlockquoteSwitcher").each(function(){b(this).remove()}))},Cb.toggleMessageBlockquote=function(a){a&&a.find(".rlBlockquoteSwitcher").click()},Cb.extendAsViewModel=function(a,b,c){b&&(c||(c=s),b.__name=a,Db.regViewModelHook(a,b),h.extend(b.prototype,c.prototype))},Cb.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},Gb.settings.push(a)},Cb.removeSettingsViewModel=function(a){Gb["settings-removed"].push(a)},Cb.disableSettingsViewModel=function(a){Gb["settings-disabled"].push(a)},Cb.convertThemeName=function(a){return Cb.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},Cb.quoteName=function(a){return a.replace(/["]/g,'\\"')},Cb.microtime=function(){return(new Date).getTime()},Cb.convertLangName=function(a,b){return Cb.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},Cb.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=Cb.isUnd(a)?32:Cb.pInt(a);b.length<a;)b+=c.substr(Math.round(Math.random()*c.length),1);return b},Cb.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},Cb.draggeblePlace=function(){return b('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-mail icon-white"></i></div>').appendTo("#rl-hidden")},Cb.defautOptionsAfterRender=function(a,b){b&&!Cb.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},Cb.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+Cb.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")),Cb.i18nToNode(d),u.prototype.applyExternal(c,b("#rl-content",d)[0]),a[i]=null,f(h)}},h.document.open(),h.document.write('<html><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><meta name="viewport" content="user-scalable=no" /><meta name="apple-mobile-web-app-capable" content="yes" /><meta name="robots" content="noindex, nofollow, noodp" /><title>'+Cb.encodeHtml(e)+'</title></head><body><div id="rl-content"></div></body></html>'),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)},Cb.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=Cb.isUnd(d)?1e3:Cb.pInt(d),function(e,f,g,i,j){b.call(c,f&&f.Result?Ab.SaveSettingsStep.TrueResult:Ab.SaveSettingsStep.FalseResult),a&&a.call(c,e,f,g,i,j),h.delay(function(){b.call(c,Ab.SaveSettingsStep.Idle)},d)}},Cb.settingsSaveHelperSimpleFunction=function(a,b){return Cb.settingsSaveHelperFunction(null,a,b,1e3)},Cb.htmlToPlain=function(a){var c="",d="> ",e=function(){if(arguments&&1<arguments.length){var a=b.trim(arguments[1]).replace(/__bq__start__(.|[\s\S\n\r]*)__bq__end__/gm,e);return a="\n"+d+b.trim(a).replace(/\n/gm,"\n"+d)+"\n>\n",a.replace(/\n([> ]+)/gm,function(){return arguments&&1<arguments.length?"\n"+b.trim(arguments[1].replace(/[\s]/,""))+" ":""})}return""},f=function(){if(arguments&&1<arguments.length){var a=b.trim(arguments[1]);return 0<a.length&&(a=a.replace(/<div[^>]*>(.|[\s\S\r\n]*)<\/div>/gim,f),a="\n"+b.trim(a)+"\n"),a}return""},g=function(){return arguments&&1<arguments.length?""+arguments[1]+arguments[2].replace(/</g,"&lt;").replace(/>/g,"&gt;"):""},h=function(){if(arguments&&1<arguments.length){var a=b.trim(arguments[1]);return a}return""};return c=a.replace(/[\s]+/gm," ").replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gim,g).replace(/<br\s?\/?>/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(/<hr[^>]*>/gim,"\n_______________________________\n\n").replace(/<img [^>]*>/gim,"").replace(/<div[^>]*>(.|[\s\S\r\n]*)<\/div>/gim,f).replace(/<blockquote[^>]*>/gim,"\n__bq__start__\n").replace(/<\/blockquote>/gim,"\n__bq__end__\n").replace(/<a [^>]*>(.|[\s\S\r\n]*)<\/a>/gim,h).replace(/&nbsp;/gi," ").replace(/<[^>]*>/gm,"").replace(/&gt;/gi,">").replace(/&lt;/gi,"<").replace(/&amp;/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,"")},Cb.plainToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},Cb.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},Cb.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:Cb.isUnd(c)?a.toString():c.toString(),custom:Cb.isUnd(c)?!1:!0,title:Cb.isUnd(c)?"":a.toString(),value:a.toString()};(Cb.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}},Cb.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()}},Cb.disableKeyFilter=function(){a.key&&(j.filter=function(){return!0})},Cb.restoreKeyFilter=function(){a.key&&(j.filter=function(a){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)})},Eb={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return Eb.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=Eb._utf8_encode(a);j<a.length;)b=a.charCodeAt(j++),c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=b>>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<a.length;)e=this._keyStr.indexOf(a.charAt(j++)),f=this._keyStr.indexOf(a.charAt(j++)),g=this._keyStr.indexOf(a.charAt(j++)),h=this._keyStr.indexOf(a.charAt(j++)),b=e<<2|f>>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 Eb._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;c<a.length;)d=a.charCodeAt(c),128>d?(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(!Fb.bMobileDevice){var e=b(a).data("tooltip-class")||"",f=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:f,trigger:"hover",title:function(){return'<span class="tooltip-class '+e+'">'+Cb.i18n(c.utils.unwrapObservable(d()))+"</span>"}})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a).data("tooltip-class")||"",e=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:e,title:function(){return'<span class="tooltip-class '+d+'">'+c()()+"</span>"}})}},c.bindingHandlers.dropdown={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&&!Cb.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&&!Cb.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.modal={init:function(a,d){b(a).toggleClass("fade",!Fb.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("hidden",function(){d()(!1)}).on("shown",function(){Cb.windowResize()})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){Cb.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),Cb.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=Cb.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=Cb.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(!Fb.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),Cb.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),Cb.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(){Cb.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Fb.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){Fb.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('&nbsp;&nbsp;<i class="icon-spinner animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>').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=Cb.trim(a),c=null;return""!==b?(c=new v,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(Cb.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},Cb.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=Cb.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=Cb.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),Cb.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 Cb.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=Cb.isNormal(b)?Cb.pInt(b):1,c=Cb.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.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.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+"/":"")},Db.oViewModelsHooks={},Db.oSimpleHooks={},Db.regViewModelHook=function(a,b){b&&(b.__hookName=a)},Db.addHook=function(a,b){Cb.isFunc(b)&&(Cb.isArray(Db.oSimpleHooks[a])||(Db.oSimpleHooks[a]=[]),Db.oSimpleHooks[a].push(b))},Db.runHook=function(a,b){Cb.isArray(Db.oSimpleHooks[a])&&(b=b||[],h.each(Db.oSimpleHooks[a],function(a){a.apply(null,b)}))},Db.mainSettingsGet=function(a){return Ob?Ob.settingsGet(a):null},Db.remoteRequest=function(a,b,c,d,e,f){Ob&&Ob.remote().defaultRequest(a,b,c,d,e,f)},Db.settingsGet=function(a,b){var c=Db.mainSettingsGet("Plugins");return c=c&&Cb.isUnd(c[a])?null:c[a],c?Cb.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=Fb.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=Fb.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.selectItemCallbacks=function(a){(this.oCallbacks.onItemSelect||this.emptyFunction)(a)},m.prototype.goDown=function(a){this.newSelectPosition(Ab.EventKeyCode.Down,!1,a)},m.prototype.goUp=function(a){this.newSelectPosition(Ab.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,!0)}).on("click",this.sItemCheckedSelector,function(a){var b=c.dataFor(this);b&&(a&&a.shiftKey?f.actionClick(b,a):(f.sLastUid=f.getItemUid(b),b.checked(!b.checked())))}),j("enter",e,function(){return f.bAutoSelect?void 0:(f.focusedItem()&&f.actionClick(f.focusedItem()),!1)}),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=Ab.EventKeyCode.Up;break;case"down":case"shift+down":c=Ab.EventKeyCode.Down;break;case"insert":c=Ab.EventKeyCode.Insert;break;case"space":c=Ab.EventKeyCode.Space;break;case"home":c=Ab.EventKeyCode.Home;break;case"end":c=Ab.EventKeyCode.End;break;case"pageup":c=Ab.EventKeyCode.PageUp;break;case"pagedown":c=Ab.EventKeyCode.PageDown}if(c>0)return f.newSelectPosition(c,j.shift),!1}})}},m.prototype.useKeyboard=function(a){this.bUseKeyboard=!!a},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(b,c,d){var e=this,f=0,g=10,i=!1,j=!1,k=null,l=this.list(),m=l?l.length:0,n=this.focusedItem();if(m>0)if(n){if(n)if(Ab.EventKeyCode.Down===b||Ab.EventKeyCode.Up===b||Ab.EventKeyCode.Insert===b||Ab.EventKeyCode.Space===b)h.each(l,function(a){if(!j)switch(b){case Ab.EventKeyCode.Up:n===a?j=!0:k=a;break;case Ab.EventKeyCode.Down:case Ab.EventKeyCode.Insert:i?(k=a,j=!0):n===a&&(i=!0)}});else if(Ab.EventKeyCode.Home===b||Ab.EventKeyCode.End===b)Ab.EventKeyCode.Home===b?k=l[0]:Ab.EventKeyCode.End===b&&(k=l[l.length-1]);else if(Ab.EventKeyCode.PageDown===b){for(;m>f;f++)if(n===l[f]){f+=g,f=f>m-1?m-1:f,k=l[f];break}}else if(Ab.EventKeyCode.PageUp===b)for(f=m;f>=0;f--)if(n===l[f]){f-=g,f=0>f?0:f,k=l[f];break}}else Ab.EventKeyCode.Down===b||Ab.EventKeyCode.Insert===b||Ab.EventKeyCode.Space===b||Ab.EventKeyCode.Home===b||Ab.EventKeyCode.PageUp===b?k=l[0]:(Ab.EventKeyCode.Up===b||Ab.EventKeyCode.End===b||Ab.EventKeyCode.PageDown===b)&&(k=l[l.length-1]);k?(n&&(c?(Ab.EventKeyCode.Up===b||Ab.EventKeyCode.Down===b)&&n.checked(!n.checked()):(Ab.EventKeyCode.Insert===b||Ab.EventKeyCode.Space===b)&&n.checked(!n.checked())),this.focusedItem(k),!this.bAutoSelect&&!d||this.isListChecked()||Ab.EventKeyCode.Space===b||(a.clearTimeout(this.iSelectTimer),this.iSelectTimer=a.setTimeout(function(){e.iSelectTimer=0,e.actionClick(k)},300)),this.scrollToFocused()):n&&(!c||Ab.EventKeyCode.Up!==b&&Ab.EventKeyCode.Down!==b?(Ab.EventKeyCode.Insert===b||Ab.EventKeyCode.Space===b)&&n.checked(!n.checked()):n.checked(!n.checked()))},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)?(d.top<0?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-a):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+d.top-e+f+a),!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?(c=!1,""===this.sLastUid&&(this.sLastUid=d),a.checked(!a.checked()),this.eventClickFunction(a,b)):b.ctrlKey&&(c=!1,this.sLastUid=d,a.checked(!a.checked()))),c&&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(zb.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(zb.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},n.prototype.get=function(a){var c=b.cookie(zb.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Cb.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[zb.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[zb.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},o.prototype.get=function(b){var c=a.localStorage[zb.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!Cb.isUnd(d[b])?d[b]:null}catch(e){}return d},p.prototype.item="armoredRainLoopKeys",p.prototype.load=function(){var b=0,c=0,d=[],e=JSON.parse(a.localStorage.getItem(this.item));if(e&&0<e.length)for(c=e.length;c>b;b++)d.push(a.openpgp.key.readArmored(e[b]).keys[0]);return d},p.prototype.store=function(b){for(var c=0,d=b.length,e=[];d>c;c++)e.push(b[c].armor());a.localStorage.setItem(this.item,JSON.stringify(e))},q.prototype.oDriver=null,q.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},q.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},r.prototype.bootstart=function(){},s.prototype.sPosition="",s.prototype.sTemplate="",s.prototype.viewModelName="",s.prototype.viewModelDom=null,s.prototype.viewModelTemplate=function(){return this.sTemplate},s.prototype.viewModelPosition=function(){return this.sPosition},s.prototype.cancelCommand=s.prototype.closeCommand=function(){},s.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=Ob.data().keyScope(),Ob.data().keyScope(this.sDefaultKeyScope)},s.prototype.restoreKeyScope=function(){Ob.data().keyScope(this.sCurrentKeyScope)},s.prototype.registerPopupEscapeKey=function(){var a=this;Lb.on("keydown",function(b){return b&&Ab.EventKeyCode.Esc===b.keyCode&&a.modalVisibility&&a.modalVisibility()?(Cb.delegateRun(a,"cancelCommand"),!1):!0})},t.prototype.oCross=null,t.prototype.sScreenName="",t.prototype.aViewModels=[],t.prototype.viewModels=function(){return this.aViewModels},t.prototype.screenName=function(){return this.sScreenName},t.prototype.routes=function(){return null},t.prototype.__cross=function(){return this.oCross},t.prototype.__start=function(){var a=this.routes(),b=null,c=null;Cb.isNonEmptyArray(a)&&(c=h.bind(this.onRoute||Cb.emptyFunction,this),b=d.create(),h.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},u.constructorEnd=function(a){Cb.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},u.prototype.sDefaultScreenName="",u.prototype.oScreens={},u.prototype.oBoot=null,u.prototype.oCurrentScreen=null,u.prototype.hideLoading=function(){b("#rl-loading").hide()},u.prototype.routeOff=function(){e.changed.active=!1},u.prototype.routeOn=function(){e.changed.active=!0},u.prototype.setBoot=function(a){return Cb.isNormal(a)&&(this.oBoot=a),this},u.prototype.screen=function(a){return""===a||Cb.isUnd(this.oScreens[a])?null:this.oScreens[a]},u.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),h=null;a.__builded=!0,a.__vm=e,e.data=Ob.data(),e.viewModelName=a.__name,g&&1===g.length?(h=b("<div>").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),h.appendTo(g),e.viewModelDom=h,a.__dom=h,"Popups"===f&&(e.cancelCommand=e.closeCommand=Cb.createCommand(e,function(){Hb.hideScreenPopup(a)})),Db.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),Cb.delegateRun(e,"onBuild",[h]),e&&"Popups"===f&&!e.bDisabeCloseOnEsc&&e.registerPopupEscapeKey(),Db.runHook("view-model-post-build",[a.__name,e,h])):Cb.log("Cannot find view model position: "+f)}return a?a.__vm:null},u.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},u.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__vm.modalVisibility(!1),Cb.delegateRun(a.__vm,"onHide"),a.__vm.restoreKeyScope(),Ob.popupVisibilityNames.remove(a.__name),Db.runHook("view-model-on-hide",[a.__name,a.__vm]),h.delay(function(){a.__dom.hide()},300))},u.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),Cb.delegateRun(a.__vm,"onShow",b||[]),a.__vm.storeAndSetKeyScope(),Ob.popupVisibilityNames.push(a.__name),Db.runHook("view-model-on-show",[a.__name,a.__vm,b||[]]),Cb.delegateRun(a.__vm,"onFocus",[],500)))},u.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===Cb.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,Cb.isNonEmptyArray(d.viewModels())&&h.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),Cb.delegateRun(d,"onBuild")),h.defer(function(){c.oCurrentScreen&&(Cb.delegateRun(c.oCurrentScreen,"onHide"),Cb.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),Cb.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(Cb.delegateRun(c.oCurrentScreen,"onShow"),Db.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),Cb.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),Cb.delegateRun(a.__vm,"onShow"),Cb.delegateRun(a.__vm,"onFocus",[],200),Db.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},u.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(),Db.runHook("screen-pre-start",[a.screenName(),a]),Cb.delegateRun(a,"onStart"),Db.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)},u.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=Cb.isUnd(c)?!1:!!c,(Cb.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)},u.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},Hb=new u,v.newInstanceFromJson=function(a){var b=new v;return b.initByJson(a)?b:null},v.prototype.name="",v.prototype.email="",v.prototype.privateType=null,v.prototype.clear=function(){this.email="",this.name="",this.privateType=null},v.prototype.validate=function(){return""!==this.name||""!==this.email},v.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},v.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},v.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=Ab.EmailType.Facebook),null===this.privateType&&(this.privateType=Ab.EmailType.Default)),this.privateType},v.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},v.prototype.parse=function(a){this.clear(),a=Cb.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)},v.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=Cb.trim(a.Name),this.email=Cb.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},v.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=Cb.isUnd(b)?!1:!!b,c=Cb.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'<a href="mailto:'+Cb.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+Cb.encodeHtml(this.name)+"</a>":c?Cb.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=Cb.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+Cb.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+Cb.encodeHtml(d)+"</a>"+Cb.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=Cb.encodeHtml(d))):b&&(d='<a href="mailto:'+Cb.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+Cb.encodeHtml(this.email)+"</a>"))),d},v.prototype.mailsoParse=function(a){if(a=Cb.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;m<a.length;){switch(a.substr(m,1)){case'"':g||h||i?h||i||(l=m,d=b(a,k+1,l-k-1),a=c(a,"",k,l-k+1),l=0,m=0,k=0,g=!1):(g=!0,k=m);break;case"<":g||h||i||(m>0&&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=Cb.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=Cb.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=Cb.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},v.prototype.inputoTagLine=function(){return 0<this.name.length?this.name+" ("+this.email+")":this.email},w.prototype.getNameAndEmailHelper=function(){var a="",b="";return Cb.isNonEmptyArray(this.properties)&&h.each(this.properties,function(c){c&&(""===a&&Ab.ContactPropertyType.FullName===c[0]?a=c[1]:""===b&&-1<Cb.inArray(c[0],[Ab.ContactPropertyType.EmailPersonal,Ab.ContactPropertyType.EmailBussines,Ab.ContactPropertyType.EmailOther])&&(b=c[1]))},this),""===b?null:[b,a]},w.prototype.parse=function(a){var b=!1;return a&&"Object/Contact"===a["@Object"]&&(this.idContact=Cb.pInt(a.IdContact),this.idContactStr=Cb.pString(a.IdContactStr),this.display=Cb.pString(a.Display),this.readOnly=!!a.ReadOnly,this.scopeType=Cb.pInt(a.ScopeType),Cb.isNonEmptyArray(a.Properties)&&h.each(a.Properties,function(a){a&&a.Type&&Cb.isNormal(a.Value)&&this.properties.push([Cb.pInt(a.Type),Cb.pString(a.Value)])},this),this.shared(Ab.ContactScopeType.ShareAll===this.scopeType),b=!0),b},w.prototype.srcAttr=function(){return Ob.link().emptyContactPic()},w.prototype.generateUid=function(){return""+this.idContact},w.prototype.lineAsCcc=function(){var a=[];return this.deleted()&&a.push("deleted"),this.selected()&&a.push("selected"),this.checked()&&a.push("checked"),this.shared()&&a.push("shared"),this.focused()&&a.push("focused"),a.join(" ")},y.newInstanceFromJson=function(a){var b=new y;return b.initByJson(a)?b:null},y.prototype.mimeType="",y.prototype.fileName="",y.prototype.estimatedSize=0,y.prototype.friendlySize="",y.prototype.isInline=!1,y.prototype.isLinked=!1,y.prototype.cid="",y.prototype.cidWithOutTags="",y.prototype.contentLocation="",y.prototype.download="",y.prototype.folder="",y.prototype.uid="",y.prototype.mimeIndex="",y.prototype.initByJson=function(a){var b=!1;return a&&"Object/Attachment"===a["@Object"]&&(this.mimeType=(a.MimeType||"").toLowerCase(),this.fileName=a.FileName,this.estimatedSize=Cb.pInt(a.EstimatedSize),this.isInline=!!a.IsInline,this.isLinked=!!a.IsLinked,this.cid=a.CID,this.contentLocation=a.ContentLocation,this.download=a.Download,this.folder=a.Folder,this.uid=a.Uid,this.mimeIndex=a.MimeIndex,this.friendlySize=Cb.friendlySize(this.estimatedSize),this.cidWithOutTags=this.cid.replace(/^<+/,"").replace(/>+$/,""),b=!0),b},y.prototype.isImage=function(){return-1<Cb.inArray(this.mimeType.toLowerCase(),["image/png","image/jpg","image/jpeg","image/gif"])},y.prototype.isText=function(){return"text/"===this.mimeType.substr(0,5)&&-1===Cb.inArray(this.mimeType,["text/html"])},y.prototype.isPdf=function(){return Fb.bAllowPdfPreview&&"application/pdf"===this.mimeType},y.prototype.linkDownload=function(){return Ob.link().attachmentDownload(this.download)},y.prototype.linkPreview=function(){return Ob.link().attachmentPreview(this.download)},y.prototype.linkPreviewAsPlain=function(){return Ob.link().attachmentPreviewAsPlain(this.download)
},y.prototype.generateTransferDownloadUrl=function(){var b=this.linkDownload();return"http"!==b.substr(0,4)&&(b=a.location.protocol+"//"+a.location.host+a.location.pathname+b),this.mimeType+":"+this.fileName+":"+b},y.prototype.eventDragStart=function(a,b){var c=b.originalEvent||b;return a&&c&&c.dataTransfer&&c.dataTransfer.setData&&c.dataTransfer.setData("DownloadURL",this.generateTransferDownloadUrl()),!0},y.prototype.iconClass=function(){var a=this.mimeType.toLocaleString().split("/"),b="icon-file";return a&&a[1]&&("image"===a[0]?b="icon-file-image":"text"===a[0]?b="icon-file-text":"audio"===a[0]?b="icon-file-music":"video"===a[0]?b="icon-file-movie":-1<Cb.inArray(a[1],["zip","7z","tar","rar","gzip","bzip","bzip2","x-zip","x-7z","x-rar","x-tar","x-gzip","x-bzip","x-bzip2","x-zip-compressed","x-7z-compressed","x-rar-compressed"])?b="icon-file-zip":-1<Cb.inArray(a[1],["rtf","msword","vnd.msword","vnd.openxmlformats-officedocument.wordprocessingml.document","vnd.openxmlformats-officedocument.wordprocessingml.template","vnd.ms-word.document.macroEnabled.12","vnd.ms-word.template.macroEnabled.12"])?b="icon-file-text":-1<Cb.inArray(a[1],["excel","ms-excel","vnd.ms-excel","vnd.openxmlformats-officedocument.spreadsheetml.sheet","vnd.openxmlformats-officedocument.spreadsheetml.template","vnd.ms-excel.sheet.macroEnabled.12","vnd.ms-excel.template.macroEnabled.12","vnd.ms-excel.addin.macroEnabled.12","vnd.ms-excel.sheet.binary.macroEnabled.12"])?b="icon-file-excel":-1<Cb.inArray(a[1],["powerpoint","ms-powerpoint","vnd.ms-powerpoint","vnd.openxmlformats-officedocument.presentationml.presentation","vnd.openxmlformats-officedocument.presentationml.template","vnd.openxmlformats-officedocument.presentationml.slideshow","vnd.ms-powerpoint.addin.macroEnabled.12","vnd.ms-powerpoint.presentation.macroEnabled.12","vnd.ms-powerpoint.template.macroEnabled.12","vnd.ms-powerpoint.slideshow.macroEnabled.12"])&&(b="icon-file-chart-graph")),b},z.prototype.id="",z.prototype.isInline=!1,z.prototype.isLinked=!1,z.prototype.CID="",z.prototype.contentLocation="",z.prototype.fromMessage=!1,z.prototype.cancel=Cb.emptyFunction,z.prototype.initByUploadJson=function(a){var b=!1;return a&&(this.fileName(a.Name),this.size(Cb.isUnd(a.Size)?0:Cb.pInt(a.Size)),this.tempName(Cb.isUnd(a.TempName)?"":a.TempName),this.isInline=!1,b=!0),b},A.newInstanceFromJson=function(a){var b=new A;return b.initByJson(a)?b:null},A.calculateFullFromatDateValue=function(a){return f.unix(a).format("LLL")},A.emailsToLine=function(a,b,c){var d=[],e=0,f=0;if(Cb.isNonEmptyArray(a))for(e=0,f=a.length;f>e;e++)d.push(a[e].toLine(b,c));return d.join(", ")},A.initEmailsFromJson=function(a){var b=0,c=0,d=null,e=[];if(Cb.isNonEmptyArray(a))for(b=0,c=a.length;c>b;b++)d=v.newInstanceFromJson(a[b]),d&&e.push(d);return e},A.replyHelper=function(a,b,c){if(a&&0<a.length)for(var d=0,e=a.length;e>d;d++)Cb.isUnd(b[a[d].email])&&(b[a[d].email]=!0,c.push(a[d]))},A.prototype.clear=function(){this.folderFullNameRaw="",this.uid="",this.hash="",this.requestHash="",this.subject(""),this.size(0),this.dateTimeStampInUTC(0),this.priority(Ab.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(Ab.SignedVerifyStatus.None),this.pgpSignedVerifyUser(""),this.priority(Ab.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)},A.prototype.computeSenderEmail=function(){var a=Ob.data().sentFolder(),b=Ob.data().draftFolder();this.senderEmailsString(this.folderFullNameRaw===a||this.folderFullNameRaw===b?this.toEmailsString():this.fromEmailString())},A.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(Cb.pInt(a.Size)),this.from=A.initEmailsFromJson(a.From),this.to=A.initEmailsFromJson(a.To),this.cc=A.initEmailsFromJson(a.Cc),this.bcc=A.initEmailsFromJson(a.Bcc),this.replyTo=A.initEmailsFromJson(a.ReplyTo),this.subject(a.Subject),this.dateTimeStampInUTC(Cb.pInt(a.DateTimeStampInUTC)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.fromEmailString(A.emailsToLine(this.from,!0)),this.toEmailsString(A.emailsToLine(this.to,!0)),this.parentUid(Cb.pInt(a.ParentThread)),this.threads(Cb.isArray(a.Threads)?a.Threads:[]),this.threadsLen(Cb.pInt(a.ThreadsLen)),this.initFlagsByJson(a),this.computeSenderEmail(),b=!0),b},A.prototype.initUpdateByMessageJson=function(a){var b=!1,c=Ab.MessagePriority.Normal;return a&&"Object/Message"===a["@Object"]&&(c=Cb.pInt(a.Priority),this.priority(-1<Cb.inArray(c,[Ab.MessagePriority.High,Ab.MessagePriority.Low])?c:Ab.MessagePriority.Normal),this.aDraftInfo=a.DraftInfo,this.sMessageId=a.MessageId,this.sInReplyTo=a.InReplyTo,this.sReferences=a.References,Ob.data().allowOpenPGP()&&(this.isPgpSigned(!!a.PgpSigned),this.isPgpEncrypted(!!a.PgpEncrypted)),this.hasAttachments(!!a.HasAttachments),this.attachmentsMainType(a.AttachmentsMainType),this.foundedCIDs=Cb.isArray(a.FoundedCIDs)?a.FoundedCIDs:[],this.attachments(this.initAttachmentsFromJson(a.Attachments)),this.readReceipt(a.ReadReceipt||""),this.computeSenderEmail(),b=!0),b},A.prototype.initAttachmentsFromJson=function(a){var b=0,c=0,d=null,e=[];if(a&&"Collection/AttachmentCollection"===a["@Object"]&&Cb.isNonEmptyArray(a["@Collection"]))for(b=0,c=a["@Collection"].length;c>b;b++)d=y.newInstanceFromJson(a["@Collection"][b]),d&&(""!==d.cidWithOutTags&&0<this.foundedCIDs.length&&0<=Cb.inArray(d.cidWithOutTags,this.foundedCIDs)&&(d.isLinked=!0),e.push(d));return e},A.prototype.initFlagsByJson=function(a){var b=!1;return a&&"Object/Message"===a["@Object"]&&(this.unseen(!a.IsSeen),this.flagged(!!a.IsFlagged),this.answered(!!a.IsAnswered),this.forwarded(!!a.IsForwarded),this.isReadReceipt(!!a.IsReadReceipt),b=!0),b},A.prototype.fromToLine=function(a,b){return A.emailsToLine(this.from,a,b)},A.prototype.toToLine=function(a,b){return A.emailsToLine(this.to,a,b)},A.prototype.ccToLine=function(a,b){return A.emailsToLine(this.cc,a,b)},A.prototype.bccToLine=function(a,b){return A.emailsToLine(this.bcc,a,b)},A.prototype.lineAsCcc=function(){var a=[];if(this.deleted()&&a.push("deleted"),this.selected()&&a.push("selected"),this.checked()&&a.push("checked"),this.flagged()&&a.push("flagged"),this.unseen()&&a.push("unseen"),this.answered()&&a.push("answered"),this.forwarded()&&a.push("forwarded"),this.focused()&&a.push("focused"),this.hasAttachments())switch(a.push("withAttachments"),this.attachmentsMainType()){case"image":a.push("imageOnlyAttachments");break;case"archive":a.push("archiveOnlyAttachments")}return this.newForAnimation()&&a.push("new"),""===this.subject()&&a.push("emptySubject"),0<this.parentUid()&&a.push("hasParentMessage"),0<this.threadsLen()&&0===this.parentUid()&&a.push("hasChildrenMessage"),this.hasUnseenSubMessage()&&a.push("hasUnseenSubMessage"),this.hasFlaggedSubMessage()&&a.push("hasFlaggedSubMessage"),a.join(" ")},A.prototype.hasVisibleAttachments=function(){return!!h.find(this.attachments(),function(a){return!a.isLinked})},A.prototype.findAttachmentByCid=function(a){var b=null,c=this.attachments();return Cb.isNonEmptyArray(c)&&(a=a.replace(/^<+/,"").replace(/>+$/,""),b=h.find(c,function(b){return a===b.cidWithOutTags})),b||null},A.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();return Cb.isNonEmptyArray(c)&&(b=h.find(c,function(b){return a===b.contentLocation})),b||null},A.prototype.messageId=function(){return this.sMessageId},A.prototype.inReplyTo=function(){return this.sInReplyTo},A.prototype.references=function(){return this.sReferences},A.prototype.fromAsSingleEmail=function(){return Cb.isArray(this.from)&&this.from[0]?this.from[0].email:""},A.prototype.viewLink=function(){return Ob.link().messageViewLink(this.requestHash)},A.prototype.downloadLink=function(){return Ob.link().messageDownloadLink(this.requestHash)},A.prototype.replyEmails=function(a){var b=[],c=Cb.isUnd(a)?{}:a;return A.replyHelper(this.replyTo,c,b),0===b.length&&A.replyHelper(this.from,c,b),b},A.prototype.replyAllEmails=function(a){var b=[],c=[],d=Cb.isUnd(a)?{}:a;return A.replyHelper(this.replyTo,d,b),0===b.length&&A.replyHelper(this.from,d,b),A.replyHelper(this.to,d,b),A.replyHelper(this.cc,d,c),[b,c]},A.prototype.textBodyToString=function(){return this.body?this.body.html():""},A.prototype.attachmentsToStringLine=function(){var a=h.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0<a.length?a.join(", "):""},A.prototype.getDataForWindowPopup=function(){return{popupFrom:this.fromToLine(!1),popupTo:this.toToLine(!1),popupCc:this.ccToLine(!1),popupBcc:this.bccToLine(!1),popupSubject:this.subject(),popupDate:this.fullFormatDateValue(),popupAttachments:this.attachmentsToStringLine(),popupBody:this.textBodyToString()}},A.prototype.viewPopupMessage=function(c){Cb.windowPopupKnockout(this.getDataForWindowPopup(),"PopupsWindowSimpleMessage",this.subject(),function(d){d&&d.document&&d.document.body&&(b("img.lazy",d.document.body).each(function(a,c){var d=b(c),e=d.data("original"),f=d.attr("src");a>=0&&e&&!f&&d.attr("src",e)}),c&&a.setTimeout(function(){d.print()},100))})},A.prototype.printMessage=function(){this.viewPopupMessage(!0)},A.prototype.generateUid=function(){return this.folderFullNameRaw+"/"+this.uid},A.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(Ab.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},A.prototype.showExternalImages=function(a){this.body&&this.body.data("rl-has-images")&&(a=Cb.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=Cb.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()),Cb.windowResize(500))},A.prototype.showInternalImages=function(a){if(this.body&&!this.body.data("rl-init-internal-images")){this.body.data("rl-init-internal-images",!0),a=Cb.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=Cb.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]),Cb.windowResize(500)}},A.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())))},A.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()))},A.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=Cb.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(Ab.SignedVerifyStatus.None),this.pgpSignedVerifyUser("")))},A.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(Ab.SignedVerifyStatus.Error),this.pgpSignedVerifyUser("");try{d=a.openpgp.cleartext.readArmored(this.plainRaw),d&&d.getText&&(this.pgpSignedVerifyStatus(f.length?Ab.SignedVerifyStatus.Unverified:Ab.SignedVerifyStatus.UnknownPublicKeys),c=d.verify(f),c&&0<c.length&&(g=h.find(c,function(a){return a&&a.keyid&&a.valid}),g&&(i=Ob.data().findPublicKeyByHex(g.keyid.toHex()),i&&(j=d.getText(),this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.Success),this.pgpSignedVerifyUser(i.user),j=Pb.empty().append(b('<pre class="b-plain-openpgp signed verified"></pre>').text(j)).html(),Pb.empty(),this.replacePlaneTextBody(j)))))}catch(k){}this.storePgpVerifyDataToDom()}},A.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(Ab.SignedVerifyStatus.Error),this.pgpSignedVerifyUser(""),j||this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.UnknownPrivateKey);try{e=a.openpgp.message.readArmored(this.plainRaw),e&&j&&e.decrypt&&(this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.Unverified),f=e.decrypt(j),f&&(d=f.verify(i),d&&0<d.length&&(k=h.find(d,function(a){return a&&a.keyid&&a.valid}),k&&(l=Ob.data().findPublicKeyByHex(k.keyid.toHex()),l&&(this.pgpSignedVerifyStatus(Ab.SignedVerifyStatus.Success),this.pgpSignedVerifyUser(l.user)))),m=f.getText(),m=Pb.empty().append(b('<pre class="b-plain-openpgp signed verified"></pre>').text(m)).html(),Pb.empty(),this.replacePlaneTextBody(m)))}catch(n){}this.storePgpVerifyDataToDom()}},A.prototype.replacePlaneTextBody=function(a){this.body&&this.body.html(a).addClass("b-text-part plain")},A.prototype.flagHash=function(){return[this.deleted(),this.unseen(),this.flagged(),this.answered(),this.forwarded(),this.isReadReceipt()].join("")},B.newInstanceFromJson=function(a){var b=new B;return b.initByJson(a)?b.initComputed():null},B.prototype.initComputed=function(){return this.hasSubScribedSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.subScribed()})},this),this.canBeEdited=c.computed(function(){return Ab.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 Ab.FolderType.User!==this.type()},this),this.hidden=c.computed(function(){var a=this.isSystemFolder(),b=this.hasSubScribedSubfolders();return this.isGmailFolder||a&&this.isNamespaceFolder||a&&!b},this),this.selectableForFolderList=c.computed(function(){return!this.isSystemFolder()&&this.selectable},this),this.messageCountAll=c.computed({read:this.privateMessageCountAll,write:function(a){Cb.isPosNumeric(a,!0)?this.privateMessageCountAll(a):this.privateMessageCountAll.valueHasMutated()},owner:this}),this.messageCountUnread=c.computed({read:this.privateMessageCountUnread,write:function(a){Cb.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(Ab.FolderType.Inbox===c&&Ob.data().foldersInboxUnreadCount(b),a>0){if(Ab.FolderType.Draft===c)return""+a;if(b>0&&Ab.FolderType.Trash!==c&&Ab.FolderType.Archive!==c&&Ab.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(){Cb.timeOutAction("folder-list-folder-visibility-change",function(){Lb.trigger("folder-list-folder-visibility-change")},100)}),this.localName=c.computed(function(){Fb.langChangeTrigger();var a=this.type(),b=this.name();if(this.isSystemFolder())switch(a){case Ab.FolderType.Inbox:b=Cb.i18n("FOLDER_LIST/INBOX_NAME");break;case Ab.FolderType.SentItems:b=Cb.i18n("FOLDER_LIST/SENT_NAME");break;case Ab.FolderType.Draft:b=Cb.i18n("FOLDER_LIST/DRAFTS_NAME");break;case Ab.FolderType.Spam:b=Cb.i18n("FOLDER_LIST/SPAM_NAME");break;case Ab.FolderType.Trash:b=Cb.i18n("FOLDER_LIST/TRASH_NAME");break;case Ab.FolderType.Archive:b=Cb.i18n("FOLDER_LIST/ARCHIVE_NAME")}return b},this),this.manageFolderSystemName=c.computed(function(){Fb.langChangeTrigger();var a="",b=this.type(),c=this.name();if(this.isSystemFolder())switch(b){case Ab.FolderType.Inbox:a="("+Cb.i18n("FOLDER_LIST/INBOX_NAME")+")";break;case Ab.FolderType.SentItems:a="("+Cb.i18n("FOLDER_LIST/SENT_NAME")+")";break;case Ab.FolderType.Draft:a="("+Cb.i18n("FOLDER_LIST/DRAFTS_NAME")+")";break;case Ab.FolderType.Spam:a="("+Cb.i18n("FOLDER_LIST/SPAM_NAME")+")";break;case Ab.FolderType.Trash:a="("+Cb.i18n("FOLDER_LIST/TRASH_NAME")+")";break;case Ab.FolderType.Archive:a="("+Cb.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<this.messageCountUnread()},this),this.hasSubScribedUnreadMessagesSubfolders=c.computed(function(){return!!h.find(this.subFolders(),function(a){return a.hasUnreadMessages()||a.hasSubScribedUnreadMessagesSubfolders()})},this),this},B.prototype.fullName="",B.prototype.fullNameRaw="",B.prototype.fullNameHash="",B.prototype.delimiter="",B.prototype.namespace="",B.prototype.deep=0,B.prototype.interval=0,B.prototype.isNamespaceFolder=!1,B.prototype.isGmailFolder=!1,B.prototype.isUnpaddigFolder=!1,B.prototype.collapsedCss=function(){return this.hasSubScribedSubfolders()?this.collapsed()?"icon-right-mini e-collapsed-sign":"icon-down-mini e-collapsed-sign":"icon-none e-collapsed-sign"},B.prototype.initByJson=function(a){var b=!1;return a&&"Object/Folder"===a["@Object"]&&(this.name(a.Name),this.delimiter=a.Delimiter,this.fullName=a.FullName,this.fullNameRaw=a.FullNameRaw,this.fullNameHash=a.FullNameHash,this.deep=a.FullNameRaw.split(this.delimiter).length-1,this.selectable=!!a.IsSelectable,this.existen=!!a.IsExisten,this.subScribed(!!a.IsSubscribed),this.type("INBOX"===this.fullNameRaw?Ab.FolderType.Inbox:Ab.FolderType.User),b=!0),b},B.prototype.printableFullName=function(){return this.fullName.split(this.delimiter).join(" / ")},C.prototype.email="",C.prototype.changeAccountLink=function(){return Ob.link().change(this.email)},D.prototype.formattedName=function(){var a=this.name();return""===a?this.email():a+" <"+this.email()+">"},D.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"},D.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+Cb.quoteName(a)+'" <'+this.email()+">"},E.prototype.index=0,E.prototype.id="",E.prototype.guid="",E.prototype.user="",E.prototype.email="",E.prototype.armor="",E.prototype.isPrivate=!1,Cb.extendAsViewModel("PopupsFolderClearViewModel",F),F.prototype.clearPopup=function(){this.clearingProcess(!1),this.selectedFolder(null)},F.prototype.onShow=function(a){this.clearPopup(),a&&this.selectedFolder(a)},Cb.extendAsViewModel("PopupsFolderCreateViewModel",G),G.prototype.sNoParentText="",G.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(Cb.trim(a))},G.prototype.clearPopup=function(){this.folderName(""),this.selectedParentValue(""),this.folderName.focused(!1)},G.prototype.onShow=function(){this.clearPopup()},G.prototype.onFocus=function(){this.folderName.focused(!0)},Cb.extendAsViewModel("PopupsFolderSystemViewModel",H),H.prototype.sChooseOnText="",H.prototype.sUnuseText="",H.prototype.onShow=function(a){var b="";switch(a=Cb.isUnd(a)?Ab.SetSystemFoldersNotification.None:a){case Ab.SetSystemFoldersNotification.Sent:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case Ab.SetSystemFoldersNotification.Draft:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case Ab.SetSystemFoldersNotification.Spam:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case Ab.SetSystemFoldersNotification.Trash:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH");break;case Ab.SetSystemFoldersNotification.Archive:b=Cb.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_ARCHIVE")}this.notification(b)},Cb.extendAsViewModel("PopupsComposeViewModel",I),I.prototype.openOpenPgpPopup=function(){if(this.allowOpenPGP()&&this.oEditor&&!this.oEditor.isHtml()){var a=this;Hb.showScreenPopup(P,[function(b){a.editor(function(a){a.setPlain(b)})},this.oEditor.getData(),this.currentIdentityResultEmail(),this.to(),this.cc(),this.bcc()])}},I.prototype.reloadDraftFolder=function(){var a=Ob.data().draftFolder();""!==a&&(Ob.cache().setFolderHash(a,""),Ob.data().currentFolderFullNameRaw()===a?Ob.reloadMessageList(!0):Ob.folderInformation(a))},I.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 Ab.ComposeType.Empty:d=Ob.data().accountEmail();break;case Ab.ComposeType.Reply:case Ab.ComposeType.ReplyAll:case Ab.ComposeType.Forward:case Ab.ComposeType.ForwardAsAttachment:h.find(h.union(b.to,b.cc,b.bcc),e);break;case Ab.ComposeType.Draft:h.find(h.union(b.from,b.replyTo),e)}else d=Ob.data().accountEmail();return d},I.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)},I.prototype.formattedFrom=function(a){var b=Ob.data().displayName(),c=Ob.data().accountEmail();return""===b?c:(Cb.isUnd(a)?1:!a)?b+" ("+c+")":'"'+Cb.quoteName(b)+'" <'+c+">"},I.prototype.sendMessageResponse=function(b,c){var d=!1,e="";this.sending(!1),Ab.StorageResultType.Success===b&&c&&c.Result&&(d=!0,this.modalVisibility()&&Cb.delegateRun(this,"closeCommand")),this.modalVisibility()&&!d&&(c&&Ab.Notification.CantSaveMessage===c.ErrorCode?(this.sendSuccessButSaveError(!0),a.alert(Cb.trim(Cb.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(e=Cb.getNotification(c&&c.ErrorCode?c.ErrorCode:Ab.Notification.CantSendMessage,c&&c.ErrorMessage?c.ErrorMessage:""),this.sendError(!0),a.alert(e||Cb.getNotification(Ab.Notification.CantSendMessage)))),this.reloadDraftFolder()},I.prototype.saveMessageResponse=function(b,c){var d=!1,e=null;this.saving(!1),Ab.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(0<this.savedTime()?Cb.i18n("COMPOSE/SAVED_TIME",{TIME:f.unix(this.savedTime()-1).format("LT")}):""),d=!0,this.bFromDraft&&Ob.cache().setFolderHash(this.draftFolder(),""))),this.modalVisibility()||d||(this.savedError(!0),this.savedOrSendingText(Cb.getNotification(Ab.Notification.CantSaveMessage))),this.reloadDraftFolder()},I.prototype.onHide=function(){this.reset(),Hb.routeOn()},I.prototype.convertSignature=function(a,b){if(""!==a){var c=!1;":HTML:"===a.substr(0,6)&&(c=!0,a=a.substr(6)),a=a.replace(/[\r]/,""),b=Cb.pString(b),a=""!==b?a.replace(/{{FROM}}/,b):a.replace(/{{IF:FROM}}[\s\S]+{{\/IF:FROM}}[\n]?/gm,""),a=a.replace(/{{FROM}}[\n]?/,"").replace(/{{IF:FROM}}[\n]?/,"").replace(/{{\/IF:FROM}}[\n]?/,""),c||(a=Cb.convertPlainTextToHtml(a))}return a},I.prototype.editor=function(a){if(a){var b=this;!this.oEditor&&this.composeEditorArea()?h.delay(function(){b.oEditor=new l(b.composeEditorArea(),null,function(){a(b.oEditor)},function(a){b.isHtml(!!a)})},300):this.oEditor&&a(this.oEditor)}},I.prototype.onShow=function(a,c,d){Hb.routeOff();var e=this,f="",g="",i="",j="",k="",l=null,m="",n="",o=[],p={},q=Ob.data().accountEmail(),r=Ob.data().signature(),s=Ob.data().signatureToAll(),t=[],u=null,v=null,w=a||Ab.ComposeType.Empty,x=function(a,b){for(var c=0,d=a.length,e=[];d>c;c++)e.push(a[c].toLine(!!b));return e.join(", ")};if(c=c||null,c&&Cb.isNormal(c)&&(v=Cb.isArray(c)&&1===c.length?c[0]:Cb.isArray(c)?null:c),null!==q&&(p[q]=!0,this.currentIdentityID(this.findIdentityIdByMessage(w,v))),this.reset(),Cb.isNonEmptyArray(d)&&this.to(x(d)),""!==w&&v){switch(j=v.fullFormatDateValue(),k=v.subject(),u=v.aDraftInfo,l=b(v.body).clone(),Cb.removeBlockquoteSwitcher(l),m=l.html(),w){case Ab.ComposeType.Empty:break;case Ab.ComposeType.Reply:this.to(x(v.replyEmails(p))),this.subject(Cb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.sReferences);break;case Ab.ComposeType.ReplyAll:o=v.replyAllEmails(p),this.to(x(o[0])),this.cc(x(o[1])),this.subject(Cb.replySubjectAdd("Re",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["reply",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.references());break;case Ab.ComposeType.Forward:this.subject(Cb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.sReferences);break;case Ab.ComposeType.ForwardAsAttachment:this.subject(Cb.replySubjectAdd("Fwd",k)),this.prepearMessageAttachments(v,w),this.aDraftInfo=["forward",v.uid,v.folderFullNameRaw],this.sInReplyTo=v.sMessageId,this.sReferences=Cb.trim(this.sInReplyTo+" "+v.sReferences);break;case Ab.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=Cb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences;break;case Ab.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=Cb.isNonEmptyArray(u)&&3===u.length?u:null,this.sInReplyTo=v.sInReplyTo,this.sReferences=v.sReferences}switch(w){case Ab.ComposeType.Reply:case Ab.ComposeType.ReplyAll:f=v.fromToLine(!1,!0),n=Cb.i18n("COMPOSE/REPLY_MESSAGE_TITLE",{DATETIME:j,EMAIL:f}),m="<br /><br />"+n+":<blockquote><p>"+m+"</p></blockquote>";break;case Ab.ComposeType.Forward:f=v.fromToLine(!1,!0),g=v.toToLine(!1,!0),i=v.ccToLine(!1,!0),m="<br /><br /><br />"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"<br />"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+f+"<br />"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+g+(0<i.length?"<br />"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+i:"")+"<br />"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+": "+Cb.encodeHtml(j)+"<br />"+Cb.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+Cb.encodeHtml(k)+"<br /><br />"+m;break;case Ab.ComposeType.ForwardAsAttachment:m=""}s&&""!==r&&Ab.ComposeType.EditAsNew!==w&&Ab.ComposeType.Draft!==w&&(m=this.convertSignature(r,x(v.from,!0))+"<br />"+m),this.editor(function(a){a.setHtml(m,!1),v.isHtml()||a.modeToggle(!1)})}else Ab.ComposeType.Empty===w?(m=this.convertSignature(r),this.editor(function(a){a.setHtml(m,!1),Ab.EditorDefaultType.Html!==Ob.data().editorDefaultType()&&a.modeToggle(!1)})):Cb.isNonEmptyArray(c)&&h.each(c,function(a){e.addMessageAsAttachment(a)});t=this.getAttachmentsDownloadsForUpload(),Cb.isNonEmptyArray(t)&&Ob.remote().messageUploadAttachments(function(a,b){if(Ab.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()},I.prototype.onFocus=function(){""===this.to()?this.to.focusTrigger(!this.to.focusTrigger()):this.oEditor&&this.oEditor.focus(),this.triggerForResize()},I.prototype.editorResize=function(){this.oEditor&&this.oEditor.resize()},I.prototype.tryToClosePopup=function(){var a=this;Hb.showScreenPopup(T,[Cb.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&Cb.delegateRun(a,"closeCommand")}])},I.prototype.useShortcuts=function(){return Ob.data().useKeyboardShortcuts()},I.prototype.onBuild=function(){this.initUploader();var a=this,c=Ob.data(),d=null;j("ctrl+s, command+s",Ab.KeyState.Compose,function(){return c.useKeyboardShortcuts()?(a.saveCommand(),!1):void 0}),j("ctrl+enter, command+enter",Ab.KeyState.Compose,function(){return c.useKeyboardShortcuts()?(a.sendCommand(),!1):void 0}),j("esc",Ab.KeyState.Compose,function(){return c.useKeyboardShortcuts()?(a.tryToClosePopup(),!1):void 0}),Lb.on("resize",function(){a.triggerForResize()}),this.dropboxEnabled()&&(d=document.createElement("script"),d.type="text/javascript",d.src="https://www.dropbox.com/static/api/1/dropins.js",b(d).attr("id","dropboxjs").attr("data-app-key",Ob.settingsGet("DropboxApiKey")),document.body.appendChild(d))
},I.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},I.prototype.initUploader=function(){if(this.composeUploaderButton()){var a={},b=Cb.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;Cb.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=Cb.isUnd(d.FileName)?"":d.FileName.toString(),g=Cb.isNormal(d.Size)?Cb.pInt(d.Size):null,h=new z(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(Cb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):!0},this)).on("onStart",h.bind(function(b){var c=null;Cb.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=Cb.getUploadErrorDescByCode(f):g||(e=Cb.i18n("UPLOAD/ERROR_UNKNOWN")),h&&(""!==e&&0<e.length?h.waiting(!1).uploading(!1).error(e):g&&(h.waiting(!1).uploading(!1),h.initByUploadJson(g)),Cb.isUnd(a[b])&&delete a[b])},this)),this.addAttachmentEnabled(!0).dragAndDropEnabled(c.isDragAndDropSupported())):this.addAttachmentEnabled(!1).dragAndDropEnabled(!1)}},I.prototype.prepearAttachmentsForSendOrSave=function(){var a={};return h.each(this.attachmentsInReady(),function(b){b&&""!==b.tempName()&&b.enabled()&&(a[b.tempName()]=[b.fileName(),b.isInline?"1":"0",b.CID,b.contentLocation])}),a},I.prototype.addMessageAsAttachment=function(a){if(a){var b=this,c=null,d=a.subject(),e=function(a){return function(){b.attachments.remove(function(b){return b&&b.id===a})}};d=".eml"===d.substr(-4).toLowerCase()?d:d+".eml",c=new z(a.requestHash,d,a.size()),c.fromMessage=!0,c.cancel=e(a.requestHash),c.waiting(!1).uploading(!0),this.attachments.push(c)}},I.prototype.addDropboxAttachment=function(a){var b=this,c=function(a){return function(){b.attachments.remove(function(b){return b&&b.id===a})}},d=Cb.pInt(Ob.settingsGet("AttachmentLimit")),e=null,f=a.bytes;return e=new z(a.link,a.name,f),e.fromMessage=!1,e.cancel=c(a.link),e.waiting(!1).uploading(!0),this.attachments.push(e),f>0&&d>0&&f>d?(e.uploading(!1),e.error(Cb.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG")),!1):(Ob.remote().composeUploadExternals(function(a,b){var c=!1;e.uploading(!1),Ab.StorageResultType.Success===a&&b&&b.Result&&b.Result[e.id]&&(c=!0,e.tempName(b.Result[e.id])),c||e.error(Cb.getUploadErrorDescByCode(Ab.UploadErrorCode.FileNoUploaded))},[a.link]),!0)},I.prototype.prepearMessageAttachments=function(a,b){if(a){var c=this,d=Cb.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(Ab.ComposeType.ForwardAsAttachment===b)this.addMessageAsAttachment(a);else for(;f>e;e++){switch(h=d[e],i=!1,b){case Ab.ComposeType.Reply:case Ab.ComposeType.ReplyAll:i=h.isLinked;break;case Ab.ComposeType.Forward:case Ab.ComposeType.Draft:case Ab.ComposeType.EditAsNew:i=!0}i=!0,i&&(g=new z(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))}}},I.prototype.removeLinkedAttachments=function(){this.attachments.remove(function(a){return a&&a.isLinked})},I.prototype.setMessageAttachmentFailedDowbloadText=function(){h.each(this.attachments(),function(a){a&&a.fromMessage&&a.waiting(!1).uploading(!1).error(Cb.getUploadErrorDescByCode(Ab.UploadErrorCode.FileNoUploaded))},this)},I.prototype.isEmptyForm=function(a){a=Cb.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())},I.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)},I.prototype.getAttachmentsDownloadsForUpload=function(){return h.map(h.filter(this.attachments(),function(a){return a&&""===a.tempName()}),function(a){return a.id})},I.prototype.triggerForResize=function(){this.resizer(!this.resizer()),this.editorResizeThrottle()},Cb.extendAsViewModel("PopupsContactsViewModel",J),J.prototype.setShareToNone=function(){this.viewScopeType(Ab.ContactScopeType.Default)},J.prototype.setShareToAll=function(){this.viewScopeType(Ab.ContactScopeType.ShareAll)},J.prototype.addNewProperty=function(a){var b=new x(a,"");b.focused(!0),this.viewProperties.push(b)},J.prototype.addNewEmail=function(){this.addNewProperty(Ab.ContactPropertyType.EmailPersonal)},J.prototype.addNewPhone=function(){this.addNewProperty(Ab.ContactPropertyType.MobilePersonal)},J.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(Cb.i18n("CONTACTS/ERROR_IMPORT_FILE"))},this))}},J.prototype.removeCheckedOrSelectedContactsFromList=function(){var a=this,b=this.contacts,c=this.currentContact(),d=this.contacts().length,e=this.contactsCheckedOrSelected();0<e.length&&(h.each(e,function(b){c&&c.idContact===b.idContact&&(c=null,a.currentContact(null)),b.deleted(!0),d--}),0>=d&&(this.bDropPageAfterDelete=!0),h.delay(function(){h.each(e,function(a){b.remove(a)})},500))},J.prototype.deleteSelectedContacts=function(){0<this.contactsCheckedOrSelected().length&&(Ob.remote().contactsDelete(h.bind(this.deleteResponse,this),this.contactsCheckedOrSelectedUids()),this.removeCheckedOrSelectedContactsFromList())},J.prototype.deleteResponse=function(a,b){500<(Ab.StorageResultType.Success===a&&b&&b.Time?Cb.pInt(b.Time):0)?this.reloadContactList(this.bDropPageAfterDelete):h.delay(function(a){return function(){a.reloadContactList(a.bDropPageAfterDelete)}}(this),500)},J.prototype.removeProperty=function(a){this.viewProperties.remove(a)},J.prototype.populateViewContact=function(a){var b="",c="",d="",e="",f=[];this.watchHash(!1),this.emptySelection(!1),this.viewReadOnly(!1),this.viewScopeType(Ab.ContactScopeType.Default),a&&(b=a.idContact,c=a.idContactStr,Cb.isNonEmptyArray(a.properties)&&h.each(a.properties,function(a){a&&a[0]&&(Ab.ContactPropertyType.LastName===a[0]?d=a[1]:Ab.ContactPropertyType.FirstName===a[0]?e=a[1]:-1===Cb.inArray(a[0],[Ab.ContactPropertyType.FullName])&&f.push(new x(a[0],a[1])))}),this.viewReadOnly(!!a.readOnly),this.viewScopeType(a.scopeType)),f.unshift(new x(Ab.ContactPropertyType.LastName,d,!a,"CONTACTS/PLACEHOLDER_ENTER_LAST_NAME")),f.unshift(new x(Ab.ContactPropertyType.FirstName,e,!1,"CONTACTS/PLACEHOLDER_ENTER_FIRST_NAME")),this.viewID(b),this.viewIDStr(c),this.viewProperties([]),this.viewProperties(f),this.watchDirty(!1),this.watchHash(!0)},J.prototype.reloadContactList=function(a){var b=this,c=(this.contactsPage()-1)*zb.Defaults.ContactsPerPage;this.bDropPageAfterDelete=!1,(Cb.isUnd(a)?1:!a)||(this.contactsPage(1),c=0),this.contacts.loading(!0),Ob.remote().contacts(function(a,c){var d=0,e=[];Ab.StorageResultType.Success===a&&c&&c.Result&&c.Result.List&&Cb.isNonEmptyArray(c.Result.List)&&(e=h.map(c.Result.List,function(a){var c=new w;return c.parse(a,b.contactsSharingIsAllowed)?c:null}),e=h.compact(e),d=Cb.pInt(c.Result.Count),d=d>0?d:0),b.contactsCount(d),b.contacts(e),b.viewClearSearch(""!==b.search()),b.contacts.loading(!1)},c,zb.Defaults.ContactsPerPage,this.search())},J.prototype.onBuild=function(a){this.oContentVisible=b(".b-list-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.selector.init(this.oContentVisible,this.oContentScrollable,Ab.KeyState.ContactList);var d=this;j("delete",Ab.KeyState.ContactList,function(){return Ob.data().useKeyboardShortcuts()?(d.deleteCommand(),!1):void 0}),a.on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&(d.contactsPage(Cb.pInt(a.value)),d.reloadContactList())}),this.initUploader()},J.prototype.onShow=function(){Hb.routeOff(),this.reloadContactList(!0)},J.prototype.onHide=function(){Hb.routeOn(),this.currentContact(null),this.emptySelection(!0),this.search(""),h.each(this.contacts(),function(a){a.checked(!1)})},Cb.extendAsViewModel("PopupsAdvancedSearchViewModel",K),K.prototype.buildSearchStringValue=function(a){return-1<a.indexOf(" ")&&(a='"'+a+'"'),a},K.prototype.buildSearchString=function(){var a=[],b=Cb.trim(this.from()),c=Cb.trim(this.to()),d=Cb.trim(this.subject()),e=Cb.trim(this.text()),g=[];return b&&""!==b&&a.push("from:"+this.buildSearchStringValue(b)),c&&""!==c&&a.push("to:"+this.buildSearchStringValue(c)),d&&""!==d&&a.push("subject:"+this.buildSearchStringValue(d)),this.hasAttachments()&&g.push("attachments"),this.unseen()&&g.push("unseen"),this.starred()&&g.push("flag"),0<g.length&&a.push("has:"+g.join(",")),-1<this.selectedDateValue()&&a.push("date:"+f().subtract("days",this.selectedDateValue()).format("YYYY.MM.DD")+"/"),e&&""!==e&&a.push("text:"+this.buildSearchStringValue(e)),Cb.trim(a.join(" "))},K.prototype.clearPopup=function(){this.from(""),this.to(""),this.subject(""),this.text(""),this.selectedDateValue(-1),this.hasAttachments(!1),this.starred(!1),this.unseen(!1),this.fromFocus(!0)},K.prototype.onShow=function(){this.clearPopup()},K.prototype.onFocus=function(){this.fromFocus(!0)},Cb.extendAsViewModel("PopupsAddAccountViewModel",L),L.prototype.clearPopup=function(){this.email(""),this.login(""),this.password(""),this.emailError(!1),this.loginError(!1),this.passwordError(!1),this.submitRequest(!1),this.submitError("")},L.prototype.onShow=function(){this.clearPopup()},L.prototype.onFocus=function(){this.emailFocus(!0)},L.prototype.onBuild=function(){this.allowCustomLogin(!!Ob.settingsGet("AllowCustomLogin"))},Cb.extendAsViewModel("PopupsAddOpenPgpKeyViewModel",M),M.prototype.clearPopup=function(){this.key(""),this.key.error(!1)},M.prototype.onShow=function(){this.clearPopup()},M.prototype.onFocus=function(){this.key.focus(!0)},Cb.extendAsViewModel("PopupsViewOpenPgpKeyViewModel",N),N.prototype.clearPopup=function(){this.key("")},N.prototype.selectKey=function(){var a=this.keyDom();a&&Cb.selectElement(a)},N.prototype.onShow=function(a){this.clearPopup(),a&&this.key(a.armor)},Cb.extendAsViewModel("PopupsGenerateNewOpenPgpKeyViewModel",O),O.prototype.clearPopup=function(){this.name(""),this.password(""),this.email(""),this.email.error(!1),this.keyBitLength(2048)},O.prototype.onShow=function(){this.clearPopup()},O.prototype.onFocus=function(){this.email.focus(!0)},Cb.extendAsViewModel("PopupsComposeOpenPgpViewModel",P),P.prototype.clearPopup=function(){this.notification(""),this.password(""),this.password.focus(!1),this.from(""),this.to([]),this.text(""),this.submitRequest(!1),this.resultCallback=null},P.prototype.onHide=function(){this.clearPopup()},P.prototype.onShow=function(a,b,c,d,e,f){this.clearPopup();var g=new v,i="",j=[];this.resultCallback=a,g.clear(),g.mailsoParse(c),""!==g.email&&(i=g.email),""!==d&&j.push(d),""!==e&&j.push(e),""!==f&&j.push(f),j=j.join(", ").split(","),j=h.compact(h.map(j,function(a){return g.clear(),g.mailsoParse(Cb.trim(a)),""===g.email?!1:g.email})),this.from(i),this.to(j),this.text(b)},Cb.extendAsViewModel("PopupsIdentityViewModel",Q),Q.prototype.clearPopup=function(){this.id="",this.edit(!1),this.owner(!1),this.name(""),this.email(""),this.replyTo(""),this.bcc(""),this.email.hasError(!1),this.replyTo.hasError(!1),this.bcc.hasError(!1),this.submitRequest(!1),this.submitError("")},Q.prototype.onShow=function(a){this.clearPopup(),a&&(this.edit(!0),this.id=a.id,this.name(a.name()),this.email(a.email()),this.replyTo(a.replyTo()),this.bcc(a.bcc()),this.owner(this.id===Ob.data().accountEmail()))},Q.prototype.onFocus=function(){this.owner()||this.email.focused(!0)},Cb.extendAsViewModel("PopupsLanguagesViewModel",R),R.prototype.languageEnName=function(a){return Cb.convertLangName(a,!0)},R.prototype.resetMainLanguage=function(){var a=Ob.data().mainLanguage();h.each(this.languages(),function(b){b.selected(b.key===a)})},R.prototype.onShow=function(){this.exp(!0),this.resetMainLanguage()},R.prototype.onHide=function(){this.exp(!1)},R.prototype.changeLanguage=function(a){Ob.data().mainLanguage(a),this.cancelCommand()},Cb.extendAsViewModel("PopupsTwoFactorTestViewModel",S),S.prototype.clearPopup=function(){this.code(""),this.code.focused(!1),this.code.status(null),this.testing(!1)},S.prototype.onShow=function(){this.clearPopup()},S.prototype.onFocus=function(){this.code.focused(!0)},Cb.extendAsViewModel("PopupsAskViewModel",T),T.prototype.clearPopup=function(){this.askDesc(""),this.yesButton(Cb.i18n("POPUPS_ASK/BUTTON_YES")),this.noButton(Cb.i18n("POPUPS_ASK/BUTTON_NO")),this.yesFocus(!1),this.noFocus(!1),this.fYesAction=null,this.fNoAction=null},T.prototype.yesClick=function(){this.cancelCommand(),Cb.isFunc(this.fYesAction)&&this.fYesAction.call(null)},T.prototype.noClick=function(){this.cancelCommand(),Cb.isFunc(this.fNoAction)&&this.fNoAction.call(null)},T.prototype.onShow=function(a,b,c,d,e){this.clearPopup(),this.fYesAction=b||null,this.fNoAction=c||null,this.askDesc(a||""),d&&this.yesButton(d),d&&this.yesButton(e)},T.prototype.onFocus=function(){this.yesFocus(!0)},T.prototype.onBuild=function(){j("tab, right, left",Ab.KeyState.PopupAsk,h.bind(function(){return this.yesFocus()?this.noFocus(!0):this.yesFocus(!0),!1},this))},Cb.extendAsViewModel("PopupsKeyboardShortcutsHelpViewModel",U),Cb.extendAsViewModel("LoginViewModel",V),V.prototype.onShow=function(){Hb.routeOff(),h.delay(h.bind(function(){""!==this.email()&&""!==this.password()?this.submitFocus(!0):this.emailFocus(!0),Ob.settingsGet("UserLanguage")&&b.cookie("rllang",Ob.data().language(),{expires:30})},this),100)},V.prototype.onHide=function(){this.submitFocus(!1),this.emailFocus(!1)},V.prototype.onBuild=function(){var c=this,d=Ob.settingsGet("JsHash"),e=function(a){a=Cb.pInt(a),0===a?(c.submitRequest(!0),Ob.loginAndLogoutReload()):c.submitError(Cb.getNotification(a))};switch(this.facebookLoginEnabled(!!Ob.settingsGet("AllowFacebookSocial")),this.twitterLoginEnabled(!!Ob.settingsGet("AllowTwitterSocial")),this.googleLoginEnabled(!!Ob.settingsGet("AllowGoogleSocial")),(Ob.settingsGet("SignMe")||"unused").toLowerCase()){case Ab.LoginSignMeTypeAsString.DefaultOff:this.signMeType(Ab.LoginSignMeType.DefaultOff);break;case Ab.LoginSignMeTypeAsString.DefaultOn:this.signMeType(Ab.LoginSignMeType.DefaultOn);break;default:case Ab.LoginSignMeTypeAsString.Unused:this.signMeType(Ab.LoginSignMeType.Unused)}this.email(Ob.data().devEmail),this.login(Ob.data().devLogin),this.password(Ob.data().devPassword),this.googleLoginEnabled()&&(a["rl_"+d+"_google_login_service"]=e),this.facebookLoginEnabled()&&(a["rl_"+d+"_facebook_login_service"]=e),this.twitterLoginEnabled()&&(a["rl_"+d+"_twitter_login_service"]=e),h.delay(function(){Ob.data().language.subscribe(function(a){c.langRequest(!0),b.ajax({url:Ob.link().langLink(a),dataType:"script",cache:!0}).done(function(){c.bSendLanguage=!0,Cb.i18nToDoc(),b.cookie("rllang",Ob.data().language(),{expires:30})}).always(function(){c.langRequest(!1)})})},50)},V.prototype.selectLanguage=function(){Hb.showScreenPopup(R)},h.extend(W.prototype,s.prototype),W.prototype.accountClick=function(a,b){if(a&&b&&!Cb.isUnd(b.which)&&1===b.which){var c=this;this.accountsLoading(!0),h.delay(function(){c.accountsLoading(!1)},1e3)}return!0},W.prototype.emailTitle=function(){return Ob.data().accountEmail()},W.prototype.settingsClick=function(){Hb.setHash(Ob.link().settings())},W.prototype.addAccountClick=function(){this.allowAddAccount&&Hb.showScreenPopup(L)},W.prototype.logoutClick=function(){Ob.remote().logout(function(){a.__rlah_clear&&a.__rlah_clear(),Ob.loginAndLogoutReload(!0,Ob.settingsGet("ParentEmail")&&0<Ob.settingsGet("ParentEmail").length)})},Cb.extendAsViewModel("MailBoxSystemDropDownViewModel",X,W),Cb.extendAsViewModel("SettingsSystemDropDownViewModel",Y,W),Cb.extendAsViewModel("MailBoxFolderListViewModel",Z),Z.prototype.onBuild=function(a){a.on("click",".b-folders .b-content",function(){Ob.data().useKeyboardShortcuts()&&Ob.data().message.focused()&&Ob.data().message.focused(!1)}).on("click",".b-folders .e-item .e-link .e-collapsed-sign",function(a){var b=c.dataFor(this),d=!1;b&&a&&(d=b.collapsed(),Cb.setExpandedFolder(b.fullNameHash,d),b.collapsed(!d),a.preventDefault(),a.stopPropagation())}).on("click",".b-folders .e-item .e-link.selectable",function(a){a.preventDefault();var b=Ob.data(),d=c.dataFor(this);d&&(Ab.Layout.NoPreview===b.layout()&&b.message(null),d.fullNameRaw===b.currentFolderFullNameRaw()&&Ob.cache().setFolderHash(d.fullNameRaw,""),Hb.setHash(Ob.link().mailBox(d.fullNameHash)))})},Z.prototype.messagesDropOver=function(b){a.clearTimeout(this.iDropOverTimer),b&&b.collapsed()&&(this.iDropOverTimer=a.setTimeout(function(){b.collapsed(!1),Cb.setExpandedFolder(b.fullNameHash,!0),Cb.windowResize()},500))},Z.prototype.messagesDropOut=function(){a.clearTimeout(this.iDropOverTimer)},Z.prototype.messagesDrop=function(a,b){if(a&&b&&b.helper){var c=b.helper.data("rl-folder"),d="1"===b.helper.data("rl-copy"),e=b.helper.data("rl-uids");Cb.isNormal(c)&&""!==c&&Cb.isArray(e)&&Ob.moveMessagesToFolder(c,e,a.fullNameRaw,d)}},Z.prototype.composeClick=function(){Hb.showScreenPopup(I)},Z.prototype.createFolder=function(){Hb.showScreenPopup(G)},Z.prototype.configureFolders=function(){Hb.setHash(Ob.link().settings("folders"))},Z.prototype.contactsClick=function(){this.allowContacts&&Hb.showScreenPopup(J)},Cb.extendAsViewModel("MailBoxMessageListViewModel",$),$.prototype.emptySubjectValue="",$.prototype.searchEnterAction=function(){this.mainMessageListSearch(this.sLastSearchValue),this.inputMessageListSearchFocus(!1)},$.prototype.printableMessageCountForDeletion=function(){var a=this.messageListCheckedOrSelectedUidsWithSubMails().length;return a>1?" ("+(100>a?a:"99+")+")":""},$.prototype.cancelSearch=function(){this.mainMessageListSearch(""),this.inputMessageListSearchFocus(!1)},$.prototype.moveSelectedMessagesToFolder=function(a){return this.canBeMoved()&&Ob.moveMessagesToFolder(Ob.data().currentFolderFullNameRaw(),Ob.data().messageListCheckedOrSelectedUidsWithSubMails(),a),!1},$.prototype.dragAndDronHelper=function(a,b){a&&a.checked(!0);var c=Cb.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},$.prototype.onMessageResponse=function(a,b,c){var d=Ob.data();d.hideMessageBodies(),d.messageLoading(!1),Ab.StorageResultType.Success===a&&b&&b.Result?d.setMessage(b,c):Ab.StorageResultType.Unload===a?(d.message(null),d.messageError("")):Ab.StorageResultType.Abort!==a&&(d.message(null),d.messageError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.getNotification(Ab.Notification.UnknownError)))},$.prototype.populateMessageBody=function(a){a&&(Ob.remote().message(this.onMessageResponse,a.folderFullNameRaw,a.uid)?Ob.data().messageLoading(!0):Cb.log("Error: Unknown message request: "+a.folderFullNameRaw+" ~ "+a.uid+" [e-101]"))},$.prototype.setAction=function(a,b,c){var d=[],e=null,f=Ob.cache(),g=0;if(Cb.isUnd(c)&&(c=Ob.data().messageListChecked()),d=h.map(c,function(a){return a.uid}),""!==a&&0<d.length){switch(b){case Ab.MessageSetAction.SetSeen:h.each(c,function(a){a.unseen()&&g++,a.unseen(!1),f.storeMessageFlagsToCache(a)}),e=f.getFolderFromCacheList(a),e&&e.messageCountUnread(e.messageCountUnread()-g),Ob.remote().messageSetSeen(Cb.emptyFunction,a,d,!0);break;case Ab.MessageSetAction.UnsetSeen:h.each(c,function(a){a.unseen()&&g++,a.unseen(!0),f.storeMessageFlagsToCache(a)}),e=f.getFolderFromCacheList(a),e&&e.messageCountUnread(e.messageCountUnread()-g+d.length),Ob.remote().messageSetSeen(Cb.emptyFunction,a,d,!1);break;case Ab.MessageSetAction.SetFlag:h.each(c,function(a){a.flagged(!0),f.storeMessageFlagsToCache(a)}),Ob.remote().messageSetFlagged(Cb.emptyFunction,a,d,!0);break;case Ab.MessageSetAction.UnsetFlag:h.each(c,function(a){a.flagged(!1),f.storeMessageFlagsToCache(a)}),Ob.remote().messageSetFlagged(Cb.emptyFunction,a,d,!1)}Ob.reloadFlagsCurrentMessageListAndMessageFromCache()}},$.prototype.setActionForAll=function(a,b){var c=null,d=Ob.data().messageList(),e=Ob.cache();if(""!==a&&(c=e.getFolderFromCacheList(a))){switch(b){case Ab.MessageSetAction.SetSeen:c=e.getFolderFromCacheList(a),c&&(h.each(d,function(a){a.unseen(!1)}),c.messageCountUnread(0),e.clearMessageFlagsFromCacheByFolder(a)),Ob.remote().messageSetSeenToAll(Cb.emptyFunction,a,!0);break;case Ab.MessageSetAction.UnsetSeen:c=e.getFolderFromCacheList(a),c&&(h.each(d,function(a){a.unseen(!0)}),c.messageCountUnread(c.messageCountAll()),e.clearMessageFlagsFromCacheByFolder(a)),Ob.remote().messageSetSeenToAll(Cb.emptyFunction,a,!1)}Ob.reloadFlagsCurrentMessageListAndMessageFromCache()}},$.prototype.listSetSeen=function(){this.setAction(Ob.data().currentFolderFullNameRaw(),Ab.MessageSetAction.SetSeen,Ob.data().messageListCheckedOrSelected())},$.prototype.listSetAllSeen=function(){this.setActionForAll(Ob.data().currentFolderFullNameRaw(),Ab.MessageSetAction.SetSeen)},$.prototype.listUnsetSeen=function(){this.setAction(Ob.data().currentFolderFullNameRaw(),Ab.MessageSetAction.UnsetSeen,Ob.data().messageListCheckedOrSelected())},$.prototype.listSetFlags=function(){this.setAction(Ob.data().currentFolderFullNameRaw(),Ab.MessageSetAction.SetFlag,Ob.data().messageListCheckedOrSelected())},$.prototype.listUnsetFlags=function(){this.setAction(Ob.data().currentFolderFullNameRaw(),Ab.MessageSetAction.UnsetFlag,Ob.data().messageListCheckedOrSelected())},$.prototype.flagMessages=function(a){var b=this.messageListCheckedOrSelected(),c=[];a&&(0<b.length&&(c=h.map(b,function(a){return a.uid})),0<c.length&&-1<Cb.inArray(a.uid,c)?this.setAction(a.folderFullNameRaw,a.flagged()?Ab.MessageSetAction.UnsetFlag:Ab.MessageSetAction.SetFlag,b):this.setAction(a.folderFullNameRaw,a.flagged()?Ab.MessageSetAction.UnsetFlag:Ab.MessageSetAction.SetFlag,[a]))},$.prototype.flagMessagesFast=function(){var a=this.messageListCheckedOrSelected(),b=[];0<a.length&&(b=h.filter(a,function(a){return a.flagged()}),this.setAction(a[0].folderFullNameRaw,a.length===b.length?Ab.MessageSetAction.UnsetFlag:Ab.MessageSetAction.SetFlag,a))},$.prototype.seenMessagesFast=function(){var a=this.messageListCheckedOrSelected(),b=[];b=h.filter(a,function(a){return a.unseen()}),this.setAction(a[0].folderFullNameRaw,0<b.length?Ab.MessageSetAction.SetSeen:Ab.MessageSetAction.UnsetSeen,a)},$.prototype.onBuild=function(a){var d=this,e=Ob.data();this.oContentVisible=b(".b-content",a),this.oContentScrollable=b(".content",this.oContentVisible),this.oContentVisible.on("click",".fullThreadHandle",function(){var a=[],b=c.dataFor(this);return b&&!b.lastInCollapsedThreadLoading()&&(Ob.data().messageListThreadFolder(b.folderFullNameRaw),a=Ob.data().messageListThreadUids(),b.lastInCollapsedThread()?a.push(0<b.parentUid()?b.parentUid():b.uid):a=h.without(a,0<b.parentUid()?b.parentUid():b.uid),Ob.data().messageListThreadUids(h.uniq(a)),b.lastInCollapsedThreadLoading(!0),b.lastInCollapsedThread(!b.lastInCollapsedThread()),Ob.reloadMessageList()),!1}),this.selector.init(this.oContentVisible,this.oContentScrollable,Ab.KeyState.MessageList),a.on("click",".messageList .b-message-list-wrapper",function(){e.useKeyboardShortcuts()&&d.message.focused()&&d.message.focused(!1)}).on("click",".e-pagenator .e-page",function(){var a=c.dataFor(this);a&&Hb.setHash(Ob.link().mailBox(e.currentFolderFullNameHash(),a.value,e.messageListSearch()))}).on("click",".messageList .checkboxCkeckAll",function(){d.checkAll(!d.checkAll())}).on("click",".messageList .messageListItem .flagParent",function(){d.flagMessages(c.dataFor(this))}),this.initUploaderForAppend(),this.initShortcuts(),!Fb.bMobileDevice&&Ob.settingsGet("AllowPrefetch")&&i&&(i.setIdleDuration(10),i.idle(function(){d.prefetchNextTick()}))},$.prototype.initShortcuts=function(){var a=this,b=Ob.data();j("ctrl+p, command+p",Ab.KeyState.MessageList,function(){return b.useKeyboardShortcuts()?!1:void 0}),j("delete, shift+delete",Ab.KeyState.MessageList,function(c,d){return b.useKeyboardShortcuts()&&c?(0<Ob.data().messageListCheckedOrSelected().length&&(d&&"shift+delete"===d.shortcut?a.deleteWithoutMoveCommand():a.deleteCommand()),!1):void 0}),j("ctrl+a, command+a",Ab.KeyState.MessageList,function(){return b.useKeyboardShortcuts()?(a.checkAll(!(a.checkAll()&&!a.isIncompleteChecked())),!1):void 0}),j("c,n",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(Hb.showScreenPopup(I),!1):void 0}),j("s",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(a.flagMessagesFast(),!1):void 0}),j("m",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(a.seenMessagesFast(),!1):void 0}),j("shift+/",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(Hb.showScreenPopup(U),!1):void 0}),j("shift+f",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(a.multyForwardCommand(),!1):void 0}),j("/",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(a.message()&&a.message.focused(!1),a.inputMessageListSearchFocus(!0),!1):void 0}),j("esc",Ab.KeyState.MessageList,function(){return b.useKeyboardShortcuts()&&""!==a.messageListSearchDesc()?(a.cancelSearch(),!1):void 0}),j("tab, shift+tab",Ab.KeyState.MessageList,function(){return b.useKeyboardShortcuts()?(a.message()&&a.message.focused(!0),!1):void 0}),j("ctrl+left, command+left",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?!1:void 0}),j("ctrl+right, command+right",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?!1:void 0})},$.prototype.prefetchNextTick=function(){if(!this.bPrefetch&&!i.now()&&this.viewModelVisibility()){var a=this,b=Ob.cache(),c=h.find(this.messageList(),function(a){return a&&!b.hasRequestedMessage(a.folderFullNameRaw,a.uid)});c&&(this.bPrefetch=!0,Ob.cache().addRequestedMessage(c.folderFullNameRaw,c.uid),Ob.remote().message(function(b,c){var d=!(Ab.StorageResultType.Success!==b||!c||!c.Result);h.delay(function(){a.bPrefetch=!1,d&&a.prefetchNextTick()},1e3)},c.folderFullNameRaw,c.uid))}},$.prototype.composeClick=function(){Hb.showScreenPopup(I)},$.prototype.advancedSearchClick=function(){Hb.showScreenPopup(K)},$.prototype.quotaTooltip=function(){return Cb.i18n("MESSAGE_LIST/QUOTA_SIZE",{SIZE:Cb.friendlySize(this.userUsageSize()),PROC:this.userUsageProc(),LIMIT:Cb.friendlySize(this.userQuota())})},$.prototype.initUploaderForAppend=function(){if(!Ob.settingsGet("AllowAppendMessage")||!this.dragOverArea())return!1;var a=new g({action:Ob.link().append(),name:"AppendFile",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,hidden:{Folder:function(){return Ob.data().currentFolderFullNameRaw()}},dragAndDropElement:this.dragOverArea(),dragAndDropBodyElement:this.dragOverBodyArea()});return a.on("onDragEnter",h.bind(function(){this.dragOverEnter(!0)},this)).on("onDragLeave",h.bind(function(){this.dragOverEnter(!1)},this)).on("onBodyDragEnter",h.bind(function(){this.dragOver(!0)},this)).on("onBodyDragLeave",h.bind(function(){this.dragOver(!1)},this)).on("onSelect",h.bind(function(a,b){return a&&b&&"message/rfc822"===b.Type?(Ob.data().messageListLoading(!0),!0):!1},this)).on("onComplete",h.bind(function(){Ob.reloadMessageList(!0,!0)},this)),!!a},Cb.extendAsViewModel("MailBoxMessageViewViewModel",_),_.prototype.isPgpActionVisible=function(){return Ab.SignedVerifyStatus.Success!==this.viewPgpSignedVerifyStatus()},_.prototype.isPgpStatusVerifyVisible=function(){return Ab.SignedVerifyStatus.None!==this.viewPgpSignedVerifyStatus()},_.prototype.isPgpStatusVerifySuccess=function(){return Ab.SignedVerifyStatus.Success===this.viewPgpSignedVerifyStatus()},_.prototype.pgpStatusVerifyMessage=function(){var a="";switch(this.viewPgpSignedVerifyStatus()){case Ab.SignedVerifyStatus.UnknownPublicKeys:a="No public keys found";break;case Ab.SignedVerifyStatus.UnknownPrivateKey:a="No private key found";break;case Ab.SignedVerifyStatus.Unverified:a="Unverified signature";break;case Ab.SignedVerifyStatus.Error:a="OpenPGP decryption error";break;case Ab.SignedVerifyStatus.Success:a="Good signature from "+this.viewPgpSignedVerifyUser()}return a},_.prototype.scrollToTop=function(){var a=b(".messageItem.nano .content",this.viewModelDom);a&&a[0]?a.scrollTop(0):b(".messageItem",this.viewModelDom).scrollTop(0),Cb.windowResize()},_.prototype.fullScreen=function(){this.fullScreenMode(!0),Cb.windowResize()},_.prototype.unFullScreen=function(){this.fullScreenMode(!1),Cb.windowResize()},_.prototype.toggleFullScreen=function(){Cb.removeSelection(),this.fullScreenMode(!this.fullScreenMode()),Cb.windowResize()},_.prototype.replyOrforward=function(a){Hb.showScreenPopup(I,[a,Ob.data().message()])},_.prototype.onBuild=function(a){var d=this,e=Ob.data();this.fullScreenMode.subscribe(function(a){a&&d.message.focused(!0)},this),b(".attachmentsPlace",a).magnificPopup({delegate:".magnificPopupImage:visible",type:"image",gallery:{enabled:!0,preload:[1,1],navigateByImgClick:!0},callbacks:{open:function(){e.useKeyboardShortcuts(!1)},close:function(){e.useKeyboardShortcuts(!0)}},mainClass:"mfp-fade",removalDelay:400}),a.on("click",".messageView .messageItem",function(){e.useKeyboardShortcuts()&&d.message()&&d.message.focused(!0)}).on("mousedown","a",function(a){return!(a&&3!==a.which&&Ob.mailToHelper(b(this).attr("href")))}).on("click",".attachmentsPlace .attachmentPreview",function(a){a&&a.stopPropagation&&a.stopPropagation()}).on("click",".attachmentsPlace .attachmentItem",function(){var a=c.dataFor(this);a&&a.download&&Ob.download(a.linkDownload())}),this.message.focused.subscribe(function(a){this.messageDomFocused(!!a)},this),this.keyScope.subscribe(function(a){Ab.KeyState.MessageView===a&&this.message.focused()&&this.messageDomFocused(!0)},this),this.oMessageScrollerDom=a.find(".messageItem .content"),this.oMessageScrollerDom=this.oMessageScrollerDom&&this.oMessageScrollerDom[0]?this.oMessageScrollerDom:null,this.initShortcuts()},_.prototype.escShortcuts=function(){return this.viewModelVisibility()&&Ob.data().useKeyboardShortcuts()&&this.message()?(this.fullScreenMode()?this.fullScreenMode(!1):(this.message.focused(!1),Ab.Layout.NoPreview===Ob.data().layout()&&Ob.historyBack()),!1):void 0
},_.prototype.initShortcuts=function(){var a=this,b=Ob.data();j("esc",Ab.KeyState.MessageView,h.bind(this.escShortcuts,this)),j("enter",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?(a.toggleFullScreen(),!1):void 0}),j("r",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()&&b.message()?(a.replyCommand(),!1):void 0}),j("a",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()&&b.message()?(a.replyAllCommand(),!1):void 0}),j("f",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()&&b.message()?(a.forwardCommand(),!1):void 0}),j("i",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()?(a.showFullInfo(!a.showFullInfo()),!1):void 0}),j("b",[Ab.KeyState.MessageList,Ab.KeyState.MessageView],function(){return b.useKeyboardShortcuts()&&b.message()&&b.message().body?(Cb.toggleMessageBlockquote(b.message().body),!1):void 0}),j("ctrl+left, command+left, ctrl+up, command+up",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?(a.goUpCommand(),!1):void 0}),j("ctrl+right, command+right, ctrl+down, command+down",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?(a.goDownCommand(),!1):void 0}),j("ctrl+p, command+p",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?(a.message()&&a.message().printMessage(),!1):void 0}),j("delete, shift+delete",Ab.KeyState.MessageView,function(c,d){return b.useKeyboardShortcuts()&&c?(d&&"shift+delete"===d.shortcut?a.deleteWithoutMoveCommand():a.deleteCommand(),!1):void 0}),j("tab, shift+tab",Ab.KeyState.MessageView,function(){return b.useKeyboardShortcuts()?(!a.fullScreenMode()&&a.message()&&a.message.focused(!1),!1):void 0})},_.prototype.isDraftFolder=function(){return Ob.data().message()&&Ob.data().draftFolder()===Ob.data().message().folderFullNameRaw},_.prototype.isSentFolder=function(){return Ob.data().message()&&Ob.data().sentFolder()===Ob.data().message().folderFullNameRaw},_.prototype.isSpamFolder=function(){return Ob.data().message()&&Ob.data().spamFolder()===Ob.data().message().folderFullNameRaw},_.prototype.isSpamDisabled=function(){return Ob.data().message()&&Ob.data().spamFolder()===zb.Values.UnuseOptionValue},_.prototype.isArchiveFolder=function(){return Ob.data().message()&&Ob.data().archiveFolder()===Ob.data().message().folderFullNameRaw},_.prototype.isArchiveDisabled=function(){return Ob.data().message()&&Ob.data().archiveFolder()===zb.Values.UnuseOptionValue},_.prototype.isDraftOrSentFolder=function(){return this.isDraftFolder()||this.isSentFolder()},_.prototype.composeClick=function(){Hb.showScreenPopup(I)},_.prototype.editMessage=function(){Ob.data().message()&&Hb.showScreenPopup(I,[Ab.ComposeType.Draft,Ob.data().message()])},_.prototype.scrollMessageToTop=function(){this.oMessageScrollerDom&&this.oMessageScrollerDom.scrollTop(0)},_.prototype.showImages=function(a){a&&a.showExternalImages&&a.showExternalImages(!0)},_.prototype.verifyPgpSignedClearMessage=function(a){a&&a.verifyPgpSignedClearMessage()},_.prototype.decryptPgpEncryptedMessage=function(a){a&&a.decryptPgpEncryptedMessage(this.viewPgpPassword())},_.prototype.readReceipt=function(a){a&&""!==a.readReceipt()&&(Ob.remote().sendReadReceiptMessage(Cb.emptyFunction,a.folderFullNameRaw,a.uid,a.readReceipt(),Cb.i18n("READ_RECEIPT/SUBJECT",{SUBJECT:a.subject()}),Cb.i18n("READ_RECEIPT/BODY",{"READ-RECEIPT":a.readReceipt()})),a.isReadReceipt(!0),Ob.cache().storeMessageFlagsToCache(a),Ob.reloadFlagsCurrentMessageListAndMessageFromCache())},Cb.extendAsViewModel("SettingsMenuViewModel",ab),ab.prototype.link=function(a){return Ob.link().settings(a)},ab.prototype.backToMailBoxClick=function(){Hb.setHash(Ob.link().inbox())},Cb.extendAsViewModel("SettingsPaneViewModel",bb),bb.prototype.onShow=function(){Ob.data().message(null)},bb.prototype.backToMailBoxClick=function(){Hb.setHash(Ob.link().inbox())},Cb.addSettingsViewModel(cb,"SettingsGeneral","SETTINGS_LABELS/LABEL_GENERAL_NAME","general",!0),cb.prototype.toggleLayout=function(){this.layout(Ab.Layout.NoPreview===this.layout()?Ab.Layout.SidePreview:Ab.Layout.NoPreview)},cb.prototype.onBuild=function(){var a=this;h.delay(function(){var c=Ob.data(),d=Cb.settingsSaveHelperSimpleFunction(a.mppTrigger,a);c.language.subscribe(function(c){a.languageTrigger(Ab.SaveSettingsStep.Animate),b.ajax({url:Ob.link().langLink(c),dataType:"script",cache:!0}).done(function(){Cb.i18nToDoc(),a.languageTrigger(Ab.SaveSettingsStep.TrueResult)}).fail(function(){a.languageTrigger(Ab.SaveSettingsStep.FalseResult)}).always(function(){h.delay(function(){a.languageTrigger(Ab.SaveSettingsStep.Idle)},1e3)}),Ob.remote().saveSettings(Cb.emptyFunction,{Language:c})}),c.editorDefaultType.subscribe(function(a){Ob.remote().saveSettings(Cb.emptyFunction,{EditorDefaultType:a})}),c.messagesPerPage.subscribe(function(a){Ob.remote().saveSettings(d,{MPP:a})}),c.showImages.subscribe(function(a){Ob.remote().saveSettings(Cb.emptyFunction,{ShowImages:a?"1":"0"})}),c.interfaceAnimation.subscribe(function(a){Ob.remote().saveSettings(Cb.emptyFunction,{InterfaceAnimation:a})}),c.useDesktopNotifications.subscribe(function(a){Cb.timeOutAction("SaveDesktopNotifications",function(){Ob.remote().saveSettings(Cb.emptyFunction,{DesktopNotifications:a?"1":"0"})},3e3)}),c.replySameFolder.subscribe(function(a){Cb.timeOutAction("SaveReplySameFolder",function(){Ob.remote().saveSettings(Cb.emptyFunction,{ReplySameFolder:a?"1":"0"})},3e3)}),c.useThreads.subscribe(function(a){c.messageList([]),Ob.remote().saveSettings(Cb.emptyFunction,{UseThreads:a?"1":"0"})}),c.layout.subscribe(function(a){c.messageList([]),Ob.remote().saveSettings(Cb.emptyFunction,{Layout:a})}),c.useCheckboxesInList.subscribe(function(a){Ob.remote().saveSettings(Cb.emptyFunction,{UseCheckboxesInList:a?"1":"0"})})},50)},cb.prototype.onShow=function(){Ob.data().desktopNotifications.valueHasMutated()},cb.prototype.selectLanguage=function(){Hb.showScreenPopup(R)},Cb.addSettingsViewModel(db,"SettingsContacts","SETTINGS_LABELS/LABEL_CONTACTS_NAME","contacts"),db.prototype.toggleShowPassword=function(){this.showPassword(!this.showPassword())},db.prototype.onBuild=function(){Ob.data().contactsAutosave.subscribe(function(a){Ob.remote().saveSettings(Cb.emptyFunction,{ContactsAutosave:a?"1":"0"})})},db.prototype.onShow=function(){this.showPassword(!1)},Cb.addSettingsViewModel(eb,"SettingsAccounts","SETTINGS_LABELS/LABEL_ACCOUNTS_NAME","accounts"),eb.prototype.addNewAccount=function(){Hb.showScreenPopup(L)},eb.prototype.deleteAccount=function(b){if(b&&b.deleteAccess()){this.accountForDeletion(null);var c=function(a){return b===a};b&&(this.accounts.remove(c),Ob.remote().accountDelete(function(b,c){Ab.StorageResultType.Success===b&&c&&c.Result&&c.Reload?(Hb.routeOff(),Hb.setHash(Ob.link().root(),!0),Hb.routeOff(),h.defer(function(){a.location.reload()})):Ob.accountsAndIdentities()},b.email))}},Cb.addSettingsViewModel(fb,"SettingsIdentity","SETTINGS_LABELS/LABEL_IDENTITY_NAME","identity"),fb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Ob.data().signature();this.editor=new l(a.signatureDom(),function(){Ob.data().signature((a.editor.isHtml()?":HTML:":"")+a.editor.getData())},function(){":HTML:"===b.substr(0,6)?a.editor.setHtml(b.substr(6),!1):a.editor.setPlain(b,!1)})}},fb.prototype.onBuild=function(){var a=this;h.delay(function(){var b=Ob.data(),c=Cb.settingsSaveHelperSimpleFunction(a.displayNameTrigger,a),d=Cb.settingsSaveHelperSimpleFunction(a.replyTrigger,a),e=Cb.settingsSaveHelperSimpleFunction(a.signatureTrigger,a);b.displayName.subscribe(function(a){Ob.remote().saveSettings(c,{DisplayName:a})}),b.replyTo.subscribe(function(a){Ob.remote().saveSettings(d,{ReplyTo:a})}),b.signature.subscribe(function(a){Ob.remote().saveSettings(e,{Signature:a})}),b.signatureToAll.subscribe(function(a){Ob.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},Cb.addSettingsViewModel(gb,"SettingsIdentities","SETTINGS_LABELS/LABEL_IDENTITIES_NAME","identities"),gb.prototype.addNewIdentity=function(){Hb.showScreenPopup(Q)},gb.prototype.editIdentity=function(a){Hb.showScreenPopup(Q,[a])},gb.prototype.deleteIdentity=function(a){if(a&&a.deleteAccess()){this.identityForDeletion(null);var b=function(b){return a===b};a&&(this.identities.remove(b),Ob.remote().identityDelete(function(){Ob.accountsAndIdentities()},a.id))}},gb.prototype.onFocus=function(){if(!this.editor&&this.signatureDom()){var a=this,b=Ob.data().signature();this.editor=new l(a.signatureDom(),function(){Ob.data().signature((a.editor.isHtml()?":HTML:":"")+a.editor.getData())},function(){":HTML:"===b.substr(0,6)?a.editor.setHtml(b.substr(6),!1):a.editor.setPlain(b,!1)})}},gb.prototype.onBuild=function(a){var b=this;a.on("click",".identity-item .e-action",function(){var a=c.dataFor(this);a&&b.editIdentity(a)}),h.delay(function(){var a=Ob.data(),c=Cb.settingsSaveHelperSimpleFunction(b.displayNameTrigger,b),d=Cb.settingsSaveHelperSimpleFunction(b.replyTrigger,b),e=Cb.settingsSaveHelperSimpleFunction(b.signatureTrigger,b);a.displayName.subscribe(function(a){Ob.remote().saveSettings(c,{DisplayName:a})}),a.replyTo.subscribe(function(a){Ob.remote().saveSettings(d,{ReplyTo:a})}),a.signature.subscribe(function(a){Ob.remote().saveSettings(e,{Signature:a})}),a.signatureToAll.subscribe(function(a){Ob.remote().saveSettings(null,{SignatureToAll:a?"1":"0"})})},50)},Cb.addSettingsViewModel(hb,"SettingsSecurity","SETTINGS_LABELS/LABEL_SECURITY_NAME","security"),hb.prototype.createTwoFactor=function(){this.processing(!0),Ob.remote().createTwoFactor(this.onResult)},hb.prototype.enableTwoFactor=function(){this.processing(!0),Ob.remote().enableTwoFactor(this.onResult,this.viewEnable())},hb.prototype.testTwoFactor=function(){Hb.showScreenPopup(S)},hb.prototype.clearTwoFactor=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl(""),this.clearing(!0),Ob.remote().clearTwoFactor(this.onResult)},hb.prototype.onShow=function(){this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")},hb.prototype.onResult=function(a,b){if(this.processing(!1),this.clearing(!1),Ab.StorageResultType.Success===a&&b&&b.Result?(this.viewUser(Cb.pString(b.Result.User)),this.viewEnable(!!b.Result.Enable),this.twoFactorStatus(!!b.Result.IsSet),this.viewSecret(Cb.pString(b.Result.Secret)),this.viewBackupCodes(Cb.pString(b.Result.BackupCodes).replace(/[\s]+/g," ")),this.viewUrl(Cb.pString(b.Result.Url))):(this.viewUser(""),this.viewEnable(!1),this.twoFactorStatus(!1),this.viewSecret(""),this.viewBackupCodes(""),this.viewUrl("")),this.bFirst){this.bFirst=!1;var c=this;this.viewEnable.subscribe(function(a){this.viewEnable.subs&&Ob.remote().enableTwoFactor(function(a,b){Ab.StorageResultType.Success===a&&b&&b.Result||(c.viewEnable.subs=!1,c.viewEnable(!1),c.viewEnable.subs=!0)},a)},this)}},hb.prototype.onBuild=function(){this.processing(!0),Ob.remote().getTwoFactor(this.onResult)},Cb.addSettingsViewModel(ib,"SettingsSocial","SETTINGS_LABELS/LABEL_SOCIAL_NAME","social"),Cb.addSettingsViewModel(jb,"SettingsChangePassword","SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME","change-password"),jb.prototype.onHide=function(){this.changeProcess(!1),this.currentPassword(""),this.newPassword("")},jb.prototype.onChangePasswordResponse=function(a,b){this.changeProcess(!1),Ab.StorageResultType.Success===a&&b&&b.Result?(this.currentPassword(""),this.newPassword(""),this.passwordUpdateSuccess(!0)):this.passwordUpdateError(!0)},Cb.addSettingsViewModel(kb,"SettingsFolders","SETTINGS_LABELS/LABEL_FOLDERS_NAME","folders"),kb.prototype.folderEditOnEnter=function(a){var b=a?Cb.trim(a.nameForEdit()):"";""!==b&&a.name()!==b&&(Ob.local().set(Ab.ClientSideKeyName.FoldersLashHash,""),Ob.data().foldersRenaming(!0),Ob.remote().folderRename(function(a,b){Ob.data().foldersRenaming(!1),Ab.StorageResultType.Success===a&&b&&b.Result||Ob.data().foldersListError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER")),Ob.folders()},a.fullNameRaw,b),Ob.cache().removeFolderFromCacheList(a.fullNameRaw),a.name(b)),a.edited(!1)},kb.prototype.folderEditOnEsc=function(a){a&&a.edited(!1)},kb.prototype.onShow=function(){Ob.data().foldersListError("")},kb.prototype.createFolder=function(){Hb.showScreenPopup(G)},kb.prototype.systemFolder=function(){Hb.showScreenPopup(H)},kb.prototype.deleteFolder=function(a){if(a&&a.canBeDeleted()&&a.deleteAccess()&&0===a.privateMessageCountAll()){this.folderForDeletion(null);var b=function(c){return a===c?!0:(c.subFolders.remove(b),!1)};a&&(Ob.local().set(Ab.ClientSideKeyName.FoldersLashHash,""),Ob.data().folderList.remove(b),Ob.data().foldersDeleting(!0),Ob.remote().folderDelete(function(a,b){Ob.data().foldersDeleting(!1),Ab.StorageResultType.Success===a&&b&&b.Result||Ob.data().foldersListError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER")),Ob.folders()},a.fullNameRaw),Ob.cache().removeFolderFromCacheList(a.fullNameRaw))}else 0<a.privateMessageCountAll()&&Ob.data().foldersListError(Cb.getNotification(Ab.Notification.CantDeleteNonEmptyFolder))},kb.prototype.subscribeFolder=function(a){Ob.local().set(Ab.ClientSideKeyName.FoldersLashHash,""),Ob.remote().folderSetSubscribe(Cb.emptyFunction,a.fullNameRaw,!0),a.subScribed(!0)},kb.prototype.unSubscribeFolder=function(a){Ob.local().set(Ab.ClientSideKeyName.FoldersLashHash,""),Ob.remote().folderSetSubscribe(Cb.emptyFunction,a.fullNameRaw,!1),a.subScribed(!1)},Cb.addSettingsViewModel(lb,"SettingsThemes","SETTINGS_LABELS/LABEL_THEMES_NAME","themes"),lb.prototype.removeCustomThemeImg=function(){this.customThemeImg("")},lb.prototype.onBuild=function(){var a=this,b=Ob.data().theme();this.themesObjects(h.map(Ob.data().themes(),function(a){return{name:a,nameDisplay:Cb.convertThemeName(a),selected:c.observable(a===b),themePreviewSrc:Ob.link().themePreviewLink(a)}})),h.delay(function(){a.customThemeType.subscribe(function(a){Ob.remote().saveSettings(function(){Ob.data().theme.valueHasMutated()},{CustomThemeType:a})}),a.customThemeImg.subscribe(function(a){Ob.remote().saveSettings(function(){Ob.data().theme.valueHasMutated()},{CustomThemeImg:a})})},50),this.initCustomThemeUploader()},lb.prototype.initCustomThemeUploader=function(){if(this.customThemeUploaderButton()){var b=new g({action:Ob.link().uploadBackground(),name:"uploader",queueSize:1,multipleSizeLimit:1,disableFolderDragAndDrop:!0,clickElement:this.customThemeUploaderButton()});return b.on("onSelect",h.bind(function(b,c){var d=Cb.isUnd(c.FileName)?"":c.FileName.toString(),e=d.substring(d.length-4,d.length),f=Cb.isNormal(c.Size)?Cb.pInt(c.Size):null;return-1===Cb.inArray(e,["jpeg",".jpg",".png"])?(a.alert(Cb.i18n("SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR")),!1):f>1048576?(a.alert(Cb.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(d&&d.ErrorCode?Cb.getUploadErrorDescByCode(d.ErrorCode):Cb.getUploadErrorDescByCode(Ab.UploadErrorCode.Unknown)),this.customThemeUploaderProgress(!1)},this)),!!b}return!1},Cb.addSettingsViewModel(mb,"SettingsOpenPGP","SETTINGS_LABELS/LABEL_OPEN_PGP_NAME","openpgp"),mb.prototype.addOpenPgpKey=function(){Hb.showScreenPopup(M)},mb.prototype.generateOpenPgpKey=function(){Hb.showScreenPopup(O)},mb.prototype.viewOpenPgpKey=function(a){a&&Hb.showScreenPopup(N,[a])},mb.prototype.deleteOpenPgpKey=function(a){if(a&&a.deleteAccess()){this.openPgpKeyForDeletion(null);var b=-1,c=Ob.data().openpgpKeyring,d=function(b){return a===b};a&&c&&(this.openpgpkeys.remove(d),h.each(c.keys,function(c,d){-1===b&&c&&c.primaryKey&&a.guid===c.primaryKey.getFingerprint()&&a.isPrivate===c.isPrivate()&&(b=d)}),b>=0&&c.removeKey(b),c.store(),Ob.reloadOpenPgpKeys())}},nb.prototype.populateDataOnStart=function(){var a=Cb.pInt(Ob.settingsGet("Layout")),b=Ob.settingsGet("Languages"),c=Ob.settingsGet("Themes");Cb.isArray(b)&&this.languages(b),Cb.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.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(Ab.Layout.SidePreview),-1<Cb.inArray(a,[Ab.Layout.NoPreview,Ab.Layout.SidePreview,Ab.Layout.BottomPreview])&&this.layout(a),this.facebookEnable(!!Ob.settingsGet("AllowFacebookSocial")),this.facebookAppID(Ob.settingsGet("FacebookAppID")),this.facebookAppSecret(Ob.settingsGet("FacebookAppSecret")),this.twitterEnable(!!Ob.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(Ob.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(Ob.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!Ob.settingsGet("AllowGoogleSocial")),this.googleClientID(Ob.settingsGet("GoogleClientID")),this.googleClientSecret(Ob.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!Ob.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(Ob.settingsGet("DropboxApiKey")),this.contactsIsAllowed(!!Ob.settingsGet("ContactsIsAllowed"))},h.extend(ob.prototype,nb.prototype),ob.prototype.purgeMessageBodyCache=function(){var a=0,c=null,d=Fb.iMessageBodyCacheCount-zb.Values.MessageBodyCacheLimit;d>0&&(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)))},ob.prototype.populateDataOnStart=function(){nb.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(Ab.ClientSideKeyName.FoldersLashHash)||"",this.remoteSuggestions=!!Ob.settingsGet("RemoteSuggestions"),this.devEmail=Ob.settingsGet("DevEmail"),this.devLogin=Ob.settingsGet("DevLogin"),this.devPassword=Ob.settingsGet("DevPassword")},ob.prototype.initUidNextAndNewMessages=function(b,c,d){if("INBOX"===b&&Cb.isNormal(c)&&""!==c){if(Cb.isArray(d)&&0<d.length){var e=Ob.cache(),f=0,g=d.length,i=function(b,c,d){var e=null;Nb&&Ob.data().useDesktopNotifications()&&(e=new Nb(c,{body:d,icon:b}),e&&(e.show&&e.show(),a.setTimeout(function(a){return function(){a.cancel?a.cancel():a.close&&a.close()}}(e),7e3)))};if(h.each(d,function(a){e.addNewMessageCache(b,a.Uid)}),g>3)i(Ob.link().notificationMailIcon(),Ob.data().accountEmail(),Cb.i18n("MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION",{COUNT:g}));else for(;g>f;f++)i(Ob.link().notificationMailIcon(),A.emailsToLine(A.initEmailsFromJson(d[f].From),!1),d[f].Subject)}Ob.cache().setFolderUidNext(b,c)}},ob.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=B.newInstanceFromJson(e),f&&(Ob.cache().setFolderToCacheList(g,f),Ob.cache().setFolderFullNameRaw(f.fullNameHash,g),f.isGmailFolder=zb.Values.GmailFolderName.toLowerCase()===g.toLowerCase(),""!==a&&a===f.fullNameRaw+f.delimiter&&(f.isNamespaceFolder=!0),(f.isNamespaceFolder||f.isGmailFolder)&&(f.isUnpaddigFolder=!0))),f&&(f.collapsed(!Cb.isFolderExpanded(f.fullNameHash)),e.Extended&&(e.Extended.Hash&&Ob.cache().setFolderHash(f.fullNameRaw,e.Extended.Hash),Cb.isNormal(e.Extended.MessageCount)&&f.messageCountAll(e.Extended.MessageCount),Cb.isNormal(e.Extended.MessageUnseenCount)&&f.messageCountUnread(e.Extended.MessageUnseenCount)),h=e.SubFolders,h&&"Collection/FolderCollection"===h["@Object"]&&h["@Collection"]&&Cb.isArray(h["@Collection"])&&f.subFolders(this.folderResponseParseRec(a,h["@Collection"])),i.push(f)));return i},ob.prototype.setFolders=function(a){var b=[],c=!1,d=Ob.data(),e=function(a){return""===a||zb.Values.UnuseOptionValue===a||null!==Ob.cache().getFolderFromCacheList(a)?a:""};a&&a.Result&&"Collection/FolderCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Cb.isArray(a.Result["@Collection"])&&(Cb.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(Cb.emptyFunction,{SentFolder:d.sentFolder(),DraftFolder:d.draftFolder(),SpamFolder:d.spamFolder(),TrashFolder:d.trashFolder(),ArchiveFolder:d.archiveFolder(),NullFolder:"NullFolder"}),Ob.local().set(Ab.ClientSideKeyName.FoldersLashHash,a.Result.FoldersHash))},ob.prototype.hideMessageBodies=function(){var a=this.messagesBodiesDom();a&&a.find(".b-text-part").hide()},ob.prototype.getNextFolderNames=function(a){a=Cb.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&&0<b.subFolders().length&&i(b.subFolders())})};return i(this.folderList()),g.sort(function(a,b){return a[0]<b[0]?-1:a[0]>b[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)},ob.prototype.removeMessagesFromList=function(a,b,c,d){c=Cb.isNormal(c)?c:"",d=Cb.isUnd(d)?!1:!!d,b=h.map(b,function(a){return Cb.pInt(a)});var e=0,f=Ob.data(),g=Ob.cache(),i=!1,j=f.messageList(),k=Ob.cache().getFolderFromCacheList(a),l=""===c?null:g.getFolderFromCacheList(c||""),m=f.currentFolderFullNameRaw(),n=f.message(),o=m===a?h.filter(j,function(a){return a&&-1<Cb.inArray(Cb.pInt(a.uid),b)}):[];h.each(o,function(a){a&&a.unseen()&&e++,a.selected()&&(i=!0)}),k&&!d&&(k.messageCountAll(0<=k.messageCountAll()-b.length?k.messageCountAll()-b.length:0),e>0&&k.messageCountUnread(0<=k.messageCountUnread()-e?k.messageCountUnread()-e:0)),l&&(l.messageCountAll(l.messageCountAll()+b.length),e>0&&l.messageCountUnread(l.messageCountUnread()+e),l.actionBlink(!0)),0<o.length&&(d?h.each(o,function(a){a.checked(!1)}):(f.messageListIsNotCompleted(!0),h.each(o,function(a){n&&n.hash===a.hash&&(n=null,f.message(null)),a.deleted(!0)}),h.delay(function(){h.each(o,function(a){f.messageList.remove(a)})},400))),""!==a&&g.setFolderHash(a,""),""!==c&&g.setFolderHash(c,"")},ob.prototype.setMessage=function(a,c){var d=!1,e=!1,f=!1,g=null,h=null,i="",j="",k=!1,l=!1,m=this.messagesBodiesDom(),n=this.message();a&&n&&a.Result&&"Object/Message"===a.Result["@Object"]&&n.folderFullNameRaw===a.Result.Folder&&n.uid===a.Result.Uid&&(this.messageError(""),n.initUpdateByMessageJson(a.Result),Ob.cache().addRequestedMessage(n.folderFullNameRaw,n.uid),c||n.initFlagsByJson(a.Result),m=m&&m[0]?m:null,m&&(i="rl-mgs-"+n.hash.replace(/[^a-zA-Z0-9]/g,""),h=m.find("#"+i),h&&h[0]?(n.body=h,n.body&&(n.body.data("rl-cache-count",++Fb.iMessageBodyCacheCount),n.fetchDataToDom())):(e=!!a.Result.HasExternals,f=!!a.Result.HasInternals,g=b('<div id="'+i+'" />').hide().addClass("rl-cache-class"),g.data("rl-cache-count",++Fb.iMessageBodyCacheCount),Cb.isNormal(a.Result.Html)&&""!==a.Result.Html?(d=!0,g.html(a.Result.Html.toString()).addClass("b-text-part html")):Cb.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(d=!1,j=a.Result.Plain.toString(),(n.isPgpSigned()||n.isPgpEncrypted())&&Ob.data().allowOpenPGP()&&Cb.isNormal(a.Result.PlainRaw)&&(n.plainRaw=Cb.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('<pre class="b-plain-openpgp signed"></pre>').text(n.plainRaw)).html():l&&n.isPgpEncrypted()&&(j=Pb.append(b('<pre class="b-plain-openpgp encrypted"></pre>').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(Ab.SignedVerifyStatus.None),n.pgpSignedVerifyUser(""),a.Result.Rtl&&(this.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&&Cb.initBlockquoteSwitcher(g)),Ob.cache().initMessageFlagsFromCache(n),n.unseen()&&Ob.setMessageSeen(n),Cb.windowResize())},ob.prototype.calculateMessageListHash=function(a){return h.map(a,function(a){return""+a.hash+"_"+a.threadsLen()+"_"+a.flagHash()}).join("|")},ob.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&Cb.isArray(a.Result["@Collection"])){var c=Ob.data(),d=Ob.cache(),e=null,g=0,h=0,i=0,j=0,k=[],l=[],m=f().unix(),n=c.staticMessageList,o=null,p=null,q=null,r=0,s=!1;for(i=Cb.pInt(a.Result.MessageResultCount),j=Cb.pInt(a.Result.Offset),Cb.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(e=a.Result.LastCollapsedThreadUids),q=Ob.cache().getFolderFromCacheList(Cb.isNormal(a.Result.Folder)?a.Result.Folder:""),q&&!b&&(q.interval=m,Ob.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),Cb.isNormal(a.Result.MessageCount)&&q.messageCountAll(a.Result.MessageCount),Cb.isNormal(a.Result.MessageUnseenCount)&&(Cb.pInt(q.messageCountUnread())!==Cb.pInt(a.Result.MessageUnseenCount)&&(s=!0),q.messageCountUnread(a.Result.MessageUnseenCount)),this.initUidNextAndNewMessages(q.fullNameRaw,a.Result.UidNext,a.Result.NewMessages)),s&&q&&Ob.cache().clearMessageFlagsFromCacheByFolder(q.fullNameRaw),g=0,h=a.Result["@Collection"].length;h>g;g++)o=a.Result["@Collection"][g],o&&"Object/Message"===o["@Object"]&&(p=n[g],p&&p.initByJson(o)||(p=A.newInstanceFromJson(o)),p&&(d.hasNewMessageAndRemoveFromCache(p.folderFullNameRaw,p.uid)&&5>=r&&(r++,p.newForAnimation(!0)),p.deleted(!1),b?Ob.cache().initMessageFlagsFromCache(p):Ob.cache().storeMessageFlagsToCache(p),p.lastInCollapsedThread(e&&-1<Cb.inArray(Cb.pInt(p.uid),e)?!0:!1),l.push(p)));c.messageListCount(i),c.messageListSearch(Cb.isNormal(a.Result.Search)?a.Result.Search:""),c.messageListEndSearch(Cb.isNormal(a.Result.Search)?a.Result.Search:""),c.messageListEndFolder(Cb.isNormal(a.Result.Folder)?a.Result.Folder:""),c.messageListPage(Math.ceil(j/c.messagesPerPage()+1)),k=c.messageList(),k.length!==l.length?c.messageList(l):this.calculateMessageListHash(k)!==this.calculateMessageListHash(l)&&c.messageList(l),k=[],c.messageListIsNotCompleted(!1),p=c.message(),n.length<l.length&&(c.staticMessageList=l),d.clearNewMessageCache(),q&&(b||s||Ob.data().useThreads())&&Ob.folderInformation(q.fullNameRaw,l)}else Ob.data().messageListCount(0),Ob.data().messageList([]),Ob.data().messageListError(Cb.getNotification(a&&a.ErrorCode?a.ErrorCode:Ab.Notification.CantGetMessageList))},ob.prototype.findPublicKeyByHex=function(a){return h.find(this.openpgpkeysPublic(),function(b){return b&&a===b.id})},ob.prototype.findPublicKeysByEmail=function(b){return h.compact(h.map(this.openpgpkeysPublic(),function(c){var d=null;if(c&&b===c.email)try{if(d=a.openpgp.key.readArmored(c.armor),d&&!d.err&&d.keys&&d.keys[0])return d.keys[0]}catch(e){}return null}))},ob.prototype.findPrivateKeyByEmail=function(b,c){var d=null,e=h.find(this.openpgpkeysPrivate(),function(a){return a&&b===a.email});if(e)try{d=a.openpgp.key.readArmored(e.armor),d&&!d.err&&d.keys&&d.keys[0]?(d=d.keys[0],d.decrypt(Cb.pString(c))):d=null}catch(f){d=null}return d},ob.prototype.findSelfPrivateKey=function(a){return this.findPrivateKeyByEmail(this.accountEmail(),a)},pb.prototype.oRequests={},pb.prototype.defaultResponse=function(b,c,d,e,f,g){var i=function(){Ab.StorageResultType.Success!==d&&Fb.bUnload&&(d=Ab.StorageResultType.Unload),Ab.StorageResultType.Success===d&&e&&!e.Result?(e&&-1<Cb.inArray(e.ErrorCode,[Ab.Notification.AuthError,Ab.Notification.AccessError,Ab.Notification.ConnectionError,Ab.Notification.DomainNotAllowed,Ab.Notification.AccountNotAllowed,Ab.Notification.MailServerError,Ab.Notification.UnknownNotification,Ab.Notification.UnknownError])&&Fb.iAjaxErrorCount++,e&&Ab.Notification.InvalidToken===e.ErrorCode&&Fb.iTokenErrorCount++,zb.Values.TokenErrorLimit<Fb.iTokenErrorCount&&Ob.loginAndLogoutReload(!0),(e.Logout||zb.Values.AjaxErrorLimit<Fb.iAjaxErrorCount)&&(a.__rlah_clear&&a.__rlah_clear(),Ob.loginAndLogoutReload(!0))):Ab.StorageResultType.Success===d&&e&&e.Result&&(Fb.iAjaxErrorCount=0,Fb.iTokenErrorCount=0),b&&(Db.runHook("ajax-default-response",[c,Ab.StorageResultType.Success===d?e:null,d,f,g]),b(d,Ab.StorageResultType.Success===d?e:null,f,c,g))};switch(d){case"success":d=Ab.StorageResultType.Success;break;case"abort":d=Ab.StorageResultType.Abort;break;default:d=Ab.StorageResultType.Error}Ab.StorageResultType.Error===d?h.delay(i,300):i()},pb.prototype.ajaxRequest=function(c,d,e,f,g){var i=this,j=""===f,k={},l=(new a.Date).getTime(),m=null,n="";return d=d||{},e=Cb.isNormal(e)?e:2e4,f=Cb.isUnd(f)?"":Cb.pString(f),g=Cb.isArray(g)?g:[],n=d.Action||"",n&&0<g.length&&h.each(g,function(a){i.oRequests[a]&&(i.oRequests[a].__aborted=!0,i.oRequests[a].abort&&i.oRequests[a].abort(),i.oRequests[a]=null)}),j&&(d.XToken=Ob.settingsGet("Token")),m=b.ajax({type:j?"POST":"GET",url:Ob.link().ajax(f),async:!0,dataType:"json",data:j?d:{},headers:k,timeout:e,global:!0}),m.always(function(b,e){var f=!1;b&&b.Time&&(f=Cb.pInt(b.Time)>(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&&0<g.length&&-1<Cb.inArray(n,g)&&(this.oRequests[n]&&(this.oRequests[n].__aborted=!0,this.oRequests[n].abort&&this.oRequests[n].abort(),this.oRequests[n]=null),this.oRequests[n]=m),m},pb.prototype.defaultRequest=function(a,b,c,d,e,f){c=c||{},c.Action=b,e=Cb.pString(e),Db.runHook("ajax-default-request",[b,c,e]),this.ajaxRequest(a,c,Cb.isUnd(d)?zb.Defaults.DefaultAjaxTimeout:Cb.pInt(d),e,f)},pb.prototype.noop=function(a){this.defaultRequest(a,"Noop")},pb.prototype.jsError=function(a,b,c,d,e,f,g){this.defaultRequest(a,"JsError",{Message:b,FileName:c,LineNo:d,Location:e,HtmlCapa:f,TimeOnPage:g})
},pb.prototype.jsInfo=function(a,b,c,d){this.defaultRequest(a,"JsInfo",{Type:b,Data:c,IsError:(Cb.isUnd(d)?1:!d)?"0":"1"})},pb.prototype.jsVersion=function(a,b){this.defaultRequest(a,"Version",{Version:b})},h.extend(qb.prototype,pb.prototype),qb.prototype.folders=function(a){this.defaultRequest(a,"Folders",{SentFolder:Ob.settingsGet("SentFolder"),DraftFolder:Ob.settingsGet("DraftFolder"),SpamFolder:Ob.settingsGet("SpamFolder"),TrashFolder:Ob.settingsGet("TrashFolder"),ArchiveFolder:Ob.settingsGet("ArchiveFolder")},null,"",["Folders"])},qb.prototype.login=function(a,b,c,d,e,f,g){this.defaultRequest(a,"Login",{Email:b,Login:c,Password:d,Language:f||"",AdditionalCode:g||"",SignMe:e?"1":"0"})},qb.prototype.getTwoFactor=function(a){this.defaultRequest(a,"GetTwoFactorInfo")},qb.prototype.createTwoFactor=function(a){this.defaultRequest(a,"CreateTwoFactorSecret")},qb.prototype.clearTwoFactor=function(a){this.defaultRequest(a,"ClearTwoFactorInfo")},qb.prototype.testTwoFactor=function(a,b){this.defaultRequest(a,"TestTwoFactorInfo",{Code:b})},qb.prototype.enableTwoFactor=function(a,b){this.defaultRequest(a,"EnableTwoFactor",{Enable:b?"1":"0"})},qb.prototype.clearTwoFactorInfo=function(a){this.defaultRequest(a,"ClearTwoFactorInfo")},qb.prototype.accountAdd=function(a,b,c,d){this.defaultRequest(a,"AccountAdd",{Email:b,Login:c,Password:d})},qb.prototype.accountDelete=function(a,b){this.defaultRequest(a,"AccountDelete",{EmailToDelete:b})},qb.prototype.identityUpdate=function(a,b,c,d,e,f){this.defaultRequest(a,"IdentityUpdate",{Id:b,Email:c,Name:d,ReplyTo:e,Bcc:f})},qb.prototype.identityDelete=function(a,b){this.defaultRequest(a,"IdentityDelete",{IdToDelete:b})},qb.prototype.accountsAndIdentities=function(a){this.defaultRequest(a,"AccountsAndIdentities")},qb.prototype.messageList=function(a,b,c,d,e,f){b=Cb.pString(b);var g=Ob.data(),h=Ob.cache().getFolderHash(b);f=Cb.isUnd(f)?!1:!!f,c=Cb.isUnd(c)?0:Cb.pInt(c),d=Cb.isUnd(c)?20:Cb.pInt(d),e=Cb.pString(e),""===h||""!==e&&-1!==e.indexOf("has:")?this.defaultRequest(a,"MessageList",{Folder:b,Offset:c,Limit:d,Search:e,UidNext:"INBOX"===b?Ob.cache().getFolderUidNext(b):"",UseThreads:Ob.data().threading()&&Ob.data().useThreads()?"1":"0",ExpandedThreadUid:g.threading()&&b===g.messageListThreadFolder()?g.messageListThreadUids().join(","):""},""===e?zb.Defaults.DefaultAjaxTimeout:zb.Defaults.SearchAjaxTimeout,"",f?[]:["MessageList"]):this.defaultRequest(a,"MessageList",{},""===e?zb.Defaults.DefaultAjaxTimeout:zb.Defaults.SearchAjaxTimeout,"MessageList/"+Eb.urlsafe_encode([b,c,d,e,g.projectHash(),h,"INBOX"===b?Ob.cache().getFolderUidNext(b):"",g.threading()&&g.useThreads()?"1":"0",g.threading()&&b===g.messageListThreadFolder()?g.messageListThreadUids().join(","):""].join(String.fromCharCode(0))),f?[]:["MessageList"])},qb.prototype.messageUploadAttachments=function(a,b){this.defaultRequest(a,"MessageUploadAttachments",{Attachments:b},999e3)},qb.prototype.message=function(a,b,c){return b=Cb.pString(b),c=Cb.pInt(c),Ob.cache().getFolderFromCacheList(b)&&c>0?(this.defaultRequest(a,"Message",{},null,"Message/"+Eb.urlsafe_encode([b,c,Ob.data().projectHash(),Ob.data().threading()&&Ob.data().useThreads()?"1":"0"].join(String.fromCharCode(0))),["Message"]),!0):!1},qb.prototype.composeUploadExternals=function(a,b){this.defaultRequest(a,"ComposeUploadExternals",{Externals:b},999e3)},qb.prototype.folderInformation=function(a,b,c){var d=!0,e=Ob.cache(),f=[];Cb.isArray(c)&&0<c.length&&(d=!1,h.each(c,function(a){e.getMessageFlagsFromCache(a.folderFullNameRaw,a.uid)||f.push(a.uid),0<a.threads().length&&h.each(a.threads(),function(b){e.getMessageFlagsFromCache(a.folderFullNameRaw,b)||f.push(b)})}),0<f.length&&(d=!0)),d?this.defaultRequest(a,"FolderInformation",{Folder:b,FlagsUids:Cb.isArray(f)?f.join(","):"",UidNext:"INBOX"===b?Ob.cache().getFolderUidNext(b):""}):Ob.data().useThreads()&&Ob.reloadFlagsCurrentMessageListAndMessageFromCache()},qb.prototype.folderInformationMultiply=function(a,b){this.defaultRequest(a,"FolderInformationMultiply",{Folders:b})},qb.prototype.logout=function(a){this.defaultRequest(a,"Logout")},qb.prototype.messageSetFlagged=function(a,b,c,d){this.defaultRequest(a,"MessageSetFlagged",{Folder:b,Uids:c.join(","),SetAction:d?"1":"0"})},qb.prototype.messageSetSeen=function(a,b,c,d){this.defaultRequest(a,"MessageSetSeen",{Folder:b,Uids:c.join(","),SetAction:d?"1":"0"})},qb.prototype.messageSetSeenToAll=function(a,b,c){this.defaultRequest(a,"MessageSetSeenToAll",{Folder:b,SetAction:c?"1":"0"})},qb.prototype.saveMessage=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){this.defaultRequest(a,"SaveMessage",{MessageFolder:b,MessageUid:c,DraftFolder:d,From:e,To:f,Cc:g,Bcc:h,Subject:i,TextIsHtml:j?"1":"0",Text:k,DraftInfo:m,InReplyTo:n,References:o,Attachments:l},zb.Defaults.SaveMessageAjaxTimeout)},qb.prototype.sendReadReceiptMessage=function(a,b,c,d,e,f){this.defaultRequest(a,"SendReadReceiptMessage",{MessageFolder:b,MessageUid:c,ReadReceipt:d,Subject:e,Text:f})},qb.prototype.sendMessage=function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){this.defaultRequest(a,"SendMessage",{MessageFolder:b,MessageUid:c,SentFolder:d,From:e,To:f,Cc:g,Bcc:h,Subject:i,TextIsHtml:j?"1":"0",Text:k,DraftInfo:m,InReplyTo:n,References:o,ReadReceiptRequest:p?"1":"0",Attachments:l},zb.Defaults.SendMessageAjaxTimeout)},qb.prototype.saveSystemFolders=function(a,b){this.defaultRequest(a,"SystemFoldersUpdate",b)},qb.prototype.saveSettings=function(a,b){this.defaultRequest(a,"SettingsUpdate",b)},qb.prototype.changePassword=function(a,b,c){this.defaultRequest(a,"ChangePassword",{PrevPassword:b,NewPassword:c})},qb.prototype.folderCreate=function(a,b,c){this.defaultRequest(a,"FolderCreate",{Folder:b,Parent:c},null,"",["Folders"])},qb.prototype.folderDelete=function(a,b){this.defaultRequest(a,"FolderDelete",{Folder:b},null,"",["Folders"])},qb.prototype.folderRename=function(a,b,c){this.defaultRequest(a,"FolderRename",{Folder:b,NewFolderName:c},null,"",["Folders"])},qb.prototype.folderClear=function(a,b){this.defaultRequest(a,"FolderClear",{Folder:b})},qb.prototype.folderSetSubscribe=function(a,b,c){this.defaultRequest(a,"FolderSubscribe",{Folder:b,Subscribe:c?"1":"0"})},qb.prototype.messagesMove=function(a,b,c,d){this.defaultRequest(a,"MessageMove",{FromFolder:b,ToFolder:c,Uids:d.join(",")},null,"",["MessageList"])},qb.prototype.messagesCopy=function(a,b,c,d){this.defaultRequest(a,"MessageCopy",{FromFolder:b,ToFolder:c,Uids:d.join(",")})},qb.prototype.messagesDelete=function(a,b,c){this.defaultRequest(a,"MessageDelete",{Folder:b,Uids:c.join(",")},null,"",["MessageList"])},qb.prototype.appDelayStart=function(a){this.defaultRequest(a,"AppDelayStart")},qb.prototype.quota=function(a){this.defaultRequest(a,"Quota")},qb.prototype.contacts=function(a,b,c,d){this.defaultRequest(a,"Contacts",{Offset:b,Limit:c,Search:d},null,"",["Contacts"])},qb.prototype.contactSave=function(a,b,c,d,e,f){this.defaultRequest(a,"ContactSave",{RequestUid:b,Uid:Cb.trim(c),UidStr:Cb.trim(d),ScopeType:e,Properties:f})},qb.prototype.contactsDelete=function(a,b){this.defaultRequest(a,"ContactsDelete",{Uids:b.join(",")})},qb.prototype.suggestions=function(a,b,c){this.defaultRequest(a,"Suggestions",{Query:b,Page:c},null,"",["Suggestions"])},qb.prototype.servicesPics=function(a){this.defaultRequest(a,"ServicesPics")},qb.prototype.emailsPicsHashes=function(a){this.defaultRequest(a,"EmailsPicsHashes")},qb.prototype.facebookUser=function(a){this.defaultRequest(a,"SocialFacebookUserInformation")},qb.prototype.facebookDisconnect=function(a){this.defaultRequest(a,"SocialFacebookDisconnect")},qb.prototype.twitterUser=function(a){this.defaultRequest(a,"SocialTwitterUserInformation")},qb.prototype.twitterDisconnect=function(a){this.defaultRequest(a,"SocialTwitterDisconnect")},qb.prototype.googleUser=function(a){this.defaultRequest(a,"SocialGoogleUserInformation")},qb.prototype.googleDisconnect=function(a){this.defaultRequest(a,"SocialGoogleDisconnect")},qb.prototype.socialUsers=function(a){this.defaultRequest(a,"SocialUsers")},rb.prototype.oEmailsPicsHashes={},rb.prototype.oServices={},rb.prototype.clear=function(){this.oServices={},this.oEmailsPicsHashes={}},rb.prototype.getUserPic=function(a){var b="",c="",d=a.toLowerCase(),e=Cb.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];return""===e?(c=d.substr(a.indexOf("@")+1),b=""!==c&&this.oServices[c]?this.oServices[c]:""):b=Ob.link().getUserPicUrlFromHash(e),b},rb.prototype.setServicesData=function(a){this.oServices=a},rb.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a},h.extend(sb.prototype,rb.prototype),sb.prototype.oFoldersCache={},sb.prototype.oFoldersNamesCache={},sb.prototype.oFolderHashCache={},sb.prototype.oFolderUidNextCache={},sb.prototype.oMessageListHashCache={},sb.prototype.oMessageFlagsCache={},sb.prototype.oBodies={},sb.prototype.oNewMessage={},sb.prototype.oRequestedMessage={},sb.prototype.clear=function(){rb.prototype.clear.call(this),this.oFoldersCache={},this.oFoldersNamesCache={},this.oFolderHashCache={},this.oFolderUidNextCache={},this.oMessageListHashCache={},this.oMessageFlagsCache={},this.oBodies={}},sb.prototype.getMessageKey=function(a,b){return a+"#"+b},sb.prototype.addRequestedMessage=function(a,b){this.oRequestedMessage[this.getMessageKey(a,b)]=!0},sb.prototype.hasRequestedMessage=function(a,b){return!0===this.oRequestedMessage[this.getMessageKey(a,b)]},sb.prototype.addNewMessageCache=function(a,b){this.oNewMessage[this.getMessageKey(a,b)]=!0},sb.prototype.hasNewMessageAndRemoveFromCache=function(a,b){return this.oNewMessage[this.getMessageKey(a,b)]?(this.oNewMessage[this.getMessageKey(a,b)]=null,!0):!1},sb.prototype.clearNewMessageCache=function(){this.oNewMessage={}},sb.prototype.getFolderFullNameRaw=function(a){return""!==a&&this.oFoldersNamesCache[a]?this.oFoldersNamesCache[a]:""},sb.prototype.setFolderFullNameRaw=function(a,b){this.oFoldersNamesCache[a]=b},sb.prototype.getFolderHash=function(a){return""!==a&&this.oFolderHashCache[a]?this.oFolderHashCache[a]:""},sb.prototype.setFolderHash=function(a,b){this.oFolderHashCache[a]=b},sb.prototype.getFolderUidNext=function(a){return""!==a&&this.oFolderUidNextCache[a]?this.oFolderUidNextCache[a]:""},sb.prototype.setFolderUidNext=function(a,b){this.oFolderUidNextCache[a]=b},sb.prototype.getFolderFromCacheList=function(a){return""!==a&&this.oFoldersCache[a]?this.oFoldersCache[a]:null},sb.prototype.setFolderToCacheList=function(a,b){this.oFoldersCache[a]=b},sb.prototype.removeFolderFromCacheList=function(a){this.setFolderToCacheList(a,null)},sb.prototype.getMessageFlagsFromCache=function(a,b){return this.oMessageFlagsCache[a]&&this.oMessageFlagsCache[a][b]?this.oMessageFlagsCache[a][b]:null},sb.prototype.setMessageFlagsToCache=function(a,b,c){this.oMessageFlagsCache[a]||(this.oMessageFlagsCache[a]={}),this.oMessageFlagsCache[a][b]=c},sb.prototype.clearMessageFlagsFromCacheByFolder=function(a){this.oMessageFlagsCache[a]={}},sb.prototype.initMessageFlagsFromCache=function(a){if(a){var b=this,c=this.getMessageFlagsFromCache(a.folderFullNameRaw,a.uid),d=null,e=null;c&&0<c.length&&(a.unseen(!!c[0]),a.flagged(!!c[1]),a.answered(!!c[2]),a.forwarded(!!c[3]),a.isReadReceipt(!!c[4])),0<a.threads().length&&(d=h.find(a.threads(),function(c){var d=b.getMessageFlagsFromCache(a.folderFullNameRaw,c);return d&&0<d.length&&!!d[0]}),e=h.find(a.threads(),function(c){var d=b.getMessageFlagsFromCache(a.folderFullNameRaw,c);return d&&0<d.length&&!!d[1]}),a.hasUnseenSubMessage(d&&0<Cb.pInt(d)),a.hasFlaggedSubMessage(e&&0<Cb.pInt(e)))}},sb.prototype.storeMessageFlagsToCache=function(a){a&&this.setMessageFlagsToCache(a.folderFullNameRaw,a.uid,[a.unseen(),a.flagged(),a.answered(),a.forwarded(),a.isReadReceipt()])},sb.prototype.storeMessageFlagsToCacheByFolderAndUid=function(a,b,c){Cb.isArray(c)&&0<c.length&&this.setMessageFlagsToCache(a,b,c)},h.extend(tb.prototype,t.prototype),tb.prototype.onRoute=function(a){var d=this,e=null,f=null,g=null,i=null;f=h.find(Gb.settings,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}),f&&(h.find(Gb["settings-removed"],function(a){return a&&a===f})&&(f=null),f&&h.find(Gb["settings-disabled"],function(a){return a&&a===f})&&(f=null)),f?(f.__builded&&f.__vm?e=f.__vm:(g=this.oViewModelPlace,g&&1===g.length?(f=f,e=new f,i=b("<div></div>").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]),Cb.delegateRun(e,"onBuild",[i])):Cb.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&h.defer(function(){d.oCurrentSubScreen&&(Cb.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),Cb.delegateRun(d.oCurrentSubScreen,"onShow"),Cb.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)),Cb.windowResize()})):Hb.setHash(Ob.link().settings(),!1,!0)},tb.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(Cb.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},tb.prototype.onBuild=function(){h.each(Gb.settings,function(a){a&&a.__rlSettingsData&&!h.find(Gb["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(Gb["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},tb.prototype.routes=function(){var a=h.find(Gb.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=Cb.isUnd(c.subname)?b:Cb.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},h.extend(ub.prototype,t.prototype),ub.prototype.onShow=function(){Ob.setTitle("")},h.extend(vb.prototype,t.prototype),vb.prototype.oLastRoute={},vb.prototype.setNewTitle=function(){var a=Ob.data().accountEmail(),b=Ob.data().foldersInboxUnreadCount();Ob.setTitle((""===a?"":(b>0?"("+b+") ":" ")+a+" - ")+Cb.i18n("TITLES/MAILBOX"))},vb.prototype.onShow=function(){this.setNewTitle(),Ob.data().keyScope(Ab.KeyState.MessageList)},vb.prototype.onHide=function(){Ob.data().keyScope(Ab.KeyState.All)},vb.prototype.onRoute=function(a,b,c,d){if(Cb.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),Ab.Layout.NoPreview===e.layout()&&e.message()&&(e.message(null),e.messageFullScreenMode(!1)),Ob.reloadMessageList())}else Ab.Layout.NoPreview!==Ob.data().layout()||Ob.data().message()||Ob.historyBack()},vb.prototype.onStart=function(){var a=Ob.data(),b=function(){Cb.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(Cb.emptyFunction)},35e3),Kb.toggleClass("rl-no-preview-pane",Ab.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",Ab.Layout.NoPreview===a)}),a.foldersInboxUnreadCount.subscribe(function(){this.setNewTitle()},this)},vb.prototype.routes=function(){var a=function(){return["Inbox",1,"",!0]},b=function(a,b){return b[0]=Cb.pString(b[0]),b[1]=Cb.pInt(b[1]),b[1]=0>=b[1]?1:b[1],b[2]=Cb.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]=Cb.pString(b[0]),b[1]=Cb.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(wb.prototype,tb.prototype),wb.prototype.onShow=function(){Ob.setTitle(this.sSettingsTitle)},h.extend(xb.prototype,r.prototype),xb.prototype.oSettings=null,xb.prototype.oPlugins=null,xb.prototype.oLocal=null,xb.prototype.oLink=null,xb.prototype.oSubs={},xb.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):(Fb.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},xb.prototype.link=function(){return null===this.oLink&&(this.oLink=new k),this.oLink},xb.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new q),this.oLocal},xb.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=Cb.isNormal(Ib)?Ib:{}),Cb.isUnd(this.oSettings[a])?null:this.oSettings[a]},xb.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=Cb.isNormal(Ib)?Ib:{}),this.oSettings[a]=b},xb.prototype.setTitle=function(b){b=(Cb.isNormal(b)&&0<b.length?b+" - ":"")+Ob.settingsGet("Title")||"",a.document.title="_",a.document.title=b},xb.prototype.loginAndLogoutReload=function(b,c){var d=Cb.pString(Ob.settingsGet("CustomLogoutLink")),e=!!Ob.settingsGet("InIframe");b=Cb.isUnd(b)?!1:!!b,c=Cb.isUnd(c)?!1:!!c,b&&c&&a.close&&a.close(),b&&""!==d&&a.location.href!==d?h.delay(function(){e&&a.parent?a.parent.location.href=d:a.location.href=d},100):(Hb.routeOff(),Hb.setHash(Ob.link().root(),!0),Hb.routeOff(),h.delay(function(){e&&a.parent?a.parent.location.reload():a.location.reload()},100))},xb.prototype.historyBack=function(){a.history.back()},xb.prototype.getAutocomplete=function(a,b){b([],a)},xb.prototype.sub=function(a,b,c){return Cb.isUnd(this.oSubs[a])&&(this.oSubs[a]=[]),this.oSubs[a].push([b,c]),this},xb.prototype.pub=function(a,b){return Db.runHook("rl-pub",[a,b]),Cb.isUnd(this.oSubs[a])||h.each(this.oSubs[a],function(a){a[0]&&a[0].apply(a[1]||null,b||[])}),this},xb.prototype.bootstart=function(){Cb.initOnStartOrLangChange(function(){Cb.initNotificationLanguage()},null),h.delay(function(){Cb.windowResize()},1e3),ssm.addState({id:"mobile",maxWidth:767,onEnter:function(){Kb.addClass("ssm-state-mobile")},onLeave:function(){Kb.removeClass("ssm-state-mobile")}}),ssm.addState({id:"tablet",minWidth:768,maxWidth:999,onEnter:function(){Kb.addClass("ssm-state-tablet")},onLeave:function(){Kb.removeClass("ssm-state-tablet")}}),ssm.addState({id:"desktop",minWidth:1e3,maxWidth:1400,onEnter:function(){Kb.addClass("ssm-state-desktop")},onLeave:function(){Kb.removeClass("ssm-state-desktop")}}),ssm.addState({id:"desktop-large",minWidth:1400,onEnter:function(){Kb.addClass("ssm-state-desktop-large")},onLeave:function(){Kb.removeClass("ssm-state-desktop-large")}}),ssm.ready()},h.extend(yb.prototype,xb.prototype),yb.prototype.oData=null,yb.prototype.oRemote=null,yb.prototype.oCache=null,yb.prototype.data=function(){return null===this.oData&&(this.oData=new ob),this.oData},yb.prototype.remote=function(){return null===this.oRemote&&(this.oRemote=new qb),this.oRemote},yb.prototype.cache=function(){return null===this.oCache&&(this.oCache=new sb),this.oCache},yb.prototype.reloadFlagsCurrentMessageListAndMessageFromCache=function(){var a=Ob.cache();h.each(Ob.data().messageList(),function(b){a.initMessageFlagsFromCache(b)}),a.initMessageFlagsFromCache(Ob.data().message())},yb.prototype.reloadMessageList=function(a,b){var c=Ob.data(),d=(c.messageListPage()-1)*c.messagesPerPage();(Cb.isUnd(b)?1:!b)||Ob.cache().setFolderHash(c.currentFolderFullNameRaw(),""),(Cb.isUnd(a)?1:!a)||(c.messageListPage(1),d=0),c.messageListLoading(!0),Ob.remote().messageList(function(a,b,d){Ab.StorageResultType.Success===a&&b&&b.Result?(c.messageListError(""),c.messageListLoading(!1),c.setMessageList(b,d)):Ab.StorageResultType.Unload===a?(c.messageListError(""),c.messageListLoading(!1)):Ab.StorageResultType.Abort!==a&&(c.messageList([]),c.messageListLoading(!1),c.messageListError(b&&b.ErrorCode?Cb.getNotification(b.ErrorCode):Cb.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST")))},c.currentFolderFullNameRaw(),d,c.messagesPerPage(),c.messageListSearch())},yb.prototype.recacheInboxMessageList=function(){Ob.remote().messageList(Cb.emptyFunction,"INBOX",0,Ob.data().messagesPerPage(),"",!0)},yb.prototype.reloadMessageListHelper=function(a){Ob.reloadMessageList(a)},yb.prototype.messagesMoveTrigger=function(){var a=this;h.each(this.oMoveCache,function(b){Ob.remote().messagesMove(a.moveOrDeleteResponseHelper,b.From,b.To,b.Uid)}),this.oMoveCache={}},yb.prototype.messagesMoveHelper=function(a,b,c){var d="$$"+a+"$$"+b+"$$";this.oMoveCache[d]||(this.oMoveCache[d]={From:a,To:b,Uid:[]}),this.oMoveCache[d].Uid=h.union(this.oMoveCache[d].Uid,c),this.messagesMoveTrigger()},yb.prototype.messagesCopyHelper=function(a,b,c){Ob.remote().messagesCopy(this.moveOrDeleteResponseHelper,a,b,c)},yb.prototype.messagesDeleteHelper=function(a,b){Ob.remote().messagesDelete(this.moveOrDeleteResponseHelper,a,b)},yb.prototype.moveOrDeleteResponseHelper=function(b,c){Ab.StorageResultType.Success===b&&Ob.data().currentFolder()&&(c&&Cb.isArray(c.Result)&&2===c.Result.length?Ob.cache().setFolderHash(c.Result[0],c.Result[1]):(Ob.cache().setFolderHash(Ob.data().currentFolderFullNameRaw(),""),c&&-1<Cb.inArray(c.ErrorCode,[Ab.Notification.CantMoveMessage,Ab.Notification.CantCopyMessage])&&a.alert(Cb.getNotification(c.ErrorCode))),Ob.reloadMessageListHelper(0===Ob.data().messageList().length),Ob.quotaDebounce())},yb.prototype.deleteMessagesFromFolderWithoutCheck=function(a,b){this.messagesDeleteHelper(a,b),Ob.data().removeMessagesFromList(a,b)},yb.prototype.deleteMessagesFromFolder=function(a,b,c,d){var e=this,f=Ob.data(),g=Ob.cache(),h=null,i=null;switch(a){case Ab.FolderType.Spam:h=g.getFolderFromCacheList(f.spamFolder()),i=Ab.SetSystemFoldersNotification.Spam;break;case Ab.FolderType.Trash:h=g.getFolderFromCacheList(f.trashFolder()),i=Ab.SetSystemFoldersNotification.Trash;break;case Ab.FolderType.Archive:h=g.getFolderFromCacheList(f.archiveFolder()),i=Ab.SetSystemFoldersNotification.Archive}d=Cb.isUnd(d)?!0:!!d,d&&(Ab.FolderType.Spam===a&&zb.Values.UnuseOptionValue===f.spamFolder()||Ab.FolderType.Trash===a&&zb.Values.UnuseOptionValue===f.trashFolder()||Ab.FolderType.Archive===a&&zb.Values.UnuseOptionValue===f.archiveFolder())&&(d=!1),!h&&d?Hb.showScreenPopup(H,[i]):d&&(Ab.FolderType.Trash!==a||b!==f.spamFolder()&&b!==f.trashFolder())?h&&(this.messagesMoveHelper(b,h.fullNameRaw,c),f.removeMessagesFromList(b,c,h.fullNameRaw)):Hb.showScreenPopup(T,[Cb.i18n("POPUPS_ASK/DESC_WANT_DELETE_MESSAGES"),function(){e.messagesDeleteHelper(b,c),f.removeMessagesFromList(b,c)}])},yb.prototype.moveMessagesToFolder=function(a,b,c,d){if(a!==c&&Cb.isArray(b)&&0<b.length){var e=Ob.cache().getFolderFromCacheList(a),f=Ob.cache().getFolderFromCacheList(c);if(e&&f)return(Cb.isUnd(d)?1:!d)?this.messagesMoveHelper(e.fullNameRaw,f.fullNameRaw,b):this.messagesCopyHelper(e.fullNameRaw,f.fullNameRaw,b),Ob.data().removeMessagesFromList(e.fullNameRaw,b,f.fullNameRaw,d),!0}return!1},yb.prototype.folders=function(a){this.data().foldersLoading(!0),this.remote().folders(h.bind(function(b,c){Ob.data().foldersLoading(!1),Ab.StorageResultType.Success===b?(this.data().setFolders(c),a&&a(!0)):a&&a(!1)},this))},yb.prototype.reloadOpenPgpKeys=function(){if(Ob.data().allowOpenPGP()){var a=[],b=new v,c=Ob.data().openpgpKeyring,d=c?c.keys:[];h.each(d,function(c,d){if(c&&c.primaryKey){var e=c.getPrimaryUser(),f=e&&e.user?e.user.userId.userid:c.users&&c.users[0]?c.users[0].userId.userid:"";b.clear(),b.mailsoParse(f),b.validate()&&a.push(new E(d,c.primaryKey.getFingerprint(),c.primaryKey.getKeyId().toHex().toLowerCase(),f,b.email,c.isPrivate(),c.armor()))}}),Ob.data().openpgpkeys(a)}},yb.prototype.accountsAndIdentities=function(){var a=Ob.data();a.accountsLoading(!0),a.identitiesLoading(!0),Ob.remote().accountsAndIdentities(function(b,c){if(a.accountsLoading(!1),a.identitiesLoading(!1),Ab.StorageResultType.Success===b&&c.Result){var d=Ob.settingsGet("ParentEmail"),e=a.accountEmail();d=""===d?e:d,Cb.isArray(c.Result.Accounts)&&a.accounts(h.map(c.Result.Accounts,function(a){return new C(a,a!==d)})),Cb.isArray(c.Result.Identities)&&a.identities(h.map(c.Result.Identities,function(a){var b=Cb.pString(a.Id),c=Cb.pString(a.Email),d=new D(b,c,b!==e);return d.name(Cb.pString(a.Name)),d.replyTo(Cb.pString(a.ReplyTo)),d.bcc(Cb.pString(a.Bcc)),d}))}})},yb.prototype.quota=function(){this.remote().quota(function(a,b){Ab.StorageResultType.Success===a&&b&&b.Result&&Cb.isArray(b.Result)&&2===b.Result.length&&Cb.isPosNumeric(b.Result[0],!0)&&Cb.isPosNumeric(b.Result[1],!0)&&(Ob.data().userQuota(1024*Cb.pInt(b.Result[1])),Ob.data().userUsageSize(1024*Cb.pInt(b.Result[0])))})},yb.prototype.folderInformation=function(a,b){""!==Cb.trim(a)&&this.remote().folderInformation(function(a,b){if(Ab.StorageResultType.Success===a&&b&&b.Result&&b.Result.Hash&&b.Result.Folder){var c=f().unix(),d=Ob.cache().getFolderHash(b.Result.Folder),e=Ob.cache().getFolderFromCacheList(b.Result.Folder),g=!1,h="",i=[],j=!1,k=null;if(e){if(e.interval=c,b.Result.Hash&&Ob.cache().setFolderHash(b.Result.Folder,b.Result.Hash),Cb.isNormal(b.Result.MessageCount)&&e.messageCountAll(b.Result.MessageCount),Cb.isNormal(b.Result.MessageUnseenCount)&&(Cb.pInt(e.messageCountUnread())!==Cb.pInt(b.Result.MessageUnseenCount)&&(j=!0),e.messageCountUnread(b.Result.MessageUnseenCount)),j&&Ob.cache().clearMessageFlagsFromCacheByFolder(e.fullNameRaw),b.Result.Flags){for(h in b.Result.Flags)b.Result.Flags.hasOwnProperty(h)&&(g=!0,k=b.Result.Flags[h],Ob.cache().storeMessageFlagsToCacheByFolderAndUid(e.fullNameRaw,h.toString(),[!k.IsSeen,!!k.IsFlagged,!!k.IsAnswered,!!k.IsForwarded,!!k.IsReadReceipt]));g&&Ob.reloadFlagsCurrentMessageListAndMessageFromCache()}Ob.data().initUidNextAndNewMessages(e.fullNameRaw,b.Result.UidNext,b.Result.NewMessages),b.Result.Hash!==d||""===d?e.fullNameRaw===Ob.data().currentFolderFullNameRaw()?Ob.reloadMessageList():"INBOX"===e.fullNameRaw&&Ob.recacheInboxMessageList():j&&e.fullNameRaw===Ob.data().currentFolderFullNameRaw()&&(i=Ob.data().messageList(),Cb.isNonEmptyArray(i)&&Ob.folderInformation(e.fullNameRaw,i))}}},a,b)},yb.prototype.folderInformationMultiply=function(a){a=Cb.isUnd(a)?!1:!!a;var b=f().unix(),c=Ob.data().getNextFolderNames(a);Cb.isNonEmptyArray(c)&&this.remote().folderInformationMultiply(function(c,d){Ab.StorageResultType.Success===c&&d&&d.Result&&d.Result.List&&Cb.isNonEmptyArray(d.Result.List)&&(h.each(d.Result.List,function(a){var c=[],d=Ob.cache().getFolderHash(a.Folder),e=Ob.cache().getFolderFromCacheList(a.Folder),f=!1;e&&(e.interval=b,a.Hash&&Ob.cache().setFolderHash(a.Folder,a.Hash),Cb.isNormal(a.MessageCount)&&e.messageCountAll(a.MessageCount),Cb.isNormal(a.MessageUnseenCount)&&(Cb.pInt(e.messageCountUnread())!==Cb.pInt(a.MessageUnseenCount)&&(f=!0),e.messageCountUnread(a.MessageUnseenCount)),f&&Ob.cache().clearMessageFlagsFromCacheByFolder(e.fullNameRaw),a.Hash!==d||""===d?e.fullNameRaw===Ob.data().currentFolderFullNameRaw()&&Ob.reloadMessageList():f&&e.fullNameRaw===Ob.data().currentFolderFullNameRaw()&&(c=Ob.data().messageList(),Cb.isNonEmptyArray(c)&&Ob.folderInformation(e.fullNameRaw,c)))}),a&&Ob.folderInformationMultiply(!0))},c)},yb.prototype.setMessageSeen=function(a){if(a.unseen()){a.unseen(!1);var b=Ob.cache().getFolderFromCacheList(a.folderFullNameRaw);b&&b.messageCountUnread(0<=b.messageCountUnread()-1?b.messageCountUnread()-1:0),Ob.cache().storeMessageFlagsToCache(a),Ob.reloadFlagsCurrentMessageListAndMessageFromCache()}Ob.remote().messageSetSeen(Cb.emptyFunction,a.folderFullNameRaw,[a.uid],!0)},yb.prototype.googleConnect=function(){a.open(Ob.link().socialGoogle(),"Google","left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes")},yb.prototype.twitterConnect=function(){a.open(Ob.link().socialTwitter(),"Twitter","left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes")},yb.prototype.facebookConnect=function(){a.open(Ob.link().socialFacebook(),"Facebook","left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes")},yb.prototype.socialUsers=function(a){var b=Ob.data();a&&(b.googleActions(!0),b.facebookActions(!0),b.twitterActions(!0)),Ob.remote().socialUsers(function(a,c){Ab.StorageResultType.Success===a&&c&&c.Result?(b.googleUserName(c.Result.Google||""),b.facebookUserName(c.Result.Facebook||""),b.twitterUserName(c.Result.Twitter||"")):(b.googleUserName(""),b.facebookUserName(""),b.twitterUserName("")),b.googleLoggined(""!==b.googleUserName()),b.facebookLoggined(""!==b.facebookUserName()),b.twitterLoggined(""!==b.twitterUserName()),b.googleActions(!1),b.facebookActions(!1),b.twitterActions(!1)})},yb.prototype.googleDisconnect=function(){Ob.data().googleActions(!0),Ob.remote().googleDisconnect(function(){Ob.socialUsers()})},yb.prototype.facebookDisconnect=function(){Ob.data().facebookActions(!0),Ob.remote().facebookDisconnect(function(){Ob.socialUsers()})},yb.prototype.twitterDisconnect=function(){Ob.data().twitterActions(!0),Ob.remote().twitterDisconnect(function(){Ob.socialUsers()})},yb.prototype.folderListOptionsBuilder=function(b,c,d,e,f,g,h,i,j,k){var l=0,m=0,n=null,o="   ",p=[];for(j=Cb.isNormal(j)?j:0<b.length,k=Cb.isUnd(k)?!1:!!k,f=Cb.isNormal(f)?f:0,g=Cb.isNormal(g)?g:null,h=Cb.isNormal(h)?h:null,i=Cb.isNormal(i)?i:null,Cb.isArray(d)||(d=[]),Cb.isArray(e)||(e=[]),l=0,m=e.length;m>l;l++)p.push({id:e[l][0],name:e[l][1],disable:!1});for(l=0,m=b.length;m>l;l++)n=b[l],(h?h.call(null,n):!0)&&p.push({id:n.fullNameRaw,system:!0,name:i?i.call(null,n):n.name(),disable:!n.selectable||-1<Cb.inArray(n.fullNameRaw,d)||(g?g.call(null,n):!1)});for(l=0,m=c.length;m>l;l++)n=c[l],n.isGmailFolder||!n.subScribed()&&n.existen||(h?h.call(null,n):!0)&&(Ab.FolderType.User===n.type()||!j||!n.isNamespaceFolder&&0<n.subFolders().length)&&p.push({id:n.fullNameRaw,system:!1,name:new a.Array(n.deep+1-f).join(o)+(i?i.call(null,n):n.name()),disable:!n.selectable||-1<Cb.inArray(n.fullNameRaw,d)||Ab.FolderType.User!==n.type()||(g?g.call(null,n):!1)}),n.subScribed()&&0<n.subFolders().length&&(p=p.concat(Ob.folderListOptionsBuilder([],n.subFolders(),d,[],n.isUnpaddigFolder?f+1:f,g,h,i,j,k)));return p},yb.prototype.getAutocomplete=function(a,b){var c=[];Ob.remote().suggestions(function(a,d){Ab.StorageResultType.Success===a&&d&&Cb.isArray(d.Result)?(c=h.map(d.Result,function(a){return a&&a[0]?new v(a[0],a[1]):null}),b(h.compact(c))):Ab.StorageResultType.Abort!==a&&b([])},a)},yb.prototype.emailsPicsHashes=function(){Ob.remote().emailsPicsHashes(function(a,b){Ab.StorageResultType.Success===a&&b&&b.Result&&Ob.cache().setEmailsPicsHashesData(b.Result)})},yb.prototype.mailToHelper=function(b){if(b&&"mailto:"===b.toString().toLowerCase().substr(0,7)){var c=null;if(c=new v,c.parse(a.decodeURI(b.toString().substr(7).replace(/\?.+$/,""))),c&&c.email)return Hb.showScreenPopup(I,[Ab.ComposeType.Empty,null,[c]]),!0}return!1},yb.prototype.bootstart=function(){Ob.pub("rl.bootstart"),xb.prototype.bootstart.call(this),Ob.data().populateDataOnStart();var c="",d=Ob.settingsGet("JsHash"),e=Ob.settingsGet("AllowGoogleSocial"),f=Ob.settingsGet("AllowFacebookSocial"),g=Ob.settingsGet("AllowTwitterSocial");Ob.settingsGet("ChangePasswordIsAllowed")||Cb.removeSettingsViewModel(jb),Ob.settingsGet("ContactsIsAllowed")||Cb.removeSettingsViewModel(db),Ob.settingsGet("AllowAdditionalAccounts")||Cb.removeSettingsViewModel(eb),Ob.settingsGet("AllowIdentities")?Cb.removeSettingsViewModel(fb):Cb.removeSettingsViewModel(gb),Ob.settingsGet("OpenPGP")||Cb.removeSettingsViewModel(mb),Ob.settingsGet("AllowTwoFactorAuth")||Cb.removeSettingsViewModel(hb),e||f||g||Cb.removeSettingsViewModel(ib),Ob.settingsGet("AllowThemes")||Cb.removeSettingsViewModel(lb),Cb.initOnStartOrLangChange(function(){b.extend(!0,b.magnificPopup.defaults,{tClose:Cb.i18n("MAGNIFIC_POPUP/CLOSE"),tLoading:Cb.i18n("MAGNIFIC_POPUP/LOADING"),gallery:{tPrev:Cb.i18n("MAGNIFIC_POPUP/GALLERY_PREV"),tNext:Cb.i18n("MAGNIFIC_POPUP/GALLERY_NEXT"),tCounter:Cb.i18n("MAGNIFIC_POPUP/GALLERY_COUNTER")},image:{tError:Cb.i18n("MAGNIFIC_POPUP/IMAGE_ERROR")},ajax:{tError:Cb.i18n("MAGNIFIC_POPUP/AJAX_ERROR")}})
},this),a.SimplePace&&(a.SimplePace.set(70),a.SimplePace.sleep()),Ob.settingsGet("Auth")?(this.setTitle(Cb.i18n("TITLES/LOADING")),this.folders(h.bind(function(c){Hb.hideLoading(),c?(a.crypto&&a.crypto.getRandomValues&&Ob.settingsGet("OpenPGP")?b.ajax({url:Ob.link().openPgpJs(),dataType:"script",cache:!0,success:function(){a.openpgp&&(Ob.data().openpgpKeyring=new a.openpgp.Keyring(new p),Ob.data().allowOpenPGP(!0),Ob.pub("openpgp.init"),Ob.reloadOpenPgpKeys())}}):Ob.data().allowOpenPGP(!1),Hb.startScreens([vb,wb]),(e||f||g)&&Ob.socialUsers(!0),Ob.sub("interval.2m",function(){Ob.folderInformation("INBOX")}),Ob.sub("interval.2m",function(){var a=Ob.data().currentFolderFullNameRaw();"INBOX"!==a&&Ob.folderInformation(a)}),Ob.sub("interval.3m",function(){Ob.folderInformationMultiply()}),Ob.sub("interval.5m",function(){Ob.quota()}),h.delay(function(){Ob.folderInformationMultiply(!0)},500),h.delay(function(){Ob.emailsPicsHashes(),Ob.remote().servicesPics(function(a,b){Ab.StorageResultType.Success===a&&b&&b.Result&&Ob.cache().setServicesData(b.Result)})},2e3),Db.runHook("rl-start-user-screens"),Ob.pub("rl.bootstart-user-screens")):(Hb.startScreens([ub]),Db.runHook("rl-start-login-screens"),Ob.pub("rl.bootstart-login-screens")),a.SimplePace&&a.SimplePace.set(100),Fb.bMobileDevice||h.defer(function(){Cb.initLayoutResizer("#rl-left","#rl-right",Ab.ClientSideKeyName.FolderListSize)})},this))):(c=Cb.pString(Ob.settingsGet("CustomLoginLink")),c?(Hb.routeOff(),Hb.setHash(Ob.link().root(),!0),Hb.routeOff(),h.defer(function(){a.location.href=c})):(Hb.hideLoading(),Hb.startScreens([ub]),Db.runHook("rl-start-login-screens"),Ob.pub("rl.bootstart-login-screens"),a.SimplePace&&a.SimplePace.set(100))),e&&(a["rl_"+d+"_google_service"]=function(){Ob.data().googleActions(!0),Ob.socialUsers()}),f&&(a["rl_"+d+"_facebook_service"]=function(){Ob.data().facebookActions(!0),Ob.socialUsers()}),g&&(a["rl_"+d+"_twitter_service"]=function(){Ob.data().twitterActions(!0),Ob.socialUsers()}),Ob.sub("interval.1m",function(){Fb.momentTrigger(!Fb.momentTrigger())}),Db.runHook("rl-start-screens"),Ob.pub("rl.bootstart-end")},Ob=new yb,Kb.addClass(Fb.bMobileDevice?"mobile":"no-mobile"),Lb.keydown(Cb.killCtrlAandS).keyup(Cb.killCtrlAandS),Lb.unload(function(){Fb.bUnload=!0}),a.rl=a.rl||{},a.rl.addHook=Db.addHook,a.rl.settingsGet=Db.mainSettingsGet,a.rl.remoteRequest=Db.remoteRequest,a.rl.pluginSettingsGet=Db.settingsGet,a.rl.addSettingsViewModel=Cb.addSettingsViewModel,a.rl.createCommand=Cb.createCommand,a.rl.EmailModel=v,a.rl.Enums=Ab,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),h.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},Hb.setBoot(Ob).bootstart(),Kb.removeClass("no-js rl-booted-trigger").addClass("rl-booted")},50)):c(!1),a.__RLBOOT=null})},a.SimplePace&&a.SimplePace.add(10)}(window,jQuery,ko,crossroads,hasher,moment,Jua,_,ifvisible,key);