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