@myop/sdk 0.4.0-beta.2 → 0.4.0-beta.4
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 +72 -32
- package/dist/cjs/{_IframeSDK.a43cfa7d.js → _IframeSDK.3a412cd4.js} +165 -63
- package/dist/cjs/_IframeSDK.3a412cd4.js.map +7 -0
- package/dist/cjs/_IframeSDK.9338575d.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.0f6ef369.js → _WebComponentSDK.4b6ac803.js} +121 -18
- package/dist/cjs/_WebComponentSDK.4b6ac803.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.4e78d94a.min.js +1 -0
- package/dist/cjs/_hostSDK.34f770f6.min.js +1 -0
- package/dist/cjs/{_hostSDK.38fcc5b4.js → _hostSDK.e9b70e44.js} +121 -18
- package/dist/cjs/_hostSDK.e9b70e44.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/cjs-bundled/myop_sdk.bundled.js +167 -64
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/IframeSDK.d.ts +26 -30
- package/dist/module/Iframe/index.js +166 -64
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +167 -64
- package/dist/module/SDK.js.map +3 -3
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/host/components/IMyopComponent.d.ts +3 -0
- package/dist/module/host/components/myopExtractedWebComponent.d.ts +24 -1
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/index.js +122 -19
- package/dist/module/host/index.js.map +2 -2
- package/dist/module/host/loaders/HTMLComponentLoader.d.ts +19 -1
- package/dist/module/webcomponent/index.js +122 -19
- package/dist/module/webcomponent/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.8f08de4b.min.js +0 -1
- package/dist/cjs/_IframeSDK.a43cfa7d.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.0f6ef369.js.map +0 -7
- package/dist/cjs/_WebComponentSDK.649e5e47.min.js +0 -1
- package/dist/cjs/_hostSDK.131fedc9.min.js +0 -1
- package/dist/cjs/_hostSDK.38fcc5b4.js.map +0 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var dn=Object.defineProperty,Zn=Object.defineProperties;var eo=Object.getOwnPropertyDescriptors;var pn=Object.getOwnPropertySymbols;var to=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var vt=(o,n,e)=>n in o?dn(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))to.call(n,e)&&vt(o,e,n[e]);if(pn)for(var e of pn(n))no.call(n,e)&&vt(o,e,n[e]);return o},z=(o,n)=>Zn(o,eo(n));var oo=(o,n)=>{for(var e in n)dn(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>vt(o,typeof n!="symbol"?n+"":n,e);var ue=class{constructor(n,e,t,i,s){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=i;this.offsetLeft=s;r(this,"type","MyopElementRef")}};var cn=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},M=class{constructor(n){this.messageToHost=n}},Fe=class extends M{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var y={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 We={};oo(We,{AddEventListenerMessage:()=>Ht,BaseMyopMessage:()=>b,BindClickMessage:()=>_t,ChangeTextMessage:()=>Rt,CleanupMessage:()=>_e,CleanupReplayMessage:()=>Re,ClickReplayMessage:()=>Q,CreateRefComponentMessage:()=>Se,CustomRefMessage:()=>X,DetectMyopRefsMessage:()=>Lt,DetectedMyopRefsMessage:()=>oe,DisposeMessage:()=>He,ElementValueReplayMessage:()=>ee,EnvelopedMessage:()=>ve,EventListenerCallbackMessage:()=>Z,ExecuteComponentMethod:()=>O,ExecuteScriptMessage:()=>B,ExecuteScriptReplyMessage:()=>J,GetAttributeMessage:()=>Pt,GetAttributeReplayMessage:()=>Ee,GetElementValueMessage:()=>Dt,InitMessage:()=>te,InitRequest:()=>ne,InitResponse:()=>xe,MessageDirection:()=>S,MutationObserverMessage:()=>Te,MyopBindMessage:()=>E,MyopBindReplayMessage:()=>v,MyopElementMessage:()=>Tt,Ref:()=>j,RefComponentCreatedMessage:()=>N,ResizeObserverMessage:()=>De,SetAttributeMessage:()=>kt,SetInnerHtml:()=>Bt,SetMutationObserverMessage:()=>Ot,SetResizeObserverMessage:()=>ke,stripFunction:()=>fn});var D=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var so=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 io=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 Et=o=>{let n=io(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(so(n.slice(t,t+16)));return e};var ln=o=>new Promise(n=>setTimeout(n,o));var S=class{};r(S,"down","down"),r(S,"up","up");var b=class{constructor(){r(this,"id",D());r(this,"myop",!0);r(this,"content");r(this,"source");r(this,"destination");r(this,"route");r(this,"ref");r(this,"direction");r(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},Tt=class extends b{constructor(e){super();this.ref=e}},v=class extends b{constructor(e){super();this.replayToHandler=e}},E=class extends b{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",D())}},j=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=z(h({},this),{component:null})}static create(n,e,t){let i=e;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(i,t)}};var mn="ClickReplayMessage",_t=class extends E{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",mn);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},Q=class extends v{constructor(){super(...arguments);r(this,"messageType",mn)}};var Rt=class extends b{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var un="ExecuteScriptReplyMessage",ro=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,ao=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,fn=o=>{let n=o.match(ro);if(n)return n[1]||n[3];{let e=o.match(ao);if(e)return e[1].trim()}},B=class extends E{constructor(e,t=()=>{},i){super(t);this.scriptInputs=i;r(this,"replyMessageKey",un);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=fn(this.content)}};r(B,"replierKey","send"),r(B,"completeStreamKey","completeStream");var J=class extends v{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",un)}};var X=class extends B{constructor(e,t,i=()=>{}){super(({rootRef:s,elementId:a,_script:p,__scriptInputs:d})=>{let c=(s.shadowRoot||s.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},i);this.scriptInputs=t;this.scriptInputs=z(h({},t),{_script:e.toString()})}};var gn="EventListenerCallbackMessage",Ht=class extends E{constructor(e,t,i){super(i);this.ref=e;this.type=t;this.handler=i;r(this,"replyMessageKey",gn);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},Z=class extends v{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",gn);this.content={e:t}}};var kt=class extends b{constructor(e,t,i){super();this.ref=e;this.name=t;this.value=i;r(this,"messageType","SetAttributeMessage")}};var yn="ElementValueReplayMessage",Dt=class extends E{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",yn);r(this,"messageType","GetElementValueMessage")}},ee=class extends v{constructor(e){super();this.content=e;r(this,"messageType",yn)}};var Bt=class extends b{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var te=class extends b{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},xe=class extends te{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},ne=class extends b{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var hn="RefComponentCreatedMessage",Se=class extends E{constructor(e,t,i,s){super(s);this.refConfig=e;this.nestedComponentConfig=t;this.options=i;r(this,"replyMessageKey",hn);r(this,"messageType","CreateRefComponentMessage")}},N=class extends v{constructor(e,t,i){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=i;r(this,"messageType",hn)}};var ve=class extends b{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let i=t;this.route=[e,...i.route?i.route:[]]}};var Mn="DetectedMyopRefsMessage",Lt=class extends E{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",Mn)}},oe=class extends v{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",Mn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var bn="GetAttributeReplayMessage",Pt=class extends E{constructor(e,t,i){super(i);this.ref=e;this.name=t;r(this,"replyMessageKey",bn);r(this,"messageType","GetAttributeMessage")}},Ee=class extends v{constructor(e){super();this.content=e;r(this,"messageType",bn)}};var O=class extends b{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ot=class extends b{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},Te=class extends b{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var Cn="CleanupReplayMessage",_e=class extends E{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",Cn);r(this,"messageType","CleanupMessage")}},Re=class extends v{constructor(e){super();this.customCleanup=e;r(this,"messageType",Cn)}};var He=class extends b{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ke=class extends b{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},De=class extends b{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var zt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},fe=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==S.down)return;if(t.messageType===y.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===y.InitMessage){let i=t.content.id;if(this.components[i])return;this.components[i]=new zt(i),this.messageToHost(new xe(i));return}if(t.messageType===y.EnvelopedMessage){let i=t,s=i.message;if(t=s,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===s.destination);if(a){a.send(s);return}let p=myop.hostSDK.components.find(d=>d.id===i.destination);if(p){p.send(s);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let s=t,a=this.messageCleanupCache[s.cleanupForMessageId],p=new Re(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[s.cleanupForMessageId],cn(a).then(()=>{this.messageToHost(p,s)}).catch(()=>{})):this.messageToHost(p,s);return}let i=!1;this.supportedHandlers.forEach(s=>{if(s.messageType===t.messageType){i=!0;let a=s.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(s.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(s.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 U={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var se={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var he={message:"message",code:"code"},ge=class{};r(ge,"code","code"),r(ge,"component","component");var ie={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ke={Segment:"Segment",Promo:"Promo",AB:"AB"},ye=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var H={id:"myop-id"};var Ne=class extends M{constructor(){super(...arguments);r(this,"messageType",y.DetectMyopRefsMessage);r(this,"executor",e=>{let t=document.querySelectorAll("[".concat(H.id,"]")),i=[];t.forEach(s=>{let a=s.getAttribute(H.id);a&&i.push(new ue(a,s.tagName,s.getBoundingClientRect()))}),this.messageToHost(new oe(e.handlerUniqueId,i))})}};var w=(o,n)=>n.querySelectorAll("[".concat(H.id,"='").concat(o.refConfig.selector,"']")),wn=(o,n)=>{let e=w(o,n);return e.length?e.item(0):null};var Ue=class extends M{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"executor",e=>{let t=[];return w(e.ref,document).forEach(s=>{let a=()=>{this.messageToHost(new Q,e)};s.addEventListener("click",a);let p=()=>{s.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(s=>s())}})}};var qe=class extends M{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{i.textContent=e.content})})}};var At=o=>o!==Object(o),po=o=>typeof o=="function",$t=o=>{if(At(o))return!0;if(po(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!$t(e))return!1}else{if(At(e))continue;return!1}}return!0},L=(o,n={},e=!0,t=new WeakMap)=>{if(At(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let i=[];t.set(o,i);for(let s=0;s<o.length;s++){let a=o[s];i[s]=L(a,n,e,t)}return i}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let i={};t.set(o,i);for(let s in o){let a=typeof n=="boolean"?n:n[s];a&&(a===!0?(e?o[s]!==void 0:o[s])&&(i[s]=L(o[s],!0,e,t)):typeof a=="object"&&(i[s]=L(o[s],a,e,t)))}return i}return{}};var Ve=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=L,t.send=n,t.rootRef=e,t.__scriptInputs=t;let s=new Function("return (".concat(o.script,")(...arguments)"))(t);n(s)};var je=class extends M{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"executor",e=>{Ve(e,i=>{this.messageToHost(new J(e.handlerUniqueId,i))},new ye(document.documentElement))})}};var Ge="__federation__",In="onLoad";var Me=(o,n)=>{window[Ge]&&window[Ge][o]&&window[Ge][o][In]&&window[Ge][o][In]({[o]:n})};var Ye=class extends M{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"executor",e=>{let t=w(e.ref,document),i=[];return t.forEach(s=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new Z(e.handlerUniqueId,L(p,e.serializableSkeleton)))})};s.addEventListener(e.type,a),i.push(()=>{s.removeEventListener(e.type,a)})}),()=>{i.forEach(s=>{s()})}})}};var Qe=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var F=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(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 i=this.messageHandlers[n],s=a=>e(a)?(t(a),!0):!1;return i.push(s),()=>{let a=i.indexOf(s);a>-1&&i.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||W.Instance().assignId(n);let i=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&(this._whenInitiatedReject("timeout_".concat(i," ").concat(this.id)),this.dispose())},i),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===y.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(i=>{t=t||i(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=S.down;let e=this.bindWhen(n.replyMessageKey,i=>i.replayToHandler===n.handlerUniqueId,i=>{n.handler(i),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=S.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,i=>i.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new _e(n.id,t=>{})),e&&e()}:()=>{}}runDisposeHandlers(){let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)})}dispose(){if(this.markedForDisposed=!0,!this.isInitiated){this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed";return}console.log("disposing component",this.id),this.send(new He),this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var xn={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 Be=class extends F{constructor(e,t,i){super(e,t.container,i);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,i=super.send(e);return this.parent.send(new ve(this.id,e)),e.handler=t,i});r(this,"dispose",()=>{this.isInitiated&&this.send(new O("dispose")),super.dispose()})}hide(){this.send(new O("hide"))}show(){this.send(new O("show"))}inspect(){return this.send(new O("inspect"))}setHeightBasedOnDocumentElement(){this.send(new O("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new O("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var re=class extends F{constructor(e,t,i,s,a,p){super(e,i,p);this.container=i;this.customElement=s;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",e=>{let t=e.detail;t!=null&&t.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}))});r(this,"_autoSizeOptions");r(this,"observeAutoSize",e=>{this._autoSizeOptions=e;let t=this.customElement;try{getComputedStyle(t).display==="inline"&&(t.style.display="block")}catch(d){}let i=d=>{if(d===void 0)return;if(typeof d=="number")return d;let c=parseFloat(d);return isNaN(c)?void 0:c},s=(d,c,m)=>c!==void 0&&d<c?c:m!==void 0&&d>m?m:d,a=()=>{var u;let d=this._autoSizeOptions,c=t.getBoundingClientRect(),m=(d==null?void 0:d.explicitHeight)===void 0;(u=d==null?void 0:d.onSizeChange)==null||u.call(d,{width:c.width,height:m?s(c.height,i(d==null?void 0:d.minHeight),i(d==null?void 0:d.maxHeight)):c.height,autoSizingWidth:!1,autoSizingHeight:m})},p;try{p=new ResizeObserver(()=>a()),p.observe(t)}catch(d){}return a(),()=>{p==null||p.disconnect(),this._autoSizeOptions=void 0}});r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=s,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=be(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(i=>{this.markedForDisposed||e(i.action,i.payload)})}}};var co=(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},be=(o,n,e,t,i,s)=>{let a=co("".concat(s.name," : ").concat(n),e,s);return t.insertBefore(a,i),i.style.border="1px solid #007BFF",i.style.display="block",()=>{i.style.border="unset",t.removeChild(a)}},Sn=(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),vn=(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."))},En=(o,n,e)=>{let t=n.reduce((s,a)=>z(h({},s),{[a.name]:h({},a)}),{}),i={get:(s,a)=>{let p=t[a];if(Sn(p,a,o))return!1;if(p.behavior.type===he.code){if(o instanceof re)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(o instanceof q&&o.isolated)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(e.loader.type===U.HTMLLoader&&e.loader.shadowRootMode===se.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return vn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(j.create(p.behavior.ref)),c.push(u=>{d(u)}),p.behavior.params&&c.push(...p.behavior.params);let m=We[p.behavior.message];o.send(new m(...c))}):null},set:(s,a,p)=>{let d=t[a];if(Sn(d,a,o))return!1;if(d.behavior.type===he.code){if(o instanceof re){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(o instanceof q&&o.isolated){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===U.HTMLLoader&&e.loader.shadowRootMode===se.localFrame){let m=d.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=p,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.forEach(l=>{o.markedForDisposed||p(l.action,l.payload)})}return!0}return vn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(j.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let m=We[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,i),o},lo=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...s)=>new Promise(a=>{s.forEach(p=>{$t(p)||xn.notSerializableRefCall(t,p)}),n.send(new X(({ref:p,propName:d,functionArgs:c,makeSerializable:m})=>{if(p){let u=p[d];return m(typeof u=="function"?p[d](...c):u,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:s},p=>{a(p.content)}))})},set(e,t,i){return n.send(new X(({ref:s,propName:a,propValue:p})=>{s&&(s[a]=p)},{elementId:e.refConfig.selector,propValue:i,propName:t},s=>{})),!0}}),Ft=async(o,n,e,t)=>{let i=o.component;if(!i)throw new Error("cant createRefComponent with detached ref");return new Promise(async(s,a)=>{let p=new Be(n.type,i,t);e.push(p);let d=()=>{let m=e.indexOf(p);m!==-1&&e.splice(m,1)};await i.initiated();let c=setTimeout(()=>{d(),a("timeout")},5e3);i.send(new Se(o.refConfig,n,z(h({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){d(),a("CreateRefComponentMessage failed");return}let u=e.find(f=>f.id==p.id);if(u&&u!==p){d(),i.refs[o.refConfig.name]=u,s(u);return}else p.setInitiated(),i.refs[o.refConfig.name]=p;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(R=>R.type.id===f.componentDefinitionId).type,l=new Be(g,p);l.setInitiated(),p.refs[f.refName]=l,e.push(l)});try{await Wt(p,n,e,!0),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),s(p)}catch(f){a(f)}}))})},Wt=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let i=Object.values(o.componentDefinition.refs).map(s=>new Promise(async(a,p)=>{var d;if(s.behavior.type==ge.component){if(t){a();return}let c=s.behavior.componentId;c||(c=s.behavior.instance.componentId);let m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=j.create("",s,o);try{let f=await Ft(u,m,e);o.refs[s.name]=f,a()}catch(f){p(f)}}else try{let c=j.create("",s,o);o.refs[s.name]=lo(c,o),a()}catch(c){}}));try{await Promise.all(i)}catch(s){throw s}};var q=class extends F{constructor(e,t,i,s,a){super(e,i,a);this.componentConfig=e;this.container=i;this.IframeElement=s;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"isolated",!1);r(this,"_lastData");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_isoMsgHandler");r(this,"_isoSizeOpts");r(this,"_isoAutoSize",!1);r(this,"_isoLastSize");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new B(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new B(({send:t})=>{let{height:i,width:s}=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:i,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this.isolated)return this._isoSizeOpts=e,this._isoAutoSize=!0,this._isoLastSize&&this._applyIsoSize(this._isoLastSize.height,this._isoLastSize.width),()=>{this._isoAutoSize=!1,this._isoSizeOpts=void 0};if(this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,i=t.contentDocument;if(!i)return this.observeHeightViaBridge();let s=(g,l,R)=>l!==void 0&&g<l?l:R!==void 0&&g>R?R:g,a=g=>{if(g===void 0)return;if(typeof g=="number")return g;let l=parseFloat(g);return isNaN(l)?void 0:l},p=()=>{var Jt,Xt,Zt,en,tn,nn,on,sn;let g=t.contentDocument;if(!g)return;let l=this._autoSizeOptions,R=a(l==null?void 0:l.minWidth),k=a(l==null?void 0:l.maxWidth),V=a(l==null?void 0:l.minHeight),T=a(l==null?void 0:l.maxHeight),pe=(Jt=l==null?void 0:l.loaderMinHeight)!=null?Jt:50,Y=((Xt=this.sizeMeta)==null?void 0:Xt.width)==="100%"?"100%":void 0,P=((Zt=this.sizeMeta)==null?void 0:Zt.height)==="100%"?"100%":void 0,I=(tn=(en=l==null?void 0:l.explicitWidth)!=null?en:Y)!=null?tn:"100%",C=(nn=l==null?void 0:l.explicitHeight)!=null?nn:P,_=I!==void 0,de=C!==void 0,ce=this.container.getBoundingClientRect(),Nn=ce.width===0,Un=ce.height===0||ce.height===pe,le=(l!=null&&l.forceAutoSize||Nn)&&!_,me=(l!=null&&l.forceAutoSize||Un)&&!de;if(!le&&!me){t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(on=l==null?void 0:l.onSizeChange)==null||on.call(l,{width:typeof I=="number"?I:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let qn=t.style.transition,K=this.container,Vn=K.style.transition;t.style.transition="none",K.style.transition="none";let qt=t.getBoundingClientRect().height,Vt=t.getBoundingClientRect().width,jt=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),Gt=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),we=Gt,Ie=jt,jn=me&&jt>qt+1,Gn=le&&Gt>Vt+1,ze=me&&!jn,Ae=le&&!Gn;if(ze||Ae){let Jn=K.style.minHeight,Xn=K.style.minWidth;ze&&(K.style.minHeight="".concat(qt,"px")),Ae&&(K.style.minWidth="".concat(Vt,"px")),ze&&(t.style.height="0px"),Ae&&(t.style.width="0px"),we=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),Ie=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height));let rn=ze&&Ie<2,an=Ae&&we<2;if(rn||an){let $e=g.createElement("style");$e.id="__myop_measure";let St=[];rn&&St.push("height: auto !important","min-height: 0 !important","max-height: none !important"),an&&St.push("width: auto !important","min-width: 0 !important","max-width: none !important"),$e.textContent="*, *::before, *::after { ".concat(St.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),g.head.appendChild($e),we=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),Ie=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),$e.remove()}K.style.minHeight=Jn,K.style.minWidth=Xn}let Yt=s(we,R,k),Qt=s(Ie,V,T);le?t.style.width="".concat(Yt,"px"):t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",me?t.style.height="".concat(Qt,"px"):t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",t.offsetHeight,t.style.transition=qn,K.style.transition=Vn;let Yn=le&&k!==void 0&&we>k,Qn=me&&T!==void 0&&Ie>T;g.documentElement.style.overflowX=Yn?"auto":"",g.documentElement.style.overflowY=Qn?"auto":"",(sn=l==null?void 0:l.onSizeChange)==null||sn.call(l,{width:Yt,height:Qt,autoSizingWidth:le,autoSizingHeight:me})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},m=new ResizeObserver(()=>c());m.observe(i.body),m.observe(i.documentElement);let u=new MutationObserver(()=>c());u.observe(i.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{m.disconnect(),u.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});r(this,"_bridgeSizeCleanup");r(this,"observeHeightViaBridge",()=>{if(this._bridgeSizeCleanup)return this._bridgeSizeCleanup;let e,t=!1,i=()=>{t=!0,e==null||e(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=i,this.initiated().then(()=>{t||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),e=this.send(new ke))}).catch(s=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(s))}),i});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new B(()=>{let{height:t,width:i}=document.documentElement.getBoundingClientRect();return{height:t,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new B(()=>{let i=0;return i++,i--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+i+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var s,a;let t=h({},e);if(t.messageType===y.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=S.down;let i=super.send(t);return(a=(s=this.IframeElement)==null?void 0:s.contentWindow)==null||a.postMessage(t,"*"),i});r(this,"dispose",()=>{var e,t;(e=this._bridgeSizeCleanup)==null||e.call(this),this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this._isoMsgHandler&&(window.removeEventListener("message",this._isoMsgHandler),this._isoMsgHandler=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),(t=this.IframeElement.parentNode)==null||t.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=e=>{if(e.source!==this.IframeElement.contentWindow)return;let t=e.data;!t||t.__myop!==!0||(t.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}):t.type==="myop:size"&&this._applyIsoSize(t.height,t.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(e){var t,i;this._lastData=e,(i=(t=this.IframeElement)==null?void 0:t.contentWindow)==null||i.postMessage({__myop:!0,type:"myop:init",data:e},"*")}getData(){return this._lastData}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(i=>{this.markedForDisposed||e(i.action,i.payload)})}}_applyIsoSize(e,t){var c;if(!e||Number.isNaN(e)||(this._isoLastSize={height:e,width:t},!this._isoAutoSize))return;let i=this._isoSizeOpts,s=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),a=s(i==null?void 0:i.minHeight),p=s(i==null?void 0:i.maxHeight),d=e;a!==void 0&&d<a&&(d=a),p!==void 0&&d>p&&(d=p),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=d+"px",this.IframeElement.style.width="100%",(c=i==null?void 0:i.onSizeChange)==null||c.call(i,{width:t!=null?t:this.IframeElement.clientWidth,height:d,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=be(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===y.In.MutationObserverMessage||e.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var G=class{constructor(){r(this,"appendChild",(n,e,t)=>{var i;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let s=(i=t.relative.child)==null?void 0:i.nextSibling;return n.insertBefore(e,s||null)}}else return n.appendChild(e)})}};var mo=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Je=class extends G{constructor(){super(...arguments);r(this,"type",U.IframeLoader);r(this,"load",async(e,t,i,s)=>{let a,p=t.loader;if((i==null?void 0:i.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,i),a=i,a.src=p.url;else{let c=D(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;let u="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(s!=null&&s.hidden?"0":"1",";\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n ");a.style.cssText=u,s!=null&&s.elementAttributes&&Object.entries(s.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=t.loader.url;s!=null&&s._hasParent&&(f=mo(f,"_myop-comp",c)),a.src=f,i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),a=this.appendChild(i,a,s)}let d=new q(e,t,i,a,s);return p.autoHeight&&(s==null?void 0:s.autoSize)!==!1&&d.observeHeightViaBridge(),d})}};var Xe={webcomponent_message_key:"myop_webcomponent_message"};var Ce=class extends F{constructor(e,t,i,s,a){super(e,i,a);this.container=i;this.customElement=s;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),i=super.send(t),s=new CustomEvent(Xe.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(s)}catch(a){console.log("error while trying to dispatchEvent",a)}return i});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=s}inspect(){return this.cleanupInspect=be(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 Kt={},Ze=class extends G{constructor(){super(...arguments);r(this,"type",U.WebComponentLoader);r(this,"load",async(e,t,i,s)=>{let a=t.loader;Kt[a.url]?console.log("Module alreday loaded or in loading process"):Kt[a.url]=new Promise((c,m)=>{let u=a.url,f=document.createElement("script");f.type="module",f.src=u,f.onload=()=>{c()},f.onerror=()=>{m()},document.head.appendChild(f)}),await Kt[a.url],await ln(1);let p="myop-comp-".concat(D()),d=document.createElement(a.tag);return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),d.id=p,s!=null&&s.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"),s!=null&&s._environment&&(d._myopEnvironment=s==null?void 0:s._environment),this.appendChild(i,d,s),new Ce(e,t,i,d,s)})}};var et="0.4.0-beta.4";var uo="myop-delivery",ot="components";var tt=null;function fo(){return tt||(tt=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(uo,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(ot)||e.createObjectStore(ot,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),tt)}function nt(o,n){return fo().then(e=>new Promise(t=>{if(!e)return t(null);try{let i=e.transaction(ot,o),s=n(i.objectStore(ot));s.onsuccess=()=>t(s.result),s.onerror=()=>t(null),i.onabort=()=>t(null)}catch(i){t(null)}}))}var Nt="myop.d.";function Tn(o,n,e){try{localStorage.setItem(Nt+o,JSON.stringify({t:n,e}))}catch(t){}}function go(o){try{localStorage.removeItem(Nt+o)}catch(n){}}var Le=new Map,A={key(o,n,e,t,i){return"".concat(o,"|").concat(n,"|").concat(e,"|").concat(t?"preview":"live","|").concat(i||"raw")},async get(o){let n=Le.get(o);if(n)return n;let e=await nt("readonly",t=>t.get(o));return e&&(Le.set(o,e),Tn(o,e.tag,e.storedAt+e.windowMs)),e},async put(o){Le.set(o.key,o),Tn(o.key,o.tag,o.storedAt+o.windowMs),await nt("readwrite",n=>n.put(o))},async drop(o){Le.delete(o),go(o),await nt("readwrite",n=>n.delete(o))},fresh(o){return!!o&&Date.now()-o.storedAt<o.windowMs},windowFrom(o){let n=o.get("cache-control")||"";if(/no-store|no-cache/i.test(n))return 0;let e=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!e)return 0;let t=Number(e[1]),i=Number(o.get("age")||0);return Math.max(0,t-(isNaN(i)?0:i))*1e3},async clear(){Le.clear();try{for(let o=localStorage.length-1;o>=0;o--){let n=localStorage.key(o);n&&n.startsWith(Nt)&&localStorage.removeItem(n)}}catch(o){}await nt("readwrite",o=>o.clear())}};var _n=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:he.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:he.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),st="__MYOP_CLOUD_REPOSITORY_MAIN__",yo=()=>{if(typeof window<"u")return window[st];if(typeof globalThis<"u")return globalThis[st]},ho=o=>{typeof window<"u"&&(window[st]=o),typeof globalThis<"u"&&(globalThis[st]=o)},$=class ${constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"preloadedComponents",{});r(this,"userFlows",{});r(this,"_defaultEnv","production");r(this,"_envExplicitlySet",!1);r(this,"_staticMode",!1);r(this,"_queryParams",{});r(this,"_delivery",{minify:!1,host:null,cache:!1});r(this,"_deliveryStats",{requests:0,viaDelivery:0,fellBack:0,lastError:null,fromMemory:0,fromStorage:0,fromNetwork:0,revalidations:0,unchanged:0,bytesSaved:0});r(this,"_localServes",new Map);r(this,"_flushBound",!1)}static get Main(){let n=yo();return n||($._main||($._main=new $,ho($._main)),$._main)}static sizeOfHeld(n){var e,t,i,s,a;try{return(((a=(s=(i=(t=(e=n==null?void 0:n.config)==null?void 0:e.type)==null?void 0:t.skins)==null?void 0:i[0])==null?void 0:s.loader)==null?void 0:a.HTML)||"").length}catch(p){return 0}}setDelivery(n={}){n.minify!==void 0&&(this._delivery.minify=!!n.minify),n.host!==void 0&&(this._delivery.host=n.host),n.cache!==void 0&&(this._delivery.cache=!!n.cache)}deliveryStats(){var n;return z(h({},this._deliveryStats),{host:(n=this._delivery.host)!=null?n:$.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache})}async refreshDelivery(){await A.clear()}noteLocalServe(n,e){let t=this._localServes.get(n);t?t.count++:this._localServes.set(n,{env:e,count:1}),this.bindFlush()}bindFlush(){if(this._flushBound||typeof document>"u")return;this._flushBound=!0;let n=()=>{document.visibilityState==="hidden"&&this.flushLocalServes()};document.addEventListener("visibilitychange",n),window.addEventListener("pagehide",()=>this.flushLocalServes())}flushLocalServes(){if(!this._localServes.size)return;let n=[...this._localServes.entries()].map(([e,t])=>"".concat(e,":").concat(t.env,":").concat(t.count)).join(",");this._localServes.clear();try{let e="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(e,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(e){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var s;this._localServes.size&&this.flushLocalServes();let e=this.deliveryHost(),t="".concat(e).concat(n);this._deliveryStats.requests++;let i=e!==this._baseUrl;try{let a=await fetch(t);if(a.ok||a.status<500||!i)return i&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(e)}catch(a){if(!i)throw a;this._deliveryStats.lastError=String((s=a==null?void 0:a.message)!=null?s:a)}return this._deliveryStats.fellBack++,console.warn("[myop] delivery host failed (".concat(this._deliveryStats.lastError,") \u2014 falling back to ").concat(this._baseUrl)),await fetch("".concat(this._baseUrl).concat(n))}enableStaticMode(){this._staticMode=!0}setQueryParams(n){this._queryParams=n}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,e,t){return this.fetchComponentV2(n,e,t)}async fetchComponentV2(n,e,t){let{env:i,usePreview:s,cacheKey:a}=this.resolveParams(n,e,t);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:i,usePreview:s,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:i,preview:s}),this.variants[a]=new Promise(async(p,d)=>{try{let c;if(this._staticMode){let V=s?"preview":i;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(V,".json");let T=new URLSearchParams(this._queryParams).toString();T&&(c+="?".concat(T))}else c="/consume?id=".concat(n,"&env=").concat(i),s&&(c+="&preview=true"),this._delivery.minify&&!s&&(c+="&opt=min");let m=this._delivery.cache&&!this._staticMode&&!s,u=m?A.key(this.deliveryHost(),n,i,s,this._delivery.minify?"min":"raw"):"",f=m?await A.get(u):null;if(f&&A.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,i),this.variants[a].resolved=f.config,p(f.config);return}if(f&&f.tag){let V="/consume?ids=".concat(n,"&env=").concat(i)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let T=await this.deliveryFetch(V);if(T.ok){let pe=await T.json();if((pe.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=$.sizeOfHeld(f),f.storedAt=Date.now(),f.windowMs=A.windowFrom(T.headers)||f.windowMs,await A.put(f),this.variants[a].resolved=f.config,p(f.config);return}let Y=(pe.items||[])[0];if(Y){let P=_n(Y);this._deliveryStats.fromNetwork++,await A.put({key:u,config:P,tag:Y.tag||null,storedAt:Date.now(),windowMs:A.windowFrom(T.headers),host:this.deliveryHost()}),this.variants[a].resolved=P,p(P);return}}}catch(T){}}let g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){d(new Error('Failed to load component "'.concat(n,'" (').concat(g.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let R=(await g.json()).item;if(!R){d(new Error('Component "'.concat(n,'" not found')));return}if(!R.consume_variant||!R.consume_variant.length){d(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(i,'"')));return}let k=_n(R);this._deliveryStats.fromNetwork++,m&&await A.put({key:u,config:k,tag:R.tag||null,storedAt:Date.now(),windowMs:A.windowFrom(g.headers),host:this.deliveryHost()}),this.variants[a].resolved=k,p(k)}catch(c){delete this.variants[a],d(c)}})),await this.variants[a]}getResolvedConfig(n,e,t){var s;let{cacheKey:i}=this.resolveParams(n,e,t);return((s=this.variants[i])==null?void 0:s.resolved)||null}resolveParams(n,e,t){let i=this.preloadedComponents[n],s=e!==void 0||t!==void 0,a,p;if(!s&&i)a=i.env,p=i.preview;else{a=e||this._defaultEnv;let d=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!d}return{env:a,usePreview:p,cacheKey:"".concat(n,":").concat(a,":").concat(p?"preview":"live")}}hydrateComponent(n,e,t,i){let{env:s,usePreview:a,cacheKey:p}=this.resolveParams(n,t,i),d=Promise.resolve(e);d.resolved=e,this.variants[p]=d,this.preloadedComponents[n]={env:s,preview:a}}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(i=>i.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 s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(s.item)}catch(i){delete this.userFlows[n],t(i)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(s.item)}catch(i){delete this.userFlows[n],t(i)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r($,"_main",null),r($,"DEFAULT_HOST","https://cloud.myop.dev");var ae=$;var it=ae.Main;var Mo="https://delivery.myop.dev",Rn=(o={})=>{var e,t;let n=o.minify!==!1||o.cache===!0;return it.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,host:o.host!==void 0?o.host:n?Mo:null}),Pe()},Hn=async()=>(await it.refreshDelivery(),Pe()),Pe=()=>it.deliveryStats(),kn=()=>(it.setDelivery({minify:!1,cache:!1,host:null}),Pe());var x=class extends Fe{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let i=(s,a)=>{this.messageToHost(z(h({},s),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,i)}else debugger}else debugger})}};var rt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,i)=>{let s=w(e.ref,t.shadowRoot),a=[];return s.forEach(p=>{let d=()=>{i(new Q(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var at=class extends x{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{w(e.ref,t.shadowRoot).forEach(s=>{s.textContent=e.content})})}};var pt=class extends ye{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var dt=class extends x{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let i=t.shadowRoot.querySelectorAll("[".concat(H.id,"]")),s=[];i.forEach(a=>{let p=a.getAttribute(H.id);p&&s.push(new ue(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new oe(e.handlerUniqueId,s))});r(this,"messageType",y.DetectMyopRefsMessage)}};var ct=class extends x{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{w(e.ref,t.shadowRoot).forEach(s=>{s.setAttribute(e.name,e.value)})})}};var lt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,i)=>{let s=w(e.ref,t.shadowRoot),a=[];return s.forEach(p=>{let d=c=>{i(new Z(e.handlerUniqueId,L(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var mt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,i)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(H.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=W.Instance(),d=p.components.find(f=>f.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),u=[];Object.keys(m.refs).forEach(f=>{let g=m.refs[f];g=g.__nonProxied||g,g.componentDefinition&&u.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),i(new N(e.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new N(e.handlerUniqueId,[],!0));debugger}})().then()})}};var ut=class extends x{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,i)=>{Ve(e,a=>{i(new J(e.handlerUniqueId,a))},t)})}};var Dn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),i=-1;return t.forEach(s=>{if(typeof s.value=="string"){let a=s.getAttribute(H.id),p=s.getAttribute("name"),d={id:s.id,name:p,value:Dn(s),required:s.required,validity:L(s.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},ft=class extends x{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,i)=>{w(e.ref,t.shadowRoot).forEach(a=>{i(new ee(Dn(a)),e)})})}};var gt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{w(e.ref,t.shadowRoot).forEach(s=>{s.innerHTML=e.content})})}};var Oe=class extends fe{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Xe.webcomponent_message_key,i=>{let s=i.data?i.data:i.detail;if(!s||!s.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=s;if(this.handleIncomeMessages(i),a.messageType===y.InitMessage){let p=a.content.id;this.components[p].context=new pt(e,t)}}}),setTimeout(()=>{this.messageToHost(new ne)},1)});r(this,"messageToHost",(e,t)=>{e.direction=S.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new at(this.messageToHost,this.components),new gt(this.messageToHost,this.components),new rt(this.messageToHost,this.components),new dt(this.messageToHost,this.components),new ct(this.messageToHost,this.components),new lt(this.messageToHost,this.components),new ut(this.messageToHost,this.components),new ft(this.messageToHost,this.components),new mt(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Me("WebComponentSDK",Oe);var Bn="";var bo="<!-- myop-web-component -->",Pn="myop-web-component",On=new Map,zn=[],yt,An=async()=>(yt||(yt=new Oe,yt.init()),yt);function Co(o,n){return class extends HTMLElement{connectedCallback(){let e=n===se.open?"open":"closed",t=this.attachShadow({mode:e});An().then(i=>{i.connectedCallback(this,t),t.innerHTML=o})}}}var wo=(o,n,e)=>{customElements.define(o,Co(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Io=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),xo=o=>(o=Io(o),o.replace(/_/g,"-"));var ht=class extends G{constructor(){super(...arguments);r(this,"type",U.HTMLLoader);r(this,"load",async(e,t,i,s)=>{let a=t.loader,p=this.isMyopWebComponent(a.HTML),{mode:d,isolate:c}=await this.resolveRenderMode(e,t,a,p,s);if(d===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(e.id,'"'));if(p){if(d!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(e.id,'"'));return this.loadExtractedWebComponent(e,t,i,a.HTML,s)}let m="myop-comp-".concat(D()),u;if(a.shadowRootMode===se.localFrame){let f=D(),g="myop-comp-".concat(f),l=document.createElement("iframe");l.id=g,c&&l.setAttribute("sandbox","allow-scripts allow-forms allow-popups"),l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(s!=null&&s.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n "),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),l=this.appendChild(i,l,s);let R=[],k=c?{open(){},writeln(I){R.push(I)},close(){l.srcdoc=R.join("\n")}}:(()=>{let I=l.contentDocument||l.contentWindow.document;return I.open(),I})(),V=null;{let _=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(_)try{V=JSON.parse(_.getAttribute("content")||"{}")}catch(de){}}let T=a.HTML;if(s!=null&&s._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),_=C.getElementById("myop_preview");_==null||_.removeAttribute("type");let de=C.implementation.createHTMLDocument();de.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ce=de.body.firstChild;ce&&C.head&&C.head.insertBefore(C.importNode(ce,!0),C.head.firstChild),T="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((s==null?void 0:s.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),_=C.getElementById("myop_preview");_&&(_.remove(),T="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(s!=null&&s.injectCss){let C=new DOMParser().parseFromString(T,"text/html"),_=C.createElement("style");_.setAttribute("data-myop-injected","true"),_.textContent=s.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(_),T="<!DOCTYPE html>"+C.documentElement.outerHTML}k.writeln(T);let pe='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),Y="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";if(c||k.writeln("".concat(pe).concat(Y)),!c&&(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null){let I="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",C=JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script"),_='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(C,";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");k.writeln(I+_)}if(c){let I=(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null?JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";k.writeln(this.buildIsolationBridge(I))}k.close();let P=new q(e,t,i,l,s);return c&&P.enableIsolation(),P.sizeMeta=V,P.initiated().then(()=>{if((s==null?void 0:s.autoSize)===!1)return;let I=!1;P.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!I&&!(s!=null&&s.hidden)&&(I=!0,P.show())}})}),P}if(a.shadowRootMode===se.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,An().then(g=>{g.connectedCallback(u,u)})}else{let f=xo(e.name+t.id);zn.includes(f)||(wo(f,a.HTML,a.shadowRootMode),zn.push(f)),u=document.createElement(f)}return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),u.id=m,s!=null&&s.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),this.appendChild(i,u,s),new Ce(e,t,i,u,s)})}isMyopWebComponent(e){return e.trimStart().startsWith(bo)?!0:new RegExp("<script[^>]*\\sid=[\"']?".concat(Pn,"[\"'\\s>]"),"i").test(e)}async resolveRenderMode(e,t,i,s,a){var m,u,f,g;let p=s?"webComponent":i.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",d=(g=a==null?void 0:a.renderPolicy)!=null?g:(f=(u=(m=window==null?void 0:window.myop)==null?void 0:m.hostSDK)==null?void 0:u.getRenderPolicy)==null?void 0:f.call(u),c=d?await d({componentDefinition:e,skin:t,requestedMode:p,isWebComponent:s}):p;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(e){return"<script>\n (function () {\n var __initial = ".concat(e,";\n var __pending;\n // data-out (cta)\n window.myop_cta_handler = function (action, payload) {\n try { parent.postMessage({ __myop: true, type: 'myop:cta', action: action, payload: payload }, '*'); } catch (e) {}\n };\n function callInit(data) {\n if (typeof window.myop_init_interface === 'function') { window.myop_init_interface(data); return true; }\n return false;\n }\n // data-in (init updates)\n window.addEventListener('message', function (e) {\n var d = e.data;\n if (!d || d.__myop !== true) return;\n if (d.type === 'myop:init') { if (!callInit(d.data)) __pending = d.data; }\n });\n // first render: use a pending update if one arrived, else the baked initial data\n (function flushInitial() {\n var data = (__pending !== undefined) ? __pending : __initial;\n if (data === undefined) return;\n if (callInit(data)) { __pending = undefined; __initial = undefined; }\n else requestAnimationFrame(flushInitial);\n })();\n // resize (report content size)\n function contentHeight() {\n // Measure the BODY (content box). documentElement.scrollHeight includes\n // the iframe viewport \u2014 which we're driving \u2014 so it would report the\n // current frame height, not the content, and never shrink.\n var b = document.body;\n if (b) return Math.max(b.scrollHeight, b.offsetHeight);\n return document.documentElement.scrollHeight;\n }\n function postSize() {\n try {\n parent.postMessage({\n __myop: true, type: 'myop:size',\n height: contentHeight(),\n width: document.documentElement.scrollWidth\n }, '*');\n } catch (e) {}\n }\n // Observe the BODY (reflows with content) \u2014 not documentElement, whose box is\n // the iframe viewport and would feed back into a resize loop. A MutationObserver\n // catches content swaps (e.g. innerHTML re-render) that don't change body's box.\n if (window.ResizeObserver) {\n try { var __ro = new ResizeObserver(postSize); if (document.body) __ro.observe(document.body); } catch (e) {}\n }\n if (window.MutationObserver && document.body) {\n try { new MutationObserver(postSize).observe(document.body, { childList: true, subtree: true, attributes: true, characterData: true }); } catch (e) {}\n }\n window.addEventListener('load', postSize);\n postSize();\n })();\n <\/script>")}extractWebComponentScript(e){let s=new DOMParser().parseFromString(e,"text/html").getElementById(Pn);return(s==null?void 0:s.textContent)||null}executeWebComponentScript(e,t){let i=On.get(t);if(i)return console.log("[MyopWebComponent] Script already executed for ".concat(t,", reusing <").concat(i,">")),i;let s=document.createElement("script");s.textContent=e,s.id="myop-extracted-".concat(t),document.head.appendChild(s);let a=window.__MYOP_TAG_NAME__;return a&&On.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,i,s,a){let p=this.extractWebComponentScript(s);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),c=this.executeWebComponentScript(p,d);if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");let m="myop-comp-".concat(D()),u=document.createElement(c);u.id=m,a!=null&&a.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML="");let f=new re(e,t,i,u,c,a);return this.appendChild(i,u,a),(a==null?void 0:a.data)!==void 0&&(a==null?void 0:a.data)!==null&&f.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),f}};var $n=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[i,...s]=Et(t);switch(i){case"component":{let[a,p]=s,d=await ae.Main.fetchComponent(a);if(d&&d.type.skins.find(m=>m.id===p))return d.instance.skinSelector={type:ie.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=Et(t),c=(await ae.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===ie.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(u=>u.id===p);if((m==null?void 0:m.type)===Ke.Segment){let u=m,g=c.instance.skinSelector.segments.find(l=>l.segmentId===u.segment.id);if(g)return c.instance.skinSelector=g==null?void 0:g.skinSelector,c}}}break}}}finally{return null}};var Fn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",W=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"_renderPolicy");r(this,"setRenderPolicy",n=>{this._renderPolicy=n});r(this,"getRenderPolicy",()=>this._renderPolicy);r(this,"initiated",!1);r(this,"version",et);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"isTrustedSource",n=>{if(!n||n===window)return!0;let e=t=>{let i=t.element;return(i==null?void 0:i.nodeName)==="IFRAME"&&i.contentWindow===n};return this.components.some(e)||this.components2init.some(e)});r(this,"incomingMessageHandler",n=>{var e;if((e=n.data)!=null&&e.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==S.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){let s=this.components2init.filter(p=>{let d=p.element;return(d==null?void 0:d.nodeName)==="IFRAME"&&d.contentWindow===n.source});(s.length?s:this.components2init).forEach(p=>{p.send(new te(p.id))});return}if(t.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==t.content.id);let s=this.components.find(a=>{var p;return a.id===((p=t.content)==null?void 0:p.id)});s==null||s.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let s=t,a=this.components.find(p=>p.id===s.destination);if(a){if(s.direction===S.down){s.message.messageType===O.name?a.onMessageReceived(s.message):(s.message.route=s.route,a.send(s.message));return}}else{let p=this.components.find(d=>d.id===s.message.destination);p&&p.send(s.message)}return}let i=this.components.find(s=>s.id===t.destination);if(!i){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(i){if(i.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let e=[new Je,new Ze,new ht];this.componentsLoaders=[...e],n&&this._registerLoaders(n),window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_registerLoaders",n=>{let e={};n.forEach(t=>{let i=new t(this.componentsLoaders);e[i.type]=i}),this.componentsLoaders.forEach(t=>{e[t.type]||(e[t.type]=t)}),this.componentsLoaders=Object.values(e)});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var s;async function i(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case ie.Dedicated:return((s=n.skin)==null?void 0:s.id)||n.skins[0].id;case ie.Segmented:{let p=await i(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(g=>g.type===Ke.Segment?g.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let u=c.segment,f=(t||{})[u.function];return f?await f():(console.warn("segmentId:".concat(d.segmentId,", ").concat(u.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(i=>i.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var m,u,f,g;if(!e){debugger;throw new Error("no container was found for this component")}let i=await $n(n);i&&(n=i);let s=h(h({},(m=this.loaderHooks)!=null?m:{}),(u=t==null?void 0:t.hooks)!=null?u:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,s);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(l=await t.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:ie.Dedicated,skin:l},t&&(t=h({},t),delete t.hooks),await Ft(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,s);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(l=>l.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),c.isInitiated||c.send(new te(c.id)),(!t||t.connectProps!==!1)&&(c=En(c,n.type.props,p));try{await Wt(c,n,this.components)}catch(l){throw l}return t!=null&&t.skipInit||await c.initiated(),c});r(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 i=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(i),i.show(),n.dispose(),i}else{let i=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:i}},t))}})}};r(W,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Fn});if(!window.myop.hostSDK){let o=new W;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Fn}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>Rn(n);o.stats=Pe,o.off=kn,o.refresh=Hn,window.myop.delivery=o}var So=window.myop.hostSDK;Me("hostSDK",So);var Mt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"executor",e=>{(async()=>{let i=document.querySelectorAll("[".concat(H.id,"='").concat(e.refConfig.selector,"']"));if(i.length===1){let a=await W.Instance().loadComponent(e.nestedComponentConfig,i.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new N(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new N(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Wn=(o,n)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(n),i={attributes:!0,childList:!0,subtree:!0};return t.observe(o,i),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var bt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetMutationObserverMessage);r(this,"executor",e=>{e.source&&Wn(document.body,()=>{this.messageToHost(new Te)})})}};var Kn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),i=-1;return t.forEach(s=>{if(typeof s.value=="string"){let a=s.getAttribute(H.id),p=s.getAttribute("name"),d={id:s.id,name:p,value:Kn(s),required:s.required,validity:L(s.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ct=class extends M{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{this.messageToHost(new ee(Kn(i)),e)})})}};var wt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.GetAttributeMessage);r(this,"executor",e=>{let t=wn(e.ref,document);t&&this.messageToHost(new Ee(t.getAttribute(e.name)),e)})}};var It=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetResizeObserverMessage);r(this,"executor",e=>{let t=new ResizeObserver(i=>{this.messageToHost(new De)});return t.observe(document.body),()=>{t.disconnect()}})}};var xt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{i.innerHTML=e.content})})}};var Ut=class extends fe{constructor(){super();r(this,"version",et);r(this,"messageToHost",(e,t)=>{var s,a;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let i=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=i[0]),e.source||(e.source=i[0]),e.direction=S.up,(a=(s=this.hostWindow)!=null?s:window.parent)==null||a.postMessage(h({},e),"*")});r(this,"supportedHandlers",[new qe(this.messageToHost),new xt(this.messageToHost),new Ue(this.messageToHost),new Ne(this.messageToHost),new je(this.messageToHost),new Ye(this.messageToHost),new Qe(this.messageToHost),new Ct(this.messageToHost),new bt(this.messageToHost),new It(this.messageToHost),new wt(this.messageToHost),new Mt(this.messageToHost)]);r(this,"hostWindow",window.parent);r(this,"isFromHostChain",e=>{if(!e||e===window)return!0;let t=window;for(let i=0;i<32;i++){let s=t.parent;if(!s||s===t)return!1;if(e===s)return!0;t=s}return!1});r(this,"init",()=>{window.onmessage=e=>{var t;this.isFromHostChain(e.source)&&(e.source&&e.source!==window&&((t=e.data)==null?void 0:t.messageType)===y.InitMessage&&(this.hostWindow=e.source),this.handleIncomeMessages(e))},this.messageToHost(new ne)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Me("IframeSDK",Ut);export{Ut as IframeSDK};
|
|
@@ -1010,6 +1010,7 @@ var BaseMyopComponent = class {
|
|
|
1010
1010
|
setTimeout(() => {
|
|
1011
1011
|
if (!this.isInitiated && this._whenInitiatedReject && !this._markedForDisposed) {
|
|
1012
1012
|
this._whenInitiatedReject("timeout_".concat(timeout, " ").concat(this.id));
|
|
1013
|
+
this.dispose();
|
|
1013
1014
|
}
|
|
1014
1015
|
}, timeout);
|
|
1015
1016
|
this.initiated().then(() => {
|
|
@@ -1093,19 +1094,27 @@ var BaseMyopComponent = class {
|
|
|
1093
1094
|
};
|
|
1094
1095
|
}
|
|
1095
1096
|
}
|
|
1097
|
+
/** Runs the 'onDispose' handlers once. hostSDK registers the one that unregisters
|
|
1098
|
+
* this component, so it has to run on EVERY dispose path, initiated or not. */
|
|
1099
|
+
runDisposeHandlers() {
|
|
1100
|
+
const onDisposeHandlers = this.messageHandlers["onDispose"];
|
|
1101
|
+
if (onDisposeHandlers) {
|
|
1102
|
+
onDisposeHandlers.forEach((disposeHandler) => {
|
|
1103
|
+
disposeHandler(null);
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1096
1107
|
dispose() {
|
|
1097
1108
|
this.markedForDisposed = true;
|
|
1098
1109
|
if (!this.isInitiated) {
|
|
1110
|
+
this.runDisposeHandlers();
|
|
1111
|
+
this.messageHandlers = {};
|
|
1112
|
+
this.id += "_disposed";
|
|
1099
1113
|
return;
|
|
1100
1114
|
}
|
|
1101
1115
|
console.log("disposing component", this.id);
|
|
1102
1116
|
this.send(new DisposeMessage());
|
|
1103
|
-
|
|
1104
|
-
if (onDisposeHandlers) {
|
|
1105
|
-
onDisposeHandlers.forEach((disposeHandler) => {
|
|
1106
|
-
disposeHandler(null);
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1117
|
+
this.runDisposeHandlers();
|
|
1109
1118
|
this.messageHandlers = {};
|
|
1110
1119
|
this.id += "_disposed";
|
|
1111
1120
|
this.isInitiated = false;
|
|
@@ -1181,6 +1190,67 @@ var MyopExtractedWebComponent = class extends BaseMyopComponent {
|
|
|
1181
1190
|
this._ctaQueue.push({ action: detail.action, payload: detail.payload });
|
|
1182
1191
|
}
|
|
1183
1192
|
});
|
|
1193
|
+
__publicField(this, "_autoSizeOptions");
|
|
1194
|
+
/**
|
|
1195
|
+
* Data-out for size — the extracted counterpart of the iframe implementation.
|
|
1196
|
+
*
|
|
1197
|
+
* THIS EXISTED ONLY ON MyopIframeComponent, and that was invisible for as long as
|
|
1198
|
+
* minification was sending every v2 component down the iframe path. Restoring v2
|
|
1199
|
+
* detection moves them to this class, and `@myop/react` drives both through one
|
|
1200
|
+
* wrapper: in content mode it hides its loader from the FIRST onSizeChange, so a
|
|
1201
|
+
* component whose class has no observeAutoSize leaves a React host on a loader
|
|
1202
|
+
* forever. Pic-Time's sizeMeta is width:100% with no height, which is exactly content
|
|
1203
|
+
* mode. Caught by v2-data-contract D8 (API parity).
|
|
1204
|
+
*
|
|
1205
|
+
* It REPORTS rather than imposes. An iframe has no intrinsic size and must be
|
|
1206
|
+
* measured inside and then set from outside; a custom element sizes itself from its
|
|
1207
|
+
* own content, so the honest thing is to measure it and tell the host, and let the
|
|
1208
|
+
* host decide. React then uses width:100% and the measured height.
|
|
1209
|
+
*
|
|
1210
|
+
* The one thing it does impose is `display: block` when the element computes to
|
|
1211
|
+
* `inline`, which is the default for a custom element and measures as zero height no
|
|
1212
|
+
* matter what it contains. The iframe path forces width:100% for the same reason —
|
|
1213
|
+
* without it the first measurement is 0 and the host sizes the component to nothing.
|
|
1214
|
+
*/
|
|
1215
|
+
__publicField(this, "observeAutoSize", (options) => {
|
|
1216
|
+
this._autoSizeOptions = options;
|
|
1217
|
+
const el = this.customElement;
|
|
1218
|
+
try {
|
|
1219
|
+
if (getComputedStyle(el).display === "inline") el.style.display = "block";
|
|
1220
|
+
} catch (e) {
|
|
1221
|
+
}
|
|
1222
|
+
const parse = (v) => {
|
|
1223
|
+
if (v === void 0) return void 0;
|
|
1224
|
+
if (typeof v === "number") return v;
|
|
1225
|
+
const n = parseFloat(v);
|
|
1226
|
+
return isNaN(n) ? void 0 : n;
|
|
1227
|
+
};
|
|
1228
|
+
const clamp = (v, min, max) => min !== void 0 && v < min ? min : max !== void 0 && v > max ? max : v;
|
|
1229
|
+
const report = () => {
|
|
1230
|
+
var _a;
|
|
1231
|
+
const opts = this._autoSizeOptions;
|
|
1232
|
+
const rect = el.getBoundingClientRect();
|
|
1233
|
+
const autoHeight = (opts == null ? void 0 : opts.explicitHeight) === void 0;
|
|
1234
|
+
(_a = opts == null ? void 0 : opts.onSizeChange) == null ? void 0 : _a.call(opts, {
|
|
1235
|
+
width: rect.width,
|
|
1236
|
+
height: autoHeight ? clamp(rect.height, parse(opts == null ? void 0 : opts.minHeight), parse(opts == null ? void 0 : opts.maxHeight)) : rect.height,
|
|
1237
|
+
autoSizingWidth: false,
|
|
1238
|
+
// a web component fills its container's width
|
|
1239
|
+
autoSizingHeight: autoHeight
|
|
1240
|
+
});
|
|
1241
|
+
};
|
|
1242
|
+
let ro;
|
|
1243
|
+
try {
|
|
1244
|
+
ro = new ResizeObserver(() => report());
|
|
1245
|
+
ro.observe(el);
|
|
1246
|
+
} catch (e) {
|
|
1247
|
+
}
|
|
1248
|
+
report();
|
|
1249
|
+
return () => {
|
|
1250
|
+
ro == null ? void 0 : ro.disconnect();
|
|
1251
|
+
this._autoSizeOptions = void 0;
|
|
1252
|
+
};
|
|
1253
|
+
});
|
|
1184
1254
|
__publicField(this, "cleanupInspect", () => {
|
|
1185
1255
|
});
|
|
1186
1256
|
/**
|
|
@@ -1508,8 +1578,13 @@ var createRefComponent = async (ref, componentConfig, components, options) => {
|
|
|
1508
1578
|
return new Promise(async (resolve, reject) => {
|
|
1509
1579
|
const refComponent = new MyopRefComponent(componentConfig.type, component, options);
|
|
1510
1580
|
components.push(refComponent);
|
|
1581
|
+
const unregister = () => {
|
|
1582
|
+
const at = components.indexOf(refComponent);
|
|
1583
|
+
if (at !== -1) components.splice(at, 1);
|
|
1584
|
+
};
|
|
1511
1585
|
await component.initiated();
|
|
1512
1586
|
const timeout = setTimeout(() => {
|
|
1587
|
+
unregister();
|
|
1513
1588
|
reject("timeout");
|
|
1514
1589
|
}, 5e3);
|
|
1515
1590
|
component.send(new CreateRefComponentMessage(
|
|
@@ -1522,11 +1597,13 @@ var createRefComponent = async (ref, componentConfig, components, options) => {
|
|
|
1522
1597
|
async (message) => {
|
|
1523
1598
|
clearTimeout(timeout);
|
|
1524
1599
|
if (message.failed) {
|
|
1600
|
+
unregister();
|
|
1525
1601
|
reject("CreateRefComponentMessage failed");
|
|
1526
1602
|
return;
|
|
1527
1603
|
}
|
|
1528
1604
|
const implementationComponent = components.find((c) => c.id == refComponent.id);
|
|
1529
|
-
if (implementationComponent !== refComponent) {
|
|
1605
|
+
if (implementationComponent && implementationComponent !== refComponent) {
|
|
1606
|
+
unregister();
|
|
1530
1607
|
component.refs[ref.refConfig.name] = implementationComponent;
|
|
1531
1608
|
resolve(implementationComponent);
|
|
1532
1609
|
return;
|
|
@@ -1890,7 +1967,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1890
1967
|
return cleanupHandler;
|
|
1891
1968
|
});
|
|
1892
1969
|
__publicField(this, "dispose", () => {
|
|
1893
|
-
var _a;
|
|
1970
|
+
var _a, _b;
|
|
1894
1971
|
(_a = this._bridgeSizeCleanup) == null ? void 0 : _a.call(this);
|
|
1895
1972
|
if (this._autoSizeCleanup) {
|
|
1896
1973
|
this._autoSizeCleanup();
|
|
@@ -1903,7 +1980,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1903
1980
|
if (this.cleanupInspect)
|
|
1904
1981
|
this.cleanupInspect();
|
|
1905
1982
|
super.dispose();
|
|
1906
|
-
this.IframeElement.parentNode.removeChild(this.IframeElement);
|
|
1983
|
+
(_b = this.IframeElement.parentNode) == null ? void 0 : _b.removeChild(this.IframeElement);
|
|
1907
1984
|
});
|
|
1908
1985
|
this.element = this.IframeElement;
|
|
1909
1986
|
this._lastData = options == null ? void 0 : options.data;
|
|
@@ -2170,7 +2247,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
2170
2247
|
};
|
|
2171
2248
|
|
|
2172
2249
|
// version:myop-sdk-version
|
|
2173
|
-
var myop_sdk_version_default = "0.4.0-beta.
|
|
2250
|
+
var myop_sdk_version_default = "0.4.0-beta.4";
|
|
2174
2251
|
|
|
2175
2252
|
// src/helpers/deliveryStore.ts
|
|
2176
2253
|
var DB_NAME = "myop-delivery";
|
|
@@ -3009,14 +3086,14 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3009
3086
|
if (!isolate) {
|
|
3010
3087
|
doc.writeln("".concat(sdkScript).concat(initScript));
|
|
3011
3088
|
}
|
|
3012
|
-
if (!isolate && (options == null ? void 0 : options.data) !== void 0) {
|
|
3089
|
+
if (!isolate && (options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null) {
|
|
3013
3090
|
const ctaQueueScript = "<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>";
|
|
3014
3091
|
const escapedData = JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script");
|
|
3015
3092
|
const dataScript = '<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(escapedData, ";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");
|
|
3016
3093
|
doc.writeln(ctaQueueScript + dataScript);
|
|
3017
3094
|
}
|
|
3018
3095
|
if (isolate) {
|
|
3019
|
-
const escapedData = (options == null ? void 0 : options.data) !== void 0 ? JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script") : "undefined";
|
|
3096
|
+
const escapedData = (options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null ? JSON.stringify(options.data).replace(/<\/script/gi, "\\u003c/script") : "undefined";
|
|
3020
3097
|
doc.writeln(this.buildIsolationBridge(escapedData));
|
|
3021
3098
|
}
|
|
3022
3099
|
doc.close();
|
|
@@ -3071,10 +3148,29 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3071
3148
|
});
|
|
3072
3149
|
}
|
|
3073
3150
|
/**
|
|
3074
|
-
* Detect if HTML is a Myop Web Component
|
|
3151
|
+
* Detect if HTML is a Myop Web Component.
|
|
3152
|
+
*
|
|
3153
|
+
* THE MARKER COMMENT ALONE IS NOT A SAFE SIGNAL, BECAUSE MINIFIERS DELETE COMMENTS.
|
|
3154
|
+
*
|
|
3155
|
+
* This used to be `startsWith(MYOP_WEB_COMPONENT_MARKER)` and nothing else. The
|
|
3156
|
+
* delivery lane minifies with `removeComments: true` (myop-server derive.ts MIN_CFG),
|
|
3157
|
+
* so the stored `min` artifact of every v2 web component loses its leading
|
|
3158
|
+
* `<!-- myop-web-component -->`. Detection then returned false, the component fell
|
|
3159
|
+
* back to plain iframe rendering, and the whole authored document was shown --
|
|
3160
|
+
* including the v2 authoring wrapper, so Pic-Time's production dashboard displayed the
|
|
3161
|
+
* preview chrome ("Web Component v2", a tag-name badge reading `loading...`, SIZE /
|
|
3162
|
+
* OVERFLOW / BG controls) instead of their component. Reported 2026-10-18; the served
|
|
3163
|
+
* HTML measured 328,071 bytes against 951,130 at origin, with zero `<!--` left in it.
|
|
3164
|
+
*
|
|
3165
|
+
* The script id is the signal that survives, and it is the one `extractWebComponentScript`
|
|
3166
|
+
* already depends on: if that element is present, extraction works, so detection
|
|
3167
|
+
* should agree. Checked with a regex rather than DOMParser -- this runs for every
|
|
3168
|
+
* HTML component, and parsing a 300 KB document to answer a yes/no question is not
|
|
3169
|
+
* worth it.
|
|
3075
3170
|
*/
|
|
3076
3171
|
isMyopWebComponent(html) {
|
|
3077
|
-
|
|
3172
|
+
if (html.trimStart().startsWith(MYOP_WEB_COMPONENT_MARKER)) return true;
|
|
3173
|
+
return new RegExp("<script[^>]*\\sid=[\"']?".concat(MYOP_WEB_COMPONENT_SCRIPT_ID, "[\"'\\s>]"), "i").test(html);
|
|
3078
3174
|
}
|
|
3079
3175
|
/**
|
|
3080
3176
|
* Resolve how this component should render, applying the host render policy.
|
|
@@ -3169,7 +3265,6 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3169
3265
|
if (!container.querySelector('[id^="myop-comp-"]')) {
|
|
3170
3266
|
container.innerHTML = "";
|
|
3171
3267
|
}
|
|
3172
|
-
this.appendChild(container, element, options);
|
|
3173
3268
|
const component = new MyopExtractedWebComponent(
|
|
3174
3269
|
componentDefinition,
|
|
3175
3270
|
skin,
|
|
@@ -3178,7 +3273,8 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
3178
3273
|
tagName,
|
|
3179
3274
|
options
|
|
3180
3275
|
);
|
|
3181
|
-
|
|
3276
|
+
this.appendChild(container, element, options);
|
|
3277
|
+
if ((options == null ? void 0 : options.data) !== void 0 && (options == null ? void 0 : options.data) !== null) {
|
|
3182
3278
|
component.initWithData(options.data);
|
|
3183
3279
|
}
|
|
3184
3280
|
console.log("[MyopWebComponent] Loaded <".concat(tagName, "> into container"));
|
|
@@ -3303,7 +3399,12 @@ var HostSDK = class {
|
|
|
3303
3399
|
}
|
|
3304
3400
|
const myopMessage = event.data;
|
|
3305
3401
|
if (myopMessage.messageType === MyopMessages.InitRequest) {
|
|
3306
|
-
this.components2init.
|
|
3402
|
+
const fromAskingFrame = this.components2init.filter((component2) => {
|
|
3403
|
+
const element = component2.element;
|
|
3404
|
+
return (element == null ? void 0 : element.nodeName) === "IFRAME" && element.contentWindow === event.source;
|
|
3405
|
+
});
|
|
3406
|
+
const targets = fromAskingFrame.length ? fromAskingFrame : this.components2init;
|
|
3407
|
+
targets.forEach((component2) => {
|
|
3307
3408
|
component2.send(new InitMessage(component2.id));
|
|
3308
3409
|
});
|
|
3309
3410
|
return;
|
|
@@ -3520,7 +3621,6 @@ var HostSDK = class {
|
|
|
3520
3621
|
let component = await componentLoader.load(componentConfig.type, selectedSkin, container, options);
|
|
3521
3622
|
if (!component.isInitiated) {
|
|
3522
3623
|
this.components2init.push(component);
|
|
3523
|
-
component.send(new InitMessage(component.id));
|
|
3524
3624
|
}
|
|
3525
3625
|
component.bind("onDispose", () => {
|
|
3526
3626
|
this.components = this.components.filter((c) => c !== component);
|
|
@@ -3528,6 +3628,9 @@ var HostSDK = class {
|
|
|
3528
3628
|
return true;
|
|
3529
3629
|
});
|
|
3530
3630
|
this.components.push(component);
|
|
3631
|
+
if (!component.isInitiated) {
|
|
3632
|
+
component.send(new InitMessage(component.id));
|
|
3633
|
+
}
|
|
3531
3634
|
if (!options || options.connectProps !== false) {
|
|
3532
3635
|
component = connectProps(component, componentConfig.type.props, selectedSkin);
|
|
3533
3636
|
}
|