1import{b as S,d as f,f as a}from"./chunk-ZDLMJVT4.js";var b=()=>crypto?.randomUUID()?.replace(/-/g,""),l="search_event",O=()=>{let d={session:b(),anonymous:b()};if(typeof globalThis.window>"u")return d;try{let y=globalThis.sessionStorage.getItem(l),s=y?JSON.parse(y):{},i=typeof s.session=="string"&&s.session.length>0?s.session:d.session,r=typeof s.anonymous=="string"&&s.anonymous.length>0?s.anonymous:d.anonymous;return globalThis.sessionStorage.setItem(l,JSON.stringify({...s,session:i,anonymous:r})),{session:i,anonymous:r}}catch{return globalThis.sessionStorage.setItem(l,JSON.stringify(d)),d}};function P({accountName:d="osklenusa"}){let y=O(),s=f(y.session),i=f(y.anonymous),r=navigator.userAgent,p=`https://sp.vtex.com/event-api/v1/${d}/event`,o=a(async e=>{try{let n=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){let t=await n.text();return console.error("VTEX event error:",t),!1}return!0}catch(n){return console.error("VTEX event fetch error:",n),!1}},[p]),m=a(e=>{let n={session:s.current,anonymous:i.current,url:e,agent:r,type:"session.ping"};return o(n)},[o,r]),v=a((e,n)=>{m(e);let t=setInterval(()=>{m(e)},n*60*1e3);return()=>clearInterval(t)},[m]),I=a((e,n)=>{let t={session:s.current,anonymous:i.current,products:e,order:n,type:"page.confirmation"};return o(t)},[o]),E=a(({productId:e,position:n,url:t,text:c})=>{let u={type:"search.click",productId:e,position:n,url:t,text:c,agent:r,anonymous:i.current,session:s.current};return o(u)},[o,r]),k=a(({productId:e,position:n,url:t,text:c})=>{let u={type:"search.autocomplete.click",productId:e,position:n,url:t,text:c,agent:r,anonymous:i.current,session:s.current};return o(u)},[o,r]),C=a(({url:e,text:n,misspelled:t,match:c,operator:u})=>{let g={session:s.current,anonymous:i.current,url:e,agent:r,type:"search.query",text:n};return t!==void 0&&(g.misspelled=t),c!==void 0&&(g.match=c),u!==void 0&&(g.operator=u),o(g)},[o,r]),A=a(({url:e,text:n,misspelled:t,match:c,operator:u})=>{let g={session:s.current,anonymous:i.current,url:e,agent:r,type:"search.autocomplete.query",text:n};return t!==void 0&&(g.misspelled=t),c!==void 0&&(g.match=c),u!==void 0&&(g.operator=u),o(g)},[o,r]),h=a(()=>{if(!globalThis.window.location?.href.includes("/s?q="))return;let e=JSON.parse(sessionStorage.getItem(l)??"{}");e.session||(e.session=s.current),e.anonymous||(e.anonymous=i.current),sessionStorage.setItem(l,JSON.stringify(e))},[s,i]);return S(()=>{h()},[]),{sendSessionPing:m,startSessionPingInterval:v,sendPageConfirmation:I,sendSearchClick:E,sendSearchAutocompleteClick:k,sendSearchQuery:C,sendSearchAutocompleteQuery:A,saveSessionSearchData:h}}export{P as a};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.