@myop/sdk 0.4.0-beta.1 → 0.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled-declarations.d.ts +35 -0
- package/dist/cjs/_IframeSDK.3faa31eb.min.js +1 -0
- package/dist/cjs/{_IframeSDK.158994c9.js → _IframeSDK.c2e3efb9.js} +89 -16
- package/dist/cjs/_IframeSDK.c2e3efb9.js.map +7 -0
- package/dist/cjs/{_WebComponentSDK.ca9d238e.js → _WebComponentSDK.3728ca8b.js} +39 -13
- package/dist/cjs/_WebComponentSDK.3728ca8b.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.e517f1a4.min.js +1 -0
- package/dist/cjs/_hostSDK.48b3ff7a.min.js +1 -0
- package/dist/cjs/{_hostSDK.3c04ba71.js → _hostSDK.94744d97.js} +39 -13
- package/dist/cjs/_hostSDK.94744d97.js.map +7 -0
- package/dist/cjs/myop_sdk.js +11 -11
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +91 -17
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/IframeSDK.d.ts +32 -0
- package/dist/module/Iframe/index.js +90 -17
- package/dist/module/Iframe/index.js.map +2 -2
- package/dist/module/SDK.js +91 -17
- package/dist/module/SDK.js.map +2 -2
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/host/components/IMyopComponent.d.ts +3 -0
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/index.js +40 -14
- package/dist/module/host/index.js.map +2 -2
- package/dist/module/webcomponent/index.js +40 -14
- package/dist/module/webcomponent/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.158994c9.js.map +0 -7
- package/dist/cjs/_IframeSDK.941e9a62.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.5f41b3b7.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.ca9d238e.js.map +0 -7
- package/dist/cjs/_hostSDK.23c64e1b.min.js +0 -1
- package/dist/cjs/_hostSDK.3c04ba71.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var jt=Object.defineProperty,On=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Vt=Object.getOwnPropertySymbols;var $n=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var at=(o,n,e)=>n in o?jt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))$n.call(n,e)&&at(o,e,n[e]);if(Vt)for(var e of Vt(n))An.call(n,e)&&at(o,e,n[e]);return o},L=(o,n)=>On(o,zn(n));var Fn=(o,n)=>{for(var e in n)jt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>at(o,typeof n!="symbol"?n+"":n,e);var De=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var Gt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},pt=class{constructor(n){this.messageToHost=n}},Be=class extends pt{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var y={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var Le={};Fn(Le,{AddEventListenerMessage:()=>ft,BaseMyopMessage:()=>M,BindClickMessage:()=>lt,ChangeTextMessage:()=>mt,CleanupMessage:()=>Ie,CleanupReplayMessage:()=>we,ClickReplayMessage:()=>me,CreateRefComponentMessage:()=>Me,CustomRefMessage:()=>G,DetectMyopRefsMessage:()=>ht,DetectedMyopRefsMessage:()=>be,DisposeMessage:()=>xe,ElementValueReplayMessage:()=>ge,EnvelopedMessage:()=>Ce,EventListenerCallbackMessage:()=>ue,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>fe,GetAttributeMessage:()=>Mt,GetAttributeReplayMessage:()=>Ct,GetElementValueMessage:()=>gt,InitMessage:()=>Y,InitRequest:()=>he,InitResponse:()=>ye,MessageDirection:()=>_,MutationObserverMessage:()=>It,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>ct,Ref:()=>U,RefComponentCreatedMessage:()=>ie,ResizeObserverMessage:()=>wt,SetAttributeMessage:()=>ut,SetInnerHtml:()=>yt,SetMutationObserverMessage:()=>bt,SetResizeObserverMessage:()=>ve,stripFunction:()=>Xt});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Kn=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Wn=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var dt=o=>{let n=Wn(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(Kn(n.slice(t,t+16)));return e};var Yt=o=>new Promise(n=>setTimeout(n,o));var _=class{};r(_,"down","down"),r(_,"up","up");var M=class{constructor(){r(this,"id",R());r(this,"myop",!0);r(this,"content");r(this,"source");r(this,"destination");r(this,"route");r(this,"ref");r(this,"direction");r(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},ct=class extends M{constructor(e){super();this.ref=e}},w=class extends M{constructor(e){super();this.replayToHandler=e}},x=class extends M{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",R())}},U=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=L(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var Qt="ClickReplayMessage",lt=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Qt);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},me=class extends w{constructor(){super(...arguments);r(this,"messageType",Qt)}};var mt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Jt="ExecuteScriptReplyMessage",Nn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Un=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xt=o=>{let n=o.match(Nn);if(n)return n[1]||n[3];{let e=o.match(Un);if(e)return e[1].trim()}},k=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Jt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Xt(this.content)}};r(k,"replierKey","send"),r(k,"completeStreamKey","completeStream");var fe=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Jt)}};var G=class extends k{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=L(h({},t),{_script:e.toString()})}};var Zt="EventListenerCallbackMessage",ft=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Zt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},ue=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Zt);this.content={e:t}}};var ut=class extends M{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var en="ElementValueReplayMessage",gt=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",en);r(this,"messageType","GetElementValueMessage")}},ge=class extends w{constructor(e){super();this.content=e;r(this,"messageType",en)}};var yt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var Y=class extends M{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ye=class extends Y{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},he=class extends M{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var tn="RefComponentCreatedMessage",Me=class extends x{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",tn);r(this,"messageType","CreateRefComponentMessage")}},ie=class extends w{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",tn)}};var Ce=class extends M{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var nn="DetectedMyopRefsMessage",ht=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",nn)}},be=class extends w{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",nn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var on="GetAttributeReplayMessage",Mt=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",on);r(this,"messageType","GetAttributeMessage")}},Ct=class extends w{constructor(e){super();this.content=e;r(this,"messageType",on)}};var D=class extends M{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var bt=class extends M{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},It=class extends M{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var sn="CleanupReplayMessage",Ie=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",sn);r(this,"messageType","CleanupMessage")}},we=class extends w{constructor(e){super();this.customCleanup=e;r(this,"messageType",sn)}};var xe=class extends M{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ve=class extends M{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},wt=class extends M{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var xt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},Pe=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==_.down)return;if(t.messageType===y.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===y.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new xt(s),this.messageToHost(new ye(s));return}if(t.messageType===y.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new we(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],Gt(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var A={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var Q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ae={message:"message",code:"code"},re=class{};r(re,"code","code"),r(re,"component","component");var J={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ze={Segment:"Segment",Promo:"Promo",AB:"AB"},Oe=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var $e={webcomponent_message_key:"myop_webcomponent_message"};var I=class extends Be{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(L(h({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var F={id:"myop-id"};var B=(o,n)=>n.querySelectorAll("[".concat(F.id,"='").concat(o.refConfig.selector,"']"));var Ae=class extends I{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=B(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new me(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Fe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Ke=class extends Oe{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var We=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(F.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(F.id);p&&i.push(new De(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new be(e.handlerUniqueId,i))});r(this,"messageType",y.DetectMyopRefsMessage)}};var Ne="__federation__",rn="onLoad";var Ue=(o,n)=>{window[Ne]&&window[Ne][o]&&window[Ne][o][rn]&&window[Ne][o][rn]({[o]:n})};var qe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var vt=o=>o!==Object(o),qn=o=>typeof o=="function",St=o=>{if(vt(o))return!0;if(qn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!St(e))return!1}else{if(vt(e))continue;return!1}}return!0},K=(o,n={},e=!0,t=new WeakMap)=>{if(vt(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=K(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=K(o[i],!0,e,t)):typeof a=="object"&&(s[i]=K(o[i],a,e,t)))}return s}return{}};var Ve=class extends I{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=B(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{s(new ue(e.handlerUniqueId,K(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var z=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||q.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&(this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id)),this.dispose())},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===y.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=_.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=_.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Ie(n.id,t=>{})),e&&e()}:()=>{}}runDisposeHandlers(){let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)})}dispose(){if(this.markedForDisposed=!0,!this.isInitiated){this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed";return}console.log("disposing component",this.id),this.send(new xe),this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var an={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var Se=class extends z{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new Ce(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var X=class extends z{constructor(e,t,s,i,a,p){super(e,s,p);this.container=s;this.customElement=i;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",e=>{let t=e.detail;t!=null&&t.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}))});r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=pe(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}};var Vn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},pe=(o,n,e,t,s,i)=>{let a=Vn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},pn=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),dn=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},cn=(o,n,e)=>{let t=n.reduce((i,a)=>L(h({},i),{[a.name]:h({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(pn(p,a,o))return!1;if(p.behavior.type===ae.code){if(o instanceof X)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(o instanceof W&&o.isolated)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Q.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return dn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(U.create(p.behavior.ref)),c.push(u=>{d(u)}),p.behavior.params&&c.push(...p.behavior.params);let m=Le[p.behavior.message];o.send(new m(...c))}):null},set:(i,a,p)=>{let d=t[a];if(pn(d,a,o))return!1;if(d.behavior.type===ae.code){if(o instanceof X){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(o instanceof W&&o.isolated){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Q.localFrame){let m=d.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=p,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.forEach(l=>{o.markedForDisposed||p(l.action,l.payload)})}return!0}return dn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(U.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let m=Le[d.behavior.message];return o.send(new m(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},jn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{St(p)||an.notSerializableRefCall(t,p)}),n.send(new G(({ref:p,propName:d,functionArgs:c,makeSerializable:m})=>{if(p){let u=p[d];return m(typeof u=="function"?p[d](...c):u,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new G(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),Et=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new Se(n.type,s,t);e.push(p);let d=()=>{let m=e.indexOf(p);m!==-1&&e.splice(m,1)};await s.initiated();let c=setTimeout(()=>{d(),a("timeout")},5e3);s.send(new Me(o.refConfig,n,L(h({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){d(),a("CreateRefComponentMessage failed");return}let u=e.find(f=>f.id==p.id);if(u&&u!==p){d(),s.refs[o.refConfig.name]=u,i(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(E=>E.type.id===f.componentDefinitionId).type,l=new Se(g,p);l.setInitiated(),p.refs[f.refName]=l,e.push(l)});try{await _t(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},_t=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var d;if(i.behavior.type==re.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=U.create("",i,o);try{let f=await Et(u,m,e);o.refs[i.name]=f,a()}catch(f){p(f)}}else try{let c=U.create("",i,o);o.refs[i.name]=jn(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(i){throw i}};var W=class extends z{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"isolated",!1);r(this,"_lastData");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_isoMsgHandler");r(this,"_isoSizeOpts");r(this,"_isoAutoSize",!1);r(this,"_isoLastSize");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new k(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this.isolated)return this._isoSizeOpts=e,this._isoAutoSize=!0,this._isoLastSize&&this._applyIsoSize(this._isoLastSize.height,this._isoLastSize.width),()=>{this._isoAutoSize=!1,this._isoSizeOpts=void 0};if(this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return this.observeHeightViaBridge();let i=(g,l,E)=>l!==void 0&&g<l?l:E!==void 0&&g>E?E:g,a=g=>{if(g===void 0)return;if(typeof g=="number")return g;let l=parseFloat(g);return isNaN(l)?void 0:l},p=()=>{var Ot,zt,$t,At,Ft,Kt,Wt,Nt;let g=t.contentDocument;if(!g)return;let l=this._autoSizeOptions,E=a(l==null?void 0:l.minWidth),T=a(l==null?void 0:l.maxWidth),N=a(l==null?void 0:l.minHeight),v=a(l==null?void 0:l.maxHeight),ee=(Ot=l==null?void 0:l.loaderMinHeight)!=null?Ot:50,j=((zt=this.sizeMeta)==null?void 0:zt.width)==="100%"?"100%":void 0,H=(($t=this.sizeMeta)==null?void 0:$t.height)==="100%"?"100%":void 0,b=(Ft=(At=l==null?void 0:l.explicitWidth)!=null?At:j)!=null?Ft:"100%",C=(Kt=l==null?void 0:l.explicitHeight)!=null?Kt:H,S=b!==void 0,te=C!==void 0,ne=this.container.getBoundingClientRect(),En=ne.width===0,_n=ne.height===0||ne.height===ee,oe=(l!=null&&l.forceAutoSize||En)&&!S,se=(l!=null&&l.forceAutoSize||_n)&&!te;if(!oe&&!se){t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(Wt=l==null?void 0:l.onSizeChange)==null||Wt.call(l,{width:typeof b=="number"?b:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let Tn=t.style.transition,$=this.container,Rn=$.style.transition;t.style.transition="none",$.style.transition="none";let kt=t.getBoundingClientRect().height,Ht=t.getBoundingClientRect().width,Dt=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),Bt=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),ce=Bt,le=Dt,kn=se&&Dt>kt+1,Hn=oe&&Bt>Ht+1,Re=se&&!kn,ke=oe&&!Hn;if(Re||ke){let Ln=$.style.minHeight,Pn=$.style.minWidth;Re&&($.style.minHeight="".concat(kt,"px")),ke&&($.style.minWidth="".concat(Ht,"px")),Re&&(t.style.height="0px"),ke&&(t.style.width="0px"),ce=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height));let Ut=Re&&le<2,qt=ke&&ce<2;if(Ut||qt){let He=g.createElement("style");He.id="__myop_measure";let rt=[];Ut&&rt.push("height: auto !important","min-height: 0 !important","max-height: none !important"),qt&&rt.push("width: auto !important","min-width: 0 !important","max-width: none !important"),He.textContent="*, *::before, *::after { ".concat(rt.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),g.head.appendChild(He),ce=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),He.remove()}$.style.minHeight=Ln,$.style.minWidth=Pn}let Lt=i(ce,E,T),Pt=i(le,N,v);oe?t.style.width="".concat(Lt,"px"):t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",se?t.style.height="".concat(Pt,"px"):t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",t.offsetHeight,t.style.transition=Tn,$.style.transition=Rn;let Dn=oe&&T!==void 0&&ce>T,Bn=se&&v!==void 0&&le>v;g.documentElement.style.overflowX=Dn?"auto":"",g.documentElement.style.overflowY=Bn?"auto":"",(Nt=l==null?void 0:l.onSizeChange)==null||Nt.call(l,{width:Lt,height:Pt,autoSizingWidth:oe,autoSizingHeight:se})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},m=new ResizeObserver(()=>c());m.observe(s.body),m.observe(s.documentElement);let u=new MutationObserver(()=>c());u.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{m.disconnect(),u.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});r(this,"_bridgeSizeCleanup");r(this,"observeHeightViaBridge",()=>{if(this._bridgeSizeCleanup)return this._bridgeSizeCleanup;let e,t=!1,s=()=>{t=!0,e==null||e(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=s,this.initiated().then(()=>{t||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),e=this.send(new ve))}).catch(i=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(i))}),s});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new k(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new k(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=h({},e);if(t.messageType===y.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=_.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(this,"dispose",()=>{var e,t;(e=this._bridgeSizeCleanup)==null||e.call(this),this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this._isoMsgHandler&&(window.removeEventListener("message",this._isoMsgHandler),this._isoMsgHandler=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),(t=this.IframeElement.parentNode)==null||t.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=e=>{if(e.source!==this.IframeElement.contentWindow)return;let t=e.data;!t||t.__myop!==!0||(t.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}):t.type==="myop:size"&&this._applyIsoSize(t.height,t.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(e){var t,s;this._lastData=e,(s=(t=this.IframeElement)==null?void 0:t.contentWindow)==null||s.postMessage({__myop:!0,type:"myop:init",data:e},"*")}getData(){return this._lastData}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}_applyIsoSize(e,t){var c;if(!e||Number.isNaN(e)||(this._isoLastSize={height:e,width:t},!this._isoAutoSize))return;let s=this._isoSizeOpts,i=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),a=i(s==null?void 0:s.minHeight),p=i(s==null?void 0:s.maxHeight),d=e;a!==void 0&&d<a&&(d=a),p!==void 0&&d>p&&(d=p),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=d+"px",this.IframeElement.style.width="100%",(c=s==null?void 0:s.onSizeChange)==null||c.call(s,{width:t!=null?t:this.IframeElement.clientWidth,height:d,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=pe(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===y.In.MutationObserverMessage||e.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var V=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var Gn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},je=class extends V{constructor(){super(...arguments);r(this,"type",A.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=R(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;let u="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=u,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=t.loader.url;i!=null&&i._hasParent&&(f=Gn(f,"_myop-comp",c)),a.src=f,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}let d=new W(e,t,s,a,i);return p.autoHeight&&(i==null?void 0:i.autoSize)!==!1&&d.observeHeightViaBridge(),d})}};var de=class extends z{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),s=super.send(t),i=new CustomEvent($e.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=pe(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var Tt={},Ge=class extends V{constructor(){super(...arguments);r(this,"type",A.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;Tt[a.url]?console.log("Module alreday loaded or in loading process"):Tt[a.url]=new Promise((c,m)=>{let u=a.url,f=document.createElement("script");f.type="module",f.src=u,f.onload=()=>{c()},f.onerror=()=>{m()},document.head.appendChild(f)}),await Tt[a.url],await Yt(1);let p="myop-comp-".concat(R()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new de(e,t,s,d,i)})}};var ln="0.4.0-beta.3";var Yn="myop-delivery",Je="components";var Ye=null;function Qn(){return Ye||(Ye=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(Yn,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(Je)||e.createObjectStore(Je,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),Ye)}function Qe(o,n){return Qn().then(e=>new Promise(t=>{if(!e)return t(null);try{let s=e.transaction(Je,o),i=n(s.objectStore(Je));i.onsuccess=()=>t(i.result),i.onerror=()=>t(null),s.onabort=()=>t(null)}catch(s){t(null)}}))}var Rt="myop.d.";function mn(o,n,e){try{localStorage.setItem(Rt+o,JSON.stringify({t:n,e}))}catch(t){}}function Jn(o){try{localStorage.removeItem(Rt+o)}catch(n){}}var Ee=new Map,P={key(o,n,e,t,s){return"".concat(o,"|").concat(n,"|").concat(e,"|").concat(t?"preview":"live","|").concat(s||"raw")},async get(o){let n=Ee.get(o);if(n)return n;let e=await Qe("readonly",t=>t.get(o));return e&&(Ee.set(o,e),mn(o,e.tag,e.storedAt+e.windowMs)),e},async put(o){Ee.set(o.key,o),mn(o.key,o.tag,o.storedAt+o.windowMs),await Qe("readwrite",n=>n.put(o))},async drop(o){Ee.delete(o),Jn(o),await Qe("readwrite",n=>n.delete(o))},fresh(o){return!!o&&Date.now()-o.storedAt<o.windowMs},windowFrom(o){let n=o.get("cache-control")||"";if(/no-store|no-cache/i.test(n))return 0;let e=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!e)return 0;let t=Number(e[1]),s=Number(o.get("age")||0);return Math.max(0,t-(isNaN(s)?0:s))*1e3},async clear(){Ee.clear();try{for(let o=localStorage.length-1;o>=0;o--){let n=localStorage.key(o);n&&n.startsWith(Rt)&&localStorage.removeItem(n)}}catch(o){}await Qe("readwrite",o=>o.clear())}};var fn=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:ae.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:ae.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Xe="__MYOP_CLOUD_REPOSITORY_MAIN__",Xn=()=>{if(typeof window<"u")return window[Xe];if(typeof globalThis<"u")return globalThis[Xe]},Zn=o=>{typeof window<"u"&&(window[Xe]=o),typeof globalThis<"u"&&(globalThis[Xe]=o)},O=class O{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"preloadedComponents",{});r(this,"userFlows",{});r(this,"_defaultEnv","production");r(this,"_envExplicitlySet",!1);r(this,"_staticMode",!1);r(this,"_queryParams",{});r(this,"_delivery",{minify:!1,host:null,cache:!1});r(this,"_deliveryStats",{requests:0,viaDelivery:0,fellBack:0,lastError:null,fromMemory:0,fromStorage:0,fromNetwork:0,revalidations:0,unchanged:0,bytesSaved:0});r(this,"_localServes",new Map);r(this,"_flushBound",!1)}static get Main(){let n=Xn();return n||(O._main||(O._main=new O,Zn(O._main)),O._main)}static sizeOfHeld(n){var e,t,s,i,a;try{return(((a=(i=(s=(t=(e=n==null?void 0:n.config)==null?void 0:e.type)==null?void 0:t.skins)==null?void 0:s[0])==null?void 0:i.loader)==null?void 0:a.HTML)||"").length}catch(p){return 0}}setDelivery(n={}){n.minify!==void 0&&(this._delivery.minify=!!n.minify),n.host!==void 0&&(this._delivery.host=n.host),n.cache!==void 0&&(this._delivery.cache=!!n.cache)}deliveryStats(){var n;return L(h({},this._deliveryStats),{host:(n=this._delivery.host)!=null?n:O.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache})}async refreshDelivery(){await P.clear()}noteLocalServe(n,e){let t=this._localServes.get(n);t?t.count++:this._localServes.set(n,{env:e,count:1}),this.bindFlush()}bindFlush(){if(this._flushBound||typeof document>"u")return;this._flushBound=!0;let n=()=>{document.visibilityState==="hidden"&&this.flushLocalServes()};document.addEventListener("visibilitychange",n),window.addEventListener("pagehide",()=>this.flushLocalServes())}flushLocalServes(){if(!this._localServes.size)return;let n=[...this._localServes.entries()].map(([e,t])=>"".concat(e,":").concat(t.env,":").concat(t.count)).join(",");this._localServes.clear();try{let e="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(e,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(e){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var i;this._localServes.size&&this.flushLocalServes();let e=this.deliveryHost(),t="".concat(e).concat(n);this._deliveryStats.requests++;let s=e!==this._baseUrl;try{let a=await fetch(t);if(a.ok||a.status<500||!s)return s&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(e)}catch(a){if(!s)throw a;this._deliveryStats.lastError=String((i=a==null?void 0:a.message)!=null?i:a)}return this._deliveryStats.fellBack++,console.warn("[myop] delivery host failed (".concat(this._deliveryStats.lastError,") \u2014 falling back to ").concat(this._baseUrl)),await fetch("".concat(this._baseUrl).concat(n))}enableStaticMode(){this._staticMode=!0}setQueryParams(n){this._queryParams=n}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,e,t){return this.fetchComponentV2(n,e,t)}async fetchComponentV2(n,e,t){let{env:s,usePreview:i,cacheKey:a}=this.resolveParams(n,e,t);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:s,usePreview:i,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:s,preview:i}),this.variants[a]=new Promise(async(p,d)=>{try{let c;if(this._staticMode){let N=i?"preview":s;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(N,".json");let v=new URLSearchParams(this._queryParams).toString();v&&(c+="?".concat(v))}else c="/consume?id=".concat(n,"&env=").concat(s),i&&(c+="&preview=true"),this._delivery.minify&&!i&&(c+="&opt=min");let m=this._delivery.cache&&!this._staticMode&&!i,u=m?P.key(this.deliveryHost(),n,s,i,this._delivery.minify?"min":"raw"):"",f=m?await P.get(u):null;if(f&&P.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,s),this.variants[a].resolved=f.config,p(f.config);return}if(f&&f.tag){let N="/consume?ids=".concat(n,"&env=").concat(s)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let v=await this.deliveryFetch(N);if(v.ok){let ee=await v.json();if((ee.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=O.sizeOfHeld(f),f.storedAt=Date.now(),f.windowMs=P.windowFrom(v.headers)||f.windowMs,await P.put(f),this.variants[a].resolved=f.config,p(f.config);return}let j=(ee.items||[])[0];if(j){let H=fn(j);this._deliveryStats.fromNetwork++,await P.put({key:u,config:H,tag:j.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(v.headers),host:this.deliveryHost()}),this.variants[a].resolved=H,p(H);return}}}catch(v){}}let g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){d(new Error('Failed to load component "'.concat(n,'" (').concat(g.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let E=(await g.json()).item;if(!E){d(new Error('Component "'.concat(n,'" not found')));return}if(!E.consume_variant||!E.consume_variant.length){d(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let T=fn(E);this._deliveryStats.fromNetwork++,m&&await P.put({key:u,config:T,tag:E.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(g.headers),host:this.deliveryHost()}),this.variants[a].resolved=T,p(T)}catch(c){delete this.variants[a],d(c)}})),await this.variants[a]}getResolvedConfig(n,e,t){var i;let{cacheKey:s}=this.resolveParams(n,e,t);return((i=this.variants[s])==null?void 0:i.resolved)||null}resolveParams(n,e,t){let s=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;if(!i&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let d=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!d}return{env:a,usePreview:p,cacheKey:"".concat(n,":").concat(a,":").concat(p?"preview":"live")}}hydrateComponent(n,e,t,s){let{env:i,usePreview:a,cacheKey:p}=this.resolveParams(n,t,s),d=Promise.resolve(e);d.resolved=e,this.variants[p]=d,this.preloadedComponents[n]={env:i,preview:a}}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(O,"_main",null),r(O,"DEFAULT_HOST","https://cloud.myop.dev");var Z=O;var Ze=Z.Main;var eo="https://delivery.myop.dev",un=(o={})=>{var e,t;let n=o.minify!==!1||o.cache===!0;return Ze.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,host:o.host!==void 0?o.host:n?eo:null}),_e()},gn=async()=>(await Ze.refreshDelivery(),_e()),_e=()=>Ze.deliveryStats(),yn=()=>(Ze.setDelivery({minify:!1,cache:!1,host:null}),_e());var hn="";var to="<!-- myop-web-component -->",no="myop-web-component",Cn=new Map,bn=[],et,In=async()=>(et||(et=new Te,et.init()),et);function oo(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Q.open?"open":"closed",t=this.attachShadow({mode:e});In().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var so=(o,n,e)=>{customElements.define(o,oo(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},io=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),ro=o=>(o=io(o),o.replace(/_/g,"-"));var tt=class extends V{constructor(){super(...arguments);r(this,"type",A.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p=this.isMyopWebComponent(a.HTML),{mode:d,isolate:c}=await this.resolveRenderMode(e,t,a,p,i);if(d===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(e.id,'"'));if(p){if(d!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(e.id,'"'));return this.loadExtractedWebComponent(e,t,s,a.HTML,i)}let m="myop-comp-".concat(R()),u;if(a.shadowRootMode===Q.localFrame){let f=R(),g="myop-comp-".concat(f),l=document.createElement("iframe");l.id=g,c&&l.setAttribute("sandbox","allow-scripts allow-forms allow-popups"),l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,i);let E=[],T=c?{open(){},writeln(b){E.push(b)},close(){l.srcdoc=E.join("\n")}}:(()=>{let b=l.contentDocument||l.contentWindow.document;return b.open(),b})(),N=null;{let S=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(S)try{N=JSON.parse(S.getAttribute("content")||"{}")}catch(te){}}let v=a.HTML;if(i!=null&&i._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),S=C.getElementById("myop_preview");S==null||S.removeAttribute("type");let te=C.implementation.createHTMLDocument();te.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ne=te.body.firstChild;ne&&C.head&&C.head.insertBefore(C.importNode(ne,!0),C.head.firstChild),v="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((i==null?void 0:i.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),S=C.getElementById("myop_preview");S&&(S.remove(),v="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(i!=null&&i.injectCss){let C=new DOMParser().parseFromString(v,"text/html"),S=C.createElement("style");S.setAttribute("data-myop-injected","true"),S.textContent=i.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(S),v="<!DOCTYPE html>"+C.documentElement.outerHTML}T.writeln(v);let ee='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),j="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";if(c||T.writeln("".concat(ee).concat(j)),!c&&(i==null?void 0:i.data)!==void 0){let b="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",C=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),S='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(C,";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");T.writeln(b+S)}if(c){let b=(i==null?void 0:i.data)!==void 0?JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";T.writeln(this.buildIsolationBridge(b))}T.close();let H=new W(e,t,s,l,i);return c&&H.enableIsolation(),H.sizeMeta=N,H.initiated().then(()=>{if((i==null?void 0:i.autoSize)===!1)return;let b=!1;H.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!b&&!(i!=null&&i.hidden)&&(b=!0,H.show())}})}),H}if(a.shadowRootMode===Q.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,In().then(g=>{g.connectedCallback(u,u)})}else{let f=ro(e.name+t.id);bn.includes(f)||(so(f,a.HTML,a.shadowRootMode),bn.push(f)),u=document.createElement(f)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),u.id=m,i!=null&&i.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),this.appendChild(s,u,i),new de(e,t,s,u,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(to)}async resolveRenderMode(e,t,s,i,a){var m,u,f,g;let p=i?"webComponent":s.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",d=(g=a==null?void 0:a.renderPolicy)!=null?g:(f=(u=(m=window==null?void 0:window.myop)==null?void 0:m.hostSDK)==null?void 0:u.getRenderPolicy)==null?void 0:f.call(u),c=d?await d({componentDefinition:e,skin:t,requestedMode:p,isWebComponent:i}):p;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(e){return"<script>\n (function () {\n var __initial = ".concat(e,";\n var __pending;\n // data-out (cta)\n window.myop_cta_handler = function (action, payload) {\n try { parent.postMessage({ __myop: true, type: 'myop:cta', action: action, payload: payload }, '*'); } catch (e) {}\n };\n function callInit(data) {\n if (typeof window.myop_init_interface === 'function') { window.myop_init_interface(data); return true; }\n return false;\n }\n // data-in (init updates)\n window.addEventListener('message', function (e) {\n var d = e.data;\n if (!d || d.__myop !== true) return;\n if (d.type === 'myop:init') { if (!callInit(d.data)) __pending = d.data; }\n });\n // first render: use a pending update if one arrived, else the baked initial data\n (function flushInitial() {\n var data = (__pending !== undefined) ? __pending : __initial;\n if (data === undefined) return;\n if (callInit(data)) { __pending = undefined; __initial = undefined; }\n else requestAnimationFrame(flushInitial);\n })();\n // resize (report content size)\n function contentHeight() {\n // Measure the BODY (content box). documentElement.scrollHeight includes\n // the iframe viewport \u2014 which we're driving \u2014 so it would report the\n // current frame height, not the content, and never shrink.\n var b = document.body;\n if (b) return Math.max(b.scrollHeight, b.offsetHeight);\n return document.documentElement.scrollHeight;\n }\n function postSize() {\n try {\n parent.postMessage({\n __myop: true, type: 'myop:size',\n height: contentHeight(),\n width: document.documentElement.scrollWidth\n }, '*');\n } catch (e) {}\n }\n // Observe the BODY (reflows with content) \u2014 not documentElement, whose box is\n // the iframe viewport and would feed back into a resize loop. A MutationObserver\n // catches content swaps (e.g. innerHTML re-render) that don't change body's box.\n if (window.ResizeObserver) {\n try { var __ro = new ResizeObserver(postSize); if (document.body) __ro.observe(document.body); } catch (e) {}\n }\n if (window.MutationObserver && document.body) {\n try { new MutationObserver(postSize).observe(document.body, { childList: true, subtree: true, attributes: true, characterData: true }); } catch (e) {}\n }\n window.addEventListener('load', postSize);\n postSize();\n })();\n <\/script>")}extractWebComponentScript(e){let i=new DOMParser().parseFromString(e,"text/html").getElementById(no);return(i==null?void 0:i.textContent)||null}executeWebComponentScript(e,t){let s=Cn.get(t);if(s)return console.log("[MyopWebComponent] Script already executed for ".concat(t,", reusing <").concat(s,">")),s;let i=document.createElement("script");i.textContent=e,i.id="myop-extracted-".concat(t),document.head.appendChild(i);let a=window.__MYOP_TAG_NAME__;return a&&Cn.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,s,i,a){let p=this.extractWebComponentScript(i);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),c=this.executeWebComponentScript(p,d);if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");let m="myop-comp-".concat(R()),u=document.createElement(c);u.id=m,a!=null&&a.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,u,a);let f=new X(e,t,s,u,c,a);return(a==null?void 0:a.data)!==void 0&&f.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),f}};var wn=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=dt(t);switch(s){case"component":{let[a,p]=i,d=await Z.Main.fetchComponent(a);if(d&&d.type.skins.find(m=>m.id===p))return d.instance.skinSelector={type:J.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=dt(t),c=(await Z.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===J.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(u=>u.id===p);if((m==null?void 0:m.type)===ze.Segment){let u=m,g=c.instance.skinSelector.segments.find(l=>l.segmentId===u.segment.id);if(g)return c.instance.skinSelector=g==null?void 0:g.skinSelector,c}}}break}}}finally{return null}};var xn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",q=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"_renderPolicy");r(this,"setRenderPolicy",n=>{this._renderPolicy=n});r(this,"getRenderPolicy",()=>this._renderPolicy);r(this,"initiated",!1);r(this,"version",ln);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"isTrustedSource",n=>{if(!n||n===window)return!0;let e=t=>{let s=t.element;return(s==null?void 0:s.nodeName)==="IFRAME"&&s.contentWindow===n};return this.components.some(e)||this.components2init.some(e)});r(this,"incomingMessageHandler",n=>{var e;if((e=n.data)!=null&&e.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==_.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){let i=this.components2init.filter(p=>{let d=p.element;return(d==null?void 0:d.nodeName)==="IFRAME"&&d.contentWindow===n.source});(i.length?i:this.components2init).forEach(p=>{p.send(new Y(p.id))});return}if(t.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==t.content.id);let i=this.components.find(a=>{var p;return a.id===((p=t.content)==null?void 0:p.id)});i==null||i.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let i=t,a=this.components.find(p=>p.id===i.destination);if(a){if(i.direction===_.down){i.message.messageType===D.name?a.onMessageReceived(i.message):(i.message.route=i.route,a.send(i.message));return}}else{let p=this.components.find(d=>d.id===i.message.destination);p&&p.send(i.message)}return}let s=this.components.find(i=>i.id===t.destination);if(!s){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(s){if(s.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let e=[new je,new Ge,new tt];this.componentsLoaders=[...e],n&&this._registerLoaders(n),window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_registerLoaders",n=>{let e={};n.forEach(t=>{let s=new t(this.componentsLoaders);e[s.type]=s}),this.componentsLoaders.forEach(t=>{e[t.type]||(e[t.type]=t)}),this.componentsLoaders=Object.values(e)});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case J.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case J.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(g=>g.type===ze.Segment?g.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let u=c.segment,f=(t||{})[u.function];return f?await f():(console.warn("segmentId:".concat(d.segmentId,", ").concat(u.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var m,u,f,g;if(!e){debugger;throw new Error("no container was found for this component")}let s=await wn(n);s&&(n=s);let i=h(h({},(m=this.loaderHooks)!=null?m:{}),(u=t==null?void 0:t.hooks)!=null?u:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,i);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(l=await t.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:J.Dedicated,skin:l},t&&(t=h({},t),delete t.hooks),await Et(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(l=>l.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),c.isInitiated||c.send(new Y(c.id)),(!t||t.connectProps!==!1)&&(c=cn(c,n.type.props,p));try{await _t(c,n,this.components)}catch(l){throw l}return t!=null&&t.skipInit||await c.initiated(),c});r(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};r(q,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:xn});if(!window.myop.hostSDK){let o=new q;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:xn}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>un(n);o.stats=_e,o.off=yn,o.refresh=gn,window.myop.delivery=o}var ao=window.myop.hostSDK;Ue("hostSDK",ao);var nt=class extends I{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(F.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=q.Instance(),d=p.components.find(f=>f.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let m=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),u=[];Object.keys(m.refs).forEach(f=>{let g=m.refs[f];g=g.__nonProxied||g,g.componentDefinition&&u.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),s(new ie(e.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new ie(e.handlerUniqueId,[],!0));debugger}})().then()})}};var vn=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=K,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var ot=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{vn(e,a=>{s(new fe(e.handlerUniqueId,a))},t)})}};var Sn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(F.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Sn(i),required:i.required,validity:K(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},st=class extends I{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{B(e.ref,t.shadowRoot).forEach(a=>{s(new ge(Sn(a)),e)})})}};var it=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Te=class extends Pe{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener($e.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===y.InitMessage){let p=a.content.id;this.components[p].context=new Ke(e,t)}}}),setTimeout(()=>{this.messageToHost(new he)},1)});r(this,"messageToHost",(e,t)=>{e.direction=_.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Fe(this.messageToHost,this.components),new it(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new We(this.messageToHost,this.components),new qe(this.messageToHost,this.components),new Ve(this.messageToHost,this.components),new ot(this.messageToHost,this.components),new st(this.messageToHost,this.components),new nt(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Ue("WebComponentSDK",Te);export{Te as WebComponentSDK};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var jt=Object.defineProperty,On=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Vt=Object.getOwnPropertySymbols;var $n=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var at=(o,n,e)=>n in o?jt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))$n.call(n,e)&&at(o,e,n[e]);if(Vt)for(var e of Vt(n))An.call(n,e)&&at(o,e,n[e]);return o},L=(o,n)=>On(o,zn(n));var Fn=(o,n)=>{for(var e in n)jt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>at(o,typeof n!="symbol"?n+"":n,e);var De="__federation__",Gt="onLoad";var Be=(o,n)=>{window[De]&&window[De][o]&&window[De][o][Gt]&&window[De][o][Gt]({[o]:n})};var y={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var Le={};Fn(Le,{AddEventListenerMessage:()=>mt,BaseMyopMessage:()=>M,BindClickMessage:()=>ct,ChangeTextMessage:()=>lt,CleanupMessage:()=>Ie,CleanupReplayMessage:()=>we,ClickReplayMessage:()=>me,CreateRefComponentMessage:()=>Me,CustomRefMessage:()=>G,DetectMyopRefsMessage:()=>yt,DetectedMyopRefsMessage:()=>be,DisposeMessage:()=>xe,ElementValueReplayMessage:()=>ge,EnvelopedMessage:()=>Ce,EventListenerCallbackMessage:()=>ue,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>fe,GetAttributeMessage:()=>ht,GetAttributeReplayMessage:()=>Mt,GetElementValueMessage:()=>ut,InitMessage:()=>Y,InitRequest:()=>he,InitResponse:()=>ye,MessageDirection:()=>_,MutationObserverMessage:()=>bt,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>dt,Ref:()=>U,RefComponentCreatedMessage:()=>ie,ResizeObserverMessage:()=>It,SetAttributeMessage:()=>ft,SetInnerHtml:()=>gt,SetMutationObserverMessage:()=>Ct,SetResizeObserverMessage:()=>ve,stripFunction:()=>Xt});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Kn=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Wn=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var pt=o=>{let n=Wn(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(Kn(n.slice(t,t+16)));return e};var Yt=o=>new Promise(n=>setTimeout(n,o));var _=class{};r(_,"down","down"),r(_,"up","up");var M=class{constructor(){r(this,"id",R());r(this,"myop",!0);r(this,"content");r(this,"source");r(this,"destination");r(this,"route");r(this,"ref");r(this,"direction");r(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},dt=class extends M{constructor(e){super();this.ref=e}},w=class extends M{constructor(e){super();this.replayToHandler=e}},x=class extends M{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",R())}},U=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=L(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var Qt="ClickReplayMessage",ct=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Qt);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},me=class extends w{constructor(){super(...arguments);r(this,"messageType",Qt)}};var lt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Jt="ExecuteScriptReplyMessage",Nn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Un=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xt=o=>{let n=o.match(Nn);if(n)return n[1]||n[3];{let e=o.match(Un);if(e)return e[1].trim()}},k=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Jt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Xt(this.content)}};r(k,"replierKey","send"),r(k,"completeStreamKey","completeStream");var fe=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Jt)}};var G=class extends k{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=L(h({},t),{_script:e.toString()})}};var Zt="EventListenerCallbackMessage",mt=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Zt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},ue=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Zt);this.content={e:t}}};var ft=class extends M{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var en="ElementValueReplayMessage",ut=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",en);r(this,"messageType","GetElementValueMessage")}},ge=class extends w{constructor(e){super();this.content=e;r(this,"messageType",en)}};var gt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var Y=class extends M{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ye=class extends Y{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},he=class extends M{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var tn="RefComponentCreatedMessage",Me=class extends x{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",tn);r(this,"messageType","CreateRefComponentMessage")}},ie=class extends w{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",tn)}};var Ce=class extends M{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var nn="DetectedMyopRefsMessage",yt=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",nn)}},be=class extends w{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",nn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var on="GetAttributeReplayMessage",ht=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",on);r(this,"messageType","GetAttributeMessage")}},Mt=class extends w{constructor(e){super();this.content=e;r(this,"messageType",on)}};var D=class extends M{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ct=class extends M{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},bt=class extends M{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var sn="CleanupReplayMessage",Ie=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",sn);r(this,"messageType","CleanupMessage")}},we=class extends w{constructor(e){super();this.customCleanup=e;r(this,"messageType",sn)}};var xe=class extends M{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ve=class extends M{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},It=class extends M{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var z=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||q.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&(this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id)),this.dispose())},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===y.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=_.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=_.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Ie(n.id,t=>{})),e&&e()}:()=>{}}runDisposeHandlers(){let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)})}dispose(){if(this.markedForDisposed=!0,!this.isInitiated){this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed";return}console.log("disposing component",this.id),this.send(new xe),this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Pe=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var rn=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},wt=class{constructor(n){this.messageToHost=n}},Oe=class extends wt{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var xt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},ze=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==_.down)return;if(t.messageType===y.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===y.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new xt(s),this.messageToHost(new ye(s));return}if(t.messageType===y.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new we(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],rn(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var A={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var Q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ae={message:"message",code:"code"},re=class{};r(re,"code","code"),r(re,"component","component");var J={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ae={Segment:"Segment",Promo:"Promo",AB:"AB"},$e=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var vt=o=>o!==Object(o),qn=o=>typeof o=="function",St=o=>{if(vt(o))return!0;if(qn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!St(e))return!1}else{if(vt(e))continue;return!1}}return!0},F=(o,n={},e=!0,t=new WeakMap)=>{if(vt(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=F(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=F(o[i],!0,e,t)):typeof a=="object"&&(s[i]=F(o[i],a,e,t)))}return s}return{}};var an={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var Se=class extends z{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new Ce(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var X=class extends z{constructor(e,t,s,i,a,p){super(e,s,p);this.container=s;this.customElement=i;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",e=>{let t=e.detail;t!=null&&t.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}))});r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=pe(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}};var Vn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},pe=(o,n,e,t,s,i)=>{let a=Vn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},pn=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),dn=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},cn=(o,n,e)=>{let t=n.reduce((i,a)=>L(h({},i),{[a.name]:h({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(pn(p,a,o))return!1;if(p.behavior.type===ae.code){if(o instanceof X)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(o instanceof K&&o.isolated)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Q.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return dn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(U.create(p.behavior.ref)),c.push(u=>{d(u)}),p.behavior.params&&c.push(...p.behavior.params);let m=Le[p.behavior.message];o.send(new m(...c))}):null},set:(i,a,p)=>{let d=t[a];if(pn(d,a,o))return!1;if(d.behavior.type===ae.code){if(o instanceof X){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(o instanceof K&&o.isolated){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Q.localFrame){let m=d.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=p,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.forEach(l=>{o.markedForDisposed||p(l.action,l.payload)})}return!0}return dn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(U.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let m=Le[d.behavior.message];return o.send(new m(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},jn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{St(p)||an.notSerializableRefCall(t,p)}),n.send(new G(({ref:p,propName:d,functionArgs:c,makeSerializable:m})=>{if(p){let u=p[d];return m(typeof u=="function"?p[d](...c):u,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new G(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),Et=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new Se(n.type,s,t);e.push(p);let d=()=>{let m=e.indexOf(p);m!==-1&&e.splice(m,1)};await s.initiated();let c=setTimeout(()=>{d(),a("timeout")},5e3);s.send(new Me(o.refConfig,n,L(h({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){d(),a("CreateRefComponentMessage failed");return}let u=e.find(f=>f.id==p.id);if(u&&u!==p){d(),s.refs[o.refConfig.name]=u,i(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(E=>E.type.id===f.componentDefinitionId).type,l=new Se(g,p);l.setInitiated(),p.refs[f.refName]=l,e.push(l)});try{await _t(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},_t=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var d;if(i.behavior.type==re.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=U.create("",i,o);try{let f=await Et(u,m,e);o.refs[i.name]=f,a()}catch(f){p(f)}}else try{let c=U.create("",i,o);o.refs[i.name]=jn(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(i){throw i}};var K=class extends z{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"isolated",!1);r(this,"_lastData");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_isoMsgHandler");r(this,"_isoSizeOpts");r(this,"_isoAutoSize",!1);r(this,"_isoLastSize");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new k(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this.isolated)return this._isoSizeOpts=e,this._isoAutoSize=!0,this._isoLastSize&&this._applyIsoSize(this._isoLastSize.height,this._isoLastSize.width),()=>{this._isoAutoSize=!1,this._isoSizeOpts=void 0};if(this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return this.observeHeightViaBridge();let i=(g,l,E)=>l!==void 0&&g<l?l:E!==void 0&&g>E?E:g,a=g=>{if(g===void 0)return;if(typeof g=="number")return g;let l=parseFloat(g);return isNaN(l)?void 0:l},p=()=>{var Ot,zt,$t,At,Ft,Kt,Wt,Nt;let g=t.contentDocument;if(!g)return;let l=this._autoSizeOptions,E=a(l==null?void 0:l.minWidth),T=a(l==null?void 0:l.maxWidth),N=a(l==null?void 0:l.minHeight),v=a(l==null?void 0:l.maxHeight),ee=(Ot=l==null?void 0:l.loaderMinHeight)!=null?Ot:50,j=((zt=this.sizeMeta)==null?void 0:zt.width)==="100%"?"100%":void 0,H=(($t=this.sizeMeta)==null?void 0:$t.height)==="100%"?"100%":void 0,b=(Ft=(At=l==null?void 0:l.explicitWidth)!=null?At:j)!=null?Ft:"100%",C=(Kt=l==null?void 0:l.explicitHeight)!=null?Kt:H,S=b!==void 0,te=C!==void 0,ne=this.container.getBoundingClientRect(),En=ne.width===0,_n=ne.height===0||ne.height===ee,oe=(l!=null&&l.forceAutoSize||En)&&!S,se=(l!=null&&l.forceAutoSize||_n)&&!te;if(!oe&&!se){t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(Wt=l==null?void 0:l.onSizeChange)==null||Wt.call(l,{width:typeof b=="number"?b:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let Tn=t.style.transition,$=this.container,Rn=$.style.transition;t.style.transition="none",$.style.transition="none";let kt=t.getBoundingClientRect().height,Ht=t.getBoundingClientRect().width,Dt=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),Bt=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),ce=Bt,le=Dt,kn=se&&Dt>kt+1,Hn=oe&&Bt>Ht+1,Re=se&&!kn,ke=oe&&!Hn;if(Re||ke){let Ln=$.style.minHeight,Pn=$.style.minWidth;Re&&($.style.minHeight="".concat(kt,"px")),ke&&($.style.minWidth="".concat(Ht,"px")),Re&&(t.style.height="0px"),ke&&(t.style.width="0px"),ce=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height));let Ut=Re&&le<2,qt=ke&&ce<2;if(Ut||qt){let He=g.createElement("style");He.id="__myop_measure";let rt=[];Ut&&rt.push("height: auto !important","min-height: 0 !important","max-height: none !important"),qt&&rt.push("width: auto !important","min-width: 0 !important","max-width: none !important"),He.textContent="*, *::before, *::after { ".concat(rt.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),g.head.appendChild(He),ce=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),He.remove()}$.style.minHeight=Ln,$.style.minWidth=Pn}let Lt=i(ce,E,T),Pt=i(le,N,v);oe?t.style.width="".concat(Lt,"px"):t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",se?t.style.height="".concat(Pt,"px"):t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",t.offsetHeight,t.style.transition=Tn,$.style.transition=Rn;let Dn=oe&&T!==void 0&&ce>T,Bn=se&&v!==void 0&&le>v;g.documentElement.style.overflowX=Dn?"auto":"",g.documentElement.style.overflowY=Bn?"auto":"",(Nt=l==null?void 0:l.onSizeChange)==null||Nt.call(l,{width:Lt,height:Pt,autoSizingWidth:oe,autoSizingHeight:se})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},m=new ResizeObserver(()=>c());m.observe(s.body),m.observe(s.documentElement);let u=new MutationObserver(()=>c());u.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{m.disconnect(),u.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});r(this,"_bridgeSizeCleanup");r(this,"observeHeightViaBridge",()=>{if(this._bridgeSizeCleanup)return this._bridgeSizeCleanup;let e,t=!1,s=()=>{t=!0,e==null||e(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=s,this.initiated().then(()=>{t||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),e=this.send(new ve))}).catch(i=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(i))}),s});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new k(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new k(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=h({},e);if(t.messageType===y.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=_.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(this,"dispose",()=>{var e,t;(e=this._bridgeSizeCleanup)==null||e.call(this),this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this._isoMsgHandler&&(window.removeEventListener("message",this._isoMsgHandler),this._isoMsgHandler=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),(t=this.IframeElement.parentNode)==null||t.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=e=>{if(e.source!==this.IframeElement.contentWindow)return;let t=e.data;!t||t.__myop!==!0||(t.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}):t.type==="myop:size"&&this._applyIsoSize(t.height,t.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(e){var t,s;this._lastData=e,(s=(t=this.IframeElement)==null?void 0:t.contentWindow)==null||s.postMessage({__myop:!0,type:"myop:init",data:e},"*")}getData(){return this._lastData}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}_applyIsoSize(e,t){var c;if(!e||Number.isNaN(e)||(this._isoLastSize={height:e,width:t},!this._isoAutoSize))return;let s=this._isoSizeOpts,i=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),a=i(s==null?void 0:s.minHeight),p=i(s==null?void 0:s.maxHeight),d=e;a!==void 0&&d<a&&(d=a),p!==void 0&&d>p&&(d=p),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=d+"px",this.IframeElement.style.width="100%",(c=s==null?void 0:s.onSizeChange)==null||c.call(s,{width:t!=null?t:this.IframeElement.clientWidth,height:d,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=pe(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===y.In.MutationObserverMessage||e.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var V=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var Gn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Fe=class extends V{constructor(){super(...arguments);r(this,"type",A.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=R(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;let u="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=u,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=t.loader.url;i!=null&&i._hasParent&&(f=Gn(f,"_myop-comp",c)),a.src=f,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}let d=new K(e,t,s,a,i);return p.autoHeight&&(i==null?void 0:i.autoSize)!==!1&&d.observeHeightViaBridge(),d})}};var Ke={webcomponent_message_key:"myop_webcomponent_message"};var de=class extends z{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),s=super.send(t),i=new CustomEvent(Ke.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=pe(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var Tt={},We=class extends V{constructor(){super(...arguments);r(this,"type",A.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;Tt[a.url]?console.log("Module alreday loaded or in loading process"):Tt[a.url]=new Promise((c,m)=>{let u=a.url,f=document.createElement("script");f.type="module",f.src=u,f.onload=()=>{c()},f.onerror=()=>{m()},document.head.appendChild(f)}),await Tt[a.url],await Yt(1);let p="myop-comp-".concat(R()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new de(e,t,s,d,i)})}};var ln="0.4.0-beta.3";var Yn="myop-delivery",qe="components";var Ne=null;function Qn(){return Ne||(Ne=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(Yn,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(qe)||e.createObjectStore(qe,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),Ne)}function Ue(o,n){return Qn().then(e=>new Promise(t=>{if(!e)return t(null);try{let s=e.transaction(qe,o),i=n(s.objectStore(qe));i.onsuccess=()=>t(i.result),i.onerror=()=>t(null),s.onabort=()=>t(null)}catch(s){t(null)}}))}var Rt="myop.d.";function mn(o,n,e){try{localStorage.setItem(Rt+o,JSON.stringify({t:n,e}))}catch(t){}}function Jn(o){try{localStorage.removeItem(Rt+o)}catch(n){}}var Ee=new Map,P={key(o,n,e,t,s){return"".concat(o,"|").concat(n,"|").concat(e,"|").concat(t?"preview":"live","|").concat(s||"raw")},async get(o){let n=Ee.get(o);if(n)return n;let e=await Ue("readonly",t=>t.get(o));return e&&(Ee.set(o,e),mn(o,e.tag,e.storedAt+e.windowMs)),e},async put(o){Ee.set(o.key,o),mn(o.key,o.tag,o.storedAt+o.windowMs),await Ue("readwrite",n=>n.put(o))},async drop(o){Ee.delete(o),Jn(o),await Ue("readwrite",n=>n.delete(o))},fresh(o){return!!o&&Date.now()-o.storedAt<o.windowMs},windowFrom(o){let n=o.get("cache-control")||"";if(/no-store|no-cache/i.test(n))return 0;let e=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!e)return 0;let t=Number(e[1]),s=Number(o.get("age")||0);return Math.max(0,t-(isNaN(s)?0:s))*1e3},async clear(){Ee.clear();try{for(let o=localStorage.length-1;o>=0;o--){let n=localStorage.key(o);n&&n.startsWith(Rt)&&localStorage.removeItem(n)}}catch(o){}await Ue("readwrite",o=>o.clear())}};var fn=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:ae.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:ae.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Ve="__MYOP_CLOUD_REPOSITORY_MAIN__",Xn=()=>{if(typeof window<"u")return window[Ve];if(typeof globalThis<"u")return globalThis[Ve]},Zn=o=>{typeof window<"u"&&(window[Ve]=o),typeof globalThis<"u"&&(globalThis[Ve]=o)},O=class O{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"preloadedComponents",{});r(this,"userFlows",{});r(this,"_defaultEnv","production");r(this,"_envExplicitlySet",!1);r(this,"_staticMode",!1);r(this,"_queryParams",{});r(this,"_delivery",{minify:!1,host:null,cache:!1});r(this,"_deliveryStats",{requests:0,viaDelivery:0,fellBack:0,lastError:null,fromMemory:0,fromStorage:0,fromNetwork:0,revalidations:0,unchanged:0,bytesSaved:0});r(this,"_localServes",new Map);r(this,"_flushBound",!1)}static get Main(){let n=Xn();return n||(O._main||(O._main=new O,Zn(O._main)),O._main)}static sizeOfHeld(n){var e,t,s,i,a;try{return(((a=(i=(s=(t=(e=n==null?void 0:n.config)==null?void 0:e.type)==null?void 0:t.skins)==null?void 0:s[0])==null?void 0:i.loader)==null?void 0:a.HTML)||"").length}catch(p){return 0}}setDelivery(n={}){n.minify!==void 0&&(this._delivery.minify=!!n.minify),n.host!==void 0&&(this._delivery.host=n.host),n.cache!==void 0&&(this._delivery.cache=!!n.cache)}deliveryStats(){var n;return L(h({},this._deliveryStats),{host:(n=this._delivery.host)!=null?n:O.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache})}async refreshDelivery(){await P.clear()}noteLocalServe(n,e){let t=this._localServes.get(n);t?t.count++:this._localServes.set(n,{env:e,count:1}),this.bindFlush()}bindFlush(){if(this._flushBound||typeof document>"u")return;this._flushBound=!0;let n=()=>{document.visibilityState==="hidden"&&this.flushLocalServes()};document.addEventListener("visibilitychange",n),window.addEventListener("pagehide",()=>this.flushLocalServes())}flushLocalServes(){if(!this._localServes.size)return;let n=[...this._localServes.entries()].map(([e,t])=>"".concat(e,":").concat(t.env,":").concat(t.count)).join(",");this._localServes.clear();try{let e="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(e,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(e){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var i;this._localServes.size&&this.flushLocalServes();let e=this.deliveryHost(),t="".concat(e).concat(n);this._deliveryStats.requests++;let s=e!==this._baseUrl;try{let a=await fetch(t);if(a.ok||a.status<500||!s)return s&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(e)}catch(a){if(!s)throw a;this._deliveryStats.lastError=String((i=a==null?void 0:a.message)!=null?i:a)}return this._deliveryStats.fellBack++,console.warn("[myop] delivery host failed (".concat(this._deliveryStats.lastError,") \u2014 falling back to ").concat(this._baseUrl)),await fetch("".concat(this._baseUrl).concat(n))}enableStaticMode(){this._staticMode=!0}setQueryParams(n){this._queryParams=n}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,e,t){return this.fetchComponentV2(n,e,t)}async fetchComponentV2(n,e,t){let{env:s,usePreview:i,cacheKey:a}=this.resolveParams(n,e,t);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:s,usePreview:i,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:s,preview:i}),this.variants[a]=new Promise(async(p,d)=>{try{let c;if(this._staticMode){let N=i?"preview":s;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(N,".json");let v=new URLSearchParams(this._queryParams).toString();v&&(c+="?".concat(v))}else c="/consume?id=".concat(n,"&env=").concat(s),i&&(c+="&preview=true"),this._delivery.minify&&!i&&(c+="&opt=min");let m=this._delivery.cache&&!this._staticMode&&!i,u=m?P.key(this.deliveryHost(),n,s,i,this._delivery.minify?"min":"raw"):"",f=m?await P.get(u):null;if(f&&P.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,s),this.variants[a].resolved=f.config,p(f.config);return}if(f&&f.tag){let N="/consume?ids=".concat(n,"&env=").concat(s)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let v=await this.deliveryFetch(N);if(v.ok){let ee=await v.json();if((ee.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=O.sizeOfHeld(f),f.storedAt=Date.now(),f.windowMs=P.windowFrom(v.headers)||f.windowMs,await P.put(f),this.variants[a].resolved=f.config,p(f.config);return}let j=(ee.items||[])[0];if(j){let H=fn(j);this._deliveryStats.fromNetwork++,await P.put({key:u,config:H,tag:j.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(v.headers),host:this.deliveryHost()}),this.variants[a].resolved=H,p(H);return}}}catch(v){}}let g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){d(new Error('Failed to load component "'.concat(n,'" (').concat(g.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let E=(await g.json()).item;if(!E){d(new Error('Component "'.concat(n,'" not found')));return}if(!E.consume_variant||!E.consume_variant.length){d(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let T=fn(E);this._deliveryStats.fromNetwork++,m&&await P.put({key:u,config:T,tag:E.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(g.headers),host:this.deliveryHost()}),this.variants[a].resolved=T,p(T)}catch(c){delete this.variants[a],d(c)}})),await this.variants[a]}getResolvedConfig(n,e,t){var i;let{cacheKey:s}=this.resolveParams(n,e,t);return((i=this.variants[s])==null?void 0:i.resolved)||null}resolveParams(n,e,t){let s=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;if(!i&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let d=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!d}return{env:a,usePreview:p,cacheKey:"".concat(n,":").concat(a,":").concat(p?"preview":"live")}}hydrateComponent(n,e,t,s){let{env:i,usePreview:a,cacheKey:p}=this.resolveParams(n,t,s),d=Promise.resolve(e);d.resolved=e,this.variants[p]=d,this.preloadedComponents[n]={env:i,preview:a}}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(O,"_main",null),r(O,"DEFAULT_HOST","https://cloud.myop.dev");var Z=O;var je=Z.Main;var eo="https://delivery.myop.dev",un=(o={})=>{var e,t;let n=o.minify!==!1||o.cache===!0;return je.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,host:o.host!==void 0?o.host:n?eo:null}),_e()},gn=async()=>(await je.refreshDelivery(),_e()),_e=()=>je.deliveryStats(),yn=()=>(je.setDelivery({minify:!1,cache:!1,host:null}),_e());var I=class extends Oe{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(L(h({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var W={id:"myop-id"};var B=(o,n)=>n.querySelectorAll("[".concat(W.id,"='").concat(o.refConfig.selector,"']"));var Ge=class extends I{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=B(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new me(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Ye=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Qe=class extends $e{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Je=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(W.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(W.id);p&&i.push(new Pe(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new be(e.handlerUniqueId,i))});r(this,"messageType",y.DetectMyopRefsMessage)}};var Xe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var Ze=class extends I{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=B(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{s(new ue(e.handlerUniqueId,F(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var et=class extends I{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(W.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=q.Instance(),d=p.components.find(f=>f.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let m=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),u=[];Object.keys(m.refs).forEach(f=>{let g=m.refs[f];g=g.__nonProxied||g,g.componentDefinition&&u.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),s(new ie(e.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new ie(e.handlerUniqueId,[],!0));debugger}})().then()})}};var hn=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=F,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var tt=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{hn(e,a=>{s(new fe(e.handlerUniqueId,a))},t)})}};var Mn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(W.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Mn(i),required:i.required,validity:F(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},nt=class extends I{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{B(e.ref,t.shadowRoot).forEach(a=>{s(new ge(Mn(a)),e)})})}};var ot=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Te=class extends ze{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Ke.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===y.InitMessage){let p=a.content.id;this.components[p].context=new Qe(e,t)}}}),setTimeout(()=>{this.messageToHost(new he)},1)});r(this,"messageToHost",(e,t)=>{e.direction=_.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Ye(this.messageToHost,this.components),new ot(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new Je(this.messageToHost,this.components),new Xe(this.messageToHost,this.components),new Ze(this.messageToHost,this.components),new tt(this.messageToHost,this.components),new nt(this.messageToHost,this.components),new et(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Be("WebComponentSDK",Te);var Cn="";var to="<!-- myop-web-component -->",no="myop-web-component",In=new Map,wn=[],st,xn=async()=>(st||(st=new Te,st.init()),st);function oo(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Q.open?"open":"closed",t=this.attachShadow({mode:e});xn().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var so=(o,n,e)=>{customElements.define(o,oo(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},io=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),ro=o=>(o=io(o),o.replace(/_/g,"-"));var it=class extends V{constructor(){super(...arguments);r(this,"type",A.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p=this.isMyopWebComponent(a.HTML),{mode:d,isolate:c}=await this.resolveRenderMode(e,t,a,p,i);if(d===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(e.id,'"'));if(p){if(d!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(e.id,'"'));return this.loadExtractedWebComponent(e,t,s,a.HTML,i)}let m="myop-comp-".concat(R()),u;if(a.shadowRootMode===Q.localFrame){let f=R(),g="myop-comp-".concat(f),l=document.createElement("iframe");l.id=g,c&&l.setAttribute("sandbox","allow-scripts allow-forms allow-popups"),l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,i);let E=[],T=c?{open(){},writeln(b){E.push(b)},close(){l.srcdoc=E.join("\n")}}:(()=>{let b=l.contentDocument||l.contentWindow.document;return b.open(),b})(),N=null;{let S=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(S)try{N=JSON.parse(S.getAttribute("content")||"{}")}catch(te){}}let v=a.HTML;if(i!=null&&i._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),S=C.getElementById("myop_preview");S==null||S.removeAttribute("type");let te=C.implementation.createHTMLDocument();te.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ne=te.body.firstChild;ne&&C.head&&C.head.insertBefore(C.importNode(ne,!0),C.head.firstChild),v="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((i==null?void 0:i.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),S=C.getElementById("myop_preview");S&&(S.remove(),v="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(i!=null&&i.injectCss){let C=new DOMParser().parseFromString(v,"text/html"),S=C.createElement("style");S.setAttribute("data-myop-injected","true"),S.textContent=i.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(S),v="<!DOCTYPE html>"+C.documentElement.outerHTML}T.writeln(v);let ee='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),j="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";if(c||T.writeln("".concat(ee).concat(j)),!c&&(i==null?void 0:i.data)!==void 0){let b="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",C=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),S='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(C,";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");T.writeln(b+S)}if(c){let b=(i==null?void 0:i.data)!==void 0?JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";T.writeln(this.buildIsolationBridge(b))}T.close();let H=new K(e,t,s,l,i);return c&&H.enableIsolation(),H.sizeMeta=N,H.initiated().then(()=>{if((i==null?void 0:i.autoSize)===!1)return;let b=!1;H.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!b&&!(i!=null&&i.hidden)&&(b=!0,H.show())}})}),H}if(a.shadowRootMode===Q.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,xn().then(g=>{g.connectedCallback(u,u)})}else{let f=ro(e.name+t.id);wn.includes(f)||(so(f,a.HTML,a.shadowRootMode),wn.push(f)),u=document.createElement(f)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),u.id=m,i!=null&&i.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),this.appendChild(s,u,i),new de(e,t,s,u,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(to)}async resolveRenderMode(e,t,s,i,a){var m,u,f,g;let p=i?"webComponent":s.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",d=(g=a==null?void 0:a.renderPolicy)!=null?g:(f=(u=(m=window==null?void 0:window.myop)==null?void 0:m.hostSDK)==null?void 0:u.getRenderPolicy)==null?void 0:f.call(u),c=d?await d({componentDefinition:e,skin:t,requestedMode:p,isWebComponent:i}):p;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(e){return"<script>\n (function () {\n var __initial = ".concat(e,";\n var __pending;\n // data-out (cta)\n window.myop_cta_handler = function (action, payload) {\n try { parent.postMessage({ __myop: true, type: 'myop:cta', action: action, payload: payload }, '*'); } catch (e) {}\n };\n function callInit(data) {\n if (typeof window.myop_init_interface === 'function') { window.myop_init_interface(data); return true; }\n return false;\n }\n // data-in (init updates)\n window.addEventListener('message', function (e) {\n var d = e.data;\n if (!d || d.__myop !== true) return;\n if (d.type === 'myop:init') { if (!callInit(d.data)) __pending = d.data; }\n });\n // first render: use a pending update if one arrived, else the baked initial data\n (function flushInitial() {\n var data = (__pending !== undefined) ? __pending : __initial;\n if (data === undefined) return;\n if (callInit(data)) { __pending = undefined; __initial = undefined; }\n else requestAnimationFrame(flushInitial);\n })();\n // resize (report content size)\n function contentHeight() {\n // Measure the BODY (content box). documentElement.scrollHeight includes\n // the iframe viewport \u2014 which we're driving \u2014 so it would report the\n // current frame height, not the content, and never shrink.\n var b = document.body;\n if (b) return Math.max(b.scrollHeight, b.offsetHeight);\n return document.documentElement.scrollHeight;\n }\n function postSize() {\n try {\n parent.postMessage({\n __myop: true, type: 'myop:size',\n height: contentHeight(),\n width: document.documentElement.scrollWidth\n }, '*');\n } catch (e) {}\n }\n // Observe the BODY (reflows with content) \u2014 not documentElement, whose box is\n // the iframe viewport and would feed back into a resize loop. A MutationObserver\n // catches content swaps (e.g. innerHTML re-render) that don't change body's box.\n if (window.ResizeObserver) {\n try { var __ro = new ResizeObserver(postSize); if (document.body) __ro.observe(document.body); } catch (e) {}\n }\n if (window.MutationObserver && document.body) {\n try { new MutationObserver(postSize).observe(document.body, { childList: true, subtree: true, attributes: true, characterData: true }); } catch (e) {}\n }\n window.addEventListener('load', postSize);\n postSize();\n })();\n <\/script>")}extractWebComponentScript(e){let i=new DOMParser().parseFromString(e,"text/html").getElementById(no);return(i==null?void 0:i.textContent)||null}executeWebComponentScript(e,t){let s=In.get(t);if(s)return console.log("[MyopWebComponent] Script already executed for ".concat(t,", reusing <").concat(s,">")),s;let i=document.createElement("script");i.textContent=e,i.id="myop-extracted-".concat(t),document.head.appendChild(i);let a=window.__MYOP_TAG_NAME__;return a&&In.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,s,i,a){let p=this.extractWebComponentScript(i);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),c=this.executeWebComponentScript(p,d);if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");let m="myop-comp-".concat(R()),u=document.createElement(c);u.id=m,a!=null&&a.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,u,a);let f=new X(e,t,s,u,c,a);return(a==null?void 0:a.data)!==void 0&&f.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),f}};var vn=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=pt(t);switch(s){case"component":{let[a,p]=i,d=await Z.Main.fetchComponent(a);if(d&&d.type.skins.find(m=>m.id===p))return d.instance.skinSelector={type:J.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=pt(t),c=(await Z.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===J.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(u=>u.id===p);if((m==null?void 0:m.type)===Ae.Segment){let u=m,g=c.instance.skinSelector.segments.find(l=>l.segmentId===u.segment.id);if(g)return c.instance.skinSelector=g==null?void 0:g.skinSelector,c}}}break}}}finally{return null}};var Sn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",q=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"_renderPolicy");r(this,"setRenderPolicy",n=>{this._renderPolicy=n});r(this,"getRenderPolicy",()=>this._renderPolicy);r(this,"initiated",!1);r(this,"version",ln);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"isTrustedSource",n=>{if(!n||n===window)return!0;let e=t=>{let s=t.element;return(s==null?void 0:s.nodeName)==="IFRAME"&&s.contentWindow===n};return this.components.some(e)||this.components2init.some(e)});r(this,"incomingMessageHandler",n=>{var e;if((e=n.data)!=null&&e.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==_.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){let i=this.components2init.filter(p=>{let d=p.element;return(d==null?void 0:d.nodeName)==="IFRAME"&&d.contentWindow===n.source});(i.length?i:this.components2init).forEach(p=>{p.send(new Y(p.id))});return}if(t.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==t.content.id);let i=this.components.find(a=>{var p;return a.id===((p=t.content)==null?void 0:p.id)});i==null||i.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let i=t,a=this.components.find(p=>p.id===i.destination);if(a){if(i.direction===_.down){i.message.messageType===D.name?a.onMessageReceived(i.message):(i.message.route=i.route,a.send(i.message));return}}else{let p=this.components.find(d=>d.id===i.message.destination);p&&p.send(i.message)}return}let s=this.components.find(i=>i.id===t.destination);if(!s){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(s){if(s.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let e=[new Fe,new We,new it];this.componentsLoaders=[...e],n&&this._registerLoaders(n),window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_registerLoaders",n=>{let e={};n.forEach(t=>{let s=new t(this.componentsLoaders);e[s.type]=s}),this.componentsLoaders.forEach(t=>{e[t.type]||(e[t.type]=t)}),this.componentsLoaders=Object.values(e)});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case J.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case J.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(g=>g.type===Ae.Segment?g.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let u=c.segment,f=(t||{})[u.function];return f?await f():(console.warn("segmentId:".concat(d.segmentId,", ").concat(u.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var m,u,f,g;if(!e){debugger;throw new Error("no container was found for this component")}let s=await vn(n);s&&(n=s);let i=h(h({},(m=this.loaderHooks)!=null?m:{}),(u=t==null?void 0:t.hooks)!=null?u:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,i);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(l=await t.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:J.Dedicated,skin:l},t&&(t=h({},t),delete t.hooks),await Et(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(l=>l.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),c.isInitiated||c.send(new Y(c.id)),(!t||t.connectProps!==!1)&&(c=cn(c,n.type.props,p));try{await _t(c,n,this.components)}catch(l){throw l}return t!=null&&t.skipInit||await c.initiated(),c});r(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};r(q,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Sn});if(!window.myop.hostSDK){let o=new q;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Sn}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>un(n);o.stats=_e,o.off=yn,o.refresh=gn,window.myop.delivery=o}var ao=window.myop.hostSDK;Be("hostSDK",ao);export{q as HostSDK,ao as hostSDK};
|
|
@@ -607,6 +607,7 @@ var BaseMyopComponent = class {
|
|
|
607
607
|
setTimeout(() => {
|
|
608
608
|
if (!this.isInitiated && this._whenInitiatedReject && !this._markedForDisposed) {
|
|
609
609
|
this._whenInitiatedReject("timeout_".concat(timeout, " ").concat(this.id));
|
|
610
|
+
this.dispose();
|
|
610
611
|
}
|
|
611
612
|
}, timeout);
|
|
612
613
|
this.initiated().then(() => {
|
|
@@ -690,19 +691,27 @@ var BaseMyopComponent = class {
|
|
|
690
691
|
};
|
|
691
692
|
}
|
|
692
693
|
}
|
|
694
|
+
/** Runs the 'onDispose' handlers once. hostSDK registers the one that unregisters
|
|
695
|
+
* this component, so it has to run on EVERY dispose path, initiated or not. */
|
|
696
|
+
runDisposeHandlers() {
|
|
697
|
+
const onDisposeHandlers = this.messageHandlers["onDispose"];
|
|
698
|
+
if (onDisposeHandlers) {
|
|
699
|
+
onDisposeHandlers.forEach((disposeHandler) => {
|
|
700
|
+
disposeHandler(null);
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
}
|
|
693
704
|
dispose() {
|
|
694
705
|
this.markedForDisposed = true;
|
|
695
706
|
if (!this.isInitiated) {
|
|
707
|
+
this.runDisposeHandlers();
|
|
708
|
+
this.messageHandlers = {};
|
|
709
|
+
this.id += "_disposed";
|
|
696
710
|
return;
|
|
697
711
|
}
|
|
698
712
|
console.log("disposing component", this.id);
|
|
699
713
|
this.send(new DisposeMessage());
|
|
700
|
-
|
|
701
|
-
if (onDisposeHandlers) {
|
|
702
|
-
onDisposeHandlers.forEach((disposeHandler) => {
|
|
703
|
-
disposeHandler(null);
|
|
704
|
-
});
|
|
705
|
-
}
|
|
714
|
+
this.runDisposeHandlers();
|
|
706
715
|
this.messageHandlers = {};
|
|
707
716
|
this.id += "_disposed";
|
|
708
717
|
this.isInitiated = false;
|
|
@@ -1363,8 +1372,13 @@ var createRefComponent = async (ref, componentConfig, components, options) => {
|
|
|
1363
1372
|
return new Promise(async (resolve, reject) => {
|
|
1364
1373
|
const refComponent = new MyopRefComponent(componentConfig.type, component, options);
|
|
1365
1374
|
components.push(refComponent);
|
|
1375
|
+
const unregister = () => {
|
|
1376
|
+
const at = components.indexOf(refComponent);
|
|
1377
|
+
if (at !== -1) components.splice(at, 1);
|
|
1378
|
+
};
|
|
1366
1379
|
await component.initiated();
|
|
1367
1380
|
const timeout = setTimeout(() => {
|
|
1381
|
+
unregister();
|
|
1368
1382
|
reject("timeout");
|
|
1369
1383
|
}, 5e3);
|
|
1370
1384
|
component.send(new CreateRefComponentMessage(
|
|
@@ -1377,11 +1391,13 @@ var createRefComponent = async (ref, componentConfig, components, options) => {
|
|
|
1377
1391
|
async (message) => {
|
|
1378
1392
|
clearTimeout(timeout);
|
|
1379
1393
|
if (message.failed) {
|
|
1394
|
+
unregister();
|
|
1380
1395
|
reject("CreateRefComponentMessage failed");
|
|
1381
1396
|
return;
|
|
1382
1397
|
}
|
|
1383
1398
|
const implementationComponent = components.find((c) => c.id == refComponent.id);
|
|
1384
|
-
if (implementationComponent !== refComponent) {
|
|
1399
|
+
if (implementationComponent && implementationComponent !== refComponent) {
|
|
1400
|
+
unregister();
|
|
1385
1401
|
component.refs[ref.refConfig.name] = implementationComponent;
|
|
1386
1402
|
resolve(implementationComponent);
|
|
1387
1403
|
return;
|
|
@@ -1695,7 +1711,8 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1695
1711
|
this.IframeElement.style.width = "100%";
|
|
1696
1712
|
this.setHeightBasedOnScrollHeight();
|
|
1697
1713
|
observerCleanup = this.send(new SetResizeObserverMessage());
|
|
1698
|
-
}).catch(() => {
|
|
1714
|
+
}).catch((e) => {
|
|
1715
|
+
console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id, ": ").concat(e));
|
|
1699
1716
|
});
|
|
1700
1717
|
return cleanup;
|
|
1701
1718
|
});
|
|
@@ -1744,7 +1761,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1744
1761
|
return cleanupHandler;
|
|
1745
1762
|
});
|
|
1746
1763
|
__publicField(this, "dispose", () => {
|
|
1747
|
-
var _a;
|
|
1764
|
+
var _a, _b;
|
|
1748
1765
|
(_a = this._bridgeSizeCleanup) == null ? void 0 : _a.call(this);
|
|
1749
1766
|
if (this._autoSizeCleanup) {
|
|
1750
1767
|
this._autoSizeCleanup();
|
|
@@ -1757,7 +1774,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1757
1774
|
if (this.cleanupInspect)
|
|
1758
1775
|
this.cleanupInspect();
|
|
1759
1776
|
super.dispose();
|
|
1760
|
-
this.IframeElement.parentNode.removeChild(this.IframeElement);
|
|
1777
|
+
(_b = this.IframeElement.parentNode) == null ? void 0 : _b.removeChild(this.IframeElement);
|
|
1761
1778
|
});
|
|
1762
1779
|
this.element = this.IframeElement;
|
|
1763
1780
|
this._lastData = options == null ? void 0 : options.data;
|
|
@@ -2029,7 +2046,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
2029
2046
|
};
|
|
2030
2047
|
|
|
2031
2048
|
// version:myop-sdk-version
|
|
2032
|
-
var myop_sdk_version_default = "0.4.0-beta.
|
|
2049
|
+
var myop_sdk_version_default = "0.4.0-beta.3";
|
|
2033
2050
|
|
|
2034
2051
|
// src/helpers/deliveryStore.ts
|
|
2035
2052
|
var DB_NAME = "myop-delivery";
|
|
@@ -3507,7 +3524,12 @@ var HostSDK = class {
|
|
|
3507
3524
|
}
|
|
3508
3525
|
const myopMessage = event.data;
|
|
3509
3526
|
if (myopMessage.messageType === MyopMessages.InitRequest) {
|
|
3510
|
-
this.components2init.
|
|
3527
|
+
const fromAskingFrame = this.components2init.filter((component2) => {
|
|
3528
|
+
const element = component2.element;
|
|
3529
|
+
return (element == null ? void 0 : element.nodeName) === "IFRAME" && element.contentWindow === event.source;
|
|
3530
|
+
});
|
|
3531
|
+
const targets = fromAskingFrame.length ? fromAskingFrame : this.components2init;
|
|
3532
|
+
targets.forEach((component2) => {
|
|
3511
3533
|
component2.send(new InitMessage(component2.id));
|
|
3512
3534
|
});
|
|
3513
3535
|
return;
|
|
@@ -3722,14 +3744,18 @@ var HostSDK = class {
|
|
|
3722
3744
|
throw new Error('no loader "'.concat(selectedSkin.loader.type, '" was found for component'));
|
|
3723
3745
|
}
|
|
3724
3746
|
let component = await componentLoader.load(componentConfig.type, selectedSkin, container, options);
|
|
3725
|
-
if (!component.isInitiated)
|
|
3747
|
+
if (!component.isInitiated) {
|
|
3726
3748
|
this.components2init.push(component);
|
|
3749
|
+
}
|
|
3727
3750
|
component.bind("onDispose", () => {
|
|
3728
3751
|
this.components = this.components.filter((c) => c !== component);
|
|
3729
3752
|
this.components2init = this.components2init.filter((c) => c !== component);
|
|
3730
3753
|
return true;
|
|
3731
3754
|
});
|
|
3732
3755
|
this.components.push(component);
|
|
3756
|
+
if (!component.isInitiated) {
|
|
3757
|
+
component.send(new InitMessage(component.id));
|
|
3758
|
+
}
|
|
3733
3759
|
if (!options || options.connectProps !== false) {
|
|
3734
3760
|
component = connectProps(component, componentConfig.type.props, selectedSkin);
|
|
3735
3761
|
}
|