找回密码
 立即注册
搜索
热搜: 丝袜 魅魔 黑丝
查看: 6|回复: 0

19793114_第三章 镜野七罪

[复制链接]

13万

主题

343

回帖

22万

积分

管理员

站长

UID
1
积分
224400
余额
13 R
Moe币
84881
在线时间
279 小时
注册时间
2025-12-28
最后登录
2026-11-9
发表于 2026-9-3 23:00:59 | 显示全部楼层 |阅读模式
const An="1.0.0-rc.19",rt=typeof window<"u",or=typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:Function("return this")(),bn=()=>!1,se=Array.isArray,Z=Object.assign,H=Object.defineProperty,k=Object.defineProperties,Pn=Object.prototype.toString,ge=Object.prototype.hasOwnProperty,q=t=>Pn.call(t);function pe(t){return t===void 0}function Te(t){return t===null}function T(t){return typeof t=="string"}function ir(t){return typeof t=="boolean"}function pt(t){return typeof t=="number"}function P(t){return typeof t=="function"}function B(t){return q(t)==="[object Object]"}function Rn(t){return!Te(t)&&typeof t=="object"}function mt(t){return q(t)==="[object Promise]"}function Sn(t){var e;return P(t)&&((e=t.name)===null||e===void 0?void 0:e.indexOf("bound "))===0&&!t.hasOwnProperty("prototype")}function nt(t){var e;if(P(t)){const r=t.toString();return((e=t.prototype)===null||e===void 0?void 0:e.constructor)===t&&Object.getOwnPropertyNames(t.prototype).length>1||/^function\s+[A-Z]/.test(r)||/^class\s+/.test(r)}return!1}function yn(t){return typeof ShadowRoot<"u"&&t instanceof ShadowRoot}function ot(t){var e;return t instanceof URL||!!(!((e=t)===null||e===void 0)&&e.href)}function ce(t){var e;return t instanceof Element||T((e=t)===null||e===void 0?void 0:e.tagName)}function ye(t){var e;return t instanceof Node||pt((e=t)===null||e===void 0?void 0:e.nodeType)}function Mn(t){return q(t)==="[object HTMLAnchorElement]"}function On(t){return q(t)==="[object HTMLAudioElement]"}function Dn(t){return q(t)==="[object HTMLVideoElement]"}function sr(t){return q(t)==="[object HTMLLinkElement]"}function Pt(t){return q(t)==="[object HTMLStyleElement]"}function ve(t){return q(t)==="[object HTMLScriptElement]"}function Cn(t){return q(t)==="[object HTMLDivElement]"}function ar(t){return q(t)==="[object HTMLImageElement]"}function In(t){return q(t)==="[object HTMLBaseElement]"}function ze(t){return q(t)==="[object DocumentFragment]"}function Ln(t){return q(t)==="[object ShadowRoot]"}function Ye(t){return ce(t)&&t.tagName.toUpperCase()==="MICRO-APP-BODY"}function xn(t){return ce(t)&&t.tagName.toUpperCase()==="MICRO-APP-HEAD"}function Tn(t){let e=q(t)==="[object HTMLElement]";if(e){const r=t.tagName.toUpperCase();e=e&&!r.startsWith("MICRO-APP")}return e}function Nn(t){return q(t)==="[object ProxyDocument]"}function cr(t,e){try{return U(t).pathname.split(".").pop()===e}catch{return!1}}function te(t,e,r){if(t==null)throw new TypeError("includes target is null or undefined");const n=Object(t),o=parseInt(n.length,10)||0;if(o===0)return!1;r=parseInt(r,10)||0;let i=Math.max(r>=0?r:o+r,0);for(;i<o;){if(e===n||e!==e&&n!==n)return!0;i++}return!1}function I(t,e=null,...r){const n=e&&T(e)?` app ${e}:`:"";T(t)?console.error(`[micro-app]${n} ${t}`,...r):console.error(`[micro-app]${n}`,t,...r)}function me(t,e=null,...r){const n=e&&T(e)?` app ${e}:`:"";T(t)?console.warn(`[micro-app]${n} ${t}`,...r):console.warn(`[micro-app]${n}`,t,...r)}function ee(t,...e){Promise.resolve().then(t.bind(null,...e))}function Bn(t,e=0,...r){setTimeout(t.bind(null,...r),e)}const U=function(){class t extends URL{}return(e,r)=>r?new t(""+e,r):new t(""+e)}();function Rt(t){return t.startsWith("//")?`${or.location.protocol}${t}`:t}function _t(t,e=null){if(!T(t)||!t)return"";try{const{origin:r,pathname:n,search:o}=U(Rt(t),(window.rawWindow||window).location.href),i=`${r}${n}${o}`;return/^https?:\/\//.test(i)?i:""}catch(r){return I(r,e),""}}function G(t){return!T(t)||!t?"":t.replace(/(^\d+)|([^\w\d-_])/gi,"")}function it(t){const{origin:e,pathname:r}=U(t);if(/\.(\w+)$/.test(r)){const n=`${e}${r}`.split("/");return n.pop(),n.join("/")+"/"}return`${e}${r}/`.replace(/\/\/$/,"/")}function X(t,e){return!t||/^((((ht|f)tps?)|file):)?\/\//.test(t)||/^(data|blob):/.test(t)?t:U(t,it(Rt(e))).toString()}function Un(t){const e=t.split("/");return e.pop(),Rt(e.join("/")+"/")}function st(t,e,r,n){let o=0;function i(){++o===t.length&&n&&n()}t.forEach((s,a)=>{mt(s)?s.then(c=>{e({data:c,index:a}),i()}).catch(c=>{r({error:c,index:a}),i()}):(e({data:s,index:a}),i())})}function Wn(){return"noModule"in document.createElement("script")}function Fn(){return"inline-"+Math.random().toString(36).substr(2,15)}function Hn(t){return t.filter(function(e){return e in this?!1:this[e]=!0},Object.create(null))}const at=or.requestIdleCallback||function(t){const e=Date.now();return setTimeout(function(){t({didTimeout:!1,timeRemaining(){return Math.max(0,50-(Date.now()-e))}})},1)};function lr(t){return new Promise(e=>{at(()=>{t(e)})})}let St=null;function gt(t){St=t}function K(){return St}function Ne(t){St!==t&&!Ot()&&(gt(t),ee(()=>{gt(null)}))}let yt=null;function vt(t){yt=t}function Ve(){return yt}function Mt(t){yt!==t&&!Ot()&&(vt(t),ee(()=>{vt(null)}))}let Ce=!1;function Ot(){return Ce}function $(t){t!==!1?(gt(null),vt(null),t&&!Ce&&(Ce=!0,ee(()=>{Ce=!1}))):Ce=!1}function z(t,e){const r=(window.rawDocument||document).createElement(t,e);return r.__MICRO_APP_NAME__&&delete r.__MICRO_APP_NAME__,r.__PURE_ELEMENT__=!0,r}function he(t){return!t||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(t)}function Pe(t){return/^body$/i.test(t)||/^head$/i.test(t)||/^html$/i.test(t)||/^title$/i.test(t)||/^:root$/i.test(t)}function le(t){return yn(t)?t.host:t}function ft(t){return t?t.replace(/^\s+|\s+$/g,""):""}function Ft(){return navigator.userAgent.indexOf("Firefox")>-1}function Ht(t){const e={},r=t.split("&");for(const n of r){const o=n.indexOf("="),i=o<0?n:n.slice(0,o),s=o<0?null:n.slice(o+1);if(i in e){let a=e;se(a)||(a=e=[a]),a.push(s)}else e=s}return e}function Je(t){let e="";for(const r in t){const n=t[r];Te(n)?e+=(e.length?"&":"")+r:(se(n)?n:[n]).forEach(i=>{pe(i)||(e+=(e.length?"&":"")+r,Te(i)||(e+="="+i))})}return e}function jt(){const t=new Set;function e(r){return t.add(r),()=>t.has(r)?t.delete(r):!1}return{add:e,list:()=>t}}function jn(){const t=new Map;function e(r,n){return t.set(r,n),()=>t.has(r)?t.delete(r):!1}return{add:e,get:r=>t.get(r),delete:r=>t.has(r)?t.delete(r):!1}}function Et(t){const e=t.attributes,r=new Map;for(let n=0;n<e.length;n++)r.set(e[n].name,e[n].value);return r}function Be(t,e){t?t.push(()=>lr(r=>{e(),r()})):e()}function Ue(t){return(t==null?void 0:t.reduce((e,r)=>e.then(r),Promise.resolve()))||null}function We(t){return t.startsWith("inline-")}function $t(t,e,r,...n){try{P(t)&&t(...n)}catch(o){I(`An error occurred in app ${e} window.${r}
`,null,o)}}function $n(t){for(;t!=null&&t.firstChild;)t.removeChild(t.firstChild)}function Gt(t,e){if(t==null)return!1;if(!P(e))throw new TypeError("Right-hand side of 'instanceof' is not callable");let r=Object.getPrototypeOf(t);for(;r;){if(r===e.prototype)return!0;r=Object.getPrototypeOf(r)}return!1}const Gn=["mounted","unmount"];function wt(t,e){return Gn.includes(t)?`${t}-${e}`:t}function Kn(t){return B(t)?!Object.keys(t).length:!0}function qn(t,e){Object.defineProperties(t,{currentTarget:{get(){return e}},target:{get(){return e}}})}function ue(t,e,r,n){var o;if(!t)return me(`element does not exist in lifecycle ${r}`,e);t=le(t),$();const i=Z({name:e,container:t},n&&{error:n}),s=new CustomEvent(r,{detail:i});qn(s,t),P((o=w.options.lifeCycles)===null||o===void 0?void 0:o[r])&&w.options.lifeCycles[r](s,e),t.dispatchEvent(s)}function oe(t,e,r={}){var n;const o=new CustomEvent(wt(e,t.name),{detail:r});(n=t.sandBox)===null||n===void 0||n.microAppWindow.dispatchEvent(o)}function Ee(t,e=null,r={}){return $(),P(w.options.fetch)?w.options.fetch(t,r,e):window.fetch(t,r).then(n=>n.text())}class Dt{static getInstance(){return this.instance||(this.instance=new Dt),this.instance}run(e,r){const n=e.name,o=e.ssrUrl||e.url;(cr(o,"js")?Promise.resolve(`<micro-app-head><script src='${o}'><\/script></micro-app-head><micro-app-body></micro-app-body>`):Ee(o,n,{cache:"no-cache"})).then(a=>{if(!a){const c="html is empty, please check in detail";return e.onerror(new Error(c)),I(c,n)}a=this.formatHTML(o,a,n),r(a,e)}).catch(a=>{I(`Failed to fetch data from ${e.url}, micro-app stop rendering`,n,a),e.onLoadError(a)})}formatHTML(e,r,n){return this.processHtml(e,r,n,w.options.plugins).replace(/<head[^>]*>[\s\S]*?<\/head>/i,o=>o.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>")).replace(/<body[^>]*>[\s\S]*?<\/body>/i,o=>o.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>"))}processHtml(e,r,n,o){var i;if(!o)return r;const s=[];return o.global&&s.push(...o.global),!((i=o.modules)===null||i===void 0)&&i[n]&&s.push(...o.modules[n]),s.length>0?s.reduce((a,c)=>B(c)&&P(c.processHtml)?c.processHtml(a,e):a,r):r}}const Qn=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,Kt=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function Vn(t,e){t=e?`${e} ${t}`:t;const r=new Error(t);throw r.reason=t,e&&(r.filename=e),r}class Xn{constructor(){this.cssText="",this.prefix="",this.baseURI="",this.linkPath="",this.result="",this.scopecssDisable=!1,this.scopecssDisableSelectors=[],this.scopecssDisableNextLine=!1,this.mediaRule=this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/,"@media"),this.supportsRule=this.createMatcherForRuleWithChildRule(/^@supports *([^{]+)/,"@supports"),this.documentRule=this.createMatcherForRuleWithChildRule(/^@([-\w]+)?document *([^{]+)/,"@document"),this.hostRule=this.createMatcherForRuleWithChildRule(/^@host\s*/,"@host"),this.importRule=this.createMatcherForNoneBraceAtRule("import"),this.charsetRule=this.createMatcherForNoneBraceAtRule("charset"),this.namespaceRule=this.createMatcherForNoneBraceAtRule("namespace"),this.containerRule=this.createMatcherForRuleWithChildRule(/^@container *([^{]+)/,"@container")}exec(e,r,n,o){return this.cssText=e,this.prefix=r,this.baseURI=n,this.linkPath=o||"",this.matchRules(),Ft()?decodeURIComponent(this.result):this.result}reset(){this.cssText=this.prefix=this.baseURI=this.linkPath=this.result="",this.scopecssDisable=this.scopecssDisableNextLine=!1,this.scopecssDisableSelectors=[]}matchRules(){for(this.matchLeadingSpaces(),this.matchComments();this.cssText.length&&this.cssText.charAt(0)!=="}"&&(this.matchAtRule()||this.matchStyleRule());)this.matchComments()}matchStyleRule(){const e=this.formatSelector(!0);return this.scopecssDisableNextLine=!1,e?(this.recordResult(e),this.matchComments(),this.styleDeclarations(),this.matchLeadingSpaces(),!0):this.printError("selector missing",this.linkPath)}formatSelector(e){const r=this.commonMatch(/^[^{]+/,e);if(!r)return!1;const n={};return r[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g,(i,s,a)=>{const c=`__mock_${s}Value__`;return n[c]=a,i.replace(a,c)}).replace(/(^|,[\n\s]*)([^,]+)/g,(i,s,a)=>(a=ft(a),a=a.replace(/\[[^\]=]+(?:=([^\]]+))?\]/g,(c,h)=>n[h]?c.replace(h,n[h]):c),a&&!(this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(a))||Qn.test(a))&&(Kt.test(a)?a=a.replace(Kt,this.prefix+" micro-app-body"):a=this.prefix+" "+a),s+a))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?!0:this.printError("Declaration missing '}'",this.linkPath)):this.printError("Declaration missing '{'",this.linkPath)}matchAllDeclarations(e=0){let r=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^{}/])*/,!0)[0];if(r&&(!this.scopecssDisableNextLine&&(!this.scopecssDisable||this.scopecssDisableSelectors.length)&&(r=r.replace(/url\((["']?)(.*?)\1\)/gm,(n,o,i)=>/^((data|blob):|#|%23)/.test(i)||/^(https?:)?\/\//.test(i)?n:(/^((\.\.?\/)|[^/])/.test(i)&&this.linkPath&&(this.baseURI=Un(this.linkPath)),`url("${X(i,this.baseURI)}")`))),this.recordResult(r)),this.scopecssDisableNextLine=!1,!!this.cssText.length){if(this.cssText.charAt(0)==="/")this.cssText.charAt(1)==="*"?this.matchComments():this.commonMatch(/\/+/);else if(this.cssText.charAt(0)==="{")this.matchOpenBrace(),e++;else if(this.cssText.charAt(0)==="}"){if(e<1)return;this.matchCloseBrace(),e--}return this.matchAllDeclarations(e)}}matchAtRule(){return this.cssText[0]!=="@"?!1:(this.scopecssDisableNextLine=!1,this.keyframesRule()||this.mediaRule()||this.customMediaRule()||this.supportsRule()||this.importRule()||this.charsetRule()||this.namespaceRule()||this.containerRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule()||this.layerRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return this.printError("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return this.printError("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError("@keyframes missing '}'",this.linkPath)}keyframeRule(){let e;const r=[];for(;e=this.commonMatch(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)r.push(e[1]),this.commonMatch(/^,\s*/);return r.length?(this.styleDeclarations(),this.matchLeadingSpaces(),!0):!1}customMediaRule(){return this.commonMatch(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/)?(this.matchLeadingSpaces(),!0):!1}pageRule(){return this.commonMatch(/^@page */)?(this.formatSelector(!1),this.scopecssDisableNextLine=!1,this.commonHandlerForAtRuleWithSelfRule("page")):!1}fontFaceRule(){return this.commonMatch(/^@font-face\s*/)?this.commonHandlerForAtRuleWithSelfRule("font-face"):!1}layerRule(){return this.commonMatch(/^@layer\s*([^{;]+)/)?this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError("@layer missing '}'",this.linkPath)):!!this.commonMatch(/^[;]+/):!1}createMatcherForRuleWithChildRule(e,r){return()=>this.commonMatch(e)?this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError(`${r} missing '}'`,this.linkPath)):this.printError(`${r} missing '{'`,this.linkPath):!1}createMatcherForNoneBraceAtRule(e){const r=new RegExp("^@"+e+"\\s*([^;]+);");return()=>this.commonMatch(r)?(this.matchLeadingSpaces(),!0):!1}commonHandlerForAtRuleWithSelfRule(e){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError(`@${e} missing '}'`,this.linkPath)):this.printError(`@${e} missing '{'`,this.linkPath)}matchComments(){for(;this.matchComment(););}matchComment(){if(this.cssText.charAt(0)!=="/"||this.cssText.charAt(1)!=="*")return!1;this.scopecssDisableNextLine=!1;let e=2;for(;this.cssText.charAt(e)!==""&&(this.cssText.charAt(e)!=="*"||this.cssText.charAt(e+1)!=="/");)++e;if(e+=2,this.cssText.charAt(e-1)==="")return this.printError("End of comment missing",this.linkPath);let r=this.cssText.slice(2,e-2);return this.recordResult(`/*${r}*/`),r=ft(r.replace(/^\s*!/,"")),r==="scopecss-disable-next-line"?this.scopecssDisableNextLine=!0:/^scopecss-disable/.test(r)?r==="scopecss-disable"?this.scopecssDisable=!0:(this.scopecssDisable=!0,r.replace("scopecss-disable","").split(",").forEach(o=>{this.scopecssDisableSelectors.push(ft(o))})):r==="scopecss-enable"&&(this.scopecssDisable=!1,this.scopecssDisableSelectors=[]),this.cssText=this.cssText.slice(e),this.matchLeadingSpaces(),!0}commonMatch(e,r=!1){const n=e.exec(this.cssText);if(!n)return;const o=n[0];return this.cssText=this.cssText.slice(o.length),r||this.recordResult(o),n}matchOpenBrace(){return this.commonMatch(/^{\s*/)}matchCloseBrace(){return this.commonMatch(/^}\s*/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){Ft()?this.result+=encodeURIComponent(e):this.result+=e}printError(e,r){this.cssText.length&&Vn(e,r)}}function qt(t,e,r,n,o){if(!t.__MICRO_APP_HAS_SCOPED__){t.__MICRO_APP_HAS_SCOPED__=!0;let i=null;try{i=Ie.exec(t.textContent,r,n,o),Ie.reset()}catch(s){Ie.reset(),I(`An error occurred while parsing CSS:
`,e,s)}i&&(t.textContent=i)}}let Ie;function ct(t,e,r){if(e.scopecss){const n=Ct(e.name);if(Ie||(Ie=new Xn),t.textContent){qt(t,e.name,n,e.url,r);const o=new MutationObserver(()=>{const i=t.textContent&&new RegExp(n).test(t.textContent);o.disconnect(),i||(t.__MICRO_APP_HAS_SCOPED__=!1),ct(t,e,r)});o.observe(t,{childList:!0,characterData:!0})}else{const o=new MutationObserver(function(){o.disconnect(),t.textContent&&!t.hasAttribute("data-styled")&&qt(t,e.name,n,e.url,r)});o.observe(t,{childList:!0})}}return t}function Ct(t,e=!1){const r=e?"\\":"";return`${w.tagName}${r}[name=${t}${r}]`}function ur(t,e){Object.defineProperties(t,{currentTarget:{get(){return e}},srcElement:{get(){return e}},target:{get(){return e}}})}function hr(t){const e=new CustomEvent("load");ur(e,t),P(t.onload)?t.onload(e):t.dispatchEvent(e)}function dr(t){const e=new CustomEvent("error");ur(e,t),P(t.onerror)?t.onerror(e):t.dispatchEvent(e)}function zn(){const t=new Map,e=new Map;function r(n){return{setInfo(o,i){n.set(o,i)},getInfo(o){var i;return(i=n.get(o))!==null&&i!==void 0?i:null},hasInfo(o){return n.has(o)},deleteInfo(o){return n.delete(o)}}}return{link:r(t),script:Object.assign(Object.assign({},r(e)),{deleteInlineInfo(n){n.forEach(o=>{We(o)&&e.delete(o)})}})}}var Y=zn();function Yn(t,e,r){const n=r.appSpace;for(const o in n)if(o!==t){const i=n[o];if(i.parsedCode)return i.parsedCode.replace(new RegExp(Ct(o,!0),"g"),e)}}function Jn(t,e){e.forEach((r,n)=>{n!=="rel"&&(n==="href"&&(n="data-origin-href"),l.rawSetAttribute.call(t,n,r))})}function fr(t,e,r,n=!1){const o=t.getAttribute("rel");let i=t.getAttribute("href"),s=null;if(o==="stylesheet"&&i){i=X(i,r.url);let a=Y.link.getInfo(i);const c={attrs:Et(t)};if(a?a.appSpace[r.name]=a.appSpace[r.name]||c:a={code:"",appSpace:{[r.name]:c}},Y.link.setInfo(i,a),!n)r.source.links.add(i),s=document.createComment(`link element with href=${i} move to micro-app-head as style element`),a.appSpace[r.name].placeholder=s;else return{address:i,linkInfo:a}}else o&&["prefetch","preload","prerender","modulepreload","icon"].includes(o)?n?s=document.createComment(`link element with rel=${o}${i?" & href="+i:""} removed by micro-app`):e==null||e.removeChild(t):i&&l.rawSetAttribute.call(t,"href",X(i,r.url));if(n)return{replaceComment:s};if(s)return e==null?void 0:e.replaceChild(s,t)}function Zn(t,e,r,n){const o=Array.from(e.source.links),i=o.map(a=>{const c=Y.link.getInfo(a);return c.code?c.code:Ee(a,e.name)}),s=n?[]:null;st(i,a=>{Be(s,()=>kn(o[a.index],a.data,r,e))},a=>{I(a,e.name)},()=>{n?n.then(()=>{s.push(()=>Promise.resolve(e.onLoad({html:t}))),Ue(s)}):e.onLoad({html:t})})}function kn(t,e,r,n){const o=Y.link.getInfo(t);o.code=e;const i=o.appSpace[n.name],s=i.placeholder;if(s){const a=z("style");pr(n,t,a,o,i.attrs),s.parentNode?s.parentNode.replaceChild(a,s):r.appendChild(a),i.placeholder=null}}function pr(t,e,r,n,o){if(t.scopecss){const i=n.appSpace[t.name];if(i.prefix=i.prefix||Ct(t.name),i.parsedCode)r.textContent=i.parsedCode;else{const s=Yn(t.name,i.prefix,n);s?r.textContent=s:(r.textContent=n.code,ct(r,t,e)),i.parsedCode=r.textContent}}else r.textContent=n.code;Jn(r,o)}function eo(t,e,r,n){const o=z("style"),i=()=>{pr(e,t,o,r,r.appSpace[e.name].attrs),hr(n)};return r.code?ee(i):Ee(t,e.name).then(s=>{r.code=s,i()}).catch(s=>{I(s,e.name),dr(n)}),o}var Le;(function(t){t.NAME="name",t.URL="url"})(Le||(Le={}));var j;(function(t){t.CREATED="created",t.LOADING="loading",t.LOAD_FAILED="load_failed",t.BEFORE_MOUNT="before_mount",t.MOUNTING="mounting",t.MOUNTED="mounted",t.UNMOUNT="unmount"})(j||(j={}));var x;(function(t){t.CREATED="created",t.BEFOREMOUNT="beforemount",t.MOUNTED="mounted",t.UNMOUNT="unmount",t.ERROR="error",t.BEFORESHOW="beforeshow",t.AFTERSHOW="aftershow",t.AFTERHIDDEN="afterhidden"})(x||(x={}));var Ae;(function(t){t.ONMOUNT="onmount",t.ONUNMOUNT="onunmount"})(Ae||(Ae={}));var xe;(function(t){t.KEEP_ALIVE_SHOW="keep_alive_show",t.KEEP_ALIVE_HIDDEN="keep_alive_hidden"})(xe||(xe={}));var Qt;(function(t){t.DESTROY="destroy",t.DESTORY="destory",t.INLINE="inline",t.DISABLESCOPECSS="disableScopecss",t.DISABLESANDBOX="disableSandbox",t.DISABLE_SCOPECSS="disable-scopecss",t.DISABLE_SANDBOX="disable-sandbox",t.DISABLE_MEMORY_ROUTER="disable-memory-router",t.DISABLE_PATCH_REQUEST="disable-patch-request",t.KEEP_ROUTER_STATE="keep-router-state",t.KEEP_ALIVE="keep-alive",t.CLEAR_DATA="clear-data",t.SSR="ssr",t.FIBER="fiber"})(Qt||(Qt={}));const Vt="window,self,globalThis,document,Document,Array,Object,String,Boolean,Math,Number,Symbol,Date,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,navigator,undefined,location,history",Xt=[1,2,3],mr="state",Fe="search",Ze="native",_r="native-scope",gr="pure",to=[Fe,mr,Ze,_r,gr],vr=["popstate","hashchange","load","unload","unmount","appstate-change","statechange","mounted"],ro=vr,no=vr.concat(["unhandledrejection","message"]),Er=["onpopstate","onhashchange","onload","onunload","onerror"],oo=Er,io=Er.concat(["onunhandledrejection"]),so=["DOMContentLoaded","readystatechange"],ao=["onreadystatechange"],wr=["window","self","globalThis"],co=["rawWindow","rawDocument"],lo=["host","hostname","port","protocol","origin"],uo=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function de(t,e){return e.appSpace[t.name].module&&(!t.useSandbox||t.iframe)}function ho(t,e){return e.appSpace[t.name].attrs.has("id")}function lt(t,e){return t.inline||e.appSpace[t.name].inline||de(t,e)||ho(t,e)}function Ar(t){return t.iframe?t.sandBox.microAppWindow:l.rawWindow}function fo(t,e){const r=Ar(t);return new r.Function(e)}function po(t,e,r){const n=e.appSpace;for(const o in n)if(o!==t.name){const i=n[o];if(i.parsedCode===r&&i.parsedFunction)return i.parsedFunction}}function br(t,e,r){return po(t,e,r)||fo(t,r)}function Pr(){const t=Fn();return Y.script.hasInfo(t)?Pr():t}function mo(t,e){e.forEach((r,n)=>{n==="type"&&r==="module"||n==="defer"||n==="async"||(n==="src"&&(n="data-origin-src"),l.rawSetAttribute.call(t,n,r))})}function Rr(t,e){return t.useSandbox&&!de(t,e)}function Sr(t,e){return Rr(t,e)?t.iframe?"iframe":"with":"disable"}function yr(t,e,r,n=!1){var o;let i=null,s=t.getAttribute("src");if(s&&(s=X(s,r.url)),t.hasAttribute("exclude")||It(s,r.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(t.type&&!uo.includes(t.type)||t.hasAttribute("ignore")||Lt(s,r.name))return!((o=l.rawDocument)===null||o===void 0)&&o.currentScript&&delete l.rawDocument.currentScript,null;if(l.supportModuleScript&&t.noModule||!l.supportModuleScript&&t.type==="module")i=document.createComment(`${t.noModule?"noModule":"module"} script ignored by micro-app`);else if(s){let a=Y.script.getInfo(s);const c={async:t.hasAttribute("async"),defer:t.defer||t.type==="module",module:t.type==="module",inline:t.hasAttribute("inline"),pure:t.hasAttribute("pure"),attrs:Et(t)};if(a?a.appSpace[r.name]=a.appSpace[r.name]||c:a={code:"",isExternal:!0,appSpace:{[r.name]:c}},Y.script.setInfo(s,a),!n)r.source.scripts.add(s),i=document.createComment(`script with src='${s}' extract by micro-app`);else return{address:s,scriptInfo:a}}else if(t.textContent){const a=Pr(),c={code:t.textContent,isExternal:!1,appSpace:{[r.name]:{async:!1,defer:t.type==="module",module:t.type==="module",inline:t.hasAttribute("inline"),pure:t.hasAttribute("pure"),attrs:Et(t)}}};if(!n)r.source.scripts.add(a),Y.script.setInfo(a,c),i=document.createComment("inline script extract by micro-app");else return{address:a,scriptInfo:c}}else n||(i=document.createComment("script element removed by micro-app"))}return n?{replaceComment:i}:e==null?void 0:e.replaceChild(i,t)}function Mr(t){var e,r,n;const o=((e=w.options.plugins)===null||e===void 0?void 0:e.global)||[],i=((n=(r=w.options.plugins)===null||r===void 0?void 0:r.modules)===null||n===void 0?void 0:n[t])||[];return[...o,...i]}function It(t,e){return t?(Mr(e)||[]).some(n=>n.excludeChecker?n.excludeChecker(t):!1):!1}function Lt(t,e){return t?(Mr(e)||[]).some(n=>n.ignoreChecker?n.ignoreChecker(t):!1):!1}function _o(t,e){const r=Array.from(e.source.scripts),n=[],o=[];for(const s of r){const a=Y.script.getInfo(s),c=a.appSpace[e.name];(!c.defer&&!c.async||e.isPrefetch&&!e.isPrerender)&&(n.push(a.code?a.code:Ee(s,e.name)),o.push([s,a]))}const i=e.isPrefetch||e.fiber?[]:null;n.length?st(n,s=>{Be(i,()=>go(o[s.index][0],o[s.index][1],s.data,e))},s=>{I(s,e.name)},()=>{i?(i.push(()=>Promise.resolve(e.onLoad({html:t}))),Ue(i)):e.onLoad({html:t})}):e.onLoad({html:t})}function go(t,e,r,n){if(e.code=r,n.isPrefetch&&n.prefetchLevel===2){const o=e.appSpace[n.name];if(!o.parsedCode&&(o.parsedCode=Or(t,n,r,e),o.sandboxType=Sr(n,e),!lt(n,e)))try{o.parsedFunction=br(n,e,o.parsedCode)}catch(i){I("Something went wrong while handling preloaded resources",n.name,`
`,i)}}}function vo(t,e){const r=t.fiber?[]:null,n=Array.from(t.source.scripts),o=[],i=[];for(const s of n){const a=Y.script.getInfo(s),c=a.appSpace[t.name];c.defer||c.async?(a.isExternal&&!a.code&&!de(t,a)?o.push(Ee(s,t.name)):o.push(a.code),i.push([s,a]),de(t,a)&&(e.moduleCount=e.moduleCount?++e.moduleCount:1)):Be(r,()=>{ke(s,t,a),e(!1)})}o.length?st(o,s=>{const a=i[s.index][1];a.code=a.code||s.data},s=>{e.errorCount=e.errorCount?++e.errorCount:1,I(s,t.name)},()=>{i.forEach(([s,a])=>{T(a.code)&&Be(r,()=>{ke(s,t,a,e),!de(t,a)&&e(!1)})}),r?(r.push(()=>Promise.resolve(e(pe(e.moduleCount)||e.errorCount===o.length))),Ue(r)):e(pe(e.moduleCount)||e.errorCount===o.length)}):r?(r.push(()=>Promise.resolve(e(!0))),Ue(r)):e(!0)}function ke(t,e,r,n,o){var i;try{Po(e);const s=r.appSpace[e.name],a=Sr(e,r);if((!s.parsedCode||s.sandboxType!==a)&&(s.parsedCode=Or(t,e,r.code,r),s.sandboxType=a,s.parsedFunction=null),lt(e,r)){const c=o||z("script");if(Ao(t,s.parsedCode,de(e,r),c,s.attrs,n),!o){const h=e.iframe?(i=e.sandBox)===null||i===void 0?void 0:i.microBody:e.querySelector("micro-app-body");h==null||h.appendChild(c)}}else bo(e,r)}catch(s){throw console.error(`[micro-app from ${o?"runDynamicScript":"runScript"}] app ${e.name}: `,s,t),s}}function Eo(t,e,r,n){const o=lt(e,r)?z("script"):document.createComment(`dynamic script with src='${t}' extract by micro-app`),i=()=>hr(n),s=()=>{const a=Object.getOwnPropertyDescriptor(l.rawDocument,"currentScript");(!a||a.configurable)&&Object.defineProperty(l.rawDocument,"currentScript",{value:n,configurable:!0}),ke(t,e,r,i,o),!de(e,r)&&i()};return r.code||de(e,r)?ee(s):Ee(t,e.name).then(a=>{r.code=a,s()}).catch(a=>{I(a,e.name),dr(n)}),o}function wo(t,e,r){const n=lt(e,r)?z("script"):document.createComment("dynamic inline script extract by micro-app");return ke(t,e,r,void 0,n),n}function Ao(t,e,r,n,o,i){if(r){if(l.rawSetAttribute.call(n,"type","module"),We(t)?n.textContent=e:n.src=t,i){const s=()=>{i.moduleCount&&i.moduleCount--,i(i.moduleCount===0)};We(t)?ee(s):n.onload=s}}else n.textContent=e;mo(n,o)}function bo(t,e){const r=e.appSpace[t.name];r.parsedFunction||(r.parsedFunction=br(t,e,r.parsedCode)),r.parsedFunction.call(Ar(t))}function Or(t,e,r,n){return B(w.options.plugins)&&(r=So(t,r,e.name,w.options.plugins)),Rr(e,n)?e.iframe?`(function(window,self,global,location){;${r}
${We(t)?"":`//# sourceURL=${t}
`}}).call(window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyWindow,window.__MICRO_APP_SANDBOX__.proxyLocation);`:`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${Vt}){;${r}
${We(t)?"":`//# sourceURL=${t}
`}}).call(proxyWindow,${Vt})}})(window.__MICRO_APP_PROXY_WINDOW__);`:r}function Po(t){Ro(t)}function Ro(t){t.sandBox&&(l.rawWindow.__MICRO_APP_PROXY_WINDOW__=t.sandBox.proxyWindow)}function So(t,e,r,n){var o;const i=zt(n.global,e,t);return zt((o=n.modules)===null||o===void 0?void 0:o[r],i,t)}function zt(t,e,r){return se(t)?t.reduce((n,o)=>B(o)&&P(o.loader)?o.loader(n,r):n,e):e}function Dr(t,e,r,n){const o=Array.from(t.children);o.length&&o.forEach(i=>{Dr(i,e,r,n)});for(const i of o)sr(i)?i.hasAttribute("exclude")||It(i.getAttribute("href"),e.name)?t.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),i):i.hasAttribute("ignore")||Lt(i.getAttribute("href"),e.name)?i.hasAttribute("href")&&l.rawSetAttribute.call(i,"href",X(i.getAttribute("href"),e.url)):fr(i,t,e):Pt(i)?i.hasAttribute("exclude")?t.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),i):e.scopecss&&!i.hasAttribute("ignore")&&Be(n,()=>ct(i,e)):ve(i)?yr(i,t,e):ar(i)&&i.hasAttribute("src")&&l.rawSetAttribute.call(i,"src",X(i.getAttribute("src"),e.url))}function yo(t,e){const r=e.parseHtmlString(t),n=l.rawElementQuerySelector.call(r,"micro-app-head"),o=l.rawElementQuerySelector.call(r,"micro-app-body");if(!n||!o){const a=`element ${n?"body":"head"} is missing`;return e.onerror(new Error(a)),I(a,e.name)}const i=e.isPrefetch||e.fiber?[]:null;Dr(r,e,n,i);const s=Ue(i);e.source.links.size?Zn(r,e,n,s):s?s.then(()=>e.onLoad({html:r})):e.onLoad({html:r}),e.source.scripts.size?_o(r,e):e.onLoad({html:r})}class Mo{constructor(){this.eventList=new Map,this.queue=[],this.recordStep={},this.process=()=>{var e,r;let n;const o=this.recordStep,i=this.queue;for(this.recordStep={},this.queue=[];n=i.shift();){const s=this.eventList.get(n),a=s.tempData,c=s.force;s.tempData=null,s.force=!1;let h;if(c||!this.isEqual(s.data,a)){s.data=a||s.data;for(const p of s.callbacks){const S=p(s.data);S&&(h??(h=[])).push(S)}(r=(e=o[n]).dispatchDataEvent)===null||r===void 0||r.call(e),o[n].nextStepList.forEach(p=>p(h))}}}}isLegalName(e){return e?!0:(I("event-center: Invalid name"),!1)}enqueue(e,r,n){this.recordStep[e]?(this.recordStep[e].nextStepList.push(r),n&&(this.recordStep[e].dispatchDataEvent=n)):this.recordStep[e]={nextStepList:[r],dispatchDataEvent:n},!this.queue.includes(e)&&this.queue.push(e)===1&&ee(this.process)}isEqual(e,r){if(!r||Object.keys(e).length!==Object.keys(r).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==r[n])return!1;return!0}on(e,r,n=!1){if(this.isLegalName(e)){if(!P(r))return I("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&r(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(r)}}off(e,r){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(P(r)?n.callbacks.delete(r):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const r=this.eventList.get(e);r&&(r.data={})}}dispatch(e,r,n,o,i){if(this.isLegalName(e)){if(!B(r))return I("event-center: data must be object");let s=this.eventList.get(e);s?(s.tempData=Z({},s.tempData||s.data,r),!s.force&&(s.force=!!o)):(s={data:r,callbacks:new Set},this.eventList.set(e,s),s.force=!0),this.enqueue(e,n,i)}}getData(e){var r;const n=this.eventList.get(e);return(r=n==null?void 0:n.data)!==null&&r!==void 0?r:null}}const W=new Mo;function Q(t,e){return!T(t)||!t?"":e?`__${t}_from_base_app__`:`__${t}_from_micro_app__`}class Cr{addGlobalDataListener(e,r){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=r),W.on("global",e,r)}removeGlobalDataListener(e){P(e)&&W.off("global",e)}setGlobalData(e,r,n){$(),W.dispatch("global",e,o=>P(r)&&r(o),n)}forceSetGlobalData(e,r){this.setGlobalData(e,r,!0)}getGlobalData(){return W.getData("global")}clearGlobalData(){W.clearData("global")}clearGlobalDataListener(){const e=this.appName,r=W.eventList.get("global");if(r)for(const n of r.callbacks)(e&&e===n.__APP_NAME__||!(e||n.__APP_NAME__))&&r.callbacks.delete(n)}}class Oo extends Cr{addDataListener(e,r,n){W.on(Q(G(e),!1),r,n)}removeDataListener(e,r){P(r)&&W.off(Q(G(e),!1),r)}getData(e,r=!1){return W.getData(Q(G(e),r))}setData(e,r,n,o){W.dispatch(Q(G(e),!0),r,i=>P(n)&&n(i),o)}forceSetData(e,r,n){this.setData(e,r,n,!0)}clearData(e,r=!0){W.clearData(Q(G(e),r))}clearDataListener(e){W.off(Q(G(e),!1))}}class Ir extends Cr{constructor(e){super(),this.appName=G(e),!this.appName&&I(`Invalid appName ${e}`)}addDataListener(e,r){e.__AUTO_TRIGGER__=r,W.on(Q(this.appName,!0),e,r)}removeDataListener(e){P(e)&&W.off(Q(this.appName,!0),e)}getData(e=!0){return W.getData(Q(this.appName,e))}dispatch(e,r,n){$(),W.dispatch(Q(this.appName,!1),e,o=>P(r)&&r(o),n,()=>{const o=y.get(this.appName);if(o!=null&&o.container&&B(e)){const i=new CustomEvent("datachange",{detail:{data:W.getData(Q(this.appName,!1))}});le(o.container).dispatchEvent(i)}})}forceDispatch(e,r){this.dispatch(e,r,!0)}clearData(e=!1){W.clearData(Q(this.appName,e))}clearDataListener(){W.off(Q(this.appName,!0))}}function Lr(t){var e,r;if(t){t.umdDataListeners={global:new Set((e=t.umdDataListeners)===null||e===void 0?void 0:e.global),normal:new Set((r=t.umdDataListeners)===null||r===void 0?void 0:r.normal)};const n=W.eventList.get("global");if(n)for(const i of n.callbacks)t.appName===i.__APP_NAME__&&t.umdDataListeners.global.add(i);const o=W.eventList.get(Q(t.appName,!0));if(o)for(const i of o.callbacks)t.umdDataListeners.normal.add(i)}}function xr(t){if(t!=null&&t.umdDataListeners){for(const e of t.umdDataListeners.global)t.addGlobalDataListener(e,e.__AUTO_TRIGGER__);for(const e of t.umdDataListeners.normal)t.addDataListener(e,e.__AUTO_TRIGGER__);xt(t)}}function xt(t){t==null||delete t.umdDataListeners}class He{constructor(){this.appInstanceMap=y}static getInstance(){return this.instance||(this.instance=new He),this.instance}get(e){return this.appInstanceMap.get(e)}set(e,r){this.appInstanceMap.set(e,r)}getAll(){return Array.from(this.appInstanceMap.values())}clear(){this.appInstanceMap.clear()}}function Tr(){Nr(),He.getInstance().getAll().forEach(t=>{t.container&&le(t.container).disconnectedCallback()}),!window.__MICRO_APP_UMD_MODE__&&He.getInstance().clear()}function Nr(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",Tr,!1)}function Do(){window.__MICRO_APP_ENVIRONMENT__&&(Nr(),window.addEventListener("unmount",Tr,!1))}function Co(t){return ir(t.__MICRO_APP_IS_BOUND_FUNCTION__)?t.__MICRO_APP_IS_BOUND_FUNCTION__:t.__MICRO_APP_IS_BOUND_FUNCTION__=Sn(t)}function Io(t){return ir(t.__MICRO_APP_IS_CONSTRUCTOR__)?t.__MICRO_APP_IS_CONSTRUCTOR__:t.__MICRO_APP_IS_CONSTRUCTOR__=nt(t)}function J(t,e,r="WINDOW"){if(P(t)&&!Io(t)&&!Co(t)&&t.bind){const n=`__MICRO_APP_BOUND_${r}_FUNCTION__`;if(t[n])return t[n];const o=t.bind(e);for(const i in t)o=t;return t.hasOwnProperty("prototype")&&H(o,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t[n]=o}return t}class Lo{constructor(e,r){this.rawWindowScopeKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue","onpopstate","onhashchange"],this.scopeProperties=Array.from(this.staticScopeProperties),this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.appName=e,this.url=r,this.injectReactHMRProperty()}injectReactHMRProperty(){}}class xo{}function To(){l.rawWindow._babelPolyfill&&(l.rawWindow._babelPolyfill=!1)}function Tt(t,e){const r=Array.from(t.childNodes);r.length&&r.forEach(n=>{Tt(n,e)}),F(t,e)}function F(t,e){var r,n;if(e&&ye(t)&&t.__MICRO_APP_NAME__!==e&&!t.__PURE_ELEMENT__&&!Ot()){const o={__MICRO_APP_NAME__:{configurable:!0,enumerable:!0,writable:!0,value:e}};if(Mn(t)&&He.getInstance().get(e)&&(o.href={get(){return this.getAttribute("href")},set(s){s!==void 0&&this.setAttribute("href",s)}}),k(t,o),we(e)){const i=(n=(r=y.get(e))===null||r===void 0?void 0:r.sandBox)===null||n===void 0?void 0:n.proxyWindow;i&&k(t,{baseURI:{configurable:!0,enumerable:!0,get:()=>i.location.href},ownerDocument:{configurable:!0,enumerable:!0,get:()=>t!==i.document?i.document:null},parentNode:Br(e,l.rawParentNodeDesc),getRootNode:{configurable:!0,enumerable:!0,writable:!0,value:function(){return i.document}}})}}return t}function Br(t,e){return{configurable:!0,enumerable:!0,get(){var r,n,o,i;Mt(t);const s=(r=e.get)===null||r===void 0?void 0:r.call(this);return Ye(s)&&(!((n=y.get(t))===null||n===void 0)&&n.container)?((i=(o=w.options).getRootElementParentNode)===null||i===void 0?void 0:i.call(o,this,t))||l.rawDocument.body:s}}}function No(t,e,r){const{proxyDocument:n,documentEffect:o}=Bo(t,r),i=Uo(t,n);return k(e,{document:{configurable:!1,enumerable:!0,get(){return n}},Document:{configurable:!1,enumerable:!1,get(){return i}}}),o}function Bo(t,e){const r=new Map,n=new Map;let o=null,i=null;const{rawDocument:s,rawCreateElement:a,rawCreateElementNS:c,rawAddEventListener:h,rawRemoveEventListener:p}=l;function S(d,_){const b=a.call(s,d,_);return F(b,t)}function A(d,_,b){const N=c.call(s,d,_,b);return F(N,t)}function O(d,_,b){const N=r.get(d);N?N.add(_):r.set(d,new Set([_])),_&&(_.__MICRO_APP_MARK_OPTIONS__=b),h.call(s,d,_,b)}function D(d,_,b){const N=r.get(d);N!=null&&N.size&&N.has(_)&&N.delete(_),p.call(s,d,_,b)}const v=()=>{n.clear(),i=null},M=()=>{i=o||i,r.forEach((d,_)=>{if(d.size){const b=n.get(_)||[];n.set(_,new Set([...b,...d]))}})},E=()=>{i&&!o&&(g.onclick=i),n.forEach((d,_)=>{for(const b of d)g.addEventListener(_,b,b==null?void 0:b.__MICRO_APP_MARK_OPTIONS__)}),v()},m=()=>{P(o)&&p.call(s,"click",o),o=null,r.size&&(r.forEach((d,_)=>{for(const b of d)p.call(s,_,b)}),r.clear())},f=(()=>{var d;const _=new Map([["onclick",L=>{P(o)&&p.call(s,"click",o,!1),P(L)&&h.call(s,"click",L,!1),o=L}]]),b=((d=w.options)===null||d===void 0?void 0:d.customProxyDocumentProps)||new Map;return new Map([..._,...b])})(),g=new Proxy(s,{get:(d,_)=>{var b;return Ne(t),_==="createElement"?S:_==="createElementNS"?A:_===Symbol.toStringTag?"ProxyDocument":_==="defaultView"?e.proxyWindow:_==="onclick"?o:_==="addEventListener"?O:_==="removeEventListener"?D:_==="microAppElement"?(b=y.get(t))===null||b===void 0?void 0:b.container:_==="__MICRO_APP_NAME__"?t:J(Reflect.get(d,_),s,"DOCUMENT")},set:(d,_,b)=>(f.has(_)?f.get(_)(b):_!=="microAppElement"&&Reflect.set(d,_,b),!0)});return{proxyDocument:g,documentEffect:{reset:v,record:M,rebuild:E,release:m}}}function Uo(t,e){const{rawDocument:r,rawRootDocument:n}=l;class o{static[Symbol.hasInstance](s){let a=s;for(;a;)if(a=Object.getPrototypeOf(a),a===o.prototype)return!0;return s===e||s instanceof n}}return Object.setPrototypeOf(o,n),Object.setPrototypeOf(o.prototype,new Proxy(n.prototype,{get(i,s){return Ne(t),J(Reflect.get(i,s),r,"DOCUMENT")},set(i,s,a){return Reflect.set(i,s,a),!0}})),o}function Wo(t,e,r){return Fo(e),Ho(t,e,r),jo(e,t)}function Fo(t){const e=l.rawWindow;Object.getOwnPropertyNames(e).filter(r=>/^on/.test(r)&&!oo.includes(r)).forEach(r=>{const{enumerable:n,writable:o,set:i}=Object.getOwnPropertyDescriptor(e,r)||{enumerable:!0,writable:!0};H(t,r,{enumerable:n,configurable:!0,get:()=>e[r],set:o??!!i?s=>{e[r]=s}:void 0})})}function Ho(t,e,r){const n=l.rawWindow,o=new Map,i=new Proxy(e,{get:(s,a)=>(Ne(t),Reflect.has(s,a)||T(a)&&/^__MICRO_APP_/.test(a)||te(r.scopeProperties,a)?(te(co,a)&&$(),Reflect.get(s,a)):J(Reflect.get(n,a),n)),set:(s,a,c)=>{if(te(r.rawWindowScopeKeyList,a))Reflect.set(n,a,c);else if(!ge.call(s,a)&&ge.call(n,a)&&!te(r.scopeProperties,a)){const h=Object.getOwnPropertyDescriptor(n,a),{configurable:p,enumerable:S,writable:A,set:O}=h;H(s,a,{value:c,configurable:p,enumerable:S,writable:A??!!O}),r.injectedKeys.add(a)}else(!Reflect.has(s,a)||te(r.scopeProperties,a))&&r.injectedKeys.add(a),Reflect.set(s,a,c);return(te(r.escapeProperties,a)||te(r.staticEscapeProperties,a)&&!Reflect.has(n,a))&&!te(r.scopeProperties,a)&&(!Reflect.has(n,a)&&r.escapeKeys.add(a),Reflect.set(n,a,c)),!0},has:(s,a)=>te(r.scopeProperties,a)?r.injectedKeys.has(a)?Reflect.has(s,a):!!s[a]:Reflect.has(s,a)||Reflect.has(n,a),getOwnPropertyDescriptor:(s,a)=>{if(ge.call(s,a))return o.set(a,"target"),Object.getOwnPropertyDescriptor(s,a);if(ge.call(n,a)){o.set(a,"rawWindow");const c=Object.getOwnPropertyDescriptor(n,a);return c&&!c.configurable&&(c.configurable=!0),c}},defineProperty:(s,a,c)=>o.get(a)==="rawWindow"?Reflect.defineProperty(n,a,c):Reflect.defineProperty(s,a,c),ownKeys:s=>Hn(Reflect.ownKeys(n).concat(Reflect.ownKeys(s))),deleteProperty:(s,a)=>ge.call(s,a)?(r.injectedKeys.has(a)&&r.injectedKeys.delete(a),r.escapeKeys.has(a)&&Reflect.deleteProperty(n,a),Reflect.deleteProperty(s,a)):!0});r.proxyWindow=i}function jo(t,e){const r=new Map,n=new Map,o=new Map,i=new Map,{rawWindow:s,rawAddEventListener:a,rawRemoveEventListener:c,rawDispatchEvent:h,rawSetInterval:p,rawSetTimeout:S,rawClearInterval:A,rawClearTimeout:O}=l;function D(u){var f;return ro.includes(u)&&(!((f=y.get(e))===null||f===void 0)&&f.container)?le(y.get(e).container):s}t.addEventListener=function(u,f,g){u=wt(u,e);const d=r.get(u);d?d.add(f):r.set(u,new Set([f])),f&&(f.__MICRO_APP_MARK_OPTIONS__=g),a.call(D(u),u,f,g)},t.removeEventListener=function(u,f,g){u=wt(u,e);const d=r.get(u);d!=null&&d.size&&d.has(f)&&d.delete(f),c.call(D(u),u,f,g)},t.dispatchEvent=function(u){return h.call(D(u==null?void 0:u.type),u)},t.setInterval=function(u,f,...g){const d=p.call(s,u,f,...g);return o.set(d,{handler:u,timeout:f,args:g}),d},t.setTimeout=function(u,f,...g){const d=S.call(s,u,f,...g);return i.set(d,{handler:u,timeout:f,args:g}),d},t.clearInterval=function(u){o.delete(u),A.call(s,u)},t.clearTimeout=function(u){i.delete(u),O.call(s,u)};const v=()=>{n.clear()};return{reset:v,record:()=>{r.forEach((u,f)=>{if(u.size){const g=n.get(f)||[];n.set(f,new Set([...g,...u]))}})},rebuild:()=>{n.forEach((u,f)=>{for(const g of u)t.addEventListener(f,g,g==null?void 0:g.__MICRO_APP_MARK_OPTIONS__)}),v()},release:u=>{r.size&&(r.forEach((f,g)=>{for(const d of f)c.call(D(g),g,d)}),r.clear()),u&&(o.forEach((f,g)=>{A.call(s,g)}),i.forEach((f,g)=>{O.call(s,g)}),o.clear(),i.clear())}}}function ie(t,e,r){const n=l.rawWindow.history.state,o={__MICRO_APP_STATE__:Z({},n==null?void 0:n.__MICRO_APP_STATE__,{[t]:{fullPath:r?r.pathname+r.search+r.hash:null,state:e??null,mode:Me(t)}})};return Z({},n,o)}function $o(t,e){return B(e==null?void 0:e.__MICRO_APP_STATE__)&&(pe(e.__MICRO_APP_STATE__[t])||delete e.__MICRO_APP_STATE__[t],Object.keys(e.__MICRO_APP_STATE__).length||delete e.__MICRO_APP_STATE__),Kn(e)?null:Z({},e)}function Ke(t){var e,r;const n=l.rawWindow.history.state;return((r=(e=n==null?void 0:n.__MICRO_APP_STATE__)===null||e===void 0?void 0:e[t])===null||r===void 0?void 0:r.state)||null}function Ur(t){var e;const r=l.rawWindow.history.state;return((e=r==null?void 0:r.__MICRO_APP_STATE__)===null||e===void 0?void 0:e[t])||null}const Go=/&/g,Ko=/=/g,Wr=/%M1/g,Fr=/%M2/g;function Hr(t){return encodeURIComponent(Nt(t).replace(Go,"%M1").replace(Ko,"%M2"))}function jr(t){return Nt(t).replace(Wr,"&").replace(Fr,"=")}function Nt(t){try{const e=decodeURIComponent(t);return t===e||Wr.test(e)||Fr.test(e)?e:Nt(e)}catch{return t}}function qe(t){var e,r,n,o;const i=l.rawWindow.location,s=l.rawWindow.history.state;if(V(t)){const a=Bt(i.search,i.hash),c=((e=a.hashQuery)===null||e===void 0?void 0:e[t])||((r=a.searchQuery)===null||r===void 0?void 0:r[t]);return T(c)?jr(c):null}return((o=(n=s==null?void 0:s.__MICRO_APP_STATE__)===null||n===void 0?void 0:n[t])===null||o===void 0?void 0:o.fullPath)||(ne(t)?i.pathname+i.search+i.hash:null)}function fe(t,e){const r=l.rawWindow.location;let n=e.pathname+e.search+e.hash,o=!1;if(V(t)){let{pathname:i,search:s,hash:a}=r;const c=Bt(s,a),h=Hr(n);return a&&!s?(o=!0,c.hashQuery?c.hashQuery[t]=h:c.hashQuery={[t]:h},a=(a.includes("?")?a.slice(0,a.indexOf("?")+1):a+"?")+Je(c.hashQuery)):(c.searchQuery?c.searchQuery[t]=h:c.searchQuery={[t]:h},s="?"+Je(c.searchQuery)),{fullPath:i+s+a,isAttach2Hash:o}}return(Ut(t)||re(t))&&(n=r.pathname+r.search+r.hash),{fullPath:n,isAttach2Hash:o}}function qo(t){var e,r,n,o;let{pathname:i,search:s,hash:a}=l.rawWindow.location,c=!1;if(V(t)){const h=Bt(s,a);if(!((e=h.hashQuery)===null||e===void 0)&&e[t]){c=!0,(r=h.hashQuery)===null||r===void 0||delete r[t];const p=Je(h.hashQuery);a=a.slice(0,a.indexOf("?")+ +!!p)+p}else if(!((n=h.searchQuery)===null||n===void 0)&&n[t]){(o=h.searchQuery)===null||o===void 0||delete o[t];const p=Je(h.searchQuery);s=p?"?"+p:""}}return{fullPath:i+s+a,isAttach2Hash:c}}function Bt(t,e){const r={};return t!==""&&t!=="?"&&(r.searchQuery=Ht(t.slice(1))),e.includes("?")&&(r.hashQuery=Ht(e.slice(e.indexOf("?")+1))),r}function Qo(t,e){const r=qe(t);if(!r)return"";const n=U(r,e);return n.origin+n.pathname+n.search}function je(t){const e=y.get(t);return!!(e&&!e.isPrefetch)}function Me(t){var e;return(e=y.get(t))===null||e===void 0?void 0:e.routerMode}function V(t){return Me(t)===Fe}function Ut(t){return Me(t)===mr}function At(t){return Me(t)===Ze}function Vo(t){return Me(t)===_r}function re(t){return Me(t)===gr}function ne(t){return At(t)||Vo(t)}function $r(t,e){const r=e&&Ze||t||w.options["disable-memory-router"]&&Ze||w.options["router-mode"]||Fe;return to.includes(r)?r:Fe}function Gr(t){const e=l.rawWindow,r=n=>{var o,i,s;if(Se({excludeHiddenApp:!0,excludePreRender:!0}).includes(t)&&!n.onlyForBrowser&&(!ne(t)||!l.rawWindow.history.state||Ur(t))){const a=(o=y.get(t))===null||o===void 0?void 0:o.container;Bn(()=>et(t,qe(t)),(s=(i=a&&le(a))===null||i===void 0?void 0:i.getRouterEventDelay())!==null&&s!==void 0?s:0)}};return e.addEventListener("popstate",r),()=>{e.removeEventListener("popstate",r)}}function et(t,e){const r=y.get(t);if(r!=null&&r.sandBox){const n=r.sandBox.proxyWindow,o=r.sandBox.microAppWindow;let i=!1;const s=n.location.href;if(e){const a=n.location.hash;Oe(t,e,o.location),i=n.location.hash!==a}Xo(t,n,o),i&&zo(t,n,o,s),$()}}function Xo(t,e,r){const n=new PopStateEvent("popstate",{state:Ke(t)});r.dispatchEvent(n),we(t)||P(e.onpopstate)&&e.onpopstate(n)}function zo(t,e,r,n){const o=new HashChangeEvent("hashchange",{newURL:e.location.href,oldURL:n});r.dispatchEvent(o),we(t)||P(e.onhashchange)&&e.onhashchange(o)}function Yo(t){const e=new PopStateEvent("popstate",{state:null});t&&(e.onlyForBrowser=!0),l.rawWindow.dispatchEvent(e)}function Jo(t){const e=new HashChangeEvent("hashchange",{newURL:l.rawWindow.location.href,oldURL:t});l.rawWindow.dispatchEvent(e)}function bt(t,e,r){$(),je(t)&&(Yo(e),r&&Jo(r))}function Kr(t,e){const r=l.rawWindow.history;function n(i){return function(...s){var a,c,h;s[2]=pe(s[2])||Te(s[2])||""+s[2]==""?e.href:""+s[2];const p=U(s[2],e.href),S=p.pathname+p.search+p.hash;re(t)||ut(t,i,fe(t,p),!0,ie(t,s[0],p),s[1]),S!==e.fullPath&&Oe(t,S,e),(h=(a=y.get(t))===null||a===void 0?void 0:(c=a.sandBox).updateIframeBase)===null||h===void 0||h.call(c)}}const o={pushState:n("pushState"),replaceState:n("replaceState")};return we(t)?Z({go(i){return r.go(i)}},o):new Proxy(r,{get(i,s){return s==="pushState"||s==="replaceState"?o:s==="state"?Ke(t):J(Reflect.get(i,s),i,"HISTORY")},set(i,s,a){return s==="pushState"||s==="replaceState"?o=a:Reflect.set(i,s,a),!0}})}function Re(t,e,r,n=null,o=""){je(t)&&(e==="pushState"?l.rawPushState:l.rawReplaceState).call(l.rawWindow.history,n,o,r)}function ut(t,e,r,n,o,i){if(je(t)){const s=l.rawWindow.location,a=s.pathname+s.search+s.hash,c=r.isAttach2Hash&&a!==r.fullPath?s.href:null;Re(t,e,r.fullPath,o,i),a!==r.fullPath&&V(t)&&bt(t,n,c)}}function ht(t,e,r){ut(t,"replaceState",e,!0,r)}function Yt(t){const e=l.rawWindow;return function(...r){var n;if(!((n=e.history.state)===null||n===void 0)&&n.__MICRO_APP_STATE__&&(!B(r[0])||!r[0].__MICRO_APP_STATE__)&&(T(r[2])||ot(r[2]))){const o=e.location.href;U(r[2],o).href===o&&(r[0]=Z({},r[0],{__MICRO_APP_STATE__:e.history.state.__MICRO_APP_STATE__}))}t.apply(e.history,r),Se({excludeHiddenApp:!0,excludePreRender:!0}).forEach(o=>{if((V(o)||Ut(o))&&!qe(o)){const i=y.get(o);ht(o,fe(o,i.sandBox.proxyWindow.location),ie(o,Ke(o),i.sandBox.proxyWindow.location))}ne(o)&&!Ur(o)&&Re(o,"replaceState",e.location.href,ie(o))}),$()}}function qr(){const t=l.rawWindow;t.history.pushState=Yt(l.rawPushState),t.history.replaceState=Yt(l.rawReplaceState)}function Qr(){const t=l.rawWindow;t.history.pushState=l.rawPushState,t.history.replaceState=l.rawReplaceState}function Zo(){function t(v,M,E,m){ut(v,M,fe(v,E),!1,ie(v,m??null,E)),$()}function e(v,M,E,m){const u=M.sandBox.proxyWindow.location,f=U(E.path,u.href),g=u.pathname+u.search+u.hash,d=f.pathname+f.search+f.hash;if(g!==d||qe(v)!==d){if(!re(v)){const _=m&&E.replace!==!1||E.replace===!0?"replaceState":"pushState";t(v,_,f,E.state)}V(v)||et(v,d)}}function r(v){return function(M){return new Promise((E,m)=>{const u=G(M.name);if(u&&T(M.path))if(Se({excludeHiddenApp:!0,excludePreRender:!0}).includes(u)){const f=y.get(u);E(f.sandBox.sandboxReady.then(()=>e(u,f,M,v)))}else m(I("导航失败,请确保子应用渲染后再调用此方法"));else m(I(`navigation failed, name & path are required when use router.${v?"replace":"push"}`))})}}function n(v){return function(...M){return l.rawWindow.history[v](...M)}}const o=jt(),i=jt();function s(v,M,E,m){$();for(const u of m)P(u)?u(M,E,v):B(u)&&P(u[v])&&u[v](M,E)}function a(v,M,E){D.current.set(v,M),s(v,M,E,o.list()),at(()=>{s(v,M,E,i.list())})}function c(v){D.current.delete(v)}function h(v){if(V(v)||Ut(v)){const M=y.get(v);ht(v,fe(v,M.sandBox.proxyWindow.location),ie(v,Ke(v),M.sandBox.proxyWindow.location))}}function p(v){v=G(v),v&&Se().includes(v)&&h(v)}function S({includeHiddenApp:v=!1,includePreRender:M=!1}){Se({excludeHiddenApp:!v,excludePreRender:!M}).forEach(E=>h(E))}function A(){const v=jn();function M(m){const u=G(m.name);return!u||!m.path?bn:v.add(u,m.path)}function E(m){return m=G(m),m?v.delete(m):!1}return{setDefaultPage:M,removeDefaultPage:E,getDefaultPage:v.get}}function O(){let v=null;function M(E){Rn(E)&&(v=new Proxy(E,{get(m,u){return $(),J(Reflect.get(m,u),m,"BASEROUTER")},set(m,u,f){return Reflect.set(m,u,f),!0}}))}return{setBaseAppRouter:M,getBaseAppRouter:()=>v}}const D=Object.assign(Object.assign({current:new Map,encode:Hr,decode:jr,push:r(!1),replace:r(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:o.add,afterEach:i.add,attachToURL:p,attachAllToURL:S},A()),O());return{router:D,executeNavigationGuard:a,clearRouterWhenUnmount:c}}const{router:Qe,executeNavigationGuard:Vr,clearRouterWhenUnmount:ko}=Zo(),ei=["href","pathname","search","hash","host","hostname","port","protocol","search"],ti=[...ei,"origin","fullPath"];function Xr(t,e,r,n,o,i){const a=l.rawWindow.location,c=!!r,h=U(e);function p(){return c?r.location:h}function S(m,u){const f=U(m,E.href);if(f.origin===E.origin){const g=fe(t,f);if(!ne(t)){if(u=re(t)?"replaceState":u,f.pathname===E.pathname&&f.search===E.search){let d=null;(f.hash!==E.hash||re(t))&&(g.isAttach2Hash&&(d=a.href),(!re(t)||!f.hash)&&Re(t,u,g.fullPath,V(t)?null:ie(t,null,f))),f.hash?V(t)?bt(t,!1,d):et(t,f.pathname+f.search+f.hash):M();return}Re(t,u,g.fullPath,V(t)?null:ie(t,null,f)),M();return}return g.fullPath}return m}function A(m,u){const f=U(m,e);f===E&&E.hash?bt(t,!1):(Re(t,f===E||re(t)?"replaceState":"pushState",fe(t,f).fullPath,V(t)?null:ie(t,null,f)),M())}const O=m=>function(u){if(je(t)){const f=S(u,m==="assign"?"pushState":"replaceState");f&&a[m](U(f,a.origin).href)}},D=O("assign"),v=O("replace"),M=m=>a.reload(m);H(p(),"fullPath",{enumerable:!0,configurable:!0,get:()=>E.pathname+E.search+E.hash});const E=new Proxy({},{get:(m,u)=>{const f=p();if(u==="assign")return D;if(u==="replace")return v;if(u==="reload")return M;if(u==="self")return f;if(u==="fullPath")return f.fullPath;if(lo.includes(u)){if(At(t))return a;if(c)return n}if(u==="href"){if(At(t))return f.replace(f.origin,a.origin);if(c)return f.replace(o,i)}return J(Reflect.get(f,u),f,"LOCATION")},set:(m,u,f)=>{if(je(t)){const g=p();if(u==="href"){const d=S(f,"pushState");d&&(a.href=U(d,a.origin).href)}else if(u==="pathname")if(ne(t))a.pathname=f;else{const d=("/"+f).replace(/^\/+/,"/")+E.search+E.hash;A(d,"pathname")}else if(u==="search")if(ne(t))a.search=f;else{const d=E.pathname+("?"+f).replace(/^\?+/,"?")+E.hash;A(d,"search")}else if(u==="hash")if(ne(t))a.hash=f;else{const d=E.pathname+E.search+("#"+f).replace(/^#+/,"#"),_=U(d,e);_.hash!==E.hash&&(re(t)||ut(t,"pushState",fe(t,_),!1,ie(t,null,_)),V(t)||et(t,_.pathname+_.search+_.hash))}else Reflect.set(g,u,f)}return!0}});return E}function tt(t,e){const r=Z({name:t},e);for(const n of ti)r[n]=e[n];return r}function ri(t,e){Vr(t,tt(t,e),tt(t,e))}function Oe(t,e,r,n){var o;const i=tt(t,r),s=U(e,r.href);if(we(t)){const h=y.get(t).sandBox.microAppWindow;(o=h.rawReplaceState)===null||o===void 0||o.call(h.history,Ke(t),"",s.href)}else{let h=s.href;r.self.origin!==s.origin&&(h=h.replace(s.origin,r.self.origin)),r.self.href=h}const a=l.rawWindow.location;ne(t)&&e!==a.pathname+a.search+a.hash&&n!=="prevent"&&Re(t,"replaceState",e,l.rawWindow.history.state);const c=tt(t,r);(n==="auto"||i.fullPath!==c.fullPath&&n!=="prevent")&&Vr(t,c,i)}function ni(t,e){const r=Xr(t,e);return{microLocation:r,microHistory:Kr(t,r)}}function zr(t,e,r){const n=qe(t);n?(Oe(t,n,e,"auto"),re(t)&&dt(t)):Wt(t,e,r)}function Wt(t,e,r){r&&Oe(t,r,e,"prevent"),re(t)||ht(t,fe(t,e),ie(t,null,e)),ri(t,e)}function Yr(t,e,r,n){if(!n&&!ne(t)){const{pathname:o,search:i,hash:s}=U(e);Oe(t,o+i+s,r,"prevent")}re(t)||dt(t),ko(t)}function dt(t){ht(t,qo(t),$o(t,l.rawWindow.history.state))}function Jt(t,e){const r=pe(e)?l.rawWindow.fetch:e;return P(r)?function(o,i,...s){return(T(o)||ot(o))&&(o=U(o,t).toString()),$(),r.call(l.rawWindow,o,i,...s)}:r}function Zt(t,e){const r=pe(e)?l.rawWindow.XMLHttpRequest:e;return nt(r)?class extends r{open(o,i,...s){(T(i)&&!/^f(ile|tp):\/\//.test(i)||ot(i))&&(i=U(i,t).toString()),$(),super.open(o,i,...s)}}:r}function oi(){let t;function e(n,o,i){const s=pe(i)?l.rawWindow.EventSource:i;return nt(s)?class extends s{constructor(c,h,...p){if((T(c)||ot(c))&&(c=U(c,o).toString()),$(),super(c,h,...p),t){const S=t.get(n);S?S.add(this):t.set(n,new Set([this]))}else t=new Map([[n,new Set([this])]])}close(){var c;super.close(),(c=t.get(n))===null||c===void 0||c.delete(this)}}:s}function r(n){const o=t==null?void 0:t.get(n);o!=null&&o.size&&(o.forEach(i=>{i.close()}),o.clear())}return{createMicroEventSource:e,clearMicroEventSource:r}}const{createMicroEventSource:kt,clearMicroEventSource:ii}=oi();class $e extends Lo{constructor(e,r){super(e,r),this.active=!1,this.microAppWindow=new xo,this.patchWith(n=>{this.getSpecialProperties(e),this.patchRouter(e,r,this.microAppWindow),this.windowEffect=Wo(e,this.microAppWindow,this),this.documentEffect=No(e,this.microAppWindow,this),this.setMappingPropertiesWithRawDescriptor(this.microAppWindow),this.initStaticGlobalKeys(e,r,this.microAppWindow),n()})}start({umdMode:e,baseroute:r,defaultPage:n,disablePatchRequest:o}){this.active||(this.active=!0,this.initRouteState(n),this.removeHistoryListener=Gr(this.microAppWindow.__MICRO_APP_NAME__),ne(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=r),e||this.initGlobalKeysWhenStart(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow,o),++l.activeSandbox===1&&(rn(),qr()),++$e.activeCount===1&&Do(),To())}stop({umdMode:e,keepRouteState:r,destroy:n,clearData:o}){var i;this.active&&(this.recordAndReleaseEffect({umdMode:e,clearData:o,destroy:n},!e||n),this.clearRouteState(r),(i=this.removeHistoryListener)===null||i===void 0||i.call(this),(!e||n)&&(ii(this.microAppWindow.__MICRO_APP_NAME__),this.injectedKeys.forEach(s=>{Reflect.deleteProperty(this.microAppWindow,s)}),this.injectedKeys.clear(),this.escapeKeys.forEach(s=>{Reflect.deleteProperty(l.rawWindow,s)}),this.escapeKeys.clear(),this.clearHijackUmdHooks()),--l.activeSandbox===0&&(nn(),Qr()),--$e.activeCount,this.active=!1)}initStaticGlobalKeys(e,r,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=r,n.__MICRO_APP_PUBLIC_PATH__=it(r),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="with",n.rawWindow=l.rawWindow,n.rawDocument=l.rawDocument,n.microApp=Z(new Ir(e),{removeDomScope:$,pureCreateElement:z,location:n.location,router:Qe})}recordAndReleaseEffect(e,r=!1){r?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),xt(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),Lr(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),xr(this.microAppWindow.microApp)}releaseGlobalEffect({umdMode:e=!1,clearData:r=!1,isPrerender:n=!1,keepAlive:o=!1,destroy:i=!1}){var s,a,c;this.windowEffect.release(!e&&!o&&!n||i),this.documentEffect.release(),(s=this.microAppWindow.microApp)===null||s===void 0||s.clearDataListener(),(a=this.microAppWindow.microApp)===null||a===void 0||a.clearGlobalDataListener(),r&&(w.clearData(this.microAppWindow.__MICRO_APP_NAME__),(c=this.microAppWindow.microApp)===null||c===void 0||c.clearData())}getSpecialProperties(e){var r;B(w.options.plugins)&&(this.commonActionForSpecialProperties(w.options.plugins.global),this.commonActionForSpecialProperties((r=w.options.plugins.modules)===null||r===void 0?void 0:r[e]))}commonActionForSpecialProperties(e){if(se(e))for(const r of e)B(r)&&(se(r.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(r.scopeProperties)),se(r.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(r.escapeProperties)))}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchWith(e){this.sandboxReady=new Promise(r=>e(r))}setMappingPropertiesWithRawDescriptor(e){let r,n;const o=l.rawWindow;o===o.parent?r=n=this.proxyWindow:(r=o.top,n=o.parent),k(e,{top:this.createDescriptorForMicroAppWindow("top",r),parent:this.createDescriptorForMicroAppWindow("parent",n)}),wr.forEach(i=>{H(e,i,this.createDescriptorForMicroAppWindow(i,this.proxyWindow))})}createDescriptorForMicroAppWindow(e,r){const{configurable:n=!0,enumerable:o=!0,writable:i,set:s}=Object.getOwnPropertyDescriptor(l.rawWindow,e)||{writable:!0};return{value:r,configurable:n,enumerable:o,writable:i??!!s}}initGlobalKeysWhenStart(e,r,n,o){n.hasOwnProperty=i=>ge.call(n,i)||ge.call(l.rawWindow,i),this.setHijackProperty(e,n),o||this.patchRequestApi(e,r,n),this.setScopeProperties(n)}setHijackProperty(e,r){let n,o;k(r,{eval:{configurable:!0,enumerable:!1,get(){return Ne(e),n||l.rawWindow.eval},set:i=>{n=i}},Image:{configurable:!0,enumerable:!1,get(){return Ne(e),o||l.ImageProxy},set:i=>{o=i}}})}patchRequestApi(e,r,n){let o=Jt(r),i=Zt(r),s=kt(e,r);k(n,{fetch:{configurable:!0,enumerable:!0,get(){return o},set(a){o=Jt(r,a)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get(){return i},set(a){i=Zt(r,a)}},EventSource:{configurable:!0,enumerable:!0,get(){return s},set(a){s=kt(e,r,a)}}})}setScopeProperties(e){this.scopeProperties.forEach(r=>{Reflect.set(e,r,e[r])})}patchRouter(e,r,n){const{microLocation:o,microHistory:i}=ni(e,r);k(n,{location:{configurable:!1,enumerable:!0,get(){return o},set:s=>{l.rawWindow.location=s}},history:{configurable:!0,enumerable:!0,get(){return i}}})}initRouteState(e){zr(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){Yr(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){Wt(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){dt(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){Tt(e,this.microAppWindow.__MICRO_APP_NAME__)}actionsBeforeExecScripts(e,r){this.patchStaticElement(e),this.clearHijackUmdHooks=this.hijackUmdHooks(this.appName,this.microAppWindow,r)}hijackUmdHooks(e,r,n){let o,i,s;return k(r,{mount:{configurable:!0,get:()=>o,set:a=>{this.active&&P(a)&&!o&&n(o=a,i)}},unmount:{configurable:!0,get:()=>i,set:a=>{this.active&&P(a)&&!i&&n(o,i=a)}},[`micro-app-${e}`]:{configurable:!0,get:()=>s,set:a=>{this.active&&B(a)&&!s&&(s=a,n(s.mount,s.unmount))}}}),()=>{o=i=s=null}}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}$e.activeCount=0;function si(t,e,r,n){const o=l.rawWindow.history,i=U(e),s=i.protocol+"//"+i.host,a=i.pathname+i.search+i.hash,c=r.history;return r.rawReplaceState=c.replaceState,Z(c,Kr(t,r.location)),k(c,{scrollRestoration:{configurable:!0,enumerable:!0,get(){return o.scrollRestoration},set(h){o.scrollRestoration=h}}}),Oe(t,a,r.location,"prevent"),Xr(t,e,r,i,n,s)}const ai=["Array"],ci=["getComputedStyle","DOMParser","visualViewport","matchMedia","ResizeObserver","IntersectionObserver"],li=[/animationFrame$/i,/mutationObserver$/i,/height$|width$/i,/offset$/i,/selection$/i,/^range/i,/^screen/i,/^scroll/i,/X$|Y$/],ui=["body","head","html","title"],hi=["childElementCount","children","firstElementChild","firstChild","lastElementChild","activeElement","fullscreenElement","pictureInPictureElement","pointerLockElement","styleSheets"],di=["append","contains","replaceChildren","createRange","getSelection","elementFromPoint","elementsFromPoint","getAnimations"],fi=["characterSet","compatMode","contentType","designMode","dir","doctype","embeds","fullscreenEnabled","hidden","implementation","lastModified","pictureInPictureEnabled","plugins","readyState","referrer","visibilityState","fonts"],pi=["execCommand","createRange","exitFullscreen","exitPictureInPicture","getElementsByTagNameNS","hasFocus","prepend"],mi=["blob:"],_i=window.Worker;function gi(t){try{const e=t instanceof URL?t:new URL(t);return mi.includes(e.protocol)?!0:e.protocol===window.location.protocol&&e.hostname===window.location.hostname&&e.port===window.location.port}catch{return!1}}function vi(t){let e;try{e=new Blob([t],{type:"application/javascript"})}catch{const o=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,i=new o;i.append(t),e=i.getBlob("application/javascript")}return(window.URL||window.webkitURL).createObjectURL(e)}const er=new Proxy(_i,{construct(t,e){let[r,n]=e;n=n||{};const o=K();let i=r;if(o){const s=y.get(o);i=X(r,s.url)}if(i&&!gi(i)){const s=`import "${r}";`,a=vi(s);return n.type="module",new t(a,n)}else return new t(r,n)}});function Ei(t,e,r){return wi(t,e,r),Ai(e,r),bi(e)}function wi(t,e,r){const n=l.rawWindow;ci.forEach(o=>{e[o]=J(n[o],n)}),Object.getOwnPropertyNames(e).filter(o=>(li.some(i=>{if(i.test(o)&&o in e.parent){if(P(n[o]))e[o]=J(n[o],n);else{const{configurable:s,enumerable:a}=Object.getOwnPropertyDescriptor(e,o)||{configurable:!0,enumerable:!0};s&&H(e,o,{configurable:s,enumerable:a,get:()=>n[o],set:c=>{n[o]=c}})}return!0}return!1}),nt(e[o])&&o in n&&!ai.includes(o)&&H(e[o],Symbol.hasInstance,{configurable:!0,enumerable:!1,value(i){return Gt(i,n[o])||Gt(i,e[o])}}),/^on/.test(o)&&!io.includes(o))).forEach(o=>{const{enumerable:i,writable:s,set:a}=Object.getOwnPropertyDescriptor(e,o)||{enumerable:!0,writable:!0};try{H(e,o,{enumerable:i,configurable:!0,get:()=>n[o],set:s??!!a?c=>{n[o]=P(c)?c.bind(e):c}:void 0})}catch(c){me(c,t)}}),r.escapeProperties.forEach(o=>{let i=e[o];H(e,o,{enumerable:!0,configurable:!0,get(){return i??J(n[o],n)},set(s){i=s}})})}function Ai(t,e){const r=l.rawWindow,n=new Set;Object.defineProperty(t,"Worker",{value:er,configurable:!0,writable:!0});const o=new Proxy(t,{get:(i,s)=>s==="Worker"?er:s==="location"?e.proxyLocation:te(wr,s)?o:n.has(s)?Reflect.get(i,s):te(e.escapeProperties,s)&&!Reflect.get(i,s)?J(Reflect.get(r,s),r):J(Reflect.get(i,s),i),set:(i,s,a)=>s==="location"?Reflect.set(r,s,a):(Reflect.has(i,s)||n.add(s),Reflect.set(i,s,a),!0),has:(i,s)=>s in i,deleteProperty:(i,s)=>Reflect.has(i,s)?Reflect.deleteProperty(i,s):!0});e.proxyWindow=o}function bi(t){const{rawWindow:e,rawAddEventListener:r,rawRemoveEventListener:n,rawDispatchEvent:o}=l,i=new Map,s=new Map;function a(A){return no.includes(A)?t:e}t.addEventListener=function(A,O,D){const v=i.get(A);v?v.add(O):i.set(A,new Set([O])),O&&(O.__MICRO_APP_MARK_OPTIONS__=D),r.call(a(A),A,O,D)},t.removeEventListener=function(A,O,D){const v=i.get(A);v!=null&&v.size&&v.has(O)&&v.delete(O),n.call(a(A),A,O,D)},t.dispatchEvent=function(A){return o.call(a(A==null?void 0:A.type),A)};const c=()=>{s.clear()};return{reset:c,record:()=>{i.forEach((A,O)=>{if(A.size){const D=s.get(O)||[];s.set(O,new Set([...D,...A]))}})},rebuild:()=>{s.forEach((A,O)=>{for(const D of A)t.addEventListener(O,D,D==null?void 0:D.__MICRO_APP_MARK_OPTIONS__)}),c()},release:()=>{i.size&&(i.forEach((A,O)=>{for(const D of A)n.call(a(O),O,D)}),i.clear())}}}function Pi(t,e,r){return Ri(t,e),Si(t,e,r),yi(t,e)}function Ri(t,e){const r=l.rawDocument,n=e.Document,o=e.document,i=n.prototype.createElement,s=n.prototype.createElementNS,a=n.prototype.createTextNode,c=n.prototype.createDocumentFragment,h=n.prototype.createComment,p=n.prototype.querySelector,S=n.prototype.querySelectorAll,A=n.prototype.getElementById,O=n.prototype.getElementsByClassName,D=n.prototype.getElementsByTagName,v=n.prototype.getElementsByName,M=n.prototype.elementFromPoint,E=n.prototype.caretRangeFromPoint;n.prototype.caretRangeFromPoint=function(d,_){const b=M.call(r,d,_),N=E.call(r,d,_);return F(b,t),N},n.prototype.createElement=function(d,_){let b=i.call(this,d,_);return Tn(b)&&(b=i.call(r,d,_)),F(b,t)},n.prototype.createElementNS=function(d,_,b){const N=s.call(this,d,_,b);return F(N,t)},n.prototype.createTextNode=function(d){const _=a.call(this,d);return F(_,t)},n.prototype.createDocumentFragment=function(){const d=c.call(this);return F(d,t)},n.prototype.createComment=function(d){const _=h.call(this,d);return F(_,t)};function m(g){return Mt(t),o===g?r:g}function u(g){var d;const _=m(this);if(!g||Pe(g)||r!==_)return p.call(_,g);const b=(d=y.get(t))===null||d===void 0?void 0:d.querySelector(g);return b||g==="base"?b:p.call(o,g)}function f(g){var d,_;const b=m(this);if(!g||Pe(g)||r!==b)return S.call(b,g);const N=(_=(d=y.get(t))===null||d===void 0?void 0:d.querySelectorAll(g))!==null&&_!==void 0?_:[];return N.length||g==="base"?N:S.call(o,g)}n.prototype.querySelector=u,n.prototype.querySelectorAll=f,n.prototype.getElementById=function(d){const _=m(this);if(he(d))return A.call(_,d);try{return u.call(this,`#${d}`)}catch{return A.call(_,d)}},n.prototype.getElementsByClassName=function(d){const _=m(this);if(he(d))return O.call(_,d);try{return f.call(this,`.${d}`)}catch{return O.call(_,d)}},n.prototype.getElementsByTagName=function(d){const _=m(this);if(Pe(d)||he(d))return D.call(_,d);if(/^script$/i.test(d))return D.call(o,d);try{return f.call(this,d)}catch{return D.call(_,d)}},n.prototype.getElementsByName=function(d){const _=m(this);if(he(d))return v.call(_,d);try{return f.call(this,`[name=${d}]`)}catch{return v.call(_,d)}}}function Si(t,e,r){const n=l.rawDocument,o=e.Document,i=e.document,s=(c,h)=>{const{enumerable:p}=Object.getOwnPropertyDescriptor(o.prototype,c)||{enumerable:!0};return{configurable:!0,enumerable:p,get:h}},a=()=>{const c={};return[["documentURI",()=>r.proxyLocation.href],["URL",()=>r.proxyLocation.href],["documentElement",()=>n.documentElement],["scrollingElement",()=>n.scrollingElement],["forms",()=>o.prototype.querySelectorAll.call(i,"form")],["images",()=>o.prototype.querySelectorAll.call(i,"img")],["links",()=>o.prototype.querySelectorAll.call(i,"a")],["microAppElement",()=>{var p;return(p=y.get(t))===null||p===void 0?void 0:p.container}],["__MICRO_APP_NAME__",()=>t]].forEach(p=>{c[p[0]]=s(p[0],p[1])}),hi.forEach(p=>{c[p]=s(p,()=>n[p])}),di.forEach(p=>{c[p]=s(p,()=>J(n[p],n,"DOCUMENT"))}),fi.forEach(p=>{c[p]=s(p,()=>n[p])}),pi.forEach(p=>{c[p]=s(p,()=>J(n[p],n,"DOCUMENT"))}),c};k(o.prototype,a()),ui.forEach(c=>{H(i,c,{enumerable:!0,configurable:!0,get:()=>(Mt(t),n[c]),set:h=>{n[c]=h}})})}function yi(t,e){const{rawDocument:r,rawAddEventListener:n,rawRemoveEventListener:o,rawDispatchEvent:i}=l,s=new Map,a=new Map;let c=null,h=null;const p=e.Document,S=e.document;function A(m,u){return so.includes(m)?u:r}p.prototype.addEventListener=function(m,u,f){const g=P(u)?u.__MICRO_APP_BOUND_FUNCTION__=u.__MICRO_APP_BOUND_FUNCTION__||u.bind(this):u,d=s.get(m);d?d.add(u):s.set(m,new Set()),u&&(u.__MICRO_APP_MARK_OPTIONS__=f),n.call(A(m,this),m,g,f)},p.prototype.removeEventListener=function(m,u,f){const g=s.get(m);g!=null&&g.size&&g.has(u)&&g.delete(u);const d=(u==null?void 0:u.__MICRO_APP_BOUND_FUNCTION__)||u;o.call(A(m,this),m,d,f)},p.prototype.dispatchEvent=function(m){return i.call(A(m==null?void 0:m.type,this),m)};function O(m){return m==="onclick"?u=>{P(c)&&o.call(r,"click",c,!1),P(u)?(c=u.bind(S),n.call(r,"click",c,!1)):c=u}:u=>{r[m]=P(u)?u.bind(S):u}}Object.getOwnPropertyNames(p.prototype).filter(m=>/^on/.test(m)&&!ao.includes(m)).forEach(m=>{const{enumerable:u,writable:f,set:g}=Object.getOwnPropertyDescriptor(p.prototype,m)||{enumerable:!0,writable:!0};try{H(p.prototype,m,{enumerable:u,configurable:!0,get:()=>m==="onclick"?c:r[m],set:f??!!g?O(m):void 0})}catch(d){me(d,t)}});const D=()=>{a.clear(),h=null};return{reset:D,record:()=>{h=c||h,s.forEach((m,u)=>{if(m.size){const f=a.get(u)||[];a.set(u,new Set([...f,...m]))}})},rebuild:()=>{h&&!c&&(S.onclick=h),a.forEach((m,u)=>{for(const f of m)S.addEventListener(u,f,f==null?void 0:f.__MICRO_APP_MARK_OPTIONS__)}),D()},release:()=>{P(c)&&o.call(r,"click",c),c=null,s.size&&(s.forEach((m,u)=>{for(const f of m)o.call(A(u,S),u,(f==null?void 0:f.__MICRO_APP_BOUND_FUNCTION__)||f)}),s.clear())}}}function Mi(t,e,r,n){Oi(t,r,n),Di(e,r)}function Oi(t,e,r){const n=l.rawRootElement,o=l.rawRootNode,i=l.rawDocument,s=e.document,a=e.Node,c=e.Element,h=e.DocumentFragment,p=a.prototype.appendChild,S=a.prototype.insertBefore,A=a.prototype.replaceChild,O=a.prototype.removeChild,D=c.prototype.append,v=c.prototype.prepend,M=h.prototype.append,E=h.prototype.prepend,m=c.prototype.insertAdjacentElement,u=a.prototype.cloneNode,f=Object.getOwnPropertyDescriptor(c.prototype,"innerHTML"),g=Object.getOwnPropertyDescriptor(a.prototype,"parentNode"),d=Object.getOwnPropertyDescriptor(a.prototype,"ownerDocument"),_=L=>(ve(L)||In(L))&&L.__PURE_ELEMENT__,b=L=>L===r.microHead?i.head:L===r.microBody?i.body:L;a.prototype.appendChild=function(R){return F(R,t),_(R)?p.call(this,R):o.prototype.appendChild.call(b(this),R)},a.prototype.insertBefore=function(R,C){return F(R,t),_(R)?S.call(this,R,C):o.prototype.insertBefore.call(b(this),R,C)},a.prototype.replaceChild=function(R,C){return F(R,t),_(R)?A.call(this,R,C):o.prototype.replaceChild.call(b(this),R,C)},a.prototype.removeChild=function(R){return _(R)||this.contains(R)?O.call(this,R):o.prototype.removeChild.call(b(this),R)},h.prototype.append=c.prototype.append=function(...R){let C=0,_e=!1;for(;C<R.length;)R[C]=ye(R[C])?R[C]:s.createTextNode(R[C]),_(R[C])&&(_e=!0),C++;return _e?(ze(this)?M:D).call(this,...R):n.prototype.append.call(b(this),...R)},h.prototype.prepend=c.prototype.prepend=function(...R){let C=0,_e=!1;for(;C<R.length;)R[C]=ye(R[C])?R[C]:s.createTextNode(R[C]),_(R[C])&&(_e=!0),C++;return _e?(ze(this)?E:v).call(this,...R):n.prototype.prepend.call(b(this),...R)},c.prototype.insertAdjacentElement=function(R,C){return F(C,t),_(C)?m.call(this,R,C):n.prototype.insertAdjacentElement.call(b(this),R,C)},H(a.prototype,"baseURI",{configurable:!0,enumerable:!0,get(){return r.proxyWindow.location.href}}),H(a.prototype,"ownerDocument",{configurable:!0,enumerable:!0,get(){var L;return this.__PURE_ELEMENT__||this===s?(L=d.get)===null||L===void 0?void 0:L.call(this):s}}),H(a.prototype,"parentNode",Br(t,g)),a.prototype.getRootNode=function(){return s},a.prototype.cloneNode=function(R){const C=u.call(this,R);return F(C,t)},H(c.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){var L;return(L=f.get)===null||L===void 0?void 0:L.call(this)},set(L){var R;(R=f.set)===null||R===void 0||R.call(this,L),Array.from(this.children).forEach(C=>{ce(C)&&F(C,t)})}});const N=new Proxy(e.Image,{construct(L,R){const C=new L(...R);return F(C,t),C}});H(e,"Image",{configurable:!0,writable:!0,value:N})}function Di(t,e){const r=e.Element,n=r.prototype.setAttribute;r.prototype.setAttribute=function(s,a){if(/^micro-app(-\S+)?/i.test(this.tagName)&&s==="data"&&this.setAttribute!==r.prototype.setAttribute)this.setAttribute(s,a);else{if((s==="src"||s==="srcset")&&/^(img|script|video|audio|source|embed)$/i.test(this.tagName)||s==="href"&&/^(link|image)$/i.test(this.tagName)||s==="href"&&/^(a)$/i.test(this.tagName)&&!/^#/.test(a)){let c=t;rt&&s==="href"&&/^a$/i.test(this.tagName)&&P(w.options.excludeAssetFilter)&&w.options.excludeAssetFilter(a)&&(c=document.baseURI),a=X(a,c)}n.call(this,s,a)}},[[e.HTMLImageElement.prototype,"src"],[e.HTMLScriptElement.prototype,"src"],[e.HTMLLinkElement.prototype,"href"],[e.SVGImageElement.prototype,"href"]].forEach(([i,s])=>{const{enumerable:a,configurable:c,get:h,set:p}=Object.getOwnPropertyDescriptor(i,s)||{enumerable:!0,configurable:!0};H(i,s,{enumerable:a,configurable:c,get:function(){return h==null?void 0:h.call(this)},set:function(S){p==null||p.call(this,X(S,t))}})})}class Ge{constructor(e,r,n){this.active=!1,this.escapeProperties=[],this.updateIframeBase=()=>{var s;(s=this.baseElement)===null||s===void 0||s.setAttribute("href",U(this.url).origin+this.proxyLocation.pathname)},this.appName=e,this.url=r,this.options=n;const o=l.rawWindow.location,i=o.protocol+"//"+o.host;this.deleteIframeElement=this.createIframeElement(e,i+o.pathname,n),this.microAppWindow=this.iframe.contentWindow,this.patchIframe(this.microAppWindow,s=>{this.createIframeTemplate(this.microAppWindow),this.getSpecialProperties(e),this.proxyLocation=si(e,r,this.microAppWindow,i),this.windowEffect=Ei(e,this.microAppWindow,this),this.documentEffect=Pi(e,this.microAppWindow,this),Mi(e,r,this.microAppWindow,this),this.initStaticGlobalKeys(e,r,this.microAppWindow),s()})}createIframeElement(e,r,n){this.iframe=z("iframe");const o=Object.assign(Object.assign({},n==null?void 0:n.attrs),{id:e,src:w.options.iframeSrc||r,style:"display: none","powered-by":"micro-app"});return Object.keys(o).forEach(i=>this.iframe.setAttribute(i,o)),l.rawDocument.body.appendChild(this.iframe),()=>ee(()=>{var i,s;(s=(i=this.iframe)===null||i===void 0?void 0:i.parentNode)===null||s===void 0||s.removeChild(this.iframe),this.iframe=null})}start({baseroute:e,defaultPage:r,disablePatchRequest:n}){this.active||(this.active=!0,this.initRouteState(r),this.removeHistoryListener=Gr(this.microAppWindow.__MICRO_APP_NAME__),ne(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e),n||this.createIframeBase(),++l.activeSandbox===1&&(rn(),qr()),++Ge.activeCount)}stop({umdMode:e,keepRouteState:r,destroy:n,clearData:o}){var i;this.active&&(this.recordAndReleaseEffect({clearData:o},!e||n),this.clearRouteState(r),(i=this.removeHistoryListener)===null||i===void 0||i.call(this),(!e||n)&&(this.deleteIframeElement(),this.clearHijackUmdHooks()),--l.activeSandbox===0&&(nn(),Qr()),--Ge.activeCount,this.active=!1)}initStaticGlobalKeys(e,r,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=r,n.__MICRO_APP_PUBLIC_PATH__=it(r),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="iframe",n.rawWindow=l.rawWindow,n.rawDocument=l.rawDocument,n.microApp=Z(new Ir(e),{removeDomScope:$,pureCreateElement:z,location:this.proxyLocation,router:Qe})}recordAndReleaseEffect(e,r=!1){r?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){var e,r;(e=this.windowEffect)===null||e===void 0||e.reset(),(r=this.documentEffect)===null||r===void 0||r.reset(),xt(this.microAppWindow.microApp)}recordEffectSnapshot(){var e,r;(e=this.windowEffect)===null||e===void 0||e.record(),(r=this.documentEffect)===null||r===void 0||r.record(),Lr(this.microAppWindow.microApp)}rebuildEffectSnapshot(){var e,r;(e=this.windowEffect)===null||e===void 0||e.rebuild(),(r=this.documentEffect)===null||r===void 0||r.rebuild(),xr(this.microAppWindow.microApp)}releaseGlobalEffect({clearData:e=!1}){var r,n,o,i,s;(r=this.windowEffect)===null||r===void 0||r.release(),(n=this.documentEffect)===null||n===void 0||n.release(),(o=this.microAppWindow.microApp)===null||o===void 0||o.clearDataListener(),(i=this.microAppWindow.microApp)===null||i===void 0||i.clearGlobalDataListener(),e&&(w.clearData(this.microAppWindow.__MICRO_APP_NAME__),(s=this.microAppWindow.microApp)===null||s===void 0||s.clearData())}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchIframe(e,r){const n=e.document;this.sandboxReady=new Promise(o=>{(function i(){setTimeout(()=>{try{e.document===n?i():(e.stop(),r(o))}catch{i()}},0)})()})}createIframeTemplate(e){const r=e.document;$n(r);const n=r.createElement("html");n.innerHTML="<head></head><body></body>",r.appendChild(n),this.microBody=r.body,this.microHead=r.head}createIframeBase(){this.baseElement=z("base"),this.updateIframeBase(),this.microHead.appendChild(this.baseElement)}getSpecialProperties(e){var r;B(w.options.plugins)&&(this.commonActionForSpecialProperties(w.options.plugins.global),this.commonActionForSpecialProperties((r=w.options.plugins.modules)===null||r===void 0?void 0:r[e]))}commonActionForSpecialProperties(e){if(se(e))for(const r of e)B(r)&&se(r.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(r.escapeProperties))}initRouteState(e){zr(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){Yr(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){Wt(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){dt(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){Tt(e,this.microAppWindow.__MICRO_APP_NAME__)}actionsBeforeExecScripts(e,r){this.patchStaticElement(e),this.clearHijackUmdHooks=this.hijackUmdHooks(this.appName,this.microAppWindow,r)}hijackUmdHooks(e,r,n){let o,i,s;return k(r,{mount:{configurable:!0,get:()=>o,set:a=>{this.active&&P(a)&&!o&&n(o=a,i)}},unmount:{configurable:!0,get:()=>i,set:a=>{this.active&&P(a)&&!i&&n(o,i=a)}},[`micro-app-${e}`]:{configurable:!0,get:()=>s,set:a=>{this.active&&B(a)&&!s&&(s=a,n(s.mount,s.unmount))}}}),()=>{o=i=s=null}}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}Ge.activeCount=0;const y=new Map;class Jr{constructor({name:e,url:r,container:n,scopecss:o,useSandbox:i,inline:s,iframe:a,ssrUrl:c,isPrefetch:h,prefetchLevel:p,routerMode:S,attrs:A}){this.state=j.CREATED,this.keepAliveState=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.umdMode=!1,this.sandBox=null,this.fiber=!1,y.set(e,this),this.name=e,this.url=r,this.useSandbox=i,this.scopecss=this.useSandbox&&o,this.attrs=A,this.iframe=a??!1,this.inline=this.getInlineModeState(s),this.routerMode=S||Fe,this.container=n??null,this.ssrUrl=c??"",this.isPrefetch=h??!1,this.isPrerender=p===3,this.prefetchLevel=p,this.source={html:null,links:new Set,scripts:new Set},this.loadSourceCode(),this.createSandbox()}loadSourceCode(){this.setAppState(j.LOADING),Dt.getInstance().run(this,yo)}onLoad({html:e,defaultPage:r,routerMode:n,baseroute:o,disablePatchRequest:i}){var s;if(++this.loadSourceLevel===2){if(this.source.html=e,this.isUnmounted())return;if(!this.isPrefetch)le(this.container).mount(this);else if(this.isPrerender){const a=z("div");a.setAttribute("prerender","true"),(s=this.sandBox)===null||s===void 0||s.setPreRenderState(!0),this.mount({container:a,inline:this.inline,fiber:!0,defaultPage:r||"",disablePatchRequest:i??!1,routerMode:n,baseroute:o||""})}}}onLoadError(e){this.loadSourceLevel=-1,this.isUnmounted()||(this.onerror(e),this.setAppState(j.LOAD_FAILED))}mount({container:e,inline:r,routerMode:n,defaultPage:o,baseroute:i,disablePatchRequest:s,fiber:a}){if(this.loadSourceLevel!==2)return this.container=e,this.isPrerender=!1,oe(this,"statechange",{appState:j.LOADING}),this.setAppState(j.LOADING);this.createSandbox(),this.setAppState(j.BEFORE_MOUNT);const c=()=>{var h,p,S,A,O,D,v;if(this.isPrerender&&Cn(this.container)&&this.container.hasAttribute("prerender"))this.container=this.cloneContainer(e,this.container,!1),(h=this.sandBox)===null||h===void 0||h.rebuildEffectSnapshot(),(p=this.preRenderEvents)===null||p===void 0||p.forEach(M=>M()),this.isPrerender=!1,this.preRenderEvents=null,Qe.attachToURL(this.name),(S=this.sandBox)===null||S===void 0||S.setPreRenderState(!1);else{this.container=e,this.inline=this.getInlineModeState(r),this.fiber=a,this.routerMode=n;const M=()=>{ue(this.container,this.name,x.BEFOREMOUNT)};if(this.isPrerender?((A=this.preRenderEvents)!==null&&A!==void 0?A:this.preRenderEvents=[]).push(M):M(),this.setAppState(j.MOUNTING),oe(this,"statechange",{appState:j.MOUNTING}),this.cloneContainer(this.container,this.source.html,!this.umdMode),(O=this.sandBox)===null||O===void 0||O.start({umdMode:this.umdMode,baseroute:i,defaultPage:o,disablePatchRequest:s}),!this.umdMode)(D=this.sandBox)===null||D===void 0||D.actionsBeforeExecScripts(this.container,(E,m)=>{var u;if(!this.umdMode&&!this.isUnmounted()&&(this.umdHookMount=P(E)?E:null,this.umdHookUnmount=P(m)?m:null,P(this.umdHookMount)&&P(this.umdHookUnmount))){(u=this.sandBox)===null||u===void 0||u.markUmdMode(this.umdMode=!0);try{this.getAppState()===j.MOUNTED?this.umdHookMount(w.getData(this.name,!0)):this.handleMounted(this.umdHookMount(w.getData(this.name,!0)))}catch(f){I(`An error occurred when mount
`,this.name,f)}}}),vo(this,E=>{!this.umdMode&&E===!0&&this.handleMounted()});else{(v=this.sandBox)===null||v===void 0||v.rebuildEffectSnapshot();try{this.handleMounted(this.umdHookMount(w.getData(this.name,!0)))}catch(E){I(`An error occurred when mount
`,this.name,E)}}}};this.sandBox?this.sandBox.sandboxReady.then(()=>!this.isUnmounted()&&c()):c()}handleMounted(e){var r,n;const o=()=>{const i=()=>this.actionsAfterMounted();mt(e)?e.then(i).catch(s=>{I(`An error occurred in window.mount
`,this.name,s),i()}):i()};this.isPrerender?((r=this.preRenderEvents)===null||r===void 0||r.push(o),(n=this.sandBox)===null||n===void 0||n.recordAndReleaseEffect({isPrerender:!0})):o()}actionsAfterMounted(){var e;this.isUnmounted()||(this.setAppState(j.MOUNTED),$t(this.getMicroAppGlobalHook(Ae.ONMOUNT),this.name,Ae.ONMOUNT,w.getData(this.name,!0)),oe(this,"statechange",{appState:j.MOUNTED}),oe(this,"mounted"),ue(this.container,this.name,x.MOUNTED),this.isHidden()&&((e=this.sandBox)===null||e===void 0||e.recordAndReleaseEffect({keepAlive:!0})))}unmount({destroy:e,clearData:r,keepRouteState:n,unmountcb:o}){var i;e=e||this.state===j.LOAD_FAILED,this.setAppState(j.UNMOUNT);try{this.handleUnmounted(e,r,n,o,(i=this.umdHookUnmount)===null||i===void 0?void 0:i.call(this,w.getData(this.name,!0)))}catch(s){I(`An error occurred when unmount
`,this.name,s)}}handleUnmounted(e,r,n,o,i){oe(this,"statechange",{appState:j.UNMOUNT}),oe(this,"unmount"),$t(this.getMicroAppGlobalHook(Ae.ONUNMOUNT),this.name,Ae.ONUNMOUNT);const s=()=>this.actionsAfterUnmounted({destroy:e,clearData:r,keepRouteState:n,unmountcb:o});mt(i)?($(),i.then(s).catch(a=>{I(`An error occurred in window.unmount
`,this.name,a),s()})):s()}actionsAfterUnmounted({destroy:e,clearData:r,keepRouteState:n,unmountcb:o}){var i;this.umdMode&&this.container&&!e&&this.cloneContainer(this.source.html,this.container,!1),(i=this.sandBox)===null||i===void 0||i.stop({umdMode:this.umdMode,keepRouteState:n&&!e,destroy:e,clearData:r||e}),ue(this.container,this.name,x.UNMOUNT),this.clearOptions(e),o==null||o()}clearOptions(e){var r,n;this.isPrerender=!1,this.preRenderEvents=null,this.setKeepAliveState(null),this.container?(this.container.innerHTML="",this.container=null):this.umdMode||(n=(r=this.sandBox)===null||r===void 0?void 0:r.deleteIframeElement)===null||n===void 0||n.call(r),this.iframe&&!this.umdMode&&(this.sandBox=null),e&&this.actionsForCompletelyDestroy(),$()}actionsForCompletelyDestroy(){var e,r;(r=(e=this.sandBox)===null||e===void 0?void 0:e.deleteIframeElement)===null||r===void 0||r.call(e),Y.script.deleteInlineInfo(this.source.scripts),y.delete(this.name)}hiddenKeepAliveApp(e){var r,n;this.setKeepAliveState(xe.KEEP_ALIVE_HIDDEN),oe(this,"appstate-change",{appState:"afterhidden"}),ue(this.container,this.name,x.AFTERHIDDEN),V(this.name)&&((r=this.sandBox)===null||r===void 0||r.removeRouteInfoForKeepAliveApp()),this.loadSourceLevel!==2?le(this.container).unmount():(this.container=this.cloneContainer(z("div"),this.container,!1),(n=this.sandBox)===null||n===void 0||n.recordAndReleaseEffect({keepAlive:!0})),e==null||e()}showKeepAliveApp(e){var r,n;const o=this.container;this.container=e,(r=this.sandBox)===null||r===void 0||r.rebuildEffectSnapshot(),oe(this,"appstate-change",{appState:"beforeshow"}),ue(e,this.name,x.BEFORESHOW),this.setKeepAliveState(xe.KEEP_ALIVE_SHOW),this.cloneContainer(this.container,o,!1),V(this.name)&&((n=this.sandBox)===null||n===void 0||n.setRouteInfoForKeepAliveApp()),oe(this,"appstate-change",{appState:"aftershow"}),ue(this.container,this.name,x.AFTERSHOW)}onerror(e){oe(this,"statechange",{appState:j.LOAD_FAILED}),ue(this.container,this.name,x.ERROR,e)}parseHtmlString(e){var r;const n=!((r=this.sandBox)===null||r===void 0)&&r.proxyWindow?this.sandBox.proxyWindow.DOMParser:l.rawWindow.DOMParser;return new n().parseFromString(e,"text/html").body}cloneContainer(e,r,n){return r&&e&&(e.innerHTML="",Array.from(n?this.parseHtmlString(r.innerHTML).childNodes:r.childNodes).forEach(o=>{e.appendChild(o)})),e}createSandbox(){this.useSandbox&&!this.sandBox&&(this.sandBox=this.iframe?new Ge(this.name,this.url,{attrs:this.attrs}):new $e(this.name,this.url))}setAppState(e){var r;this.state=e,(r=this.sandBox)===null||r===void 0||r.setStaticAppState(e)}getAppState(){return this.state}setKeepAliveState(e){this.keepAliveState=e}getKeepAliveState(){return this.keepAliveState}isUnmounted(){return j.UNMOUNT===this.state}isHidden(){return xe.KEEP_ALIVE_HIDDEN===this.keepAliveState}getMicroAppGlobalHook(e){var r,n;const o=(n=(r=this.sandBox)===null||r===void 0?void 0:r.proxyWindow)===null||n===void 0?void 0:n[e];return P(o)?o:null}querySelector(e){return this.container?l.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?l.rawElementQuerySelectorAll.call(this.container,e):[]}getInlineModeState(e){var r;return(r=this.iframe||e)!==null&&r!==void 0?r:!1}}function we(t){var e,r;return(r=(e=y.get(t))===null||e===void 0?void 0:e.iframe)!==null&&r!==void 0?r:!1}const ae=new WeakMap;function Zr(t){var e;return(e=ae.get(t))!==null&&e!==void 0?e:t}function kr(t,e){if(ae.has(t))return ae.get(t);if(Pt(t)){if(t.hasAttribute("exclude")){const r=document.createComment("style element with exclude attribute ignored by micro-app");return ae.set(t,r),r}else if(e.scopecss&&!t.hasAttribute("ignore"))return ct(t,e);return t}else if(sr(t)){if(t.hasAttribute("exclude")||It(t.getAttribute("href"),e.name)){const i=document.createComment("link element with exclude attribute ignored by micro-app");return ae.set(t,i),i}else if(t.hasAttribute("ignore")||Lt(t.getAttribute("href"),e.name)||t.href&&P(w.options.excludeAssetFilter)&&w.options.excludeAssetFilter(t.href))return t;const{address:r,linkInfo:n,replaceComment:o}=fr(t,null,e,!0);if(r&&n){const i=eo(r,e,n,t);return ae.set(t,i),i}else if(o)return ae.set(t,o),o;return t}else if(ve(t)){if(t.src&&P(w.options.excludeAssetFilter)&&w.options.excludeAssetFilter(t.src))return t;const{replaceComment:r,address:n,scriptInfo:o}=yr(t,null,e,!0)||{};if(n&&o){const i=o.isExternal?Eo(n,e,o,t):wo(n,e,o);return ae.set(t,i),i}else if(r)return ae.set(t,r),r;return t}return t}function en(t,e,r,n,o){const i=tn(r,n,t);if(i){if(!we(t.name)&&Ye(i)&&e!==l.rawRemoveChild){const s=Object.getOwnPropertyDescriptor(n,"parentNode");(!s||s.configurable)&&!n.__MICRO_APP_HAS_DPN__&&k(n,{parentNode:{configurable:!0,get(){var a,c;const h=l.rawParentNodeDesc.get.call(this);return Ye(h)&&t.container?((c=(a=w.options).getRootElementParentNode)===null||c===void 0?void 0:c.call(a,this,t.name))||document.body:h}},__MICRO_APP_HAS_DPN__:{configurable:!0,get:()=>!0}})}if(o&&!i.contains(o)){if(e===l.rawInsertBefore&&r.contains(o)){const s=Array.from(r.childNodes).indexOf(o);if(i.childNodes)return Xe(e,i,n,i.childNodes,t)}return l.rawAppendChild.call(i,n)}else if(e===l.rawRemoveChild&&!i.contains(n))return r.contains(n)?e.call(n.parentElement,n):n;return Xe(e,i,n,o,t)}return Xe(e,r,n,o,t)}function tn(t,e,r){if(r){if(t===document.head)return r.iframe&&ve(e)?r.sandBox.microHead:r.querySelector("micro-app-head");if(t===document.body||t===document.body.parentNode)return r.iframe&&ve(e)?r.sandBox.microBody:r.querySelector("micro-app-body");if(r.iframe&&ve(e))return r.sandBox.microBody}return null}function Xe(t,e,r,n,o){return Ci(t)?(o!=null&&o.iframe&&ve(r)&&(t===l.rawFragmentAppend?t=l.rawAppend:t===l.rawFragmentPrepend&&(t=l.rawPrepend)),t.call(e,r)):t.call(e,r,n)}function Ci(t){return t===l.rawAppend||t===l.rawPrepend||t===l.rawFragmentAppend||t===l.rawFragmentPrepend}function Ii(t,e){ce(e)&&(/^(img|script)$/i.test(e.tagName)?(e.hasAttribute("src")&&l.rawSetAttribute.call(e,"src",X(e.getAttribute("src"),t.url)),e.hasAttribute("srcset")&&l.rawSetAttribute.call(e,"srcset",X(e.getAttribute("srcset"),t.url))):(/^(link|image)$/i.test(e.tagName)&&e.hasAttribute("href")||/^(a)$/i.test(e.tagName)&&e.hasAttribute("href")&&!/^#/.test(e.getAttribute("href")||""))&&l.rawSetAttribute.call(e,"href",X(e.getAttribute("href"),t.url)))}function De(t,e,r,n){const o=K();if(ye(e)&&!e.__PURE_ELEMENT__&&(e.__MICRO_APP_NAME__||o)){F(e,e.__MICRO_APP_NAME__||o);const i=y.get(e.__MICRO_APP_NAME__);if(i!=null&&i.container)return Pt(e)&&t.getRootNode()instanceof ShadowRoot&&e.setAttribute("ignore","true"),Ii(i,e),en(i,n,t,kr(e,i),r&&Zr(r))}return Xe(n,t,e,r)}function rn(){Li();const t=l.rawRootElement,e=l.rawRootNode,r=l.rawDocumentFragment;e.prototype.appendChild=function(s
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|M男之家

GMT+8, 2026-11-13 05:43 , Processed in 0.042857 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表