(function(h,j,e,Ta,P,da,ua,i){function C(){this.sBase="#/";this.sCdnStaticDomain=f.settingsGet("CdnStaticDomain");this.sVersion=f.settingsGet("Version");this.sSpecSuffix=f.settingsGet("AuthAccountHash")||"0";this.sServer=(f.settingsGet("IndexFile")||"./")+"?";this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function u(a,b,c,k){this.bIe=!!/msie/.test(navigator.userAgent.toLowerCase());this.oOptions= k=j.extend({DisableHtml:!1,onSwitch:!1,LangSwitcherConferm:"EDITOR_TEXT_SWITCHER_CONFIRM",LangSwitcherTextLabel:"EDITOR_SWITCHER_TEXT_LABEL",LangSwitcherHtmlLabel:"EDITOR_SWITCHER_HTML_LABEL"},d.isUnd(k)?{}:k);this.bOnlyPlain=!!this.oOptions.DisableHtml;this.fOnSwitch=this.oOptions.onSwitch;this.textarea=j(a).empty().addClass("editorTextArea");this.htmlarea=j(b).empty().addClass("editorHtmlArea").prop("contentEditable","true");this.toolbar=j(c).empty().addClass("editorToolbar");u.htmlInitEditor.apply(this); u.htmlInitToolbar.apply(this);u.htmlAttachEditorEvents.apply(this);this.bOnlyPlain&&this.toolbar.hide()}function M(a,b,c,k,f){this.list=a;this.selectedItem=b;this.selectedItem.extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]});this.oContentScrollable=this.oContentVisible=null;this.sItemSelector=c;this.sItemSelectedSelector=k;this.sItemCheckedSelector=f;this.sLastUid="";this.oCallbacks={};this.iSelectTimer=0;this.bUseKeyboard=!0;this.emptyFunction=function(){}; this.useItemSelectCallback=!0;this.throttleSelection=!1;this.selectedItem.subscribe(function(a){this.useItemSelectCallback&&(this.throttleSelection?(this.throttleSelection=!1,this.selectItemCallbacksThrottle(a)):this.selectItemCallbacks(a))},this);var e=this,g=[],l=null;this.list.subscribe(function(){var a=this,b=this.list();d.isArray(b)&&i.each(b,function(b){b.checked()&&g.push(a.getItemUid(b));null===l&&b.selected()&&(l=a.getItemUid(b))})},this,"beforeChange");this.list.subscribe(function(a){this.useItemSelectCallback= !1;this.selectedItem(null);if(d.isArray(a)){var b=this,c=g.length;i.each(a,function(a){0=e||g-2<=e)k+=2;l(e);c=b=e}for(;0=c)l(c, !0),k--;else if(0>=b)break;3===b?l(2,!1):3c&&l(Math.round((g+c)/2),!0,"...");1c&&l(g,!0)}return f},this);this.checkAll=e.computed({read:function(){return 0c},this);this.hasMessages=e.computed(function(){return 0'),c.after(k),c.remove();k&&k[0]&&k.attr("data-href",e).attr("data-theme",b[0]).text(b[1]);a.themeTrigger(g.SaveSettingsStep.TrueResult)}}).always(function(){a.iTimer=h.setTimeout(function(){a.themeTrigger(g.SaveSettingsStep.Idle)},1E3);a.oLastAjax=null}));f.remote().saveSettings(null,{Theme:b})},this)}function Pa(){d.initDataConstructorBySettings(this)}function U(){d.initDataConstructorBySettings(this);var a=function(a){return function(){var b= f.cache().getFolderFromCacheList(a());b&&b.type(g.FolderType.User)}},b=function(a){return function(b){(b=f.cache().getFolderFromCacheList(b))&&b.type(a)}};this.devPassword=this.devLogin=this.devEmail="";this.accountEmail=e.observable("");this.accountLogin=e.observable("");this.projectHash=e.observable("");this.threading=e.observable(!1);this.lastFoldersHash="";this.remoteChangePassword=this.remoteSuggestions=!1;this.sentFolder=e.observable("");this.draftFolder=e.observable("");this.spamFolder=e.observable(""); this.trashFolder=e.observable("");this.sentFolder.subscribe(a(this.sentFolder),this,"beforeChange");this.draftFolder.subscribe(a(this.draftFolder),this,"beforeChange");this.spamFolder.subscribe(a(this.spamFolder),this,"beforeChange");this.trashFolder.subscribe(a(this.trashFolder),this,"beforeChange");this.sentFolder.subscribe(b(g.FolderType.SentItems),this);this.draftFolder.subscribe(b(g.FolderType.Draft),this);this.spamFolder.subscribe(b(g.FolderType.Spam),this);this.trashFolder.subscribe(b(g.FolderType.Trash), this);this.draftFolderNotEnabled=e.computed(function(){return""===this.draftFolder()||n.Values.UnuseOptionValue===this.draftFolder()},this);this.displayName=e.observable("");this.signature=e.observable("");this.replyTo=e.observable("");this.accounts=e.observableArray([]);this.accountsLoading=e.observable(!1).extend({throttle:100});this.identities=e.observableArray([]);this.identitiesLoading=e.observable(!1).extend({throttle:100});this.namespace="";this.folderList=e.observableArray([]);this.foldersListError= e.observable("");this.foldersLoading=e.observable(!1);this.foldersCreating=e.observable(!1);this.foldersDeleting=e.observable(!1);this.foldersRenaming=e.observable(!1);this.currentFolder=e.observable(null).extend({toggleSubscribe:[null,function(a){a&&a.selected(!1)},function(a){a&&a.selected(!0)}]});this.currentFolderFullNameRaw=e.computed(function(){return this.currentFolder()?this.currentFolder().fullNameRaw:""},this);this.currentFolderFullName=e.computed(function(){return this.currentFolder()? this.currentFolder().fullName:""},this);this.currentFolderFullNameHash=e.computed(function(){return this.currentFolder()?this.currentFolder().fullNameHash:""},this);this.currentFolderName=e.computed(function(){return this.currentFolder()?this.currentFolder().name():""},this);this.folderListSystemNames=e.computed(function(){var a=["INBOX"],b=this.folderList(),f=this.sentFolder(),e=this.draftFolder(),g=this.spamFolder(),l=this.trashFolder();d.isArray(b)&&0').appendTo("body");R.on("error",function(a){f&& (a&&a.originalEvent&&a.originalEvent.message&&-1===d.inArray(a.originalEvent.message,["Script error.","Uncaught Error: Error calling method on NPObject."]))&&f.remote().jsError(d.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",Q.attr("class"),d.microtime()-m.now)})}function B(){K.call(this);this.oCache=this.oRemote=this.oData=null;this.iSuggestionsLimit=d.pInt(this.settingsGet("SuggestionsLimit"));this.iSuggestionsLimit= 0===this.iSuggestionsLimit?20:this.iSuggestionsLimit;this.quotaDebounce=i.debounce(this.quota,3E4)}var n={},g={},v={},d={},y={},ma={},m={},V={settings:[],"settings-removed":[],"settings-disabled":[]},o=null,Ga=h.rainloopAppData||{},Ra=h.rainloopI18N||{},Q=j("html"),R=j(h),Ha=j(h.document),na=h.Notification&&h.Notification.requestPermission?h.Notification:null,f=null;m.now=(new Date).getTime();m.minuteTick=e.observable(!0);m.fiveMinuteTick=e.observable(!0);m.langChangeTick=e.observable(!0);m.iAjaxErrorCount= 0;m.iTokenErrorCount=0;m.iMessageBodyCacheCount=0;m.bUnload=!1;m.sUserAgent=(navigator.userAgent||"").toLowerCase();m.bIsiOSDevice=-1/g,">").replace(/"/g,""").replace(/'/g,"'"):""};d.splitPlainText=function(a,b){for(var c="",k="",f=a,e=0,g=0,b=d.isUnd(b)?100:b;f.length>b;)k=f.substring(0,b),e=k.lastIndexOf(" "),g=k.lastIndexOf("\n"),-1!==g&&(e=g),-1===e&&(e=b),c+=k.substring(0,e)+"\n",f=f.substring(e+1);return c+f};var Ia= {};d.timeOutAction=function(a,b,c){d.isUnd(Ia[a])&&(Ia[a]=0);h.clearTimeout(Ia[a]);Ia[a]=h.setTimeout(b,c)};var Sa={};d.timeOutActionSecond=function(a,b,c){Sa[a]||(Sa[a]=h.setTimeout(function(){b();Sa[a]=0},c))};var S=!1;d.audio=function(a,b){if(!1===S)if(m.bIsiOSDevice)S=null;else{var c=!1,d=!1,f=h.Audio?new h.Audio:null;f&&f.canPlayType&&f.play?((c=""!==f.canPlayType('audio/mpeg; codecs="mp3"'))||(d=""!==f.canPlayType('audio/ogg; codecs="vorbis"')),c||d?(S=f,S.preload="none",S.loop=!1,S.autoplay= !1,S.muted=!1,S.src=c?a:b):S=null):S=null}return S};d.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1};d.i18n=function(a,b,c){var k="",a=d.isUnd(Ra[a])?d.isUnd(c)?a:c:Ra[a];if(!d.isUnd(b)&&!d.isNull(b))for(k in b)d.hos(b,k)&&(a=a.replace("%"+k+"%",b[k]));return a};d.i18nToNode=function(a){i.defer(function(){j(".i18n",a).each(function(){var a=j(this),c="";(c=a.data("i18n-text"))?a.text(d.i18n(c)):((c=a.data("i18n-html"))&&a.html(d.i18n(c)),(c=a.data("i18n-placeholder"))&& a.attr("placeholder",d.i18n(c)))})})};d.i18nToDoc=function(){h.rainloopI18N&&(Ra=h.rainloopI18N||{},d.i18nToNode(Ha),m.langChangeTick(!m.langChangeTick()));h.rainloopI18N={}};d.initOnStartOrLangChange=function(a,b,c){a&&a.call(b);c?m.langChangeTick.subscribe(function(){a&&a.call(b);c.call(b)}):a&&m.langChangeTick.subscribe(a,b)};d.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)};d.removeInFocus=function(){if(document&&document.activeElement&&document.activeElement.blur){var a=j(document.activeElement);(a.is("input")||a.is("textarea"))&&document.activeElement.blur()}};d.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()};d.replySubjectAdd=function(a,b){var c=null,k=d.trim(b);null!==(c=(new h.RegExp("^"+ a+"[\\s]?\\:(.*)$","gi")).exec(b))&&!d.isUnd(c[1])?k=a+"[2]: "+c[1]:null!==(c=(new h.RegExp("^("+a+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi")).exec(b))&&!d.isUnd(c[1])&&!d.isUnd(c[2])&&!d.isUnd(c[3])?(d.pInt(c[2]),k=c[1]+(d.pInt(c[2])+1)+c[3]):k=a+": "+b;return k};d.roundNumber=function(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)};d.friendlySize=function(a){a=d.pInt(a);return 1073741824<=a?d.roundNumber(a/1073741824,1)+"GB":1048576<=a?d.roundNumber(a/1048576,1)+"MB":1024<= a?d.roundNumber(a/1024,0)+"KB":a+"B"};d.log=function(a){h.console&&h.console.log&&h.console.log(a)};d.getNotification=function(a){a=d.pInt(a);return d.isUnd(v[a])?"":v[a]};d.initNotificationLanguage=function(){v[g.Notification.InvalidToken]=d.i18n("NOTIFICATIONS/INVALID_TOKEN");v[g.Notification.AuthError]=d.i18n("NOTIFICATIONS/AUTH_ERROR");v[g.Notification.AccessError]=d.i18n("NOTIFICATIONS/ACCESS_ERROR");v[g.Notification.ConnectionError]=d.i18n("NOTIFICATIONS/CONNECTION_ERROR");v[g.Notification.CaptchaError]= d.i18n("NOTIFICATIONS/CAPTCHA_ERROR");v[g.Notification.SocialFacebookLoginAccessDisable]=d.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE");v[g.Notification.SocialTwitterLoginAccessDisable]=d.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE");v[g.Notification.SocialGoogleLoginAccessDisable]=d.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE");v[g.Notification.DomainNotAllowed]=d.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED");v[g.Notification.AccountNotAllowed]=d.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED"); v[g.Notification.CantGetMessageList]=d.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST");v[g.Notification.CantGetMessage]=d.i18n("NOTIFICATIONS/CANT_GET_MESSAGE");v[g.Notification.CantDeleteMessage]=d.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE");v[g.Notification.CantMoveMessage]=d.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE");v[g.Notification.CantSaveMessage]=d.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE");v[g.Notification.CantSendMessage]=d.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE");v[g.Notification.InvalidRecipients]= d.i18n("NOTIFICATIONS/INVALID_RECIPIENTS");v[g.Notification.CantCreateFolder]=d.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER");v[g.Notification.CantRenameFolder]=d.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER");v[g.Notification.CantDeleteFolder]=d.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER");v[g.Notification.CantDeleteNonEmptyFolder]=d.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER");v[g.Notification.CantSubscribeFolder]=d.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER");v[g.Notification.CantUnsubscribeFolder]=d.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER"); v[g.Notification.CantSaveSettings]=d.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS");v[g.Notification.CantSavePluginSettings]=d.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS");v[g.Notification.DomainAlreadyExists]=d.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS");v[g.Notification.CantInstallPackage]=d.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE");v[g.Notification.CantDeletePackage]=d.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE");v[g.Notification.InvalidPluginPackage]=d.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE"); v[g.Notification.UnsupportedPluginPackage]=d.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE");v[g.Notification.LicensingServerIsUnavailable]=d.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE");v[g.Notification.LicensingExpired]=d.i18n("NOTIFICATIONS/LICENSING_EXPIRED");v[g.Notification.LicensingBanned]=d.i18n("NOTIFICATIONS/LICENSING_BANNED");v[g.Notification.DemoSendMessageError]=d.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR");v[g.Notification.AccountAlreadyExists]=d.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS"); v[g.Notification.MailServerError]=d.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR");v[g.Notification.UnknownNotification]=d.i18n("NOTIFICATIONS/UNKNOWN_ERROR");v[g.Notification.UnknownError]=d.i18n("NOTIFICATIONS/UNKNOWN_ERROR")};d.getUploadErrorDescByCode=function(a){var b="";switch(d.pInt(a)){case g.UploadErrorCode.FileIsTooBig:b=d.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case g.UploadErrorCode.FilePartiallyUploaded:b=d.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case g.UploadErrorCode.FileNoUploaded:b= d.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case g.UploadErrorCode.MissingTempFolder:b=d.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case g.UploadErrorCode.FileOnSaveingError:b=d.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case g.UploadErrorCode.FileType:b=d.i18n("UPLOAD/ERROR_FILE_TYPE");break;default:b=d.i18n("UPLOAD/ERROR_UNKNOWN")}return b};d.killCtrlAandS=function(a){if(a=a||h.event){var b=a.target||a.srcElement,c=a.keyCode||a.which;if(a.ctrlKey&&c===g.EventKeyCode.S)a.preventDefault();else if((!b|| !b.tagName||!b.tagName.match(/INPUT|TEXTAREA/i))&&a.ctrlKey&&c===g.EventKeyCode.A)h.getSelection?h.getSelection().removeAllRanges():h.document.selection&&h.document.selection.clear&&h.document.selection.clear(),a.preventDefault()}};d.createCommand=function(a,b,c){var k=b?function(){k.canExecute&&k.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments));return!1}:function(){};k.enabled=e.observable(!0);c=d.isUnd(c)?!0:c;k.canExecute=d.isFunc(c)?e.computed(function(){return k.enabled()&&c.call(a)}): e.computed(function(){return k.enabled()&&!!c});return k};d.initDataConstructorBySettings=function(a){a.editorDefaultType=e.observable(g.EditorDefaultType.Html);a.showImages=e.observable(!1);a.interfaceAnimation=e.observable(g.InterfaceAnimation.Full);m.sAnimationType=g.InterfaceAnimation.Full;a.allowThemes=e.observable(!0);a.allowCustomLogin=e.observable(!1);a.allowLanguagesOnSettings=e.observable(!0);a.allowLanguagesOnLogin=e.observable(!0);a.desktopNotifications=e.observable(!1);a.useThreads=e.observable(!0); a.replySameFolder=e.observable(!0);a.usePreviewPane=e.observable(!0);a.useCheckboxesInList=e.observable(!0);a.interfaceAnimation.subscribe(function(a){if(m.bMobileDevice||a===g.InterfaceAnimation.None)Q.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),m.sAnimationType=g.InterfaceAnimation.None;else switch(a){case g.InterfaceAnimation.Full:Q.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full");m.sAnimationType=a;break;case g.InterfaceAnimation.Normal:Q.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"), m.sAnimationType=a}});a.interfaceAnimation.valueHasMutated();a.desktopNotificationsPermisions=e.computed(function(){a.desktopNotifications();var b=g.DesktopNotifications.NotSupported;if(na&&na.permission)switch(na.permission.toLowerCase()){case "granted":b=g.DesktopNotifications.Allowed;break;case "denied":b=g.DesktopNotifications.Denied;break;case "default":b=g.DesktopNotifications.NotAllowed}else h.webkitNotifications&&h.webkitNotifications.checkPermission&&(b=h.webkitNotifications.checkPermission()); return b});a.useDesktopNotifications=e.computed({read:function(){return a.desktopNotifications()&&g.DesktopNotifications.Allowed===a.desktopNotificationsPermisions()},write:function(b){b?(b=a.desktopNotificationsPermisions(),g.DesktopNotifications.Allowed===b?a.desktopNotifications(!0):g.DesktopNotifications.NotAllowed===b?na.requestPermission(function(){a.desktopNotifications.valueHasMutated();g.DesktopNotifications.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=e.observable("");a.languages=e.observableArray([]);a.mainLanguage=e.computed({read:a.language,write:function(b){b!==a.language()?-1=a.diff(c,"hours")?k:a.format("L")===c.format("L")?d.i18n("MESSAGE_LIST/TODAY_AT",{TIME:c.format("LT")}):a.clone().subtract("days",1).format("L")===c.format("L")?d.i18n("MESSAGE_LIST/YESTERDAY_IN", {TIME:c.format("LT")}):a.year()===c.year()?c.format("D MMM."):c.format("LL")},a)};d.isFolderExpanded=function(a){var b=f.local().get(g.ClientSideKeyName.ExpandedFolders);return i.isArray(b)&&-1!==i.indexOf(b,a)};d.setExpandedFolder=function(a,b){var c=f.local().get(g.ClientSideKeyName.ExpandedFolders);i.isArray(c)||(c=[]);b?(c.push(a),c=i.uniq(c)):c=i.without(c,a);f.local().set(g.ClientSideKeyName.ExpandedFolders,c)};d.initLayoutResizer=function(a,b,c,d,e,g,w,l){var d=d||300,e=e||500,g=g||e-d/2,w= w||300,h=0,q=j(a),gb=j(b),r=j(c),b=f.local().get(l)||g,H=function(a,b,c){if(b||c)a=r.width(),b=b?100*(b.size.width/a):null,null===b&&c&&(b=100*(q.width()/a)),null!==b&&(q.css({width:"",height:"",right:""+(100-b)+"%"}),gb.css({width:"",height:"",left:""+b+"%"}))};b&&q.width(b);h=r.width()-w;h=e>h?h:e;q.resizable({minWidth:d,maxWidth:h,handles:"e",resize:H,stop:H});H(null,null,!0);R.resize(i.throttle(function(b,c){c&&(c.element&&c.element[0].id&&"#"+c.element[0].id===""+a)&&(h=r.width()-w,h=e>h?h:e, q.resizable("option","maxWidth",h),c.size&&c.size.width&&f.local().set(l,c.size.width),H(null,null,!0))},400))};d.initBlockquoteSwitcher=function(a){if(a){var b=j("blockquote:not(.rl-bq-switcher)",a).filter(function(){return 0===j(this).parent().closest("blockquote",a).length});b&&0').insertBefore(a).click(function(){a.toggleClass("hidden-bq"); d.windowResize()}).after("
").before("
")})}};d.removeBlockquoteSwitcher=function(a){a&&(j(a).find("blockquote.rl-bq-switcher").each(function(){j(this).removeClass("rl-bq-switcher hidden-bq")}),j(a).find(".rlBlockquoteSwitcher").each(function(){j(this).remove()}))};d.extendAsViewModel=function(a,b){b&&(b.__name=a,y.regViewModelHook(a,b),i.extend(b.prototype,D.prototype))};d.addSettingsViewModel=function(a,b,c,d,f){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!f};V.settings.push(a)}; d.removeSettingsViewModel=function(a){V["settings-removed"].push(a)};d.disableSettingsViewModel=function(a){V["settings-disabled"].push(a)};d.convertThemeName=function(a){return d.trim(a.replace(/[^a-zA-Z]/g," ").replace(/([A-Z])/g," $1").replace(/[\s]+/g," "))};d.quoteName=function(a){return a.replace(/["]/g,'\\"')};d.microtime=function(){return(new Date).getTime()};d.convertLangName=function(a){return d.i18n("LANGS_NAMES/LANG_"+a.toUpperCase().replace(/[^a-zA-Z0-9]+/,"_"),null,a)};d.fakeMd5=function(a){for(var b= "",a=d.isUnd(a)?32:d.pInt(a);b.length/g,">").replace(/")};d.draggeblePlace=function(){return j('
 
').appendTo("#rl-hidden")};d.defautOptionsAfterRender=function(a, b){b&&!d.isUnd(b.disable)&&e.applyBindingsToNode(a,{disable:b.disable},b)};d.windowPopupKnockout=function(a,b,c,k){var f=null,e=h.open(""),g="__OpenerApplyBindingsUid"+d.fakeMd5()+"__",l=j("#"+b);h[g]=function(){if(e&&e.document.body&&l&&l[0]){var b=j(e.document.body);j("#rl-content",b).html(l.html());j("html",e.document).addClass("external "+j("html").attr("class"));d.i18nToNode(b);F.prototype.applyExternal(a,j("#rl-content",b)[0]);h[g]=null;k(e)}};e.document.open();e.document.write(''+ d.encodeHtml(c)+'
');e.document.close();f=e.document.createElement("script");f.type="text/javascript";f.innerHTML="if(window&&window.opener&&window.opener['"+g+"']){window.opener['"+g+"']();window.opener['"+g+"']=null}";e.document.getElementsByTagName("head")[0].appendChild(f)};d.settingsSaveHelperFunction=function(a,b,c,k){c=c||null;k=d.isUnd(k)?1E3:d.pInt(k);return function(d,f,e,l,h){b.call(c,f&&f.Result?g.SaveSettingsStep.TrueResult: g.SaveSettingsStep.FalseResult);a&&a.call(c,d,f,e,l,h);i.delay(function(){b.call(c,g.SaveSettingsStep.Idle)},k)}};d.settingsSaveHelperSimpleFunction=function(a,b){return d.settingsSaveHelperFunction(null,a,b,1E3)};d.resizeAndCrop=function(a,b,c){var d=new Image;d.onload=function(){var a=[0,0],d=document.createElement("canvas"),k=d.getContext("2d");d.width=b;d.height=b;a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width];k.fillStyle="#fff";k.fillRect(0,0,b,b);k.drawImage(this, a[0]/2,a[1]/2,this.width-a[0],this.height-a[1],0,0,b,b);c(d.toDataURL("image/jpeg"))};d.src=a};ma={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",urlsafe_encode:function(a){return ma.encode(a).replace(/[+]/g,"-").replace(/[\/]/g,"_").replace(/[=]/g,".")},encode:function(a){for(var b="",c,d,f,e,g,l,i=0,a=ma._utf8_encode(a);i>2,c=(c&3)<<4|d>>4,g=(d&15)<<2|f>>6,l=f&63,isNaN(d)?g=l=64:isNaN(f)&&(l= 64),b=b+this._keyStr.charAt(e)+this._keyStr.charAt(c)+this._keyStr.charAt(g)+this._keyStr.charAt(l);return b},decode:function(a){for(var b="",c,d,f,e,g,l=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");l>4,d=(d&15)<<4|e>>2,f=(e&3)<<6|g,b+=String.fromCharCode(c),64!==e&&(b+=String.fromCharCode(d)),64!==g&&(b+=String.fromCharCode(f));return ma._utf8_decode(b)}, _utf8_encode:function(a){for(var a=a.replace(/\r\n/g,"\n"),b="",c=0,d=a.length,f=0;cf?b+=String.fromCharCode(f):(127f?b+=String.fromCharCode(f>>6|192):(b+=String.fromCharCode(f>>12|224),b+=String.fromCharCode(f>>6&63|128)),b+=String.fromCharCode(f&63|128));return b},_utf8_decode:function(a){for(var b="",c=0,d=0,f=0,e=0;cd?(b+=String.fromCharCode(d),c++):191d?(f=a.charCodeAt(c+1),b+=String.fromCharCode((d&31)<<6|f&63),c+= 2):(f=a.charCodeAt(c+1),e=a.charCodeAt(c+2),b+=String.fromCharCode((d&15)<<12|(f&63)<<6|e&63),c+=3);return b}};e.bindingHandlers.tooltip={init:function(a,b){if(!m.bMobileDevice){var c=j(a).data("tooltip-class")||"",k=j(a).data("tooltip-placement")||"top";j(a).tooltip({delay:{show:500,hide:100},html:!0,placement:k,trigger:"hover",title:function(){return''+d.i18n(e.utils.unwrapObservable(b()))+""}})}}};e.bindingHandlers.tooltip2={init:function(a,b){var c=j(a).data("tooltip-class")|| "",d=j(a).data("tooltip-placement")||"top";j(a).tooltip({delay:{show:500,hide:100},html:!0,placement:d,title:function(){return''+b()()+""}})}};e.bindingHandlers.dropdown={init:function(a){j(a).closest(".dropdown").on("click",".e-item",function(){j(a).dropdown("toggle")})}};e.bindingHandlers.popover={init:function(a,b){j(a).popover(e.utils.unwrapObservable(b()))}};e.bindingHandlers.resizecrop={init:function(a){j(a).addClass("resizecrop").resizecrop({width:"100", height:"100",wrapperCSS:{"border-radius":"10px"}})},update:function(a,b){b()();j(a).resizecrop({width:"100",height:"100"})}};e.bindingHandlers.onEnter={init:function(a,b,c,d){j(a).on("keypress",function(c){c&&13===h.parseInt(c.keyCode,10)&&(j(a).trigger("change"),b().call(d))})}};e.bindingHandlers.onEsc={init:function(a,b,c,d){j(a).on("keypress",function(c){c&&27===h.parseInt(c.keyCode,10)&&(j(a).trigger("change"),b().call(d))})}};e.bindingHandlers.modal={init:function(a,b){j(a).modal({keyboard:!1, show:e.utils.unwrapObservable(b())}).on("hidden",function(){b()(!1)})},update:function(a,b){var c=e.utils.unwrapObservable(b());j(a).modal(c?"show":"hide");i.delay(function(){j(a).toggleClass("popup-active",c)},1)}};e.bindingHandlers.i18nInit={init:function(a){d.i18nToNode(a)}};e.bindingHandlers.i18nUpdate={update:function(a,b){e.utils.unwrapObservable(b());d.i18nToNode(a)}};e.bindingHandlers.link={update:function(a,b){j(a).attr("href",e.utils.unwrapObservable(b()))}};e.bindingHandlers.title={update:function(a, b){j(a).attr("title",e.utils.unwrapObservable(b()))}};e.bindingHandlers.textF={init:function(a,b){j(a).text(e.utils.unwrapObservable(b()))}};e.bindingHandlers.initDom={init:function(a,b){b()(a)}};e.bindingHandlers.initResizeTrigger={init:function(a,b){var c=e.utils.unwrapObservable(b());j(a).css({height:c[1],"min-height":c[1]})},update:function(a,b){var c=e.utils.unwrapObservable(b()),k=d.pInt(c[1]),f=0,f=j(a).offset().top;0=c.left&&a.pageX<=c.left+k.width()&&(a.pageY>=b-100&&a.pageY<=b&&(b=function(){k.scrollTop(k.scrollTop()+3);d.windowResize()},k.data("timerScroll",h.setInterval(b,10)),b()),a.pageY>=c.top&&a.pageY<=c.top+100))c=function(){k.scrollTop(k.scrollTop()-3);d.windowResize()},k.data("timerScroll",h.setInterval(c,10)),c()})},c.stop=function(){j(k).each(function(){h.clearInterval(j(this).data("timerScroll"));j(this).data("timerScroll",!1)})});c.helper=function(a){return b()(a&&a.target?e.dataFor(a.target): null)};j(a).draggable(c).on("mousedown",function(){d.removeInFocus()})}}};e.bindingHandlers.droppable={init:function(a,b,c){if(!m.bMobileDevice){var d=b(),f=(b=c())&&b.droppableOver?b.droppableOver:null,e=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)}),e&&(b.out=function(a,b){e(a,b)}),j(a).droppable(b))}}};e.bindingHandlers.nano={init:function(a){m.bDisableNanoScroll||j(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1, preventPageScrolling:!0})}};e.bindingHandlers.saveTrigger={init:function(a){j(a).append('  ').addClass("settings-saved-trigger")},update:function(a,b){var c=e.utils.unwrapObservable(b()),d=j(a);switch(c.toString()){case "1":d.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case "0":d.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible"); break;case "-2":d.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:d.find(".animated").hide().end().find(".error,.success").removeClass("visible")}}};e.bindingHandlers.select2={init:function(a,b){var c=0,k=null,g=new h.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),t=new h.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),w=function(){return""},l=function(a){f.getAutocomplete(a.term,a.page,function(b,c){a.callback({more:!!c,results:i.map(b, function(a){var b=a.toLine(!1);return{id:b,text:b,c:a}})})})};j(a).addClass("ko-select2").select2({query:function(a){a&&(0===c?(l(a),c=h.setTimeout(d.emptyFunction,100)):(h.clearInterval(c),c=h.setTimeout(function(){l(a)},100)))},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,d){b=a&&a.c?a.c.select2Result(b):"";return""===b?d(a.text):b},createSearchChoice:function(a,b){return 0===b.length&&g.test(a)?{id:a,text:a}:null},formatNoMatches:w, formatSearching:function(){return d.i18n("SUGGESTIONS/SEARCHING_DESC")},formatInputTooShort:w,formatSelectionTooBig:w,multiple:!0,tokenSeparators:[",",";"],minimumInputLength:2,selectOnBlur:!1,closeOnSelect:!0,openOnEnter:!1});e.utils.domNodeDisposal.addDisposeCallback(a,function(){j(a).select2("destroy")});j(a).on("change",function(){for(var a=j(this).select2("data"),c=0,f=a.length,e=null,g=[];c "+d.trim(a).replace(/\n/gm,"\n> ")+"\n>\n";return a.replace(/\n([> ]+)/gm,function(){return arguments&&1]*>([\s\S]*)<\/div>/gmi,f),a="\n"+d.trim(a)+"\n");return a}return""}, a=d.isUnd(a)?!0:!!a,b=this.toHtmlString().replace(/[\s]+/gm," ").replace(//gmi,"\n").replace(/<\/h\d>/gi,"\n").replace(/<\/p>/gi,"\n\n").replace(/<\/li>/gi,"\n").replace(/<\/td>/gi,"\n").replace(/<\/tr>/gi,"\n").replace(/]*>/gmi,"\n_______________________________\n\n").replace(/]*>/gmi,"").replace(/]*>([\s\S]*)<\/div>/gmi,f).replace(/]*>/gmi,"\n__bq__start__\n").replace(/<\/blockquote>/gmi,"\n__bq__end__\n").replace(/]*>([\s\S]*?)<\/a>/gmi,function(){return arguments&& 1]*>/gm,"").replace(/>/gi,">").replace(/</gi,"<").replace(/&/gi,"&").replace(/&\w{2,6};/gi,"");return(a?d.splitPlainText(b):b).replace(/\n[ \t]+/gm,"\n").replace(/[\n]{3,}/gm,"\n\n").replace(/__bq__start__([\s\S]*)__bq__end__/gm,c).replace(/__bq__start__/gm,"").replace(/__bq__end__/gm,"")};u.prototype.getHtmlFromText=function(){return d.convertPlainTextToHtml(this.textarea.val())};u.prototype.switchToggle=function(){this.isHtml()? this.switchToPlain():this.switchToHtml()};u.prototype.switchToPlain=function(a){var a=d.isUnd(a)?!0:a,b=this.getTextFromHtml(),c=i.bind(function(a){a&&(this.toolbar.addClass("editorHideToolbar"),j(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!1)),this.textarea.val(b),this.textarea.show(),this.htmlarea.hide(),this.fOnSwitch&&this.fOnSwitch(!1))},this);!a||0===d.trim(b).length?c(!0):c(h.confirm(this.oOptions.LangSwitcherConferm))};u.prototype.switcherLinkText=function(a){return a?this.oOptions.LangSwitcherTextLabel: this.oOptions.LangSwitcherHtmlLabel};u.prototype.switchToHtml=function(){this.toolbar.removeClass("editorHideToolbar");j(".editorSwitcher",this.toolbar).text(this.switcherLinkText(!0));this.textarea.val(this.getHtmlFromText());this.updateHtmlArea();this.textarea.hide();this.htmlarea.show();this.fOnSwitch&&this.fOnSwitch(!0)};u.prototype.addButton=function(a,b){var c=this;j("
").addClass("editorToolbarButtom").append(j('').addClass(a)).attr("title", b).click(function(b){d.isUnd(u.htmlFunctions[a])?h.alert(a):u.htmlFunctions[a].apply(c,[j(this),b])}).appendTo(this.toolbar)};u.htmlInitToolbar=function(){if(!this.bOnlyPlain){this.addButton("bold","Bold");this.addButton("italic","Italic");this.addButton("underline","Underline");this.addButton("strikethrough","Strikethrough");this.addButton("removeformat","removeformat");this.addButton("justifyleft","justifyleft");this.addButton("justifycenter","justifycenter");this.addButton("justifyright","justifyright"); this.addButton("horizontalrule","horizontalrule");this.addButton("orderedlist","orderedlist");this.addButton("unorderedlist","unorderedlist");this.addButton("indent","indent");this.addButton("outdent","outdent");this.addButton("forecolor","forecolor");var a=this;j("").addClass("editorSwitcher").text(a.switcherLinkText(!0)).click(function(){a.switchToggle()}).appendTo(a.toolbar)}};u.htmlInitEditor=function(){this.editor=this.htmlarea[0];this.editor.innerHTML=this.textarea.val()};u.htmlAttachEditorEvents= function(){var a=this,b=function(b){if(b=(b&&b.originalEvent?b.originalEvent:b)||h.event){b.stopPropagation();b.preventDefault();var c=null,d=null;if((b=b.files||(b.dataTransfer?b.dataTransfer.files:null))&&1===b.length&&b[0]&&b[0].type&&0===b[0].type.indexOf("image/")){var d=b[0],c=new h.FileReader,f=d;c.onload=function(b){a.insertImage(b.target.result,f.name)};c.readAsDataURL(d)}}a.htmlarea.removeClass("editorDragOver")},c=function(){a.htmlarea.removeClass("editorDragOver")},d=function(b){b.stopPropagation(); b.preventDefault();a.htmlarea.addClass("editorDragOver")},f=function(b){(b=b&&b.clipboardData?b.clipboardData:b&&b.originalEvent&&b.originalEvent.clipboardData?b.originalEvent.clipboardData:null)&&b.items&&i.each(b.items,function(b){if(b&&(b.type&&0===b.type.indexOf("image/"))&&b.getAsFile){var c=null,d=b.getAsFile();d&&(c=new h.FileReader,c.onload=function(b){a.insertImage(b.target.result,d.name)},c.readAsDataURL(d))}})};!this.bOnlyPlain&&(h.File&&h.FileReader&&h.FileList)&&(this.htmlarea.bind("dragover", d),this.htmlarea.bind("dragleave",c),this.htmlarea.bind("drop",b),this.htmlarea.bind("paste",f))};for(var hb=u,ra=[],Ya=[],Y=0,Ja=0,Ka=0,La=0,Ma="",Y=0;256>Y;Y+=85)Ma=Y.toString(16),ra.push(1===Ma.length?"0"+Ma:Ma);La=ra.length;for(Y=0;Y
'),ab=sa.find(".editorFpFonts"), bb=function(){};j.each("Arial;Arial Black;Courier New;Tahoma;Times New Roman;Verdana".split(";"),function(a,b){ab.append(j(''+b+"").click(function(){bb(b)}));ab.append("
")});sa.hide();ib.htmlFontPicker=function(a,b,c){$a||(sa.appendTo(c),$a=!0);bb=b;Za.unbind("click.fpNamespace");h.setTimeout(function(){Za.one("click.fpNamespace",function(){sa.hide()})},500);b=j(a).position();sa.css("top",5+b.top+ j(a).height()+"px").css("left",b.left+"px").show()};var jb=u,cb=j(h.document),db=!1,ta=j('
'),eb=ta.find(".editorCpColors"),fb=function(){};j.each(u.htmlColorPickerColors,function(a,b){eb.append('')});ta.hide();j(".editorCpColor",eb).click(function(a){var b=1,c="#000000",a=j(a.target).css("background-color"), c=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(null!==c){for(delete c[0];3>=b;++b)c[b]=d.pInt(c[b]).toString(16),1===c[b].length&&(c[b]="0"+c[b]);c="#"+c.join("")}else c=a;fb(c)});jb.htmlColorPicker=function(a,b,c){db||(ta.appendTo(c),db=!0);c=j(a).position();fb=b;cb.unbind("click.cpNamespace");h.setTimeout(function(){cb.one("click.cpNamespace",function(){ta.hide()})},100);ta.css("top",5+c.top+j(a).height()+"px").css("left",c.left+"px").show()};u.htmlFunctions={bold:function(){this.ec("bold")}, italic:function(){this.ec("italic")},underline:function(){this.ec("underline")},strikethrough:function(){this.ec("strikethrough")},indent:function(){this.ec("indent")},outdent:function(){this.ec("outdent")},justifyleft:function(){this.ec("justifyLeft")},justifycenter:function(){this.ec("justifyCenter")},justifyright:function(){this.ec("justifyRight")},horizontalrule:function(){this.ec("insertHorizontalRule",!1,"ht")},removeformat:function(){this.ec("removeFormat")},orderedlist:function(){this.ec("insertorderedlist")}, unorderedlist:function(){this.ec("insertunorderedlist")},forecolor:function(a){u.htmlColorPicker(a,i.bind(function(a){this.setcolor("forecolor",a)},this),this.toolbar)},backcolor:function(a){u.htmlColorPicker(a,i.bind(function(a){this.setcolor("backcolor",a)},this),this.toolbar)},fontname:function(a){u.htmlFontPicker(a,i.bind(function(a){this.ec("fontname",!1,a)},this),this.toolbar)}};M.prototype.selectItemCallbacks=function(a){(this.oCallbacks.onItemSelect||this.emptyFunction)(a)};M.prototype.init= function(a,b){this.oContentVisible=a;this.oContentScrollable=b;if(this.oContentVisible&&this.oContentScrollable){var c=this;j(this.oContentVisible).on("click",this.sItemSelector,function(a){c.actionClick(e.dataFor(this),a)}).on("click",this.sItemCheckedSelector,function(a){var b=e.dataFor(this);b&&(a&&a.shiftKey?c.actionClick(b,a):(c.sLastUid=c.getItemUid(b),b.selected()?(b.checked(!1),c.selectedItem(null)):b.checked(!b.checked())))});j(h.document).on("keydown",function(a){var b=!0;if(a&&c.bUseKeyboard&& !d.inFocus())if(-1d?0:d;w=l[d];break}}else if(g.EventKeyCode.Down===a||g.EventKeyCode.Insert===a||g.EventKeyCode.Home=== a||g.EventKeyCode.PageUp===a)w=l[0];else if(g.EventKeyCode.Up===a||g.EventKeyCode.End===a||g.EventKeyCode.PageDown===a)w=l[l.length-1];w?(q&&(b?(g.EventKeyCode.Up===a||g.EventKeyCode.Down===a)&&q.checked(!q.checked()):g.EventKeyCode.Insert===a&&q.checked(!q.checked())),this.throttleSelection=!0,this.selectedItem(w),this.throttleSelection=!0,0!==this.iSelectTimer?(h.clearTimeout(this.iSelectTimer),this.iSelectTimer=h.setTimeout(function(){c.iSelectTimer=0;c.actionClick(w)},1E3)):(this.iSelectTimer= h.setTimeout(function(){c.iSelectTimer=0},200),this.actionClick(w)),this.scrollToSelected()):q&&(b&&(g.EventKeyCode.Up===a||g.EventKeyCode.Down===a)?q.checked(!q.checked()):g.EventKeyCode.Insert===a&&q.checked(!q.checked()))};M.prototype.scrollToSelected=function(){if(!this.oContentVisible||!this.oContentScrollable)return!1;var a=j(this.sItemSelectedSelector,this.oContentScrollable),b=a.position(),c=this.oContentVisible.height(),a=a.outerHeight();return b&&(0>b.top||b.top+a>c)?(0>b.top?this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+ b.top-20):this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop()+b.top-c+a+20),!0):!1};M.prototype.eventClickFunction=function(a,b){var c=this.getItemUid(a),d=0,f=0,e=null,g="",l=!1,i=!1,h=[],j=!1;if(b&&b.shiftKey&&""!==c&&""!==this.sLastUid&&c!==this.sLastUid){h=this.list();j=a.checked();d=0;for(f=h.length;d").addClass("rl-view-model").addClass("RL-"+c.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+c.viewModelTemplate()+'"}, i18nInit: true'),t.appendTo(g),c.viewModelDom=t,a.__dom=t,"Popups"===k&&(c.cancelCommand=c.closeCommand=d.createCommand(c,function(){o.hideScreenPopup(a)})),y.runHook("view-model-pre-build",[a.__name,c,t]),e.applyBindings(c,t[0]),this.delegateRun(c,"onBuild",[t]),y.runHook("view-model-post-build",[a.__name,c,t])):d.log("Cannot find view model position: "+ k)}return a?a.__vm:null};F.prototype.applyExternal=function(a,b){a&&b&&e.applyBindings(a,b)};F.prototype.hideScreenPopup=function(a){a&&(a.__vm&&a.__dom)&&(a.__dom.hide(),a.__vm.modalVisibility(!1),this.delegateRun(a.__vm,"onHide"),this.popupVisibility(!1),i.defer(function(){a.__dom.find(".ko-select2").select2("close")}))};F.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), y.runHook("view-model-on-show",[a.__name,a.__vm,b||[]])))};F.prototype.screenOnRoute=function(a,b){var c=this,f=null,e=null;""===d.pString(a)&&(a=this.sDefaultScreenName);if(""!==a){f=this.screen(a);if(!f&&(f=this.screen(this.sDefaultScreenName)))b=a+"/"+b,a=this.sDefaultScreenName;f&&f.__started&&(f.__builded||(f.__builded=!0,d.isNonEmptyArray(f.viewModels())&&i.each(f.viewModels(),function(a){this.buildViewModel(a,f)},this),this.delegateRun(f,"onBuild")),i.defer(function(){if(c.oCurrentScreen){c.delegateRun(c.oCurrentScreen, "onHide");d.isNonEmptyArray(c.oCurrentScreen.viewModels())&&i.each(c.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.hide();a.__vm.viewModelVisibility(false);c.delegateRun(a.__vm,"onHide")}})}c.oCurrentScreen=f;if(c.oCurrentScreen){c.delegateRun(c.oCurrentScreen,"onShow");y.runHook("screen-on-show",[c.oCurrentScreen.screenName(),c.oCurrentScreen]);d.isNonEmptyArray(c.oCurrentScreen.viewModels())&&i.each(c.oCurrentScreen.viewModels(),function(a){if(a.__vm&& a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.show();a.__vm.viewModelVisibility(true);c.delegateRun(a.__vm,"onShow");y.runHook("view-model-on-show",[a.__name,a.__vm])}},c)}(e=f.__cross())&&e.parse(b)}))}};F.prototype.startScreens=function(a){i.each(a,function(a){var c=(a=new a)?a.screenName():"";a&&""!==c&&(""===this.sDefaultScreenName&&(this.sDefaultScreenName=c),this.oScreens[c]=a)},this);i.each(this.oScreens,function(a){a&&(!a.__started&&a.__start)&&(a.__started=!0,a.__start(),y.runHook("screen-pre-start", [a.screenName(),a]),this.delegateRun(a,"onStart"),y.runHook("screen-post-start",[a.screenName(),a]))},this);a=Ta.create();a.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,i.bind(this.screenOnRoute,this));P.initialized.add(a.parse,a);P.changed.add(a.parse,a);P.init()};F.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=d.isUnd(c)?!1:!!c;(d.isUnd(b)?0:b)?(P.changed.active=!1,P[c?"replaceHash":"setHash"](a),P.changed.active=!0):(P.changed.active=!0,P[c? "replaceHash":"setHash"](a),P.setHash(a))};F.prototype.bootstart=function(){this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart();return this};o=new F;G.newInstanceFromJson=function(a){var b=new G;return b.initByJson(a)?b:null};G.prototype.name="";G.prototype.email="";G.prototype.privateType=null;G.prototype.validate=function(){return""!==this.name||""!==this.email};G.prototype.hash=function(a){return"#"+(a?"":this.name)+"#"+this.email+"#"};G.prototype.clearDuplicateName=function(){this.name=== this.email&&(this.name="")};G.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};G.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())};G.prototype.parse=function(a){var a=d.trim(a),b=/(?:"([^"]+)")? ?,]+)>?,? ?/g.exec(a);b?(this.name=b[1]||"",this.email= b[2]||"",this.clearDuplicateName()):/^[^@]+@[^@]+$/.test(a)&&(this.name="",this.email=a)};G.prototype.initByJson=function(a){var b=!1;a&&"Object/Email"===a["@Object"]&&(this.name=d.trim(a.Name),this.email=d.trim(a.Email),b=""!==this.email,this.clearDuplicateName());return b};G.prototype.toLine=function(a,b){var c="";""!==this.email&&(b=d.isUnd(b)?!1:!!b,a&&""!==this.name?c=b?'")+'" target="_blank" tabindex="-1">'+d.encodeHtml(this.name)+ "":this.name:(c=this.email,""!==this.name?c=b?d.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+d.encodeHtml(c)+""+d.encodeHtml(">"):'"'+this.name+'" <'+c+">":b&&(c=''+d.encodeHtml(this.email)+"")));return c};G.prototype.select2Result=function(){var a="",b=f.cache().getUserPic(this.email),a=""!==b?a+(''):a+('');g.EmailType.Facebook===this.type()?(a+=""+(0'):a+=""+(0('+this.name+")":this.email);return a+""};G.prototype.select2Selection=function(a){var b="";if(g.EmailType.Facebook===this.type()){if(b=0").text(b).appendTo(a),a.append(''),null}else b=0+$/,""),b=!0);return b};E.prototype.isImage=function(){return-1+$/,""),b=i.find(c,function(b){return a===b.cidWithOutTags})); return b||null};p.prototype.findAttachmentByContentLocation=function(a){var b=null,c=this.attachments();d.isNonEmptyArray(c)&&(b=i.find(c,function(b){return a===b.contentLocation}));return b||null};p.prototype.messageId=function(){return this.sMessageId};p.prototype.inReplyTo=function(){return this.sInReplyTo};p.prototype.references=function(){return this.sReferences};p.prototype.fromAsSingleEmail=function(){return d.isArray(this.from)&&this.from[0]?this.from[0].email:""};p.prototype.viewLink=function(){return f.link().messageViewLink(this.requestHash)}; p.prototype.downloadLink=function(){return f.link().messageDownloadLink(this.requestHash)};p.prototype.replyEmails=function(a){var b=[],a=d.isUnd(a)?{}:a;p.replyHelper(this.replyTo,a,b);0===b.length&&p.replyHelper(this.from,a,b);return b};p.prototype.replyAllEmails=function(a){var b=[],c=[],a=d.isUnd(a)?{}:a;p.replyHelper(this.replyTo,a,b);0===b.length&&p.replyHelper(this.from,a,b);p.replyHelper(this.to,a,b);p.replyHelper(this.cc,a,c);return[b,c]};p.prototype.textBodyToString=function(){return this.body? this.body.html():""};p.prototype.attachmentsToStringLine=function(){var a=i.map(this.attachments(),function(a){return a.fileName+" ("+a.friendlySize+")"});return a&&0"};ya.prototype.formattedNameForCompose=function(){var a=this.name();return""===a?this.email():a+" ("+this.email()+")"};ya.prototype.formattedNameForEmail=function(){var a=this.name();return""===a?this.email():'"'+d.quoteName(a)+'" <'+this.email()+">"};d.extendAsViewModel("PopupsFolderClearViewModel",za);za.prototype.clearPopup=function(){this.clearingProcess(!1);this.selectedFolder(null)};za.prototype.onShow=function(a){this.clearPopup(); a&&this.selectedFolder(a)};d.extendAsViewModel("PopupsFolderCreateViewModel",ga);ga.prototype.sNoParentText="";ga.prototype.simpleFolderNameValidation=function(a){return/^[^\\\/]+$/g.test(d.trim(a))};ga.prototype.clearPopup=function(){this.folderName("");this.selectedParentValue("");this.focusTrigger(!1)};ga.prototype.onShow=function(){this.clearPopup();this.focusTrigger(!0)};d.extendAsViewModel("PopupsFolderSystemViewModel",aa);aa.prototype.sChooseOnText="";aa.prototype.sUnuseText="";aa.prototype.onShow= function(a){var b="",a=d.isUnd(a)?g.SetSystemFoldersNotification.None:a;switch(a){case g.SetSystemFoldersNotification.Sent:b=d.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SENT");break;case g.SetSystemFoldersNotification.Draft:b=d.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_DRAFTS");break;case g.SetSystemFoldersNotification.Spam:b=d.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_SPAM");break;case g.SetSystemFoldersNotification.Trash:b=d.i18n("POPUPS_SYSTEM_FOLDERS/NOTIFICATION_TRASH")}this.notification(b)};d.extendAsViewModel("PopupsComposeViewModel", z);z.prototype.selectIdentity=function(a){a&&this.currentIdentityID(a.optValue)};z.prototype.formattedFrom=function(a){var b=f.data().displayName(),c=f.data().accountEmail();return""===b?c:(d.isUnd(a)?0:a)?'"'+d.quoteName(b)+'" <'+c+">":b+" ("+c+")"};z.prototype.sendMessageResponse=function(a,b){var c=!1;this.sending(!1);g.StorageResultType.Success===a&&(b&&b.Result)&&(c=!0,this.modalVisibility()&&o.delegateRun(this,"closeCommand"));this.modalVisibility()&&!c&&(b&&g.Notification.CantSaveMessage=== b.ErrorCode?(this.sendSuccessButSaveError(!0),h.alert(d.trim(d.i18n("COMPOSE/SAVED_ERROR_ON_SEND")))):(this.sendError(!0),h.alert(d.getNotification(b.ErrorCode?b.ErrorCode:g.Notification.CantSendMessage))))};z.prototype.saveMessageResponse=function(a,b){var c=!1,e=null;this.saving(!1);if(g.StorageResultType.Success===a&&(b&&b.Result)&&(b.Result.NewFolder&&b.Result.NewUid)&&(this.bFromDraft&&(e=f.data().message())&&(this.draftFolder()===e.folderFullNameRaw&&this.draftUid()===e.uid)&&f.data().message(null), this.draftFolder(b.Result.NewFolder),this.draftUid(b.Result.NewUid),this.draftID(b.Result.NewID),this.modalVisibility()))this.savedTime(h.Math.round((new h.Date).getTime()/1E3)),this.savedOrSendingText(0
"+l+":

"+q+"
";break;case g.ComposeType.Forward:Z=r.fromToLine(!1,!0);t=r.toToLine(!1,!0);w=r.ccToLine(!1,!0);q="


"+d.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TITLE")+"
"+d.i18n("COMPOSE/FORWARD_MESSAGE_TOP_FROM")+": "+Z+"
"+d.i18n("COMPOSE/FORWARD_MESSAGE_TOP_TO")+": "+t+(0"+d.i18n("COMPOSE/FORWARD_MESSAGE_TOP_CC")+": "+w:"")+"
"+d.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SENT")+ ": "+d.encodeHtml(l)+"
"+d.i18n("COMPOSE/FORWARD_MESSAGE_TOP_SUBJECT")+": "+d.encodeHtml(h)+"

"+q;break;case g.ComposeType.ForwardAsAttachment:q=""}this.oEditor.setRawText(q,r.isHtml)}}else this.oEditor&&g.ComposeType.Empty===a?this.oEditor.setRawText("
"+d.convertPlainTextToHtml(f.data().signature()),g.EditorDefaultType.Html===f.data().editorDefaultType()):d.isNonEmptyArray(b)&&i.each(b,function(a){e.addMessageAsAttachment(a)});r=this.getAttachmentsDownloadsForUpload();d.isNonEmptyArray(r)&& f.remote().messageUploadAttachments(function(a,b){if(g.StorageResultType.Success===a&&b&&b.Result){var c=null,d="";if(!e.viewModelVisibility())for(d in b.Result)if(b.Result.hasOwnProperty(d))(c=e.getAttachmentById(b.Result[d]))&&c.tempName(d)}else e.setMessageAttachmentFailedDowbloadText()},r);m&&this.oEditor&&this.oEditor.focus();this.triggerForResize()};z.prototype.onBuild=function(){this.initEditor();this.initUploader();var a=this,b=null;R.on("keydown",function(b){var d=!0;b&&(a.modalVisibility()&& f.data().useKeyboardShortcuts())&&(b.ctrlKey&&g.EventKeyCode.S===b.keyCode?(a.saveCommand(),d=!1):b.ctrlKey&&g.EventKeyCode.Enter===b.keyCode&&(a.sendCommand(),d=!1));return d});R.on("resize",function(){a.triggerForResize()});this.dropboxEnabled()&&(b=document.createElement("script"),b.type="text/javascript",b.src="https://www.dropbox.com/static/api/1/dropins.js",j(b).attr("id","dropboxjs").attr("data-app-key",f.settingsGet("DropboxApiKey")),document.body.appendChild(b))};z.prototype.getAttachmentById= function(a){for(var b=this.attachments(),c=0,d=b.length;cb.data("rl-cache-count")&&(b.addClass("rl-cache-purge"),a++)}),0').hide().addClass("rl-cache-class"),h.data("rl-cache-count",++m.iMessageBodyCacheCount),d.isNormal(a.Result.Html)&&""!==a.Result.Html?(c=!0,h.html(a.Result.Html.toString()).addClass("b-text-part html")):d.isNormal(a.Result.Plain)&&""!==a.Result.Plain?(c=!1,h.html(a.Result.Plain.toString()).addClass("b-text-part plain")): c=!1,a.Result.Rtl&&(h.data("rl-is-rtl",!0),h.addClass("rtl-text-part")),i.append(h),h.data("rl-is-html",c),h.data("rl-has-images",e),l.isRtl(!!h.data("rl-is-rtl")),l.isHtml(!!h.data("rl-is-html")),l.hasImages(!!h.data("rl-has-images")),l.body=h,g&&l.showInternalImages(!0),l.hasImages()&&this.showImages()&&l.showExternalImages(!0),this.purgeMessageBodyCacheThrottle()):(e.data("rl-cache-count",++m.iMessageBodyCacheCount),l.isRtl(!!e.data("rl-is-rtl")),l.isHtml(!!e.data("rl-is-html")),l.hasImages(!!e.data("rl-has-images")), l.body=e),this.messageActiveDom(l.body),this.hideMessageBodies(),l.body.show(),h&&d.initBlockquoteSwitcher(h);f.cache().initMessageFlagsFromCache(l);l.unseen()&&f.setMessageSeen(l);d.windowResize()}};U.prototype.setMessageList=function(a,b){if(a&&a.Result&&"Collection/MessageCollection"===a.Result["@Object"]&&a.Result["@Collection"]&&d.isArray(a.Result["@Collection"])){var c=f.data(),e=f.cache(),h=null,i=0,j=0,l=0,m=0,q=[],o=c.staticMessageList,r=null,H=null,n=null,s=0,u=!1,l=d.pInt(a.Result.MessageResultCount), m=d.pInt(a.Result.Offset);d.isNonEmptyArray(a.Result.LastCollapsedThreadUids)&&(h=a.Result.LastCollapsedThreadUids);if((n=f.cache().getFolderFromCacheList(d.isNormal(a.Result.Folder)?a.Result.Folder:""))&&!b)f.cache().setFolderHash(a.Result.Folder,a.Result.FolderHash),d.isNormal(a.Result.MessageCount)&&n.messageCountAll(a.Result.MessageCount),d.isNormal(a.Result.MessageUnseenCount)&&(d.pInt(n.messageCountUnread())!==d.pInt(a.Result.MessageUnseenCount)&&(u=!0),n.messageCountUnread(a.Result.MessageUnseenCount)), this.initUidNextAndNewMessages(n.fullNameRaw,a.Result.UidNext,a.Result.NewMessages);u&&n&&f.cache().clearMessageFlagsFromCacheByFolder(n.fullNameRaw);i=0;for(j=a.Result["@Collection"].length;i=s&&(s++,H.newForAnimation(!0)),H.deleted(!1),b?f.cache().initMessageFlagsFromCache(H):f.cache().storeMessageFlagsToCache(H), H.lastInCollapsedThread(h&&-1(new h.Date).getTime()-l);q&&t.oRequests[q]&& (t.oRequests[q].__aborted&&(f="abort"),t.oRequests[q]=null);t.defaultResponse(a,q,f,c,e,b)});q&&(0").addClass("rl-settings-view-model").hide().attr("data-bind",'template: {name: "'+g.__rlSettingsData.Template+'"}, i18nInit: true'),t.appendTo(h),c.data=f.data(),c.viewModelDom=t,c.__rlSettingsData=g.__rlSettingsData,g.__dom=t,g.__builded= !0,g.__vm=c,e.applyBindings(c,t[0]),o.delegateRun(c,"onBuild",[t])):d.log("Cannot find sub settings view model position: SettingsSubScreen"),c&&i.defer(function(){if(b.oCurrentSubScreen){o.delegateRun(b.oCurrentSubScreen,"onHide");b.oCurrentSubScreen.viewModelDom.hide()}b.oCurrentSubScreen=c;if(b.oCurrentSubScreen){b.oCurrentSubScreen.viewModelDom.show();o.delegateRun(b.oCurrentSubScreen,"onShow");i.each(b.menu(),function(a){a.selected(c&&c.__rlSettingsData&&a.route===c.__rlSettingsData.Route)}); j("#rl-content .b-settings .b-content .content").scrollTop(0)}d.windowResize()})):o.setHash(f.link().settings(),!1,!0)};fa.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(o.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide())};fa.prototype.onBuild=function(){i.each(V.settings,function(a){a&&(a.__rlSettingsData&&!i.find(V["settings-removed"],function(b){return b&&b===a}))&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label, selected:e.observable(!1),disabled:!!i.find(V["settings-disabled"],function(b){return b&&b===a})})},this);this.oViewModelPlace=j("#rl-content #rl-settings-subscreen")};fa.prototype.routes=function(){var a=i.find(V.settings,function(a){return a&&a.__rlSettingsData&&a.__rlSettingsData.IsDefault}),b=a?a.__rlSettingsData.Route:"general",a={subname:/^(.*)$/,normalize_:function(a,f){f.subname=d.isUnd(f.subname)?b:d.pString(f.subname);return[f.subname]}};return[["{subname}/",a],["{subname}",a],["",a]]}; i.extend(Fa.prototype,L.prototype);Fa.prototype.onShow=function(){f.setTitle(d.i18n("TITLES/LOGIN"))};i.extend(ca.prototype,L.prototype);ca.prototype.oLastRoute={};ca.prototype.onShow=function(){var a=f.data().accountEmail();f.setTitle((""===a?"":a+" - ")+d.i18n("TITLES/MAILBOX"))};ca.prototype.onRoute=function(a,b,c){var d=f.data(),a=f.cache().getFolderFullNameRaw(a);if(a=f.cache().getFolderFromCacheList(a))d.currentFolder(a).messageListPage(b).messageListSearch(c),!d.usePreviewPane()&&d.message()&& d.message(null),f.reloadMessageList()};ca.prototype.onStart=function(){var a=f.data(),b=function(){d.windowResize()};(f.settingsGet("AllowAdditionalAccounts")||f.settingsGet("AllowIdentities"))&&f.accountsAndIdentities();i.delay(function(){f.quota()},5E3);i.delay(function(){"INBOX"!==a.currentFolderFullNameRaw()&&f.folderInformation("INBOX")},1E3);i.delay(function(){var b=f.data().spamFolder();b!==a.currentFolderFullNameRaw()&&f.folderInformation(b)},1500);i.delay(function(){var b=f.data().draftFolder(); b!==a.currentFolderFullNameRaw()&&f.folderInformation(b)},2E3);i.delay(function(){f.remote().appDelayStart(d.emptyFunction)},35E3);h.setInterval(function(){f.folderInformation("INBOX")},12E4);h.setInterval(function(){f.quota()},3E5);Q.toggleClass("rl-no-preview-pane",!a.usePreviewPane());a.folderList.subscribe(b);a.messageList.subscribe(b);a.message.subscribe(b);a.usePreviewPane.subscribe(function(a){Q.toggleClass("rl-no-preview-pane",!a)})};ca.prototype.onBuild=function(){m.bMobileDevice||i.defer(function(){d.initLayoutResizer("#rl-resizer-left", "#rl-resizer-right","#rl-right",350,800,350,350,g.ClientSideKeyName.MailBoxListSize)})};ca.prototype.routes=function(){var a=function(a,c){c[0]=d.pString(c[0]);c[1]=d.pInt(c[1]);c[1]=0>=c[1]?1:c[1];c[2]=d.pString(c[2]);""===a&&(c[0]="Inbox",c[1]=1);return[decodeURI(c[0]),c[1],decodeURI(c[2])]};return[[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/(.+)\/?$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/p([1-9][0-9]*)\/?$/,{normalize_:a}],[/^([a-zA-Z0-9]+)\/(.+)\/?$/,{normalize_:function(a,c){c[0]=d.pString(c[0]);c[1]=d.pString(c[1]); ""===a&&(c[0]="Inbox");return[decodeURI(c[0]),1,decodeURI(c[1])]}}],[/^([^\/]*)$/,{normalize_:a}]]};i.extend(Qa.prototype,fa.prototype);Qa.prototype.onShow=function(){f.setTitle(this.sSettingsTitle)};i.extend(K.prototype,Ua.prototype);K.prototype.oSettings=null;K.prototype.oLink=null;K.prototype.download=function(a){var b=null,c=null;if((b=navigator.userAgent.toLowerCase())&&(-1