@myop/sdk 0.1.43 → 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.d40f5d05.js → _IframeSDK.dd7fa267.js} +118 -46
- 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.82d073da.js → _WebComponentSDK.d843788d.js} +118 -46
- package/dist/cjs/_WebComponentSDK.d843788d.js.map +7 -0
- package/dist/cjs/_hostSDK.39162c05.min.js +1 -0
- package/dist/cjs/{_hostSDK.cc791efe.js → _hostSDK.a057f932.js} +118 -46
- 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 +138 -56
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +140 -58
- 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 +138 -56
- package/dist/module/host/index.js.map +3 -3
- package/dist/module/webcomponent/index.js +138 -56
- package/dist/module/webcomponent/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.125baf65.min.js +0 -1
- package/dist/cjs/_IframeSDK.d40f5d05.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.82d073da.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.e5da466e.min.js +0 -1
- package/dist/cjs/_hostSDK.78b64302.min.js +0 -1
- package/dist/cjs/_hostSDK.cc791efe.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ot=Object.defineProperty,vt=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var nt=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var He=(o,n,e)=>n in o?ot(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Ht.call(n,e)&&He(o,e,n[e]);if(nt)for(var e of nt(n))Dt.call(n,e)&&He(o,e,n[e]);return o},E=(o,n)=>vt(o,kt(n));var Bt=(o,n)=>{for(var e in n)ot(o,e,{get:n[e],enumerable:!0})};var i=(o,n,e)=>He(o,typeof n!="symbol"?n+"":n,e);var re="__federation__",st="onLoad";var ie=(o,n)=>{window[re]&&window[re][o]&&window[re][o][st]&&window[re][o][st]({[o]:n})};var f={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var ae={};Bt(ae,{AddEventListenerMessage:()=>Pe,BaseMyopMessage:()=>y,BindClickMessage:()=>Le,ChangeTextMessage:()=>_e,CleanupMessage:()=>Y,CleanupReplayMessage:()=>ee,ClickReplayMessage:()=>W,CreateRefComponentMessage:()=>X,CustomRefMessage:()=>P,DetectMyopRefsMessage:()=>$e,DetectedMyopRefsMessage:()=>Z,DisposeMessage:()=>te,ElementValueReplayMessage:()=>j,EnvelopedMessage:()=>Q,EventListenerCallbackMessage:()=>V,ExecuteComponentMethod:()=>S,ExecuteScriptMessage:()=>T,ExecuteScriptReplyMessage:()=>q,GetAttributeMessage:()=>Ae,GetAttributeReplayMessage:()=>Ue,GetElementValueMessage:()=>Ke,InitMessage:()=>$,InitRequest:()=>J,InitResponse:()=>G,MessageDirection:()=>b,MutationObserverMessage:()=>Ne,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>C,MyopElementMessage:()=>Be,Ref:()=>D,RefComponentCreatedMessage:()=>A,ResizeObserverMessage:()=>qe,SetAttributeMessage:()=>Oe,SetInnerHtml:()=>Fe,SetMutationObserverMessage:()=>ze,SetResizeObserverMessage:()=>We,stripFunction:()=>pt});var w=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Lt=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var _t=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var De=o=>{let n=_t(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(Lt(n.slice(t,t+16)));return e};var rt=o=>new Promise(n=>setTimeout(n,o));var b=class{};i(b,"down","down"),i(b,"up","up");var y=class{constructor(){i(this,"id",w());i(this,"myop",!0);i(this,"content");i(this,"source");i(this,"destination");i(this,"route");i(this,"ref");i(this,"direction");i(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},Be=class extends y{constructor(e){super();this.ref=e}},C=class extends y{constructor(e){super();this.replayToHandler=e}},x=class extends y{constructor(e){super();this.handler=e;i(this,"handlerUniqueId",w())}},D=class o{constructor(n,e){this.refConfig=n;this.component=e;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=E(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var it="ClickReplayMessage",Le=class extends x{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",it);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},W=class extends C{constructor(){super(...arguments);i(this,"messageType",it)}};var _e=class extends y{constructor(e,t){super();this.ref=e;i(this,"messageType","ChangeTextMessage");this.content=t}};var at="ExecuteScriptReplyMessage",Pt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Ot=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,pt=o=>{let n=o.match(Pt);if(n)return n[1]||n[3];{let e=o.match(Ot);if(e)return e[1].trim()}},T=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;i(this,"replyMessageKey",at);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=pt(this.content)}};i(T,"replierKey","send"),i(T,"completeStreamKey","completeStream");var q=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;i(this,"messageType",at)}};var P=class extends T{constructor(e,t,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:d})=>{let c=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=E(h({},t),{_script:e.toString()})}};var dt="EventListenerCallbackMessage",Pe=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;i(this,"replyMessageKey",dt);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},V=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;i(this,"messageType",dt);this.content={e:t}}};var Oe=class extends y{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;i(this,"messageType","SetAttributeMessage")}};var ct="ElementValueReplayMessage",Ke=class extends x{constructor(e,t){super(t);this.ref=e;i(this,"replyMessageKey",ct);i(this,"messageType","GetElementValueMessage")}},j=class extends C{constructor(e){super();this.content=e;i(this,"messageType",ct)}};var Fe=class extends y{constructor(e,t){super();this.ref=e;i(this,"messageType","SetInnerHtml");this.content=t}};var $=class extends y{constructor(e){super();i(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},G=class extends ${constructor(){super(...arguments);i(this,"messageType","InitResponse")}},J=class extends y{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var mt="RefComponentCreatedMessage",X=class extends x{constructor(e,t,s,r){super(r);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;i(this,"replyMessageKey",mt);i(this,"messageType","CreateRefComponentMessage")}},A=class extends C{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;i(this,"messageType",mt)}};var Q=class extends y{constructor(e,t){super();this.destination=e;this.message=t;i(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var lt="DetectedMyopRefsMessage",$e=class extends x{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",lt)}},Z=class extends C{constructor(e,t){super(e);this.replayToHandler=e;i(this,"messageType",lt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var ft="GetAttributeReplayMessage",Ae=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;i(this,"replyMessageKey",ft);i(this,"messageType","GetAttributeMessage")}},Ue=class extends C{constructor(e){super();this.content=e;i(this,"messageType",ft)}};var S=class extends y{constructor(e){super();this.method=e;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 gt="CleanupReplayMessage",Y=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;i(this,"replyMessageKey",gt);i(this,"messageType","CleanupMessage")}},ee=class extends C{constructor(e){super();this.customCleanup=e;i(this,"messageType",gt)}};var te=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 B=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});i(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>e(a)?(t(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(t==null?void 0:t.id)||L.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===f.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=b.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Y(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new te);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var pe=class{constructor(n,e,t,s,r){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var ut=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},Ve=class{constructor(n){this.messageToHost=n}},de=class extends Ve{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var je=class{constructor(n,e){this.id=n;this.context=e;i(this,"send",n=>{})}},ce=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===f.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===f.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new je(s),this.messageToHost(new G(s));return}if(t.messageType===f.EnvelopedMessage){let s=t,r=s.message;if(t=r,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===r.destination);if(a){a.send(r);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(r);return}}else return}if(t.messageType){if(t.messageType===f.CleanupMessage){let r=t,a=this.messageCleanupCache[r.cleanupForMessageId],p=new ee(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],ut(a).then(()=>{this.messageToHost(p,r)}).catch(()=>{})):this.messageToHost(p,r);return}let s=!1;this.supportedHandlers.forEach(r=>{if(r.messageType===t.messageType){s=!0;let a=r.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(r.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var v={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"};var O={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var Ge={message:"message",code:"code"},U=class{};i(U,"code","code"),i(U,"component","component");var K={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},le={Segment:"Segment",Promo:"Promo",AB:"AB"},me=class{constructor(n,e){this.container=n;this.shadowRoot=e;i(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));i(this,"getRoot",()=>this.shadowRoot||this.container)}};var Je=o=>o!==Object(o),Kt=o=>typeof o=="function",Xe=o=>{if(Je(o))return!0;if(Kt(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!Xe(e))return!1}else{if(Je(e))continue;return!1}}return!0},k=(o,n={},e=!0,t=new WeakMap)=>{if(Je(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=k(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(e?o[r]!==void 0:o[r])&&(s[r]=k(o[r],!0,e,t)):typeof a=="object"&&(s[r]=k(o[r],a,e,t)))}return s}return{}};var yt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var ne=class extends B{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;i(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new Q(this.id,e)),e.handler=t,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new S("dispose")),super.dispose()})}hide(){this.send(new S("hide"))}show(){this.send(new S("show"))}inspect(){return this.send(new S("inspect"))}setHeightBasedOnDocumentElement(){this.send(new S("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new S("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var Ft=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},fe=(o,n,e,t,s,r)=>{let a=Ft("".concat(r.name," : ").concat(n),e,r);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},ht=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Mt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},It=(o,n,e)=>{let t=n.reduce((r,a)=>E(h({},r),{[a.name]:h({},a)}),{}),s={get:(r,a)=>{let p=t[a];if(ht(p,a,o))return!1;if(p.behavior.type===Ge.code){if(e.loader.type===v.HTMLLoader&&e.loader.shadowRootMode===O.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return Mt(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(D.create(p.behavior.ref)),c.push(l=>{d(l)}),p.behavior.params&&c.push(...p.behavior.params);let m=ae[p.behavior.message];o.send(new m(...c))}):null},set:(r,a,p)=>{let d=t[a];if(ht(d,a,o))return!1;if(d.behavior.type===Ge.code){if(e.loader.type===v.HTMLLoader&&e.loader.shadowRootMode===O.localFrame){let m=d.behavior;return o.element.contentWindow[m.remap||a]=p,!0}return Mt(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(D.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let m=ae[d.behavior.message];return o.send(new m(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},$t=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...r)=>new Promise(a=>{r.forEach(p=>{Xe(p)||yt.notSerializableRefCall(t,p)}),n.send(new P(({ref:p,propName:d,functionArgs:c,makeSerializable:m})=>{if(p){let l=p[d];return m(typeof l=="function"?p[d](...c):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:r},p=>{a(p.content)}))})},set(e,t,s){return n.send(new P(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},r=>{})),!0}}),Qe=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(r,a)=>{let p=new ne(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new X(o.refConfig,n,E(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let m=e.find(l=>l.id==p.id);if(m!==p){s.refs[o.refConfig.name]=m,r(m);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(I=>I.type.id===l.componentDefinitionId).type,u=new ne(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await Ze(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(l){a(l)}}))})},Ze=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(r=>new Promise(async(a,p)=>{var d;if(r.behavior.type==U.component){if(t){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=D.create("",r,o);try{let g=await Qe(l,m,e);o.refs[r.name]=g,a()}catch(g){p(g)}}else try{let c=D.create("",r,o);o.refs[r.name]=$t(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}};var z=class extends B{constructor(e,t,s,r,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=r;i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new T(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});i(this,"observeSizeBasedOnDocumentElement",()=>this.send(new T(({send:t})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));i(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new T(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new T(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});i(this,"send",e=>{var r,a;let t=h({},e);if(t.messageType===f.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let s=super.send(t);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(t,"*"),s});i(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=fe(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===f.In.MutationObserverMessage||e.messageType===f.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var _=class{constructor(){i(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let r=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,r||null)}}else return n.appendChild(e)})}};var At=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},ge=class extends _{constructor(){super(...arguments);i(this,"type",v.IframeLoader);i(this,"load",async(e,t,s,r)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let d=w(),c="myop-comp-".concat(d);a=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(a.style.visibility="hidden"),a=this.appendChild(s,a,r);let m=t.loader.url;r!=null&&r._hasParent&&(m=At(m,"_myop-comp",d));let l="";r!=null&&r.elementAttributes&&(l=Object.entries(r==null?void 0:r.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(c,'"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(p.autoHeight||!p.height?"":p.height,"; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",';\n "\n src="').concat(m,'"\n ').concat(l,"\n ></iframe>"),a=s.querySelector("#".concat(c))}return new z(e,t,s,a,r)})}};var ue={webcomponent_message_key:"myop_webcomponent_message"};var N=class extends B{constructor(e,t,s,r,a){super(e,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",e=>{let t=h({},e),s=super.send(t),r=new CustomEvent(ue.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(r)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});i(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=r}inspect(){return this.cleanupInspect=fe(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 Ye={},ye=class extends _{constructor(){super(...arguments);i(this,"type",v.WebComponentLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader;Ye[a.url]?console.log("Module alreday loaded or in loading process"):Ye[a.url]=new Promise((c,m)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{c()},g.onerror=()=>{m()},document.head.appendChild(g)}),await Ye[a.url],await rt(1);let p="myop-comp-".concat(w()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),r!=null&&r._environment&&(d._myopEnvironment=r==null?void 0:r._environment),this.appendChild(s,d,r),new N(e,t,s,d,r)})}};var Ct="0.1.44";var M=class extends de{constructor(e,t){super(e);this.context=t;i(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(r,a)=>{this.messageToHost(E(h({},r),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var H={id:"myop-id"};var R=(o,n)=>n.querySelectorAll("[".concat(H.id,"='").concat(o.refConfig.selector,"']"));var he=class extends M{constructor(){super(...arguments);i(this,"messageType",f.BindClickMessage);i(this,"innerExecutor",(e,t,s)=>{let r=R(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new W(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Me=class extends M{constructor(){super(...arguments);i(this,"messageType",f.ChangeTextMessage);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.textContent=e.content})})}};var Ie=class extends me{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ce=class extends M{constructor(){super(...arguments);i(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(H.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(H.id);p&&r.push(new pe(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new Z(e.handlerUniqueId,r))});i(this,"messageType",f.DetectMyopRefsMessage)}};var xe=class extends M{constructor(){super(...arguments);i(this,"messageType",f.SetAttributeMessage);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var be=class extends M{constructor(){super(...arguments);i(this,"messageType",f.AddEventListenerMessage);i(this,"innerExecutor",(e,t,s)=>{let r=R(e.ref,t.shadowRoot),a=[];return r.forEach(p=>{let d=c=>{s(new V(e.handlerUniqueId,k(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var Te=class extends M{constructor(){super(...arguments);i(this,"messageType",f.CreateRefComponentMessage);i(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(H.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=L.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let m=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(m.refs).forEach(g=>{let u=m.refs[g];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),s(new A(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new A(e.handlerUniqueId,[],!0));debugger}})().then()})}};var xt=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=k,t.send=n,t.rootRef=e,t.__scriptInputs=t;let r=new Function("return (".concat(o.script,")(...arguments)"))(t);n(r)};var we=class extends M{constructor(){super(...arguments);i(this,"messageType",f.ExecuteScriptMessage);i(this,"innerExecutor",(e,t,s)=>{xt(e,a=>{s(new q(e.handlerUniqueId,a))},t)})}};var bt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(r=>{if(typeof r.value=="string"){let a=r.getAttribute(H.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:bt(r),required:r.required,validity:k(r.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Se=class extends M{constructor(){super(...arguments);i(this,"messageType",f.GetElementValueMessage);i(this,"innerExecutor",(e,t,s)=>{R(e.ref,t.shadowRoot).forEach(a=>{s(new j(bt(a)),e)})})}};var Re=class extends M{constructor(){super(...arguments);i(this,"messageType",f.SetInnerHtml);i(this,"innerExecutor",(e,t)=>{R(e.ref,t.shadowRoot).forEach(r=>{r.innerHTML=e.content})})}};var oe=class extends ce{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(e,t)=>{e.addEventListener(ue.webcomponent_message_key,s=>{let r=s.data?s.data:s.detail;if(!r||!r.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=r;if(this.handleIncomeMessages(s),a.messageType===f.InitMessage){let p=a.content.id;this.components[p].context=new Ie(e,t)}}}),setTimeout(()=>{this.messageToHost(new J)},1)});i(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});i(this,"supportedHandlers",[new Me(this.messageToHost,this.components),new Re(this.messageToHost,this.components),new he(this.messageToHost,this.components),new Ce(this.messageToHost,this.components),new xe(this.messageToHost,this.components),new be(this.messageToHost,this.components),new we(this.messageToHost,this.components),new Se(this.messageToHost,this.components),new Te(this.messageToHost,this.components)]);i(this,"init",()=>{})}};ie("WebComponentSDK",oe);var Tt=[],Ee,wt=async()=>(Ee||(Ee=new oe,Ee.init()),Ee);function Ut(o,n){return class extends HTMLElement{connectedCallback(){let e=n===O.open?"open":"closed",t=this.attachShadow({mode:e});wt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var zt=(o,n,e)=>{customElements.define(o,Ut(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Nt=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Wt=o=>(o=Nt(o),o.replace(/_/g,"-"));var ve=class extends _{constructor(){super(...arguments);i(this,"type",v.HTMLLoader);i(this,"load",async(e,t,s,r)=>{let a=t.loader,p="myop-comp-".concat(w()),d;if(a.shadowRootMode===O.localFrame){let c=w(),m="myop-comp-".concat(c),l=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(l.style.visibility="hidden"),l=this.appendChild(s,l,r),l.id=m,l.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ")),s.appendChild(l);let g=l.contentDocument||l.contentWindow.document;g.open();let u=a.HTML;if(r!=null&&r._inspection){let F=new DOMParser().parseFromString(a.HTML,"text/html"),et=F.implementation.createHTMLDocument();et.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let tt=et.body.firstChild;tt&&F.head&&F.head.insertBefore(F.importNode(tt,!0),F.head.firstChild),u=F.documentElement.outerHTML}g.writeln(u),g.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>")),g.close();let I=new z(e,t,s,l,r);return a.autoHeight&&(l.onload=()=>{I.observeSizeBasedOnDocumentElement()}),I}if(a.shadowRootMode===O.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,wt().then(m=>{m.connectedCallback(d,d)})}else{let c=Wt(e.name+t.id);Tt.includes(c)||(zt(c,a.HTML,a.shadowRootMode),Tt.push(c)),d=document.createElement(c)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,r),new N(e,t,s,d,r)})}};var ke=class ke{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"userFlows",{})}async fetchComponent(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(r.item)}catch(s){t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(r.item)}catch(s){t(s)}})),await this.userFlows[n]}};i(ke,"Main",new ke);var se=ke;var St=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...r]=De(t);switch(s){case"component":{let[a,p]=r,d=await se.Main.fetchComponent(a);if(d&&d.type.skins.find(m=>m.id===p))return d.instance.skinSelector={type:K.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=De(t),c=(await se.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===K.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(l=>l.id===p);if((m==null?void 0:m.type)===le.Segment){let l=m,u=c.instance.skinSelector.segments.find(I=>I.segmentId===l.segment.id);if(u)return c.instance.skinSelector=u==null?void 0:u.skinSelector,c}}}break}}}finally{return null}};var Rt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",L=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",Ct);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==f.EnvelopedMessage)return;let e=n.data;if(e.messageType===f.InitRequest){this.components2init.forEach(s=>{s.send(new $(s.id))});return}if(e.messageType===f.InitResponse){this.components2init=this.components2init.filter(r=>r.id!==e.content.id);let s=this.components.find(r=>{var a;return r.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===f.EnvelopedMessage){let s=e,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===b.down){s.message.messageType===S.name?r.onMessageReceived(s.message):(s.message.route=s.route,r.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let t=this.components.find(s=>s.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});i(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});i(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new ge,new ye,new ve];if(this.componentsLoaders=[...e],n){let t={};n.forEach(s=>{let r=new s(this.componentsLoaders);t[r.type]=r}),this.componentsLoaders.forEach(s=>{t[s.type]||(t[s.type]=s)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});i(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var r;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case K.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case K.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(u=>u.type===le.Segment?u.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let l=c.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});i(this,"loaderHooks");i(this,"loadComponent",async(n,e,t)=>{var m,l,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await St(n);s&&(n=s);let r=h(h({},(m=this.loaderHooks)!=null?m:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let I=await this.runSkinSelector(n,r);if(!I)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(I=await t.hooks.afterSkinSelected(h({},I))),n.instance.skinSelector={type:K.Dedicated,skin:I},t&&(t=h({},t),delete t.hooks),await Qe(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,r);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(I=>I.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(I=>I!==c),this.components2init=this.components2init.filter(I=>I!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=It(c,n.type.props,p));try{await Ze(c,n,this.components)}catch(I){throw I}return t!=null&&t.skipInit||await c.initiated(),c});i(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};i(L,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Rt});if(!window.myop.hostSDK){let o=new L;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Rt}),window.myop.hostSDK=o}var qt=window.myop.hostSDK;ie("hostSDK",qt);export{L as HostSDK,qt as hostSDK};
|
|
@@ -859,6 +859,10 @@ var ShadowRootModeType = {
|
|
|
859
859
|
"none": "none",
|
|
860
860
|
"localFrame": "localFrame"
|
|
861
861
|
};
|
|
862
|
+
var PropConfigBehaviorTypes = {
|
|
863
|
+
"message": "message",
|
|
864
|
+
"code": "code"
|
|
865
|
+
};
|
|
862
866
|
var RefBehaviorType = class {
|
|
863
867
|
};
|
|
864
868
|
__publicField(RefBehaviorType, "code", "code");
|
|
@@ -1032,7 +1036,22 @@ var setDebugStyle = (id, type, top, container, componentElement, componentDefini
|
|
|
1032
1036
|
container.removeChild(topText);
|
|
1033
1037
|
};
|
|
1034
1038
|
};
|
|
1035
|
-
var
|
|
1039
|
+
var reportError = (propConfig, propName, component) => {
|
|
1040
|
+
if (!propConfig) {
|
|
1041
|
+
console.error(
|
|
1042
|
+
// throw new Error(
|
|
1043
|
+
"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(propName, "\n") + "Component: ".concat(component.componentDefinition.name, ", ID: ").concat(component.componentDefinition.id, "\n\n") + "For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(component.componentDefinition.id, " or consult the developer guide.")
|
|
1044
|
+
);
|
|
1045
|
+
return true;
|
|
1046
|
+
}
|
|
1047
|
+
return false;
|
|
1048
|
+
};
|
|
1049
|
+
var reportUnsupported = (propConfig, propName, component) => {
|
|
1050
|
+
console.error(
|
|
1051
|
+
"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(propName, "\n") + "Component: ".concat(component.componentDefinition.name, ", ID: ").concat(component.componentDefinition.id, "\n\n") + "For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(component.componentDefinition.id, " or consult the developer guide.")
|
|
1052
|
+
);
|
|
1053
|
+
};
|
|
1054
|
+
var connectProps = (component, propsConfig, selectedSkin) => {
|
|
1036
1055
|
const propsMap = propsConfig.reduce((previousValue, currentValue) => {
|
|
1037
1056
|
return __spreadProps(__spreadValues({}, previousValue), {
|
|
1038
1057
|
[currentValue.name]: __spreadValues({}, currentValue)
|
|
@@ -1041,6 +1060,20 @@ var connectProps = (component, propsConfig) => {
|
|
|
1041
1060
|
const propsHandler = {
|
|
1042
1061
|
get: (_, prop) => {
|
|
1043
1062
|
const propConfig = propsMap[prop];
|
|
1063
|
+
if (reportError(propConfig, prop, component)) {
|
|
1064
|
+
return false;
|
|
1065
|
+
}
|
|
1066
|
+
if (propConfig.behavior.type === PropConfigBehaviorTypes.code) {
|
|
1067
|
+
if (selectedSkin.loader.type === SkinLoaders.HTMLLoader) {
|
|
1068
|
+
const typedLoader = selectedSkin.loader;
|
|
1069
|
+
if (typedLoader.shadowRootMode === ShadowRootModeType.localFrame) {
|
|
1070
|
+
const typedPropBehavior = propConfig.behavior;
|
|
1071
|
+
return component.element.contentWindow[typedPropBehavior.remap || prop];
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
reportUnsupported(propConfig, prop, component);
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1044
1077
|
if (propConfig.mode === "output") {
|
|
1045
1078
|
return new Promise((resolve) => {
|
|
1046
1079
|
const messageParams = [];
|
|
@@ -1061,29 +1094,40 @@ var connectProps = (component, propsConfig) => {
|
|
|
1061
1094
|
},
|
|
1062
1095
|
set: (_, prop, value) => {
|
|
1063
1096
|
const propConfig = propsMap[prop];
|
|
1064
|
-
if (
|
|
1065
|
-
|
|
1066
|
-
"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(prop, "\n") + "Component: ".concat(component.componentDefinition.name, ", ID: ").concat(component.componentDefinition.id, "\n\n") + "For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(component.componentDefinition.id, " or consult the developer guide.")
|
|
1067
|
-
);
|
|
1097
|
+
if (reportError(propConfig, prop, component)) {
|
|
1098
|
+
return false;
|
|
1068
1099
|
}
|
|
1069
|
-
if (propConfig.
|
|
1070
|
-
if (
|
|
1071
|
-
const
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1100
|
+
if (propConfig.behavior.type === PropConfigBehaviorTypes.code) {
|
|
1101
|
+
if (selectedSkin.loader.type === SkinLoaders.HTMLLoader) {
|
|
1102
|
+
const typedLoader = selectedSkin.loader;
|
|
1103
|
+
if (typedLoader.shadowRootMode === ShadowRootModeType.localFrame) {
|
|
1104
|
+
const typedPropBehavior = propConfig.behavior;
|
|
1105
|
+
component.element.contentWindow[typedPropBehavior.remap || prop] = value;
|
|
1106
|
+
return true;
|
|
1074
1107
|
}
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1108
|
+
}
|
|
1109
|
+
reportUnsupported(propConfig, prop, component);
|
|
1110
|
+
return false;
|
|
1111
|
+
} else {
|
|
1112
|
+
if (propConfig.mode === "input") {
|
|
1113
|
+
if (propConfig.behavior.type === "message") {
|
|
1114
|
+
const messageParams = [];
|
|
1115
|
+
if (propConfig.behavior.ref) {
|
|
1116
|
+
messageParams.push(Ref.create(propConfig.behavior.ref));
|
|
1117
|
+
}
|
|
1118
|
+
messageParams.push(value);
|
|
1119
|
+
if (propConfig.behavior.params) {
|
|
1120
|
+
messageParams.push(...propConfig.behavior.params);
|
|
1121
|
+
}
|
|
1122
|
+
const messageCtor = messages_exports[propConfig.behavior.message];
|
|
1123
|
+
component.send(new messageCtor(...messageParams));
|
|
1124
|
+
return true;
|
|
1125
|
+
} else {
|
|
1126
|
+
throw new Error(
|
|
1127
|
+
"Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n" + "Component: ".concat(component.componentDefinition.name, ", ID: ").concat(component.componentDefinition.id, "\n\n") + "Prop Name: ".concat(prop, "\n") + "Behavior Field: ".concat(propConfig.behavior.type, "\n\n") + "Check the documentation for valid behavior options."
|
|
1128
|
+
);
|
|
1129
|
+
return false;
|
|
1078
1130
|
}
|
|
1079
|
-
const messageCtor = messages_exports[propConfig.behavior.message];
|
|
1080
|
-
component.send(new messageCtor(...messageParams));
|
|
1081
|
-
return true;
|
|
1082
|
-
} else {
|
|
1083
|
-
throw new Error(
|
|
1084
|
-
"Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n" + "Component: ".concat(component.componentDefinition.name, ", ID: ").concat(component.componentDefinition.id, "\n\n") + "Prop Name: ".concat(prop, "\n") + "Behavior Field: ".concat(propConfig.behavior.type, "\n\n") + "Check the documentation for valid behavior options."
|
|
1085
|
-
);
|
|
1086
|
-
return false;
|
|
1087
1131
|
}
|
|
1088
1132
|
}
|
|
1089
1133
|
return false;
|
|
@@ -1277,6 +1321,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1277
1321
|
this.IframeElement.style.width = "".concat(ret.content.width, "px");
|
|
1278
1322
|
this.IframeElement.style.height = "".concat(ret.content.height, "px");
|
|
1279
1323
|
}));
|
|
1324
|
+
return cleanupHandler;
|
|
1280
1325
|
});
|
|
1281
1326
|
__publicField(this, "setSizeBasedOnDocumentElement", () => {
|
|
1282
1327
|
const cleanupHandler = this.send(new ExecuteScriptMessage(() => {
|
|
@@ -1542,7 +1587,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
1542
1587
|
};
|
|
1543
1588
|
|
|
1544
1589
|
// version:myop-sdk-version
|
|
1545
|
-
var myop_sdk_version_default = "0.1.
|
|
1590
|
+
var myop_sdk_version_default = "0.1.44";
|
|
1546
1591
|
|
|
1547
1592
|
// src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
|
|
1548
1593
|
var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
|
|
@@ -1964,9 +2009,11 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
1964
2009
|
), "};\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>"));
|
|
1965
2010
|
doc.close();
|
|
1966
2011
|
const comp = new MyopIframeComponent(componentDefinition, skin, container, IframeElement, options);
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2012
|
+
if (loaderConfig.autoHeight) {
|
|
2013
|
+
IframeElement.onload = () => {
|
|
2014
|
+
comp.observeSizeBasedOnDocumentElement();
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
1970
2017
|
return comp;
|
|
1971
2018
|
}
|
|
1972
2019
|
if (loaderConfig.shadowRootMode === ShadowRootModeType.none) {
|
|
@@ -2064,24 +2111,50 @@ var checkMyopOverride = async (componentConfig) => {
|
|
|
2064
2111
|
const params = new URLSearchParams(url.search);
|
|
2065
2112
|
const myopOverride = params.get("myopOverride");
|
|
2066
2113
|
if (myopOverride) {
|
|
2067
|
-
const [
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2114
|
+
const [source, ...uuids] = decompressUUIDs(myopOverride);
|
|
2115
|
+
switch (source) {
|
|
2116
|
+
case "component":
|
|
2117
|
+
{
|
|
2118
|
+
const [componentId, skinId] = uuids;
|
|
2119
|
+
const componentToOverride = await CloudRepository.Main.fetchComponent(componentId);
|
|
2120
|
+
if (componentToOverride) {
|
|
2121
|
+
const skin = componentToOverride.type.skins.find((skin2) => skin2.id === skinId);
|
|
2122
|
+
if (skin) {
|
|
2123
|
+
componentToOverride.instance.skinSelector = {
|
|
2124
|
+
type: SkinSelectorTypes.Dedicated,
|
|
2125
|
+
skin: {
|
|
2126
|
+
id: skinId
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2080
2129
|
return componentToOverride;
|
|
2081
2130
|
}
|
|
2082
2131
|
}
|
|
2083
2132
|
}
|
|
2084
|
-
|
|
2133
|
+
break;
|
|
2134
|
+
// case 'flow': {
|
|
2135
|
+
default:
|
|
2136
|
+
{
|
|
2137
|
+
const [flowId, experimentId] = decompressUUIDs(myopOverride);
|
|
2138
|
+
const flow = await CloudRepository.Main.fetchFlow(flowId);
|
|
2139
|
+
const componentToOverride = flow.components.find((c) => c.type.id === componentConfig.type.id);
|
|
2140
|
+
if (componentToOverride) {
|
|
2141
|
+
if (componentToOverride.instance.skinSelector.type === SkinSelectorTypes.Segmented) {
|
|
2142
|
+
if (componentToOverride.instance.resolvedExperiences) {
|
|
2143
|
+
const resolvedExperience = componentToOverride.instance.resolvedExperiences.find((e) => e.id === experimentId);
|
|
2144
|
+
if ((resolvedExperience == null ? void 0 : resolvedExperience.type) === ExperienceTypes.Segment) {
|
|
2145
|
+
const typedResolvedExperience = resolvedExperience;
|
|
2146
|
+
const typedSkinSelector = componentToOverride.instance.skinSelector;
|
|
2147
|
+
const segment = typedSkinSelector.segments.find((s) => s.segmentId === typedResolvedExperience.segment.id);
|
|
2148
|
+
if (segment) {
|
|
2149
|
+
componentToOverride.instance.skinSelector = segment == null ? void 0 : segment.skinSelector;
|
|
2150
|
+
return componentToOverride;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
break;
|
|
2085
2158
|
}
|
|
2086
2159
|
}
|
|
2087
2160
|
} finally {
|
|
@@ -2285,7 +2358,7 @@ var HostSDK = class {
|
|
|
2285
2358
|
});
|
|
2286
2359
|
__publicField(this, "loaderHooks");
|
|
2287
2360
|
__publicField(this, "loadComponent", async (componentConfig, container, options) => {
|
|
2288
|
-
var _a, _b, _c, _d
|
|
2361
|
+
var _a, _b, _c, _d;
|
|
2289
2362
|
if (!container) {
|
|
2290
2363
|
debugger;
|
|
2291
2364
|
throw new Error("no container was found for this component");
|
|
@@ -2294,13 +2367,13 @@ var HostSDK = class {
|
|
|
2294
2367
|
if (overriddenConfig) {
|
|
2295
2368
|
componentConfig = overriddenConfig;
|
|
2296
2369
|
}
|
|
2370
|
+
const hooks = __spreadValues(__spreadValues({}, (_a = this.loaderHooks) != null ? _a : {}), (_b = options == null ? void 0 : options.hooks) != null ? _b : {});
|
|
2297
2371
|
const ref = container;
|
|
2298
2372
|
if (ref.myop) {
|
|
2299
2373
|
if (ref.component) {
|
|
2300
2374
|
componentConfig = __spreadValues({}, componentConfig);
|
|
2301
2375
|
componentConfig.instance = __spreadValues({}, componentConfig.instance);
|
|
2302
|
-
|
|
2303
|
-
let selectedSkin2 = await this.runSkinSelector(componentConfig, hooks2);
|
|
2376
|
+
let selectedSkin2 = await this.runSkinSelector(componentConfig, hooks);
|
|
2304
2377
|
if (!selectedSkin2) {
|
|
2305
2378
|
throw new Error("runSkinSelector failed to choose skin, check the provided config");
|
|
2306
2379
|
}
|
|
@@ -2323,12 +2396,11 @@ var HostSDK = class {
|
|
|
2323
2396
|
}
|
|
2324
2397
|
}
|
|
2325
2398
|
container = container;
|
|
2326
|
-
const hooks = __spreadValues(__spreadValues({}, (_d = this.loaderHooks) != null ? _d : {}), (_e = options == null ? void 0 : options.hooks) != null ? _e : {});
|
|
2327
2399
|
let selectedSkin = await this.runSkinSelector(componentConfig, hooks);
|
|
2328
2400
|
if (!selectedSkin) {
|
|
2329
2401
|
throw new Error("runSkinSelector failed to choose skin, check the provided config");
|
|
2330
2402
|
}
|
|
2331
|
-
if ((
|
|
2403
|
+
if ((_d = options == null ? void 0 : options.hooks) == null ? void 0 : _d.afterSkinSelected) {
|
|
2332
2404
|
selectedSkin = await options.hooks.afterSkinSelected(__spreadValues({}, selectedSkin));
|
|
2333
2405
|
}
|
|
2334
2406
|
const componentLoader = this.componentsLoaders.find((loader) => loader.type === selectedSkin.loader.type);
|
|
@@ -2345,8 +2417,8 @@ var HostSDK = class {
|
|
|
2345
2417
|
return true;
|
|
2346
2418
|
});
|
|
2347
2419
|
this.components.push(component);
|
|
2348
|
-
if (options
|
|
2349
|
-
component = connectProps(component, componentConfig.type.props);
|
|
2420
|
+
if (!options || options.connectProps !== false) {
|
|
2421
|
+
component = connectProps(component, componentConfig.type.props, selectedSkin);
|
|
2350
2422
|
}
|
|
2351
2423
|
try {
|
|
2352
2424
|
await connectRefs(component, componentConfig, this.components);
|