@sentientui/snippet 0.17.1 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var De=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames,pt=Object.getOwnPropertySymbols;var mt=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable;var gt=(e,t,n)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Y=(e,t)=>{for(var n in t||(t={}))mt.call(t,n)&&gt(e,n,t[n]);if(pt)for(var n of pt(t))Tn.call(t,n)&&gt(e,n,t[n]);return e};var ht=(e,t)=>()=>(e&&(t=e(e=0)),t);var yt=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})},Rn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ln(t))!mt.call(e,s)&&s!==n&&De(e,s,{get:()=>t[s],enumerable:!(r=Cn(t,s))||r.enumerable});return e};var Pn=e=>Rn(De({},"__esModule",{value:!0}),e);var Dn,Bn,Mn,vt,Nn,Kn,bt,C,ke,Be=ht(()=>{"use strict";Dn=Object.defineProperty,Bn=Object.defineProperties,Mn=Object.getOwnPropertyDescriptors,vt=Object.getOwnPropertySymbols,Nn=Object.prototype.hasOwnProperty,Kn=Object.prototype.propertyIsEnumerable,bt=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))Nn.call(t,n)&&bt(e,n,t[n]);if(vt)for(var n of vt(t))Kn.call(t,n)&&bt(e,n,t[n]);return e},ke=(e,t)=>Bn(e,Mn(t))});var Ot={};yt(Ot,{LOCAL_ENGINE_AVAILABLE:()=>zn,createLocalEngine:()=>qn});function qn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var zn,Ct=ht(()=>{"use strict";zn=!1});var ao={};yt(ao,{applyPersonaAttributes:()=>He,applyRegistrySlots:()=>Ve,applySlotArms:()=>Fe,applySlotAttributes:()=>We,parseEditorToken:()=>xn,parsePersonaPreview:()=>kn,parsePreview:()=>En,parseSnippetConfig:()=>ze,reapply:()=>ft,run:()=>_n,version:()=>lt});Be();var $n=["buyer","researcher","deal_seeker","browser"];var jn={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Me(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function wt(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 s=n.slice(0,r);if(s in t)return null;t[s]=n.slice(r+1)}return t}function Qe(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 Me(e.baseline);if(typeof e.baseline=="string")return e.baseline;let s={};for(let[l,o]of Object.entries((n=e.dims)!=null?n:{}))s[l]=(r=o[0])!=null?r:"";return Me(s)}function St(e,t){var n,r;return e.dims!=null?(r=(n=wt(t))!=null?n:wt(Qe(e)))!=null?r:{}:t}function me(e){return e>=.3?e<.7?"medium":"high":"low"}var uo=$n.map(e=>({key:e,displayName:jn[e]}));var Un=["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 At(e){return Gn(e)!==null}function Gn(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Un.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function xt(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 Et(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(s){}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 kt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function It(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function et(e){return C(C(C({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 tt(e){let t=et(e);return St(t,Qe(t))}function _t(e){return typeof e=="string"?e:Me(e)}Be();function Tt(){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)})}function Rt(e){return e?`_${e.slice(0,12)}`:""}var Hn="_snt_uid",Wn=365,Fn="_snt_uid";function Vn(){return Tt()}function Jn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Yn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Xn(e){try{return localStorage.getItem(e)}catch(t){return null}}function Zn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Qn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function er(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function tr(e){try{sessionStorage.removeItem(e)}catch(t){}}function nr(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 rr(e){try{localStorage.removeItem(e)}catch(t){}}function or(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var ir={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Pt(e){var t,n,r,s,l,o;if(typeof window=="undefined")return ir;let c=Rt(e==null?void 0:e.apiKey),i=(t=e==null?void 0:e.cookieName)!=null?t:`${Hn}${c}`,a=`${Fn}${c}`,u=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Wn)*24*60*60,f=w=>w&&w.length>0?w:null,d=(o=(l=(s=(r=f(Jn(i)))!=null?r:f(Xn(a)))!=null?s:f(Qn(a)))!=null?l:f(e==null?void 0:e.ssrSessionId))!=null?o:Vn();Yn(i,d,u);let g=Zn(a,d),A=nr(i),L=g?!1:er(a,d),x=!g&&!A&&!L;return{getSessionId:()=>d,isEphemeral:()=>x,destroy:()=>{d=null,or(i),rr(a),tr(a)}}}function _e(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ot(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 Dt(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 we(e,t,n){try{let r=(()=>{try{let l=localStorage.getItem(n);if(!l)return[];let o=JSON.parse(l);return Array.isArray(o)?o:[]}catch(l){return[]}})(),s=new Map;for(let l of r)s.set(l.id,l);for(let l of e)s.set(l.id,l);localStorage.setItem(n,JSON.stringify([...s.values()].slice(-t)))}catch(r){}}function Bt(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let s=new Set(e),l=r.filter(o=>!s.has(o.id));if(l.length===r.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var sr=500,ar=56*1024;function Mt(e){return`_snt_retry_${e.slice(0,12)}`}var lr={push:()=>{},flush:()=>{},destroy:()=>{}};function cr(e){var t,n,r;if(typeof window=="undefined")return lr;let s=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxBatchSize)!=null?n:20,o=(r=e.maxRetrySize)!=null?r:100,c=e.ingestUrl,i=e.apiKey,a=Mt(i),u=[],f=new Set,d=[],g=p=>{for(let y of p)A.delete(y),!f.has(y)&&(f.add(y),d.push(y));for(;d.length>sr;){let y=d.shift();y&&f.delete(y)}Bt(p,a)},A=new Set,L=p=>{f.has(p.id)||A.has(p.id)||(A.add(p.id),u.push(p))},x=p=>{for(let y of p)f.has(y.id)||(A.add(y.id),u.push(y))},w=Dt(a,o);for(let p of w)L(p);let k=0,h=0,b=(p,y=!0)=>{if(p.length===0)return;let E=JSON.stringify(p),P=p.map(ne=>ne.id),T;try{T=fetch(c,{method:"POST",keepalive:!0,body:E,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(ne){we(p,o,a),x(p),h++,k=Date.now()+_e(h);return}let ve=ne=>{if(ot(ne)!=="retry"){if(!ne.ok&&y){let se=p.filter(ae=>ae.eventType!=="pageview");if(se.length>0&&se.length<p.length){g(p.filter(ae=>ae.eventType==="pageview").map(ae=>ae.id)),b(se,!1);return}}g(P),h=0,k=0;return}we(p,o,a),x(p),h++,k=Date.now()+_e(h)};T instanceof Promise?T.then(ve).catch(()=>{we(p,o,a),x(p),h++,k=Date.now()+_e(h)}):ve(T)},I=typeof TextEncoder!="undefined"?new TextEncoder:null,M=p=>I?I.encode(p).length:p.length,S=p=>{let y=[],E=2;for(let P of p){let T=M(JSON.stringify(P))+1;if(y.length>0&&E+T>ar||y.length>=l)break;y.push(P),E+=T}return y},R=()=>{try{if(Date.now()<k)return;for(;u.length>0&&!(Date.now()<k);){let p=u.filter(E=>!f.has(E.id));if(u.length=0,p.length===0)break;let y=S(p);if(y.length===0)break;y.length<p.length&&u.push(...p.slice(y.length)),b(y)}}catch(p){}},X=!0,_=null;_=setInterval(()=>{X&&R()},s);let Z=()=>{document.visibilityState==="hidden"&&R()},N=()=>{R()};return document.addEventListener("visibilitychange",Z),window.addEventListener("pagehide",N),{push(p){L(p),u.length>=l&&R()},flush:R,destroy(){X=!1,_!==null&&(clearInterval(_),_=null),document.removeEventListener("visibilitychange",Z),window.removeEventListener("pagehide",N),R()}}}var ur=200;function Nt(e){return`_snt_goal_retry_${e.slice(0,12)}`}var dr={send:()=>{},flush:()=>{},destroy:()=>{}};function fr(e){var t,n,r;if(typeof window=="undefined")return dr;let s=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxRetrySize)!=null?n:100,o=(r=e.maxPerFlush)!=null?r:5,c=Nt(e.apiKey),i=[],a=new Set,u=new Set,f=[],d=0,g=0,A=!1,L=S=>{for(a.delete(S.id),u.has(S.id)||(u.add(S.id),f.push(S.id));f.length>ur;){let R=f.shift();R&&u.delete(R)}Bt([S.id],c)},x=S=>{we([S],l,c),!u.has(S.id)&&!a.has(S.id)&&(a.add(S.id),i.push(S)),Date.now()>=d&&(g++,d=Date.now()+_e(g))},w=S=>{let R;try{R=fetch(e.url,{method:"POST",keepalive:!0,body:S.body,headers:e.headers})}catch(_){x(S);return}let X=_=>{var Z;let N=ot(_);if(N==="retry"){x(S);return}N==="dropped"&&((Z=e.onDrop)==null||Z.call(e,S,_.status)),L(S),g=0,d=0};R instanceof Promise?R.then(X).catch(()=>x(S)):X(R)},k=()=>{try{if(A||Date.now()<d)return;let S=0;for(;i.length>0&&S<o&&!(Date.now()<d);){let R=i.shift();a.delete(R.id),!u.has(R.id)&&(S++,w(R))}}catch(S){}},h=Dt(c,l);for(let S of h)a.has(S.id)||(a.add(S.id),i.push(S));h.length>0&&we(h,l,c);let b=setInterval(k,s),I=()=>{document.visibilityState==="hidden"&&k()},M=()=>k();return document.addEventListener("visibilitychange",I),window.addEventListener("pagehide",M),{send(S){if(!A&&!(u.has(S.id)||a.has(S.id))){if(Date.now()<d){we([S],l,c),a.add(S.id),i.push(S);return}w(S)}},flush:k,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",I),window.removeEventListener("pagehide",M),k(),A=!0}}}var pr=1800*1e3;function Ne(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function gr(e=pr,t){let n=new Map,r=`_snt_asgn${Rt(t)}_`,s=(i,a)=>`${r}${encodeURIComponent(i)}:${encodeURIComponent(a)}`,l=i=>{let a=i.slice(r.length),u=a.indexOf(":");if(u<0)return null;try{return{componentId:decodeURIComponent(a.slice(0,u)),segment:decodeURIComponent(a.slice(u+1))}}catch(f){return null}},o=()=>{try{let i=[];for(let a=0;a<localStorage.length;a++){let u=localStorage.key(a);u!=null&&u.startsWith(r)&&i.push(u)}return i}catch(i){return[]}},c=i=>i.assignedAt+(i.ttlMs&&i.ttlMs>0?i.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let i of o())try{let a=localStorage.getItem(i);if(!a)continue;let u=JSON.parse(a);if(c(u)){localStorage.removeItem(i);continue}let f=l(i);if(!f)continue;n.set(Ne(f.componentId,f.segment),u)}catch(a){}})(),{get(i,a){let u=n.get(Ne(i,a));return u?c(u)?(n.delete(Ne(i,a)),null):u:null},set(i,a,u){let f=Ne(i,a);n.set(f,u);try{localStorage.setItem(s(i,a),JSON.stringify(u))}catch(d){}},invalidate(i){let a=`${encodeURIComponent(i)}:`;for(let u of[...n.keys()])u.startsWith(a)&&n.delete(u);for(let u of o()){let f=l(u);if((f==null?void 0:f.componentId)===i)try{localStorage.removeItem(u)}catch(d){}}},clear(){n.clear();for(let i of o())try{localStorage.removeItem(i)}catch(a){}}}}var je="_snt_snap:",mr=["low","medium","high"];function Ue(e){try{let t=localStorage.getItem(je+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"||!mr.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 Oe(e,t){try{localStorage.setItem(je+e,JSON.stringify(t))}catch(n){}}var rt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Kt="[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.",Lt=!1,Ke=!1;function hr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function yr(e){var t;let n=Pt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",s=hr(),l=Promise.resolve().then(()=>(Ct(),Ot)).then(i=>{let a=i;return a.LOCAL_ENGINE_AVAILABLE?(Lt||(Lt=!0,console.info(Kt)),a):(Ke||(Ke=!0,console.error(rt)),null)}).catch(()=>(Ke||(Ke=!0,console.error(rt)),null)),o=null;function c(i){let a=document.documentElement;a.dataset.sentientPersona===void 0&&(a.dataset.sentientPersona=i.persona,a.dataset.sentientConfidence=me(i.confidence))}return{isLocal:!0,async decide(i){var a,u,f;let d=await l;if(!d)return null;let g=d.createLocalEngine({sessionId:r,forcedPersona:s}).decide(i);return o=ke(C({},g),{layoutOrder:(u=(a=g.layoutOrder)!=null?a:o==null?void 0:o.layoutOrder)!=null?u:null,slots:C(C({},(f=o==null?void 0:o.slots)!=null?f:{}),g.slots)}),Oe(e.apiKey||"local",{v:1,persona:o.persona,band:me(o.confidence),slots:o.slots,layoutOrder:o.layoutOrder,savedAt:Date.now()}),c(g),g},getSlotResult(i){var a,u,f;return(f=(u=o==null?void 0:o.slots[i])!=null?u:(a=e.initialSlots)==null?void 0:a[i])!=null?f:null},getPersona(){return o?{persona:o.persona,confidence:o.confidence,band:me(o.confidence)}:null},async assign(i,a){var u;let f=await l;return!f||!a||a.length===0?a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null:{variantId:(u=f.createLocalEngine({sessionId:r,forcedPersona:s}).decide({components:[{id:i,variantIds:a}]}).assignments[i])!=null?u:a[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Ce(e,t,n,r){let s=[];{let l=!1,o=[],c=()=>{if(l)return;let i=Date.now();for(o.push(i);o.length>0&&i-o[0]>500;)o.shift();o.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",c),s.push(()=>t.removeEventListener("click",c))}{let l=!1,o=c=>{if(l||!(c.target instanceof Node)||!t.contains(c.target)&&t!==c.target)return;l=!0;let i=typeof window!="undefined"?window.getSelection():null,a=i?i.toString().length:0;e("text_copy",{selectionLength:a})};document.addEventListener("copy",o),s.push(()=>document.removeEventListener("copy",o))}{let l=!1,o=!1,c=null,i=()=>{c!==null&&(clearTimeout(c),c=null)},a=()=>{l||!o||(i(),c=setTimeout(()=>{!l&&o&&(l=!0,e("scroll_hesitation"))},3e3))},u=()=>{i(),a()},f=g=>{for(let A of g)o=A.intersectionRatio>.3,o?a():i()},d=new IntersectionObserver(f,{threshold:[.3]});d.observe(t),window.addEventListener("scroll",u,{passive:!0}),s.push(()=>{d.disconnect(),window.removeEventListener("scroll",u),i()})}if((r==null?void 0:r.tabLoss)!==!1){let l=!1,o=n!=null?n:Date.now(),c=()=>{if(l||document.visibilityState!=="hidden")return;let i=Date.now()-o;i<15e3&&(l=!0,e("tab_loss",{timeOnPage:i}))};document.addEventListener("visibilitychange",c),s.push(()=>document.removeEventListener("visibilitychange",c))}return()=>{for(let l of s)l()}}var $t="https://api.sentient-ui.com/v1/events",V=new Map,jt=null;function vr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var br=3;function nt(){return Tt()}function $e(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function wr(e){if(typeof MessageChannel=="function"){let t=new MessageChannel;t.port1.onmessage=()=>{e.clear(),t.port1.close(),t.port2.close()},t.port2.postMessage(0)}else setTimeout(()=>e.clear(),0)}var Ut=new Set;function Sr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let s=!1,l,o=()=>{if(s)return;let a=$e();!a||a===l||(l=a,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${a}`))},c=[];for(let a of["pushState","replaceState"]){let u=r[a],f=function(...d){let g=u.apply(this,d);return o(),g};r[a]=f,c.push([a,u,f])}window.addEventListener("popstate",o);let i=$e();return i&&Ut.has(`${t}:${i}`)?l=i:o(),()=>{if(!s){s=!0,window.removeEventListener("popstate",o);for(let[a,u,f]of c)r[a]===f&&(r[a]=u)}}}var Ie={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 Ar(){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 Gt(e){return e.replace(/\/events\/?$/,"")}function he(){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 it(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:jt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=V.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:s,upgrade:l}=r;if(!l||s.respectDoNotTrack!==!1&&he())return;let o=Ge(ke(C({},s),{consent:!0}));l(o);let c=(t=V.get(n))==null?void 0:t.dispose;V.set(n,{config:ke(C({},s),{consent:!0}),upgrade:null,dispose:c})}function xr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Gt((t=e.ingestUrl)!=null?t:$t),s={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},l={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(i,a,u){if(!n)return null;try{let f=new URLSearchParams({componentId:i});for(let g of a!=null?a:[])f.append("variantIds[]",g);let d=await fetch(`${r}/winner?${f.toString()}`,{headers:s});return d.ok?{variantId:(await d.json()).variantId,assignmentTtlMs:0}:a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}catch(f){return a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},o={track:i=>l.track(i),goal:((i,a,u,f)=>l.goal(i,a,u,f)),componentGoal:(i,a,u)=>l.componentGoal(i,a,u),identify:i=>l.identify(i),getAssignment:(i,a)=>l.getAssignment(i,a),assign:(i,a,u,f)=>l.assign(i,a,u,f),decide:i=>l.decide(i),getSlotResult:i=>l.getSlotResult(i),getPersona:()=>l.getPersona(),fetchWeights:()=>l.fetchWeights(),getGraph:()=>l.getGraph(),dispose:()=>l.dispose(),destroy:()=>l.destroy()};function c(i){l=i}return{proxy:o,setInner:c}}function Ge(e){var t,n,r,s,l,o,c,i,a;if(typeof window=="undefined")return Ie;jt=e.apiKey;let u=V.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(m){}let f=e.respectDoNotTrack!==!1&&he(),d=e.consent===!1||f,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return d?(V.set(e.apiKey||"local",{config:e,upgrade:null}),Ie):(V.set(e.apiKey||"local",{config:e,upgrade:null}),yr(e));if(d){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."),V.set(e.apiKey,{config:e,upgrade:null}),Ie;let{proxy:m,setInner:v}=xr(e);return V.set(e.apiKey,{config:e,upgrade:f?null:v}),m}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."),Ie;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Ie;let A=(t=e.ingestUrl)!=null?t:$t,L=Date.now(),x=Pt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),w=gr(void 0,e.apiKey),k=cr({ingestUrl:A,apiKey:e.apiKey}),h=Gt(A),b={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},I=new Set,M=fr({url:`${h}/goals`,apiKey:e.apiKey,headers:b,onDrop:(m,v)=>{if(!e.debug){if(I.has(v))return;I.add(v)}console.warn(`[sentient] goal dropped (HTTP ${v}) \u2014 this will not be retried. `+(v===400?"The session was not found: call init() and let the session upsert complete before firing goals.":v===401||v===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),m)}}),S=xt((n=navigator.userAgent)!=null?n:""),R=typeof window!="undefined"?window.location.origin:void 0,X=Et((r=document.referrer)!=null?r:"",R),_=(s=e.sessionSegment)!=null?s:`${S}:${X}`,Z=new Map,N=new Map,p=null,y=m=>{for(let v of m)N.has(v.id)||N.set(v.id,tt(v))};if(e.initialSlots)for(let[m,v]of Object.entries(e.initialSlots))N.set(m,v);let E=Ue(e.apiKey);if(E)for(let[m,v]of Object.entries(E.slots))N.has(m)||N.set(m,v);let P={low:.15,medium:.5,high:.85};if(e.initialPersona)p=C({},e.initialPersona);else{let m=document.documentElement.dataset;m.sentientPersona?p={persona:m.sentientPersona,confidence:(o=P[(l=m.sentientConfidence)!=null?l:"low"])!=null?o:.15}:E&&(p={persona:E.persona,confidence:(c=P[E.band])!=null?c:.15})}if(e.initialAssignments)for(let[m,v]of Object.entries(e.initialAssignments))w.set(m,_,{variantId:v,assignedAt:Date.now(),segment:_,confidence:1});let T=Promise.resolve(),ve=x.getSessionId();if(ve){let m=kt((i=document.referrer)!=null?i:""),v=C(C(C({sessionId:ve,deviceClass:S,trafficSource:X,referrerDomain:m,utmParams:Ar(),timeOfDay:It(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:x.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||At((a=navigator.userAgent)!=null?a:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),D=async()=>{for(let G=0;;G++){try{let K=await fetch(`${h}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(v),headers:b});if(K.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(K.ok||ot(K)==="dropped")return}catch(K){}if(G>=br){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(K=>setTimeout(K,_e(G+1)))}};try{T=D()}catch(G){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:k});let ne=new Set,se=null,ae=!1,be={goal(m,v={},D=1,G=0){var K,j,Q,F,q,re;let H=x.getSessionId();if(!H)return;let W=vr(v)?v:{metadata:v},ee=`${m}\0${(K=W.externalId)!=null?K:""}\0${(j=W.stepIndex)!=null?j:G}\0${(Q=W.weight)!=null?Q:D}`;if(ne.has(ee)){e.debug&&console.log(`[sentient] goal("${m}") already recorded for this action \u2014 not sent twice`);return}ne.add(ee),ne.size===1&&wr(ne);let xe=nt(),O={sessionId:H,name:m,metadata:(F=W.metadata)!=null?F:{},weight:(q=W.weight)!=null?q:D,stepIndex:(re=W.stepIndex)!=null?re:G,goalId:xe,value:W.value,currency:W.currency,externalId:W.externalId};e.debug&&console.log("[sentient] goal",O);let ge={id:xe,body:JSON.stringify(O)};T.then(()=>M.send(ge))},componentGoal(m,v,D){var G,K,j;let Q=x.getSessionId();if(!Q)return;let F=w.get(m,_),q=F?null:(G=N.get(m))!=null?G:null;if(!F&&q===null){e.debug&&console.warn(`[sentient] componentGoal("${m}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let re=F?F.variantId:_t(q),H={id:nt(),sessionId:Q,projectId:e.apiKey,componentId:m,variantId:re,eventType:"goal_achieved",goalType:v,payload:C({reward:(K=D==null?void 0:D.reward)!=null?K:1,goalValue:D==null?void 0:D.value,currency:D==null?void 0:D.currency},(j=D==null?void 0:D.metadata)!=null?j:{}),timestamp:Date.now(),timeInSession:Date.now()-L,path:$e()};e.debug&&console.log("[sentient] componentGoal",H),T.then(()=>k.push(H))},identify(m){let v=x.getSessionId();v&&T.then(()=>{fetch(`${h}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:v,userId:m,ephemeral:x.isEphemeral()}),headers:b}).catch(()=>{})})},track(m){let v=x.getSessionId();if(!v)return;let D=ke(C({path:$e()},m),{id:nt(),sessionId:v,timestamp:Date.now(),timeInSession:Date.now()-L});e.debug&&console.log("[sentient] track",D),T.then(()=>k.push(D))},getAssignment(m,v){return w.get(m,v)},async assign(m,v,D,G){let K=x.getSessionId();if(!K)return null;let j=w.get(m,_);if(j&&(v!=null&&v.length||j.content!==void 0)){let q=j.ttlMs&&j.ttlMs>0?Math.max(0,j.assignedAt+j.ttlMs-Date.now()):0;return{variantId:j.variantId,assignmentTtlMs:q,content:j.content}}let Q=Z.get(m);if(Q)return Q;let F=(async()=>{await T;try{let q={sessionId:K,componentId:m,variantIds:v};G!==void 0?q.agentDataByVariant=G:D!==void 0&&(q.agentData=D);let re=await fetch(`${h}/assign`,{method:"POST",body:JSON.stringify(q),headers:b});if(!re.ok)return null;let H=await re.json();return w.set(m,_,C({variantId:H.variantId,assignedAt:Date.now(),segment:_,confidence:1,content:H.content},H.assignmentTtlMs&&H.assignmentTtlMs>0?{ttlMs:H.assignmentTtlMs}:{})),H}catch(q){return null}finally{Z.delete(m)}})();return Z.set(m,F),F},async decide(m){var v,D,G,K,j,Q,F,q,re;let H=x.getSessionId();if(!H)return null;let W=(v=m.slots)!=null?v:[];await T;try{let ee={sessionId:H};m.sections&&m.sections.length>0&&(ee.sections=m.sections.map(J=>({id:J}))),ee.components=(D=m.components)!=null?D:[],W.length>0&&(ee.slots=W.map(et)),m.slotsFrom==="registry"&&(ee.slotsFrom="registry"),m.v&&(ee.v=m.v),e.persona&&(ee.persona=e.persona);let xe=await fetch(`${h}/decide`,{method:"POST",body:JSON.stringify(ee),headers:b});if(!xe.ok)return y(W),null;let O=await xe.json(),ge={};for(let J of W)ge[J.id]=(K=(G=O.slots)==null?void 0:G[J.id])!=null?K:tt(J);if(O.slots)for(let[J,Ee]of Object.entries(O.slots))J in ge||(ge[J]=Ee);for(let[J,Ee]of Object.entries(ge))N.set(J,Ee);let On=p!=null&&p.persona!=="unknown";O.persona&&!(O.persona==="unknown"&&On)?p={persona:O.persona,confidence:(j=O.confidence)!=null?j:0}:p||(p={persona:"unknown",confidence:0});for(let[J,Ee]of Object.entries((Q=O.assignments)!=null?Q:{}))w.set(J,_,{variantId:Ee,assignedAt:Date.now(),segment:_,confidence:1});return Oe(e.apiKey,C(C({v:1,persona:p.persona,band:me(p.confidence),slots:Object.fromEntries(N),layoutOrder:(F=O.layoutOrder)!=null?F:null,savedAt:Date.now()},O.slotConfig?{slotConfig:O.slotConfig}:{}),O.palette?{palette:O.palette}:{})),C(C(C(C({layoutOrder:(q=O.layoutOrder)!=null?q:null,assignments:(re=O.assignments)!=null?re:{},slots:ge,persona:p.persona,confidence:p.confidence},O.slotConfig?{slotConfig:O.slotConfig}:{}),O.goals?{goals:O.goals}:{}),O.sectionMap?{sectionMap:O.sectionMap}:{}),O.palette?{palette:O.palette}:{})}catch(ee){return y(W),null}},getSlotResult(m){var v;return(v=N.get(m))!=null?v:null},getPersona(){return p?{persona:p.persona,confidence:p.confidence,band:me(p.confidence)}:null},async fetchWeights(){var m;try{let v=await fetch(`${h}/weights`,{headers:b});return v.ok?(m=(await v.json()).components)!=null?m:[]:[]}catch(v){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var m;se==null||se(),ae=!0,k.destroy(),M.destroy(),((m=V.get(e.apiKey))==null?void 0:m.dispose)===be.dispose&&V.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var m;se==null||se(),ae=!0,k.destroy(),M.destroy(),x.destroy(),((m=V.get(e.apiKey))==null?void 0:m.dispose)===be.dispose&&V.delete(e.apiKey);try{localStorage.removeItem(je+e.apiKey),localStorage.removeItem(Mt(e.apiKey)),localStorage.removeItem(Nt(e.apiKey))}catch(v){}e.debug&&console.log("[sentient] destroyed")}};if(V.set(e.apiKey,{config:e,upgrade:null,dispose:be.dispose}),se=Sr(be,e.apiKey,m=>{T.then(()=>{ae||Ut.add(m)})}),e.debug){let m=window;m.__sentient&&(m.__sentient.client=be)}return be}var zt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Er=[["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]],kr=[["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 Ir(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function qt(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 Er)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of kr)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 Ht(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:Ir(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function Wt(e){return qt(Ht(e)).type}Be();var _r="section, header, footer, nav, main > div, [data-sentient-section]",Or=2e4;function Cr(e){let t=Array.from(e.querySelectorAll(_r)),n=t.filter(r=>t.filter(s=>s!==r&&r.contains(s)).length<2);return n.filter(r=>!n.some(s=>s!==r&&s.contains(r)))}function Lr(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(s){}}var Ft=()=>{};function Vt(e,t){var n,r,s,l,o,c,i,a,u;let f=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!f||typeof IntersectionObserver=="undefined"||he()||!t.apiKey)return Ft;let d=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),g=Cr(f);if(g.length===0)return Ft;let A=new Map,L=new Map,x=new Map;for(let p of g){let y=p.getAttribute("data-sentient-type"),E=y&&zt.includes(y)?y:null,P=(l=E!=null?E:(s=t.typeOf)==null?void 0:s.call(t,p))!=null?l:Wt(p),T=`nc-${P}`;A.set(p,T),L.set(T,P),E?x.set(T,"markup"):x.has(T)||x.set(T,"auto")}let w=(a=(i=(c=(o=f.defaultView)!=null?o:typeof window!="undefined"?window:void 0)==null?void 0:c.location)==null?void 0:i.pathname)!=null?a:"/";Lr(t.apiKey,d,w,[...L.entries()].map(([p,y])=>{var E;return{componentId:p,semanticType:y,source:(E=x.get(p))!=null?E:"auto"}}));let k=new Map,h=p=>{let y=k.get(p);return y||(y={ms:0,scroll:0,enterAt:null,intersecting:!1},k.set(p,y)),y},b=new IntersectionObserver(p=>{for(let y of p){let E=A.get(y.target);if(!E)continue;let P=h(E);y.isIntersecting?(P.intersecting=!0,P.enterAt=Date.now(),y.intersectionRatio>P.scroll&&(P.scroll=y.intersectionRatio)):(P.intersecting=!1,P.enterAt!=null&&(P.ms+=Date.now()-P.enterAt,P.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let p of A.keys())b.observe(p);let I=()=>{let p=Date.now();for(let[y,E]of k)if(E.enterAt!=null&&(E.ms+=p-E.enterAt,E.enterAt=null),!(E.ms<=0)){try{e.track({projectId:t.apiKey,componentId:y,eventType:"dwell",payload:{dwell_time:Math.round(E.ms),scroll_depth:Number(E.scroll.toFixed(2))}})}catch(P){}E.ms=0}},M=()=>{if(f.hidden)I();else{let p=Date.now();for(let y of k.values())y.intersecting&&(y.enterAt=p)}},S=!1,R=p=>{if(I(),p!=null&&p.persisted){S=!0;return}try{b.disconnect()}catch(y){}},X=p=>{if(!(p!=null&&p.persisted)||!S)return;S=!1;let y=Date.now();for(let E of k.values())E.enterAt=E.intersecting&&!f.hidden?y:null};f.addEventListener("visibilitychange",M);let _=(u=f.defaultView)!=null?u:typeof window!="undefined"?window:void 0;_==null||_.addEventListener("pagehide",R),_==null||_.addEventListener("pageshow",X);let Z=setInterval(()=>{if(f.hidden||S)return;I();let p=Date.now();for(let y of k.values())y.intersecting&&(y.enterAt=p)},Or),N=[];return t.microSignals&&[...A.entries()].forEach(([p,y],E)=>{N.push(Ce((P,T={})=>{try{e.track({projectId:t.apiKey,componentId:y,eventType:"micro_signal",payload:C({signalType:P},T)})}catch(ve){}},p,void 0,{tabLoss:E===0}))}),()=>{I(),clearInterval(Z),f.removeEventListener("visibilitychange",M),_==null||_.removeEventListener("pagehide",R),_==null||_.removeEventListener("pageshow",X);for(let p of N)p();try{b.disconnect()}catch(p){}}}var Tr=["landing","ecommerce","saas","marketplace"];function Rr(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,s]of t){if(!Array.isArray(s)||s.length<2||s.length>6||!s.every(l=>typeof l=="string"))return null;n[r]=s}return n}function Pr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Dr(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=Tr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[o,c]of Object.entries(t.slots)){if(typeof c!="object"||c===null)continue;let i=c,a=Rr(i.dims);if(!a||i.target!==void 0&&typeof i.target!="string")continue;let u=i.arms!==void 0?Pr(i.arms):null,f={dims:a};typeof i.target=="string"&&(f.target=i.target),u&&(f.arms=u),r[o]=f}let s={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(s.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(s.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(s.debug=!0),typeof t.registry=="boolean"&&(s.registry=t.registry),typeof t.editorSrc=="string"&&(s.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(s.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(s.sectionCapture=t.sectionCapture);let l=typeof t.persona=="function"?Dr(t.persona):t.persona;if(typeof l=="string"&&l.trim()!==""&&(s.persona=l),Array.isArray(t.sections)){let o=t.sections.filter(c=>typeof c=="string"&&c.trim()!=="").slice(0,50);o.length>=2&&(s.sections=o)}return s}function Jt(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function Br(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(),s=t.text.trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}function Yt(e,t){return!!(e!=null&&e.urlMatch)&&!Jt(t).includes(e.urlMatch)}var Mr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function de(e,t){var s;if(e.urlMatch&&!Jt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let l=t.getElementById(e.id);n=l?[l]:[]}if(n.length===0&&((s=e.dataAttr)!=null&&s.name)&&Mr.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&&!Br(r,e.fingerprint)?null:r}var Xt={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"},Nr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Zt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Nr.test((t=n[1])!=null?t:""))return!1;return!0}var Qt=/^https:\/\//i,en=new Map,fe=null;function Kr(e){return e.replace(/["\\]/g,"\\$&")}function $r(e){var t;(!fe||!fe.isConnected)&&(fe=e.querySelector("style[data-sentient-ops]"),fe||(fe=e.createElement("style"),fe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(fe))),fe.textContent=[...en.entries()].map(([n,r])=>`[data-snt-e="${Kr(n)}"]{${r}}`).join(`
2
- `)}function tn(e,t,n,r){var c;let s=!1,l=(c=t.moveBefore)!=null?c:t.moveAfter;if(l){let i=de(l,r);!i||i===e||i.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,i):e.parentElement.insertBefore(e,i.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Qt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Qt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let o=[];if(t.hidden&&o.push("display:none !important"),t.style)for(let[i,a]of Object.entries(t.style)){let u=Xt[i];u&&typeof a=="string"&&Zt(a)&&o.push(`${u}:${a.trim()} !important`)}return o.length>0&&(e.setAttribute("data-snt-e",n),en.set(n,o.join(";")),$r(r)),{anchorMiss:s}}var Le="data-sentient-block-arm",oe=null;function Te(e){oe=e!=null?e:null}var ce="data-sentient-blocks-hid",nn={none:"0",sm:"8px",md:"16px",lg:"24px"},st={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},rn={sm:"0.875em",md:"1em",lg:"1.25em"},jr={sm:"1.25em",md:"1.5em",lg:"2em"},Ur={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},on={sm:"8px",md:"16px",lg:"32px"},Gr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},zr={normal:"400",medium:"500",bold:"700"};function le(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function sn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function an(e,t){var n,r,s,l,o,c,i,a,u,f;try{switch(e.type){case"stack":case"grid":{let d=t.createElement("div");if(e.type==="stack"){let g=e;le(d,{display:"flex","flex-direction":g.direction,gap:nn[(n=g.gap)!=null?n:"md"],"align-items":g.align?st[g.align]:void 0,"justify-content":g.justify?st[g.justify]:void 0,"flex-wrap":g.wrap?"wrap":void 0})}else{let g=e,A=nn[(r=g.gap)!=null?r:"md"];le(d,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${g.columns-1} * ${A}) / ${g.columns})), 1fr))`,gap:A,"align-items":g.align?st[g.align]:void 0})}for(let g of(s=e.children)!=null?s:[]){let A=an(g,t);A&&d.appendChild(A)}return d}case"text":{let d=t.createElement("p");return d.textContent=e.value,le(d,Y({margin:"0","font-size":e.size?rn[e.size]:void 0,"font-weight":e.weight?zr[e.weight]:void 0,"text-align":e.align},sn(e.tone)))}case"heading":{let d=t.createElement(`h${e.level}`);return d.textContent=e.value,le(d,{margin:"0","font-size":jr[(l=e.size)!=null?l:"md"],"text-align":e.align})}case"button":{let d=t.createElement("a");d.textContent=e.label,d.href=e.href,e.tag&&d.setAttribute("data-sentient-tag",e.tag);let g=(o=e.emphasis)!=null?o:"primary";return le(d,{display:"inline-block",padding:Ur[(c=e.size)!=null?c:"md"],"border-radius":(i=oe==null?void 0:oe.radius)!=null?i:"8px",font:"inherit","font-size":e.size?rn[e.size]:void 0,"text-decoration":g==="ghost"?"underline":"none",cursor:"pointer",background:g==="primary"?(a=oe==null?void 0:oe.primaryBg)!=null?a:"#111827":"transparent",color:g==="primary"?(u=oe==null?void 0:oe.primaryText)!=null?u:"#ffffff":"inherit",border:g==="secondary"?"1px solid currentColor":"none"})}case"link":{let d=t.createElement("a");return d.textContent=e.label,d.href=e.href,e.tag&&d.setAttribute("data-sentient-tag",e.tag),le(d,{color:"inherit","text-decoration":"underline"})}case"image":{let d=t.createElement("img");return d.src=e.src,d.alt=e.alt,le(d,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Gr[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let d=t.createElement("span");return d.textContent=e.value,le(d,Y({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},sn(e.tone)))}case"spacer":return le(t.createElement("div"),{height:(f=on[e.size])!=null?f:on.md});default:return null}}catch(d){return null}}function ln(e,t,n,r){try{let s=new Set;for(let o of Array.from(e.children)){let c=o.getAttribute(Le);c!==null&&(t[c]===void 0?o.remove():s.add(c))}for(let[o,c]of Object.entries(t)){if(s.has(o))continue;let i=an(c,r);if(!i)continue;let a=r.createElement("div");a.setAttribute(Le,o),a.style.display="none",a.appendChild(i),e.appendChild(a)}let l=n!==void 0&&t[n]!==void 0;for(let o of Array.from(e.children)){let c=o.getAttribute(Le),i=o;c!==null?i.style.display=l&&c===n?"":"none":l?i.hasAttribute(ce)||(i.setAttribute(ce,i.style.display),i.style.display="none"):i.hasAttribute(ce)&&(i.style.display=i.getAttribute(ce),i.removeAttribute(ce))}}catch(s){}}function qr(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Le)!==null){n.remove();continue}n.hasAttribute(ce)&&(n.style.display=n.getAttribute(ce),n.removeAttribute(ce))}}catch(t){}}function qe(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Le}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ce}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||qr(r)}catch(n){}}function He(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function We(e,t,n){var r;for(let[s,l]of Object.entries(t)){let o=e[s];if(!o||typeof o=="string")continue;let c=l.target?Array.from(n.querySelectorAll(l.target)):[n.documentElement];for(let i of c)for(let[a,u]of Object.entries(o))(r=l.dims[a])!=null&&r.includes(u)&&i.setAttribute(`data-${a}`,u)}}function Fe(e,t,n){for(let[r,s]of Object.entries(t)){let l=e[r];if(typeof l!="string"||!s.arms||!s.arms.includes(l))continue;let o=s.target?Array.from(n.querySelectorAll(s.target)):[n.documentElement];for(let c of o)c.setAttribute("data-sentient-arm",l)}}function Ve(e,t,n,r){var c,i;let s=new Set,l=(c=r==null?void 0:r.contentAndOps)!=null?c:!0,o=[];for(let[a,u]of Object.entries(t)){if(Yt(u.locator,n))continue;let f;if(u.locator){let g=de(u.locator,n);f=g?[g]:[]}else u.target?f=Array.from(n.querySelectorAll(u.target)):f=[n.documentElement];(u.locator||u.target)&&f.length===0&&o.push(a);let d=e[a];for(let g of f){if(d!==void 0)if(typeof d=="string")g.setAttribute("data-sentient-arm",d),l&&((i=r==null?void 0:r.onApplied)==null||i.call(r,a,d,g));else for(let[A,L]of Object.entries(d))g.setAttribute(`data-${A}`,L);u.blocks&&!Wr(n)&&(ln(g,u.blocks,typeof d=="string"?d:void 0,n),s.add(g)),l&&(typeof u.content=="string"&&(g.textContent=u.content),u.ops&&tn(g,u.ops,a,n).anchorMiss&&!o.includes(a)&&o.push(a))}}return qe(n,s),o}var Hr=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Wr(e){var t,n,r;try{let s=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return s?s.webdriver===!0?!0:Hr.test((r=s.userAgent)!=null?r:""):!1}catch(s){return!1}}var Fr=800;function Je(e,t,n){let r=[];return n.forEach(({slotId:s,arm:l,el:o},c)=>{r.push(Ce((d,g={})=>{try{e.track({projectId:t,componentId:s,variantId:l,eventType:"micro_signal",payload:Y({signalType:d},g)})}catch(A){}},o,void 0,{tabLoss:c===0}));let i=null,a=0,u=()=>{a=Date.now(),i=setTimeout(()=>{try{e.track({projectId:t,componentId:s,variantId:l,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-a}})}catch(d){}i=null},Fr)},f=()=>{i!==null&&(clearTimeout(i),i=null)};o.addEventListener("mouseenter",u),o.addEventListener("mouseleave",f),r.push(()=>{o.removeEventListener("mouseenter",u),o.removeEventListener("mouseleave",f),i!==null&&clearTimeout(i)})}),()=>{for(let s of r)s()}}function Vr(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function Jr(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 Yr(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}function Xr(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Zr(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(s=>typeof s=="string")):new Set}catch(n){return new Set}}function Qr(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function cn(e,t,n,r){var w,k;let s=(w=n.defaultView)!=null?w:typeof window!="undefined"?window:null,l=Yr(r),o=Zr(s,l),c=h=>{let b=Xr(h);if(!o.has(b))try{h.slotId?t.componentGoal(h.slotId,h.goalId):t.goal(h.goalId),o.add(b),Qr(s,l,o)}catch(I){}},i=e.filter(h=>h.event==="click"),a=e.filter(h=>h.event==="form_submit"),u=e.filter(h=>h.event==="url_reached"),f=e.filter(h=>h.event==="scroll_depth"),d=(h,b)=>{if(!h.locator)return!1;let I=de(h.locator,n);return!!I&&(I===b||I.contains(b))},g=h=>{let b=h.target;if(!(!b||typeof b.closest!="function"))for(let I of i)d(I,b)&&c(I)},A=h=>{let b=h.target;if(b)for(let I of a)d(I,b)&&c(I)},L=()=>{if(u.length===0)return;let h=Vr(n);for(let b of u)b.urlPattern&&Jr(b.urlPattern,h)&&c(b)},x=()=>{var I;let h=n.documentElement,b=h.scrollHeight>0?(h.scrollTop+h.clientHeight)/h.scrollHeight:0;for(let M of f)b>=((I=M.threshold)!=null?I:.75)&&c(M);f.every(M=>o.has(M.goalId))&&n.removeEventListener("scroll",x)};return n.addEventListener("click",g,!0),n.addEventListener("submit",A,!0),(k=n.defaultView)==null||k.addEventListener("popstate",L),L(),f.length>0&&(n.addEventListener("scroll",x,{passive:!0}),x()),{checkUrl:L,teardown:()=>{var h;n.removeEventListener("click",g,!0),n.removeEventListener("submit",A,!0),(h=n.defaultView)==null||h.removeEventListener("popstate",L),f.length>0&&n.removeEventListener("scroll",x)}}}var un="__snt_editor_token";function dn(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(un):null}catch(e){return null}}function fn(e){try{sessionStorage.setItem(un,e)}catch(t){}}var lt="0.17.1",wn=5e3,eo=50,to=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),z=null,$=null,ue={},pe=null,te=null,U=null,ie=null,B=null,ye=null,pn=!1,at=null,Ye=null,Xe=null,Re=!1,Ze=!1;function Sn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function Se(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Ae(e,t){return z?(z.personaAttributes&&B&&He(B.persona,B.band,e),We(ue,z.slots,e),Fe(ue,z.slots,e),pe?Ve(ue,pe,e,t):(qe(e,new Set),[])):[]}function An(e){var n;let t=new Map;for(let r of(n=z==null?void 0:z.sections)!=null?n:[])try{let s=e.querySelectorAll(r);s.length===1&&t.set(r,s[0])}catch(s){}return t}function ct(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=An(t);if(n.size!==e.length)return;let r=[];for(let o of e){let c=n.get(o);if(!c)return;r.push(c)}let s=r[0].parentNode;if(!s||!r.every(o=>o.parentNode===s))return;let l=r.slice().sort((o,c)=>o.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let o=0;o<r.length;o++){let c=r[o];l[o]!==c&&(s.insertBefore(c,l[o]),l.splice(l.indexOf(c),1),l.splice(o,0,c))}}catch(n){}}function no(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 Pe(){return!!(z&&$&&z.sectionCapture!==!1&&(z.consent!==!1||Ze)&&!he())}function ro(){if(!$||!z||!Pe()||ie)return;let e=[];Ae(document,{contentAndOps:Re,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),dt();try{U==null||U(),U=Je($,z.apiKey,e)}catch(t){}}function dt(){if(typeof document=="undefined"||!Pe())return;let e;try{if(Ye&&Ye.length>0){let t=new Map;for(let n of Ye){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{ie=Vt($,Y({apiKey:z.apiKey,apiBase:z.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Xe=window.location.pathname}catch(t){}}function ft(){try{let e=[];if(U==null||U(),U=null,Ae(document,{contentAndOps:Re,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),ct(ye,document),e.length>0&&Pe())try{U=Je($,z.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Xe!==null&&window.location.pathname!==Xe&&Pe()&&(ie==null||ie(),ie=null,dt())}catch(t){}}catch(e){}}function gn(){at===null&&(at=setTimeout(()=>{at=null,ft();try{te==null||te.checkUrl()}catch(e){}},eo))}function mn(){if(!(pn||typeof window=="undefined"||typeof history=="undefined")){pn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,s,l){let o=n.call(this,r,s,l!=null?l:null);return gn(),o}};e("pushState"),e("replaceState"),window.addEventListener("popstate",gn)}catch(e){}}}function ut(e){let t={};for(let[n,r]of Object.entries(e.slots))t[n]=r.target?document.querySelectorAll(r.target).length:1;return t}function xn(e){return new URLSearchParams(e).get("sentient_editor")}function oo(){try{let t=Array.from(document.getElementsByTagName("script")).find(n=>/snippet(\.global)?\.js/.test(n.src));if(t!=null&&t.src)return t.src.replace(/snippet(\.global)?\.js/,"editor.global.js")}catch(e){}return null}function io(e,t){var n,r,s,l;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let i=document.createElement("meta");i.name="referrer",i.content="no-referrer",i.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(i)}catch(i){}let o=(s=e.editorSrc)!=null?s:oo();if(!o){yn();return}let c=document.createElement("script");c.src=o,c.async=!0,c.onerror=()=>yn(),((l=document.head)!=null?l:document.documentElement).appendChild(c)}catch(o){}}var hn="sentient-editor-load-notice";function yn(){var e;try{if(typeof document=="undefined"||document.getElementById(hn))return;let t=document.createElement("div");t.id=hn,t.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(t.style,{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",cursor:"pointer"}),t.addEventListener("click",()=>t.remove()),((e=document.body)!=null?e:document.documentElement).appendChild(t),setTimeout(()=>t.remove(),1e4)}catch(t){}}function En(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let s=r.indexOf(":"),l=s===-1?"":r.slice(0,s),o=s===-1?"":r.slice(s+1);if(!(!l||!o))if(o.includes("=")){let c={};for(let i of o.split(",")){let[a,u]=i.split("=");a&&u&&(c[a]=u)}Object.keys(c).length&&(n[l]=c)}else n[l]=o}return Object.keys(n).length?n:null}function kn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var vn="sentient-persona-preview-banner";function bn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(vn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),s=document.createElement("div");s.id=vn,s.setAttribute("role","status"),Object.assign(s.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",background:"#111827",color:"#fff",font:"13px/1 system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",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 o=document.createElement("button");o.type="button",o.textContent="Exit preview",Object.assign(o.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),o.addEventListener("click",()=>{try{let c=new URL(window.location.href);c.searchParams.delete("sentient_persona"),window.location.href=c.pathname+c.search+c.hash}catch(c){}}),s.appendChild(l),s.appendChild(o),((n=document.body)!=null?n:document.documentElement).appendChild(s)}catch(r){}}async function so(e,t){var a,u,f,d,g,A,L,x,w,k;let n=(a=e.apiBase)!=null?a:"https://api.sentient-ui.com",s=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([h,b])=>({id:h,dims:b.dims}))},l=await Sn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(s)}).then(h=>h.ok?h.json():null).catch(()=>null),wn);if(!l){Se(e,"persona preview: explain unavailable \u2014 page left as-is");return}let o=l;ue=(f=o.slots)!=null?f:{},pe=(d=o.slotConfig)!=null?d:null,Te(o.palette);let c=(L=(A=(g=o.personaAttributes)==null?void 0:g.persona)!=null?A:o.persona)!=null?L:t,i=(w=(x=o.personaAttributes)==null?void 0:x.confidence)!=null?w:"high";B={persona:c,band:i},Ae(document),Re=!0,In(e),o.recognized===!1?bn(t,!0):bn((k=o.personaDisplay)!=null?k:c)}function In(e){let t={goal(n,r){try{$==null||$.goal(n,r)}catch(s){}},componentGoal(n,r){try{$==null||$.componentGoal(n,r)}catch(s){}},grantConsent(){try{it(e.apiKey)}catch(n){}Ze=!0;try{ro()}catch(n){}},revokeConsent(){try{ie==null||ie(),ie=null,Xe=null,U==null||U(),U=null,te==null||te.teardown(),te=null,Ze=!1,$==null||$.destroy()}catch(n){}},reapply:ft,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=B==null?void 0:B.persona)!=null?n:null,band:(r=B==null?void 0:B.band)!=null?r:null,slots:ue,matchCounts:ut(e),consent:e.consent!==!1}}};window.SentientSnippet=t;for(let n of to.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}async function _n(){var e,t,n,r,s,l;try{let o=ze(window.sentient);if(!o)return;z=o,Re=!1,ye=null,Te(null),Ze=!1;let c=typeof window!="undefined"?xn(window.location.search):null;if(c){fn(c);try{let b=new URL(window.location.href);b.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",b.pathname+b.search+b.hash)}catch(b){}}let i=c!=null?c:dn();if(i){io(o,i),Se(o,"editor mode");return}let a=typeof window!="undefined"?En(window.location.search):null;if(a){ue=a,B=null,Ae(document),mn(),Se(o,"preview mode",a);return}let u=typeof window!="undefined"?kn(window.location.search):null;if(u){await so(o,u),Se(o,"persona preview",u);return}let f=(e=o.registry)!=null?e:Object.keys(o.slots).length===0,d=Ue(o.apiKey);d&&(B={persona:d.persona,band:d.band},ue=d.slots,d.slotConfig&&(pe=d.slotConfig),d.palette&&Te(d.palette),Ae(document,{contentAndOps:!1}),d.layoutOrder&&(ye=d.layoutOrder,ct(ye,document)));let g=Ge({apiKey:o.apiKey,context:o.context,consent:o.consent,preConsentBehavior:o.preConsentBehavior,debug:o.debug,persona:o.persona});$=g,In(o),mn();let A=Object.entries(o.slots).map(([b,I])=>({id:b,dims:I.dims})),L=lt!=="0.0.0-dev"?{v:lt}:{},x=Array.from(An(document).keys()),w=await Sn(g.decide(Y(Y(Y({slots:A},L),x.length>=2?{sections:x}:{}),f?{slotsFrom:"registry"}:{})),wn);if(!w){Se(o,"decide timeout/null \u2014 snapshot state stands",ut(o));return}let k=g.getPersona();k?B={persona:k.persona,band:k.band}:w.persona&&(B={persona:w.persona,band:"low"}),ue=w.slots,f?pe=(t=w.slotConfig)!=null?t:null:w.slotConfig&&(pe=w.slotConfig),w.palette&&Te(w.palette);let h=[];if(no(o,Ae(document,{onApplied:(b,I,M)=>h.push({slotId:b,arm:I,el:M})})),ye=(n=w.layoutOrder)!=null?n:ye,ct(ye,document),Re=!0,w.goals&&w.goals.length>0&&o.consent!==!1&&$)try{te==null||te.teardown(),te=cn(w.goals,$,document,o.apiKey)}catch(b){}if(Ye=(r=w.sectionMap)!=null?r:null,Pe()){dt();try{U==null||U(),U=Je($,o.apiKey,h)}catch(b){}}Se(o,"applied",{persona:B,slots:ue,matches:ut(o)}),Oe(o.apiKey,Y(Y({v:1,persona:(s=B==null?void 0:B.persona)!=null?s:w.persona,band:(l=B==null?void 0:B.band)!=null?l:"low",slots:w.slots,layoutOrder:w.layoutOrder,savedAt:Date.now()},pe?{slotConfig:pe}:{}),w.palette?{palette:w.palette}:{}))}catch(o){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,_n())}return Pn(ao);})();
1
+ "use strict";var SentientSnippet=(()=>{var Ke=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames,bt=Object.getOwnPropertySymbols;var At=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable;var St=(e,t,n)=>t in e?Ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,X=(e,t)=>{for(var n in t||(t={}))At.call(t,n)&&St(e,n,t[n]);if(bt)for(var n of bt(t))$n.call(t,n)&&St(e,n,t[n]);return e};var xt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Et=(e,t)=>{for(var n in t)Ke(e,n,{get:t[n],enumerable:!0})},jn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Kn(t))!At.call(e,i)&&i!==n&&Ke(e,i,{get:()=>t[i],enumerable:!(r=Nn(t,i))||r.enumerable});return e};var Gn=e=>jn(Ke({},"__esModule",{value:!0}),e);var Un,zn,qn,kt,Wn,Hn,It,C,Ee,$e=xt(()=>{"use strict";Un=Object.defineProperty,zn=Object.defineProperties,qn=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,Wn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,It=(e,t,n)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))Wn.call(t,n)&&It(e,n,t[n]);if(kt)for(var n of kt(t))Hn.call(t,n)&&It(e,n,t[n]);return e},Ee=(e,t)=>zn(e,qn(t))});var Mt={};Et(Mt,{LOCAL_ENGINE_AVAILABLE:()=>Zn,createLocalEngine:()=>Qn});function Qn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Zn,Nt=xt(()=>{"use strict";Zn=!1});var po={};Et(po,{applyPersonaAttributes:()=>Je,applyRegistrySlots:()=>Ze,applySlotArms:()=>Xe,applySlotAttributes:()=>Ye,parseEditorToken:()=>Pn,parsePersonaPreview:()=>Bn,parsePreview:()=>Dn,parseSnippetConfig:()=>Fe,reapply:()=>wt,run:()=>Mn,version:()=>mt});$e();var Fn=["buyer","researcher","deal_seeker","browser"];var Vn={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function je(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Ot(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 i=n.slice(0,r);if(i in t)return null;t[i]=n.slice(r+1)}return t}function ot(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 je(e.baseline);if(typeof e.baseline=="string")return e.baseline;let i={};for(let[c,a]of Object.entries((n=e.dims)!=null?n:{}))i[c]=(r=a[0])!=null?r:"";return je(i)}function _t(e,t){var n,r;return e.dims!=null?(r=(n=Ot(t))!=null?n:Ot(ot(e)))!=null?r:{}:t}function me(e){return e>=.3?e<.7?"medium":"high":"low"}var mo=Fn.map(e=>({key:e,displayName:Vn[e]}));function Ge(e){return e?`_${e.slice(0,12)}`:""}var Jn="_snt_uid";function Ct(e){return`${Jn}${Ge(e)}`}var Yn=["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 Lt(e){return Xn(e)!==null}function Xn(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Yn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Tt(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 Rt(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(i){}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 Pt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function Dt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function it(e){return C(C(C({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 st(e){let t=it(e);return _t(t,ot(t))}function Bt(e){return typeof e=="string"?e:je(e)}$e();function Ut(){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 er="_snt_uid",tr=365,at="_snt_uid";function nr(){return Ut()}function Kt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function rr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function $t(e){try{return localStorage.getItem(e)}catch(t){return null}}function or(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 ir(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function sr(e){try{sessionStorage.removeItem(e)}catch(t){}}function ar(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 lr(e){try{localStorage.removeItem(e)}catch(t){}}function cr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var ur={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function zt(e){var t,n,r,i,c,a,l;if(typeof window=="undefined")return ur;let o=Ge(e==null?void 0:e.apiKey),s=(t=e==null?void 0:e.cookieName)!=null?t:Ct(e==null?void 0:e.apiKey),u=`${at}${o}`,d=((n=e==null?void 0:e.cookieTTLDays)!=null?n:tr)*24*60*60,f=m=>m&&m.length>0?m:null,g=()=>{var m,A;return o&&!(e!=null&&e.cookieName)?(A=(m=f(Kt(er)))!=null?m:f($t(at)))!=null?A:f(jt(at)):null},S=(l=(a=(c=(i=(r=f(Kt(s)))!=null?r:f($t(u)))!=null?i:f(jt(u)))!=null?c:g())!=null?a:f(e==null?void 0:e.ssrSessionId))!=null?l:nr();rr(s,S,d);let O=or(u,S),k=ar(s),L=O?!1:ir(u,S),v=!O&&!k&&!L;return{getSessionId:()=>S,isEphemeral:()=>v,destroy:()=>{S=null,cr(s),lr(u),sr(u)}}}function Ie(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ut(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 be(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let a=JSON.parse(c);return Array.isArray(a)?a:[]}catch(c){return[]}})(),i=new Map;for(let c of r)i.set(c.id,c);for(let c of e)i.set(c.id,c);localStorage.setItem(n,JSON.stringify([...i.values()].slice(-t)))}catch(r){}}function Wt(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let i=new Set(e),c=r.filter(a=>!i.has(a.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var dr=500,pr=56*1024;function Ht(e){return`_snt_retry_${e.slice(0,12)}`}var fr={push:()=>{},flush:()=>{},destroy:()=>{}};function gr(e){var t,n,r;if(typeof window=="undefined")return fr;let i=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,a=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,o=e.apiKey,s=Ht(o),u=[],d=new Set,f=[],g=p=>{for(let y of p)S.delete(y),!d.has(y)&&(d.add(y),f.push(y));for(;f.length>dr;){let y=f.shift();y&&d.delete(y)}Wt(p,s)},S=new Set,O=p=>{d.has(p.id)||S.has(p.id)||(S.add(p.id),u.push(p))},k=p=>{for(let y of p)d.has(y.id)||(S.add(y.id),u.push(y))},L=qt(s,a);for(let p of L)O(p);let v=0,m=0,A=(p,y=!0)=>{if(p.length===0)return;let E=JSON.stringify(p),P=p.map(ge=>ge.id),T;try{T=fetch(l,{method:"POST",keepalive:!0,body:E,headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}})}catch(ge){be(p,a,s),k(p),m++,v=Date.now()+Ie(m);return}let ve=ge=>{if(ut(ge)!=="retry"){if(!ge.ok&&y){let oe=p.filter(ie=>ie.eventType!=="pageview");if(oe.length>0&&oe.length<p.length){g(p.filter(ie=>ie.eventType==="pageview").map(ie=>ie.id)),A(oe,!1);return}}g(P),m=0,v=0;return}be(p,a,s),k(p),m++,v=Date.now()+Ie(m)};T instanceof Promise?T.then(ve).catch(()=>{be(p,a,s),k(p),m++,v=Date.now()+Ie(m)}):ve(T)},x=typeof TextEncoder!="undefined"?new TextEncoder:null,K=p=>x?x.encode(p).length:p.length,b=p=>{let y=[],E=2;for(let P of p){let T=K(JSON.stringify(P))+1;if(y.length>0&&E+T>pr||y.length>=c)break;y.push(P),E+=T}return y},R=()=>{try{if(Date.now()<v)return;for(;u.length>0&&!(Date.now()<v);){let p=u.filter(E=>!d.has(E.id));if(u.length=0,p.length===0)break;let y=b(p);if(y.length===0)break;y.length<p.length&&u.push(...p.slice(y.length)),A(y)}}catch(p){}},Z=!0,I=null;I=setInterval(()=>{Z&&R()},i);let Q=()=>{document.visibilityState==="hidden"&&R()},$=()=>{R()};return document.addEventListener("visibilitychange",Q),window.addEventListener("pagehide",$),{push(p){O(p),u.length>=c&&R()},flush:R,destroy(){Z=!1,I!==null&&(clearInterval(I),I=null),document.removeEventListener("visibilitychange",Q),window.removeEventListener("pagehide",$),R()}}}var mr=200;function Ft(e){return`_snt_goal_retry_${e.slice(0,12)}`}var hr={send:()=>{},flush:()=>{},destroy:()=>{}};function yr(e){var t,n,r;if(typeof window=="undefined")return hr;let i=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,a=(r=e.maxPerFlush)!=null?r:5,l=Ft(e.apiKey),o=[],s=new Set,u=new Set,d=[],f=0,g=0,S=!1,O=b=>{for(s.delete(b.id),u.has(b.id)||(u.add(b.id),d.push(b.id));d.length>mr;){let R=d.shift();R&&u.delete(R)}Wt([b.id],l)},k=b=>{be([b],c,l),!u.has(b.id)&&!s.has(b.id)&&(s.add(b.id),o.push(b)),Date.now()>=f&&(g++,f=Date.now()+Ie(g))},L=b=>{let R;try{R=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(I){k(b);return}let Z=I=>{var Q;let $=ut(I);if($==="retry"){k(b);return}$==="dropped"&&((Q=e.onDrop)==null||Q.call(e,b,I.status)),O(b),g=0,f=0};R instanceof Promise?R.then(Z).catch(()=>k(b)):Z(R)},v=()=>{try{if(S||Date.now()<f)return;let b=0;for(;o.length>0&&b<a&&!(Date.now()<f);){let R=o.shift();s.delete(R.id),!u.has(R.id)&&(b++,L(R))}}catch(b){}},m=qt(l,c);for(let b of m)s.has(b.id)||(s.add(b.id),o.push(b));m.length>0&&be(m,c,l);let A=setInterval(v,i),x=()=>{document.visibilityState==="hidden"&&v()},K=()=>v();return document.addEventListener("visibilitychange",x),window.addEventListener("pagehide",K),{send(b){if(!S&&!(u.has(b.id)||s.has(b.id))){if(Date.now()<f){be([b],c,l),s.add(b.id),o.push(b);return}L(b)}},flush:v,destroy(){clearInterval(A),document.removeEventListener("visibilitychange",x),window.removeEventListener("pagehide",K),v(),S=!0}}}var vr=1800*1e3;function Ue(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function wr(e=vr,t){let n=new Map,r=`_snt_asgn${Ge(t)}_`,i=(o,s)=>`${r}${encodeURIComponent(o)}:${encodeURIComponent(s)}`,c=o=>{let s=o.slice(r.length),u=s.indexOf(":");if(u<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,u)),segment:decodeURIComponent(s.slice(u+1))}}catch(d){return null}},a=()=>{try{let o=[];for(let s=0;s<localStorage.length;s++){let u=localStorage.key(s);u!=null&&u.startsWith(r)&&o.push(u)}return o}catch(o){return[]}},l=o=>o.assignedAt+(o.ttlMs&&o.ttlMs>0?o.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let o of a())try{let s=localStorage.getItem(o);if(!s)continue;let u=JSON.parse(s);if(l(u)){localStorage.removeItem(o);continue}let d=c(o);if(!d)continue;n.set(Ue(d.componentId,d.segment),u)}catch(s){}})(),{get(o,s){let u=n.get(Ue(o,s));return u?l(u)?(n.delete(Ue(o,s)),null):u:null},set(o,s,u){let d=Ue(o,s);n.set(d,u);try{localStorage.setItem(i(o,s),JSON.stringify(u))}catch(f){}},invalidate(o){let s=`${encodeURIComponent(o)}:`;for(let u of[...n.keys()])u.startsWith(s)&&n.delete(u);for(let u of a()){let d=c(u);if((d==null?void 0:d.componentId)===o)try{localStorage.removeItem(u)}catch(f){}}},clear(){n.clear();for(let o of a())try{localStorage.removeItem(o)}catch(s){}}}}var We="_snt_snap:",br=["low","medium","high"];function He(e){try{let t=localStorage.getItem(We+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"||!br.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 Oe(e,t){try{localStorage.setItem(We+e,JSON.stringify(t))}catch(n){}}var ct="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Vt="[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.",Gt=!1,ze=!1;function Sr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Ar(e){var t;let n=zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",i=Sr(),c=Promise.resolve().then(()=>(Nt(),Mt)).then(o=>{let s=o;return s.LOCAL_ENGINE_AVAILABLE?(Gt||(Gt=!0,console.info(Vt)),s):(ze||(ze=!0,console.error(ct)),null)}).catch(()=>(ze||(ze=!0,console.error(ct)),null)),a=null;function l(o){let s=document.documentElement;s.dataset.sentientPersona===void 0&&(s.dataset.sentientPersona=o.persona,s.dataset.sentientConfidence=me(o.confidence))}return{isLocal:!0,async decide(o){var s,u,d;let f=await c;if(!f)return null;let g=f.createLocalEngine({sessionId:r,forcedPersona:i}).decide(o);return a=Ee(C({},g),{layoutOrder:(u=(s=g.layoutOrder)!=null?s:a==null?void 0:a.layoutOrder)!=null?u:null,slots:C(C({},(d=a==null?void 0:a.slots)!=null?d:{}),g.slots)}),Oe(e.apiKey||"local",{v:1,persona:a.persona,band:me(a.confidence),slots:a.slots,layoutOrder:a.layoutOrder,savedAt:Date.now()}),l(g),g},getSlotResult(o){var s,u,d;return(d=(u=a==null?void 0:a.slots[o])!=null?u:(s=e.initialSlots)==null?void 0:s[o])!=null?d:null},getPersona(){return a?{persona:a.persona,confidence:a.confidence,band:me(a.confidence)}:null},async assign(o,s){var u;let d=await c;return!d||!s||s.length===0?s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null:{variantId:(u=d.createLocalEngine({sessionId:r,forcedPersona:i}).decide({components:[{id:o,variantIds:s}]}).assignments[o])!=null?u:s[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function _e(e,t,n,r){let i=[];{let c=!1,a=[],l=()=>{if(c)return;let o=Date.now();for(a.push(o);a.length>0&&o-a[0]>500;)a.shift();a.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",l),i.push(()=>t.removeEventListener("click",l))}{let c=!1,a=l=>{if(c||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;c=!0;let o=typeof window!="undefined"?window.getSelection():null,s=o?o.toString().length:0;e("text_copy",{selectionLength:s})};document.addEventListener("copy",a),i.push(()=>document.removeEventListener("copy",a))}{let c=!1,a=!1,l=null,o=()=>{l!==null&&(clearTimeout(l),l=null)},s=()=>{c||!a||(o(),l=setTimeout(()=>{!c&&a&&(c=!0,e("scroll_hesitation"))},3e3))},u=()=>{o(),s()},d=g=>{for(let S of g)a=S.intersectionRatio>.3,a?s():o()},f=new IntersectionObserver(d,{threshold:[.3]});f.observe(t),window.addEventListener("scroll",u,{passive:!0}),i.push(()=>{f.disconnect(),window.removeEventListener("scroll",u),o()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,a=n!=null?n:Date.now(),l=()=>{if(c||document.visibilityState!=="hidden")return;let o=Date.now()-a;o<15e3&&(c=!0,e("tab_loss",{timeOnPage:o}))};document.addEventListener("visibilitychange",l),i.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let c of i)c()}}var Jt="https://api.sentient-ui.com/v1/events",Y=new Map,Yt=null;function xr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Er=3;function lt(){return Ut()}function qe(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function kr(){let e=new WeakMap,t=new Map,n=!1,r=(l,o,s)=>{let u=l.get(o);return s===null?u?!0:(l.set(o,new Set),!1):u?u.has(s)?!0:(u.add(s),!1):(l.set(o,new Set([s])),!1)},i=typeof window!="undefined"&&"event"in window,c=()=>{if(!i)return;let l=window.event;return typeof Event=="function"&&l instanceof Event?l:void 0},a=()=>{if(i){Promise.resolve().then(()=>{n=!1,t.clear()});return}let l=!1,o=()=>{l||(l=!0,n=!1,t.clear())};if(setTimeout(o,0),typeof MessageChannel=="function"){let s=new MessageChannel;s.port1.onmessage=()=>{s.port1.close(),s.port2.close(),o()},s.port2.postMessage(0)}};return{firedBefore(l,o){let s=c();if(s){let d=e.get(s);return d||(d=new Map,e.set(s,d)),r(d,l,o)}let u=r(t,l,o);return!u&&!n&&(n=!0,a()),u}}}var Xt=new Set;function Ir(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let i=!1,c,a=()=>{if(i)return;let s=qe();!s||s===c||(c=s,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${s}`))},l=[];for(let s of["pushState","replaceState"]){let u=r[s],d=function(...f){let g=u.apply(this,f);return a(),g};r[s]=d,l.push([s,u,d])}window.addEventListener("popstate",a);let o=qe();return o&&Xt.has(`${t}:${o}`)?c=o:a(),()=>{if(!i){i=!0,window.removeEventListener("popstate",a);for(let[s,u,d]of l)r[s]===d&&(r[s]=u)}}}var ke={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 Or(){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 Zt(e){return e.replace(/\/events\/?$/,"")}function he(){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 dt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Yt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=Y.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:i,upgrade:c}=r;if(!c||i.respectDoNotTrack!==!1&&he())return;let a=Ce(Ee(C({},i),{consent:!0}));c(a);let l=(t=Y.get(n))==null?void 0:t.dispose;Y.set(n,{config:Ee(C({},i),{consent:!0}),upgrade:null,dispose:l})}function _r(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Zt((t=e.ingestUrl)!=null?t:Jt),i={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(o,s,u){if(!n)return null;try{let d=new URLSearchParams({componentId:o});for(let g of s!=null?s:[])d.append("variantIds[]",g);let f=await fetch(`${r}/winner?${d.toString()}`,{headers:i});return f.ok?{variantId:(await f.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(d){return s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},a={track:o=>c.track(o),goal:((o,s,u,d)=>c.goal(o,s,u,d)),componentGoal:(o,s,u)=>c.componentGoal(o,s,u),identify:o=>c.identify(o),getAssignment:(o,s)=>c.getAssignment(o,s),assign:(o,s,u,d)=>c.assign(o,s,u,d),decide:o=>c.decide(o),getSlotResult:o=>c.getSlotResult(o),getPersona:()=>c.getPersona(),fetchWeights:()=>c.fetchWeights(),getGraph:()=>c.getGraph(),dispose:()=>c.dispose(),destroy:()=>c.destroy()};function l(o){c=o}return{proxy:a,setInner:l}}function Ce(e){var t,n,r,i,c,a,l,o,s;if(typeof window=="undefined")return ke;Yt=e.apiKey;let u=Y.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&he(),f=e.consent===!1||d,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return f?(Y.set(e.apiKey||"local",{config:e,upgrade:null}),ke):(Y.set(e.apiKey||"local",{config:e,upgrade:null}),Ar(e));if(f){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."),Y.set(e.apiKey,{config:e,upgrade:null}),ke;let{proxy:h,setInner:w}=_r(e);return Y.set(e.apiKey,{config:e,upgrade:d?null:w}),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."),ke;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ke;let S=(t=e.ingestUrl)!=null?t:Jt,O=Date.now(),k=zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),L=wr(void 0,e.apiKey),v=gr({ingestUrl:S,apiKey:e.apiKey}),m=Zt(S),A={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},x=new Set,K=yr({url:`${m}/goals`,apiKey:e.apiKey,headers:A,onDrop:(h,w)=>{if(!e.debug){if(x.has(w))return;x.add(w)}console.warn(`[sentient] goal dropped (HTTP ${w}) \u2014 this will not be retried. `+(w===400?"The session was not found: call init() and let the session upsert complete before firing goals.":w===401||w===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),b=Tt((n=navigator.userAgent)!=null?n:""),R=typeof window!="undefined"?window.location.origin:void 0,Z=Rt((r=document.referrer)!=null?r:"",R),I=(i=e.sessionSegment)!=null?i:`${b}:${Z}`,Q=new Map,$=new Map,p=null,y=h=>{for(let w of h)$.has(w.id)||$.set(w.id,st(w))};if(e.initialSlots)for(let[h,w]of Object.entries(e.initialSlots))$.set(h,w);let E=He(e.apiKey);if(E)for(let[h,w]of Object.entries(E.slots))$.has(h)||$.set(h,w);let P={low:.15,medium:.5,high:.85};if(e.initialPersona)p=C({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?p={persona:h.sentientPersona,confidence:(a=P[(c=h.sentientConfidence)!=null?c:"low"])!=null?a:.15}:E&&(p={persona:E.persona,confidence:(l=P[E.band])!=null?l:.15})}if(e.initialAssignments)for(let[h,w]of Object.entries(e.initialAssignments))L.set(h,I,{variantId:w,assignedAt:Date.now(),segment:I,confidence:1});let T=Promise.resolve(),ve=k.getSessionId();if(ve){let h=Pt((o=document.referrer)!=null?o:""),w=C(C(C({sessionId:ve,deviceClass:b,trafficSource:Z,referrerDomain:h,utmParams:Or(),timeOfDay:Dt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:k.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Lt((s=navigator.userAgent)!=null?s:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),D=async()=>{for(let z=0;;z++){try{let j=await fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(w),headers:A});if(j.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(j.ok||ut(j)==="dropped")return}catch(j){}if(z>=Er){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(j=>setTimeout(j,Ie(z+1)))}};try{T=D()}catch(z){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:v});let ge=kr(),oe=null,ie=!1,we={goal(h,w={},D=1,z=0){var j,G,ee,J,W,te,H;let ce=k.getSessionId();if(!ce)return;let M=xr(w)?w:{metadata:w},Me=[h,(j=M.externalId)!=null?j:"",(G=M.stepIndex)!=null?G:z,(ee=M.weight)!=null?ee:D].join("\0"),_=M.value!==void 0?`${M.value}\0${(J=M.currency)!=null?J:""}`:null;if(ge.firedBefore(Me,_)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let ue=lt(),Ne={sessionId:ce,name:h,metadata:(W=M.metadata)!=null?W:{},weight:(te=M.weight)!=null?te:D,stepIndex:(H=M.stepIndex)!=null?H:z,goalId:ue,value:M.value,currency:M.currency,externalId:M.externalId};e.debug&&console.log("[sentient] goal",Ne);let V={id:ue,body:JSON.stringify(Ne)};T.then(()=>K.send(V))},componentGoal(h,w,D){var z,j,G;let ee=k.getSessionId();if(!ee)return;let J=L.get(h,I),W=J?null:(z=$.get(h))!=null?z:null;if(!J&&W===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 te=J?J.variantId:Bt(W),H={id:lt(),sessionId:ee,projectId:e.apiKey,componentId:h,variantId:te,eventType:"goal_achieved",goalType:w,payload:C({reward:(j=D==null?void 0:D.reward)!=null?j:1,goalValue:D==null?void 0:D.value,currency:D==null?void 0:D.currency},(G=D==null?void 0:D.metadata)!=null?G:{}),timestamp:Date.now(),timeInSession:Date.now()-O,path:qe()};e.debug&&console.log("[sentient] componentGoal",H),T.then(()=>v.push(H))},identify(h){let w=k.getSessionId();w&&T.then(()=>{fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:w,userId:h,ephemeral:k.isEphemeral()}),headers:A}).catch(()=>{})})},track(h){let w=k.getSessionId();if(!w)return;let D=Ee(C({path:qe()},h),{id:lt(),sessionId:w,timestamp:Date.now(),timeInSession:Date.now()-O});e.debug&&console.log("[sentient] track",D),T.then(()=>v.push(D))},getAssignment(h,w){return L.get(h,w)},async assign(h,w,D,z){let j=k.getSessionId();if(!j)return null;let G=L.get(h,I);if(G&&(w!=null&&w.length||G.content!==void 0)){let W=G.ttlMs&&G.ttlMs>0?Math.max(0,G.assignedAt+G.ttlMs-Date.now()):0;return{variantId:G.variantId,assignmentTtlMs:W,content:G.content}}let ee=Q.get(h);if(ee)return ee;let J=(async()=>{await T;try{let W={sessionId:j,componentId:h,variantIds:w};z!==void 0?W.agentDataByVariant=z:D!==void 0&&(W.agentData=D);let te=await fetch(`${m}/assign`,{method:"POST",body:JSON.stringify(W),headers:A});if(!te.ok)return null;let H=await te.json();return L.set(h,I,C({variantId:H.variantId,assignedAt:Date.now(),segment:I,confidence:1,content:H.content},H.assignmentTtlMs&&H.assignmentTtlMs>0?{ttlMs:H.assignmentTtlMs}:{})),H}catch(W){return null}finally{Q.delete(h)}})();return Q.set(h,J),J},async decide(h){var w,D,z,j,G,ee,J,W,te;let H=k.getSessionId();if(!H)return null;let ce=(w=h.slots)!=null?w:[];await T;try{let M={sessionId:H};h.sections&&h.sections.length>0&&(M.sections=h.sections.map(V=>({id:V}))),M.components=(D=h.components)!=null?D:[],ce.length>0&&(M.slots=ce.map(it)),h.slotsFrom==="registry"&&(M.slotsFrom="registry"),h.v&&(M.v=h.v),e.persona&&(M.persona=e.persona);let Me=await fetch(`${m}/decide`,{method:"POST",body:JSON.stringify(M),headers:A});if(!Me.ok)return y(ce),null;let _=await Me.json(),ue={};for(let V of ce)ue[V.id]=(j=(z=_.slots)==null?void 0:z[V.id])!=null?j:st(V);if(_.slots)for(let[V,xe]of Object.entries(_.slots))V in ue||(ue[V]=xe);for(let[V,xe]of Object.entries(ue))$.set(V,xe);let Ne=p!=null&&p.persona!=="unknown";_.persona&&!(_.persona==="unknown"&&Ne)?p={persona:_.persona,confidence:(G=_.confidence)!=null?G:0}:p||(p={persona:"unknown",confidence:0});for(let[V,xe]of Object.entries((ee=_.assignments)!=null?ee:{}))L.set(V,I,{variantId:xe,assignedAt:Date.now(),segment:I,confidence:1});return Oe(e.apiKey,C(C({v:1,persona:p.persona,band:me(p.confidence),slots:Object.fromEntries($),layoutOrder:(J=_.layoutOrder)!=null?J:null,savedAt:Date.now()},_.slotConfig?{slotConfig:_.slotConfig}:{}),_.palette?{palette:_.palette}:{})),C(C(C(C({layoutOrder:(W=_.layoutOrder)!=null?W:null,assignments:(te=_.assignments)!=null?te:{},slots:ue,persona:p.persona,confidence:p.confidence},_.slotConfig?{slotConfig:_.slotConfig}:{}),_.goals?{goals:_.goals}:{}),_.sectionMap?{sectionMap:_.sectionMap}:{}),_.palette?{palette:_.palette}:{})}catch(M){return y(ce),null}},getSlotResult(h){var w;return(w=$.get(h))!=null?w:null},getPersona(){return p?{persona:p.persona,confidence:p.confidence,band:me(p.confidence)}:null},async fetchWeights(){var h;try{let w=await fetch(`${m}/weights`,{headers:A});return w.ok?(h=(await w.json()).components)!=null?h:[]:[]}catch(w){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;oe==null||oe(),ie=!0,v.destroy(),K.destroy(),((h=Y.get(e.apiKey))==null?void 0:h.dispose)===we.dispose&&Y.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;oe==null||oe(),ie=!0,v.destroy(),K.destroy(),k.destroy(),((h=Y.get(e.apiKey))==null?void 0:h.dispose)===we.dispose&&Y.delete(e.apiKey);try{localStorage.removeItem(We+e.apiKey),localStorage.removeItem(Ht(e.apiKey)),localStorage.removeItem(Ft(e.apiKey))}catch(w){}e.debug&&console.log("[sentient] destroyed")}};if(Y.set(e.apiKey,{config:e,upgrade:null,dispose:we.dispose}),oe=Ir(we,e.apiKey,h=>{T.then(()=>{ie||Xt.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=we)}return we}var Qt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Cr=[["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]],Lr=[["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 Tr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function en(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 Cr)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of Lr)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 tn(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:Tr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function nn(e){return en(tn(e)).type}$e();var Rr="section, header, footer, nav, main > div, [data-sentient-section]",Pr=2e4;function Dr(e){let t=Array.from(e.querySelectorAll(Rr)),n=t.filter(r=>t.filter(i=>i!==r&&r.contains(i)).length<2);return n.filter(r=>!n.some(i=>i!==r&&i.contains(r)))}function Br(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(i){}}var rn=()=>{};function on(e,t){var n,r,i,c,a,l,o,s,u;let d=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!d||typeof IntersectionObserver=="undefined"||he()||!t.apiKey)return rn;let f=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),g=Dr(d);if(g.length===0)return rn;let S=new Map,O=new Map,k=new Map;for(let p of g){let y=p.getAttribute("data-sentient-type"),E=y&&Qt.includes(y)?y:null,P=(c=E!=null?E:(i=t.typeOf)==null?void 0:i.call(t,p))!=null?c:nn(p),T=`nc-${P}`;S.set(p,T),O.set(T,P),E?k.set(T,"markup"):k.has(T)||k.set(T,"auto")}let L=(s=(o=(l=(a=d.defaultView)!=null?a:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:o.pathname)!=null?s:"/";Br(t.apiKey,f,L,[...O.entries()].map(([p,y])=>{var E;return{componentId:p,semanticType:y,source:(E=k.get(p))!=null?E:"auto"}}));let v=new Map,m=p=>{let y=v.get(p);return y||(y={ms:0,scroll:0,enterAt:null,intersecting:!1},v.set(p,y)),y},A=new IntersectionObserver(p=>{for(let y of p){let E=S.get(y.target);if(!E)continue;let P=m(E);y.isIntersecting?(P.intersecting=!0,P.enterAt=Date.now(),y.intersectionRatio>P.scroll&&(P.scroll=y.intersectionRatio)):(P.intersecting=!1,P.enterAt!=null&&(P.ms+=Date.now()-P.enterAt,P.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let p of S.keys())A.observe(p);let x=()=>{let p=Date.now();for(let[y,E]of v)if(E.enterAt!=null&&(E.ms+=p-E.enterAt,E.enterAt=null),!(E.ms<=0)){try{e.track({projectId:t.apiKey,componentId:y,eventType:"dwell",payload:{dwell_time:Math.round(E.ms),scroll_depth:Number(E.scroll.toFixed(2))}})}catch(P){}E.ms=0}},K=()=>{if(d.hidden)x();else{let p=Date.now();for(let y of v.values())y.intersecting&&(y.enterAt=p)}},b=!1,R=p=>{if(x(),p!=null&&p.persisted){b=!0;return}try{A.disconnect()}catch(y){}},Z=p=>{if(!(p!=null&&p.persisted)||!b)return;b=!1;let y=Date.now();for(let E of v.values())E.enterAt=E.intersecting&&!d.hidden?y:null};d.addEventListener("visibilitychange",K);let I=(u=d.defaultView)!=null?u:typeof window!="undefined"?window:void 0;I==null||I.addEventListener("pagehide",R),I==null||I.addEventListener("pageshow",Z);let Q=setInterval(()=>{if(d.hidden||b)return;x();let p=Date.now();for(let y of v.values())y.intersecting&&(y.enterAt=p)},Pr),$=[];return t.microSignals&&[...S.entries()].forEach(([p,y],E)=>{$.push(_e((P,T={})=>{try{e.track({projectId:t.apiKey,componentId:y,eventType:"micro_signal",payload:C({signalType:P},T)})}catch(ve){}},p,void 0,{tabLoss:E===0}))}),()=>{x(),clearInterval(Q),d.removeEventListener("visibilitychange",K),I==null||I.removeEventListener("pagehide",R),I==null||I.removeEventListener("pageshow",Z);for(let p of $)p();try{A.disconnect()}catch(p){}}}var Mr=["landing","ecommerce","saas","marketplace"];function Nr(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,i]of t){if(!Array.isArray(i)||i.length<2||i.length>6||!i.every(c=>typeof c=="string"))return null;n[r]=i}return n}function Kr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function $r(e){try{return e()}catch(t){return}}function Fe(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=Mr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[a,l]of Object.entries(t.slots)){if(typeof l!="object"||l===null)continue;let o=l,s=Nr(o.dims);if(!s||o.target!==void 0&&typeof o.target!="string")continue;let u=o.arms!==void 0?Kr(o.arms):null,d={dims:s};typeof o.target=="string"&&(d.target=o.target),u&&(d.arms=u),r[a]=d}let i={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(i.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(i.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(i.debug=!0),typeof t.registry=="boolean"&&(i.registry=t.registry),typeof t.editorSrc=="string"&&(i.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(i.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(i.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?$r(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(i.persona=c),Array.isArray(t.sections)){let a=t.sections.filter(l=>typeof l=="string"&&l.trim()!=="").slice(0,50);a.length>=2&&(i.sections=a)}return i}function sn(e){var n,r,i;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(i=t==null?void 0:t.pathname)!=null?i:""}function jr(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(),i=t.text.trim().toLowerCase();if(!(r===i||r.startsWith(i)||i.startsWith(r)))return!1}return!0}function an(e,t){return!!(e!=null&&e.urlMatch)&&!sn(t).includes(e.urlMatch)}var Gr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function de(e,t){var i;if(e.urlMatch&&!sn(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((i=e.dataAttr)!=null&&i.name)&&Gr.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&&!jr(r,e.fingerprint)?null:r}var ln={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"},Ur=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function cn(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Ur.test((t=n[1])!=null?t:""))return!1;return!0}var un=/^https:\/\//i,dn=new Map,pe=null;function zr(e){return e.replace(/["\\]/g,"\\$&")}function qr(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=[...dn.entries()].map(([n,r])=>`[data-snt-e="${zr(n)}"]{${r}}`).join(`
2
+ `)}function pn(e,t,n,r){var l;let i=!1,c=(l=t.moveBefore)!=null?l:t.moveAfter;if(c){let o=de(c,r);!o||o===e||o.parentElement!==e.parentElement||!e.parentElement?i=!0:t.moveBefore?e.parentElement.insertBefore(e,o):e.parentElement.insertBefore(e,o.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&un.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&un.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let a=[];if(t.hidden&&a.push("display:none !important"),t.style)for(let[o,s]of Object.entries(t.style)){let u=ln[o];u&&typeof s=="string"&&cn(s)&&a.push(`${u}:${s.trim()} !important`)}return a.length>0&&(e.setAttribute("data-snt-e",n),dn.set(n,a.join(";")),qr(r)),{anchorMiss:i}}var Le="data-sentient-block-arm",ne=null;function Te(e){ne=e!=null?e:null}var ae="data-sentient-blocks-hid",fn={none:"0",sm:"8px",md:"16px",lg:"24px"},pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},gn={sm:"0.875em",md:"1em",lg:"1.25em"},Wr={sm:"1.25em",md:"1.5em",lg:"2em"},Hr={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},mn={sm:"8px",md:"16px",lg:"32px"},Fr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Vr={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 hn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function yn(e,t){var n,r,i,c,a,l,o,s,u,d;try{switch(e.type){case"stack":case"grid":{let f=t.createElement("div");if(e.type==="stack"){let g=e;se(f,{display:"flex","flex-direction":g.direction,gap:fn[(n=g.gap)!=null?n:"md"],"align-items":g.align?pt[g.align]:void 0,"justify-content":g.justify?pt[g.justify]:void 0,"flex-wrap":g.wrap?"wrap":void 0})}else{let g=e,S=fn[(r=g.gap)!=null?r:"md"];se(f,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${g.columns-1} * ${S}) / ${g.columns})), 1fr))`,gap:S,"align-items":g.align?pt[g.align]:void 0})}for(let g of(i=e.children)!=null?i:[]){let S=yn(g,t);S&&f.appendChild(S)}return f}case"text":{let f=t.createElement("p");return f.textContent=e.value,se(f,X({margin:"0","font-size":e.size?gn[e.size]:void 0,"font-weight":e.weight?Vr[e.weight]:void 0,"text-align":e.align},hn(e.tone)))}case"heading":{let f=t.createElement(`h${e.level}`);return f.textContent=e.value,se(f,{margin:"0","font-size":Wr[(c=e.size)!=null?c:"md"],"text-align":e.align})}case"button":{let f=t.createElement("a");f.textContent=e.label,f.href=e.href,e.tag&&f.setAttribute("data-sentient-tag",e.tag);let g=(a=e.emphasis)!=null?a:"primary";return se(f,{display:"inline-block",padding:Hr[(l=e.size)!=null?l:"md"],"border-radius":(o=ne==null?void 0:ne.radius)!=null?o:"8px",font:"inherit","font-size":e.size?gn[e.size]:void 0,"text-decoration":g==="ghost"?"underline":"none",cursor:"pointer",background:g==="primary"?(s=ne==null?void 0:ne.primaryBg)!=null?s:"#111827":"transparent",color:g==="primary"?(u=ne==null?void 0:ne.primaryText)!=null?u:"#ffffff":"inherit",border:g==="secondary"?"1px solid currentColor":"none"})}case"link":{let f=t.createElement("a");return f.textContent=e.label,f.href=e.href,e.tag&&f.setAttribute("data-sentient-tag",e.tag),se(f,{color:"inherit","text-decoration":"underline"})}case"image":{let f=t.createElement("img");return f.src=e.src,f.alt=e.alt,se(f,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Fr[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let f=t.createElement("span");return f.textContent=e.value,se(f,X({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},hn(e.tone)))}case"spacer":return se(t.createElement("div"),{height:(d=mn[e.size])!=null?d:mn.md});default:return null}}catch(f){return null}}function vn(e,t,n,r){try{let i=new Set;for(let a of Array.from(e.children)){let l=a.getAttribute(Le);l!==null&&(t[l]===void 0?a.remove():i.add(l))}for(let[a,l]of Object.entries(t)){if(i.has(a))continue;let o=yn(l,r);if(!o)continue;let s=r.createElement("div");s.setAttribute(Le,a),s.style.display="none",s.appendChild(o),e.appendChild(s)}let c=n!==void 0&&t[n]!==void 0;for(let a of Array.from(e.children)){let l=a.getAttribute(Le),o=a;l!==null?o.style.display=c&&l===n?"":"none":c?o.hasAttribute(ae)||(o.setAttribute(ae,o.style.display),o.style.display="none"):o.hasAttribute(ae)&&(o.style.display=o.getAttribute(ae),o.removeAttribute(ae))}}catch(i){}}function Jr(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Le)!==null){n.remove();continue}n.hasAttribute(ae)&&(n.style.display=n.getAttribute(ae),n.removeAttribute(ae))}}catch(t){}}function Ve(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Le}]`)))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)||Jr(r)}catch(n){}}function Je(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Ye(e,t,n){var r;for(let[i,c]of Object.entries(t)){let a=e[i];if(!a||typeof a=="string")continue;let l=c.target?Array.from(n.querySelectorAll(c.target)):[n.documentElement];for(let o of l)for(let[s,u]of Object.entries(a))(r=c.dims[s])!=null&&r.includes(u)&&o.setAttribute(`data-${s}`,u)}}function Xe(e,t,n){for(let[r,i]of Object.entries(t)){let c=e[r];if(typeof c!="string"||!i.arms||!i.arms.includes(c))continue;let a=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let l of a)l.setAttribute("data-sentient-arm",c)}}function Ze(e,t,n,r){var l,o;let i=new Set,c=(l=r==null?void 0:r.contentAndOps)!=null?l:!0,a=[];for(let[s,u]of Object.entries(t)){if(an(u.locator,n))continue;let d;if(u.locator){let g=de(u.locator,n);d=g?[g]:[]}else u.target?d=Array.from(n.querySelectorAll(u.target)):d=[n.documentElement];(u.locator||u.target)&&d.length===0&&a.push(s);let f=e[s];for(let g of d){if(f!==void 0)if(typeof f=="string")g.setAttribute("data-sentient-arm",f),c&&((o=r==null?void 0:r.onApplied)==null||o.call(r,s,f,g));else for(let[S,O]of Object.entries(f))g.setAttribute(`data-${S}`,O);u.blocks&&!Xr(n)&&(vn(g,u.blocks,typeof f=="string"?f:void 0,n),i.add(g)),c&&(typeof u.content=="string"&&(g.textContent=u.content),u.ops&&pn(g,u.ops,s,n).anchorMiss&&!a.includes(s)&&a.push(s))}}return Ve(n,i),a}var Yr=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Xr(e){var t,n,r;try{let i=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return i?i.webdriver===!0?!0:Yr.test((r=i.userAgent)!=null?r:""):!1}catch(i){return!1}}var Zr=800;function Qe(e,t,n){let r=[];return n.forEach(({slotId:i,arm:c,el:a},l)=>{r.push(_e((f,g={})=>{try{e.track({projectId:t,componentId:i,variantId:c,eventType:"micro_signal",payload:X({signalType:f},g)})}catch(S){}},a,void 0,{tabLoss:l===0}));let o=null,s=0,u=()=>{s=Date.now(),o=setTimeout(()=>{try{e.track({projectId:t,componentId:i,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-s}})}catch(f){}o=null},Zr)},d=()=>{o!==null&&(clearTimeout(o),o=null)};a.addEventListener("mouseenter",u),a.addEventListener("mouseleave",d),r.push(()=>{a.removeEventListener("mouseenter",u),a.removeEventListener("mouseleave",d),o!==null&&clearTimeout(o)})}),()=>{for(let i of r)i()}}function Qr(e){var n,r,i;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(i=t==null?void 0:t.pathname)!=null?i:""}function eo(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 to(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}function wn(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function no(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(i=>typeof i=="string")):new Set}catch(n){return new Set}}function ro(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function ft(e,t,n,r){var L,v;let i=(L=n.defaultView)!=null?L:typeof window!="undefined"?window:null,c=to(r),a=no(i,c),l=m=>{let A=wn(m);if(!a.has(A))try{m.slotId?t.componentGoal(m.slotId,m.goalId):t.goal(m.goalId),a.add(A),ro(i,c,a)}catch(x){}},o=e.filter(m=>m.event==="click"),s=e.filter(m=>m.event==="form_submit"),u=e.filter(m=>m.event==="url_reached"),d=e.filter(m=>m.event==="scroll_depth"),f=(m,A)=>{if(!m.locator)return!1;let x=de(m.locator,n);return!!x&&(x===A||x.contains(A))},g=m=>{let A=m.target;if(!(!A||typeof A.closest!="function"))for(let x of o)f(x,A)&&l(x)},S=m=>{let A=m.target;if(A)for(let x of s)f(x,A)&&l(x)},O=()=>{if(u.length===0)return;let m=Qr(n);for(let A of u)A.urlPattern&&eo(A.urlPattern,m)&&l(A)},k=()=>{var x;let m=n.documentElement,A=m.scrollHeight>0?(m.scrollTop+m.clientHeight)/m.scrollHeight:0;for(let K of d)A>=((x=K.threshold)!=null?x:.75)&&l(K);d.every(K=>a.has(wn(K)))&&n.removeEventListener("scroll",k)};return n.addEventListener("click",g,!0),n.addEventListener("submit",S,!0),(v=n.defaultView)==null||v.addEventListener("popstate",O),O(),d.length>0&&(n.addEventListener("scroll",k,{passive:!0}),k()),{checkUrl:O,teardown:()=>{var m;n.removeEventListener("click",g,!0),n.removeEventListener("submit",S,!0),(m=n.defaultView)==null||m.removeEventListener("popstate",O),d.length>0&&n.removeEventListener("scroll",k)}}}var bn="__snt_editor_token";function Sn(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(bn):null}catch(e){return null}}function An(e){try{sessionStorage.setItem(bn,e)}catch(t){}}var mt="0.17.2",Ln=5e3,oo=50,io=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),q=null,B=null,le={},fe=null,F=null,Re=null,U=null,re=null,N=null,ye=null,xn=!1,gt=null,et=null,nt=null,De=!1,rt=!1,tt=!1;function Tn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function Se(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Ae(e,t){return q?(q.personaAttributes&&N&&Je(N.persona,N.band,e),Ye(le,q.slots,e),Xe(le,q.slots,e),fe?Ze(le,fe,e,t):(Ve(e,new Set),[])):[]}function Rn(e){var n;let t=new Map;for(let r of(n=q==null?void 0:q.sections)!=null?n:[])try{let i=e.querySelectorAll(r);i.length===1&&t.set(r,i[0])}catch(i){}return t}function ht(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Rn(t);if(n.size!==e.length)return;let r=[];for(let a of e){let l=n.get(a);if(!l)return;r.push(l)}let i=r[0].parentNode;if(!i||!r.every(a=>a.parentNode===i))return;let c=r.slice().sort((a,l)=>a.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let a=0;a<r.length;a++){let l=r[a];c[a]!==l&&(i.insertBefore(l,c[a]),c.splice(c.indexOf(l),1),c.splice(a,0,l))}}catch(n){}}function so(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 Be(){return!!(q&&B&&q.sectionCapture!==!1&&(q.consent!==!1||rt)&&!he())}function ao(){if(!B||!q||!Be()||re)return;let e=[];Ae(document,{contentAndOps:De,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),vt();try{U==null||U(),U=Qe(B,q.apiKey,e)}catch(t){}}function vt(){if(typeof document=="undefined"||!Be())return;let e;try{if(et&&et.length>0){let t=new Map;for(let n of et){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{re=on(B,X({apiKey:q.apiKey,apiBase:q.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),nt=window.location.pathname}catch(t){}}function wt(){try{let e=[];if(U==null||U(),U=null,Ae(document,{contentAndOps:De,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),ht(ye,document),e.length>0&&Be())try{U=Qe(B,q.apiKey,e)}catch(t){}try{typeof window!="undefined"&&nt!==null&&window.location.pathname!==nt&&Be()&&(re==null||re(),re=null,vt())}catch(t){}}catch(e){}}function En(){gt===null&&(gt=setTimeout(()=>{gt=null,wt();try{F==null||F.checkUrl()}catch(e){}},oo))}function kn(){if(!(xn||typeof window=="undefined"||typeof history=="undefined")){xn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,i,c){let a=n.call(this,r,i,c!=null?c:null);return En(),a}};e("pushState"),e("replaceState"),window.addEventListener("popstate",En)}catch(e){}}}function yt(e){let t={};for(let[n,r]of Object.entries(e.slots))t[n]=r.target?document.querySelectorAll(r.target).length:1;return t}function Pn(e){return new URLSearchParams(e).get("sentient_editor")}function lo(){try{let t=Array.from(document.getElementsByTagName("script")).find(n=>/snippet(\.global)?\.js/.test(n.src));if(t!=null&&t.src)return t.src.replace(/snippet(\.global)?\.js/,"editor.global.js")}catch(e){}return null}function co(e,t){var n,r,i,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let o=document.createElement("meta");o.name="referrer",o.content="no-referrer",o.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(o)}catch(o){}let a=(i=e.editorSrc)!=null?i:lo();if(!a){On();return}let l=document.createElement("script");l.src=a,l.async=!0,l.onerror=()=>On(),((c=document.head)!=null?c:document.documentElement).appendChild(l)}catch(a){}}var In="sentient-editor-load-notice";function On(){var e;try{if(typeof document=="undefined"||document.getElementById(In))return;let t=document.createElement("div");t.id=In,t.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(t.style,{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",cursor:"pointer"}),t.addEventListener("click",()=>t.remove()),((e=document.body)!=null?e:document.documentElement).appendChild(t),setTimeout(()=>t.remove(),1e4)}catch(t){}}function Dn(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let i=r.indexOf(":"),c=i===-1?"":r.slice(0,i),a=i===-1?"":r.slice(i+1);if(!(!c||!a))if(a.includes("=")){let l={};for(let o of a.split(",")){let[s,u]=o.split("=");s&&u&&(l[s]=u)}Object.keys(l).length&&(n[c]=l)}else n[c]=a}return Object.keys(n).length?n:null}function Bn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var _n="sentient-persona-preview-banner";function Cn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(_n))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),i=document.createElement("div");i.id=_n,i.setAttribute("role","status"),Object.assign(i.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",background:"#111827",color:"#fff",font:"13px/1 system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",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 a=document.createElement("button");a.type="button",a.textContent="Exit preview",Object.assign(a.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),a.addEventListener("click",()=>{try{let l=new URL(window.location.href);l.searchParams.delete("sentient_persona"),window.location.href=l.pathname+l.search+l.hash}catch(l){}}),i.appendChild(c),i.appendChild(a),((n=document.body)!=null?n:document.documentElement).appendChild(i)}catch(r){}}async function uo(e,t){var s,u,d,f,g,S,O,k,L,v;let n=(s=e.apiBase)!=null?s:"https://api.sentient-ui.com",i=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([m,A])=>({id:m,dims:A.dims}))},c=await Tn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(i)}).then(m=>m.ok?m.json():null).catch(()=>null),Ln);if(!c){Pe(e),Se(e,"persona preview: explain unavailable \u2014 page left as-is");return}let a=c;le=(d=a.slots)!=null?d:{},fe=(f=a.slotConfig)!=null?f:null,Te(a.palette);let l=(O=(S=(g=a.personaAttributes)==null?void 0:g.persona)!=null?S:a.persona)!=null?O:t,o=(L=(k=a.personaAttributes)==null?void 0:k.confidence)!=null?L:"high";N={persona:l,band:o},Ae(document),De=!0,Pe(e),a.recognized===!1?Cn(t,!0):Cn((v=a.personaDisplay)!=null?v:l)}function Pe(e){let t={goal(n,r){try{B==null||B.goal(n,r)}catch(i){}},componentGoal(n,r){try{B==null||B.componentGoal(n,r)}catch(i){}},grantConsent(){try{!B&&tt?(B=Ce({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona}),Re&&Re.length>0&&(F==null||F.teardown(),F=ft(Re,B,document,e.apiKey))):dt(e.apiKey),tt=!1}catch(n){}rt=!0;try{ao()}catch(n){}},revokeConsent(){try{re==null||re(),re=null,nt=null,U==null||U(),U=null,F==null||F.teardown(),F=null,rt=!1,tt=!0,B==null||B.destroy(),B=null}catch(n){}},reapply:wt,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=N==null?void 0:N.persona)!=null?n:null,band:(r=N==null?void 0:N.band)!=null?r:null,slots:le,matchCounts:yt(e),consent:e.consent!==!1}}};window.SentientSnippet=t;for(let n of io.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}async function Mn(){var e,t,n,r,i,c,a;try{let l=Fe(window.sentient);if(!l)return;q=l,De=!1,ye=null,Te(null),rt=!1,tt=!1,Re=null;let o=typeof window!="undefined"?Pn(window.location.search):null;if(o){An(o);try{let x=new URL(window.location.href);x.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",x.pathname+x.search+x.hash)}catch(x){}}let s=o!=null?o:Sn();if(s){co(l,s),Pe(l),Se(l,"editor mode");return}let u=typeof window!="undefined"?Dn(window.location.search):null;if(u){le=u,N=null,Ae(document),kn(),Pe(l),Se(l,"preview mode",u);return}let d=typeof window!="undefined"?Bn(window.location.search):null;if(d){await uo(l,d),Se(l,"persona preview",d);return}let f=(e=l.registry)!=null?e:Object.keys(l.slots).length===0,g=He(l.apiKey);g&&(N={persona:g.persona,band:g.band},le=g.slots,g.slotConfig&&(fe=g.slotConfig),g.palette&&Te(g.palette),Ae(document,{contentAndOps:!1}),g.layoutOrder&&(ye=g.layoutOrder,ht(ye,document)));let S=Ce({apiKey:l.apiKey,context:l.context,consent:l.consent,preConsentBehavior:l.preConsentBehavior,debug:l.debug,persona:l.persona});B=S,Pe(l),kn();let O=Object.entries(l.slots).map(([x,K])=>({id:x,dims:K.dims})),k=mt!=="0.0.0-dev"?{v:mt}:{},L=Array.from(Rn(document).keys()),v=await Tn(S.decide(X(X(X({slots:O},k),L.length>=2?{sections:L}:{}),f?{slotsFrom:"registry"}:{})),Ln);if(!v){Se(l,"decide timeout/null \u2014 snapshot state stands",yt(l));return}let m=S.getPersona();m?N={persona:m.persona,band:m.band}:v.persona&&(N={persona:v.persona,band:"low"}),le=v.slots,f?fe=(t=v.slotConfig)!=null?t:null:v.slotConfig&&(fe=v.slotConfig),v.palette&&Te(v.palette);let A=[];if(so(l,Ae(document,{onApplied:(x,K,b)=>A.push({slotId:x,arm:K,el:b})})),ye=(n=v.layoutOrder)!=null?n:ye,ht(ye,document),De=!0,Re=(r=v.goals)!=null?r:null,v.goals&&v.goals.length>0&&l.consent!==!1&&B)try{F==null||F.teardown(),F=ft(v.goals,B,document,l.apiKey)}catch(x){}if(et=(i=v.sectionMap)!=null?i:null,Be()){vt();try{U==null||U(),U=Qe(B,l.apiKey,A)}catch(x){}}Se(l,"applied",{persona:N,slots:le,matches:yt(l)}),Oe(l.apiKey,X(X({v:1,persona:(c=N==null?void 0:N.persona)!=null?c:v.persona,band:(a=N==null?void 0:N.band)!=null?a:"low",slots:v.slots,layoutOrder:v.layoutOrder,savedAt:Date.now()},fe?{slotConfig:fe}:{}),v.palette?{palette:v.palette}:{}))}catch(l){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Mn())}return Gn(po);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
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.21.2"
27
+ "@sentientui/core": "0.21.3"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",