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