@micro-zoe/micro-app 1.0.0-rc.10 → 1.0.0-rc.11

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