@myop/sdk 0.4.0-beta.5 → 0.4.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +13 -0
  2. package/dist/bundled-declarations.d.ts +87 -4
  3. package/dist/cjs/{_IframeSDK.ac4c28cf.js → _IframeSDK.49662e01.js} +97 -18
  4. package/dist/cjs/_IframeSDK.49662e01.js.map +7 -0
  5. package/dist/cjs/_IframeSDK.d4a97876.min.js +1 -0
  6. package/dist/cjs/_MyopHelpers.12acc780.min.js +1 -0
  7. package/dist/cjs/{_MyopHelpers.efed13e4.js → _MyopHelpers.2c449e7a.js} +78 -15
  8. package/dist/cjs/_MyopHelpers.2c449e7a.js.map +7 -0
  9. package/dist/cjs/_WebComponentSDK.1addf28b.min.js +1 -0
  10. package/dist/cjs/{_WebComponentSDK.4085389a.js → _WebComponentSDK.d5f9105b.js} +97 -18
  11. package/dist/cjs/_WebComponentSDK.d5f9105b.js.map +7 -0
  12. package/dist/cjs/_hostSDK.6dab59cb.min.js +1 -0
  13. package/dist/cjs/{_hostSDK.46b85afc.js → _hostSDK.8cf37510.js} +97 -18
  14. package/dist/cjs/_hostSDK.8cf37510.js.map +7 -0
  15. package/dist/cjs/myop_sdk.js +14 -14
  16. package/dist/cjs/myop_sdk.js.map +1 -1
  17. package/dist/cjs/myop_sdk.min.js +1 -1
  18. package/dist/cjs-bundled/myop_sdk.bundled.js +107 -21
  19. package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
  20. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  21. package/dist/module/Iframe/index.js +98 -19
  22. package/dist/module/Iframe/index.js.map +2 -2
  23. package/dist/module/SDK.js +107 -21
  24. package/dist/module/SDK.js.map +3 -3
  25. package/dist/module/common/index.d.ts +5 -0
  26. package/dist/module/common/index.js +1 -1
  27. package/dist/module/common/index.js.map +2 -2
  28. package/dist/module/embeddedSDK.js +1 -1
  29. package/dist/module/helpers/CloudRepository.d.ts +36 -1
  30. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +42 -2
  31. package/dist/module/helpers/index.js +77 -16
  32. package/dist/module/helpers/index.js.map +2 -2
  33. package/dist/module/host/components/IMyopComponent.d.ts +3 -0
  34. package/dist/module/host/embeddedSDK.js +1 -1
  35. package/dist/module/host/hostSDK.d.ts +1 -1
  36. package/dist/module/host/index.js +98 -19
  37. package/dist/module/host/index.js.map +2 -2
  38. package/dist/module/webcomponent/index.js +98 -19
  39. package/dist/module/webcomponent/index.js.map +2 -2
  40. package/package.json +1 -1
  41. package/dist/cjs/_IframeSDK.47f37ec9.min.js +0 -1
  42. package/dist/cjs/_IframeSDK.ac4c28cf.js.map +0 -7
  43. package/dist/cjs/_MyopHelpers.91004b19.min.js +0 -1
  44. package/dist/cjs/_MyopHelpers.efed13e4.js.map +0 -7
  45. package/dist/cjs/_WebComponentSDK.4085389a.js.map +0 -7
  46. package/dist/cjs/_WebComponentSDK.4ca43f0a.min.js +0 -1
  47. package/dist/cjs/_hostSDK.0443afcd.min.js +0 -1
  48. package/dist/cjs/_hostSDK.46b85afc.js.map +0 -7
@@ -0,0 +1 @@
1
+ var jt=Object.defineProperty,$n=Object.defineProperties;var An=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Fn=Object.prototype.hasOwnProperty,Wn=Object.prototype.propertyIsEnumerable;var at=(o,n,e)=>n in o?jt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Fn.call(n,e)&&at(o,e,n[e]);if(qt)for(var e of qt(n))Wn.call(n,e)&&at(o,e,n[e]);return o},L=(o,n)=>$n(o,An(n));var Kn=(o,n)=>{for(var e in n)jt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>at(o,typeof n!="symbol"?n+"":n,e);var Be="__federation__",Gt="onLoad";var Le=(o,n)=>{window[Be]&&window[Be][o]&&window[Be][o][Gt]&&window[Be][o][Gt]({[o]:n})};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 Pe={};Kn(Pe,{AddEventListenerMessage:()=>mt,BaseMyopMessage:()=>M,BindClickMessage:()=>ct,ChangeTextMessage:()=>lt,CleanupMessage:()=>we,CleanupReplayMessage:()=>Ie,ClickReplayMessage:()=>me,CreateRefComponentMessage:()=>Me,CustomRefMessage:()=>G,DetectMyopRefsMessage:()=>yt,DetectedMyopRefsMessage:()=>be,DisposeMessage:()=>ve,ElementValueReplayMessage:()=>ge,EnvelopedMessage:()=>Ce,EventListenerCallbackMessage:()=>fe,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>ue,GetAttributeMessage:()=>ht,GetAttributeReplayMessage:()=>Mt,GetElementValueMessage:()=>ft,InitMessage:()=>Y,InitRequest:()=>he,InitResponse:()=>ye,MessageDirection:()=>E,MutationObserverMessage:()=>bt,MyopBindMessage:()=>v,MyopBindReplayMessage:()=>I,MyopElementMessage:()=>pt,Ref:()=>U,RefComponentCreatedMessage:()=>ie,ResizeObserverMessage:()=>wt,SetAttributeMessage:()=>ut,SetInnerHtml:()=>gt,SetMutationObserverMessage:()=>Ct,SetResizeObserverMessage:()=>Se,stripFunction:()=>Xt});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Nn=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 Un=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 dt=o=>{let n=Un(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(Nn(n.slice(t,t+16)));return e};var Yt=o=>new Promise(n=>setTimeout(n,o));var E=class{};r(E,"down","down"),r(E,"up","up");var M=class{constructor(){r(this,"id",R());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}},pt=class extends M{constructor(e){super();this.ref=e}},I=class extends M{constructor(e){super();this.replayToHandler=e}},v=class extends M{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",R())}},U=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=L(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 Qt="ClickReplayMessage",ct=class extends v{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Qt);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},me=class extends I{constructor(){super(...arguments);r(this,"messageType",Qt)}};var lt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Jt="ExecuteScriptReplyMessage",Vn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,qn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xt=o=>{let n=o.match(Vn);if(n)return n[1]||n[3];{let e=o.match(qn);if(e)return e[1].trim()}},k=class extends v{constructor(e,t=()=>{},i){super(t);this.scriptInputs=i;r(this,"replyMessageKey",Jt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Xt(this.content)}};r(k,"replierKey","send"),r(k,"completeStreamKey","completeStream");var ue=class extends I{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Jt)}};var G=class extends k{constructor(e,t,i=()=>{}){super(({rootRef:s,elementId:a,_script:d,__scriptInputs:p})=>{let c=(s.shadowRoot||s.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(p.ref=c[0],new Function("return (".concat(d,")(...arguments)"))(p)):null},i);this.scriptInputs=t;this.scriptInputs=L(h({},t),{_script:e.toString()})}};var Zt="EventListenerCallbackMessage",mt=class extends v{constructor(e,t,i){super(i);this.ref=e;this.type=t;this.handler=i;r(this,"replyMessageKey",Zt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},fe=class extends I{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Zt);this.content={e:t}}};var ut=class extends M{constructor(e,t,i){super();this.ref=e;this.name=t;this.value=i;r(this,"messageType","SetAttributeMessage")}};var en="ElementValueReplayMessage",ft=class extends v{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",en);r(this,"messageType","GetElementValueMessage")}},ge=class extends I{constructor(e){super();this.content=e;r(this,"messageType",en)}};var gt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var Y=class extends M{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ye=class extends Y{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},he=class extends M{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var tn="RefComponentCreatedMessage",Me=class extends v{constructor(e,t,i,s){super(s);this.refConfig=e;this.nestedComponentConfig=t;this.options=i;r(this,"replyMessageKey",tn);r(this,"messageType","CreateRefComponentMessage")}},ie=class extends I{constructor(e,t,i){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=i;r(this,"messageType",tn)}};var Ce=class extends M{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 nn="DetectedMyopRefsMessage",yt=class extends v{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",nn)}},be=class extends I{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",nn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var on="GetAttributeReplayMessage",ht=class extends v{constructor(e,t,i){super(i);this.ref=e;this.name=t;r(this,"replyMessageKey",on);r(this,"messageType","GetAttributeMessage")}},Mt=class extends I{constructor(e){super();this.content=e;r(this,"messageType",on)}};var D=class extends M{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ct=class extends M{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},bt=class extends M{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var sn="CleanupReplayMessage",we=class extends v{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",sn);r(this,"messageType","CleanupMessage")}},Ie=class extends I{constructor(e){super();this.customCleanup=e;r(this,"messageType",sn)}};var ve=class extends M{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var Se=class extends M{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},wt=class extends M{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var z=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)||V.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 uiTags(){var n;return((n=this.componentDefinition)==null?void 0:n.uiTags)||[]}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=E.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=E.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 we(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 ve),this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Oe=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 rn=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},It=class{constructor(n){this.messageToHost=n}},ze=class extends It{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var vt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},$e=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!==E.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 vt(i),this.messageToHost(new ye(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(p=>p.id===s.destination);if(a){a.send(s);return}let d=myop.hostSDK.components.find(p=>p.id===i.destination);if(d){d.send(s);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let s=t,a=this.messageCleanupCache[s.cleanupForMessageId],d=new Ie(!!a);d.destination=t.destination,a?(delete this.messageCleanupCache[s.cleanupForMessageId],rn(a).then(()=>{this.messageToHost(d,s)}).catch(()=>{})):this.messageToHost(d,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 A={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var Q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ae={message:"message",code:"code"},re=class{};r(re,"code","code"),r(re,"component","component");var J={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Fe={Segment:"Segment",Promo:"Promo",AB:"AB"},Ae=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 St=o=>o!==Object(o),jn=o=>typeof o=="function",xt=o=>{if(St(o))return!0;if(jn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!xt(e))return!1}else{if(St(e))continue;return!1}}return!0},F=(o,n={},e=!0,t=new WeakMap)=>{if(St(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]=F(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]=F(o[s],!0,e,t)):typeof a=="object"&&(i[s]=F(o[s],a,e,t)))}return i}return{}};var an={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 xe=class extends z{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 Ce(this.id,e)),e.handler=t,i});r(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var X=class extends z{constructor(e,t,i,s,a,d){super(e,i,d);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(p){}let i=p=>{if(p===void 0)return;if(typeof p=="number")return p;let c=parseFloat(p);return isNaN(c)?void 0:c},s=(p,c,m)=>c!==void 0&&p<c?c:m!==void 0&&p>m?m:p,a=()=>{var u;let p=this._autoSizeOptions,c=t.getBoundingClientRect(),m=(p==null?void 0:p.explicitHeight)===void 0;(u=p==null?void 0:p.onSizeChange)==null||u.call(p,{width:c.width,height:m?s(c.height,i(p==null?void 0:p.minHeight),i(p==null?void 0:p.maxHeight)):c.height,autoSizingWidth:!1,autoSizingHeight:m})},d;try{d=new ResizeObserver(()=>a()),d.observe(t)}catch(p){}return a(),()=>{d==null||d.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=de(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 Gn=(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},de=(o,n,e,t,i,s)=>{let a=Gn("".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)}},dn=(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),pn=(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."))},cn=(o,n,e)=>{let t=n.reduce((s,a)=>L(h({},s),{[a.name]:h({},a)}),{}),i={get:(s,a)=>{let d=t[a];if(dn(d,a,o))return!1;if(d.behavior.type===ae.code){if(o instanceof X)return(d.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(o instanceof W&&o.isolated)return(d.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Q.localFrame){let c=d.behavior;return o.element.contentWindow[c.remap||a]}return pn(d,a,o),!1}return d.mode==="output"?new Promise(p=>{let c=[];d.behavior.ref&&c.push(U.create(d.behavior.ref)),c.push(u=>{p(u)}),d.behavior.params&&c.push(...d.behavior.params);let m=Pe[d.behavior.message];o.send(new m(...c))}):null},set:(s,a,d)=>{let p=t[a];if(dn(p,a,o))return!1;if(p.behavior.type===ae.code){if(o instanceof X){let m=p.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(d),!0;if(m==="myop_init_interface")return o.initWithData(d),!0}if(o instanceof W&&o.isolated){let m=p.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(d),!0;if(m==="myop_init_interface")return o.initWithData(d),!0}if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Q.localFrame){let m=p.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=d,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.forEach(l=>{o.markedForDisposed||d(l.action,l.payload)})}return!0}return pn(p,a,o),!1}else if(p.mode==="input")if(p.behavior.type==="message"){let c=[];p.behavior.ref&&c.push(U.create(p.behavior.ref)),c.push(d),p.behavior.params&&c.push(...p.behavior.params);let m=Pe[p.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(p.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,i),o},Yn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...s)=>new Promise(a=>{s.forEach(d=>{xt(d)||an.notSerializableRefCall(t,d)}),n.send(new G(({ref:d,propName:p,functionArgs:c,makeSerializable:m})=>{if(d){let u=d[p];return m(typeof u=="function"?d[p](...c):u,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:s},d=>{a(d.content)}))})},set(e,t,i){return n.send(new G(({ref:s,propName:a,propValue:d})=>{s&&(s[a]=d)},{elementId:e.refConfig.selector,propValue:i,propName:t},s=>{})),!0}}),_t=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 d=new xe(n.type,i,t);e.push(d);let p=()=>{let m=e.indexOf(d);m!==-1&&e.splice(m,1)};await i.initiated();let c=setTimeout(()=>{p(),a("timeout")},5e3);i.send(new Me(o.refConfig,n,L(h({},t||{}),{id:d.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){p(),a("CreateRefComponentMessage failed");return}let u=e.find(f=>f.id==d.id);if(u&&u!==d){p(),i.refs[o.refConfig.name]=u,s(u);return}else d.setInitiated(),i.refs[o.refConfig.name]=d;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(_=>_.type.id===f.componentDefinitionId).type,l=new xe(g,d);l.setInitiated(),d.refs[f.refName]=l,e.push(l)});try{await Et(d,n,e,!0),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),s(d)}catch(f){a(f)}}))})},Et=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let i=Object.values(o.componentDefinition.refs).map(s=>new Promise(async(a,d)=>{var p;if(s.behavior.type==re.component){if(t){a();return}let c=s.behavior.componentId;c||(c=s.behavior.instance.componentId);let m=(p=n.instance.resolvedNestedComponents)==null?void 0:p.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=U.create("",s,o);try{let f=await _t(u,m,e);o.refs[s.name]=f,a()}catch(f){d(f)}}else try{let c=U.create("",s,o);o.refs[s.name]=Yn(c,o),a()}catch(c){}}));try{await Promise.all(i)}catch(s){throw s}};var W=class extends z{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 k(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:t})=>{let{height:i,width:s}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:d,width:p}=document.documentElement.getBoundingClientRect();t({height:d,width:p})});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,_)=>l!==void 0&&g<l?l:_!==void 0&&g>_?_:g,a=g=>{if(g===void 0)return;if(typeof g=="number")return g;let l=parseFloat(g);return isNaN(l)?void 0:l},d=()=>{var Ot,zt,$t,At,Ft,Wt,Kt,Nt;let g=t.contentDocument;if(!g)return;let l=this._autoSizeOptions,_=a(l==null?void 0:l.minWidth),T=a(l==null?void 0:l.maxWidth),N=a(l==null?void 0:l.minHeight),S=a(l==null?void 0:l.maxHeight),ee=(Ot=l==null?void 0:l.loaderMinHeight)!=null?Ot:50,j=((zt=this.sizeMeta)==null?void 0:zt.width)==="100%"?"100%":void 0,H=(($t=this.sizeMeta)==null?void 0:$t.height)==="100%"?"100%":void 0,b=(Ft=(At=l==null?void 0:l.explicitWidth)!=null?At:j)!=null?Ft:"100%",C=(Wt=l==null?void 0:l.explicitHeight)!=null?Wt:H,x=b!==void 0,te=C!==void 0,ne=this.container.getBoundingClientRect(),Tn=ne.width===0,Rn=ne.height===0||ne.height===ee,oe=(l!=null&&l.forceAutoSize||Tn)&&!x,se=(l!=null&&l.forceAutoSize||Rn)&&!te;if(!oe&&!se){t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(Kt=l==null?void 0:l.onSizeChange)==null||Kt.call(l,{width:typeof b=="number"?b:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let kn=t.style.transition,$=this.container,Hn=$.style.transition;t.style.transition="none",$.style.transition="none";let kt=t.getBoundingClientRect().height,Ht=t.getBoundingClientRect().width,Dt=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),Bt=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),ce=Bt,le=Dt,Dn=se&&Dt>kt+1,Bn=oe&&Bt>Ht+1,ke=se&&!Dn,He=oe&&!Bn;if(ke||He){let On=$.style.minHeight,zn=$.style.minWidth;ke&&($.style.minHeight="".concat(kt,"px")),He&&($.style.minWidth="".concat(Ht,"px")),ke&&(t.style.height="0px"),He&&(t.style.width="0px"),ce=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height));let Ut=ke&&le<2,Vt=He&&ce<2;if(Ut||Vt){let De=g.createElement("style");De.id="__myop_measure";let rt=[];Ut&&rt.push("height: auto !important","min-height: 0 !important","max-height: none !important"),Vt&&rt.push("width: auto !important","min-width: 0 !important","max-width: none !important"),De.textContent="*, *::before, *::after { ".concat(rt.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),g.head.appendChild(De),ce=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),De.remove()}$.style.minHeight=On,$.style.minWidth=zn}let Lt=s(ce,_,T),Pt=s(le,N,S);oe?t.style.width="".concat(Lt,"px"):t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",se?t.style.height="".concat(Pt,"px"):t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",t.offsetHeight,t.style.transition=kn,$.style.transition=Hn;let Ln=oe&&T!==void 0&&ce>T,Pn=se&&S!==void 0&&le>S;g.documentElement.style.overflowX=Ln?"auto":"",g.documentElement.style.overflowY=Pn?"auto":"",(Nt=l==null?void 0:l.onSizeChange)==null||Nt.call(l,{width:Lt,height:Pt,autoSizingWidth:oe,autoSizingHeight:se})};d(),this._autoSizeUpdate=d;let p,c=()=>{p===void 0&&(p=requestAnimationFrame(()=>{p=void 0,d()}))},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(),p!==void 0&&(cancelAnimationFrame(p),p=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 Se))}).catch(s=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(s))}),i});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new k(()=>{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 k(()=>{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=E.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),d=s(i==null?void 0:i.maxHeight),p=e;a!==void 0&&p<a&&(p=a),d!==void 0&&p>d&&(p=d),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=p+"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:p,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=de(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 q=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 Qn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Jn=(o,n)=>{let e=o.getAttribute("src");if(!e||!n)return!1;let t=i=>{let s=new URL(i,document.baseURI);return s.hash="",s.pathname.length>1&&(s.pathname=s.pathname.replace(/\/$/,"")),s.href};try{return t(e)===t(n)}catch(i){return!1}},We=class extends q{constructor(){super(...arguments);r(this,"type",A.IframeLoader);r(this,"load",async(e,t,i,s)=>{let a,d=t.loader;if((i==null?void 0:i.nodeName)==="IFRAME")a=i,Jn(a,d.url)||(a.src=d.url);else{let c=R(),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(d.autoHeight||!d.height?"100%":d.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=Qn(f,"_myop-comp",c)),a.src=f,i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),a=this.appendChild(i,a,s)}let p=new W(e,t,i,a,s);return d.autoHeight&&(s==null?void 0:s.autoSize)!==!1&&p.observeHeightViaBridge(),p})}};var Ke={webcomponent_message_key:"myop_webcomponent_message"};var pe=class extends z{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(Ke.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=de(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 Tt={},Ne=class extends q{constructor(){super(...arguments);r(this,"type",A.WebComponentLoader);r(this,"load",async(e,t,i,s)=>{let a=t.loader;Tt[a.url]?console.log("Module alreday loaded or in loading process"):Tt[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 Tt[a.url],await Yt(1);let d="myop-comp-".concat(R()),p=document.createElement(a.tag);return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),p.id=d,s!=null&&s.hidden&&(p.style.opacity="0",p.style.position="absolute",p.style.height="0",p.style.width="0",p.style.pointerEvents="none",p.style.visibility="hidden"),s!=null&&s._environment&&(p._myopEnvironment=s==null?void 0:s._environment),this.appendChild(i,p,s),new pe(e,t,i,p,s)})}};var ln="0.4.0-beta.6";var Xn="myop-delivery",qe="components";var Ue=null;function Zn(){return Ue||(Ue=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(Xn,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(qe)||e.createObjectStore(qe,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),Ue)}function Ve(o,n){return Zn().then(e=>new Promise(t=>{if(!e)return t(null);try{let i=e.transaction(qe,o),s=n(i.objectStore(qe));s.onsuccess=()=>t(s.result),s.onerror=()=>t(null),i.onabort=()=>t(null)}catch(i){t(null)}}))}var Rt="myop.d.";function mn(o,n,e){try{localStorage.setItem(Rt+o,JSON.stringify({t:n,e}))}catch(t){}}function eo(o){try{localStorage.removeItem(Rt+o)}catch(n){}}var _e=new Map,P={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=_e.get(o);if(n)return n;let e=await Ve("readonly",t=>t.get(o));return e&&(_e.set(o,e),mn(o,e.tag,e.storedAt+e.windowMs)),e},async put(o){_e.set(o.key,o),mn(o.key,o.tag,o.storedAt+o.windowMs),await Ve("readwrite",n=>n.put(o))},async drop(o){_e.delete(o),eo(o),await Ve("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(){_e.clear();try{for(let o=localStorage.length-1;o>=0;o--){let n=localStorage.key(o);n&&n.startsWith(Rt)&&localStorage.removeItem(n)}}catch(o){}await Ve("readwrite",o=>o.clear())}};var un=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:ae.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:ae.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0,uiTags:Array.isArray(o.uiTags)?o.uiTags:[]},name:o.name}),je="__MYOP_CLOUD_REPOSITORY_MAIN__",to=()=>{if(typeof window<"u")return window[je];if(typeof globalThis<"u")return globalThis[je]},no=o=>{typeof window<"u"&&(window[je]=o),typeof globalThis<"u"&&(globalThis[je]=o)},O=class O{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,flow:!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);r(this,"_hydratedV1",new Set)}static get Main(){let n=to();return n||(O._main||(O._main=new O,no(O._main)),O._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(d){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),n.flow!==void 0&&(this._delivery.flow=!!n.flow)}deliveryStats(){var n;return L(h({},this._deliveryStats),{host:(n=this._delivery.host)!=null?n:O.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache,flow:this._delivery.flow})}async refreshDelivery(){await P.clear()}noteLocalServe(n,e,t){let i=t?"".concat(n,":").concat(t):n,s=this._localServes.get(i);s?s.count++:this._localServes.set(i,{id:n,env:e,count:1,source:t}),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])=>"".concat(e.id,":").concat(e.env,":").concat(e.count).concat(e.source?":"+e.source:"")).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(d,p)=>{try{let c;if(this._staticMode){let N=s?"preview":i;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(N,".json");let S=new URLSearchParams(this._queryParams).toString();S&&(c+="?".concat(S))}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?P.key(this.deliveryHost(),n,i,s,this._delivery.minify?"min":"raw"):"",f=m?await P.get(u):null;if(f&&P.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,i),this.variants[a].resolved=f.config,d(f.config);return}if(f&&f.tag){let N="/consume?ids=".concat(n,"&env=").concat(i)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let S=await this.deliveryFetch(N);if(S.ok){let ee=await S.json();if((ee.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=O.sizeOfHeld(f),f.storedAt=Date.now(),f.windowMs=P.windowFrom(S.headers)||f.windowMs,await P.put(f),this.variants[a].resolved=f.config,d(f.config);return}let j=(ee.items||[])[0];if(j){let H=un(j);this._deliveryStats.fromNetwork++,await P.put({key:u,config:H,tag:j.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(S.headers),host:this.deliveryHost()}),this.variants[a].resolved=H,d(H);return}}}catch(S){}}let g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){p(new Error('Failed to load component "'.concat(n,'" (').concat(g.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let _=(await g.json()).item;if(!_){p(new Error('Component "'.concat(n,'" not found')));return}if(!_.consume_variant||!_.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(i,'"')));return}let T=un(_);this._deliveryStats.fromNetwork++,m&&await P.put({key:u,config:T,tag:_.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(g.headers),host:this.deliveryHost()}),this.variants[a].resolved=T,d(T)}catch(c){delete this.variants[a],p(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}getComponentTags(n,e,t){var i,s;return((s=(i=this.getResolvedConfig(n,e,t))==null?void 0:i.type)==null?void 0:s.uiTags)||[]}resolveParams(n,e,t){let i=this.preloadedComponents[n],s=e!==void 0||t!==void 0,a,d;if(!s&&i)a=i.env,d=i.preview;else{a=e||this._defaultEnv;let p=e||this._envExplicitlySet;d=t===!0?!0:t===!1?!1:!p}return{env:a,usePreview:d,cacheKey:"".concat(n,":").concat(a,":").concat(d?"preview":"live")}}hydrateComponent(n,e,t,i){let{env:s,usePreview:a,cacheKey:d}=this.resolveParams(n,t,i),p=Promise.resolve(e);p.resolved=e,this.variants[d]=p,this.preloadedComponents[n]={env:s,preview:a}}hydrateV1Component(n,e){var i,s;let t=(i=e==null?void 0:e.item)!=null?i:e;if(!((s=t==null?void 0:t.components)!=null&&s.length))throw new Error("hydrateV1Component(".concat(n,"): not a /flow?auto=true response"));this.userFlows[n]=Promise.resolve(t),this._hydratedV1.add(n)}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._hydratedV1.delete(n)&&this.noteLocalServe(n,"v1_auto_flow","h"),this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i="/flow?id=".concat(n,"&auto=true"),a=await(this._delivery.flow&&this._delivery.host?await this.deliveryFetch(i):await fetch("".concat(this._baseUrl).concat(i))).json();e(a.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(O,"_main",null),r(O,"DEFAULT_HOST","https://cloud.myop.dev");var Z=O;var Ee=Z.Main;var oo="https://delivery.myop.dev",fn=(o={})=>{var e,t,i;let n=o.minify!==!1||o.cache===!0||o.flow===!0;return Ee.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,flow:(i=o.flow)!=null?i:!1,host:o.host!==void 0?o.host:n?oo:null}),Te()},gn=async()=>(await Ee.refreshDelivery(),Te()),Te=()=>Ee.deliveryStats(),yn=()=>(Ee.setDelivery({minify:!1,cache:!1,flow:!1,host:null}),Te());var hn=o=>{for(let[n,e]of Object.entries(o))Ee.hydrateV1Component(n,e)};var w=class extends ze{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(L(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 K={id:"myop-id"};var B=(o,n)=>n.querySelectorAll("[".concat(K.id,"='").concat(o.refConfig.selector,"']"));var Ge=class extends w{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,i)=>{let s=B(e.ref,t.shadowRoot),a=[];return s.forEach(d=>{let p=()=>{i(new me(e.handlerUniqueId))};d.addEventListener("click",p),a.push(()=>{d.removeEventListener("click",p)})}),()=>{a.forEach(d=>d())}})}};var Ye=class extends w{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(s=>{s.textContent=e.content})})}};var Qe=class extends Ae{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Je=class extends w{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let i=t.shadowRoot.querySelectorAll("[".concat(K.id,"]")),s=[];i.forEach(a=>{let d=a.getAttribute(K.id);d&&s.push(new Oe(d,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new be(e.handlerUniqueId,s))});r(this,"messageType",y.DetectMyopRefsMessage)}};var Xe=class extends w{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(s=>{s.setAttribute(e.name,e.value)})})}};var Ze=class extends w{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,i)=>{let s=B(e.ref,t.shadowRoot),a=[];return s.forEach(d=>{let p=c=>{i(new fe(e.handlerUniqueId,F(c,e.serializableSkeleton)))};d.addEventListener(e.type,p),a.push(()=>{d.removeEventListener(e.type,p)})}),()=>{a.forEach(d=>d())}})}};var et=class extends w{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,i)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(K.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let d=V.Instance(),p=d.components.find(f=>f.id===e.options.id);p&&p.dispose();let c=d.components.indexOf(p);c!==-1&&d.components.splice(c,1);let m=await d.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 ie(e.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new ie(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Mn=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=F,t.send=n,t.rootRef=e,t.__scriptInputs=t;let s=new Function("return (".concat(o.script,")(...arguments)"))(t);n(s)};var tt=class extends w{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,i)=>{Mn(e,a=>{i(new ue(e.handlerUniqueId,a))},t)})}};var Cn=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(K.id),d=s.getAttribute("name"),p={id:s.id,name:d,value:Cn(s),required:s.required,validity:F(s.validity,!0),myopId:a};d?e.formData[d]?e.formData[d].value?e.unmappedData.push(p):(e.unmappedData.push(e.formData[d]),e.formData[d]=p):e.formData[d]=p:e.unmappedData.push(p)}}),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},nt=class extends w{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,i)=>{B(e.ref,t.shadowRoot).forEach(a=>{i(new ge(Cn(a)),e)})})}};var ot=class extends w{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(s=>{s.innerHTML=e.content})})}};var Re=class extends $e{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Ke.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 d=a.content.id;this.components[d].context=new Qe(e,t)}}}),setTimeout(()=>{this.messageToHost(new he)},1)});r(this,"messageToHost",(e,t)=>{e.direction=E.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Ye(this.messageToHost,this.components),new ot(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new Je(this.messageToHost,this.components),new Xe(this.messageToHost,this.components),new Ze(this.messageToHost,this.components),new tt(this.messageToHost,this.components),new nt(this.messageToHost,this.components),new et(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Le("WebComponentSDK",Re);var bn="";var so="<!-- myop-web-component -->",In="myop-web-component",vn=new Map,Sn=[],st,xn=async()=>(st||(st=new Re,st.init()),st);function io(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Q.open?"open":"closed",t=this.attachShadow({mode:e});xn().then(i=>{i.connectedCallback(this,t),t.innerHTML=o})}}}var ro=(o,n,e)=>{customElements.define(o,io(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},ao=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),po=o=>(o=ao(o),o.replace(/_/g,"-"));var it=class extends q{constructor(){super(...arguments);r(this,"type",A.HTMLLoader);r(this,"load",async(e,t,i,s)=>{let a=t.loader,d=this.isMyopWebComponent(a.HTML),{mode:p,isolate:c}=await this.resolveRenderMode(e,t,a,d,s);if(p===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(e.id,'"'));if(d){if(p!=="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(R()),u;if(a.shadowRootMode===Q.localFrame){let f=R(),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 _=[],T=c?{open(){},writeln(b){_.push(b)},close(){l.srcdoc=_.join("\n")}}:(()=>{let b=l.contentDocument||l.contentWindow.document;return b.open(),b})(),N=null;{let x=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(x)try{N=JSON.parse(x.getAttribute("content")||"{}")}catch(te){}}let S=a.HTML;if(s!=null&&s._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),x=C.getElementById("myop_preview");x==null||x.removeAttribute("type");let te=C.implementation.createHTMLDocument();te.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ne=te.body.firstChild;ne&&C.head&&C.head.insertBefore(C.importNode(ne,!0),C.head.firstChild),S="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((s==null?void 0:s.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),x=C.getElementById("myop_preview");x&&(x.remove(),S="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(s!=null&&s.injectCss){let C=new DOMParser().parseFromString(S,"text/html"),x=C.createElement("style");x.setAttribute("data-myop-injected","true"),x.textContent=s.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(x),S="<!DOCTYPE html>"+C.documentElement.outerHTML}T.writeln(S);let ee='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),j="<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||T.writeln("".concat(ee).concat(j)),!c&&(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null){let b="<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"),x='<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>");T.writeln(b+x)}if(c){let b=(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";T.writeln(this.buildIsolationBridge(b))}T.close();let H=new W(e,t,i,l,s);return c&&H.enableIsolation(),H.sizeMeta=N,H.initiated().then(()=>{if((s==null?void 0:s.autoSize)===!1)return;let b=!1;H.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!b&&!(s!=null&&s.hidden)&&(b=!0,H.show())}})}),H}if(a.shadowRootMode===Q.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,xn().then(g=>{g.connectedCallback(u,u)})}else{let f=po(e.name+t.id);Sn.includes(f)||(ro(f,a.HTML,a.shadowRootMode),Sn.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 pe(e,t,i,u,s)})}isMyopWebComponent(e){return e.trimStart().startsWith(so)?!0:new RegExp("<script[^>]*\\sid=[\"']?".concat(In,"[\"'\\s>]"),"i").test(e)}async resolveRenderMode(e,t,i,s,a){var m,u,f,g;let d=s?"webComponent":i.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",p=(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=p?await p({componentDefinition:e,skin:t,requestedMode:d,isWebComponent:s}):d;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(In);return(s==null?void 0:s.textContent)||null}executeWebComponentScript(e,t){let i=vn.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&&vn.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,i,s,a){let d=this.extractWebComponentScript(s);if(!d)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let p="".concat(e.id,"-").concat(t.id),c=this.executeWebComponentScript(d,p);if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");let m="myop-comp-".concat(R()),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 X(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]=dt(t);switch(i){case"component":{let[a,d]=s,p=await Z.Main.fetchComponent(a);if(p&&p.type.skins.find(m=>m.id===d))return p.instance.skinSelector={type:J.Dedicated,skin:{id:d}},p}break;default:{let[a,d]=dt(t),c=(await Z.Main.fetchFlow(a)).components.find(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===J.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(u=>u.id===d);if((m==null?void 0:m.type)===Fe.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 En="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",V=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",ln);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!==E.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){let s=this.components2init.filter(d=>{let p=d.element;return(p==null?void 0:p.nodeName)==="IFRAME"&&p.contentWindow===n.source});(s.length?s:this.components2init).forEach(d=>{d.send(new Y(d.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 d;return a.id===((d=t.content)==null?void 0:d.id)});s==null||s.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let s=t,a=this.components.find(d=>d.id===s.destination);if(a){if(s.direction===E.down){s.message.messageType===D.name?a.onMessageReceived(s.message):(s.message.route=s.route,a.send(s.message));return}}else{let d=this.components.find(p=>p.id===s.message.destination);d&&d.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 We,new Ne,new it];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,d){for(let p of a)if(await d(p))return p}switch(n.type){case"DedicatedSkin":case J.Dedicated:return((s=n.skin)==null?void 0:s.id)||n.skins[0].id;case J.Segmented:{let d=await i(n.segments,async p=>{if(p.segmentId==="Default")return!0;let c=e.find(g=>g.type===Fe.Segment?g.segment.id===p.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(p.segmentId,", ").concat(u.function," function not provided !")),!1)});if(d)return this._getSkinIdBySkinSelector(d.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:J.Dedicated,skin:l},t&&(t=h({},t),delete t.hooks),await _t(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let d=await this.runSkinSelector(n,s);if(!d)throw new Error("runSkinSelector failed to choose skin, check the provided config");(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(d=await t.hooks.afterSkinSelected(h({},d)));let p=this.componentsLoaders.find(l=>l.type===d.loader.type);if(!p){debugger;throw new Error('no loader "'.concat(d.loader.type,'" was found for component'))}let c=await p.load(n.type,d,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 Y(c.id)),(!t||t.connectProps!==!1)&&(c=cn(c,n.type.props,d));try{await Et(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(V,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:En});if(!window.myop.hostSDK){let o=new V;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:En}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>fn(n);o.stats=Te,o.off=yn,o.refresh=gn,window.myop.delivery=o}window.myop&&!window.myop.hydrateV1&&(window.myop.hydrateV1=hn);var co=window.myop.hostSDK;Le("hostSDK",co);export{V as HostSDK,co as hostSDK};
@@ -616,6 +616,10 @@ var BaseMyopComponent = class {
616
616
  }
617
617
  });
618
618
  }
619
+ get uiTags() {
620
+ var _a;
621
+ return ((_a = this.componentDefinition) == null ? void 0 : _a.uiTags) || [];
622
+ }
619
623
  get markedForDisposed() {
620
624
  return this._markedForDisposed;
621
625
  }
@@ -1953,6 +1957,21 @@ var addQueryParam = (url, param, value) => {
1953
1957
  urlObj.searchParams.append(param, value);
1954
1958
  return urlObj.toString();
1955
1959
  };
1960
+ var showsSamePage = (frame, url) => {
1961
+ const current = frame.getAttribute("src");
1962
+ if (!current || !url) return false;
1963
+ const norm = (u) => {
1964
+ const x = new URL(u, document.baseURI);
1965
+ x.hash = "";
1966
+ if (x.pathname.length > 1) x.pathname = x.pathname.replace(/\/$/, "");
1967
+ return x.href;
1968
+ };
1969
+ try {
1970
+ return norm(current) === norm(url);
1971
+ } catch (e) {
1972
+ return false;
1973
+ }
1974
+ };
1956
1975
  var MyopIframeLoader = class extends BaseMyopLoader {
1957
1976
  constructor() {
1958
1977
  super(...arguments);
@@ -1962,9 +1981,10 @@ var MyopIframeLoader = class extends BaseMyopLoader {
1962
1981
  let IframeElement;
1963
1982
  const typedLoaderConfig = skin.loader;
1964
1983
  if ((container == null ? void 0 : container.nodeName) === "IFRAME") {
1965
- console.log("needs to load into an exsisting Iframe...", typedLoaderConfig.url, container);
1966
1984
  IframeElement = container;
1967
- IframeElement.src = typedLoaderConfig.url;
1985
+ if (!showsSamePage(IframeElement, typedLoaderConfig.url)) {
1986
+ IframeElement.src = typedLoaderConfig.url;
1987
+ }
1968
1988
  } else {
1969
1989
  const uniqId = uuidv4();
1970
1990
  const domId = "myop-comp-".concat(uniqId);
@@ -2107,7 +2127,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
2107
2127
  };
2108
2128
 
2109
2129
  // version:myop-sdk-version
2110
- var myop_sdk_version_default = "0.4.0-beta.5";
2130
+ var myop_sdk_version_default = "0.4.0-beta.6";
2111
2131
 
2112
2132
  // src/helpers/deliveryStore.ts
2113
2133
  var DB_NAME = "myop-delivery";
@@ -2264,7 +2284,10 @@ var convertV2VariantToComponentConfig = (config) => {
2264
2284
  loader: config.consume_variant[0].loader
2265
2285
  }
2266
2286
  ],
2267
- defaultSkin: 0
2287
+ defaultSkin: 0,
2288
+ // Only `ui:` tags ever reach the client; the server filters, absent = none.
2289
+ // @ts-ignore
2290
+ uiTags: Array.isArray(config.uiTags) ? config.uiTags : []
2268
2291
  },
2269
2292
  name: config.name
2270
2293
  };
@@ -2306,7 +2329,7 @@ var _CloudRepository = class _CloudRepository {
2306
2329
  * Opt-in delivery settings, set by myop.delivery(). Off means: this file behaves
2307
2330
  * EXACTLY as it did before — same host, same URL, same everything.
2308
2331
  */
2309
- __publicField(this, "_delivery", { minify: false, host: null, cache: false });
2332
+ __publicField(this, "_delivery", { minify: false, host: null, cache: false, flow: false });
2310
2333
  /**
2311
2334
  * What actually happened, for myop.delivery.stats(). `fellBack` is the number that
2312
2335
  * matters: it is how you find out the lane is unhealthy without waiting for a
@@ -2341,6 +2364,9 @@ var _CloudRepository = class _CloudRepository {
2341
2364
  */
2342
2365
  __publicField(this, "_localServes", /* @__PURE__ */ new Map());
2343
2366
  __publicField(this, "_flushBound", false);
2367
+ // ============ V1 Methods (Legacy) ============
2368
+ /** ids seeded by hydrateV1Component whose first use has not been counted yet */
2369
+ __publicField(this, "_hydratedV1", /* @__PURE__ */ new Set());
2344
2370
  }
2345
2371
  static get Main() {
2346
2372
  const globalMain = getGlobalMain();
@@ -2376,32 +2402,46 @@ var _CloudRepository = class _CloudRepository {
2376
2402
  * Deliberately mutates THIS instance rather than constructing a new repository:
2377
2403
  * CloudRepository.Main is a global singleton shared across bundles (see getGlobalMain),
2378
2404
  * so a second instance would be ignored by every component already using the first.
2405
+ *
2406
+ * @internal
2379
2407
  */
2380
2408
  setDelivery(opts = {}) {
2381
2409
  if (opts.minify !== void 0) this._delivery.minify = !!opts.minify;
2382
2410
  if (opts.host !== void 0) this._delivery.host = opts.host;
2383
2411
  if (opts.cache !== void 0) this._delivery.cache = !!opts.cache;
2412
+ if (opts.flow !== void 0) this._delivery.flow = !!opts.flow;
2384
2413
  }
2414
+ /** @internal */
2385
2415
  deliveryStats() {
2386
2416
  var _a;
2387
2417
  return __spreadProps(__spreadValues({}, this._deliveryStats), {
2388
2418
  host: (_a = this._delivery.host) != null ? _a : _CloudRepository.DEFAULT_HOST,
2389
2419
  minify: this._delivery.minify,
2390
- cache: this._delivery.cache
2420
+ cache: this._delivery.cache,
2421
+ flow: this._delivery.flow
2391
2422
  });
2392
2423
  }
2393
2424
  /**
2394
2425
  * Forget what this browser holds, so the next load asks the server.
2395
2426
  * `refresh()` with no ids drops everything; the counterpart to the window for the case
2396
2427
  * where a change has to be visible on THIS load — right after someone publishes.
2428
+ *
2429
+ * @internal
2397
2430
  */
2398
2431
  async refreshDelivery() {
2399
2432
  await deliveryStore.clear();
2400
2433
  }
2401
- noteLocalServe(componentId, env) {
2402
- const cur = this._localServes.get(componentId);
2434
+ /**
2435
+ * `source: 'h'` = the view was served from a config the page's SERVER embedded
2436
+ * (hydrateV1Component), not from this browser's cache window. Reported as a 4th batch
2437
+ * field (`id:env:n:h`) so our usage data can tell server-rendered views apart; a server
2438
+ * that predates it reads the first three fields and counts the view all the same.
2439
+ */
2440
+ noteLocalServe(componentId, env, source) {
2441
+ const key = source ? "".concat(componentId, ":").concat(source) : componentId;
2442
+ const cur = this._localServes.get(key);
2403
2443
  if (cur) cur.count++;
2404
- else this._localServes.set(componentId, { env, count: 1 });
2444
+ else this._localServes.set(key, { id: componentId, env, count: 1, source });
2405
2445
  this.bindFlush();
2406
2446
  }
2407
2447
  /** Report on page-hide, which is the only event that reliably fires on mobile. */
@@ -2421,7 +2461,7 @@ var _CloudRepository = class _CloudRepository {
2421
2461
  */
2422
2462
  flushLocalServes() {
2423
2463
  if (!this._localServes.size) return;
2424
- const batch = [...this._localServes.entries()].map(([id, v]) => "".concat(id, ":").concat(v.env, ":").concat(v.count)).join(",");
2464
+ const batch = [...this._localServes.entries()].map(([, v]) => "".concat(v.id, ":").concat(v.env, ":").concat(v.count).concat(v.source ? ":" + v.source : "")).join(",");
2425
2465
  this._localServes.clear();
2426
2466
  try {
2427
2467
  const url = "".concat(this.deliveryHost(), "/clientUsage?b=").concat(encodeURIComponent(batch));
@@ -2470,7 +2510,7 @@ var _CloudRepository = class _CloudRepository {
2470
2510
  /**
2471
2511
  * Enable static mode for self-hosted component registries.
2472
2512
  * In static mode, URLs are constructed as file paths instead of query params:
2473
- * ${baseUrl}/components/${componentId}/${env}.json
2513
+ * `${baseUrl}/components/${componentId}/${env}.json`
2474
2514
  */
2475
2515
  enableStaticMode() {
2476
2516
  this._staticMode = true;
@@ -2679,6 +2719,14 @@ var _CloudRepository = class _CloudRepository {
2679
2719
  const { cacheKey } = this.resolveParams(componentId, env, preview);
2680
2720
  return ((_a = this.variants[cacheKey]) == null ? void 0 : _a.resolved) || null;
2681
2721
  }
2722
+ /**
2723
+ * The `ui:` tags of an already-resolved component (`[]` if it has none or is not
2724
+ * resolved yet). Synchronous, no request: tags arrive with the component itself.
2725
+ */
2726
+ getComponentTags(componentId, env, preview) {
2727
+ var _a, _b;
2728
+ return ((_b = (_a = this.getResolvedConfig(componentId, env, preview)) == null ? void 0 : _a.type) == null ? void 0 : _b.uiTags) || [];
2729
+ }
2682
2730
  /**
2683
2731
  * Resolve which (env, preview) pair — and therefore which cache key — a call
2684
2732
  * for `componentId` refers to.
@@ -2723,7 +2771,27 @@ var _CloudRepository = class _CloudRepository {
2723
2771
  this.variants[cacheKey] = promise;
2724
2772
  this.preloadedComponents[componentId] = { env: resolvedEnv, preview: usePreview };
2725
2773
  }
2726
- // ============ V1 Methods (Legacy) ============
2774
+ /**
2775
+ * Seed a v1 component's config, so `fetchComponentV1(componentId)` answers from memory
2776
+ * with no request. The v1 counterpart of {@link hydrateComponent}.
2777
+ *
2778
+ * `flow` is what `GET /flow?id=<componentId>&auto=true` returns: either the whole body
2779
+ * (`{item: {...}}`) or its `item`. Typical use is a server that fetched it (with
2780
+ * `&prefetch=1`, so the fetch is not counted as a view) and embedded it in the page.
2781
+ *
2782
+ * The view IS counted: the first time the seeded config is used, it is reported through
2783
+ * /clientUsage (flagged `:h`, recorded as deliveryPath 'hydrated'), so hydrating never makes
2784
+ * usage disappear and server-rendered views stay distinguishable.
2785
+ */
2786
+ hydrateV1Component(componentId, flow) {
2787
+ var _a, _b;
2788
+ const item = (_a = flow == null ? void 0 : flow.item) != null ? _a : flow;
2789
+ if (!((_b = item == null ? void 0 : item.components) == null ? void 0 : _b.length)) {
2790
+ throw new Error("hydrateV1Component(".concat(componentId, "): not a /flow?auto=true response"));
2791
+ }
2792
+ this.userFlows[componentId] = Promise.resolve(item);
2793
+ this._hydratedV1.add(componentId);
2794
+ }
2727
2795
  /**
2728
2796
  * Fetch a v1 component from a flow
2729
2797
  */
@@ -2737,13 +2805,15 @@ var _CloudRepository = class _CloudRepository {
2737
2805
  }
2738
2806
  }
2739
2807
  async fetchAutoFlow(componentId) {
2808
+ if (this._hydratedV1.delete(componentId)) {
2809
+ this.noteLocalServe(componentId, "v1_auto_flow", "h");
2810
+ }
2740
2811
  if (!this.userFlows[componentId]) {
2741
2812
  this.userFlows[componentId] = new Promise(
2742
2813
  async (resolve, reject) => {
2743
2814
  try {
2744
- const res = await fetch(
2745
- "".concat(this._baseUrl, "/flow?id=").concat(componentId, "&auto=true")
2746
- );
2815
+ const path = "/flow?id=".concat(componentId, "&auto=true");
2816
+ const res = this._delivery.flow && this._delivery.host ? await this.deliveryFetch(path) : await fetch("".concat(this._baseUrl).concat(path));
2747
2817
  const json = await res.json();
2748
2818
  resolve(json.item);
2749
2819
  } catch (e) {
@@ -2792,11 +2862,12 @@ var CloudRepository = _CloudRepository;
2792
2862
  var _cloudRepository = CloudRepository.Main;
2793
2863
  var DELIVERY_HOST = "https://delivery.myop.dev";
2794
2864
  var delivery = (opts = {}) => {
2795
- var _a, _b;
2796
- const wantsLane = opts.minify !== false || opts.cache === true;
2865
+ var _a, _b, _c;
2866
+ const wantsLane = opts.minify !== false || opts.cache === true || opts.flow === true;
2797
2867
  _cloudRepository.setDelivery({
2798
2868
  minify: (_a = opts.minify) != null ? _a : false,
2799
2869
  cache: (_b = opts.cache) != null ? _b : false,
2870
+ flow: (_c = opts.flow) != null ? _c : false,
2800
2871
  host: opts.host !== void 0 ? opts.host : wantsLane ? DELIVERY_HOST : null
2801
2872
  });
2802
2873
  return deliveryStats();
@@ -2807,9 +2878,14 @@ var deliveryRefresh = async () => {
2807
2878
  };
2808
2879
  var deliveryStats = () => _cloudRepository.deliveryStats();
2809
2880
  var deliveryOff = () => {
2810
- _cloudRepository.setDelivery({ minify: false, cache: false, host: null });
2881
+ _cloudRepository.setDelivery({ minify: false, cache: false, flow: false, host: null });
2811
2882
  return deliveryStats();
2812
2883
  };
2884
+ var hydrateV1Components = (flows) => {
2885
+ for (const [id, flow] of Object.entries(flows)) {
2886
+ _cloudRepository.hydrateV1Component(id, flow);
2887
+ }
2888
+ };
2813
2889
 
2814
2890
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
2815
2891
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
@@ -3898,6 +3974,9 @@ if (window.myop && !window.myop.delivery) {
3898
3974
  api.refresh = deliveryRefresh;
3899
3975
  window.myop.delivery = api;
3900
3976
  }
3977
+ if (window.myop && !window.myop.hydrateV1) {
3978
+ window.myop.hydrateV1 = hydrateV1Components;
3979
+ }
3901
3980
  var hostSDK = window.myop.hostSDK;
3902
3981
  defineDynamicImport("hostSDK", hostSDK);
3903
3982
  export {