snappymail/rainloop/v/0.0.0/static/js/admin.min.js
2014-04-27 02:08:07 +04:00

5 lines
105 KiB
JavaScript

/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
!function(a,b,c,d,e,f){"use strict";function g(){this.sBase="#/",this.sCdnStaticDomain=gb.settingsGet("CdnStaticDomain"),this.sVersion=gb.settingsGet("Version"),this.sSpecSuffix=gb.settingsGet("AuthAccountHash")||"0",this.sServer=(gb.settingsGet("IndexFile")||"./")+"?",this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function h(){}function i(){}function j(){var a=[i,h],b=f.find(a,function(a){return a.supported()});b&&(b=b,this.oDriver=new b)}function k(){}function l(a,b){this.bDisabeCloseOnEsc=!1,this.sPosition=V.pString(a),this.sTemplate=V.pString(b),this.sDefaultKeyScope=T.KeyState.None,this.sCurrentKeyScope=this.sDefaultKeyScope,this.viewModelName="",this.viewModelVisibility=c.observable(!1),this.modalVisibility=c.observable(!1).extend({rateLimit:0}),this.viewModelDom=null}function m(a,b){this.sScreenName=a,this.aViewModels=V.isArray(b)?b:[]}function n(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null}function o(a,b){this.email=a||"",this.name=b||"",this.privateType=null,this.clearDuplicateName()}function p(){l.call(this,"Popups","PopupsDomain"),this.edit=c.observable(!1),this.saving=c.observable(!1),this.savingError=c.observable(""),this.whiteListPage=c.observable(!1),this.testing=c.observable(!1),this.testingDone=c.observable(!1),this.testingImapError=c.observable(!1),this.testingSmtpError=c.observable(!1),this.imapServerFocus=c.observable(!1),this.smtpServerFocus=c.observable(!1),this.name=c.observable(""),this.name.focused=c.observable(!1),this.imapServer=c.observable(""),this.imapPort=c.observable(S.Values.ImapDefaulPort),this.imapSecure=c.observable(T.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(S.Values.SmtpDefaulPort),this.smtpSecure=c.observable(T.ServerSecure.None),this.smtpShortLogin=c.observable(!1),this.smtpAuth=c.observable(!0),this.whiteList=c.observable(""),this.headerText=c.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this),this.domainIsComputed=c.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this),this.canBeTested=c.computed(function(){return!this.testing()&&this.domainIsComputed()},this),this.canBeSaved=c.computed(function(){return!this.saving()&&this.domainIsComputed()},this),this.createOrAddCommand=V.createCommand(this,function(){this.saving(!0),gb.remote().createOrUpdateDomain(f.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.imapShortLogin(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpShortLogin(),this.smtpAuth(),this.whiteList())},this.canBeSaved),this.testConnectionCommand=V.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),gb.remote().testConnectionForDomain(f.bind(this.onTestConnectionResponse,this),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested),this.whiteListCommand=V.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())}),this.imapServerFocus.subscribe(function(a){a&&""!==this.name()&&""===this.imapServer()&&this.imapServer(this.name().replace(/[.]?[*][.]?/g,""))},this),this.smtpServerFocus.subscribe(function(a){a&&""!==this.imapServer()&&""===this.smtpServer()&&this.smtpServer(this.imapServer().replace(/imap/gi,"smtp"))},this),this.imapSecure.subscribe(function(a){var b=V.pInt(this.imapPort());switch(a=V.pString(a)){case"0":993===b&&this.imapPort(143);break;case"1":143===b&&this.imapPort(993)}},this),this.smtpSecure.subscribe(function(a){var b=V.pInt(this.smtpPort());switch(a=V.pString(a)){case"0":(465===b||587===b)&&this.smtpPort(25);break;case"1":(25===b||587===b)&&this.smtpPort(465);break;case"2":(25===b||465===b)&&this.smtpPort(587)}},this),n.constructorEnd(this)}function q(){l.call(this,"Popups","PopupsPlugin");var a=this;this.onPluginSettingsUpdateResponse=f.bind(this.onPluginSettingsUpdateResponse,this),this.saveError=c.observable(""),this.name=c.observable(""),this.readme=c.observable(""),this.configures=c.observableArray([]),this.hasReadme=c.computed(function(){return""!==this.readme()},this),this.hasConfiguration=c.computed(function(){return 0<this.configures().length},this),this.readmePopoverConf={placement:"top",trigger:"hover",title:"About",content:function(){return a.readme()}},this.saveCommand=V.createCommand(this,function(){var a={};a.Name=this.name(),f.each(this.configures(),function(b){var c=b.value();(!1===c||!0===c)&&(c=c?"1":"0"),a["_"+b.Name]=c},this),this.saveError(""),gb.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse,a)},this.hasConfiguration),this.bDisabeCloseOnEsc=!0,this.sDefaultKeyScope=T.KeyState.All,n.constructorEnd(this)}function r(){l.call(this,"Popups","PopupsActivate");var a=this;this.domain=c.observable(""),this.key=c.observable(""),this.key.focus=c.observable(!1),this.activationSuccessed=c.observable(!1),this.licenseTrigger=gb.data().licenseTrigger,this.activateProcess=c.observable(!1),this.activateText=c.observable(""),this.activateText.isError=c.observable(!1),this.key.subscribe(function(){this.activateText(""),this.activateText.isError(!1)},this),this.activationSuccessed.subscribe(function(a){a&&this.licenseTrigger(!this.licenseTrigger())},this),this.activateCommand=V.createCommand(this,function(){this.activateProcess(!0),this.validateSubscriptionKey()?gb.remote().licensingActivate(function(b,c){a.activateProcess(!1),T.StorageResultType.Success===b&&c.Result?!0===c.Result?(a.activationSuccessed(!0),a.activateText("Subscription Key Activated Successfully"),a.activateText.isError(!1)):(a.activateText(c.Result),a.activateText.isError(!0),a.key.focus(!0)):c.ErrorCode?(a.activateText(V.getNotification(c.ErrorCode)),a.activateText.isError(!0),a.key.focus(!0)):(a.activateText(V.getNotification(T.Notification.UnknownError)),a.activateText.isError(!0),a.key.focus(!0))},this.domain(),this.key()):(this.activateProcess(!1),this.activateText("Invalid Subscription Key"),this.activateText.isError(!0),this.key.focus(!0))},function(){return!this.activateProcess()&&""!==this.domain()&&""!==this.key()&&!this.activationSuccessed()}),n.constructorEnd(this)}function s(){l.call(this,"Popups","PopupsLanguages"),this.exp=c.observable(!1),this.languages=c.computed(function(){return f.map(gb.data().languages(),function(a){return{key:a,selected:c.observable(!1),fullName:V.convertLangName(a)}})}),gb.data().mainLanguage.subscribe(function(){this.resetMainLanguage()},this),n.constructorEnd(this)}function t(){l.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=T.KeyState.PopupAsk,n.constructorEnd(this)}function u(){l.call(this,"Center","AdminLogin"),this.login=c.observable(""),this.password=c.observable(""),this.loginError=c.observable(!1),this.passwordError=c.observable(!1),this.loginFocus=c.observable(!1),this.login.subscribe(function(){this.loginError(!1)},this),this.password.subscribe(function(){this.passwordError(!1)},this),this.submitRequest=c.observable(!1),this.submitError=c.observable(""),this.submitCommand=V.createCommand(this,function(){return this.loginError(""===V.trim(this.login())),this.passwordError(""===V.trim(this.password())),this.loginError()||this.passwordError()?!1:(this.submitRequest(!0),gb.remote().adminLogin(f.bind(function(a,b){T.StorageResultType.Success===a&&b&&"AdminLogin"===b.Action?b.Result?gb.loginAndLogoutReload():b.ErrorCode&&(this.submitRequest(!1),this.submitError(V.getNotification(b.ErrorCode))):(this.submitRequest(!1),this.submitError(V.getNotification(T.Notification.UnknownError)))},this),this.login(),this.password()),!0)},function(){return!this.submitRequest()}),n.constructorEnd(this)}function v(a){l.call(this,"Left","AdminMenu"),this.menu=a.menu,n.constructorEnd(this)}function w(){l.call(this,"Right","AdminPane"),this.adminDomain=c.observable(gb.settingsGet("AdminDomain")),this.version=c.observable(gb.settingsGet("Version")),this.adminManLoadingVisibility=gb.data().adminManLoadingVisibility,n.constructorEnd(this)}function x(){var a=gb.data();this.mainLanguage=a.mainLanguage,this.mainTheme=a.mainTheme,this.language=a.language,this.theme=a.theme,this.allowThemes=a.allowThemes,this.allowCustomTheme=a.allowCustomTheme,this.allowLanguagesOnSettings=a.allowLanguagesOnSettings,this.allowAdditionalAccounts=a.allowAdditionalAccounts,this.allowIdentities=a.allowIdentities,this.themesOptions=c.computed(function(){return f.map(a.themes(),function(a){return{optValue:a,optText:V.convertThemeName(a)}})}),this.mainLanguageFullName=c.computed(function(){return V.convertLangName(this.mainLanguage())},this),this.weakPassword=!!gb.settingsGet("WeakPassword"),this.languageTrigger=c.observable(T.SaveSettingsStep.Idle),this.themeTrigger=c.observable(T.SaveSettingsStep.Idle)}function y(){var a=gb.data();this.allowCustomLogin=a.allowCustomLogin,this.determineUserLanguage=a.determineUserLanguage,this.defaultDomain=c.observable(gb.settingsGet("LoginDefaultDomain")),this.allowLanguagesOnLogin=a.allowLanguagesOnLogin,this.defaultDomainTrigger=c.observable(T.SaveSettingsStep.Idle)}function z(){this.title=c.observable(gb.settingsGet("Title")),this.title.trigger=c.observable(T.SaveSettingsStep.Idle),this.loadingDesc=c.observable(gb.settingsGet("LoadingDescription")),this.loadingDesc.trigger=c.observable(T.SaveSettingsStep.Idle),this.loginLogo=c.observable(gb.settingsGet("LoginLogo")),this.loginLogo.trigger=c.observable(T.SaveSettingsStep.Idle),this.loginDescription=c.observable(gb.settingsGet("LoginDescription")),this.loginDescription.trigger=c.observable(T.SaveSettingsStep.Idle),this.loginCss=c.observable(gb.settingsGet("LoginCss")),this.loginCss.trigger=c.observable(T.SaveSettingsStep.Idle)}function A(){this.defautOptionsAfterRender=V.defautOptionsAfterRender,this.enableContacts=c.observable(!!gb.settingsGet("ContactsEnable")),this.contactsSharing=c.observable(!!gb.settingsGet("ContactsSharing")),this.contactsSync=c.observable(!!gb.settingsGet("ContactsSync"));var a=["sqlite","mysql","pgsql"],b=[],d=function(a){switch(a){case"sqlite":a="SQLite";break;case"mysql":a="MySQL";break;case"pgsql":a="PostgreSQL"}return a};gb.settingsGet("SQLiteIsSupported")&&b.push("sqlite"),gb.settingsGet("MySqlIsSupported")&&b.push("mysql"),gb.settingsGet("PostgreSqlIsSupported")&&b.push("pgsql"),this.contactsSupported=0<b.length,this.contactsTypes=c.observableArray([]),this.contactsTypesOptions=this.contactsTypes.map(function(a){var c=-1===V.inArray(a,b);return{id:a,name:d(a)+(c?" (not supported)":""),disabled:c}}),this.contactsTypes(a),this.contactsType=c.observable(""),this.mainContactsType=c.computed({owner:this,read:this.contactsType,write:function(a){a!==this.contactsType()?-1<V.inArray(a,b)?this.contactsType(a):0<b.length&&this.contactsType(""):this.contactsType.valueHasMutated()}}),this.contactsType.subscribe(function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage("")},this),this.pdoDsn=c.observable(gb.settingsGet("ContactsPdoDsn")),this.pdoUser=c.observable(gb.settingsGet("ContactsPdoUser")),this.pdoPassword=c.observable(gb.settingsGet("ContactsPdoPassword")),this.pdoDsnTrigger=c.observable(T.SaveSettingsStep.Idle),this.pdoUserTrigger=c.observable(T.SaveSettingsStep.Idle),this.pdoPasswordTrigger=c.observable(T.SaveSettingsStep.Idle),this.contactsTypeTrigger=c.observable(T.SaveSettingsStep.Idle),this.testing=c.observable(!1),this.testContactsSuccess=c.observable(!1),this.testContactsError=c.observable(!1),this.testContactsErrorMessage=c.observable(""),this.testContactsCommand=V.createCommand(this,function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage(""),this.testing(!0),gb.remote().testContacts(this.onTestContactsResponse,{ContactsPdoType:this.contactsType(),ContactsPdoDsn:this.pdoDsn(),ContactsPdoUser:this.pdoUser(),ContactsPdoPassword:this.pdoPassword()})},function(){return""!==this.pdoDsn()&&""!==this.pdoUser()}),this.contactsType(gb.settingsGet("ContactsPdoType")),this.onTestContactsResponse=f.bind(this.onTestContactsResponse,this)}function B(){var a=gb.data();this.domains=a.domains,this.domainsLoading=a.domainsLoading,this.iDomainForDeletionTimeout=0,this.visibility=c.computed(function(){return a.domainsLoading()?"visible":"hidden"},this),this.domainForDeletion=c.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&(a.deleteAccess(!0),this.startDomainForDeletionTimeout())}]})}function C(){this.csrfProtection=c.observable(!!gb.settingsGet("UseTokenProtection")),this.openPGP=c.observable(!!gb.settingsGet("OpenPGP")),this.allowTwoFactorAuth=c.observable(!!gb.settingsGet("AllowTwoFactorAuth")),this.adminLogin=c.observable(gb.settingsGet("AdminLogin")),this.adminPassword=c.observable(""),this.adminPasswordNew=c.observable(""),this.adminPasswordUpdateError=c.observable(!1),this.adminPasswordUpdateSuccess=c.observable(!1),this.adminPassword.subscribe(function(){this.adminPasswordUpdateError(!1),this.adminPasswordUpdateSuccess(!1)},this),this.adminPasswordNew.subscribe(function(){this.adminPasswordUpdateError(!1),this.adminPasswordUpdateSuccess(!1)},this),this.saveNewAdminPasswordCommand=V.createCommand(this,function(){this.adminPasswordUpdateError(!1),this.adminPasswordUpdateSuccess(!1),gb.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse,{Password:this.adminPassword(),NewPassword:this.adminPasswordNew()})},function(){return""!==this.adminPassword()&&""!==this.adminPasswordNew()}),this.onNewAdminPasswordResponse=f.bind(this.onNewAdminPasswordResponse,this)}function D(){var a=gb.data();this.googleEnable=a.googleEnable,this.googleClientID=a.googleClientID,this.googleClientSecret=a.googleClientSecret,this.googleTrigger1=c.observable(T.SaveSettingsStep.Idle),this.googleTrigger2=c.observable(T.SaveSettingsStep.Idle),this.facebookEnable=a.facebookEnable,this.facebookAppID=a.facebookAppID,this.facebookAppSecret=a.facebookAppSecret,this.facebookTrigger1=c.observable(T.SaveSettingsStep.Idle),this.facebookTrigger2=c.observable(T.SaveSettingsStep.Idle),this.twitterEnable=a.twitterEnable,this.twitterConsumerKey=a.twitterConsumerKey,this.twitterConsumerSecret=a.twitterConsumerSecret,this.twitterTrigger1=c.observable(T.SaveSettingsStep.Idle),this.twitterTrigger2=c.observable(T.SaveSettingsStep.Idle),this.dropboxEnable=a.dropboxEnable,this.dropboxApiKey=a.dropboxApiKey,this.dropboxTrigger1=c.observable(T.SaveSettingsStep.Idle)}function E(){var a=gb.data();this.enabledPlugins=c.observable(!!gb.settingsGet("EnabledPlugins")),this.pluginsError=c.observable(""),this.plugins=a.plugins,this.pluginsLoading=a.pluginsLoading,this.visibility=c.computed(function(){return a.pluginsLoading()?"visible":"hidden"},this),this.onPluginLoadRequest=f.bind(this.onPluginLoadRequest,this),this.onPluginDisableRequest=f.bind(this.onPluginDisableRequest,this)}function F(){var a=gb.data();this.packagesError=c.observable(""),this.packages=a.packages,this.packagesLoading=a.packagesLoading,this.packagesReal=a.packagesReal,this.packagesMainUpdatable=a.packagesMainUpdatable,this.packagesCurrent=this.packages.filter(function(a){return a&&""!==a.installed&&!a.compare}),this.packagesAvailableForUpdate=this.packages.filter(function(a){return a&&""!==a.installed&&!!a.compare}),this.packagesAvailableForInstallation=this.packages.filter(function(a){return a&&""===a.installed}),this.visibility=c.computed(function(){return a.packagesLoading()?"visible":"hidden"},this)}function G(){this.licensing=gb.data().licensing,this.licensingProcess=gb.data().licensingProcess,this.licenseValid=gb.data().licenseValid,this.licenseExpired=gb.data().licenseExpired,this.licenseError=gb.data().licenseError,this.licenseTrigger=gb.data().licenseTrigger,this.adminDomain=c.observable(""),this.subscriptionEnabled=c.observable(!!gb.settingsGet("SubscriptionEnabled")),this.licenseTrigger.subscribe(function(){this.subscriptionEnabled()&&gb.reloadLicensing(!0)},this)}function H(){this.useKeyboardShortcuts=c.observable(!0),this.keyScopeReal=c.observable(T.KeyState.All),this.keyScopeFake=c.observable(T.KeyState.All),this.keyScope=c.computed({owner:this,read:function(){return this.keyScopeFake()},write:function(a){T.KeyState.Menu!==a&&(T.KeyState.Compose===a?V.disableKeyFilter():V.restoreKeyFilter(),this.keyScopeFake(a),Y.dropdownVisibility()&&(a=T.KeyState.Menu)),this.keyScopeReal(a)}}),this.keyScopeReal.subscribe(function(a){key.setScope(a)}),Y.dropdownVisibility.subscribe(function(a){a?this.keyScope(T.KeyState.Menu):T.KeyState.Menu===key.getScope()&&this.keyScope(this.keyScopeFake())},this),V.initDataConstructorBySettings(this)}function I(){H.call(this),this.domainsLoading=c.observable(!1).extend({throttle:100}),this.domains=c.observableArray([]),this.pluginsLoading=c.observable(!1).extend({throttle:100}),this.plugins=c.observableArray([]),this.packagesReal=c.observable(!0),this.packagesMainUpdatable=c.observable(!0),this.packagesLoading=c.observable(!1).extend({throttle:100}),this.packages=c.observableArray([]),this.licensing=c.observable(!1),this.licensingProcess=c.observable(!1),this.licenseValid=c.observable(!1),this.licenseExpired=c.observable(0),this.licenseError=c.observable(""),this.licenseTrigger=c.observable(!1),this.adminManLoading=c.computed(function(){return"000"!==[this.domainsLoading()?"1":"0",this.pluginsLoading()?"1":"0",this.packagesLoading()?"1":"0"].join("")},this),this.adminManLoadingVisibility=c.computed(function(){return this.adminManLoading()?"visible":"hidden"},this).extend({rateLimit:300})}function J(){this.oRequests={}}function K(){J.call(this),this.oRequests={}}function L(){this.oEmailsPicsHashes={},this.oServices={}}function M(){L.call(this)}function N(a){m.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function O(){m.call(this,"login",[u])}function P(){N.call(this,[v,w])}function Q(){k.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"),db.on("error",function(a){gb&&a&&a.originalEvent&&a.originalEvent.message&&-1===V.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&gb.remote().jsError(V.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",cb.attr("class"),V.microtime()-Y.now)})}function R(){Q.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var S={},T={},U={},V={},W={},X={},Y={},Z={settings:[],"settings-removed":[],"settings-disabled":[]},$=[],_=null,ab=a.rainloopAppData||{},bb=a.rainloopI18N||{},cb=b("html"),db=b(a),eb=b(a.document),fb=a.Notification&&a.Notification.requestPermission?a.Notification:null,gb=null;Y.now=(new Date).getTime(),Y.momentTrigger=c.observable(!0),Y.dropdownVisibility=c.observable(!1).extend({rateLimit:0}),Y.langChangeTrigger=c.observable(!0),Y.iAjaxErrorCount=0,Y.iTokenErrorCount=0,Y.iMessageBodyCacheCount=0,Y.bUnload=!1,Y.sUserAgent=(navigator.userAgent||"").toLowerCase(),Y.bIsiOSDevice=-1<Y.sUserAgent.indexOf("iphone")||-1<Y.sUserAgent.indexOf("ipod")||-1<Y.sUserAgent.indexOf("ipad"),Y.bIsAndroidDevice=-1<Y.sUserAgent.indexOf("android"),Y.bMobileDevice=Y.bIsiOSDevice||Y.bIsAndroidDevice,Y.bDisableNanoScroll=Y.bMobileDevice,Y.bAllowPdfPreview=!Y.bMobileDevice,Y.bAnimationSupported=!Y.bMobileDevice&&cb.hasClass("csstransitions"),Y.sAnimationType="",Y.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"},Y.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"},Y.bAllowPdfPreview&&navigator&&navigator.mimeTypes&&(Y.bAllowPdfPreview=!!f.find(navigator.mimeTypes,function(a){return a&&"application/pdf"===a.type})),S.Defaults={},S.Values={},S.DataImages={},S.Defaults.MessagesPerPage=20,S.Defaults.ContactsPerPage=50,S.Defaults.MessagesPerPageArray=[10,20,30,50,100],S.Defaults.DefaultAjaxTimeout=3e4,S.Defaults.SearchAjaxTimeout=3e5,S.Defaults.SendMessageAjaxTimeout=3e5,S.Defaults.SaveMessageAjaxTimeout=2e5,S.Defaults.ContactsSyncAjaxTimeout=2e5,S.Values.UnuseOptionValue="__UNUSE__",S.Values.ClientSideCookieIndexName="rlcsc",S.Values.ImapDefaulPort=143,S.Values.ImapDefaulSecurePort=993,S.Values.SmtpDefaulPort=25,S.Values.SmtpDefaulSecurePort=465,S.Values.MessageBodyCacheLimit=15,S.Values.AjaxErrorLimit=7,S.Values.TokenErrorLimit=10,S.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",S.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",T.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"},T.State={Empty:10,Login:20,Auth:30},T.StateType={Webmail:0,Admin:1},T.KeyState={All:"all",None:"none",ContactList:"contact-list",MessageList:"message-list",FolderList:"folder-list",MessageView:"message-view",Compose:"compose",Settings:"settings",Menu:"menu",PopupComposeOpenPGP:"compose-open-pgp",PopupKeyboardShortcutsHelp:"popup-keyboard-shortcuts-help",PopupAsk:"popup-ask"},T.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,Archive:15,User:99},T.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"},T.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2},T.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft",EditAsNew:"editasnew"},T.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99},T.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4,Archive:5},T.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3,FolderListSize:4},T.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},T.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3},T.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6},T.DesktopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9},T.MessagePriority={Low:5,Normal:3,High:1},T.EditorDefaultType={Html:"Html",Plain:"Plain"},T.CustomThemeType={Light:"Light",Dark:"Dark"},T.ServerSecure={None:0,SSL:1,TLS:2},T.SearchDateType={All:-1,Days3:3,Days7:7,Month:30},T.EmailType={Defailt:0,Facebook:1,Google:2},T.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0},T.InterfaceAnimation={None:"None",Normal:"Normal",Full:"Full"},T.Layout={NoPreview:0,SidePreview:1,BottomPreview:2},T.SignedVerifyStatus={UnknownPublicKeys:-4,UnknownPrivateKey:-3,Unverified:-2,Error:-1,None:0,Success:1},T.ContactPropertyType={Unknown:0,FullName:10,FirstName:15,LastName:16,MiddleName:16,Nick:18,NamePrefix:20,NameSuffix:21,Email:30,Phone:31,Web:32,Facebook:90,Skype:91,GitHub:92,Note:110,Custom:250},T.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,CouldNotSaveNewPassword:130,CurrentPasswordIncorrect:131,NewPasswordShort:132,NewPasswordWeak:133,NewPasswordForbidden:134,ContactsSyncError:140,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},V.trim=b.trim,V.inArray=b.inArray,V.isArray=f.isArray,V.isFunc=f.isFunction,V.isUnd=f.isUndefined,V.isNull=f.isNull,V.emptyFunction=function(){},V.isNormal=function(a){return!V.isUnd(a)&&!V.isNull(a)},V.windowResize=f.debounce(function(b){V.isUnd(b)?db.resize():a.setTimeout(function(){db.resize()},b)},50),V.isPosNumeric=function(a,b){return V.isNormal(a)?(V.isUnd(b)?0:!b)?/^[1-9]+[0-9]*$/.test(a.toString()):/^[0-9]*$/.test(a.toString()):!1},V.pInt=function(b){return V.isNormal(b)&&""!==b?a.parseInt(b,10):0},V.pString=function(a){return V.isNormal(a)?""+a:""},V.isNonEmptyArray=function(a){return V.isArray(a)&&0<a.length},V.exportPath=function(b,c,d){for(var e=null,f=b.split("."),g=d||a;f.length&&(e=f.shift());)f.length||V.isUnd(c)?g=g[e]?g[e]:g[e]={}:g[e]=c},V.pImport=function(a,b,c){a[b]=c},V.pExport=function(a,b,c){return V.isUnd(a[b])?c:a[b]},V.encodeHtml=function(a){return V.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},V.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=V.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},V.timeOutAction=function(){var b={};return function(c,d,e){V.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),V.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),V.audio=function(){var b=!1;return function(c,d){if(!1===b)if(Y.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}}(),V.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},V.i18n=function(a,b,c){var d="",e=V.isUnd(bb[a])?V.isUnd(c)?a:c:bb[a];if(!V.isUnd(b)&&!V.isNull(b))for(d in b)V.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},V.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(V.i18n(c)):(c=a.data("i18n-html"),c&&a.html(V.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",V.i18n(c)),c=a.data("i18n-title"),c&&a.attr("title",V.i18n(c)))})})},V.i18nToDoc=function(){a.rainloopI18N&&(bb=a.rainloopI18N||{},V.i18nToNode(eb),Y.langChangeTrigger(!Y.langChangeTrigger())),a.rainloopI18N={}},V.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?Y.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&Y.langChangeTrigger.subscribe(a,b)},V.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)},V.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},V.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()},V.replySubjectAdd=function(b,c,d){var e=null,f=V.trim(c);return f=null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||V.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||V.isUnd(e[1])||V.isUnd(e[2])||V.isUnd(e[3])?b+": "+c:e[1]+(V.pInt(e[2])+1)+e[3]:b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),f=(V.isUnd(d)?!0:d)?V.fixLongSubject(f):f},V.fixLongSubject=function(a){var b=0,c=null;a=V.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||V.isUnd(c[0]))&&(c=null),c&&(b=0,b+=V.isUnd(c[2])?1:0+V.pInt(c[2]),b+=V.isUnd(c[4])?1:0+V.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]+/," ")},V.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},V.friendlySize=function(a){return a=V.pInt(a),a>=1073741824?V.roundNumber(a/1073741824,1)+"GB":a>=1048576?V.roundNumber(a/1048576,1)+"MB":a>=1024?V.roundNumber(a/1024,0)+"KB":a+"B"},V.log=function(b){a.console&&a.console.log&&a.console.log(b)},V.getNotification=function(a,b){return a=V.pInt(a),T.Notification.ClientViewError===a&&b?b:V.isUnd(U[a])?"":U[a]},V.initNotificationLanguage=function(){U[T.Notification.InvalidToken]=V.i18n("NOTIFICATIONS/INVALID_TOKEN"),U[T.Notification.AuthError]=V.i18n("NOTIFICATIONS/AUTH_ERROR"),U[T.Notification.AccessError]=V.i18n("NOTIFICATIONS/ACCESS_ERROR"),U[T.Notification.ConnectionError]=V.i18n("NOTIFICATIONS/CONNECTION_ERROR"),U[T.Notification.CaptchaError]=V.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),U[T.Notification.SocialFacebookLoginAccessDisable]=V.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),U[T.Notification.SocialTwitterLoginAccessDisable]=V.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),U[T.Notification.SocialGoogleLoginAccessDisable]=V.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),U[T.Notification.DomainNotAllowed]=V.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),U[T.Notification.AccountNotAllowed]=V.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),U[T.Notification.AccountTwoFactorAuthRequired]=V.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED"),U[T.Notification.AccountTwoFactorAuthError]=V.i18n("NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR"),U[T.Notification.CouldNotSaveNewPassword]=V.i18n("NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD"),U[T.Notification.CurrentPasswordIncorrect]=V.i18n("NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT"),U[T.Notification.NewPasswordShort]=V.i18n("NOTIFICATIONS/NEW_PASSWORD_SHORT"),U[T.Notification.NewPasswordWeak]=V.i18n("NOTIFICATIONS/NEW_PASSWORD_WEAK"),U[T.Notification.NewPasswordForbidden]=V.i18n("NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT"),U[T.Notification.ContactsSyncError]=V.i18n("NOTIFICATIONS/CONTACTS_SYNC_ERROR"),U[T.Notification.CantGetMessageList]=V.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),U[T.Notification.CantGetMessage]=V.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),U[T.Notification.CantDeleteMessage]=V.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),U[T.Notification.CantMoveMessage]=V.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),U[T.Notification.CantCopyMessage]=V.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),U[T.Notification.CantSaveMessage]=V.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),U[T.Notification.CantSendMessage]=V.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),U[T.Notification.InvalidRecipients]=V.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),U[T.Notification.CantCreateFolder]=V.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),U[T.Notification.CantRenameFolder]=V.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),U[T.Notification.CantDeleteFolder]=V.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),U[T.Notification.CantDeleteNonEmptyFolder]=V.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),U[T.Notification.CantSubscribeFolder]=V.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),U[T.Notification.CantUnsubscribeFolder]=V.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),U[T.Notification.CantSaveSettings]=V.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),U[T.Notification.CantSavePluginSettings]=V.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),U[T.Notification.DomainAlreadyExists]=V.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),U[T.Notification.CantInstallPackage]=V.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),U[T.Notification.CantDeletePackage]=V.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),U[T.Notification.InvalidPluginPackage]=V.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),U[T.Notification.UnsupportedPluginPackage]=V.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),U[T.Notification.LicensingServerIsUnavailable]=V.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),U[T.Notification.LicensingExpired]=V.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),U[T.Notification.LicensingBanned]=V.i18n("NOTIFICATIONS/LICENSING_BANNED"),U[T.Notification.DemoSendMessageError]=V.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),U[T.Notification.AccountAlreadyExists]=V.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),U[T.Notification.MailServerError]=V.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),U[T.Notification.UnknownNotification]=V.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),U[T.Notification.UnknownError]=V.i18n("NOTIFICATIONS/UNKNOWN_ERROR")
},V.getUploadErrorDescByCode=function(a){var b="";switch(V.pInt(a)){case T.UploadErrorCode.FileIsTooBig:b=V.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case T.UploadErrorCode.FilePartiallyUploaded:b=V.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case T.UploadErrorCode.FileNoUploaded:b=V.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case T.UploadErrorCode.MissingTempFolder:b=V.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case T.UploadErrorCode.FileOnSaveingError:b=V.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case T.UploadErrorCode.FileType:b=V.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=V.i18n("UPLOAD/ERROR_UNKNOWN")}return b},V.delegateRun=function(a,b,c,d){a&&a[b]&&(d=V.pInt(d),0>=d?a[b].apply(a,V.isArray(c)?c:[]):f.delay(function(){a[b].apply(a,V.isArray(c)?c:[])},d))},V.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===T.EventKeyCode.S)return void b.preventDefault();if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;d===T.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},V.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=V.isUnd(d)?!0:d,e.canExecute=c.computed(V.isFunc(d)?function(){return e.enabled()&&d.call(a)}:function(){return e.enabled()&&!!d}),e},V.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(T.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(T.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),Y.sAnimationType=T.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(T.Layout.SidePreview),b.usePreviewPane=c.computed(function(){return T.Layout.NoPreview!==b.layout()}),b.interfaceAnimation.subscribe(function(a){if(Y.bMobileDevice||a===T.InterfaceAnimation.None)cb.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),Y.sAnimationType=T.InterfaceAnimation.None;else switch(a){case T.InterfaceAnimation.Full:cb.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),Y.sAnimationType=a;break;case T.InterfaceAnimation.Normal:cb.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),Y.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=T.DesktopNotifications.NotSupported;if(fb&&fb.permission)switch(fb.permission.toLowerCase()){case"granted":c=T.DesktopNotifications.Allowed;break;case"denied":c=T.DesktopNotifications.Denied;break;case"default":c=T.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&T.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();T.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):T.DesktopNotifications.NotAllowed===c?fb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),T.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<V.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<V.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(S.Defaults.MessagesPerPage),b.mainMessagesPerPage=b.messagesPerPage,b.mainMessagesPerPage=c.computed({read:b.messagesPerPage,write:function(a){-1<V.inArray(V.pInt(a),S.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)},V.createMomentDate=function(a){return V.isUnd(a.moment)&&(a.moment=c.observable(moment())),c.computed(function(){return Y.momentTrigger(),this.moment().fromNow()},a)},V.createMomentShortDate=function(a){return c.computed(function(){var a="",b=moment(),c=this.moment(),d=this.momentDate();return a=4>=b.diff(c,"hours")?d:b.format("L")===c.format("L")?V.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?V.i18n("MESSAGE_LIST/YESTERDAY_AT",{TIME:c.format("LT")}):c.format(b.year()===c.year()?"D MMM.":"LL")},a)},V.isFolderExpanded=function(a){var b=gb.local().get(T.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},V.setExpandedFolder=function(a,b){var c=gb.local().get(T.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),gb.local().set(T.ClientSideKeyName.ExpandedFolders,c)},V.initLayoutResizer=function(a,c,d){var e=b(a),f=b(c),g=gb.local().get(d)||null,h=function(a,b){b&&b.size&&b.size.width&&(gb.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})},V.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"),V.windowResize()}).after("<br />").before("<br />"))})}},V.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()}))},V.toggleMessageBlockquote=function(a){a&&a.find(".rlBlockquoteSwitcher").click()},V.extendAsViewModel=function(a,b,c){b&&(c||(c=l),b.__name=a,W.regViewModelHook(a,b),f.extend(b.prototype,c.prototype))},V.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},Z.settings.push(a)},V.removeSettingsViewModel=function(a){Z["settings-removed"].push(a)},V.disableSettingsViewModel=function(a){Z["settings-disabled"].push(a)},V.convertThemeName=function(a){return V.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},V.quoteName=function(a){return a.replace(/["]/g,'\\"')},V.microtime=function(){return(new Date).getTime()},V.convertLangName=function(a,b){return V.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},V.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=V.isUnd(a)?32:V.pInt(a);b.length<a;)b+=c.substr(Math.round(Math.random()*c.length),1);return b},V.md5=function(a){function b(a,b){return a<<b|a>>>32-b}function c(a,b){var c,d,e,f,g;return e=2147483648&a,f=2147483648&b,c=1073741824&a,d=1073741824&b,g=(1073741823&a)+(1073741823&b),c&d?2147483648^g^e^f:c|d?1073741824&g?3221225472^g^e^f:1073741824^g^e^f:g^e^f}function d(a,b,c){return a&b|~a&c}function e(a,b,c){return a&c|b&~c}function f(a,b,c){return a^b^c}function g(a,b,c){return b^(a|~c)}function h(a,e,f,g,h,i,j){return a=c(a,c(c(d(e,f,g),h),j)),c(b(a,i),e)}function i(a,d,f,g,h,i,j){return a=c(a,c(c(e(d,f,g),h),j)),c(b(a,i),d)}function j(a,d,e,g,h,i,j){return a=c(a,c(c(f(d,e,g),h),j)),c(b(a,i),d)}function k(a,d,e,f,h,i,j){return a=c(a,c(c(g(d,e,f),h),j)),c(b(a,i),d)}function l(a){for(var b,c=a.length,d=c+8,e=(d-d%64)/64,f=16*(e+1),g=Array(f-1),h=0,i=0;c>i;)b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|a.charCodeAt(i)<<h,i++;return b=(i-i%4)/4,h=i%4*8,g[b]=g[b]|128<<h,g[f-2]=c<<3,g[f-1]=c>>>29,g}function m(a){var b,c,d="",e="";for(c=0;3>=c;c++)b=a>>>8*c&255,e="0"+b.toString(16),d+=e.substr(e.length-2,2);return d}function n(a){a=a.replace(/rn/g,"n");for(var b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b}var o,p,q,r,s,t,u,v,w,x=Array(),y=7,z=12,A=17,B=22,C=5,D=9,E=14,F=20,G=4,H=11,I=16,J=23,K=6,L=10,M=15,N=21;for(a=n(a),x=l(a),t=1732584193,u=4023233417,v=2562383102,w=271733878,o=0;o<x.length;o+=16)p=t,q=u,r=v,s=w,t=h(t,u,v,w,x[o+0],y,3614090360),w=h(w,t,u,v,x[o+1],z,3905402710),v=h(v,w,t,u,x[o+2],A,606105819),u=h(u,v,w,t,x[o+3],B,3250441966),t=h(t,u,v,w,x[o+4],y,4118548399),w=h(w,t,u,v,x[o+5],z,1200080426),v=h(v,w,t,u,x[o+6],A,2821735955),u=h(u,v,w,t,x[o+7],B,4249261313),t=h(t,u,v,w,x[o+8],y,1770035416),w=h(w,t,u,v,x[o+9],z,2336552879),v=h(v,w,t,u,x[o+10],A,4294925233),u=h(u,v,w,t,x[o+11],B,2304563134),t=h(t,u,v,w,x[o+12],y,1804603682),w=h(w,t,u,v,x[o+13],z,4254626195),v=h(v,w,t,u,x[o+14],A,2792965006),u=h(u,v,w,t,x[o+15],B,1236535329),t=i(t,u,v,w,x[o+1],C,4129170786),w=i(w,t,u,v,x[o+6],D,3225465664),v=i(v,w,t,u,x[o+11],E,643717713),u=i(u,v,w,t,x[o+0],F,3921069994),t=i(t,u,v,w,x[o+5],C,3593408605),w=i(w,t,u,v,x[o+10],D,38016083),v=i(v,w,t,u,x[o+15],E,3634488961),u=i(u,v,w,t,x[o+4],F,3889429448),t=i(t,u,v,w,x[o+9],C,568446438),w=i(w,t,u,v,x[o+14],D,3275163606),v=i(v,w,t,u,x[o+3],E,4107603335),u=i(u,v,w,t,x[o+8],F,1163531501),t=i(t,u,v,w,x[o+13],C,2850285829),w=i(w,t,u,v,x[o+2],D,4243563512),v=i(v,w,t,u,x[o+7],E,1735328473),u=i(u,v,w,t,x[o+12],F,2368359562),t=j(t,u,v,w,x[o+5],G,4294588738),w=j(w,t,u,v,x[o+8],H,2272392833),v=j(v,w,t,u,x[o+11],I,1839030562),u=j(u,v,w,t,x[o+14],J,4259657740),t=j(t,u,v,w,x[o+1],G,2763975236),w=j(w,t,u,v,x[o+4],H,1272893353),v=j(v,w,t,u,x[o+7],I,4139469664),u=j(u,v,w,t,x[o+10],J,3200236656),t=j(t,u,v,w,x[o+13],G,681279174),w=j(w,t,u,v,x[o+0],H,3936430074),v=j(v,w,t,u,x[o+3],I,3572445317),u=j(u,v,w,t,x[o+6],J,76029189),t=j(t,u,v,w,x[o+9],G,3654602809),w=j(w,t,u,v,x[o+12],H,3873151461),v=j(v,w,t,u,x[o+15],I,530742520),u=j(u,v,w,t,x[o+2],J,3299628645),t=k(t,u,v,w,x[o+0],K,4096336452),w=k(w,t,u,v,x[o+7],L,1126891415),v=k(v,w,t,u,x[o+14],M,2878612391),u=k(u,v,w,t,x[o+5],N,4237533241),t=k(t,u,v,w,x[o+12],K,1700485571),w=k(w,t,u,v,x[o+3],L,2399980690),v=k(v,w,t,u,x[o+10],M,4293915773),u=k(u,v,w,t,x[o+1],N,2240044497),t=k(t,u,v,w,x[o+8],K,1873313359),w=k(w,t,u,v,x[o+15],L,4264355552),v=k(v,w,t,u,x[o+6],M,2734768916),u=k(u,v,w,t,x[o+13],N,1309151649),t=k(t,u,v,w,x[o+4],K,4149444226),w=k(w,t,u,v,x[o+11],L,3174756917),v=k(v,w,t,u,x[o+2],M,718787259),u=k(u,v,w,t,x[o+9],N,3951481745),t=c(t,p),u=c(u,q),v=c(v,r),w=c(w,s);var O=m(t)+m(u)+m(v)+m(w);return O.toLowerCase()},V.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},V.draggeblePlace=function(){return b('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-mail icon-white"></i></div>').appendTo("#rl-hidden")},V.defautOptionsAfterRender=function(a,c){c&&!V.isUnd(c.disabled)&&a&&b(a).toggleClass("disabled",c.disabled).prop("disabled",c.disabled)},V.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+V.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")),V.i18nToNode(d),n.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>'+V.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)},V.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=V.isUnd(d)?1e3:V.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?T.SaveSettingsStep.TrueResult:T.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,T.SaveSettingsStep.Idle)},d)}},V.settingsSaveHelperSimpleFunction=function(a,b){return V.settingsSaveHelperFunction(null,a,b,1e3)},V.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,"")},V.plainToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},V.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},V.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:V.isUnd(c)?a.toString():c.toString(),custom:V.isUnd(c)?!1:!0,title:V.isUnd(c)?"":a.toString(),value:a.toString()};(V.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}},V.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()}},V.disableKeyFilter=function(){a.key&&(key.filter=function(){return gb.data().useKeyboardShortcuts()})},V.restoreKeyFilter=function(){a.key&&(key.filter=function(a){if(gb.data().useKeyboardShortcuts()){var b=a.target||a.srcElement,c=b?b.tagName:"";return c=c.toUpperCase(),!("INPUT"===c||"SELECT"===c||"TEXTAREA"===c||b&&"DIV"===c&&"editorHtmlArea"===b.className&&b.contentEditable)}return!1})},V.detectDropdownVisibility=f.debounce(function(){Y.dropdownVisibility(!!f.find($,function(a){return a.hasClass("open")}))},50),X={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return X.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=X._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 X._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(!Y.bMobileDevice){var e=b(a),f=e.data("tooltip-class")||"",g=e.data("tooltip-placement")||"top";e.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:g,trigger:"hover",title:function(){return e.is(".disabled")||Y.dropdownVisibility()?"":'<span class="tooltip-class '+f+'">'+V.i18n(c.utils.unwrapObservable(d()))+"</span>"}}).click(function(){e.tooltip("hide")}),Y.dropdownVisibility.subscribe(function(a){a&&e.tooltip("hide")})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a),e=d.data("tooltip-class")||"",f=d.data("tooltip-placement")||"top";d.tooltip({delay:{show:500,hide:100},html:!0,container:"body",placement:f,title:function(){return d.is(".disabled")||Y.dropdownVisibility()?"":'<span class="tooltip-class '+e+'">'+c()()+"</span>"}}).click(function(){d.tooltip("hide")}),Y.dropdownVisibility.subscribe(function(a){a&&d.tooltip("hide")})}},c.bindingHandlers.registrateBootstrapDropdown={init:function(a){$.push(b(a))}},c.bindingHandlers.openDropdownTrigger={update:function(a,d){if(c.utils.unwrapObservable(d())){var e=b(a);e.hasClass("open")||(e.find(".dropdown-toggle").dropdown("toggle"),V.detectDropdownVisibility()),d()(!1)}}},c.bindingHandlers.dropdownCloser={init:function(a){b(a).closest(".dropdown").on("click",".e-item",function(){b(a).dropdown("toggle")})}},c.bindingHandlers.popover={init:function(a,d){b(a).popover(c.utils.unwrapObservable(d()))}},c.bindingHandlers.csstext={init:function(a,d){a&&a.styleSheet&&!V.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&&!V.isUnd(a.styleSheet.cssText)?a.styleSheet.cssText=c.utils.unwrapObservable(d()):b(a).text(c.utils.unwrapObservable(d()))}},c.bindingHandlers.resizecrop={init:function(a){b(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,c){c()(),b(a).resizecrop({width:"100",height:"100"})}},c.bindingHandlers.onEnter={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&13===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.onEsc={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&27===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.clickOnTrue={update:function(a,d){c.utils.unwrapObservable(d())&&b(a).click()}},c.bindingHandlers.modal={init:function(a,d){b(a).toggleClass("fade",!Y.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("shown",function(){V.windowResize()}).find(".close").click(function(){d()(!1)})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){V.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),V.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=V.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=V.pInt(e[2]),g=db.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(!Y.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),V.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),V.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(){V.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!Y.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){Y.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){gb.getAutocomplete(a.term,function(a){b(f.map(a,function(a){return a.toLine(!1)}))})},parseHook:function(a){return f.map(a,function(a){var b=V.trim(a),c=null;return""!==b?(c=new o,c.mailsoParse(b),c.clearDuplicateName(),[c.toLine(!1),c]):[b,null]})},change:f.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(V.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},V.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=V.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=V.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),V.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated()),this},g.prototype.root=function(){return this.sBase},g.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a},g.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"},g.prototype.uploadContacts=function(){return this.sServer+"/UploadContacts/"+this.sSpecSuffix+"/"},g.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"},g.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"},g.prototype.change=function(b){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+a.encodeURIComponent(b)+"/"},g.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a},g.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a},g.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a},g.prototype.inbox=function(){return this.sBase+"mailbox/Inbox"},g.prototype.messagePreview=function(){return this.sBase+"mailbox/message-preview"},g.prototype.settings=function(a){var b=this.sBase+"settings";return V.isUnd(a)||""===a||(b+="/"+a),b},g.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},g.prototype.mailBox=function(a,b,c){b=V.isNormal(b)?V.pInt(b):1,c=V.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},g.prototype.phpInfo=function(){return this.sServer+"Info"},g.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"},g.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"},g.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"},g.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a},g.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"},g.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"},g.prototype.openPgpJs=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/js/openpgp.min.js"},g.prototype.socialGoogle=function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},g.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")},W.oViewModelsHooks={},W.oSimpleHooks={},W.regViewModelHook=function(a,b){b&&(b.__hookName=a)},W.addHook=function(a,b){V.isFunc(b)&&(V.isArray(W.oSimpleHooks[a])||(W.oSimpleHooks[a]=[]),W.oSimpleHooks[a].push(b))},W.runHook=function(a,b){V.isArray(W.oSimpleHooks[a])&&(b=b||[],f.each(W.oSimpleHooks[a],function(a){a.apply(null,b)}))},W.mainSettingsGet=function(a){return gb?gb.settingsGet(a):null},W.remoteRequest=function(a,b,c,d,e,f){gb&&gb.remote().defaultRequest(a,b,c,d,e,f)},W.settingsGet=function(a,b){var c=W.mainSettingsGet("Plugins");return c=c&&V.isUnd(c[a])?null:c[a],c?V.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(S.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(S.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(S.Values.ClientSideCookieIndexName),d=null;
try{d=null===c?null:JSON.parse(c),d=d&&!V.isUnd(d[a])?d[a]:null}catch(e){}return d},i.supported=function(){return!!a.localStorage},i.prototype.set=function(b,c){var d=a.localStorage[S.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[S.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[S.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!V.isUnd(d[b])?d[b]:null}catch(e){}return d},j.prototype.oDriver=null,j.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1},j.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+a):null},k.prototype.bootstart=function(){},l.prototype.sPosition="",l.prototype.sTemplate="",l.prototype.viewModelName="",l.prototype.viewModelDom=null,l.prototype.viewModelTemplate=function(){return this.sTemplate},l.prototype.viewModelPosition=function(){return this.sPosition},l.prototype.cancelCommand=l.prototype.closeCommand=function(){},l.prototype.storeAndSetKeyScope=function(){this.sCurrentKeyScope=gb.data().keyScope(),gb.data().keyScope(this.sDefaultKeyScope)},l.prototype.restoreKeyScope=function(){gb.data().keyScope(this.sCurrentKeyScope)},l.prototype.registerPopupEscapeKey=function(){var a=this;db.on("keydown",function(b){return b&&T.EventKeyCode.Esc===b.keyCode&&a.modalVisibility&&a.modalVisibility()?(V.delegateRun(a,"cancelCommand"),!1):!0})},m.prototype.oCross=null,m.prototype.sScreenName="",m.prototype.aViewModels=[],m.prototype.viewModels=function(){return this.aViewModels},m.prototype.screenName=function(){return this.sScreenName},m.prototype.routes=function(){return null},m.prototype.__cross=function(){return this.oCross},m.prototype.__start=function(){var a=this.routes(),b=null,c=null;V.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||V.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.constructorEnd=function(a){V.isFunc(a.__constructor_end)&&a.__constructor_end.call(a)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.hideLoading=function(){b("#rl-loading").hide()},n.prototype.routeOff=function(){e.changed.active=!1},n.prototype.routeOn=function(){e.changed.active=!0},n.prototype.setBoot=function(a){return V.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||V.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),g=e.viewModelPosition(),h=b("#rl-content #rl-"+g.toLowerCase()),i=null;a.__builded=!0,a.__vm=e,e.data=gb.data(),e.viewModelName=a.__name,h&&1===h.length?(i=b("<div>").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(h),e.viewModelDom=i,a.__dom=i,"Popups"===g&&(e.cancelCommand=e.closeCommand=V.createCommand(e,function(){_.hideScreenPopup(a)}),e.modalVisibility.subscribe(function(a){var b=this;a?(this.viewModelDom.show(),this.storeAndSetKeyScope(),gb.popupVisibilityNames.push(this.viewModelName),V.delegateRun(this,"onFocus",[],500)):(V.delegateRun(this,"onHide"),this.restoreKeyScope(),gb.popupVisibilityNames.remove(this.viewModelName),f.delay(function(){b.viewModelDom.hide()},300))},e)),W.runHook("view-model-pre-build",[a.__name,e,i]),c.applyBindings(e,i[0]),V.delegateRun(e,"onBuild",[i]),e&&"Popups"===g&&!e.bDisabeCloseOnEsc&&e.registerPopupEscapeKey(),W.runHook("view-model-post-build",[a.__name,e,i])):V.log("Cannot find view model position: "+g)}return a?a.__vm:null},n.prototype.applyExternal=function(a,b){a&&b&&c.applyBindings(a,b)},n.prototype.hideScreenPopup=function(a){a&&a.__vm&&a.__dom&&(a.__vm.modalVisibility(!1),W.runHook("view-model-on-hide",[a.__name,a.__vm]))},n.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__vm.modalVisibility(!0),V.delegateRun(a.__vm,"onShow",b||[]),W.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===V.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,V.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),V.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(V.delegateRun(c.oCurrentScreen,"onHide"),V.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.hide(),a.__vm.viewModelVisibility(!1),V.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(V.delegateRun(c.oCurrentScreen,"onShow"),W.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),V.isNonEmptyArray(c.oCurrentScreen.viewModels())&&f.each(c.oCurrentScreen.viewModels(),function(a){a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()&&(a.__dom.show(),a.__vm.viewModelVisibility(!0),V.delegateRun(a.__vm,"onShow"),V.delegateRun(a.__vm,"onFocus",[],200),W.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){b("#rl-content").css({visibility:"hidden"}),f.each(a,function(a){var b=new a,c=b?b.screenName():"";b&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=b)},this),f.each(this.oScreens,function(a){a&&!a.__started&&a.__start&&(a.__started=!0,a.__start(),W.runHook("screen-pre-start",[a.screenName(),a]),V.delegateRun(a,"onStart"),W.runHook("screen-post-start",[a.screenName(),a]))},this);var c=d.create();c.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(c.parse,c),e.changed.add(c.parse,c),e.init(),b("#rl-content").css({visibility:"visible"}),f.delay(function(){cb.removeClass("rl-started-trigger").addClass("rl-started")},50)},n.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=V.isUnd(c)?!1:!!c,(V.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)},n.prototype.bootstart=function(){return this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart(),this},_=new n,o.newInstanceFromJson=function(a){var b=new o;return b.initByJson(a)?b:null},o.prototype.name="",o.prototype.email="",o.prototype.privateType=null,o.prototype.clear=function(){this.email="",this.name="",this.privateType=null},o.prototype.validate=function(){return""!==this.name||""!==this.email},o.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"},o.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")},o.prototype.type=function(){return null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=T.EmailType.Facebook),null===this.privateType&&(this.privateType=T.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){this.clear(),a=V.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)},o.prototype.initByJson=function(a){var b=!1;return a&&"Object/Email"===a["@Object"]&&(this.name=V.trim(a.Name),this.email=V.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=V.isUnd(b)?!1:!!b,c=V.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'<a href="mailto:'+V.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+V.encodeHtml(this.name)+"</a>":c?V.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=V.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+V.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+V.encodeHtml(d)+"</a>"+V.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=V.encodeHtml(d))):b&&(d='<a href="mailto:'+V.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+V.encodeHtml(this.email)+"</a>"))),d},o.prototype.mailsoParse=function(a){if(a=V.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=V.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=V.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=V.trim(f).replace(/^[(]+/,"").replace(/[)]+$/,""),d=d.replace(/\\\\(.)/,"$1"),f=f.replace(/\\\\(.)/,"$1"),this.name=d,this.email=e,this.clearDuplicateName(),!0},o.prototype.inputoTagLine=function(){return 0<this.name.length?this.name+" ("+this.email+")":this.email},V.extendAsViewModel("PopupsDomainViewModel",p),p.prototype.onTestConnectionResponse=function(a,b){this.testing(!1),T.StorageResultType.Success===a&&b.Result?(this.testingDone(!0),this.testingImapError(!1===b.Result.Imap),this.testingSmtpError(!1===b.Result.Smtp)):(this.testingImapError(!0),this.testingSmtpError(!0))},p.prototype.onDomainCreateOrSaveResponse=function(a,b){this.saving(!1),T.StorageResultType.Success===a&&b?b.Result?(gb.reloadDomainList(),this.closeCommand()):T.Notification.DomainAlreadyExists===b.ErrorCode&&this.savingError("Domain already exists"):this.savingError("Unknown error")},p.prototype.onHide=function(){this.whiteListPage(!1)},p.prototype.onShow=function(a){this.saving(!1),this.whiteListPage(!1),this.testing(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.clearForm(),a&&(this.edit(!0),this.name(V.trim(a.Name)),this.imapServer(V.trim(a.IncHost)),this.imapPort(V.pInt(a.IncPort)),this.imapSecure(V.trim(a.IncSecure)),this.imapShortLogin(!!a.IncShortLogin),this.smtpServer(V.trim(a.OutHost)),this.smtpPort(V.pInt(a.OutPort)),this.smtpSecure(V.trim(a.OutSecure)),this.smtpShortLogin(!!a.OutShortLogin),this.smtpAuth(!!a.OutAuth),this.whiteList(V.trim(a.WhiteList)))},p.prototype.onFocus=function(){""===this.name()&&this.name.focused(!0)},p.prototype.clearForm=function(){this.edit(!1),this.whiteListPage(!1),this.savingError(""),this.name(""),this.name.focused(!1),this.imapServer(""),this.imapPort(S.Values.ImapDefaulPort),this.imapSecure(T.ServerSecure.None),this.imapShortLogin(!1),this.smtpServer(""),this.smtpPort(S.Values.SmtpDefaulPort),this.smtpSecure(T.ServerSecure.None),this.smtpShortLogin(!1),this.smtpAuth(!0),this.whiteList("")},V.extendAsViewModel("PopupsPluginViewModel",q),q.prototype.onPluginSettingsUpdateResponse=function(a,b){T.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),this.saveError(b&&b.ErrorCode?V.getNotification(b.ErrorCode):V.getNotification(T.Notification.CantSavePluginSettings)))},q.prototype.onShow=function(a){if(this.name(),this.readme(),this.configures([]),a){this.name(a.Name),this.readme(a.Readme);var b=a.Config;V.isNonEmptyArray(b)&&this.configures(f.map(b,function(a){return{value:c.observable(a[0]),Name:a[1],Type:a[2],Label:a[3],Default:a[4],Desc:a[5]}}))}},q.prototype.tryToClosePopup=function(){var a=this;_.showScreenPopup(t,[V.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&V.delegateRun(a,"cancelCommand")}])},q.prototype.onBuild=function(){key("esc",T.KeyState.All,f.bind(function(){return this.modalVisibility()?(this.tryToClosePopup(),!1):void 0},this))},V.extendAsViewModel("PopupsActivateViewModel",r),r.prototype.onShow=function(){this.domain(gb.settingsGet("AdminDomain")),this.activateProcess()||(this.key(""),this.activateText(""),this.activateText.isError(!1),this.activationSuccessed(!1))},r.prototype.onFocus=function(){this.activateProcess()||this.key.focus(!0)},r.prototype.validateSubscriptionKey=function(){var a=this.key();return""===a||!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(V.trim(a))},V.extendAsViewModel("PopupsLanguagesViewModel",s),s.prototype.languageEnName=function(a){return V.convertLangName(a,!0)},s.prototype.resetMainLanguage=function(){var a=gb.data().mainLanguage();f.each(this.languages(),function(b){b.selected(b.key===a)})},s.prototype.onShow=function(){this.exp(!0),this.resetMainLanguage()},s.prototype.onHide=function(){this.exp(!1)},s.prototype.changeLanguage=function(a){gb.data().mainLanguage(a),this.cancelCommand()},V.extendAsViewModel("PopupsAskViewModel",t),t.prototype.clearPopup=function(){this.askDesc(""),this.yesButton(V.i18n("POPUPS_ASK/BUTTON_YES")),this.noButton(V.i18n("POPUPS_ASK/BUTTON_NO")),this.yesFocus(!1),this.noFocus(!1),this.fYesAction=null,this.fNoAction=null},t.prototype.yesClick=function(){this.cancelCommand(),V.isFunc(this.fYesAction)&&this.fYesAction.call(null)},t.prototype.noClick=function(){this.cancelCommand(),V.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(){key("tab, shift+tab, right, left",T.KeyState.PopupAsk,f.bind(function(){return this.yesFocus()?this.noFocus(!0):this.yesFocus(!0),!1},this))},V.extendAsViewModel("AdminLoginViewModel",u),u.prototype.onShow=function(){_.routeOff(),f.delay(f.bind(function(){this.loginFocus(!0)},this),100)},u.prototype.onHide=function(){this.loginFocus(!1)},V.extendAsViewModel("AdminMenuViewModel",v),v.prototype.link=function(a){return"#/"+a},V.extendAsViewModel("AdminPaneViewModel",w),w.prototype.logoutClick=function(){gb.remote().adminLogout(function(){gb.loginAndLogoutReload()})},V.addSettingsViewModel(x,"AdminSettingsGeneral","General","general",!0),x.prototype.onBuild=function(){var a=this;f.delay(function(){var b=V.settingsSaveHelperSimpleFunction(a.languageTrigger,a),c=V.settingsSaveHelperSimpleFunction(a.themeTrigger,a);a.language.subscribe(function(a){gb.remote().saveAdminConfig(b,{Language:V.trim(a)})}),a.theme.subscribe(function(a){gb.remote().saveAdminConfig(c,{Theme:V.trim(a)})}),a.allowCustomTheme.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowCustomTheme:a?"1":"0"})}),a.allowAdditionalAccounts.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowAdditionalAccounts:a?"1":"0"})}),a.allowIdentities.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowIdentities:a?"1":"0"})}),a.allowThemes.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowThemes:a?"1":"0"})}),a.allowLanguagesOnSettings.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowLanguagesOnSettings:a?"1":"0"})})},50)},x.prototype.selectLanguage=function(){_.showScreenPopup(s)},V.addSettingsViewModel(y,"AdminSettingsLogin","Login","login"),y.prototype.onBuild=function(){var a=this;f.delay(function(){var b=V.settingsSaveHelperSimpleFunction(a.defaultDomainTrigger,a);a.determineUserLanguage.subscribe(function(a){gb.remote().saveAdminConfig(null,{DetermineUserLanguage:a?"1":"0"})}),a.allowCustomLogin.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowCustomLogin:a?"1":"0"})}),a.allowLanguagesOnLogin.subscribe(function(a){gb.remote().saveAdminConfig(null,{AllowLanguagesOnLogin:a?"1":"0"})}),a.defaultDomain.subscribe(function(a){gb.remote().saveAdminConfig(b,{LoginDefaultDomain:V.trim(a)})})},50)},V.addSettingsViewModel(z,"AdminSettingsBranding","Branding","branding"),z.prototype.onBuild=function(){var a=this;f.delay(function(){var b=V.settingsSaveHelperSimpleFunction(a.title.trigger,a),c=V.settingsSaveHelperSimpleFunction(a.loadingDesc.trigger,a),d=V.settingsSaveHelperSimpleFunction(a.loginLogo.trigger,a),e=V.settingsSaveHelperSimpleFunction(a.loginDescription.trigger,a),f=V.settingsSaveHelperSimpleFunction(a.loginCss.trigger,a);a.title.subscribe(function(a){gb.remote().saveAdminConfig(b,{Title:V.trim(a)})}),a.loadingDesc.subscribe(function(a){gb.remote().saveAdminConfig(c,{LoadingDescription:V.trim(a)})}),a.loginLogo.subscribe(function(a){gb.remote().saveAdminConfig(d,{LoginLogo:V.trim(a)})}),a.loginDescription.subscribe(function(a){gb.remote().saveAdminConfig(e,{LoginDescription:V.trim(a)})}),a.loginCss.subscribe(function(a){gb.remote().saveAdminConfig(f,{LoginCss:V.trim(a)})})},50)},V.addSettingsViewModel(A,"AdminSettingsContacts","Contacts","contacts"),A.prototype.onTestContactsResponse=function(a,b){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage(""),T.StorageResultType.Success===a&&b&&b.Result&&b.Result.Result?this.testContactsSuccess(!0):(this.testContactsError(!0),this.testContactsErrorMessage(b&&b.Result?b.Result.Message||"":"")),this.testing(!1)},A.prototype.onShow=function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage("")},A.prototype.onBuild=function(){var a=this;f.delay(function(){var b=V.settingsSaveHelperSimpleFunction(a.pdoDsnTrigger,a),c=V.settingsSaveHelperSimpleFunction(a.pdoUserTrigger,a),d=V.settingsSaveHelperSimpleFunction(a.pdoPasswordTrigger,a),e=V.settingsSaveHelperSimpleFunction(a.contactsTypeTrigger,a);a.enableContacts.subscribe(function(a){gb.remote().saveAdminConfig(null,{ContactsEnable:a?"1":"0"})}),a.contactsSharing.subscribe(function(a){gb.remote().saveAdminConfig(null,{ContactsSharing:a?"1":"0"})}),a.contactsSync.subscribe(function(a){gb.remote().saveAdminConfig(null,{ContactsSync:a?"1":"0"})}),a.contactsType.subscribe(function(a){gb.remote().saveAdminConfig(e,{ContactsPdoType:a})}),a.pdoDsn.subscribe(function(a){gb.remote().saveAdminConfig(b,{ContactsPdoDsn:V.trim(a)})}),a.pdoUser.subscribe(function(a){gb.remote().saveAdminConfig(c,{ContactsPdoUser:V.trim(a)})}),a.pdoPassword.subscribe(function(a){gb.remote().saveAdminConfig(d,{ContactsPdoPassword:V.trim(a)})}),a.contactsType(gb.settingsGet("ContactsPdoType"))},50)},V.addSettingsViewModel(B,"AdminSettingsDomains","Domains","domains"),B.prototype.startDomainForDeletionTimeout=function(){var b=this;a.clearInterval(this.iDomainForDeletionTimeout),this.iDomainForDeletionTimeout=a.setTimeout(function(){b.domainForDeletion(null)},3e3)},B.prototype.createDomain=function(){_.showScreenPopup(p)},B.prototype.deleteDomain=function(a){this.domains.remove(a),gb.remote().domainDelete(f.bind(this.onDomainListChangeRequest,this),a.name)},B.prototype.disableDomain=function(a){a.disabled(!a.disabled()),gb.remote().domainDisable(f.bind(this.onDomainListChangeRequest,this),a.name,a.disabled())},B.prototype.onBuild=function(a){var b=this;a.on("click",".b-admin-domains-list-table .e-item .e-action",function(){var a=c.dataFor(this);a&&gb.remote().domain(f.bind(b.onDomainLoadRequest,b),a.name)}),gb.reloadDomainList()},B.prototype.onDomainLoadRequest=function(a,b){T.StorageResultType.Success===a&&b&&b.Result&&_.showScreenPopup(p,[b.Result])},B.prototype.onDomainListChangeRequest=function(){gb.reloadDomainList()},V.addSettingsViewModel(C,"AdminSettingsSecurity","Security","security"),C.prototype.onNewAdminPasswordResponse=function(a,b){T.StorageResultType.Success===a&&b&&b.Result?(this.adminPassword(""),this.adminPasswordNew(""),this.adminPasswordUpdateSuccess(!0)):this.adminPasswordUpdateError(!0)},C.prototype.onBuild=function(){this.csrfProtection.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{TokenProtection:a?"1":"0"})}),this.openPGP.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{OpenPGP:a?"1":"0"})}),this.allowTwoFactorAuth.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{AllowTwoFactorAuth:a?"1":"0"})})},C.prototype.onHide=function(){this.adminPassword(""),this.adminPasswordNew("")},C.prototype.phpInfoLink=function(){return gb.link().phpInfo()},V.addSettingsViewModel(D,"AdminSettingsSocial","Social","social"),D.prototype.onBuild=function(){var a=this;f.delay(function(){var b=V.settingsSaveHelperSimpleFunction(a.facebookTrigger1,a),c=V.settingsSaveHelperSimpleFunction(a.facebookTrigger2,a),d=V.settingsSaveHelperSimpleFunction(a.twitterTrigger1,a),e=V.settingsSaveHelperSimpleFunction(a.twitterTrigger2,a),f=V.settingsSaveHelperSimpleFunction(a.googleTrigger1,a),g=V.settingsSaveHelperSimpleFunction(a.googleTrigger2,a),h=V.settingsSaveHelperSimpleFunction(a.dropboxTrigger1,a);a.facebookEnable.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{FacebookEnable:a?"1":"0"})}),a.facebookAppID.subscribe(function(a){gb.remote().saveAdminConfig(b,{FacebookAppID:V.trim(a)})}),a.facebookAppSecret.subscribe(function(a){gb.remote().saveAdminConfig(c,{FacebookAppSecret:V.trim(a)})}),a.twitterEnable.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{TwitterEnable:a?"1":"0"})}),a.twitterConsumerKey.subscribe(function(a){gb.remote().saveAdminConfig(d,{TwitterConsumerKey:V.trim(a)})}),a.twitterConsumerSecret.subscribe(function(a){gb.remote().saveAdminConfig(e,{TwitterConsumerSecret:V.trim(a)})}),a.googleEnable.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{GoogleEnable:a?"1":"0"})}),a.googleClientID.subscribe(function(a){gb.remote().saveAdminConfig(f,{GoogleClientID:V.trim(a)})}),a.googleClientSecret.subscribe(function(a){gb.remote().saveAdminConfig(g,{GoogleClientSecret:V.trim(a)})}),a.dropboxEnable.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{DropboxEnable:a?"1":"0"})}),a.dropboxApiKey.subscribe(function(a){gb.remote().saveAdminConfig(h,{DropboxApiKey:V.trim(a)})})},50)},V.addSettingsViewModel(E,"AdminSettingsPlugins","Plugins","plugins"),E.prototype.disablePlugin=function(a){a.disabled(!a.disabled()),gb.remote().pluginDisable(this.onPluginDisableRequest,a.name,a.disabled())},E.prototype.configurePlugin=function(a){gb.remote().plugin(this.onPluginLoadRequest,a.name)},E.prototype.onBuild=function(a){var b=this;a.on("click",".e-item .configure-plugin-action",function(){var a=c.dataFor(this);a&&b.configurePlugin(a)}).on("click",".e-item .disabled-plugin",function(){var a=c.dataFor(this);a&&b.disablePlugin(a)}),this.enabledPlugins.subscribe(function(a){gb.remote().saveAdminConfig(V.emptyFunction,{EnabledPlugins:a?"1":"0"})})},E.prototype.onShow=function(){this.pluginsError(""),gb.reloadPluginList()},E.prototype.onPluginLoadRequest=function(a,b){T.StorageResultType.Success===a&&b&&b.Result&&_.showScreenPopup(q,[b.Result])},E.prototype.onPluginDisableRequest=function(a,b){T.StorageResultType.Success===a&&b&&!b.Result&&b.ErrorCode&&this.pluginsError(T.Notification.UnsupportedPluginPackage===b.ErrorCode&&b.ErrorMessage&&""!==b.ErrorMessage?b.ErrorMessage:V.getNotification(b.ErrorCode)),gb.reloadPluginList()},V.addSettingsViewModel(F,"AdminSettingsPackages","Packages","packages"),F.prototype.onShow=function(){this.packagesError("")},F.prototype.onBuild=function(){gb.reloadPackagesList()},F.prototype.requestHelper=function(b,c){var d=this;return function(e,g){T.StorageResultType.Success===e&&g&&g.Result||d.packagesError(g&&g.ErrorCode?V.getNotification(g.ErrorCode):V.getNotification(c?T.Notification.CantInstallPackage:T.Notification.CantDeletePackage)),f.each(gb.data().packages(),function(a){a&&b&&a.loading()&&b.file===a.file&&(b.loading(!1),a.loading(!1))}),T.StorageResultType.Success===e&&g&&g.Result&&g.Result.Reload?a.location.reload():gb.reloadPackagesList()}},F.prototype.deletePackage=function(a){a&&(a.loading(!0),gb.remote().packageDelete(this.requestHelper(a,!1),a))},F.prototype.installPackage=function(a){a&&(a.loading(!0),gb.remote().packageInstall(this.requestHelper(a,!0),a))},V.addSettingsViewModel(G,"AdminSettingsLicensing","Licensing","licensing"),G.prototype.onBuild=function(){this.subscriptionEnabled()&&gb.reloadLicensing(!1)},G.prototype.onShow=function(){this.adminDomain(gb.settingsGet("AdminDomain"))},G.prototype.showActivationForm=function(){_.showScreenPopup(r)},G.prototype.licenseExpiredMomentValue=function(){var a=moment.unix(this.licenseExpired());return a.format("LL")+" ("+a.from(moment())+")"},H.prototype.populateDataOnStart=function(){var a=V.pInt(gb.settingsGet("Layout")),b=gb.settingsGet("Languages"),c=gb.settingsGet("Themes");V.isArray(b)&&this.languages(b),V.isArray(c)&&this.themes(c),this.mainLanguage(gb.settingsGet("Language")),this.mainTheme(gb.settingsGet("Theme")),this.allowCustomTheme(!!gb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!gb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!gb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!gb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!gb.settingsGet("AllowThemes")),this.allowCustomLogin(!!gb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!gb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!gb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(gb.settingsGet("EditorDefaultType")),this.showImages(!!gb.settingsGet("ShowImages")),this.contactsAutosave(!!gb.settingsGet("ContactsAutosave")),this.interfaceAnimation(gb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(gb.settingsGet("MPP")),this.desktopNotifications(!!gb.settingsGet("DesktopNotifications")),this.useThreads(!!gb.settingsGet("UseThreads")),this.replySameFolder(!!gb.settingsGet("ReplySameFolder")),this.useCheckboxesInList(!!gb.settingsGet("UseCheckboxesInList")),this.layout(T.Layout.SidePreview),-1<V.inArray(a,[T.Layout.NoPreview,T.Layout.SidePreview,T.Layout.BottomPreview])&&this.layout(a),this.facebookEnable(!!gb.settingsGet("AllowFacebookSocial")),this.facebookAppID(gb.settingsGet("FacebookAppID")),this.facebookAppSecret(gb.settingsGet("FacebookAppSecret")),this.twitterEnable(!!gb.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(gb.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(gb.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!gb.settingsGet("AllowGoogleSocial")),this.googleClientID(gb.settingsGet("GoogleClientID")),this.googleClientSecret(gb.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!gb.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(gb.settingsGet("DropboxApiKey")),this.contactsIsAllowed(!!gb.settingsGet("ContactsIsAllowed"))},f.extend(I.prototype,H.prototype),I.prototype.populateDataOnStart=function(){H.prototype.populateDataOnStart.call(this)},J.prototype.oRequests={},J.prototype.defaultResponse=function(b,c,d,e,g,h){var i=function(){T.StorageResultType.Success!==d&&Y.bUnload&&(d=T.StorageResultType.Unload),T.StorageResultType.Success===d&&e&&!e.Result?(e&&-1<V.inArray(e.ErrorCode,[T.Notification.AuthError,T.Notification.AccessError,T.Notification.ConnectionError,T.Notification.DomainNotAllowed,T.Notification.AccountNotAllowed,T.Notification.MailServerError,T.Notification.UnknownNotification,T.Notification.UnknownError])&&Y.iAjaxErrorCount++,e&&T.Notification.InvalidToken===e.ErrorCode&&Y.iTokenErrorCount++,S.Values.TokenErrorLimit<Y.iTokenErrorCount&&gb.loginAndLogoutReload(!0),(e.Logout||S.Values.AjaxErrorLimit<Y.iAjaxErrorCount)&&(a.__rlah_clear&&a.__rlah_clear(),gb.loginAndLogoutReload(!0))):T.StorageResultType.Success===d&&e&&e.Result&&(Y.iAjaxErrorCount=0,Y.iTokenErrorCount=0),b&&(W.runHook("ajax-default-response",[c,T.StorageResultType.Success===d?e:null,d,g,h]),b(d,T.StorageResultType.Success===d?e:null,g,c,h))};switch(d){case"success":d=T.StorageResultType.Success;break;case"abort":d=T.StorageResultType.Abort;break;default:d=T.StorageResultType.Error}T.StorageResultType.Error===d?f.delay(i,300):i()},J.prototype.ajaxRequest=function(c,d,e,g,h){var i=this,j=""===g,k={},l=(new a.Date).getTime(),m=null,n="";return d=d||{},e=V.isNormal(e)?e:2e4,g=V.isUnd(g)?"":V.pString(g),h=V.isArray(h)?h:[],n=d.Action||"",n&&0<h.length&&f.each(h,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=gb.settingsGet("Token")),m=b.ajax({type:j?"POST":"GET",url:gb.link().ajax(g),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=V.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<h.length&&-1<V.inArray(n,h)&&(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},J.prototype.defaultRequest=function(a,b,c,d,e,f){c=c||{},c.Action=b,e=V.pString(e),W.runHook("ajax-default-request",[b,c,e]),this.ajaxRequest(a,c,V.isUnd(d)?S.Defaults.DefaultAjaxTimeout:V.pInt(d),e,f)},J.prototype.noop=function(a){this.defaultRequest(a,"Noop")},J.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})},J.prototype.jsInfo=function(a,b,c,d){this.defaultRequest(a,"JsInfo",{Type:b,Data:c,IsError:(V.isUnd(d)?1:!d)?"0":"1"})},J.prototype.jsVersion=function(a,b){this.defaultRequest(a,"Version",{Version:b})},f.extend(K.prototype,J.prototype),K.prototype.adminLogin=function(a,b,c){this.defaultRequest(a,"AdminLogin",{Login:b,Password:c})},K.prototype.adminLogout=function(a){this.defaultRequest(a,"AdminLogout")},K.prototype.saveAdminConfig=function(a,b){this.defaultRequest(a,"AdminSettingsUpdate",b)},K.prototype.domainList=function(a){this.defaultRequest(a,"AdminDomainList")},K.prototype.pluginList=function(a){this.defaultRequest(a,"AdminPluginList")},K.prototype.packagesList=function(a){this.defaultRequest(a,"AdminPackagesList")},K.prototype.packageInstall=function(a,b){this.defaultRequest(a,"AdminPackageInstall",{Id:b.id,Type:b.type,File:b.file},6e4)},K.prototype.packageDelete=function(a,b){this.defaultRequest(a,"AdminPackageDelete",{Id:b.id})},K.prototype.domain=function(a,b){this.defaultRequest(a,"AdminDomainLoad",{Name:b})},K.prototype.plugin=function(a,b){this.defaultRequest(a,"AdminPluginLoad",{Name:b})},K.prototype.domainDelete=function(a,b){this.defaultRequest(a,"AdminDomainDelete",{Name:b})},K.prototype.domainDisable=function(a,b,c){return this.defaultRequest(a,"AdminDomainDisable",{Name:b,Disabled:c?"1":"0"})},K.prototype.pluginSettingsUpdate=function(a,b){return this.defaultRequest(a,"AdminPluginSettingsUpdate",b)},K.prototype.licensing=function(a,b){return this.defaultRequest(a,"AdminLicensing",{Force:b?"1":"0"})},K.prototype.licensingActivate=function(a,b,c){return this.defaultRequest(a,"AdminLicensingActivate",{Domain:b,Key:c})},K.prototype.pluginDisable=function(a,b,c){return this.defaultRequest(a,"AdminPluginDisable",{Name:b,Disabled:c?"1":"0"})},K.prototype.createOrUpdateDomain=function(a,b,c,d,e,f,g,h,i,j,k,l,m){this.defaultRequest(a,"AdminDomainSave",{Create:b?"1":"0",Name:c,IncHost:d,IncPort:e,IncSecure:f,IncShortLogin:g?"1":"0",OutHost:h,OutPort:i,OutSecure:j,OutShortLogin:k?"1":"0",OutAuth:l?"1":"0",WhiteList:m})},K.prototype.testConnectionForDomain=function(a,b,c,d,e,f,g,h,i){this.defaultRequest(a,"AdminDomainTest",{Name:b,IncHost:c,IncPort:d,IncSecure:e,OutHost:f,OutPort:g,OutSecure:h,OutAuth:i?"1":"0"})},K.prototype.testContacts=function(a,b){this.defaultRequest(a,"AdminContactsTest",b)},K.prototype.saveNewAdminPassword=function(a,b){this.defaultRequest(a,"AdminPasswordUpdate",b)},K.prototype.adminPing=function(a){this.defaultRequest(a,"AdminPing")
},L.prototype.oEmailsPicsHashes={},L.prototype.oServices={},L.prototype.clear=function(){this.oServices={},this.oEmailsPicsHashes={}},L.prototype.getUserPic=function(a,b){a=V.trim(a);var c="",d="",e=a.toLowerCase(),f=V.isUnd(this.oEmailsPicsHashes[e])?"":this.oEmailsPicsHashes[e];""!==f?c=gb.link().getUserPicUrlFromHash(f):(d=e.substr(a.indexOf("@")+1),c=""!==d&&this.oServices[d]?this.oServices[d]:""),b(c,a)},L.prototype.setServicesData=function(a){this.oServices=a},L.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a},f.extend(M.prototype,L.prototype),f.extend(N.prototype,m.prototype),N.prototype.onRoute=function(a){var d=this,e=null,g=null,h=null,i=null;g=f.find(Z.settings,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}),g&&(f.find(Z["settings-removed"],function(a){return a&&a===g})&&(g=null),g&&f.find(Z["settings-disabled"],function(a){return a&&a===g})&&(g=null)),g?(g.__builded&&g.__vm?e=g.__vm:(h=this.oViewModelPlace,h&&1===h.length?(g=g,e=new g,i=b("<div></div>").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),i.appendTo(h),e.data=gb.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),V.delegateRun(e,"onBuild",[i])):V.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(V.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),V.delegateRun(d.oCurrentSubScreen,"onShow"),V.delegateRun(d.oCurrentSubScreen,"onFocus",[],200),f.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)),V.windowResize()})):_.setHash(gb.link().settings(),!1,!0)},N.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(V.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},N.prototype.onBuild=function(){f.each(Z.settings,function(a){a&&a.__rlSettingsData&&!f.find(Z["settings-removed"],function(b){return b&&b===a})&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:c.observable(!1),disabled:!!f.find(Z["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},N.prototype.routes=function(){var a=f.find(Z.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=V.isUnd(c.subname)?b:V.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(O.prototype,m.prototype),O.prototype.onShow=function(){gb.setTitle("")},f.extend(P.prototype,N.prototype),P.prototype.onShow=function(){gb.setTitle("")},f.extend(Q.prototype,k.prototype),Q.prototype.oSettings=null,Q.prototype.oPlugins=null,Q.prototype.oLocal=null,Q.prototype.oLink=null,Q.prototype.oSubs={},Q.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):(Y.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},Q.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},Q.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},Q.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=V.isNormal(ab)?ab:{}),V.isUnd(this.oSettings[a])?null:this.oSettings[a]},Q.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=V.isNormal(ab)?ab:{}),this.oSettings[a]=b},Q.prototype.setTitle=function(b){b=(V.isNormal(b)&&0<b.length?b+" - ":"")+gb.settingsGet("Title")||"",a.document.title="_",a.document.title=b},Q.prototype.loginAndLogoutReload=function(b,c){var d=V.pString(gb.settingsGet("CustomLogoutLink")),e=!!gb.settingsGet("InIframe");b=V.isUnd(b)?!1:!!b,c=V.isUnd(c)?!1:!!c,b&&c&&a.close&&a.close(),b&&""!==d&&a.location.href!==d?f.delay(function(){e&&a.parent?a.parent.location.href=d:a.location.href=d},100):(_.routeOff(),_.setHash(gb.link().root(),!0),_.routeOff(),f.delay(function(){e&&a.parent?a.parent.location.reload():a.location.reload()},100))},Q.prototype.historyBack=function(){a.history.back()},Q.prototype.getAutocomplete=function(a,b){b([],a)},Q.prototype.sub=function(a,b,c){return V.isUnd(this.oSubs[a])&&(this.oSubs[a]=[]),this.oSubs[a].push([b,c]),this},Q.prototype.pub=function(a,b){return W.runHook("rl-pub",[a,b]),V.isUnd(this.oSubs[a])||f.each(this.oSubs[a],function(a){a[0]&&a[0].apply(a[1]||null,b||[])}),this},Q.prototype.bootstart=function(){V.initOnStartOrLangChange(function(){V.initNotificationLanguage()},null),f.delay(function(){V.windowResize()},1e3),ssm.addState({id:"mobile",maxWidth:767,onEnter:function(){cb.addClass("ssm-state-mobile")},onLeave:function(){cb.removeClass("ssm-state-mobile")}}),ssm.addState({id:"tablet",minWidth:768,maxWidth:999,onEnter:function(){cb.addClass("ssm-state-tablet")},onLeave:function(){cb.removeClass("ssm-state-tablet")}}),ssm.addState({id:"desktop",minWidth:1e3,maxWidth:1400,onEnter:function(){cb.addClass("ssm-state-desktop")},onLeave:function(){cb.removeClass("ssm-state-desktop")}}),ssm.addState({id:"desktop-large",minWidth:1400,onEnter:function(){cb.addClass("ssm-state-desktop-large")},onLeave:function(){cb.removeClass("ssm-state-desktop-large")}}),ssm.ready()},f.extend(R.prototype,Q.prototype),R.prototype.oData=null,R.prototype.oRemote=null,R.prototype.oCache=null,R.prototype.data=function(){return null===this.oData&&(this.oData=new I),this.oData},R.prototype.remote=function(){return null===this.oRemote&&(this.oRemote=new K),this.oRemote},R.prototype.cache=function(){return null===this.oCache&&(this.oCache=new M),this.oCache},R.prototype.reloadDomainList=function(){gb.data().domainsLoading(!0),gb.remote().domainList(function(a,b){if(gb.data().domainsLoading(!1),T.StorageResultType.Success===a&&b&&b.Result){var d=f.map(b.Result,function(a,b){return{name:b,disabled:c.observable(!a),deleteAccess:c.observable(!1)}},this);gb.data().domains(d)}})},R.prototype.reloadPluginList=function(){gb.data().pluginsLoading(!0),gb.remote().pluginList(function(a,b){if(gb.data().pluginsLoading(!1),T.StorageResultType.Success===a&&b&&b.Result){var d=f.map(b.Result,function(a){return{name:a.Name,disabled:c.observable(!a.Enabled),configured:c.observable(!!a.Configured)}},this);gb.data().plugins(d)}})},R.prototype.reloadPackagesList=function(){gb.data().packagesLoading(!0),gb.data().packagesReal(!0),gb.remote().packagesList(function(a,b){if(gb.data().packagesLoading(!1),T.StorageResultType.Success===a&&b&&b.Result){gb.data().packagesReal(!!b.Result.Real),gb.data().packagesMainUpdatable(!!b.Result.MainUpdatable);var d=[],e={};f.each(gb.data().packages(),function(a){a&&a.loading()&&(e[a.file]=a)}),V.isArray(b.Result.List)&&(d=f.compact(f.map(b.Result.List,function(a){return a?(a.loading=c.observable(!V.isUnd(e[a.file])),"core"!==a.type||a.canBeInstalled?a:null):null}))),gb.data().packages(d)}else gb.data().packagesReal(!1)})},R.prototype.reloadLicensing=function(a){a=V.isUnd(a)?!1:!!a,gb.data().licensingProcess(!0),gb.data().licenseError(""),gb.remote().licensing(function(a,b){gb.data().licensingProcess(!1),T.StorageResultType.Success===a&&b&&b.Result&&V.isNormal(b.Result.Expired)?(gb.data().licenseValid(!0),gb.data().licenseExpired(V.pInt(b.Result.Expired)),gb.data().licenseError(""),gb.data().licensing(!0)):b&&b.ErrorCode&&-1<V.inArray(V.pInt(b.ErrorCode),[T.Notification.LicensingServerIsUnavailable,T.Notification.LicensingExpired])?(gb.data().licenseError(V.getNotification(V.pInt(b.ErrorCode))),gb.data().licensing(!0)):T.StorageResultType.Abort===a?(gb.data().licenseError(V.getNotification(T.Notification.LicensingServerIsUnavailable)),gb.data().licensing(!0)):gb.data().licensing(!1)},a)},R.prototype.bootstart=function(){Q.prototype.bootstart.call(this),gb.data().populateDataOnStart(),_.hideLoading(),gb.settingsGet("AllowAdminPanel")?_.startScreens(gb.settingsGet("Auth")?[P]:[O]):(_.routeOff(),_.setHash(gb.link().root(),!0),_.routeOff(),f.defer(function(){a.location.href="/"})),a.SimplePace&&a.SimplePace.set(100)},gb=new R,cb.addClass(Y.bMobileDevice?"mobile":"no-mobile"),db.keydown(V.killCtrlAandS).keyup(V.killCtrlAandS),db.unload(function(){Y.bUnload=!0}),cb.on("click.dropdown.data-api",function(){V.detectDropdownVisibility()}),a.rl=a.rl||{},a.rl.addHook=W.addHook,a.rl.settingsGet=W.mainSettingsGet,a.rl.remoteRequest=W.remoteRequest,a.rl.pluginSettingsGet=W.settingsGet,a.rl.addSettingsViewModel=V.addSettingsViewModel,a.rl.createCommand=V.createCommand,a.rl.EmailModel=o,a.rl.Enums=T,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),f.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},_.setBoot(gb).bootstart(),cb.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,_);