veo-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRACT.md +144 -0
- package/README.md +141 -0
- package/dist/index.cjs +2536 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +238 -0
- package/dist/index.d.ts +238 -0
- package/dist/index.mjs +2528 -0
- package/dist/index.mjs.map +1 -0
- package/dist/veo.js +170 -0
- package/dist/veo.js.map +1 -0
- package/package.json +64 -0
package/dist/veo.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
var veo=(function(exports){'use strict';var qe="0.0.1";function D(){return typeof window<"u"}function P(){return typeof document<"u"}function Ke(){try{if(typeof localStorage>"u")return !1;let n="__veo_test__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch{return false}}function ft(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}function L(){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 i=Array.from(t,r=>r.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),i.slice(0,4),i.slice(4,8),i.slice(8,20)].join("-")}var me=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.retryCount=0;this.retryTimer=null;this.startTimer();}add(e){this.buffer.push(e),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);try{await this.config.transport.send("/v1/events",{events:e}),this.retryCount=0;}catch(t){this.buffer.unshift(...e),this.scheduleRetry(),this.config.onError?.(t);}finally{this.flushing=false;}}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);this.config.transport.sendBeacon("/v1/events",{events:e})||this.buffer.unshift(...e);}destroy(){this.timer&&clearInterval(this.timer),this.retryTimer&&clearTimeout(this.retryTimer),this.timer=null,this.retryTimer=null;}startTimer(){this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs);}scheduleRetry(){let e=this.config.maxRetries??3;if(this.retryCount>=e){this.retryCount=0;return}this.retryCount++;let t=Math.min(1e3*2**(this.retryCount-1),3e4);this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.flush();},t);}};var ht="anonymous_user_id",Ye="end_user_id",ve="session_id",ie="session_last_active",pt=1800*1e3,ye=class{constructor(e){this.storage=e;this._endUserId=null;this._anonymousId=this.loadOrCreateAnonymousId(),this._sessionId=this.loadOrCreateSession(),this._endUserId=this.storage.get(Ye);}get anonymousId(){return this._anonymousId}get sessionId(){return this._sessionId}get endUserId(){return this._endUserId}get effectiveUserId(){return this._endUserId??this._anonymousId}setEndUserId(e){this._endUserId=e,this.storage.set(Ye,e);}touch(){let e=this.storage.get(ie),t=Date.now();e&&t-Number.parseInt(e,10)>pt&&(this._sessionId=L(),this.storage.set(ve,this._sessionId)),this.storage.set(ie,String(t));}reset(){this._endUserId=null,this.storage.remove(Ye),this._sessionId=L(),this.storage.set(ve,this._sessionId),this.storage.set(ie,String(Date.now()));}loadOrCreateAnonymousId(){let e=this.storage.get(ht);return e||(e=L(),this.storage.set(ht,e)),e}loadOrCreateSession(){let e=this.storage.get(ve),t=this.storage.get(ie);if(e&&t&&Date.now()-Number.parseInt(t,10)<pt)return e;let i=L();return this.storage.set(ve,i),this.storage.set(ie,String(Date.now())),i}};var O="veo:",yn=365*24*60*60*1e3,we=class{get(e){return localStorage.getItem(O+e)}set(e,t){try{localStorage.setItem(O+e,t);}catch{}}remove(e){localStorage.removeItem(O+e);}clear(){let e=[];for(let t=0;t<localStorage.length;t++){let i=localStorage.key(t);i?.startsWith(O)&&e.push(i);}for(let t of e)localStorage.removeItem(t);}};function gt(){let n=document.cookie;return n===""?[]:n.split("; ")}var xe=class{get(e){let t=`${O}${e}=`;for(let i of gt())if(i.startsWith(t))return decodeURIComponent(i.slice(t.length));return null}set(e,t,i){let r=Math.floor((i?.ttlMs??yn)/1e3),o=typeof location<"u"&&location.protocol==="https:"?"; Secure":"";document.cookie=`${O}${e}=${encodeURIComponent(t)}; Path=/; Max-Age=${r}; SameSite=Lax${o}`;}remove(e){document.cookie=`${O}${e}=; Path=/; Max-Age=0; SameSite=Lax`;}clear(){for(let e of gt()){let t=e.indexOf("="),i=t===-1?e:e.slice(0,t);i.startsWith(O)&&this.remove(i.slice(O.length));}}},be=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function mt(n="localStorage"){return n==="localStorage"&&Ke()?new we:n==="cookie"&&P()?new xe:n==="memory"?new be:Ke()?new we:P()?new xe:new be}var Xe=class extends Error{constructor(t,i){super(t);this.statusCode=i;this.name="TransportError";}},Se=class{constructor(e){this.config=e;}async send(e,t){let i=`${this.config.apiUrl}${e}`,r=new AbortController,o=setTimeout(()=>r.abort(),this.config.timeoutMs??1e4);try{let s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.config.apiKey,"X-Sdk-Version":this.config.sdkVersion},body:JSON.stringify(t),keepalive:!0,signal:r.signal});if(!s.ok)throw new Xe(`HTTP ${s.status}`,s.status);return await s.json()}finally{clearTimeout(o);}}sendBeacon(e,t){if(!ft())return false;let i=new URL(`${this.config.apiUrl}${e}`);i.searchParams.set("key",this.config.apiKey),i.searchParams.set("v",this.config.sdkVersion);let r=new Blob([JSON.stringify(t)],{type:"application/json"});return navigator.sendBeacon(i.toString(),r)}};var je="organization_id",vt="end_user_id",Qe="identify_signature";function Je(n){return n===null||typeof n!="object"?JSON.stringify(n)??"null":Array.isArray(n)?`[${n.map(Je).join(",")}]`:`{${Object.keys(n).sort().map(t=>`${JSON.stringify(t)}:${Je(n[t])}`).join(",")}}`}var re=class{constructor(e){this.config=e;this.plugins=[];this.currentOrganizationId=null;this.listeners={pageview:new Set,identify:new Set};if(!e.apiKey)throw new Error("apiKey is required");if(!e.apiUrl)throw new Error("apiUrl is required");this.storage=mt(e.storage??"localStorage"),this.session=new ye(this.storage),this.transport=new Se({apiKey:e.apiKey,apiUrl:e.apiUrl.replace(/\/$/,""),sdkVersion:qe}),this.queue=new me({transport:this.transport,flushIntervalMs:e.flushInterval??5e3,batchSize:e.flushBatchSize??20,onError:r=>{e.debug&&console.error("[veo] flush error:",r);}});let t=this.storage.get(vt);t&&this.session.setEndUserId(t);let i=this.storage.get(je);i&&(this.currentOrganizationId=i),this.setupUnloadHandlers(),e.debug&&console.log("[veo] initialized",{anonymousId:this.session.anonymousId,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}identify(e){let{visitor:t,organization:i}=e,r=Je({id:t.id,traits:t.traits??{},org:i?{id:i.id,attributes:i.attributes??{}}:null});if(this.session.endUserId===t.id&&this.storage.get(Qe)===r){this.config.debug&&console.debug("[veo] identify: sin cambios, omitido");return}let o=this.session.endUserId===null?this.session.anonymousId:void 0;this.session.setEndUserId(t.id),i&&(this.currentOrganizationId=i.id,this.storage.set(je,i.id));let a={endUser:{id:t.id,traits:t.traits??{},...o!==void 0?{anonymousId:o}:{}},...i?{organization:{id:i.id,attributes:i.attributes??{}}}:{}};this.transport.send("/v1/identify",a).catch(c=>{this.config.debug&&console.error("[veo] identify failed:",c);}),this.enqueue({actionType:"identify",actionProperties:{traits:t.traits,organizationAttributes:i?.attributes}}),this.storage.set(Qe,r),this.emit("identify",{endUserId:t.id,sessionId:this.session.sessionId});}track(e,t){if(!e||typeof e!="string"){this.config.debug&&console.error("[veo] track: name is required");return}this.enqueue({actionType:"track",actionName:e,...t!==void 0?{actionProperties:t}:{}});}pageview(e){if(!P())return;let t=window.location.href,i=e??window.location.pathname;this.enqueue({actionType:"pageview",pageUrl:t,pagePath:i,pageTitle:document.title,pageReferrer:document.referrer}),this.emit("pageview",{url:t,path:i,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}reset(){this.session.reset(),this.currentOrganizationId=null,this.storage.remove(je),this.storage.remove(vt),this.storage.remove(Qe);}flush(){return this.queue.flush()}use(e){return this.plugins.push(e),e.install(this),this}getEndUserId(){return this.session.endUserId}getSessionId(){return this.session.sessionId}on(e,t){return this.listeners[e].add(t),()=>{this.listeners[e].delete(t);}}emit(e,t){for(let i of this.listeners[e])try{i(t);}catch(r){this.config.debug&&console.error(`[veo] listener for '${e}' failed:`,r);}}enqueue(e){this.session.touch();let t=this.currentOrganizationId??void 0,i=e.pageUrl??(D()?window.location.href:void 0),r=e.pagePath??(D()?window.location.pathname:void 0),o=e.pageTitle??(P()?document.title:void 0),s=e.pageReferrer??(P()?document.referrer:void 0),a={actionId:L(),endUserId:this.session.effectiveUserId,sessionId:this.session.sessionId,actionType:e.actionType,occurredAt:new Date().toISOString(),...t!==void 0?{organizationId:t}:{},...e.actionName!==void 0?{actionName:e.actionName}:{},...i!==void 0?{pageUrl:i}:{},...r!==void 0?{pagePath:r}:{},...o!==void 0?{pageTitle:o}:{},...s!==void 0?{pageReferrer:s}:{},...e.actionProperties!==void 0?{actionProperties:e.actionProperties}:{}};this.queue.add(a);}setupUnloadHandlers(){D()&&(window.addEventListener("pagehide",()=>this.queue.flushBeacon()),window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.queue.flushBeacon();}));}};function bn(n){return n}var yt={enabled:true,captureClicks:true,captureSubmits:true,captureChanges:true,maskAllInputs:true,maskAllText:false,throttleMs:100,maxTextLength:200,captureElementMetadata:true,captureAncestors:5},wt=10,xt=["[data-veo-ignore]",".veo-ignore",'input[type="password"]','input[type="email"]','input[type="tel"]','input[type="hidden"]','[autocomplete="cc-number"]','[autocomplete="cc-csc"]','[autocomplete="cc-exp"]','[autocomplete="cc-name"]','[name*="password" i]','[name*="ssn" i]','[name*="credit" i]','[name*="card" i]','[id*="password" i]','[id*="ssn" i]'],bt=["value","data-credit-card","data-ssn","data-password"],St=["id","name","type","role","href","data-action","data-veo-tag","data-testid","aria-label","aria-labelledby"],Et=[/^css-[a-z0-9]{4,}$/i,/^_[a-z0-9]+_[a-z0-9]{4,}_\d+$/,/^[a-z]{2,4}-[a-z0-9]{6,}$/i,/^[a-f0-9]{6,}$/i,/^sc-[a-z0-9]+$/i];function Ee(n,e=[]){let t=[...xt,...e],i=n;for(;i&&i!==document.documentElement;){for(let r of t)try{if(i.matches(r))return !0}catch{}i=i.parentElement;}return false}function Ct(n){let e=n.toLowerCase();return bt.includes(e)||/password|secret|token|ssn|credit/i.test(n)}function kt(n,e,t){if(t)return "";let i=n.tagName.toLowerCase();if(i==="input"||i==="textarea")return "";let o=((n instanceof HTMLElement?n.innerText:"")||n.textContent||"").trim().replace(/\s+/g," ");return o.length>e?`${o.slice(0,e)}\u2026`:o}function Sn(n){return Et.some(e=>e.test(n))}function oe(n){return Array.from(n.classList).filter(e=>!Sn(e)&&e.length<64)}var En=["data-testid","data-test","data-cy","name","aria-label","placeholder","alt","title","href","role","type"],Cn=100;function Ze(n){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(n):n.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&")}function At(n){return n.replace(/[\\"]/g,"\\$&")}function kn(n,e){for(let t of En){let i=n.getAttribute(t);if(i&&i.length>0&&i.length<=Cn)return `${e}[${t}="${At(i)}"]`}return null}function An(n){let e=n.tagName.toLowerCase(),t=n.getAttribute("data-veo-tag");if(t)return `${e}[data-veo-tag="${At(t)}"]`;if(n.id){let s=oe(n),a=s.length>0?`.${s.map(Ze).join(".")}`:"";return `${e}#${Ze(n.id)}${a}`}let i=kn(n,e);if(i)return i;let r=oe(n),o=r.length>0?`.${r.map(Ze).join(".")}`:"";return `${e}${o}`}function It(n,e=5){let t=[],i=n,r=0;for(;i&&i!==document.documentElement&&r<=e;)t.unshift(An(i)),i=i.parentElement,r++;return t.join(" > ")}function In(n){let e={};for(let t of St){let i=n.getAttribute(t);i!==null&&!Ct(t)&&i.length<256&&(e[t]=i);}return e}function Rn(n,e){let t=n.getBoundingClientRect();return {tag:n.tagName.toLowerCase(),id:n.id||null,classes:oe(n),text:kt(n,e.maxTextLength,e.maskAllText),attributes:e.captureElementMetadata?In(n):{},position:{x:Math.round(t.left+window.scrollX),y:Math.round(t.top+window.scrollY),w:Math.round(t.width),h:Math.round(t.height)}}}function Tn(n,e){let t=[],i=n.parentElement,r=0;for(;i&&i!==document.documentElement&&r<e;)t.push({tag:i.tagName.toLowerCase(),id:i.id||null,classes:oe(i),veoTag:i.getAttribute("data-veo-tag")||null}),i=i.parentElement,r++;return t}function Rt(n,e,t){return {$event_type:n,$element:Rn(e,t),$ancestors:Tn(e,t.captureAncestors),$selector_path:It(e,t.captureAncestors),$page_url:window.location.href,$page_path:window.location.pathname}}var Ce=class{constructor(e){this.windowMs=e;this.lastFired=new WeakMap;}shouldFire(e){let t=Date.now(),i=this.lastFired.get(e)??0;return t-i<this.windowMs?false:(this.lastFired.set(e,t),true)}};var ke=class{constructor(e,t){this.client=e;this.cleanups=[];let i=yt;this.config={enabled:t.enabled??i.enabled,captureClicks:t.captureClicks??i.captureClicks,captureSubmits:t.captureSubmits??i.captureSubmits,captureChanges:t.captureChanges??i.captureChanges,maskAllInputs:t.maskAllInputs??i.maskAllInputs,maskAllText:t.maskAllText??i.maskAllText,blockSelectors:t.blockSelectors??[],throttleMs:t.throttleMs??i.throttleMs,maxTextLength:t.maxTextLength??i.maxTextLength,captureElementMetadata:t.captureElementMetadata??i.captureElementMetadata,captureAncestors:Math.min(t.captureAncestors??i.captureAncestors,wt)},this.throttle=new Ce(this.config.throttleMs);}install(){!P()||!this.config.enabled||(this.config.captureClicks&&this.attach("click",e=>this.handleClick(e)),this.config.captureSubmits&&this.attach("submit",e=>this.handleSubmit(e),true),this.config.captureChanges&&this.attach("change",e=>this.handleChange(e),true));}destroy(){for(let e of this.cleanups)e();this.cleanups=[];}attach(e,t,i=false){let r=o=>{if(o.isTrusted)try{t(o);}catch{}};document.addEventListener(e,r,i),this.cleanups.push(()=>document.removeEventListener(e,r,i));}handleClick(e){let t=e.target;if(!(t instanceof Element))return;let i=this.findMeaningfulAncestor(t);i&&(Ee(i,this.config.blockSelectors)||this.throttle.shouldFire(i)&&this.emit("click",i));}handleSubmit(e){let t=e.target;!(t instanceof Element)||t.tagName.toLowerCase()!=="form"||Ee(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("submit",t);}handleChange(e){let t=e.target;if(!(t instanceof Element))return;let i=t.tagName.toLowerCase();i!=="select"&&i!=="input"&&i!=="textarea"||t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||Ee(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("change",t);}findMeaningfulAncestor(e){let t=e,i=0;for(;t&&t!==document.documentElement&&i<5;){let r=t.tagName.toLowerCase();if(r==="button"||r==="a"||r==="input"||r==="select"||r==="textarea"||t.hasAttribute("data-veo-tag")||t.hasAttribute("role")||t.hasAttribute("onclick")||t instanceof HTMLElement&&t.style.cursor==="pointer")return t;t=t.parentElement,i++;}return null}emit(e,t){let i=Rt(e,t,this.config);this.client.track("$autocapture",i);}};function et(n={}){let e=null;return {name:"autocapture",install(t){e=new ke(t,n),e.install();},destroy(){e?.destroy(),e=null;}}}var Tt=["http:","https:"],_t="data-veo-guide",Pt="veo:freq:";var Lt="veo:walkthrough_state:";var Nt={shown:1,dismissed:2,completed:2};function Mt(n){return n.slice(-16)||"default"}var Ae=class{constructor(e){this.storageKey=`${Pt}${e}`,this.cache=this.load(),this.prune();}shouldFilter(e,t){if(t==="every_visit"||t==="always")return false;let i=this.cache.get(e);return i?t==="once"?true:t==="until_dismissed"?i.status==="dismissed":false:false}record(e,t){let i=this.cache.get(e);i&&Nt[t]<Nt[i.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[i,r]of this.cache)e-r.lastInteractionAt>7776e6&&(this.cache.delete(i),t=true);if(this.cache.size>500){let i=Array.from(this.cache.entries()).sort((o,s)=>o[1].lastInteractionAt-s[1].lastInteractionAt),r=this.cache.size-500;for(let o=0;o<r;o++){let s=i[o];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 i=[];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 o=r;i.push([o.guideId,o]);}return new Map(i)}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 Ie=class{constructor(e,t,i=false){this.apiUrl=e;this.apiKey=t;this.debug=i;}async resolve(e,t){let i=new URLSearchParams({endUserId:e,pageUrl:t}),r;try{r=await fetch(`${this.apiUrl}/v1/guides/resolve?${i.toString()}`,{method:"GET",headers:{"X-Api-Key":this.apiKey},credentials:"omit"});}catch(o){return this.debug&&console.error("[veo] guides resolve fetch failed:",o),[]}if(!r.ok)return this.debug&&console.warn("[veo] guides resolve HTTP",r.status),[];try{let o=await r.json();return Array.isArray(o.guides)?o.guides:[]}catch(o){return this.debug&&console.error("[veo] guides resolve parse failed:",o),[]}}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(i){return this.debug&&console.error("[veo] guides fetchById network failed:",i),null}if(!t.ok)return this.debug&&console.warn("[veo] guides fetchById HTTP",t.status),null;try{let i=await t.json();return typeof i.guideId!="string"||typeof i.guideName!="string"||typeof i.guideType!="string"||!Array.isArray(i.guideSteps)||!i.activationRules||typeof i.displayFrequency!="string"||typeof i.displayPriority!="number"?(this.debug&&console.warn("[veo] guides fetchById: unexpected shape"),null):{guideId:i.guideId,guideName:i.guideName,guideType:i.guideType,guideSteps:i.guideSteps,activationRules:i.activationRules,displayFrequency:i.displayFrequency,displayPriority:i.displayPriority}}catch(i){return this.debug&&console.error("[veo] guides fetchById parse failed:",i),null}}};function Ut(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 Re=class{constructor(e,t){this.apiUrl=e;this.apiKey=t;}async send(e){let t=this.buildUrl(e.guideId),i=await fetch(t,{method:"POST",headers:{"X-Api-Key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(Ut(e.payload)),credentials:"omit"});if(!i.ok)throw new Error(`guide interaction send failed: HTTP ${i.status}`)}sendBeacon(e){if(typeof navigator>"u"||typeof navigator.sendBeacon!="function")return false;let t=`${this.buildUrl(e.guideId)}?key=${encodeURIComponent(this.apiKey)}`,i=new Blob([JSON.stringify(Ut(e.payload))],{type:"application/json"});try{return navigator.sendBeacon(t,i)}catch{return false}}buildUrl(e){return `${this.apiUrl}/v1/guides/${encodeURIComponent(e)}/interactions`}};var Te=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(i=>this.config.client.send({guideId:i.guideId,payload:i.payload})));for(let i=0;i<t.length;i++){let r=t[i],o=e[i];!r||!o||r.status!=="fulfilled"&&(o.attempts+=1,o.attempts<this.config.maxRetries?this.buffer.push(o):this.safeOnError(r.reason,o));}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 i=e instanceof Error?e:new Error(String(e));try{this.config.onError(i,t);}catch{}}};function Y(n,e,t){let i=e.createElement("div");if(i.className="veo-guide-content",typeof n.imageUrl=="string"&&n.imageUrl&&H(n.imageUrl)){let s=e.createElement("img");s.className="veo-guide-image",s.src=n.imageUrl,s.alt=typeof n.title=="string"?n.title:"",i.appendChild(s);}if(typeof n.title=="string"&&n.title){let s=e.createElement("h2");s.className="veo-guide-title",s.textContent=n.title,i.appendChild(s);}if(typeof n.content=="string"&&n.content){let s=e.createElement("p");s.className="veo-guide-text",s.textContent=n.content,i.appendChild(s);}let r=e.createElement("div");if(r.className="veo-guide-actions",typeof n.ctaText=="string"&&n.ctaText){let s=e.createElement("button");s.type="button",s.className="veo-guide-cta",s.textContent=n.ctaText,s.addEventListener("click",()=>{let a=n.ctaAction??"dismiss",c=Pn(n);t.onCtaClick(a,c);}),r.appendChild(s);}i.appendChild(r);let o=e.createElement("button");return o.type="button",o.className="veo-guide-close",o.setAttribute("aria-label","Cerrar"),o.textContent="\xD7",o.addEventListener("click",()=>t.onDismiss()),i.appendChild(o),i}function H(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 Tt.includes(t.protocol)}catch{return false}}function Pn(n){let e=n.style?.ctaUrl;if(typeof e=="string")return H(e)?e:void 0}var Dt=`
|
|
2
|
+
:host {
|
|
3
|
+
--veo-primary: #4f46e5;
|
|
4
|
+
--veo-text: #1f2937;
|
|
5
|
+
--veo-text-secondary: #4b5563;
|
|
6
|
+
--veo-bg: #ffffff;
|
|
7
|
+
--veo-radius: 12px;
|
|
8
|
+
--veo-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
|
|
9
|
+
all: initial;
|
|
10
|
+
}
|
|
11
|
+
* { box-sizing: border-box; font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
|
|
12
|
+
|
|
13
|
+
.veo-modal-overlay {
|
|
14
|
+
position: fixed; inset: 0;
|
|
15
|
+
background: rgba(15, 15, 30, 0.45);
|
|
16
|
+
display: flex; align-items: center; justify-content: center;
|
|
17
|
+
z-index: ${2147483640};
|
|
18
|
+
animation: veo-fade-in 180ms ease-out;
|
|
19
|
+
}
|
|
20
|
+
.veo-modal-card {
|
|
21
|
+
background: var(--veo-bg);
|
|
22
|
+
border-radius: var(--veo-radius);
|
|
23
|
+
padding: 24px 28px;
|
|
24
|
+
max-width: 420px; width: 90%;
|
|
25
|
+
position: relative;
|
|
26
|
+
box-shadow: var(--veo-shadow);
|
|
27
|
+
animation: veo-slide-up 220ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.veo-banner {
|
|
31
|
+
position: fixed; left: 0; right: 0;
|
|
32
|
+
background: var(--veo-bg);
|
|
33
|
+
padding: 14px 20px;
|
|
34
|
+
z-index: ${2147483640};
|
|
35
|
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
|
|
36
|
+
animation: veo-slide-down 200ms ease-out;
|
|
37
|
+
}
|
|
38
|
+
.veo-banner-top { top: 0; }
|
|
39
|
+
.veo-banner-bottom { bottom: 0; }
|
|
40
|
+
|
|
41
|
+
.veo-tooltip {
|
|
42
|
+
position: absolute;
|
|
43
|
+
background: var(--veo-bg);
|
|
44
|
+
border-radius: var(--veo-radius);
|
|
45
|
+
padding: 14px 16px;
|
|
46
|
+
max-width: 300px;
|
|
47
|
+
z-index: ${2147483640};
|
|
48
|
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
|
|
49
|
+
animation: veo-fade-in 150ms ease-out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.veo-guide-content {
|
|
53
|
+
position: relative;
|
|
54
|
+
display: flex; flex-direction: column;
|
|
55
|
+
}
|
|
56
|
+
.veo-guide-image {
|
|
57
|
+
display: block; width: 100%; max-height: 180px;
|
|
58
|
+
object-fit: cover; border-radius: 8px;
|
|
59
|
+
margin-bottom: 12px;
|
|
60
|
+
}
|
|
61
|
+
.veo-guide-title {
|
|
62
|
+
font-size: 18px; font-weight: 600; line-height: 1.3;
|
|
63
|
+
margin: 0 0 6px; color: var(--veo-text);
|
|
64
|
+
}
|
|
65
|
+
.veo-guide-text {
|
|
66
|
+
font-size: 14px; line-height: 1.5;
|
|
67
|
+
margin: 0 0 16px; color: var(--veo-text-secondary);
|
|
68
|
+
}
|
|
69
|
+
.veo-guide-actions {
|
|
70
|
+
display: flex; gap: 8px; justify-content: flex-end;
|
|
71
|
+
}
|
|
72
|
+
.veo-guide-cta {
|
|
73
|
+
background: var(--veo-primary); color: #fff; border: none;
|
|
74
|
+
padding: 9px 18px; border-radius: 8px;
|
|
75
|
+
font-size: 14px; font-weight: 500; cursor: pointer;
|
|
76
|
+
transition: opacity 120ms ease;
|
|
77
|
+
}
|
|
78
|
+
.veo-guide-cta:hover { opacity: 0.9; }
|
|
79
|
+
.veo-guide-cta:active { transform: translateY(1px); }
|
|
80
|
+
.veo-guide-close {
|
|
81
|
+
position: absolute; top: -6px; right: -6px;
|
|
82
|
+
width: 24px; height: 24px;
|
|
83
|
+
background: none; border: none;
|
|
84
|
+
font-size: 22px; line-height: 1;
|
|
85
|
+
cursor: pointer; color: #9ca3af; padding: 0;
|
|
86
|
+
}
|
|
87
|
+
.veo-guide-close:hover { color: var(--veo-text); }
|
|
88
|
+
|
|
89
|
+
.veo-walkthrough {
|
|
90
|
+
position: absolute;
|
|
91
|
+
background: var(--veo-bg);
|
|
92
|
+
border-radius: var(--veo-radius);
|
|
93
|
+
padding: 16px;
|
|
94
|
+
max-width: 340px;
|
|
95
|
+
z-index: ${2147483640};
|
|
96
|
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
|
|
97
|
+
animation: veo-fade-in 150ms ease-out;
|
|
98
|
+
}
|
|
99
|
+
.veo-walkthrough-counter {
|
|
100
|
+
font-size: 11px; color: #9ca3af;
|
|
101
|
+
margin-bottom: 8px; letter-spacing: 0.02em;
|
|
102
|
+
}
|
|
103
|
+
.veo-walkthrough-progress {
|
|
104
|
+
display: flex; gap: 4px;
|
|
105
|
+
margin-bottom: 12px;
|
|
106
|
+
}
|
|
107
|
+
.veo-walkthrough-progress-dot {
|
|
108
|
+
width: 8px; height: 8px;
|
|
109
|
+
border-radius: 50%;
|
|
110
|
+
background: #e5e7eb;
|
|
111
|
+
transition: background 200ms ease;
|
|
112
|
+
}
|
|
113
|
+
.veo-walkthrough-progress-dot.active { background: var(--veo-primary); }
|
|
114
|
+
.veo-walkthrough-progress-dot.completed { background: var(--veo-primary); opacity: 0.5; }
|
|
115
|
+
.veo-walkthrough-actions {
|
|
116
|
+
display: flex; align-items: center;
|
|
117
|
+
margin-top: 16px; gap: 8px;
|
|
118
|
+
}
|
|
119
|
+
.veo-walkthrough-actions-right {
|
|
120
|
+
display: flex; gap: 8px;
|
|
121
|
+
margin-left: auto;
|
|
122
|
+
}
|
|
123
|
+
.veo-walkthrough-btn-secondary {
|
|
124
|
+
background: transparent; color: #6b7280;
|
|
125
|
+
border: 1px solid #e5e7eb;
|
|
126
|
+
padding: 8px 16px; border-radius: 8px;
|
|
127
|
+
font-size: 13px; cursor: pointer;
|
|
128
|
+
transition: background 120ms ease;
|
|
129
|
+
}
|
|
130
|
+
.veo-walkthrough-btn-secondary:hover { background: #f9fafb; }
|
|
131
|
+
.veo-walkthrough-skip {
|
|
132
|
+
background: transparent; color: #9ca3af;
|
|
133
|
+
border: none; padding: 4px 8px;
|
|
134
|
+
font-size: 12px; cursor: pointer;
|
|
135
|
+
}
|
|
136
|
+
.veo-walkthrough-skip:hover { color: var(--veo-text); }
|
|
137
|
+
|
|
138
|
+
.veo-custom-floating {
|
|
139
|
+
position: fixed;
|
|
140
|
+
z-index: ${2147483640};
|
|
141
|
+
max-width: calc(100vw - 16px);
|
|
142
|
+
max-height: calc(100vh - 16px);
|
|
143
|
+
animation: veo-fade-in 160ms ease;
|
|
144
|
+
}
|
|
145
|
+
.veo-custom-anchored {
|
|
146
|
+
position: fixed;
|
|
147
|
+
top: 0; left: 0;
|
|
148
|
+
z-index: ${2147483640};
|
|
149
|
+
max-width: calc(100vw - 16px);
|
|
150
|
+
animation: veo-fade-in 160ms ease;
|
|
151
|
+
}
|
|
152
|
+
.veo-custom-frame {
|
|
153
|
+
display: block;
|
|
154
|
+
border: 0;
|
|
155
|
+
width: 360px;
|
|
156
|
+
background: transparent;
|
|
157
|
+
color-scheme: normal;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@keyframes veo-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
161
|
+
@keyframes veo-slide-up {
|
|
162
|
+
from { transform: translateY(10px); opacity: 0; }
|
|
163
|
+
to { transform: translateY(0); opacity: 1; }
|
|
164
|
+
}
|
|
165
|
+
@keyframes veo-slide-down {
|
|
166
|
+
from { transform: translateY(-10px); opacity: 0; }
|
|
167
|
+
to { transform: translateY(0); opacity: 1; }
|
|
168
|
+
}
|
|
169
|
+
`;var S=class{constructor(){this.host=null;this.shadow=null;this.cleanups=[];}createHost(){let e=document.createElement("div");e.setAttribute(_t,"");let t=e.attachShadow({mode:"open"}),i=document.createElement("style");i.textContent=Dt,t.appendChild(i);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}}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 _e=class extends S{render(e){let t=e.guide.guideSteps[0];if(!t)return;let{root:i}=this.createHost(),r=i.ownerDocument??document,o=t.style?.position==="bottom"?"bottom":"top",s=r.createElement("div");s.className=`veo-banner veo-banner-${o}`;let a=(u,d)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:u}),d&&window.open(d,"_blank","noopener,noreferrer"),e.onClose();},c=Y(t,r,{onCtaClick:(u,d)=>{a("cta_clicked",u==="url"?d:void 0);},onDismiss:()=>a("dismissed")});s.appendChild(c),i.appendChild(s),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var ce=Math.min,$=Math.max,le=Math.round;var A=n=>({x:n,y:n}),Ln={left:"right",right:"left",bottom:"top",top:"bottom"};function tt(n,e,t){return $(n,ce(e,t))}function ue(n,e){return typeof n=="function"?n(e):n}function W(n){return n.split("-")[0]}function de(n){return n.split("-")[1]}function nt(n){return n==="x"?"y":"x"}function it(n){return n==="y"?"height":"width"}function N(n){let e=n[0];return e==="t"||e==="b"?"y":"x"}function rt(n){return nt(N(n))}function Ft(n,e,t){t===void 0&&(t=false);let i=de(n),r=rt(n),o=it(r),s=r==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(s=ae(s)),[s,ae(s)]}function Gt(n){let e=ae(n);return [Pe(n),e,Pe(e)]}function Pe(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}var $t=["left","right"],Wt=["right","left"],On=["top","bottom"],Nn=["bottom","top"];function Mn(n,e,t){switch(n){case "top":case "bottom":return t?e?Wt:$t:e?$t:Wt;case "left":case "right":return e?On:Nn;default:return []}}function Ht(n,e,t,i){let r=de(n),o=Mn(W(n),t==="start",i);return r&&(o=o.map(s=>s+"-"+r),e&&(o=o.concat(o.map(Pe)))),o}function ae(n){let e=W(n);return Ln[e]+n.slice(e.length)}function Un(n){return {top:0,right:0,bottom:0,left:0,...n}}function Vt(n){return typeof n!="number"?Un(n):{top:n,right:n,bottom:n,left:n}}function V(n){let{x:e,y:t,width:i,height:r}=n;return {width:i,height:r,top:t,left:e,right:e+i,bottom:t+r,x:e,y:t}}function zt(n,e,t){let{reference:i,floating:r}=n,o=N(e),s=rt(e),a=it(s),c=W(e),u=o==="y",d=i.x+i.width/2-r.width/2,f=i.y+i.height/2-r.height/2,p=i[a]/2-r[a]/2,h;switch(c){case "top":h={x:d,y:i.y-r.height};break;case "bottom":h={x:d,y:i.y+i.height};break;case "right":h={x:i.x+i.width,y:f};break;case "left":h={x:i.x-r.width,y:f};break;default:h={x:i.x,y:i.y};}switch(de(e)){case "start":h[s]-=p*(t&&u?-1:1);break;case "end":h[s]+=p*(t&&u?-1:1);break}return h}async function Bt(n,e){var t;e===void 0&&(e={});let{x:i,y:r,platform:o,rects:s,elements:a,strategy:c}=n,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=false,padding:h=0}=ue(e,n),l=Vt(h),m=a[p?f==="floating"?"reference":"floating":f],v=V(await o.getClippingRect({element:(t=await(o.isElement==null?void 0:o.isElement(m)))==null||t?m:m.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:c})),y=f==="floating"?{x:i,y:r,width:s.floating.width,height:s.floating.height}:s.reference,w=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),x=await(o.isElement==null?void 0:o.isElement(w))?await(o.getScale==null?void 0:o.getScale(w))||{x:1,y:1}:{x:1,y:1},_=V(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:w,strategy:c}):y);return {top:(v.top-_.top+l.top)/x.y,bottom:(_.bottom-v.bottom+l.bottom)/x.y,left:(v.left-_.left+l.left)/x.x,right:(_.right-v.right+l.right)/x.x}}var Dn=50,qt=async(n,e,t)=>{let{placement:i="bottom",strategy:r="absolute",middleware:o=[],platform:s}=t,a=s.detectOverflow?s:{...s,detectOverflow:Bt},c=await(s.isRTL==null?void 0:s.isRTL(e)),u=await s.getElementRects({reference:n,floating:e,strategy:r}),{x:d,y:f}=zt(u,i,c),p=i,h=0,l={};for(let g=0;g<o.length;g++){let m=o[g];if(!m)continue;let{name:v,fn:y}=m,{x:w,y:x,data:_,reset:I}=await y({x:d,y:f,initialPlacement:i,placement:p,strategy:r,middlewareData:l,rects:u,platform:a,elements:{reference:n,floating:e}});d=w??d,f=x??f,l[v]={...l[v],..._},I&&h<Dn&&(h++,typeof I=="object"&&(I.placement&&(p=I.placement),I.rects&&(u=I.rects===true?await s.getElementRects({reference:n,floating:e,strategy:r}):I.rects),{x:d,y:f}=zt(u,p,c)),g=-1);}return {x:d,y:f,placement:p,strategy:r,middlewareData:l}};var Kt=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,i;let{placement:r,middlewareData:o,rects:s,initialPlacement:a,platform:c,elements:u}=e,{mainAxis:d=true,crossAxis:f=true,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:l="none",flipAlignment:g=true,...m}=ue(n,e);if((t=o.arrow)!=null&&t.alignmentOffset)return {};let v=W(r),y=N(a),w=W(a)===a,x=await(c.isRTL==null?void 0:c.isRTL(u.floating)),_=p||(w||!g?[ae(a)]:Gt(a)),I=l!=="none";!p&&I&&_.push(...Ht(a,g,l,x));let mn=[a,..._],ze=await c.detectOverflow(e,m),ge=[],K=((i=o.flip)==null?void 0:i.overflows)||[];if(d&&ge.push(ze[v]),f){let F=Ft(r,s,x);ge.push(ze[F[0]],ze[F[1]]);}if(K=[...K,{placement:r,overflows:ge}],!ge.every(F=>F<=0)){var lt,ut;let F=(((lt=o.flip)==null?void 0:lt.index)||0)+1,Be=mn[F];if(Be&&(!(f==="alignment"?y!==N(Be):false)||K.every(k=>N(k.placement)===y?k.overflows[0]>0:true)))return {data:{index:F,overflows:K},reset:{placement:Be}};let ne=(ut=K.filter(G=>G.overflows[0]<=0).sort((G,k)=>G.overflows[1]-k.overflows[1])[0])==null?void 0:ut.placement;if(!ne)switch(h){case "bestFit":{var dt;let G=(dt=K.filter(k=>{if(I){let U=N(k.placement);return U===y||U==="y"}return true}).map(k=>[k.placement,k.overflows.filter(U=>U>0).reduce((U,vn)=>U+vn,0)]).sort((k,U)=>k[1]-U[1])[0])==null?void 0:dt[0];G&&(ne=G);break}case "initialPlacement":ne=a;break}if(r!==ne)return {reset:{placement:ne}}}return {}}}};var $n=new Set(["left","top"]);async function Wn(n,e){let{placement:t,platform:i,elements:r}=n,o=await(i.isRTL==null?void 0:i.isRTL(r.floating)),s=W(t),a=de(t),c=N(t)==="y",u=$n.has(s)?-1:1,d=o&&c?-1:1,f=ue(e,n),{mainAxis:p,crossAxis:h,alignmentAxis:l}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof l=="number"&&(h=a==="end"?l*-1:l),c?{x:h*d,y:p*u}:{x:p*u,y:h*d}}var Yt=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;let{x:r,y:o,placement:s,middlewareData:a}=e,c=await Wn(e,n);return s===((t=a.offset)==null?void 0:t.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:r+c.x,y:o+c.y,data:{...c,placement:s}}}}},Xt=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){let{x:t,y:i,placement:r,platform:o}=e,{mainAxis:s=true,crossAxis:a=false,limiter:c={fn:v=>{let{x:y,y:w}=v;return {x:y,y:w}}},...u}=ue(n,e),d={x:t,y:i},f=await o.detectOverflow(e,u),p=N(W(r)),h=nt(p),l=d[h],g=d[p];if(s){let v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=l+f[v],x=l-f[y];l=tt(w,l,x);}if(a){let v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",w=g+f[v],x=g-f[y];g=tt(w,g,x);}let m=c.fn({...e,[h]:l,[p]:g});return {...m,data:{x:m.x-t,y:m.y-i,enabled:{[h]:s,[p]:a}}}}}};function Oe(){return typeof window<"u"}function B(n){return Qt(n)?(n.nodeName||"").toLowerCase():"#document"}function b(n){var e;return (n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function R(n){var e;return (e=(Qt(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Qt(n){return Oe()?n instanceof Node||n instanceof b(n).Node:false}function E(n){return Oe()?n instanceof Element||n instanceof b(n).Element:false}function T(n){return Oe()?n instanceof HTMLElement||n instanceof b(n).HTMLElement:false}function jt(n){return !Oe()||typeof ShadowRoot>"u"?false:n instanceof ShadowRoot||n instanceof b(n).ShadowRoot}function X(n){let{overflow:e,overflowX:t,overflowY:i,display:r}=C(n);return /auto|scroll|overlay|hidden|clip/.test(e+i+t)&&r!=="inline"&&r!=="contents"}function Jt(n){return /^(table|td|th)$/.test(B(n))}function fe(n){try{if(n.matches(":popover-open"))return !0}catch{}try{return n.matches(":modal")}catch{return false}}var Fn=/transform|translate|scale|rotate|perspective|filter/,Gn=/paint|layout|strict|content/,z=n=>!!n&&n!=="none",ot;function Ne(n){let e=E(n)?C(n):n;return z(e.transform)||z(e.translate)||z(e.scale)||z(e.rotate)||z(e.perspective)||!Me()&&(z(e.backdropFilter)||z(e.filter))||Fn.test(e.willChange||"")||Gn.test(e.contain||"")}function Zt(n){let e=M(n);for(;T(e)&&!q(e);){if(Ne(e))return e;if(fe(e))return null;e=M(e);}return null}function Me(){return ot==null&&(ot=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ot}function q(n){return /^(html|body|#document)$/.test(B(n))}function C(n){return b(n).getComputedStyle(n)}function he(n){return E(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function M(n){if(B(n)==="html")return n;let e=n.assignedSlot||n.parentNode||jt(n)&&n.host||R(n);return jt(e)?e.host:e}function en(n){let e=M(n);return q(e)?n.ownerDocument?n.ownerDocument.body:n.body:T(e)&&X(e)?e:en(e)}function Le(n,e,t){var i;e===void 0&&(e=[]);let r=en(n),o=r===((i=n.ownerDocument)==null?void 0:i.body),s=b(r);if(o){Ue(s);return e.concat(s,s.visualViewport||[],X(r)?r:[],[])}else return e.concat(r,Le(r,[]))}function Ue(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function on(n){let e=C(n),t=parseFloat(e.width)||0,i=parseFloat(e.height)||0,r=T(n),o=r?n.offsetWidth:t,s=r?n.offsetHeight:i,a=le(t)!==o||le(i)!==s;return a&&(t=o,i=s),{width:t,height:i,$:a}}function sn(n){return E(n)?n:n.contextElement}function j(n){let e=sn(n);if(!T(e))return A(1);let t=e.getBoundingClientRect(),{width:i,height:r,$:o}=on(e),s=(o?le(t.width):t.width)/i,a=(o?le(t.height):t.height)/r;return (!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Hn=A(0);function an(n){let e=b(n);return !Me()||!e.visualViewport?Hn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Vn(n,e,t){return e===void 0&&(e=false),!t||e&&t!==b(n)?false:e}function pe(n,e,t,i){e===void 0&&(e=false),t===void 0&&(t=false);let r=n.getBoundingClientRect(),o=sn(n),s=A(1);e&&(i?E(i)&&(s=j(i)):s=j(n));let a=Vn(o,t,i)?an(o):A(0),c=(r.left+a.x)/s.x,u=(r.top+a.y)/s.y,d=r.width/s.x,f=r.height/s.y;if(o){let p=b(o),h=i&&E(i)?b(i):i,l=p,g=Ue(l);for(;g&&i&&h!==l;){let m=j(g),v=g.getBoundingClientRect(),y=C(g),w=v.left+(g.clientLeft+parseFloat(y.paddingLeft))*m.x,x=v.top+(g.clientTop+parseFloat(y.paddingTop))*m.y;c*=m.x,u*=m.y,d*=m.x,f*=m.y,c+=w,u+=x,l=b(g),g=Ue(l);}}return V({width:d,height:f,x:c,y:u})}function De(n,e){let t=he(n).scrollLeft;return e?e.left+t:pe(R(n)).left+t}function cn(n,e){let t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-De(n,t),r=t.top+e.scrollTop;return {x:i,y:r}}function zn(n){let{elements:e,rect:t,offsetParent:i,strategy:r}=n,o=r==="fixed",s=R(i),a=e?fe(e.floating):false;if(i===s||a&&o)return t;let c={scrollLeft:0,scrollTop:0},u=A(1),d=A(0),f=T(i);if((f||!f&&!o)&&((B(i)!=="body"||X(s))&&(c=he(i)),f)){let h=pe(i);u=j(i),d.x=h.x+i.clientLeft,d.y=h.y+i.clientTop;}let p=s&&!f&&!o?cn(s,c):A(0);return {width:t.width*u.x,height:t.height*u.y,x:t.x*u.x-c.scrollLeft*u.x+d.x+p.x,y:t.y*u.y-c.scrollTop*u.y+d.y+p.y}}function Bn(n){return Array.from(n.getClientRects())}function qn(n){let e=R(n),t=he(n),i=n.ownerDocument.body,r=$(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),o=$(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),s=-t.scrollLeft+De(n),a=-t.scrollTop;return C(i).direction==="rtl"&&(s+=$(e.clientWidth,i.clientWidth)-r),{width:r,height:o,x:s,y:a}}var tn=25;function Kn(n,e){let t=b(n),i=R(n),r=t.visualViewport,o=i.clientWidth,s=i.clientHeight,a=0,c=0;if(r){o=r.width,s=r.height;let d=Me();(!d||d&&e==="fixed")&&(a=r.offsetLeft,c=r.offsetTop);}let u=De(i);if(u<=0){let d=i.ownerDocument,f=d.body,p=getComputedStyle(f),h=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,l=Math.abs(i.clientWidth-f.clientWidth-h);l<=tn&&(o-=l);}else u<=tn&&(o+=u);return {width:o,height:s,x:a,y:c}}function Yn(n,e){let t=pe(n,true,e==="fixed"),i=t.top+n.clientTop,r=t.left+n.clientLeft,o=T(n)?j(n):A(1),s=n.clientWidth*o.x,a=n.clientHeight*o.y,c=r*o.x,u=i*o.y;return {width:s,height:a,x:c,y:u}}function nn(n,e,t){let i;if(e==="viewport")i=Kn(n,t);else if(e==="document")i=qn(R(n));else if(E(e))i=Yn(e,t);else {let r=an(n);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height};}return V(i)}function ln(n,e){let t=M(n);return t===e||!E(t)||q(t)?false:C(t).position==="fixed"||ln(t,e)}function Xn(n,e){let t=e.get(n);if(t)return t;let i=Le(n,[]).filter(a=>E(a)&&B(a)!=="body"),r=null,o=C(n).position==="fixed",s=o?M(n):n;for(;E(s)&&!q(s);){let a=C(s),c=Ne(s);!c&&a.position==="fixed"&&(r=null),(o?!c&&!r:!c&&a.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||X(s)&&!c&&ln(n,s))?i=i.filter(d=>d!==s):r=a,s=M(s);}return e.set(n,i),i}function jn(n){let{element:e,boundary:t,rootBoundary:i,strategy:r}=n,s=[...t==="clippingAncestors"?fe(e)?[]:Xn(e,this._c):[].concat(t),i],a=nn(e,s[0],r),c=a.top,u=a.right,d=a.bottom,f=a.left;for(let p=1;p<s.length;p++){let h=nn(e,s[p],r);c=$(h.top,c),u=ce(h.right,u),d=ce(h.bottom,d),f=$(h.left,f);}return {width:u-f,height:d-c,x:f,y:c}}function Qn(n){let{width:e,height:t}=on(n);return {width:e,height:t}}function Jn(n,e,t){let i=T(e),r=R(e),o=t==="fixed",s=pe(n,true,o,e),a={scrollLeft:0,scrollTop:0},c=A(0);function u(){c.x=De(r);}if(i||!i&&!o)if((B(e)!=="body"||X(r))&&(a=he(e)),i){let h=pe(e,true,o,e);c.x=h.x+e.clientLeft,c.y=h.y+e.clientTop;}else r&&u();o&&!i&&r&&u();let d=r&&!i&&!o?cn(r,a):A(0),f=s.left+a.scrollLeft-c.x-d.x,p=s.top+a.scrollTop-c.y-d.y;return {x:f,y:p,width:s.width,height:s.height}}function st(n){return C(n).position==="static"}function rn(n,e){if(!T(n)||C(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return R(n)===t&&(t=t.ownerDocument.body),t}function un(n,e){let t=b(n);if(fe(n))return t;if(!T(n)){let r=M(n);for(;r&&!q(r);){if(E(r)&&!st(r))return r;r=M(r);}return t}let i=rn(n,e);for(;i&&Jt(i)&&st(i);)i=rn(i,e);return i&&q(i)&&st(i)&&!Ne(i)?t:i||Zt(n)||t}var Zn=async function(n){let e=this.getOffsetParent||un,t=this.getDimensions,i=await t(n.floating);return {reference:Jn(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ei(n){return C(n).direction==="rtl"}var ti={convertOffsetParentRelativeRectToViewportRelativeRect:zn,getDocumentElement:R,getClippingRect:jn,getOffsetParent:un,getElementRects:Zn,getClientRects:Bn,getDimensions:Qn,getScale:j,isElement:E,isRTL:ei};var Q=Yt;var J=Xt,Z=Kt;var ee=(n,e,t)=>{let i=new Map,r={platform:ti,...t},o={...r.platform,_c:i};return qt(n,e,{...r,platform:o})};function te(n,e=5e3){return new Promise(t=>{let i=()=>{try{return document.querySelector(n)}catch{return null}},r=i();if(r){t(r);return}let o=false,s=u=>{o||(o=true,a.disconnect(),clearTimeout(c),t(u));},a=new MutationObserver(()=>{let u=i();u&&s(u);});a.observe(document.body,{childList:true,subtree:true});let c=setTimeout(()=>s(null),e);})}var ni={mode:"floating",position:"bottom-right"},dn=16,ii=360,$e=class extends S{async render(e){let t=e.guide.guideSteps[0];if(!t||typeof t.html!="string"||t.html.length===0)return;let i=t.placement??ni,r=null;if(i.mode==="anchored"){let h=i.selector??t.selector??e.guide.activationRules.selector;if(typeof h!="string"||h.length===0||(r=await te(h),!r))return}let{root:o}=this.createHost(),s=o.ownerDocument??document,a=s.createElement("div");a.className=i.mode==="anchored"?"veo-custom-anchored":"veo-custom-floating";let c=s.createElement("iframe");c.className="veo-custom-frame",c.setAttribute("sandbox","allow-scripts"),c.setAttribute("title",e.guide.guideName||"Veo"),c.style.width=fn(i.width??ii);let u=i.height!==void 0&&i.height!==null;u&&(c.style.height=fn(i.height));let d=L();c.srcdoc=si(t.html,t.css??"",t.js??"",d),a.appendChild(c),o.appendChild(a),i.mode==="floating"?oi(a,i):r&&this.registerCleanup(await this.setupAnchoredPosition(r,a,i));let f=()=>e.onClose(),p=h=>{if(h.source!==c.contentWindow)return;let l=h.data;if(!(!l||typeof l!="object"||l.__veo!==d))switch(l.type){case "dismiss":e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"dismissed"}),f();break;case "cta":e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"cta_clicked"}),typeof l.url=="string"&&H(l.url)&&window.open(l.url,"_blank","noopener,noreferrer"),l.close!==false&&f();break;case "navigate":typeof l.url=="string"&&H(l.url)&&window.location.assign(l.url);break;case "track":typeof l.name=="string"&&e.onTrack&&e.onTrack(l.name,ri(l.props)?l.props:void 0);break;case "resize":!u&&typeof l.height=="number"&&l.height>0&&(c.style.height=`${Math.ceil(l.height)}px`);break}};window.addEventListener("message",p),this.registerCleanup(()=>window.removeEventListener("message",p)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}async setupAnchoredPosition(e,t,i){let r=i.side??"bottom",o=async()=>{let{x:a,y:c}=await ee(e,t,{placement:r,strategy:"fixed",middleware:[Q(i.offsetY??8),Z(),J({padding:8})]});t.style.left=`${a}px`,t.style.top=`${c}px`;};await o();let s=()=>{o();};return window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}}};function fn(n){return typeof n=="number"?`${n}px`:n}function ri(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function oi(n,e){let t=e.position??"bottom-right",i=`${e.offsetX??dn}px`,r=`${e.offsetY??dn}px`,o=n.style;if(t==="center"){o.top="50%",o.left="50%",o.transform="translate(-50%, -50%)";return}let[s,a]=t.split("-");s==="top"?o.top=r:o.bottom=r,a==="left"?o.left=i:a==="right"?o.right=i:(o.left="50%",o.transform="translateX(-50%)");}function si(n,e,t,i){let r=`(function(){var T=${JSON.stringify(i)};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});}};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){}})();`;return `<!DOCTYPE html><html><head><meta charset="utf-8"><style>html,body{margin:0;padding:0;background:transparent;}</style><style>${hn(e,"style")}</style></head><body>${n}<script>${r}</script>`+(t?`<script>${hn(t,"script")}</script>`:"")+"</body></html>"}function hn(n,e){let t=e==="script"?/<\/script/gi:/<\/style/gi;return n.replace(t,`<\\/${e}`)}var We=class extends S{render(e){let t=e.guide.guideSteps[0];if(!t)return;let{root:i}=this.createHost(),r=i.ownerDocument??document,o=r.createElement("div");o.className="veo-modal-overlay";let s=r.createElement("div");s.className="veo-modal-card";let a=(d,f)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:d}),f&&window.open(f,"_blank","noopener,noreferrer"),e.onClose();},c=Y(t,r,{onCtaClick:(d,f)=>{a("cta_clicked",d==="url"?f:void 0);},onDismiss:()=>a("dismissed")});s.appendChild(c),o.appendChild(s),i.appendChild(o),o.addEventListener("click",d=>{d.target===o&&a("dismissed");});let u=d=>{d.key==="Escape"&&a("dismissed");};document.addEventListener("keydown",u),this.registerCleanup(()=>document.removeEventListener("keydown",u)),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};var Fe=class extends S{async render(e){let t=e.guide.guideSteps[0];if(!t)return;let i=t.selector??e.guide.activationRules.selector;if(typeof i!="string"||i.length===0)return;let r=await te(i);if(!r)return;let{root:o}=this.createHost(),s=o.ownerDocument??document,a=s.createElement("div");a.className="veo-tooltip";let c=(p,h)=>{e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:p}),h&&window.open(h,"_blank","noopener,noreferrer"),e.onClose();},u=Y(t,s,{onCtaClick:(p,h)=>{c("cta_clicked",p==="url"?h:void 0);},onDismiss:()=>c("dismissed")});a.appendChild(u),o.appendChild(a);let d=async()=>{let{x:p,y:h}=await ee(r,a,{placement:"bottom",middleware:[Q(8),Z(),J({padding:8})]});a.style.left=`${p}px`,a.style.top=`${h}px`;};await d();let f=()=>{d();};window.addEventListener("scroll",f,true),window.addEventListener("resize",f),this.registerCleanup(()=>{window.removeEventListener("scroll",f,true),window.removeEventListener("resize",f);}),e.onInteraction({guideId:e.guide.guideId,stepIndex:0,action:"shown"});}};function pn(n,e,t,i,r){let o=i.createElement("div");o.className="veo-guide-content";let s=i.createElement("div");s.className="veo-walkthrough-counter",s.textContent=`Paso ${e+1} de ${t}`,o.appendChild(s);let a=i.createElement("div");a.className="veo-walkthrough-progress";for(let l=0;l<t;l++){let g=i.createElement("span");g.className="veo-walkthrough-progress-dot",l<e&&g.classList.add("completed"),l===e&&g.classList.add("active"),a.appendChild(g);}if(o.appendChild(a),typeof n.imageUrl=="string"&&n.imageUrl&&H(n.imageUrl)){let l=i.createElement("img");l.className="veo-guide-image",l.src=n.imageUrl,l.alt=typeof n.title=="string"?n.title:"",o.appendChild(l);}if(typeof n.title=="string"&&n.title){let l=i.createElement("h2");l.className="veo-guide-title",l.textContent=n.title,o.appendChild(l);}if(typeof n.content=="string"&&n.content){let l=i.createElement("p");l.className="veo-guide-text",l.textContent=n.content,o.appendChild(l);}let c=i.createElement("div");c.className="veo-walkthrough-actions";let u=i.createElement("button");u.type="button",u.className="veo-walkthrough-skip",u.textContent="Omitir",u.addEventListener("click",()=>r.onSkip()),c.appendChild(u);let d=i.createElement("div");if(d.className="veo-walkthrough-actions-right",e>0){let l=i.createElement("button");l.type="button",l.className="veo-walkthrough-btn-secondary",l.textContent="Atr\xE1s",l.addEventListener("click",()=>r.onBack()),d.appendChild(l);}let f=e===t-1,p=i.createElement("button");p.type="button",p.className="veo-guide-cta";let h=f?"Finalizar":"Siguiente";return p.textContent=typeof n.ctaText=="string"&&n.ctaText?n.ctaText:h,p.addEventListener("click",()=>{f?r.onComplete():r.onNext();}),d.appendChild(p),c.appendChild(d),o.appendChild(c),o}var Ge=class extends S{async render(e){let t=e.guide.guideSteps[e.currentStepIndex];if(!t)return false;let i=t.selector??e.guide.activationRules.selector;if(typeof i!="string"||i.length===0)return false;let r=await te(i,5e3);if(!r)return false;let{root:o}=this.createHost(),s=o.ownerDocument??document,a=s.createElement("div");a.className="veo-walkthrough";let c=pn(t,e.currentStepIndex,e.guide.guideSteps.length,s,e.callbacks);a.appendChild(c),o.appendChild(a);let u=async()=>{let{x:f,y:p}=await ee(r,a,{placement:"bottom",middleware:[Q(8),Z(),J({padding:8})]});a.style.left=`${f}px`,a.style.top=`${p}px`;};await u();let d=()=>{u();};return window.addEventListener("scroll",d,true),window.addEventListener("resize",d),this.registerCleanup(()=>{window.removeEventListener("scroll",d,true),window.removeEventListener("resize",d);}),true}};var He=class{constructor(e){this.state=null;this.storageKey=`${Lt}${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 i=Date.now();return this.state={guideId:e,totalSteps:t,currentStepIndex:0,startedAt:i,lastProgressAt:i},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 i=t;return typeof i.guideId!="string"||typeof i.totalSteps!="number"||typeof i.currentStepIndex!="number"||typeof i.startedAt!="number"||typeof i.lastProgressAt!="number"?null:i}catch{return null}}persist(){if(!(typeof localStorage>"u"||!this.state))try{localStorage.setItem(this.storageKey,JSON.stringify(this.state));}catch{}}};var ci={shown:"shown",dismissed:"dismissed",cta_clicked:null,step_advanced:null,step_back:null,completed:"completed"},Ve=class{constructor(e,t){this.client=e;this.activeRenderers=new Set;this.dispatched=new Set;this.activeWalkthroughRenderer=null;this.activeWalkthroughGuide=null;if(this.debug=t.debug===true,this.resolver=t.resolver??new Ie(t.apiUrl,t.apiKey,this.debug),t.trackerQueue)this.trackerQueue=t.trackerQueue;else {let r=new Re(t.apiUrl,t.apiKey);this.trackerQueue=new Te({client:r,flushIntervalMs:3e3,batchSize:5,maxRetries:3,onError:(o,s)=>{this.debug&&console.warn(`[veo] dropped guide interaction after retries: guideId=${s.guideId} action=${s.payload.action}`,o);}});}let i=Mt(t.apiKey);this.frequencyCache=t.frequencyCache??new Ae(i),this.walkthroughState=t.walkthroughState??new He(i);}get pendingInteractions(){return this.trackerQueue.size}clearFrequencyCache(){this.frequencyCache.clear();}clearWalkthroughState(){this.tearDownWalkthrough();}async checkGuides(e,t){let i=this.client.getEndUserId();if(!i){this.debug&&console.log("[veo] guides: skipped, no endUserId yet");return}if(await this.tryResumeWalkthrough(i,t,e))return;let r;try{r=await this.resolver.resolve(i,e);}catch(o){this.debug&&console.error("[veo] guides resolver threw:",o);return}this.debug&&console.log(`[veo] guides: ${r.length} eligible at ${e}`);for(let o of r){if(this.frequencyCache.shouldFilter(o.guideId,o.displayFrequency)){this.debug&&console.log(`[veo] guides: filtered locally guideId=${o.guideId}`);continue}if(o.guideType==="walkthrough"&&o.guideSteps.length>1){if(this.walkthroughState.hasActive()){this.debug&&console.log(`[veo] guides: walkthrough ${o.guideId} skipped (another active)`);continue}await this.startWalkthrough(o,i,t,e);continue}this.runSingleStepRender(o,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.activeWalkthroughRenderer){try{this.activeWalkthroughRenderer.destroy();}catch{}this.activeWalkthroughRenderer=null,this.activeWalkthroughGuide=null;}this.dispatched.clear(),this.trackerQueue.destroy();}runSingleStepRender(e,t,i){let r=this.createSingleStepRenderer(e.guideType);if(!r)return;let o=e.activationRules.delayMs??0;window.setTimeout(()=>this.mountSingleStepRenderer(e,r,t,i),o);}mountSingleStepRenderer(e,t,i,r){this.activeRenderers.add(t);let o=()=>{t.destroy(),this.activeRenderers.delete(t);},s=c=>{this.handleInteraction(e,i,r,c);},a=(c,u)=>{this.client.track(c,u);};try{t.render({guide:e,onInteraction:s,onClose:o,onTrack:a});}catch(c){this.debug&&console.error("[veo] renderer.render threw:",c),this.activeRenderers.delete(t);}}async tryResumeWalkthrough(e,t,i){let r=this.walkthroughState.current();if(!r)return false;let o=await this.resolver.fetchById(r.guideId);if(!o||o.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,o.guideSteps.length-1);return await this.renderWalkthroughStep(o,s,e,t,i),true}async startWalkthrough(e,t,i,r){this.walkthroughState.start(e.guideId,e.guideSteps.length),await this.renderWalkthroughStep(e,0,t,i,r)&&(this.enqueueInteractionOnce(e.guideId,t,i,r,"shown",0),this.frequencyCache.record(e.guideId,"shown"));}async renderWalkthroughStep(e,t,i,r,o){this.activeWalkthroughRenderer&&(this.activeWalkthroughRenderer.destroy(),this.activeWalkthroughRenderer=null);let s=new Ge;this.activeWalkthroughGuide=e;let a={onNext:()=>this.handleWalkthroughNext(i,r,o),onBack:()=>this.handleWalkthroughBack(i,r,o),onSkip:()=>this.handleWalkthroughSkip(i,r,o),onComplete:()=>this.handleWalkthroughComplete(i,r,o)},c=false;try{c=await s.render({guide:e,currentStepIndex:t,callbacks:a});}catch(u){this.debug&&console.error("[veo] walkthrough renderer threw:",u);}return c?(this.activeWalkthroughRenderer=s,true):(this.debug&&console.warn(`[veo] walkthrough ${e.guideId} step ${t} could not render, cancelling`),this.tearDownWalkthrough(),false)}handleWalkthroughNext(e,t,i){let r=this.activeWalkthroughGuide;if(!r)return;let o=this.walkthroughState.advance();if(!o){this.handleWalkthroughComplete(e,t,i);return}this.enqueueInteraction(r.guideId,e,t,i,"step_advanced",o.currentStepIndex),this.renderWalkthroughStep(r,o.currentStepIndex,e,t,i);}handleWalkthroughBack(e,t,i){let r=this.activeWalkthroughGuide;if(!r)return;let o=this.walkthroughState.current();if(!o||o.currentStepIndex===0)return;let s=this.walkthroughState.back();s&&(this.enqueueInteraction(r.guideId,e,t,i,"step_back",s.currentStepIndex),this.renderWalkthroughStep(r,s.currentStepIndex,e,t,i));}handleWalkthroughSkip(e,t,i){let r=this.activeWalkthroughGuide,o=this.walkthroughState.current();!r||!o||(this.enqueueInteraction(r.guideId,e,t,i,"dismissed",o.currentStepIndex),this.frequencyCache.record(r.guideId,"dismissed"),this.tearDownWalkthrough());}handleWalkthroughComplete(e,t,i){let r=this.activeWalkthroughGuide,o=this.walkthroughState.current();!r||!o||(this.enqueueInteraction(r.guideId,e,t,i,"completed",o.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,i,r){let o=`${e.guideId}:${r.action}`;if(this.dispatched.has(o)){this.debug&&console.log(`[veo] guides: dedup hit ${o}`);return}this.dispatched.add(o);let s=ci[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:i,pagePath:gn(i)}});}enqueueInteraction(e,t,i,r,o,s){this.trackerQueue.enqueue({guideId:e,payload:{endUserId:t,sessionId:i,action:o,stepIndex:s,pageUrl:r,pagePath:gn(r)}});}enqueueInteractionOnce(e,t,i,r,o,s){let a=`${e}:${o}:${s}`;this.dispatched.has(a)||(this.dispatched.add(a),this.enqueueInteraction(e,t,i,r,o,s));}createSingleStepRenderer(e){switch(e){case "modal":return new We;case "banner":return new _e;case "tooltip":return new Fe;case "custom":return new $e;case "walkthrough":return null}}};function gn(n){try{return new URL(n).pathname}catch{return "/"}}function at(n){return {name:"guides",install(e){if(!D())return;let t=new Ve(e,n);window.__veoGuides={controller:t},e.on("identify",({sessionId:i})=>{t.checkGuides(window.location.href,i);}),e.on("pageview",({url:i,sessionId:r})=>{t.checkGuides(i,r);});}}}function ct(){return {name:"spa-router",install(n){if(!D())return;n.pageview();let e=()=>{queueMicrotask(()=>n.pageview());},t=window.history.pushState,i=window.history.replaceState;window.history.pushState=function(...r){t.apply(this,r),e();},window.history.replaceState=function(...r){i.apply(this,r),e();},window.addEventListener("popstate",e),window.addEventListener("hashchange",e);}}}function bo(n){let e=new re(n);if(e.use(ct()),n.autocapture!==false){let t=typeof n.autocapture=="object"?n.autocapture:{};e.use(et(t));}if(n.guides===true&&e.use(at({apiUrl:n.apiUrl,apiKey:n.apiKey,...n.debug!==void 0?{debug:n.debug}:{}})),typeof window<"u"){let i=window.veo?._q??[];window.veo=e;for(let r of i){let[o,s]=r;if(o==="init")continue;let a=e[o];if(typeof a=="function")try{a.apply(e,Array.from(s));}catch(c){n.debug&&console.error("[veo] drain error:",c);}}}return e}exports.Client=re;exports.SDK_VERSION=qe;exports.autocapturePlugin=et;exports.definePlugin=bn;exports.guidesPlugin=at;exports.init=bo;exports.spaRouterPlugin=ct;return exports;})({});//# sourceMappingURL=veo.js.map
|
|
170
|
+
//# sourceMappingURL=veo.js.map
|