@jmodule/client
Version:
JModule运行时
16 lines (15 loc) • 38.7 kB
JavaScript
(function(w,b){typeof exports=="object"&&typeof module!="undefined"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(w=typeof globalThis!="undefined"?globalThis:w||self,b(w.JModule={}))})(this,function(w){"use strict";var b=(e=>(e.Style="text/css",e.Script="text/javascript",e))(b||{}),m=(e=>(e.Init="Init",e.InitScriptLoaded="InitScriptLoaded",e.InitScriptError="InitScriptError",e.ApplyScript="ApplyScript",e.ApplyStyle="ApplyStyle",e.ScriptResolved="ScriptResolved",e.StyleResolved="StyleResolved",e.StyleRemoved="StyleRemoved",e.ScriptError="ScriptError",e.Initializing="Initializing",e.Initialized="Initialized",e.Preloading="Preloading",e.Preloaded="Preloaded",e.InitializeFailed="InitializeFailed",e.PreloadFailed="PreloadFailed",e.StyleError="StyleError",e.StyleRemoveBefore="StyleRemoveBefore",e.StyleDisabled="StyleDisabled",e.StyleEnabled="StyleEnabled",e))(m||{}),f=(e=>(e.bootFailure="bootFailure",e.loadFailure="loadFailure",e.init="init",e.initializing="initializing",e.initialized="initialized",e.initializeFailed="initializeFailed",e.loading="loading",e.loaded="loaded",e.defined="defined",e.booting="booting",e.done="done",e))(f||{});const H={Initializing:"initializing",Initialized:"initialized",InitializeFailed:"initializeFailed",ScriptError:"loadFailure",ScriptResolved:"loaded"},ke=f;var M=(e=>(e[e.Fetch=0]="Fetch",e[e.Element=1]="Element",e))(M||{}),xe=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});const $={};function te(e,t){return xe(this,arguments,function*(r,n,i=[]){const o=i[n];return o?te(yield o(...r),n+1,i):r})}function re(e,t,r=[]){const n=r[t];return n?re(n(...e),t+1,r):e}class A{static addHook(t,r){$[t]=$[t]||[],$[t].push(r)}static removeHook(t,r){const n=$[t].indexOf(r);$[t]=$[t]||[],n>-1&&$[t].splice(n,1)}static clearHooks(t){$[t]=[]}static runHook(t,...r){return te(r,0,$[t]).catch(n=>{throw console.error(`\u6267\u884C hook.${t} \u65F6\u51FA\u73B0\u5F02\u5E38\uFF0C\u540E\u7EED\u8FC7\u7A0B\u5C06\u7EC8\u6B62`),console.error(n),n})}static runHookSync(t,...r){try{return re(r,0,$[t])}catch(n){throw console.error(`\u6267\u884C hook.${t} \u65F6\u51FA\u73B0\u5F02\u5E38\uFF0C\u540E\u7EED\u8FC7\u7A0B\u5C06\u7EC8\u6B62`),console.error(n),n}}}function D(e){return`background: ${e};color:#fff;padding: 0 3px; border-radius: 2px;`}const _={timestamp:"color: #999",key:D("rgb(42,154,243)"),message:"#333",type:{success:D("green"),error:D("red"),log:D("#999"),warning:D("#b39500")},space:"background: initial"};function Be(){return`[${new Date().toISOString().slice(11,-1)}]`}function ne({key:e,message:t,instance:r,type:n="log"}){console.debug(`%c${Be()} %c${n}%c %c${e}%c ${t} %O`,_.timestamp,_.type[n],_.space,_.key,_.message,r)}var De=Object.defineProperty,_e=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,oe=(e,t,r)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ue=(e,t)=>{for(var r in t||(t={}))ie.call(t,r)&&oe(e,r,t[r]);if(I)for(var r of I(t))se.call(t,r)&&oe(e,r,t[r]);return e},Ie=(e,t)=>_e(e,Ue(t)),Le=(e,t)=>{var r={};for(var n in e)ie.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&I)for(var n of I(e))t.indexOf(n)<0&&se.call(e,n)&&(r[n]=e[n]);return r};let L=!1;function Ne(e){if(!e)return"";let t;try{t=JSON.parse(JSON.stringify(e)),t._=e,t.__proto__=e.__proto__}catch(r){t=ue({},e)}return t}class S{static print(t){if(!L||!t)return;const r=t,{instance:n}=r,i=Le(r,["instance"]);ne(Ie(ue({},i),{instance:Ne(n)}))}static printContinue(t){L&&console.debug(` - %c${t}`,"color: #555")}static enable(){L=!0}static disable(){L=!1}}var Te=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});function N(e,t,r){return Te(this,null,function*(){const n=window.JModuleManager.resource(t);if(n.isESM(e))return S.print({key:e,type:"warning",instance:n,message:`
ESM\u811A\u672C\u4E0D\u9002\u7528 fetch \u65B9\u5F0F\u52A0\u8F7D\u811A\u672C,\u8FD9\u610F\u5473\u7740\u8BE5\u8D44\u6E90\u5C06\u5FFD\u7565\u4EE5\u4E0Bhook:
resource:getFetchOptions\u3001
resource:transformFetchResult\u3001
resource:insertPrivateVariable.`}),e;if(n.cachedUrlMap[e])return n.cachedUrlMap[e];const[i]=yield n.constructor.runHook("resource:getFetchOptions",{currentUrl:e,type:r,resource:n,fetchOptions:{}}),o=yield fetch(e,i.fetchOptions).catch(d=>{throw S.print({key:e,type:"error",instance:n,message:d.message}),d});if(!o.ok)throw S.print({key:e,type:"error",instance:n,message:o.statusText}),new Error(`LoadScriptError: ${e}`);const a=o.headers.get("Content-Type");if(r===b.Script&&!(a!=null&&a.includes("javascript"))||r===b.Style&&!(a!=null&&a.includes("style"))&&!(a!=null&&a.includes("css")))throw S.print({key:e,type:"error",instance:n,message:`${e} is not a ${r}`}),new Error(`LoadScriptError: ${e} is not a ${r}`);const u=yield o.arrayBuffer(),[s]=yield n.constructor.runHook("resource:transformFetchResult",{currentUrl:e,sourceUrl:t,type:a||r,resource:n,buffer:new Uint8Array(u)}),l=new Blob([s.buffer],{type:a||r}),c=URL.createObjectURL(l);return n.cachedUrlMap[e]=c,c})}function Je(e,t,r){return new Proxy(r,{apply(n,i,o){const a=r(o[0],o[1]);if(!["script","link","style"].includes(o[0])||(a.dataset.jmoduleFrom=e,a.dataset.loadedBy=t,o[0]==="style"))return a;const u=o[0]==="script"?"src":"href",s=o[0]==="script"?b.Script:b.Style;return Object.defineProperty(a,u,{get(){return a.dataset.srcRaw},set(l){const c=window.JModuleManager.resource(e),d=(c==null?void 0:c.resolveUrl(l))||new URL(l,t||e).href;return a.dataset.srcRaw=d,N(d,e,s).then(p=>{a.setAttribute(u,p)}),!0}}),a}})}function ze(e,t,r){return new Proxy(r,{get(n,i){if(i==="src")return t;const o=Reflect.get(r,i);return o instanceof Function?o.bind(r):o}})}function He(e,t,{sourceUrl:r,currentUrl:n}){return new Proxy(e,{get(i,o){if(o==="__origin__")return e;if(o==="createElement")return Je(r,n,t);const a=Reflect.get(i,o,e);return o==="currentScript"?ze(r,n,a):o==="createTreeWalker"?(u,...s)=>{a.bind(e)(u.__origin__||u,...s)}:a instanceof Function?a.bind(i):a},set(i,o,a){return Reflect.set(i,o,a),!0}})}var ae=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},le={exports:{}},K={exports:{}},ce;function Ke(){return ce||(ce=1,function(e,t){(function(r,n){e.exports=n()})(ae,function(){function r(h){return!isNaN(parseFloat(h))&&isFinite(h)}function n(h){return h.charAt(0).toUpperCase()+h.substring(1)}function i(h){return function(){return this[h]}}var o=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],u=["fileName","functionName","source"],s=["args"],l=["evalOrigin"],c=o.concat(a,u,s,l);function d(h){if(h)for(var g=0;g<c.length;g++)h[c[g]]!==void 0&&this["set"+n(c[g])](h[c[g]])}d.prototype={getArgs:function(){return this.args},setArgs:function(h){if(Object.prototype.toString.call(h)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=h},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(h){if(h instanceof d)this.evalOrigin=h;else if(h instanceof Object)this.evalOrigin=new d(h);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var h=this.getFileName()||"",g=this.getLineNumber()||"",R=this.getColumnNumber()||"",U=this.getFunctionName()||"";return this.getIsEval()?h?"[eval] ("+h+":"+g+":"+R+")":"[eval]:"+g+":"+R:U?U+" ("+h+":"+g+":"+R+")":h+":"+g+":"+R}},d.fromString=function(g){var R=g.indexOf("("),U=g.lastIndexOf(")"),Bt=g.substring(0,R),Dt=g.substring(R+1,U).split(","),je=g.substring(U+1);if(je.indexOf("@")===0)var ee=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(je,""),_t=ee[1],Ut=ee[2],It=ee[3];return new d({functionName:Bt,args:Dt||void 0,fileName:_t,lineNumber:Ut||void 0,columnNumber:It||void 0})};for(var p=0;p<o.length;p++)d.prototype["get"+n(o[p])]=i(o[p]),d.prototype["set"+n(o[p])]=function(h){return function(g){this[h]=Boolean(g)}}(o[p]);for(var y=0;y<a.length;y++)d.prototype["get"+n(a[y])]=i(a[y]),d.prototype["set"+n(a[y])]=function(h){return function(g){if(!r(g))throw new TypeError(h+" must be a Number");this[h]=Number(g)}}(a[y]);for(var v=0;v<u.length;v++)d.prototype["get"+n(u[v])]=i(u[v]),d.prototype["set"+n(u[v])]=function(h){return function(g){this[h]=String(g)}}(u[v]);return d})}(K)),K.exports}(function(e,t){(function(r,n){e.exports=n(Ke())})(ae,function(n){var i=/(^|@)\S+:\d+/,o=/^\s*at .*(\S+:\d+|\(native\))/m,a=/^(eval@)?(\[native code])?$/;return{parse:function(s){if(typeof s.stacktrace!="undefined"||typeof s["opera#sourceloc"]!="undefined")return this.parseOpera(s);if(s.stack&&s.stack.match(o))return this.parseV8OrIE(s);if(s.stack)return this.parseFFOrSafari(s);throw new Error("Cannot parse given Error object")},extractLocation:function(s){if(s.indexOf(":")===-1)return[s];var l=/(.+?)(?::(\d+))?(?::(\d+))?$/,c=l.exec(s.replace(/[()]/g,""));return[c[1],c[2]||void 0,c[3]||void 0]},parseV8OrIE:function(s){var l=s.stack.split(`
`).filter(function(c){return!!c.match(o)},this);return l.map(function(c){c.indexOf("(eval ")>-1&&(c=c.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var d=c.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),p=d.match(/ (\(.+\)$)/);d=p?d.replace(p[0],""):d;var y=this.extractLocation(p?p[1]:d),v=p&&d||void 0,h=["eval","<anonymous>"].indexOf(y[0])>-1?void 0:y[0];return new n({functionName:v,fileName:h,lineNumber:y[1],columnNumber:y[2],source:c})},this)},parseFFOrSafari:function(s){var l=s.stack.split(`
`).filter(function(c){return!c.match(a)},this);return l.map(function(c){if(c.indexOf(" > eval")>-1&&(c=c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),c.indexOf("@")===-1&&c.indexOf(":")===-1)return new n({functionName:c});var d=/((.*".+"[^@]*)?[^@]*)(?:@)/,p=c.match(d),y=p&&p[1]?p[1]:void 0,v=this.extractLocation(c.replace(d,""));return new n({functionName:y,fileName:v[0],lineNumber:v[1],columnNumber:v[2],source:c})},this)},parseOpera:function(s){return!s.stacktrace||s.message.indexOf(`
`)>-1&&s.message.split(`
`).length>s.stacktrace.split(`
`).length?this.parseOpera9(s):s.stack?this.parseOpera11(s):this.parseOpera10(s)},parseOpera9:function(s){for(var l=/Line (\d+).*script (?:in )?(\S+)/i,c=s.message.split(`
`),d=[],p=2,y=c.length;p<y;p+=2){var v=l.exec(c[p]);v&&d.push(new n({fileName:v[2],lineNumber:v[1],source:c[p]}))}return d},parseOpera10:function(s){for(var l=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,c=s.stacktrace.split(`
`),d=[],p=0,y=c.length;p<y;p+=2){var v=l.exec(c[p]);v&&d.push(new n({functionName:v[3]||void 0,fileName:v[2],lineNumber:v[1],source:c[p]}))}return d},parseOpera11:function(s){var l=s.stack.split(`
`).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return l.map(function(c){var d=c.split("@"),p=this.extractLocation(d.pop()),y=d.shift()||"",v=y.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,h;y.match(/\(([^)]*)\)/)&&(h=y.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var g=h===void 0||h==="[arguments not available]"?void 0:h.split(",");return new n({functionName:v,args:g,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:c})},this)}}})})(le);var qe=le.exports;function Ve(e){const t=Error.stackTraceLimit;Error.stackTraceLimit=100;const r=new Error("[JModule]");Error.stackTraceLimit=t;let n;return(qe.parse(r)||[]).find(({fileName:i})=>(i&&(n=e.getResourceUrlByUrl(i)),!!n)),n}function Xe(e){const t=window.JModuleManager;document.createElement.__original__||(document.createElement.__original__=e,document.createElement=new Proxy(document.createElement,{apply(r,n,i){const o=e(i[0],i[1]);if(!["script","link","style"].includes(i[0]))return o;const a=Ve(t);if(o.dataset.jmoduleFrom=a,i[0]==="style")return o;const u=i[0]==="script"?"src":"href",s=Object.getOwnPropertyDescriptor(o,u);return s&&!s.configurable||Object.defineProperty(o,u,{get(){return o.getAttribute(u)},set(l){const[c,d]=t.findResolvedUrlByUrl(l);if(d!==a&&console.warn(`[JModule]: \u5BF9\u8D44\u6E90${l}\u8FDB\u884C\u5730\u5740\u4FEE\u6B63\u65F6\u9047\u5230\u4E00\u4E9B\u975E\u786E\u5B9A\u56E0\u7D20, \u8BF7\u68C0\u67E5\u5176\u52A0\u8F7D\u60C5\u51B5`),!d&&a){const p=t.resource(a);o.setAttribute(u,(p==null?void 0:p.resolveUrl(l))||l);return}o.setAttribute(u,c)}}),o}}))}function j(e,t){return new Promise((r,n)=>{t&&setTimeout(()=>n(new Error(`\u4E8B\u4EF6${e}\u8D85\u65F6: ${t}ms`)),t),window.addEventListener(e,function i(o){if(window.removeEventListener(e,i),o.detail instanceof Error){n(o.detail);return}r(o.detail)})})}var We=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});function Ge(e,t){return We(this,null,function*(){const{key:r}=e,n=e.constructor.runHook;S.print({key:r,message:"\u5F00\u59CB\u6267\u884C\u521D\u59CB\u5316\u51FD\u6570",instance:t});try{return typeof t.init=="function"&&(S.printContinue("\u6267\u884C init \u51FD\u6570"),yield t.init(e)),yield n("afterInit",e,t),(t.imports||[]).forEach(i=>{S.printContinue("\u52A0\u8F7D\u4F9D\u8D56\u6A21\u5757"),this.waitModuleComplete(i).then(o=>o.load())}),yield n("afterImports",e,t),this.cacheModuleExport(r,t.exports),yield n("afterExports",e,t),e}catch(i){throw console.error(i),S.print({type:"error",key:r,message:i.message||"\u672A\u627E\u5230\u6A21\u5757\u6CE8\u518C\u4FE1\u606F, \u6216\u6A21\u5757\u53C2\u6570\u9519\u8BEF",instance:i}),i}})}function Ye(e,t){let r,n;return t?(r=e,n=t):(r=e.key,n=e),(this.jmodule(r)?Promise.resolve(this.jmodule(r)):j(`module.${e}.${f.init}`)).then(i=>(i.bootstrap=()=>{i.status=f.booting;const o=i.constructor;let a=o.runHook("beforeDefine",i,n).then(()=>Ge.bind(this)(i,n)).then(()=>(o.runHook("afterDefine",i,n),i.status=f.done,i)).catch(u=>{throw i.status=f.bootFailure,u});return i.bootstrap=()=>a,a},i.status=f.defined,i.autoBootstrap?i.bootstrap():i))}const Qe=Ye;var Ze=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});const q=[],V=(()=>{let e,t=!0;return r=>{t&&(t=!1,window.postMessage({type:"jmodule:page",action:"jmodule:ready"})),q.push(r),clearTimeout(e),e=setTimeout(()=>Ze(void 0,null,function*(){window.postMessage({type:"jmodule:page",action:"jmodule:change"})}),300)}})();function et(){q.push([Date.now(),"__global__","startRecord",""]),window.addEventListener("module.afterRegister",({detail:e})=>{(e||[]).forEach(({key:t,status:r}={})=>{t&&(V([Date.now(),t,"module",f[r]]),window.addEventListener(`module.${t}.statusChange`,({detail:n})=>{V([Date.now(),t,"module",f[n.status]])}),window.addEventListener(`resource.${t}.statusChange`,({detail:n})=>{V([Date.now(),t,"resource",m[n.status]])}))})})}function tt(){et(),window.__jmodule_devtool__||(window.__jmodule_devtool__={getActionsFromIndex(e=0){return q.slice(e)},getDefinition(){return{ModuleStatus:f,ResourceStatus:m,ResourceLoadStrategy:M}}})}var rt=Object.defineProperty,de=Object.getOwnPropertySymbols,nt=Object.prototype.hasOwnProperty,it=Object.prototype.propertyIsEnumerable,pe=(e,t,r)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,he=(e,t)=>{for(var r in t||(t={}))nt.call(t,r)&&pe(e,r,t[r]);if(de)for(var r of de(t))it.call(t,r)&&pe(e,r,t[r]);return e};const fe=new Set,T={};class k{constructor(t={}){if(t instanceof k)return t;const r=Object.keys(t).sort()||[],n=JSON.stringify(r.map(i=>[i,t[i]])).replace(/^\[|\]$/g,"");fe.add(n),this.hash=n}get matched(){return[...fe].filter(t=>this.hash.indexOf(t)>-1).sort((t,r)=>t.length>r.length?1:-1)}cache(t){T[this.hash]=he(he({},T[this.hash]||{}),t)}getCache(t=!0){return t?Object.assign({},...this.matched.map(r=>T[r])):T[this.hash]}}const X={};class W{constructor(t,r={}){if(!t||typeof t!="function")throw new Error("DepResolver \u53C2\u6570\u9519\u8BEF\uFF0C\u5FC5\u987B\u4E3A\u51FD\u6570");const{cacheBy:n}=r;this.resolver=t,this.cacheBy=n,this.result=void 0}resolve(t={}){const{cacheBy:r}=this,n=r&&t[r];if(n&&X[n])return X[n];const i=this.resolver(t);return n&&(X[n]=i),i}}var me=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});const G=document,ye=G.createElement.bind(G),st=(window.JModule||{}).config||{},ve=class extends A{static createDocument(t){return He(G,ye,t)}static getInitialConfig(){return st}static setFileMapCache(t,r){var n;const i=(n=this.fileMapCache[t])==null?void 0:n[0];if(i&&i!==r[0]){const o=`\u5EFA\u7ACB\u5F02\u6B65\u7EC4\u4EF6\u7D22\u5F15 "${t}" \u51FA\u73B0\u51B2\u7A81\uFF0C\u53EF\u80FD\u4F1A\u5BFC\u81F4\u5F02\u6B65\u7EC4\u4EF6\u52A0\u8F7D\u5F02\u5E38`;console.error(o,r)}return this.fileMapCache[t]=r}static appendFileList(t){this.fileListCache.push(t)}static findResolvedUrlByUrl(t){const r=this.fileListCache.find(n=>n&&t.includes(n));return!r||!this.fileMapCache[r]?[t]:this.fileMapCache[r]}static getResourceUrlByUrl(t){if(!t)return;if(this.resourceCache[t])return t;let r;for(const n of document.scripts)if(n.src===t){r=n.getAttribute("data-jmodule-from")||void 0;break}return r}static resource(t,r){if(r===null){delete this.resourceCache[t];return}return r?(this.resourceCache[t]=r,r):this.resourceCache[t]}static jmodule(t,r){if(r===null){delete this.jmoduleCache[t];return}return r?(this.jmoduleCache[t]=r,r):this.jmoduleCache[t]}static get registeredModules(){return Object.keys(this.jmoduleCache).map(t=>this.jmodule(t)).filter(t=>!!t)}static mapResourceUrlAndModuleKey(t,r){this.resourceUrlAndModuleKeyMap[t]=[...this.resourceUrlAndModuleKeyMap[t]||[],r]}static getModulesByResourceUrl(t){return(this.resourceUrlAndModuleKeyMap[t]||[]).map(r=>this.jmodule(r)).filter(r=>!!r)}static getJModuleConstructor(t){const r=this.jmodule(t);if(!r)throw new Error(`Module ${t} not found`);return r.constructor}static registerJModule(t){return this.defaultJModule||(this.defaultJModule=t),this.nextJModuleId++}static cacheModuleExport(t,r){Object.assign(this.moduleExports,{[t]:r})}static waitModuleComplete(t){return me(this,null,function*(){const r=this.jmodule(t);return r&&r.status===f.done?Promise.resolve(r):j(`module.${t}.${f.done}`)})}static require(t){return me(this,null,function*(){const r=t.split(".");if(yield this.waitModuleComplete(r[0]),!this.moduleExportsCache[t]){const n=r.reduce((i,o)=>(i||{})[o],this.moduleExports);this.moduleExportsCache[t]=n}return this.moduleExportsCache[t]})}static export(t={},r={}){new k(r).cache(t)}static import(t="",r={}){const n=new k(r).getCache(),i=t.split(".").reduce((o,a)=>(o||{})[a],n);return i&&i instanceof W?i.resolve(r):i}};let F=ve;F.resourceCache={},F.jmoduleCache={},F.resourceUrlAndModuleKeyMap={},F.fileMapCache={},F.fileListCache=[],F.moduleExportsCache={},F.moduleExports={},F.nextJModuleId=0,F.define=Qe.bind(ve),window.JModuleManager||(window.JModuleManager=F,Xe(ye),tt());var E=window.JModuleManager,ot=Object.defineProperty,ut=Object.defineProperties,at=Object.getOwnPropertyDescriptors,J=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,we=(e,t,r)=>t in e?ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,be=(e,t)=>{for(var r in t||(t={}))ge.call(t,r)&&we(e,r,t[r]);if(J)for(var r of J(t))Ee.call(t,r)&&we(e,r,t[r]);return e},Se=(e,t)=>ut(e,at(t)),lt=(e,t)=>{var r={};for(var n in e)ge.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&J)for(var n of J(e))t.indexOf(n)<0&&Ee.call(e,n)&&(r[n]=e[n]);return r},ct=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});const dt="((context) => {const document = JModuleManager?.createDocument?.(context) || document;",pt=(e,t)=>`
})({ sourceUrl: '${e}', currentUrl: '${t}' })`;function ht(e){return ct(this,null,function*(){const t=e,{buffer:r,resource:n}=t,i=lt(t,["buffer","resource"]);if(!e.type.includes("javascript")||!(r instanceof Uint8Array)||n.isESM(e.currentUrl))return[e];const o=new TextEncoder,[{code:a=""}]=yield n.constructor.runHook("resource:insertPrivateVariable",Se(be({},e),{code:""}));return[Se(be({},i),{resource:n,buffer:new Uint8Array([...o.encode(dt),...o.encode(a),...r,...o.encode(`${pt(e.sourceUrl,e.currentUrl)}`)])})]})}var Y=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});function ft(e,t){return Y(this,null,function*(){const r=yield(yield fetch(t)).json(),n=`(window.JModuleManager && window.JModuleManager.defaultJModule || window.JModule).applyResource(${JSON.stringify(r)}, "${e.url}")`,i=new Blob([n],{type:"text/javascript"});return URL.createObjectURL(i)})}function mt(e,t){return Y(this,null,function*(){const r=yield fetch(t),[n]=(r.headers.get("Content-Type")||"").split(";");return e.type=n.split("/").pop()||e.type,URL.createObjectURL(yield r.blob())})}function yt(e){const t={};return[...e].forEach(r=>t[r.name]=r.value),t}const vt=(e,t)=>{const r=new DOMParser().parseFromString(e,"text/html"),n={},i=/(\bimport\b[\r\n\s]+[^'"]*\bfrom\b[\r\n\s]+['"])([^'"]+)(['"])/gm,o=[...r.scripts].map(u=>{var s;let l;if(u.attributes.getNamedItem("src")&&(l=(s=u.attributes.getNamedItem("src"))==null?void 0:s.value),u.textContent){if(u.type==="importmap")return;if(u.type==="module"){const c=u.textContent.replace(i,(d,p,y,v)=>p&&y&&v?`${p}${new URL(y,t).href}${v}`:d);l=URL.createObjectURL(new Blob([c],{type:"text/javascript"}))}else l=URL.createObjectURL(new Blob([u.textContent],{type:"text/javascript"}))}return l&&(n[l]=yt(u.attributes)),l}).filter(u=>!!u),a=[...r.querySelectorAll('style, link[rel="stylesheet"]')].map(u=>{var s;if(u.tagName==="LINK")return(s=u.attributes.getNamedItem("href"))==null?void 0:s.value;if(u.tagName==="STYLE"&&u.textContent)return URL.createObjectURL(new Blob([u.textContent],{type:"text/css"}))});return{js:o,css:a,jsAttributes:n}};function gt(e,t){return Y(this,null,function*(){const r=yield fetch(t),[n]=(r.headers.get("Content-Type")||"").split(";");n.includes("html")||console.warn(`\u8D44\u6E90 ${t} \u5B9E\u9645\u7C7B\u578B\u4E3A ${n}, \u671F\u671B\u662F 'text/html', \u8BF7\u6CE8\u610F\u68C0\u67E5`);const i=vt(yield r.text(),t),o=`(window.JModuleManager && window.JModuleManager.defaultJModule || window.JModule).applyResource(${JSON.stringify(i)}, "${e.url}")`;return URL.createObjectURL(new Blob([o],{type:"text/javascript"}))})}const Et=[["auto",mt],["json",ft],["html",gt]];var wt=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});function bt(e,t,r){return wt(this,null,function*(){return(yield Promise.allSettled(e.map(n=>new Promise((i,o)=>{const a=n.href||n.src;n.onload=()=>i(n),n.onerror=()=>o(new Error(`LoadError: ${a}`)),t&&t(n)})))).reduce((n,i)=>(i.status==="fulfilled"&&(n.results.push(i.value),r&&r(i.value)),i.status==="rejected"&&n.errors.push(i.reason),n),{results:[],errors:[]})})}function Fe(e,t){return new Promise((r,n)=>{setTimeout(()=>{if(t instanceof Error){n(t);return}r(t)},e)})}function St(e,t){return!e||!t?!0:["js","css","asyncFiles"].some(r=>(e[r]||[]).sort().join(",")!==(t[r]||[]).sort().join(","))}var x=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});function $e(e,t,r,n){const i=document.createElement("script");return i.setAttribute("src",e),i.async=!1,i.dataset.jmoduleFrom=t,Object.keys(r||{}).forEach(o=>{["src","async"].includes(o)||i.setAttribute(o,r[o])}),n&&n(i),document.body.appendChild(i),new Promise((o,a)=>{i.onerror=()=>a(new Error(`LoadScriptError: ${e}`)),i.onload=()=>o(i)})}function Ft(e,t,r){const n=document.createElement("link");return n.setAttribute("rel","preload"),n.setAttribute("as","style"),n.setAttribute("href",e),n.dataset.jmoduleFrom=t,r&&r(n),n}function $t(e){return`${new URL(e,window.location.href)}${e.indexOf("?")>0?"&":"?"}__v__=${Date.now()}`}const Ct=/\?.+$/;function Mt(e){const{asyncFiles:t=[]}=e.metadata||{};t.forEach(r=>{const n=r.replace(Ct,""),i=e.resolveUrl(r);E.setFileMapCache(n,[i,e.url]),E.appendFileList(n)})}const At={},O=class extends A{constructor(e,t){var r,n;if(super(),this.appliedScript=!1,this.resolvedUrlMap={},this.url="",this.styleElements=[],this.scriptElements=[],this.styleMounted=!1,this.status=m.Init,this.cachedUrlMap={},!e&&typeof e!="string")throw new Error("\u521B\u5EFA Resource \u5B9E\u4F8B\u5F02\u5E38, \u7F3A\u5C11sourceUrl");const{href:i,origin:o}=new URL(e,window.location.href);if(E.resource(i))return E.resource(i);this.url=i,this.server=o;const a=((r=e.split(".").pop())==null?void 0:r.replace(/\s|(\?.*$)/g,""))||"";this.type=(t==null?void 0:t.type)||(["js","json"].includes(a)?a:"auto"),this.afterApplyScript=new Promise((u,s)=>{this.resolveScript=u,this.rejectScript=s}),this.strategy=(n=t==null?void 0:t.strategy)!=null?n:M.Element,this.initTimeout=(t==null?void 0:t.initTimeout)||O.initTimeout,E.resource(this.url,this)}static enableAsyncChunk(){console.warn("Resource.enableAsyncChunk() is deprecated, just remove it")}static getResource(e){return console.warn("Resource.getResource() is deprecated, use JModuleManager.getInstance() instead"),e?E.resource(e):void 0}static getTrueResourceUrl(e){let t,r;return Object.keys(O.asyncFilesMap).some(n=>{if(e.includes(n))return t=O.asyncFilesMap[n],r=n,!0}),t&&r?{resource:t,filepath:r}:void 0}static setResourceData(e,t){var r;const n=E.resource(t);if(!n)throw new Error(`\u672A\u627E\u5230${t}\u5BF9\u5E94\u7684 resource \u5B9E\u4F8B`);return n.metadata&&St(n.metadata,e)&&(O.runHookSync("resource:upgrade",n),n.resetStyleStatus()),(r=n.resolveInit)==null||r.call(n,e),n}static defineType(e,t){O.addHook("resource:resolveEntry",(r,n)=>x(this,null,function*(){return r.type===e&&typeof t=="function"?[r,yield t(r,n)]:[r,n]}))}prepareInit(){this.status===m.Initializing&&this.rejectInit&&this.rejectInit(new Error("ResourceInit:Aborted")),this.setStatus(m.Initializing),this.afterInit=new Promise((e,t)=>{this.resolveInit=r=>{this.status===m.Initializing&&(this.metadata=r,this.setStatus(m.Initialized),e())},this.rejectInit=r=>{this.setStatus(m.InitializeFailed),console.error(`${this.url} \u52A0\u8F7D\u5931\u8D25: ${r.message}`),t(r)}})}init(e=!1){return x(this,null,function*(){var t;if(this.status===m.Initializing)return this.afterInit;if(this.afterInit&&!e)return this.afterInit;this.prepareInit();try{const[,r]=yield O.runHook("resource:resolveEntry",this,$t(this.url));yield $e(r,this.url,{},n=>{n.async=!0,this.initScriptElement=n,At[this.url]=n}),yield Promise.race([Fe(this.initTimeout,new Error("ResourceInit:Timeout")),this.afterInit])}catch(r){throw(t=this.rejectInit)==null||t.call(this,r),r}})}resolveUrl(e){var t;let r=e;try{e.startsWith("X_WEBPACK_SERVER")&&(console.warn("X_WEBPACK_SERVER \u5DF2\u5E9F\u5F03, \u4E0B\u4E2A\u7248\u672C\u5C06\u5F03\u7528"),(t=this.metadata)!=null&&t.asyncFiles?e=e.replace(/^X_WEBPACK_SERVER\/?/,""):e=e.replace(/^X_WEBPACK_SERVER/,"")),this.urlAdapter?r=this.urlAdapter(e,this):r=new URL(e,this.url).href}catch(n){}return this.resolvedUrlMap[r]=e,r}setStatus(e){this.status!==e&&(this.status=e,E.getModulesByResourceUrl(this.url).forEach(t=>{e in H&&(t.status=H[e]),window.dispatchEvent(new CustomEvent(`resource.${t.key}.statusChange`,{detail:this}))}))}applyScript(e){return x(this,null,function*(){if(!this.metadata)return Promise.reject(new Error(`no resource metadata: ${this.url}`));if(this.appliedScript)return Promise.resolve(this.scriptElements);if(this.scriptLoading)return this.scriptLoading;this.setStatus(m.ApplyScript),this.scriptElements=[];const t=(this.metadata.js||[]).map(i=>{var o,a;return(a=(o=this.metadata)==null?void 0:o.jsAttributes)==null?void 0:a[i]}),r=(this.metadata.js||[]).map(i=>this.resolveUrl(i)),n=()=>x(this,null,function*(){return this.strategy===M.Fetch?yield Promise.all(r.map(i=>N(i,this.url,b.Script))):(Mt(this),r)});return this.scriptLoading=n().then(i=>Promise.all(i.map((o,a)=>$e(o,this.url,t[a],e)))).then(i=>(this.setStatus(m.ScriptResolved),this.resolveScript(i),this.scriptElements=i,this.appliedScript=!0,this.scriptElements)).catch(i=>{throw this.setStatus(m.ScriptError),this.scriptLoading=void 0,this.rejectScript(i),i}),this.scriptLoading})}applyStyle(e){return x(this,null,function*(){var t;if(!this.metadata)return Promise.reject(new Error("no resource metadata"));const{css:r=[]}=this.metadata,{length:n}=this.styleElements;if(!this.styleLoading){if(this.setStatus(m.ApplyStyle),r.length!==n){const o=(this.metadata.css||[]).map(u=>this.resolveUrl(u)),a=yield(()=>x(this,null,function*(){return this.strategy===M.Fetch?yield Promise.all(o.map(u=>N(u,this.url,b.Style))):o}))();this.styleElements=a.map(u=>Ft(u,this.url,e))}const i=bt(this.styleElements,o=>document.head.appendChild(o),o=>o.setAttribute("rel","stylesheet"));(t=this.appendedAsyncStyleElements)==null||t.forEach(o=>document.head.appendChild(o)),this.styleMounted=!0,this.styleLoading=i.then(o=>(this.setStatus(m.StyleResolved),o.errors.length&&(this.setStatus(m.StyleError),console.error(o.errors)),o.results))}return this.status===m.StyleDisabled&&this.setStyleStatus("enabled"),this.styleLoading})}isESM(e){var t,r;const n=this.resolvedUrlMap[e]||e,i=(r=(t=this.metadata)==null?void 0:t.jsAttributes)==null?void 0:r[n];return i?i.type==="module":!!document.querySelector(`script[type="module"][data-src-raw="${e}"]`)}preload(e){if(!this.metadata)throw new Error("no resource metadata");if(this.status===m.Preloading)return;this.setStatus(m.Preloading);const{css:t=[],js:r=[]}=this.metadata,n=[{type:"script",urls:r},{type:"style",urls:t}].map(({type:i,urls:o})=>{const a=o.map(u=>{const s=this.resolveUrl(u);if(this.strategy===M.Fetch){const l=i==="script"?b.Script:b.Style;return N(s,this.url,l).then(c=>{this.cachedUrlMap[s]=c})}else return new Promise((l,c)=>{const d=document.createElement("link");d.setAttribute("href",s),d.rel="preload",d.as=i,d.onload=l,d.onerror=c,document.head.appendChild((e==null||e(d),d))})});return Promise.all(a)});Promise.all(n).then(()=>{this.setStatus(m.Preloaded)}).catch(()=>{this.setStatus(m.PreloadFailed)})}removeStyle(){if(!this.styleLoading)return;this.setStatus(m.StyleRemoveBefore),(this.styleElements||[]).forEach(t=>t.remove());const e=document.querySelectorAll(`link[data-jmodule-from="${this.url}"], style[data-jmodule-from="${this.url}"]`);e.forEach(t=>t.remove()),this.appendedAsyncStyleElements=e,this.styleMounted=!1,this.styleLoading=void 0,this.setStatus(m.StyleRemoved)}setStyleStatus(e){const t=e==="disabled",r=[...this.styleElements||[],...this.appendedAsyncStyleElements||[]];[...document.styleSheets].forEach(n=>{r.includes(n.ownerNode)&&(n.disabled=t)}),this.setStatus(t?m.StyleDisabled:m.StyleEnabled)}resetStyleStatus(){this.styleLoading=void 0,this.styleMounted=!1,this.styleElements=[],this.appendedAsyncStyleElements=void 0}destroy(){this.removeStyle(),this.initScriptElement=void 0,this.scriptElements=[],this.styleElements=[],E.resource(this.url,null)}};let C=O;C.asyncFilesMap={},C.initTimeout=1e4,C.addHook("resource:transformFetchResult",ht),Et.forEach(([e,t])=>{C.defineType(e,t)});var Ce=Object.getOwnPropertySymbols,Ot=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,Rt=(e,t)=>{var r={};for(var n in e)Ot.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&Ce)for(var n of Ce(e))t.indexOf(n)<0&&Pt.call(e,n)&&(r[n]=e[n]);return r},z=(e,t,r)=>new Promise((n,i)=>{var o=s=>{try{u(r.next(s))}catch(l){i(l)}},a=s=>{try{u(r.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((r=r.apply(e,t)).next())});const Me={},Ae=()=>{var e;return((e=document.currentScript)==null?void 0:e.src)||(Me==null?void 0:Me.url)||""},Oe=document.currentScript,Q={},Pe={[f.init]:"\u5DF2\u521B\u5EFA\u6A21\u5757\u5B9E\u4F8B",[f.initializing]:"\u6B63\u5728\u83B7\u53D6\u8D44\u6E90\u5217\u8868",[f.initialized]:"\u8D44\u6E90\u521D\u59CB\u5316\u5B8C\u6210",[f.initializeFailed]:"\u8D44\u6E90\u521D\u59CB\u5316\u5931\u8D25",[f.loading]:"\u6B63\u5728\u52A0\u8F7D\u6A21\u5757\u8D44\u6E90",[f.loaded]:"\u6A21\u5757\u52A0\u8F7D\u5B8C\u6210",[f.loadFailure]:"\u6A21\u5757\u52A0\u8F7D\u6216\u89E3\u6790\u5931\u8D25",[f.defined]:"\u89E3\u6790\u6A21\u5757\u5B9A\u4E49",[f.booting]:"\u6B63\u5728\u6302\u8F7D\u6A21\u5757",[f.done]:"\u6A21\u5757\u5DF2\u6302\u8F7D",[f.bootFailure]:"\u6302\u8F7D\u6A21\u5757\u8FC7\u7A0B\u5F02\u5E38"},{filter:Z,debug:jt}=E.getInitialConfig(),kt=e=>{const{key:t}=e;let r;return(!t||Q[t])&&(r="\u91CD\u590D\u6CE8\u518C\u6216moduleKey\u672A\u5B9A\u4E49"),Z&&typeof Z=="function"&&!Z(e)&&(r="\u4E3B\u52A8\u8FC7\u6EE4"),r?(S.print({key:t,message:r,instance:e}),!1):!0},Re=/^((?:http|https):\/\/[^/]+)(\/.*)?$/g;function xt(e=""){return Re.test(e)?e.replace(Re,(t,r)=>r):""}const P=class extends A{constructor(e){var t=e,{key:r,url:n,server:i,name:o,autoBootstrap:a=!0,resourceType:u,resource:s,type:l,resourceLoadStrategy:c}=t,d=Rt(t,["key","url","server","name","autoBootstrap","resourceType","resource","type","resourceLoadStrategy"]);const p=i||xt(n),y=p!=="/";super(),this.hooks={complete:void 0},this.type=l,this.key=r,this.name=o,this.url=n,this.status=f.init,this.server=p,this.isRemoteModule=y,this.domain=p,this.resource=s&&s instanceof C?s:new C(n,{type:u,strategy:c}),this.autoBootstrap=a,this.bootstrap=void 0,this.metadata=d,E.mapResourceUrlAndModuleKey(this.resource.url,this.key),E.jmodule(this.key,this)}set status(e){if(e===f.loaded&&this._status!==f.loading)return;this._status=e,e===f.loaded&&setTimeout(()=>{this.status===f.loaded&&S.print({type:"warning",key:this.key,message:"JModule.define \u53EF\u80FD\u65E0\u6CD5\u6B63\u5E38\u6267\u884C, \u8BF7\u68C0\u67E5\u5B50\u5E94\u7528\u8D44\u6E90\u54CD\u5E94\u662F\u5426\u6B63\u5E38\u3001\u662F\u5426\u6267\u884C\u5F02\u5E38\u3001\u662F\u5426\u80FD\u6267\u884CJModule.define",instance:this})},5e3);const t={detail:this};S.print({type:e!==f.loadFailure?e!==f.loading?"success":"log":"error",key:this.key,message:Pe[e],instance:this}),window.dispatchEvent(new CustomEvent(`module.${this.key}.statusChange`,t)),window.dispatchEvent(new CustomEvent(`module.${this.key}.${e}`,t))}get status(){return this._status}static set debug(e){P._debug=e,e?S.enable():S.disable()}static get debug(){return P._debug||!1}static defineType(e,t){P.addHook("afterDefine",(r,n)=>{if(r.type===e&&typeof t=="function"){const{activate:i,deactivate:o}=t(r,n)||{};r.activate=i,r.deactivate=o}return[r,n]})}static get registeredModules(){return Object.values(Q)}static getModule(e){return E.jmodule(e)}static getModuleAsync(e,t){return z(this,null,function*(){const r=E.jmodule(e);return r?Promise.resolve(r):new Promise((n,i)=>{if(t){const a=setTimeout(()=>{clearTimeout(a),E.jmodule(e)||i(new Error(`Timeout:getModuleAsync('${e}', ${t})`))},t)}function o(){E.jmodule(e)&&(window.removeEventListener("module.afterRegister",o),n(E.jmodule(e)))}window.addEventListener("module.afterRegister",o)})})}static require(e){return z(this,null,function*(){return E.require(e)})}static registerModules(){return z(this,arguments,function*(e=[]){S.print({type:"log",key:"registerModules",message:"\u8BF7\u6C42\u6CE8\u518C\u6A21\u5757",instance:e}),yield A.runHook("beforeFilterModules",e);const t=e.filter(kt);yield A.runHook("beforeRegisterModules",t);const r=t.map(n=>n instanceof P?n:new this(n));return r.forEach(n=>{n.key&&(Q[n.key]=n)}),window.dispatchEvent(new CustomEvent("module.afterRegister",{detail:r})),yield A.runHook("afterRegisterModules",r),r})}static export(e={},t={}){return new k(t).cache(e),P}static applyResource(e,t){const r=t||Ae();if(!r)throw new Error("JModule.applyResource \u6267\u884C\u5F02\u5E38: \u65E0\u6CD5\u627E\u5230\u811A\u672C\u52A0\u8F7D\u6E90\u5E76\u5173\u8054\u5230\u5BF9\u5E94\u7684\u8D44\u6E90\u5B9E\u4F8B");return C.setResourceData(e,r.replace(/(\?|&)__v__=\d+$/,""))}static getMeta(){const e=Ae();return e?{url:e,server:new URL(e).origin}:{}}static import(e="",t={},r=!1){if(e==="$module.meta")return this.getMeta();if(!r&&this===window.JModule)return this.import(e,t,!0);if(!r&&this!==E.defaultJModule&&Oe){const{dataset:o}=Oe,a=(o==null?void 0:o.jmoduleFrom)||"",[u]=E.getModulesByResourceUrl(a)||[];return u&&u.constructor!==P?u.constructor.import(e,t,!0):this.import(e,t,!0)}const n=new k(t).getCache(),i=e.split(".").reduce((o,a)=>(o||{})[a],n);return!i&&this!==E.defaultJModule?E.import(e,t):i&&i instanceof W?i.resolve(t):i}static _import(e="",t={}){return console.warn("JModule._import is deprecated"),this.import(e,t)}setCompleteHook(){this.hooks.complete=Promise.race([j(`module.${this.key}.${f.done}`),j(`module.${this.key}.${f.loadFailure}`),j(`module.${this.key}.${f.bootFailure}`)]).then(()=>{if(this._status!==f.done)throw new Error(Pe[this._status]);return this})}load(){return z(this,arguments,function*(e="load",t={autoApplyStyle:!0}){const{resource:r}=this,{loading:n,defined:i,booting:o,done:a,loaded:u,initializeFailed:s,loadFailure:l,bootFailure:c}=f;if([n,i,o,a,u].includes(this.status))return e==="load"&&t.autoApplyStyle&&r.applyStyle(),yield e!=="load"?Promise.resolve():this.hooks.complete,r;if(yield r.init([l,c,s].includes(this.status)),e==="preload"&&(window.requestIdleCallback?window.requestIdleCallback(()=>r.preload(t.elementModifier)):window.setTimeout(()=>r.preload(t.elementModifier),500)),e==="load"){this.status=f.loading,this.setCompleteHook(),r.applyScript(t.elementModifier),t.autoApplyStyle&&r.applyStyle(t.elementModifier);try{yield this.hooks.complete}catch(d){throw r.removeStyle(),r.resetStyleStatus(),d}}return r})}};let B=P;B.define=E.define,B.id=E.registerJModule(B),B.debug=jt,w.DepResolver=W,w.JModule=B,w.JModuleManager=F,w.MODULE_STATUS=ke,w.ModuleHook=A,w.ModuleStatus=f,w.Resource=C,w.ResourceLoadStrategy=M,w.ResourceStatus=m,w.ResourceType=b,w.default=B,w.eventToPromise=j,w.printDebugInfo=ne,w.statusFromResourceToModule=H,w.timeoutToPromise=Fe,Object.defineProperty(w,"__esModule",{value:!0})});
//# sourceMappingURL=index.js.map