snappymail/rainloop/v/0.0.0/static/js/admin.min.js
2013-11-24 02:04:10 +04:00

4 lines
No EOL
84 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=cb.settingsGet("CdnStaticDomain"),this.sVersion=cb.settingsGet("Version"),this.sSpecSuffix=cb.settingsGet("AuthAccountHash")||"0",this.sServer=(cb.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.sPosition=S.pString(a),this.sTemplate=S.pString(b),this.viewModelName="",this.viewModelVisibility=c.observable(!1),"Popups"===this.sPosition&&(this.modalVisibility=c.observable(!1)),this.viewModelDom=null}function m(a,b){this.sScreenName=a,this.aViewModels=S.isArray(b)?b:[]}function n(){this.sDefaultScreenName="",this.oScreens={},this.oBoot=null,this.oCurrentScreen=null,this.popupVisibility=c.observable(!1),this.popupVisibility.subscribe(function(a){cb&&cb.popupVisibility(a)})}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.imapServer=c.observable(""),this.imapPort=c.observable(P.Values.ImapDefaulPort),this.imapSecure=c.observable(Q.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(P.Values.SmtpDefaulPort),this.smtpSecure=c.observable(Q.ServerSecure.None),this.smtpShortLogin=c.observable(!1),this.smtpAuth=c.observable(!0),this.whiteList=c.observable(""),this.imapServerFocus.subscribe(function(a){a&&""!==this.name()&&""===this.imapServer()&&this.imapServer(this.name())},this),this.smtpServerFocus.subscribe(function(a){a&&""!==this.imapServer()&&""===this.smtpServer()&&this.smtpServer(this.imapServer())},this),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=S.createCommand(this,function(){this.saving(!0),cb.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=S.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),cb.remote().testConnectionForDomain(f.bind(this.onTestConnectionResponse,this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested),this.whiteListCommand=S.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())})}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=S.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(""),cb.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse,a)},this.hasConfiguration)}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=cb.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=S.createCommand(this,function(){this.activateProcess(!0),this.validateSubscriptionKey()?cb.remote().licensingActivate(function(b,c){a.activateProcess(!1),Q.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(S.getNotification(c.ErrorCode)),a.activateText.isError(!0),a.key.focus(!0)):(a.activateText(S.getNotification(Q.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()})}function s(){l.call(this,"Popups","PopupsLanguages"),this.exp=c.observable(!1),this.languages=c.computed(function(){return f.map(cb.data().languages(),function(a){return{key:a,selected:c.observable(!1),fullName:S.convertLangName(a)}})}),cb.data().mainLanguage.subscribe(function(){this.resetMainLanguage()},this)}function t(){l.call(this,"Right","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=S.createCommand(this,function(){return this.loginError(""===S.trim(this.login())),this.passwordError(""===S.trim(this.password())),this.loginError()||this.passwordError()?!1:(this.submitRequest(!0),cb.remote().adminLogin(f.bind(function(a,b){Q.StorageResultType.Success===a&&b&&"AdminLogin"===b.Action?b.Result?cb.loginAndLogoutReload():b.ErrorCode&&(this.submitRequest(!1),this.submitError(S.getNotification(b.ErrorCode))):(this.submitRequest(!1),this.submitError(S.getNotification(Q.Notification.UnknownError)))},this),this.login(),this.password()),!0)},function(){return!this.submitRequest()})}function u(a){l.call(this,"Left","AdminMenu"),this.menu=a.menu}function v(){l.call(this,"Right","AdminPane"),this.adminDomain=c.observable(cb.settingsGet("AdminDomain")),this.version=c.observable(cb.settingsGet("Version"))}function w(){var a=cb.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.title=c.observable(cb.settingsGet("Title")),this.loadingDesc=c.observable(cb.settingsGet("LoadingDescription")),this.themesOptions=c.computed(function(){return f.map(a.themes(),function(a){return{optValue:a,optText:S.convertThemeName(a)}})}),this.mainLanguageFullName=c.computed(function(){return S.convertLangName(this.mainLanguage())},this),this.contactsSupported=cb.settingsGet("ContactsIsSupported"),this.contactsIsAllowed=cb.settingsGet("ContactsIsAllowed"),this.weakPassword=!!cb.settingsGet("WeakPassword"),this.titleTrigger=c.observable(Q.SaveSettingsStep.Idle),this.languageTrigger=c.observable(Q.SaveSettingsStep.Idle),this.themeTrigger=c.observable(Q.SaveSettingsStep.Idle),this.loadingDescTrigger=c.observable(Q.SaveSettingsStep.Idle)}function x(){var a=cb.data();this.allowCustomLogin=a.allowCustomLogin,this.determineUserLanguage=a.determineUserLanguage,this.defaultDomain=c.observable(cb.settingsGet("LoginDefaultDomain")),this.allowLanguagesOnLogin=a.allowLanguagesOnLogin,this.defaultDomainTrigger=c.observable(Q.SaveSettingsStep.Idle)}function y(){var a=cb.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 z(){this.csrfProtection=c.observable(!!cb.settingsGet("UseTokenProtection")),this.usageStatistics=c.observable(!!cb.settingsGet("UsageStatistics")),this.adminLogin=c.observable(cb.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.onNewAdminPasswordResponse=f.bind(this.onNewAdminPasswordResponse,this),this.saveNewAdminPasswordCommand=S.createCommand(this,function(){this.adminPasswordUpdateError(!1),this.adminPasswordUpdateSuccess(!1),cb.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse,{Password:this.adminPassword(),NewPassword:this.adminPasswordNew()})},function(){return""!==this.adminPassword()&&""!==this.adminPasswordNew()})}function A(){var a=cb.data();this.googleEnable=a.googleEnable,this.googleClientID=a.googleClientID,this.googleClientSecret=a.googleClientSecret,this.googleTrigger1=c.observable(Q.SaveSettingsStep.Idle),this.googleTrigger2=c.observable(Q.SaveSettingsStep.Idle),this.facebookEnable=a.facebookEnable,this.facebookAppID=a.facebookAppID,this.facebookAppSecret=a.facebookAppSecret,this.facebookTrigger1=c.observable(Q.SaveSettingsStep.Idle),this.facebookTrigger2=c.observable(Q.SaveSettingsStep.Idle),this.twitterEnable=a.twitterEnable,this.twitterConsumerKey=a.twitterConsumerKey,this.twitterConsumerSecret=a.twitterConsumerSecret,this.twitterTrigger1=c.observable(Q.SaveSettingsStep.Idle),this.twitterTrigger2=c.observable(Q.SaveSettingsStep.Idle),this.dropboxEnable=a.dropboxEnable,this.dropboxApiKey=a.dropboxApiKey,this.dropboxTrigger1=c.observable(Q.SaveSettingsStep.Idle)}function B(){var a=cb.data();this.enabledPlugins=c.observable(!!cb.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 C(){var a=cb.data();this.packagesError=c.observable(""),this.packages=a.packages,this.packagesLoading=a.packagesLoading,this.packagesReal=a.packagesReal,this.packagesMainUpdatable=a.packagesMainUpdatable,this.packagesCurrent=c.computed(function(){return f.filter(this.packages(),function(a){return a&&""!==a.installed&&!a.compare})},this),this.packagesAvailableForUpdate=c.computed(function(){return f.filter(this.packages(),function(a){return a&&""!==a.installed&&!!a.compare})},this),this.packagesAvailableForInstallation=c.computed(function(){return f.filter(this.packages(),function(a){return a&&""===a.installed})},this),this.visibility=c.computed(function(){return a.packagesLoading()?"visible":"hidden"},this)}function D(){this.licensing=cb.data().licensing,this.licensingProcess=cb.data().licensingProcess,this.licenseValid=cb.data().licenseValid,this.licenseExpired=cb.data().licenseExpired,this.licenseError=cb.data().licenseError,this.licenseTrigger=cb.data().licenseTrigger,this.adminDomain=c.observable(""),this.subscriptionEnabled=c.observable(!!cb.settingsGet("SubscriptionEnabled")),this.licenseTrigger.subscribe(function(){this.subscriptionEnabled()&&cb.reloadLicensing(!0)},this)}function E(){S.initDataConstructorBySettings(this)}function F(){E.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)}function G(){this.oRequests={}}function H(){G.call(this),this.oRequests={}}function I(){this.oEmailsPicsHashes={},this.oServices={}}function J(){I.call(this)}function K(a){m.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function L(){m.call(this,"login",[t])}function M(){K.call(this,[u,v])}function N(){k.call(this),this.oSettings=null,this.oPlugins=null,this.oLink=null,this.oLocal=null,this.isLocalAutocomplete=!0,this.popupVisibility=c.observable(!1),this.iframe=b('<iframe style="display:none" src="javascript:;" />').appendTo("body"),_.on("error",function(a){cb&&a&&a.originalEvent&&a.originalEvent.message&&-1===S.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&cb.remote().jsError(S.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",$.attr("class"),S.microtime()-V.now)})}function O(){N.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var P={},Q={},R={},S={},T={},U={},V={},W={settings:[],"settings-removed":[],"settings-disabled":[]},X=null,Y=a.rainloopAppData||{},Z=a.rainloopI18N||{},$=b("html"),_=b(a),ab=b(a.document),bb=a.Notification&&a.Notification.requestPermission?a.Notification:null,cb=null;V.now=(new Date).getTime(),V.minuteTick=c.observable(!0),V.fiveMinuteTick=c.observable(!0),V.langChangeTick=c.observable(!0),V.iAjaxErrorCount=0,V.iTokenErrorCount=0,V.iMessageBodyCacheCount=0,V.bUnload=!1,V.sUserAgent=(navigator.userAgent||"").toLowerCase(),V.bIsiOSDevice=-1<V.sUserAgent.indexOf("iphone")||-1<V.sUserAgent.indexOf("ipod")||-1<V.sUserAgent.indexOf("ipad"),V.bIsAndroidDevice=-1<V.sUserAgent.indexOf("android"),V.bMobileDevice=V.bIsiOSDevice||V.bIsAndroidDevice,V.bDisableNanoScroll=V.bMobileDevice,V.bAnimationSupported=!V.bMobileDevice&&$.hasClass("csstransitions"),V.sAnimationType="",P.Defaults={},P.Values={},P.DataImages={},P.Defaults.MessagesPerPage=20,P.Defaults.MessagesPerPageArray=[10,20,30,50,100],P.Defaults.DefaultAjaxTimeout=2e4,P.Defaults.SearchAjaxTimeout=12e4,P.Defaults.SendMessageAjaxTimeout=2e5,P.Defaults.SaveMessageAjaxTimeout=2e5,P.Values.UnuseOptionValue="__UNUSE__",P.Values.GmailFolderName="[Gmail]",P.Values.ClientSideCookieIndexName="rlcsc",P.Values.ImapDefaulPort=143,P.Values.ImapDefaulSecurePort=993,P.Values.SmtpDefaulPort=25,P.Values.SmtpDefaulSecurePort=465,P.Values.MessageBodyCacheLimit=15,P.Values.AjaxErrorLimit=7,P.Values.TokenErrorLimit=10,P.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",P.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",Q.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"},Q.State={Empty:10,Login:20,Auth:30},Q.StateType={Webmail:0,Admin:1},Q.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99},Q.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"},Q.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2},Q.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"},Q.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99},Q.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4},Q.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3,FolderListSize:4},Q.EventKeyCode={Backspace:8,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Insert:45,Delete:46,A:65,S:83},Q.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3},Q.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6},Q.DesktopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9},Q.MessagePriority={Low:5,Normal:3,High:1},Q.EditorDefaultType={Html:"Html",Plain:"Plain"},Q.CustomThemeType={Light:"Light",Dark:"Dark"},Q.ServerSecure={None:0,SSL:1,TLS:2},Q.SearchDateType={All:-1,Days3:3,Days7:7,Month:30},Q.EmailType={Defailt:0,Facebook:1,Google:2},Q.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0},Q.InterfaceAnimation={None:"None",Normal:"Normal",Full:"Full"},Q.Notification={InvalidToken:101,AuthError:102,AccessError:103,ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,AccountNotAllowed:110,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,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,UnknownNotification:999,UnknownError:999},S.trim=b.trim,S.inArray=b.inArray,S.isArray=f.isArray,S.isFunc=f.isFunction,S.isUnd=f.isUndefined,S.isNull=f.isNull,S.emptyFunction=function(){},S.isNormal=function(a){return!S.isUnd(a)&&!S.isNull(a)},S.windowResize=f.debounce(function(b){S.isUnd(b)?_.resize():a.setTimeout(function(){_.resize()},b)},50),S.isPosNumeric=function(a,b){return S.isNormal(a)?(S.isUnd(b)?0:!b)?/^[1-9]+[0-9]*$/.test(a.toString()):/^[0-9]*$/.test(a.toString()):!1},S.pInt=function(b){return S.isNormal(b)&&""!==b?a.parseInt(b,10):0},S.pString=function(a){return S.isNormal(a)?""+a:""},S.isNonEmptyArray=function(a){return S.isArray(a)&&0<a.length},S.exportPath=function(b,c,d){for(var e=null,f=b.split("."),g=d||a;f.length&&(e=f.shift());)f.length||S.isUnd(c)?g=g[e]?g[e]:g[e]={}:g[e]=c},S.pImport=function(a,b,c){a[b]=c},S.pExport=function(a,b,c){return S.isUnd(a[b])?c:a[b]},S.encodeHtml=function(a){return S.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},S.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=S.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},S.timeOutAction=function(){var b={};return function(c,d,e){S.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),S.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),S.audio=function(){var b=!1;return function(c,d){if(!1===b)if(V.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}}(),S.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},S.i18n=function(a,b,c){var d="",e=S.isUnd(Z[a])?S.isUnd(c)?a:c:Z[a];if(!S.isUnd(b)&&!S.isNull(b))for(d in b)S.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},S.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(S.i18n(c)):(c=a.data("i18n-html"),c&&a.html(S.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",S.i18n(c)))})})},S.i18nToDoc=function(){a.rainloopI18N&&(Z=a.rainloopI18N||{},S.i18nToNode(ab),V.langChangeTick(!V.langChangeTick())),a.rainloopI18N={}},S.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?V.langChangeTick.subscribe(function(){a&&a.call(b),c.call(b)}):a&&V.langChangeTick.subscribe(a,b)},S.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)},S.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},S.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()},S.replySubjectAdd=function(b,c){var d=null,e=S.trim(c);return null===(d=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||S.isUnd(d[1])?null===(d=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||S.isUnd(d[1])||S.isUnd(d[2])||S.isUnd(d[3])?e=b+": "+c:(e=d[1]+(S.pInt(d[2])+1)+d[3],e=d[1]+(S.pInt(d[2])+1)+d[3]):e=b+"[2]: "+d[1],e},S.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},S.friendlySize=function(a){return a=S.pInt(a),a>=1073741824?S.roundNumber(a/1073741824,1)+"GB":a>=1048576?S.roundNumber(a/1048576,1)+"MB":a>=1024?S.roundNumber(a/1024,0)+"KB":a+"B"},S.log=function(b){a.console&&a.console.log&&a.console.log(b)},S.getNotification=function(a){return a=S.pInt(a),S.isUnd(R[a])?"":R[a]},S.initNotificationLanguage=function(){R[Q.Notification.InvalidToken]=S.i18n("NOTIFICATIONS/INVALID_TOKEN"),R[Q.Notification.AuthError]=S.i18n("NOTIFICATIONS/AUTH_ERROR"),R[Q.Notification.AccessError]=S.i18n("NOTIFICATIONS/ACCESS_ERROR"),R[Q.Notification.ConnectionError]=S.i18n("NOTIFICATIONS/CONNECTION_ERROR"),R[Q.Notification.CaptchaError]=S.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),R[Q.Notification.SocialFacebookLoginAccessDisable]=S.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),R[Q.Notification.SocialTwitterLoginAccessDisable]=S.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),R[Q.Notification.SocialGoogleLoginAccessDisable]=S.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),R[Q.Notification.DomainNotAllowed]=S.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),R[Q.Notification.AccountNotAllowed]=S.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),R[Q.Notification.CantGetMessageList]=S.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),R[Q.Notification.CantGetMessage]=S.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),R[Q.Notification.CantDeleteMessage]=S.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),R[Q.Notification.CantMoveMessage]=S.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),R[Q.Notification.CantSaveMessage]=S.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),R[Q.Notification.CantSendMessage]=S.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),R[Q.Notification.InvalidRecipients]=S.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),R[Q.Notification.CantCreateFolder]=S.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),R[Q.Notification.CantRenameFolder]=S.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),R[Q.Notification.CantDeleteFolder]=S.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),R[Q.Notification.CantDeleteNonEmptyFolder]=S.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),R[Q.Notification.CantSubscribeFolder]=S.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),R[Q.Notification.CantUnsubscribeFolder]=S.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),R[Q.Notification.CantSaveSettings]=S.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),R[Q.Notification.CantSavePluginSettings]=S.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),R[Q.Notification.DomainAlreadyExists]=S.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),R[Q.Notification.CantInstallPackage]=S.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),R[Q.Notification.CantDeletePackage]=S.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),R[Q.Notification.InvalidPluginPackage]=S.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),R[Q.Notification.UnsupportedPluginPackage]=S.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),R[Q.Notification.LicensingServerIsUnavailable]=S.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),R[Q.Notification.LicensingExpired]=S.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),R[Q.Notification.LicensingBanned]=S.i18n("NOTIFICATIONS/LICENSING_BANNED"),R[Q.Notification.DemoSendMessageError]=S.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),R[Q.Notification.AccountAlreadyExists]=S.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),R[Q.Notification.MailServerError]=S.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),R[Q.Notification.UnknownNotification]=S.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),R[Q.Notification.UnknownError]=S.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},S.getUploadErrorDescByCode=function(a){var b="";switch(S.pInt(a)){case Q.UploadErrorCode.FileIsTooBig:b=S.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case Q.UploadErrorCode.FilePartiallyUploaded:b=S.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case Q.UploadErrorCode.FileNoUploaded:b=S.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case Q.UploadErrorCode.MissingTempFolder:b=S.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case Q.UploadErrorCode.FileOnSaveingError:b=S.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case Q.UploadErrorCode.FileType:b=S.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=S.i18n("UPLOAD/ERROR_UNKNOWN")}return b},S.killCtrlAandS=function(b){if(b=b||a.event){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(b.ctrlKey&&d===Q.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;b.ctrlKey&&d===Q.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},S.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=S.isUnd(d)?!0:d,e.canExecute=S.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},S.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(Q.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(Q.InterfaceAnimation.Full),V.sAnimationType=Q.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.usePreviewPane=c.observable(!0),b.useCheckboxesInList=c.observable(!0),b.interfaceAnimation.subscribe(function(a){if(V.bMobileDevice||a===Q.InterfaceAnimation.None)$.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),V.sAnimationType=Q.InterfaceAnimation.None;else switch(a){case Q.InterfaceAnimation.Full:$.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),V.sAnimationType=a;break;case Q.InterfaceAnimation.Normal:$.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),V.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=Q.DesktopNotifications.NotSupported;if(bb&&bb.permission)switch(bb.permission.toLowerCase()){case"granted":c=Q.DesktopNotifications.Allowed;break;case"denied":c=Q.DesktopNotifications.Denied;break;case"default":c=Q.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&Q.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();Q.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):Q.DesktopNotifications.NotAllowed===c?bb.requestPermission(function(){b.desktopNotifications.valueHasMutated(),Q.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<S.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<S.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(P.Defaults.MessagesPerPage),b.mainMessagesPerPage=b.messagesPerPage,b.mainMessagesPerPage=c.computed({read:b.messagesPerPage,write:function(a){-1<S.inArray(S.pInt(a),P.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.contactsIsSupported=c.observable(!1),b.contactsIsAllowed=c.observable(!1)},S.createMomentDate=function(a){return c.computed(function(){return V.minuteTick(),this.moment().fromNow()},a)},S.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")?S.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?S.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},S.isFolderExpanded=function(a){var b=cb.local().get(Q.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},S.setExpandedFolder=function(a,b){var c=cb.local().get(Q.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),cb.local().set(Q.ClientSideKeyName.ExpandedFolders,c)},S.initLayoutResizer=function(a,c,d,e,g,h,i,j){e=e||300,g=g||500,h=h||g-e/2,i=i||300;var k=0,l=b(a),m=b(c),n=b(d),o=cb.local().get(j)||h,p=function(a,b,c){if(b||c){var d=n.width(),e=b?b.size.width/d*100:null;
null===e&&c&&(e=l.width()/d*100),null!==e&&(l.css({width:"",height:"",right:""+(100-e)+"%"}),m.css({width:"",height:"",left:""+e+"%"}))}},q=function(b,c){if(c&&c.element&&c.element[0].id&&"#"+c.element[0].id==""+a){var d=n.width();k=d-i,k=g>k?k:g,l.resizable("option","maxWidth",k),c.size&&c.size.width&&cb.local().set(j,c.size.width),p(null,null,!0)}};o&&l.width(o),k=n.width()-i,k=g>k?k:g,l.resizable({minWidth:e,maxWidth:k,handles:"e",resize:p,stop:p}),p(null,null,!0),_.resize(f.throttle(q,400))},S.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"),S.windowResize()}).after("<br />").before("<br />"))})}},S.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()}))},S.extendAsViewModel=function(a,b){b&&(b.__name=a,T.regViewModelHook(a,b),f.extend(b.prototype,l.prototype))},S.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},W.settings.push(a)},S.removeSettingsViewModel=function(a){W["settings-removed"].push(a)},S.disableSettingsViewModel=function(a){W["settings-disabled"].push(a)},S.convertThemeName=function(a){return S.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},S.quoteName=function(a){return a.replace(/["]/g,'\\"')},S.microtime=function(){return(new Date).getTime()},S.convertLangName=function(a,b){return S.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},S.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=S.isUnd(a)?32:S.pInt(a);b.length<a;)b+=c.substr(Math.round(Math.random()*c.length),1);return b},S.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},S.draggeblePlace=function(){return b('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-envelope icon-white"></i></div>').appendTo("#rl-hidden")},S.defautOptionsAfterRender=function(a,b){b&&!S.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},S.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+S.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")),S.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>'+S.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)},S.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=S.isUnd(d)?1e3:S.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?Q.SaveSettingsStep.TrueResult:Q.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,Q.SaveSettingsStep.Idle)},d)}},S.settingsSaveHelperSimpleFunction=function(a,b){return S.settingsSaveHelperFunction(null,a,b,1e3)},S.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},U={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return U.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=U._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 U._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(!V.bMobileDevice){var e=b(a).data("tooltip-class")||"",f=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:f,trigger:"hover",title:function(){return'<span class="tooltip-class '+e+'">'+S.i18n(c.utils.unwrapObservable(d()))+"</span>"}})}}},c.bindingHandlers.tooltip2={init:function(a,c){var d=b(a).data("tooltip-class")||"",e=b(a).data("tooltip-placement")||"top";b(a).tooltip({delay:{show:500,hide:100},html:!0,placement:e,title:function(){return'<span class="tooltip-class '+d+'">'+c()()+"</span>"}})}},c.bindingHandlers.dropdown={init:function(a){b(a).closest(".dropdown").on("click",".e-item",function(){b(a).dropdown("toggle")})}},c.bindingHandlers.popover={init:function(a,d){b(a).popover(c.utils.unwrapObservable(d()))}},c.bindingHandlers.resizecrop={init:function(a){b(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,c){c()(),b(a).resizecrop({width:"100",height:"100"})}},c.bindingHandlers.onEnter={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&13===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.onEsc={init:function(c,d,e,f){b(c).on("keypress",function(e){e&&27===a.parseInt(e.keyCode,10)&&(b(c).trigger("change"),d().call(f))})}},c.bindingHandlers.modal={init:function(a,d){b(a).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("hidden",function(){d()(!1)})},update:function(a,d){var e=c.utils.unwrapObservable(d());b(a).modal(e?"show":"hide"),f.delay(function(){b(a).toggleClass("popup-active",e)},1)}},c.bindingHandlers.i18nInit={init:function(a){S.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),S.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=S.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=S.pInt(e[2]),g=_.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(!V.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),S.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),S.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)},b(d).draggable(k).on("mousedown",function(){S.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!V.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){V.bDisableNanoScroll||b(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}},c.bindingHandlers.saveTrigger1={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text]")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.append('&nbsp;&nbsp;<i class="icon-spinner-2 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),g="custom"===f.data("save-trigger-type"),h=g?"":"-input";switch(e.toString()){case"1":f.find(".sst-animated"+h+",.sst-error"+h).hide().removeClass("sst-visible"+h).end().find(".sst-success"+h).show().addClass("sst-visible"+h);break;case"0":f.find(".sst-animated"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-error"+h).show().addClass("sst-visible"+h);break;case"-2":f.find(".sst-error"+h+",.sst-success"+h).hide().removeClass("sst-visible"+h).end().find(".sst-animated"+h).show().addClass("sst-visible"+h);break;default:f.find(".sst-animated"+h).hide().end().find(".sst-error"+h+",.sst-success"+h).removeClass("sst-visible"+h)}}},c.bindingHandlers.saveTrigger={init:function(a){var c=b(a);c.data("save-trigger-type",c.is("input[type=text],select,textarea")?"input":"custom"),"custom"===c.data("save-trigger-type")?c.append('&nbsp;&nbsp;<i class="icon-spinner-2 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.select2={init:function(d,e){var g=0,h=100,i=null,j=new a.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),k=new a.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),l=function(){return""},m=function(a){cb.getAutocomplete(a.term,a.page,function(b,c){a.callback({more:!!c,results:f.map(b,function(a){var b=a.toLine(!1);return{id:b,text:b,c:a}})})})};b(d).addClass("ko-select2").select2({query:function(b){b&&(0===g?(m(b),g=a.setTimeout(S.emptyFunction,h)):(a.clearInterval(g),g=a.setTimeout(function(){m(b)},h)))},formatSelection:function(a,b){var c=a&&a.c?a.c.select2Selection(b):a.text;return null!==c?c:void 0},formatResult:function(a,b,c,d){var e=a&&a.c?a.c.select2Result(b):"";return""===e?d(a.text):e},createSearchChoice:function(a,b){return 0===b.length&&j.test(a)?{id:a,text:a}:null},formatNoMatches:l,formatSearching:function(){return S.i18n("SUGGESTIONS/SEARCHING_DESC")},formatInputTooShort:l,formatSelectionTooBig:l,multiple:!0,tokenSeparators:[",",";"],minimumInputLength:2,selectOnBlur:!1,closeOnSelect:!0,openOnEnter:!1}),c.utils.domNodeDisposal.addDisposeCallback(d,function(){b(d).select2("destroy")}),b(d).on("change",function(){for(var a=b(this).select2("data"),c=0,d=a.length,f=null,g=[];d>c;c++)f=a[c],f&&f.id&&(f.c||(f.c=new o,i=k.exec(S.trim(f.id)),i&&!S.isUnd(i[2])?(f.c.name=i[1],f.c.email=i[2]):f.c.email=f.id),g.push(f.c));e()(g)})},update:function(a,d){for(var e=c.utils.unwrapObservable(d()),f=0,g=e.length,h=null,i="",j=[];g>f;f++)h=e[f],i=h.toLine(!1),j.push({id:i,text:i,c:h});b(a).select2("data",j)}},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),(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(S.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},S.pInt(c)))}),b},c.observable.fn.validateEmail=function(){return this.hasError=c.observable(!1),this.subscribe(function(a){a=S.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=S.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),S.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.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.settings=function(a){var b=this.sBase+"settings";return S.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=S.isNormal(b)?S.pInt(b):1,c=S.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.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+"/":"")},T.oViewModelsHooks={},T.oSimpleHooks={},T.regViewModelHook=function(a,b){b&&(b.__hookName=a)},T.addHook=function(a,b){S.isFunc(b)&&(S.isArray(T.oSimpleHooks[a])||(T.oSimpleHooks[a]=[]),T.oSimpleHooks[a].push(b))},T.runHook=function(a,b){S.isArray(T.oSimpleHooks[a])&&(b=b||[],f.each(T.oSimpleHooks[a],function(a){a.apply(null,b)}))},T.mainSettingsGet=function(a){return cb?cb.settingsGet(a):null},T.remoteRequest=function(a,b,c,d,e,f){cb&&cb.remote().defaultRequest(a,b,c,d,e,f)},T.settingsGet=function(a,b){var c=T.mainSettingsGet("Plugins");return c=c&&S.isUnd(c[a])?null:c[a],c?S.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(P.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(P.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(P.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!S.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[P.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[P.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[P.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!S.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(){},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;S.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||S.emptyFunction,this),b=d.create(),f.each(a,function(a){b.addRoute(a[0],c).rules=a[1]}),this.oCross=b)},n.prototype.sDefaultScreenName="",n.prototype.oScreens={},n.prototype.oBoot=null,n.prototype.oCurrentScreen=null,n.prototype.showLoading=function(){b("#rl-loading").show()},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 S.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||S.isUnd(this.oScreens[a])?null:this.oScreens[a]},n.prototype.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,S.isArray(c)?c:[])},n.prototype.buildViewModel=function(a,d){if(a&&!a.__builded){var e=new a(d),f=e.viewModelPosition(),g=b("#rl-content #rl-"+f.toLowerCase()),h=null;a.__builded=!0,a.__vm=e,e.data=cb.data(),e.viewModelName=a.__name,g&&1===g.length?(h=b("<div>").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),h.appendTo(g),e.viewModelDom=h,a.__dom=h,"Popups"===f&&(e.cancelCommand=e.closeCommand=S.createCommand(e,function(){X.hideScreenPopup(a)})),T.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),this.delegateRun(e,"onBuild",[h]),T.runHook("view-model-post-build",[a.__name,e,h])):S.log("Cannot find view model position: "+f)}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.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),f.defer(function(){a.__dom.find(".ko-select2").select2("close")}))},n.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),T.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===S.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,S.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onHide"),S.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),c.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(c.delegateRun(c.oCurrentScreen,"onShow"),T.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),S.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),c.delegateRun(a.__vm,"onShow"),T.runHook("view-model-on-show",[a.__name,a.__vm]))},c)),e=d.__cross(),e&&e.parse(b)})))},n.prototype.startScreens=function(a){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(),T.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),T.runHook("screen-post-start",[a.screenName(),a]))},this);var b=d.create();b.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,f.bind(this.screenOnRoute,this)),e.initialized.add(b.parse,b),e.changed.add(b.parse,b),e.init()},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=S.isUnd(c)?!1:!!c,(S.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},X=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.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=Q.EmailType.Facebook),null===this.privateType&&(this.privateType=Q.EmailType.Default)),this.privateType},o.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())},o.prototype.parse=function(a){a=S.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=S.trim(a.Name),this.email=S.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b){var c="";return""!==this.email&&(b=S.isUnd(b)?!1:!!b,a&&""!==this.name?c=b?'<a href="mailto:'+S.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+S.encodeHtml(this.name)+"</a>":this.name:(c=this.email,""!==this.name?c=b?S.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+S.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+S.encodeHtml(c)+"</a>"+S.encodeHtml(">"):'"'+this.name+'" <'+c+">":b&&(c='<a href="mailto:'+S.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+S.encodeHtml(this.email)+"</a>"))),c},o.prototype.select2Result=function(){var a="",b=cb.cache().getUserPic(this.email);return a+=""!==b?'<img class="select2-user-pic pull-left" src="'+S.encodeHtml(b)+'" />':'<img class="select2-user-pic pull-left" src="'+cb.link().emptyContactPic()+'" />',Q.EmailType.Facebook===this.type()?(a+=""+(0<this.name.length?this.name:this.email),a+='<i class="icon-facebook pull-right select2-icon-result" />'):a+=""+(0<this.name.length?this.email+' <span class="select2-subname">('+this.name+")</span>":this.email),a+""},o.prototype.select2Selection=function(a){var c="";if(Q.EmailType.Facebook===this.type()){if(c=0<this.name.length?this.name:this.email,""!==c)return b("<pan>").text(c).appendTo(a),a.append('<i class="icon-facebook select2-icon"></i>'),null}else c=0<this.name.length?this.name+" ("+this.email+")":this.email;return c},S.extendAsViewModel("PopupsDomainViewModel",p),p.prototype.onTestConnectionResponse=function(a,b){this.testing(!1),Q.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),Q.StorageResultType.Success===a&&b?b.Result?(cb.reloadDomainList(),this.closeCommand()):Q.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(S.trim(a.Name)),this.imapServer(S.trim(a.IncHost)),this.imapPort(S.pInt(a.IncPort)),this.imapSecure(S.trim(a.IncSecure)),this.imapShortLogin(!!a.IncShortLogin),this.smtpServer(S.trim(a.OutHost)),this.smtpPort(S.pInt(a.OutPort)),this.smtpSecure(S.trim(a.OutSecure)),this.smtpShortLogin(!!a.OutShortLogin),this.smtpAuth(!!a.OutAuth),this.whiteList(S.trim(a.WhiteList)))},p.prototype.clearForm=function(){this.edit(!1),this.whiteListPage(!1),this.savingError(""),this.name(""),this.imapServer(""),this.imapPort(P.Values.ImapDefaulPort),this.imapSecure(Q.ServerSecure.None),this.imapShortLogin(!1),this.smtpServer(""),this.smtpPort(P.Values.SmtpDefaulPort),this.smtpSecure(Q.ServerSecure.None),this.smtpShortLogin(!1),this.smtpAuth(!0),this.whiteList("")},S.extendAsViewModel("PopupsPluginViewModel",q),q.prototype.onPluginSettingsUpdateResponse=function(a,b){Q.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),b&&b.ErrorCode?this.saveError(S.getNotification(b.ErrorCode)):this.saveError(S.getNotification(Q.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;S.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]}}))}},S.extendAsViewModel("PopupsActivateViewModel",r),r.prototype.onShow=function(){this.domain(cb.settingsGet("AdminDomain")),this.activateProcess()||(this.key(""),this.activateText(""),this.activateText.isError(!1),this.activationSuccessed(!1),this.key.focus(!0))},r.prototype.validateSubscriptionKey=function(){var a=this.key();return""===a||!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(S.trim(a))},S.extendAsViewModel("PopupsLanguagesViewModel",s),s.prototype.languageEnName=function(a){return S.convertLangName(a,!0)},s.prototype.resetMainLanguage=function(){var a=cb.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){cb.data().mainLanguage(a),this.cancelCommand()},S.extendAsViewModel("AdminLoginViewModel",t),t.prototype.onShow=function(){X.routeOff(),f.delay(f.bind(function(){this.loginFocus(!0)},this),100)},t.prototype.onHide=function(){this.loginFocus(!1)},S.extendAsViewModel("AdminMenuViewModel",u),u.prototype.link=function(a){return"#/"+a},S.extendAsViewModel("AdminPaneViewModel",v),v.prototype.logoutClick=function(){cb.remote().adminLogout(function(){cb.loginAndLogoutReload()})},S.addSettingsViewModel(w,"AdminSettingsGeneral","General","general",!0),w.prototype.onBuild=function(){var a=this;f.delay(function(){var b=S.settingsSaveHelperSimpleFunction(a.titleTrigger,a),c=S.settingsSaveHelperSimpleFunction(a.languageTrigger,a),d=S.settingsSaveHelperSimpleFunction(a.themeTrigger,a),e=S.settingsSaveHelperSimpleFunction(a.loadingDescTrigger,a);a.title.subscribe(function(a){cb.remote().saveAdminConfig(b,{Title:S.trim(a)})}),a.loadingDesc.subscribe(function(a){cb.remote().saveAdminConfig(e,{LoadingDescription:S.trim(a)})}),a.language.subscribe(function(a){cb.remote().saveAdminConfig(c,{Language:S.trim(a)})}),a.theme.subscribe(function(a){cb.remote().saveAdminConfig(d,{Theme:S.trim(a)})}),a.allowCustomTheme.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowCustomTheme:a?"1":"0"})}),a.allowAdditionalAccounts.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowAdditionalAccounts:a?"1":"0"})
}),a.allowIdentities.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowIdentities:a?"1":"0"})}),a.allowThemes.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowThemes:a?"1":"0"})}),a.allowLanguagesOnSettings.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowLanguagesOnSettings:a?"1":"0"})})},50)},w.prototype.selectLanguage=function(){X.showScreenPopup(s)},S.addSettingsViewModel(x,"AdminSettingsLogin","Login","login"),x.prototype.onBuild=function(){var a=this;f.delay(function(){var b=S.settingsSaveHelperSimpleFunction(a.defaultDomainTrigger,a);a.determineUserLanguage.subscribe(function(a){cb.remote().saveAdminConfig(null,{DetermineUserLanguage:a?"1":"0"})}),a.allowCustomLogin.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowCustomLogin:a?"1":"0"})}),a.allowLanguagesOnLogin.subscribe(function(a){cb.remote().saveAdminConfig(null,{AllowLanguagesOnLogin:a?"1":"0"})}),a.defaultDomain.subscribe(function(a){cb.remote().saveAdminConfig(b,{LoginDefaultDomain:S.trim(a)})})},50)},S.addSettingsViewModel(y,"AdminSettingsDomains","Domains","domains"),y.prototype.startDomainForDeletionTimeout=function(){var b=this;a.clearInterval(this.iDomainForDeletionTimeout),this.iDomainForDeletionTimeout=a.setTimeout(function(){b.domainForDeletion(null)},3e3)},y.prototype.createDomain=function(){X.showScreenPopup(p)},y.prototype.deleteDomain=function(a){this.domains.remove(a),cb.remote().domainDelete(f.bind(this.onDomainListChangeRequest,this),a.name)},y.prototype.disableDomain=function(a){a.disabled(!a.disabled()),cb.remote().domainDisable(f.bind(this.onDomainListChangeRequest,this),a.name,a.disabled())},y.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&&cb.remote().domain(f.bind(b.onDomainLoadRequest,b),a.name)}),cb.reloadDomainList()},y.prototype.onDomainLoadRequest=function(a,b){Q.StorageResultType.Success===a&&b&&b.Result&&X.showScreenPopup(p,[b.Result])},y.prototype.onDomainListChangeRequest=function(){cb.reloadDomainList()},S.addSettingsViewModel(z,"AdminSettingsSecurity","Security","security"),z.prototype.onNewAdminPasswordResponse=function(a,b){Q.StorageResultType.Success===a&&b&&b.Result?(this.adminPassword(""),this.adminPasswordNew(""),this.adminPasswordUpdateSuccess(!0)):this.adminPasswordUpdateError(!0)},z.prototype.onBuild=function(){this.csrfProtection.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{TokenProtection:a?"1":"0"})}),this.usageStatistics.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{UsageStatistics:a?"1":"0"})})},z.prototype.onHide=function(){this.adminPassword(""),this.adminPasswordNew("")},z.prototype.phpInfoLink=function(){return cb.link().phpInfo()},S.addSettingsViewModel(A,"AdminSettingsSocial","Social","social"),A.prototype.onBuild=function(){var a=this;f.delay(function(){var b=S.settingsSaveHelperSimpleFunction(a.facebookTrigger1,a),c=S.settingsSaveHelperSimpleFunction(a.facebookTrigger2,a),d=S.settingsSaveHelperSimpleFunction(a.twitterTrigger1,a),e=S.settingsSaveHelperSimpleFunction(a.twitterTrigger2,a),f=S.settingsSaveHelperSimpleFunction(a.googleTrigger1,a),g=S.settingsSaveHelperSimpleFunction(a.googleTrigger2,a),h=S.settingsSaveHelperSimpleFunction(a.dropboxTrigger1,a);a.facebookEnable.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{FacebookEnable:a?"1":"0"})}),a.facebookAppID.subscribe(function(a){cb.remote().saveAdminConfig(b,{FacebookAppID:S.trim(a)})}),a.facebookAppSecret.subscribe(function(a){cb.remote().saveAdminConfig(c,{FacebookAppSecret:S.trim(a)})}),a.twitterEnable.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{TwitterEnable:a?"1":"0"})}),a.twitterConsumerKey.subscribe(function(a){cb.remote().saveAdminConfig(d,{TwitterConsumerKey:S.trim(a)})}),a.twitterConsumerSecret.subscribe(function(a){cb.remote().saveAdminConfig(e,{TwitterConsumerSecret:S.trim(a)})}),a.googleEnable.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{GoogleEnable:a?"1":"0"})}),a.googleClientID.subscribe(function(a){cb.remote().saveAdminConfig(f,{GoogleClientID:S.trim(a)})}),a.googleClientSecret.subscribe(function(a){cb.remote().saveAdminConfig(g,{GoogleClientSecret:S.trim(a)})}),a.dropboxEnable.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{DropboxEnable:a?"1":"0"})}),a.dropboxApiKey.subscribe(function(a){cb.remote().saveAdminConfig(h,{DropboxApiKey:S.trim(a)})})},50)},S.addSettingsViewModel(B,"AdminSettingsPlugins","Plugins","plugins"),B.prototype.disablePlugin=function(a){a.disabled(!a.disabled()),cb.remote().pluginDisable(this.onPluginDisableRequest,a.name,a.disabled())},B.prototype.configurePlugin=function(a){cb.remote().plugin(this.onPluginLoadRequest,a.name)},B.prototype.onBuild=function(){this.enabledPlugins.subscribe(function(a){cb.remote().saveAdminConfig(S.emptyFunction,{EnabledPlugins:a?"1":"0"})})},B.prototype.onShow=function(){this.pluginsError(""),cb.reloadPluginList()},B.prototype.onPluginLoadRequest=function(a,b){Q.StorageResultType.Success===a&&b&&b.Result&&X.showScreenPopup(q,[b.Result])},B.prototype.onPluginDisableRequest=function(a,b){Q.StorageResultType.Success===a&&b&&!b.Result&&b.ErrorCode&&(Q.Notification.UnsupportedPluginPackage===b.ErrorCode&&b.ErrorMessage&&""!==b.ErrorMessage?this.pluginsError(b.ErrorMessage):this.pluginsError(S.getNotification(b.ErrorCode))),cb.reloadPluginList()},S.addSettingsViewModel(C,"AdminSettingsPackages","Packages","packages"),C.prototype.onShow=function(){this.packagesError("")},C.prototype.onBuild=function(){cb.reloadPackagesList()},C.prototype.requestHelper=function(b,c){var d=this;return function(e,g){Q.StorageResultType.Success===e&&g&&g.Result||(g&&g.ErrorCode?d.packagesError(S.getNotification(g.ErrorCode)):d.packagesError(S.getNotification(c?Q.Notification.CantInstallPackage:Q.Notification.CantDeletePackage))),f.each(cb.data().packages(),function(a){a&&b&&a.loading()&&b.file===a.file&&(b.loading(!1),a.loading(!1))}),Q.StorageResultType.Success===e&&g&&g.Result&&g.Result.Reload?a.location.reload():cb.reloadPackagesList()}},C.prototype.deletePackage=function(a){a&&(a.loading(!0),cb.remote().packageDelete(this.requestHelper(a,!1),a))},C.prototype.installPackage=function(a){a&&(a.loading(!0),cb.remote().packageInstall(this.requestHelper(a,!0),a))},S.addSettingsViewModel(D,"AdminSettingsLicensing","Licensing","licensing"),D.prototype.onBuild=function(){this.subscriptionEnabled()&&cb.reloadLicensing(!1)},D.prototype.onShow=function(){this.adminDomain(cb.settingsGet("AdminDomain"))},D.prototype.showActivationForm=function(){X.showScreenPopup(r)},D.prototype.licenseExpiredMomentValue=function(){var a=moment.unix(this.licenseExpired());return a.format("LL")+" ("+a.from(moment())+")"},E.prototype.populateDataOnStart=function(){var a=cb.settingsGet("Languages"),b=cb.settingsGet("Themes");S.isArray(a)&&this.languages(a),S.isArray(b)&&this.themes(b),this.mainLanguage(cb.settingsGet("Language")),this.mainTheme(cb.settingsGet("Theme")),this.allowCustomTheme(!!cb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!cb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!cb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!cb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!cb.settingsGet("AllowThemes")),this.allowCustomLogin(!!cb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!cb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!cb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(cb.settingsGet("EditorDefaultType")),this.showImages(!!cb.settingsGet("ShowImages")),this.interfaceAnimation(cb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(cb.settingsGet("MPP")),this.desktopNotifications(!!cb.settingsGet("DesktopNotifications")),this.useThreads(!!cb.settingsGet("UseThreads")),this.replySameFolder(!!cb.settingsGet("ReplySameFolder")),this.usePreviewPane(!!cb.settingsGet("UsePreviewPane")),this.useCheckboxesInList(!!cb.settingsGet("UseCheckboxesInList")),this.facebookEnable(!!cb.settingsGet("AllowFacebookSocial")),this.facebookAppID(cb.settingsGet("FacebookAppID")),this.facebookAppSecret(cb.settingsGet("FacebookAppSecret")),this.twitterEnable(!!cb.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(cb.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(cb.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!cb.settingsGet("AllowGoogleSocial")),this.googleClientID(cb.settingsGet("GoogleClientID")),this.googleClientSecret(cb.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!cb.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(cb.settingsGet("DropboxApiKey")),this.contactsIsSupported(!!cb.settingsGet("ContactsIsSupported")),this.contactsIsAllowed(!!cb.settingsGet("ContactsIsAllowed"))},f.extend(F.prototype,E.prototype),F.prototype.populateDataOnStart=function(){E.prototype.populateDataOnStart.call(this)},G.prototype.oRequests={},G.prototype.defaultResponse=function(b,c,d,e,g,h){var i=function(){Q.StorageResultType.Success!==d&&V.bUnload&&(d=Q.StorageResultType.Unload),Q.StorageResultType.Success===d&&e&&!e.Result?(e&&-1<S.inArray(e.ErrorCode,[Q.Notification.AuthError,Q.Notification.AccessError,Q.Notification.ConnectionError,Q.Notification.DomainNotAllowed,Q.Notification.AccountNotAllowed,Q.Notification.MailServerError,Q.Notification.UnknownNotification,Q.Notification.UnknownError])&&V.iAjaxErrorCount++,e&&Q.Notification.InvalidToken===e.ErrorCode&&V.iTokenErrorCount++,P.Values.TokenErrorLimit<V.iTokenErrorCount&&cb.loginAndLogoutReload(!0),(e.Logout||P.Values.AjaxErrorLimit<V.iAjaxErrorCount)&&(a.__rlah_clear&&a.__rlah_clear(),cb.loginAndLogoutReload(!0))):Q.StorageResultType.Success===d&&e&&e.Result&&(V.iAjaxErrorCount=0,V.iTokenErrorCount=0),b&&(T.runHook("ajax-default-response",[c,Q.StorageResultType.Success===d?e:null,d,g,h]),b(d,Q.StorageResultType.Success===d?e:null,g,c,h))};switch(d){case"success":d=Q.StorageResultType.Success;break;case"abort":d=Q.StorageResultType.Abort;break;default:d=Q.StorageResultType.Error}Q.StorageResultType.Error===d?f.delay(i,300):i()},G.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=S.isNormal(e)?e:2e4,g=S.isUnd(g)?"":S.pString(g),h=S.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=cb.settingsGet("Token")),m=b.ajax({type:j?"POST":"GET",url:cb.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=S.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<S.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},G.prototype.defaultRequest=function(a,b,c,d,e,f){c=c||{},c.Action=b,e=S.pString(e),T.runHook("ajax-default-request",[b,c,e]),this.ajaxRequest(a,c,S.isUnd(d)?P.Defaults.DefaultAjaxTimeout:S.pInt(d),e,f)},G.prototype.noop=function(a){this.defaultRequest(a,"Noop")},G.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})},G.prototype.jsInfo=function(a,b,c,d){this.defaultRequest(a,"JsInfo",{Type:b,Data:c,IsError:(S.isUnd(d)?1:!d)?"0":"1"})},f.extend(H.prototype,G.prototype),H.prototype.adminLogin=function(a,b,c){this.defaultRequest(a,"AdminLogin",{Login:b,Password:c})},H.prototype.adminLogout=function(a){this.defaultRequest(a,"AdminLogout")},H.prototype.saveAdminConfig=function(a,b){this.defaultRequest(a,"AdminSettingsUpdate",b)},H.prototype.domainList=function(a){this.defaultRequest(a,"AdminDomainList")},H.prototype.pluginList=function(a){this.defaultRequest(a,"AdminPluginList")},H.prototype.packagesList=function(a){this.defaultRequest(a,"AdminPackagesList")},H.prototype.packageInstall=function(a,b){this.defaultRequest(a,"AdminPackageInstall",{Id:b.id,Type:b.type,File:b.file},6e4)},H.prototype.packageDelete=function(a,b){this.defaultRequest(a,"AdminPackageDelete",{Id:b.id})},H.prototype.domain=function(a,b){this.defaultRequest(a,"AdminDomainLoad",{Name:b})},H.prototype.plugin=function(a,b){this.defaultRequest(a,"AdminPluginLoad",{Name:b})},H.prototype.domainDelete=function(a,b){this.defaultRequest(a,"AdminDomainDelete",{Name:b})},H.prototype.domainDisable=function(a,b,c){return this.defaultRequest(a,"AdminDomainDisable",{Name:b,Disabled:c?"1":"0"})},H.prototype.pluginSettingsUpdate=function(a,b){return this.defaultRequest(a,"AdminPluginSettingsUpdate",b)},H.prototype.licensing=function(a,b){return this.defaultRequest(a,"AdminLicensing",{Force:b?"1":"0"})},H.prototype.licensingActivate=function(a,b,c){return this.defaultRequest(a,"AdminLicensingActivate",{Domain:b,Key:c})},H.prototype.pluginDisable=function(a,b,c){return this.defaultRequest(a,"AdminPluginDisable",{Name:b,Disabled:c?"1":"0"})},H.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})},H.prototype.testConnectionForDomain=function(a,b,c,d,e,f,g,h){this.defaultRequest(a,"AdminDomainTest",{IncHost:b,IncPort:c,IncSecure:d,OutHost:e,OutPort:f,OutSecure:g,OutAuth:h?"1":"0"})},H.prototype.saveNewAdminPassword=function(a,b){this.defaultRequest(a,"AdminPasswordUpdate",b)},H.prototype.adminPing=function(a){this.defaultRequest(a,"AdminPing")},I.prototype.oEmailsPicsHashes={},I.prototype.oServices={},I.prototype.clear=function(){this.oServices={},this.oEmailsPicsHashes={}},I.prototype.getUserPic=function(a){var b="",c="",d=a.toLowerCase(),e=S.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];return""===e?(c=d.substr(a.indexOf("@")+1),b=""!==c&&this.oServices[c]?this.oServices[c]:""):b=cb.link().getUserPicUrlFromHash(e),b},I.prototype.setServicesData=function(a){this.oServices=a},I.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a},f.extend(J.prototype,I.prototype),f.extend(K.prototype,m.prototype),K.prototype.onRoute=function(a){var d=this,e=null,g=null,h=null,i=null;g=f.find(W.settings,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}),g&&(f.find(W["settings-removed"],function(a){return a&&a===g})&&(g=null),g&&f.find(W["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=cb.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),X.delegateRun(e,"onBuild",[i])):S.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(X.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),X.delegateRun(d.oCurrentSubScreen,"onShow"),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)),S.windowResize()})):X.setHash(cb.link().settings(),!1,!0)},K.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(X.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},K.prototype.onBuild=function(){f.each(W.settings,function(a){a&&a.__rlSettingsData&&!f.find(W["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(W["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},K.prototype.routes=function(){var a=f.find(W.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=S.isUnd(c.subname)?b:S.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(L.prototype,m.prototype),L.prototype.onShow=function(){cb.setTitle("")},f.extend(M.prototype,K.prototype),M.prototype.onShow=function(){cb.setTitle("")},f.extend(N.prototype,k.prototype),N.prototype.oSettings=null,N.prototype.oLink=null,N.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):(V.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},N.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},N.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},N.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=S.isNormal(Y)?Y:{}),S.isUnd(this.oSettings[a])?null:this.oSettings[a]},N.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=S.isNormal(Y)?Y:{}),this.oSettings[a]=b},N.prototype.setTitle=function(b){b=(0<b.length?b+" - ":"")+cb.settingsGet("Title")||"",a.document.title=b,f.delay(function(){a.document.title=b},5)},N.prototype.loginAndLogoutReload=function(b,c){var d=S.pString(cb.settingsGet("CustomLogoutLink")),e=!!cb.settingsGet("InIframe");b=S.isUnd(b)?!1:!!b,c=S.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):(X.routeOff(),X.setHash(cb.link().root(),!0),X.routeOff(),f.delay(function(){e&&a.parent?a.parent.location.reload():a.location.reload()},100))},N.prototype.getAutocomplete=function(a,b,c){c([],a)},N.prototype.bootstart=function(){S.initOnStartOrLangChange(function(){S.initNotificationLanguage()},null),f.delay(function(){S.windowResize()},1e3)},f.extend(O.prototype,N.prototype),O.prototype.oData=null,O.prototype.oRemote=null,O.prototype.oCache=null,O.prototype.data=function(){return null===this.oData&&(this.oData=new F),this.oData},O.prototype.remote=function(){return null===this.oRemote&&(this.oRemote=new H),this.oRemote},O.prototype.cache=function(){return null===this.oCache&&(this.oCache=new J),this.oCache},O.prototype.reloadDomainList=function(){cb.data().domainsLoading(!0),cb.remote().domainList(function(a,b){if(cb.data().domainsLoading(!1),Q.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);cb.data().domains(d)}})},O.prototype.reloadPluginList=function(){cb.data().pluginsLoading(!0),cb.remote().pluginList(function(a,b){if(cb.data().pluginsLoading(!1),Q.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);cb.data().plugins(d)}})},O.prototype.reloadPackagesList=function(){cb.data().packagesLoading(!0),cb.data().packagesReal(!0),cb.remote().packagesList(function(a,b){if(cb.data().packagesLoading(!1),Q.StorageResultType.Success===a&&b&&b.Result){cb.data().packagesReal(!!b.Result.Real),cb.data().packagesMainUpdatable(!!b.Result.MainUpdatable);var d=[],e={};f.each(cb.data().packages(),function(a){a&&a.loading()&&(e[a.file]=a)}),S.isArray(b.Result.List)&&(d=f.compact(f.map(b.Result.List,function(a){return a?(a.loading=c.observable(!S.isUnd(e[a.file])),"core"!==a.type||a.canBeInstalled?a:null):null}))),cb.data().packages(d)}else cb.data().packagesReal(!1)})},O.prototype.reloadLicensing=function(a){a=S.isUnd(a)?!1:!!a,cb.data().licensingProcess(!0),cb.data().licenseError(""),cb.remote().licensing(function(a,b){cb.data().licensingProcess(!1),Q.StorageResultType.Success===a&&b&&b.Result&&S.isNormal(b.Result.Expired)?(cb.data().licenseValid(!0),cb.data().licenseExpired(S.pInt(b.Result.Expired)),cb.data().licenseError(""),cb.data().licensing(!0)):b&&b.ErrorCode&&-1<S.inArray(S.pInt(b.ErrorCode),[Q.Notification.LicensingServerIsUnavailable,Q.Notification.LicensingExpired])?(cb.data().licenseError(S.getNotification(S.pInt(b.ErrorCode))),cb.data().licensing(!0)):Q.StorageResultType.Abort===a?(cb.data().licenseError(S.getNotification(Q.Notification.LicensingServerIsUnavailable)),cb.data().licensing(!0)):cb.data().licensing(!1)},a)},O.prototype.bootstart=function(){N.prototype.bootstart.call(this),cb.data().populateDataOnStart(),X.hideLoading(),cb.settingsGet("AllowAdminPanel")?cb.settingsGet("Auth")?(X.startScreens([M]),V.bMobileDevice||f.defer(function(){S.initLayoutResizer("#rl-top-resizer-left","#rl-top-resizer-right","#rl-center",120,300,200,600,Q.ClientSideKeyName.FolderListSize)})):X.startScreens([L]):(X.routeOff(),X.setHash(cb.link().root(),!0),X.routeOff(),f.defer(function(){a.location.href="/"})),a.SimplePace&&a.SimplePace.set(100)},cb=new O,$.addClass(V.bMobileDevice?"mobile":"no-mobile"),_.keydown(S.killCtrlAandS).keyup(S.killCtrlAandS),_.unload(function(){V.bUnload=!0}),a.rl=a.rl||{},a.rl.addHook=T.addHook,a.rl.settingsGet=T.mainSettingsGet,a.rl.remoteRequest=T.remoteRequest,a.rl.pluginSettingsGet=T.settingsGet,a.rl.addSettingsViewModel=S.addSettingsViewModel,a.rl.createCommand=S.createCommand,a.rl.EmailModel=o,a.rl.Enums=Q,a.__RLBOOT=function(c){b(function(){a.rainloopTEMPLATES&&a.rainloopTEMPLATES[0]?(b("#rl-templates").html(a.rainloopTEMPLATES[0]),a.setInterval(function(){V.minuteTick(!V.minuteTick())},6e4),a.setInterval(function(){V.fiveMinuteTick(!V.fiveMinuteTick())},3e5),f.delay(function(){a.rainloopAppData={},a.rainloopI18N={},a.rainloopTEMPLATES={},X.setBoot(cb).bootstart(),$.addClass("rl-started")},50)):c(!1),a.__RLBOOT=null})},a.SimplePace&&a.SimplePace.add(10)}(window,jQuery,ko,crossroads,hasher,_);