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S,IACnC,aAAa,cAAe,WAAW,KAIxC,OAAS,IAAM,QAKf,QAAU,IAAM,GACT,GAAI,OAAM,2BAA2B,IAAM,CAAC,YAK7C,KAAK,YAAY,CAAE,CAC7B,kBAQuC,EAAa,EAAgB,EAA2C,MACxG,GAAgB,6BAA6B,YAAiB,OAGhE,QAAO,YAIL,GAAW,EAAK,EAAW,EAAI,EAGjC,OAAO,GAAS,SACX,KAAK,CAAa,wBAInB,KAAK,2BAA2B,kBAAuB,EAGxD,EAAiB,EAAK,EAAQ,CAAS,EAC/C,CCtFA,OAAO,WAAa,OAAO,YAAc,GACzC,OAAO,aAAe,OAAO,cAAgB,GAC7C,OAAO,SAAW,OAAO,UAAY,CACpC,WAAY,GACZ,YAAa,GACb,WAAY,GACZ,MAAO,EACR,EAGA,GAAI,CAAC,OAAO,IAAK,MACV,GAAoB,OAAO,aAAa,IAAI,KAAO,IACxD,EAAiB,EAAS,IAAK,EAAS,MAAM,CAC/C,UAEQ,IAAI,CAAiB,EAC3B,KAAK,SAAY,uFAA6C,EAC9D,KAAK,MAAO,CAAE,SAAU,GAAI,KAAM,WAAW,EAC7C,MAAM,QAAQ,KAAK,CACtB","names":[],"sources":["../../../../dxa.ui/vite/preload-helper","../../../../dxa.ui/src/framework/scripts/network/script-loader/load-script.ts","../../../../dxa.ui/src/main.ts"],"sourcesContent":["const scriptRel = (function detectScriptRel() {\n // @ts-ignore\n const relList = document.createElement('link').relList;\n // @ts-ignore\n return relList && relList.supports && relList.supports('modulepreload')\n ? 'modulepreload'\n : 'preload';\n})();const seen = {};const base = '/static/';export const __vitePreload = function preload(baseModule, deps) {\n // @ts-ignore\n if (!__VITE_IS_MODERN__ || !deps || deps.length === 0) {\n return baseModule();\n }\n return Promise.all(deps.map((dep) => {\n // @ts-ignore\n dep = `${base}${dep}`;\n // @ts-ignore\n if (dep in seen)\n return;\n // @ts-ignore\n seen[dep] = true;\n const isCss = dep.endsWith('.css');\n const cssSelector = isCss ? '[rel=\"stylesheet\"]' : '';\n // @ts-ignore check if the file is already preloaded by SSR markup\n if (document.querySelector(`link[href=\"${dep}\"]${cssSelector}`)) {\n return;\n }\n // @ts-ignore\n const link = document.createElement('link');\n // @ts-ignore\n link.rel = isCss ? 'stylesheet' : scriptRel;\n if (!isCss) {\n link.as = 'script';\n link.crossOrigin = '';\n }\n link.href = dep;\n // @ts-ignore\n document.head.appendChild(link);\n if (isCss) {\n return new Promise((res, rej) => {\n link.addEventListener('load', res);\n link.addEventListener('error', () => rej(new Error(`Unable to preload CSS for ${dep}`)));\n });\n }\n })).then(() => baseModule());\n}","/**\r\n * @module framework/network/script-loader\r\n */\r\n\r\n/**\r\n * Map of scripts which are loaded/loading\r\n * @hidden\r\n */\r\nconst loadedScriptMap: Map> = new Map();\r\n\r\n/**\r\n * Loads a script asynchronously\r\n * @param url - url to script (prefer `https://`)\r\n * @param integrity - integrity hash to verify script\r\n * @param force - force load\r\n */\r\nexport async function loadScript(url: string, integrity?: string, force = false): Promise {\r\n\tif (!force && loadedScriptMap.has(url)) {\r\n\t\treturn loadedScriptMap.get(url);\r\n\t}\r\n\r\n\tconst promise = new Promise((resolve, reject) => {\r\n\t\tloadScriptCallback(\r\n\t\t\turl,\r\n\t\t\t(error) => {\r\n\t\t\t\tif (error) {\r\n\t\t\t\t\treject(error);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tresolve();\r\n\t\t\t},\r\n\t\t\tintegrity\r\n\t\t);\r\n\t});\r\n\r\n\tloadedScriptMap.set(url, promise);\r\n\r\n\treturn promise;\r\n}\r\n\r\n/**\r\n * Loads the script at the provided `src` and executes the callback\r\n * @hidden\r\n * @param url - url to script\r\n * @param callback\r\n * @param integrity - script integrity hash\r\n */\r\nfunction loadScriptCallback(url: string, callback: (error?: Error) => void, integrity?: string): void {\r\n\t// Create Script Load object ASAP\r\n\tconst js = document.createElement('script');\r\n\tjs.src = url;\r\n\r\n\tif (integrity?.length) {\r\n\t\tjs.setAttribute('integrity', integrity);\r\n\t\tjs.setAttribute('crossorigin', 'anonymous');\r\n\t}\r\n\r\n\t// eslint-disable-next-line unicorn/prefer-add-event-listener\r\n\tjs.onload = () => {\r\n\t\tcallback();\r\n\t};\r\n\r\n\t// eslint-disable-next-line unicorn/prefer-add-event-listener\r\n\tjs.onerror = () => {\r\n\t\tcallback(new Error(`Failed to load script: '${url}'`));\r\n\t};\r\n\r\n\t// Load script (by appending to document head)\r\n\t// eslint-disable-next-line unicorn/prefer-dom-node-append\r\n\tdocument.head.appendChild(js);\r\n}\r\n\r\n/**\r\n * Ensures a script is loaded by checking for a global value\r\n * @param url - url to script (prefer `https://`)\r\n * @param global - global to check against\r\n * @param integrity - integrity hash to verify script\r\n */\r\nexport async function ensureLoadScript(url: string, global: string, integrity?: string): Promise {\r\n\tconst loadedMessage = `Fallback has loaded for \\`${global}\\` from ${url}`;\r\n\r\n\t// @ts-expect-error Window is typed with any :-/\r\n\tif (window[global]) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tawait loadScript(url, integrity, true);\r\n\r\n\t// @ts-expect-error Window is typed with any :-/\r\n\tif (window[global]) {\r\n\t\tconsole.info(loadedMessage);\r\n\t\treturn;\r\n\t}\r\n\r\n\tconsole.warn(`Unable to find global \\`${global}\\`, retrying...`);\r\n\r\n\t// noinspection TailRecursionJS\r\n\treturn ensureLoadScript(url, global, integrity);\r\n}\r\n","/**\r\n * @file Main\r\n * @author Rhys Lloyd\r\n */\r\n/* eslint-disable unicorn/prefer-top-level-await */\r\n\r\n// DevTools is a side effect import, imports nothing for production.\r\n// eslint-disable-next-line import/no-unassigned-import\r\nimport './main-devtools';\r\n\r\nimport { ensureLoadScript } from '~/framework/network/script-loader/load-script';\r\n\r\n// Globals\r\nwindow.AppGlobals = window.AppGlobals || {};\r\nwindow.CdnFallbacks = window.CdnFallbacks || [];\r\nwindow.AppHooks = window.AppHooks || {\r\n\tinitialise: [],\r\n\tbeforeMount: [],\r\n\tafterMount: [],\r\n\tready: [],\r\n};\r\n\r\n// Run\r\nif (!window.App) {\r\n\tconst ensureCdnPromises = window.CdnFallbacks.map(async (fallback) =>\r\n\t\tensureLoadScript(fallback.src, fallback.global)\r\n\t);\r\n\r\n\tPromise.all(ensureCdnPromises)\r\n\t\t.then(async () => import(/* webpackChunkName: \"app\" */ './app'))\r\n\t\t.then(async ({ App }) => new App().autoStart())\r\n\t\t.catch(console.error);\r\n}\r\n"],"file":"assets/head.2d5385d4.js"}