(()=>{var e="mfe-loader",t="manifest.json",r=`${e}: Missing file name`,n=`${e}: Missing manifest file`,a=`${e}: Missing mfe name in manifest`,i=`${e}: Missing URL`,o=`${e}: Root element not found`,s=`${e}: Renderer type not defined`,l=`${e}: Renderer handler not found`,d=`${e}: Renderer loader not found`,f=`${e}: Module not found`,u=(e,t,r)=>e.prepend(m(c(t,r)));function c(e,t){return`${e}/${t}`}function p(e){if(e)for(;e.firstChild;)e.lastChild&&e.removeChild(e.lastChild)}function h(e,t){p(e),t&&e.appendChild(t)}function m(e){let t=document.createElement("link");return t.setAttribute("rel","stylesheet"),t.setAttribute("href",e),t}async function w(e,t){return new Promise((r,n)=>{let a="mfe-script:"+e;document.getElementById(a)&&r();let i=document.createElement("script");i.id=a,i.onload=()=>r(),i.onerror=e=>n(e),i.src=t,document.head.appendChild(i)})}async function y(e){let t=await fetch(e);return t.ok?t.json():null}var g,M,C,E,b,R,$={web_component:class{async getModule(e="es",t,r){return"es"===e?await import(r):(await w(t,r),window[t])}loadWebComponent(e,t,r={}){let n=document.createElement(t);n.id=t,Object.entries(r).forEach(e=>{n[e[0]]=e[1]}),e.append(n),h(e,n)}async render(e){let{jsFile:t,name:n,format:i}=e.manifest;if(!t)throw Error(r);if(!n)throw Error(a);let o=await this.getModule(i,n,c(e.url,t));customElements.define(n,o.default),this.loadWebComponent(e.root,n,e.props)}},shadow_dom:class{async getModule(e="es",t,r){return"es"===e?await import(r):(await w(t,r),{default:window[t]})}async render(e){let{jsFile:t,cssFile:n,format:a,name:i}=e.manifest;if(!t)throw Error(r);let o=e.root.attachShadow({mode:"open"}),s=await this.getModule(a,i,c(e.url,t));if(await s.default({container:o,styledTarget:o,props:e.props}),Array.isArray(n))return n.forEach(t=>{u(o,e.url,t)});n&&u(o,e.url,n)}},iframe:class{async render(e){let t=document.createElement("iframe");t.src=e.url,t.width="100%",t.height="100%",t.style.marginBottom="2.6rem",t.style.display="block",t.id="iframe-stage",e.root.appendChild(t)}},html:class{async getModule(e="es",t,r){return"es"===e?await import(r):(await w(t,r),{default:window[t]})}async render(e){let{jsFile:t,cssFile:n,format:a,name:i}=e.manifest,{root:o}=e;if(!t)throw Error(r);let s=await this.getModule(a,i,c(e.url,t));if(await s.default({container:o,styledTarget:o,props:e.props}),Array.isArray(n))return n.forEach(t=>{document.head.appendChild(m(c(e.url,t)))});n&&document.head.appendChild(m(c(e.url,n)))}}},v=class{static create(e="iframe"){let{[e]:t}=$;return new t}},A=class{container;url;props;options;constructor(e,t,r={},n={}){this.url=t,this.container=e,this.props=r,this.options=n}get manifest(){return y(c(this.url,t))}async render(){p(this.container);let e=await this.manifest||{name:"mfe",loader:"iframe"},t=v.create(e.loader),r={manifest:e,root:this.container,url:this.url,props:this.props};return t.render(r)}};async function k({root:e,url:t,props:r}){if(!e)throw Error(o);if(!t)throw Error(i);let n=new A(e,t.replace(/\/$/,""),r);await n.render()}var _=k;window.renderMfe=_})();