@myop/react 0.0.38 → 0.0.39
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/index.js +986 -973
- package/dist/index.umd.cjs +23 -23
- package/package.json +3 -3
package/dist/index.umd.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(b,C){typeof exports=="object"&&typeof module<"u"?C(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],C):(b=typeof globalThis<"u"?globalThis:b||self,C(b["@myop/react"]={},b.React,b.React))})(this,(function(b,C,w){"use strict";const jt=`"use strict";var MyopSDK=(()=>{var qe=Object.defineProperty,Os=Object.defineProperties,As=Object.getOwnPropertyDescriptor,Ks=Object.getOwnPropertyDescriptors,zs=Object.getOwnPropertyNames,kn=Object.getOwnPropertySymbols;var Hn=Object.prototype.hasOwnProperty,$s=Object.prototype.propertyIsEnumerable;var Pt=(o,n,e)=>n in o?qe(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,M=(o,n)=>{for(var e in n||(n={}))Hn.call(n,e)&&Pt(o,e,n[e]);if(kn)for(var e of kn(n))$s.call(n,e)&&Pt(o,e,n[e]);return o},U=(o,n)=>Os(o,Ks(n));var l=(o,n)=>()=>(o&&(n=o(o=0)),n);var ee=(o,n)=>{for(var e in n)qe(o,e,{get:n[e],enumerable:!0})},Fs=(o,n,e,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of zs(n))!Hn.call(o,s)&&s!==e&&qe(o,s,{get:()=>n[s],enumerable:!(t=As(n,s))||t.enumerable});return o};var Ws=o=>Fs(qe({},"__esModule",{value:!0}),o);var i=(o,n,e)=>Pt(o,typeof n!="symbol"?n+"":n,e);var Ve,je,Ot,F,te=l(()=>{"use strict";Ve="__federation__",je="onLoad",Ot="moduleInstance",F=(o,n)=>{window[Ve]&&window[Ve][o]&&window[Ve][o][je]&&window[Ve][o][je]({[o]:n})}});var ge,Ge=l(()=>{ge="0.3.21"});var g,C=l(()=>{"use strict";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 E,Ns,Us,At,Kt=l(()=>{"use strict";E=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16)),Ns=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("-")},Us=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))},At=o=>{let n=Us(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(Ns(n.slice(t,t+16)));return e}});var Bn,ne=l(()=>{"use strict";Kt();Bn=o=>new Promise(n=>setTimeout(n,o))});var _,I,zt,R,k,G,H=l(()=>{"use strict";ne();_=class{};i(_,"down","down"),i(_,"up","up");I=class{constructor(){i(this,"id",E());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}},zt=class extends I{constructor(e){super();this.ref=e}},R=class extends I{constructor(e){super();this.replayToHandler=e}},k=class extends I{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",E())}},G=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=U(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 Ln,$t,oe,Pn=l(()=>{"use strict";H();Ln="ClickReplayMessage",$t=class extends k{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",Ln);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},oe=class extends R{constructor(){super(...arguments);i(this,"messageType",Ln)}}});var Ft,On=l(()=>{"use strict";H();Ft=class extends I{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}}});var An,qs,Vs,Kn,D,se,Wt=l(()=>{"use strict";H();An="ExecuteScriptReplyMessage",qs=/(?:function\\s*\\w*\\s*\\([^)]*\\)\\s*\\{([\\s\\S]*?)\\}|(\\([^)]*\\)\\s*=>\\s*\\{([\\s\\S]*?)\\}))\\s*$/,Vs=/\\(\\s*[^)]+\\s*\\)\\s*=>\\s*(.+)/,Kn=o=>{let n=o.match(qs);if(n)return n[1]||n[3];{let e=o.match(Vs);if(e)return e[1].trim()}},D=class extends k{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",An);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Kn(this.content)}};i(D,"replierKey","send"),i(D,"completeStreamKey","completeStream");se=class extends R{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",An)}}});var q,zn=l(()=>{"use strict";Wt();q=class extends D{constructor(e,t,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:d})=>{let m=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(d.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=U(M({},t),{_script:e.toString()})}}});var $n,Nt,ie,Fn=l(()=>{"use strict";H();$n="EventListenerCallbackMessage",Nt=class extends k{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",$n);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},ie=class extends R{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",$n);this.content={e:t}}}});var Ut,Wn=l(()=>{"use strict";H();Ut=class extends I{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}}});var Nn,qt,re,Vt=l(()=>{"use strict";H();Nn="ElementValueReplayMessage",qt=class extends k{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",Nn);i(this,"messageType","GetElementValueMessage")}},re=class extends R{constructor(e){super();this.content=e;i(this,"messageType",Nn)}}});var jt,Un=l(()=>{"use strict";H();jt=class extends I{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}}});var ye,He,ae,qn=l(()=>{"use strict";H();ye=class extends I{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},He=class extends ye{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},ae=class extends I{constructor(){super(...arguments);i(this,"messageType","InitRequest")}}});var Vn,De,V,Ye=l(()=>{"use strict";H();Vn="RefComponentCreatedMessage",De=class extends k{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",Vn);i(this,"messageType","CreateRefComponentMessage")}},V=class extends R{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",Vn)}}});var Be,Gt=l(()=>{"use strict";H();Be=class extends I{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 jn,Yt,pe,Gn=l(()=>{"use strict";H();jn="DetectedMyopRefsMessage",Yt=class extends k{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",jn)}},pe=class extends R{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",jn);this.content=t}isTypeof(e){return e.messageType===this.messageType}}});var Yn,Qt,Le,Qn=l(()=>{"use strict";H();Yn="GetAttributeReplayMessage",Qt=class extends k{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",Yn);i(this,"messageType","GetAttributeMessage")}},Le=class extends R{constructor(e){super();this.content=e;i(this,"messageType",Yn)}}});var A,Jn=l(()=>{"use strict";H();A=class extends I{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}}});var Jt,Pe,Xn=l(()=>{"use strict";H();Jt=class extends I{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},Pe=class extends I{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}}});var Zn,Oe,Ae,eo=l(()=>{"use strict";H();Zn="CleanupReplayMessage",Oe=class extends k{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",Zn);i(this,"messageType","CleanupMessage")}},Ae=class extends R{constructor(e){super();this.customCleanup=e;i(this,"messageType",Zn)}}});var Ke,to=l(()=>{"use strict";H();Ke=class extends I{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}}});var Xt,ze,no=l(()=>{"use strict";H();Xt=class extends I{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},ze=class extends I{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}}});var he={};ee(he,{AddEventListenerMessage:()=>Nt,BaseMyopMessage:()=>I,BindClickMessage:()=>$t,ChangeTextMessage:()=>Ft,CleanupMessage:()=>Oe,CleanupReplayMessage:()=>Ae,ClickReplayMessage:()=>oe,CreateRefComponentMessage:()=>De,CustomRefMessage:()=>q,DetectMyopRefsMessage:()=>Yt,DetectedMyopRefsMessage:()=>pe,DisposeMessage:()=>Ke,ElementValueReplayMessage:()=>re,EnvelopedMessage:()=>Be,EventListenerCallbackMessage:()=>ie,ExecuteComponentMethod:()=>A,ExecuteScriptMessage:()=>D,ExecuteScriptReplyMessage:()=>se,GetAttributeMessage:()=>Qt,GetAttributeReplayMessage:()=>Le,GetElementValueMessage:()=>qt,InitMessage:()=>ye,InitRequest:()=>ae,InitResponse:()=>He,MessageDirection:()=>_,MutationObserverMessage:()=>Pe,MyopBindMessage:()=>k,MyopBindReplayMessage:()=>R,MyopElementMessage:()=>zt,Ref:()=>G,RefComponentCreatedMessage:()=>V,ResizeObserverMessage:()=>ze,SetAttributeMessage:()=>Ut,SetInnerHtml:()=>jt,SetMutationObserverMessage:()=>Jt,SetResizeObserverMessage:()=>Xt,stripFunction:()=>Kn});var b=l(()=>{"use strict";H();Pn();On();Wt();zn();Fn();Wn();Vt();Un();qn();Ye();Gt();Gn();Vt();Qn();Jn();Xn();eo();to();no()});var W,$e=l(()=>{"use strict";C();b();Fe();W=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)||$.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=_.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=_.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Oe(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new Ke);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}}});var Me,oo=l(()=>{"use strict";Me=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 so,x,Qe,io=l(()=>{"use strict";so=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},x=class{constructor(n){this.messageToHost=n}},Qe=class extends x{constructor(e,t){super(e);this.messageToHost=e;this.context=t}}});var Zt,Ce,ro=l(()=>{"use strict";C();w();b();Zt=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!==_.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 Zt(s),this.messageToHost(new He(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 Ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],so(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 j,de,be,Ie,ce,Je,xe,w=l(()=>{"use strict";oo();io();ro();j={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"},de={open:"open",closed:"closed",none:"none",localFrame:"localFrame"},be={message:"message",code:"code"},Ie=class{};i(Ie,"code","code"),i(Ie,"component","component");ce={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Je={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 en,js,tn,O,me=l(()=>{"use strict";en=o=>o!==Object(o),js=o=>typeof o=="function",tn=o=>{if(en(o))return!0;if(js(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!tn(e))return!1}else{if(en(e))continue;return!1}}return!0},O=(o,n={},e=!0,t=new WeakMap)=>{if(en(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]=O(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]=O(o[r],!0,e,t)):typeof a=="object"&&(s[r]=O(o[r],a,e,t)))}return s}return{}}});var ao,po=l(()=>{"use strict";ao={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 We,co=l(()=>{"use strict";$e();b();Gt();We=class extends W{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 Be(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new A("dispose")),super.dispose()})}hide(){this.send(new A("hide"))}show(){this.send(new A("show"))}inspect(){return this.send(new A("inspect"))}setHeightBasedOnDocumentElement(){this.send(new A("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new A("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}}});var le,nn=l(()=>{"use strict";$e();Ne();le=class extends W{constructor(e,t,s,r,a,p){super(e,s,p);this.container=s;this.customElement=r;this.tagName=a;i(this,"ctaCleanup");i(this,"_ctaHandler");i(this,"_ctaQueue",[]);i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});i(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=r,this.setInitiated()}inspect(){return this.cleanupInspect=we(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this.ctaCleanup&&this.ctaCleanup(),this._ctaHandler=e,this._ctaQueue.length>0){let s=[...this._ctaQueue];this._ctaQueue=[],s.forEach(r=>{this.markedForDisposed||e(r.action,r.payload)})}let t=s=>{var a;let r=s;(a=r.detail)!=null&&a.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(r.detail.action,r.detail.payload):this._ctaHandler||this._ctaQueue.push({action:r.detail.action,payload:r.detail.payload}))};this.customElement.addEventListener("myop-cta",t),this.ctaCleanup=()=>{this.customElement.removeEventListener("myop-cta",t)}}}});var Gs,we,mo,lo,fo,Ys,on,sn,Ne=l(()=>{"use strict";b();b();w();me();po();co();nn();Gs=(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},we=(o,n,e,t,s,r)=>{let a=Gs("".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)}},mo=(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),lo=(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."))},fo=(o,n,e)=>{let t=n.reduce((r,a)=>U(M({},r),{[a.name]:M({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(mo(p,a,o))return!1;if(p.behavior.type===be.code){if(o instanceof le)return(p.behavior.remap||a)==="myop_init_interface"?u=>{if(u===void 0)return o.getData();o.initWithData(u)}:void 0;if(e.loader.type===j.HTMLLoader&&e.loader.shadowRootMode===de.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return lo(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let m=[];p.behavior.ref&&m.push(G.create(p.behavior.ref)),m.push(f=>{d(f)}),p.behavior.params&&m.push(...p.behavior.params);let u=he[p.behavior.message];o.send(new u(...m))}):null},set:(r,a,p)=>{let d=t[a];if(mo(d,a,o))return!1;if(d.behavior.type===be.code){if(o instanceof le){let u=d.behavior.remap||a;if(u==="myop_cta_handler")return o.setCtaHandler(p),!0;if(u==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===j.HTMLLoader&&e.loader.shadowRootMode===de.localFrame){let u=d.behavior,f=o.element.contentWindow,c=u.remap||a;if(f[c]=p,c==="myop_cta_handler"&&f.__myop_cta_queue){let y=f.__myop_cta_queue;f.__myop_cta_queue=null,y.forEach(h=>{o.markedForDisposed||p(h.action,h.payload)})}return!0}return lo(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let m=[];d.behavior.ref&&m.push(G.create(d.behavior.ref)),m.push(p),d.behavior.params&&m.push(...d.behavior.params);let u=he[d.behavior.message];return o.send(new u(...m)),!0}else throw new Error("Error: Unsupported Behavior\\n\\nThe 'behavior' field provided is not supported.\\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\\n\\n")+"Prop Name: ".concat(a,"\\n")+"Behavior Field: ".concat(d.behavior.type,"\\n\\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Ys=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{tn(p)||ao.notSerializableRefCall(t,p)}),n.send(new q(({ref:p,propName:d,functionArgs:m,makeSerializable:u})=>{if(p){let f=p[d];return u(typeof f=="function"?p[d](...m):f,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new q(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),on=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 We(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new De(o.refConfig,n,U(M({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(d),m.failed){a("CreateRefComponentMessage failed");return}let u=e.find(f=>f.id==p.id);if(u!==p){s.refs[o.refConfig.name]=u,r(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(f=>{let c=n.instance.resolvedNestedComponents.find(h=>h.type.id===f.componentDefinitionId).type,y=new We(c,p);y.setInitiated(),p.refs[f.refName]=y,e.push(y)});try{await sn(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(f){a(f)}}))})},sn=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==Ie.component){if(t){a();return}let m=r.behavior.componentId;m||(m=r.behavior.instance.componentId);let u=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(c=>c.type.id===m);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let f=G.create("",r,o);try{let c=await on(f,u,e);o.refs[r.name]=c,a()}catch(c){p(c)}}else try{let m=G.create("",r,o);o.refs[r.name]=Ys(m,o),a()}catch(m){}}));try{await Promise.all(s)}catch(r){throw r}}});var Se,rn=l(()=>{"use strict";$e();b();Ne();C();Se=class extends W{constructor(e,t,s,r,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=r;i(this,"_autoSizeCleanup");i(this,"_autoSizeOptions");i(this,"_autoSizeUpdate");i(this,"sizeMeta");i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new D(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});i(this,"observeSizeBasedOnDocumentElement",()=>this.send(new D(({send:t})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));i(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let r=(f,c,y)=>c!==void 0&&f<c?c:y!==void 0&&f>y?y:f,a=f=>{if(f===void 0)return;if(typeof f=="number")return f;let c=parseFloat(f);return isNaN(c)?void 0:c},p=()=>{var In,xn,bn,wn,Sn,En,Tn,vn;let f=t.contentDocument;if(!f)return;let c=this._autoSizeOptions,y=a(c==null?void 0:c.minWidth),h=a(c==null?void 0:c.maxWidth),fe=a(c==null?void 0:c.minHeight),ve=a(c==null?void 0:c.maxHeight),Z=(In=c==null?void 0:c.loaderMinHeight)!=null?In:50,ue=((xn=this.sizeMeta)==null?void 0:xn.width)==="100%"?"100%":void 0,L=((bn=this.sizeMeta)==null?void 0:bn.height)==="100%"?"100%":void 0,v=(Sn=(wn=c==null?void 0:c.explicitWidth)!=null?wn:ue)!=null?Sn:"100%",z=(En=c==null?void 0:c.explicitHeight)!=null?En:L,_e=v!==void 0,gn=z!==void 0,Lt=this.container.getBoundingClientRect(),Ds=Lt.width===0,Bs=Lt.height===0||Lt.height===Z,Re=(c!=null&&c.forceAutoSize||Ds)&&!_e,ke=(c!=null&&c.forceAutoSize||Bs)&&!gn;if(!Re&&!ke){t.style.width=typeof v=="number"?"".concat(v,"px"):"100%",t.style.height=typeof z=="number"?"".concat(z,"px"):"100%";let _n=typeof v=="number"?v:void 0,Rn=typeof z=="number"?z:void 0;(_n!==void 0||Rn!==void 0)&&((Tn=c==null?void 0:c.onSizeChange)==null||Tn.call(c,{width:_n,height:Rn,autoSizingWidth:!1,autoSizingHeight:!1}));return}ke&&(t.style.height="0px"),Re&&(t.style.width="0px");let yn=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth)),hn=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight)),Mn=r(yn,y,h),Cn=r(hn,fe,ve);Re?t.style.width="".concat(Mn,"px"):t.style.width=typeof v=="number"?"".concat(v,"px"):"100%",ke?t.style.height="".concat(Cn,"px"):t.style.height=typeof z=="number"?"".concat(z,"px"):"100%";let Ls=Re&&h!==void 0&&yn>h,Ps=ke&&ve!==void 0&&hn>ve;f.documentElement.style.overflowX=Ls?"auto":"",f.documentElement.style.overflowY=Ps?"auto":"",(vn=c==null?void 0:c.onSizeChange)==null||vn.call(c,{width:Mn,height:Cn,autoSizingWidth:Re,autoSizingHeight:ke})};p(),this._autoSizeUpdate=p;let d=new ResizeObserver(p);d.observe(s.body),d.observe(s.documentElement);let m=new MutationObserver(p);m.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let u=()=>{d.disconnect(),m.disconnect(),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=u,u});i(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new D(()=>{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 D(()=>{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=_.down;let s=super.send(t);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(t,"*"),s});i(this,"dispose",()=>{this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=we(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 Y,Xe=l(()=>{"use strict";Y=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 Qs,Ze,uo=l(()=>{"use strict";rn();Xe();ne();w();Qs=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Ze=class extends Y{constructor(){super(...arguments);i(this,"type",j.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=E(),m="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=m;let u="\\n padding: 0;\\n margin: 0;\\n position: absolute;\\n inset: 0;\\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\\n width: 100%;\\n overflow: hidden;\\n border: none;\\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\\n ");a.style.cssText=u,r!=null&&r.elementAttributes&&Object.entries(r.elementAttributes).forEach(([c,y])=>{y===""||y===null||y===void 0?a.setAttribute(c,""):a.setAttribute(c,String(y))});let f=t.loader.url;r!=null&&r._hasParent&&(f=Qs(f,"_myop-comp",d)),a.src=f,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,r)}return new Se(e,t,s,a,r)})}}});var et,an=l(()=>{"use strict";et={webcomponent_message_key:"myop_webcomponent_message"}});var Ee,pn=l(()=>{"use strict";an();$e();Ne();Ee=class extends W{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(et.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=we(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 dn,tt,go=l(()=>{"use strict";pn();Xe();ne();w();dn={},tt=class extends Y{constructor(){super(...arguments);i(this,"type",j.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;dn[a.url]?console.log("Module alreday loaded or in loading process"):dn[a.url]=new Promise((m,u)=>{let f=a.url,c=document.createElement("script");c.type="module",c.src=f,c.onload=()=>{m()},c.onerror=()=>{u()},document.head.appendChild(c)}),await dn[a.url],await Bn(1);let p="myop-comp-".concat(E()),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 Ee(e,t,s,d,r)})}}});var T,N=l(()=>{"use strict";w();T=class extends Qe{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(U(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 B,Q=l(()=>{"use strict";B={id:"myop-id"}});var S,yo,P=l(()=>{"use strict";Q();S=(o,n)=>n.querySelectorAll("[".concat(B.id,"='").concat(o.refConfig.selector,"']")),yo=(o,n)=>{let e=S(o,n);return e.length?e.item(0):null}});var nt,ho=l(()=>{"use strict";C();b();N();P();nt=class extends T{constructor(){super(...arguments);i(this,"messageType",g.BindClickMessage);i(this,"innerExecutor",(e,t,s)=>{let r=S(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new oe(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}}});var ot,Mo=l(()=>{"use strict";C();N();P();ot=class extends T{constructor(){super(...arguments);i(this,"messageType",g.ChangeTextMessage);i(this,"innerExecutor",(e,t)=>{S(e.ref,t.shadowRoot).forEach(r=>{r.textContent=e.content})})}}});var st,Co=l(()=>{"use strict";w();st=class extends xe{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}}});var it,Io=l(()=>{"use strict";w();Q();N();b();C();it=class extends T{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(B.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(B.id);p&&r.push(new Me(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new pe(e.handlerUniqueId,r))});i(this,"messageType",g.DetectMyopRefsMessage)}}});var rt,xo=l(()=>{"use strict";C();N();P();rt=class extends T{constructor(){super(...arguments);i(this,"messageType",g.SetAttributeMessage);i(this,"innerExecutor",(e,t)=>{S(e.ref,t.shadowRoot).forEach(r=>{r.setAttribute(e.name,e.value)})})}}});var at,bo=l(()=>{"use strict";C();b();N();P();me();at=class extends T{constructor(){super(...arguments);i(this,"messageType",g.AddEventListenerMessage);i(this,"innerExecutor",(e,t,s)=>{let r=S(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=m=>{s(new ie(e.handlerUniqueId,O(m,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}}});var pt,wo=l(()=>{"use strict";C();Q();Fe();Ye();N();pt=class extends T{constructor(){super(...arguments);i(this,"messageType",g.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(B.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=$.Instance(),d=p.components.find(c=>c.id===e.options.id);d&&d.dispose();let m=p.components.indexOf(d);m!==-1&&p.components.splice(m,1);let u=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),f=[];Object.keys(u.refs).forEach(c=>{let y=u.refs[c];y=y.__nonProxied||y,y.componentDefinition&&f.push({refName:c,componentDefinitionId:y.componentDefinition.id})}),s(new V(e.handlerUniqueId,f))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new V(e.handlerUniqueId,[],!0));debugger}})().then()})}}});var dt,cn=l(()=>{"use strict";me();dt=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=O,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)}});var ct,So=l(()=>{"use strict";C();b();N();cn();ct=class extends T{constructor(){super(...arguments);i(this,"messageType",g.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{dt(e,a=>{s(new se(e.handlerUniqueId,a))},t)})}}});var Eo,mt,To=l(()=>{"use strict";C();b();N();P();Q();me();Eo=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(B.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Eo(r),required:r.required,validity:O(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},mt=class extends T{constructor(){super(...arguments);i(this,"messageType",g.GetElementValueMessage);i(this,"innerExecutor",(e,t,s)=>{S(e.ref,t.shadowRoot).forEach(a=>{s(new re(Eo(a)),e)})})}}});var lt,vo=l(()=>{"use strict";C();N();P();lt=class extends T{constructor(){super(...arguments);i(this,"messageType",g.SetInnerHtml);i(this,"innerExecutor",(e,t)=>{S(e.ref,t.shadowRoot).forEach(r=>{r.innerHTML=e.content})})}}});var _o={};ee(_o,{WebComponentSDK:()=>Te});var Te,mn=l(()=>{"use strict";w();C();an();ho();Mo();Co();Io();te();b();xo();bo();wo();So();To();vo();Te=class extends Ce{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(et.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 st(e,t)}}}),setTimeout(()=>{this.messageToHost(new ae)},1)});i(this,"messageToHost",(e,t)=>{e.direction=_.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new ot(this.messageToHost,this.components),new lt(this.messageToHost,this.components),new nt(this.messageToHost,this.components),new it(this.messageToHost,this.components),new rt(this.messageToHost,this.components),new at(this.messageToHost,this.components),new ct(this.messageToHost,this.components),new mt(this.messageToHost,this.components),new pt(this.messageToHost,this.components)]);i(this,"init",()=>{})}};F("WebComponentSDK",Te)});var Ro=l(()=>{"use strict";mn()});var ko,Ho=l(()=>{"use strict";ko=""});function Zs(o,n){return class extends HTMLElement{connectedCallback(){let e=n===de.open?"open":"closed",t=this.attachShadow({mode:e});Po().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var Js,Xs,Bo,Lo,ft,Po,ei,ti,ni,ut,Oo=l(()=>{"use strict";pn();nn();Xe();ne();w();Ro();rn();Ho();Js="<!-- myop-web-component -->",Xs="myop-web-component",Bo=new Set,Lo=[],Po=async()=>(ft||(ft=new Te,ft.init()),ft);ei=(o,n,e)=>{customElements.define(o,Zs(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},ti=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\\d+)/g,"-$1").toLowerCase(),ni=o=>(o=ti(o),o.replace(/_/g,"-")),ut=class extends Y{constructor(){super(...arguments);i(this,"type",j.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(E()),d;if(a.shadowRootMode===de.localFrame){let m=E(),u="myop-comp-".concat(m),f=document.createElement("iframe");f.id=u,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(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=""),f=this.appendChild(s,f,r);let c=f.contentDocument||f.contentWindow.document;c.open();let y=null;{let v=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(v)try{y=JSON.parse(v.getAttribute("content")||"{}")}catch(z){}}let h=a.HTML;if(r!=null&&r._inspection){let L=new DOMParser().parseFromString(a.HTML,"text/html"),v=L.getElementById("myop_preview");v==null||v.removeAttribute("type");let z=L.implementation.createHTMLDocument();z.body.innerHTML="<script>\\n const beforeKeysWindow = new Set(Object.keys(window));\\n window.myopState = {\\n beforeKeysWindow,\\n };\\n <\\/script>";let _e=z.body.firstChild;_e&&L.head&&L.head.insertBefore(L.importNode(_e,!0),L.head.firstChild),h=L.documentElement.outerHTML}else if((r==null?void 0:r.data)!==void 0){let L=new DOMParser().parseFromString(a.HTML,"text/html"),v=L.getElementById("myop_preview");v&&(v.remove(),h=L.documentElement.outerHTML)}c.writeln(h);let fe='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\\/script>'),ve="<script>\\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\\n const __myop_init = async () => {\\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\\n const sdk = new IframeSDK();\\n sdk.init();\\n }\\n __myop_init().then();\\n <\\/script>";if(c.writeln("".concat(fe).concat(ve)),(r==null?void 0:r.data)!==void 0){let ue="<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>",L=JSON.stringify(r.data).replace(/<\\/script/gi,"\\\\u003c/script"),v='<script id="__myop_init_data_script">\\n (function() {\\n var data = '.concat(L,";\\n var scriptEl = document.getElementById('__myop_init_data_script');\\n\\n var callInitInterface = function(fn) {\\n var startTime = performance.now();\\n // Mark as pre-injected data call for extension tracking\\n window.__myop_init_preinjected = true;\\n try {\\n fn(data);\\n } finally {\\n window.__myop_init_preinjected = false;\\n }\\n var duration = performance.now() - startTime;\\n\\n // Notify extension via postMessage (init* = pre-injected)\\n try {\\n window.parent.postMessage({\\n type: 'MYOP_PREINJECTED_INIT',\\n payload: {\\n data: data,\\n duration: duration,\\n timestamp: Date.now()\\n }\\n }, '*');\\n } catch (e) {}\\n\\n // Cleanup: remove script tag and stored data\\n if (scriptEl && scriptEl.parentNode) {\\n scriptEl.parentNode.removeChild(scriptEl);\\n }\\n delete window.__myop_init_data;\\n };\\n\\n if (typeof window.myop_init_interface === 'function') {\\n // Function already exists - call immediately\\n callInitInterface(window.myop_init_interface);\\n } else {\\n // Function not yet defined - store data and watch for definition\\n window.__myop_init_data = data;\\n\\n var _original;\\n Object.defineProperty(window, 'myop_init_interface', {\\n configurable: true,\\n enumerable: true,\\n set: function(fn) {\\n _original = fn;\\n if (window.__myop_init_data !== undefined) {\\n var storedData = window.__myop_init_data;\\n delete window.__myop_init_data;\\n callInitInterface(fn);\\n }\\n },\\n get: function() {\\n return _original;\\n }\\n });\\n }\\n })();\\n <\\/script>");c.writeln(ue+v)}c.close();let Z=new Se(e,t,s,f,r);return Z.sizeMeta=y,Z.initiated().then(()=>{Z.observeAutoSize({forceAutoSize:!0}),r!=null&&r.hidden||Z.show()}),Z}if(a.shadowRootMode===de.none){let m=document.createElement("template");m.innerHTML=a.HTML,d=m.content.firstElementChild,Po().then(u=>{u.connectedCallback(d,d)})}else{let m=ni(e.name+t.id);Lo.includes(m)||(ei(m,a.HTML,a.shadowRootMode),Lo.push(m)),d=document.createElement(m)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,r),new Ee(e,t,s,d,r)})}isMyopWebComponent(e){return e.trimStart().startsWith(Js)}extractWebComponentScript(e){let r=new DOMParser().parseFromString(e,"text/html").getElementById(Xs);return(r==null?void 0:r.textContent)||null}executeWebComponentScript(e,t){if(Bo.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),Bo.add(t),console.log("[MyopWebComponent] Executed web component script: ".concat(t))}async loadExtractedWebComponent(e,t,s,r,a){let p=this.extractWebComponentScript(r);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),m=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(p,d);let u=window.__MYOP_TAG_NAME__;if(!u)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");m&&m!==u&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(m," to ").concat(u));let f="myop-comp-".concat(E()),c=document.createElement(u);c.id=f,a!=null&&a.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,c,a);let y=new le(e,t,s,c,u,a);return(a==null?void 0:a.data)!==void 0&&y.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(u,"> into container")),y}}});var Ao,Ko,zo=l(()=>{"use strict";ne();b();Ao=(o,n,e)=>{let t="myop-css-".concat(E());return o.send(new D(({rootRef:s,_stylesheet:r,_tagId:a,_css:p})=>{let d=document.createElement("style");d.type="text/css";let m=p;for(let u in r){m+="".concat(u," { ");let f=r[u];for(let c in f)m+="".concat(c,": ").concat(f[c],"; ");m+="} "}d.appendChild(document.createTextNode(m)),d.id=a,(s.shadowRoot||s.container).appendChild(d)},()=>{},{_stylesheet:n,_css:e||"",_tagId:t})),()=>{o.send(new D(({rootRef:s,_tagId:r})=>{let a=(s.shadowRoot||document).getElementById(r);a&&a.remove()},()=>{},{_tagId:t}))}},Ko=(o,n)=>{let e="myop-css-".concat(E());return o.send(new D(({rootRef:t,_tagId:s,_link:r})=>{let a=document.createElement("link");a.id=s,a.rel="stylesheet",a.href=r,document.head.appendChild(a),(t.shadowRoot||t.container).appendChild(a)},()=>{},{_link:n,_tagId:e})),()=>{o.send(new D(({rootRef:t,_tagId:s})=>{let r=(t.shadowRoot||document).getElementById(s);r&&r.remove()},()=>{},{_tagId:e}))}}});var oi,ln,$o,Fo=l(()=>{"use strict";oi=(o,n)=>{let e=new RegExp(Object.keys(n).join("|"),"g");return o.replace(e,t=>(n[t]||t).toString())},ln=(o,n)=>{let e=o.loader;if(e.type!=="IframeLoader")throw new Error('iframeSkinUrlTokenizer received skin with loader type "'.concat(e.type,'", currently only "IframeLoader" is supported'));return o.loader=M({},o.loader),o.loader.url=oi(o.loader.url,n),o},$o=o=>async n=>ln(n,o)});var Wo,No,Uo=l(()=>{"use strict";b();Wo=(o,n,e)=>{o.send(new q(({ref:t,_className:s})=>{t==null||t.classList.add(s)},{elementId:e,_className:n}))},No=(o,n,e)=>{o.send(new q(({ref:t,_className:s})=>{t==null||t.classList.remove(s)},{elementId:e,_className:n}))}});var ht,gt,Mt,yt,qo=l(()=>{"use strict";ne();ht=class ht{constructor(){i(this,"_runTimeInstanceId","runtime-instance-id-"+E());i(this,"_runTimeId","runtime-id-"+E());i(this,"_runTimeName","runtime-name-"+E());i(this,"id",this._runTimeId);i(this,"name",this._runTimeName);i(this,"description","");i(this,"loader",null);i(this,"withLoader",n=>(this.loader=n,this));i(this,"withHTMLLoader",n=>(n.type="HTMLLoader",this.loader=n,this));i(this,"build",()=>this)}};i(ht,"create",()=>new ht);gt=ht,Mt=class Mt{constructor(){i(this,"_runTimeInstanceId","runtime-instance-id-"+E());i(this,"_runTimeId","runtime-id-"+E());i(this,"_runTimeName","runtime-name-"+E());i(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null});i(this,"name",this._runTimeName);i(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0});i(this,"withInstance",n=>(this.instance=n,this));i(this,"withType",n=>(this.type=n,this));i(this,"withName",n=>(this.name=n,this));i(this,"withDefaultSkin",n=>(this.type.skins.push(n),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:n.id}},this));i(this,"withRef",n=>(this.type.refs.push(n),this));i(this,"withBasicRef",n=>{let e={id:"",name:n,description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}};return this.type.refs.push(e),this});i(this,"build",()=>JSON.parse(JSON.stringify(this)))}};i(Mt,"create",()=>new Mt);yt=Mt});var si,Ct,ii,ri,J,K,Vo,fn=l(()=>{"use strict";w();si=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:be.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:be.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Ct="__MYOP_CLOUD_REPOSITORY_MAIN__",ii=()=>{if(typeof window<"u")return window[Ct];if(typeof globalThis<"u")return globalThis[Ct]},ri=o=>{typeof window<"u"&&(window[Ct]=o),typeof globalThis<"u"&&(globalThis[Ct]=o)},J=class J{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"variants",{});i(this,"preloadedComponents",{});i(this,"userFlows",{});i(this,"_defaultEnv","production");i(this,"_envExplicitlySet",!1)}static get Main(){let n=ii();return n||(J._main||(J._main=new J,ri(J._main)),J._main)}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let s=this.preloadedComponents[n],r=e!==void 0||t!==void 0,a,p;if(!r&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let m=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!m}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(m,u)=>{try{let f="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(f+="&preview=true");let h=(await(await fetch(f)).json()).item;if(!h){u(new Error('Component "'.concat(n,'" not found')));return}if(!h.consume_variant||!h.consume_variant.length){u(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let fe=si(h);m(fe)}catch(f){u(f)}})),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(J,"_main",null);K=J,Vo=K});var jo,Go=l(()=>{"use strict";jo=async o=>await o()});var X,Yo,Qo,Jo,Xo,Zo,es,ts,ns,os=l(()=>{"use strict";fn();X=K.Main,Yo=()=>X,Qo=(o,n,e)=>X.isPreloaded(o,n,e),Jo=o=>X.getPreloadedParams(o),Xo=()=>{X=new K("http://localhost:9292")},Zo=o=>{X=new K(o)},es=o=>{X=o},ts=o=>{X.setEnvironment(o)},ns=async(o,n,e)=>Promise.allSettled(o.map(t=>X.fetchComponentV2(t,n,e)))});var un={};ee(un,{CloudRepository:()=>K,ComponentConfig:()=>yt,SkinConfig:()=>gt,addClass:()=>Wo,applyStylesheet:()=>Ao,applyStylesheetLink:()=>Ko,changeSkinUrlByTokenizer:()=>$o,createIframeSkinByTokenizer:()=>ln,enableLocalDev:()=>Xo,exec:()=>jo,getCloudRepository:()=>Yo,getPreloadedParams:()=>Jo,isPreloaded:()=>Qo,preloadComponents:()=>ns,removeClass:()=>No,setCloudRepository:()=>es,setCloudRepositoryUrl:()=>Zo,setEnvironment:()=>ts,v2_CloudRepository:()=>Vo});var It=l(()=>{"use strict";zo();Fo();Uo();qo();fn();Go();os()});var ss,is=l(()=>{"use strict";Kt();It();w();ss=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=At(t);switch(s){case"component":{let[a,p]=r,d=await K.Main.fetchComponent(a);if(d&&d.type.skins.find(u=>u.id===p))return d.instance.skinSelector={type:ce.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=At(t),m=(await K.Main.fetchFlow(a)).components.find(u=>u.type.id===o.type.id);if(m&&m.instance.skinSelector.type===ce.Segmented&&m.instance.resolvedExperiences){let u=m.instance.resolvedExperiences.find(f=>f.id===p);if((u==null?void 0:u.type)===Je.Segment){let f=u,y=m.instance.skinSelector.segments.find(h=>h.segmentId===f.segment.id);if(y)return m.instance.skinSelector=y==null?void 0:y.skinSelector,m}}}break}}}finally{return null}}});var ps={};ee(ps,{HostSDK:()=>$,hostSDK:()=>as});var rs,$,as,Fe=l(()=>{"use strict";te();C();b();uo();go();Ne();w();Ge();Oo();is();rs="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",$=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",ge);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==_.up&&n.data.messageType!==g.EnvelopedMessage)return;let e=n.data;if(e.messageType===g.InitRequest){this.components2init.forEach(s=>{s.send(new ye(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===_.down){s.message.messageType===A.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 Ze,new tt,new ut];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 ce.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case ce.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let m=e.find(y=>y.type===Je.Segment?y.segment.id===d.segmentId:!1);if(!m)throw new Error("experience not found");let f=m.segment,c=(t||{})[f.function];return c?await c():(console.warn("segmentId:".concat(d.segmentId,", ").concat(f.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 u,f,c,y;if(!e){debugger;throw new Error("no container was found for this component")}let s=await ss(n);s&&(n=s);let r=M(M({},(u=this.loaderHooks)!=null?u:{}),(f=t==null?void 0:t.hooks)!=null?f:{}),a=e;if(a.myop)if(a.component){n=M({},n),n.instance=M({},n.instance);let h=await this.runSkinSelector(n,r);if(!h)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(c=t==null?void 0:t.hooks)!=null&&c.afterSkinSelected&&(h=await t.hooks.afterSkinSelected(M({},h))),n.instance.skinSelector={type:ce.Dedicated,skin:h},t&&(t=M({},t),delete t.hooks),await on(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");(y=t==null?void 0:t.hooks)!=null&&y.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(M({},p)));let d=this.componentsLoaders.find(h=>h.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await d.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(h=>h!==m),this.components2init=this.components2init.filter(h=>h!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=fo(m,n.type.props,p));try{await sn(m,n,this.components)}catch(h){throw h}return t!=null&&t.skipInit||await m.initiated(),m});i(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,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($,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:rs});if(!window.myop.hostSDK){let o=new $;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:rs}),window.myop.hostSDK=o}as=window.myop.hostSDK;F("hostSDK",as)});var xt,ds=l(()=>{"use strict";C();Q();w();b();xt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.DetectMyopRefsMessage);i(this,"executor",e=>{let t=document.querySelectorAll("[".concat(B.id,"]")),s=[];t.forEach(r=>{let a=r.getAttribute(B.id);a&&s.push(new Me(a,r.tagName,r.getBoundingClientRect()))}),this.messageToHost(new pe(e.handlerUniqueId,s))})}}});var bt,cs=l(()=>{"use strict";C();w();b();P();bt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.BindClickMessage);i(this,"executor",e=>{let t=[];return S(e.ref,document).forEach(r=>{let a=()=>{this.messageToHost(new oe,e)};r.addEventListener("click",a);let p=()=>{r.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(r=>r())}})}}});var wt,ms=l(()=>{"use strict";C();w();P();wt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.ChangeTextMessage);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{s.textContent=e.content})})}}});var St,ls=l(()=>{"use strict";C();b();w();cn();St=class extends x{constructor(){super(...arguments);i(this,"messageType",g.ExecuteScriptMessage);i(this,"executor",e=>{dt(e,s=>{this.messageToHost(new se(e.handlerUniqueId,s))},new xe(document.documentElement))})}}});var Et,fs=l(()=>{"use strict";C();w();b();me();P();Et=class extends x{constructor(){super(...arguments);i(this,"messageType",g.AddEventListenerMessage);i(this,"executor",e=>{let t=S(e.ref,document),s=[];return t.forEach(r=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new ie(e.handlerUniqueId,O(p,e.serializableSkeleton)))})};r.addEventListener(e.type,a),s.push(()=>{r.removeEventListener(e.type,a)})}),()=>{s.forEach(r=>{r()})}})}}});var Tt,us=l(()=>{"use strict";C();w();P();Tt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.SetAttributeMessage);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{s.setAttribute(e.name,e.value)})})}}});var vt,gs=l(()=>{"use strict";C();Q();w();Fe();Ye();vt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.CreateRefComponentMessage);i(this,"executor",e=>{(async()=>{let s=document.querySelectorAll("[".concat(B.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await $.Instance().loadComponent(e.nestedComponentConfig,s.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let m=a.refs[d];m=m.__nonProxied||m,m.componentDefinition&&p.push({refName:d,componentDefinitionId:m.componentDefinition.id})}),this.messageToHost(new V(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new V(e.handlerUniqueId,[],!0));debugger}})().then()})}}});var ys,hs=l(()=>{"use strict";ys=(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 _t,Ms=l(()=>{"use strict";C();b();w();hs();_t=class extends x{constructor(){super(...arguments);i(this,"messageType",g.SetMutationObserverMessage);i(this,"executor",e=>{e.source&&ys(document.body,()=>{this.messageToHost(new Pe)})})}}});var Cs,Rt,Is=l(()=>{"use strict";C();Q();w();b();me();P();Cs=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(B.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Cs(r),required:r.required,validity:O(r.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Rt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.GetElementValueMessage);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{this.messageToHost(new re(Cs(s)),e)})})}}});var kt,xs=l(()=>{"use strict";C();w();b();P();kt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.GetAttributeMessage);i(this,"executor",e=>{let t=yo(e.ref,document);t&&this.messageToHost(new Le(t.getAttribute(e.name)),e)})}}});var Ht,bs=l(()=>{"use strict";b();C();w();Ht=class extends x{constructor(){super(...arguments);i(this,"messageType",g.SetResizeObserverMessage);i(this,"executor",e=>{let t=new ResizeObserver(s=>{this.messageToHost(new ze)});return t.observe(document.body),()=>{t.disconnect()}})}}});var Dt,ws=l(()=>{"use strict";C();w();P();Dt=class extends x{constructor(){super(...arguments);i(this,"messageType",g.SetInnerHtml);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{s.innerHTML=e.content})})}}});var Ss={};ee(Ss,{IframeSDK:()=>Bt});var Bt,Es=l(()=>{"use strict";w();ds();cs();ms();ls();te();fs();us();b();gs();Ms();Is();Ge();xs();bs();ws();Bt=class extends Ce{constructor(){super();i(this,"version",ge);i(this,"messageToHost",(e,t)=>{var r;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let s=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=s[0]),e.source||(e.source=s[0]),e.direction=_.up,(r=window.parent)==null||r.postMessage(M({},e),"*")});i(this,"supportedHandlers",[new wt(this.messageToHost),new Dt(this.messageToHost),new bt(this.messageToHost),new xt(this.messageToHost),new St(this.messageToHost),new Et(this.messageToHost),new Tt(this.messageToHost),new Rt(this.messageToHost),new _t(this.messageToHost),new Ht(this.messageToHost),new kt(this.messageToHost),new vt(this.messageToHost)]);i(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new ae)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};F("IframeSDK",Bt)});var pi={};var ai,Ts=l(()=>{"use strict";b();te();ai=M({},he);F("MyopMessages",ai)});var vs={};ee(vs,{CloudRepository:()=>K,ComponentConfig:()=>yt,SkinConfig:()=>gt,addClass:()=>Wo,applyStylesheet:()=>Ao,applyStylesheetLink:()=>Ko,changeSkinUrlByTokenizer:()=>$o,createIframeSkinByTokenizer:()=>ln,enableLocalDev:()=>Xo,exec:()=>jo,getCloudRepository:()=>Yo,getPreloadedParams:()=>Jo,isPreloaded:()=>Qo,preloadComponents:()=>ns,removeClass:()=>No,setCloudRepository:()=>es,setCloudRepositoryUrl:()=>Zo,setEnvironment:()=>ts,v2_CloudRepository:()=>Vo});var _s=l(()=>{"use strict";te();It();It();F("MyopHelpers",un)});var fi={};ee(fi,{getHostModule:()=>Rs,getIframeModule:()=>ks,getWebcomponentModule:()=>Hs});te();var Dn;if(window.__federation__)console.log("__federation__ loaded more than once.");else{let o=(Dn=document.currentScript)==null?void 0:Dn.src,n=o?o.split("/").slice(0,-1).join("/"):"";window.__federation__={__public_auto_path__:n,__use_public_auto_path__:!0,__public_path__:void 0,__loading_timeout__:5*1e3}}window.__federation__.load__federation__=(o,n,e)=>{if(window.__federation__[n])console.log("__federation__ module ".concat(n," already loaded.")),e(window.__federation__[n][Ot]);else{let t;window.__federation__[n]={},window.__federation__[n][je]=s=>{t&&(document.head.removeChild(t),t=null),window.__federation__[n][Ot]=s,e(s)},t=document.createElement("script"),t.type="module",t.src=o,t.async=!0,document.head.appendChild(t)}};Ge();console.log("myop root sdk - loaded",document.location.origin);var di="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",Rs=()=>Promise.resolve().then(()=>(Fe(),ps)),ks=()=>Promise.resolve().then(()=>(Es(),Ss)),Hs=()=>Promise.resolve().then(()=>(mn(),_o)),ci=()=>Promise.resolve().then(()=>(Ts(),pi)),mi=()=>Promise.resolve().then(()=>(_s(),vs)),Ue=o=>async()=>(await o()).get(),li={version:ge,getHostModule:Ue(Rs),getIframeModule:Ue(ks),getWebcomponentModule:Ue(Hs),getMyopMessages:Ue(ci),getMyopHelpers:Ue(mi)};window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:di});window.myop.rootSDK?console.log("myop root host loaded more than once."):window.myop=M({rootSDK:li},window.myop);return Ws(fi);})();
|
|
2
|
-
`;var Ue=Object.defineProperty,Vt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,qe=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,Re=(e,t,s)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,S=(e,t)=>{for(var s in t||(t={}))Yt.call(t,s)&&Re(e,s,t[s]);if(qe)for(var s of qe(t))Jt.call(t,s)&&Re(e,s,t[s]);return e},le=(e,t)=>Vt(e,Gt(t)),Qt=(e,t)=>{for(var s in t)Ue(e,s,{get:t[s],enumerable:!0})},r=(e,t,s)=>Re(e,typeof t!="symbol"?t+"":t,s),g=(e,t,s)=>new Promise((n,i)=>{var a=c=>{try{l(s.next(c))}catch(d){i(d)}},o=c=>{try{l(s.throw(c))}catch(d){i(d)}},l=c=>c.done?n(c.value):Promise.resolve(c.value).then(a,o);l((s=s.apply(e,t)).next())}),ge="__federation__",je="onLoad",Ve=(e,t)=>{window[ge]&&window[ge][e]&&window[ge][e][je]&&window[ge][e][je]({[e]:t})},_={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",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",CleanupMessage:"CleanupMessage",In:{MutationObserverMessage:"MutationObserverMessage",ResizeObserverMessage:"ResizeObserverMessage"}},He={};Qt(He,{AddEventListenerMessage:()=>rs,BaseMyopMessage:()=>x,BindClickMessage:()=>ss,ChangeTextMessage:()=>ns,CleanupMessage:()=>pt,CleanupReplayMessage:()=>mt,ClickReplayMessage:()=>Je,CreateRefComponentMessage:()=>at,CustomRefMessage:()=>De,DetectMyopRefsMessage:()=>ds,DetectedMyopRefsMessage:()=>dt,DisposeMessage:()=>ft,ElementValueReplayMessage:()=>nt,EnvelopedMessage:()=>lt,EventListenerCallbackMessage:()=>tt,ExecuteComponentMethod:()=>j,ExecuteScriptMessage:()=>q,ExecuteScriptReplyMessage:()=>Ze,GetAttributeMessage:()=>us,GetAttributeReplayMessage:()=>hs,GetElementValueMessage:()=>ls,InitMessage:()=>ke,InitRequest:()=>ot,InitResponse:()=>it,MessageDirection:()=>O,MutationObserverMessage:()=>ms,MyopBindMessage:()=>$,MyopBindReplayMessage:()=>B,MyopElementMessage:()=>ts,Ref:()=>ce,RefComponentCreatedMessage:()=>Le,ResizeObserverMessage:()=>ys,SetAttributeMessage:()=>as,SetInnerHtml:()=>cs,SetMutationObserverMessage:()=>ps,SetResizeObserverMessage:()=>fs,stripFunction:()=>Xe});var Q=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),Xt=e=>{const t=[...e].map(s=>s.toString(16).padStart(2,"0")).join("");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")},Zt=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";const s=atob(t);return Uint8Array.from(s,n=>n.charCodeAt(0))},Ge=e=>{const t=Zt(e);if(t.length%16!==0)throw new Error("Invalid input length");const s=[];for(let n=0;n<t.length;n+=16)s.push(Xt(t.slice(n,n+16)));return s},es=e=>new Promise(t=>setTimeout(t,e)),O=class{};r(O,"down","down"),r(O,"up","up");var x=class{constructor(){r(this,"id",Q()),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(...t){return new this(...t)}isTypeof(t){return t.messageType===this.messageType}},ts=class extends x{constructor(e){super(),this.ref=e}},B=class extends x{constructor(e){super(),this.replayToHandler=e}},$=class extends x{constructor(t){super(),this.handler=t,r(this,"handlerUniqueId",Q())}},ce=class qt{constructor(t,s){this.refConfig=t,this.component=s,r(this,"myop",!0),r(this,"__nonProxied"),this.__nonProxied=le(S({},this),{component:null})}static create(t,s,n){let i=s;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:t,behavior:{type:"code"}}),new qt(i,n)}},Ye="ClickReplayMessage",ss=class extends ${constructor(e,t){super(t),this.ref=e,r(this,"replyMessageKey",Ye),r(this,"messageType","BindClickMessage"),r(this,"cleanable",!0)}},Je=class extends B{constructor(){super(...arguments),r(this,"messageType",Ye)}},ns=class extends x{constructor(e,t){super(),this.ref=e,r(this,"messageType","ChangeTextMessage"),this.content=t}},Qe="ExecuteScriptReplyMessage",is=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,os=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xe=e=>{let t=e.match(is);if(t)return t[1]||t[3];{let s=e.match(os);if(s)return s[1].trim()}},q=class extends ${constructor(t,s=()=>{},n){super(s),this.scriptInputs=n,r(this,"replyMessageKey",Qe),r(this,"messageType","ExecuteScriptMessage"),r(this,"script",""),this.script=t.toString(),this.content=t.toString(),this.content=Xe(this.content)}};r(q,"replierKey","send"),r(q,"completeStreamKey","completeStream");var Ze=class extends B{constructor(e,t){super(e),this.replayToHandler=e,this.content=t,r(this,"messageType",Qe)}},De=class extends q{constructor(e,t,s=()=>{}){super(({rootRef:n,elementId:i,_script:a,__scriptInputs:o})=>{const l=(n.shadowRoot||n.container).querySelectorAll(`[myop-id='${i}']`);return l.length?(o.ref=l[0],new Function(`return (${a})(...arguments)`)(o)):null},s),this.scriptInputs=t,this.scriptInputs=le(S({},t),{_script:e.toString()})}},et="EventListenerCallbackMessage",rs=class extends ${constructor(e,t,s){super(s),this.ref=e,this.type=t,this.handler=s,r(this,"replyMessageKey",et),r(this,"messageType","AddEventListenerMessage"),r(this,"cleanable",!0),r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},tt=class extends B{constructor(e,t){super(e),this.replayToHandler=e,this.e=t,r(this,"messageType",et),this.content={e:t}}},as=class extends x{constructor(e,t,s){super(),this.ref=e,this.name=t,this.value=s,r(this,"messageType","SetAttributeMessage")}},st="ElementValueReplayMessage",ls=class extends ${constructor(e,t){super(t),this.ref=e,r(this,"replyMessageKey",st),r(this,"messageType","GetElementValueMessage")}},nt=class extends B{constructor(e){super(),this.content=e,r(this,"messageType",st)}},cs=class extends x{constructor(e,t){super(),this.ref=e,r(this,"messageType","SetInnerHtml"),this.content=t}},ke=class extends x{constructor(e){super(),r(this,"messageType","InitMessage"),this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},it=class extends ke{constructor(){super(...arguments),r(this,"messageType","InitResponse")}},ot=class extends x{constructor(){super(...arguments),r(this,"messageType","InitRequest")}},rt="RefComponentCreatedMessage",at=class extends ${constructor(e,t,s,n){super(n),this.refConfig=e,this.nestedComponentConfig=t,this.options=s,r(this,"replyMessageKey",rt),r(this,"messageType","CreateRefComponentMessage")}},Le=class extends B{constructor(e,t,s){super(e),this.replayToHandler=e,this.nestedRefs=t,this.failed=s,r(this,"messageType",rt)}},lt=class extends x{constructor(e,t){super(),this.destination=e,this.message=t,r(this,"messageType","EnvelopedMessage");const s=t;this.route=[e,...s.route?s.route:[]]}},ct="DetectedMyopRefsMessage",ds=class extends ${constructor(){super(...arguments),r(this,"messageType","DetectMyopRefsMessage"),r(this,"replyMessageKey",ct)}},dt=class extends B{constructor(e,t){super(e),this.replayToHandler=e,r(this,"messageType",ct),this.content=t}isTypeof(e){return e.messageType===this.messageType}},ut="GetAttributeReplayMessage",us=class extends ${constructor(e,t,s){super(s),this.ref=e,this.name=t,r(this,"replyMessageKey",ut),r(this,"messageType","GetAttributeMessage")}},hs=class extends B{constructor(e){super(),this.content=e,r(this,"messageType",ut)}},j=class extends x{constructor(e){super(),this.method=e,r(this,"messageType","ExecuteComponentMethod")}},ps=class extends x{constructor(){super(...arguments),r(this,"messageType","SetMutationObserverMessage")}},ms=class extends x{constructor(){super(...arguments),r(this,"messageType","MutationObserverMessage")}},ht="CleanupReplayMessage",pt=class extends ${constructor(e,t){super(t),this.cleanupForMessageId=e,r(this,"replyMessageKey",ht),r(this,"messageType","CleanupMessage")}},mt=class extends B{constructor(e){super(),this.customCleanup=e,r(this,"messageType",ht)}},ft=class extends x{constructor(){super(...arguments),r(this,"messageType","DisposeMessage")}},fs=class extends x{constructor(){super(...arguments),r(this,"cleanable",!0),r(this,"messageType","SetResizeObserverMessage")}},ys=class extends x{constructor(){super(...arguments),r(this,"messageType","ResizeObserverMessage")}},ve=class{constructor(e,t,s){this.componentDefinition=e,this.container=t,r(this,"id",""),r(this,"messageHandlers",{}),r(this,"element"),r(this,"_markedForDisposed",!1),r(this,"bind",(i,a)=>{this.messageHandlers[i]||(this.messageHandlers[i]=[]),this.messageHandlers[i].includes(a)||this.messageHandlers[i].push(a)}),r(this,"bindWhen",(i,a,o)=>{if(!o)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[i]||(this.messageHandlers[i]=[]);const l=this.messageHandlers[i],c=d=>a(d)?(o(d),!0):!1;return l.push(c),()=>{const d=l.indexOf(c);d>-1&&l.splice(d,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((i,a)=>{this._whenInitiatedResolve=i,this._whenInitiatedReject=a})),r(this,"initiated",()=>this._whenInitiated),r(this,"props",{}),r(this,"refs",{}),this.id=(s==null?void 0:s.id)||be.Instance().assignId(e);const n=s!=null&&s.timeout?s==null?void 0:s.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject(`timeout_${n} ${this.id}`)},n),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(e){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=e}onMessageReceived(e){if(e.messageType===_.ExecuteComponentMethod){const s=e;return this[s.method]?this[s.method](s.content):console.log(`method not found ${s.method} on component`,this),!0}const t=this.messageHandlers[e.messageType];if(t&&t.length){let s=!1;return t.forEach(n=>{s=s||n(e)}),s}return!1}sendCleanupMessage(e){e.source=this.id,e.destination=this.id,e.direction=O.down;const t=this.bindWhen(e.replyMessageKey,n=>n.replayToHandler===e.handlerUniqueId,n=>{e.handler(n),t()}),s=e.handler;delete e.handler,this.send(e),e.handler=s}send(e){e.source||(e.source=this.id),e.destination||(e.destination=this.id),e.direction=O.down;let t;if(e.handler){const s=e;t=this.bindWhen(s.replyMessageKey,n=>n.replayToHandler===s.handlerUniqueId,s.handler),delete e.handler}return e.ref&&(e.ref=e.ref.__nonProxied||e.ref),e.cleanable?()=>{this.sendCleanupMessage(new pt(e.id,s=>{})),t&&t()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ft);const e=this.messageHandlers.onDispose;e&&e.forEach(t=>{t(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}},gs=class{constructor(e,t,s,n,i){this.myopId=e,this.htmlTagName=t,this.BoundingRect=s,this.offsetTop=n,this.offsetLeft=i,r(this,"type","MyopElementRef")}},vs=e=>g(void 0,null,function*(){if(typeof e=="function")e();else if(e instanceof Promise){const t=yield e;typeof t=="function"&&t()}}),ws=class{constructor(e){this.messageToHost=e}},_s=class extends ws{constructor(e,t){super(e),this.messageToHost=e,this.context=t}},Ms=class{constructor(e,t){this.id=e,this.context=t,r(this,"send",s=>{})}},bs=class{constructor(){r(this,"messageToHandleAfterInit",[]),r(this,"components",{}),r(this,"alwaysPassEnvelopesToHost",!1),r(this,"messageCleanupCache",{})}handleIncomeMessages(e){const t=e.data?e.data:e.detail;if(!(!t||!t.myop)){let s=t;if(s.direction!==O.down)return;if(s.messageType===_.DisposeMessage){s.destination&&delete this.components[s.destination];return}if(s.messageType===_.InitMessage){const n=s.content.id;if(this.components[n])return;this.components[n]=new Ms(n),this.messageToHost(new it(n));return}if(s.messageType===_.EnvelopedMessage){const n=s,i=n.message;if(s=i,this.alwaysPassEnvelopesToHost||this.components[s.destination]){const a=myop.hostSDK.components.find(l=>l.id===i.destination);if(a){a.send(i);return}const o=myop.hostSDK.components.find(l=>l.id===n.destination);if(o){o.send(i);return}}else return}if(s.messageType){if(s.messageType===_.CleanupMessage){const n=s,i=this.messageCleanupCache[n.cleanupForMessageId],a=new mt(!!i);a.destination=s.destination,i?(delete this.messageCleanupCache[n.cleanupForMessageId],vs(i).then(()=>{this.messageToHost(a,n)}).catch(()=>{})):this.messageToHost(a,n);return}this.supportedHandlers.forEach(n=>{if(n.messageType===s.messageType){const i=n.executor(s);if(s.cleanable&&i&&(this.messageCleanupCache[s.id]=i),i&&!s.cleanable)throw new Error(`Cleanup handler generated for non-cleanable message.
|
|
3
|
-
messageType - ${
|
|
1
|
+
(function(C,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],x):(C=typeof globalThis<"u"?globalThis:C||self,x(C["@myop/react"]={},C.React,C.React))})(this,(function(C,x,M){"use strict";const en=`"use strict";var MyopSDK=(()=>{var Ye=Object.defineProperty,Ys=Object.defineProperties,Qs=Object.getOwnPropertyDescriptor,Js=Object.getOwnPropertyDescriptors,Xs=Object.getOwnPropertyNames,zn=Object.getOwnPropertySymbols;var $n=Object.prototype.hasOwnProperty,Zs=Object.prototype.propertyIsEnumerable;var Nt=(o,n,e)=>n in o?Ye(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,M=(o,n)=>{for(var e in n||(n={}))$n.call(n,e)&&Nt(o,e,n[e]);if(zn)for(var e of zn(n))Zs.call(n,e)&&Nt(o,e,n[e]);return o},V=(o,n)=>Ys(o,Js(n));var m=(o,n)=>()=>(o&&(n=o(o=0)),n);var se=(o,n)=>{for(var e in n)Ye(o,e,{get:n[e],enumerable:!0})},ei=(o,n,e,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Xs(n))!$n.call(o,s)&&s!==e&&Ye(o,s,{get:()=>n[s],enumerable:!(t=Qs(n,s))||t.enumerable});return o};var ti=o=>ei(Ye({},"__esModule",{value:!0}),o);var i=(o,n,e)=>Nt(o,typeof n!="symbol"?n+"":n,e);var Qe,Je,Ut,F,ie=m(()=>{"use strict";Qe="__federation__",Je="onLoad",Ut="moduleInstance",F=(o,n)=>{window[Qe]&&window[Qe][o]&&window[Qe][o][Je]&&window[Qe][o][Je]({[o]:n})}});var Ce,Xe=m(()=>{Ce="0.3.22"});var u,C=m(()=>{"use strict";u={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}}});var E,ni,oi,qt,Vt=m(()=>{"use strict";E=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16)),ni=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("-")},oi=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))},qt=o=>{let n=oi(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(ni(n.slice(t,t+16)));return e}});var Fn,re=m(()=>{"use strict";Vt();Fn=o=>new Promise(n=>setTimeout(n,o))});var v,I,Gt,_,R,J,H=m(()=>{"use strict";re();v=class{};i(v,"down","down"),i(v,"up","up");I=class{constructor(){i(this,"id",E());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}},Gt=class extends I{constructor(e){super();this.ref=e}},_=class extends I{constructor(e){super();this.replayToHandler=e}},R=class extends I{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",E())}},J=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=V(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 Nn,jt,ae,Un=m(()=>{"use strict";H();Nn="ClickReplayMessage",jt=class extends R{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",Nn);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},ae=class extends _{constructor(){super(...arguments);i(this,"messageType",Nn)}}});var Yt,qn=m(()=>{"use strict";H();Yt=class extends I{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}}});var Vn,si,ii,Gn,k,pe,Qt=m(()=>{"use strict";H();Vn="ExecuteScriptReplyMessage",si=/(?:function\\s*\\w*\\s*\\([^)]*\\)\\s*\\{([\\s\\S]*?)\\}|(\\([^)]*\\)\\s*=>\\s*\\{([\\s\\S]*?)\\}))\\s*$/,ii=/\\(\\s*[^)]+\\s*\\)\\s*=>\\s*(.+)/,Gn=o=>{let n=o.match(si);if(n)return n[1]||n[3];{let e=o.match(ii);if(e)return e[1].trim()}},k=class extends R{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",Vn);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Gn(this.content)}};i(k,"replierKey","send"),i(k,"completeStreamKey","completeStream");pe=class extends _{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",Vn)}}});var G,jn=m(()=>{"use strict";Qt();G=class extends k{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=V(M({},t),{_script:e.toString()})}}});var Yn,Jt,de,Qn=m(()=>{"use strict";H();Yn="EventListenerCallbackMessage",Jt=class extends R{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",Yn);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},de=class extends _{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",Yn);this.content={e:t}}}});var Xt,Jn=m(()=>{"use strict";H();Xt=class extends I{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}}});var Xn,Zt,ce,en=m(()=>{"use strict";H();Xn="ElementValueReplayMessage",Zt=class extends R{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",Xn);i(this,"messageType","GetElementValueMessage")}},ce=class extends _{constructor(e){super();this.content=e;i(this,"messageType",Xn)}}});var tn,Zn=m(()=>{"use strict";H();tn=class extends I{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}}});var Ie,Be,me,eo=m(()=>{"use strict";H();Ie=class extends I{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},Be=class extends Ie{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},me=class extends I{constructor(){super(...arguments);i(this,"messageType","InitRequest")}}});var to,Le,j,Ze=m(()=>{"use strict";H();to="RefComponentCreatedMessage",Le=class extends R{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",to);i(this,"messageType","CreateRefComponentMessage")}},j=class extends _{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",to)}}});var Pe,nn=m(()=>{"use strict";H();Pe=class extends I{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 no,on,le,oo=m(()=>{"use strict";H();no="DetectedMyopRefsMessage",on=class extends R{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",no)}},le=class extends _{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",no);this.content=t}isTypeof(e){return e.messageType===this.messageType}}});var so,sn,Oe,io=m(()=>{"use strict";H();so="GetAttributeReplayMessage",sn=class extends R{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",so);i(this,"messageType","GetAttributeMessage")}},Oe=class extends _{constructor(e){super();this.content=e;i(this,"messageType",so)}}});var A,ro=m(()=>{"use strict";H();A=class extends I{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}}});var rn,Ae,ao=m(()=>{"use strict";H();rn=class extends I{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},Ae=class extends I{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}}});var po,Ke,ze,co=m(()=>{"use strict";H();po="CleanupReplayMessage",Ke=class extends R{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",po);i(this,"messageType","CleanupMessage")}},ze=class extends _{constructor(e){super();this.customCleanup=e;i(this,"messageType",po)}}});var $e,mo=m(()=>{"use strict";H();$e=class extends I{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}}});var an,We,lo=m(()=>{"use strict";H();an=class extends I{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},We=class extends I{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}}});var xe={};se(xe,{AddEventListenerMessage:()=>Jt,BaseMyopMessage:()=>I,BindClickMessage:()=>jt,ChangeTextMessage:()=>Yt,CleanupMessage:()=>Ke,CleanupReplayMessage:()=>ze,ClickReplayMessage:()=>ae,CreateRefComponentMessage:()=>Le,CustomRefMessage:()=>G,DetectMyopRefsMessage:()=>on,DetectedMyopRefsMessage:()=>le,DisposeMessage:()=>$e,ElementValueReplayMessage:()=>ce,EnvelopedMessage:()=>Pe,EventListenerCallbackMessage:()=>de,ExecuteComponentMethod:()=>A,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>pe,GetAttributeMessage:()=>sn,GetAttributeReplayMessage:()=>Oe,GetElementValueMessage:()=>Zt,InitMessage:()=>Ie,InitRequest:()=>me,InitResponse:()=>Be,MessageDirection:()=>v,MutationObserverMessage:()=>Ae,MyopBindMessage:()=>R,MyopBindReplayMessage:()=>_,MyopElementMessage:()=>Gt,Ref:()=>J,RefComponentCreatedMessage:()=>j,ResizeObserverMessage:()=>We,SetAttributeMessage:()=>Xt,SetInnerHtml:()=>tn,SetMutationObserverMessage:()=>rn,SetResizeObserverMessage:()=>an,stripFunction:()=>Gn});var b=m(()=>{"use strict";H();Un();qn();Qt();jn();Qn();Jn();en();Zn();eo();Ze();nn();oo();en();io();ro();ao();co();mo();lo()});var N,Fe=m(()=>{"use strict";C();b();Ne();N=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)||z.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===u.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=v.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=v.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 Ke(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new $e);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}}});var be,fo=m(()=>{"use strict";be=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 uo,x,et,go=m(()=>{"use strict";uo=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},x=class{constructor(n){this.messageToHost=n}},et=class extends x{constructor(e,t){super(e);this.messageToHost=e;this.context=t}}});var pn,we,yo=m(()=>{"use strict";C();w();b();pn=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},we=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!==v.down)return;if(t.messageType===u.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===u.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new pn(s),this.messageToHost(new Be(s));return}if(t.messageType===u.EnvelopedMessage){let s=t,r=s.message;if(t=r,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===r.destination);if(a){a.send(r);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(r);return}}else return}if(t.messageType){if(t.messageType===u.CleanupMessage){let r=t,a=this.messageCleanupCache[r.cleanupForMessageId],p=new ze(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],uo(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 Y,fe,Te,Se,ue,tt,Ee,w=m(()=>{"use strict";fo();go();yo();Y={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"},fe={open:"open",closed:"closed",none:"none",localFrame:"localFrame"},Te={message:"message",code:"code"},Se=class{};i(Se,"code","code"),i(Se,"component","component");ue={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},tt={Segment:"Segment",Promo:"Promo",AB:"AB"},Ee=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 dn,ri,cn,O,ge=m(()=>{"use strict";dn=o=>o!==Object(o),ri=o=>typeof o=="function",cn=o=>{if(dn(o))return!0;if(ri(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!cn(e))return!1}else{if(dn(e))continue;return!1}}return!0},O=(o,n={},e=!0,t=new WeakMap)=>{if(dn(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]=O(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]=O(o[r],!0,e,t)):typeof a=="object"&&(s[r]=O(o[r],a,e,t)))}return s}return{}}});var ho,Mo=m(()=>{"use strict";ho={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 Ue,Co=m(()=>{"use strict";Fe();b();nn();Ue=class extends N{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 A("dispose")),super.dispose()})}hide(){this.send(new A("hide"))}show(){this.send(new A("show"))}inspect(){return this.send(new A("inspect"))}setHeightBasedOnDocumentElement(){this.send(new A("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new A("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}}});var ye,mn=m(()=>{"use strict";Fe();qe();ye=class extends N{constructor(e,t,s,r,a,p){super(e,s,p);this.container=s;this.customElement=r;this.tagName=a;i(this,"ctaCleanup");i(this,"_ctaHandler");i(this,"_ctaQueue",[]);i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});i(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=r,this.setInitiated()}inspect(){return this.cleanupInspect=ve(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this.ctaCleanup&&this.ctaCleanup(),this._ctaHandler=e,this._ctaQueue.length>0){let s=[...this._ctaQueue];this._ctaQueue=[],s.forEach(r=>{this.markedForDisposed||e(r.action,r.payload)})}let t=s=>{var a;let r=s;(a=r.detail)!=null&&a.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(r.detail.action,r.detail.payload):this._ctaHandler||this._ctaQueue.push({action:r.detail.action,payload:r.detail.payload}))};this.customElement.addEventListener("myop-cta",t),this.ctaCleanup=()=>{this.customElement.removeEventListener("myop-cta",t)}}}});var ai,ve,Io,xo,bo,pi,ln,fn,qe=m(()=>{"use strict";b();b();w();ge();Mo();Co();mn();ai=(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},ve=(o,n,e,t,s,r)=>{let a=ai("".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)}},Io=(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),xo=(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."))},bo=(o,n,e)=>{let t=n.reduce((r,a)=>V(M({},r),{[a.name]:M({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(Io(p,a,o))return!1;if(p.behavior.type===Te.code){if(o instanceof ye)return(p.behavior.remap||a)==="myop_init_interface"?f=>{if(f===void 0)return o.getData();o.initWithData(f)}:void 0;if(e.loader.type===Y.HTMLLoader&&e.loader.shadowRootMode===fe.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return xo(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(J.create(p.behavior.ref)),c.push(g=>{d(g)}),p.behavior.params&&c.push(...p.behavior.params);let f=xe[p.behavior.message];o.send(new f(...c))}):null},set:(r,a,p)=>{let d=t[a];if(Io(d,a,o))return!1;if(d.behavior.type===Te.code){if(o instanceof ye){let f=d.behavior.remap||a;if(f==="myop_cta_handler")return o.setCtaHandler(p),!0;if(f==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===Y.HTMLLoader&&e.loader.shadowRootMode===fe.localFrame){let f=d.behavior,g=o.element.contentWindow,h=f.remap||a;if(g[h]=p,h==="myop_cta_handler"&&g.__myop_cta_queue){let y=g.__myop_cta_queue;g.__myop_cta_queue=null,y.forEach(l=>{o.markedForDisposed||p(l.action,l.payload)})}return!0}return xo(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(J.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let f=xe[d.behavior.message];return o.send(new f(...c)),!0}else throw new Error("Error: Unsupported Behavior\\n\\nThe 'behavior' field provided is not supported.\\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\\n\\n")+"Prop Name: ".concat(a,"\\n")+"Behavior Field: ".concat(d.behavior.type,"\\n\\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},pi=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{cn(p)||ho.notSerializableRefCall(t,p)}),n.send(new G(({ref:p,propName:d,functionArgs:c,makeSerializable:f})=>{if(p){let g=p[d];return f(typeof g=="function"?p[d](...c):g,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new G(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),ln=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 Ue(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new Le(o.refConfig,n,V(M({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let f=e.find(g=>g.id==p.id);if(f!==p){s.refs[o.refConfig.name]=f,r(f);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(g=>{let h=n.instance.resolvedNestedComponents.find(l=>l.type.id===g.componentDefinitionId).type,y=new Ue(h,p);y.setInitiated(),p.refs[g.refName]=y,e.push(y)});try{await fn(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(g){a(g)}}))})},fn=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(r=>new Promise(async(a,p)=>{var d;if(r.behavior.type==Se.component){if(t){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(h=>h.type.id===c);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let g=J.create("",r,o);try{let h=await ln(g,f,e);o.refs[r.name]=h,a()}catch(h){p(h)}}else try{let c=J.create("",r,o);o.refs[r.name]=pi(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}}});var _e,un=m(()=>{"use strict";Fe();b();qe();C();_e=class extends N{constructor(e,t,s,r,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=r;i(this,"_autoSizeCleanup");i(this,"_autoSizeOptions");i(this,"_autoSizeUpdate");i(this,"sizeMeta");i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new k(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});i(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:t})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));i(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let r=(y,l,$)=>l!==void 0&&y<l?l:$!==void 0&&y>$?$:y,a=y=>{if(y===void 0)return;if(typeof y=="number")return y;let l=parseFloat(y);return isNaN(l)?void 0:l},p=()=>{var kn,Dn,Bn,Ln,Pn,On,An,Kn;let y=t.contentDocument;if(!y)return;let l=this._autoSizeOptions,$=a(l==null?void 0:l.minWidth),ke=a(l==null?void 0:l.maxWidth),ne=a(l==null?void 0:l.minHeight),Q=a(l==null?void 0:l.maxHeight),B=(kn=l==null?void 0:l.loaderMinHeight)!=null?kn:50,P=((Dn=this.sizeMeta)==null?void 0:Dn.width)==="100%"?"100%":void 0,De=((Bn=this.sizeMeta)==null?void 0:Bn.height)==="100%"?"100%":void 0,W=(Pn=(Ln=l==null?void 0:l.explicitWidth)!=null?Ln:P)!=null?Pn:"100%",oe=(On=l==null?void 0:l.explicitHeight)!=null?On:De,wn=W!==void 0,Sn=oe!==void 0,Kt=this.container.getBoundingClientRect(),Ws=Kt.width===0,Fs=Kt.height===0||Kt.height===B,he=(l!=null&&l.forceAutoSize||Ws)&&!wn,Me=(l!=null&&l.forceAutoSize||Fs)&&!Sn;if(!he&&!Me){t.style.width=typeof W=="number"?"".concat(W,"px"):"100%",t.style.height=typeof oe=="number"?"".concat(oe,"px"):"100%";let Ge=typeof W=="number"?W:void 0,je=typeof oe=="number"?oe:void 0;(Ge!==void 0||je!==void 0)&&((An=l==null?void 0:l.onSizeChange)==null||An.call(l,{width:Ge,height:je,autoSizingWidth:!1,autoSizingHeight:!1}));return}let Ns=t.style.transition,q=this.container,Us=q.style.transition;t.style.transition="none",q.style.transition="none";let En=t.getBoundingClientRect().height,Tn=t.getBoundingClientRect().width,vn=Math.ceil(Math.max(y.documentElement.scrollHeight,y.body.scrollHeight)),_n=Math.ceil(Math.max(y.documentElement.scrollWidth,y.body.scrollWidth)),zt=_n,$t=vn,qs=Me&&vn>En+1,Vs=he&&_n>Tn+1,Wt=Me&&!qs,Ft=he&&!Vs;if(Wt||Ft){let Ge=q.style.minHeight,je=q.style.minWidth;Wt&&(q.style.minHeight="".concat(En,"px")),Ft&&(q.style.minWidth="".concat(Tn,"px")),Wt&&(t.style.height="0px"),Ft&&(t.style.width="0px"),zt=Math.ceil(Math.max(y.documentElement.scrollWidth,y.body.scrollWidth)),$t=Math.ceil(Math.max(y.documentElement.scrollHeight,y.body.scrollHeight)),q.style.minHeight=Ge,q.style.minWidth=je}let Rn=r(zt,$,ke),Hn=r($t,ne,Q);he?t.style.width="".concat(Rn,"px"):t.style.width=typeof W=="number"?"".concat(W,"px"):"100%",Me?t.style.height="".concat(Hn,"px"):t.style.height=typeof oe=="number"?"".concat(oe,"px"):"100%",t.offsetHeight,t.style.transition=Ns,q.style.transition=Us;let Gs=he&&ke!==void 0&&zt>ke,js=Me&&Q!==void 0&&$t>Q;y.documentElement.style.overflowX=Gs?"auto":"",y.documentElement.style.overflowY=js?"auto":"",(Kn=l==null?void 0:l.onSizeChange)==null||Kn.call(l,{width:Rn,height:Hn,autoSizingWidth:he,autoSizingHeight:Me})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},f=new ResizeObserver(()=>c());f.observe(s.body),f.observe(s.documentElement);let g=new MutationObserver(()=>c());g.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let h=()=>{f.disconnect(),g.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=h,h});i(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new k(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new k(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});i(this,"send",e=>{var r,a;let t=M({},e);if(t.messageType===u.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=v.down;let s=super.send(t);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(t,"*"),s});i(this,"dispose",()=>{this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=ve(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===u.In.MutationObserverMessage||e.messageType===u.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}}});var X,nt=m(()=>{"use strict";X=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 di,ot,wo=m(()=>{"use strict";un();nt();re();w();di=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},ot=class extends X{constructor(){super(...arguments);i(this,"type",Y.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=E(),c="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=c;let f="\\n padding: 0;\\n margin: 0;\\n position: absolute;\\n inset: 0;\\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\\n width: 100%;\\n overflow: hidden;\\n border: none;\\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\\n ");a.style.cssText=f,r!=null&&r.elementAttributes&&Object.entries(r.elementAttributes).forEach(([h,y])=>{y===""||y===null||y===void 0?a.setAttribute(h,""):a.setAttribute(h,String(y))});let g=t.loader.url;r!=null&&r._hasParent&&(g=di(g,"_myop-comp",d)),a.src=g,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,r)}return new _e(e,t,s,a,r)})}}});var st,gn=m(()=>{"use strict";st={webcomponent_message_key:"myop_webcomponent_message"}});var Re,yn=m(()=>{"use strict";gn();Fe();qe();Re=class extends N{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(st.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=ve(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 hn,it,So=m(()=>{"use strict";yn();nt();re();w();hn={},it=class extends X{constructor(){super(...arguments);i(this,"type",Y.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;hn[a.url]?console.log("Module alreday loaded or in loading process"):hn[a.url]=new Promise((c,f)=>{let g=a.url,h=document.createElement("script");h.type="module",h.src=g,h.onload=()=>{c()},h.onerror=()=>{f()},document.head.appendChild(h)}),await hn[a.url],await Fn(1);let p="myop-comp-".concat(E()),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 Re(e,t,s,d,r)})}}});var T,U=m(()=>{"use strict";w();T=class extends et{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(V(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 D,Z=m(()=>{"use strict";D={id:"myop-id"}});var S,Eo,L=m(()=>{"use strict";Z();S=(o,n)=>n.querySelectorAll("[".concat(D.id,"='").concat(o.refConfig.selector,"']")),Eo=(o,n)=>{let e=S(o,n);return e.length?e.item(0):null}});var rt,To=m(()=>{"use strict";C();b();U();L();rt=class extends T{constructor(){super(...arguments);i(this,"messageType",u.BindClickMessage);i(this,"innerExecutor",(e,t,s)=>{let r=S(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new ae(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}}});var at,vo=m(()=>{"use strict";C();U();L();at=class extends T{constructor(){super(...arguments);i(this,"messageType",u.ChangeTextMessage);i(this,"innerExecutor",(e,t)=>{S(e.ref,t.shadowRoot).forEach(r=>{r.textContent=e.content})})}}});var pt,_o=m(()=>{"use strict";w();pt=class extends Ee{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}}});var dt,Ro=m(()=>{"use strict";w();Z();U();b();C();dt=class extends T{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(D.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(D.id);p&&r.push(new be(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new le(e.handlerUniqueId,r))});i(this,"messageType",u.DetectMyopRefsMessage)}}});var ct,Ho=m(()=>{"use strict";C();U();L();ct=class extends T{constructor(){super(...arguments);i(this,"messageType",u.SetAttributeMessage);i(this,"innerExecutor",(e,t)=>{S(e.ref,t.shadowRoot).forEach(r=>{r.setAttribute(e.name,e.value)})})}}});var mt,ko=m(()=>{"use strict";C();b();U();L();ge();mt=class extends T{constructor(){super(...arguments);i(this,"messageType",u.AddEventListenerMessage);i(this,"innerExecutor",(e,t,s)=>{let r=S(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=c=>{s(new de(e.handlerUniqueId,O(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}}});var lt,Do=m(()=>{"use strict";C();Z();Ne();Ze();U();lt=class extends T{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(D.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=z.Instance(),d=p.components.find(h=>h.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),g=[];Object.keys(f.refs).forEach(h=>{let y=f.refs[h];y=y.__nonProxied||y,y.componentDefinition&&g.push({refName:h,componentDefinitionId:y.componentDefinition.id})}),s(new j(e.handlerUniqueId,g))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new j(e.handlerUniqueId,[],!0));debugger}})().then()})}}});var ft,Mn=m(()=>{"use strict";ge();ft=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=O,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)}});var ut,Bo=m(()=>{"use strict";C();b();U();Mn();ut=class extends T{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{ft(e,a=>{s(new pe(e.handlerUniqueId,a))},t)})}}});var Lo,gt,Po=m(()=>{"use strict";C();b();U();L();Z();ge();Lo=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(D.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Lo(r),required:r.required,validity:O(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},gt=class extends T{constructor(){super(...arguments);i(this,"messageType",u.GetElementValueMessage);i(this,"innerExecutor",(e,t,s)=>{S(e.ref,t.shadowRoot).forEach(a=>{s(new ce(Lo(a)),e)})})}}});var yt,Oo=m(()=>{"use strict";C();U();L();yt=class extends T{constructor(){super(...arguments);i(this,"messageType",u.SetInnerHtml);i(this,"innerExecutor",(e,t)=>{S(e.ref,t.shadowRoot).forEach(r=>{r.innerHTML=e.content})})}}});var Ao={};se(Ao,{WebComponentSDK:()=>He});var He,Cn=m(()=>{"use strict";w();C();gn();To();vo();_o();Ro();ie();b();Ho();ko();Do();Bo();Po();Oo();He=class extends we{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(st.webcomponent_message_key,s=>{let r=s.data?s.data:s.detail;if(!r||!r.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=r;if(this.handleIncomeMessages(s),a.messageType===u.InitMessage){let p=a.content.id;this.components[p].context=new pt(e,t)}}}),setTimeout(()=>{this.messageToHost(new me)},1)});i(this,"messageToHost",(e,t)=>{e.direction=v.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new at(this.messageToHost,this.components),new yt(this.messageToHost,this.components),new rt(this.messageToHost,this.components),new dt(this.messageToHost,this.components),new ct(this.messageToHost,this.components),new mt(this.messageToHost,this.components),new ut(this.messageToHost,this.components),new gt(this.messageToHost,this.components),new lt(this.messageToHost,this.components)]);i(this,"init",()=>{})}};F("WebComponentSDK",He)});var Ko=m(()=>{"use strict";Cn()});var zo,$o=m(()=>{"use strict";zo=""});function li(o,n){return class extends HTMLElement{connectedCallback(){let e=n===fe.open?"open":"closed",t=this.attachShadow({mode:e});Uo().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var ci,mi,Fo,No,ht,Uo,fi,ui,gi,Mt,qo=m(()=>{"use strict";yn();mn();nt();re();w();Ko();un();$o();ci="<!-- myop-web-component -->",mi="myop-web-component",Fo=new Set,No=[],Uo=async()=>(ht||(ht=new He,ht.init()),ht);fi=(o,n,e)=>{customElements.define(o,li(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},ui=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\\d+)/g,"-$1").toLowerCase(),gi=o=>(o=ui(o),o.replace(/_/g,"-")),Mt=class extends X{constructor(){super(...arguments);i(this,"type",Y.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(E()),d;if(a.shadowRootMode===fe.localFrame){let c=E(),f="myop-comp-".concat(c),g=document.createElement("iframe");g.id=f,g.style.cssText="\\n display: block;\\n padding: 0;\\n margin: 0;\\n position: absolute;\\n inset: 0;\\n overflow: hidden;\\n border: none;\\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\\n width: 100%;\\n height: 100%;\\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),g=this.appendChild(s,g,r);let h=g.contentDocument||g.contentWindow.document;h.open();let y=null;{let P=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(P)try{y=JSON.parse(P.getAttribute("content")||"{}")}catch(De){}}let l=a.HTML;if(r!=null&&r._inspection){let B=new DOMParser().parseFromString(a.HTML,"text/html"),P=B.getElementById("myop_preview");P==null||P.removeAttribute("type");let De=B.implementation.createHTMLDocument();De.body.innerHTML="<script>\\n const beforeKeysWindow = new Set(Object.keys(window));\\n window.myopState = {\\n beforeKeysWindow,\\n };\\n <\\/script>";let W=De.body.firstChild;W&&B.head&&B.head.insertBefore(B.importNode(W,!0),B.head.firstChild),l=B.documentElement.outerHTML}else if((r==null?void 0:r.data)!==void 0){let B=new DOMParser().parseFromString(a.HTML,"text/html"),P=B.getElementById("myop_preview");P&&(P.remove(),l=B.documentElement.outerHTML)}h.writeln(l);let $='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\\/script>'),ke="<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(h.writeln("".concat($).concat(ke)),(r==null?void 0:r.data)!==void 0){let Q="<script>\\n window.__myop_cta_queue = [];\\n window.myop_cta_handler = function(action, payload) {\\n window.__myop_cta_queue.push({action: action, payload: payload});\\n };\\n <\\/script>",B=JSON.stringify(r.data).replace(/<\\/script/gi,"\\\\u003c/script"),P='<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>");h.writeln(Q+P)}h.close();let ne=new _e(e,t,s,g,r);return ne.sizeMeta=y,ne.initiated().then(()=>{ne.observeAutoSize({forceAutoSize:!0}),r!=null&&r.hidden||ne.show()}),ne}if(a.shadowRootMode===fe.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Uo().then(f=>{f.connectedCallback(d,d)})}else{let c=gi(e.name+t.id);No.includes(c)||(fi(c,a.HTML,a.shadowRootMode),No.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 Re(e,t,s,d,r)})}isMyopWebComponent(e){return e.trimStart().startsWith(ci)}extractWebComponentScript(e){let r=new DOMParser().parseFromString(e,"text/html").getElementById(mi);return(r==null?void 0:r.textContent)||null}executeWebComponentScript(e,t){if(Fo.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),Fo.add(t),console.log("[MyopWebComponent] Executed web component script: ".concat(t))}async loadExtractedWebComponent(e,t,s,r,a){let p=this.extractWebComponentScript(r);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),c=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(p,d);let f=window.__MYOP_TAG_NAME__;if(!f)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");c&&c!==f&&console.warn("[MyopWebComponent] __MYOP_TAG_NAME__ changed from ".concat(c," to ").concat(f));let g="myop-comp-".concat(E()),h=document.createElement(f);h.id=g,a!=null&&a.hidden&&(h.style.opacity="0",h.style.position="absolute",h.style.height="0",h.style.width="0",h.style.pointerEvents="none",h.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,h,a);let y=new ye(e,t,s,h,f,a);return(a==null?void 0:a.data)!==void 0&&y.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(f,"> into container")),y}}});var Vo,Go,jo=m(()=>{"use strict";re();b();Vo=(o,n,e)=>{let t="myop-css-".concat(E());return o.send(new k(({rootRef:s,_stylesheet:r,_tagId:a,_css:p})=>{let d=document.createElement("style");d.type="text/css";let c=p;for(let f in r){c+="".concat(f," { ");let g=r[f];for(let h in g)c+="".concat(h,": ").concat(g[h],"; ");c+="} "}d.appendChild(document.createTextNode(c)),d.id=a,(s.shadowRoot||s.container).appendChild(d)},()=>{},{_stylesheet:n,_css:e||"",_tagId:t})),()=>{o.send(new k(({rootRef:s,_tagId:r})=>{let a=(s.shadowRoot||document).getElementById(r);a&&a.remove()},()=>{},{_tagId:t}))}},Go=(o,n)=>{let e="myop-css-".concat(E());return o.send(new k(({rootRef:t,_tagId:s,_link:r})=>{let a=document.createElement("link");a.id=s,a.rel="stylesheet",a.href=r,document.head.appendChild(a),(t.shadowRoot||t.container).appendChild(a)},()=>{},{_link:n,_tagId:e})),()=>{o.send(new k(({rootRef:t,_tagId:s})=>{let r=(t.shadowRoot||document).getElementById(s);r&&r.remove()},()=>{},{_tagId:e}))}}});var yi,In,Yo,Qo=m(()=>{"use strict";yi=(o,n)=>{let e=new RegExp(Object.keys(n).join("|"),"g");return o.replace(e,t=>(n[t]||t).toString())},In=(o,n)=>{let e=o.loader;if(e.type!=="IframeLoader")throw new Error('iframeSkinUrlTokenizer received skin with loader type "'.concat(e.type,'", currently only "IframeLoader" is supported'));return o.loader=M({},o.loader),o.loader.url=yi(o.loader.url,n),o},Yo=o=>async n=>In(n,o)});var Jo,Xo,Zo=m(()=>{"use strict";b();Jo=(o,n,e)=>{o.send(new G(({ref:t,_className:s})=>{t==null||t.classList.add(s)},{elementId:e,_className:n}))},Xo=(o,n,e)=>{o.send(new G(({ref:t,_className:s})=>{t==null||t.classList.remove(s)},{elementId:e,_className:n}))}});var xt,Ct,bt,It,es=m(()=>{"use strict";re();xt=class xt{constructor(){i(this,"_runTimeInstanceId","runtime-instance-id-"+E());i(this,"_runTimeId","runtime-id-"+E());i(this,"_runTimeName","runtime-name-"+E());i(this,"id",this._runTimeId);i(this,"name",this._runTimeName);i(this,"description","");i(this,"loader",null);i(this,"withLoader",n=>(this.loader=n,this));i(this,"withHTMLLoader",n=>(n.type="HTMLLoader",this.loader=n,this));i(this,"build",()=>this)}};i(xt,"create",()=>new xt);Ct=xt,bt=class bt{constructor(){i(this,"_runTimeInstanceId","runtime-instance-id-"+E());i(this,"_runTimeId","runtime-id-"+E());i(this,"_runTimeName","runtime-name-"+E());i(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null});i(this,"name",this._runTimeName);i(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0});i(this,"withInstance",n=>(this.instance=n,this));i(this,"withType",n=>(this.type=n,this));i(this,"withName",n=>(this.name=n,this));i(this,"withDefaultSkin",n=>(this.type.skins.push(n),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:n.id}},this));i(this,"withRef",n=>(this.type.refs.push(n),this));i(this,"withBasicRef",n=>{let e={id:"",name:n,description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}};return this.type.refs.push(e),this});i(this,"build",()=>JSON.parse(JSON.stringify(this)))}};i(bt,"create",()=>new bt);It=bt});var hi,wt,Mi,Ci,ee,K,ts,xn=m(()=>{"use strict";w();hi=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:Te.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:Te.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),wt="__MYOP_CLOUD_REPOSITORY_MAIN__",Mi=()=>{if(typeof window<"u")return window[wt];if(typeof globalThis<"u")return globalThis[wt]},Ci=o=>{typeof window<"u"&&(window[wt]=o),typeof globalThis<"u"&&(globalThis[wt]=o)},ee=class ee{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"variants",{});i(this,"preloadedComponents",{});i(this,"userFlows",{});i(this,"_defaultEnv","production");i(this,"_envExplicitlySet",!1)}static get Main(){let n=Mi();return n||(ee._main||(ee._main=new ee,Ci(ee._main)),ee._main)}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let s=this.preloadedComponents[n],r=e!==void 0||t!==void 0,a,p;if(!r&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let c=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!c}let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(c,f)=>{try{let g="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(g+="&preview=true");let l=(await(await fetch(g)).json()).item;if(!l){f(new Error('Component "'.concat(n,'" not found')));return}if(!l.consume_variant||!l.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let $=hi(l);c($)}catch(g){f(g)}})),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(ee,"_main",null);K=ee,ts=K});var ns,os=m(()=>{"use strict";ns=async o=>await o()});var te,ss,is,rs,as,ps,ds,cs,ms,ls=m(()=>{"use strict";xn();te=K.Main,ss=()=>te,is=(o,n,e)=>te.isPreloaded(o,n,e),rs=o=>te.getPreloadedParams(o),as=()=>{te=new K("http://localhost:9292")},ps=o=>{te=new K(o)},ds=o=>{te=o},cs=o=>{te.setEnvironment(o)},ms=async(o,n,e)=>Promise.allSettled(o.map(t=>te.fetchComponentV2(t,n,e)))});var bn={};se(bn,{CloudRepository:()=>K,ComponentConfig:()=>It,SkinConfig:()=>Ct,addClass:()=>Jo,applyStylesheet:()=>Vo,applyStylesheetLink:()=>Go,changeSkinUrlByTokenizer:()=>Yo,createIframeSkinByTokenizer:()=>In,enableLocalDev:()=>as,exec:()=>ns,getCloudRepository:()=>ss,getPreloadedParams:()=>rs,isPreloaded:()=>is,preloadComponents:()=>ms,removeClass:()=>Xo,setCloudRepository:()=>ds,setCloudRepositoryUrl:()=>ps,setEnvironment:()=>cs,v2_CloudRepository:()=>ts});var St=m(()=>{"use strict";jo();Qo();Zo();es();xn();os();ls()});var fs,us=m(()=>{"use strict";Vt();St();w();fs=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=qt(t);switch(s){case"component":{let[a,p]=r,d=await K.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:ue.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=qt(t),c=(await K.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(c&&c.instance.skinSelector.type===ue.Segmented&&c.instance.resolvedExperiences){let f=c.instance.resolvedExperiences.find(g=>g.id===p);if((f==null?void 0:f.type)===tt.Segment){let g=f,y=c.instance.skinSelector.segments.find(l=>l.segmentId===g.segment.id);if(y)return c.instance.skinSelector=y==null?void 0:y.skinSelector,c}}}break}}}finally{return null}}});var hs={};se(hs,{HostSDK:()=>z,hostSDK:()=>ys});var gs,z,ys,Ne=m(()=>{"use strict";ie();C();b();wo();So();qe();w();Xe();qo();us();gs="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",z=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",Ce);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!==v.up&&n.data.messageType!==u.EnvelopedMessage)return;let e=n.data;if(e.messageType===u.InitRequest){this.components2init.forEach(s=>{s.send(new Ie(s.id))});return}if(e.messageType===u.InitResponse){this.components2init=this.components2init.filter(r=>r.id!==e.content.id);let s=this.components.find(r=>{var a;return r.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===u.EnvelopedMessage){let s=e,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===v.down){s.message.messageType===A.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 ot,new it,new Mt];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 ue.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case ue.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(y=>y.type===tt.Segment?y.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let g=c.segment,h=(t||{})[g.function];return h?await h():(console.warn("segmentId:".concat(d.segmentId,", ").concat(g.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});i(this,"loaderHooks");i(this,"loadComponent",async(n,e,t)=>{var f,g,h,y;if(!e){debugger;throw new Error("no container was found for this component")}let s=await fs(n);s&&(n=s);let r=M(M({},(f=this.loaderHooks)!=null?f:{}),(g=t==null?void 0:t.hooks)!=null?g:{}),a=e;if(a.myop)if(a.component){n=M({},n),n.instance=M({},n.instance);let l=await this.runSkinSelector(n,r);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(h=t==null?void 0:t.hooks)!=null&&h.afterSkinSelected&&(l=await t.hooks.afterSkinSelected(M({},l))),n.instance.skinSelector={type:ue.Dedicated,skin:l},t&&(t=M({},t),delete t.hooks),await ln(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");(y=t==null?void 0:t.hooks)!=null&&y.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(M({},p)));let d=this.componentsLoaders.find(l=>l.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=bo(c,n.type.props,p));try{await fn(c,n,this.components)}catch(l){throw l}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(z,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:gs});if(!window.myop.hostSDK){let o=new z;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:gs}),window.myop.hostSDK=o}ys=window.myop.hostSDK;F("hostSDK",ys)});var Et,Ms=m(()=>{"use strict";C();Z();w();b();Et=class extends x{constructor(){super(...arguments);i(this,"messageType",u.DetectMyopRefsMessage);i(this,"executor",e=>{let t=document.querySelectorAll("[".concat(D.id,"]")),s=[];t.forEach(r=>{let a=r.getAttribute(D.id);a&&s.push(new be(a,r.tagName,r.getBoundingClientRect()))}),this.messageToHost(new le(e.handlerUniqueId,s))})}}});var Tt,Cs=m(()=>{"use strict";C();w();b();L();Tt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.BindClickMessage);i(this,"executor",e=>{let t=[];return S(e.ref,document).forEach(r=>{let a=()=>{this.messageToHost(new ae,e)};r.addEventListener("click",a);let p=()=>{r.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(r=>r())}})}}});var vt,Is=m(()=>{"use strict";C();w();L();vt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.ChangeTextMessage);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{s.textContent=e.content})})}}});var _t,xs=m(()=>{"use strict";C();b();w();Mn();_t=class extends x{constructor(){super(...arguments);i(this,"messageType",u.ExecuteScriptMessage);i(this,"executor",e=>{ft(e,s=>{this.messageToHost(new pe(e.handlerUniqueId,s))},new Ee(document.documentElement))})}}});var Rt,bs=m(()=>{"use strict";C();w();b();ge();L();Rt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.AddEventListenerMessage);i(this,"executor",e=>{let t=S(e.ref,document),s=[];return t.forEach(r=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new de(e.handlerUniqueId,O(p,e.serializableSkeleton)))})};r.addEventListener(e.type,a),s.push(()=>{r.removeEventListener(e.type,a)})}),()=>{s.forEach(r=>{r()})}})}}});var Ht,ws=m(()=>{"use strict";C();w();L();Ht=class extends x{constructor(){super(...arguments);i(this,"messageType",u.SetAttributeMessage);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{s.setAttribute(e.name,e.value)})})}}});var kt,Ss=m(()=>{"use strict";C();Z();w();Ne();Ze();kt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.CreateRefComponentMessage);i(this,"executor",e=>{(async()=>{let s=document.querySelectorAll("[".concat(D.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await z.Instance().loadComponent(e.nestedComponentConfig,s.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new j(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new j(e.handlerUniqueId,[],!0));debugger}})().then()})}}});var Es,Ts=m(()=>{"use strict";Es=(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 Dt,vs=m(()=>{"use strict";C();b();w();Ts();Dt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.SetMutationObserverMessage);i(this,"executor",e=>{e.source&&Es(document.body,()=>{this.messageToHost(new Ae)})})}}});var _s,Bt,Rs=m(()=>{"use strict";C();Z();w();b();ge();L();_s=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(D.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:_s(r),required:r.required,validity:O(r.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Bt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.GetElementValueMessage);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{this.messageToHost(new ce(_s(s)),e)})})}}});var Lt,Hs=m(()=>{"use strict";C();w();b();L();Lt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.GetAttributeMessage);i(this,"executor",e=>{let t=Eo(e.ref,document);t&&this.messageToHost(new Oe(t.getAttribute(e.name)),e)})}}});var Pt,ks=m(()=>{"use strict";b();C();w();Pt=class extends x{constructor(){super(...arguments);i(this,"messageType",u.SetResizeObserverMessage);i(this,"executor",e=>{let t=new ResizeObserver(s=>{this.messageToHost(new We)});return t.observe(document.body),()=>{t.disconnect()}})}}});var Ot,Ds=m(()=>{"use strict";C();w();L();Ot=class extends x{constructor(){super(...arguments);i(this,"messageType",u.SetInnerHtml);i(this,"executor",e=>{S(e.ref,document).forEach(s=>{s.innerHTML=e.content})})}}});var Bs={};se(Bs,{IframeSDK:()=>At});var At,Ls=m(()=>{"use strict";w();Ms();Cs();Is();xs();ie();bs();ws();b();Ss();vs();Rs();Xe();Hs();ks();Ds();At=class extends we{constructor(){super();i(this,"version",Ce);i(this,"messageToHost",(e,t)=>{var r;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let s=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=s[0]),e.source||(e.source=s[0]),e.direction=v.up,(r=window.parent)==null||r.postMessage(M({},e),"*")});i(this,"supportedHandlers",[new vt(this.messageToHost),new Ot(this.messageToHost),new Tt(this.messageToHost),new Et(this.messageToHost),new _t(this.messageToHost),new Rt(this.messageToHost),new Ht(this.messageToHost),new Bt(this.messageToHost),new Dt(this.messageToHost),new Pt(this.messageToHost),new Lt(this.messageToHost),new kt(this.messageToHost)]);i(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new me)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};F("IframeSDK",At)});var xi={};var Ii,Ps=m(()=>{"use strict";b();ie();Ii=M({},xe);F("MyopMessages",Ii)});var Os={};se(Os,{CloudRepository:()=>K,ComponentConfig:()=>It,SkinConfig:()=>Ct,addClass:()=>Jo,applyStylesheet:()=>Vo,applyStylesheetLink:()=>Go,changeSkinUrlByTokenizer:()=>Yo,createIframeSkinByTokenizer:()=>In,enableLocalDev:()=>as,exec:()=>ns,getCloudRepository:()=>ss,getPreloadedParams:()=>rs,isPreloaded:()=>is,preloadComponents:()=>ms,removeClass:()=>Xo,setCloudRepository:()=>ds,setCloudRepositoryUrl:()=>ps,setEnvironment:()=>cs,v2_CloudRepository:()=>ts});var As=m(()=>{"use strict";ie();St();St();F("MyopHelpers",bn)});var Ti={};se(Ti,{getHostModule:()=>Ks,getIframeModule:()=>zs,getWebcomponentModule:()=>$s});ie();var Wn;if(window.__federation__)console.log("__federation__ loaded more than once.");else{let o=(Wn=document.currentScript)==null?void 0:Wn.src,n=o?o.split("/").slice(0,-1).join("/"):"";window.__federation__={__public_auto_path__:n,__use_public_auto_path__:!0,__public_path__:void 0,__loading_timeout__:5*1e3}}window.__federation__.load__federation__=(o,n,e)=>{if(window.__federation__[n])console.log("__federation__ module ".concat(n," already loaded.")),e(window.__federation__[n][Ut]);else{let t;window.__federation__[n]={},window.__federation__[n][Je]=s=>{t&&(document.head.removeChild(t),t=null),window.__federation__[n][Ut]=s,e(s)},t=document.createElement("script"),t.type="module",t.src=o,t.async=!0,document.head.appendChild(t)}};Xe();console.log("myop root sdk - loaded",document.location.origin);var bi="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",Ks=()=>Promise.resolve().then(()=>(Ne(),hs)),zs=()=>Promise.resolve().then(()=>(Ls(),Bs)),$s=()=>Promise.resolve().then(()=>(Cn(),Ao)),wi=()=>Promise.resolve().then(()=>(Ps(),xi)),Si=()=>Promise.resolve().then(()=>(As(),Os)),Ve=o=>async()=>(await o()).get(),Ei={version:Ce,getHostModule:Ve(Ks),getIframeModule:Ve(zs),getWebcomponentModule:Ve($s),getMyopMessages:Ve(wi),getMyopHelpers:Ve(Si)};window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:bi});window.myop.rootSDK?console.log("myop root host loaded more than once."):window.myop=M({rootSDK:Ei},window.myop);return ti(Ti);})();
|
|
2
|
+
`;var Qe=Object.defineProperty,tn=Object.defineProperties,nn=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable,Pe=(e,t,n)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))sn.call(t,n)&&Pe(e,n,t[n]);if(Xe)for(var n of Xe(t))on.call(t,n)&&Pe(e,n,t[n]);return e},le=(e,t)=>tn(e,nn(t)),rn=(e,t)=>{for(var n in t)Qe(e,n,{get:t[n],enumerable:!0})},r=(e,t,n)=>Pe(e,typeof t!="symbol"?t+"":t,n),v=(e,t,n)=>new Promise((s,i)=>{var a=c=>{try{l(n.next(c))}catch(d){i(d)}},o=c=>{try{l(n.throw(c))}catch(d){i(d)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,o);l((n=n.apply(e,t)).next())}),ve="__federation__",Ze="onLoad",et=(e,t)=>{window[ve]&&window[ve][e]&&window[ve][e][Ze]&&window[ve][e][Ze]({[e]:t})},b={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",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",CleanupMessage:"CleanupMessage",In:{MutationObserverMessage:"MutationObserverMessage",ResizeObserverMessage:"ResizeObserverMessage"}},Ae={};rn(Ae,{AddEventListenerMessage:()=>fn,BaseMyopMessage:()=>H,BindClickMessage:()=>un,ChangeTextMessage:()=>hn,CleanupMessage:()=>_t,CleanupReplayMessage:()=>Mt,ClickReplayMessage:()=>st,CreateRefComponentMessage:()=>mt,CustomRefMessage:()=>ze,DetectMyopRefsMessage:()=>wn,DetectedMyopRefsMessage:()=>gt,DisposeMessage:()=>bt,ElementValueReplayMessage:()=>dt,EnvelopedMessage:()=>ft,EventListenerCallbackMessage:()=>lt,ExecuteComponentMethod:()=>j,ExecuteScriptMessage:()=>q,ExecuteScriptReplyMessage:()=>rt,GetAttributeMessage:()=>_n,GetAttributeReplayMessage:()=>Mn,GetElementValueMessage:()=>gn,InitMessage:()=>Fe,InitRequest:()=>ht,InitResponse:()=>ut,MessageDirection:()=>A,MutationObserverMessage:()=>En,MyopBindMessage:()=>B,MyopBindReplayMessage:()=>F,MyopElementMessage:()=>dn,Ref:()=>ce,RefComponentCreatedMessage:()=>Be,ResizeObserverMessage:()=>Sn,SetAttributeMessage:()=>yn,SetInnerHtml:()=>vn,SetMutationObserverMessage:()=>bn,SetResizeObserverMessage:()=>Cn,stripFunction:()=>ot});var J=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),an=e=>{const t=[...e].map(n=>n.toString(16).padStart(2,"0")).join("");return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20)].join("-")},ln=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";const n=atob(t);return Uint8Array.from(n,s=>s.charCodeAt(0))},tt=e=>{const t=ln(e);if(t.length%16!==0)throw new Error("Invalid input length");const n=[];for(let s=0;s<t.length;s+=16)n.push(an(t.slice(s,s+16)));return n},cn=e=>new Promise(t=>setTimeout(t,e)),A=class{};r(A,"down","down"),r(A,"up","up");var H=class{constructor(){r(this,"id",J()),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(...t){return new this(...t)}isTypeof(t){return t.messageType===this.messageType}},dn=class extends H{constructor(e){super(),this.ref=e}},F=class extends H{constructor(e){super(),this.replayToHandler=e}},B=class extends H{constructor(t){super(),this.handler=t,r(this,"handlerUniqueId",J())}},ce=class Zt{constructor(t,n){this.refConfig=t,this.component=n,r(this,"myop",!0),r(this,"__nonProxied"),this.__nonProxied=le(T({},this),{component:null})}static create(t,n,s){let i=n;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:t,behavior:{type:"code"}}),new Zt(i,s)}},nt="ClickReplayMessage",un=class extends B{constructor(e,t){super(t),this.ref=e,r(this,"replyMessageKey",nt),r(this,"messageType","BindClickMessage"),r(this,"cleanable",!0)}},st=class extends F{constructor(){super(...arguments),r(this,"messageType",nt)}},hn=class extends H{constructor(e,t){super(),this.ref=e,r(this,"messageType","ChangeTextMessage"),this.content=t}},it="ExecuteScriptReplyMessage",pn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,mn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,ot=e=>{let t=e.match(pn);if(t)return t[1]||t[3];{let n=e.match(mn);if(n)return n[1].trim()}},q=class extends B{constructor(t,n=()=>{},s){super(n),this.scriptInputs=s,r(this,"replyMessageKey",it),r(this,"messageType","ExecuteScriptMessage"),r(this,"script",""),this.script=t.toString(),this.content=t.toString(),this.content=ot(this.content)}};r(q,"replierKey","send"),r(q,"completeStreamKey","completeStream");var rt=class extends F{constructor(e,t){super(e),this.replayToHandler=e,this.content=t,r(this,"messageType",it)}},ze=class extends q{constructor(e,t,n=()=>{}){super(({rootRef:s,elementId:i,_script:a,__scriptInputs:o})=>{const l=(s.shadowRoot||s.container).querySelectorAll(`[myop-id='${i}']`);return l.length?(o.ref=l[0],new Function(`return (${a})(...arguments)`)(o)):null},n),this.scriptInputs=t,this.scriptInputs=le(T({},t),{_script:e.toString()})}},at="EventListenerCallbackMessage",fn=class extends B{constructor(e,t,n){super(n),this.ref=e,this.type=t,this.handler=n,r(this,"replyMessageKey",at),r(this,"messageType","AddEventListenerMessage"),r(this,"cleanable",!0),r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},lt=class extends F{constructor(e,t){super(e),this.replayToHandler=e,this.e=t,r(this,"messageType",at),this.content={e:t}}},yn=class extends H{constructor(e,t,n){super(),this.ref=e,this.name=t,this.value=n,r(this,"messageType","SetAttributeMessage")}},ct="ElementValueReplayMessage",gn=class extends B{constructor(e,t){super(t),this.ref=e,r(this,"replyMessageKey",ct),r(this,"messageType","GetElementValueMessage")}},dt=class extends F{constructor(e){super(),this.content=e,r(this,"messageType",ct)}},vn=class extends H{constructor(e,t){super(),this.ref=e,r(this,"messageType","SetInnerHtml"),this.content=t}},Fe=class extends H{constructor(e){super(),r(this,"messageType","InitMessage"),this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ut=class extends Fe{constructor(){super(...arguments),r(this,"messageType","InitResponse")}},ht=class extends H{constructor(){super(...arguments),r(this,"messageType","InitRequest")}},pt="RefComponentCreatedMessage",mt=class extends B{constructor(e,t,n,s){super(s),this.refConfig=e,this.nestedComponentConfig=t,this.options=n,r(this,"replyMessageKey",pt),r(this,"messageType","CreateRefComponentMessage")}},Be=class extends F{constructor(e,t,n){super(e),this.replayToHandler=e,this.nestedRefs=t,this.failed=n,r(this,"messageType",pt)}},ft=class extends H{constructor(e,t){super(),this.destination=e,this.message=t,r(this,"messageType","EnvelopedMessage");const n=t;this.route=[e,...n.route?n.route:[]]}},yt="DetectedMyopRefsMessage",wn=class extends B{constructor(){super(...arguments),r(this,"messageType","DetectMyopRefsMessage"),r(this,"replyMessageKey",yt)}},gt=class extends F{constructor(e,t){super(e),this.replayToHandler=e,r(this,"messageType",yt),this.content=t}isTypeof(e){return e.messageType===this.messageType}},vt="GetAttributeReplayMessage",_n=class extends B{constructor(e,t,n){super(n),this.ref=e,this.name=t,r(this,"replyMessageKey",vt),r(this,"messageType","GetAttributeMessage")}},Mn=class extends F{constructor(e){super(),this.content=e,r(this,"messageType",vt)}},j=class extends H{constructor(e){super(),this.method=e,r(this,"messageType","ExecuteComponentMethod")}},bn=class extends H{constructor(){super(...arguments),r(this,"messageType","SetMutationObserverMessage")}},En=class extends H{constructor(){super(...arguments),r(this,"messageType","MutationObserverMessage")}},wt="CleanupReplayMessage",_t=class extends B{constructor(e,t){super(t),this.cleanupForMessageId=e,r(this,"replyMessageKey",wt),r(this,"messageType","CleanupMessage")}},Mt=class extends F{constructor(e){super(),this.customCleanup=e,r(this,"messageType",wt)}},bt=class extends H{constructor(){super(...arguments),r(this,"messageType","DisposeMessage")}},Cn=class extends H{constructor(){super(...arguments),r(this,"cleanable",!0),r(this,"messageType","SetResizeObserverMessage")}},Sn=class extends H{constructor(){super(...arguments),r(this,"messageType","ResizeObserverMessage")}},we=class{constructor(e,t,n){this.componentDefinition=e,this.container=t,r(this,"id",""),r(this,"messageHandlers",{}),r(this,"element"),r(this,"_markedForDisposed",!1),r(this,"bind",(i,a)=>{this.messageHandlers[i]||(this.messageHandlers[i]=[]),this.messageHandlers[i].includes(a)||this.messageHandlers[i].push(a)}),r(this,"bindWhen",(i,a,o)=>{if(!o)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[i]||(this.messageHandlers[i]=[]);const l=this.messageHandlers[i],c=d=>a(d)?(o(d),!0):!1;return l.push(c),()=>{const d=l.indexOf(c);d>-1&&l.splice(d,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((i,a)=>{this._whenInitiatedResolve=i,this._whenInitiatedReject=a})),r(this,"initiated",()=>this._whenInitiated),r(this,"props",{}),r(this,"refs",{}),this.id=(n==null?void 0:n.id)||Ee.Instance().assignId(e);const s=n!=null&&n.timeout?n==null?void 0:n.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject(`timeout_${s} ${this.id}`)},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(e){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=e}onMessageReceived(e){if(e.messageType===b.ExecuteComponentMethod){const n=e;return this[n.method]?this[n.method](n.content):console.log(`method not found ${n.method} on component`,this),!0}const t=this.messageHandlers[e.messageType];if(t&&t.length){let n=!1;return t.forEach(s=>{n=n||s(e)}),n}return!1}sendCleanupMessage(e){e.source=this.id,e.destination=this.id,e.direction=A.down;const t=this.bindWhen(e.replyMessageKey,s=>s.replayToHandler===e.handlerUniqueId,s=>{e.handler(s),t()}),n=e.handler;delete e.handler,this.send(e),e.handler=n}send(e){e.source||(e.source=this.id),e.destination||(e.destination=this.id),e.direction=A.down;let t;if(e.handler){const n=e;t=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,n.handler),delete e.handler}return e.ref&&(e.ref=e.ref.__nonProxied||e.ref),e.cleanable?()=>{this.sendCleanupMessage(new _t(e.id,n=>{})),t&&t()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new bt);const e=this.messageHandlers.onDispose;e&&e.forEach(t=>{t(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}},xn=class{constructor(e,t,n,s,i){this.myopId=e,this.htmlTagName=t,this.BoundingRect=n,this.offsetTop=s,this.offsetLeft=i,r(this,"type","MyopElementRef")}},Tn=e=>v(void 0,null,function*(){if(typeof e=="function")e();else if(e instanceof Promise){const t=yield e;typeof t=="function"&&t()}}),In=class{constructor(e){this.messageToHost=e}},Hn=class extends In{constructor(e,t){super(e),this.messageToHost=e,this.context=t}},Rn=class{constructor(e,t){this.id=e,this.context=t,r(this,"send",n=>{})}},Dn=class{constructor(){r(this,"messageToHandleAfterInit",[]),r(this,"components",{}),r(this,"alwaysPassEnvelopesToHost",!1),r(this,"messageCleanupCache",{})}handleIncomeMessages(e){const t=e.data?e.data:e.detail;if(!(!t||!t.myop)){let n=t;if(n.direction!==A.down)return;if(n.messageType===b.DisposeMessage){n.destination&&delete this.components[n.destination];return}if(n.messageType===b.InitMessage){const s=n.content.id;if(this.components[s])return;this.components[s]=new Rn(s),this.messageToHost(new ut(s));return}if(n.messageType===b.EnvelopedMessage){const s=n,i=s.message;if(n=i,this.alwaysPassEnvelopesToHost||this.components[n.destination]){const a=myop.hostSDK.components.find(l=>l.id===i.destination);if(a){a.send(i);return}const o=myop.hostSDK.components.find(l=>l.id===s.destination);if(o){o.send(i);return}}else return}if(n.messageType){if(n.messageType===b.CleanupMessage){const s=n,i=this.messageCleanupCache[s.cleanupForMessageId],a=new Mt(!!i);a.destination=n.destination,i?(delete this.messageCleanupCache[s.cleanupForMessageId],Tn(i).then(()=>{this.messageToHost(a,s)}).catch(()=>{})):this.messageToHost(a,s);return}this.supportedHandlers.forEach(s=>{if(s.messageType===n.messageType){const i=s.executor(n);if(n.cleanable&&i&&(this.messageCleanupCache[n.id]=i),i&&!n.cleanable)throw new Error(`Cleanup handler generated for non-cleanable message.
|
|
3
|
+
messageType - ${n.messageType}, handler executor was - ${s.executor}
|
|
4
4
|
|
|
5
5
|
Please review the message definition object & message handler.
|
|
6
|
-
To ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers.`);if(!i&&
|
|
7
|
-
messageType - ${
|
|
6
|
+
To ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers.`);if(!i&&n.cleanable)throw new Error(`No cleanup handler generated for a cleanable message.
|
|
7
|
+
messageType - ${n.messageType}, handler executor was - ${s.executor}
|
|
8
8
|
|
|
9
9
|
Please review the message definition object & message handler.
|
|
10
|
-
To ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers.`)}})}else console.log("unsupported message type")}}},de={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"},ue={open:"open",none:"none",localFrame:"localFrame"},
|
|
10
|
+
To ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers.`)}})}else console.log("unsupported message type")}}},de={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"},ue={open:"open",none:"none",localFrame:"localFrame"},_e={code:"code"},Ne=class{};r(Ne,"code","code"),r(Ne,"component","component");var he={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Et={Segment:"Segment",Promo:"Promo",AB:"AB"},kn=class{constructor(e,t){this.container=e,this.shadowRoot=t,r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div")),r(this,"getRoot",()=>this.shadowRoot||this.container)}},$e=e=>e!==Object(e),Ln=e=>typeof e=="function",Ct=e=>{if($e(e))return!0;if(Ln(e)||Object.getPrototypeOf(e))return!1;for(const t in e){const n=e[t];if(typeof n=="object"){if(!Ct(n))return!1}else{if($e(n))continue;return!1}}return!0},te=(e,t={},n=!0,s=new WeakMap)=>{if($e(e))return e;if(Array.isArray(e)){if(s.has(e))return s.get(e);const i=[];s.set(e,i);for(let a=0;a<e.length;a++){const o=e[a];i[a]=te(o,t,n,s)}return i}if(e!==null&&typeof e=="object"){if(s.has(e))return s.get(e);const i={};s.set(e,i);for(const a in e){const o=typeof t=="boolean"?t:t[a];o&&(o===!0?(n?e[a]!==void 0:e[a])&&(i[a]=te(e[a],!0,n,s)):typeof o=="object"&&(i[a]=te(e[a],o,n,s)))}return i}return{}},On={notSerializableRefCall:(e,t)=>{throw new Error(`
|
|
11
11
|
The input provided to '${e.toString()}' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation.
|
|
12
12
|
The following types of data are considered non-serializable and cannot be processed:
|
|
13
13
|
|
|
@@ -37,15 +37,15 @@ Suggested Fix:
|
|
|
37
37
|
|
|
38
38
|
For more details on serialization and Myop message examples, refer to https://docs.myop.dev.
|
|
39
39
|
|
|
40
|
-
`)}},
|
|
40
|
+
`)}},St=class extends we{constructor(e,t,n){super(e,t.container,n),this.componentDefinition=e,this.parent=t,r(this,"send",s=>{const i=s.handler,a=super.send(s);return this.parent.send(new ft(this.id,s)),s.handler=i,a}),r(this,"dispose",()=>{this.isInitiated&&this.send(new j("dispose")),super.dispose()})}hide(){this.send(new j("hide"))}show(){this.send(new j("show"))}inspect(){return this.send(new j("inspect"))}setHeightBasedOnDocumentElement(){this.send(new j("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new j("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}},We=class extends we{constructor(e,t,n,s,i,a){super(e,n,a),this.container=n,this.customElement=s,this.tagName=i,r(this,"ctaCleanup"),r(this,"_ctaHandler"),r(this,"_ctaQueue",[]),r(this,"cleanupInspect",()=>{}),r(this,"send",o=>{const l=super.send(o);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",o),l}),r(this,"dispose",()=>{var o;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(o=this.customElement.parentNode)==null||o.removeChild(this.customElement)}),this.element=s,this.setInitiated()}inspect(){return this.cleanupInspect=Ke(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this.ctaCleanup&&this.ctaCleanup(),this._ctaHandler=e,this._ctaQueue.length>0){const n=[...this._ctaQueue];this._ctaQueue=[],n.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}const t=n=>{var s;const i=n;(s=i.detail)!=null&&s.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(i.detail.action,i.detail.payload):this._ctaHandler||this._ctaQueue.push({action:i.detail.action,payload:i.detail.payload}))};this.customElement.addEventListener("myop-cta",t),this.ctaCleanup=()=>{this.customElement.removeEventListener("myop-cta",t)}}},Pn=(e,t,n)=>{const s=document.createElement("a");return s.textContent=e,s.style.position="relative",s.style.padding="0 5px",s.style.fontSize="14px",s.style.top="0",s.style.top=`${t}px`,s.style.transform="translateX(-50%)",s.target="_blank",s.href=`https://dashboard.myop.dev/dashboard/component/${n.id}`,s},Ke=(e,t,n,s,i,a)=>{const o=Pn(`${a.name} : ${t}`,n,a);return s.insertBefore(o,i),i.style.border="1px solid #007BFF",i.style.display="block",()=>{i.style.border="unset",s.removeChild(o)}},xt=(e,t,n)=>e?!1:(console.error(`Error: Undefined Prop
|
|
41
41
|
|
|
42
42
|
It looks like you've tried to use a prop that hasn't been defined.
|
|
43
43
|
Please check the prop name for any typos or ensure that it is properly defined in the component's prop list.
|
|
44
44
|
|
|
45
45
|
Prop Name: ${t}
|
|
46
|
-
Component: ${
|
|
46
|
+
Component: ${n.componentDefinition.name}, ID: ${n.componentDefinition.id}
|
|
47
47
|
|
|
48
|
-
For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/${
|
|
48
|
+
For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/${n.componentDefinition.id} or consult the developer guide.`),!0),Tt=(e,t,n)=>{console.error(`Error: Code Prop Not Supported
|
|
49
49
|
|
|
50
50
|
Currently, code props are only supported in local frame components.
|
|
51
51
|
⚠️ This is a work in progress feature — code props will be supported in upcoming versions.
|
|
@@ -53,9 +53,9 @@ Currently, code props are only supported in local frame components.
|
|
|
53
53
|
In the meantime, you can use message props.
|
|
54
54
|
|
|
55
55
|
Prop Name: ${t}
|
|
56
|
-
Component: ${
|
|
56
|
+
Component: ${n.componentDefinition.name}, ID: ${n.componentDefinition.id}
|
|
57
57
|
|
|
58
|
-
For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/${
|
|
58
|
+
For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/${n.componentDefinition.id} or consult the developer guide.`)},An=(e,t,n)=>{const s=t.reduce((a,o)=>le(T({},a),{[o.name]:T({},o)}),{}),i={get:(a,o)=>{const l=s[o];if(xt(l,o,e))return!1;if(l.behavior.type===_e.code){if(e instanceof We)return(l.behavior.remap||o)==="myop_init_interface"?u=>{if(u===void 0)return e.getData();e.initWithData(u)}:void 0;if(n.loader.type===de.HTMLLoader&&n.loader.shadowRootMode===ue.localFrame){const d=l.behavior;return e.element.contentWindow[d.remap||o]}return Tt(l,o,e),!1}return l.mode==="output"?new Promise(c=>{const d=[];l.behavior.ref&&d.push(ce.create(l.behavior.ref)),d.push(h=>{c(h)}),l.behavior.params&&d.push(...l.behavior.params);const u=Ae[l.behavior.message];e.send(new u(...d))}):null},set:(a,o,l)=>{const c=s[o];if(xt(c,o,e))return!1;if(c.behavior.type===_e.code){if(e instanceof We){const u=c.behavior.remap||o;if(u==="myop_cta_handler")return e.setCtaHandler(l),!0;if(u==="myop_init_interface")return e.initWithData(l),!0}if(n.loader.type===de.HTMLLoader&&n.loader.shadowRootMode===ue.localFrame){const u=c.behavior,h=e.element.contentWindow,m=u.remap||o;if(h[m]=l,m==="myop_cta_handler"&&h.__myop_cta_queue){const y=h.__myop_cta_queue;h.__myop_cta_queue=null,y.forEach(f=>{e.markedForDisposed||l(f.action,f.payload)})}return!0}return Tt(c,o,e),!1}else if(c.mode==="input")if(c.behavior.type==="message"){const d=[];c.behavior.ref&&d.push(ce.create(c.behavior.ref)),d.push(l),c.behavior.params&&d.push(...c.behavior.params);const u=Ae[c.behavior.message];return e.send(new u(...d)),!0}else throw new Error(`Error: Unsupported Behavior
|
|
59
59
|
|
|
60
60
|
The 'behavior' field provided is not supported.
|
|
61
61
|
Component: ${e.componentDefinition.name}, ID: ${e.componentDefinition.id}
|
|
@@ -63,7 +63,7 @@ Component: ${e.componentDefinition.name}, ID: ${e.componentDefinition.id}
|
|
|
63
63
|
Prop Name: ${o}
|
|
64
64
|
Behavior Field: ${c.behavior.type}
|
|
65
65
|
|
|
66
|
-
Check the documentation for valid behavior options.`);return!1}};return e.props={},e.props=new Proxy(e.props,i),e},
|
|
66
|
+
Check the documentation for valid behavior options.`);return!1}};return e.props={},e.props=new Proxy(e.props,i),e},zn=(e,t)=>new Proxy(e,{get(n,s){return n[s]?n[s]:(...a)=>new Promise(o=>{a.forEach(l=>{Ct(l)||On.notSerializableRefCall(s,l)}),t.send(new ze(({ref:l,propName:c,functionArgs:d,makeSerializable:u})=>{if(l){const h=l[c];return u(typeof h=="function"?l[c](...d):h,!0)}return null},{elementId:n.refConfig.selector,propName:s,functionArgs:a},l=>{o(l.content)}))})},set(n,s,i){return t.send(new ze(({ref:a,propName:o,propValue:l})=>{a&&(a[o]=l)},{elementId:n.refConfig.selector,propValue:i,propName:s},a=>{})),!0}}),It=(e,t,n,s)=>v(void 0,null,function*(){const i=e.component;if(!i)throw new Error("cant createRefComponent with detached ref");return new Promise((a,o)=>v(void 0,null,function*(){const l=new St(t.type,i,s);n.push(l),yield i.initiated();const c=setTimeout(()=>{o("timeout")},5e3);i.send(new mt(e.refConfig,t,le(T({},s||{}),{id:l.id,_hasParent:!0}),d=>v(void 0,null,function*(){if(clearTimeout(c),d.failed){o("CreateRefComponentMessage failed");return}const u=n.find(h=>h.id==l.id);if(u!==l){i.refs[e.refConfig.name]=u,a(u);return}else l.setInitiated(),i.refs[e.refConfig.name]=l;d.nestedRefs.forEach(h=>{const m=t.instance.resolvedNestedComponents.find(f=>f.type.id===h.componentDefinitionId).type,y=new St(m,l);y.setInitiated(),l.refs[h.refName]=y,n.push(y)});try{yield Ht(l,t,n,!0),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),a(l)}catch(h){o(h)}})))}))}),Ht=(e,t,n,s=!1)=>v(void 0,null,function*(){e.refs||(e.refs={});const i=Object.values(e.componentDefinition.refs).map(a=>new Promise((o,l)=>v(void 0,null,function*(){var c;if(a.behavior.type==Ne.component){if(s){o();return}let d=a.behavior.componentId;d||(d=a.behavior.instance.componentId);const u=(c=t.instance.resolvedNestedComponents)==null?void 0:c.find(m=>m.type.id===d);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");const h=ce.create("",a,e);try{const m=yield It(h,u,n);e.refs[a.name]=m,o()}catch(m){l(m)}}else try{const d=ce.create("",a,e);e.refs[a.name]=zn(d,e),o()}catch{}})));try{yield Promise.all(i)}catch(a){throw a}}),Rt=class extends we{constructor(e,t,n,s,i){super(e,n,i),this.componentConfig=e,this.container=n,this.IframeElement=s,r(this,"_autoSizeCleanup"),r(this,"_autoSizeOptions"),r(this,"_autoSizeUpdate"),r(this,"sizeMeta"),r(this,"cleanupInspect"),r(this,"setHeightBasedOnDocumentElement",()=>{const a=this.send(new q(()=>window.document.documentElement.scrollHeight,o=>{this.IframeElement.style.height=`${o.content}px`,a()}))}),r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new q(({send:o})=>{const{height:l,width:c}=document.documentElement.getBoundingClientRect(),d=new ResizeObserver(()=>{const{height:u,width:h}=document.documentElement.getBoundingClientRect();o({height:u,width:h})});return d.observe(document.documentElement),d.observe(document.body),{height:l,width:c}},o=>{this.IframeElement.style.width=`${o.content.width}px`,this.IframeElement.style.height=`${o.content.height}px`}))),r(this,"observeAutoSize",a=>{if(this._autoSizeOptions=a,this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;const o=this.IframeElement,l=o.contentDocument;if(!l)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};const c=(E,w,S)=>w!==void 0&&E<w?w:S!==void 0&&E>S?S:E,d=E=>{if(E===void 0)return;if(typeof E=="number")return E;const w=parseFloat(E);return isNaN(w)?void 0:w},u=()=>{var E,w,S,z,W,Q,me,fe;const k=o.contentDocument;if(!k)return;const g=this._autoSizeOptions,ye=d(g==null?void 0:g.minWidth),se=d(g==null?void 0:g.maxWidth),xe=d(g==null?void 0:g.minHeight),ie=d(g==null?void 0:g.maxHeight),Te=(E=g==null?void 0:g.loaderMinHeight)!=null?E:50,Ie=((w=this.sizeMeta)==null?void 0:w.width)==="100%"?"100%":void 0,He=((S=this.sizeMeta)==null?void 0:S.height)==="100%"?"100%":void 0,_=(W=(z=g==null?void 0:g.explicitWidth)!=null?z:Ie)!=null?W:"100%",L=(Q=g==null?void 0:g.explicitHeight)!=null?Q:He,R=_!==void 0,Y=L!==void 0,K=this.container.getBoundingClientRect(),X=K.width===0,Z=K.height===0||K.height===Te,I=(g!=null&&g.forceAutoSize||X)&&!R,O=(g!=null&&g.forceAutoSize||Z)&&!Y;if(!I&&!O){o.style.width=typeof _=="number"?`${_}px`:"100%",o.style.height=typeof L=="number"?`${L}px`:"100%";const Le=typeof _=="number"?_:void 0,Oe=typeof L=="number"?L:void 0;(Le!==void 0||Oe!==void 0)&&((me=g==null?void 0:g.onSizeChange)==null||me.call(g,{width:Le,height:Oe,autoSizingWidth:!1,autoSizingHeight:!1}));return}const U=o.style.transition,P=this.container,Re=P.style.transition;o.style.transition="none",P.style.transition="none";const De=o.getBoundingClientRect().height,ee=o.getBoundingClientRect().width,ge=Math.ceil(Math.max(k.documentElement.scrollHeight,k.body.scrollHeight)),ke=Math.ceil(Math.max(k.documentElement.scrollWidth,k.body.scrollWidth));let oe=ke,Ge=ge;const Ps=O&&ge>De+1,As=I&&ke>ee+1,Ye=O&&!Ps,Je=I&&!As;if(Ye||Je){const Le=P.style.minHeight,Oe=P.style.minWidth;Ye&&(P.style.minHeight=`${De}px`),Je&&(P.style.minWidth=`${ee}px`),Ye&&(o.style.height="0px"),Je&&(o.style.width="0px"),oe=Math.ceil(Math.max(k.documentElement.scrollWidth,k.body.scrollWidth)),Ge=Math.ceil(Math.max(k.documentElement.scrollHeight,k.body.scrollHeight)),P.style.minHeight=Le,P.style.minWidth=Oe}const Qt=c(oe,ye,se),Xt=c(Ge,xe,ie);I?o.style.width=`${Qt}px`:o.style.width=typeof _=="number"?`${_}px`:"100%",O?o.style.height=`${Xt}px`:o.style.height=typeof L=="number"?`${L}px`:"100%",o.offsetHeight,o.style.transition=U,P.style.transition=Re;const zs=I&&se!==void 0&&oe>se,Fs=O&&ie!==void 0&&Ge>ie;k.documentElement.style.overflowX=zs?"auto":"",k.documentElement.style.overflowY=Fs?"auto":"",(fe=g==null?void 0:g.onSizeChange)==null||fe.call(g,{width:Qt,height:Xt,autoSizingWidth:I,autoSizingHeight:O})};u(),this._autoSizeUpdate=u;let h;const m=()=>{h===void 0&&(h=requestAnimationFrame(()=>{h=void 0,u()}))},y=new ResizeObserver(()=>m());y.observe(l.body),y.observe(l.documentElement);const f=new MutationObserver(()=>m());f.observe(l.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});const D=()=>{y.disconnect(),f.disconnect(),h!==void 0&&(cancelAnimationFrame(h),h=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=D,D}),r(this,"setSizeBasedOnDocumentElement",()=>{const a=this.send(new q(()=>{const{height:o,width:l}=document.documentElement.getBoundingClientRect();return{height:o,width:l}},o=>{this.IframeElement.style.width=`${o.content.width}px`,this.IframeElement.style.height=`${o.content.height}px`,a()}))}),r(this,"setHeightBasedOnScrollHeight",()=>{const a=this.send(new q(()=>{let l=0;return l++,l--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+l+"px"},o=>{this.IframeElement.style.height=o.content,a()}))}),r(this,"send",a=>{var o,l;let c=T({},a);if(c.messageType===b.ExecuteComponentMethod)return this[c.method](),()=>{};c.direction=A.down;const d=super.send(c);return(l=(o=this.IframeElement)==null?void 0:o.contentWindow)==null||l.postMessage(c,"*"),d}),r(this,"dispose",()=>{this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Ke(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===b.In.MutationObserverMessage||e.messageType===b.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}},Ue=class{constructor(){r(this,"appendChild",(e,t,n)=>{var s;if(n!=null&&n.relative){if(n.relative.direction==="before")return e.insertBefore(t,n.relative.child);if(n.relative.direction==="after"){const i=(s=n.relative.child)==null?void 0:s.nextSibling;return e.insertBefore(t,i||null)}}else return e.appendChild(t)})}},Fn=(e,t,n)=>{const s=new URL(e);return s.searchParams.append(t,n),s.toString()},Bn=class extends Ue{constructor(){super(...arguments),r(this,"type",de.IframeLoader),r(this,"load",(e,t,n,s)=>v(this,null,function*(){let i;const a=t.loader;if((n==null?void 0:n.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",a.url,n),i=n,i.src=a.url;else{const o=J(),l=`myop-comp-${o}`;i=document.createElement("iframe"),i.id=l;const c=`
|
|
67
67
|
padding: 0;
|
|
68
68
|
margin: 0;
|
|
69
69
|
position: absolute;
|
|
@@ -72,9 +72,9 @@ Check the documentation for valid behavior options.`);return!1}};return e.props=
|
|
|
72
72
|
width: 100%;
|
|
73
73
|
overflow: hidden;
|
|
74
74
|
border: none;
|
|
75
|
-
opacity: ${
|
|
76
|
-
pointer-events: ${
|
|
77
|
-
`;i.style.cssText=c,
|
|
75
|
+
opacity: ${s!=null&&s.hidden?"0":"1"};
|
|
76
|
+
pointer-events: ${s!=null&&s.hidden?"none":"all"};
|
|
77
|
+
`;i.style.cssText=c,s!=null&&s.elementAttributes&&Object.entries(s.elementAttributes).forEach(([u,h])=>{h===""||h===null||h===void 0?i.setAttribute(u,""):i.setAttribute(u,String(h))});let d=t.loader.url;s!=null&&s._hasParent&&(d=Fn(d,"_myop-comp",o)),i.src=d,n.querySelector('[id^="myop-comp-"]')||(n.innerHTML=""),i=this.appendChild(n,i,s)}return new Rt(e,t,n,i,s)}))}},Dt={webcomponent_message_key:"myop_webcomponent_message"},kt=class extends we{constructor(e,t,n,s,i){super(e,n,i),this.container=n,this.customElement=s,r(this,"cleanupInspect",()=>{}),r(this,"send",a=>{let o=T({},a);const l=super.send(o),c=new CustomEvent(Dt.webcomponent_message_key,{detail:o});try{this.customElement.dispatchEvent(c)}catch(d){console.log("error while trying to dispatchEvent",d)}return l}),r(this,"dispose",()=>{var a;super.dispose(),(a=this.customElement.parentNode)==null||a.removeChild(this.customElement)}),this.element=s}inspect(){return this.cleanupInspect=Ke(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=""}},qe={},Nn=class extends Ue{constructor(){super(...arguments),r(this,"type",de.WebComponentLoader),r(this,"load",(e,t,n,s)=>v(this,null,function*(){const i=t.loader;qe[i.url]?console.log("Module alreday loaded or in loading process"):qe[i.url]=new Promise((l,c)=>{const d=i.url,u=document.createElement("script");u.type="module",u.src=d,u.onload=()=>{l()},u.onerror=()=>{c()},document.head.appendChild(u)}),yield qe[i.url],yield cn(1);let a=`myop-comp-${J()}`;const o=document.createElement(i.tag);return n.querySelector('[id^="myop-comp-"]')||(n.innerHTML=""),o.id=a,s!=null&&s.hidden&&(o.style.opacity="0",o.style.position="absolute",o.style.height="0",o.style.width="0",o.style.pointerEvents="none",o.style.visibility="hidden"),s!=null&&s._environment&&(o._myopEnvironment=s==null?void 0:s._environment),this.appendChild(n,o,s),new kt(e,t,n,o,s)}))}},$n="0.3.22",N=class extends Hn{constructor(e,t){super(e),this.context=t,r(this,"executor",n=>{if(n.destination){const s=n.destination;if(this.context[s].context){const i=(a,o)=>{this.messageToHost(le(T({},a),{source:n.destination?n.destination:n.source,destination:n.source?n.source:n.destination}),o)};return this.innerExecutor(n,this.context[s].context,i)}else debugger}else debugger})}},pe={id:"myop-id"},ne=(e,t)=>t.querySelectorAll(`[${pe.id}='${e.refConfig.selector}']`),Wn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.BindClickMessage),r(this,"innerExecutor",(e,t,n)=>{const s=ne(e.ref,t.shadowRoot),i=[];return s.forEach(a=>{const o=()=>{n(new st(e.handlerUniqueId))};a.addEventListener("click",o),i.push(()=>{a.removeEventListener("click",o)})}),()=>{i.forEach(a=>a())}})}},Kn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.ChangeTextMessage),r(this,"innerExecutor",(e,t)=>{ne(e.ref,t.shadowRoot).forEach(s=>{s.textContent=e.content})})}},Un=class extends kn{constructor(e,t){super(e,t),this.container=e,this.shadowRoot=t}},qn=class extends N{constructor(){super(...arguments),r(this,"innerExecutor",(e,t)=>{const n=t.shadowRoot.querySelectorAll(`[${pe.id}]`);let s=[];n.forEach(i=>{const a=i.getAttribute(pe.id);a&&s.push(new xn(a,i.tagName,i.getBoundingClientRect(),i.offsetTop,i.offsetLeft))}),this.messageToHost(new gt(e.handlerUniqueId,s))}),r(this,"messageType",b.DetectMyopRefsMessage)}},jn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.SetAttributeMessage),r(this,"innerExecutor",(e,t)=>{ne(e.ref,t.shadowRoot).forEach(s=>{s.setAttribute(e.name,e.value)})})}},Vn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.AddEventListenerMessage),r(this,"innerExecutor",(e,t,n)=>{const s=ne(e.ref,t.shadowRoot),i=[];return s.forEach(a=>{const o=l=>{n(new lt(e.handlerUniqueId,te(l,e.serializableSkeleton)))};a.addEventListener(e.type,o),i.push(()=>{a.removeEventListener(e.type,o)})}),()=>{i.forEach(a=>a())}})}},Gn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.CreateRefComponentMessage),r(this,"innerExecutor",(e,t,n)=>{v(this,null,function*(){const i=t.shadowRoot.querySelectorAll(`[${pe.id}='${e.refConfig.selector}']`);if(i.length===1){const a=Ee.Instance(),o=a.components.find(u=>u.id===e.options.id);o&&o.dispose();const l=a.components.indexOf(o);l!==-1&&a.components.splice(l,1);const c=yield a.loadComponent(e.nestedComponentConfig,i.item(0),e.options),d=[];Object.keys(c.refs).forEach(u=>{let h=c.refs[u];h=h.__nonProxied||h,h.componentDefinition&&d.push({refName:u,componentDefinitionId:h.componentDefinition.id})}),n(new Be(e.handlerUniqueId,d))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new Be(e.handlerUniqueId,[],!0));debugger}}).then()})}},Yn=(e,t,n)=>{const s=e.scriptInputs?e.scriptInputs:{};s.makeSerializable=te,s.send=t,s.rootRef=n,s.__scriptInputs=s;const a=new Function(`return (${e.script})(...arguments)`)(s);t(a)},Jn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.ExecuteScriptMessage),r(this,"innerExecutor",(e,t,n)=>{Yn(e,i=>{n(new rt(e.handlerUniqueId,i))},t)})}},Lt=e=>{if(!e)return null;if(e.tagName==="FORM"){new FormData(e);const t={formData:{},unmappedData:[]};return e.querySelectorAll("input, select, textarea").forEach(s=>{if(typeof s.value=="string"){const i=s.getAttribute(pe.id);let a=s.getAttribute("name");const o={id:s.id,name:a,value:Lt(s),required:s.required,validity:te(s.validity,!0),myopId:i};a?t.formData[a]?t.formData[a].value?t.unmappedData.push(o):(t.unmappedData.push(t.formData[a]),t.formData[a]=o):t.formData[a]=o:t.unmappedData.push(o)}}),t}return e.type==="checkbox"||e.type==="radio"?e.checked?e.value:null:e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT"?e.value:e.isContentEditable?e.innerText||e.textContent:null},Qn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.GetElementValueMessage),r(this,"innerExecutor",(e,t,n)=>{ne(e.ref,t.shadowRoot).forEach(i=>{n(new dt(Lt(i)),e)})})}},Xn=class extends N{constructor(){super(...arguments),r(this,"messageType",b.SetInnerHtml),r(this,"innerExecutor",(e,t)=>{ne(e.ref,t.shadowRoot).forEach(s=>{s.innerHTML=e.content})})}},Ot=class extends Dn{constructor(){super(...arguments),r(this,"alwaysPassEnvelopesToHost",!0),r(this,"connectedCallback",(e,t)=>{e.addEventListener(Dt.webcomponent_message_key,n=>{const s=n.data?n.data:n.detail;if(!s||!s.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{const i=s;if(this.handleIncomeMessages(n),i.messageType===b.InitMessage){const a=i.content.id;this.components[a].context=new Un(e,t)}}}),setTimeout(()=>{this.messageToHost(new ht)},1)}),r(this,"messageToHost",(e,t)=>{e.direction=A.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)}),r(this,"supportedHandlers",[new Kn(this.messageToHost,this.components),new Xn(this.messageToHost,this.components),new Wn(this.messageToHost,this.components),new qn(this.messageToHost,this.components),new jn(this.messageToHost,this.components),new Vn(this.messageToHost,this.components),new Jn(this.messageToHost,this.components),new Qn(this.messageToHost,this.components),new Gn(this.messageToHost,this.components)]),r(this,"init",()=>{})}};et("WebComponentSDK",Ot);var Zn="<!-- myop-web-component -->",es="myop-web-component",Pt=new Set,At=[],Me,zt=()=>v(void 0,null,function*(){return Me||(Me=new Ot,Me.init()),Me});function ts(e,t){return class extends HTMLElement{connectedCallback(){const n=t===ue.open?"open":"closed",s=this.attachShadow({mode:n});zt().then(i=>{i.connectedCallback(this,s),s.innerHTML=e})}}}var ns=(e,t,n)=>{customElements.define(e,ts(t,n)),console.log(`define('${e}') was called, web component ready to use`)},ss=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),is=e=>(e=ss(e),e.replace(/_/g,"-")),os=class extends Ue{constructor(){super(...arguments),r(this,"type",de.HTMLLoader),r(this,"load",(e,t,n,s)=>v(this,null,function*(){const i=t.loader;if(this.isMyopWebComponent(i.HTML))return this.loadExtractedWebComponent(e,t,n,i.HTML,s);let a=`myop-comp-${J()}`,o;if(i.shadowRootMode===ue.localFrame){const c=`myop-comp-${J()}`;let d=document.createElement("iframe");d.id=c,d.style.cssText=`
|
|
78
78
|
display: block;
|
|
79
79
|
padding: 0;
|
|
80
80
|
margin: 0;
|
|
@@ -82,16 +82,16 @@ Check the documentation for valid behavior options.`);return!1}};return e.props=
|
|
|
82
82
|
inset: 0;
|
|
83
83
|
overflow: hidden;
|
|
84
84
|
border: none;
|
|
85
|
-
opacity: ${
|
|
85
|
+
opacity: ${s!=null&&s.hidden?"0":"1"};
|
|
86
86
|
width: 100%;
|
|
87
87
|
height: 100%;
|
|
88
|
-
pointer-events: ${
|
|
89
|
-
`,
|
|
88
|
+
pointer-events: ${s!=null&&s.hidden?"none":"all"};
|
|
89
|
+
`,n.querySelector('[id^="myop-comp-"]')||(n.innerHTML=""),d=this.appendChild(n,d,s);const u=d.contentDocument||d.contentWindow.document;u.open();let h=null;{const S=new DOMParser().parseFromString(i.HTML,"text/html").querySelector('meta[name="myop:size"]');if(S)try{h=JSON.parse(S.getAttribute("content")||"{}")}catch{}}let m=i.HTML;if(s!=null&&s._inspection){const w=new DOMParser().parseFromString(i.HTML,"text/html"),S=w.getElementById("myop_preview");S==null||S.removeAttribute("type");const z=w.implementation.createHTMLDocument();z.body.innerHTML=`<script>
|
|
90
90
|
const beforeKeysWindow = new Set(Object.keys(window));
|
|
91
91
|
window.myopState = {
|
|
92
92
|
beforeKeysWindow,
|
|
93
93
|
};
|
|
94
|
-
<\/script>`;const
|
|
94
|
+
<\/script>`;const W=z.body.firstChild;W&&w.head&&w.head.insertBefore(w.importNode(W,!0),w.head.firstChild),m=w.documentElement.outerHTML}else if((s==null?void 0:s.data)!==void 0){const w=new DOMParser().parseFromString(i.HTML,"text/html"),S=w.getElementById("myop_preview");S&&(S.remove(),m=w.documentElement.outerHTML)}u.writeln(m);const y=`<script>${en}<\/script>`;if(u.writeln(`${y}<script>
|
|
95
95
|
const __myop_init = async () => {
|
|
96
96
|
const iframeModule = await MyopSDK.getIframeModule();
|
|
97
97
|
const IframeSDK = iframeModule.IframeSDK;
|
|
@@ -99,14 +99,14 @@ Check the documentation for valid behavior options.`);return!1}};return e.props=
|
|
|
99
99
|
sdk.init();
|
|
100
100
|
}
|
|
101
101
|
__myop_init().then();
|
|
102
|
-
<\/script>`),(
|
|
102
|
+
<\/script>`),(s==null?void 0:s.data)!==void 0){const E=`<script>
|
|
103
103
|
window.__myop_cta_queue = [];
|
|
104
104
|
window.myop_cta_handler = function(action, payload) {
|
|
105
105
|
window.__myop_cta_queue.push({action: action, payload: payload});
|
|
106
106
|
};
|
|
107
|
-
<\/script>`,
|
|
107
|
+
<\/script>`,S=`<script id="__myop_init_data_script">
|
|
108
108
|
(function() {
|
|
109
|
-
var data = ${JSON.stringify(
|
|
109
|
+
var data = ${JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script")};
|
|
110
110
|
var scriptEl = document.getElementById('__myop_init_data_script');
|
|
111
111
|
|
|
112
112
|
var callInitInterface = function(fn) {
|
|
@@ -164,4 +164,4 @@ Check the documentation for valid behavior options.`);return!1}};return e.props=
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
})();
|
|
167
|
-
<\/script>`;u.writeln(I+H)}u.close();const M=new Et(e,t,s,d,n);return M.sizeMeta=h,M.initiated().then(()=>{M.observeAutoSize({forceAutoSize:!0}),n!=null&&n.hidden||M.show()}),M}if(i.shadowRootMode===ue.none){const l=document.createElement("template");l.innerHTML=i.HTML,o=l.content.firstElementChild,Ht().then(c=>{c.connectedCallback(o,o)})}else{const l=Ys(e.name+t.id);Rt.includes(l)||(Vs(l,i.HTML,i.shadowRootMode),Rt.push(l)),o=document.createElement(l)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),o.id=a,n!=null&&n.hidden&&(o.style.opacity="0",o.style.position="absolute",o.style.height="0",o.style.width="0",o.style.pointerEvents="none",o.style.visibility="hidden"),this.appendChild(s,o,n),new St(e,t,s,o,n)}))}isMyopWebComponent(e){return e.trimStart().startsWith(Us)}extractWebComponentScript(e){const n=new DOMParser().parseFromString(e,"text/html").getElementById(qs);return(n==null?void 0:n.textContent)||null}executeWebComponentScript(e,t){if(It.has(t)){console.log(`[MyopWebComponent] Script already executed for ${t}, skipping`);return}const s=document.createElement("script");s.textContent=e,s.id=`myop-extracted-${t}`,document.head.appendChild(s),It.add(t),console.log(`[MyopWebComponent] Executed web component script: ${t}`)}loadExtractedWebComponent(e,t,s,n,i){return g(this,null,function*(){const a=this.extractWebComponentScript(n);if(!a)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');const o=`${e.id}-${t.id}`,l=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(a,o);const c=window.__MYOP_TAG_NAME__;if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");l&&l!==c&&console.warn(`[MyopWebComponent] __MYOP_TAG_NAME__ changed from ${l} to ${c}`);const d=`myop-comp-${Q()}`,u=document.createElement(c);u.id=d,i!=null&&i.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,u,i);const h=new Ae(e,t,s,u,c,i);return(i==null?void 0:i.data)!==void 0&&h.initWithData(i.data),console.log(`[MyopWebComponent] Loaded <${c}> into container`),h})}},Qs=e=>({instance:{id:"auto",componentId:e.componentId,componentName:e.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:e.id,name:e.name,description:e.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:we.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:we.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:e.consume_variant[0].loader}],defaultSkin:0},name:e.name}),Me="__MYOP_CLOUD_REPOSITORY_MAIN__",Xs=()=>{if(typeof window<"u")return window[Me];if(typeof globalThis<"u")return globalThis[Me]},Zs=e=>{typeof window<"u"&&(window[Me]=e),typeof globalThis<"u"&&(globalThis[Me]=e)},Dt=class re{constructor(t="https://cloud.myop.dev"){this._baseUrl=t,r(this,"variants",{}),r(this,"preloadedComponents",{}),r(this,"userFlows",{}),r(this,"_defaultEnv","production"),r(this,"_envExplicitlySet",!1)}static get Main(){const t=Xs();return t||(re._main||(re._main=new re,Zs(re._main)),re._main)}setEnvironment(t){this._defaultEnv=t,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(t,s,n){return s!==void 0||n!==void 0?`${t}:${s||this._defaultEnv}:${n?"preview":"live"}`in this.variants:t in this.preloadedComponents}getPreloadedParams(t){return this.preloadedComponents[t]}fetchComponentV2(t,s,n){return g(this,null,function*(){const i=this.preloadedComponents[t],a=s!==void 0||n!==void 0;let o,l;if(!a&&i)o=i.env,l=i.preview;else{o=s||this._defaultEnv;const d=s||this._envExplicitlySet;l=n===!0?!0:n===!1?!1:!d}const c=`${t}:${o}:${l?"preview":"live"}`;return console.log("[CloudRepository] fetchComponentV2",{componentId:t.slice(0,8)+"...",env:o,usePreview:l,cacheKey:c,cached:c in this.variants}),this.variants[c]||(this.preloadedComponents[t]||(this.preloadedComponents[t]={env:o,preview:l}),this.variants[c]=new Promise((d,u)=>g(this,null,function*(){try{let h=`${this._baseUrl}/consume?id=${t}&env=${o}`;l&&(h+="&preview=true");const m=(yield(yield fetch(h)).json()).item;if(!m){u(new Error(`Component "${t}" not found`));return}if(!m.consume_variant||!m.consume_variant.length){u(new Error(`Component "${t}" has no implementation for environment "${o}"`));return}const M=Qs(m);d(M)}catch(h){u(h)}}))),yield this.variants[c]})}fetchComponentV1(t,s){return g(this,null,function*(){return s?(yield this.fetchFlow(s)).components.find(i=>i.type.id===t):(yield this.fetchAutoFlow(t)).components[0]})}fetchAutoFlow(t){return g(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>g(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&auto=true`)).json();s(a.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}fetchFlow(t){return g(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>g(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&resolve=components`)).json();s(a.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}fetchComponent(t,s){return g(this,null,function*(){return this.fetchComponentV1(t,s)})}};r(Dt,"_main",null);var Be=Dt;Be.Main;var en=e=>g(void 0,null,function*(){try{const t=new URL(window.location.href),n=new URLSearchParams(t.search).get("myopOverride");if(n){const[i,...a]=Ge(n);switch(i){case"component":{const[o,l]=a,c=yield Be.Main.fetchComponent(o);if(c&&c.type.skins.find(u=>u.id===l))return c.instance.skinSelector={type:he.Dedicated,skin:{id:l}},c}break;default:{const[o,l]=Ge(n),d=(yield Be.Main.fetchFlow(o)).components.find(u=>u.type.id===e.type.id);if(d&&d.instance.skinSelector.type===he.Segmented&&d.instance.resolvedExperiences){const u=d.instance.resolvedExperiences.find(h=>h.id===l);if((u==null?void 0:u.type)===yt.Segment){const h=u,y=d.instance.skinSelector.segments.find(m=>m.segmentId===h.segment.id);if(y)return d.instance.skinSelector=y==null?void 0:y.skinSelector,d}}}break}}}finally{return null}}),kt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",be=class{constructor(){r(this,"components2init",[]),r(this,"components",[]),r(this,"componentsLoaders",[]),r(this,"initiated",!1),r(this,"version",ks),r(this,"type2InstanceCount",{}),r(this,"assignId",e=>(this.type2InstanceCount[e.id]||(this.type2InstanceCount[e.id]=0),`${e.id}_${++this.type2InstanceCount[e.id]}`)),r(this,"inspected",!1),r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(e=>{e.inspect&&e.inspect()}))}),r(this,"incomingMessageHandler",e=>{if(e.origin,document.location.origin,e.data.myop){if(e.data.direction!==O.up&&e.data.messageType!==_.EnvelopedMessage)return;const t=e.data;if(t.messageType===_.InitRequest){this.components2init.forEach(n=>{n.send(new ke(n.id))});return}if(t.messageType===_.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==t.content.id);const n=this.components.find(i=>{var a;return i.id===((a=t.content)==null?void 0:a.id)});n==null||n.setInitiated();return}if(t.messageType===_.EnvelopedMessage){const n=t,i=this.components.find(a=>a.id===n.destination);if(i){if(n.direction===O.down){n.message.messageType===j.name?i.onMessageReceived(n.message):(n.message.route=n.route,i.send(n.message));return}}else{const a=this.components.find(o=>o.id===n.message.destination);a&&a.send(n.message)}return}const s=this.components.find(n=>n.id===t.destination);if(!s){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(s){if(s.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}}),r(this,"send",e=>{const t=new MessageEvent("",{data:e});this.incomingMessageHandler(t)}),r(this,"init",e=>{if(this.initiated)throw new Error("hostSDK already initiated");const t=[new Hs,new Ds,new Js];if(this.componentsLoaders=[...t],e){const s={};e.forEach(n=>{const i=new n(this.componentsLoaders);s[i.type]=i}),this.componentsLoaders.forEach(n=>{s[n.type]||(s[n.type]=n)}),this.componentsLoaders=Object.values(s)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0}),r(this,"_getSkinIdBySkinSelector",(e,...t)=>g(this,[e,...t],function*(s,n=[],i){var a;function o(l,c){return g(this,null,function*(){for(const d of l)if(yield c(d))return d})}switch(s.type){case"DedicatedSkin":case he.Dedicated:return((a=s.skin)==null?void 0:a.id)||s.skins[0].id;case he.Segmented:{const c=yield o(s.segments,d=>g(this,null,function*(){if(d.segmentId==="Default")return!0;const u=n.find(m=>m.type===yt.Segment?m.segment.id===d.segmentId:!1);if(!u)throw new Error("experience not found");const f=u.segment,y=(i||{})[f.function];return y?yield y():(console.warn(`segmentId:${d.segmentId}, ${f.function} function not provided !`),!1)}));if(c)return this._getSkinIdBySkinSelector(c.skinSelector,n);debugger}break;default:debugger}return""})),r(this,"runSkinSelector",(e,t)=>g(this,null,function*(){const s=yield this._getSkinIdBySkinSelector(e.instance.skinSelector,e.instance.resolvedExperiences,t);return e.type.skins.find(n=>n.id===s)})),r(this,"loaderHooks"),r(this,"loadComponent",(e,t,s)=>g(this,null,function*(){var n,i,a,o;if(!t){debugger;throw new Error("no container was found for this component")}const l=yield en(e);l&&(e=l);const c=S(S({},(n=this.loaderHooks)!=null?n:{}),(i=s==null?void 0:s.hooks)!=null?i:{}),d=t;if(d.myop)if(d.component){e=S({},e),e.instance=S({},e.instance);let y=yield this.runSkinSelector(e,c);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(a=s==null?void 0:s.hooks)!=null&&a.afterSkinSelected&&(y=yield s.hooks.afterSkinSelected(S({},y))),e.instance.skinSelector={type:he.Dedicated,skin:y},s&&(s=S({},s),delete s.hooks),yield Mt(d,e,this.components,s)}else throw new Error("load component got a detached ref.");t=t;let u=yield this.runSkinSelector(e,c);if(!u)throw new Error("runSkinSelector failed to choose skin, check the provided config");(o=s==null?void 0:s.hooks)!=null&&o.afterSkinSelected&&(u=yield s.hooks.afterSkinSelected(S({},u)));const h=this.componentsLoaders.find(y=>y.type===u.loader.type);if(!h){debugger;throw new Error(`no loader "${u.loader.type}" was found for component`)}let f=yield h.load(e.type,u,t,s);f.isInitiated||this.components2init.push(f),f.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==f),this.components2init=this.components2init.filter(y=>y!==f),!0)),this.components.push(f),(!s||s.connectProps!==!1)&&(f=xs(f,e.type.props,u));try{yield bt(f,e,this.components)}catch(y){throw y}return s!=null&&s.skipInit||(yield f.initiated()),f})),r(this,"navigate",(e,t,s)=>g(this,null,function*(){if(e.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(s!=null&&s.staged){let n=yield this.loadComponent(t,e.container,S({hidden:!0,relative:{direction:"after",child:e.element}},s));return s.init&&(yield s.init(n)),n.show(),e.dispose(),n}else{const n=e.element.nextSibling;return e.dispose(),this.loadComponent(t,e.container,S({relative:{direction:"before",child:n}},s))}}))}};if(r(be,"Instance",()=>window.myop.hostSDK),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:kt}),!window.myop.hostSDK){const e=new be;e.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:kt}),window.myop.hostSDK=e}var $e=window.myop.hostSDK;Ve("hostSDK",$e);var tn="linear-gradient(135deg, #FF8651 0%, #FFBEA8 50%, #A397F5 100%)",sn="linear-gradient(135deg, #9CA3AF 0%, #D1D5DB 50%, #E5E7EB 100%)",nn={position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,background:tn,display:"flex",justifyContent:"center",alignItems:"center"},on={position:"absolute",top:0,left:0,right:0,bottom:0,background:sn,display:"flex",justifyContent:"center",alignItems:"center"},rn={position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,display:"flex",justifyContent:"center",alignItems:"center"},an=Object.defineProperty,ln=(e,t,s)=>t in e?an(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,p=(e,t,s)=>ln(e,typeof t!="symbol"?t+"":t,s),K=(e,t,s)=>new Promise((n,i)=>{var a=c=>{try{l(s.next(c))}catch(d){i(d)}},o=c=>{try{l(s.throw(c))}catch(d){i(d)}},l=c=>c.done?n(c.value):Promise.resolve(c.value).then(a,o);l((s=s.apply(e,t)).next())}),V=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),cn=class{constructor(){p(this,"id",V()),p(this,"myop",!0),p(this,"content"),p(this,"source"),p(this,"destination"),p(this,"route"),p(this,"ref"),p(this,"direction"),p(this,"cleanable",!1)}static create(...e){return new this(...e)}isTypeof(e){return e.messageType===this.messageType}},dn=class extends cn{constructor(e){super(),this.handler=e,p(this,"handlerUniqueId",V())}},un="ExecuteScriptReplyMessage",hn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,pn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,mn=e=>{let t=e.match(hn);if(t)return t[1]||t[3];{let s=e.match(pn);if(s)return s[1].trim()}},Lt=class extends dn{constructor(e,t=()=>{},s){super(t),this.scriptInputs=s,p(this,"replyMessageKey",un),p(this,"messageType","ExecuteScriptMessage"),p(this,"script",""),this.script=e.toString(),this.content=e.toString(),this.content=mn(this.content)}};p(Lt,"replierKey","send"),p(Lt,"completeStreamKey","completeStream");var Ot=class{constructor(){p(this,"_runTimeInstanceId","runtime-instance-id-"+V()),p(this,"_runTimeId","runtime-id-"+V()),p(this,"_runTimeName","runtime-name-"+V()),p(this,"id",this._runTimeId),p(this,"name",this._runTimeName),p(this,"description",""),p(this,"loader",null),p(this,"withLoader",t=>(this.loader=t,this)),p(this,"withHTMLLoader",t=>(t.type="HTMLLoader",this.loader=t,this)),p(this,"build",()=>this)}};p(Ot,"create",()=>new Ot);var Pt=class{constructor(){p(this,"_runTimeInstanceId","runtime-instance-id-"+V()),p(this,"_runTimeId","runtime-id-"+V()),p(this,"_runTimeName","runtime-name-"+V()),p(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null}),p(this,"name",this._runTimeName),p(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0}),p(this,"withInstance",t=>(this.instance=t,this)),p(this,"withType",t=>(this.type=t,this)),p(this,"withName",t=>(this.name=t,this)),p(this,"withDefaultSkin",t=>(this.type.skins.push(t),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:t.id}},this)),p(this,"withRef",t=>(this.type.refs.push(t),this)),p(this,"withBasicRef",t=>{const s={id:"",name:t,description:"",selectorType:"id-attribute",selector:t,behavior:{type:"code"}};return this.type.refs.push(s),this}),p(this,"build",()=>JSON.parse(JSON.stringify(this)))}};p(Pt,"create",()=>new Pt);var At={code:"code"},fn=e=>({instance:{id:"auto",componentId:e.componentId,componentName:e.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:e.id,name:e.name,description:e.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:At.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:At.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:e.consume_variant[0].loader}],defaultSkin:0},name:e.name}),Ee="__MYOP_CLOUD_REPOSITORY_MAIN__",yn=()=>{if(typeof window<"u")return window[Ee];if(typeof globalThis<"u")return globalThis[Ee]},gn=e=>{typeof window<"u"&&(window[Ee]=e),typeof globalThis<"u"&&(globalThis[Ee]=e)},zt=class ae{constructor(t="https://cloud.myop.dev"){this._baseUrl=t,p(this,"variants",{}),p(this,"preloadedComponents",{}),p(this,"userFlows",{}),p(this,"_defaultEnv","production"),p(this,"_envExplicitlySet",!1)}static get Main(){const t=yn();return t||(ae._main||(ae._main=new ae,gn(ae._main)),ae._main)}setEnvironment(t){this._defaultEnv=t,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(t,s,n){return s!==void 0||n!==void 0?`${t}:${s||this._defaultEnv}:${n?"preview":"live"}`in this.variants:t in this.preloadedComponents}getPreloadedParams(t){return this.preloadedComponents[t]}fetchComponentV2(t,s,n){return K(this,null,function*(){const i=this.preloadedComponents[t],a=s!==void 0||n!==void 0;let o,l;if(!a&&i)o=i.env,l=i.preview;else{o=s||this._defaultEnv;const d=s||this._envExplicitlySet;l=n===!0?!0:n===!1?!1:!d}const c=`${t}:${o}:${l?"preview":"live"}`;return console.log("[CloudRepository] fetchComponentV2",{componentId:t.slice(0,8)+"...",env:o,usePreview:l,cacheKey:c,cached:c in this.variants}),this.variants[c]||(this.preloadedComponents[t]||(this.preloadedComponents[t]={env:o,preview:l}),this.variants[c]=new Promise((d,u)=>K(this,null,function*(){try{let h=`${this._baseUrl}/consume?id=${t}&env=${o}`;l&&(h+="&preview=true");const m=(yield(yield fetch(h)).json()).item;if(!m){u(new Error(`Component "${t}" not found`));return}if(!m.consume_variant||!m.consume_variant.length){u(new Error(`Component "${t}" has no implementation for environment "${o}"`));return}const M=fn(m);d(M)}catch(h){u(h)}}))),yield this.variants[c]})}fetchComponentV1(t,s){return K(this,null,function*(){return s?(yield this.fetchFlow(s)).components.find(i=>i.type.id===t):(yield this.fetchAutoFlow(t)).components[0]})}fetchAutoFlow(t){return K(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>K(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&auto=true`)).json();s(a.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}fetchFlow(t){return K(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((s,n)=>K(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&resolve=components`)).json();s(a.item)}catch(i){n(i)}}))),yield this.userFlows[t]})}fetchComponent(t,s){return K(this,null,function*(){return this.fetchComponentV1(t,s)})}};p(zt,"_main",null);var Ce=zt,G=Ce.Main,Ft=()=>G,Nt=(e,t,s)=>G.isPreloaded(e,t,s),vn=e=>G.getPreloadedParams(e),wn=()=>{G=new Ce("http://localhost:9292")},_n=e=>{G=new Ce(e)},Mn=e=>{G=e},bn=e=>{G.setEnvironment(e)},En=(e,t,s)=>K(void 0,null,function*(){return Promise.allSettled(e.map(n=>G.fetchComponentV2(n,t,s)))});const Cn=e=>{const t=w.useRef(null),s=w.useRef(null),n=w.useRef(!1),i=w.useRef(null);return w.useEffect(()=>{let a=!1;n.current=!(t!=null&&t.current);const o=async l=>{n.current=!0;try{const c=await Ce.Main.fetchComponent(l.componentId,l.flowId);s.current=await $e.loadComponent(c,t.current,{_environment:{props:{...l}}}),a?s.current&&s.current.dispose():l.onReady&&l.onReady(s.current)}catch{}finally{if(n.current=!1,i.current!==null&&!a){const c=i.current;i.current=null,await o(c)}}};return n.current?i.current={...e}:o(e).then(),()=>{a=!0,s.current&&s.current.dispose()}},[e.flowId,e.componentId]),C.jsx("div",{style:{height:"100%",overflow:"inherit"},ref:t})},Bt=()=>C.jsx("svg",{width:"80",viewBox:"0 0 525 243",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:C.jsx("path",{d:"M151.438 2.7168C177.625 2.76042 248.179 4.2832 300.4 56.7441C350.671 107.245 364.44 114.452 389.967 119.211C392.576 119.436 397.472 119.394 400.802 116.521C403.011 114.614 403.921 109.518 404.265 104.627V5.95996C404.265 4.85556 405.16 3.96023 406.265 3.95996H522.711C523.815 3.95996 524.711 4.85539 524.711 5.95996V122.405C524.711 123.51 523.815 124.405 522.711 124.405H421.998C418.579 124.728 413.852 125.627 410.974 128.095C407.879 130.748 407.042 137.805 406.845 142.661V240.414C406.845 241.436 406.111 242.292 405.093 242.38C366.548 245.717 277.079 228.462 235.837 173.668C202.909 129.919 173.882 122.474 151.458 122.077C150.354 122.058 149.459 121.164 149.459 120.06V4.71582C149.459 3.6114 150.334 2.71519 151.438 2.7168ZM62.2031 0C96.5566 0.000213148 124.405 27.8496 124.405 62.2031C124.405 96.5564 96.5564 124.405 62.2031 124.405C27.8496 124.405 0.000213175 96.5566 0 62.2031C0 27.8495 27.8495 0 62.2031 0Z",fill:"white"})}),$t=({opacity:e=1,fadeDuration:t=200,children:s})=>{if(s!==void 0){const i={...rn,opacity:e,transition:`opacity ${t}ms ease-out`};return C.jsx("div",{style:i,children:s})}const n={...nn,opacity:e,transition:`opacity ${t}ms ease-out`};return C.jsx("div",{style:n,children:C.jsx(Bt,{})})},Sn={position:"absolute",top:0,left:0,right:0,bottom:0},Wt=({children:e})=>e!==void 0?C.jsx("div",{style:Sn,children:e}):C.jsx("div",{style:on,children:C.jsx(Bt,{})}),Tn=e=>`on${e.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("")}`,Kt=e=>{var oe,Se,Te,xe,z,F;const t=w.useRef(null),s=w.useRef(null),n=w.useRef(!1),i=w.useRef(null),a=e.componentId?Nt(e.componentId):!1,[o,l]=w.useState(!a),[c,d]=w.useState(1),[u,h]=w.useState(!1),[f,y]=w.useState(!1),[m,M]=w.useState(void 0),I=e.autoSize??!0,[T,H]=w.useState({fillWidth:!1,fillHeight:!1}),P=w.useRef(!1),U=e.fadeDuration??200,X=w.useCallback(()=>{d(0),setTimeout(()=>{l(!1)},U)},[U]),A=w.useCallback(E=>{console.error("[MyopComponent] Error:",E),X(),h(!0),e.onError&&e.onError(E)},[X,e.onError]);w.useEffect(()=>{P.current=!1},[e.componentId]),w.useEffect(()=>{if(f&&e.data!==void 0&&s.current){if(!P.current){P.current=!0;return}const E=s.current.props.myop_init_interface;E&&E(e.data)}},[e.data,f]),w.useEffect(()=>{var Y,R,ee,te,k,L,D;if(!f||!((Y=s.current)!=null&&Y.observeAutoSize))return;let E=!0;return s.current.observeAutoSize({explicitWidth:(R=e.style)==null?void 0:R.width,explicitHeight:(ee=e.style)==null?void 0:ee.height,minWidth:(te=e.style)==null?void 0:te.minWidth,maxWidth:(k=e.style)==null?void 0:k.maxWidth,minHeight:(L=e.style)==null?void 0:L.minHeight,maxHeight:(D=e.style)==null?void 0:D.maxHeight,forceAutoSize:I,loaderMinHeight:50,onSizeChange:J=>{e.onSizeChange&&e.onSizeChange(J)===!1||(M(J),E&&(E=!1,X()))}})},[I,f,e.onSizeChange,(oe=e.style)==null?void 0:oe.width,(Se=e.style)==null?void 0:Se.height,(Te=e.style)==null?void 0:Te.minWidth,(xe=e.style)==null?void 0:xe.maxWidth,(z=e.style)==null?void 0:z.minHeight,(F=e.style)==null?void 0:F.maxHeight]),w.useEffect(()=>{let E=!1;n.current=!(t!=null&&t.current);const Y=async R=>{var ee,te,k,L;n.current=!0;try{if(!R.componentId&&!R.componentConfig){A("No component configuration provided");return}const D=await Ft().fetchComponentV2(R.componentId,R.environment,R.preview),J=await $e.loadComponent(D,t.current,{data:R.data,_environment:{props:{...R}}});if(E){J.dispose();return}if(s.current=J,await s.current.initiated(),E){s.current&&s.current.dispose();return}if(await new Promise(se=>requestAnimationFrame(se)),E||!s.current||s.current.markedForDisposed){s.current&&!s.current.markedForDisposed&&s.current.dispose();return}y(!0);const N=(ee=s.current)==null?void 0:ee.sizeMeta,fe=(N==null?void 0:N.width)==="100%",Ie=(N==null?void 0:N.height)==="100%";H({fillWidth:fe,fillHeight:Ie});const Ke=(fe||((te=e.style)==null?void 0:te.width))&&(Ie||((k=e.style)==null?void 0:k.height));(!I||Ke)&&X(),(L=s.current)!=null&&L.props&&(s.current.props.myop_cta_handler=(se,ye)=>{e.on&&e.on(se,ye);const xn=Tn(se),Ut=e[xn];typeof Ut=="function"&&Ut(ye)}),R.onLoad&&s.current&&R.onLoad(s.current)}catch(D){E||A((D==null?void 0:D.message)||"Unknown error")}finally{if(n.current=!1,i.current!==null&&!E){const D=i.current;i.current=null,await Y(D)}}};return n.current?i.current={...e}:Y(e).then(),()=>{E=!0,s.current&&s.current.dispose()}},[e.componentId]);const v=o?50:void 0,We=!I||!f||T.fillHeight;let Z,me;return We?(Z={position:"relative",width:"100%",height:"100%",minHeight:v,...e.style},me={position:"absolute",inset:0}):(Z={position:"relative",width:m!=null&&m.autoSizingWidth?m.width:"100%",height:(m==null?void 0:m.height)??void 0,minHeight:v,...e.style},me={width:"100%",height:(m==null?void 0:m.height)??void 0}),C.jsxs("div",{style:Z,children:[C.jsx("div",{ref:t,style:me}),o&&e.loader!==void 0&&C.jsx($t,{opacity:c,fadeDuration:U,children:e.loader}),u&&C.jsx(Wt,{children:e.fallback})]})};b.MyopComponent=Kt,b.MyopContainer=Cn,b.MyopFallback=Wt,b.MyopLoader=$t,b.MyopV2Container=Kt,b.enableLocalDev=wn,b.getCloudRepository=Ft,b.getPreloadedParams=vn,b.isPreloaded=Nt,b.preloadComponents=En,b.setCloudRepository=Mn,b.setCloudRepositoryUrl=_n,b.setEnvironment=bn,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
|
167
|
+
<\/script>`;u.writeln(E+S)}u.close();const D=new Rt(e,t,n,d,s);return D.sizeMeta=h,D.initiated().then(()=>{D.observeAutoSize({forceAutoSize:!0}),s!=null&&s.hidden||D.show()}),D}if(i.shadowRootMode===ue.none){const l=document.createElement("template");l.innerHTML=i.HTML,o=l.content.firstElementChild,zt().then(c=>{c.connectedCallback(o,o)})}else{const l=is(e.name+t.id);At.includes(l)||(ns(l,i.HTML,i.shadowRootMode),At.push(l)),o=document.createElement(l)}return n.querySelector('[id^="myop-comp-"]')||(n.innerHTML=""),o.id=a,s!=null&&s.hidden&&(o.style.opacity="0",o.style.position="absolute",o.style.height="0",o.style.width="0",o.style.pointerEvents="none",o.style.visibility="hidden"),this.appendChild(n,o,s),new kt(e,t,n,o,s)}))}isMyopWebComponent(e){return e.trimStart().startsWith(Zn)}extractWebComponentScript(e){const s=new DOMParser().parseFromString(e,"text/html").getElementById(es);return(s==null?void 0:s.textContent)||null}executeWebComponentScript(e,t){if(Pt.has(t)){console.log(`[MyopWebComponent] Script already executed for ${t}, skipping`);return}const n=document.createElement("script");n.textContent=e,n.id=`myop-extracted-${t}`,document.head.appendChild(n),Pt.add(t),console.log(`[MyopWebComponent] Executed web component script: ${t}`)}loadExtractedWebComponent(e,t,n,s,i){return v(this,null,function*(){const a=this.extractWebComponentScript(s);if(!a)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');const o=`${e.id}-${t.id}`,l=window.__MYOP_TAG_NAME__;this.executeWebComponentScript(a,o);const c=window.__MYOP_TAG_NAME__;if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");l&&l!==c&&console.warn(`[MyopWebComponent] __MYOP_TAG_NAME__ changed from ${l} to ${c}`);const d=`myop-comp-${J()}`,u=document.createElement(c);u.id=d,i!=null&&i.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),n.querySelector('[id^="myop-comp-"]')||(n.innerHTML=""),this.appendChild(n,u,i);const h=new We(e,t,n,u,c,i);return(i==null?void 0:i.data)!==void 0&&h.initWithData(i.data),console.log(`[MyopWebComponent] Loaded <${c}> into container`),h})}},rs=e=>({instance:{id:"auto",componentId:e.componentId,componentName:e.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:e.id,name:e.name,description:e.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:_e.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:_e.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:e.consume_variant[0].loader}],defaultSkin:0},name:e.name}),be="__MYOP_CLOUD_REPOSITORY_MAIN__",as=()=>{if(typeof window<"u")return window[be];if(typeof globalThis<"u")return globalThis[be]},ls=e=>{typeof window<"u"&&(window[be]=e),typeof globalThis<"u"&&(globalThis[be]=e)},Ft=class re{constructor(t="https://cloud.myop.dev"){this._baseUrl=t,r(this,"variants",{}),r(this,"preloadedComponents",{}),r(this,"userFlows",{}),r(this,"_defaultEnv","production"),r(this,"_envExplicitlySet",!1)}static get Main(){const t=as();return t||(re._main||(re._main=new re,ls(re._main)),re._main)}setEnvironment(t){this._defaultEnv=t,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(t,n,s){return n!==void 0||s!==void 0?`${t}:${n||this._defaultEnv}:${s?"preview":"live"}`in this.variants:t in this.preloadedComponents}getPreloadedParams(t){return this.preloadedComponents[t]}fetchComponentV2(t,n,s){return v(this,null,function*(){const i=this.preloadedComponents[t],a=n!==void 0||s!==void 0;let o,l;if(!a&&i)o=i.env,l=i.preview;else{o=n||this._defaultEnv;const d=n||this._envExplicitlySet;l=s===!0?!0:s===!1?!1:!d}const c=`${t}:${o}:${l?"preview":"live"}`;return console.log("[CloudRepository] fetchComponentV2",{componentId:t.slice(0,8)+"...",env:o,usePreview:l,cacheKey:c,cached:c in this.variants}),this.variants[c]||(this.preloadedComponents[t]||(this.preloadedComponents[t]={env:o,preview:l}),this.variants[c]=new Promise((d,u)=>v(this,null,function*(){try{let h=`${this._baseUrl}/consume?id=${t}&env=${o}`;l&&(h+="&preview=true");const f=(yield(yield fetch(h)).json()).item;if(!f){u(new Error(`Component "${t}" not found`));return}if(!f.consume_variant||!f.consume_variant.length){u(new Error(`Component "${t}" has no implementation for environment "${o}"`));return}const D=rs(f);d(D)}catch(h){u(h)}}))),yield this.variants[c]})}fetchComponentV1(t,n){return v(this,null,function*(){return n?(yield this.fetchFlow(n)).components.find(i=>i.type.id===t):(yield this.fetchAutoFlow(t)).components[0]})}fetchAutoFlow(t){return v(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((n,s)=>v(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&auto=true`)).json();n(a.item)}catch(i){s(i)}}))),yield this.userFlows[t]})}fetchFlow(t){return v(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((n,s)=>v(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&resolve=components`)).json();n(a.item)}catch(i){s(i)}}))),yield this.userFlows[t]})}fetchComponent(t,n){return v(this,null,function*(){return this.fetchComponentV1(t,n)})}};r(Ft,"_main",null);var je=Ft;je.Main;var cs=e=>v(void 0,null,function*(){try{const t=new URL(window.location.href),s=new URLSearchParams(t.search).get("myopOverride");if(s){const[i,...a]=tt(s);switch(i){case"component":{const[o,l]=a,c=yield je.Main.fetchComponent(o);if(c&&c.type.skins.find(u=>u.id===l))return c.instance.skinSelector={type:he.Dedicated,skin:{id:l}},c}break;default:{const[o,l]=tt(s),d=(yield je.Main.fetchFlow(o)).components.find(u=>u.type.id===e.type.id);if(d&&d.instance.skinSelector.type===he.Segmented&&d.instance.resolvedExperiences){const u=d.instance.resolvedExperiences.find(h=>h.id===l);if((u==null?void 0:u.type)===Et.Segment){const h=u,y=d.instance.skinSelector.segments.find(f=>f.segmentId===h.segment.id);if(y)return d.instance.skinSelector=y==null?void 0:y.skinSelector,d}}}break}}}finally{return null}}),Bt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",Ee=class{constructor(){r(this,"components2init",[]),r(this,"components",[]),r(this,"componentsLoaders",[]),r(this,"initiated",!1),r(this,"version",$n),r(this,"type2InstanceCount",{}),r(this,"assignId",e=>(this.type2InstanceCount[e.id]||(this.type2InstanceCount[e.id]=0),`${e.id}_${++this.type2InstanceCount[e.id]}`)),r(this,"inspected",!1),r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(e=>{e.inspect&&e.inspect()}))}),r(this,"incomingMessageHandler",e=>{if(e.origin,document.location.origin,e.data.myop){if(e.data.direction!==A.up&&e.data.messageType!==b.EnvelopedMessage)return;const t=e.data;if(t.messageType===b.InitRequest){this.components2init.forEach(s=>{s.send(new Fe(s.id))});return}if(t.messageType===b.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==t.content.id);const s=this.components.find(i=>{var a;return i.id===((a=t.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(t.messageType===b.EnvelopedMessage){const s=t,i=this.components.find(a=>a.id===s.destination);if(i){if(s.direction===A.down){s.message.messageType===j.name?i.onMessageReceived(s.message):(s.message.route=s.route,i.send(s.message));return}}else{const a=this.components.find(o=>o.id===s.message.destination);a&&a.send(s.message)}return}const n=this.components.find(s=>s.id===t.destination);if(!n){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(n){if(n.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}}),r(this,"send",e=>{const t=new MessageEvent("",{data:e});this.incomingMessageHandler(t)}),r(this,"init",e=>{if(this.initiated)throw new Error("hostSDK already initiated");const t=[new Bn,new Nn,new os];if(this.componentsLoaders=[...t],e){const n={};e.forEach(s=>{const i=new s(this.componentsLoaders);n[i.type]=i}),this.componentsLoaders.forEach(s=>{n[s.type]||(n[s.type]=s)}),this.componentsLoaders=Object.values(n)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0}),r(this,"_getSkinIdBySkinSelector",(e,...t)=>v(this,[e,...t],function*(n,s=[],i){var a;function o(l,c){return v(this,null,function*(){for(const d of l)if(yield c(d))return d})}switch(n.type){case"DedicatedSkin":case he.Dedicated:return((a=n.skin)==null?void 0:a.id)||n.skins[0].id;case he.Segmented:{const c=yield o(n.segments,d=>v(this,null,function*(){if(d.segmentId==="Default")return!0;const u=s.find(f=>f.type===Et.Segment?f.segment.id===d.segmentId:!1);if(!u)throw new Error("experience not found");const m=u.segment,y=(i||{})[m.function];return y?yield y():(console.warn(`segmentId:${d.segmentId}, ${m.function} function not provided !`),!1)}));if(c)return this._getSkinIdBySkinSelector(c.skinSelector,s);debugger}break;default:debugger}return""})),r(this,"runSkinSelector",(e,t)=>v(this,null,function*(){const n=yield this._getSkinIdBySkinSelector(e.instance.skinSelector,e.instance.resolvedExperiences,t);return e.type.skins.find(s=>s.id===n)})),r(this,"loaderHooks"),r(this,"loadComponent",(e,t,n)=>v(this,null,function*(){var s,i,a,o;if(!t){debugger;throw new Error("no container was found for this component")}const l=yield cs(e);l&&(e=l);const c=T(T({},(s=this.loaderHooks)!=null?s:{}),(i=n==null?void 0:n.hooks)!=null?i:{}),d=t;if(d.myop)if(d.component){e=T({},e),e.instance=T({},e.instance);let y=yield this.runSkinSelector(e,c);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(a=n==null?void 0:n.hooks)!=null&&a.afterSkinSelected&&(y=yield n.hooks.afterSkinSelected(T({},y))),e.instance.skinSelector={type:he.Dedicated,skin:y},n&&(n=T({},n),delete n.hooks),yield It(d,e,this.components,n)}else throw new Error("load component got a detached ref.");t=t;let u=yield this.runSkinSelector(e,c);if(!u)throw new Error("runSkinSelector failed to choose skin, check the provided config");(o=n==null?void 0:n.hooks)!=null&&o.afterSkinSelected&&(u=yield n.hooks.afterSkinSelected(T({},u)));const h=this.componentsLoaders.find(y=>y.type===u.loader.type);if(!h){debugger;throw new Error(`no loader "${u.loader.type}" was found for component`)}let m=yield h.load(e.type,u,t,n);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==m),this.components2init=this.components2init.filter(y=>y!==m),!0)),this.components.push(m),(!n||n.connectProps!==!1)&&(m=An(m,e.type.props,u));try{yield Ht(m,e,this.components)}catch(y){throw y}return n!=null&&n.skipInit||(yield m.initiated()),m})),r(this,"navigate",(e,t,n)=>v(this,null,function*(){if(e.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(n!=null&&n.staged){let s=yield this.loadComponent(t,e.container,T({hidden:!0,relative:{direction:"after",child:e.element}},n));return n.init&&(yield n.init(s)),s.show(),e.dispose(),s}else{const s=e.element.nextSibling;return e.dispose(),this.loadComponent(t,e.container,T({relative:{direction:"before",child:s}},n))}}))}};if(r(Ee,"Instance",()=>window.myop.hostSDK),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Bt}),!window.myop.hostSDK){const e=new Ee;e.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Bt}),window.myop.hostSDK=e}var Ve=window.myop.hostSDK;et("hostSDK",Ve);var ds="linear-gradient(135deg, #FF8651 0%, #FFBEA8 50%, #A397F5 100%)",us="linear-gradient(135deg, #9CA3AF 0%, #D1D5DB 50%, #E5E7EB 100%)",hs={position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,background:ds,display:"flex",justifyContent:"center",alignItems:"center"},ps={position:"absolute",top:0,left:0,right:0,bottom:0,background:us,display:"flex",justifyContent:"center",alignItems:"center"},ms={position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,display:"flex",justifyContent:"center",alignItems:"center"},fs=Object.defineProperty,ys=(e,t,n)=>t in e?fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t,n)=>ys(e,typeof t!="symbol"?t+"":t,n),$=(e,t,n)=>new Promise((s,i)=>{var a=c=>{try{l(n.next(c))}catch(d){i(d)}},o=c=>{try{l(n.throw(c))}catch(d){i(d)}},l=c=>c.done?s(c.value):Promise.resolve(c.value).then(a,o);l((n=n.apply(e,t)).next())}),V=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),gs=class{constructor(){p(this,"id",V()),p(this,"myop",!0),p(this,"content"),p(this,"source"),p(this,"destination"),p(this,"route"),p(this,"ref"),p(this,"direction"),p(this,"cleanable",!1)}static create(...e){return new this(...e)}isTypeof(e){return e.messageType===this.messageType}},vs=class extends gs{constructor(e){super(),this.handler=e,p(this,"handlerUniqueId",V())}},ws="ExecuteScriptReplyMessage",_s=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Ms=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,bs=e=>{let t=e.match(_s);if(t)return t[1]||t[3];{let n=e.match(Ms);if(n)return n[1].trim()}},Nt=class extends vs{constructor(e,t=()=>{},n){super(t),this.scriptInputs=n,p(this,"replyMessageKey",ws),p(this,"messageType","ExecuteScriptMessage"),p(this,"script",""),this.script=e.toString(),this.content=e.toString(),this.content=bs(this.content)}};p(Nt,"replierKey","send"),p(Nt,"completeStreamKey","completeStream");var $t=class{constructor(){p(this,"_runTimeInstanceId","runtime-instance-id-"+V()),p(this,"_runTimeId","runtime-id-"+V()),p(this,"_runTimeName","runtime-name-"+V()),p(this,"id",this._runTimeId),p(this,"name",this._runTimeName),p(this,"description",""),p(this,"loader",null),p(this,"withLoader",t=>(this.loader=t,this)),p(this,"withHTMLLoader",t=>(t.type="HTMLLoader",this.loader=t,this)),p(this,"build",()=>this)}};p($t,"create",()=>new $t);var Wt=class{constructor(){p(this,"_runTimeInstanceId","runtime-instance-id-"+V()),p(this,"_runTimeId","runtime-id-"+V()),p(this,"_runTimeName","runtime-name-"+V()),p(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null}),p(this,"name",this._runTimeName),p(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0}),p(this,"withInstance",t=>(this.instance=t,this)),p(this,"withType",t=>(this.type=t,this)),p(this,"withName",t=>(this.name=t,this)),p(this,"withDefaultSkin",t=>(this.type.skins.push(t),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:t.id}},this)),p(this,"withRef",t=>(this.type.refs.push(t),this)),p(this,"withBasicRef",t=>{const n={id:"",name:t,description:"",selectorType:"id-attribute",selector:t,behavior:{type:"code"}};return this.type.refs.push(n),this}),p(this,"build",()=>JSON.parse(JSON.stringify(this)))}};p(Wt,"create",()=>new Wt);var Kt={code:"code"},Es=e=>({instance:{id:"auto",componentId:e.componentId,componentName:e.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:e.id,name:e.name,description:e.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:Kt.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:Kt.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:e.consume_variant[0].loader}],defaultSkin:0},name:e.name}),Ce="__MYOP_CLOUD_REPOSITORY_MAIN__",Cs=()=>{if(typeof window<"u")return window[Ce];if(typeof globalThis<"u")return globalThis[Ce]},Ss=e=>{typeof window<"u"&&(window[Ce]=e),typeof globalThis<"u"&&(globalThis[Ce]=e)},Ut=class ae{constructor(t="https://cloud.myop.dev"){this._baseUrl=t,p(this,"variants",{}),p(this,"preloadedComponents",{}),p(this,"userFlows",{}),p(this,"_defaultEnv","production"),p(this,"_envExplicitlySet",!1)}static get Main(){const t=Cs();return t||(ae._main||(ae._main=new ae,Ss(ae._main)),ae._main)}setEnvironment(t){this._defaultEnv=t,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(t,n,s){return n!==void 0||s!==void 0?`${t}:${n||this._defaultEnv}:${s?"preview":"live"}`in this.variants:t in this.preloadedComponents}getPreloadedParams(t){return this.preloadedComponents[t]}fetchComponentV2(t,n,s){return $(this,null,function*(){const i=this.preloadedComponents[t],a=n!==void 0||s!==void 0;let o,l;if(!a&&i)o=i.env,l=i.preview;else{o=n||this._defaultEnv;const d=n||this._envExplicitlySet;l=s===!0?!0:s===!1?!1:!d}const c=`${t}:${o}:${l?"preview":"live"}`;return console.log("[CloudRepository] fetchComponentV2",{componentId:t.slice(0,8)+"...",env:o,usePreview:l,cacheKey:c,cached:c in this.variants}),this.variants[c]||(this.preloadedComponents[t]||(this.preloadedComponents[t]={env:o,preview:l}),this.variants[c]=new Promise((d,u)=>$(this,null,function*(){try{let h=`${this._baseUrl}/consume?id=${t}&env=${o}`;l&&(h+="&preview=true");const f=(yield(yield fetch(h)).json()).item;if(!f){u(new Error(`Component "${t}" not found`));return}if(!f.consume_variant||!f.consume_variant.length){u(new Error(`Component "${t}" has no implementation for environment "${o}"`));return}const D=Es(f);d(D)}catch(h){u(h)}}))),yield this.variants[c]})}fetchComponentV1(t,n){return $(this,null,function*(){return n?(yield this.fetchFlow(n)).components.find(i=>i.type.id===t):(yield this.fetchAutoFlow(t)).components[0]})}fetchAutoFlow(t){return $(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((n,s)=>$(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&auto=true`)).json();n(a.item)}catch(i){s(i)}}))),yield this.userFlows[t]})}fetchFlow(t){return $(this,null,function*(){return this.userFlows[t]||(this.userFlows[t]=new Promise((n,s)=>$(this,null,function*(){try{const a=yield(yield fetch(`${this._baseUrl}/flow?id=${t}&resolve=components`)).json();n(a.item)}catch(i){s(i)}}))),yield this.userFlows[t]})}fetchComponent(t,n){return $(this,null,function*(){return this.fetchComponentV1(t,n)})}};p(Ut,"_main",null);var Se=Ut,G=Se.Main,qt=()=>G,jt=(e,t,n)=>G.isPreloaded(e,t,n),xs=e=>G.getPreloadedParams(e),Ts=()=>{G=new Se("http://localhost:9292")},Is=e=>{G=new Se(e)},Hs=e=>{G=e},Rs=e=>{G.setEnvironment(e)},Ds=(e,t,n)=>$(void 0,null,function*(){return Promise.allSettled(e.map(s=>G.fetchComponentV2(s,t,n)))});const ks=e=>{const t=M.useRef(null),n=M.useRef(null),s=M.useRef(!1),i=M.useRef(null);return M.useEffect(()=>{let a=!1;s.current=!(t!=null&&t.current);const o=async l=>{s.current=!0;try{const c=await Se.Main.fetchComponent(l.componentId,l.flowId);n.current=await Ve.loadComponent(c,t.current,{_environment:{props:{...l}}}),a?n.current&&n.current.dispose():l.onReady&&l.onReady(n.current)}catch{}finally{if(s.current=!1,i.current!==null&&!a){const c=i.current;i.current=null,await o(c)}}};return s.current?i.current={...e}:o(e).then(),()=>{a=!0,n.current&&n.current.dispose()}},[e.flowId,e.componentId]),x.jsx("div",{style:{height:"100%",overflow:"inherit"},ref:t})},Vt=()=>x.jsx("svg",{width:"80",viewBox:"0 0 525 243",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:x.jsx("path",{d:"M151.438 2.7168C177.625 2.76042 248.179 4.2832 300.4 56.7441C350.671 107.245 364.44 114.452 389.967 119.211C392.576 119.436 397.472 119.394 400.802 116.521C403.011 114.614 403.921 109.518 404.265 104.627V5.95996C404.265 4.85556 405.16 3.96023 406.265 3.95996H522.711C523.815 3.95996 524.711 4.85539 524.711 5.95996V122.405C524.711 123.51 523.815 124.405 522.711 124.405H421.998C418.579 124.728 413.852 125.627 410.974 128.095C407.879 130.748 407.042 137.805 406.845 142.661V240.414C406.845 241.436 406.111 242.292 405.093 242.38C366.548 245.717 277.079 228.462 235.837 173.668C202.909 129.919 173.882 122.474 151.458 122.077C150.354 122.058 149.459 121.164 149.459 120.06V4.71582C149.459 3.6114 150.334 2.71519 151.438 2.7168ZM62.2031 0C96.5566 0.000213148 124.405 27.8496 124.405 62.2031C124.405 96.5564 96.5564 124.405 62.2031 124.405C27.8496 124.405 0.000213175 96.5566 0 62.2031C0 27.8495 27.8495 0 62.2031 0Z",fill:"white"})}),Gt=({opacity:e=1,fadeDuration:t=200,children:n})=>{if(n!==void 0){const i={...ms,opacity:e,transition:`opacity ${t}ms ease-out`};return x.jsx("div",{style:i,children:n})}const s={...hs,opacity:e,transition:`opacity ${t}ms ease-out`};return x.jsx("div",{style:s,children:x.jsx(Vt,{})})},Ls={position:"absolute",top:0,left:0,right:0,bottom:0},Yt=({children:e})=>e!==void 0?x.jsx("div",{style:Ls,children:e}):x.jsx("div",{style:ps,children:x.jsx(Vt,{})}),Os=e=>`on${e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}`,Jt=e=>{var se,xe,ie,Te,Ie,He;const t=M.useRef(null),n=M.useRef(null),s=M.useRef(!1),i=M.useRef(null),a=e.componentId?jt(e.componentId):!1,[o,l]=M.useState(!a),[c,d]=M.useState(1),[u,h]=M.useState(!1),[m,y]=M.useState(!1),[f,D]=M.useState(void 0),E=e.autoSize??!0,[w,S]=M.useState({fillWidth:!1,fillHeight:!1}),z=M.useRef(!1),W=e.fadeDuration??200,Q=M.useCallback(()=>{d(0),setTimeout(()=>{l(!1)},W)},[W]),me=M.useCallback(_=>{console.error("[MyopComponent] Error:",_),Q(),h(!0),e.onError&&e.onError(_)},[Q,e.onError]);M.useEffect(()=>{z.current=!1},[e.componentId]),M.useEffect(()=>{if(m&&e.data!==void 0&&n.current){if(!z.current){z.current=!0;return}const _=n.current.props.myop_init_interface;_&&_(e.data)}},[e.data,m]),M.useEffect(()=>{var L,R,Y,K,X,Z,I;if(!m||!((L=n.current)!=null&&L.observeAutoSize))return;let _=!0;return n.current.observeAutoSize({explicitWidth:(R=e.style)==null?void 0:R.width,explicitHeight:(Y=e.style)==null?void 0:Y.height,minWidth:(K=e.style)==null?void 0:K.minWidth,maxWidth:(X=e.style)==null?void 0:X.maxWidth,minHeight:(Z=e.style)==null?void 0:Z.minHeight,maxHeight:(I=e.style)==null?void 0:I.maxHeight,forceAutoSize:E,loaderMinHeight:50,onSizeChange:O=>{e.onSizeChange&&e.onSizeChange(O)===!1||(D(O),_&&(_=!1,Q()))}})},[E,m,e.onSizeChange,(se=e.style)==null?void 0:se.width,(xe=e.style)==null?void 0:xe.height,(ie=e.style)==null?void 0:ie.minWidth,(Te=e.style)==null?void 0:Te.maxWidth,(Ie=e.style)==null?void 0:Ie.minHeight,(He=e.style)==null?void 0:He.maxHeight]),M.useEffect(()=>{let _=!1;s.current=!(t!=null&&t.current);const L=async R=>{var Y,K,X,Z;s.current=!0;try{if(!R.componentId&&!R.componentConfig){me("No component configuration provided");return}const I=await qt().fetchComponentV2(R.componentId,R.environment,R.preview),O=await Ve.loadComponent(I,t.current,{data:R.data,_environment:{props:{...R}}});if(_){O.dispose();return}if(n.current=O,await n.current.initiated(),_){n.current&&n.current.dispose();return}if(await new Promise(ee=>requestAnimationFrame(ee)),_||!n.current||n.current.markedForDisposed){n.current&&!n.current.markedForDisposed&&n.current.dispose();return}y(!0);const U=(Y=n.current)==null?void 0:Y.sizeMeta,P=(U==null?void 0:U.width)==="100%",Re=(U==null?void 0:U.height)==="100%";S({fillWidth:P,fillHeight:Re});const De=(P||((K=e.style)==null?void 0:K.width))&&(Re||((X=e.style)==null?void 0:X.height));(!E||De)&&Q(),(Z=n.current)!=null&&Z.props&&(n.current.props.myop_cta_handler=(ee,ge)=>{e.on&&e.on(ee,ge);const ke=Os(ee),oe=e[ke];typeof oe=="function"&&oe(ge)}),R.onLoad&&n.current&&R.onLoad(n.current)}catch(I){_||me((I==null?void 0:I.message)||"Unknown error")}finally{if(s.current=!1,i.current!==null&&!_){const I=i.current;i.current=null,await L(I)}}};return s.current?i.current={...e}:L(e).then(),()=>{_=!0,n.current&&n.current.dispose()}},[e.componentId]);const fe=o?50:void 0,k=!E||!m||w.fillHeight;let g,ye;return k?(g={position:"relative",width:"100%",height:"100%",minHeight:fe,...e.style},ye={position:"absolute",inset:0}):(g={position:"relative",width:f!=null&&f.autoSizingWidth?f.width:"100%",height:(f==null?void 0:f.height)??void 0,minHeight:fe,...e.style},ye={width:"100%",height:(f==null?void 0:f.height)??void 0}),x.jsxs("div",{style:g,children:[x.jsx("div",{ref:t,style:ye}),o&&e.loader!==void 0&&x.jsx(Gt,{opacity:c,fadeDuration:W,children:e.loader}),u&&x.jsx(Yt,{children:e.fallback})]})};C.MyopComponent=Jt,C.MyopContainer=ks,C.MyopFallback=Yt,C.MyopLoader=Gt,C.MyopV2Container=Jt,C.enableLocalDev=Ts,C.getCloudRepository=qt,C.getPreloadedParams=xs,C.isPreloaded=jt,C.preloadComponents=Ds,C.setCloudRepository=Hs,C.setCloudRepositoryUrl=Is,C.setEnvironment=Rs,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})}));
|