@myop/sdk 0.4.0-beta.3 → 0.4.0-beta.5

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.
Files changed (35) hide show
  1. package/dist/bundled-declarations.d.ts +43 -2
  2. package/dist/cjs/_IframeSDK.47f37ec9.min.js +1 -0
  3. package/dist/cjs/{_IframeSDK.c2e3efb9.js → _IframeSDK.ac4c28cf.js} +87 -7
  4. package/dist/cjs/_IframeSDK.ac4c28cf.js.map +7 -0
  5. package/dist/cjs/{_WebComponentSDK.3728ca8b.js → _WebComponentSDK.4085389a.js} +87 -7
  6. package/dist/cjs/_WebComponentSDK.4085389a.js.map +7 -0
  7. package/dist/cjs/_WebComponentSDK.4ca43f0a.min.js +1 -0
  8. package/dist/cjs/_hostSDK.0443afcd.min.js +1 -0
  9. package/dist/cjs/{_hostSDK.94744d97.js → _hostSDK.46b85afc.js} +87 -7
  10. package/dist/cjs/_hostSDK.46b85afc.js.map +7 -0
  11. package/dist/cjs/myop_sdk.js +11 -11
  12. package/dist/cjs/myop_sdk.js.map +1 -1
  13. package/dist/cjs/myop_sdk.min.js +1 -1
  14. package/dist/cjs-bundled/myop_sdk.bundled.js +88 -8
  15. package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
  16. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  17. package/dist/module/Iframe/index.js +88 -8
  18. package/dist/module/Iframe/index.js.map +2 -2
  19. package/dist/module/SDK.js +88 -8
  20. package/dist/module/SDK.js.map +2 -2
  21. package/dist/module/embeddedSDK.js +1 -1
  22. package/dist/module/host/components/myopExtractedWebComponent.d.ts +24 -1
  23. package/dist/module/host/embeddedSDK.js +1 -1
  24. package/dist/module/host/index.js +88 -8
  25. package/dist/module/host/index.js.map +2 -2
  26. package/dist/module/host/loaders/HTMLComponentLoader.d.ts +19 -1
  27. package/dist/module/webcomponent/index.js +88 -8
  28. package/dist/module/webcomponent/index.js.map +2 -2
  29. package/package.json +1 -1
  30. package/dist/cjs/_IframeSDK.3faa31eb.min.js +0 -1
  31. package/dist/cjs/_IframeSDK.c2e3efb9.js.map +0 -7
  32. package/dist/cjs/_WebComponentSDK.3728ca8b.js.map +0 -7
  33. package/dist/cjs/_WebComponentSDK.e517f1a4.min.js +0 -1
  34. package/dist/cjs/_hostSDK.48b3ff7a.min.js +0 -1
  35. package/dist/cjs/_hostSDK.94744d97.js.map +0 -7
@@ -0,0 +1 @@
1
+ var jt=Object.defineProperty,zn=Object.defineProperties;var $n=Object.getOwnPropertyDescriptors;var Vt=Object.getOwnPropertySymbols;var An=Object.prototype.hasOwnProperty,Fn=Object.prototype.propertyIsEnumerable;var at=(o,n,t)=>n in o?jt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,h=(o,n)=>{for(var t in n||(n={}))An.call(n,t)&&at(o,t,n[t]);if(Vt)for(var t of Vt(n))Fn.call(n,t)&&at(o,t,n[t]);return o},L=(o,n)=>zn(o,$n(n));var Wn=(o,n)=>{for(var t in n)jt(o,t,{get:n[t],enumerable:!0})};var r=(o,n,t)=>at(o,typeof n!="symbol"?n+"":n,t);var De=class{constructor(n,t,e,i,s){this.myopId=n;this.htmlTagName=t;this.BoundingRect=e;this.offsetTop=i;this.offsetLeft=s;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()}},dt=class{constructor(n){this.messageToHost=n}},Be=class extends dt{constructor(t,e){super(t);this.messageToHost=t;this.context=e}};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={};Wn(Le,{AddEventListenerMessage:()=>ut,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:()=>fe,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>ue,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:()=>ft,SetInnerHtml:()=>yt,SetMutationObserverMessage:()=>bt,SetResizeObserverMessage:()=>Se,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(t=>t.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 Nn=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))};var pt=o=>{let n=Nn(o);if(n.length%16!==0)throw new Error("Invalid input length");let t=[];for(let e=0;e<n.length;e+=16)t.push(Kn(n.slice(e,e+16)));return t};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(t){super();this.ref=t}},w=class extends M{constructor(t){super();this.replayToHandler=t}},x=class extends M{constructor(t){super();this.handler=t;r(this,"handlerUniqueId",R())}},U=class o{constructor(n,t){this.refConfig=n;this.component=t;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=L(h({},this),{component:null})}static create(n,t,e){let i=t;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(i,e)}};var Qt="ClickReplayMessage",lt=class extends x{constructor(t,e){super(e);this.ref=t;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(t,e){super();this.ref=t;r(this,"messageType","ChangeTextMessage");this.content=e}};var Jt="ExecuteScriptReplyMessage",Un=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,qn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xt=o=>{let n=o.match(Un);if(n)return n[1]||n[3];{let t=o.match(qn);if(t)return t[1].trim()}},k=class extends x{constructor(t,e=()=>{},i){super(e);this.scriptInputs=i;r(this,"replyMessageKey",Jt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=t.toString(),this.content=t.toString(),this.content=Xt(this.content)}};r(k,"replierKey","send"),r(k,"completeStreamKey","completeStream");var ue=class extends w{constructor(t,e){super(t);this.replayToHandler=t;this.content=e;r(this,"messageType",Jt)}};var G=class extends k{constructor(t,e,i=()=>{}){super(({rootRef:s,elementId:a,_script:d,__scriptInputs:p})=>{let c=(s.shadowRoot||s.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(p.ref=c[0],new Function("return (".concat(d,")(...arguments)"))(p)):null},i);this.scriptInputs=e;this.scriptInputs=L(h({},e),{_script:t.toString()})}};var Zt="EventListenerCallbackMessage",ut=class extends x{constructor(t,e,i){super(i);this.ref=t;this.type=e;this.handler=i;r(this,"replyMessageKey",Zt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(t){return this.serializableSkeleton=t,this}},fe=class extends w{constructor(t,e){super(t);this.replayToHandler=t;this.e=e;r(this,"messageType",Zt);this.content={e}}};var ft=class extends M{constructor(t,e,i){super();this.ref=t;this.name=e;this.value=i;r(this,"messageType","SetAttributeMessage")}};var en="ElementValueReplayMessage",gt=class extends x{constructor(t,e){super(e);this.ref=t;r(this,"replyMessageKey",en);r(this,"messageType","GetElementValueMessage")}},ge=class extends w{constructor(t){super();this.content=t;r(this,"messageType",en)}};var yt=class extends M{constructor(t,e){super();this.ref=t;r(this,"messageType","SetInnerHtml");this.content=e}};var Y=class extends M{constructor(t){super();r(this,"messageType","InitMessage");this.content={id:t}}isTypeof(t){return t.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(t,e,i,s){super(s);this.refConfig=t;this.nestedComponentConfig=e;this.options=i;r(this,"replyMessageKey",tn);r(this,"messageType","CreateRefComponentMessage")}},ie=class extends w{constructor(t,e,i){super(t);this.replayToHandler=t;this.nestedRefs=e;this.failed=i;r(this,"messageType",tn)}};var Ce=class extends M{constructor(t,e){super();this.destination=t;this.message=e;r(this,"messageType","EnvelopedMessage");let i=e;this.route=[t,...i.route?i.route:[]]}};var nn="DetectedMyopRefsMessage",ht=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",nn)}},be=class extends w{constructor(t,e){super(t);this.replayToHandler=t;r(this,"messageType",nn);this.content=e}isTypeof(t){return t.messageType===this.messageType}};var on="GetAttributeReplayMessage",Mt=class extends x{constructor(t,e,i){super(i);this.ref=t;this.name=e;r(this,"replyMessageKey",on);r(this,"messageType","GetAttributeMessage")}},Ct=class extends w{constructor(t){super();this.content=t;r(this,"messageType",on)}};var D=class extends M{constructor(t){super();this.method=t;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(t,e){super(e);this.cleanupForMessageId=t;r(this,"replyMessageKey",sn);r(this,"messageType","CleanupMessage")}},we=class extends w{constructor(t){super();this.customCleanup=t;r(this,"messageType",sn)}};var xe=class extends M{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var Se=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,t){this.id=n;this.context=t;r(this,"send",n=>{})}},Pe=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let t=n.data?n.data:n.detail;if(!(!t||!t.myop)){let e=t;if(e.direction!==_.down)return;if(e.messageType===y.DisposeMessage){e.destination&&delete this.components[e.destination];return}if(e.messageType===y.InitMessage){let i=e.content.id;if(this.components[i])return;this.components[i]=new xt(i),this.messageToHost(new ye(i));return}if(e.messageType===y.EnvelopedMessage){let i=e,s=i.message;if(e=s,this.alwaysPassEnvelopesToHost||this.components[e.destination]){let a=myop.hostSDK.components.find(p=>p.id===s.destination);if(a){a.send(s);return}let d=myop.hostSDK.components.find(p=>p.id===i.destination);if(d){d.send(s);return}}else return}if(e.messageType){if(e.messageType===y.CleanupMessage){let s=e,a=this.messageCleanupCache[s.cleanupForMessageId],d=new we(!!a);d.destination=e.destination,a?(delete this.messageCleanupCache[s.cleanupForMessageId],Gt(a).then(()=>{this.messageToHost(d,s)}).catch(()=>{})):this.messageToHost(d,s);return}let i=!1;this.supportedHandlers.forEach(s=>{if(s.messageType===e.messageType){i=!0;let a=s.executor(e);if(e.cleanable&&a&&(this.messageCleanupCache[e.id]=a),a&&!e.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(s.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&&e.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(s.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,t){this.container=n;this.shadowRoot=t;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(t,e){super(t);this.context=e;r(this,"executor",t=>{if(t.destination){let e=t.destination;if(this.context[e].context){let i=(s,a)=>{this.messageToHost(L(h({},s),{source:t.destination?t.destination:t.source,destination:t.source?t.source:t.destination}),a)};return this.innerExecutor(t,this.context[e].context,i)}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",(t,e,i)=>{let s=B(t.ref,e.shadowRoot),a=[];return s.forEach(d=>{let p=()=>{i(new me(t.handlerUniqueId))};d.addEventListener("click",p),a.push(()=>{d.removeEventListener("click",p)})}),()=>{a.forEach(d=>d())}})}};var Fe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(t,e)=>{B(t.ref,e.shadowRoot).forEach(s=>{s.textContent=t.content})})}};var We=class extends Oe{constructor(t,e){super(t,e);this.container=t;this.shadowRoot=e}};var Ke=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(t,e)=>{let i=e.shadowRoot.querySelectorAll("[".concat(F.id,"]")),s=[];i.forEach(a=>{let d=a.getAttribute(F.id);d&&s.push(new De(d,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new be(t.handlerUniqueId,s))});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",(t,e)=>{B(t.ref,e.shadowRoot).forEach(s=>{s.setAttribute(t.name,t.value)})})}};var St=o=>o!==Object(o),Vn=o=>typeof o=="function",vt=o=>{if(St(o))return!0;if(Vn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let t=o[n];if(typeof t=="object"){if(!vt(t))return!1}else{if(St(t))continue;return!1}}return!0},W=(o,n={},t=!0,e=new WeakMap)=>{if(St(o))return o;if(Array.isArray(o)){if(e.has(o))return e.get(o);let i=[];e.set(o,i);for(let s=0;s<o.length;s++){let a=o[s];i[s]=W(a,n,t,e)}return i}if(o!==null&&typeof o=="object"){if(e.has(o))return e.get(o);let i={};e.set(o,i);for(let s in o){let a=typeof n=="boolean"?n:n[s];a&&(a===!0?(t?o[s]!==void 0:o[s])&&(i[s]=W(o[s],!0,t,e)):typeof a=="object"&&(i[s]=W(o[s],a,t,e)))}return i}return{}};var Ve=class extends I{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(t,e,i)=>{let s=B(t.ref,e.shadowRoot),a=[];return s.forEach(d=>{let p=c=>{i(new fe(t.handlerUniqueId,W(c,t.serializableSkeleton)))};d.addEventListener(t.type,p),a.push(()=>{d.removeEventListener(t.type,p)})}),()=>{a.forEach(d=>d())}})}};var z=class{constructor(n,t,e){this.componentDefinition=n;this.container=t;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,t)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(t)||this.messageHandlers[n].push(t)});r(this,"bindWhen",(n,t,e)=>{if(!e)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let i=this.messageHandlers[n],s=a=>t(a)?(e(a),!0):!1;return i.push(s),()=>{let a=i.indexOf(s);a>-1&&i.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,t)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=t}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(e==null?void 0:e.id)||q.Instance().assignId(n);let i=e!=null&&e.timeout?e==null?void 0:e.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&(this._whenInitiatedReject("timeout_".concat(i," ").concat(this.id)),this.dispose())},i),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 e=n;return this[e.method]?this[e.method](e.content):console.log("method not found ".concat(e.method," on component"),this),!0}let t=this.messageHandlers[n.messageType];if(t&&t.length){let e=!1;return t.forEach(i=>{e=e||i(n)}),e}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=_.down;let t=this.bindWhen(n.replyMessageKey,i=>i.replayToHandler===n.handlerUniqueId,i=>{n.handler(i),t()}),e=n.handler;delete n.handler,this.send(n),n.handler=e}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=_.down;let t;if(n.handler){let e=n;t=this.bindWhen(e.replyMessageKey,i=>i.replayToHandler===e.handlerUniqueId,e.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Ie(n.id,e=>{})),t&&t()}:()=>{}}runDisposeHandlers(){let n=this.messageHandlers.onDispose;n&&n.forEach(t=>{t(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 ve=class extends z{constructor(t,e,i){super(t,e.container,i);this.componentDefinition=t;this.parent=e;r(this,"send",t=>{let e=t.handler,i=super.send(t);return this.parent.send(new Ce(this.id,t)),t.handler=e,i});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(t){return super.onMessageReceived(t)}};var X=class extends z{constructor(t,e,i,s,a,d){super(t,i,d);this.container=i;this.customElement=s;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",t=>{let e=t.detail;e!=null&&e.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(e.action,e.payload):this._ctaHandler||this._ctaQueue.push({action:e.action,payload:e.payload}))});r(this,"_autoSizeOptions");r(this,"observeAutoSize",t=>{this._autoSizeOptions=t;let e=this.customElement;try{getComputedStyle(e).display==="inline"&&(e.style.display="block")}catch(p){}let i=p=>{if(p===void 0)return;if(typeof p=="number")return p;let c=parseFloat(p);return isNaN(c)?void 0:c},s=(p,c,m)=>c!==void 0&&p<c?c:m!==void 0&&p>m?m:p,a=()=>{var u;let p=this._autoSizeOptions,c=e.getBoundingClientRect(),m=(p==null?void 0:p.explicitHeight)===void 0;(u=p==null?void 0:p.onSizeChange)==null||u.call(p,{width:c.width,height:m?s(c.height,i(p==null?void 0:p.minHeight),i(p==null?void 0:p.maxHeight)):c.height,autoSizingWidth:!1,autoSizingHeight:m})},d;try{d=new ResizeObserver(()=>a()),d.observe(e)}catch(p){}return a(),()=>{d==null||d.disconnect(),this._autoSizeOptions=void 0}});r(this,"cleanupInspect",()=>{});r(this,"send",t=>{let e=super.send(t);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",t),e});r(this,"dispose",()=>{var t;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=s,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=de(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(t){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(t)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(t){if(this._ctaHandler=t,this._ctaQueue.length>0){let e=[...this._ctaQueue];this._ctaQueue=[],e.forEach(i=>{this.markedForDisposed||t(i.action,i.payload)})}}};var jn=(o,n,t)=>{let e=document.createElement("a");return e.textContent=o,e.style.position="relative",e.style.padding="0 5px",e.style.fontSize="14px",e.style.top="0",e.style.top="".concat(n,"px"),e.style.transform="translateX(-50%)",e.target="_blank",e.href="https://dashboard.myop.dev/dashboard/component/".concat(t.id),e},de=(o,n,t,e,i,s)=>{let a=jn("".concat(s.name," : ").concat(n),t,s);return e.insertBefore(a,i),i.style.border="1px solid #007BFF",i.style.display="block",()=>{i.style.border="unset",e.removeChild(a)}},dn=(o,n,t)=>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(t.componentDefinition.name,", ID: ").concat(t.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(t.componentDefinition.id," or consult the developer guide.")),!0),pn=(o,n,t)=>{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(t.componentDefinition.name,", ID: ").concat(t.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(t.componentDefinition.id," or consult the developer guide."))},cn=(o,n,t)=>{let e=n.reduce((s,a)=>L(h({},s),{[a.name]:h({},a)}),{}),i={get:(s,a)=>{let d=e[a];if(dn(d,a,o))return!1;if(d.behavior.type===ae.code){if(o instanceof X)return(d.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(d.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(t.loader.type===A.HTMLLoader&&t.loader.shadowRootMode===Q.localFrame){let c=d.behavior;return o.element.contentWindow[c.remap||a]}return pn(d,a,o),!1}return d.mode==="output"?new Promise(p=>{let c=[];d.behavior.ref&&c.push(U.create(d.behavior.ref)),c.push(u=>{p(u)}),d.behavior.params&&c.push(...d.behavior.params);let m=Le[d.behavior.message];o.send(new m(...c))}):null},set:(s,a,d)=>{let p=e[a];if(dn(p,a,o))return!1;if(p.behavior.type===ae.code){if(o instanceof X){let m=p.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(d),!0;if(m==="myop_init_interface")return o.initWithData(d),!0}if(o instanceof K&&o.isolated){let m=p.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(d),!0;if(m==="myop_init_interface")return o.initWithData(d),!0}if(t.loader.type===A.HTMLLoader&&t.loader.shadowRootMode===Q.localFrame){let m=p.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=d,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.forEach(l=>{o.markedForDisposed||d(l.action,l.payload)})}return!0}return pn(p,a,o),!1}else if(p.mode==="input")if(p.behavior.type==="message"){let c=[];p.behavior.ref&&c.push(U.create(p.behavior.ref)),c.push(d),p.behavior.params&&c.push(...p.behavior.params);let m=Le[p.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(p.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,i),o},Gn=(o,n)=>new Proxy(o,{get(t,e){return t[e]?t[e]:(...s)=>new Promise(a=>{s.forEach(d=>{vt(d)||an.notSerializableRefCall(e,d)}),n.send(new G(({ref:d,propName:p,functionArgs:c,makeSerializable:m})=>{if(d){let u=d[p];return m(typeof u=="function"?d[p](...c):u,!0)}return null},{elementId:t.refConfig.selector,propName:e,functionArgs:s},d=>{a(d.content)}))})},set(t,e,i){return n.send(new G(({ref:s,propName:a,propValue:d})=>{s&&(s[a]=d)},{elementId:t.refConfig.selector,propValue:i,propName:e},s=>{})),!0}}),Et=async(o,n,t,e)=>{let i=o.component;if(!i)throw new Error("cant createRefComponent with detached ref");return new Promise(async(s,a)=>{let d=new ve(n.type,i,e);t.push(d);let p=()=>{let m=t.indexOf(d);m!==-1&&t.splice(m,1)};await i.initiated();let c=setTimeout(()=>{p(),a("timeout")},5e3);i.send(new Me(o.refConfig,n,L(h({},e||{}),{id:d.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){p(),a("CreateRefComponentMessage failed");return}let u=t.find(f=>f.id==d.id);if(u&&u!==d){p(),i.refs[o.refConfig.name]=u,s(u);return}else d.setInitiated(),i.refs[o.refConfig.name]=d;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(E=>E.type.id===f.componentDefinitionId).type,l=new ve(g,d);l.setInitiated(),d.refs[f.refName]=l,t.push(l)});try{await _t(d,n,t,!0),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),s(d)}catch(f){a(f)}}))})},_t=async(o,n,t,e=!1)=>{o.refs||(o.refs={});let i=Object.values(o.componentDefinition.refs).map(s=>new Promise(async(a,d)=>{var p;if(s.behavior.type==re.component){if(e){a();return}let c=s.behavior.componentId;c||(c=s.behavior.instance.componentId);let m=(p=n.instance.resolvedNestedComponents)==null?void 0:p.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=U.create("",s,o);try{let f=await Et(u,m,t);o.refs[s.name]=f,a()}catch(f){d(f)}}else try{let c=U.create("",s,o);o.refs[s.name]=Gn(c,o),a()}catch(c){}}));try{await Promise.all(i)}catch(s){throw s}};var K=class extends z{constructor(t,e,i,s,a){super(t,i,a);this.componentConfig=t;this.container=i;this.IframeElement=s;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 t=this.send(new k(()=>window.document.documentElement.scrollHeight,e=>{this.IframeElement.style.height="".concat(e.content,"px"),t()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:e})=>{let{height:i,width:s}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:d,width:p}=document.documentElement.getBoundingClientRect();e({height:d,width:p})});return a.observe(document.documentElement),a.observe(document.body),{height:i,width:s}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px")})));r(this,"observeAutoSize",t=>{if(this._autoSizeOptions=t,this.isolated)return this._isoSizeOpts=t,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 e=this.IframeElement,i=e.contentDocument;if(!i)return this.observeHeightViaBridge();let s=(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},d=()=>{var Ot,zt,$t,At,Ft,Wt,Kt,Nt;let g=e.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),S=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=(Wt=l==null?void 0:l.explicitHeight)!=null?Wt:H,v=b!==void 0,te=C!==void 0,ne=this.container.getBoundingClientRect(),_n=ne.width===0,Tn=ne.height===0||ne.height===ee,oe=(l!=null&&l.forceAutoSize||_n)&&!v,se=(l!=null&&l.forceAutoSize||Tn)&&!te;if(!oe&&!se){e.style.width=typeof b=="number"?"".concat(b,"px"):"100%",e.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(Kt=l==null?void 0:l.onSizeChange)==null||Kt.call(l,{width:typeof b=="number"?b:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let Rn=e.style.transition,$=this.container,kn=$.style.transition;e.style.transition="none",$.style.transition="none";let kt=e.getBoundingClientRect().height,Ht=e.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,Hn=se&&Dt>kt+1,Dn=oe&&Bt>Ht+1,Re=se&&!Hn,ke=oe&&!Dn;if(Re||ke){let Pn=$.style.minHeight,On=$.style.minWidth;Re&&($.style.minHeight="".concat(kt,"px")),ke&&($.style.minWidth="".concat(Ht,"px")),Re&&(e.style.height="0px"),ke&&(e.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=Pn,$.style.minWidth=On}let Lt=s(ce,E,T),Pt=s(le,N,S);oe?e.style.width="".concat(Lt,"px"):e.style.width=typeof b=="number"?"".concat(b,"px"):"100%",se?e.style.height="".concat(Pt,"px"):e.style.height=typeof C=="number"?"".concat(C,"px"):"100%",e.offsetHeight,e.style.transition=Rn,$.style.transition=kn;let Bn=oe&&T!==void 0&&ce>T,Ln=se&&S!==void 0&&le>S;g.documentElement.style.overflowX=Bn?"auto":"",g.documentElement.style.overflowY=Ln?"auto":"",(Nt=l==null?void 0:l.onSizeChange)==null||Nt.call(l,{width:Lt,height:Pt,autoSizingWidth:oe,autoSizingHeight:se})};d(),this._autoSizeUpdate=d;let p,c=()=>{p===void 0&&(p=requestAnimationFrame(()=>{p=void 0,d()}))},m=new ResizeObserver(()=>c());m.observe(i.body),m.observe(i.documentElement);let u=new MutationObserver(()=>c());u.observe(i.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{m.disconnect(),u.disconnect(),p!==void 0&&(cancelAnimationFrame(p),p=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 t,e=!1,i=()=>{e=!0,t==null||t(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=i,this.initiated().then(()=>{e||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),t=this.send(new Se))}).catch(s=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(s))}),i});r(this,"setSizeBasedOnDocumentElement",()=>{let t=this.send(new k(()=>{let{height:e,width:i}=document.documentElement.getBoundingClientRect();return{height:e,width:i}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px"),t()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let t=this.send(new k(()=>{let i=0;return i++,i--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+i+"px"},e=>{this.IframeElement.style.height=e.content,t()}))});r(this,"send",t=>{var s,a;let e=h({},t);if(e.messageType===y.ExecuteComponentMethod)return this[e.method](),()=>{};e.direction=_.down;let i=super.send(e);return(a=(s=this.IframeElement)==null?void 0:s.contentWindow)==null||a.postMessage(e,"*"),i});r(this,"dispose",()=>{var t,e;(t=this._bridgeSizeCleanup)==null||t.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(),(e=this.IframeElement.parentNode)==null||e.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=t=>{if(t.source!==this.IframeElement.contentWindow)return;let e=t.data;!e||e.__myop!==!0||(e.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(e.action,e.payload):this._ctaHandler||this._ctaQueue.push({action:e.action,payload:e.payload}):e.type==="myop:size"&&this._applyIsoSize(e.height,e.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(t){var e,i;this._lastData=t,(i=(e=this.IframeElement)==null?void 0:e.contentWindow)==null||i.postMessage({__myop:!0,type:"myop:init",data:t},"*")}getData(){return this._lastData}setCtaHandler(t){if(this._ctaHandler=t,this._ctaQueue.length>0){let e=[...this._ctaQueue];this._ctaQueue=[],e.forEach(i=>{this.markedForDisposed||t(i.action,i.payload)})}}_applyIsoSize(t,e){var c;if(!t||Number.isNaN(t)||(this._isoLastSize={height:t,width:e},!this._isoAutoSize))return;let i=this._isoSizeOpts,s=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),a=s(i==null?void 0:i.minHeight),d=s(i==null?void 0:i.maxHeight),p=t;a!==void 0&&p<a&&(p=a),d!==void 0&&p>d&&(p=d),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=p+"px",this.IframeElement.style.width="100%",(c=i==null?void 0:i.onSizeChange)==null||c.call(i,{width:e!=null?e:this.IframeElement.clientWidth,height:p,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=de(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(t){return t.messageType===y.In.MutationObserverMessage||t.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(t)}};var V=class{constructor(){r(this,"appendChild",(n,t,e)=>{var i;if(e!=null&&e.relative){if(e.relative.direction==="before")return n.insertBefore(t,e.relative.child);if(e.relative.direction==="after"){let s=(i=e.relative.child)==null?void 0:i.nextSibling;return n.insertBefore(t,s||null)}}else return n.appendChild(t)})}};var Yn=(o,n,t)=>{let e=new URL(o);return e.searchParams.append(n,t),e.toString()},je=class extends V{constructor(){super(...arguments);r(this,"type",A.IframeLoader);r(this,"load",async(t,e,i,s)=>{let a,d=e.loader;if((i==null?void 0:i.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",d.url,i),a=i,a.src=d.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(d.autoHeight||!d.height?"100%":d.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(s!=null&&s.hidden?"0":"1",";\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n ");a.style.cssText=u,s!=null&&s.elementAttributes&&Object.entries(s.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=e.loader.url;s!=null&&s._hasParent&&(f=Yn(f,"_myop-comp",c)),a.src=f,i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),a=this.appendChild(i,a,s)}let p=new K(t,e,i,a,s);return d.autoHeight&&(s==null?void 0:s.autoSize)!==!1&&p.observeHeightViaBridge(),p})}};var pe=class extends z{constructor(t,e,i,s,a){super(t,i,a);this.container=i;this.customElement=s;r(this,"cleanupInspect",()=>{});r(this,"send",t=>{let e=h({},t),i=super.send(e),s=new CustomEvent($e.webcomponent_message_key,{detail:e});try{this.customElement.dispatchEvent(s)}catch(a){console.log("error while trying to dispatchEvent",a)}return i});r(this,"dispose",()=>{var t;super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=s}inspect(){return this.cleanupInspect=de(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(t,e,i,s)=>{let a=e.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 d="myop-comp-".concat(R()),p=document.createElement(a.tag);return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),p.id=d,s!=null&&s.hidden&&(p.style.opacity="0",p.style.position="absolute",p.style.height="0",p.style.width="0",p.style.pointerEvents="none",p.style.visibility="hidden"),s!=null&&s._environment&&(p._myopEnvironment=s==null?void 0:s._environment),this.appendChild(i,p,s),new pe(t,e,i,p,s)})}};var ln="0.4.0-beta.5";var Qn="myop-delivery",Je="components";var Ye=null;function Jn(){return Ye||(Ye=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(Qn,1);n.onupgradeneeded=()=>{let t=n.result;t.objectStoreNames.contains(Je)||t.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 Jn().then(t=>new Promise(e=>{if(!t)return e(null);try{let i=t.transaction(Je,o),s=n(i.objectStore(Je));s.onsuccess=()=>e(s.result),s.onerror=()=>e(null),i.onabort=()=>e(null)}catch(i){e(null)}}))}var Rt="myop.d.";function mn(o,n,t){try{localStorage.setItem(Rt+o,JSON.stringify({t:n,e:t}))}catch(e){}}function Xn(o){try{localStorage.removeItem(Rt+o)}catch(n){}}var Ee=new Map,P={key(o,n,t,e,i){return"".concat(o,"|").concat(n,"|").concat(t,"|").concat(e?"preview":"live","|").concat(i||"raw")},async get(o){let n=Ee.get(o);if(n)return n;let t=await Qe("readonly",e=>e.get(o));return t&&(Ee.set(o,t),mn(o,t.tag,t.storedAt+t.windowMs)),t},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),Xn(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 t=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!t)return 0;let e=Number(t[1]),i=Number(o.get("age")||0);return Math.max(0,e-(isNaN(i)?0:i))*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 un=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__",Zn=()=>{if(typeof window<"u")return window[Xe];if(typeof globalThis<"u")return globalThis[Xe]},eo=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=Zn();return n||(O._main||(O._main=new O,eo(O._main)),O._main)}static sizeOfHeld(n){var t,e,i,s,a;try{return(((a=(s=(i=(e=(t=n==null?void 0:n.config)==null?void 0:t.type)==null?void 0:e.skins)==null?void 0:i[0])==null?void 0:s.loader)==null?void 0:a.HTML)||"").length}catch(d){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,t){let e=this._localServes.get(n);e?e.count++:this._localServes.set(n,{env:t,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(([t,e])=>"".concat(t,":").concat(e.env,":").concat(e.count)).join(",");this._localServes.clear();try{let t="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(t,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(t){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var s;this._localServes.size&&this.flushLocalServes();let t=this.deliveryHost(),e="".concat(t).concat(n);this._deliveryStats.requests++;let i=t!==this._baseUrl;try{let a=await fetch(e);if(a.ok||a.status<500||!i)return i&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(t)}catch(a){if(!i)throw a;this._deliveryStats.lastError=String((s=a==null?void 0:a.message)!=null?s: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,t,e){return t!==void 0||e!==void 0?"".concat(n,":").concat(t||this._defaultEnv,":").concat(e?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,t,e){return this.fetchComponentV2(n,t,e)}async fetchComponentV2(n,t,e){let{env:i,usePreview:s,cacheKey:a}=this.resolveParams(n,t,e);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:i,usePreview:s,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:i,preview:s}),this.variants[a]=new Promise(async(d,p)=>{try{let c;if(this._staticMode){let N=s?"preview":i;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(N,".json");let S=new URLSearchParams(this._queryParams).toString();S&&(c+="?".concat(S))}else c="/consume?id=".concat(n,"&env=").concat(i),s&&(c+="&preview=true"),this._delivery.minify&&!s&&(c+="&opt=min");let m=this._delivery.cache&&!this._staticMode&&!s,u=m?P.key(this.deliveryHost(),n,i,s,this._delivery.minify?"min":"raw"):"",f=m?await P.get(u):null;if(f&&P.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,i),this.variants[a].resolved=f.config,d(f.config);return}if(f&&f.tag){let N="/consume?ids=".concat(n,"&env=").concat(i)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let S=await this.deliveryFetch(N);if(S.ok){let ee=await S.json();if((ee.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=O.sizeOfHeld(f),f.storedAt=Date.now(),f.windowMs=P.windowFrom(S.headers)||f.windowMs,await P.put(f),this.variants[a].resolved=f.config,d(f.config);return}let j=(ee.items||[])[0];if(j){let H=un(j);this._deliveryStats.fromNetwork++,await P.put({key:u,config:H,tag:j.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(S.headers),host:this.deliveryHost()}),this.variants[a].resolved=H,d(H);return}}}catch(S){}}let g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){p(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){p(new Error('Component "'.concat(n,'" not found')));return}if(!E.consume_variant||!E.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(i,'"')));return}let T=un(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,d(T)}catch(c){delete this.variants[a],p(c)}})),await this.variants[a]}getResolvedConfig(n,t,e){var s;let{cacheKey:i}=this.resolveParams(n,t,e);return((s=this.variants[i])==null?void 0:s.resolved)||null}resolveParams(n,t,e){let i=this.preloadedComponents[n],s=t!==void 0||e!==void 0,a,d;if(!s&&i)a=i.env,d=i.preview;else{a=t||this._defaultEnv;let p=t||this._envExplicitlySet;d=e===!0?!0:e===!1?!1:!p}return{env:a,usePreview:d,cacheKey:"".concat(n,":").concat(a,":").concat(d?"preview":"live")}}hydrateComponent(n,t,e,i){let{env:s,usePreview:a,cacheKey:d}=this.resolveParams(n,e,i),p=Promise.resolve(t);p.resolved=t,this.variants[d]=p,this.preloadedComponents[n]={env:s,preview:a}}async fetchComponentV1(n,t){return t?(await this.fetchFlow(t)).components.find(i=>i.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();t(s.item)}catch(i){delete this.userFlows[n],e(i)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();t(s.item)}catch(i){delete this.userFlows[n],e(i)}})),await this.userFlows[n]}async fetchComponent(n,t){return this.fetchComponentV1(n,t)}};r(O,"_main",null),r(O,"DEFAULT_HOST","https://cloud.myop.dev");var Z=O;var Ze=Z.Main;var to="https://delivery.myop.dev",fn=(o={})=>{var t,e;let n=o.minify!==!1||o.cache===!0;return Ze.setDelivery({minify:(t=o.minify)!=null?t:!1,cache:(e=o.cache)!=null?e:!1,host:o.host!==void 0?o.host:n?to:null}),_e()},gn=async()=>(await Ze.refreshDelivery(),_e()),_e=()=>Ze.deliveryStats(),yn=()=>(Ze.setDelivery({minify:!1,cache:!1,host:null}),_e());var hn="";var no="<!-- myop-web-component -->",Cn="myop-web-component",bn=new Map,In=[],et,wn=async()=>(et||(et=new Te,et.init()),et);function oo(o,n){return class extends HTMLElement{connectedCallback(){let t=n===Q.open?"open":"closed",e=this.attachShadow({mode:t});wn().then(i=>{i.connectedCallback(this,e),e.innerHTML=o})}}}var so=(o,n,t)=>{customElements.define(o,oo(n,t)),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(t,e,i,s)=>{let a=e.loader,d=this.isMyopWebComponent(a.HTML),{mode:p,isolate:c}=await this.resolveRenderMode(t,e,a,d,s);if(p===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(t.id,'"'));if(d){if(p!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(t.id,'"'));return this.loadExtractedWebComponent(t,e,i,a.HTML,s)}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(s!=null&&s.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n "),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),l=this.appendChild(i,l,s);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 v=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(v)try{N=JSON.parse(v.getAttribute("content")||"{}")}catch(te){}}let S=a.HTML;if(s!=null&&s._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),v=C.getElementById("myop_preview");v==null||v.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),S="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((s==null?void 0:s.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),v=C.getElementById("myop_preview");v&&(v.remove(),S="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(s!=null&&s.injectCss){let C=new DOMParser().parseFromString(S,"text/html"),v=C.createElement("style");v.setAttribute("data-myop-injected","true"),v.textContent=s.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(v),S="<!DOCTYPE html>"+C.documentElement.outerHTML}T.writeln(S);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&&(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null){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(s.data).replace(/<\/script/gi,"\\u003c/script"),v='<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+v)}if(c){let b=(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null?JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";T.writeln(this.buildIsolationBridge(b))}T.close();let H=new K(t,e,i,l,s);return c&&H.enableIsolation(),H.sizeMeta=N,H.initiated().then(()=>{if((s==null?void 0:s.autoSize)===!1)return;let b=!1;H.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!b&&!(s!=null&&s.hidden)&&(b=!0,H.show())}})}),H}if(a.shadowRootMode===Q.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,wn().then(g=>{g.connectedCallback(u,u)})}else{let f=ro(t.name+e.id);In.includes(f)||(so(f,a.HTML,a.shadowRootMode),In.push(f)),u=document.createElement(f)}return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),u.id=m,s!=null&&s.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(i,u,s),new pe(t,e,i,u,s)})}isMyopWebComponent(t){return t.trimStart().startsWith(no)?!0:new RegExp("<script[^>]*\\sid=[\"']?".concat(Cn,"[\"'\\s>]"),"i").test(t)}async resolveRenderMode(t,e,i,s,a){var m,u,f,g;let d=s?"webComponent":i.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",p=(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=p?await p({componentDefinition:t,skin:e,requestedMode:d,isWebComponent:s}):d;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(t){return"<script>\n (function () {\n var __initial = ".concat(t,";\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(t){let s=new DOMParser().parseFromString(t,"text/html").getElementById(Cn);return(s==null?void 0:s.textContent)||null}executeWebComponentScript(t,e){let i=bn.get(e);if(i)return console.log("[MyopWebComponent] Script already executed for ".concat(e,", reusing <").concat(i,">")),i;let s=document.createElement("script");s.textContent=t,s.id="myop-extracted-".concat(e),document.head.appendChild(s);let a=window.__MYOP_TAG_NAME__;return a&&bn.set(e,a),console.log("[MyopWebComponent] Executed web component script: ".concat(e," -> <").concat(a,">")),a}async loadExtractedWebComponent(t,e,i,s,a){let d=this.extractWebComponentScript(s);if(!d)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let p="".concat(t.id,"-").concat(e.id),c=this.executeWebComponentScript(d,p);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"),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML="");let f=new X(t,e,i,u,c,a);return this.appendChild(i,u,a),(a==null?void 0:a.data)!==void 0&&(a==null?void 0:a.data)!==null&&f.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),f}};var xn=async o=>{try{let n=new URL(window.location.href),e=new URLSearchParams(n.search).get("myopOverride");if(e){let[i,...s]=pt(e);switch(i){case"component":{let[a,d]=s,p=await Z.Main.fetchComponent(a);if(p&&p.type.skins.find(m=>m.id===d))return p.instance.skinSelector={type:J.Dedicated,skin:{id:d}},p}break;default:{let[a,d]=pt(e),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===d);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 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 t=e=>{let i=e.element;return(i==null?void 0:i.nodeName)==="IFRAME"&&i.contentWindow===n};return this.components.some(t)||this.components2init.some(t)});r(this,"incomingMessageHandler",n=>{var t;if((t=n.data)!=null&&t.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==_.up&&n.data.messageType!==y.EnvelopedMessage)return;let e=n.data;if(e.messageType===y.InitRequest){let s=this.components2init.filter(d=>{let p=d.element;return(p==null?void 0:p.nodeName)==="IFRAME"&&p.contentWindow===n.source});(s.length?s:this.components2init).forEach(d=>{d.send(new Y(d.id))});return}if(e.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==e.content.id);let s=this.components.find(a=>{var d;return a.id===((d=e.content)==null?void 0:d.id)});s==null||s.setInitiated();return}if(e.messageType===y.EnvelopedMessage){let s=e,a=this.components.find(d=>d.id===s.destination);if(a){if(s.direction===_.down){s.message.messageType===D.name?a.onMessageReceived(s.message):(s.message.route=s.route,a.send(s.message));return}}else{let d=this.components.find(p=>p.id===s.message.destination);d&&d.send(s.message)}return}let i=this.components.find(s=>s.id===e.destination);if(!i){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(i){if(i.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});r(this,"send",n=>{let t=new MessageEvent("",{data:n});this.incomingMessageHandler(t)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let t=[new je,new Ge,new tt];this.componentsLoaders=[...t],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 t={};n.forEach(e=>{let i=new e(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(e=>{t[e.type]||(t[e.type]=e)}),this.componentsLoaders=Object.values(t)});r(this,"_getSkinIdBySkinSelector",async(n,t=[],e)=>{var s;async function i(a,d){for(let p of a)if(await d(p))return p}switch(n.type){case"DedicatedSkin":case J.Dedicated:return((s=n.skin)==null?void 0:s.id)||n.skins[0].id;case J.Segmented:{let d=await i(n.segments,async p=>{if(p.segmentId==="Default")return!0;let c=t.find(g=>g.type===ze.Segment?g.segment.id===p.segmentId:!1);if(!c)throw new Error("experience not found");let u=c.segment,f=(e||{})[u.function];return f?await f():(console.warn("segmentId:".concat(p.segmentId,", ").concat(u.function," function not provided !")),!1)});if(d)return this._getSkinIdBySkinSelector(d.skinSelector,t);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,t)=>{let e=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,t);return n.type.skins.find(i=>i.id===e)});r(this,"loaderHooks");r(this,"loadComponent",async(n,t,e)=>{var m,u,f,g;if(!t){debugger;throw new Error("no container was found for this component")}let i=await xn(n);i&&(n=i);let s=h(h({},(m=this.loaderHooks)!=null?m:{}),(u=e==null?void 0:e.hooks)!=null?u:{}),a=t;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,s);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=e==null?void 0:e.hooks)!=null&&f.afterSkinSelected&&(l=await e.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:J.Dedicated,skin:l},e&&(e=h({},e),delete e.hooks),await Et(a,n,this.components,e)}else throw new Error("load component got a detached ref.");t=t;let d=await this.runSkinSelector(n,s);if(!d)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=e==null?void 0:e.hooks)!=null&&g.afterSkinSelected&&(d=await e.hooks.afterSkinSelected(h({},d)));let p=this.componentsLoaders.find(l=>l.type===d.loader.type);if(!p){debugger;throw new Error('no loader "'.concat(d.loader.type,'" was found for component'))}let c=await p.load(n.type,d,t,e);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)),(!e||e.connectProps!==!1)&&(c=cn(c,n.type.props,d));try{await _t(c,n,this.components)}catch(l){throw l}return e!=null&&e.skipInit||await c.initiated(),c});r(this,"navigate",async(n,t,e)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(e!=null&&e.staged){let i=await this.loadComponent(t,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},e));return e.init&&await e.init(i),i.show(),n.dispose(),i}else{let i=n.element.nextSibling;return n.dispose(),this.loadComponent(t,n.container,h({relative:{direction:"before",child:i}},e))}})}};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=>fn(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",(t,e,i)=>{(async()=>{let a=e.shadowRoot.querySelectorAll("[".concat(F.id,"='").concat(t.refConfig.selector,"']"));if(a.length===1){let d=q.Instance(),p=d.components.find(f=>f.id===t.options.id);p&&p.dispose();let c=d.components.indexOf(p);c!==-1&&d.components.splice(c,1);let m=await d.loadComponent(t.nestedComponentConfig,a.item(0),t.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})}),i(new ie(t.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new ie(t.handlerUniqueId,[],!0));debugger}})().then()})}};var vn=(o,n,t)=>{let e=o.scriptInputs?o.scriptInputs:{};e.makeSerializable=W,e.send=n,e.rootRef=t,e.__scriptInputs=e;let s=new Function("return (".concat(o.script,")(...arguments)"))(e);n(s)};var ot=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(t,e,i)=>{vn(t,a=>{i(new ue(t.handlerUniqueId,a))},e)})}};var En=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),t={formData:{},unmappedData:[]},e=o.querySelectorAll("input, select, textarea"),i=-1;return e.forEach(s=>{if(typeof s.value=="string"){let a=s.getAttribute(F.id),d=s.getAttribute("name"),p={id:s.id,name:d,value:En(s),required:s.required,validity:W(s.validity,!0),myopId:a};d?t.formData[d]?t.formData[d].value?t.unmappedData.push(p):(t.unmappedData.push(t.formData[d]),t.formData[d]=p):t.formData[d]=p:t.unmappedData.push(p)}}),t}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",(t,e,i)=>{B(t.ref,e.shadowRoot).forEach(a=>{i(new ge(En(a)),t)})})}};var it=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(t,e)=>{B(t.ref,e.shadowRoot).forEach(s=>{s.innerHTML=t.content})})}};var Te=class extends Pe{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(t,e)=>{t.addEventListener($e.webcomponent_message_key,i=>{let s=i.data?i.data:i.detail;if(!s||!s.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=s;if(this.handleIncomeMessages(i),a.messageType===y.InitMessage){let d=a.content.id;this.components[d].context=new We(t,e)}}}),setTimeout(()=>{this.messageToHost(new he)},1)});r(this,"messageToHost",(t,e)=>{t.direction=_.up,!t.replayToHandler&&(e!=null&&e.handlerUniqueId)&&(t.replayToHandler=e.handlerUniqueId),window.myop.hostSDK.send(t)});r(this,"supportedHandlers",[new Fe(this.messageToHost,this.components),new it(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new Ke(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,zn=Object.defineProperties;var $n=Object.getOwnPropertyDescriptors;var Vt=Object.getOwnPropertySymbols;var An=Object.prototype.hasOwnProperty,Fn=Object.prototype.propertyIsEnumerable;var at=(o,n,t)=>n in o?jt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,h=(o,n)=>{for(var t in n||(n={}))An.call(n,t)&&at(o,t,n[t]);if(Vt)for(var t of Vt(n))Fn.call(n,t)&&at(o,t,n[t]);return o},L=(o,n)=>zn(o,$n(n));var Wn=(o,n)=>{for(var t in n)jt(o,t,{get:n[t],enumerable:!0})};var r=(o,n,t)=>at(o,typeof n!="symbol"?n+"":n,t);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={};Wn(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:()=>fe,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>ue,GetAttributeMessage:()=>ht,GetAttributeReplayMessage:()=>Mt,GetElementValueMessage:()=>ft,InitMessage:()=>Y,InitRequest:()=>he,InitResponse:()=>ye,MessageDirection:()=>_,MutationObserverMessage:()=>bt,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>pt,Ref:()=>U,RefComponentCreatedMessage:()=>ie,ResizeObserverMessage:()=>It,SetAttributeMessage:()=>ut,SetInnerHtml:()=>gt,SetMutationObserverMessage:()=>Ct,SetResizeObserverMessage:()=>Se,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(t=>t.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 Nn=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))};var dt=o=>{let n=Nn(o);if(n.length%16!==0)throw new Error("Invalid input length");let t=[];for(let e=0;e<n.length;e+=16)t.push(Kn(n.slice(e,e+16)));return t};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}},pt=class extends M{constructor(t){super();this.ref=t}},w=class extends M{constructor(t){super();this.replayToHandler=t}},x=class extends M{constructor(t){super();this.handler=t;r(this,"handlerUniqueId",R())}},U=class o{constructor(n,t){this.refConfig=n;this.component=t;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=L(h({},this),{component:null})}static create(n,t,e){let i=t;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(i,e)}};var Qt="ClickReplayMessage",ct=class extends x{constructor(t,e){super(e);this.ref=t;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(t,e){super();this.ref=t;r(this,"messageType","ChangeTextMessage");this.content=e}};var Jt="ExecuteScriptReplyMessage",Un=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,qn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xt=o=>{let n=o.match(Un);if(n)return n[1]||n[3];{let t=o.match(qn);if(t)return t[1].trim()}},k=class extends x{constructor(t,e=()=>{},i){super(e);this.scriptInputs=i;r(this,"replyMessageKey",Jt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=t.toString(),this.content=t.toString(),this.content=Xt(this.content)}};r(k,"replierKey","send"),r(k,"completeStreamKey","completeStream");var ue=class extends w{constructor(t,e){super(t);this.replayToHandler=t;this.content=e;r(this,"messageType",Jt)}};var G=class extends k{constructor(t,e,i=()=>{}){super(({rootRef:s,elementId:a,_script:d,__scriptInputs:p})=>{let c=(s.shadowRoot||s.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(p.ref=c[0],new Function("return (".concat(d,")(...arguments)"))(p)):null},i);this.scriptInputs=e;this.scriptInputs=L(h({},e),{_script:t.toString()})}};var Zt="EventListenerCallbackMessage",mt=class extends x{constructor(t,e,i){super(i);this.ref=t;this.type=e;this.handler=i;r(this,"replyMessageKey",Zt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(t){return this.serializableSkeleton=t,this}},fe=class extends w{constructor(t,e){super(t);this.replayToHandler=t;this.e=e;r(this,"messageType",Zt);this.content={e}}};var ut=class extends M{constructor(t,e,i){super();this.ref=t;this.name=e;this.value=i;r(this,"messageType","SetAttributeMessage")}};var en="ElementValueReplayMessage",ft=class extends x{constructor(t,e){super(e);this.ref=t;r(this,"replyMessageKey",en);r(this,"messageType","GetElementValueMessage")}},ge=class extends w{constructor(t){super();this.content=t;r(this,"messageType",en)}};var gt=class extends M{constructor(t,e){super();this.ref=t;r(this,"messageType","SetInnerHtml");this.content=e}};var Y=class extends M{constructor(t){super();r(this,"messageType","InitMessage");this.content={id:t}}isTypeof(t){return t.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(t,e,i,s){super(s);this.refConfig=t;this.nestedComponentConfig=e;this.options=i;r(this,"replyMessageKey",tn);r(this,"messageType","CreateRefComponentMessage")}},ie=class extends w{constructor(t,e,i){super(t);this.replayToHandler=t;this.nestedRefs=e;this.failed=i;r(this,"messageType",tn)}};var Ce=class extends M{constructor(t,e){super();this.destination=t;this.message=e;r(this,"messageType","EnvelopedMessage");let i=e;this.route=[t,...i.route?i.route:[]]}};var nn="DetectedMyopRefsMessage",yt=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",nn)}},be=class extends w{constructor(t,e){super(t);this.replayToHandler=t;r(this,"messageType",nn);this.content=e}isTypeof(t){return t.messageType===this.messageType}};var on="GetAttributeReplayMessage",ht=class extends x{constructor(t,e,i){super(i);this.ref=t;this.name=e;r(this,"replyMessageKey",on);r(this,"messageType","GetAttributeMessage")}},Mt=class extends w{constructor(t){super();this.content=t;r(this,"messageType",on)}};var D=class extends M{constructor(t){super();this.method=t;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(t,e){super(e);this.cleanupForMessageId=t;r(this,"replyMessageKey",sn);r(this,"messageType","CleanupMessage")}},we=class extends w{constructor(t){super();this.customCleanup=t;r(this,"messageType",sn)}};var xe=class extends M{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var Se=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,t,e){this.componentDefinition=n;this.container=t;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,t)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(t)||this.messageHandlers[n].push(t)});r(this,"bindWhen",(n,t,e)=>{if(!e)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let i=this.messageHandlers[n],s=a=>t(a)?(e(a),!0):!1;return i.push(s),()=>{let a=i.indexOf(s);a>-1&&i.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,t)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=t}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(e==null?void 0:e.id)||q.Instance().assignId(n);let i=e!=null&&e.timeout?e==null?void 0:e.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&(this._whenInitiatedReject("timeout_".concat(i," ").concat(this.id)),this.dispose())},i),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 e=n;return this[e.method]?this[e.method](e.content):console.log("method not found ".concat(e.method," on component"),this),!0}let t=this.messageHandlers[n.messageType];if(t&&t.length){let e=!1;return t.forEach(i=>{e=e||i(n)}),e}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=_.down;let t=this.bindWhen(n.replyMessageKey,i=>i.replayToHandler===n.handlerUniqueId,i=>{n.handler(i),t()}),e=n.handler;delete n.handler,this.send(n),n.handler=e}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=_.down;let t;if(n.handler){let e=n;t=this.bindWhen(e.replyMessageKey,i=>i.replayToHandler===e.handlerUniqueId,e.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Ie(n.id,e=>{})),t&&t()}:()=>{}}runDisposeHandlers(){let n=this.messageHandlers.onDispose;n&&n.forEach(t=>{t(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,t,e,i,s){this.myopId=n;this.htmlTagName=t;this.BoundingRect=e;this.offsetTop=i;this.offsetLeft=s;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(t,e){super(t);this.messageToHost=t;this.context=e}};var xt=class{constructor(n,t){this.id=n;this.context=t;r(this,"send",n=>{})}},ze=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let t=n.data?n.data:n.detail;if(!(!t||!t.myop)){let e=t;if(e.direction!==_.down)return;if(e.messageType===y.DisposeMessage){e.destination&&delete this.components[e.destination];return}if(e.messageType===y.InitMessage){let i=e.content.id;if(this.components[i])return;this.components[i]=new xt(i),this.messageToHost(new ye(i));return}if(e.messageType===y.EnvelopedMessage){let i=e,s=i.message;if(e=s,this.alwaysPassEnvelopesToHost||this.components[e.destination]){let a=myop.hostSDK.components.find(p=>p.id===s.destination);if(a){a.send(s);return}let d=myop.hostSDK.components.find(p=>p.id===i.destination);if(d){d.send(s);return}}else return}if(e.messageType){if(e.messageType===y.CleanupMessage){let s=e,a=this.messageCleanupCache[s.cleanupForMessageId],d=new we(!!a);d.destination=e.destination,a?(delete this.messageCleanupCache[s.cleanupForMessageId],rn(a).then(()=>{this.messageToHost(d,s)}).catch(()=>{})):this.messageToHost(d,s);return}let i=!1;this.supportedHandlers.forEach(s=>{if(s.messageType===e.messageType){i=!0;let a=s.executor(e);if(e.cleanable&&a&&(this.messageCleanupCache[e.id]=a),a&&!e.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(s.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&&e.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(s.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,t){this.container=n;this.shadowRoot=t;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var St=o=>o!==Object(o),Vn=o=>typeof o=="function",vt=o=>{if(St(o))return!0;if(Vn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let t=o[n];if(typeof t=="object"){if(!vt(t))return!1}else{if(St(t))continue;return!1}}return!0},F=(o,n={},t=!0,e=new WeakMap)=>{if(St(o))return o;if(Array.isArray(o)){if(e.has(o))return e.get(o);let i=[];e.set(o,i);for(let s=0;s<o.length;s++){let a=o[s];i[s]=F(a,n,t,e)}return i}if(o!==null&&typeof o=="object"){if(e.has(o))return e.get(o);let i={};e.set(o,i);for(let s in o){let a=typeof n=="boolean"?n:n[s];a&&(a===!0?(t?o[s]!==void 0:o[s])&&(i[s]=F(o[s],!0,t,e)):typeof a=="object"&&(i[s]=F(o[s],a,t,e)))}return i}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 ve=class extends z{constructor(t,e,i){super(t,e.container,i);this.componentDefinition=t;this.parent=e;r(this,"send",t=>{let e=t.handler,i=super.send(t);return this.parent.send(new Ce(this.id,t)),t.handler=e,i});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(t){return super.onMessageReceived(t)}};var X=class extends z{constructor(t,e,i,s,a,d){super(t,i,d);this.container=i;this.customElement=s;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",t=>{let e=t.detail;e!=null&&e.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(e.action,e.payload):this._ctaHandler||this._ctaQueue.push({action:e.action,payload:e.payload}))});r(this,"_autoSizeOptions");r(this,"observeAutoSize",t=>{this._autoSizeOptions=t;let e=this.customElement;try{getComputedStyle(e).display==="inline"&&(e.style.display="block")}catch(p){}let i=p=>{if(p===void 0)return;if(typeof p=="number")return p;let c=parseFloat(p);return isNaN(c)?void 0:c},s=(p,c,m)=>c!==void 0&&p<c?c:m!==void 0&&p>m?m:p,a=()=>{var u;let p=this._autoSizeOptions,c=e.getBoundingClientRect(),m=(p==null?void 0:p.explicitHeight)===void 0;(u=p==null?void 0:p.onSizeChange)==null||u.call(p,{width:c.width,height:m?s(c.height,i(p==null?void 0:p.minHeight),i(p==null?void 0:p.maxHeight)):c.height,autoSizingWidth:!1,autoSizingHeight:m})},d;try{d=new ResizeObserver(()=>a()),d.observe(e)}catch(p){}return a(),()=>{d==null||d.disconnect(),this._autoSizeOptions=void 0}});r(this,"cleanupInspect",()=>{});r(this,"send",t=>{let e=super.send(t);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",t),e});r(this,"dispose",()=>{var t;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=s,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=de(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(t){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(t)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(t){if(this._ctaHandler=t,this._ctaQueue.length>0){let e=[...this._ctaQueue];this._ctaQueue=[],e.forEach(i=>{this.markedForDisposed||t(i.action,i.payload)})}}};var jn=(o,n,t)=>{let e=document.createElement("a");return e.textContent=o,e.style.position="relative",e.style.padding="0 5px",e.style.fontSize="14px",e.style.top="0",e.style.top="".concat(n,"px"),e.style.transform="translateX(-50%)",e.target="_blank",e.href="https://dashboard.myop.dev/dashboard/component/".concat(t.id),e},de=(o,n,t,e,i,s)=>{let a=jn("".concat(s.name," : ").concat(n),t,s);return e.insertBefore(a,i),i.style.border="1px solid #007BFF",i.style.display="block",()=>{i.style.border="unset",e.removeChild(a)}},dn=(o,n,t)=>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(t.componentDefinition.name,", ID: ").concat(t.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(t.componentDefinition.id," or consult the developer guide.")),!0),pn=(o,n,t)=>{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(t.componentDefinition.name,", ID: ").concat(t.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(t.componentDefinition.id," or consult the developer guide."))},cn=(o,n,t)=>{let e=n.reduce((s,a)=>L(h({},s),{[a.name]:h({},a)}),{}),i={get:(s,a)=>{let d=e[a];if(dn(d,a,o))return!1;if(d.behavior.type===ae.code){if(o instanceof X)return(d.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(d.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(t.loader.type===A.HTMLLoader&&t.loader.shadowRootMode===Q.localFrame){let c=d.behavior;return o.element.contentWindow[c.remap||a]}return pn(d,a,o),!1}return d.mode==="output"?new Promise(p=>{let c=[];d.behavior.ref&&c.push(U.create(d.behavior.ref)),c.push(u=>{p(u)}),d.behavior.params&&c.push(...d.behavior.params);let m=Le[d.behavior.message];o.send(new m(...c))}):null},set:(s,a,d)=>{let p=e[a];if(dn(p,a,o))return!1;if(p.behavior.type===ae.code){if(o instanceof X){let m=p.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(d),!0;if(m==="myop_init_interface")return o.initWithData(d),!0}if(o instanceof W&&o.isolated){let m=p.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(d),!0;if(m==="myop_init_interface")return o.initWithData(d),!0}if(t.loader.type===A.HTMLLoader&&t.loader.shadowRootMode===Q.localFrame){let m=p.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=d,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.forEach(l=>{o.markedForDisposed||d(l.action,l.payload)})}return!0}return pn(p,a,o),!1}else if(p.mode==="input")if(p.behavior.type==="message"){let c=[];p.behavior.ref&&c.push(U.create(p.behavior.ref)),c.push(d),p.behavior.params&&c.push(...p.behavior.params);let m=Le[p.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(p.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,i),o},Gn=(o,n)=>new Proxy(o,{get(t,e){return t[e]?t[e]:(...s)=>new Promise(a=>{s.forEach(d=>{vt(d)||an.notSerializableRefCall(e,d)}),n.send(new G(({ref:d,propName:p,functionArgs:c,makeSerializable:m})=>{if(d){let u=d[p];return m(typeof u=="function"?d[p](...c):u,!0)}return null},{elementId:t.refConfig.selector,propName:e,functionArgs:s},d=>{a(d.content)}))})},set(t,e,i){return n.send(new G(({ref:s,propName:a,propValue:d})=>{s&&(s[a]=d)},{elementId:t.refConfig.selector,propValue:i,propName:e},s=>{})),!0}}),Et=async(o,n,t,e)=>{let i=o.component;if(!i)throw new Error("cant createRefComponent with detached ref");return new Promise(async(s,a)=>{let d=new ve(n.type,i,e);t.push(d);let p=()=>{let m=t.indexOf(d);m!==-1&&t.splice(m,1)};await i.initiated();let c=setTimeout(()=>{p(),a("timeout")},5e3);i.send(new Me(o.refConfig,n,L(h({},e||{}),{id:d.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){p(),a("CreateRefComponentMessage failed");return}let u=t.find(f=>f.id==d.id);if(u&&u!==d){p(),i.refs[o.refConfig.name]=u,s(u);return}else d.setInitiated(),i.refs[o.refConfig.name]=d;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(E=>E.type.id===f.componentDefinitionId).type,l=new ve(g,d);l.setInitiated(),d.refs[f.refName]=l,t.push(l)});try{await _t(d,n,t,!0),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),s(d)}catch(f){a(f)}}))})},_t=async(o,n,t,e=!1)=>{o.refs||(o.refs={});let i=Object.values(o.componentDefinition.refs).map(s=>new Promise(async(a,d)=>{var p;if(s.behavior.type==re.component){if(e){a();return}let c=s.behavior.componentId;c||(c=s.behavior.instance.componentId);let m=(p=n.instance.resolvedNestedComponents)==null?void 0:p.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=U.create("",s,o);try{let f=await Et(u,m,t);o.refs[s.name]=f,a()}catch(f){d(f)}}else try{let c=U.create("",s,o);o.refs[s.name]=Gn(c,o),a()}catch(c){}}));try{await Promise.all(i)}catch(s){throw s}};var W=class extends z{constructor(t,e,i,s,a){super(t,i,a);this.componentConfig=t;this.container=i;this.IframeElement=s;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 t=this.send(new k(()=>window.document.documentElement.scrollHeight,e=>{this.IframeElement.style.height="".concat(e.content,"px"),t()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:e})=>{let{height:i,width:s}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:d,width:p}=document.documentElement.getBoundingClientRect();e({height:d,width:p})});return a.observe(document.documentElement),a.observe(document.body),{height:i,width:s}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px")})));r(this,"observeAutoSize",t=>{if(this._autoSizeOptions=t,this.isolated)return this._isoSizeOpts=t,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 e=this.IframeElement,i=e.contentDocument;if(!i)return this.observeHeightViaBridge();let s=(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},d=()=>{var Ot,zt,$t,At,Ft,Wt,Kt,Nt;let g=e.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),S=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=(Wt=l==null?void 0:l.explicitHeight)!=null?Wt:H,v=b!==void 0,te=C!==void 0,ne=this.container.getBoundingClientRect(),_n=ne.width===0,Tn=ne.height===0||ne.height===ee,oe=(l!=null&&l.forceAutoSize||_n)&&!v,se=(l!=null&&l.forceAutoSize||Tn)&&!te;if(!oe&&!se){e.style.width=typeof b=="number"?"".concat(b,"px"):"100%",e.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(Kt=l==null?void 0:l.onSizeChange)==null||Kt.call(l,{width:typeof b=="number"?b:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let Rn=e.style.transition,$=this.container,kn=$.style.transition;e.style.transition="none",$.style.transition="none";let kt=e.getBoundingClientRect().height,Ht=e.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,Hn=se&&Dt>kt+1,Dn=oe&&Bt>Ht+1,Re=se&&!Hn,ke=oe&&!Dn;if(Re||ke){let Pn=$.style.minHeight,On=$.style.minWidth;Re&&($.style.minHeight="".concat(kt,"px")),ke&&($.style.minWidth="".concat(Ht,"px")),Re&&(e.style.height="0px"),ke&&(e.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=Pn,$.style.minWidth=On}let Lt=s(ce,E,T),Pt=s(le,N,S);oe?e.style.width="".concat(Lt,"px"):e.style.width=typeof b=="number"?"".concat(b,"px"):"100%",se?e.style.height="".concat(Pt,"px"):e.style.height=typeof C=="number"?"".concat(C,"px"):"100%",e.offsetHeight,e.style.transition=Rn,$.style.transition=kn;let Bn=oe&&T!==void 0&&ce>T,Ln=se&&S!==void 0&&le>S;g.documentElement.style.overflowX=Bn?"auto":"",g.documentElement.style.overflowY=Ln?"auto":"",(Nt=l==null?void 0:l.onSizeChange)==null||Nt.call(l,{width:Lt,height:Pt,autoSizingWidth:oe,autoSizingHeight:se})};d(),this._autoSizeUpdate=d;let p,c=()=>{p===void 0&&(p=requestAnimationFrame(()=>{p=void 0,d()}))},m=new ResizeObserver(()=>c());m.observe(i.body),m.observe(i.documentElement);let u=new MutationObserver(()=>c());u.observe(i.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{m.disconnect(),u.disconnect(),p!==void 0&&(cancelAnimationFrame(p),p=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 t,e=!1,i=()=>{e=!0,t==null||t(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=i,this.initiated().then(()=>{e||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),t=this.send(new Se))}).catch(s=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(s))}),i});r(this,"setSizeBasedOnDocumentElement",()=>{let t=this.send(new k(()=>{let{height:e,width:i}=document.documentElement.getBoundingClientRect();return{height:e,width:i}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px"),t()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let t=this.send(new k(()=>{let i=0;return i++,i--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+i+"px"},e=>{this.IframeElement.style.height=e.content,t()}))});r(this,"send",t=>{var s,a;let e=h({},t);if(e.messageType===y.ExecuteComponentMethod)return this[e.method](),()=>{};e.direction=_.down;let i=super.send(e);return(a=(s=this.IframeElement)==null?void 0:s.contentWindow)==null||a.postMessage(e,"*"),i});r(this,"dispose",()=>{var t,e;(t=this._bridgeSizeCleanup)==null||t.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(),(e=this.IframeElement.parentNode)==null||e.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=t=>{if(t.source!==this.IframeElement.contentWindow)return;let e=t.data;!e||e.__myop!==!0||(e.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(e.action,e.payload):this._ctaHandler||this._ctaQueue.push({action:e.action,payload:e.payload}):e.type==="myop:size"&&this._applyIsoSize(e.height,e.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(t){var e,i;this._lastData=t,(i=(e=this.IframeElement)==null?void 0:e.contentWindow)==null||i.postMessage({__myop:!0,type:"myop:init",data:t},"*")}getData(){return this._lastData}setCtaHandler(t){if(this._ctaHandler=t,this._ctaQueue.length>0){let e=[...this._ctaQueue];this._ctaQueue=[],e.forEach(i=>{this.markedForDisposed||t(i.action,i.payload)})}}_applyIsoSize(t,e){var c;if(!t||Number.isNaN(t)||(this._isoLastSize={height:t,width:e},!this._isoAutoSize))return;let i=this._isoSizeOpts,s=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),a=s(i==null?void 0:i.minHeight),d=s(i==null?void 0:i.maxHeight),p=t;a!==void 0&&p<a&&(p=a),d!==void 0&&p>d&&(p=d),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=p+"px",this.IframeElement.style.width="100%",(c=i==null?void 0:i.onSizeChange)==null||c.call(i,{width:e!=null?e:this.IframeElement.clientWidth,height:p,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=de(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(t){return t.messageType===y.In.MutationObserverMessage||t.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(t)}};var V=class{constructor(){r(this,"appendChild",(n,t,e)=>{var i;if(e!=null&&e.relative){if(e.relative.direction==="before")return n.insertBefore(t,e.relative.child);if(e.relative.direction==="after"){let s=(i=e.relative.child)==null?void 0:i.nextSibling;return n.insertBefore(t,s||null)}}else return n.appendChild(t)})}};var Yn=(o,n,t)=>{let e=new URL(o);return e.searchParams.append(n,t),e.toString()},Fe=class extends V{constructor(){super(...arguments);r(this,"type",A.IframeLoader);r(this,"load",async(t,e,i,s)=>{let a,d=e.loader;if((i==null?void 0:i.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",d.url,i),a=i,a.src=d.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(d.autoHeight||!d.height?"100%":d.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(s!=null&&s.hidden?"0":"1",";\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n ");a.style.cssText=u,s!=null&&s.elementAttributes&&Object.entries(s.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=e.loader.url;s!=null&&s._hasParent&&(f=Yn(f,"_myop-comp",c)),a.src=f,i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),a=this.appendChild(i,a,s)}let p=new W(t,e,i,a,s);return d.autoHeight&&(s==null?void 0:s.autoSize)!==!1&&p.observeHeightViaBridge(),p})}};var We={webcomponent_message_key:"myop_webcomponent_message"};var pe=class extends z{constructor(t,e,i,s,a){super(t,i,a);this.container=i;this.customElement=s;r(this,"cleanupInspect",()=>{});r(this,"send",t=>{let e=h({},t),i=super.send(e),s=new CustomEvent(We.webcomponent_message_key,{detail:e});try{this.customElement.dispatchEvent(s)}catch(a){console.log("error while trying to dispatchEvent",a)}return i});r(this,"dispose",()=>{var t;super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=s}inspect(){return this.cleanupInspect=de(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={},Ke=class extends V{constructor(){super(...arguments);r(this,"type",A.WebComponentLoader);r(this,"load",async(t,e,i,s)=>{let a=e.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 d="myop-comp-".concat(R()),p=document.createElement(a.tag);return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),p.id=d,s!=null&&s.hidden&&(p.style.opacity="0",p.style.position="absolute",p.style.height="0",p.style.width="0",p.style.pointerEvents="none",p.style.visibility="hidden"),s!=null&&s._environment&&(p._myopEnvironment=s==null?void 0:s._environment),this.appendChild(i,p,s),new pe(t,e,i,p,s)})}};var ln="0.4.0-beta.5";var Qn="myop-delivery",qe="components";var Ne=null;function Jn(){return Ne||(Ne=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(Qn,1);n.onupgradeneeded=()=>{let t=n.result;t.objectStoreNames.contains(qe)||t.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 Jn().then(t=>new Promise(e=>{if(!t)return e(null);try{let i=t.transaction(qe,o),s=n(i.objectStore(qe));s.onsuccess=()=>e(s.result),s.onerror=()=>e(null),i.onabort=()=>e(null)}catch(i){e(null)}}))}var Rt="myop.d.";function mn(o,n,t){try{localStorage.setItem(Rt+o,JSON.stringify({t:n,e:t}))}catch(e){}}function Xn(o){try{localStorage.removeItem(Rt+o)}catch(n){}}var Ee=new Map,P={key(o,n,t,e,i){return"".concat(o,"|").concat(n,"|").concat(t,"|").concat(e?"preview":"live","|").concat(i||"raw")},async get(o){let n=Ee.get(o);if(n)return n;let t=await Ue("readonly",e=>e.get(o));return t&&(Ee.set(o,t),mn(o,t.tag,t.storedAt+t.windowMs)),t},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),Xn(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 t=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!t)return 0;let e=Number(t[1]),i=Number(o.get("age")||0);return Math.max(0,e-(isNaN(i)?0:i))*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 un=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__",Zn=()=>{if(typeof window<"u")return window[Ve];if(typeof globalThis<"u")return globalThis[Ve]},eo=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=Zn();return n||(O._main||(O._main=new O,eo(O._main)),O._main)}static sizeOfHeld(n){var t,e,i,s,a;try{return(((a=(s=(i=(e=(t=n==null?void 0:n.config)==null?void 0:t.type)==null?void 0:e.skins)==null?void 0:i[0])==null?void 0:s.loader)==null?void 0:a.HTML)||"").length}catch(d){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,t){let e=this._localServes.get(n);e?e.count++:this._localServes.set(n,{env:t,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(([t,e])=>"".concat(t,":").concat(e.env,":").concat(e.count)).join(",");this._localServes.clear();try{let t="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(t,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(t){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var s;this._localServes.size&&this.flushLocalServes();let t=this.deliveryHost(),e="".concat(t).concat(n);this._deliveryStats.requests++;let i=t!==this._baseUrl;try{let a=await fetch(e);if(a.ok||a.status<500||!i)return i&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(t)}catch(a){if(!i)throw a;this._deliveryStats.lastError=String((s=a==null?void 0:a.message)!=null?s: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,t,e){return t!==void 0||e!==void 0?"".concat(n,":").concat(t||this._defaultEnv,":").concat(e?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,t,e){return this.fetchComponentV2(n,t,e)}async fetchComponentV2(n,t,e){let{env:i,usePreview:s,cacheKey:a}=this.resolveParams(n,t,e);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:i,usePreview:s,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:i,preview:s}),this.variants[a]=new Promise(async(d,p)=>{try{let c;if(this._staticMode){let N=s?"preview":i;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(N,".json");let S=new URLSearchParams(this._queryParams).toString();S&&(c+="?".concat(S))}else c="/consume?id=".concat(n,"&env=").concat(i),s&&(c+="&preview=true"),this._delivery.minify&&!s&&(c+="&opt=min");let m=this._delivery.cache&&!this._staticMode&&!s,u=m?P.key(this.deliveryHost(),n,i,s,this._delivery.minify?"min":"raw"):"",f=m?await P.get(u):null;if(f&&P.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,i),this.variants[a].resolved=f.config,d(f.config);return}if(f&&f.tag){let N="/consume?ids=".concat(n,"&env=").concat(i)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let S=await this.deliveryFetch(N);if(S.ok){let ee=await S.json();if((ee.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=O.sizeOfHeld(f),f.storedAt=Date.now(),f.windowMs=P.windowFrom(S.headers)||f.windowMs,await P.put(f),this.variants[a].resolved=f.config,d(f.config);return}let j=(ee.items||[])[0];if(j){let H=un(j);this._deliveryStats.fromNetwork++,await P.put({key:u,config:H,tag:j.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(S.headers),host:this.deliveryHost()}),this.variants[a].resolved=H,d(H);return}}}catch(S){}}let g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){p(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){p(new Error('Component "'.concat(n,'" not found')));return}if(!E.consume_variant||!E.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(i,'"')));return}let T=un(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,d(T)}catch(c){delete this.variants[a],p(c)}})),await this.variants[a]}getResolvedConfig(n,t,e){var s;let{cacheKey:i}=this.resolveParams(n,t,e);return((s=this.variants[i])==null?void 0:s.resolved)||null}resolveParams(n,t,e){let i=this.preloadedComponents[n],s=t!==void 0||e!==void 0,a,d;if(!s&&i)a=i.env,d=i.preview;else{a=t||this._defaultEnv;let p=t||this._envExplicitlySet;d=e===!0?!0:e===!1?!1:!p}return{env:a,usePreview:d,cacheKey:"".concat(n,":").concat(a,":").concat(d?"preview":"live")}}hydrateComponent(n,t,e,i){let{env:s,usePreview:a,cacheKey:d}=this.resolveParams(n,e,i),p=Promise.resolve(t);p.resolved=t,this.variants[d]=p,this.preloadedComponents[n]={env:s,preview:a}}async fetchComponentV1(n,t){return t?(await this.fetchFlow(t)).components.find(i=>i.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();t(s.item)}catch(i){delete this.userFlows[n],e(i)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();t(s.item)}catch(i){delete this.userFlows[n],e(i)}})),await this.userFlows[n]}async fetchComponent(n,t){return this.fetchComponentV1(n,t)}};r(O,"_main",null),r(O,"DEFAULT_HOST","https://cloud.myop.dev");var Z=O;var je=Z.Main;var to="https://delivery.myop.dev",fn=(o={})=>{var t,e;let n=o.minify!==!1||o.cache===!0;return je.setDelivery({minify:(t=o.minify)!=null?t:!1,cache:(e=o.cache)!=null?e:!1,host:o.host!==void 0?o.host:n?to: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(t,e){super(t);this.context=e;r(this,"executor",t=>{if(t.destination){let e=t.destination;if(this.context[e].context){let i=(s,a)=>{this.messageToHost(L(h({},s),{source:t.destination?t.destination:t.source,destination:t.source?t.source:t.destination}),a)};return this.innerExecutor(t,this.context[e].context,i)}else debugger}else debugger})}};var K={id:"myop-id"};var B=(o,n)=>n.querySelectorAll("[".concat(K.id,"='").concat(o.refConfig.selector,"']"));var Ge=class extends I{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(t,e,i)=>{let s=B(t.ref,e.shadowRoot),a=[];return s.forEach(d=>{let p=()=>{i(new me(t.handlerUniqueId))};d.addEventListener("click",p),a.push(()=>{d.removeEventListener("click",p)})}),()=>{a.forEach(d=>d())}})}};var Ye=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(t,e)=>{B(t.ref,e.shadowRoot).forEach(s=>{s.textContent=t.content})})}};var Qe=class extends $e{constructor(t,e){super(t,e);this.container=t;this.shadowRoot=e}};var Je=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(t,e)=>{let i=e.shadowRoot.querySelectorAll("[".concat(K.id,"]")),s=[];i.forEach(a=>{let d=a.getAttribute(K.id);d&&s.push(new Pe(d,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new be(t.handlerUniqueId,s))});r(this,"messageType",y.DetectMyopRefsMessage)}};var Xe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(t,e)=>{B(t.ref,e.shadowRoot).forEach(s=>{s.setAttribute(t.name,t.value)})})}};var Ze=class extends I{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(t,e,i)=>{let s=B(t.ref,e.shadowRoot),a=[];return s.forEach(d=>{let p=c=>{i(new fe(t.handlerUniqueId,F(c,t.serializableSkeleton)))};d.addEventListener(t.type,p),a.push(()=>{d.removeEventListener(t.type,p)})}),()=>{a.forEach(d=>d())}})}};var et=class extends I{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(t,e,i)=>{(async()=>{let a=e.shadowRoot.querySelectorAll("[".concat(K.id,"='").concat(t.refConfig.selector,"']"));if(a.length===1){let d=q.Instance(),p=d.components.find(f=>f.id===t.options.id);p&&p.dispose();let c=d.components.indexOf(p);c!==-1&&d.components.splice(c,1);let m=await d.loadComponent(t.nestedComponentConfig,a.item(0),t.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})}),i(new ie(t.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new ie(t.handlerUniqueId,[],!0));debugger}})().then()})}};var hn=(o,n,t)=>{let e=o.scriptInputs?o.scriptInputs:{};e.makeSerializable=F,e.send=n,e.rootRef=t,e.__scriptInputs=e;let s=new Function("return (".concat(o.script,")(...arguments)"))(e);n(s)};var tt=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(t,e,i)=>{hn(t,a=>{i(new ue(t.handlerUniqueId,a))},e)})}};var Mn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),t={formData:{},unmappedData:[]},e=o.querySelectorAll("input, select, textarea"),i=-1;return e.forEach(s=>{if(typeof s.value=="string"){let a=s.getAttribute(K.id),d=s.getAttribute("name"),p={id:s.id,name:d,value:Mn(s),required:s.required,validity:F(s.validity,!0),myopId:a};d?t.formData[d]?t.formData[d].value?t.unmappedData.push(p):(t.unmappedData.push(t.formData[d]),t.formData[d]=p):t.formData[d]=p:t.unmappedData.push(p)}}),t}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",(t,e,i)=>{B(t.ref,e.shadowRoot).forEach(a=>{i(new ge(Mn(a)),t)})})}};var ot=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(t,e)=>{B(t.ref,e.shadowRoot).forEach(s=>{s.innerHTML=t.content})})}};var Te=class extends ze{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(t,e)=>{t.addEventListener(We.webcomponent_message_key,i=>{let s=i.data?i.data:i.detail;if(!s||!s.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=s;if(this.handleIncomeMessages(i),a.messageType===y.InitMessage){let d=a.content.id;this.components[d].context=new Qe(t,e)}}}),setTimeout(()=>{this.messageToHost(new he)},1)});r(this,"messageToHost",(t,e)=>{t.direction=_.up,!t.replayToHandler&&(e!=null&&e.handlerUniqueId)&&(t.replayToHandler=e.handlerUniqueId),window.myop.hostSDK.send(t)});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 no="<!-- myop-web-component -->",In="myop-web-component",wn=new Map,xn=[],st,Sn=async()=>(st||(st=new Te,st.init()),st);function oo(o,n){return class extends HTMLElement{connectedCallback(){let t=n===Q.open?"open":"closed",e=this.attachShadow({mode:t});Sn().then(i=>{i.connectedCallback(this,e),e.innerHTML=o})}}}var so=(o,n,t)=>{customElements.define(o,oo(n,t)),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(t,e,i,s)=>{let a=e.loader,d=this.isMyopWebComponent(a.HTML),{mode:p,isolate:c}=await this.resolveRenderMode(t,e,a,d,s);if(p===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(t.id,'"'));if(d){if(p!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(t.id,'"'));return this.loadExtractedWebComponent(t,e,i,a.HTML,s)}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(s!=null&&s.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n "),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),l=this.appendChild(i,l,s);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 v=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(v)try{N=JSON.parse(v.getAttribute("content")||"{}")}catch(te){}}let S=a.HTML;if(s!=null&&s._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),v=C.getElementById("myop_preview");v==null||v.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),S="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((s==null?void 0:s.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),v=C.getElementById("myop_preview");v&&(v.remove(),S="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(s!=null&&s.injectCss){let C=new DOMParser().parseFromString(S,"text/html"),v=C.createElement("style");v.setAttribute("data-myop-injected","true"),v.textContent=s.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(v),S="<!DOCTYPE html>"+C.documentElement.outerHTML}T.writeln(S);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&&(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null){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(s.data).replace(/<\/script/gi,"\\u003c/script"),v='<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+v)}if(c){let b=(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null?JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";T.writeln(this.buildIsolationBridge(b))}T.close();let H=new W(t,e,i,l,s);return c&&H.enableIsolation(),H.sizeMeta=N,H.initiated().then(()=>{if((s==null?void 0:s.autoSize)===!1)return;let b=!1;H.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!b&&!(s!=null&&s.hidden)&&(b=!0,H.show())}})}),H}if(a.shadowRootMode===Q.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,Sn().then(g=>{g.connectedCallback(u,u)})}else{let f=ro(t.name+e.id);xn.includes(f)||(so(f,a.HTML,a.shadowRootMode),xn.push(f)),u=document.createElement(f)}return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),u.id=m,s!=null&&s.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(i,u,s),new pe(t,e,i,u,s)})}isMyopWebComponent(t){return t.trimStart().startsWith(no)?!0:new RegExp("<script[^>]*\\sid=[\"']?".concat(In,"[\"'\\s>]"),"i").test(t)}async resolveRenderMode(t,e,i,s,a){var m,u,f,g;let d=s?"webComponent":i.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",p=(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=p?await p({componentDefinition:t,skin:e,requestedMode:d,isWebComponent:s}):d;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(t){return"<script>\n (function () {\n var __initial = ".concat(t,";\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(t){let s=new DOMParser().parseFromString(t,"text/html").getElementById(In);return(s==null?void 0:s.textContent)||null}executeWebComponentScript(t,e){let i=wn.get(e);if(i)return console.log("[MyopWebComponent] Script already executed for ".concat(e,", reusing <").concat(i,">")),i;let s=document.createElement("script");s.textContent=t,s.id="myop-extracted-".concat(e),document.head.appendChild(s);let a=window.__MYOP_TAG_NAME__;return a&&wn.set(e,a),console.log("[MyopWebComponent] Executed web component script: ".concat(e," -> <").concat(a,">")),a}async loadExtractedWebComponent(t,e,i,s,a){let d=this.extractWebComponentScript(s);if(!d)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let p="".concat(t.id,"-").concat(e.id),c=this.executeWebComponentScript(d,p);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"),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML="");let f=new X(t,e,i,u,c,a);return this.appendChild(i,u,a),(a==null?void 0:a.data)!==void 0&&(a==null?void 0:a.data)!==null&&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),e=new URLSearchParams(n.search).get("myopOverride");if(e){let[i,...s]=dt(e);switch(i){case"component":{let[a,d]=s,p=await Z.Main.fetchComponent(a);if(p&&p.type.skins.find(m=>m.id===d))return p.instance.skinSelector={type:J.Dedicated,skin:{id:d}},p}break;default:{let[a,d]=dt(e),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===d);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 En="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 t=e=>{let i=e.element;return(i==null?void 0:i.nodeName)==="IFRAME"&&i.contentWindow===n};return this.components.some(t)||this.components2init.some(t)});r(this,"incomingMessageHandler",n=>{var t;if((t=n.data)!=null&&t.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==_.up&&n.data.messageType!==y.EnvelopedMessage)return;let e=n.data;if(e.messageType===y.InitRequest){let s=this.components2init.filter(d=>{let p=d.element;return(p==null?void 0:p.nodeName)==="IFRAME"&&p.contentWindow===n.source});(s.length?s:this.components2init).forEach(d=>{d.send(new Y(d.id))});return}if(e.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==e.content.id);let s=this.components.find(a=>{var d;return a.id===((d=e.content)==null?void 0:d.id)});s==null||s.setInitiated();return}if(e.messageType===y.EnvelopedMessage){let s=e,a=this.components.find(d=>d.id===s.destination);if(a){if(s.direction===_.down){s.message.messageType===D.name?a.onMessageReceived(s.message):(s.message.route=s.route,a.send(s.message));return}}else{let d=this.components.find(p=>p.id===s.message.destination);d&&d.send(s.message)}return}let i=this.components.find(s=>s.id===e.destination);if(!i){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(i){if(i.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});r(this,"send",n=>{let t=new MessageEvent("",{data:n});this.incomingMessageHandler(t)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let t=[new Fe,new Ke,new it];this.componentsLoaders=[...t],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 t={};n.forEach(e=>{let i=new e(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(e=>{t[e.type]||(t[e.type]=e)}),this.componentsLoaders=Object.values(t)});r(this,"_getSkinIdBySkinSelector",async(n,t=[],e)=>{var s;async function i(a,d){for(let p of a)if(await d(p))return p}switch(n.type){case"DedicatedSkin":case J.Dedicated:return((s=n.skin)==null?void 0:s.id)||n.skins[0].id;case J.Segmented:{let d=await i(n.segments,async p=>{if(p.segmentId==="Default")return!0;let c=t.find(g=>g.type===Ae.Segment?g.segment.id===p.segmentId:!1);if(!c)throw new Error("experience not found");let u=c.segment,f=(e||{})[u.function];return f?await f():(console.warn("segmentId:".concat(p.segmentId,", ").concat(u.function," function not provided !")),!1)});if(d)return this._getSkinIdBySkinSelector(d.skinSelector,t);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,t)=>{let e=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,t);return n.type.skins.find(i=>i.id===e)});r(this,"loaderHooks");r(this,"loadComponent",async(n,t,e)=>{var m,u,f,g;if(!t){debugger;throw new Error("no container was found for this component")}let i=await vn(n);i&&(n=i);let s=h(h({},(m=this.loaderHooks)!=null?m:{}),(u=e==null?void 0:e.hooks)!=null?u:{}),a=t;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,s);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=e==null?void 0:e.hooks)!=null&&f.afterSkinSelected&&(l=await e.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:J.Dedicated,skin:l},e&&(e=h({},e),delete e.hooks),await Et(a,n,this.components,e)}else throw new Error("load component got a detached ref.");t=t;let d=await this.runSkinSelector(n,s);if(!d)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=e==null?void 0:e.hooks)!=null&&g.afterSkinSelected&&(d=await e.hooks.afterSkinSelected(h({},d)));let p=this.componentsLoaders.find(l=>l.type===d.loader.type);if(!p){debugger;throw new Error('no loader "'.concat(d.loader.type,'" was found for component'))}let c=await p.load(n.type,d,t,e);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)),(!e||e.connectProps!==!1)&&(c=cn(c,n.type.props,d));try{await _t(c,n,this.components)}catch(l){throw l}return e!=null&&e.skipInit||await c.initiated(),c});r(this,"navigate",async(n,t,e)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(e!=null&&e.staged){let i=await this.loadComponent(t,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},e));return e.init&&await e.init(i),i.show(),n.dispose(),i}else{let i=n.element.nextSibling;return n.dispose(),this.loadComponent(t,n.container,h({relative:{direction:"before",child:i}},e))}})}};r(q,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:En});if(!window.myop.hostSDK){let o=new q;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:En}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>fn(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};
@@ -1045,6 +1045,67 @@ var MyopExtractedWebComponent = class extends BaseMyopComponent {
1045
1045
  this._ctaQueue.push({ action: detail.action, payload: detail.payload });
1046
1046
  }
1047
1047
  });
1048
+ __publicField(this, "_autoSizeOptions");
1049
+ /**
1050
+ * Data-out for size — the extracted counterpart of the iframe implementation.
1051
+ *
1052
+ * THIS EXISTED ONLY ON MyopIframeComponent, and that was invisible for as long as
1053
+ * minification was sending every v2 component down the iframe path. Restoring v2
1054
+ * detection moves them to this class, and `@myop/react` drives both through one
1055
+ * wrapper: in content mode it hides its loader from the FIRST onSizeChange, so a
1056
+ * component whose class has no observeAutoSize leaves a React host on a loader
1057
+ * forever. Pic-Time's sizeMeta is width:100% with no height, which is exactly content
1058
+ * mode. Caught by v2-data-contract D8 (API parity).
1059
+ *
1060
+ * It REPORTS rather than imposes. An iframe has no intrinsic size and must be
1061
+ * measured inside and then set from outside; a custom element sizes itself from its
1062
+ * own content, so the honest thing is to measure it and tell the host, and let the
1063
+ * host decide. React then uses width:100% and the measured height.
1064
+ *
1065
+ * The one thing it does impose is `display: block` when the element computes to
1066
+ * `inline`, which is the default for a custom element and measures as zero height no
1067
+ * matter what it contains. The iframe path forces width:100% for the same reason —
1068
+ * without it the first measurement is 0 and the host sizes the component to nothing.
1069
+ */
1070
+ __publicField(this, "observeAutoSize", (options) => {
1071
+ this._autoSizeOptions = options;
1072
+ const el = this.customElement;
1073
+ try {
1074
+ if (getComputedStyle(el).display === "inline") el.style.display = "block";
1075
+ } catch (e) {
1076
+ }
1077
+ const parse = (v) => {
1078
+ if (v === void 0) return void 0;
1079
+ if (typeof v === "number") return v;
1080
+ const n = parseFloat(v);
1081
+ return isNaN(n) ? void 0 : n;
1082
+ };
1083
+ const clamp = (v, min, max) => min !== void 0 && v < min ? min : max !== void 0 && v > max ? max : v;
1084
+ const report = () => {
1085
+ var _a;
1086
+ const opts = this._autoSizeOptions;
1087
+ const rect = el.getBoundingClientRect();
1088
+ const autoHeight = (opts == null ? void 0 : opts.explicitHeight) === void 0;
1089
+ (_a = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _a.call(opts, {
1090
+ width: rect.width,
1091
+ height: autoHeight ? clamp(rect.height, parse(opts == null ? void 0 : opts.minHeight), parse(opts == null ? void 0 : opts.maxHeight)) : rect.height,
1092
+ autoSizingWidth: false,
1093
+ // a web component fills its container's width
1094
+ autoSizingHeight: autoHeight
1095
+ });
1096
+ };
1097
+ let ro;
1098
+ try {
1099
+ ro = new ResizeObserver(() => report());
1100
+ ro.observe(el);
1101
+ } catch (e) {
1102
+ }
1103
+ report();
1104
+ return () => {
1105
+ ro == null ? void 0 : ro.disconnect();
1106
+ this._autoSizeOptions = void 0;
1107
+ };
1108
+ });
1048
1109
  __publicField(this, "cleanupInspect", () => {
1049
1110
  });
1050
1111
  /**
@@ -2046,7 +2107,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
2046
2107
  };
2047
2108
 
2048
2109
  // version:myop-sdk-version
2049
- var myop_sdk_version_default = "0.4.0-beta.3";
2110
+ var myop_sdk_version_default = "0.4.0-beta.5";
2050
2111
 
2051
2112
  // src/helpers/deliveryStore.ts
2052
2113
  var DB_NAME = "myop-delivery";
@@ -3230,14 +3291,14 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
3230
3291
  if (!isolate) {
3231
3292
  doc.writeln("".concat(sdkScript).concat(initScript));
3232
3293
  }
3233
- if (!isolate && (options == null ? void 0 : options.data) !== void 0) {
3294
+ if (!isolate && (options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null) {
3234
3295
  const ctaQueueScript = "<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>";
3235
3296
  const escapedData = JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script");
3236
3297
  const dataScript = '<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(escapedData, ";\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>");
3237
3298
  doc.writeln(ctaQueueScript + dataScript);
3238
3299
  }
3239
3300
  if (isolate) {
3240
- const escapedData = (options == null ? void 0 : options.data) !== void 0 ? JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script") : "undefined";
3301
+ const escapedData = (options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null ? JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script") : "undefined";
3241
3302
  doc.writeln(this.buildIsolationBridge(escapedData));
3242
3303
  }
3243
3304
  doc.close();
@@ -3292,10 +3353,29 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
3292
3353
  });
3293
3354
  }
3294
3355
  /**
3295
- * Detect if HTML is a Myop Web Component (starts with marker comment)
3356
+ * Detect if HTML is a Myop Web Component.
3357
+ *
3358
+ * THE MARKER COMMENT ALONE IS NOT A SAFE SIGNAL, BECAUSE MINIFIERS DELETE COMMENTS.
3359
+ *
3360
+ * This used to be `startsWith(MYOP_WEB_COMPONENT_MARKER)` and nothing else. The
3361
+ * delivery lane minifies with `removeComments: true` (myop-server derive.ts MIN_CFG),
3362
+ * so the stored `min` artifact of every v2 web component loses its leading
3363
+ * `<!-- myop-web-component -->`. Detection then returned false, the component fell
3364
+ * back to plain iframe rendering, and the whole authored document was shown --
3365
+ * including the v2 authoring wrapper, so Pic-Time's production dashboard displayed the
3366
+ * preview chrome ("Web Component v2", a tag-name badge reading `loading...`, SIZE /
3367
+ * OVERFLOW / BG controls) instead of their component. Reported 2026-10-18; the served
3368
+ * HTML measured 328,071 bytes against 951,130 at origin, with zero `<!--` left in it.
3369
+ *
3370
+ * The script id is the signal that survives, and it is the one `extractWebComponentScript`
3371
+ * already depends on: if that element is present, extraction works, so detection
3372
+ * should agree. Checked with a regex rather than DOMParser -- this runs for every
3373
+ * HTML component, and parsing a 300 KB document to answer a yes/no question is not
3374
+ * worth it.
3296
3375
  */
3297
3376
  isMyopWebComponent(html) {
3298
- return html.trimStart().startsWith(MYOP_WEB_COMPONENT_MARKER);
3377
+ if (html.trimStart().startsWith(MYOP_WEB_COMPONENT_MARKER)) return true;
3378
+ return new RegExp("<script[^>]*\\sid=[\"']?".concat(MYOP_WEB_COMPONENT_SCRIPT_ID, "[\"'\\s>]"), "i").test(html);
3299
3379
  }
3300
3380
  /**
3301
3381
  * Resolve how this component should render, applying the host render policy.
@@ -3390,7 +3470,6 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
3390
3470
  if (!container.querySelector('[id^="myop-comp-"]')) {
3391
3471
  container.innerHTML = "";
3392
3472
  }
3393
- this.appendChild(container, element, options);
3394
3473
  const component = new MyopExtractedWebComponent(
3395
3474
  componentDefinition,
3396
3475
  skin,
@@ -3399,7 +3478,8 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
3399
3478
  tagName,
3400
3479
  options
3401
3480
  );
3402
- if ((options == null ? void 0 : options.data) !== void 0) {
3481
+ this.appendChild(container, element, options);
3482
+ if ((options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null) {
3403
3483
  component.initWithData(options.data);
3404
3484
  }
3405
3485
  console.log("[MyopWebComponent] Loaded <".concat(tagName, "> into container"));