@sentientui/snippet 0.18.0 → 0.19.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/dist/snippet.global.js +2 -2
- package/package.json +2 -2
package/dist/snippet.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var Ue=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames,Ot=Object.getOwnPropertySymbols;var Tt=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var Lt=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Z=(e,t)=>{for(var n in t||(t={}))Tt.call(t,n)&&Lt(e,n,t[n]);if(Ot)for(var n of Ot(t))Yn.call(t,n)&&Lt(e,n,t[n]);return e};var Rt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Pt=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Xn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!Tt.call(e,o)&&o!==n&&Ue(e,o,{get:()=>t[o],enumerable:!(r=Vn(t,o))||r.enumerable});return e};var Zn=e=>Xn(Ue({},"__esModule",{value:!0}),e);var Qn,er,tr,Dt,nr,rr,Bt,L,Le,ze=Rt(()=>{"use strict";Qn=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Bt=(e,t,n)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||(t={}))nr.call(t,n)&&Bt(e,n,t[n]);if(Dt)for(var n of Dt(t))rr.call(t,n)&&Bt(e,n,t[n]);return e},Le=(e,t)=>er(e,tr(t))});var Ft={};Pt(Ft,{LOCAL_ENGINE_AVAILABLE:()=>cr,createLocalEngine:()=>ur});function ur(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var cr,Wt=Rt(()=>{"use strict";cr=!1});var bo={};Pt(bo,{applyPersonaAttributes:()=>tt,applyRegistrySlots:()=>ot,applySlotArms:()=>rt,applySlotAttributes:()=>nt,parseEditorToken:()=>zn,parsePersonaPreview:()=>Wn,parsePreview:()=>Fn,parseSnippetConfig:()=>Xe,reapply:()=>It,run:()=>Hn,version:()=>At});ze();var or=["buyer","researcher","deal_seeker","browser"];var ir={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function qe(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Mt(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function ut(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return qe(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[c,i]of Object.entries((n=e.dims)!=null?n:{}))o[c]=(r=i[0])!=null?r:"";return qe(o)}function Kt(e,t){var n,r;return e.dims!=null?(r=(n=Mt(t))!=null?n:Mt(ut(e)))!=null?r:{}:t}function ye(e){return e>=.3?e<.7?"medium":"high":"low"}var xo=or.map(e=>({key:e,displayName:ir[e]}));function Fe(e){return e?`_${e.slice(0,12)}`:""}var sr="_snt_uid";function Nt(e){return`${sr}${Fe(e)}`}var ar=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function $t(e){return lr(e)!==null}function lr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=ar.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function jt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Gt(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Ut(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function zt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function dt(e){return L(L(L({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function pt(e){let t=dt(e);return Kt(t,ut(t))}function qt(e){return typeof e=="string"?e:qe(e)}ze();function Xt(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var dr="_snt_uid",pr=365,We="_snt_uid";function fr(){return Xt()}function Ht(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function gr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function ft(e){try{return localStorage.getItem(e)}catch(t){return null}}function Vt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Jt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function mr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function hr(e){try{sessionStorage.removeItem(e)}catch(t){}}function yr(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function vr(e){try{localStorage.removeItem(e)}catch(t){}}function wr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var br={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Zt(e){var t,n,r,o,c,i,a;if(typeof window=="undefined")return br;let l=Fe(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Nt(e==null?void 0:e.apiKey),s=`${We}${l}`,d=`${We}_tomb${l}`,y=((n=e==null?void 0:e.cookieTTLDays)!=null?n:pr)*24*60*60,m=w=>w&&w.length>0?w:null,g=()=>{var w,k;return l&&!(e!=null&&e.cookieName)&&ft(d)===null?(k=(w=m(Ht(dr)))!=null?w:m(ft(We)))!=null?k:m(Jt(We)):null},p=(a=(i=(c=(o=(r=m(Ht(u)))!=null?r:m(ft(s)))!=null?o:m(Jt(s)))!=null?c:g())!=null?i:m(e==null?void 0:e.ssrSessionId))!=null?a:fr();gr(u,p,y);let A=Vt(s,p),_=yr(u),I=A?!1:mr(s,p),v=!A&&!_&&!I;return{getSessionId:()=>p,isEphemeral:()=>v,destroy:()=>{p=null,wr(u),vr(s),hr(s),l&&!(e!=null&&e.cookieName)&&Vt(d,"1")}}}function Re(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function yt(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Qt(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function xe(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let i=JSON.parse(c);return Array.isArray(i)?i:[]}catch(c){return[]}})(),o=new Map;for(let c of r)o.set(c.id,c);for(let c of e)o.set(c.id,c);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function en(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),c=r.filter(i=>!o.has(i.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var Sr=500,Ar=56*1024;function tn(e){return`_snt_retry_${e.slice(0,12)}`}var xr={push:()=>{},flush:()=>{},destroy:()=>{}};function Er(e){var t,n,r;if(typeof window=="undefined")return xr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,a=e.ingestUrl,l=e.apiKey,u=tn(l),s=[],d=new Set,y=[],m=f=>{for(let b of f)g.delete(b),!d.has(b)&&(d.add(b),y.push(b));for(;y.length>Sr;){let b=y.shift();b&&d.delete(b)}en(f,u)},g=new Set,p=()=>{for(;s.length>i;){let f=s.shift();f&&g.delete(f.id)}},A=f=>{d.has(f.id)||g.has(f.id)||(g.add(f.id),s.push(f),p())},_=f=>{for(let b of f)d.has(b.id)||(g.add(b.id),s.push(b));p()},I=Qt(u,i);for(let f of I)A(f);let v=0,w=0,k=(f,b=!0)=>{if(f.length===0)return;let C=JSON.stringify(f),W=f.map(me=>me.id),G;try{G=fetch(a,{method:"POST",keepalive:!0,body:C,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(me){xe(f,i,u),_(f),w++,v=Date.now()+Re(w);return}let _e=me=>{if(yt(me)!=="retry"){if(!me.ok&&b){let re=f.filter(oe=>oe.eventType!=="pageview");if(re.length>0&&re.length<f.length){m(f.filter(oe=>oe.eventType==="pageview").map(oe=>oe.id)),k(re,!1);return}}m(W),w=0,v=0;return}xe(f,i,u),_(f),w++,v=Date.now()+Re(w)};G instanceof Promise?G.then(_e).catch(()=>{xe(f,i,u),_(f),w++,v=Date.now()+Re(w)}):_e(G)},N=typeof TextEncoder!="undefined"?new TextEncoder:null,E=f=>N?N.encode(f).length:f.length,P=f=>{let b=[],C=2;for(let W of f){let G=E(JSON.stringify(W))+1;if(b.length>0&&C+G>Ar||b.length>=c)break;b.push(W),C+=G}return b},j=()=>{try{if(Date.now()<v)return;for(;s.length>0&&!(Date.now()<v);){let f=s.filter(C=>!d.has(C.id));if(s.length=0,f.length===0)break;let b=P(f);if(b.length===0)break;b.length<f.length&&s.push(...f.slice(b.length)),k(b)}}catch(f){}},O=!0,X=null;X=setInterval(()=>{O&&j()},o);let ee=()=>{document.visibilityState==="hidden"&&j()},x=()=>{j()};return document.addEventListener("visibilitychange",ee),window.addEventListener("pagehide",x),{push(f){A(f),s.length>=c&&j()},flush:j,destroy(){O=!1,X!==null&&(clearInterval(X),X=null),document.removeEventListener("visibilitychange",ee),window.removeEventListener("pagehide",x),j()}}}var kr=200;function nn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ir={send:()=>{},flush:()=>{},destroy:()=>{}};function _r(e){var t,n,r;if(typeof window=="undefined")return Ir;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,a=nn(e.apiKey),l=[],u=new Set,s=new Set,d=[],y=0,m=0,g=!1,p=E=>{for(u.delete(E.id),s.has(E.id)||(s.add(E.id),d.push(E.id));d.length>kr;){let P=d.shift();P&&s.delete(P)}en([E.id],a)},A=E=>{xe([E],c,a),!s.has(E.id)&&!u.has(E.id)&&(u.add(E.id),l.push(E)),Date.now()>=y&&(m++,y=Date.now()+Re(m))},_=E=>{let P;try{P=fetch(e.url,{method:"POST",keepalive:!0,body:E.body,headers:e.headers})}catch(O){A(E);return}let j=O=>{var X;let ee=yt(O);if(ee==="retry"){A(E);return}ee==="dropped"&&((X=e.onDrop)==null||X.call(e,E,O.status)),p(E),m=0,y=0};P instanceof Promise?P.then(j).catch(()=>A(E)):j(P)},I=()=>{try{if(g||Date.now()<y)return;let E=0;for(;l.length>0&&E<i&&!(Date.now()<y);){let P=l.shift();u.delete(P.id),!s.has(P.id)&&(E++,_(P))}}catch(E){}},v=Qt(a,c);for(let E of v)u.has(E.id)||(u.add(E.id),l.push(E));v.length>0&&xe(v,c,a);let w=setInterval(I,o),k=()=>{document.visibilityState==="hidden"&&I()},N=()=>I();return document.addEventListener("visibilitychange",k),window.addEventListener("pagehide",N),{send(E){if(!g&&!(s.has(E.id)||u.has(E.id))){if(Date.now()<y){xe([E],c,a),u.add(E.id),l.push(E);return}_(E)}},flush:I,destroy(){clearInterval(w),document.removeEventListener("visibilitychange",k),window.removeEventListener("pagehide",N),I(),g=!0}}}var Cr=1800*1e3;function He(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Or(e=Cr,t){let n=new Map,r=`_snt_asgn${Fe(t)}_`,o=(l,u)=>`${r}${encodeURIComponent(l)}:${encodeURIComponent(u)}`,c=l=>{let u=l.slice(r.length),s=u.indexOf(":");if(s<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,s)),segment:decodeURIComponent(u.slice(s+1))}}catch(d){return null}},i=()=>{try{let l=[];for(let u=0;u<localStorage.length;u++){let s=localStorage.key(u);s!=null&&s.startsWith(r)&&l.push(s)}return l}catch(l){return[]}},a=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of i())try{let u=localStorage.getItem(l);if(!u)continue;let s=JSON.parse(u);if(a(s)){localStorage.removeItem(l);continue}let d=c(l);if(!d)continue;n.set(He(d.componentId,d.segment),s)}catch(u){}})(),{get(l,u){let s=n.get(He(l,u));return s?a(s)?(n.delete(He(l,u)),null):s:null},set(l,u,s){let d=He(l,u);n.set(d,s);try{localStorage.setItem(o(l,u),JSON.stringify(s))}catch(y){}},clear(){n.clear();for(let l of i())try{localStorage.removeItem(l)}catch(u){}}}}var Ye="_snt_snap:",Lr=["low","medium","high"];function Pe(e){try{let t=localStorage.getItem(Ye+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Lr.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function De(e,t){try{localStorage.setItem(Ye+e,JSON.stringify(t))}catch(n){}}var mt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",rn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Yt=!1,Ve=!1;function Tr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Rr(e){var t;let n=Zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Tr(),c=Promise.resolve().then(()=>(Wt(),Ft)).then(s=>{let d=s;return d.LOCAL_ENGINE_AVAILABLE?(Yt||(Yt=!0,console.info(rn)),d):(Ve||(Ve=!0,console.error(mt)),null)}).catch(()=>(Ve||(Ve=!0,console.error(mt)),null)),i=null,a={low:.15,medium:.5,high:.85},l=(()=>{var s;if(e.initialPersona)return L({},e.initialPersona);let d=Pe(e.apiKey||"local");return d?{persona:d.persona,confidence:(s=a[d.band])!=null?s:.15}:null})();function u(s){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=s.persona,d.dataset.sentientConfidence=ye(s.confidence))}return{isLocal:!0,async decide(s){var d,y,m;let g=await c;if(!g)return null;let p=g.createLocalEngine({sessionId:r,forcedPersona:o}).decide(s);return i=Le(L({},p),{layoutOrder:(y=(d=p.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?y:null,slots:L(L({},(m=i==null?void 0:i.slots)!=null?m:{}),p.slots)}),De(e.apiKey||"local",{v:1,persona:i.persona,band:ye(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(p),p},getSlotResult(s){var d,y,m;return(m=(y=i==null?void 0:i.slots[s])!=null?y:(d=e.initialSlots)==null?void 0:d[s])!=null?m:null},getPersona(){let s=i!=null?i:l;return s?{persona:s.persona,confidence:s.confidence,band:ye(s.confidence)}:null},async assign(s,d){var y;let m=await c;return!m||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(y=m.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:s,variantIds:d}]}).assignments[s])!=null?y:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Be(e,t,n,r){let o=[];{let c=!1,i=[],a=()=>{if(c)return;let l=Date.now();for(i.push(l);i.length>0&&l-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",a),o.push(()=>t.removeEventListener("click",a))}{let c=!1,i=a=>{if(c||!(a.target instanceof Node)||!t.contains(a.target)&&t!==a.target)return;c=!0;let l=typeof window!="undefined"?window.getSelection():null,u=l?l.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,a=null,l=()=>{a!==null&&(clearTimeout(a),a=null)},u=()=>{c||!i||(l(),a=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},s=()=>{l(),u()},d=m=>{for(let g of m)i=g.intersectionRatio>.3,i?u():l()},y=new IntersectionObserver(d,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",s,{passive:!0}),o.push(()=>{y.disconnect(),window.removeEventListener("scroll",s),l()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),a=()=>{if(c||document.visibilityState!=="hidden")return;let l=Date.now()-i;l<15e3&&(c=!0,e("tab_loss",{timeOnPage:l}))};document.addEventListener("visibilitychange",a),o.push(()=>document.removeEventListener("visibilitychange",a))}return()=>{for(let c of o)c()}}var on="https://api.sentient-ui.com/v1/events",Q=new Map,sn=null;function Pr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Dr=3;function gt(){return Xt()}function Je(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Br(){let e=new WeakMap,t=new Map,n=!1,r=(a,l,u)=>{let s=a.get(l);return u===null?s?!0:(a.set(l,new Set),!1):s?s.has(u)?!0:(s.add(u),!1):(a.set(l,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{if(!o)return;let a=window.event;return typeof Event=="function"&&a instanceof Event?a:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let a=!1,l=()=>{a||(a=!0,n=!1,t.clear())};if(setTimeout(l,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),l()},u.port2.postMessage(0)}};return{firedBefore(a,l){let u=c();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,a,l)}let s=r(t,a,l);return!s&&!n&&(n=!0,i()),s}}}var an=new Set;function Mr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let u=Je();!u||u===c||(c=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},a=[];for(let u of["pushState","replaceState"]){let s=r[u],d=function(...y){let m=s.apply(this,y);return i(),m};r[u]=d,a.push([u,s,d])}window.addEventListener("popstate",i);let l=Je();return l&&an.has(`${t}:${l}`)?c=l:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,s,d]of a)r[u]===d&&(r[u]=s)}}}var Te={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Kr(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function ln(e){return e.replace(/\/events\/?$/,"")}function ve(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function vt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:sn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=Q.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:c,reinit:i}=r;if(!c){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&ve())return;let a=(i!=null?i:Me)(Le(L({},o),{consent:!0}));c(a);let l=(t=Q.get(n))==null?void 0:t.dispose;Q.set(n,{config:Le(L({},o),{consent:!0}),upgrade:null,dispose:l})}function Nr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=ln((t=e.ingestUrl)!=null?t:on),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(s,d,y){if(!n)return Promise.resolve(null);let m=c.get(s);return m?Promise.resolve(m):ht(i,s,async()=>{try{let g=new URLSearchParams({componentId:s});for(let _ of d!=null?d:[])g.append("variantIds[]",_);let p=await fetch(`${r}/winner?${g.toString()}`,{headers:o});if(!p.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let A={variantId:(await p.json()).variantId,assignmentTtlMs:0};return c.set(s,A),A}catch(g){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:s=>a.track(s),goal:((s,d,y,m)=>a.goal(s,d,y,m)),componentGoal:(s,d,y)=>a.componentGoal(s,d,y),identify:s=>a.identify(s),getAssignment:(s,d)=>a.getAssignment(s,d),assign:(s,d,y,m)=>a.assign(s,d,y,m),decide:s=>a.decide(s),getSlotResult:s=>a.getSlotResult(s),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function u(s){a=s}return{proxy:l,setInner:u}}function ht(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function Me(e){var t,n,r,o,c,i,a,l,u;if(typeof window=="undefined")return Te;sn=e.apiKey||"local";let s=Q.get(e.apiKey||"local");if(s!=null&&s.dispose)try{s.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&ve(),y=e.consent===!1||d,m=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!m&&e.localMode!==!1)return Q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),y?Te:Rr(e);if(y){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Te;let{proxy:h,setInner:S}=Nr(e);return Q.set(e.apiKey,{config:e,upgrade:d?null:S}),h}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Te;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Te;let g=(t=e.ingestUrl)!=null?t:on,p=Date.now(),A=Zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),_=Or(void 0,e.apiKey),I=Er({ingestUrl:g,apiKey:e.apiKey}),v=ln(g),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},k=new Set,N=_r({url:`${v}/goals`,apiKey:e.apiKey,headers:w,onDrop:(h,S)=>{if(!e.debug){if(k.has(S))return;k.add(S)}console.warn(`[sentient] goal dropped (HTTP ${S}) \u2014 this will not be retried. `+(S===400?"The session was not found: call init() and let the session upsert complete before firing goals.":S===401||S===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),E=jt((n=navigator.userAgent)!=null?n:""),P=window.location.origin,j=Gt((r=document.referrer)!=null?r:"",P),O=(o=e.sessionSegment)!=null?o:`${E}:${j}`,X=new Map,ee=new Map,x=new Map,f=null,b=h=>{for(let S of h)x.has(S.id)||x.set(S.id,pt(S))};if(e.initialSlots)for(let[h,S]of Object.entries(e.initialSlots))x.set(h,S);let C=Pe(e.apiKey);if(C)for(let[h,S]of Object.entries(C.slots))x.has(h)||x.set(h,S);let W={low:.15,medium:.5,high:.85};if(e.initialPersona)f=L({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?f={persona:h.sentientPersona,confidence:(i=W[(c=h.sentientConfidence)!=null?c:"low"])!=null?i:.15}:C&&(f={persona:C.persona,confidence:(a=W[C.band])!=null?a:.15})}if(e.initialAssignments)for(let[h,S]of Object.entries(e.initialAssignments))_.set(h,O,{variantId:S,assignedAt:Date.now(),segment:O,confidence:1});let G=Promise.resolve(),_e=A.getSessionId();if(_e){let h=Ut((l=document.referrer)!=null?l:""),S=L(L(L({sessionId:_e,deviceClass:E,trafficSource:j,referrerDomain:h,utmParams:Kr(),timeOfDay:zt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||$t((u=navigator.userAgent)!=null?u:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),D=async()=>{for(let z=0;;z++){try{let M=await fetch(`${v}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(S),headers:w});if(M.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(M.ok||yt(M)==="dropped")return}catch(M){}if(z>=Dr){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(M=>setTimeout(M,Re(z+1)))}};try{G=D()}catch(z){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:I});let me=Br(),re=null,oe=!1,Ae={goal(h,S={},D=1,z=0){var M,B,H,V,J,he,ce;let Ce=A.getSessionId();if(!Ce)return;let Y=Pr(S)?S:{metadata:S},Oe=[h,(M=Y.externalId)!=null?M:"",(B=Y.stepIndex)!=null?B:z,(H=Y.weight)!=null?H:D].join("\0"),T=Y.value!==void 0?`${Y.value}\0${(V=Y.currency)!=null?V:""}`:null;if(me.firedBefore(Oe,T)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let ie=gt(),Ge={sessionId:Ce,name:h,metadata:(J=Y.metadata)!=null?J:{},weight:(he=Y.weight)!=null?he:D,stepIndex:(ce=Y.stepIndex)!=null?ce:z,goalId:ie,value:Y.value,currency:Y.currency,externalId:Y.externalId};e.debug&&console.log("[sentient] goal",Ge);let q={id:ie,body:JSON.stringify(Ge)};G.then(()=>N.send(q))},componentGoal(h,S,D){var z,M,B;let H=A.getSessionId();if(!H)return;let V=_.get(h,O),J=V?null:(z=x.get(h))!=null?z:null;if(!V&&J===null){e.debug&&console.warn(`[sentient] componentGoal("${h}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let he=V?V.variantId:qt(J),ce={id:gt(),sessionId:H,projectId:e.apiKey,componentId:h,variantId:he,eventType:"goal_achieved",goalType:S,payload:L({reward:(M=D==null?void 0:D.reward)!=null?M:1,goalValue:D==null?void 0:D.value,currency:D==null?void 0:D.currency},(B=D==null?void 0:D.metadata)!=null?B:{}),timestamp:Date.now(),timeInSession:Date.now()-p,path:Je()};e.debug&&console.log("[sentient] componentGoal",ce),G.then(()=>I.push(ce))},identify(h){let S=A.getSessionId();S&&G.then(()=>{fetch(`${v}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:S,userId:h,ephemeral:A.isEphemeral()}),headers:w}).catch(()=>{})})},track(h){let S=A.getSessionId();if(!S)return;let D=Le(L({path:Je()},h),{id:gt(),sessionId:S,timestamp:Date.now(),timeInSession:Date.now()-p});e.debug&&console.log("[sentient] track",D),G.then(()=>I.push(D))},getAssignment(h,S){return _.get(h,S)},async assign(h,S,D,z){let M=A.getSessionId();if(!M)return null;let B=_.get(h,O);if(B&&(S!=null&&S.length||B.content!==void 0)){let H=B.ttlMs&&B.ttlMs>0?Math.max(0,B.assignedAt+B.ttlMs-Date.now()):0;return{variantId:B.variantId,assignmentTtlMs:H,content:B.content}}return ht(X,h,async()=>{await G;try{let H={sessionId:M,componentId:h,variantIds:S};z!==void 0?H.agentDataByVariant=z:D!==void 0&&(H.agentData=D);let V=await fetch(`${v}/assign`,{method:"POST",body:JSON.stringify(H),headers:w});if(!V.ok)return null;let J=await V.json();return _.set(h,O,L({variantId:J.variantId,assignedAt:Date.now(),segment:O,confidence:1,content:J.content},J.assignmentTtlMs&&J.assignmentTtlMs>0?{ttlMs:J.assignmentTtlMs}:{})),J}catch(H){return null}})},async decide(h){var S,D;let z=A.getSessionId();if(!z)return null;let M=(S=h.slots)!=null?S:[],B={sessionId:z};h.sections&&h.sections.length>0&&(B.sections=h.sections.map(V=>({id:V}))),B.components=(D=h.components)!=null?D:[],M.length>0&&(B.slots=M.map(dt)),h.slotsFrom==="registry"&&(B.slotsFrom="registry"),h.v&&(B.v=h.v),e.persona&&(B.persona=e.persona);let H=JSON.stringify(B);return ht(ee,H,async()=>{var V,J,he,ce,Ce,Y;await G;try{let Oe=await fetch(`${v}/decide`,{method:"POST",body:H,headers:w});if(!Oe.ok)return b(M),null;let T=await Oe.json(),ie={};for(let q of M){let ue=(V=T.slots)==null?void 0:V[q.id];if(ue!==void 0){ie[q.id]=ue,x.set(q.id,ue);continue}let _t=x.get(q.id);if(_t!==void 0)ie[q.id]=_t;else{let Ct=pt(q);ie[q.id]=Ct,x.set(q.id,Ct)}}if(T.slots)for(let[q,ue]of Object.entries(T.slots))q in ie||(ie[q]=ue,x.set(q,ue));let Ge=f!=null&&f.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&Ge)?f={persona:T.persona,confidence:(J=T.confidence)!=null?J:0}:f||(f={persona:"unknown",confidence:0});for(let[q,ue]of Object.entries((he=T.assignments)!=null?he:{}))_.set(q,O,{variantId:ue,assignedAt:Date.now(),segment:O,confidence:1});return De(e.apiKey,L(L({v:1,persona:f.persona,band:ye(f.confidence),slots:Object.fromEntries(x),layoutOrder:(ce=T.layoutOrder)!=null?ce:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.palette?{palette:T.palette}:{})),L(L(L(L({layoutOrder:(Ce=T.layoutOrder)!=null?Ce:null,assignments:(Y=T.assignments)!=null?Y:{},slots:ie,persona:f.persona,confidence:f.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{}),T.palette?{palette:T.palette}:{})}catch(Oe){return b(M),null}})},getSlotResult(h){var S;return(S=x.get(h))!=null?S:null},getPersona(){return f?{persona:f.persona,confidence:f.confidence,band:ye(f.confidence)}:null},async fetchWeights(){var h;try{let S=await fetch(`${v}/weights`,{headers:w});return S.ok?(h=(await S.json()).components)!=null?h:[]:[]}catch(S){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;re==null||re(),oe=!0,I.destroy(),N.destroy(),((h=Q.get(e.apiKey))==null?void 0:h.dispose)===Ae.dispose&&Q.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;re==null||re(),oe=!0,I.destroy(),N.destroy(),A.destroy(),_.clear(),((h=Q.get(e.apiKey))==null?void 0:h.dispose)===Ae.dispose&&Q.delete(e.apiKey);try{localStorage.removeItem(Ye+e.apiKey),localStorage.removeItem(tn(e.apiKey)),localStorage.removeItem(nn(e.apiKey))}catch(S){}e.debug&&console.log("[sentient] destroyed")}};if(Q.set(e.apiKey,{config:e,upgrade:null,dispose:Ae.dispose}),re=Mr(Ae,e.apiKey,h=>{G.then(()=>{oe||an.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=Ae)}return Ae}var cn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],$r=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],jr=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function Gr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function un(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of $r)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of jr)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function dn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Gr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function pn(e){return un(dn(e)).type}ze();var Ur="section, header, footer, nav, main > div, [data-sentient-section]",zr=2e4;function qr(e){let t=Array.from(e.querySelectorAll(Ur)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function Fr(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var fn=()=>{};function gn(e,t){var n,r,o,c,i,a,l,u,s;let d=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!d||typeof IntersectionObserver=="undefined"||ve()||!t.apiKey||!t.apiKey.startsWith("pk_"))return fn;let y=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),m=qr(d);if(m.length===0)return fn;let g=new Map,p=new Map,A=new Map;for(let x of m){let f=x.getAttribute("data-sentient-type"),b=f&&cn.includes(f)?f:null,C=(c=b!=null?b:(o=t.typeOf)==null?void 0:o.call(t,x))!=null?c:pn(x),W=`nc-${C}`;g.set(x,W),p.set(W,C),b?A.set(W,"markup"):A.has(W)||A.set(W,"auto")}let _=(u=(l=(a=(i=d.defaultView)!=null?i:typeof window!="undefined"?window:void 0)==null?void 0:a.location)==null?void 0:l.pathname)!=null?u:"/";Fr(t.apiKey,y,_,[...p.entries()].map(([x,f])=>{var b;return{componentId:x,semanticType:f,source:(b=A.get(x))!=null?b:"auto"}}));let I=new Map,v=x=>{let f=I.get(x);return f||(f={ms:0,scroll:0,enterAt:null,intersecting:!1},I.set(x,f)),f},w=new IntersectionObserver(x=>{for(let f of x){let b=g.get(f.target);if(!b)continue;let C=v(b);f.isIntersecting?(C.intersecting=!0,C.enterAt=Date.now(),f.intersectionRatio>C.scroll&&(C.scroll=f.intersectionRatio)):(C.intersecting=!1,C.enterAt!=null&&(C.ms+=Date.now()-C.enterAt,C.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let x of g.keys())w.observe(x);let k=()=>{let x=Date.now();for(let[f,b]of I)if(b.enterAt!=null&&(b.ms+=x-b.enterAt,b.enterAt=null),!(b.ms<=0)){try{e.track({projectId:t.apiKey,componentId:f,eventType:"dwell",payload:{dwell_time:Math.round(b.ms),scroll_depth:Number(b.scroll.toFixed(2))}})}catch(C){}b.ms=0}},N=()=>{if(d.hidden)k();else{let x=Date.now();for(let f of I.values())f.intersecting&&(f.enterAt=x)}},E=!1,P=x=>{if(k(),x!=null&&x.persisted){E=!0;return}try{w.disconnect()}catch(f){}},j=x=>{if(!(x!=null&&x.persisted)||!E)return;E=!1;let f=Date.now();for(let b of I.values())b.enterAt=b.intersecting&&!d.hidden?f:null};d.addEventListener("visibilitychange",N);let O=(s=d.defaultView)!=null?s:typeof window!="undefined"?window:void 0;O==null||O.addEventListener("pagehide",P),O==null||O.addEventListener("pageshow",j);let X=setInterval(()=>{if(d.hidden||E)return;k();let x=Date.now();for(let f of I.values())f.intersecting&&(f.enterAt=x)},zr),ee=[];return t.microSignals&&[...g.entries()].forEach(([x,f],b)=>{ee.push(Be((C,W={})=>{try{e.track({projectId:t.apiKey,componentId:f,eventType:"micro_signal",payload:L({signalType:C},W)})}catch(G){}},x,void 0,{tabLoss:b===0}))}),()=>{k(),clearInterval(X),d.removeEventListener("visibilitychange",N),O==null||O.removeEventListener("pagehide",P),O==null||O.removeEventListener("pageshow",j);for(let x of ee)x();try{w.disconnect()}catch(x){}}}var Wr=["landing","ecommerce","saas","marketplace"];function Hr(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(c=>typeof c=="string"))return null;n[r]=o}return n}function Vr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Jr(e){try{return e()}catch(t){return}}function Xe(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=Wr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,a]of Object.entries(t.slots)){if(typeof a!="object"||a===null)continue;let l=a,u=Hr(l.dims);if(!u||l.target!==void 0&&typeof l.target!="string")continue;let s=l.arms!==void 0?Vr(l.arms):null,d={dims:u};typeof l.target=="string"&&(d.target=l.target),s&&(d.arms=s),r[i]=d}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?Jr(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),Array.isArray(t.sections)){let i=t.sections.filter(a=>typeof a=="string"&&a.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function Ze(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Yr(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").trim().toLowerCase(),o=t.text.trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function mn(e,t){return!!(e!=null&&e.urlMatch)&&!Ze(t).includes(e.urlMatch)}var Xr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function de(e,t){var o;if(e.urlMatch&&!Ze(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&Xr.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Yr(r,e.fingerprint)?null:r}var hn={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Zr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function yn(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Zr.test((r=n[1])!=null?r:""))return!1;return!0}var vn=/^https:\/\//i,wn=new Map,pe=null;function Qr(e){return e.replace(/["\\]/g,"\\$&")}function eo(e){var t;(!pe||!pe.isConnected)&&(pe=e.querySelector("style[data-sentient-ops]"),pe||(pe=e.createElement("style"),pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(pe))),pe.textContent=[...wn.entries()].map(([n,r])=>`[data-snt-e="${Qr(n)}"]{${r}}`).join(`
|
|
2
|
-
`)}function bn(e,t,n,r){var a;let o=!1,c=(a=t.moveBefore)!=null?a:t.moveAfter;if(c){let l=de(c,r);!l||l===e||l.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&vn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&vn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[l,u]of Object.entries(t.style)){let s=hn[l];s&&typeof u=="string"&&yn(u)&&i.push(`${s}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),wn.set(n,i.join(";")),eo(r)),{anchorMiss:o}}var Ke="data-sentient-block-arm",te=null;function Ne(e){te=e!=null?e:null}var ae="data-sentient-blocks-hid",Qe={none:"0",sm:"8px",md:"16px",lg:"24px"},wt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Sn={sm:"0.875em",md:"1em",lg:"1.25em"},to={sm:"1.25em",md:"1.5em",lg:"2em"},no={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},An={sm:"8px",md:"16px",lg:"32px"},ro={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},oo={normal:"400",medium:"500",bold:"700"};function se(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function xn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function En(e,t){var n,r,o,c,i,a,l,u,s,d,y,m;try{switch(e.type){case"stack":case"grid":{let g=t.createElement("div");if(e.type==="stack"){let p=e;se(g,{display:"flex","flex-direction":p.direction,gap:(r=Qe[(n=p.gap)!=null?n:"md"])!=null?r:Qe.md,"align-items":p.align?wt[p.align]:void 0,"justify-content":p.justify?wt[p.justify]:void 0,"flex-wrap":p.wrap?"wrap":void 0})}else{let p=e,A=(c=Qe[(o=p.gap)!=null?o:"md"])!=null?c:Qe.md;se(g,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${p.columns-1} * ${A}) / ${p.columns})), 1fr))`,gap:A,"align-items":p.align?wt[p.align]:void 0})}for(let p of(i=e.children)!=null?i:[]){let A=En(p,t);A&&g.appendChild(A)}return g}case"text":{let g=t.createElement("p");return g.textContent=e.value,se(g,Z({margin:"0","font-size":e.size?Sn[e.size]:void 0,"font-weight":e.weight?oo[e.weight]:void 0,"text-align":e.align},xn(e.tone)))}case"heading":{let g=t.createElement(`h${e.level}`);return g.textContent=e.value,se(g,{margin:"0","font-size":to[(a=e.size)!=null?a:"md"],"text-align":e.align})}case"button":{let g=t.createElement("a");g.textContent=e.label,g.href=e.href,e.tag&&g.setAttribute("data-sentient-tag",e.tag);let p=(l=e.emphasis)!=null?l:"primary";return se(g,{display:"inline-block",padding:no[(u=e.size)!=null?u:"md"],"border-radius":(s=te==null?void 0:te.radius)!=null?s:"8px",font:"inherit","font-size":e.size?Sn[e.size]:void 0,"text-decoration":p==="ghost"?"underline":"none",cursor:"pointer",background:p==="primary"?(d=te==null?void 0:te.primaryBg)!=null?d:"#111827":"transparent",color:p==="primary"?(y=te==null?void 0:te.primaryText)!=null?y:"#ffffff":"inherit",border:p==="secondary"?"1px solid currentColor":"none"})}case"link":{let g=t.createElement("a");return g.textContent=e.label,g.href=e.href,e.tag&&g.setAttribute("data-sentient-tag",e.tag),se(g,{color:"inherit","text-decoration":"underline"})}case"image":{let g=t.createElement("img");return g.src=e.src,g.alt=e.alt,se(g,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?ro[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let g=t.createElement("span");return g.textContent=e.value,se(g,Z({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},xn(e.tone)))}case"spacer":return se(t.createElement("div"),{height:(m=An[e.size])!=null?m:An.md});default:return null}}catch(g){return null}}function kn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let a=i.getAttribute(Ke);a!==null&&(t[a]===void 0?i.remove():o.add(a))}for(let[i,a]of Object.entries(t)){if(o.has(i))continue;let l=En(a,r);if(!l)continue;let u=r.createElement("div");u.setAttribute(Ke,i),u.style.display="none",u.appendChild(l),e.appendChild(u)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let a=i.getAttribute(Ke),l=i;a!==null?l.style.display=c&&a===n?"":"none":c?l.hasAttribute(ae)||(l.setAttribute(ae,l.style.display),l.style.display="none"):l.hasAttribute(ae)&&(l.style.display=l.getAttribute(ae),l.removeAttribute(ae))}}catch(o){}}function io(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ke)!==null){n.remove();continue}n.hasAttribute(ae)&&(n.style.display=n.getAttribute(ae),n.removeAttribute(ae))}}catch(t){}}function et(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ke}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ae}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||io(r)}catch(n){}}function bt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function tt(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function nt(e,t,n){var r;for(let[o,c]of Object.entries(t)){let i=e[o];if(!i||typeof i=="string")continue;let a=bt(c.target,n);for(let l of a)for(let[u,s]of Object.entries(i))(r=c.dims[u])!=null&&r.includes(s)&&l.setAttribute(`data-${u}`,s)}}function rt(e,t,n){for(let[r,o]of Object.entries(t)){let c=e[r];if(typeof c!="string"||!o.arms||!o.arms.includes(c))continue;let i=bt(o.target,n);for(let a of i)a.setAttribute("data-sentient-arm",c)}}function ot(e,t,n,r){var a,l;let o=new Set,c=(a=r==null?void 0:r.contentAndOps)!=null?a:!0,i=[];for(let[u,s]of Object.entries(t)){if(mn(s.locator,n))continue;let d;if(s.locator){let m=de(s.locator,n);d=m?[m]:[]}else d=bt(s.target,n);(s.locator||s.target)&&d.length===0&&i.push(u);let y=e[u];for(let m of d){if(y!==void 0)if(typeof y=="string")m.setAttribute("data-sentient-arm",y),c&&((l=r==null?void 0:r.onApplied)==null||l.call(r,u,y,m));else for(let[g,p]of Object.entries(y))m.setAttribute(`data-${g}`,p);s.blocks&&!ao(n)&&(kn(m,s.blocks,typeof y=="string"?y:void 0,n),o.add(m)),c&&(typeof s.content=="string"&&(m.textContent=s.content),s.ops&&bn(m,s.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u))}}return et(n,o),i}var so=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function ao(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:so.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var lo=800;function it(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},a)=>{r.push(Be((y,m={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:Z({signalType:y},m)})}catch(g){}},i,void 0,{tabLoss:a===0}));let l=null,u=0,s=()=>{u=Date.now(),l=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(y){}l=null},lo)},d=()=>{l!==null&&(clearTimeout(l),l=null)};i.addEventListener("mouseenter",s),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",s),i.removeEventListener("mouseleave",d),l!==null&&clearTimeout(l)})}),()=>{for(let o of r)o()}}function co(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function _n(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var uo="_snt_fired_goals";function Cn(e,t){try{e==null||e.sessionStorage.removeItem(_n(t)),e==null||e.sessionStorage.removeItem(uo)}catch(n){}}function In(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function po(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function fo(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function st(e,t,n,r){var _,I;let o=(_=n.defaultView)!=null?_:typeof window!="undefined"?window:null,c=_n(r),i=po(o,c),a=v=>{let w=In(v);if(!i.has(w))try{v.slotId?t.componentGoal(v.slotId,v.goalId):t.goal(v.goalId),i.add(w),fo(o,c,i)}catch(k){}},l=e.filter(v=>v.event==="click"),u=e.filter(v=>v.event==="form_submit"),s=e.filter(v=>v.event==="url_reached"),d=e.filter(v=>v.event==="scroll_depth"),y=(v,w)=>{if(!v.locator)return!1;let k=de(v.locator,n);return!!k&&(k===w||k.contains(w))},m=v=>{let w=v.target;if(!(!w||typeof w.closest!="function"))for(let k of l)y(k,w)&&a(k)},g=v=>{let w=v.target;if(w)for(let k of u)y(k,w)&&a(k)},p=()=>{if(s.length===0)return;let v=Ze(n);for(let w of s)w.urlPattern&&co(w.urlPattern,v)&&a(w)},A=()=>{var k;let v=n.documentElement,w=v.scrollHeight>0?(v.scrollTop+v.clientHeight)/v.scrollHeight:0;for(let N of d)w>=((k=N.threshold)!=null?k:.75)&&a(N);d.every(N=>i.has(In(N)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",m,!0),n.addEventListener("submit",g,!0),(I=n.defaultView)==null||I.addEventListener("popstate",p),p(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:p,teardown:()=>{var v;n.removeEventListener("click",m,!0),n.removeEventListener("submit",g,!0),(v=n.defaultView)==null||v.removeEventListener("popstate",p),d.length>0&&n.removeEventListener("scroll",A)}}}var On="__snt_editor_token";function Ln(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(On):null}catch(e){return null}}function Tn(e){try{sessionStorage.setItem(On,e)}catch(t){}}var At="0.18.0",$n=5e3,go=50,jn=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),F=null,R=null,le={},ge=null,$=null,fe=null,U=null,ne=null,K=null,we=null,Rn=!1,St=null,at=null,ct=null,Ee=!1,$e=!1,Se=!1;function Gn(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function be(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function ke(e,t){return F?(F.personaAttributes&&K&&tt(K.persona,K.band,e),nt(le,F.slots,e),rt(le,F.slots,e),ge?ot(le,ge,e,t):(et(e,new Set),[])):[]}function Un(e){var n;let t=new Map;for(let r of(n=F==null?void 0:F.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function xt(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Un(t);if(n.size!==e.length)return;let r=[];for(let i of e){let a=n.get(i);if(!a)return;r.push(a)}let o=r[0].parentNode;if(!o||!r.every(i=>i.parentNode===o))return;let c=r.slice().sort((i,a)=>i.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let i=0;i<r.length;i++){let a=r[i];c[i]!==a&&(o.insertBefore(a,c[i]),c.splice(c.indexOf(a),1),c.splice(i,0,a))}}catch(n){}}function mo(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ie(){return!!(F&&R&&F.sectionCapture!==!1&&(F.consent!==!1||$e)&&!ve())}function ho(){if(!R||!F||!Ie()||ne)return;let e=[];ke(document,{contentAndOps:Ee,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),kt();try{U==null||U(),U=it(R,F.apiKey,e)}catch(t){}}function kt(){if(typeof document=="undefined"||!Ie())return;let e;try{if(at&&at.length>0){let t=new Map;for(let n of at){if(n.urlMatch!==window.location.pathname)continue;let r=de(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ne=gn(R,Z({apiKey:F.apiKey,apiBase:F.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),ct=window.location.pathname}catch(t){}}function It(){try{let e=[];if(U==null||U(),U=null,ke(document,{contentAndOps:Ee,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),xt(we,document),e.length>0&&Ie())try{U=it(R,F.apiKey,e)}catch(t){}try{typeof window!="undefined"&&ct!==null&&window.location.pathname!==ct&&Ie()&&(ne==null||ne(),ne=null,kt())}catch(t){}}catch(e){}}function Pn(){St===null&&(St=setTimeout(()=>{St=null,It();try{$==null||$.checkUrl()}catch(e){}},go))}function Et(){if(!(Rn||typeof window=="undefined"||typeof history=="undefined")){Rn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,c){let i=n.call(this,r,o,c!=null?c:null);return Pn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Pn)}catch(e){}}}function lt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function zn(e){return new URLSearchParams(e).get("sentient_editor")}function yo(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function vo(e,t){var n,r,o,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let l=document.createElement("meta");l.name="referrer",l.content="no-referrer",l.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(l)}catch(l){}let i=(o=e.editorSrc)!=null?o:yo();if(!i){Bn();return}let a=document.createElement("script");a.src=i,a.async=!0,a.onerror=()=>Bn(),((c=document.head)!=null?c:document.documentElement).appendChild(a)}catch(i){}}var Dn="sentient-editor-load-notice",qn={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Bn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Dn))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Dn,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,qn,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function Fn(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),c=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!c||!i))if(i.includes("=")){let a={};for(let l of i.split(",")){let[u,s]=l.split("=");u&&s&&(a[u]=s)}Object.keys(a).length&&(n[c]=a)}else n[c]=i}return Object.keys(n).length?n:null}function Wn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Mn="sentient-persona-preview-banner";function Kn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Mn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Mn,o.setAttribute("role","status"),Object.assign(o.style,qn,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let c=document.createElement("span");c.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let a=new URL(window.location.href);a.searchParams.delete("sentient_persona"),window.location.href=a.pathname+a.search+a.hash}catch(a){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function wo(e,t){var u,s,d,y,m,g,p,A,_,I;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((s=e.registry)!=null?s:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([v,w])=>({id:v,dims:w.dims}))},c=await Gn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(v=>v.ok?v.json():null).catch(()=>null),$n);if(!c){je(e),be(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;le=(d=i.slots)!=null?d:{},ge=(y=i.slotConfig)!=null?y:null,Ne(i.palette);let a=(p=(g=(m=i.personaAttributes)==null?void 0:m.persona)!=null?g:i.persona)!=null?p:t,l=(_=(A=i.personaAttributes)==null?void 0:A.confidence)!=null?_:"high";K={persona:a,band:l},ke(document),Ee=!0,Et(),je(e),i.recognized===!1?Kn(t,!0):Kn((I=i.personaDisplay)!=null?I:a)}function je(e){let t={goal(n,r){try{R==null||R.goal(n,r)}catch(o){}},componentGoal(n,r){try{R==null||R.componentGoal(n,r)}catch(o){}},grantConsent(){try{!R&&Se?(R=Me({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona}),fe&&fe.length>0&&($==null||$.teardown(),$=st(fe,R,document,e.apiKey))):(vt(e.apiKey),R&&fe&&fe.length>0&&($==null||$.teardown(),$=st(fe,R,document,e.apiKey))),Se=!1}catch(n){}$e=!0;try{ho()}catch(n){}},revokeConsent(){try{ne==null||ne(),ne=null,ct=null,U==null||U(),U=null,$==null||$.teardown(),$=null,Cn(typeof window!="undefined"?window:null,e.apiKey),$e=!1,Se=!0,R==null||R.destroy(),R=null}catch(n){}},reapply:It,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=K==null?void 0:K.persona)!=null?n:null,band:(r=K==null?void 0:K.band)!=null?r:null,slots:le,matchCounts:lt(e),consent:!Se&&(e.consent!==!1||$e)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of jn.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Nn(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},jn.length=0}catch(t){}}async function Hn(){var e;try{let t=Xe(window.sentient);if(!t){Nn();return}F=t,Ee=!1,we=null,Ne(null),$e=!1,Se=!1,fe=null;let n=typeof window!="undefined"?zn(window.location.search):null;if(n){Tn(n);try{let p=new URL(window.location.href);p.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",p.pathname+p.search+p.hash)}catch(p){}}let r=n!=null?n:Ln();if(r){vo(t,r),je(t),be(t,"editor mode");return}let o=typeof window!="undefined"?Fn(window.location.search):null;if(o){le=o,K=null,ke(document),Et(),je(t),be(t,"preview mode",o);return}let c=typeof window!="undefined"?Wn(window.location.search):null;if(c){await wo(t,c),be(t,"persona preview",c);return}let i=(e=t.registry)!=null?e:Object.keys(t.slots).length===0,a=Pe(t.apiKey);a&&(K={persona:a.persona,band:a.band},le=a.slots,a.slotConfig&&(ge=a.slotConfig),a.palette&&Ne(a.palette),ke(document,{contentAndOps:!1}),a.layoutOrder&&(we=a.layoutOrder,xt(we,document)));let l=Me({apiKey:t.apiKey,context:t.context,consent:t.consent,preConsentBehavior:t.preConsentBehavior,debug:t.debug,persona:t.persona});R=l,je(t),Et();let u=Object.entries(t.slots).map(([p,A])=>({id:p,dims:A.dims})),s=At!=="0.0.0-dev"?{v:At}:{},d=Array.from(Un(document).keys()),y=l.decide(Z(Z(Z({slots:u},s),d.length>=2?{sections:d}:{}),i?{slotsFrom:"registry"}:{})),m=await Gn(y,$n),g=p=>{var I,v,w,k,N,E;let A=l.getPersona();A?K={persona:A.persona,band:A.band}:p.persona&&(K={persona:p.persona,band:"low"}),le=p.slots,i?ge=(I=p.slotConfig)!=null?I:null:p.slotConfig&&(ge=p.slotConfig),p.palette&&Ne(p.palette),we=(v=p.layoutOrder)!=null?v:we;let _=()=>{let P=[];if(mo(t,ke(document,{onApplied:(j,O,X)=>P.push({slotId:j,arm:O,el:X})})),xt(we,document),Ee=!0,Ie())try{U==null||U(),U=it(R,t.apiKey,P)}catch(j){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_,{once:!0}):_(),fe=(w=p.goals)!=null?w:null,p.goals&&p.goals.length>0&&t.consent!==!1&&R)try{$==null||$.teardown(),$=st(p.goals,R,document,t.apiKey)}catch(P){}at=(k=p.sectionMap)!=null?k:null,Ie()&&kt(),be(t,"applied",{persona:K,slots:le,matches:lt(t)}),!Se&&De(t.apiKey,Z(Z({v:1,persona:(N=K==null?void 0:K.persona)!=null?N:p.persona,band:(E=K==null?void 0:K.band)!=null?E:"low",slots:p.slots,layoutOrder:p.layoutOrder,savedAt:Date.now()},ge?{slotConfig:ge}:{}),p.palette?{palette:p.palette}:{}))};if(!m){be(t,"decide timeout/null \u2014 snapshot state stands",lt(t)),y.then(p=>{!p||Ee||Se||R!==l||(g(p),be(t,"late decide applied",lt(t)))}).catch(()=>{});return}g(m)}catch(t){Nn()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Hn())}return Zn(bo);})();
|
|
1
|
+
"use strict";var SentientSnippet=(()=>{var qe=Object.defineProperty;var nr=Object.getOwnPropertyDescriptor;var rr=Object.getOwnPropertyNames,Rt=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,or=Object.prototype.propertyIsEnumerable;var Pt=(e,t,n)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ne=(e,t)=>{for(var n in t||(t={}))Dt.call(t,n)&&Pt(e,n,t[n]);if(Rt)for(var n of Rt(t))or.call(t,n)&&Pt(e,n,t[n]);return e};var Mt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Bt=(e,t)=>{for(var n in t)qe(e,n,{get:t[n],enumerable:!0})},ir=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rr(t))!Dt.call(e,o)&&o!==n&&qe(e,o,{get:()=>t[o],enumerable:!(r=nr(t,o))||r.enumerable});return e};var sr=e=>ir(qe({},"__esModule",{value:!0}),e);var ar,lr,cr,Nt,ur,dr,$t,_,be,Te=Mt(()=>{"use strict";ar=Object.defineProperty,lr=Object.defineProperties,cr=Object.getOwnPropertyDescriptors,Nt=Object.getOwnPropertySymbols,ur=Object.prototype.hasOwnProperty,dr=Object.prototype.propertyIsEnumerable,$t=(e,t,n)=>t in e?ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t)=>{for(var n in t||(t={}))ur.call(t,n)&&$t(e,n,t[n]);if(Nt)for(var n of Nt(t))dr.call(t,n)&&$t(e,n,t[n]);return e},be=(e,t)=>lr(e,cr(t))});var Yt={};Bt(Yt,{LOCAL_ENGINE_AVAILABLE:()=>vr,createLocalEngine:()=>br});function br(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var vr,Xt=Mt(()=>{"use strict";vr=!1});var Po={};Bt(Po,{applyPersonaAttributes:()=>nt,applyRegistrySlots:()=>it,applySlotArms:()=>ot,applySlotAttributes:()=>rt,parseEditorToken:()=>Xn,parsePersonaPreview:()=>er,parsePreview:()=>Qn,parseSnippetConfig:()=>Ze,reapply:()=>Ot,run:()=>tr,version:()=>Et});Te();var fr=["buyer","researcher","deal_seeker","browser"];var pr={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Fe(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Kt(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function dt(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return Fe(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[l,i]of Object.entries((n=e.dims)!=null?n:{}))o[l]=(r=i[0])!=null?r:"";return Fe(o)}function jt(e,t){var n,r;return e.dims!=null?(r=(n=Kt(t))!=null?n:Kt(dt(e)))!=null?r:{}:t}function Gt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t}function we(e){return e>=.3?e<.7?"medium":"high":"low"}var Bo=fr.map(e=>({key:e,displayName:pr[e]}));function We(e){return e?`_${e.slice(0,12)}`:""}var gr="_snt_uid";function Ut(e){return`${gr}${We(e)}`}var mr=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function zt(e){return hr(e)!==null}function hr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=mr.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function qt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Ft(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Wt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var yr=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function Ht(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,l])=>{let i=Array.isArray(l)?l[0]:l;return i===void 0?[]:[[o,i]]});for(let[o,l]of r)o.startsWith("utm_")?o in t||(t[o]=l):yr.includes(o)&&(o in n||(n[o]=l))}catch(r){}return{utmParams:t,clickIds:n}}function Jt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function ft(e){return _(_(_({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function pt(e){let t=ft(e);return jt(t,dt(t))}function Vt(e){return typeof e=="string"?e:Fe(e)}Te();function nn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var wr="_snt_uid",Sr=365,He="_snt_uid";function Ar(){return nn()}function Zt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function xr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function gt(e){try{return localStorage.getItem(e)}catch(t){return null}}function Qt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function en(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function kr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Er(e){try{sessionStorage.removeItem(e)}catch(t){}}function Cr(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function _r(e){try{localStorage.removeItem(e)}catch(t){}}function Ir(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Or={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function rn(e){var t,n,r,o,l,i,s;if(typeof window=="undefined")return Or;let c=We(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Ut(e==null?void 0:e.apiKey),a=`${He}${c}`,d=`${He}_tomb${c}`,g=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Sr)*24*60*60,m=w=>w&&w.length>0?w:null,p=()=>{var w,I;return c&&!(e!=null&&e.cookieName)&>(d)===null?(I=(w=m(Zt(wr)))!=null?w:m(gt(He)))!=null?I:m(en(He)):null},f=(s=(i=(l=(o=(r=m(Zt(u)))!=null?r:m(gt(a)))!=null?o:m(en(a)))!=null?l:p())!=null?i:m(e==null?void 0:e.ssrSessionId))!=null?s:Ar();xr(u,f,g);let A=Qt(a,f),C=Cr(u),L=A?!1:kr(a,f),y=!A&&!C&&!L;return{getSessionId:()=>f,isEphemeral:()=>y,destroy:()=>{f=null,Ir(u),_r(a),Er(a),c&&!(e!=null&&e.cookieName)&&Qt(d,"1")}}}function Pe(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function vt(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function on(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function Ee(e,t,n){try{let r=(()=>{try{let l=localStorage.getItem(n);if(!l)return[];let i=JSON.parse(l);return Array.isArray(i)?i:[]}catch(l){return[]}})(),o=new Map;for(let l of r)o.set(l.id,l);for(let l of e)o.set(l.id,l);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function sn(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),l=r.filter(i=>!o.has(i.id));if(l.length===r.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var Lr=500,Tr=56*1024;function an(e){return`_snt_retry_${e.slice(0,12)}`}var Rr={push:()=>{},flush:()=>{},destroy:()=>{}};function Pr(e){var t,n,r;if(typeof window=="undefined")return Rr;let o=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,c=e.apiKey,u=an(c),a=[],d=new Set,g=[],m=v=>{for(let b of v)p.delete(b),!d.has(b)&&(d.add(b),g.push(b));for(;g.length>Lr;){let b=g.shift();b&&d.delete(b)}sn(v,u)},p=new Set,f=()=>{for(;a.length>i;){let v=a.shift();v&&p.delete(v.id)}},A=v=>{d.has(v.id)||p.has(v.id)||(p.add(v.id),a.push(v),f())},C=v=>{for(let b of v)d.has(b.id)||(p.add(b.id),a.push(b));f()},L=on(u,i);for(let v of L)A(v);let y=0,w=0,I=(v,b=!0)=>{if(v.length===0)return;let k=JSON.stringify(v),O=v.map(J=>J.id),E;try{E=fetch(s,{method:"POST",keepalive:!0,body:k,headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`}})}catch(J){Ee(v,i,u),C(v),w++,y=Date.now()+Pe(w);return}let oe=J=>{if(vt(J)!=="retry"){if(!J.ok&&b){let ee=v.filter(te=>te.eventType!=="pageview");if(ee.length>0&&ee.length<v.length){m(v.filter(te=>te.eventType==="pageview").map(te=>te.id)),I(ee,!1);return}}m(O),w=0,y=0;return}Ee(v,i,u),C(v),w++,y=Date.now()+Pe(w)};E instanceof Promise?E.then(oe).catch(()=>{Ee(v,i,u),C(v),w++,y=Date.now()+Pe(w)}):oe(E)},N=typeof TextEncoder!="undefined"?new TextEncoder:null,x=v=>N?N.encode(v).length:v.length,D=v=>{let b=[],k=2;for(let O of v){let E=x(JSON.stringify(O))+1;if(b.length>0&&k+E>Tr||b.length>=l)break;b.push(O),k+=E}return b},K=()=>{try{if(Date.now()<y)return;for(;a.length>0&&!(Date.now()<y);){let v=a.filter(k=>!d.has(k.id));if(a.length=0,v.length===0)break;let b=D(v);if(b.length===0)break;b.length<v.length&&a.push(...v.slice(b.length)),I(b)}}catch(v){}},j=!0,Z=null;Z=setInterval(()=>{j&&K()},o);let q=()=>{document.visibilityState==="hidden"&&K()},U=()=>{K()};return document.addEventListener("visibilitychange",q),window.addEventListener("pagehide",U),{push(v){A(v),a.length>=l&&K()},flush:K,destroy(){j=!1,Z!==null&&(clearInterval(Z),Z=null),document.removeEventListener("visibilitychange",q),window.removeEventListener("pagehide",U),K()}}}var Dr=200;function ln(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Mr={send:()=>{},flush:()=>{},destroy:()=>{}};function Br(e){var t,n,r;if(typeof window=="undefined")return Mr;let o=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=ln(e.apiKey),c=[],u=new Set,a=new Set,d=[],g=0,m=0,p=!1,f=x=>{for(u.delete(x.id),a.has(x.id)||(a.add(x.id),d.push(x.id));d.length>Dr;){let D=d.shift();D&&a.delete(D)}sn([x.id],s)},A=x=>{Ee([x],l,s),!a.has(x.id)&&!u.has(x.id)&&(u.add(x.id),c.push(x)),Date.now()>=g&&(m++,g=Date.now()+Pe(m))},C=x=>{let D;try{D=fetch(e.url,{method:"POST",keepalive:!0,body:x.body,headers:e.headers})}catch(j){A(x);return}let K=j=>{var Z;let q=vt(j);if(q==="retry"){A(x);return}q==="dropped"&&((Z=e.onDrop)==null||Z.call(e,x,j.status)),f(x),m=0,g=0};D instanceof Promise?D.then(K).catch(()=>A(x)):K(D)},L=()=>{try{if(p||Date.now()<g)return;let x=0;for(;c.length>0&&x<i&&!(Date.now()<g);){let D=c.shift();u.delete(D.id),!a.has(D.id)&&(x++,C(D))}}catch(x){}},y=on(s,l);for(let x of y)u.has(x.id)||(u.add(x.id),c.push(x));y.length>0&&Ee(y,l,s);let w=setInterval(L,o),I=()=>{document.visibilityState==="hidden"&&L()},N=()=>L();return document.addEventListener("visibilitychange",I),window.addEventListener("pagehide",N),{send(x){if(!p&&!(a.has(x.id)||u.has(x.id))){if(Date.now()<g){Ee([x],l,s),u.add(x.id),c.push(x);return}C(x)}},flush:L,destroy(){clearInterval(w),document.removeEventListener("visibilitychange",I),window.removeEventListener("pagehide",N),L(),p=!0}}}var Nr=1800*1e3;function Je(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function $r(e=Nr,t){let n=new Map,r=`_snt_asgn${We(t)}_`,o=(c,u)=>`${r}${encodeURIComponent(c)}:${encodeURIComponent(u)}`,l=c=>{let u=c.slice(r.length),a=u.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,a)),segment:decodeURIComponent(u.slice(a+1))}}catch(d){return null}},i=()=>{try{let c=[];for(let u=0;u<localStorage.length;u++){let a=localStorage.key(u);a!=null&&a.startsWith(r)&&c.push(a)}return c}catch(c){return[]}},s=c=>c.assignedAt+(c.ttlMs&&c.ttlMs>0?c.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let c of i())try{let u=localStorage.getItem(c);if(!u)continue;let a=JSON.parse(u);if(s(a)){localStorage.removeItem(c);continue}let d=l(c);if(!d)continue;n.set(Je(d.componentId,d.segment),a)}catch(u){}})(),{get(c,u){let a=n.get(Je(c,u));return a?s(a)?(n.delete(Je(c,u)),null):a:null},set(c,u,a){let d=Je(c,u);n.set(d,a);try{localStorage.setItem(o(c,u),JSON.stringify(a))}catch(g){}},clear(){n.clear();for(let c of i())try{localStorage.removeItem(c)}catch(u){}}}}var Xe="_snt_snap:",Kr=["low","medium","high"];function De(e){try{let t=localStorage.getItem(Xe+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Kr.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function Me(e,t){try{localStorage.setItem(Xe+e,JSON.stringify(t))}catch(n){}}var ht="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",cn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",tn=!1,Ve=!1;function jr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Gr(e){var t;let n=rn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=jr(),l=Promise.resolve().then(()=>(Xt(),Yt)).then(a=>{let d=a;return d.LOCAL_ENGINE_AVAILABLE?(tn||(tn=!0,console.info(cn)),d):(Ve||(Ve=!0,console.error(ht)),null)}).catch(()=>(Ve||(Ve=!0,console.error(ht)),null)),i=null,s={low:.15,medium:.5,high:.85},c=(()=>{var a;if(e.initialPersona)return _({},e.initialPersona);let d=De(e.apiKey||"local");return d?{persona:d.persona,confidence:(a=s[d.band])!=null?a:.15}:null})();function u(a){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=a.persona,d.dataset.sentientConfidence=we(a.confidence))}return{isLocal:!0,async decide(a){var d,g,m;let p=await l;if(!p)return null;let f=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide(a);return i=be(_({},f),{layoutOrder:(g=(d=f.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?g:null,slots:_(_({},(m=i==null?void 0:i.slots)!=null?m:{}),f.slots)}),Me(e.apiKey||"local",{v:1,persona:i.persona,band:we(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(f),f},getSlotResult(a){var d,g,m;return(m=(g=i==null?void 0:i.slots[a])!=null?g:(d=e.initialSlots)==null?void 0:d[a])!=null?m:null},getPersona(){let a=i!=null?i:c;return a?{persona:a.persona,confidence:a.confidence,band:we(a.confidence)}:null},async assign(a,d){var g;let m=await l;return!m||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(g=m.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:a,variantIds:d}]}).assignments[a])!=null?g:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Be(e,t,n,r){let o=[];{let l=!1,i=[],s=()=>{if(l)return;let c=Date.now();for(i.push(c);i.length>0&&c-i[0]>500;)i.shift();i.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let l=!1,i=s=>{if(l||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;l=!0;let c=typeof window!="undefined"?window.getSelection():null,u=c?c.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let l=!1,i=!1,s=null,c=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{l||!i||(c(),s=setTimeout(()=>{!l&&i&&(l=!0,e("scroll_hesitation"))},3e3))},a=()=>{c(),u()},d=m=>{for(let p of m)i=p.intersectionRatio>.3,i?u():c()},g=new IntersectionObserver(d,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",a,{passive:!0}),o.push(()=>{g.disconnect(),window.removeEventListener("scroll",a),c()})}if((r==null?void 0:r.tabLoss)!==!1){let l=!1,i=n!=null?n:Date.now(),s=()=>{if(l||document.visibilityState!=="hidden")return;let c=Date.now()-i;c<15e3&&(l=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let l of o)l()}}var un="https://api.sentient-ui.com/v1/events",re=new Map,dn=null;function Ur(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var zr=3;function mt(){return nn()}function Ye(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function qr(){let e=new WeakMap,t=new Map,n=!1,r=(s,c,u)=>{let a=s.get(c);return u===null?a?!0:(s.set(c,new Set),!1):a?a.has(u)?!0:(a.add(u),!1):(s.set(c,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,l=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,c=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(c,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),c()},u.port2.postMessage(0)}};return{firedBefore(s,c){let u=l();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,c)}let a=r(t,s,c);return!a&&!n&&(n=!0,i()),a}}}var fn=new Set;function Fr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,l,i=()=>{if(o)return;let u=Ye();!u||u===l||(l=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},s=[];for(let u of["pushState","replaceState"]){let a=r[u],d=function(...g){let m=a.apply(this,g);return i(),m};r[u]=d,s.push([u,a,d])}window.addEventListener("popstate",i);let c=Ye();return c&&fn.has(`${t}:${c}`)?l=c:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,a,d]of s)r[u]===d&&(r[u]=a)}}}var Re={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Wr(){try{return Ht(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function pn(e){return e.replace(/\/events\/?$/,"")}function Se(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function bt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:dn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=re.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:l,reinit:i}=r;if(!l){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Se())return;let s=(i!=null?i:Ne)(be(_({},o),{consent:!0}));l(s);let c=(t=re.get(n))==null?void 0:t.dispose;re.set(n,{config:be(_({},o),{consent:!0}),upgrade:null,dispose:c})}function Hr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=pn((t=e.ingestUrl)!=null?t:un),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},l=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(a,d,g){if(!n)return Promise.resolve(null);let m=l.get(a);return m?Promise.resolve(m):yt(i,a,async()=>{try{let p=new URLSearchParams({componentId:a});for(let C of d!=null?d:[])p.append("variantIds[]",C);let f=await fetch(`${r}/winner?${p.toString()}`,{headers:o});if(!f.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let A={variantId:(await f.json()).variantId,assignmentTtlMs:0};return l.set(a,A),A}catch(p){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},c={track:a=>s.track(a),goal:((a,d,g,m)=>s.goal(a,d,g,m)),componentGoal:(a,d,g)=>s.componentGoal(a,d,g),identify:a=>s.identify(a),getAssignment:(a,d)=>s.getAssignment(a,d),assign:(a,d,g,m)=>s.assign(a,d,g,m),decide:a=>s.decide(a),getSlotResult:a=>s.getSlotResult(a),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function u(a){s=a}return{proxy:c,setInner:u}}function yt(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function Ne(e){var t,n,r,o,l,i,s,c,u;if(typeof window=="undefined")return Re;dn=e.apiKey||"local";let a=re.get(e.apiKey||"local");if(a!=null&&a.dispose)try{a.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&Se(),g=e.consent===!1||d,m=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!m&&e.localMode!==!1)return re.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),g?Re:Gr(e);if(g){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),re.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Re;let{proxy:h,setInner:S}=Hr(e);return re.set(e.apiKey,{config:e,upgrade:d?null:S}),h}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Re;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Re;let p=(t=e.ingestUrl)!=null?t:un,f=Date.now(),A=rn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),C=$r(void 0,e.apiKey),L=Pr({ingestUrl:p,apiKey:e.apiKey}),y=pn(p),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},I=new Set,N=Br({url:`${y}/goals`,apiKey:e.apiKey,headers:w,onDrop:(h,S)=>{if(!e.debug){if(I.has(S))return;I.add(S)}console.warn(`[sentient] goal dropped (HTTP ${S}) \u2014 this will not be retried. `+(S===400?"The session was not found: call init() and let the session upsert complete before firing goals.":S===401||S===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),x=qt((n=navigator.userAgent)!=null?n:""),D=window.location.origin,K=Ft((r=document.referrer)!=null?r:"",D),j=(o=e.sessionSegment)!=null?o:`${x}:${K}`,Z=new Map,q=new Map,U=new Map,v=null,b=h=>{for(let S of h)U.has(S.id)||U.set(S.id,pt(S))};if(e.initialSlots)for(let[h,S]of Object.entries(e.initialSlots))U.set(h,S);let k=De(e.apiKey);if(k)for(let[h,S]of Object.entries(k.slots))U.has(h)||U.set(h,S);let O={low:.15,medium:.5,high:.85};if(e.initialPersona)v=_({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?v={persona:h.sentientPersona,confidence:(i=O[(l=h.sentientConfidence)!=null?l:"low"])!=null?i:.15}:k&&(v={persona:k.persona,confidence:(s=O[k.band])!=null?s:.15})}if(e.initialAssignments)for(let[h,S]of Object.entries(e.initialAssignments))C.set(h,j,{variantId:S,assignedAt:Date.now(),segment:j,confidence:1});let E=Promise.resolve(),oe=A.getSessionId();if(oe){let h=Wt((c=document.referrer)!=null?c:""),{utmParams:S,clickIds:M}=Wr(),Q=_(_(_({sessionId:oe,deviceClass:x,trafficSource:K,referrerDomain:h,utmParams:S,clickIds:M,timeOfDay:Jt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||zt((u=navigator.userAgent)!=null?u:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),F=async()=>{for(let T=0;;T++){try{let B=await fetch(`${y}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(Q),headers:w});if(B.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(B.ok||vt(B)==="dropped")return}catch(B){}if(T>=zr){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(B=>setTimeout(B,Pe(T+1)))}};try{E=F()}catch(T){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:L});let J=qr(),ee=null,te=!1,ie={goal(h,S={},M=1,Q=0){var F,T,B,V,Y,ve,fe;let Oe=A.getSessionId();if(!Oe)return;let X=Ur(S)?S:{metadata:S},Le=[h,(F=X.externalId)!=null?F:"",(T=X.stepIndex)!=null?T:Q,(B=X.weight)!=null?B:M].join("\0"),R=X.value!==void 0?`${X.value}\0${(V=X.currency)!=null?V:""}`:null;if(J.firedBefore(Le,R)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let le=mt(),ze={sessionId:Oe,name:h,metadata:(Y=X.metadata)!=null?Y:{},weight:(ve=X.weight)!=null?ve:M,stepIndex:(fe=X.stepIndex)!=null?fe:Q,goalId:le,value:X.value,currency:X.currency,externalId:X.externalId};e.debug&&console.log("[sentient] goal",ze);let W={id:le,body:JSON.stringify(ze)};E.then(()=>N.send(W))},componentGoal(h,S,M){var Q,F,T;let B=A.getSessionId();if(!B)return;let V=C.get(h,j),Y=V?null:(Q=U.get(h))!=null?Q:null;if(!V&&Y===null){e.debug&&console.warn(`[sentient] componentGoal("${h}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let ve=V?V.variantId:Vt(Y),fe={id:mt(),sessionId:B,projectId:e.apiKey,componentId:h,variantId:ve,eventType:"goal_achieved",goalType:S,payload:_({reward:(F=M==null?void 0:M.reward)!=null?F:1,goalValue:M==null?void 0:M.value,currency:M==null?void 0:M.currency},(T=M==null?void 0:M.metadata)!=null?T:{}),timestamp:Date.now(),timeInSession:Date.now()-f,path:Ye()};e.debug&&console.log("[sentient] componentGoal",fe),E.then(()=>L.push(fe))},identify(h){let S=A.getSessionId();S&&E.then(()=>{fetch(`${y}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:S,userId:h,ephemeral:A.isEphemeral()}),headers:w}).catch(()=>{})})},track(h){let S=A.getSessionId();if(!S)return;let M=be(_({path:Ye()},h),{id:mt(),sessionId:S,timestamp:Date.now(),timeInSession:Date.now()-f});e.debug&&console.log("[sentient] track",M),E.then(()=>L.push(M))},getAssignment(h,S){return C.get(h,S)},async assign(h,S,M,Q){let F=A.getSessionId();if(!F)return null;let T=C.get(h,j);if(T&&(S!=null&&S.length||T.content!==void 0)){let B=T.ttlMs&&T.ttlMs>0?Math.max(0,T.assignedAt+T.ttlMs-Date.now()):0;return{variantId:T.variantId,assignmentTtlMs:B,content:T.content}}return yt(Z,h,async()=>{await E;try{let B={sessionId:F,componentId:h,variantIds:S};Q!==void 0?B.agentDataByVariant=Q:M!==void 0&&(B.agentData=M);let V=await fetch(`${y}/assign`,{method:"POST",body:JSON.stringify(B),headers:w});if(!V.ok)return null;let Y=await V.json();return C.set(h,j,_({variantId:Y.variantId,assignedAt:Date.now(),segment:j,confidence:1,content:Y.content},Y.assignmentTtlMs&&Y.assignmentTtlMs>0?{ttlMs:Y.assignmentTtlMs}:{})),Y}catch(B){return null}})},async decide(h){var S,M;let Q=A.getSessionId();if(!Q)return null;let F=(S=h.slots)!=null?S:[],T={sessionId:Q};h.sections&&h.sections.length>0&&(T.sections=h.sections.map(V=>({id:V}))),T.components=(M=h.components)!=null?M:[],F.length>0&&(T.slots=F.map(ft)),h.slotsFrom==="registry"&&(T.slotsFrom="registry"),h.v&&(T.v=h.v),e.persona&&(T.persona=e.persona);let B=JSON.stringify(T);return yt(q,B,async()=>{var V,Y,ve,fe,Oe,X;await E;try{let Le=await fetch(`${y}/decide`,{method:"POST",body:B,headers:w});if(!Le.ok)return b(F),null;let R=await Le.json(),le={};for(let W of F){let pe=(V=R.slots)==null?void 0:V[W.id];if(pe!==void 0){le[W.id]=pe,U.set(W.id,pe);continue}let Lt=U.get(W.id);if(Lt!==void 0)le[W.id]=Lt;else{let Tt=pt(W);le[W.id]=Tt,U.set(W.id,Tt)}}if(R.slots)for(let[W,pe]of Object.entries(R.slots))W in le||(le[W]=pe,U.set(W,pe));let ze=v!=null&&v.persona!=="unknown";R.persona&&!(R.persona==="unknown"&&ze)?v={persona:R.persona,confidence:(Y=R.confidence)!=null?Y:0}:v||(v={persona:"unknown",confidence:0});for(let[W,pe]of Object.entries((ve=R.assignments)!=null?ve:{}))C.set(W,j,{variantId:pe,assignedAt:Date.now(),segment:j,confidence:1});return Me(e.apiKey,_(_({v:1,persona:v.persona,band:we(v.confidence),slots:Object.fromEntries(U),layoutOrder:(fe=R.layoutOrder)!=null?fe:null,savedAt:Date.now()},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.palette?{palette:R.palette}:{})),_(_(_(_({layoutOrder:(Oe=R.layoutOrder)!=null?Oe:null,assignments:(X=R.assignments)!=null?X:{},slots:le,persona:v.persona,confidence:v.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{}),R.sectionMap?{sectionMap:R.sectionMap}:{}),R.palette?{palette:R.palette}:{})}catch(Le){return b(F),null}})},getSlotResult(h){var S;return(S=U.get(h))!=null?S:null},getPersona(){return v?{persona:v.persona,confidence:v.confidence,band:we(v.confidence)}:null},async fetchWeights(){var h;try{let S=await fetch(`${y}/weights`,{headers:w});return S.ok?(h=(await S.json()).components)!=null?h:[]:[]}catch(S){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;ee==null||ee(),te=!0,L.destroy(),N.destroy(),((h=re.get(e.apiKey))==null?void 0:h.dispose)===ie.dispose&&re.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;ee==null||ee(),te=!0,L.destroy(),N.destroy(),A.destroy(),C.clear(),((h=re.get(e.apiKey))==null?void 0:h.dispose)===ie.dispose&&re.delete(e.apiKey);try{localStorage.removeItem(Xe+e.apiKey),localStorage.removeItem(an(e.apiKey)),localStorage.removeItem(ln(e.apiKey))}catch(S){}e.debug&&console.log("[sentient] destroyed")}};if(re.set(e.apiKey,{config:e,upgrade:null,dispose:ie.dispose}),ee=Fr(ie,e.apiKey,h=>{E.then(()=>{te||fn.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=ie)}return ie}var Jr=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function wt(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function Vr(e){return{tag:e.tagName.toLowerCase(),text:wt(e).slice(0,40)}}function gn(e){return e.replace(/["\\\]]/g,"\\$&")}function $e(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function mn(e,t){var n;let r=e.tagName.toLowerCase();if(!r)return null;let o=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),l=[r,...o.map(s=>`${r}.${s}`)];for(let s of l)if($e(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=mn(i,t);if(s){for(let d of l){let g=`${s} > ${d}`;if($e(t,g))return g}let c=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=c.indexOf(e),a=c.some(d=>d!==e&&wt(d)!==wt(e));if(u>=0&&a){let d=`${s} > ${r}:nth-of-type(${u+1})`;if($e(t,d))return d}}}return null}function hn(e,t){let n=Vr(e),r=e.getAttribute("id");if(r&&$e(t,`#${gn(r)}`))return{v:1,id:r,fingerprint:n};for(let l of Jr){let i=e.getAttribute(l);if(i&&$e(t,`[${l}="${gn(i)}"]`))return{v:1,dataAttr:{name:l,value:i},fingerprint:n}}let o=mn(e,t);return o?{v:1,selector:o,fingerprint:n}:null}Te();var vn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Yr={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Xr(e){let t=e.ariaRole?Yr[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function Zr(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Qr=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],St=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],yn={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function eo(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function bn(e){var t,n;let r=Xr(e);if(r)return{type:(t=yn[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of Qr)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of St)if(s.test(e.bodyText))return{type:i,strength:"strong"};let l=Zr(e);return{type:(n=yn[l])!=null?n:"generic",strength:"weak"}}function wn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return _({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:eo(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}Te();var to="section, header, footer, nav, main > div, [data-sentient-section]",no=2e4;function ro(e){let t=Array.from(e.querySelectorAll(to)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function oo(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var Sn=()=>{};function An(e,t){var n,r,o,l,i,s,c,u,a,d,g,m;let p=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!p||typeof IntersectionObserver=="undefined"||Se()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Sn;let f=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),A=ro(p);if(A.length===0)return Sn;let C=new Map,L=[];for(let b of A){let k=b.getAttribute("data-sentient-type"),O=k&&vn.includes(k)?k:null,E=wn(b),oe=(l=O!=null?O:(o=t.typeOf)==null?void 0:o.call(t,b))!=null?l:bn(E).type,J=hn(b,p),ee=J?`nc-${oe}-${Gt(JSON.stringify({id:(i=J.id)!=null?i:null,dataAttr:(s=J.dataAttr)!=null?s:null,selector:(c=J.selector)!=null?c:null})).toString(36)}`:`nc-${oe}`;C.set(b,ee);let te=St.filter(([,ie])=>ie.test(E.bodyText)).map(([ie])=>ie);L.push(be(_({componentId:ee,semanticType:oe,source:O?"markup":"auto"},J?{locator:J}:{}),{observation:_(_({tag:E.tag,idClass:E.idClass.slice(0,200),headingText:E.headingText,textLength:E.textLength,actionCount:E.actionCount},E.ariaRole?{ariaRole:E.ariaRole}:{}),te.length>0?{patternFlags:te}:{})}))}let y=(g=(d=(a=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0)==null?void 0:a.location)==null?void 0:d.pathname)!=null?g:"/";oo(t.apiKey,f,y,L);let w=new Map,I=b=>{let k=w.get(b);return k||(k={ms:0,scroll:0,enterAt:null,intersecting:!1},w.set(b,k)),k},N=new IntersectionObserver(b=>{for(let k of b){let O=C.get(k.target);if(!O)continue;let E=I(O);k.isIntersecting?(E.intersecting=!0,E.enterAt=Date.now(),k.intersectionRatio>E.scroll&&(E.scroll=k.intersectionRatio)):(E.intersecting=!1,E.enterAt!=null&&(E.ms+=Date.now()-E.enterAt,E.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let b of C.keys())N.observe(b);let x=()=>{let b=Date.now();for(let[k,O]of w)if(O.enterAt!=null&&(O.ms+=b-O.enterAt,O.enterAt=null),!(O.ms<=0)){try{e.track({projectId:t.apiKey,componentId:k,eventType:"dwell",payload:{dwell_time:Math.round(O.ms),scroll_depth:Number(O.scroll.toFixed(2))}})}catch(E){}O.ms=0}},D=()=>{if(p.hidden)x();else{let b=Date.now();for(let k of w.values())k.intersecting&&(k.enterAt=b)}},K=!1,j=b=>{if(x(),b!=null&&b.persisted){K=!0;return}try{N.disconnect()}catch(k){}},Z=b=>{if(!(b!=null&&b.persisted)||!K)return;K=!1;let k=Date.now();for(let O of w.values())O.enterAt=O.intersecting&&!p.hidden?k:null};p.addEventListener("visibilitychange",D);let q=(m=p.defaultView)!=null?m:typeof window!="undefined"?window:void 0;q==null||q.addEventListener("pagehide",j),q==null||q.addEventListener("pageshow",Z);let U=setInterval(()=>{if(p.hidden||K)return;x();let b=Date.now();for(let k of w.values())k.intersecting&&(k.enterAt=b)},no),v=[];return t.microSignals&&[...C.entries()].forEach(([b,k],O)=>{v.push(Be((E,oe={})=>{try{e.track({projectId:t.apiKey,componentId:k,eventType:"micro_signal",payload:_({signalType:E},oe)})}catch(J){}},b,void 0,{tabLoss:O===0}))}),()=>{x(),clearInterval(U),p.removeEventListener("visibilitychange",D),q==null||q.removeEventListener("pagehide",j),q==null||q.removeEventListener("pageshow",Z);for(let b of v)b();try{N.disconnect()}catch(b){}}}var io=["landing","ecommerce","saas","marketplace"];function so(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(l=>typeof l=="string"))return null;n[r]=o}return n}function ao(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function lo(e){try{return e()}catch(t){return}}function Ze(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=io.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let c=s,u=so(c.dims);if(!u||c.target!==void 0&&typeof c.target!="string")continue;let a=c.arms!==void 0?ao(c.arms):null,d={dims:u};typeof c.target=="string"&&(d.target=c.target),a&&(d.arms=a),r[i]=d}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let l=typeof t.persona=="function"?lo(t.persona):t.persona;if(typeof l=="string"&&l.trim()!==""&&(o.persona=l),Array.isArray(t.sections)){let i=t.sections.filter(s=>typeof s=="string"&&s.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function Qe(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function co(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").trim().toLowerCase(),o=t.text.trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function xn(e,t){return!!(e!=null&&e.urlMatch)&&!Qe(t).includes(e.urlMatch)}var uo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ge(e,t){var o;if(e.urlMatch&&!Qe(t).includes(e.urlMatch))return null;let n=[];if(e.id){let l=t.getElementById(e.id);n=l?[l]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&uo.test(e.dataAttr.name))try{let l=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${l}"]`))}catch(l){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(l){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!co(r,e.fingerprint)?null:r}var kn={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},fo=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function En(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!fo.test((r=n[1])!=null?r:""))return!1;return!0}var Cn=/^https:\/\//i,_n=new Map,me=null;function po(e){return e.replace(/["\\]/g,"\\$&")}function go(e){var t;(!me||!me.isConnected)&&(me=e.querySelector("style[data-sentient-ops]"),me||(me=e.createElement("style"),me.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(me))),me.textContent=[..._n.entries()].map(([n,r])=>`[data-snt-e="${po(n)}"]{${r}}`).join(`
|
|
2
|
+
`)}function In(e,t,n,r){var s;let o=!1,l=(s=t.moveBefore)!=null?s:t.moveAfter;if(l){let c=ge(l,r);!c||c===e||c.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,c):e.parentElement.insertBefore(e,c.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Cn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Cn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[c,u]of Object.entries(t.style)){let a=kn[c];a&&typeof u=="string"&&En(u)&&i.push(`${a}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),_n.set(n,i.join(";")),go(r)),{anchorMiss:o}}var Ke="data-sentient-block-arm",se=null;function je(e){se=e!=null?e:null}var ue="data-sentient-blocks-hid",et={none:"0",sm:"8px",md:"16px",lg:"24px"},At={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},On={sm:"0.875em",md:"1em",lg:"1.25em"},mo={sm:"1.25em",md:"1.5em",lg:"2em"},ho={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ln={sm:"8px",md:"16px",lg:"32px"},yo={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},vo={normal:"400",medium:"500",bold:"700"};function ce(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function Tn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function Rn(e,t){var n,r,o,l,i,s,c,u,a,d,g,m;try{switch(e.type){case"stack":case"grid":{let p=t.createElement("div");if(e.type==="stack"){let f=e;ce(p,{display:"flex","flex-direction":f.direction,gap:(r=et[(n=f.gap)!=null?n:"md"])!=null?r:et.md,"align-items":f.align?At[f.align]:void 0,"justify-content":f.justify?At[f.justify]:void 0,"flex-wrap":f.wrap?"wrap":void 0})}else{let f=e,A=(l=et[(o=f.gap)!=null?o:"md"])!=null?l:et.md;ce(p,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${f.columns-1} * ${A}) / ${f.columns})), 1fr))`,gap:A,"align-items":f.align?At[f.align]:void 0})}for(let f of(i=e.children)!=null?i:[]){let A=Rn(f,t);A&&p.appendChild(A)}return p}case"text":{let p=t.createElement("p");return p.textContent=e.value,ce(p,ne({margin:"0","font-size":e.size?On[e.size]:void 0,"font-weight":e.weight?vo[e.weight]:void 0,"text-align":e.align},Tn(e.tone)))}case"heading":{let p=t.createElement(`h${e.level}`);return p.textContent=e.value,ce(p,{margin:"0","font-size":mo[(s=e.size)!=null?s:"md"],"text-align":e.align})}case"button":{let p=t.createElement("a");p.textContent=e.label,p.href=e.href,e.tag&&p.setAttribute("data-sentient-tag",e.tag);let f=(c=e.emphasis)!=null?c:"primary";return ce(p,{display:"inline-block",padding:ho[(u=e.size)!=null?u:"md"],"border-radius":(a=se==null?void 0:se.radius)!=null?a:"8px",font:"inherit","font-size":e.size?On[e.size]:void 0,"text-decoration":f==="ghost"?"underline":"none",cursor:"pointer",background:f==="primary"?(d=se==null?void 0:se.primaryBg)!=null?d:"#111827":"transparent",color:f==="primary"?(g=se==null?void 0:se.primaryText)!=null?g:"#ffffff":"inherit",border:f==="secondary"?"1px solid currentColor":"none"})}case"link":{let p=t.createElement("a");return p.textContent=e.label,p.href=e.href,e.tag&&p.setAttribute("data-sentient-tag",e.tag),ce(p,{color:"inherit","text-decoration":"underline"})}case"image":{let p=t.createElement("img");return p.src=e.src,p.alt=e.alt,ce(p,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?yo[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let p=t.createElement("span");return p.textContent=e.value,ce(p,ne({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},Tn(e.tone)))}case"spacer":return ce(t.createElement("div"),{height:(m=Ln[e.size])!=null?m:Ln.md});default:return null}}catch(p){return null}}function Pn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(Ke);s!==null&&(t[s]===void 0?i.remove():o.add(s))}for(let[i,s]of Object.entries(t)){if(o.has(i))continue;let c=Rn(s,r);if(!c)continue;let u=r.createElement("div");u.setAttribute(Ke,i),u.style.display="none",u.appendChild(c),e.appendChild(u)}let l=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(Ke),c=i;s!==null?c.style.display=l&&s===n?"":"none":l?c.hasAttribute(ue)||(c.setAttribute(ue,c.style.display),c.style.display="none"):c.hasAttribute(ue)&&(c.style.display=c.getAttribute(ue),c.removeAttribute(ue))}}catch(o){}}function bo(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ke)!==null){n.remove();continue}n.hasAttribute(ue)&&(n.style.display=n.getAttribute(ue),n.removeAttribute(ue))}}catch(t){}}function tt(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ke}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ue}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||bo(r)}catch(n){}}function xt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function nt(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function rt(e,t,n){var r;for(let[o,l]of Object.entries(t)){let i=e[o];if(!i||typeof i=="string")continue;let s=xt(l.target,n);for(let c of s)for(let[u,a]of Object.entries(i))(r=l.dims[u])!=null&&r.includes(a)&&c.setAttribute(`data-${u}`,a)}}function ot(e,t,n){for(let[r,o]of Object.entries(t)){let l=e[r];if(typeof l!="string"||!o.arms||!o.arms.includes(l))continue;let i=xt(o.target,n);for(let s of i)s.setAttribute("data-sentient-arm",l)}}function it(e,t,n,r){var s,c;let o=new Set,l=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[u,a]of Object.entries(t)){if(xn(a.locator,n))continue;let d;if(a.locator){let m=ge(a.locator,n);d=m?[m]:[]}else d=xt(a.target,n);(a.locator||a.target)&&d.length===0&&i.push(u);let g=e[u];for(let m of d){if(g!==void 0)if(typeof g=="string")m.setAttribute("data-sentient-arm",g),l&&((c=r==null?void 0:r.onApplied)==null||c.call(r,u,g,m));else for(let[p,f]of Object.entries(g))m.setAttribute(`data-${p}`,f);a.blocks&&!So(n)&&(Pn(m,a.blocks,typeof g=="string"?g:void 0,n),o.add(m)),l&&(typeof a.content=="string"&&(m.textContent=a.content),a.ops&&In(m,a.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u))}}return tt(n,o),i}var wo=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function So(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:wo.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var Ao=800;function st(e,t,n){let r=[];return n.forEach(({slotId:o,arm:l,el:i},s)=>{r.push(Be((g,m={})=>{try{e.track({projectId:t,componentId:o,variantId:l,eventType:"micro_signal",payload:ne({signalType:g},m)})}catch(p){}},i,void 0,{tabLoss:s===0}));let c=null,u=0,a=()=>{u=Date.now(),c=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:l,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(g){}c=null},Ao)},d=()=>{c!==null&&(clearTimeout(c),c=null)};i.addEventListener("mouseenter",a),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",a),i.removeEventListener("mouseleave",d),c!==null&&clearTimeout(c)})}),()=>{for(let o of r)o()}}function xo(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function Mn(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var ko="_snt_fired_goals";function Bn(e,t){try{e==null||e.sessionStorage.removeItem(Mn(t)),e==null||e.sessionStorage.removeItem(ko)}catch(n){}}function Dn(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Eo(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function Co(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function at(e,t,n,r){var C,L;let o=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,l=Mn(r),i=Eo(o,l),s=y=>{let w=Dn(y);if(!i.has(w))try{y.slotId?t.componentGoal(y.slotId,y.goalId):t.goal(y.goalId),i.add(w),Co(o,l,i)}catch(I){}},c=e.filter(y=>y.event==="click"),u=e.filter(y=>y.event==="form_submit"),a=e.filter(y=>y.event==="url_reached"),d=e.filter(y=>y.event==="scroll_depth"),g=(y,w)=>{if(!y.locator)return!1;let I=ge(y.locator,n);return!!I&&(I===w||I.contains(w))},m=y=>{let w=y.target;if(!(!w||typeof w.closest!="function"))for(let I of c)g(I,w)&&s(I)},p=y=>{let w=y.target;if(w)for(let I of u)g(I,w)&&s(I)},f=()=>{if(a.length===0)return;let y=Qe(n);for(let w of a)w.urlPattern&&xo(w.urlPattern,y)&&s(w)},A=()=>{var I;let y=n.documentElement,w=y.scrollHeight>0?(y.scrollTop+y.clientHeight)/y.scrollHeight:0;for(let N of d)w>=((I=N.threshold)!=null?I:.75)&&s(N);d.every(N=>i.has(Dn(N)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",m,!0),n.addEventListener("submit",p,!0),(L=n.defaultView)==null||L.addEventListener("popstate",f),f(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:f,teardown:()=>{var y;n.removeEventListener("click",m,!0),n.removeEventListener("submit",p,!0),(y=n.defaultView)==null||y.removeEventListener("popstate",f),d.length>0&&n.removeEventListener("scroll",A)}}}var Nn="__snt_editor_token";function $n(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Nn):null}catch(e){return null}}function Kn(e){try{sessionStorage.setItem(Nn,e)}catch(t){}}var Et="0.19.0",Hn=5e3,_o=50,Jn=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),H=null,P=null,de={},ye=null,G=null,he=null,z=null,ae=null,$=null,Ae=null,jn=!1,kt=null,lt=null,ut=null,Ce=!1,Ge=!1,ke=!1;function Vn(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function xe(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function _e(e,t){return H?(H.personaAttributes&&$&&nt($.persona,$.band,e),rt(de,H.slots,e),ot(de,H.slots,e),ye?it(de,ye,e,t):(tt(e,new Set),[])):[]}function Yn(e){var n;let t=new Map;for(let r of(n=H==null?void 0:H.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function Ct(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Yn(t);if(n.size!==e.length)return;let r=[];for(let i of e){let s=n.get(i);if(!s)return;r.push(s)}let o=r[0].parentNode;if(!o||!r.every(i=>i.parentNode===o))return;let l=r.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let i=0;i<r.length;i++){let s=r[i];l[i]!==s&&(o.insertBefore(s,l[i]),l.splice(l.indexOf(s),1),l.splice(i,0,s))}}catch(n){}}function Io(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ie(){return!!(H&&P&&H.sectionCapture!==!1&&(H.consent!==!1||Ge)&&!Se())}function Oo(){if(!P||!H||!Ie()||ae)return;let e=[];_e(document,{contentAndOps:Ce,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),It();try{z==null||z(),z=st(P,H.apiKey,e)}catch(t){}}function It(){if(typeof document=="undefined"||!Ie())return;let e;try{if(lt&<.length>0){let t=new Map;for(let n of lt){if(n.urlMatch!==window.location.pathname)continue;let r=ge(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ae=An(P,ne({apiKey:H.apiKey,apiBase:H.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),ut=window.location.pathname}catch(t){}}function Ot(){try{let e=[];if(z==null||z(),z=null,_e(document,{contentAndOps:Ce,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Ct(Ae,document),e.length>0&&Ie())try{z=st(P,H.apiKey,e)}catch(t){}try{typeof window!="undefined"&&ut!==null&&window.location.pathname!==ut&&Ie()&&(ae==null||ae(),ae=null,It())}catch(t){}}catch(e){}}function Gn(){kt===null&&(kt=setTimeout(()=>{kt=null,Ot();try{G==null||G.checkUrl()}catch(e){}},_o))}function _t(){if(!(jn||typeof window=="undefined"||typeof history=="undefined")){jn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,l){let i=n.call(this,r,o,l!=null?l:null);return Gn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Gn)}catch(e){}}}function ct(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function Xn(e){return new URLSearchParams(e).get("sentient_editor")}function Lo(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function To(e,t){var n,r,o,l;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let c=document.createElement("meta");c.name="referrer",c.content="no-referrer",c.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(c)}catch(c){}let i=(o=e.editorSrc)!=null?o:Lo();if(!i){zn();return}let s=document.createElement("script");s.src=i,s.async=!0,s.onerror=()=>zn(),((l=document.head)!=null?l:document.documentElement).appendChild(s)}catch(i){}}var Un="sentient-editor-load-notice",Zn={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function zn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Un))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Un,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,Zn,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function Qn(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),l=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!l||!i))if(i.includes("=")){let s={};for(let c of i.split(",")){let[u,a]=c.split("=");u&&a&&(s[u]=a)}Object.keys(s).length&&(n[l]=s)}else n[l]=i}return Object.keys(n).length?n:null}function er(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var qn="sentient-persona-preview-banner";function Fn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(qn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=qn,o.setAttribute("role","status"),Object.assign(o.style,Zn,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let l=document.createElement("span");l.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(l),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Ro(e,t){var u,a,d,g,m,p,f,A,C,L;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((a=e.registry)!=null?a:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([y,w])=>({id:y,dims:w.dims}))},l=await Vn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(y=>y.ok?y.json():null).catch(()=>null),Hn);if(!l){Ue(e),xe(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=l;de=(d=i.slots)!=null?d:{},ye=(g=i.slotConfig)!=null?g:null,je(i.palette);let s=(f=(p=(m=i.personaAttributes)==null?void 0:m.persona)!=null?p:i.persona)!=null?f:t,c=(C=(A=i.personaAttributes)==null?void 0:A.confidence)!=null?C:"high";$={persona:s,band:c},_e(document),Ce=!0,_t(),Ue(e),i.recognized===!1?Fn(t,!0):Fn((L=i.personaDisplay)!=null?L:s)}function Ue(e){let t={goal(n,r){try{P==null||P.goal(n,r)}catch(o){}},componentGoal(n,r){try{P==null||P.componentGoal(n,r)}catch(o){}},grantConsent(){try{!P&&ke?(P=Ne({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona}),he&&he.length>0&&(G==null||G.teardown(),G=at(he,P,document,e.apiKey))):(bt(e.apiKey),P&&he&&he.length>0&&(G==null||G.teardown(),G=at(he,P,document,e.apiKey))),ke=!1}catch(n){}Ge=!0;try{Oo()}catch(n){}},revokeConsent(){try{ae==null||ae(),ae=null,ut=null,z==null||z(),z=null,G==null||G.teardown(),G=null,Bn(typeof window!="undefined"?window:null,e.apiKey),Ge=!1,ke=!0,P==null||P.destroy(),P=null}catch(n){}},reapply:Ot,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=$==null?void 0:$.persona)!=null?n:null,band:(r=$==null?void 0:$.band)!=null?r:null,slots:de,matchCounts:ct(e),consent:!ke&&(e.consent!==!1||Ge)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of Jn.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Wn(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},Jn.length=0}catch(t){}}async function tr(){var e;try{let t=Ze(window.sentient);if(!t){Wn();return}H=t,Ce=!1,Ae=null,je(null),Ge=!1,ke=!1,he=null;let n=typeof window!="undefined"?Xn(window.location.search):null;if(n){Kn(n);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let r=n!=null?n:$n();if(r){To(t,r),Ue(t),xe(t,"editor mode");return}let o=typeof window!="undefined"?Qn(window.location.search):null;if(o){de=o,$=null,_e(document),_t(),Ue(t),xe(t,"preview mode",o);return}let l=typeof window!="undefined"?er(window.location.search):null;if(l){await Ro(t,l),xe(t,"persona preview",l);return}let i=(e=t.registry)!=null?e:Object.keys(t.slots).length===0,s=De(t.apiKey);s&&($={persona:s.persona,band:s.band},de=s.slots,s.slotConfig&&(ye=s.slotConfig),s.palette&&je(s.palette),_e(document,{contentAndOps:!1}),s.layoutOrder&&(Ae=s.layoutOrder,Ct(Ae,document)));let c=Ne({apiKey:t.apiKey,context:t.context,consent:t.consent,preConsentBehavior:t.preConsentBehavior,debug:t.debug,persona:t.persona});P=c,Ue(t),_t();let u=Object.entries(t.slots).map(([f,A])=>({id:f,dims:A.dims})),a=Et!=="0.0.0-dev"?{v:Et}:{},d=Array.from(Yn(document).keys()),g=c.decide(ne(ne(ne({slots:u},a),d.length>=2?{sections:d}:{}),i?{slotsFrom:"registry"}:{})),m=await Vn(g,Hn),p=f=>{var L,y,w,I,N,x;let A=c.getPersona();A?$={persona:A.persona,band:A.band}:f.persona&&($={persona:f.persona,band:"low"}),de=f.slots,i?ye=(L=f.slotConfig)!=null?L:null:f.slotConfig&&(ye=f.slotConfig),f.palette&&je(f.palette),Ae=(y=f.layoutOrder)!=null?y:Ae;let C=()=>{let D=[];if(Io(t,_e(document,{onApplied:(K,j,Z)=>D.push({slotId:K,arm:j,el:Z})})),Ct(Ae,document),Ce=!0,Ie())try{z==null||z(),z=st(P,t.apiKey,D)}catch(K){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C,{once:!0}):C(),he=(w=f.goals)!=null?w:null,f.goals&&f.goals.length>0&&t.consent!==!1&&P)try{G==null||G.teardown(),G=at(f.goals,P,document,t.apiKey)}catch(D){}lt=(I=f.sectionMap)!=null?I:null,Ie()&&It(),xe(t,"applied",{persona:$,slots:de,matches:ct(t)}),!ke&&Me(t.apiKey,ne(ne({v:1,persona:(N=$==null?void 0:$.persona)!=null?N:f.persona,band:(x=$==null?void 0:$.band)!=null?x:"low",slots:f.slots,layoutOrder:f.layoutOrder,savedAt:Date.now()},ye?{slotConfig:ye}:{}),f.palette?{palette:f.palette}:{}))};if(!m){xe(t,"decide timeout/null \u2014 snapshot state stands",ct(t)),g.then(f=>{!f||Ce||ke||P!==c||(p(f),xe(t,"late decide applied",ct(t)))}).catch(()=>{});return}p(m)}catch(t){Wn()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,tr())}return sr(Po);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/snippet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SentientUI Style-rung snippet for non-React sites — persona attributes and adaptive style tokens from one script tag",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"tsx": "^4.19.2",
|
|
25
25
|
"typescript": "^5.7.2",
|
|
26
26
|
"vitest": "^2.1.8",
|
|
27
|
-
"@sentientui/core": "0.
|
|
27
|
+
"@sentientui/core": "0.25.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsup",
|