snappymail/rainloop/v/1.3.3.451/static/js/admin.min.js
RainLoop Team 8b9afa23bd v1.3.3.451
2013-10-23 23:11:15 +04:00

148 lines
No EOL
75 KiB
JavaScript

(function(h,i,d,oa,y,j){function n(){this.sBase="#/";this.sCdnStaticDomain=f.settingsGet("CdnStaticDomain");this.sVersion=f.settingsGet("Version");this.sSpecSuffix=f.settingsGet("AuthAccountHash")||"0";this.sServer="./?";this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function M(){}function N(){}function O(){var a=j.find([N,M],function(a){return a.supported()});a&&(this.oDriver=new a)}function pa(){}
function t(a,b){this.sPosition=c.pString(a);this.sTemplate=c.pString(b);this.viewModelName="";this.viewModelVisibility=d.observable(!1);"Popups"===this.sPosition&&(this.modalVisibility=d.observable(!1));this.viewModelDom=null}function w(a,b){this.sScreenName=a;this.aViewModels=c.isArray(b)?b:[]}function m(){this.sDefaultScreenName="";this.oScreens={};this.oCurrentScreen=this.oBoot=null;this.popupVisibility=d.observable(!1);this.popupVisibility.subscribe(function(a){f&&f.popupVisibility(a)})}function r(a,
b){this.email=a||"";this.name=b||"";this.privateType=null;this.clearDuplicateName()}function z(){t.call(this,"Popups","PopupsDomain");this.edit=d.observable(!1);this.saving=d.observable(!1);this.savingError=d.observable("");this.whiteListPage=d.observable(!1);this.testing=d.observable(!1);this.testingDone=d.observable(!1);this.testingImapError=d.observable(!1);this.testingSmtpError=d.observable(!1);this.imapServerFocus=d.observable(!1);this.smtpServerFocus=d.observable(!1);this.name=d.observable("");
this.imapServer=d.observable("");this.imapPort=d.observable(l.Values.ImapDefaulPort);this.imapSecure=d.observable(g.ServerSecure.None);this.smtpServer=d.observable("");this.smtpPort=d.observable(l.Values.SmtpDefaulPort);this.smtpSecure=d.observable(g.ServerSecure.None);this.smtpAuth=d.observable(!0);this.whiteList=d.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=d.computed(function(){var a=this.name();return this.edit()?'Edit Domain "'+a+'"':"Add Domain"+(""===a?"":' "'+a+'"')},this);this.domainIsComputed=d.computed(function(){return""!==this.name()&&""!==this.imapServer()&&""!==this.imapPort()&&""!==this.smtpServer()&&""!==this.smtpPort()},this);this.canBeTested=d.computed(function(){return!this.testing()&&this.domainIsComputed()},this);this.canBeSaved=
d.computed(function(){return!this.saving()&&this.domainIsComputed()},this);this.createOrAddCommand=c.createCommand(this,function(){this.saving(!0);f.remote().createOrUpdateDomain(j.bind(this.onDomainCreateOrSaveResponse,this),!this.edit(),this.name(),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth(),this.whiteList())},this.canBeSaved);this.testConnectionCommand=c.createCommand(this,function(){this.whiteListPage(!1);this.testingDone(!1);
this.testingImapError(!1);this.testingSmtpError(!1);this.testing(!0);f.remote().testConnectionForDomain(j.bind(this.onTestConnectionResponse,this),this.imapServer(),this.imapPort(),this.imapSecure(),this.smtpServer(),this.smtpPort(),this.smtpSecure(),this.smtpAuth())},this.canBeTested);this.whiteListCommand=c.createCommand(this,function(){this.whiteListPage(!this.whiteListPage())})}function P(){t.call(this,"Popups","PopupsPlugin");this.onPluginSettingsUpdateResponse=j.bind(this.onPluginSettingsUpdateResponse,
this);this.saveError=d.observable("");this.name=d.observable("");this.readme=d.observable("");this.configures=d.observableArray([]);this.hasReadme=d.computed(function(){return""!==this.readme()},this);this.hasConfiguration=d.computed(function(){return 0<this.configures().length},this);this.saveCommand=c.createCommand(this,function(){var a={};a.Name=this.name();j.each(this.configures(),function(b){var e=b.value();if(!1===e||!0===e)e=e?"1":"0";a["_"+b.Name]=e},this);this.saveError("");f.remote().pluginSettingsUpdate(this.onPluginSettingsUpdateResponse,
a)},this.hasConfiguration)}function Q(){t.call(this,"Popups","PopupsActivate");var a=this;this.domain=d.observable("");this.key=d.observable("");this.key.focus=d.observable(!1);this.activationSuccessed=d.observable(!1);this.licenseTrigger=f.data().licenseTrigger;this.activateProcess=d.observable(!1);this.activateText=d.observable("");this.activateText.isError=d.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=c.createCommand(this,function(){this.activateProcess(!0);this.validateSubscriptionKey()?f.remote().licensingActivate(function(b,e){a.activateProcess(!1);g.StorageResultType.Success===b&&e.Result?!0===e.Result?(a.activationSuccessed(!0),a.activateText("Subscription Key Activated Successfully"),a.activateText.isError(!1)):(a.activateText(e.Result),a.activateText.isError(!0),a.key.focus(!0)):(e.ErrorCode?a.activateText(c.getNotification(e.ErrorCode)):
a.activateText(c.getNotification(g.Notification.UnknownError)),a.activateText.isError(!0),a.key.focus(!0))},this.domain(),this.key()):(this.activateProcess(!1),this.activateText("Invalid Subscription Key"),this.activateText.isError(!0),this.key.focus(!0))},function(){return!this.activateProcess()&&""!==this.domain()&&""!==this.key()&&!this.activationSuccessed()})}function R(){t.call(this,"Right","AdminLogin");this.login=d.observable("");this.password=d.observable("");this.loginError=d.observable(!1);
this.passwordError=d.observable(!1);this.loginFocus=d.observable(!1);this.login.subscribe(function(){this.loginError(!1)},this);this.password.subscribe(function(){this.passwordError(!1)},this);this.submitRequest=d.observable(!1);this.submitError=d.observable("");this.submitCommand=c.createCommand(this,function(){this.loginError(""===c.trim(this.login()));this.passwordError(""===c.trim(this.password()));if(this.loginError()||this.passwordError())return!1;this.submitRequest(!0);f.remote().adminLogin(j.bind(function(a,
b){g.StorageResultType.Success===a&&b&&"AdminLogin"===b.Action?b.Result?f.loginAndLogoutReload():b.ErrorCode&&(this.submitRequest(!1),this.submitError(c.getNotification(b.ErrorCode))):(this.submitRequest(!1),this.submitError(c.getNotification(g.Notification.UnknownError)))},this),this.login(),this.password());return!0},function(){return!this.submitRequest()})}function aa(a){t.call(this,"Left","AdminMenu");this.menu=a.menu}function ba(){t.call(this,"Right","AdminPane");this.adminDomain=d.observable(f.settingsGet("AdminDomain"))}
function qa(){var a=f.data();this.mainLanguage=a.mainLanguage;this.mainTheme=a.mainTheme;this.language=a.language;this.theme=a.theme;this.allowCustomTheme=a.allowCustomTheme;this.allowAdditionalAccounts=a.allowAdditionalAccounts;this.title=d.observable(f.settingsGet("Title"));this.version=f.settingsGet("Version");this.themesOptions=d.computed(function(){return j.map(a.themes(),function(a){return{optValue:a,optText:c.convertThemeName(a)}})});this.languagesOptions=d.computed(function(){return j.map(a.languages(),
function(a){return{optValue:a,optText:c.convertLangName(a)}})});this.contactsSupported=f.settingsGet("ContactsIsSupported");this.contactsIsAllowed=f.settingsGet("ContactsIsAllowed");this.titleTrigger=d.observable(g.SaveSettingsStep.Idle);this.languageTrigger=d.observable(g.SaveSettingsStep.Idle);this.themeTrigger=d.observable(g.SaveSettingsStep.Idle)}function A(){var a=f.data();this.domains=a.domains;this.domainsLoading=a.domainsLoading;this.iDomainForDeletionTimeout=0;this.visibility=d.computed(function(){return a.domainsLoading()?
"visible":"hidden"},this);this.domainForDeletion=d.observable(null).extend({toggleSubscribe:[this,function(a){a&&a.deleteAccess(!1)},function(a){a&&(a.deleteAccess(!0),this.startDomainForDeletionTimeout())}]})}function K(){this.licensing=f.data().licensing;this.licensingProcess=f.data().licensingProcess;this.licenseValid=f.data().licenseValid;this.licenseExpired=f.data().licenseExpired;this.licenseError=f.data().licenseError;this.licenseTrigger=f.data().licenseTrigger;this.adminDomain=d.observable("");
this.subscriptionEnabled=d.observable(!!f.settingsGet("SubscriptionEnabled"));this.licenseTrigger.subscribe(function(){this.subscriptionEnabled()&&f.reloadLicensing(!0)},this)}function L(){this.csrfProtection=d.observable(!!f.settingsGet("UseTokenProtection"));this.usageStatistics=d.observable(!!f.settingsGet("UsageStatistics"));this.adminLogin=d.observable(f.settingsGet("AdminLogin"));this.adminPassword=d.observable("");this.adminPasswordNew=d.observable("");this.adminPasswordUpdateError=d.observable(!1);
this.adminPasswordUpdateSuccess=d.observable(!1);this.adminPassword.subscribe(function(){this.adminPasswordUpdateError(!1);this.adminPasswordUpdateSuccess(!1)},this);this.adminPasswordNew.subscribe(function(){this.adminPasswordUpdateError(!1);this.adminPasswordUpdateSuccess(!1)},this);this.onNewAdminPasswordResponse=j.bind(this.onNewAdminPasswordResponse,this);this.saveNewAdminPasswordCommand=c.createCommand(this,function(){this.adminPasswordUpdateError(!1);this.adminPasswordUpdateSuccess(!1);f.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse,
{Password:this.adminPassword(),NewPassword:this.adminPasswordNew()})},function(){return""!==this.adminPassword()&&""!==this.adminPasswordNew()})}function ra(){var a=f.data();this.googleEnable=a.googleEnable;this.googleClientID=a.googleClientID;this.googleClientSecret=a.googleClientSecret;this.googleTrigger1=d.observable(g.SaveSettingsStep.Idle);this.googleTrigger2=d.observable(g.SaveSettingsStep.Idle);this.facebookEnable=a.facebookEnable;this.facebookAppID=a.facebookAppID;this.facebookAppSecret=a.facebookAppSecret;
this.facebookTrigger1=d.observable(g.SaveSettingsStep.Idle);this.facebookTrigger2=d.observable(g.SaveSettingsStep.Idle);this.twitterEnable=a.twitterEnable;this.twitterConsumerKey=a.twitterConsumerKey;this.twitterConsumerSecret=a.twitterConsumerSecret;this.twitterTrigger1=d.observable(g.SaveSettingsStep.Idle);this.twitterTrigger2=d.observable(g.SaveSettingsStep.Idle);this.dropboxEnable=a.dropboxEnable;this.dropboxApiKey=a.dropboxApiKey;this.dropboxTrigger1=d.observable(g.SaveSettingsStep.Idle)}function E(){var a=
f.data();this.enabledPlugins=d.observable(!!f.settingsGet("EnabledPlugins"));this.pluginsError=d.observable("");this.plugins=a.plugins;this.pluginsLoading=a.pluginsLoading;this.visibility=d.computed(function(){return a.pluginsLoading()?"visible":"hidden"},this);this.onPluginLoadRequest=j.bind(this.onPluginLoadRequest,this);this.onPluginDisableRequest=j.bind(this.onPluginDisableRequest,this)}function I(){var a=f.data();this.packagesError=d.observable("");this.packages=a.packages;this.packagesLoading=
a.packagesLoading;this.packagesReal=a.packagesReal;this.packagesMainUpdatable=a.packagesMainUpdatable;this.packagesCurrent=d.computed(function(){return j.filter(this.packages(),function(a){return a&&""!==a.installed&&!a.compare})},this);this.packagesAvailableForUpdate=d.computed(function(){return j.filter(this.packages(),function(a){return a&&""!==a.installed&&!!a.compare})},this);this.packagesAvailableForInstallation=d.computed(function(){return j.filter(this.packages(),function(a){return a&&""===
a.installed})},this);this.visibility=d.computed(function(){return a.packagesLoading()?"visible":"hidden"},this)}function ca(){c.initDataConstructorBySettings(this)}function da(){c.initDataConstructorBySettings(this);this.domainsLoading=d.observable(!1).extend({throttle:100});this.domains=d.observableArray([]);this.pluginsLoading=d.observable(!1).extend({throttle:100});this.plugins=d.observableArray([]);this.packagesReal=d.observable(!0);this.packagesMainUpdatable=d.observable(!0);this.packagesLoading=
d.observable(!1).extend({throttle:100});this.packages=d.observableArray([]);this.licensing=d.observable(!1);this.licensingProcess=d.observable(!1);this.licenseValid=d.observable(!1);this.licenseExpired=d.observable(0);this.licenseError=d.observable("");this.licenseTrigger=d.observable(!1)}function F(){this.oRequests={}}function p(){this.oRequests={};this.oRequests={}}function B(){this.oEmailsPicsHashes={};this.oServices={}}function sa(){B.call(this)}function J(a){w.call(this,"settings",a);this.menu=
d.observableArray([]);this.oCurrentSubScreen=null}function ea(){w.call(this,"login",[R])}function fa(){J.call(this,[aa,ba])}function u(){this.oLocal=this.oLink=this.oPlugins=this.oSettings=null;this.isLocalAutocomplete=!0;this.popupVisibility=d.observable(!1);this.iframe=i('<iframe style="display:none" src="javascript:;" />').appendTo("body");G.on("error",function(a){f&&(a&&a.originalEvent&&a.originalEvent.message&&-1===c.inArray(a.originalEvent.message,["Uncaught Error: Error calling method on NPObject."]))&&
f.remote().jsError(c.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",S.attr("class"))})}function v(){u.call(this);this.oCache=this.oRemote=this.oData=null}var l={},g={},k={},c={},o={},T,U,ga,H,ha,C,ia=d.observable(!0),V=d.observable(!0),s=null,W=h.rainloopAppData||{},ja=h.rainloopI18N||{},S=i("html"),G=i(h),ta=i(h.document),X=[],ka=[],la=[],Y=h.Notification&&h.Notification.requestPermission?h.Notification:null,
f=null;U=T=0;ga=!1;H=(navigator.userAgent||"").toLowerCase();ha=-1<H.indexOf("iphone")||-1<H.indexOf("ipod")||-1<H.indexOf("ipad");H=-1<H.indexOf("android");C=ha||H;l.Defaults={};l.Values={};l.DataImages={};l.Defaults.MessagesPerPage=20;l.Defaults.MessagesPerPageArray=[10,20,30,50,100];l.Defaults.DefaultAjaxTimeout=2E4;l.Defaults.SearchAjaxTimeout=12E4;l.Defaults.SendMessageAjaxTimeout=2E5;l.Defaults.SaveMessageAjaxTimeout=2E5;l.Values.UnuseOptionValue="__UNUSE__";l.Values.GmailFolderName="[Gmail]";
l.Values.ClientSideCookieIndexName="rlcsc";l.Values.ImapDefaulPort=143;l.Values.ImapDefaulSecurePort=993;l.Values.SmtpDefaulPort=25;l.Values.SmtpDefaulSecurePort=465;l.DataImages.UserDotPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2P8DwQACgAD/il4QJ8AAAAASUVORK5CYII=";l.DataImages.TranspPic="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=";g.StorageResultType={Success:"success",Abort:"abort",Error:"error",
Unload:"unload"};g.State={Empty:10,Login:20,Auth:30};g.StateType={Webmail:0,Admin:1};g.FolderType={Inbox:10,SentItems:11,Draft:12,Trash:13,Spam:14,User:99};g.LoginSignMeTypeAsString={DefaultOff:"defaultoff",DefaultOn:"defaulton",Unused:"unused"};g.LoginSignMeType={DefaultOff:0,DefaultOn:1,Unused:2};g.ComposeType={Empty:"empty",Reply:"reply",ReplyAll:"replyall",Forward:"forward",ForwardAsAttachment:"forward-as-attachment",Draft:"draft"};g.UploadErrorCode={Normal:0,FileIsTooBig:1,FilePartiallyUploaded:2,
FileNoUploaded:3,MissingTempFolder:4,FileOnSaveingError:5,FileType:98,Unknown:99};g.SetSystemFoldersNotification={None:0,Sent:1,Draft:2,Spam:3,Trash:4};g.ClientSideKeyName={FoldersLashHash:0,MessagesInboxLastHash:1,MailBoxListSize:2,ExpandedFolders:3};g.EventKeyCode={Backspace:8,Enter:13,Esc:27,PageUp:33,PageDown:34,Left:37,Right:39,Up:38,Down:40,End:35,Home:36,Insert:45,Delete:46,A:65,S:83};g.MessageSetAction={SetSeen:0,UnsetSeen:1,SetFlag:2,UnsetFlag:3};g.MessageSelectAction={All:0,None:1,Invert:2,
Unseen:3,Seen:4,Flagged:5,Unflagged:6};g.DesctopNotifications={Allowed:0,NotAllowed:1,Denied:2,NotSupported:9};g.MessagePriority={Low:5,Normal:3,High:1};g.EditorDefaultType={Html:"Html",Plain:"Plain"};g.CustomThemeType={Light:"Light",Dark:"Dark"};g.ServerSecure={None:0,SSL:1,TLS:2};g.SearchDateType={All:-1,Days3:3,Days7:7,Month:30};g.EmailType={Defailt:0,Facebook:1,Google:2};g.SaveSettingsStep={Animate:-2,Idle:-1,TrueResult:1,FalseResult:0};g.Notification={InvalidToken:101,AuthError:102,AccessError:103,
ConnectionError:104,CaptchaError:105,SocialFacebookLoginAccessDisable:106,SocialTwitterLoginAccessDisable:107,SocialGoogleLoginAccessDisable:108,DomainNotAllowed:109,AccountNotAllowed:110,CantGetMessageList:201,CantGetMessage:202,CantDeleteMessage:203,CantMoveMessage:204,CantSaveMessage:301,CantSendMessage:302,InvalidRecipients:303,CantCreateFolder:400,CantRenameFolder:401,CantDeleteFolder:402,CantSubscribeFolder:403,CantUnsubscribeFolder:404,CantDeleteNonEmptyFolder:405,CantSaveSettings:501,CantSavePluginSettings:502,
DomainAlreadyExists:601,CantInstallPackage:701,CantDeletePackage:702,InvalidPluginPackage:703,UnsupportedPluginPackage:704,LicensingServerIsUnavailable:710,LicensingExpired:711,LicensingBanned:712,DemoSendMessageError:750,AccountAlreadyExists:801,MailServerError:901,UnknownNotification:999,UnknownError:999};c.trim=i.trim;c.inArray=i.inArray;c.isArray=j.isArray;c.isFunc=j.isFunction;c.isUnd=j.isUndefined;c.isNull=j.isNull;c.emptyFunction=function(){};c.isNormal=function(a){return!c.isUnd(a)&&!c.isNull(a)};
c.windowResize=j.debounce(function(a){c.isUnd(a)?G.resize():h.setTimeout(function(){G.resize()},a)},50);c.isPosNumeric=function(a,b){return c.isNormal(a)?c.isUnd(b)||b?/^[0-9]*$/.test(a.toString()):/^[1-9]+[0-9]*$/.test(a.toString()):!1};c.pInt=function(a){return c.isNormal(a)&&""!==a?h.parseInt(a,10):0};c.pString=function(a){return c.isNormal(a)?a+"":""};c.isNonEmptyArray=function(a){return c.isArray(a)&&0<a.length};c.exportPath=function(a,b,e){for(var q=null,a=a.split("."),e=e||h;a.length&&(q=a.shift());)!a.length&&
!c.isUnd(b)?e[q]=b:e=e[q]?e[q]:e[q]={}};c.pImport=function(a,b,e){a[b]=e};c.pExport=function(a,b,e){return c.isUnd(a[b])?e:a[b]};c.encodeHtml=function(a){return c.isNormal(a)?a.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"):""};c.splitPlainText=function(a,b){for(var e="",q="",d=a,f=0,g=0,b=c.isUnd(b)?100:b;d.length>b;)q=d.substring(0,b),f=q.lastIndexOf(" "),g=q.lastIndexOf("\n"),-1!==g&&(f=g),-1===f&&(f=b),e+=q.substring(0,
f)+"\n",d=d.substring(f+1);return e+d};var Z={};c.timeOutAction=function(a,b,e){c.isUnd(Z[a])&&(Z[a]=0);h.clearTimeout(Z[a]);Z[a]=h.setTimeout(b,e)};var na={};c.timeOutActionSecond=function(a,b,e){na[a]||(na[a]=h.setTimeout(function(){b();na[a]=0},e))};var x=!1;c.audio=function(a,b){if(!1===x)if(ha)x=null;else{var e=!1,c=!1,d=h.Audio?new h.Audio:null;d&&d.canPlayType&&d.play?((e=""!==d.canPlayType('audio/mpeg; codecs="mp3"'))||(c=""!==d.canPlayType('audio/ogg; codecs="vorbis"')),e||c?(x=d,x.preload=
"none",x.loop=!1,x.autoplay=!1,x.muted=!1,x.src=e?a:b):x=null):x=null}return x};c.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1};c.i18n=function(a,b,e){var d="",a=c.isUnd(ja[a])?c.isUnd(e)?a:e:ja[a];if(!c.isUnd(b)&&!c.isNull(b))for(d in b)c.hos(b,d)&&(a=a.replace("%"+d+"%",b[d]));return a};c.i18nToNode=function(a){j.defer(function(){i(".i18n",a).each(function(){var a=i(this),e="";(e=a.data("i18n-text"))?a.text(c.i18n(e)):((e=a.data("i18n-html"))&&a.html(c.i18n(e)),
(e=a.data("i18n-placeholder"))&&a.attr("placeholder",c.i18n(e)))})})};c.i18nToDoc=function(){h.rainloopI18N&&(ja=h.rainloopI18N||{},c.i18nToNode(ta),V(!V()));h.rainloopI18N={}};c.initOnStartOrLangChange=function(a,b,e){a&&a.call(b);e?V.subscribe(function(){a&&a.call(b);e.call(b)}):a&&V.subscribe(a,b)};c.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)};
c.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=i(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}};c.removeSelection=function(){if(h&&h.getSelection){var a=h.getSelection();a&&a.removeAllRanges&&a.removeAllRanges()}else document&&(document.selection&&document.selection.empty)&&document.selection.empty()};c.replySubjectAdd=function(a,b){var e=null,d=c.trim(b);null!==(e=(new h.RegExp("^"+a+"[\\s]?\\:(.*)$",
"gi")).exec(b))&&!c.isUnd(e[1])?d=a+"[2]: "+e[1]:null!==(e=(new h.RegExp("^("+a+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi")).exec(b))&&!c.isUnd(e[1])&&!c.isUnd(e[2])&&!c.isUnd(e[3])?(c.pInt(e[2]),d=e[1]+(c.pInt(e[2])+1)+e[3]):d=a+": "+b;return d};c.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)};c.friendlySize=function(a){a=c.pInt(a);return 1073741824<=a?c.roundNumber(a/1073741824,1)+"GB":1048576<=a?c.roundNumber(a/1048576,1)+"MB":1024<=a?c.roundNumber(a/
1024,0)+"KB":a+"B"};c.log=function(a){h.console&&h.console.log&&h.console.log(a)};c.getNotification=function(a){a=c.pInt(a);return c.isUnd(k[a])?"":k[a]};c.initNotificationLanguage=function(){k[g.Notification.InvalidToken]=c.i18n("NOTIFICATIONS/INVALID_TOKEN");k[g.Notification.AuthError]=c.i18n("NOTIFICATIONS/AUTH_ERROR");k[g.Notification.AccessError]=c.i18n("NOTIFICATIONS/ACCESS_ERROR");k[g.Notification.ConnectionError]=c.i18n("NOTIFICATIONS/CONNECTION_ERROR");k[g.Notification.CaptchaError]=c.i18n("NOTIFICATIONS/CAPTCHA_ERROR");
k[g.Notification.SocialFacebookLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE");k[g.Notification.SocialTwitterLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE");k[g.Notification.SocialGoogleLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE");k[g.Notification.DomainNotAllowed]=c.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED");k[g.Notification.AccountNotAllowed]=c.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED");k[g.Notification.CantGetMessageList]=
c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST");k[g.Notification.CantGetMessage]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE");k[g.Notification.CantDeleteMessage]=c.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE");k[g.Notification.CantMoveMessage]=c.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE");k[g.Notification.CantSaveMessage]=c.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE");k[g.Notification.CantSendMessage]=c.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE");k[g.Notification.InvalidRecipients]=c.i18n("NOTIFICATIONS/INVALID_RECIPIENTS");
k[g.Notification.CantCreateFolder]=c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER");k[g.Notification.CantRenameFolder]=c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER");k[g.Notification.CantDeleteFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER");k[g.Notification.CantDeleteNonEmptyFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER");k[g.Notification.CantSubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER");k[g.Notification.CantUnsubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER");
k[g.Notification.CantSaveSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS");k[g.Notification.CantSavePluginSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS");k[g.Notification.DomainAlreadyExists]=c.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS");k[g.Notification.CantInstallPackage]=c.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE");k[g.Notification.CantDeletePackage]=c.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE");k[g.Notification.InvalidPluginPackage]=c.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE");
k[g.Notification.UnsupportedPluginPackage]=c.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE");k[g.Notification.LicensingServerIsUnavailable]=c.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE");k[g.Notification.LicensingExpired]=c.i18n("NOTIFICATIONS/LICENSING_EXPIRED");k[g.Notification.LicensingBanned]=c.i18n("NOTIFICATIONS/LICENSING_BANNED");k[g.Notification.DemoSendMessageError]=c.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR");k[g.Notification.AccountAlreadyExists]=c.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS");
k[g.Notification.MailServerError]=c.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR");k[g.Notification.UnknownNotification]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR");k[g.Notification.UnknownError]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR")};c.getUploadErrorDescByCode=function(a){var b="";switch(c.pInt(a)){case g.UploadErrorCode.FileIsTooBig:b=c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case g.UploadErrorCode.FilePartiallyUploaded:b=c.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case g.UploadErrorCode.FileNoUploaded:b=
c.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case g.UploadErrorCode.MissingTempFolder:b=c.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case g.UploadErrorCode.FileOnSaveingError:b=c.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case g.UploadErrorCode.FileType:b=c.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=c.i18n("UPLOAD/ERROR_UNKNOWN")}return b};c.killCtrlAandS=function(a){if(a=a||h.event){var b=a.target||a.srcElement,e=a.keyCode||a.which;if(a.ctrlKey&&e===g.EventKeyCode.S)a.preventDefault();else if((!b||
!b.tagName||!b.tagName.match(/INPUT|TEXTAREA/i))&&a.ctrlKey&&e===g.EventKeyCode.A)h.getSelection?h.getSelection().removeAllRanges():h.document.selection&&h.document.selection.clear&&h.document.selection.clear(),a.preventDefault()}};c.createCommand=function(a,b,e){var q=b?function(){q.canExecute&&q.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments));return!1}:function(){};q.enabled=d.observable(!0);e=c.isUnd(e)?!0:e;q.canExecute=c.isFunc(e)?d.computed(function(){return q.enabled()&&e.call(a)}):
d.computed(function(){return q.enabled()&&!!e});return q};c.initDataConstructorBySettings=function(a){a.ignoreFolderSubscribe=d.observable(!1);a.editorDefaultType=d.observable(g.EditorDefaultType.Html);a.showImages=d.observable(!1);a.showAnimation=d.observable(!1);a.desktopNotifications=d.observable(!1);a.useThreads=d.observable(!0);a.replySameFolder=d.observable(!0);a.usePreviewPane=d.observable(!0);a.useCheckboxesInList=d.observable(!0);a.showAnimation.subscribe(function(a){C?S.removeClass("rl-anim").addClass("no-rl-anim"):
S.toggleClass("rl-anim",a).toggleClass("no-rl-anim",!a)});a.showAnimation.valueHasMutated();a.desktopNotificationsPermisions=d.computed(function(){a.desktopNotifications();var b=g.DesctopNotifications.NotSupported;if(Y&&Y.permission)switch(Y.permission.toLowerCase()){case "granted":b=g.DesctopNotifications.Allowed;break;case "denied":b=g.DesctopNotifications.Denied;break;case "default":b=g.DesctopNotifications.NotAllowed}else h.webkitNotifications&&h.webkitNotifications.checkPermission&&(b=h.webkitNotifications.checkPermission());
return b});a.useDesktopNotifications=d.computed({read:function(){return a.desktopNotifications()&&g.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()},write:function(b){b?(b=a.desktopNotificationsPermisions(),g.DesctopNotifications.Allowed===b?a.desktopNotifications(!0):g.DesctopNotifications.NotAllowed===b?Y.requestPermission(function(){a.desktopNotifications.valueHasMutated();h.console.log(a.desktopNotificationsPermisions());g.DesctopNotifications.Allowed===a.desktopNotificationsPermisions()?
a.desktopNotifications()?a.desktopNotifications.valueHasMutated():a.desktopNotifications(!0):a.desktopNotifications()?a.desktopNotifications(!1):a.desktopNotifications.valueHasMutated()}):a.desktopNotifications(!1)):a.desktopNotifications(!1)}});a.language=d.observable("");a.languages=d.observableArray([]);a.mainLanguage=d.computed({read:a.language,write:function(b){b!==a.language()?-1<c.inArray(b,a.languages())?a.language(b):0<a.languages().length&&a.language(a.languages()[0]):a.language.valueHasMutated()}});
a.theme=d.observable("");a.themes=d.observableArray([]);a.mainTheme=d.computed({read:a.theme,write:function(b){if(b!==a.theme()){var e=a.themes();-1<c.inArray(b,e)?a.theme(b):0<e.length&&a.theme(e[0])}else a.theme.valueHasMutated()}});a.allowCustomTheme=d.observable(!0);a.allowAdditionalAccounts=d.observable(!0);a.messagesPerPage=d.observable(l.Defaults.MessagesPerPage);a.mainMessagesPerPage=a.messagesPerPage;a.mainMessagesPerPage=d.computed({read:a.messagesPerPage,write:function(b){-1<c.inArray(c.pInt(b),
l.Defaults.MessagesPerPageArray)?b!==a.messagesPerPage()&&a.messagesPerPage(b):a.messagesPerPage.valueHasMutated()}});a.facebookEnable=d.observable(!1);a.facebookAppID=d.observable("");a.facebookAppSecret=d.observable("");a.twitterEnable=d.observable(!1);a.twitterConsumerKey=d.observable("");a.twitterConsumerSecret=d.observable("");a.googleEnable=d.observable(!1);a.googleClientID=d.observable("");a.googleClientSecret=d.observable("");a.dropboxEnable=d.observable(!1);a.dropboxApiKey=d.observable("");
a.contactsIsSupported=d.observable(!1);a.contactsIsAllowed=d.observable(!1)};c.createMomentDate=function(a){return d.computed(function(){ia();return this.moment().fromNow()},a)};c.createMomentShortDate=function(a){return d.computed(function(){var a="",a=moment(),e=this.moment(),d=this.momentDate();return a=4>=a.diff(e,"hours")?d:a.format("L")===e.format("L")?c.i18n("MESSAGE_LIST/TODAY_AT",{TIME:e.format("LT")}):a.clone().subtract("days",1).format("L")===e.format("L")?c.i18n("MESSAGE_LIST/YESTERDAY_IN",
{TIME:e.format("LT")}):a.year()===e.year()?e.format("D MMM."):e.format("LL")},a)};c.isFolderExpanded=function(a){var b=f.local().get(g.ClientSideKeyName.ExpandedFolders);return j.isArray(b)&&-1!==j.indexOf(b,a)};c.setExpandedFolder=function(a,b){var e=f.local().get(g.ClientSideKeyName.ExpandedFolders);j.isArray(e)||(e=[]);b?(e.push(a),e=j.uniq(e)):e=j.without(e,a);f.local().set(g.ClientSideKeyName.ExpandedFolders,e)};c.initLayoutResizer=function(a,b,e,c){var d=i(a),ma=i(b),h=i(e),a=f.local().get(g.ClientSideKeyName.MailBoxListSize),
D=function(a,b,e){if(b||e)a=h.width(),b=b?100*(b.size.width/a):null,null===b&&e&&(b=100*(d.width()/a)),null!==b&&(d.css({width:"",height:"",right:""+(100-b)+"%"}),ma.css({width:"",height:"",left:""+b+"%"}))};a&&d.width(a);d.resizable({minWidth:350,maxWidth:h.width()-250,handles:"e",resize:D,stop:D});D(null,null,!0);G.resize(j.throttle(function(a,b){if(c&&c()){var e=h.width();d.resizable("option","maxWidth",e-250);b&&(b.size&&b.size.width)&&f.local().set(g.ClientSideKeyName.MailBoxListSize,b.size.width);
D(null,null,!0)}},400))};c.initBlockquoteSwitcher=function(a){if(a){var b=i("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===i(this).parent().closest("blockquote",a).length});b&&0<b.length&&b.each(function(){var a=i(this),b=a.height();if(0===b||100<b)a.addClass("rl-bq-switcher hidden-bq"),i('<span class="rlBlockquoteSwitcher"><i class="icon-ellipsis" /></span>').insertBefore(a).click(function(){a.toggleClass("hidden-bq");c.windowResize()}).after("<br />").before("<br />")})}};c.removeBlockquoteSwitcher=
function(a){a&&(i(a).find("blockquote.rl-bq-switcher").each(function(){i(this).removeClass("rl-bq-switcher hidden-bq")}),i(a).find(".rlBlockquoteSwitcher").each(function(){i(this).remove()}))};c.extendAsViewModel=function(a,b){b&&(b.__name=a,o.regViewModelHook(a,b),j.extend(b.prototype,t.prototype))};c.addSettingsViewModel=function(a,b,e,c,d){a.__rlSettingsData={Label:e,Template:b,Route:c,IsDefault:!!d};X.push(a)};c.removeSettingsViewModel=function(a){ka.push(a)};c.disableSettingsViewModel=function(a){la.push(a)};
c.convertThemeName=function(a){return c.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))};c.convertLangName=function(a){return c.i18n("LANGS_NAMES/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)};c.fakeMd5=function(a){for(var b="",a=c.isUnd(a)?32:c.pInt(a);b.length<a;)b+="0123456789abcdefghijklmnopqrstuvwxyz".substr(h.Math.round(36*h.Math.random()),1);return b};c.convertPlainTextToHtml=function(a){return a.toString().replace(/&/g,"&amp;").replace(/>/g,
"&gt;").replace(/</g,"&lt;").replace(/\r/g,"").replace(/\n/g,"<br />")};c.draggeblePlace=function(){return i('<div class="draggablePlace"><span class="text"></span>&nbsp;<i class="icon-envelope icon-white"></i></div>').appendTo("#rl-hidden")};c.defautOptionsAfterRender=function(a,b){b&&!c.isUnd(b.disable)&&d.applyBindingsToNode(a,{disable:b.disable},b)};c.windowPopupKnockout=function(a,b,e,d){var f=null,g=h.open(""),j="__OpenerApplyBindingsUid"+c.fakeMd5()+"__",D=i("#"+b);h[j]=function(){if(g&&g.document.body&&
D&&D[0]){var b=i(g.document.body);i("#rl-content",b).html(D.html());i("html",g.document).addClass("external "+i("html").attr("class"));c.i18nToNode(b);m.prototype.applyExternal(a,i("#rl-content",b)[0]);h[j]=null;d(g)}};g.document.open();g.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>'+
c.encodeHtml(e)+'</title></head><body><div id="rl-content"></div></body></html>');g.document.close();f=g.document.createElement("script");f.type="text/javascript";f.innerHTML="if(window&&window.opener&&window.opener['"+j+"']){window.opener['"+j+"']();window.opener['"+j+"']=null}";g.document.getElementsByTagName("head")[0].appendChild(f)};c.settingsSaveHelperFunction=function(a,b,e,d){e=e||null;d=c.isUnd(d)?1E3:c.pInt(d);return function(c,f,h,i,va){b.call(e,f&&f.Result?g.SaveSettingsStep.TrueResult:
g.SaveSettingsStep.FalseResult);a&&a.call(e,c,f,h,i,va);j.delay(function(){b.call(e,g.SaveSettingsStep.Idle)},d)}};c.settingsSaveHelperSimpleFunction=function(a,b){return c.settingsSaveHelperFunction(null,a,b,1E3)};c.resizeAndCrop=function(a,b,e){var c=new Image;c.onload=function(){var a=[0,0],c=document.createElement("canvas"),d=c.getContext("2d");c.width=b;c.height=b;a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width];d.fillStyle="#fff";d.fillRect(0,0,b,b);d.drawImage(this,
a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,b,b);e(c.toDataURL("image/jpeg"))};c.src=a};d.bindingHandlers.tooltip={init:function(a,b){if(!C){var e=i(a).data("tooltip-class")||"";i(a).tooltip({delay:{show:500,hide:100},html:!0,trigger:"hover",title:function(){return'<span class="tooltip-class '+e+'">'+c.i18n(d.utils.unwrapObservable(b()))+"</span>"}})}}};d.bindingHandlers.tooltip2={init:function(a,b){var c=i(a).data("tooltip-class")||"";i(a).tooltip({delay:{show:500,hide:100},html:!0,title:function(){return'<span class="tooltip-class '+
c+'">'+b()()+"</span>"}})}};d.bindingHandlers.popover={init:function(a,b){var e=d.utils.unwrapObservable(b());i(a).popover({trigger:e[2]||"click",placement:e[3]||"right",title:function(){return c.i18n(e[0]||"")},content:function(){return c.i18n(e[1]||"")}})}};d.bindingHandlers.resizecrop={init:function(a){i(a).addClass("resizecrop").resizecrop({width:"100",height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,b){b()();i(a).resizecrop({width:"100",height:"100"})}};d.bindingHandlers.onEnter=
{init:function(a,b,c,d){i(a).on("keypress",function(c){c&&13===h.parseInt(c.keyCode,10)&&(i(a).trigger("change"),b().call(d))})}};d.bindingHandlers.onEsc={init:function(a,b,c,d){i(a).on("keypress",function(c){c&&27===h.parseInt(c.keyCode,10)&&(i(a).trigger("change"),b().call(d))})}};d.bindingHandlers.modal={init:function(a,b){i(a).modal({keyboard:!1,show:d.utils.unwrapObservable(b())}).on("hidden",function(){b()(!1)})},update:function(a,b){var c=d.utils.unwrapObservable(b());i(a).modal(c?"show":"hide");
j.delay(function(){i(a).toggleClass("popup-active",c)},1)}};d.bindingHandlers.i18nInit={init:function(a){c.i18nToNode(a)}};d.bindingHandlers.i18nUpdate={update:function(a,b){d.utils.unwrapObservable(b());c.i18nToNode(a)}};d.bindingHandlers.link={update:function(a,b){i(a).attr("href",d.utils.unwrapObservable(b()))}};d.bindingHandlers.title={update:function(a,b){i(a).attr("title",d.utils.unwrapObservable(b()))}};d.bindingHandlers.textF={init:function(a,b){i(a).text(d.utils.unwrapObservable(b()))}};
d.bindingHandlers.initDom={init:function(a,b){b()(a)}};d.bindingHandlers.initResizeTrigger={init:function(a,b){var c=d.utils.unwrapObservable(b());i(a).css({height:c[1],"min-height":c[1]})},update:function(a,b){var e=d.utils.unwrapObservable(b()),f=c.pInt(e[1]),g=0,g=i(a).offset().top;0<g&&(g+=c.pInt(e[2]),g=G.height()-g,f<g&&(f=g),i(a).css({height:f,"min-height":f}))}};d.bindingHandlers.appendDom={update:function(a,b){i(a).hide().empty().append(d.utils.unwrapObservable(b())).show()}};d.bindingHandlers.draggable=
{init:function(a,b,e){if(!C){var f=(e=e())&&e.droppableSelector?e.droppableSelector:"",e={distance:20,handle:".dragHandle",cursorAt:{top:22,left:3},refreshPositions:!0,scroll:!0};f&&(e.drag=function(a){i(f).each(function(){var b=null,e=null,d=i(this),e=d.offset(),b=e.top+d.height();h.clearInterval(d.data("timerScroll"));d.data("timerScroll",!1);if(a.pageX>=e.left&&a.pageX<=e.left+d.width()&&(a.pageY>=b-100&&a.pageY<=b&&(b=function(){d.scrollTop(d.scrollTop()+3);c.windowResize()},d.data("timerScroll",
h.setInterval(b,10)),b()),a.pageY>=e.top&&a.pageY<=e.top+100))e=function(){d.scrollTop(d.scrollTop()-3);c.windowResize()},d.data("timerScroll",h.setInterval(e,10)),e()})},e.stop=function(){i(f).each(function(){h.clearInterval(i(this).data("timerScroll"));i(this).data("timerScroll",!1)})});e.helper=function(a){return b()(a&&a.target?d.dataFor(a.target):null)};i(a).draggable(e).on("mousedown",function(){c.removeInFocus()})}}};d.bindingHandlers.droppable={init:function(a,b,c){if(!C){var d=b(),f=(b=c())&&
b.droppableOver?b.droppableOver:null,g=b&&b.droppableOut?b.droppableOut:null,b={tolerance:"pointer",hoverClass:"droppableHover"};d&&(b.drop=function(a,b){d(a,b)},f&&(b.over=function(a,b){f(a,b)}),g&&(b.out=function(a,b){g(a,b)}),i(a).droppable(b))}}};d.bindingHandlers.nano={init:function(a){C||i(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}};d.bindingHandlers.saveTrigger={init:function(a){i(a).append('&nbsp;&nbsp;<i class="icon-spinner-2 animated"></i><i class="icon-remove error"></i><i class="icon-ok success"></i>').addClass("settings-saved-trigger")},
update:function(a,b){var c=d.utils.unwrapObservable(b()),f=i(a);switch(c.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")}}};
d.bindingHandlers.select2={init:function(a,b){var e=0,g=null,ua=new h.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),ma=new h.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),k=function(){return""},l=function(a){f.getAutocomplete(a.term,a.page,function(b,c){a.callback({more:!!c,results:j.map(b,function(a){var b=a.toLine(!1);return{id:b,text:b,c:a}})})})};i(a).addClass("ko-select2").select2({query:function(a){a&&(0===e?(l(a),e=h.setTimeout(c.emptyFunction,200)):(h.clearInterval(e),e=h.setTimeout(function(){l(a)},
200)))},formatSelection:function(a,b){var c=a&&a.c?a.c.select2Selection(b):a.text;if(null!==c)return c},formatResult:function(a,b,c,e){b=a&&a.c?a.c.select2Result(b):"";return""===b?e(a.text):b},createSearchChoice:function(a,b){return 0===b.length&&ua.test(a)?{id:a,text:a}:null},formatNoMatches:k,formatSearching:function(){return c.i18n("SUGGESTIONS/SEARCHING_DESC")},formatInputTooShort:k,formatSelectionTooBig:k,multiple:!0,tokenSeparators:[",",";"],minimumInputLength:2,selectOnBlur:!1,closeOnSelect:!0,
openOnEnter:!1});d.utils.domNodeDisposal.addDisposeCallback(a,function(){i(a).select2("destroy")});i(a).on("change",function(){for(var a=i(this).select2("data"),e=0,d=a.length,f=null,h=[];e<d;e++)if((f=a[e])&&f.id)f.c||(f.c=new r,(g=ma.exec(c.trim(f.id)))&&!c.isUnd(g[2])?(f.c.name=g[1],f.c.email=g[2]):f.c.email=f.id),h.push(f.c);b()(h)})},update:function(a,b){for(var c=d.utils.unwrapObservable(b()),f=0,g=c.length,h=null,j="",k=[];f<g;f++)h=c[f],j=h.toLine(!1),k.push({id:j,text:j,c:h});i(a).select2("data",
k)}};d.bindingHandlers.command={init:function(a,b,c,f){var g=i(a),h=b();if(!h||!h.enabled||!h.canExecute)throw Error("You are not using command function");g.addClass("command");d.bindingHandlers[g.is("form")?"submit":"click"].init.apply(f,arguments)},update:function(a,b){var c=!0,d=i(a),f=b(),c=f.enabled();d.toggleClass("command-not-enabled",!c);c&&(c=f.canExecute(),d.toggleClass("command-can-not-be-execute",!c));d.toggleClass("command-disabled disable disabled",!c);(d.is("input")||d.is("button"))&&
d.prop("disabled",!c)}};d.extenders.trimmer=function(a){var b=d.computed({read:a,write:function(b){a(c.trim(b.toString()))},owner:this});b(a());return b};d.extenders.reversible=function(a){var b=a();a.commit=function(){b=a()};a.reverse=function(){a(b)};a.commitedValue=function(){return b};return a};d.extenders.toggleSubscribe=function(a,b){a.subscribe(b[1],b[0],"beforeChange");a.subscribe(b[2],b[0]);return a};d.extenders.falseTimeout=function(a,b){a.iTimeout=0;a.subscribe(function(e){e&&(h.clearTimeout(a.iTimeout),
a.iTimeout=h.setTimeout(function(){a(!1);a.iTimeout=0},c.pInt(b)))});return a};d.observable.fn.validateEmail=function(){this.hasError=d.observable(!1);this.subscribe(function(a){a=c.trim(a);this.hasError(""!==a&&!/^[^@\s]+@[^@\s]+$/.test(a))},this);this.valueHasMutated();return this};d.observable.fn.validateFunc=function(a){this.hasFuncError=d.observable(!1);c.isFunc(a)&&(this.subscribe(function(b){this.hasFuncError(!a(b))},this),this.valueHasMutated());return this};n.prototype.root=function(){return this.sBase};
n.prototype.attachmentDownload=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};n.prototype.attachmentPreview=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/View/"+a};n.prototype.attachmentPreviewAsPlain=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};n.prototype.upload=function(){return this.sServer+"/Upload/"+this.sSpecSuffix+"/"};n.prototype.uploadBackground=function(){return this.sServer+"/UploadBackground/"+this.sSpecSuffix+"/"};
n.prototype.append=function(){return this.sServer+"/Append/"+this.sSpecSuffix+"/"};n.prototype.change=function(a){return this.sServer+"/Change/"+this.sSpecSuffix+"/"+h.encodeURIComponent(a)+"/"};n.prototype.ajax=function(a){return this.sServer+"/Ajax/"+this.sSpecSuffix+"/"+a};n.prototype.messageViewLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/ViewAsPlain/"+a};n.prototype.messageDownloadLink=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/Download/"+a};n.prototype.inbox=
function(){return this.sBase+"mailbox/Inbox"};n.prototype.settings=function(a){var b=this.sBase+"settings";!c.isUnd(a)&&""!==a&&(b+="/"+a);return b};n.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};n.prototype.mailBox=function(a,b,e){var b=c.isNormal(b)?c.pInt(b):1,e=c.pString(e),d=this.sBase+"mailbox/";""!==a&&(d+=encodeURI(a));1<b&&(d=d.replace(/[\/]+$/,""),d+="/p"+
b);""!==e&&(d=d.replace(/[\/]+$/,""),d+="/"+encodeURI(e));return d};n.prototype.phpInfo=function(){return this.sServer+"Info"};n.prototype.langLink=function(a){return this.sServer+"/Lang/0/"+encodeURI(a)+"/"+this.sVersion+"/"};n.prototype.getUserPicUrlFromHash=function(a){return this.sServer+"/Raw/"+this.sSpecSuffix+"/UserPic/"+a+"/"+this.sVersion+"/"};n.prototype.emptyContactPic=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/empty-contact.png"};
n.prototype.sound=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/sounds/"+a};n.prototype.themePreviewLink=function(a){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/themes/"+encodeURI(a)+"/images/preview.png"};n.prototype.notificationMailIcon=function(){return(""===this.sCdnStaticDomain?"rainloop/v/":this.sCdnStaticDomain)+this.sVersion+"/static/css/images/icom-message-notification.png"};n.prototype.socialGoogle=
function(){return this.sServer+"SocialGoogle"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};n.prototype.socialTwitter=function(){return this.sServer+"SocialTwitter"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};n.prototype.socialFacebook=function(){return this.sServer+"SocialFacebook"+(""!==this.sSpecSuffix?"/"+this.sSpecSuffix+"/":"")};o.oViewModelsHooks={};o.oSimpleHooks={};o.regViewModelHook=function(a,b){b&&(b.__hookName=a)};o.addHook=function(a,b){c.isFunc(b)&&(c.isArray(o.oSimpleHooks[a])||
(o.oSimpleHooks[a]=[]),o.oSimpleHooks[a].push(b))};o.runHook=function(a,b){c.isArray(o.oSimpleHooks[a])&&(b=b||[],j.each(o.oSimpleHooks[a],function(a){a.apply(null,b)}))};o.mainSettingsGet=function(a){return f?f.settingsGet(a):null};o.remoteRequest=function(a,b,c,d,g,h){f&&f.remote().defaultRequest(a,b,c,d,g,h)};o.settingsGet=function(a,b){var e=o.mainSettingsGet("Plugins");return(e=e&&c.isUnd(e[a])?null:e[a])?c.isUnd(e[b])?null:e[b]:null};M.supported=function(){return!0};M.prototype.set=function(a,
b){var c=i.cookie(l.Values.ClientSideCookieIndexName),d=null;try{(d=null===c?null:JSON.parse(c))||(d={}),d[a]=b,i.cookie(l.Values.ClientSideCookieIndexName,JSON.stringify(d),{expires:30})}catch(f){}return d};M.prototype.get=function(a){var b=i.cookie(l.Values.ClientSideCookieIndexName),e=null;try{e=(e=null===b?null:JSON.parse(b))&&!c.isUnd(e[a])?e[a]:null}catch(d){}return e};N.supported=function(){return!!h.localStorage};N.prototype.set=function(a,b){var c=h.localStorage[l.Values.ClientSideCookieIndexName]||
null,d=null;try{(d=null===c?null:JSON.parse(c))||(d={}),d[a]=b,h.localStorage[l.Values.ClientSideCookieIndexName]=JSON.stringify(d)}catch(f){}return d};N.prototype.get=function(a){var b=h.localStorage[l.Values.ClientSideCookieIndexName]||null,e=null;try{e=(e=null===b?null:JSON.parse(b))&&!c.isUnd(e[a])?e[a]:null}catch(d){}return e};O.prototype.oDriver=null;O.prototype.set=function(a,b){return this.oDriver?this.oDriver.set("p"+a,b):!1};O.prototype.get=function(a){return this.oDriver?this.oDriver.get("p"+
a):null};pa.prototype.bootstart=function(){};t.prototype.sPosition="";t.prototype.sTemplate="";t.prototype.viewModelName="";t.prototype.viewModelDom=null;t.prototype.viewModelTemplate=function(){return this.sTemplate};t.prototype.viewModelPosition=function(){return this.sPosition};t.prototype.cancelCommand=t.prototype.closeCommand=function(){};w.prototype.oCross=null;w.prototype.sScreenName="";w.prototype.aViewModels=[];w.prototype.viewModels=function(){return this.aViewModels};w.prototype.screenName=
function(){return this.sScreenName};w.prototype.routes=function(){return null};w.prototype.__cross=function(){return this.oCross};w.prototype.__start=function(){var a=this.routes(),b=null,e=null;c.isNonEmptyArray(a)&&(e=j.bind(this.onRoute||c.emptyFunction,this),b=oa.create(),j.each(a,function(a){b.addRoute(a[0],e).rules=a[1]}),this.oCross=b)};m.prototype.sDefaultScreenName="";m.prototype.oScreens={};m.prototype.oBoot=null;m.prototype.oCurrentScreen=null;m.prototype.showLoading=function(){i("#rl-loading").show()};
m.prototype.hideLoading=function(){i("#rl-loading").hide()};m.prototype.routeOff=function(){y.changed.active=!1};m.prototype.routeOn=function(){y.changed.active=!0};m.prototype.setBoot=function(a){c.isNormal(a)&&(this.oBoot=a);return this};m.prototype.screen=function(a){return""!==a&&!c.isUnd(this.oScreens[a])?this.oScreens[a]:null};m.prototype.delegateRun=function(a,b,e){a&&a[b]&&a[b].apply(a,c.isArray(e)?e:[])};m.prototype.buildViewModel=function(a,b){if(a&&!a.__builded){var e=new a(b),g=e.viewModelPosition(),
h=i("#rl-content #rl-"+g.toLowerCase()),j=null;a.__builded=!0;a.__vm=e;e.data=f.data();e.viewModelName=a.__name;h&&1===h.length?(j=i("<div>").addClass("rl-view-model").addClass("RL-"+e.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+e.viewModelTemplate()+'"}, i18nInit: true'),j.appendTo(h),e.viewModelDom=j,a.__dom=j,"Popups"===g&&(e.cancelCommand=e.closeCommand=c.createCommand(e,function(){s.hideScreenPopup(a)})),o.runHook("view-model-pre-build",[a.__name,e,j]),d.applyBindings(e,
j[0]),this.delegateRun(e,"onBuild",[j]),o.runHook("view-model-post-build",[a.__name,e,j])):c.log("Cannot find view model position: "+g)}return a?a.__vm:null};m.prototype.applyExternal=function(a,b){a&&b&&d.applyBindings(a,b)};m.prototype.hideScreenPopup=function(a){a&&(a.__vm&&a.__dom)&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),j.defer(function(){a.__dom.find(".ko-select2").select2("close")}))};m.prototype.showScreenPopup=function(a,b){a&&
(this.buildViewModel(a),a.__vm&&a.__dom&&(a.__dom.show(),a.__vm.modalVisibility(!0),this.delegateRun(a.__vm,"onShow",b||[]),this.popupVisibility(!0),o.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))};m.prototype.screenOnRoute=function(a,b){var e=this,d=null,f=null;""===c.pString(a)&&(a=this.sDefaultScreenName);if(""!==a){d=this.screen(a);if(!d&&(d=this.screen(this.sDefaultScreenName)))b=a+"/"+b,a=this.sDefaultScreenName;d&&d.__started&&(d.__builded||(d.__builded=!0,c.isNonEmptyArray(d.viewModels())&&
j.each(d.viewModels(),function(a){this.buildViewModel(a,d)},this),this.delegateRun(d,"onBuild")),j.defer(function(){if(e.oCurrentScreen){e.delegateRun(e.oCurrentScreen,"onHide");c.isNonEmptyArray(e.oCurrentScreen.viewModels())&&j.each(e.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.hide();a.__vm.viewModelVisibility(false);e.delegateRun(a.__vm,"onHide")}})}e.oCurrentScreen=d;if(e.oCurrentScreen){e.delegateRun(e.oCurrentScreen,"onShow");o.runHook("screen-on-show",
[e.oCurrentScreen.screenName(),e.oCurrentScreen]);c.isNonEmptyArray(e.oCurrentScreen.viewModels())&&j.each(e.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.show();a.__vm.viewModelVisibility(true);e.delegateRun(a.__vm,"onShow");o.runHook("view-model-on-show",[a.__name,a.__vm])}},e)}(f=d.__cross())&&f.parse(b)}))}};m.prototype.startScreens=function(a){j.each(a,function(a){var c=(a=new a)?a.screenName():"";a&&""!==c&&(""===this.sDefaultScreenName&&
(this.sDefaultScreenName=c),this.oScreens[c]=a)},this);j.each(this.oScreens,function(a){a&&(!a.__started&&a.__start)&&(a.__started=!0,a.__start(),o.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),o.runHook("screen-post-start",[a.screenName(),a]))},this);a=oa.create();a.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,j.bind(this.screenOnRoute,this));y.initialized.add(a.parse,a);y.changed.add(a.parse,a);y.init()};m.prototype.setHash=function(a,b){a="#"===a.substr(0,1)?a.substr(1):
a;a="/"===a.substr(0,1)?a.substr(1):a;(c.isUnd(b)?0:b)?(y.changed.active=!1,y.setHash(a),y.changed.active=!0):(y.changed.active=!0,y.setHash(a))};m.prototype.bootstart=function(){this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart();return this};s=new m;r.newInstanceFromJson=function(a){var b=new r;return b.initByJson(a)?b:null};r.prototype.name="";r.prototype.email="";r.prototype.privateType=null;r.prototype.validate=function(){return""!==this.name||""!==this.email};r.prototype.hash=function(a){return"#"+
(a?"":this.name)+"#"+this.email+"#"};r.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")};r.prototype.type=function(){if(null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=g.EmailType.Facebook),null===this.privateType))this.privateType=g.EmailType.Default;return this.privateType};r.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())};r.prototype.parse=function(a){var a=c.trim(a),
b=/(?:"([^"]+)")? ?<?(.*?@[^>,]+)>?,? ?/g.exec(a);b?(this.name=b[1]||"",this.email=b[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)};r.prototype.initByJson=function(a){var b=!1;a&&"Object/Email"===a["@Object"]&&(this.name=c.trim(a.Name),this.email=c.trim(a.Email),b=""!==this.email,this.clearDuplicateName());return b};r.prototype.toLine=function(a,b){var e="";""!==this.email&&(b=c.isUnd(b)?!1:!!b,a&&""!==this.name?e=b?'<a href="mailto:'+c.encodeHtml('"'+this.name+
'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.name)+"</a>":this.name:(e=this.email,""!==this.name?e=b?c.encodeHtml('"'+this.name+'" <')+'<a href="mailto:'+c.encodeHtml('"'+this.name+'" <'+this.email+">")+'" target="_blank" tabindex="-1">'+c.encodeHtml(e)+"</a>"+c.encodeHtml(">"):'"'+this.name+'" <'+e+">":b&&(e='<a href="mailto:'+c.encodeHtml(this.email)+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.email)+"</a>")));return e};r.prototype.select2Result=function(){var a=
"",b=f.cache().getUserPic(this.email),a=""!==b?a+('<img class="select2-user-pic pull-left" src="'+c.encodeHtml(b)+'" />'):a+('<img class="select2-user-pic pull-left" src="'+f.link().emptyContactPic()+'" />');g.EmailType.Facebook===this.type()?(a+=""+(0<this.name.length?this.name:this.email),a+='<i class="icon-facebook pull-right select2-icon-result" />'):a+=""+(0<this.name.length?this.email+' <span class="select2-subname">('+this.name+")</span>":this.email);return a+""};r.prototype.select2Selection=
function(a){var b="";if(g.EmailType.Facebook===this.type()){if(b=0<this.name.length?this.name:this.email,""!==b)return i("<pan>").text(b).appendTo(a),a.append('<i class="icon-facebook select2-icon"></i>'),null}else b=0<this.name.length?this.name+" ("+this.email+")":this.email;return b};c.extendAsViewModel("PopupsDomainViewModel",z);z.prototype.onTestConnectionResponse=function(a,b){this.testing(!1);g.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))};z.prototype.onDomainCreateOrSaveResponse=function(a,b){this.saving(!1);g.StorageResultType.Success===a&&b?b.Result?(f.reloadDomainList(),this.closeCommand()):g.Notification.DomainAlreadyExists===b.ErrorCode&&this.savingError("Domain already exists"):this.savingError("Unknown error")};z.prototype.onHide=function(){this.whiteListPage(!1)};z.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(c.trim(a.Name)),this.imapServer(c.trim(a.IncHost)),this.imapPort(c.pInt(a.IncPort)),this.imapSecure(c.trim(a.IncSecure)),this.smtpServer(c.trim(a.OutHost)),this.smtpPort(c.pInt(a.OutPort)),this.smtpSecure(c.trim(a.OutSecure)),this.smtpAuth(!!a.OutAuth),this.whiteList(c.trim(a.WhiteList)))};z.prototype.clearForm=function(){this.edit(!1);this.whiteListPage(!1);this.savingError("");
this.name("");this.imapServer("");this.imapPort(l.Values.ImapDefaulPort);this.imapSecure(g.ServerSecure.None);this.smtpServer("");this.smtpPort(l.Values.SmtpDefaulPort);this.smtpSecure(g.ServerSecure.None);this.smtpAuth(!0);this.whiteList("")};c.extendAsViewModel("PopupsPluginViewModel",P);P.prototype.onPluginSettingsUpdateResponse=function(a,b){g.StorageResultType.Success===a&&b&&b.Result?this.cancelCommand():(this.saveError(""),b&&b.ErrorCode?this.saveError(c.getNotification(b.ErrorCode)):this.saveError(c.getNotification(g.Notification.CantSavePluginSettings)))};
P.prototype.onShow=function(a){this.name();this.readme();this.configures([]);a&&(this.name(a.Name),this.readme(a.Readme),a=a.Config,c.isNonEmptyArray(a)&&this.configures(j.map(a,function(a){return{value:d.observable(a[0]),Name:a[1],Type:a[2],Label:a[3],Default:a[4],Desc:a[5]}})))};c.extendAsViewModel("PopupsActivateViewModel",Q);Q.prototype.onShow=function(){this.domain(f.settingsGet("AdminDomain"));this.activateProcess()||(this.key(""),this.activateText(""),this.activateText.isError(!1),this.activationSuccessed(!1),
this.key.focus(!0))};Q.prototype.validateSubscriptionKey=function(){var a=this.key();return""===a||!!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(c.trim(a))};c.extendAsViewModel("AdminLoginViewModel",R);R.prototype.onShow=function(){s.routeOff();j.delay(j.bind(function(){this.loginFocus(!0)},this),100)};R.prototype.onHide=function(){this.loginFocus(!1)};c.extendAsViewModel("AdminMenuViewModel",aa);aa.prototype.link=function(a){return"#/"+a};c.extendAsViewModel("AdminPaneViewModel",ba);ba.prototype.logoutClick=function(){f.remote().adminLogout(function(){f.loginAndLogoutReload()})};
c.addSettingsViewModel(qa,"AdminGeneral","General","general",!0);qa.prototype.onBuild=function(){var a=this;j.delay(function(){var b=c.settingsSaveHelperSimpleFunction(a.titleTrigger,a),e=c.settingsSaveHelperSimpleFunction(a.languageTrigger,a),d=c.settingsSaveHelperSimpleFunction(a.themeTrigger,a);a.title.subscribe(function(a){f.remote().saveAdminConfig(b,{Title:c.trim(a)})});a.language.subscribe(function(a){f.remote().saveAdminConfig(e,{Language:c.trim(a)})});a.theme.subscribe(function(a){f.remote().saveAdminConfig(d,
{Theme:c.trim(a)})});a.allowCustomTheme.subscribe(function(a){f.remote().saveAdminConfig(null,{AllowCustomTheme:a?"1":"0"})});a.allowAdditionalAccounts.subscribe(function(a){f.remote().saveAdminConfig(null,{AllowAdditionalAccounts:a?"1":"0"})})},50)};c.addSettingsViewModel(A,"AdminDomains","Domains","domains");A.prototype.startDomainForDeletionTimeout=function(){var a=this;h.clearInterval(this.iDomainForDeletionTimeout);this.iDomainForDeletionTimeout=h.setTimeout(function(){a.domainForDeletion(null)},
3E3)};A.prototype.createDomain=function(){s.showScreenPopup(z)};A.prototype.deleteDomain=function(a){this.domains.remove(a);f.remote().domainDelete(j.bind(this.onDomainListChangeRequest,this),a.name)};A.prototype.disableDomain=function(a){a.disabled(!a.disabled());f.remote().domainDisable(j.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=d.dataFor(this);a&&f.remote().domain(j.bind(b.onDomainLoadRequest,
b),a.name)});f.reloadDomainList()};A.prototype.onDomainLoadRequest=function(a,b){g.StorageResultType.Success===a&&(b&&b.Result)&&s.showScreenPopup(z,[b.Result])};A.prototype.onDomainListChangeRequest=function(){f.reloadDomainList()};c.addSettingsViewModel(K,"AdminLicensing","Licensing","licensing");K.prototype.onBuild=function(){this.subscriptionEnabled()&&f.reloadLicensing(!1)};K.prototype.onShow=function(){this.adminDomain(f.settingsGet("AdminDomain"))};K.prototype.showActivationForm=function(){s.showScreenPopup(Q)};
K.prototype.licenseExpiredMomentValue=function(){var a=moment.unix(this.licenseExpired());return a.format("LL")+" ("+a.from(moment())+")"};c.addSettingsViewModel(L,"AdminSecurity","Security","security");L.prototype.onNewAdminPasswordResponse=function(a,b){g.StorageResultType.Success===a&&b&&b.Result?(this.adminPassword(""),this.adminPasswordNew(""),this.adminPasswordUpdateSuccess(!0)):this.adminPasswordUpdateError(!0)};L.prototype.onBuild=function(){this.csrfProtection.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,
{TokenProtection:a?"1":"0"})});this.usageStatistics.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,{UsageStatistics:a?"1":"0"})})};L.prototype.onHide=function(){this.adminPassword("");this.adminPasswordNew("")};L.prototype.phpInfoLink=function(){return f.link().phpInfo()};c.addSettingsViewModel(ra,"AdminSocial","Social","social");ra.prototype.onBuild=function(){var a=this;j.delay(function(){var b=c.settingsSaveHelperSimpleFunction(a.facebookTrigger1,a),e=c.settingsSaveHelperSimpleFunction(a.facebookTrigger2,
a),d=c.settingsSaveHelperSimpleFunction(a.twitterTrigger1,a),g=c.settingsSaveHelperSimpleFunction(a.twitterTrigger2,a),h=c.settingsSaveHelperSimpleFunction(a.googleTrigger1,a),j=c.settingsSaveHelperSimpleFunction(a.googleTrigger2,a),i=c.settingsSaveHelperSimpleFunction(a.dropboxTrigger1,a);a.facebookEnable.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,{FacebookEnable:a?"1":"0"})});a.facebookAppID.subscribe(function(a){f.remote().saveAdminConfig(b,{FacebookAppID:c.trim(a)})});a.facebookAppSecret.subscribe(function(a){f.remote().saveAdminConfig(e,
{FacebookAppSecret:c.trim(a)})});a.twitterEnable.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,{TwitterEnable:a?"1":"0"})});a.twitterConsumerKey.subscribe(function(a){f.remote().saveAdminConfig(d,{TwitterConsumerKey:c.trim(a)})});a.twitterConsumerSecret.subscribe(function(a){f.remote().saveAdminConfig(g,{TwitterConsumerSecret:c.trim(a)})});a.googleEnable.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,{GoogleEnable:a?"1":"0"})});a.googleClientID.subscribe(function(a){f.remote().saveAdminConfig(h,
{GoogleClientID:c.trim(a)})});a.googleClientSecret.subscribe(function(a){f.remote().saveAdminConfig(j,{GoogleClientSecret:c.trim(a)})});a.dropboxEnable.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,{DropboxEnable:a?"1":"0"})});a.dropboxApiKey.subscribe(function(a){f.remote().saveAdminConfig(i,{DropboxApiKey:c.trim(a)})})},50)};c.addSettingsViewModel(E,"AdminPlugins","Plugins","plugins");E.prototype.disablePlugin=function(a){a.disabled(!a.disabled());f.remote().pluginDisable(this.onPluginDisableRequest,
a.name,a.disabled())};E.prototype.configurePlugin=function(a){f.remote().plugin(this.onPluginLoadRequest,a.name)};E.prototype.onBuild=function(){this.enabledPlugins.subscribe(function(a){f.remote().saveAdminConfig(c.emptyFunction,{EnabledPlugins:a?"1":"0"})})};E.prototype.onShow=function(){this.pluginsError("");f.reloadPluginList()};E.prototype.onPluginLoadRequest=function(a,b){g.StorageResultType.Success===a&&(b&&b.Result)&&s.showScreenPopup(P,[b.Result])};E.prototype.onPluginDisableRequest=function(a,
b){g.StorageResultType.Success===a&&b&&!b.Result&&b.ErrorCode&&(g.Notification.UnsupportedPluginPackage===b.ErrorCode&&b.ErrorMessage&&""!==b.ErrorMessage?this.pluginsError(b.ErrorMessage):this.pluginsError(c.getNotification(b.ErrorCode)));f.reloadPluginList()};c.addSettingsViewModel(I,"AdminPackages","Packages","packages");I.prototype.onShow=function(){this.packagesError("")};I.prototype.onBuild=function(){f.reloadPackagesList()};I.prototype.requestHelper=function(a,b){var e=this;return function(d,
i){if(g.StorageResultType.Success!==d||!i||!i.Result)i&&i.ErrorCode?e.packagesError(c.getNotification(i.ErrorCode)):e.packagesError(c.getNotification(b?g.Notification.CantInstallPackage:g.Notification.CantDeletePackage));j.each(f.data().packages(),function(b){b&&(a&&b.loading()&&a.file===b.file)&&(a.loading(!1),b.loading(!1))});g.StorageResultType.Success===d&&i&&i.Result&&i.Result.Reload?h.location.reload():f.reloadPackagesList()}};I.prototype.deletePackage=function(a){a&&(a.loading(!0),f.remote().packageDelete(this.requestHelper(a,
!1),a))};I.prototype.installPackage=function(a){a&&(a.loading(!0),f.remote().packageInstall(this.requestHelper(a,!0),a))};ca.prototype.populateDataOnStart=function(){var a=f.settingsGet("Languages"),b=f.settingsGet("Themes");c.isArray(a)&&this.languages(a);c.isArray(b)&&this.themes(b);this.mainLanguage(f.settingsGet("Language"));this.mainTheme(f.settingsGet("Theme"));this.allowCustomTheme(!!f.settingsGet("AllowCustomTheme"));this.allowAdditionalAccounts(!!f.settingsGet("AllowAdditionalAccounts"));
this.ignoreFolderSubscribe(!!f.settingsGet("IgnoreFolderSubscribe"));this.editorDefaultType(f.settingsGet("EditorDefaultType"));this.showImages(!!f.settingsGet("ShowImages"));this.showAnimation(!!f.settingsGet("ShowAnimation"));this.mainMessagesPerPage(f.settingsGet("MPP"));this.desktopNotifications(!!f.settingsGet("DesktopNotifications"));this.useThreads(!!f.settingsGet("UseThreads"));this.replySameFolder(!!f.settingsGet("ReplySameFolder"));this.usePreviewPane(!!f.settingsGet("UsePreviewPane"));
this.useCheckboxesInList(!!f.settingsGet("UseCheckboxesInList"));this.facebookEnable(!!f.settingsGet("AllowFacebookSocial"));this.facebookAppID(f.settingsGet("FacebookAppID"));this.facebookAppSecret(f.settingsGet("FacebookAppSecret"));this.twitterEnable(!!f.settingsGet("AllowTwitterSocial"));this.twitterConsumerKey(f.settingsGet("TwitterConsumerKey"));this.twitterConsumerSecret(f.settingsGet("TwitterConsumerSecret"));this.googleEnable(!!f.settingsGet("AllowGoogleSocial"));this.googleClientID(f.settingsGet("GoogleClientID"));
this.googleClientSecret(f.settingsGet("GoogleClientSecret"));this.dropboxEnable(!!f.settingsGet("AllowDropboxSocial"));this.dropboxApiKey(f.settingsGet("DropboxApiKey"));this.contactsIsSupported(!!f.settingsGet("ContactsIsSupported"));this.contactsIsAllowed(!!f.settingsGet("ContactsIsAllowed"))};j.extend(da.prototype,ca.prototype);da.prototype.populateDataOnStart=function(){ca.prototype.populateDataOnStart.call(this)};F.prototype.oRequests={};F.prototype.defaultResponse=function(a,b,d,i,k,l){var n=
function(){g.StorageResultType.Success!==d&&ga&&(d=g.StorageResultType.Unload);if(g.StorageResultType.Success===d&&i&&!i.Result){if(i&&-1<c.inArray(i.ErrorCode,[g.Notification.AuthError,g.Notification.AccessError,g.Notification.ConnectionError,g.Notification.DomainNotAllowed,g.Notification.AccountNotAllowed,g.Notification.MailServerError,g.Notification.UnknownNotification,g.Notification.UnknownError])&&T++,i&&g.Notification.InvalidToken===i.ErrorCode&&U++,10<U&&f.loginAndLogoutReload(!0),i.Logout||
7<T)h.__rlah_clear&&h.__rlah_clear(),f.loginAndLogoutReload(!0)}else g.StorageResultType.Success===d&&(i&&i.Result)&&(U=T=0);a&&(o.runHook("ajax-default-response",[b,g.StorageResultType.Success===d?i:null,d,k,l]),a(d,g.StorageResultType.Success===d?i:null,k,b,l))};switch(d){case "success":d=g.StorageResultType.Success;break;case "abort":d=g.StorageResultType.Abort;break;default:d=g.StorageResultType.Error}g.StorageResultType.Error===d?j.delay(n,300):n()};F.prototype.ajaxRequest=function(a,b,d,g,k){var l=
this,n=""===g,o=(new h.Date).getTime(),p=null,m="",b=b||{},d=c.isNormal(d)?d:2E4,g=c.isUnd(g)?"":c.pString(g),k=c.isArray(k)?k:[];(m=b.Action||"")&&0<k.length&&j.each(k,function(a){l.oRequests[a]&&(l.oRequests[a].__aborted=!0,l.oRequests[a].abort&&l.oRequests[a].abort(),l.oRequests[a]=null)});n&&(b.XToken=f.settingsGet("Token"));p=i.ajax({type:n?"POST":"GET",url:f.link().ajax(g),async:!0,dataType:"json",data:n?b:{},headers:{},timeout:d,global:!0});p.always(function(d,e){var f=!1;d&&d.Time&&(f=c.pInt(d.Time)>
(new h.Date).getTime()-o);m&&l.oRequests[m]&&(l.oRequests[m].__aborted&&(e="abort"),l.oRequests[m]=null);l.defaultResponse(a,m,e,d,f,b)});m&&(0<k.length&&-1<c.inArray(m,k))&&(this.oRequests[m]&&(this.oRequests[m].__aborted=!0,this.oRequests[m].abort&&this.oRequests[m].abort(),this.oRequests[m]=null),this.oRequests[m]=p);return p};F.prototype.defaultRequest=function(a,b,d,f,g,h){d=d||{};d.Action=b;g=c.pString(g);o.runHook("ajax-default-request",[b,d,g]);this.ajaxRequest(a,d,c.isUnd(f)?l.Defaults.DefaultAjaxTimeout:
c.pInt(f),g,h)};F.prototype.noop=function(a){this.defaultRequest(a,"Noop")};F.prototype.jsError=function(a,b,c,d,f,g){this.defaultRequest(a,"JsError",{Message:b,FileName:c,LineNo:d,Location:f,HtmlCapa:g})};j.extend(p.prototype,F.prototype);p.prototype.adminLogin=function(a,b,c){this.defaultRequest(a,"AdminLogin",{Login:b,Password:c})};p.prototype.adminLogout=function(a){this.defaultRequest(a,"AdminLogout")};p.prototype.saveAdminConfig=function(a,b){this.defaultRequest(a,"AdminSettingsUpdate",b)};
p.prototype.domainList=function(a){this.defaultRequest(a,"AdminDomainList")};p.prototype.pluginList=function(a){this.defaultRequest(a,"AdminPluginList")};p.prototype.packagesList=function(a){this.defaultRequest(a,"AdminPackagesList")};p.prototype.packageInstall=function(a,b){this.defaultRequest(a,"AdminPackageInstall",{Id:b.id,Type:b.type,File:b.file})};p.prototype.packageDelete=function(a,b){this.defaultRequest(a,"AdminPackageDelete",{Id:b.id})};p.prototype.domain=function(a,b){this.defaultRequest(a,
"AdminDomainLoad",{Name:b})};p.prototype.plugin=function(a,b){this.defaultRequest(a,"AdminPluginLoad",{Name:b})};p.prototype.domainDelete=function(a,b){this.defaultRequest(a,"AdminDomainDelete",{Name:b})};p.prototype.domainDisable=function(a,b,c){return this.defaultRequest(a,"AdminDomainDisable",{Name:b,Disabled:c?"1":"0"})};p.prototype.pluginSettingsUpdate=function(a,b){return this.defaultRequest(a,"AdminPluginSettingsUpdate",b)};p.prototype.licensing=function(a,b){return this.defaultRequest(a,"AdminLicensing",
{Force:b?"1":"0"})};p.prototype.licensingActivate=function(a,b,c){return this.defaultRequest(a,"AdminLicensingActivate",{Domain:b,Key:c})};p.prototype.pluginDisable=function(a,b,c){return this.defaultRequest(a,"AdminPluginDisable",{Name:b,Disabled:c?"1":"0"})};p.prototype.createOrUpdateDomain=function(a,b,c,d,f,g,h,i,j,k,l){this.defaultRequest(a,"AdminDomainSave",{Create:b?"1":"0",Name:c,IncHost:d,IncPort:f,IncSecure:g,OutHost:h,OutPort:i,OutSecure:j,OutAuth:k?"1":"0",WhiteList:l})};p.prototype.testConnectionForDomain=
function(a,b,c,d,f,g,h,i){this.defaultRequest(a,"AdminDomainTest",{IncHost:b,IncPort:c,IncSecure:d,OutHost:f,OutPort:g,OutSecure:h,OutAuth:i?"1":"0"})};p.prototype.saveNewAdminPassword=function(a,b){this.defaultRequest(a,"AdminPasswordUpdate",b)};p.prototype.adminPing=function(a){this.defaultRequest(a,"AdminPing")};B.prototype.oEmailsPicsHashes={};B.prototype.oServices={};B.prototype.clear=function(){this.oServices={};this.oEmailsPicsHashes={}};B.prototype.getUserPic=function(a){var b="",b="",b=a.toLowerCase(),
d=c.isUnd(this.oEmailsPicsHashes[a])?"":this.oEmailsPicsHashes[a];""===d?(b=b.substr(a.indexOf("@")+1),b=""!==b&&this.oServices[b]?this.oServices[b]:""):b=f.link().getUserPicUrlFromHash(d);return b};B.prototype.setServicesData=function(a){this.oServices=a};B.prototype.setEmailsPicsHashesData=function(a){this.oEmailsPicsHashes=a};j.extend(sa.prototype,B.prototype);j.extend(J.prototype,w.prototype);J.prototype.onRoute=function(a){var b=this,e=null,g=null,h=null,k=null;if(g=j.find(X,function(b){return b&&
b.__rlSettingsData&&a===b.__rlSettingsData.Route}))j.find(ka,function(a){return a&&a===g})&&(g=null),g&&j.find(la,function(a){return a&&a===g})&&(g=null);g&&(g.__builded&&g.__vm?e=g.__vm:(h=i("#rl-content #rl-settings-subscreen"))&&1===h.length?(e=new g,k=i("<div></div>").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),k.appendTo(h),e.data=f.data(),e.viewModelDom=k,e.__rlSettingsData=g.__rlSettingsData,g.__dom=k,g.__builded=
!0,g.__vm=e,d.applyBindings(e,k[0]),s.delegateRun(e,"onBuild",[k])):c.log("Cannot find sub settings view model position: SettingsSubScreen"),e&&j.defer(function(){if(b.oCurrentSubScreen){s.delegateRun(b.oCurrentSubScreen,"onHide");b.oCurrentSubScreen.viewModelDom.hide()}b.oCurrentSubScreen=e;if(b.oCurrentSubScreen){b.oCurrentSubScreen.viewModelDom.show();s.delegateRun(b.oCurrentSubScreen,"onShow");j.each(b.menu(),function(a){a.selected(e&&e.__rlSettingsData&&a.route===e.__rlSettingsData.Route)})}c.windowResize()}))};
J.prototype.onBuild=function(){j.each(X,function(a){a&&(a.__rlSettingsData&&!j.find(ka,function(b){return b&&b===a}))&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:d.observable(!1),disabled:!!j.find(la,function(b){return b&&b===a})})},this)};J.prototype.routes=function(){var a=j.find(X,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",a={subname:/^(.*)$/,normalize_:function(a,d){d.subname=c.isUnd(d.subname)?
b:c.pString(d.subname);return[d.subname]}};return[["{subname}/",a],["{subname}",a],["",a]]};j.extend(ea.prototype,w.prototype);ea.prototype.onShow=function(){f.setTitle("")};j.extend(fa.prototype,J.prototype);fa.prototype.onShow=function(){f.setTitle("")};j.extend(u.prototype,pa.prototype);u.prototype.oSettings=null;u.prototype.oLink=null;u.prototype.download=function(a){C?this.iframe.attr("src",a):h.open(a)};u.prototype.link=function(){null===this.oLink&&(this.oLink=new n);return this.oLink};u.prototype.local=
function(){null===this.oLocal&&(this.oLocal=new O);return this.oLocal};u.prototype.settingsGet=function(a){null===this.oSettings&&(this.oSettings=c.isNormal(W)?W:{});return c.isUnd(this.oSettings[a])?null:this.oSettings[a]};u.prototype.settingsSet=function(a,b){null===this.oSettings&&(this.oSettings=c.isNormal(W)?W:{});this.oSettings[a]=b};u.prototype.setTitle=function(a){a=(0<a.length?a+" - ":"")+this.settingsGet("Title")||"";a!==h.document.title&&(h.document.title=a)};u.prototype.loginAndLogoutReload=
function(a,b){var d=c.pString(this.settingsGet("CustomLogoutLink")),g=!!this.settingsGet("InIframe"),a=c.isUnd(a)?!1:!!a,b=c.isUnd(b)?!1:!!b;a&&(b&&h.close)&&h.close();a&&""!==d&&h.location.href!==d?j.defer(function(){g&&h.parent?h.parent.location.href=d:h.location.href=d}):(s.routeOff(),s.setHash(f.link().root(),!0),s.routeOff(),j.defer(function(){g&&h.parent?h.parent.location.reload():h.location.reload()}))};u.prototype.getAutocomplete=function(a,b,c){c([],a)};u.prototype.bootstart=function(){c.initOnStartOrLangChange(function(){c.initNotificationLanguage()},
null);j.delay(function(){c.windowResize()},1E3)};j.extend(v.prototype,u.prototype);v.prototype.oData=null;v.prototype.oRemote=null;v.prototype.oCache=null;v.prototype.data=function(){null===this.oData&&(this.oData=new da);return this.oData};v.prototype.remote=function(){null===this.oRemote&&(this.oRemote=new p);return this.oRemote};v.prototype.cache=function(){null===this.oCache&&(this.oCache=new sa);return this.oCache};v.prototype.reloadDomainList=function(){f.data().domainsLoading(!0);f.remote().domainList(function(a,
b){f.data().domainsLoading(!1);if(g.StorageResultType.Success===a&&b&&b.Result){var c=j.map(b.Result,function(a,b){return{name:b,disabled:d.observable(!a),deleteAccess:d.observable(!1)}},this);f.data().domains(c)}})};v.prototype.reloadPluginList=function(){f.data().pluginsLoading(!0);f.remote().pluginList(function(a,b){f.data().pluginsLoading(!1);if(g.StorageResultType.Success===a&&b&&b.Result){var c=j.map(b.Result,function(a){return{name:a.Name,disabled:d.observable(!a.Enabled),configured:d.observable(!!a.Configured)}},
this);f.data().plugins(c)}})};v.prototype.reloadPackagesList=function(){f.data().packagesLoading(!0);f.data().packagesReal(!0);f.remote().packagesList(function(a,b){f.data().packagesLoading(!1);if(g.StorageResultType.Success===a&&b&&b.Result){f.data().packagesReal(!!b.Result.Real);f.data().packagesMainUpdatable(!!b.Result.MainUpdatable);var e=[],h={};j.each(f.data().packages(),function(a){a&&a.loading()&&(h[a.file]=a)});c.isArray(b.Result.List)&&(e=j.map(b.Result.List,function(a){a.loading=d.observable(!c.isUnd(h[a.file]));
return a},this));f.data().packages(e)}else f.data().packagesReal(!1)})};v.prototype.reloadLicensing=function(a){a=c.isUnd(a)?!1:!!a;f.data().licensingProcess(!0);f.data().licenseError("");f.remote().licensing(function(a,d){f.data().licensingProcess(!1);g.StorageResultType.Success===a&&d&&d.Result&&c.isNormal(d.Result.Expired)?(f.data().licenseValid(!0),f.data().licenseExpired(c.pInt(d.Result.Expired)),f.data().licenseError(""),f.data().licensing(!0)):d&&d.ErrorCode&&-1<c.inArray(c.pInt(d.ErrorCode),
[g.Notification.LicensingServerIsUnavailable,g.Notification.LicensingExpired])?(f.data().licenseError(c.getNotification(c.pInt(d.ErrorCode))),f.data().licensing(!0)):g.StorageResultType.Abort===a?(f.data().licenseError(c.getNotification(g.Notification.LicensingServerIsUnavailable)),f.data().licensing(!0)):f.data().licensing(!1)},a)};v.prototype.bootstart=function(){u.prototype.bootstart.call(this);f.data().populateDataOnStart();s.hideLoading();this.settingsGet("Auth")?s.startScreens([fa]):s.startScreens([ea]);
h.SimplePace&&h.SimplePace.set(100)};f=new v;S.addClass(C?"mobile":"no-mobile");G.keydown(c.killCtrlAandS).keyup(c.killCtrlAandS);G.unload(function(){ga=!0});h.rl=h.rl||{};h.rl.addHook=o.addHook;h.rl.settingsGet=o.mainSettingsGet;h.rl.remoteRequest=o.remoteRequest;h.rl.pluginSettingsGet=o.settingsGet;h.rl.addSettingsViewModel=c.addSettingsViewModel;h.rl.createCommand=c.createCommand;h.rl.EmailModel=r;h.rl.Enums=g;h.__RLBOOT=function(a){i(function(){h.rainloopTEMPLATES&&h.rainloopTEMPLATES[0]?(i("#rl-templates").html(h.rainloopTEMPLATES[0]),
h.setInterval(function(){ia(!ia())},6E4),j.delay(function(){h.rainloopAppData={};h.rainloopI18N={};h.rainloopTEMPLATES={};s.setBoot(f).bootstart()},50)):a(!1);h.__RLBOOT=null})};h.SimplePace&&h.SimplePace.add(10)})(window,jQuery,ko,crossroads,hasher,_);