snappymail/rainloop/v/0.0.0/static/js/admin.min.js
2013-12-31 15:57:02 +04:00

4 lines
92 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=eb.settingsGet("CdnStaticDomain"),this.sVersion=eb.settingsGet("Version"),this.sSpecSuffix=eb.settingsGet("AuthAccountHash")||"0",this.sServer=(eb.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=U.pString(a),this.sTemplate=U.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=U.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){eb&&eb.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(R.Values.ImapDefaulPort),this.imapSecure=c.observable(S.ServerSecure.None),this.imapShortLogin=c.observable(!1),this.smtpServer=c.observable(""),this.smtpPort=c.observable(R.Values.SmtpDefaulPort),this.smtpSecure=c.observable(S.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=U.createCommand(this,function(){this.saving(!0),eb.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=U.createCommand(this,function(){this.whiteListPage(!1),this.testingDone(!1),this.testingImapError(!1),this.testingSmtpError(!1),this.testing(!0),eb.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=U.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())}),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=U.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(""),eb.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse,a)},this.hasConfiguration),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=eb.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=U.createCommand(this,function(){this.activateProcess(!0),this.validateSubscriptionKey()?eb.remote().licensingActivate(function(b,c){a.activateProcess(!1),S.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(U.getNotification(c.ErrorCode)),a.activateText.isError(!0),a.key.focus(!0)):(a.activateText(U.getNotification(S.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(eb.data().languages(),function(a){return{key:a,selected:c.observable(!1),fullName:U.convertLangName(a)}})}),eb.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,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=U.createCommand(this,function(){return this.loginError(""===U.trim(this.login())),this.passwordError(""===U.trim(this.password())),this.loginError()||this.passwordError()?!1:(this.submitRequest(!0),eb.remote().adminLogin(f.bind(function(a,b){S.StorageResultType.Success===a&&b&&"AdminLogin"===b.Action?b.Result?eb.loginAndLogoutReload():b.ErrorCode&&(this.submitRequest(!1),this.submitError(U.getNotification(b.ErrorCode))):(this.submitRequest(!1),this.submitError(U.getNotification(S.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(eb.settingsGet("AdminDomain")),this.version=c.observable(eb.settingsGet("Version")),n.constructorEnd(this)}function x(){var a=eb.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(eb.settingsGet("Title")),this.loadingDesc=c.observable(eb.settingsGet("LoadingDescription")),this.themesOptions=c.computed(function(){return f.map(a.themes(),function(a){return{optValue:a,optText:U.convertThemeName(a)}})}),this.mainLanguageFullName=c.computed(function(){return U.convertLangName(this.mainLanguage())},this),this.weakPassword=!!eb.settingsGet("WeakPassword"),this.titleTrigger=c.observable(S.SaveSettingsStep.Idle),this.languageTrigger=c.observable(S.SaveSettingsStep.Idle),this.themeTrigger=c.observable(S.SaveSettingsStep.Idle),this.loadingDescTrigger=c.observable(S.SaveSettingsStep.Idle)}function y(){var a=eb.data();this.allowCustomLogin=a.allowCustomLogin,this.determineUserLanguage=a.determineUserLanguage,this.defaultDomain=c.observable(eb.settingsGet("LoginDefaultDomain")),this.allowLanguagesOnLogin=a.allowLanguagesOnLogin,this.defaultDomainTrigger=c.observable(S.SaveSettingsStep.Idle)}function z(){this.defautOptionsAfterRender=U.defautOptionsAfterRender,this.enableContacts=c.observable(!!eb.settingsGet("ContactsEnable")),this.contactsSharing=c.observable(!!eb.settingsGet("ContactsSharing")),this.contactsSync=c.observable(!!eb.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};eb.settingsGet("SQLiteIsSupported")&&b.push("sqlite"),eb.settingsGet("MySqlIsSupported")&&b.push("mysql"),eb.settingsGet("PostgreSqlIsSupported")&&b.push("pgsql"),this.contactsSupported=0<b.length,this.contactsTypes=c.observableArray([]),this.contactsTypesOptions=this.contactsTypes.map(function(a){var c=-1===U.inArray(a,b);return{id:a,name:d(a)+(c?" (not supported)":""),disable:c}}),this.contactsTypes(a),this.contactsType=c.observable(""),this.mainContactsType=c.computed({owner:this,read:this.contactsType,write:function(a){a!==this.contactsType()?-1<U.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(eb.settingsGet("ContactsPdoDsn")),this.pdoUser=c.observable(eb.settingsGet("ContactsPdoUser")),this.pdoPassword=c.observable(eb.settingsGet("ContactsPdoPassword")),this.pdoDsnTrigger=c.observable(S.SaveSettingsStep.Idle),this.pdoUserTrigger=c.observable(S.SaveSettingsStep.Idle),this.pdoPasswordTrigger=c.observable(S.SaveSettingsStep.Idle),this.contactsTypeTrigger=c.observable(S.SaveSettingsStep.Idle),this.testing=c.observable(!1),this.testContactsSuccess=c.observable(!1),this.testContactsError=c.observable(!1),this.testContactsErrorMessage=c.observable(""),this.testContactsCommand=U.createCommand(this,function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage(""),this.testing(!0),eb.remote().testContacts(this.onTestContactsResponse,{ContactsPdoType:this.contactsType(),ContactsPdoDsn:this.pdoDsn(),ContactsPdoUser:this.pdoUser(),ContactsPdoPassword:this.pdoPassword()})},function(){return""!==this.pdoDsn()&&""!==this.pdoUser()}),this.contactsType(eb.settingsGet("ContactsPdoType")),this.onTestContactsResponse=f.bind(this.onTestContactsResponse,this)}function A(){var a=eb.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 B(){this.csrfProtection=c.observable(!!eb.settingsGet("UseTokenProtection")),this.adminLogin=c.observable(eb.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=U.createCommand(this,function(){this.adminPasswordUpdateError(!1),this.adminPasswordUpdateSuccess(!1),eb.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse,{Password:this.adminPassword(),NewPassword:this.adminPasswordNew()})},function(){return""!==this.adminPassword()&&""!==this.adminPasswordNew()}),this.onNewAdminPasswordResponse=f.bind(this.onNewAdminPasswordResponse,this)}function C(){var a=eb.data();this.googleEnable=a.googleEnable,this.googleClientID=a.googleClientID,this.googleClientSecret=a.googleClientSecret,this.googleTrigger1=c.observable(S.SaveSettingsStep.Idle),this.googleTrigger2=c.observable(S.SaveSettingsStep.Idle),this.facebookEnable=a.facebookEnable,this.facebookAppID=a.facebookAppID,this.facebookAppSecret=a.facebookAppSecret,this.facebookTrigger1=c.observable(S.SaveSettingsStep.Idle),this.facebookTrigger2=c.observable(S.SaveSettingsStep.Idle),this.twitterEnable=a.twitterEnable,this.twitterConsumerKey=a.twitterConsumerKey,this.twitterConsumerSecret=a.twitterConsumerSecret,this.twitterTrigger1=c.observable(S.SaveSettingsStep.Idle),this.twitterTrigger2=c.observable(S.SaveSettingsStep.Idle),this.dropboxEnable=a.dropboxEnable,this.dropboxApiKey=a.dropboxApiKey,this.dropboxTrigger1=c.observable(S.SaveSettingsStep.Idle)}function D(){var a=eb.data();this.enabledPlugins=c.observable(!!eb.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 E(){var a=eb.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 F(){this.licensing=eb.data().licensing,this.licensingProcess=eb.data().licensingProcess,this.licenseValid=eb.data().licenseValid,this.licenseExpired=eb.data().licenseExpired,this.licenseError=eb.data().licenseError,this.licenseTrigger=eb.data().licenseTrigger,this.adminDomain=c.observable(""),this.subscriptionEnabled=c.observable(!!eb.settingsGet("SubscriptionEnabled")),this.licenseTrigger.subscribe(function(){this.subscriptionEnabled()&&eb.reloadLicensing(!0)},this)}function G(){U.initDataConstructorBySettings(this)}function H(){G.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 I(){this.oRequests={}}function J(){I.call(this),this.oRequests={}}function K(){this.oEmailsPicsHashes={},this.oServices={}}function L(){K.call(this)}function M(a){m.call(this,"settings",a),this.menu=c.observableArray([]),this.oCurrentSubScreen=null,this.oViewModelPlace=null}function N(){m.call(this,"login",[u])}function O(){M.call(this,[v,w])}function P(){k.call(this),this.oSettings=null,this.oPlugins=null,this.oLocal=null,this.oLink=null,this.oSubs={},this.isLocalAutocomplete=!0,this.popupVisibility=c.observable(!1),this.iframe=b('<iframe style="display:none" src="javascript:;" />').appendTo("body"),bb.on("error",function(a){eb&&a&&a.originalEvent&&a.originalEvent.message&&-1===U.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."])&&eb.remote().jsError(U.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",ab.attr("class"),U.microtime()-X.now)})}function Q(){P.call(this),this.oData=null,this.oRemote=null,this.oCache=null}var R={},S={},T={},U={},V={},W={},X={},Y={settings:[],"settings-removed":[],"settings-disabled":[]},Z=null,$=a.rainloopAppData||{},_=a.rainloopI18N||{},ab=b("html"),bb=b(a),cb=b(a.document),db=a.Notification&&a.Notification.requestPermission?a.Notification:null,eb=null;X.now=(new Date).getTime(),X.momentTrigger=c.observable(!0),X.langChangeTrigger=c.observable(!0),X.iAjaxErrorCount=0,X.iTokenErrorCount=0,X.iMessageBodyCacheCount=0,X.bUnload=!1,X.sUserAgent=(navigator.userAgent||"").toLowerCase(),X.bIsiOSDevice=-1<X.sUserAgent.indexOf("iphone")||-1<X.sUserAgent.indexOf("ipod")||-1<X.sUserAgent.indexOf("ipad"),X.bIsAndroidDevice=-1<X.sUserAgent.indexOf("android"),X.bMobileDevice=X.bIsiOSDevice||X.bIsAndroidDevice,X.bDisableNanoScroll=X.bMobileDevice,X.bAllowPdfPreview=!X.bMobileDevice,X.bAnimationSupported=!X.bMobileDevice&&ab.hasClass("csstransitions"),X.sAnimationType="",X.bAllowPdfPreview&&navigator&&navigator.mimeTypes&&(X.bAllowPdfPreview=!!f.find(navigator.mimeTypes,function(a){return a&&"application/pdf"===a.type})),R.Defaults={},R.Values={},R.DataImages={},R.Defaults.MessagesPerPage=20,R.Defaults.ContactsPerPage=20,R.Defaults.MessagesPerPageArray=[10,20,30,50,100],R.Defaults.DefaultAjaxTimeout=2e4,R.Defaults.SearchAjaxTimeout=12e4,R.Defaults.SendMessageAjaxTimeout=2e5,R.Defaults.SaveMessageAjaxTimeout=2e5,R.Values.UnuseOptionValue="__UNUSE__",R.Values.GmailFolderName="[Gmail]",R.Values.ClientSideCookieIndexName="rlcsc",R.Values.ImapDefaulPort=143,R.Values.ImapDefaulSecurePort=993,R.Values.SmtpDefaulPort=25,R.Values.SmtpDefaulSecurePort=465,R.Values.MessageBodyCacheLimit=15,R.Values.AjaxErrorLimit=7,R.Values.TokenErrorLimit=10,R.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=",R.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=",S.StorageResultType={Success:"success",Abort:"abort",Error:"error",Unload:"unload"},S.State={Empty:10,Login:20,Auth:30},S.StateType={Webmail:0,Admin:1},S.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99},S.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"},S.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2},S.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"},S.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99},S.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4},S.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3,FolderListSize:4},S.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,Insert:45,Delete:46,A:65,S:83},S.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3},S.MessageSelectAction={All:0,None:1,Invert:2,Unseen:3,Seen:4,Flagged:5,Unflagged:6},S.DesktopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9},S.MessagePriority={Low:5,Normal:3,High:1},S.EditorDefaultType={Html:"Html",Plain:"Plain"},S.CustomThemeType={Light:"Light",Dark:"Dark"},S.ServerSecure={None:0,SSL:1,TLS:2},S.SearchDateType={All:-1,Days3:3,Days7:7,Month:30},S.EmailType={Defailt:0,Facebook:1,Google:2},S.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0},S.InterfaceAnimation={None:"None",Normal:"Normal",Full:"Full"},S.ContactScopeType={Default:0,ShareAll:2},S.ContactPropertyType={Unknown:0,FullName:10,FirstName:15,LastName:16,MiddleName:16,Nick:18,NamePrefix:20,NameSuffix:21,EmailPersonal:30,EmailBussines:31,PhonePersonal:50,PhoneBussines:51,MobilePersonal:60,MobileBussines:61,FaxPesonal:70,FaxBussines:71,Facebook:90,Skype:91,GitHub:92,Note:110,Custom:250},S.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,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,UnknownNotification:999,UnknownError:999},U.trim=b.trim,U.inArray=b.inArray,U.isArray=f.isArray,U.isFunc=f.isFunction,U.isUnd=f.isUndefined,U.isNull=f.isNull,U.emptyFunction=function(){},U.isNormal=function(a){return!U.isUnd(a)&&!U.isNull(a)},U.windowResize=f.debounce(function(b){U.isUnd(b)?bb.resize():a.setTimeout(function(){bb.resize()},b)},50),U.isPosNumeric=function(a,b){return U.isNormal(a)?(U.isUnd(b)?0:!b)?/^[1-9]+[0-9]*$/.test(a.toString()):/^[0-9]*$/.test(a.toString()):!1},U.pInt=function(b){return U.isNormal(b)&&""!==b?a.parseInt(b,10):0},U.pString=function(a){return U.isNormal(a)?""+a:""},U.isNonEmptyArray=function(a){return U.isArray(a)&&0<a.length},U.exportPath=function(b,c,d){for(var e=null,f=b.split("."),g=d||a;f.length&&(e=f.shift());)f.length||U.isUnd(c)?g=g[e]?g[e]:g[e]={}:g[e]=c},U.pImport=function(a,b,c){a[b]=c},U.pExport=function(a,b,c){return U.isUnd(a[b])?c:a[b]},U.encodeHtml=function(a){return U.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""},U.splitPlainText=function(a,b){var c="",d="",e=a,f=0,g=0;for(b=U.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},U.timeOutAction=function(){var b={};return function(c,d,e){U.isUnd(b[c])&&(b[c]=0),a.clearTimeout(b[c]),b[c]=a.setTimeout(d,e)}}(),U.timeOutActionSecond=function(){var b={};return function(c,d,e){b[c]||(b[c]=a.setTimeout(function(){d(),b[c]=0},e))}}(),U.audio=function(){var b=!1;return function(c,d){if(!1===b)if(X.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}}(),U.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1},U.i18n=function(a,b,c){var d="",e=U.isUnd(_[a])?U.isUnd(c)?a:c:_[a];if(!U.isUnd(b)&&!U.isNull(b))for(d in b)U.hos(b,d)&&(e=e.replace("%"+d+"%",b[d]));return e},U.i18nToNode=function(a){f.defer(function(){b(".i18n",a).each(function(){var a=b(this),c="";c=a.data("i18n-text"),c?a.text(U.i18n(c)):(c=a.data("i18n-html"),c&&a.html(U.i18n(c)),c=a.data("i18n-placeholder"),c&&a.attr("placeholder",U.i18n(c)))})})},U.i18nToDoc=function(){a.rainloopI18N&&(_=a.rainloopI18N||{},U.i18nToNode(cb),X.langChangeTrigger(!X.langChangeTrigger())),a.rainloopI18N={}},U.initOnStartOrLangChange=function(a,b,c){a&&a.call(b),c?X.langChangeTrigger.subscribe(function(){a&&a.call(b),c.call(b)}):a&&X.langChangeTrigger.subscribe(a,b)},U.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)},U.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=b(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}},U.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()},U.replySubjectAdd=function(b,c,d){var e=null,f=U.trim(c);return null===(e=new a.RegExp("^"+b+"[\\s]?\\:(.*)$","gi").exec(c))||U.isUnd(e[1])?null===(e=new a.RegExp("^("+b+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi").exec(c))||U.isUnd(e[1])||U.isUnd(e[2])||U.isUnd(e[3])?f=b+": "+c:(f=e[1]+(U.pInt(e[2])+1)+e[3],f=e[1]+(U.pInt(e[2])+1)+e[3]):f=b+"[2]: "+e[1],f=f.replace(/[\s]+/g," "),(U.isUnd(d)?!0:d)?U.fixLongSubject(f):f},U.fixLongSubject=function(a){var b=0,c=null;a=U.trim(a.replace(/[\s]+/," "));do c=/^Re(\[([\d]+)\]|):[\s]{0,3}Re(\[([\d]+)\]|):/gi.exec(a),(!c||U.isUnd(c[0]))&&(c=null),c&&(b=0,b+=U.isUnd(c[2])?1:0+U.pInt(c[2]),b+=U.isUnd(c[4])?1:0+U.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]+/," ")},U.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)},U.friendlySize=function(a){return a=U.pInt(a),a>=1073741824?U.roundNumber(a/1073741824,1)+"GB":a>=1048576?U.roundNumber(a/1048576,1)+"MB":a>=1024?U.roundNumber(a/1024,0)+"KB":a+"B"},U.log=function(b){a.console&&a.console.log&&a.console.log(b)},U.getNotification=function(a){return a=U.pInt(a),U.isUnd(T[a])?"":T[a]},U.initNotificationLanguage=function(){T[S.Notification.InvalidToken]=U.i18n("NOTIFICATIONS/INVALID_TOKEN"),T[S.Notification.AuthError]=U.i18n("NOTIFICATIONS/AUTH_ERROR"),T[S.Notification.AccessError]=U.i18n("NOTIFICATIONS/ACCESS_ERROR"),T[S.Notification.ConnectionError]=U.i18n("NOTIFICATIONS/CONNECTION_ERROR"),T[S.Notification.CaptchaError]=U.i18n("NOTIFICATIONS/CAPTCHA_ERROR"),T[S.Notification.SocialFacebookLoginAccessDisable]=U.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE"),T[S.Notification.SocialTwitterLoginAccessDisable]=U.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE"),T[S.Notification.SocialGoogleLoginAccessDisable]=U.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE"),T[S.Notification.DomainNotAllowed]=U.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED"),T[S.Notification.AccountNotAllowed]=U.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"),T[S.Notification.CantGetMessageList]=U.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST"),T[S.Notification.CantGetMessage]=U.i18n("NOTIFICATIONS/CANT_GET_MESSAGE"),T[S.Notification.CantDeleteMessage]=U.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE"),T[S.Notification.CantMoveMessage]=U.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),T[S.Notification.CantCopyMessage]=U.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE"),T[S.Notification.CantSaveMessage]=U.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE"),T[S.Notification.CantSendMessage]=U.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE"),T[S.Notification.InvalidRecipients]=U.i18n("NOTIFICATIONS/INVALID_RECIPIENTS"),T[S.Notification.CantCreateFolder]=U.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER"),T[S.Notification.CantRenameFolder]=U.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER"),T[S.Notification.CantDeleteFolder]=U.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER"),T[S.Notification.CantDeleteNonEmptyFolder]=U.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER"),T[S.Notification.CantSubscribeFolder]=U.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER"),T[S.Notification.CantUnsubscribeFolder]=U.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"),T[S.Notification.CantSaveSettings]=U.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS"),T[S.Notification.CantSavePluginSettings]=U.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS"),T[S.Notification.DomainAlreadyExists]=U.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS"),T[S.Notification.CantInstallPackage]=U.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE"),T[S.Notification.CantDeletePackage]=U.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE"),T[S.Notification.InvalidPluginPackage]=U.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"),T[S.Notification.UnsupportedPluginPackage]=U.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE"),T[S.Notification.LicensingServerIsUnavailable]=U.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE"),T[S.Notification.LicensingExpired]=U.i18n("NOTIFICATIONS/LICENSING_EXPIRED"),T[S.Notification.LicensingBanned]=U.i18n("NOTIFICATIONS/LICENSING_BANNED"),T[S.Notification.DemoSendMessageError]=U.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR"),T[S.Notification.AccountAlreadyExists]=U.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"),T[S.Notification.MailServerError]=U.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR"),T[S.Notification.UnknownNotification]=U.i18n("NOTIFICATIONS/UNKNOWN_ERROR"),T[S.Notification.UnknownError]=U.i18n("NOTIFICATIONS/UNKNOWN_ERROR")},U.getUploadErrorDescByCode=function(a){var b="";switch(U.pInt(a)){case S.UploadErrorCode.FileIsTooBig:b=U.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case S.UploadErrorCode.FilePartiallyUploaded:b=U.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case S.UploadErrorCode.FileNoUploaded:b=U.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case S.UploadErrorCode.MissingTempFolder:b=U.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case S.UploadErrorCode.FileOnSaveingError:b=U.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case S.UploadErrorCode.FileType:b=U.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=U.i18n("UPLOAD/ERROR_UNKNOWN")}return b},U.delegateRun=function(a,b,c){a&&a[b]&&a[b].apply(a,U.isArray(c)?c:[])},U.killCtrlAandS=function(b){if(b=b||a.event){var c=b.target||b.srcElement,d=b.keyCode||b.which;if(b.ctrlKey&&d===S.EventKeyCode.S)return b.preventDefault(),void 0;if(c&&c.tagName&&c.tagName.match(/INPUT|TEXTAREA/i))return;b.ctrlKey&&d===S.EventKeyCode.A&&(a.getSelection?a.getSelection().removeAllRanges():a.document.selection&&a.document.selection.clear&&a.document.selection.clear(),b.preventDefault())}},U.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=U.isUnd(d)?!0:d,e.canExecute=U.isFunc(d)?c.computed(function(){return e.enabled()&&d.call(a)}):c.computed(function(){return e.enabled()&&!!d}),e},U.initDataConstructorBySettings=function(b){b.editorDefaultType=c.observable(S.EditorDefaultType.Html),b.showImages=c.observable(!1),b.interfaceAnimation=c.observable(S.InterfaceAnimation.Full),b.contactsAutosave=c.observable(!1),X.sAnimationType=S.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(X.bMobileDevice||a===S.InterfaceAnimation.None)ab.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),X.sAnimationType=S.InterfaceAnimation.None;else switch(a){case S.InterfaceAnimation.Full:ab.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full"),X.sAnimationType=a;
break;case S.InterfaceAnimation.Normal:ab.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),X.sAnimationType=a}}),b.interfaceAnimation.valueHasMutated(),b.desktopNotificationsPermisions=c.computed(function(){b.desktopNotifications();var c=S.DesktopNotifications.NotSupported;if(db&&db.permission)switch(db.permission.toLowerCase()){case"granted":c=S.DesktopNotifications.Allowed;break;case"denied":c=S.DesktopNotifications.Denied;break;case"default":c=S.DesktopNotifications.NotAllowed}else a.webkitNotifications&&a.webkitNotifications.checkPermission&&(c=a.webkitNotifications.checkPermission());return c}),b.useDesktopNotifications=c.computed({read:function(){return b.desktopNotifications()&&S.DesktopNotifications.Allowed===b.desktopNotificationsPermisions()},write:function(a){if(a){var c=b.desktopNotificationsPermisions();S.DesktopNotifications.Allowed===c?b.desktopNotifications(!0):S.DesktopNotifications.NotAllowed===c?db.requestPermission(function(){b.desktopNotifications.valueHasMutated(),S.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<U.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<U.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(R.Defaults.MessagesPerPage),b.mainMessagesPerPage=b.messagesPerPage,b.mainMessagesPerPage=c.computed({read:b.messagesPerPage,write:function(a){-1<U.inArray(U.pInt(a),R.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)},U.createMomentDate=function(a){return U.isUnd(a.moment)&&(a.moment=c.observable(moment())),c.computed(function(){return X.momentTrigger(),this.moment().fromNow()},a)},U.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")?U.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):b.clone().subtract("days",1).format("L")===c.format("L")?U.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:c.format("LT")}):b.year()===c.year()?c.format("D MMM."):c.format("LL")},a)},U.isFolderExpanded=function(a){var b=eb.local().get(S.ClientSideKeyName.ExpandedFolders);return f.isArray(b)&&-1!==f.indexOf(b,a)},U.setExpandedFolder=function(a,b){var c=eb.local().get(S.ClientSideKeyName.ExpandedFolders);f.isArray(c)||(c=[]),b?(c.push(a),c=f.uniq(c)):c=f.without(c,a),eb.local().set(S.ClientSideKeyName.ExpandedFolders,c)},U.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=eb.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&&eb.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),bb.resize(f.throttle(q,400))},U.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"),U.windowResize()}).after("<br />").before("<br />"))})}},U.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()}))},U.extendAsViewModel=function(a,b,c){b&&(c||(c=l),b.__name=a,V.regViewModelHook(a,b),f.extend(b.prototype,c.prototype))},U.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e},Y.settings.push(a)},U.removeSettingsViewModel=function(a){Y["settings-removed"].push(a)},U.disableSettingsViewModel=function(a){Y["settings-disabled"].push(a)},U.convertThemeName=function(a){return U.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))},U.quoteName=function(a){return a.replace(/["]/g,'\\"')},U.microtime=function(){return(new Date).getTime()},U.convertLangName=function(a,b){return U.i18n("LANGS_NAMES"+(!0===b?"_EN":"")+"/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)},U.fakeMd5=function(a){var b="",c="0123456789abcdefghijklmnopqrstuvwxyz";for(a=U.isUnd(a)?32:U.pInt(a);b.length<a;)b+=c.substr(Math.round(Math.random()*c.length),1);return b},U.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")},U.draggeblePlace=function(){return b('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-mail icon-white"></i></div>').appendTo("#rl-hidden")},U.defautOptionsAfterRender=function(a,b){b&&!U.isUnd(b.disable)&&c.applyBindingsToNode(a,{disable:b.disable},b)},U.windowPopupKnockout=function(c,d,e,f){var g=null,h=a.open(""),i="__OpenerApplyBindingsUid"+U.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")),U.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>'+U.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)},U.settingsSaveHelperFunction=function(a,b,c,d){return c=c||null,d=U.isUnd(d)?1e3:U.pInt(d),function(e,g,h,i,j){b.call(c,g&&g.Result?S.SaveSettingsStep.TrueResult:S.SaveSettingsStep.FalseResult),a&&a.call(c,e,g,h,i,j),f.delay(function(){b.call(c,S.SaveSettingsStep.Idle)},d)}},U.settingsSaveHelperSimpleFunction=function(a,b){return U.settingsSaveHelperFunction(null,a,b,1e3)},U.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.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:U.isUnd(c)?a.toString():c.toString(),custom:U.isUnd(c)?!1:!0,title:U.isUnd(c)?"":a.toString(),value:a.toString()};(U.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}},W={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return W.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){var b,c,d,e,f,g,h,i="",j=0;for(a=W._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 W._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(!X.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+'">'+U.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).toggleClass("fade",!X.bMobileDevice).modal({keyboard:!1,show:c.utils.unwrapObservable(d())}).on("hidden",function(){d()(!1)}).on("shown",function(){U.windowResize()})},update:function(a,d){b(a).modal(c.utils.unwrapObservable(d())?"show":"hide")}},c.bindingHandlers.i18nInit={init:function(a){U.i18nToNode(a)}},c.bindingHandlers.i18nUpdate={update:function(a,b){c.utils.unwrapObservable(b()),U.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=U.pInt(e[1]),g=0,h=b(a).offset().top;h>0&&(h+=U.pInt(e[2]),g=bb.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(!X.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),U.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),U.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(){U.removeInFocus()})}}},c.bindingHandlers.droppable={init:function(a,c,d){if(!X.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){X.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){eb.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=U.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(U.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},U.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=U.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=U.trim(a),this.hasError(""!==a&&!/^.+@.+$/.test(a))},this),this.valueHasMutated(),this},c.observable.fn.validateFunc=function(a){return this.hasFuncError=c.observable(!1),U.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 U.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=U.isNormal(b)?U.pInt(b):1,c=U.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+"/":"")},V.oViewModelsHooks={},V.oSimpleHooks={},V.regViewModelHook=function(a,b){b&&(b.__hookName=a)},V.addHook=function(a,b){U.isFunc(b)&&(U.isArray(V.oSimpleHooks[a])||(V.oSimpleHooks[a]=[]),V.oSimpleHooks[a].push(b))},V.runHook=function(a,b){U.isArray(V.oSimpleHooks[a])&&(b=b||[],f.each(V.oSimpleHooks[a],function(a){a.apply(null,b)}))},V.mainSettingsGet=function(a){return eb?eb.settingsGet(a):null},V.remoteRequest=function(a,b,c,d,e,f){eb&&eb.remote().defaultRequest(a,b,c,d,e,f)},V.settingsGet=function(a,b){var c=V.mainSettingsGet("Plugins");return c=c&&U.isUnd(c[a])?null:c[a],c?U.isUnd(c[b])?null:c[b]:null},h.supported=function(){return!0},h.prototype.set=function(a,c){var d=b.cookie(R.Values.ClientSideCookieIndexName),e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[a]=c,b.cookie(R.Values.ClientSideCookieIndexName,JSON.stringify(f),{expires:30}),e=!0}catch(g){}return e},h.prototype.get=function(a){var c=b.cookie(R.Values.ClientSideCookieIndexName),d=null;try{d=null===c?null:JSON.parse(c),d=d&&!U.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[R.Values.ClientSideCookieIndexName]||null,e=!1,f=null;try{f=null===d?null:JSON.parse(d),f||(f={}),f[b]=c,a.localStorage[R.Values.ClientSideCookieIndexName]=JSON.stringify(f),e=!0}catch(g){}return e},i.prototype.get=function(b){var c=a.localStorage[R.Values.ClientSideCookieIndexName]||null,d=null;try{d=null===c?null:JSON.parse(c),d=d&&!U.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;U.isNonEmptyArray(a)&&(c=f.bind(this.onRoute||U.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){U.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 U.isNormal(a)&&(this.oBoot=a),this},n.prototype.screen=function(a){return""===a||U.isUnd(this.oScreens[a])?null:this.oScreens[a]},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=eb.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=U.createCommand(e,function(){Z.hideScreenPopup(a)})),V.runHook("view-model-pre-build",[a.__name,e,h]),c.applyBindings(e,h[0]),U.delegateRun(e,"onBuild",[h]),V.runHook("view-model-post-build",[a.__name,e,h])):U.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.__vm.modalVisibility(!1),U.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),V.runHook("view-model-on-hide",[a.__name,a.__vm]),f.delay(function(){a.__dom.hide()},300))},n.prototype.showScreenPopup=function(a,b){a&&(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),U.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),V.runHook("view-model-on-show",[a.__name,a.__vm,b||[]]),f.delay(function(){U.delegateRun(a.__vm,"onFocus")},500)))},n.prototype.screenOnRoute=function(a,b){var c=this,d=null,e=null;""===U.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,U.isNonEmptyArray(d.viewModels())&&f.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),U.delegateRun(d,"onBuild")),f.defer(function(){c.oCurrentScreen&&(U.delegateRun(c.oCurrentScreen,"onHide"),U.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),U.delegateRun(a.__vm,"onHide"))})),c.oCurrentScreen=d,c.oCurrentScreen&&(U.delegateRun(c.oCurrentScreen,"onShow"),V.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]),U.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),U.delegateRun(a.__vm,"onShow"),V.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(),V.runHook("screen-pre-start",[a.screenName(),a]),U.delegateRun(a,"onStart"),V.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(){ab.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=U.isUnd(c)?!1:!!c,(U.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},Z=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=S.EmailType.Facebook),null===this.privateType&&(this.privateType=S.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=U.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=U.trim(a.Name),this.email=U.trim(a.Email),b=""!==this.email,this.clearDuplicateName()),b},o.prototype.toLine=function(a,b,c){var d="";return""!==this.email&&(b=U.isUnd(b)?!1:!!b,c=U.isUnd(c)?!1:!!c,a&&""!==this.name?d=b?'<a href="mailto:'+U.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+U.encodeHtml(this.name)+"</a>":c?U.encodeHtml(this.name):this.name:(d=this.email,""!==this.name?b?d=U.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+U.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+U.encodeHtml(d)+"</a>"+U.encodeHtml(">"):(d='"'+this.name+'" <'+d+">",c&&(d=U.encodeHtml(d))):b&&(d='<a href="mailto:'+U.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+U.encodeHtml(this.email)+"</a>"))),d},o.prototype.mailsoParse=function(a){if(a=U.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=U.trim(e).replace(/^[<]+/,"").replace(/[>]+$/,""),d=U.trim(d).replace(/^["']+/,"").replace(/["']+$/,""),f=U.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},U.extendAsViewModel("PopupsDomainViewModel",p),p.prototype.onTestConnectionResponse=function(a,b){this.testing(!1),S.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),S.StorageResultType.Success===a&&b?b.Result?(eb.reloadDomainList(),this.closeCommand()):S.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(U.trim(a.Name)),this.imapServer(U.trim(a.IncHost)),this.imapPort(U.pInt(a.IncPort)),this.imapSecure(U.trim(a.IncSecure)),this.imapShortLogin(!!a.IncShortLogin),this.smtpServer(U.trim(a.OutHost)),this.smtpPort(U.pInt(a.OutPort)),this.smtpSecure(U.trim(a.OutSecure)),this.smtpShortLogin(!!a.OutShortLogin),this.smtpAuth(!!a.OutAuth),this.whiteList(U.trim(a.WhiteList)))
},p.prototype.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&S.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(U.delegateRun(a,"cancelCommand"),c=!1),c})},p.prototype.clearForm=function(){this.edit(!1),this.whiteListPage(!1),this.savingError(""),this.name(""),this.imapServer(""),this.imapPort(R.Values.ImapDefaulPort),this.imapSecure(S.ServerSecure.None),this.imapShortLogin(!1),this.smtpServer(""),this.smtpPort(R.Values.SmtpDefaulPort),this.smtpSecure(S.ServerSecure.None),this.smtpShortLogin(!1),this.smtpAuth(!0),this.whiteList("")},U.extendAsViewModel("PopupsPluginViewModel",q),q.prototype.onPluginSettingsUpdateResponse=function(a,b){S.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),b&&b.ErrorCode?this.saveError(U.getNotification(b.ErrorCode)):this.saveError(U.getNotification(S.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;U.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;Z.showScreenPopup(t,[U.i18n("POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW"),function(){a.modalVisibility()&&U.delegateRun(a,"cancelCommand")}])},q.prototype.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&S.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(a.tryToClosePopup(),c=!1),c})},U.extendAsViewModel("PopupsActivateViewModel",r),r.prototype.onShow=function(){this.domain(eb.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(U.trim(a))},U.extendAsViewModel("PopupsLanguagesViewModel",s),s.prototype.languageEnName=function(a){return U.convertLangName(a,!0)},s.prototype.resetMainLanguage=function(){var a=eb.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.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&S.EventKeyCode.Esc===b.keyCode&&a.modalVisibility()&&(U.delegateRun(a,"cancelCommand"),c=!1),c})},s.prototype.changeLanguage=function(a){eb.data().mainLanguage(a),this.cancelCommand()},U.extendAsViewModel("PopupsAskViewModel",t),t.prototype.clearPopup=function(){this.askDesc(""),this.yesButton(U.i18n("POPUPS_ASK/BUTTON_YES")),this.noButton(U.i18n("POPUPS_ASK/BUTTON_NO")),this.yesFocus(!1),this.noFocus(!1),this.fYesAction=null,this.fNoAction=null},t.prototype.yesClick=function(){U.isFunc(this.fYesAction)&&this.fYesAction.call(null),this.cancelCommand()},t.prototype.noClick=function(){U.isFunc(this.fNoAction)&&this.fNoAction.call(null),this.cancelCommand()},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.onHide=function(){},t.prototype.onBuild=function(){var a=this;bb.on("keydown",function(b){var c=!0;return b&&a.modalVisibility()&&(S.EventKeyCode.Tab===b.keyCode||S.EventKeyCode.Right===b.keyCode||S.EventKeyCode.Left===b.keyCode)&&(a.yesFocus()?a.noFocus(!0):a.yesFocus(!0),c=!1),c})},U.extendAsViewModel("AdminLoginViewModel",u),u.prototype.onShow=function(){Z.routeOff(),f.delay(f.bind(function(){this.loginFocus(!0)},this),100)},u.prototype.onHide=function(){this.loginFocus(!1)},U.extendAsViewModel("AdminMenuViewModel",v),v.prototype.link=function(a){return"#/"+a},U.extendAsViewModel("AdminPaneViewModel",w),w.prototype.logoutClick=function(){eb.remote().adminLogout(function(){eb.loginAndLogoutReload()})},U.addSettingsViewModel(x,"AdminSettingsGeneral","General","general",!0),x.prototype.onBuild=function(){var a=this;f.delay(function(){var b=U.settingsSaveHelperSimpleFunction(a.titleTrigger,a),c=U.settingsSaveHelperSimpleFunction(a.languageTrigger,a),d=U.settingsSaveHelperSimpleFunction(a.themeTrigger,a),e=U.settingsSaveHelperSimpleFunction(a.loadingDescTrigger,a);a.title.subscribe(function(a){eb.remote().saveAdminConfig(b,{Title:U.trim(a)})}),a.loadingDesc.subscribe(function(a){eb.remote().saveAdminConfig(e,{LoadingDescription:U.trim(a)})}),a.language.subscribe(function(a){eb.remote().saveAdminConfig(c,{Language:U.trim(a)})}),a.theme.subscribe(function(a){eb.remote().saveAdminConfig(d,{Theme:U.trim(a)})}),a.allowCustomTheme.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowCustomTheme:a?"1":"0"})}),a.allowAdditionalAccounts.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowAdditionalAccounts:a?"1":"0"})}),a.allowIdentities.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowIdentities:a?"1":"0"})}),a.allowThemes.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowThemes:a?"1":"0"})}),a.allowLanguagesOnSettings.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowLanguagesOnSettings:a?"1":"0"})})},50)},x.prototype.selectLanguage=function(){Z.showScreenPopup(s)},U.addSettingsViewModel(y,"AdminSettingsLogin","Login","login"),y.prototype.onBuild=function(){var a=this;f.delay(function(){var b=U.settingsSaveHelperSimpleFunction(a.defaultDomainTrigger,a);a.determineUserLanguage.subscribe(function(a){eb.remote().saveAdminConfig(null,{DetermineUserLanguage:a?"1":"0"})}),a.allowCustomLogin.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowCustomLogin:a?"1":"0"})}),a.allowLanguagesOnLogin.subscribe(function(a){eb.remote().saveAdminConfig(null,{AllowLanguagesOnLogin:a?"1":"0"})}),a.defaultDomain.subscribe(function(a){eb.remote().saveAdminConfig(b,{LoginDefaultDomain:U.trim(a)})})},50)},U.addSettingsViewModel(z,"AdminSettingsContacts","Contacts","contacts"),z.prototype.onTestContactsResponse=function(a,b){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage(""),S.StorageResultType.Success===a&&b&&b.Result&&b.Result.Result?this.testContactsSuccess(!0):(this.testContactsError(!0),b&&b.Result?this.testContactsErrorMessage(b.Result.Message||""):this.testContactsErrorMessage("")),this.testing(!1)},z.prototype.onShow=function(){this.testContactsSuccess(!1),this.testContactsError(!1),this.testContactsErrorMessage("")},z.prototype.onBuild=function(){var a=this;f.delay(function(){var b=U.settingsSaveHelperSimpleFunction(a.pdoDsnTrigger,a),c=U.settingsSaveHelperSimpleFunction(a.pdoUserTrigger,a),d=U.settingsSaveHelperSimpleFunction(a.pdoPasswordTrigger,a),e=U.settingsSaveHelperSimpleFunction(a.contactsTypeTrigger,a);a.enableContacts.subscribe(function(a){eb.remote().saveAdminConfig(null,{ContactsEnable:a?"1":"0"})}),a.contactsSharing.subscribe(function(a){eb.remote().saveAdminConfig(null,{ContactsSharing:a?"1":"0"})}),a.contactsSync.subscribe(function(a){eb.remote().saveAdminConfig(null,{ContactsSync:a?"1":"0"})}),a.contactsType.subscribe(function(a){eb.remote().saveAdminConfig(e,{ContactsPdoType:a})}),a.pdoDsn.subscribe(function(a){eb.remote().saveAdminConfig(b,{ContactsPdoDsn:U.trim(a)})}),a.pdoUser.subscribe(function(a){eb.remote().saveAdminConfig(c,{ContactsPdoUser:U.trim(a)})}),a.pdoPassword.subscribe(function(a){eb.remote().saveAdminConfig(d,{ContactsPdoPassword:U.trim(a)})}),a.contactsType(eb.settingsGet("ContactsPdoType"))},50)},U.addSettingsViewModel(A,"AdminSettingsDomains","Domains","domains"),A.prototype.startDomainForDeletionTimeout=function(){var b=this;a.clearInterval(this.iDomainForDeletionTimeout),this.iDomainForDeletionTimeout=a.setTimeout(function(){b.domainForDeletion(null)},3e3)},A.prototype.createDomain=function(){Z.showScreenPopup(p)},A.prototype.deleteDomain=function(a){this.domains.remove(a),eb.remote().domainDelete(f.bind(this.onDomainListChangeRequest,this),a.name)},A.prototype.disableDomain=function(a){a.disabled(!a.disabled()),eb.remote().domainDisable(f.bind(this.onDomainListChangeRequest,this),a.name,a.disabled())},A.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&&eb.remote().domain(f.bind(b.onDomainLoadRequest,b),a.name)}),eb.reloadDomainList()},A.prototype.onDomainLoadRequest=function(a,b){S.StorageResultType.Success===a&&b&&b.Result&&Z.showScreenPopup(p,[b.Result])},A.prototype.onDomainListChangeRequest=function(){eb.reloadDomainList()},U.addSettingsViewModel(B,"AdminSettingsSecurity","Security","security"),B.prototype.onNewAdminPasswordResponse=function(a,b){S.StorageResultType.Success===a&&b&&b.Result?(this.adminPassword(""),this.adminPasswordNew(""),this.adminPasswordUpdateSuccess(!0)):this.adminPasswordUpdateError(!0)},B.prototype.onBuild=function(){this.csrfProtection.subscribe(function(a){eb.remote().saveAdminConfig(U.emptyFunction,{TokenProtection:a?"1":"0"})})},B.prototype.onHide=function(){this.adminPassword(""),this.adminPasswordNew("")},B.prototype.phpInfoLink=function(){return eb.link().phpInfo()},U.addSettingsViewModel(C,"AdminSettingsSocial","Social","social"),C.prototype.onBuild=function(){var a=this;f.delay(function(){var b=U.settingsSaveHelperSimpleFunction(a.facebookTrigger1,a),c=U.settingsSaveHelperSimpleFunction(a.facebookTrigger2,a),d=U.settingsSaveHelperSimpleFunction(a.twitterTrigger1,a),e=U.settingsSaveHelperSimpleFunction(a.twitterTrigger2,a),f=U.settingsSaveHelperSimpleFunction(a.googleTrigger1,a),g=U.settingsSaveHelperSimpleFunction(a.googleTrigger2,a),h=U.settingsSaveHelperSimpleFunction(a.dropboxTrigger1,a);a.facebookEnable.subscribe(function(a){eb.remote().saveAdminConfig(U.emptyFunction,{FacebookEnable:a?"1":"0"})}),a.facebookAppID.subscribe(function(a){eb.remote().saveAdminConfig(b,{FacebookAppID:U.trim(a)})}),a.facebookAppSecret.subscribe(function(a){eb.remote().saveAdminConfig(c,{FacebookAppSecret:U.trim(a)})}),a.twitterEnable.subscribe(function(a){eb.remote().saveAdminConfig(U.emptyFunction,{TwitterEnable:a?"1":"0"})}),a.twitterConsumerKey.subscribe(function(a){eb.remote().saveAdminConfig(d,{TwitterConsumerKey:U.trim(a)})}),a.twitterConsumerSecret.subscribe(function(a){eb.remote().saveAdminConfig(e,{TwitterConsumerSecret:U.trim(a)})}),a.googleEnable.subscribe(function(a){eb.remote().saveAdminConfig(U.emptyFunction,{GoogleEnable:a?"1":"0"})}),a.googleClientID.subscribe(function(a){eb.remote().saveAdminConfig(f,{GoogleClientID:U.trim(a)})}),a.googleClientSecret.subscribe(function(a){eb.remote().saveAdminConfig(g,{GoogleClientSecret:U.trim(a)})}),a.dropboxEnable.subscribe(function(a){eb.remote().saveAdminConfig(U.emptyFunction,{DropboxEnable:a?"1":"0"})}),a.dropboxApiKey.subscribe(function(a){eb.remote().saveAdminConfig(h,{DropboxApiKey:U.trim(a)})})},50)},U.addSettingsViewModel(D,"AdminSettingsPlugins","Plugins","plugins"),D.prototype.disablePlugin=function(a){a.disabled(!a.disabled()),eb.remote().pluginDisable(this.onPluginDisableRequest,a.name,a.disabled())},D.prototype.configurePlugin=function(a){eb.remote().plugin(this.onPluginLoadRequest,a.name)},D.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 .disable-plugin",function(){var a=c.dataFor(this);a&&b.disablePlugin(a)}),this.enabledPlugins.subscribe(function(a){eb.remote().saveAdminConfig(U.emptyFunction,{EnabledPlugins:a?"1":"0"})})},D.prototype.onShow=function(){this.pluginsError(""),eb.reloadPluginList()},D.prototype.onPluginLoadRequest=function(a,b){S.StorageResultType.Success===a&&b&&b.Result&&Z.showScreenPopup(q,[b.Result])},D.prototype.onPluginDisableRequest=function(a,b){S.StorageResultType.Success===a&&b&&!b.Result&&b.ErrorCode&&(S.Notification.UnsupportedPluginPackage===b.ErrorCode&&b.ErrorMessage&&""!==b.ErrorMessage?this.pluginsError(b.ErrorMessage):this.pluginsError(U.getNotification(b.ErrorCode))),eb.reloadPluginList()},U.addSettingsViewModel(E,"AdminSettingsPackages","Packages","packages"),E.prototype.onShow=function(){this.packagesError("")},E.prototype.onBuild=function(){eb.reloadPackagesList()},E.prototype.requestHelper=function(b,c){var d=this;return function(e,g){S.StorageResultType.Success===e&&g&&g.Result||(g&&g.ErrorCode?d.packagesError(U.getNotification(g.ErrorCode)):d.packagesError(U.getNotification(c?S.Notification.CantInstallPackage:S.Notification.CantDeletePackage))),f.each(eb.data().packages(),function(a){a&&b&&a.loading()&&b.file===a.file&&(b.loading(!1),a.loading(!1))}),S.StorageResultType.Success===e&&g&&g.Result&&g.Result.Reload?a.location.reload():eb.reloadPackagesList()}},E.prototype.deletePackage=function(a){a&&(a.loading(!0),eb.remote().packageDelete(this.requestHelper(a,!1),a))},E.prototype.installPackage=function(a){a&&(a.loading(!0),eb.remote().packageInstall(this.requestHelper(a,!0),a))},U.addSettingsViewModel(F,"AdminSettingsLicensing","Licensing","licensing"),F.prototype.onBuild=function(){this.subscriptionEnabled()&&eb.reloadLicensing(!1)},F.prototype.onShow=function(){this.adminDomain(eb.settingsGet("AdminDomain"))},F.prototype.showActivationForm=function(){Z.showScreenPopup(r)},F.prototype.licenseExpiredMomentValue=function(){var a=moment.unix(this.licenseExpired());return a.format("LL")+" ("+a.from(moment())+")"},G.prototype.populateDataOnStart=function(){var a=eb.settingsGet("Languages"),b=eb.settingsGet("Themes");U.isArray(a)&&this.languages(a),U.isArray(b)&&this.themes(b),this.mainLanguage(eb.settingsGet("Language")),this.mainTheme(eb.settingsGet("Theme")),this.allowCustomTheme(!!eb.settingsGet("AllowCustomTheme")),this.allowAdditionalAccounts(!!eb.settingsGet("AllowAdditionalAccounts")),this.allowIdentities(!!eb.settingsGet("AllowIdentities")),this.determineUserLanguage(!!eb.settingsGet("DetermineUserLanguage")),this.allowThemes(!!eb.settingsGet("AllowThemes")),this.allowCustomLogin(!!eb.settingsGet("AllowCustomLogin")),this.allowLanguagesOnLogin(!!eb.settingsGet("AllowLanguagesOnLogin")),this.allowLanguagesOnSettings(!!eb.settingsGet("AllowLanguagesOnSettings")),this.editorDefaultType(eb.settingsGet("EditorDefaultType")),this.showImages(!!eb.settingsGet("ShowImages")),this.contactsAutosave(!!eb.settingsGet("ContactsAutosave")),this.interfaceAnimation(eb.settingsGet("InterfaceAnimation")),this.mainMessagesPerPage(eb.settingsGet("MPP")),this.desktopNotifications(!!eb.settingsGet("DesktopNotifications")),this.useThreads(!!eb.settingsGet("UseThreads")),this.replySameFolder(!!eb.settingsGet("ReplySameFolder")),this.usePreviewPane(!!eb.settingsGet("UsePreviewPane")),this.useCheckboxesInList(!!eb.settingsGet("UseCheckboxesInList")),this.facebookEnable(!!eb.settingsGet("AllowFacebookSocial")),this.facebookAppID(eb.settingsGet("FacebookAppID")),this.facebookAppSecret(eb.settingsGet("FacebookAppSecret")),this.twitterEnable(!!eb.settingsGet("AllowTwitterSocial")),this.twitterConsumerKey(eb.settingsGet("TwitterConsumerKey")),this.twitterConsumerSecret(eb.settingsGet("TwitterConsumerSecret")),this.googleEnable(!!eb.settingsGet("AllowGoogleSocial")),this.googleClientID(eb.settingsGet("GoogleClientID")),this.googleClientSecret(eb.settingsGet("GoogleClientSecret")),this.dropboxEnable(!!eb.settingsGet("AllowDropboxSocial")),this.dropboxApiKey(eb.settingsGet("DropboxApiKey")),this.contactsIsAllowed(!!eb.settingsGet("ContactsIsAllowed"))},f.extend(H.prototype,G.prototype),H.prototype.populateDataOnStart=function(){G.prototype.populateDataOnStart.call(this)},I.prototype.oRequests={},I.prototype.defaultResponse=function(b,c,d,e,g,h){var i=function(){S.StorageResultType.Success!==d&&X.bUnload&&(d=S.StorageResultType.Unload),S.StorageResultType.Success===d&&e&&!e.Result?(e&&-1<U.inArray(e.ErrorCode,[S.Notification.AuthError,S.Notification.AccessError,S.Notification.ConnectionError,S.Notification.DomainNotAllowed,S.Notification.AccountNotAllowed,S.Notification.MailServerError,S.Notification.UnknownNotification,S.Notification.UnknownError])&&X.iAjaxErrorCount++,e&&S.Notification.InvalidToken===e.ErrorCode&&X.iTokenErrorCount++,R.Values.TokenErrorLimit<X.iTokenErrorCount&&eb.loginAndLogoutReload(!0),(e.Logout||R.Values.AjaxErrorLimit<X.iAjaxErrorCount)&&(a.__rlah_clear&&a.__rlah_clear(),eb.loginAndLogoutReload(!0))):S.StorageResultType.Success===d&&e&&e.Result&&(X.iAjaxErrorCount=0,X.iTokenErrorCount=0),b&&(V.runHook("ajax-default-response",[c,S.StorageResultType.Success===d?e:null,d,g,h]),b(d,S.StorageResultType.Success===d?e:null,g,c,h))};switch(d){case"success":d=S.StorageResultType.Success;break;case"abort":d=S.StorageResultType.Abort;break;default:d=S.StorageResultType.Error}S.StorageResultType.Error===d?f.delay(i,300):i()},I.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=U.isNormal(e)?e:2e4,g=U.isUnd(g)?"":U.pString(g),h=U.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=eb.settingsGet("Token")),m=b.ajax({type:j?"POST":"GET",url:eb.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=U.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<U.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},I.prototype.defaultRequest=function(a,b,c,d,e,f){c=c||{},c.Action=b,e=U.pString(e),V.runHook("ajax-default-request",[b,c,e]),this.ajaxRequest(a,c,U.isUnd(d)?R.Defaults.DefaultAjaxTimeout:U.pInt(d),e,f)},I.prototype.noop=function(a){this.defaultRequest(a,"Noop")},I.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})},I.prototype.jsInfo=function(a,b,c,d){this.defaultRequest(a,"JsInfo",{Type:b,Data:c,IsError:(U.isUnd(d)?1:!d)?"0":"1"})},I.prototype.jsVersion=function(a,b){this.defaultRequest(a,"Version",{Version:b})},f.extend(J.prototype,I.prototype),J.prototype.adminLogin=function(a,b,c){this.defaultRequest(a,"AdminLogin",{Login:b,Password:c})},J.prototype.adminLogout=function(a){this.defaultRequest(a,"AdminLogout")},J.prototype.saveAdminConfig=function(a,b){this.defaultRequest(a,"AdminSettingsUpdate",b)},J.prototype.domainList=function(a){this.defaultRequest(a,"AdminDomainList")},J.prototype.pluginList=function(a){this.defaultRequest(a,"AdminPluginList")},J.prototype.packagesList=function(a){this.defaultRequest(a,"AdminPackagesList")},J.prototype.packageInstall=function(a,b){this.defaultRequest(a,"AdminPackageInstall",{Id:b.id,Type:b.type,File:b.file},6e4)},J.prototype.packageDelete=function(a,b){this.defaultRequest(a,"AdminPackageDelete",{Id:b.id})},J.prototype.domain=function(a,b){this.defaultRequest(a,"AdminDomainLoad",{Name:b})},J.prototype.plugin=function(a,b){this.defaultRequest(a,"AdminPluginLoad",{Name:b})},J.prototype.domainDelete=function(a,b){this.defaultRequest(a,"AdminDomainDelete",{Name:b})},J.prototype.domainDisable=function(a,b,c){return this.defaultRequest(a,"AdminDomainDisable",{Name:b,Disabled:c?"1":"0"})},J.prototype.pluginSettingsUpdate=function(a,b){return this.defaultRequest(a,"AdminPluginSettingsUpdate",b)},J.prototype.licensing=function(a,b){return this.defaultRequest(a,"AdminLicensing",{Force:b?"1":"0"})},J.prototype.licensingActivate=function(a,b,c){return this.defaultRequest(a,"AdminLicensingActivate",{Domain:b,Key:c})},J.prototype.pluginDisable=function(a,b,c){return this.defaultRequest(a,"AdminPluginDisable",{Name:b,Disabled:c?"1":"0"})},J.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})},J.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"})},J.prototype.testContacts=function(a,b){this.defaultRequest(a,"AdminContactsTest",b)},J.prototype.saveNewAdminPassword=function(a,b){this.defaultRequest(a,"AdminPasswordUpdate",b)},J.prototype.adminPing=function(a){this.defaultRequest(a,"AdminPing")},K.prototype.oEmailsPicsHashes={},K.prototype.oServices={},K.prototype.clear=function(){this.oServices={},this.oEmailsPicsHashes={}},K.prototype.getUserPic=function(a){var b="",c="",d=a.toLowerCase(),e=U.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];return""===e?(c=d.substr(a.indexOf("@")+1),b=""!==c&&this.oServices[c]?this.oServices[c]:""):b=eb.link().getUserPicUrlFromHash(e),b},K.prototype.setServicesData=function(a){this.oServices=a},K.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a},f.extend(L.prototype,K.prototype),f.extend(M.prototype,m.prototype),M.prototype.onRoute=function(a){var d=this,e=null,g=null,h=null,i=null;g=f.find(Y.settings,function(b){return b&&b.__rlSettingsData&&a===b.__rlSettingsData.Route}),g&&(f.find(Y["settings-removed"],function(a){return a&&a===g})&&(g=null),g&&f.find(Y["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=eb.data(),e.viewModelDom=i,e.__rlSettingsData=g.__rlSettingsData,g.__dom=i,g.__builded=!0,g.__vm=e,c.applyBindings(e,i[0]),U.delegateRun(e,"onBuild",[i])):U.log("Cannot find sub settings view model position: SettingsSubScreen")),e&&f.defer(function(){d.oCurrentSubScreen&&(U.delegateRun(d.oCurrentSubScreen,"onHide"),d.oCurrentSubScreen.viewModelDom.hide()),d.oCurrentSubScreen=e,d.oCurrentSubScreen&&(d.oCurrentSubScreen.viewModelDom.show(),U.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)),U.windowResize()})):Z.setHash(eb.link().settings(),!1,!0)},M.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(U.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())},M.prototype.onBuild=function(){f.each(Y.settings,function(a){a&&a.__rlSettingsData&&!f.find(Y["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(Y["settings-disabled"],function(b){return b&&b===a})})},this),this.oViewModelPlace=b("#rl-content #rl-settings-subscreen")},M.prototype.routes=function(){var a=f.find(Y.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=U.isUnd(c.subname)?b:U.pString(c.subname),[c.subname]}};return[["{subname}/",c],["{subname}",c],["",c]]},f.extend(N.prototype,m.prototype),N.prototype.onShow=function(){eb.setTitle("")},f.extend(O.prototype,M.prototype),O.prototype.onShow=function(){eb.setTitle("")},f.extend(P.prototype,k.prototype),P.prototype.oSettings=null,P.prototype.oPlugins=null,P.prototype.oLocal=null,P.prototype.oLink=null,P.prototype.oSubs={},P.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):(X.bMobileDevice?(a.open(b,"_self"),a.focus()):this.iframe.attr("src",b),!0)},P.prototype.link=function(){return null===this.oLink&&(this.oLink=new g),this.oLink},P.prototype.local=function(){return null===this.oLocal&&(this.oLocal=new j),this.oLocal},P.prototype.settingsGet=function(a){return null===this.oSettings&&(this.oSettings=U.isNormal($)?$:{}),U.isUnd(this.oSettings[a])?null:this.oSettings[a]},P.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=U.isNormal($)?$:{}),this.oSettings[a]=b},P.prototype.setTitle=function(b){b=(U.isNormal(b)&&0<b.length?b+" - ":"")+eb.settingsGet("Title")||"",a.document.title="_",a.document.title=b},P.prototype.loginAndLogoutReload=function(b,c){var d=U.pString(eb.settingsGet("CustomLogoutLink")),e=!!eb.settingsGet("InIframe");b=U.isUnd(b)?!1:!!b,c=U.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):(Z.routeOff(),Z.setHash(eb.link().root(),!0),Z.routeOff(),f.delay(function(){e&&a.parent?a.parent.location.reload():a.location.reload()},100))},P.prototype.getAutocomplete=function(a,b){b([],a)},P.prototype.sub=function(a,b,c){return U.isUnd(this.oSubs[a])&&(this.oSubs[a]=[]),this.oSubs[a].push([b,c]),this},P.prototype.pub=function(a,b){return U.isUnd(this.oSubs[a])||f.each(this.oSubs[a],function(a){a[0]&&a[0].apply(a[1]||null,b||[])}),this},P.prototype.bootstart=function(){U.initOnStartOrLangChange(function(){U.initNotificationLanguage()},null),f.delay(function(){U.windowResize()},1e3),ssm.addState({id:"mobile",maxWidth:767,onEnter:function(){ab.addClass("ssm-state-mobile")},onLeave:function(){ab.removeClass("ssm-state-mobile")}}),ssm.addState({id:"tablet",minWidth:768,maxWidth:999,onEnter:function(){ab.addClass("ssm-state-tablet")},onLeave:function(){ab.removeClass("ssm-state-tablet")}}),ssm.addState({id:"desktop",minWidth:1e3,maxWidth:1400,onEnter:function(){ab.addClass("ssm-state-desktop")},onLeave:function(){ab.removeClass("ssm-state-desktop")}}),ssm.addState({id:"desktop-large",minWidth:1400,onEnter:function(){ab.addClass("ssm-state-desktop-large")},onLeave:function(){ab.removeClass("ssm-state-desktop-large")}}),ssm.ready()},f.extend(Q.prototype,P.prototype),Q.prototype.oData=null,Q.prototype.oRemote=null,Q.prototype.oCache=null,Q.prototype.data=function(){return null===this.oData&&(this.oData=new H),this.oData},Q.prototype.remote=function(){return null===this.oRemote&&(this.oRemote=new J),this.oRemote},Q.prototype.cache=function(){return null===this.oCache&&(this.oCache=new L),this.oCache},Q.prototype.reloadDomainList=function(){eb.data().domainsLoading(!0),eb.remote().domainList(function(a,b){if(eb.data().domainsLoading(!1),S.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);eb.data().domains(d)}})},Q.prototype.reloadPluginList=function(){eb.data().pluginsLoading(!0),eb.remote().pluginList(function(a,b){if(eb.data().pluginsLoading(!1),S.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);eb.data().plugins(d)}})},Q.prototype.reloadPackagesList=function(){eb.data().packagesLoading(!0),eb.data().packagesReal(!0),eb.remote().packagesList(function(a,b){if(eb.data().packagesLoading(!1),S.StorageResultType.Success===a&&b&&b.Result){eb.data().packagesReal(!!b.Result.Real),eb.data().packagesMainUpdatable(!!b.Result.MainUpdatable);var d=[],e={};f.each(eb.data().packages(),function(a){a&&a.loading()&&(e[a.file]=a)}),U.isArray(b.Result.List)&&(d=f.compact(f.map(b.Result.List,function(a){return a?(a.loading=c.observable(!U.isUnd(e[a.file])),"core"!==a.type||a.canBeInstalled?a:null):null}))),eb.data().packages(d)}else eb.data().packagesReal(!1)})},Q.prototype.reloadLicensing=function(a){a=U.isUnd(a)?!1:!!a,eb.data().licensingProcess(!0),eb.data().licenseError(""),eb.remote().licensing(function(a,b){eb.data().licensingProcess(!1),S.StorageResultType.Success===a&&b&&b.Result&&U.isNormal(b.Result.Expired)?(eb.data().licenseValid(!0),eb.data().licenseExpired(U.pInt(b.Result.Expired)),eb.data().licenseError(""),eb.data().licensing(!0)):b&&b.ErrorCode&&-1<U.inArray(U.pInt(b.ErrorCode),[S.Notification.LicensingServerIsUnavailable,S.Notification.LicensingExpired])?(eb.data().licenseError(U.getNotification(U.pInt(b.ErrorCode))),eb.data().licensing(!0)):S.StorageResultType.Abort===a?(eb.data().licenseError(U.getNotification(S.Notification.LicensingServerIsUnavailable)),eb.data().licensing(!0)):eb.data().licensing(!1)},a)},Q.prototype.bootstart=function(){P.prototype.bootstart.call(this),eb.data().populateDataOnStart(),Z.hideLoading(),eb.settingsGet("AllowAdminPanel")?eb.settingsGet("Auth")?Z.startScreens([O]):Z.startScreens([N]):(Z.routeOff(),Z.setHash(eb.link().root(),!0),Z.routeOff(),f.defer(function(){a.location.href="/"})),a.SimplePace&&a.SimplePace.set(100)},eb=new Q,ab.addClass(X.bMobileDevice?"mobile":"no-mobile"),bb.keydown(U.killCtrlAandS).keyup(U.killCtrlAandS),bb.unload(function(){X.bUnload=!0}),a.rl=a.rl||{},a.rl.addHook=V.addHook,a.rl.settingsGet=V.mainSettingsGet,a.rl.remoteRequest=V.remoteRequest,a.rl.pluginSettingsGet=V.settingsGet,a.rl.addSettingsViewModel=U.addSettingsViewModel,a.rl.createCommand=U.createCommand,a.rl.EmailModel=o,a.rl.Enums=S,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={},Z.setBoot(eb).bootstart(),ab.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,_);