Socket
Socket
Sign inDemoInstall

@micro-zoe/micro-app

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@micro-zoe/micro-app - npm Package Compare versions

Comparing version 0.7.0 to 0.7.1

2

lib/index.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="undefined"!=typeof window,t="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")();function n(e){return"string"==typeof e}function o(e){return"boolean"==typeof e}function r(e){return"function"==typeof e}const i=Array.isArray;function s(e){return"[object Object]"===toString.call(e)}function a(e){return"[object Promise]"===toString.call(e)}function l(e){return r(e)&&0===e.name.indexOf("bound ")&&!e.hasOwnProperty("prototype")}const c=Object.defineProperty,p=Object.defineProperties,u=Object.prototype.hasOwnProperty;function d(e,t=null,...o){const r=t&&n(t)?` app ${t}:`:"";n(e)?console.error(`[micro-app]${r} ${e}`,...o):console.error(`[micro-app]${r}`,e,...o)}function h(e,t=null,...o){const r=t&&n(t)?` app ${t}:`:"";n(e)?console.warn(`[micro-app]${r} ${e}`,...o):console.warn(`[micro-app]${r}`,e,...o)}function m(e,...t){Promise.resolve().then(e.bind(null,...t))}function f(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function _(e,t=null){if(!n(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=new URL(f(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return d(e,t),""}}function A(e){return n(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function b(e){const{origin:t,pathname:n}=new URL(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function w(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:new URL(e,b(f(t))).toString()}function y(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 g=t.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let E=null;function v(e){E=e}let N=!1;function C(e){N&&E===e||(N=!0,v(e),m((()=>{N=!1,v(null)})))}function P(){return E}function O(){v(null)}function D(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function M(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n}function S(e,t,n){if(t.innerHTML="",n){const n=e.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),t.appendChild(o)}else Array.from(e.childNodes).forEach((e=>{t.appendChild(e)}))}function R(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function I(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)}function U(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}var L,x,T,W;!function(e){e.NAME="name",e.URL="url"}(L||(L={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(x||(x={})),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"}(T||(T={})),function(e){e.KEEP_ALIVE_SHOW="KEEP_ALIVE_SHOW",e.KEEP_ALIVE_HIDDEN="KEEP_ALIVE_HIDDEN"}(W||(W={}));const $="window,self,globalThis,Array,Object,String,Boolean,Math,Number,Symbol,Date,Promise,Function,Proxy,WeakMap,WeakRef,WeakSet,Set,Map,Reflect,Element,Node,Document,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,location,navigator,undefined";function k(e,t=null,n={}){return r(Ge.fetch)?Ge.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}const B={};function F(){if(e){const e=Element.prototype.setAttribute,t=Element.prototype.appendChild,n=Element.prototype.insertBefore,o=Element.prototype.replaceChild,r=Element.prototype.removeChild,i=Element.prototype.append,s=Element.prototype.prepend,a=Element.prototype.cloneNode,l=Document.prototype.createElement,c=Document.prototype.createElementNS,p=Document.prototype.createDocumentFragment,u=Document.prototype.querySelector,d=Document.prototype.querySelectorAll,h=Document.prototype.getElementById,m=Document.prototype.getElementsByClassName,f=Document.prototype.getElementsByTagName,_=Document.prototype.getElementsByName,A=new Proxy(Image,{construct(e,t){const n=new e(...t);return n.__MICRO_APP_NAME__=P(),n}}),b=Function("return window")(),w=Function("return document")(),y="noModule"in document.createElement("script"),g=w.body.querySelector("#micro-app-template-style"),E=b.addEventListener,v=b.removeEventListener,N=b.setInterval,C=b.setTimeout,O=b.clearInterval,D=b.clearTimeout,M=w.addEventListener,S=w.removeEventListener;window.__MICRO_APP_BASE_APPLICATION__=!0,Object.assign(B,{rawSetAttribute:e,rawAppendChild:t,rawInsertBefore:n,rawReplaceChild:o,rawRemoveChild:r,rawAppend:i,rawPrepend:s,rawCloneNode:a,rawCreateElement:l,rawCreateElementNS:c,rawCreateDocumentFragment:p,rawQuerySelector:u,rawQuerySelectorAll:d,rawGetElementById:h,rawGetElementsByClassName:m,rawGetElementsByTagName:f,rawGetElementsByName:_,ImageProxy:A,rawWindow:b,rawDocument:w,supportModuleScript:y,templateStyle:g,rawWindowAddEventListener:E,rawWindowRemoveEventListener:v,rawSetInterval:N,rawSetTimeout:C,rawClearInterval:O,rawClearTimeout:D,rawDocumentAddEventListener:M,rawDocumentRemoveEventListener:S})}}function H(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function K(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^(data|blob):/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!D())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),f(t.join("/")+"/")}(o)),`url("${w(r,t)}")`}))}function j(e,t,n){const o=G(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function G(e,t){let n="";for(const o of e)switch(o.constructor.name){case"CSSStyleRule":n+=H(o,t);break;case"CSSMediaRule":n+=j(o,t,"media");break;case"CSSSupportsRule":n+=j(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function q(e,t,n,o,r,i){var s,a;if(!t.__MICRO_APP_HAS_SCOPED__){let l=K(G(Array.from(null!==(a=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==a?a:[]),o),r,n,i);D()&&(l=l.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=l,t.__MICRO_APP_HAS_SCOPED__=!0}}function V(e,t){if(t.scopecss){const n=`${Ge.tagName}[name=${t.name}]`;let o=B.templateStyle;if(o||(B.templateStyle=o=M("style"),o.setAttribute("id","micro-app-template-style"),B.rawDocument.body.appendChild(o),o.sheet.disabled=!0),e.textContent)o.textContent=e.textContent,q(o,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__),o.textContent="";else{const o=new MutationObserver((function(){var r,i;o.disconnect(),!e.textContent&&(null===(i=null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||q(e,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__)}));o.observe(e,{childList:!0})}}return e}function z(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function Q(e){const t=new CustomEvent("load");z(t,e),r(e.onload)?e.onload(t):e.dispatchEvent(t)}function J(e){const t=new CustomEvent("error");z(t,e),r(e.onerror)?e.onerror(t):e.dispatchEvent(t)}const X=new Map;function Y(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){if(i=w(i,n.url),o)return{url:i,info:{code:"",isGlobal:e.hasAttribute("global")}};s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),n.source.links.set(i,{code:"",placeholder:s,isGlobal:e.hasAttribute("global")})}else r&&["prefetch","preload","prerender","icon","apple-touch-icon"].includes(r)?o?s=document.createComment(`link element with rel=${r}${i?" & href="+i:""} removed by micro-app`):t.removeChild(e):i&&e.setAttribute("href",w(i,n.url));return o?{replaceComment:s}:s?t.replaceChild(s,e):void 0}function Z(e,t,n){const o=Array.from(t.source.links.entries()),r=[];for(const[e]of o){const n=X.get(e);n?r.push(n):r.push(k(e,t.name))}y(r,(e=>{!function(e,t,n,o,r){t.isGlobal&&!X.has(e)&&X.set(e,n);const i=M("style");i.textContent=n,i.__MICRO_APP_LINK_PATH__=e,i.setAttribute("data-origin-href",e),o.replaceChild(V(i,r),t.placeholder),t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{d(e,t.name)}),(()=>{t.onLoad(e)}))}const ee=new Map;function te(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module"].includes(e.type)||e.hasAttribute("ignore"))return null;if(B.supportModuleScript&&e.noModule||!B.supportModuleScript&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=w(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t="inline-"+Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else o||(r=document.createComment("script element removed by micro-app"))}return o?{replaceComment:r}:t.replaceChild(r,e)}function ne(e,t){const n=Array.from(t.source.scripts.entries()),o=[],r=[];for(const[e,i]of n)if(i.isExternal){const n=ee.get(e);n?i.code=n:i.defer||i.async||(o.push(k(e,t.name)),r.push([e,i]))}o.length?y(o,(e=>{!function(e,t,n){t.isGlobal&&!ee.has(e)&&ee.set(e,n);t.code=n}(r[e.index][0],r[e.index][1],e.data)}),(e=>{d(e,t.name)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function oe(e,t,n,o,r){var i;try{const s=se(e,t,n.code,n.module);if(t.inline||n.module){const a=M("script");if(re(e,s,n.module,a,r),o)return a;null===(i=t.container)||void 0===i||i.querySelector("micro-app-body").appendChild(a)}else if(ie(s,n),o)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error(`[micro-app from runScript] app ${t.name}: `,e)}}function re(e,t,n,o,r){if(n){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e),o.setAttribute("type","module"),r&&(r.moduleCount&&r.moduleCount--,o.onload=r.bind(o,0===r.moduleCount))}else o.textContent=t;e.startsWith("inline-")||o.setAttribute("data-origin-src",e)}function ie(e,t){t.code2Function||(t.code2Function=new Function(e)),t.code2Function.call(window)}function se(e,t,n,o){return s(Ge.plugins)&&(n=function(e,t,n,o){var a;if(i(o.global))for(const n of o.global)s(n)&&r(n.loader)&&(t=n.loader(t,e,n.options));if(i(null===(a=o.modules)||void 0===a?void 0:a[n]))for(const i of o.modules[n])s(i)&&r(i.loader)&&(t=i.loader(t,e,i.options));return t}(e,n,t.name,Ge.plugins)),t.sandBox&&!o?(B.rawWindow.__MICRO_APP_PROXY_WINDOW__=t.sandBox.proxyWindow,`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${$}){;${n}\n}).call(proxyWindow,${$})}})(window.__MICRO_APP_PROXY_WINDOW__);`):n}function ae(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{ae(e,t)}));for(const n of o)n instanceof HTMLLinkElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")?n.hasAttribute("href")&&n.setAttribute("href",w(n.getAttribute("href"),t.url)):Y(n,e,t):n instanceof HTMLStyleElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&V(n,t):n instanceof HTMLScriptElement?te(n,e,t):n instanceof HTMLMetaElement||n instanceof HTMLTitleElement?e.removeChild(n):n instanceof HTMLImageElement&&n.hasAttribute("src")&&n.setAttribute("src",w(n.getAttribute("src"),t.url))}function le(e,t){const n=function(e){const t=M("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),r=n.querySelector("micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),d(e,t.name)}ae(n,t),t.source.links.size?Z(n,t,o):t.onLoad(n),t.source.scripts.size?ne(n,t):t.onLoad(n)}const ce=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(d("event-center: Invalid name"),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if(!r(t))return d("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&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&&(r(t)?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if(!s(t))return d("event-center: data must be object");let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}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 pe(e,t){return n(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class ue{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),ce.on("global",e,t)}removeGlobalDataListener(e){r(e)&&ce.off("global",e)}setGlobalData(e){O(),ce.dispatch("global",e)}getGlobalData(){return ce.getData("global")}clearGlobalDataListener(){const e=this.appName,t=ce.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 de extends ue{addDataListener(e,t,n){ce.on(pe(A(e),!1),t,n)}removeDataListener(e,t){r(t)&&ce.off(pe(A(e),!1),t)}getData(e,t=!1){return ce.getData(pe(A(e),t))}setData(e,t){ce.dispatch(pe(A(e),!0),t)}clearDataListener(e){ce.off(pe(A(e),!1))}}class he extends ue{constructor(e){super(),this.appName=A(e),!this.appName&&d(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,ce.on(pe(this.appName,!0),e,t)}removeDataListener(e){r(e)&&ce.off(pe(this.appName,!0),e)}getData(){return ce.getData(pe(this.appName,!0))}dispatch(e){O(),ce.dispatch(pe(this.appName,!1),e);const t=Oe.get(this.appName);if((null==t?void 0:t.container)&&s(e)){const n=new CustomEvent("datachange",{detail:{data:e}});U(t.container).dispatchEvent(n)}}clearDataListener(){ce.off(pe(this.appName,!0))}}function me(e,t){if(t.__MICRO_APP_BOUND_WINDOW_FUNCTION)return t.__MICRO_APP_BOUND_WINDOW_FUNCTION;if(!function(e){var t;if(o(e.__MICRO_APP_ISCONSTRUCTOR))return e.__MICRO_APP_ISCONSTRUCTOR;const n=e.toString(),r=(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 e.__MICRO_APP_ISCONSTRUCTOR=r}(t)&&!function(e){return o(e.__MICRO_APP_ISBOUND_FUNCTION)?e.__MICRO_APP_ISBOUND_FUNCTION:e.__MICRO_APP_ISBOUND_FUNCTION=l(e)}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&c(n,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t.__MICRO_APP_BOUND_WINDOW_FUNCTION=n}return t}const fe=new Map;let _e=!1;const Ae=new Map;function be(){const{rawDocument:e,rawDocumentAddEventListener:t,rawDocumentRemoveEventListener:n}=B;!_e&&function(){if(_e=!0,Object.getOwnPropertyDescriptor(document,"onclick"))return h("Cannot redefine document property onclick");const e=document.onclick;document.onclick=null;let t=!1;function n(e){fe.forEach((t=>{r(t)&&t.call(document,e)}))}c(document,"onclick",{configurable:!0,enumerable:!0,get(){const e=P();return e?fe.get(e):fe.get("base")},set(e){const o=P();o?fe.set(o,e):fe.set("base",e),!t&&r(e)&&(t=!0,B.rawDocumentAddEventListener.call(B.rawDocument,"click",n,!1))}}),e&&(document.onclick=e)}(),document.addEventListener=function(n,o,r){var i;const s=P();if(s&&(!(null===(i=Oe.get(s))||void 0===i?void 0:i.umdMode)||!l(o))){const e=Ae.get(s);if(e){const t=e.get(n);t?t.add(o):e.set(n,new Set([o]))}else Ae.set(s,new Map([[n,new Set([o])]]));o&&(o.__MICRO_APP_MARK_OPTIONS__=r)}t.call(e,n,o,r)},document.removeEventListener=function(t,o,r){var i;const s=P();if(s&&(!(null===(i=Oe.get(s))||void 0===i?void 0:i.umdMode)||!l(o))){const e=Ae.get(s);if(e){const n=e.get(t);(null==n?void 0:n.size)&&n.has(o)&&n.delete(o)}}n.call(e,t,o,r)}}const we=["unmount","appstate-change"];function ye(e,t){return we.includes(e)?`${e}-${t.__MICRO_APP_NAME__}`:e}const ge=["System","__cjsWrapper"],Ee=["location"],ve=["window","self","globalThis"];class Ne{constructor(e,t){this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.active=!1,this.microAppWindow={},this.getScopeProperties(e),this.proxyWindow=this.createProxyWindow(),this.initMicroAppWindow(this.microAppWindow,e,t),Object.assign(this,function(e){const t=e.__MICRO_APP_NAME__,n=new Map,o=new Map,r=new Map,{rawWindow:i,rawDocument:s,rawWindowAddEventListener:a,rawWindowRemoveEventListener:l,rawSetInterval:c,rawSetTimeout:p,rawClearInterval:u,rawClearTimeout:d,rawDocumentRemoveEventListener:h}=B;e.addEventListener=function(t,o,r){t=ye(t,e);const s=n.get(t);s?s.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(i,t,o,r)},e.removeEventListener=function(t,o,r){t=ye(t,e);const s=n.get(t);(null==s?void 0:s.size)&&s.has(o)&&s.delete(o),l.call(i,t,o,r)},e.setInterval=function(e,t,...n){const r=c.call(i,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const o=p.call(i,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.clearInterval=function(e){o.delete(e),u.call(i,e)},e.clearTimeout=function(e){r.delete(e),d.call(i,e)};const m=new Map,f=new Map;let _,A=new Map,b=new Map;return{recordUmdEffect:()=>{n.forEach(((e,t)=>{e.size&&m.set(t,new Set(e))})),o.size&&(A=new Map(o)),r.size&&(b=new Map(r)),_=fe.get(t);const e=Ae.get(t);e&&e.forEach(((e,t)=>{e.size&&f.set(t,new Set(e))}))},rebuildUmdEffect:()=>{m.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),A.forEach((t=>{e.setInterval(t.handler,t.timeout,...t.args)})),b.forEach((t=>{e.setTimeout(t.handler,t.timeout,...t.args)})),_&&fe.set(t,_),v(t),f.forEach(((e,t)=>{for(const n of e)document.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),v(null)},releaseEffect:()=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(i,t,n)})),n.clear()),o.size&&(o.forEach(((e,t)=>{u.call(i,t)})),o.clear()),r.size&&(r.forEach(((e,t)=>{d.call(i,t)})),r.clear()),fe.delete(t);const e=Ae.get(t);e&&(e.forEach(((e,t)=>{for(const n of e)h.call(s,t,n)})),e.clear())}}}(this.microAppWindow))}start(e){this.active||(this.active=!0,this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e,B.rawWindow._babelPolyfill&&(B.rawWindow._babelPolyfill=!1),1==++Ne.activeCount&&be())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microAppWindow.microApp.clearDataListener(),this.microAppWindow.microApp.clearGlobalDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(B.rawWindow,e)})),this.escapeKeys.clear(),0==--Ne.activeCount&&(document.addEventListener=B.rawDocumentAddEventListener,document.removeEventListener=B.rawDocumentRemoveEventListener))}recordUmdSnapshot(){this.microAppWindow.__MICRO_APP_UMD_MODE__=!0,this.recordUmdEffect(),function(e){const t=e.appName;e.umdDataListeners={global:new Set,normal:new Set};const n=ce.eventList.get("global");if(n)for(const o of n.callbacks)t===o.__APP_NAME__&&e.umdDataListeners.global.add(o);const o=ce.eventList.get(pe(t,!0));o&&(e.umdDataListeners.normal=new Set(o.callbacks))}(this.microAppWindow.microApp),this.recordUmdinjectedValues=new Map,this.injectedKeys.forEach((e=>{this.recordUmdinjectedValues.set(e,Reflect.get(this.microAppWindow,e))}))}rebuildUmdSnapshot(){this.recordUmdinjectedValues.forEach(((e,t)=>{Reflect.set(this.proxyWindow,t,e)})),this.rebuildUmdEffect(),function(e){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__)}(this.microAppWindow.microApp)}getScopeProperties(e){var t;if(s(Ge.plugins)){if(i(Ge.plugins.global))for(const e of Ge.plugins.global)s(e)&&(i(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),i(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if(i(null===(t=Ge.plugins.modules)||void 0===t?void 0:t[e]))for(const t of Ge.plugins.modules[e])s(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}createProxyWindow(){const e=B.rawWindow,t=new Map;return new Proxy(this.microAppWindow,{get:(t,o)=>{if(Reflect.has(t,o)||n(o)&&/^__MICRO_APP_/.test(o)||this.scopeProperties.includes(o))return Reflect.get(t,o);const i=Reflect.get(e,o);return r(i)?me(e,i):i},set:(t,n,o)=>{if(this.active){if(Ee.includes(n))Reflect.set(e,n,o);else if(u.call(t,n)||!u.call(e,n)||this.scopeProperties.includes(n))Reflect.set(t,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(e,n),{configurable:i,enumerable:s,writable:a,set:l}=r;c(t,n,{value:o,configurable:i,enumerable:s,writable:null!=a?a:!!l}),this.injectedKeys.add(n)}(this.escapeProperties.includes(n)||ge.includes(n)&&!Reflect.has(e,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(e,n,o),this.escapeKeys.add(n))}return!0},has:(t,n)=>this.scopeProperties.includes(n)?n in t:n in t||n in e,getOwnPropertyDescriptor:(n,o)=>{if(u.call(n,o))return t.set(o,"target"),Object.getOwnPropertyDescriptor(n,o);if(u.call(e,o)){t.set(o,"rawWindow");const n=Object.getOwnPropertyDescriptor(e,o);return n&&!n.configurable&&(n.configurable=!0),n}},defineProperty:(n,o,r)=>"rawWindow"===t.get(o)?Reflect.defineProperty(e,o,r):Reflect.defineProperty(n,o,r),ownKeys:t=>Reflect.ownKeys(e).concat(Reflect.ownKeys(t)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(t,n)=>!u.call(t,n)||(this.injectedKeys.has(n)&&this.injectedKeys.delete(n),this.escapeKeys.has(n)&&Reflect.deleteProperty(e,n),Reflect.deleteProperty(t,n))})}initMicroAppWindow(e,t,n){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=t,e.__MICRO_APP_PUBLIC_PATH__=b(n),e.__MICRO_APP_WINDOW__=e,e.microApp=new he(t),e.rawWindow=B.rawWindow,e.rawDocument=B.rawDocument,e.removeDomScope=O,e.hasOwnProperty=t=>u.call(e,t)||u.call(B.rawWindow,t),this.setMappingPropertiesWithRawDescriptor(e),this.setHijackProperties(e,t)}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=B.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),c(e,"top",this.createDescriptorFormicroAppWindow("top",t)),c(e,"parent",this.createDescriptorFormicroAppWindow("parent",n)),ve.forEach((t=>{c(e,t,this.createDescriptorFormicroAppWindow(t,this.proxyWindow))}))}createDescriptorFormicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(B.rawWindow,e)||{};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}setHijackProperties(e,t){let n,o;p(e,{document:{get:()=>(C(t),B.rawDocument),configurable:!1,enumerable:!0},eval:{get:()=>(C(t),n||eval),set:e=>{n=e},configurable:!0,enumerable:!1},Image:{get:()=>(C(t),o||B.ImageProxy),set:e=>{o=e},configurable:!0,enumerable:!1}})}}function Ce(e,t,n,o){var i;if(!e)return d(`element does not exist in lifecycle ${n}`,t);e=U(e),O();const s=Object.assign({name:t,container:e},o&&{error:o}),a=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),r(null===(i=Ge.lifeCycles)||void 0===i?void 0:i[n])&&Ge.lifeCycles[n](a),e.dispatchEvent(a)}function Pe(e,t,n={}){const o=new CustomEvent(`${e}-${t}`,{detail:n});window.dispatchEvent(o)}Ne.activeCount=0;const Oe=new Map;class De{constructor({name:e,url:t,ssrUrl:n,container:o,inline:r,scopecss:i,useSandbox:s,baseroute:a}){this.state=x.NOT_LOADED,this.keepAliveState=null,this.keepAliveContainer=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.libraryName=null,this.umdMode=!1,this.isPrefetch=!1,this.container=null,this.baseroute="",this.sandBox=null,this.container=null!=o?o:null,this.inline=null!=r&&r,this.baseroute=null!=a?a:"",this.ssrUrl=null!=n?n:"",this.name=e,this.url=t,this.useSandbox=s,this.scopecss=this.useSandbox&&i,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Ne(e,t))}loadSourceCode(){var e;this.state=x.LOADING_SOURCE_CODE,k((e=this).ssrUrl||e.url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),d(t,e.name)}le(t=t.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>"))),e)})).catch((t=>{d(`Failed to fetch data from ${e.url}, micro-app stop rendering`,e.name,t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||x.UNMOUNT===this.state)return;this.state=x.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,x.UNMOUNT!==this.state&&(this.onerror(e),this.state=x.LOAD_SOURCE_ERROR)}mount(e,t,n){var i,s,a;if(o(t)&&t!==this.inline&&(this.inline=t),this.container=null!==(i=this.container)&&void 0!==i?i:e,this.baseroute=null!=n?n:this.baseroute,2!==this.loadSourceLevel)return void(this.state=x.LOADING_SOURCE_CODE);let l;if(Ce(this.container,this.name,T.BEFOREMOUNT),this.state=x.MOUNTING,S(this.source.html,this.container,!this.umdMode),null===(s=this.sandBox)||void 0===s||s.start(this.baseroute),this.umdMode){null===(a=this.sandBox)||void 0===a||a.rebuildUmdSnapshot();try{l=this.umdHookMount()}catch(e){d("an error occurred in the mount function \n",this.name,e)}this.handleMounted(l)}else{let e=!1;!function(e,t,n){const o=Array.from(e.entries()),r=[],i=[];for(const[e,s]of o)s.isDynamic||(s.defer||s.async?(s.isExternal&&!s.code?r.push(k(e,t.name)):r.push(s.code),i.push([e,s]),s.module&&(n.moduleCount=n.moduleCount?++n.moduleCount:1)):(oe(e,t,s,!1),n(!1)));r.length?y(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(e=>{n.errorCount=n.errorCount?++n.errorCount:1,d(e,t.name)}),(()=>{i.forEach((([e,o])=>{o.code&&(oe(e,t,o,!1,n),!o.module&&n(!1))})),n(void 0===n.moduleCount||n.errorCount===r.length)})):n(!0)}(this.source.scripts,this,(t=>{var n;if(!this.umdMode){const{mount:e,unmount:t}=this.getUmdLibraryHooks();if(r(e)&&r(t)){this.umdHookMount=e,this.umdHookUnmount=t,this.umdMode=!0,null===(n=this.sandBox)||void 0===n||n.recordUmdSnapshot();try{l=this.umdHookMount()}catch(e){d("an error occurred in the mount function \n",this.name,e)}}}e||!0!==t&&!this.umdMode||(e=!0,this.handleMounted(l))}))}}handleMounted(e){a(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>this.onerror(e))):this.dispatchMountedEvent()}dispatchMountedEvent(){x.UNMOUNT!==this.state&&(this.state=x.MOUNTED,Ce(this.container,this.name,T.MOUNTED))}unmount(e,t){let n;if(this.state===x.LOAD_SOURCE_ERROR&&(e=!0),this.state=x.UNMOUNT,this.keepAliveState=null,this.keepAliveContainer=null,this.umdHookUnmount)try{n=this.umdHookUnmount()}catch(e){d("an error occurred in the unmount function \n",this.name,e)}Pe("unmount",this.name),this.handleUnmounted(e,n,t)}handleUnmounted(e,t,n){a(t)?t.then((()=>this.actionsForUnmount(e,n))).catch((()=>this.actionsForUnmount(e,n))):this.actionsForUnmount(e,n)}actionsForUnmount(e,t){var n;null===(n=this.sandBox)||void 0===n||n.stop(),e?this.actionsForCompletelyDestroy():this.umdMode&&this.container.childElementCount&&S(this.container,this.source.html,!1),Ce(this.container,this.name,T.UNMOUNT),this.container.innerHTML="",this.container=null,t&&t()}actionsForCompletelyDestroy(){!this.useSandbox&&this.umdMode&&delete window[this.libraryName],Oe.delete(this.name)}hiddenKeepAliveApp(){const e=this.container;S(this.container,this.keepAliveContainer?this.keepAliveContainer:this.keepAliveContainer=document.createElement("div"),!1),this.container=this.keepAliveContainer,this.keepAliveState=W.KEEP_ALIVE_HIDDEN,Pe("appstate-change",this.name,{appState:"afterhidden"}),Ce(e,this.name,T.AFTERHIDDEN)}showKeepAliveApp(e){Pe("appstate-change",this.name,{appState:"beforeshow"}),Ce(e,this.name,T.BEFORESHOW),S(this.container,e,!1),this.container=e,this.keepAliveState=W.KEEP_ALIVE_SHOW,Pe("appstate-change",this.name,{appState:"aftershow"}),Ce(this.container,this.name,T.AFTERSHOW)}onerror(e){Ce(this.container,this.name,T.ERROR,e)}getAppState(){return this.state}getKeepAliveState(){return this.keepAliveState}getUmdLibraryHooks(){var e,t;if(x.UNMOUNT!==this.state){const n=null!==(t=null===(e=this.sandBox)||void 0===e?void 0:e.proxyWindow)&&void 0!==t?t:B.rawWindow;return this.libraryName=U(this.container).getAttribute("library")||`micro-app-${this.name}`,"object"==typeof n[this.libraryName]?n[this.libraryName]:{}}return{}}}const Me=new WeakMap;function Se(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return Me.set(t,e),e}return n.scopecss&&!t.hasAttribute("ignore")?V(t,n):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return Me.set(t,e),e}if(t.hasAttribute("ignore"))return t;const{url:o,info:r,replaceComment:i}=Y(t,e,n,!0);if(o&&r){const e=M("style");return e.__MICRO_APP_LINK_PATH__=o,function(e,t,n,o,r){if(n.source.links.has(e))return r.textContent=n.source.links.get(e).code,V(r,n),void m((()=>Q(o)));if(X.has(e)){const i=X.get(e);return t.code=i,n.source.links.set(e,t),r.textContent=i,V(r,n),void m((()=>Q(o)))}k(e,n.name).then((i=>{t.code=i,n.source.links.set(e,t),t.isGlobal&&X.set(e,i),r.textContent=i,V(r,n),Q(o)})).catch((e=>{d(e,n.name),J(o)}))}(o,r,n,t,e),Me.set(t,e),e}return i?(Me.set(t,i),i):t}if(t instanceof HTMLScriptElement){const{replaceComment:o,url:r,info:i}=te(t,e,n,!0)||{};if(r&&i){if(i.isExternal){const e=function(e,t,n,o){const r=()=>Q(o);if(n.source.scripts.has(e)){const t=n.source.scripts.get(e);return!t.module&&m(r),oe(e,n,t,!0,r)}if(ee.has(e)){const o=ee.get(e);return t.code=o,n.source.scripts.set(e,t),!t.module&&m(r),oe(e,n,t,!0,r)}let i;return i=n.inline||t.module?M("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),k(e,n.name).then((s=>{t.code=s,n.source.scripts.set(e,t),t.isGlobal&&ee.set(e,s);try{s=se(e,n,s,t.module),n.inline||t.module?re(e,s,t.module,i,r):ie(s,t)}catch(t){console.error(`[micro-app from runDynamicScript] app ${n.name}: `,t,e)}!t.module&&Q(o)})).catch((e=>{d(e,n.name),J(o)})),i}(r,i,n,t);return Me.set(t,e),e}{const e=oe(r,n,i,!0);return Me.set(t,e),e}}return o?(Me.set(t,o),o):t}return t}function Re(e,t,n,o,r){if(n===document.head){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?B.rawAppendChild.call(i,o):t!==B.rawRemoveChild||i.contains(o)?t===B.rawAppend||t===B.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n===document.body){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?B.rawAppendChild.call(i,o):t!==B.rawRemoveChild||i.contains(o)?t===B.rawAppend||t===B.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===B.rawAppend||t===B.rawPrepend?t.call(n,o):t.call(n,o,r)}function Ie(e){var t;return null!==(t=Me.get(e))&&void 0!==t?t:e}function Ue(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Oe.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?Re(r,o,e,Se(e,t,r),n&&Ie(n)):o===B.rawAppend||o===B.rawPrepend?o.call(e,t):o.call(e,t,n)}if(o===B.rawAppend||o===B.rawPrepend){const n=P();if(!(t instanceof Node)&&n){const r=Oe.get(n);if(null==r?void 0:r.container){if(e===document.head)return o.call(r.container.querySelector("micro-app-head"),t);if(e===document.body)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function Le(){!function(){const e=B.rawDocument;function t(t){var n,o,r;const i=P();return i&&t&&!I(t)&&e===this?null!==(r=null===(o=null===(n=Oe.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:B.rawQuerySelector.call(this,t)}function n(t){var n,o,r;const i=P();return i&&t&&!I(t)&&e===this?null!==(r=null===(o=null===(n=Oe.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:B.rawQuerySelectorAll.call(this,t)}Document.prototype.createElement=function(e,t){return xe(B.rawCreateElement.call(this,e,t))},Document.prototype.createElementNS=function(e,t,n){return xe(B.rawCreateElementNS.call(this,e,t,n))},Document.prototype.createDocumentFragment=function(){return xe(B.rawCreateDocumentFragment.call(this))},Document.prototype.querySelector=t,Document.prototype.querySelectorAll=n,Document.prototype.getElementById=function(e){if(!P()||R(e))return B.rawGetElementById.call(this,e);try{return t.call(this,`#${e}`)}catch(t){return B.rawGetElementById.call(this,e)}},Document.prototype.getElementsByClassName=function(e){if(!P()||R(e))return B.rawGetElementsByClassName.call(this,e);try{return n.call(this,`.${e}`)}catch(t){return B.rawGetElementsByClassName.call(this,e)}},Document.prototype.getElementsByTagName=function(e){var t;const o=P();if(!o||I(e)||R(e)||!(null===(t=Oe.get(o))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return B.rawGetElementsByTagName.call(this,e);try{return n.call(this,e)}catch(t){return B.rawGetElementsByTagName.call(this,e)}},Document.prototype.getElementsByName=function(e){if(!P()||R(e))return B.rawGetElementsByName.call(this,e);try{return n.call(this,`[name=${e}]`)}catch(t){return B.rawGetElementsByName.call(this,e)}}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if(s(t)){const e={};Object.getOwnPropertyNames(t).forEach((o=>{n(o)&&0===o.indexOf("__")||(e[o]=t[o])})),this.data=e}else"[object Object]"!==t&&h("property data must be an object",this.getAttribute("name"));else if((("src"===e||"srcset"===e)&&/^(img|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Oe.has(this.__MICRO_APP_NAME__)){const n=Oe.get(this.__MICRO_APP_NAME__);B.rawSetAttribute.call(this,e,w(t,n.url))}else B.rawSetAttribute.call(this,e,t)},Element.prototype.appendChild=function(e){return Ue(this,e,null,B.rawAppendChild)},Element.prototype.insertBefore=function(e,t){return Ue(this,e,t,B.rawInsertBefore)},Element.prototype.replaceChild=function(e,t){return Ue(this,e,t,B.rawReplaceChild)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)Ue(this,e[t],null,B.rawAppend),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)Ue(this,e[t-1],null,B.rawPrepend),t--},Element.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Oe.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?Re(t,B.rawRemoveChild,this,Ie(e)):B.rawRemoveChild.call(this,e)}return B.rawRemoveChild.call(this,e)},Element.prototype.cloneNode=function(e){const t=B.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t}}function xe(e){const t=P();return t&&(e.__MICRO_APP_NAME__=t),e}function Te(){v(null),Document.prototype.createElement=B.rawCreateElement,Document.prototype.createElementNS=B.rawCreateElementNS,Document.prototype.createDocumentFragment=B.rawCreateDocumentFragment,Document.prototype.querySelector=B.rawQuerySelector,Document.prototype.querySelectorAll=B.rawQuerySelectorAll,Document.prototype.getElementById=B.rawGetElementById,Document.prototype.getElementsByClassName=B.rawGetElementsByClassName,Document.prototype.getElementsByTagName=B.rawGetElementsByTagName,Document.prototype.getElementsByName=B.rawGetElementsByName,Element.prototype.setAttribute=B.rawSetAttribute,Element.prototype.appendChild=B.rawAppendChild,Element.prototype.insertBefore=B.rawInsertBefore,Element.prototype.replaceChild=B.rawReplaceChild,Element.prototype.removeChild=B.rawRemoveChild,Element.prototype.append=B.rawAppend,Element.prototype.prepend=B.rawPrepend,Element.prototype.cloneNode=B.rawCloneNode}let We=!1;function $e(){ke(),Oe.forEach((e=>{e.container&&U(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Oe.clear(),Be.size&&(Be.clear(),Te())}function ke(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",$e,!1)}const Be=new Map;function Fe(e){class t extends HTMLElement{constructor(){super(),this.isWating=!1,this.cacheData=null,this.hasConnected=!1,this.appName="",this.appUrl="",this.ssrUrl="",this.version="0.7.0",this.handleAttributeUpdate=()=>{this.isWating=!1;const e=A(this.getAttribute("name")),t=_(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Oe.get(e);if(e!==this.appName&&n&&x.UNMOUNT!==n.getAppState()&&W.KEEP_ALIVE_HIDDEN!==n.getKeepAliveState()&&!n.isPrefetch)return this.setAttribute("name",this.appName),d(`app name conflict, an app named ${e} is running`,this.appName);e===this.appName&&t===this.appUrl||(e===this.appName?this.handleUnmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)},this.querySelector("micro-app-head")||this.performWhenFirstCreated()}static get observedAttributes(){return["name","url"]}connectedCallback(){this.hasConnected=!0,Be.has(this)||this.performWhenFirstCreated(),m((()=>Ce(this,this.appName,T.CREATED))),this.initialMount()}disconnectedCallback(){this.hasConnected=!1,this.getKeepAliveModeResult()?this.handleHiddenKeepAliveApp():(Be.delete(this),this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{0===Be.size&&Te()})))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===L.NAME?"appName":"appUrl"]!==n)if(e!==L.URL||this.appUrl)if(e!==L.NAME||this.appName)this.isWating||(this.isWating=!0,m(this.handleAttributeUpdate));else{const e=A(n);if(!e)return d(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(Ge.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=_(n,this.appName)))return d(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.hasConnected&&this.initialMount()}performWhenFirstCreated(){1===Be.set(this,!0).size&&(Le(),function(){if(!We){We=!0;const e=M("style");e.setAttribute("type","text/css"),e.textContent=`\n${Ge.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,B.rawDocument.head.appendChild(e)}}(),ke(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",$e,!1))}initialMount(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&r(this.attachShadow)&&this.attachShadow({mode:"open"}),this.getDisposeResult("ssr")?this.ssrUrl=w(B.rawWindow.location.pathname,this.appUrl):this.ssrUrl&&(this.ssrUrl=""),Oe.has(this.appName)){const e=Oe.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===W.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t!==n||!e.isPrefetch&&e.getAppState()!==x.UNMOUNT?e.isPrefetch||e.getAppState()===x.UNMOUNT?(h(`the ${e.isPrefetch?"prefetch":"unmounted"} app with url: ${t} is replaced by a new app`,this.appName),this.handleCreateApp()):d(`app name conflict, an app named ${this.appName} is running`,this.appName):this.handleAppMount(e)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.getDisposeResult("ssr")?this.ssrUrl=w(B.rawWindow.location.pathname,t):this.ssrUrl&&(this.ssrUrl=""),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.getKeepAliveState()===W.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):d(`app name conflict, an app named ${this.appName} is running`,this.appName):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleAppMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!n(t)||!t)||(d(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleAppMount(e){e.isPrefetch=!1,m((()=>{var t;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),this.getBaseRouteCompatible())}))}handleCreateApp(){var e;Oe.has(this.appName)&&Oe.get(this.appName).actionsForCompletelyDestroy();const t=new De({name:this.appName,url:this.appUrl,ssrUrl:this.ssrUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),baseroute:this.getBaseRouteCompatible()});Oe.set(this.appName,t)}handleUnmount(e,t){const n=Oe.get(this.appName);n&&n.getAppState()!==x.UNMOUNT&&n.unmount(e,t)}handleHiddenKeepAliveApp(){const e=Oe.get(this.appName);e&&e.getAppState()!==x.UNMOUNT&&e.getKeepAliveState()!==W.KEEP_ALIVE_HIDDEN&&e.hiddenKeepAliveApp()}handleShowKeepAliveApp(e){m((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleSpecialProperties(e)||Ge[e])&&this.compatibleDisablSpecialProperties(e)}compatibleSpecialProperties(e){return"disableScopecss"===e?this.hasAttribute("disableScopecss")||this.hasAttribute("disable-scopecss"):"disableSandbox"===e?this.hasAttribute("disableSandbox")||this.hasAttribute("disable-sandbox"):this.hasAttribute(e)}compatibleDisablSpecialProperties(e){return"disableScopecss"===e?"false"!==this.getAttribute("disableScopecss")&&"false"!==this.getAttribute("disable-scopecss"):"disableSandbox"===e?"false"!==this.getAttribute("disableSandbox")&&"false"!==this.getAttribute("disable-sandbox"):"false"!==this.getAttribute(e)}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()}set data(e){this.appName?Ge.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Ge.getData(this.appName,!0):this.cacheData?this.cacheData:null}}window.customElements.define(e,t)}function He(t){if(!e)return d("preFetch is only supported in browser environment");g((()=>{r(t)&&(t=t()),function(e){const t=[];return i(e)&&e.forEach((e=>{s(e)&&(e.name=A(e.name),e.url=_(e.url,e.name),e.name&&e.url&&!Oe.has(e.name)&&t.push(e))})),t}(t).forEach((e=>{var t,n;const o=new De({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:Ge.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:Ge.disableSandbox)});o.isPrefetch=!0,Oe.set(e.name,o)}))}))}function Ke(e,t){const n=Oe.get(A(e));return new Promise((o=>{if(n)if(n.getAppState()===x.UNMOUNT||n.isPrefetch)(null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o();else if(n.getKeepAliveState()===W.KEEP_ALIVE_HIDDEN)(null==t?void 0:t.destroy)?n.unmount(!0,o):(null==t?void 0:t.clearAliveState)?n.unmount(!1,o):o();else{const e=U(n.container),r=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()},i=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()};if(e.addEventListener("unmount",r),e.addEventListener("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"),"string"==typeof t&&e.setAttribute("destroy",t),"string"==typeof n&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const t=e.getAttribute("keep-alive");e.removeAttribute("keep-alive"),e.parentNode.removeChild(e),e.setAttribute("keep-alive",t)}else e.parentNode.removeChild(e)}else h(`app ${e} does not exist`),o()}))}class je extends de{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=He}start(t){if(!e||!window.customElements)return d("micro-app is not supported in this environment");if(null==t?void 0:t.tagName){if(!/^micro-app(-\S+)?/.test(t.tagName))return d(`${t.tagName} is invalid tagName`);this.tagName=t.tagName}if(window.customElements.get(this.tagName))return h(`element ${this.tagName} is already defined`);if(F(),t&&s(t)&&(this.shadowDOM=t.shadowDOM,this.destroy=t.destroy,this.destory=t.destory,this.inline=t.inline,this.disableScopecss=t.disableScopecss,this.disableSandbox=t.disableSandbox,this.ssr=t.ssr,r(t.fetch)&&(this.fetch=t.fetch),s(t.lifeCycles)&&(this.lifeCycles=t.lifeCycles),t.preFetchApps&&He(t.preFetchApps),t.globalAssets&&(s(o=t.globalAssets)&&g((()=>{if(i(o.js)){const e=o.js.filter((e=>n(e)&&e.includes(".js")&&!ee.has(e))),t=[];e.forEach((e=>{t.push(k(e))})),y(t,(t=>{const n=e[t.index];ee.has(n)||ee.set(n,t.data)}),(e=>{d(e)}))}if(i(o.css)){const e=o.css.filter((e=>n(e)&&e.includes(".css")&&!X.has(e))),t=[];e.forEach((e=>{t.push(k(e))})),y(t,(t=>{const n=e[t.index];X.has(n)||X.set(n,t.data)}),(e=>{d(e)}))}}))),s(t.plugins))){const e=t.plugins.modules;if(s(e))for(const t in e){const n=A(t);n&&t!==n&&(e[n]=e[t],delete e[t])}this.plugins=t.plugins}var o;Fe(this.tagName)}}var Ge=new je;exports.EventCenterForMicroApp=he,exports.MicroApp=je,exports.default=Ge,exports.getActiveApps=function(e){const t=[];return Oe.forEach(((n,o)=>{x.UNMOUNT===n.getAppState()||n.isPrefetch||e&&W.KEEP_ALIVE_HIDDEN===n.getKeepAliveState()||t.push(o)})),t},exports.getAllApps=function(){return Array.from(Oe.keys())},exports.preFetch=He,exports.pureCreateElement=M,exports.removeDomScope=O,exports.unmountAllApps=function(e){return Array.from(Oe.keys()).reduce(((t,n)=>t.then((()=>Ke(n,e)))),Promise.resolve())},exports.unmountApp=Ke,exports.version="0.7.0";
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="undefined"!=typeof window,t="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")();function n(e){return"string"==typeof e}function o(e){return"boolean"==typeof e}function r(e){return"function"==typeof e}const i=Array.isArray;function s(e){return"[object Object]"===toString.call(e)}function a(e){return"[object Promise]"===toString.call(e)}function l(e){return r(e)&&0===e.name.indexOf("bound ")&&!e.hasOwnProperty("prototype")}const c=Object.defineProperty,p=Object.defineProperties,u=Object.prototype.hasOwnProperty;function d(e,t=null,...o){const r=t&&n(t)?` app ${t}:`:"";n(e)?console.error(`[micro-app]${r} ${e}`,...o):console.error(`[micro-app]${r}`,e,...o)}function h(e,t=null,...o){const r=t&&n(t)?` app ${t}:`:"";n(e)?console.warn(`[micro-app]${r} ${e}`,...o):console.warn(`[micro-app]${r}`,e,...o)}function m(e,...t){Promise.resolve().then(e.bind(null,...t))}function f(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function _(e,t=null){if(!n(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=new URL(f(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return d(e,t),""}}function A(e){return n(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function b(e){const{origin:t,pathname:n}=new URL(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function w(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:new URL(e,b(f(t))).toString()}function y(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 g=t.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let E=null;function v(e){E=e}let N=!1;function C(e){N&&E===e||(N=!0,v(e),m((()=>{N=!1,v(null)})))}function P(){return E}function O(){v(null)}function D(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function M(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n}function S(e,t,n){if(t.innerHTML="",n){const n=e.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),t.appendChild(o)}else Array.from(e.childNodes).forEach((e=>{t.appendChild(e)}))}function R(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function I(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)}function U(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}var L,x,T,W;!function(e){e.NAME="name",e.URL="url"}(L||(L={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(x||(x={})),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"}(T||(T={})),function(e){e.KEEP_ALIVE_SHOW="KEEP_ALIVE_SHOW",e.KEEP_ALIVE_HIDDEN="KEEP_ALIVE_HIDDEN"}(W||(W={}));const $="window,self,globalThis,Array,Object,String,Boolean,Math,Number,Symbol,Date,Promise,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,Document,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,location,navigator,undefined";function k(e,t=null,n={}){return r(Ge.fetch)?Ge.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}const B={};function F(){if(e){const e=Element.prototype.setAttribute,t=Element.prototype.appendChild,n=Element.prototype.insertBefore,o=Element.prototype.replaceChild,r=Element.prototype.removeChild,i=Element.prototype.append,s=Element.prototype.prepend,a=Element.prototype.cloneNode,l=Document.prototype.createElement,c=Document.prototype.createElementNS,p=Document.prototype.createDocumentFragment,u=Document.prototype.querySelector,d=Document.prototype.querySelectorAll,h=Document.prototype.getElementById,m=Document.prototype.getElementsByClassName,f=Document.prototype.getElementsByTagName,_=Document.prototype.getElementsByName,A=new Proxy(Image,{construct(e,t){const n=new e(...t);return n.__MICRO_APP_NAME__=P(),n}}),b=Function("return window")(),w=Function("return document")(),y="noModule"in document.createElement("script"),g=w.body.querySelector("#micro-app-template-style"),E=b.addEventListener,v=b.removeEventListener,N=b.setInterval,C=b.setTimeout,O=b.clearInterval,D=b.clearTimeout,M=w.addEventListener,S=w.removeEventListener;window.__MICRO_APP_BASE_APPLICATION__=!0,Object.assign(B,{rawSetAttribute:e,rawAppendChild:t,rawInsertBefore:n,rawReplaceChild:o,rawRemoveChild:r,rawAppend:i,rawPrepend:s,rawCloneNode:a,rawCreateElement:l,rawCreateElementNS:c,rawCreateDocumentFragment:p,rawQuerySelector:u,rawQuerySelectorAll:d,rawGetElementById:h,rawGetElementsByClassName:m,rawGetElementsByTagName:f,rawGetElementsByName:_,ImageProxy:A,rawWindow:b,rawDocument:w,supportModuleScript:y,templateStyle:g,rawWindowAddEventListener:E,rawWindowRemoveEventListener:v,rawSetInterval:N,rawSetTimeout:C,rawClearInterval:O,rawClearTimeout:D,rawDocumentAddEventListener:M,rawDocumentRemoveEventListener:S})}}function H(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function K(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^((data|blob):|#)/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!D())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),f(t.join("/")+"/")}(o)),`url("${w(r,t)}")`}))}function j(e,t,n){const o=G(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function G(e,t){let n="";for(const o of e)switch(o.constructor.name){case"CSSStyleRule":n+=H(o,t);break;case"CSSMediaRule":n+=j(o,t,"media");break;case"CSSSupportsRule":n+=j(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function q(e,t,n,o,r,i){var s,a;if(!t.__MICRO_APP_HAS_SCOPED__){let l=K(G(Array.from(null!==(a=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==a?a:[]),o),r,n,i);D()&&(l=l.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=l,t.__MICRO_APP_HAS_SCOPED__=!0}}function V(e,t){if(t.scopecss){const n=`${Ge.tagName}[name=${t.name}]`;let o=B.templateStyle;if(o||(B.templateStyle=o=M("style"),o.setAttribute("id","micro-app-template-style"),B.rawDocument.body.appendChild(o),o.sheet.disabled=!0),e.textContent)o.textContent=e.textContent,q(o,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__),o.textContent="";else{const o=new MutationObserver((function(){var r,i;o.disconnect(),!e.textContent&&(null===(i=null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||q(e,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__)}));o.observe(e,{childList:!0})}}return e}function z(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function Q(e){const t=new CustomEvent("load");z(t,e),r(e.onload)?e.onload(t):e.dispatchEvent(t)}function J(e){const t=new CustomEvent("error");z(t,e),r(e.onerror)?e.onerror(t):e.dispatchEvent(t)}const X=new Map;function Y(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){if(i=w(i,n.url),o)return{url:i,info:{code:"",isGlobal:e.hasAttribute("global")}};s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),n.source.links.set(i,{code:"",placeholder:s,isGlobal:e.hasAttribute("global")})}else r&&["prefetch","preload","prerender","icon","apple-touch-icon"].includes(r)?o?s=document.createComment(`link element with rel=${r}${i?" & href="+i:""} removed by micro-app`):t.removeChild(e):i&&e.setAttribute("href",w(i,n.url));return o?{replaceComment:s}:s?t.replaceChild(s,e):void 0}function Z(e,t,n){const o=Array.from(t.source.links.entries()),r=[];for(const[e]of o){const n=X.get(e);n?r.push(n):r.push(k(e,t.name))}y(r,(e=>{!function(e,t,n,o,r){t.isGlobal&&!X.has(e)&&X.set(e,n);const i=M("style");i.textContent=n,i.__MICRO_APP_LINK_PATH__=e,i.setAttribute("data-origin-href",e),t.placeholder.parentNode?t.placeholder.parentNode.replaceChild(V(i,r),t.placeholder):o.appendChild(V(i,r));t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{d(e,t.name)}),(()=>{t.onLoad(e)}))}const ee=new Map;function te(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module"].includes(e.type)||e.hasAttribute("ignore"))return null;if(B.supportModuleScript&&e.noModule||!B.supportModuleScript&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=w(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t="inline-"+Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else o||(r=document.createComment("script element removed by micro-app"))}return o?{replaceComment:r}:t.replaceChild(r,e)}function ne(e,t){const n=Array.from(t.source.scripts.entries()),o=[],r=[];for(const[e,i]of n)if(i.isExternal){const n=ee.get(e);n?i.code=n:i.defer||i.async||(o.push(k(e,t.name)),r.push([e,i]))}o.length?y(o,(e=>{!function(e,t,n){t.isGlobal&&!ee.has(e)&&ee.set(e,n);t.code=n}(r[e.index][0],r[e.index][1],e.data)}),(e=>{d(e,t.name)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function oe(e,t,n,o,r){var i;try{const s=se(e,t,n.code,n.module);if(t.inline||n.module){const a=M("script");if(re(e,s,n.module,a,r),o)return a;null===(i=t.container)||void 0===i||i.querySelector("micro-app-body").appendChild(a)}else if(ie(s,n),o)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error(`[micro-app from runScript] app ${t.name}: `,e)}}function re(e,t,n,o,r){if(n){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e),o.setAttribute("type","module"),r&&(r.moduleCount&&r.moduleCount--,o.onload=r.bind(o,0===r.moduleCount))}else o.textContent=t;e.startsWith("inline-")||o.setAttribute("data-origin-src",e)}function ie(e,t){t.code2Function||(t.code2Function=new Function(e)),t.code2Function.call(window)}function se(e,t,n,o){return s(Ge.plugins)&&(n=function(e,t,n,o){var a;if(i(o.global))for(const n of o.global)s(n)&&r(n.loader)&&(t=n.loader(t,e,n.options));if(i(null===(a=o.modules)||void 0===a?void 0:a[n]))for(const i of o.modules[n])s(i)&&r(i.loader)&&(t=i.loader(t,e,i.options));return t}(e,n,t.name,Ge.plugins)),t.sandBox&&!o?(B.rawWindow.__MICRO_APP_PROXY_WINDOW__=t.sandBox.proxyWindow,`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${$}){;${n}\n}).call(proxyWindow,${$})}})(window.__MICRO_APP_PROXY_WINDOW__);`):n}function ae(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{ae(e,t)}));for(const n of o)n instanceof HTMLLinkElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")?n.hasAttribute("href")&&n.setAttribute("href",w(n.getAttribute("href"),t.url)):Y(n,e,t):n instanceof HTMLStyleElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&V(n,t):n instanceof HTMLScriptElement?te(n,e,t):n instanceof HTMLMetaElement||n instanceof HTMLTitleElement?e.removeChild(n):n instanceof HTMLImageElement&&n.hasAttribute("src")&&n.setAttribute("src",w(n.getAttribute("src"),t.url))}function le(e,t){const n=function(e){const t=M("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),r=n.querySelector("micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),d(e,t.name)}ae(n,t),t.source.links.size?Z(n,t,o):t.onLoad(n),t.source.scripts.size?ne(n,t):t.onLoad(n)}const ce=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(d("event-center: Invalid name"),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if(!r(t))return d("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&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&&(r(t)?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if(!s(t))return d("event-center: data must be object");let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}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 pe(e,t){return n(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class ue{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),ce.on("global",e,t)}removeGlobalDataListener(e){r(e)&&ce.off("global",e)}setGlobalData(e){O(),ce.dispatch("global",e)}getGlobalData(){return ce.getData("global")}clearGlobalDataListener(){const e=this.appName,t=ce.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 de extends ue{addDataListener(e,t,n){ce.on(pe(A(e),!1),t,n)}removeDataListener(e,t){r(t)&&ce.off(pe(A(e),!1),t)}getData(e,t=!1){return ce.getData(pe(A(e),t))}setData(e,t){ce.dispatch(pe(A(e),!0),t)}clearDataListener(e){ce.off(pe(A(e),!1))}}class he extends ue{constructor(e){super(),this.appName=A(e),!this.appName&&d(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,ce.on(pe(this.appName,!0),e,t)}removeDataListener(e){r(e)&&ce.off(pe(this.appName,!0),e)}getData(){return ce.getData(pe(this.appName,!0))}dispatch(e){O(),ce.dispatch(pe(this.appName,!1),e);const t=Oe.get(this.appName);if((null==t?void 0:t.container)&&s(e)){const n=new CustomEvent("datachange",{detail:{data:e}});U(t.container).dispatchEvent(n)}}clearDataListener(){ce.off(pe(this.appName,!0))}}function me(e,t){if(t.__MICRO_APP_BOUND_WINDOW_FUNCTION)return t.__MICRO_APP_BOUND_WINDOW_FUNCTION;if(!function(e){var t;if(o(e.__MICRO_APP_ISCONSTRUCTOR))return e.__MICRO_APP_ISCONSTRUCTOR;const n=e.toString(),r=(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 e.__MICRO_APP_ISCONSTRUCTOR=r}(t)&&!function(e){return o(e.__MICRO_APP_ISBOUND_FUNCTION)?e.__MICRO_APP_ISBOUND_FUNCTION:e.__MICRO_APP_ISBOUND_FUNCTION=l(e)}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&c(n,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t.__MICRO_APP_BOUND_WINDOW_FUNCTION=n}return t}const fe=new Map;let _e=!1;const Ae=new Map;function be(){const{rawDocument:e,rawDocumentAddEventListener:t,rawDocumentRemoveEventListener:n}=B;!_e&&function(){if(_e=!0,Object.getOwnPropertyDescriptor(document,"onclick"))return h("Cannot redefine document property onclick");const e=document.onclick;document.onclick=null;let t=!1;function n(e){fe.forEach((t=>{r(t)&&t.call(document,e)}))}c(document,"onclick",{configurable:!0,enumerable:!0,get(){const e=P();return e?fe.get(e):fe.get("base")},set(e){const o=P();o?fe.set(o,e):fe.set("base",e),!t&&r(e)&&(t=!0,B.rawDocumentAddEventListener.call(B.rawDocument,"click",n,!1))}}),e&&(document.onclick=e)}(),document.addEventListener=function(n,o,r){var i;const s=P();if(s&&(!(null===(i=Oe.get(s))||void 0===i?void 0:i.umdMode)||!l(o))){const e=Ae.get(s);if(e){const t=e.get(n);t?t.add(o):e.set(n,new Set([o]))}else Ae.set(s,new Map([[n,new Set([o])]]));o&&(o.__MICRO_APP_MARK_OPTIONS__=r)}t.call(e,n,o,r)},document.removeEventListener=function(t,o,r){var i;const s=P();if(s&&(!(null===(i=Oe.get(s))||void 0===i?void 0:i.umdMode)||!l(o))){const e=Ae.get(s);if(e){const n=e.get(t);(null==n?void 0:n.size)&&n.has(o)&&n.delete(o)}}n.call(e,t,o,r)}}const we=["unmount","appstate-change"];function ye(e,t){return we.includes(e)?`${e}-${t.__MICRO_APP_NAME__}`:e}const ge=["System","__cjsWrapper"],Ee=["location"],ve=["window","self","globalThis"];class Ne{constructor(e,t){this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.active=!1,this.microAppWindow={},this.getScopeProperties(e),this.proxyWindow=this.createProxyWindow(),this.initMicroAppWindow(this.microAppWindow,e,t),Object.assign(this,function(e){const t=e.__MICRO_APP_NAME__,n=new Map,o=new Map,r=new Map,{rawWindow:i,rawDocument:s,rawWindowAddEventListener:a,rawWindowRemoveEventListener:l,rawSetInterval:c,rawSetTimeout:p,rawClearInterval:u,rawClearTimeout:d,rawDocumentRemoveEventListener:h}=B;e.addEventListener=function(t,o,r){t=ye(t,e);const s=n.get(t);s?s.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(i,t,o,r)},e.removeEventListener=function(t,o,r){t=ye(t,e);const s=n.get(t);(null==s?void 0:s.size)&&s.has(o)&&s.delete(o),l.call(i,t,o,r)},e.setInterval=function(e,t,...n){const r=c.call(i,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const o=p.call(i,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.clearInterval=function(e){o.delete(e),u.call(i,e)},e.clearTimeout=function(e){r.delete(e),d.call(i,e)};const m=new Map,f=new Map;let _,A=new Map,b=new Map;return{recordUmdEffect:()=>{n.forEach(((e,t)=>{e.size&&m.set(t,new Set(e))})),o.size&&(A=new Map(o)),r.size&&(b=new Map(r)),_=fe.get(t);const e=Ae.get(t);e&&e.forEach(((e,t)=>{e.size&&f.set(t,new Set(e))}))},rebuildUmdEffect:()=>{m.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),A.forEach((t=>{e.setInterval(t.handler,t.timeout,...t.args)})),b.forEach((t=>{e.setTimeout(t.handler,t.timeout,...t.args)})),_&&fe.set(t,_),v(t),f.forEach(((e,t)=>{for(const n of e)document.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),v(null)},releaseEffect:()=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(i,t,n)})),n.clear()),o.size&&(o.forEach(((e,t)=>{u.call(i,t)})),o.clear()),r.size&&(r.forEach(((e,t)=>{d.call(i,t)})),r.clear()),fe.delete(t);const e=Ae.get(t);e&&(e.forEach(((e,t)=>{for(const n of e)h.call(s,t,n)})),e.clear())}}}(this.microAppWindow))}start(e){this.active||(this.active=!0,this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e,B.rawWindow._babelPolyfill&&(B.rawWindow._babelPolyfill=!1),1==++Ne.activeCount&&be())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microAppWindow.microApp.clearDataListener(),this.microAppWindow.microApp.clearGlobalDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(B.rawWindow,e)})),this.escapeKeys.clear(),0==--Ne.activeCount&&(document.addEventListener=B.rawDocumentAddEventListener,document.removeEventListener=B.rawDocumentRemoveEventListener))}recordUmdSnapshot(){this.microAppWindow.__MICRO_APP_UMD_MODE__=!0,this.recordUmdEffect(),function(e){const t=e.appName;e.umdDataListeners={global:new Set,normal:new Set};const n=ce.eventList.get("global");if(n)for(const o of n.callbacks)t===o.__APP_NAME__&&e.umdDataListeners.global.add(o);const o=ce.eventList.get(pe(t,!0));o&&(e.umdDataListeners.normal=new Set(o.callbacks))}(this.microAppWindow.microApp),this.recordUmdinjectedValues=new Map,this.injectedKeys.forEach((e=>{this.recordUmdinjectedValues.set(e,Reflect.get(this.microAppWindow,e))}))}rebuildUmdSnapshot(){this.recordUmdinjectedValues.forEach(((e,t)=>{Reflect.set(this.proxyWindow,t,e)})),this.rebuildUmdEffect(),function(e){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__)}(this.microAppWindow.microApp)}getScopeProperties(e){var t;if(s(Ge.plugins)){if(i(Ge.plugins.global))for(const e of Ge.plugins.global)s(e)&&(i(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),i(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if(i(null===(t=Ge.plugins.modules)||void 0===t?void 0:t[e]))for(const t of Ge.plugins.modules[e])s(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}createProxyWindow(){const e=B.rawWindow,t=new Map;return new Proxy(this.microAppWindow,{get:(t,o)=>{if(Reflect.has(t,o)||n(o)&&/^__MICRO_APP_/.test(o)||this.scopeProperties.includes(o))return Reflect.get(t,o);const i=Reflect.get(e,o);return r(i)?me(e,i):i},set:(t,n,o)=>{if(this.active){if(Ee.includes(n))Reflect.set(e,n,o);else if(u.call(t,n)||!u.call(e,n)||this.scopeProperties.includes(n))Reflect.set(t,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(e,n),{configurable:i,enumerable:s,writable:a,set:l}=r;c(t,n,{value:o,configurable:i,enumerable:s,writable:null!=a?a:!!l}),this.injectedKeys.add(n)}(this.escapeProperties.includes(n)||ge.includes(n)&&!Reflect.has(e,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(e,n,o),this.escapeKeys.add(n))}return!0},has:(t,n)=>this.scopeProperties.includes(n)?n in t:n in t||n in e,getOwnPropertyDescriptor:(n,o)=>{if(u.call(n,o))return t.set(o,"target"),Object.getOwnPropertyDescriptor(n,o);if(u.call(e,o)){t.set(o,"rawWindow");const n=Object.getOwnPropertyDescriptor(e,o);return n&&!n.configurable&&(n.configurable=!0),n}},defineProperty:(n,o,r)=>"rawWindow"===t.get(o)?Reflect.defineProperty(e,o,r):Reflect.defineProperty(n,o,r),ownKeys:t=>Reflect.ownKeys(e).concat(Reflect.ownKeys(t)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(t,n)=>!u.call(t,n)||(this.injectedKeys.has(n)&&this.injectedKeys.delete(n),this.escapeKeys.has(n)&&Reflect.deleteProperty(e,n),Reflect.deleteProperty(t,n))})}initMicroAppWindow(e,t,n){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=t,e.__MICRO_APP_PUBLIC_PATH__=b(n),e.__MICRO_APP_WINDOW__=e,e.microApp=new he(t),e.rawWindow=B.rawWindow,e.rawDocument=B.rawDocument,e.removeDomScope=O,e.hasOwnProperty=t=>u.call(e,t)||u.call(B.rawWindow,t),this.setMappingPropertiesWithRawDescriptor(e),this.setHijackProperties(e,t)}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=B.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),c(e,"top",this.createDescriptorFormicroAppWindow("top",t)),c(e,"parent",this.createDescriptorFormicroAppWindow("parent",n)),ve.forEach((t=>{c(e,t,this.createDescriptorFormicroAppWindow(t,this.proxyWindow))}))}createDescriptorFormicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(B.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}setHijackProperties(e,t){let n,o;p(e,{document:{get:()=>(C(t),B.rawDocument),configurable:!1,enumerable:!0},eval:{get:()=>(C(t),n||eval),set:e=>{n=e},configurable:!0,enumerable:!1},Image:{get:()=>(C(t),o||B.ImageProxy),set:e=>{o=e},configurable:!0,enumerable:!1}})}}function Ce(e,t,n,o){var i;if(!e)return d(`element does not exist in lifecycle ${n}`,t);e=U(e),O();const s=Object.assign({name:t,container:e},o&&{error:o}),a=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),r(null===(i=Ge.lifeCycles)||void 0===i?void 0:i[n])&&Ge.lifeCycles[n](a),e.dispatchEvent(a)}function Pe(e,t,n={}){const o=new CustomEvent(`${e}-${t}`,{detail:n});window.dispatchEvent(o)}Ne.activeCount=0;const Oe=new Map;class De{constructor({name:e,url:t,ssrUrl:n,container:o,inline:r,scopecss:i,useSandbox:s,baseroute:a}){this.state=x.NOT_LOADED,this.keepAliveState=null,this.keepAliveContainer=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.libraryName=null,this.umdMode=!1,this.isPrefetch=!1,this.container=null,this.baseroute="",this.sandBox=null,this.container=null!=o?o:null,this.inline=null!=r&&r,this.baseroute=null!=a?a:"",this.ssrUrl=null!=n?n:"",this.name=e,this.url=t,this.useSandbox=s,this.scopecss=this.useSandbox&&i,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Ne(e,t))}loadSourceCode(){var e;this.state=x.LOADING_SOURCE_CODE,k((e=this).ssrUrl||e.url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),d(t,e.name)}le(t=t.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>"))),e)})).catch((t=>{d(`Failed to fetch data from ${e.url}, micro-app stop rendering`,e.name,t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||x.UNMOUNT===this.state)return;this.state=x.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,x.UNMOUNT!==this.state&&(this.onerror(e),this.state=x.LOAD_SOURCE_ERROR)}mount(e,t,n){var i,s,a;if(o(t)&&t!==this.inline&&(this.inline=t),this.container=null!==(i=this.container)&&void 0!==i?i:e,this.baseroute=null!=n?n:this.baseroute,2!==this.loadSourceLevel)return void(this.state=x.LOADING_SOURCE_CODE);let l;if(Ce(this.container,this.name,T.BEFOREMOUNT),this.state=x.MOUNTING,S(this.source.html,this.container,!this.umdMode),null===(s=this.sandBox)||void 0===s||s.start(this.baseroute),this.umdMode){null===(a=this.sandBox)||void 0===a||a.rebuildUmdSnapshot();try{l=this.umdHookMount()}catch(e){d("an error occurred in the mount function \n",this.name,e)}this.handleMounted(l)}else{let e=!1;!function(e,t,n){const o=Array.from(e.entries()),r=[],i=[];for(const[e,s]of o)s.isDynamic||(s.defer||s.async?(s.isExternal&&!s.code?r.push(k(e,t.name)):r.push(s.code),i.push([e,s]),s.module&&(n.moduleCount=n.moduleCount?++n.moduleCount:1)):(oe(e,t,s,!1),n(!1)));r.length?y(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(e=>{n.errorCount=n.errorCount?++n.errorCount:1,d(e,t.name)}),(()=>{i.forEach((([e,o])=>{o.code&&(oe(e,t,o,!1,n),!o.module&&n(!1))})),n(void 0===n.moduleCount||n.errorCount===r.length)})):n(!0)}(this.source.scripts,this,(t=>{var n;if(!this.umdMode){const{mount:e,unmount:t}=this.getUmdLibraryHooks();if(r(e)&&r(t)){this.umdHookMount=e,this.umdHookUnmount=t,this.umdMode=!0,null===(n=this.sandBox)||void 0===n||n.recordUmdSnapshot();try{l=this.umdHookMount()}catch(e){d("an error occurred in the mount function \n",this.name,e)}}}e||!0!==t&&!this.umdMode||(e=!0,this.handleMounted(l))}))}}handleMounted(e){a(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>this.onerror(e))):this.dispatchMountedEvent()}dispatchMountedEvent(){x.UNMOUNT!==this.state&&(this.state=x.MOUNTED,Ce(this.container,this.name,T.MOUNTED))}unmount(e,t){let n;if(this.state===x.LOAD_SOURCE_ERROR&&(e=!0),this.state=x.UNMOUNT,this.keepAliveState=null,this.keepAliveContainer=null,this.umdHookUnmount)try{n=this.umdHookUnmount()}catch(e){d("an error occurred in the unmount function \n",this.name,e)}Pe("unmount",this.name),this.handleUnmounted(e,n,t)}handleUnmounted(e,t,n){a(t)?t.then((()=>this.actionsForUnmount(e,n))).catch((()=>this.actionsForUnmount(e,n))):this.actionsForUnmount(e,n)}actionsForUnmount(e,t){var n;null===(n=this.sandBox)||void 0===n||n.stop(),e?this.actionsForCompletelyDestroy():this.umdMode&&this.container.childElementCount&&S(this.container,this.source.html,!1),Ce(this.container,this.name,T.UNMOUNT),this.container.innerHTML="",this.container=null,t&&t()}actionsForCompletelyDestroy(){!this.useSandbox&&this.umdMode&&delete window[this.libraryName],Oe.delete(this.name)}hiddenKeepAliveApp(){const e=this.container;S(this.container,this.keepAliveContainer?this.keepAliveContainer:this.keepAliveContainer=document.createElement("div"),!1),this.container=this.keepAliveContainer,this.keepAliveState=W.KEEP_ALIVE_HIDDEN,Pe("appstate-change",this.name,{appState:"afterhidden"}),Ce(e,this.name,T.AFTERHIDDEN)}showKeepAliveApp(e){Pe("appstate-change",this.name,{appState:"beforeshow"}),Ce(e,this.name,T.BEFORESHOW),S(this.container,e,!1),this.container=e,this.keepAliveState=W.KEEP_ALIVE_SHOW,Pe("appstate-change",this.name,{appState:"aftershow"}),Ce(this.container,this.name,T.AFTERSHOW)}onerror(e){Ce(this.container,this.name,T.ERROR,e)}getAppState(){return this.state}getKeepAliveState(){return this.keepAliveState}getUmdLibraryHooks(){var e,t;if(x.UNMOUNT!==this.state){const n=null!==(t=null===(e=this.sandBox)||void 0===e?void 0:e.proxyWindow)&&void 0!==t?t:B.rawWindow;return this.libraryName=U(this.container).getAttribute("library")||`micro-app-${this.name}`,"object"==typeof n[this.libraryName]?n[this.libraryName]:{}}return{}}}const Me=new WeakMap;function Se(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return Me.set(t,e),e}return n.scopecss&&!t.hasAttribute("ignore")?V(t,n):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return Me.set(t,e),e}if(t.hasAttribute("ignore"))return t;const{url:o,info:r,replaceComment:i}=Y(t,e,n,!0);if(o&&r){const e=M("style");return e.__MICRO_APP_LINK_PATH__=o,function(e,t,n,o,r){if(n.source.links.has(e))return r.textContent=n.source.links.get(e).code,V(r,n),void m((()=>Q(o)));if(X.has(e)){const i=X.get(e);return t.code=i,n.source.links.set(e,t),r.textContent=i,V(r,n),void m((()=>Q(o)))}k(e,n.name).then((i=>{t.code=i,n.source.links.set(e,t),t.isGlobal&&X.set(e,i),r.textContent=i,V(r,n),Q(o)})).catch((e=>{d(e,n.name),J(o)}))}(o,r,n,t,e),Me.set(t,e),e}return i?(Me.set(t,i),i):t}if(t instanceof HTMLScriptElement){const{replaceComment:o,url:r,info:i}=te(t,e,n,!0)||{};if(r&&i){if(i.isExternal){const e=function(e,t,n,o){const r=()=>Q(o);if(n.source.scripts.has(e)){const t=n.source.scripts.get(e);return!t.module&&m(r),oe(e,n,t,!0,r)}if(ee.has(e)){const o=ee.get(e);return t.code=o,n.source.scripts.set(e,t),!t.module&&m(r),oe(e,n,t,!0,r)}let i;return i=n.inline||t.module?M("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),k(e,n.name).then((s=>{t.code=s,n.source.scripts.set(e,t),t.isGlobal&&ee.set(e,s);try{s=se(e,n,s,t.module),n.inline||t.module?re(e,s,t.module,i,r):ie(s,t)}catch(t){console.error(`[micro-app from runDynamicScript] app ${n.name}: `,t,e)}!t.module&&Q(o)})).catch((e=>{d(e,n.name),J(o)})),i}(r,i,n,t);return Me.set(t,e),e}{const e=oe(r,n,i,!0);return Me.set(t,e),e}}return o?(Me.set(t,o),o):t}return t}function Re(e,t,n,o,r){if(n===document.head){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?B.rawAppendChild.call(i,o):t!==B.rawRemoveChild||i.contains(o)?t===B.rawAppend||t===B.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n===document.body){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?B.rawAppendChild.call(i,o):t!==B.rawRemoveChild||i.contains(o)?t===B.rawAppend||t===B.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===B.rawAppend||t===B.rawPrepend?t.call(n,o):t.call(n,o,r)}function Ie(e){var t;return null!==(t=Me.get(e))&&void 0!==t?t:e}function Ue(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Oe.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?Re(r,o,e,Se(e,t,r),n&&Ie(n)):o===B.rawAppend||o===B.rawPrepend?o.call(e,t):o.call(e,t,n)}if(o===B.rawAppend||o===B.rawPrepend){const n=P();if(!(t instanceof Node)&&n){const r=Oe.get(n);if(null==r?void 0:r.container){if(e===document.head)return o.call(r.container.querySelector("micro-app-head"),t);if(e===document.body)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function Le(){!function(){const e=B.rawDocument;function t(t){var n,o,r;const i=P();return i&&t&&!I(t)&&e===this?null!==(r=null===(o=null===(n=Oe.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:B.rawQuerySelector.call(this,t)}function n(t){var n,o,r;const i=P();return i&&t&&!I(t)&&e===this?null!==(r=null===(o=null===(n=Oe.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:B.rawQuerySelectorAll.call(this,t)}Document.prototype.createElement=function(e,t){return xe(B.rawCreateElement.call(this,e,t))},Document.prototype.createElementNS=function(e,t,n){return xe(B.rawCreateElementNS.call(this,e,t,n))},Document.prototype.createDocumentFragment=function(){return xe(B.rawCreateDocumentFragment.call(this))},Document.prototype.querySelector=t,Document.prototype.querySelectorAll=n,Document.prototype.getElementById=function(e){if(!P()||R(e))return B.rawGetElementById.call(this,e);try{return t.call(this,`#${e}`)}catch(t){return B.rawGetElementById.call(this,e)}},Document.prototype.getElementsByClassName=function(e){if(!P()||R(e))return B.rawGetElementsByClassName.call(this,e);try{return n.call(this,`.${e}`)}catch(t){return B.rawGetElementsByClassName.call(this,e)}},Document.prototype.getElementsByTagName=function(e){var t;const o=P();if(!o||I(e)||R(e)||!(null===(t=Oe.get(o))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return B.rawGetElementsByTagName.call(this,e);try{return n.call(this,e)}catch(t){return B.rawGetElementsByTagName.call(this,e)}},Document.prototype.getElementsByName=function(e){if(!P()||R(e))return B.rawGetElementsByName.call(this,e);try{return n.call(this,`[name=${e}]`)}catch(t){return B.rawGetElementsByName.call(this,e)}}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if(s(t)){const e={};Object.getOwnPropertyNames(t).forEach((o=>{n(o)&&0===o.indexOf("__")||(e[o]=t[o])})),this.data=e}else"[object Object]"!==t&&h("property data must be an object",this.getAttribute("name"));else if((("src"===e||"srcset"===e)&&/^(img|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Oe.has(this.__MICRO_APP_NAME__)){const n=Oe.get(this.__MICRO_APP_NAME__);B.rawSetAttribute.call(this,e,w(t,n.url))}else B.rawSetAttribute.call(this,e,t)},Element.prototype.appendChild=function(e){return Ue(this,e,null,B.rawAppendChild)},Element.prototype.insertBefore=function(e,t){return Ue(this,e,t,B.rawInsertBefore)},Element.prototype.replaceChild=function(e,t){return Ue(this,e,t,B.rawReplaceChild)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)Ue(this,e[t],null,B.rawAppend),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)Ue(this,e[t-1],null,B.rawPrepend),t--},Element.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Oe.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?Re(t,B.rawRemoveChild,this,Ie(e)):B.rawRemoveChild.call(this,e)}return B.rawRemoveChild.call(this,e)},Element.prototype.cloneNode=function(e){const t=B.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t}}function xe(e){const t=P();return t&&(e.__MICRO_APP_NAME__=t),e}function Te(){v(null),Document.prototype.createElement=B.rawCreateElement,Document.prototype.createElementNS=B.rawCreateElementNS,Document.prototype.createDocumentFragment=B.rawCreateDocumentFragment,Document.prototype.querySelector=B.rawQuerySelector,Document.prototype.querySelectorAll=B.rawQuerySelectorAll,Document.prototype.getElementById=B.rawGetElementById,Document.prototype.getElementsByClassName=B.rawGetElementsByClassName,Document.prototype.getElementsByTagName=B.rawGetElementsByTagName,Document.prototype.getElementsByName=B.rawGetElementsByName,Element.prototype.setAttribute=B.rawSetAttribute,Element.prototype.appendChild=B.rawAppendChild,Element.prototype.insertBefore=B.rawInsertBefore,Element.prototype.replaceChild=B.rawReplaceChild,Element.prototype.removeChild=B.rawRemoveChild,Element.prototype.append=B.rawAppend,Element.prototype.prepend=B.rawPrepend,Element.prototype.cloneNode=B.rawCloneNode}let We=!1;function $e(){ke(),Oe.forEach((e=>{e.container&&U(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Oe.clear(),Be.size&&(Be.clear(),Te())}function ke(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",$e,!1)}const Be=new Map;function Fe(e){class t extends HTMLElement{constructor(){super(),this.isWating=!1,this.cacheData=null,this.hasConnected=!1,this.appName="",this.appUrl="",this.ssrUrl="",this.version="0.7.1",this.handleAttributeUpdate=()=>{this.isWating=!1;const e=A(this.getAttribute("name")),t=_(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Oe.get(e);if(e!==this.appName&&n&&x.UNMOUNT!==n.getAppState()&&W.KEEP_ALIVE_HIDDEN!==n.getKeepAliveState()&&!n.isPrefetch)return this.setAttribute("name",this.appName),d(`app name conflict, an app named ${e} is running`,this.appName);e===this.appName&&t===this.appUrl||(e===this.appName?this.handleUnmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)},this.querySelector("micro-app-head")||this.performWhenFirstCreated()}static get observedAttributes(){return["name","url"]}connectedCallback(){this.hasConnected=!0,Be.has(this)||this.performWhenFirstCreated(),m((()=>Ce(this,this.appName,T.CREATED))),this.initialMount()}disconnectedCallback(){this.hasConnected=!1,this.getKeepAliveModeResult()?this.handleHiddenKeepAliveApp():(Be.delete(this),this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{0===Be.size&&Te()})))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===L.NAME?"appName":"appUrl"]!==n)if(e!==L.URL||this.appUrl)if(e!==L.NAME||this.appName)this.isWating||(this.isWating=!0,m(this.handleAttributeUpdate));else{const e=A(n);if(!e)return d(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(Ge.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=_(n,this.appName)))return d(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.hasConnected&&this.initialMount()}performWhenFirstCreated(){1===Be.set(this,!0).size&&(Le(),function(){if(!We){We=!0;const e=M("style");e.setAttribute("type","text/css"),e.textContent=`\n${Ge.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,B.rawDocument.head.appendChild(e)}}(),ke(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",$e,!1))}initialMount(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&r(this.attachShadow)&&this.attachShadow({mode:"open"}),this.getDisposeResult("ssr")?this.ssrUrl=w(B.rawWindow.location.pathname,this.appUrl):this.ssrUrl&&(this.ssrUrl=""),Oe.has(this.appName)){const e=Oe.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===W.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t!==n||!e.isPrefetch&&e.getAppState()!==x.UNMOUNT?e.isPrefetch||e.getAppState()===x.UNMOUNT?(h(`the ${e.isPrefetch?"prefetch":"unmounted"} app with url: ${t} is replaced by a new app`,this.appName),this.handleCreateApp()):d(`app name conflict, an app named ${this.appName} is running`,this.appName):this.handleAppMount(e)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.getDisposeResult("ssr")?this.ssrUrl=w(B.rawWindow.location.pathname,t):this.ssrUrl&&(this.ssrUrl=""),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.getKeepAliveState()===W.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):d(`app name conflict, an app named ${this.appName} is running`,this.appName):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleAppMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!n(t)||!t)||(d(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleAppMount(e){e.isPrefetch=!1,m((()=>{var t;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),this.getBaseRouteCompatible())}))}handleCreateApp(){var e;Oe.has(this.appName)&&Oe.get(this.appName).actionsForCompletelyDestroy();const t=new De({name:this.appName,url:this.appUrl,ssrUrl:this.ssrUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),baseroute:this.getBaseRouteCompatible()});Oe.set(this.appName,t)}handleUnmount(e,t){const n=Oe.get(this.appName);n&&n.getAppState()!==x.UNMOUNT&&n.unmount(e,t)}handleHiddenKeepAliveApp(){const e=Oe.get(this.appName);e&&e.getAppState()!==x.UNMOUNT&&e.getKeepAliveState()!==W.KEEP_ALIVE_HIDDEN&&e.hiddenKeepAliveApp()}handleShowKeepAliveApp(e){m((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleSpecialProperties(e)||Ge[e])&&this.compatibleDisablSpecialProperties(e)}compatibleSpecialProperties(e){return"disableScopecss"===e?this.hasAttribute("disableScopecss")||this.hasAttribute("disable-scopecss"):"disableSandbox"===e?this.hasAttribute("disableSandbox")||this.hasAttribute("disable-sandbox"):this.hasAttribute(e)}compatibleDisablSpecialProperties(e){return"disableScopecss"===e?"false"!==this.getAttribute("disableScopecss")&&"false"!==this.getAttribute("disable-scopecss"):"disableSandbox"===e?"false"!==this.getAttribute("disableSandbox")&&"false"!==this.getAttribute("disable-sandbox"):"false"!==this.getAttribute(e)}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()}set data(e){this.appName?Ge.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Ge.getData(this.appName,!0):this.cacheData?this.cacheData:null}}window.customElements.define(e,t)}function He(t){if(!e)return d("preFetch is only supported in browser environment");g((()=>{r(t)&&(t=t()),function(e){const t=[];return i(e)&&e.forEach((e=>{s(e)&&(e.name=A(e.name),e.url=_(e.url,e.name),e.name&&e.url&&!Oe.has(e.name)&&t.push(e))})),t}(t).forEach((e=>{var t,n;const o=new De({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:Ge.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:Ge.disableSandbox)});o.isPrefetch=!0,Oe.set(e.name,o)}))}))}function Ke(e,t){const n=Oe.get(A(e));return new Promise((o=>{if(n)if(n.getAppState()===x.UNMOUNT||n.isPrefetch)(null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o();else if(n.getKeepAliveState()===W.KEEP_ALIVE_HIDDEN)(null==t?void 0:t.destroy)?n.unmount(!0,o):(null==t?void 0:t.clearAliveState)?n.unmount(!1,o):o();else{const e=U(n.container),r=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()},i=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()};if(e.addEventListener("unmount",r),e.addEventListener("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"),"string"==typeof t&&e.setAttribute("destroy",t),"string"==typeof n&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const t=e.getAttribute("keep-alive");e.removeAttribute("keep-alive"),e.parentNode.removeChild(e),e.setAttribute("keep-alive",t)}else e.parentNode.removeChild(e)}else h(`app ${e} does not exist`),o()}))}class je extends de{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=He}start(t){if(!e||!window.customElements)return d("micro-app is not supported in this environment");if(null==t?void 0:t.tagName){if(!/^micro-app(-\S+)?/.test(t.tagName))return d(`${t.tagName} is invalid tagName`);this.tagName=t.tagName}if(window.customElements.get(this.tagName))return h(`element ${this.tagName} is already defined`);if(F(),t&&s(t)&&(this.shadowDOM=t.shadowDOM,this.destroy=t.destroy,this.destory=t.destory,this.inline=t.inline,this.disableScopecss=t.disableScopecss,this.disableSandbox=t.disableSandbox,this.ssr=t.ssr,r(t.fetch)&&(this.fetch=t.fetch),s(t.lifeCycles)&&(this.lifeCycles=t.lifeCycles),t.preFetchApps&&He(t.preFetchApps),t.globalAssets&&(s(o=t.globalAssets)&&g((()=>{if(i(o.js)){const e=o.js.filter((e=>n(e)&&e.includes(".js")&&!ee.has(e))),t=[];e.forEach((e=>{t.push(k(e))})),y(t,(t=>{const n=e[t.index];ee.has(n)||ee.set(n,t.data)}),(e=>{d(e)}))}if(i(o.css)){const e=o.css.filter((e=>n(e)&&e.includes(".css")&&!X.has(e))),t=[];e.forEach((e=>{t.push(k(e))})),y(t,(t=>{const n=e[t.index];X.has(n)||X.set(n,t.data)}),(e=>{d(e)}))}}))),s(t.plugins))){const e=t.plugins.modules;if(s(e))for(const t in e){const n=A(t);n&&t!==n&&(e[n]=e[t],delete e[t])}this.plugins=t.plugins}var o;Fe(this.tagName)}}var Ge=new je;exports.EventCenterForMicroApp=he,exports.MicroApp=je,exports.default=Ge,exports.getActiveApps=function(e){const t=[];return Oe.forEach(((n,o)=>{x.UNMOUNT===n.getAppState()||n.isPrefetch||e&&W.KEEP_ALIVE_HIDDEN===n.getKeepAliveState()||t.push(o)})),t},exports.getAllApps=function(){return Array.from(Oe.keys())},exports.preFetch=He,exports.pureCreateElement=M,exports.removeDomScope=O,exports.unmountAllApps=function(e){return Array.from(Oe.keys()).reduce(((t,n)=>t.then((()=>Ke(n,e)))),Promise.resolve())},exports.unmountApp=Ke,exports.version="0.7.1";
//# sourceMappingURL=index.min.js.map

@@ -1,2 +0,2 @@

!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="0.7.0",n="undefined"!=typeof window,o="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")();function r(e){return"string"==typeof e}function i(e){return"boolean"==typeof e}function s(e){return"function"==typeof e}const a=Array.isArray;function l(e){return"[object Object]"===toString.call(e)}function c(e){return"[object Promise]"===toString.call(e)}function p(e){return s(e)&&0===e.name.indexOf("bound ")&&!e.hasOwnProperty("prototype")}const u=Object.defineProperty,d=Object.defineProperties,h=Object.prototype.hasOwnProperty;function m(e,t=null,...n){const o=t&&r(t)?` app ${t}:`:"";r(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function f(e,t=null,...n){const o=t&&r(t)?` app ${t}:`:"";r(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function _(e,...t){Promise.resolve().then(e.bind(null,...t))}function A(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function b(e,t=null){if(!r(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=new URL(A(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return m(e,t),""}}function w(e){return r(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function y(e){const{origin:t,pathname:n}=new URL(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function g(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:new URL(e,y(A(t))).toString()}function E(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{c(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 v=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let N=null;function C(e){N=e}let P=!1;function O(e){P&&N===e||(P=!0,C(e),_((()=>{P=!1,C(null)})))}function D(){return N}function M(){C(null)}function S(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function R(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n}function I(e,t,n){if(t.innerHTML="",n){const n=e.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),t.appendChild(o)}else Array.from(e.childNodes).forEach((e=>{t.appendChild(e)}))}function U(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function L(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)}function T(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}var x,W,$,k;!function(e){e.NAME="name",e.URL="url"}(x||(x={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(W||(W={})),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"}($||($={})),function(e){e.KEEP_ALIVE_SHOW="KEEP_ALIVE_SHOW",e.KEEP_ALIVE_HIDDEN="KEEP_ALIVE_HIDDEN"}(k||(k={}));const B="window,self,globalThis,Array,Object,String,Boolean,Math,Number,Symbol,Date,Promise,Function,Proxy,WeakMap,WeakRef,WeakSet,Set,Map,Reflect,Element,Node,Document,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,location,navigator,undefined";function F(e,t=null,n={}){return s(Ve.fetch)?Ve.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}const H={};function K(){if(n){const e=Element.prototype.setAttribute,t=Element.prototype.appendChild,n=Element.prototype.insertBefore,o=Element.prototype.replaceChild,r=Element.prototype.removeChild,i=Element.prototype.append,s=Element.prototype.prepend,a=Element.prototype.cloneNode,l=Document.prototype.createElement,c=Document.prototype.createElementNS,p=Document.prototype.createDocumentFragment,u=Document.prototype.querySelector,d=Document.prototype.querySelectorAll,h=Document.prototype.getElementById,m=Document.prototype.getElementsByClassName,f=Document.prototype.getElementsByTagName,_=Document.prototype.getElementsByName,A=new Proxy(Image,{construct(e,t){const n=new e(...t);return n.__MICRO_APP_NAME__=D(),n}}),b=Function("return window")(),w=Function("return document")(),y="noModule"in document.createElement("script"),g=w.body.querySelector("#micro-app-template-style"),E=b.addEventListener,v=b.removeEventListener,N=b.setInterval,C=b.setTimeout,P=b.clearInterval,O=b.clearTimeout,M=w.addEventListener,S=w.removeEventListener;window.__MICRO_APP_BASE_APPLICATION__=!0,Object.assign(H,{rawSetAttribute:e,rawAppendChild:t,rawInsertBefore:n,rawReplaceChild:o,rawRemoveChild:r,rawAppend:i,rawPrepend:s,rawCloneNode:a,rawCreateElement:l,rawCreateElementNS:c,rawCreateDocumentFragment:p,rawQuerySelector:u,rawQuerySelectorAll:d,rawGetElementById:h,rawGetElementsByClassName:m,rawGetElementsByTagName:f,rawGetElementsByName:_,ImageProxy:A,rawWindow:b,rawDocument:w,supportModuleScript:y,templateStyle:g,rawWindowAddEventListener:E,rawWindowRemoveEventListener:v,rawSetInterval:N,rawSetTimeout:C,rawClearInterval:P,rawClearTimeout:O,rawDocumentAddEventListener:M,rawDocumentRemoveEventListener:S})}}function j(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function G(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^(data|blob):/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!S())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),A(t.join("/")+"/")}(o)),`url("${g(r,t)}")`}))}function q(e,t,n){const o=V(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function V(e,t){let n="";for(const o of e)switch(o.constructor.name){case"CSSStyleRule":n+=j(o,t);break;case"CSSMediaRule":n+=q(o,t,"media");break;case"CSSSupportsRule":n+=q(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function z(e,t,n,o,r,i){var s,a;if(!t.__MICRO_APP_HAS_SCOPED__){let l=G(V(Array.from(null!==(a=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==a?a:[]),o),r,n,i);S()&&(l=l.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=l,t.__MICRO_APP_HAS_SCOPED__=!0}}function Q(e,t){if(t.scopecss){const n=`${Ve.tagName}[name=${t.name}]`;let o=H.templateStyle;if(o||(H.templateStyle=o=R("style"),o.setAttribute("id","micro-app-template-style"),H.rawDocument.body.appendChild(o),o.sheet.disabled=!0),e.textContent)o.textContent=e.textContent,z(o,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__),o.textContent="";else{const o=new MutationObserver((function(){var r,i;o.disconnect(),!e.textContent&&(null===(i=null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||z(e,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__)}));o.observe(e,{childList:!0})}}return e}function J(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function X(e){const t=new CustomEvent("load");J(t,e),s(e.onload)?e.onload(t):e.dispatchEvent(t)}function Y(e){const t=new CustomEvent("error");J(t,e),s(e.onerror)?e.onerror(t):e.dispatchEvent(t)}const Z=new Map;function ee(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){if(i=g(i,n.url),o)return{url:i,info:{code:"",isGlobal:e.hasAttribute("global")}};s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),n.source.links.set(i,{code:"",placeholder:s,isGlobal:e.hasAttribute("global")})}else r&&["prefetch","preload","prerender","icon","apple-touch-icon"].includes(r)?o?s=document.createComment(`link element with rel=${r}${i?" & href="+i:""} removed by micro-app`):t.removeChild(e):i&&e.setAttribute("href",g(i,n.url));return o?{replaceComment:s}:s?t.replaceChild(s,e):void 0}function te(e,t,n){const o=Array.from(t.source.links.entries()),r=[];for(const[e]of o){const n=Z.get(e);n?r.push(n):r.push(F(e,t.name))}E(r,(e=>{!function(e,t,n,o,r){t.isGlobal&&!Z.has(e)&&Z.set(e,n);const i=R("style");i.textContent=n,i.__MICRO_APP_LINK_PATH__=e,i.setAttribute("data-origin-href",e),o.replaceChild(Q(i,r),t.placeholder),t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{m(e,t.name)}),(()=>{t.onLoad(e)}))}const ne=new Map;function oe(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module"].includes(e.type)||e.hasAttribute("ignore"))return null;if(H.supportModuleScript&&e.noModule||!H.supportModuleScript&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=g(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t="inline-"+Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else o||(r=document.createComment("script element removed by micro-app"))}return o?{replaceComment:r}:t.replaceChild(r,e)}function re(e,t){const n=Array.from(t.source.scripts.entries()),o=[],r=[];for(const[e,i]of n)if(i.isExternal){const n=ne.get(e);n?i.code=n:i.defer||i.async||(o.push(F(e,t.name)),r.push([e,i]))}o.length?E(o,(e=>{!function(e,t,n){t.isGlobal&&!ne.has(e)&&ne.set(e,n);t.code=n}(r[e.index][0],r[e.index][1],e.data)}),(e=>{m(e,t.name)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function ie(e,t,n,o,r){var i;try{const s=le(e,t,n.code,n.module);if(t.inline||n.module){const a=R("script");if(se(e,s,n.module,a,r),o)return a;null===(i=t.container)||void 0===i||i.querySelector("micro-app-body").appendChild(a)}else if(ae(s,n),o)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error(`[micro-app from runScript] app ${t.name}: `,e)}}function se(e,t,n,o,r){if(n){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e),o.setAttribute("type","module"),r&&(r.moduleCount&&r.moduleCount--,o.onload=r.bind(o,0===r.moduleCount))}else o.textContent=t;e.startsWith("inline-")||o.setAttribute("data-origin-src",e)}function ae(e,t){t.code2Function||(t.code2Function=new Function(e)),t.code2Function.call(window)}function le(e,t,n,o){return l(Ve.plugins)&&(n=function(e,t,n,o){var r;if(a(o.global))for(const n of o.global)l(n)&&s(n.loader)&&(t=n.loader(t,e,n.options));if(a(null===(r=o.modules)||void 0===r?void 0:r[n]))for(const r of o.modules[n])l(r)&&s(r.loader)&&(t=r.loader(t,e,r.options));return t}(e,n,t.name,Ve.plugins)),t.sandBox&&!o?(H.rawWindow.__MICRO_APP_PROXY_WINDOW__=t.sandBox.proxyWindow,`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${B}){;${n}\n}).call(proxyWindow,${B})}})(window.__MICRO_APP_PROXY_WINDOW__);`):n}function ce(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{ce(e,t)}));for(const n of o)n instanceof HTMLLinkElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")?n.hasAttribute("href")&&n.setAttribute("href",g(n.getAttribute("href"),t.url)):ee(n,e,t):n instanceof HTMLStyleElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&Q(n,t):n instanceof HTMLScriptElement?oe(n,e,t):n instanceof HTMLMetaElement||n instanceof HTMLTitleElement?e.removeChild(n):n instanceof HTMLImageElement&&n.hasAttribute("src")&&n.setAttribute("src",g(n.getAttribute("src"),t.url))}function pe(e,t){const n=function(e){const t=R("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),r=n.querySelector("micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),m(e,t.name)}ce(n,t),t.source.links.size?te(n,t,o):t.onLoad(n),t.source.scripts.size?re(n,t):t.onLoad(n)}const ue=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(m("event-center: Invalid name"),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if(!s(t))return m("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&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&&(s(t)?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if(!l(t))return m("event-center: data must be object");let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}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 de(e,t){return r(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class he{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),ue.on("global",e,t)}removeGlobalDataListener(e){s(e)&&ue.off("global",e)}setGlobalData(e){M(),ue.dispatch("global",e)}getGlobalData(){return ue.getData("global")}clearGlobalDataListener(){const e=this.appName,t=ue.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 me extends he{addDataListener(e,t,n){ue.on(de(w(e),!1),t,n)}removeDataListener(e,t){s(t)&&ue.off(de(w(e),!1),t)}getData(e,t=!1){return ue.getData(de(w(e),t))}setData(e,t){ue.dispatch(de(w(e),!0),t)}clearDataListener(e){ue.off(de(w(e),!1))}}class fe extends he{constructor(e){super(),this.appName=w(e),!this.appName&&m(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,ue.on(de(this.appName,!0),e,t)}removeDataListener(e){s(e)&&ue.off(de(this.appName,!0),e)}getData(){return ue.getData(de(this.appName,!0))}dispatch(e){M(),ue.dispatch(de(this.appName,!1),e);const t=Me.get(this.appName);if((null==t?void 0:t.container)&&l(e)){const n=new CustomEvent("datachange",{detail:{data:e}});T(t.container).dispatchEvent(n)}}clearDataListener(){ue.off(de(this.appName,!0))}}function _e(e,t){if(t.__MICRO_APP_BOUND_WINDOW_FUNCTION)return t.__MICRO_APP_BOUND_WINDOW_FUNCTION;if(!function(e){var t;if(i(e.__MICRO_APP_ISCONSTRUCTOR))return e.__MICRO_APP_ISCONSTRUCTOR;const n=e.toString(),o=(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 e.__MICRO_APP_ISCONSTRUCTOR=o}(t)&&!function(e){return i(e.__MICRO_APP_ISBOUND_FUNCTION)?e.__MICRO_APP_ISBOUND_FUNCTION:e.__MICRO_APP_ISBOUND_FUNCTION=p(e)}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&u(n,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t.__MICRO_APP_BOUND_WINDOW_FUNCTION=n}return t}const Ae=new Map;let be=!1;const we=new Map;function ye(){const{rawDocument:e,rawDocumentAddEventListener:t,rawDocumentRemoveEventListener:n}=H;!be&&function(){if(be=!0,Object.getOwnPropertyDescriptor(document,"onclick"))return f("Cannot redefine document property onclick");const e=document.onclick;document.onclick=null;let t=!1;function n(e){Ae.forEach((t=>{s(t)&&t.call(document,e)}))}u(document,"onclick",{configurable:!0,enumerable:!0,get(){const e=D();return e?Ae.get(e):Ae.get("base")},set(e){const o=D();o?Ae.set(o,e):Ae.set("base",e),!t&&s(e)&&(t=!0,H.rawDocumentAddEventListener.call(H.rawDocument,"click",n,!1))}}),e&&(document.onclick=e)}(),document.addEventListener=function(n,o,r){var i;const s=D();if(s&&(!(null===(i=Me.get(s))||void 0===i?void 0:i.umdMode)||!p(o))){const e=we.get(s);if(e){const t=e.get(n);t?t.add(o):e.set(n,new Set([o]))}else we.set(s,new Map([[n,new Set([o])]]));o&&(o.__MICRO_APP_MARK_OPTIONS__=r)}t.call(e,n,o,r)},document.removeEventListener=function(t,o,r){var i;const s=D();if(s&&(!(null===(i=Me.get(s))||void 0===i?void 0:i.umdMode)||!p(o))){const e=we.get(s);if(e){const n=e.get(t);(null==n?void 0:n.size)&&n.has(o)&&n.delete(o)}}n.call(e,t,o,r)}}const ge=["unmount","appstate-change"];function Ee(e,t){return ge.includes(e)?`${e}-${t.__MICRO_APP_NAME__}`:e}const ve=["System","__cjsWrapper"],Ne=["location"],Ce=["window","self","globalThis"];class Pe{constructor(e,t){this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.active=!1,this.microAppWindow={},this.getScopeProperties(e),this.proxyWindow=this.createProxyWindow(),this.initMicroAppWindow(this.microAppWindow,e,t),Object.assign(this,function(e){const t=e.__MICRO_APP_NAME__,n=new Map,o=new Map,r=new Map,{rawWindow:i,rawDocument:s,rawWindowAddEventListener:a,rawWindowRemoveEventListener:l,rawSetInterval:c,rawSetTimeout:p,rawClearInterval:u,rawClearTimeout:d,rawDocumentRemoveEventListener:h}=H;e.addEventListener=function(t,o,r){t=Ee(t,e);const s=n.get(t);s?s.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(i,t,o,r)},e.removeEventListener=function(t,o,r){t=Ee(t,e);const s=n.get(t);(null==s?void 0:s.size)&&s.has(o)&&s.delete(o),l.call(i,t,o,r)},e.setInterval=function(e,t,...n){const r=c.call(i,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const o=p.call(i,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.clearInterval=function(e){o.delete(e),u.call(i,e)},e.clearTimeout=function(e){r.delete(e),d.call(i,e)};const m=new Map,f=new Map;let _,A=new Map,b=new Map;return{recordUmdEffect:()=>{n.forEach(((e,t)=>{e.size&&m.set(t,new Set(e))})),o.size&&(A=new Map(o)),r.size&&(b=new Map(r)),_=Ae.get(t);const e=we.get(t);e&&e.forEach(((e,t)=>{e.size&&f.set(t,new Set(e))}))},rebuildUmdEffect:()=>{m.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),A.forEach((t=>{e.setInterval(t.handler,t.timeout,...t.args)})),b.forEach((t=>{e.setTimeout(t.handler,t.timeout,...t.args)})),_&&Ae.set(t,_),C(t),f.forEach(((e,t)=>{for(const n of e)document.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),C(null)},releaseEffect:()=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(i,t,n)})),n.clear()),o.size&&(o.forEach(((e,t)=>{u.call(i,t)})),o.clear()),r.size&&(r.forEach(((e,t)=>{d.call(i,t)})),r.clear()),Ae.delete(t);const e=we.get(t);e&&(e.forEach(((e,t)=>{for(const n of e)h.call(s,t,n)})),e.clear())}}}(this.microAppWindow))}start(e){this.active||(this.active=!0,this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e,H.rawWindow._babelPolyfill&&(H.rawWindow._babelPolyfill=!1),1==++Pe.activeCount&&ye())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microAppWindow.microApp.clearDataListener(),this.microAppWindow.microApp.clearGlobalDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(H.rawWindow,e)})),this.escapeKeys.clear(),0==--Pe.activeCount&&(document.addEventListener=H.rawDocumentAddEventListener,document.removeEventListener=H.rawDocumentRemoveEventListener))}recordUmdSnapshot(){this.microAppWindow.__MICRO_APP_UMD_MODE__=!0,this.recordUmdEffect(),function(e){const t=e.appName;e.umdDataListeners={global:new Set,normal:new Set};const n=ue.eventList.get("global");if(n)for(const o of n.callbacks)t===o.__APP_NAME__&&e.umdDataListeners.global.add(o);const o=ue.eventList.get(de(t,!0));o&&(e.umdDataListeners.normal=new Set(o.callbacks))}(this.microAppWindow.microApp),this.recordUmdinjectedValues=new Map,this.injectedKeys.forEach((e=>{this.recordUmdinjectedValues.set(e,Reflect.get(this.microAppWindow,e))}))}rebuildUmdSnapshot(){this.recordUmdinjectedValues.forEach(((e,t)=>{Reflect.set(this.proxyWindow,t,e)})),this.rebuildUmdEffect(),function(e){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__)}(this.microAppWindow.microApp)}getScopeProperties(e){var t;if(l(Ve.plugins)){if(a(Ve.plugins.global))for(const e of Ve.plugins.global)l(e)&&(a(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),a(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if(a(null===(t=Ve.plugins.modules)||void 0===t?void 0:t[e]))for(const t of Ve.plugins.modules[e])l(t)&&(a(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),a(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}createProxyWindow(){const e=H.rawWindow,t=new Map;return new Proxy(this.microAppWindow,{get:(t,n)=>{if(Reflect.has(t,n)||r(n)&&/^__MICRO_APP_/.test(n)||this.scopeProperties.includes(n))return Reflect.get(t,n);const o=Reflect.get(e,n);return s(o)?_e(e,o):o},set:(t,n,o)=>{if(this.active){if(Ne.includes(n))Reflect.set(e,n,o);else if(h.call(t,n)||!h.call(e,n)||this.scopeProperties.includes(n))Reflect.set(t,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(e,n),{configurable:i,enumerable:s,writable:a,set:l}=r;u(t,n,{value:o,configurable:i,enumerable:s,writable:null!=a?a:!!l}),this.injectedKeys.add(n)}(this.escapeProperties.includes(n)||ve.includes(n)&&!Reflect.has(e,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(e,n,o),this.escapeKeys.add(n))}return!0},has:(t,n)=>this.scopeProperties.includes(n)?n in t:n in t||n in e,getOwnPropertyDescriptor:(n,o)=>{if(h.call(n,o))return t.set(o,"target"),Object.getOwnPropertyDescriptor(n,o);if(h.call(e,o)){t.set(o,"rawWindow");const n=Object.getOwnPropertyDescriptor(e,o);return n&&!n.configurable&&(n.configurable=!0),n}},defineProperty:(n,o,r)=>"rawWindow"===t.get(o)?Reflect.defineProperty(e,o,r):Reflect.defineProperty(n,o,r),ownKeys:t=>Reflect.ownKeys(e).concat(Reflect.ownKeys(t)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(t,n)=>!h.call(t,n)||(this.injectedKeys.has(n)&&this.injectedKeys.delete(n),this.escapeKeys.has(n)&&Reflect.deleteProperty(e,n),Reflect.deleteProperty(t,n))})}initMicroAppWindow(e,t,n){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=t,e.__MICRO_APP_PUBLIC_PATH__=y(n),e.__MICRO_APP_WINDOW__=e,e.microApp=new fe(t),e.rawWindow=H.rawWindow,e.rawDocument=H.rawDocument,e.removeDomScope=M,e.hasOwnProperty=t=>h.call(e,t)||h.call(H.rawWindow,t),this.setMappingPropertiesWithRawDescriptor(e),this.setHijackProperties(e,t)}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=H.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),u(e,"top",this.createDescriptorFormicroAppWindow("top",t)),u(e,"parent",this.createDescriptorFormicroAppWindow("parent",n)),Ce.forEach((t=>{u(e,t,this.createDescriptorFormicroAppWindow(t,this.proxyWindow))}))}createDescriptorFormicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(H.rawWindow,e)||{};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}setHijackProperties(e,t){let n,o;d(e,{document:{get:()=>(O(t),H.rawDocument),configurable:!1,enumerable:!0},eval:{get:()=>(O(t),n||eval),set:e=>{n=e},configurable:!0,enumerable:!1},Image:{get:()=>(O(t),o||H.ImageProxy),set:e=>{o=e},configurable:!0,enumerable:!1}})}}function Oe(e,t,n,o){var r;if(!e)return m(`element does not exist in lifecycle ${n}`,t);e=T(e),M();const i=Object.assign({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),s(null===(r=Ve.lifeCycles)||void 0===r?void 0:r[n])&&Ve.lifeCycles[n](a),e.dispatchEvent(a)}function De(e,t,n={}){const o=new CustomEvent(`${e}-${t}`,{detail:n});window.dispatchEvent(o)}Pe.activeCount=0;const Me=new Map;class Se{constructor({name:e,url:t,ssrUrl:n,container:o,inline:r,scopecss:i,useSandbox:s,baseroute:a}){this.state=W.NOT_LOADED,this.keepAliveState=null,this.keepAliveContainer=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.libraryName=null,this.umdMode=!1,this.isPrefetch=!1,this.container=null,this.baseroute="",this.sandBox=null,this.container=null!=o?o:null,this.inline=null!=r&&r,this.baseroute=null!=a?a:"",this.ssrUrl=null!=n?n:"",this.name=e,this.url=t,this.useSandbox=s,this.scopecss=this.useSandbox&&i,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Pe(e,t))}loadSourceCode(){var e;this.state=W.LOADING_SOURCE_CODE,F((e=this).ssrUrl||e.url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),m(t,e.name)}pe(t=t.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>"))),e)})).catch((t=>{m(`Failed to fetch data from ${e.url}, micro-app stop rendering`,e.name,t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||W.UNMOUNT===this.state)return;this.state=W.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,W.UNMOUNT!==this.state&&(this.onerror(e),this.state=W.LOAD_SOURCE_ERROR)}mount(e,t,n){var o,r,a;if(i(t)&&t!==this.inline&&(this.inline=t),this.container=null!==(o=this.container)&&void 0!==o?o:e,this.baseroute=null!=n?n:this.baseroute,2!==this.loadSourceLevel)return void(this.state=W.LOADING_SOURCE_CODE);let l;if(Oe(this.container,this.name,$.BEFOREMOUNT),this.state=W.MOUNTING,I(this.source.html,this.container,!this.umdMode),null===(r=this.sandBox)||void 0===r||r.start(this.baseroute),this.umdMode){null===(a=this.sandBox)||void 0===a||a.rebuildUmdSnapshot();try{l=this.umdHookMount()}catch(e){m("an error occurred in the mount function \n",this.name,e)}this.handleMounted(l)}else{let e=!1;!function(e,t,n){const o=Array.from(e.entries()),r=[],i=[];for(const[e,s]of o)s.isDynamic||(s.defer||s.async?(s.isExternal&&!s.code?r.push(F(e,t.name)):r.push(s.code),i.push([e,s]),s.module&&(n.moduleCount=n.moduleCount?++n.moduleCount:1)):(ie(e,t,s,!1),n(!1)));r.length?E(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(e=>{n.errorCount=n.errorCount?++n.errorCount:1,m(e,t.name)}),(()=>{i.forEach((([e,o])=>{o.code&&(ie(e,t,o,!1,n),!o.module&&n(!1))})),n(void 0===n.moduleCount||n.errorCount===r.length)})):n(!0)}(this.source.scripts,this,(t=>{var n;if(!this.umdMode){const{mount:e,unmount:t}=this.getUmdLibraryHooks();if(s(e)&&s(t)){this.umdHookMount=e,this.umdHookUnmount=t,this.umdMode=!0,null===(n=this.sandBox)||void 0===n||n.recordUmdSnapshot();try{l=this.umdHookMount()}catch(e){m("an error occurred in the mount function \n",this.name,e)}}}e||!0!==t&&!this.umdMode||(e=!0,this.handleMounted(l))}))}}handleMounted(e){c(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>this.onerror(e))):this.dispatchMountedEvent()}dispatchMountedEvent(){W.UNMOUNT!==this.state&&(this.state=W.MOUNTED,Oe(this.container,this.name,$.MOUNTED))}unmount(e,t){let n;if(this.state===W.LOAD_SOURCE_ERROR&&(e=!0),this.state=W.UNMOUNT,this.keepAliveState=null,this.keepAliveContainer=null,this.umdHookUnmount)try{n=this.umdHookUnmount()}catch(e){m("an error occurred in the unmount function \n",this.name,e)}De("unmount",this.name),this.handleUnmounted(e,n,t)}handleUnmounted(e,t,n){c(t)?t.then((()=>this.actionsForUnmount(e,n))).catch((()=>this.actionsForUnmount(e,n))):this.actionsForUnmount(e,n)}actionsForUnmount(e,t){var n;null===(n=this.sandBox)||void 0===n||n.stop(),e?this.actionsForCompletelyDestroy():this.umdMode&&this.container.childElementCount&&I(this.container,this.source.html,!1),Oe(this.container,this.name,$.UNMOUNT),this.container.innerHTML="",this.container=null,t&&t()}actionsForCompletelyDestroy(){!this.useSandbox&&this.umdMode&&delete window[this.libraryName],Me.delete(this.name)}hiddenKeepAliveApp(){const e=this.container;I(this.container,this.keepAliveContainer?this.keepAliveContainer:this.keepAliveContainer=document.createElement("div"),!1),this.container=this.keepAliveContainer,this.keepAliveState=k.KEEP_ALIVE_HIDDEN,De("appstate-change",this.name,{appState:"afterhidden"}),Oe(e,this.name,$.AFTERHIDDEN)}showKeepAliveApp(e){De("appstate-change",this.name,{appState:"beforeshow"}),Oe(e,this.name,$.BEFORESHOW),I(this.container,e,!1),this.container=e,this.keepAliveState=k.KEEP_ALIVE_SHOW,De("appstate-change",this.name,{appState:"aftershow"}),Oe(this.container,this.name,$.AFTERSHOW)}onerror(e){Oe(this.container,this.name,$.ERROR,e)}getAppState(){return this.state}getKeepAliveState(){return this.keepAliveState}getUmdLibraryHooks(){var e,t;if(W.UNMOUNT!==this.state){const n=null!==(t=null===(e=this.sandBox)||void 0===e?void 0:e.proxyWindow)&&void 0!==t?t:H.rawWindow;return this.libraryName=T(this.container).getAttribute("library")||`micro-app-${this.name}`,"object"==typeof n[this.libraryName]?n[this.libraryName]:{}}return{}}}const Re=new WeakMap;function Ie(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return Re.set(t,e),e}return n.scopecss&&!t.hasAttribute("ignore")?Q(t,n):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return Re.set(t,e),e}if(t.hasAttribute("ignore"))return t;const{url:o,info:r,replaceComment:i}=ee(t,e,n,!0);if(o&&r){const e=R("style");return e.__MICRO_APP_LINK_PATH__=o,function(e,t,n,o,r){if(n.source.links.has(e))return r.textContent=n.source.links.get(e).code,Q(r,n),void _((()=>X(o)));if(Z.has(e)){const i=Z.get(e);return t.code=i,n.source.links.set(e,t),r.textContent=i,Q(r,n),void _((()=>X(o)))}F(e,n.name).then((i=>{t.code=i,n.source.links.set(e,t),t.isGlobal&&Z.set(e,i),r.textContent=i,Q(r,n),X(o)})).catch((e=>{m(e,n.name),Y(o)}))}(o,r,n,t,e),Re.set(t,e),e}return i?(Re.set(t,i),i):t}if(t instanceof HTMLScriptElement){const{replaceComment:o,url:r,info:i}=oe(t,e,n,!0)||{};if(r&&i){if(i.isExternal){const e=function(e,t,n,o){const r=()=>X(o);if(n.source.scripts.has(e)){const t=n.source.scripts.get(e);return!t.module&&_(r),ie(e,n,t,!0,r)}if(ne.has(e)){const o=ne.get(e);return t.code=o,n.source.scripts.set(e,t),!t.module&&_(r),ie(e,n,t,!0,r)}let i;return i=n.inline||t.module?R("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),F(e,n.name).then((s=>{t.code=s,n.source.scripts.set(e,t),t.isGlobal&&ne.set(e,s);try{s=le(e,n,s,t.module),n.inline||t.module?se(e,s,t.module,i,r):ae(s,t)}catch(t){console.error(`[micro-app from runDynamicScript] app ${n.name}: `,t,e)}!t.module&&X(o)})).catch((e=>{m(e,n.name),Y(o)})),i}(r,i,n,t);return Re.set(t,e),e}{const e=ie(r,n,i,!0);return Re.set(t,e),e}}return o?(Re.set(t,o),o):t}return t}function Ue(e,t,n,o,r){if(n===document.head){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?H.rawAppendChild.call(i,o):t!==H.rawRemoveChild||i.contains(o)?t===H.rawAppend||t===H.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n===document.body){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?H.rawAppendChild.call(i,o):t!==H.rawRemoveChild||i.contains(o)?t===H.rawAppend||t===H.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===H.rawAppend||t===H.rawPrepend?t.call(n,o):t.call(n,o,r)}function Le(e){var t;return null!==(t=Re.get(e))&&void 0!==t?t:e}function Te(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Me.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?Ue(r,o,e,Ie(e,t,r),n&&Le(n)):o===H.rawAppend||o===H.rawPrepend?o.call(e,t):o.call(e,t,n)}if(o===H.rawAppend||o===H.rawPrepend){const n=D();if(!(t instanceof Node)&&n){const r=Me.get(n);if(null==r?void 0:r.container){if(e===document.head)return o.call(r.container.querySelector("micro-app-head"),t);if(e===document.body)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function xe(){!function(){const e=H.rawDocument;function t(t){var n,o,r;const i=D();return i&&t&&!L(t)&&e===this?null!==(r=null===(o=null===(n=Me.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:H.rawQuerySelector.call(this,t)}function n(t){var n,o,r;const i=D();return i&&t&&!L(t)&&e===this?null!==(r=null===(o=null===(n=Me.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:H.rawQuerySelectorAll.call(this,t)}Document.prototype.createElement=function(e,t){return We(H.rawCreateElement.call(this,e,t))},Document.prototype.createElementNS=function(e,t,n){return We(H.rawCreateElementNS.call(this,e,t,n))},Document.prototype.createDocumentFragment=function(){return We(H.rawCreateDocumentFragment.call(this))},Document.prototype.querySelector=t,Document.prototype.querySelectorAll=n,Document.prototype.getElementById=function(e){if(!D()||U(e))return H.rawGetElementById.call(this,e);try{return t.call(this,`#${e}`)}catch(t){return H.rawGetElementById.call(this,e)}},Document.prototype.getElementsByClassName=function(e){if(!D()||U(e))return H.rawGetElementsByClassName.call(this,e);try{return n.call(this,`.${e}`)}catch(t){return H.rawGetElementsByClassName.call(this,e)}},Document.prototype.getElementsByTagName=function(e){var t;const o=D();if(!o||L(e)||U(e)||!(null===(t=Me.get(o))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return H.rawGetElementsByTagName.call(this,e);try{return n.call(this,e)}catch(t){return H.rawGetElementsByTagName.call(this,e)}},Document.prototype.getElementsByName=function(e){if(!D()||U(e))return H.rawGetElementsByName.call(this,e);try{return n.call(this,`[name=${e}]`)}catch(t){return H.rawGetElementsByName.call(this,e)}}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if(l(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{r(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&f("property data must be an object",this.getAttribute("name"));else if((("src"===e||"srcset"===e)&&/^(img|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Me.has(this.__MICRO_APP_NAME__)){const n=Me.get(this.__MICRO_APP_NAME__);H.rawSetAttribute.call(this,e,g(t,n.url))}else H.rawSetAttribute.call(this,e,t)},Element.prototype.appendChild=function(e){return Te(this,e,null,H.rawAppendChild)},Element.prototype.insertBefore=function(e,t){return Te(this,e,t,H.rawInsertBefore)},Element.prototype.replaceChild=function(e,t){return Te(this,e,t,H.rawReplaceChild)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)Te(this,e[t],null,H.rawAppend),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)Te(this,e[t-1],null,H.rawPrepend),t--},Element.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Me.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?Ue(t,H.rawRemoveChild,this,Le(e)):H.rawRemoveChild.call(this,e)}return H.rawRemoveChild.call(this,e)},Element.prototype.cloneNode=function(e){const t=H.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t}}function We(e){const t=D();return t&&(e.__MICRO_APP_NAME__=t),e}function $e(){C(null),Document.prototype.createElement=H.rawCreateElement,Document.prototype.createElementNS=H.rawCreateElementNS,Document.prototype.createDocumentFragment=H.rawCreateDocumentFragment,Document.prototype.querySelector=H.rawQuerySelector,Document.prototype.querySelectorAll=H.rawQuerySelectorAll,Document.prototype.getElementById=H.rawGetElementById,Document.prototype.getElementsByClassName=H.rawGetElementsByClassName,Document.prototype.getElementsByTagName=H.rawGetElementsByTagName,Document.prototype.getElementsByName=H.rawGetElementsByName,Element.prototype.setAttribute=H.rawSetAttribute,Element.prototype.appendChild=H.rawAppendChild,Element.prototype.insertBefore=H.rawInsertBefore,Element.prototype.replaceChild=H.rawReplaceChild,Element.prototype.removeChild=H.rawRemoveChild,Element.prototype.append=H.rawAppend,Element.prototype.prepend=H.rawPrepend,Element.prototype.cloneNode=H.rawCloneNode}let ke=!1;function Be(){Fe(),Me.forEach((e=>{e.container&&T(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Me.clear(),He.size&&(He.clear(),$e())}function Fe(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",Be,!1)}const He=new Map;function Ke(e){class n extends HTMLElement{constructor(){super(),this.isWating=!1,this.cacheData=null,this.hasConnected=!1,this.appName="",this.appUrl="",this.ssrUrl="",this.version=t,this.handleAttributeUpdate=()=>{this.isWating=!1;const e=w(this.getAttribute("name")),t=b(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Me.get(e);if(e!==this.appName&&n&&W.UNMOUNT!==n.getAppState()&&k.KEEP_ALIVE_HIDDEN!==n.getKeepAliveState()&&!n.isPrefetch)return this.setAttribute("name",this.appName),m(`app name conflict, an app named ${e} is running`,this.appName);e===this.appName&&t===this.appUrl||(e===this.appName?this.handleUnmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)},this.querySelector("micro-app-head")||this.performWhenFirstCreated()}static get observedAttributes(){return["name","url"]}connectedCallback(){this.hasConnected=!0,He.has(this)||this.performWhenFirstCreated(),_((()=>Oe(this,this.appName,$.CREATED))),this.initialMount()}disconnectedCallback(){this.hasConnected=!1,this.getKeepAliveModeResult()?this.handleHiddenKeepAliveApp():(He.delete(this),this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{0===He.size&&$e()})))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===x.NAME?"appName":"appUrl"]!==n)if(e!==x.URL||this.appUrl)if(e!==x.NAME||this.appName)this.isWating||(this.isWating=!0,_(this.handleAttributeUpdate));else{const e=w(n);if(!e)return m(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(Ve.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=b(n,this.appName)))return m(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.hasConnected&&this.initialMount()}performWhenFirstCreated(){1===He.set(this,!0).size&&(xe(),function(){if(!ke){ke=!0;const e=R("style");e.setAttribute("type","text/css"),e.textContent=`\n${Ve.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,H.rawDocument.head.appendChild(e)}}(),Fe(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",Be,!1))}initialMount(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&s(this.attachShadow)&&this.attachShadow({mode:"open"}),this.getDisposeResult("ssr")?this.ssrUrl=g(H.rawWindow.location.pathname,this.appUrl):this.ssrUrl&&(this.ssrUrl=""),Me.has(this.appName)){const e=Me.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===k.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t!==n||!e.isPrefetch&&e.getAppState()!==W.UNMOUNT?e.isPrefetch||e.getAppState()===W.UNMOUNT?(f(`the ${e.isPrefetch?"prefetch":"unmounted"} app with url: ${t} is replaced by a new app`,this.appName),this.handleCreateApp()):m(`app name conflict, an app named ${this.appName} is running`,this.appName):this.handleAppMount(e)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.getDisposeResult("ssr")?this.ssrUrl=g(H.rawWindow.location.pathname,t):this.ssrUrl&&(this.ssrUrl=""),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.getKeepAliveState()===k.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):m(`app name conflict, an app named ${this.appName} is running`,this.appName):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleAppMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!r(t)||!t)||(m(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleAppMount(e){e.isPrefetch=!1,_((()=>{var t;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),this.getBaseRouteCompatible())}))}handleCreateApp(){var e;Me.has(this.appName)&&Me.get(this.appName).actionsForCompletelyDestroy();const t=new Se({name:this.appName,url:this.appUrl,ssrUrl:this.ssrUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),baseroute:this.getBaseRouteCompatible()});Me.set(this.appName,t)}handleUnmount(e,t){const n=Me.get(this.appName);n&&n.getAppState()!==W.UNMOUNT&&n.unmount(e,t)}handleHiddenKeepAliveApp(){const e=Me.get(this.appName);e&&e.getAppState()!==W.UNMOUNT&&e.getKeepAliveState()!==k.KEEP_ALIVE_HIDDEN&&e.hiddenKeepAliveApp()}handleShowKeepAliveApp(e){_((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleSpecialProperties(e)||Ve[e])&&this.compatibleDisablSpecialProperties(e)}compatibleSpecialProperties(e){return"disableScopecss"===e?this.hasAttribute("disableScopecss")||this.hasAttribute("disable-scopecss"):"disableSandbox"===e?this.hasAttribute("disableSandbox")||this.hasAttribute("disable-sandbox"):this.hasAttribute(e)}compatibleDisablSpecialProperties(e){return"disableScopecss"===e?"false"!==this.getAttribute("disableScopecss")&&"false"!==this.getAttribute("disable-scopecss"):"disableSandbox"===e?"false"!==this.getAttribute("disableSandbox")&&"false"!==this.getAttribute("disable-sandbox"):"false"!==this.getAttribute(e)}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()}set data(e){this.appName?Ve.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Ve.getData(this.appName,!0):this.cacheData?this.cacheData:null}}window.customElements.define(e,n)}function je(e){if(!n)return m("preFetch is only supported in browser environment");v((()=>{s(e)&&(e=e()),function(e){const t=[];return a(e)&&e.forEach((e=>{l(e)&&(e.name=w(e.name),e.url=b(e.url,e.name),e.name&&e.url&&!Me.has(e.name)&&t.push(e))})),t}(e).forEach((e=>{var t,n;const o=new Se({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:Ve.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:Ve.disableSandbox)});o.isPrefetch=!0,Me.set(e.name,o)}))}))}function Ge(e,t){const n=Me.get(w(e));return new Promise((o=>{if(n)if(n.getAppState()===W.UNMOUNT||n.isPrefetch)(null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o();else if(n.getKeepAliveState()===k.KEEP_ALIVE_HIDDEN)(null==t?void 0:t.destroy)?n.unmount(!0,o):(null==t?void 0:t.clearAliveState)?n.unmount(!1,o):o();else{const e=T(n.container),r=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()},i=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()};if(e.addEventListener("unmount",r),e.addEventListener("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"),"string"==typeof t&&e.setAttribute("destroy",t),"string"==typeof n&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const t=e.getAttribute("keep-alive");e.removeAttribute("keep-alive"),e.parentNode.removeChild(e),e.setAttribute("keep-alive",t)}else e.parentNode.removeChild(e)}else f(`app ${e} does not exist`),o()}))}class qe extends me{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=je}start(e){if(!n||!window.customElements)return m("micro-app is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return m(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(window.customElements.get(this.tagName))return f(`element ${this.tagName} is already defined`);if(K(),e&&l(e)&&(this.shadowDOM=e.shadowDOM,this.destroy=e.destroy,this.destory=e.destory,this.inline=e.inline,this.disableScopecss=e.disableScopecss,this.disableSandbox=e.disableSandbox,this.ssr=e.ssr,s(e.fetch)&&(this.fetch=e.fetch),l(e.lifeCycles)&&(this.lifeCycles=e.lifeCycles),e.preFetchApps&&je(e.preFetchApps),e.globalAssets&&(l(t=e.globalAssets)&&v((()=>{if(a(t.js)){const e=t.js.filter((e=>r(e)&&e.includes(".js")&&!ne.has(e))),n=[];e.forEach((e=>{n.push(F(e))})),E(n,(t=>{const n=e[t.index];ne.has(n)||ne.set(n,t.data)}),(e=>{m(e)}))}if(a(t.css)){const e=t.css.filter((e=>r(e)&&e.includes(".css")&&!Z.has(e))),n=[];e.forEach((e=>{n.push(F(e))})),E(n,(t=>{const n=e[t.index];Z.has(n)||Z.set(n,t.data)}),(e=>{m(e)}))}}))),l(e.plugins))){const t=e.plugins.modules;if(l(t))for(const e in t){const n=w(e);n&&e!==n&&(t[n]=t[e],delete t[e])}this.plugins=e.plugins}var t;Ke(this.tagName)}}var Ve=new qe;e.EventCenterForMicroApp=fe,e.MicroApp=qe,e.default=Ve,e.getActiveApps=function(e){const t=[];return Me.forEach(((n,o)=>{W.UNMOUNT===n.getAppState()||n.isPrefetch||e&&k.KEEP_ALIVE_HIDDEN===n.getKeepAliveState()||t.push(o)})),t},e.getAllApps=function(){return Array.from(Me.keys())},e.preFetch=je,e.pureCreateElement=R,e.removeDomScope=M,e.unmountAllApps=function(e){return Array.from(Me.keys()).reduce(((t,n)=>t.then((()=>Ge(n,e)))),Promise.resolve())},e.unmountApp=Ge,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
!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="0.7.1",n="undefined"!=typeof window,o="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")();function r(e){return"string"==typeof e}function i(e){return"boolean"==typeof e}function s(e){return"function"==typeof e}const a=Array.isArray;function l(e){return"[object Object]"===toString.call(e)}function c(e){return"[object Promise]"===toString.call(e)}function p(e){return s(e)&&0===e.name.indexOf("bound ")&&!e.hasOwnProperty("prototype")}const u=Object.defineProperty,d=Object.defineProperties,h=Object.prototype.hasOwnProperty;function m(e,t=null,...n){const o=t&&r(t)?` app ${t}:`:"";r(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function f(e,t=null,...n){const o=t&&r(t)?` app ${t}:`:"";r(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function _(e,...t){Promise.resolve().then(e.bind(null,...t))}function A(e){return e.startsWith("//")?`${location.protocol}${e}`:e}function b(e,t=null){if(!r(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=new URL(A(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return m(e,t),""}}function w(e){return r(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function y(e){const{origin:t,pathname:n}=new URL(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function g(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:new URL(e,y(A(t))).toString()}function E(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{c(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 v=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};let N=null;function C(e){N=e}let P=!1;function O(e){P&&N===e||(P=!0,C(e),_((()=>{P=!1,C(null)})))}function D(){return N}function M(){C(null)}function S(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)}function R(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n}function I(e,t,n){if(t.innerHTML="",n){const n=e.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),t.appendChild(o)}else Array.from(e.childNodes).forEach((e=>{t.appendChild(e)}))}function U(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function L(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)}function T(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}var x,W,$,k;!function(e){e.NAME="name",e.URL="url"}(x||(x={})),function(e){e.NOT_LOADED="NOT_LOADED",e.LOADING_SOURCE_CODE="LOADING_SOURCE_CODE",e.LOAD_SOURCE_FINISHED="LOAD_SOURCE_FINISHED",e.LOAD_SOURCE_ERROR="LOAD_SOURCE_ERROR",e.MOUNTING="MOUNTING",e.MOUNTED="MOUNTED",e.UNMOUNT="UNMOUNT"}(W||(W={})),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"}($||($={})),function(e){e.KEEP_ALIVE_SHOW="KEEP_ALIVE_SHOW",e.KEEP_ALIVE_HIDDEN="KEEP_ALIVE_HIDDEN"}(k||(k={}));const B="window,self,globalThis,Array,Object,String,Boolean,Math,Number,Symbol,Date,Promise,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,Document,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,location,navigator,undefined";function F(e,t=null,n={}){return s(Ve.fetch)?Ve.fetch(e,n,t):fetch(e,n).then((e=>e.text()))}const H={};function K(){if(n){const e=Element.prototype.setAttribute,t=Element.prototype.appendChild,n=Element.prototype.insertBefore,o=Element.prototype.replaceChild,r=Element.prototype.removeChild,i=Element.prototype.append,s=Element.prototype.prepend,a=Element.prototype.cloneNode,l=Document.prototype.createElement,c=Document.prototype.createElementNS,p=Document.prototype.createDocumentFragment,u=Document.prototype.querySelector,d=Document.prototype.querySelectorAll,h=Document.prototype.getElementById,m=Document.prototype.getElementsByClassName,f=Document.prototype.getElementsByTagName,_=Document.prototype.getElementsByName,A=new Proxy(Image,{construct(e,t){const n=new e(...t);return n.__MICRO_APP_NAME__=D(),n}}),b=Function("return window")(),w=Function("return document")(),y="noModule"in document.createElement("script"),g=w.body.querySelector("#micro-app-template-style"),E=b.addEventListener,v=b.removeEventListener,N=b.setInterval,C=b.setTimeout,P=b.clearInterval,O=b.clearTimeout,M=w.addEventListener,S=w.removeEventListener;window.__MICRO_APP_BASE_APPLICATION__=!0,Object.assign(H,{rawSetAttribute:e,rawAppendChild:t,rawInsertBefore:n,rawReplaceChild:o,rawRemoveChild:r,rawAppend:i,rawPrepend:s,rawCloneNode:a,rawCreateElement:l,rawCreateElementNS:c,rawCreateDocumentFragment:p,rawQuerySelector:u,rawQuerySelectorAll:d,rawGetElementById:h,rawGetElementsByClassName:m,rawGetElementsByTagName:f,rawGetElementsByName:_,ImageProxy:A,rawWindow:b,rawDocument:w,supportModuleScript:y,templateStyle:g,rawWindowAddEventListener:E,rawWindowRemoveEventListener:v,rawSetInterval:N,rawSetTimeout:C,rawClearInterval:P,rawClearTimeout:O,rawDocumentAddEventListener:M,rawDocumentRemoveEventListener:S})}}function j(e,t){const{selectorText:n,cssText:o}=e;if(/^((html[\s>~,]+body)|(html|body|:root))$/.test(n))return o.replace(/^((html[\s>~,]+body)|(html|body|:root))/,t);if("*"===n)return o.replace("*",`${t} *`);const r=/(^|\s+)((html[\s>~]+body)|(html|body|:root))(?=[\s>~]+|$)/;return o.replace(/^[\s\S]+{/,(e=>e.replace(/(^|,)([^,]+)/g,((e,n,o)=>r.test(o)?e.replace(r,t):`${n} ${t} ${o.replace(/^\s*/,"")}`))))}function G(e,t,n,o){return e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,r)=>{if(/^((data|blob):|#)/.test(r))return e;if(/^(https?:)?\/\//.test(r)){if(!S())return e;{const t=r.replace(/^https?:/,"");if(-1!==n.indexOf(t))return e;r=r.replace(window.location.origin,"")}}return/^((\.\.?\/)|[^/])/.test(r)&&o&&(t=function(e){const t=e.split("/");return t.pop(),A(t.join("/")+"/")}(o)),`url("${g(r,t)}")`}))}function q(e,t,n){const o=V(Array.from(e.cssRules),t);return`@${n} ${e.conditionText} {${o}}`}function V(e,t){let n="";for(const o of e)switch(o.constructor.name){case"CSSStyleRule":n+=j(o,t);break;case"CSSMediaRule":n+=q(o,t,"media");break;case"CSSSupportsRule":n+=q(o,t,"supports");break;default:n+=o.cssText}return n.replace(/^\s+/,"")}function z(e,t,n,o,r,i){var s,a;if(!t.__MICRO_APP_HAS_SCOPED__){let l=G(V(Array.from(null!==(a=null===(s=e.sheet)||void 0===s?void 0:s.cssRules)&&void 0!==a?a:[]),o),r,n,i);S()&&(l=l.replace(/([;{]\s*content:\s*)([^\s"][^";}]*)/gm,((e,t,n)=>"none"===n||/^(url\()|(counter\()|(attr\()|(open-quote)|(close-quote)/.test(n)?e:`${t}"${n}"`))),t.textContent=l,t.__MICRO_APP_HAS_SCOPED__=!0}}function Q(e,t){if(t.scopecss){const n=`${Ve.tagName}[name=${t.name}]`;let o=H.templateStyle;if(o||(H.templateStyle=o=R("style"),o.setAttribute("id","micro-app-template-style"),H.rawDocument.body.appendChild(o),o.sheet.disabled=!0),e.textContent)o.textContent=e.textContent,z(o,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__),o.textContent="";else{const o=new MutationObserver((function(){var r,i;o.disconnect(),!e.textContent&&(null===(i=null===(r=e.sheet)||void 0===r?void 0:r.cssRules)||void 0===i?void 0:i.length)||e.hasAttribute("data-styled")||z(e,e,e.textContent,n,t.url,e.__MICRO_APP_LINK_PATH__)}));o.observe(e,{childList:!0})}}return e}function J(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function X(e){const t=new CustomEvent("load");J(t,e),s(e.onload)?e.onload(t):e.dispatchEvent(t)}function Y(e){const t=new CustomEvent("error");J(t,e),s(e.onerror)?e.onerror(t):e.dispatchEvent(t)}const Z=new Map;function ee(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){if(i=g(i,n.url),o)return{url:i,info:{code:"",isGlobal:e.hasAttribute("global")}};s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),n.source.links.set(i,{code:"",placeholder:s,isGlobal:e.hasAttribute("global")})}else r&&["prefetch","preload","prerender","icon","apple-touch-icon"].includes(r)?o?s=document.createComment(`link element with rel=${r}${i?" & href="+i:""} removed by micro-app`):t.removeChild(e):i&&e.setAttribute("href",g(i,n.url));return o?{replaceComment:s}:s?t.replaceChild(s,e):void 0}function te(e,t,n){const o=Array.from(t.source.links.entries()),r=[];for(const[e]of o){const n=Z.get(e);n?r.push(n):r.push(F(e,t.name))}E(r,(e=>{!function(e,t,n,o,r){t.isGlobal&&!Z.has(e)&&Z.set(e,n);const i=R("style");i.textContent=n,i.__MICRO_APP_LINK_PATH__=e,i.setAttribute("data-origin-href",e),t.placeholder.parentNode?t.placeholder.parentNode.replaceChild(Q(i,r),t.placeholder):o.appendChild(Q(i,r));t.placeholder=null,t.code=n}(o[e.index][0],o[e.index][1],e.data,n,t)}),(e=>{m(e,t.name)}),(()=>{t.onLoad(e)}))}const ne=new Map;function oe(e,t,n,o=!1){let r=null,i=e.getAttribute("src");if(e.hasAttribute("exclude"))r=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module"].includes(e.type)||e.hasAttribute("ignore"))return null;if(H.supportModuleScript&&e.noModule||!H.supportModuleScript&&"module"===e.type)r=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(i){i=g(i,n.url);const t={code:"",isExternal:!0,isDynamic:o,async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,isGlobal:e.hasAttribute("global")};if(o)return{url:i,info:t};n.source.scripts.set(i,t),r=document.createComment(`script with src='${i}' extract by micro-app`)}else if(e.textContent){const t="inline-"+Math.random().toString(36).substr(2,15),i={code:e.textContent,isExternal:!1,isDynamic:o,async:!1,defer:"module"===e.type,module:"module"===e.type};if(o)return{url:t,info:i};n.source.scripts.set(t,i),r=document.createComment("inline script extract by micro-app")}else o||(r=document.createComment("script element removed by micro-app"))}return o?{replaceComment:r}:t.replaceChild(r,e)}function re(e,t){const n=Array.from(t.source.scripts.entries()),o=[],r=[];for(const[e,i]of n)if(i.isExternal){const n=ne.get(e);n?i.code=n:i.defer||i.async||(o.push(F(e,t.name)),r.push([e,i]))}o.length?E(o,(e=>{!function(e,t,n){t.isGlobal&&!ne.has(e)&&ne.set(e,n);t.code=n}(r[e.index][0],r[e.index][1],e.data)}),(e=>{m(e,t.name)}),(()=>{t.onLoad(e)})):t.onLoad(e)}function ie(e,t,n,o,r){var i;try{const s=le(e,t,n.code,n.module);if(t.inline||n.module){const a=R("script");if(se(e,s,n.module,a,r),o)return a;null===(i=t.container)||void 0===i||i.querySelector("micro-app-body").appendChild(a)}else if(ae(s,n),o)return document.createComment("dynamic script extract by micro-app")}catch(e){console.error(`[micro-app from runScript] app ${t.name}: `,e)}}function se(e,t,n,o,r){if(n){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e),o.setAttribute("type","module"),r&&(r.moduleCount&&r.moduleCount--,o.onload=r.bind(o,0===r.moduleCount))}else o.textContent=t;e.startsWith("inline-")||o.setAttribute("data-origin-src",e)}function ae(e,t){t.code2Function||(t.code2Function=new Function(e)),t.code2Function.call(window)}function le(e,t,n,o){return l(Ve.plugins)&&(n=function(e,t,n,o){var r;if(a(o.global))for(const n of o.global)l(n)&&s(n.loader)&&(t=n.loader(t,e,n.options));if(a(null===(r=o.modules)||void 0===r?void 0:r[n]))for(const r of o.modules[n])l(r)&&s(r.loader)&&(t=r.loader(t,e,r.options));return t}(e,n,t.name,Ve.plugins)),t.sandBox&&!o?(H.rawWindow.__MICRO_APP_PROXY_WINDOW__=t.sandBox.proxyWindow,`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${B}){;${n}\n}).call(proxyWindow,${B})}})(window.__MICRO_APP_PROXY_WINDOW__);`):n}function ce(e,t,n){const o=Array.from(e.children);o.length&&o.forEach((e=>{ce(e,t)}));for(const n of o)n instanceof HTMLLinkElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")?n.hasAttribute("href")&&n.setAttribute("href",g(n.getAttribute("href"),t.url)):ee(n,e,t):n instanceof HTMLStyleElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&Q(n,t):n instanceof HTMLScriptElement?oe(n,e,t):n instanceof HTMLMetaElement||n instanceof HTMLTitleElement?e.removeChild(n):n instanceof HTMLImageElement&&n.hasAttribute("src")&&n.setAttribute("src",g(n.getAttribute("src"),t.url))}function pe(e,t){const n=function(e){const t=R("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),r=n.querySelector("micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),m(e,t.name)}ce(n,t),t.source.links.size?te(n,t,o):t.onLoad(n),t.source.scripts.size?re(n,t):t.onLoad(n)}const ue=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(m("event-center: Invalid name"),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if(!s(t))return m("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&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&&(s(t)?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if(!l(t))return m("event-center: data must be object");let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}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 de(e,t){return r(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class he{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),ue.on("global",e,t)}removeGlobalDataListener(e){s(e)&&ue.off("global",e)}setGlobalData(e){M(),ue.dispatch("global",e)}getGlobalData(){return ue.getData("global")}clearGlobalDataListener(){const e=this.appName,t=ue.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 me extends he{addDataListener(e,t,n){ue.on(de(w(e),!1),t,n)}removeDataListener(e,t){s(t)&&ue.off(de(w(e),!1),t)}getData(e,t=!1){return ue.getData(de(w(e),t))}setData(e,t){ue.dispatch(de(w(e),!0),t)}clearDataListener(e){ue.off(de(w(e),!1))}}class fe extends he{constructor(e){super(),this.appName=w(e),!this.appName&&m(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,ue.on(de(this.appName,!0),e,t)}removeDataListener(e){s(e)&&ue.off(de(this.appName,!0),e)}getData(){return ue.getData(de(this.appName,!0))}dispatch(e){M(),ue.dispatch(de(this.appName,!1),e);const t=Me.get(this.appName);if((null==t?void 0:t.container)&&l(e)){const n=new CustomEvent("datachange",{detail:{data:e}});T(t.container).dispatchEvent(n)}}clearDataListener(){ue.off(de(this.appName,!0))}}function _e(e,t){if(t.__MICRO_APP_BOUND_WINDOW_FUNCTION)return t.__MICRO_APP_BOUND_WINDOW_FUNCTION;if(!function(e){var t;if(i(e.__MICRO_APP_ISCONSTRUCTOR))return e.__MICRO_APP_ISCONSTRUCTOR;const n=e.toString(),o=(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 e.__MICRO_APP_ISCONSTRUCTOR=o}(t)&&!function(e){return i(e.__MICRO_APP_ISBOUND_FUNCTION)?e.__MICRO_APP_ISBOUND_FUNCTION:e.__MICRO_APP_ISBOUND_FUNCTION=p(e)}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&u(n,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t.__MICRO_APP_BOUND_WINDOW_FUNCTION=n}return t}const Ae=new Map;let be=!1;const we=new Map;function ye(){const{rawDocument:e,rawDocumentAddEventListener:t,rawDocumentRemoveEventListener:n}=H;!be&&function(){if(be=!0,Object.getOwnPropertyDescriptor(document,"onclick"))return f("Cannot redefine document property onclick");const e=document.onclick;document.onclick=null;let t=!1;function n(e){Ae.forEach((t=>{s(t)&&t.call(document,e)}))}u(document,"onclick",{configurable:!0,enumerable:!0,get(){const e=D();return e?Ae.get(e):Ae.get("base")},set(e){const o=D();o?Ae.set(o,e):Ae.set("base",e),!t&&s(e)&&(t=!0,H.rawDocumentAddEventListener.call(H.rawDocument,"click",n,!1))}}),e&&(document.onclick=e)}(),document.addEventListener=function(n,o,r){var i;const s=D();if(s&&(!(null===(i=Me.get(s))||void 0===i?void 0:i.umdMode)||!p(o))){const e=we.get(s);if(e){const t=e.get(n);t?t.add(o):e.set(n,new Set([o]))}else we.set(s,new Map([[n,new Set([o])]]));o&&(o.__MICRO_APP_MARK_OPTIONS__=r)}t.call(e,n,o,r)},document.removeEventListener=function(t,o,r){var i;const s=D();if(s&&(!(null===(i=Me.get(s))||void 0===i?void 0:i.umdMode)||!p(o))){const e=we.get(s);if(e){const n=e.get(t);(null==n?void 0:n.size)&&n.has(o)&&n.delete(o)}}n.call(e,t,o,r)}}const ge=["unmount","appstate-change"];function Ee(e,t){return ge.includes(e)?`${e}-${t.__MICRO_APP_NAME__}`:e}const ve=["System","__cjsWrapper"],Ne=["location"],Ce=["window","self","globalThis"];class Pe{constructor(e,t){this.scopeProperties=["webpackJsonp"],this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.active=!1,this.microAppWindow={},this.getScopeProperties(e),this.proxyWindow=this.createProxyWindow(),this.initMicroAppWindow(this.microAppWindow,e,t),Object.assign(this,function(e){const t=e.__MICRO_APP_NAME__,n=new Map,o=new Map,r=new Map,{rawWindow:i,rawDocument:s,rawWindowAddEventListener:a,rawWindowRemoveEventListener:l,rawSetInterval:c,rawSetTimeout:p,rawClearInterval:u,rawClearTimeout:d,rawDocumentRemoveEventListener:h}=H;e.addEventListener=function(t,o,r){t=Ee(t,e);const s=n.get(t);s?s.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(i,t,o,r)},e.removeEventListener=function(t,o,r){t=Ee(t,e);const s=n.get(t);(null==s?void 0:s.size)&&s.has(o)&&s.delete(o),l.call(i,t,o,r)},e.setInterval=function(e,t,...n){const r=c.call(i,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const o=p.call(i,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.clearInterval=function(e){o.delete(e),u.call(i,e)},e.clearTimeout=function(e){r.delete(e),d.call(i,e)};const m=new Map,f=new Map;let _,A=new Map,b=new Map;return{recordUmdEffect:()=>{n.forEach(((e,t)=>{e.size&&m.set(t,new Set(e))})),o.size&&(A=new Map(o)),r.size&&(b=new Map(r)),_=Ae.get(t);const e=we.get(t);e&&e.forEach(((e,t)=>{e.size&&f.set(t,new Set(e))}))},rebuildUmdEffect:()=>{m.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),A.forEach((t=>{e.setInterval(t.handler,t.timeout,...t.args)})),b.forEach((t=>{e.setTimeout(t.handler,t.timeout,...t.args)})),_&&Ae.set(t,_),C(t),f.forEach(((e,t)=>{for(const n of e)document.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),C(null)},releaseEffect:()=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(i,t,n)})),n.clear()),o.size&&(o.forEach(((e,t)=>{u.call(i,t)})),o.clear()),r.size&&(r.forEach(((e,t)=>{d.call(i,t)})),r.clear()),Ae.delete(t);const e=we.get(t);e&&(e.forEach(((e,t)=>{for(const n of e)h.call(s,t,n)})),e.clear())}}}(this.microAppWindow))}start(e){this.active||(this.active=!0,this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e,H.rawWindow._babelPolyfill&&(H.rawWindow._babelPolyfill=!1),1==++Pe.activeCount&&ye())}stop(){this.active&&(this.active=!1,this.releaseEffect(),this.microAppWindow.microApp.clearDataListener(),this.microAppWindow.microApp.clearGlobalDataListener(),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(H.rawWindow,e)})),this.escapeKeys.clear(),0==--Pe.activeCount&&(document.addEventListener=H.rawDocumentAddEventListener,document.removeEventListener=H.rawDocumentRemoveEventListener))}recordUmdSnapshot(){this.microAppWindow.__MICRO_APP_UMD_MODE__=!0,this.recordUmdEffect(),function(e){const t=e.appName;e.umdDataListeners={global:new Set,normal:new Set};const n=ue.eventList.get("global");if(n)for(const o of n.callbacks)t===o.__APP_NAME__&&e.umdDataListeners.global.add(o);const o=ue.eventList.get(de(t,!0));o&&(e.umdDataListeners.normal=new Set(o.callbacks))}(this.microAppWindow.microApp),this.recordUmdinjectedValues=new Map,this.injectedKeys.forEach((e=>{this.recordUmdinjectedValues.set(e,Reflect.get(this.microAppWindow,e))}))}rebuildUmdSnapshot(){this.recordUmdinjectedValues.forEach(((e,t)=>{Reflect.set(this.proxyWindow,t,e)})),this.rebuildUmdEffect(),function(e){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__)}(this.microAppWindow.microApp)}getScopeProperties(e){var t;if(l(Ve.plugins)){if(a(Ve.plugins.global))for(const e of Ve.plugins.global)l(e)&&(a(e.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(e.scopeProperties)),a(e.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(e.escapeProperties)));if(a(null===(t=Ve.plugins.modules)||void 0===t?void 0:t[e]))for(const t of Ve.plugins.modules[e])l(t)&&(a(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),a(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}}createProxyWindow(){const e=H.rawWindow,t=new Map;return new Proxy(this.microAppWindow,{get:(t,n)=>{if(Reflect.has(t,n)||r(n)&&/^__MICRO_APP_/.test(n)||this.scopeProperties.includes(n))return Reflect.get(t,n);const o=Reflect.get(e,n);return s(o)?_e(e,o):o},set:(t,n,o)=>{if(this.active){if(Ne.includes(n))Reflect.set(e,n,o);else if(h.call(t,n)||!h.call(e,n)||this.scopeProperties.includes(n))Reflect.set(t,n,o),this.injectedKeys.add(n);else{const r=Object.getOwnPropertyDescriptor(e,n),{configurable:i,enumerable:s,writable:a,set:l}=r;u(t,n,{value:o,configurable:i,enumerable:s,writable:null!=a?a:!!l}),this.injectedKeys.add(n)}(this.escapeProperties.includes(n)||ve.includes(n)&&!Reflect.has(e,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(e,n,o),this.escapeKeys.add(n))}return!0},has:(t,n)=>this.scopeProperties.includes(n)?n in t:n in t||n in e,getOwnPropertyDescriptor:(n,o)=>{if(h.call(n,o))return t.set(o,"target"),Object.getOwnPropertyDescriptor(n,o);if(h.call(e,o)){t.set(o,"rawWindow");const n=Object.getOwnPropertyDescriptor(e,o);return n&&!n.configurable&&(n.configurable=!0),n}},defineProperty:(n,o,r)=>"rawWindow"===t.get(o)?Reflect.defineProperty(e,o,r):Reflect.defineProperty(n,o,r),ownKeys:t=>Reflect.ownKeys(e).concat(Reflect.ownKeys(t)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(t,n)=>!h.call(t,n)||(this.injectedKeys.has(n)&&this.injectedKeys.delete(n),this.escapeKeys.has(n)&&Reflect.deleteProperty(e,n),Reflect.deleteProperty(t,n))})}initMicroAppWindow(e,t,n){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=t,e.__MICRO_APP_PUBLIC_PATH__=y(n),e.__MICRO_APP_WINDOW__=e,e.microApp=new fe(t),e.rawWindow=H.rawWindow,e.rawDocument=H.rawDocument,e.removeDomScope=M,e.hasOwnProperty=t=>h.call(e,t)||h.call(H.rawWindow,t),this.setMappingPropertiesWithRawDescriptor(e),this.setHijackProperties(e,t)}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=H.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),u(e,"top",this.createDescriptorFormicroAppWindow("top",t)),u(e,"parent",this.createDescriptorFormicroAppWindow("parent",n)),Ce.forEach((t=>{u(e,t,this.createDescriptorFormicroAppWindow(t,this.proxyWindow))}))}createDescriptorFormicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(H.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}setHijackProperties(e,t){let n,o;d(e,{document:{get:()=>(O(t),H.rawDocument),configurable:!1,enumerable:!0},eval:{get:()=>(O(t),n||eval),set:e=>{n=e},configurable:!0,enumerable:!1},Image:{get:()=>(O(t),o||H.ImageProxy),set:e=>{o=e},configurable:!0,enumerable:!1}})}}function Oe(e,t,n,o){var r;if(!e)return m(`element does not exist in lifecycle ${n}`,t);e=T(e),M();const i=Object.assign({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),s(null===(r=Ve.lifeCycles)||void 0===r?void 0:r[n])&&Ve.lifeCycles[n](a),e.dispatchEvent(a)}function De(e,t,n={}){const o=new CustomEvent(`${e}-${t}`,{detail:n});window.dispatchEvent(o)}Pe.activeCount=0;const Me=new Map;class Se{constructor({name:e,url:t,ssrUrl:n,container:o,inline:r,scopecss:i,useSandbox:s,baseroute:a}){this.state=W.NOT_LOADED,this.keepAliveState=null,this.keepAliveContainer=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.libraryName=null,this.umdMode=!1,this.isPrefetch=!1,this.container=null,this.baseroute="",this.sandBox=null,this.container=null!=o?o:null,this.inline=null!=r&&r,this.baseroute=null!=a?a:"",this.ssrUrl=null!=n?n:"",this.name=e,this.url=t,this.useSandbox=s,this.scopecss=this.useSandbox&&i,this.source={links:new Map,scripts:new Map},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new Pe(e,t))}loadSourceCode(){var e;this.state=W.LOADING_SOURCE_CODE,F((e=this).ssrUrl||e.url,e.name,{cache:"no-cache"}).then((t=>{if(!t){const t="html is empty, please check in detail";return e.onerror(new Error(t)),m(t,e.name)}pe(t=t.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>"))),e)})).catch((t=>{m(`Failed to fetch data from ${e.url}, micro-app stop rendering`,e.name,t),e.onLoadError(t)}))}onLoad(e){if(2==++this.loadSourceLevel){if(this.source.html=e,this.isPrefetch||W.UNMOUNT===this.state)return;this.state=W.LOAD_SOURCE_FINISHED,this.mount()}}onLoadError(e){this.loadSourceLevel=-1,W.UNMOUNT!==this.state&&(this.onerror(e),this.state=W.LOAD_SOURCE_ERROR)}mount(e,t,n){var o,r,a;if(i(t)&&t!==this.inline&&(this.inline=t),this.container=null!==(o=this.container)&&void 0!==o?o:e,this.baseroute=null!=n?n:this.baseroute,2!==this.loadSourceLevel)return void(this.state=W.LOADING_SOURCE_CODE);let l;if(Oe(this.container,this.name,$.BEFOREMOUNT),this.state=W.MOUNTING,I(this.source.html,this.container,!this.umdMode),null===(r=this.sandBox)||void 0===r||r.start(this.baseroute),this.umdMode){null===(a=this.sandBox)||void 0===a||a.rebuildUmdSnapshot();try{l=this.umdHookMount()}catch(e){m("an error occurred in the mount function \n",this.name,e)}this.handleMounted(l)}else{let e=!1;!function(e,t,n){const o=Array.from(e.entries()),r=[],i=[];for(const[e,s]of o)s.isDynamic||(s.defer||s.async?(s.isExternal&&!s.code?r.push(F(e,t.name)):r.push(s.code),i.push([e,s]),s.module&&(n.moduleCount=n.moduleCount?++n.moduleCount:1)):(ie(e,t,s,!1),n(!1)));r.length?E(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(e=>{n.errorCount=n.errorCount?++n.errorCount:1,m(e,t.name)}),(()=>{i.forEach((([e,o])=>{o.code&&(ie(e,t,o,!1,n),!o.module&&n(!1))})),n(void 0===n.moduleCount||n.errorCount===r.length)})):n(!0)}(this.source.scripts,this,(t=>{var n;if(!this.umdMode){const{mount:e,unmount:t}=this.getUmdLibraryHooks();if(s(e)&&s(t)){this.umdHookMount=e,this.umdHookUnmount=t,this.umdMode=!0,null===(n=this.sandBox)||void 0===n||n.recordUmdSnapshot();try{l=this.umdHookMount()}catch(e){m("an error occurred in the mount function \n",this.name,e)}}}e||!0!==t&&!this.umdMode||(e=!0,this.handleMounted(l))}))}}handleMounted(e){c(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>this.onerror(e))):this.dispatchMountedEvent()}dispatchMountedEvent(){W.UNMOUNT!==this.state&&(this.state=W.MOUNTED,Oe(this.container,this.name,$.MOUNTED))}unmount(e,t){let n;if(this.state===W.LOAD_SOURCE_ERROR&&(e=!0),this.state=W.UNMOUNT,this.keepAliveState=null,this.keepAliveContainer=null,this.umdHookUnmount)try{n=this.umdHookUnmount()}catch(e){m("an error occurred in the unmount function \n",this.name,e)}De("unmount",this.name),this.handleUnmounted(e,n,t)}handleUnmounted(e,t,n){c(t)?t.then((()=>this.actionsForUnmount(e,n))).catch((()=>this.actionsForUnmount(e,n))):this.actionsForUnmount(e,n)}actionsForUnmount(e,t){var n;null===(n=this.sandBox)||void 0===n||n.stop(),e?this.actionsForCompletelyDestroy():this.umdMode&&this.container.childElementCount&&I(this.container,this.source.html,!1),Oe(this.container,this.name,$.UNMOUNT),this.container.innerHTML="",this.container=null,t&&t()}actionsForCompletelyDestroy(){!this.useSandbox&&this.umdMode&&delete window[this.libraryName],Me.delete(this.name)}hiddenKeepAliveApp(){const e=this.container;I(this.container,this.keepAliveContainer?this.keepAliveContainer:this.keepAliveContainer=document.createElement("div"),!1),this.container=this.keepAliveContainer,this.keepAliveState=k.KEEP_ALIVE_HIDDEN,De("appstate-change",this.name,{appState:"afterhidden"}),Oe(e,this.name,$.AFTERHIDDEN)}showKeepAliveApp(e){De("appstate-change",this.name,{appState:"beforeshow"}),Oe(e,this.name,$.BEFORESHOW),I(this.container,e,!1),this.container=e,this.keepAliveState=k.KEEP_ALIVE_SHOW,De("appstate-change",this.name,{appState:"aftershow"}),Oe(this.container,this.name,$.AFTERSHOW)}onerror(e){Oe(this.container,this.name,$.ERROR,e)}getAppState(){return this.state}getKeepAliveState(){return this.keepAliveState}getUmdLibraryHooks(){var e,t;if(W.UNMOUNT!==this.state){const n=null!==(t=null===(e=this.sandBox)||void 0===e?void 0:e.proxyWindow)&&void 0!==t?t:H.rawWindow;return this.libraryName=T(this.container).getAttribute("library")||`micro-app-${this.name}`,"object"==typeof n[this.libraryName]?n[this.libraryName]:{}}return{}}}const Re=new WeakMap;function Ie(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return Re.set(t,e),e}return n.scopecss&&!t.hasAttribute("ignore")?Q(t,n):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")){const e=document.createComment("link element with exclude attribute ignored by micro-app");return Re.set(t,e),e}if(t.hasAttribute("ignore"))return t;const{url:o,info:r,replaceComment:i}=ee(t,e,n,!0);if(o&&r){const e=R("style");return e.__MICRO_APP_LINK_PATH__=o,function(e,t,n,o,r){if(n.source.links.has(e))return r.textContent=n.source.links.get(e).code,Q(r,n),void _((()=>X(o)));if(Z.has(e)){const i=Z.get(e);return t.code=i,n.source.links.set(e,t),r.textContent=i,Q(r,n),void _((()=>X(o)))}F(e,n.name).then((i=>{t.code=i,n.source.links.set(e,t),t.isGlobal&&Z.set(e,i),r.textContent=i,Q(r,n),X(o)})).catch((e=>{m(e,n.name),Y(o)}))}(o,r,n,t,e),Re.set(t,e),e}return i?(Re.set(t,i),i):t}if(t instanceof HTMLScriptElement){const{replaceComment:o,url:r,info:i}=oe(t,e,n,!0)||{};if(r&&i){if(i.isExternal){const e=function(e,t,n,o){const r=()=>X(o);if(n.source.scripts.has(e)){const t=n.source.scripts.get(e);return!t.module&&_(r),ie(e,n,t,!0,r)}if(ne.has(e)){const o=ne.get(e);return t.code=o,n.source.scripts.set(e,t),!t.module&&_(r),ie(e,n,t,!0,r)}let i;return i=n.inline||t.module?R("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),F(e,n.name).then((s=>{t.code=s,n.source.scripts.set(e,t),t.isGlobal&&ne.set(e,s);try{s=le(e,n,s,t.module),n.inline||t.module?se(e,s,t.module,i,r):ae(s,t)}catch(t){console.error(`[micro-app from runDynamicScript] app ${n.name}: `,t,e)}!t.module&&X(o)})).catch((e=>{m(e,n.name),Y(o)})),i}(r,i,n,t);return Re.set(t,e),e}{const e=ie(r,n,i,!0);return Re.set(t,e),e}}return o?(Re.set(t,o),o):t}return t}function Ue(e,t,n,o,r){if(n===document.head){const i=e.container.querySelector("micro-app-head");return r&&!i.contains(r)?H.rawAppendChild.call(i,o):t!==H.rawRemoveChild||i.contains(o)?t===H.rawAppend||t===H.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}if(n===document.body){const i=e.container.querySelector("micro-app-body");return r&&!i.contains(r)?H.rawAppendChild.call(i,o):t!==H.rawRemoveChild||i.contains(o)?t===H.rawAppend||t===H.rawPrepend?t.call(i,o):t.call(i,o,r):n.contains(o)?t.call(n,o):o}return t===H.rawAppend||t===H.rawPrepend?t.call(n,o):t.call(n,o,r)}function Le(e){var t;return null!==(t=Re.get(e))&&void 0!==t?t:e}function Te(e,t,n,o){if(null==t?void 0:t.__MICRO_APP_NAME__){const r=Me.get(t.__MICRO_APP_NAME__);return(null==r?void 0:r.container)?Ue(r,o,e,Ie(e,t,r),n&&Le(n)):o===H.rawAppend||o===H.rawPrepend?o.call(e,t):o.call(e,t,n)}if(o===H.rawAppend||o===H.rawPrepend){const n=D();if(!(t instanceof Node)&&n){const r=Me.get(n);if(null==r?void 0:r.container){if(e===document.head)return o.call(r.container.querySelector("micro-app-head"),t);if(e===document.body)return o.call(r.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function xe(){!function(){const e=H.rawDocument;function t(t){var n,o,r;const i=D();return i&&t&&!L(t)&&e===this?null!==(r=null===(o=null===(n=Me.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:H.rawQuerySelector.call(this,t)}function n(t){var n,o,r;const i=D();return i&&t&&!L(t)&&e===this?null!==(r=null===(o=null===(n=Me.get(i))||void 0===n?void 0:n.container)||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:H.rawQuerySelectorAll.call(this,t)}Document.prototype.createElement=function(e,t){return We(H.rawCreateElement.call(this,e,t))},Document.prototype.createElementNS=function(e,t,n){return We(H.rawCreateElementNS.call(this,e,t,n))},Document.prototype.createDocumentFragment=function(){return We(H.rawCreateDocumentFragment.call(this))},Document.prototype.querySelector=t,Document.prototype.querySelectorAll=n,Document.prototype.getElementById=function(e){if(!D()||U(e))return H.rawGetElementById.call(this,e);try{return t.call(this,`#${e}`)}catch(t){return H.rawGetElementById.call(this,e)}},Document.prototype.getElementsByClassName=function(e){if(!D()||U(e))return H.rawGetElementsByClassName.call(this,e);try{return n.call(this,`.${e}`)}catch(t){return H.rawGetElementsByClassName.call(this,e)}},Document.prototype.getElementsByTagName=function(e){var t;const o=D();if(!o||L(e)||U(e)||!(null===(t=Me.get(o))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return H.rawGetElementsByTagName.call(this,e);try{return n.call(this,e)}catch(t){return H.rawGetElementsByTagName.call(this,e)}},Document.prototype.getElementsByName=function(e){if(!D()||U(e))return H.rawGetElementsByName.call(this,e);try{return n.call(this,`[name=${e}]`)}catch(t){return H.rawGetElementsByName.call(this,e)}}}(),Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if(l(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{r(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&f("property data must be an object",this.getAttribute("name"));else if((("src"===e||"srcset"===e)&&/^(img|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))&&this.__MICRO_APP_NAME__&&Me.has(this.__MICRO_APP_NAME__)){const n=Me.get(this.__MICRO_APP_NAME__);H.rawSetAttribute.call(this,e,g(t,n.url))}else H.rawSetAttribute.call(this,e,t)},Element.prototype.appendChild=function(e){return Te(this,e,null,H.rawAppendChild)},Element.prototype.insertBefore=function(e,t){return Te(this,e,t,H.rawInsertBefore)},Element.prototype.replaceChild=function(e,t){return Te(this,e,t,H.rawReplaceChild)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)Te(this,e[t],null,H.rawAppend),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)Te(this,e[t-1],null,H.rawPrepend),t--},Element.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Me.get(e.__MICRO_APP_NAME__);return(null==t?void 0:t.container)?Ue(t,H.rawRemoveChild,this,Le(e)):H.rawRemoveChild.call(this,e)}return H.rawRemoveChild.call(this,e)},Element.prototype.cloneNode=function(e){const t=H.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t}}function We(e){const t=D();return t&&(e.__MICRO_APP_NAME__=t),e}function $e(){C(null),Document.prototype.createElement=H.rawCreateElement,Document.prototype.createElementNS=H.rawCreateElementNS,Document.prototype.createDocumentFragment=H.rawCreateDocumentFragment,Document.prototype.querySelector=H.rawQuerySelector,Document.prototype.querySelectorAll=H.rawQuerySelectorAll,Document.prototype.getElementById=H.rawGetElementById,Document.prototype.getElementsByClassName=H.rawGetElementsByClassName,Document.prototype.getElementsByTagName=H.rawGetElementsByTagName,Document.prototype.getElementsByName=H.rawGetElementsByName,Element.prototype.setAttribute=H.rawSetAttribute,Element.prototype.appendChild=H.rawAppendChild,Element.prototype.insertBefore=H.rawInsertBefore,Element.prototype.replaceChild=H.rawReplaceChild,Element.prototype.removeChild=H.rawRemoveChild,Element.prototype.append=H.rawAppend,Element.prototype.prepend=H.rawPrepend,Element.prototype.cloneNode=H.rawCloneNode}let ke=!1;function Be(){Fe(),Me.forEach((e=>{e.container&&T(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Me.clear(),He.size&&(He.clear(),$e())}function Fe(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",Be,!1)}const He=new Map;function Ke(e){class n extends HTMLElement{constructor(){super(),this.isWating=!1,this.cacheData=null,this.hasConnected=!1,this.appName="",this.appUrl="",this.ssrUrl="",this.version=t,this.handleAttributeUpdate=()=>{this.isWating=!1;const e=w(this.getAttribute("name")),t=b(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Me.get(e);if(e!==this.appName&&n&&W.UNMOUNT!==n.getAppState()&&k.KEEP_ALIVE_HIDDEN!==n.getKeepAliveState()&&!n.isPrefetch)return this.setAttribute("name",this.appName),m(`app name conflict, an app named ${e} is running`,this.appName);e===this.appName&&t===this.appUrl||(e===this.appName?this.handleUnmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)},this.querySelector("micro-app-head")||this.performWhenFirstCreated()}static get observedAttributes(){return["name","url"]}connectedCallback(){this.hasConnected=!0,He.has(this)||this.performWhenFirstCreated(),_((()=>Oe(this,this.appName,$.CREATED))),this.initialMount()}disconnectedCallback(){this.hasConnected=!1,this.getKeepAliveModeResult()?this.handleHiddenKeepAliveApp():(He.delete(this),this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{0===He.size&&$e()})))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===x.NAME?"appName":"appUrl"]!==n)if(e!==x.URL||this.appUrl)if(e!==x.NAME||this.appName)this.isWating||(this.isWating=!0,_(this.handleAttributeUpdate));else{const e=w(n);if(!e)return m(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(Ve.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=b(n,this.appName)))return m(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.hasConnected&&this.initialMount()}performWhenFirstCreated(){1===He.set(this,!0).size&&(xe(),function(){if(!ke){ke=!0;const e=R("style");e.setAttribute("type","text/css"),e.textContent=`\n${Ve.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,H.rawDocument.head.appendChild(e)}}(),Fe(),window.__MICRO_APP_ENVIRONMENT__&&window.addEventListener("unmount",Be,!1))}initialMount(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&s(this.attachShadow)&&this.attachShadow({mode:"open"}),this.getDisposeResult("ssr")?this.ssrUrl=g(H.rawWindow.location.pathname,this.appUrl):this.ssrUrl&&(this.ssrUrl=""),Me.has(this.appName)){const e=Me.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===k.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t!==n||!e.isPrefetch&&e.getAppState()!==W.UNMOUNT?e.isPrefetch||e.getAppState()===W.UNMOUNT?(f(`the ${e.isPrefetch?"prefetch":"unmounted"} app with url: ${t} is replaced by a new app`,this.appName),this.handleCreateApp()):m(`app name conflict, an app named ${this.appName} is running`,this.appName):this.handleAppMount(e)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.getDisposeResult("ssr")?this.ssrUrl=g(H.rawWindow.location.pathname,t):this.ssrUrl&&(this.ssrUrl=""),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.getKeepAliveState()===k.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):m(`app name conflict, an app named ${this.appName} is running`,this.appName):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleAppMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!r(t)||!t)||(m(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleAppMount(e){e.isPrefetch=!1,_((()=>{var t;return e.mount(null!==(t=this.shadowRoot)&&void 0!==t?t:this,this.getDisposeResult("inline"),this.getBaseRouteCompatible())}))}handleCreateApp(){var e;Me.has(this.appName)&&Me.get(this.appName).actionsForCompletelyDestroy();const t=new Se({name:this.appName,url:this.appUrl,ssrUrl:this.ssrUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,inline:this.getDisposeResult("inline"),scopecss:!(this.getDisposeResult("disableScopecss")||this.getDisposeResult("shadowDOM")),useSandbox:!this.getDisposeResult("disableSandbox"),baseroute:this.getBaseRouteCompatible()});Me.set(this.appName,t)}handleUnmount(e,t){const n=Me.get(this.appName);n&&n.getAppState()!==W.UNMOUNT&&n.unmount(e,t)}handleHiddenKeepAliveApp(){const e=Me.get(this.appName);e&&e.getAppState()!==W.UNMOUNT&&e.getKeepAliveState()!==k.KEEP_ALIVE_HIDDEN&&e.hiddenKeepAliveApp()}handleShowKeepAliveApp(e){_((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleSpecialProperties(e)||Ve[e])&&this.compatibleDisablSpecialProperties(e)}compatibleSpecialProperties(e){return"disableScopecss"===e?this.hasAttribute("disableScopecss")||this.hasAttribute("disable-scopecss"):"disableSandbox"===e?this.hasAttribute("disableSandbox")||this.hasAttribute("disable-sandbox"):this.hasAttribute(e)}compatibleDisablSpecialProperties(e){return"disableScopecss"===e?"false"!==this.getAttribute("disableScopecss")&&"false"!==this.getAttribute("disable-scopecss"):"disableSandbox"===e?"false"!==this.getAttribute("disableSandbox")&&"false"!==this.getAttribute("disable-sandbox"):"false"!==this.getAttribute(e)}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()}set data(e){this.appName?Ve.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Ve.getData(this.appName,!0):this.cacheData?this.cacheData:null}}window.customElements.define(e,n)}function je(e){if(!n)return m("preFetch is only supported in browser environment");v((()=>{s(e)&&(e=e()),function(e){const t=[];return a(e)&&e.forEach((e=>{l(e)&&(e.name=w(e.name),e.url=b(e.url,e.name),e.name&&e.url&&!Me.has(e.name)&&t.push(e))})),t}(e).forEach((e=>{var t,n;const o=new Se({name:e.name,url:e.url,scopecss:!(null!==(t=e.disableScopecss)&&void 0!==t?t:Ve.disableScopecss),useSandbox:!(null!==(n=e.disableSandbox)&&void 0!==n?n:Ve.disableSandbox)});o.isPrefetch=!0,Me.set(e.name,o)}))}))}function Ge(e,t){const n=Me.get(w(e));return new Promise((o=>{if(n)if(n.getAppState()===W.UNMOUNT||n.isPrefetch)(null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o();else if(n.getKeepAliveState()===k.KEEP_ALIVE_HIDDEN)(null==t?void 0:t.destroy)?n.unmount(!0,o):(null==t?void 0:t.clearAliveState)?n.unmount(!1,o):o();else{const e=T(n.container),r=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()},i=()=>{e.removeEventListener("unmount",r),e.removeEventListener("afterhidden",i),o()};if(e.addEventListener("unmount",r),e.addEventListener("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"),"string"==typeof t&&e.setAttribute("destroy",t),"string"==typeof n&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const t=e.getAttribute("keep-alive");e.removeAttribute("keep-alive"),e.parentNode.removeChild(e),e.setAttribute("keep-alive",t)}else e.parentNode.removeChild(e)}else f(`app ${e} does not exist`),o()}))}class qe extends me{constructor(){super(...arguments),this.tagName="micro-app",this.preFetch=je}start(e){if(!n||!window.customElements)return m("micro-app is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return m(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(window.customElements.get(this.tagName))return f(`element ${this.tagName} is already defined`);if(K(),e&&l(e)&&(this.shadowDOM=e.shadowDOM,this.destroy=e.destroy,this.destory=e.destory,this.inline=e.inline,this.disableScopecss=e.disableScopecss,this.disableSandbox=e.disableSandbox,this.ssr=e.ssr,s(e.fetch)&&(this.fetch=e.fetch),l(e.lifeCycles)&&(this.lifeCycles=e.lifeCycles),e.preFetchApps&&je(e.preFetchApps),e.globalAssets&&(l(t=e.globalAssets)&&v((()=>{if(a(t.js)){const e=t.js.filter((e=>r(e)&&e.includes(".js")&&!ne.has(e))),n=[];e.forEach((e=>{n.push(F(e))})),E(n,(t=>{const n=e[t.index];ne.has(n)||ne.set(n,t.data)}),(e=>{m(e)}))}if(a(t.css)){const e=t.css.filter((e=>r(e)&&e.includes(".css")&&!Z.has(e))),n=[];e.forEach((e=>{n.push(F(e))})),E(n,(t=>{const n=e[t.index];Z.has(n)||Z.set(n,t.data)}),(e=>{m(e)}))}}))),l(e.plugins))){const t=e.plugins.modules;if(l(t))for(const e in t){const n=w(e);n&&e!==n&&(t[n]=t[e],delete t[e])}this.plugins=e.plugins}var t;Ke(this.tagName)}}var Ve=new qe;e.EventCenterForMicroApp=fe,e.MicroApp=qe,e.default=Ve,e.getActiveApps=function(e){const t=[];return Me.forEach(((n,o)=>{W.UNMOUNT===n.getAppState()||n.isPrefetch||e&&k.KEEP_ALIVE_HIDDEN===n.getKeepAliveState()||t.push(o)})),t},e.getAllApps=function(){return Array.from(Me.keys())},e.preFetch=je,e.pureCreateElement=R,e.removeDomScope=M,e.unmountAllApps=function(e){return Array.from(Me.keys()).reduce(((t,n)=>t.then((()=>Ge(n,e)))),Promise.resolve())},e.unmountApp=Ge,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.umd.js.map
{
"name": "@micro-zoe/micro-app",
"version": "0.7.0",
"version": "0.7.1",
"description": "A lightweight, efficient and powerful micro front-end framework",

@@ -5,0 +5,0 @@ "private": false,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc