@micro-zoe/micro-app 1.0.0-rc.5 → 1.0.0-rc.7

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