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