var globalThis;void 0===globalThis&&(globalThis=self),function(){"use strict";globalThis.Emby={};var docElem,appMode,supportsModules="noModule"in document.createElement("script"),usesModules=!1;function loadScript(src){return new Promise(function(resolve,reject){var doc=document,script=doc.createElement("script");globalThis.urlCacheParam&&(src+="?"+globalThis.urlCacheParam),usesModules&&supportsModules&&(script.type="module"),script.onload=resolve,script.onerror=reject,script.src=src,doc.head.appendChild(script)})}function catchAndResolve(err){return console.error("error registering service worker: ",err),Promise.resolve()}function loadRequire(){return loadScript("./modules/alameda/alameda"+globalThis.Emby.jsExtension)}function loadApp(){var baseRoute,config={urlArgs:globalThis.urlCacheParam,renameJsExtension:".js"===globalThis.Emby.jsExtension?null:globalThis.Emby.jsExtension};return"android"!==globalThis.appMode&&((baseRoute=(baseRoute=globalThis.location.href.split("?")[0].replace("/index.html","")).split("#")[0]).lastIndexOf("/")===baseRoute.length-1&&(baseRoute=baseRoute.substring(0,baseRoute.length-1)),console.log("Setting require baseUrl to "+baseRoute),config.baseUrl=baseRoute),require.config(config),loadScript("./app"+globalThis.Emby.jsExtension)}function onPromiseLoaded(){!function(){if("file:"===globalThis.location.protocol)return Promise.resolve();switch(globalThis.appMode){case"ios":case"android":case"tizen":case"webos":case"chromecast":case"embyclient":return Promise.resolve()}return"undefined"!=typeof caches&&navigator.serviceWorker?caches.open("embyappinfo").then(function(cache){return cache.put("appversion",new Response(globalThis.dashboardVersion||"")).then(function(){try{var serviceWorkerOptions={};return usesModules&&supportsModules&&(serviceWorkerOptions.type="module"),navigator.serviceWorker.register("serviceworker.js",serviceWorkerOptions).then(function(){return navigator.serviceWorker.ready.then(function(){"standalone"===globalThis.appMode&&(globalThis.urlCacheParam=null),Emby.serviceWorkerEnabled=!0})},catchAndResolve).then(function(reg){return reg&&reg.sync?reg.sync.register("emby-sync"):Promise.resolve()})}catch(err){console.error("Error registering serviceWorker: ",err)}},catchAndResolve)},catchAndResolve):Promise.resolve()}().then(loadRequire,loadRequire).then(loadApp,loadApp)}globalThis.Emby.requiresClassesPolyfill=!!1,globalThis.Emby.jsExtension=".js",docElem=document.documentElement,(appMode=docElem.getAttribute("data-appmode"))&&(globalThis.appMode=appMode),(docElem=docElem.getAttribute("data-appversion"))&&(globalThis.dashboardVersion=docElem),docElem?globalThis.urlCacheParam="v="+docElem:appMode||(globalThis.urlCacheParam="v="+Date.now()),function(onDone){var doc,script,src;globalThis.Promise&&globalThis.Promise.all?onDone():(script=(doc=document).createElement("script"),src="./modules/polyfills/native-promise-only"+globalThis.Emby.jsExtension,globalThis.urlCacheParam&&(src+="?"+globalThis.urlCacheParam),script.onload=onDone,script.src=src,doc.head.appendChild(script))}(onPromiseLoaded)}();