@micro-zoe/micro-app
Version:
A lightweight, efficient and powerful micro front-end framework
1 lines • 116 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t="1.0.0-rc.27",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}=x(L(e),(window.rawWindow||window).location.href),r=`${t}${n}${o}`;return/^https?:\/\//.test(r)?r:""}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||/^((((ht|f)tps?)|file):)?\/\//.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)){Dt.getInstance().get(t)&&(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,