@myop/sdk 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var st=Object.defineProperty,kt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var ot=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var Be=(o,n,e)=>n in o?st(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Bt.call(n,e)&&Be(o,e,n[e]);if(ot)for(var e of ot(n))Dt.call(n,e)&&Be(o,e,n[e]);return o},E=(o,n)=>kt(o,Ht(n));var Lt=(o,n)=>{for(var e in n)st(o,e,{get:n[e],enumerable:!0})};var i=(o,n,e)=>Be(o,typeof n!="symbol"?n+"":n,e);var re=class{constructor(n,e,t,s,r){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var rt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},De=class{constructor(n){this.messageToHost=n}},ie=class extends De{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var f={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 ae={};Lt(ae,{AddEventListenerMessage:()=>Ke,BaseMyopMessage:()=>y,BindClickMessage:()=>Pe,ChangeTextMessage:()=>Oe,CleanupMessage:()=>Y,CleanupReplayMessage:()=>ee,ClickReplayMessage:()=>V,CreateRefComponentMessage:()=>X,CustomRefMessage:()=>O,DetectMyopRefsMessage:()=>Ue,DetectedMyopRefsMessage:()=>Z,DisposeMessage:()=>te,ElementValueReplayMessage:()=>j,EnvelopedMessage:()=>Q,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>S,ExecuteScriptMessage:()=>T,ExecuteScriptReplyMessage:()=>W,GetAttributeMessage:()=>ze,GetAttributeReplayMessage:()=>Ne,GetElementValueMessage:()=>$e,InitMessage:()=>$,InitRequest:()=>J,InitResponse:()=>G,MessageDirection:()=>b,MutationObserverMessage:()=>We,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>C,MyopElementMessage:()=>_e,Ref:()=>B,RefComponentCreatedMessage:()=>A,ResizeObserverMessage:()=>je,SetAttributeMessage:()=>Fe,SetInnerHtml:()=>Ae,SetMutationObserverMessage:()=>Ve,SetResizeObserverMessage:()=>qe,stripFunction:()=>dt});var w=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var _t=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Pt=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Le=o=>{let n=Pt(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(_t(n.slice(t,t+16)));return e};var it=o=>new Promise(n=>setTimeout(n,o));var b=class{};i(b,"down","down"),i(b,"up","up");var y=class{constructor(){i(this,"id",w());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}},_e=class extends y{constructor(e){super();this.ref=e}},C=class extends y{constructor(e){super();this.replayToHandler=e}},x=class extends y{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",w())}},B=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=E(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var at="ClickReplayMessage",Pe=class extends x{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",at);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},V=class extends C{constructor(){super(...arguments);i(this,"messageType",at)}};var Oe=class extends y{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}};var pt="ExecuteScriptReplyMessage",Ot=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Kt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,dt=o=>{let n=o.match(Ot);if(n)return n[1]||n[3];{let e=o.match(Kt);if(e)return e[1].trim()}},T=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",pt);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=dt(this.content)}};i(T,"replierKey","send"),i(T,"completeStreamKey","completeStream");var W=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",pt)}};var O=class extends T{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=E(h({},t),{_script:e.toString()})}};var ct="EventListenerCallbackMessage",Ke=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",ct);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},q=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",ct);this.content={e:t}}};var Fe=class extends y{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}};var mt="ElementValueReplayMessage",$e=class extends x{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",mt);i(this,"messageType","GetElementValueMessage")}},j=class extends C{constructor(e){super();this.content=e;i(this,"messageType",mt)}};var Ae=class extends y{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}};var $=class extends y{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},G=class extends ${constructor(){super(...arguments);i(this,"messageType","InitResponse")}},J=class extends y{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var lt="RefComponentCreatedMessage",X=class extends x{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",lt);i(this,"messageType","CreateRefComponentMessage")}},A=class extends C{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",lt)}};var Q=class extends y{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 ft="DetectedMyopRefsMessage",Ue=class extends x{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",ft)}},Z=class extends C{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",ft);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var gt="GetAttributeReplayMessage",ze=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",gt);i(this,"messageType","GetAttributeMessage")}},Ne=class extends C{constructor(e){super();this.content=e;i(this,"messageType",gt)}};var S=class extends y{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}};var Ve=class extends y{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},We=class extends y{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ut="CleanupReplayMessage",Y=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",ut);i(this,"messageType","CleanupMessage")}},ee=class extends C{constructor(e){super();this.customCleanup=e;i(this,"messageType",ut)}};var te=class extends y{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var qe=class extends y{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},je=class extends y{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var Ge=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},pe=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===f.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===f.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new Ge(s),this.messageToHost(new G(s));return}if(t.messageType===f.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===f.CleanupMessage){let r=t,a=this.messageCleanupCache[r.cleanupForMessageId],p=new ee(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],rt(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 v={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var K={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var Je={message:"message",code:"code"},U=class{};i(U,"code","code"),i(U,"component","component");var F={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ce={Segment:"Segment",Promo:"Promo",AB:"AB"},de=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 me={webcomponent_message_key:"myop_webcomponent_message"};var M=class extends ie{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(E(h({},r),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var k={id:"myop-id"};var R=(o,n)=>n.querySelectorAll("[".concat(k.id,"='").concat(o.refConfig.selector,"']"));var le=class extends M{constructor(){super(...arguments);i(this,"messageType",f.BindClickMessage);i(this,"innerExecutor",(e,t,s)=>{let r=R(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new V(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var fe=class extends M{constructor(){super(...arguments);i(this,"messageType",f.ChangeTextMessage);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.textContent=e.content})})}};var ge=class extends de{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var ue=class extends M{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(k.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(k.id);p&&r.push(new re(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Z(e.handlerUniqueId,r))});i(this,"messageType",f.DetectMyopRefsMessage)}};var ye="__federation__",yt="onLoad";var he=(o,n)=>{window[ye]&&window[ye][o]&&window[ye][o][yt]&&window[ye][o][yt]({[o]:n})};var Me=class extends M{constructor(){super(...arguments);i(this,"messageType",f.SetAttributeMessage);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var Xe=o=>o!==Object(o),Ft=o=>typeof o=="function",Qe=o=>{if(Xe(o))return!0;if(Ft(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!Qe(e))return!1}else{if(Xe(e))continue;return!1}}return!0},H=(o,n={},e=!0,t=new WeakMap)=>{if(Xe(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=H(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(e?o[r]!==void 0:o[r])&&(s[r]=H(o[r],!0,e,t)):typeof a=="object"&&(s[r]=H(o[r],a,e,t)))}return s}return{}};var Ie=class extends M{constructor(){super(...arguments);i(this,"messageType",f.AddEventListenerMessage);i(this,"innerExecutor",(e,t,s)=>{let r=R(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=c=>{s(new q(e.handlerUniqueId,H(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var D=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});i(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>e(a)?(t(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(t==null?void 0:t.id)||L.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===f.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=b.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Y(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new te);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var ht={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 ne=class extends D{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 Q(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new S("dispose")),super.dispose()})}hide(){this.send(new S("hide"))}show(){this.send(new S("show"))}inspect(){return this.send(new S("inspect"))}setHeightBasedOnDocumentElement(){this.send(new S("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new S("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var $t=(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},Ce=(o,n,e,t,s,r)=>{let a=$t("".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)}},Mt=(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),It=(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."))},Ct=(o,n,e)=>{let t=n.reduce((r,a)=>E(h({},r),{[a.name]:h({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(Mt(p,a,o))return!1;if(p.behavior.type===Je.code){if(e.loader.type===v.HTMLLoader&&e.loader.shadowRootMode===K.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return It(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(B.create(p.behavior.ref)),c.push(l=>{d(l)}),p.behavior.params&&c.push(...p.behavior.params);let m=ae[p.behavior.message];o.send(new m(...c))}):null},set:(r,a,p)=>{let d=t[a];if(Mt(d,a,o))return!1;if(d.behavior.type===Je.code){if(e.loader.type===v.HTMLLoader&&e.loader.shadowRootMode===K.localFrame){let m=d.behavior;return o.element.contentWindow[m.remap||a]=p,!0}return It(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(B.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let m=ae[d.behavior.message];return o.send(new m(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},At=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{Qe(p)||ht.notSerializableRefCall(t,p)}),n.send(new O(({ref:p,propName:d,functionArgs:c,makeSerializable:m})=>{if(p){let l=p[d];return m(typeof l=="function"?p[d](...c):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new O(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),Ze=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 ne(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new X(o.refConfig,n,E(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let m=e.find(l=>l.id==p.id);if(m!==p){s.refs[o.refConfig.name]=m,r(m);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(I=>I.type.id===l.componentDefinitionId).type,u=new ne(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await Ye(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(l){a(l)}}))})},Ye=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==U.component){if(t){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=B.create("",r,o);try{let g=await Ze(l,m,e);o.refs[r.name]=g,a()}catch(g){p(g)}}else try{let c=B.create("",r,o);o.refs[r.name]=At(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}};var z=class extends D{constructor(e,t,s,r,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=r;i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new T(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});i(this,"observeSizeBasedOnDocumentElement",()=>this.send(new T(({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,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new T(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new T(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});i(this,"send",e=>{var r,a;let t=h({},e);if(t.messageType===f.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let s=super.send(t);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(t,"*"),s});i(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Ce(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===f.In.MutationObserverMessage||e.messageType===f.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var _=class{constructor(){i(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let r=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,r||null)}}else return n.appendChild(e)})}};var Ut=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},xe=class extends _{constructor(){super(...arguments);i(this,"type",v.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=w(),c="myop-comp-".concat(d);a=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(a.style.visibility="hidden"),a=this.appendChild(s,a,r);let m=t.loader.url;r!=null&&r._hasParent&&(m=Ut(m,"_myop-comp",d));let l="";r!=null&&r.elementAttributes&&(l=Object.entries(r==null?void 0:r.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(c,'"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(p.autoHeight||!p.height?"":p.height,"; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",';\n "\n src="').concat(m,'"\n ').concat(l,"\n ></iframe>"),a=s.querySelector("#".concat(c))}return new z(e,t,s,a,r)})}};var N=class extends D{constructor(e,t,s,r,a){super(e,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=h({},e),s=super.send(t),r=new CustomEvent(me.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=Ce(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var et={},be=class extends _{constructor(){super(...arguments);i(this,"type",v.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;et[a.url]?console.log("Module alreday loaded or in loading process"):et[a.url]=new Promise((c,m)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{c()},g.onerror=()=>{m()},document.head.appendChild(g)}),await et[a.url],await it(1);let p="myop-comp-".concat(w()),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 N(e,t,s,d,r)})}};var xt="0.2.4";var bt=[],Te,Tt=async()=>(Te||(Te=new oe,Te.init()),Te);function zt(o,n){return class extends HTMLElement{connectedCallback(){let e=n===K.open?"open":"closed",t=this.attachShadow({mode:e});Tt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var Nt=(o,n,e)=>{customElements.define(o,zt(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Vt=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Wt=o=>(o=Vt(o),o.replace(/_/g,"-"));var we=class extends _{constructor(){super(...arguments);i(this,"type",v.HTMLLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader,p="myop-comp-".concat(w()),d;if(a.shadowRootMode===K.localFrame){let c=w(),m="myop-comp-".concat(c),l=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(l.style.visibility="hidden"),l=this.appendChild(s,l,r),l.id=m,l.setAttribute("style","\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ")),s.appendChild(l);let g=l.contentDocument||l.contentWindow.document;g.open();let u=a.HTML;if(r!=null&&r._inspection){let P=new DOMParser().parseFromString(a.HTML,"text/html"),He=P.getElementById("myop_preview");He==null||He.removeAttribute("type");let tt=P.implementation.createHTMLDocument();tt.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let nt=tt.body.firstChild;nt&&P.head&&P.head.insertBefore(P.importNode(nt,!0),P.head.firstChild),u=P.documentElement.outerHTML}g.writeln(u),g.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>\n <script>\n \n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n \n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n \n __myop_init().then();\n \n <\/script>')),g.close();let I=new z(e,t,s,l,r);return a.autoHeight&&(l.onload=()=>{I.observeSizeBasedOnDocumentElement()}),I}if(a.shadowRootMode===K.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Tt().then(m=>{m.connectedCallback(d,d)})}else{let c=Wt(e.name+t.id);bt.includes(c)||(Nt(c,a.HTML,a.shadowRootMode),bt.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 N(e,t,s,d,r)})}};var Se=class Se{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"variants",{});i(this,"userFlows",{})}isPreloaded(n){return n in this.variants}async fetchComponentV2(n,e){return this.variants[n]||(this.variants[n]=new Promise(async(t,s)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(e))).json();t(a.item)}catch(r){s(r)}})),await this.variants[n]}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(Se,"Main",new Se);var se=Se;var wt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=Le(t);switch(s){case"component":{let[a,p]=r,d=await se.Main.fetchComponent(a);if(d&&d.type.skins.find(m=>m.id===p))return d.instance.skinSelector={type:F.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=Le(t),c=(await se.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===F.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(l=>l.id===p);if((m==null?void 0:m.type)===ce.Segment){let l=m,u=c.instance.skinSelector.segments.find(I=>I.segmentId===l.segment.id);if(u)return c.instance.skinSelector=u==null?void 0:u.skinSelector,c}}}break}}}finally{return null}};var St="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",L=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",xt);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==f.EnvelopedMessage)return;let e=n.data;if(e.messageType===f.InitRequest){this.components2init.forEach(s=>{s.send(new $(s.id))});return}if(e.messageType===f.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===f.EnvelopedMessage){let s=e,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===b.down){s.message.messageType===S.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 xe,new be,new we];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 F.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case F.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(u=>u.type===ce.Segment?u.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let l=c.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});i(this,"loaderHooks");i(this,"loadComponent",async(n,e,t)=>{var m,l,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await wt(n);s&&(n=s);let r=h(h({},(m=this.loaderHooks)!=null?m:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let I=await this.runSkinSelector(n,r);if(!I)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(I=await t.hooks.afterSkinSelected(h({},I))),n.instance.skinSelector={type:F.Dedicated,skin:I},t&&(t=h({},t),delete t.hooks),await Ze(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,r);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(I=>I.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(I=>I!==c),this.components2init=this.components2init.filter(I=>I!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=Ct(c,n.type.props,p));try{await Ye(c,n,this.components)}catch(I){throw I}return t!=null&&t.skipInit||await c.initiated(),c});i(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};i(L,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:St});if(!window.myop.hostSDK){let o=new L;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:St}),window.myop.hostSDK=o}var qt=window.myop.hostSDK;he("hostSDK",qt);var Re=class extends M{constructor(){super(...arguments);i(this,"messageType",f.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(k.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=L.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let m=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(m.refs).forEach(g=>{let u=m.refs[g];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),s(new A(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new A(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Rt=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=H,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)};var Ee=class extends M{constructor(){super(...arguments);i(this,"messageType",f.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{Rt(e,a=>{s(new W(e.handlerUniqueId,a))},t)})}};var Et=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(k.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Et(r),required:r.required,validity:H(r.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},ve=class extends M{constructor(){super(...arguments);i(this,"messageType",f.GetElementValueMessage);i(this,"innerExecutor",(e,t,s)=>{R(e.ref,t.shadowRoot).forEach(a=>{s(new j(Et(a)),e)})})}};var ke=class extends M{constructor(){super(...arguments);i(this,"messageType",f.SetInnerHtml);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.innerHTML=e.content})})}};var oe=class extends pe{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(me.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===f.InitMessage){let p=a.content.id;this.components[p].context=new ge(e,t)}}}),setTimeout(()=>{this.messageToHost(new J)},1)});i(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new fe(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new le(this.messageToHost,this.components),new ue(this.messageToHost,this.components),new Me(this.messageToHost,this.components),new Ie(this.messageToHost,this.components),new Ee(this.messageToHost,this.components),new ve(this.messageToHost,this.components),new Re(this.messageToHost,this.components)]);i(this,"init",()=>{})}};he("WebComponentSDK",oe);export{oe as WebComponentSDK};
1
+ var st=Object.defineProperty,kt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var ot=Object.getOwnPropertySymbols;var Bt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var Be=(o,n,e)=>n in o?st(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Bt.call(n,e)&&Be(o,e,n[e]);if(ot)for(var e of ot(n))Dt.call(n,e)&&Be(o,e,n[e]);return o},E=(o,n)=>kt(o,Ht(n));var Lt=(o,n)=>{for(var e in n)st(o,e,{get:n[e],enumerable:!0})};var i=(o,n,e)=>Be(o,typeof n!="symbol"?n+"":n,e);var re=class{constructor(n,e,t,s,r){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var rt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},De=class{constructor(n){this.messageToHost=n}},ie=class extends De{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var f={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 ae={};Lt(ae,{AddEventListenerMessage:()=>Ke,BaseMyopMessage:()=>y,BindClickMessage:()=>Pe,ChangeTextMessage:()=>Oe,CleanupMessage:()=>Y,CleanupReplayMessage:()=>ee,ClickReplayMessage:()=>V,CreateRefComponentMessage:()=>X,CustomRefMessage:()=>O,DetectMyopRefsMessage:()=>Ue,DetectedMyopRefsMessage:()=>Z,DisposeMessage:()=>te,ElementValueReplayMessage:()=>j,EnvelopedMessage:()=>Q,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>S,ExecuteScriptMessage:()=>T,ExecuteScriptReplyMessage:()=>W,GetAttributeMessage:()=>ze,GetAttributeReplayMessage:()=>Ne,GetElementValueMessage:()=>$e,InitMessage:()=>$,InitRequest:()=>J,InitResponse:()=>G,MessageDirection:()=>b,MutationObserverMessage:()=>We,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>C,MyopElementMessage:()=>_e,Ref:()=>B,RefComponentCreatedMessage:()=>A,ResizeObserverMessage:()=>je,SetAttributeMessage:()=>Fe,SetInnerHtml:()=>Ae,SetMutationObserverMessage:()=>Ve,SetResizeObserverMessage:()=>qe,stripFunction:()=>dt});var w=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var _t=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Pt=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Le=o=>{let n=Pt(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(_t(n.slice(t,t+16)));return e};var it=o=>new Promise(n=>setTimeout(n,o));var b=class{};i(b,"down","down"),i(b,"up","up");var y=class{constructor(){i(this,"id",w());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}},_e=class extends y{constructor(e){super();this.ref=e}},C=class extends y{constructor(e){super();this.replayToHandler=e}},x=class extends y{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",w())}},B=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=E(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var at="ClickReplayMessage",Pe=class extends x{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",at);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},V=class extends C{constructor(){super(...arguments);i(this,"messageType",at)}};var Oe=class extends y{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}};var pt="ExecuteScriptReplyMessage",Ot=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Kt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,dt=o=>{let n=o.match(Ot);if(n)return n[1]||n[3];{let e=o.match(Kt);if(e)return e[1].trim()}},T=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",pt);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=dt(this.content)}};i(T,"replierKey","send"),i(T,"completeStreamKey","completeStream");var W=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",pt)}};var O=class extends T{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=E(h({},t),{_script:e.toString()})}};var ct="EventListenerCallbackMessage",Ke=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",ct);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},q=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",ct);this.content={e:t}}};var Fe=class extends y{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}};var mt="ElementValueReplayMessage",$e=class extends x{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",mt);i(this,"messageType","GetElementValueMessage")}},j=class extends C{constructor(e){super();this.content=e;i(this,"messageType",mt)}};var Ae=class extends y{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}};var $=class extends y{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},G=class extends ${constructor(){super(...arguments);i(this,"messageType","InitResponse")}},J=class extends y{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var lt="RefComponentCreatedMessage",X=class extends x{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",lt);i(this,"messageType","CreateRefComponentMessage")}},A=class extends C{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",lt)}};var Q=class extends y{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 ft="DetectedMyopRefsMessage",Ue=class extends x{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",ft)}},Z=class extends C{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",ft);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var gt="GetAttributeReplayMessage",ze=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",gt);i(this,"messageType","GetAttributeMessage")}},Ne=class extends C{constructor(e){super();this.content=e;i(this,"messageType",gt)}};var S=class extends y{constructor(e){super();this.method=e;i(this,"messageType","ExecuteComponentMethod")}};var Ve=class extends y{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},We=class extends y{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ut="CleanupReplayMessage",Y=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",ut);i(this,"messageType","CleanupMessage")}},ee=class extends C{constructor(e){super();this.customCleanup=e;i(this,"messageType",ut)}};var te=class extends y{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var qe=class extends y{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},je=class extends y{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var Ge=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},pe=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===f.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===f.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new Ge(s),this.messageToHost(new G(s));return}if(t.messageType===f.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===f.CleanupMessage){let r=t,a=this.messageCleanupCache[r.cleanupForMessageId],p=new ee(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],rt(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 v={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var K={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var Je={message:"message",code:"code"},U=class{};i(U,"code","code"),i(U,"component","component");var F={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ce={Segment:"Segment",Promo:"Promo",AB:"AB"},de=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 me={webcomponent_message_key:"myop_webcomponent_message"};var M=class extends ie{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(E(h({},r),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var k={id:"myop-id"};var R=(o,n)=>n.querySelectorAll("[".concat(k.id,"='").concat(o.refConfig.selector,"']"));var le=class extends M{constructor(){super(...arguments);i(this,"messageType",f.BindClickMessage);i(this,"innerExecutor",(e,t,s)=>{let r=R(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new V(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var fe=class extends M{constructor(){super(...arguments);i(this,"messageType",f.ChangeTextMessage);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.textContent=e.content})})}};var ge=class extends de{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var ue=class extends M{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(k.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(k.id);p&&r.push(new re(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Z(e.handlerUniqueId,r))});i(this,"messageType",f.DetectMyopRefsMessage)}};var ye="__federation__",yt="onLoad";var he=(o,n)=>{window[ye]&&window[ye][o]&&window[ye][o][yt]&&window[ye][o][yt]({[o]:n})};var Me=class extends M{constructor(){super(...arguments);i(this,"messageType",f.SetAttributeMessage);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var Xe=o=>o!==Object(o),Ft=o=>typeof o=="function",Qe=o=>{if(Xe(o))return!0;if(Ft(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!Qe(e))return!1}else{if(Xe(e))continue;return!1}}return!0},H=(o,n={},e=!0,t=new WeakMap)=>{if(Xe(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=H(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(e?o[r]!==void 0:o[r])&&(s[r]=H(o[r],!0,e,t)):typeof a=="object"&&(s[r]=H(o[r],a,e,t)))}return s}return{}};var Ie=class extends M{constructor(){super(...arguments);i(this,"messageType",f.AddEventListenerMessage);i(this,"innerExecutor",(e,t,s)=>{let r=R(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=c=>{s(new q(e.handlerUniqueId,H(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var D=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});i(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>e(a)?(t(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(t==null?void 0:t.id)||L.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===f.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=b.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Y(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new te);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var ht={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 ne=class extends D{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 Q(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new S("dispose")),super.dispose()})}hide(){this.send(new S("hide"))}show(){this.send(new S("show"))}inspect(){return this.send(new S("inspect"))}setHeightBasedOnDocumentElement(){this.send(new S("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new S("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var $t=(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},Ce=(o,n,e,t,s,r)=>{let a=$t("".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)}},Mt=(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),It=(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."))},Ct=(o,n,e)=>{let t=n.reduce((r,a)=>E(h({},r),{[a.name]:h({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(Mt(p,a,o))return!1;if(p.behavior.type===Je.code){if(e.loader.type===v.HTMLLoader&&e.loader.shadowRootMode===K.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return It(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(B.create(p.behavior.ref)),c.push(l=>{d(l)}),p.behavior.params&&c.push(...p.behavior.params);let m=ae[p.behavior.message];o.send(new m(...c))}):null},set:(r,a,p)=>{let d=t[a];if(Mt(d,a,o))return!1;if(d.behavior.type===Je.code){if(e.loader.type===v.HTMLLoader&&e.loader.shadowRootMode===K.localFrame){let m=d.behavior;return o.element.contentWindow[m.remap||a]=p,!0}return It(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(B.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let m=ae[d.behavior.message];return o.send(new m(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},At=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{Qe(p)||ht.notSerializableRefCall(t,p)}),n.send(new O(({ref:p,propName:d,functionArgs:c,makeSerializable:m})=>{if(p){let l=p[d];return m(typeof l=="function"?p[d](...c):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new O(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),Ze=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 ne(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new X(o.refConfig,n,E(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let m=e.find(l=>l.id==p.id);if(m!==p){s.refs[o.refConfig.name]=m,r(m);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(I=>I.type.id===l.componentDefinitionId).type,u=new ne(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await Ye(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(l){a(l)}}))})},Ye=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==U.component){if(t){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=B.create("",r,o);try{let g=await Ze(l,m,e);o.refs[r.name]=g,a()}catch(g){p(g)}}else try{let c=B.create("",r,o);o.refs[r.name]=At(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}};var z=class extends D{constructor(e,t,s,r,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=r;i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new T(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});i(this,"observeSizeBasedOnDocumentElement",()=>this.send(new T(({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,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new T(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new T(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});i(this,"send",e=>{var r,a;let t=h({},e);if(t.messageType===f.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let s=super.send(t);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(t,"*"),s});i(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Ce(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===f.In.MutationObserverMessage||e.messageType===f.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var _=class{constructor(){i(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let r=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,r||null)}}else return n.appendChild(e)})}};var Ut=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},xe=class extends _{constructor(){super(...arguments);i(this,"type",v.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=w(),c="myop-comp-".concat(d);a=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(a.style.visibility="hidden"),a=this.appendChild(s,a,r);let m=t.loader.url;r!=null&&r._hasParent&&(m=Ut(m,"_myop-comp",d));let l="";r!=null&&r.elementAttributes&&(l=Object.entries(r==null?void 0:r.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(c,'"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(p.autoHeight||!p.height?"":p.height,"; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",';\n "\n src="').concat(m,'"\n ').concat(l,"\n ></iframe>"),a=s.querySelector("#".concat(c))}return new z(e,t,s,a,r)})}};var N=class extends D{constructor(e,t,s,r,a){super(e,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=h({},e),s=super.send(t),r=new CustomEvent(me.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=Ce(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var et={},be=class extends _{constructor(){super(...arguments);i(this,"type",v.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;et[a.url]?console.log("Module alreday loaded or in loading process"):et[a.url]=new Promise((c,m)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{c()},g.onerror=()=>{m()},document.head.appendChild(g)}),await et[a.url],await it(1);let p="myop-comp-".concat(w()),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 N(e,t,s,d,r)})}};var xt="0.2.5";var bt=[],Te,Tt=async()=>(Te||(Te=new oe,Te.init()),Te);function zt(o,n){return class extends HTMLElement{connectedCallback(){let e=n===K.open?"open":"closed",t=this.attachShadow({mode:e});Tt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var Nt=(o,n,e)=>{customElements.define(o,zt(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Vt=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Wt=o=>(o=Vt(o),o.replace(/_/g,"-"));var we=class extends _{constructor(){super(...arguments);i(this,"type",v.HTMLLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader,p="myop-comp-".concat(w()),d;if(a.shadowRootMode===K.localFrame){let c=w(),m="myop-comp-".concat(c),l=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(l.style.visibility="hidden"),l=this.appendChild(s,l,r),l.id=m,l.setAttribute("style","\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ")),s.appendChild(l);let g=l.contentDocument||l.contentWindow.document;g.open();let u=a.HTML;if(r!=null&&r._inspection){let P=new DOMParser().parseFromString(a.HTML,"text/html"),He=P.getElementById("myop_preview");He==null||He.removeAttribute("type");let tt=P.implementation.createHTMLDocument();tt.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let nt=tt.body.firstChild;nt&&P.head&&P.head.insertBefore(P.importNode(nt,!0),P.head.firstChild),u=P.documentElement.outerHTML}g.writeln(u),g.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>\n <script>\n \n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n \n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n \n __myop_init().then();\n \n <\/script>')),g.close();let I=new z(e,t,s,l,r);return a.autoHeight&&(l.onload=()=>{I.observeSizeBasedOnDocumentElement()}),I}if(a.shadowRootMode===K.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Tt().then(m=>{m.connectedCallback(d,d)})}else{let c=Wt(e.name+t.id);bt.includes(c)||(Nt(c,a.HTML,a.shadowRootMode),bt.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 N(e,t,s,d,r)})}};var Se=class Se{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"variants",{});i(this,"userFlows",{})}isPreloaded(n){return n in this.variants}async fetchComponentV2(n,e){return this.variants[n]||(this.variants[n]=new Promise(async(t,s)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(e))).json();t(a.item)}catch(r){s(r)}})),await this.variants[n]}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(Se,"Main",new Se);var se=Se;var wt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=Le(t);switch(s){case"component":{let[a,p]=r,d=await se.Main.fetchComponent(a);if(d&&d.type.skins.find(m=>m.id===p))return d.instance.skinSelector={type:F.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=Le(t),c=(await se.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===F.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(l=>l.id===p);if((m==null?void 0:m.type)===ce.Segment){let l=m,u=c.instance.skinSelector.segments.find(I=>I.segmentId===l.segment.id);if(u)return c.instance.skinSelector=u==null?void 0:u.skinSelector,c}}}break}}}finally{return null}};var St="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",L=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",xt);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==f.EnvelopedMessage)return;let e=n.data;if(e.messageType===f.InitRequest){this.components2init.forEach(s=>{s.send(new $(s.id))});return}if(e.messageType===f.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===f.EnvelopedMessage){let s=e,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===b.down){s.message.messageType===S.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 xe,new be,new we];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 F.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case F.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(u=>u.type===ce.Segment?u.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let l=c.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});i(this,"loaderHooks");i(this,"loadComponent",async(n,e,t)=>{var m,l,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await wt(n);s&&(n=s);let r=h(h({},(m=this.loaderHooks)!=null?m:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let I=await this.runSkinSelector(n,r);if(!I)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(I=await t.hooks.afterSkinSelected(h({},I))),n.instance.skinSelector={type:F.Dedicated,skin:I},t&&(t=h({},t),delete t.hooks),await Ze(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,r);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(I=>I.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(I=>I!==c),this.components2init=this.components2init.filter(I=>I!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=Ct(c,n.type.props,p));try{await Ye(c,n,this.components)}catch(I){throw I}return t!=null&&t.skipInit||await c.initiated(),c});i(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};i(L,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:St});if(!window.myop.hostSDK){let o=new L;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:St}),window.myop.hostSDK=o}var qt=window.myop.hostSDK;he("hostSDK",qt);var Re=class extends M{constructor(){super(...arguments);i(this,"messageType",f.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(k.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=L.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let m=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(m.refs).forEach(g=>{let u=m.refs[g];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),s(new A(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new A(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Rt=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=H,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)};var Ee=class extends M{constructor(){super(...arguments);i(this,"messageType",f.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{Rt(e,a=>{s(new W(e.handlerUniqueId,a))},t)})}};var Et=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(k.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Et(r),required:r.required,validity:H(r.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},ve=class extends M{constructor(){super(...arguments);i(this,"messageType",f.GetElementValueMessage);i(this,"innerExecutor",(e,t,s)=>{R(e.ref,t.shadowRoot).forEach(a=>{s(new j(Et(a)),e)})})}};var ke=class extends M{constructor(){super(...arguments);i(this,"messageType",f.SetInnerHtml);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.innerHTML=e.content})})}};var oe=class extends pe{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(me.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===f.InitMessage){let p=a.content.id;this.components[p].context=new ge(e,t)}}}),setTimeout(()=>{this.messageToHost(new J)},1)});i(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new fe(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new le(this.messageToHost,this.components),new ue(this.messageToHost,this.components),new Me(this.messageToHost,this.components),new Ie(this.messageToHost,this.components),new Ee(this.messageToHost,this.components),new ve(this.messageToHost,this.components),new Re(this.messageToHost,this.components)]);i(this,"init",()=>{})}};he("WebComponentSDK",oe);export{oe as WebComponentSDK};
@@ -1588,7 +1588,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
1588
1588
  };
1589
1589
 
1590
1590
  // version:myop-sdk-version
1591
- var myop_sdk_version_default = "0.2.4";
1591
+ var myop_sdk_version_default = "0.2.5";
1592
1592
 
1593
1593
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
1594
1594
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {