@myop/sdk 0.3.29 → 0.3.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/bundled-declarations.d.ts +7 -1
  2. package/dist/cjs/{_IframeSDK.a588c953.js → _IframeSDK.01a61f0b.js} +13 -3
  3. package/dist/cjs/{_IframeSDK.a588c953.js.map → _IframeSDK.01a61f0b.js.map} +2 -2
  4. package/dist/cjs/{_IframeSDK.aad83b0e.min.js → _IframeSDK.79b8258f.min.js} +1 -1
  5. package/dist/cjs/_MyopHelpers.172384f4.min.js +1 -0
  6. package/dist/cjs/{_MyopHelpers.39adea76.js → _MyopHelpers.95610381.js} +14 -1
  7. package/dist/cjs/{_MyopHelpers.39adea76.js.map → _MyopHelpers.95610381.js.map} +2 -2
  8. package/dist/cjs/{_WebComponentSDK.7cb826f6.min.js → _WebComponentSDK.2ac55fb8.min.js} +1 -1
  9. package/dist/cjs/{_WebComponentSDK.54cf170b.js → _WebComponentSDK.82b7afdf.js} +13 -3
  10. package/dist/cjs/{_WebComponentSDK.54cf170b.js.map → _WebComponentSDK.82b7afdf.js.map} +2 -2
  11. package/dist/cjs/{_hostSDK.cde5ef67.js → _hostSDK.aee4f072.js} +13 -3
  12. package/dist/cjs/{_hostSDK.cde5ef67.js.map → _hostSDK.aee4f072.js.map} +2 -2
  13. package/dist/cjs/{_hostSDK.5ff6334c.min.js → _hostSDK.ec7b5c9a.min.js} +1 -1
  14. package/dist/cjs/myop_sdk.js +14 -14
  15. package/dist/cjs/myop_sdk.js.map +1 -1
  16. package/dist/cjs/myop_sdk.min.js +1 -1
  17. package/dist/cjs-bundled/myop_sdk.bundled.js +18 -5
  18. package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
  19. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  20. package/dist/module/Iframe/index.js +14 -4
  21. package/dist/module/Iframe/index.js.map +2 -2
  22. package/dist/module/SDK.js +18 -5
  23. package/dist/module/SDK.js.map +2 -2
  24. package/dist/module/embeddedSDK.js +1 -1
  25. package/dist/module/helpers/CloudRepository.d.ts +6 -0
  26. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +1 -1
  27. package/dist/module/helpers/index.js +15 -2
  28. package/dist/module/helpers/index.js.map +2 -2
  29. package/dist/module/host/embeddedSDK.js +1 -1
  30. package/dist/module/host/index.js +14 -4
  31. package/dist/module/host/index.js.map +2 -2
  32. package/dist/module/webcomponent/index.js +14 -4
  33. package/dist/module/webcomponent/index.js.map +2 -2
  34. package/package.json +1 -1
  35. package/dist/cjs/_MyopHelpers.ce80c342.min.js +0 -1
@@ -1 +1 @@
1
- var en=Object.defineProperty,Kn=Object.defineProperties;var $n=Object.getOwnPropertyDescriptors;var Zt=Object.getOwnPropertySymbols;var Fn=Object.prototype.hasOwnProperty,Wn=Object.prototype.propertyIsEnumerable;var gt=(o,n,e)=>n in o?en(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Fn.call(n,e)&&gt(o,e,n[e]);if(Zt)for(var e of Zt(n))Wn.call(n,e)&&gt(o,e,n[e]);return o},z=(o,n)=>Kn(o,$n(n));var Nn=(o,n)=>{for(var e in n)en(o,e,{get:n[e],enumerable:!0})};var i=(o,n,e)=>gt(o,typeof n!="symbol"?n+"":n,e);var re=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 tn=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}},Be=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 Le={};Nn(Le,{AddEventListenerMessage:()=>It,BaseMyopMessage:()=>C,BindClickMessage:()=>Mt,ChangeTextMessage:()=>Ct,CleanupMessage:()=>Se,CleanupReplayMessage:()=>Ee,ClickReplayMessage:()=>G,CreateRefComponentMessage:()=>Ie,CustomRefMessage:()=>Y,DetectMyopRefsMessage:()=>St,DetectedMyopRefsMessage:()=>Z,DisposeMessage:()=>Te,ElementValueReplayMessage:()=>J,EnvelopedMessage:()=>xe,EventListenerCallbackMessage:()=>Q,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>_,ExecuteScriptReplyMessage:()=>j,GetAttributeMessage:()=>Et,GetAttributeReplayMessage:()=>be,GetElementValueMessage:()=>bt,InitMessage:()=>ae,InitRequest:()=>X,InitResponse:()=>Ce,MessageDirection:()=>b,MutationObserverMessage:()=>we,MyopBindMessage:()=>S,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>ht,Ref:()=>F,RefComponentCreatedMessage:()=>K,ResizeObserverMessage:()=>ve,SetAttributeMessage:()=>xt,SetInnerHtml:()=>wt,SetMutationObserverMessage:()=>Tt,SetResizeObserverMessage:()=>vt,stripFunction:()=>rn});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Un=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 qn=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 yt=o=>{let n=qn(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(Un(n.slice(t,t+16)));return e};var nn=o=>new Promise(n=>setTimeout(n,o));var b=class{};i(b,"down","down"),i(b,"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}},ht=class extends C{constructor(e){super();this.ref=e}},w=class extends C{constructor(e){super();this.replayToHandler=e}},S=class extends C{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",R())}},F=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=z(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 on="ClickReplayMessage",Mt=class extends S{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",on);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},G=class extends w{constructor(){super(...arguments);i(this,"messageType",on)}};var Ct=class extends C{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}};var sn="ExecuteScriptReplyMessage",Vn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Gn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,rn=o=>{let n=o.match(Vn);if(n)return n[1]||n[3];{let e=o.match(Gn);if(e)return e[1].trim()}},_=class extends S{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",sn);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=rn(this.content)}};i(_,"replierKey","send"),i(_,"completeStreamKey","completeStream");var j=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",sn)}};var Y=class extends _{constructor(e,t,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:d})=>{let c=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=z(h({},t),{_script:e.toString()})}};var an="EventListenerCallbackMessage",It=class extends S{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",an);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},Q=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",an);this.content={e:t}}};var xt=class extends C{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}};var pn="ElementValueReplayMessage",bt=class extends S{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",pn);i(this,"messageType","GetElementValueMessage")}},J=class extends w{constructor(e){super();this.content=e;i(this,"messageType",pn)}};var wt=class extends C{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}};var ae=class extends C{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},Ce=class extends ae{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},X=class extends C{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var dn="RefComponentCreatedMessage",Ie=class extends S{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",dn);i(this,"messageType","CreateRefComponentMessage")}},K=class extends w{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",dn)}};var xe=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 cn="DetectedMyopRefsMessage",St=class extends S{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",cn)}},Z=class extends w{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",cn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var mn="GetAttributeReplayMessage",Et=class extends S{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",mn);i(this,"messageType","GetAttributeMessage")}},be=class extends w{constructor(e){super();this.content=e;i(this,"messageType",mn)}};var k=class extends C{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}};var Tt=class extends C{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},we=class extends C{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ln="CleanupReplayMessage",Se=class extends S{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",ln);i(this,"messageType","CleanupMessage")}},Ee=class extends w{constructor(e){super();this.customCleanup=e;i(this,"messageType",ln)}};var Te=class extends C{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var vt=class extends C{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},ve=class extends C{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var Rt=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},pe=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!==b.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 Rt(s),this.messageToHost(new Ce(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 Ee(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],tn(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 $={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var ee={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var me={message:"message",code:"code"},de=class{};i(de,"code","code"),i(de,"component","component");var te={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Pe={Segment:"Segment",Promo:"Promo",AB:"AB"},ce=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 E={id:"myop-id"};var Oe=class extends M{constructor(){super(...arguments);i(this,"messageType",u.DetectMyopRefsMessage);i(this,"executor",e=>{let t=document.querySelectorAll("[".concat(E.id,"]")),s=[];t.forEach(r=>{let a=r.getAttribute(E.id);a&&s.push(new re(a,r.tagName,r.getBoundingClientRect()))}),this.messageToHost(new Z(e.handlerUniqueId,s))})}};var I=(o,n)=>n.querySelectorAll("[".concat(E.id,"='").concat(o.refConfig.selector,"']")),fn=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Ae=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 G,e)};r.addEventListener("click",a);let p=()=>{r.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(r=>r())}})}};var ze=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 _t=o=>o!==Object(o),jn=o=>typeof o=="function",Ht=o=>{if(_t(o))return!0;if(jn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!Ht(e))return!1}else{if(_t(e))continue;return!1}}return!0},H=(o,n={},e=!0,t=new WeakMap)=>{if(_t(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]=H(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]=H(o[r],!0,e,t)):typeof a=="object"&&(s[r]=H(o[r],a,e,t)))}return s}return{}};var Ke=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=H,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)};var $e=class extends M{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"executor",e=>{Ke(e,s=>{this.messageToHost(new j(e.handlerUniqueId,s))},new ce(document.documentElement))})}};var Fe="__federation__",un="onLoad";var le=(o,n)=>{window[Fe]&&window[Fe][o]&&window[Fe][o][un]&&window[Fe][o][un]({[o]:n})};var We=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,H(p,e.serializableSkeleton)))})};r.addEventListener(e.type,a),s.push(()=>{r.removeEventListener(e.type,a)})}),()=>{s.forEach(r=>{r()})}})}};var Ne=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 P=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)||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===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=b.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=b.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 Se(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new Te);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var gn={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 Re=class extends P{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 xe(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var ne=class extends P{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=fe(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 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},fe=(o,n,e,t,s,r)=>{let a=Yn("".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)}},yn=(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),hn=(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."))},Mn=(o,n,e)=>{let t=n.reduce((r,a)=>z(h({},r),{[a.name]:h({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(yn(p,a,o))return!1;if(p.behavior.type===me.code){if(o instanceof ne)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===$.HTMLLoader&&e.loader.shadowRootMode===ee.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return hn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(F.create(p.behavior.ref)),c.push(g=>{d(g)}),p.behavior.params&&c.push(...p.behavior.params);let f=Le[p.behavior.message];o.send(new f(...c))}):null},set:(r,a,p)=>{let d=t[a];if(yn(d,a,o))return!1;if(d.behavior.type===me.code){if(o instanceof ne){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===$.HTMLLoader&&e.loader.shadowRootMode===ee.localFrame){let f=d.behavior,g=o.element.contentWindow,y=f.remap||a;if(g[y]=p,y==="myop_cta_handler"&&g.__myop_cta_queue){let l=g.__myop_cta_queue;g.__myop_cta_queue=null,l.forEach(m=>{o.markedForDisposed||p(m.action,m.payload)})}return!0}return hn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(F.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let f=Le[d.behavior.message];return o.send(new f(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Qn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{Ht(p)||gn.notSerializableRefCall(t,p)}),n.send(new Y(({ref:p,propName:d,functionArgs:c,makeSerializable:f})=>{if(p){let g=p[d];return f(typeof g=="function"?p[d](...c):g,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new Y(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),kt=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 Re(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new Ie(o.refConfig,n,z(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let f=e.find(g=>g.id==p.id);if(f!==p){s.refs[o.refConfig.name]=f,r(f);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(g=>{let y=n.instance.resolvedNestedComponents.find(m=>m.type.id===g.componentDefinitionId).type,l=new Re(y,p);l.setInitiated(),p.refs[g.refName]=l,e.push(l)});try{await Dt(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(g){a(g)}}))})},Dt=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==de.component){if(t){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(y=>y.type.id===c);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let g=F.create("",r,o);try{let y=await kt(g,f,e);o.refs[r.name]=y,a()}catch(y){p(y)}}else try{let c=F.create("",r,o);o.refs[r.name]=Qn(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}};var ue=class extends P{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,m,D)=>m!==void 0&&l<m?m:D!==void 0&&l>D?D:l,a=l=>{if(l===void 0)return;if(typeof l=="number")return l;let m=parseFloat(l);return isNaN(m)?void 0:m},p=()=>{var Nt,Ut,qt,Vt,Gt,jt,Yt,Qt;let l=t.contentDocument;if(!l)return;let m=this._autoSizeOptions,D=a(m==null?void 0:m.minWidth),U=a(m==null?void 0:m.maxWidth),q=a(m==null?void 0:m.minHeight),B=a(m==null?void 0:m.maxHeight),T=(Nt=m==null?void 0:m.loaderMinHeight)!=null?Nt:50,v=((Ut=this.sizeMeta)==null?void 0:Ut.width)==="100%"?"100%":void 0,ye=((qt=this.sizeMeta)==null?void 0:qt.height)==="100%"?"100%":void 0,L=(Gt=(Vt=m==null?void 0:m.explicitWidth)!=null?Vt:v)!=null?Gt:"100%",V=(jt=m==null?void 0:m.explicitHeight)!=null?jt:ye,Pt=L!==void 0,Ot=V!==void 0,ft=this.container.getBoundingClientRect(),_n=ft.width===0,Hn=ft.height===0||ft.height===T,se=(m!=null&&m.forceAutoSize||_n)&&!Pt,ie=(m!=null&&m.forceAutoSize||Hn)&&!Ot;if(!se&&!ie){t.style.width=typeof L=="number"?"".concat(L,"px"):"100%",t.style.height=typeof V=="number"?"".concat(V,"px"):"100%",(Yt=m==null?void 0:m.onSizeChange)==null||Yt.call(m,{width:typeof L=="number"?L:void 0,height:typeof V=="number"?V:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let kn=t.style.transition,A=this.container,Dn=A.style.transition;t.style.transition="none",A.style.transition="none";let At=t.getBoundingClientRect().height,zt=t.getBoundingClientRect().width,Kt=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight,l.body.getBoundingClientRect().height)),$t=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth,l.body.getBoundingClientRect().width)),he=$t,Me=Kt,Bn=ie&&Kt>At+1,Ln=se&&$t>zt+1,He=ie&&!Bn,ke=se&&!Ln;if(He||ke){let An=A.style.minHeight,zn=A.style.minWidth;He&&(A.style.minHeight="".concat(At,"px")),ke&&(A.style.minWidth="".concat(zt,"px")),He&&(t.style.height="0px"),ke&&(t.style.width="0px"),he=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth,l.body.getBoundingClientRect().width)),Me=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight,l.body.getBoundingClientRect().height));let Jt=He&&Me<2,Xt=ke&&he<2;if(Jt||Xt){let De=l.createElement("style");De.id="__myop_measure";let ut=[];Jt&&ut.push("height: auto !important","min-height: 0 !important","max-height: none !important"),Xt&&ut.push("width: auto !important","min-width: 0 !important","max-width: none !important"),De.textContent="*, *::before, *::after { ".concat(ut.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),l.head.appendChild(De),he=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth,l.body.getBoundingClientRect().width)),Me=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight,l.body.getBoundingClientRect().height)),De.remove()}A.style.minHeight=An,A.style.minWidth=zn}let Ft=r(he,D,U),Wt=r(Me,q,B);se?t.style.width="".concat(Ft,"px"):t.style.width=typeof L=="number"?"".concat(L,"px"):"100%",ie?t.style.height="".concat(Wt,"px"):t.style.height=typeof V=="number"?"".concat(V,"px"):"100%",t.offsetHeight,t.style.transition=kn,A.style.transition=Dn;let Pn=se&&U!==void 0&&he>U,On=ie&&B!==void 0&&Me>B;l.documentElement.style.overflowX=Pn?"auto":"",l.documentElement.style.overflowY=On?"auto":"",(Qt=m==null?void 0:m.onSizeChange)==null||Qt.call(m,{width:Ft,height:Wt,autoSizingWidth:se,autoSizingHeight:ie})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},f=new ResizeObserver(()=>c());f.observe(s.body),f.observe(s.documentElement);let g=new MutationObserver(()=>c());g.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let y=()=>{f.disconnect(),g.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=y,y});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=b.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=fe(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 W=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 Jn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Ue=class extends W{constructor(){super(...arguments);i(this,"type",$.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(),c="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=c;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(([y,l])=>{l===""||l===null||l===void 0?a.setAttribute(y,""):a.setAttribute(y,String(l))});let g=t.loader.url;r!=null&&r._hasParent&&(g=Jn(g,"_myop-comp",d)),a.src=g,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,r)}return new ue(e,t,s,a,r)})}};var qe={webcomponent_message_key:"myop_webcomponent_message"};var ge=class extends P{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(qe.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=fe(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 Bt={},Ve=class extends W{constructor(){super(...arguments);i(this,"type",$.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;Bt[a.url]?console.log("Module alreday loaded or in loading process"):Bt[a.url]=new Promise((c,f)=>{let g=a.url,y=document.createElement("script");y.type="module",y.src=g,y.onload=()=>{c()},y.onerror=()=>{f()},document.head.appendChild(y)}),await Bt[a.url],await nn(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 ge(e,t,s,d,r)})}};var Ge="0.3.29";var x=class extends Be{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(z(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 je=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 G(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Ye=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 Qe=class extends ce{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Je=class extends x{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(E.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(E.id);p&&r.push(new re(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Z(e.handlerUniqueId,r))});i(this,"messageType",u.DetectMyopRefsMessage)}};var Xe=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 Ze=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=c=>{s(new Q(e.handlerUniqueId,H(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var et=class extends x{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=O.Instance(),d=p.components.find(y=>y.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),g=[];Object.keys(f.refs).forEach(y=>{let l=f.refs[y];l=l.__nonProxied||l,l.componentDefinition&&g.push({refName:y,componentDefinitionId:l.componentDefinition.id})}),s(new K(e.handlerUniqueId,g))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new K(e.handlerUniqueId,[],!0));debugger}})().then()})}};var tt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{Ke(e,a=>{s(new j(e.handlerUniqueId,a))},t)})}};var Cn=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(E.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Cn(r),required:r.required,validity:H(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},nt=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 J(Cn(a)),e)})})}};var ot=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 _e=class extends pe{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(qe.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 Qe(e,t)}}}),setTimeout(()=>{this.messageToHost(new X)},1)});i(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new Ye(this.messageToHost,this.components),new ot(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Je(this.messageToHost,this.components),new Xe(this.messageToHost,this.components),new Ze(this.messageToHost,this.components),new tt(this.messageToHost,this.components),new nt(this.messageToHost,this.components),new et(this.messageToHost,this.components)]);i(this,"init",()=>{})}};le("WebComponentSDK",_e);var In="";var Xn="<!-- myop-web-component -->",Zn="myop-web-component",bn=new Set,wn=[],st,Sn=async()=>(st||(st=new _e,st.init()),st);function eo(o,n){return class extends HTMLElement{connectedCallback(){let e=n===ee.open?"open":"closed",t=this.attachShadow({mode:e});Sn().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var to=(o,n,e)=>{customElements.define(o,eo(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},no=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),oo=o=>(o=no(o),o.replace(/_/g,"-"));var it=class extends W{constructor(){super(...arguments);i(this,"type",$.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===ee.localFrame){let c=R(),f="myop-comp-".concat(c),g=document.createElement("iframe");g.id=f,g.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=""),g=this.appendChild(s,g,r);let y=g.contentDocument||g.contentWindow.document;y.open();let l=null;{let v=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(v)try{l=JSON.parse(v.getAttribute("content")||"{}")}catch(ye){}}let m=a.HTML;if(r!=null&&r._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),v=T.getElementById("myop_preview");v==null||v.removeAttribute("type");let ye=T.implementation.createHTMLDocument();ye.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let L=ye.body.firstChild;L&&T.head&&T.head.insertBefore(T.importNode(L,!0),T.head.firstChild),m=T.documentElement.outerHTML}else if((r==null?void 0:r.data)!==void 0){let T=new DOMParser().parseFromString(a.HTML,"text/html"),v=T.getElementById("myop_preview");v&&(v.remove(),m=T.documentElement.outerHTML)}y.writeln(m);let D='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),U="<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(y.writeln("".concat(D).concat(U)),(r==null?void 0:r.data)!==void 0){let B="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",T=JSON.stringify(r.data).replace(/<\/script/gi,"\\u003c/script"),v='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(T,";\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>");y.writeln(B+v)}y.close();let q=new ue(e,t,s,g,r);return q.sizeMeta=l,q.initiated().then(()=>{if((r==null?void 0:r.autoSize)===!1)return;let B=!1;q.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!B&&!(r!=null&&r.hidden)&&(B=!0,q.show())}})}),q}if(a.shadowRootMode===ee.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Sn().then(f=>{f.connectedCallback(d,d)})}else{let c=oo(e.name+t.id);wn.includes(c)||(to(c,a.HTML,a.shadowRootMode),wn.push(c)),d=document.createElement(c)}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 ge(e,t,s,d,r)})}isMyopWebComponent(e){return e.trimStart().startsWith(Xn)}extractWebComponentScript(e){let r=new DOMParser().parseFromString(e,"text/html").getElementById(Zn);return(r==null?void 0:r.textContent)||null}executeWebComponentScript(e,t){if(bn.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),bn.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),c=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__");c&&c!==f&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(c," to ").concat(f));let g="myop-comp-".concat(R()),y=document.createElement(f);y.id=g,a!=null&&a.hidden&&(y.style.opacity="0",y.style.position="absolute",y.style.height="0",y.style.width="0",y.style.pointerEvents="none",y.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,y,a);let l=new ne(e,t,s,y,f,a);return(a==null?void 0:a.data)!==void 0&&l.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(f,"> into container")),l}};var so=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:me.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:me.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),rt="__MYOP_CLOUD_REPOSITORY_MAIN__",io=()=>{if(typeof window<"u")return window[rt];if(typeof globalThis<"u")return globalThis[rt]},ro=o=>{typeof window<"u"&&(window[rt]=o),typeof globalThis<"u"&&(globalThis[rt]=o)},N=class N{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);i(this,"_staticMode",!1)}static get Main(){let n=io();return n||(N._main||(N._main=new N,ro(N._main)),N._main)}enableStaticMode(){this._staticMode=!0}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 c=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!c}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(c,f)=>{try{let g;if(this._staticMode){let U=p?"preview":a;g="".concat(this._baseUrl,"/components/").concat(n,"/").concat(U,".json")}else g="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a),p&&(g+="&preview=true");let y=await fetch(g);if(!y.ok){f(new Error('Failed to load component "'.concat(n,'" (').concat(y.status).concat(this._staticMode?" from ".concat(g):"",")")));return}let m=(await y.json()).item;if(!m){f(new Error('Component "'.concat(n,'" not found')));return}if(!m.consume_variant||!m.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let D=so(m);this.variants[d].resolved=D,c(D)}catch(g){delete this.variants[d],f(g)}})),await this.variants[d]}getResolvedConfig(n,e,t){var c;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 f=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!f}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return((c=this.variants[d])==null?void 0:c.resolved)||null}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){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(r.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};i(N,"_main",null);var oe=N;var ac=oe.Main;var En=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=yt(t);switch(s){case"component":{let[a,p]=r,d=await oe.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:te.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=yt(t),c=(await oe.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(c&&c.instance.skinSelector.type===te.Segmented&&c.instance.resolvedExperiences){let f=c.instance.resolvedExperiences.find(g=>g.id===p);if((f==null?void 0:f.type)===Pe.Segment){let g=f,l=c.instance.skinSelector.segments.find(m=>m.segmentId===g.segment.id);if(l)return c.instance.skinSelector=l==null?void 0:l.skinSelector,c}}}break}}}finally{return null}};var Tn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",O=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",Ge);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!==b.up&&n.data.messageType!==u.EnvelopedMessage)return;let e=n.data;if(e.messageType===u.InitRequest){this.components2init.forEach(s=>{s.send(new ae(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===b.down){s.message.messageType===k.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 Ue,new Ve,new it];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 te.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case te.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(l=>l.type===Pe.Segment?l.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let g=c.segment,y=(t||{})[g.function];return y?await y():(console.warn("segmentId:".concat(d.segmentId,", ").concat(g.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,g,y,l;if(!e){debugger;throw new Error("no container was found for this component")}let s=await En(n);s&&(n=s);let r=h(h({},(f=this.loaderHooks)!=null?f:{}),(g=t==null?void 0:t.hooks)!=null?g:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let m=await this.runSkinSelector(n,r);if(!m)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(y=t==null?void 0:t.hooks)!=null&&y.afterSkinSelected&&(m=await t.hooks.afterSkinSelected(h({},m))),n.instance.skinSelector={type:te.Dedicated,skin:m},t&&(t=h({},t),delete t.hooks),await kt(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");(l=t==null?void 0:t.hooks)!=null&&l.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(m=>m.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(m=>m!==c),this.components2init=this.components2init.filter(m=>m!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=Mn(c,n.type.props,p));try{await Dt(c,n,this.components)}catch(m){throw m}return t!=null&&t.skipInit||await c.initiated(),c});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(O,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Tn});if(!window.myop.hostSDK){let o=new O;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Tn}),window.myop.hostSDK=o}var ao=window.myop.hostSDK;le("hostSDK",ao);var at=class extends M{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"executor",e=>{(async()=>{let s=document.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await O.Instance().loadComponent(e.nestedComponentConfig,s.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new K(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new K(e.handlerUniqueId,[],!0));debugger}})().then()})}};var vn=(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 pt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetMutationObserverMessage);i(this,"executor",e=>{e.source&&vn(document.body,()=>{this.messageToHost(new we)})})}};var Rn=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(E.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Rn(r),required:r.required,validity:H(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},dt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.GetElementValueMessage);i(this,"executor",e=>{I(e.ref,document).forEach(s=>{this.messageToHost(new J(Rn(s)),e)})})}};var ct=class extends M{constructor(){super(...arguments);i(this,"messageType",u.GetAttributeMessage);i(this,"executor",e=>{let t=fn(e.ref,document);t&&this.messageToHost(new be(t.getAttribute(e.name)),e)})}};var mt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetResizeObserverMessage);i(this,"executor",e=>{let t=new ResizeObserver(s=>{this.messageToHost(new ve)});return t.observe(document.body),()=>{t.disconnect()}})}};var lt=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 Lt=class extends pe{constructor(){super();i(this,"version",Ge);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=b.up,(r=window.parent)==null||r.postMessage(h({},e),"*")});i(this,"supportedHandlers",[new ze(this.messageToHost),new lt(this.messageToHost),new Ae(this.messageToHost),new Oe(this.messageToHost),new $e(this.messageToHost),new We(this.messageToHost),new Ne(this.messageToHost),new dt(this.messageToHost),new pt(this.messageToHost),new mt(this.messageToHost),new ct(this.messageToHost),new at(this.messageToHost)]);i(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new X)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};le("IframeSDK",Lt);export{Lt as IframeSDK};
1
+ var en=Object.defineProperty,Kn=Object.defineProperties;var $n=Object.getOwnPropertyDescriptors;var Zt=Object.getOwnPropertySymbols;var Fn=Object.prototype.hasOwnProperty,Wn=Object.prototype.propertyIsEnumerable;var gt=(o,n,e)=>n in o?en(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Fn.call(n,e)&&gt(o,e,n[e]);if(Zt)for(var e of Zt(n))Wn.call(n,e)&&gt(o,e,n[e]);return o},K=(o,n)=>Kn(o,$n(n));var Nn=(o,n)=>{for(var e in n)en(o,e,{get:n[e],enumerable:!0})};var i=(o,n,e)=>gt(o,typeof n!="symbol"?n+"":n,e);var re=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 tn=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}},Be=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 Le={};Nn(Le,{AddEventListenerMessage:()=>It,BaseMyopMessage:()=>C,BindClickMessage:()=>Mt,ChangeTextMessage:()=>Ct,CleanupMessage:()=>Se,CleanupReplayMessage:()=>Ee,ClickReplayMessage:()=>G,CreateRefComponentMessage:()=>Ie,CustomRefMessage:()=>Y,DetectMyopRefsMessage:()=>St,DetectedMyopRefsMessage:()=>Z,DisposeMessage:()=>Te,ElementValueReplayMessage:()=>J,EnvelopedMessage:()=>xe,EventListenerCallbackMessage:()=>Q,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>_,ExecuteScriptReplyMessage:()=>j,GetAttributeMessage:()=>Et,GetAttributeReplayMessage:()=>be,GetElementValueMessage:()=>bt,InitMessage:()=>ae,InitRequest:()=>X,InitResponse:()=>Ce,MessageDirection:()=>b,MutationObserverMessage:()=>we,MyopBindMessage:()=>S,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>ht,Ref:()=>W,RefComponentCreatedMessage:()=>$,ResizeObserverMessage:()=>ve,SetAttributeMessage:()=>xt,SetInnerHtml:()=>wt,SetMutationObserverMessage:()=>Tt,SetResizeObserverMessage:()=>vt,stripFunction:()=>rn});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Un=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 qn=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 yt=o=>{let n=qn(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(Un(n.slice(t,t+16)));return e};var nn=o=>new Promise(n=>setTimeout(n,o));var b=class{};i(b,"down","down"),i(b,"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}},ht=class extends C{constructor(e){super();this.ref=e}},w=class extends C{constructor(e){super();this.replayToHandler=e}},S=class extends C{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",R())}},W=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=K(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 on="ClickReplayMessage",Mt=class extends S{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",on);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},G=class extends w{constructor(){super(...arguments);i(this,"messageType",on)}};var Ct=class extends C{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}};var sn="ExecuteScriptReplyMessage",Vn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Gn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,rn=o=>{let n=o.match(Vn);if(n)return n[1]||n[3];{let e=o.match(Gn);if(e)return e[1].trim()}},_=class extends S{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",sn);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=rn(this.content)}};i(_,"replierKey","send"),i(_,"completeStreamKey","completeStream");var j=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",sn)}};var Y=class extends _{constructor(e,t,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:d})=>{let c=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=K(h({},t),{_script:e.toString()})}};var an="EventListenerCallbackMessage",It=class extends S{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",an);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},Q=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",an);this.content={e:t}}};var xt=class extends C{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}};var pn="ElementValueReplayMessage",bt=class extends S{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",pn);i(this,"messageType","GetElementValueMessage")}},J=class extends w{constructor(e){super();this.content=e;i(this,"messageType",pn)}};var wt=class extends C{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}};var ae=class extends C{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},Ce=class extends ae{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},X=class extends C{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var dn="RefComponentCreatedMessage",Ie=class extends S{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",dn);i(this,"messageType","CreateRefComponentMessage")}},$=class extends w{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",dn)}};var xe=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 cn="DetectedMyopRefsMessage",St=class extends S{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",cn)}},Z=class extends w{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",cn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var mn="GetAttributeReplayMessage",Et=class extends S{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",mn);i(this,"messageType","GetAttributeMessage")}},be=class extends w{constructor(e){super();this.content=e;i(this,"messageType",mn)}};var k=class extends C{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}};var Tt=class extends C{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},we=class extends C{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ln="CleanupReplayMessage",Se=class extends S{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",ln);i(this,"messageType","CleanupMessage")}},Ee=class extends w{constructor(e){super();this.customCleanup=e;i(this,"messageType",ln)}};var Te=class extends C{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var vt=class extends C{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},ve=class extends C{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var Rt=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},pe=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!==b.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 Rt(s),this.messageToHost(new Ce(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 Ee(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],tn(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 F={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var ee={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var me={message:"message",code:"code"},de=class{};i(de,"code","code"),i(de,"component","component");var te={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Pe={Segment:"Segment",Promo:"Promo",AB:"AB"},ce=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 E={id:"myop-id"};var Oe=class extends M{constructor(){super(...arguments);i(this,"messageType",u.DetectMyopRefsMessage);i(this,"executor",e=>{let t=document.querySelectorAll("[".concat(E.id,"]")),s=[];t.forEach(r=>{let a=r.getAttribute(E.id);a&&s.push(new re(a,r.tagName,r.getBoundingClientRect()))}),this.messageToHost(new Z(e.handlerUniqueId,s))})}};var I=(o,n)=>n.querySelectorAll("[".concat(E.id,"='").concat(o.refConfig.selector,"']")),fn=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Ae=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 G,e)};r.addEventListener("click",a);let p=()=>{r.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(r=>r())}})}};var ze=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 _t=o=>o!==Object(o),jn=o=>typeof o=="function",Ht=o=>{if(_t(o))return!0;if(jn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!Ht(e))return!1}else{if(_t(e))continue;return!1}}return!0},H=(o,n={},e=!0,t=new WeakMap)=>{if(_t(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]=H(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]=H(o[r],!0,e,t)):typeof a=="object"&&(s[r]=H(o[r],a,e,t)))}return s}return{}};var Ke=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=H,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)};var $e=class extends M{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"executor",e=>{Ke(e,s=>{this.messageToHost(new j(e.handlerUniqueId,s))},new ce(document.documentElement))})}};var Fe="__federation__",un="onLoad";var le=(o,n)=>{window[Fe]&&window[Fe][o]&&window[Fe][o][un]&&window[Fe][o][un]({[o]:n})};var We=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,H(p,e.serializableSkeleton)))})};r.addEventListener(e.type,a),s.push(()=>{r.removeEventListener(e.type,a)})}),()=>{s.forEach(r=>{r()})}})}};var Ne=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 O=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)||A.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=b.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=b.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 Se(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new Te);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var gn={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 Re=class extends O{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 xe(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var ne=class extends O{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=fe(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 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},fe=(o,n,e,t,s,r)=>{let a=Yn("".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)}},yn=(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),hn=(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."))},Mn=(o,n,e)=>{let t=n.reduce((r,a)=>K(h({},r),{[a.name]:h({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(yn(p,a,o))return!1;if(p.behavior.type===me.code){if(o instanceof ne)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===F.HTMLLoader&&e.loader.shadowRootMode===ee.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return hn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(W.create(p.behavior.ref)),c.push(g=>{d(g)}),p.behavior.params&&c.push(...p.behavior.params);let f=Le[p.behavior.message];o.send(new f(...c))}):null},set:(r,a,p)=>{let d=t[a];if(yn(d,a,o))return!1;if(d.behavior.type===me.code){if(o instanceof ne){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===F.HTMLLoader&&e.loader.shadowRootMode===ee.localFrame){let f=d.behavior,g=o.element.contentWindow,y=f.remap||a;if(g[y]=p,y==="myop_cta_handler"&&g.__myop_cta_queue){let l=g.__myop_cta_queue;g.__myop_cta_queue=null,l.forEach(m=>{o.markedForDisposed||p(m.action,m.payload)})}return!0}return hn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(W.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let f=Le[d.behavior.message];return o.send(new f(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Qn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{Ht(p)||gn.notSerializableRefCall(t,p)}),n.send(new Y(({ref:p,propName:d,functionArgs:c,makeSerializable:f})=>{if(p){let g=p[d];return f(typeof g=="function"?p[d](...c):g,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new Y(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),kt=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 Re(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new Ie(o.refConfig,n,K(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let f=e.find(g=>g.id==p.id);if(f!==p){s.refs[o.refConfig.name]=f,r(f);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(g=>{let y=n.instance.resolvedNestedComponents.find(m=>m.type.id===g.componentDefinitionId).type,l=new Re(y,p);l.setInitiated(),p.refs[g.refName]=l,e.push(l)});try{await Dt(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(g){a(g)}}))})},Dt=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==de.component){if(t){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(y=>y.type.id===c);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let g=W.create("",r,o);try{let y=await kt(g,f,e);o.refs[r.name]=y,a()}catch(y){p(y)}}else try{let c=W.create("",r,o);o.refs[r.name]=Qn(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}};var ue=class extends O{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,m,D)=>m!==void 0&&l<m?m:D!==void 0&&l>D?D:l,a=l=>{if(l===void 0)return;if(typeof l=="number")return l;let m=parseFloat(l);return isNaN(m)?void 0:m},p=()=>{var Nt,Ut,qt,Vt,Gt,jt,Yt,Qt;let l=t.contentDocument;if(!l)return;let m=this._autoSizeOptions,D=a(m==null?void 0:m.minWidth),q=a(m==null?void 0:m.maxWidth),L=a(m==null?void 0:m.minHeight),B=a(m==null?void 0:m.maxHeight),T=(Nt=m==null?void 0:m.loaderMinHeight)!=null?Nt:50,v=((Ut=this.sizeMeta)==null?void 0:Ut.width)==="100%"?"100%":void 0,ye=((qt=this.sizeMeta)==null?void 0:qt.height)==="100%"?"100%":void 0,P=(Gt=(Vt=m==null?void 0:m.explicitWidth)!=null?Vt:v)!=null?Gt:"100%",V=(jt=m==null?void 0:m.explicitHeight)!=null?jt:ye,Pt=P!==void 0,Ot=V!==void 0,ft=this.container.getBoundingClientRect(),_n=ft.width===0,Hn=ft.height===0||ft.height===T,se=(m!=null&&m.forceAutoSize||_n)&&!Pt,ie=(m!=null&&m.forceAutoSize||Hn)&&!Ot;if(!se&&!ie){t.style.width=typeof P=="number"?"".concat(P,"px"):"100%",t.style.height=typeof V=="number"?"".concat(V,"px"):"100%",(Yt=m==null?void 0:m.onSizeChange)==null||Yt.call(m,{width:typeof P=="number"?P:void 0,height:typeof V=="number"?V:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let kn=t.style.transition,z=this.container,Dn=z.style.transition;t.style.transition="none",z.style.transition="none";let At=t.getBoundingClientRect().height,zt=t.getBoundingClientRect().width,Kt=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight,l.body.getBoundingClientRect().height)),$t=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth,l.body.getBoundingClientRect().width)),he=$t,Me=Kt,Bn=ie&&Kt>At+1,Ln=se&&$t>zt+1,He=ie&&!Bn,ke=se&&!Ln;if(He||ke){let An=z.style.minHeight,zn=z.style.minWidth;He&&(z.style.minHeight="".concat(At,"px")),ke&&(z.style.minWidth="".concat(zt,"px")),He&&(t.style.height="0px"),ke&&(t.style.width="0px"),he=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth,l.body.getBoundingClientRect().width)),Me=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight,l.body.getBoundingClientRect().height));let Jt=He&&Me<2,Xt=ke&&he<2;if(Jt||Xt){let De=l.createElement("style");De.id="__myop_measure";let ut=[];Jt&&ut.push("height: auto !important","min-height: 0 !important","max-height: none !important"),Xt&&ut.push("width: auto !important","min-width: 0 !important","max-width: none !important"),De.textContent="*, *::before, *::after { ".concat(ut.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),l.head.appendChild(De),he=Math.ceil(Math.max(l.documentElement.scrollWidth,l.body.scrollWidth,l.body.getBoundingClientRect().width)),Me=Math.ceil(Math.max(l.documentElement.scrollHeight,l.body.scrollHeight,l.body.getBoundingClientRect().height)),De.remove()}z.style.minHeight=An,z.style.minWidth=zn}let Ft=r(he,D,q),Wt=r(Me,L,B);se?t.style.width="".concat(Ft,"px"):t.style.width=typeof P=="number"?"".concat(P,"px"):"100%",ie?t.style.height="".concat(Wt,"px"):t.style.height=typeof V=="number"?"".concat(V,"px"):"100%",t.offsetHeight,t.style.transition=kn,z.style.transition=Dn;let Pn=se&&q!==void 0&&he>q,On=ie&&B!==void 0&&Me>B;l.documentElement.style.overflowX=Pn?"auto":"",l.documentElement.style.overflowY=On?"auto":"",(Qt=m==null?void 0:m.onSizeChange)==null||Qt.call(m,{width:Ft,height:Wt,autoSizingWidth:se,autoSizingHeight:ie})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},f=new ResizeObserver(()=>c());f.observe(s.body),f.observe(s.documentElement);let g=new MutationObserver(()=>c());g.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let y=()=>{f.disconnect(),g.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=y,y});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=b.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=fe(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 N=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 Jn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Ue=class extends N{constructor(){super(...arguments);i(this,"type",F.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(),c="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=c;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(([y,l])=>{l===""||l===null||l===void 0?a.setAttribute(y,""):a.setAttribute(y,String(l))});let g=t.loader.url;r!=null&&r._hasParent&&(g=Jn(g,"_myop-comp",d)),a.src=g,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,r)}return new ue(e,t,s,a,r)})}};var qe={webcomponent_message_key:"myop_webcomponent_message"};var ge=class extends O{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(qe.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=fe(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 Bt={},Ve=class extends N{constructor(){super(...arguments);i(this,"type",F.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;Bt[a.url]?console.log("Module alreday loaded or in loading process"):Bt[a.url]=new Promise((c,f)=>{let g=a.url,y=document.createElement("script");y.type="module",y.src=g,y.onload=()=>{c()},y.onerror=()=>{f()},document.head.appendChild(y)}),await Bt[a.url],await nn(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 ge(e,t,s,d,r)})}};var Ge="0.3.31";var x=class extends Be{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(K(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 je=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 G(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Ye=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 Qe=class extends ce{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Je=class extends x{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(E.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(E.id);p&&r.push(new re(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Z(e.handlerUniqueId,r))});i(this,"messageType",u.DetectMyopRefsMessage)}};var Xe=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 Ze=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=c=>{s(new Q(e.handlerUniqueId,H(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var et=class extends x{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=A.Instance(),d=p.components.find(y=>y.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),g=[];Object.keys(f.refs).forEach(y=>{let l=f.refs[y];l=l.__nonProxied||l,l.componentDefinition&&g.push({refName:y,componentDefinitionId:l.componentDefinition.id})}),s(new $(e.handlerUniqueId,g))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new $(e.handlerUniqueId,[],!0));debugger}})().then()})}};var tt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{Ke(e,a=>{s(new j(e.handlerUniqueId,a))},t)})}};var Cn=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(E.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Cn(r),required:r.required,validity:H(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},nt=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 J(Cn(a)),e)})})}};var ot=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 _e=class extends pe{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(qe.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 Qe(e,t)}}}),setTimeout(()=>{this.messageToHost(new X)},1)});i(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new Ye(this.messageToHost,this.components),new ot(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Je(this.messageToHost,this.components),new Xe(this.messageToHost,this.components),new Ze(this.messageToHost,this.components),new tt(this.messageToHost,this.components),new nt(this.messageToHost,this.components),new et(this.messageToHost,this.components)]);i(this,"init",()=>{})}};le("WebComponentSDK",_e);var In="";var Xn="<!-- myop-web-component -->",Zn="myop-web-component",bn=new Set,wn=[],st,Sn=async()=>(st||(st=new _e,st.init()),st);function eo(o,n){return class extends HTMLElement{connectedCallback(){let e=n===ee.open?"open":"closed",t=this.attachShadow({mode:e});Sn().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var to=(o,n,e)=>{customElements.define(o,eo(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},no=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),oo=o=>(o=no(o),o.replace(/_/g,"-"));var it=class extends N{constructor(){super(...arguments);i(this,"type",F.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===ee.localFrame){let c=R(),f="myop-comp-".concat(c),g=document.createElement("iframe");g.id=f,g.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=""),g=this.appendChild(s,g,r);let y=g.contentDocument||g.contentWindow.document;y.open();let l=null;{let v=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(v)try{l=JSON.parse(v.getAttribute("content")||"{}")}catch(ye){}}let m=a.HTML;if(r!=null&&r._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),v=T.getElementById("myop_preview");v==null||v.removeAttribute("type");let ye=T.implementation.createHTMLDocument();ye.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let P=ye.body.firstChild;P&&T.head&&T.head.insertBefore(T.importNode(P,!0),T.head.firstChild),m="<!DOCTYPE html>"+T.documentElement.outerHTML}else if((r==null?void 0:r.data)!==void 0){let T=new DOMParser().parseFromString(a.HTML,"text/html"),v=T.getElementById("myop_preview");v&&(v.remove(),m="<!DOCTYPE html>"+T.documentElement.outerHTML)}y.writeln(m);let D='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),q="<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(y.writeln("".concat(D).concat(q)),(r==null?void 0:r.data)!==void 0){let B="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",T=JSON.stringify(r.data).replace(/<\/script/gi,"\\u003c/script"),v='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(T,";\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>");y.writeln(B+v)}y.close();let L=new ue(e,t,s,g,r);return L.sizeMeta=l,L.initiated().then(()=>{if((r==null?void 0:r.autoSize)===!1)return;let B=!1;L.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!B&&!(r!=null&&r.hidden)&&(B=!0,L.show())}})}),L}if(a.shadowRootMode===ee.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Sn().then(f=>{f.connectedCallback(d,d)})}else{let c=oo(e.name+t.id);wn.includes(c)||(to(c,a.HTML,a.shadowRootMode),wn.push(c)),d=document.createElement(c)}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 ge(e,t,s,d,r)})}isMyopWebComponent(e){return e.trimStart().startsWith(Xn)}extractWebComponentScript(e){let r=new DOMParser().parseFromString(e,"text/html").getElementById(Zn);return(r==null?void 0:r.textContent)||null}executeWebComponentScript(e,t){if(bn.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),bn.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),c=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__");c&&c!==f&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(c," to ").concat(f));let g="myop-comp-".concat(R()),y=document.createElement(f);y.id=g,a!=null&&a.hidden&&(y.style.opacity="0",y.style.position="absolute",y.style.height="0",y.style.width="0",y.style.pointerEvents="none",y.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,y,a);let l=new ne(e,t,s,y,f,a);return(a==null?void 0:a.data)!==void 0&&l.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(f,"> into container")),l}};var so=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:me.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:me.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),rt="__MYOP_CLOUD_REPOSITORY_MAIN__",io=()=>{if(typeof window<"u")return window[rt];if(typeof globalThis<"u")return globalThis[rt]},ro=o=>{typeof window<"u"&&(window[rt]=o),typeof globalThis<"u"&&(globalThis[rt]=o)},U=class U{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);i(this,"_staticMode",!1);i(this,"_queryParams",{})}static get Main(){let n=io();return n||(U._main||(U._main=new U,ro(U._main)),U._main)}enableStaticMode(){this._staticMode=!0}setQueryParams(n){this._queryParams=n}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async 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 c=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!c}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(c,f)=>{try{let g;if(this._staticMode){let q=p?"preview":a;g="".concat(this._baseUrl,"/components/").concat(n,"/").concat(q,".json");let L=new URLSearchParams(this._queryParams).toString();L&&(g+="?".concat(L))}else g="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a),p&&(g+="&preview=true");let y=await fetch(g);if(!y.ok){f(new Error('Failed to load component "'.concat(n,'" (').concat(y.status).concat(this._staticMode?" from ".concat(g):"",")")));return}let m=(await y.json()).item;if(!m){f(new Error('Component "'.concat(n,'" not found')));return}if(!m.consume_variant||!m.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let D=so(m);this.variants[d].resolved=D,c(D)}catch(g){delete this.variants[d],f(g)}})),await this.variants[d]}getResolvedConfig(n,e,t){var c;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 f=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!f}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return((c=this.variants[d])==null?void 0:c.resolved)||null}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){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(r.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};i(U,"_main",null);var oe=U;var ac=oe.Main;var En=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=yt(t);switch(s){case"component":{let[a,p]=r,d=await oe.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:te.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=yt(t),c=(await oe.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(c&&c.instance.skinSelector.type===te.Segmented&&c.instance.resolvedExperiences){let f=c.instance.resolvedExperiences.find(g=>g.id===p);if((f==null?void 0:f.type)===Pe.Segment){let g=f,l=c.instance.skinSelector.segments.find(m=>m.segmentId===g.segment.id);if(l)return c.instance.skinSelector=l==null?void 0:l.skinSelector,c}}}break}}}finally{return null}};var Tn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",A=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",Ge);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!==b.up&&n.data.messageType!==u.EnvelopedMessage)return;let e=n.data;if(e.messageType===u.InitRequest){this.components2init.forEach(s=>{s.send(new ae(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===b.down){s.message.messageType===k.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 Ue,new Ve,new it];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 te.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case te.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(l=>l.type===Pe.Segment?l.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let g=c.segment,y=(t||{})[g.function];return y?await y():(console.warn("segmentId:".concat(d.segmentId,", ").concat(g.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,g,y,l;if(!e){debugger;throw new Error("no container was found for this component")}let s=await En(n);s&&(n=s);let r=h(h({},(f=this.loaderHooks)!=null?f:{}),(g=t==null?void 0:t.hooks)!=null?g:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let m=await this.runSkinSelector(n,r);if(!m)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(y=t==null?void 0:t.hooks)!=null&&y.afterSkinSelected&&(m=await t.hooks.afterSkinSelected(h({},m))),n.instance.skinSelector={type:te.Dedicated,skin:m},t&&(t=h({},t),delete t.hooks),await kt(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");(l=t==null?void 0:t.hooks)!=null&&l.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(m=>m.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(m=>m!==c),this.components2init=this.components2init.filter(m=>m!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=Mn(c,n.type.props,p));try{await Dt(c,n,this.components)}catch(m){throw m}return t!=null&&t.skipInit||await c.initiated(),c});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(A,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Tn});if(!window.myop.hostSDK){let o=new A;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Tn}),window.myop.hostSDK=o}var ao=window.myop.hostSDK;le("hostSDK",ao);var at=class extends M{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"executor",e=>{(async()=>{let s=document.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await A.Instance().loadComponent(e.nestedComponentConfig,s.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new $(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new $(e.handlerUniqueId,[],!0));debugger}})().then()})}};var vn=(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 pt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetMutationObserverMessage);i(this,"executor",e=>{e.source&&vn(document.body,()=>{this.messageToHost(new we)})})}};var Rn=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(E.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Rn(r),required:r.required,validity:H(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},dt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.GetElementValueMessage);i(this,"executor",e=>{I(e.ref,document).forEach(s=>{this.messageToHost(new J(Rn(s)),e)})})}};var ct=class extends M{constructor(){super(...arguments);i(this,"messageType",u.GetAttributeMessage);i(this,"executor",e=>{let t=fn(e.ref,document);t&&this.messageToHost(new be(t.getAttribute(e.name)),e)})}};var mt=class extends M{constructor(){super(...arguments);i(this,"messageType",u.SetResizeObserverMessage);i(this,"executor",e=>{let t=new ResizeObserver(s=>{this.messageToHost(new ve)});return t.observe(document.body),()=>{t.disconnect()}})}};var lt=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 Lt=class extends pe{constructor(){super();i(this,"version",Ge);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=b.up,(r=window.parent)==null||r.postMessage(h({},e),"*")});i(this,"supportedHandlers",[new ze(this.messageToHost),new lt(this.messageToHost),new Ae(this.messageToHost),new Oe(this.messageToHost),new $e(this.messageToHost),new We(this.messageToHost),new Ne(this.messageToHost),new dt(this.messageToHost),new pt(this.messageToHost),new mt(this.messageToHost),new ct(this.messageToHost),new at(this.messageToHost)]);i(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new X)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};le("IframeSDK",Lt);export{Lt as IframeSDK};
@@ -0,0 +1 @@
1
+ var O=Object.defineProperty,z=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var k=(t,e,n)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,T=(t,e)=>{for(var n in e||(e={}))j.call(e,n)&&k(t,n,e[n]);if(F)for(var n of F(e))G.call(e,n)&&k(t,n,e[n]);return t},_=(t,e)=>z(t,N(e));var q=(t,e)=>{for(var n in e)O(t,n,{get:e[n],enumerable:!0})};var s=(t,e,n)=>k(t,typeof e!="symbol"?e+"":e,n);var S="__federation__",$="onLoad";var A=(t,e)=>{window[S]&&window[S][t]&&window[S][t][$]&&window[S][t][$]({[t]:e})};var D={};q(D,{CloudRepository:()=>x,ComponentConfig:()=>L,SkinConfig:()=>B,addClass:()=>se,applyStylesheet:()=>X,applyStylesheetLink:()=>Z,changeSkinUrlByTokenizer:()=>te,createIframeSkinByTokenizer:()=>U,enableLocalDev:()=>de,enableSelfHosted:()=>ye,exec:()=>pe,getCloudRepository:()=>ce,getPreloadedParams:()=>ge,getResolvedConfig:()=>Me,isPreloaded:()=>le,preloadComponents:()=>xe,removeClass:()=>ne,setCloudRepository:()=>fe,setCloudRepositoryUrl:()=>me,setEnvironment:()=>ue,v2_CloudRepository:()=>ae});var g=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var d=class{constructor(){s(this,"id",g());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...e){return new this(...e)}isTypeof(e){return e.messageType===this.messageType}};var f=class extends d{constructor(n){super();this.handler=n;s(this,"handlerUniqueId",g())}};var W="ExecuteScriptReplyMessage",Y=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,J=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Q=t=>{let e=t.match(Y);if(e)return e[1]||e[3];{let n=t.match(J);if(n)return n[1].trim()}},u=class extends f{constructor(n,o=()=>{},r){super(o);this.scriptInputs=r;s(this,"replyMessageKey",W);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=n.toString(),this.content=n.toString(),this.content=Q(this.content)}};s(u,"replierKey","send"),s(u,"completeStreamKey","completeStream");var b=class extends u{constructor(n,o,r=()=>{}){super(({rootRef:a,elementId:i,_script:c,__scriptInputs:p})=>{let l=(a.shadowRoot||a.container).querySelectorAll("[myop-id='".concat(i,"']"));return l.length?(p.ref=l[0],new Function("return (".concat(c,")(...arguments)"))(p)):null},r);this.scriptInputs=o;this.scriptInputs=_(T({},o),{_script:n.toString()})}};var X=(t,e,n)=>{let o="myop-css-".concat(g());return t.send(new u(({rootRef:r,_stylesheet:a,_tagId:i,_css:c})=>{let p=document.createElement("style");p.type="text/css";let l=c;for(let M in a){l+="".concat(M," { ");let y=a[M];for(let C in y)l+="".concat(C,": ").concat(y[C],"; ");l+="} "}p.appendChild(document.createTextNode(l)),p.id=i,(r.shadowRoot||r.container).appendChild(p)},()=>{},{_stylesheet:e,_css:n||"",_tagId:o})),()=>{t.send(new u(({rootRef:r,_tagId:a})=>{let i=(r.shadowRoot||document).getElementById(a);i&&i.remove()},()=>{},{_tagId:o}))}},Z=(t,e)=>{let n="myop-css-".concat(g());return t.send(new u(({rootRef:o,_tagId:r,_link:a})=>{let i=document.createElement("link");i.id=r,i.rel="stylesheet",i.href=a,document.head.appendChild(i),(o.shadowRoot||o.container).appendChild(i)},()=>{},{_link:e,_tagId:n})),()=>{t.send(new u(({rootRef:o,_tagId:r})=>{let a=(o.shadowRoot||document).getElementById(r);a&&a.remove()},()=>{},{_tagId:n}))}};var ee=(t,e)=>{let n=new RegExp(Object.keys(e).join("|"),"g");return t.replace(n,o=>(e[o]||o).toString())},U=(t,e)=>{let n=t.loader;if(n.type!=="IframeLoader")throw new Error('iframeSkinUrlTokenizer received skin with loader type "'.concat(n.type,'", currently only "IframeLoader" is supported'));return t.loader=T({},t.loader),t.loader.url=ee(t.loader.url,e),t},te=t=>async e=>U(e,t);var se=(t,e,n)=>{t.send(new b(({ref:o,_className:r})=>{o==null||o.classList.add(r)},{elementId:n,_className:e}))},ne=(t,e,n)=>{t.send(new b(({ref:o,_className:r})=>{o==null||o.classList.remove(r)},{elementId:n,_className:e}))};var R=class R{constructor(){s(this,"_runTimeInstanceId","runtime-instance-id-"+g());s(this,"_runTimeId","runtime-id-"+g());s(this,"_runTimeName","runtime-name-"+g());s(this,"id",this._runTimeId);s(this,"name",this._runTimeName);s(this,"description","");s(this,"loader",null);s(this,"withLoader",e=>(this.loader=e,this));s(this,"withHTMLLoader",e=>(e.type="HTMLLoader",this.loader=e,this));s(this,"build",()=>this)}};s(R,"create",()=>new R);var B=R,w=class w{constructor(){s(this,"_runTimeInstanceId","runtime-instance-id-"+g());s(this,"_runTimeId","runtime-id-"+g());s(this,"_runTimeName","runtime-name-"+g());s(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null});s(this,"name",this._runTimeName);s(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0});s(this,"withInstance",e=>(this.instance=e,this));s(this,"withType",e=>(this.type=e,this));s(this,"withName",e=>(this.name=e,this));s(this,"withDefaultSkin",e=>(this.type.skins.push(e),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:e.id}},this));s(this,"withRef",e=>(this.type.refs.push(e),this));s(this,"withBasicRef",e=>{let n={id:"",name:e,description:"",selectorType:"id-attribute",selector:e,behavior:{type:"code"}};return this.type.refs.push(n),this});s(this,"build",()=>JSON.parse(JSON.stringify(this)))}};s(w,"create",()=>new w);var L=w;var P={message:"message",code:"code"};var oe=t=>({instance:{id:"auto",componentId:t.componentId,componentName:t.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:t.id,name:t.name,description:t.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:P.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:P.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:t.consume_variant[0].loader}],defaultSkin:0},name:t.name}),E="__MYOP_CLOUD_REPOSITORY_MAIN__",re=()=>{if(typeof window<"u")return window[E];if(typeof globalThis<"u")return globalThis[E]},ie=t=>{typeof window<"u"&&(window[E]=t),typeof globalThis<"u"&&(globalThis[E]=t)},I=class I{constructor(e="https://cloud.myop.dev"){this._baseUrl=e;s(this,"variants",{});s(this,"preloadedComponents",{});s(this,"userFlows",{});s(this,"_defaultEnv","production");s(this,"_envExplicitlySet",!1);s(this,"_staticMode",!1);s(this,"_queryParams",{})}static get Main(){let e=re();return e||(I._main||(I._main=new I,ie(I._main)),I._main)}enableStaticMode(){this._staticMode=!0}setQueryParams(e){this._queryParams=e}setEnvironment(e){this._defaultEnv=e,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(e,n,o){return n!==void 0||o!==void 0?"".concat(e,":").concat(n||this._defaultEnv,":").concat(o?"preview":"live")in this.variants:e in this.preloadedComponents}getPreloadedParams(e){return this.preloadedComponents[e]}async fetchComponentV2(e,n,o){let r=this.preloadedComponents[e],a=n!==void 0||o!==void 0,i,c;if(!a&&r)i=r.env,c=r.preview;else{i=n||this._defaultEnv;let l=n||this._envExplicitlySet;c=o===!0?!0:o===!1?!1:!l}let p="".concat(e,":").concat(i,":").concat(c?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:e.slice(0,8)+"...",env:i,usePreview:c,cacheKey:p,cached:p in this.variants}),this.variants[p]||(this.preloadedComponents[e]||(this.preloadedComponents[e]={env:i,preview:c}),this.variants[p]=new Promise(async(l,M)=>{try{let y;if(this._staticMode){let V=c?"preview":i;y="".concat(this._baseUrl,"/components/").concat(e,"/").concat(V,".json");let H=new URLSearchParams(this._queryParams).toString();H&&(y+="?".concat(H))}else y="".concat(this._baseUrl,"/consume?id=").concat(e,"&env=").concat(i),c&&(y+="&preview=true");let C=await fetch(y);if(!C.ok){M(new Error('Failed to load component "'.concat(e,'" (').concat(C.status).concat(this._staticMode?" from ".concat(y):"",")")));return}let v=(await C.json()).item;if(!v){M(new Error('Component "'.concat(e,'" not found')));return}if(!v.consume_variant||!v.consume_variant.length){M(new Error('Component "'.concat(e,'" has no implementation for environment "').concat(i,'"')));return}let K=oe(v);this.variants[p].resolved=K,l(K)}catch(y){delete this.variants[p],M(y)}})),await this.variants[p]}getResolvedConfig(e,n,o){var l;let r=this.preloadedComponents[e],a=n!==void 0||o!==void 0,i,c;if(!a&&r)i=r.env,c=r.preview;else{i=n||this._defaultEnv;let M=n||this._envExplicitlySet;c=o===!0?!0:o===!1?!1:!M}let p="".concat(e,":").concat(i,":").concat(c?"preview":"live");return((l=this.variants[p])==null?void 0:l.resolved)||null}async fetchComponentV1(e,n){return n?(await this.fetchFlow(n)).components.find(r=>r.type.id===e):(await this.fetchAutoFlow(e)).components[0]}async fetchAutoFlow(e){return this.userFlows[e]||(this.userFlows[e]=new Promise(async(n,o)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(e,"&auto=true"))).json();n(a.item)}catch(r){delete this.userFlows[e],o(r)}})),await this.userFlows[e]}async fetchFlow(e){return this.userFlows[e]||(this.userFlows[e]=new Promise(async(n,o)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(e,"&resolve=components"))).json();n(a.item)}catch(r){delete this.userFlows[e],o(r)}})),await this.userFlows[e]}async fetchComponent(e,n){return this.fetchComponentV1(e,n)}};s(I,"_main",null);var x=I,ae=x;var pe=async t=>await t();var m=x.Main,ce=()=>m,le=(t,e,n)=>m.isPreloaded(t,e,n),ge=t=>m.getPreloadedParams(t),de=()=>{m=new x("http://localhost:9292")},me=t=>{m=new x(t)},ye=(t,e)=>{m=new x(t),m.enableStaticMode(),e&&m.setQueryParams(e)},fe=t=>{m=t},ue=t=>{m.setEnvironment(t)},Me=(t,e,n)=>m.getResolvedConfig(t,e,n),xe=async(t,e,n)=>Promise.allSettled(t.map(o=>m.fetchComponentV2(o,e,n)));A("MyopHelpers",D);export{x as CloudRepository,L as ComponentConfig,B as SkinConfig,se as addClass,X as applyStylesheet,Z as applyStylesheetLink,te as changeSkinUrlByTokenizer,U as createIframeSkinByTokenizer,de as enableLocalDev,ye as enableSelfHosted,pe as exec,ce as getCloudRepository,ge as getPreloadedParams,Me as getResolvedConfig,le as isPreloaded,xe as preloadComponents,ne as removeClass,fe as setCloudRepository,me as setCloudRepositoryUrl,ue as setEnvironment,ae as v2_CloudRepository};
@@ -440,6 +440,7 @@ var _CloudRepository = class _CloudRepository {
440
440
  __publicField(this, "_defaultEnv", "production");
441
441
  __publicField(this, "_envExplicitlySet", false);
442
442
  __publicField(this, "_staticMode", false);
443
+ __publicField(this, "_queryParams", {});
443
444
  }
444
445
  static get Main() {
445
446
  const globalMain = getGlobalMain();
@@ -460,6 +461,13 @@ var _CloudRepository = class _CloudRepository {
460
461
  enableStaticMode() {
461
462
  this._staticMode = true;
462
463
  }
464
+ /**
465
+ * Set query parameters to append to all fetch URLs (e.g. for CDN cache busting).
466
+ * Example: `setQueryParams({ lastupdate: '11112026' })`
467
+ */
468
+ setQueryParams(params) {
469
+ this._queryParams = params;
470
+ }
463
471
  /**
464
472
  * Set the default environment for this CloudRepository instance
465
473
  */
@@ -528,6 +536,8 @@ var _CloudRepository = class _CloudRepository {
528
536
  if (this._staticMode) {
529
537
  const file = usePreview ? "preview" : env;
530
538
  url = "".concat(this._baseUrl, "/components/").concat(componentId, "/").concat(file, ".json");
539
+ const qs = new URLSearchParams(this._queryParams).toString();
540
+ if (qs) url += "?".concat(qs);
531
541
  } else {
532
542
  url = "".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(env);
533
543
  if (usePreview) {
@@ -675,9 +685,12 @@ var enableLocalDev = () => {
675
685
  var setCloudRepositoryUrl = (url) => {
676
686
  _cloudRepository = new CloudRepository(url);
677
687
  };
678
- var enableSelfHosted = (cdnUrl) => {
688
+ var enableSelfHosted = (cdnUrl, queryParams) => {
679
689
  _cloudRepository = new CloudRepository(cdnUrl);
680
690
  _cloudRepository.enableStaticMode();
691
+ if (queryParams) {
692
+ _cloudRepository.setQueryParams(queryParams);
693
+ }
681
694
  };
682
695
  var setCloudRepository = (repository) => {
683
696
  _cloudRepository = repository;