veo-sdk 0.3.8 → 0.3.9

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.
@@ -1,4 +1,4 @@
1
- var veoGuides=(function(exports){'use strict';function ft(){return typeof window<"u"}function Ne(){return typeof document<"u"}var ht=["http:","https:"],mt="data-veo-guide",gt="veo:freq:";var vt="veo:walkthrough_state:";var wt={shown:1,dismissed:2,completed:2};function bt(n){return n.slice(-16)||"default"}var Ge=class{constructor(e){this.storageKey=`${gt}${e}`,this.cache=this.load(),this.prune();}shouldFilter(e,t){if(t==="every_visit"||t==="always")return false;let o=this.cache.get(e);return o?t==="once"?true:t==="until_dismissed"?o.status==="dismissed"||o.status==="completed":t==="until_answered"?o.status==="completed":false:false}record(e,t){let o=this.cache.get(e);o&&wt[t]<wt[o.status]||(this.cache.set(e,{guideId:e,status:t,lastInteractionAt:Date.now()}),this.persist());}clear(){this.cache.clear(),this.persist();}snapshot(){return Array.from(this.cache.values())}prune(){let e=Date.now(),t=false;for(let[o,r]of this.cache)e-r.lastInteractionAt>7776e6&&(this.cache.delete(o),t=true);if(this.cache.size>500){let o=Array.from(this.cache.entries()).sort((i,s)=>i[1].lastInteractionAt-s[1].lastInteractionAt),r=this.cache.size-500;for(let i=0;i<r;i++){let s=o[i];s&&this.cache.delete(s[0]);}t=true;}t&&this.persist();}load(){if(typeof localStorage>"u")return new Map;try{let e=localStorage.getItem(this.storageKey);if(!e)return new Map;let t=JSON.parse(e);if(!Array.isArray(t))return new Map;let o=[];for(let r of t)if(r&&typeof r=="object"&&typeof r.guideId=="string"&&typeof r.lastInteractionAt=="number"&&["shown","dismissed","completed"].includes(r.status)){let i=r;o.push([i.guideId,i]);}return new Map(o)}catch{return new Map}}persist(){if(!(typeof localStorage>"u"))try{let e=JSON.stringify(Array.from(this.cache.values()));localStorage.setItem(this.storageKey,e);}catch{}}};var Oe=class{constructor(e,t,o=false){this.apiUrl=e;this.apiKey=t;this.debug=o;}async resolve(e,t){let o=new URLSearchParams({endUserId:e,pageUrl:t}),r;try{r=await fetch(`${this.apiUrl}/v1/guides/resolve?${o.toString()}`,{method:"GET",headers:{"X-Api-Key":this.apiKey},credentials:"omit"});}catch(i){return this.debug&&console.error("[veo] guides resolve fetch failed:",i),[]}if(!r.ok)return this.debug&&console.warn("[veo] guides resolve HTTP",r.status),[];try{let i=await r.json();return Array.isArray(i.guides)?i.guides:[]}catch(i){return this.debug&&console.error("[veo] guides resolve parse failed:",i),[]}}async fetchById(e){let t;try{t=await fetch(`${this.apiUrl}/v1/guides/${encodeURIComponent(e)}`,{method:"GET",headers:{"X-Api-Key":this.apiKey},credentials:"omit"});}catch(o){return this.debug&&console.error("[veo] guides fetchById network failed:",o),null}if(!t.ok)return this.debug&&console.warn("[veo] guides fetchById HTTP",t.status),null;try{let o=await t.json();return typeof o.guideId!="string"||typeof o.guideName!="string"||typeof o.guideType!="string"||!Array.isArray(o.guideSteps)||!o.activationRules||typeof o.displayFrequency!="string"||typeof o.displayPriority!="number"?(this.debug&&console.warn("[veo] guides fetchById: unexpected shape"),null):{guideId:o.guideId,guideName:o.guideName,guideType:o.guideType,guideSteps:o.guideSteps,activationRules:o.activationRules,displayFrequency:o.displayFrequency,displayPriority:o.displayPriority}}catch(o){return this.debug&&console.error("[veo] guides fetchById parse failed:",o),null}}};function xt(n){let e={endUserId:n.endUserId,interactionType:n.action};return n.sessionId&&(e.sessionId=n.sessionId),typeof n.stepIndex=="number"&&(e.stepPosition=n.stepIndex),n.pageUrl&&(e.pageUrl=n.pageUrl),n.pagePath&&(e.pagePath=n.pagePath),e}var _e=class{constructor(e,t){this.apiUrl=e;this.apiKey=t;}async send(e){let t=this.buildUrl(e.guideId),o=await fetch(t,{method:"POST",headers:{"X-Api-Key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(xt(e.payload)),credentials:"omit"});if(!o.ok)throw new Error(`guide interaction send failed: HTTP ${o.status}`)}sendBeacon(e){if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return false;let t=`${this.buildUrl(e.guideId)}?key=${encodeURIComponent(this.apiKey)}`,o=new Blob([JSON.stringify(xt(e.payload))],{type:"application/json"});try{return navigator.sendBeacon(t,o)}catch{return false}}buildUrl(e){return `${this.apiUrl}/v1/guides/${encodeURIComponent(e)}/interactions`}};var De=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.unloadCleanup=null;this.startTimer(),this.installUnloadHandler();}get size(){return this.buffer.length}enqueue(e){this.buffer.push({guideId:e.guideId,payload:e.payload,attempts:0,enqueuedAt:Date.now()}),this.buffer.length>=this.config.batchSize&&this.flush();}async flush(){if(this.flushing||this.buffer.length===0)return;this.flushing=true;let e=this.buffer.splice(0,this.buffer.length),t=await Promise.allSettled(e.map(o=>this.config.client.send({guideId:o.guideId,payload:o.payload})));for(let o=0;o<t.length;o++){let r=t[o],i=e[o];!r||!i||r.status!=="fulfilled"&&(i.attempts+=1,i.attempts<this.config.maxRetries?this.buffer.push(i):this.safeOnError(r.reason,i));}this.flushing=false;}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);for(let t of e)this.config.client.sendBeacon({guideId:t.guideId,payload:t.payload});}destroy(){this.timer&&clearInterval(this.timer),this.timer=null,this.unloadCleanup?.(),this.unloadCleanup=null;}startTimer(){typeof window>"u"||(this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs));}installUnloadHandler(){if(typeof window>"u")return;let e=()=>this.flushBeacon(),t=()=>{document.visibilityState==="hidden"&&this.flushBeacon();};window.addEventListener("pagehide",e),window.addEventListener("visibilitychange",t),this.unloadCleanup=()=>{window.removeEventListener("pagehide",e),window.removeEventListener("visibilitychange",t);};}safeOnError(e,t){if(!this.config.onError)return;let o=e instanceof Error?e:new Error(String(e));try{this.config.onError(o,t);}catch{}}};function B(n,e,t){let o=e.createElement("div");o.className="veo-guide-content";let r=cn(n);return r?dn(o,r,e,t):ln(o,n,e,t),o.appendChild(M(e,()=>t.onDismiss())),o}function ln(n,e,t,o){if(typeof e.imageUrl=="string"&&e.imageUrl&&G(e.imageUrl)){let i=t.createElement("img");i.className="veo-guide-image",i.src=e.imageUrl,i.alt=typeof e.title=="string"?e.title:"",n.appendChild(i);}if(typeof e.title=="string"&&e.title){let i=t.createElement("h2");i.className="veo-guide-title",i.textContent=e.title,n.appendChild(i);}if(typeof e.content=="string"&&e.content){let i=t.createElement("p");i.className="veo-guide-text",i.textContent=e.content,n.appendChild(i);}let r=t.createElement("div");if(r.className="veo-guide-actions",typeof e.ctaText=="string"&&e.ctaText){let i=t.createElement("button");i.type="button",i.className="veo-guide-cta",i.textContent=e.ctaText,i.addEventListener("click",()=>{let s=e.ctaAction??"dismiss",a=fn(e);o.onCtaClick(s,a);}),r.appendChild(i);}n.appendChild(r);}function cn(n){if(!Array.isArray(n.blocks)||n.blocks.length===0)return null;let e=n.blocks.filter(t=>!t||typeof t!="object"?false:t.type==="image"?typeof t.url=="string"&&G(t.url):t.type==="title"||t.type==="text"||t.type==="button");return e.length>0?e:null}function dn(n,e,t,o){let r=0;for(;r<e.length;){let i=e[r];if(i?.type==="button"){let a=t.createElement("div");a.className="veo-guide-actions";let c;for(;r<e.length&&e[r]?.type==="button";){let l=e[r];if(!c){let u=l.style?.align;(u==="left"||u==="center"||u==="right")&&(c=u);}a.appendChild(pn(l,t,o)),r++;}c&&(a.style.justifyContent=Ct[c]),n.appendChild(a);continue}let s=un(i,t);s&&n.appendChild(s),r++;}}function un(n,e){switch(n.type){case "title":{let t=e.createElement("h2");return t.className="veo-guide-title",t.textContent=typeof n.text=="string"?n.text:"",Fe(t,n.style,"text"),t}case "text":{let t=e.createElement("p");return t.className="veo-guide-text",t.textContent=typeof n.text=="string"?n.text:"",Fe(t,n.style,"text"),t}case "image":{if(typeof n.url!="string"||!G(n.url))return null;let t=e.createElement("img");return t.className="veo-guide-image",t.src=n.url,t.alt="",Fe(t,n.style,"image"),t}default:return null}}function pn(n,e,t){let o=e.createElement("button");return o.type="button",o.className="veo-guide-cta",o.textContent=typeof n.text=="string"&&n.text?n.text:"OK",Fe(o,n.style,"button"),o.addEventListener("click",()=>{let r=n.action??"dismiss",i=r==="url"&&typeof n.url=="string"&&G(n.url)?n.url:void 0;t.onCtaClick(r,i);}),o}var Ct={left:"flex-start",center:"center",right:"flex-end"};function Ee(n,e,t){return Math.min(t,Math.max(e,n))}function Fe(n,e,t){if(!e||typeof e!="object")return;let o=e,r=typeof o.align=="string"?o.align:null;r&&(r==="left"||r==="center"||r==="right")&&(t==="text"?n.style.textAlign=r:t==="image"&&(n.style.alignSelf=Ct[r])),t!=="image"&&typeof o.color=="string"&&(n.style.color=o.color),t==="text"&&typeof o.fontSize=="number"&&Number.isFinite(o.fontSize)&&(n.style.fontSize=`${Ee(o.fontSize,8,72)}px`),t==="image"&&typeof o.width=="number"&&Number.isFinite(o.width)&&(n.style.width=`${Ee(o.width,10,100)}%`),t==="image"&&typeof o.radius=="number"&&Number.isFinite(o.radius)&&(n.style.borderRadius=`${Ee(o.radius,0,48)}px`),typeof o.marginTop=="number"&&Number.isFinite(o.marginTop)&&(n.style.marginTop=`${Ee(o.marginTop,0,64)}px`),typeof o.marginBottom=="number"&&Number.isFinite(o.marginBottom)&&(n.style.marginBottom=`${Ee(o.marginBottom,0,64)}px`);}function M(n,e,t="veo-guide-close"){let o=n.createElement("button");return o.type="button",o.className=t,o.setAttribute("aria-label","Cerrar"),o.textContent="\xD7",o.addEventListener("click",e),o}function G(n){if(typeof n!="string"||n.length===0)return false;try{let e=typeof window<"u"?window.location.href:"http://localhost/",t=new URL(n,e);return ht.includes(t.protocol)}catch{return false}}function fn(n){let e=n.style?.ctaUrl;if(typeof e=="string")return G(e)?e:void 0}function re(n,e,t,o,r){let i=o.createElement("div");i.className="veo-guide-content";let s=o.createElement("div");s.className="veo-walkthrough-counter",s.textContent=`Paso ${e+1} de ${t}`,i.appendChild(s);let a=o.createElement("div");a.className="veo-walkthrough-progress";for(let h=0;h<t;h++){let m=o.createElement("span");m.className="veo-walkthrough-progress-dot",h<e&&m.classList.add("completed"),h===e&&m.classList.add("active"),a.appendChild(m);}if(i.appendChild(a),typeof n.imageUrl=="string"&&n.imageUrl&&G(n.imageUrl)){let h=o.createElement("img");h.className="veo-guide-image",h.src=n.imageUrl,h.alt=typeof n.title=="string"?n.title:"",i.appendChild(h);}if(typeof n.title=="string"&&n.title){let h=o.createElement("h2");h.className="veo-guide-title",h.textContent=n.title,i.appendChild(h);}if(typeof n.content=="string"&&n.content){let h=o.createElement("p");h.className="veo-guide-text",h.textContent=n.content,i.appendChild(h);}let c=o.createElement("div");c.className="veo-walkthrough-actions";let l=o.createElement("button");l.type="button",l.className="veo-walkthrough-skip",l.textContent="Omitir",l.addEventListener("click",()=>r.onSkip()),c.appendChild(l);let u=o.createElement("div");if(u.className="veo-walkthrough-actions-right",e>0){let h=o.createElement("button");h.type="button",h.className="veo-walkthrough-btn-secondary",h.textContent="Atr\xE1s",h.addEventListener("click",()=>r.onBack()),u.appendChild(h);}let d=e===t-1,p=o.createElement("button");p.type="button",p.className="veo-guide-cta";let f=d?"Finalizar":"Siguiente";return p.textContent=typeof n.ctaText=="string"&&n.ctaText?n.ctaText:f,p.addEventListener("click",()=>{d?r.onComplete():r.onNext();}),u.appendChild(p),c.appendChild(u),i.appendChild(c),i.appendChild(M(o,()=>r.onSkip())),i}var hn={"--veo-bg":"#1f2937","--veo-text":"#f9fafb","--veo-text-secondary":"#d1d5db","--veo-shadow":"0 20px 60px rgba(0, 0, 0, 0.55)"},ot={left:"flex-start",center:"center",right:"flex-end"},mn={left:"flex-start",center:"center",right:"flex-end"},gn={title:"text",text:"text",image:"self"},kt={none:"none",soft:"0 4px 14px rgba(0, 0, 0, 0.10)",medium:"0 8px 30px rgba(0, 0, 0, 0.18)",strong:"0 24px 60px rgba(0, 0, 0, 0.32)"},St={center:[.5,.5],top:[.5,0],bottom:[.5,1],left:[0,.5],right:[1,.5],"top-left":[0,0],"top-right":[1,0],"bottom-left":[0,1],"bottom-right":[1,1]},it=/^#[0-9a-f]{3,8}$|^(rgb|rgba|hsl|hsla)\([\d.,%/\sdeg]+\)$|^[a-z]{3,20}$/i;function E(n,e,t){return Math.min(t,Math.max(e,n))}function Et(n,e){if(!e||typeof e!="object")return;let t=e;if(typeof t.accentColor=="string"&&it.test(t.accentColor.trim())&&n.style.setProperty("--veo-primary",t.accentColor.trim()),typeof t.fontFamily=="string"&&t.fontFamily.length<=200&&!/[<>{}]/.test(t.fontFamily)&&n.style.setProperty("--veo-font",t.fontFamily.trim()),t.theme==="dark")for(let[i,s]of Object.entries(hn))n.style.setProperty(i,s);typeof t.radius=="number"&&Number.isFinite(t.radius)&&n.style.setProperty("--veo-radius",`${E(t.radius,0,48)}px`),typeof t.width=="number"&&Number.isFinite(t.width)&&n.style.setProperty("--veo-width",`${E(t.width,220,720)}px`),(t.align==="left"||t.align==="center"||t.align==="right")&&n.style.setProperty("--veo-actions-justify",ot[t.align]),typeof t.padding=="number"&&Number.isFinite(t.padding)&&n.style.setProperty("--veo-pad",`${E(t.padding,0,64)}px`),typeof t.margin=="number"&&Number.isFinite(t.margin)&&n.style.setProperty("--veo-margin",`${E(t.margin,0,64)}px`),typeof t.borderWidth=="number"&&Number.isFinite(t.borderWidth)&&n.style.setProperty("--veo-border-width",`${E(t.borderWidth,0,16)}px`),typeof t.borderColor=="string"&&it.test(t.borderColor.trim())&&n.style.setProperty("--veo-border-color",t.borderColor.trim()),typeof t.shadow=="string"&&kt[t.shadow]&&n.style.setProperty("--veo-shadow",kt[t.shadow]);let o,r;if(typeof t.posX=="number"&&typeof t.posY=="number"?(o=E(t.posX,0,1),r=E(t.posY,0,1)):typeof t.overlayPosition=="string"&&St[t.overlayPosition]&&([o,r]=St[t.overlayPosition]),o!==void 0&&r!==void 0&&(n.style.setProperty("--veo-pos-x",`${o*100}%`),n.style.setProperty("--veo-pos-y",`${r*100}%`)),t.elements&&typeof t.elements=="object"){let i=t.elements;rt(n,"title",i.title),rt(n,"text",i.text),rt(n,"image",i.image);let s=i.cta;s&&typeof s.align=="string"&&ot[s.align]&&n.style.setProperty("--veo-actions-justify",ot[s.align]);}}function rt(n,e,t){if(!t||typeof t!="object")return;let o=t;if(typeof o.align=="string"&&(o.align==="left"||o.align==="center"||o.align==="right")){let i=(gn[e]??"text")==="self"?mn[o.align]:o.align;n.style.setProperty(`--veo-${e}-align`,i);}typeof o.color=="string"&&it.test(o.color.trim())&&n.style.setProperty(`--veo-${e}-color`,o.color.trim()),typeof o.fontSize=="number"&&Number.isFinite(o.fontSize)&&n.style.setProperty(`--veo-${e}-size`,`${E(o.fontSize,8,72)}px`),typeof o.width=="number"&&Number.isFinite(o.width)&&n.style.setProperty(`--veo-${e}-width`,`${E(o.width,10,100)}%`),typeof o.radius=="number"&&Number.isFinite(o.radius)&&n.style.setProperty(`--veo-${e}-radius`,`${E(o.radius,0,48)}px`),typeof o.marginTop=="number"&&Number.isFinite(o.marginTop)&&n.style.setProperty(`--veo-${e}-mt`,`${E(o.marginTop,0,64)}px`),typeof o.marginBottom=="number"&&Number.isFinite(o.marginBottom)&&n.style.setProperty(`--veo-${e}-mb`,`${E(o.marginBottom,0,64)}px`);}var Rt=`
1
+ var veoGuides=(function(exports){'use strict';function ft(){return typeof window<"u"}function Ne(){return typeof document<"u"}var ht=["http:","https:"],mt="data-veo-guide",gt="veo:freq:";var vt="veo:walkthrough_state:";var wt={shown:1,dismissed:2,completed:2};function bt(n){return n.slice(-16)||"default"}var Ge=class{constructor(e){this.storageKey=`${gt}${e}`,this.cache=this.load(),this.prune();}shouldFilter(e,t){if(t==="every_visit"||t==="always")return false;let o=this.cache.get(e);return o?t==="once"?true:t==="until_dismissed"?o.status==="dismissed"||o.status==="completed":t==="until_answered"?o.status==="completed":false:false}record(e,t){let o=this.cache.get(e);o&&wt[t]<wt[o.status]||(this.cache.set(e,{guideId:e,status:t,lastInteractionAt:Date.now()}),this.persist());}clear(){this.cache.clear(),this.persist();}snapshot(){return Array.from(this.cache.values())}prune(){let e=Date.now(),t=false;for(let[o,r]of this.cache)e-r.lastInteractionAt>7776e6&&(this.cache.delete(o),t=true);if(this.cache.size>500){let o=Array.from(this.cache.entries()).sort((i,s)=>i[1].lastInteractionAt-s[1].lastInteractionAt),r=this.cache.size-500;for(let i=0;i<r;i++){let s=o[i];s&&this.cache.delete(s[0]);}t=true;}t&&this.persist();}load(){if(typeof localStorage>"u")return new Map;try{let e=localStorage.getItem(this.storageKey);if(!e)return new Map;let t=JSON.parse(e);if(!Array.isArray(t))return new Map;let o=[];for(let r of t)if(r&&typeof r=="object"&&typeof r.guideId=="string"&&typeof r.lastInteractionAt=="number"&&["shown","dismissed","completed"].includes(r.status)){let i=r;o.push([i.guideId,i]);}return new Map(o)}catch{return new Map}}persist(){if(!(typeof localStorage>"u"))try{let e=JSON.stringify(Array.from(this.cache.values()));localStorage.setItem(this.storageKey,e);}catch{}}};var Oe=class{constructor(e,t,o=false){this.apiUrl=e;this.apiKey=t;this.debug=o;}async resolve(e,t){let o=new URLSearchParams({endUserId:e,pageUrl:t}),r;try{r=await fetch(`${this.apiUrl}/v1/guides/resolve?${o.toString()}`,{method:"GET",headers:{"X-Api-Key":this.apiKey},credentials:"omit"});}catch(i){return this.debug&&console.error("[veo] guides resolve fetch failed:",i),[]}if(!r.ok)return this.debug&&console.warn("[veo] guides resolve HTTP",r.status),[];try{let i=await r.json();return Array.isArray(i.guides)?i.guides:[]}catch(i){return this.debug&&console.error("[veo] guides resolve parse failed:",i),[]}}async fetchById(e){let t;try{t=await fetch(`${this.apiUrl}/v1/guides/${encodeURIComponent(e)}`,{method:"GET",headers:{"X-Api-Key":this.apiKey},credentials:"omit"});}catch(o){return this.debug&&console.error("[veo] guides fetchById network failed:",o),null}if(!t.ok)return this.debug&&console.warn("[veo] guides fetchById HTTP",t.status),null;try{let o=await t.json();return typeof o.guideId!="string"||typeof o.guideName!="string"||typeof o.guideType!="string"||!Array.isArray(o.guideSteps)||!o.activationRules||typeof o.displayFrequency!="string"||typeof o.displayPriority!="number"?(this.debug&&console.warn("[veo] guides fetchById: unexpected shape"),null):{guideId:o.guideId,guideName:o.guideName,guideType:o.guideType,guideSteps:o.guideSteps,activationRules:o.activationRules,displayFrequency:o.displayFrequency,displayPriority:o.displayPriority}}catch(o){return this.debug&&console.error("[veo] guides fetchById parse failed:",o),null}}};function xt(n){let e={endUserId:n.endUserId,interactionType:n.action};return n.sessionId&&(e.sessionId=n.sessionId),typeof n.stepIndex=="number"&&(e.stepPosition=n.stepIndex),n.pageUrl&&(e.pageUrl=n.pageUrl),n.pagePath&&(e.pagePath=n.pagePath),e}var _e=class{constructor(e,t){this.apiUrl=e;this.apiKey=t;}async send(e){let t=this.buildUrl(e.guideId),o=await fetch(t,{method:"POST",headers:{"X-Api-Key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(xt(e.payload)),credentials:"omit"});if(!o.ok)throw new Error(`guide interaction send failed: HTTP ${o.status}`)}sendBeacon(e){if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return false;let t=`${this.buildUrl(e.guideId)}?key=${encodeURIComponent(this.apiKey)}`,o=new Blob([JSON.stringify(xt(e.payload))],{type:"application/json"});try{return navigator.sendBeacon(t,o)}catch{return false}}buildUrl(e){return `${this.apiUrl}/v1/guides/${encodeURIComponent(e)}/interactions`}};var De=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.unloadCleanup=null;this.startTimer(),this.installUnloadHandler();}get size(){return this.buffer.length}enqueue(e){this.buffer.push({guideId:e.guideId,payload:e.payload,attempts:0,enqueuedAt:Date.now()}),this.buffer.length>=this.config.batchSize&&this.flush();}async flush(){if(this.flushing||this.buffer.length===0)return;this.flushing=true;let e=this.buffer.splice(0,this.buffer.length),t=await Promise.allSettled(e.map(o=>this.config.client.send({guideId:o.guideId,payload:o.payload})));for(let o=0;o<t.length;o++){let r=t[o],i=e[o];!r||!i||r.status!=="fulfilled"&&(i.attempts+=1,i.attempts<this.config.maxRetries?this.buffer.push(i):this.safeOnError(r.reason,i));}this.flushing=false;}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);for(let t of e)this.config.client.sendBeacon({guideId:t.guideId,payload:t.payload});}destroy(){this.timer&&clearInterval(this.timer),this.timer=null,this.unloadCleanup?.(),this.unloadCleanup=null;}startTimer(){typeof window>"u"||(this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs));}installUnloadHandler(){if(typeof window>"u")return;let e=()=>this.flushBeacon(),t=()=>{document.visibilityState==="hidden"&&this.flushBeacon();};window.addEventListener("pagehide",e),window.addEventListener("visibilitychange",t),this.unloadCleanup=()=>{window.removeEventListener("pagehide",e),window.removeEventListener("visibilitychange",t);};}safeOnError(e,t){if(!this.config.onError)return;let o=e instanceof Error?e:new Error(String(e));try{this.config.onError(o,t);}catch{}}};function $(n,e,t){let o=e.createElement("div");o.className="veo-guide-content";let r=cn(n);return r?dn(o,r,e,t):ln(o,n,e,t),o.appendChild(Ee(e,()=>t.onDismiss())),o}function ln(n,e,t,o){if(typeof e.imageUrl=="string"&&e.imageUrl&&G(e.imageUrl)){let i=t.createElement("img");i.className="veo-guide-image",i.src=e.imageUrl,i.alt=typeof e.title=="string"?e.title:"",n.appendChild(i);}if(typeof e.title=="string"&&e.title){let i=t.createElement("h2");i.className="veo-guide-title",i.textContent=e.title,n.appendChild(i);}if(typeof e.content=="string"&&e.content){let i=t.createElement("p");i.className="veo-guide-text",i.textContent=e.content,n.appendChild(i);}let r=t.createElement("div");if(r.className="veo-guide-actions",typeof e.ctaText=="string"&&e.ctaText){let i=t.createElement("button");i.type="button",i.className="veo-guide-cta",i.textContent=e.ctaText,i.addEventListener("click",()=>{let s=e.ctaAction??"dismiss",a=fn(e);o.onCtaClick(s,a);}),r.appendChild(i);}n.appendChild(r);}function cn(n){if(!Array.isArray(n.blocks)||n.blocks.length===0)return null;let e=n.blocks.filter(t=>!t||typeof t!="object"?false:t.type==="image"?typeof t.url=="string"&&G(t.url):t.type==="title"||t.type==="text"||t.type==="button");return e.length>0?e:null}function dn(n,e,t,o){let r=0;for(;r<e.length;){let i=e[r];if(i?.type==="button"){let a=t.createElement("div");a.className="veo-guide-actions";let c;for(;r<e.length&&e[r]?.type==="button";){let l=e[r];if(!c){let u=l.style?.align;(u==="left"||u==="center"||u==="right")&&(c=u);}a.appendChild(pn(l,t,o)),r++;}c&&(a.style.justifyContent=Ct[c]),n.appendChild(a);continue}let s=un(i,t);s&&n.appendChild(s),r++;}}function un(n,e){switch(n.type){case "title":{let t=e.createElement("h2");return t.className="veo-guide-title",t.textContent=typeof n.text=="string"?n.text:"",Fe(t,n.style,"text"),t}case "text":{let t=e.createElement("p");return t.className="veo-guide-text",t.textContent=typeof n.text=="string"?n.text:"",Fe(t,n.style,"text"),t}case "image":{if(typeof n.url!="string"||!G(n.url))return null;let t=e.createElement("img");return t.className="veo-guide-image",t.src=n.url,t.alt="",Fe(t,n.style,"image"),t}default:return null}}function pn(n,e,t){let o=e.createElement("button");return o.type="button",o.className="veo-guide-cta",o.textContent=typeof n.text=="string"&&n.text?n.text:"OK",Fe(o,n.style,"button"),o.addEventListener("click",()=>{let r=n.action??"dismiss",i=r==="url"&&typeof n.url=="string"&&G(n.url)?n.url:void 0;t.onCtaClick(r,i);}),o}var Ct={left:"flex-start",center:"center",right:"flex-end"};function Se(n,e,t){return Math.min(t,Math.max(e,n))}function Fe(n,e,t){if(!e||typeof e!="object")return;let o=e,r=typeof o.align=="string"?o.align:null;r&&(r==="left"||r==="center"||r==="right")&&(t==="text"?n.style.textAlign=r:t==="image"&&(n.style.alignSelf=Ct[r])),t!=="image"&&typeof o.color=="string"&&(n.style.color=o.color),t==="text"&&typeof o.fontSize=="number"&&Number.isFinite(o.fontSize)&&(n.style.fontSize=`${Se(o.fontSize,8,72)}px`),t==="image"&&typeof o.width=="number"&&Number.isFinite(o.width)&&(n.style.width=`${Se(o.width,10,100)}%`),t==="image"&&typeof o.radius=="number"&&Number.isFinite(o.radius)&&(n.style.borderRadius=`${Se(o.radius,0,48)}px`),typeof o.marginTop=="number"&&Number.isFinite(o.marginTop)&&(n.style.marginTop=`${Se(o.marginTop,0,64)}px`),typeof o.marginBottom=="number"&&Number.isFinite(o.marginBottom)&&(n.style.marginBottom=`${Se(o.marginBottom,0,64)}px`);}function Ee(n,e,t="veo-guide-close"){let o=n.createElement("button");return o.type="button",o.className=t,o.setAttribute("aria-label","Cerrar"),o.textContent="\xD7",o.addEventListener("click",e),o}function G(n){if(typeof n!="string"||n.length===0)return false;try{let e=typeof window<"u"?window.location.href:"http://localhost/",t=new URL(n,e);return ht.includes(t.protocol)}catch{return false}}function fn(n){let e=n.style?.ctaUrl;if(typeof e=="string")return G(e)?e:void 0}function oe(n,e,t,o,r){let i=o.createElement("div");i.className="veo-guide-content";let s=o.createElement("div");s.className="veo-walkthrough-counter",s.textContent=`Paso ${e+1} de ${t}`,i.appendChild(s);let a=o.createElement("div");a.className="veo-walkthrough-progress";for(let h=0;h<t;h++){let m=o.createElement("span");m.className="veo-walkthrough-progress-dot",h<e&&m.classList.add("completed"),h===e&&m.classList.add("active"),a.appendChild(m);}if(i.appendChild(a),typeof n.imageUrl=="string"&&n.imageUrl&&G(n.imageUrl)){let h=o.createElement("img");h.className="veo-guide-image",h.src=n.imageUrl,h.alt=typeof n.title=="string"?n.title:"",i.appendChild(h);}if(typeof n.title=="string"&&n.title){let h=o.createElement("h2");h.className="veo-guide-title",h.textContent=n.title,i.appendChild(h);}if(typeof n.content=="string"&&n.content){let h=o.createElement("p");h.className="veo-guide-text",h.textContent=n.content,i.appendChild(h);}let c=o.createElement("div");c.className="veo-walkthrough-actions";let l=o.createElement("button");l.type="button",l.className="veo-walkthrough-skip",l.textContent="Omitir",l.addEventListener("click",()=>r.onSkip()),c.appendChild(l);let u=o.createElement("div");if(u.className="veo-walkthrough-actions-right",e>0){let h=o.createElement("button");h.type="button",h.className="veo-walkthrough-btn-secondary",h.textContent="Atr\xE1s",h.addEventListener("click",()=>r.onBack()),u.appendChild(h);}let d=e===t-1,p=o.createElement("button");p.type="button",p.className="veo-guide-cta";let f=d?"Finalizar":"Siguiente";return p.textContent=typeof n.ctaText=="string"&&n.ctaText?n.ctaText:f,p.addEventListener("click",()=>{d?r.onComplete():r.onNext();}),u.appendChild(p),c.appendChild(u),i.appendChild(c),i.appendChild(Ee(o,()=>r.onSkip())),i}var hn={"--veo-bg":"#1f2937","--veo-text":"#f9fafb","--veo-text-secondary":"#d1d5db","--veo-shadow":"0 20px 60px rgba(0, 0, 0, 0.55)"},ot={left:"flex-start",center:"center",right:"flex-end"},mn={left:"flex-start",center:"center",right:"flex-end"},gn={title:"text",text:"text",image:"self"},kt={none:"none",soft:"0 4px 14px rgba(0, 0, 0, 0.10)",medium:"0 8px 30px rgba(0, 0, 0, 0.18)",strong:"0 24px 60px rgba(0, 0, 0, 0.32)"},St={center:[.5,.5],top:[.5,0],bottom:[.5,1],left:[0,.5],right:[1,.5],"top-left":[0,0],"top-right":[1,0],"bottom-left":[0,1],"bottom-right":[1,1]},it=/^#[0-9a-f]{3,8}$|^(rgb|rgba|hsl|hsla)\([\d.,%/\sdeg]+\)$|^[a-z]{3,20}$/i;function E(n,e,t){return Math.min(t,Math.max(e,n))}function Et(n,e){if(!e||typeof e!="object")return;let t=e;if(typeof t.accentColor=="string"&&it.test(t.accentColor.trim())&&n.style.setProperty("--veo-primary",t.accentColor.trim()),typeof t.fontFamily=="string"&&t.fontFamily.length<=200&&!/[<>{}]/.test(t.fontFamily)&&n.style.setProperty("--veo-font",t.fontFamily.trim()),t.theme==="dark")for(let[i,s]of Object.entries(hn))n.style.setProperty(i,s);typeof t.radius=="number"&&Number.isFinite(t.radius)&&n.style.setProperty("--veo-radius",`${E(t.radius,0,48)}px`),typeof t.width=="number"&&Number.isFinite(t.width)&&n.style.setProperty("--veo-width",`${E(t.width,220,720)}px`),(t.align==="left"||t.align==="center"||t.align==="right")&&n.style.setProperty("--veo-actions-justify",ot[t.align]),typeof t.padding=="number"&&Number.isFinite(t.padding)&&n.style.setProperty("--veo-pad",`${E(t.padding,0,64)}px`),typeof t.margin=="number"&&Number.isFinite(t.margin)&&n.style.setProperty("--veo-margin",`${E(t.margin,0,64)}px`),typeof t.borderWidth=="number"&&Number.isFinite(t.borderWidth)&&n.style.setProperty("--veo-border-width",`${E(t.borderWidth,0,16)}px`),typeof t.borderColor=="string"&&it.test(t.borderColor.trim())&&n.style.setProperty("--veo-border-color",t.borderColor.trim()),typeof t.shadow=="string"&&kt[t.shadow]&&n.style.setProperty("--veo-shadow",kt[t.shadow]);let o,r;if(typeof t.posX=="number"&&typeof t.posY=="number"?(o=E(t.posX,0,1),r=E(t.posY,0,1)):typeof t.overlayPosition=="string"&&St[t.overlayPosition]&&([o,r]=St[t.overlayPosition]),o!==void 0&&r!==void 0&&(n.style.setProperty("--veo-pos-x",`${o*100}%`),n.style.setProperty("--veo-pos-y",`${r*100}%`)),t.elements&&typeof t.elements=="object"){let i=t.elements;rt(n,"title",i.title),rt(n,"text",i.text),rt(n,"image",i.image);let s=i.cta;s&&typeof s.align=="string"&&ot[s.align]&&n.style.setProperty("--veo-actions-justify",ot[s.align]);}}function rt(n,e,t){if(!t||typeof t!="object")return;let o=t;if(typeof o.align=="string"&&(o.align==="left"||o.align==="center"||o.align==="right")){let i=(gn[e]??"text")==="self"?mn[o.align]:o.align;n.style.setProperty(`--veo-${e}-align`,i);}typeof o.color=="string"&&it.test(o.color.trim())&&n.style.setProperty(`--veo-${e}-color`,o.color.trim()),typeof o.fontSize=="number"&&Number.isFinite(o.fontSize)&&n.style.setProperty(`--veo-${e}-size`,`${E(o.fontSize,8,72)}px`),typeof o.width=="number"&&Number.isFinite(o.width)&&n.style.setProperty(`--veo-${e}-width`,`${E(o.width,10,100)}%`),typeof o.radius=="number"&&Number.isFinite(o.radius)&&n.style.setProperty(`--veo-${e}-radius`,`${E(o.radius,0,48)}px`),typeof o.marginTop=="number"&&Number.isFinite(o.marginTop)&&n.style.setProperty(`--veo-${e}-mt`,`${E(o.marginTop,0,64)}px`),typeof o.marginBottom=="number"&&Number.isFinite(o.marginBottom)&&n.style.setProperty(`--veo-${e}-mb`,`${E(o.marginBottom,0,64)}px`);}var Rt=`
2
2
  :host {
3
3
  --veo-primary: #4f46e5;
4
4
  --veo-text: #1f2937;
@@ -259,21 +259,6 @@ var veoGuides=(function(exports){'use strict';function ft(){return typeof window
259
259
  background: transparent;
260
260
  color-scheme: normal;
261
261
  }
262
- /*
263
- * X de cerrar de las gu\xEDas custom: el HTML del cliente vive en un iframe
264
- * sandbox, as\xED que el bot\xF3n lo pone el host POR ENCIMA del iframe. Con fondo
265
- * propio para ser visible sobre cualquier contenido.
266
- */
267
- .veo-custom-close {
268
- position: absolute; top: 6px; right: 6px; z-index: 1;
269
- width: 22px; height: 22px; padding: 0;
270
- display: flex; align-items: center; justify-content: center;
271
- font-size: 16px; line-height: 1; color: #6b7280;
272
- background: rgba(255, 255, 255, 0.92);
273
- border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 50%;
274
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); cursor: pointer;
275
- }
276
- .veo-custom-close:hover { color: #111827; }
277
262
 
278
263
  @keyframes veo-fade-in { from { opacity: 0; } to { opacity: 1; } }
279
264
  @keyframes veo-slide-up {
@@ -284,7 +269,8 @@ var veoGuides=(function(exports){'use strict';function ft(){return typeof window
284
269
  from { transform: translateY(-10px); opacity: 0; }
285
270
  to { transform: translateY(0); opacity: 1; }
286
271
  }
287
- `;var w=class{constructor(){this.host=null;this.shadow=null;this.cleanups=[];}createHost(){let e=document.createElement("div");e.setAttribute(mt,"");let t=e.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=Rt,t.appendChild(o);let r=document.createElement("div");return t.appendChild(r),document.body.appendChild(e),this.host=e,this.shadow=t,{host:e,shadow:t,root:r}}applyDesign(e){this.host&&Et(this.host,e);}registerCleanup(e){this.cleanups.push(e);}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 U=class extends w{render(e){let t=e.nav?.stepIndex??0,o=e.guide.guideSteps[t];if(!o)return;let{root:r}=this.createHost();this.applyDesign(o.style);let i=r.ownerDocument??document,s=o.style?.position==="bottom"?"bottom":"top",a=i.createElement("div");a.className=`veo-banner veo-banner-${s}`;let c=(u,d)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:u}),d&&window.open(d,"_blank","noopener,noreferrer"),e.onClose();},l=e.nav?re(o,e.nav.stepIndex,e.nav.totalSteps,i,e.nav.callbacks):B(o,i,{onCtaClick:(u,d)=>c("cta_clicked",u==="url"?d:void 0),onDismiss:()=>c("dismissed")});a.appendChild(l),r.appendChild(a),e.nav||e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Q=Math.min,z=Math.max,Pe=Math.round;var N=n=>({x:n,y:n}),vn={left:"right",right:"left",bottom:"top",top:"bottom"};function We(n,e,t){return z(n,Q(e,t))}function ie(n,e){return typeof n=="function"?n(e):n}function K(n){return n.split("-")[0]}function se(n){return n.split("-")[1]}function st(n){return n==="x"?"y":"x"}function He(n){return n==="y"?"height":"width"}function W(n){let e=n[0];return e==="t"||e==="b"?"y":"x"}function $e(n){return st(W(n))}function Tt(n,e,t){t===void 0&&(t=false);let o=se(n),r=$e(n),i=He(r),s=r==="x"?o===(t?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Ie(s)),[s,Ie(s)]}function At(n){let e=Ie(n);return [Me(n),e,Me(e)]}function Me(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}var It=["left","right"],Pt=["right","left"],yn=["top","bottom"],wn=["bottom","top"];function bn(n,e,t){switch(n){case "top":case "bottom":return t?e?Pt:It:e?It:Pt;case "left":case "right":return e?yn:wn;default:return []}}function Lt(n,e,t,o){let r=se(n),i=bn(K(n),t==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(Me)))),i}function Ie(n){let e=K(n);return vn[e]+n.slice(e.length)}function xn(n){return {top:0,right:0,bottom:0,left:0,...n}}function at(n){return typeof n!="number"?xn(n):{top:n,right:n,bottom:n,left:n}}function J(n){let{x:e,y:t,width:o,height:r}=n;return {width:o,height:r,top:t,left:e,right:e+o,bottom:t+r,x:e,y:t}}function Nt(n,e,t){let{reference:o,floating:r}=n,i=W(e),s=$e(e),a=He(s),c=K(e),l=i==="y",u=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,p=o[a]/2-r[a]/2,f;switch(c){case "top":f={x:u,y:o.y-r.height};break;case "bottom":f={x:u,y:o.y+o.height};break;case "right":f={x:o.x+o.width,y:d};break;case "left":f={x:o.x-r.width,y:d};break;default:f={x:o.x,y:o.y};}switch(se(e)){case "start":f[s]-=p*(t&&l?-1:1);break;case "end":f[s]+=p*(t&&l?-1:1);break}return f}async function Gt(n,e){var t;e===void 0&&(e={});let{x:o,y:r,platform:i,rects:s,elements:a,strategy:c}=n,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:p=false,padding:f=0}=ie(e,n),h=at(f),g=a[p?d==="floating"?"reference":"floating":d],v=J(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(g)))==null||t?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),y=d==="floating"?{x:o,y:r,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),x=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},T=J(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:c}):y);return {top:(v.top-T.top+h.top)/x.y,bottom:(T.bottom-v.bottom+h.bottom)/x.y,left:(v.left-T.left+h.left)/x.x,right:(T.right-v.right+h.right)/x.x}}var Cn=50,Ot=async(n,e,t)=>{let{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:Gt},c=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:d}=Nt(l,o,c),p=o,f=0,h={};for(let m=0;m<i.length;m++){let g=i[m];if(!g)continue;let{name:v,fn:y}=g,{x:b,y:x,data:T,reset:k}=await y({x:u,y:d,initialPlacement:o,placement:p,strategy:r,middlewareData:h,rects:l,platform:a,elements:{reference:n,floating:e}});u=b??u,d=x??d,h[v]={...h[v],...T},k&&f<Cn&&(f++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(l=k.rects===true?await s.getElementRects({reference:n,floating:e,strategy:r}):k.rects),{x:u,y:d}=Nt(l,p,c)),m=-1);}return {x:u,y:d,placement:p,strategy:r,middlewareData:h}},_t=n=>({name:"arrow",options:n,async fn(e){let{x:t,y:o,placement:r,rects:i,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:u=0}=ie(n,e)||{};if(l==null)return {};let d=at(u),p={x:t,y:o},f=$e(r),h=He(f),m=await s.getDimensions(l),g=f==="y",v=g?"top":"left",y=g?"bottom":"right",b=g?"clientHeight":"clientWidth",x=i.reference[h]+i.reference[f]-p[f]-i.floating[h],T=p[f]-i.reference[f],k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),j=k?k[b]:0;(!j||!await(s.isElement==null?void 0:s.isElement(k)))&&(j=a.floating[b]||i.floating[h]);let Ce=x/2-T/2,V=j/2-m[h]/2-1,D=Q(d[v],V),ke=Q(d[y],V),Y=D,Se=j-m[h]-ke,C=j/2-m[h]/2+Ce,X=We(Y,C,Se),F=!c.arrow&&se(r)!=null&&C!==X&&i.reference[h]/2-(C<Y?D:ke)-m[h]/2<0,A=F?C<Y?C-Y:C-Se:0;return {[f]:p[f]+A,data:{[f]:X,centerOffset:C-X-A,...F&&{alignmentOffset:A}},reset:F}}});var Dt=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,o;let{placement:r,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:u=true,crossAxis:d=true,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=true,...g}=ie(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return {};let v=K(r),y=W(a),b=K(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(l.floating)),T=p||(b||!m?[Ie(a)]:At(a)),k=h!=="none";!p&&k&&T.push(...Lt(a,m,h,x));let j=[a,...T],Ce=await c.detectOverflow(e,g),V=[],D=((o=i.flip)==null?void 0:o.overflows)||[];if(u&&V.push(Ce[v]),d){let C=Tt(r,s,x);V.push(Ce[C[0]],Ce[C[1]]);}if(D=[...D,{placement:r,overflows:V}],!V.every(C=>C<=0)){var ke,Y;let C=(((ke=i.flip)==null?void 0:ke.index)||0)+1,X=j[C];if(X&&(!(d==="alignment"?y!==W(X):false)||D.every(L=>W(L.placement)===y?L.overflows[0]>0:true)))return {data:{index:C,overflows:D},reset:{placement:X}};let F=(Y=D.filter(A=>A.overflows[0]<=0).sort((A,L)=>A.overflows[1]-L.overflows[1])[0])==null?void 0:Y.placement;if(!F)switch(f){case "bestFit":{var Se;let A=(Se=D.filter(L=>{if(k){let $=W(L.placement);return $===y||$==="y"}return true}).map(L=>[L.placement,L.overflows.filter($=>$>0).reduce(($,sn)=>$+sn,0)]).sort((L,$)=>L[1]-$[1])[0])==null?void 0:Se[0];A&&(F=A);break}case "initialPlacement":F=a;break}if(r!==F)return {reset:{placement:F}}}return {}}}};var kn=new Set(["left","top"]);async function Sn(n,e){let{placement:t,platform:o,elements:r}=n,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=K(t),a=se(t),c=W(t)==="y",l=kn.has(s)?-1:1,u=i&&c?-1:1,d=ie(e,n),{mainAxis:p,crossAxis:f,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof h=="number"&&(f=a==="end"?h*-1:h),c?{x:f*u,y:p*l}:{x:p*l,y:f*u}}var Ft=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,o;let{x:r,y:i,placement:s,middlewareData:a}=e,c=await Sn(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(o=a.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:i+c.y,data:{...c,placement:s}}}}},Mt=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){let{x:t,y:o,placement:r,platform:i}=e,{mainAxis:s=true,crossAxis:a=false,limiter:c={fn:v=>{let{x:y,y:b}=v;return {x:y,y:b}}},...l}=ie(n,e),u={x:t,y:o},d=await i.detectOverflow(e,l),p=W(K(r)),f=st(p),h=u[f],m=u[p];if(s){let v=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=h+d[v],x=h-d[y];h=We(b,h,x);}if(a){let v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=m+d[v],x=m-d[y];m=We(b,m,x);}let g=c.fn({...e,[f]:h,[p]:m});return {...g,data:{x:g.x-t,y:g.y-o,enabled:{[f]:s,[p]:a}}}}}};function Ue(){return typeof window<"u"}function ee(n){return Ht(n)?(n.nodeName||"").toLowerCase():"#document"}function S(n){var e;return (n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function O(n){var e;return (e=(Ht(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Ht(n){return Ue()?n instanceof Node||n instanceof S(n).Node:false}function R(n){return Ue()?n instanceof Element||n instanceof S(n).Element:false}function _(n){return Ue()?n instanceof HTMLElement||n instanceof S(n).HTMLElement:false}function Wt(n){return !Ue()||typeof ShadowRoot>"u"?false:n instanceof ShadowRoot||n instanceof S(n).ShadowRoot}function ae(n){let{overflow:e,overflowX:t,overflowY:o,display:r}=I(n);return /auto|scroll|overlay|hidden|clip/.test(e+o+t)&&r!=="inline"&&r!=="contents"}function $t(n){return /^(table|td|th)$/.test(ee(n))}function Te(n){try{if(n.matches(":popover-open"))return !0}catch{}try{return n.matches(":modal")}catch{return false}}var En=/transform|translate|scale|rotate|perspective|filter/,Rn=/paint|layout|strict|content/,Z=n=>!!n&&n!=="none",lt;function ze(n){let e=R(n)?I(n):n;return Z(e.transform)||Z(e.translate)||Z(e.scale)||Z(e.rotate)||Z(e.perspective)||!Ke()&&(Z(e.backdropFilter)||Z(e.filter))||En.test(e.willChange||"")||Rn.test(e.contain||"")}function Bt(n){let e=H(n);for(;_(e)&&!te(e);){if(ze(e))return e;if(Te(e))return null;e=H(e);}return null}function Ke(){return lt==null&&(lt=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),lt}function te(n){return /^(html|body|#document)$/.test(ee(n))}function I(n){return S(n).getComputedStyle(n)}function Ae(n){return R(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function H(n){if(ee(n)==="html")return n;let e=n.assignedSlot||n.parentNode||Wt(n)&&n.host||O(n);return Wt(e)?e.host:e}function Ut(n){let e=H(n);return te(e)?n.ownerDocument?n.ownerDocument.body:n.body:_(e)&&ae(e)?e:Ut(e)}function Be(n,e,t){var o;e===void 0&&(e=[]);let r=Ut(n),i=r===((o=n.ownerDocument)==null?void 0:o.body),s=S(r);if(i){qe(s);return e.concat(s,s.visualViewport||[],ae(r)?r:[],[])}else return e.concat(r,Be(r,[]))}function qe(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function jt(n){let e=I(n),t=parseFloat(e.width)||0,o=parseFloat(e.height)||0,r=_(n),i=r?n.offsetWidth:t,s=r?n.offsetHeight:o,a=Pe(t)!==i||Pe(o)!==s;return a&&(t=i,o=s),{width:t,height:o,$:a}}function Vt(n){return R(n)?n:n.contextElement}function le(n){let e=Vt(n);if(!_(e))return N(1);let t=e.getBoundingClientRect(),{width:o,height:r,$:i}=jt(e),s=(i?Pe(t.width):t.width)/o,a=(i?Pe(t.height):t.height)/r;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var In=N(0);function Yt(n){let e=S(n);return !Ke()||!e.visualViewport?In:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Pn(n,e,t){return e===void 0&&(e=false),!t||e&&t!==S(n)?false:e}function Le(n,e,t,o){e===void 0&&(e=false),t===void 0&&(t=false);let r=n.getBoundingClientRect(),i=Vt(n),s=N(1);e&&(o?R(o)&&(s=le(o)):s=le(n));let a=Pn(i,t,o)?Yt(i):N(0),c=(r.left+a.x)/s.x,l=(r.top+a.y)/s.y,u=r.width/s.x,d=r.height/s.y;if(i){let p=S(i),f=o&&R(o)?S(o):o,h=p,m=qe(h);for(;m&&o&&f!==h;){let g=le(m),v=m.getBoundingClientRect(),y=I(m),b=v.left+(m.clientLeft+parseFloat(y.paddingLeft))*g.x,x=v.top+(m.clientTop+parseFloat(y.paddingTop))*g.y;c*=g.x,l*=g.y,u*=g.x,d*=g.y,c+=b,l+=x,h=S(m),m=qe(h);}}return J({width:u,height:d,x:c,y:l})}function je(n,e){let t=Ae(n).scrollLeft;return e?e.left+t:Le(O(n)).left+t}function Xt(n,e){let t=n.getBoundingClientRect(),o=t.left+e.scrollLeft-je(n,t),r=t.top+e.scrollTop;return {x:o,y:r}}function Tn(n){let{elements:e,rect:t,offsetParent:o,strategy:r}=n,i=r==="fixed",s=O(o),a=e?Te(e.floating):false;if(o===s||a&&i)return t;let c={scrollLeft:0,scrollTop:0},l=N(1),u=N(0),d=_(o);if((d||!d&&!i)&&((ee(o)!=="body"||ae(s))&&(c=Ae(o)),d)){let f=Le(o);l=le(o),u.x=f.x+o.clientLeft,u.y=f.y+o.clientTop;}let p=s&&!d&&!i?Xt(s,c):N(0);return {width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-c.scrollLeft*l.x+u.x+p.x,y:t.y*l.y-c.scrollTop*l.y+u.y+p.y}}function An(n){return Array.from(n.getClientRects())}function Ln(n){let e=O(n),t=Ae(n),o=n.ownerDocument.body,r=z(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=z(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-t.scrollLeft+je(n),a=-t.scrollTop;return I(o).direction==="rtl"&&(s+=z(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:a}}var zt=25;function Nn(n,e){let t=S(n),o=O(n),r=t.visualViewport,i=o.clientWidth,s=o.clientHeight,a=0,c=0;if(r){i=r.width,s=r.height;let u=Ke();(!u||u&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop);}let l=je(o);if(l<=0){let u=o.ownerDocument,d=u.body,p=getComputedStyle(d),f=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,h=Math.abs(o.clientWidth-d.clientWidth-f);h<=zt&&(i-=h);}else l<=zt&&(i+=l);return {width:i,height:s,x:a,y:c}}function Gn(n,e){let t=Le(n,true,e==="fixed"),o=t.top+n.clientTop,r=t.left+n.clientLeft,i=_(n)?le(n):N(1),s=n.clientWidth*i.x,a=n.clientHeight*i.y,c=r*i.x,l=o*i.y;return {width:s,height:a,x:c,y:l}}function Kt(n,e,t){let o;if(e==="viewport")o=Nn(n,t);else if(e==="document")o=Ln(O(n));else if(R(e))o=Gn(e,t);else {let r=Yt(n);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height};}return J(o)}function Qt(n,e){let t=H(n);return t===e||!R(t)||te(t)?false:I(t).position==="fixed"||Qt(t,e)}function On(n,e){let t=e.get(n);if(t)return t;let o=Be(n,[]).filter(a=>R(a)&&ee(a)!=="body"),r=null,i=I(n).position==="fixed",s=i?H(n):n;for(;R(s)&&!te(s);){let a=I(s),c=ze(s);!c&&a.position==="fixed"&&(r=null),(i?!c&&!r:!c&&a.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||ae(s)&&!c&&Qt(n,s))?o=o.filter(u=>u!==s):r=a,s=H(s);}return e.set(n,o),o}function _n(n){let{element:e,boundary:t,rootBoundary:o,strategy:r}=n,s=[...t==="clippingAncestors"?Te(e)?[]:On(e,this._c):[].concat(t),o],a=Kt(e,s[0],r),c=a.top,l=a.right,u=a.bottom,d=a.left;for(let p=1;p<s.length;p++){let f=Kt(e,s[p],r);c=z(f.top,c),l=Q(f.right,l),u=Q(f.bottom,u),d=z(f.left,d);}return {width:l-d,height:u-c,x:d,y:c}}function Dn(n){let{width:e,height:t}=jt(n);return {width:e,height:t}}function Fn(n,e,t){let o=_(e),r=O(e),i=t==="fixed",s=Le(n,true,i,e),a={scrollLeft:0,scrollTop:0},c=N(0);function l(){c.x=je(r);}if(o||!o&&!i)if((ee(e)!=="body"||ae(r))&&(a=Ae(e)),o){let f=Le(e,true,i,e);c.x=f.x+e.clientLeft,c.y=f.y+e.clientTop;}else r&&l();i&&!o&&r&&l();let u=r&&!o&&!i?Xt(r,a):N(0),d=s.left+a.scrollLeft-c.x-u.x,p=s.top+a.scrollTop-c.y-u.y;return {x:d,y:p,width:s.width,height:s.height}}function ct(n){return I(n).position==="static"}function qt(n,e){if(!_(n)||I(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return O(n)===t&&(t=t.ownerDocument.body),t}function Jt(n,e){let t=S(n);if(Te(n))return t;if(!_(n)){let r=H(n);for(;r&&!te(r);){if(R(r)&&!ct(r))return r;r=H(r);}return t}let o=qt(n,e);for(;o&&$t(o)&&ct(o);)o=qt(o,e);return o&&te(o)&&ct(o)&&!ze(o)?t:o||Bt(n)||t}var Mn=async function(n){let e=this.getOffsetParent||Jt,t=this.getDimensions,o=await t(n.floating);return {reference:Fn(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Wn(n){return I(n).direction==="rtl"}var Hn={convertOffsetParentRelativeRectToViewportRelativeRect:Tn,getDocumentElement:O,getClippingRect:_n,getOffsetParent:Jt,getElementRects:Mn,getClientRects:An,getDimensions:Dn,getScale:le,isElement:R,isRTL:Wn};var ce=Ft;var de=Mt,ue=Dt;var Ve=_t;var pe=(n,e,t)=>{let o=new Map,r={platform:Hn,...t},i={...r.platform,_c:o};return Ot(n,e,{...r,platform:i})};function P(n,e=5e3){return new Promise(t=>{let o=()=>{try{return document.querySelector(n)}catch{return null}},r=o();if(r){t(r);return}let i=false,s=l=>{i||(i=true,a.disconnect(),clearTimeout(c),t(l));},a=new MutationObserver(()=>{let l=o();l&&s(l);});a.observe(document.body,{childList:true,subtree:true});let c=setTimeout(()=>s(null),e);})}function Zt(){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 r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let o=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),o.slice(0,4),o.slice(4,8),o.slice(8,20)].join("-")}function Ye(n,e,t,o){let r=n.createElement("iframe");r.className="veo-custom-frame",r.setAttribute("sandbox","allow-scripts"),r.setAttribute("title",t.guide.guideName||"Veo"),r.style.width=o.width;let i=o.fixedHeight!==void 0&&o.fixedHeight!==null;i&&(r.style.height=ut(o.fixedHeight));let s=Zt(),a=e.style?.tailwind===true;r.srcdoc=Un(e.html??"",e.css??"",e.js??"",s,{tokens:$n(),tailwind:a});let c=()=>t.onClose(),l=u=>{if(u.source!==r.contentWindow)return;let d=u.data;if(!(!d||typeof d!="object"||d.__veo!==s))switch(d.type){case "dismiss":t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"dismissed"}),c();break;case "cta":t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"cta_clicked"}),typeof d.url=="string"&&G(d.url)&&window.open(d.url,"_blank","noopener,noreferrer"),d.close!==false&&c();break;case "navigate":typeof d.url=="string"&&G(d.url)&&window.location.assign(d.url);break;case "track":typeof d.name=="string"&&t.onTrack&&t.onTrack(d.name,Bn(d.props)?d.props:void 0);break;case "resize":!i&&typeof d.height=="number"&&d.height>0&&(r.style.height=`${Math.ceil(d.height)}px`);break}};return window.addEventListener("message",l),{iframe:r,cleanup:()=>window.removeEventListener("message",l)}}function ut(n){return typeof n=="number"?`${n}px`:n}function $n(){if(typeof window>"u"||typeof document>"u")return "";try{let n=getComputedStyle(document.documentElement),e=[],t=new Set;for(let r=0;r<n.length&&e.length<400;r++){let i=n.item(r);if(!i.startsWith("--")||t.has(i))continue;t.add(i);let s=n.getPropertyValue(i).trim();!s||s.length>200||/[<>{}]/.test(s)||e.push(`${i}:${s}`);}let o=getComputedStyle(document.body).fontFamily;return o&&o.length<=200&&!/[<>{}]/.test(o)&&e.push(`--veo-host-font:${o}`),e.length?`:root{${e.join(";")}}`:""}catch{return ""}}function Bn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Un(n,e,t,o,r){let i=`(function(){var T=${JSON.stringify(o)};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(){P({type:'resize',height:Math.ceil(document.documentElement.scrollHeight)});}window.addEventListener('load',H);try{if(typeof ResizeObserver!=='undefined'){new ResizeObserver(H).observe(document.documentElement);}}catch(e){}})();`,s=r.tokens?`<style>${dt(r.tokens,"style")}</style>`:"",a=r.tailwind?'<script src="https://cdn.tailwindcss.com"></script>':"";return '<!DOCTYPE html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;font-family:var(--veo-host-font,system-ui,sans-serif);}</style>'+s+a+`<style>${dt(e,"style")}</style></head><body>${n}<script>${i}</script>`+(t?`<script>${dt(t,"script")}</script>`:"")+"</body></html>"}function dt(n,e){let t=e==="script"?/<\/script/gi:/<\/style/gi;return n.replace(t,`<\\/${e}`)}var zn={mode:"floating",position:"bottom-right"},en=16,Kn=360,fe=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let o=t.placement??zn,r=null;if(o.mode==="anchored"){let u=o.selector??t.selector??e.guide.activationRules.selector;if(typeof u!="string"||u.length===0||(r=await P(u),!r))return}let{root:i}=this.createHost(),s=i.ownerDocument??document,a=s.createElement("div");a.className=o.mode==="anchored"?"veo-custom-anchored":"veo-custom-floating";let{iframe:c,cleanup:l}=Ye(s,t,e,{width:ut(o.width??Kn),fixedHeight:o.height??null});this.registerCleanup(l),a.appendChild(c),a.appendChild(M(s,()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();},"veo-custom-close")),i.appendChild(a),o.mode==="floating"?qn(a,o):r&&this.registerCleanup(await this.setupAnchoredPosition(r,a,o)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}async setupAnchoredPosition(e,t,o){let r=o.side??"bottom",i=async()=>{let{x:a,y:c}=await pe(e,t,{placement:r,strategy:"fixed",middleware:[ce(o.offsetY??8),ue(),de({padding:8})]});t.style.left=`${a}px`,t.style.top=`${c}px`;};await i();let s=()=>{i();};return window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}}};function qn(n,e){let t=e.position??"bottom-right",o=`${e.offsetX??en}px`,r=`${e.offsetY??en}px`,i=n.style;if(t==="center"){i.top="50%",i.left="50%",i.transform="translate(-50%, -50%)";return}let[s,a]=t.split("-");s==="top"?i.top=r:i.bottom=r,a==="left"?i.left=o:a==="right"?i.right=o:(i.left="50%",i.transform="translateX(-50%)");}function Xe(n,e,t){let o=e.guide.guideSteps[0];if(!o)return;let r=o.fields??[],i=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();},s=t.createElement("div");if(s.className="veo-guide-content",o.title){let p=t.createElement("h2");p.className="veo-guide-title",p.textContent=o.title,s.appendChild(p);}if(o.content){let p=t.createElement("p");p.className="veo-guide-text",p.textContent=o.content,s.appendChild(p);}let a=[],c=t.createElement("form");c.className="veo-form",c.noValidate=true;for(let p of r){let{wrapper:f,read:h}=Vn(p,t);a.push({field:p,read:h}),c.appendChild(f);}let l=t.createElement("p");l.className="veo-form-error",l.style.display="none",c.appendChild(l);let u=t.createElement("div");u.className="veo-guide-actions";let d=t.createElement("button");d.type="submit",d.className="veo-guide-cta",d.textContent=o.ctaText||"Enviar",u.appendChild(d),c.appendChild(u),c.addEventListener("submit",p=>{p.preventDefault(),l.style.display="none";let f={};for(let{field:m,read:g}of a){let v=g();if(v==null||v===""){if(m.required){l.textContent=`Complet\xE1 "${m.label}"`,l.style.display="block";return}continue}f[m.key]=v;}if(Object.keys(f).length===0){l.textContent="Respond\xE9 al menos un campo",l.style.display="block";return}d.disabled=true,(e.onFormSubmit??(()=>Promise.resolve(true)))(f).then(m=>{if(!m){d.disabled=false,l.textContent="No se pudo enviar. Prob\xE1 de nuevo.",l.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;jn(n,t,g),window.setTimeout(()=>e.onClose(),g?2200:1400);});}),s.appendChild(c),s.appendChild(M(t,i)),n.appendChild(s);}function jn(n,e,t){for(;n.firstChild;)n.removeChild(n.firstChild);let o=e.createElement("div");if(o.className="veo-form-thanks",o.textContent="\u2713 \xA1Gracias por tu respuesta!",n.appendChild(o),t){let r=e.createElement("p");r.className="veo-form-preview-note",r.textContent=t,n.appendChild(r);}}function Vn(n,e){let t=e.createElement("div");t.className="veo-form-field";let o=e.createElement("label");switch(o.className="veo-form-label",o.textContent=n.required?`${n.label} *`:n.label,t.appendChild(o),n.type){case "textarea":{let r=e.createElement("textarea");return r.className="veo-form-input",r.rows=3,n.placeholder&&(r.placeholder=n.placeholder),t.appendChild(r),{wrapper:t,read:()=>r.value.trim()}}case "number":{let r=e.createElement("input");return r.type="number",r.className="veo-form-input",n.placeholder&&(r.placeholder=n.placeholder),t.appendChild(r),{wrapper:t,read:()=>r.value.trim()===""?void 0:Number(r.value)}}case "select":{let r=e.createElement("select");r.className="veo-form-input";let i=e.createElement("option");i.value="",i.textContent=n.placeholder||"Eleg\xED una opci\xF3n\u2026",r.appendChild(i);for(let s of n.options??[]){let a=e.createElement("option");a.value=s,a.textContent=s,r.appendChild(a);}return t.appendChild(r),{wrapper:t,read:()=>r.value||void 0}}case "radio":{let r=e.createElement("div");r.className="veo-form-options";let i=`veo-${n.key}`,s=[];for(let a of n.options??[]){let c=e.createElement("label");c.className="veo-form-option";let l=e.createElement("input");l.type="radio",l.name=i,l.value=a,s.push(l);let u=e.createElement("span");u.textContent=a,c.appendChild(l),c.appendChild(u),r.appendChild(c);}return t.appendChild(r),{wrapper:t,read:()=>s.find(a=>a.checked)?.value}}case "multiselect":{let r=e.createElement("div");r.className="veo-form-options";let i=[];for(let s of n.options??[]){let a=e.createElement("label");a.className="veo-form-option";let c=e.createElement("input");c.type="checkbox",c.value=s,i.push(c);let l=e.createElement("span");l.textContent=s,a.appendChild(c),a.appendChild(l),r.appendChild(a);}return t.appendChild(r),{wrapper:t,read:()=>{let s=i.filter(a=>a.checked).map(a=>a.value);return s.length>0?s:void 0}}}case "checkbox":{let r=e.createElement("label");r.className="veo-form-option";let i=e.createElement("input");i.type="checkbox";let s=e.createElement("span");return s.textContent=n.placeholder||"S\xED",r.appendChild(i),r.appendChild(s),t.appendChild(r),{wrapper:t,read:()=>i.checked?true:n.required?"":false}}case "yesno":{let r=e.createElement("div");r.className="veo-form-options";let i=`veo-${n.key}`,[s,a]=n.options?.length===2?n.options:["S\xED","No"],c=[];for(let{label:l,value:u}of [{label:s,value:true},{label:a,value:false}]){let d=e.createElement("label");d.className="veo-form-option";let p=e.createElement("input");p.type="radio",p.name=i,c.push({input:p,value:u});let f=e.createElement("span");f.textContent=l,d.appendChild(p),d.appendChild(f),r.appendChild(d);}return t.appendChild(r),{wrapper:t,read:()=>c.find(l=>l.input.checked)?.value}}case "nps":return tn(t,e,0,10,"veo-nps-btn");case "rating":return tn(t,e,1,5,"veo-rating-btn","\u2605");default:{let r=e.createElement("input");return r.type="text",r.className="veo-form-input",n.placeholder&&(r.placeholder=n.placeholder),t.appendChild(r),{wrapper:t,read:()=>r.value.trim()}}}}function tn(n,e,t,o,r,i){let s=e.createElement("div");s.className="veo-form-scale";let a,c=[];for(let l=t;l<=o;l++){let u=e.createElement("button");u.type="button",u.className=r,u.textContent=i??String(l),u.setAttribute("aria-label",String(l)),u.addEventListener("click",()=>{a=l,c.forEach((d,p)=>{let f=i?p+t<=l:p+t===l;d.classList.toggle("veo-scale-active",f);});}),c.push(u),s.appendChild(u);}return n.appendChild(s),{wrapper:n,read:()=>a}}var he=class extends w{render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let{root:o}=this.createHost();this.applyDesign(t.style);let r=o.ownerDocument??document,i=r.createElement("div");i.className="veo-modal-overlay";let s=r.createElement("div");s.className="veo-modal-card",Xe(s,e,r),i.appendChild(s),o.appendChild(i);let a=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();};i.addEventListener("click",l=>{l.target===i&&a();});let c=l=>{l.key==="Escape"&&a();};document.addEventListener("keydown",c),this.registerCleanup(()=>document.removeEventListener("keydown",c)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};function me(n){let e=n?.inlinePosition;return e==="before"||e==="prepend"||e==="append"?e:"after"}function ne(n,e,t){switch(t){case "before":n.before(e);break;case "after":n.after(e);break;case "prepend":n.prepend(e);break;case "append":n.append(e);break}}function ge(n,e,t){let o=window.setInterval(()=>{if(n.isConnected)return;let r=document.querySelector(e);r&&ne(r,n,t);},1e3);return ()=>window.clearInterval(o)}var ve=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let{host:i,root:s}=this.createHost();i.style.display="block";let a=me(t.style);ne(r,i,a),this.registerCleanup(ge(i,o,a));let c=s.ownerDocument??document,l=c.createElement("div");l.className="veo-custom-inline";let{iframe:u,cleanup:d}=Ye(c,t,e,{width:"100%"});this.registerCleanup(d),l.appendChild(u),l.appendChild(M(c,()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();},"veo-custom-close")),s.appendChild(l),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var ye=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let{host:i,root:s}=this.createHost();i.style.display="block";let a=me(t.style);ne(r,i,a),this.registerCleanup(ge(i,o,a)),this.applyDesign(t.style);let c=s.ownerDocument??document,l=c.createElement("div");l.className="veo-inline",Xe(l,e,c),s.appendChild(l),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var we=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let{host:i,root:s}=this.createHost();i.style.display="block";let a=me(t.style);ne(r,i,a),this.registerCleanup(ge(i,o,a)),this.applyDesign(t.style);let c=s.ownerDocument??document,l=c.createElement("div");l.className="veo-inline";let u=(p,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:p}),f&&window.open(f,"_blank","noopener,noreferrer"),e.onClose();},d=B(t,c,{onCtaClick:(p,f)=>u("cta_clicked",p==="url"?f:void 0),onDismiss:()=>u("dismissed")});l.appendChild(d),s.appendChild(l),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var q=class extends w{render(e){let t=e.nav?.stepIndex??0,o=e.guide.guideSteps[t];if(!o)return;let{root:r}=this.createHost();this.applyDesign(o.style);let i=r.ownerDocument??document,s=i.createElement("div");s.className="veo-modal-overlay";let a=i.createElement("div");a.className="veo-modal-card";let c=(p,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:p}),f&&window.open(f,"_blank","noopener,noreferrer"),e.onClose();},l=()=>{e.nav?e.nav.callbacks.onSkip():c("dismissed");},u=e.nav?re(o,e.nav.stepIndex,e.nav.totalSteps,i,e.nav.callbacks):B(o,i,{onCtaClick:(p,f)=>c("cta_clicked",p==="url"?f:void 0),onDismiss:()=>c("dismissed")});a.appendChild(u),s.appendChild(a),r.appendChild(s),s.addEventListener("click",p=>{p.target===s&&l();});let d=p=>{p.key==="Escape"&&l();};document.addEventListener("keydown",d),this.registerCleanup(()=>document.removeEventListener("keydown",d)),e.nav||e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Yn={top:"bottom",bottom:"top",left:"right",right:"left"};function Qe(n,e,t){let o=Yn[e.split("-")[0]??"bottom"]??"top";for(let r of ["top","bottom","left","right"])n.style.setProperty(r,"");t?.x!=null&&n.style.setProperty("left",`${t.x}px`),t?.y!=null&&n.style.setProperty("top",`${t.y}px`),n.style.setProperty(o,"-6px");}var be=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let i=t.style?.tooltipPlacement,s=i==="top"||i==="left"||i==="right"?i:"bottom",{root:a}=this.createHost();this.applyDesign(t.style);let c=a.ownerDocument??document,l=c.createElement("div");l.className="veo-tooltip";let u=(m,g)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:m}),g&&window.open(g,"_blank","noopener,noreferrer"),e.onClose();},d=B(t,c,{onCtaClick:(m,g)=>{u("cta_clicked",m==="url"?g:void 0);},onDismiss:()=>u("dismissed")});l.appendChild(d);let p=c.createElement("div");p.className="veo-tooltip-arrow",l.appendChild(p),a.appendChild(l);let f=async()=>{let{x:m,y:g,placement:v,middlewareData:y}=await pe(r,l,{placement:s,middleware:[ce(10),ue(),de({padding:8}),Ve({element:p})]});l.style.left=`${m}px`,l.style.top=`${g}px`,Qe(p,v,y.arrow);};await f();let h=()=>{f();};window.addEventListener("scroll",h,true),window.addEventListener("resize",h),this.registerCleanup(()=>{window.removeEventListener("scroll",h,true),window.removeEventListener("resize",h);}),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var xe=class extends w{async render(e){let t=e.guide.guideSteps[e.currentStepIndex];if(!t)return false;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return false;let r=await P(o,5e3);if(!r)return false;let i=t.style?.tooltipPlacement,s=i==="top"||i==="left"||i==="right"?i:"bottom",{root:a}=this.createHost();this.applyDesign(t.style);let c=a.ownerDocument??document,l=c.createElement("div");l.className="veo-walkthrough";let u=re(t,e.currentStepIndex,e.guide.guideSteps.length,c,e.callbacks);l.appendChild(u);let d=c.createElement("div");d.className="veo-walkthrough-arrow",l.appendChild(d),a.appendChild(l);let p=async()=>{let{x:h,y:m,placement:g,middlewareData:v}=await pe(r,l,{placement:s,middleware:[ce(10),ue(),de({padding:8}),Ve({element:d})]});l.style.left=`${h}px`,l.style.top=`${m}px`,Qe(d,g,v.arrow);};await p();let f=()=>{p();};return window.addEventListener("scroll",f,true),window.addEventListener("resize",f),this.registerCleanup(()=>{window.removeEventListener("scroll",f,true),window.removeEventListener("resize",f);}),true}};var Je=class{constructor(e){this.state=null;this.storageKey=`${vt}${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 o=Date.now();return this.state={guideId:e,totalSteps:t,currentStepIndex:0,startedAt:o,lastProgressAt:o},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 o=t;return typeof o.guideId!="string"||typeof o.totalSteps!="number"||typeof o.currentStepIndex!="number"||typeof o.startedAt!="number"||typeof o.lastProgressAt!="number"?null:o}catch{return null}}persist(){if(!(typeof localStorage>"u"||!this.state))try{localStorage.setItem(this.storageKey,JSON.stringify(this.state));}catch{}}};var Qn={shown:"shown",dismissed:"dismissed",cta_clicked:null,step_advanced:null,step_back:null,completed:"completed"},Ze=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;if(this.debug=t.debug===true,this.apiUrl=t.apiUrl,this.apiKey=t.apiKey,this.resolver=t.resolver??new Oe(t.apiUrl,t.apiKey,this.debug),t.trackerQueue)this.trackerQueue=t.trackerQueue;else {let r=new _e(t.apiUrl,t.apiKey);this.trackerQueue=new De({client:r,flushIntervalMs:3e3,batchSize:5,maxRetries:3,onError:(i,s)=>{this.debug&&console.warn(`[veo] dropped guide interaction after retries: guideId=${s.guideId} action=${s.payload.action}`,i);}});}let o=bt(t.apiKey);this.frequencyCache=t.frequencyCache??new Ge(o),this.walkthroughState=t.walkthroughState??new Je(o);}get pendingInteractions(){return this.trackerQueue.size}clearFrequencyCache(){this.frequencyCache.clear();}clearWalkthroughState(){this.tearDownWalkthrough();}async checkGuides(e,t){let o=this.client.getEndUserId();if(!o){this.debug&&console.log("[veo] guides: skipped, no endUserId yet");return}if(await this.tryResumeWalkthrough(o,t,e))return;let r;try{r=await this.resolver.resolve(o,e);}catch(i){this.debug&&console.error("[veo] guides resolver threw:",i);return}this.debug&&console.log(`[veo] guides: ${r.length} eligible at ${e}`);for(let i of r){if(this.frequencyCache.shouldFilter(i.guideId,i.displayFrequency)){this.debug&&console.log(`[veo] guides: filtered locally guideId=${i.guideId}`);continue}if(this.activeByGuideId.has(i.guideId)){this.debug&&console.log(`[veo] guides: already shown guideId=${i.guideId}`);continue}if(i.guideType==="walkthrough"&&i.guideSteps.length>1){if(this.walkthroughState.hasActive()){this.debug&&console.log(`[veo] guides: walkthrough ${i.guideId} skipped (another active)`);continue}await this.startWalkthrough(i,o,t,e);continue}this.runSingleStepRender(i,t,e);}}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.dispatched.clear(),this.trackerQueue.destroy();}runSingleStepRender(e,t,o){let r=this.createSingleStepRenderer(e.guideType);if(!r)return;this.activeByGuideId.set(e.guideId,r);let i=e.activationRules.delayMs??0;window.setTimeout(()=>this.mountSingleStepRenderer(e,r,t,o),i);}mountSingleStepRenderer(e,t,o,r){this.activeRenderers.add(t),this.activeByGuideId.set(e.guideId,t);let i=()=>{t.destroy(),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);},s=l=>{this.handleInteraction(e,o,r,l);},a=(l,u)=>{this.client.track(l,u);},c=l=>this.submitFormResponse(e.guideId,l);try{t.render({guide:e,onInteraction:s,onClose:i,onTrack:a,onFormSubmit:c});}catch(l){this.debug&&console.error("[veo] renderer.render threw:",l),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);}}async tryResumeWalkthrough(e,t,o){let r=this.walkthroughState.current();if(!r)return false;let i=await this.resolver.fetchById(r.guideId);if(!i||i.guideType!=="walkthrough")return this.debug&&console.log(`[veo] guides: walkthrough ${r.guideId} no longer available, cleaning up`),this.tearDownWalkthrough(),true;let s=Math.min(r.currentStepIndex,i.guideSteps.length-1);return await this.renderWalkthroughStep(i,s,e,t,o),true}async startWalkthrough(e,t,o,r){this.walkthroughState.start(e.guideId,e.guideSteps.length),await this.renderWalkthroughStep(e,0,t,o,r)&&(this.enqueueInteractionOnce(e.guideId,t,o,r,"shown",0),this.frequencyCache.record(e.guideId,"shown"));}async renderWalkthroughStep(e,t,o,r,i){this.activeWalkthroughRenderer&&(this.activeWalkthroughRenderer.destroy(),this.activeWalkthroughRenderer=null),this.activeWalkthroughGuide=e;let s={onNext:()=>this.handleWalkthroughNext(o,r,i),onBack:()=>this.handleWalkthroughBack(o,r,i),onSkip:()=>this.handleWalkthroughSkip(o,r,i),onComplete:()=>this.handleWalkthroughComplete(o,r,i)},a=e.guideSteps[t],c=Jn(a);if(c==="modal"||c==="banner"){let d=c==="modal"?new q:new U;try{d.render({guide:e,onInteraction:()=>{},onClose:()=>{},nav:{stepIndex:t,totalSteps:e.guideSteps.length,callbacks:s}});}catch(p){return this.debug&&console.error("[veo] sequence renderer threw:",p),this.tearDownWalkthrough(),false}return this.activeWalkthroughRenderer=d,true}let l=new xe,u=false;try{u=await l.render({guide:e,currentStepIndex:t,callbacks:s});}catch(d){this.debug&&console.error("[veo] walkthrough renderer threw:",d);}return u?(this.activeWalkthroughRenderer=l,true):(this.debug&&console.warn(`[veo] walkthrough ${e.guideId} step ${t} could not render, cancelling`),this.tearDownWalkthrough(),false)}handleWalkthroughNext(e,t,o){let r=this.activeWalkthroughGuide;if(!r)return;let i=this.walkthroughState.advance();if(!i){this.handleWalkthroughComplete(e,t,o);return}this.enqueueInteraction(r.guideId,e,t,o,"step_advanced",i.currentStepIndex),this.renderWalkthroughStep(r,i.currentStepIndex,e,t,o);}handleWalkthroughBack(e,t,o){let r=this.activeWalkthroughGuide;if(!r)return;let i=this.walkthroughState.current();if(!i||i.currentStepIndex===0)return;let s=this.walkthroughState.back();s&&(this.enqueueInteraction(r.guideId,e,t,o,"step_back",s.currentStepIndex),this.renderWalkthroughStep(r,s.currentStepIndex,e,t,o));}handleWalkthroughSkip(e,t,o){let r=this.activeWalkthroughGuide,i=this.walkthroughState.current();!r||!i||(this.enqueueInteraction(r.guideId,e,t,o,"dismissed",i.currentStepIndex),this.frequencyCache.record(r.guideId,"dismissed"),this.tearDownWalkthrough());}handleWalkthroughComplete(e,t,o){let r=this.activeWalkthroughGuide,i=this.walkthroughState.current();!r||!i||(this.enqueueInteraction(r.guideId,e,t,o,"completed",i.currentStepIndex),this.frequencyCache.record(r.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,o,r){let i=`${e.guideId}:${r.action}`;if(this.dispatched.has(i)){this.debug&&console.log(`[veo] guides: dedup hit ${i}`);return}this.dispatched.add(i);let s=Qn[r.action];s&&this.frequencyCache.record(e.guideId,s);let a=this.client.getEndUserId();if(!a){this.debug&&console.warn("[veo] guides: interaction without endUserId \u2014 skipping enqueue");return}this.trackerQueue.enqueue({guideId:e.guideId,payload:{endUserId:a,sessionId:t,action:r.action,stepIndex:r.stepIndex,pageUrl:o,pagePath:nn(o)}});}enqueueInteraction(e,t,o,r,i,s){this.trackerQueue.enqueue({guideId:e,payload:{endUserId:t,sessionId:o,action:i,stepIndex:s,pageUrl:r,pagePath:nn(r)}});}enqueueInteractionOnce(e,t,o,r,i,s){let a=`${e}:${i}:${s}`;this.dispatched.has(a)||(this.dispatched.add(a),this.enqueueInteraction(e,t,o,r,i,s));}createSingleStepRenderer(e){switch(e){case "modal":return new q;case "banner":return new U;case "tooltip":return new be;case "custom":return new fe;case "inline":return new we;case "inline-custom":return new ve;case "form":return new he;case "inline-form":return new ye;case "walkthrough":return null}}async submitFormResponse(e,t){let o=this.client.getEndUserId()??this.client.getAnonymousId();try{let r=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:o,answers:t})});return !r.ok&&this.debug&&console.warn("[veo] form-response respondi\xF3",r.status),r.ok}catch(r){return this.debug&&console.warn("[veo] form-response fall\xF3:",r),false}}};function nn(n){try{return new URL(n).pathname}catch{return "/"}}function Jn(n){let e=n?.style?.render;return typeof e=="string"?e:"walkthrough"}var Zn="__veo_preview__",pt=class{constructor(){this.singleStep=null;this.walkthrough=null;this.walkthroughGuide=null;this.walkthroughIndex=0;this.input=null;}preview(e){this.close(),this.input=e;let t=eo(e),o=typeof e.startStepIndex=="number"?e.startStepIndex:0,r=t.guideType==="walkthrough"?this.startWalkthrough(t,o):this.renderSingleStep(t);return {close:()=>this.close(),ready:r}}close(){this.singleStep&&(oe(this.singleStep),this.singleStep=null),this.walkthrough&&(oe(this.walkthrough),this.walkthrough=null),this.walkthroughGuide=null,this.walkthroughIndex=0,this.input=null;}async renderSingleStep(e){let t=to(e.guideType);if(!t)return {rendered:false};this.singleStep=t;let o=false;try{await t.render({guide:e,onInteraction:r=>{r.action==="shown"&&(o=!0);},onClose:()=>this.close(),onTrack:()=>{},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?(oe(t),{rendered:false}):{rendered:o}}async startWalkthrough(e,t=0){if(e.guideSteps.length===0)return {rendered:false};this.walkthroughGuide=e;let o=Math.min(Math.max(0,Math.floor(t)),e.guideSteps.length-1);return this.walkthroughIndex=o,{rendered:await this.renderWalkthroughStep(o)}}async renderWalkthroughStep(e){let t=this.walkthroughGuide;if(!t)return false;this.walkthrough&&(oe(this.walkthrough),this.walkthrough=null);let o={onNext:()=>{let c=this.walkthroughIndex+1;if(c>=t.guideSteps.length){this.close();return}this.walkthroughIndex=c,this.renderWalkthroughStep(c);},onBack:()=>{let c=this.walkthroughIndex-1;c<0||(this.walkthroughIndex=c,this.renderWalkthroughStep(c));},onSkip:()=>this.close(),onComplete:()=>this.close()},i=t.guideSteps[e]?.style?.render;if(i==="modal"||i==="banner"){let c=i==="modal"?new q:new U;try{c.render({guide:t,onInteraction:()=>{},onClose:()=>this.close(),nav:{stepIndex:e,totalSteps:t.guideSteps.length,callbacks:o}});}catch{return oe(c),false}return this.walkthroughGuide!==t?(oe(c),false):(this.walkthrough=c,true)}let s=new xe,a=false;try{a=await s.render({guide:t,currentStepIndex:e,callbacks:o});}catch{a=false;}return !a||this.walkthroughGuide!==t?(oe(s),false):(this.walkthrough=s,true)}},et=null;function tt(n){return Ne()?(et||(et=new pt),et.preview(n)):{close:()=>{},ready:Promise.resolve({rendered:false})}}function on(){et?.close();}function eo(n){let e=n.activationRules?.selector,t={url:n.activationRules?.url??{type:"prefix",pattern:"/"},trigger:"immediate",...e!==void 0?{selector:e}:{}};return {guideId:Zn,guideName:n.guideName??"Preview",guideType:n.guideType,guideSteps:n.guideSteps,activationRules:t,displayFrequency:"always",displayPriority:0}}function to(n){switch(n){case "modal":return new q;case "banner":return new U;case "tooltip":return new be;case "custom":return new fe;case "inline":return new we;case "inline-custom":return new ve;case "form":return new he;case "inline-form":return new ye;case "walkthrough":return null}}function oe(n){try{n.destroy();}catch{}}var nt=null;async function rn(n){if(!Ne())return null;nt?.teardown();let e=null;try{let a=await fetch(`${n.apiUrl}/v1/guides/preview-resolve`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":n.apiKey},body:JSON.stringify({token:n.token})});a.ok?e=(await a.json()).guide??null:n.debug&&console.warn("[veo] preview-resolve respondi\xF3",a.status);}catch(a){n.debug&&console.warn("[veo] preview-resolve fall\xF3:",a);}let t=async a=>{if(!e)return false;let c=window.veo,l=c?.getEndUserId?.()??c?.getAnonymousId?.()??null;if(!l)return false;try{return (await fetch(`${n.apiUrl}/v1/guides/${e.guideId}/form-response`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":n.apiKey},body:JSON.stringify({endUserId:l,answers:a})})).ok}catch{return false}},o=null,r=()=>{e&&(o?.close(),o=tt({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."}));},i=no({label:e?`Vista previa: ${e.guideName}`:"Link de preview inv\xE1lido o vencido",error:!e,onReshow:e?r:null,onClose:()=>s.teardown()}),s={teardown(){o?.close(),o=null,i.remove(),nt===s&&(nt=null);}};return nt=s,r(),s}function no(n){let e=document.createElement("div");e.setAttribute("data-veo-preview-chip","");let t=e.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=`
272
+ `;var w=class{constructor(){this.host=null;this.shadow=null;this.cleanups=[];}createHost(){let e=document.createElement("div");e.setAttribute(mt,"");let t=e.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=Rt,t.appendChild(o);let r=document.createElement("div");return t.appendChild(r),document.body.appendChild(e),this.host=e,this.shadow=t,{host:e,shadow:t,root:r}}applyDesign(e){this.host&&Et(this.host,e);}registerCleanup(e){this.cleanups.push(e);}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 B=class extends w{render(e){let t=e.nav?.stepIndex??0,o=e.guide.guideSteps[t];if(!o)return;let{root:r}=this.createHost();this.applyDesign(o.style);let i=r.ownerDocument??document,s=o.style?.position==="bottom"?"bottom":"top",a=i.createElement("div");a.className=`veo-banner veo-banner-${s}`;let c=(u,d)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:u}),d&&window.open(d,"_blank","noopener,noreferrer"),e.onClose();},l=e.nav?oe(o,e.nav.stepIndex,e.nav.totalSteps,i,e.nav.callbacks):$(o,i,{onCtaClick:(u,d)=>c("cta_clicked",u==="url"?d:void 0),onDismiss:()=>c("dismissed")});a.appendChild(l),r.appendChild(a),e.nav||e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var X=Math.min,U=Math.max,Pe=Math.round;var N=n=>({x:n,y:n}),vn={left:"right",right:"left",bottom:"top",top:"bottom"};function He(n,e,t){return U(n,X(e,t))}function re(n,e){return typeof n=="function"?n(e):n}function z(n){return n.split("-")[0]}function ie(n){return n.split("-")[1]}function st(n){return n==="x"?"y":"x"}function We(n){return n==="y"?"height":"width"}function M(n){let e=n[0];return e==="t"||e==="b"?"y":"x"}function $e(n){return st(M(n))}function At(n,e,t){t===void 0&&(t=false);let o=ie(n),r=$e(n),i=We(r),s=r==="x"?o===(t?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=Ie(s)),[s,Ie(s)]}function Tt(n){let e=Ie(n);return [Me(n),e,Me(e)]}function Me(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}var It=["left","right"],Pt=["right","left"],yn=["top","bottom"],wn=["bottom","top"];function bn(n,e,t){switch(n){case "top":case "bottom":return t?e?Pt:It:e?It:Pt;case "left":case "right":return e?yn:wn;default:return []}}function Lt(n,e,t,o){let r=ie(n),i=bn(z(n),t==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(Me)))),i}function Ie(n){let e=z(n);return vn[e]+n.slice(e.length)}function xn(n){return {top:0,right:0,bottom:0,left:0,...n}}function at(n){return typeof n!="number"?xn(n):{top:n,right:n,bottom:n,left:n}}function Q(n){let{x:e,y:t,width:o,height:r}=n;return {width:o,height:r,top:t,left:e,right:e+o,bottom:t+r,x:e,y:t}}function Nt(n,e,t){let{reference:o,floating:r}=n,i=M(e),s=$e(e),a=We(s),c=z(e),l=i==="y",u=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,p=o[a]/2-r[a]/2,f;switch(c){case "top":f={x:u,y:o.y-r.height};break;case "bottom":f={x:u,y:o.y+o.height};break;case "right":f={x:o.x+o.width,y:d};break;case "left":f={x:o.x-r.width,y:d};break;default:f={x:o.x,y:o.y};}switch(ie(e)){case "start":f[s]-=p*(t&&l?-1:1);break;case "end":f[s]+=p*(t&&l?-1:1);break}return f}async function Gt(n,e){var t;e===void 0&&(e={});let{x:o,y:r,platform:i,rects:s,elements:a,strategy:c}=n,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:p=false,padding:f=0}=re(e,n),h=at(f),g=a[p?d==="floating"?"reference":"floating":d],v=Q(await i.getClippingRect({element:(t=await(i.isElement==null?void 0:i.isElement(g)))==null||t?g:g.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:l,rootBoundary:u,strategy:c})),y=d==="floating"?{x:o,y:r,width:s.floating.width,height:s.floating.height}:s.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),x=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},A=Q(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:b,strategy:c}):y);return {top:(v.top-A.top+h.top)/x.y,bottom:(A.bottom-v.bottom+h.bottom)/x.y,left:(v.left-A.left+h.left)/x.x,right:(A.right-v.right+h.right)/x.x}}var Cn=50,Ot=async(n,e,t)=>{let{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:Gt},c=await(s.isRTL==null?void 0:s.isRTL(e)),l=await s.getElementRects({reference:n,floating:e,strategy:r}),{x:u,y:d}=Nt(l,o,c),p=o,f=0,h={};for(let m=0;m<i.length;m++){let g=i[m];if(!g)continue;let{name:v,fn:y}=g,{x:b,y:x,data:A,reset:k}=await y({x:u,y:d,initialPlacement:o,placement:p,strategy:r,middlewareData:h,rects:l,platform:a,elements:{reference:n,floating:e}});u=b??u,d=x??d,h[v]={...h[v],...A},k&&f<Cn&&(f++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(l=k.rects===true?await s.getElementRects({reference:n,floating:e,strategy:r}):k.rects),{x:u,y:d}=Nt(l,p,c)),m=-1);}return {x:u,y:d,placement:p,strategy:r,middlewareData:h}},_t=n=>({name:"arrow",options:n,async fn(e){let{x:t,y:o,placement:r,rects:i,platform:s,elements:a,middlewareData:c}=e,{element:l,padding:u=0}=re(n,e)||{};if(l==null)return {};let d=at(u),p={x:t,y:o},f=$e(r),h=We(f),m=await s.getDimensions(l),g=f==="y",v=g?"top":"left",y=g?"bottom":"right",b=g?"clientHeight":"clientWidth",x=i.reference[h]+i.reference[f]-p[f]-i.floating[h],A=p[f]-i.reference[f],k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l)),q=k?k[b]:0;(!q||!await(s.isElement==null?void 0:s.isElement(k)))&&(q=a.floating[b]||i.floating[h]);let xe=x/2-A/2,j=q/2-m[h]/2-1,D=X(d[v],j),Ce=X(d[y],j),V=D,ke=q-m[h]-Ce,C=q/2-m[h]/2+xe,Y=He(V,C,ke),F=!c.arrow&&ie(r)!=null&&C!==Y&&i.reference[h]/2-(C<V?D:Ce)-m[h]/2<0,T=F?C<V?C-V:C-ke:0;return {[f]:p[f]+T,data:{[f]:Y,centerOffset:C-Y-T,...F&&{alignmentOffset:T}},reset:F}}});var Dt=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,o;let{placement:r,middlewareData:i,rects:s,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:u=true,crossAxis:d=true,fallbackPlacements:p,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:m=true,...g}=re(n,e);if((t=i.arrow)!=null&&t.alignmentOffset)return {};let v=z(r),y=M(a),b=z(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(l.floating)),A=p||(b||!m?[Ie(a)]:Tt(a)),k=h!=="none";!p&&k&&A.push(...Lt(a,m,h,x));let q=[a,...A],xe=await c.detectOverflow(e,g),j=[],D=((o=i.flip)==null?void 0:o.overflows)||[];if(u&&j.push(xe[v]),d){let C=At(r,s,x);j.push(xe[C[0]],xe[C[1]]);}if(D=[...D,{placement:r,overflows:j}],!j.every(C=>C<=0)){var Ce,V;let C=(((Ce=i.flip)==null?void 0:Ce.index)||0)+1,Y=q[C];if(Y&&(!(d==="alignment"?y!==M(Y):false)||D.every(L=>M(L.placement)===y?L.overflows[0]>0:true)))return {data:{index:C,overflows:D},reset:{placement:Y}};let F=(V=D.filter(T=>T.overflows[0]<=0).sort((T,L)=>T.overflows[1]-L.overflows[1])[0])==null?void 0:V.placement;if(!F)switch(f){case "bestFit":{var ke;let T=(ke=D.filter(L=>{if(k){let W=M(L.placement);return W===y||W==="y"}return true}).map(L=>[L.placement,L.overflows.filter(W=>W>0).reduce((W,sn)=>W+sn,0)]).sort((L,W)=>L[1]-W[1])[0])==null?void 0:ke[0];T&&(F=T);break}case "initialPlacement":F=a;break}if(r!==F)return {reset:{placement:F}}}return {}}}};var kn=new Set(["left","top"]);async function Sn(n,e){let{placement:t,platform:o,elements:r}=n,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=z(t),a=ie(t),c=M(t)==="y",l=kn.has(s)?-1:1,u=i&&c?-1:1,d=re(e,n),{mainAxis:p,crossAxis:f,alignmentAxis:h}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof h=="number"&&(f=a==="end"?h*-1:h),c?{x:f*u,y:p*l}:{x:p*l,y:f*u}}var Ft=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,o;let{x:r,y:i,placement:s,middlewareData:a}=e,c=await Sn(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(o=a.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:i+c.y,data:{...c,placement:s}}}}},Mt=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){let{x:t,y:o,placement:r,platform:i}=e,{mainAxis:s=true,crossAxis:a=false,limiter:c={fn:v=>{let{x:y,y:b}=v;return {x:y,y:b}}},...l}=re(n,e),u={x:t,y:o},d=await i.detectOverflow(e,l),p=M(z(r)),f=st(p),h=u[f],m=u[p];if(s){let v=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=h+d[v],x=h-d[y];h=He(b,h,x);}if(a){let v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",b=m+d[v],x=m-d[y];m=He(b,m,x);}let g=c.fn({...e,[f]:h,[p]:m});return {...g,data:{x:g.x-t,y:g.y-o,enabled:{[f]:s,[p]:a}}}}}};function Ue(){return typeof window<"u"}function Z(n){return Wt(n)?(n.nodeName||"").toLowerCase():"#document"}function S(n){var e;return (n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function O(n){var e;return (e=(Wt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Wt(n){return Ue()?n instanceof Node||n instanceof S(n).Node:false}function R(n){return Ue()?n instanceof Element||n instanceof S(n).Element:false}function _(n){return Ue()?n instanceof HTMLElement||n instanceof S(n).HTMLElement:false}function Ht(n){return !Ue()||typeof ShadowRoot>"u"?false:n instanceof ShadowRoot||n instanceof S(n).ShadowRoot}function se(n){let{overflow:e,overflowX:t,overflowY:o,display:r}=I(n);return /auto|scroll|overlay|hidden|clip/.test(e+o+t)&&r!=="inline"&&r!=="contents"}function $t(n){return /^(table|td|th)$/.test(Z(n))}function Ae(n){try{if(n.matches(":popover-open"))return !0}catch{}try{return n.matches(":modal")}catch{return false}}var En=/transform|translate|scale|rotate|perspective|filter/,Rn=/paint|layout|strict|content/,J=n=>!!n&&n!=="none",lt;function ze(n){let e=R(n)?I(n):n;return J(e.transform)||J(e.translate)||J(e.scale)||J(e.rotate)||J(e.perspective)||!Ke()&&(J(e.backdropFilter)||J(e.filter))||En.test(e.willChange||"")||Rn.test(e.contain||"")}function Bt(n){let e=H(n);for(;_(e)&&!ee(e);){if(ze(e))return e;if(Ae(e))return null;e=H(e);}return null}function Ke(){return lt==null&&(lt=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),lt}function ee(n){return /^(html|body|#document)$/.test(Z(n))}function I(n){return S(n).getComputedStyle(n)}function Te(n){return R(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function H(n){if(Z(n)==="html")return n;let e=n.assignedSlot||n.parentNode||Ht(n)&&n.host||O(n);return Ht(e)?e.host:e}function Ut(n){let e=H(n);return ee(e)?n.ownerDocument?n.ownerDocument.body:n.body:_(e)&&se(e)?e:Ut(e)}function Be(n,e,t){var o;e===void 0&&(e=[]);let r=Ut(n),i=r===((o=n.ownerDocument)==null?void 0:o.body),s=S(r);if(i){qe(s);return e.concat(s,s.visualViewport||[],se(r)?r:[],[])}else return e.concat(r,Be(r,[]))}function qe(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function jt(n){let e=I(n),t=parseFloat(e.width)||0,o=parseFloat(e.height)||0,r=_(n),i=r?n.offsetWidth:t,s=r?n.offsetHeight:o,a=Pe(t)!==i||Pe(o)!==s;return a&&(t=i,o=s),{width:t,height:o,$:a}}function Vt(n){return R(n)?n:n.contextElement}function ae(n){let e=Vt(n);if(!_(e))return N(1);let t=e.getBoundingClientRect(),{width:o,height:r,$:i}=jt(e),s=(i?Pe(t.width):t.width)/o,a=(i?Pe(t.height):t.height)/r;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var In=N(0);function Yt(n){let e=S(n);return !Ke()||!e.visualViewport?In:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Pn(n,e,t){return e===void 0&&(e=false),!t||e&&t!==S(n)?false:e}function Le(n,e,t,o){e===void 0&&(e=false),t===void 0&&(t=false);let r=n.getBoundingClientRect(),i=Vt(n),s=N(1);e&&(o?R(o)&&(s=ae(o)):s=ae(n));let a=Pn(i,t,o)?Yt(i):N(0),c=(r.left+a.x)/s.x,l=(r.top+a.y)/s.y,u=r.width/s.x,d=r.height/s.y;if(i){let p=S(i),f=o&&R(o)?S(o):o,h=p,m=qe(h);for(;m&&o&&f!==h;){let g=ae(m),v=m.getBoundingClientRect(),y=I(m),b=v.left+(m.clientLeft+parseFloat(y.paddingLeft))*g.x,x=v.top+(m.clientTop+parseFloat(y.paddingTop))*g.y;c*=g.x,l*=g.y,u*=g.x,d*=g.y,c+=b,l+=x,h=S(m),m=qe(h);}}return Q({width:u,height:d,x:c,y:l})}function je(n,e){let t=Te(n).scrollLeft;return e?e.left+t:Le(O(n)).left+t}function Xt(n,e){let t=n.getBoundingClientRect(),o=t.left+e.scrollLeft-je(n,t),r=t.top+e.scrollTop;return {x:o,y:r}}function An(n){let{elements:e,rect:t,offsetParent:o,strategy:r}=n,i=r==="fixed",s=O(o),a=e?Ae(e.floating):false;if(o===s||a&&i)return t;let c={scrollLeft:0,scrollTop:0},l=N(1),u=N(0),d=_(o);if((d||!d&&!i)&&((Z(o)!=="body"||se(s))&&(c=Te(o)),d)){let f=Le(o);l=ae(o),u.x=f.x+o.clientLeft,u.y=f.y+o.clientTop;}let p=s&&!d&&!i?Xt(s,c):N(0);return {width:t.width*l.x,height:t.height*l.y,x:t.x*l.x-c.scrollLeft*l.x+u.x+p.x,y:t.y*l.y-c.scrollTop*l.y+u.y+p.y}}function Tn(n){return Array.from(n.getClientRects())}function Ln(n){let e=O(n),t=Te(n),o=n.ownerDocument.body,r=U(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=U(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-t.scrollLeft+je(n),a=-t.scrollTop;return I(o).direction==="rtl"&&(s+=U(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:a}}var zt=25;function Nn(n,e){let t=S(n),o=O(n),r=t.visualViewport,i=o.clientWidth,s=o.clientHeight,a=0,c=0;if(r){i=r.width,s=r.height;let u=Ke();(!u||u&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop);}let l=je(o);if(l<=0){let u=o.ownerDocument,d=u.body,p=getComputedStyle(d),f=u.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,h=Math.abs(o.clientWidth-d.clientWidth-f);h<=zt&&(i-=h);}else l<=zt&&(i+=l);return {width:i,height:s,x:a,y:c}}function Gn(n,e){let t=Le(n,true,e==="fixed"),o=t.top+n.clientTop,r=t.left+n.clientLeft,i=_(n)?ae(n):N(1),s=n.clientWidth*i.x,a=n.clientHeight*i.y,c=r*i.x,l=o*i.y;return {width:s,height:a,x:c,y:l}}function Kt(n,e,t){let o;if(e==="viewport")o=Nn(n,t);else if(e==="document")o=Ln(O(n));else if(R(e))o=Gn(e,t);else {let r=Yt(n);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height};}return Q(o)}function Qt(n,e){let t=H(n);return t===e||!R(t)||ee(t)?false:I(t).position==="fixed"||Qt(t,e)}function On(n,e){let t=e.get(n);if(t)return t;let o=Be(n,[]).filter(a=>R(a)&&Z(a)!=="body"),r=null,i=I(n).position==="fixed",s=i?H(n):n;for(;R(s)&&!ee(s);){let a=I(s),c=ze(s);!c&&a.position==="fixed"&&(r=null),(i?!c&&!r:!c&&a.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||se(s)&&!c&&Qt(n,s))?o=o.filter(u=>u!==s):r=a,s=H(s);}return e.set(n,o),o}function _n(n){let{element:e,boundary:t,rootBoundary:o,strategy:r}=n,s=[...t==="clippingAncestors"?Ae(e)?[]:On(e,this._c):[].concat(t),o],a=Kt(e,s[0],r),c=a.top,l=a.right,u=a.bottom,d=a.left;for(let p=1;p<s.length;p++){let f=Kt(e,s[p],r);c=U(f.top,c),l=X(f.right,l),u=X(f.bottom,u),d=U(f.left,d);}return {width:l-d,height:u-c,x:d,y:c}}function Dn(n){let{width:e,height:t}=jt(n);return {width:e,height:t}}function Fn(n,e,t){let o=_(e),r=O(e),i=t==="fixed",s=Le(n,true,i,e),a={scrollLeft:0,scrollTop:0},c=N(0);function l(){c.x=je(r);}if(o||!o&&!i)if((Z(e)!=="body"||se(r))&&(a=Te(e)),o){let f=Le(e,true,i,e);c.x=f.x+e.clientLeft,c.y=f.y+e.clientTop;}else r&&l();i&&!o&&r&&l();let u=r&&!o&&!i?Xt(r,a):N(0),d=s.left+a.scrollLeft-c.x-u.x,p=s.top+a.scrollTop-c.y-u.y;return {x:d,y:p,width:s.width,height:s.height}}function ct(n){return I(n).position==="static"}function qt(n,e){if(!_(n)||I(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return O(n)===t&&(t=t.ownerDocument.body),t}function Jt(n,e){let t=S(n);if(Ae(n))return t;if(!_(n)){let r=H(n);for(;r&&!ee(r);){if(R(r)&&!ct(r))return r;r=H(r);}return t}let o=qt(n,e);for(;o&&$t(o)&&ct(o);)o=qt(o,e);return o&&ee(o)&&ct(o)&&!ze(o)?t:o||Bt(n)||t}var Mn=async function(n){let e=this.getOffsetParent||Jt,t=this.getDimensions,o=await t(n.floating);return {reference:Fn(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Hn(n){return I(n).direction==="rtl"}var Wn={convertOffsetParentRelativeRectToViewportRelativeRect:An,getDocumentElement:O,getClippingRect:_n,getOffsetParent:Jt,getElementRects:Mn,getClientRects:Tn,getDimensions:Dn,getScale:ae,isElement:R,isRTL:Hn};var le=Ft;var ce=Mt,de=Dt;var Ve=_t;var ue=(n,e,t)=>{let o=new Map,r={platform:Wn,...t},i={...r.platform,_c:o};return Ot(n,e,{...r,platform:i})};function P(n,e=5e3){return new Promise(t=>{let o=()=>{try{return document.querySelector(n)}catch{return null}},r=o();if(r){t(r);return}let i=false,s=l=>{i||(i=true,a.disconnect(),clearTimeout(c),t(l));},a=new MutationObserver(()=>{let l=o();l&&s(l);});a.observe(document.body,{childList:true,subtree:true});let c=setTimeout(()=>s(null),e);})}function Zt(){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 r=0;r<t.length;r++)t[r]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let o=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),o.slice(0,4),o.slice(4,8),o.slice(8,20)].join("-")}function Ye(n,e,t,o){let r=n.createElement("iframe");r.className="veo-custom-frame",r.setAttribute("sandbox","allow-scripts"),r.setAttribute("title",t.guide.guideName||"Veo"),r.style.width=o.width;let i=o.fixedHeight!==void 0&&o.fixedHeight!==null;i&&(r.style.height=ut(o.fixedHeight));let s=Zt(),a=e.style?.tailwind===true;r.srcdoc=Kn(e.html??"",e.css??"",e.js??"",s,{hostCss:Bn(),htmlAttrs:Un(),tailwind:a});let c=()=>t.onClose(),l=u=>{if(u.source!==r.contentWindow)return;let d=u.data;if(!(!d||typeof d!="object"||d.__veo!==s))switch(d.type){case "dismiss":t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"dismissed"}),c();break;case "cta":t.onInteraction({guideId:t.guide.guideId,stepIndex:0,action:"cta_clicked"}),typeof d.url=="string"&&G(d.url)&&window.open(d.url,"_blank","noopener,noreferrer"),d.close!==false&&c();break;case "navigate":typeof d.url=="string"&&G(d.url)&&window.location.assign(d.url);break;case "track":typeof d.name=="string"&&t.onTrack&&t.onTrack(d.name,zn(d.props)?d.props:void 0);break;case "resize":!i&&typeof d.height=="number"&&d.height>0&&(r.style.height=`${Math.ceil(d.height)}px`);break}};return window.addEventListener("message",l),{iframe:r,cleanup:()=>window.removeEventListener("message",l)}}function ut(n){return typeof n=="number"?`${n}px`:n}var $n=800*1024;function Bn(){if(typeof document>"u")return "";let n="";try{for(let e of Array.from(document.styleSheets)){let t=null;try{t=e.cssRules;}catch{continue}if(t){for(let o of Array.from(t))if(n+=`${o.cssText}
273
+ `,n.length>$n)return n}}}catch{return n}return n}function Un(){if(typeof document>"u")return "";try{let n=document.documentElement,e=[];for(let t of ["class","style","data-theme","data-mode","data-color-mode"]){let o=n.getAttribute(t);o&&o.length<=1e3&&!/["<>]/.test(o)&&e.push(`${t}="${o}"`);}return e.join(" ")}catch{return ""}}function zn(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function Kn(n,e,t,o,r){let i=`(function(){var T=${JSON.stringify(o)};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(){P({type:'resize',height:Math.ceil(document.documentElement.scrollHeight)});}window.addEventListener('load',H);try{if(typeof ResizeObserver!=='undefined'){new ResizeObserver(H).observe(document.documentElement);}}catch(e){}})();`,s=r.hostCss?`<style>${dt(r.hostCss,"style")}</style>`:"",a=r.tailwind?'<script src="https://cdn.tailwindcss.com"></script>':"";return `<!DOCTYPE html><html ${r.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;}</style>"+a+`<style>${dt(e,"style")}</style></head><body>${n}<script>${i}</script>`+(t?`<script>${dt(t,"script")}</script>`:"")+"</body></html>"}function dt(n,e){let t=e==="script"?/<\/script/gi:/<\/style/gi;return n.replace(t,`<\\/${e}`)}var qn={mode:"floating",position:"bottom-right"},en=16,jn=360,pe=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let o=t.placement??qn,r=null;if(o.mode==="anchored"){let u=o.selector??t.selector??e.guide.activationRules.selector;if(typeof u!="string"||u.length===0||(r=await P(u),!r))return}let{root:i}=this.createHost(),s=i.ownerDocument??document,a=s.createElement("div");a.className=o.mode==="anchored"?"veo-custom-anchored":"veo-custom-floating";let{iframe:c,cleanup:l}=Ye(s,t,e,{width:ut(o.width??jn),fixedHeight:o.height??null});this.registerCleanup(l),a.appendChild(c),i.appendChild(a),o.mode==="floating"?Vn(a,o):r&&this.registerCleanup(await this.setupAnchoredPosition(r,a,o)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}async setupAnchoredPosition(e,t,o){let r=o.side??"bottom",i=async()=>{let{x:a,y:c}=await ue(e,t,{placement:r,strategy:"fixed",middleware:[le(o.offsetY??8),de(),ce({padding:8})]});t.style.left=`${a}px`,t.style.top=`${c}px`;};await i();let s=()=>{i();};return window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}}};function Vn(n,e){let t=e.position??"bottom-right",o=`${e.offsetX??en}px`,r=`${e.offsetY??en}px`,i=n.style;if(t==="center"){i.top="50%",i.left="50%",i.transform="translate(-50%, -50%)";return}let[s,a]=t.split("-");s==="top"?i.top=r:i.bottom=r,a==="left"?i.left=o:a==="right"?i.right=o:(i.left="50%",i.transform="translateX(-50%)");}function Xe(n,e,t){let o=e.guide.guideSteps[0];if(!o)return;let r=o.fields??[],i=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();},s=t.createElement("div");if(s.className="veo-guide-content",o.title){let p=t.createElement("h2");p.className="veo-guide-title",p.textContent=o.title,s.appendChild(p);}if(o.content){let p=t.createElement("p");p.className="veo-guide-text",p.textContent=o.content,s.appendChild(p);}let a=[],c=t.createElement("form");c.className="veo-form",c.noValidate=true;for(let p of r){let{wrapper:f,read:h}=Xn(p,t);a.push({field:p,read:h}),c.appendChild(f);}let l=t.createElement("p");l.className="veo-form-error",l.style.display="none",c.appendChild(l);let u=t.createElement("div");u.className="veo-guide-actions";let d=t.createElement("button");d.type="submit",d.className="veo-guide-cta",d.textContent=o.ctaText||"Enviar",u.appendChild(d),c.appendChild(u),c.addEventListener("submit",p=>{p.preventDefault(),l.style.display="none";let f={};for(let{field:m,read:g}of a){let v=g();if(v==null||v===""){if(m.required){l.textContent=`Complet\xE1 "${m.label}"`,l.style.display="block";return}continue}f[m.key]=v;}if(Object.keys(f).length===0){l.textContent="Respond\xE9 al menos un campo",l.style.display="block";return}d.disabled=true,(e.onFormSubmit??(()=>Promise.resolve(true)))(f).then(m=>{if(!m){d.disabled=false,l.textContent="No se pudo enviar. Prob\xE1 de nuevo.",l.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;Yn(n,t,g),window.setTimeout(()=>e.onClose(),g?2200:1400);});}),s.appendChild(c),s.appendChild(Ee(t,i)),n.appendChild(s);}function Yn(n,e,t){for(;n.firstChild;)n.removeChild(n.firstChild);let o=e.createElement("div");if(o.className="veo-form-thanks",o.textContent="\u2713 \xA1Gracias por tu respuesta!",n.appendChild(o),t){let r=e.createElement("p");r.className="veo-form-preview-note",r.textContent=t,n.appendChild(r);}}function Xn(n,e){let t=e.createElement("div");t.className="veo-form-field";let o=e.createElement("label");switch(o.className="veo-form-label",o.textContent=n.required?`${n.label} *`:n.label,t.appendChild(o),n.type){case "textarea":{let r=e.createElement("textarea");return r.className="veo-form-input",r.rows=3,n.placeholder&&(r.placeholder=n.placeholder),t.appendChild(r),{wrapper:t,read:()=>r.value.trim()}}case "number":{let r=e.createElement("input");return r.type="number",r.className="veo-form-input",n.placeholder&&(r.placeholder=n.placeholder),t.appendChild(r),{wrapper:t,read:()=>r.value.trim()===""?void 0:Number(r.value)}}case "select":{let r=e.createElement("select");r.className="veo-form-input";let i=e.createElement("option");i.value="",i.textContent=n.placeholder||"Eleg\xED una opci\xF3n\u2026",r.appendChild(i);for(let s of n.options??[]){let a=e.createElement("option");a.value=s,a.textContent=s,r.appendChild(a);}return t.appendChild(r),{wrapper:t,read:()=>r.value||void 0}}case "radio":{let r=e.createElement("div");r.className="veo-form-options";let i=`veo-${n.key}`,s=[];for(let a of n.options??[]){let c=e.createElement("label");c.className="veo-form-option";let l=e.createElement("input");l.type="radio",l.name=i,l.value=a,s.push(l);let u=e.createElement("span");u.textContent=a,c.appendChild(l),c.appendChild(u),r.appendChild(c);}return t.appendChild(r),{wrapper:t,read:()=>s.find(a=>a.checked)?.value}}case "multiselect":{let r=e.createElement("div");r.className="veo-form-options";let i=[];for(let s of n.options??[]){let a=e.createElement("label");a.className="veo-form-option";let c=e.createElement("input");c.type="checkbox",c.value=s,i.push(c);let l=e.createElement("span");l.textContent=s,a.appendChild(c),a.appendChild(l),r.appendChild(a);}return t.appendChild(r),{wrapper:t,read:()=>{let s=i.filter(a=>a.checked).map(a=>a.value);return s.length>0?s:void 0}}}case "checkbox":{let r=e.createElement("label");r.className="veo-form-option";let i=e.createElement("input");i.type="checkbox";let s=e.createElement("span");return s.textContent=n.placeholder||"S\xED",r.appendChild(i),r.appendChild(s),t.appendChild(r),{wrapper:t,read:()=>i.checked?true:n.required?"":false}}case "yesno":{let r=e.createElement("div");r.className="veo-form-options";let i=`veo-${n.key}`,[s,a]=n.options?.length===2?n.options:["S\xED","No"],c=[];for(let{label:l,value:u}of [{label:s,value:true},{label:a,value:false}]){let d=e.createElement("label");d.className="veo-form-option";let p=e.createElement("input");p.type="radio",p.name=i,c.push({input:p,value:u});let f=e.createElement("span");f.textContent=l,d.appendChild(p),d.appendChild(f),r.appendChild(d);}return t.appendChild(r),{wrapper:t,read:()=>c.find(l=>l.input.checked)?.value}}case "nps":return tn(t,e,0,10,"veo-nps-btn");case "rating":return tn(t,e,1,5,"veo-rating-btn","\u2605");default:{let r=e.createElement("input");return r.type="text",r.className="veo-form-input",n.placeholder&&(r.placeholder=n.placeholder),t.appendChild(r),{wrapper:t,read:()=>r.value.trim()}}}}function tn(n,e,t,o,r,i){let s=e.createElement("div");s.className="veo-form-scale";let a,c=[];for(let l=t;l<=o;l++){let u=e.createElement("button");u.type="button",u.className=r,u.textContent=i??String(l),u.setAttribute("aria-label",String(l)),u.addEventListener("click",()=>{a=l,c.forEach((d,p)=>{let f=i?p+t<=l:p+t===l;d.classList.toggle("veo-scale-active",f);});}),c.push(u),s.appendChild(u);}return n.appendChild(s),{wrapper:n,read:()=>a}}var fe=class extends w{render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let{root:o}=this.createHost();this.applyDesign(t.style);let r=o.ownerDocument??document,i=r.createElement("div");i.className="veo-modal-overlay";let s=r.createElement("div");s.className="veo-modal-card",Xe(s,e,r),i.appendChild(s),o.appendChild(i);let a=()=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),e.onClose();};i.addEventListener("click",l=>{l.target===i&&a();});let c=l=>{l.key==="Escape"&&a();};document.addEventListener("keydown",c),this.registerCleanup(()=>document.removeEventListener("keydown",c)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};function he(n){let e=n?.inlinePosition;return e==="before"||e==="prepend"||e==="append"?e:"after"}function te(n,e,t){switch(t){case "before":n.before(e);break;case "after":n.after(e);break;case "prepend":n.prepend(e);break;case "append":n.append(e);break}}function me(n,e,t){let o=window.setInterval(()=>{if(n.isConnected)return;let r=document.querySelector(e);r&&te(r,n,t);},1e3);return ()=>window.clearInterval(o)}var ge=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let{host:i,root:s}=this.createHost();i.style.display="block";let a=he(t.style);te(r,i,a),this.registerCleanup(me(i,o,a));let c=s.ownerDocument??document,l=c.createElement("div");l.className="veo-custom-inline";let{iframe:u,cleanup:d}=Ye(c,t,e,{width:"100%"});this.registerCleanup(d),l.appendChild(u),s.appendChild(l),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var ve=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t||(t.fields??[]).length===0)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let{host:i,root:s}=this.createHost();i.style.display="block";let a=he(t.style);te(r,i,a),this.registerCleanup(me(i,o,a)),this.applyDesign(t.style);let c=s.ownerDocument??document,l=c.createElement("div");l.className="veo-inline",Xe(l,e,c),s.appendChild(l),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var ye=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let{host:i,root:s}=this.createHost();i.style.display="block";let a=he(t.style);te(r,i,a),this.registerCleanup(me(i,o,a)),this.applyDesign(t.style);let c=s.ownerDocument??document,l=c.createElement("div");l.className="veo-inline";let u=(p,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:p}),f&&window.open(f,"_blank","noopener,noreferrer"),e.onClose();},d=$(t,c,{onCtaClick:(p,f)=>u("cta_clicked",p==="url"?f:void 0),onDismiss:()=>u("dismissed")});l.appendChild(d),s.appendChild(l),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var K=class extends w{render(e){let t=e.nav?.stepIndex??0,o=e.guide.guideSteps[t];if(!o)return;let{root:r}=this.createHost();this.applyDesign(o.style);let i=r.ownerDocument??document,s=i.createElement("div");s.className="veo-modal-overlay";let a=i.createElement("div");a.className="veo-modal-card";let c=(p,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:t,action:p}),f&&window.open(f,"_blank","noopener,noreferrer"),e.onClose();},l=()=>{e.nav?e.nav.callbacks.onSkip():c("dismissed");},u=e.nav?oe(o,e.nav.stepIndex,e.nav.totalSteps,i,e.nav.callbacks):$(o,i,{onCtaClick:(p,f)=>c("cta_clicked",p==="url"?f:void 0),onDismiss:()=>c("dismissed")});a.appendChild(u),s.appendChild(a),r.appendChild(s),s.addEventListener("click",p=>{p.target===s&&l();});let d=p=>{p.key==="Escape"&&l();};document.addEventListener("keydown",d),this.registerCleanup(()=>document.removeEventListener("keydown",d)),e.nav||e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Qn={top:"bottom",bottom:"top",left:"right",right:"left"};function Qe(n,e,t){let o=Qn[e.split("-")[0]??"bottom"]??"top";for(let r of ["top","bottom","left","right"])n.style.setProperty(r,"");t?.x!=null&&n.style.setProperty("left",`${t.x}px`),t?.y!=null&&n.style.setProperty("top",`${t.y}px`),n.style.setProperty(o,"-6px");}var we=class extends w{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return;let r=await P(o);if(!r)return;let i=t.style?.tooltipPlacement,s=i==="top"||i==="left"||i==="right"?i:"bottom",{root:a}=this.createHost();this.applyDesign(t.style);let c=a.ownerDocument??document,l=c.createElement("div");l.className="veo-tooltip";let u=(m,g)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:m}),g&&window.open(g,"_blank","noopener,noreferrer"),e.onClose();},d=$(t,c,{onCtaClick:(m,g)=>{u("cta_clicked",m==="url"?g:void 0);},onDismiss:()=>u("dismissed")});l.appendChild(d);let p=c.createElement("div");p.className="veo-tooltip-arrow",l.appendChild(p),a.appendChild(l);let f=async()=>{let{x:m,y:g,placement:v,middlewareData:y}=await ue(r,l,{placement:s,middleware:[le(10),de(),ce({padding:8}),Ve({element:p})]});l.style.left=`${m}px`,l.style.top=`${g}px`,Qe(p,v,y.arrow);};await f();let h=()=>{f();};window.addEventListener("scroll",h,true),window.addEventListener("resize",h),this.registerCleanup(()=>{window.removeEventListener("scroll",h,true),window.removeEventListener("resize",h);}),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var be=class extends w{async render(e){let t=e.guide.guideSteps[e.currentStepIndex];if(!t)return false;let o=t.selector??e.guide.activationRules.selector;if(typeof o!="string"||o.length===0)return false;let r=await P(o,5e3);if(!r)return false;let i=t.style?.tooltipPlacement,s=i==="top"||i==="left"||i==="right"?i:"bottom",{root:a}=this.createHost();this.applyDesign(t.style);let c=a.ownerDocument??document,l=c.createElement("div");l.className="veo-walkthrough";let u=oe(t,e.currentStepIndex,e.guide.guideSteps.length,c,e.callbacks);l.appendChild(u);let d=c.createElement("div");d.className="veo-walkthrough-arrow",l.appendChild(d),a.appendChild(l);let p=async()=>{let{x:h,y:m,placement:g,middlewareData:v}=await ue(r,l,{placement:s,middleware:[le(10),de(),ce({padding:8}),Ve({element:d})]});l.style.left=`${h}px`,l.style.top=`${m}px`,Qe(d,g,v.arrow);};await p();let f=()=>{p();};return window.addEventListener("scroll",f,true),window.addEventListener("resize",f),this.registerCleanup(()=>{window.removeEventListener("scroll",f,true),window.removeEventListener("resize",f);}),true}};var Je=class{constructor(e){this.state=null;this.storageKey=`${vt}${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 o=Date.now();return this.state={guideId:e,totalSteps:t,currentStepIndex:0,startedAt:o,lastProgressAt:o},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 o=t;return typeof o.guideId!="string"||typeof o.totalSteps!="number"||typeof o.currentStepIndex!="number"||typeof o.startedAt!="number"||typeof o.lastProgressAt!="number"?null:o}catch{return null}}persist(){if(!(typeof localStorage>"u"||!this.state))try{localStorage.setItem(this.storageKey,JSON.stringify(this.state));}catch{}}};var Zn={shown:"shown",dismissed:"dismissed",cta_clicked:null,step_advanced:null,step_back:null,completed:"completed"},Ze=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;if(this.debug=t.debug===true,this.apiUrl=t.apiUrl,this.apiKey=t.apiKey,this.resolver=t.resolver??new Oe(t.apiUrl,t.apiKey,this.debug),t.trackerQueue)this.trackerQueue=t.trackerQueue;else {let r=new _e(t.apiUrl,t.apiKey);this.trackerQueue=new De({client:r,flushIntervalMs:3e3,batchSize:5,maxRetries:3,onError:(i,s)=>{this.debug&&console.warn(`[veo] dropped guide interaction after retries: guideId=${s.guideId} action=${s.payload.action}`,i);}});}let o=bt(t.apiKey);this.frequencyCache=t.frequencyCache??new Ge(o),this.walkthroughState=t.walkthroughState??new Je(o);}get pendingInteractions(){return this.trackerQueue.size}clearFrequencyCache(){this.frequencyCache.clear();}clearWalkthroughState(){this.tearDownWalkthrough();}async checkGuides(e,t){let o=this.client.getEndUserId();if(!o){this.debug&&console.log("[veo] guides: skipped, no endUserId yet");return}if(await this.tryResumeWalkthrough(o,t,e))return;let r;try{r=await this.resolver.resolve(o,e);}catch(i){this.debug&&console.error("[veo] guides resolver threw:",i);return}this.debug&&console.log(`[veo] guides: ${r.length} eligible at ${e}`);for(let i of r){if(this.frequencyCache.shouldFilter(i.guideId,i.displayFrequency)){this.debug&&console.log(`[veo] guides: filtered locally guideId=${i.guideId}`);continue}if(this.activeByGuideId.has(i.guideId)){this.debug&&console.log(`[veo] guides: already shown guideId=${i.guideId}`);continue}if(i.guideType==="walkthrough"&&i.guideSteps.length>1){if(this.walkthroughState.hasActive()){this.debug&&console.log(`[veo] guides: walkthrough ${i.guideId} skipped (another active)`);continue}await this.startWalkthrough(i,o,t,e);continue}this.runSingleStepRender(i,t,e);}}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.dispatched.clear(),this.trackerQueue.destroy();}runSingleStepRender(e,t,o){let r=this.createSingleStepRenderer(e.guideType);if(!r)return;this.activeByGuideId.set(e.guideId,r);let i=e.activationRules.delayMs??0;window.setTimeout(()=>this.mountSingleStepRenderer(e,r,t,o),i);}mountSingleStepRenderer(e,t,o,r){this.activeRenderers.add(t),this.activeByGuideId.set(e.guideId,t);let i=()=>{t.destroy(),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);},s=l=>{this.handleInteraction(e,o,r,l);},a=(l,u)=>{this.client.track(l,u);},c=l=>this.submitFormResponse(e.guideId,l);try{t.render({guide:e,onInteraction:s,onClose:i,onTrack:a,onFormSubmit:c});}catch(l){this.debug&&console.error("[veo] renderer.render threw:",l),this.activeRenderers.delete(t),this.activeByGuideId.get(e.guideId)===t&&this.activeByGuideId.delete(e.guideId);}}async tryResumeWalkthrough(e,t,o){let r=this.walkthroughState.current();if(!r)return false;let i=await this.resolver.fetchById(r.guideId);if(!i||i.guideType!=="walkthrough")return this.debug&&console.log(`[veo] guides: walkthrough ${r.guideId} no longer available, cleaning up`),this.tearDownWalkthrough(),true;let s=Math.min(r.currentStepIndex,i.guideSteps.length-1);return await this.renderWalkthroughStep(i,s,e,t,o),true}async startWalkthrough(e,t,o,r){this.walkthroughState.start(e.guideId,e.guideSteps.length),await this.renderWalkthroughStep(e,0,t,o,r)&&(this.enqueueInteractionOnce(e.guideId,t,o,r,"shown",0),this.frequencyCache.record(e.guideId,"shown"));}async renderWalkthroughStep(e,t,o,r,i){this.activeWalkthroughRenderer&&(this.activeWalkthroughRenderer.destroy(),this.activeWalkthroughRenderer=null),this.activeWalkthroughGuide=e;let s={onNext:()=>this.handleWalkthroughNext(o,r,i),onBack:()=>this.handleWalkthroughBack(o,r,i),onSkip:()=>this.handleWalkthroughSkip(o,r,i),onComplete:()=>this.handleWalkthroughComplete(o,r,i)},a=e.guideSteps[t],c=eo(a);if(c==="modal"||c==="banner"){let d=c==="modal"?new K:new B;try{d.render({guide:e,onInteraction:()=>{},onClose:()=>{},nav:{stepIndex:t,totalSteps:e.guideSteps.length,callbacks:s}});}catch(p){return this.debug&&console.error("[veo] sequence renderer threw:",p),this.tearDownWalkthrough(),false}return this.activeWalkthroughRenderer=d,true}let l=new be,u=false;try{u=await l.render({guide:e,currentStepIndex:t,callbacks:s});}catch(d){this.debug&&console.error("[veo] walkthrough renderer threw:",d);}return u?(this.activeWalkthroughRenderer=l,true):(this.debug&&console.warn(`[veo] walkthrough ${e.guideId} step ${t} could not render, cancelling`),this.tearDownWalkthrough(),false)}handleWalkthroughNext(e,t,o){let r=this.activeWalkthroughGuide;if(!r)return;let i=this.walkthroughState.advance();if(!i){this.handleWalkthroughComplete(e,t,o);return}this.enqueueInteraction(r.guideId,e,t,o,"step_advanced",i.currentStepIndex),this.renderWalkthroughStep(r,i.currentStepIndex,e,t,o);}handleWalkthroughBack(e,t,o){let r=this.activeWalkthroughGuide;if(!r)return;let i=this.walkthroughState.current();if(!i||i.currentStepIndex===0)return;let s=this.walkthroughState.back();s&&(this.enqueueInteraction(r.guideId,e,t,o,"step_back",s.currentStepIndex),this.renderWalkthroughStep(r,s.currentStepIndex,e,t,o));}handleWalkthroughSkip(e,t,o){let r=this.activeWalkthroughGuide,i=this.walkthroughState.current();!r||!i||(this.enqueueInteraction(r.guideId,e,t,o,"dismissed",i.currentStepIndex),this.frequencyCache.record(r.guideId,"dismissed"),this.tearDownWalkthrough());}handleWalkthroughComplete(e,t,o){let r=this.activeWalkthroughGuide,i=this.walkthroughState.current();!r||!i||(this.enqueueInteraction(r.guideId,e,t,o,"completed",i.currentStepIndex),this.frequencyCache.record(r.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,o,r){let i=`${e.guideId}:${r.action}`;if(this.dispatched.has(i)){this.debug&&console.log(`[veo] guides: dedup hit ${i}`);return}this.dispatched.add(i);let s=Zn[r.action];s&&this.frequencyCache.record(e.guideId,s);let a=this.client.getEndUserId();if(!a){this.debug&&console.warn("[veo] guides: interaction without endUserId \u2014 skipping enqueue");return}this.trackerQueue.enqueue({guideId:e.guideId,payload:{endUserId:a,sessionId:t,action:r.action,stepIndex:r.stepIndex,pageUrl:o,pagePath:nn(o)}});}enqueueInteraction(e,t,o,r,i,s){this.trackerQueue.enqueue({guideId:e,payload:{endUserId:t,sessionId:o,action:i,stepIndex:s,pageUrl:r,pagePath:nn(r)}});}enqueueInteractionOnce(e,t,o,r,i,s){let a=`${e}:${i}:${s}`;this.dispatched.has(a)||(this.dispatched.add(a),this.enqueueInteraction(e,t,o,r,i,s));}createSingleStepRenderer(e){switch(e){case "modal":return new K;case "banner":return new B;case "tooltip":return new we;case "custom":return new pe;case "inline":return new ye;case "inline-custom":return new ge;case "form":return new fe;case "inline-form":return new ve;case "walkthrough":return null}}async submitFormResponse(e,t){let o=this.client.getEndUserId()??this.client.getAnonymousId();try{let r=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:o,answers:t})});return !r.ok&&this.debug&&console.warn("[veo] form-response respondi\xF3",r.status),r.ok}catch(r){return this.debug&&console.warn("[veo] form-response fall\xF3:",r),false}}};function nn(n){try{return new URL(n).pathname}catch{return "/"}}function eo(n){let e=n?.style?.render;return typeof e=="string"?e:"walkthrough"}var to="__veo_preview__",pt=class{constructor(){this.singleStep=null;this.walkthrough=null;this.walkthroughGuide=null;this.walkthroughIndex=0;this.input=null;}preview(e){this.close(),this.input=e;let t=no(e),o=typeof e.startStepIndex=="number"?e.startStepIndex:0,r=t.guideType==="walkthrough"?this.startWalkthrough(t,o):this.renderSingleStep(t);return {close:()=>this.close(),ready:r}}close(){this.singleStep&&(ne(this.singleStep),this.singleStep=null),this.walkthrough&&(ne(this.walkthrough),this.walkthrough=null),this.walkthroughGuide=null,this.walkthroughIndex=0,this.input=null;}async renderSingleStep(e){let t=oo(e.guideType);if(!t)return {rendered:false};this.singleStep=t;let o=false;try{await t.render({guide:e,onInteraction:r=>{r.action==="shown"&&(o=!0);},onClose:()=>this.close(),onTrack:()=>{},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?(ne(t),{rendered:false}):{rendered:o}}async startWalkthrough(e,t=0){if(e.guideSteps.length===0)return {rendered:false};this.walkthroughGuide=e;let o=Math.min(Math.max(0,Math.floor(t)),e.guideSteps.length-1);return this.walkthroughIndex=o,{rendered:await this.renderWalkthroughStep(o)}}async renderWalkthroughStep(e){let t=this.walkthroughGuide;if(!t)return false;this.walkthrough&&(ne(this.walkthrough),this.walkthrough=null);let o={onNext:()=>{let c=this.walkthroughIndex+1;if(c>=t.guideSteps.length){this.close();return}this.walkthroughIndex=c,this.renderWalkthroughStep(c);},onBack:()=>{let c=this.walkthroughIndex-1;c<0||(this.walkthroughIndex=c,this.renderWalkthroughStep(c));},onSkip:()=>this.close(),onComplete:()=>this.close()},i=t.guideSteps[e]?.style?.render;if(i==="modal"||i==="banner"){let c=i==="modal"?new K:new B;try{c.render({guide:t,onInteraction:()=>{},onClose:()=>this.close(),nav:{stepIndex:e,totalSteps:t.guideSteps.length,callbacks:o}});}catch{return ne(c),false}return this.walkthroughGuide!==t?(ne(c),false):(this.walkthrough=c,true)}let s=new be,a=false;try{a=await s.render({guide:t,currentStepIndex:e,callbacks:o});}catch{a=false;}return !a||this.walkthroughGuide!==t?(ne(s),false):(this.walkthrough=s,true)}},et=null;function tt(n){return Ne()?(et||(et=new pt),et.preview(n)):{close:()=>{},ready:Promise.resolve({rendered:false})}}function on(){et?.close();}function no(n){let e=n.activationRules?.selector,t={url:n.activationRules?.url??{type:"prefix",pattern:"/"},trigger:"immediate",...e!==void 0?{selector:e}:{}};return {guideId:to,guideName:n.guideName??"Preview",guideType:n.guideType,guideSteps:n.guideSteps,activationRules:t,displayFrequency:"always",displayPriority:0}}function oo(n){switch(n){case "modal":return new K;case "banner":return new B;case "tooltip":return new we;case "custom":return new pe;case "inline":return new ye;case "inline-custom":return new ge;case "form":return new fe;case "inline-form":return new ve;case "walkthrough":return null}}function ne(n){try{n.destroy();}catch{}}var nt=null;async function rn(n){if(!Ne())return null;nt?.teardown();let e=null;try{let a=await fetch(`${n.apiUrl}/v1/guides/preview-resolve`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":n.apiKey},body:JSON.stringify({token:n.token})});a.ok?e=(await a.json()).guide??null:n.debug&&console.warn("[veo] preview-resolve respondi\xF3",a.status);}catch(a){n.debug&&console.warn("[veo] preview-resolve fall\xF3:",a);}let t=async a=>{if(!e)return false;let c=window.veo,l=c?.getEndUserId?.()??c?.getAnonymousId?.()??null;if(!l)return false;try{return (await fetch(`${n.apiUrl}/v1/guides/${e.guideId}/form-response`,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":n.apiKey},body:JSON.stringify({endUserId:l,answers:a})})).ok}catch{return false}},o=null,r=()=>{e&&(o?.close(),o=tt({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."}));},i=ro({label:e?`Vista previa: ${e.guideName}`:"Link de preview inv\xE1lido o vencido",error:!e,onReshow:e?r:null,onClose:()=>s.teardown()}),s={teardown(){o?.close(),o=null,i.remove(),nt===s&&(nt=null);}};return nt=s,r(),s}function ro(n){let e=document.createElement("div");e.setAttribute("data-veo-preview-chip","");let t=e.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=`
288
274
  .chip { position: fixed; bottom: 16px; right: 16px; z-index: 2147483647;
289
275
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
290
276
  background: #111827; color: #f9fafb; border-radius: 9999px;
@@ -294,5 +280,5 @@ var veoGuides=(function(exports){'use strict';function ft(){return typeof window
294
280
  button { all: unset; cursor: pointer; padding: 2px 6px; border-radius: 9999px;
295
281
  font-size: 12px; line-height: 1; }
296
282
  button:hover { background: rgba(255,255,255,.15); }
297
- `,t.appendChild(o);let r=document.createElement("div");r.className=n.error?"chip error":"chip";let i=document.createElement("span");if(i.className="label",i.textContent=n.label,r.appendChild(i),n.onReshow){let a=document.createElement("button");a.textContent="\u21BB",a.title="Volver a mostrar la gu\xEDa",a.addEventListener("click",n.onReshow),r.appendChild(a);}let s=document.createElement("button");return s.textContent="\u2715",s.title="Salir de la vista previa",s.addEventListener("click",n.onClose),r.appendChild(s),t.appendChild(r),document.body.appendChild(e),{remove:()=>e.remove()}}function oo(n){return {name:"guides",install(e){if(!ft())return;let t=new Ze(e,n);window.__veoGuides={controller:t},e.on("identify",({sessionId:o})=>{t.checkGuides(window.location.href,o);}),e.on("pageview",({url:o,sessionId:r})=>{t.checkGuides(o,r);}),t.checkGuides(window.location.href,e.getSessionId());}}}exports.closeGuidePreview=on;exports.guidesPlugin=oo;exports.previewGuide=tt;exports.runPreviewMode=rn;return exports;})({});//# sourceMappingURL=veo-guides.js.map
283
+ `,t.appendChild(o);let r=document.createElement("div");r.className=n.error?"chip error":"chip";let i=document.createElement("span");if(i.className="label",i.textContent=n.label,r.appendChild(i),n.onReshow){let a=document.createElement("button");a.textContent="\u21BB",a.title="Volver a mostrar la gu\xEDa",a.addEventListener("click",n.onReshow),r.appendChild(a);}let s=document.createElement("button");return s.textContent="\u2715",s.title="Salir de la vista previa",s.addEventListener("click",n.onClose),r.appendChild(s),t.appendChild(r),document.body.appendChild(e),{remove:()=>e.remove()}}function io(n){return {name:"guides",install(e){if(!ft())return;let t=new Ze(e,n);window.__veoGuides={controller:t},e.on("identify",({sessionId:o})=>{t.checkGuides(window.location.href,o);}),e.on("pageview",({url:o,sessionId:r})=>{t.checkGuides(o,r);}),t.checkGuides(window.location.href,e.getSessionId());}}}exports.closeGuidePreview=on;exports.guidesPlugin=io;exports.previewGuide=tt;exports.runPreviewMode=rn;return exports;})({});//# sourceMappingURL=veo-guides.js.map
298
284
  //# sourceMappingURL=veo-guides.js.map