@myop/sdk 0.1.46 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/bundled-declarations.d.ts +61 -0
  2. package/dist/cjs/{_IframeSDK.71663203.min.js → _IframeSDK.7d51275f.min.js} +1 -1
  3. package/dist/cjs/{_IframeSDK.b1e6c181.js → _IframeSDK.cc82a827.js} +31 -1
  4. package/dist/cjs/_IframeSDK.cc82a827.js.map +7 -0
  5. package/dist/cjs/_MyopHelpers.a07c6289.js +2810 -0
  6. package/dist/cjs/_MyopHelpers.a07c6289.js.map +7 -0
  7. package/dist/cjs/_MyopHelpers.ac3e8038.min.js +1 -0
  8. package/dist/cjs/{_WebComponentSDK.bf4ad0dd.js → _WebComponentSDK.64c6a9c1.js} +31 -1
  9. package/dist/cjs/_WebComponentSDK.64c6a9c1.js.map +7 -0
  10. package/dist/cjs/{_WebComponentSDK.3474ea7a.min.js → _WebComponentSDK.6c4296d5.min.js} +1 -1
  11. package/dist/cjs/{_hostSDK.7c59d1ae.js → _hostSDK.788bdb7f.js} +31 -1
  12. package/dist/cjs/_hostSDK.788bdb7f.js.map +7 -0
  13. package/dist/cjs/{_hostSDK.8b543e61.min.js → _hostSDK.e5552529.min.js} +1 -1
  14. package/dist/cjs/myop_sdk.js +14 -14
  15. package/dist/cjs/myop_sdk.js.map +1 -1
  16. package/dist/cjs/myop_sdk.min.js +1 -1
  17. package/dist/module/Iframe/index.js +34 -2
  18. package/dist/module/Iframe/index.js.map +3 -3
  19. package/dist/module/SDK.js +123 -4
  20. package/dist/module/SDK.js.map +3 -3
  21. package/dist/module/common/index.d.ts +46 -0
  22. package/dist/module/common/index.js +1 -1
  23. package/dist/module/common/index.js.map +2 -2
  24. package/dist/module/helpers/EnableV2.d.ts +12 -0
  25. package/dist/module/helpers/index.d.ts +1 -0
  26. package/dist/module/helpers/index.js +2520 -4
  27. package/dist/module/helpers/index.js.map +4 -4
  28. package/dist/module/host/index.js +34 -2
  29. package/dist/module/host/index.js.map +3 -3
  30. package/dist/module/webcomponent/index.js +34 -2
  31. package/dist/module/webcomponent/index.js.map +3 -3
  32. package/package.json +1 -1
  33. package/dist/cjs/_IframeSDK.b1e6c181.js.map +0 -7
  34. package/dist/cjs/_MyopHelpers.98cae3f9.js +0 -417
  35. package/dist/cjs/_MyopHelpers.98cae3f9.js.map +0 -7
  36. package/dist/cjs/_MyopHelpers.f3e207e0.min.js +0 -1
  37. package/dist/cjs/_WebComponentSDK.bf4ad0dd.js.map +0 -7
  38. package/dist/cjs/_hostSDK.7c59d1ae.js.map +0 -7
@@ -203,11 +203,25 @@ declare module "@myop/sdk/common" {
203
203
  type: SkinLoaderType;
204
204
  [key: string]: any;
205
205
  }
206
+ export interface v2_IReleaseMetadata {
207
+ environmentId: string;
208
+ environmentIdentifier: string;
209
+ }
210
+ export interface v2_IVariantConfig extends v2_IMyopStoredObject {
211
+ loader: ISkinLoaderConfig;
212
+ componentId: string;
213
+ releases?: v2_IReleaseMetadata[];
214
+ }
206
215
  export interface ISkinConfig {
207
216
  id: string;
208
217
  name: string;
209
218
  description: string;
210
219
  loader: ISkinLoaderConfig;
220
+ createdBy?: string;
221
+ createdOn?: string;
222
+ }
223
+ export interface v2_ISkinConfig extends ISkinConfig {
224
+ componentId: string;
211
225
  }
212
226
  export interface IMessagePropConfig extends IPropConfig {
213
227
  type: PropType;
@@ -286,6 +300,38 @@ declare module "@myop/sdk/common" {
286
300
  skins: ISkinConfig[];
287
301
  defaultSkin: number;
288
302
  createdOn?: string;
303
+ createdBy?: string;
304
+ updatedBy?: string;
305
+ }
306
+ export interface v2_IBaseMyopObject {
307
+ id: string;
308
+ name: string;
309
+ description: string;
310
+ }
311
+ export interface v2_IMyopStoredObject extends v2_IBaseMyopObject {
312
+ updatedOn?: string;
313
+ updatedBy?: string;
314
+ }
315
+ export interface v2_IComponentDefinitionConfig extends v2_IMyopStoredObject {
316
+ variants_ids: string[];
317
+ DTOs: v2_IDTO[];
318
+ tags: string[];
319
+ variants_names: string[];
320
+ variants_data: {
321
+ name: string;
322
+ id: string;
323
+ updatedOn?: string;
324
+ updatedBy?: string;
325
+ has_releases?: boolean;
326
+ }[];
327
+ preview_variant: v2_IVariantConfig;
328
+ extra?: {
329
+ firstVariant: v2_IVariantConfig;
330
+ };
331
+ }
332
+ export interface v2_IDTO extends v2_IMyopStoredObject {
333
+ data: object;
334
+ methodName: string;
289
335
  }
290
336
  export interface ISkinInstanceConfig {
291
337
  id: string;
@@ -1543,6 +1589,20 @@ declare module "@myop/sdk/helpers/CloudRepository" {
1543
1589
  declare module "@myop/sdk/helpers/exec" {
1544
1590
  export const exec: (getter: any) => Promise<any>;
1545
1591
  }
1592
+ declare module "@myop/sdk/helpers/EnableV2" {
1593
+ import { v2_IVariantConfig } from "@myop/sdk/common";
1594
+ import { loaderOptions } from "@myop/sdk/host/hostSDK";
1595
+ export class v2_CloudRepository {
1596
+ private _baseUrl;
1597
+ static Main: v2_CloudRepository;
1598
+ private variants;
1599
+ constructor(_baseUrl?: string);
1600
+ fetchComponent(componentId: string, environmentIdentifier?: string): Promise<v2_IVariantConfig>;
1601
+ }
1602
+ export const enableV2: (environmentIdentifier: string, cloudRepository?: v2_CloudRepository) => {
1603
+ loadComponent: (componentId: string, container: HTMLElement, options?: loaderOptions) => Promise<import("host").IMyopComponent<any, any>>;
1604
+ };
1605
+ }
1546
1606
  declare module "@myop/sdk/helpers" {
1547
1607
  export * from "@myop/sdk/helpers/applyStylesheet";
1548
1608
  export * from "@myop/sdk/helpers/iframeSkinUrlTokenizer";
@@ -1550,6 +1610,7 @@ declare module "@myop/sdk/helpers" {
1550
1610
  export * from "@myop/sdk/helpers/configBuilder";
1551
1611
  export * from "@myop/sdk/helpers/CloudRepository";
1552
1612
  export * from "@myop/sdk/helpers/exec";
1613
+ export * from "@myop/sdk/helpers/EnableV2";
1553
1614
  }
1554
1615
  declare module "@myop/sdk/host/myopOverride" {
1555
1616
  import { IComponentConfig } from "@myop/sdk/common";
@@ -1 +1 @@
1
- var Mt=Object.defineProperty,qt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var ht=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var je=(n,o,e)=>o in n?Mt(n,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[o]=e,y=(n,o)=>{for(var e in o||(o={}))Vt.call(o,e)&&je(n,e,o[e]);if(ht)for(var e of ht(o))Gt.call(o,e)&&je(n,e,o[e]);return n},B=(n,o)=>qt(n,Wt(o));var jt=(n,o)=>{for(var e in o)Mt(n,e,{get:o[e],enumerable:!0})};var s=(n,o,e)=>je(n,typeof o!="symbol"?o+"":o,e);var G=class{constructor(o,e,t,r,i){this.myopId=o;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;s(this,"type","MyopElementRef")}};var It=async n=>{if(typeof n=="function")n();else if(n instanceof Promise){let o=await n;typeof o=="function"&&o()}},h=class{constructor(o){this.messageToHost=o}},fe=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var c={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 ge={};jt(ge,{AddEventListenerMessage:()=>Ye,BaseMyopMessage:()=>M,BindClickMessage:()=>Qe,ChangeTextMessage:()=>Ze,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>K,CreateRefComponentMessage:()=>oe,CustomRefMessage:()=>F,DetectMyopRefsMessage:()=>nt,DetectedMyopRefsMessage:()=>N,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>z,EnvelopedMessage:()=>ne,EventListenerCallbackMessage:()=>$,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>E,ExecuteScriptReplyMessage:()=>A,GetAttributeMessage:()=>st,GetAttributeReplayMessage:()=>se,GetElementValueMessage:()=>tt,InitMessage:()=>j,InitRequest:()=>U,InitResponse:()=>te,MessageDirection:()=>b,MutationObserverMessage:()=>re,MyopBindMessage:()=>w,MyopBindReplayMessage:()=>T,MyopElementMessage:()=>Xe,Ref:()=>_,RefComponentCreatedMessage:()=>D,ResizeObserverMessage:()=>me,SetAttributeMessage:()=>et,SetInnerHtml:()=>ot,SetMutationObserverMessage:()=>rt,SetResizeObserverMessage:()=>it,stripFunction:()=>Tt});var v=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+n/4).toString(16));var Jt=n=>{let o=[...n].map(e=>e.toString(16).padStart(2,"0")).join("");return[o.slice(0,8),o.slice(8,12),o.slice(12,16),o.slice(16,20),o.slice(20)].join("-")};var Xt=n=>{let o=n.replace(/-/g,"+").replace(/_/g,"/");for(;o.length%4;)o+="=";let e=atob(o);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Je=n=>{let o=Xt(n);if(o.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<o.length;t+=16)e.push(Jt(o.slice(t,t+16)));return e};var Ct=n=>new Promise(o=>setTimeout(o,n));var b=class{};s(b,"down","down"),s(b,"up","up");var M=class{constructor(){s(this,"id",v());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...o){return new this(...o)}isTypeof(o){return o.messageType===this.messageType}},Xe=class extends M{constructor(e){super();this.ref=e}},T=class extends M{constructor(e){super();this.replayToHandler=e}},w=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",v())}},_=class n{constructor(o,e){this.refConfig=o;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=B(y({},this),{component:null})}static create(o,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:o,behavior:{type:"code"}}),new n(r,t)}};var xt="ClickReplayMessage",Qe=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",xt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},K=class extends T{constructor(){super(...arguments);s(this,"messageType",xt)}};var Ze=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var bt="ExecuteScriptReplyMessage",Qt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Zt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Tt=n=>{let o=n.match(Qt);if(o)return o[1]||o[3];{let e=n.match(Zt);if(e)return e[1].trim()}},E=class extends w{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",bt);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Tt(this.content)}};s(E,"replierKey","send"),s(E,"completeStreamKey","completeStream");var A=class extends T{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",bt)}};var F=class extends E{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:m})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(m.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(m)):null},r);this.scriptInputs=t;this.scriptInputs=B(y({},t),{_script:e.toString()})}};var wt="EventListenerCallbackMessage",Ye=class extends w{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",wt);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},$=class extends T{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",wt);this.content={e:t}}};var et=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var St="ElementValueReplayMessage",tt=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",St);s(this,"messageType","GetElementValueMessage")}},z=class extends T{constructor(e){super();this.content=e;s(this,"messageType",St)}};var ot=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var j=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},te=class extends j{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},U=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var Et="RefComponentCreatedMessage",oe=class extends w{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",Et);s(this,"messageType","CreateRefComponentMessage")}},D=class extends T{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",Et)}};var ne=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Rt="DetectedMyopRefsMessage",nt=class extends w{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Rt)}},N=class extends T{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Rt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var vt="GetAttributeReplayMessage",st=class extends w{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",vt);s(this,"messageType","GetAttributeMessage")}},se=class extends T{constructor(e){super();this.content=e;s(this,"messageType",vt)}};var k=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var rt=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},re=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var kt="CleanupReplayMessage",ie=class extends w{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",kt);s(this,"messageType","CleanupMessage")}},ae=class extends T{constructor(e){super();this.customCleanup=e;s(this,"messageType",kt)}};var pe=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var it=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},me=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var at=class{constructor(o,e){this.id=o;this.context=e;s(this,"send",o=>{})}},J=class{constructor(){s(this,"messageToHandleAfterInit",[]);s(this,"components",{});s(this,"alwaysPassEnvelopesToHost",!1);s(this,"messageCleanupCache",{})}handleIncomeMessages(o){let e=o.data?o.data:o.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===c.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===c.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new at(r),this.messageToHost(new te(r));return}if(t.messageType===c.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(m=>m.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(m=>m.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===c.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],It(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let r=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){r=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var L={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var pt={message:"message",code:"code"},X=class{};s(X,"code","code"),s(X,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ue={Segment:"Segment",Promo:"Promo",AB:"AB"},Q=class{constructor(o,e){this.container=o;this.shadowRoot=e;s(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));s(this,"getRoot",()=>this.shadowRoot||this.container)}};var S={id:"myop-id"};var ye=class extends h{constructor(){super(...arguments);s(this,"messageType",c.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(S.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(S.id);a&&r.push(new G(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new N(e.handlerUniqueId,r))})}};var I=(n,o)=>o.querySelectorAll("[".concat(S.id,"='").concat(n.refConfig.selector,"']")),Ht=(n,o)=>{let e=I(n,o);return e.length?e.item(0):null};var he=class extends h{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new K,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var Me=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var mt=n=>n!==Object(n),Yt=n=>typeof n=="function",dt=n=>{if(mt(n))return!0;if(Yt(n)||Object.getPrototypeOf(n))return!1;for(let o in n){let e=n[o];if(typeof e=="object"){if(!dt(e))return!1}else{if(mt(e))continue;return!1}}return!0},R=(n,o={},e=!0,t=new WeakMap)=>{if(mt(n))return n;if(Array.isArray(n)){if(t.has(n))return t.get(n);let r=[];t.set(n,r);for(let i=0;i<n.length;i++){let a=n[i];r[i]=R(a,o,e,t)}return r}if(n!==null&&typeof n=="object"){if(t.has(n))return t.get(n);let r={};t.set(n,r);for(let i in n){let a=typeof o=="boolean"?o:o[i];a&&(a===!0?(e?n[i]!==void 0:n[i])&&(r[i]=R(n[i],!0,e,t)):typeof a=="object"&&(r[i]=R(n[i],a,e,t)))}return r}return{}};var Ie=(n,o,e)=>{let t=n.scriptInputs?n.scriptInputs:{};t.makeSerializable=R,t.send=o,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(n.script,")(...arguments)"))(t);o(i)};var Ce=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"executor",e=>{Ie(e,r=>{this.messageToHost(new A(e.handlerUniqueId,r))},new Q(document.documentElement))})}};var xe="__federation__",Bt="onLoad";var Z=(n,o)=>{window[xe]&&window[xe][n]&&window[xe][n][Bt]&&window[xe][n][Bt]({[n]:o})};var be=class extends h{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new $(e.handlerUniqueId,R(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Te=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var P=class{constructor(o,e,t){this.componentDefinition=o;this.container=e;s(this,"id","");s(this,"messageHandlers",{});s(this,"element");s(this,"_markedForDisposed",!1);s(this,"bind",(o,e)=>{this.messageHandlers[o]||(this.messageHandlers[o]=[]),this.messageHandlers[o].includes(e)||this.messageHandlers[o].push(e)});s(this,"bindWhen",(o,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[o]||(this.messageHandlers[o]=[]);let r=this.messageHandlers[o],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});s(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});s(this,"isInitiated",!1);s(this,"_whenInitiatedResolve");s(this,"_whenInitiatedReject");s(this,"_whenInitiated",new Promise((o,e)=>{this._whenInitiatedResolve=o,this._whenInitiatedReject=e}));s(this,"initiated",()=>this._whenInitiated);s(this,"props",{});s(this,"refs",{});this.id=(t==null?void 0:t.id)||H.Instance().assignId(o);let r=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(r," ").concat(this.id))},r),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(o){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=o}onMessageReceived(o){if(o.messageType===c.ExecuteComponentMethod){let t=o;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[o.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(o)}),t}return!1}sendCleanupMessage(o){o.source=this.id,o.destination=this.id,o.direction=b.down;let e=this.bindWhen(o.replyMessageKey,r=>r.replayToHandler===o.handlerUniqueId,r=>{o.handler(r),e()}),t=o.handler;delete o.handler,this.send(o),o.handler=t}send(o){o.source||(o.source=this.id),o.destination||(o.destination=this.id),o.direction=b.down;let e;if(o.handler){let t=o;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete o.handler}return o.ref&&(o.ref=o.ref.__nonProxied||o.ref),o.cleanable?()=>{this.sendCleanupMessage(new ie(o.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let o=this.messageHandlers.onDispose;o&&o.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Dt={notSerializableRefCall:(n,o)=>{throw new Error("\nThe input provided to '".concat(n.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(o," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(n.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 de=class extends P{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;s(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new ne(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var eo=(n,o,e)=>{let t=document.createElement("a");return t.textContent=n,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(o,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},we=(n,o,e,t,r,i)=>{let a=eo("".concat(i.name," : ").concat(o),e,i);return t.insertBefore(a,r),r.style.border="1px solid #007BFF",r.style.display="block",()=>{r.style.border="unset",t.removeChild(a)}},Lt=(n,o,e)=>n?!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(o,"\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),_t=(n,o,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(o,"\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."))},Pt=(n,o,e)=>{let t=o.reduce((i,a)=>B(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Lt(p,a,n))return!1;if(p.behavior.type===pt.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let d=p.behavior;return n.element.contentWindow[d.remap||a]}return _t(p,a,n),!1}return p.mode==="output"?new Promise(m=>{let d=[];p.behavior.ref&&d.push(_.create(p.behavior.ref)),d.push(f=>{m(f)}),p.behavior.params&&d.push(...p.behavior.params);let l=ge[p.behavior.message];n.send(new l(...d))}):null},set:(i,a,p)=>{let m=t[a];if(Lt(m,a,n))return!1;if(m.behavior.type===pt.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let l=m.behavior;return n.element.contentWindow[l.remap||a]=p,!0}return _t(m,a,n),!1}else if(m.mode==="input")if(m.behavior.type==="message"){let d=[];m.behavior.ref&&d.push(_.create(m.behavior.ref)),d.push(p),m.behavior.params&&d.push(...m.behavior.params);let l=ge[m.behavior.message];return n.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(n.componentDefinition.name,", ID: ").concat(n.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(m.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return n.props={},n.props=new Proxy(n.props,r),n},to=(n,o)=>new Proxy(n,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{dt(p)||Dt.notSerializableRefCall(t,p)}),o.send(new F(({ref:p,propName:m,functionArgs:d,makeSerializable:l})=>{if(p){let f=p[m];return l(typeof f=="function"?p[m](...d):f,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return o.send(new F(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),ct=async(n,o,e,t)=>{let r=n.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(o.type,r,t);e.push(p),await r.initiated();let m=setTimeout(()=>{a("timeout")},5e3);r.send(new oe(n.refConfig,o,B(y({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(m),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(f=>f.id==p.id);if(l!==p){r.refs[n.refConfig.name]=l,i(l);return}else p.setInitiated(),r.refs[n.refConfig.name]=p;d.nestedRefs.forEach(f=>{let g=o.instance.resolvedNestedComponents.find(x=>x.type.id===f.componentDefinitionId).type,u=new de(g,p);u.setInitiated(),p.refs[f.refName]=u,e.push(u)});try{await lt(p,o,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},lt=async(n,o,e,t=!1)=>{n.refs||(n.refs={});let r=Object.values(n.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var m;if(i.behavior.type==X.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(m=o.instance.resolvedNestedComponents)==null?void 0:m.find(g=>g.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let f=_.create("",i,n);try{let g=await ct(f,l,e);n.refs[i.name]=g,a()}catch(g){p(g)}}else try{let d=_.create("",i,n);n.refs[i.name]=to(d,n),a()}catch(d){}}));try{await Promise.all(r)}catch(i){throw i}};var Y=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;s(this,"cleanupInspect");s(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new E(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new E(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:m}=document.documentElement.getBoundingClientRect();t({height:p,width:m})});return a.observe(document.documentElement),a.observe(document.body),{height:r,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new E(()=>{let{height:t,width:r}=document.documentElement.getBoundingClientRect();return{height:t,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});s(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new E(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===c.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});s(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=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===c.In.MutationObserverMessage||e.messageType===c.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var O=class{constructor(){s(this,"appendChild",(o,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return o.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return o.insertBefore(e,i||null)}}else return o.appendChild(e)})}};var oo=(n,o,e)=>{let t=new URL(n);return t.searchParams.append(o,e),t.toString()},Se=class extends O{constructor(){super(...arguments);s(this,"type",L.IframeLoader);s(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let m=v(),d="myop-comp-".concat(m);a=document.createElement("iframe"),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(a.style.visibility="hidden"),a=this.appendChild(r,a,i);let l=t.loader.url;i!=null&&i._hasParent&&(l=oo(l,"_myop-comp",m));let f="";i!=null&&i.elementAttributes&&(f=Object.entries(i==null?void 0:i.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(d,'"\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(i!=null&&i.hidden?"0":"1",";\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",';\n "\n src="').concat(l,'"\n ').concat(f,"\n ></iframe>"),a=r.querySelector("#".concat(d))}return new Y(e,t,r,a,i)})}};var Ee={webcomponent_message_key:"myop_webcomponent_message"};var ee=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Ee.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});s(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}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 ft={},Re=class extends O{constructor(){super(...arguments);s(this,"type",L.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;ft[a.url]?console.log("Module alreday loaded or in loading process"):ft[a.url]=new Promise((d,l)=>{let f=a.url,g=document.createElement("script");g.type="module",g.src=f,g.onload=()=>{d()},g.onerror=()=>{l()},document.head.appendChild(g)}),await ft[a.url],await Ct(1);let p="myop-comp-".concat(v()),m=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),i!=null&&i._environment&&(m._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ve="0.1.46";var C=class extends fe{constructor(e,t){super(e);this.context=t;s(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(B(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ke=class extends C{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=()=>{r(new K(e.handlerUniqueId))};p.addEventListener("click",m),a.push(()=>{p.removeEventListener("click",m)})}),()=>{a.forEach(p=>p())}})}};var He=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Be=class extends Q{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var De=class extends C{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(S.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(S.id);p&&i.push(new G(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new N(e.handlerUniqueId,i))});s(this,"messageType",c.DetectMyopRefsMessage)}};var Le=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var _e=class extends C{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=d=>{r(new $(e.handlerUniqueId,R(d,e.serializableSkeleton)))};p.addEventListener(e.type,m),a.push(()=>{p.removeEventListener(e.type,m)})}),()=>{a.forEach(p=>p())}})}};var Pe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=H.Instance(),m=p.components.find(g=>g.id===e.options.id);m&&m.dispose();let d=p.components.indexOf(m);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),f=[];Object.keys(l.refs).forEach(g=>{let u=l.refs[g];u=u.__nonProxied||u,u.componentDefinition&&f.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new D(e.handlerUniqueId,f))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Oe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{Ie(e,a=>{r(new A(e.handlerUniqueId,a))},t)})}};var Ot=n=>{if(!n)return null;if(n.tagName==="FORM"){let o=new FormData(n),e={formData:{},unmappedData:[]},t=n.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Ot(i),required:i.required,validity:R(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(m):(e.unmappedData.push(e.formData[p]),e.formData[p]=m):e.formData[p]=m:e.unmappedData.push(m)}}),e}return n.type==="checkbox"||n.type==="radio"?n.checked?n.value:null:n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"?n.value:n.isContentEditable?n.innerText||n.textContent:null},Ke=class extends C{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new z(Ot(a)),e)})})}};var Ae=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var ce=class extends J{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Ee.webcomponent_message_key,r=>{let i=r.data?r.data:r.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(r),a.messageType===c.InitMessage){let p=a.content.id;this.components[p].context=new Be(e,t)}}}),setTimeout(()=>{this.messageToHost(new U)},1)});s(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});s(this,"supportedHandlers",[new He(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new De(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Oe(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Pe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};Z("WebComponentSDK",ce);var Kt=[],Fe,At=async()=>(Fe||(Fe=new ce,Fe.init()),Fe);function no(n,o){return class extends HTMLElement{connectedCallback(){let e=o===q.open?"open":"closed",t=this.attachShadow({mode:e});At().then(r=>{r.connectedCallback(this,t),t.innerHTML=n})}}}var so=(n,o,e)=>{customElements.define(n,no(o,e)),console.log("define('".concat(n,"') was called, web component ready to use"))},ro=n=>n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),io=n=>(n=ro(n),n.replace(/_/g,"-"));var $e=class extends O{constructor(){super(...arguments);s(this,"type",L.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(v()),m;if(a.shadowRootMode===q.localFrame){let d=v(),l="myop-comp-".concat(d),f=document.createElement("iframe");r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(f.style.visibility="hidden"),f=this.appendChild(r,f,i),f.id=l,f.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ")),r.appendChild(f);let g=f.contentDocument||f.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let V=new DOMParser().parseFromString(a.HTML,"text/html"),ut=V.implementation.createHTMLDocument();ut.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let yt=ut.body.firstChild;yt&&V.head&&V.head.insertBefore(V.importNode(yt,!0),V.head.firstChild),u=V.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 x=new Y(e,t,r,f,i);return a.autoHeight&&(f.onload=()=>{x.observeSizeBasedOnDocumentElement()}),x}if(a.shadowRootMode===q.none){let d=document.createElement("template");d.innerHTML=a.HTML,m=d.content.firstElementChild,At().then(l=>{l.connectedCallback(m,m)})}else{let d=io(e.name+t.id);Kt.includes(d)||(so(d,a.HTML,a.shadowRootMode),Kt.push(d)),m=document.createElement(d)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ze=class ze{constructor(o="https://cloud.myop.dev"){this._baseUrl=o;s(this,"userFlows",{})}async fetchComponent(o,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===o):(await this.fetchAutoFlow(o)).components[0]}async fetchAutoFlow(o){return this.userFlows[o]||(this.userFlows[o]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(o,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[o]}async fetchFlow(o){return this.userFlows[o]||(this.userFlows[o]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(o,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[o]}};s(ze,"Main",new ze);var le=ze;var Ft=async n=>{try{let o=new URL(window.location.href),t=new URLSearchParams(o.search).get("myopOverride");if(t){let[r,...i]=Je(t);switch(r){case"component":{let[a,p]=i,m=await le.Main.fetchComponent(a);if(m&&m.type.skins.find(l=>l.id===p))return m.instance.skinSelector={type:W.Dedicated,skin:{id:p}},m}break;default:{let[a,p]=Je(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===n.type.id);if(d&&d.instance.skinSelector.type===W.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(f=>f.id===p);if((l==null?void 0:l.type)===ue.Segment){let f=l,u=d.instance.skinSelector.segments.find(x=>x.segmentId===f.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var $t="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",H=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",ve);s(this,"type2InstanceCount",{});s(this,"assignId",o=>(this.type2InstanceCount[o.id]||(this.type2InstanceCount[o.id]=0),"".concat(o.id,"_").concat(++this.type2InstanceCount[o.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(o=>{o.inspect&&o.inspect()}))});s(this,"incomingMessageHandler",o=>{if(o.origin,document.location.origin,o.data.myop){if(o.data.direction!==b.up&&o.data.messageType!==c.EnvelopedMessage)return;let e=o.data;if(e.messageType===c.InitRequest){this.components2init.forEach(r=>{r.send(new j(r.id))});return}if(e.messageType===c.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let r=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});r==null||r.setInitiated();return}if(e.messageType===c.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===k.name?i.onMessageReceived(r.message):(r.message.route=r.route,i.send(r.message));return}}else{let a=this.components.find(p=>p.id===r.message.destination);a&&a.send(r.message)}return}let t=this.components.find(r=>r.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)}}});s(this,"send",o=>{let e=new MessageEvent("",{data:o});this.incomingMessageHandler(e)});s(this,"init",o=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Se,new Re,new $e];if(this.componentsLoaders=[...e],o){let t={};o.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});s(this,"_getSkinIdBySkinSelector",async(o,e=[],t)=>{var i;async function r(a,p){for(let m of a)if(await p(m))return m}switch(o.type){case"DedicatedSkin":case W.Dedicated:return((i=o.skin)==null?void 0:i.id)||o.skins[0].id;case W.Segmented:{let p=await r(o.segments,async m=>{if(m.segmentId==="Default")return!0;let d=e.find(u=>u.type===ue.Segment?u.segment.id===m.segmentId:!1);if(!d)throw new Error("experience not found");let f=d.segment,g=(t||{})[f.function];return g?await g():(console.warn("segmentId:".concat(m.segmentId,", ").concat(f.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});s(this,"runSkinSelector",async(o,e)=>{let t=await this._getSkinIdBySkinSelector(o.instance.skinSelector,o.instance.resolvedExperiences,e);return o.type.skins.find(r=>r.id===t)});s(this,"loaderHooks");s(this,"loadComponent",async(o,e,t)=>{var l,f,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Ft(o);r&&(o=r);let i=y(y({},(l=this.loaderHooks)!=null?l:{}),(f=t==null?void 0:t.hooks)!=null?f:{}),a=e;if(a.myop)if(a.component){o=y({},o),o.instance=y({},o.instance);let x=await this.runSkinSelector(o,i);if(!x)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(x=await t.hooks.afterSkinSelected(y({},x))),o.instance.skinSelector={type:W.Dedicated,skin:x},t&&(t=y({},t),delete t.hooks),await ct(a,o,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(o,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let m=this.componentsLoaders.find(x=>x.type===p.loader.type);if(!m){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await m.load(o.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(x=>x!==d),this.components2init=this.components2init.filter(x=>x!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=Pt(d,o.type.props,p));try{await lt(d,o,this.components)}catch(x){throw x}return t!=null&&t.skipInit||await d.initiated(),d});s(this,"navigate",async(o,e,t)=>{if(o.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,o.container,y({hidden:!0,relative:{direction:"after",child:o.element}},t));return t.init&&await t.init(r),r.show(),o.dispose(),r}else{let r=o.element.nextSibling;return o.dispose(),this.loadComponent(e,o.container,y({relative:{direction:"before",child:r}},t))}})}};s(H,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$t});if(!window.myop.hostSDK){let n=new H;n.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$t}),window.myop.hostSDK=n}var ao=window.myop.hostSDK;Z("hostSDK",ao);var Ue=class extends h{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await H.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(m=>{let d=a.refs[m];d=d.__nonProxied||d,d.componentDefinition&&p.push({refName:m,componentDefinitionId:d.componentDefinition.id})}),this.messageToHost(new D(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var zt=(n,o)=>{if(!n){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!n||n.nodeType!==1))if(e){let t=new e(o),r={attributes:!0,childList:!0,subtree:!0};return t.observe(n,r),t}else window.addEventListener&&(n.addEventListener("DOMNodeInserted",o,!1),n.addEventListener("DOMNodeRemoved",o,!1))};var Ne=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&zt(document.body,()=>{this.messageToHost(new re)})})}};var Ut=n=>{if(!n)return null;if(n.tagName==="FORM"){let o=new FormData(n),e={formData:{},unmappedData:[]},t=n.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Ut(i),required:i.required,validity:R(i.validity,!0),myopId:a};e.unmappedData.push(m),p&&(!e.formData[p]||!e.formData[p].value||m.value)&&(e.formData[p]=m)}}),e}return n.type==="checkbox"||n.type==="radio"?n.checked?n.value:null:n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"?n.value:n.isContentEditable?n.innerText||n.textContent:null},qe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new z(Ut(r)),e)})})}};var We=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetAttributeMessage);s(this,"executor",e=>{let t=Ht(e.ref,document);t&&this.messageToHost(new se(t.getAttribute(e.name)),e)})}};var Ve=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new me)});return t.observe(document.body),()=>{t.disconnect()}})}};var Ge=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var gt=class extends J{constructor(){super();s(this,"version",ve);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new Me(this.messageToHost),new Ge(this.messageToHost),new he(this.messageToHost),new ye(this.messageToHost),new Ce(this.messageToHost),new be(this.messageToHost),new Te(this.messageToHost),new qe(this.messageToHost),new Ne(this.messageToHost),new Ve(this.messageToHost),new We(this.messageToHost),new Ue(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new U)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Z("IframeSDK",gt);export{gt as IframeSDK};
1
+ var xt=Object.defineProperty,Gt=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var Ct=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Qe=(n,o,e)=>o in n?xt(n,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[o]=e,y=(n,o)=>{for(var e in o||(o={}))Xt.call(o,e)&&Qe(n,e,o[e]);if(Ct)for(var e of Ct(o))Qt.call(o,e)&&Qe(n,e,o[e]);return n},D=(n,o)=>Gt(n,Jt(o));var Zt=(n,o)=>{for(var e in o)xt(n,e,{get:o[e],enumerable:!0})};var s=(n,o,e)=>Qe(n,typeof o!="symbol"?o+"":o,e);var j=class{constructor(o,e,t,r,i){this.myopId=o;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;s(this,"type","MyopElementRef")}};var bt=async n=>{if(typeof n=="function")n();else if(n instanceof Promise){let o=await n;typeof o=="function"&&o()}},h=class{constructor(o){this.messageToHost=o}},fe=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var c={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 ge={};Zt(ge,{AddEventListenerMessage:()=>ot,BaseMyopMessage:()=>M,BindClickMessage:()=>et,ChangeTextMessage:()=>tt,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>A,CreateRefComponentMessage:()=>oe,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>it,DetectedMyopRefsMessage:()=>q,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>z,EnvelopedMessage:()=>ne,EventListenerCallbackMessage:()=>U,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>E,ExecuteScriptReplyMessage:()=>F,GetAttributeMessage:()=>at,GetAttributeReplayMessage:()=>se,GetElementValueMessage:()=>st,InitMessage:()=>G,InitRequest:()=>N,InitResponse:()=>te,MessageDirection:()=>b,MutationObserverMessage:()=>re,MyopBindMessage:()=>T,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>Ye,Ref:()=>_,RefComponentCreatedMessage:()=>B,ResizeObserverMessage:()=>me,SetAttributeMessage:()=>nt,SetInnerHtml:()=>rt,SetMutationObserverMessage:()=>pt,SetResizeObserverMessage:()=>mt,stripFunction:()=>Et});var v=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+n/4).toString(16));var Yt=n=>{let o=[...n].map(e=>e.toString(16).padStart(2,"0")).join("");return[o.slice(0,8),o.slice(8,12),o.slice(12,16),o.slice(16,20),o.slice(20)].join("-")};var eo=n=>{let o=n.replace(/-/g,"+").replace(/_/g,"/");for(;o.length%4;)o+="=";let e=atob(o);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Ze=n=>{let o=eo(n);if(o.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<o.length;t+=16)e.push(Yt(o.slice(t,t+16)));return e};var wt=n=>new Promise(o=>setTimeout(o,n));var b=class{};s(b,"down","down"),s(b,"up","up");var M=class{constructor(){s(this,"id",v());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...o){return new this(...o)}isTypeof(o){return o.messageType===this.messageType}},Ye=class extends M{constructor(e){super();this.ref=e}},w=class extends M{constructor(e){super();this.replayToHandler=e}},T=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",v())}},_=class n{constructor(o,e){this.refConfig=o;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=D(y({},this),{component:null})}static create(o,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:o,behavior:{type:"code"}}),new n(r,t)}};var Tt="ClickReplayMessage",et=class extends T{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Tt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},A=class extends w{constructor(){super(...arguments);s(this,"messageType",Tt)}};var tt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var St="ExecuteScriptReplyMessage",to=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,oo=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Et=n=>{let o=n.match(to);if(o)return o[1]||o[3];{let e=n.match(oo);if(e)return e[1].trim()}},E=class extends T{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",St);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Et(this.content)}};s(E,"replierKey","send"),s(E,"completeStreamKey","completeStream");var F=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",St)}};var $=class extends E{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:m})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(m.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(m)):null},r);this.scriptInputs=t;this.scriptInputs=D(y({},t),{_script:e.toString()})}};var Rt="EventListenerCallbackMessage",ot=class extends T{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Rt);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},U=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Rt);this.content={e:t}}};var nt=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var vt="ElementValueReplayMessage",st=class extends T{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",vt);s(this,"messageType","GetElementValueMessage")}},z=class extends w{constructor(e){super();this.content=e;s(this,"messageType",vt)}};var rt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var G=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},te=class extends G{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},N=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var kt="RefComponentCreatedMessage",oe=class extends T{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",kt);s(this,"messageType","CreateRefComponentMessage")}},B=class extends w{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",kt)}};var ne=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Ht="DetectedMyopRefsMessage",it=class extends T{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Ht)}},q=class extends w{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Ht);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var Dt="GetAttributeReplayMessage",at=class extends T{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",Dt);s(this,"messageType","GetAttributeMessage")}},se=class extends w{constructor(e){super();this.content=e;s(this,"messageType",Dt)}};var k=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var pt=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},re=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var Bt="CleanupReplayMessage",ie=class extends T{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",Bt);s(this,"messageType","CleanupMessage")}},ae=class extends w{constructor(e){super();this.customCleanup=e;s(this,"messageType",Bt)}};var pe=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var mt=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},me=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var dt=class{constructor(o,e){this.id=o;this.context=e;s(this,"send",o=>{})}},J=class{constructor(){s(this,"messageToHandleAfterInit",[]);s(this,"components",{});s(this,"alwaysPassEnvelopesToHost",!1);s(this,"messageCleanupCache",{})}handleIncomeMessages(o){let e=o.data?o.data:o.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===c.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===c.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new dt(r),this.messageToHost(new te(r));return}if(t.messageType===c.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(m=>m.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(m=>m.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===c.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],bt(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let r=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){r=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var L={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var V={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ue={message:"message",code:"code"},X=class{};s(X,"code","code"),s(X,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ye={Segment:"Segment",Promo:"Promo",AB:"AB"},Q=class{constructor(o,e){this.container=o;this.shadowRoot=e;s(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));s(this,"getRoot",()=>this.shadowRoot||this.container)}};var S={id:"myop-id"};var he=class extends h{constructor(){super(...arguments);s(this,"messageType",c.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(S.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(S.id);a&&r.push(new j(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new q(e.handlerUniqueId,r))})}};var I=(n,o)=>o.querySelectorAll("[".concat(S.id,"='").concat(n.refConfig.selector,"']")),Lt=(n,o)=>{let e=I(n,o);return e.length?e.item(0):null};var Me=class extends h{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new A,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var Ie=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var ct=n=>n!==Object(n),no=n=>typeof n=="function",lt=n=>{if(ct(n))return!0;if(no(n)||Object.getPrototypeOf(n))return!1;for(let o in n){let e=n[o];if(typeof e=="object"){if(!lt(e))return!1}else{if(ct(e))continue;return!1}}return!0},R=(n,o={},e=!0,t=new WeakMap)=>{if(ct(n))return n;if(Array.isArray(n)){if(t.has(n))return t.get(n);let r=[];t.set(n,r);for(let i=0;i<n.length;i++){let a=n[i];r[i]=R(a,o,e,t)}return r}if(n!==null&&typeof n=="object"){if(t.has(n))return t.get(n);let r={};t.set(n,r);for(let i in n){let a=typeof o=="boolean"?o:o[i];a&&(a===!0?(e?n[i]!==void 0:n[i])&&(r[i]=R(n[i],!0,e,t)):typeof a=="object"&&(r[i]=R(n[i],a,e,t)))}return r}return{}};var Ce=(n,o,e)=>{let t=n.scriptInputs?n.scriptInputs:{};t.makeSerializable=R,t.send=o,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(n.script,")(...arguments)"))(t);o(i)};var xe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"executor",e=>{Ce(e,r=>{this.messageToHost(new F(e.handlerUniqueId,r))},new Q(document.documentElement))})}};var be="__federation__",_t="onLoad";var Z=(n,o)=>{window[be]&&window[be][n]&&window[be][n][_t]&&window[be][n][_t]({[n]:o})};var we=class extends h{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new U(e.handlerUniqueId,R(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Te=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var P=class{constructor(o,e,t){this.componentDefinition=o;this.container=e;s(this,"id","");s(this,"messageHandlers",{});s(this,"element");s(this,"_markedForDisposed",!1);s(this,"bind",(o,e)=>{this.messageHandlers[o]||(this.messageHandlers[o]=[]),this.messageHandlers[o].includes(e)||this.messageHandlers[o].push(e)});s(this,"bindWhen",(o,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[o]||(this.messageHandlers[o]=[]);let r=this.messageHandlers[o],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});s(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});s(this,"isInitiated",!1);s(this,"_whenInitiatedResolve");s(this,"_whenInitiatedReject");s(this,"_whenInitiated",new Promise((o,e)=>{this._whenInitiatedResolve=o,this._whenInitiatedReject=e}));s(this,"initiated",()=>this._whenInitiated);s(this,"props",{});s(this,"refs",{});this.id=(t==null?void 0:t.id)||H.Instance().assignId(o);let r=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(r," ").concat(this.id))},r),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(o){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=o}onMessageReceived(o){if(o.messageType===c.ExecuteComponentMethod){let t=o;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[o.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(o)}),t}return!1}sendCleanupMessage(o){o.source=this.id,o.destination=this.id,o.direction=b.down;let e=this.bindWhen(o.replyMessageKey,r=>r.replayToHandler===o.handlerUniqueId,r=>{o.handler(r),e()}),t=o.handler;delete o.handler,this.send(o),o.handler=t}send(o){o.source||(o.source=this.id),o.destination||(o.destination=this.id),o.direction=b.down;let e;if(o.handler){let t=o;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete o.handler}return o.ref&&(o.ref=o.ref.__nonProxied||o.ref),o.cleanable?()=>{this.sendCleanupMessage(new ie(o.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let o=this.messageHandlers.onDispose;o&&o.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Pt={notSerializableRefCall:(n,o)=>{throw new Error("\nThe input provided to '".concat(n.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(o," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(n.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 de=class extends P{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;s(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new ne(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var so=(n,o,e)=>{let t=document.createElement("a");return t.textContent=n,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(o,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},Se=(n,o,e,t,r,i)=>{let a=so("".concat(i.name," : ").concat(o),e,i);return t.insertBefore(a,r),r.style.border="1px solid #007BFF",r.style.display="block",()=>{r.style.border="unset",t.removeChild(a)}},Ot=(n,o,e)=>n?!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(o,"\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),Kt=(n,o,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(o,"\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."))},At=(n,o,e)=>{let t=o.reduce((i,a)=>D(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Ot(p,a,n))return!1;if(p.behavior.type===ue.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===V.localFrame){let d=p.behavior;return n.element.contentWindow[d.remap||a]}return Kt(p,a,n),!1}return p.mode==="output"?new Promise(m=>{let d=[];p.behavior.ref&&d.push(_.create(p.behavior.ref)),d.push(f=>{m(f)}),p.behavior.params&&d.push(...p.behavior.params);let l=ge[p.behavior.message];n.send(new l(...d))}):null},set:(i,a,p)=>{let m=t[a];if(Ot(m,a,n))return!1;if(m.behavior.type===ue.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===V.localFrame){let l=m.behavior;return n.element.contentWindow[l.remap||a]=p,!0}return Kt(m,a,n),!1}else if(m.mode==="input")if(m.behavior.type==="message"){let d=[];m.behavior.ref&&d.push(_.create(m.behavior.ref)),d.push(p),m.behavior.params&&d.push(...m.behavior.params);let l=ge[m.behavior.message];return n.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(n.componentDefinition.name,", ID: ").concat(n.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(m.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return n.props={},n.props=new Proxy(n.props,r),n},ro=(n,o)=>new Proxy(n,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{lt(p)||Pt.notSerializableRefCall(t,p)}),o.send(new $(({ref:p,propName:m,functionArgs:d,makeSerializable:l})=>{if(p){let f=p[m];return l(typeof f=="function"?p[m](...d):f,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return o.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),ft=async(n,o,e,t)=>{let r=n.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(o.type,r,t);e.push(p),await r.initiated();let m=setTimeout(()=>{a("timeout")},5e3);r.send(new oe(n.refConfig,o,D(y({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(m),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(f=>f.id==p.id);if(l!==p){r.refs[n.refConfig.name]=l,i(l);return}else p.setInitiated(),r.refs[n.refConfig.name]=p;d.nestedRefs.forEach(f=>{let g=o.instance.resolvedNestedComponents.find(x=>x.type.id===f.componentDefinitionId).type,u=new de(g,p);u.setInitiated(),p.refs[f.refName]=u,e.push(u)});try{await gt(p,o,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},gt=async(n,o,e,t=!1)=>{n.refs||(n.refs={});let r=Object.values(n.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var m;if(i.behavior.type==X.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(m=o.instance.resolvedNestedComponents)==null?void 0:m.find(g=>g.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let f=_.create("",i,n);try{let g=await ft(f,l,e);n.refs[i.name]=g,a()}catch(g){p(g)}}else try{let d=_.create("",i,n);n.refs[i.name]=ro(d,n),a()}catch(d){}}));try{await Promise.all(r)}catch(i){throw i}};var Y=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;s(this,"cleanupInspect");s(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new E(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new E(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:m}=document.documentElement.getBoundingClientRect();t({height:p,width:m})});return a.observe(document.documentElement),a.observe(document.body),{height:r,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new E(()=>{let{height:t,width:r}=document.documentElement.getBoundingClientRect();return{height:t,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});s(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new E(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===c.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});s(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=Se(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===c.In.MutationObserverMessage||e.messageType===c.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var O=class{constructor(){s(this,"appendChild",(o,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return o.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return o.insertBefore(e,i||null)}}else return o.appendChild(e)})}};var io=(n,o,e)=>{let t=new URL(n);return t.searchParams.append(o,e),t.toString()},Ee=class extends O{constructor(){super(...arguments);s(this,"type",L.IframeLoader);s(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let m=v(),d="myop-comp-".concat(m);a=document.createElement("iframe"),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(a.style.visibility="hidden"),a=this.appendChild(r,a,i);let l=t.loader.url;i!=null&&i._hasParent&&(l=io(l,"_myop-comp",m));let f="";i!=null&&i.elementAttributes&&(f=Object.entries(i==null?void 0:i.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(d,'"\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(i!=null&&i.hidden?"0":"1",";\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",';\n "\n src="').concat(l,'"\n ').concat(f,"\n ></iframe>"),a=r.querySelector("#".concat(d))}return new Y(e,t,r,a,i)})}};var Re={webcomponent_message_key:"myop_webcomponent_message"};var ee=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Re.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});s(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=Se(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 ut={},ve=class extends O{constructor(){super(...arguments);s(this,"type",L.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;ut[a.url]?console.log("Module alreday loaded or in loading process"):ut[a.url]=new Promise((d,l)=>{let f=a.url,g=document.createElement("script");g.type="module",g.src=f,g.onload=()=>{d()},g.onerror=()=>{l()},document.head.appendChild(g)}),await ut[a.url],await wt(1);let p="myop-comp-".concat(v()),m=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),i!=null&&i._environment&&(m._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ke="0.1.47";var C=class extends fe{constructor(e,t){super(e);this.context=t;s(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(D(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var He=class extends C{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=()=>{r(new A(e.handlerUniqueId))};p.addEventListener("click",m),a.push(()=>{p.removeEventListener("click",m)})}),()=>{a.forEach(p=>p())}})}};var De=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Be=class extends Q{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Le=class extends C{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(S.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(S.id);p&&i.push(new j(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new q(e.handlerUniqueId,i))});s(this,"messageType",c.DetectMyopRefsMessage)}};var _e=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var Pe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=d=>{r(new U(e.handlerUniqueId,R(d,e.serializableSkeleton)))};p.addEventListener(e.type,m),a.push(()=>{p.removeEventListener(e.type,m)})}),()=>{a.forEach(p=>p())}})}};var Oe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=H.Instance(),m=p.components.find(g=>g.id===e.options.id);m&&m.dispose();let d=p.components.indexOf(m);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),f=[];Object.keys(l.refs).forEach(g=>{let u=l.refs[g];u=u.__nonProxied||u,u.componentDefinition&&f.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new B(e.handlerUniqueId,f))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new B(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Ke=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{Ce(e,a=>{r(new F(e.handlerUniqueId,a))},t)})}};var Ft=n=>{if(!n)return null;if(n.tagName==="FORM"){let o=new FormData(n),e={formData:{},unmappedData:[]},t=n.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Ft(i),required:i.required,validity:R(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(m):(e.unmappedData.push(e.formData[p]),e.formData[p]=m):e.formData[p]=m:e.unmappedData.push(m)}}),e}return n.type==="checkbox"||n.type==="radio"?n.checked?n.value:null:n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"?n.value:n.isContentEditable?n.innerText||n.textContent:null},Ae=class extends C{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new z(Ft(a)),e)})})}};var Fe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var ce=class extends J{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Re.webcomponent_message_key,r=>{let i=r.data?r.data:r.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(r),a.messageType===c.InitMessage){let p=a.content.id;this.components[p].context=new Be(e,t)}}}),setTimeout(()=>{this.messageToHost(new N)},1)});s(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});s(this,"supportedHandlers",[new De(this.messageToHost,this.components),new Fe(this.messageToHost,this.components),new He(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Pe(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new Oe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};Z("WebComponentSDK",ce);var $t=[],$e,Ut=async()=>($e||($e=new ce,$e.init()),$e);function ao(n,o){return class extends HTMLElement{connectedCallback(){let e=o===V.open?"open":"closed",t=this.attachShadow({mode:e});Ut().then(r=>{r.connectedCallback(this,t),t.innerHTML=n})}}}var po=(n,o,e)=>{customElements.define(n,ao(o,e)),console.log("define('".concat(n,"') was called, web component ready to use"))},mo=n=>n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),co=n=>(n=mo(n),n.replace(/_/g,"-"));var Ue=class extends O{constructor(){super(...arguments);s(this,"type",L.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(v()),m;if(a.shadowRootMode===V.localFrame){let d=v(),l="myop-comp-".concat(d),f=document.createElement("iframe");r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(f.style.visibility="hidden"),f=this.appendChild(r,f,i),f.id=l,f.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ")),r.appendChild(f);let g=f.contentDocument||f.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let K=new DOMParser().parseFromString(a.HTML,"text/html"),Xe=K.getElementById("myop_preview");Xe==null||Xe.removeAttribute("type");let Mt=K.implementation.createHTMLDocument();Mt.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let It=Mt.body.firstChild;It&&K.head&&K.head.insertBefore(K.importNode(It,!0),K.head.firstChild),u=K.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 x=new Y(e,t,r,f,i);return a.autoHeight&&(f.onload=()=>{x.observeSizeBasedOnDocumentElement()}),x}if(a.shadowRootMode===V.none){let d=document.createElement("template");d.innerHTML=a.HTML,m=d.content.firstElementChild,Ut().then(l=>{l.connectedCallback(m,m)})}else{let d=co(e.name+t.id);$t.includes(d)||(po(d,a.HTML,a.shadowRootMode),$t.push(d)),m=document.createElement(d)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ze=class ze{constructor(o="https://cloud.myop.dev"){this._baseUrl=o;s(this,"userFlows",{})}async fetchComponent(o,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===o):(await this.fetchAutoFlow(o)).components[0]}async fetchAutoFlow(o){return this.userFlows[o]||(this.userFlows[o]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(o,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[o]}async fetchFlow(o){return this.userFlows[o]||(this.userFlows[o]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(o,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[o]}};s(ze,"Main",new ze);var le=ze;var Ne=class Ne{constructor(o="https://cloud.myop.dev"){this._baseUrl=o;s(this,"variants",{})}async fetchComponent(o,e){return this.variants[o]||(this.variants[o]=new Promise(async(t,r)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/consume?id=").concat(o,"&env=").concat(e))).json();t(a.item)}catch(i){r(i)}})),await this.variants[o]}};s(Ne,"Main",new Ne);var zt=Ne;var Nt=async n=>{try{let o=new URL(window.location.href),t=new URLSearchParams(o.search).get("myopOverride");if(t){let[r,...i]=Ze(t);switch(r){case"component":{let[a,p]=i,m=await le.Main.fetchComponent(a);if(m&&m.type.skins.find(l=>l.id===p))return m.instance.skinSelector={type:W.Dedicated,skin:{id:p}},m}break;default:{let[a,p]=Ze(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===n.type.id);if(d&&d.instance.skinSelector.type===W.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(f=>f.id===p);if((l==null?void 0:l.type)===ye.Segment){let f=l,u=d.instance.skinSelector.segments.find(x=>x.segmentId===f.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var qt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",H=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",ke);s(this,"type2InstanceCount",{});s(this,"assignId",o=>(this.type2InstanceCount[o.id]||(this.type2InstanceCount[o.id]=0),"".concat(o.id,"_").concat(++this.type2InstanceCount[o.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(o=>{o.inspect&&o.inspect()}))});s(this,"incomingMessageHandler",o=>{if(o.origin,document.location.origin,o.data.myop){if(o.data.direction!==b.up&&o.data.messageType!==c.EnvelopedMessage)return;let e=o.data;if(e.messageType===c.InitRequest){this.components2init.forEach(r=>{r.send(new G(r.id))});return}if(e.messageType===c.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let r=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});r==null||r.setInitiated();return}if(e.messageType===c.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===k.name?i.onMessageReceived(r.message):(r.message.route=r.route,i.send(r.message));return}}else{let a=this.components.find(p=>p.id===r.message.destination);a&&a.send(r.message)}return}let t=this.components.find(r=>r.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)}}});s(this,"send",o=>{let e=new MessageEvent("",{data:o});this.incomingMessageHandler(e)});s(this,"init",o=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Ee,new ve,new Ue];if(this.componentsLoaders=[...e],o){let t={};o.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});s(this,"_getSkinIdBySkinSelector",async(o,e=[],t)=>{var i;async function r(a,p){for(let m of a)if(await p(m))return m}switch(o.type){case"DedicatedSkin":case W.Dedicated:return((i=o.skin)==null?void 0:i.id)||o.skins[0].id;case W.Segmented:{let p=await r(o.segments,async m=>{if(m.segmentId==="Default")return!0;let d=e.find(u=>u.type===ye.Segment?u.segment.id===m.segmentId:!1);if(!d)throw new Error("experience not found");let f=d.segment,g=(t||{})[f.function];return g?await g():(console.warn("segmentId:".concat(m.segmentId,", ").concat(f.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});s(this,"runSkinSelector",async(o,e)=>{let t=await this._getSkinIdBySkinSelector(o.instance.skinSelector,o.instance.resolvedExperiences,e);return o.type.skins.find(r=>r.id===t)});s(this,"loaderHooks");s(this,"loadComponent",async(o,e,t)=>{var l,f,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Nt(o);r&&(o=r);let i=y(y({},(l=this.loaderHooks)!=null?l:{}),(f=t==null?void 0:t.hooks)!=null?f:{}),a=e;if(a.myop)if(a.component){o=y({},o),o.instance=y({},o.instance);let x=await this.runSkinSelector(o,i);if(!x)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(x=await t.hooks.afterSkinSelected(y({},x))),o.instance.skinSelector={type:W.Dedicated,skin:x},t&&(t=y({},t),delete t.hooks),await ft(a,o,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(o,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let m=this.componentsLoaders.find(x=>x.type===p.loader.type);if(!m){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await m.load(o.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(x=>x!==d),this.components2init=this.components2init.filter(x=>x!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=At(d,o.type.props,p));try{await gt(d,o,this.components)}catch(x){throw x}return t!=null&&t.skipInit||await d.initiated(),d});s(this,"navigate",async(o,e,t)=>{if(o.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,o.container,y({hidden:!0,relative:{direction:"after",child:o.element}},t));return t.init&&await t.init(r),r.show(),o.dispose(),r}else{let r=o.element.nextSibling;return o.dispose(),this.loadComponent(e,o.container,y({relative:{direction:"before",child:r}},t))}})}};s(H,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:qt});if(!window.myop.hostSDK){let n=new H;n.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:qt}),window.myop.hostSDK=n}var yt=window.myop.hostSDK;Z("hostSDK",yt);var qe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await H.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(m=>{let d=a.refs[m];d=d.__nonProxied||d,d.componentDefinition&&p.push({refName:m,componentDefinitionId:d.componentDefinition.id})}),this.messageToHost(new B(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new B(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Vt=(n,o)=>{if(!n){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!n||n.nodeType!==1))if(e){let t=new e(o),r={attributes:!0,childList:!0,subtree:!0};return t.observe(n,r),t}else window.addEventListener&&(n.addEventListener("DOMNodeInserted",o,!1),n.addEventListener("DOMNodeRemoved",o,!1))};var Ve=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&Vt(document.body,()=>{this.messageToHost(new re)})})}};var Wt=n=>{if(!n)return null;if(n.tagName==="FORM"){let o=new FormData(n),e={formData:{},unmappedData:[]},t=n.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Wt(i),required:i.required,validity:R(i.validity,!0),myopId:a};e.unmappedData.push(m),p&&(!e.formData[p]||!e.formData[p].value||m.value)&&(e.formData[p]=m)}}),e}return n.type==="checkbox"||n.type==="radio"?n.checked?n.value:null:n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"?n.value:n.isContentEditable?n.innerText||n.textContent:null},We=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new z(Wt(r)),e)})})}};var je=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetAttributeMessage);s(this,"executor",e=>{let t=Lt(e.ref,document);t&&this.messageToHost(new se(t.getAttribute(e.name)),e)})}};var Ge=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new me)});return t.observe(document.body),()=>{t.disconnect()}})}};var Je=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var ht=class extends J{constructor(){super();s(this,"version",ke);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new Ie(this.messageToHost),new Je(this.messageToHost),new Me(this.messageToHost),new he(this.messageToHost),new xe(this.messageToHost),new we(this.messageToHost),new Te(this.messageToHost),new We(this.messageToHost),new Ve(this.messageToHost),new Ge(this.messageToHost),new je(this.messageToHost),new qe(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new N)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Z("IframeSDK",ht);export{ht as IframeSDK};
@@ -1731,7 +1731,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
1731
1731
  };
1732
1732
 
1733
1733
  // version:myop-sdk-version
1734
- var myop_sdk_version_default = "0.1.46";
1734
+ var myop_sdk_version_default = "0.1.47";
1735
1735
 
1736
1736
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
1737
1737
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
@@ -2116,6 +2116,8 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
2116
2116
  if (options == null ? void 0 : options._inspection) {
2117
2117
  const parser = new DOMParser();
2118
2118
  const _doc = parser.parseFromString(loaderConfig.HTML, "text/html");
2119
+ const myop_preview_script = _doc.getElementById("myop_preview");
2120
+ myop_preview_script == null ? void 0 : myop_preview_script.removeAttribute("type");
2119
2121
  const temp = _doc.implementation.createHTMLDocument();
2120
2122
  temp.body.innerHTML = "<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";
2121
2123
  const node = temp.body.firstChild;
@@ -2223,6 +2225,34 @@ var _CloudRepository = class _CloudRepository {
2223
2225
  __publicField(_CloudRepository, "Main", new _CloudRepository());
2224
2226
  var CloudRepository = _CloudRepository;
2225
2227
 
2228
+ // src/helpers/EnableV2.ts
2229
+ var _v2_CloudRepository = class _v2_CloudRepository {
2230
+ constructor(_baseUrl = "https://cloud.myop.dev") {
2231
+ this._baseUrl = _baseUrl;
2232
+ __publicField(this, "variants", {});
2233
+ }
2234
+ async fetchComponent(componentId, environmentIdentifier) {
2235
+ if (!this.variants[componentId]) {
2236
+ this.variants[componentId] = new Promise(
2237
+ async (resolve, reject) => {
2238
+ try {
2239
+ const res = await fetch(
2240
+ "".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(environmentIdentifier)
2241
+ );
2242
+ const json = await res.json();
2243
+ resolve(json.item);
2244
+ } catch (e) {
2245
+ reject(e);
2246
+ }
2247
+ }
2248
+ );
2249
+ }
2250
+ return await this.variants[componentId];
2251
+ }
2252
+ };
2253
+ __publicField(_v2_CloudRepository, "Main", new _v2_CloudRepository());
2254
+ var v2_CloudRepository = _v2_CloudRepository;
2255
+
2226
2256
  // src/host/myopOverride.ts
2227
2257
  var checkMyopOverride = async (componentConfig) => {
2228
2258
  try {