(function(h,j,d,ga,A,i){function p(){this.sBase="#/";this.sCdnStaticDomain=e.settingsGet("CdnStaticDomain");this.sVersion=e.settingsGet("Version");this.sSpecSuffix=e.settingsGet("AuthAccountHash")||"0";this.sServer=(e.settingsGet("IndexFile")||"./")+"?";this.sCdnStaticDomain=""===this.sCdnStaticDomain?this.sCdnStaticDomain:"/"===this.sCdnStaticDomain.substr(-1)?this.sCdnStaticDomain:this.sCdnStaticDomain+"/"}function O(){}function P(){}function Q(){var a=i.find([P,O],function(a){return a.supported()});
a&&(this.oDriver=new a)}function ha(){}function u(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 x(a,b){this.sScreenName=a;this.aViewModels=c.isArray(b)?b:[]}function q(){this.sDefaultScreenName="";this.oScreens={};this.oCurrentScreen=this.oBoot=null;this.popupVisibility=d.observable(!1);this.popupVisibility.subscribe(function(a){e&&
e.popupVisibility(a)})}function t(a,b){this.email=a||"";this.name=b||"";this.privateType=null;this.clearDuplicateName()}function C(){u.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(m.Values.ImapDefaulPort);this.imapSecure=d.observable(f.ServerSecure.None);this.smtpServer=d.observable("");this.smtpPort=d.observable(m.Values.SmtpDefaulPort);this.smtpSecure=d.observable(f.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);e.remote().createOrUpdateDomain(i.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);e.remote().testConnectionForDomain(i.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 R(){u.call(this,"Popups","PopupsPlugin");var a=this;this.onPluginSettingsUpdateResponse=i.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').appendTo("body");
I.on("error",function(a){e&&(a&&a.originalEvent&&a.originalEvent.message&&-1===c.inArray(a.originalEvent.message,["Uncaught Error: Error calling method on NPObject."]))&&e.remote().jsError(c.emptyFunction,a.originalEvent.message,a.originalEvent.filename,a.originalEvent.lineno,location&&location.toString?location.toString():"",K.attr("class"))})}function w(){v.call(this);this.oCache=this.oRemote=this.oData=null}var m={},f={},l={},c={},o={},k={},B={settings:[],"settings-removed":[],"settings-disabled":[]},
r=null,V=h.rainloopAppData||{},ea=h.rainloopI18N||{},K=j("html"),I=j(h),la=j(h.document),W=h.Notification&&h.Notification.requestPermission?h.Notification:null,e=null;k.minuteTick=d.observable(!0);k.fiveMinuteTick=d.observable(!0);k.langChangeTick=d.observable(!0);k.iAjaxErrorCount=0;k.iTokenErrorCount=0;k.iMessageBodyCacheCount=0;k.bUnload=!1;k.sUserAgent=(navigator.userAgent||"").toLowerCase();k.bIsiOSDevice=-1/g,">").replace(/"/g,""").replace(/'/g,"'"):""};c.splitPlainText=function(a,
b){for(var g="",s="",d=a,e=0,f=0,b=c.isUnd(b)?100:b;d.length>b;)s=d.substring(0,b),e=s.lastIndexOf(" "),f=s.lastIndexOf("\n"),-1!==f&&(e=f),-1===e&&(e=b),g+=s.substring(0,e)+"\n",d=d.substring(e+1);return g+d};var X={};c.timeOutAction=function(a,b,g){c.isUnd(X[a])&&(X[a]=0);h.clearTimeout(X[a]);X[a]=h.setTimeout(b,g)};var fa={};c.timeOutActionSecond=function(a,b,g){fa[a]||(fa[a]=h.setTimeout(function(){b();fa[a]=0},g))};var z=!1;c.audio=function(a,b){if(!1===z)if(k.bIsiOSDevice)z=null;else{var g=
!1,c=!1,d=h.Audio?new h.Audio:null;d&&d.canPlayType&&d.play?((g=""!==d.canPlayType('audio/mpeg; codecs="mp3"'))||(c=""!==d.canPlayType('audio/ogg; codecs="vorbis"')),g||c?(z=d,z.preload="none",z.loop=!1,z.autoplay=!1,z.muted=!1,z.src=g?a:b):z=null):z=null}return z};c.hos=function(a,b){return a&&Object.hasOwnProperty?Object.hasOwnProperty.call(a,b):!1};c.i18n=function(a,b,g){var d="",a=c.isUnd(ea[a])?c.isUnd(g)?a:g:ea[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){i.defer(function(){j(".i18n",a).each(function(){var a=j(this),g="";(g=a.data("i18n-text"))?a.text(c.i18n(g)):((g=a.data("i18n-html"))&&a.html(c.i18n(g)),(g=a.data("i18n-placeholder"))&&a.attr("placeholder",c.i18n(g)))})})};c.i18nToDoc=function(){h.rainloopI18N&&(ea=h.rainloopI18N||{},c.i18nToNode(la),k.langChangeTick(!k.langChangeTick()));h.rainloopI18N={}};c.initOnStartOrLangChange=function(a,b,c){a&&a.call(b);c?k.langChangeTick.subscribe(function(){a&&a.call(b);
c.call(b)}):a&&k.langChangeTick.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=j(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 g=null,d=c.trim(b);null!==(g=(new h.RegExp("^"+a+"[\\s]?\\:(.*)$","gi")).exec(b))&&!c.isUnd(g[1])?d=a+"[2]: "+g[1]:null!==(g=(new h.RegExp("^("+a+"[\\s]?[\\[\\(]?)([\\d]+)([\\]\\)]?[\\s]?\\:.*)$","gi")).exec(b))&&!c.isUnd(g[1])&&!c.isUnd(g[2])&&!c.isUnd(g[3])?(c.pInt(g[2]),d=g[1]+(c.pInt(g[2])+1)+g[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(l[a])?"":l[a]};c.initNotificationLanguage=function(){l[f.Notification.InvalidToken]=c.i18n("NOTIFICATIONS/INVALID_TOKEN");l[f.Notification.AuthError]=
c.i18n("NOTIFICATIONS/AUTH_ERROR");l[f.Notification.AccessError]=c.i18n("NOTIFICATIONS/ACCESS_ERROR");l[f.Notification.ConnectionError]=c.i18n("NOTIFICATIONS/CONNECTION_ERROR");l[f.Notification.CaptchaError]=c.i18n("NOTIFICATIONS/CAPTCHA_ERROR");l[f.Notification.SocialFacebookLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE");l[f.Notification.SocialTwitterLoginAccessDisable]=c.i18n("NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE");l[f.Notification.SocialGoogleLoginAccessDisable]=
c.i18n("NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE");l[f.Notification.DomainNotAllowed]=c.i18n("NOTIFICATIONS/DOMAIN_NOT_ALLOWED");l[f.Notification.AccountNotAllowed]=c.i18n("NOTIFICATIONS/ACCOUNT_NOT_ALLOWED");l[f.Notification.CantGetMessageList]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE_LIST");l[f.Notification.CantGetMessage]=c.i18n("NOTIFICATIONS/CANT_GET_MESSAGE");l[f.Notification.CantDeleteMessage]=c.i18n("NOTIFICATIONS/CANT_DELETE_MESSAGE");l[f.Notification.CantMoveMessage]=c.i18n("NOTIFICATIONS/CANT_MOVE_MESSAGE");
l[f.Notification.CantSaveMessage]=c.i18n("NOTIFICATIONS/CANT_SAVE_MESSAGE");l[f.Notification.CantSendMessage]=c.i18n("NOTIFICATIONS/CANT_SEND_MESSAGE");l[f.Notification.InvalidRecipients]=c.i18n("NOTIFICATIONS/INVALID_RECIPIENTS");l[f.Notification.CantCreateFolder]=c.i18n("NOTIFICATIONS/CANT_CREATE_FOLDER");l[f.Notification.CantRenameFolder]=c.i18n("NOTIFICATIONS/CANT_RENAME_FOLDER");l[f.Notification.CantDeleteFolder]=c.i18n("NOTIFICATIONS/CANT_DELETE_FOLDER");l[f.Notification.CantDeleteNonEmptyFolder]=
c.i18n("NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER");l[f.Notification.CantSubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER");l[f.Notification.CantUnsubscribeFolder]=c.i18n("NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER");l[f.Notification.CantSaveSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_SETTINGS");l[f.Notification.CantSavePluginSettings]=c.i18n("NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS");l[f.Notification.DomainAlreadyExists]=c.i18n("NOTIFICATIONS/DOMAIN_ALREADY_EXISTS");l[f.Notification.CantInstallPackage]=
c.i18n("NOTIFICATIONS/CANT_INSTALL_PACKAGE");l[f.Notification.CantDeletePackage]=c.i18n("NOTIFICATIONS/CANT_DELETE_PACKAGE");l[f.Notification.InvalidPluginPackage]=c.i18n("NOTIFICATIONS/INVALID_PLUGIN_PACKAGE");l[f.Notification.UnsupportedPluginPackage]=c.i18n("NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE");l[f.Notification.LicensingServerIsUnavailable]=c.i18n("NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE");l[f.Notification.LicensingExpired]=c.i18n("NOTIFICATIONS/LICENSING_EXPIRED");l[f.Notification.LicensingBanned]=
c.i18n("NOTIFICATIONS/LICENSING_BANNED");l[f.Notification.DemoSendMessageError]=c.i18n("NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR");l[f.Notification.AccountAlreadyExists]=c.i18n("NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS");l[f.Notification.MailServerError]=c.i18n("NOTIFICATIONS/MAIL_SERVER_ERROR");l[f.Notification.UnknownNotification]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR");l[f.Notification.UnknownError]=c.i18n("NOTIFICATIONS/UNKNOWN_ERROR")};c.getUploadErrorDescByCode=function(a){var b="";switch(c.pInt(a)){case f.UploadErrorCode.FileIsTooBig:b=
c.i18n("UPLOAD/ERROR_FILE_IS_TOO_BIG");break;case f.UploadErrorCode.FilePartiallyUploaded:b=c.i18n("UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED");break;case f.UploadErrorCode.FileNoUploaded:b=c.i18n("UPLOAD/ERROR_NO_FILE_UPLOADED");break;case f.UploadErrorCode.MissingTempFolder:b=c.i18n("UPLOAD/ERROR_MISSING_TEMP_FOLDER");break;case f.UploadErrorCode.FileOnSaveingError:b=c.i18n("UPLOAD/ERROR_ON_SAVING_FILE");break;case f.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,c=a.keyCode||a.which;if(a.ctrlKey&&c===f.EventKeyCode.S)a.preventDefault();else if((!b||!b.tagName||!b.tagName.match(/INPUT|TEXTAREA/i))&&a.ctrlKey&&c===f.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,g){var s=b?function(){s.canExecute&&s.canExecute()&&b.apply(a,Array.prototype.slice.call(arguments));
return!1}:function(){};s.enabled=d.observable(!0);g=c.isUnd(g)?!0:g;s.canExecute=c.isFunc(g)?d.computed(function(){return s.enabled()&&g.call(a)}):d.computed(function(){return s.enabled()&&!!g});return s};c.initDataConstructorBySettings=function(a){a.editorDefaultType=d.observable(f.EditorDefaultType.Html);a.showImages=d.observable(!1);a.interfaceAnimation=d.observable(f.InterfaceAnimation.Full);k.sAnimationType=f.InterfaceAnimation.Full;a.allowThemes=d.observable(!0);a.allowCustomLogin=d.observable(!1);
a.allowLanguagesOnSettings=d.observable(!0);a.allowLanguagesOnLogin=d.observable(!0);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.interfaceAnimation.subscribe(function(a){if(k.bMobileDevice||a===f.InterfaceAnimation.None)K.removeClass("rl-anim rl-anim-full").addClass("no-rl-anim"),k.sAnimationType=f.InterfaceAnimation.None;else switch(a){case f.InterfaceAnimation.Full:K.removeClass("no-rl-anim").addClass("rl-anim rl-anim-full");
k.sAnimationType=a;break;case f.InterfaceAnimation.Normal:K.removeClass("no-rl-anim rl-anim-full").addClass("rl-anim"),k.sAnimationType=a}});a.interfaceAnimation.valueHasMutated();a.desktopNotificationsPermisions=d.computed(function(){a.desktopNotifications();var b=f.DesktopNotifications.NotSupported;if(W&&W.permission)switch(W.permission.toLowerCase()){case "granted":b=f.DesktopNotifications.Allowed;break;case "denied":b=f.DesktopNotifications.Denied;break;case "default":b=f.DesktopNotifications.NotAllowed}else h.webkitNotifications&&
h.webkitNotifications.checkPermission&&(b=h.webkitNotifications.checkPermission());return b});a.useDesktopNotifications=d.computed({read:function(){return a.desktopNotifications()&&f.DesktopNotifications.Allowed===a.desktopNotificationsPermisions()},write:function(b){b?(b=a.desktopNotificationsPermisions(),f.DesktopNotifications.Allowed===b?a.desktopNotifications(!0):f.DesktopNotifications.NotAllowed===b?W.requestPermission(function(){a.desktopNotifications.valueHasMutated();f.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=d.observable("");a.languages=d.observableArray([]);a.mainLanguage=d.computed({read:a.language,write:function(b){b!==a.language()?-1=a.diff(g,"hours")?d:a.format("L")===g.format("L")?c.i18n("MESSAGE_LIST/TODAY_AT",{TIME:g.format("LT")}):a.clone().subtract("days",
1).format("L")===g.format("L")?c.i18n("MESSAGE_LIST/YESTERDAY_IN",{TIME:g.format("LT")}):a.year()===g.year()?g.format("D MMM."):g.format("LL")},a)};c.isFolderExpanded=function(a){var b=e.local().get(f.ClientSideKeyName.ExpandedFolders);return i.isArray(b)&&-1!==i.indexOf(b,a)};c.setExpandedFolder=function(a,b){var c=e.local().get(f.ClientSideKeyName.ExpandedFolders);i.isArray(c)||(c=[]);b?(c.push(a),c=i.uniq(c)):c=i.without(c,a);e.local().set(f.ClientSideKeyName.ExpandedFolders,c)};c.initLayoutResizer=
function(a,b,c,d,f,N,h,k){var d=d||300,f=f||500,N=N||f-d/2,h=h||300,y=0,l=j(a),m=j(b),o=j(c),b=e.local().get(k)||N,p=function(a,b,c){if(b||c)a=o.width(),b=b?100*(b.size.width/a):null,null===b&&c&&(b=100*(l.width()/a)),null!==b&&(l.css({width:"",height:"",right:""+(100-b)+"%"}),m.css({width:"",height:"",left:""+b+"%"}))};b&&l.width(b);y=o.width()-h;y=f>y?y:f;l.resizable({minWidth:d,maxWidth:y,handles:"e",resize:p,stop:p});p(null,null,!0);I.resize(i.throttle(function(b,c){c&&(c.element&&c.element[0].id&&
"#"+c.element[0].id===""+a)&&(y=o.width()-h,y=f>y?y:f,l.resizable("option","maxWidth",y),c.size&&c.size.width&&e.local().set(k,c.size.width),p(null,null,!0))},400))};c.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");
c.windowResize()}).after("
").before("
")})}};c.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()}))};c.extendAsViewModel=function(a,b){b&&(b.__name=a,o.regViewModelHook(a,b),i.extend(b.prototype,u.prototype))};c.addSettingsViewModel=function(a,b,c,d,e){a.__rlSettingsData={Label:c,Template:b,Route:d,IsDefault:!!e};B.settings.push(a)};
c.removeSettingsViewModel=function(a){B["settings-removed"].push(a)};c.disableSettingsViewModel=function(a){B["settings-disabled"].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/g,">").replace(/")};c.draggeblePlace=function(){return j('
').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,g,d){var e=null,f=h.open(""),i="__OpenerApplyBindingsUid"+c.fakeMd5()+"__",k=j("#"+b);h[i]=function(){if(f&&f.document.body&&k&&k[0]){var b=j(f.document.body);j("#rl-content",b).html(k.html());j("html",f.document).addClass("external "+j("html").attr("class"));c.i18nToNode(b);q.prototype.applyExternal(a,j("#rl-content",b)[0]);h[i]=null;d(f)}};f.document.open();f.document.write(''+
c.encodeHtml(g)+'');f.document.close();e=f.document.createElement("script");e.type="text/javascript";e.innerHTML="if(window&&window.opener&&window.opener['"+i+"']){window.opener['"+i+"']();window.opener['"+i+"']=null}";f.document.getElementsByTagName("head")[0].appendChild(e)};c.settingsSaveHelperFunction=function(a,b,g,d){g=g||null;d=c.isUnd(d)?1E3:c.pInt(d);return function(c,e,h,j,y){b.call(g,e&&e.Result?f.SaveSettingsStep.TrueResult:
f.SaveSettingsStep.FalseResult);a&&a.call(g,c,e,h,j,y);i.delay(function(){b.call(g,f.SaveSettingsStep.Idle)},d)}};c.settingsSaveHelperSimpleFunction=function(a,b){return c.settingsSaveHelperFunction(null,a,b,1E3)};c.resizeAndCrop=function(a,b,c){var d=new Image;d.onload=function(){var a=[0,0],d=document.createElement("canvas"),e=d.getContext("2d");d.width=b;d.height=b;a=this.width>this.height?[this.width-this.height,0]:[0,this.height-this.width];e.fillStyle="#fff";e.fillRect(0,0,b,b);e.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};d.bindingHandlers.tooltip={init:function(a,b){if(!k.bMobileDevice){var g=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},html:!0,trigger:"hover",title:function(){return''+c.i18n(d.utils.unwrapObservable(b()))+""}})}}};d.bindingHandlers.tooltip2={init:function(a,b){var c=j(a).data("tooltip-class")||"";j(a).tooltip({delay:{show:500,hide:100},
html:!0,title:function(){return''+b()()+""}})}};d.bindingHandlers.popover={init:function(a,b){j(a).popover(d.utils.unwrapObservable(b()))}};d.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"})}};d.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))})}};d.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))})}};d.bindingHandlers.modal={init:function(a,b){j(a).modal({keyboard:!1,show:d.utils.unwrapObservable(b())}).on("hidden",function(){b()(!1)})},update:function(a,b){var c=d.utils.unwrapObservable(b());j(a).modal(c?"show":"hide");i.delay(function(){j(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){j(a).attr("href",d.utils.unwrapObservable(b()))}};d.bindingHandlers.title={update:function(a,b){j(a).attr("title",d.utils.unwrapObservable(b()))}};d.bindingHandlers.textF={init:function(a,b){j(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());j(a).css({height:c[1],"min-height":c[1]})},update:function(a,b){var g=d.utils.unwrapObservable(b()),e=c.pInt(g[1]),f=0,f=j(a).offset().top;0=g.left&&a.pageX<=g.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>=g.top&&a.pageY<=g.top+100))g=
function(){d.scrollTop(d.scrollTop()-3);c.windowResize()},d.data("timerScroll",h.setInterval(g,10)),g()})},g.stop=function(){j(e).each(function(){h.clearInterval(j(this).data("timerScroll"));j(this).data("timerScroll",!1)})});g.helper=function(a){return b()(a&&a.target?d.dataFor(a.target):null)};j(a).draggable(g).on("mousedown",function(){c.removeInFocus()})}}};d.bindingHandlers.droppable={init:function(a,b,c){if(!k.bMobileDevice){var d=b(),e=(b=c())&&b.droppableOver?b.droppableOver:null,f=b&&b.droppableOut?
b.droppableOut:null,b={tolerance:"pointer",hoverClass:"droppableHover"};d&&(b.drop=function(a,b){d(a,b)},e&&(b.over=function(a,b){e(a,b)}),f&&(b.out=function(a,b){f(a,b)}),j(a).droppable(b))}}};d.bindingHandlers.nano={init:function(a){k.bDisableNanoScroll||j(a).addClass("nano").nanoScroller({iOSNativeScrolling:!1,preventPageScrolling:!0})}};d.bindingHandlers.saveTrigger={init:function(a){j(a).append(' ').addClass("settings-saved-trigger")},
update:function(a,b){var c=d.utils.unwrapObservable(b()),e=j(a);switch(c.toString()){case "1":e.find(".animated,.error").hide().removeClass("visible").end().find(".success").show().addClass("visible");break;case "0":e.find(".animated,.success").hide().removeClass("visible").end().find(".error").show().addClass("visible");break;case "-2":e.find(".error,.success").hide().removeClass("visible").end().find(".animated").show().addClass("visible");break;default:e.find(".animated").hide().end().find(".error,.success").removeClass("visible")}}};
d.bindingHandlers.select2={init:function(a,b){var g=0,f=null,ma=new h.RegExp(/[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9\.\-_]+/),N=new h.RegExp(/(.+) [<]?([^\s<@]+@[a-zA-Z0-9\.\-_]+)[>]?/),k=function(){return""},l=function(a){e.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===g?(l(a),g=h.setTimeout(c.emptyFunction,100)):(h.clearInterval(g),g=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,g){b=a&&a.c?a.c.select2Result(b):"";return""===b?g(a.text):b},createSearchChoice:function(a,b){return 0===b.length&&ma.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(){j(a).select2("destroy")});j(a).on("change",function(){for(var a=j(this).select2("data"),g=0,d=a.length,e=null,h=[];g").addClass("rl-view-model").addClass("RL-"+g.viewModelTemplate()).hide().attr("data-bind",'template: {name: "'+g.viewModelTemplate()+'"}, i18nInit: true'),i.appendTo(h),g.viewModelDom=i,a.__dom=i,"Popups"===f&&(g.cancelCommand=g.closeCommand=c.createCommand(g,function(){r.hideScreenPopup(a)})),o.runHook("view-model-pre-build",[a.__name,g,i]),d.applyBindings(g,
i[0]),this.delegateRun(g,"onBuild",[i]),o.runHook("view-model-post-build",[a.__name,g,i])):c.log("Cannot find view model position: "+f)}return a?a.__vm:null};q.prototype.applyExternal=function(a,b){a&&b&&d.applyBindings(a,b)};q.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")}))};q.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||[]])))};q.prototype.screenOnRoute=function(a,b){var d=this,e=null,f=null;""===c.pString(a)&&(a=this.sDefaultScreenName);if(""!==a){e=this.screen(a);if(!e&&(e=this.screen(this.sDefaultScreenName)))b=a+"/"+b,a=this.sDefaultScreenName;e&&e.__started&&(e.__builded||(e.__builded=!0,c.isNonEmptyArray(e.viewModels())&&
i.each(e.viewModels(),function(a){this.buildViewModel(a,e)},this),this.delegateRun(e,"onBuild")),i.defer(function(){if(d.oCurrentScreen){d.delegateRun(d.oCurrentScreen,"onHide");c.isNonEmptyArray(d.oCurrentScreen.viewModels())&&i.each(d.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.hide();a.__vm.viewModelVisibility(false);d.delegateRun(a.__vm,"onHide")}})}d.oCurrentScreen=e;if(d.oCurrentScreen){d.delegateRun(d.oCurrentScreen,"onShow");o.runHook("screen-on-show",
[d.oCurrentScreen.screenName(),d.oCurrentScreen]);c.isNonEmptyArray(d.oCurrentScreen.viewModels())&&i.each(d.oCurrentScreen.viewModels(),function(a){if(a.__vm&&a.__dom&&"Popups"!==a.__vm.viewModelPosition()){a.__dom.show();a.__vm.viewModelVisibility(true);d.delegateRun(a.__vm,"onShow");o.runHook("view-model-on-show",[a.__name,a.__vm])}},d)}(f=e.__cross())&&f.parse(b)}))}};q.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(),o.runHook("screen-pre-start",[a.screenName(),a]),this.delegateRun(a,"onStart"),o.runHook("screen-post-start",[a.screenName(),a]))},this);a=ga.create();a.addRoute(/^([a-zA-Z0-9\-]*)\/?(.*)$/,i.bind(this.screenOnRoute,this));A.initialized.add(a.parse,a);A.changed.add(a.parse,a);A.init()};q.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)?(A.changed.active=!1,A.setHash(a),A.changed.active=!0):(A.changed.active=!0,A.setHash(a))};q.prototype.bootstart=function(){this.oBoot&&this.oBoot.bootstart&&this.oBoot.bootstart();return this};r=new q;t.newInstanceFromJson=function(a){var b=new t;return b.initByJson(a)?b:null};t.prototype.name="";t.prototype.email="";t.prototype.privateType=null;t.prototype.validate=function(){return""!==this.name||""!==this.email};t.prototype.hash=function(a){return"#"+
(a?"":this.name)+"#"+this.email+"#"};t.prototype.clearDuplicateName=function(){this.name===this.email&&(this.name="")};t.prototype.type=function(){if(null===this.privateType&&(this.email&&"@facebook.com"===this.email.substr(-13)&&(this.privateType=f.EmailType.Facebook),null===this.privateType))this.privateType=f.EmailType.Default;return this.privateType};t.prototype.search=function(a){return-1<(this.name+" "+this.email).toLowerCase().indexOf(a.toLowerCase())};t.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)};t.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};t.prototype.toLine=function(a,b){var d="";""!==this.email&&(b=c.isUnd(b)?!1:!!b,a&&""!==this.name?d=b?'")+'" target="_blank" tabindex="-1">'+c.encodeHtml(this.name)+"":this.name:(d=this.email,""!==this.name?d=b?c.encodeHtml('"'+this.name+'" <')+'")+'" target="_blank" tabindex="-1">'+c.encodeHtml(d)+""+c.encodeHtml(">"):'"'+this.name+'" <'+d+">":b&&(d=''+c.encodeHtml(this.email)+"")));return d};t.prototype.select2Result=function(){var a=
"",b=e.cache().getUserPic(this.email),a=""!==b?a+('
'):a+('
');f.EmailType.Facebook===this.type()?(a+=""+(0'):a+=""+(0('+this.name+")":this.email);return a+""};t.prototype.select2Selection=
function(a){var b="";if(f.EmailType.Facebook===this.type()){if(b=0").text(b).appendTo(a),a.append(''),null}else b=0(new h.Date).getTime()-p);n&&l.oRequests[n]&&(l.oRequests[n].__aborted&&(e="abort"),l.oRequests[n]=null);l.defaultResponse(a,n,e,d,g,b)});n&&(0").addClass("rl-settings-view-model").hide().attr("data-bind",
'template: {name: "'+h.__rlSettingsData.Template+'"}, i18nInit: true'),l.appendTo(k),f.data=e.data(),f.viewModelDom=l,f.viewModelDom.addClass("rl-animation-margin"),f.__rlSettingsData=h.__rlSettingsData,h.__dom=l,h.__builded=!0,h.__vm=f,d.applyBindings(f,l[0]),r.delegateRun(f,"onBuild",[l])):c.log("Cannot find sub settings view model position: SettingsSubScreen"),f&&i.defer(function(){if(b.oCurrentSubScreen){r.delegateRun(b.oCurrentSubScreen,"onHide");b.oCurrentSubScreen.viewModelDom.hide();b.oCurrentSubScreen.viewModelDom.addClass("rl-animation-margin")}b.oCurrentSubScreen=
f;if(b.oCurrentSubScreen){b.oCurrentSubScreen.viewModelDom.show();r.delegateRun(b.oCurrentSubScreen,"onShow");i.each(b.menu(),function(a){a.selected(f&&f.__rlSettingsData&&a.route===f.__rlSettingsData.Route)});j("#rl-content .b-settings .b-content .content").scrollTop(0);b.oCurrentSubScreen.viewModelDom.removeClass("rl-animation-margin")}c.windowResize()}))};H.prototype.onHide=function(){this.oCurrentSubScreen&&this.oCurrentSubScreen.viewModelDom&&(r.delegateRun(this.oCurrentSubScreen,"onHide"),this.oCurrentSubScreen.viewModelDom.hide(),
this.oCurrentSubScreen.viewModelDom.addClass("rl-animation-margin"))};H.prototype.onBuild=function(){i.each(B.settings,function(a){a&&(a.__rlSettingsData&&!i.find(B["settings-removed"],function(b){return b&&b===a}))&&this.menu.push({route:a.__rlSettingsData.Route,label:a.__rlSettingsData.Label,selected:d.observable(!1),disabled:!!i.find(B["settings-disabled"],function(b){return b&&b===a})})},this);this.oViewModelPlace=j("#rl-content #rl-settings-subscreen")};H.prototype.routes=function(){var a=i.find(B.settings,
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]]};i.extend(ca.prototype,x.prototype);ca.prototype.onShow=function(){e.setTitle("")};i.extend(da.prototype,H.prototype);da.prototype.onShow=function(){e.setTitle("")};i.extend(v.prototype,ha.prototype);v.prototype.oSettings=null;
v.prototype.oLink=null;v.prototype.download=function(a){var b=null,c=null;if((b=navigator.userAgent.toLowerCase())&&(-1