@sentientui/snippet 0.15.1 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,8 @@ page is left exactly as it was.
14
14
  apiKey: 'pk_your_key', // sentient-ui.com → Settings
15
15
  context: 'landing', // 'landing' | 'ecommerce' | 'saas' | 'marketplace'
16
16
  personaAttributes: true, // sets data-sentient-persona / -confidence on <html>
17
+ persona: () => window.myApp?.role, // optional: declare the role your site already knows
18
+ // (string or function; must be a key from Settings → Personas)
17
19
  slots: {
18
20
  hero: { dims: { tone: ['calm', 'urgent'] }, target: '#hero' },
19
21
  },
@@ -40,6 +42,12 @@ html[data-sentient-persona='deal_seeker'] .discount-banner { display: block; }
40
42
  The first value of each dim is your baseline (what you show today). Decisions are locked per
41
43
  session and learned per visitor type on the SentientUI API: Visit 1 learns, Visit 2 converts.
42
44
 
45
+ `persona` declares the visitor type your site already knows (e.g. a role from your own
46
+ session state) instead of waiting for it to be inferred. It must be a key in the project's
47
+ persona vocabulary (dashboard → Settings → Personas); unrecognized values are ignored
48
+ server-side and surfaced in the dashboard so you can add them. Keep it a low-cardinality
49
+ role label — never a user id or email.
50
+
43
51
  The snippet also captures per-section attention (visible time + scroll depth) and behavioral
44
52
  signals by default — that's what builds audience profiles with zero tagging. Add
45
53
  `sectionCapture: false` to `window.sentient` to turn it off; it never runs for a Do-Not-Track,
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var ke=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var rt=(e,t,n)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t)=>{for(var n in t||(t={}))ot.call(t,n)&&rt(e,n,t[n]);if(nt)for(var n of nt(t))mn.call(t,n)&&rt(e,n,t[n]);return e};var it=(e,t)=>()=>(e&&(t=e(e=0)),t);var st=(e,t)=>{for(var n in t)ke(e,n,{get:t[n],enumerable:!0})},hn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of gn(t))!ot.call(e,a)&&a!==n&&ke(e,a,{get:()=>t[a],enumerable:!(r=fn(t,a))||r.enumerable});return e};var yn=e=>hn(ke({},"__esModule",{value:!0}),e);var vn,bn,wn,at,Sn,An,lt,R,be,Ee=it(()=>{"use strict";vn=Object.defineProperty,bn=Object.defineProperties,wn=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable,lt=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&lt(e,n,t[n]);if(at)for(var n of at(t))An.call(t,n)&&lt(e,n,t[n]);return e},be=(e,t)=>bn(e,wn(t))});var yt={};st(yt,{LOCAL_ENGINE_AVAILABLE:()=>kn,createLocalEngine:()=>En});function En(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var kn,vt=it(()=>{"use strict";kn=!1});var Rr={};st(Rr,{applyPersonaAttributes:()=>Ne,applyRegistrySlots:()=>Be,applySlotArms:()=>Ke,applySlotAttributes:()=>je,parseEditorToken:()=>an,parsePersonaPreview:()=>cn,parsePreview:()=>ln,parseSnippetConfig:()=>$e,reapply:()=>tt,run:()=>dn,version:()=>Ze});Ee();function Ce(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function ct(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 a=n.slice(0,r);if(a in t)return null;t[a]=n.slice(r+1)}return t}function ze(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 Ce(e.baseline);if(typeof e.baseline=="string")return e.baseline;let a={};for(let[o,l]of Object.entries((n=e.dims)!=null?n:{}))a[o]=(r=l[0])!=null?r:"";return Ce(a)}function ut(e,t){var n,r;return e.dims!=null?(r=(n=ct(t))!=null?n:ct(ze(e)))!=null?r:{}:t}function fe(e){return e>=.3?e<.7?"medium":"high":"low"}var xn=["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 dt(e){return In(e)!==null}function In(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=xn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function pt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function ft(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(a){}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 gt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function mt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ve(e){return R(R(R({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 Je(e){let t=Ve(e);return ut(t,ze(t))}function ht(e){return typeof e=="string"?e:Ce(e)}Ee();function wt(){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 St(e){return e?`_${e.slice(0,12)}`:""}var Cn="_snt_uid",On=365,_n="_snt_uid";function Tn(){return wt()}function Rn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Ln(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Pn(e){try{return localStorage.getItem(e)}catch(t){return null}}function Dn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Mn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function $n(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Nn(e){try{sessionStorage.removeItem(e)}catch(t){}}function jn(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 Kn(e){try{localStorage.removeItem(e)}catch(t){}}function Bn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Un={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function At(e){var t,n,r,a,o,l;if(typeof window=="undefined")return Un;let d=St(e==null?void 0:e.apiKey),s=(t=e==null?void 0:e.cookieName)!=null?t:`${Cn}${d}`,i=`${_n}${d}`,c=((n=e==null?void 0:e.cookieTTLDays)!=null?n:On)*24*60*60,u=h=>h&&h.length>0?h:null,m=(l=(o=(a=(r=u(Rn(s)))!=null?r:u(Pn(i)))!=null?a:u(Mn(i)))!=null?o:u(e==null?void 0:e.ssrSessionId))!=null?l:Tn();Ln(s,m,c);let v=Dn(i,m),E=jn(s),C=v?!1:$n(i,m),k=!v&&!E&&!C;return{getSessionId:()=>m,isEphemeral:()=>k,destroy:()=>{m=null,Bn(s),Kn(i),Nn(i)}}}function Te(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function xt(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 It(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 Re(e,t,n){try{let r=(()=>{try{let o=localStorage.getItem(n);if(!o)return[];let l=JSON.parse(o);return Array.isArray(l)?l:[]}catch(o){return[]}})(),a=new Map;for(let o of r)a.set(o.id,o);for(let o of e)a.set(o.id,o);localStorage.setItem(n,JSON.stringify([...a.values()].slice(-t)))}catch(r){}}function kt(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let a=new Set(e),o=r.filter(l=>!a.has(l.id));if(o.length===r.length)return;o.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(o))}catch(n){}}var Gn=500,qn=56*1024;function Et(e){return`_snt_retry_${e.slice(0,12)}`}var Wn={push:()=>{},flush:()=>{},destroy:()=>{}};function zn(e){var t,n,r;if(typeof window=="undefined")return Wn;let a=(t=e.flushIntervalMs)!=null?t:5e3,o=(n=e.maxBatchSize)!=null?n:20,l=(r=e.maxRetrySize)!=null?r:100,d=e.ingestUrl,s=e.apiKey,i=Et(s),c=[],u=new Set,m=[],v=g=>{for(let I of g)E.delete(I),!u.has(I)&&(u.add(I),m.push(I));for(;m.length>Gn;){let I=m.shift();I&&u.delete(I)}kt(g,i)},E=new Set,C=g=>{u.has(g.id)||E.has(g.id)||(E.add(g.id),c.push(g))},k=g=>{for(let I of g)u.has(I.id)||(E.add(I.id),c.push(I))},h=It(i,l);for(let g of h)C(g);let f=0,x=0,O=(g,I=!0)=>{if(g.length===0)return;let ee=JSON.stringify(g),q=g.map(H=>H.id),te;try{te=fetch(d,{method:"POST",keepalive:!0,body:ee,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(H){Re(g,l,i),k(g),x++,f=Date.now()+Te(x);return}let ce=H=>{if(xt(H)!=="retry"){if(!H.ok&&I){let ue=g.filter(J=>J.eventType!=="pageview");if(ue.length>0&&ue.length<g.length){v(g.filter(J=>J.eventType==="pageview").map(J=>J.id)),O(ue,!1);return}}v(q),x=0,f=0;return}Re(g,l,i),k(g),x++,f=Date.now()+Te(x)};te instanceof Promise?te.then(ce).catch(()=>{Re(g,l,i),k(g),x++,f=Date.now()+Te(x)}):ce(te)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,b=g=>G?G.encode(g).length:g.length,P=g=>{let I=[],ee=2;for(let q of g){let te=b(JSON.stringify(q))+1;if(I.length>0&&ee+te>qn||I.length>=o)break;I.push(q),ee+=te}return I},$=()=>{try{if(Date.now()<f)return;for(;c.length>0&&!(Date.now()<f);){let g=c.filter(ee=>!u.has(ee.id));if(c.length=0,g.length===0)break;let I=P(g);if(I.length===0)break;I.length<g.length&&c.push(...g.slice(I.length)),O(I)}}catch(g){}},D=!0,S=null;S=setInterval(()=>{D&&$()},a);let A=()=>{document.visibilityState==="hidden"&&$()},w=()=>{$()};return document.addEventListener("visibilitychange",A),window.addEventListener("pagehide",w),{push(g){C(g),c.length>=o&&$()},flush:$,destroy(){D=!1,S!==null&&(clearInterval(S),S=null),document.removeEventListener("visibilitychange",A),window.removeEventListener("pagehide",w),$()}}}var Vn=200;function Ct(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Jn={send:()=>{},flush:()=>{},destroy:()=>{}};function Fn(e){var t,n,r;if(typeof window=="undefined")return Jn;let a=(t=e.flushIntervalMs)!=null?t:5e3,o=(n=e.maxRetrySize)!=null?n:100,l=(r=e.maxPerFlush)!=null?r:5,d=Ct(e.apiKey),s=[],i=new Set,c=new Set,u=[],m=0,v=0,E=!1,C=b=>{for(i.delete(b.id),c.has(b.id)||(c.add(b.id),u.push(b.id));u.length>Vn;){let P=u.shift();P&&c.delete(P)}kt([b.id],d)},k=b=>{Re([b],o,d),!c.has(b.id)&&!i.has(b.id)&&(i.add(b.id),s.push(b)),v++,m=Date.now()+Te(v)},h=b=>{let P;try{P=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(D){k(b);return}let $=D=>{var S;let A=xt(D);if(A==="retry"){k(b);return}A==="dropped"&&((S=e.onDrop)==null||S.call(e,b,D.status)),C(b),v=0,m=0};P instanceof Promise?P.then($).catch(()=>k(b)):$(P)},f=()=>{try{if(E||Date.now()<m)return;let b=0;for(;s.length>0&&b<l&&!(Date.now()<m);){let P=s.shift();i.delete(P.id),!c.has(P.id)&&(b++,h(P))}}catch(b){}};for(let b of It(d,o))i.has(b.id)||(i.add(b.id),s.push(b));let x=setInterval(f,a),O=()=>{document.visibilityState==="hidden"&&f()},G=()=>f();return document.addEventListener("visibilitychange",O),window.addEventListener("pagehide",G),{send(b){if(!E&&!(c.has(b.id)||i.has(b.id))){if(Date.now()<m){i.add(b.id),s.push(b);return}h(b)}},flush:f,destroy(){clearInterval(x),document.removeEventListener("visibilitychange",O),window.removeEventListener("pagehide",G),f(),E=!0}}}var Hn=1800*1e3;function Oe(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Yn(e=Hn,t){let n=new Map,r=`_snt_asgn${St(t)}_`,a=(s,i)=>`${r}${encodeURIComponent(s)}:${encodeURIComponent(i)}`,o=s=>{let i=s.slice(r.length),c=i.indexOf(":");if(c<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,c)),segment:decodeURIComponent(i.slice(c+1))}}catch(u){return null}},l=()=>{try{let s=[];for(let i=0;i<localStorage.length;i++){let c=localStorage.key(i);c!=null&&c.startsWith(r)&&s.push(c)}return s}catch(s){return[]}},d=s=>s.assignedAt+(s.ttlMs&&s.ttlMs>0?s.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let s of l())try{let i=localStorage.getItem(s);if(!i)continue;let c=JSON.parse(i);if(d(c)){localStorage.removeItem(s);continue}let u=o(s);if(!u)continue;n.set(Oe(u.componentId,u.segment),c)}catch(i){}})(),{get(s,i){let c=n.get(Oe(s,i));return c?d(c)?(n.delete(Oe(s,i)),null):c:null},set(s,i,c){let u=Oe(s,i);n.set(u,c);try{localStorage.setItem(a(s,i),JSON.stringify(c))}catch(m){}},invalidate(s){let i=`${encodeURIComponent(s)}:`;for(let c of[...n.keys()])c.startsWith(i)&&n.delete(c);for(let c of l()){let u=o(c);if((u==null?void 0:u.componentId)===s)try{localStorage.removeItem(c)}catch(m){}}},clear(){n.clear();for(let s of l())try{localStorage.removeItem(s)}catch(i){}}}}var Pe="_snt_snap:",Xn=["low","medium","high"];function De(e){try{let t=localStorage.getItem(Pe+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"||!Xn.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 Se(e,t){try{localStorage.setItem(Pe+e,JSON.stringify(t))}catch(n){}}var He="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ot="[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.",bt=!1,_e=!1;function Zn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Qn(e){var t;let n=At({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",a=Zn(),o=Promise.resolve().then(()=>(vt(),yt)).then(s=>{let i=s;return i.LOCAL_ENGINE_AVAILABLE?(bt||(bt=!0,console.info(Ot)),i):(_e||(_e=!0,console.error(He)),null)}).catch(()=>(_e||(_e=!0,console.error(He)),null)),l=null;function d(s){let i=document.documentElement;i.dataset.sentientPersona===void 0&&(i.dataset.sentientPersona=s.persona,i.dataset.sentientConfidence=fe(s.confidence))}return{isLocal:!0,async decide(s){var i,c,u;let m=await o;if(!m)return null;let v=m.createLocalEngine({sessionId:r,forcedPersona:a}).decide(s);return l=be(R({},v),{layoutOrder:(c=(i=v.layoutOrder)!=null?i:l==null?void 0:l.layoutOrder)!=null?c:null,slots:R(R({},(u=l==null?void 0:l.slots)!=null?u:{}),v.slots)}),Se(e.apiKey||"local",{v:1,persona:l.persona,band:fe(l.confidence),slots:l.slots,layoutOrder:l.layoutOrder,savedAt:Date.now()}),d(v),v},getSlotResult(s){var i,c,u;return(u=(c=l==null?void 0:l.slots[s])!=null?c:(i=e.initialSlots)==null?void 0:i[s])!=null?u:null},getPersona(){return l?{persona:l.persona,confidence:l.confidence,band:fe(l.confidence)}:null},async assign(s,i){var c;let u=await o;return!u||!i||i.length===0?i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null:{variantId:(c=u.createLocalEngine({sessionId:r,forcedPersona:a}).decide({components:[{id:s,variantIds:i}]}).assignments[s])!=null?c:i[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Ae(e,t,n,r){let a=[];{let o=!1,l=[],d=()=>{if(o)return;let s=Date.now();for(l.push(s);l.length>0&&s-l[0]>500;)l.shift();l.length>=3&&(o=!0,e("rage_click"))};t.addEventListener("click",d),a.push(()=>t.removeEventListener("click",d))}{let o=!1,l=d=>{if(o||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;o=!0;let s=typeof window!="undefined"?window.getSelection():null,i=s?s.toString().length:0;e("text_copy",{selectionLength:i})};document.addEventListener("copy",l),a.push(()=>document.removeEventListener("copy",l))}{let o=!1,l=!1,d=null,s=()=>{d!==null&&(clearTimeout(d),d=null)},i=()=>{o||!l||(s(),d=setTimeout(()=>{!o&&l&&(o=!0,e("scroll_hesitation"))},3e3))},c=()=>{s(),i()},u=v=>{for(let E of v)l=E.intersectionRatio>.3,l?i():s()},m=new IntersectionObserver(u,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",c,{passive:!0}),a.push(()=>{m.disconnect(),window.removeEventListener("scroll",c),s()})}if((r==null?void 0:r.tabLoss)!==!1){let o=!1,l=n!=null?n:Date.now(),d=()=>{if(o||document.visibilityState!=="hidden")return;let s=Date.now()-l;s<15e3&&(o=!0,e("tab_loss",{timeOnPage:s}))};document.addEventListener("visibilitychange",d),a.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let o of a)o()}}var _t="https://api.sentient-ui.com/v1/events",z=new Map,Tt=null;function er(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Fe(){return wt()}function Le(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function tr(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 Rt=new Set;function nr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let a=!1,o,l=()=>{if(a)return;let i=Le();!i||i===o||(o=i,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${i}`))},d=[];for(let i of["pushState","replaceState"]){let c=r[i],u=function(...m){let v=c.apply(this,m);return l(),v};r[i]=u,d.push([i,c,u])}window.addEventListener("popstate",l);let s=Le();return s&&Rt.has(`${t}:${s}`)?o=s:l(),()=>{if(!a){a=!0,window.removeEventListener("popstate",l);for(let[i,c,u]of d)r[i]===u&&(r[i]=c)}}}var we={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 rr(){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 Lt(e){return e.replace(/\/events\/?$/,"")}function ge(){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 Ye(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Tt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=z.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:a,upgrade:o}=r;if(!o||a.respectDoNotTrack!==!1&&ge())return;let l=Me(be(R({},a),{consent:!0}));o(l);let d=(t=z.get(n))==null?void 0:t.dispose;z.set(n,{config:be(R({},a),{consent:!0}),upgrade:null,dispose:d})}function or(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Lt((t=e.ingestUrl)!=null?t:_t),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(s,i,c){if(!n)return null;try{let u=new URLSearchParams({componentId:s});for(let v of i!=null?i:[])u.append("variantIds[]",v);let m=await fetch(`${r}/winner?${u.toString()}`,{headers:a});return m.ok?{variantId:(await m.json()).variantId,assignmentTtlMs:0}:i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}catch(u){return i!=null&&i[0]?{variantId:i[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:s=>o.track(s),goal:((s,i,c,u)=>o.goal(s,i,c,u)),componentGoal:(s,i,c)=>o.componentGoal(s,i,c),identify:s=>o.identify(s),getAssignment:(s,i)=>o.getAssignment(s,i),assign:(s,i,c,u)=>o.assign(s,i,c,u),decide:s=>o.decide(s),getSlotResult:s=>o.getSlotResult(s),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function d(s){o=s}return{proxy:l,setInner:d}}function Me(e){var t,n,r,a,o,l,d,s,i;if(typeof window=="undefined")return we;Tt=e.apiKey;let c=z.get(e.apiKey||"local");if(c!=null&&c.dispose)try{c.dispose()}catch(p){}let u=e.respectDoNotTrack!==!1&&ge(),m=e.consent===!1||u,v=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!v&&e.localMode!==!1)return m?(z.set(e.apiKey||"local",{config:e,upgrade:null}),we):(z.set(e.apiKey||"local",{config:e,upgrade:null}),Qn(e));if(m){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."),z.set(e.apiKey,{config:e,upgrade:null}),we;let{proxy:p,setInner:y}=or(e);return z.set(e.apiKey,{config:e,upgrade:u?null:y}),p}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."),we;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),we;let E=(t=e.ingestUrl)!=null?t:_t,C=Date.now(),k=At({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),h=Yn(void 0,e.apiKey),f=zn({ingestUrl:E,apiKey:e.apiKey}),x=Lt(E),O={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},G=Fn({url:`${x}/goals`,apiKey:e.apiKey,headers:O,onDrop:(p,y)=>{e.debug&&console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),b=pt((n=navigator.userAgent)!=null?n:""),P=typeof window!="undefined"?window.location.origin:void 0,$=ft((r=document.referrer)!=null?r:"",P),D=(a=e.sessionSegment)!=null?a:`${b}:${$}`,S=new Map,A=new Map,w=null,g=p=>{for(let y of p)A.has(y.id)||A.set(y.id,Je(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))A.set(p,y);let I=De(e.apiKey);if(I)for(let[p,y]of Object.entries(I.slots))A.has(p)||A.set(p,y);let ee={low:.15,medium:.5,high:.85};if(e.initialPersona)w=R({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?w={persona:p.sentientPersona,confidence:(l=ee[(o=p.sentientConfidence)!=null?o:"low"])!=null?l:.15}:I&&(w={persona:I.persona,confidence:(d=ee[I.band])!=null?d:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))h.set(p,D,{variantId:y,assignedAt:Date.now(),segment:D,confidence:1});let q=Promise.resolve(),te=k.getSessionId();if(te){let p=gt((s=document.referrer)!=null?s:""),y=R(R({sessionId:te,deviceClass:b,trafficSource:$,referrerDomain:p,utmParams:rr(),timeOfDay:mt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:k.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||dt((i=navigator.userAgent)!=null?i:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{q=fetch(`${x}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:O}).then(_=>{_.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")}).catch(()=>{})}catch(_){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let ce=new Set,H=null,ue=!1,J={goal(p,y={},_=1,Y=0){var X,N,Z,W,K,ne;let B=k.getSessionId();if(!B)return;let U=er(y)?y:{metadata:y},re=`${p}\0${(X=U.externalId)!=null?X:""}\0${(N=U.stepIndex)!=null?N:Y}\0${(Z=U.weight)!=null?Z:_}`;if(ce.has(re)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}ce.add(re),ce.size===1&&tr(ce);let ye=Fe(),T={sessionId:B,name:p,metadata:(W=U.metadata)!=null?W:{},weight:(K=U.weight)!=null?K:_,stepIndex:(ne=U.stepIndex)!=null?ne:Y,goalId:ye,value:U.value,currency:U.currency,externalId:U.externalId};e.debug&&console.log("[sentient] goal",T);let de={id:ye,body:JSON.stringify(T)};q.then(()=>G.send(de))},componentGoal(p,y,_){var Y,X,N;let Z=k.getSessionId();if(!Z)return;let W=h.get(p,D),K=W?null:(Y=A.get(p))!=null?Y:null;if(!W&&K===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let ne=W?W.variantId:ht(K),B={id:Fe(),sessionId:Z,projectId:e.apiKey,componentId:p,variantId:ne,eventType:"goal_achieved",goalType:y,payload:R({reward:(X=_==null?void 0:_.reward)!=null?X:1,goalValue:_==null?void 0:_.value,currency:_==null?void 0:_.currency},(N=_==null?void 0:_.metadata)!=null?N:{}),timestamp:Date.now(),timeInSession:Date.now()-C,path:Le()};e.debug&&console.log("[sentient] componentGoal",B),q.then(()=>f.push(B))},identify(p){let y=k.getSessionId();y&&q.then(()=>{fetch(`${x}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:k.isEphemeral()}),headers:O}).catch(()=>{})})},track(p){let y=k.getSessionId();if(!y)return;let _=be(R({path:Le()},p),{id:Fe(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",_),q.then(()=>f.push(_))},getAssignment(p,y){return h.get(p,y)},async assign(p,y,_,Y){let X=k.getSessionId();if(!X)return null;let N=h.get(p,D);if(N&&(y!=null&&y.length||N.content!==void 0)){let K=N.ttlMs&&N.ttlMs>0?Math.max(0,N.assignedAt+N.ttlMs-Date.now()):0;return{variantId:N.variantId,assignmentTtlMs:K,content:N.content}}let Z=S.get(p);if(Z)return Z;let W=(async()=>{await q;try{let K={sessionId:X,componentId:p,variantIds:y};Y!==void 0?K.agentDataByVariant=Y:_!==void 0&&(K.agentData=_);let ne=await fetch(`${x}/assign`,{method:"POST",body:JSON.stringify(K),headers:O});if(!ne.ok)return null;let B=await ne.json();return h.set(p,D,R({variantId:B.variantId,assignedAt:Date.now(),segment:D,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B}catch(K){return null}finally{S.delete(p)}})();return S.set(p,W),W},async decide(p){var y,_,Y,X,N,Z,W,K,ne;let B=k.getSessionId();if(!B)return null;let U=(y=p.slots)!=null?y:[];await q;try{let re={sessionId:B};p.sections&&p.sections.length>0&&(re.sections=p.sections.map(F=>({id:F}))),re.components=(_=p.components)!=null?_:[],U.length>0&&(re.slots=U.map(Ve)),p.slotsFrom==="registry"&&(re.slotsFrom="registry"),p.v&&(re.v=p.v);let ye=await fetch(`${x}/decide`,{method:"POST",body:JSON.stringify(re),headers:O});if(!ye.ok)return g(U),null;let T=await ye.json(),de={};for(let F of U)de[F.id]=(X=(Y=T.slots)==null?void 0:Y[F.id])!=null?X:Je(F);if(T.slots)for(let[F,ve]of Object.entries(T.slots))F in de||(de[F]=ve);for(let[F,ve]of Object.entries(de))A.set(F,ve);let pn=w!=null&&w.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&pn)?w={persona:T.persona,confidence:(N=T.confidence)!=null?N:0}:w||(w={persona:"unknown",confidence:0});for(let[F,ve]of Object.entries((Z=T.assignments)!=null?Z:{}))h.set(F,D,{variantId:ve,assignedAt:Date.now(),segment:D,confidence:1});return Se(e.apiKey,R({v:1,persona:w.persona,band:fe(w.confidence),slots:Object.fromEntries(A),layoutOrder:(W=T.layoutOrder)!=null?W:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{})),R(R(R({layoutOrder:(K=T.layoutOrder)!=null?K:null,assignments:(ne=T.assignments)!=null?ne:{},slots:de,persona:w.persona,confidence:w.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{})}catch(re){return g(U),null}},getSlotResult(p){var y;return(y=A.get(p))!=null?y:null},getPersona(){return w?{persona:w.persona,confidence:w.confidence,band:fe(w.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${x}/weights`,{headers:O});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;H==null||H(),ue=!0,f.destroy(),G.destroy(),((p=z.get(e.apiKey))==null?void 0:p.dispose)===J.dispose&&z.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;H==null||H(),ue=!0,f.destroy(),G.destroy(),k.destroy(),((p=z.get(e.apiKey))==null?void 0:p.dispose)===J.dispose&&z.delete(e.apiKey);try{localStorage.removeItem(Pe+e.apiKey),localStorage.removeItem(Et(e.apiKey)),localStorage.removeItem(Ct(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(z.set(e.apiKey,{config:e,upgrade:null,dispose:J.dispose}),H=nr(J,e.apiKey,p=>{q.then(()=>{ue||Rt.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=J)}return J}var Pt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],ir=[["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]],sr=[["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 ar(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Dt(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 ir)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of sr)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 Mt(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:ar(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function $t(e){return Dt(Mt(e)).type}Ee();var jt="section, header, footer, nav, main > div, [data-sentient-section]";function lr(e){var t;return((t=e.parentElement)==null?void 0:t.closest(jt))!=null}function cr(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(a){}}var Nt=()=>{};function Kt(e,t){var n,r,a,o,l,d,s,i,c;let u=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!u||typeof IntersectionObserver=="undefined"||ge()||!t.apiKey)return Nt;let m=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),v=Array.from(u.querySelectorAll(jt)).filter(S=>!lr(S));if(v.length===0)return Nt;let E=new Map,C=new Map,k=new Map;for(let S of v){let A=S.getAttribute("data-sentient-type"),w=A&&Pt.includes(A)?A:null,g=(o=w!=null?w:(a=t.typeOf)==null?void 0:a.call(t,S))!=null?o:$t(S),I=`nc-${g}`;E.set(S,I),C.set(I,g),w?k.set(I,"markup"):k.has(I)||k.set(I,"auto")}let h=(i=(s=(d=(l=u.defaultView)!=null?l:typeof window!="undefined"?window:void 0)==null?void 0:d.location)==null?void 0:s.pathname)!=null?i:"/";cr(t.apiKey,m,h,[...C.entries()].map(([S,A])=>{var w;return{componentId:S,semanticType:A,source:(w=k.get(S))!=null?w:"auto"}}));let f=new Map,x=S=>{let A=f.get(S);return A||(A={ms:0,scroll:0,enterAt:null,intersecting:!1},f.set(S,A)),A},O=new IntersectionObserver(S=>{for(let A of S){let w=E.get(A.target);if(!w)continue;let g=x(w);A.isIntersecting?(g.intersecting=!0,g.enterAt=Date.now(),A.intersectionRatio>g.scroll&&(g.scroll=A.intersectionRatio)):(g.intersecting=!1,g.enterAt!=null&&(g.ms+=Date.now()-g.enterAt,g.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let S of E.keys())O.observe(S);let G=()=>{let S=Date.now();for(let[A,w]of f)if(w.enterAt!=null&&(w.ms+=S-w.enterAt,w.enterAt=null),!(w.ms<=0)){try{e.track({projectId:t.apiKey,componentId:A,eventType:"dwell",payload:{dwell_time:Math.round(w.ms),scroll_depth:Number(w.scroll.toFixed(2))}})}catch(g){}w.ms=0}},b=()=>{if(u.hidden)G();else{let S=Date.now();for(let A of f.values())A.intersecting&&(A.enterAt=S)}},P=()=>{G();try{O.disconnect()}catch(S){}};u.addEventListener("visibilitychange",b);let $=(c=u.defaultView)!=null?c:typeof window!="undefined"?window:void 0;$==null||$.addEventListener("pagehide",P);let D=[];return t.microSignals&&[...E.entries()].forEach(([S,A],w)=>{D.push(Ae((g,I={})=>{try{e.track({projectId:t.apiKey,componentId:A,eventType:"micro_signal",payload:R({signalType:g},I)})}catch(ee){}},S,void 0,{tabLoss:w===0}))}),()=>{G(),u.removeEventListener("visibilitychange",b),$==null||$.removeEventListener("pagehide",P);for(let S of D)S();try{O.disconnect()}catch(S){}}}var ur=["landing","ecommerce","saas","marketplace"];function dr(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,a]of t){if(!Array.isArray(a)||a.length<2||a.length>6||!a.every(o=>typeof o=="string"))return null;n[r]=a}return n}function pr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function $e(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=ur.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[o,l]of Object.entries(t.slots)){if(typeof l!="object"||l===null)continue;let d=l,s=dr(d.dims);if(!s||d.target!==void 0&&typeof d.target!="string")continue;let i=d.arms!==void 0?pr(d.arms):null,c={dims:s};typeof d.target=="string"&&(c.target=d.target),i&&(c.arms=i),r[o]=c}let a={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};return typeof t.consent=="boolean"&&(a.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(a.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(a.debug=!0),typeof t.registry=="boolean"&&(a.registry=t.registry),typeof t.editorSrc=="string"&&(a.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(a.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(a.sectionCapture=t.sectionCapture),a}function Bt(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function fr(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(),a=t.text.trim().toLowerCase();if(!(r===a||r.startsWith(a)||a.startsWith(r)))return!1}return!0}function Ut(e,t){return!!(e!=null&&e.urlMatch)&&!Bt(t).includes(e.urlMatch)}var gr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function se(e,t){var a;if(e.urlMatch&&!Bt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((a=e.dataAttr)!=null&&a.name)&&gr.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!fr(r,e.fingerprint)?null:r}var Gt={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"},mr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function qt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!mr.test((t=n[1])!=null?t:""))return!1;return!0}var Wt=/^https:\/\//i,zt=new Map,ae=null;function hr(e){return e.replace(/["\\]/g,"\\$&")}function yr(e){var t;(!ae||!ae.isConnected)&&(ae=e.querySelector("style[data-sentient-ops]"),ae||(ae=e.createElement("style"),ae.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(ae))),ae.textContent=[...zt.entries()].map(([n,r])=>`[data-snt-e="${hr(n)}"]{${r}}`).join(`
2
- `)}function Vt(e,t,n,r){var d;let a=!1,o=(d=t.moveBefore)!=null?d:t.moveAfter;if(o){let s=se(o,r);!s||s===e||s.parentElement!==e.parentElement||!e.parentElement?a=!0:t.moveBefore?e.parentElement.insertBefore(e,s):e.parentElement.insertBefore(e,s.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Wt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Wt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let l=[];if(t.hidden&&l.push("display:none !important"),t.style)for(let[s,i]of Object.entries(t.style)){let c=Gt[s];c&&typeof i=="string"&&qt(i)&&l.push(`${c}:${i.trim()} !important`)}return l.length>0&&(e.setAttribute("data-snt-e",n),zt.set(n,l.join(";")),yr(r)),{anchorMiss:a}}function Ne(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function je(e,t,n){var r;for(let[a,o]of Object.entries(t)){let l=e[a];if(!l||typeof l=="string")continue;let d=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let s of d)for(let[i,c]of Object.entries(l))(r=o.dims[i])!=null&&r.includes(c)&&s.setAttribute(`data-${i}`,c)}}function Ke(e,t,n){for(let[r,a]of Object.entries(t)){let o=e[r];if(typeof o!="string"||!a.arms||!a.arms.includes(o))continue;let l=a.target?Array.from(n.querySelectorAll(a.target)):[n.documentElement];for(let d of l)d.setAttribute("data-sentient-arm",o)}}function Be(e,t,n,r){var l,d;let a=(l=r==null?void 0:r.contentAndOps)!=null?l:!0,o=[];for(let[s,i]of Object.entries(t)){if(Ut(i.locator,n))continue;let c;if(i.locator){let m=se(i.locator,n);c=m?[m]:[]}else i.target?c=Array.from(n.querySelectorAll(i.target)):c=[n.documentElement];(i.locator||i.target)&&c.length===0&&o.push(s);let u=e[s];for(let m of c){if(u!==void 0)if(typeof u=="string")m.setAttribute("data-sentient-arm",u),a&&((d=r==null?void 0:r.onApplied)==null||d.call(r,s,u,m));else for(let[v,E]of Object.entries(u))m.setAttribute(`data-${v}`,E);a&&(typeof i.content=="string"&&(m.textContent=i.content),i.ops&&Vt(m,i.ops,s,n).anchorMiss&&!o.includes(s)&&o.push(s))}}return o}var vr=800;function Ue(e,t,n){let r=[];return n.forEach(({slotId:a,arm:o,el:l},d)=>{r.push(Ae((m,v={})=>{try{e.track({projectId:t,componentId:a,variantId:o,eventType:"micro_signal",payload:pe({signalType:m},v)})}catch(E){}},l,void 0,{tabLoss:d===0}));let s=null,i=0,c=()=>{i=Date.now(),s=setTimeout(()=>{try{e.track({projectId:t,componentId:a,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-i}})}catch(m){}s=null},vr)},u=()=>{s!==null&&(clearTimeout(s),s=null)};l.addEventListener("mouseenter",c),l.addEventListener("mouseleave",u),r.push(()=>{l.removeEventListener("mouseenter",c),l.removeEventListener("mouseleave",u),s!==null&&clearTimeout(s)})}),()=>{for(let a of r)a()}}function br(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function wr(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}/`)}var Jt="_snt_fired_goals";function Sr(e){try{let t=e==null?void 0:e.sessionStorage.getItem(Jt);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(r=>typeof r=="string")):new Set}catch(t){return new Set}}function Ar(e,t){try{e==null||e.sessionStorage.setItem(Jt,JSON.stringify([...t]))}catch(n){}}function Ft(e,t,n){var C,k;let r=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,a=Sr(r),o=h=>{if(!a.has(h.goalId)){a.add(h.goalId),Ar(r,a);try{h.slotId?t.componentGoal(h.slotId,h.goalId):t.goal(h.goalId)}catch(f){}}},l=e.filter(h=>h.event==="click"),d=e.filter(h=>h.event==="form_submit"),s=e.filter(h=>h.event==="url_reached"),i=e.filter(h=>h.event==="scroll_depth"),c=(h,f)=>{if(!h.locator)return!1;let x=se(h.locator,n);return!!x&&(x===f||x.contains(f))},u=h=>{let f=h.target;if(!(!f||typeof f.closest!="function"))for(let x of l)c(x,f)&&o(x)},m=h=>{let f=h.target;if(f)for(let x of d)c(x,f)&&o(x)},v=()=>{if(s.length===0)return;let h=br(n);for(let f of s)f.urlPattern&&wr(f.urlPattern,h)&&o(f)},E=()=>{var x;let h=n.documentElement,f=h.scrollHeight>0?(h.scrollTop+h.clientHeight)/h.scrollHeight:0;for(let O of i)f>=((x=O.threshold)!=null?x:.75)&&o(O);i.every(O=>a.has(O.goalId))&&n.removeEventListener("scroll",E)};return n.addEventListener("click",u,!0),n.addEventListener("submit",m,!0),(k=n.defaultView)==null||k.addEventListener("popstate",v),v(),i.length>0&&(n.addEventListener("scroll",E,{passive:!0}),E()),{checkUrl:v,teardown:()=>{var h;n.removeEventListener("click",u,!0),n.removeEventListener("submit",m,!0),(h=n.defaultView)==null||h.removeEventListener("popstate",v),i.length>0&&n.removeEventListener("scroll",E)}}}var Ht="__snt_editor_token";function Yt(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Ht):null}catch(e){return null}}function Xt(e){try{sessionStorage.setItem(Ht,e)}catch(t){}}var Ze="0.15.1",on=5e3,xr=50,Ir=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),V=null,M=null,ie={},le=null,Q=null,j=null,oe=null,L=null,Zt=!1,Xe=null,Ge=null,qe=null,xe=!1,We=!1;function sn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function me(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function he(e,t){return V?(V.personaAttributes&&L&&Ne(L.persona,L.band,e),je(ie,V.slots,e),Ke(ie,V.slots,e),le?Be(ie,le,e,t):[]):[]}function kr(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ie(){return!!(V&&M&&V.sectionCapture!==!1&&(V.consent!==!1||We)&&!ge())}function Er(){if(!M||!V||!Ie()||oe)return;let e=[];he(document,{contentAndOps:xe,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),et();try{j==null||j(),j=Ue(M,V.apiKey,e)}catch(t){}}function et(){if(typeof document=="undefined"||!Ie())return;let e;try{if(Ge&&Ge.length>0){let t=new Map;for(let n of Ge){if(n.urlMatch!==window.location.pathname)continue;let r=se(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{oe=Kt(M,pe({apiKey:V.apiKey,apiBase:V.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),qe=window.location.pathname}catch(t){}}function tt(){try{let e=[];if(j==null||j(),j=null,he(document,{contentAndOps:xe,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&Ie())try{j=Ue(M,V.apiKey,e)}catch(t){}try{typeof window!="undefined"&&qe!==null&&window.location.pathname!==qe&&Ie()&&(oe==null||oe(),oe=null,et())}catch(t){}}catch(e){}}function Qt(){Xe===null&&(Xe=setTimeout(()=>{Xe=null,tt();try{Q==null||Q.checkUrl()}catch(e){}},xr))}function en(){if(!(Zt||typeof window=="undefined"||typeof history=="undefined")){Zt=!0;try{let e=t=>{let n=history[t];history[t]=function(r,a,o){let l=n.call(this,r,a,o!=null?o:null);return Qt(),l}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Qt)}catch(e){}}}function Qe(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 an(e){return new URLSearchParams(e).get("sentient_editor")}function Cr(){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 Or(e,t){var n,r,a,o;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let s=document.createElement("meta");s.name="referrer",s.content="no-referrer",s.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(s)}catch(s){}let l=(a=e.editorSrc)!=null?a:Cr();if(!l){nn();return}let d=document.createElement("script");d.src=l,d.async=!0,d.onerror=()=>nn(),((o=document.head)!=null?o:document.documentElement).appendChild(d)}catch(l){}}var tn="sentient-editor-load-notice";function nn(){var e;try{if(typeof document=="undefined"||document.getElementById(tn))return;let t=document.createElement("div");t.id=tn,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 ln(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let a=r.indexOf(":"),o=a===-1?"":r.slice(0,a),l=a===-1?"":r.slice(a+1);if(!(!o||!l))if(l.includes("=")){let d={};for(let s of l.split(",")){let[i,c]=s.split("=");i&&c&&(d[i]=c)}Object.keys(d).length&&(n[o]=d)}else n[o]=l}return Object.keys(n).length?n:null}function cn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var rn="sentient-persona-preview-banner";function _r(e){var t;try{if(typeof document=="undefined"||document.getElementById(rn))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=rn,r.setAttribute("role","status"),Object.assign(r.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 a=document.createElement("span");a.textContent=`Previewing as ${n}`;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 l=new URL(window.location.href);l.searchParams.delete("sentient_persona"),window.location.href=l.pathname+l.search+l.hash}catch(l){}}),r.appendChild(a),r.appendChild(o),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function Tr(e,t){var i,c,u,m,v,E,C,k,h;let n=(i=e.apiBase)!=null?i:"https://api.sentient-ui.com",a=((c=e.registry)!=null?c:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,x])=>({id:f,dims:x.dims}))},o=await sn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(a)}).then(f=>f.ok?f.json():null).catch(()=>null),on);if(!o){me(e,"persona preview: explain unavailable \u2014 page left as-is");return}let l=o;ie=(u=l.slots)!=null?u:{},le=(m=l.slotConfig)!=null?m:null;let d=(C=(E=(v=l.personaAttributes)==null?void 0:v.persona)!=null?E:l.persona)!=null?C:t,s=(h=(k=l.personaAttributes)==null?void 0:k.confidence)!=null?h:"high";L={persona:d,band:s},he(document),xe=!0,un(e),_r(d)}function un(e){let t={goal(n,r){try{M==null||M.goal(n,r)}catch(a){}},componentGoal(n,r){try{M==null||M.componentGoal(n,r)}catch(a){}},grantConsent(){try{Ye(e.apiKey)}catch(n){}We=!0;try{Er()}catch(n){}},revokeConsent(){try{oe==null||oe(),oe=null,qe=null,j==null||j(),j=null,Q==null||Q.teardown(),Q=null,We=!1,M==null||M.destroy()}catch(n){}},reapply:tt,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=L==null?void 0:L.persona)!=null?n:null,band:(r=L==null?void 0:L.band)!=null?r:null,slots:ie,matchCounts:Qe(e),consent:e.consent!==!1}}};window.SentientSnippet=t;for(let n of Ir.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}async function dn(){var e,t,n,r,a;try{let o=$e(window.sentient);if(!o)return;V=o,xe=!1,We=!1;let l=typeof window!="undefined"?an(window.location.search):null;if(l){Xt(l);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let d=l!=null?l:Yt();if(d){Or(o,d),me(o,"editor mode");return}let s=typeof window!="undefined"?ln(window.location.search):null;if(s){ie=s,L=null,he(document),en(),me(o,"preview mode",s);return}let i=typeof window!="undefined"?cn(window.location.search):null;if(i){await Tr(o,i),me(o,"persona preview",i);return}let c=(e=o.registry)!=null?e:Object.keys(o.slots).length===0,u=De(o.apiKey);u&&(L={persona:u.persona,band:u.band},ie=u.slots,u.slotConfig&&(le=u.slotConfig),he(document,{contentAndOps:!1}));let m=Me({apiKey:o.apiKey,context:o.context,consent:o.consent,preConsentBehavior:o.preConsentBehavior,debug:o.debug});M=m,un(o),en();let v=Object.entries(o.slots).map(([f,x])=>({id:f,dims:x.dims})),E=Ze!=="0.0.0-dev"?{v:Ze}:{},C=await sn(m.decide(pe(pe({slots:v},E),c?{slotsFrom:"registry"}:{})),on);if(!C){me(o,"decide timeout/null \u2014 snapshot state stands",Qe(o));return}let k=m.getPersona();k?L={persona:k.persona,band:k.band}:C.persona&&(L={persona:C.persona,band:"low"}),ie=C.slots,c?le=(t=C.slotConfig)!=null?t:null:C.slotConfig&&(le=C.slotConfig);let h=[];if(kr(o,he(document,{onApplied:(f,x,O)=>h.push({slotId:f,arm:x,el:O})})),xe=!0,C.goals&&C.goals.length>0&&o.consent!==!1&&M)try{Q==null||Q.teardown(),Q=Ft(C.goals,M,document)}catch(f){}if(Ge=(n=C.sectionMap)!=null?n:null,Ie()){et();try{j==null||j(),j=Ue(M,o.apiKey,h)}catch(f){}}me(o,"applied",{persona:L,slots:ie,matches:Qe(o)}),Se(o.apiKey,pe({v:1,persona:(r=L==null?void 0:L.persona)!=null?r:C.persona,band:(a=L==null?void 0:L.band)!=null?a:"low",slots:C.slots,layoutOrder:C.layoutOrder,savedAt:Date.now()},le?{slotConfig:le}:{}))}catch(o){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,dn())}return yn(Rr);})();
1
+ "use strict";var SentientSnippet=(()=>{var ke=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var rt=(e,t,n)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t)=>{for(var n in t||(t={}))ot.call(t,n)&&rt(e,n,t[n]);if(nt)for(var n of nt(t))mn.call(t,n)&&rt(e,n,t[n]);return e};var it=(e,t)=>()=>(e&&(t=e(e=0)),t);var st=(e,t)=>{for(var n in t)ke(e,n,{get:t[n],enumerable:!0})},hn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of gn(t))!ot.call(e,a)&&a!==n&&ke(e,a,{get:()=>t[a],enumerable:!(r=fn(t,a))||r.enumerable});return e};var yn=e=>hn(ke({},"__esModule",{value:!0}),e);var vn,bn,wn,at,Sn,An,lt,R,be,Ie=it(()=>{"use strict";vn=Object.defineProperty,bn=Object.defineProperties,wn=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable,lt=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&lt(e,n,t[n]);if(at)for(var n of at(t))An.call(t,n)&&lt(e,n,t[n]);return e},be=(e,t)=>bn(e,wn(t))});var yt={};st(yt,{LOCAL_ENGINE_AVAILABLE:()=>Cn,createLocalEngine:()=>On});function On(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Cn,vt=it(()=>{"use strict";Cn=!1});var Dr={};st(Dr,{applyPersonaAttributes:()=>Ne,applyRegistrySlots:()=>Be,applySlotArms:()=>Ke,applySlotAttributes:()=>je,parseEditorToken:()=>an,parsePersonaPreview:()=>cn,parsePreview:()=>ln,parseSnippetConfig:()=>$e,reapply:()=>tt,run:()=>dn,version:()=>Ze});Ie();var xn=["buyer","researcher","deal_seeker","browser"];var En={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Ce(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function ct(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 a=n.slice(0,r);if(a in t)return null;t[a]=n.slice(r+1)}return t}function We(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 Ce(e.baseline);if(typeof e.baseline=="string")return e.baseline;let a={};for(let[o,l]of Object.entries((n=e.dims)!=null?n:{}))a[o]=(r=l[0])!=null?r:"";return Ce(a)}function ut(e,t){var n,r;return e.dims!=null?(r=(n=ct(t))!=null?n:ct(We(e)))!=null?r:{}:t}function fe(e){return e>=.3?e<.7?"medium":"high":"low"}var Nr=xn.map(e=>({key:e,displayName:En[e]}));var kn=["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 dt(e){return In(e)!==null}function In(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=kn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function pt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function ft(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(a){}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 gt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function mt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ve(e){return R(R(R({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 Fe(e){let t=Ve(e);return ut(t,We(t))}function ht(e){return typeof e=="string"?e:Ce(e)}Ie();function wt(){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 St(e){return e?`_${e.slice(0,12)}`:""}var _n="_snt_uid",Rn=365,Tn="_snt_uid";function Ln(){return wt()}function Pn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Dn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Mn(e){try{return localStorage.getItem(e)}catch(t){return null}}function $n(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Nn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function jn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Kn(e){try{sessionStorage.removeItem(e)}catch(t){}}function Bn(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 Un(e){try{localStorage.removeItem(e)}catch(t){}}function Gn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var qn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function At(e){var t,n,r,a,o,l;if(typeof window=="undefined")return qn;let d=St(e==null?void 0:e.apiKey),i=(t=e==null?void 0:e.cookieName)!=null?t:`${_n}${d}`,s=`${Tn}${d}`,c=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Rn)*24*60*60,u=h=>h&&h.length>0?h:null,m=(l=(o=(a=(r=u(Pn(i)))!=null?r:u(Mn(s)))!=null?a:u(Nn(s)))!=null?o:u(e==null?void 0:e.ssrSessionId))!=null?l:Ln();Dn(i,m,c);let v=$n(s,m),I=Bn(i),C=v?!1:jn(s,m),k=!v&&!I&&!C;return{getSessionId:()=>m,isEphemeral:()=>k,destroy:()=>{m=null,Gn(i),Un(s),Kn(s)}}}function Re(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function xt(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 Et(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 Te(e,t,n){try{let r=(()=>{try{let o=localStorage.getItem(n);if(!o)return[];let l=JSON.parse(o);return Array.isArray(l)?l:[]}catch(o){return[]}})(),a=new Map;for(let o of r)a.set(o.id,o);for(let o of e)a.set(o.id,o);localStorage.setItem(n,JSON.stringify([...a.values()].slice(-t)))}catch(r){}}function kt(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let a=new Set(e),o=r.filter(l=>!a.has(l.id));if(o.length===r.length)return;o.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(o))}catch(n){}}var zn=500,Wn=56*1024;function It(e){return`_snt_retry_${e.slice(0,12)}`}var Vn={push:()=>{},flush:()=>{},destroy:()=>{}};function Fn(e){var t,n,r;if(typeof window=="undefined")return Vn;let a=(t=e.flushIntervalMs)!=null?t:5e3,o=(n=e.maxBatchSize)!=null?n:20,l=(r=e.maxRetrySize)!=null?r:100,d=e.ingestUrl,i=e.apiKey,s=It(i),c=[],u=new Set,m=[],v=g=>{for(let E of g)I.delete(E),!u.has(E)&&(u.add(E),m.push(E));for(;m.length>zn;){let E=m.shift();E&&u.delete(E)}kt(g,s)},I=new Set,C=g=>{u.has(g.id)||I.has(g.id)||(I.add(g.id),c.push(g))},k=g=>{for(let E of g)u.has(E.id)||(I.add(E.id),c.push(E))},h=Et(s,l);for(let g of h)C(g);let f=0,x=0,O=(g,E=!0)=>{if(g.length===0)return;let te=JSON.stringify(g),q=g.map(H=>H.id),ne;try{ne=fetch(d,{method:"POST",keepalive:!0,body:te,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(H){Te(g,l,s),k(g),x++,f=Date.now()+Re(x);return}let ce=H=>{if(xt(H)!=="retry"){if(!H.ok&&E){let ue=g.filter(F=>F.eventType!=="pageview");if(ue.length>0&&ue.length<g.length){v(g.filter(F=>F.eventType==="pageview").map(F=>F.id)),O(ue,!1);return}}v(q),x=0,f=0;return}Te(g,l,s),k(g),x++,f=Date.now()+Re(x)};ne instanceof Promise?ne.then(ce).catch(()=>{Te(g,l,s),k(g),x++,f=Date.now()+Re(x)}):ce(ne)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,b=g=>G?G.encode(g).length:g.length,P=g=>{let E=[],te=2;for(let q of g){let ne=b(JSON.stringify(q))+1;if(E.length>0&&te+ne>Wn||E.length>=o)break;E.push(q),te+=ne}return E},$=()=>{try{if(Date.now()<f)return;for(;c.length>0&&!(Date.now()<f);){let g=c.filter(te=>!u.has(te.id));if(c.length=0,g.length===0)break;let E=P(g);if(E.length===0)break;E.length<g.length&&c.push(...g.slice(E.length)),O(E)}}catch(g){}},D=!0,S=null;S=setInterval(()=>{D&&$()},a);let A=()=>{document.visibilityState==="hidden"&&$()},w=()=>{$()};return document.addEventListener("visibilitychange",A),window.addEventListener("pagehide",w),{push(g){C(g),c.length>=o&&$()},flush:$,destroy(){D=!1,S!==null&&(clearInterval(S),S=null),document.removeEventListener("visibilitychange",A),window.removeEventListener("pagehide",w),$()}}}var Jn=200;function Ct(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Hn={send:()=>{},flush:()=>{},destroy:()=>{}};function Yn(e){var t,n,r;if(typeof window=="undefined")return Hn;let a=(t=e.flushIntervalMs)!=null?t:5e3,o=(n=e.maxRetrySize)!=null?n:100,l=(r=e.maxPerFlush)!=null?r:5,d=Ct(e.apiKey),i=[],s=new Set,c=new Set,u=[],m=0,v=0,I=!1,C=b=>{for(s.delete(b.id),c.has(b.id)||(c.add(b.id),u.push(b.id));u.length>Jn;){let P=u.shift();P&&c.delete(P)}kt([b.id],d)},k=b=>{Te([b],o,d),!c.has(b.id)&&!s.has(b.id)&&(s.add(b.id),i.push(b)),v++,m=Date.now()+Re(v)},h=b=>{let P;try{P=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(D){k(b);return}let $=D=>{var S;let A=xt(D);if(A==="retry"){k(b);return}A==="dropped"&&((S=e.onDrop)==null||S.call(e,b,D.status)),C(b),v=0,m=0};P instanceof Promise?P.then($).catch(()=>k(b)):$(P)},f=()=>{try{if(I||Date.now()<m)return;let b=0;for(;i.length>0&&b<l&&!(Date.now()<m);){let P=i.shift();s.delete(P.id),!c.has(P.id)&&(b++,h(P))}}catch(b){}};for(let b of Et(d,o))s.has(b.id)||(s.add(b.id),i.push(b));let x=setInterval(f,a),O=()=>{document.visibilityState==="hidden"&&f()},G=()=>f();return document.addEventListener("visibilitychange",O),window.addEventListener("pagehide",G),{send(b){if(!I&&!(c.has(b.id)||s.has(b.id))){if(Date.now()<m){s.add(b.id),i.push(b);return}h(b)}},flush:f,destroy(){clearInterval(x),document.removeEventListener("visibilitychange",O),window.removeEventListener("pagehide",G),f(),I=!0}}}var Xn=1800*1e3;function Oe(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Zn(e=Xn,t){let n=new Map,r=`_snt_asgn${St(t)}_`,a=(i,s)=>`${r}${encodeURIComponent(i)}:${encodeURIComponent(s)}`,o=i=>{let s=i.slice(r.length),c=s.indexOf(":");if(c<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,c)),segment:decodeURIComponent(s.slice(c+1))}}catch(u){return null}},l=()=>{try{let i=[];for(let s=0;s<localStorage.length;s++){let c=localStorage.key(s);c!=null&&c.startsWith(r)&&i.push(c)}return i}catch(i){return[]}},d=i=>i.assignedAt+(i.ttlMs&&i.ttlMs>0?i.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let i of l())try{let s=localStorage.getItem(i);if(!s)continue;let c=JSON.parse(s);if(d(c)){localStorage.removeItem(i);continue}let u=o(i);if(!u)continue;n.set(Oe(u.componentId,u.segment),c)}catch(s){}})(),{get(i,s){let c=n.get(Oe(i,s));return c?d(c)?(n.delete(Oe(i,s)),null):c:null},set(i,s,c){let u=Oe(i,s);n.set(u,c);try{localStorage.setItem(a(i,s),JSON.stringify(c))}catch(m){}},invalidate(i){let s=`${encodeURIComponent(i)}:`;for(let c of[...n.keys()])c.startsWith(s)&&n.delete(c);for(let c of l()){let u=o(c);if((u==null?void 0:u.componentId)===i)try{localStorage.removeItem(c)}catch(m){}}},clear(){n.clear();for(let i of l())try{localStorage.removeItem(i)}catch(s){}}}}var Pe="_snt_snap:",Qn=["low","medium","high"];function De(e){try{let t=localStorage.getItem(Pe+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"||!Qn.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 Se(e,t){try{localStorage.setItem(Pe+e,JSON.stringify(t))}catch(n){}}var He="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ot="[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.",bt=!1,_e=!1;function er(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function tr(e){var t;let n=At({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",a=er(),o=Promise.resolve().then(()=>(vt(),yt)).then(i=>{let s=i;return s.LOCAL_ENGINE_AVAILABLE?(bt||(bt=!0,console.info(Ot)),s):(_e||(_e=!0,console.error(He)),null)}).catch(()=>(_e||(_e=!0,console.error(He)),null)),l=null;function d(i){let s=document.documentElement;s.dataset.sentientPersona===void 0&&(s.dataset.sentientPersona=i.persona,s.dataset.sentientConfidence=fe(i.confidence))}return{isLocal:!0,async decide(i){var s,c,u;let m=await o;if(!m)return null;let v=m.createLocalEngine({sessionId:r,forcedPersona:a}).decide(i);return l=be(R({},v),{layoutOrder:(c=(s=v.layoutOrder)!=null?s:l==null?void 0:l.layoutOrder)!=null?c:null,slots:R(R({},(u=l==null?void 0:l.slots)!=null?u:{}),v.slots)}),Se(e.apiKey||"local",{v:1,persona:l.persona,band:fe(l.confidence),slots:l.slots,layoutOrder:l.layoutOrder,savedAt:Date.now()}),d(v),v},getSlotResult(i){var s,c,u;return(u=(c=l==null?void 0:l.slots[i])!=null?c:(s=e.initialSlots)==null?void 0:s[i])!=null?u:null},getPersona(){return l?{persona:l.persona,confidence:l.confidence,band:fe(l.confidence)}:null},async assign(i,s){var c;let u=await o;return!u||!s||s.length===0?s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null:{variantId:(c=u.createLocalEngine({sessionId:r,forcedPersona:a}).decide({components:[{id:i,variantIds:s}]}).assignments[i])!=null?c:s[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Ae(e,t,n,r){let a=[];{let o=!1,l=[],d=()=>{if(o)return;let i=Date.now();for(l.push(i);l.length>0&&i-l[0]>500;)l.shift();l.length>=3&&(o=!0,e("rage_click"))};t.addEventListener("click",d),a.push(()=>t.removeEventListener("click",d))}{let o=!1,l=d=>{if(o||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;o=!0;let i=typeof window!="undefined"?window.getSelection():null,s=i?i.toString().length:0;e("text_copy",{selectionLength:s})};document.addEventListener("copy",l),a.push(()=>document.removeEventListener("copy",l))}{let o=!1,l=!1,d=null,i=()=>{d!==null&&(clearTimeout(d),d=null)},s=()=>{o||!l||(i(),d=setTimeout(()=>{!o&&l&&(o=!0,e("scroll_hesitation"))},3e3))},c=()=>{i(),s()},u=v=>{for(let I of v)l=I.intersectionRatio>.3,l?s():i()},m=new IntersectionObserver(u,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",c,{passive:!0}),a.push(()=>{m.disconnect(),window.removeEventListener("scroll",c),i()})}if((r==null?void 0:r.tabLoss)!==!1){let o=!1,l=n!=null?n:Date.now(),d=()=>{if(o||document.visibilityState!=="hidden")return;let i=Date.now()-l;i<15e3&&(o=!0,e("tab_loss",{timeOnPage:i}))};document.addEventListener("visibilitychange",d),a.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let o of a)o()}}var _t="https://api.sentient-ui.com/v1/events",W=new Map,Rt=null;function nr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Je(){return wt()}function Le(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function rr(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 Tt=new Set;function or(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let a=!1,o,l=()=>{if(a)return;let s=Le();!s||s===o||(o=s,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${s}`))},d=[];for(let s of["pushState","replaceState"]){let c=r[s],u=function(...m){let v=c.apply(this,m);return l(),v};r[s]=u,d.push([s,c,u])}window.addEventListener("popstate",l);let i=Le();return i&&Tt.has(`${t}:${i}`)?o=i:l(),()=>{if(!a){a=!0,window.removeEventListener("popstate",l);for(let[s,c,u]of d)r[s]===u&&(r[s]=c)}}}var we={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 ir(){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 Lt(e){return e.replace(/\/events\/?$/,"")}function ge(){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 Ye(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Rt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=W.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:a,upgrade:o}=r;if(!o||a.respectDoNotTrack!==!1&&ge())return;let l=Me(be(R({},a),{consent:!0}));o(l);let d=(t=W.get(n))==null?void 0:t.dispose;W.set(n,{config:be(R({},a),{consent:!0}),upgrade:null,dispose:d})}function sr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Lt((t=e.ingestUrl)!=null?t:_t),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(i,s,c){if(!n)return null;try{let u=new URLSearchParams({componentId:i});for(let v of s!=null?s:[])u.append("variantIds[]",v);let m=await fetch(`${r}/winner?${u.toString()}`,{headers:a});return m.ok?{variantId:(await m.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(u){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:()=>{}},l={track:i=>o.track(i),goal:((i,s,c,u)=>o.goal(i,s,c,u)),componentGoal:(i,s,c)=>o.componentGoal(i,s,c),identify:i=>o.identify(i),getAssignment:(i,s)=>o.getAssignment(i,s),assign:(i,s,c,u)=>o.assign(i,s,c,u),decide:i=>o.decide(i),getSlotResult:i=>o.getSlotResult(i),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function d(i){o=i}return{proxy:l,setInner:d}}function Me(e){var t,n,r,a,o,l,d,i,s;if(typeof window=="undefined")return we;Rt=e.apiKey;let c=W.get(e.apiKey||"local");if(c!=null&&c.dispose)try{c.dispose()}catch(p){}let u=e.respectDoNotTrack!==!1&&ge(),m=e.consent===!1||u,v=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!v&&e.localMode!==!1)return m?(W.set(e.apiKey||"local",{config:e,upgrade:null}),we):(W.set(e.apiKey||"local",{config:e,upgrade:null}),tr(e));if(m){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."),W.set(e.apiKey,{config:e,upgrade:null}),we;let{proxy:p,setInner:y}=sr(e);return W.set(e.apiKey,{config:e,upgrade:u?null:y}),p}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."),we;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),we;let I=(t=e.ingestUrl)!=null?t:_t,C=Date.now(),k=At({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),h=Zn(void 0,e.apiKey),f=Fn({ingestUrl:I,apiKey:e.apiKey}),x=Lt(I),O={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},G=Yn({url:`${x}/goals`,apiKey:e.apiKey,headers:O,onDrop:(p,y)=>{e.debug&&console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),b=pt((n=navigator.userAgent)!=null?n:""),P=typeof window!="undefined"?window.location.origin:void 0,$=ft((r=document.referrer)!=null?r:"",P),D=(a=e.sessionSegment)!=null?a:`${b}:${$}`,S=new Map,A=new Map,w=null,g=p=>{for(let y of p)A.has(y.id)||A.set(y.id,Fe(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))A.set(p,y);let E=De(e.apiKey);if(E)for(let[p,y]of Object.entries(E.slots))A.has(p)||A.set(p,y);let te={low:.15,medium:.5,high:.85};if(e.initialPersona)w=R({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?w={persona:p.sentientPersona,confidence:(l=te[(o=p.sentientConfidence)!=null?o:"low"])!=null?l:.15}:E&&(w={persona:E.persona,confidence:(d=te[E.band])!=null?d:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))h.set(p,D,{variantId:y,assignedAt:Date.now(),segment:D,confidence:1});let q=Promise.resolve(),ne=k.getSessionId();if(ne){let p=gt((i=document.referrer)!=null?i:""),y=R(R(R({sessionId:ne,deviceClass:b,trafficSource:$,referrerDomain:p,utmParams:ir(),timeOfDay:mt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:k.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||dt((s=navigator.userAgent)!=null?s:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{});try{q=fetch(`${x}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:O}).then(_=>{_.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")}).catch(()=>{})}catch(_){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let ce=new Set,H=null,ue=!1,F={goal(p,y={},_=1,Y=0){var X,N,Z,z,K,re;let B=k.getSessionId();if(!B)return;let U=nr(y)?y:{metadata:y},Q=`${p}\0${(X=U.externalId)!=null?X:""}\0${(N=U.stepIndex)!=null?N:Y}\0${(Z=U.weight)!=null?Z:_}`;if(ce.has(Q)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}ce.add(Q),ce.size===1&&rr(ce);let ye=Je(),T={sessionId:B,name:p,metadata:(z=U.metadata)!=null?z:{},weight:(K=U.weight)!=null?K:_,stepIndex:(re=U.stepIndex)!=null?re:Y,goalId:ye,value:U.value,currency:U.currency,externalId:U.externalId};e.debug&&console.log("[sentient] goal",T);let de={id:ye,body:JSON.stringify(T)};q.then(()=>G.send(de))},componentGoal(p,y,_){var Y,X,N;let Z=k.getSessionId();if(!Z)return;let z=h.get(p,D),K=z?null:(Y=A.get(p))!=null?Y:null;if(!z&&K===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let re=z?z.variantId:ht(K),B={id:Je(),sessionId:Z,projectId:e.apiKey,componentId:p,variantId:re,eventType:"goal_achieved",goalType:y,payload:R({reward:(X=_==null?void 0:_.reward)!=null?X:1,goalValue:_==null?void 0:_.value,currency:_==null?void 0:_.currency},(N=_==null?void 0:_.metadata)!=null?N:{}),timestamp:Date.now(),timeInSession:Date.now()-C,path:Le()};e.debug&&console.log("[sentient] componentGoal",B),q.then(()=>f.push(B))},identify(p){let y=k.getSessionId();y&&q.then(()=>{fetch(`${x}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:k.isEphemeral()}),headers:O}).catch(()=>{})})},track(p){let y=k.getSessionId();if(!y)return;let _=be(R({path:Le()},p),{id:Je(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",_),q.then(()=>f.push(_))},getAssignment(p,y){return h.get(p,y)},async assign(p,y,_,Y){let X=k.getSessionId();if(!X)return null;let N=h.get(p,D);if(N&&(y!=null&&y.length||N.content!==void 0)){let K=N.ttlMs&&N.ttlMs>0?Math.max(0,N.assignedAt+N.ttlMs-Date.now()):0;return{variantId:N.variantId,assignmentTtlMs:K,content:N.content}}let Z=S.get(p);if(Z)return Z;let z=(async()=>{await q;try{let K={sessionId:X,componentId:p,variantIds:y};Y!==void 0?K.agentDataByVariant=Y:_!==void 0&&(K.agentData=_);let re=await fetch(`${x}/assign`,{method:"POST",body:JSON.stringify(K),headers:O});if(!re.ok)return null;let B=await re.json();return h.set(p,D,R({variantId:B.variantId,assignedAt:Date.now(),segment:D,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B}catch(K){return null}finally{S.delete(p)}})();return S.set(p,z),z},async decide(p){var y,_,Y,X,N,Z,z,K,re;let B=k.getSessionId();if(!B)return null;let U=(y=p.slots)!=null?y:[];await q;try{let Q={sessionId:B};p.sections&&p.sections.length>0&&(Q.sections=p.sections.map(J=>({id:J}))),Q.components=(_=p.components)!=null?_:[],U.length>0&&(Q.slots=U.map(Ve)),p.slotsFrom==="registry"&&(Q.slotsFrom="registry"),p.v&&(Q.v=p.v),e.persona&&(Q.persona=e.persona);let ye=await fetch(`${x}/decide`,{method:"POST",body:JSON.stringify(Q),headers:O});if(!ye.ok)return g(U),null;let T=await ye.json(),de={};for(let J of U)de[J.id]=(X=(Y=T.slots)==null?void 0:Y[J.id])!=null?X:Fe(J);if(T.slots)for(let[J,ve]of Object.entries(T.slots))J in de||(de[J]=ve);for(let[J,ve]of Object.entries(de))A.set(J,ve);let pn=w!=null&&w.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&pn)?w={persona:T.persona,confidence:(N=T.confidence)!=null?N:0}:w||(w={persona:"unknown",confidence:0});for(let[J,ve]of Object.entries((Z=T.assignments)!=null?Z:{}))h.set(J,D,{variantId:ve,assignedAt:Date.now(),segment:D,confidence:1});return Se(e.apiKey,R({v:1,persona:w.persona,band:fe(w.confidence),slots:Object.fromEntries(A),layoutOrder:(z=T.layoutOrder)!=null?z:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{})),R(R(R({layoutOrder:(K=T.layoutOrder)!=null?K:null,assignments:(re=T.assignments)!=null?re:{},slots:de,persona:w.persona,confidence:w.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{})}catch(Q){return g(U),null}},getSlotResult(p){var y;return(y=A.get(p))!=null?y:null},getPersona(){return w?{persona:w.persona,confidence:w.confidence,band:fe(w.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${x}/weights`,{headers:O});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;H==null||H(),ue=!0,f.destroy(),G.destroy(),((p=W.get(e.apiKey))==null?void 0:p.dispose)===F.dispose&&W.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;H==null||H(),ue=!0,f.destroy(),G.destroy(),k.destroy(),((p=W.get(e.apiKey))==null?void 0:p.dispose)===F.dispose&&W.delete(e.apiKey);try{localStorage.removeItem(Pe+e.apiKey),localStorage.removeItem(It(e.apiKey)),localStorage.removeItem(Ct(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(W.set(e.apiKey,{config:e,upgrade:null,dispose:F.dispose}),H=or(F,e.apiKey,p=>{q.then(()=>{ue||Tt.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=F)}return F}var Pt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],ar=[["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 cr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Dt(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 ar)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 Mt(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:cr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function $t(e){return Dt(Mt(e)).type}Ie();var jt="section, header, footer, nav, main > div, [data-sentient-section]";function ur(e){var t;return((t=e.parentElement)==null?void 0:t.closest(jt))!=null}function dr(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(a){}}var Nt=()=>{};function Kt(e,t){var n,r,a,o,l,d,i,s,c;let u=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!u||typeof IntersectionObserver=="undefined"||ge()||!t.apiKey)return Nt;let m=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),v=Array.from(u.querySelectorAll(jt)).filter(S=>!ur(S));if(v.length===0)return Nt;let I=new Map,C=new Map,k=new Map;for(let S of v){let A=S.getAttribute("data-sentient-type"),w=A&&Pt.includes(A)?A:null,g=(o=w!=null?w:(a=t.typeOf)==null?void 0:a.call(t,S))!=null?o:$t(S),E=`nc-${g}`;I.set(S,E),C.set(E,g),w?k.set(E,"markup"):k.has(E)||k.set(E,"auto")}let h=(s=(i=(d=(l=u.defaultView)!=null?l:typeof window!="undefined"?window:void 0)==null?void 0:d.location)==null?void 0:i.pathname)!=null?s:"/";dr(t.apiKey,m,h,[...C.entries()].map(([S,A])=>{var w;return{componentId:S,semanticType:A,source:(w=k.get(S))!=null?w:"auto"}}));let f=new Map,x=S=>{let A=f.get(S);return A||(A={ms:0,scroll:0,enterAt:null,intersecting:!1},f.set(S,A)),A},O=new IntersectionObserver(S=>{for(let A of S){let w=I.get(A.target);if(!w)continue;let g=x(w);A.isIntersecting?(g.intersecting=!0,g.enterAt=Date.now(),A.intersectionRatio>g.scroll&&(g.scroll=A.intersectionRatio)):(g.intersecting=!1,g.enterAt!=null&&(g.ms+=Date.now()-g.enterAt,g.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let S of I.keys())O.observe(S);let G=()=>{let S=Date.now();for(let[A,w]of f)if(w.enterAt!=null&&(w.ms+=S-w.enterAt,w.enterAt=null),!(w.ms<=0)){try{e.track({projectId:t.apiKey,componentId:A,eventType:"dwell",payload:{dwell_time:Math.round(w.ms),scroll_depth:Number(w.scroll.toFixed(2))}})}catch(g){}w.ms=0}},b=()=>{if(u.hidden)G();else{let S=Date.now();for(let A of f.values())A.intersecting&&(A.enterAt=S)}},P=()=>{G();try{O.disconnect()}catch(S){}};u.addEventListener("visibilitychange",b);let $=(c=u.defaultView)!=null?c:typeof window!="undefined"?window:void 0;$==null||$.addEventListener("pagehide",P);let D=[];return t.microSignals&&[...I.entries()].forEach(([S,A],w)=>{D.push(Ae((g,E={})=>{try{e.track({projectId:t.apiKey,componentId:A,eventType:"micro_signal",payload:R({signalType:g},E)})}catch(te){}},S,void 0,{tabLoss:w===0}))}),()=>{G(),u.removeEventListener("visibilitychange",b),$==null||$.removeEventListener("pagehide",P);for(let S of D)S();try{O.disconnect()}catch(S){}}}var pr=["landing","ecommerce","saas","marketplace"];function fr(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,a]of t){if(!Array.isArray(a)||a.length<2||a.length>6||!a.every(o=>typeof o=="string"))return null;n[r]=a}return n}function gr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function mr(e){try{return e()}catch(t){return}}function $e(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=pr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[l,d]of Object.entries(t.slots)){if(typeof d!="object"||d===null)continue;let i=d,s=fr(i.dims);if(!s||i.target!==void 0&&typeof i.target!="string")continue;let c=i.arms!==void 0?gr(i.arms):null,u={dims:s};typeof i.target=="string"&&(u.target=i.target),c&&(u.arms=c),r[l]=u}let a={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(a.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(a.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(a.debug=!0),typeof t.registry=="boolean"&&(a.registry=t.registry),typeof t.editorSrc=="string"&&(a.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(a.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(a.sectionCapture=t.sectionCapture);let o=typeof t.persona=="function"?mr(t.persona):t.persona;return typeof o=="string"&&o.trim()!==""&&(a.persona=o),a}function Bt(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function hr(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(),a=t.text.trim().toLowerCase();if(!(r===a||r.startsWith(a)||a.startsWith(r)))return!1}return!0}function Ut(e,t){return!!(e!=null&&e.urlMatch)&&!Bt(t).includes(e.urlMatch)}var yr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function se(e,t){var a;if(e.urlMatch&&!Bt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((a=e.dataAttr)!=null&&a.name)&&yr.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!hr(r,e.fingerprint)?null:r}var Gt={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"},vr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function qt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!vr.test((t=n[1])!=null?t:""))return!1;return!0}var zt=/^https:\/\//i,Wt=new Map,ae=null;function br(e){return e.replace(/["\\]/g,"\\$&")}function wr(e){var t;(!ae||!ae.isConnected)&&(ae=e.querySelector("style[data-sentient-ops]"),ae||(ae=e.createElement("style"),ae.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(ae))),ae.textContent=[...Wt.entries()].map(([n,r])=>`[data-snt-e="${br(n)}"]{${r}}`).join(`
2
+ `)}function Vt(e,t,n,r){var d;let a=!1,o=(d=t.moveBefore)!=null?d:t.moveAfter;if(o){let i=se(o,r);!i||i===e||i.parentElement!==e.parentElement||!e.parentElement?a=!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"&&zt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&zt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let l=[];if(t.hidden&&l.push("display:none !important"),t.style)for(let[i,s]of Object.entries(t.style)){let c=Gt[i];c&&typeof s=="string"&&qt(s)&&l.push(`${c}:${s.trim()} !important`)}return l.length>0&&(e.setAttribute("data-snt-e",n),Wt.set(n,l.join(";")),wr(r)),{anchorMiss:a}}function Ne(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function je(e,t,n){var r;for(let[a,o]of Object.entries(t)){let l=e[a];if(!l||typeof l=="string")continue;let d=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let i of d)for(let[s,c]of Object.entries(l))(r=o.dims[s])!=null&&r.includes(c)&&i.setAttribute(`data-${s}`,c)}}function Ke(e,t,n){for(let[r,a]of Object.entries(t)){let o=e[r];if(typeof o!="string"||!a.arms||!a.arms.includes(o))continue;let l=a.target?Array.from(n.querySelectorAll(a.target)):[n.documentElement];for(let d of l)d.setAttribute("data-sentient-arm",o)}}function Be(e,t,n,r){var l,d;let a=(l=r==null?void 0:r.contentAndOps)!=null?l:!0,o=[];for(let[i,s]of Object.entries(t)){if(Ut(s.locator,n))continue;let c;if(s.locator){let m=se(s.locator,n);c=m?[m]:[]}else s.target?c=Array.from(n.querySelectorAll(s.target)):c=[n.documentElement];(s.locator||s.target)&&c.length===0&&o.push(i);let u=e[i];for(let m of c){if(u!==void 0)if(typeof u=="string")m.setAttribute("data-sentient-arm",u),a&&((d=r==null?void 0:r.onApplied)==null||d.call(r,i,u,m));else for(let[v,I]of Object.entries(u))m.setAttribute(`data-${v}`,I);a&&(typeof s.content=="string"&&(m.textContent=s.content),s.ops&&Vt(m,s.ops,i,n).anchorMiss&&!o.includes(i)&&o.push(i))}}return o}var Sr=800;function Ue(e,t,n){let r=[];return n.forEach(({slotId:a,arm:o,el:l},d)=>{r.push(Ae((m,v={})=>{try{e.track({projectId:t,componentId:a,variantId:o,eventType:"micro_signal",payload:pe({signalType:m},v)})}catch(I){}},l,void 0,{tabLoss:d===0}));let i=null,s=0,c=()=>{s=Date.now(),i=setTimeout(()=>{try{e.track({projectId:t,componentId:a,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-s}})}catch(m){}i=null},Sr)},u=()=>{i!==null&&(clearTimeout(i),i=null)};l.addEventListener("mouseenter",c),l.addEventListener("mouseleave",u),r.push(()=>{l.removeEventListener("mouseenter",c),l.removeEventListener("mouseleave",u),i!==null&&clearTimeout(i)})}),()=>{for(let a of r)a()}}function Ar(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function xr(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}/`)}var Ft="_snt_fired_goals";function Er(e){try{let t=e==null?void 0:e.sessionStorage.getItem(Ft);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(r=>typeof r=="string")):new Set}catch(t){return new Set}}function kr(e,t){try{e==null||e.sessionStorage.setItem(Ft,JSON.stringify([...t]))}catch(n){}}function Jt(e,t,n){var C,k;let r=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,a=Er(r),o=h=>{if(!a.has(h.goalId)){a.add(h.goalId),kr(r,a);try{h.slotId?t.componentGoal(h.slotId,h.goalId):t.goal(h.goalId)}catch(f){}}},l=e.filter(h=>h.event==="click"),d=e.filter(h=>h.event==="form_submit"),i=e.filter(h=>h.event==="url_reached"),s=e.filter(h=>h.event==="scroll_depth"),c=(h,f)=>{if(!h.locator)return!1;let x=se(h.locator,n);return!!x&&(x===f||x.contains(f))},u=h=>{let f=h.target;if(!(!f||typeof f.closest!="function"))for(let x of l)c(x,f)&&o(x)},m=h=>{let f=h.target;if(f)for(let x of d)c(x,f)&&o(x)},v=()=>{if(i.length===0)return;let h=Ar(n);for(let f of i)f.urlPattern&&xr(f.urlPattern,h)&&o(f)},I=()=>{var x;let h=n.documentElement,f=h.scrollHeight>0?(h.scrollTop+h.clientHeight)/h.scrollHeight:0;for(let O of s)f>=((x=O.threshold)!=null?x:.75)&&o(O);s.every(O=>a.has(O.goalId))&&n.removeEventListener("scroll",I)};return n.addEventListener("click",u,!0),n.addEventListener("submit",m,!0),(k=n.defaultView)==null||k.addEventListener("popstate",v),v(),s.length>0&&(n.addEventListener("scroll",I,{passive:!0}),I()),{checkUrl:v,teardown:()=>{var h;n.removeEventListener("click",u,!0),n.removeEventListener("submit",m,!0),(h=n.defaultView)==null||h.removeEventListener("popstate",v),s.length>0&&n.removeEventListener("scroll",I)}}}var Ht="__snt_editor_token";function Yt(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Ht):null}catch(e){return null}}function Xt(e){try{sessionStorage.setItem(Ht,e)}catch(t){}}var Ze="0.16.1",on=5e3,Ir=50,Cr=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),V=null,M=null,ie={},le=null,ee=null,j=null,oe=null,L=null,Zt=!1,Xe=null,Ge=null,qe=null,xe=!1,ze=!1;function sn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function me(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function he(e,t){return V?(V.personaAttributes&&L&&Ne(L.persona,L.band,e),je(ie,V.slots,e),Ke(ie,V.slots,e),le?Be(ie,le,e,t):[]):[]}function Or(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 Ee(){return!!(V&&M&&V.sectionCapture!==!1&&(V.consent!==!1||ze)&&!ge())}function _r(){if(!M||!V||!Ee()||oe)return;let e=[];he(document,{contentAndOps:xe,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),et();try{j==null||j(),j=Ue(M,V.apiKey,e)}catch(t){}}function et(){if(typeof document=="undefined"||!Ee())return;let e;try{if(Ge&&Ge.length>0){let t=new Map;for(let n of Ge){if(n.urlMatch!==window.location.pathname)continue;let r=se(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{oe=Kt(M,pe({apiKey:V.apiKey,apiBase:V.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),qe=window.location.pathname}catch(t){}}function tt(){try{let e=[];if(j==null||j(),j=null,he(document,{contentAndOps:xe,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&Ee())try{j=Ue(M,V.apiKey,e)}catch(t){}try{typeof window!="undefined"&&qe!==null&&window.location.pathname!==qe&&Ee()&&(oe==null||oe(),oe=null,et())}catch(t){}}catch(e){}}function Qt(){Xe===null&&(Xe=setTimeout(()=>{Xe=null,tt();try{ee==null||ee.checkUrl()}catch(e){}},Ir))}function en(){if(!(Zt||typeof window=="undefined"||typeof history=="undefined")){Zt=!0;try{let e=t=>{let n=history[t];history[t]=function(r,a,o){let l=n.call(this,r,a,o!=null?o:null);return Qt(),l}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Qt)}catch(e){}}}function Qe(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 an(e){return new URLSearchParams(e).get("sentient_editor")}function Rr(){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 Tr(e,t){var n,r,a,o;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 l=(a=e.editorSrc)!=null?a:Rr();if(!l){nn();return}let d=document.createElement("script");d.src=l,d.async=!0,d.onerror=()=>nn(),((o=document.head)!=null?o:document.documentElement).appendChild(d)}catch(l){}}var tn="sentient-editor-load-notice";function nn(){var e;try{if(typeof document=="undefined"||document.getElementById(tn))return;let t=document.createElement("div");t.id=tn,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 ln(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let a=r.indexOf(":"),o=a===-1?"":r.slice(0,a),l=a===-1?"":r.slice(a+1);if(!(!o||!l))if(l.includes("=")){let d={};for(let i of l.split(",")){let[s,c]=i.split("=");s&&c&&(d[s]=c)}Object.keys(d).length&&(n[o]=d)}else n[o]=l}return Object.keys(n).length?n:null}function cn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var rn="sentient-persona-preview-banner";function Lr(e){var t;try{if(typeof document=="undefined"||document.getElementById(rn))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=rn,r.setAttribute("role","status"),Object.assign(r.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 a=document.createElement("span");a.textContent=`Previewing as ${n}`;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 l=new URL(window.location.href);l.searchParams.delete("sentient_persona"),window.location.href=l.pathname+l.search+l.hash}catch(l){}}),r.appendChild(a),r.appendChild(o),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function Pr(e,t){var s,c,u,m,v,I,C,k,h;let n=(s=e.apiBase)!=null?s:"https://api.sentient-ui.com",a=((c=e.registry)!=null?c:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,x])=>({id:f,dims:x.dims}))},o=await sn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(a)}).then(f=>f.ok?f.json():null).catch(()=>null),on);if(!o){me(e,"persona preview: explain unavailable \u2014 page left as-is");return}let l=o;ie=(u=l.slots)!=null?u:{},le=(m=l.slotConfig)!=null?m:null;let d=(C=(I=(v=l.personaAttributes)==null?void 0:v.persona)!=null?I:l.persona)!=null?C:t,i=(h=(k=l.personaAttributes)==null?void 0:k.confidence)!=null?h:"high";L={persona:d,band:i},he(document),xe=!0,un(e),Lr(d)}function un(e){let t={goal(n,r){try{M==null||M.goal(n,r)}catch(a){}},componentGoal(n,r){try{M==null||M.componentGoal(n,r)}catch(a){}},grantConsent(){try{Ye(e.apiKey)}catch(n){}ze=!0;try{_r()}catch(n){}},revokeConsent(){try{oe==null||oe(),oe=null,qe=null,j==null||j(),j=null,ee==null||ee.teardown(),ee=null,ze=!1,M==null||M.destroy()}catch(n){}},reapply:tt,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=L==null?void 0:L.persona)!=null?n:null,band:(r=L==null?void 0:L.band)!=null?r:null,slots:ie,matchCounts:Qe(e),consent:e.consent!==!1}}};window.SentientSnippet=t;for(let n of Cr.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}async function dn(){var e,t,n,r,a;try{let o=$e(window.sentient);if(!o)return;V=o,xe=!1,ze=!1;let l=typeof window!="undefined"?an(window.location.search):null;if(l){Xt(l);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let d=l!=null?l:Yt();if(d){Tr(o,d),me(o,"editor mode");return}let i=typeof window!="undefined"?ln(window.location.search):null;if(i){ie=i,L=null,he(document),en(),me(o,"preview mode",i);return}let s=typeof window!="undefined"?cn(window.location.search):null;if(s){await Pr(o,s),me(o,"persona preview",s);return}let c=(e=o.registry)!=null?e:Object.keys(o.slots).length===0,u=De(o.apiKey);u&&(L={persona:u.persona,band:u.band},ie=u.slots,u.slotConfig&&(le=u.slotConfig),he(document,{contentAndOps:!1}));let m=Me({apiKey:o.apiKey,context:o.context,consent:o.consent,preConsentBehavior:o.preConsentBehavior,debug:o.debug,persona:o.persona});M=m,un(o),en();let v=Object.entries(o.slots).map(([f,x])=>({id:f,dims:x.dims})),I=Ze!=="0.0.0-dev"?{v:Ze}:{},C=await sn(m.decide(pe(pe({slots:v},I),c?{slotsFrom:"registry"}:{})),on);if(!C){me(o,"decide timeout/null \u2014 snapshot state stands",Qe(o));return}let k=m.getPersona();k?L={persona:k.persona,band:k.band}:C.persona&&(L={persona:C.persona,band:"low"}),ie=C.slots,c?le=(t=C.slotConfig)!=null?t:null:C.slotConfig&&(le=C.slotConfig);let h=[];if(Or(o,he(document,{onApplied:(f,x,O)=>h.push({slotId:f,arm:x,el:O})})),xe=!0,C.goals&&C.goals.length>0&&o.consent!==!1&&M)try{ee==null||ee.teardown(),ee=Jt(C.goals,M,document)}catch(f){}if(Ge=(n=C.sectionMap)!=null?n:null,Ee()){et();try{j==null||j(),j=Ue(M,o.apiKey,h)}catch(f){}}me(o,"applied",{persona:L,slots:ie,matches:Qe(o)}),Se(o.apiKey,pe({v:1,persona:(r=L==null?void 0:L.persona)!=null?r:C.persona,band:(a=L==null?void 0:L.band)!=null?a:"low",slots:C.slots,layoutOrder:C.layoutOrder,savedAt:Date.now()},le?{slotConfig:le}:{}))}catch(o){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,dn())}return yn(Dr);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.15.1",
3
+ "version": "0.16.1",
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.19.1"
27
+ "@sentientui/core": "0.20.1"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",