HEX
Server: Apache/2.2.34 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141
System: Linux Kou-Etsu-Dou 4.4.59+ #25556 SMP PREEMPT Thu Mar 4 18:03:46 CST 2021 x86_64
User: hosam (1026)
PHP: 7.2.29
Disabled: NONE
Upload Files
File: //usr/syno/synoman/sharing/sharing.js
/* Copyright (c) 2021 Synology Inc. All rights reserved. */

Object.defineProperty(SYNO.SDS,"isNVR",{get:function(){return"yes"===_D("nvr")}}),function(){var t=!("no"===_D("is_business_model"));Ext.isIE8?SYNO.SDS.isBusinessModel=t:Object.defineProperty(SYNO.SDS,"isBusinessModel",{get:function(){return t},set:function(){throw"cannot change readonly value"},configurable:!1})}(),Ext.define("SYNO.SDS.Environment",{statics:{ESM:"ESM",GetEnvironment:function(){return"yes"===_D("support_ESM")?SYNO.SDS.Environment.ESM:""}}}),Ext.namespace("SYNO.SDS");var _S,_TT;_S=function(t){return SYNO.SDS.Session[t]},_TT=function(t,e,i){try{return SYNO.SDS.Strings[t][e][i]}catch(t){return""}},Ext.define("SYNO.SDS.DependencyProvider",{extend:"Ext.util.Observable",constructor:function(t){var e=this;Ext.apply(e,t),e.callParent(arguments)},resolve:function(t,e){var i=this;return i.fn?i.fn.apply(t||window,e||[]):i.className}}),Ext.define("SYNO.SDS._Injector",{extend:"Ext.util.Observable",constructor:function(t){var e=this;e.callParent(arguments),e.providers={},e.selector=t},getEnvironment:function(){return this.selector},register:function(t){if(!(Ext.isEmpty(t)||Ext.isEmpty(t.cls)||Ext.isEmpty(t.realCls))){var e=t.cls;if(this.selector===t.name)Ext.define(e,{extend:t.realCls});else{if(e===t.defaultCls)return;Ext.isEmpty(t.defaultCls)||Ext.define(e,{extend:t.defaultCls})}}},configure:function(t){var e,i,n;for(e in t)t.hasOwnProperty(e)&&(n=t[e],Ext.isString(n)?i=new SYNO.SDS.DependencyProvider({identifier:e,className:n}):Ext.isObject(n)&&(i=new SYNO.SDS.DependencyProvider(Ext.apply({identifier:e},n))),this.providers[e]=i)},resolve:function(t,e,i){var n=this,o=n.providers[t];if(o)return o.resolve(e,i)}}),Ext.define("SYNO.SDS.basic.Themer",{extend:"Ext.util.Observable",constructor:function(){this.callParent(arguments)},setTheme:function(t,e){this.theme=t,this.themeCls=e,Ext.getBody().addClass(e)},getTheme:function(){return this.theme},getThemeCls:function(){return this.themeCls},getPath:function(t){var e=arguments.length>1;if(e||Ext.isArray(t)){var i=[];return Ext.each(e?arguments:t,function(t){i.push(this.innerGetPath(t))},this),i}return this.innerGetPath(t)},innerGetPath:function(t){return SYNO.SDS.CompatibleMode&&!0===SYNO.SDS.CompatibleMode?t.replace("default/",""):t.replace("default/",this.themeCls+"/")}}),Ext.define("SYNO.SDS.DSM.Themer",{extend:"SYNO.SDS.basic.Themer",statics:{BUSINESS:"business",DEFAULT:"default"},defaultThemeCls:"default",defaultThemeName:"dsm",constructor:function(t){var e=this,i=this.defaultThemeCls;e.callParent(arguments),SYNO.SDS.DSM.Themer.BUSINESS===t.themeCls&&(i=SYNO.SDS.DSM.Themer.BUSINESS),e.setTheme(this.defaultThemeName,i)}}),Ext.define("SYNO.SDS.ESM.Themer",{extend:"SYNO.SDS.basic.Themer",defaultThemeCls:"business",defaultThemeName:"esm",constructor:function(){var t=this;t.callParent(arguments),t.setTheme(this.defaultThemeName,this.defaultThemeCls)}}),Ext.define("SYNO.SDS.interval.Task",{extend:"Ext.Component",constructor:function(){var t=this;t.callParent(arguments),_S("isLogined")&&t.getTimeout()},stopPollingTask:function(){var t=this;t.pollTask&&t.pollUnreg(t.pollTask)},startPollingTask:function(){var t=this,e={interval:60,webapi:{api:"SYNO.Core.Desktop.Timeout",version:1,method:"check"},scope:t,status_callback:t.handleResponese};t.stopPollingTask(),t.pollTask=t.pollReg(e),t.mon(SYNO.SDS.StatusNotifier,"halt",function(){this.pollUnreg(this.pollTask)},t)},handleResponese:function(t,e,i,n){},delayGetTimeOut:function(){this.getTimeout.defer(6e4,this)},getTimeout:function(){var t=this,e={api:"SYNO.Core.Desktop.Timeout",method:"get",version:1,params:{}};t.sendWebAPI({api:e.api,version:e.version,method:e.method,params:e.params,scope:t,callback:function(t,e,i,n){t&&Ext.isNumber(e.timeout)&&e.timeout>0?(this.intervalTime=e.timeout,this.startPollingTask()):this.delayGetTimeOut()}})}}),SYNO.SDS.iFrameAppToFront=function(t){var e=SYNO.SDS.AppMgr.getByAppName(t);e.length&&Ext.each(e,function(t){if(t.window)return t.window.toFront(),!1})},SYNO.SDS.restoreLogoutTrigger=function(){SYNO.SDS.Utils.Logout.logoutTriggered=!1},SYNO.SDS.isCompatibleMode=function(){for(var t=document.getElementsByTagName("script"),e=0;e<t.length;e++){if(t[e].src.indexOf("compatible-6.x")>=0)return!0}return!1},SYNO.SDS.onBasicBeforeUnload=function(){Ext.isChrome&&SYNO.SDS.DragToDesktop.destroy();var t,e;if(!_S("standalone")&&(t=SYNO.SDS.AppMgr.getByAppName("SYNO.SDS.App.WelcomeApp.Instance"))&&t[0]&&!t[0].window.canReload())return _T("welcome","unload_hint");if(!_S("standalone")&&(t=SYNO.SDS.AppMgr.getByAppName("SYNO.SDS.PkgManApp.Instance"))&&t[0]&&t[0].window.isUpdating())return _T("pkgmgr","close_updateall_confirm");if((t=_S("standalone")?SYNO.SDS.AppMgr.getByAppName("SYNO.SDS.App.FileStation3.Instance"):SYNO.SDS.AppMgr.getByAppName("SYNO.SDS.App.FileTaskMonitor.Instance"))&&t[0]){e=_S("standalone")?t[0].window.panelObj.monitorPanel:t[0].window;var i="",n=_S("standalone")?_T("tree","leaf_filebrowser"):_D("os_name")||"DSM";if(e.uploadGrid.isProcessing()?i+=String.format(_T("filebrowser","upload_confirm_unload"),n):e.localGrid.isProcessing()?i+=String.format(_T("filebrowser","local_confirm_unload"),n):e.downloadGrid.isProcessing()&&(i+=String.format(_T("filebrowser","download_confirm_unload"),n)),""!==i)return SYNO.SDS.restoreLogoutTrigger.defer(10),i}},SYNO.SDS.getMsgBeforeUnload=function(){var t=SYNO.SDS.onBasicBeforeUnload();return!1===SYNO.SDS.StatusNotifier.fireEvent("beforeunload")?(SYNO.SDS.restoreLogoutTrigger.defer(10),_T("desktop","confirm_leave")):t?(SYNO.SDS.restoreLogoutTrigger.defer(10),t):void 0},SYNO.SDS.onBeforeUnload=function(){var t=_S("standalone")?SYNO.SDS.Config.FnMap[_S("standaloneAppName")]:null,e=t&&t.config?SYNO.SDS.Utils.GetLocalizedString(t.config.title,t.config.jsID):_D("os_name")||"DSM";return SYNO.SDS.getMsgBeforeUnload()||(!1===SYNO.SDS.UserSettings.getProperty("Desktop","disableLogoutConfirm")?String.format(_T("desktop","confirm_unload"),e):void 0)},SYNO.SDS.onBeforeUnloadForApplication=function(){return SYNO.SDS.getMsgBeforeUnload()},SYNO.SDS.initData=function(t){var e,i=Ext.urlDecode(window.location.search.substr(1));if(window.sessionStorage){window.sessionStorage.getItem("errCode")&&window.sessionStorage.removeItem("errCode")}if(Ext.isNumber(t)&&t>0)return void SYNO.SDS.initData.defer(t,this);SYNO.SDS.CompatibleMode=SYNO.SDS.isCompatibleMode();var n=i.launchApp;!n&&SYNO.SDS.Session&&(n=SYNO.SDS.Session.rewriteApp),e=i.jsDebug?{action:"debug",launch_app:n}:{launch_app:n},SYNO.SDS.InitUtils.fetchSYNODEFS().then(function(){SYNO.API.Request({api:"SYNO.Core.Desktop.Initdata",method:"get",params:e,version:1,callback:function(t,e,n,o){function s(){0===(r-=1)&&(Ext.isDefined(window._loadSynoLang)&&window._loadSynoLang(),e.Session.SynoToken=_S("SynoToken"),SYNO.SDS.Session=e.Session,SYNO.SDS.Config.JSConfig=e.JSConfig,SYNO.SDS.Strings=e.Strings,SYNO.SDS.initUserSettings=e.UserSettings,SYNO.SDS.initGroupSettings=e.GroupSettings,SYNO.SDS.UrlTag=e.UrlTag,SYNO.SDS.AppPrivilege=e.AppPrivilege,SYNO.SDS.ServiceStatus=e.ServiceStatus,SYNO.SDS.UIFeatures.IconSizeManager.enableHDDisplay(e.SynohdpackStatus||!0),SYNO.SDS.init(),window.loginLang&&_S("lang")!==window.loginLang&&(Ext.form.VTypes.reloadVtypeStr(),SYNO.API.AssignErrorStr(),SYNO.SDS.Utils.StorageUtils.UiRenderHelper=SYNO.SDS.Utils.StorageUtils.UiRenderHelperInitializer(),SYNO.SDS.Relay.GetRelaydStatusStr=SYNO.SDS.Relay.GenRelaydStatusStr()),SYNO.SDS.appendMissingCSSFiles(e.CSSFiles),SYNO.SDS.InitUtils.removeForm())}if(!t)return SYNO.Debug("SYNO.SDS.initData fail",arguments),void SYNO.SDS.initData(3e3);var r=1,a=Ext.get(document.documentElement);switch(e.Session.lang){case"cht":a.set({lang:"zh-Hant"}),Ext.getBody().addClass("syno-cjk");break;case"chs":a.set({lang:"zh-Hans"}),Ext.getBody().addClass("syno-cjk");break;case"jpn":a.set({lang:"ja"}),Ext.getBody().addClass("syno-cjk");break;case"krn":a.set({lang:"ko"}),Ext.getBody().addClass("syno-cjk")}var l=i.launchApp;!0!==e.Session.is_admin||e.Session.rewriteApp||l?window.loginLang&&e.Session.lang!==window.loginLang?SYNO.SDS.Utils.loadUIStrings(e.Session.lang,e.Session.fullversion,s):s():(r+=1,window.loginLang&&e.Session.lang!==window.loginLang?SYNO.SDS.Utils.loadUIStrings(e.Session.lang,e.Session.fullversion,s):s(),SYNO.API.Request({api:"SYNO.Core.QuickStart.Info",method:"load_ds_info",version:2,callback:function(t,i,n,o){if(!t)return e.Session.qckFailed=!0,void s();Ext.isObject(i)&&(Ext.copyTo(e.Session,i,["welcome_hide","admin_configured","myds_unified","found_myds_account","udc_check_state","udc_enabled"]),i.vol_path&&(e.Session.vol_path=i.vol_path),e.Session.myds_region_api_base_url=i.myds_region_api_base_url),s()}}))}})}).catch(function(t){SYNO.Debug("Failed to fetch DSM defs scripts",t)})},SYNO.SDS.filterStandaloneCSSFiles=function(t){if(!_S("standalone"))return t;var e,i,n,o,s=_S("standaloneAppName"),r=SYNO.SDS.Config.FnMap,a=[],l=function(e){Ext.each(t,function(t){if(t.indexOf(e)>=0)return a.push(t),!1})};return(e=r[s]?r[s].config:null)&&(o=e.white_pkg_list)?(Ext.each(o,function(t){(i=r[t]?r[t].config:null)&&(n=i.jsBaseURL,l(n))}),l(e.jsBaseURL),a):t},SYNO.SDS.appendMissingCSSFiles=function(t){var e=-1,i="",n=function(t){Ext.each(document.getElementsByTagName("link"),function(n){if(-1!==(e=t.indexOf("?"))&&(i=t.substring(0,e),0<n.href.indexOf(i)))return n.parentNode.removeChild(n),!1})};t=SYNO.SDS.filterStandaloneCSSFiles(t),Ext.each(t,function(t){var e=!1,i=function(t){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",t),document.getElementsByTagName("head")[0].appendChild(e)};if(0!==t.indexOf("webman/3rdparty/"))return Ext.each(document.getElementsByTagName("style"),function(i){if(i.innerHTML.indexOf(t)>=0)return e=!0,!1}),void(e||(Ext.each(document.getElementsByTagName("style"),function(e){var i=t.substr(0,t.indexOf("?v=")),n=new RegExp('@import url\\("'+i+'\\?v=[^"]+"\\);(\\n)?');e.innerHTML.indexOf(i)>=0&&(e.innerHTML=e.innerHTML.replace(n,""))}),i(t)));Ext.each(document.getElementsByTagName("link"),function(i){if(0<i.href.indexOf(t))return e=!0,!1}),e||(n(t),i(t))})},SYNO.SDS.AutoLaunch=function(){var t=function(t,e){var i,n,o=SYNO.SDS.Config.FnMap[t]&&SYNO.SDS.Config.FnMap[t].config?SYNO.SDS.Config.FnMap[t].config:{},s=o.canLaunch;if(Ext.isObject(s))for(i in s)if(!!_S(i)!==s[i])return;n=SYNO.SDS.AppMgr.getByAppName(t),0===n.length&&SYNO.SDS.AppLaunch(t,{},!1,e)};SYNO.SDS.Config.AutoLaunchFnList.each(function(e){Ext.isObject(e)?t(e.dependName,t.createDelegate(this,[e.appName])):t(e)})},SYNO.SDS.reloadJSConfig=function(t){if(Ext.isNumber(t)&&t>0)return void SYNO.SDS.reloadJSConfig.defer(t,this);var e=function(){var t=[];SYNO.SDS.AppMgr.each(function(e){var i=e.jsConfig.jsID;Ext.isDefined(SYNO.SDS.Config.FnMap[i])||t.push(e)}),Ext.invoke(t,"destroy")},i=function(){var t=[];SYNO.SDS.TaskButtons.buttons.each(function(e){var i=e.appName;Ext.isDefined(SYNO.SDS.Config.FnMap[i])||t.push(e)}),Ext.invoke(t,"destroy")},n=Ext.urlDecode(location.search.substr(1));SYNO.API.Request({api:"SYNO.Core.Desktop.Initdata",method:"get",version:1,params:{action:"jsconfig",launch_app:n.launchApp},callback:function(t,n,o,s){if(!t)return SYNO.Debug("SYNO.SDS.reloadJSConfig fail",arguments),void SYNO.SDS.reloadJSConfig(3e3);SYNO.SDS.Config.JSConfig=n.JSConfig,SYNO.SDS.Strings=n.Strings,SYNO.SDS.ServiceStatus=n.ServiceStatus,SYNO.SDS.AppPrivilege=n.AppPrivilege,SYNO.SDS.UrlTag=n.UrlTag,SYNO.SDS.JSLoad.init(),SYNO.SDS.AppView.refresh(),SYNO.SDS.Desktop.refresh(),SYNO.SDS.appendMissingCSSFiles(n.CSSFiles),e(),i(),SYNO.SDS.StatusNotifier&&SYNO.SDS.StatusNotifier.fireEvent("jsconfigLoaded"),SYNO.SDS.AutoLaunch()}}),SYNO.API.currentManager||(SYNO.API.currentManager=new SYNO.API.Manager),SYNO.API.currentManager.queryAPI("all")},SYNO.SDS.CheckAndNotifySecurityAdvisor=function(){SYNO.API.Request({api:"SYNO.Core.SecurityScan.Conf",method:"first_get",version:1,callback:function(t,e){if(!t||e.firstLogAnalyzer||e.firstScan){var i=String.format(_T("desktop","notify_security_advisor"),'<a data-syno-app="SYNO.SDS.SecurityScan.Instance">',"</a>");SYNO.SDS.SystemTray.notifyMsg(null,_T("helptoc","securityscan"),i,0,!1)}},scope:this})},SYNO.SDS.CheckAndNotifyPackageStarting=function(){SYNO.API.Request({api:"SYNO.Core.Package",method:"list",version:2,params:{additional:["status"]},callback:function(t,e){var i=e.packages;if(t&&void 0!==i)for(var n={installing:!0,starting:!0,upgrading:!0,repairing:!0},o=0;o<i.length;o++){var s=i[o].additional;if(void 0!==s&&void 0!==s.status&&!0===n[s.status]){var r=_T("notification","pkg_still_enabling_title"),a=_T("notification","pkg_still_enabling_info");return void SYNO.SDS.SystemTray.notifyMsg(null,r,a,0,!0)}}}})},SYNO.SDS.autoStart=function(){var t=SYNO.SDS.UserSettings.getProperty("Desktop","restoreParams")||[],e=SYNO.SDS.UserSettings.getLocalStorageRestoreParams();!Ext.isEmpty(e)&&SYNO.SDS.UserSettings.getProperty("Desktop","rememberWindowState")&&(t=e),_S("is_admin")&&(_S("welcome_hide")||(SYNO.SDS.CheckAndNotifySecurityAdvisor(),SYNO.API.Request({api:"SYNO.Core.QuickStart.Info",method:"hide_welcome",version:1,callback:Ext.emptyFn})),!0===SYNO.SDS.Session.admin_first_login_after_upgrade&&(SYNO.SDS.CheckAndNotifyPackageStarting(),SYNO.SDS.CheckAndNotifySecurityAdvisor())),SYNO.SDS.AutoLaunch(),Ext.each(t,function(t){SYNO.SDS.AppLaunch(t.className,Ext.apply({fromRestore:!0},t.params),!0)}),SYNO.SDS.UserSettings.removeProperty("Desktop","restoreParams"),SYNO.SDS.UserSettings.removeLocalStorageRestoreParams()},SYNO.SDS.CheckBadge=function(){!function(){SYNO.API.Request({compound:{api:"SYNO.Entry.Request",version:1,method:"request",stopwhenerror:!1,params:[{api:"SYNO.Core.Upgrade.Server",method:"check",version:1,params:{need_auto_smallupdate:!0}},{api:"SYNO.Core.Package.Server",method:"check",version:1}]},scope:this,callback:Ext.emptyFn})}()},SYNO.SDS.init=function(){var t,e,i=Ext.urlDecode(location.search.substr(1)),n=i.launchApp,o=i.launchParam,s=i.jsDebug,r=i.report,a=SYNO.SDS.Session.rewriteApp,l=Ext.id();if(Ext.isDefined(r))return void(window.location=Ext.urlAppend(r));Ext.isDefined(s)&&(SYNO.SDS.JSDebug=s),SYNO.SDS.initFramework();var S=SYNO.SDS.Config.FnMap[n],c=!1;if(S&&S.config){var h=S.config;"standalone"!==h.type&&!0!==h.allowStandalone&&"url"!==h.type&&"legacy"!==h.type||(c=!0)}if(SYNO.SDS.StatusNotifier.isAppEnabled(n)&&c)SYNO.SDS.initStandaloneDesktop(n,o);else if(a){if(!SYNO.SDS.StatusNotifier.isAppEnabled(a))return SYNO.SDS.StatusNotifier.fireEvent("logout"),window.alert(_JSLIBSTR("uicommon","error_noprivilege")),void SYNO.SDS.Utils.Logout.action(!0);SYNO.SDS.Session.rewrite_mode=!0,SYNO.SDS.initStandaloneDesktop(a,o)}else{if(!SYNO.SDS.StatusNotifier.isAppEnabled("SYNO.Desktop"))return SYNO.SDS.StatusNotifier.fireEvent("logout"),window.alert(_JSLIBSTR("uicommon","error_noprivilege")),void SYNO.SDS.Utils.Logout.action(!0);SYNO.SDS.initDesktop(n),SYNO.SDS.StatusNotifier.isAppEnabled(n)&&SYNO.SDS.AppLaunch(n,o),window.Notification&&SYNO.SDS.UserSettings.getProperty("Desktop","enableDesktopNotification")&&"default"===window.Notification.permission&&(t=String.format('<span id={0} class="blue-status" style="cursor:pointer;">{1}</span>',l,_T("common","here")),t=String.format(_T("common","click_to_enable_notification"),t),e=SYNO.SDS.SystemTray.notifyMsg("",_T("common","desktop"),t,0,!1),Ext.get(l).on("click",function(){window.Notification.requestPermission(function(t){window.Notification.permission=t}),e.close()})),_S("is_admin")&&SYNO.SDS.CheckBadge()}SYNO.SDS.GetExternalIP(),SYNO.SDS.initAccesibilityPlugin(),SYNO.SDS.HandleTimeoutTask=new SYNO.SDS.interval.Task},SYNO.SDS.initAccesibilityPlugin=function(){var t=SYNO.SDS.UserSettings.getProperty("Desktop","disableAccessibility")||!1;setARIAPluginsDisabled(t)},SYNO.SDS.initFramework=function(){var t=Ext.getCmp("sds-login");if(t&&t.el.fadeOut({callback:function(){t.destroy()}}),SYNO.SDS.LaunchTime=(new Date).getTime(),SYNO.SDS.JSLoad.init(),SYNO.SDS.StatusNotifier=new SYNO.SDS._StatusNotifier({}),SYNO.SDS.UserSettings=new SYNO.SDS._UserSettings,SYNO.SDS.GroupSettings=new SYNO.SDS._GroupSettings,SYNO.SDS.WindowMgr=new SYNO.SDS._WindowMgr,SYNO.SDS.FocusMgr=new SYNO.SDS._FocusMgr,SYNO.SDS.AppMgr=new SYNO.SDS._AppMgr,SYNO.SDS.GestureMgr=new SYNO.SDS._GestureMgr,SYNO.SDS.Injector=new SYNO.SDS._Injector(SYNO.SDS.Environment.GetEnvironment()),SYNO.SDS.Injector.configure({getDesktopClass:{fn:function(){var t=SYNO.SDS.UserSettings.getProperty("Desktop","desktopStyle");return"classical"===t||SYNO.SDS.Environment.GetEnvironment()===SYNO.SDS.Environment.ESM||"business"===_S("theme_cls")&&Ext.isEmpty(t)?"SYNO.SDS.Classical._Desktop":"SYNO.SDS._Desktop"}},getLaunchItemClass:{fn:function(){var t=SYNO.SDS.UserSettings.getProperty("Desktop","desktopStyle");return"classical"===t||SYNO.SDS.Environment.GetEnvironment()===SYNO.SDS.Environment.ESM||"business"===_S("theme_cls")&&Ext.isEmpty(t)?"SYNO.SDS.Classical._LaunchItem":"SYNO.SDS._LaunchItem"}},getAppMenuClass:{fn:function(){var t=SYNO.SDS.UserSettings.getProperty("Desktop","appMenuStyle");return"classical"===t||SYNO.SDS.Environment.GetEnvironment()===SYNO.SDS.Environment.ESM||"business"===_S("theme_cls")&&Ext.isEmpty(t)?"SYNO.SDS.Classic._AppView":"SYNO.SDS._AppView"}}}),SYNO.SDS._ActiveDesktop=Ext.getClassByName(SYNO.SDS.Injector.resolve("getDesktopClass")),SYNO.SDS.LaunchItem=Ext.getClassByName(SYNO.SDS.Injector.resolve("getLaunchItemClass")),SYNO.SDS._ActiveMenu=Ext.getClassByName(SYNO.SDS.Injector.resolve("getAppMenuClass")),SYNO.SDS.Injector.register({name:SYNO.SDS.Environment.ESM,cls:"SYNO.SDS.Themer",realCls:"SYNO.SDS.DSM.Themer",defaultCls:"SYNO.SDS.DSM.Themer"}),SYNO.SDS.ThemeProvider=new SYNO.SDS.Themer({themeCls:_S("theme_cls")}),Ext.isDefined(SYNO.SDS.JSDebug)&&(SYNO.Debug("JS Loading Caching Disabled. (append _dc to js link)"),"all"===SYNO.SDS.JSDebug)){var e=SYNO.SDS.Config.FnMap;SYNO.Debug("JS Dynamic Loading Disabled.");for(var i in e)e.hasOwnProperty(i)&&SYNO.SDS.JSLoad(i)}},SYNO.SDS.initStandaloneDesktop=function(t,e){_S("isLogined")&&(SYNO.SDS.BackgroundTaskMgr=new SYNO.SDS._BackgroundTaskMgr,SYNO.SDS.UploadTaskMgr=new SYNO.SDS._UploadBackgroundTaskMgr,SYNO.SDS.MailTaskMgr=new SYNO.SDS._MailBackgroundTaskMgr,SYNO.SDS.SystemTray=new SYNO.SDS._SystemTray),SYNO.SDS.Session.standalone=!0,SYNO.SDS.Session.standaloneAppName=t,SYNO.SDS.Desktop=new SYNO.SDS._StandaloneDesktop,SYNO.SDS.AppLaunch(t,e),window.onbeforeunload=SYNO.SDS.onBeforeUnload,SYNO.SDS.DestroyLoginInstance&&SYNO.SDS.DestroyLoginInstance()},SYNO.SDS.HideDesktop=function(){SYNO.SDS.TaskBar.hide(),SYNO.SDS.Desktop.hide(),Ext.get("sds-taskbar-shadow").hide()},SYNO.SDS.ShowDesktop=function(){var t=Ext.fly("sds-wallpaper");t.dom&&t.dom.src&&Ext.fly("sds-wallpaper").show(),SYNO.SDS.Desktop.show(),SYNO.SDS.TaskBar.show(),Ext.get("sds-taskbar-shadow").show()},Ext.define("SYNO.SDS.LaunchFullSizeApps",{statics:{appList:["SYNO.SDS.App.WelcomeApp.Instance","SYNO.SDS.UDC.Instance","SYNO.SDS.App.WelcomeTip.Instance"],index:0,start:function(){if(this.index<this.appList.length)return SYNO.SDS.AppLaunch(this.appList[this.index],{},!1),void this.index++;this.index===this.appList.length&&(SYNO.SDS.ShowDesktop(),SYNO.SDS.autoStart())}}}),SYNO.SDS.initDesktop=function(t){var e=!t&&!_S("qckFailed")&&_S("is_admin");if(SYNO.SDS.BackgroundTaskMgr=new SYNO.SDS._BackgroundTaskMgr,SYNO.SDS.UploadTaskMgr=new SYNO.SDS._UploadBackgroundTaskMgr,SYNO.SDS.PackageTaskMgr=new SYNO.SDS._PackageBackgroundTaskMgr,SYNO.SDS.MailTaskMgr=new SYNO.SDS._MailBackgroundTaskMgr,SYNO.SDS.DeskTopManager=new SYNO.SDS._DeskTopManager,SYNO.SDS.TaskBar=new SYNO.SDS._TaskBar,SYNO.SDS.TaskButtons=Ext.getCmp("sds-taskbuttons-panel"),SYNO.SDS.SystemTray=Ext.getCmp("sds-tray-panel"),SYNO.SDS.Desktop=new SYNO.SDS._ActiveDesktop,SYNO.SDS.AppView=new SYNO.SDS._ActiveMenu,SYNO.SDS.System=new SYNO.SDS._System,!1===SYNO.SDS.Session.boot_done)return void SYNO.SDS.System.WaitForBootUp();e&&(SYNO.SDS.LaunchFullSizeApps.start(),SYNO.SDS.HideDesktop()),SYNO.SDS.PreviewBox=new SYNO.SDS._PreviewBox,window.onbeforeunload=SYNO.SDS.onBeforeUnload,SYNO.SDS.StatusNotifier.on("thirdpartychanged",SYNO.SDS.reloadJSConfig),SYNO.SDS.StatusNotifier.on("halt",function(){var t=Ext.getClassByName("SYNO.API.Request.Polling.Instance");SYNO.SDS.TaskMgr.setHalt(!0),Ext.isObject(t)&&Ext.isFunction(t.endPolling)&&t.endPolling("halt")}),SYNO.SDS.StatusNotifier.on("resumehalt",function(){var t=Ext.getClassByName("SYNO.API.Request.Polling.Instance");SYNO.SDS.TaskMgr.setHalt(!1),Ext.isObject(t)&&Ext.isFunction(t.beginPolling)&&t.beginPolling("halt")}),e?SYNO.SDS.StatusNotifier.on("fullsizeappdestroy",function(){SYNO.SDS.LaunchFullSizeApps.start()}):SYNO.SDS.autoStart()},SYNO.SDS.DragToDesktop=function(){var t=!1,e=[".syno-sds-fs-win",".welcomedragable-url"],i=function(t){var i=!1;Ext.each(e,function(e){if(t.within(t.getTarget(e)))return i=!0,!1},this),i||t.preventDefault()},n=function(t){t.preventDefault();var e=this.timeStamp||(this.timeStamp=t.browserEvent.timeStamp);Math.abs(t.browserEvent.timeStamp-e)<100||(this.timeStamp=t.browserEvent.timeStamp,this.handleMouseMove(t))},o=function(t){this.handleMouseUp(t),t.stopPropagation(),t.preventDefault()},s=function(t){this.dragCurrent&&this.handleMouseUp.defer(150,this,[t])},r=function(t){t.preventDefault()};return{init:function(){Ext.dd.DragDropMgr.preventDefault=!1,Ext.EventManager.on(document,"dragstart",i,this,!0),Ext.EventManager.on(document,"dragenter",r,Ext.dd.DragDropMgr,!0),Ext.EventManager.on(document,"dragover",n,Ext.dd.DragDropMgr,!0),Ext.EventManager.on(document,"drop",o,Ext.dd.DragDropMgr,{preventDefault:!0}),Ext.EventManager.on(document,"dragend",s,Ext.dd.DragDropMgr,!0),t=!0},destroy:function(){Ext.dd.DragDropMgr.preventDefault=!0,Ext.EventManager.un(document,"dragstart",i,this,!0),Ext.EventManager.un(document,"dragover",n,Ext.dd.DragDropMgr,!0),Ext.EventManager.un(document,"dragenter",r,Ext.dd.DragDropMgr,!0),Ext.EventManager.un(document,"drop",o,Ext.dd.DragDropMgr),Ext.EventManager.un(document,"dragend",s,Ext.dd.DragDropMgr),t=!1},isEnable:function(){return t}}}(),Ext.namespace("SYNO.SDS"),SYNO.SDS.GetExternalIP=function(){_S("isLogined")&&SYNO.API.Request({api:"SYNO.Core.Desktop.Initdata",method:"get",version:1,params:{action:"external_ip"},callback:function(t,e,i,n){if(!t)return void SYNO.Debug("SYNO.SDS.GetExternalIP fail",arguments);SYNO.SDS.Session.external_ip=e.external_ip,SYNO.SDS.Session.ddns_hostname=e.ddns_hostname}})},SYNO.SDS.HTML5Utils=function(){var t=window.XMLHttpRequest?new XMLHttpRequest:{};return{HTML5Progress:!!t.upload,HTML5SendBinary:!(!t.sendAsBinary&&!t.upload),HTML5ReadBinary:!!(window.FileReader||window.File&&window.File.prototype.getAsBinary),HTML5Slice:!(!window.File||!(window.File.prototype.slice||window.File.prototype.mozSlice||window.File.prototype.webkitSlice)),isSupportHTML5Upload:function(){return(Ext.isChrome||!Ext.isSafari4&&!Ext.isSafari5_0&&!(Ext.isWindows&&Ext.isSafari)&&!Ext.isGecko3&&!Ext.isOpera)&&(!!window.FormData||SYNO.SDS.HTML5Utils.HTML5SendBinary&&SYNO.SDS.HTML5Utils.HTML5ReadBinary&&SYNO.SDS.HTML5Utils.HTML5Slice)},isDragFile:function(t){try{if(Ext.isWebKit){return t.dataTransfer.types&&-1!=t.dataTransfer.types.indexOf("Files")}if(Ext.isGecko)return t.dataTransfer.types.contains&&t.dataTransfer.types.contains("application/x-moz-file")||0<=t.dataTransfer.types.indexOf("application/x-moz-file");if(Ext.isIE10||Ext.isModernIE)return t.dataTransfer.files&&t.dataTransfer.types&&t.dataTransfer.types.contains("Files")}catch(t){SYNO.Debug.error("Error in isDragFile")}return!1}}}(),SYNO.SDS.SSOUtils=function(){return{callbackFn:{fn:Ext.emptyFn,scope:this},setCallback:function(t,e){this.callbackFn.fn=t,Ext.isDefined(e)&&(this.callbackFn.scope=e)},isSupport:function(){return _S("sso_support")&&_S("sso_server")&&_S("sso_appid")&&"SYNOSSO"in window&&Ext.isFunction(SYNOSSO.init)},init:function(t,e){if(this.isSupport()){this.setCallback(t,e);try{SYNOSSO.init({oauthserver_url:_S("sso_server"),app_id:_S("sso_appid"),redirect_uri:document.URL,callback:this.callback.createDelegate(this)})}catch(t){}}},callback:function(t){SYNOSSO.status=t.status,this.callbackFn.fn.call(this.callbackFn.scope,t)},login:function(t,e){this.setCallback(t,e),SYNOSSO.login()},logout:function(t,e){e&&t.createDelegate(e),"sso"===(Ext.util.Cookies.get("login_type")||"sso")&&SYNOSSO.logout(t)}}}(),SYNO.SDS.AzureSSOUtils=function(){var t=screen.width/2-250,e=screen.height/2-300,i=String.format("height={0},width={1},left={2},top={3}",600,500,t,e);return{login:function(t,e){var n=function(i){t(e,i)}.createDelegate(this),o=_S("dsm_https_port"),s=Ext.urlEncode({action:"signin",method:"azure_oidc",origin:location.origin}),r=location.hostname,a="https://"+r+":"+o+"/webman/index.cgi?"+s;window.addEventListener("message",n),window.open(a,"OIDC",i)},logout:function(){var t=Ext.urlEncode({asso:"true"}),e="webman/logout.cgi?"+t;window.open(e,"OIDC",i)}}}(),SYNO.SDS.WebSphereSSOUtils=function(){var t=screen.width/2-250,e=screen.height/2-300,i=String.format("height={0},width={1},left={2},top={3}",600,500,t,e);return{login:function(t,e){var n=function(i){t(e,i)}.createDelegate(this),o=_S("dsm_https_port"),s=Ext.urlEncode({action:"signin",method:"websphere_oidc",origin:location.origin}),r=location.hostname,a="https://"+r+":"+o+"/webman/index.cgi?"+s;window.addEventListener("message",n),window.open(a,"OIDC",i)},logout:function(){var t=Ext.urlEncode({webspheresso:"true"}),e="webman/logout.cgi?"+t;window.open(e,"OIDC",i)}}}(),Ext.define("SYNO.SDS.IEUpgradeAlert",{extend:"SYNO.SDS.Window",constructor:function(){var t={cls:"ie-upgrade-alert",width:450,height:230,maximizable:!1,title:_D("manager"),items:[{xtype:"syno_formpanel",name:"ie_alert_form",items:[{xtype:"syno_displayfield",hideLabel:!0,value:_T("desktop","upgrade_ie_browser")},{name:"skip_alert",xtype:"syno_checkbox",checked:!1,boxLabel:_T("common","dont_alert_again")}]}],fbar:{toolbarCls:"x-panel-fbar x-statusbar",items:[{xtype:"syno_button",text:_T("common","ok"),btnStyle:"blue",handler:function(){var t=this.find("name","skip_alert")[0],e=new Date;!0===t.getValue()&&Ext.util.Cookies.set("skip_upgrade_ie_alert",!0,e.add(Date.YEAR,1)),this.close()},scope:this}]}};this.callParent([t])}}),Ext.define("SYNO.SDS.InitUtils",{singleton:!0,checkTargetSelectable:function(t){if(t.getTarget(".selectabletext"))return!0;if(t.getTarget("textarea"))return!0;var e=t.getTarget("input"),i=e&&e.type?e.type.toLowerCase():"";return("text"===i||"textarea"===i||"password"===i)&&!e.readOnly},checkTargetTextFiledorTextArea:function(t){var e=t.getTarget("input"),i=e&&e.type?e.type.toLowerCase():"";return!!t.getTarget("textarea")||("text"===i||"password"===i)},hideForms:function(){var t=Ext.get("sds-login-dialog-form"),e=Ext.get("sds-apply-preview-form");return t&&t.setStyle("display","none"),e&&e.setStyle("display","none"),this},removeForm:function(){var t=Ext.get("sds-login-dialog-form");return t&&t.remove(),this},initQuickTips:function(){return Ext.QuickTips.init(),Ext.isIE9m&&!Ext.isIE9||Ext.QuickTips.getQuickTip().getEl().disableShadow(),this},initDragDrop:function(){return Ext.dd.DragDropMgr.stopPropagation=!1,Ext.dd.DragDropMgr.clickTimeThresh=-1,Ext.WindowMgr.zseed=12e3,this},disableIESelect:function(){return Ext.isIE&&Ext.getDoc().on("selectstart",function(t){this.checkTargetSelectable(t)||t.stopEvent()},this),this},disableSelectAllKeyboard:function(){return Ext.getDoc().on("keydown",function(t){t.ctrlKey&&t.A===t.getKey()&&!this.checkTargetSelectable(t)&&t.stopEvent();var e,i=SYNO.SDS.WindowMgr,n=i?i.getActiveAppWindow():null;n&&(e=n.appInstance),e&&e.jsConfig&&!0!=!e.jsConfig.allowBackspace||t.BACKSPACE!==t.getKey()||this.checkTargetTextFiledorTextArea(t)||t.preventDefault(),Ext.isIE&&t.ESC===t.getKey()&&this.checkTargetTextFiledorTextArea(t)&&t.preventDefault()},this),this},disableRightClick:function(){return Ext.getBody().on("contextmenu",function(t){this.checkTargetSelectable(t)||t.getTarget(".allowDefCtxMenu")||t.stopEvent()},this),this},handleServerError:function(){return Ext.Ajax.on("requestcomplete",function(t,e,i){try{SYNO.SDS.Utils.CheckServerError(e)&&(t.purgeListeners(),delete i.success,delete i.failure,delete i.callback)}catch(t){if(!Ext.isIE8)throw t}}),this},initHTML5Upload:function(){return SYNO.SDS.HTML5Utils.isSupportHTML5Upload()&&Ext.getBody().on("dragover",function(t){SYNO.SDS.HTML5Utils.isDragFile(t.browserEvent)&&(t.preventDefault(),t.browserEvent.dataTransfer.dropEffect="none")}),this},IEUpgradeAlert:function(){if(Ext.isIE6||Ext.isIE7||Ext.isIE8||Ext.isIE9){if(!Ext.util.Cookies.get("skip_upgrade_ie_alert")){(new SYNO.SDS.IEUpgradeAlert).show()}}return this},defaultCSSSelectors:function(){_S("diskless")&&Ext.getBody().addClass("syno-diskless"),Ext.isIE10Touch&&Ext.getBody().addClass("syno-ie10-touch");var t=Ext.urlDecode(location.search.substr(1)),e=t.accessible;return Ext.isDefined(e)&&Ext.getBody().addClass("accessible"),this},initAPIManagerPromise:function(){return SYNO.API.currentManager||(SYNO.API.currentManager=new SYNO.API.Manager),new Promise(function(t,e){SYNO.API.currentManager.queryAPI("all",t)})},checkTokenLogin:function(){var t="";return Ext.isWindows&&!1===_S("isLogined")&&!0===_S("enable_http_negotiate")?t="webman/login.cgi?negotiate="+Math.floor(window.performance.now()):!1===_S("isLogined")&&0===window.location.search.indexOf("?token=")&&(t="webman/login.cgi"+window.location.search),t.length?new Promise(function(e,i){Ext.Ajax.request({url:t,method:"Get",success:function(t,i){var n=Ext.decode(t.responseText);!0===n.success?(Ext.isEmpty(n.SynoToken)||(SYNO.SDS.Session.SynoToken=encodeURIComponent(n.SynoToken)),e(!0)):e(!1)},failure:function(){i()},scope:this})}):Promise.resolve(!1)},initHDPack:function(){return SYNO.SDS.UIFeatures.IconSizeManager.addHDClsAndCSS(_S("SynohdpackStatus")),this},initLoginDialog:function(){return void 0!==SYNO.SDS.ForgotPass?new SYNO.SDS.ChangePassPage({}):_S("isLogined")?_S("preview")?(window.opener&&window.opener.previewParam&&window.opener.previewParam.preview_modified&&new SYNO.SDS.LoginApplyPreviewForm({}),new SYNO.SDS.LoginDialog({preview:!0})):"no"!==_S("enable_syno_token")?SYNO.SDS.UpdateSynoToken(this.readyToInitData):this.readyToInitData():0<window.location.search.indexOf("SynoToken=")?window.location.search=window.location.search.replace(/&SynoToken=.*/,""):_S("public_access")?this.readyToInitData():document.getElementById("logined-default-admin")?localStorage.getItem("newInstallRedirectedHTTPS")?(localStorage.removeItem("newInstallRedirectedHTTPS"),window.loginLang=_S("lang"),new SYNO.SDS.LoginDialog({})):(localStorage.setItem("newInstallRedirectedHTTPS","1"),window.location.href="https://"+window.location.hostname+":5001/webman/logout.cgi"):(window.loginLang=_S("lang"),new SYNO.SDS.LoginDialog({})),this},readyToInitData:function(){return SYNO.SDS.initData(),this},fetchSYNODEFS:function(){return new Promise(function(t,e){if(!0===_S("isLogined"))t();else{var i="webapi/entry.cgi?api=SYNO.Core.Desktop.Defs&version=1&method=getjs";i=Ext.urlAppend(i,""),SYNO.SDS.JSLoader.requestJSFileByScript(i,t,e)}})}}),Ext.define("SYNO.SDS.TransitionEndHandler",{extend:"Ext.util.Observable",constructor:function(t){var e=this;e.el=t,t.on("transitionend",this.endTransition,this),e.callParent(arguments)},start:function(){this.startTime=new Date},endTransition:function(){var t=this;t.fireEvent("aftertransition",t,new Date-t.startTime)}}),Ext.define("SYNO.SDS._DeskTopManager",{extend:"Ext.util.Observable",list:null,front:null,desktopId:"sds-desktop",constructor:function(){var t=this;t.list={},t.callParent()},register:function(t){var e=this;t.manager&&t.manager.unregister(t),t.manager=this,e.list[t.id]=t,t.id!==e.desktopId&&t!==e.desktopId||e.showDesktop()},unregister:function(t){var e=this;delete t.manager,delete e.list[t.id]},isDesktopOnTop:function(){var t=this;return t.front===t.get(t.desktopId)},showDesktop:function(){var t=this,e=t.get(t.desktopId);t.bringToFront(e)},get:function(t){return"object"==typeof t?t:this.list[t]},
updateTransition:function(t,e){var i=this;e>500&&(i.disableBlur=!0,i.transitionHandler.un("aftertransition",i.updateTransition,i))},bringToFront:function(t){var e=this,i=!1;return!((t=e.get(t))===e.front||!t)&&(i=t.doLayout,t.show(),e.front&&e.front.id===e.desktopId?e.front.addClass(e.backgroundTransparent?"semi-transparent":"sent-back"):e.front&&e.front.hide(),e.front=t,i&&t.doLayout(),!0)},hideAllExceptMe:function(t){var e,i=this;for(var n in i.list)i.list.hasOwnProperty(n)&&(e=i.list[n])&&e!==t&&"function"!=typeof i.list[n]&&i.list[n].isVisible()&&i.list[n].hide()},hideAll:function(){for(var t in this.list)this.list[t]&&"function"!=typeof this.list[t]&&this.list[t].isVisible()&&this.list[t].hide();this.front=null},getActive:function(){return this.front},each:function(t,e){for(var i in this.list)if(this.list[i]&&"function"!=typeof this.list[i]&&!1===t.call(e||this.list[i],this.list[i]))return}}),SYNO.SDS.DefineDesktopView=function(t,e){Ext.define(t,{extend:e,animateShowHideCls:"sds-desktop-view-animate",showCls:"sds-desktop-view-show",constructor:function(t){var e=this;t=t||{},t=Ext.apply(t,{tabIndex:-1,hideMode:"offsets",hidden:!0}),e.callParent([t]),e.initManager(t.manager||SYNO.SDS.DeskTopManager),t.taskBarConfig&&e.initTaskbarButton(t.taskBarConfig),t.trayIconConfig&&e.initTrayIconButton(t.trayIconConfig)},initManager:function(t){var e=this;e.manager=t,e.manager.register(e)},initTaskbarButton:function(t){_S("standalone")||(t=t||{},t=Ext.applyIf(t,{toggleHandler:this.onToggle.createDelegate(this)}),this.taskBarButton=SYNO.SDS.TaskBar.addDesktopViewButton(t))},initTrayIconButton:function(t){_S("standalone")||(t=t||{},t=Ext.applyIf(t,{toggleHandler:this.onToggle.createDelegate(this)}),this.taskBarButton=SYNO.SDS.TaskBar.addTrayIconViewButton(t))},toggleButton:function(t,e){var i=this,n=i.taskBarButton;n&&n.toggle(t,e)},onToggle:function(t,e){this[e?"activeView":"showDesktop"]()},hide:function(){var t=this;t.transitionHandler.start(),t.removeClass(t.showCls),t.callParent(),t.toggleButton(!1,!0)},show:function(){var t=this;t.transitionHandler.start(),t.addClass(t.showCls),t.callParent()},updateTransition:function(t,e){var i=this;e>500&&(i.addClass("no-transition"),i.transitionHandler.un("aftertransition",i.updateTransition,i))},resetTransition:function(){var t=this;t.disableBlur=!1,t.removeClass("no-transition")},activeView:function(){var t=this;t.manager.bringToFront(t),t.focus()},showDesktop:function(){this.manager.showDesktop()},afterRender:function(){var t=this;t.callParent(),t.transitionHandler=t.transitionHandler||new SYNO.SDS.TransitionEndHandler(t.getEl()),t.transitionHandler.on("aftertransition",t.updateTransition,t),Ext.EventManager.onWindowResize(this.onWindowResize,this),t.animateShowHide&&t.addClass(t.animateShowHideCls),t.el.on("mousedown",this.onClick,this),void 0!==t.tabIndex&&t.el.dom.setAttribute("tabIndex",t.tabIndex),t.keyNav=new Ext.KeyNav(t.el,{esc:this.onEnterEsc,scope:this})},onEnterEsc:function(t){this.showDesktop()},onClick:function(t,e){},resize:function(t,e){},getViewSize:function(){return{viewH:Ext.lib.Dom.getViewHeight()-SYNO.SDS.TaskBar.getHeight(),viewW:Ext.lib.Dom.getViewWidth()}},onWindowResize:function(){var t=this,e=t.getViewSize();t.resize(e.viewW,e.viewH)},refresh:function(){},addInstruction:function(){var t=Ext.lib.Dom.getViewHeight()-SYNO.SDS.TaskBar.getHeight(),e=Ext.lib.Dom.getViewWidth();this.instruction=new Ext.Container({cls:"sds-app-widget-instruction",width:e,height:t,items:[{xtype:"box",cls:"message-container",html:_T("desktop","shortcut_zone_instruction")},{xtype:"box",cls:"message-arrow"}],listeners:{afterlayout:function(){var t=this.el.child(".message-container"),e=this.el.child(".message-arrow"),i=.33*this.getHeight();t.alignTo(this.shortcutZoneLeft.el,"tl-tr",[-36,i]),e.alignTo(t,"r-l",[1,5])},scope:this},resize:function(){var t=Ext.lib.Dom.getViewHeight()-SYNO.SDS.TaskBar.getHeight(),e=Ext.lib.Dom.getViewWidth();this.setSize(e,t),this.doLayout()},showTip:function(){this.addClass("show")}}),this.add(this.instruction),this.on("show",this.showInstruction,this)},showInstruction:function(){this.showTaskId=Ext.defer(function(){this.instruction&&(this.shortcutZoneLeft.addClass("on-instruction"),this.shortcutZoneRight.addClass("on-instruction"),this.shortcutZoneBottom&&this.shortcutZoneBottom.addClass("on-instruction"),this.instruction.showTip())},500,this)},removeInstruction:function(){clearTimeout(this.showTaskId),this.resetTransition(),this.instruction&&(this.remove(this.instruction,!0),this.instruction=null,this.shortcutZoneLeft.removeClass("on-instruction"),this.shortcutZoneRight.removeClass("on-instruction"),this.shortcutZoneBottom&&this.shortcutZoneBottom.removeClass("on-instruction"),this.un("show",this.showInstruction,this),this.un("beforehide",this.removeInstruction,this))},destroy:function(){var t=this;t.transitionHandler.un("aftertransition",t.updateTransition,t),t.transitionHandler=null,Ext.EventManager.removeResizeListener(t.onWindowResize,t),Ext.destroy(t.keyNav),t.keyNav=null,t.taskBarButton.getEl().remove(),t.callParent(arguments)}})},SYNO.SDS.DefineDesktopView("SYNO.SDS._DesktopView","Ext.Container"),SYNO.SDS.DefineDesktopView("SYNO.SDS.Box_DesktopView","Ext.BoxComponent"),Ext.define("SYNO.SDS._Logo",{extend:"Ext.Component",theme:"light",logoArray:["synology","DSM"],constructor:function(t){var e=this;t=Ext.applyIf(t||{},{cls:"sds-logo"}),e.callParent([t])},onRender:function(t,e){var i=this;i.callParent(arguments),i.el.addClass(i.theme),Ext.each(i.logoArray,function(t){this[t]=this.el.createChild({cls:"logo-"+t})},i)}}),Ext.define("SYNO.SDS.DSMLogo",{extend:"SYNO.SDS._Logo",logoArray:["synology","DSM","major"],version:2,onRender:function(t,e){var i=this,n=i.version,o=[],s=_S("buildphase").toLowerCase();i.callParent(arguments),n=Ext.isNumber(n)?n:0,n+="",o=n.split(""),Ext.each(o,function(t){this.el.createChild({cls:"logo-"+t})},i),"beta"!==s&&"rc"!==s||(i.el.createChild({cls:"logo-"+s}),i.el.addClass(s))}}),Ext.namespace("SYNO.SDS.LaunchItem"),Ext.define("SYNO.SDS.LaunchItemHelper",{statics:{getGroupReviewIconPosition:function(t,e,i,n){i=Ext.isNumber(i)?i:6,n=Ext.isNumber(n)?n:6;var o=i+e+t-2*e-2*i,s=n+e+t-2*e-2*n;return[{left:i,top:n},{left:o,top:n},{left:i,top:s},{left:o,top:s}]}}}),SYNO.SDS._LaunchItem=Ext.extend(Ext.util.Observable,{getPriviewPositionFn:SYNO.SDS.LaunchItemHelper.getGroupReviewIconPosition.createDelegate(this,[64,24]),iconCategory:"Desktop",shortIconCls:"",manager:null,removable:!1,container:null,el:null,dragEl:null,contextMenu:null,lastClick:0,clickInterval:1e3,iconItems:[],li_el:null,defaultXY:null,specialTarget:{_blank:!0,_self:!0,_parent:!0,_top:!0},constructor:function(t,e){this.allowedCfgProperty=SYNO.SDS.ShortcutUtil.getCfgPropertis(),t.className||t.jsID?this.applyConfig(t):Ext.apply(this,t),Ext.id(this),this.container=Ext.get(e||document.body),this.contextMenu=this.getContextMenu(),this.module=t.module,this.index=t.index,this.el=this.createElement(),this.el.on("click",this.onClick,this),this.dragEl.on("mouseover",this.onMouseOver,this),this.dragEl.on("mousedown",this.onMouseDown,this),this.dragEl.on("contextmenu",this.onContextMenu,this)},applyConfig:function(t){var e,i=SYNO.SDS.Config.FnMap[t.className||t.jsID];i&&(this.className=t.jsID,t.title&&t.icon||Ext.copyTo(this,i.config,this.allowedCfgProperty),Ext.copyTo(this,t,"manager,removable,iconSize,"+this.allowedCfgProperty),this.plaintitle=SYNO.SDS.Utils.GetLocalizedString(this.title||"",this.className),this.title=SYNO.SDS.Utils.GetLocalizedString(this.formatedTitle||this.title||"",this.className),this.desc=SYNO.SDS.Utils.GetLocalizedString(this.desc||"",this.className),e=encodeURI(i.config.jsBaseURL)+"/"+(this.icon||this.icon_32),this.icon=SYNO.SDS.UIFeatures.IconSizeManager.getIconPath(e,this.iconCategory))},remove:function(){return this.isSelected()&&this.manager?void this.manager.removeSelectedItems():this.manager&&"SYNO.SDS.VirtualGroup"==this.manager.className?1===this.manager.subItems.length?void this.manager.remove():(this.manager.subItems.remove(this.managerItemConfig),this.manager.manager.updateItemsSetting(),this.manager.refreshSubItems(),this.manager=null,void this.destroy()):(this.manager&&(this.manager.removeLaunchItem(this),this.manager=null),this.li_el.addClass("launch-icon-remove-animation"),void this.destroy.defer(250,this))},renameHandler:function(){this.showInputField()},showInputField:function(){var t,e=this.li_el.child(".text");e.hide(),this.renameInputField=Ext.getBody().createChild({tag:"input",type:"text",value:this.title||"",maxlength:256,cls:"sds-launch-icon-input"}),t=this.renameInputField,t.setLeft(e.getX()),t.setTop(e.getY()),t.focus(100),t.on("blur",this.onRenameInputBlur,this),t.on("keyup",this.onRenameInputKeyup,this)},onRenameInputBlur:function(t,e,i){var n=this.li_el.child(".text"),o=this.renameInputField;this.title=Ext.util.Format.htmlEncode(e.value),this.managerItemConfig.title=this.title,this.manager.updateItemsSetting(),this.updateGroupTitle(this.title),o.removeAllListeners(),o.remove(),n.show()},onRenameInputKeyup:function(t,e,i){var n=this.renameInputField;t.getKey()===t.ENTER&&n.blur()},destroy:function(){this.closeSubContainer(),this.monitoringMouseOver&&Ext.getDoc().un("mouseover",this.monitorMouseOver,this),this.monitoringMouseMove&&Ext.getDoc().un("mousemove",this.monitorMouseMove,this),this.contextMenu&&(this.contextMenu.destroy(),this.contextMenu=null),this.el&&(this.el.purgeAllListeners(),this.el.remove(),this.el=null)},refreshElementIcons:function(){Ext.each(this.iconEls,function(t){t&&t.remove()},this),this.iconEls=[],this.createVirtualGroupIcon()},getIconStyle:function(){return"SYNO.SDS.VirtualGroup"!==this.className?{"background-image":String.format("url({0})",this.icon||"")}:{}},createElement:function(){var t,e,i,n="",o=!1;if(n=this.desc||this.plaintitle||this.title||"",e=this.container,("standalone"===this.type||!0===this.allowStandalone||"url"===this.type||"legacy"===this.type)&&(this.url||this.urlTag)){var s=this.url||SYNO.SDS.UrlTag[this.urlTag]||"";if((this.port||this.protocol)&&"http"!==s.substr(0,4).toLowerCase()){var r=this.protocol||window.location.protocol,a=this.port||window.location.port||"";a&&(a=":"+a),s=r+"://"+window.location.hostname+a+s}e=e.createChild({tag:"li","aria-label":n,role:"menuitem",href:s,target:this.urlTarget in this.specialTarget?this.urlTarget:this.urlTarget?this.urlTarget+SYNO.SDS.LaunchTime:"_blank"}),t=e,o=!0}return i=e.createChild({tag:"li","ext:qtip":Ext.util.Format.htmlEncode(n),cls:"launch-icon "+this.shortIconCls,cn:[{cls:"image",style:this.getIconStyle()},{cls:"text",html:this.title||""}]}),!1===o&&i.set({"aria-label":n,role:"menuitem"}),this.li_el=i,this.createVirtualGroupIcon(),this.dragEl=i,t||i},getContextMenu:function(){var t=this.launchParams||{},e=[];for(var i in t)t.hasOwnProperty(i)&&e.push({id:this.id+i,text:SYNO.SDS.Utils.GetLocalizedString(i,this.className),handler:this.launchApp.createDelegate(this,[t[i]])});return"standalone"!==this.type&&!0!==this.allowStandalone&&("url"!==this.type&&"legacy"!==this.type||"_self"===this.urlTarget)||e.push({text:_T("desktop","open_in_new_window"),scope:this,handler:this.openNewWindow,useBuffer:!1}),this.manager&&this.removable&&(e.length>0&&e.push("-"),e.push({itemId:"remove_shortcut",text:_T("desktop","remove_shortcut"),scope:this,handler:this.remove})),this.isFileShortcut(this)&&e.push({text:_T("filebrowser","filetable_rename"),scope:this,handler:this.renameHandler}),e.length?new SYNO.ux.Menu({items:e}):null},onContextMenu:function(t){if(t.preventDefault(),this.contextMenu){var e,i,n,o,s=this.contextMenu.getComponent("remove_shortcut"),r=!0;if(Ext.QuickTips.getQuickTip().cancelShow(this.dragEl),e=this.contextMenu.items,this.subItems?Ext.each(this.subItems,function(t){o=SYNO.SDS.Config.FnMap[t.className].config,!1===o.removable&&(r=!1)}):(o=SYNO.SDS.Config.FnMap[this.className].config,!1===o.removable&&(r=!1)),!1===r){if(s){if(1===e.getCount())return;i=e.indexOf(s),n=e.getRange(Math.max(i-1,0),i),n.each(function(t){t.hide()})}}else e.each(function(t){t.show()});this.contextMenu.showAt(t.getXY())}},openNewWindow:function(){SYNO.SDS.WindowLaunch(this.className,this.param,null,this)},onClick:function(t){var e=(new Date).getTime(),i=this.cancelClick||e-this.lastClick<this.clickInterval;return"click"===t.browserEvent.type&&i?void t.stopEvent():(this.lastClick=e,"SYNO.SDS.VirtualGroup"===this.className?(this.createSubContainer(),void this._ul.focus()):(this.manager&&"SYNO.SDS.VirtualGroup"==this.manager.className&&this.manager.closeSubContainer(),"url"===this.type||"standalone"===this.type||!0===this.allowStandalone&&t.hasModifier()||"legacy"===this.type&&("url"===this.urlDefMode||t.hasModifier())?void("_self"===this.urlTarget?window.onbeforeunload=null:(t.stopEvent(),this.openNewWindow())):(t.stopEvent(),void this.launchApp(this.param))))},launchApp:function(t){SYNO.SDS.AppLaunch.defer(100,window,[this.className,t,!0])},onMouseOver:function(t){this.dragEl.addClass("x-btn-over"),this.monitoringMouseOver||(Ext.getDoc().on("mouseover",this.monitorMouseOver,this),this.monitoringMouseOver=!0)},monitorMouseOver:function(t){t.target==this.el.dom||t.within(this.el)||(this.monitoringMouseOver&&(Ext.getDoc().un("mouseover",this.monitorMouseOver,this),this.monitoringMouseOver=!1),this.onMouseOut(t))},onMouseOut:function(t){this.dragEl.removeClass("x-btn-over")},onMouseDown:function(t){this.disabled||0!==t.button||(this.dragEl.addClass("x-btn-click"),Ext.getDoc().on("mouseup",this.onMouseUp,this),this.cancelClick=!1,this.monitoringMouseMove||(Ext.getDoc().on("mousemove",this.monitorMouseMove,this),this.monitoringMouseMove=t.getXY()))},onMouseUp:function(t){0===t.button&&(this.dragEl.removeClass("x-btn-click"),Ext.getDoc().un("mouseup",this.onMouseUp,this))},monitorMouseMove:function(t){if(this.monitoringMouseMove){var e=Ext.dd.DragDropMgr.clickPixelThresh,i=t.getXY(),n=this.monitoringMouseMove,o=Math.abs(n[0]-i[0]),s=Math.abs(n[1]-i[1]);o<=e&&s<=e||(Ext.getDoc().un("mousemove",this.monitorMouseMove,this),delete this.monitoringMouseMove,this.cancelClick=!0)}},createSubItems:function(){var t,e=["subItemsDesc","separator","divCt"];this.iconItems=[],this.uls=[],e.each(function(t){var e=this[t];e&&e.remove()},this),this.subItemsDesc=this.virtualContainer.createChild({tag:"input",type:"text",value:this.title||"",maxlength:64,cls:"sds-sub-container-desc"}),this.subItemsDesc.on("keyup",this.onDescKeyUp,this,{buffer:100}),this.subItemsDesc.on("blur",this.onDescBlur,this),this.separator=this.virtualContainer.createChild({tag:"hr"}),this.divCt=this.virtualContainer.createChild({tag:"div",cls:"sds-sub-container-div-ct"}),t=this.divCt.createChild({tag:"ul",tabindex:0,"aria-lable":this.title||"",role:"listbox",cls:"sds-desktop-shortcut"}),this.uls.push(t),this._ul=t,this.keyNav=new Ext.KeyNav(t,{esc:function(){this.closeSubContainer(),Ext.get("sds-desktop-shortcut").focus()},scope:this}),this.refresh()},onDescKeyUp:function(t,e,i){this.title=Ext.util.Format.htmlEncode(e.value),this.managerItemConfig.title=this.title,this.manager.updateItemsSetting(),this.updateGroupTitle(this.title),t.getKey()===t.ENTER&&this.subItemsDesc.blur()},onDescBlur:function(t,e,i){var n=e.value;Ext.isIE||Ext.isOpera?(e.value="",function(){e.value=n}.defer(10)):Ext.isGecko&&(e.value=n)},updateGroupTitle:function(t){var e=this.li_el,i=e.child(".text");i&&i.update(t),this.desc||e.set({"ext:qtip":t})},removeSubItems:function(){if(this.manager&&"SYNO.SDS.VirtualGroup"==this.manager.className)return this.manager=null,void this.destroy()},createSubContainer:function(){var t,e=Ext.get("sds-desktop");this.iconItems=[],this.uls=[];var i=Ext.getBody();this.shim=i.createChild({tag:"div",id:"sds-sub-container-shim"}),this.shim.on("click",this.onShimClick,this),t=this.virtualContainer=e.createChild({tag:"div",cls:"white-scrollerbar "+(this.shortIconCls||""),id:"sds-sub-container"}),this.arrow=t.createChild({tag:"div",cls:"virtual-group-background"}).createChild({tag:"div",cls:"virtual-group-arrow"}),this.createSubItems(),this.adjustSubContainerPosition(),this.virtualContainer.shift({height:this.virtualContainer.targetHeight,width:this.virtualContainer.targetWidth,easing:"easeIn",duration:.45,callback:function(){},scope:this})},adjustSubContainerPosition:function(){var t,e,i,n=this.el,o=n.getTop(!0),s=n.getLeft(),r=n.getRight(),a=this.virtualContainer,l=this.arrow,S=Ext.get("sds-desktop"),c=S.getHeight(),h=S.getWidth();t=o-48,e=r-24+12,t<0&&(i=84+t,t=0),t+192>c&&(i=t+192-c+84,t=c-192),s>316&&e+316>h&&(e=s-316+24-12,l&&l.addClass("right-arrow")),a.setLeft(e),a.setTop(t),l&&Ext.isNumber(i)&&l.setTop(i)},validTempNode:function(){var t;for(t=0;t<this.subItems.length;++t)if(this.subItems[t]._temp){this.subItems[t]._temp=!1,this.iconItems[t]&&(this.iconItems[t].li_el.show(),this.iconItems[t].li_el._temp=!1);break}return this.manager.updateItemsSetting(),!0},removeTempNode:function(){for(var t=-1,e=0;e<this.subItems.length;++e)if(this.subItems[e]._temp){t=e;break}return!(t<0)&&(this.subItems.splice(t,1),this.manager.updateItemsSetting(),!0)},addSubItem:function(t,e){t._temp=!e,this.subItems.push(t)},validateItems:function(){var t=[];Ext.each(this.subItems,function(e){if(e){var i=e.className||e.jsID;SYNO.SDS.Config.FnMap[i]&&SYNO.SDS.StatusNotifier.isAppEnabled(i)&&t.push(e)}},this),0===t.length?this.remove():this.subItems.length!==t.length&&(this.subItems=t,this.refreshElementIcons())},refresh:function(){var t,e,i=0,n=0;t=this._ul;var o=0,s=0;if(Ext.each(this.subItems,function(r,a){if(r&&SYNO.SDS.Config.FnMap[r.className]){++i,++n,e=this.iconItems[a],e||(e=new SYNO.SDS.LaunchItem(Ext.apply({},{manager:this,removable:!0},r),t),this.iconItems.push(e),e.managerItemConfig=r,r._temp&&(e.li_el._temp=!0,e.li_el.hide()),e.li_el.addClass("transition-cls")),a%3==0&&a>0&&(s++,o=0);var l=0+106*o,S=24+128*s;e.li_el.setLeft(l),e.li_el.setTop(S),o++}},this),t){var r=24+128*s+128;t.setHeight(r),this.updateScrollbar()}},updateScrollbar:function(){var t=this.divCt.dom;t&&t.fleXcroll?t.fleXcroll.updateScrollBars():t&&fleXenv.fleXcrollMain(this.divCt.dom)},refreshSubItems:function(){Ext.each(this.iconItems,function(t){t&&t.removeSubItems()}),this.iconItems=[],Ext.each(this.uls,function(t){t&&t.remove()}),this.uls=[],this.createSubItems(),this.adjustSubContainerPosition()},closeSubContainer:function(){if("SYNO.SDS.VirtualGroup"!=this.className)return!1;Ext.each(this.iconItems,function(t,e){t&&t.removeSubItems()}),this.iconItems=[],Ext.each(this.uls,function(t){t&&t.remove()}),this.uls=[],this.shim&&(this.shim.remove(),this.shim=null);var t=!1;return this.virtualContainer&&(t=!0,this.virtualContainer.remove(),this.virtualContainer=null),this.refreshElementIcons(),t},onShimClick:function(){this.shim.remove(),this.shim=null,this.virtualContainer.remove(),this.virtualContainer=null,this.manager.refresh(),SYNO.SDS.Desktop._containerShown=!1,this.refreshElementIcons()},setMoveIcon:function(t){if(!(t<0||t>=this.subItems.length)){var e=this.subItems[t];if(e){var i=SYNO.SDS.Config.FnMap[e.className];if(i){var n=encodeURI(i.config.jsBaseURL)+"/"+(e.icon||i.config.icon||i.config.icon_32),o=SYNO.SDS.UIFeatures.IconSizeManager.getIconPath(n,this.iconCategory);this._preview.dom.src=o}}}},onMoveIcons:function(t){if(!Ext.dd.DragDropMgr.dragCurrent&&this._preview){var e=this.el.getWidth()+10,i=t.xy[0]-this.el.getLeft();if(!(i>e||i<0)){var n=Math.floor(i/e*this.subItems.length);this.setMoveIcon(n)}}},onMouseOverMoveIcons:function(){!Ext.dd.DragDropMgr.dragCurrent&&this._preview&&(this.setMoveIcon(0),this.icon_holder.addClass("sds-grouping-show-big-preview"))},onMouseOutMoveIcons:function(){this.icon_holder.removeClass("sds-grouping-show-big-preview")},rePosition:function(t,e){var i=t,n=e,o=this.subItems[i],s=this.iconItems[i];this.subItems.splice(n,0,o),this.iconItems.splice(n,0,s),n<i&&i++,this.subItems.splice(i,1),this.iconItems.splice(i,1),this.manager.updateItemsSetting(),this.refresh()},createVirtualGroupIcon:function(){if(this.subItems){var t=this.li_el;this.icon_holder=t.first(),this._background||(this._background=this.icon_holder.createChild({cls:"virtual-group-icon-background"})),this._preview||(this._preview=this.icon_holder.createChild({tag:"img",cls:"sds-grouping-big-preview-icon"}),t.on("mousemove",this.onMoveIcons,this),t.on("mouseover",this.onMouseOverMoveIcons,this),t.on("mouseout",this.onMouseOutMoveIcons,this)),this.iconEls=[];var e=this.getPriviewPositionFn();Ext.each(this.subItems,function(t,i){if(!(i>=4)&&t){var n=SYNO.SDS.Config.FnMap[t.className];if(n){var o=encodeURI(n.config.jsBaseURL)+"/"+(t.icon||n.config.icon||n.config.icon_32),s=SYNO.SDS.UIFeatures.IconSizeManager.getIconPath(o,this.iconCategory);this.iconEls[i]=this.icon_holder.createChild({tag:"img",cls:"sds-grouping-preview-icon",style:String.format("left: {0}px; top: {1}px",e[i].left,e[i].top),src:s})}}},this)}},isSelected:function(){return!!this._selected},setSelected:function(t){this._selected=!!t},blinkForAdd:function(){var t;"SYNO.SDS.VirtualGroup"===this.className&&this.li_el&&(t=this.li_el.child(".image"),t.frame("#000",1,{duration:.5}),t.setStyle("visibility",""))},isFileShortcut:function(t){return!(!t||"SYNO.SDS.App.FileStation3.Instance"!==t.className)&&!(!t.param||!t.param.file_id)}}),Ext.define("SYNO.SDS.Classical._LaunchItem",{extend:"SYNO.SDS._LaunchItem",shortIconCls:"classical",iconCategory:"ClassicalDesktop",getPriviewPositionFn:SYNO.SDS.LaunchItemHelper.getGroupReviewIconPosition.createDelegate(this,[48,16]),adjustSubContainerPosition:function(){var t,e,i,n=this.el,o=n.getTop(!0),s=n.getLeft(),r=n.getRight(),a=this.virtualContainer,l=this.arrow,S=Ext.get("sds-desktop"),c=S.getHeight(),h=S.getWidth();t=o-48,e=r-24+12,t<0&&(i=76+t,t=0),t+176>c&&(i=t+176-c+76,t=c-176),s>316&&e+316>h&&(e=s-316+24-12,l&&l.addClass("right-arrow")),a.setLeft(e),a.setTop(t),l&&Ext.isNumber(i)&&l.setTop(i)},refresh:function(){var t,e,i=0,n=0;t=this._ul;var o=0,s=0;if(Ext.each(this.subItems,function(r,a){if(r&&SYNO.SDS.Config.FnMap[r.className]){++i,++n,e=this.iconItems[a],e||(e=new SYNO.SDS.LaunchItem(Ext.apply({},{manager:this,removable:!0},r),t),this.iconItems.push(e),e.managerItemConfig=r,r._temp&&(e.li_el._temp=!0,e.li_el.hide()),e.li_el.addClass("transition-cls")),a%3==0&&a>0&&(s++,o=0);var l=0+101*o,S=24+112*s;e.li_el.setLeft(l),e.li_el.setTop(S),o++}},this),t){var r=24+112*s+112;t.setHeight(r),this.updateScrollbar()}}}),Ext.define("SYNO.SDS.DesktopShortcutPanel",{extend:"Ext.Container",activeIdx:-1,constructor:function(t){var e={autoEl:{tag:"ul",tabindex:0,role:"menu","aria-label":_T("common","desktop"),id:"sds-desktop-shortcut",cls:"sds-desktop-shortcut"},listeners:{afterrender:{fn:function(){this.getEl().on("keydown",this.onKeyPress,this),this.getEl().on("blur",this.onBlur,this)},scope:this}}};Ext.apply(e,t),this.callParent([e])},onBlur:function(){this.clearSelectCls(),this.getEl().dom.removeAttribute("aria-activedescendant"),this.activeIdx=-1},onKeyPress:function(t){var e=t.getKey(),i=this.activeIdx;e===t.ENTER||e===t.SPACE?(this.module.iconItems[i].onClick(t),t.preventDefault()):e===t.LEFT||e===t.UP?(this.setPrevItem(i),t.preventDefault()):e!==t.RIGHT&&e!==t.DOWN||(this.setNextItem(i),t.preventDefault())},setNextItem:function(t){var e=this.module.iconItems,i=t===e.length-1?0:t+1;if(!(i>e.length-1))return!0===e[i].hidden?void this.setNextItem(i):void this.setActiveItem(i)},setPrevItem:function(t){var e=this.module.iconItems,i=0===t?e.length-1:t-1;if(!(i<0))return!0===e[i].hidden?void this.setPrevItem(i):void this.setActiveItem(i)},setActiveItem:function(t){var e=this.module.iconItems[t];e&&(this.clearSelectCls(),this.getSelectClsEl(e).addClass("sds-desktop-icon-selected"),this.getEl().dom.setAttribute("aria-activedescendant",e.el.dom.id),this.activeIdx=t)},clearSelectCls:function(){var t=this.module.iconItems[this.activeIdx];t&&this.getSelectClsEl(t).removeClass("sds-desktop-icon-selected")},getSelectClsEl:function(t){var e=t.el,i=t.el.child(".launch-icon");return i&&(e=i),e}}),Ext.define("SYNO.SDS.DesktopHotKeyPlugin",{extend:"Ext.util.Observable",init:function(t){this.initHotkeyEvents(),Ext.getBody().on("keydown",this.onKeyDown,this),Ext.getBody().on("keypress",this.onKeyPress,this);var e=SYNO.SDS.UserSettings.getProperty("Desktop","hotkey_disabled");this.hotkeyEnabled=!0!==e},setHotkeyEnabled:function(t){this.hotkeyEnabled=t,SYNO.SDS.UserSettings.setProperty("Desktop","hotkey_disabled",!t)},setHotkeySuspended:function(t){this.hotkeySuspended=t},initHotkeyEvents:function(){var t=[[!1,!0,Ext.EventObject.W,this.onSwitchWindow],[!1,!0,Ext.EventObject.S,this.onFocusDesktop],[!1,!0,Ext.EventObject.Q,this.onToggleAllWin],[!1,!0,Ext.EventObject.H,this.onLaunchHelp],[!1,!0,Ext.EventObject.A,this.onMainMenu],[!0,!1,Ext.EventObject.F,this.onSearch],[!1,!0,Ext.EventObject.P,this.onSearch],[!1,!0,Ext.EventObject.D,this.onSearch],[!1,!0,Ext.EventObject.M,this.onSearch],[!1,!0,Ext.EventObject.V,this.onSearch]];this.Alt_FnMap={},this.Ctrl_FnMap={},this.Ctrl_Alt_FnMap={},Ext.each(t,function(t){t[0]&&t[1]?this.Ctrl_Alt_FnMap[t[2]]=t[3]:t[0]&&!t[1]?this.Ctrl_FnMap[t[2]]=t[3]:!t[0]&&t[1]&&(this.Alt_FnMap[t[2]]=t[3])},this)},onKeyDown:function(t){var e=t.getKey();this.isEventSuspended(t)||(t.altKey&&t.ctrlKey&&e in this.Ctrl_Alt_FnMap?(t.preventDefault(),this.Ctrl_Alt_FnMap[e](t)):t.altKey&&e in this.Alt_FnMap?(t.preventDefault(),this.Alt_FnMap[e](t)):t.ctrlKey&&e in this.Ctrl_FnMap&&(t.preventDefault(),this.Ctrl_FnMap[e](t)))},onKeyPress:function(t){this.isEventSuspended(t)||63===t.getKey()&&(t.preventDefault(),this.showTips(t))},isEventSuspended:function(t){return"text"===document.activeElement.type||"textarea"===document.activeElement.type||"password"===document.activeElement.type||"true"===t.target.contentEditable||this.hotkeySuspended||!1===this.hotkeyEnabled},onSwitchWindow:function(){SYNO.SDS.TaskButtons.setNextItem(),SYNO.SDS.TaskButtons.bringFocusWinUp()},onFocusDesktop:function(){Ext.get("sds-desktop-shortcut").focus()},onToggleAllWin:function(){SYNO.SDS.WindowMgr.toggleAllWin()},onMainMenu:function(){var t=SYNO.SDS.DeskTopManager.isDesktopOnTop()?SYNO.SDS.AppView:SYNO.SDS.Desktop;SYNO.SDS.DeskTopManager.bringToFront(t)},onLaunchHelp:function(){var t=SYNO.SDS.WindowMgr.getActiveAppWindow();t&&t.onClickHelp()},onSearch:function(t){var e="all";switch(t.getKey()){case Ext.EventObject.D:e="document";break;case Ext.EventObject.P:e="image";break;case Ext.EventObject.M:e="audio";break;case Ext.EventObject.V:e="video"}SYNO.SDS.SearchBox.toggleBox(e)},showTips:function(t){SYNO.SDS.AppLaunch("SYNO.SDS.HotkeyMgr.Instance",{target:t.target},!1)}}),Ext.namespace("SYNO.SDS"),Ext.define("SYNO.SDS.DesktopSetting",{statics:{}}),SYNO.SDS.ShortcutUtil={allowedCfgProperty:["jsID","className","param","title","formatedTitle","desc","icon","type","url","urlDefMode","urlTag","urlTarget","launchParams","subItems","icon_16","icon_32","allowStandalone","port","protocol","windowLaunchEncodeFn","windowLaunchDecodeFn"],getCfgPropertis:function(){return this.allowedCfgProperty.join(",")}},SYNO.SDS._StandaloneDesktop=Ext.extend(Ext.BoxComponent,{constructor:function(){SYNO.SDS._StandaloneDesktop.superclass.constructor.call(this,{id:"sds-desktop",style:"background: transparent; top: 0px; background-size: 100% 100%;",renderTo:document.body}),this.onWindowResize(),Ext.EventManager.onWindowResize(this.onWindowResize,this)},onWindowResize:function(){this.el.setHeight(Ext.lib.Dom.getViewHeight());var t=this.el.getBox(),e=SYNO.SDS.DesktopSetting.miniWidth||1e3,i=SYNO.SDS.DesktopSetting.miniHeight||580,n=t.width<=e?"auto":"hidden",o=t.height<=i?"auto":"hidden";this.el.setStyle({"overflow-x":n,"overflow-y":o})}}),Ext.define("SYNO.SDS._Desktop",{extend:"SYNO.SDS.Box_DesktopView",defShortCuts:SYNO.SDS.isNVR?[{className:"SYNO.SDS.PkgManApp.Instance"},{className:"SYNO.SDS.AdminCenter.Application"},{className:"SYNO.SDS.App.FileStation3.Instance"},{className:"SYNO.SDS.HelpBrowser.Application"},{className:"SYNO.SDS.SurveillanceStation"}]:[{className:"SYNO.SDS.PkgManApp.Instance"},{className:"SYNO.SDS.AdminCenter.Application"},{className:"SYNO.SDS.App.FileStation3.Instance"},{className:"SYNO.SDS.HelpBrowser.Application"}],DROP_ALLOWED_CLS:"x-dd-drop-ok-add",DROP_DENIED_CLS:"x-dd-drop-nodrop",REPOSITION_OK_CLS:"x-dd-reposition-ok",CURSOR_OVER_TYPE:{ABOVE_ICON:0,OVER_ICON:1,BELOW_ICON:2},items:null,iconItems:null,updateTask:null,updateDelay:200,ICON_WIDTH:136,ICON_HEIGHT:116,isBeta:!1,opacityHideCls:"sds-desktop-hide",isItemUpdated:!1,constructor:function(){var t=this;SYNO.SDS.DesktopSetting.miniWidth=1e3,SYNO.SDS.DesktopSetting.miniHeight=580,this.allowedCfgProperty=SYNO.SDS.ShortcutUtil.getCfgPropertis(),this.hotkeyPlugin=new SYNO.SDS.DesktopHotKeyPlugin({module:this}),SYNO.SDS._Desktop.superclass.constructor.call(this,{id:"sds-desktop",taskBarConfig:{handler:this.onShowAll.createDelegate(this),tooltip:_T("desktop","show_desktop"),renderTo:"sds-taskbar-showall"},plugins:[this.hotkeyPlugin],hidden:!1,renderTo:document.body}),this.items=[],this.iconItems=[],this.updateTask=new Ext.util.DelayedTask(this.updateItems,this),this.shortcutPanel=new SYNO.SDS.DesktopShortcutPanel({renderTo:"sds-desktop",module:this}),this.mon(this.el,"scroll",function(t){var e=this.el.getBox();return this.el.dom.scrollTop>0&&e.height>=SYNO.SDS.DesktopSetting.miniHeight&&(this.el.dom.scrollTop=-100),t.preventDefault(),!1},this),this.mon(Ext.getBody(),"scroll",function(t,e,i){return e.scrollTop>0&&(e.scrollTop=0),t.preventDefault(),!1},this),this.el.dragZone=new Ext.dd.DragZone(this.el,{ddGroup:"SDSShortCut",proxy:new SYNO.ux.StatusProxy({baseCls:"sds-launch-icon-dragging-proxy"}),validateTarget:function(t,e,i){var n=e.getTarget("li.launch-icon");return!!(SYNO.SDS.Desktop.el.id===e.getTarget().id||n&&Ext.fly(n).findParentNode(".sds-desktop-shortcut"))||(!(!e.getTarget("#sds-sub-container")&&!e.getTarget("#sds-sub-container-shim"))||(this.getProxy().setStatus(this.dropNotAllowed),!1))},getDragData:this.getDragData.createDelegate(this,[],!0),getRepairXY:function(){return this.dragData.repairXY},endDrag:function(t){SYNO.SDS.Desktop.onEndDrag(this.dragData)},onStartDrag:function(e,i){var n=Ext.get(this.dragData.sourceEl).getBox(),o=SYNO.SDS.Desktop.getEl().getBox(),s=Ext.get(this.dragData.sourceEl);s.setVisibilityMode(Ext.Element.VISIBILITY),t.isInSelectState()||s.hide(),this.getProxy().getEl().disableShadow(),this.dragData.sourceEl.initPos=[e-s.getLeft(),i-s.getTop()+30],this.dragData.sourceEl.moving=!1,this.minX=o.x,this.minY=o.y,this.maxX=o.right-n.width,this.maxY=o.bottom-n.height,this.constrainX=!0,this.constrainY=!0;var r=Ext.get("sds-desktop"),a=r.dom.getElementsByTagName("iframe");Ext.each(a,function(t){var e=document.createElement("div");e.addClassName("sds-shim-for-iframe"),Ext.get(t.parentNode).appendChild(e)})}}),this.el.dropZone=new Ext.dd.DropZone(Ext.getBody(),{dropAllowed:"x-dd-drop-ok-add",ddGroup:"SDSShortCut",getTargetFromEvent:function(t){var e=t.getTarget("li.launch-icon");return e&&Ext.fly(e).findParentNode(".sds-desktop-shortcut")?e:null},onNodeOver:this.onNodeOver.createDelegate(this,[],!0),onContainerOver:this.onContainerOver.createDelegate(this,[],!0),onContainerDrop:this.onNotifyDrop.createDelegate(this,[],!0),onNodeDrop:this.onNodeDrop.createDelegate(this,[],!0)}),this.el.dropZone.addToGroup("AppReorderAndShortCut"),this.el.dropZone.addToGroup("AppShortCut"),this.wallpaper=this.createWallpaper(),this.onWindowResize(),Ext.EventManager.onWindowResize(this.onWindowResize,this),this.loadShortcutItems(),this.mon(SYNO.SDS.StatusNotifier,"servicechanged",this.onServiceChanged,this),this.mon(SYNO.SDS.StatusNotifier,"appprivilegechanged",this.onServiceChanged,this),this.mon(SYNO.SDS.StatusNotifier,"urltagchanged",this.refresh,this),this.mon(SYNO.SDS.StatusNotifier,"thirdpartychanged",this.onThirdPartyChanged,this),_S("isMobile")&&_S("is_admin")?this.addMobileEditionButton():t.isBeta&&this.addBetaBugReportButton(),this.el.on("mousedown",this.onDesktopMouseDown,this)},onEndDrag:function(t){
var e=Ext.get(t._fromAppMenu?t.desktopSrcEl:t.sourceEl),i=SYNO.SDS.Desktop;i.isInSelectState()&&(Ext.removeNode(t.ddel),Ext.destroy(i.ddel)),e.show(),Ext.each(SYNO.SDS.Desktop.iconItems,function(t,e){t&&"SYNO.SDS.VirtualGroup"===t.className&&t.validTempNode()});var n=Ext.get("sds-desktop").query(".sds-shim-for-iframe");Ext.each(n,function(t){Ext.removeNode(t)}),this.el.focus()},setDesktopVisible:function(t){Ext.get("sds-desktop").setVisibilityMode(Ext.Element.OFFSETS),this.bugReportButton&&this.bugReportButton.setVisible(t)},hide:function(){this.setDesktopVisible(!1),this.addClass(this.opacityHideCls),this.removeClass(this.showCls),Ext.isIE&&this.callParent()},show:function(){this.setDesktopVisible(!0),this.callParent(),this.removeClass(this.opacityHideCls),this.removeClass("semi-transparent"),this.removeClass("sent-back")},onShowAll:function(){this.showDesktop(),SYNO.SDS.WindowMgr.toggleAllWin(this.taskButton)},isInSelectState:function(){var t=!1;return Ext.each(this.iconItems,function(e){t||e&&e.isSelected()&&(t=!0)},this),t},getEvtXYWithScroll:function(t){return[t.xy[0]+this.el.dom.scrollLeft,t.xy[1]+this.el.dom.scrollTop]},onDesktopMouseDown:function(t,e,i){var n,o=this.el.getLeft(),s=this.getEvtXYWithScroll(t);s[0]>e.scrollWidth||s[1]>e.scrollHeight||t.target===this.el.dom&&(n=Ext.get(document.body),n.on("mousemove",this.onDesktopMouseMove,this),n.on("mouseup",this.onDesktopMouseUp,this),n.on("mouseleave",this.onDesktopMouseLeave,this,{delay:100}),this.el._beginDragPos=s,this._range&&this._range.remove(),this._range=this.el.createChild({tag:"div",cls:"sds-desktop-select-range"}),this._range.setPosition=function(t,e,i){this.setLeft(t[0]-o),this.setTop(t[1]-32),this.setWidth(e),this.setHeight(i)}.createDelegate(this._range),this._range.setPosition(s,0,0))},onDesktopMouseMove:function(t){if(this.el._beginDragPos&&t){var e=this.el._beginDragPos,i=this.getEvtXYWithScroll(t),n=i[0]-e[0],o=i[1]-e[1];i=[n>0?e[0]:i[0],o>0?e[1]:i[1]],n=Math.abs(n),o=Math.abs(o),this._range.setPosition(i,n,o),this.rangeDetectTask=new Ext.util.DelayedTask(this.detectOverlappedObjects,this),this.rangeDetectTask.delay(5)}},onDesktopMouseLeave:function(t){this.cancelRangeDetectTask(),this.endRangeDetect()},onDesktopMouseUp:function(t){this.cancelRangeDetectTask(),this.detectOverlappedObjects(),this.endRangeDetect()},cancelRangeDetectTask:function(){this.rangeDetectTask&&(this.rangeDetectTask.cancel(),this.rangeDetectTask=null)},endRangeDetect:function(){var t=Ext.get(document.body);this._range&&this._range.remove(),this._range=null,delete this.el._beginDragPos,t.un("mousemove",this.onDesktopMouseMove,this),t.un("mouseup",this.onDesktopMouseUp,this),t.un("mouseleave",this.onDesktopMouseLeave,this)},collisionDetect:function(t,e){var i,n;if(t&&e)return i=t.getRegion(),n=e.getRegion(),(i.left<n.right&&i.right>n.right||i.left<n.left&&i.right>n.left||i.left>n.left&&i.right<n.right)&&(i.top>n.top&&i.bottom<n.bottom||i.top<n.bottom&&i.bottom>n.bottom||i.bottom>n.top&&i.top<n.top)},detectOverlappedObjects:function(){var t=0;Ext.each(this.iconItems,function(e,i){e.subItems||(this.collisionDetect(e.li_el,this._range)?(this.selectItem(e,!0),t++):this.selectItem(e,!1))},this),0===t&&Ext.destroy(this.ddel)},selectItem:function(t,e){t&&t.li_el&&t.setSelected&&(t.setSelected(e),e?t.li_el.addClass("sds-desktop-icon-selected"):t.li_el.removeClass("sds-desktop-icon-selected"))},getCursorOverType:function(t,e){var i;return t[0]-e[0],i=t[1]-e[1],i<=17?this.CURSOR_OVER_TYPE.ABOVE_ICON:i>=80?this.CURSOR_OVER_TYPE.BELOW_ICON:this.CURSOR_OVER_TYPE.OVER_ICON},onContainerOver:function(t,e,i){return i.ddText&&t.getProxy().getGhost().update(i.ddText),e.getTarget("#sds-sub-container")?this.REPOSITION_OK_CLS:e.getTarget("#sds-taskbar")?this.DROP_DENIED_CLS:i._fromDesktop||i._fromAppMenu?this.REPOSITION_OK_CLS:this.DROP_ALLOWED_CLS},onNodeOver:function(t,e,i,n){return n._fromSubContainer||this.isSubContainerExist()?this.onSubNodeOver(t,e,i,n):n._fromDesktop||n._fromAppMenu?this.onDesktopNodeOver(t,e,i,n):this.DROP_ALLOWED_CLS},onSubNodeOver:function(t,e,i,n){var o=i.xy,s=Ext.get(t).getXY(),r=[o[0]-s[0],o[1]-s[1]],a=null;this.appendSubItemMode?a=this.getItemFromSubTempNode():n._fromSubContainer?a=this.getItemFromSubNode(n.sourceEl):this._creatingVirtualGroup&&(a=this.getItemFromSubTempNode());var l=this.getItemFromSubNode(t),S=this.iconItems[l[0]];return this.isVirtualGroup(S)?(r[0]>40&&l[1]++,S.rePosition(a[1],l[1]),this.REPOSITION_OK_CLS):this.DROP_ALLOWED_CLS},onDesktopNodeOver:function(t,e,i,n){var o,s,r,a,l,S=this.getItemFromNode(t);if(!((o=n._fromAppMenu?this.getItemFromNode(n.desktopSrcEl):this.getItemFromNode(n.sourceEl))<0||S<0))return s=this.iconItems[o],r=this.iconItems[S],l=this.getCursorOverType(i.xy,Ext.get(t).getXY()),this.cancelDeferTask(),l===this.CURSOR_OVER_TYPE.OVER_ICON?this.nodeOverToGrouping(t,o,S,s,r):(l===this.CURSOR_OVER_TYPE.ABOVE_ICON?(a=this.rePosition.defer(100,this,[o,S]),this.setDeferTaskId(a)):(a=this.rePosition.defer(100,this,[o,S+1]),this.setDeferTaskId(a)),this.REPOSITION_OK_CLS)},rePosition:function(t,e){if(t!==e&&!this.isInSelectState()){var i=this.items[t],n=this.iconItems[t];this.items.splice(e,0,i),this.iconItems.splice(e,0,n),e<t&&t++,this.items.splice(t,1),this.iconItems.splice(t,1),this.updateItemsSetting(),this.refresh()}},isVirtualGroup:function(t){return!(!t||"SYNO.SDS.VirtualGroup"!==t.className)},nodeOverToGrouping:function(t,e,i,n,o){var s,r=this.isVirtualGroup(n),a=this.isVirtualGroup(o);if(n&&o){if(n===o)return this.DROP_ALLOWED_CLS;if(this.isInSelectState())return o.isSelected()?void 0:this.DROP_ALLOWED_CLS;if(t&&a&&!r){var l=Ext.copyTo({},n.managerItemConfig?n.managerItemConfig:n,this.allowedCfgProperty);return s=this.deferTaskToShowFolder.defer(800,this,[i,l]),this.setDeferTaskId(s),this.DROP_ALLOWED_CLS}return!t||a||r?void 0:(s=this.deferCreateVirtualGroup.defer(800,this,[e,i,n,o]),this.setDeferTaskId(s),this.DROP_ALLOWED_CLS)}},deferCreateVirtualGroup:function(t,e,i,n){var o,s;this.backupNode={src:{index:t,item:this.items[t]},dst:{index:e,item:this.items[e]}},this.setOldDstItem(n),n.li_el.hide(),o=this.createNewGroupIcon(e,n,!1),this._containerShown=!0,this._creatingVirtualGroup=!0,o.createSubContainer(),s=Ext.copyTo({},i.managerItemConfig?i.managerItemConfig:i,this.allowedCfgProperty),o.addSubItem(s),o.refresh()},getItemFromSubTempNode:function(){var t=[-1,-1];return Ext.each(this.iconItems,function(e,i){if(t[1]>=0)return!1;Ext.each(e.iconItems,function(e,n){if(e)return e.li_el._temp?(t[0]=i,t[1]=n,!1):void 0})}),t},getItemFromSubNode:function(t){var e=[-1,-1];return Ext.each(this.iconItems,function(i,n){if(i)return!(e[1]>=0)&&void Ext.each(i.iconItems,function(i,o){if(i&&t===i.dragEl.dom)return e[0]=n,e[1]=o,!1})}),e},updateItemsSetting:function(){SYNO.SDS.UserSettings.setProperty("Desktop","ShortcutItems",this.items)},deferTaskToShowFolder:function(t,e){var i=this.iconItems[t];i&&(i.createSubContainer(),e&&(this.appendSubItemMode=!0,i.addSubItem(e),i.refresh()),this._containerShown=!0)},addMobileEditionButton:function(){this.bugReportButton=this.el.createChild({tag:"div",id:"sds-mobile-edition",title:_T("common","mobile_edition")}),this.mon(Ext.fly("sds-mobile-edition"),"click",function(){window.location="?forceDesktop=0"})},addBetaBugReportButton:function(){this.bugReportButton=this.el.createChild({tag:"div",id:"sds-bug-report-container",cn:[{tag:"div",id:"sds-bug-report",title:_T("pkgmgr","report_desc")}]}),this.mon(Ext.fly("sds-bug-report"),"click",function(){_S("is_admin")?SYNO.SDS.AppLaunch("SYNO.SDS.SupportForm.Application"):window.open("http://myds.synology.com/support/beta_dsm_form.php","_blank")})},onWindowResize:function(){this.el.setHeight(Ext.lib.Dom.getViewHeight()-SYNO.SDS.TaskBar.getHeight()),this.el.setWidth(Ext.lib.Dom.getViewWidth());var t=this.el.getBox();this.el.setStyle({"overflow-x":t.width<=SYNO.SDS.DesktopSetting.miniWidth?"auto":"hidden","overflow-y":t.height<=SYNO.SDS.DesktopSetting.miniHeight?"auto":"hidden"}),this.wallpaper.resize(),this.refresh(),this.fireEvent("desktopresize",this)},getDragData:function(t){var e,i,n=this.getItemFromNode(t.getTarget("li.launch-icon"));if(n>=0){if(!(i=this.iconItems[n]))return;if(this.isInSelectState()){if(i.isSelected())return this.getDragDataInSelectState(n,t);this.deselectItems()}return e=i.dragEl.dom.cloneNode(!0),e.style.position="",e.style.left="",e.style.top="",e.id=Ext.id(),{_fromDesktop:!0,ddel:e,sourceEl:i.dragEl.dom,repairXY:i.dragEl.getXY(),SDSShortCut:i.managerItemConfig}}var o=this.getItemFromSubNode(t.getTarget("li.launch-icon")),s=this.iconItems[o[0]];if(s&&!(s&&s.iconItems&&s.iconItems.length<=0)&&(i=s.iconItems[o[1]]))return e=i.dragEl.dom.cloneNode(!0),e.style.position="",e.style.left="",e.style.top="",e.id=Ext.id(),{_fromDesktop:!1,_fromSubContainer:!0,ddel:e,sourceEl:i.dragEl.dom,repairXY:i.dragEl.getXY(),SDSShortCut:i.managerItemConfig}},getDragDataInSelectState:function(t,e){var i,n,o=[];if(i=Ext.getBody().createChild({tag:"div",cls:"sds-desktop-dd-ct"}),Ext.destroy(this.ddel),this.ddel=i,Ext.each(this.iconItems,function(t){var e;t&&t.isSelected()&&(e=t.dragEl.dom.cloneNode(!0),e.id=Ext.id(),o.push(e),i.appendChild(e))},this),n=this.iconItems[t])return i=i.dom.cloneNode(!0),i.style.top="0px",i.id=Ext.id(),{_fromDesktop:!0,ddel:i,sourceEl:n.dragEl.dom,repairXY:n.dragEl.getXY(),SDSShortCut:n.managerItemConfig}},onNodeDropToInsertToGroup:function(t,e,i){var n=this.getItemFromNode(i._fromAppMenu?i.desktopSrcEl:i.sourceEl);n>=0?this.iconItems[n].remove():SYNO.Debug("Failed to get src node when insert to group"),this.appendSubItemMode=!1},onNotifyDrop:function(t,e,i){return!(!e.getTarget("#sds-sub-container")&&"sds-sub-container-shim"!==e.target.id||(this._creatingVirtualGroup&&(this.removeOldDstItem(),this.iconItems[this.backupNode.src.index].remove(),this.updateItemsSetting(),this.refresh(),this.backupNode=null,this._creatingVirtualGroup=!1),this.appendSubItemMode&&this.onNodeDropToInsertToGroup(t,e,i),"sds-sub-container-shim"===e.target.id))||this.onNodeDrop(null,t,e,i)},onNodeDropSelectedToInsertToGroup:function(t,e,i,n){var o,s=this.getItemFromNode(t),r=[];if(!(s<0)&&(o=this.iconItems[s])&&!o.isSelected())return this.isVirtualGroup(o)||(o=this.createNewGroupIcon(s,o,!0)),Ext.each(this.iconItems,function(t,e){var i,n;t&&t.isSelected()&&(n=this.items[e],i=Ext.copyTo({},n.managerItemConfig?n.managerItemConfig:n,this.allowedCfgProperty),o.addSubItem(i,!0),r.push(t))},this),Ext.each(r,function(t){t.remove()},this),o.blinkForAdd(),o.refreshElementIcons(),this.refresh(),!0},createNewGroupIcon:function(t,e,i){var n,o,s;if(!(e<0)&&e){n=Ext.copyTo({},e.managerItemConfig?e.managerItemConfig:e,this.allowedCfgProperty),o={className:"SYNO.SDS.VirtualGroup",title:"New Group",subItems:[n]},s=this.iconItems[t],this.items[t]=o;var r={x:s.li_el.dom.style.left,y:s.li_el.dom.style.top},a=new SYNO.SDS.LaunchItem(Ext.apply({},{manager:this,removable:!0,module:this,index:t},o),this.shortcutPanel.getEl());return a.li_el.setLeft(r.x),a.li_el.setTop(r.y),a.li_el.addClass.defer(500,a.li_el,["transition-cls"]),this.iconItems[t]=a,a.managerItemConfig=this.items[t],!0===i&&s.remove(),a}},onNodeDrop:function(t,e,i,n){var o,s,r,a=-1,l=n.SDSShortCut;if(this.isInSelectState())return this.onNodeDropSelectedToInsertToGroup(t,e,i,n);if(!n._fromFile&&(!l||!l.className)||t&&t===n.sourceEl)return!1;if(t&&(a=this.getItemFromNode(t)),this.cancelDeferTask(),n._fromSubContainer&&"sds-sub-container-shim"===i.target.id){var S=this.getItemFromSubNode(n.sourceEl),c=this.iconItems[S[0]].iconItems[S[1]];c&&c.remove(),this.addLaunchItem(n.SDSShortCut,-1)}else{if(n._fromSubContainer&&i.getTarget("#sds-sub-container")){var h=this.getItemFromSubNode(t),d=this.getItemFromSubNode(n.sourceEl),u=this.iconItems[h[0]];return u.iconItems[h[1]].li_el.show(),u.iconItems[d[1]].li_el.show(),!0}if((n._fromDesktop||n._fromAppMenu)&&i.getTarget("#sds-sub-container"))return this.onNotifyDrop(e,i,n);if(n._fromFile){var g=i.getTarget();g&&Ext.fly(g).findParentNode("div.syno-sds-fs-win",Number.MAX_VALUE)||(o=this.isNodeDropOnIcon(t,e,i,n),o?this.isVirtualGroup(o)?Ext.isArray(n.SDSShortCut)&&(Ext.each(n.SDSShortCut,function(t){var e=Ext.copyTo({},t.config,this.allowedCfgProperty);o.addSubItem(e,!0)},this),o.blinkForAdd(),o.refreshElementIcons()):Ext.isArray(n.SDSShortCut)&&(r=this.createNewGroupIcon(a,o,!0),Ext.each(n.SDSShortCut,function(t){var e=Ext.copyTo({},t.config,this.allowedCfgProperty);r.addSubItem(e,!0)},this),r.blinkForAdd(),r.refreshElementIcons()):this.addLaunchItems(l,a))}else if(n.SDSShortCut&&(n._fromControlPanel||n._fromDesktop||n._fromAppMenu)){o=this.isNodeDropOnIcon(t,e,i,n);var p;if(n._fromDesktop||n._fromAppMenu){var m=this.getItemFromNode(n._fromAppMenu?n.desktopSrcEl:n.sourceEl);p=this.iconItems[m]}o?this.isVirtualGroup(p)||(this.isVirtualGroup(o)?(s=Ext.copyTo({},n.SDSShortCut,this.allowedCfgProperty),o=this.iconItems[a],o.addSubItem(s,!0),o.blinkForAdd(),o.refreshElementIcons(),(n._fromDesktop||n._fromAppMenu)&&p&&p.remove()):p!==o&&(s=Ext.copyTo({},n.SDSShortCut,this.allowedCfgProperty),r=this.createNewGroupIcon(a,o,!0),r.addSubItem(s,!0),r.blinkForAdd(),r.refreshElementIcons(),(n._fromDesktop||n._fromAppMenu)&&p&&p.remove(),this.refresh())):n._fromControlPanel&&this.addLaunchItem(n.SDSShortCut,a)}}return!0},isNodeDropOnIcon:function(t,e,i,n){var o,s=-1;return t&&(s=this.getItemFromNode(t),o=this.getCursorOverType(i.xy,Ext.get(t).getXY())),s>=0&&o===this.CURSOR_OVER_TYPE.OVER_ICON&&this.iconItems[s]},getItemFromNode:function(t){var e=-1;if(t)return Ext.each(this.iconItems,function(i,n){if(i&&t===i.dragEl.dom)return e=n,!1}),e},validateItems:function(){var t=[],e=[];Ext.each(this.items,function(e,i){var n=e.className||e.jsID;if(!_S("ha_safemode")||-1!=n.search("SYNO.SDS.HA")||-1!=n.search("SYNO.SDS.SupportForm")||-1!=n.search("SYNO.SDS.App.FileStation3")){if(this.isVirtualGroup(e))return void t.push(e);if(!this.isHiddenControlPanelModule(n,e)){var o=e.needHide;SYNO.SDS.Config.FnMap[n]?e.needHide=!SYNO.SDS.StatusNotifier.isAppEnabled(n):e.needHide=!0,!0===o&&!1===e.needHide?e.needUpdate=!0:e.needUpdate=!1,t.push(e)}}},this),this.items=t,SYNO.SDS.UserSettings.setProperty("Desktop","ShortcutItems",this.items),Ext.each(this.iconItems,function(t){-1===this.items.indexOf(t.managerItemConfig)&&e.push(t)},this),Ext.each(e,function(t){t.remove()},this),Ext.each(this.iconItems,function(t){this.isVirtualGroup(t)&&t.validateItems()},this)},loadShortcutItems:function(){var t=SYNO.SDS.UserSettings.getProperty("Desktop","ShortcutItems")||this.defShortCuts;t=this.removeDeprecatedShortcutItems(t),Ext.each(t,function(t){this.addLaunchItem(t,-1,!0)},this),this.updateTextColor()},onThirdPartyChanged:function(t,e,i){if("uninstall"===e){var n=[],o={};if(Array.isArray(i)&&i.length>0){for(var s=0;s<i.length;s++){o[i[s]]=!0}for(s=0;s<this.items.length;s++){var r=this.items[s];void 0===o[r.className||r.jsID]&&n.push(r)}}this.items=n,SYNO.SDS.UserSettings.setProperty("Desktop","ShortcutItems",this.items)}},createWallpaper:function(){var t=new SYNO.SDS.DesktopStyleParser;return Ext.getBody().setStyle({backgroundImage:String.format('url("{0}")',t.getDefaultWallpaperPath()),backgroundColor:"transparent",backgroundPosition:"center center",backgroundRepeat:"no-repeat",backgroundSize:"cover"}),new SYNO.SDS.Background(Ext.apply(t.getWallpaperCfg({wallpaper_path:""}),{renderTo:"sds-wallpaper"}))},setBackground:function(t){var e=new SYNO.SDS.DesktopStyleParser;this.wallpaper.destroy(),this.wallpaper=new SYNO.SDS.Background(Ext.apply(e.getWallpaperCfg(t),{renderTo:"sds-wallpaper"}))},updateTextColor:function(t){var e=Ext.apply({},SYNO.SDS.UserSettings.getProperty("Desktop","wallpaper")||{}),i="#FFFFFF";t&&Ext.apply(e,t,{customize_color:!1,customize_wallpaper:!1}),e.customize_color&&(i=e.text_color||"#FFFFFF"),!Ext.isIE9p&&Ext.isIE?(Ext.util.CSS.updateRule("#sds-desktop li.launch-icon .text","color",i),Ext.util.CSS.updateRule("#sds-desktop li.launch-icon .text a","color",i)):Ext.util.CSS.updateRule("#sds-desktop li.launch-icon .text, #sds-desktop li.launch-icon .text a","color",i)},onServiceChanged:function(t,e){for(var i=0;i<this.iconItems.length;i++)this.iconItems[i].className===t&&this.refresh()},addLaunchItemCfg:function(t,e,i){var n=Ext.copyTo({},t,this.allowedCfgProperty);Ext.isNumber(e)&&e>=0?this.items.splice(e,0,n):this.items.push(n),!0!==i&&SYNO.SDS.UserSettings.setProperty("Desktop","ShortcutItems",this.items)},addLaunchItem:function(t,e,i){this.addLaunchItemCfg(t,e,i),this.refresh()},addLaunchItems:function(t,e){Ext.each(t,function(t){this.addLaunchItemCfg(t.config,e||t.pos,t.skipRegister)},this),this.refresh()},addHiddenLaunchItem:function(t,e){var i=Ext.copyTo({},t,this.allowedCfgProperty),n=this.items.push(i)-1;return this.refresh(),this.updateItems(),this.iconItems[n].el.hide(),SYNO.SDS.UserSettings.setProperty("Desktop","ShortcutItems",this.items),n},removeLaunchItem:function(t){t.managerItemConfig&&(this.iconItems.remove(t),this.items.remove(t.managerItemConfig),SYNO.SDS.UserSettings.setProperty("Desktop","ShortcutItems",this.items),this.refresh())},showHideItems:function(t){this.showIcon=t,Ext.each(this.iconItems,function(e,i){!0===t?e.el.show():e.el.hide()},this)},refresh:function(){this.updateTask.delay(this.updateDelay)},updateItems:function(){var t,e,i=0,n=0,o=this.iconItems.length<=0;this.validateItems(),t=this.shortcutPanel.getEl();var s=0,r=this.ICON_WIDTH,a=this.ICON_HEIGHT;Ext.each(this.items,function(l){var S=s*r,c=n*a,h=!1;if(o||(e=this.iconItems[i])&&e.managerItemConfig!==l&&(e=null),l.needUpdate&&(e=this.iconItems[i],e=null,this.iconItems.splice(i,1)),!o&&e&&e.li_el||(e=new SYNO.SDS.LaunchItem(Ext.apply({},{manager:this,removable:!0,module:this,index:i},l),t),e.param&&e.el.addClass("hide-overflow"),this.iconItems.splice(i,0,e),e.managerItemConfig=l,h=!0),this.setShortcutVisible(e,l.needHide),l.needHide)return void++i;c+a>Ext.get("sds-desktop").getHeight()&&(n=0,s++,S=s*r,c=n*a),++i,++n,this.animShortcutNode(e.li_el,S,c,!h)},this),this.el.getBox().width<this.getTotalIconWidth()&&(this.el.setStyle({"overflow-x":"scroll"}),this.fireEvent("desktopresize",this)),this.isItemUpdated=!0,this.fireEvent("desktopupdated")},setShortcutVisible:function(t,e){t.el.setVisible(!e);var i=t.el.dom.childNodes;Ext.each(i,function(t){var i=t.id,n=document.getElementById(i);n&&n.classList.contains("launch-icon")&&(n.style.visibility=e?"hidden":"visible")})},animShortcutNode:function(t,e,i,n){if(t&&t.dom)if(Ext.isIE&&!t.dom.moving){var o=t.getLeft(),s=t.getTop();if(o===e&&s===i)return;n?t.shift({left:e,top:i,easing:"easeOut",duration:.5}):t.setLeftTop(e,i)}else t.dom.moving||(n||t.removeClass("transition-cls"),t.setStyle("left",e+"px"),t.setStyle("top",i+"px"),t.addClass.defer(100,t,["transition-cls"]))},isHiddenControlPanelModule:function(t,e){if("SYNO.SDS.ControlPanel.Instance"===t)return!0;if(!e.param||!e.param.fn)return!1;var i=e.param.fn;return!(!Ext.isDefined(SYNO.SDS.AppPrivilege[i])||!1!==SYNO.SDS.AppPrivilege[i])},msgBox:null,getMsgBox:function(){return this.msgBox&&!this.msgBox.isDestroyed||(this.msgBox=new SYNO.SDS.MessageBoxV5({modal:!0,draggable:!1,renderTo:document.body})),this.msgBox.getWrapper()},removeDeprecatedShortcutItems:function(t){var e=[],i=function(t){if(t.className){for(var e=["SYNO.SDS.LogViewer.Application","SYNO.SDS.App.WelcomeApp.Instance","SYNO.SDS.SystemInfoApp.Application","SYNO.SDS.ControlPanel.Instance","SYNO.SDS.Tutorial.Application"],i=0;i<e.length;i++){if(e[i]==t.className)return!0;if("SYNO.SDS.VirtualGroup"==t.className)for(var n=t.subItems,o=n.length-1;o>=0;o--)e[i]==n[o].className&&t.subItems.splice(o,1)}return!1}},n=function(t){var e=["SYNO.SDS.AdminCenter.WebServices.Main"];return!("SYNO.SDS.AdminCenter.Application"!==t.className||!t.param||!t.param.fn||-1===e.indexOf(t.param.fn))};return Ext.each(t,function(t){i(t)||n(t)||e.push(t)},this),e},isSubContainerExist:function(){return!!Ext.getDom("sds-sub-container")},setDeferTaskId:function(t){this._deferTaskId=t},getDeferTaskId:function(){return this._deferTaskId},cancelDeferTask:function(){var t=this.getDeferTaskId();t>0&&(window.clearTimeout(t),this.setDeferTaskId(0))},getSelectedItems:function(){var t=[];return Ext.each(this.iconItems,function(e){e&&e.isSelected()&&t.push(e)},this),t},removeSelectedItems:function(){Ext.each(this.getSelectedItems(),function(t){t.setSelected(!1),t.remove()},this)},deselectItems:function(){Ext.each(this.getSelectedItems(),function(t){this.selectItem(t,!1)},this)},setOldDstItem:function(t){this._oldDstItem&&this._oldDstItem.remove(),this._oldDstItem=t},removeOldDstItem:function(t){this._oldDstItem&&this._oldDstItem.remove(),this._oldDstItem=null},getTotalIconWidth:function(){var t=Ext.get("sds-desktop").getHeight(),e=Math.floor(t/this.ICON_HEIGHT);return 10+this.ICON_WIDTH*Math.ceil(this.items.length/e)}}),Ext.define("SYNO.SDS.Classical._Desktop",{extend:"SYNO.SDS._Desktop",ICON_HEIGHT:100,getCursorOverType:function(t,e){var i;return t[0]-e[0],i=t[1]-e[1],i<=17?this.CURSOR_OVER_TYPE.ABOVE_ICON:i>=64?this.CURSOR_OVER_TYPE.BELOW_ICON:this.CURSOR_OVER_TYPE.OVER_ICON}}),Ext.define("SYNO.SDS._NewShortcutZone",{extend:"Ext.Container",isDropped:!1,constructor:function(t){this.zoneId=Ext.id(),this.addIconId=Ext.id(),this.type=t.type,this.parentView=t.parentView,this.slideDirection="right"===this.type?"r":"l";var e={cls:"syno-sds-shortcut-zone-wrapper",width:t.width,height:t.height,items:[new Ext.Container({cls:"syno-sds-shortcut-zone "+t.type,id:this.zoneId,autoEl:{cn:[{tag:"div",cls:"add-icon",id:this.addIconId}]},listeners:{afterrender:this.defineFields,scope:this}})]};SYNO.SDS._NewShortcutZone.superclass.constructor.call(this,e)},defineFields:function(){this.zone=Ext.get(this.zoneId),this.addIcon=Ext.get(this.addIconId),this.el.on("mouseenter",this.onMouseEnter,this),this.el.on("mouseleave",this.onMouseLeave,this)},onMouseEnter:function(){this.isDragging&&this.runTask("showDesktop",this.gotoDesktop,500)},onMouseLeave:function(){this.isDragging&&this.removeDelayedTask("showDesktop")},gotoDesktop:function(){this.parentView.fireEvent("gotoDesktop"),this.parentView.showDesktop()},resize:function(t,e){this.setSize({width:t,height:e})},onStartDrag:function(){this.addClass("on-mouse-drag"),this.isDropped=!1,this.isDragging=!0},onEndDrag:function(){this.isDragging=!1,this.removeDelayedTask("showDesktop"),this.isDropped?Ext.defer(this.animateDropped,100,this):this.removeClass("on-mouse-drag")},resetProperties:function(){this.addIcon.hide(),this.addIcon.removeClass("bounce-effect-fast"),this.removeClass("on-dropped"),this.removeClass("on-mouse-drag")},animateDropped:function(){this.addIcon.setXY(this.dropPos),this.addIcon.show(),this.addClass("on-dropped"),this.addIcon.addClass("bounce-effect-fast"),Ext.defer(function(){this.resetProperties()},1e3,this)}}),Ext.define("SYNO.SDS.LoginStyleParser",{extend:"Ext.util.Observable",constructor:function(t){this.isPreview=t.isPreview,this.isBusiness=t.isBusiness,this.parseAppPortalName(),this.parseTpl(),this.callParent()},getParam:function(t){var e;return this.isPreview&&window.opener&&window.opener.previewParam?(e=window.opener.previewParam[t],Ext.isBoolean(e)||(e=Ext.util.Format.htmlEncode(e))):e=_S(t),e},parseAppPortalName:function(){var t=_S("preview_appName")||_S("appName");this.appName=t?t+"_":""},parseTpl:function(){var t=this.getParam("login_style");this.tpl="dark"===t?"dark":"light"},getLoginConfig:function(){var t={tplName:this.tpl,preview:this.isPreview};return Ext.apply(t,this.getTitleConf()),Ext.apply(t,this.getCustomizeLogoConf()),Ext.apply(t,this.getWelcomeMsgConf()),Ext.apply(t,this.getBkgConf()),Ext.apply(t,this.getVersionLogoConf()),Ext.apply(t,this.getFooterConf()),t},getBkgConf:function(){var t=this.getRawBkgConf(),e=t.background_enable,i=t.only_bgcolor;return e?this.isPreview&&this.getParam("new_background")?t.background_path=this.getEncodedPathUrl(this.getParam("login_background_path")):t.background_path=this.getBuiltInPath(t):i?t.background_path=Ext.BLANK_IMAGE_URL:t=this.getDefaultBkgConf(),t},getVersionLogoConf:function(){var t=this.getParam("login_version_logo");return{versionLogo:!Ext.isDefined(t)||t}},getRawBkgConf:function(){return{background_enable:this.getParam("login_background_enable"),background_hd_enable:_S("login_background_hd_enable"),background_pos:this.getParam("login_background_pos")||"fill",only_bgcolor:this.getParam("login_only_bgcolor"),background_color:this.getParam("login_background_color")||"#FFFFFF",ext:_S("login_background_ext"),idx:_S("login_background_seq"),background_width:_S("login_background_width"),background_height:_S("login_background_height")}},getDefaultBkgConf:function(){var t,e=this.isRetina(),i=String.format("webman/resources/images/default/{0}/default_login_background/",e?"2x":"1x"),n={background_pos:"fill",background_path:i+"dsm6_02.jpg?v="+_S("version"),background_color:"#505050"},o={background_pos:"fill",background_path:i+"dsm6_01.jpg?v="+_S("version"),background_color:"#4c8fbf"};if(t="dark"===this.tpl?n:o,SYNO.SDS.isCompatibleMode()){var s=this.getPkgDefBgPath(!0);null!==s?t.background_path=s:(i="webman/resources/images/2x/default_login_background/",t.background_path=i+"dsm7_01.jpg?v="+_S("version"))}return t},isRetina:function(){return SYNO.SDS.UIFeatures.IconSizeManager.getRetinaAndSynohdpackStatus()},isBuiltInBkg2X:function(){var t="default"===this.getParam("login_background_type"),e=this.isRetina();return t&&e},getEncodedPathUrl:function(t){if(SYNO.SDS.isCompatibleMode()&&this.isPreview&&"pkgDefault"===this.getParam("login_background_type"))return t.replace("/usr/syno/synoman/","");var e=new Date;return Ext.urlAppend("webapi/entry.cgi",Ext.urlEncode({api:"SYNO.Core.PersonalSettings",method:"wallpaper",version:1,path:Ext.encode(SYNO.SDS.Utils.bin2hex(t)),preview:e.getTime()}))},getBuiltInPath:function(t){var e=this.isBuiltInBkg2X();if(SYNO.SDS.isCompatibleMode()){var i=this.getPkgDefBgPath(e);if(null!==i&&0===t.idx)return i}return String.format("webman/{0}login_background{1}{2}?id={3}",this.appName,e?"_hd":"",t.ext,t.idx)},getTitleConf:function(){return{login_title:this.getParam("custom_login_title")||_S("hostname")}},getCustomizeLogoConf:function(){var t={logo_enable:this.getParam("login_logo_enable")};return this.isPreview&&t.logo_enable&&this.getParam("new_logo")?t.logo_path=this.getEncodedPathUrl(this.getParam("login_logo_path")):t.logo_enable&&(t.logo_path="webman/"+this.appName+"login_logo"+_S("login_logo_ext")+"?id="+_S("login_logo_seq")),t},getWelcomeMsgConf:function(){return{login_welcome_title:this.getParam("login_welcome_title")||"",login_welcome_msg:this.getParam("login_welcome_msg")||""}},getFooterConf:function(){var t=this.getParam("login_footer_enable_html");return{login_footer_msg:this.getParam("login_footer_msg")||"",login_footer_enable_html:!!Ext.isDefined(t)&&t}},getPkgDefBgPath:function(t){return SYNO.SDS.Session&&SYNO.SDS.Session.appLoginStyle&&SYNO.SDS.Session.appLoginStyle.defaultLoginWallpaper&&SYNO.SDS.Session.appLoginStyle.defaultLoginWallpaperThumbnail?String.format(SYNO.SDS.Session.appLoginStyle.defaultLoginWallpaper,t?"2x":"1x"):null}}),SYNO.SDS.LoginDialog=Ext.extend(Ext.Container,{tplConfig:null,constructor:function(t){this.isAppPortal=!!_S("appIconPath");var e=[];t=t||{},this.tplConfig=this.getTplConfig(t.preview),this.createBackground(),this.createWelcomeInfo(),this.createDialog(),this.createFooterInfo(),e.push(this.backgound),this.footer&&e.push(this.footer),this.welcomeInfo&&e.push(this.welcomeInfo),e.push(this.dialog),this.isAppPortal&&(this.createAppIcon(),e.push(this.appIcon));var i={id:"sds-login",cls:String.format("sds-login-{0} {1}",this.tplConfig.tplName,this.isAppPortal?"app-portal":""),renderTo:document.body,items:e,listeners:{afterrender:{fn:this.createOSLogo,scope:this}}};SYNO.SDS.LoginDialog.superclass.constructor.call(this,Ext.apply(i,t)),Ext.EventManager.onWindowResize(this.onWindowResize,this),this.el.applyStyles("background-color: "+this.tplConfig.background_color),this.onWindowResize(),t.preview||Ext.getDom("login_username")&&Ext.getDom("login_username").focus(),Ext.isSafari&&Ext.defer(this.onWindowResize,1e3,this)},createOSLogo:function(){if(this.tplConfig.versionLogo){var t="light"===this.tplConfig.tplName;this.osLogo=new SYNO.SDS.DSMLogo({id:"sds-login-logo",theme:t?"light":"dark",renderTo:Ext.get("sds-login")})}},createBackground:function(){this.backgound=SYNO.SDS.LoginUtils.createBackground(this.tplConfig,"sds-login-background")},createWelcomeInfo:function(){var t=""!==this.tplConfig.login_welcome_title||""!==this.tplConfig.login_welcome_msg,e=this.tplConfig.logo_enable;(t||e)&&(this.welcomeInfo=new SYNO.SDS.WelcomeInfo({logo_enable:this.tplConfig.logo_enable,logo_path:this.tplConfig.logo_path,login_welcome_title:this.tplConfig.login_welcome_title,login_welcome_msg:this.tplConfig.login_welcome_msg}))},createFooterInfo:function(){if(Ext.isDefined(this.tplConfig.login_footer_msg)&&""!==this.tplConfig.login_footer_msg){var t=this.tplConfig.login_footer_msg.replace(/&nbsp;/g," ");!0===this.tplConfig.login_footer_enable_html&&(t=Ext.util.Format.htmlDecode(t));var e=new Ext.Container({id:"sds-login-footer-msg",html:t});this.footer=new Ext.Container({id:"sds-login-footer",autoHeight:!0,module:this,items:[e]})}},createDialog:function(){var t=new Ext.Container({id:"sds-login-dialog-title",html:this.tplConfig.login_title,autoEl:{"ext:qtip":Ext.util.Format.htmlEncode(this.tplConfig.login_title)}});this.loginForm=this.newForm(),this.dialog=new Ext.Container({id:"sds-login-dialog",autoHeight:!0,module:this,items:[t,this.loginForm]})},createAppIcon:function(){this.appIcon=new Ext.Container({id:"sds-login-icon",autoEl:{tag:"img",src:SYNO.SDS.UIFeatures.IconSizeManager.getAppPortalIconPath(_S("appIconPath"))},style:String.format("width: {0}px",SYNO.SDS.UIFeatures.IconSizeManager.PortalIcon)})},newForm:function(){return new SYNO.SDS.LoginDialog.Form({module:this,tplConfig:this.tplConfig})},destroy:function(){Ext.EventManager.removeResizeListener(this.onWindowResize,this),SYNO.SDS.LoginDialog.superclass.destroy.apply(this,arguments)},onWindowResize:function(){var t=Ext.lib.Dom.getViewWidth(),e=Ext.lib.Dom.getViewHeight();t<840||e<500?this.welcomeInfo&&this.welcomeInfo.hide():this.welcomeInfo&&this.welcomeInfo.show(),this.doAlignDialog(),this.doAlignFooter(t),this.backgound.resize(),this.welcomeInfo&&this.welcomeInfo.resize();var i=Ext.getCmp("sds-login-dialog-combobox");i&&i.isExpanded()&&i.list.alignTo(i.el,i.listAlign[0],i.listAlign[1]),this.updateDialogLayout()},updateDialogLayout:function(){this.doAlignAppIcon()},doAlignDialog:function(){var t=Ext.lib.Dom.getViewHeight()*(.45-.5);Ext.fly("sds-login-dialog").alignTo(document.body,"c-c",[0,-30+t]),Ext.defer(function(){Ext.fly("sds-login-dialog").alignTo(document.body,"c-c",[0,-30+t])},500,this)},doAlignFooter:function(t){if(this.footer){var e=-24;this.tplConfig.versionLogo&&t<=864&&(e=-64),this.footer.el.alignTo(document.body,"b-b",[0,e])}},doAlignAppIcon:function(){var t=Ext.get("login-inner-panel");this.appIcon&&t&&this.appIcon.el.alignTo(Ext.get("login-inner-panel"),"br-br",[16,16])},getTplConfig:function(t){return new SYNO.SDS.LoginStyleParser({isPreview:!0===t,isBusiness:SYNO.SDS.isBusinessModel}).getLoginConfig()}}),SYNO.SDS.LoginDialog.Form=Ext.extend(SYNO.ux.FormPanel,{btnLogin:null,iframe:null,constructor:function(t){if(Ext.fly("sds-login-dialog-form").dom.removeAttribute("style"),this.supportForgetPass=1===_S("login_enable_fp"),this.isAppPortal=!!_S("appIconPath"),this.isPreview=t.tplConfig.preview,window.sessionStorage){var e=window.sessionStorage.getItem("errCode");e&&(this.errCode=e,this.addBrowserVisibility(),window.onbeforeunload=function(){window.sessionStorage.removeItem("errCode")})}this.createSSOcombobox(t.tplConfig.tplName),this.createInputFields(),this.createLoginBtn(),this.createLinks(),this.createStatus()
;var i=[this.userField,this.passField,this.otpField,this.rememberField,this.trustDeviceField,this.btnLogin,this.forgetPassUrl,this.lostPhoneUrl];(this.isSupportSSO()||this.isSupportOIDCSSO())&&i.unshift(this.ssoCombo),this.innerPanel=new SYNO.ux.Panel({id:"login-inner-panel",cls:"login-inner-panel",items:i});var n=this.supportForgetPass?"":"extra-padding",o={applyTo:"sds-login-dialog-form",cls:n,hideMode:"display",standardSubmit:!0,url:"webman/login.cgi",method:"POST",width:320,minHeight:260,unstyled:!0,autoFlexcroll:!1,useGradient:!1,listeners:{afterlayout:{scope:this,fn:this.onAfterLayout},afterrender:{scope:this,fn:this.onAfterRender,single:!0}},items:[this.innerPanel,this.statusField,{xtype:"hidden",name:"__cIpHeRtExT"},{xtype:"hidden",name:"isIframeLogin",value:"yes"},{xtype:"hidden",name:"enable_device_token"},{xtype:"hidden",name:"token"}]};SYNO.SDS.LoginDialog.Form.superclass.constructor.call(this,Ext.apply(o,t)),"no"!==_S("enable_syno_token")&&(this.form.url=Ext.urlAppend(this.form.url,"enable_syno_token="+_S("enable_syno_token")),this.form.el.dom.action=Ext.urlAppend(this.form.el.dom.action,"enable_syno_token="+_S("enable_syno_token")))},getUser:function(){return this.userField.getValue()},getPass:function(){return this.passField.getValue()},validURL:function(t){var e=/^(https?):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,i=/((^https?):\/\/([a-z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*)(:\d+)?$/i,n=t.replace(/https?:\/\/\[/i,"").replace(/\].*$/,"");return!1!==e.test(t)||!1!==i.test(t)||!1!==Ext.form.VTypes.v6ipVal.test(n)||Ext.form.VTypes.urlText},createInputFields:function(){this.userField=new SYNO.SDS.IconTextfield({el:"login_username",fieldLabel:_T("common","username"),iconCls:"user-icon"}),this.passField=new SYNO.SDS.IconTextfield({el:"login_passwd",fieldLabel:_T("common","password"),iconCls:"passwd-icon"}),this.otpField=new SYNO.SDS.IconTextfield({el:"login_otp",fieldLabel:_T("login","enter_otp_desc"),iconCls:"otp-icon",emptyText:_T("login","enter_otp_desc"),validator:function(t){var e=/^[0-9]{6}$/,i=/^[0-9]{8}$/;return!(!e.exec(t)&&!i.exec(t))}}),this.rememberField=new SYNO.ux.Checkbox({id:"login_rememberme",name:"rememberme",width:296,hideLabel:!0,boxLabel:_T("login","rememberme"),disabled:!1}),this.trustDeviceField=new SYNO.ux.Checkbox({id:"login_trudtdevice",name:"trustdevice",width:296,boxLabel:_T("login","trustdevice"),disabled:!1})},createLinks:function(){this.lostPhoneUrl=new SYNO.ux.Button({id:"lost_phone",cls:"link",hidden:!0,text:_T("login","otp_lost_phone_desc"),scope:this,handler:this.lostPhone}),this.forgetPassUrl=new SYNO.ux.Button({id:"forget_pass",cls:"link",hidden:1!==_S("login_enable_fp"),text:_T("login","forget_pass_link"),scope:this,handler:this.onForgetPass})},createStatus:function(){this.statusField=new Ext.form.DisplayField({id:"sds-login-dialog-status",hideLabel:!0,hidden:!0,value:"",listeners:{afterrender:function(){this.el.setARIA({role:"log",live:"assertive"})},scope:this}})},onVisibilityChange:function(){if("visible"===document.visibilityState){var t=new XMLHttpRequest;t.onreadystatechange=function(){if(4===t.readyState&&200===t.status){if(!0===JSON.parse(t.response).success)return void window.location.reload(!0)}},t.open("POST","webman/login.cgi",!0),t.send()}},addBrowserVisibility:function(){document.addEventListener("visibilitychange",this.onVisibilityChange)},removeBrowserVisibility:function(){document.removeEventListener("visibilitychange",this.onVisibilityChange)},createSSOcombobox:function(t){var e=this.isSupportSSO(),i=this.isSupportOIDCSSO(),n=[["local",_T("sso","account_login")]];e&&n.push(["sso",_T("sso","sso_login")]),i&&n.push(["oidc_sso",_T("sso",_S("oidc_sso_profile")+"_sso_login")]),(e||i)&&(this.ssoCombo=new SYNO.ux.ComboBox({xtype:"syno_combobox",width:320,id:"sds-login-dialog-combobox",listClass:"sds-login-"+t+" syno-ux-combobox-list sds-login-dialog-combobox-list",triggerClass:"sds-login-dialog-combobox-trigger",listAlign:["tl-bl?",[0,6]],forceSelection:!0,typeAhead:!0,triggerAction:"all",lazyRender:!0,allowBlank:!1,displayField:"display",valueField:"value",value:"local",hidden:!0,tpl:'<tpl for="."><div ext:qtip="{display}" class="x-combo-list-item">{display}</div></tpl>',store:new Ext.data.ArrayStore({fields:["value","display"],data:n}),listeners:{scope:this,expand:function(t){t.list.setZIndex(19999)},select:function(t,e,i){this.onLoginTypeChange(e.get("value"))}}}))},createLoginBtn:function(t){this.btnLogin=new SYNO.ux.Button({xtype:"syno_button",btnStyle:"blue",text:_T("common","dsm_login"),id:"login-btn",width:280,height:40,scope:this,disabled:t,handler:this.onClickLogin})},onAfterLayout:function(){if(!this.initLayout)return SYNO.SDS.SSOUtils.init(Ext.emptyFn,this),void(this.initLayout=!0)},onAfterRender:function(){this.otpField.hide(),this.trustDeviceField.hide(),this.rememberField.setValue("1"===Ext.util.Cookies.get("stay_login")),this.form.el.dom.onsubmit=this.onSubmit.createDelegate(this),this.showLoginComboBox(),this.isPreview&&this.setFormDisabled(!0),this.errCode&&this.setError(SYNO.API.Errors.common[this.errCode])},onForgetPass:function(){var t=this.module;t.el.fadeOut({callback:function(){t.destroy(),(new SYNO.SDS.ForgotPassPage).el.fadeIn({duration:1})}})},setFormRemove:function(){this.userField.hide(),this.btnLogin.hide()},setFormDisabled:function(t,e){this.userField.setDisabled(t),this.passField.setDisabled(t),this.rememberField.setDisabled(t),this.forgetPassUrl.setDisabled(t),this.btnLogin.setDisabled(t),this.trustDeviceField.setDisabled(t),e&&(this.userField.setDisabled(!1),this.passField.setDisabled(!1))},initIFrameEvent:function(){var t=this;t.iframe||(t.iframe=Ext.get("login_iframe"),Ext.isIE?t.iframe.dom.onreadystatechange=function(){"complete"!==this.readyState&&"loaded"!==this.readyState||t.onCallback()}:t.iframe.dom.onload=function(){t.onCallback()})},onClickLogin:function(){if(!1===this.onSSOLogin()){Ext.getDom("login_submit").click();var t=this.ssoCombo;t&&(t.isExpanded()&&t.collapse(),t.setDisabled(!0))}},isSlowModel:function(){var t=["synology_armada370_216se","synology_armada370_ds115j","synology_armada370_rs214","synology_armada370_414slim","synology_armada370_214se","synology_armada370_114","synology_armada370_213j","synology_88f6282_413j","synology_88f6282_213","synology_88f6282_213air","synology_88f6282_rs812","synology_88f6282_rs212","synology_x86_712+","synology_88f6282_212+","synology_88f6282_212","synology_88f6281_212j","synology_88f6282_112+","synology_88f6282_112","synology_88f6281_112j","synology_88f6282_411","synology_88f6281_411j","synology_88f6282_411slim","synology_88f6282_211+","synology_88f6282_211","synology_88f6281_211j","synology_88f6282_111"],e=_D("unique");return t.indexOf(e)>=0},onSubmit:function(){return this.blShowOTPField&&!this.otpField.validate()?(this.setMsg(_T("login","otp_wrong_input_format")),!1):(Ext.getDom("login_submit").focus(),this.setFormDisabled(!0),this.setMsg(_T("common","msg_waiting")),this.isResponed=!1,this.isSlowModel()&&window.setTimeout(function(){this.isResponed||this.setMsg(_T("login","error_system_getting_ready"))}.bind(this),2e4),SYNO.API.currentManager.requestAPI("SYNO.API.Encryption","getinfo",1,{format:"module"},this.onEncryptParams,this),!1)},stdTimezone:function(){var t=(new Date).getFullYear(),e=new Date(t,0,1),i=new Date(t,6,1);return e.getTimezoneOffset()>=i.getTimezoneOffset()?e.format("P"):i.format("P")},onEncryptParams:function(t,e,i){var n=this.form.findField("__cIpHeRtExT"),o="",s=this.form.findField("enable_device_token");t&&(SYNO.Encryption.CipherKey=e.cipherkey,SYNO.Encryption.RSAModulus=e.public_key,SYNO.Encryption.CipherToken=e.ciphertoken,SYNO.Encryption.TimeBias=e.server_time-Math.floor(+new Date/1e3));var r,a={},l="local",S=this.ssoCombo;S&&(l=this.ssoCombo.getValue()),r={username:this.getUser(),passwd:this.getPass(),logintype:l,OTPcode:this.otpField.getValue(),rememberme:this.rememberField.getValue()?1:0,timezone:this.stdTimezone()},a=SYNO.Encryption.EncryptParam(r),o=a[e.cipherkey]||"",n.setValue(o),s.setValue(this.trustDeviceField.getValue()?"yes":"no");var c=new Date;c.setDate(c.getDate()+60),Ext.util.Cookies.set("stay_login",this.rememberField.getValue()?1:0,c);var h=""===o;if(this.initIFrameEvent(),h&&(!navigator||navigator.onLine)&&!1===window.confirm(_T("login","error_key_invalid")))return this.clearMsg(),this.setFormDisabled(!1),S&&S.setDisabled(!1),void this.passField.setValue("");this.setFormDisabled(!0,h),this.form.el.dom.submit()},launchOTPwizard:function(){var t=new SYNO.SDS.LoginStyleParser({isPreview:!1,isBusiness:"business"===_S("theme_cls")}),e=t.getDefaultBkgConf(),i=e.background_path,n=Ext.get("sds-login-background").dom.firstChild;n&&(n.style.display="none");new SYNO.SDS.Background({id:"sds-steup-otp-background",renderTo:"sds-login-background",type:"fill",imgSrc:i,tplName:"tpl1"}),this.module.welcomeInfo&&(this.module.welcomeInfo.destroy(),this.module.welcomeInfo=null);var o=Ext.get("sds-login-icon");o&&o.hide(),Ext.get("sds-login-dialog").hide();var s={module:this,username:this.getUser(),passwd:this.getPass(),isLDAP:this.isLDAP,modal:!1,draggable:!1,closable:!1,renderTo:"sds-login"};this.OTPwizard=new SYNO.SDS.EnforceOTPWizard(s),this.OTPwizard.onOpen()},onCallback:function(){this.form.findField("token").setValue("");var t,e,i,n=!1;this.isResponed=!0;try{e=Ext.fly(this.iframe.dom.contentWindow.document.body),i=e.first("#synology",!0);var o=Ext.util.Format.htmlDecode(i.innerHTML);if(t=Ext.decode(o),!0===t.success&&!0===t.setup_otp)this.isLDAP=t.is_ldap,this.launchOTPwizard();else if(!0===t.success)Ext.isEmpty(SYNO.SDS.Session)&&(SYNO.SDS.Session={}),Ext.isEmpty(t.SynoToken)||(SYNO.SDS.Session.SynoToken=encodeURIComponent(t.SynoToken)),n=!0,this.removeBrowserVisibility(),SYNO.SDS.initData(),this.setMsg(_T("common","loading")),Ext.isIE?this.iframe.dom.onreadystatechange=Ext.emptyFn:this.iframe.dom.onload=Ext.emptyFn,this.iframe.dom.src="about:blank";else if(t.request_pwdchange)if(t.external_url){var s=Ext.urlAppend(t.external_url,Ext.urlEncode({callback_url:window.location.href}),!1);window.location.href=s}else{var r=this.module,a=this.getUser(),l=this.getPass(),S=window.location.pathname,c="error_pwd_expired"===t.reason?_T("passwd","passwd_expired"):_T("passwd","passwd_stronger");r.el.fadeOut({callback:function(){r.destroy(),new SYNO.SDS.ChangeUserPassPage({title:c,username:a,passwd:l,path:S}).el.fadeIn({duration:1})}})}else if(!0===t.request_otp)this.blShowOTPField=!0,this.clearMsg();else if(t.reason){if("error_otp_failed"===t.reason)this.blShowOTPField=!0;else{this.passField.setValue(""),this.passField.focus("",1);var h=Ext.getCmp("sds-login-dialog-combobox");h&&h.setDisabled(!1)}this.setError(_T("login",t.reason))}else this.setError(_T("common","error_system"))}catch(t){_T("common","error_system")}this.setFormDisabled(!1),this.blShowOTPField?(this.showOTPField(),n||"error_otp_failed"!==t.reason||(this.otpField.setValue(""),this.otpField.focus("",1))):n||"error_otp_failed"==t.reason||Ext.getDom("login_passwd").focus(),this.isSupportSSO()&&"login"===SYNOSSO.status&&!n&&SYNOSSO.logout(Ext.emptyFn)},showOTPField:function(){this.forgetPassUrl.hide(),this.userField.hide(),this.passField.hide(),this.otpField.show(),this.trustDeviceField.show(),this.rememberField.hide(),this.lostPhoneUrl.show(),this.otpField.focus(),this.hideLoginComboBox(),this.hideAppIcon()},hideAppIcon:function(){this.isAppPortal&&(this.module.removeClass("app-portal"),this.module.appIcon.hide())},lostPhone:function(){this.sendWebAPI({api:"SYNO.Core.OTP.Mail",method:"send",version:1,params:{username:this.getUser()},scope:this,callback:function(t,e,i){var n=_T("login","unknown_otp_err");t?this.setMsg(_T("login","otp_mail_success")):e.errors&&e.errors.err?this.setError(_T("login",e.errors.err)):this.setError(n)}})},setError:function(t){this.statusField.addClass("error"),this.setStatus(t)},setMsg:function(t){this.statusField.removeClass("error"),this.setStatus(t)},clearMsg:function(){this.statusField.setValue(""),this.statusField.removeClass("error"),this.statusField.hide()},setStatus:function(t){this.statusField.setValue(t),this.statusField.show(),this.module.doAlignAppIcon()},isSupportSSO:function(){return SYNO.SDS.SSOUtils.isSupport()},isSupportOIDCSSO:function(){if(!_S("oidc_sso_enable")||"https:"!==location.protocol)return!1;if(!_S("oidc_redirect_uri"))return!1;if(!this.validURL(_S("oidc_redirect_uri")))return!1;var t=document.createElement("a");return t.href=_S("oidc_redirect_uri"),t.hostname===location.hostname},onLoginTypeChange:function(t){var e="local"===t,i=e&&this.supportForgetPass;this.userField.setVisible(e),this.passField.setVisible(e),this.forgetPassUrl.setVisible(i),i?this.el.removeClass("extra-padding"):this.el.addClass("extra-padding"),Ext.getCmp("login-btn").setText(e?_T("common","dsm_login"):_T("common","alt_next")),Ext.util.Cookies.set("login_type",t),this.module.updateDialogLayout()},showLoginComboBox:function(){var t=this.isSupportSSO(),e=this.isSupportOIDCSSO();if(t||e){var i=this.ssoCombo;if(!i.isVisible()){var n=Ext.util.Cookies.get("login_type")||"local";!0===_S("sso_default_login")&&(n="sso"),i.setVisible(!0),i.setValue(n),this.onLoginTypeChange(n)}}},hideLoginComboBox:function(){var t=this.isSupportSSO(),e=this.isSupportOIDCSSO();if(t||e){var i=this.ssoCombo;i.isVisible()&&"sso"!==i.getValue()&&"azure_sso"!==i.getValue()&&"websphere_sso"!==i.getValue()&&i.setVisible(!1)}},onSSOLogin:function(){var t=this.isSupportSSO(),e=this.isSupportOIDCSSO();if(!(t||e))return!1;if("oidc_sso"===this.ssoCombo.getValue()){if("azure"===_S("oidc_sso_profile"))return SYNO.SDS.AzureSSOUtils.login(this.onOIDCSSOCallback,this),!0;if("websphere"===_S("oidc_sso_profile"))return SYNO.SDS.WebSphereSSOUtils.login(this.onOIDCSSOCallback,this),!0}return"sso"===this.ssoCombo.getValue()&&(SYNO.SDS.SSOUtils.login(this.onSSOCallback,this),!0)},onSSOCallback:function(t){if("login"===t.status&&t.access_token&&40===t.access_token.length)this.sendWebAPI({api:"SYNO.Core.Directory.SSO.utils",method:"exchange",version:1,params:{token:t.access_token},scope:this,callback:this.onGotSSOUsername});else if(t.token){this.setMsg(_T("common","msg_waiting"));var e=this.passField,i=this.userField;e.hide(),i.hide(),this.form.findField("token").setValue(t.token),i.setValue(""),Ext.getDom("login_submit").click();var n=Ext.getCmp("sds-login-dialog-combobox");n.isExpanded()&&n.collapse(),n.setDisabled(!0)}},onOIDCSSOCallback:function(t,e){var i=function(e){if(window.removeEventListener("message",i),e.source.close(),e.data.success)SYNO.SDS.initData(),location.reload();else{var n=_T("login",e.data.reason)||_T("login","error_cantlogin");t.setError(n)}}.createDelegate();i(e)},onGotSSOUsername:function(t,e,i,n){if(!t)return void this.setError("SSO login fail");this.setMsg(_T("common","msg_waiting"));var o=this.passField,s=this.userField;o.hide(),s.hide(),o.setValue("SYNOSSOLOGIN"+i.token),s.setValue(e.user.replace("\\\\","\\")),Ext.getDom("login_submit").click();var r=Ext.getCmp("sds-login-dialog-combobox");r.isExpanded()&&r.collapse(),r.setDisabled(!0)}}),Ext.define("SYNO.SDS.IconTextfield",{extend:"Ext.Container",constructor:function(t){this.icon=new Ext.BoxComponent({cls:"icon "+(t.iconCls?t.iconCls:"")}),this.input=t.input||new Ext.form.TextField({cls:"textfield",el:t.el,inputType:t.inputType,fieldLabel:t.fieldLabel||null,emptyText:t.emptyText||null,validator:t.validator||null});var e={width:t.width,cls:String.format("sds-icon-text-field {0}",t.cls||""),items:[this.icon,this.input]};this.callParent([e])},getValue:function(){return this.input.getValue()},setValue:function(t){this.input.setValue(t)},setDisabled:function(t){this.input.setDisabled(t)},setEmptyText:function(t){this.input.emptyText=t,this.input.applyEmptyText()},focus:function(){this.input.focus(arguments)},validate:function(){return this.input.validate()}}),Ext.define("SYNO.SDS.IconPasswordfield",{extend:"SYNO.SDS.IconTextfield",constructor:function(t){var e={input:new SYNO.ux.PasswordField({cls:"textfield",el:t.el,inputType:t.inputType,fieldLabel:t.fieldLabel||null,emptyText:t.emptyText||null,validator:t.validator||null,updateWhenRender:!1,startValidate:!1,listeners:{afterrender:function(){this.hidePasswordStrength()},password_strength_get:function(){this.showPasswordStrength()}}})};Ext.apply(e,t),this.callParent([e])}}),SYNO.SDS.LoginUtils={createBackground:function(t,e){return new SYNO.SDS.Background({id:e||Ext.id(),cls:"sds-login-background",type:t.background_pos,imgSrc:t.background_path,bgColor:t.background_color,tplName:t.tplName})}},Ext.namespace("SYNO.SDS.QuickConnect"),Ext.define("SYNO.SDS.QuickConnect.Main",{extend:"Ext.Component",DOMAIN:"QuickConnect.to",DOMAIN_PATTERN:/^.+\.quickconnect\.[^.]+$/,construtor:function(){this.callParent([{hidden:!0}])},TYPES:{NORMAL:"NORMAL",DIRECT:"DIRECT",TUNNEL:"TUNNEL"},SUB_DOMAIN_MAPPING:{NORMAL:"",DIRECT:"/direct/",TUNNEL:"/tunnel/"},aliasToPortalUrl:function(t,e){return void 0!==e&&""!==e||(e=this.DOMAIN),this.generatePortalUrl(this.TYPES.NORMAL,t,e)},getPortalUrl:function(t,e,i){if(void 0===this.SUB_DOMAIN_MAPPING[t])return!1;if("function"!=typeof e)return!1;if(void 0===this.callback_queue){this.callback_queue=[];var n={api:"SYNO.Core.QuickConnect",method:"get",version:1,scope:this,callback:this.processReturnData};this.sendWebAPI(n)}return this.callback_queue.push({callback:e,scope:i,type:t}),!0},isInTunnel:function(){return this.DOMAIN_PATTERN.test(window.location.hostname.toLowerCase())},processReturnData:function(t,e,i){for(var n=t&&void 0!==e.server_alias&&void 0!==e.region&&void 0!==e.enabled&&!0===e.enabled,o=0;o<this.callback_queue.length;++o){var s="",r=this.callback_queue[o].callback,a=this.callback_queue[o].scope;if(n){var l=this.callback_queue[o].type;s=this.generatePortalUrl(l,e.server_alias,e.domain,e.region)}else s=void 0===e.error||void 0===e.error.code?"":e.error.code;r.apply(a,[n,s])}delete this.callback_queue},generatePortalUrl:function(t,e,i,n){var o=this.SUB_DOMAIN_MAPPING[t],s=t==this.TYPES.NORMAL,r=s?"http":"https";return i=i.replace(/quickconnect/i,"QuickConnect"),s?r+"://"+i+"/"+e:r+"://"+e+"."+n+"."+i+o}}),SYNO.SDS.QuickConnect.Utils=new SYNO.SDS.QuickConnect.Main,Ext.define("SYNO.SDS.Sharing.ErrorDialog",{extend:"SYNO.ux.Panel",constructor:function(t){var e={renderTo:document.body,cls:"syno-sds-sharing-errordialog",height:112,floating:!0,shadow:!1,items:[{type:"box",cls:"sharing-error-icon"},{type:"box",cls:"sharing-error-msg",html:t.errorMsg}],listeners:{scope:this,afterlayout:this._onAfterLayout}};Ext.apply(e,t),this.callParent([e])},_onAfterLayout:function(){this.getEl().alignTo(document.body,"c-c")}}),Ext.define("SYNO.SDS.Sharing.ErrorHandler",{singleton:!0,REASON:{permission:0,invalid:1,error:2,timeout:3,invalid_entry:4},MSG:{0:_JSLIBSTR("uicommon","error_noprivilege"),1:_T("error","error_page"),2:_T("error","error_error_system"),3:_T("error","error_timeout"),4:_T("sharing","error_invalid_entry")},toErrorPage:function(t){SYNO.SDS.Desktop&&SYNO.SDS.Desktop.hide(),Ext.getBody().mask().addClass("desktop-timeout-mask"),window.location.href="/sharing/errors?sharing_error="+t},initErrorPage:function(t){new SYNO.SDS.Sharing.ErrorDialog({errorMsg:this.MSG[t]})}}),Ext.define("SYNO.SDS.Sharing.Logout",{singleton:!0,logoutTriggered:!1,action:function(t){this.logoutTriggered||(window.onbeforeunload=null,this.logoutTriggered=!0,t===SYNO.SDS.Sharing.ErrorHandler.REASON.timeout?(window.alert(SYNO.SDS.Sharing.ErrorHandler.MSG[t]),this.reload()):SYNO.SDS.Sharing.ErrorHandler.toErrorPage(t))},reload:function(){window.location.reload()}}),SYNO.SDS.Utils.Logout.redirect=SYNO.SDS.Sharing.Logout.reload,Ext.ns("SYNO.SDS.Sharing"),SYNO.SDS.Sharing.LoginHandler=function(t){SYNO.SDS.Sharing.LoginDialog||(SYNO.SDS.Sharing.LoginDialog=new SYNO.SDS.Sharing._LoginDialog(t))},Ext.define("SYNO.SDS.Sharing._LoginDialog",{extend:"Ext.Container",constructor:function(t){this.loginType=t;var e=[];this.dialog=this.createLoginDialog(),this.wrapper=this.createLoginWrapper(),this.footer=this.createFooter(),e.push(this.wrapper),e.push(this.footer);var i="";Ext.isObject(_S("sharing_theme"))&&_S("sharing_theme").color&&(i+=" syno-sds-sharing-login-dialog-"+_S("sharing_theme").color);var n={cls:"syno-sds-sharing-login-dialog"+i,renderTo:document.body,items:e};this.callParent([n]),this._onResize(),Ext.EventManager.onWindowResize(this._onResize,this)},createLoginDialog:function(){return new SYNO.SDS.Sharing.LoginForm({owner:this,loginType:this.loginType})},createLoginWrapper:function(){return new SYNO.ux.Panel({cls:"login-wrapper",items:[{xtype:"box",cls:"login-image"},{xtype:"box",cls:"login-title",html:this.getProtectTitle()||_T("sharing","link")},this.dialog]})},createFooter:function(){return new SYNO.ux.Panel({cls:"login-footer",items:[{xtype:"box",cls:"login-footer-box",html:String.format("Copyright &copy; {0} Synology Inc.",(new Date).getFullYear())}]})},getProtectTitle:function(){var t=_S("protect_title");return Ext.isObject(t)?t.app_name?_TT(t.app_name,t.section,t.key):_T(t.section,t.key):Ext.util.Format.htmlEncode(t)},_onResize:function(){var t=Ext.lib.Dom.getViewHeight(),e=this.wrapper.getEl().getHeight(),i=this.footer.getEl().getHeight(),n=t-e-i;this.wrapper.getEl().alignTo(document.body,"t-t",[0,1*n/2.3])},destroy:function(){Ext.EventManager.removeResizeListener(this._onResize,this),this.callParent(arguments)}}),Ext.define("SYNO.SDS.Sharing.LoginController",{extend:"Ext.util.Observable",statics:{ERRCODE_MAP:{1e3:_T("error","error_error_system"),1001:_T("common","err_pass"),1002:_T("error","error_privilege_not_enough"),1003:_T("login","error_cantlogin"),1008:_T("login","error_maxtried"),1012:_T("sharing","err_expire_times")}},constructor:function(){this.callParent(arguments),this.addEvents("beforelogin","login","loginerror")},submit:function(t){t.sharing_id=_S("sharing_id"),SYNO.API.Request({api:"SYNO.Core.Sharing.Login",method:"login",version:1,params:t,scope:this,callback:function(t,e){if(t)this.fireEvent("beforelogin")&&(SYNO.SDS.Sharing.Init.initData(),this.fireEvent("login"));else{var i=SYNO.SDS.Sharing.LoginController.ERRCODE_MAP[e.code]||SYNO.API.Errors.common[e.code];this.fireEvent("loginerror",e.code,i)}},encryption:["password","dsm_username","dsm_password","sharing_id"]})}}),Ext.define("SYNO.SDS.Sharing.LoginForm",{extend:"SYNO.ux.Panel",constructor:function(t){this.onlyPassword="password"===t.loginType,this.createInputFields(),this.createLoginBtn();var e={cls:"login-form",items:[{xtype:"syno_panel",items:[this.userField]},{xtype:"syno_panel",items:[this.passField]},this.loginBtn,this.errMsgBox=new Ext.BoxComponent({cls:"login-error"})],listeners:{scope:this,afterlayout:this.applySharingLayout}};Ext.apply(e,t),this.callParent([e]),_S("preview")&&this.setFormDisabled(!0),this.attachLoginController()},attachLoginController:function(){this.loginController=new SYNO.SDS.Sharing.LoginController,this.mon(this.loginController,"loginerror",this.onLoginError,this),this.mon(this.loginController,"login",this.onAfterLogin,this)},createInputFields:function(){this.userField=new SYNO.ux.TextField({fieldLabel:_T("common","username"),emptyText:_T("common","username"),enableKeyEvents:!0,hideLabel:!0,listeners:{scope:this,keydown:this.onKeyDown}}),this.passField=new SYNO.ux.TextField({fieldLabel:_T("common","password"),emptyText:_T("common","password"),textType:"password",enableKeyEvents:!0,hideLabel:!0,listeners:{scope:this,keydown:this.onKeyDown}}),this.onlyPassword&&this.userField.hide()},onKeyDown:function(t,e){Ext.EventObject.ENTER===e.getKey()&&this.onSubmit()},applySharingLayout:function(){this.onlyPassword?this.passField.focus("",1):this.userField.focus("",1)},createLoginBtn:function(t){this.loginBtn=new SYNO.ux.Button({cls:"login-btn",xtype:"syno_button",btnStyle:"blue",text:_T("common","enter"),minWidth:84,scope:this,disabled:t,handler:this.onSubmit})},setFormDisabled:function(t){this.userField.setDisabled(t),this.passField.setDisabled(t),this.loginBtn.setDisabled(t),this.onlyPassword&&this.userField.hide()},setError:function(t){this.errMsgBox.update(t)},onLoginError:function(t,e){this.setError(e),this.setFormDisabled(!1)},onAfterLogin:function(){this.owner.destroy.defer(1e3,this.owner)},onSubmit:function(){var t={};this.onlyPassword?Ext.apply(t,{password:this.passField.getValue()}):Ext.apply(t,{dsm_username:this.userField.getValue(),dsm_password:this.passField.getValue()}),this.loginController.submit(t),this.setFormDisabled(!0)}}),Ext.define("SYNO.SDS.Sharing.PreviewDialog",{extend:"Ext.form.FormPanel",constructor:function(t){t=t||{},Ext.fly("sds-apply-preview-form").dom.removeAttribute("style"),this.callParent([SYNO.LayoutConfig.fill(Ext.apply({applyTo:"sds-apply-preview-form",unstyled:!0,items:[{synotype:"desc",value:_T("dsmoption","login_apply_preview")},{itemId:"btn_apply",xtype:"button",scope:this,width:100,text:_T("common","apply"),handler:this.onApply},{itemId:"btn_cancel",xtype:"button",scope:this,width:100,text:_T("common","cancel"),handler:this.onCancel}]},t))])},onApply:function(){this.getComponent("btn_apply").setDisabled(!0),this.getComponent("btn_cancel").setDisabled(!0);var t=window.location.origin;t||(t=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")),opener&&opener.postMessage({action:"save",origin:t},t),window.close()},onCancel:function(){window.close()}}),Ext.define("SYNO.SDS._UserSettings",{extend:"Ext.Component",getUnloadEventName:function(){var t="onpagehide"in window,e="onbeforeunload"in window;return e?"beforeunload":t?"pagehide":null},registerUnloadEvent:Ext.emptyFn,unregisterUnloadEvent:Ext.emptyFn,saveAndUnload:Ext.emptyFn,syncSave:function(t){this.onSaveSuccess(t)},load:Ext.emptyFn,save:Ext.emptyFn,onSaveSuccess:function(t){var e;if(Ext.isObject(t)){e=t.scope||this;var i=t.callback;Ext.isFunction(i)&&i.call(e)}},getProperty:function(t,e){return SYNO.Debug.warn("getProperty is disabled in sharing mode."),null},setProperty:Ext.emptyFn,removeProperty:Ext.emptyFn}),Ext.define("SYNO.SDS.Sharing.Init",{extend:"Ext.util.Observable",singleton:!0,constructor:function(){this.callParent(arguments),this.addEvents("beforeredirect","beforeinitdata","initdata")},init:function(){var t=this.preInitData();"none"!==_S("sharing_status")||this.isErrorPage()||t.then(this.initData.bind(this))},preInitData:function(){return SYNO.SDS.InitUtils.hideForms().initQuickTips().initDragDrop().disableIESelect().disableSelectAllKeyboard().disableRightClick().handleServerError().initHTML5Upload().IEUpgradeAlert().defaultCSSSelectors().initHDPack(),this.initDialog().initPreviewDialog().hideStandaloneHelp(),this.initAPIPromise()},initAPIPromise:function(){return this.injectCheckAPIResponse(),SYNO.API.QueryAPI.QueryAPIInfo()},injectCheckAPIResponse:function(){var t=SYNO.API.CheckResponse;SYNO.API.CheckResponse=function(e,i,n,o){var s={105:SYNO.SDS.Sharing.ErrorHandler.REASON.permission,106:SYNO.SDS.Sharing.ErrorHandler.REASON.timeout,107:SYNO.SDS.Sharing.ErrorHandler.REASON.error,124:SYNO.SDS.Sharing.ErrorHandler.REASON.invalid,125:SYNO.SDS.Sharing.ErrorHandler.REASON.timeout},r=Ext.isObject(i)?i.code:void 0;if(void 0!==s[r])return void SYNO.SDS.Sharing.Logout.action(s[r]);var a=t.apply(SYNO.API,arguments);return r>=122&&r<=127&&SYNO.SDS.Sharing.Logout.action(SYNO.SDS.Sharing.ErrorHandler.REASON.permission),a}},initDialog:function(){switch(_S("sharing_status")){case"password":case"user":SYNO.SDS.Sharing.LoginHandler(_S("sharing_status"))}return this},isErrorPage:function(){return void 0!==_S("sharing_error")&&(SYNO.SDS.Sharing.ErrorHandler.initErrorPage(_S("sharing_error")),!0)},initPreviewDialog:function(){return _S("preview")&&Ext.isObject(_S("sharing_preview_params"))&&_S("sharing_preview_params").preview_modified&&new SYNO.SDS.Sharing.PreviewDialog,this},hideStandaloneHelp:function(){return Ext.util.CSS.updateRule(".sds-standalone-help","display","none"),this},initData:function(t){var e=this;if(!1!==this.fireEvent("beforeinitdata"))return Ext.isNumber(t)&&t>0?void this.initData.defer(t,this):(SYNO.API.Request({api:"SYNO.Core.Sharing.Initdata",method:"get",version:1,headers:{"X-SYNO-SHARING":_S("sharing_id")},callback:function(t,i,n,o){function s(){Ext.isDefined(window._loadSynoLang)&&window._loadSynoLang(),Ext.apply(SYNO.SDS.Session,i.Session),SYNO.SDS.Config.JSConfig=i.JSConfig,SYNO.SDS.Strings=i.Strings,SYNO.SDS.AppPrivilege=i.AppPrivilege,SYNO.SDS.ServiceStatus=i.ServiceStatus,SYNO.SDS.UIFeatures.IconSizeManager.enableHDDisplay(i.SynohdpackStatus),SYNO.SDS.appendMissingCSSFiles(i.CSSFiles),e.postInitData(i.Sharing)}if(!t)return SYNO.Debug("SYNO.Core.Sharing.initData fail",arguments),void e.initData(3e3);if(!1!==e.fireEvent("initdata",i.Sharing)){if(!i||!i.Sharing||!i.Session)return void SYNO.SDS.Sharing.Logout.action(SYNO.SDS.Sharing.ErrorHandler.REASON.error);if(!e.initSharingRedirect(i.Sharing)){switch(i.Session.lang){case"cht":case"chs":case"jpn":case"krn":Ext.getBody().addClass("syno-cjk")}SYNO.SDS.Utils.loadUIStrings(i.Session.lang,i.Session.fullversion,s)}}}}),this)},postInitData:function(t){var e=Ext.urlDecode(location.search.substr(1)),i=t.project_name,n=t.app,o=e.jsDebug,s=e.accessible;Ext.isDefined(o)&&(SYNO.SDS.JSDebug=o),Ext.isDefined(s)&&Ext.getBody().addClass("accessible"),SYNO.SDS.initFramework(),this.injectIsAppEnabled();var r=SYNO.SDS.Config.FnMap[i],a=!1;if(r&&r.config){var l=r.config;a="standalone"===l.type||!0===l.allowStandalone||"url"===l.type||"legacy"===l.type}return SYNO.SDS.StatusNotifier.isAppEnabled(i)&&a?(this.initSharingId(),this.initStandaloneDesktop(i,n),this.getExternalIP(),this):(SYNO.SDS.Sharing.Logout.action(SYNO.SDS.Sharing.ErrorHandler.REASON.invalid_entry),this)},initSharingRedirect:function(t){return("always"===t.redirect_type||"url_param"===t.redirect_type&&"true"===Ext.urlDecode(location.search.substr(1)).redirect)&&(-1!==t.redirect_uri.indexOf("?")?t.redirect_uri+="&":t.redirect_uri+="?",t.redirect_uri+='_sharing_id="'+_S("sharing_id")+'"',t.redirect_uri=".."+t.redirect_uri,this.fireEvent("beforeredirect",t)&&(window.location.href=t.redirect_uri),!0)},initStandaloneDesktop:function(t,e){return SYNO.SDS.Session.standalone=!0,SYNO.SDS.Session.standaloneAppName=t,SYNO.SDS.Desktop=new SYNO.SDS._StandaloneDesktop,SYNO.SDS.AppLaunch(t,e),this},getExternalIP:function(){return SYNO.API.Request({api:"SYNO.Core.Sharing.Initdata",method:"get",version:1,headers:{"X-SYNO-SHARING":_S("sharing_id")},params:{action:"external_ip"},callback:function(t,e,i,n){if(!t)return void SYNO.Debug("SYNO.Core.Sharing.initData get external_ip fail",arguments);SYNO.SDS.Session.external_ip=e.external_ip,SYNO.SDS.Session.ddns_hostname=e.ddns_hostname}}),this},injectIsAppEnabled:function(){var t=SYNO.SDS.StatusNotifier.isAppHasPrivilege;return SYNO.SDS.StatusNotifier.isAppHasPrivilege=function(e){
return!!t.call(SYNO.SDS.StatusNotifier,e)&&!0===SYNO.SDS.Config.FnMap[e].config.allowSharing},this},initSharingId:function(){var t=Ext.urlAppend;return Ext.urlAppend=function(e,i){var n=Ext.urlDecode(i);return-1!==e.indexOf("_sharing_id")||Ext.isEmpty(_S("sharing_id"))||(n._sharing_id=Ext.util.JSON.encode(_S("sharing_id"))),t(e,Ext.urlEncode(n))},Ext.Ajax.on("beforerequest",function(t,e){Ext.isEmpty(_S("sharing_id"))||(Ext.isEmpty(e.headers)&&(e.headers={}),e.headers["X-SYNO-SHARING"]=_S("sharing_id"))}),Ext.util.Observable.observeClass(Ext.form.BasicForm),Ext.form.BasicForm.on("beforeaction",function(t,e){t.url&&(t.url=Ext.urlAppend(t.url))}),Ext.util.Observable.observeClass(Ext.data.Connection),Ext.data.Connection.on("beforerequest",function(t,e){Ext.isEmpty(_S("sharing_id"))||(e.headers=e.headers||{},e.headers["X-SYNO-SHARING"]=_S("sharing_id"))}),this}}),Ext.onReady(function(){SYNO.SDS.Sharing.Init.init()});