@micro-zoe/micro-app 1.0.0-rc.3 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.min.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="1.0.0-rc.3",t="undefined"!=typeof window,n="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),o=()=>!1,r=Array.isArray,i=Object.assign,s=Object.defineProperty,a=Object.defineProperties,c=Object.prototype.toString,l=Object.prototype.hasOwnProperty,u=e=>c.call(e);function p(e){return void 0===e}function h(e){return null===e}function d(e){return"string"==typeof e}function m(e){return"boolean"==typeof e}function f(e){return"number"==typeof e}function _(e){return"function"==typeof e}function A(e){return"[object Object]"===u(e)}function w(e){return!h(e)&&"object"==typeof e}function y(e){return"[object Promise]"===u(e)}function g(e){var t;if(_(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function b(e){var t;return e instanceof URL||!!(null===(t=e)||void 0===t?void 0:t.href)}function v(e){var t;return e instanceof Element||d(null===(t=e)||void 0===t?void 0:t.tagName)}function E(e){var t;return e instanceof Node||f(null===(t=e)||void 0===t?void 0:t.nodeType)}function P(e){return"[object HTMLLinkElement]"===u(e)}function R(e){return"[object HTMLStyleElement]"===u(e)}function S(e){return"[object HTMLScriptElement]"===u(e)}function M(e){return v(e)&&"MICRO-APP-BODY"===e.tagName.toUpperCase()}function C(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function N(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function O(e,...t){Promise.resolve().then(e.bind(null,...t))}const D=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function I(e){return e.startsWith("//")?`${n.location.protocol}${e}`:e}function x(e,t=null){if(!d(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=D(I(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return C(e,t),""}}function L(e){return d(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function T(e){const{origin:t,pathname:n}=D(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function U(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:D(e,T(I(t))).toString()}function W(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{y(e)?e.then((e=>{t({data:e,index:o}),i()})).catch((e=>{n({error:e,index:o}),i()})):(t({data:e,index:o}),i())}))}const B=n.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function k(e){return new Promise((t=>{B((()=>{e(t)}))}))}let H=null;function F(e){H=e}function $(e){H!==e&&(F(e),O((()=>{F(null)})))}function j(){return H}function K(){F(null)}function q(e,t){const n=(window.rawDocument||document).createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function G(e,t,n){if(t)if(e.innerHTML="",n){const n=t.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),e.appendChild(o)}else Array.from(t.childNodes).forEach((t=>{e.appendChild(t)}));return e}function Q(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function z(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||/^title$/i.test(e)||/^:root$/i.test(e)}function X(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function V(e){return e?e.replace(/^\s+|\s+$/g,""):""}function Y(){return navigator.userAgent.indexOf("Firefox")>-1}function J(e){const t={},n=e.split("&");for(const e of n){const n=e.indexOf("="),o=n<0?e:e.slice(0,n),i=n<0?null:e.slice(n+1);if(o in t){let e=t[o];r(e)||(e=t[o]=[e]),e.push(i)}else t[o]=i}return t}function Z(e){let t="";for(const n in e){const o=e[n];if(h(o))t+=(t.length?"&":"")+n;else{(r(o)?o:[o]).forEach((e=>{p(e)||(t+=(t.length?"&":"")+n,h(e)||(t+="="+e))}))}}return t}function ee(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function te(e){const t=e.attributes,n=new Map;for(let e=0;e<t.length;e++)n.set(t[e].name,t[e].value);return n}function ne(e,t){e?e.push((()=>k((e=>{t(),e()})))):t()}function oe(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function re(e){return e.startsWith("inline-")}function ie(e,t,n,...o){try{_(e)&&e(...o)}catch(e){C(`An error occurred in app ${t} window.${n} \n`,null,e)}}function se(e,t,n,o){var r;if(!e)return C(`element does not exist in lifecycle ${n}`,t);e=X(e),K();const s=i({name:t,container:e},o&&{error:o}),a=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),_(null===(r=Zn.options.lifeCycles)||void 0===r?void 0:r[n])&&Zn.options.lifeCycles[n](a),e.dispatchEvent(a)}function ae(e,t,n={}){var o;const r=new CustomEvent(t,{detail:n});null===(o=e.sandBox)||void 0===o||o.microAppWindow.dispatchEvent(r)}function ce(e,t=null,n={}){return K(),_(Zn.options.fetch)?Zn.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class le{static getInstance(){return this.instance||(this.instance=new le),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;(o.includes(".js")?Promise.resolve(`<micro-app-head><script src='${o}'><\/script></micro-app-head><micro-app-body></micro-app-body>`):ce(o,n,{cache:"no-cache"})).then((r=>{if(!r){const t="html is empty, please check in detail";return e.onerror(new Error(t)),C(t,n)}r=this.formatHTML(o,r,n),t(r,e)})).catch((t=>{C(`Failed to fetch data from ${e.url}, micro-app stop rendering`,n,t),e.onLoadError(t)}))}formatHTML(e,t,n){return this.processHtml(e,t,n,Zn.options.plugins).replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>")))}processHtml(e,t,n,o){var r;if(!o)return t;const i=[];return o.global&&i.push(...o.global),(null===(r=o.modules)||void 0===r?void 0:r[n])&&i.push(...o.modules[n]),i.length>0?i.reduce(((t,n)=>A(n)&&_(n.processHtml)?n.processHtml(t,e):t),t):t}}const ue=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,pe=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function he(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class de{constructor(){this.cssText="",this.prefix="",this.baseURI="",this.linkPath="",this.result="",this.scopecssDisable=!1,this.scopecssDisableSelectors=[],this.scopecssDisableNextLine=!1,this.mediaRule=this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/,"@media"),this.supportsRule=this.createMatcherForRuleWithChildRule(/^@supports *([^{]+)/,"@supports"),this.documentRule=this.createMatcherForRuleWithChildRule(/^@([-\w]+)?document *([^{]+)/,"@document"),this.hostRule=this.createMatcherForRuleWithChildRule(/^@host\s*/,"@host"),this.importRule=this.createMatcherForNoneBraceAtRule("import"),this.charsetRule=this.createMatcherForNoneBraceAtRule("charset"),this.namespaceRule=this.createMatcherForNoneBraceAtRule("namespace"),this.containerRule=this.createMatcherForRuleWithChildRule(/^@container *([^{]+)/,"@container")}exec(e,t,n,o){return this.cssText=e,this.prefix=t,this.baseURI=n,this.linkPath=o||"",this.matchRules(),Y()?decodeURIComponent(this.result):this.result}reset(){this.cssText=this.prefix=this.baseURI=this.linkPath=this.result="",this.scopecssDisable=this.scopecssDisableNextLine=!1,this.scopecssDisableSelectors=[]}matchRules(){for(this.matchLeadingSpaces(),this.matchComments();this.cssText.length&&"}"!==this.cssText.charAt(0)&&(this.matchAtRule()||this.matchStyleRule());)this.matchComments()}matchStyleRule(){const e=this.formatSelector(!0);return this.scopecssDisableNextLine=!1,e?(this.recordResult(e),this.matchComments(),this.styleDeclarations(),this.matchLeadingSpaces(),!0):he("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=V(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||ue.test(n)||(n=pe.test(n)?n.replace(pe,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||he("Declaration missing '}'",this.linkPath)):he("Declaration missing '{'",this.linkPath)}matchAllDeclarations(e=1){let t=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^{}/])*/,!0)[0];if(t&&(this.scopecssDisableNextLine||this.scopecssDisable&&!this.scopecssDisableSelectors.length||(t=t.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,t)=>/^((data|blob):|#)/.test(t)||/^(https?:)?\/\//.test(t)?e:(/^((\.\.?\/)|[^/])/.test(t)&&this.linkPath&&(this.baseURI=function(e){const t=e.split("/");return t.pop(),I(t.join("/")+"/")}(this.linkPath)),`url("${U(t,this.baseURI)}")`)))),this.recordResult(t)),this.scopecssDisableNextLine=!1,this.cssText){if("}"===this.cssText.charAt(0)){if(!e)return;return e>1&&this.commonMatch(/}+/),this.matchAllDeclarations(e-1)}return"/"===this.cssText.charAt(0)&&("*"===this.cssText.charAt(1)?this.matchComments():this.commonMatch(/\/+/)),"{"===this.cssText.charAt(0)&&(this.commonMatch(/{+\s*/),e++),this.matchAllDeclarations(e)}}matchAtRule(){return"@"===this.cssText[0]&&(this.scopecssDisableNextLine=!1,this.keyframesRule()||this.mediaRule()||this.customMediaRule()||this.supportsRule()||this.importRule()||this.charsetRule()||this.namespaceRule()||this.containerRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return he("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return he("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):he("@keyframes missing '}'",this.linkPath)}keyframeRule(){let e;const t=[];for(;e=this.commonMatch(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),this.commonMatch(/^,\s*/);return!!t.length&&(this.styleDeclarations(),this.matchLeadingSpaces(),!0)}customMediaRule(){return!!this.commonMatch(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/)&&(this.matchLeadingSpaces(),!0)}pageRule(){return!!this.commonMatch(/^@page */)&&(this.formatSelector(!1),this.scopecssDisableNextLine=!1,this.commonHandlerForAtRuleWithSelfRule("page"))}fontFaceRule(){return!!this.commonMatch(/^@font-face\s*/)&&this.commonHandlerForAtRuleWithSelfRule("font-face")}createMatcherForRuleWithChildRule(e,t){return()=>!!this.commonMatch(e)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):he(`${t} missing '}'`,this.linkPath)):he(`${t} missing '{'`,this.linkPath))}createMatcherForNoneBraceAtRule(e){const t=new RegExp("^@"+e+"\\s*([^;]+);");return()=>!!this.commonMatch(t)&&(this.matchLeadingSpaces(),!0)}commonHandlerForAtRuleWithSelfRule(e){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):he(`@${e} missing '}'`,this.linkPath)):he(`@${e} missing '{'`,this.linkPath)}matchComments(){for(;this.matchComment(););}matchComment(){if("/"!==this.cssText.charAt(0)||"*"!==this.cssText.charAt(1))return!1;this.scopecssDisableNextLine=!1;let e=2;for(;""!==this.cssText.charAt(e)&&("*"!==this.cssText.charAt(e)||"/"!==this.cssText.charAt(e+1));)++e;if(e+=2,""===this.cssText.charAt(e-1))return he("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=V(t.replace(/^\s*!/,"")),"scopecss-disable-next-line"===t)this.scopecssDisableNextLine=!0;else if(/^scopecss-disable/.test(t))if("scopecss-disable"===t)this.scopecssDisable=!0;else{this.scopecssDisable=!0;t.replace("scopecss-disable","").split(",").forEach((e=>{this.scopecssDisableSelectors.push(V(e))}))}else"scopecss-enable"===t&&(this.scopecssDisable=!1,this.scopecssDisableSelectors=[]);return this.cssText=this.cssText.slice(e),this.matchLeadingSpaces(),!0}commonMatch(e,t=!1){const n=e.exec(this.cssText);if(!n)return;const o=n[0];return this.cssText=this.cssText.slice(o.length),t||this.recordResult(o),n}matchOpenBrace(){return this.commonMatch(/^{\s*/)}matchCloseBrace(){return this.commonMatch(/^}/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){Y()?this.result+=encodeURIComponent(e):this.result+=e}}function me(e,t,n,o,r){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let i=null;try{i=fe.exec(e.textContent,n,o,r),fe.reset()}catch(e){fe.reset(),C("An error occurred while parsing CSS:\n",t,e)}i&&(e.textContent=i)}}let fe;function _e(e,t,n){if(t.scopecss){const o=Ae(t.name);if(fe||(fe=new de),e.textContent)me(e,t.name,o,t.url,n);else{const r=new MutationObserver((function(){r.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&me(e,t.name,o,t.url,n)}));r.observe(e,{childList:!0})}}return e}function Ae(e,t=!1){const n=t?"\\":"";return`${Zn.tagName}${n}[name=${e}${n}]`}function we(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function ye(e){const t=new CustomEvent("load");we(t,e),_(e.onload)?e.onload(t):e.dispatchEvent(t)}function ge(e){const t=new CustomEvent("error");we(t,e),_(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var be,ve,Ee,Pe,Re,Se,Me=function(){const e=new Map,t=new Map;function n(e){return{setInfo(t,n){e.set(t,n)},getInfo(t){var n;return null!==(n=e.get(t))&&void 0!==n?n:null},hasInfo:t=>e.has(t),deleteInfo:t=>e.delete(t)}}return{link:n(e),script:Object.assign(Object.assign({},n(t)),{deleteInlineInfo(e){e.forEach((e=>{re(e)&&t.delete(e)}))}})}}();function Ce(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){i=U(i,n.url);let t=Me.link.getInfo(i);const r={attrs:te(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",appSpace:{[n.name]:r}},Me.link.setInfo(i,t),o)return{address:i,linkInfo:t};n.source.links.add(i),s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),t.appSpace[n.name].placeholder=s}else r&&["prefetch","preload","prerender"].includes(r)?o?s=document.createComment(`link element with rel=${r}${i?" & href="+i:""} removed by micro-app`):null==t||t.removeChild(e):i&&Hn.rawSetAttribute.call(e,"href",U(i,n.url));return o?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function Ne(e,t,n,o){const r=Array.from(t.source.links),i=r.map((e=>{const n=Me.link.getInfo(e);return n.code?n.code:ce(e,t.name)})),s=o?[]:null;W(i,(e=>{ne(s,(()=>function(e,t,n,o){const r=Me.link.getInfo(e);r.code=t;const i=r.appSpace[o.name],s=i.placeholder;if(s){const t=q("style");Oe(o,e,t,r,i.attrs),s.parentNode?s.parentNode.replaceChild(t,s):n.appendChild(t),i.placeholder=null}}(r[e.index],e.data,n,t)))}),(e=>{C(e,t.name)}),(()=>{o?o.then((()=>{s.push((()=>Promise.resolve(t.onLoad(e)))),oe(s)})):t.onLoad(e)}))}function Oe(e,t,n,o,r){if(e.scopecss){const r=o.appSpace[e.name];if(r.prefix=r.prefix||Ae(e.name),r.parsedCode)n.textContent=r.parsedCode;else{const i=function(e,t,n){const o=n.appSpace;for(const n in o)if(n!==e){const e=o[n];if(e.parsedCode)return e.parsedCode.replace(new RegExp(Ae(n,!0),"g"),t)}}(e.name,r.prefix,o);i?n.textContent=i:(n.textContent=o.code,_e(n,e,t)),r.parsedCode=n.textContent}}else n.textContent=o.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),Hn.rawSetAttribute.call(e,n,t))}))}(n,r)}!function(e){e.NAME="name",e.URL="url"}(be||(be={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOAD_FAILED="load_failed",e.BEFORE_MOUNT="before_mount",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(ve||(ve={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error",e.BEFORESHOW="beforeshow",e.AFTERSHOW="aftershow",e.AFTERHIDDEN="afterhidden"}(Ee||(Ee={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(Pe||(Pe={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(Re||(Re={})),function(e){e.DESTROY="destroy",e.DESTORY="destory",e.INLINE="inline",e.DISABLESCOPECSS="disableScopecss",e.DISABLESANDBOX="disableSandbox",e.DISABLE_SCOPECSS="disable-scopecss",e.DISABLE_SANDBOX="disable-sandbox",e.DISABLE_MEMORY_ROUTER="disable-memory-router",e.DISABLE_PATCH_REQUEST="disable-patch-request",e.KEEP_ROUTER_STATE="keep-router-state",e.HIDDEN_ROUTER="hidden-router",e.KEEP_ALIVE="keep-alive",e.CLEAR_DATA="clear-data",e.SSR="ssr",e.FIBER="fiber"}(Se||(Se={}));const De=[1,2,3],Ie="search",xe="custom",Le=[Ie,"history",xe],Te=["popstate","hashchange","load","beforeunload","unload","unmount","appstate-change","statechange","mounted"],Ue=["onpopstate","onhashchange","onload","onbeforeunload","onunload","onerror"],We=["DOMContentLoaded","readystatechange"],Be=["onreadystatechange"],ke=["window","self","globalThis"],He=["rawWindow","rawDocument"],Fe="window,self,globalThis,document,Document,Array,Object,String,Boolean,Math,Number,Symbol,Date,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,navigator,undefined,location,history",$e=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function je(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function Ke(e,t){return e.inline||t.appSpace[e.name].inline||je(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function qe(e){return e.iframe?e.sandBox.microAppWindow:Hn.rawWindow}function Ge(e,t,n){return function(e,t,n){const o=t.appSpace;for(const t in o)if(t!==e.name){const e=o[t];if(e.parsedCode===n&&e.parsedFunction)return e.parsedFunction}}(e,t,n)||function(e,t){return new(qe(e).Function)(t)}(e,n)}function Qe(){const e="inline-"+Math.random().toString(36).substr(2,15);return Me.script.hasInfo(e)?Qe():e}function ze(e,t){return e.useSandbox&&!je(e,t)}function Xe(e,t){return ze(e,t)?e.iframe?"iframe":"with":"disable"}function Ve(e,t,n,o=!1){var r;let i=null,s=e.getAttribute("src");if(s&&(s=U(s,n.url)),e.hasAttribute("exclude")||Je(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!$e.includes(e.type)||e.hasAttribute("ignore")||Ze(s,n.name))return(null===(r=Hn.rawDocument)||void 0===r?void 0:r.currentScript)&&delete Hn.rawDocument.currentScript,null;if(Hn.supportModuleScript&&e.noModule||!Hn.supportModuleScript&&"module"===e.type)i=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(s){let t=Me.script.getInfo(s);const r={async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:te(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",isExternal:!0,appSpace:{[n.name]:r}},Me.script.setInfo(s,t),o)return{address:s,scriptInfo:t};n.source.scripts.add(s),i=document.createComment(`script with src='${s}' extract by micro-app`)}else if(e.textContent){const t=Qe(),r={code:e.textContent,isExternal:!1,appSpace:{[n.name]:{async:!1,defer:"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:te(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),Me.script.setInfo(t,r),i=document.createComment("inline script extract by micro-app")}else o||(i=document.createComment("script element removed by micro-app"))}return o?{replaceComment:i}:null==t?void 0:t.replaceChild(i,e)}function Ye(e){var t,n,o;return[...(null===(t=Zn.options.plugins)||void 0===t?void 0:t.global)||[],...(null===(o=null===(n=Zn.options.plugins)||void 0===n?void 0:n.modules)||void 0===o?void 0:o[e])||[]]}function Je(e,t){if(!e)return!1;return(Ye(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function Ze(e,t){if(!e)return!1;return(Ye(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function et(e,t){const n=Array.from(t.source.scripts),o=[],r=[];for(const e of n){const n=Me.script.getInfo(e),i=n.appSpace[t.name];(!i.defer&&!i.async||t.isPrefetch&&!t.isPrerender)&&(o.push(n.code?n.code:ce(e,t.name)),r.push([e,n]))}const i=t.isPrefetch||t.fiber?[]:null;o.length?W(o,(e=>{ne(i,(()=>function(e,t,n,o){if(t.code=n,o.isPrefetch&&2===o.prefetchLevel){const r=t.appSpace[o.name];if(!r.parsedCode&&(r.parsedCode=nt(e,o,n,t),r.sandboxType=Xe(o,t),!Ke(o,t)))try{r.parsedFunction=Ge(o,t,r.parsedCode)}catch(e){C("Something went wrong while handling preloaded resources",o.name,"\n",e)}}}(r[e.index][0],r[e.index][1],e.data,t)))}),(e=>{C(e,t.name)}),(()=>{i?(i.push((()=>Promise.resolve(t.onLoad(e)))),oe(i)):t.onLoad(e)})):t.onLoad(e)}function tt(e,t,n,o,r){try{!function(e){!function(e){e.sandBox&&(Hn.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],s=Xe(t,n);if(i.parsedCode&&i.sandboxType===s||(i.parsedCode=nt(e,t,n.code,n),i.sandboxType=s,i.parsedFunction=null),Ke(t,n)){const s=r||q("script");if(function(e,t,n,o,r,i){if(n){if(Hn.rawSetAttribute.call(o,"type","module"),re(e)?o.textContent=t:o.src=e,i){const t=()=>{i.moduleCount&&i.moduleCount--,i(0===i.moduleCount)};re(e)?O(t):o.onload=t}}else o.textContent=t;!function(e,t){t.forEach(((t,n)=>{"type"===n&&"module"===t||"defer"===n||"async"===n||("src"===n&&(n="data-origin-src"),Hn.rawSetAttribute.call(e,n,t))}))}(o,r)}(e,i.parsedCode,je(t,n),s,i.attrs,o),!r){const e=t.iframe?t.sandBox.microBody:t.querySelector("micro-app-body");null==e||e.appendChild(s)}}else!function(e,t){const n=t.appSpace[e.name];n.parsedFunction||(n.parsedFunction=Ge(e,t,n.parsedCode));n.parsedFunction.call(qe(e))}(t,n)}catch(n){throw console.error(`[micro-app from ${r?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e),n}}function nt(e,t,n,o){return A(Zn.options.plugins)&&(n=function(e,t,n,o){var r;const i=ot(o.global,t,e);return ot(null===(r=o.modules)||void 0===r?void 0:r[n],i,e)}(e,n,t.name,Zn.options.plugins)),ze(t,o)?t.iframe?`(function(window,self,global,location){;${n}\n${re(e)?"":`//# sourceURL=${e}\n`}}).call(window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyLocation);`:`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${Fe}){;${n}\n${re(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${Fe})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function ot(e,t,n){return r(e)?e.reduce(((e,t)=>A(t)&&_(t.loader)?t.loader(e,n):e),t):t}function rt(e,t,n,o){const r=Array.from(e.children);r.length&&r.forEach((e=>{rt(e,t,n,o)}));for(const n of r)P(n)?n.hasAttribute("exclude")||Je(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||Ze(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&Hn.rawSetAttribute.call(n,"href",U(n.getAttribute("href"),t.url)):Ce(n,e,t):R(n)?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&ne(o,(()=>_e(n,t))):S(n)?Ve(n,e,t):"[object HTMLImageElement]"===u(n)&&n.hasAttribute("src")&&Hn.rawSetAttribute.call(n,"src",U(n.getAttribute("src"),t.url))}function it(e,t){const n=function(e){const t=q("div");return t.innerHTML=e,t}(e),o=Hn.rawElementQuerySelector.call(n,"micro-app-head"),r=Hn.rawElementQuerySelector.call(n,"micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),C(e,t.name)}const i=t.isPrefetch||t.fiber?[]:null;rt(n,t,o,i);const s=oe(i);t.source.links.size?Ne(n,t,o,s):s?s.then((()=>t.onLoad(n))):t.onLoad(n),t.source.scripts.size?et(n,t):t.onLoad(n)}const st=new class{constructor(){this.eventList=new Map,this.queue=[],this.recordStep={},this.process=()=>{var e,t;let n;const o=this.recordStep,r=this.queue;for(this.recordStep={},this.queue=[];n=r.shift();){const r=this.eventList.get(n),i=r.tempData,s=r.force;let a;if(r.tempData=null,r.force=!1,s||!this.isEqual(r.data,i)){r.data=i||r.data;for(const e of r.callbacks){const t=e(r.data);t&&(null!=a?a:a=[]).push(t)}null===(t=(e=o[n]).dispatchDataEvent)||void 0===t||t.call(e),o[n].nextStepList.forEach((e=>e(a)))}}}}isLegalName(e){return!!e||(C("event-center: Invalid name"),!1)}enqueue(e,t,n){this.recordStep[e]?(this.recordStep[e].nextStepList.push(t),n&&(this.recordStep[e].dispatchDataEvent=n)):this.recordStep[e]={nextStepList:[t],dispatchDataEvent:n},!this.queue.includes(e)&&1===this.queue.push(e)&&O(this.process)}isEqual(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==t[n])return!1;return!0}on(e,t,n=!1){if(this.isLegalName(e)){if(!_(t))return C("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(_(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,o,r){if(this.isLegalName(e)){if(!A(t))return C("event-center: data must be object");let s=this.eventList.get(e);s?(s.tempData=i({},s.tempData||s.data,t),!s.force&&(s.force=!!o)):(s={data:t,callbacks:new Set},this.eventList.set(e,s),s.force=!0),this.enqueue(e,n,r)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function at(e,t){return d(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class ct{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),st.on("global",e,t)}removeGlobalDataListener(e){_(e)&&st.off("global",e)}setGlobalData(e,t,n){K(),st.dispatch("global",e,(e=>_(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return st.getData("global")}clearGlobalData(){st.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=st.eventList.get("global");if(t)for(const n of t.callbacks)(e&&e===n.__APP_NAME__||!e&&!n.__APP_NAME__)&&t.callbacks.delete(n)}}class lt extends ct{addDataListener(e,t,n){st.on(at(L(e),!1),t,n)}removeDataListener(e,t){_(t)&&st.off(at(L(e),!1),t)}getData(e,t=!1){return st.getData(at(L(e),t))}setData(e,t,n,o){st.dispatch(at(L(e),!0),t,(e=>_(n)&&n(e)),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){st.clearData(at(L(e),t))}clearDataListener(e){st.off(at(L(e),!1))}}class ut extends ct{constructor(e){super(),this.appName=L(e),!this.appName&&C(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,st.on(at(this.appName,!0),e,t)}removeDataListener(e){_(e)&&st.off(at(this.appName,!0),e)}getData(e=!0){return st.getData(at(this.appName,e))}dispatch(e,t,n){K(),st.dispatch(at(this.appName,!1),e,(e=>_(t)&&t(e)),n,(()=>{const t=Sn.get(this.appName);if((null==t?void 0:t.container)&&A(e)){const e=new CustomEvent("datachange",{detail:{data:st.getData(at(this.appName,!1))}});X(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){st.clearData(at(this.appName,e))}clearDataListener(){st.off(at(this.appName,!0))}}function pt(e){var t,n;if(e){e.umdDataListeners={global:new Set(null===(t=e.umdDataListeners)||void 0===t?void 0:t.global),normal:new Set(null===(n=e.umdDataListeners)||void 0===n?void 0:n.normal)};const o=st.eventList.get("global");if(o)for(const t of o.callbacks)e.appName===t.__APP_NAME__&&e.umdDataListeners.global.add(t);const r=st.eventList.get(at(e.appName,!0));if(r)for(const t of r.callbacks)e.umdDataListeners.normal.add(t)}}function ht(e){if(null==e?void 0:e.umdDataListeners){for(const t of e.umdDataListeners.global)e.addGlobalDataListener(t,t.__AUTO_TRIGGER__);for(const t of e.umdDataListeners.normal)e.addDataListener(t,t.__AUTO_TRIGGER__);dt(e)}}function dt(e){null==e||delete e.umdDataListeners}class mt{constructor(){this.appInstanceMap=Sn}static getInstance(){return this.instance||(this.instance=new mt),this.instance}get(e){return this.appInstanceMap.get(e)}set(e,t){this.appInstanceMap.set(e,t)}getAll(){return Array.from(this.appInstanceMap.values())}clear(){this.appInstanceMap.clear()}}function ft(){_t(),mt.getInstance().getAll().forEach((e=>{e.container&&X(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&mt.getInstance().clear()}function _t(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",ft,!1)}function At(e){return m(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=_(t=e)&&0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");var t}function wt(e,t,n="WINDOW"){if(_(e)&&!function(e){return m(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=g(e)}(e)&&!At(e)){const o=`__MICRO_APP_BOUND_${n}_FUNCTION__`;if(e[o])return e[o];const r=e.bind(t);for(const t in e)r[t]=e[t];return e.hasOwnProperty("prototype")&&s(r,"prototype",{value:e.prototype,configurable:!0,enumerable:!1,writable:!0}),e[o]=r}return e}function yt(e,t,n){const{proxyDocument:o,documentEffect:r}=function(e,t){const n=new Map,o=new Map;let r=null,i=null;const{rawDocument:s,rawCreateElement:a,rawAddEventListener:c,rawRemoveEventListener:l}=Hn;function u(t,n){const o=a.call(s,t,n);return o.__MICRO_APP_NAME__=e,o}function p(e,t,o){const r=n.get(e);r?r.add(t):n.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=o),c.call(s,e,t,o)}function h(e,t,o){const r=n.get(e);(null==r?void 0:r.size)&&r.has(t)&&r.delete(t),l.call(s,e,t,o)}const d=()=>{o.clear(),i=null},m=()=>{i=r||i,n.forEach(((e,t)=>{if(e.size){const n=o.get(t)||[];o.set(t,new Set([...n,...e]))}}))},f=()=>{i&&!r&&(y.onclick=i),o.forEach(((e,t)=>{for(const n of e)y.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),d()},A=()=>{_(r)&&l.call(s,"click",r),r=null,n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(s,t,n)})),n.clear())},w=(()=>{var e;const t=new Map([["onclick",e=>{_(r)&&l.call(s,"click",r,!1),_(e)&&c.call(s,"click",e,!1),r=e}]]),n=(null===(e=Zn.options)||void 0===e?void 0:e.customProxyDocumentProps)||new Map;return new Map([...t,...n])})(),y=new Proxy(s,{get:(n,o)=>{var i;return $(e),"createElement"===o?u:o===Symbol.toStringTag?"ProxyDocument":"defaultView"===o?t.proxyWindow:"onclick"===o?r:"addEventListener"===o?p:"removeEventListener"===o?h:"microAppElement"===o?null===(i=Sn.get(e))||void 0===i?void 0:i.container:"__MICRO_APP_NAME__"===o?e:wt(Reflect.get(n,o),s,"DOCUMENT")},set:(e,t,n)=>{if(w.has(t)){w.get(t)(n)}else"microAppElement"!==t&&Reflect.set(e,t,n);return!0}});return{proxyDocument:y,documentEffect:{reset:d,record:m,rebuild:f,release:A}}}(e,n),i=function(e,t){const{rawDocument:n,rawRootDocument:o}=Hn;class r{static[Symbol.hasInstance](e){let n=e;for(;n;)if(n=Object.getPrototypeOf(n),n===r.prototype)return!0;return e===t||e instanceof o}}return Object.setPrototypeOf(r,o),Object.setPrototypeOf(r.prototype,new Proxy(o.prototype,{get:(t,o)=>($(e),wt(Reflect.get(t,o),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),r}(e,o);return a(t,{document:{configurable:!1,enumerable:!0,get:()=>o},Document:{configurable:!1,enumerable:!1,get:()=>i}}),r}function gt(e,t,n){return function(e){const t=Hn.rawWindow;Object.getOwnPropertyNames(t).filter((e=>/^on/.test(e)&&!Ue.includes(e))).forEach((n=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,writable:!0};s(e,n,{enumerable:o,configurable:!0,get:()=>t[n],set:(null!=r?r:i)?e=>{t[n]=e}:void 0})}))}(t),function(e,t,n){const o=Hn.rawWindow,r=new Map,i=new Proxy(t,{get:(t,r)=>($(e),Reflect.has(t,r)||d(r)&&/^__MICRO_APP_/.test(r)||n.scopeProperties.includes(r)?(He.includes(r)&&K(),Reflect.get(t,r)):wt(Reflect.get(o,r),o)),set:(e,t,r)=>{if(n.adapter.escapeSetterKeyList.includes(t))Reflect.set(o,t,r);else if(l.call(e,t)||!l.call(o,t)||n.scopeProperties.includes(t))!Reflect.has(e,t)&&n.injectedKeys.add(t),Reflect.set(e,t,r);else{const i=Object.getOwnPropertyDescriptor(o,t),{configurable:a,enumerable:c,writable:l,set:u}=i;s(e,t,{value:r,configurable:a,enumerable:c,writable:null!=l?l:!!u}),n.injectedKeys.add(t)}return(n.escapeProperties.includes(t)||n.adapter.staticEscapeProperties.includes(t)&&!Reflect.has(o,t))&&!n.scopeProperties.includes(t)&&(!Reflect.has(o,t)&&n.escapeKeys.add(t),Reflect.set(o,t,r)),!0},has:(e,t)=>n.scopeProperties.includes(t)?n.adapter.staticScopeProperties.includes(t)?!!e[t]:t in e:t in e||t in o,getOwnPropertyDescriptor:(e,t)=>{if(l.call(e,t))return r.set(t,"target"),Object.getOwnPropertyDescriptor(e,t);if(l.call(o,t)){r.set(t,"rawWindow");const e=Object.getOwnPropertyDescriptor(o,t);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,t,n)=>"rawWindow"===r.get(t)?Reflect.defineProperty(o,t,n):Reflect.defineProperty(e,t,n),ownKeys:e=>Reflect.ownKeys(o).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,t)=>!l.call(e,t)||(n.injectedKeys.has(t)&&n.injectedKeys.delete(t),n.escapeKeys.has(t)&&Reflect.deleteProperty(o,t),Reflect.deleteProperty(e,t))});n.proxyWindow=i}(e,t,n),function(e){const t=new Map,n=new Map,o=new Map,r=new Map,{rawWindow:i,rawAddEventListener:s,rawRemoveEventListener:a,rawDispatchEvent:c,rawSetInterval:l,rawSetTimeout:u,rawClearInterval:p,rawClearTimeout:h}=Hn;function d(t){return Te.includes(t)?e:i}e.addEventListener=function(e,n,o){const r=t.get(e);r?r.add(n):t.set(e,new Set([n])),n&&(n.__MICRO_APP_MARK_OPTIONS__=o),s.call(d(e),e,n,o)},e.removeEventListener=function(e,n,o){const r=t.get(e);(null==r?void 0:r.size)&&r.has(n)&&r.delete(n),a.call(d(e),e,n,o)},e.dispatchEvent=function(e){return c.call(d(null==e?void 0:e.type),e)},e.setInterval=function(e,t,...n){const r=l.call(i,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const o=u.call(i,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.clearInterval=function(e){o.delete(e),p.call(i,e)},e.clearTimeout=function(e){r.delete(e),h.call(i,e)};const m=()=>{n.clear()},f=()=>{n.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),m()};return{reset:m,record:()=>{t.forEach(((e,t)=>{if(e.size){const o=n.get(t)||[];n.set(t,new Set([...o,...e]))}}))},rebuild:f,release:e=>{t.size&&(t.forEach(((e,t)=>{for(const n of e)a.call(d(t),t,n)})),t.clear()),e&&(o.forEach(((e,t)=>{p.call(i,t)})),r.forEach(((e,t)=>{h.call(i,t)})),o.clear(),r.clear())}}}(t)}function bt(e,t){if(!Lt(e)){const n=Hn.rawWindow.history.state,o={microAppState:i({},null==n?void 0:n.microAppState,{[e]:t})};return i({},n,o)}return t}function vt(e){var t;const n=Hn.rawWindow.history.state;return Lt(e)?n:(null===(t=null==n?void 0:n.microAppState)||void 0===t?void 0:t[e])||null}const Et=/&/g,Pt=/=/g,Rt=/%M1/g,St=/%M2/g;function Mt(e){return encodeURIComponent(Nt(e).replace(Et,"%M1").replace(Pt,"%M2"))}function Ct(e){return Nt(e).replace(Rt,"&").replace(St,"=")}function Nt(e){try{const t=decodeURIComponent(e);return e===t||Rt.test(t)||St.test(t)?t:Nt(t)}catch(t){return e}}function Ot(e){var t,n;const o=Hn.rawWindow.location;if(!Lt(e)){const r=It(o.search,o.hash),i=(null===(t=r.hashQuery)||void 0===t?void 0:t[e])||(null===(n=r.searchQuery)||void 0===n?void 0:n[e]);return d(i)?Ct(i):null}return o.pathname+o.search+o.hash}function Dt(e,t){const n=t.pathname+t.search+t.hash;let o=!1;if(!Lt(e)){let{pathname:t,search:r,hash:i}=Hn.rawWindow.location;const s=It(r,i),a=Mt(n);if(i&&!r){o=!0,s.hashQuery?s.hashQuery[e]=a:s.hashQuery={[e]:a};const t=i.includes("?")?i.slice(0,i.indexOf("?")+1):i+"?";i=t+Z(s.hashQuery)}else s.searchQuery?s.searchQuery[e]=a:s.searchQuery={[e]:a},r="?"+Z(s.searchQuery);return{fullPath:t+r+i,isAttach2Hash:o}}return{fullPath:n,isAttach2Hash:o}}function It(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=J(e.slice(1))),t.includes("?")&&(n.hashQuery=J(t.slice(t.indexOf("?")+1))),n}function xt(e){const t=Sn.get(e);return!(!t||t.isPrefetch)}function Lt(e){const t=Sn.get(e);return!t||!t.sandBox||t.routerMode===xe}function Tt(e,t){let n;return n=t?t.getDisposeResult("disable-memory-router")?xe:e||Zn.options["router-mode"]||"":Zn.options["disable-memory-router"]?xe:e||Zn.options["router-mode"]||"",Le.includes(n)?n:Ie}function Ut(e){const t=Hn.rawWindow,n=t=>{qn({excludeHiddenApp:!0,excludePreRender:!0}).includes(e)&&!t.onlyForBrowser&&Wt(e,Ot(e))};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function Wt(e,t){const n=Sn.get(e),o=n.sandBox.proxyWindow,r=n.sandBox.microAppWindow;let i=!1;const s=o.location.href;if(t){const n=o.location.hash;cn(e,t,r.location),i=o.location.hash!==n}!function(e,t,n){const o=new PopStateEvent("popstate",{state:vt(e)});n.dispatchEvent(o),Cn(e)||_(t.onpopstate)&&t.onpopstate(o)}(e,o,r),i&&function(e,t,n,o){const r=new HashChangeEvent("hashchange",{newURL:t.location.href,oldURL:o});n.dispatchEvent(r),Cn(e)||_(t.onhashchange)&&t.onhashchange(r)}(e,o,r,s),K()}function Bt(e,t,n){K(),xt(e)&&(function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),Hn.rawWindow.dispatchEvent(t)}(t),n&&function(e){const t=new HashChangeEvent("hashchange",{newURL:Hn.rawWindow.location.href,oldURL:e});Hn.rawWindow.dispatchEvent(t)}(n))}function kt(e,t){const n=Hn.rawWindow.history;function o(n){return function(...o){var r,i,s;if(d(o[2])||b(o[2])){const a=D(o[2],t.href),c=a.pathname+a.search+a.hash;Ft(e,n,Dt(e,a),!0,bt(e,o[0]),o[1]),c!==t.fullPath&&cn(e,c,t),null===(s=null===(r=Sn.get(e))||void 0===r?void 0:(i=r.sandBox).updateIframeBase)||void 0===s||s.call(i)}else Ht(e,n,o[2],o[0],o[1])}}const r=o("pushState"),i=o("replaceState");return Cn(e)?{pushState:r,replaceState:i}:new Proxy(n,{get:(t,n)=>"state"===n?vt(e):"pushState"===n?r:"replaceState"===n?i:wt(Reflect.get(t,n),t,"HISTORY"),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})}function Ht(e,t,n,o=null,r=""){if(xt(e)){("pushState"===t?Hn.rawPushState:Hn.rawReplaceState).call(Hn.rawWindow.history,o,r,n)}}function Ft(e,t,n,o,r,i){if(xt(e)){const s=Hn.rawWindow.location,a=s.pathname+s.search+s.hash,c=n.isAttach2Hash&&a!==n.fullPath?s.href:null;Ht(e,t,n.fullPath,r,i),a===n.fullPath||Lt(e)||Bt(e,o,c)}}function $t(e,t,n){Ft(e,"replaceState",t,!0,n)}function jt(e){const t=Hn.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.microAppState)&&(!A(n[0])||!n[0].microAppState)&&(d(n[2])||b(n[2]))){const e=t.location.href;D(n[2],e).href===e&&(n[0]=i({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),qn({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{if(!Lt(e)&&!Ot(e)){$t(e,Dt(e,Sn.get(e).sandBox.proxyWindow.location),bt(e,vt(e)))}})),K()}}function Kt(){const e=Hn.rawWindow;e.history.pushState=jt(Hn.rawPushState),e.history.replaceState=jt(Hn.rawReplaceState)}function qt(){const e=Hn.rawWindow;e.history.pushState=Hn.rawPushState,e.history.replaceState=Hn.rawReplaceState}const{router:Gt,executeNavigationGuard:Qt,clearRouterWhenUnmount:zt}=function(){function e(e,t,n,o){const r=t.sandBox.proxyWindow.location,i=D(n.path,r.href),s=r.pathname+r.search+r.hash,a=i.pathname+i.search+i.hash;if(s!==a||Ot(e)!==a){!function(e,t,n,o){Ft(e,t,Dt(e,n),!1,bt(e,null!=o?o:null)),K()}(e,o&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state),Lt(e)&&Wt(e,a)}}function t(t){return function(n){return new Promise(((o,r)=>{const i=L(n.name);if(i&&d(n.path))if(qn({excludeHiddenApp:!0,excludePreRender:!0}).includes(i)){const r=Sn.get(i);o(r.sandBox.sandboxReady.then((()=>e(i,r,n,t))))}else r(C("navigation failed, app does not exist or is inactive"));else r(C("navigation failed, name & path are required when use router."+(t?"replace":"push")))}))}}function n(e){return function(...t){return Hn.rawWindow.history[e](...t)}}const r=ee(),i=ee();function s(e,t,n,o){K();for(const r of o)_(r)?r(t,n,e):A(r)&&_(r[e])&&r[e](t,n)}function a(e){if(!Lt(e)){$t(e,Dt(e,Sn.get(e).sandBox.proxyWindow.location),bt(e,vt(e)))}}const c=Object.assign(Object.assign({current:new Map,encode:Mt,decode:Ct,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:r.add,afterEach:i.add,attachToURL:function(e){(e=L(e))&&qn().includes(e)&&a(e)},attachAllToURL:function({includeHiddenApp:e=!1,includePreRender:t=!1}){qn({excludeHiddenApp:!e,excludePreRender:!t}).forEach((e=>a(e)))}},function(){const e=function(){const e=new Map;return{add:function(t,n){return e.set(t,n),()=>!!e.has(t)&&e.delete(t)},get:t=>e.get(t),delete:t=>!!e.has(t)&&e.delete(t)}}();return{setDefaultPage:function(t){const n=L(t.name);return n&&t.path?e.add(n,t.path):o},removeDefaultPage:function(t){return!!(t=L(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){w(t)&&(e=new Proxy(t,{get:(e,t)=>(K(),wt(Reflect.get(e,t),e,"BASEROUTER")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)}))},getBaseAppRouter:()=>e}}());return{router:c,executeNavigationGuard:function(e,t,n){c.current.set(e,t),s(e,t,n,r.list()),B((()=>{s(e,t,n,i.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),Xt=["getComputedStyle","visualViewport","matchMedia","ResizeObserver","IntersectionObserver"],Vt=[/animationFrame$/i,/mutationObserver$/i,/height$|width$/i,/offset$/i,/selection$/i,/^range/i,/^screen/i,/^scroll/i,/X$|Y$/],Yt=["body","head","html","title"],Jt=["host","hostname","port","protocol","origin"],Zt=["childElementCount","children","firstElementChild","firstChild","lastElementChild","activeElement","fullscreenElement","pictureInPictureElement","pointerLockElement","styleSheets"],en=["append","contains","replaceChildren","createRange","getSelection","elementFromPoint","elementsFromPoint","getAnimations"],tn=["characterSet","compatMode","contentType","designMode","dir","doctype","embeds","fullscreenEnabled","hidden","implementation","lastModified","pictureInPictureEnabled","plugins","readyState","referrer","visibilityState","fonts"],nn=["execCommand","createRange","exitFullscreen","exitPictureInPicture","getElementsByTagNameNS","hasFocus","prepend"],on=["href","pathname","search","hash","host","hostname","port","protocol","search"],rn=[...on,"origin","fullPath"];function sn(e,t,n,o,r,i){const a=Hn.rawWindow.location,c=!!n,l=D(t);function u(){return c?n.location:l}function p(t,n){const o=D(t,A.href);if(o.origin===A.origin){const t=Dt(e,o);if(!Lt(e)){if(o.pathname===A.pathname&&o.search===A.search){let r=null;return o.hash!==A.hash&&(t.isAttach2Hash&&(r=a.href),Ht(e,n,t.fullPath)),void(o.hash?Bt(e,!1,r):_())}if(t.isAttach2Hash)return Ht(e,n,t.fullPath),void _()}return t.fullPath}return t}function h(n,o){const r=D(n,t);r[o]===A[o]&&A.hash?Bt(e,!1):(Ht(e,r[o]===A[o]?"replaceState":"pushState",Dt(e,r).fullPath),_())}const d=t=>function(n){if(xt(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&a[t](D(e,a.origin).href)}},m=d("assign"),f=d("replace"),_=e=>a.reload(e);s(u(),"fullPath",{enumerable:!0,configurable:!0,get:()=>A.pathname+A.search+A.hash});const A=new Proxy({},{get:(e,t)=>{const n=u();if(c){if(Jt.includes(t))return o[t];if("href"===t)return n[t].replace(r,i)}return"assign"===t?m:"replace"===t?f:"reload"===t?_:"self"===t?n:wt(Reflect.get(n,t),n,"LOCATION")},set:(n,o,r)=>{if(xt(e)){const n=u();if("href"===o){const e=p(r,"pushState");e&&(a.href=D(e,a.origin).href)}else if("pathname"===o)if(Lt(e))a.pathname=r;else{h(("/"+r).replace(/^\/+/,"/")+A.search+A.hash,"pathname")}else if("search"===o)if(Lt(e))a.search=r;else{h(A.pathname+("?"+r).replace(/^\?+/,"?")+A.hash,"search")}else if("hash"===o)if(Lt(e))a.hash=r;else{const n=A.pathname+A.search+("#"+r).replace(/^#+/,"#"),o=D(n,t);o.hash!==A.hash&&Ft(e,"pushState",Dt(e,o),!1)}else Reflect.set(n,o,r)}return!0}});return A}function an(e,t){const n=i({name:e},t);for(const e of rn)n[e]=t[e];return n}function cn(e,t,n,o){var r;const i=an(e,n),s=D(t,n.href);if(Cn(e)){const t=Sn.get(e).sandBox.microAppWindow;null===(r=t.rawReplaceState)||void 0===r||r.call(t.history,vt(e),"",s.href)}else for(const e of on)n.self[e]=s[e];const a=an(e,n);("auto"===o||i.fullPath!==a.fullPath&&"prevent"!==o)&&Qt(e,a,i)}function ln(e,t,n){const o=Ot(e);o?cn(e,o,t,"auto"):un(e,t,n)}function un(e,t,n){n&&cn(e,n,t,"prevent"),$t(e,Dt(e,t),bt(e,null)),function(e,t){Qt(e,an(e,t),an(e,t))}(e,t)}function pn(e,t,n,o){if(!Lt(e)){if(!o){const{pathname:o,search:r,hash:i}=D(t);cn(e,o+r+i,n,"prevent")}hn(e)}zt(e)}function hn(e){$t(e,function(e,t){var n,o,r,i;let{pathname:s,search:a,hash:c}=t||Hn.rawWindow.location,l=!1;if(!Lt(e)){const t=It(a,c);if(null===(n=t.hashQuery)||void 0===n?void 0:n[e]){l=!0,null===(o=t.hashQuery)||void 0===o||delete o[e];const n=Z(t.hashQuery);c=c.slice(0,c.indexOf("?")+Number(Boolean(n)))+n}else if(null===(r=t.searchQuery)||void 0===r?void 0:r[e]){null===(i=t.searchQuery)||void 0===i||delete i[e];const n=Z(t.searchQuery);a=n?"?"+n:""}}return{fullPath:s+a+c,isAttach2Hash:l}}(e),function(e,t){return Lt(e)?t:(A(null==t?void 0:t.microAppState)&&(p(t.microAppState[e])||delete t.microAppState[e],Object.keys(t.microAppState).length||delete t.microAppState),i({},t))}(e,Hn.rawWindow.history.state))}class dn{constructor(){this.escapeSetterKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue"],this.injectReactHMRProperty()}injectReactHMRProperty(){}}function mn(e,t){const n=Array.from(e.children);n.length&&n.forEach((e=>{mn(e,t)}));for(const e of n)fn(e,t)}function fn(e,t){var n,o;const r=null===(o=null===(n=Sn.get(t))||void 0===n?void 0:n.sandBox)||void 0===o?void 0:o.proxyWindow;return E(e)&&!e.__MICRO_APP_NAME__&&!e.__PURE_ELEMENT__&&r&&(a(e,{baseURI:{configurable:!0,get:()=>r.location.href},__MICRO_APP_NAME__:{configurable:!0,writable:!0,value:t}}),Cn(t)&&e instanceof Hn.rawRootNode&&s(e,"parentNode",{configurable:!0,get:_n(t,Hn.rawParentNodeDesc,!0)})),e}function _n(e,t,n){return function(){var o,r,i;$(e);const s=t.get.call(this);return!n&&M(s)&&(null===(o=Sn.get(e))||void 0===o?void 0:o.container)?(null===(i=(r=Zn.options).getRootElementParentNode)||void 0===i?void 0:i.call(r,this,e))||Hn.rawDocument.body:s}}function An(e,t){const n=p(t)?Hn.rawWindow.fetch:t;return _(n)?function(t,o,...r){return(d(t)||b(t))&&(t=D(t,e).toString()),K(),n.call(Hn.rawWindow,t,o,...r)}:n}function wn(e,t){const n=p(t)?Hn.rawWindow.XMLHttpRequest:t;return g(n)?class extends n{open(t,n,...o){(d(n)&&!/^f(ile|tp):\/\//.test(n)||b(n))&&(n=D(n,e).toString()),K(),super.open(t,n,...o)}}:n}const{createMicroEventSource:yn,clearMicroEventSource:gn}=function(){let e;return{createMicroEventSource:function(t,n,o){const r=p(o)?Hn.rawWindow.EventSource:o;return g(r)?class extends r{constructor(o,r,...i){if((d(o)||b(o))&&(o=D(o,n).toString()),K(),super(o,r,...i),e){const n=e.get(t);n?n.add(this):e.set(t,new Set([this]))}else e=new Map([[t,new Set([this])]])}close(){var n;super.close(),null===(n=e.get(t))||void 0===n||n.delete(this)}}:r},clearMicroEventSource:function(t){const n=null==e?void 0:e.get(t);(null==n?void 0:n.size)&&(n.forEach((e=>{e.close()})),n.clear())}}}();class bn{constructor(e,t){this.active=!1,this.scopeProperties=[],this.escapeProperties=[],this.escapeKeys=new Set,this.injectedKeys=new Set,this.microAppWindow=new EventTarget,this.patchWith((n=>{this.adapter=new dn,this.getSpecialProperties(e),this.patchRouter(e,t,this.microAppWindow),this.windowEffect=gt(e,this.microAppWindow,this),this.documentEffect=yt(e,this.microAppWindow,this),this.initStaticGlobalKeys(e,t,this.microAppWindow),n()}))}start({umdMode:e,baseroute:t,defaultPage:n,disablePatchRequest:o}){this.active||(this.active=!0,this.initRouteState(n),this.removeHistoryListener=Ut(this.microAppWindow.__MICRO_APP_NAME__),Lt(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=t),e||this.initGlobalKeysWhenStart(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow,o),1==++Hn.activeSandbox&&(Un(),Kt()),1==++bn.activeCount&&window.__MICRO_APP_ENVIRONMENT__&&(_t(),window.addEventListener("unmount",ft,!1)),Hn.rawWindow._babelPolyfill&&(Hn.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){var r;this.active&&(this.recordAndReleaseEffect({umdMode:e,clearData:o,destroy:n},!e||n),this.clearRouteState(t),null===(r=this.removeHistoryListener)||void 0===r||r.call(this),e&&!n||(gn(this.microAppWindow.__MICRO_APP_NAME__),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(Hn.rawWindow,e)})),this.escapeKeys.clear()),0==--Hn.activeSandbox&&(Bn(),qt()),--bn.activeCount,this.active=!1)}initStaticGlobalKeys(e,t,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=t,n.__MICRO_APP_PUBLIC_PATH__=T(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="with",n.rawWindow=Hn.rawWindow,n.rawDocument=Hn.rawDocument,n.microApp=i(new ut(e),{removeDomScope:K,pureCreateElement:q,router:Gt}),this.setMappingPropertiesWithRawDescriptor(n)}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),dt(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),pt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),ht(this.microAppWindow.microApp)}releaseGlobalEffect({umdMode:e=!1,clearData:t=!1,isPrerender:n=!1,keepAlive:o=!1,destroy:r=!1}){var i,s,a;this.windowEffect.release(!e&&!o&&!n||r),this.documentEffect.release(),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearDataListener(),null===(s=this.microAppWindow.microApp)||void 0===s||s.clearGlobalDataListener(),t&&(Zn.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(a=this.microAppWindow.microApp)||void 0===a||a.clearData())}getSpecialProperties(e){var t;this.scopeProperties=this.scopeProperties.concat(this.adapter.staticScopeProperties),A(Zn.options.plugins)&&(this.commonActionForSpecialProperties(Zn.options.plugins.global),this.commonActionForSpecialProperties(null===(t=Zn.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(r(e))for(const t of e)A(t)&&(r(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),r(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchWith(e){this.sandboxReady=new Promise((t=>e(t)))}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=Hn.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),s(e,"top",this.createDescriptorForMicroAppWindow("top",t)),s(e,"parent",this.createDescriptorForMicroAppWindow("parent",n)),ke.forEach((t=>{s(e,t,this.createDescriptorForMicroAppWindow(t,this.proxyWindow))}))}createDescriptorForMicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(Hn.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}initGlobalKeysWhenStart(e,t,n,o){n.hasOwnProperty=e=>l.call(n,e)||l.call(Hn.rawWindow,e),this.setHijackProperty(e,n),o||this.patchRequestApi(e,t,n),this.setScopeProperties(n)}setHijackProperty(e,t){let n,o;a(t,{eval:{configurable:!0,enumerable:!1,get:()=>($(e),n||Hn.rawWindow.eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>($(e),o||Hn.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=An(t),r=wn(t),i=yn(e,t);a(n,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=An(t,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=wn(t,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>i,set(n){i=yn(e,t,n)}}})}setScopeProperties(e){this.scopeProperties.forEach((t=>{Reflect.set(e,t,e[t])}))}patchRouter(e,t,n){const{microLocation:o,microHistory:r}=function(e,t){const n=sn(e,t);return{microLocation:n,microHistory:kt(e,n)}}(e,t);a(n,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{Hn.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>r}})}initRouteState(e){ln(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){pn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){un(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){hn(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){mn(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}function vn(e,t,n){return function(e,t){const n=Hn.rawWindow;Xt.forEach((e=>{t[e]=wt(n[e],n)})),Object.getOwnPropertyNames(t).filter((e=>(Vt.some((o=>{if(o.test(e)&&e in t.parent){if(_(n[e]))t[e]=wt(n[e],n);else{const{configurable:o,enumerable:r}=Object.getOwnPropertyDescriptor(t,e)||{configurable:!0,enumerable:!0};o&&s(t,e,{configurable:o,enumerable:r,get:()=>n[e],set:t=>{n[e]=t}})}return!0}return!1})),/^on/.test(e)&&!Ue.includes(e)))).forEach((o=>{const{enumerable:r,writable:i,set:a}=Object.getOwnPropertyDescriptor(t,o)||{enumerable:!0,writable:!0};try{s(t,o,{enumerable:r,configurable:!0,get:()=>n[o],set:(null!=i?i:a)?e=>{n[o]=_(e)?e.bind(t):e}:void 0})}catch(t){N(t,e)}}))}(e,t),function(e,t){const n=Hn.rawWindow,o=[],r=new Proxy(e,{get:(e,n)=>"location"===n?t.proxyLocation:ke.includes(n.toString())?r:o.includes(n)?Reflect.get(e,n):wt(Reflect.get(e,n),e),set:(e,r,i)=>"location"===r?Reflect.set(n,r,i):(Reflect.has(e,r)||o.push(r),Reflect.set(e,r,i),t.escapeProperties.includes(r)&&(!Reflect.has(n,r)&&t.escapeKeys.add(r),Reflect.set(n,r,i)),!0),has:(e,t)=>t in e,deleteProperty:(e,o)=>!Reflect.has(e,o)||(t.escapeKeys.has(o)&&Reflect.deleteProperty(n,o),Reflect.deleteProperty(e,o))});t.proxyWindow=r}(t,n),function(e){const{rawWindow:t,rawAddEventListener:n,rawRemoveEventListener:o}=Hn,r=new Map,i=new Map;function s(n){return Te.includes(n)?e:t}e.addEventListener=function(e,t,o){const i=r.get(e);i?i.add(t):r.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=o),n.call(s(e),e,t,o)},e.removeEventListener=function(e,t,n){const i=r.get(e);(null==i?void 0:i.size)&&i.has(t)&&i.delete(t),o.call(s(e),e,t,n)};const a=()=>{i.clear()},c=()=>{i.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),a()};return{reset:a,record:()=>{r.forEach(((e,t)=>{if(e.size){const n=i.get(t)||[];i.set(t,new Set([...n,...e]))}}))},rebuild:c,release:()=>{r.size&&(r.forEach(((e,t)=>{for(const n of e)o.call(s(t),t,n)})),r.clear())}}}(t)}function En(e,t,n){return function(e,t){const n=Hn.rawDocument,o=t.Document,r=t.document,i=o.prototype.createElement,s=o.prototype.createTextNode,a=o.prototype.createComment,c=o.prototype.querySelector,l=o.prototype.querySelectorAll,u=o.prototype.getElementById,p=o.prototype.getElementsByClassName,h=o.prototype.getElementsByTagName,d=o.prototype.getElementsByName,m=o.prototype.elementFromPoint,f=o.prototype.caretRangeFromPoint;function _(e){return r!==e?e:n}function A(t){var n,o;if(!t||z(t)||r!==this){const e=_(this);return c.call(e,t)}return null!==(o=null===(n=Sn.get(e))||void 0===n?void 0:n.querySelector(t))&&void 0!==o?o:null}function w(t){var n,o;if(!t||z(t)||r!==this){const e=_(this);return l.call(e,t)}return null!==(o=null===(n=Sn.get(e))||void 0===n?void 0:n.querySelectorAll(t))&&void 0!==o?o:[]}o.prototype.caretRangeFromPoint=function(t,o){const r=m.call(n,t,o),i=f.call(n,t,o);return fn(r,e),i},o.prototype.createElement=function(t,n){return fn(i.call(this,t,n),e)},o.prototype.createTextNode=function(t){return fn(s.call(this,t),e)},o.prototype.createComment=function(t){return fn(a.call(this,t),e)},o.prototype.querySelector=A,o.prototype.querySelectorAll=w,o.prototype.getElementById=function(e){const t=_(this);if(Q(e))return u.call(t,e);try{return A.call(this,`#${e}`)}catch(n){return u.call(t,e)}},o.prototype.getElementsByClassName=function(e){const t=_(this);if(Q(e))return p.call(t,e);try{return w.call(this,`.${e}`)}catch(n){return p.call(t,e)}},o.prototype.getElementsByTagName=function(e){const t=_(this);if(z(e)||Q(e))return h.call(t,e);if(/^script|base$/i.test(e))return h.call(r,e);try{return w.call(this,e)}catch(n){return h.call(t,e)}},o.prototype.getElementsByName=function(e){const t=_(this);if(Q(e))return d.call(t,e);try{return w.call(this,`[name=${e}]`)}catch(n){return d.call(t,e)}}}(e,t),function(e,t,n){const o=Hn.rawDocument,r=t.Document,i=t.document,c=(e,t)=>{const{enumerable:n}=Object.getOwnPropertyDescriptor(r.prototype,e)||{enumerable:!0};return{configurable:!0,enumerable:n,get:t}},l=()=>{const t={};return[["documentURI",()=>n.proxyLocation.href],["URL",()=>n.proxyLocation.href],["documentElement",()=>o.documentElement],["scrollingElement",()=>o.scrollingElement],["forms",()=>r.prototype.querySelectorAll.call(i,"form")],["images",()=>r.prototype.querySelectorAll.call(i,"img")],["links",()=>r.prototype.querySelectorAll.call(i,"a")],["microAppElement",()=>{var t;return null===(t=Sn.get(e))||void 0===t?void 0:t.container}],["__MICRO_APP_NAME__",()=>e]].forEach((e=>{t[e[0]]=c(e[0],e[1])})),Zt.forEach((e=>{t[e]=c(e,(()=>o[e]))})),en.forEach((e=>{t[e]=c(e,(()=>wt(o[e],o,"DOCUMENT")))})),tn.forEach((e=>{t[e]=c(e,(()=>o[e]))})),nn.forEach((e=>{t[e]=c(e,(()=>wt(o[e],o,"DOCUMENT")))})),t};a(r.prototype,l()),Yt.forEach((t=>{s(i,t,{enumerable:!0,configurable:!0,get:()=>($(e),o[t]),set:e=>{o[t]=e}})}))}(e,t,n),function(e,t){const{rawDocument:n,rawAddEventListener:o,rawRemoveEventListener:r}=Hn,i=new Map,a=new Map;let c=null,l=null;const u=t.Document,p=t.document;function h(e,t){return We.includes(e)?t:n}function d(e){return"onclick"===e?e=>{_(c)&&r.call(n,"click",c,!1),_(e)?(c=e.bind(p),o.call(n,"click",c,!1)):c=e}:t=>{n[e]=_(t)?t.bind(p):t}}u.prototype.addEventListener=function(e,t,n){const r=_(t)?t.__MICRO_APP_BOUND_FUNCTION__=t.__MICRO_APP_BOUND_FUNCTION__||t.bind(this):t,s=i.get(e);s?s.add(t):i.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=n),o.call(h(e,this),e,r,n)},u.prototype.removeEventListener=function(e,t,n){const o=i.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t);const s=(null==t?void 0:t.__MICRO_APP_BOUND_FUNCTION__)||t;r.call(h(e,this),e,s,n)},Object.getOwnPropertyNames(u.prototype).filter((e=>/^on/.test(e)&&!Be.includes(e))).forEach((t=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(u.prototype,t)||{enumerable:!0,writable:!0};try{s(u.prototype,t,{enumerable:o,configurable:!0,get:()=>"onclick"===t?c:n[t],set:(null!=r?r:i)?d(t):void 0})}catch(t){N(t,e)}}));const m=()=>{a.clear(),l=null},f=()=>{l&&!c&&(p.onclick=l),a.forEach(((e,t)=>{for(const n of e)p.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),m()};return{reset:m,record:()=>{l=c||l,i.forEach(((e,t)=>{if(e.size){const n=a.get(t)||[];a.set(t,new Set([...n,...e]))}}))},rebuild:f,release:()=>{_(c)&&r.call(n,"click",c),c=null,i.size&&(i.forEach(((e,t)=>{for(const n of e)r.call(h(t,p),t,(null==n?void 0:n.__MICRO_APP_BOUND_FUNCTION__)||n)})),i.clear())}}}(e,t)}function Pn(e,t,n,o){!function(e,t,n){const o=Hn.rawRootElement,r=Hn.rawDocument,i=t.document,a=t.Node,c=t.Element,l=a.prototype.appendChild,p=a.prototype.insertBefore,h=a.prototype.replaceChild,d=a.prototype.removeChild,m=c.prototype.append,f=c.prototype.prepend,_=c.prototype.insertAdjacentElement,A=a.prototype.cloneNode,w=Object.getOwnPropertyDescriptor(c.prototype,"innerHTML"),y=Object.getOwnPropertyDescriptor(a.prototype,"parentNode"),g=Object.getOwnPropertyDescriptor(a.prototype,"ownerDocument"),b=e=>(S(e)||function(e){return"[object HTMLBaseElement]"===u(e)}(e))&&e.__PURE_ELEMENT__,P=e=>e===n.microHead?r.head:e===n.microBody?r.body:e;a.prototype.getRootNode=function(){return i},a.prototype.appendChild=function(t){return fn(t,e),b(t)?l.call(this,t):o.prototype.appendChild.call(P(this),t)},a.prototype.insertBefore=function(t,n){return fn(t,e),b(t)?p.call(this,t,n):o.prototype.insertBefore.call(P(this),t,n)},a.prototype.replaceChild=function(t,n){return fn(t,e),b(t)?h.call(this,t,n):o.prototype.replaceChild.call(P(this),t,n)},a.prototype.removeChild=function(e){return b(e)||this.contains(e)?d.call(this,e):o.prototype.removeChild.call(P(this),e)},c.prototype.append=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=E(e[t])?e[t]:i.createTextNode(e[t]),b(e[t])&&(n=!0),t++;return n?m.call(this,...e):o.prototype.append.call(P(this),...e)},c.prototype.prepend=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=E(e[t])?e[t]:i.createTextNode(e[t]),b(e[t])&&(n=!0),t++;return n?f.call(this,...e):o.prototype.prepend.call(P(this),...e)},c.prototype.insertAdjacentElement=function(t,n){return fn(n,e),b(n)?_.call(this,t,n):o.prototype.insertAdjacentElement.call(P(this),t,n)},a.prototype.cloneNode=function(t){return fn(A.call(this,t),e)},s(a.prototype,"ownerDocument",{configurable:!0,enumerable:!0,get(){return this.__PURE_ELEMENT__?g.get.call(this):i}}),s(c.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return w.get.call(this)},set(t){w.set.call(this,t),Array.from(this.children).forEach((t=>{v(t)&&fn(t,e)}))}}),s(a.prototype,"parentNode",{configurable:!0,enumerable:!0,get:_n(e,y)});const R=new Proxy(t.Image,{construct(t,n){const o=new t(...n);return fn(o,e),o}});s(t,"Image",{configurable:!0,writable:!0,value:R})}(e,n,o),function(e,t){const n=t.Element,o=n.prototype.setAttribute;n.prototype.setAttribute=function(t,n){(("src"===t||"srcset"===t)&&/^(img|script)$/i.test(this.tagName)||"href"===t&&/^link$/i.test(this.tagName))&&(n=U(n,e)),o.call(this,t,n)};const r=[[t.HTMLImageElement.prototype,"src"],[t.HTMLScriptElement.prototype,"src"],[t.HTMLLinkElement.prototype,"href"]];r.forEach((([t,n])=>{const{enumerable:o,configurable:r,get:i,set:a}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,configurable:!0};s(t,n,{enumerable:o,configurable:r,get:function(){return null==i?void 0:i.call(this)},set:function(t){null==a||a.call(this,U(t,e))}})}))}(t,n)}bn.activeCount=0;class Rn{constructor(e,t){this.active=!1,this.escapeProperties=[],this.escapeKeys=new Set,this.updateIframeBase=()=>{var e;null===(e=this.baseElement)||void 0===e||e.setAttribute("href",this.proxyLocation.protocol+"//"+this.proxyLocation.host+this.proxyLocation.pathname)};const n=Hn.rawWindow.location,o=n.protocol+"//"+n.host;this.deleteIframeElement=this.createIframeElement(e,o),this.microAppWindow=this.iframe.contentWindow,this.patchIframe(this.microAppWindow,(n=>{this.createIframeTemplate(this.microAppWindow),this.getSpecialProperties(e),this.proxyLocation=function(e,t,n,o){const r=new URL(t),s=r.protocol+"//"+r.host,a=r.pathname+r.search+r.hash,c=n.history;return n.rawReplaceState=c.replaceState,i(c,kt(e,n.location)),cn(e,a,n.location,"prevent"),sn(e,t,n,r,o,s)}(e,t,this.microAppWindow,o),this.windowEffect=vn(e,this.microAppWindow,this),this.documentEffect=En(e,this.microAppWindow,this),Pn(e,t,this.microAppWindow,this),this.initStaticGlobalKeys(e,t,this.microAppWindow),n()}))}createIframeElement(e,t){this.iframe=q("iframe");const n={src:t,style:"display: none",id:e};return Object.keys(n).forEach((e=>this.iframe.setAttribute(e,n[e]))),Hn.rawDocument.body.appendChild(this.iframe),()=>O((()=>{var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.parentNode)||void 0===t||t.removeChild(this.iframe),this.iframe=null}))}start({baseroute:e,defaultPage:t,disablePatchRequest:n}){this.active||(this.active=!0,this.initRouteState(t),this.removeHistoryListener=Ut(this.microAppWindow.__MICRO_APP_NAME__),Lt(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e),n||this.createIframeBase(),1==++Hn.activeSandbox&&(Un(),Kt()),++Rn.activeCount)}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){var r;this.active&&(this.recordAndReleaseEffect({clearData:o},!e||n),this.clearRouteState(t),null===(r=this.removeHistoryListener)||void 0===r||r.call(this),e&&!n||(this.deleteIframeElement(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(Hn.rawWindow,e)})),this.escapeKeys.clear()),0==--Hn.activeSandbox&&(Bn(),qt()),--Rn.activeCount,this.active=!1)}initStaticGlobalKeys(e,t,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=t,n.__MICRO_APP_PUBLIC_PATH__=T(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="iframe",n.rawWindow=Hn.rawWindow,n.rawDocument=Hn.rawDocument,n.microApp=i(new ut(e),{removeDomScope:K,pureCreateElement:q,location:this.proxyLocation,router:Gt})}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.reset(),null===(t=this.documentEffect)||void 0===t||t.reset(),dt(this.microAppWindow.microApp)}recordEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.record(),null===(t=this.documentEffect)||void 0===t||t.record(),pt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.rebuild(),null===(t=this.documentEffect)||void 0===t||t.rebuild(),ht(this.microAppWindow.microApp)}releaseGlobalEffect({clearData:e=!1}){var t,n,o,r,i;null===(t=this.windowEffect)||void 0===t||t.release(),null===(n=this.documentEffect)||void 0===n||n.release(),null===(o=this.microAppWindow.microApp)||void 0===o||o.clearDataListener(),null===(r=this.microAppWindow.microApp)||void 0===r||r.clearGlobalDataListener(),e&&(Zn.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearData())}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchIframe(e,t){const n=e.document;this.sandboxReady=new Promise((o=>{!function r(){setTimeout((()=>{try{e.document===n?r():(e.stop(),t(o))}catch(e){r()}}),0)}()}))}createIframeTemplate(e){const t=e.document;!function(e){for(;null==e?void 0:e.firstChild;)e.removeChild(e.firstChild)}(t);const n=t.createElement("html");n.innerHTML="<head></head><body></body>",t.appendChild(n),this.microBody=t.body,this.microHead=t.head}createIframeBase(){this.baseElement=q("base"),this.updateIframeBase(),this.microHead.appendChild(this.baseElement)}getSpecialProperties(e){var t;A(Zn.options.plugins)&&(this.commonActionForSpecialProperties(Zn.options.plugins.global),this.commonActionForSpecialProperties(null===(t=Zn.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(r(e))for(const t of e)A(t)&&r(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties))}initRouteState(e){ln(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){pn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){un(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){hn(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){mn(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}Rn.activeCount=0;const Sn=new Map;class Mn{constructor({name:e,url:t,container:n,scopecss:o,useSandbox:r,inline:i,iframe:s,ssrUrl:a,isPrefetch:c,prefetchLevel:l,routerMode:u}){this.state=ve.CREATED,this.keepAliveState=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.lifeCycleState=null,this.umdMode=!1,this.sandBox=null,this.fiber=!1,Sn.set(e,this),this.name=e,this.url=t,this.useSandbox=r,this.scopecss=this.useSandbox&&o,this.iframe=null!=s&&s,this.inline=this.getInlineModeState(i),this.routerMode=u||Ie,this.container=null!=n?n:null,this.ssrUrl=null!=a?a:"",this.isPrefetch=null!=c&&c,this.isPrerender=3===l,this.prefetchLevel=l,this.source={html:null,links:new Set,scripts:new Set},this.loadSourceCode(),this.createSandbox()}loadSourceCode(){this.setAppState(ve.LOADING),le.getInstance().run(this,it)}onLoad(e,t,n,o,r){var i;if(2==++this.loadSourceLevel)if(this.source.html=e,this.isPrefetch||this.isUnmounted()){if(this.isPrerender){const e=q("div");e.setAttribute("prerender","true"),null===(i=this.sandBox)||void 0===i||i.setPreRenderState(!0),this.mount({container:e,inline:this.inline,routerMode:o,baseroute:r||"",fiber:!0,defaultPage:t||"",disablePatchRequest:null!=n&&n})}}else X(this.container).mount(this)}onLoadError(e){this.loadSourceLevel=-1,this.isUnmounted()||(this.onerror(e),this.setAppState(ve.LOAD_FAILED))}mount({container:e,inline:t,routerMode:n,defaultPage:o,baseroute:r,disablePatchRequest:i,fiber:s}){if(2!==this.loadSourceLevel)return this.container=e,this.isPrerender=!1,ae(this,"statechange",{appState:ve.LOADING}),this.setAppState(ve.LOADING);this.createSandbox(),this.setAppState(ve.BEFORE_MOUNT);const a=()=>{var a,c,l,h,m,f,A,w;if(this.isPrerender&&(w=this.container,"[object HTMLDivElement]"===u(w))&&this.container.hasAttribute("prerender"))null===(a=this.sandBox)||void 0===a||a.rebuildEffectSnapshot(),G(e,this.container,!1),this.container=e,null===(c=this.preRenderEvents)||void 0===c||c.forEach((e=>e())),this.isPrerender=!1,this.preRenderEvents=null,Gt.attachToURL(this.name),null===(l=this.sandBox)||void 0===l||l.setPreRenderState(!1);else{this.container=e,this.inline=this.getInlineModeState(t),this.fiber=s,this.routerMode=n;const a=()=>{this.setLifeCycleState(Ee.BEFOREMOUNT),se(this.container,this.name,Ee.BEFOREMOUNT)};if(this.isPrerender?(null!==(h=this.preRenderEvents)&&void 0!==h?h:this.preRenderEvents=[]).push(a):a(),this.setAppState(ve.MOUNTING),ae(this,"statechange",{appState:ve.MOUNTING}),G(this.container,this.source.html,!this.umdMode),null===(m=this.sandBox)||void 0===m||m.start({umdMode:this.umdMode,baseroute:r,defaultPage:o,disablePatchRequest:i}),this.umdMode){null===(A=this.sandBox)||void 0===A||A.rebuildEffectSnapshot();try{this.handleMounted(this.umdHookMount(Zn.getData(this.name,!0)))}catch(e){C("An error occurred in window.mount \n",this.name,e)}}else null===(f=this.sandBox)||void 0===f||f.actionBeforeExecScripts(this.container),function(e,t){const n=e.fiber?[]:null,o=Array.from(e.source.scripts),r=[],i=[];for(const s of o){const o=Me.script.getInfo(s),a=o.appSpace[e.name];a.defer||a.async?(!o.isExternal||o.code||je(e,o)?r.push(o.code):r.push(ce(s,e.name)),i.push([s,o]),je(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):ne(n,(()=>{tt(s,e,o),t(!1)}))}r.length?W(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,C(n,e.name)}),(()=>{i.forEach((([o,r])=>{d(r.code)&&ne(n,(()=>{tt(o,e,r,t),!je(e,r)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(p(t.moduleCount)||t.errorCount===r.length)))),oe(n)):t(p(t.moduleCount)||t.errorCount===r.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),oe(n)):t(!0)}(this,(e=>{if(!this.umdMode){const{mount:t,unmount:n}=this.getUmdLibraryHooks();if(this.umdHookUnmount=n,_(t)&&_(n)){this.umdHookMount=t,this.sandBox.markUmdMode(this.umdMode=!0);try{this.handleMounted(this.umdHookMount(Zn.getData(this.name,!0)))}catch(e){C("An error occurred in window.mount \n",this.name,e)}}else!0===e&&this.handleMounted()}}))}};this.sandBox?this.sandBox.sandboxReady.then(a):a()}handleMounted(e){var t,n;const o=()=>{y(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>{C("An error occurred in window.mount \n",this.name,e),this.dispatchMountedEvent()})):this.dispatchMountedEvent()};this.isPrerender?(null===(t=this.preRenderEvents)||void 0===t||t.push(o),null===(n=this.sandBox)||void 0===n||n.recordAndReleaseEffect({isPrerender:!0})):o()}dispatchMountedEvent(){var e;this.isUnmounted()||(this.setAppState(ve.MOUNTED),ie(this.getMicroAppGlobalHook(Pe.ONMOUNT),this.name,Pe.ONMOUNT,Zn.getData(this.name,!0)),ae(this,"statechange",{appState:ve.MOUNTED}),ae(this,"mounted"),this.setLifeCycleState(Ee.MOUNTED),se(this.container,this.name,Ee.MOUNTED),this.isHidden()&&(null===(e=this.sandBox)||void 0===e||e.recordAndReleaseEffect({keepAlive:!0})))}unmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;e=e||this.state===ve.LOAD_FAILED,this.setAppState(ve.UNMOUNT);let i=null;try{i=null===(r=this.umdHookUnmount)||void 0===r?void 0:r.call(this,Zn.getData(this.name,!0))}catch(e){C("An error occurred in window.unmount \n",this.name,e)}ae(this,"statechange",{appState:ve.UNMOUNT}),ae(this,"unmount"),ie(this.getMicroAppGlobalHook(Pe.ONUNMOUNT),this.name,Pe.ONUNMOUNT),this.handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o,umdHookUnmountResult:i})}handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o,umdHookUnmountResult:r}){const i=()=>this.actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o});y(r)?(K(),r.then(i).catch(i)):i()}actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;this.umdMode&&this.container&&!e&&G(this.source.html,this.container,!1),null===(r=this.sandBox)||void 0===r||r.stop({umdMode:this.umdMode,keepRouteState:n&&!e,destroy:e,clearData:t||e}),this.setLifeCycleState(Ee.UNMOUNT),se(this.container,this.name,Ee.UNMOUNT),this.clearOptions(e),null==o||o()}clearOptions(e){this.container.innerHTML="",this.container=null,this.isPrerender=!1,this.preRenderEvents=null,this.setKeepAliveState(null),this.iframe&&!this.umdMode&&(this.sandBox=null),e&&this.actionsForCompletelyDestroy(),K()}actionsForCompletelyDestroy(){var e,t;null===(t=null===(e=this.sandBox)||void 0===e?void 0:e.deleteIframeElement)||void 0===t||t.call(e),Me.script.deleteInlineInfo(this.source.scripts),Sn.delete(this.name)}hiddenKeepAliveApp(e){var t,n;this.setKeepAliveState(Re.KEEP_ALIVE_HIDDEN),ae(this,"appstate-change",{appState:"afterhidden"}),this.setLifeCycleState(Ee.AFTERHIDDEN),se(this.container,this.name,Ee.AFTERHIDDEN),this.routerMode!==xe&&(null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp()),2!==this.loadSourceLevel?X(this.container).unmount():(this.container=G(q("div"),this.container,!1),null===(n=this.sandBox)||void 0===n||n.recordAndReleaseEffect({keepAlive:!0})),null==e||e()}showKeepAliveApp(e){var t,n;null===(t=this.sandBox)||void 0===t||t.rebuildEffectSnapshot(),ae(this,"appstate-change",{appState:"beforeshow"}),se(e,this.name,Ee.BEFORESHOW),this.setKeepAliveState(Re.KEEP_ALIVE_SHOW),this.container=G(e,this.container,!1),this.routerMode!==xe&&(null===(n=this.sandBox)||void 0===n||n.setRouteInfoForKeepAliveApp()),ae(this,"appstate-change",{appState:"aftershow"}),this.setLifeCycleState(Ee.AFTERSHOW),se(this.container,this.name,Ee.AFTERSHOW)}onerror(e){this.setLifeCycleState(Ee.ERROR),ae(this,"statechange",{appState:ve.LOAD_FAILED}),se(this.container,this.name,Ee.ERROR,e)}createSandbox(){this.useSandbox&&!this.sandBox&&(this.iframe?this.sandBox=new Rn(this.name,this.url):this.sandBox=new bn(this.name,this.url))}setAppState(e){var t;this.state=e,null===(t=this.sandBox)||void 0===t||t.setStaticAppState(e)}getAppState(){return this.state}setLifeCycleState(e){this.lifeCycleState=e}getLifeCycleState(){return this.lifeCycleState||""}setKeepAliveState(e){this.keepAliveState=e}getKeepAliveState(){return this.keepAliveState}isUnmounted(){return ve.UNMOUNT===this.state}isHidden(){return Re.KEEP_ALIVE_HIDDEN===this.keepAliveState}getUmdLibraryHooks(){if(!this.isUnmounted()&&this.sandBox){const e=X(this.container).getAttribute("library")||`micro-app-${this.name}`,t=this.sandBox.proxyWindow;return w(t[e])?t[e]:{mount:t.mount,unmount:t.unmount}}return{}}getMicroAppGlobalHook(e){var t,n;const o=null===(n=null===(t=this.sandBox)||void 0===t?void 0:t.proxyWindow)||void 0===n?void 0:n[e];return _(o)?o:null}querySelector(e){return this.container?Hn.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?Hn.rawElementQuerySelectorAll.call(this.container,e):[]}getInlineModeState(e){var t;return null!==(t=this.iframe||e)&&void 0!==t&&t}}function Cn(e){var t,n;return null!==(n=null===(t=Sn.get(e))||void 0===t?void 0:t.iframe)&&void 0!==n&&n}const Nn=new WeakMap;function On(e){var t;return null!==(t=Nn.get(e))&&void 0!==t?t:e}function Dn(e,t){if(Nn.has(e))return Nn.get(e);if(R(e)){if(e.hasAttribute("exclude")){const t=document.createComment("style element with exclude attribute ignored by micro-app");return Nn.set(e,t),t}return t.scopecss&&!e.hasAttribute("ignore")?_e(e,t):e}if(P(e)){if(e.hasAttribute("exclude")||Je(e.getAttribute("href"),t.name)){const t=document.createComment("link element with exclude attribute ignored by micro-app");return Nn.set(e,t),t}if(e.hasAttribute("ignore")||Ze(e.getAttribute("href"),t.name)||e.href&&_(Zn.options.excludeAssetFilter)&&Zn.options.excludeAssetFilter(e.href))return e;const{address:n,linkInfo:o,replaceComment:r}=Ce(e,null,t,!0);if(n&&o){const r=function(e,t,n,o){const r=q("style"),i=()=>{Oe(t,e,r,n,n.appSpace[t.name].attrs),ye(o)};return n.code?O(i):ce(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{C(e,t.name),ge(o)})),r}(n,t,o,e);return Nn.set(e,r),r}return r?(Nn.set(e,r),r):e}if(S(e)){if(e.src&&_(Zn.options.excludeAssetFilter)&&Zn.options.excludeAssetFilter(e.src))return e;const{replaceComment:n,address:o,scriptInfo:r}=Ve(e,null,t,!0)||{};if(o&&r){const n=r.isExternal?function(e,t,n,o){const r=Ke(t,n)?q("script"):document.createComment("dynamic script extract by micro-app"),i=()=>ye(o),s=()=>{const s=Object.getOwnPropertyDescriptor(Hn.rawDocument,"currentScript");s&&!s.configurable||Object.defineProperty(Hn.rawDocument,"currentScript",{value:o,configurable:!0}),tt(e,t,n,i,r),!je(t,n)&&i()};return n.code||je(t,n)?O(s):ce(e,t.name).then((e=>{n.code=e,s()})).catch((e=>{C(e,t.name),ge(o)})),r}(o,t,r,e):function(e,t,n){const o=Ke(t,n)?q("script"):document.createComment("dynamic script extract by micro-app");return tt(e,t,n,void 0,o),o}(o,t,r);return Nn.set(e,n),n}return n?(Nn.set(e,n),n):e}return e}function In(e,t,n,o,r){const i=xn(n,o,e);if(i){if(!Cn(e.name)&&M(i)&&t!==Hn.rawRemoveChild){const t=Object.getOwnPropertyDescriptor(o,"parentNode");t&&!t.configurable||o.__MICRO_APP_HAS_DPN__||a(o,{parentNode:{configurable:!0,get(){var t,n;const o=Hn.rawParentNodeDesc.get.call(this);return M(o)&&e.container?(null===(n=(t=Zn.options).getRootElementParentNode)||void 0===n?void 0:n.call(t,this,e.name))||document.body:o}},__MICRO_APP_HAS_DPN__:{configurable:!0,get:()=>!0}})}return r&&!i.contains(r)?Hn.rawAppendChild.call(i,o):t!==Hn.rawRemoveChild||i.contains(o)?Ln(t,i,o,r):n.contains(o)?t.call(n,o):o}return Ln(t,n,o,r)}function xn(e,t,n){if(n){if(e===document.head)return n.iframe&&S(t)?n.sandBox.microHead:n.querySelector("micro-app-head");if(e===document.body||e===document.body.parentNode)return n.iframe&&S(t)?n.sandBox.microBody:n.querySelector("micro-app-body");if(n.iframe&&S(t))return n.sandBox.microBody}return null}function Ln(e,t,n,o){return(r=e)===Hn.rawAppend||r===Hn.rawPrepend?e.call(t,n):e.call(t,n,o);var r}function Tn(e,t,n,o){const r=j();if(E(t)&&!t.__PURE_ELEMENT__&&(t.__MICRO_APP_NAME__||r)){t.__MICRO_APP_NAME__=t.__MICRO_APP_NAME__||r;const i=Sn.get(t.__MICRO_APP_NAME__);if(null==i?void 0:i.container)return function(e,t){v(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&Hn.rawSetAttribute.call(t,"src",U(t.getAttribute("src"),e.url)),t.hasAttribute("srcset")&&Hn.rawSetAttribute.call(t,"srcset",U(t.getAttribute("srcset"),e.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&Hn.rawSetAttribute.call(t,"href",U(t.getAttribute("href"),e.url)))}(i,t),In(i,o,e,Dn(t,i),n&&On(n))}return o===Hn.rawAppend||o===Hn.rawPrepend?o.call(e,t):o.call(e,t,n)}function Un(){!function(){const e=Hn.rawDocument,t=Hn.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===u(e)}(t)?e:t}function o(t){var o,r;const i=n(this),s=j();return s&&t&&!z(t)&&e===i?null!==(r=null===(o=Sn.get(s))||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:Hn.rawQuerySelector.call(i,t)}function r(t){var o,r;const i=n(this),s=j();return s&&t&&!z(t)&&e===i?null!==(r=null===(o=Sn.get(s))||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:Hn.rawQuerySelectorAll.call(i,t)}t.prototype.createElement=function(e,t){return Wn(Hn.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return Wn(Hn.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return Wn(Hn.rawCreateDocumentFragment.call(n(this)))},t.prototype.createComment=function(e){return Wn(Hn.rawCreateComment.call(n(this),e))},t.prototype.querySelector=o,t.prototype.querySelectorAll=r,t.prototype.getElementById=function(e){const t=n(this);if(!j()||Q(e))return Hn.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(n){return Hn.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!j()||Q(e))return Hn.rawGetElementsByClassName.call(t,e);try{return r.call(t,`.${e}`)}catch(n){return Hn.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),i=j();if(!i||z(e)||Q(e)||!(null===(t=Sn.get(i))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return Hn.rawGetElementsByTagName.call(o,e);try{return r.call(o,e)}catch(t){return Hn.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!j()||Q(e))return Hn.rawGetElementsByName.call(t,e);try{return r.call(t,`[name=${e}]`)}catch(n){return Hn.rawGetElementsByName.call(t,e)}}}();const e=Hn.rawRootElement,t=Hn.rawRootNode;function n(e){const t=j();if((e===document.body||e===document.head)&&t){const n=Sn.get(t);if(null==n?void 0:n.container){if(e===document.body)return n.querySelector("micro-app-body");if(e===document.head)return n.querySelector("micro-app-head")}}return null}e.prototype.appendChild=function(e){return Tn(this,e,null,Hn.rawAppendChild)},e.prototype.insertBefore=function(e,t){return Tn(this,e,t,Hn.rawInsertBefore)},e.prototype.replaceChild=function(e,t){return Tn(this,e,t,Hn.rawReplaceChild)},e.prototype.append=function(...e){let t=0;for(;t<e.length;){let n=e[t];n=E(n)?n:Hn.rawCreateTextNode.call(Hn.rawDocument,n),Tn(this,Wn(n),null,Hn.rawAppend),t++}},e.prototype.prepend=function(...e){let t=e.length;for(;t>0;){let n=e[t-1];n=E(n)?n:Hn.rawCreateTextNode.call(Hn.rawDocument,n),Tn(this,Wn(n),null,Hn.rawPrepend),t--}},e.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Sn.get(e.__MICRO_APP_NAME__);if(null==t?void 0:t.container)return In(t,Hn.rawRemoveChild,this,On(e));try{return Hn.rawRemoveChild.call(this,e)}catch(t){return(null==e?void 0:e.parentNode)&&Hn.rawRemoveChild.call(e.parentNode,e)}}return Hn.rawRemoveChild.call(this,e)},e.prototype.insertAdjacentElement=function(e,t){var n;if((null==t?void 0:t.__MICRO_APP_NAME__)&&v(t)){const o=Sn.get(t.__MICRO_APP_NAME__);if(null==o?void 0:o.container){const r=Dn(t,o);if(!v(r))return t;const i=null!==(n=xn(this,r,o))&&void 0!==n?n:this;return Hn.rawInsertAdjacentElement.call(i,e,r)}}return Hn.rawInsertAdjacentElement.call(this,e,t)},e.prototype.cloneNode=function(e){const t=Hn.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t},e.prototype.querySelector=function(e){var t;const o=null!==(t=n(this))&&void 0!==t?t:this;return Hn.rawElementQuerySelector.call(o,e)},e.prototype.querySelectorAll=function(e){var t;const o=null!==(t=n(this))&&void 0!==t?t:this;return Hn.rawElementQuerySelectorAll.call(o,e)},e.prototype.setAttribute=function(e,t){const n=this.__MICRO_APP_NAME__||j();if(n&&Sn.has(n)&&(("src"===e||"srcset"===e)&&/^(img|script|video|audio|source|embed)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))){t=U(t,Sn.get(n).url)}Hn.rawSetAttribute.call(this,e,t)},s(e.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return Hn.rawInnerHTMLDesc.get.call(this)},set(e){Hn.rawInnerHTMLDesc.set.call(this,e);const t=j();Array.from(this.children).forEach((e=>{v(e)&&t&&(e.__MICRO_APP_NAME__=t)}))}}),s(t.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var e,t,n;const o=j();if(o&&this===Hn.rawDocument.firstElementChild){const r=null===(n=null===(t=null===(e=Sn.get(o))||void 0===e?void 0:e.sandBox)||void 0===t?void 0:t.proxyWindow)||void 0===n?void 0:n.document;if(r)return r}return Hn.rawParentNodeDesc.get.call(this)}})}function Wn(e){const t=j();return t&&(e.__MICRO_APP_NAME__=t),e}function Bn(){K(),function(){const e=Hn.rawRootDocument;e.prototype.createElement=Hn.rawCreateElement,e.prototype.createElementNS=Hn.rawCreateElementNS,e.prototype.createDocumentFragment=Hn.rawCreateDocumentFragment,e.prototype.querySelector=Hn.rawQuerySelector,e.prototype.querySelectorAll=Hn.rawQuerySelectorAll,e.prototype.getElementById=Hn.rawGetElementById,e.prototype.getElementsByClassName=Hn.rawGetElementsByClassName,e.prototype.getElementsByTagName=Hn.rawGetElementsByTagName,e.prototype.getElementsByName=Hn.rawGetElementsByName}();const e=Hn.rawRootElement,t=Hn.rawRootNode;e.prototype.appendChild=Hn.rawAppendChild,e.prototype.insertBefore=Hn.rawInsertBefore,e.prototype.replaceChild=Hn.rawReplaceChild,e.prototype.removeChild=Hn.rawRemoveChild,e.prototype.append=Hn.rawAppend,e.prototype.prepend=Hn.rawPrepend,e.prototype.cloneNode=Hn.rawCloneNode,e.prototype.querySelector=Hn.rawElementQuerySelector,e.prototype.querySelectorAll=Hn.rawElementQuerySelectorAll,e.prototype.setAttribute=Hn.rawSetAttribute,s(e.prototype,"innerHTML",Hn.rawInnerHTMLDesc),s(t.prototype,"parentNode",Hn.rawParentNodeDesc)}let kn=!1;const Hn={activeSandbox:0};function Fn(){if(t){const e=window.rawWindow||Function("return window")(),t=window.rawDocument||Function("return document")(),n=e.Document||Function("return Document")(),o=e.Element,r=e.Node,s=e.EventTarget,a=o.prototype.setAttribute,c=o.prototype.appendChild,l=o.prototype.insertBefore,u=o.prototype.replaceChild,p=o.prototype.removeChild,h=o.prototype.append,d=o.prototype.prepend,m=o.prototype.cloneNode,f=o.prototype.querySelector,_=o.prototype.querySelectorAll,A=o.prototype.insertAdjacentElement,w=Object.getOwnPropertyDescriptor(o.prototype,"innerHTML"),y=Object.getOwnPropertyDescriptor(r.prototype,"parentNode"),g=n.prototype.createElement,b=n.prototype.createElementNS,v=n.prototype.createDocumentFragment,E=n.prototype.createTextNode,P=n.prototype.createComment,R=n.prototype.querySelector,S=n.prototype.querySelectorAll,M=n.prototype.getElementById,C=n.prototype.getElementsByClassName,N=n.prototype.getElementsByTagName,O=n.prototype.getElementsByName,D=new Proxy(Image,{construct(e,t){const n=new e(...t),o=j();return o&&(n.__MICRO_APP_NAME__=o),n}}),I=e.setInterval,x=e.setTimeout,L=e.clearInterval,T=e.clearTimeout,U=e.history.pushState,W=e.history.replaceState,B=s.prototype.addEventListener,k=s.prototype.removeEventListener,H=s.prototype.dispatchEvent;window.__MICRO_APP_BASE_APPLICATION__=!0,i(Hn,{supportModuleScript:"noModule"in document.createElement("script"),rawWindow:e,rawDocument:t,rawRootDocument:n,rawRootElement:o,rawRootNode:r,rawSetAttribute:a,rawAppendChild:c,rawInsertBefore:l,rawReplaceChild:u,rawRemoveChild:p,rawAppend:h,rawPrepend:d,rawCloneNode:m,rawElementQuerySelector:f,rawElementQuerySelectorAll:_,rawInsertAdjacentElement:A,rawInnerHTMLDesc:w,rawParentNodeDesc:y,rawCreateElement:g,rawCreateElementNS:b,rawCreateDocumentFragment:v,rawCreateTextNode:E,rawCreateComment:P,rawQuerySelector:R,rawQuerySelectorAll:S,rawGetElementById:M,rawGetElementsByClassName:C,rawGetElementsByTagName:N,rawGetElementsByName:O,ImageProxy:D,rawSetInterval:I,rawSetTimeout:x,rawClearInterval:L,rawClearTimeout:T,rawPushState:U,rawReplaceState:W,rawAddEventListener:B,rawRemoveEventListener:k,rawDispatchEvent:H}),function(){if(!kn){kn=!0;const e=q("style");Hn.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${Zn.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,Hn.rawDocument.head.appendChild(e)}}()}}function $n(t){class n extends(function(){var e;return(null===(e=window.rawWindow)||void 0===e?void 0:e.HTMLElement)||window.HTMLElement}()){constructor(){super(...arguments),this.isWaiting=!1,this.cacheData=null,this.connectedCount=0,this.connectStateMap=new Map,this.appName="",this.appUrl="",this.ssrUrl="",this.version=e,this.handleAttributeUpdate=()=>{this.isWaiting=!1;const e=L(this.getAttribute("name")),t=x(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Sn.get(e);if(e!==this.appName&&n&&!n.isUnmounted()&&!n.isHidden()&&!n.isPrefetch)return this.setAttribute("name",this.appName),C(`app name conflict, an app named ${e} is running`);e===this.appName&&t===this.appUrl||(e===this.appName?this.unmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.unmount(!1,(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)}}static get observedAttributes(){return["name","url"]}connectedCallback(){const e=++this.connectedCount;this.connectStateMap.set(e,!0);const t=this.appName&&this.appUrl;O((()=>{this.connectStateMap.get(e)&&(se(this,this.appName,Ee.CREATED),t&&this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(Ee.MOUNTED,n),this.removeEventListener(Ee.AFTERSHOW,n),t(!0)};this.addEventListener(Ee.MOUNTED,n),this.addEventListener(Ee.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=Sn.get(this.appName);!n||n.isUnmounted()||n.isHidden()||(this.getKeepAliveModeResult()&&!e?this.handleHiddenKeepAliveApp(t):this.unmount(e,t))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===be.NAME?"appName":"appUrl"]!==n)if(e!==be.URL||this.appUrl&&this.connectStateMap.get(this.connectedCount))if(e!==be.NAME||this.appName&&this.connectStateMap.get(this.connectedCount))this.isWaiting||(this.isWaiting=!0,O(this.handleAttributeUpdate));else{const e=L(n);if(!e)return C(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(Zn.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=x(n,this.appName)))return C(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.handleConnected()}handleConnected(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&_(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),Sn.has(this.appName)){const e=Sn.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.isHidden()&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t===n&&(e.isUnmounted()||e.isPrefetch&&this.sameCoreOptions(e))?this.handleMount(e):e.isPrefetch||e.isUnmounted()?this.handleCreateApp():C(`app name conflict, an app named: ${this.appName} with url: ${t} is running`)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.updateSsrUrl(t),this.appName=e,this.appUrl=t,(null!==(o=this.shadowRoot)&&void 0!==o?o:this).innerHTML="",e!==this.getAttribute("name")&&this.setAttribute("name",this.appName),n?n.isHidden()?n.url===this.appUrl?this.handleShowKeepAliveApp(n):C(`app name conflict, an app named ${this.appName} is running`):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!d(t)||!t)||(C(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleCreateApp(){const e=()=>{var e;return new Mn({name:this.appName,url:this.appUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,scopecss:this.useScopecss(),useSandbox:this.useSandbox(),inline:this.getDisposeResult("inline"),iframe:this.getDisposeResult("iframe"),ssrUrl:this.ssrUrl,routerMode:this.getMemoryRouterMode()})},t=Sn.get(this.appName);t?t.isPrerender?this.unmount(!0,e):(t.actionsForCompletelyDestroy(),e()):e()}handleMount(e){e.isPrefetch=!1,e.setAppState(ve.BEFORE_MOUNT),O((()=>this.mount(e)))}mount(e){var t;e.mount({container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,inline:this.getDisposeResult("inline"),routerMode:this.getMemoryRouterMode(),baseroute:this.getBaseRouteCompatible(),defaultPage:this.getDefaultPage(),disablePatchRequest:this.getDisposeResult("disable-patch-request"),fiber:this.getDisposeResult("fiber")})}unmount(e,t){const n=Sn.get(this.appName);n&&!n.isUnmounted()&&n.unmount({destroy:e||this.getDestroyCompatibleResult(),clearData:this.getDisposeResult("clear-data"),keepRouteState:this.getDisposeResult("keep-router-state"),unmountcb:t})}handleHiddenKeepAliveApp(e){const t=Sn.get(this.appName);!t||t.isUnmounted()||t.isHidden()||t.hiddenKeepAliveApp(e)}handleShowKeepAliveApp(e){O((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleProperties(e)||!!Zn.options[e])&&this.compatibleDisableProperties(e)}compatibleProperties(e){return"disable-scopecss"===e?this.hasAttribute("disable-scopecss")||this.hasAttribute("disableScopecss"):"disable-sandbox"===e?this.hasAttribute("disable-sandbox")||this.hasAttribute("disableSandbox"):this.hasAttribute(e)}compatibleDisableProperties(e){return"disable-scopecss"===e?"false"!==this.getAttribute("disable-scopecss")&&"false"!==this.getAttribute("disableScopecss"):"disable-sandbox"===e?"false"!==this.getAttribute("disable-sandbox")&&"false"!==this.getAttribute("disableSandbox"):"false"!==this.getAttribute(e)}useScopecss(){return!(this.getDisposeResult("disable-scopecss")||this.getDisposeResult("shadowDOM"))}useSandbox(){return!this.getDisposeResult("disable-sandbox")}sameCoreOptions(e){return e.scopecss===this.useScopecss()&&e.useSandbox===this.useSandbox()&&e.iframe===this.getDisposeResult("iframe")}getBaseRouteCompatible(){var e,t;return null!==(t=null!==(e=this.getAttribute("baseroute"))&&void 0!==e?e:this.getAttribute("baseurl"))&&void 0!==t?t:""}getDestroyCompatibleResult(){return this.getDisposeResult("destroy")||this.getDisposeResult("destory")}getKeepAliveModeResult(){return this.getDisposeResult("keep-alive")&&!this.getDestroyCompatibleResult()}updateSsrUrl(e){if(this.getDisposeResult("ssr"))if(this.getDisposeResult("disable-memory-router")||this.getDisposeResult("disableSandbox")){const t=Hn.rawWindow.location;this.ssrUrl=U(t.pathname+t.search,e)}else{let t=function(e,t){const n=Ot(e);if(!n)return"";const o=D(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPage();if(!t&&n){const o=D(n,e);t=o.origin+o.pathname+o.search}this.ssrUrl=t}else this.ssrUrl&&(this.ssrUrl="")}getDefaultPage(){return Gt.getDefaultPage(this.appName)||this.getAttribute("default-page")||this.getAttribute("defaultPage")||""}getMemoryRouterMode(){return Tt(this.getAttribute("router-mode"),this)}setAttribute(e,t){if("data"===e)if(A(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{d(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&N("property data must be an object",this.appName);else Hn.rawSetAttribute.call(this,e,t)}set data(e){this.appName?Zn.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Zn.getData(this.appName,!0):this.cacheData?this.cacheData:null}}Hn.rawWindow.customElements.define(t,n)}function jn(e,n){if(!t)return C("preFetch is only supported in browser environment");B((()=>{const t=f(n)?n:Zn.options.prefetchDelay;setTimeout((()=>{!function(e){_(e)&&(e=e()),r(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,k((t=>{var n,o,r,i,s,a;if(A(e)&&navigator.onLine)if(e.name=L(e.name),e.url=x(e.url,e.name),e.name&&e.url&&!Sn.has(e.name)){const c=new Mn({name:e.name,url:e.url,isPrefetch:!0,scopecss:!(null!==(o=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss)&&void 0!==o?o:Zn.options["disable-scopecss"]),useSandbox:!(null!==(i=null!==(r=e["disable-sandbox"])&&void 0!==r?r:e.disableSandbox)&&void 0!==i?i:Zn.options["disable-sandbox"]),inline:null!==(s=e.inline)&&void 0!==s?s:Zn.options.inline,iframe:null!==(a=e.iframe)&&void 0!==a?a:Zn.options.iframe,prefetchLevel:e.level&&De.includes(e.level)?e.level:Zn.options.prefetchLevel&&De.includes(Zn.options.prefetchLevel)?Zn.options.prefetchLevel:2}),l=c.onLoad,u=c.onLoadError;c.onLoad=n=>{t(),l.call(c,n,e["default-page"],e["disable-patch-request"],Tt(e["router-mode"]),e.baseroute)},c.onLoadError=(...e)=>{t(),u.call(c,...e)}}else t();else t()}));var e}))),Promise.resolve())}(e)}),f(t)?t:3e3)}))}function Kn(e,t,n){if(r(e)){const o=e.filter((e=>d(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));W(o.map((e=>ce(e))),(e=>{const r=o[e.index];"js"===t?n.hasInfo(r)||n.setInfo(r,{code:e.data,isExternal:!1,appSpace:{}}):n.hasInfo(r)||n.setInfo(r,{code:e.data,appSpace:{}})}),(e=>{C(e)}))}}function qn({excludeHiddenApp:e=!1,excludePreRender:t=!1}={}){const n=[];return Sn.forEach(((o,r)=>{o.isUnmounted()||o.isPrefetch&&(!o.isPrerender||t)||e&&o.isHidden()||n.push(r)})),n}function Gn(){return Array.from(Sn.keys())}function Qn(e,t){const n=Sn.get(L(e));return new Promise((o=>{if(n)if(n.isUnmounted()||n.isPrefetch)n.isPrerender?n.unmount({destroy:!!(null==t?void 0:t.destroy),clearData:!!(null==t?void 0:t.clearData),keepRouteState:!1,unmountcb:o.bind(null,!0)}):((null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o(!0));else if(n.isHidden())(null==t?void 0:t.destroy)?n.unmount({destroy:!0,clearData:!0,keepRouteState:!0,unmountcb:o.bind(null,!0)}):(null==t?void 0:t.clearAliveState)?n.unmount({destroy:!1,clearData:!!t.clearData,keepRouteState:!0,unmountcb:o.bind(null,!0)}):o(!0);else{const e=X(n.container),r=()=>{e.removeEventListener(Ee.UNMOUNT,r),e.removeEventListener(Ee.AFTERHIDDEN,i),o(!0)},i=()=>{e.removeEventListener(Ee.UNMOUNT,r),e.removeEventListener(Ee.AFTERHIDDEN,i),o(!0)};if(e.addEventListener(Ee.UNMOUNT,r),e.addEventListener(Ee.AFTERHIDDEN,i),null==t?void 0:t.destroy){let t,n;e.hasAttribute("destroy")&&(t=e.getAttribute("destroy")),e.hasAttribute("destory")&&(n=e.getAttribute("destory")),e.setAttribute("destroy","true"),e.parentNode.removeChild(e),e.removeAttribute("destroy"),d(t)&&e.setAttribute("destroy",t),d(n)&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const n=e.getAttribute("keep-alive");e.removeAttribute("keep-alive");let o=null;t.clearData&&(o=e.getAttribute("clear-data"),e.setAttribute("clear-data","true")),e.parentNode.removeChild(e),e.setAttribute("keep-alive",n),d(o)&&e.setAttribute("clear-data",o)}else{let n=null;(null==t?void 0:t.clearData)&&(n=e.getAttribute("clear-data"),e.setAttribute("clear-data","true")),e.parentNode.removeChild(e),d(n)&&e.setAttribute("clear-data",n)}}else N(`app ${e} does not exist`),o(!1)}))}function zn(e){return Array.from(Sn.keys()).reduce(((t,n)=>t.then((()=>Qn(n,e)))),Promise.resolve(!0))}function Xn(e,t){return new Promise((n=>{const o=Sn.get(L(e));if(o){const r=o.container&&X(o.container);r?n(r.reload(t)):(N(`app ${e} is not rendered, cannot use reload`),n(!1))}else N(`app ${e} does not exist`),n(!1)}))}function Vn(e){return new Promise((t=>{if(!A(e))return C("renderApp options must be an object");const n=v(e.container)?e.container:d(e.container)?document.querySelector(e.container):null;if(!v(n))return C("Target container is not a DOM element.");const o=q(Zn.tagName);for(const t in e)if("onDataChange"===t)_(e[t])&&o.addEventListener("datachange",e[t]);else if("lifeCycles"===t){const n=e[t];if(A(n))for(const e in n)e.toUpperCase()in Ee&&_(n[e])&&o.addEventListener(e.toLowerCase(),n[e])}else"container"!==t&&o.setAttribute(t,e[t]);const r=()=>{s(),t(!0)},i=()=>{s(),t(!1)},s=()=>{o.removeEventListener(Ee.MOUNTED,r),o.removeEventListener(Ee.ERROR,i)};o.addEventListener(Ee.MOUNTED,r),o.addEventListener(Ee.ERROR,i),n.appendChild(o)}))}function Yn(e){const t=Sn.get(L(e));if(t)return t.getLifeCycleState();N(`app ${e} does not exist`)}class Jn extends lt{constructor(){super(...arguments),this.tagName="micro-app",this.hasInit=!1,this.options={},this.router=Gt,this.preFetch=jn,this.unmountApp=Qn,this.unmountAllApps=zn,this.getActiveApps=qn,this.getAllApps=Gn,this.reload=Xn,this.renderApp=Vn,this.getAppStatus=Yn}start(e){var n,o,r;if(!t||!window.customElements)return C("micro-app is not supported in this environment");if(this.hasInit)return C("microApp.start executed repeatedly");if(this.hasInit=!0,null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return C(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(Fn(),Hn.rawWindow.customElements.get(this.tagName))return N(`element ${this.tagName} is already defined`);if(A(e)&&(this.options=e,e["disable-scopecss"]=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss,e["disable-sandbox"]=null!==(o=e["disable-sandbox"])&&void 0!==o?o:e.disableSandbox,e.preFetchApps&&jn(e.preFetchApps),e.globalAssets&&(A(r=e.globalAssets)&&B((()=>{Kn(r.js,"js",Me.script),Kn(r.css,"css",Me.link)}))),A(e.plugins))){const t=e.plugins.modules;if(A(t))for(const e in t){const n=L(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}$n(this.tagName)}}const Zn=new Jn;exports.EventCenterForMicroApp=ut,exports.MicroApp=Jn,exports.default=Zn,exports.getActiveApps=qn,exports.getAllApps=Gn,exports.getAppStatus=Yn,exports.preFetch=jn,exports.pureCreateElement=q,exports.reload=Xn,exports.removeDomScope=K,exports.renderApp=Vn,exports.unmountAllApps=zn,exports.unmountApp=Qn,exports.version=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="1.0.0-rc.4",t="undefined"!=typeof window,n="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),r=()=>!1,o=Array.isArray,i=Object.assign,s=Object.defineProperty,a=Object.defineProperties,c=Object.prototype.toString,l=Object.prototype.hasOwnProperty,u=e=>c.call(e);function p(e){return void 0===e}function h(e){return null===e}function d(e){return"string"==typeof e}function m(e){return"boolean"==typeof e}function f(e){return"number"==typeof e}function _(e){return"function"==typeof e}function A(e){return"[object Object]"===u(e)}function w(e){return!h(e)&&"object"==typeof e}function y(e){return"[object Promise]"===u(e)}function g(e){var t;if(_(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function b(e){var t;return e instanceof URL||!!(null===(t=e)||void 0===t?void 0:t.href)}function v(e){var t;return e instanceof Element||d(null===(t=e)||void 0===t?void 0:t.tagName)}function E(e){var t;return e instanceof Node||f(null===(t=e)||void 0===t?void 0:t.nodeType)}function P(e){return"[object HTMLLinkElement]"===u(e)}function R(e){return"[object HTMLStyleElement]"===u(e)}function S(e){return"[object HTMLScriptElement]"===u(e)}function M(e){return v(e)&&"MICRO-APP-BODY"===e.tagName.toUpperCase()}function C(e,t,n){if(null==e)throw new TypeError("includes target is null or undefined");const r=Object(e),o=parseInt(r.length,10)||0;if(0===o)return!1;n=parseInt(n,10)||0;let i=Math.max(n>=0?n:o+n,0);for(;i<o;){if(t===r[i]||t!=t&&r[i]!=r[i])return!0;i++}return!1}function N(e,t=null,...n){const r=t&&d(t)?` app ${t}:`:"";d(e)?console.error(`[micro-app]${r} ${e}`,...n):console.error(`[micro-app]${r}`,e,...n)}function O(e,t=null,...n){const r=t&&d(t)?` app ${t}:`:"";d(e)?console.warn(`[micro-app]${r} ${e}`,...n):console.warn(`[micro-app]${r}`,e,...n)}function D(e,...t){Promise.resolve().then(e.bind(null,...t))}const I=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function x(e){return e.startsWith("//")?`${n.location.protocol}${e}`:e}function L(e,t=null){if(!d(e)||!e)return"";try{const{origin:t,pathname:n,search:r}=I(x(e),(window.rawWindow||window).location.href);if(/\.(\w+)$/.test(n))return`${t}${n}${r}`;const o=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(o)?`${o}${r}`:""}catch(e){return N(e,t),""}}function T(e){return d(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function W(e){const{origin:t,pathname:n}=I(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function U(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:I(e,W(x(t))).toString()}function B(e,t,n,r){let o=0;function i(){++o===e.length&&r&&r()}e.forEach(((e,r)=>{y(e)?e.then((e=>{t({data:e,index:r}),i()})).catch((e=>{n({error:e,index:r}),i()})):(t({data:e,index:r}),i())}))}const k=n.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function H(e){return new Promise((t=>{k((()=>{e(t)}))}))}let F=null;function $(e){F=e}function j(){return F}let K=!1;function q(e){$(null),e&&!K&&(K=!0,D((()=>{K=!1})))}function G(e){F===e||K||($(e),D((()=>{$(null)})))}function Q(e,t){const n=(window.rawDocument||document).createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function X(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function z(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||/^title$/i.test(e)||/^:root$/i.test(e)}function V(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function Y(e){return e?e.replace(/^\s+|\s+$/g,""):""}function J(){return navigator.userAgent.indexOf("Firefox")>-1}function Z(e){const t={},n=e.split("&");for(const e of n){const n=e.indexOf("="),r=n<0?e:e.slice(0,n),i=n<0?null:e.slice(n+1);if(r in t){let e=t[r];o(e)||(e=t[r]=[e]),e.push(i)}else t[r]=i}return t}function ee(e){let t="";for(const n in e){const r=e[n];if(h(r))t+=(t.length?"&":"")+n;else{(o(r)?r:[r]).forEach((e=>{p(e)||(t+=(t.length?"&":"")+n,h(e)||(t+="="+e))}))}}return t}function te(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function ne(e){const t=e.attributes,n=new Map;for(let e=0;e<t.length;e++)n.set(t[e].name,t[e].value);return n}function re(e,t){e?e.push((()=>H((e=>{t(),e()})))):t()}function oe(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function ie(e){return e.startsWith("inline-")}function se(e,t,n,...r){try{_(e)&&e(...r)}catch(e){N(`An error occurred in app ${t} window.${n} \n`,null,e)}}function ae(e,t,n,r){var o;if(!e)return N(`element does not exist in lifecycle ${n}`,t);e=V(e),q();const s=i({name:t,container:e},r&&{error:r}),a=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),_(null===(o=or.options.lifeCycles)||void 0===o?void 0:o[n])&&or.options.lifeCycles[n](a),e.dispatchEvent(a)}function ce(e,t,n={}){var r;const o=new CustomEvent(t,{detail:n});null===(r=e.sandBox)||void 0===r||r.microAppWindow.dispatchEvent(o)}function le(e,t=null,n={}){return q(),_(or.options.fetch)?or.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class ue{static getInstance(){return this.instance||(this.instance=new ue),this.instance}run(e,t){const n=e.name,r=e.ssrUrl||e.url;(r.includes(".js")?Promise.resolve(`<micro-app-head><script src='${r}'><\/script></micro-app-head><micro-app-body></micro-app-body>`):le(r,n,{cache:"no-cache"})).then((o=>{if(!o){const t="html is empty, please check in detail";return e.onerror(new Error(t)),N(t,n)}o=this.formatHTML(r,o,n),t(o,e)})).catch((t=>{N(`Failed to fetch data from ${e.url}, micro-app stop rendering`,n,t),e.onLoadError(t)}))}formatHTML(e,t,n){return this.processHtml(e,t,n,or.options.plugins).replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>")))}processHtml(e,t,n,r){var o;if(!r)return t;const i=[];return r.global&&i.push(...r.global),(null===(o=r.modules)||void 0===o?void 0:o[n])&&i.push(...r.modules[n]),i.length>0?i.reduce(((t,n)=>A(n)&&_(n.processHtml)?n.processHtml(t,e):t),t):t}}const pe=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,he=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function de(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class me{constructor(){this.cssText="",this.prefix="",this.baseURI="",this.linkPath="",this.result="",this.scopecssDisable=!1,this.scopecssDisableSelectors=[],this.scopecssDisableNextLine=!1,this.mediaRule=this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/,"@media"),this.supportsRule=this.createMatcherForRuleWithChildRule(/^@supports *([^{]+)/,"@supports"),this.documentRule=this.createMatcherForRuleWithChildRule(/^@([-\w]+)?document *([^{]+)/,"@document"),this.hostRule=this.createMatcherForRuleWithChildRule(/^@host\s*/,"@host"),this.importRule=this.createMatcherForNoneBraceAtRule("import"),this.charsetRule=this.createMatcherForNoneBraceAtRule("charset"),this.namespaceRule=this.createMatcherForNoneBraceAtRule("namespace"),this.containerRule=this.createMatcherForRuleWithChildRule(/^@container *([^{]+)/,"@container")}exec(e,t,n,r){return this.cssText=e,this.prefix=t,this.baseURI=n,this.linkPath=r||"",this.matchRules(),J()?decodeURIComponent(this.result):this.result}reset(){this.cssText=this.prefix=this.baseURI=this.linkPath=this.result="",this.scopecssDisable=this.scopecssDisableNextLine=!1,this.scopecssDisableSelectors=[]}matchRules(){for(this.matchLeadingSpaces(),this.matchComments();this.cssText.length&&"}"!==this.cssText.charAt(0)&&(this.matchAtRule()||this.matchStyleRule());)this.matchComments()}matchStyleRule(){const e=this.formatSelector(!0);return this.scopecssDisableNextLine=!1,e?(this.recordResult(e),this.matchComments(),this.styleDeclarations(),this.matchLeadingSpaces(),!0):de("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=Y(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||pe.test(n)||(n=he.test(n)?n.replace(he,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||de("Declaration missing '}'",this.linkPath)):de("Declaration missing '{'",this.linkPath)}matchAllDeclarations(e=1){let t=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^{}/])*/,!0)[0];if(t&&(this.scopecssDisableNextLine||this.scopecssDisable&&!this.scopecssDisableSelectors.length||(t=t.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,t)=>/^((data|blob):|#)/.test(t)||/^(https?:)?\/\//.test(t)?e:(/^((\.\.?\/)|[^/])/.test(t)&&this.linkPath&&(this.baseURI=function(e){const t=e.split("/");return t.pop(),x(t.join("/")+"/")}(this.linkPath)),`url("${U(t,this.baseURI)}")`)))),this.recordResult(t)),this.scopecssDisableNextLine=!1,this.cssText){if("}"===this.cssText.charAt(0)){if(!e)return;return e>1&&this.commonMatch(/}+/),this.matchAllDeclarations(e-1)}return"/"===this.cssText.charAt(0)&&("*"===this.cssText.charAt(1)?this.matchComments():this.commonMatch(/\/+/)),"{"===this.cssText.charAt(0)&&(this.commonMatch(/{+\s*/),e++),this.matchAllDeclarations(e)}}matchAtRule(){return"@"===this.cssText[0]&&(this.scopecssDisableNextLine=!1,this.keyframesRule()||this.mediaRule()||this.customMediaRule()||this.supportsRule()||this.importRule()||this.charsetRule()||this.namespaceRule()||this.containerRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return de("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return de("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):de("@keyframes missing '}'",this.linkPath)}keyframeRule(){let e;const t=[];for(;e=this.commonMatch(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),this.commonMatch(/^,\s*/);return!!t.length&&(this.styleDeclarations(),this.matchLeadingSpaces(),!0)}customMediaRule(){return!!this.commonMatch(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/)&&(this.matchLeadingSpaces(),!0)}pageRule(){return!!this.commonMatch(/^@page */)&&(this.formatSelector(!1),this.scopecssDisableNextLine=!1,this.commonHandlerForAtRuleWithSelfRule("page"))}fontFaceRule(){return!!this.commonMatch(/^@font-face\s*/)&&this.commonHandlerForAtRuleWithSelfRule("font-face")}createMatcherForRuleWithChildRule(e,t){return()=>!!this.commonMatch(e)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):de(`${t} missing '}'`,this.linkPath)):de(`${t} missing '{'`,this.linkPath))}createMatcherForNoneBraceAtRule(e){const t=new RegExp("^@"+e+"\\s*([^;]+);");return()=>!!this.commonMatch(t)&&(this.matchLeadingSpaces(),!0)}commonHandlerForAtRuleWithSelfRule(e){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):de(`@${e} missing '}'`,this.linkPath)):de(`@${e} missing '{'`,this.linkPath)}matchComments(){for(;this.matchComment(););}matchComment(){if("/"!==this.cssText.charAt(0)||"*"!==this.cssText.charAt(1))return!1;this.scopecssDisableNextLine=!1;let e=2;for(;""!==this.cssText.charAt(e)&&("*"!==this.cssText.charAt(e)||"/"!==this.cssText.charAt(e+1));)++e;if(e+=2,""===this.cssText.charAt(e-1))return de("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=Y(t.replace(/^\s*!/,"")),"scopecss-disable-next-line"===t)this.scopecssDisableNextLine=!0;else if(/^scopecss-disable/.test(t))if("scopecss-disable"===t)this.scopecssDisable=!0;else{this.scopecssDisable=!0;t.replace("scopecss-disable","").split(",").forEach((e=>{this.scopecssDisableSelectors.push(Y(e))}))}else"scopecss-enable"===t&&(this.scopecssDisable=!1,this.scopecssDisableSelectors=[]);return this.cssText=this.cssText.slice(e),this.matchLeadingSpaces(),!0}commonMatch(e,t=!1){const n=e.exec(this.cssText);if(!n)return;const r=n[0];return this.cssText=this.cssText.slice(r.length),t||this.recordResult(r),n}matchOpenBrace(){return this.commonMatch(/^{\s*/)}matchCloseBrace(){return this.commonMatch(/^}/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){J()?this.result+=encodeURIComponent(e):this.result+=e}}function fe(e,t,n,r,o){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let i=null;try{i=_e.exec(e.textContent,n,r,o),_e.reset()}catch(e){_e.reset(),N("An error occurred while parsing CSS:\n",t,e)}i&&(e.textContent=i)}}let _e;function Ae(e,t,n){if(t.scopecss){const r=we(t.name);if(_e||(_e=new me),e.textContent)fe(e,t.name,r,t.url,n);else{const o=new MutationObserver((function(){o.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&fe(e,t.name,r,t.url,n)}));o.observe(e,{childList:!0})}}return e}function we(e,t=!1){const n=t?"\\":"";return`${or.tagName}${n}[name=${e}${n}]`}function ye(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function ge(e){const t=new CustomEvent("load");ye(t,e),_(e.onload)?e.onload(t):e.dispatchEvent(t)}function be(e){const t=new CustomEvent("error");ye(t,e),_(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var ve,Ee,Pe,Re,Se,Me,Ce=function(){const e=new Map,t=new Map;function n(e){return{setInfo(t,n){e.set(t,n)},getInfo(t){var n;return null!==(n=e.get(t))&&void 0!==n?n:null},hasInfo:t=>e.has(t),deleteInfo:t=>e.delete(t)}}return{link:n(e),script:Object.assign(Object.assign({},n(t)),{deleteInlineInfo(e){e.forEach((e=>{ie(e)&&t.delete(e)}))}})}}();function Ne(e,t,n,r=!1){const o=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===o&&i){i=U(i,n.url);let t=Ce.link.getInfo(i);const o={attrs:ne(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||o:t={code:"",appSpace:{[n.name]:o}},Ce.link.setInfo(i,t),r)return{address:i,linkInfo:t};n.source.links.add(i),s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),t.appSpace[n.name].placeholder=s}else o&&["prefetch","preload","prerender"].includes(o)?r?s=document.createComment(`link element with rel=${o}${i?" & href="+i:""} removed by micro-app`):null==t||t.removeChild(e):i&&qn.rawSetAttribute.call(e,"href",U(i,n.url));return r?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function Oe(e,t,n,r){const o=Array.from(t.source.links),i=o.map((e=>{const n=Ce.link.getInfo(e);return n.code?n.code:le(e,t.name)})),s=r?[]:null;B(i,(e=>{re(s,(()=>function(e,t,n,r){const o=Ce.link.getInfo(e);o.code=t;const i=o.appSpace[r.name],s=i.placeholder;if(s){const t=Q("style");De(r,e,t,o,i.attrs),s.parentNode?s.parentNode.replaceChild(t,s):n.appendChild(t),i.placeholder=null}}(o[e.index],e.data,n,t)))}),(e=>{N(e,t.name)}),(()=>{r?r.then((()=>{s.push((()=>Promise.resolve(t.onLoad({html:e})))),oe(s)})):t.onLoad({html:e})}))}function De(e,t,n,r,o){if(e.scopecss){const o=r.appSpace[e.name];if(o.prefix=o.prefix||we(e.name),o.parsedCode)n.textContent=o.parsedCode;else{const i=function(e,t,n){const r=n.appSpace;for(const n in r)if(n!==e){const e=r[n];if(e.parsedCode)return e.parsedCode.replace(new RegExp(we(n,!0),"g"),t)}}(e.name,o.prefix,r);i?n.textContent=i:(n.textContent=r.code,Ae(n,e,t)),o.parsedCode=n.textContent}}else n.textContent=r.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),qn.rawSetAttribute.call(e,n,t))}))}(n,o)}!function(e){e.NAME="name",e.URL="url"}(ve||(ve={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOAD_FAILED="load_failed",e.BEFORE_MOUNT="before_mount",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(Ee||(Ee={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error",e.BEFORESHOW="beforeshow",e.AFTERSHOW="aftershow",e.AFTERHIDDEN="afterhidden"}(Pe||(Pe={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(Re||(Re={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(Se||(Se={})),function(e){e.DESTROY="destroy",e.DESTORY="destory",e.INLINE="inline",e.DISABLESCOPECSS="disableScopecss",e.DISABLESANDBOX="disableSandbox",e.DISABLE_SCOPECSS="disable-scopecss",e.DISABLE_SANDBOX="disable-sandbox",e.DISABLE_MEMORY_ROUTER="disable-memory-router",e.DISABLE_PATCH_REQUEST="disable-patch-request",e.KEEP_ROUTER_STATE="keep-router-state",e.HIDDEN_ROUTER="hidden-router",e.KEEP_ALIVE="keep-alive",e.CLEAR_DATA="clear-data",e.SSR="ssr",e.FIBER="fiber"}(Me||(Me={}));const Ie=[1,2,3],xe="search",Le="native",Te="native-scope",We="pure",Ue=[xe,Le,Te,We],Be=["popstate","hashchange","load","beforeunload","unload","unmount","appstate-change","statechange","mounted"],ke=["onpopstate","onhashchange","onload","onbeforeunload","onunload","onerror"],He=["DOMContentLoaded","readystatechange"],Fe=["onreadystatechange"],$e=["window","self","globalThis"],je=["rawWindow","rawDocument"],Ke="window,self,globalThis,document,Document,Array,Object,String,Boolean,Math,Number,Symbol,Date,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,navigator,undefined,location,history",qe=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function Ge(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function Qe(e,t){return e.inline||t.appSpace[e.name].inline||Ge(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function Xe(e){return e.iframe?e.sandBox.microAppWindow:qn.rawWindow}function ze(e,t,n){return function(e,t,n){const r=t.appSpace;for(const t in r)if(t!==e.name){const e=r[t];if(e.parsedCode===n&&e.parsedFunction)return e.parsedFunction}}(e,t,n)||function(e,t){return new(Xe(e).Function)(t)}(e,n)}function Ve(){const e="inline-"+Math.random().toString(36).substr(2,15);return Ce.script.hasInfo(e)?Ve():e}function Ye(e,t){return e.useSandbox&&!Ge(e,t)}function Je(e,t){return Ye(e,t)?e.iframe?"iframe":"with":"disable"}function Ze(e,t,n,r=!1){var o;let i=null,s=e.getAttribute("src");if(s&&(s=U(s,n.url)),e.hasAttribute("exclude")||tt(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!qe.includes(e.type)||e.hasAttribute("ignore")||nt(s,n.name))return(null===(o=qn.rawDocument)||void 0===o?void 0:o.currentScript)&&delete qn.rawDocument.currentScript,null;if(qn.supportModuleScript&&e.noModule||!qn.supportModuleScript&&"module"===e.type)i=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(s){let t=Ce.script.getInfo(s);const o={async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:ne(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||o:t={code:"",isExternal:!0,appSpace:{[n.name]:o}},Ce.script.setInfo(s,t),r)return{address:s,scriptInfo:t};n.source.scripts.add(s),i=document.createComment(`script with src='${s}' extract by micro-app`)}else if(e.textContent){const t=Ve(),o={code:e.textContent,isExternal:!1,appSpace:{[n.name]:{async:!1,defer:"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:ne(e)}}};if(r)return{address:t,scriptInfo:o};n.source.scripts.add(t),Ce.script.setInfo(t,o),i=document.createComment("inline script extract by micro-app")}else r||(i=document.createComment("script element removed by micro-app"))}return r?{replaceComment:i}:null==t?void 0:t.replaceChild(i,e)}function et(e){var t,n,r;return[...(null===(t=or.options.plugins)||void 0===t?void 0:t.global)||[],...(null===(r=null===(n=or.options.plugins)||void 0===n?void 0:n.modules)||void 0===r?void 0:r[e])||[]]}function tt(e,t){if(!e)return!1;return(et(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function nt(e,t){if(!e)return!1;return(et(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function rt(e,t){const n=Array.from(t.source.scripts),r=[],o=[];for(const e of n){const n=Ce.script.getInfo(e),i=n.appSpace[t.name];(!i.defer&&!i.async||t.isPrefetch&&!t.isPrerender)&&(r.push(n.code?n.code:le(e,t.name)),o.push([e,n]))}const i=t.isPrefetch||t.fiber?[]:null;r.length?B(r,(e=>{re(i,(()=>function(e,t,n,r){if(t.code=n,r.isPrefetch&&2===r.prefetchLevel){const o=t.appSpace[r.name];if(!o.parsedCode&&(o.parsedCode=it(e,r,n,t),o.sandboxType=Je(r,t),!Qe(r,t)))try{o.parsedFunction=ze(r,t,o.parsedCode)}catch(e){N("Something went wrong while handling preloaded resources",r.name,"\n",e)}}}(o[e.index][0],o[e.index][1],e.data,t)))}),(e=>{N(e,t.name)}),(()=>{i?(i.push((()=>Promise.resolve(t.onLoad({html:e})))),oe(i)):t.onLoad({html:e})})):t.onLoad({html:e})}function ot(e,t,n,r,o){try{!function(e){!function(e){e.sandBox&&(qn.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],s=Je(t,n);if(i.parsedCode&&i.sandboxType===s||(i.parsedCode=it(e,t,n.code,n),i.sandboxType=s,i.parsedFunction=null),Qe(t,n)){const s=o||Q("script");if(function(e,t,n,r,o,i){if(n){if(qn.rawSetAttribute.call(r,"type","module"),ie(e)?r.textContent=t:r.src=e,i){const t=()=>{i.moduleCount&&i.moduleCount--,i(0===i.moduleCount)};ie(e)?D(t):r.onload=t}}else r.textContent=t;!function(e,t){t.forEach(((t,n)=>{"type"===n&&"module"===t||"defer"===n||"async"===n||("src"===n&&(n="data-origin-src"),qn.rawSetAttribute.call(e,n,t))}))}(r,o)}(e,i.parsedCode,Ge(t,n),s,i.attrs,r),!o){const e=t.iframe?t.sandBox.microBody:t.querySelector("micro-app-body");null==e||e.appendChild(s)}}else!function(e,t){const n=t.appSpace[e.name];n.parsedFunction||(n.parsedFunction=ze(e,t,n.parsedCode));n.parsedFunction.call(Xe(e))}(t,n)}catch(n){throw console.error(`[micro-app from ${o?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e),n}}function it(e,t,n,r){return A(or.options.plugins)&&(n=function(e,t,n,r){var o;const i=st(r.global,t,e);return st(null===(o=r.modules)||void 0===o?void 0:o[n],i,e)}(e,n,t.name,or.options.plugins)),Ye(t,r)?t.iframe?`(function(window,self,global,location){;${n}\n${ie(e)?"":`//# sourceURL=${e}\n`}}).call(window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyLocation);`:`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${Ke}){;${n}\n${ie(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${Ke})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function st(e,t,n){return o(e)?e.reduce(((e,t)=>A(t)&&_(t.loader)?t.loader(e,n):e),t):t}function at(e,t,n,r){const o=Array.from(e.children);o.length&&o.forEach((e=>{at(e,t,n,r)}));for(const n of o)P(n)?n.hasAttribute("exclude")||tt(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||nt(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&qn.rawSetAttribute.call(n,"href",U(n.getAttribute("href"),t.url)):Ne(n,e,t):R(n)?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&re(r,(()=>Ae(n,t))):S(n)?Ze(n,e,t):"[object HTMLImageElement]"===u(n)&&n.hasAttribute("src")&&qn.rawSetAttribute.call(n,"src",U(n.getAttribute("src"),t.url))}function ct(e,t){const n=t.parseHtmlString(e),r=qn.rawElementQuerySelector.call(n,"micro-app-head"),o=qn.rawElementQuerySelector.call(n,"micro-app-body");if(!r||!o){const e=`element ${r?"body":"head"} is missing`;return t.onerror(new Error(e)),N(e,t.name)}const i=t.isPrefetch||t.fiber?[]:null;at(n,t,r,i);const s=oe(i);t.source.links.size?Oe(n,t,r,s):s?s.then((()=>t.onLoad({html:n}))):t.onLoad({html:n}),t.source.scripts.size?rt(n,t):t.onLoad({html:n})}const lt=new class{constructor(){this.eventList=new Map,this.queue=[],this.recordStep={},this.process=()=>{var e,t;let n;const r=this.recordStep,o=this.queue;for(this.recordStep={},this.queue=[];n=o.shift();){const o=this.eventList.get(n),i=o.tempData,s=o.force;let a;if(o.tempData=null,o.force=!1,s||!this.isEqual(o.data,i)){o.data=i||o.data;for(const e of o.callbacks){const t=e(o.data);t&&(null!=a?a:a=[]).push(t)}null===(t=(e=r[n]).dispatchDataEvent)||void 0===t||t.call(e),r[n].nextStepList.forEach((e=>e(a)))}}}}isLegalName(e){return!!e||(N("event-center: Invalid name"),!1)}enqueue(e,t,n){this.recordStep[e]?(this.recordStep[e].nextStepList.push(t),n&&(this.recordStep[e].dispatchDataEvent=n)):this.recordStep[e]={nextStepList:[t],dispatchDataEvent:n},!this.queue.includes(e)&&1===this.queue.push(e)&&D(this.process)}isEqual(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==t[n])return!1;return!0}on(e,t,n=!1){if(this.isLegalName(e)){if(!_(t))return N("event-center: Invalid callback function");let r=this.eventList.get(e);r?n&&Object.keys(r.data).length&&(!this.queue.includes(e)||this.isEqual(r.data,r.tempData))&&t(r.data):(r={data:{},callbacks:new Set},this.eventList.set(e,r)),r.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(_(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,r,o){if(this.isLegalName(e)){if(!A(t))return N("event-center: data must be object");let s=this.eventList.get(e);s?(s.tempData=i({},s.tempData||s.data,t),!s.force&&(s.force=!!r)):(s={data:t,callbacks:new Set},this.eventList.set(e,s),s.force=!0),this.enqueue(e,n,o)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function ut(e,t){return d(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class pt{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),lt.on("global",e,t)}removeGlobalDataListener(e){_(e)&&lt.off("global",e)}setGlobalData(e,t,n){q(),lt.dispatch("global",e,(e=>_(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return lt.getData("global")}clearGlobalData(){lt.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=lt.eventList.get("global");if(t)for(const n of t.callbacks)(e&&e===n.__APP_NAME__||!e&&!n.__APP_NAME__)&&t.callbacks.delete(n)}}class ht extends pt{addDataListener(e,t,n){lt.on(ut(T(e),!1),t,n)}removeDataListener(e,t){_(t)&&lt.off(ut(T(e),!1),t)}getData(e,t=!1){return lt.getData(ut(T(e),t))}setData(e,t,n,r){lt.dispatch(ut(T(e),!0),t,(e=>_(n)&&n(e)),r)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){lt.clearData(ut(T(e),t))}clearDataListener(e){lt.off(ut(T(e),!1))}}class dt extends pt{constructor(e){super(),this.appName=T(e),!this.appName&&N(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,lt.on(ut(this.appName,!0),e,t)}removeDataListener(e){_(e)&&lt.off(ut(this.appName,!0),e)}getData(e=!0){return lt.getData(ut(this.appName,e))}dispatch(e,t,n){q(),lt.dispatch(ut(this.appName,!1),e,(e=>_(t)&&t(e)),n,(()=>{const t=Dn.get(this.appName);if((null==t?void 0:t.container)&&A(e)){const e=new CustomEvent("datachange",{detail:{data:lt.getData(ut(this.appName,!1))}});V(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){lt.clearData(ut(this.appName,e))}clearDataListener(){lt.off(ut(this.appName,!0))}}function mt(e){var t,n;if(e){e.umdDataListeners={global:new Set(null===(t=e.umdDataListeners)||void 0===t?void 0:t.global),normal:new Set(null===(n=e.umdDataListeners)||void 0===n?void 0:n.normal)};const r=lt.eventList.get("global");if(r)for(const t of r.callbacks)e.appName===t.__APP_NAME__&&e.umdDataListeners.global.add(t);const o=lt.eventList.get(ut(e.appName,!0));if(o)for(const t of o.callbacks)e.umdDataListeners.normal.add(t)}}function ft(e){if(null==e?void 0:e.umdDataListeners){for(const t of e.umdDataListeners.global)e.addGlobalDataListener(t,t.__AUTO_TRIGGER__);for(const t of e.umdDataListeners.normal)e.addDataListener(t,t.__AUTO_TRIGGER__);_t(e)}}function _t(e){null==e||delete e.umdDataListeners}class At{constructor(){this.appInstanceMap=Dn}static getInstance(){return this.instance||(this.instance=new At),this.instance}get(e){return this.appInstanceMap.get(e)}set(e,t){this.appInstanceMap.set(e,t)}getAll(){return Array.from(this.appInstanceMap.values())}clear(){this.appInstanceMap.clear()}}function wt(){yt(),At.getInstance().getAll().forEach((e=>{e.container&&V(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&At.getInstance().clear()}function yt(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",wt,!1)}function gt(e){return m(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=_(t=e)&&0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");var t}function bt(e,t,n="WINDOW"){if(_(e)&&!function(e){return m(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=g(e)}(e)&&!gt(e)){const r=`__MICRO_APP_BOUND_${n}_FUNCTION__`;if(e[r])return e[r];const o=e.bind(t);for(const t in e)o[t]=e[t];return e.hasOwnProperty("prototype")&&s(o,"prototype",{value:e.prototype,configurable:!0,enumerable:!1,writable:!0}),e[r]=o}return e}function vt(e,t,n){const{proxyDocument:r,documentEffect:o}=function(e,t){const n=new Map,r=new Map;let o=null,i=null;const{rawDocument:s,rawCreateElement:a,rawCreateElementNS:c,rawAddEventListener:l,rawRemoveEventListener:u}=qn;function p(t,n){const r=a.call(s,t,n);return r.__MICRO_APP_NAME__=e,r}function h(t,n,r){const o=c.call(s,t,n,r);return o.__MICRO_APP_NAME__=e,o}function d(e,t,r){const o=n.get(e);o?o.add(t):n.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=r),l.call(s,e,t,r)}function m(e,t,r){const o=n.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t),u.call(s,e,t,r)}const f=()=>{r.clear(),i=null},A=()=>{i=o||i,n.forEach(((e,t)=>{if(e.size){const n=r.get(t)||[];r.set(t,new Set([...n,...e]))}}))},w=()=>{i&&!o&&(b.onclick=i),r.forEach(((e,t)=>{for(const n of e)b.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),f()},y=()=>{_(o)&&u.call(s,"click",o),o=null,n.size&&(n.forEach(((e,t)=>{for(const n of e)u.call(s,t,n)})),n.clear())},g=(()=>{var e;const t=new Map([["onclick",e=>{_(o)&&u.call(s,"click",o,!1),_(e)&&l.call(s,"click",e,!1),o=e}]]),n=(null===(e=or.options)||void 0===e?void 0:e.customProxyDocumentProps)||new Map;return new Map([...t,...n])})(),b=new Proxy(s,{get:(n,r)=>{var i;return G(e),"createElement"===r?p:"createElementNS"===r?h:r===Symbol.toStringTag?"ProxyDocument":"defaultView"===r?t.proxyWindow:"onclick"===r?o:"addEventListener"===r?d:"removeEventListener"===r?m:"microAppElement"===r?null===(i=Dn.get(e))||void 0===i?void 0:i.container:"__MICRO_APP_NAME__"===r?e:bt(Reflect.get(n,r),s,"DOCUMENT")},set:(e,t,n)=>{if(g.has(t)){g.get(t)(n)}else"microAppElement"!==t&&Reflect.set(e,t,n);return!0}});return{proxyDocument:b,documentEffect:{reset:f,record:A,rebuild:w,release:y}}}(e,n),i=function(e,t){const{rawDocument:n,rawRootDocument:r}=qn;class o{static[Symbol.hasInstance](e){let n=e;for(;n;)if(n=Object.getPrototypeOf(n),n===o.prototype)return!0;return e===t||e instanceof r}}return Object.setPrototypeOf(o,r),Object.setPrototypeOf(o.prototype,new Proxy(r.prototype,{get:(t,r)=>(G(e),bt(Reflect.get(t,r),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),o}(e,r);return a(t,{document:{configurable:!1,enumerable:!0,get:()=>r},Document:{configurable:!1,enumerable:!1,get:()=>i}}),o}function Et(e,t,n){return function(e){const t=qn.rawWindow;Object.getOwnPropertyNames(t).filter((e=>/^on/.test(e)&&!ke.includes(e))).forEach((n=>{const{enumerable:r,writable:o,set:i}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,writable:!0};s(e,n,{enumerable:r,configurable:!0,get:()=>t[n],set:(null!=o?o:i)?e=>{t[n]=e}:void 0})}))}(t),function(e,t,n){const r=qn.rawWindow,o=new Map,i=new Proxy(t,{get:(t,o)=>(G(e),Reflect.has(t,o)||d(o)&&/^__MICRO_APP_/.test(o)||C(n.scopeProperties,o)?(C(je,o)&&q(),Reflect.get(t,o)):bt(Reflect.get(r,o),r)),set:(e,t,o)=>{if(C(n.rawWindowScopeKeyList,t))Reflect.set(r,t,o);else if(l.call(e,t)||!l.call(r,t)||C(n.scopeProperties,t))Reflect.has(e,t)&&!C(n.scopeProperties,t)||n.injectedKeys.add(t),Reflect.set(e,t,o);else{const i=Object.getOwnPropertyDescriptor(r,t),{configurable:a,enumerable:c,writable:l,set:u}=i;s(e,t,{value:o,configurable:a,enumerable:c,writable:null!=l?l:!!u}),n.injectedKeys.add(t)}return(C(n.escapeProperties,t)||C(n.staticEscapeProperties,t)&&!Reflect.has(r,t))&&!C(n.scopeProperties,t)&&(!Reflect.has(r,t)&&n.escapeKeys.add(t),Reflect.set(r,t,o)),!0},has:(e,t)=>C(n.scopeProperties,t)?n.injectedKeys.has(t)?Reflect.has(e,t):!!e[t]:Reflect.has(e,t)||Reflect.has(r,t),getOwnPropertyDescriptor:(e,t)=>{if(l.call(e,t))return o.set(t,"target"),Object.getOwnPropertyDescriptor(e,t);if(l.call(r,t)){o.set(t,"rawWindow");const e=Object.getOwnPropertyDescriptor(r,t);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,t,n)=>"rawWindow"===o.get(t)?Reflect.defineProperty(r,t,n):Reflect.defineProperty(e,t,n),ownKeys:e=>Reflect.ownKeys(r).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,t)=>!l.call(e,t)||(n.injectedKeys.has(t)&&n.injectedKeys.delete(t),n.escapeKeys.has(t)&&Reflect.deleteProperty(r,t),Reflect.deleteProperty(e,t))});n.proxyWindow=i}(e,t,n),function(e,t){const n=new Map,r=new Map,o=new Map,i=new Map,{rawWindow:s,rawAddEventListener:a,rawRemoveEventListener:c,rawDispatchEvent:l,rawSetInterval:u,rawSetTimeout:p,rawClearInterval:h,rawClearTimeout:d}=qn;function m(e){var n;return Be.includes(e)&&(null===(n=Dn.get(t))||void 0===n?void 0:n.container)?V(Dn.get(t).container):s}e.addEventListener=function(e,t,r){const o=n.get(e);o?o.add(t):n.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=r),a.call(m(e),e,t,r)},e.removeEventListener=function(e,t,r){const o=n.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t),c.call(m(e),e,t,r)},e.dispatchEvent=function(e){return l.call(m(null==e?void 0:e.type),e)},e.setInterval=function(e,t,...n){const r=u.call(s,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const r=p.call(s,e,t,...n);return i.set(r,{handler:e,timeout:t,args:n}),r},e.clearInterval=function(e){o.delete(e),h.call(s,e)},e.clearTimeout=function(e){i.delete(e),d.call(s,e)};const f=()=>{r.clear()},_=()=>{r.forEach(((t,n)=>{for(const r of t)e.addEventListener(n,r,null==r?void 0:r.__MICRO_APP_MARK_OPTIONS__)})),f()};return{reset:f,record:()=>{n.forEach(((e,t)=>{if(e.size){const n=r.get(t)||[];r.set(t,new Set([...n,...e]))}}))},rebuild:_,release:e=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)c.call(m(t),t,n)})),n.clear()),e&&(o.forEach(((e,t)=>{h.call(s,t)})),i.forEach(((e,t)=>{d.call(s,t)})),o.clear(),i.clear())}}}(t,e)}function Pt(e,t){if(Ut(e)){const n=qn.rawWindow.history.state,r={microAppState:i({},null==n?void 0:n.microAppState,{[e]:t})};return i({},n,r)}return t}function Rt(e){var t;const n=qn.rawWindow.history.state;return Ut(e)?(null===(t=null==n?void 0:n.microAppState)||void 0===t?void 0:t[e])||null:n}const St=/&/g,Mt=/=/g,Ct=/%M1/g,Nt=/%M2/g;function Ot(e){return encodeURIComponent(It(e).replace(St,"%M1").replace(Mt,"%M2"))}function Dt(e){return It(e).replace(Ct,"&").replace(Nt,"=")}function It(e){try{const t=decodeURIComponent(e);return e===t||Ct.test(t)||Nt.test(t)?t:It(t)}catch(t){return e}}function xt(e){var t,n;if(kt(e))return null;const r=qn.rawWindow.location;if(Ut(e)){const o=Tt(r.search,r.hash),i=(null===(t=o.hashQuery)||void 0===t?void 0:t[e])||(null===(n=o.searchQuery)||void 0===n?void 0:n[e]);return d(i)?Dt(i):null}return r.pathname+r.search+r.hash}function Lt(e,t){const n=t.pathname+t.search+t.hash;let r=!1;if(Ut(e)){let{pathname:t,search:o,hash:i}=qn.rawWindow.location;const s=Tt(o,i),a=Ot(n);if(i&&!o){r=!0,s.hashQuery?s.hashQuery[e]=a:s.hashQuery={[e]:a};const t=i.includes("?")?i.slice(0,i.indexOf("?")+1):i+"?";i=t+ee(s.hashQuery)}else s.searchQuery?s.searchQuery[e]=a:s.searchQuery={[e]:a},o="?"+ee(s.searchQuery);return{fullPath:t+o+i,isAttach2Hash:r}}return{fullPath:n,isAttach2Hash:r}}function Tt(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=Z(e.slice(1))),t.includes("?")&&(n.hashQuery=Z(t.slice(t.indexOf("?")+1))),n}function Wt(e){const t=Dn.get(e);return!(!t||t.isPrefetch)}function Ut(e){const t=Dn.get(e);return!(!t||!t.sandBox||t.routerMode!==xe)}function Bt(e){const t=Dn.get(e);return!(!t||!t.sandBox||t.routerMode!==Le)}function kt(e){const t=Dn.get(e);return!(!t||!t.sandBox||t.routerMode!==We)}function Ht(e){return Bt(e)||function(e){const t=Dn.get(e);return!(!t||!t.sandBox||t.routerMode!==Te)}(e)}function Ft(e,t){const n=t&&Le||e||or.options["disable-memory-router"]&&Le||or.options["router-mode"]||xe;return Ue.includes(n)?n:xe}function $t(e){const t=qn.rawWindow,n=t=>{Vn({excludeHiddenApp:!0,excludePreRender:!0}).includes(e)&&!t.onlyForBrowser&&jt(e,xt(e))};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function jt(e,t){const n=Dn.get(e),r=n.sandBox.proxyWindow,o=n.sandBox.microAppWindow;let i=!1;const s=r.location.href;if(t){const n=r.location.hash;dn(e,t,o.location),i=r.location.hash!==n}!function(e,t,n){const r=new PopStateEvent("popstate",{state:Rt(e)});n.dispatchEvent(r),xn(e)||_(t.onpopstate)&&t.onpopstate(r)}(e,r,o),i&&function(e,t,n,r){const o=new HashChangeEvent("hashchange",{newURL:t.location.href,oldURL:r});n.dispatchEvent(o),xn(e)||_(t.onhashchange)&&t.onhashchange(o)}(e,r,o,s),q()}function Kt(e,t,n){q(),Wt(e)&&(function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),qn.rawWindow.dispatchEvent(t)}(t),n&&function(e){const t=new HashChangeEvent("hashchange",{newURL:qn.rawWindow.location.href,oldURL:e});qn.rawWindow.dispatchEvent(t)}(n))}function qt(e,t){const n=qn.rawWindow.history;function r(n){return function(...r){var o,i,s;if(d(r[2])||b(r[2])){const a=I(r[2],t.href),c=a.pathname+a.search+a.hash;kt(e)||Qt(e,n,Lt(e,a),!0,Pt(e,r[0]),r[1]),c!==t.fullPath&&dn(e,c,t),null===(s=null===(o=Dn.get(e))||void 0===o?void 0:(i=o.sandBox).updateIframeBase)||void 0===s||s.call(i)}else Gt(e,n,r[2],r[0],r[1])}}const o=r("pushState"),i=r("replaceState");return xn(e)?{pushState:o,replaceState:i}:new Proxy(n,{get:(t,n)=>"state"===n?Rt(e):"pushState"===n?o:"replaceState"===n?i:bt(Reflect.get(t,n),t,"HISTORY"),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})}function Gt(e,t,n,r=null,o=""){if(Wt(e)){("pushState"===t?qn.rawPushState:qn.rawReplaceState).call(qn.rawWindow.history,r,o,n)}}function Qt(e,t,n,r,o,i){if(Wt(e)){const s=qn.rawWindow.location,a=s.pathname+s.search+s.hash,c=n.isAttach2Hash&&a!==n.fullPath?s.href:null;Gt(e,t,n.fullPath,o,i),a!==n.fullPath&&Ut(e)&&Kt(e,r,c)}}function Xt(e,t,n){Qt(e,"replaceState",t,!0,n)}function zt(e){const t=qn.rawWindow;return function(...n){var r;if((null===(r=t.history.state)||void 0===r?void 0:r.microAppState)&&(!A(n[0])||!n[0].microAppState)&&(d(n[2])||b(n[2]))){const e=t.location.href;I(n[2],e).href===e&&(n[0]=i({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),Vn({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{if(Ut(e)&&!xt(e)){Xt(e,Lt(e,Dn.get(e).sandBox.proxyWindow.location),Pt(e,Rt(e)))}})),q()}}function Vt(){const e=qn.rawWindow;e.history.pushState=zt(qn.rawPushState),e.history.replaceState=zt(qn.rawReplaceState)}function Yt(){const e=qn.rawWindow;e.history.pushState=qn.rawPushState,e.history.replaceState=qn.rawReplaceState}const{router:Jt,executeNavigationGuard:Zt,clearRouterWhenUnmount:en}=function(){function e(e,t,n,r){const o=t.sandBox.proxyWindow.location,i=I(n.path,o.href),s=o.pathname+o.search+o.hash,a=i.pathname+i.search+i.hash;if(s!==a||xt(e)!==a){if(!kt(e)){!function(e,t,n,r){Qt(e,t,Lt(e,n),!1,Pt(e,null!=r?r:null)),q()}(e,r&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state)}(Ht(e)||kt(e))&&jt(e,a)}}function t(t){return function(n){return new Promise(((r,o)=>{const i=T(n.name);if(i&&d(n.path))if(Vn({excludeHiddenApp:!0,excludePreRender:!0}).includes(i)){const o=Dn.get(i);r(o.sandBox.sandboxReady.then((()=>e(i,o,n,t))))}else o(N("navigation failed, app does not exist or is inactive"));else o(N("navigation failed, name & path are required when use router."+(t?"replace":"push")))}))}}function n(e){return function(...t){return qn.rawWindow.history[e](...t)}}const o=te(),i=te();function s(e,t,n,r){q();for(const o of r)_(o)?o(t,n,e):A(o)&&_(o[e])&&o[e](t,n)}function a(e){if(Ut(e)){Xt(e,Lt(e,Dn.get(e).sandBox.proxyWindow.location),Pt(e,Rt(e)))}}const c=Object.assign(Object.assign({current:new Map,encode:Ot,decode:Dt,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:o.add,afterEach:i.add,attachToURL:function(e){(e=T(e))&&Vn().includes(e)&&a(e)},attachAllToURL:function({includeHiddenApp:e=!1,includePreRender:t=!1}){Vn({excludeHiddenApp:!e,excludePreRender:!t}).forEach((e=>a(e)))}},function(){const e=function(){const e=new Map;return{add:function(t,n){return e.set(t,n),()=>!!e.has(t)&&e.delete(t)},get:t=>e.get(t),delete:t=>!!e.has(t)&&e.delete(t)}}();return{setDefaultPage:function(t){const n=T(t.name);return n&&t.path?e.add(n,t.path):r},removeDefaultPage:function(t){return!!(t=T(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){w(t)&&(e=new Proxy(t,{get:(e,t)=>(q(),bt(Reflect.get(e,t),e,"BASEROUTER")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)}))},getBaseAppRouter:()=>e}}());return{router:c,executeNavigationGuard:function(e,t,n){c.current.set(e,t),s(e,t,n,o.list()),k((()=>{s(e,t,n,i.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),tn=["getComputedStyle","visualViewport","matchMedia","ResizeObserver","IntersectionObserver"],nn=[/animationFrame$/i,/mutationObserver$/i,/height$|width$/i,/offset$/i,/selection$/i,/^range/i,/^screen/i,/^scroll/i,/X$|Y$/],rn=["body","head","html","title"],on=["host","hostname","port","protocol","origin"],sn=["childElementCount","children","firstElementChild","firstChild","lastElementChild","activeElement","fullscreenElement","pictureInPictureElement","pointerLockElement","styleSheets"],an=["append","contains","replaceChildren","createRange","getSelection","elementFromPoint","elementsFromPoint","getAnimations"],cn=["characterSet","compatMode","contentType","designMode","dir","doctype","embeds","fullscreenEnabled","hidden","implementation","lastModified","pictureInPictureEnabled","plugins","readyState","referrer","visibilityState","fonts"],ln=["execCommand","createRange","exitFullscreen","exitPictureInPicture","getElementsByTagNameNS","hasFocus","prepend"],un=["href","pathname","search","hash","host","hostname","port","protocol","search","origin","fullPath"];function pn(e,t,n,r,o,i){const a=qn.rawWindow.location,c=!!n,l=I(t);function u(){return c?n.location:l}function p(t,n){const r=I(t,A.href);if(r.origin===A.origin){const t=Lt(e,r);if(Ut(e)){if(r.pathname===A.pathname&&r.search===A.search){let o=null;return r.hash!==A.hash&&(t.isAttach2Hash&&(o=a.href),Gt(e,n,t.fullPath)),void(r.hash?Kt(e,!1,o):_())}if(t.isAttach2Hash)return Gt(e,n,t.fullPath),void _()}return t.fullPath}return t}function h(n,r){const o=I(n,t);o[r]===A[r]&&A.hash?Kt(e,!1):(Gt(e,o[r]===A[r]?"replaceState":"pushState",Lt(e,o).fullPath),_())}const d=t=>function(n){if(Wt(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&a[t](I(e,a.origin).href)}},m=d("assign"),f=d("replace"),_=e=>a.reload(e);s(u(),"fullPath",{enumerable:!0,configurable:!0,get:()=>A.pathname+A.search+A.hash});const A=new Proxy({},{get:(t,n)=>{const s=u();if("assign"===n)return m;if("replace"===n)return f;if("reload"===n)return _;if("self"===n)return s;if("fullPath"===n)return s.fullPath;if(Bt(e))return bt(Reflect.get(a,n),a,"LOCATION");if(c){if(on.includes(n))return r[n];if("href"===n)return s[n].replace(o,i)}return bt(Reflect.get(s,n),s,"LOCATION")},set:(n,r,o)=>{if(Wt(e)){const n=u();if("href"===r){const e=p(o,"pushState");e&&(a.href=I(e,a.origin).href)}else if("pathname"===r)if(Ht(e))a.pathname=o;else{h(("/"+o).replace(/^\/+/,"/")+A.search+A.hash,"pathname")}else if("search"===r)if(Ht(e))a.search=o;else{h(A.pathname+("?"+o).replace(/^\?+/,"?")+A.hash,"search")}else if("hash"===r)if(Ht(e))a.hash=o;else{const n=A.pathname+A.search+("#"+o).replace(/^#+/,"#"),r=I(n,t);r.hash!==A.hash&&Qt(e,"pushState",Lt(e,r),!1)}else Reflect.set(n,r,o)}return!0}});return A}function hn(e,t){const n=i({name:e},t);for(const e of un)n[e]=t[e];return n}function dn(e,t,n,r){var o;const i=hn(e,n),s=I(t,n.href);if(xn(e)){const t=Dn.get(e).sandBox.microAppWindow;null===(o=t.rawReplaceState)||void 0===o||o.call(t.history,Rt(e),"",s.href)}else{let e=s.href;n.self.origin!==s.origin&&(e=e.replace(s.origin,n.self.origin)),n.self.href=e}const a=hn(e,n);("auto"===r||i.fullPath!==a.fullPath&&"prevent"!==r)&&Zt(e,a,i)}function mn(e,t,n){const r=xt(e);r?dn(e,r,t,"auto"):fn(e,t,n)}function fn(e,t,n){n&&dn(e,n,t,"prevent"),kt(e)||Xt(e,Lt(e,t),Pt(e,null)),function(e,t){Zt(e,hn(e,t),hn(e,t))}(e,t)}function _n(e,t,n,r){if(!Ht(e)){if(!r){const{pathname:r,search:o,hash:i}=I(t);dn(e,r+o+i,n,"prevent")}kt(e)||An(e)}en(e)}function An(e){Xt(e,function(e,t){var n,r,o,i;let{pathname:s,search:a,hash:c}=t||qn.rawWindow.location,l=!1;if(Ut(e)){const t=Tt(a,c);if(null===(n=t.hashQuery)||void 0===n?void 0:n[e]){l=!0,null===(r=t.hashQuery)||void 0===r||delete r[e];const n=ee(t.hashQuery);c=c.slice(0,c.indexOf("?")+Number(Boolean(n)))+n}else if(null===(o=t.searchQuery)||void 0===o?void 0:o[e]){null===(i=t.searchQuery)||void 0===i||delete i[e];const n=ee(t.searchQuery);a=n?"?"+n:""}}return{fullPath:s+a+c,isAttach2Hash:l}}(e),function(e,t){return Ut(e)?(A(null==t?void 0:t.microAppState)&&(p(t.microAppState[e])||delete t.microAppState[e],Object.keys(t.microAppState).length||delete t.microAppState),i({},t)):t}(e,qn.rawWindow.history.state))}class wn{constructor(){this.rawWindowScopeKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue","onpopstate","onhashchange"],this.scopeProperties=Array.from(this.staticScopeProperties),this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.injectReactHMRProperty()}injectReactHMRProperty(){}}class yn{}function gn(e,t){const n=Array.from(e.children);n.length&&n.forEach((e=>{gn(e,t)}));for(const e of n)bn(e,t)}function bn(e,t){var n,r;const o=null===(r=null===(n=Dn.get(t))||void 0===n?void 0:n.sandBox)||void 0===r?void 0:r.proxyWindow;return E(e)&&!e.__MICRO_APP_NAME__&&!e.__PURE_ELEMENT__&&o&&a(e,{baseURI:{configurable:!0,get:()=>o.location.href},__MICRO_APP_NAME__:{configurable:!0,writable:!0,value:t}}),e}function vn(e,t){const n=p(t)?qn.rawWindow.fetch:t;return _(n)?function(t,r,...o){return(d(t)||b(t))&&(t=I(t,e).toString()),q(),n.call(qn.rawWindow,t,r,...o)}:n}function En(e,t){const n=p(t)?qn.rawWindow.XMLHttpRequest:t;return g(n)?class extends n{open(t,n,...r){(d(n)&&!/^f(ile|tp):\/\//.test(n)||b(n))&&(n=I(n,e).toString()),q(),super.open(t,n,...r)}}:n}const{createMicroEventSource:Pn,clearMicroEventSource:Rn}=function(){let e;return{createMicroEventSource:function(t,n,r){const o=p(r)?qn.rawWindow.EventSource:r;return g(o)?class extends o{constructor(r,o,...i){if((d(r)||b(r))&&(r=I(r,n).toString()),q(),super(r,o,...i),e){const n=e.get(t);n?n.add(this):e.set(t,new Set([this]))}else e=new Map([[t,new Set([this])]])}close(){var n;super.close(),null===(n=e.get(t))||void 0===n||n.delete(this)}}:o},clearMicroEventSource:function(t){const n=null==e?void 0:e.get(t);(null==n?void 0:n.size)&&(n.forEach((e=>{e.close()})),n.clear())}}}();class Sn extends wn{constructor(e,t){super(),this.active=!1,this.microAppWindow=new yn,this.patchWith((n=>{this.getSpecialProperties(e),this.patchRouter(e,t,this.microAppWindow),this.windowEffect=Et(e,this.microAppWindow,this),this.documentEffect=vt(e,this.microAppWindow,this),this.setMappingPropertiesWithRawDescriptor(this.microAppWindow),this.initStaticGlobalKeys(e,t,this.microAppWindow),n()}))}start({umdMode:e,baseroute:t,defaultPage:n,disablePatchRequest:r}){this.active||(this.active=!0,this.initRouteState(n),this.removeHistoryListener=$t(this.microAppWindow.__MICRO_APP_NAME__),Ht(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=t),e||this.initGlobalKeysWhenStart(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow,r),1==++qn.activeSandbox&&(Fn(),Vt()),1==++Sn.activeCount&&window.__MICRO_APP_ENVIRONMENT__&&(yt(),window.addEventListener("unmount",wt,!1)),qn.rawWindow._babelPolyfill&&(qn.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:r}){var o;this.active&&(this.recordAndReleaseEffect({umdMode:e,clearData:r,destroy:n},!e||n),this.clearRouteState(t),null===(o=this.removeHistoryListener)||void 0===o||o.call(this),e&&!n||(Rn(this.microAppWindow.__MICRO_APP_NAME__),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(qn.rawWindow,e)})),this.escapeKeys.clear()),0==--qn.activeSandbox&&(jn(),Yt()),--Sn.activeCount,this.active=!1)}initStaticGlobalKeys(e,t,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=t,n.__MICRO_APP_PUBLIC_PATH__=W(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="with",n.rawWindow=qn.rawWindow,n.rawDocument=qn.rawDocument,n.microApp=i(new dt(e),{removeDomScope:q,pureCreateElement:Q,router:Jt})}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),_t(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),mt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),ft(this.microAppWindow.microApp)}releaseGlobalEffect({umdMode:e=!1,clearData:t=!1,isPrerender:n=!1,keepAlive:r=!1,destroy:o=!1}){var i,s,a;this.windowEffect.release(!e&&!r&&!n||o),this.documentEffect.release(),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearDataListener(),null===(s=this.microAppWindow.microApp)||void 0===s||s.clearGlobalDataListener(),t&&(or.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(a=this.microAppWindow.microApp)||void 0===a||a.clearData())}getSpecialProperties(e){var t;A(or.options.plugins)&&(this.commonActionForSpecialProperties(or.options.plugins.global),this.commonActionForSpecialProperties(null===(t=or.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(o(e))for(const t of e)A(t)&&(o(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),o(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchWith(e){this.sandboxReady=new Promise((t=>e(t)))}setMappingPropertiesWithRawDescriptor(e){let t,n;const r=qn.rawWindow;r===r.parent?t=n=this.proxyWindow:(t=r.top,n=r.parent),a(e,{top:this.createDescriptorForMicroAppWindow("top",t),parent:this.createDescriptorForMicroAppWindow("parent",n)}),$e.forEach((t=>{s(e,t,this.createDescriptorForMicroAppWindow(t,this.proxyWindow))}))}createDescriptorForMicroAppWindow(e,t){const{configurable:n=!0,enumerable:r=!0,writable:o,set:i}=Object.getOwnPropertyDescriptor(qn.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:r,writable:null!=o?o:!!i}}initGlobalKeysWhenStart(e,t,n,r){n.hasOwnProperty=e=>l.call(n,e)||l.call(qn.rawWindow,e),this.setHijackProperty(e,n),r||this.patchRequestApi(e,t,n),this.setScopeProperties(n)}setHijackProperty(e,t){let n,r;a(t,{eval:{configurable:!0,enumerable:!1,get:()=>(G(e),n||qn.rawWindow.eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>(G(e),r||qn.ImageProxy),set:e=>{r=e}}})}patchRequestApi(e,t,n){let r=vn(t),o=En(t),i=Pn(e,t);a(n,{fetch:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=vn(t,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=En(t,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>i,set(n){i=Pn(e,t,n)}}})}setScopeProperties(e){this.scopeProperties.forEach((t=>{Reflect.set(e,t,e[t])}))}patchRouter(e,t,n){const{microLocation:r,microHistory:o}=function(e,t){const n=pn(e,t);return{microLocation:n,microHistory:qt(e,n)}}(e,t);a(n,{location:{configurable:!1,enumerable:!0,get:()=>r,set:e=>{qn.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>o}})}initRouteState(e){mn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){_n(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){fn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){An(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){gn(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}function Mn(e,t,n){return function(e,t){const n=qn.rawWindow;tn.forEach((e=>{t[e]=bt(n[e],n)})),Object.getOwnPropertyNames(t).filter((e=>(nn.some((r=>{if(r.test(e)&&e in t.parent){if(_(n[e]))t[e]=bt(n[e],n);else{const{configurable:r,enumerable:o}=Object.getOwnPropertyDescriptor(t,e)||{configurable:!0,enumerable:!0};r&&s(t,e,{configurable:r,enumerable:o,get:()=>n[e],set:t=>{n[e]=t}})}return!0}return!1})),/^on/.test(e)&&!ke.includes(e)))).forEach((r=>{const{enumerable:o,writable:i,set:a}=Object.getOwnPropertyDescriptor(t,r)||{enumerable:!0,writable:!0};try{s(t,r,{enumerable:o,configurable:!0,get:()=>n[r],set:(null!=i?i:a)?e=>{n[r]=_(e)?e.bind(t):e}:void 0})}catch(t){O(t,e)}}))}(e,t),function(e,t){const n=qn.rawWindow,r=new Set,o=new Proxy(e,{get:(e,i)=>"location"===i?t.proxyLocation:C($e,i)?o:r.has(i)?Reflect.get(e,i):C(t.escapeProperties,i)&&!Reflect.has(e,i)?bt(Reflect.get(n,i),n):bt(Reflect.get(e,i),e),set:(e,o,i)=>"location"===o?Reflect.set(n,o,i):(Reflect.has(e,o)||r.add(o),Reflect.set(e,o,i),C(t.escapeProperties,o)&&(!Reflect.has(n,o)&&t.escapeKeys.add(o),Reflect.set(n,o,i)),!0),has:(e,t)=>t in e,deleteProperty:(e,r)=>!Reflect.has(e,r)||(t.escapeKeys.has(r)&&Reflect.deleteProperty(n,r),Reflect.deleteProperty(e,r))});t.proxyWindow=o}(t,n),function(e){const{rawWindow:t,rawAddEventListener:n,rawRemoveEventListener:r}=qn,o=new Map,i=new Map;function s(n){return Be.includes(n)?e:t}e.addEventListener=function(e,t,r){const i=o.get(e);i?i.add(t):o.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=r),n.call(s(e),e,t,r)},e.removeEventListener=function(e,t,n){const i=o.get(e);(null==i?void 0:i.size)&&i.has(t)&&i.delete(t),r.call(s(e),e,t,n)};const a=()=>{i.clear()},c=()=>{i.forEach(((t,n)=>{for(const r of t)e.addEventListener(n,r,null==r?void 0:r.__MICRO_APP_MARK_OPTIONS__)})),a()};return{reset:a,record:()=>{o.forEach(((e,t)=>{if(e.size){const n=i.get(t)||[];i.set(t,new Set([...n,...e]))}}))},rebuild:c,release:()=>{o.size&&(o.forEach(((e,t)=>{for(const n of e)r.call(s(t),t,n)})),o.clear())}}}(t)}function Cn(e,t,n){return function(e,t){const n=qn.rawDocument,r=t.Document,o=t.document,i=r.prototype.createElement,s=r.prototype.createElementNS,a=r.prototype.createTextNode,c=r.prototype.createDocumentFragment,l=r.prototype.createComment,u=r.prototype.querySelector,p=r.prototype.querySelectorAll,h=r.prototype.getElementById,d=r.prototype.getElementsByClassName,m=r.prototype.getElementsByTagName,f=r.prototype.getElementsByName,_=r.prototype.elementFromPoint,A=r.prototype.caretRangeFromPoint;function w(e){return o!==e?e:n}function y(t){var n,r;if(!t||z(t)||o!==this){const e=w(this);return u.call(e,t)}return null!==(r=null===(n=Dn.get(e))||void 0===n?void 0:n.querySelector(t))&&void 0!==r?r:null}function g(t){var n,r;if(!t||z(t)||o!==this){const e=w(this);return p.call(e,t)}return null!==(r=null===(n=Dn.get(e))||void 0===n?void 0:n.querySelectorAll(t))&&void 0!==r?r:[]}r.prototype.caretRangeFromPoint=function(t,r){const o=_.call(n,t,r),i=A.call(n,t,r);return bn(o,e),i},r.prototype.createElement=function(t,n){return bn(i.call(this,t,n),e)},r.prototype.createElementNS=function(t,n,r){return bn(s.call(this,t,n,r),e)},r.prototype.createTextNode=function(t){return bn(a.call(this,t),e)},r.prototype.createDocumentFragment=function(){return bn(c.call(this),e)},r.prototype.createComment=function(t){return bn(l.call(this,t),e)},r.prototype.querySelector=y,r.prototype.querySelectorAll=g,r.prototype.getElementById=function(e){const t=w(this);if(X(e))return h.call(t,e);try{return y.call(this,`#${e}`)}catch(n){return h.call(t,e)}},r.prototype.getElementsByClassName=function(e){const t=w(this);if(X(e))return d.call(t,e);try{return g.call(this,`.${e}`)}catch(n){return d.call(t,e)}},r.prototype.getElementsByTagName=function(e){const t=w(this);if(z(e)||X(e))return m.call(t,e);if(/^script|base$/i.test(e))return m.call(o,e);try{return g.call(this,e)}catch(n){return m.call(t,e)}},r.prototype.getElementsByName=function(e){const t=w(this);if(X(e))return f.call(t,e);try{return g.call(this,`[name=${e}]`)}catch(n){return f.call(t,e)}}}(e,t),function(e,t,n){const r=qn.rawDocument,o=t.Document,i=t.document,c=(e,t)=>{const{enumerable:n}=Object.getOwnPropertyDescriptor(o.prototype,e)||{enumerable:!0};return{configurable:!0,enumerable:n,get:t}},l=()=>{const t={};return[["documentURI",()=>n.proxyLocation.href],["URL",()=>n.proxyLocation.href],["documentElement",()=>r.documentElement],["scrollingElement",()=>r.scrollingElement],["forms",()=>o.prototype.querySelectorAll.call(i,"form")],["images",()=>o.prototype.querySelectorAll.call(i,"img")],["links",()=>o.prototype.querySelectorAll.call(i,"a")],["microAppElement",()=>{var t;return null===(t=Dn.get(e))||void 0===t?void 0:t.container}],["__MICRO_APP_NAME__",()=>e]].forEach((e=>{t[e[0]]=c(e[0],e[1])})),sn.forEach((e=>{t[e]=c(e,(()=>r[e]))})),an.forEach((e=>{t[e]=c(e,(()=>bt(r[e],r,"DOCUMENT")))})),cn.forEach((e=>{t[e]=c(e,(()=>r[e]))})),ln.forEach((e=>{t[e]=c(e,(()=>bt(r[e],r,"DOCUMENT")))})),t};a(o.prototype,l()),rn.forEach((t=>{s(i,t,{enumerable:!0,configurable:!0,get:()=>(G(e),r[t]),set:e=>{r[t]=e}})}))}(e,t,n),function(e,t){const{rawDocument:n,rawAddEventListener:r,rawRemoveEventListener:o}=qn,i=new Map,a=new Map;let c=null,l=null;const u=t.Document,p=t.document;function h(e,t){return He.includes(e)?t:n}function d(e){return"onclick"===e?e=>{_(c)&&o.call(n,"click",c,!1),_(e)?(c=e.bind(p),r.call(n,"click",c,!1)):c=e}:t=>{n[e]=_(t)?t.bind(p):t}}u.prototype.addEventListener=function(e,t,n){const o=_(t)?t.__MICRO_APP_BOUND_FUNCTION__=t.__MICRO_APP_BOUND_FUNCTION__||t.bind(this):t,s=i.get(e);s?s.add(t):i.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=n),r.call(h(e,this),e,o,n)},u.prototype.removeEventListener=function(e,t,n){const r=i.get(e);(null==r?void 0:r.size)&&r.has(t)&&r.delete(t);const s=(null==t?void 0:t.__MICRO_APP_BOUND_FUNCTION__)||t;o.call(h(e,this),e,s,n)},Object.getOwnPropertyNames(u.prototype).filter((e=>/^on/.test(e)&&!Fe.includes(e))).forEach((t=>{const{enumerable:r,writable:o,set:i}=Object.getOwnPropertyDescriptor(u.prototype,t)||{enumerable:!0,writable:!0};try{s(u.prototype,t,{enumerable:r,configurable:!0,get:()=>"onclick"===t?c:n[t],set:(null!=o?o:i)?d(t):void 0})}catch(t){O(t,e)}}));const m=()=>{a.clear(),l=null},f=()=>{l&&!c&&(p.onclick=l),a.forEach(((e,t)=>{for(const n of e)p.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),m()};return{reset:m,record:()=>{l=c||l,i.forEach(((e,t)=>{if(e.size){const n=a.get(t)||[];a.set(t,new Set([...n,...e]))}}))},rebuild:f,release:()=>{_(c)&&o.call(n,"click",c),c=null,i.size&&(i.forEach(((e,t)=>{for(const n of e)o.call(h(t,p),t,(null==n?void 0:n.__MICRO_APP_BOUND_FUNCTION__)||n)})),i.clear())}}}(e,t)}function Nn(e,t,n,r){!function(e,t,n){const r=qn.rawRootElement,o=qn.rawDocument,i=t.document,a=t.Node,c=t.Element,l=a.prototype.appendChild,p=a.prototype.insertBefore,h=a.prototype.replaceChild,d=a.prototype.removeChild,m=c.prototype.append,f=c.prototype.prepend,_=c.prototype.insertAdjacentElement,A=a.prototype.cloneNode,w=Object.getOwnPropertyDescriptor(c.prototype,"innerHTML"),y=Object.getOwnPropertyDescriptor(a.prototype,"parentNode"),g=Object.getOwnPropertyDescriptor(a.prototype,"ownerDocument"),b=e=>(S(e)||function(e){return"[object HTMLBaseElement]"===u(e)}(e))&&e.__PURE_ELEMENT__,P=e=>e===n.microHead?o.head:e===n.microBody?o.body:e;a.prototype.getRootNode=function(){return i},a.prototype.appendChild=function(t){return bn(t,e),b(t)?l.call(this,t):r.prototype.appendChild.call(P(this),t)},a.prototype.insertBefore=function(t,n){return bn(t,e),b(t)?p.call(this,t,n):r.prototype.insertBefore.call(P(this),t,n)},a.prototype.replaceChild=function(t,n){return bn(t,e),b(t)?h.call(this,t,n):r.prototype.replaceChild.call(P(this),t,n)},a.prototype.removeChild=function(e){return b(e)||this.contains(e)?d.call(this,e):r.prototype.removeChild.call(P(this),e)},c.prototype.append=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=E(e[t])?e[t]:i.createTextNode(e[t]),b(e[t])&&(n=!0),t++;return n?m.call(this,...e):r.prototype.append.call(P(this),...e)},c.prototype.prepend=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=E(e[t])?e[t]:i.createTextNode(e[t]),b(e[t])&&(n=!0),t++;return n?f.call(this,...e):r.prototype.prepend.call(P(this),...e)},c.prototype.insertAdjacentElement=function(t,n){return bn(n,e),b(n)?_.call(this,t,n):r.prototype.insertAdjacentElement.call(P(this),t,n)},a.prototype.cloneNode=function(t){return bn(A.call(this,t),e)},s(a.prototype,"ownerDocument",{configurable:!0,enumerable:!0,get(){return this.__PURE_ELEMENT__?g.get.call(this):i}}),s(c.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return w.get.call(this)},set(t){w.set.call(this,t),Array.from(this.children).forEach((t=>{v(t)&&bn(t,e)}))}}),s(a.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var t,n,r;G(e);const o=y.get.call(this);return M(o)&&(null===(t=Dn.get(e))||void 0===t?void 0:t.container)?(null===(r=(n=or.options).getRootElementParentNode)||void 0===r?void 0:r.call(n,this,e))||qn.rawDocument.body:o}});const R=new Proxy(t.Image,{construct(t,n){const r=new t(...n);return bn(r,e),r}});s(t,"Image",{configurable:!0,writable:!0,value:R})}(e,n,r),function(e,t){const n=t.Element,r=n.prototype.setAttribute;n.prototype.setAttribute=function(t,n){(("src"===t||"srcset"===t)&&/^(img|script)$/i.test(this.tagName)||"href"===t&&/^link$/i.test(this.tagName))&&(n=U(n,e)),r.call(this,t,n)};const o=[[t.HTMLImageElement.prototype,"src"],[t.HTMLScriptElement.prototype,"src"],[t.HTMLLinkElement.prototype,"href"]];o.forEach((([t,n])=>{const{enumerable:r,configurable:o,get:i,set:a}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,configurable:!0};s(t,n,{enumerable:r,configurable:o,get:function(){return null==i?void 0:i.call(this)},set:function(t){null==a||a.call(this,U(t,e))}})}))}(t,n)}Sn.activeCount=0;class On{constructor(e,t){this.active=!1,this.escapeProperties=[],this.escapeKeys=new Set,this.updateIframeBase=()=>{var e;null===(e=this.baseElement)||void 0===e||e.setAttribute("href",I(this.url).origin+this.proxyLocation.pathname)},this.appName=e,this.url=t;const n=qn.rawWindow.location,r=n.protocol+"//"+n.host;this.deleteIframeElement=this.createIframeElement(e,r+n.pathname),this.microAppWindow=this.iframe.contentWindow,this.patchIframe(this.microAppWindow,(n=>{this.createIframeTemplate(this.microAppWindow),this.getSpecialProperties(e),this.proxyLocation=function(e,t,n,r){const o=I(t),s=o.protocol+"//"+o.host,a=o.pathname+o.search+o.hash,c=n.history;return n.rawReplaceState=c.replaceState,i(c,qt(e,n.location)),dn(e,a,n.location,"prevent"),pn(e,t,n,o,r,s)}(e,t,this.microAppWindow,r),this.windowEffect=Mn(e,this.microAppWindow,this),this.documentEffect=Cn(e,this.microAppWindow,this),Nn(e,t,this.microAppWindow,this),this.initStaticGlobalKeys(e,t,this.microAppWindow),n()}))}createIframeElement(e,t){this.iframe=Q("iframe");const n={src:or.options.iframeSrc||t,style:"display: none",id:e};return Object.keys(n).forEach((e=>this.iframe.setAttribute(e,n[e]))),qn.rawDocument.body.appendChild(this.iframe),()=>D((()=>{var e,t;null===(t=null===(e=this.iframe)||void 0===e?void 0:e.parentNode)||void 0===t||t.removeChild(this.iframe),this.iframe=null}))}start({baseroute:e,defaultPage:t,disablePatchRequest:n}){this.active||(this.active=!0,this.initRouteState(t),this.removeHistoryListener=$t(this.microAppWindow.__MICRO_APP_NAME__),Ht(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e),n||this.createIframeBase(),1==++qn.activeSandbox&&(Fn(),Vt()),++On.activeCount)}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:r}){var o;this.active&&(this.recordAndReleaseEffect({clearData:r},!e||n),this.clearRouteState(t),null===(o=this.removeHistoryListener)||void 0===o||o.call(this),e&&!n||(this.deleteIframeElement(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(qn.rawWindow,e)})),this.escapeKeys.clear()),0==--qn.activeSandbox&&(jn(),Yt()),--On.activeCount,this.active=!1)}initStaticGlobalKeys(e,t,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=t,n.__MICRO_APP_PUBLIC_PATH__=W(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="iframe",n.rawWindow=qn.rawWindow,n.rawDocument=qn.rawDocument,n.microApp=i(new dt(e),{removeDomScope:q,pureCreateElement:Q,location:this.proxyLocation,router:Jt})}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.reset(),null===(t=this.documentEffect)||void 0===t||t.reset(),_t(this.microAppWindow.microApp)}recordEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.record(),null===(t=this.documentEffect)||void 0===t||t.record(),mt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.rebuild(),null===(t=this.documentEffect)||void 0===t||t.rebuild(),ft(this.microAppWindow.microApp)}releaseGlobalEffect({clearData:e=!1}){var t,n,r,o,i;null===(t=this.windowEffect)||void 0===t||t.release(),null===(n=this.documentEffect)||void 0===n||n.release(),null===(r=this.microAppWindow.microApp)||void 0===r||r.clearDataListener(),null===(o=this.microAppWindow.microApp)||void 0===o||o.clearGlobalDataListener(),e&&(or.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearData())}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchIframe(e,t){const n=e.document;this.sandboxReady=new Promise((r=>{!function o(){setTimeout((()=>{try{e.document===n?o():(e.stop(),t(r))}catch(e){o()}}),0)}()}))}createIframeTemplate(e){const t=e.document;!function(e){for(;null==e?void 0:e.firstChild;)e.removeChild(e.firstChild)}(t);const n=t.createElement("html");n.innerHTML="<head></head><body></body>",t.appendChild(n),this.microBody=t.body,this.microHead=t.head}createIframeBase(){this.baseElement=Q("base"),this.updateIframeBase(),this.microHead.appendChild(this.baseElement)}getSpecialProperties(e){var t;A(or.options.plugins)&&(this.commonActionForSpecialProperties(or.options.plugins.global),this.commonActionForSpecialProperties(null===(t=or.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(o(e))for(const t of e)A(t)&&o(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties))}initRouteState(e){mn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){_n(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){fn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){An(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){gn(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}On.activeCount=0;const Dn=new Map;class In{constructor({name:e,url:t,container:n,scopecss:r,useSandbox:o,inline:i,iframe:s,ssrUrl:a,isPrefetch:c,prefetchLevel:l,routerMode:u}){this.state=Ee.CREATED,this.keepAliveState=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.lifeCycleState=null,this.umdMode=!1,this.sandBox=null,this.fiber=!1,Dn.set(e,this),this.name=e,this.url=t,this.useSandbox=o,this.scopecss=this.useSandbox&&r,this.iframe=null!=s&&s,this.inline=this.getInlineModeState(i),this.routerMode=u||xe,this.container=null!=n?n:null,this.ssrUrl=null!=a?a:"",this.isPrefetch=null!=c&&c,this.isPrerender=3===l,this.prefetchLevel=l,this.source={html:null,links:new Set,scripts:new Set},this.loadSourceCode(),this.createSandbox()}loadSourceCode(){this.setAppState(Ee.LOADING),ue.getInstance().run(this,ct)}onLoad({html:e,defaultPage:t,routerMode:n,baseroute:r,disablePatchRequest:o}){var i;if(2==++this.loadSourceLevel)if(this.source.html=e,this.isPrefetch||this.isUnmounted()){if(this.isPrerender){const e=Q("div");e.setAttribute("prerender","true"),null===(i=this.sandBox)||void 0===i||i.setPreRenderState(!0),this.mount({container:e,inline:this.inline,fiber:!0,defaultPage:t||"",disablePatchRequest:null!=o&&o,routerMode:n,baseroute:r||""})}}else V(this.container).mount(this)}onLoadError(e){this.loadSourceLevel=-1,this.isUnmounted()||(this.onerror(e),this.setAppState(Ee.LOAD_FAILED))}mount({container:e,inline:t,routerMode:n,defaultPage:r,baseroute:o,disablePatchRequest:i,fiber:s}){if(2!==this.loadSourceLevel)return this.container=e,this.isPrerender=!1,ce(this,"statechange",{appState:Ee.LOADING}),this.setAppState(Ee.LOADING);this.createSandbox(),this.setAppState(Ee.BEFORE_MOUNT);const a=()=>{var a,c,l,h,m,f,A,w;if(this.isPrerender&&(w=this.container,"[object HTMLDivElement]"===u(w))&&this.container.hasAttribute("prerender"))null===(a=this.sandBox)||void 0===a||a.rebuildEffectSnapshot(),this.cloneContainer(e,this.container,!1),this.container=e,null===(c=this.preRenderEvents)||void 0===c||c.forEach((e=>e())),this.isPrerender=!1,this.preRenderEvents=null,Jt.attachToURL(this.name),null===(l=this.sandBox)||void 0===l||l.setPreRenderState(!1);else{this.container=e,this.inline=this.getInlineModeState(t),this.fiber=s,this.routerMode=n;const a=()=>{this.setLifeCycleState(Pe.BEFOREMOUNT),ae(this.container,this.name,Pe.BEFOREMOUNT)};if(this.isPrerender?(null!==(h=this.preRenderEvents)&&void 0!==h?h:this.preRenderEvents=[]).push(a):a(),this.setAppState(Ee.MOUNTING),ce(this,"statechange",{appState:Ee.MOUNTING}),this.cloneContainer(this.container,this.source.html,!this.umdMode),null===(m=this.sandBox)||void 0===m||m.start({umdMode:this.umdMode,baseroute:o,defaultPage:r,disablePatchRequest:i}),this.umdMode){null===(A=this.sandBox)||void 0===A||A.rebuildEffectSnapshot();try{this.handleMounted(this.umdHookMount(or.getData(this.name,!0)))}catch(e){N("An error occurred in window.mount \n",this.name,e)}}else null===(f=this.sandBox)||void 0===f||f.actionBeforeExecScripts(this.container),function(e,t){const n=e.fiber?[]:null,r=Array.from(e.source.scripts),o=[],i=[];for(const s of r){const r=Ce.script.getInfo(s),a=r.appSpace[e.name];a.defer||a.async?(!r.isExternal||r.code||Ge(e,r)?o.push(r.code):o.push(le(s,e.name)),i.push([s,r]),Ge(e,r)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):re(n,(()=>{ot(s,e,r),t(!1)}))}o.length?B(o,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,N(n,e.name)}),(()=>{i.forEach((([r,o])=>{d(o.code)&&re(n,(()=>{ot(r,e,o,t),!Ge(e,o)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(p(t.moduleCount)||t.errorCount===o.length)))),oe(n)):t(p(t.moduleCount)||t.errorCount===o.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),oe(n)):t(!0)}(this,(e=>{if(!this.umdMode){const{mount:t,unmount:n}=this.getUmdLibraryHooks();if(this.umdHookUnmount=n,_(t)&&_(n)){this.umdHookMount=t,this.sandBox.markUmdMode(this.umdMode=!0);try{this.handleMounted(this.umdHookMount(or.getData(this.name,!0)))}catch(e){N("An error occurred in window.mount \n",this.name,e)}}else!0===e&&this.handleMounted()}}))}};this.sandBox?this.sandBox.sandboxReady.then(a):a()}handleMounted(e){var t,n;const r=()=>{y(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>{N("An error occurred in window.mount \n",this.name,e),this.dispatchMountedEvent()})):this.dispatchMountedEvent()};this.isPrerender?(null===(t=this.preRenderEvents)||void 0===t||t.push(r),null===(n=this.sandBox)||void 0===n||n.recordAndReleaseEffect({isPrerender:!0})):r()}dispatchMountedEvent(){var e;this.isUnmounted()||(this.setAppState(Ee.MOUNTED),se(this.getMicroAppGlobalHook(Re.ONMOUNT),this.name,Re.ONMOUNT,or.getData(this.name,!0)),ce(this,"statechange",{appState:Ee.MOUNTED}),ce(this,"mounted"),this.setLifeCycleState(Pe.MOUNTED),ae(this.container,this.name,Pe.MOUNTED),this.isHidden()&&(null===(e=this.sandBox)||void 0===e||e.recordAndReleaseEffect({keepAlive:!0})))}unmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:r}){var o;e=e||this.state===Ee.LOAD_FAILED,this.setAppState(Ee.UNMOUNT);let i=null;try{i=null===(o=this.umdHookUnmount)||void 0===o?void 0:o.call(this,or.getData(this.name,!0))}catch(e){N("An error occurred in window.unmount \n",this.name,e)}ce(this,"statechange",{appState:Ee.UNMOUNT}),ce(this,"unmount"),se(this.getMicroAppGlobalHook(Re.ONUNMOUNT),this.name,Re.ONUNMOUNT),this.handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:r,umdHookUnmountResult:i})}handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:r,umdHookUnmountResult:o}){const i=()=>this.actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:r});y(o)?(q(),o.then(i).catch(i)):i()}actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:r}){var o;this.umdMode&&this.container&&!e&&this.cloneContainer(this.source.html,this.container,!1),null===(o=this.sandBox)||void 0===o||o.stop({umdMode:this.umdMode,keepRouteState:n&&!e,destroy:e,clearData:t||e}),this.setLifeCycleState(Pe.UNMOUNT),ae(this.container,this.name,Pe.UNMOUNT),this.clearOptions(e),null==r||r()}clearOptions(e){this.container.innerHTML="",this.container=null,this.isPrerender=!1,this.preRenderEvents=null,this.setKeepAliveState(null),this.iframe&&!this.umdMode&&(this.sandBox=null),e&&this.actionsForCompletelyDestroy(),q()}actionsForCompletelyDestroy(){var e,t;null===(t=null===(e=this.sandBox)||void 0===e?void 0:e.deleteIframeElement)||void 0===t||t.call(e),Ce.script.deleteInlineInfo(this.source.scripts),Dn.delete(this.name)}hiddenKeepAliveApp(e){var t,n;this.setKeepAliveState(Se.KEEP_ALIVE_HIDDEN),ce(this,"appstate-change",{appState:"afterhidden"}),this.setLifeCycleState(Pe.AFTERHIDDEN),ae(this.container,this.name,Pe.AFTERHIDDEN),Ut(this.name)&&(null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp()),2!==this.loadSourceLevel?V(this.container).unmount():(this.container=this.cloneContainer(Q("div"),this.container,!1),null===(n=this.sandBox)||void 0===n||n.recordAndReleaseEffect({keepAlive:!0})),null==e||e()}showKeepAliveApp(e){var t,n;null===(t=this.sandBox)||void 0===t||t.rebuildEffectSnapshot(),ce(this,"appstate-change",{appState:"beforeshow"}),ae(e,this.name,Pe.BEFORESHOW),this.setKeepAliveState(Se.KEEP_ALIVE_SHOW),this.container=this.cloneContainer(e,this.container,!1),Ut(this.name)&&(null===(n=this.sandBox)||void 0===n||n.setRouteInfoForKeepAliveApp()),ce(this,"appstate-change",{appState:"aftershow"}),this.setLifeCycleState(Pe.AFTERSHOW),ae(this.container,this.name,Pe.AFTERSHOW)}onerror(e){this.setLifeCycleState(Pe.ERROR),ce(this,"statechange",{appState:Ee.LOAD_FAILED}),ae(this.container,this.name,Pe.ERROR,e)}parseHtmlString(e){var t;return(new((null===(t=this.sandBox)||void 0===t?void 0:t.proxyWindow)?this.sandBox.proxyWindow.DOMParser:qn.rawWindow.DOMParser)).parseFromString(e,"text/html").body}cloneContainer(e,t,n){return t&&(e.innerHTML="",Array.from(n?this.parseHtmlString(t.innerHTML).childNodes:t.childNodes).forEach((t=>{e.appendChild(t)}))),e}createSandbox(){this.useSandbox&&!this.sandBox&&(this.sandBox=this.iframe?new On(this.name,this.url):new Sn(this.name,this.url))}setAppState(e){var t;this.state=e,null===(t=this.sandBox)||void 0===t||t.setStaticAppState(e)}getAppState(){return this.state}setLifeCycleState(e){this.lifeCycleState=e}getLifeCycleState(){return this.lifeCycleState||""}setKeepAliveState(e){this.keepAliveState=e}getKeepAliveState(){return this.keepAliveState}isUnmounted(){return Ee.UNMOUNT===this.state}isHidden(){return Se.KEEP_ALIVE_HIDDEN===this.keepAliveState}getUmdLibraryHooks(){if(!this.isUnmounted()&&this.sandBox){const e=V(this.container).getAttribute("library")||`micro-app-${this.name}`,t=this.sandBox.proxyWindow;return w(t[e])?t[e]:{mount:t.mount,unmount:t.unmount}}return{}}getMicroAppGlobalHook(e){var t,n;const r=null===(n=null===(t=this.sandBox)||void 0===t?void 0:t.proxyWindow)||void 0===n?void 0:n[e];return _(r)?r:null}querySelector(e){return this.container?qn.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?qn.rawElementQuerySelectorAll.call(this.container,e):[]}getInlineModeState(e){var t;return null!==(t=this.iframe||e)&&void 0!==t&&t}}function xn(e){var t,n;return null!==(n=null===(t=Dn.get(e))||void 0===t?void 0:t.iframe)&&void 0!==n&&n}const Ln=new WeakMap;function Tn(e){var t;return null!==(t=Ln.get(e))&&void 0!==t?t:e}function Wn(e,t){if(Ln.has(e))return Ln.get(e);if(R(e)){if(e.hasAttribute("exclude")){const t=document.createComment("style element with exclude attribute ignored by micro-app");return Ln.set(e,t),t}return t.scopecss&&!e.hasAttribute("ignore")?Ae(e,t):e}if(P(e)){if(e.hasAttribute("exclude")||tt(e.getAttribute("href"),t.name)){const t=document.createComment("link element with exclude attribute ignored by micro-app");return Ln.set(e,t),t}if(e.hasAttribute("ignore")||nt(e.getAttribute("href"),t.name)||e.href&&_(or.options.excludeAssetFilter)&&or.options.excludeAssetFilter(e.href))return e;const{address:n,linkInfo:r,replaceComment:o}=Ne(e,null,t,!0);if(n&&r){const o=function(e,t,n,r){const o=Q("style"),i=()=>{De(t,e,o,n,n.appSpace[t.name].attrs),ge(r)};return n.code?D(i):le(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{N(e,t.name),be(r)})),o}(n,t,r,e);return Ln.set(e,o),o}return o?(Ln.set(e,o),o):e}if(S(e)){if(e.src&&_(or.options.excludeAssetFilter)&&or.options.excludeAssetFilter(e.src))return e;const{replaceComment:n,address:r,scriptInfo:o}=Ze(e,null,t,!0)||{};if(r&&o){const n=o.isExternal?function(e,t,n,r){const o=Qe(t,n)?Q("script"):document.createComment("dynamic script extract by micro-app"),i=()=>ge(r),s=()=>{const s=Object.getOwnPropertyDescriptor(qn.rawDocument,"currentScript");s&&!s.configurable||Object.defineProperty(qn.rawDocument,"currentScript",{value:r,configurable:!0}),ot(e,t,n,i,o),!Ge(t,n)&&i()};return n.code||Ge(t,n)?D(s):le(e,t.name).then((e=>{n.code=e,s()})).catch((e=>{N(e,t.name),be(r)})),o}(r,t,o,e):function(e,t,n){const r=Qe(t,n)?Q("script"):document.createComment("dynamic script extract by micro-app");return ot(e,t,n,void 0,r),r}(r,t,o);return Ln.set(e,n),n}return n?(Ln.set(e,n),n):e}return e}function Un(e,t,n,r,o){const i=Bn(n,r,e);if(i){if(!xn(e.name)&&M(i)&&t!==qn.rawRemoveChild){const t=Object.getOwnPropertyDescriptor(r,"parentNode");t&&!t.configurable||r.__MICRO_APP_HAS_DPN__||a(r,{parentNode:{configurable:!0,get(){var t,n;const r=qn.rawParentNodeDesc.get.call(this);return M(r)&&e.container?(null===(n=(t=or.options).getRootElementParentNode)||void 0===n?void 0:n.call(t,this,e.name))||document.body:r}},__MICRO_APP_HAS_DPN__:{configurable:!0,get:()=>!0}})}if(o&&!i.contains(o)){if(t===qn.rawInsertBefore&&n.contains(o)){const e=Array.from(n.childNodes).indexOf(o);if(i.childNodes[e])return kn(t,i,r,i.childNodes[e])}return qn.rawAppendChild.call(i,r)}return t!==qn.rawRemoveChild||i.contains(r)?kn(t,i,r,o):n.contains(r)?t.call(n,r):r}return kn(t,n,r,o)}function Bn(e,t,n){if(n){if(e===document.head)return n.iframe&&S(t)?n.sandBox.microHead:n.querySelector("micro-app-head");if(e===document.body||e===document.body.parentNode)return n.iframe&&S(t)?n.sandBox.microBody:n.querySelector("micro-app-body");if(n.iframe&&S(t))return n.sandBox.microBody}return null}function kn(e,t,n,r){return(o=e)===qn.rawAppend||o===qn.rawPrepend?e.call(t,n):e.call(t,n,r);var o}function Hn(e,t,n,r){const o=j();if(E(t)&&!t.__PURE_ELEMENT__&&(t.__MICRO_APP_NAME__||o)){t.__MICRO_APP_NAME__=t.__MICRO_APP_NAME__||o;const i=Dn.get(t.__MICRO_APP_NAME__);if(R(t)){e.getRootNode()instanceof ShadowRoot&&t.setAttribute("ignore","true")}if(null==i?void 0:i.container)return function(e,t){v(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&qn.rawSetAttribute.call(t,"src",U(t.getAttribute("src"),e.url)),t.hasAttribute("srcset")&&qn.rawSetAttribute.call(t,"srcset",U(t.getAttribute("srcset"),e.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&qn.rawSetAttribute.call(t,"href",U(t.getAttribute("href"),e.url)))}(i,t),Un(i,r,e,Wn(t,i),n&&Tn(n))}return r===qn.rawAppend||r===qn.rawPrepend?r.call(e,t):r.call(e,t,n)}function Fn(){!function(){const e=qn.rawDocument,t=qn.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===u(e)}(t)?e:t}function r(t){var r,o;const i=n(this),s=j();return s&&t&&!z(t)&&e===i?null!==(o=null===(r=Dn.get(s))||void 0===r?void 0:r.querySelector(t))&&void 0!==o?o:null:qn.rawQuerySelector.call(i,t)}function o(t){var r,o;const i=n(this),s=j();return s&&t&&!z(t)&&e===i?null!==(o=null===(r=Dn.get(s))||void 0===r?void 0:r.querySelectorAll(t))&&void 0!==o?o:[]:qn.rawQuerySelectorAll.call(i,t)}t.prototype.createElement=function(e,t){return $n(qn.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,r){return $n(qn.rawCreateElementNS.call(n(this),e,t,r))},t.prototype.createDocumentFragment=function(){return $n(qn.rawCreateDocumentFragment.call(n(this)))},t.prototype.createComment=function(e){return $n(qn.rawCreateComment.call(n(this),e))},t.prototype.querySelector=r,t.prototype.querySelectorAll=o,t.prototype.getElementById=function(e){const t=n(this);if(!j()||X(e))return qn.rawGetElementById.call(t,e);try{return r.call(t,`#${e}`)}catch(n){return qn.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!j()||X(e))return qn.rawGetElementsByClassName.call(t,e);try{return o.call(t,`.${e}`)}catch(n){return qn.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const r=n(this),i=j();if(!i||z(e)||X(e)||!(null===(t=Dn.get(i))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return qn.rawGetElementsByTagName.call(r,e);try{return o.call(r,e)}catch(t){return qn.rawGetElementsByTagName.call(r,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!j()||X(e))return qn.rawGetElementsByName.call(t,e);try{return o.call(t,`[name=${e}]`)}catch(n){return qn.rawGetElementsByName.call(t,e)}}}();const e=qn.rawRootElement,t=qn.rawRootNode;function n(e){const t=j();if((e===document.body||e===document.head)&&t){const n=Dn.get(t);if(null==n?void 0:n.container){if(e===document.body)return n.querySelector("micro-app-body");if(e===document.head)return n.querySelector("micro-app-head")}}return e}e.prototype.appendChild=function(e){return Hn(this,e,null,qn.rawAppendChild)},e.prototype.insertBefore=function(e,t){return Hn(this,e,t,qn.rawInsertBefore)},e.prototype.replaceChild=function(e,t){return Hn(this,e,t,qn.rawReplaceChild)},e.prototype.append=function(...e){let t=0;for(;t<e.length;){let n=e[t];n=E(n)?n:qn.rawCreateTextNode.call(qn.rawDocument,n),Hn(this,$n(n),null,qn.rawAppend),t++}},e.prototype.prepend=function(...e){let t=e.length;for(;t>0;){let n=e[t-1];n=E(n)?n:qn.rawCreateTextNode.call(qn.rawDocument,n),Hn(this,$n(n),null,qn.rawPrepend),t--}},e.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Dn.get(e.__MICRO_APP_NAME__);if(null==t?void 0:t.container)return Un(t,qn.rawRemoveChild,this,Tn(e));try{return qn.rawRemoveChild.call(this,e)}catch(t){return(null==e?void 0:e.parentNode)&&qn.rawRemoveChild.call(e.parentNode,e)}}return qn.rawRemoveChild.call(this,e)},e.prototype.insertAdjacentElement=function(e,t){var n;if((null==t?void 0:t.__MICRO_APP_NAME__)&&v(t)){const r=Dn.get(t.__MICRO_APP_NAME__);if(null==r?void 0:r.container){const o=Wn(t,r);if(!v(o))return t;const i=null!==(n=Bn(this,o,r))&&void 0!==n?n:this;return qn.rawInsertAdjacentElement.call(i,e,o)}}return qn.rawInsertAdjacentElement.call(this,e,t)},e.prototype.cloneNode=function(e){const t=qn.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t},e.prototype.querySelector=function(e){var t;return qn.rawElementQuerySelector.call(null!==(t=n(this))&&void 0!==t?t:this,e)},e.prototype.querySelectorAll=function(e){var t;return qn.rawElementQuerySelectorAll.call(null!==(t=n(this))&&void 0!==t?t:this,e)},e.prototype.setAttribute=function(e,t){const n=this.__MICRO_APP_NAME__||j();if(n&&Dn.has(n)&&(("src"===e||"srcset"===e)&&/^(img|script|video|audio|source|embed)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))){t=U(t,Dn.get(n).url)}qn.rawSetAttribute.call(this,e,t)},s(e.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return qn.rawInnerHTMLDesc.get.call(this)},set(e){qn.rawInnerHTMLDesc.set.call(this,e);const t=j();Array.from(this.children).forEach((e=>{v(e)&&t&&(e.__MICRO_APP_NAME__=t)}))}}),s(t.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var e,t,n;const r=j();if(r&&this===qn.rawDocument.firstElementChild){const o=null===(n=null===(t=null===(e=Dn.get(r))||void 0===e?void 0:e.sandBox)||void 0===t?void 0:t.proxyWindow)||void 0===n?void 0:n.document;if(o)return o}return qn.rawParentNodeDesc.get.call(this)}})}function $n(e){const t=j();return t&&(e.__MICRO_APP_NAME__=t),e}function jn(){q(),function(){const e=qn.rawRootDocument;e.prototype.createElement=qn.rawCreateElement,e.prototype.createElementNS=qn.rawCreateElementNS,e.prototype.createDocumentFragment=qn.rawCreateDocumentFragment,e.prototype.querySelector=qn.rawQuerySelector,e.prototype.querySelectorAll=qn.rawQuerySelectorAll,e.prototype.getElementById=qn.rawGetElementById,e.prototype.getElementsByClassName=qn.rawGetElementsByClassName,e.prototype.getElementsByTagName=qn.rawGetElementsByTagName,e.prototype.getElementsByName=qn.rawGetElementsByName}();const e=qn.rawRootElement,t=qn.rawRootNode;e.prototype.appendChild=qn.rawAppendChild,e.prototype.insertBefore=qn.rawInsertBefore,e.prototype.replaceChild=qn.rawReplaceChild,e.prototype.removeChild=qn.rawRemoveChild,e.prototype.append=qn.rawAppend,e.prototype.prepend=qn.rawPrepend,e.prototype.cloneNode=qn.rawCloneNode,e.prototype.querySelector=qn.rawElementQuerySelector,e.prototype.querySelectorAll=qn.rawElementQuerySelectorAll,e.prototype.setAttribute=qn.rawSetAttribute,s(e.prototype,"innerHTML",qn.rawInnerHTMLDesc),s(t.prototype,"parentNode",qn.rawParentNodeDesc)}let Kn=!1;const qn={activeSandbox:0};function Gn(){if(t){const e=window.rawWindow||Function("return window")(),t=window.rawDocument||Function("return document")(),n=e.Document||Function("return Document")(),r=e.Element,o=e.Node,s=e.EventTarget,a=r.prototype.setAttribute,c=r.prototype.appendChild,l=r.prototype.insertBefore,u=r.prototype.replaceChild,p=r.prototype.removeChild,h=r.prototype.append,d=r.prototype.prepend,m=r.prototype.cloneNode,f=r.prototype.querySelector,_=r.prototype.querySelectorAll,A=r.prototype.insertAdjacentElement,w=Object.getOwnPropertyDescriptor(r.prototype,"innerHTML"),y=Object.getOwnPropertyDescriptor(o.prototype,"parentNode"),g=n.prototype.createElement,b=n.prototype.createElementNS,v=n.prototype.createTextNode,E=n.prototype.createDocumentFragment,P=n.prototype.createComment,R=n.prototype.querySelector,S=n.prototype.querySelectorAll,M=n.prototype.getElementById,C=n.prototype.getElementsByClassName,N=n.prototype.getElementsByTagName,O=n.prototype.getElementsByName,D=new Proxy(Image,{construct(e,t){const n=new e(...t),r=j();return r&&(n.__MICRO_APP_NAME__=r),n}}),I=e.setInterval,x=e.setTimeout,L=e.clearInterval,T=e.clearTimeout,W=e.history.pushState,U=e.history.replaceState,B=s.prototype.addEventListener,k=s.prototype.removeEventListener,H=s.prototype.dispatchEvent;window.__MICRO_APP_BASE_APPLICATION__=!0,i(qn,{supportModuleScript:"noModule"in document.createElement("script"),rawWindow:e,rawDocument:t,rawRootDocument:n,rawRootElement:r,rawRootNode:o,rawSetAttribute:a,rawAppendChild:c,rawInsertBefore:l,rawReplaceChild:u,rawRemoveChild:p,rawAppend:h,rawPrepend:d,rawCloneNode:m,rawElementQuerySelector:f,rawElementQuerySelectorAll:_,rawInsertAdjacentElement:A,rawInnerHTMLDesc:w,rawParentNodeDesc:y,rawCreateElement:g,rawCreateElementNS:b,rawCreateDocumentFragment:E,rawCreateTextNode:v,rawCreateComment:P,rawQuerySelector:R,rawQuerySelectorAll:S,rawGetElementById:M,rawGetElementsByClassName:C,rawGetElementsByTagName:N,rawGetElementsByName:O,ImageProxy:D,rawSetInterval:I,rawSetTimeout:x,rawClearInterval:L,rawClearTimeout:T,rawPushState:W,rawReplaceState:U,rawAddEventListener:B,rawRemoveEventListener:k,rawDispatchEvent:H}),function(){if(!Kn){Kn=!0;const e=Q("style");qn.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${or.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,qn.rawDocument.head.appendChild(e)}}()}}function Qn(t){class n extends(function(){var e;return(null===(e=window.rawWindow)||void 0===e?void 0:e.HTMLElement)||window.HTMLElement}()){constructor(){super(...arguments),this.isWaiting=!1,this.cacheData=null,this.connectedCount=0,this.connectStateMap=new Map,this.appName="",this.appUrl="",this.ssrUrl="",this.version=e,this.handleAttributeUpdate=()=>{this.isWaiting=!1;const e=T(this.getAttribute("name")),t=L(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Dn.get(e);if(e!==this.appName&&n&&!n.isUnmounted()&&!n.isHidden()&&!n.isPrefetch)return this.setAttribute("name",this.appName),N(`app name conflict, an app named ${e} is running`);e===this.appName&&t===this.appUrl||(e===this.appName?this.unmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.unmount(!1,(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)}}static get observedAttributes(){return["name","url"]}connectedCallback(){const e=++this.connectedCount;this.connectStateMap.set(e,!0);const t=this.appName&&this.appUrl;D((()=>{this.connectStateMap.get(e)&&(ae(this,this.appName,Pe.CREATED),t&&this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(Pe.MOUNTED,n),this.removeEventListener(Pe.AFTERSHOW,n),t(!0)};this.addEventListener(Pe.MOUNTED,n),this.addEventListener(Pe.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=Dn.get(this.appName);!n||n.isUnmounted()||n.isHidden()||(this.getKeepAliveModeResult()&&!e?this.handleHiddenKeepAliveApp(t):this.unmount(e,t))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===ve.NAME?"appName":"appUrl"]!==n)if(e!==ve.URL||this.appUrl&&this.connectStateMap.get(this.connectedCount))if(e!==ve.NAME||this.appName&&this.connectStateMap.get(this.connectedCount))this.isWaiting||(this.isWaiting=!0,D(this.handleAttributeUpdate));else{const e=T(n);if(!e)return N(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(or.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=L(n,this.appName)))return N(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.handleConnected()}handleConnected(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&_(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),Dn.has(this.appName)){const e=Dn.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.isHidden()&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t===n&&(e.isUnmounted()||e.isPrefetch&&this.sameCoreOptions(e))?this.handleMount(e):e.isPrefetch||e.isUnmounted()?this.handleCreateApp():N(`app name conflict, an app named: ${this.appName} with url: ${t} is running`)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var r;this.updateSsrUrl(t),this.appName=e,this.appUrl=t,(null!==(r=this.shadowRoot)&&void 0!==r?r:this).innerHTML="",e!==this.getAttribute("name")&&this.setAttribute("name",this.appName),n?n.isHidden()?n.url===this.appUrl?this.handleShowKeepAliveApp(n):N(`app name conflict, an app named ${this.appName} is running`):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!d(t)||!t)||(N(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleCreateApp(){const e=()=>{var e;return new In({name:this.appName,url:this.appUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,scopecss:this.useScopecss(),useSandbox:this.useSandbox(),inline:this.getDisposeResult("inline"),iframe:this.getDisposeResult("iframe"),ssrUrl:this.ssrUrl,routerMode:this.getMemoryRouterMode()})},t=Dn.get(this.appName);t?t.isPrerender?this.unmount(!0,e):(t.actionsForCompletelyDestroy(),e()):e()}handleMount(e){e.isPrefetch=!1,e.setAppState(Ee.BEFORE_MOUNT),D((()=>this.mount(e)))}mount(e){var t;e.mount({container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,inline:this.getDisposeResult("inline"),routerMode:this.getMemoryRouterMode(),baseroute:this.getBaseRouteCompatible(),defaultPage:this.getDefaultPage(),disablePatchRequest:this.getDisposeResult("disable-patch-request"),fiber:this.getDisposeResult("fiber")})}unmount(e,t){const n=Dn.get(this.appName);n&&!n.isUnmounted()&&n.unmount({destroy:e||this.getDestroyCompatibleResult(),clearData:this.getDisposeResult("clear-data"),keepRouteState:this.getDisposeResult("keep-router-state"),unmountcb:t})}handleHiddenKeepAliveApp(e){const t=Dn.get(this.appName);!t||t.isUnmounted()||t.isHidden()||t.hiddenKeepAliveApp(e)}handleShowKeepAliveApp(e){D((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleProperties(e)||!!or.options[e])&&this.compatibleDisableProperties(e)}compatibleProperties(e){return"disable-scopecss"===e?this.hasAttribute("disable-scopecss")||this.hasAttribute("disableScopecss"):"disable-sandbox"===e?this.hasAttribute("disable-sandbox")||this.hasAttribute("disableSandbox"):this.hasAttribute(e)}compatibleDisableProperties(e){return"disable-scopecss"===e?"false"!==this.getAttribute("disable-scopecss")&&"false"!==this.getAttribute("disableScopecss"):"disable-sandbox"===e?"false"!==this.getAttribute("disable-sandbox")&&"false"!==this.getAttribute("disableSandbox"):"false"!==this.getAttribute(e)}useScopecss(){return!(this.getDisposeResult("disable-scopecss")||this.getDisposeResult("shadowDOM"))}useSandbox(){return!this.getDisposeResult("disable-sandbox")}sameCoreOptions(e){return e.scopecss===this.useScopecss()&&e.useSandbox===this.useSandbox()&&e.iframe===this.getDisposeResult("iframe")}getBaseRouteCompatible(){var e,t;return null!==(t=null!==(e=this.getAttribute("baseroute"))&&void 0!==e?e:this.getAttribute("baseurl"))&&void 0!==t?t:""}getDestroyCompatibleResult(){return this.getDisposeResult("destroy")||this.getDisposeResult("destory")}getKeepAliveModeResult(){return this.getDisposeResult("keep-alive")&&!this.getDestroyCompatibleResult()}updateSsrUrl(e){if(this.getDisposeResult("ssr"))if(this.getDisposeResult("disable-memory-router")||this.getDisposeResult("disableSandbox")){const t=qn.rawWindow.location;this.ssrUrl=U(t.pathname+t.search,e)}else{let t=function(e,t){const n=xt(e);if(!n)return"";const r=I(n,t);return r.origin+r.pathname+r.search}(this.appName,e);const n=this.getDefaultPage();if(!t&&n){const r=I(n,e);t=r.origin+r.pathname+r.search}this.ssrUrl=t}else this.ssrUrl&&(this.ssrUrl="")}getDefaultPage(){return Jt.getDefaultPage(this.appName)||this.getAttribute("default-page")||this.getAttribute("defaultPage")||""}getMemoryRouterMode(){return Ft(this.getAttribute("router-mode"),this.compatibleProperties("disable-memory-router")&&this.compatibleDisableProperties("disable-memory-router"))}setAttribute(e,t){if("data"===e)if(A(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{d(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&O("property data must be an object",this.appName);else qn.rawSetAttribute.call(this,e,t)}set data(e){this.appName?or.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?or.getData(this.appName,!0):this.cacheData?this.cacheData:null}get publicPath(){return W(this.appUrl)}get baseRoute(){return this.getBaseRouteCompatible()}}qn.rawWindow.customElements.define(t,n)}function Xn(e,n){if(!t)return N("preFetch is only supported in browser environment");k((()=>{const t=f(n)?n:or.options.prefetchDelay;setTimeout((()=>{!function(e){_(e)&&(e=e()),o(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,H((t=>{var n,r,o,s,a,c;if(A(e)&&navigator.onLine)if(e.name=T(e.name),e.url=L(e.url,e.name),e.name&&e.url&&!Dn.has(e.name)){const l=new In({name:e.name,url:e.url,isPrefetch:!0,scopecss:!(null!==(r=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss)&&void 0!==r?r:or.options["disable-scopecss"]),useSandbox:!(null!==(s=null!==(o=e["disable-sandbox"])&&void 0!==o?o:e.disableSandbox)&&void 0!==s?s:or.options["disable-sandbox"]),inline:null!==(a=e.inline)&&void 0!==a?a:or.options.inline,iframe:null!==(c=e.iframe)&&void 0!==c?c:or.options.iframe,prefetchLevel:e.level&&Ie.includes(e.level)?e.level:or.options.prefetchLevel&&Ie.includes(or.options.prefetchLevel)?or.options.prefetchLevel:2}),u=l.onLoad,p=l.onLoadError;l.onLoad=n=>{l.isPrerender&&i(n,{defaultPage:e["default-page"],routerMode:Ft(e["router-mode"]),baseroute:e.baseroute,disablePatchRequest:e["disable-patch-request"]}),t(),u.call(l,n)},l.onLoadError=(...e)=>{t(),p.call(l,...e)}}else t();else t()}));var e}))),Promise.resolve())}(e)}),f(t)?t:3e3)}))}function zn(e,t,n){if(o(e)){const r=e.filter((e=>d(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));B(r.map((e=>le(e))),(e=>{const o=r[e.index];"js"===t?n.hasInfo(o)||n.setInfo(o,{code:e.data,isExternal:!1,appSpace:{}}):n.hasInfo(o)||n.setInfo(o,{code:e.data,appSpace:{}})}),(e=>{N(e)}))}}function Vn({excludeHiddenApp:e=!1,excludePreRender:t=!1}={}){const n=[];return Dn.forEach(((r,o)=>{r.isUnmounted()||r.isPrefetch&&(!r.isPrerender||t)||e&&r.isHidden()||n.push(o)})),n}function Yn(){return Array.from(Dn.keys())}function Jn(e,t){const n=Dn.get(T(e));return new Promise((r=>{if(n)if(n.isUnmounted()||n.isPrefetch)n.isPrerender?n.unmount({destroy:!!(null==t?void 0:t.destroy),clearData:!!(null==t?void 0:t.clearData),keepRouteState:!1,unmountcb:r.bind(null,!0)}):((null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),r(!0));else if(n.isHidden())(null==t?void 0:t.destroy)?n.unmount({destroy:!0,clearData:!0,keepRouteState:!0,unmountcb:r.bind(null,!0)}):(null==t?void 0:t.clearAliveState)?n.unmount({destroy:!1,clearData:!!t.clearData,keepRouteState:!0,unmountcb:r.bind(null,!0)}):r(!0);else{const e=V(n.container),o=()=>{e.removeEventListener(Pe.UNMOUNT,o),e.removeEventListener(Pe.AFTERHIDDEN,i),r(!0)},i=()=>{e.removeEventListener(Pe.UNMOUNT,o),e.removeEventListener(Pe.AFTERHIDDEN,i),r(!0)};if(e.addEventListener(Pe.UNMOUNT,o),e.addEventListener(Pe.AFTERHIDDEN,i),null==t?void 0:t.destroy){let t,n;e.hasAttribute("destroy")&&(t=e.getAttribute("destroy")),e.hasAttribute("destory")&&(n=e.getAttribute("destory")),e.setAttribute("destroy","true"),e.parentNode.removeChild(e),e.removeAttribute("destroy"),d(t)&&e.setAttribute("destroy",t),d(n)&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const n=e.getAttribute("keep-alive");e.removeAttribute("keep-alive");let r=null;t.clearData&&(r=e.getAttribute("clear-data"),e.setAttribute("clear-data","true")),e.parentNode.removeChild(e),e.setAttribute("keep-alive",n),d(r)&&e.setAttribute("clear-data",r)}else{let n=null;(null==t?void 0:t.clearData)&&(n=e.getAttribute("clear-data"),e.setAttribute("clear-data","true")),e.parentNode.removeChild(e),d(n)&&e.setAttribute("clear-data",n)}}else O(`app ${e} does not exist`),r(!1)}))}function Zn(e){return Array.from(Dn.keys()).reduce(((t,n)=>t.then((()=>Jn(n,e)))),Promise.resolve(!0))}function er(e,t){return new Promise((n=>{const r=Dn.get(T(e));if(r){const o=r.container&&V(r.container);o?n(o.reload(t)):(O(`app ${e} is not rendered, cannot use reload`),n(!1))}else O(`app ${e} does not exist`),n(!1)}))}function tr(e){return new Promise((t=>{if(!A(e))return N("renderApp options must be an object");const n=v(e.container)?e.container:d(e.container)?document.querySelector(e.container):null;if(!v(n))return N("Target container is not a DOM element.");const r=Q(or.tagName);for(const t in e)if("onDataChange"===t)_(e[t])&&r.addEventListener("datachange",e[t]);else if("lifeCycles"===t){const n=e[t];if(A(n))for(const e in n)e.toUpperCase()in Pe&&_(n[e])&&r.addEventListener(e.toLowerCase(),n[e])}else"container"!==t&&r.setAttribute(t,e[t]);const o=()=>{s(),t(!0)},i=()=>{s(),t(!1)},s=()=>{r.removeEventListener(Pe.MOUNTED,o),r.removeEventListener(Pe.ERROR,i)};r.addEventListener(Pe.MOUNTED,o),r.addEventListener(Pe.ERROR,i),n.appendChild(r)}))}function nr(e){const t=Dn.get(T(e));if(t)return t.getLifeCycleState();O(`app ${e} does not exist`)}class rr extends ht{constructor(){super(...arguments),this.tagName="micro-app",this.hasInit=!1,this.options={},this.router=Jt,this.preFetch=Xn,this.unmountApp=Jn,this.unmountAllApps=Zn,this.getActiveApps=Vn,this.getAllApps=Yn,this.reload=er,this.renderApp=tr,this.getAppStatus=nr}start(e){var n,r,o;if(!t||!window.customElements)return N("micro-app is not supported in this environment");if(this.hasInit)return N("microApp.start executed repeatedly");if(this.hasInit=!0,null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return N(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(Gn(),qn.rawWindow.customElements.get(this.tagName))return O(`element ${this.tagName} is already defined`);if(A(e)&&(this.options=e,e["disable-scopecss"]=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss,e["disable-sandbox"]=null!==(r=e["disable-sandbox"])&&void 0!==r?r:e.disableSandbox,e.preFetchApps&&Xn(e.preFetchApps),e.globalAssets&&(A(o=e.globalAssets)&&k((()=>{zn(o.js,"js",Ce.script),zn(o.css,"css",Ce.link)}))),A(e.plugins))){const t=e.plugins.modules;if(A(t))for(const e in t){const n=T(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}Qn(this.tagName)}}const or=new rr;exports.EventCenterForMicroApp=dt,exports.MicroApp=rr,exports.default=or,exports.getActiveApps=Vn,exports.getAllApps=Yn,exports.getAppStatus=nr,exports.preFetch=Xn,exports.pureCreateElement=Q,exports.reload=er,exports.removeDomScope=q,exports.renderApp=tr,exports.unmountAllApps=Zn,exports.unmountApp=Jn,exports.version=e;
2
2
  //# sourceMappingURL=index.min.js.map