@sentientui/snippet 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,10 +2,16 @@
2
2
 
3
3
  Style-rung [SentientUI](https://sentient-ui.com) for sites that are not built with React.
4
4
  One script tag: visitor-type attributes on `<html>` plus learned `data-*` style tokens on the
5
- elements you declare. Plain CSS does the rest. No markup is ever injected — text is written as
6
- `textContent` and styles come from a bounded, validated set. The only structural change possible
7
- is moving a declared element among its own siblings (a registry `moveBefore`/`moveAfter` op,
8
- applied after the decision returns); a drifted anchor applies nothing. If anything fails, your
5
+ elements you declare. Plain CSS does the rest. No HTML is ever accepted or injected — text is
6
+ written as `textContent`, styles come from a bounded validated set, and dashboard-authored
7
+ Composition Blocks are a typed, enumerated component tree rendered via `createElement` only
8
+ (there is no sanitizer because there is no HTML to sanitize). The structural changes possible
9
+ are: moving a declared element among its own siblings (a registry `moveBefore`/`moveAfter` op,
10
+ applied after the decision returns; a drifted anchor applies nothing), reordering the sections
11
+ you list in `sections` within their shared parent (never applied unless every selector still
12
+ resolves and the served order is exactly a permutation of them), and revealing one published
13
+ Composition-Block arm inside its slot (all arms render hidden up front; the served one is
14
+ shown, and removing the arm restores your original markup exactly). If anything fails, your
9
15
  page is left exactly as it was.
10
16
 
11
17
  ```html
@@ -14,6 +20,10 @@ page is left exactly as it was.
14
20
  apiKey: 'pk_your_key', // sentient-ui.com → Settings
15
21
  context: 'landing', // 'landing' | 'ecommerce' | 'saas' | 'marketplace'
16
22
  personaAttributes: true, // sets data-sentient-persona / -confidence on <html>
23
+ persona: () => window.myApp?.role, // optional: declare the role your site already knows
24
+ // (string or function; must be a key from Settings → Personas)
25
+ sections: ['#hero', '#pricing', '#faq'], // optional: sections eligible for reordering,
26
+ // CSS selectors in your theme's natural order
17
27
  slots: {
18
28
  hero: { dims: { tone: ['calm', 'urgent'] }, target: '#hero' },
19
29
  },
@@ -40,9 +50,21 @@ html[data-sentient-persona='deal_seeker'] .discount-banner { display: block; }
40
50
  The first value of each dim is your baseline (what you show today). Decisions are locked per
41
51
  session and learned per visitor type on the SentientUI API: Visit 1 learns, Visit 2 converts.
42
52
 
53
+ `persona` declares the visitor type your site already knows (e.g. a role from your own
54
+ session state) instead of waiting for it to be inferred. It must be a key in the project's
55
+ persona vocabulary (dashboard → Settings → Personas); unrecognized values are ignored
56
+ server-side and surfaced in the dashboard so you can add them. Keep it a low-cardinality
57
+ role label — never a user id or email.
58
+
59
+ `sections` lists the page sections the optimizer may reorder, as CSS selectors in the order
60
+ your theme renders them (the first learned baseline). Each selector must match exactly one
61
+ element and all of them must share one parent; anything else — a missing section, an ambiguous
62
+ selector, a served order that isn't a permutation of your list — applies nothing. Return visits
63
+ pre-paint the last served order from a local snapshot, so there is no natural-order flash.
64
+
43
65
  The snippet also captures per-section attention (visible time + scroll depth) and behavioral
44
66
  signals by default — that's what builds audience profiles with zero tagging. Add
45
67
  `sectionCapture: false` to `window.sentient` to turn it off; it never runs for a Do-Not-Track,
46
68
  Global Privacy Control, or consent-gated visitor.
47
69
 
48
- Bundle ≤ 15 KB gzip. MIT.
70
+ Bundle ≤ 20 KiB gzip (CI-enforced). MIT.
@@ -1,5 +1,5 @@
1
- "use strict";var SentientSnippet=(()=>{var kt=Object.defineProperty,be=Object.defineProperties,xe=Object.getOwnPropertyDescriptor,ve=Object.getOwnPropertyDescriptors,ke=Object.getOwnPropertyNames,Yt=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var Vt=(e,t,n)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D=(e,t)=>{for(var n in t||(t={}))Zt.call(t,n)&&Vt(e,n,t[n]);if(Yt)for(var n of Yt(t))Ee.call(t,n)&&Vt(e,n,t[n]);return e},ot=(e,t)=>be(e,ve(t));var we=(e,t)=>{for(var n in t)kt(e,n,{get:t[n],enumerable:!0})},Se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ke(t))!Zt.call(e,s)&&s!==n&&kt(e,s,{get:()=>t[s],enumerable:!(o=xe(t,s))||o.enumerable});return e};var Le=e=>Se(kt({},"__esModule",{value:!0}),e);var Je={};we(Je,{buildStyleOps:()=>de,clearTargetHighlights:()=>ft,computeMoveAnchors:()=>Tt,deriveSlotId:()=>Ct,drawTargetHighlights:()=>ae,mount:()=>ue,styleFieldError:()=>ce});function Ce(e){var n,o,s;let t=(o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function Te(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let o=((n=e.textContent)!=null?n:"").trim().toLowerCase(),s=t.text.trim().toLowerCase();if(!(o===s||o.startsWith(s)||s.startsWith(o)))return!1}return!0}var Be=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function V(e,t){var s;if(e.urlMatch&&!Ce(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((s=e.dataAttr)!=null&&s.name)&&Be.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 o=n[0];return e.fingerprint&&!Te(o,e.fingerprint)?null:o}function Jt(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let o=0;o<e.length;o++){let s=e[o],c=s>="0"&&s<="9";o===0&&c||o===1&&c&&e[0]==="-"?n+=`\\3${s} `:o===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function $e(e,t){if(e.id)return`#${Jt(e.id)}`;let n=[],o=e,s=0;for(;o&&o!==t.body&&o!==t.documentElement&&s<6;){if(o.id){n.unshift(`#${Jt(o.id)}`);break}let c=o.tagName.toLowerCase(),u=o.parentElement;if(u){let E=Array.from(u.children).filter(h=>h.tagName===o.tagName);E.length>1&&(c+=`:nth-of-type(${E.indexOf(o)+1})`)}n.unshift(c),o=o.parentElement,s++}return n.join(" > ")}function pt(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let c of["data-framer-name","data-w-id","data-sentient-name"]){let u=e.getAttribute(c);if(u){n.dataAttr={name:c,value:u};break}}n.selector=$e(e,t);let o=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=D({tag:e.tagName.toLowerCase()},o?{text:o}:{}),n}function Et(e,t,n){return V(e,n)===t}var Ae="__snt_editor_token";function wt(){try{sessionStorage.removeItem(Ae)}catch(e){}}var Kt={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"},_e=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function St(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!_e.test((t=n[1])!=null?t:""))return!1;return!0}var Xt=/^https:\/\//i,Qt=new Map,G=null;function Re(e){return e.replace(/["\\]/g,"\\$&")}function Ie(e){var t;(!G||!G.isConnected)&&(G=e.querySelector("style[data-sentient-ops]"),G||(G=e.createElement("style"),G.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(G))),G.textContent=[...Qt.entries()].map(([n,o])=>`[data-snt-e="${Re(n)}"]{${o}}`).join(`
2
- `)}function te(e,t,n,o){var E;let s=!1,c=(E=t.moveBefore)!=null?E:t.moveAfter;if(c){let h=V(c,o);!h||h===e||h.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,h):e.parentElement.insertBefore(e,h.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Xt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Xt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let u=[];if(t.hidden&&u.push("display:none !important"),t.style)for(let[h,O]of Object.entries(t.style)){let C=Kt[h];C&&typeof O=="string"&&St(O)&&u.push(`${C}:${O.trim()} !important`)}return u.length>0&&(e.setAttribute("data-snt-e",n),Qt.set(n,u.join(";")),Ie(o)),{anchorMiss:s}}function It(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Mt(e,t){return e.steps.map(n=>{var o;return{value:n.step_index,label:`${n.step_index+1}. ${(o=t.get(n.goal_id))!=null?o:n.goal_id}`}})}function ee(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Me(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function ne(e,t){let n=e.trim();return n?t.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:t.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:Me(n),body:{displayName:n.slice(0,128),steps:t.map(o=>({goalId:o}))}}:{ok:!1,error:"Give the funnel a name."}}function ie(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)}function Lt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Ct(e,t,n){var E,h;let o=t.id||((E=t.dataAttr)==null?void 0:E.value)||((h=n.textContent)!=null?h:"").trim()||n.tagName,s=Lt(o)||"el",c=ie(JSON.stringify(t));return`${e}-${s}-${c}`.slice(0,128)}var He="sentient-editor-highlight",Pe="sentient-editor-selection",rt="sentient-editor-panel",Bt="sentient-editor-toast",oe="sentient-editor-styles",Pt="sentient-editor-target-highlight",Oe=10,ze="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Ne="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function se(){var t;if(document.getElementById(oe))return;let e=document.createElement("style");e.id=oe,e.textContent=`
1
+ "use strict";var SentientSnippet=(()=>{var Lt=Object.defineProperty,Ee=Object.defineProperties,we=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertyNames,Jt=Object.getOwnPropertySymbols;var Zt=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var Xt=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t)=>{for(var n in t||(t={}))Zt.call(t,n)&&Xt(e,n,t[n]);if(Jt)for(var n of Jt(t))Ce.call(t,n)&&Xt(e,n,t[n]);return e},V=(e,t)=>Ee(e,Se(t));var Te=(e,t)=>{for(var n in t)Lt(e,n,{get:t[n],enumerable:!0})},Be=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Le(t))!Zt.call(e,s)&&s!==n&&Lt(e,s,{get:()=>t[s],enumerable:!(o=we(t,s))||o.enumerable});return e};var $e=e=>Be(Lt({},"__esModule",{value:!0}),e);var on={};Te(on,{buildStyleOps:()=>fe,clearTargetHighlights:()=>yt,computeMoveAnchors:()=>_t,deriveSlotId:()=>ht,drawTargetHighlights:()=>ce,mount:()=>ge,styleFieldError:()=>pe});function Ae(e){var n,o,s;let t=(o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function _e(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let o=((n=e.textContent)!=null?n:"").trim().toLowerCase(),s=t.text.trim().toLowerCase();if(!(o===s||o.startsWith(s)||s.startsWith(o)))return!1}return!0}var Re=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function et(e,t){var s;if(e.urlMatch&&!Ae(t).includes(e.urlMatch))return null;let n=[];if(e.id){let d=t.getElementById(e.id);n=d?[d]:[]}if(n.length===0&&((s=e.dataAttr)!=null&&s.name)&&Re.test(e.dataAttr.name))try{let d=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${d}"]`))}catch(d){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(d){n=[]}if(n.length!==1)return null;let o=n[0];return e.fingerprint&&!_e(o,e.fingerprint)?null:o}function Kt(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let o=0;o<e.length;o++){let s=e[o],d=s>="0"&&s<="9";o===0&&d||o===1&&d&&e[0]==="-"?n+=`\\3${s} `:o===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function Ie(e,t){if(e.id)return`#${Kt(e.id)}`;let n=[],o=e,s=0;for(;o&&o!==t.body&&o!==t.documentElement&&s<6;){if(o.id){n.unshift(`#${Kt(o.id)}`);break}let d=o.tagName.toLowerCase(),f=o.parentElement;if(f){let v=Array.from(f.children).filter(m=>m.tagName===o.tagName);v.length>1&&(d+=`:nth-of-type(${v.indexOf(o)+1})`)}n.unshift(d),o=o.parentElement,s++}return n.join(" > ")}function mt(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let d of["data-framer-name","data-w-id","data-sentient-name"]){let f=e.getAttribute(d);if(f){n.dataAttr={name:d,value:f};break}}n.selector=Ie(e,t);let o=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=F({tag:e.tagName.toLowerCase()},o?{text:o}:{}),n}function Ct(e,t,n){return et(e,n)===t}var Me="__snt_editor_token";function Tt(){try{sessionStorage.removeItem(Me)}catch(e){}}var Pe=/rgba\([^)]*,\s*0\s*\)$/,He=/^\d+(\.\d+)?px$/;function Qt(e){var t,n;try{let o=e.defaultView;if(!o||!e.body)return null;let s=o.getComputedStyle(e.body).backgroundColor,d=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),f=new Map;for(let I of Array.from(d).slice(0,300)){let _=I.getBoundingClientRect();if(_.width>0&&(_.width<48||_.height<24))continue;let M=o.getComputedStyle(I),L=M.backgroundColor;if(!L||L==="transparent"||L===s||Pe.test(L))continue;let P=(t=(M.borderRadius||"").split(" ")[0])!=null?t:"",H=`${L}|${M.color}|${He.test(P)?P:"8px"}`;f.set(H,((n=f.get(H))!=null?n:0)+1)}let v=null,m=0;for(let[I,_]of f)_>m&&(v=I,m=_);if(!v)return null;let[z,B,G]=v.split("|");return{primaryBg:z,primaryText:B,radius:G}}catch(o){return null}}var te={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"},Oe=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Bt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Oe.test((t=n[1])!=null?t:""))return!1;return!0}var ee=/^https:\/\//i,ne=new Map,J=null;function ze(e){return e.replace(/["\\]/g,"\\$&")}function Ne(e){var t;(!J||!J.isConnected)&&(J=e.querySelector("style[data-sentient-ops]"),J||(J=e.createElement("style"),J.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(J))),J.textContent=[...ne.entries()].map(([n,o])=>`[data-snt-e="${ze(n)}"]{${o}}`).join(`
2
+ `)}function oe(e,t,n,o){var v;let s=!1,d=(v=t.moveBefore)!=null?v:t.moveAfter;if(d){let m=et(d,o);!m||m===e||m.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,m):e.parentElement.insertBefore(e,m.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&ee.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&ee.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let f=[];if(t.hidden&&f.push("display:none !important"),t.style)for(let[m,z]of Object.entries(t.style)){let B=te[m];B&&typeof z=="string"&&Bt(z)&&f.push(`${B}:${z.trim()} !important`)}return f.length>0&&(e.setAttribute("data-snt-e",n),ne.set(n,f.join(";")),Ne(o)),{anchorMiss:s}}function Ht(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Ot(e,t){return e.steps.map(n=>{var o;return{value:n.step_index,label:`${n.step_index+1}. ${(o=t.get(n.goal_id))!=null?o:n.goal_id}`}})}function re(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Fe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function ie(e,t){let n=e.trim();return n?t.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:t.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:Fe(n),body:{displayName:n.slice(0,128),steps:t.map(o=>({goalId:o}))}}:{ok:!1,error:"Give the funnel a name."}}function le(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)}function At(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function ht(e,t,n){var v,m;let o=t.id||((v=t.dataAttr)==null?void 0:v.value)||((m=n.textContent)!=null?m:"").trim()||n.tagName,s=At(o)||"el",d=le(JSON.stringify(t));return`${e}-${s}-${d}`.slice(0,128)}var De="sentient-editor-highlight",je="sentient-editor-selection",st="sentient-editor-panel",Rt="sentient-editor-toast",se="sentient-editor-styles",zt="sentient-editor-target-highlight",Ge=10,Ue="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",We="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function de(){var t;if(document.getElementById(se))return;let e=document.createElement("style");e.id=se,e.textContent=`
3
3
  @keyframes sntedi-in {
4
4
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
5
5
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -12,13 +12,13 @@
12
12
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
13
13
  50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
14
14
  }
15
- #${rt} {
15
+ #${st} {
16
16
  animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both,
17
17
  sntedi-attn 1.7s ease-in-out 0.42s 3;
18
18
  }
19
- #${rt} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
- #${Bt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
19
+ #${st} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
+ #${Rt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
21
21
  @media (prefers-reduced-motion: reduce) {
22
- #${rt}, #${rt} .sntedi-dot, #${Bt} { animation: none !important; }
22
+ #${st}, #${st} .sntedi-dot, #${Rt} { animation: none !important; }
23
23
  }
24
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function re(e){var o,s;se(),(o=document.getElementById(Bt))==null||o.remove();let t=a("div",{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)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=Bt;let n=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,a("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function Fe(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function De(e){try{let t=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let n=(await t.json()).projectId;return n?{ok:!0,projectId:n}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}async function P(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?"ok":o.status===401?"expired":"error"}catch(o){return"error"}}var Ot=[];async function Ge(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let n=await t.json();return Ot=Array.isArray(n.fonts)?n.fonts.filter(o=>typeof o=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function Ht(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return n.ok?await n.json():null}catch(n){return null}}function ft(e=document){for(let t of Array.from(e.querySelectorAll(`.${Pt}`)))t.remove()}function ae(e,t=document){var o;ft(t);let n=0;for(let s of e){if(n>=Oe)break;let c=V(s.locator,t);if(!c)continue;let u=c.getBoundingClientRect(),E=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${u.left}px`,top:`${u.top}px`,width:`${u.width}px`,height:`${u.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});E.className=Pt;let h=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${u.left}px`,top:`${Math.max(0,u.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);h.className=Pt,((o=t.body)!=null?o:t.documentElement).append(E,h),n+=1}}function Tt(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,s=n?pt(n,t):null,c=o?pt(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&s&&Et(s,n,t)?s:null,nextLocator:o&&c&&Et(c,o,t)?c:null}}var le=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],je=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Ue=new Set(["left","center","right","justify","start","end"]),We=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,qe=/^(rgb|rgba|hsl|hsla)\(/i;function Ye(e){return We.test(e)||qe.test(e)}function ce(e,t){switch(e){case"fontSize":case"borderRadius":return je.test(t)?null:"Add a unit, e.g. 20px or 1.5rem.";case"fontWeight":return/^(normal|bold|bolder|lighter)$/i.test(t)||/^\d{1,4}$/.test(t)&&+t>=1&&+t<=1e3?null:"Use 100\u2013900, or normal/bold.";case"textAlign":return Ue.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Ye(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(o=>o.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(o=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(o))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function de(e){let t={},n={};for(let o of le){let s=e[o];if(typeof s!="string")continue;let c=s.trim();if(c==="")continue;if(!St(c)){n[o]="That value isn\u2019t allowed.";continue}let u=ce(o,c);if(u){n[o]=u;continue}t[o]=c}return{style:t,errors:n}}function a(e,t,n){let o=document.createElement(e);return Object.assign(o.style,t),n!==void 0&&(o.textContent=n),o}function ue(e){var qt;let t=null,n=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=He;let o=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});o.id=Pe;let s=()=>{if(!t||!t.isConnected){o.style.display="none";return}let r=t.getBoundingClientRect();Object.assign(o.style,{display:"block",left:`${r.left-2}px`,top:`${r.top-2}px`,width:`${r.width}px`,height:`${r.height}px`})},c=()=>s();se();let u=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"320px",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});u.id=rt;let E=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});E.className="sntedi-dot";let h=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});h.append(E,a("span",{},"SentientUI editor"));let O=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),C=!1,Z=a("button",y("#374151"),"Pause selecting");Z.onclick=()=>{C=!C,Z.textContent=C?"Resume selecting":"Pause selecting",C?(n.style.display="none",ft(document),d("Selection paused \u2014 browse normally, then resume.")):d("Click any element on the page to adapt it.")};let J=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),K=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),j=r=>a("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},r),I=a("button",y("#6366f1"),"Test different text here"),z=a("button",y("#374151"),"Change style"),N=a("button",y("#374151"),"Track clicks as a goal"),F=a("button",y("#374151"),"Track form submissions as a goal"),it=a("button",y("#374151"),"Track page visits as a goal"),st=a("button",y("#374151"),"Track reading this far as a goal"),w=a("button",y("#374151"),"Set up a funnel"),_=a("button",y("#374151"),"Attach this test to a funnel step"),L=a("button",y("#10b981"),"Turn the funnel on"),U=a("button",y("#374151"),"Move up"),W=a("button",y("#374151"),"Move down"),gt=a("button",y("#6366f1"),"Save this arrangement"),mt=a("button",y("#374151"),"Undo"),zt=a("button",ot(D({},y("transparent")),{opacity:"0.6"}),"Close editor"),q=a("button",y("#10b981"),"Publish now \u2014 go live"),Y=a("button",y("#10b981"),"Start tracking now");for(let r of[I,z,N,U,W])r.disabled=!0;let Nt=[I,z,N,F,U,W];for(let r of Nt)r.style.display="none";gt.style.display="none",mt.style.display="none",q.style.display="none",Y.style.display="none",_.style.display="none",L.style.display="none",u.append(h,O,Z,J,K,j("Content & style"),I,z,j("Track a goal"),N,F,it,st,j("Funnels"),w,_,L,j("Move"),U,W,gt,mt,q,Y,zt),((qt=document.body)!=null?qt:document.documentElement).append(n,o,u);let T=a("div",{marginTop:"10px"});u.append(T);let R=()=>{T.textContent=""},ht=(r,i,l)=>{var A;R();let p={},f={},k={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let g of r){let m=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},g.label);if(T.append(m),g.type==="select"){let v=a("select",k);v.setAttribute("data-field",g.key);let H=document.createElement("option");H.value="",H.textContent="\u2014 no change \u2014",v.append(H);for(let et of(A=g.options)!=null?A:[]){let nt=document.createElement("option");nt.value=et,nt.textContent=et,v.append(nt)}p[g.key]=()=>v.value,T.append(v)}else if(g.type==="color"){let v=a("input",ot(D({},k),{padding:"2px",height:"34px"}));v.type="color",v.setAttribute("data-field",g.key);let H=!1;v.addEventListener("input",()=>{H=!0}),p[g.key]=()=>H?v.value:"",T.append(v)}else{let v=a("input",k);v.setAttribute("data-field",g.key),g.value!==void 0&&(v.value=g.value),p[g.key]=()=>v.value,T.append(v)}let x=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});x.setAttribute("data-feedback",g.key),f[g.key]=x,T.append(x)}let S=(g,m)=>{let x=f[g];x&&(x.textContent=m!=null?m:"",x.style.display=m?"block":"none")},b=a("button",y("#6366f1"),i),$=a("button",ot(D({},y("transparent")),{opacity:"0.6"}),"Cancel");b.onclick=()=>l(Object.fromEntries(Object.entries(p).map(([g,m])=>[g,m()])),S),$.onclick=R,T.append(b,$)},d=(r,i=!0)=>{K.textContent=r,K.style.color=i?"#a7f3d0":"#fca5a5"},X=(r,i)=>{r==="ok"?d(i,!0):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.":"\u26A0 Couldn\u2019t save \u2014 try again.",!1)},at=null,$t=r=>{at=r,q.style.display="block",_.style.display="block"};q.onclick=async()=>{if(!at)return;q.disabled=!0,d("Publishing\u2026");let r=await P(e,`/v1/editor/slots/${encodeURIComponent(at)}/publish`,{});q.disabled=!1,r==="ok"?(d("\u2713 Published \u2014 live for new visitors.",!0),q.style.display="none",at=null):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.":"\u26A0 Couldn\u2019t publish \u2014 try again.",!1)};let B=null,lt=!1,ct=null,dt=null,M=null,Q=null,ut=null,yt=null,tt=!1,Ft=(r,i)=>lt?r?"":`Nothing to swap with ${i} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Dt=()=>{U.disabled=!lt||!M,W.disabled=!lt||!Q,U.title=U.disabled?Ft(M,"above"):"",W.title=W.disabled?Ft(Q,"below"):""},At=r=>{gt.style.display=r?"block":"none",mt.style.display=r?"block":"none",Dt()},Gt=()=>{if(tt&&t&&ut&&ut.insertBefore(t,yt),tt=!1,ut=null,yt=null,t){let r=Tt(t,document);ct=r.prevEl,dt=r.nextEl,M=r.prevLocator,Q=r.nextLocator}s(),At(!1)},jt=r=>{if(C)return;let i=r.target;if(!i||u.contains(i)||i===n)return;ft(document);let l=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${l.left}px`,top:`${l.top}px`,width:`${l.width}px`,height:`${l.height}px`})},fe=r=>{var l;let i=((l=r.textContent)!=null?l:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:r.tagName.toLowerCase()},Ut=r=>{if(C)return;let i=r.target;if(!i||u.contains(i))return;r.preventDefault(),r.stopPropagation(),Gt(),R(),t=i,B=pt(i,document);let l=Et(B,i,document);lt=l,s(),J.style.display="block",J.textContent=`Selected: ${fe(i)}`,d(l?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",l);for(let S of Nt)S.style.display="block";let p=i.childElementCount===0;I.disabled=!l||!p,I.title=l?p?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",z.disabled=!l,N.disabled=!l;let f=i.closest("form");F.style.display=f?"block":"none",F.disabled=!f;let k=Tt(i,document);ct=k.prevEl,dt=k.nextEl,M=k.prevLocator,Q=k.nextLocator,Dt()};I.onclick=()=>{var l,p;if(!t||!B)return;let r=B,i=(p=(l=t.textContent)==null?void 0:l.trim())!=null?p:"";ht([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async f=>{let k=f.alt.trim();if(!k){d("\u26A0 Enter alternative wording to test.",!1);return}if(k===f.current.trim()){d("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let S=Ct("text",r,t);d("Saving\u2026");let b=await P(e,`/v1/editor/slots/${encodeURIComponent(S)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:f.current}},{id:"b",displayName:"Alternative",ops:{text:f.alt}}]}});b==="ok"&&(R(),$t(S)),X(b,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let bt=null,ge=r=>{bt=r,Y.style.display="block"};Y.onclick=async()=>{if(!bt)return;Y.disabled=!0,d("Activating\u2026");let r=await P(e,`/v1/editor/goals/${encodeURIComponent(bt)}/publish`,{});Y.disabled=!1,r==="ok"?(d("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),Y.style.display="none",bt=null):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.":"\u26A0 Couldn\u2019t activate \u2014 try again.",!1)};let _t=(r,i)=>`${Lt(r)||"goal"}-${ie(i)}`.slice(0,128),xt=async(r,i)=>{d("Saving\u2026");let l=await P(e,`/v1/editor/goals/${encodeURIComponent(r)}`,i);l==="ok"&&ge(r),X(l,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};N.onclick=()=>{var i;if(!t||!B)return;let r=_t(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify(B));xt(r,{event:"click",locator:B})},F.onclick=()=>{var p,f;let r=t==null?void 0:t.closest("form");if(!r)return;let i=pt(r,document),l=(f=(p=r.getAttribute("id"))!=null?p:r.getAttribute("name"))!=null?f:"form-submitted";xt(_t(l,JSON.stringify(i)),{event:"form_submit",locator:i})},it.onclick=()=>{let r=window.location.pathname||"/",i=Lt(r)?`reached-${Lt(r)}`:"page-visited";xt(_t(i,r),{event:"url_reached",urlPattern:r})};let Rt=[{label:"25% \u2014 skimmed the top",value:.25},{label:"50% \u2014 read halfway",value:.5},{label:"75% \u2014 read most of the page",value:.75},{label:"90% \u2014 read to the end",value:.9}];st.onclick=()=>{ht([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Rt.map(r=>r.label)}],"Track it",r=>{var p;let i=(p=Rt.find(f=>f.label===r.depth))!=null?p:Rt[2],l=Math.round(i.value*100);xt(`read-${l}pct`,{event:"scroll_depth",threshold:i.value}),R()})};let vt=null,me=r=>{vt=r,L.style.display="block"};L.onclick=async()=>{if(!vt)return;L.disabled=!0,d("Turning on\u2026");let r=await P(e,`/v1/editor/funnels/${encodeURIComponent(vt)}/publish`,{});L.disabled=!1,r==="ok"?(d("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),L.style.display="none",vt=null):d(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.":"\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},w.onclick=async()=>{var g;d("Loading your goals\u2026");let r=await Ht(e,"/v1/editor/goals"),i=(g=r==null?void 0:r.goals)!=null?g:[];if(i.length<2){d("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}d("Pick the steps in order \u2014 first click = first step."),R();let l=[],p=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),f=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});T.append(p,f);let k=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");T.append(k);let S=new Map,b=()=>{var m,x;for(let[v,H]of S){let et=l.indexOf(v),nt=(x=(m=i.find(ye=>ye.goal_id===v))==null?void 0:m.display_name)!=null?x:v;H.textContent=et===-1?nt:`${et+1}. ${nt}`,H.style.background=et===-1?"#374151":"#6366f1"}};for(let m of i){let x=a("button",ot(D({},y("#374151")),{textAlign:"left"}));S.set(m.goal_id,x),x.onclick=()=>{l=ee(l,m.goal_id),b()},T.append(x)}b();let $=a("button",y("#6366f1"),"Save funnel"),A=a("button",ot(D({},y("transparent")),{opacity:"0.6"}),"Cancel");A.onclick=R,$.onclick=async()=>{let m=ne(f.value,l);if(!m.ok){d(`\u26A0 ${m.error}`,!1);return}d("Saving\u2026");let x=await P(e,`/v1/editor/funnels/${encodeURIComponent(m.funnelId)}`,m.body);x==="ok"&&(R(),me(m.funnelId)),X(x,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},T.append($,A)},_.onclick=async()=>{var k,S;let r=at;if(!r)return;d("Loading funnels\u2026");let i=await Ht(e,"/v1/editor/funnels"),l=(k=i==null?void 0:i.funnels)!=null?k:[];if(l.length===0){d("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let p=await Ht(e,"/v1/editor/goals"),f=new Map(((S=p==null?void 0:p.goals)!=null?S:[]).map(b=>[b.goal_id,b.display_name]));ht([{key:"funnel",label:"Funnel",type:"select",options:l.map(b=>It(b))},{key:"step",label:"Which step does this element serve?",type:"select",options:Mt(l[0],f).map(b=>b.label)}],"Attach",async b=>{var m;let $=(m=l.find(x=>It(x)===b.funnel))!=null?m:l[0],A=Mt($,f).findIndex(x=>x.label===b.step);d("Attaching\u2026");let g=await P(e,`/v1/editor/funnels/${encodeURIComponent($.funnel_id)}/assign`,{slotId:r,stepIndex:A>=0?A:null});g==="ok"&&R(),X(g,`\u2713 Attached \u2014 this test now works toward \u201C${$.display_name}\u201D.`)})},z.onclick=()=>{if(!t||!B)return;let r=B;ht([{key:"color",label:"Text colour",type:"color"},{key:"background",label:"Background colour",type:"color"},{key:"fontSize",label:"Font size (e.g. 20px)"},{key:"fontWeight",label:"Font weight (e.g. 700)"},{key:"fontFamily",label:Ot.length?`Font (this site has: ${Ot.slice(0,3).join(", ")})`:"Font (e.g. Georgia, serif)"},{key:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(i,l)=>{var $;let{style:p,errors:f}=de(i),k=!1;for(let A of le)l(A,($=f[A])!=null?$:null),f[A]&&(k=!0);if(k){d("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(p).length===0){d("\u26A0 Enter at least one style change.",!1);return}let S=Ct("style",r,t);d("Saving\u2026");let b=await P(e,`/v1/editor/slots/${encodeURIComponent(S)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:p}}]}});b==="ok"&&(R(),$t(S)),X(b,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Wt=r=>{if(!t)return;let i=t.parentElement;if(!i)return;tt||(ut=i,yt=t.nextSibling,tt=!0),r==="up"&&ct?i.insertBefore(t,ct):r==="down"&&dt&&i.insertBefore(t,dt.nextSibling);let l=Tt(t,document);ct=l.prevEl,dt=l.nextEl,M=l.prevLocator,Q=l.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(p){}s(),At(!0),d("Previewing the new position \u2014 keep moving, save, or undo.")};U.onclick=()=>Wt("up"),W.onclick=()=>Wt("down"),mt.onclick=()=>{Gt(),d("Move undone \u2014 back to the original position.")},gt.onclick=async()=>{if(!t||!B||!tt||!lt)return;let r=M?"moveAfter":"moveBefore",i=M!=null?M:Q;if(!i){d("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let l=Ct("move",B,t);d("Saving\u2026");let p=await P(e,`/v1/editor/slots/${encodeURIComponent(l)}`,{kind:"arms",target:B,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:i}}]}});p==="ok"&&(tt=!1,ut=null,yt=null,At(!1),$t(l)),X(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let he=()=>{var r;document.removeEventListener("mousemove",jt,!0),document.removeEventListener("click",Ut,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),ft(document),n.remove(),o.remove(),u.remove(),window.__sentientEditor=null,(r=document.querySelector("meta[data-sentient-editor]"))==null||r.remove(),wt()};zt.onclick=he,document.addEventListener("mousemove",jt,!0),document.addEventListener("click",Ut,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c)}function y(e){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:e,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}var pe="sentient-preview-bar";async function Ve(e,t){var O,C,Z,J,K,j,I,z,N,F,it,st;let n=null;try{let w=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});w.ok&&(n=(C=((O=(await w.json()).slots)!=null?O:[]).find(L=>L.slot_id===t&&L.kind==="arms"))!=null?C:null)}catch(w){}let o=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});o.id=pe;let s=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");s.onclick=()=>{wt();let w=new URL(location.href);for(let _ of["sentient_editor","sentient_preview","sentient_arm"])w.searchParams.delete(_);location.assign(w.toString())};let c=(j=(K=(Z=n==null?void 0:n.draft_config)==null?void 0:Z.arms)!=null?K:(J=n==null?void 0:n.published_config)==null?void 0:J.arms)!=null?j:[];if(!n||c.length===0){o.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),s),((I=document.body)!=null?I:document.documentElement).append(o);return}let u=new URLSearchParams(location.search).get("sentient_arm"),E=(N=(z=c.find(w=>w.id===u))!=null?z:c[1])!=null?N:c[0];o.append(a("span",{fontWeight:"700"},`Previewing: ${(F=n.display_name)!=null?F:n.slot_id}`));let h=n.target&&typeof n.target=="object"?V(n.target,document):null;if(!h)o.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{te(h,E.ops,`preview-${n.slot_id}`,document);try{h.scrollIntoView({block:"center"})}catch(w){}for(let w of c){let _=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:w.id===E.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(it=w.displayName)!=null?it:w.id);_.onclick=()=>{let L=new URL(location.href);L.searchParams.set("sentient_arm",w.id),location.assign(L.toString())},o.append(_)}}o.append(s),((st=document.body)!=null?st:document.documentElement).append(o)}async function Ze(){if(typeof document=="undefined")return;let e=Fe();if(!e)return;let t=await De(e);if(!t.ok){t.unauthorized?(wt(),re(ze)):re(Ne);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(pe)||await Ve(e,n);return}if(document.getElementById(rt))return;ue(e);let o=await Ge(e);ae(o,document)}Ze();return Le(Je);})();
24
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function ae(e){var o,s;de(),(o=document.getElementById(Rt))==null||o.remove();let t=a("div",{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)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=Rt;let n=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,a("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function qe(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Ye(e){try{let t=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let n=(await t.json()).projectId;return n?{ok:!0,projectId:n}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}async function O(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?"ok":o.status===401?"expired":"error"}catch(o){return"error"}}async function Ve(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await o.json().catch(()=>null);return o.ok?{r:"ok",data:s}:{r:o.status===401?"expired":"error",data:s}}catch(o){return{r:"error",data:null}}}var Nt=[];async function Je(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let n=await t.json();return Nt=Array.isArray(n.fonts)?n.fonts.filter(o=>typeof o=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function $t(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return n.ok?await n.json():null}catch(n){return null}}function yt(e=document){for(let t of Array.from(e.querySelectorAll(`.${zt}`)))t.remove()}function ce(e,t=document){var o;yt(t);let n=0;for(let s of e){if(n>=Ge)break;let d=et(s.locator,t);if(!d)continue;let f=d.getBoundingClientRect(),v=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});v.className=zt;let m=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${f.left}px`,top:`${Math.max(0,f.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);m.className=zt,((o=t.body)!=null?o:t.documentElement).append(v,m),n+=1}}function _t(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,s=n?mt(n,t):null,d=o?mt(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&s&&Ct(s,n,t)?s:null,nextLocator:o&&d&&Ct(d,o,t)?d:null}}var ue=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Xe=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Ze=new Set(["left","center","right","justify","start","end"]),Ke=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Qe=/^(rgb|rgba|hsl|hsla)\(/i;function tn(e){return Ke.test(e)||Qe.test(e)}function pe(e,t){switch(e){case"fontSize":case"borderRadius":return Xe.test(t)?null:"Add a unit, e.g. 20px or 1.5rem.";case"fontWeight":return/^(normal|bold|bolder|lighter)$/i.test(t)||/^\d{1,4}$/.test(t)&&+t>=1&&+t<=1e3?null:"Use 100\u2013900, or normal/bold.";case"textAlign":return Ze.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return tn(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(o=>o.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(o=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(o))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function fe(e){let t={},n={};for(let o of ue){let s=e[o];if(typeof s!="string")continue;let d=s.trim();if(d==="")continue;if(!Bt(d)){n[o]="That value isn\u2019t allowed.";continue}let f=pe(o,d);if(f){n[o]=f;continue}t[o]=d}return{style:t,errors:n}}function a(e,t,n){let o=document.createElement(e);return Object.assign(o.style,t),n!==void 0&&(o.textContent=n),o}function ge(e){var Vt;let t=null,n=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=De;let o=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});o.id=je;let s=()=>{if(!t||!t.isConnected){o.style.display="none";return}let r=t.getBoundingClientRect();Object.assign(o.style,{display:"block",left:`${r.left-2}px`,top:`${r.top-2}px`,width:`${r.width}px`,height:`${r.height}px`})},d=()=>s();de();let f=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"320px",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});f.id=st;let v=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});v.className="sntedi-dot";let m=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});m.append(v,a("span",{},"SentientUI editor"));let z=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),B=!1,G=a("button",h("#374151"),"Pause selecting");G.onclick=()=>{B=!B,G.textContent=B?"Resume selecting":"Pause selecting",B?(n.style.display="none",yt(document),c("Selection paused \u2014 browse normally, then resume.")):c("Click any element on the page to adapt it.")};let I=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),_=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),M=r=>a("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},r),L=a("button",h("#6366f1"),"Test different text here"),P=a("button",h("#374151"),"Change style"),H=a("button",h("#374151"),"Try a different arrangement"),U=a("button",h("#374151"),"Track clicks as a goal"),W=a("button",h("#374151"),"Track form submissions as a goal"),at=a("button",h("#374151"),"Track page visits as a goal"),S=a("button",h("#374151"),"Track reading this far as a goal"),q=a("button",h("#374151"),"Set up a funnel"),N=a("button",h("#374151"),"Attach this test to a funnel step"),X=a("button",h("#10b981"),"Turn the funnel on"),Z=a("button",h("#374151"),"Move up"),K=a("button",h("#374151"),"Move down"),bt=a("button",h("#6366f1"),"Save this arrangement"),xt=a("button",h("#374151"),"Undo"),Ft=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Close editor"),Q=a("button",h("#10b981"),"Publish now \u2014 go live"),tt=a("button",h("#10b981"),"Start tracking now");for(let r of[L,P,H,U,Z,K])r.disabled=!0;let Dt=[L,P,H,U,W,Z,K];for(let r of Dt)r.style.display="none";bt.style.display="none",xt.style.display="none",Q.style.display="none",tt.style.display="none",N.style.display="none",X.style.display="none",f.append(m,z,G,I,_,M("Content & style"),L,P,H,M("Track a goal"),U,W,at,S,M("Funnels"),q,N,X,M("Move"),Z,K,bt,xt,Q,tt,Ft),((Vt=document.body)!=null?Vt:document.documentElement).append(n,o,f);let $=a("div",{marginTop:"10px"});f.append($);let R=()=>{$.textContent=""},lt=(r,i,l)=>{var T;R();let p={},u={},g={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let b of r){let x=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},b.label);if($.append(x),b.type==="select"){let E=a("select",g);E.setAttribute("data-field",b.key);let j=document.createElement("option");j.value="",j.textContent="\u2014 no change \u2014",E.append(j);for(let rt of(T=b.options)!=null?T:[]){let it=document.createElement("option");it.value=rt,it.textContent=rt,E.append(it)}p[b.key]=()=>E.value,$.append(E)}else if(b.type==="color"){let E=a("input",V(F({},g),{padding:"2px",height:"34px"}));E.type="color",E.setAttribute("data-field",b.key);let j=!1;E.addEventListener("input",()=>{j=!0}),p[b.key]=()=>j?E.value:"",$.append(E)}else{let E=a("input",g);E.setAttribute("data-field",b.key),b.value!==void 0&&(E.value=b.value),p[b.key]=()=>E.value,$.append(E)}let k=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});k.setAttribute("data-feedback",b.key),u[b.key]=k,$.append(k)}let w=(b,x)=>{let k=u[b];k&&(k.textContent=x!=null?x:"",k.style.display=x?"block":"none")},y=a("button",h("#6366f1"),i),C=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Cancel");y.onclick=()=>l(Object.fromEntries(Object.entries(p).map(([b,x])=>[b,x()])),w),C.onclick=R,$.append(y,C)},c=(r,i=!0)=>{_.textContent=r,_.style.color=i?"#a7f3d0":"#fca5a5"},Y=(r,i)=>{r==="ok"?c(i,!0):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.":"\u26A0 Couldn\u2019t save \u2014 try again.",!1)},dt=null,vt=r=>{dt=r,Q.style.display="block",N.style.display="block"};Q.onclick=async()=>{if(!dt)return;Q.disabled=!0,c("Publishing\u2026");let r=await O(e,`/v1/editor/slots/${encodeURIComponent(dt)}/publish`,{});Q.disabled=!1,r==="ok"?(c("\u2713 Published \u2014 live for new visitors.",!0),Q.style.display="none",dt=null):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.":"\u26A0 Couldn\u2019t publish \u2014 try again.",!1)};let A=null,ct=!1,ut=null,pt=null,D=null,nt=null,ft=null,kt=null,ot=!1,jt=(r,i)=>ct?r?"":`Nothing to swap with ${i} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Gt=()=>{Z.disabled=!ct||!D,K.disabled=!ct||!nt,Z.title=Z.disabled?jt(D,"above"):"",K.title=K.disabled?jt(nt,"below"):""},It=r=>{bt.style.display=r?"block":"none",xt.style.display=r?"block":"none",Gt()},Ut=()=>{if(ot&&t&&ft&&ft.insertBefore(t,kt),ot=!1,ft=null,kt=null,t){let r=_t(t,document);ut=r.prevEl,pt=r.nextEl,D=r.prevLocator,nt=r.nextLocator}s(),It(!1)},Wt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i)||i===n)return;yt(document);let l=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${l.left}px`,top:`${l.top}px`,width:`${l.width}px`,height:`${l.height}px`})},he=r=>{var l;let i=((l=r.textContent)!=null?l:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:r.tagName.toLowerCase()},qt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i))return;r.preventDefault(),r.stopPropagation(),Ut(),R(),t=i,A=mt(i,document);let l=Ct(A,i,document);ct=l,s(),I.style.display="block",I.textContent=`Selected: ${he(i)}`,c(l?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",l);for(let w of Dt)w.style.display="block";let p=i.childElementCount===0;L.disabled=!l||!p,L.title=l?p?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",P.disabled=!l,H.disabled=!l,U.disabled=!l;let u=i.closest("form");W.style.display=u?"block":"none",W.disabled=!u;let g=_t(i,document);ut=g.prevEl,pt=g.nextEl,D=g.prevLocator,nt=g.nextLocator,Gt()};L.onclick=()=>{var l,p;if(!t||!A)return;let r=A,i=(p=(l=t.textContent)==null?void 0:l.trim())!=null?p:"";lt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async u=>{let g=u.alt.trim();if(!g){c("\u26A0 Enter alternative wording to test.",!1);return}if(g===u.current.trim()){c("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let w=ht("text",r,t);c("Saving\u2026");let y=await O(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:u.current}},{id:"b",displayName:"Alternative",ops:{text:u.alt}}]}});y==="ok"&&(R(),vt(w)),Y(y,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let gt=null,ye=(r,i,l)=>{lt(r.fields.map(p=>{var u;return{key:p.id,label:p.kind==="href"?`${p.label} (link \u2014 required)`:p.label,value:(u=p.default)!=null?u:""}}),"Save draft",async p=>{var y,C,T;c("Saving\u2026");let u=await Ve(e,`/v1/editor/arrangements/${encodeURIComponent(r.id)}/instantiate`,{fields:p});if(u.r!=="ok"||!((y=u.data)!=null&&y.blocks)){u.r==="expired"?Y("expired",""):c(`\u26A0 ${(T=(C=u.data)==null?void 0:C.reason)!=null?T:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let g=ht("arrange",i,l),w=await O(e,`/v1/editor/slots/${encodeURIComponent(g)}`,{kind:"arms",target:i,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:r.id,displayName:r.name,blocks:u.data.blocks}],baseline:"original"}});w==="ok"&&(R(),vt(g)),Y(w,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish now\u201D to go live.")})};H.onclick=async()=>{var p;if(!t||!A)return;let r=A,i=t;if(R(),c("Loading arrangements\u2026"),!gt){let u=await $t(e,"/v1/editor/arrangements");gt=(p=u==null?void 0:u.arrangements)!=null?p:null}if(!gt||gt.length===0){c("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}c("Pick an arrangement to test against this section.");for(let u of gt){let g=a("button",V(F({},h("#374151")),{textAlign:"left"}));g.append(a("div",{fontWeight:"600"},u.name),a("div",{fontSize:"11px",opacity:"0.7"},u.description)),g.onclick=()=>ye(u,r,i),$.append(g)}let l=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Cancel");l.onclick=R,$.append(l)};let Et=null,be=r=>{Et=r,tt.style.display="block"};tt.onclick=async()=>{if(!Et)return;tt.disabled=!0,c("Activating\u2026");let r=await O(e,`/v1/editor/goals/${encodeURIComponent(Et)}/publish`,{});tt.disabled=!1,r==="ok"?(c("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),tt.style.display="none",Et=null):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.":"\u26A0 Couldn\u2019t activate \u2014 try again.",!1)};let Mt=(r,i)=>`${At(r)||"goal"}-${le(i)}`.slice(0,128),wt=async(r,i)=>{c("Saving\u2026");let l=await O(e,`/v1/editor/goals/${encodeURIComponent(r)}`,i);l==="ok"&&be(r),Y(l,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};U.onclick=()=>{var i;if(!t||!A)return;let r=Mt(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify(A));wt(r,{event:"click",locator:A})},W.onclick=()=>{var p,u;let r=t==null?void 0:t.closest("form");if(!r)return;let i=mt(r,document),l=(u=(p=r.getAttribute("id"))!=null?p:r.getAttribute("name"))!=null?u:"form-submitted";wt(Mt(l,JSON.stringify(i)),{event:"form_submit",locator:i})},at.onclick=()=>{let r=window.location.pathname||"/",i=At(r)?`reached-${At(r)}`:"page-visited";wt(Mt(i,r),{event:"url_reached",urlPattern:r})};let Pt=[{label:"25% \u2014 skimmed the top",value:.25},{label:"50% \u2014 read halfway",value:.5},{label:"75% \u2014 read most of the page",value:.75},{label:"90% \u2014 read to the end",value:.9}];S.onclick=()=>{lt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Pt.map(r=>r.label)}],"Track it",r=>{var p;let i=(p=Pt.find(u=>u.label===r.depth))!=null?p:Pt[2],l=Math.round(i.value*100);wt(`read-${l}pct`,{event:"scroll_depth",threshold:i.value}),R()})};let St=null,xe=r=>{St=r,X.style.display="block"};X.onclick=async()=>{if(!St)return;X.disabled=!0,c("Turning on\u2026");let r=await O(e,`/v1/editor/funnels/${encodeURIComponent(St)}/publish`,{});X.disabled=!1,r==="ok"?(c("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),X.style.display="none",St=null):c(r==="expired"?"Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.":"\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},q.onclick=async()=>{var b;c("Loading your goals\u2026");let r=await $t(e,"/v1/editor/goals"),i=(b=r==null?void 0:r.goals)!=null?b:[];if(i.length<2){c("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}c("Pick the steps in order \u2014 first click = first step."),R();let l=[],p=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});$.append(p,u);let g=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");$.append(g);let w=new Map,y=()=>{var x,k;for(let[E,j]of w){let rt=l.indexOf(E),it=(k=(x=i.find(ke=>ke.goal_id===E))==null?void 0:x.display_name)!=null?k:E;j.textContent=rt===-1?it:`${rt+1}. ${it}`,j.style.background=rt===-1?"#374151":"#6366f1"}};for(let x of i){let k=a("button",V(F({},h("#374151")),{textAlign:"left"}));w.set(x.goal_id,k),k.onclick=()=>{l=re(l,x.goal_id),y()},$.append(k)}y();let C=a("button",h("#6366f1"),"Save funnel"),T=a("button",V(F({},h("transparent")),{opacity:"0.6"}),"Cancel");T.onclick=R,C.onclick=async()=>{let x=ie(u.value,l);if(!x.ok){c(`\u26A0 ${x.error}`,!1);return}c("Saving\u2026");let k=await O(e,`/v1/editor/funnels/${encodeURIComponent(x.funnelId)}`,x.body);k==="ok"&&(R(),xe(x.funnelId)),Y(k,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},$.append(C,T)},N.onclick=async()=>{var g,w;let r=dt;if(!r)return;c("Loading funnels\u2026");let i=await $t(e,"/v1/editor/funnels"),l=(g=i==null?void 0:i.funnels)!=null?g:[];if(l.length===0){c("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let p=await $t(e,"/v1/editor/goals"),u=new Map(((w=p==null?void 0:p.goals)!=null?w:[]).map(y=>[y.goal_id,y.display_name]));lt([{key:"funnel",label:"Funnel",type:"select",options:l.map(y=>Ht(y))},{key:"step",label:"Which step does this element serve?",type:"select",options:Ot(l[0],u).map(y=>y.label)}],"Attach",async y=>{var x;let C=(x=l.find(k=>Ht(k)===y.funnel))!=null?x:l[0],T=Ot(C,u).findIndex(k=>k.label===y.step);c("Attaching\u2026");let b=await O(e,`/v1/editor/funnels/${encodeURIComponent(C.funnel_id)}/assign`,{slotId:r,stepIndex:T>=0?T:null});b==="ok"&&R(),Y(b,`\u2713 Attached \u2014 this test now works toward \u201C${C.display_name}\u201D.`)})},P.onclick=()=>{if(!t||!A)return;let r=A;lt([{key:"color",label:"Text colour",type:"color"},{key:"background",label:"Background colour",type:"color"},{key:"fontSize",label:"Font size (e.g. 20px)"},{key:"fontWeight",label:"Font weight (e.g. 700)"},{key:"fontFamily",label:Nt.length?`Font (this site has: ${Nt.slice(0,3).join(", ")})`:"Font (e.g. Georgia, serif)"},{key:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(i,l)=>{var C;let{style:p,errors:u}=fe(i),g=!1;for(let T of ue)l(T,(C=u[T])!=null?C:null),u[T]&&(g=!0);if(g){c("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(p).length===0){c("\u26A0 Enter at least one style change.",!1);return}let w=ht("style",r,t);c("Saving\u2026");let y=await O(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:p}}]}});y==="ok"&&(R(),vt(w)),Y(y,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Yt=r=>{if(!t)return;let i=t.parentElement;if(!i)return;ot||(ft=i,kt=t.nextSibling,ot=!0),r==="up"&&ut?i.insertBefore(t,ut):r==="down"&&pt&&i.insertBefore(t,pt.nextSibling);let l=_t(t,document);ut=l.prevEl,pt=l.nextEl,D=l.prevLocator,nt=l.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(p){}s(),It(!0),c("Previewing the new position \u2014 keep moving, save, or undo.")};Z.onclick=()=>Yt("up"),K.onclick=()=>Yt("down"),xt.onclick=()=>{Ut(),c("Move undone \u2014 back to the original position.")},bt.onclick=async()=>{if(!t||!A||!ot||!ct)return;let r=D?"moveAfter":"moveBefore",i=D!=null?D:nt;if(!i){c("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let l=ht("move",A,t);c("Saving\u2026");let p=await O(e,`/v1/editor/slots/${encodeURIComponent(l)}`,{kind:"arms",target:A,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:i}}]}});p==="ok"&&(ot=!1,ft=null,kt=null,It(!1),vt(l)),Y(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let ve=()=>{var r;document.removeEventListener("mousemove",Wt,!0),document.removeEventListener("click",qt,!0),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d),yt(document),n.remove(),o.remove(),f.remove(),window.__sentientEditor=null,(r=document.querySelector("meta[data-sentient-editor]"))==null||r.remove(),Tt()};Ft.onclick=ve,document.addEventListener("mousemove",Wt,!0),document.addEventListener("click",qt,!0),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d)}function h(e){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:e,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}var me="sentient-preview-bar";async function en(e,t){var z,B,G,I,_,M,L,P,H,U,W,at;let n=null;try{let S=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});S.ok&&(n=(B=((z=(await S.json()).slots)!=null?z:[]).find(N=>N.slot_id===t&&N.kind==="arms"))!=null?B:null)}catch(S){}let o=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});o.id=me;let s=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");s.onclick=()=>{Tt();let S=new URL(location.href);for(let q of["sentient_editor","sentient_preview","sentient_arm"])S.searchParams.delete(q);location.assign(S.toString())};let d=(M=(_=(G=n==null?void 0:n.draft_config)==null?void 0:G.arms)!=null?_:(I=n==null?void 0:n.published_config)==null?void 0:I.arms)!=null?M:[];if(!n||d.length===0){o.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),s),((L=document.body)!=null?L:document.documentElement).append(o);return}let f=new URLSearchParams(location.search).get("sentient_arm"),v=(H=(P=d.find(S=>S.id===f))!=null?P:d[1])!=null?H:d[0];o.append(a("span",{fontWeight:"700"},`Previewing: ${(U=n.display_name)!=null?U:n.slot_id}`));let m=n.target&&typeof n.target=="object"?et(n.target,document):null;if(!m)o.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{oe(m,v.ops,`preview-${n.slot_id}`,document);try{m.scrollIntoView({block:"center"})}catch(S){}for(let S of d){let q=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:S.id===v.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(W=S.displayName)!=null?W:S.id);q.onclick=()=>{let N=new URL(location.href);N.searchParams.set("sentient_arm",S.id),location.assign(N.toString())},o.append(q)}}o.append(s),((at=document.body)!=null?at:document.documentElement).append(o)}async function nn(){if(typeof document=="undefined")return;let e=qe();if(!e)return;let t=await Ye(e);if(!t.ok){t.unauthorized?(Tt(),ae(Ue)):ae(We);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(me)||await en(e,n);return}if(document.getElementById(st))return;ge(e);let o=Qt(document);o&&O(e,"/v1/editor/palette",o);let s=await Je(e);ce(s,document)}nn();return $e(on);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var ke=Object.defineProperty;var fn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols;var ot=Object.prototype.hasOwnProperty,mn=Object.prototype.propertyIsEnumerable;var rt=(e,t,n)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t)=>{for(var n in t||(t={}))ot.call(t,n)&&rt(e,n,t[n]);if(nt)for(var n of nt(t))mn.call(t,n)&&rt(e,n,t[n]);return e};var it=(e,t)=>()=>(e&&(t=e(e=0)),t);var st=(e,t)=>{for(var n in t)ke(e,n,{get:t[n],enumerable:!0})},hn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of gn(t))!ot.call(e,a)&&a!==n&&ke(e,a,{get:()=>t[a],enumerable:!(r=fn(t,a))||r.enumerable});return e};var yn=e=>hn(ke({},"__esModule",{value:!0}),e);var vn,bn,wn,at,Sn,An,lt,R,be,Ie=it(()=>{"use strict";vn=Object.defineProperty,bn=Object.defineProperties,wn=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable,lt=(e,t,n)=>t in e?vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&lt(e,n,t[n]);if(at)for(var n of at(t))An.call(t,n)&&lt(e,n,t[n]);return e},be=(e,t)=>bn(e,wn(t))});var yt={};st(yt,{LOCAL_ENGINE_AVAILABLE:()=>Cn,createLocalEngine:()=>On});function On(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Cn,vt=it(()=>{"use strict";Cn=!1});var Dr={};st(Dr,{applyPersonaAttributes:()=>Ne,applyRegistrySlots:()=>Be,applySlotArms:()=>Ke,applySlotAttributes:()=>je,parseEditorToken:()=>an,parsePersonaPreview:()=>cn,parsePreview:()=>ln,parseSnippetConfig:()=>$e,reapply:()=>tt,run:()=>dn,version:()=>Ze});Ie();var xn=["buyer","researcher","deal_seeker","browser"];var En={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Ce(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function ct(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let a=n.slice(0,r);if(a in t)return null;t[a]=n.slice(r+1)}return t}function We(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return Ce(e.baseline);if(typeof e.baseline=="string")return e.baseline;let a={};for(let[o,l]of Object.entries((n=e.dims)!=null?n:{}))a[o]=(r=l[0])!=null?r:"";return Ce(a)}function ut(e,t){var n,r;return e.dims!=null?(r=(n=ct(t))!=null?n:ct(We(e)))!=null?r:{}:t}function fe(e){return e>=.3?e<.7?"medium":"high":"low"}var Nr=xn.map(e=>({key:e,displayName:En[e]}));var kn=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function dt(e){return In(e)!==null}function In(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=kn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function pt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function ft(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(a){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function gt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function mt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ve(e){return R(R(R({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function Fe(e){let t=Ve(e);return ut(t,We(t))}function ht(e){return typeof e=="string"?e:Ce(e)}Ie();function wt(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function St(e){return e?`_${e.slice(0,12)}`:""}var _n="_snt_uid",Rn=365,Tn="_snt_uid";function Ln(){return wt()}function Pn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Dn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Mn(e){try{return localStorage.getItem(e)}catch(t){return null}}function $n(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Nn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function jn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Kn(e){try{sessionStorage.removeItem(e)}catch(t){}}function Bn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Un(e){try{localStorage.removeItem(e)}catch(t){}}function Gn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var qn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function At(e){var t,n,r,a,o,l;if(typeof window=="undefined")return qn;let d=St(e==null?void 0:e.apiKey),i=(t=e==null?void 0:e.cookieName)!=null?t:`${_n}${d}`,s=`${Tn}${d}`,c=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Rn)*24*60*60,u=h=>h&&h.length>0?h:null,m=(l=(o=(a=(r=u(Pn(i)))!=null?r:u(Mn(s)))!=null?a:u(Nn(s)))!=null?o:u(e==null?void 0:e.ssrSessionId))!=null?l:Ln();Dn(i,m,c);let v=$n(s,m),I=Bn(i),C=v?!1:jn(s,m),k=!v&&!I&&!C;return{getSessionId:()=>m,isEphemeral:()=>k,destroy:()=>{m=null,Gn(i),Un(s),Kn(s)}}}function Re(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function xt(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Et(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function Te(e,t,n){try{let r=(()=>{try{let o=localStorage.getItem(n);if(!o)return[];let l=JSON.parse(o);return Array.isArray(l)?l:[]}catch(o){return[]}})(),a=new Map;for(let o of r)a.set(o.id,o);for(let o of e)a.set(o.id,o);localStorage.setItem(n,JSON.stringify([...a.values()].slice(-t)))}catch(r){}}function kt(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let a=new Set(e),o=r.filter(l=>!a.has(l.id));if(o.length===r.length)return;o.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(o))}catch(n){}}var zn=500,Wn=56*1024;function It(e){return`_snt_retry_${e.slice(0,12)}`}var Vn={push:()=>{},flush:()=>{},destroy:()=>{}};function Fn(e){var t,n,r;if(typeof window=="undefined")return Vn;let a=(t=e.flushIntervalMs)!=null?t:5e3,o=(n=e.maxBatchSize)!=null?n:20,l=(r=e.maxRetrySize)!=null?r:100,d=e.ingestUrl,i=e.apiKey,s=It(i),c=[],u=new Set,m=[],v=g=>{for(let E of g)I.delete(E),!u.has(E)&&(u.add(E),m.push(E));for(;m.length>zn;){let E=m.shift();E&&u.delete(E)}kt(g,s)},I=new Set,C=g=>{u.has(g.id)||I.has(g.id)||(I.add(g.id),c.push(g))},k=g=>{for(let E of g)u.has(E.id)||(I.add(E.id),c.push(E))},h=Et(s,l);for(let g of h)C(g);let f=0,x=0,O=(g,E=!0)=>{if(g.length===0)return;let te=JSON.stringify(g),q=g.map(H=>H.id),ne;try{ne=fetch(d,{method:"POST",keepalive:!0,body:te,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(H){Te(g,l,s),k(g),x++,f=Date.now()+Re(x);return}let ce=H=>{if(xt(H)!=="retry"){if(!H.ok&&E){let ue=g.filter(F=>F.eventType!=="pageview");if(ue.length>0&&ue.length<g.length){v(g.filter(F=>F.eventType==="pageview").map(F=>F.id)),O(ue,!1);return}}v(q),x=0,f=0;return}Te(g,l,s),k(g),x++,f=Date.now()+Re(x)};ne instanceof Promise?ne.then(ce).catch(()=>{Te(g,l,s),k(g),x++,f=Date.now()+Re(x)}):ce(ne)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,b=g=>G?G.encode(g).length:g.length,P=g=>{let E=[],te=2;for(let q of g){let ne=b(JSON.stringify(q))+1;if(E.length>0&&te+ne>Wn||E.length>=o)break;E.push(q),te+=ne}return E},$=()=>{try{if(Date.now()<f)return;for(;c.length>0&&!(Date.now()<f);){let g=c.filter(te=>!u.has(te.id));if(c.length=0,g.length===0)break;let E=P(g);if(E.length===0)break;E.length<g.length&&c.push(...g.slice(E.length)),O(E)}}catch(g){}},D=!0,S=null;S=setInterval(()=>{D&&$()},a);let A=()=>{document.visibilityState==="hidden"&&$()},w=()=>{$()};return document.addEventListener("visibilitychange",A),window.addEventListener("pagehide",w),{push(g){C(g),c.length>=o&&$()},flush:$,destroy(){D=!1,S!==null&&(clearInterval(S),S=null),document.removeEventListener("visibilitychange",A),window.removeEventListener("pagehide",w),$()}}}var Jn=200;function Ct(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Hn={send:()=>{},flush:()=>{},destroy:()=>{}};function Yn(e){var t,n,r;if(typeof window=="undefined")return Hn;let a=(t=e.flushIntervalMs)!=null?t:5e3,o=(n=e.maxRetrySize)!=null?n:100,l=(r=e.maxPerFlush)!=null?r:5,d=Ct(e.apiKey),i=[],s=new Set,c=new Set,u=[],m=0,v=0,I=!1,C=b=>{for(s.delete(b.id),c.has(b.id)||(c.add(b.id),u.push(b.id));u.length>Jn;){let P=u.shift();P&&c.delete(P)}kt([b.id],d)},k=b=>{Te([b],o,d),!c.has(b.id)&&!s.has(b.id)&&(s.add(b.id),i.push(b)),v++,m=Date.now()+Re(v)},h=b=>{let P;try{P=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(D){k(b);return}let $=D=>{var S;let A=xt(D);if(A==="retry"){k(b);return}A==="dropped"&&((S=e.onDrop)==null||S.call(e,b,D.status)),C(b),v=0,m=0};P instanceof Promise?P.then($).catch(()=>k(b)):$(P)},f=()=>{try{if(I||Date.now()<m)return;let b=0;for(;i.length>0&&b<l&&!(Date.now()<m);){let P=i.shift();s.delete(P.id),!c.has(P.id)&&(b++,h(P))}}catch(b){}};for(let b of Et(d,o))s.has(b.id)||(s.add(b.id),i.push(b));let x=setInterval(f,a),O=()=>{document.visibilityState==="hidden"&&f()},G=()=>f();return document.addEventListener("visibilitychange",O),window.addEventListener("pagehide",G),{send(b){if(!I&&!(c.has(b.id)||s.has(b.id))){if(Date.now()<m){s.add(b.id),i.push(b);return}h(b)}},flush:f,destroy(){clearInterval(x),document.removeEventListener("visibilitychange",O),window.removeEventListener("pagehide",G),f(),I=!0}}}var Xn=1800*1e3;function Oe(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Zn(e=Xn,t){let n=new Map,r=`_snt_asgn${St(t)}_`,a=(i,s)=>`${r}${encodeURIComponent(i)}:${encodeURIComponent(s)}`,o=i=>{let s=i.slice(r.length),c=s.indexOf(":");if(c<0)return null;try{return{componentId:decodeURIComponent(s.slice(0,c)),segment:decodeURIComponent(s.slice(c+1))}}catch(u){return null}},l=()=>{try{let i=[];for(let s=0;s<localStorage.length;s++){let c=localStorage.key(s);c!=null&&c.startsWith(r)&&i.push(c)}return i}catch(i){return[]}},d=i=>i.assignedAt+(i.ttlMs&&i.ttlMs>0?i.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let i of l())try{let s=localStorage.getItem(i);if(!s)continue;let c=JSON.parse(s);if(d(c)){localStorage.removeItem(i);continue}let u=o(i);if(!u)continue;n.set(Oe(u.componentId,u.segment),c)}catch(s){}})(),{get(i,s){let c=n.get(Oe(i,s));return c?d(c)?(n.delete(Oe(i,s)),null):c:null},set(i,s,c){let u=Oe(i,s);n.set(u,c);try{localStorage.setItem(a(i,s),JSON.stringify(c))}catch(m){}},invalidate(i){let s=`${encodeURIComponent(i)}:`;for(let c of[...n.keys()])c.startsWith(s)&&n.delete(c);for(let c of l()){let u=o(c);if((u==null?void 0:u.componentId)===i)try{localStorage.removeItem(c)}catch(m){}}},clear(){n.clear();for(let i of l())try{localStorage.removeItem(i)}catch(s){}}}}var Pe="_snt_snap:",Qn=["low","medium","high"];function De(e){try{let t=localStorage.getItem(Pe+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Qn.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function Se(e,t){try{localStorage.setItem(Pe+e,JSON.stringify(t))}catch(n){}}var He="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ot="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",bt=!1,_e=!1;function er(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function tr(e){var t;let n=At({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",a=er(),o=Promise.resolve().then(()=>(vt(),yt)).then(i=>{let s=i;return s.LOCAL_ENGINE_AVAILABLE?(bt||(bt=!0,console.info(Ot)),s):(_e||(_e=!0,console.error(He)),null)}).catch(()=>(_e||(_e=!0,console.error(He)),null)),l=null;function d(i){let s=document.documentElement;s.dataset.sentientPersona===void 0&&(s.dataset.sentientPersona=i.persona,s.dataset.sentientConfidence=fe(i.confidence))}return{isLocal:!0,async decide(i){var s,c,u;let m=await o;if(!m)return null;let v=m.createLocalEngine({sessionId:r,forcedPersona:a}).decide(i);return l=be(R({},v),{layoutOrder:(c=(s=v.layoutOrder)!=null?s:l==null?void 0:l.layoutOrder)!=null?c:null,slots:R(R({},(u=l==null?void 0:l.slots)!=null?u:{}),v.slots)}),Se(e.apiKey||"local",{v:1,persona:l.persona,band:fe(l.confidence),slots:l.slots,layoutOrder:l.layoutOrder,savedAt:Date.now()}),d(v),v},getSlotResult(i){var s,c,u;return(u=(c=l==null?void 0:l.slots[i])!=null?c:(s=e.initialSlots)==null?void 0:s[i])!=null?u:null},getPersona(){return l?{persona:l.persona,confidence:l.confidence,band:fe(l.confidence)}:null},async assign(i,s){var c;let u=await o;return!u||!s||s.length===0?s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null:{variantId:(c=u.createLocalEngine({sessionId:r,forcedPersona:a}).decide({components:[{id:i,variantIds:s}]}).assignments[i])!=null?c:s[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Ae(e,t,n,r){let a=[];{let o=!1,l=[],d=()=>{if(o)return;let i=Date.now();for(l.push(i);l.length>0&&i-l[0]>500;)l.shift();l.length>=3&&(o=!0,e("rage_click"))};t.addEventListener("click",d),a.push(()=>t.removeEventListener("click",d))}{let o=!1,l=d=>{if(o||!(d.target instanceof Node)||!t.contains(d.target)&&t!==d.target)return;o=!0;let i=typeof window!="undefined"?window.getSelection():null,s=i?i.toString().length:0;e("text_copy",{selectionLength:s})};document.addEventListener("copy",l),a.push(()=>document.removeEventListener("copy",l))}{let o=!1,l=!1,d=null,i=()=>{d!==null&&(clearTimeout(d),d=null)},s=()=>{o||!l||(i(),d=setTimeout(()=>{!o&&l&&(o=!0,e("scroll_hesitation"))},3e3))},c=()=>{i(),s()},u=v=>{for(let I of v)l=I.intersectionRatio>.3,l?s():i()},m=new IntersectionObserver(u,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",c,{passive:!0}),a.push(()=>{m.disconnect(),window.removeEventListener("scroll",c),i()})}if((r==null?void 0:r.tabLoss)!==!1){let o=!1,l=n!=null?n:Date.now(),d=()=>{if(o||document.visibilityState!=="hidden")return;let i=Date.now()-l;i<15e3&&(o=!0,e("tab_loss",{timeOnPage:i}))};document.addEventListener("visibilitychange",d),a.push(()=>document.removeEventListener("visibilitychange",d))}return()=>{for(let o of a)o()}}var _t="https://api.sentient-ui.com/v1/events",W=new Map,Rt=null;function nr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Je(){return wt()}function Le(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function rr(e){if(typeof MessageChannel=="function"){let t=new MessageChannel;t.port1.onmessage=()=>{e.clear(),t.port1.close(),t.port2.close()},t.port2.postMessage(0)}else setTimeout(()=>e.clear(),0)}var Tt=new Set;function or(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let a=!1,o,l=()=>{if(a)return;let s=Le();!s||s===o||(o=s,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${s}`))},d=[];for(let s of["pushState","replaceState"]){let c=r[s],u=function(...m){let v=c.apply(this,m);return l(),v};r[s]=u,d.push([s,c,u])}window.addEventListener("popstate",l);let i=Le();return i&&Tt.has(`${t}:${i}`)?o=i:l(),()=>{if(!a){a=!0,window.removeEventListener("popstate",l);for(let[s,c,u]of d)r[s]===u&&(r[s]=c)}}}var we={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function ir(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function Lt(e){return e.replace(/\/events\/?$/,"")}function ge(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function Ye(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Rt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=W.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:a,upgrade:o}=r;if(!o||a.respectDoNotTrack!==!1&&ge())return;let l=Me(be(R({},a),{consent:!0}));o(l);let d=(t=W.get(n))==null?void 0:t.dispose;W.set(n,{config:be(R({},a),{consent:!0}),upgrade:null,dispose:d})}function sr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Lt((t=e.ingestUrl)!=null?t:_t),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(i,s,c){if(!n)return null;try{let u=new URLSearchParams({componentId:i});for(let v of s!=null?s:[])u.append("variantIds[]",v);let m=await fetch(`${r}/winner?${u.toString()}`,{headers:a});return m.ok?{variantId:(await m.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(u){return s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:i=>o.track(i),goal:((i,s,c,u)=>o.goal(i,s,c,u)),componentGoal:(i,s,c)=>o.componentGoal(i,s,c),identify:i=>o.identify(i),getAssignment:(i,s)=>o.getAssignment(i,s),assign:(i,s,c,u)=>o.assign(i,s,c,u),decide:i=>o.decide(i),getSlotResult:i=>o.getSlotResult(i),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function d(i){o=i}return{proxy:l,setInner:d}}function Me(e){var t,n,r,a,o,l,d,i,s;if(typeof window=="undefined")return we;Rt=e.apiKey;let c=W.get(e.apiKey||"local");if(c!=null&&c.dispose)try{c.dispose()}catch(p){}let u=e.respectDoNotTrack!==!1&&ge(),m=e.consent===!1||u,v=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!v&&e.localMode!==!1)return m?(W.set(e.apiKey||"local",{config:e,upgrade:null}),we):(W.set(e.apiKey||"local",{config:e,upgrade:null}),tr(e));if(m){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),W.set(e.apiKey,{config:e,upgrade:null}),we;let{proxy:p,setInner:y}=sr(e);return W.set(e.apiKey,{config:e,upgrade:u?null:y}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),we;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),we;let I=(t=e.ingestUrl)!=null?t:_t,C=Date.now(),k=At({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),h=Zn(void 0,e.apiKey),f=Fn({ingestUrl:I,apiKey:e.apiKey}),x=Lt(I),O={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},G=Yn({url:`${x}/goals`,apiKey:e.apiKey,headers:O,onDrop:(p,y)=>{e.debug&&console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),b=pt((n=navigator.userAgent)!=null?n:""),P=typeof window!="undefined"?window.location.origin:void 0,$=ft((r=document.referrer)!=null?r:"",P),D=(a=e.sessionSegment)!=null?a:`${b}:${$}`,S=new Map,A=new Map,w=null,g=p=>{for(let y of p)A.has(y.id)||A.set(y.id,Fe(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))A.set(p,y);let E=De(e.apiKey);if(E)for(let[p,y]of Object.entries(E.slots))A.has(p)||A.set(p,y);let te={low:.15,medium:.5,high:.85};if(e.initialPersona)w=R({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?w={persona:p.sentientPersona,confidence:(l=te[(o=p.sentientConfidence)!=null?o:"low"])!=null?l:.15}:E&&(w={persona:E.persona,confidence:(d=te[E.band])!=null?d:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))h.set(p,D,{variantId:y,assignedAt:Date.now(),segment:D,confidence:1});let q=Promise.resolve(),ne=k.getSessionId();if(ne){let p=gt((i=document.referrer)!=null?i:""),y=R(R(R({sessionId:ne,deviceClass:b,trafficSource:$,referrerDomain:p,utmParams:ir(),timeOfDay:mt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:k.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||dt((s=navigator.userAgent)!=null?s:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{});try{q=fetch(`${x}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(y),headers:O}).then(_=>{_.status===402&&console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing")}).catch(()=>{})}catch(_){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let ce=new Set,H=null,ue=!1,F={goal(p,y={},_=1,Y=0){var X,N,Z,z,K,re;let B=k.getSessionId();if(!B)return;let U=nr(y)?y:{metadata:y},Q=`${p}\0${(X=U.externalId)!=null?X:""}\0${(N=U.stepIndex)!=null?N:Y}\0${(Z=U.weight)!=null?Z:_}`;if(ce.has(Q)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}ce.add(Q),ce.size===1&&rr(ce);let ye=Je(),T={sessionId:B,name:p,metadata:(z=U.metadata)!=null?z:{},weight:(K=U.weight)!=null?K:_,stepIndex:(re=U.stepIndex)!=null?re:Y,goalId:ye,value:U.value,currency:U.currency,externalId:U.externalId};e.debug&&console.log("[sentient] goal",T);let de={id:ye,body:JSON.stringify(T)};q.then(()=>G.send(de))},componentGoal(p,y,_){var Y,X,N;let Z=k.getSessionId();if(!Z)return;let z=h.get(p,D),K=z?null:(Y=A.get(p))!=null?Y:null;if(!z&&K===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let re=z?z.variantId:ht(K),B={id:Je(),sessionId:Z,projectId:e.apiKey,componentId:p,variantId:re,eventType:"goal_achieved",goalType:y,payload:R({reward:(X=_==null?void 0:_.reward)!=null?X:1,goalValue:_==null?void 0:_.value,currency:_==null?void 0:_.currency},(N=_==null?void 0:_.metadata)!=null?N:{}),timestamp:Date.now(),timeInSession:Date.now()-C,path:Le()};e.debug&&console.log("[sentient] componentGoal",B),q.then(()=>f.push(B))},identify(p){let y=k.getSessionId();y&&q.then(()=>{fetch(`${x}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:k.isEphemeral()}),headers:O}).catch(()=>{})})},track(p){let y=k.getSessionId();if(!y)return;let _=be(R({path:Le()},p),{id:Je(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",_),q.then(()=>f.push(_))},getAssignment(p,y){return h.get(p,y)},async assign(p,y,_,Y){let X=k.getSessionId();if(!X)return null;let N=h.get(p,D);if(N&&(y!=null&&y.length||N.content!==void 0)){let K=N.ttlMs&&N.ttlMs>0?Math.max(0,N.assignedAt+N.ttlMs-Date.now()):0;return{variantId:N.variantId,assignmentTtlMs:K,content:N.content}}let Z=S.get(p);if(Z)return Z;let z=(async()=>{await q;try{let K={sessionId:X,componentId:p,variantIds:y};Y!==void 0?K.agentDataByVariant=Y:_!==void 0&&(K.agentData=_);let re=await fetch(`${x}/assign`,{method:"POST",body:JSON.stringify(K),headers:O});if(!re.ok)return null;let B=await re.json();return h.set(p,D,R({variantId:B.variantId,assignedAt:Date.now(),segment:D,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B}catch(K){return null}finally{S.delete(p)}})();return S.set(p,z),z},async decide(p){var y,_,Y,X,N,Z,z,K,re;let B=k.getSessionId();if(!B)return null;let U=(y=p.slots)!=null?y:[];await q;try{let Q={sessionId:B};p.sections&&p.sections.length>0&&(Q.sections=p.sections.map(J=>({id:J}))),Q.components=(_=p.components)!=null?_:[],U.length>0&&(Q.slots=U.map(Ve)),p.slotsFrom==="registry"&&(Q.slotsFrom="registry"),p.v&&(Q.v=p.v),e.persona&&(Q.persona=e.persona);let ye=await fetch(`${x}/decide`,{method:"POST",body:JSON.stringify(Q),headers:O});if(!ye.ok)return g(U),null;let T=await ye.json(),de={};for(let J of U)de[J.id]=(X=(Y=T.slots)==null?void 0:Y[J.id])!=null?X:Fe(J);if(T.slots)for(let[J,ve]of Object.entries(T.slots))J in de||(de[J]=ve);for(let[J,ve]of Object.entries(de))A.set(J,ve);let pn=w!=null&&w.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&pn)?w={persona:T.persona,confidence:(N=T.confidence)!=null?N:0}:w||(w={persona:"unknown",confidence:0});for(let[J,ve]of Object.entries((Z=T.assignments)!=null?Z:{}))h.set(J,D,{variantId:ve,assignedAt:Date.now(),segment:D,confidence:1});return Se(e.apiKey,R({v:1,persona:w.persona,band:fe(w.confidence),slots:Object.fromEntries(A),layoutOrder:(z=T.layoutOrder)!=null?z:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{})),R(R(R({layoutOrder:(K=T.layoutOrder)!=null?K:null,assignments:(re=T.assignments)!=null?re:{},slots:de,persona:w.persona,confidence:w.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{})}catch(Q){return g(U),null}},getSlotResult(p){var y;return(y=A.get(p))!=null?y:null},getPersona(){return w?{persona:w.persona,confidence:w.confidence,band:fe(w.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${x}/weights`,{headers:O});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;H==null||H(),ue=!0,f.destroy(),G.destroy(),((p=W.get(e.apiKey))==null?void 0:p.dispose)===F.dispose&&W.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;H==null||H(),ue=!0,f.destroy(),G.destroy(),k.destroy(),((p=W.get(e.apiKey))==null?void 0:p.dispose)===F.dispose&&W.delete(e.apiKey);try{localStorage.removeItem(Pe+e.apiKey),localStorage.removeItem(It(e.apiKey)),localStorage.removeItem(Ct(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(W.set(e.apiKey,{config:e,upgrade:null,dispose:F.dispose}),H=or(F,e.apiKey,p=>{q.then(()=>{ue||Tt.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=F)}return F}var Pt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],ar=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],lr=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function cr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Dt(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of ar)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of lr)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function Mt(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:cr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function $t(e){return Dt(Mt(e)).type}Ie();var jt="section, header, footer, nav, main > div, [data-sentient-section]";function ur(e){var t;return((t=e.parentElement)==null?void 0:t.closest(jt))!=null}function dr(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(a){}}var Nt=()=>{};function Kt(e,t){var n,r,a,o,l,d,i,s,c;let u=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!u||typeof IntersectionObserver=="undefined"||ge()||!t.apiKey)return Nt;let m=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),v=Array.from(u.querySelectorAll(jt)).filter(S=>!ur(S));if(v.length===0)return Nt;let I=new Map,C=new Map,k=new Map;for(let S of v){let A=S.getAttribute("data-sentient-type"),w=A&&Pt.includes(A)?A:null,g=(o=w!=null?w:(a=t.typeOf)==null?void 0:a.call(t,S))!=null?o:$t(S),E=`nc-${g}`;I.set(S,E),C.set(E,g),w?k.set(E,"markup"):k.has(E)||k.set(E,"auto")}let h=(s=(i=(d=(l=u.defaultView)!=null?l:typeof window!="undefined"?window:void 0)==null?void 0:d.location)==null?void 0:i.pathname)!=null?s:"/";dr(t.apiKey,m,h,[...C.entries()].map(([S,A])=>{var w;return{componentId:S,semanticType:A,source:(w=k.get(S))!=null?w:"auto"}}));let f=new Map,x=S=>{let A=f.get(S);return A||(A={ms:0,scroll:0,enterAt:null,intersecting:!1},f.set(S,A)),A},O=new IntersectionObserver(S=>{for(let A of S){let w=I.get(A.target);if(!w)continue;let g=x(w);A.isIntersecting?(g.intersecting=!0,g.enterAt=Date.now(),A.intersectionRatio>g.scroll&&(g.scroll=A.intersectionRatio)):(g.intersecting=!1,g.enterAt!=null&&(g.ms+=Date.now()-g.enterAt,g.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let S of I.keys())O.observe(S);let G=()=>{let S=Date.now();for(let[A,w]of f)if(w.enterAt!=null&&(w.ms+=S-w.enterAt,w.enterAt=null),!(w.ms<=0)){try{e.track({projectId:t.apiKey,componentId:A,eventType:"dwell",payload:{dwell_time:Math.round(w.ms),scroll_depth:Number(w.scroll.toFixed(2))}})}catch(g){}w.ms=0}},b=()=>{if(u.hidden)G();else{let S=Date.now();for(let A of f.values())A.intersecting&&(A.enterAt=S)}},P=()=>{G();try{O.disconnect()}catch(S){}};u.addEventListener("visibilitychange",b);let $=(c=u.defaultView)!=null?c:typeof window!="undefined"?window:void 0;$==null||$.addEventListener("pagehide",P);let D=[];return t.microSignals&&[...I.entries()].forEach(([S,A],w)=>{D.push(Ae((g,E={})=>{try{e.track({projectId:t.apiKey,componentId:A,eventType:"micro_signal",payload:R({signalType:g},E)})}catch(te){}},S,void 0,{tabLoss:w===0}))}),()=>{G(),u.removeEventListener("visibilitychange",b),$==null||$.removeEventListener("pagehide",P);for(let S of D)S();try{O.disconnect()}catch(S){}}}var pr=["landing","ecommerce","saas","marketplace"];function fr(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,a]of t){if(!Array.isArray(a)||a.length<2||a.length>6||!a.every(o=>typeof o=="string"))return null;n[r]=a}return n}function gr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function mr(e){try{return e()}catch(t){return}}function $e(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=pr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[l,d]of Object.entries(t.slots)){if(typeof d!="object"||d===null)continue;let i=d,s=fr(i.dims);if(!s||i.target!==void 0&&typeof i.target!="string")continue;let c=i.arms!==void 0?gr(i.arms):null,u={dims:s};typeof i.target=="string"&&(u.target=i.target),c&&(u.arms=c),r[l]=u}let a={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(a.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(a.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(a.debug=!0),typeof t.registry=="boolean"&&(a.registry=t.registry),typeof t.editorSrc=="string"&&(a.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(a.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(a.sectionCapture=t.sectionCapture);let o=typeof t.persona=="function"?mr(t.persona):t.persona;return typeof o=="string"&&o.trim()!==""&&(a.persona=o),a}function Bt(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function hr(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").trim().toLowerCase(),a=t.text.trim().toLowerCase();if(!(r===a||r.startsWith(a)||a.startsWith(r)))return!1}return!0}function Ut(e,t){return!!(e!=null&&e.urlMatch)&&!Bt(t).includes(e.urlMatch)}var yr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function se(e,t){var a;if(e.urlMatch&&!Bt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((a=e.dataAttr)!=null&&a.name)&&yr.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!hr(r,e.fingerprint)?null:r}var Gt={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},vr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function qt(e){var t;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!vr.test((t=n[1])!=null?t:""))return!1;return!0}var zt=/^https:\/\//i,Wt=new Map,ae=null;function br(e){return e.replace(/["\\]/g,"\\$&")}function wr(e){var t;(!ae||!ae.isConnected)&&(ae=e.querySelector("style[data-sentient-ops]"),ae||(ae=e.createElement("style"),ae.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(ae))),ae.textContent=[...Wt.entries()].map(([n,r])=>`[data-snt-e="${br(n)}"]{${r}}`).join(`
2
- `)}function Vt(e,t,n,r){var d;let a=!1,o=(d=t.moveBefore)!=null?d:t.moveAfter;if(o){let i=se(o,r);!i||i===e||i.parentElement!==e.parentElement||!e.parentElement?a=!0:t.moveBefore?e.parentElement.insertBefore(e,i):e.parentElement.insertBefore(e,i.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&zt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&zt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let l=[];if(t.hidden&&l.push("display:none !important"),t.style)for(let[i,s]of Object.entries(t.style)){let c=Gt[i];c&&typeof s=="string"&&qt(s)&&l.push(`${c}:${s.trim()} !important`)}return l.length>0&&(e.setAttribute("data-snt-e",n),Wt.set(n,l.join(";")),wr(r)),{anchorMiss:a}}function Ne(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function je(e,t,n){var r;for(let[a,o]of Object.entries(t)){let l=e[a];if(!l||typeof l=="string")continue;let d=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let i of d)for(let[s,c]of Object.entries(l))(r=o.dims[s])!=null&&r.includes(c)&&i.setAttribute(`data-${s}`,c)}}function Ke(e,t,n){for(let[r,a]of Object.entries(t)){let o=e[r];if(typeof o!="string"||!a.arms||!a.arms.includes(o))continue;let l=a.target?Array.from(n.querySelectorAll(a.target)):[n.documentElement];for(let d of l)d.setAttribute("data-sentient-arm",o)}}function Be(e,t,n,r){var l,d;let a=(l=r==null?void 0:r.contentAndOps)!=null?l:!0,o=[];for(let[i,s]of Object.entries(t)){if(Ut(s.locator,n))continue;let c;if(s.locator){let m=se(s.locator,n);c=m?[m]:[]}else s.target?c=Array.from(n.querySelectorAll(s.target)):c=[n.documentElement];(s.locator||s.target)&&c.length===0&&o.push(i);let u=e[i];for(let m of c){if(u!==void 0)if(typeof u=="string")m.setAttribute("data-sentient-arm",u),a&&((d=r==null?void 0:r.onApplied)==null||d.call(r,i,u,m));else for(let[v,I]of Object.entries(u))m.setAttribute(`data-${v}`,I);a&&(typeof s.content=="string"&&(m.textContent=s.content),s.ops&&Vt(m,s.ops,i,n).anchorMiss&&!o.includes(i)&&o.push(i))}}return o}var Sr=800;function Ue(e,t,n){let r=[];return n.forEach(({slotId:a,arm:o,el:l},d)=>{r.push(Ae((m,v={})=>{try{e.track({projectId:t,componentId:a,variantId:o,eventType:"micro_signal",payload:pe({signalType:m},v)})}catch(I){}},l,void 0,{tabLoss:d===0}));let i=null,s=0,c=()=>{s=Date.now(),i=setTimeout(()=>{try{e.track({projectId:t,componentId:a,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-s}})}catch(m){}i=null},Sr)},u=()=>{i!==null&&(clearTimeout(i),i=null)};l.addEventListener("mouseenter",c),l.addEventListener("mouseleave",u),r.push(()=>{l.removeEventListener("mouseenter",c),l.removeEventListener("mouseleave",u),i!==null&&clearTimeout(i)})}),()=>{for(let a of r)a()}}function Ar(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function xr(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}var Ft="_snt_fired_goals";function Er(e){try{let t=e==null?void 0:e.sessionStorage.getItem(Ft);if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(r=>typeof r=="string")):new Set}catch(t){return new Set}}function kr(e,t){try{e==null||e.sessionStorage.setItem(Ft,JSON.stringify([...t]))}catch(n){}}function Jt(e,t,n){var C,k;let r=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,a=Er(r),o=h=>{if(!a.has(h.goalId)){a.add(h.goalId),kr(r,a);try{h.slotId?t.componentGoal(h.slotId,h.goalId):t.goal(h.goalId)}catch(f){}}},l=e.filter(h=>h.event==="click"),d=e.filter(h=>h.event==="form_submit"),i=e.filter(h=>h.event==="url_reached"),s=e.filter(h=>h.event==="scroll_depth"),c=(h,f)=>{if(!h.locator)return!1;let x=se(h.locator,n);return!!x&&(x===f||x.contains(f))},u=h=>{let f=h.target;if(!(!f||typeof f.closest!="function"))for(let x of l)c(x,f)&&o(x)},m=h=>{let f=h.target;if(f)for(let x of d)c(x,f)&&o(x)},v=()=>{if(i.length===0)return;let h=Ar(n);for(let f of i)f.urlPattern&&xr(f.urlPattern,h)&&o(f)},I=()=>{var x;let h=n.documentElement,f=h.scrollHeight>0?(h.scrollTop+h.clientHeight)/h.scrollHeight:0;for(let O of s)f>=((x=O.threshold)!=null?x:.75)&&o(O);s.every(O=>a.has(O.goalId))&&n.removeEventListener("scroll",I)};return n.addEventListener("click",u,!0),n.addEventListener("submit",m,!0),(k=n.defaultView)==null||k.addEventListener("popstate",v),v(),s.length>0&&(n.addEventListener("scroll",I,{passive:!0}),I()),{checkUrl:v,teardown:()=>{var h;n.removeEventListener("click",u,!0),n.removeEventListener("submit",m,!0),(h=n.defaultView)==null||h.removeEventListener("popstate",v),s.length>0&&n.removeEventListener("scroll",I)}}}var Ht="__snt_editor_token";function Yt(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Ht):null}catch(e){return null}}function Xt(e){try{sessionStorage.setItem(Ht,e)}catch(t){}}var Ze="0.16.0",on=5e3,Ir=50,Cr=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),V=null,M=null,ie={},le=null,ee=null,j=null,oe=null,L=null,Zt=!1,Xe=null,Ge=null,qe=null,xe=!1,ze=!1;function sn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function me(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function he(e,t){return V?(V.personaAttributes&&L&&Ne(L.persona,L.band,e),je(ie,V.slots,e),Ke(ie,V.slots,e),le?Be(ie,le,e,t):[]):[]}function Or(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ee(){return!!(V&&M&&V.sectionCapture!==!1&&(V.consent!==!1||ze)&&!ge())}function _r(){if(!M||!V||!Ee()||oe)return;let e=[];he(document,{contentAndOps:xe,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),et();try{j==null||j(),j=Ue(M,V.apiKey,e)}catch(t){}}function et(){if(typeof document=="undefined"||!Ee())return;let e;try{if(Ge&&Ge.length>0){let t=new Map;for(let n of Ge){if(n.urlMatch!==window.location.pathname)continue;let r=se(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{oe=Kt(M,pe({apiKey:V.apiKey,apiBase:V.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),qe=window.location.pathname}catch(t){}}function tt(){try{let e=[];if(j==null||j(),j=null,he(document,{contentAndOps:xe,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&Ee())try{j=Ue(M,V.apiKey,e)}catch(t){}try{typeof window!="undefined"&&qe!==null&&window.location.pathname!==qe&&Ee()&&(oe==null||oe(),oe=null,et())}catch(t){}}catch(e){}}function Qt(){Xe===null&&(Xe=setTimeout(()=>{Xe=null,tt();try{ee==null||ee.checkUrl()}catch(e){}},Ir))}function en(){if(!(Zt||typeof window=="undefined"||typeof history=="undefined")){Zt=!0;try{let e=t=>{let n=history[t];history[t]=function(r,a,o){let l=n.call(this,r,a,o!=null?o:null);return Qt(),l}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Qt)}catch(e){}}}function Qe(e){let t={};for(let[n,r]of Object.entries(e.slots))t[n]=r.target?document.querySelectorAll(r.target).length:1;return t}function an(e){return new URLSearchParams(e).get("sentient_editor")}function Rr(){try{let t=Array.from(document.getElementsByTagName("script")).find(n=>/snippet(\.global)?\.js/.test(n.src));if(t!=null&&t.src)return t.src.replace(/snippet(\.global)?\.js/,"editor.global.js")}catch(e){}return null}function Tr(e,t){var n,r,a,o;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let i=document.createElement("meta");i.name="referrer",i.content="no-referrer",i.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(i)}catch(i){}let l=(a=e.editorSrc)!=null?a:Rr();if(!l){nn();return}let d=document.createElement("script");d.src=l,d.async=!0,d.onerror=()=>nn(),((o=document.head)!=null?o:document.documentElement).appendChild(d)}catch(l){}}var tn="sentient-editor-load-notice";function nn(){var e;try{if(typeof document=="undefined"||document.getElementById(tn))return;let t=document.createElement("div");t.id=tn,t.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(t.style,{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",cursor:"pointer"}),t.addEventListener("click",()=>t.remove()),((e=document.body)!=null?e:document.documentElement).appendChild(t),setTimeout(()=>t.remove(),1e4)}catch(t){}}function ln(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let a=r.indexOf(":"),o=a===-1?"":r.slice(0,a),l=a===-1?"":r.slice(a+1);if(!(!o||!l))if(l.includes("=")){let d={};for(let i of l.split(",")){let[s,c]=i.split("=");s&&c&&(d[s]=c)}Object.keys(d).length&&(n[o]=d)}else n[o]=l}return Object.keys(n).length?n:null}function cn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var rn="sentient-persona-preview-banner";function Lr(e){var t;try{if(typeof document=="undefined"||document.getElementById(rn))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=rn,r.setAttribute("role","status"),Object.assign(r.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",background:"#111827",color:"#fff",font:"13px/1 system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.14)"});let a=document.createElement("span");a.textContent=`Previewing as ${n}`;let o=document.createElement("button");o.type="button",o.textContent="Exit preview",Object.assign(o.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),o.addEventListener("click",()=>{try{let l=new URL(window.location.href);l.searchParams.delete("sentient_persona"),window.location.href=l.pathname+l.search+l.hash}catch(l){}}),r.appendChild(a),r.appendChild(o),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function Pr(e,t){var s,c,u,m,v,I,C,k,h;let n=(s=e.apiBase)!=null?s:"https://api.sentient-ui.com",a=((c=e.registry)!=null?c:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,x])=>({id:f,dims:x.dims}))},o=await sn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(a)}).then(f=>f.ok?f.json():null).catch(()=>null),on);if(!o){me(e,"persona preview: explain unavailable \u2014 page left as-is");return}let l=o;ie=(u=l.slots)!=null?u:{},le=(m=l.slotConfig)!=null?m:null;let d=(C=(I=(v=l.personaAttributes)==null?void 0:v.persona)!=null?I:l.persona)!=null?C:t,i=(h=(k=l.personaAttributes)==null?void 0:k.confidence)!=null?h:"high";L={persona:d,band:i},he(document),xe=!0,un(e),Lr(d)}function un(e){let t={goal(n,r){try{M==null||M.goal(n,r)}catch(a){}},componentGoal(n,r){try{M==null||M.componentGoal(n,r)}catch(a){}},grantConsent(){try{Ye(e.apiKey)}catch(n){}ze=!0;try{_r()}catch(n){}},revokeConsent(){try{oe==null||oe(),oe=null,qe=null,j==null||j(),j=null,ee==null||ee.teardown(),ee=null,ze=!1,M==null||M.destroy()}catch(n){}},reapply:tt,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=L==null?void 0:L.persona)!=null?n:null,band:(r=L==null?void 0:L.band)!=null?r:null,slots:ie,matchCounts:Qe(e),consent:e.consent!==!1}}};window.SentientSnippet=t;for(let n of Cr.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}async function dn(){var e,t,n,r,a;try{let o=$e(window.sentient);if(!o)return;V=o,xe=!1,ze=!1;let l=typeof window!="undefined"?an(window.location.search):null;if(l){Xt(l);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let d=l!=null?l:Yt();if(d){Tr(o,d),me(o,"editor mode");return}let i=typeof window!="undefined"?ln(window.location.search):null;if(i){ie=i,L=null,he(document),en(),me(o,"preview mode",i);return}let s=typeof window!="undefined"?cn(window.location.search):null;if(s){await Pr(o,s),me(o,"persona preview",s);return}let c=(e=o.registry)!=null?e:Object.keys(o.slots).length===0,u=De(o.apiKey);u&&(L={persona:u.persona,band:u.band},ie=u.slots,u.slotConfig&&(le=u.slotConfig),he(document,{contentAndOps:!1}));let m=Me({apiKey:o.apiKey,context:o.context,consent:o.consent,preConsentBehavior:o.preConsentBehavior,debug:o.debug,persona:o.persona});M=m,un(o),en();let v=Object.entries(o.slots).map(([f,x])=>({id:f,dims:x.dims})),I=Ze!=="0.0.0-dev"?{v:Ze}:{},C=await sn(m.decide(pe(pe({slots:v},I),c?{slotsFrom:"registry"}:{})),on);if(!C){me(o,"decide timeout/null \u2014 snapshot state stands",Qe(o));return}let k=m.getPersona();k?L={persona:k.persona,band:k.band}:C.persona&&(L={persona:C.persona,band:"low"}),ie=C.slots,c?le=(t=C.slotConfig)!=null?t:null:C.slotConfig&&(le=C.slotConfig);let h=[];if(Or(o,he(document,{onApplied:(f,x,O)=>h.push({slotId:f,arm:x,el:O})})),xe=!0,C.goals&&C.goals.length>0&&o.consent!==!1&&M)try{ee==null||ee.teardown(),ee=Jt(C.goals,M,document)}catch(f){}if(Ge=(n=C.sectionMap)!=null?n:null,Ee()){et();try{j==null||j(),j=Ue(M,o.apiKey,h)}catch(f){}}me(o,"applied",{persona:L,slots:ie,matches:Qe(o)}),Se(o.apiKey,pe({v:1,persona:(r=L==null?void 0:L.persona)!=null?r:C.persona,band:(a=L==null?void 0:L.band)!=null?a:"low",slots:C.slots,layoutOrder:C.layoutOrder,savedAt:Date.now()},le?{slotConfig:le}:{}))}catch(o){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,dn())}return yn(Dr);})();
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);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "private": false,
5
5
  "description": "SentientUI Style-rung snippet for non-React sites — persona attributes and adaptive style tokens from one script tag",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "tsx": "^4.19.2",
25
25
  "typescript": "^5.7.2",
26
26
  "vitest": "^2.1.8",
27
- "@sentientui/core": "0.20.0"
27
+ "@sentientui/core": "0.21.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",