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