veo-sdk 0.5.17 → 0.5.18
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/builder-Q3V33JIO.mjs +5 -0
- package/dist/{builder-CMSFET5V.mjs.map → builder-Q3V33JIO.mjs.map} +1 -1
- package/dist/builder.cjs +18 -1
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.cts +2 -2
- package/dist/builder.d.ts +2 -2
- package/dist/builder.mjs +4 -4
- package/dist/{chunk-Z73XWYE3.mjs → chunk-345TTBZM.mjs} +4 -4
- package/dist/chunk-345TTBZM.mjs.map +1 -0
- package/dist/{chunk-5Q6CFNW4.mjs → chunk-JRUCBH2I.mjs} +19 -2
- package/dist/chunk-JRUCBH2I.mjs.map +1 -0
- package/dist/{chunk-L3KS6G7T.mjs → chunk-JYTQQ623.mjs} +3 -3
- package/dist/{chunk-L3KS6G7T.mjs.map → chunk-JYTQQ623.mjs.map} +1 -1
- package/dist/{guide-preview-XUnTmzUO.d.cts → guide-preview-BiufCjq9.d.cts} +7 -0
- package/dist/{guide-preview-XUnTmzUO.d.ts → guide-preview-BiufCjq9.d.ts} +7 -0
- package/dist/index.cjs +18 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +5 -5
- package/dist/veo-builder.js +6 -6
- package/dist/veo-builder.js.map +1 -1
- package/dist/veo-guides.js +3 -3
- package/dist/veo-guides.js.map +1 -1
- package/package.json +1 -1
- package/dist/builder-CMSFET5V.mjs +0 -5
- package/dist/chunk-5Q6CFNW4.mjs.map +0 -1
- package/dist/chunk-Z73XWYE3.mjs.map +0 -1
package/dist/veo-guides.js
CHANGED
|
@@ -423,8 +423,8 @@ var veoGuides=(function(exports){'use strict';function wt(){return typeof window
|
|
|
423
423
|
to { transform: translateY(0); opacity: 1; }
|
|
424
424
|
}
|
|
425
425
|
`;var w=class{constructor(){this.host=null;this.shadow=null;this.cleanups=[];this.liveContainer=null;this.liveContent=null;this.liveBuild=null;this.liveKey="";}liveKeyOf(e){return ""}onLiveUpdate(e){}updateStep(e){if(!this.host||!this.liveContainer||!this.liveContent||!this.liveBuild||this.liveKeyOf(e)!==this.liveKey)return false;let t=this.liveBuild(e);return this.liveContainer.replaceChild(t,this.liveContent),this.liveContent=t,this.applyDesign(e.style),this.onLiveUpdate(e),true}createHost(){let e=document.createElement("div");e.setAttribute(Ct,"");let t=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=cn,t.appendChild(n);let i=document.createElement("div");return t.appendChild(i),document.body.appendChild(e),this.host=e,this.shadow=t,{host:e,shadow:t,root:i}}applyDesign(e){this.host&&dn(this.host,e);}registerCleanup(e){this.cleanups.push(e);}hostElement(){return this.host}destroy(){for(let e of this.cleanups)try{e();}catch{}this.cleanups=[],this.host?.parentNode&&this.host.parentNode.removeChild(this.host),this.host=null,this.shadow=null;}};var ao={top:"bottom",bottom:"top",left:"right",right:"left"};function te(o,e,t){let n=ao[e.split("-")[0]??"bottom"]??"top";for(let i of ["top","bottom","left","right"])o.style.setProperty(i,"");t?.x!=null&&o.style.setProperty("left",`${t.x}px`),t?.y!=null&&o.style.setProperty("top",`${t.y}px`),o.style.setProperty(n,"-6px");}var lo=150,xe=class extends w{constructor(){super(...arguments);this.tooltip=null;this.arrowEl=null;this.badgeBtn=null;this.open=false;this.shownEmitted=false;this.trigger="hover";this.side="top";this.closeTimer=null;this.stopFloat=null;}async render(t){let n=t.guide.guideSteps[0];if(!n)return;let i=n.selector??t.guide.activationRules.selector;if(typeof i!="string"||i.length===0)return;let r=await k(i);if(!r)return;let{host:s,root:a}=this.createHost(),l=a.ownerDocument??document;this.applyDesign(n.style);let d=n.style?.width;typeof d=="number"&&Number.isFinite(d)&&s.style.setProperty("--veo-badge-tip-width",`${Math.min(720,Math.max(220,d))}px`),this.trigger=n.style?.badgeTrigger==="click"?"click":"hover";let c=n.style?.tooltipPlacement;this.side=c==="bottom"||c==="left"||c==="right"?c:"top";let p=K(n.style);s.style.display="inline-flex",s.style.verticalAlign="middle";let m=pn(un(n),l);a.appendChild(m),this.badgeBtn=m,A(r,s,p),this.registerCleanup(M(s,i,p));let u=l.createElement("div");u.className="veo-tooltip veo-badge-tooltip",u.style.display="none";let f=(y,C)=>{t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:y,...C?{metadata:C}:{}});},h=y=>P(y,l,{onCtaClick:(C,S,q)=>{f("cta_clicked",q),C==="url"&&S&&window.open(S,"_blank","noopener,noreferrer"),this.closeTooltip(),C==="guide"&&S&&t.onOpenGuide?.(S);},onDismiss:()=>this.closeTooltip()}),g=h(n);u.appendChild(g);let v=l.createElement("div");v.className="veo-tooltip-arrow",u.appendChild(v),a.appendChild(u),this.tooltip=u,this.arrowEl=v,this.liveContainer=u,this.liveContent=g,this.liveKey=this.liveKeyOf(n),this.liveBuild=h;let b=()=>{this.cancelClose(),this.open||(this.openTooltip(m),this.shownEmitted||(this.shownEmitted=true,f("shown")));};if(this.trigger==="hover"){let y=()=>{this.cancelClose(),this.closeTimer=window.setTimeout(()=>this.closeTooltip(),lo);};m.addEventListener("mouseenter",b),m.addEventListener("focus",b),m.addEventListener("mouseleave",y),m.addEventListener("blur",y),u.addEventListener("mouseenter",()=>this.cancelClose()),u.addEventListener("mouseleave",y);}else {m.addEventListener("click",()=>{this.open?this.closeTooltip():b();});let y=C=>{this.open&&(C.composedPath().includes(s)||this.closeTooltip());};document.addEventListener("click",y,true),this.registerCleanup(()=>document.removeEventListener("click",y,true));}let x=y=>{y.key==="Escape"&&this.open&&this.closeTooltip();};document.addEventListener("keydown",x),this.registerCleanup(()=>document.removeEventListener("keydown",x)),t.isPreview&&b();}liveKeyOf(t){let n=t.selector??"",i=K(t.style),r=t.style?.badgeTrigger==="click"?"click":"hover";return `${n}|${i}|${r}`}onLiveUpdate(t){if(this.badgeBtn){let i=this.badgeBtn.ownerDocument,r=pn(un(t),i);this.badgeBtn.className=r.className,this.badgeBtn.setAttribute("style",r.getAttribute("style")??""),this.badgeBtn.replaceChildren(...Array.from(r.childNodes));}let n=t.style?.tooltipPlacement;this.side=n==="bottom"||n==="left"||n==="right"?n:"top",this.open&&this.badgeBtn&&this.position(this.badgeBtn);}destroy(){this.cancelClose(),this.stopFloat?.(),this.stopFloat=null,this.tooltip=null,this.arrowEl=null,this.badgeBtn=null,this.open=false,super.destroy();}openTooltip(t){if(!this.tooltip)return;this.tooltip.style.display="block",this.open=true,this.position(t);let n=()=>{this.position(t);};window.addEventListener("scroll",n,true),window.addEventListener("resize",n),this.stopFloat=()=>{window.removeEventListener("scroll",n,true),window.removeEventListener("resize",n);};}closeTooltip(){this.cancelClose(),!(!this.tooltip||!this.open)&&(this.tooltip.style.display="none",this.open=false,this.stopFloat?.(),this.stopFloat=null);}cancelClose(){this.closeTimer!==null&&(window.clearTimeout(this.closeTimer),this.closeTimer=null);}async position(t){let n=this.tooltip,i=this.arrowEl;if(!n||!i)return;let{x:r,y:s,placement:a,middlewareData:l}=await z(t,n,{strategy:"fixed",placement:this.side,middleware:[H(8),W(),D({padding:8}),ee({element:i})]});n.style.left=`${r}px`,n.style.top=`${s}px`,te(i,a,l.arrow);}};function un(o){let e=o.style?.badge;if(!e||typeof e!="object")return {kind:"icon"};let t=e;return {kind:t.kind==="dot"||t.kind==="pill"||t.kind==="text"||t.kind==="image"||t.kind==="icon"?t.kind:"icon",icon:typeof t.icon=="string"?t.icon:null,text:typeof t.text=="string"?t.text:null,imageUrl:typeof t.imageUrl=="string"?t.imageUrl:null,color:typeof t.color=="string"&&U.test(t.color.trim())?t.color.trim():null,size:typeof t.size=="number"&&Number.isFinite(t.size)?t.size:null}}function He(o,e,t){return Math.min(t,Math.max(e,o))}function pn(o,e){let t=e.createElement("button");t.type="button",t.className=`veo-badge veo-badge--${o.kind}`,t.setAttribute("aria-label","M\xE1s informaci\xF3n");let n=He(o.size??18,8,48);switch(o.kind){case "dot":t.style.width=`${n}px`,t.style.height=`${n}px`,o.color&&(t.style.background=o.color);break;case "pill":{t.textContent=o.text?.slice(0,24)||"Nuevo",t.style.fontSize=`${He(Math.round(n*.62),8,24)}px`,o.color&&(t.style.background=o.color);break}case "text":{t.textContent=o.text?.slice(0,32)||"Nuevo",t.style.fontSize=`${He(Math.round(n*.7),9,28)}px`,o.color&&(t.style.color=o.color);break}case "image":{if(o.imageUrl&&R(o.imageUrl)){let i=e.createElement("img");i.src=o.imageUrl,i.alt="",i.style.width=`${n}px`,i.style.height=`${n}px`,t.appendChild(i);}else t.className="veo-badge veo-badge--icon",t.textContent="?",t.style.width=`${n}px`,t.style.height=`${n}px`,t.style.fontSize=`${He(Math.round(n*.62),8,32)}px`;break}default:{t.textContent=(o.icon||"\u2139\uFE0F").slice(0,4),t.style.width=`${n}px`,t.style.height=`${n}px`,t.style.fontSize=`${He(Math.round(n*.62),8,32)}px`,o.color&&(t.style.color=o.color);break}}return t}function Ce(o,e,t,n,i){let r=n.createElement("div");r.className="veo-guide-content";let s=n.createElement("div");s.className="veo-walkthrough-counter",s.textContent=`Paso ${e+1} de ${t}`,r.appendChild(s);let a=n.createElement("div");a.className="veo-walkthrough-progress";for(let f=0;f<t;f++){let h=n.createElement("span");h.className="veo-walkthrough-progress-dot",f<e&&h.classList.add("completed"),f===e&&h.classList.add("active"),a.appendChild(h);}r.appendChild(a);for(let f of on(o,n))r.appendChild(f);let l=n.createElement("div");l.className="veo-walkthrough-actions";let d=n.createElement("button");d.type="button",d.className="veo-walkthrough-skip",d.textContent="Omitir",d.addEventListener("click",()=>i.onSkip()),l.appendChild(d);let c=n.createElement("div");if(c.className="veo-walkthrough-actions-right",e>0){let f=n.createElement("button");f.type="button",f.className="veo-walkthrough-btn-secondary",f.textContent="Atr\xE1s",f.addEventListener("click",()=>i.onBack()),c.appendChild(f);}let p=e===t-1,m=n.createElement("button");m.type="button",m.className="veo-guide-cta";let u=p?"Finalizar":"Siguiente";return m.textContent=typeof o.ctaText=="string"&&o.ctaText?o.ctaText:u,m.addEventListener("click",()=>{p?i.onComplete():i.onNext();}),c.appendChild(m),l.appendChild(c),r.appendChild(l),r.appendChild(pe(n,()=>i.onSkip())),r}var ne=class extends w{async render(e){let t=e.nav?.stepIndex??0,n=e.guide.guideSteps[t];if(!n)return;let i=n.style?.position==="bottom"?"bottom":"top",r=n.selector?.trim()||null,s=null;if(r&&(s=await k(r),!s))return;let{host:a,root:l}=this.createHost();this.applyDesign(n.style);let d=l.ownerDocument??document,c=d.createElement("div");c.className=fn(i,!!s);let p=(u,f,h)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:u,...h?{metadata:h}:{}}),f&&window.open(f,"_blank","noopener,noreferrer"),e.onClose();},m=e.nav?Ce(n,e.nav.stepIndex,e.nav.totalSteps,d,e.nav.callbacks):P(n,d,{onCtaClick:(u,f,h)=>{p("cta_clicked",u==="url"?f:void 0,h),u==="guide"&&f&&e.onOpenGuide?.(f);},onDismiss:()=>p("dismissed")});if(c.appendChild(m),l.appendChild(c),r&&s){a.style.display="block";let u=i==="top"?"prepend":"append";A(s,a,u),this.registerCleanup(M(a,r,u));}e.nav||(this.liveContainer=c,this.liveContent=m,this.liveBuild=u=>P(u,d,{onCtaClick:(f,h,g)=>{p("cta_clicked",f==="url"?h:void 0,g),f==="guide"&&h&&e.onOpenGuide?.(h);},onDismiss:()=>p("dismissed")}),this.liveKey=this.liveKeyOf(n),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"}));}liveKeyOf(e){let t=e.selector?.trim()??"";if(!t)return "";let n=e.style?.position==="bottom"?"bottom":"top";return `${t}|${n}`}onLiveUpdate(e){if(this.liveContainer){let t=e.style?.position==="bottom"?"bottom":"top",n=!!e.selector?.trim();this.liveContainer.className=fn(t,n);}}};function fn(o,e){return e?"veo-banner veo-banner-embedded":`veo-banner veo-banner-${o}`}function mn(){let e=Date.now().toString(16).padStart(12,"0"),t=new Uint8Array(10);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let i=0;i<t.length;i++)t[i]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let n=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),n.slice(0,4),n.slice(4,8),n.slice(8,20)].join("-")}function Se(o,e,t,n){let i=o.createElement("iframe");i.className="veo-custom-frame",i.setAttribute("sandbox","allow-scripts"),i.setAttribute("title",t.guide.guideName||"OnUser"),i.style.width=n.width;let r=n.fixedHeight!==void 0&&n.fixedHeight!==null;r&&(i.style.height=vt(n.fixedHeight));let s=mn(),a=e.style?.tailwind===true;i.srcdoc=mo(e.html??"",e.css??"",e.js??"",s,{hostCss:uo(),htmlAttrs:po(),tailwind:a});let l=()=>t.onClose(),d=c=>{if(c.source!==i.contentWindow)return;let p=c.data;if(!(!p||typeof p!="object"||p.__veo!==s))switch(p.type){case "dismiss":t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"dismissed"}),l();break;case "cta":t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"cta_clicked"}),typeof p.url=="string"&&R(p.url)&&window.open(p.url,"_blank","noopener,noreferrer"),p.close!==false&&l();break;case "navigate":typeof p.url=="string"&&R(p.url)&&window.location.assign(p.url);break;case "track":typeof p.name=="string"&&t.onTrack&&t.onTrack(p.name,fo(p.props)?p.props:void 0);break;case "resize":!r&&typeof p.height=="number"&&p.height>0&&(i.style.height=`${Math.ceil(p.height)}px`);break}};return window.addEventListener("message",d),{iframe:i,cleanup:()=>window.removeEventListener("message",d)}}function vt(o){return typeof o=="number"?`${o}px`:o}var co=800*1024;function uo(){if(typeof document>"u")return "";let o="";try{for(let e of Array.from(document.styleSheets)){let t=null;try{t=e.cssRules;}catch{continue}if(t){for(let n of Array.from(t))if(o+=`${n.cssText}
|
|
426
|
-
`,o.length>co)return o}}}catch{return o}return o}function po(){if(typeof document>"u")return "";try{let o=document.documentElement,e=[];for(let t of ["class","style","data-theme","data-mode","data-color-mode"]){let n=o.getAttribute(t);n&&n.length<=1e3&&!/["<>]/.test(n)&&e.push(`${t}="${n}"`);}return e.join(" ")}catch{return ""}}function fo(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function mo(o,e,t,n,i){let r=`(function(){var T=${JSON.stringify(n)};function P(m){m.__veo=T;parent.postMessage(m,'*');}window.veo={dismiss:function(){P({type:'dismiss'});},cta:function(u){P({type:'cta',url:u});},track:function(n,p){P({type:'track',name:n,props:p||{}});},navigate:function(u){P({type:'navigate',url:u});}};document.addEventListener('click',function(e){var a=e.target&&e.target.closest?e.target.closest('a[href]'):null;if(!a)return;var h=a.getAttribute('href');if(!h||h.charAt(0)==='#'||/^(javascript|mailto|tel):/i.test(h))return;e.preventDefault();if(a.target==='_blank'){P({type:'cta',url:a.href,close:false});}else{P({type:'navigate',url:h});}},true);function H(){var r=document.getElementById('__veo_root');var h=r?r.getBoundingClientRect().height:document.documentElement.scrollHeight;P({type:'resize',height:Math.ceil(h)});}window.addEventListener('load',H);try{if(typeof ResizeObserver!=='undefined'){var _r=document.getElementById('__veo_root');new ResizeObserver(H).observe(_r||document.documentElement);}}catch(e){}})();`,s=i.hostCss?`<style>${gt(i.hostCss,"style")}</style>`:"",a=i.tailwind?'<script src="https://cdn.tailwindcss.com"></script>':"";return `<!DOCTYPE html><html ${i.htmlAttrs}><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;}body{font-family:system-ui,-apple-system,sans-serif;}</style>`+s+"<style>html,body{margin:0!important;padding:0!important;background:transparent!important;height:auto!important;min-height:0!important;max-height:none!important;width:auto!important;min-width:0!important;overflow:visible!important;color-scheme:normal!important;}</style>"+a+`<style>${gt(e,"style")}</style></head><body style="margin:0!important;background:transparent!important;min-height:0!important;height:auto!important;"><div id="__veo_root">${o}</div><script>${r}</script>`+(t?`<script>${gt(t,"script")}</script>`:"")+"</body></html>"}function gt(o,e){let t=e==="script"?/<\/script/gi:/<\/style/gi;return o.replace(t,`<\\/${e}`)}function hn(o,e,t){if(o.sandboxed){let s={html:o.html??"",css:o.css,js:o.js},{iframe:a,cleanup:l}=Se(e,s,t,{width:"100%"}),d=e.createElement("div");return d.className="veo-code-sandbox",d.appendChild(a),{node:d,cleanup:l}}let n=e,i=[];if(typeof o.css=="string"&&o.css.trim()){let s=n.createElement("style");s.textContent=o.css,n.head.appendChild(s),i.push(s);}let r=null;if(typeof o.html=="string"&&o.html.trim()){r=e.createElement("div"),r.className="veo-code-html",r.innerHTML=o.html;for(let s of Array.from(r.querySelectorAll("script")))i.push(ho(s,n)),s.remove();}if(typeof o.js=="string"&&o.js.trim()){let s=n.createElement("script");s.textContent=o.js,n.body.appendChild(s),i.push(s);}return {node:r,cleanup:()=>{for(let s of i)s.parentNode?.removeChild(s);}}}function ho(o,e){let t=e.createElement("script");for(let n of Array.from(o.attributes))t.setAttribute(n.name,n.value);return o.src||(t.textContent=o.textContent),e.body.appendChild(t),t}function ot(o,e,t){let n=e.guide.guideSteps[0];if(!n)return;let i=n.fields??[],r=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();},s=t.createElement("div");if(s.className="veo-guide-content",n.title){let m=t.createElement("h2");m.className="veo-guide-title",m.textContent=n.title,s.appendChild(m);}if(n.content){let m=t.createElement("p");m.className="veo-guide-text",m.textContent=n.content,s.appendChild(m);}let a=[],l=t.createElement("form");l.className="veo-form",l.noValidate=true;for(let m of i){let{wrapper:u,read:f}=yt(m,t);a.push({field:m,read:f}),l.appendChild(u);}let d=t.createElement("p");d.className="veo-form-error",d.style.display="none",l.appendChild(d);let c=t.createElement("div");c.className="veo-guide-actions";let p=t.createElement("button");p.type="submit",p.className="veo-guide-cta",p.textContent=n.ctaText||"Enviar",c.appendChild(p),l.appendChild(c),l.addEventListener("submit",m=>{m.preventDefault(),d.style.display="none";let u={};for(let{field:h,read:g}of a){let v=g();if(v==null||v===""){if(h.required){d.textContent=`Completa "${h.label}"`,d.style.display="block";return}continue}u[h.key]=v;}if(Object.keys(u).length===0){d.textContent="Responde al menos un campo",d.style.display="block";return}p.disabled=true,(e.onFormSubmit??(()=>Promise.resolve(true)))(u).then(h=>{if(!h){p.disabled=false,d.textContent="No se pudo enviar. Prueba de nuevo.",d.style.display="block";return}e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"completed"});let g=e.isPreview?e.previewNote??"Vista previa: la respuesta NO se guard\xF3.":null;go(o,t,g),window.setTimeout(()=>e.onClose(),g?2200:1400);});}),s.appendChild(l),s.appendChild(pe(t,r)),o.appendChild(s);}function go(o,e,t){for(;o.firstChild;)o.removeChild(o.firstChild);let n=e.createElement("div");if(n.className="veo-form-thanks",n.textContent="\u2713 \xA1Gracias por tu respuesta!",o.appendChild(n),t){let i=e.createElement("p");i.className="veo-form-preview-note",i.textContent=t,o.appendChild(i);}}function yt(o,e){let t=e.createElement("div");t.className="veo-form-field";let n=e.createElement("label");switch(n.className="veo-form-label",n.textContent=o.required?`${o.label} *`:o.label,t.appendChild(n),o.type){case "textarea":{let i=e.createElement("textarea");return i.className="veo-form-input",i.rows=3,o.placeholder&&(i.placeholder=o.placeholder),t.appendChild(i),{wrapper:t,read:()=>i.value.trim()}}case "number":{let i=e.createElement("input");return i.type="number",i.className="veo-form-input",o.placeholder&&(i.placeholder=o.placeholder),t.appendChild(i),{wrapper:t,read:()=>i.value.trim()===""?void 0:Number(i.value)}}case "select":{let i=e.createElement("select");i.className="veo-form-input";let r=e.createElement("option");r.value="",r.textContent=o.placeholder||"Elige una opci\xF3n\u2026",i.appendChild(r);for(let s of o.options??[]){let a=e.createElement("option");a.value=s,a.textContent=s,i.appendChild(a);}return t.appendChild(i),{wrapper:t,read:()=>i.value||void 0}}case "radio":{let i=e.createElement("div");i.className="veo-form-options";let r=`veo-${o.key}`,s=[];for(let a of o.options??[]){let l=e.createElement("label");l.className="veo-form-option";let d=e.createElement("input");d.type="radio",d.name=r,d.value=a,s.push(d);let c=e.createElement("span");c.textContent=a,l.appendChild(d),l.appendChild(c),i.appendChild(l);}return t.appendChild(i),{wrapper:t,read:()=>s.find(a=>a.checked)?.value}}case "multiselect":{let i=e.createElement("div");i.className="veo-form-options";let r=[];for(let s of o.options??[]){let a=e.createElement("label");a.className="veo-form-option";let l=e.createElement("input");l.type="checkbox",l.value=s,r.push(l);let d=e.createElement("span");d.textContent=s,a.appendChild(l),a.appendChild(d),i.appendChild(a);}return t.appendChild(i),{wrapper:t,read:()=>{let s=r.filter(a=>a.checked).map(a=>a.value);return s.length>0?s:void 0}}}case "checkbox":{let i=e.createElement("label");i.className="veo-form-option";let r=e.createElement("input");r.type="checkbox";let s=e.createElement("span");return s.textContent=o.placeholder||"S\xED",i.appendChild(r),i.appendChild(s),t.appendChild(i),{wrapper:t,read:()=>r.checked?true:o.required?"":false}}case "yesno":{let i=e.createElement("div");i.className="veo-form-options";let r=`veo-${o.key}`,[s,a]=o.options?.length===2?o.options:["S\xED","No"],l=[];for(let{label:d,value:c}of [{label:s,value:true},{label:a,value:false}]){let p=e.createElement("label");p.className="veo-form-option";let m=e.createElement("input");m.type="radio",m.name=r,l.push({input:m,value:c});let u=e.createElement("span");u.textContent=d,p.appendChild(m),p.appendChild(u),i.appendChild(p);}return t.appendChild(i),{wrapper:t,read:()=>l.find(d=>d.input.checked)?.value}}case "nps":return gn(t,e,0,10,"veo-nps-btn");case "rating":return gn(t,e,1,5,"veo-rating-btn","\u2605");default:{let i=e.createElement("input");return i.type="text",i.className="veo-form-input",o.placeholder&&(i.placeholder=o.placeholder),t.appendChild(i),{wrapper:t,read:()=>i.value.trim()}}}}function gn(o,e,t,n,i,r){let s=e.createElement("div");s.className="veo-form-scale";let a,l=[];for(let d=t;d<=n;d++){let c=e.createElement("button");c.type="button",c.className=i,c.textContent=r??String(d),c.setAttribute("aria-label",String(d)),c.addEventListener("click",()=>{a=d,l.forEach((p,m)=>{let u=r?m+t<=d:m+t===d;p.classList.toggle("veo-scale-active",u);});}),l.push(c),s.appendChild(c);}return o.appendChild(s),{wrapper:o,read:()=>a}}var vo={left:"flex-start",center:"center",right:"flex-end"},me=class extends w{async render(e){let t=e.nav?.stepIndex??0,n=e.guide.guideSteps[t];if(!n)return;let i=(n.position==="relative-to-element"||n.presentation==="inline")&&n.anchorSelector?.trim()||void 0,r=null;if(i&&(r=await k(i),!r))return;let{host:s,root:a}=this.createHost(),l=a.ownerDocument??document,d=n.design??{};typeof d.zIndex=="number"&&(s.style.zIndex=String(d.zIndex));let c=l.createElement("div");c.className="veo-card",Ro(c,d);let p=(u,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:u,...{}});},m=[];if(this.buildContent(c,n.blocks??[],l,e,t,m),d.closeButton!==false){let u=pe(l,()=>{p("dismissed"),this.closeOrSkip(e);}),f=typeof d.closeColor=="string"?d.closeColor:null,h=typeof d.closeHoverColor=="string"?d.closeHoverColor:null;f&&(u.style.color=f);let g=typeof d.closePosition=="string"?d.closePosition:"top-right";wo(u,g),Co(c,g),h&&(u.addEventListener("mouseenter",()=>{u.style.color=h;}),u.addEventListener("mouseleave",()=>{u.style.color=f??"";})),c.appendChild(u);}if(n.presentation==="inline"&&r){s.style.display="block";let u=yo(n.inlinePosition);a.appendChild(c),A(r,s,u),this.registerCleanup(M(s,i,u));}else if(n.position==="relative-to-element"&&r){if(d.backdrop===true){let h=l.createElement("div");h.className="veo-composite-overlay veo-composite-overlay--dim",typeof d.backdropColor=="string"&&(h.style.background=d.backdropColor);let g=typeof d.backdropZIndex=="number"?d.backdropZIndex:2e5;h.style.zIndex=String(g),a.appendChild(h),d.targetAbove===true&&this.registerCleanup(ko(r,g+1));}let u=l.createElement("div");u.className="veo-composite-anchored";let f=d.caret===false?null:So(l,d);f&&u.appendChild(f),u.appendChild(c),a.appendChild(u),this.registerCleanup(await Eo(r,u,f));}else {let u=l.createElement("div");u.className="veo-composite-overlay",d.backdrop!==false&&(u.classList.add("veo-composite-overlay--dim"),typeof d.backdropColor=="string"&&(u.style.background=d.backdropColor),typeof d.backdropZIndex=="number"&&(u.style.zIndex=String(d.backdropZIndex)),u.addEventListener("click",f=>{f.target===u&&(p("dismissed"),this.closeOrSkip(e));})),bo(c,n.position,d),u.appendChild(c),a.appendChild(u);}e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:"shown"});}buildContent(e,t,n,i,r,s){let a=d=>{i.onInteraction({guideId:i.guide.guideId,stepIndex:r,action:"cta_clicked",...d.id?{metadata:{buttonId:d.id}}:{}});},l=0;for(;l<t.length;){let d=t[l];if(!d){l++;continue}if(d.type==="button"){let p=n.createElement("div");p.className="veo-guide-actions";let m;for(;l<t.length&&t[l]?.type==="button";){let u=t[l];if(!m){let f=u.style?.align;(f==="left"||f==="center"||f==="right")&&(m=f);}p.appendChild(this.buildButton(u,n,i,r,s,a)),l++;}m&&(p.style.justifyContent=vo[m]??"flex-end"),e.appendChild(p);continue}if(d.type==="code"){let{node:p,cleanup:m}=hn(d,n,i);p&&e.appendChild(p),this.registerCleanup(m),l++;continue}if(d.type==="form"){let p=n.createElement("div");p.className="veo-form";for(let m of d.fields??[]){let{wrapper:u,read:f}=yt(m,n);s.push({field:m,read:f}),p.appendChild(u);}e.appendChild(p),l++;continue}let c=nt(d,n);c&&e.appendChild(c),l++;}}buildButton(e,t,n,i,r,s){let a=t.createElement("button");a.type="button",a.className="veo-guide-cta",a.textContent=e.text?.trim()||"OK",we(a,e.style,"button");let l=n.nav?.callbacks;return a.addEventListener("click",()=>{switch(e.action){case "next":s(e),l?l.onNext():n.onClose();break;case "prev":s(e),l?.onBack();break;case "url":s(e),typeof e.url=="string"&&R(e.url)&&window.open(e.url,"_blank","noopener,noreferrer");break;case "guide":s(e),e.targetGuideId&&n.onOpenGuide?.(e.targetGuideId),this.closeOrSkip(n);break;case "submit-forms":case "submit-forms-advance":case "submit-forms-goto":this.submitForms(r,n,i,a,()=>{s(e),e.action==="submit-forms"||!l?n.onClose():e.action==="submit-forms-goto"&&typeof e.targetStep=="number"&&l.onGoto?l.onGoto(e.targetStep):l.onNext();});break;default:s(e),this.closeOrSkip(n);}}),a}submitForms(e,t,n,i,r){let s={};for(let{field:l,read:d}of e){let c=d();if(c==null||c===""){if(l.required){i.textContent=`Completa "${l.label}"`;return}continue}s[l.key]=c;}if(e.length>0&&Object.keys(s).length===0)return;i.disabled=true,(t.onFormSubmit??(()=>Promise.resolve(true)))(s).then(l=>{i.disabled=false,l&&(t.onInteraction({guideId:t.guide.guideId,stepIndex:n,action:"completed"}),r());});}closeOrSkip(e){e.nav?.callbacks?e.nav.callbacks.onSkip():e.onClose();}};function yo(o){return o==="before"||o==="prepend"||o==="append"?o:"after"}function bo(o,e,t){let n=o.style;n.position="fixed";let i="16px",r=t.hAlign==="left"?"left":t.hAlign==="right"?"right":null,s=e.includes("top")?"top":e.includes("bottom")?"bottom":"middle",a=r??(e.includes("left")?"left":e.includes("right")?"right":"middle");s==="top"?n.top=i:s==="bottom"?n.bottom=i:n.top="50%",a==="left"?n.left=i:a==="right"?n.right=i:n.left="50%";let l=a==="middle"?"-50%":"0",d=s==="middle"?"-50%":"0";n.transform=l==="0"&&d==="0"?"":`translate(${l}, ${d})`;}var vn="10px";function wo(o,e){let t=o.style;t.top="auto",t.right="auto",t.bottom="auto",t.left="auto";let n=e.includes("bottom")?"bottom":"top",i=e.includes("left")?"left":"right";t.setProperty(n,vn),t.setProperty(i,vn);}var xo="34px";function Co(o,e){let t=Array.from(o.children).filter(i=>i instanceof HTMLElement&&!i.classList.contains("veo-guide-close"));if(t.length===0)return;let n=e.includes("bottom")?t[t.length-1]:t[0];n&&(n.style[e.includes("left")?"paddingLeft":"paddingRight"]=xo);}function So(o,e){let t=o.createElement("div");t.className="veo-composite-caret";let n=typeof e.caretWidth=="number"?e.caretWidth:12,i=typeof e.caretHeight=="number"?e.caretHeight:12,r=t.style;if(r.position="absolute",r.width=`${n}px`,r.height=`${i}px`,r.transform="rotate(45deg)",r.background=typeof e.background=="string"?e.background:"#ffffff",typeof e.borderWidth=="number"&&e.borderWidth>0){let s=typeof e.borderColor=="string"?e.borderColor:"#bbbbbb";r.border=`${e.borderWidth}px solid ${s}`;}return t}function ko(o,e){let t=o,n=t.style.position,i=t.style.zIndex;return getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.style.zIndex=String(e),()=>{t.style.position=n,t.style.zIndex=i;}}async function Eo(o,e,t){let n=async()=>{let{x:r,y:s,placement:a,middlewareData:l}=await z(o,e,{placement:"bottom",strategy:"fixed",middleware:[H(t?10:8),W(),D({padding:8}),...t?[ee({element:t})]:[]]});e.style.left=`${r}px`,e.style.top=`${s}px`,t&&te(t,a,l.arrow);};await n();let i=()=>{n();};return window.addEventListener("scroll",i,true),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,true),window.removeEventListener("resize",i);}}function Ro(o,e){let t=o.style,n=a=>typeof a=="number"&&Number.isFinite(a)?`${a}px`:null,i=a=>typeof a=="string"&&a?a:null;i(e.background)&&(t.background=e.background);let r=i(e.color)??i(e.textColor);r&&(t.color=r),n(e.fontSize)&&(t.fontSize=n(e.fontSize)),i(e.fontWeight)&&(t.fontWeight=e.fontWeight),i(e.fontFamily)&&e.fontFamily!=="inherit"&&(t.fontFamily=e.fontFamily),i(e.textTransform)&&e.textTransform!=="none"&&(t.textTransform=e.textTransform),typeof e.letterSpacing=="number"&&(t.letterSpacing=`${e.letterSpacing}px`),i(e.align)&&(t.textAlign=e.align),typeof e.lineHeight=="number"&&(t.lineHeight=`${e.lineHeight}%`),n(e.radius)&&(t.borderRadius=n(e.radius));let s=n(e.borderWidth);if(s&&(t.border=`${s} solid ${i(e.borderColor)??"#e5e5e5"}`),i(e.shadowColor)||typeof e.shadowBlur=="number"){let a=l=>typeof e[l]=="number"?e[l]:0;t.boxShadow=`${a("shadowX")}px ${a("shadowY")}px ${a("shadowBlur")}px ${a("shadowSpread")}px ${i(e.shadowColor)??"rgba(0,0,0,0.2)"}`;}e.fullWidth===true?t.width="100%":e.widthType==="fluid"?(t.width="auto",n(e.width)&&(t.maxWidth=n(e.width))):n(e.width)&&(t.width=n(e.width));for(let a of ["Top","Right","Bottom","Left"]){let l=n(e[`padding${a}`]);l&&t.setProperty(`padding-${a.toLowerCase()}`,l);let d=n(e[`margin${a}`]);d&&t.setProperty(`margin-${a.toLowerCase()}`,d);}}var Io={mode:"floating",position:"bottom-right"},yn=16,To=360,ke=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let n=t.placement??Io,i=null;if(n.mode==="anchored"){let c=n.selector??t.selector??e.guide.activationRules.selector;if(typeof c!="string"||c.length===0||(i=await k(c),!i))return}let{root:r}=this.createHost(),s=r.ownerDocument??document,a=s.createElement("div");a.className=n.mode==="anchored"?"veo-custom-anchored":"veo-custom-floating";let{iframe:l,cleanup:d}=Se(s,t,e,{width:vt(n.width??To),fixedHeight:n.height??null});this.registerCleanup(d),a.appendChild(l),r.appendChild(a),n.mode==="floating"?Po(a,n):i&&this.registerCleanup(await this.setupAnchoredPosition(i,a,n)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}async setupAnchoredPosition(e,t,n){let i=n.side??"bottom",r=async()=>{let{x:a,y:l}=await z(e,t,{placement:i,strategy:"fixed",middleware:[H(n.offsetY??8),W(),D({padding:8})]});t.style.left=`${a}px`,t.style.top=`${l}px`;};await r();let s=()=>{r();};return window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}}};function Po(o,e){let t=e.position??"bottom-right",n=`${e.offsetX??yn}px`,i=`${e.offsetY??yn}px`,r=o.style;if(t==="center"){r.top="50%",r.left="50%",r.transform="translate(-50%, -50%)";return}let[s,a]=t.split("-");s==="top"?r.top=i:r.bottom=i,a==="left"?r.left=n:a==="right"?r.right=n:(r.left="50%",r.transform="translateX(-50%)");}var Ee=class extends w{render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let{root:n}=this.createHost();this.applyDesign(t.style);let i=n.ownerDocument??document,r=i.createElement("div");r.className="veo-modal-overlay";let s=i.createElement("div");s.className="veo-modal-card",ot(s,e,i),r.appendChild(s),n.appendChild(r);let a=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();};r.addEventListener("click",d=>{d.target===r&&a();});let l=d=>{d.key==="Escape"&&a();};document.addEventListener("keydown",l),this.registerCleanup(()=>document.removeEventListener("keydown",l)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Re=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return;let i=await k(n);if(!i)return;let{host:r,root:s}=this.createHost();r.style.display="block";let a=K(t.style);A(i,r,a),this.registerCleanup(M(r,n,a));let l=s.ownerDocument??document,d=l.createElement("div");d.className="veo-custom-inline";let{iframe:c,cleanup:p}=Se(l,t,e,{width:"100%"});this.registerCleanup(p),d.appendChild(c),s.appendChild(d),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Ie=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return;let i=await k(n);if(!i)return;let{host:r,root:s}=this.createHost();r.style.display="block";let a=K(t.style);A(i,r,a),this.registerCleanup(M(r,n,a)),this.applyDesign(t.style);let l=s.ownerDocument??document,d=l.createElement("div");d.className="veo-inline",ot(d,e,l),s.appendChild(d),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Te=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return;let i=await k(n);if(!i)return;let{host:r,root:s}=this.createHost();r.style.display="block";let a=K(t.style);A(i,r,a),this.registerCleanup(M(r,n,a)),this.applyDesign(t.style);let l=s.ownerDocument??document,d=l.createElement("div");d.className="veo-inline";let c=(m,u,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:m,...f?{metadata:f}:{}}),u&&window.open(u,"_blank","noopener,noreferrer"),e.onClose();},p=P(t,l,{onCtaClick:(m,u,f)=>{c("cta_clicked",m==="url"?u:void 0,f),m==="guide"&&u&&e.onOpenGuide?.(u);},onDismiss:()=>c("dismissed")});d.appendChild(p),s.appendChild(d),this.liveContainer=d,this.liveContent=p,this.liveKey=`${n}|${a}`,this.liveBuild=m=>P(m,l,{onCtaClick:(u,f,h)=>{c("cta_clicked",u==="url"?f:void 0,h),u==="guide"&&f&&e.onOpenGuide?.(f);},onDismiss:()=>c("dismissed")}),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}liveKeyOf(e){return `${e.selector??""}|${K(e.style)}`}};function bn(o){return o.style?.backdrop===false?"veo-modal-overlay veo-modal-overlay--none":"veo-modal-overlay"}var oe=class extends w{constructor(){super(...arguments);this.overlay=null;}render(t){let n=t.nav?.stepIndex??0,i=t.guide.guideSteps[n];if(!i)return;let{root:r}=this.createHost();this.applyDesign(i.style);let s=r.ownerDocument??document,a=s.createElement("div");a.className=bn(i),this.overlay=a;let l=s.createElement("div");l.className="veo-modal-card";let d=(u,f,h)=>{t.onInteraction({guideId:t.guide.guideId,stepIndex:n,action:u,...h?{metadata:h}:{}}),f&&window.open(f,"_blank","noopener,noreferrer"),t.onClose();},c=()=>{t.nav?t.nav.callbacks.onSkip():d("dismissed");},p=t.nav?Ce(i,t.nav.stepIndex,t.nav.totalSteps,s,t.nav.callbacks):P(i,s,{onCtaClick:(u,f,h)=>{d("cta_clicked",u==="url"?f:void 0,h),u==="guide"&&f&&t.onOpenGuide?.(f);},onDismiss:()=>d("dismissed")});l.appendChild(p),a.appendChild(l),r.appendChild(a),t.nav||(this.liveContainer=l,this.liveContent=p,this.liveBuild=u=>P(u,s,{onCtaClick:(f,h,g)=>{d("cta_clicked",f==="url"?h:void 0,g),f==="guide"&&h&&t.onOpenGuide?.(h);},onDismiss:()=>d("dismissed")})),a.addEventListener("click",u=>{u.target===a&&c();});let m=u=>{u.key==="Escape"&&c();};document.addEventListener("keydown",m),this.registerCleanup(()=>document.removeEventListener("keydown",m)),t.nav||t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"shown"});}onLiveUpdate(t){this.overlay&&(this.overlay.className=bn(t));}destroy(){this.overlay=null,super.destroy();}};var Pe=class extends w{constructor(){super(...arguments);this.side="bottom";this.reposition=null;}async render(t){let n=t.guide.guideSteps[0];if(!n)return;let i=n.selector??t.guide.activationRules.selector;if(typeof i!="string"||i.length===0)return;let r=await k(i);if(!r)return;let s=n.style?.tooltipPlacement;this.side=s==="top"||s==="left"||s==="right"?s:"bottom";let{root:a}=this.createHost();this.applyDesign(n.style);let l=a.ownerDocument??document,d=l.createElement("div");d.className="veo-tooltip";let c=(h,g,v)=>{t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:h,...v?{metadata:v}:{}}),g&&window.open(g,"_blank","noopener,noreferrer"),t.onClose();},p=P(n,l,{onCtaClick:(h,g,v)=>{c("cta_clicked",h==="url"?g:void 0,v),h==="guide"&&g&&t.onOpenGuide?.(g);},onDismiss:()=>c("dismissed")});d.appendChild(p);let m=l.createElement("div");m.className="veo-tooltip-arrow",d.appendChild(m),a.appendChild(d);let u=async()=>{let{x:h,y:g,placement:v,middlewareData:b}=await z(r,d,{placement:this.side,middleware:[H(10),W(),D({padding:8}),ee({element:m})]});d.style.left=`${h}px`,d.style.top=`${g}px`,te(m,v,b.arrow);};await u();let f=()=>{u();};this.reposition=f,window.addEventListener("scroll",f,true),window.addEventListener("resize",f),this.registerCleanup(()=>{window.removeEventListener("scroll",f,true),window.removeEventListener("resize",f);}),this.liveContainer=d,this.liveContent=p,this.liveKey=i,this.liveBuild=h=>P(h,l,{onCtaClick:(g,v,b)=>{c("cta_clicked",g==="url"?v:void 0,b),g==="guide"&&v&&t.onOpenGuide?.(v);},onDismiss:()=>c("dismissed")}),t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"shown"});}liveKeyOf(t){return t.selector??""}onLiveUpdate(t){let n=t.style?.tooltipPlacement;this.side=n==="top"||n==="left"||n==="right"?n:"bottom",this.reposition?.();}};var Ae=class extends w{async render(e){let t=e.guide.guideSteps[e.currentStepIndex];if(!t)return false;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return false;let i=await k(n,5e3);if(!i)return false;let r=t.style?.tooltipPlacement,s=r==="top"||r==="left"||r==="right"?r:"bottom",{root:a}=this.createHost();this.applyDesign(t.style);let l=a.ownerDocument??document,d=l.createElement("div");d.className="veo-walkthrough";let c=Ce(t,e.currentStepIndex,e.guide.guideSteps.length,l,e.callbacks);d.appendChild(c);let p=l.createElement("div");p.className="veo-walkthrough-arrow",d.appendChild(p),a.appendChild(d);let m=async()=>{let{x:f,y:h,placement:g,middlewareData:v}=await z(i,d,{placement:s,middleware:[H(10),W(),D({padding:8}),ee({element:p})]});d.style.left=`${f}px`,d.style.top=`${h}px`,te(p,g,v.arrow);};await m();let u=()=>{m();};return window.addEventListener("scroll",u,true),window.addEventListener("resize",u),this.registerCleanup(()=>{window.removeEventListener("scroll",u,true),window.removeEventListener("resize",u);}),true}};function Ao(o,e){switch(o.type){case "exact":return o.pattern===e;case "prefix":return e.startsWith(o.pattern);case "regex":try{return new RegExp(o.pattern).test(e)}catch{return false}}}function it(o,e){return !o||o.scope==="sitewide"||!o.pattern?true:Ao({type:o.matchType??"prefix",pattern:o.pattern},e)}var rt=class{constructor(e){this.state=null;this.storageKey=`${kt}${e}`,this.state=this.load(),this.state&&this.isAbandoned(this.state)&&this.clear();}current(){return this.state?this.isAbandoned(this.state)?(this.clear(),null):this.state:null}hasActive(){return this.current()!==null}start(e,t){let n=Date.now();return this.state={guideId:e,totalSteps:t,currentStepIndex:0,startedAt:n,lastProgressAt:n},this.persist(),this.state}advance(){if(!this.state)return null;let e=this.state.currentStepIndex+1;return e>=this.state.totalSteps?null:(this.state={...this.state,currentStepIndex:e,lastProgressAt:Date.now()},this.persist(),this.state)}back(){return this.state?this.state.currentStepIndex===0?this.state:(this.state={...this.state,currentStepIndex:this.state.currentStepIndex-1,lastProgressAt:Date.now()},this.persist(),this.state):null}clear(){if(this.state=null,!(typeof localStorage>"u"))try{localStorage.removeItem(this.storageKey);}catch{}}isAbandoned(e){return Date.now()-e.lastProgressAt>18e5}load(){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem(this.storageKey);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;return typeof n.guideId!="string"||typeof n.totalSteps!="number"||typeof n.currentStepIndex!="number"||typeof n.startedAt!="number"||typeof n.lastProgressAt!="number"?null:n}catch{return null}}persist(){if(!(typeof localStorage>"u"||!this.state))try{localStorage.setItem(this.storageKey,JSON.stringify(this.state));}catch{}}};var Go=3e4,No={shown:"shown",dismissed:"dismissed",cta_clicked:null,step_advanced:null,step_back:null,completed:"completed"},st=class{constructor(e,t){this.client=e;this.activeRenderers=new Set;this.activeByGuideId=new Map;this.dispatched=new Set;this.activeWalkthroughRenderer=null;this.activeWalkthroughGuide=null;this.resolveCache=null;this.inflightResolve=null;this.armedTriggers=new Map;this.pendingComposite=null;if(this.debug=t.debug===true,this.apiUrl=t.apiUrl,this.apiKey=t.apiKey,this.resolver=t.resolver??new ze(t.apiUrl,t.apiKey,this.debug),t.trackerQueue)this.trackerQueue=t.trackerQueue;else {let i=new Ue(t.apiUrl,t.apiKey);this.trackerQueue=new Ke({client:i,flushIntervalMs:3e3,batchSize:5,maxRetries:3,onError:(r,s)=>{this.debug&&console.warn(`[veo] dropped guide interaction after retries: guideId=${s.guideId} action=${s.payload.action}`,r);}});}let n=It(t.apiKey);this.frequencyCache=t.frequencyCache??new We(n),this.walkthroughState=t.walkthroughState??new rt(n);}get pendingInteractions(){return this.trackerQueue.size}clearFrequencyCache(){this.frequencyCache.clear();}clearWalkthroughState(){this.tearDownWalkthrough();}async checkGuides(e,t){let n=this.client.getEndUserId();if(!n){this.debug&&console.log("[veo] guides: skipped, no endUserId yet");return}if(await this.tryResumeWalkthrough(n,t,e))return;this.tryResumeComposite(t,e);let i;try{i=await this.resolveGuides(n,e);}catch(r){this.debug&&console.error("[veo] guides resolver threw:",r);return}this.debug&&console.log(`[veo] guides: ${i.length} eligible at ${e}`),this.disarmTriggers();for(let r of i){let s=r.activationRules.trigger;if((s==="on_click"||s==="on_hover")&&r.activationRules.selector){this.armInteractionTrigger(r,n,t,e);continue}await this.showGuide(r,n,t,e);}}async showGuide(e,t,n,i){if(this.frequencyCache.shouldFilter(e.guideId,e.displayFrequency)){this.debug&&console.log(`[veo] guides: filtered locally guideId=${e.guideId}`);return}if(this.activeByGuideId.has(e.guideId)){this.debug&&console.log(`[veo] guides: already shown guideId=${e.guideId}`);return}if(e.guideType==="walkthrough"&&e.guideSteps.length>1){if(this.walkthroughState.hasActive()){this.debug&&console.log(`[veo] guides: walkthrough ${e.guideId} skipped (another active)`);return}await this.startWalkthrough(e,t,n,i);return}if(e.guideType==="composite"){this.startComposite(e,n,i);return}this.runSingleStepRender(e,n,i);}armInteractionTrigger(e,t,n,i){if(this.frequencyCache.shouldFilter(e.guideId,e.displayFrequency)||this.activeByGuideId.has(e.guideId)||this.armedTriggers.has(e.guideId))return;let r=e.activationRules.selector,s=e.activationRules.trigger==="on_hover"?"mouseover":"click",a=d=>{let c=d.target;if(c instanceof Element){try{if(!c.closest(r))return}catch{return}l(),this.showGuide(e,t,n,i);}},l=()=>{document.removeEventListener(s,a,true),this.armedTriggers.delete(e.guideId);};document.addEventListener(s,a,true),this.armedTriggers.set(e.guideId,l),this.debug&&console.log(`[veo] guides: armed ${s} trigger for ${e.guideId} on ${r}`);}disarmTriggers(){for(let e of this.armedTriggers.values())e();this.armedTriggers.clear();}async resolveGuides(e,t){let n=`${e}
|
|
427
|
-
${t}`,i=Date.now();if(this.resolveCache?.key===n&&i-this.resolveCache.at<Go)return this.debug&&console.log("[veo] guides: resolve cache hit"),this.resolveCache.guides;if(this.inflightResolve?.key===n)return this.inflightResolve.promise;let r=this.resolver.resolve(e,t);this.inflightResolve={key:n,promise:r};try{let s=await r;return this.resolveCache={key:n,at:Date.now(),guides:s},s}finally{this.inflightResolve?.key===n&&(this.inflightResolve=null);}}destroy(){for(let e of this.activeRenderers)try{e.destroy();}catch(t){this.debug&&console.error("[veo] renderer destroy failed:",t);}if(this.activeRenderers.clear(),this.activeByGuideId.clear(),this.activeWalkthroughRenderer){try{this.activeWalkthroughRenderer.destroy();}catch{}this.activeWalkthroughRenderer=null,this.activeWalkthroughGuide=null;}this.disarmTriggers(),this.dispatched.clear(),this.resolveCache=null,this.inflightResolve=null,this.trackerQueue.destroy();}runSingleStepRender(e,t,n){let i=this.createSingleStepRenderer(e.guideType);if(!i)return;this.activeByGuideId.set(e.guideId,i);let r=e.activationRules.delayMs??0;window.setTimeout(()=>this.mountSingleStepRenderer(e,i,t,n),r);}startComposite(e,t,n){if(this.pendingComposite?.guide.guideId===e.guideId)return;let r=e.guideSteps.findIndex(s=>it(s.pageLocation,n));r!==-1&&this.renderCompositeStep(e,r,t,n);}tryResumeComposite(e,t){let n=this.pendingComposite;if(!n)return false;let r=n.guide.guideSteps[n.stepIndex];return r?it(r.pageLocation,t)?(this.pendingComposite=null,this.renderCompositeStep(n.guide,n.stepIndex,e,t),true):false:(this.pendingComposite=null,false)}renderCompositeStep(e,t,n,i){let r=e.guideSteps,s=new me;this.activeRenderers.add(s),this.activeByGuideId.set(e.guideId,s);let a=()=>{s.destroy(),this.activeRenderers.delete(s),this.activeByGuideId.get(e.guideId)===s&&this.activeByGuideId.delete(e.guideId);},l=c=>{if(a(),c<0||c>=r.length)return;let p=r[c];p&&it(p.pageLocation,i)?this.renderCompositeStep(e,c,n,i):this.pendingComposite={guide:e,stepIndex:c};},d=r.length>1?{stepIndex:t,totalSteps:r.length,callbacks:{onNext:()=>l(t+1),onBack:()=>l(t-1),onGoto:c=>l(c),onSkip:a,onComplete:a}}:void 0;try{s.render({guide:e,onInteraction:c=>this.handleInteraction(e,n,i,c),onClose:a,onTrack:(c,p)=>this.client.track(c,p),onFormSubmit:c=>this.submitFormResponse(e.guideId,c),onOpenGuide:c=>{this.openGuideById(c,n,i);},...d?{nav:d}:{}});}catch(c){this.debug&&console.error("[veo] composite renderer threw:",c),a();}}mountSingleStepRenderer(e,t,n,i){this.activeRenderers.add(t),this.activeByGuideId.set(e.guideId,t);let r=()=>{t.destroy(),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);},s=c=>{this.handleInteraction(e,n,i,c);},a=(c,p)=>{this.client.track(c,p);},l=c=>this.submitFormResponse(e.guideId,c),d=c=>{this.openGuideById(c,n,i);};try{t.render({guide:e,onInteraction:s,onClose:r,onTrack:a,onFormSubmit:l,onOpenGuide:d});}catch(c){this.debug&&console.error("[veo] renderer.render threw:",c),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);}}async openGuideById(e,t,n){if(this.activeByGuideId.has(e))return;let i=await this.resolver.fetchById(e);if(!i){this.debug&&console.warn(`[veo] guides: chained guide ${e} not found`);return}let r=this.client.getEndUserId()??this.client.getAnonymousId();if(i.guideType==="walkthrough"&&i.guideSteps.length>1){this.walkthroughState.hasActive()||await this.startWalkthrough(i,r,t,n);return}this.runSingleStepRender(i,t,n);}async tryResumeWalkthrough(e,t,n){let i=this.walkthroughState.current();if(!i)return false;let r=await this.resolver.fetchById(i.guideId);if(!r||r.guideType!=="walkthrough")return this.debug&&console.log(`[veo] guides: walkthrough ${i.guideId} no longer available, cleaning up`),this.tearDownWalkthrough(),true;let s=Math.min(i.currentStepIndex,r.guideSteps.length-1);return await this.renderWalkthroughStep(r,s,e,t,n),true}async startWalkthrough(e,t,n,i){this.walkthroughState.start(e.guideId,e.guideSteps.length),await this.renderWalkthroughStep(e,0,t,n,i)&&(this.enqueueInteractionOnce(e.guideId,t,n,i,"shown",0),this.frequencyCache.record(e.guideId,"shown"));}async renderWalkthroughStep(e,t,n,i,r){this.activeWalkthroughRenderer&&(this.activeWalkthroughRenderer.destroy(),this.activeWalkthroughRenderer=null),this.activeWalkthroughGuide=e;let s={onNext:()=>this.handleWalkthroughNext(n,i,r),onBack:()=>this.handleWalkthroughBack(n,i,r),onSkip:()=>this.handleWalkthroughSkip(n,i,r),onComplete:()=>this.handleWalkthroughComplete(n,i,r)},a=e.guideSteps[t],l=Mo(a);if(l==="modal"||l==="banner"){let p=l==="modal"?new oe:new ne;try{p.render({guide:e,onInteraction:()=>{},onClose:()=>{},nav:{stepIndex:t,totalSteps:e.guideSteps.length,callbacks:s}});}catch(m){return this.debug&&console.error("[veo] sequence renderer threw:",m),this.tearDownWalkthrough(),false}return this.activeWalkthroughRenderer=p,true}let d=new Ae,c=false;try{c=await d.render({guide:e,currentStepIndex:t,callbacks:s});}catch(p){this.debug&&console.error("[veo] walkthrough renderer threw:",p);}return c?(this.activeWalkthroughRenderer=d,true):(this.debug&&console.warn(`[veo] walkthrough ${e.guideId} step ${t} could not render, cancelling`),this.tearDownWalkthrough(),false)}handleWalkthroughNext(e,t,n){let i=this.activeWalkthroughGuide;if(!i)return;let r=this.walkthroughState.advance();if(!r){this.handleWalkthroughComplete(e,t,n);return}this.enqueueInteraction(i.guideId,e,t,n,"step_advanced",r.currentStepIndex),this.renderWalkthroughStep(i,r.currentStepIndex,e,t,n);}handleWalkthroughBack(e,t,n){let i=this.activeWalkthroughGuide;if(!i)return;let r=this.walkthroughState.current();if(!r||r.currentStepIndex===0)return;let s=this.walkthroughState.back();s&&(this.enqueueInteraction(i.guideId,e,t,n,"step_back",s.currentStepIndex),this.renderWalkthroughStep(i,s.currentStepIndex,e,t,n));}handleWalkthroughSkip(e,t,n){let i=this.activeWalkthroughGuide,r=this.walkthroughState.current();!i||!r||(this.enqueueInteraction(i.guideId,e,t,n,"dismissed",r.currentStepIndex),this.frequencyCache.record(i.guideId,"dismissed"),this.tearDownWalkthrough());}handleWalkthroughComplete(e,t,n){let i=this.activeWalkthroughGuide,r=this.walkthroughState.current();!i||!r||(this.enqueueInteraction(i.guideId,e,t,n,"completed",r.currentStepIndex),this.frequencyCache.record(i.guideId,"completed"),this.tearDownWalkthrough());}tearDownWalkthrough(){if(this.activeWalkthroughRenderer)try{this.activeWalkthroughRenderer.destroy();}catch{}this.activeWalkthroughRenderer=null,this.activeWalkthroughGuide=null,this.walkthroughState.clear();}handleInteraction(e,t,n,i){let r=i.metadata?.buttonId?`:${i.metadata.buttonId}`:"",s=`${e.guideId}:${i.action}${r}`;if(this.dispatched.has(s)){this.debug&&console.log(`[veo] guides: dedup hit ${s}`);return}this.dispatched.add(s);let a=No[i.action];a&&this.frequencyCache.record(e.guideId,a);let l=this.client.getEndUserId();if(!l){this.debug&&console.warn("[veo] guides: interaction without endUserId \u2014 skipping enqueue");return}this.trackerQueue.enqueue({guideId:e.guideId,payload:{endUserId:l,sessionId:t,action:i.action,stepIndex:i.stepIndex,pageUrl:n,pagePath:wn(n),...i.metadata?{metadata:i.metadata}:{}}});}enqueueInteraction(e,t,n,i,r,s){this.trackerQueue.enqueue({guideId:e,payload:{endUserId:t,sessionId:n,action:r,stepIndex:s,pageUrl:i,pagePath:wn(i)}});}enqueueInteractionOnce(e,t,n,i,r,s){let a=`${e}:${r}:${s}`;this.dispatched.has(a)||(this.dispatched.add(a),this.enqueueInteraction(e,t,n,i,r,s));}createSingleStepRenderer(e){switch(e){case "modal":return new oe;case "banner":return new ne;case "tooltip":return new Pe;case "custom":return new ke;case "inline":return new Te;case "inline-custom":return new Re;case "form":return new Ee;case "inline-form":return new Ie;case "badge":return new xe;case "composite":return new me;case "walkthrough":return null;default:return null}}async submitFormResponse(e,t){let n=this.client.getEndUserId()??this.client.getAnonymousId();try{let i=await fetch(`${this.apiUrl}/v1/guides/${e}/form-response`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.apiKey},body:JSON.stringify({endUserId:n,answers:t})});return !i.ok&&this.debug&&console.warn("[veo] form-response respondi\xF3",i.status),i.ok}catch(i){return this.debug&&console.warn("[veo] form-response fall\xF3:",i),false}}};function wn(o){try{return new URL(o).pathname}catch{return "/"}}function Mo(o){let e=o?.style?.render;return typeof e=="string"?e:"walkthrough"}var Oo="__veo_preview__",bt=class{constructor(){this.singleStep=null;this.walkthrough=null;this.walkthroughGuide=null;this.walkthroughIndex=0;this.input=null;}preview(e){let t=e.guideSteps[0];if(this.singleStep&&this.input&&e.guideType===this.input.guideType&&e.guideType!=="walkthrough"&&t&&this.singleStep.updateStep(t))return this.input=e,{close:()=>this.close(),ready:Promise.resolve({rendered:true}),host:()=>this.activeHost()};this.close(),this.input=e;let n=_o(e),i=typeof e.startStepIndex=="number"?e.startStepIndex:0;if(n.guideType==="composite"){let s=Math.min(Math.max(0,i),n.guideSteps.length-1),a=n.guideSteps[s];a&&(n.guideSteps=[a]);let l=this.renderSingleStep(n);return {close:()=>this.close(),ready:l,host:()=>this.activeHost()}}let r=n.guideType==="walkthrough"?this.startWalkthrough(n,i):this.renderSingleStep(n);return {close:()=>this.close(),ready:r,host:()=>this.activeHost()}}activeHost(){return this.singleStep?this.singleStep.hostElement():this.walkthrough instanceof w?this.walkthrough.hostElement():null}close(){this.singleStep&&(he(this.singleStep),this.singleStep=null),this.walkthrough&&(he(this.walkthrough),this.walkthrough=null),this.walkthroughGuide=null,this.walkthroughIndex=0,this.input=null;}async renderSingleStep(e){let t=Bo(e.guideType);if(!t)return {rendered:false};this.singleStep=t;let n=false;try{await t.render({guide:e,onInteraction:i=>{i.action==="shown"&&(n=!0);},onClose:()=>this.close(),onTrack:()=>{},onOpenGuide:()=>{},onFormSubmit:this.input?.formSubmit??(()=>Promise.resolve(!0)),isPreview:!0,...this.input?.formSubmit&&this.input.formSubmitNote!==void 0?{previewNote:this.input.formSubmitNote}:{}});}catch{return this.close(),{rendered:false}}return this.singleStep!==t?(he(t),{rendered:false}):{rendered:n}}async startWalkthrough(e,t=0){if(e.guideSteps.length===0)return {rendered:false};this.walkthroughGuide=e;let n=Math.min(Math.max(0,Math.floor(t)),e.guideSteps.length-1);return this.walkthroughIndex=n,{rendered:await this.renderWalkthroughStep(n)}}async renderWalkthroughStep(e){let t=this.walkthroughGuide;if(!t)return false;this.walkthrough&&(he(this.walkthrough),this.walkthrough=null);let n={onNext:()=>{let l=this.walkthroughIndex+1;if(l>=t.guideSteps.length){this.close();return}this.walkthroughIndex=l,this.renderWalkthroughStep(l);},onBack:()=>{let l=this.walkthroughIndex-1;l<0||(this.walkthroughIndex=l,this.renderWalkthroughStep(l));},onSkip:()=>this.close(),onComplete:()=>this.close()},r=t.guideSteps[e]?.style?.render;if(r==="modal"||r==="banner"){let l=r==="modal"?new oe:new ne;try{l.render({guide:t,onInteraction:()=>{},onClose:()=>this.close(),nav:{stepIndex:e,totalSteps:t.guideSteps.length,callbacks:n}});}catch{return he(l),false}return this.walkthroughGuide!==t?(he(l),false):(this.walkthrough=l,true)}let s=new Ae,a=false;try{a=await s.render({guide:t,currentStepIndex:e,callbacks:n});}catch{a=false;}return !a||this.walkthroughGuide!==t?(he(s),false):(this.walkthrough=s,true)}},at=null;function lt(o){return De()?(at||(at=new bt),at.preview(o)):{close:()=>{},ready:Promise.resolve({rendered:false}),host:()=>null}}function xn(){at?.close();}function _o(o){let e=o.activationRules?.selector,t={url:o.activationRules?.url??{type:"prefix",pattern:"/"},trigger:"immediate",...e!==void 0?{selector:e}:{}};return {guideId:Oo,guideName:o.guideName??"Preview",guideType:o.guideType,guideSteps:o.guideSteps,activationRules:t,displayFrequency:"always",displayPriority:0}}function Bo(o){switch(o){case "modal":return new oe;case "banner":return new ne;case "tooltip":return new Pe;case "custom":return new ke;case "inline":return new Te;case "inline-custom":return new Re;case "form":return new Ee;case "inline-form":return new Ie;case "badge":return new xe;case "composite":return new me;case "walkthrough":return null;default:return null}}function he(o){try{o.destroy();}catch{}}var dt=null;async function Cn(o){if(!De())return null;dt?.teardown();let e=null;try{let a=await fetch(`${o.apiUrl}/v1/guides/preview-resolve`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":o.apiKey},body:JSON.stringify({token:o.token})});a.ok?e=(await a.json()).guide??null:o.debug&&console.warn("[veo] preview-resolve respondi\xF3",a.status);}catch(a){o.debug&&console.warn("[veo] preview-resolve fall\xF3:",a);}let t=async a=>{if(!e)return false;let l=window.veo,d=l?.getEndUserId?.()??l?.getAnonymousId?.()??null;if(!d)return false;try{return (await fetch(`${o.apiUrl}/v1/guides/${e.guideId}/form-response`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":o.apiKey},body:JSON.stringify({endUserId:d,answers:a})})).ok}catch{return false}},n=null,i=()=>{e&&(n?.close(),n=lt({guideType:e.guideType,guideSteps:e.guideSteps,activationRules:e.activationRules,guideName:e.guideName,formSubmit:t,formSubmitNote:"Vista previa: guardado en TU usuario para probar el flujo."}));},r=Fo({label:e?`Vista previa: ${e.guideName}`:"Link de preview inv\xE1lido o vencido",error:!e,onReshow:e?i:null,onClose:()=>s.teardown()}),s={teardown(){n?.close(),n=null,r.remove(),dt===s&&(dt=null);}};return dt=s,i(),s}function Fo(o){let e=document.createElement("div");e.setAttribute("data-veo-preview-chip","");let t=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=`
|
|
426
|
+
`,o.length>co)return o}}}catch{return o}return o}function po(){if(typeof document>"u")return "";try{let o=document.documentElement,e=[];for(let t of ["class","style","data-theme","data-mode","data-color-mode"]){let n=o.getAttribute(t);n&&n.length<=1e3&&!/["<>]/.test(n)&&e.push(`${t}="${n}"`);}return e.join(" ")}catch{return ""}}function fo(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function mo(o,e,t,n,i){let r=`(function(){var T=${JSON.stringify(n)};function P(m){m.__veo=T;parent.postMessage(m,'*');}window.veo={dismiss:function(){P({type:'dismiss'});},cta:function(u){P({type:'cta',url:u});},track:function(n,p){P({type:'track',name:n,props:p||{}});},navigate:function(u){P({type:'navigate',url:u});}};document.addEventListener('click',function(e){var a=e.target&&e.target.closest?e.target.closest('a[href]'):null;if(!a)return;var h=a.getAttribute('href');if(!h||h.charAt(0)==='#'||/^(javascript|mailto|tel):/i.test(h))return;e.preventDefault();if(a.target==='_blank'){P({type:'cta',url:a.href,close:false});}else{P({type:'navigate',url:h});}},true);function H(){var r=document.getElementById('__veo_root');var h=r?r.getBoundingClientRect().height:document.documentElement.scrollHeight;P({type:'resize',height:Math.ceil(h)});}window.addEventListener('load',H);try{if(typeof ResizeObserver!=='undefined'){var _r=document.getElementById('__veo_root');new ResizeObserver(H).observe(_r||document.documentElement);}}catch(e){}})();`,s=i.hostCss?`<style>${gt(i.hostCss,"style")}</style>`:"",a=i.tailwind?'<script src="https://cdn.tailwindcss.com"></script>':"";return `<!DOCTYPE html><html ${i.htmlAttrs}><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;}body{font-family:system-ui,-apple-system,sans-serif;}</style>`+s+"<style>html,body{margin:0!important;padding:0!important;background:transparent!important;height:auto!important;min-height:0!important;max-height:none!important;width:auto!important;min-width:0!important;overflow:visible!important;color-scheme:normal!important;}</style>"+a+`<style>${gt(e,"style")}</style></head><body style="margin:0!important;background:transparent!important;min-height:0!important;height:auto!important;"><div id="__veo_root">${o}</div><script>${r}</script>`+(t?`<script>${gt(t,"script")}</script>`:"")+"</body></html>"}function gt(o,e){let t=e==="script"?/<\/script/gi:/<\/style/gi;return o.replace(t,`<\\/${e}`)}function hn(o,e,t){if(o.sandboxed){let s={html:o.html??"",css:o.css,js:o.js},{iframe:a,cleanup:l}=Se(e,s,t,{width:"100%"}),d=e.createElement("div");return d.className="veo-code-sandbox",d.appendChild(a),{node:d,cleanup:l}}if(t.editorPreview)return {node:ho(e),cleanup:()=>{}};let n=e,i=[];if(typeof o.css=="string"&&o.css.trim()){let s=n.createElement("style");s.textContent=o.css,n.head.appendChild(s),i.push(s);}let r=null;if(typeof o.html=="string"&&o.html.trim()){r=e.createElement("div"),r.className="veo-code-html",r.innerHTML=o.html;for(let s of Array.from(r.querySelectorAll("script")))i.push(go(s,n)),s.remove();}if(typeof o.js=="string"&&o.js.trim()){let s=n.createElement("script");s.textContent=o.js,n.body.appendChild(s),i.push(s);}return {node:r,cleanup:()=>{for(let s of i)s.parentNode?.removeChild(s);}}}function ho(o){let e=o.createElement("div");e.className="veo-code-placeholder",e.style.cssText="border:1px dashed #cbd5e1;border-radius:8px;padding:12px;text-align:center;font:13px/1.4 system-ui,sans-serif;color:#64748b;background:#f8fafc;";let t=o.createElement("strong");t.textContent="\u27E8 \u27E9 Bloque de c\xF3digo",t.style.cssText="display:block;color:#475569;margin-bottom:2px;";let n=o.createElement("span");return n.textContent="Se ejecuta en tu app al publicar (no corre en el editor).",e.append(t,n),e}function go(o,e){let t=e.createElement("script");for(let n of Array.from(o.attributes))t.setAttribute(n.name,n.value);return o.src||(t.textContent=o.textContent),e.body.appendChild(t),t}function ot(o,e,t){let n=e.guide.guideSteps[0];if(!n)return;let i=n.fields??[],r=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();},s=t.createElement("div");if(s.className="veo-guide-content",n.title){let m=t.createElement("h2");m.className="veo-guide-title",m.textContent=n.title,s.appendChild(m);}if(n.content){let m=t.createElement("p");m.className="veo-guide-text",m.textContent=n.content,s.appendChild(m);}let a=[],l=t.createElement("form");l.className="veo-form",l.noValidate=true;for(let m of i){let{wrapper:u,read:f}=yt(m,t);a.push({field:m,read:f}),l.appendChild(u);}let d=t.createElement("p");d.className="veo-form-error",d.style.display="none",l.appendChild(d);let c=t.createElement("div");c.className="veo-guide-actions";let p=t.createElement("button");p.type="submit",p.className="veo-guide-cta",p.textContent=n.ctaText||"Enviar",c.appendChild(p),l.appendChild(c),l.addEventListener("submit",m=>{m.preventDefault(),d.style.display="none";let u={};for(let{field:h,read:g}of a){let v=g();if(v==null||v===""){if(h.required){d.textContent=`Completa "${h.label}"`,d.style.display="block";return}continue}u[h.key]=v;}if(Object.keys(u).length===0){d.textContent="Responde al menos un campo",d.style.display="block";return}p.disabled=true,(e.onFormSubmit??(()=>Promise.resolve(true)))(u).then(h=>{if(!h){p.disabled=false,d.textContent="No se pudo enviar. Prueba de nuevo.",d.style.display="block";return}e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"completed"});let g=e.isPreview?e.previewNote??"Vista previa: la respuesta NO se guard\xF3.":null;vo(o,t,g),window.setTimeout(()=>e.onClose(),g?2200:1400);});}),s.appendChild(l),s.appendChild(pe(t,r)),o.appendChild(s);}function vo(o,e,t){for(;o.firstChild;)o.removeChild(o.firstChild);let n=e.createElement("div");if(n.className="veo-form-thanks",n.textContent="\u2713 \xA1Gracias por tu respuesta!",o.appendChild(n),t){let i=e.createElement("p");i.className="veo-form-preview-note",i.textContent=t,o.appendChild(i);}}function yt(o,e){let t=e.createElement("div");t.className="veo-form-field";let n=e.createElement("label");switch(n.className="veo-form-label",n.textContent=o.required?`${o.label} *`:o.label,t.appendChild(n),o.type){case "textarea":{let i=e.createElement("textarea");return i.className="veo-form-input",i.rows=3,o.placeholder&&(i.placeholder=o.placeholder),t.appendChild(i),{wrapper:t,read:()=>i.value.trim()}}case "number":{let i=e.createElement("input");return i.type="number",i.className="veo-form-input",o.placeholder&&(i.placeholder=o.placeholder),t.appendChild(i),{wrapper:t,read:()=>i.value.trim()===""?void 0:Number(i.value)}}case "select":{let i=e.createElement("select");i.className="veo-form-input";let r=e.createElement("option");r.value="",r.textContent=o.placeholder||"Elige una opci\xF3n\u2026",i.appendChild(r);for(let s of o.options??[]){let a=e.createElement("option");a.value=s,a.textContent=s,i.appendChild(a);}return t.appendChild(i),{wrapper:t,read:()=>i.value||void 0}}case "radio":{let i=e.createElement("div");i.className="veo-form-options";let r=`veo-${o.key}`,s=[];for(let a of o.options??[]){let l=e.createElement("label");l.className="veo-form-option";let d=e.createElement("input");d.type="radio",d.name=r,d.value=a,s.push(d);let c=e.createElement("span");c.textContent=a,l.appendChild(d),l.appendChild(c),i.appendChild(l);}return t.appendChild(i),{wrapper:t,read:()=>s.find(a=>a.checked)?.value}}case "multiselect":{let i=e.createElement("div");i.className="veo-form-options";let r=[];for(let s of o.options??[]){let a=e.createElement("label");a.className="veo-form-option";let l=e.createElement("input");l.type="checkbox",l.value=s,r.push(l);let d=e.createElement("span");d.textContent=s,a.appendChild(l),a.appendChild(d),i.appendChild(a);}return t.appendChild(i),{wrapper:t,read:()=>{let s=r.filter(a=>a.checked).map(a=>a.value);return s.length>0?s:void 0}}}case "checkbox":{let i=e.createElement("label");i.className="veo-form-option";let r=e.createElement("input");r.type="checkbox";let s=e.createElement("span");return s.textContent=o.placeholder||"S\xED",i.appendChild(r),i.appendChild(s),t.appendChild(i),{wrapper:t,read:()=>r.checked?true:o.required?"":false}}case "yesno":{let i=e.createElement("div");i.className="veo-form-options";let r=`veo-${o.key}`,[s,a]=o.options?.length===2?o.options:["S\xED","No"],l=[];for(let{label:d,value:c}of [{label:s,value:true},{label:a,value:false}]){let p=e.createElement("label");p.className="veo-form-option";let m=e.createElement("input");m.type="radio",m.name=r,l.push({input:m,value:c});let u=e.createElement("span");u.textContent=d,p.appendChild(m),p.appendChild(u),i.appendChild(p);}return t.appendChild(i),{wrapper:t,read:()=>l.find(d=>d.input.checked)?.value}}case "nps":return gn(t,e,0,10,"veo-nps-btn");case "rating":return gn(t,e,1,5,"veo-rating-btn","\u2605");default:{let i=e.createElement("input");return i.type="text",i.className="veo-form-input",o.placeholder&&(i.placeholder=o.placeholder),t.appendChild(i),{wrapper:t,read:()=>i.value.trim()}}}}function gn(o,e,t,n,i,r){let s=e.createElement("div");s.className="veo-form-scale";let a,l=[];for(let d=t;d<=n;d++){let c=e.createElement("button");c.type="button",c.className=i,c.textContent=r??String(d),c.setAttribute("aria-label",String(d)),c.addEventListener("click",()=>{a=d,l.forEach((p,m)=>{let u=r?m+t<=d:m+t===d;p.classList.toggle("veo-scale-active",u);});}),l.push(c),s.appendChild(c);}return o.appendChild(s),{wrapper:o,read:()=>a}}var yo={left:"flex-start",center:"center",right:"flex-end"},me=class extends w{async render(e){let t=e.nav?.stepIndex??0,n=e.guide.guideSteps[t];if(!n)return;let i=(n.position==="relative-to-element"||n.presentation==="inline")&&n.anchorSelector?.trim()||void 0,r=null;if(i&&(r=await k(i),!r))return;let{host:s,root:a}=this.createHost(),l=a.ownerDocument??document,d=n.design??{};typeof d.zIndex=="number"&&(s.style.zIndex=String(d.zIndex));let c=l.createElement("div");c.className="veo-card",Io(c,d);let p=(u,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:u,...{}});},m=[];if(this.buildContent(c,n.blocks??[],l,e,t,m),d.closeButton!==false){let u=pe(l,()=>{p("dismissed"),this.closeOrSkip(e);}),f=typeof d.closeColor=="string"?d.closeColor:null,h=typeof d.closeHoverColor=="string"?d.closeHoverColor:null;f&&(u.style.color=f);let g=typeof d.closePosition=="string"?d.closePosition:"top-right";xo(u,g),So(c,g),h&&(u.addEventListener("mouseenter",()=>{u.style.color=h;}),u.addEventListener("mouseleave",()=>{u.style.color=f??"";})),c.appendChild(u);}if(n.presentation==="inline"&&r){s.style.display="block";let u=bo(n.inlinePosition);a.appendChild(c),A(r,s,u),this.registerCleanup(M(s,i,u));}else if(n.position==="relative-to-element"&&r){if(d.backdrop===true){let h=l.createElement("div");h.className="veo-composite-overlay veo-composite-overlay--dim",typeof d.backdropColor=="string"&&(h.style.background=d.backdropColor);let g=typeof d.backdropZIndex=="number"?d.backdropZIndex:2e5;h.style.zIndex=String(g),a.appendChild(h),d.targetAbove===true&&this.registerCleanup(Eo(r,g+1));}let u=l.createElement("div");u.className="veo-composite-anchored";let f=d.caret===false?null:ko(l,d);f&&u.appendChild(f),u.appendChild(c),a.appendChild(u),this.registerCleanup(await Ro(r,u,f));}else {let u=l.createElement("div");u.className="veo-composite-overlay",d.backdrop!==false&&(u.classList.add("veo-composite-overlay--dim"),typeof d.backdropColor=="string"&&(u.style.background=d.backdropColor),typeof d.backdropZIndex=="number"&&(u.style.zIndex=String(d.backdropZIndex)),u.addEventListener("click",f=>{f.target===u&&(p("dismissed"),this.closeOrSkip(e));})),wo(c,n.position,d),u.appendChild(c),a.appendChild(u);}e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:"shown"});}buildContent(e,t,n,i,r,s){let a=d=>{i.onInteraction({guideId:i.guide.guideId,stepIndex:r,action:"cta_clicked",...d.id?{metadata:{buttonId:d.id}}:{}});},l=0;for(;l<t.length;){let d=t[l];if(!d){l++;continue}if(d.type==="button"){let p=n.createElement("div");p.className="veo-guide-actions";let m;for(;l<t.length&&t[l]?.type==="button";){let u=t[l];if(!m){let f=u.style?.align;(f==="left"||f==="center"||f==="right")&&(m=f);}p.appendChild(this.buildButton(u,n,i,r,s,a)),l++;}m&&(p.style.justifyContent=yo[m]??"flex-end"),e.appendChild(p);continue}if(d.type==="code"){let{node:p,cleanup:m}=hn(d,n,i);p&&e.appendChild(p),this.registerCleanup(m),l++;continue}if(d.type==="form"){let p=n.createElement("div");p.className="veo-form";for(let m of d.fields??[]){let{wrapper:u,read:f}=yt(m,n);s.push({field:m,read:f}),p.appendChild(u);}e.appendChild(p),l++;continue}let c=nt(d,n);c&&e.appendChild(c),l++;}}buildButton(e,t,n,i,r,s){let a=t.createElement("button");a.type="button",a.className="veo-guide-cta",a.textContent=e.text?.trim()||"OK",we(a,e.style,"button");let l=n.nav?.callbacks;return a.addEventListener("click",()=>{switch(e.action){case "next":s(e),l?l.onNext():n.onClose();break;case "prev":s(e),l?.onBack();break;case "url":s(e),typeof e.url=="string"&&R(e.url)&&window.open(e.url,"_blank","noopener,noreferrer");break;case "guide":s(e),e.targetGuideId&&n.onOpenGuide?.(e.targetGuideId),this.closeOrSkip(n);break;case "submit-forms":case "submit-forms-advance":case "submit-forms-goto":this.submitForms(r,n,i,a,()=>{s(e),e.action==="submit-forms"||!l?n.onClose():e.action==="submit-forms-goto"&&typeof e.targetStep=="number"&&l.onGoto?l.onGoto(e.targetStep):l.onNext();});break;default:s(e),this.closeOrSkip(n);}}),a}submitForms(e,t,n,i,r){let s={};for(let{field:l,read:d}of e){let c=d();if(c==null||c===""){if(l.required){i.textContent=`Completa "${l.label}"`;return}continue}s[l.key]=c;}if(e.length>0&&Object.keys(s).length===0)return;i.disabled=true,(t.onFormSubmit??(()=>Promise.resolve(true)))(s).then(l=>{i.disabled=false,l&&(t.onInteraction({guideId:t.guide.guideId,stepIndex:n,action:"completed"}),r());});}closeOrSkip(e){e.nav?.callbacks?e.nav.callbacks.onSkip():e.onClose();}};function bo(o){return o==="before"||o==="prepend"||o==="append"?o:"after"}function wo(o,e,t){let n=o.style;n.position="fixed";let i="16px",r=t.hAlign==="left"?"left":t.hAlign==="right"?"right":null,s=e.includes("top")?"top":e.includes("bottom")?"bottom":"middle",a=r??(e.includes("left")?"left":e.includes("right")?"right":"middle");s==="top"?n.top=i:s==="bottom"?n.bottom=i:n.top="50%",a==="left"?n.left=i:a==="right"?n.right=i:n.left="50%";let l=a==="middle"?"-50%":"0",d=s==="middle"?"-50%":"0";n.transform=l==="0"&&d==="0"?"":`translate(${l}, ${d})`;}var vn="10px";function xo(o,e){let t=o.style;t.top="auto",t.right="auto",t.bottom="auto",t.left="auto";let n=e.includes("bottom")?"bottom":"top",i=e.includes("left")?"left":"right";t.setProperty(n,vn),t.setProperty(i,vn);}var Co="34px";function So(o,e){let t=Array.from(o.children).filter(i=>i instanceof HTMLElement&&!i.classList.contains("veo-guide-close"));if(t.length===0)return;let n=e.includes("bottom")?t[t.length-1]:t[0];n&&(n.style[e.includes("left")?"paddingLeft":"paddingRight"]=Co);}function ko(o,e){let t=o.createElement("div");t.className="veo-composite-caret";let n=typeof e.caretWidth=="number"?e.caretWidth:12,i=typeof e.caretHeight=="number"?e.caretHeight:12,r=t.style;if(r.position="absolute",r.width=`${n}px`,r.height=`${i}px`,r.transform="rotate(45deg)",r.background=typeof e.background=="string"?e.background:"#ffffff",typeof e.borderWidth=="number"&&e.borderWidth>0){let s=typeof e.borderColor=="string"?e.borderColor:"#bbbbbb";r.border=`${e.borderWidth}px solid ${s}`;}return t}function Eo(o,e){let t=o,n=t.style.position,i=t.style.zIndex;return getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.style.zIndex=String(e),()=>{t.style.position=n,t.style.zIndex=i;}}async function Ro(o,e,t){let n=async()=>{let{x:r,y:s,placement:a,middlewareData:l}=await z(o,e,{placement:"bottom",strategy:"fixed",middleware:[H(t?10:8),W(),D({padding:8}),...t?[ee({element:t})]:[]]});e.style.left=`${r}px`,e.style.top=`${s}px`,t&&te(t,a,l.arrow);};await n();let i=()=>{n();};return window.addEventListener("scroll",i,true),window.addEventListener("resize",i),()=>{window.removeEventListener("scroll",i,true),window.removeEventListener("resize",i);}}function Io(o,e){let t=o.style,n=a=>typeof a=="number"&&Number.isFinite(a)?`${a}px`:null,i=a=>typeof a=="string"&&a?a:null;i(e.background)&&(t.background=e.background);let r=i(e.color)??i(e.textColor);r&&(t.color=r),n(e.fontSize)&&(t.fontSize=n(e.fontSize)),i(e.fontWeight)&&(t.fontWeight=e.fontWeight),i(e.fontFamily)&&e.fontFamily!=="inherit"&&(t.fontFamily=e.fontFamily),i(e.textTransform)&&e.textTransform!=="none"&&(t.textTransform=e.textTransform),typeof e.letterSpacing=="number"&&(t.letterSpacing=`${e.letterSpacing}px`),i(e.align)&&(t.textAlign=e.align),typeof e.lineHeight=="number"&&(t.lineHeight=`${e.lineHeight}%`),n(e.radius)&&(t.borderRadius=n(e.radius));let s=n(e.borderWidth);if(s&&(t.border=`${s} solid ${i(e.borderColor)??"#e5e5e5"}`),i(e.shadowColor)||typeof e.shadowBlur=="number"){let a=l=>typeof e[l]=="number"?e[l]:0;t.boxShadow=`${a("shadowX")}px ${a("shadowY")}px ${a("shadowBlur")}px ${a("shadowSpread")}px ${i(e.shadowColor)??"rgba(0,0,0,0.2)"}`;}e.fullWidth===true?t.width="100%":e.widthType==="fluid"?(t.width="auto",n(e.width)&&(t.maxWidth=n(e.width))):n(e.width)&&(t.width=n(e.width));for(let a of ["Top","Right","Bottom","Left"]){let l=n(e[`padding${a}`]);l&&t.setProperty(`padding-${a.toLowerCase()}`,l);let d=n(e[`margin${a}`]);d&&t.setProperty(`margin-${a.toLowerCase()}`,d);}}var To={mode:"floating",position:"bottom-right"},yn=16,Po=360,ke=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let n=t.placement??To,i=null;if(n.mode==="anchored"){let c=n.selector??t.selector??e.guide.activationRules.selector;if(typeof c!="string"||c.length===0||(i=await k(c),!i))return}let{root:r}=this.createHost(),s=r.ownerDocument??document,a=s.createElement("div");a.className=n.mode==="anchored"?"veo-custom-anchored":"veo-custom-floating";let{iframe:l,cleanup:d}=Se(s,t,e,{width:vt(n.width??Po),fixedHeight:n.height??null});this.registerCleanup(d),a.appendChild(l),r.appendChild(a),n.mode==="floating"?Ao(a,n):i&&this.registerCleanup(await this.setupAnchoredPosition(i,a,n)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}async setupAnchoredPosition(e,t,n){let i=n.side??"bottom",r=async()=>{let{x:a,y:l}=await z(e,t,{placement:i,strategy:"fixed",middleware:[H(n.offsetY??8),W(),D({padding:8})]});t.style.left=`${a}px`,t.style.top=`${l}px`;};await r();let s=()=>{r();};return window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}}};function Ao(o,e){let t=e.position??"bottom-right",n=`${e.offsetX??yn}px`,i=`${e.offsetY??yn}px`,r=o.style;if(t==="center"){r.top="50%",r.left="50%",r.transform="translate(-50%, -50%)";return}let[s,a]=t.split("-");s==="top"?r.top=i:r.bottom=i,a==="left"?r.left=n:a==="right"?r.right=n:(r.left="50%",r.transform="translateX(-50%)");}var Ee=class extends w{render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let{root:n}=this.createHost();this.applyDesign(t.style);let i=n.ownerDocument??document,r=i.createElement("div");r.className="veo-modal-overlay";let s=i.createElement("div");s.className="veo-modal-card",ot(s,e,i),r.appendChild(s),n.appendChild(r);let a=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();};r.addEventListener("click",d=>{d.target===r&&a();});let l=d=>{d.key==="Escape"&&a();};document.addEventListener("keydown",l),this.registerCleanup(()=>document.removeEventListener("keydown",l)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Re=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return;let i=await k(n);if(!i)return;let{host:r,root:s}=this.createHost();r.style.display="block";let a=K(t.style);A(i,r,a),this.registerCleanup(M(r,n,a));let l=s.ownerDocument??document,d=l.createElement("div");d.className="veo-custom-inline";let{iframe:c,cleanup:p}=Se(l,t,e,{width:"100%"});this.registerCleanup(p),d.appendChild(c),s.appendChild(d),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Ie=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return;let i=await k(n);if(!i)return;let{host:r,root:s}=this.createHost();r.style.display="block";let a=K(t.style);A(i,r,a),this.registerCleanup(M(r,n,a)),this.applyDesign(t.style);let l=s.ownerDocument??document,d=l.createElement("div");d.className="veo-inline",ot(d,e,l),s.appendChild(d),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Te=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return;let i=await k(n);if(!i)return;let{host:r,root:s}=this.createHost();r.style.display="block";let a=K(t.style);A(i,r,a),this.registerCleanup(M(r,n,a)),this.applyDesign(t.style);let l=s.ownerDocument??document,d=l.createElement("div");d.className="veo-inline";let c=(m,u,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:m,...f?{metadata:f}:{}}),u&&window.open(u,"_blank","noopener,noreferrer"),e.onClose();},p=P(t,l,{onCtaClick:(m,u,f)=>{c("cta_clicked",m==="url"?u:void 0,f),m==="guide"&&u&&e.onOpenGuide?.(u);},onDismiss:()=>c("dismissed")});d.appendChild(p),s.appendChild(d),this.liveContainer=d,this.liveContent=p,this.liveKey=`${n}|${a}`,this.liveBuild=m=>P(m,l,{onCtaClick:(u,f,h)=>{c("cta_clicked",u==="url"?f:void 0,h),u==="guide"&&f&&e.onOpenGuide?.(f);},onDismiss:()=>c("dismissed")}),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}liveKeyOf(e){return `${e.selector??""}|${K(e.style)}`}};function bn(o){return o.style?.backdrop===false?"veo-modal-overlay veo-modal-overlay--none":"veo-modal-overlay"}var oe=class extends w{constructor(){super(...arguments);this.overlay=null;}render(t){let n=t.nav?.stepIndex??0,i=t.guide.guideSteps[n];if(!i)return;let{root:r}=this.createHost();this.applyDesign(i.style);let s=r.ownerDocument??document,a=s.createElement("div");a.className=bn(i),this.overlay=a;let l=s.createElement("div");l.className="veo-modal-card";let d=(u,f,h)=>{t.onInteraction({guideId:t.guide.guideId,stepIndex:n,action:u,...h?{metadata:h}:{}}),f&&window.open(f,"_blank","noopener,noreferrer"),t.onClose();},c=()=>{t.nav?t.nav.callbacks.onSkip():d("dismissed");},p=t.nav?Ce(i,t.nav.stepIndex,t.nav.totalSteps,s,t.nav.callbacks):P(i,s,{onCtaClick:(u,f,h)=>{d("cta_clicked",u==="url"?f:void 0,h),u==="guide"&&f&&t.onOpenGuide?.(f);},onDismiss:()=>d("dismissed")});l.appendChild(p),a.appendChild(l),r.appendChild(a),t.nav||(this.liveContainer=l,this.liveContent=p,this.liveBuild=u=>P(u,s,{onCtaClick:(f,h,g)=>{d("cta_clicked",f==="url"?h:void 0,g),f==="guide"&&h&&t.onOpenGuide?.(h);},onDismiss:()=>d("dismissed")})),a.addEventListener("click",u=>{u.target===a&&c();});let m=u=>{u.key==="Escape"&&c();};document.addEventListener("keydown",m),this.registerCleanup(()=>document.removeEventListener("keydown",m)),t.nav||t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"shown"});}onLiveUpdate(t){this.overlay&&(this.overlay.className=bn(t));}destroy(){this.overlay=null,super.destroy();}};var Pe=class extends w{constructor(){super(...arguments);this.side="bottom";this.reposition=null;}async render(t){let n=t.guide.guideSteps[0];if(!n)return;let i=n.selector??t.guide.activationRules.selector;if(typeof i!="string"||i.length===0)return;let r=await k(i);if(!r)return;let s=n.style?.tooltipPlacement;this.side=s==="top"||s==="left"||s==="right"?s:"bottom";let{root:a}=this.createHost();this.applyDesign(n.style);let l=a.ownerDocument??document,d=l.createElement("div");d.className="veo-tooltip";let c=(h,g,v)=>{t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:h,...v?{metadata:v}:{}}),g&&window.open(g,"_blank","noopener,noreferrer"),t.onClose();},p=P(n,l,{onCtaClick:(h,g,v)=>{c("cta_clicked",h==="url"?g:void 0,v),h==="guide"&&g&&t.onOpenGuide?.(g);},onDismiss:()=>c("dismissed")});d.appendChild(p);let m=l.createElement("div");m.className="veo-tooltip-arrow",d.appendChild(m),a.appendChild(d);let u=async()=>{let{x:h,y:g,placement:v,middlewareData:b}=await z(r,d,{placement:this.side,middleware:[H(10),W(),D({padding:8}),ee({element:m})]});d.style.left=`${h}px`,d.style.top=`${g}px`,te(m,v,b.arrow);};await u();let f=()=>{u();};this.reposition=f,window.addEventListener("scroll",f,true),window.addEventListener("resize",f),this.registerCleanup(()=>{window.removeEventListener("scroll",f,true),window.removeEventListener("resize",f);}),this.liveContainer=d,this.liveContent=p,this.liveKey=i,this.liveBuild=h=>P(h,l,{onCtaClick:(g,v,b)=>{c("cta_clicked",g==="url"?v:void 0,b),g==="guide"&&v&&t.onOpenGuide?.(v);},onDismiss:()=>c("dismissed")}),t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"shown"});}liveKeyOf(t){return t.selector??""}onLiveUpdate(t){let n=t.style?.tooltipPlacement;this.side=n==="top"||n==="left"||n==="right"?n:"bottom",this.reposition?.();}};var Ae=class extends w{async render(e){let t=e.guide.guideSteps[e.currentStepIndex];if(!t)return false;let n=t.selector??e.guide.activationRules.selector;if(typeof n!="string"||n.length===0)return false;let i=await k(n,5e3);if(!i)return false;let r=t.style?.tooltipPlacement,s=r==="top"||r==="left"||r==="right"?r:"bottom",{root:a}=this.createHost();this.applyDesign(t.style);let l=a.ownerDocument??document,d=l.createElement("div");d.className="veo-walkthrough";let c=Ce(t,e.currentStepIndex,e.guide.guideSteps.length,l,e.callbacks);d.appendChild(c);let p=l.createElement("div");p.className="veo-walkthrough-arrow",d.appendChild(p),a.appendChild(d);let m=async()=>{let{x:f,y:h,placement:g,middlewareData:v}=await z(i,d,{placement:s,middleware:[H(10),W(),D({padding:8}),ee({element:p})]});d.style.left=`${f}px`,d.style.top=`${h}px`,te(p,g,v.arrow);};await m();let u=()=>{m();};return window.addEventListener("scroll",u,true),window.addEventListener("resize",u),this.registerCleanup(()=>{window.removeEventListener("scroll",u,true),window.removeEventListener("resize",u);}),true}};function Lo(o,e){switch(o.type){case "exact":return o.pattern===e;case "prefix":return e.startsWith(o.pattern);case "regex":try{return new RegExp(o.pattern).test(e)}catch{return false}}}function it(o,e){return !o||o.scope==="sitewide"||!o.pattern?true:Lo({type:o.matchType??"prefix",pattern:o.pattern},e)}var rt=class{constructor(e){this.state=null;this.storageKey=`${kt}${e}`,this.state=this.load(),this.state&&this.isAbandoned(this.state)&&this.clear();}current(){return this.state?this.isAbandoned(this.state)?(this.clear(),null):this.state:null}hasActive(){return this.current()!==null}start(e,t){let n=Date.now();return this.state={guideId:e,totalSteps:t,currentStepIndex:0,startedAt:n,lastProgressAt:n},this.persist(),this.state}advance(){if(!this.state)return null;let e=this.state.currentStepIndex+1;return e>=this.state.totalSteps?null:(this.state={...this.state,currentStepIndex:e,lastProgressAt:Date.now()},this.persist(),this.state)}back(){return this.state?this.state.currentStepIndex===0?this.state:(this.state={...this.state,currentStepIndex:this.state.currentStepIndex-1,lastProgressAt:Date.now()},this.persist(),this.state):null}clear(){if(this.state=null,!(typeof localStorage>"u"))try{localStorage.removeItem(this.storageKey);}catch{}}isAbandoned(e){return Date.now()-e.lastProgressAt>18e5}load(){if(typeof localStorage>"u")return null;try{let e=localStorage.getItem(this.storageKey);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;return typeof n.guideId!="string"||typeof n.totalSteps!="number"||typeof n.currentStepIndex!="number"||typeof n.startedAt!="number"||typeof n.lastProgressAt!="number"?null:n}catch{return null}}persist(){if(!(typeof localStorage>"u"||!this.state))try{localStorage.setItem(this.storageKey,JSON.stringify(this.state));}catch{}}};var No=3e4,Mo={shown:"shown",dismissed:"dismissed",cta_clicked:null,step_advanced:null,step_back:null,completed:"completed"},st=class{constructor(e,t){this.client=e;this.activeRenderers=new Set;this.activeByGuideId=new Map;this.dispatched=new Set;this.activeWalkthroughRenderer=null;this.activeWalkthroughGuide=null;this.resolveCache=null;this.inflightResolve=null;this.armedTriggers=new Map;this.pendingComposite=null;if(this.debug=t.debug===true,this.apiUrl=t.apiUrl,this.apiKey=t.apiKey,this.resolver=t.resolver??new ze(t.apiUrl,t.apiKey,this.debug),t.trackerQueue)this.trackerQueue=t.trackerQueue;else {let i=new Ue(t.apiUrl,t.apiKey);this.trackerQueue=new Ke({client:i,flushIntervalMs:3e3,batchSize:5,maxRetries:3,onError:(r,s)=>{this.debug&&console.warn(`[veo] dropped guide interaction after retries: guideId=${s.guideId} action=${s.payload.action}`,r);}});}let n=It(t.apiKey);this.frequencyCache=t.frequencyCache??new We(n),this.walkthroughState=t.walkthroughState??new rt(n);}get pendingInteractions(){return this.trackerQueue.size}clearFrequencyCache(){this.frequencyCache.clear();}clearWalkthroughState(){this.tearDownWalkthrough();}async checkGuides(e,t){let n=this.client.getEndUserId();if(!n){this.debug&&console.log("[veo] guides: skipped, no endUserId yet");return}if(await this.tryResumeWalkthrough(n,t,e))return;this.tryResumeComposite(t,e);let i;try{i=await this.resolveGuides(n,e);}catch(r){this.debug&&console.error("[veo] guides resolver threw:",r);return}this.debug&&console.log(`[veo] guides: ${i.length} eligible at ${e}`),this.disarmTriggers();for(let r of i){let s=r.activationRules.trigger;if((s==="on_click"||s==="on_hover")&&r.activationRules.selector){this.armInteractionTrigger(r,n,t,e);continue}await this.showGuide(r,n,t,e);}}async showGuide(e,t,n,i){if(this.frequencyCache.shouldFilter(e.guideId,e.displayFrequency)){this.debug&&console.log(`[veo] guides: filtered locally guideId=${e.guideId}`);return}if(this.activeByGuideId.has(e.guideId)){this.debug&&console.log(`[veo] guides: already shown guideId=${e.guideId}`);return}if(e.guideType==="walkthrough"&&e.guideSteps.length>1){if(this.walkthroughState.hasActive()){this.debug&&console.log(`[veo] guides: walkthrough ${e.guideId} skipped (another active)`);return}await this.startWalkthrough(e,t,n,i);return}if(e.guideType==="composite"){this.startComposite(e,n,i);return}this.runSingleStepRender(e,n,i);}armInteractionTrigger(e,t,n,i){if(this.frequencyCache.shouldFilter(e.guideId,e.displayFrequency)||this.activeByGuideId.has(e.guideId)||this.armedTriggers.has(e.guideId))return;let r=e.activationRules.selector,s=e.activationRules.trigger==="on_hover"?"mouseover":"click",a=d=>{let c=d.target;if(c instanceof Element){try{if(!c.closest(r))return}catch{return}l(),this.showGuide(e,t,n,i);}},l=()=>{document.removeEventListener(s,a,true),this.armedTriggers.delete(e.guideId);};document.addEventListener(s,a,true),this.armedTriggers.set(e.guideId,l),this.debug&&console.log(`[veo] guides: armed ${s} trigger for ${e.guideId} on ${r}`);}disarmTriggers(){for(let e of this.armedTriggers.values())e();this.armedTriggers.clear();}async resolveGuides(e,t){let n=`${e}
|
|
427
|
+
${t}`,i=Date.now();if(this.resolveCache?.key===n&&i-this.resolveCache.at<No)return this.debug&&console.log("[veo] guides: resolve cache hit"),this.resolveCache.guides;if(this.inflightResolve?.key===n)return this.inflightResolve.promise;let r=this.resolver.resolve(e,t);this.inflightResolve={key:n,promise:r};try{let s=await r;return this.resolveCache={key:n,at:Date.now(),guides:s},s}finally{this.inflightResolve?.key===n&&(this.inflightResolve=null);}}destroy(){for(let e of this.activeRenderers)try{e.destroy();}catch(t){this.debug&&console.error("[veo] renderer destroy failed:",t);}if(this.activeRenderers.clear(),this.activeByGuideId.clear(),this.activeWalkthroughRenderer){try{this.activeWalkthroughRenderer.destroy();}catch{}this.activeWalkthroughRenderer=null,this.activeWalkthroughGuide=null;}this.disarmTriggers(),this.dispatched.clear(),this.resolveCache=null,this.inflightResolve=null,this.trackerQueue.destroy();}runSingleStepRender(e,t,n){let i=this.createSingleStepRenderer(e.guideType);if(!i)return;this.activeByGuideId.set(e.guideId,i);let r=e.activationRules.delayMs??0;window.setTimeout(()=>this.mountSingleStepRenderer(e,i,t,n),r);}startComposite(e,t,n){if(this.pendingComposite?.guide.guideId===e.guideId)return;let r=e.guideSteps.findIndex(s=>it(s.pageLocation,n));r!==-1&&this.renderCompositeStep(e,r,t,n);}tryResumeComposite(e,t){let n=this.pendingComposite;if(!n)return false;let r=n.guide.guideSteps[n.stepIndex];return r?it(r.pageLocation,t)?(this.pendingComposite=null,this.renderCompositeStep(n.guide,n.stepIndex,e,t),true):false:(this.pendingComposite=null,false)}renderCompositeStep(e,t,n,i){let r=e.guideSteps,s=new me;this.activeRenderers.add(s),this.activeByGuideId.set(e.guideId,s);let a=()=>{s.destroy(),this.activeRenderers.delete(s),this.activeByGuideId.get(e.guideId)===s&&this.activeByGuideId.delete(e.guideId);},l=c=>{if(a(),c<0||c>=r.length)return;let p=r[c];p&&it(p.pageLocation,i)?this.renderCompositeStep(e,c,n,i):this.pendingComposite={guide:e,stepIndex:c};},d=r.length>1?{stepIndex:t,totalSteps:r.length,callbacks:{onNext:()=>l(t+1),onBack:()=>l(t-1),onGoto:c=>l(c),onSkip:a,onComplete:a}}:void 0;try{s.render({guide:e,onInteraction:c=>this.handleInteraction(e,n,i,c),onClose:a,onTrack:(c,p)=>this.client.track(c,p),onFormSubmit:c=>this.submitFormResponse(e.guideId,c),onOpenGuide:c=>{this.openGuideById(c,n,i);},...d?{nav:d}:{}});}catch(c){this.debug&&console.error("[veo] composite renderer threw:",c),a();}}mountSingleStepRenderer(e,t,n,i){this.activeRenderers.add(t),this.activeByGuideId.set(e.guideId,t);let r=()=>{t.destroy(),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);},s=c=>{this.handleInteraction(e,n,i,c);},a=(c,p)=>{this.client.track(c,p);},l=c=>this.submitFormResponse(e.guideId,c),d=c=>{this.openGuideById(c,n,i);};try{t.render({guide:e,onInteraction:s,onClose:r,onTrack:a,onFormSubmit:l,onOpenGuide:d});}catch(c){this.debug&&console.error("[veo] renderer.render threw:",c),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);}}async openGuideById(e,t,n){if(this.activeByGuideId.has(e))return;let i=await this.resolver.fetchById(e);if(!i){this.debug&&console.warn(`[veo] guides: chained guide ${e} not found`);return}let r=this.client.getEndUserId()??this.client.getAnonymousId();if(i.guideType==="walkthrough"&&i.guideSteps.length>1){this.walkthroughState.hasActive()||await this.startWalkthrough(i,r,t,n);return}this.runSingleStepRender(i,t,n);}async tryResumeWalkthrough(e,t,n){let i=this.walkthroughState.current();if(!i)return false;let r=await this.resolver.fetchById(i.guideId);if(!r||r.guideType!=="walkthrough")return this.debug&&console.log(`[veo] guides: walkthrough ${i.guideId} no longer available, cleaning up`),this.tearDownWalkthrough(),true;let s=Math.min(i.currentStepIndex,r.guideSteps.length-1);return await this.renderWalkthroughStep(r,s,e,t,n),true}async startWalkthrough(e,t,n,i){this.walkthroughState.start(e.guideId,e.guideSteps.length),await this.renderWalkthroughStep(e,0,t,n,i)&&(this.enqueueInteractionOnce(e.guideId,t,n,i,"shown",0),this.frequencyCache.record(e.guideId,"shown"));}async renderWalkthroughStep(e,t,n,i,r){this.activeWalkthroughRenderer&&(this.activeWalkthroughRenderer.destroy(),this.activeWalkthroughRenderer=null),this.activeWalkthroughGuide=e;let s={onNext:()=>this.handleWalkthroughNext(n,i,r),onBack:()=>this.handleWalkthroughBack(n,i,r),onSkip:()=>this.handleWalkthroughSkip(n,i,r),onComplete:()=>this.handleWalkthroughComplete(n,i,r)},a=e.guideSteps[t],l=Oo(a);if(l==="modal"||l==="banner"){let p=l==="modal"?new oe:new ne;try{p.render({guide:e,onInteraction:()=>{},onClose:()=>{},nav:{stepIndex:t,totalSteps:e.guideSteps.length,callbacks:s}});}catch(m){return this.debug&&console.error("[veo] sequence renderer threw:",m),this.tearDownWalkthrough(),false}return this.activeWalkthroughRenderer=p,true}let d=new Ae,c=false;try{c=await d.render({guide:e,currentStepIndex:t,callbacks:s});}catch(p){this.debug&&console.error("[veo] walkthrough renderer threw:",p);}return c?(this.activeWalkthroughRenderer=d,true):(this.debug&&console.warn(`[veo] walkthrough ${e.guideId} step ${t} could not render, cancelling`),this.tearDownWalkthrough(),false)}handleWalkthroughNext(e,t,n){let i=this.activeWalkthroughGuide;if(!i)return;let r=this.walkthroughState.advance();if(!r){this.handleWalkthroughComplete(e,t,n);return}this.enqueueInteraction(i.guideId,e,t,n,"step_advanced",r.currentStepIndex),this.renderWalkthroughStep(i,r.currentStepIndex,e,t,n);}handleWalkthroughBack(e,t,n){let i=this.activeWalkthroughGuide;if(!i)return;let r=this.walkthroughState.current();if(!r||r.currentStepIndex===0)return;let s=this.walkthroughState.back();s&&(this.enqueueInteraction(i.guideId,e,t,n,"step_back",s.currentStepIndex),this.renderWalkthroughStep(i,s.currentStepIndex,e,t,n));}handleWalkthroughSkip(e,t,n){let i=this.activeWalkthroughGuide,r=this.walkthroughState.current();!i||!r||(this.enqueueInteraction(i.guideId,e,t,n,"dismissed",r.currentStepIndex),this.frequencyCache.record(i.guideId,"dismissed"),this.tearDownWalkthrough());}handleWalkthroughComplete(e,t,n){let i=this.activeWalkthroughGuide,r=this.walkthroughState.current();!i||!r||(this.enqueueInteraction(i.guideId,e,t,n,"completed",r.currentStepIndex),this.frequencyCache.record(i.guideId,"completed"),this.tearDownWalkthrough());}tearDownWalkthrough(){if(this.activeWalkthroughRenderer)try{this.activeWalkthroughRenderer.destroy();}catch{}this.activeWalkthroughRenderer=null,this.activeWalkthroughGuide=null,this.walkthroughState.clear();}handleInteraction(e,t,n,i){let r=i.metadata?.buttonId?`:${i.metadata.buttonId}`:"",s=`${e.guideId}:${i.action}${r}`;if(this.dispatched.has(s)){this.debug&&console.log(`[veo] guides: dedup hit ${s}`);return}this.dispatched.add(s);let a=Mo[i.action];a&&this.frequencyCache.record(e.guideId,a);let l=this.client.getEndUserId();if(!l){this.debug&&console.warn("[veo] guides: interaction without endUserId \u2014 skipping enqueue");return}this.trackerQueue.enqueue({guideId:e.guideId,payload:{endUserId:l,sessionId:t,action:i.action,stepIndex:i.stepIndex,pageUrl:n,pagePath:wn(n),...i.metadata?{metadata:i.metadata}:{}}});}enqueueInteraction(e,t,n,i,r,s){this.trackerQueue.enqueue({guideId:e,payload:{endUserId:t,sessionId:n,action:r,stepIndex:s,pageUrl:i,pagePath:wn(i)}});}enqueueInteractionOnce(e,t,n,i,r,s){let a=`${e}:${r}:${s}`;this.dispatched.has(a)||(this.dispatched.add(a),this.enqueueInteraction(e,t,n,i,r,s));}createSingleStepRenderer(e){switch(e){case "modal":return new oe;case "banner":return new ne;case "tooltip":return new Pe;case "custom":return new ke;case "inline":return new Te;case "inline-custom":return new Re;case "form":return new Ee;case "inline-form":return new Ie;case "badge":return new xe;case "composite":return new me;case "walkthrough":return null;default:return null}}async submitFormResponse(e,t){let n=this.client.getEndUserId()??this.client.getAnonymousId();try{let i=await fetch(`${this.apiUrl}/v1/guides/${e}/form-response`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.apiKey},body:JSON.stringify({endUserId:n,answers:t})});return !i.ok&&this.debug&&console.warn("[veo] form-response respondi\xF3",i.status),i.ok}catch(i){return this.debug&&console.warn("[veo] form-response fall\xF3:",i),false}}};function wn(o){try{return new URL(o).pathname}catch{return "/"}}function Oo(o){let e=o?.style?.render;return typeof e=="string"?e:"walkthrough"}var _o="__veo_preview__",bt=class{constructor(){this.singleStep=null;this.walkthrough=null;this.walkthroughGuide=null;this.walkthroughIndex=0;this.input=null;}preview(e){let t=e.guideSteps[0];if(this.singleStep&&this.input&&e.guideType===this.input.guideType&&e.guideType!=="walkthrough"&&t&&this.singleStep.updateStep(t))return this.input=e,{close:()=>this.close(),ready:Promise.resolve({rendered:true}),host:()=>this.activeHost()};this.close(),this.input=e;let n=Bo(e),i=typeof e.startStepIndex=="number"?e.startStepIndex:0;if(n.guideType==="composite"){let s=Math.min(Math.max(0,i),n.guideSteps.length-1),a=n.guideSteps[s];a&&(n.guideSteps=[a]);let l=this.renderSingleStep(n);return {close:()=>this.close(),ready:l,host:()=>this.activeHost()}}let r=n.guideType==="walkthrough"?this.startWalkthrough(n,i):this.renderSingleStep(n);return {close:()=>this.close(),ready:r,host:()=>this.activeHost()}}activeHost(){return this.singleStep?this.singleStep.hostElement():this.walkthrough instanceof w?this.walkthrough.hostElement():null}close(){this.singleStep&&(he(this.singleStep),this.singleStep=null),this.walkthrough&&(he(this.walkthrough),this.walkthrough=null),this.walkthroughGuide=null,this.walkthroughIndex=0,this.input=null;}async renderSingleStep(e){let t=Fo(e.guideType);if(!t)return {rendered:false};this.singleStep=t;let n=false;try{await t.render({guide:e,onInteraction:i=>{i.action==="shown"&&(n=!0);},onClose:()=>this.close(),onTrack:()=>{},onOpenGuide:()=>{},onFormSubmit:this.input?.formSubmit??(()=>Promise.resolve(!0)),isPreview:!0,editorPreview:this.input?.editorPreview===!0,...this.input?.formSubmit&&this.input.formSubmitNote!==void 0?{previewNote:this.input.formSubmitNote}:{}});}catch{return this.close(),{rendered:false}}return this.singleStep!==t?(he(t),{rendered:false}):{rendered:n}}async startWalkthrough(e,t=0){if(e.guideSteps.length===0)return {rendered:false};this.walkthroughGuide=e;let n=Math.min(Math.max(0,Math.floor(t)),e.guideSteps.length-1);return this.walkthroughIndex=n,{rendered:await this.renderWalkthroughStep(n)}}async renderWalkthroughStep(e){let t=this.walkthroughGuide;if(!t)return false;this.walkthrough&&(he(this.walkthrough),this.walkthrough=null);let n={onNext:()=>{let l=this.walkthroughIndex+1;if(l>=t.guideSteps.length){this.close();return}this.walkthroughIndex=l,this.renderWalkthroughStep(l);},onBack:()=>{let l=this.walkthroughIndex-1;l<0||(this.walkthroughIndex=l,this.renderWalkthroughStep(l));},onSkip:()=>this.close(),onComplete:()=>this.close()},r=t.guideSteps[e]?.style?.render;if(r==="modal"||r==="banner"){let l=r==="modal"?new oe:new ne;try{l.render({guide:t,onInteraction:()=>{},onClose:()=>this.close(),nav:{stepIndex:e,totalSteps:t.guideSteps.length,callbacks:n}});}catch{return he(l),false}return this.walkthroughGuide!==t?(he(l),false):(this.walkthrough=l,true)}let s=new Ae,a=false;try{a=await s.render({guide:t,currentStepIndex:e,callbacks:n});}catch{a=false;}return !a||this.walkthroughGuide!==t?(he(s),false):(this.walkthrough=s,true)}},at=null;function lt(o){return De()?(at||(at=new bt),at.preview(o)):{close:()=>{},ready:Promise.resolve({rendered:false}),host:()=>null}}function xn(){at?.close();}function Bo(o){let e=o.activationRules?.selector,t={url:o.activationRules?.url??{type:"prefix",pattern:"/"},trigger:"immediate",...e!==void 0?{selector:e}:{}};return {guideId:_o,guideName:o.guideName??"Preview",guideType:o.guideType,guideSteps:o.guideSteps,activationRules:t,displayFrequency:"always",displayPriority:0}}function Fo(o){switch(o){case "modal":return new oe;case "banner":return new ne;case "tooltip":return new Pe;case "custom":return new ke;case "inline":return new Te;case "inline-custom":return new Re;case "form":return new Ee;case "inline-form":return new Ie;case "badge":return new xe;case "composite":return new me;case "walkthrough":return null;default:return null}}function he(o){try{o.destroy();}catch{}}var dt=null;async function Cn(o){if(!De())return null;dt?.teardown();let e=null;try{let a=await fetch(`${o.apiUrl}/v1/guides/preview-resolve`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":o.apiKey},body:JSON.stringify({token:o.token})});a.ok?e=(await a.json()).guide??null:o.debug&&console.warn("[veo] preview-resolve respondi\xF3",a.status);}catch(a){o.debug&&console.warn("[veo] preview-resolve fall\xF3:",a);}let t=async a=>{if(!e)return false;let l=window.veo,d=l?.getEndUserId?.()??l?.getAnonymousId?.()??null;if(!d)return false;try{return (await fetch(`${o.apiUrl}/v1/guides/${e.guideId}/form-response`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":o.apiKey},body:JSON.stringify({endUserId:d,answers:a})})).ok}catch{return false}},n=null,i=()=>{e&&(n?.close(),n=lt({guideType:e.guideType,guideSteps:e.guideSteps,activationRules:e.activationRules,guideName:e.guideName,formSubmit:t,formSubmitNote:"Vista previa: guardado en TU usuario para probar el flujo."}));},r=$o({label:e?`Vista previa: ${e.guideName}`:"Link de preview inv\xE1lido o vencido",error:!e,onReshow:e?i:null,onClose:()=>s.teardown()}),s={teardown(){n?.close(),n=null,r.remove(),dt===s&&(dt=null);}};return dt=s,i(),s}function $o(o){let e=document.createElement("div");e.setAttribute("data-veo-preview-chip","");let t=e.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=`
|
|
428
428
|
.chip { position: fixed; bottom: 16px; right: 16px; z-index: 2147483647;
|
|
429
429
|
display: flex; align-items: center; gap: 8px; padding: 8px 12px;
|
|
430
430
|
background: #111827; color: #f9fafb; border-radius: 9999px;
|
|
@@ -434,5 +434,5 @@ ${t}`,i=Date.now();if(this.resolveCache?.key===n&&i-this.resolveCache.at<Go)retu
|
|
|
434
434
|
button { all: unset; cursor: pointer; padding: 2px 6px; border-radius: 9999px;
|
|
435
435
|
font-size: 12px; line-height: 1; }
|
|
436
436
|
button:hover { background: rgba(255,255,255,.15); }
|
|
437
|
-
`,t.appendChild(n);let i=document.createElement("div");i.className=o.error?"chip error":"chip";let r=document.createElement("span");if(r.className="label",r.textContent=o.label,i.appendChild(r),o.onReshow){let a=document.createElement("button");a.textContent="\u21BB",a.title="Volver a mostrar la gu\xEDa",a.addEventListener("click",o.onReshow),i.appendChild(a);}let s=document.createElement("button");return s.textContent="\u2715",s.title="Salir de la vista previa",s.addEventListener("click",o.onClose),i.appendChild(s),t.appendChild(i),document.body.appendChild(e),{remove:()=>e.remove()}}function
|
|
437
|
+
`,t.appendChild(n);let i=document.createElement("div");i.className=o.error?"chip error":"chip";let r=document.createElement("span");if(r.className="label",r.textContent=o.label,i.appendChild(r),o.onReshow){let a=document.createElement("button");a.textContent="\u21BB",a.title="Volver a mostrar la gu\xEDa",a.addEventListener("click",o.onReshow),i.appendChild(a);}let s=document.createElement("button");return s.textContent="\u2715",s.title="Salir de la vista previa",s.addEventListener("click",o.onClose),i.appendChild(s),t.appendChild(i),document.body.appendChild(e),{remove:()=>e.remove()}}function Ho(o){return {name:"guides",install(e){if(!wt())return;let t=new st(e,o);window.__veoGuides={controller:t},e.on("identify",({sessionId:n})=>{t.checkGuides(window.location.href,n);}),e.on("pageview",({url:n,sessionId:i})=>{t.checkGuides(n,i);}),t.checkGuides(window.location.href,e.getSessionId());}}}exports.closeGuidePreview=xn;exports.guidesPlugin=Ho;exports.previewGuide=lt;exports.runPreviewMode=Cn;return exports;})({});//# sourceMappingURL=veo-guides.js.map
|
|
438
438
|
//# sourceMappingURL=veo-guides.js.map
|