@myop/sdk 0.3.20 → 0.3.22

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 (30) hide show
  1. package/dist/cjs/{_IframeSDK.63faba1b.js → _IframeSDK.4a7ea89d.js} +44 -10
  2. package/dist/cjs/_IframeSDK.4a7ea89d.js.map +7 -0
  3. package/dist/cjs/_IframeSDK.fe8716bb.min.js +1 -0
  4. package/dist/cjs/{_WebComponentSDK.8f19258f.js → _WebComponentSDK.0579265f.js} +44 -10
  5. package/dist/cjs/{_WebComponentSDK.8f19258f.js.map → _WebComponentSDK.0579265f.js.map} +2 -2
  6. package/dist/cjs/_WebComponentSDK.11b0056f.min.js +1 -0
  7. package/dist/cjs/{_hostSDK.a5f727f5.js → _hostSDK.279d5ccb.js} +44 -10
  8. package/dist/cjs/{_hostSDK.a5f727f5.js.map → _hostSDK.279d5ccb.js.map} +2 -2
  9. package/dist/cjs/_hostSDK.eb048156.min.js +1 -0
  10. package/dist/cjs/myop_sdk.js +16 -16
  11. package/dist/cjs/myop_sdk.js.map +1 -1
  12. package/dist/cjs/myop_sdk.min.js +1 -1
  13. package/dist/cjs-bundled/myop_sdk.bundled.js +45 -11
  14. package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
  15. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  16. package/dist/module/Iframe/index.js +45 -11
  17. package/dist/module/Iframe/index.js.map +2 -2
  18. package/dist/module/SDK.js +45 -11
  19. package/dist/module/SDK.js.map +2 -2
  20. package/dist/module/embeddedSDK.js +1 -1
  21. package/dist/module/host/embeddedSDK.js +1 -1
  22. package/dist/module/host/index.js +45 -11
  23. package/dist/module/host/index.js.map +2 -2
  24. package/dist/module/webcomponent/index.js +45 -11
  25. package/dist/module/webcomponent/index.js.map +2 -2
  26. package/package.json +6 -54
  27. package/dist/cjs/_IframeSDK.63faba1b.js.map +0 -7
  28. package/dist/cjs/_IframeSDK.a00fcd4b.min.js +0 -1
  29. package/dist/cjs/_WebComponentSDK.03cdf3cf.min.js +0 -1
  30. package/dist/cjs/_hostSDK.1c0fe5db.min.js +0 -1
@@ -1 +0,0 @@
1
- var Nt=Object.defineProperty,bn=Object.defineProperties;var wn=Object.getOwnPropertyDescriptors;var Wt=Object.getOwnPropertySymbols;var Sn=Object.prototype.hasOwnProperty,En=Object.prototype.propertyIsEnumerable;var at=(o,n,e)=>n in o?Nt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Sn.call(n,e)&&at(o,e,n[e]);if(Wt)for(var e of Wt(n))En.call(n,e)&&at(o,e,n[e]);return o},P=(o,n)=>bn(o,wn(n));var Tn=(o,n)=>{for(var e in n)Nt(o,e,{get:n[e],enumerable:!0})};var i=(o,n,e)=>at(o,typeof n!="symbol"?n+"":n,e);var te=class{constructor(n,e,t,s,r){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var Ut=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},M=class{constructor(n){this.messageToHost=n}},Te=class extends M{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var u={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 ve={};Tn(ve,{AddEventListenerMessage:()=>lt,BaseMyopMessage:()=>C,BindClickMessage:()=>ct,ChangeTextMessage:()=>mt,CleanupMessage:()=>Ie,CleanupReplayMessage:()=>xe,ClickReplayMessage:()=>W,CreateRefComponentMessage:()=>ye,CustomRefMessage:()=>U,DetectMyopRefsMessage:()=>yt,DetectedMyopRefsMessage:()=>j,DisposeMessage:()=>be,ElementValueReplayMessage:()=>V,EnvelopedMessage:()=>he,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>H,ExecuteScriptMessage:()=>_,ExecuteScriptReplyMessage:()=>N,GetAttributeMessage:()=>ht,GetAttributeReplayMessage:()=>Me,GetElementValueMessage:()=>ut,InitMessage:()=>ne,InitRequest:()=>G,InitResponse:()=>ge,MessageDirection:()=>w,MutationObserverMessage:()=>Ce,MyopBindMessage:()=>E,MyopBindReplayMessage:()=>S,MyopElementMessage:()=>dt,Ref:()=>z,RefComponentCreatedMessage:()=>O,ResizeObserverMessage:()=>we,SetAttributeMessage:()=>ft,SetInnerHtml:()=>gt,SetMutationObserverMessage:()=>Mt,SetResizeObserverMessage:()=>Ct,stripFunction:()=>jt});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var vn=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Rn=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var pt=o=>{let n=Rn(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(vn(n.slice(t,t+16)));return e};var qt=o=>new Promise(n=>setTimeout(n,o));var w=class{};i(w,"down","down"),i(w,"up","up");var C=class{constructor(){i(this,"id",R());i(this,"myop",!0);i(this,"content");i(this,"source");i(this,"destination");i(this,"route");i(this,"ref");i(this,"direction");i(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},dt=class extends C{constructor(e){super();this.ref=e}},S=class extends C{constructor(e){super();this.replayToHandler=e}},E=class extends C{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",R())}},z=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=P(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var Vt="ClickReplayMessage",ct=class extends E{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",Vt);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},W=class extends S{constructor(){super(...arguments);i(this,"messageType",Vt)}};var mt=class extends C{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}};var Gt="ExecuteScriptReplyMessage",_n=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,kn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,jt=o=>{let n=o.match(_n);if(n)return n[1]||n[3];{let e=o.match(kn);if(e)return e[1].trim()}},_=class extends E{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",Gt);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=jt(this.content)}};i(_,"replierKey","send"),i(_,"completeStreamKey","completeStream");var N=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",Gt)}};var U=class extends _{constructor(e,t,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:d})=>{let m=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(d.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=P(h({},t),{_script:e.toString()})}};var Yt="EventListenerCallbackMessage",lt=class extends E{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",Yt);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},q=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",Yt);this.content={e:t}}};var ft=class extends C{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}};var Qt="ElementValueReplayMessage",ut=class extends E{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",Qt);i(this,"messageType","GetElementValueMessage")}},V=class extends S{constructor(e){super();this.content=e;i(this,"messageType",Qt)}};var gt=class extends C{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}};var ne=class extends C{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ge=class extends ne{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},G=class extends C{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var Jt="RefComponentCreatedMessage",ye=class extends E{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",Jt);i(this,"messageType","CreateRefComponentMessage")}},O=class extends S{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",Jt)}};var he=class extends C{constructor(e,t){super();this.destination=e;this.message=t;i(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var Xt="DetectedMyopRefsMessage",yt=class extends E{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",Xt)}},j=class extends S{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",Xt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var Zt="GetAttributeReplayMessage",ht=class extends E{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",Zt);i(this,"messageType","GetAttributeMessage")}},Me=class extends S{constructor(e){super();this.content=e;i(this,"messageType",Zt)}};var H=class extends C{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}};var Mt=class extends C{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},Ce=class extends C{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var en="CleanupReplayMessage",Ie=class extends E{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",en);i(this,"messageType","CleanupMessage")}},xe=class extends S{constructor(e){super();this.customCleanup=e;i(this,"messageType",en)}};var be=class extends C{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var Ct=class extends C{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},we=class extends C{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var It=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},oe=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==w.down)return;if(t.messageType===u.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===u.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new It(s),this.messageToHost(new ge(s));return}if(t.messageType===u.EnvelopedMessage){let s=t,r=s.message;if(t=r,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===r.destination);if(a){a.send(r);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(r);return}}else return}if(t.messageType){if(t.messageType===u.CleanupMessage){let r=t,a=this.messageCleanupCache[r.cleanupForMessageId],p=new xe(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],Ut(a).then(()=>{this.messageToHost(p,r)}).catch(()=>{})):this.messageToHost(p,r);return}let s=!1;this.supportedHandlers.forEach(r=>{if(r.messageType===t.messageType){s=!0;let a=r.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(r.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 Y={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var re={message:"message",code:"code"},se=class{};i(se,"code","code"),i(se,"component","component");var Q={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Re={Segment:"Segment",Promo:"Promo",AB:"AB"},ie=class{constructor(n,e){this.container=n;this.shadowRoot=e;i(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));i(this,"getRoot",()=>this.shadowRoot||this.container)}};var T={id:"myop-id"};var _e=class extends M{constructor(){super(...arguments);i(this,"messageType",u.DetectMyopRefsMessage);i(this,"executor",e=>{let t=document.querySelectorAll("[".concat(T.id,"]")),s=[];t.forEach(r=>{let a=r.getAttribute(T.id);a&&s.push(new te(a,r.tagName,r.getBoundingClientRect()))}),this.messageToHost(new j(e.handlerUniqueId,s))})}};var I=(o,n)=>n.querySelectorAll("[".concat(T.id,"='").concat(o.refConfig.selector,"']")),tn=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var ke=class extends M{constructor(){super(...arguments);i(this,"messageType",u.BindClickMessage);i(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(r=>{let a=()=>{this.messageToHost(new W,e)};r.addEventListener("click",a);let p=()=>{r.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(r=>r())}})}};var He=class extends M{constructor(){super(...arguments);i(this,"messageType",u.ChangeTextMessage);i(this,"executor",e=>{I(e.ref,document).forEach(s=>{s.textContent=e.content})})}};var xt=o=>o!==Object(o),Hn=o=>typeof o=="function",bt=o=>{if(xt(o))return!0;if(Hn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!bt(e))return!1}else{if(xt(e))continue;return!1}}return!0},k=(o,n={},e=!0,t=new WeakMap)=>{if(xt(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=k(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(e?o[r]!==void 0:o[r])&&(s[r]=k(o[r],!0,e,t)):typeof a=="object"&&(s[r]=k(o[r],a,e,t)))}return s}return{}};var De=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=k,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)};var Be=class extends M{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"executor",e=>{De(e,s=>{this.messageToHost(new N(e.handlerUniqueId,s))},new ie(document.documentElement))})}};var Le="__federation__",nn="onLoad";var ae=(o,n)=>{window[Le]&&window[Le][o]&&window[Le][o][nn]&&window[Le][o][nn]({[o]:n})};var Pe=class extends M{constructor(){super(...arguments);i(this,"messageType",u.AddEventListenerMessage);i(this,"executor",e=>{let t=I(e.ref,document),s=[];return t.forEach(r=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new q(e.handlerUniqueId,k(p,e.serializableSkeleton)))})};r.addEventListener(e.type,a),s.push(()=>{r.removeEventListener(e.type,a)})}),()=>{s.forEach(r=>{r()})}})}};var Oe=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetAttributeMessage);i(this,"executor",e=>{I(e.ref,document).forEach(s=>{s.setAttribute(e.name,e.value)})})}};var B=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});i(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>e(a)?(t(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(t==null?void 0:t.id)||L.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===u.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=w.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=w.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Ie(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new be);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var on={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var Se=class extends B{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;i(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new he(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new H("dispose")),super.dispose()})}hide(){this.send(new H("hide"))}show(){this.send(new H("show"))}inspect(){return this.send(new H("inspect"))}setHeightBasedOnDocumentElement(){this.send(new H("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new H("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var J=class extends B{constructor(e,t,s,r,a,p){super(e,s,p);this.container=s;this.customElement=r;this.tagName=a;i(this,"ctaCleanup");i(this,"_ctaHandler");i(this,"_ctaQueue",[]);i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});i(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=r,this.setInitiated()}inspect(){return this.cleanupInspect=pe(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this.ctaCleanup&&this.ctaCleanup(),this._ctaHandler=e,this._ctaQueue.length>0){let s=[...this._ctaQueue];this._ctaQueue=[],s.forEach(r=>{this.markedForDisposed||e(r.action,r.payload)})}let t=s=>{var a;let r=s;(a=r.detail)!=null&&a.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(r.detail.action,r.detail.payload):this._ctaHandler||this._ctaQueue.push({action:r.detail.action,payload:r.detail.payload}))};this.customElement.addEventListener("myop-cta",t),this.ctaCleanup=()=>{this.customElement.removeEventListener("myop-cta",t)}}};var Dn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},pe=(o,n,e,t,s,r)=>{let a=Dn("".concat(r.name," : ").concat(n),e,r);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},sn=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),rn=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},an=(o,n,e)=>{let t=n.reduce((r,a)=>P(h({},r),{[a.name]:h({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(sn(p,a,o))return!1;if(p.behavior.type===re.code){if(o instanceof J)return(p.behavior.remap||a)==="myop_init_interface"?f=>{if(f===void 0)return o.getData();o.initWithData(f)}:void 0;if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return rn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let m=[];p.behavior.ref&&m.push(z.create(p.behavior.ref)),m.push(l=>{d(l)}),p.behavior.params&&m.push(...p.behavior.params);let f=ve[p.behavior.message];o.send(new f(...m))}):null},set:(r,a,p)=>{let d=t[a];if(sn(d,a,o))return!1;if(d.behavior.type===re.code){if(o instanceof J){let f=d.behavior.remap||a;if(f==="myop_cta_handler")return o.setCtaHandler(p),!0;if(f==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let f=d.behavior,l=o.element.contentWindow,c=f.remap||a;if(l[c]=p,c==="myop_cta_handler"&&l.__myop_cta_queue){let g=l.__myop_cta_queue;l.__myop_cta_queue=null,g.forEach(y=>{o.markedForDisposed||p(y.action,y.payload)})}return!0}return rn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let m=[];d.behavior.ref&&m.push(z.create(d.behavior.ref)),m.push(p),d.behavior.params&&m.push(...d.behavior.params);let f=ve[d.behavior.message];return o.send(new f(...m)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Bn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{bt(p)||on.notSerializableRefCall(t,p)}),n.send(new U(({ref:p,propName:d,functionArgs:m,makeSerializable:f})=>{if(p){let l=p[d];return f(typeof l=="function"?p[d](...m):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new U(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),wt=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(r,a)=>{let p=new Se(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new ye(o.refConfig,n,P(h({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(d),m.failed){a("CreateRefComponentMessage failed");return}let f=e.find(l=>l.id==p.id);if(f!==p){s.refs[o.refConfig.name]=f,r(f);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(l=>{let c=n.instance.resolvedNestedComponents.find(y=>y.type.id===l.componentDefinitionId).type,g=new Se(c,p);g.setInitiated(),p.refs[l.refName]=g,e.push(g)});try{await St(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(l){a(l)}}))})},St=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(r=>new Promise(async(a,p)=>{var d;if(r.behavior.type==se.component){if(t){a();return}let m=r.behavior.componentId;m||(m=r.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(c=>c.type.id===m);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=z.create("",r,o);try{let c=await wt(l,f,e);o.refs[r.name]=c,a()}catch(c){p(c)}}else try{let m=z.create("",r,o);o.refs[r.name]=Bn(m,o),a()}catch(m){}}));try{await Promise.all(s)}catch(r){throw r}};var de=class extends B{constructor(e,t,s,r,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=r;i(this,"_autoSizeCleanup");i(this,"_autoSizeOptions");i(this,"_autoSizeUpdate");i(this,"sizeMeta");i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new _(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});i(this,"observeSizeBasedOnDocumentElement",()=>this.send(new _(({send:t})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));i(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let r=(l,c,g)=>c!==void 0&&l<c?c:g!==void 0&&l>g?g:l,a=l=>{if(l===void 0)return;if(typeof l=="number")return l;let c=parseFloat(l);return isNaN(c)?void 0:c},p=()=>{var Dt,Bt,Lt,Pt,Ot,At,zt,Kt;let l=t.contentDocument;if(!l)return;let c=this._autoSizeOptions,g=a(c==null?void 0:c.minWidth),y=a(c==null?void 0:c.maxWidth),Z=a(c==null?void 0:c.minHeight),me=a(c==null?void 0:c.maxHeight),F=(Dt=c==null?void 0:c.loaderMinHeight)!=null?Dt:50,ee=((Bt=this.sizeMeta)==null?void 0:Bt.width)==="100%"?"100%":void 0,v=((Lt=this.sizeMeta)==null?void 0:Lt.height)==="100%"?"100%":void 0,b=(Ot=(Pt=c==null?void 0:c.explicitWidth)!=null?Pt:ee)!=null?Ot:"100%",D=(At=c==null?void 0:c.explicitHeight)!=null?At:v,le=b!==void 0,vt=D!==void 0,rt=this.container.getBoundingClientRect(),Mn=rt.width===0,Cn=rt.height===0||rt.height===F,fe=(c!=null&&c.forceAutoSize||Mn)&&!le,ue=(c!=null&&c.forceAutoSize||Cn)&&!vt;if(!fe&&!ue){t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",t.style.height=typeof D=="number"?"".concat(D,"px"):"100%";let $t=typeof b=="number"?b:void 0,Ft=typeof D=="number"?D:void 0;($t!==void 0||Ft!==void 0)&&((zt=c==null?void 0:c.onSizeChange)==null||zt.call(c,{width:$t,height:Ft,autoSizingWidth:!1,autoSizingHeight:!1}));return}ue&&(t.style.height="0px"),fe&&(t.style.width="0px");let Rt=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth)),_t=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight)),kt=r(Rt,g,y),Ht=r(_t,Z,me);fe?t.style.width="".concat(kt,"px"):t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",ue?t.style.height="".concat(Ht,"px"):t.style.height=typeof D=="number"?"".concat(D,"px"):"100%";let In=fe&&y!==void 0&&Rt>y,xn=ue&&me!==void 0&&_t>me;l.documentElement.style.overflowX=In?"auto":"",l.documentElement.style.overflowY=xn?"auto":"",(Kt=c==null?void 0:c.onSizeChange)==null||Kt.call(c,{width:kt,height:Ht,autoSizingWidth:fe,autoSizingHeight:ue})};p(),this._autoSizeUpdate=p;let d=new ResizeObserver(p);d.observe(s.body),d.observe(s.documentElement);let m=new MutationObserver(p);m.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{d.disconnect(),m.disconnect(),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});i(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new _(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new _(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});i(this,"send",e=>{var r,a;let t=h({},e);if(t.messageType===u.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=w.down;let s=super.send(t);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(t,"*"),s});i(this,"dispose",()=>{this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=pe(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===u.In.MutationObserverMessage||e.messageType===u.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var K=class{constructor(){i(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let r=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,r||null)}}else return n.appendChild(e)})}};var Ln=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Ae=class extends K{constructor(){super(...arguments);i(this,"type",A.IframeLoader);i(this,"load",async(e,t,s,r)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let d=R(),m="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=m;let f="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ");a.style.cssText=f,r!=null&&r.elementAttributes&&Object.entries(r.elementAttributes).forEach(([c,g])=>{g===""||g===null||g===void 0?a.setAttribute(c,""):a.setAttribute(c,String(g))});let l=t.loader.url;r!=null&&r._hasParent&&(l=Ln(l,"_myop-comp",d)),a.src=l,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,r)}return new de(e,t,s,a,r)})}};var ze={webcomponent_message_key:"myop_webcomponent_message"};var ce=class extends B{constructor(e,t,s,r,a){super(e,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=h({},e),s=super.send(t),r=new CustomEvent(ze.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(r)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});i(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=r}inspect(){return this.cleanupInspect=pe(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var Et={},Ke=class extends K{constructor(){super(...arguments);i(this,"type",A.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;Et[a.url]?console.log("Module alreday loaded or in loading process"):Et[a.url]=new Promise((m,f)=>{let l=a.url,c=document.createElement("script");c.type="module",c.src=l,c.onload=()=>{m()},c.onerror=()=>{f()},document.head.appendChild(c)}),await Et[a.url],await qt(1);let p="myop-comp-".concat(R()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),r!=null&&r._environment&&(d._myopEnvironment=r==null?void 0:r._environment),this.appendChild(s,d,r),new ce(e,t,s,d,r)})}};var $e="0.3.19";var x=class extends Te{constructor(e,t){super(e);this.context=t;i(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(r,a)=>{this.messageToHost(P(h({},r),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var Fe=class extends x{constructor(){super(...arguments);i(this,"messageType",u.BindClickMessage);i(this,"innerExecutor",(e,t,s)=>{let r=I(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new W(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var We=class extends x{constructor(){super(...arguments);i(this,"messageType",u.ChangeTextMessage);i(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(r=>{r.textContent=e.content})})}};var Ne=class extends ie{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ue=class extends x{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(T.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(T.id);p&&r.push(new te(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new j(e.handlerUniqueId,r))});i(this,"messageType",u.DetectMyopRefsMessage)}};var qe=class extends x{constructor(){super(...arguments);i(this,"messageType",u.SetAttributeMessage);i(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var Ve=class extends x{constructor(){super(...arguments);i(this,"messageType",u.AddEventListenerMessage);i(this,"innerExecutor",(e,t,s)=>{let r=I(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=m=>{s(new q(e.handlerUniqueId,k(m,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var Ge=class extends x{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(T.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=L.Instance(),d=p.components.find(c=>c.id===e.options.id);d&&d.dispose();let m=p.components.indexOf(d);m!==-1&&p.components.splice(m,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(f.refs).forEach(c=>{let g=f.refs[c];g=g.__nonProxied||g,g.componentDefinition&&l.push({refName:c,componentDefinitionId:g.componentDefinition.id})}),s(new O(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var je=class extends x{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{De(e,a=>{s(new N(e.handlerUniqueId,a))},t)})}};var pn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(r=>{if(typeof r.value=="string"){let a=r.getAttribute(T.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:pn(r),required:r.required,validity:k(r.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ye=class extends x{constructor(){super(...arguments);i(this,"messageType",u.GetElementValueMessage);i(this,"innerExecutor",(e,t,s)=>{I(e.ref,t.shadowRoot).forEach(a=>{s(new V(pn(a)),e)})})}};var Qe=class extends x{constructor(){super(...arguments);i(this,"messageType",u.SetInnerHtml);i(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(r=>{r.innerHTML=e.content})})}};var Ee=class extends oe{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(ze.webcomponent_message_key,s=>{let r=s.data?s.data:s.detail;if(!r||!r.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=r;if(this.handleIncomeMessages(s),a.messageType===u.InitMessage){let p=a.content.id;this.components[p].context=new Ne(e,t)}}}),setTimeout(()=>{this.messageToHost(new G)},1)});i(this,"messageToHost",(e,t)=>{e.direction=w.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new We(this.messageToHost,this.components),new Qe(this.messageToHost,this.components),new Fe(this.messageToHost,this.components),new Ue(this.messageToHost,this.components),new qe(this.messageToHost,this.components),new Ve(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Ye(this.messageToHost,this.components),new Ge(this.messageToHost,this.components)]);i(this,"init",()=>{})}};ae("WebComponentSDK",Ee);var dn="";var Pn="<!-- myop-web-component -->",On="myop-web-component",mn=new Set,ln=[],Je,fn=async()=>(Je||(Je=new Ee,Je.init()),Je);function An(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Y.open?"open":"closed",t=this.attachShadow({mode:e});fn().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var zn=(o,n,e)=>{customElements.define(o,An(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Kn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),$n=o=>(o=Kn(o),o.replace(/_/g,"-"));var Xe=class extends K{constructor(){super(...arguments);i(this,"type",A.HTMLLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;if(this.isMyopWebComponent(a.HTML))return this.loadExtractedWebComponent(e,t,s,a.HTML,r);let p="myop-comp-".concat(R()),d;if(a.shadowRootMode===Y.localFrame){let m=R(),f="myop-comp-".concat(m),l=document.createElement("iframe");l.id=f,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(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,r);let c=l.contentDocument||l.contentWindow.document;c.open();let g=null;{let b=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(b)try{g=JSON.parse(b.getAttribute("content")||"{}")}catch(D){}}let y=a.HTML;if(r!=null&&r._inspection){let v=new DOMParser().parseFromString(a.HTML,"text/html"),b=v.getElementById("myop_preview");b==null||b.removeAttribute("type");let D=v.implementation.createHTMLDocument();D.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let le=D.body.firstChild;le&&v.head&&v.head.insertBefore(v.importNode(le,!0),v.head.firstChild),y=v.documentElement.outerHTML}else if((r==null?void 0:r.data)!==void 0){let v=new DOMParser().parseFromString(a.HTML,"text/html"),b=v.getElementById("myop_preview");b&&(b.remove(),y=v.documentElement.outerHTML)}c.writeln(y);let Z='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),me="<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.writeln("".concat(Z).concat(me)),(r==null?void 0:r.data)!==void 0){let ee="<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>",v=JSON.stringify(r.data).replace(/<\/script/gi,"\\u003c/script"),b='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(v,";\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>");c.writeln(ee+b)}c.close();let F=new de(e,t,s,l,r);return F.sizeMeta=g,F.initiated().then(()=>{F.observeAutoSize({forceAutoSize:!0}),r!=null&&r.hidden||F.show()}),F}if(a.shadowRootMode===Y.none){let m=document.createElement("template");m.innerHTML=a.HTML,d=m.content.firstElementChild,fn().then(f=>{f.connectedCallback(d,d)})}else{let m=$n(e.name+t.id);ln.includes(m)||(zn(m,a.HTML,a.shadowRootMode),ln.push(m)),d=document.createElement(m)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,r),new ce(e,t,s,d,r)})}isMyopWebComponent(e){return e.trimStart().startsWith(Pn)}extractWebComponentScript(e){let r=new DOMParser().parseFromString(e,"text/html").getElementById(On);return(r==null?void 0:r.textContent)||null}executeWebComponentScript(e,t){if(mn.has(t)){console.log("[MyopWebComponent] Script already executed for ".concat(t,", skipping"));return}let s=document.createElement("script");s.textContent=e,s.id="myop-extracted-".concat(t),document.head.appendChild(s),mn.add(t),console.log("[MyopWebComponent] Executed web component script: ".concat(t))}async loadExtractedWebComponent(e,t,s,r,a){let p=this.extractWebComponentScript(r);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),m=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(p,d);let f=window.__MYOP_TAG_NAME__;if(!f)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");m&&m!==f&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(m," to ").concat(f));let l="myop-comp-".concat(R()),c=document.createElement(f);c.id=l,a!=null&&a.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,c,a);let g=new J(e,t,s,c,f,a);return(a==null?void 0:a.data)!==void 0&&g.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(f,"> into container")),g}};var Fn=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:re.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:re.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Ze="__MYOP_CLOUD_REPOSITORY_MAIN__",Wn=()=>{if(typeof window<"u")return window[Ze];if(typeof globalThis<"u")return globalThis[Ze]},Nn=o=>{typeof window<"u"&&(window[Ze]=o),typeof globalThis<"u"&&(globalThis[Ze]=o)},$=class ${constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"variants",{});i(this,"preloadedComponents",{});i(this,"userFlows",{});i(this,"_defaultEnv","production");i(this,"_envExplicitlySet",!1)}static get Main(){let n=Wn();return n||($._main||($._main=new $,Nn($._main)),$._main)}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let s=this.preloadedComponents[n],r=e!==void 0||t!==void 0,a,p;if(!r&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let m=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!m}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(m,f)=>{try{let l="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(l+="&preview=true");let y=(await(await fetch(l)).json()).item;if(!y){f(new Error('Component "'.concat(n,'" not found')));return}if(!y.consume_variant||!y.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let Z=Fn(y);m(Z)}catch(l){f(l)}})),await this.variants[d]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(r.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(r.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};i($,"_main",null);var X=$;var Ud=X.Main;var un=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=pt(t);switch(s){case"component":{let[a,p]=r,d=await X.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:Q.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=pt(t),m=(await X.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(m&&m.instance.skinSelector.type===Q.Segmented&&m.instance.resolvedExperiences){let f=m.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Re.Segment){let l=f,g=m.instance.skinSelector.segments.find(y=>y.segmentId===l.segment.id);if(g)return m.instance.skinSelector=g==null?void 0:g.skinSelector,m}}}break}}}finally{return null}};var gn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",L=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",$e);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==w.up&&n.data.messageType!==u.EnvelopedMessage)return;let e=n.data;if(e.messageType===u.InitRequest){this.components2init.forEach(s=>{s.send(new ne(s.id))});return}if(e.messageType===u.InitResponse){this.components2init=this.components2init.filter(r=>r.id!==e.content.id);let s=this.components.find(r=>{var a;return r.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===u.EnvelopedMessage){let s=e,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===w.down){s.message.messageType===H.name?r.onMessageReceived(s.message):(s.message.route=s.route,r.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let t=this.components.find(s=>s.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});i(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});i(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Ae,new Ke,new Xe];if(this.componentsLoaders=[...e],n){let t={};n.forEach(s=>{let r=new s(this.componentsLoaders);t[r.type]=r}),this.componentsLoaders.forEach(s=>{t[s.type]||(t[s.type]=s)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});i(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var r;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case Q.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case Q.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let m=e.find(g=>g.type===Re.Segment?g.segment.id===d.segmentId:!1);if(!m)throw new Error("experience not found");let l=m.segment,c=(t||{})[l.function];return c?await c():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});i(this,"loaderHooks");i(this,"loadComponent",async(n,e,t)=>{var f,l,c,g;if(!e){debugger;throw new Error("no container was found for this component")}let s=await un(n);s&&(n=s);let r=h(h({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let y=await this.runSkinSelector(n,r);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(c=t==null?void 0:t.hooks)!=null&&c.afterSkinSelected&&(y=await t.hooks.afterSkinSelected(h({},y))),n.instance.skinSelector={type:Q.Dedicated,skin:y},t&&(t=h({},t),delete t.hooks),await wt(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,r);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(y=>y.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await d.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==m),this.components2init=this.components2init.filter(y=>y!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=an(m,n.type.props,p));try{await St(m,n,this.components)}catch(y){throw y}return t!=null&&t.skipInit||await m.initiated(),m});i(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};i(L,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:gn});if(!window.myop.hostSDK){let o=new L;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:gn}),window.myop.hostSDK=o}var Un=window.myop.hostSDK;ae("hostSDK",Un);var et=class extends M{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"executor",e=>{(async()=>{let s=document.querySelectorAll("[".concat(T.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await L.Instance().loadComponent(e.nestedComponentConfig,s.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let m=a.refs[d];m=m.__nonProxied||m,m.componentDefinition&&p.push({refName:d,componentDefinitionId:m.componentDefinition.id})}),this.messageToHost(new O(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var yn=(o,n)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(n),s={attributes:!0,childList:!0,subtree:!0};return t.observe(o,s),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var tt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetMutationObserverMessage);i(this,"executor",e=>{e.source&&yn(document.body,()=>{this.messageToHost(new Ce)})})}};var hn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(r=>{if(typeof r.value=="string"){let a=r.getAttribute(T.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:hn(r),required:r.required,validity:k(r.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},nt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.GetElementValueMessage);i(this,"executor",e=>{I(e.ref,document).forEach(s=>{this.messageToHost(new V(hn(s)),e)})})}};var ot=class extends M{constructor(){super(...arguments);i(this,"messageType",u.GetAttributeMessage);i(this,"executor",e=>{let t=tn(e.ref,document);t&&this.messageToHost(new Me(t.getAttribute(e.name)),e)})}};var st=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetResizeObserverMessage);i(this,"executor",e=>{let t=new ResizeObserver(s=>{this.messageToHost(new we)});return t.observe(document.body),()=>{t.disconnect()}})}};var it=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetInnerHtml);i(this,"executor",e=>{I(e.ref,document).forEach(s=>{s.innerHTML=e.content})})}};var Tt=class extends oe{constructor(){super();i(this,"version",$e);i(this,"messageToHost",(e,t)=>{var r;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let s=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=s[0]),e.source||(e.source=s[0]),e.direction=w.up,(r=window.parent)==null||r.postMessage(h({},e),"*")});i(this,"supportedHandlers",[new He(this.messageToHost),new it(this.messageToHost),new ke(this.messageToHost),new _e(this.messageToHost),new Be(this.messageToHost),new Pe(this.messageToHost),new Oe(this.messageToHost),new nt(this.messageToHost),new tt(this.messageToHost),new st(this.messageToHost),new ot(this.messageToHost),new et(this.messageToHost)]);i(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new G)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};ae("IframeSDK",Tt);export{Tt as IframeSDK};
@@ -1 +0,0 @@
1
- var Rt=Object.defineProperty,rn=Object.defineProperties;var an=Object.getOwnPropertyDescriptors;var vt=Object.getOwnPropertySymbols;var pn=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable;var Ne=(o,n,e)=>n in o?Rt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,M=(o,n)=>{for(var e in n||(n={}))pn.call(n,e)&&Ne(o,e,n[e]);if(vt)for(var e of vt(n))dn.call(n,e)&&Ne(o,e,n[e]);return o},H=(o,n)=>rn(o,an(n));var cn=(o,n)=>{for(var e in n)Rt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>Ne(o,typeof n!="symbol"?n+"":n,e);var Me=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var _t=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},Ue=class{constructor(n){this.messageToHost=n}},Ce=class extends Ue{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var g={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 Ie={};cn(Ie,{AddEventListenerMessage:()=>Ye,BaseMyopMessage:()=>h,BindClickMessage:()=>je,ChangeTextMessage:()=>Ge,CleanupMessage:()=>fe,CleanupReplayMessage:()=>ue,ClickReplayMessage:()=>se,CreateRefComponentMessage:()=>ce,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>Ze,DetectedMyopRefsMessage:()=>le,DisposeMessage:()=>ge,ElementValueReplayMessage:()=>ae,EnvelopedMessage:()=>me,EventListenerCallbackMessage:()=>re,ExecuteComponentMethod:()=>v,ExecuteScriptMessage:()=>T,ExecuteScriptReplyMessage:()=>ie,GetAttributeMessage:()=>et,GetAttributeReplayMessage:()=>tt,GetElementValueMessage:()=>Je,InitMessage:()=>j,InitRequest:()=>de,InitResponse:()=>pe,MessageDirection:()=>w,MutationObserverMessage:()=>ot,MyopBindMessage:()=>b,MyopBindReplayMessage:()=>x,MyopElementMessage:()=>qe,Ref:()=>P,RefComponentCreatedMessage:()=>G,ResizeObserverMessage:()=>it,SetAttributeMessage:()=>Qe,SetInnerHtml:()=>Xe,SetMutationObserverMessage:()=>nt,SetResizeObserverMessage:()=>st,stripFunction:()=>Bt});var E=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var mn=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var ln=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Ve=o=>{let n=ln(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(mn(n.slice(t,t+16)));return e};var kt=o=>new Promise(n=>setTimeout(n,o));var w=class{};r(w,"down","down"),r(w,"up","up");var h=class{constructor(){r(this,"id",E());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}},qe=class extends h{constructor(e){super();this.ref=e}},x=class extends h{constructor(e){super();this.replayToHandler=e}},b=class extends h{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",E())}},P=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=H(M({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var Ht="ClickReplayMessage",je=class extends b{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Ht);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},se=class extends x{constructor(){super(...arguments);r(this,"messageType",Ht)}};var Ge=class extends h{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Dt="ExecuteScriptReplyMessage",fn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,un=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Bt=o=>{let n=o.match(fn);if(n)return n[1]||n[3];{let e=o.match(un);if(e)return e[1].trim()}},T=class extends b{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Dt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Bt(this.content)}};r(T,"replierKey","send"),r(T,"completeStreamKey","completeStream");var ie=class extends x{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Dt)}};var $=class extends T{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let m=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(d.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=H(M({},t),{_script:e.toString()})}};var Lt="EventListenerCallbackMessage",Ye=class extends b{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Lt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},re=class extends x{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Lt);this.content={e:t}}};var Qe=class extends h{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var Pt="ElementValueReplayMessage",Je=class extends b{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Pt);r(this,"messageType","GetElementValueMessage")}},ae=class extends x{constructor(e){super();this.content=e;r(this,"messageType",Pt)}};var Xe=class extends h{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var j=class extends h{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},pe=class extends j{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},de=class extends h{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var Ot="RefComponentCreatedMessage",ce=class extends b{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",Ot);r(this,"messageType","CreateRefComponentMessage")}},G=class extends x{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",Ot)}};var me=class extends h{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var zt="DetectedMyopRefsMessage",Ze=class extends b{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",zt)}},le=class extends x{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",zt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var Kt="GetAttributeReplayMessage",et=class extends b{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",Kt);r(this,"messageType","GetAttributeMessage")}},tt=class extends x{constructor(e){super();this.content=e;r(this,"messageType",Kt)}};var v=class extends h{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var nt=class extends h{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},ot=class extends h{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var At="CleanupReplayMessage",fe=class extends b{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",At);r(this,"messageType","CleanupMessage")}},ue=class extends x{constructor(e){super();this.customCleanup=e;r(this,"messageType",At)}};var ge=class extends h{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var st=class extends h{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},it=class extends h{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var rt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},xe=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==w.down)return;if(t.messageType===g.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===g.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new rt(s),this.messageToHost(new pe(s));return}if(t.messageType===g.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===g.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ue(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],_t(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var D={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var F={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var Q={message:"message",code:"code"},Y=class{};r(Y,"code","code"),r(Y,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},we={Segment:"Segment",Promo:"Promo",AB:"AB"},be=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var Se={webcomponent_message_key:"myop_webcomponent_message"};var C=class extends Ce{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(H(M({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var B={id:"myop-id"};var R=(o,n)=>n.querySelectorAll("[".concat(B.id,"='").concat(o.refConfig.selector,"']"));var Ee=class extends C{constructor(){super(...arguments);r(this,"messageType",g.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=R(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new se(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Te=class extends C{constructor(){super(...arguments);r(this,"messageType",g.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var ve=class extends be{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Re=class extends C{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(B.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(B.id);p&&i.push(new Me(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new le(e.handlerUniqueId,i))});r(this,"messageType",g.DetectMyopRefsMessage)}};var _e="__federation__",$t="onLoad";var ke=(o,n)=>{window[_e]&&window[_e][o]&&window[_e][o][$t]&&window[_e][o][$t]({[o]:n})};var He=class extends C{constructor(){super(...arguments);r(this,"messageType",g.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var at=o=>o!==Object(o),gn=o=>typeof o=="function",pt=o=>{if(at(o))return!0;if(gn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!pt(e))return!1}else{if(at(e))continue;return!1}}return!0},L=(o,n={},e=!0,t=new WeakMap)=>{if(at(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=L(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=L(o[i],!0,e,t)):typeof a=="object"&&(s[i]=L(o[i],a,e,t)))}return s}return{}};var De=class extends C{constructor(){super(...arguments);r(this,"messageType",g.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=R(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=m=>{s(new re(e.handlerUniqueId,L(m,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var k=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||O.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===g.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=w.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=w.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new fe(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ge);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Ft={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 ye=class extends k{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new me(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new v("dispose")),super.dispose()})}hide(){this.send(new v("hide"))}show(){this.send(new v("show"))}inspect(){return this.send(new v("inspect"))}setHeightBasedOnDocumentElement(){this.send(new v("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new v("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var N=class extends k{constructor(e,t,s,i,a,p){super(e,s,p);this.container=s;this.customElement=i;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i,this.setInitiated()}inspect(){return this.cleanupInspect=J(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this.ctaCleanup&&this.ctaCleanup(),this._ctaHandler=e,this._ctaQueue.length>0){let s=[...this._ctaQueue];this._ctaQueue=[],s.forEach(i=>{this.markedForDisposed||e(i.action,i.payload)})}let t=s=>{var a;let i=s;(a=i.detail)!=null&&a.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(i.detail.action,i.detail.payload):this._ctaHandler||this._ctaQueue.push({action:i.detail.action,payload:i.detail.payload}))};this.customElement.addEventListener("myop-cta",t),this.ctaCleanup=()=>{this.customElement.removeEventListener("myop-cta",t)}}};var yn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},J=(o,n,e,t,s,i)=>{let a=yn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},Wt=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Nt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},Ut=(o,n,e)=>{let t=n.reduce((i,a)=>H(M({},i),{[a.name]:M({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(Wt(p,a,o))return!1;if(p.behavior.type===Q.code){if(o instanceof N)return(p.behavior.remap||a)==="myop_init_interface"?f=>{if(f===void 0)return o.getData();o.initWithData(f)}:void 0;if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===F.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return Nt(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let m=[];p.behavior.ref&&m.push(P.create(p.behavior.ref)),m.push(l=>{d(l)}),p.behavior.params&&m.push(...p.behavior.params);let f=Ie[p.behavior.message];o.send(new f(...m))}):null},set:(i,a,p)=>{let d=t[a];if(Wt(d,a,o))return!1;if(d.behavior.type===Q.code){if(o instanceof N){let f=d.behavior.remap||a;if(f==="myop_cta_handler")return o.setCtaHandler(p),!0;if(f==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===F.localFrame){let f=d.behavior,l=o.element.contentWindow,c=f.remap||a;if(l[c]=p,c==="myop_cta_handler"&&l.__myop_cta_queue){let u=l.__myop_cta_queue;l.__myop_cta_queue=null,u.forEach(y=>{o.markedForDisposed||p(y.action,y.payload)})}return!0}return Nt(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let m=[];d.behavior.ref&&m.push(P.create(d.behavior.ref)),m.push(p),d.behavior.params&&m.push(...d.behavior.params);let f=Ie[d.behavior.message];return o.send(new f(...m)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},hn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{pt(p)||Ft.notSerializableRefCall(t,p)}),n.send(new $(({ref:p,propName:d,functionArgs:m,makeSerializable:f})=>{if(p){let l=p[d];return f(typeof l=="function"?p[d](...m):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),dt=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new ye(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new ce(o.refConfig,n,H(M({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(d),m.failed){a("CreateRefComponentMessage failed");return}let f=e.find(l=>l.id==p.id);if(f!==p){s.refs[o.refConfig.name]=f,i(f);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(l=>{let c=n.instance.resolvedNestedComponents.find(y=>y.type.id===l.componentDefinitionId).type,u=new ye(c,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await ct(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},ct=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var d;if(i.behavior.type==Y.component){if(t){a();return}let m=i.behavior.componentId;m||(m=i.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(c=>c.type.id===m);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=P.create("",i,o);try{let c=await dt(l,f,e);o.refs[i.name]=c,a()}catch(c){p(c)}}else try{let m=P.create("",i,o);o.refs[i.name]=hn(m,o),a()}catch(m){}}));try{await Promise.all(s)}catch(i){throw i}};var X=class extends k{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new T(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new T(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(l,c,u)=>c!==void 0&&l<c?c:u!==void 0&&l>u?u:l,a=l=>{if(l===void 0)return;if(typeof l=="number")return l;let c=parseFloat(l);return isNaN(c)?void 0:c},p=()=>{var ht,Mt,Ct,It,xt,bt,wt,St;let l=t.contentDocument;if(!l)return;let c=this._autoSizeOptions,u=a(c==null?void 0:c.minWidth),y=a(c==null?void 0:c.maxWidth),V=a(c==null?void 0:c.minHeight),ee=a(c==null?void 0:c.maxHeight),A=(ht=c==null?void 0:c.loaderMinHeight)!=null?ht:50,q=((Mt=this.sizeMeta)==null?void 0:Mt.width)==="100%"?"100%":void 0,S=((Ct=this.sizeMeta)==null?void 0:Ct.height)==="100%"?"100%":void 0,I=(xt=(It=c==null?void 0:c.explicitWidth)!=null?It:q)!=null?xt:"100%",_=(bt=c==null?void 0:c.explicitHeight)!=null?bt:S,te=I!==void 0,lt=_!==void 0,We=this.container.getBoundingClientRect(),tn=We.width===0,nn=We.height===0||We.height===A,ne=(c!=null&&c.forceAutoSize||tn)&&!te,oe=(c!=null&&c.forceAutoSize||nn)&&!lt;if(!ne&&!oe){t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",t.style.height=typeof _=="number"?"".concat(_,"px"):"100%";let Et=typeof I=="number"?I:void 0,Tt=typeof _=="number"?_:void 0;(Et!==void 0||Tt!==void 0)&&((wt=c==null?void 0:c.onSizeChange)==null||wt.call(c,{width:Et,height:Tt,autoSizingWidth:!1,autoSizingHeight:!1}));return}oe&&(t.style.height="0px"),ne&&(t.style.width="0px");let ft=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth)),ut=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight)),gt=i(ft,u,y),yt=i(ut,V,ee);ne?t.style.width="".concat(gt,"px"):t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",oe?t.style.height="".concat(yt,"px"):t.style.height=typeof _=="number"?"".concat(_,"px"):"100%";let on=ne&&y!==void 0&&ft>y,sn=oe&&ee!==void 0&&ut>ee;l.documentElement.style.overflowX=on?"auto":"",l.documentElement.style.overflowY=sn?"auto":"",(St=c==null?void 0:c.onSizeChange)==null||St.call(c,{width:gt,height:yt,autoSizingWidth:ne,autoSizingHeight:oe})};p(),this._autoSizeUpdate=p;let d=new ResizeObserver(p);d.observe(s.body),d.observe(s.documentElement);let m=new MutationObserver(p);m.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{d.disconnect(),m.disconnect(),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new T(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new T(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=M({},e);if(t.messageType===g.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=w.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(this,"dispose",()=>{this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=J(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===g.In.MutationObserverMessage||e.messageType===g.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var z=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var Mn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Be=class extends z{constructor(){super(...arguments);r(this,"type",D.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let d=E(),m="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=m;let f="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=f,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([c,u])=>{u===""||u===null||u===void 0?a.setAttribute(c,""):a.setAttribute(c,String(u))});let l=t.loader.url;i!=null&&i._hasParent&&(l=Mn(l,"_myop-comp",d)),a.src=l,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}return new X(e,t,s,a,i)})}};var Z=class extends k{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=M({},e),s=super.send(t),i=new CustomEvent(Se.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=J(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 mt={},Le=class extends z{constructor(){super(...arguments);r(this,"type",D.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;mt[a.url]?console.log("Module alreday loaded or in loading process"):mt[a.url]=new Promise((m,f)=>{let l=a.url,c=document.createElement("script");c.type="module",c.src=l,c.onload=()=>{m()},c.onerror=()=>{f()},document.head.appendChild(c)}),await mt[a.url],await kt(1);let p="myop-comp-".concat(E()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new Z(e,t,s,d,i)})}};var Vt="0.3.19";var qt="";var Cn="<!-- myop-web-component -->",In="myop-web-component",Gt=new Set,Yt=[],Pe,Qt=async()=>(Pe||(Pe=new he,Pe.init()),Pe);function xn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===F.open?"open":"closed",t=this.attachShadow({mode:e});Qt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var bn=(o,n,e)=>{customElements.define(o,xn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},wn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Sn=o=>(o=wn(o),o.replace(/_/g,"-"));var Oe=class extends z{constructor(){super(...arguments);r(this,"type",D.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;if(this.isMyopWebComponent(a.HTML))return this.loadExtractedWebComponent(e,t,s,a.HTML,i);let p="myop-comp-".concat(E()),d;if(a.shadowRootMode===F.localFrame){let m=E(),f="myop-comp-".concat(m),l=document.createElement("iframe");l.id=f,l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,i);let c=l.contentDocument||l.contentWindow.document;c.open();let u=null;{let I=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(I)try{u=JSON.parse(I.getAttribute("content")||"{}")}catch(_){}}let y=a.HTML;if(i!=null&&i._inspection){let S=new DOMParser().parseFromString(a.HTML,"text/html"),I=S.getElementById("myop_preview");I==null||I.removeAttribute("type");let _=S.implementation.createHTMLDocument();_.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let te=_.body.firstChild;te&&S.head&&S.head.insertBefore(S.importNode(te,!0),S.head.firstChild),y=S.documentElement.outerHTML}else if((i==null?void 0:i.data)!==void 0){let S=new DOMParser().parseFromString(a.HTML,"text/html"),I=S.getElementById("myop_preview");I&&(I.remove(),y=S.documentElement.outerHTML)}c.writeln(y);let V='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),ee="<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.writeln("".concat(V).concat(ee)),(i==null?void 0:i.data)!==void 0){let q="<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>",S=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),I='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(S,";\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>");c.writeln(q+I)}c.close();let A=new X(e,t,s,l,i);return A.sizeMeta=u,A.initiated().then(()=>{A.observeAutoSize({forceAutoSize:!0}),i!=null&&i.hidden||A.show()}),A}if(a.shadowRootMode===F.none){let m=document.createElement("template");m.innerHTML=a.HTML,d=m.content.firstElementChild,Qt().then(f=>{f.connectedCallback(d,d)})}else{let m=Sn(e.name+t.id);Yt.includes(m)||(bn(m,a.HTML,a.shadowRootMode),Yt.push(m)),d=document.createElement(m)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,i),new Z(e,t,s,d,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(Cn)}extractWebComponentScript(e){let i=new DOMParser().parseFromString(e,"text/html").getElementById(In);return(i==null?void 0:i.textContent)||null}executeWebComponentScript(e,t){if(Gt.has(t)){console.log("[MyopWebComponent] Script already executed for ".concat(t,", skipping"));return}let s=document.createElement("script");s.textContent=e,s.id="myop-extracted-".concat(t),document.head.appendChild(s),Gt.add(t),console.log("[MyopWebComponent] Executed web component script: ".concat(t))}async loadExtractedWebComponent(e,t,s,i,a){let p=this.extractWebComponentScript(i);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),m=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(p,d);let f=window.__MYOP_TAG_NAME__;if(!f)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");m&&m!==f&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(m," to ").concat(f));let l="myop-comp-".concat(E()),c=document.createElement(f);c.id=l,a!=null&&a.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,c,a);let u=new N(e,t,s,c,f,a);return(a==null?void 0:a.data)!==void 0&&u.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(f,"> into container")),u}};var En=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:Q.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:Q.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),ze="__MYOP_CLOUD_REPOSITORY_MAIN__",Tn=()=>{if(typeof window<"u")return window[ze];if(typeof globalThis<"u")return globalThis[ze]},vn=o=>{typeof window<"u"&&(window[ze]=o),typeof globalThis<"u"&&(globalThis[ze]=o)},K=class K{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)}static get Main(){let n=Tn();return n||(K._main||(K._main=new K,vn(K._main)),K._main)}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let s=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;if(!i&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let m=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!m}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(m,f)=>{try{let l="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(l+="&preview=true");let y=(await(await fetch(l)).json()).item;if(!y){f(new Error('Component "'.concat(n,'" not found')));return}if(!y.consume_variant||!y.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let V=En(y);m(V)}catch(l){f(l)}})),await this.variants[d]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(K,"_main",null);var U=K;var Aa=U.Main;var Jt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=Ve(t);switch(s){case"component":{let[a,p]=i,d=await U.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:W.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=Ve(t),m=(await U.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(m&&m.instance.skinSelector.type===W.Segmented&&m.instance.resolvedExperiences){let f=m.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===we.Segment){let l=f,u=m.instance.skinSelector.segments.find(y=>y.segmentId===l.segment.id);if(u)return m.instance.skinSelector=u==null?void 0:u.skinSelector,m}}}break}}}finally{return null}};var Xt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",O=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"initiated",!1);r(this,"version",Vt);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,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==w.up&&n.data.messageType!==g.EnvelopedMessage)return;let e=n.data;if(e.messageType===g.InitRequest){this.components2init.forEach(s=>{s.send(new j(s.id))});return}if(e.messageType===g.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let s=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===g.EnvelopedMessage){let s=e,i=this.components.find(a=>a.id===s.destination);if(i){if(s.direction===w.down){s.message.messageType===v.name?i.onMessageReceived(s.message):(s.message.route=s.route,i.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let t=this.components.find(s=>s.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Be,new Le,new Oe];if(this.componentsLoaders=[...e],n){let t={};n.forEach(s=>{let i=new s(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(s=>{t[s.type]||(t[s.type]=s)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case W.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case W.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let m=e.find(u=>u.type===we.Segment?u.segment.id===d.segmentId:!1);if(!m)throw new Error("experience not found");let l=m.segment,c=(t||{})[l.function];return c?await c():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var f,l,c,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await Jt(n);s&&(n=s);let i=M(M({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=M({},n),n.instance=M({},n.instance);let y=await this.runSkinSelector(n,i);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(c=t==null?void 0:t.hooks)!=null&&c.afterSkinSelected&&(y=await t.hooks.afterSkinSelected(M({},y))),n.instance.skinSelector={type:W.Dedicated,skin:y},t&&(t=M({},t),delete t.hooks),await dt(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(M({},p)));let d=this.componentsLoaders.find(y=>y.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await d.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==m),this.components2init=this.components2init.filter(y=>y!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=Ut(m,n.type.props,p));try{await ct(m,n,this.components)}catch(y){throw y}return t!=null&&t.skipInit||await m.initiated(),m});r(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,M({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,M({relative:{direction:"before",child:s}},t))}})}};r(O,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Xt});if(!window.myop.hostSDK){let o=new O;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Xt}),window.myop.hostSDK=o}var Rn=window.myop.hostSDK;ke("hostSDK",Rn);var Ke=class extends C{constructor(){super(...arguments);r(this,"messageType",g.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(B.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=O.Instance(),d=p.components.find(c=>c.id===e.options.id);d&&d.dispose();let m=p.components.indexOf(d);m!==-1&&p.components.splice(m,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(f.refs).forEach(c=>{let u=f.refs[c];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:c,componentDefinitionId:u.componentDefinition.id})}),s(new G(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new G(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Zt=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=L,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var Ae=class extends C{constructor(){super(...arguments);r(this,"messageType",g.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{Zt(e,a=>{s(new ie(e.handlerUniqueId,a))},t)})}};var en=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(B.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:en(i),required:i.required,validity:L(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},$e=class extends C{constructor(){super(...arguments);r(this,"messageType",g.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{R(e.ref,t.shadowRoot).forEach(a=>{s(new ae(en(a)),e)})})}};var Fe=class extends C{constructor(){super(...arguments);r(this,"messageType",g.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var he=class extends xe{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Se.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===g.InitMessage){let p=a.content.id;this.components[p].context=new ve(e,t)}}}),setTimeout(()=>{this.messageToHost(new de)},1)});r(this,"messageToHost",(e,t)=>{e.direction=w.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Te(this.messageToHost,this.components),new Fe(this.messageToHost,this.components),new Ee(this.messageToHost,this.components),new Re(this.messageToHost,this.components),new He(this.messageToHost,this.components),new De(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new $e(this.messageToHost,this.components),new Ke(this.messageToHost,this.components)]);r(this,"init",()=>{})}};ke("WebComponentSDK",he);export{he as WebComponentSDK};
@@ -1 +0,0 @@
1
- var Rt=Object.defineProperty,rn=Object.defineProperties;var an=Object.getOwnPropertyDescriptors;var vt=Object.getOwnPropertySymbols;var pn=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable;var Ne=(o,n,e)=>n in o?Rt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,M=(o,n)=>{for(var e in n||(n={}))pn.call(n,e)&&Ne(o,e,n[e]);if(vt)for(var e of vt(n))dn.call(n,e)&&Ne(o,e,n[e]);return o},H=(o,n)=>rn(o,an(n));var cn=(o,n)=>{for(var e in n)Rt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>Ne(o,typeof n!="symbol"?n+"":n,e);var Me="__federation__",_t="onLoad";var Ce=(o,n)=>{window[Me]&&window[Me][o]&&window[Me][o][_t]&&window[Me][o][_t]({[o]:n})};var g={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 Ie={};cn(Ie,{AddEventListenerMessage:()=>Ge,BaseMyopMessage:()=>h,BindClickMessage:()=>qe,ChangeTextMessage:()=>je,CleanupMessage:()=>fe,CleanupReplayMessage:()=>ue,ClickReplayMessage:()=>se,CreateRefComponentMessage:()=>ce,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>Xe,DetectedMyopRefsMessage:()=>le,DisposeMessage:()=>ge,ElementValueReplayMessage:()=>ae,EnvelopedMessage:()=>me,EventListenerCallbackMessage:()=>re,ExecuteComponentMethod:()=>v,ExecuteScriptMessage:()=>T,ExecuteScriptReplyMessage:()=>ie,GetAttributeMessage:()=>Ze,GetAttributeReplayMessage:()=>et,GetElementValueMessage:()=>Qe,InitMessage:()=>j,InitRequest:()=>de,InitResponse:()=>pe,MessageDirection:()=>w,MutationObserverMessage:()=>nt,MyopBindMessage:()=>b,MyopBindReplayMessage:()=>x,MyopElementMessage:()=>Ve,Ref:()=>P,RefComponentCreatedMessage:()=>G,ResizeObserverMessage:()=>st,SetAttributeMessage:()=>Ye,SetInnerHtml:()=>Je,SetMutationObserverMessage:()=>tt,SetResizeObserverMessage:()=>ot,stripFunction:()=>Bt});var E=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var mn=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var ln=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Ue=o=>{let n=ln(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(mn(n.slice(t,t+16)));return e};var kt=o=>new Promise(n=>setTimeout(n,o));var w=class{};r(w,"down","down"),r(w,"up","up");var h=class{constructor(){r(this,"id",E());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}},Ve=class extends h{constructor(e){super();this.ref=e}},x=class extends h{constructor(e){super();this.replayToHandler=e}},b=class extends h{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",E())}},P=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=H(M({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var Ht="ClickReplayMessage",qe=class extends b{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Ht);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},se=class extends x{constructor(){super(...arguments);r(this,"messageType",Ht)}};var je=class extends h{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Dt="ExecuteScriptReplyMessage",fn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,un=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Bt=o=>{let n=o.match(fn);if(n)return n[1]||n[3];{let e=o.match(un);if(e)return e[1].trim()}},T=class extends b{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Dt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Bt(this.content)}};r(T,"replierKey","send"),r(T,"completeStreamKey","completeStream");var ie=class extends x{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Dt)}};var $=class extends T{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let m=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(d.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=H(M({},t),{_script:e.toString()})}};var Lt="EventListenerCallbackMessage",Ge=class extends b{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Lt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},re=class extends x{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Lt);this.content={e:t}}};var Ye=class extends h{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var Pt="ElementValueReplayMessage",Qe=class extends b{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Pt);r(this,"messageType","GetElementValueMessage")}},ae=class extends x{constructor(e){super();this.content=e;r(this,"messageType",Pt)}};var Je=class extends h{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var j=class extends h{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},pe=class extends j{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},de=class extends h{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var Ot="RefComponentCreatedMessage",ce=class extends b{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",Ot);r(this,"messageType","CreateRefComponentMessage")}},G=class extends x{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",Ot)}};var me=class extends h{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var zt="DetectedMyopRefsMessage",Xe=class extends b{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",zt)}},le=class extends x{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",zt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var Kt="GetAttributeReplayMessage",Ze=class extends b{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",Kt);r(this,"messageType","GetAttributeMessage")}},et=class extends x{constructor(e){super();this.content=e;r(this,"messageType",Kt)}};var v=class extends h{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var tt=class extends h{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},nt=class extends h{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var At="CleanupReplayMessage",fe=class extends b{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",At);r(this,"messageType","CleanupMessage")}},ue=class extends x{constructor(e){super();this.customCleanup=e;r(this,"messageType",At)}};var ge=class extends h{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ot=class extends h{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},st=class extends h{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var k=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||O.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===g.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=w.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=w.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new fe(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ge);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var xe=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var $t=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},it=class{constructor(n){this.messageToHost=n}},be=class extends it{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var rt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},we=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==w.down)return;if(t.messageType===g.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===g.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new rt(s),this.messageToHost(new pe(s));return}if(t.messageType===g.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===g.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ue(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],$t(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var D={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var F={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var Q={message:"message",code:"code"},Y=class{};r(Y,"code","code"),r(Y,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ee={Segment:"Segment",Promo:"Promo",AB:"AB"},Se=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var at=o=>o!==Object(o),gn=o=>typeof o=="function",pt=o=>{if(at(o))return!0;if(gn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!pt(e))return!1}else{if(at(e))continue;return!1}}return!0},B=(o,n={},e=!0,t=new WeakMap)=>{if(at(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=B(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=B(o[i],!0,e,t)):typeof a=="object"&&(s[i]=B(o[i],a,e,t)))}return s}return{}};var Ft={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 ye=class extends k{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new me(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new v("dispose")),super.dispose()})}hide(){this.send(new v("hide"))}show(){this.send(new v("show"))}inspect(){return this.send(new v("inspect"))}setHeightBasedOnDocumentElement(){this.send(new v("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new v("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var N=class extends k{constructor(e,t,s,i,a,p){super(e,s,p);this.container=s;this.customElement=i;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i,this.setInitiated()}inspect(){return this.cleanupInspect=J(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this.ctaCleanup&&this.ctaCleanup(),this._ctaHandler=e,this._ctaQueue.length>0){let s=[...this._ctaQueue];this._ctaQueue=[],s.forEach(i=>{this.markedForDisposed||e(i.action,i.payload)})}let t=s=>{var a;let i=s;(a=i.detail)!=null&&a.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(i.detail.action,i.detail.payload):this._ctaHandler||this._ctaQueue.push({action:i.detail.action,payload:i.detail.payload}))};this.customElement.addEventListener("myop-cta",t),this.ctaCleanup=()=>{this.customElement.removeEventListener("myop-cta",t)}}};var yn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},J=(o,n,e,t,s,i)=>{let a=yn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},Wt=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Nt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},Ut=(o,n,e)=>{let t=n.reduce((i,a)=>H(M({},i),{[a.name]:M({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(Wt(p,a,o))return!1;if(p.behavior.type===Q.code){if(o instanceof N)return(p.behavior.remap||a)==="myop_init_interface"?f=>{if(f===void 0)return o.getData();o.initWithData(f)}:void 0;if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===F.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return Nt(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let m=[];p.behavior.ref&&m.push(P.create(p.behavior.ref)),m.push(l=>{d(l)}),p.behavior.params&&m.push(...p.behavior.params);let f=Ie[p.behavior.message];o.send(new f(...m))}):null},set:(i,a,p)=>{let d=t[a];if(Wt(d,a,o))return!1;if(d.behavior.type===Q.code){if(o instanceof N){let f=d.behavior.remap||a;if(f==="myop_cta_handler")return o.setCtaHandler(p),!0;if(f==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===F.localFrame){let f=d.behavior,l=o.element.contentWindow,c=f.remap||a;if(l[c]=p,c==="myop_cta_handler"&&l.__myop_cta_queue){let u=l.__myop_cta_queue;l.__myop_cta_queue=null,u.forEach(y=>{o.markedForDisposed||p(y.action,y.payload)})}return!0}return Nt(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let m=[];d.behavior.ref&&m.push(P.create(d.behavior.ref)),m.push(p),d.behavior.params&&m.push(...d.behavior.params);let f=Ie[d.behavior.message];return o.send(new f(...m)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},hn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{pt(p)||Ft.notSerializableRefCall(t,p)}),n.send(new $(({ref:p,propName:d,functionArgs:m,makeSerializable:f})=>{if(p){let l=p[d];return f(typeof l=="function"?p[d](...m):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),dt=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new ye(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new ce(o.refConfig,n,H(M({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(d),m.failed){a("CreateRefComponentMessage failed");return}let f=e.find(l=>l.id==p.id);if(f!==p){s.refs[o.refConfig.name]=f,i(f);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(l=>{let c=n.instance.resolvedNestedComponents.find(y=>y.type.id===l.componentDefinitionId).type,u=new ye(c,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await ct(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},ct=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var d;if(i.behavior.type==Y.component){if(t){a();return}let m=i.behavior.componentId;m||(m=i.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(c=>c.type.id===m);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=P.create("",i,o);try{let c=await dt(l,f,e);o.refs[i.name]=c,a()}catch(c){p(c)}}else try{let m=P.create("",i,o);o.refs[i.name]=hn(m,o),a()}catch(m){}}));try{await Promise.all(s)}catch(i){throw i}};var X=class extends k{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new T(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new T(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(l,c,u)=>c!==void 0&&l<c?c:u!==void 0&&l>u?u:l,a=l=>{if(l===void 0)return;if(typeof l=="number")return l;let c=parseFloat(l);return isNaN(c)?void 0:c},p=()=>{var ht,Mt,Ct,It,xt,bt,wt,St;let l=t.contentDocument;if(!l)return;let c=this._autoSizeOptions,u=a(c==null?void 0:c.minWidth),y=a(c==null?void 0:c.maxWidth),V=a(c==null?void 0:c.minHeight),ee=a(c==null?void 0:c.maxHeight),A=(ht=c==null?void 0:c.loaderMinHeight)!=null?ht:50,q=((Mt=this.sizeMeta)==null?void 0:Mt.width)==="100%"?"100%":void 0,S=((Ct=this.sizeMeta)==null?void 0:Ct.height)==="100%"?"100%":void 0,I=(xt=(It=c==null?void 0:c.explicitWidth)!=null?It:q)!=null?xt:"100%",_=(bt=c==null?void 0:c.explicitHeight)!=null?bt:S,te=I!==void 0,lt=_!==void 0,We=this.container.getBoundingClientRect(),tn=We.width===0,nn=We.height===0||We.height===A,ne=(c!=null&&c.forceAutoSize||tn)&&!te,oe=(c!=null&&c.forceAutoSize||nn)&&!lt;if(!ne&&!oe){t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",t.style.height=typeof _=="number"?"".concat(_,"px"):"100%";let Et=typeof I=="number"?I:void 0,Tt=typeof _=="number"?_:void 0;(Et!==void 0||Tt!==void 0)&&((wt=c==null?void 0:c.onSizeChange)==null||wt.call(c,{width:Et,height:Tt,autoSizingWidth:!1,autoSizingHeight:!1}));return}oe&&(t.style.height="0px"),ne&&(t.style.width="0px");let ft=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth)),ut=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight)),gt=i(ft,u,y),yt=i(ut,V,ee);ne?t.style.width="".concat(gt,"px"):t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",oe?t.style.height="".concat(yt,"px"):t.style.height=typeof _=="number"?"".concat(_,"px"):"100%";let on=ne&&y!==void 0&&ft>y,sn=oe&&ee!==void 0&&ut>ee;l.documentElement.style.overflowX=on?"auto":"",l.documentElement.style.overflowY=sn?"auto":"",(St=c==null?void 0:c.onSizeChange)==null||St.call(c,{width:gt,height:yt,autoSizingWidth:ne,autoSizingHeight:oe})};p(),this._autoSizeUpdate=p;let d=new ResizeObserver(p);d.observe(s.body),d.observe(s.documentElement);let m=new MutationObserver(p);m.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{d.disconnect(),m.disconnect(),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new T(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new T(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=M({},e);if(t.messageType===g.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=w.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(this,"dispose",()=>{this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=J(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===g.In.MutationObserverMessage||e.messageType===g.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var z=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var Mn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Te=class extends z{constructor(){super(...arguments);r(this,"type",D.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let d=E(),m="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=m;let f="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=f,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([c,u])=>{u===""||u===null||u===void 0?a.setAttribute(c,""):a.setAttribute(c,String(u))});let l=t.loader.url;i!=null&&i._hasParent&&(l=Mn(l,"_myop-comp",d)),a.src=l,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}return new X(e,t,s,a,i)})}};var ve={webcomponent_message_key:"myop_webcomponent_message"};var Z=class extends k{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=M({},e),s=super.send(t),i=new CustomEvent(ve.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=J(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 mt={},Re=class extends z{constructor(){super(...arguments);r(this,"type",D.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;mt[a.url]?console.log("Module alreday loaded or in loading process"):mt[a.url]=new Promise((m,f)=>{let l=a.url,c=document.createElement("script");c.type="module",c.src=l,c.onload=()=>{m()},c.onerror=()=>{f()},document.head.appendChild(c)}),await mt[a.url],await kt(1);let p="myop-comp-".concat(E()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new Z(e,t,s,d,i)})}};var Vt="0.3.19";var C=class extends be{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(H(M({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var L={id:"myop-id"};var R=(o,n)=>n.querySelectorAll("[".concat(L.id,"='").concat(o.refConfig.selector,"']"));var _e=class extends C{constructor(){super(...arguments);r(this,"messageType",g.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=R(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new se(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var ke=class extends C{constructor(){super(...arguments);r(this,"messageType",g.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var He=class extends Se{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var De=class extends C{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(L.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(L.id);p&&i.push(new xe(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new le(e.handlerUniqueId,i))});r(this,"messageType",g.DetectMyopRefsMessage)}};var Be=class extends C{constructor(){super(...arguments);r(this,"messageType",g.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var Le=class extends C{constructor(){super(...arguments);r(this,"messageType",g.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=R(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=m=>{s(new re(e.handlerUniqueId,B(m,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var Pe=class extends C{constructor(){super(...arguments);r(this,"messageType",g.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(L.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=O.Instance(),d=p.components.find(c=>c.id===e.options.id);d&&d.dispose();let m=p.components.indexOf(d);m!==-1&&p.components.splice(m,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(f.refs).forEach(c=>{let u=f.refs[c];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:c,componentDefinitionId:u.componentDefinition.id})}),s(new G(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new G(e.handlerUniqueId,[],!0));debugger}})().then()})}};var qt=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=B,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var Oe=class extends C{constructor(){super(...arguments);r(this,"messageType",g.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{qt(e,a=>{s(new ie(e.handlerUniqueId,a))},t)})}};var jt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(L.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:jt(i),required:i.required,validity:B(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},ze=class extends C{constructor(){super(...arguments);r(this,"messageType",g.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{R(e.ref,t.shadowRoot).forEach(a=>{s(new ae(jt(a)),e)})})}};var Ke=class extends C{constructor(){super(...arguments);r(this,"messageType",g.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var he=class extends we{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(ve.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===g.InitMessage){let p=a.content.id;this.components[p].context=new He(e,t)}}}),setTimeout(()=>{this.messageToHost(new de)},1)});r(this,"messageToHost",(e,t)=>{e.direction=w.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new ke(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new De(this.messageToHost,this.components),new Be(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new Oe(this.messageToHost,this.components),new ze(this.messageToHost,this.components),new Pe(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Ce("WebComponentSDK",he);var Gt="";var Cn="<!-- myop-web-component -->",In="myop-web-component",Qt=new Set,Jt=[],Ae,Xt=async()=>(Ae||(Ae=new he,Ae.init()),Ae);function xn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===F.open?"open":"closed",t=this.attachShadow({mode:e});Xt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var bn=(o,n,e)=>{customElements.define(o,xn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},wn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Sn=o=>(o=wn(o),o.replace(/_/g,"-"));var $e=class extends z{constructor(){super(...arguments);r(this,"type",D.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;if(this.isMyopWebComponent(a.HTML))return this.loadExtractedWebComponent(e,t,s,a.HTML,i);let p="myop-comp-".concat(E()),d;if(a.shadowRootMode===F.localFrame){let m=E(),f="myop-comp-".concat(m),l=document.createElement("iframe");l.id=f,l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,i);let c=l.contentDocument||l.contentWindow.document;c.open();let u=null;{let I=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(I)try{u=JSON.parse(I.getAttribute("content")||"{}")}catch(_){}}let y=a.HTML;if(i!=null&&i._inspection){let S=new DOMParser().parseFromString(a.HTML,"text/html"),I=S.getElementById("myop_preview");I==null||I.removeAttribute("type");let _=S.implementation.createHTMLDocument();_.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let te=_.body.firstChild;te&&S.head&&S.head.insertBefore(S.importNode(te,!0),S.head.firstChild),y=S.documentElement.outerHTML}else if((i==null?void 0:i.data)!==void 0){let S=new DOMParser().parseFromString(a.HTML,"text/html"),I=S.getElementById("myop_preview");I&&(I.remove(),y=S.documentElement.outerHTML)}c.writeln(y);let V='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),ee="<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.writeln("".concat(V).concat(ee)),(i==null?void 0:i.data)!==void 0){let q="<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>",S=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),I='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(S,";\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>");c.writeln(q+I)}c.close();let A=new X(e,t,s,l,i);return A.sizeMeta=u,A.initiated().then(()=>{A.observeAutoSize({forceAutoSize:!0}),i!=null&&i.hidden||A.show()}),A}if(a.shadowRootMode===F.none){let m=document.createElement("template");m.innerHTML=a.HTML,d=m.content.firstElementChild,Xt().then(f=>{f.connectedCallback(d,d)})}else{let m=Sn(e.name+t.id);Jt.includes(m)||(bn(m,a.HTML,a.shadowRootMode),Jt.push(m)),d=document.createElement(m)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,i),new Z(e,t,s,d,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(Cn)}extractWebComponentScript(e){let i=new DOMParser().parseFromString(e,"text/html").getElementById(In);return(i==null?void 0:i.textContent)||null}executeWebComponentScript(e,t){if(Qt.has(t)){console.log("[MyopWebComponent] Script already executed for ".concat(t,", skipping"));return}let s=document.createElement("script");s.textContent=e,s.id="myop-extracted-".concat(t),document.head.appendChild(s),Qt.add(t),console.log("[MyopWebComponent] Executed web component script: ".concat(t))}async loadExtractedWebComponent(e,t,s,i,a){let p=this.extractWebComponentScript(i);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),m=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(p,d);let f=window.__MYOP_TAG_NAME__;if(!f)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");m&&m!==f&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(m," to ").concat(f));let l="myop-comp-".concat(E()),c=document.createElement(f);c.id=l,a!=null&&a.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,c,a);let u=new N(e,t,s,c,f,a);return(a==null?void 0:a.data)!==void 0&&u.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(f,"> into container")),u}};var En=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:Q.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:Q.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Fe="__MYOP_CLOUD_REPOSITORY_MAIN__",Tn=()=>{if(typeof window<"u")return window[Fe];if(typeof globalThis<"u")return globalThis[Fe]},vn=o=>{typeof window<"u"&&(window[Fe]=o),typeof globalThis<"u"&&(globalThis[Fe]=o)},K=class K{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)}static get Main(){let n=Tn();return n||(K._main||(K._main=new K,vn(K._main)),K._main)}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let s=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;if(!i&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let m=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!m}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(m,f)=>{try{let l="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(l+="&preview=true");let y=(await(await fetch(l)).json()).item;if(!y){f(new Error('Component "'.concat(n,'" not found')));return}if(!y.consume_variant||!y.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let V=En(y);m(V)}catch(l){f(l)}})),await this.variants[d]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(K,"_main",null);var U=K;var Wp=U.Main;var Zt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=Ue(t);switch(s){case"component":{let[a,p]=i,d=await U.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:W.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=Ue(t),m=(await U.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(m&&m.instance.skinSelector.type===W.Segmented&&m.instance.resolvedExperiences){let f=m.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Ee.Segment){let l=f,u=m.instance.skinSelector.segments.find(y=>y.segmentId===l.segment.id);if(u)return m.instance.skinSelector=u==null?void 0:u.skinSelector,m}}}break}}}finally{return null}};var en="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",O=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"initiated",!1);r(this,"version",Vt);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,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==w.up&&n.data.messageType!==g.EnvelopedMessage)return;let e=n.data;if(e.messageType===g.InitRequest){this.components2init.forEach(s=>{s.send(new j(s.id))});return}if(e.messageType===g.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let s=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===g.EnvelopedMessage){let s=e,i=this.components.find(a=>a.id===s.destination);if(i){if(s.direction===w.down){s.message.messageType===v.name?i.onMessageReceived(s.message):(s.message.route=s.route,i.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let t=this.components.find(s=>s.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Te,new Re,new $e];if(this.componentsLoaders=[...e],n){let t={};n.forEach(s=>{let i=new s(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(s=>{t[s.type]||(t[s.type]=s)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case W.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case W.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let m=e.find(u=>u.type===Ee.Segment?u.segment.id===d.segmentId:!1);if(!m)throw new Error("experience not found");let l=m.segment,c=(t||{})[l.function];return c?await c():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var f,l,c,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await Zt(n);s&&(n=s);let i=M(M({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=M({},n),n.instance=M({},n.instance);let y=await this.runSkinSelector(n,i);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(c=t==null?void 0:t.hooks)!=null&&c.afterSkinSelected&&(y=await t.hooks.afterSkinSelected(M({},y))),n.instance.skinSelector={type:W.Dedicated,skin:y},t&&(t=M({},t),delete t.hooks),await dt(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(M({},p)));let d=this.componentsLoaders.find(y=>y.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await d.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==m),this.components2init=this.components2init.filter(y=>y!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=Ut(m,n.type.props,p));try{await ct(m,n,this.components)}catch(y){throw y}return t!=null&&t.skipInit||await m.initiated(),m});r(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,M({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,M({relative:{direction:"before",child:s}},t))}})}};r(O,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:en});if(!window.myop.hostSDK){let o=new O;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:en}),window.myop.hostSDK=o}var Rn=window.myop.hostSDK;Ce("hostSDK",Rn);export{O as HostSDK,Rn as hostSDK};