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