@myop/sdk 0.1.42 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled-declarations.d.ts +4 -3
- package/dist/cjs/{_IframeSDK.4fce182a.js → _IframeSDK.dd7fa267.js} +117 -44
- package/dist/cjs/_IframeSDK.dd7fa267.js.map +7 -0
- package/dist/cjs/_IframeSDK.f382f9c1.min.js +1 -0
- package/dist/cjs/_WebComponentSDK.9306948e.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.a2aed5b5.js → _WebComponentSDK.d843788d.js} +117 -44
- package/dist/cjs/_WebComponentSDK.d843788d.js.map +7 -0
- package/dist/cjs/_hostSDK.39162c05.min.js +1 -0
- package/dist/cjs/{_hostSDK.f1314596.js → _hostSDK.a057f932.js} +117 -44
- package/dist/cjs/_hostSDK.a057f932.js.map +7 -0
- package/dist/cjs/myop_sdk.js +11 -11
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/module/Iframe/index.js +137 -54
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +139 -56
- package/dist/module/SDK.js.map +3 -3
- package/dist/module/common/index.d.ts +1 -0
- package/dist/module/common/index.js +1 -1
- package/dist/module/common/index.js.map +2 -2
- package/dist/module/host/componentCore.d.ts +2 -2
- package/dist/module/host/components/myopIframeComponent.d.ts +1 -1
- package/dist/module/host/index.js +137 -54
- package/dist/module/host/index.js.map +3 -3
- package/dist/module/webcomponent/index.js +137 -54
- package/dist/module/webcomponent/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.4fce182a.js.map +0 -7
- package/dist/cjs/_IframeSDK.6ba9f7e0.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.a2aed5b5.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.dc12528b.min.js +0 -1
- package/dist/cjs/_hostSDK.5ea0f6d9.min.js +0 -1
- package/dist/cjs/_hostSDK.f1314596.js.map +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var tt=Object.defineProperty,St=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var et=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var He=(o,n,t)=>n in o?tt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,h=(o,n)=>{for(var t in n||(n={}))Et.call(n,t)&&He(o,t,n[t]);if(et)for(var t of et(n))vt.call(n,t)&&He(o,t,n[t]);return o},E=(o,n)=>St(o,Rt(n));var kt=(o,n)=>{for(var t in n)tt(o,t,{get:n[t],enumerable:!0})};var i=(o,n,t)=>He(o,typeof n!="symbol"?n+"":n,t);var oe=class{constructor(n,t,e,s,r){this.myopId=n;this.htmlTagName=t;this.BoundingRect=e;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var nt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},De=class{constructor(n){this.messageToHost=n}},se=class extends De{constructor(t,e){super(t);this.messageToHost=t;this.context=e}};var l={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 re={};kt(re,{AddEventListenerMessage:()=>Pe,BaseMyopMessage:()=>y,BindClickMessage:()=>Le,ChangeTextMessage:()=>_e,CleanupMessage:()=>Z,CleanupReplayMessage:()=>Y,ClickReplayMessage:()=>N,CreateRefComponentMessage:()=>J,CustomRefMessage:()=>_,DetectMyopRefsMessage:()=>$e,DetectedMyopRefsMessage:()=>Q,DisposeMessage:()=>ee,ElementValueReplayMessage:()=>V,EnvelopedMessage:()=>X,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>T,ExecuteScriptMessage:()=>b,ExecuteScriptReplyMessage:()=>W,GetAttributeMessage:()=>Ae,GetAttributeReplayMessage:()=>Ue,GetElementValueMessage:()=>Ke,InitMessage:()=>O,InitRequest:()=>G,InitResponse:()=>j,MessageDirection:()=>x,MutationObserverMessage:()=>Ne,MyopBindMessage:()=>C,MyopBindReplayMessage:()=>I,MyopElementMessage:()=>Be,Ref:()=>H,RefComponentCreatedMessage:()=>K,ResizeObserverMessage:()=>qe,SetAttributeMessage:()=>Oe,SetInnerHtml:()=>Fe,SetMutationObserverMessage:()=>ze,SetResizeObserverMessage:()=>We,stripFunction:()=>at});var w=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Ht=o=>{let n=[...o].map(t=>t.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Dt=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))};var ot=o=>{let n=Dt(o);if(n.length%16!==0)throw new Error("Invalid input length");let t=[];for(let e=0;e<n.length;e+=16)t.push(Ht(n.slice(e,e+16)));return t};var st=o=>new Promise(n=>setTimeout(n,o));var x=class{};i(x,"down","down"),i(x,"up","up");var y=class{constructor(){i(this,"id",w());i(this,"myop",!0);i(this,"content");i(this,"source");i(this,"destination");i(this,"route");i(this,"ref");i(this,"direction");i(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},Be=class extends y{constructor(t){super();this.ref=t}},I=class extends y{constructor(t){super();this.replayToHandler=t}},C=class extends y{constructor(t){super();this.handler=t;i(this,"handlerUniqueId",w())}},H=class o{constructor(n,t){this.refConfig=n;this.component=t;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=E(h({},this),{component:null})}static create(n,t,e){let s=t;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,e)}};var rt="ClickReplayMessage",Le=class extends C{constructor(t,e){super(e);this.ref=t;i(this,"replyMessageKey",rt);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},N=class extends I{constructor(){super(...arguments);i(this,"messageType",rt)}};var _e=class extends y{constructor(t,e){super();this.ref=t;i(this,"messageType","ChangeTextMessage");this.content=e}};var it="ExecuteScriptReplyMessage",Bt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Lt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,at=o=>{let n=o.match(Bt);if(n)return n[1]||n[3];{let t=o.match(Lt);if(t)return t[1].trim()}},b=class extends C{constructor(t,e=()=>{},s){super(e);this.scriptInputs=s;i(this,"replyMessageKey",it);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=t.toString(),this.content=t.toString(),this.content=at(this.content)}};i(b,"replierKey","send"),i(b,"completeStreamKey","completeStream");var W=class extends I{constructor(t,e){super(t);this.replayToHandler=t;this.content=e;i(this,"messageType",it)}};var _=class extends b{constructor(t,e,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:c})=>{let d=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(c.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},s);this.scriptInputs=e;this.scriptInputs=E(h({},e),{_script:t.toString()})}};var pt="EventListenerCallbackMessage",Pe=class extends C{constructor(t,e,s){super(s);this.ref=t;this.type=e;this.handler=s;i(this,"replyMessageKey",pt);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(t){return this.serializableSkeleton=t,this}},q=class extends I{constructor(t,e){super(t);this.replayToHandler=t;this.e=e;i(this,"messageType",pt);this.content={e}}};var Oe=class extends y{constructor(t,e,s){super();this.ref=t;this.name=e;this.value=s;i(this,"messageType","SetAttributeMessage")}};var ct="ElementValueReplayMessage",Ke=class extends C{constructor(t,e){super(e);this.ref=t;i(this,"replyMessageKey",ct);i(this,"messageType","GetElementValueMessage")}},V=class extends I{constructor(t){super();this.content=t;i(this,"messageType",ct)}};var Fe=class extends y{constructor(t,e){super();this.ref=t;i(this,"messageType","SetInnerHtml");this.content=e}};var O=class extends y{constructor(t){super();i(this,"messageType","InitMessage");this.content={id:t}}isTypeof(t){return t.messageType===this.messageType}},j=class extends O{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},G=class extends y{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var dt="RefComponentCreatedMessage",J=class extends C{constructor(t,e,s,r){super(r);this.refConfig=t;this.nestedComponentConfig=e;this.options=s;i(this,"replyMessageKey",dt);i(this,"messageType","CreateRefComponentMessage")}},K=class extends I{constructor(t,e,s){super(t);this.replayToHandler=t;this.nestedRefs=e;this.failed=s;i(this,"messageType",dt)}};var X=class extends y{constructor(t,e){super();this.destination=t;this.message=e;i(this,"messageType","EnvelopedMessage");let s=e;this.route=[t,...s.route?s.route:[]]}};var mt="DetectedMyopRefsMessage",$e=class extends C{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",mt)}},Q=class extends I{constructor(t,e){super(t);this.replayToHandler=t;i(this,"messageType",mt);this.content=e}isTypeof(t){return t.messageType===this.messageType}};var lt="GetAttributeReplayMessage",Ae=class extends C{constructor(t,e,s){super(s);this.ref=t;this.name=e;i(this,"replyMessageKey",lt);i(this,"messageType","GetAttributeMessage")}},Ue=class extends I{constructor(t){super();this.content=t;i(this,"messageType",lt)}};var T=class extends y{constructor(t){super();this.method=t;i(this,"messageType","ExecuteComponentMethod")}};var ze=class extends y{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},Ne=class extends y{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ft="CleanupReplayMessage",Z=class extends C{constructor(t,e){super(e);this.cleanupForMessageId=t;i(this,"replyMessageKey",ft);i(this,"messageType","CleanupMessage")}},Y=class extends I{constructor(t){super();this.customCleanup=t;i(this,"messageType",ft)}};var ee=class extends y{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var We=class extends y{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},qe=class extends y{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var Ve=class{constructor(n,t){this.id=n;this.context=t;i(this,"send",n=>{})}},ie=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let t=n.data?n.data:n.detail;if(!(!t||!t.myop)){let e=t;if(e.direction!==x.down)return;if(e.messageType===l.DisposeMessage){e.destination&&delete this.components[e.destination];return}if(e.messageType===l.InitMessage){let s=e.content.id;if(this.components[s])return;this.components[s]=new Ve(s),this.messageToHost(new j(s));return}if(e.messageType===l.EnvelopedMessage){let s=e,r=s.message;if(e=r,this.alwaysPassEnvelopesToHost||this.components[e.destination]){let a=myop.hostSDK.components.find(c=>c.id===r.destination);if(a){a.send(r);return}let p=myop.hostSDK.components.find(c=>c.id===s.destination);if(p){p.send(r);return}}else return}if(e.messageType){if(e.messageType===l.CleanupMessage){let r=e,a=this.messageCleanupCache[r.cleanupForMessageId],p=new Y(!!a);p.destination=e.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],nt(a).then(()=>{this.messageToHost(p,r)}).catch(()=>{})):this.messageToHost(p,r);return}let s=!1;this.supportedHandlers.forEach(r=>{if(r.messageType===e.messageType){s=!0;let a=r.executor(e);if(e.cleanable&&a&&(this.messageCleanupCache[e.id]=a),a&&!e.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&e.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var $={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"};var pe={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var F=class{};i(F,"code","code"),i(F,"component","component");var A={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ce={Segment:"Segment",Promo:"Promo",AB:"AB"},ae=class{constructor(n,t){this.container=n;this.shadowRoot=t;i(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));i(this,"getRoot",()=>this.shadowRoot||this.container)}};var de={webcomponent_message_key:"myop_webcomponent_message"};var M=class extends se{constructor(t,e){super(t);this.context=e;i(this,"executor",t=>{if(t.destination){let e=t.destination;if(this.context[e].context){let s=(r,a)=>{this.messageToHost(E(h({},r),{source:t.destination?t.destination:t.source,destination:t.source?t.source:t.destination}),a)};return this.innerExecutor(t,this.context[e].context,s)}else debugger}else debugger})}};var v={id:"myop-id"};var S=(o,n)=>n.querySelectorAll("[".concat(v.id,"='").concat(o.refConfig.selector,"']"));var me=class extends M{constructor(){super(...arguments);i(this,"messageType",l.BindClickMessage);i(this,"innerExecutor",(t,e,s)=>{let r=S(t.ref,e.shadowRoot),a=[];return r.forEach(p=>{let c=()=>{s(new N(t.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var le=class extends M{constructor(){super(...arguments);i(this,"messageType",l.ChangeTextMessage);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.textContent=t.content})})}};var fe=class extends ae{constructor(t,e){super(t,e);this.container=t;this.shadowRoot=e}};var ge=class extends M{constructor(){super(...arguments);i(this,"innerExecutor",(t,e)=>{let s=e.shadowRoot.querySelectorAll("[".concat(v.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(v.id);p&&r.push(new oe(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Q(t.handlerUniqueId,r))});i(this,"messageType",l.DetectMyopRefsMessage)}};var ue="__federation__",gt="onLoad";var ye=(o,n)=>{window[ue]&&window[ue][o]&&window[ue][o][gt]&&window[ue][o][gt]({[o]:n})};var he=class extends M{constructor(){super(...arguments);i(this,"messageType",l.SetAttributeMessage);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.setAttribute(t.name,t.value)})})}};var je=o=>o!==Object(o),_t=o=>typeof o=="function",Ge=o=>{if(je(o))return!0;if(_t(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let t=o[n];if(typeof t=="object"){if(!Ge(t))return!1}else{if(je(t))continue;return!1}}return!0},k=(o,n={},t=!0,e=new WeakMap)=>{if(je(o))return o;if(Array.isArray(o)){if(e.has(o))return e.get(o);let s=[];e.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=k(a,n,t,e)}return s}if(o!==null&&typeof o=="object"){if(e.has(o))return e.get(o);let s={};e.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(t?o[r]!==void 0:o[r])&&(s[r]=k(o[r],!0,t,e)):typeof a=="object"&&(s[r]=k(o[r],a,t,e)))}return s}return{}};var Me=class extends M{constructor(){super(...arguments);i(this,"messageType",l.AddEventListenerMessage);i(this,"innerExecutor",(t,e,s)=>{let r=S(t.ref,e.shadowRoot),a=[];return r.forEach(p=>{let c=d=>{s(new q(t.handlerUniqueId,k(d,t.serializableSkeleton)))};p.addEventListener(t.type,c),a.push(()=>{p.removeEventListener(t.type,c)})}),()=>{a.forEach(p=>p())}})}};var D=class{constructor(n,t,e){this.componentDefinition=n;this.container=t;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,t)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(t)||this.messageHandlers[n].push(t)});i(this,"bindWhen",(n,t,e)=>{if(!e)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>t(a)?(e(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,t)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=t}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(e==null?void 0:e.id)||B.Instance().assignId(n);let s=e!=null&&e.timeout?e==null?void 0:e.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===l.ExecuteComponentMethod){let e=n;return this[e.method]?this[e.method](e.content):console.log("method not found ".concat(e.method," on component"),this),!0}let t=this.messageHandlers[n.messageType];if(t&&t.length){let e=!1;return t.forEach(s=>{e=e||s(n)}),e}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=x.down;let t=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),t()}),e=n.handler;delete n.handler,this.send(n),n.handler=e}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=x.down;let t;if(n.handler){let e=n;t=this.bindWhen(e.replyMessageKey,s=>s.replayToHandler===e.handlerUniqueId,e.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Z(n.id,e=>{})),t&&t()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ee);let n=this.messageHandlers.onDispose;n&&n.forEach(t=>{t(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var ut={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var te=class extends D{constructor(t,e,s){super(t,e.container,s);this.componentDefinition=t;this.parent=e;i(this,"send",t=>{let e=t.handler,s=super.send(t);return this.parent.send(new X(this.id,t)),t.handler=e,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new T("dispose")),super.dispose()})}hide(){this.send(new T("hide"))}show(){this.send(new T("show"))}inspect(){return this.send(new T("inspect"))}setHeightBasedOnDocumentElement(){this.send(new T("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new T("setHeightBasedOnScrollHeight"))}onMessageReceived(t){return super.onMessageReceived(t)}};var Pt=(o,n,t)=>{let e=document.createElement("a");return e.textContent=o,e.style.position="relative",e.style.padding="0 5px",e.style.fontSize="14px",e.style.top="0",e.style.top="".concat(n,"px"),e.style.transform="translateX(-50%)",e.target="_blank",e.href="https://dashboard.myop.dev/dashboard/component/".concat(t.id),e},Ie=(o,n,t,e,s,r)=>{let a=Pt("".concat(r.name," : ").concat(n),t,r);return e.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",e.removeChild(a)}},yt=(o,n)=>{let t=n.reduce((s,r)=>E(h({},s),{[r.name]:h({},r)}),{}),e={get:(s,r)=>{let a=t[r];return a.mode==="output"?new Promise(p=>{let c=[];a.behavior.ref&&c.push(H.create(a.behavior.ref)),c.push(u=>{p(u)}),a.behavior.params&&c.push(...a.behavior.params);let d=re[a.behavior.message];o.send(new d(...c))}):null},set:(s,r,a)=>{let p=t[r];if(!p)throw new 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(r,"\n")+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(o.componentDefinition.id," or consult the developer guide."));if(p.mode==="input")if(p.behavior.type==="message"){let c=[];p.behavior.ref&&c.push(H.create(p.behavior.ref)),c.push(a),p.behavior.params&&c.push(...p.behavior.params);let d=re[p.behavior.message];return o.send(new d(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(r,"\n")+"Behavior Field: ".concat(p.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,e),o},Ot=(o,n)=>new Proxy(o,{get(t,e){return t[e]?t[e]:(...r)=>new Promise(a=>{r.forEach(p=>{Ge(p)||ut.notSerializableRefCall(e,p)}),n.send(new _(({ref:p,propName:c,functionArgs:d,makeSerializable:u})=>{if(p){let m=p[c];return u(typeof m=="function"?p[c](...d):m,!0)}return null},{elementId:t.refConfig.selector,propName:e,functionArgs:r},p=>{a(p.content)}))})},set(t,e,s){return n.send(new _(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:t.refConfig.selector,propValue:s,propName:e},r=>{})),!0}}),Je=async(o,n,t,e)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(r,a)=>{let p=new te(n.type,s,e);t.push(p),await s.initiated();let c=setTimeout(()=>{a("timeout")},5e3);s.send(new J(o.refConfig,n,E(h({},e||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(c),d.failed){a("CreateRefComponentMessage failed");return}let u=t.find(m=>m.id==p.id);if(u!==p){s.refs[o.refConfig.name]=u,r(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;d.nestedRefs.forEach(m=>{let f=n.instance.resolvedNestedComponents.find(R=>R.type.id===m.componentDefinitionId).type,g=new te(f,p);g.setInitiated(),p.refs[m.refName]=g,t.push(g)});try{await Xe(p,n,t,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(m){a(m)}}))})},Xe=async(o,n,t,e=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(r=>new Promise(async(a,p)=>{var c;if(r.behavior.type==F.component){if(e){a();return}let d=r.behavior.componentId;d||(d=r.behavior.instance.componentId);let u=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(f=>f.type.id===d);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=H.create("",r,o);try{let f=await Je(m,u,t);o.refs[r.name]=f,a()}catch(f){p(f)}}else try{let d=H.create("",r,o);o.refs[r.name]=Ot(d,o),a()}catch(d){}}));try{await Promise.all(s)}catch(r){throw r}};var U=class extends D{constructor(t,e,s,r,a){super(t,s,a);this.componentConfig=t;this.container=s;this.IframeElement=r;i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let t=this.send(new b(()=>window.document.documentElement.scrollHeight,e=>{this.IframeElement.style.height="".concat(e.content,"px"),t()}))});i(this,"observeSizeBasedOnDocumentElement",()=>{let t=this.send(new b(({send:e})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();e({height:p,width:c})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px")}))});i(this,"setSizeBasedOnDocumentElement",()=>{let t=this.send(new b(()=>{let{height:e,width:s}=document.documentElement.getBoundingClientRect();return{height:e,width:s}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px"),t()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let t=this.send(new b(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},e=>{this.IframeElement.style.height=e.content,t()}))});i(this,"send",t=>{var r,a;let e=h({},t);if(e.messageType===l.ExecuteComponentMethod)return this[e.method](),()=>{};e.direction=x.down;let s=super.send(e);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(e,"*"),s});i(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});e.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Ie(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(t){return t.messageType===l.In.MutationObserverMessage||t.messageType===l.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(t)}};var L=class{constructor(){i(this,"appendChild",(n,t,e)=>{var s;if(e!=null&&e.relative){if(e.relative.direction==="before")return n.insertBefore(t,e.relative.child);if(e.relative.direction==="after"){let r=(s=e.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(t,r||null)}}else return n.appendChild(t)})}};var Kt=(o,n,t)=>{let e=new URL(o);return e.searchParams.append(n,t),e.toString()},Ce=class extends L{constructor(){super(...arguments);i(this,"type",$.IframeLoader);i(this,"load",async(t,e,s,r)=>{let a,p=e.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=w(),d="myop-comp-".concat(c);a=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(a.style.visibility="hidden"),a=this.appendChild(s,a,r);let u=e.loader.url;r!=null&&r._hasParent&&(u=Kt(u,"_myop-comp",c));let m="";r!=null&&r.elementAttributes&&(m=Object.entries(r==null?void 0:r.elementAttributes).map(([f,g])=>g===""||g===null||g===void 0?f:"".concat(f,'="').concat(String(g),'"')).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(r!=null&&r.hidden?"0":"1",";\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",';\n "\n src="').concat(u,'"\n ').concat(m,"\n ></iframe>"),a=s.querySelector("#".concat(d))}return new U(t,e,s,a,r)})}};var z=class extends D{constructor(t,e,s,r,a){super(t,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",t=>{let e=h({},t),s=super.send(e),r=new CustomEvent(de.webcomponent_message_key,{detail:e});try{this.customElement.dispatchEvent(r)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});i(this,"dispose",()=>{var t;super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=r}inspect(){return this.cleanupInspect=Ie(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 Qe={},xe=class extends L{constructor(){super(...arguments);i(this,"type",$.WebComponentLoader);i(this,"load",async(t,e,s,r)=>{let a=e.loader;Qe[a.url]?console.log("Module alreday loaded or in loading process"):Qe[a.url]=new Promise((d,u)=>{let m=a.url,f=document.createElement("script");f.type="module",f.src=m,f.onload=()=>{d()},f.onerror=()=>{u()},document.head.appendChild(f)}),await Qe[a.url],await st(1);let p="myop-comp-".concat(w()),c=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,r!=null&&r.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),r!=null&&r._environment&&(c._myopEnvironment=r==null?void 0:r._environment),this.appendChild(s,c,r),new z(t,e,s,c,r)})}};var ht="0.1.42";var Mt=[],be,It=async()=>(be||(be=new ne,be.init()),be);function Ft(o,n){return class extends HTMLElement{connectedCallback(){let t=n===pe.open?"open":"closed",e=this.attachShadow({mode:t});It().then(s=>{s.connectedCallback(this,e),e.innerHTML=o})}}}var $t=(o,n,t)=>{customElements.define(o,Ft(n,t)),console.log("define('".concat(o,"') was called, web component ready to use"))},At=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Ut=o=>(o=At(o),o.replace(/_/g,"-"));var we=class extends L{constructor(){super(...arguments);i(this,"type",$.HTMLLoader);i(this,"load",async(t,e,s,r)=>{let a=e.loader,p="myop-comp-".concat(w()),c;if(a.shadowRootMode===pe.localFrame){let d=w(),u="myop-comp-".concat(d),m=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(m.style.visibility="hidden"),m=this.appendChild(s,m,r),m.id=u,m.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ")),s.appendChild(m);let f=m.contentDocument||m.contentWindow.document;f.open();let g=a.HTML;if(r!=null&&r._inspection){let P=new DOMParser().parseFromString(a.HTML,"text/html"),Ze=P.implementation.createHTMLDocument();Ze.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let Ye=Ze.body.firstChild;Ye&&P.head&&P.head.insertBefore(P.importNode(Ye,!0),P.head.firstChild),g=P.documentElement.outerHTML}f.writeln(g),f.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,"\"><\/script>\n <script>\n window.__federation__ = \n { ...window.__federation__,\n //TODO : get from ENV at build time, \n // inject value to module at build time \n // today we doing so just for the CJS version \n __public_path__ :'https://cdn.myop.dev/sdk/next',\n ...").concat(JSON.stringify(window.__federation__),"};\n const init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n init().then();\n <\/script>")),f.close();let R=new U(t,e,s,m,r);return m.onload=()=>{R.observeSizeBasedOnDocumentElement()},R}if(a.shadowRootMode===pe.none){let d=document.createElement("template");d.innerHTML=a.HTML,c=d.content.firstElementChild,It().then(u=>{u.connectedCallback(c,c)})}else{let d=Ut(t.name+e.id);Mt.includes(d)||($t(d,a.HTML,a.shadowRootMode),Mt.push(d)),c=document.createElement(d)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,r!=null&&r.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(s,c,r),new z(t,e,s,c,r)})}};var Se=class Se{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"userFlows",{})}async fetchComponent(n,t){return t?(await this.fetchFlow(t)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();t(r.item)}catch(s){e(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();t(r.item)}catch(s){e(s)}})),await this.userFlows[n]}};i(Se,"Main",new Se);var Te=Se;var Ct=async o=>{try{let n=new URL(window.location.href),e=new URLSearchParams(n.search).get("myopOverride");if(e){let[s,r]=ot(e),p=(await Te.Main.fetchFlow(s)).components.find(c=>c.type.id===o.type.id);if(p&&p.instance.skinSelector.type===A.Segmented&&p.instance.resolvedExperiences){let c=p.instance.resolvedExperiences.find(d=>d.id===r);if((c==null?void 0:c.type)===ce.Segment){let d=c,m=p.instance.skinSelector.segments.find(f=>f.segmentId===d.segment.id);if(m)return p.instance.skinSelector=m==null?void 0:m.skinSelector,p}}}}catch(n){return null}};var xt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",B=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",ht);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==x.up&&n.data.messageType!==l.EnvelopedMessage)return;let t=n.data;if(t.messageType===l.InitRequest){this.components2init.forEach(s=>{s.send(new O(s.id))});return}if(t.messageType===l.InitResponse){this.components2init=this.components2init.filter(r=>r.id!==t.content.id);let s=this.components.find(r=>{var a;return r.id===((a=t.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(t.messageType===l.EnvelopedMessage){let s=t,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===x.down){s.message.messageType===T.name?r.onMessageReceived(s.message):(s.message.route=s.route,r.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let e=this.components.find(s=>s.id===t.destination);if(!e){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(e){if(e.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});i(this,"send",n=>{let t=new MessageEvent("",{data:n});this.incomingMessageHandler(t)});i(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let t=[new Ce,new xe,new we];if(this.componentsLoaders=[...t],n){let e={};n.forEach(s=>{let r=new s(this.componentsLoaders);e[r.type]=r}),this.componentsLoaders.forEach(s=>{e[s.type]||(e[s.type]=s)}),this.componentsLoaders=Object.values(e)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});i(this,"_getSkinIdBySkinSelector",async(n,t=[],e)=>{var r;async function s(a,p){for(let c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case A.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case A.Segmented:{let p=await s(n.segments,async c=>{if(c.segmentId==="Default")return!0;let d=t.find(g=>g.type===ce.Segment?g.segment.id===c.segmentId:!1);if(!d)throw new Error("experience not found");let m=d.segment,f=(e||{})[m.function];return f?await f():(console.warn("segmentId:".concat(c.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,t);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,t)=>{let e=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,t);return n.type.skins.find(s=>s.id===e)});i(this,"loaderHooks");i(this,"loadComponent",async(n,t,e)=>{var d,u,m,f;if(!t){debugger;throw new Error("no container was found for this component")}let s=await Ct(n);s&&(n=s);let r=t;if(r.myop)if(r.component){n=h({},n),n.instance=h({},n.instance);let g=h(h({},(d=this.loaderHooks)!=null?d:{}),(u=e==null?void 0:e.hooks)!=null?u:{}),R=await this.runSkinSelector(n,g);if(!R)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(m=e==null?void 0:e.hooks)!=null&&m.afterSkinSelected&&(R=await e.hooks.afterSkinSelected(h({},R))),n.instance.skinSelector={type:A.Dedicated,skin:R},e&&(e=h({},e),delete e.hooks),await Je(r,n,this.components,e)}else throw new Error("load component got a detached ref.");t=t;let a=await this.runSkinSelector(n,e==null?void 0:e.hooks);if(!a)throw new Error("runSkinSelector failed to choose skin, check the provided config");(f=e==null?void 0:e.hooks)!=null&&f.afterSkinSelected&&(a=await e.hooks.afterSkinSelected(h({},a)));let p=this.componentsLoaders.find(g=>g.type===a.loader.type);if(!p){debugger;throw new Error('no loader "'.concat(a.loader.type,'" was found for component'))}let c=await p.load(n.type,a,t,e);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(g=>g!==c),this.components2init=this.components2init.filter(g=>g!==c),!0)),this.components.push(c),e!=null&&e.connectProps&&(c=yt(c,n.type.props));try{await Xe(c,n,this.components)}catch(g){throw g}return e!=null&&e.skipInit||await c.initiated(),c});i(this,"navigate",async(n,t,e)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(e!=null&&e.staged){let s=await this.loadComponent(t,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},e));return e.init&&await e.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(t,n.container,h({relative:{direction:"before",child:s}},e))}})}};i(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:xt});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:xt}),window.myop.hostSDK=o}var zt=window.myop.hostSDK;ye("hostSDK",zt);var Re=class extends M{constructor(){super(...arguments);i(this,"messageType",l.CreateRefComponentMessage);i(this,"innerExecutor",(t,e,s)=>{(async()=>{let a=e.shadowRoot.querySelectorAll("[".concat(v.id,"='").concat(t.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),c=p.components.find(f=>f.id===t.options.id);c&&c.dispose();let d=p.components.indexOf(c);d!==-1&&p.components.splice(d,1);let u=await p.loadComponent(t.nestedComponentConfig,a.item(0),t.options),m=[];Object.keys(u.refs).forEach(f=>{let g=u.refs[f];g=g.__nonProxied||g,g.componentDefinition&&m.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),s(new K(t.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new K(t.handlerUniqueId,[],!0));debugger}})().then()})}};var bt=(o,n,t)=>{let e=o.scriptInputs?o.scriptInputs:{};e.makeSerializable=k,e.send=n,e.rootRef=t,e.__scriptInputs=e;let r=new Function("return (".concat(o.script,")(...arguments)"))(e);n(r)};var Ee=class extends M{constructor(){super(...arguments);i(this,"messageType",l.ExecuteScriptMessage);i(this,"innerExecutor",(t,e,s)=>{bt(t,a=>{s(new W(t.handlerUniqueId,a))},e)})}};var wt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),t={formData:{},unmappedData:[]},e=o.querySelectorAll("input, select, textarea"),s=-1;return e.forEach(r=>{if(typeof r.value=="string"){let a=r.getAttribute(v.id),p=r.getAttribute("name"),c={id:r.id,name:p,value:wt(r),required:r.required,validity:k(r.validity,!0),myopId:a};p?t.formData[p]?t.formData[p].value?t.unmappedData.push(c):(t.unmappedData.push(t.formData[p]),t.formData[p]=c):t.formData[p]=c:t.unmappedData.push(c)}}),t}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},ve=class extends M{constructor(){super(...arguments);i(this,"messageType",l.GetElementValueMessage);i(this,"innerExecutor",(t,e,s)=>{S(t.ref,e.shadowRoot).forEach(a=>{s(new V(wt(a)),t)})})}};var ke=class extends M{constructor(){super(...arguments);i(this,"messageType",l.SetInnerHtml);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.innerHTML=t.content})})}};var ne=class extends ie{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(t,e)=>{t.addEventListener(de.webcomponent_message_key,s=>{let r=s.data?s.data:s.detail;if(!r||!r.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=r;if(this.handleIncomeMessages(s),a.messageType===l.InitMessage){let p=a.content.id;this.components[p].context=new fe(t,e)}}}),setTimeout(()=>{this.messageToHost(new G)},1)});i(this,"messageToHost",(t,e)=>{t.direction=x.up,!t.replayToHandler&&(e!=null&&e.handlerUniqueId)&&(t.replayToHandler=e.handlerUniqueId),window.myop.hostSDK.send(t)});i(this,"supportedHandlers",[new le(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new me(this.messageToHost,this.components),new ge(this.messageToHost,this.components),new he(this.messageToHost,this.components),new Me(this.messageToHost,this.components),new Ee(this.messageToHost,this.components),new ve(this.messageToHost,this.components),new Re(this.messageToHost,this.components)]);i(this,"init",()=>{})}};ye("WebComponentSDK",ne);export{ne as WebComponentSDK};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var tt=Object.defineProperty,St=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var et=Object.getOwnPropertySymbols;var Et=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var He=(o,n,t)=>n in o?tt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,h=(o,n)=>{for(var t in n||(n={}))Et.call(n,t)&&He(o,t,n[t]);if(et)for(var t of et(n))vt.call(n,t)&&He(o,t,n[t]);return o},E=(o,n)=>St(o,Rt(n));var kt=(o,n)=>{for(var t in n)tt(o,t,{get:n[t],enumerable:!0})};var i=(o,n,t)=>He(o,typeof n!="symbol"?n+"":n,t);var oe="__federation__",nt="onLoad";var se=(o,n)=>{window[oe]&&window[oe][o]&&window[oe][o][nt]&&window[oe][o][nt]({[o]:n})};var l={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 re={};kt(re,{AddEventListenerMessage:()=>_e,BaseMyopMessage:()=>y,BindClickMessage:()=>Be,ChangeTextMessage:()=>Le,CleanupMessage:()=>Z,CleanupReplayMessage:()=>Y,ClickReplayMessage:()=>N,CreateRefComponentMessage:()=>J,CustomRefMessage:()=>_,DetectMyopRefsMessage:()=>Fe,DetectedMyopRefsMessage:()=>Q,DisposeMessage:()=>ee,ElementValueReplayMessage:()=>V,EnvelopedMessage:()=>X,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>T,ExecuteScriptMessage:()=>b,ExecuteScriptReplyMessage:()=>W,GetAttributeMessage:()=>$e,GetAttributeReplayMessage:()=>Ae,GetElementValueMessage:()=>Oe,InitMessage:()=>O,InitRequest:()=>G,InitResponse:()=>j,MessageDirection:()=>x,MutationObserverMessage:()=>ze,MyopBindMessage:()=>C,MyopBindReplayMessage:()=>I,MyopElementMessage:()=>De,Ref:()=>H,RefComponentCreatedMessage:()=>K,ResizeObserverMessage:()=>We,SetAttributeMessage:()=>Pe,SetInnerHtml:()=>Ke,SetMutationObserverMessage:()=>Ue,SetResizeObserverMessage:()=>Ne,stripFunction:()=>at});var w=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Ht=o=>{let n=[...o].map(t=>t.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Dt=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))};var ot=o=>{let n=Dt(o);if(n.length%16!==0)throw new Error("Invalid input length");let t=[];for(let e=0;e<n.length;e+=16)t.push(Ht(n.slice(e,e+16)));return t};var st=o=>new Promise(n=>setTimeout(n,o));var x=class{};i(x,"down","down"),i(x,"up","up");var y=class{constructor(){i(this,"id",w());i(this,"myop",!0);i(this,"content");i(this,"source");i(this,"destination");i(this,"route");i(this,"ref");i(this,"direction");i(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},De=class extends y{constructor(t){super();this.ref=t}},I=class extends y{constructor(t){super();this.replayToHandler=t}},C=class extends y{constructor(t){super();this.handler=t;i(this,"handlerUniqueId",w())}},H=class o{constructor(n,t){this.refConfig=n;this.component=t;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=E(h({},this),{component:null})}static create(n,t,e){let s=t;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,e)}};var rt="ClickReplayMessage",Be=class extends C{constructor(t,e){super(e);this.ref=t;i(this,"replyMessageKey",rt);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},N=class extends I{constructor(){super(...arguments);i(this,"messageType",rt)}};var Le=class extends y{constructor(t,e){super();this.ref=t;i(this,"messageType","ChangeTextMessage");this.content=e}};var it="ExecuteScriptReplyMessage",Bt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Lt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,at=o=>{let n=o.match(Bt);if(n)return n[1]||n[3];{let t=o.match(Lt);if(t)return t[1].trim()}},b=class extends C{constructor(t,e=()=>{},s){super(e);this.scriptInputs=s;i(this,"replyMessageKey",it);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=t.toString(),this.content=t.toString(),this.content=at(this.content)}};i(b,"replierKey","send"),i(b,"completeStreamKey","completeStream");var W=class extends I{constructor(t,e){super(t);this.replayToHandler=t;this.content=e;i(this,"messageType",it)}};var _=class extends b{constructor(t,e,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:c})=>{let d=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(c.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},s);this.scriptInputs=e;this.scriptInputs=E(h({},e),{_script:t.toString()})}};var pt="EventListenerCallbackMessage",_e=class extends C{constructor(t,e,s){super(s);this.ref=t;this.type=e;this.handler=s;i(this,"replyMessageKey",pt);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(t){return this.serializableSkeleton=t,this}},q=class extends I{constructor(t,e){super(t);this.replayToHandler=t;this.e=e;i(this,"messageType",pt);this.content={e}}};var Pe=class extends y{constructor(t,e,s){super();this.ref=t;this.name=e;this.value=s;i(this,"messageType","SetAttributeMessage")}};var ct="ElementValueReplayMessage",Oe=class extends C{constructor(t,e){super(e);this.ref=t;i(this,"replyMessageKey",ct);i(this,"messageType","GetElementValueMessage")}},V=class extends I{constructor(t){super();this.content=t;i(this,"messageType",ct)}};var Ke=class extends y{constructor(t,e){super();this.ref=t;i(this,"messageType","SetInnerHtml");this.content=e}};var O=class extends y{constructor(t){super();i(this,"messageType","InitMessage");this.content={id:t}}isTypeof(t){return t.messageType===this.messageType}},j=class extends O{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},G=class extends y{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var dt="RefComponentCreatedMessage",J=class extends C{constructor(t,e,s,r){super(r);this.refConfig=t;this.nestedComponentConfig=e;this.options=s;i(this,"replyMessageKey",dt);i(this,"messageType","CreateRefComponentMessage")}},K=class extends I{constructor(t,e,s){super(t);this.replayToHandler=t;this.nestedRefs=e;this.failed=s;i(this,"messageType",dt)}};var X=class extends y{constructor(t,e){super();this.destination=t;this.message=e;i(this,"messageType","EnvelopedMessage");let s=e;this.route=[t,...s.route?s.route:[]]}};var mt="DetectedMyopRefsMessage",Fe=class extends C{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",mt)}},Q=class extends I{constructor(t,e){super(t);this.replayToHandler=t;i(this,"messageType",mt);this.content=e}isTypeof(t){return t.messageType===this.messageType}};var lt="GetAttributeReplayMessage",$e=class extends C{constructor(t,e,s){super(s);this.ref=t;this.name=e;i(this,"replyMessageKey",lt);i(this,"messageType","GetAttributeMessage")}},Ae=class extends I{constructor(t){super();this.content=t;i(this,"messageType",lt)}};var T=class extends y{constructor(t){super();this.method=t;i(this,"messageType","ExecuteComponentMethod")}};var Ue=class extends y{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},ze=class extends y{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ft="CleanupReplayMessage",Z=class extends C{constructor(t,e){super(e);this.cleanupForMessageId=t;i(this,"replyMessageKey",ft);i(this,"messageType","CleanupMessage")}},Y=class extends I{constructor(t){super();this.customCleanup=t;i(this,"messageType",ft)}};var ee=class extends y{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var Ne=class extends y{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},We=class extends y{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var D=class{constructor(n,t,e){this.componentDefinition=n;this.container=t;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,t)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(t)||this.messageHandlers[n].push(t)});i(this,"bindWhen",(n,t,e)=>{if(!e)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>t(a)?(e(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,t)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=t}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(e==null?void 0:e.id)||B.Instance().assignId(n);let s=e!=null&&e.timeout?e==null?void 0:e.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===l.ExecuteComponentMethod){let e=n;return this[e.method]?this[e.method](e.content):console.log("method not found ".concat(e.method," on component"),this),!0}let t=this.messageHandlers[n.messageType];if(t&&t.length){let e=!1;return t.forEach(s=>{e=e||s(n)}),e}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=x.down;let t=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),t()}),e=n.handler;delete n.handler,this.send(n),n.handler=e}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=x.down;let t;if(n.handler){let e=n;t=this.bindWhen(e.replyMessageKey,s=>s.replayToHandler===e.handlerUniqueId,e.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Z(n.id,e=>{})),t&&t()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ee);let n=this.messageHandlers.onDispose;n&&n.forEach(t=>{t(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var ie=class{constructor(n,t,e,s,r){this.myopId=n;this.htmlTagName=t;this.BoundingRect=e;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var gt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},qe=class{constructor(n){this.messageToHost=n}},ae=class extends qe{constructor(t,e){super(t);this.messageToHost=t;this.context=e}};var Ve=class{constructor(n,t){this.id=n;this.context=t;i(this,"send",n=>{})}},pe=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let t=n.data?n.data:n.detail;if(!(!t||!t.myop)){let e=t;if(e.direction!==x.down)return;if(e.messageType===l.DisposeMessage){e.destination&&delete this.components[e.destination];return}if(e.messageType===l.InitMessage){let s=e.content.id;if(this.components[s])return;this.components[s]=new Ve(s),this.messageToHost(new j(s));return}if(e.messageType===l.EnvelopedMessage){let s=e,r=s.message;if(e=r,this.alwaysPassEnvelopesToHost||this.components[e.destination]){let a=myop.hostSDK.components.find(c=>c.id===r.destination);if(a){a.send(r);return}let p=myop.hostSDK.components.find(c=>c.id===s.destination);if(p){p.send(r);return}}else return}if(e.messageType){if(e.messageType===l.CleanupMessage){let r=e,a=this.messageCleanupCache[r.cleanupForMessageId],p=new Y(!!a);p.destination=e.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],gt(a).then(()=>{this.messageToHost(p,r)}).catch(()=>{})):this.messageToHost(p,r);return}let s=!1;this.supportedHandlers.forEach(r=>{if(r.messageType===e.messageType){s=!0;let a=r.executor(e);if(e.cleanable&&a&&(this.messageCleanupCache[e.id]=a),a&&!e.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&e.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var $={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"};var de={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var F=class{};i(F,"code","code"),i(F,"component","component");var A={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},me={Segment:"Segment",Promo:"Promo",AB:"AB"},ce=class{constructor(n,t){this.container=n;this.shadowRoot=t;i(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));i(this,"getRoot",()=>this.shadowRoot||this.container)}};var je=o=>o!==Object(o),_t=o=>typeof o=="function",Ge=o=>{if(je(o))return!0;if(_t(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let t=o[n];if(typeof t=="object"){if(!Ge(t))return!1}else{if(je(t))continue;return!1}}return!0},v=(o,n={},t=!0,e=new WeakMap)=>{if(je(o))return o;if(Array.isArray(o)){if(e.has(o))return e.get(o);let s=[];e.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=v(a,n,t,e)}return s}if(o!==null&&typeof o=="object"){if(e.has(o))return e.get(o);let s={};e.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(t?o[r]!==void 0:o[r])&&(s[r]=v(o[r],!0,t,e)):typeof a=="object"&&(s[r]=v(o[r],a,t,e)))}return s}return{}};var ut={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var te=class extends D{constructor(t,e,s){super(t,e.container,s);this.componentDefinition=t;this.parent=e;i(this,"send",t=>{let e=t.handler,s=super.send(t);return this.parent.send(new X(this.id,t)),t.handler=e,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new T("dispose")),super.dispose()})}hide(){this.send(new T("hide"))}show(){this.send(new T("show"))}inspect(){return this.send(new T("inspect"))}setHeightBasedOnDocumentElement(){this.send(new T("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new T("setHeightBasedOnScrollHeight"))}onMessageReceived(t){return super.onMessageReceived(t)}};var Pt=(o,n,t)=>{let e=document.createElement("a");return e.textContent=o,e.style.position="relative",e.style.padding="0 5px",e.style.fontSize="14px",e.style.top="0",e.style.top="".concat(n,"px"),e.style.transform="translateX(-50%)",e.target="_blank",e.href="https://dashboard.myop.dev/dashboard/component/".concat(t.id),e},le=(o,n,t,e,s,r)=>{let a=Pt("".concat(r.name," : ").concat(n),t,r);return e.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",e.removeChild(a)}},yt=(o,n)=>{let t=n.reduce((s,r)=>E(h({},s),{[r.name]:h({},r)}),{}),e={get:(s,r)=>{let a=t[r];return a.mode==="output"?new Promise(p=>{let c=[];a.behavior.ref&&c.push(H.create(a.behavior.ref)),c.push(u=>{p(u)}),a.behavior.params&&c.push(...a.behavior.params);let d=re[a.behavior.message];o.send(new d(...c))}):null},set:(s,r,a)=>{let p=t[r];if(!p)throw new 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(r,"\n")+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(o.componentDefinition.id," or consult the developer guide."));if(p.mode==="input")if(p.behavior.type==="message"){let c=[];p.behavior.ref&&c.push(H.create(p.behavior.ref)),c.push(a),p.behavior.params&&c.push(...p.behavior.params);let d=re[p.behavior.message];return o.send(new d(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(r,"\n")+"Behavior Field: ".concat(p.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,e),o},Ot=(o,n)=>new Proxy(o,{get(t,e){return t[e]?t[e]:(...r)=>new Promise(a=>{r.forEach(p=>{Ge(p)||ut.notSerializableRefCall(e,p)}),n.send(new _(({ref:p,propName:c,functionArgs:d,makeSerializable:u})=>{if(p){let m=p[c];return u(typeof m=="function"?p[c](...d):m,!0)}return null},{elementId:t.refConfig.selector,propName:e,functionArgs:r},p=>{a(p.content)}))})},set(t,e,s){return n.send(new _(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:t.refConfig.selector,propValue:s,propName:e},r=>{})),!0}}),Je=async(o,n,t,e)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(r,a)=>{let p=new te(n.type,s,e);t.push(p),await s.initiated();let c=setTimeout(()=>{a("timeout")},5e3);s.send(new J(o.refConfig,n,E(h({},e||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(c),d.failed){a("CreateRefComponentMessage failed");return}let u=t.find(m=>m.id==p.id);if(u!==p){s.refs[o.refConfig.name]=u,r(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;d.nestedRefs.forEach(m=>{let f=n.instance.resolvedNestedComponents.find(R=>R.type.id===m.componentDefinitionId).type,g=new te(f,p);g.setInitiated(),p.refs[m.refName]=g,t.push(g)});try{await Xe(p,n,t,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(m){a(m)}}))})},Xe=async(o,n,t,e=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(r=>new Promise(async(a,p)=>{var c;if(r.behavior.type==F.component){if(e){a();return}let d=r.behavior.componentId;d||(d=r.behavior.instance.componentId);let u=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(f=>f.type.id===d);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=H.create("",r,o);try{let f=await Je(m,u,t);o.refs[r.name]=f,a()}catch(f){p(f)}}else try{let d=H.create("",r,o);o.refs[r.name]=Ot(d,o),a()}catch(d){}}));try{await Promise.all(s)}catch(r){throw r}};var U=class extends D{constructor(t,e,s,r,a){super(t,s,a);this.componentConfig=t;this.container=s;this.IframeElement=r;i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let t=this.send(new b(()=>window.document.documentElement.scrollHeight,e=>{this.IframeElement.style.height="".concat(e.content,"px"),t()}))});i(this,"observeSizeBasedOnDocumentElement",()=>{let t=this.send(new b(({send:e})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();e({height:p,width:c})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px")}))});i(this,"setSizeBasedOnDocumentElement",()=>{let t=this.send(new b(()=>{let{height:e,width:s}=document.documentElement.getBoundingClientRect();return{height:e,width:s}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px"),t()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let t=this.send(new b(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},e=>{this.IframeElement.style.height=e.content,t()}))});i(this,"send",t=>{var r,a;let e=h({},t);if(e.messageType===l.ExecuteComponentMethod)return this[e.method](),()=>{};e.direction=x.down;let s=super.send(e);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(e,"*"),s});i(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});e.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=le(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(t){return t.messageType===l.In.MutationObserverMessage||t.messageType===l.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(t)}};var L=class{constructor(){i(this,"appendChild",(n,t,e)=>{var s;if(e!=null&&e.relative){if(e.relative.direction==="before")return n.insertBefore(t,e.relative.child);if(e.relative.direction==="after"){let r=(s=e.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(t,r||null)}}else return n.appendChild(t)})}};var Kt=(o,n,t)=>{let e=new URL(o);return e.searchParams.append(n,t),e.toString()},fe=class extends L{constructor(){super(...arguments);i(this,"type",$.IframeLoader);i(this,"load",async(t,e,s,r)=>{let a,p=e.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=w(),d="myop-comp-".concat(c);a=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(a.style.visibility="hidden"),a=this.appendChild(s,a,r);let u=e.loader.url;r!=null&&r._hasParent&&(u=Kt(u,"_myop-comp",c));let m="";r!=null&&r.elementAttributes&&(m=Object.entries(r==null?void 0:r.elementAttributes).map(([f,g])=>g===""||g===null||g===void 0?f:"".concat(f,'="').concat(String(g),'"')).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(r!=null&&r.hidden?"0":"1",";\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",';\n "\n src="').concat(u,'"\n ').concat(m,"\n ></iframe>"),a=s.querySelector("#".concat(d))}return new U(t,e,s,a,r)})}};var ge={webcomponent_message_key:"myop_webcomponent_message"};var z=class extends D{constructor(t,e,s,r,a){super(t,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",t=>{let e=h({},t),s=super.send(e),r=new CustomEvent(ge.webcomponent_message_key,{detail:e});try{this.customElement.dispatchEvent(r)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});i(this,"dispose",()=>{var t;super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=r}inspect(){return this.cleanupInspect=le(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 Qe={},ue=class extends L{constructor(){super(...arguments);i(this,"type",$.WebComponentLoader);i(this,"load",async(t,e,s,r)=>{let a=e.loader;Qe[a.url]?console.log("Module alreday loaded or in loading process"):Qe[a.url]=new Promise((d,u)=>{let m=a.url,f=document.createElement("script");f.type="module",f.src=m,f.onload=()=>{d()},f.onerror=()=>{u()},document.head.appendChild(f)}),await Qe[a.url],await st(1);let p="myop-comp-".concat(w()),c=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,r!=null&&r.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),r!=null&&r._environment&&(c._myopEnvironment=r==null?void 0:r._environment),this.appendChild(s,c,r),new z(t,e,s,c,r)})}};var ht="0.1.42";var M=class extends ae{constructor(t,e){super(t);this.context=e;i(this,"executor",t=>{if(t.destination){let e=t.destination;if(this.context[e].context){let s=(r,a)=>{this.messageToHost(E(h({},r),{source:t.destination?t.destination:t.source,destination:t.source?t.source:t.destination}),a)};return this.innerExecutor(t,this.context[e].context,s)}else debugger}else debugger})}};var k={id:"myop-id"};var S=(o,n)=>n.querySelectorAll("[".concat(k.id,"='").concat(o.refConfig.selector,"']"));var ye=class extends M{constructor(){super(...arguments);i(this,"messageType",l.BindClickMessage);i(this,"innerExecutor",(t,e,s)=>{let r=S(t.ref,e.shadowRoot),a=[];return r.forEach(p=>{let c=()=>{s(new N(t.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var he=class extends M{constructor(){super(...arguments);i(this,"messageType",l.ChangeTextMessage);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.textContent=t.content})})}};var Me=class extends ce{constructor(t,e){super(t,e);this.container=t;this.shadowRoot=e}};var Ie=class extends M{constructor(){super(...arguments);i(this,"innerExecutor",(t,e)=>{let s=e.shadowRoot.querySelectorAll("[".concat(k.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(k.id);p&&r.push(new ie(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Q(t.handlerUniqueId,r))});i(this,"messageType",l.DetectMyopRefsMessage)}};var Ce=class extends M{constructor(){super(...arguments);i(this,"messageType",l.SetAttributeMessage);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.setAttribute(t.name,t.value)})})}};var xe=class extends M{constructor(){super(...arguments);i(this,"messageType",l.AddEventListenerMessage);i(this,"innerExecutor",(t,e,s)=>{let r=S(t.ref,e.shadowRoot),a=[];return r.forEach(p=>{let c=d=>{s(new q(t.handlerUniqueId,v(d,t.serializableSkeleton)))};p.addEventListener(t.type,c),a.push(()=>{p.removeEventListener(t.type,c)})}),()=>{a.forEach(p=>p())}})}};var be=class extends M{constructor(){super(...arguments);i(this,"messageType",l.CreateRefComponentMessage);i(this,"innerExecutor",(t,e,s)=>{(async()=>{let a=e.shadowRoot.querySelectorAll("[".concat(k.id,"='").concat(t.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),c=p.components.find(f=>f.id===t.options.id);c&&c.dispose();let d=p.components.indexOf(c);d!==-1&&p.components.splice(d,1);let u=await p.loadComponent(t.nestedComponentConfig,a.item(0),t.options),m=[];Object.keys(u.refs).forEach(f=>{let g=u.refs[f];g=g.__nonProxied||g,g.componentDefinition&&m.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),s(new K(t.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new K(t.handlerUniqueId,[],!0));debugger}})().then()})}};var Mt=(o,n,t)=>{let e=o.scriptInputs?o.scriptInputs:{};e.makeSerializable=v,e.send=n,e.rootRef=t,e.__scriptInputs=e;let r=new Function("return (".concat(o.script,")(...arguments)"))(e);n(r)};var we=class extends M{constructor(){super(...arguments);i(this,"messageType",l.ExecuteScriptMessage);i(this,"innerExecutor",(t,e,s)=>{Mt(t,a=>{s(new W(t.handlerUniqueId,a))},e)})}};var It=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),t={formData:{},unmappedData:[]},e=o.querySelectorAll("input, select, textarea"),s=-1;return e.forEach(r=>{if(typeof r.value=="string"){let a=r.getAttribute(k.id),p=r.getAttribute("name"),c={id:r.id,name:p,value:It(r),required:r.required,validity:v(r.validity,!0),myopId:a};p?t.formData[p]?t.formData[p].value?t.unmappedData.push(c):(t.unmappedData.push(t.formData[p]),t.formData[p]=c):t.formData[p]=c:t.unmappedData.push(c)}}),t}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Te=class extends M{constructor(){super(...arguments);i(this,"messageType",l.GetElementValueMessage);i(this,"innerExecutor",(t,e,s)=>{S(t.ref,e.shadowRoot).forEach(a=>{s(new V(It(a)),t)})})}};var Se=class extends M{constructor(){super(...arguments);i(this,"messageType",l.SetInnerHtml);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.innerHTML=t.content})})}};var ne=class extends pe{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(t,e)=>{t.addEventListener(ge.webcomponent_message_key,s=>{let r=s.data?s.data:s.detail;if(!r||!r.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=r;if(this.handleIncomeMessages(s),a.messageType===l.InitMessage){let p=a.content.id;this.components[p].context=new Me(t,e)}}}),setTimeout(()=>{this.messageToHost(new G)},1)});i(this,"messageToHost",(t,e)=>{t.direction=x.up,!t.replayToHandler&&(e!=null&&e.handlerUniqueId)&&(t.replayToHandler=e.handlerUniqueId),window.myop.hostSDK.send(t)});i(this,"supportedHandlers",[new he(this.messageToHost,this.components),new Se(this.messageToHost,this.components),new ye(this.messageToHost,this.components),new Ie(this.messageToHost,this.components),new Ce(this.messageToHost,this.components),new xe(this.messageToHost,this.components),new we(this.messageToHost,this.components),new Te(this.messageToHost,this.components),new be(this.messageToHost,this.components)]);i(this,"init",()=>{})}};se("WebComponentSDK",ne);var Ct=[],Re,xt=async()=>(Re||(Re=new ne,Re.init()),Re);function Ft(o,n){return class extends HTMLElement{connectedCallback(){let t=n===de.open?"open":"closed",e=this.attachShadow({mode:t});xt().then(s=>{s.connectedCallback(this,e),e.innerHTML=o})}}}var $t=(o,n,t)=>{customElements.define(o,Ft(n,t)),console.log("define('".concat(o,"') was called, web component ready to use"))},At=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Ut=o=>(o=At(o),o.replace(/_/g,"-"));var Ee=class extends L{constructor(){super(...arguments);i(this,"type",$.HTMLLoader);i(this,"load",async(t,e,s,r)=>{let a=e.loader,p="myop-comp-".concat(w()),c;if(a.shadowRootMode===de.localFrame){let d=w(),u="myop-comp-".concat(d),m=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(m.style.visibility="hidden"),m=this.appendChild(s,m,r),m.id=u,m.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ")),s.appendChild(m);let f=m.contentDocument||m.contentWindow.document;f.open();let g=a.HTML;if(r!=null&&r._inspection){let P=new DOMParser().parseFromString(a.HTML,"text/html"),Ze=P.implementation.createHTMLDocument();Ze.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let Ye=Ze.body.firstChild;Ye&&P.head&&P.head.insertBefore(P.importNode(Ye,!0),P.head.firstChild),g=P.documentElement.outerHTML}f.writeln(g),f.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,"\"><\/script>\n <script>\n window.__federation__ = \n { ...window.__federation__,\n //TODO : get from ENV at build time, \n // inject value to module at build time \n // today we doing so just for the CJS version \n __public_path__ :'https://cdn.myop.dev/sdk/next',\n ...").concat(JSON.stringify(window.__federation__),"};\n const init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n init().then();\n <\/script>")),f.close();let R=new U(t,e,s,m,r);return m.onload=()=>{R.observeSizeBasedOnDocumentElement()},R}if(a.shadowRootMode===de.none){let d=document.createElement("template");d.innerHTML=a.HTML,c=d.content.firstElementChild,xt().then(u=>{u.connectedCallback(c,c)})}else{let d=Ut(t.name+e.id);Ct.includes(d)||($t(d,a.HTML,a.shadowRootMode),Ct.push(d)),c=document.createElement(d)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,r!=null&&r.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(s,c,r),new z(t,e,s,c,r)})}};var ke=class ke{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"userFlows",{})}async fetchComponent(n,t){return t?(await this.fetchFlow(t)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();t(r.item)}catch(s){e(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();t(r.item)}catch(s){e(s)}})),await this.userFlows[n]}};i(ke,"Main",new ke);var ve=ke;var bt=async o=>{try{let n=new URL(window.location.href),e=new URLSearchParams(n.search).get("myopOverride");if(e){let[s,r]=ot(e),p=(await ve.Main.fetchFlow(s)).components.find(c=>c.type.id===o.type.id);if(p&&p.instance.skinSelector.type===A.Segmented&&p.instance.resolvedExperiences){let c=p.instance.resolvedExperiences.find(d=>d.id===r);if((c==null?void 0:c.type)===me.Segment){let d=c,m=p.instance.skinSelector.segments.find(f=>f.segmentId===d.segment.id);if(m)return p.instance.skinSelector=m==null?void 0:m.skinSelector,p}}}}catch(n){return null}};var wt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",B=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",ht);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==x.up&&n.data.messageType!==l.EnvelopedMessage)return;let t=n.data;if(t.messageType===l.InitRequest){this.components2init.forEach(s=>{s.send(new O(s.id))});return}if(t.messageType===l.InitResponse){this.components2init=this.components2init.filter(r=>r.id!==t.content.id);let s=this.components.find(r=>{var a;return r.id===((a=t.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(t.messageType===l.EnvelopedMessage){let s=t,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===x.down){s.message.messageType===T.name?r.onMessageReceived(s.message):(s.message.route=s.route,r.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let e=this.components.find(s=>s.id===t.destination);if(!e){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(e){if(e.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});i(this,"send",n=>{let t=new MessageEvent("",{data:n});this.incomingMessageHandler(t)});i(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let t=[new fe,new ue,new Ee];if(this.componentsLoaders=[...t],n){let e={};n.forEach(s=>{let r=new s(this.componentsLoaders);e[r.type]=r}),this.componentsLoaders.forEach(s=>{e[s.type]||(e[s.type]=s)}),this.componentsLoaders=Object.values(e)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});i(this,"_getSkinIdBySkinSelector",async(n,t=[],e)=>{var r;async function s(a,p){for(let c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case A.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case A.Segmented:{let p=await s(n.segments,async c=>{if(c.segmentId==="Default")return!0;let d=t.find(g=>g.type===me.Segment?g.segment.id===c.segmentId:!1);if(!d)throw new Error("experience not found");let m=d.segment,f=(e||{})[m.function];return f?await f():(console.warn("segmentId:".concat(c.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,t);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,t)=>{let e=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,t);return n.type.skins.find(s=>s.id===e)});i(this,"loaderHooks");i(this,"loadComponent",async(n,t,e)=>{var d,u,m,f;if(!t){debugger;throw new Error("no container was found for this component")}let s=await bt(n);s&&(n=s);let r=t;if(r.myop)if(r.component){n=h({},n),n.instance=h({},n.instance);let g=h(h({},(d=this.loaderHooks)!=null?d:{}),(u=e==null?void 0:e.hooks)!=null?u:{}),R=await this.runSkinSelector(n,g);if(!R)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(m=e==null?void 0:e.hooks)!=null&&m.afterSkinSelected&&(R=await e.hooks.afterSkinSelected(h({},R))),n.instance.skinSelector={type:A.Dedicated,skin:R},e&&(e=h({},e),delete e.hooks),await Je(r,n,this.components,e)}else throw new Error("load component got a detached ref.");t=t;let a=await this.runSkinSelector(n,e==null?void 0:e.hooks);if(!a)throw new Error("runSkinSelector failed to choose skin, check the provided config");(f=e==null?void 0:e.hooks)!=null&&f.afterSkinSelected&&(a=await e.hooks.afterSkinSelected(h({},a)));let p=this.componentsLoaders.find(g=>g.type===a.loader.type);if(!p){debugger;throw new Error('no loader "'.concat(a.loader.type,'" was found for component'))}let c=await p.load(n.type,a,t,e);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(g=>g!==c),this.components2init=this.components2init.filter(g=>g!==c),!0)),this.components.push(c),e!=null&&e.connectProps&&(c=yt(c,n.type.props));try{await Xe(c,n,this.components)}catch(g){throw g}return e!=null&&e.skipInit||await c.initiated(),c});i(this,"navigate",async(n,t,e)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(e!=null&&e.staged){let s=await this.loadComponent(t,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},e));return e.init&&await e.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(t,n.container,h({relative:{direction:"before",child:s}},e))}})}};i(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:wt});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:wt}),window.myop.hostSDK=o}var zt=window.myop.hostSDK;se("hostSDK",zt);export{B as HostSDK,zt as hostSDK};
|