@sentientui/snippet 0.18.0 → 0.20.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.
@@ -1,5 +1,5 @@
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,D=(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:()=>It,deriveSlotId:()=>ht,drawTargetHighlights:()=>de,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 c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((s=e.dataAttr)!=null&&s.name)&&Re.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&&!_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],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 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 c=o.tagName.toLowerCase(),f=o.parentElement;if(f){let E=Array.from(f.children).filter(y=>y.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 mt(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 f=e.getAttribute(c);if(f){n.dataAttr={name:c,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=D({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,c=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),f=new Map;for(let M of Array.from(c).slice(0,300)){let _=M.getBoundingClientRect();if(_.width>0&&(_.width<48||_.height<24))continue;let P=o.getComputedStyle(M),T=P.backgroundColor;if(!T||T==="transparent"||T===s||Pe.test(T))continue;let H=(t=(P.borderRadius||"").split(" ")[0])!=null?t:"",O=`${T}|${P.color}|${He.test(H)?H:"8px"}`;f.set(O,((n=f.get(O))!=null?n:0)+1)}let E=null,y=0;for(let[M,_]of f)_>y&&(E=M,y=_);if(!E)return null;let[N,B,G]=E.split("|");return{primaryBg:N,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 o;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Oe.test((o=n[1])!=null?o:""))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 E;let s=!1,c=(E=t.moveBefore)!=null?E:t.moveAfter;if(c){let y=et(c,o);!y||y===e||y.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,y):e.parentElement.insertBefore(e,y.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[y,N]of Object.entries(t.style)){let B=te[y];B&&typeof N=="string"&&Bt(N)&&f.push(`${B}:${N.trim()} !important`)}return f.length>0&&(e.setAttribute("data-snt-e",n),ne.set(n,f.join(";")),Ne(o)),{anchorMiss:s}}function $t(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function At(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 Rt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function ht(e,t,n){var E,y;let o=t.id||((E=t.dataAttr)==null?void 0:E.value)||((y=n.textContent)!=null?y:"").trim()||n.tagName,s=Rt(o)||"el",c=le(JSON.stringify(t));return`${e}-${s}-${c}`.slice(0,128)}var De="sentient-editor-highlight",je="sentient-editor-selection",st="sentient-editor-panel",Mt="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.",qe="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function ce(){var t;if(document.getElementById(se))return;let e=document.createElement("style");e.id=se,e.textContent=`
1
+ "use strict";var SentientSnippet=(()=>{var Ge=Object.defineProperty,fn=Object.defineProperties,gn=Object.getOwnPropertyDescriptor,mn=Object.getOwnPropertyDescriptors,hn=Object.getOwnPropertyNames,Pt=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable;var Ot=(t,e,o)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,_=(t,e)=>{for(var o in e||(e={}))zt.call(e,o)&&Ot(t,o,e[o]);if(Pt)for(var o of Pt(e))yn.call(e,o)&&Ot(t,o,e[o]);return t},j=(t,e)=>fn(t,mn(e));var bn=(t,e)=>{for(var o in e)Ge(t,o,{get:e[o],enumerable:!0})},xn=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of hn(e))!zt.call(t,u)&&u!==o&&Ge(t,u,{get:()=>e[u],enumerable:!(i=gn(e,u))||i.enumerable});return t};var vn=t=>xn(Ge({},"__esModule",{value:!0}),t);var Vn={};bn(Vn,{buildStyleOps:()=>ft,clearTargetHighlights:()=>Ee,computeMoveAnchors:()=>Ke,deriveSlotId:()=>He,drawTargetHighlights:()=>Kt,mount:()=>en,styleFieldError:()=>Qt});function kn(t){var o,i,u;let e=(i=(o=t.defaultView)!=null?o:typeof window!="undefined"?window:void 0)==null?void 0:i.location;return(u=e==null?void 0:e.pathname)!=null?u:""}function wn(t,e){var o;if(e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())return!1;if(e.text){let i=((o=t.textContent)!=null?o:"").replace(/\s+/g," ").trim().toLowerCase(),u=e.text.replace(/\s+/g," ").trim().toLowerCase();if(!(i===u||i.startsWith(u)||u.startsWith(i)))return!1}return!0}var En=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ye(t,e){var u;if(t.urlMatch&&!kn(e).includes(t.urlMatch))return null;let o=[];if(t.id){let p=e.getElementById(t.id);o=p?[p]:[]}if(o.length===0&&((u=t.dataAttr)!=null&&u.name)&&En.test(t.dataAttr.name))try{let p=t.dataAttr.value.replace(/["\\]/g,"\\$&");o=Array.from(e.querySelectorAll(`[${t.dataAttr.name}="${p}"]`))}catch(p){o=[]}if(o.length===0&&t.selector)try{o=Array.from(e.querySelectorAll(t.selector))}catch(p){o=[]}if(o.length!==1)return null;let i=o[0];return t.fingerprint&&!wn(i,t.fingerprint)?null:i}function Nt(t){let e=globalThis;if(e.CSS&&typeof e.CSS.escape=="function")return e.CSS.escape(t);let o="";for(let i=0;i<t.length;i++){let u=t[i],p=u>="0"&&u<="9";i===0&&p||i===1&&p&&t[0]==="-"?o+=`\\3${u} `:i===0&&u==="-"&&t.length===1?o+="\\-":/[a-zA-Z0-9_-]/.test(u)?o+=u:o+=`\\${u}`}return o}function Sn(t,e){if(t.id)return`#${Nt(t.id)}`;let o=[],i=t,u=0;for(;i&&i!==e.body&&i!==e.documentElement&&u<6;){if(i.id){o.unshift(`#${Nt(i.id)}`);break}let p=i.tagName.toLowerCase(),k=i.parentElement;if(k){let C=Array.from(k.children).filter(L=>L.tagName===i.tagName);C.length>1&&(p+=`:nth-of-type(${C.indexOf(i)+1})`)}o.unshift(p),i=i.parentElement,u++}return o.join(" > ")}function ke(t,e){var u;let o={v:1};t.id&&(o.id=t.id);for(let p of["data-framer-name","data-w-id","data-sentient-name"]){let k=t.getAttribute(p);if(k){o.dataAttr={name:p,value:k};break}}o.selector=Sn(t,e);let i=((u=t.textContent)!=null?u:"").trim().replace(/\s+/g," ").slice(0,80);return o.fingerprint=_({tag:t.tagName.toLowerCase()},i?{text:i}:{}),o}function Me(t,e,o){return ye(t,o)===e}var Tn="__snt_editor_token";function We(){try{sessionStorage.removeItem(Tn)}catch(t){}}var Ln=/rgba\([^)]*,\s*0\s*\)$/,Cn=/^\d+(\.\d+)?px$/;function jt(t){var e,o;try{let i=t.defaultView;if(!i||!t.body)return null;let u=i.getComputedStyle(t.body).backgroundColor,p=t.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),k=new Map;for(let D of Array.from(p).slice(0,300)){let F=D.getBoundingClientRect();if(F.width>0&&(F.width<48||F.height<24))continue;let R=i.getComputedStyle(D),z=R.backgroundColor;if(!z||z==="transparent"||z===u||Ln.test(z))continue;let W=(e=(R.borderRadius||"").split(" ")[0])!=null?e:"",Y=`${z}|${R.color}|${Cn.test(W)?W:"8px"}`;k.set(Y,((o=k.get(Y))!=null?o:0)+1)}let C=null,L=0;for(let[D,F]of k)F>L&&(C=D,L=F);if(!C)return null;let[H,A,ae]=C.split("|");return{primaryBg:H,primaryText:A,radius:ae}}catch(i){return null}}var Ye={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"},Bn=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Ie(t){var i;if(t.trim().length===0||/[;{}<>]/.test(t))return!1;let e=/([A-Za-z-]*)\(/g,o;for(;(o=e.exec(t))!==null;)if(!Bn.test((i=o[1])!=null?i:""))return!1;return!0}var Ft=/^https:\/\//i,qt=new Map,se=null;function _n(t){return t.replace(/["\\]/g,"\\$&")}function $n(t){var e;(!se||!se.isConnected)&&(se=t.querySelector("style[data-sentient-ops]"),se||(se=t.createElement("style"),se.setAttribute("data-sentient-ops",""),((e=t.head)!=null?e:t.documentElement).appendChild(se))),se.textContent=[...qt.entries()].map(([o,i])=>`[data-snt-e="${_n(o)}"]{${i}}`).join(`
2
+ `)}function Dt(t,e,o,i){var C;let u=!1,p=(C=e.moveBefore)!=null?C:e.moveAfter;if(p){let L=ye(p,i);!L||L===t||L.parentElement!==t.parentElement||!t.parentElement?u=!0:e.moveBefore?t.parentElement.insertBefore(t,L):t.parentElement.insertBefore(t,L.nextSibling)}typeof e.text=="string"&&(t.textContent=e.text),typeof e.href=="string"&&Ft.test(e.href)&&t.setAttribute("href",e.href),typeof e.imageSrc=="string"&&Ft.test(e.imageSrc)&&t.setAttribute("src",e.imageSrc),typeof e.imageAlt=="string"&&t.setAttribute("alt",e.imageAlt);let k=[];if(e.hidden&&k.push("display:none !important"),e.style)for(let[L,H]of Object.entries(e.style)){let A=Ye[L];A&&typeof H=="string"&&Ie(H)&&k.push(`${A}:${H.trim()} !important`)}return k.length>0&&(t.setAttribute("data-snt-e",o),qt.set(o,k.join(";")),$n(i)),{anchorMiss:u}}function Ve(t){let e=t.steps.length,o=t.status==="active"?"":` (${t.status})`;return`${t.display_name} \u2014 ${e} step${e===1?"":"s"}${o}`}function Je(t,e){return t.steps.map(o=>{var i;return{value:o.step_index,label:`${o.step_index+1}. ${(i=e.get(o.goal_id))!=null?i:o.goal_id}`}})}function Ut(t,e){return t.includes(e)?t.filter(o=>o!==e):[...t,e]}function An(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function Gt(t,e){let o=t.trim();return o?e.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:e.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:An(o),body:{displayName:o.slice(0,128),steps:e.map(i=>({goalId:i}))}}:{ok:!1,error:"Give the funnel a name."}}function Jt(t){let e=5381;for(let o=0;o<t.length;o++)e=(e<<5)+e+t.charCodeAt(o)>>>0;return e.toString(36)}function Ze(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function He(t,e,o){var C,L;let i=e.id||((C=e.dataAttr)==null?void 0:C.value)||((L=o.textContent)!=null?L:"").trim()||o.tagName,u=Ze(i)||"el",p=Jt(JSON.stringify(e));return`${t}-${u}-${p}`.slice(0,128)}var Rn="sentient-editor-highlight",Mn="sentient-editor-selection",we="sentient-editor-panel",Qe="sentient-editor-toast",Wt="sentient-editor-styles",ct="sentient-editor-target-highlight",In=10,Hn="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Pn="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Xt(){var e;if(document.getElementById(Wt))return;let t=document.createElement("style");t.id=Wt,t.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
- #${st} {
15
+ #${we} {
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
- #${st} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
- #${Mt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
19
+ #${we} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
+ #${Qe} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
21
21
  @media (prefers-reduced-motion: reduce) {
22
- #${st}, #${st} .sntedi-dot, #${Mt} { animation: none !important; }
22
+ #${we}, #${we} .sntedi-dot, #${Qe} { animation: none !important; }
23
23
  }
24
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function ae(e){var o,s;ce(),(o=document.getElementById(Mt))==null||o.remove();let t=l("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=Mt;let n=l("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,l("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function We(){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 z(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 de(e,t=document){var o;yt(t);let n=0;for(let s of e){if(n>=Ge)break;let c=et(s.locator,t);if(!c)continue;let f=c.getBoundingClientRect(),E=l("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)"});E.className=zt;let y=l("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);y.className=zt,((o=t.body)!=null?o:t.documentElement).append(E,y),n+=1}}function It(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,s=n?mt(n,t):null,c=o?mt(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&s&&Ct(s,n,t)?s:null,nextLocator:o&&c&&Ct(c,o,t)?c: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 c=s.trim();if(c==="")continue;if(!Bt(c)){n[o]="That value isn\u2019t allowed.";continue}let f=pe(o,c);if(f){n[o]=f;continue}t[o]=c}return{style:t,errors:n}}function l(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=l("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=l("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`})},c=()=>s();ce();let f=l("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 E=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});E.className="sntedi-dot";let y=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});y.append(E,l("span",{},"SentientUI editor"));let N=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),B=!1,G=l("button",b("#374151"),"Pause selecting");G.onclick=()=>{B=!B,G.textContent=B?"Resume selecting":"Pause selecting",B?(n.style.display="none",yt(document),d("Selection paused \u2014 browse normally, then resume.")):d("Click any element on the page to adapt it.")};let M=l("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"}),_=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),P=r=>l("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},r),T=l("button",b("#6366f1"),"Test different text here"),H=l("button",b("#374151"),"Change style"),O=l("button",b("#374151"),"Try a different arrangement"),U=l("button",b("#374151"),"Track clicks as a goal"),q=l("button",b("#374151"),"Track form submissions as a goal"),at=l("button",b("#374151"),"Track page visits as a goal"),S=l("button",b("#374151"),"Track reading this far as a goal"),W=l("button",b("#374151"),"Set up a funnel"),F=l("button",b("#374151"),"Attach this test to a funnel step"),X=l("button",b("#10b981"),"Turn the funnel on"),Z=l("button",b("#374151"),"Move up"),K=l("button",b("#374151"),"Move down"),bt=l("button",b("#6366f1"),"Save this arrangement"),xt=l("button",b("#374151"),"Undo"),Ft=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Close editor"),Q=l("button",b("#10b981"),"Publish now \u2014 go live"),tt=l("button",b("#10b981"),"Start tracking now");for(let r of[T,H,O,U,Z,K])r.disabled=!0;let Dt=[T,H,O,U,q,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",F.style.display="none",X.style.display="none",f.append(y,N,G,M,_,P("Content & style"),T,H,O,P("Track a goal"),U,q,at,S,P("Funnels"),W,F,X,P("Move"),Z,K,bt,xt,Q,tt,Ft),((Vt=document.body)!=null?Vt:document.documentElement).append(n,o,f);let C=l("div",{marginTop:"10px"});f.append(C);let R=()=>{C.textContent=""},lt=(r,i,a)=>{var x;R();let p={},u={},h={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=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},g.label);if(C.append(m),g.type==="select"){let k=l("select",h);k.setAttribute("data-field",g.key);let I=document.createElement("option");I.value="",I.textContent="\u2014 no change \u2014",k.append(I);for(let rt of(x=g.options)!=null?x:[]){let it=document.createElement("option");it.value=rt,it.textContent=rt,k.append(it)}p[g.key]=()=>k.value,C.append(k)}else if(g.type==="color"){let k=l("input",V(D({},h),{padding:"2px",height:"34px"}));k.type="color",k.setAttribute("data-field",g.key);let I=!1;k.addEventListener("input",()=>{I=!0}),p[g.key]=()=>I?k.value:"",C.append(k)}else{let k=l("input",h);k.setAttribute("data-field",g.key),g.value!==void 0&&(k.value=g.value),p[g.key]=()=>k.value,C.append(k)}let v=l("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});v.setAttribute("data-feedback",g.key),u[g.key]=v,C.append(v)}let w=(g,m)=>{let v=u[g];v&&(v.textContent=m!=null?m:"",v.style.display=m?"block":"none")},L=l("button",b("#6366f1"),i),A=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Cancel");L.onclick=()=>a(Object.fromEntries(Object.entries(p).map(([g,m])=>[g,m()])),w),A.onclick=R,C.append(L,A)},d=(r,i=!0)=>{_.textContent=r,_.style.color=i?"#a7f3d0":"#fca5a5"},Y=(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)},ct=null,vt=r=>{ct=r,Q.style.display="block",F.style.display="block"};Q.onclick=async()=>{if(!ct)return;Q.disabled=!0,d("Publishing\u2026");let r=await z(e,`/v1/editor/slots/${encodeURIComponent(ct)}/publish`,{});Q.disabled=!1,r==="ok"?(d("\u2713 Published \u2014 live for new visitors.",!0),Q.style.display="none",ct=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 $=null,dt=!1,ut=null,pt=null,j=null,nt=null,ft=null,kt=null,ot=!1,jt=(r,i)=>dt?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=!dt||!j,K.disabled=!dt||!nt,Z.title=Z.disabled?jt(j,"above"):"",K.title=K.disabled?jt(nt,"below"):""},Pt=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=It(t,document);ut=r.prevEl,pt=r.nextEl,j=r.prevLocator,nt=r.nextLocator}s(),Pt(!1)},qt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i)||i===n)return;yt(document);let a=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},he=r=>{var a;let i=((a=r.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:r.tagName.toLowerCase()},Wt=r=>{if(B)return;let i=r.target;if(!i||f.contains(i))return;r.preventDefault(),r.stopPropagation(),Ut(),R(),t=i,$=mt(i,document);let a=Ct($,i,document);dt=a,s(),M.style.display="block",M.textContent=`Selected: ${he(i)}`,d(a?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",a);for(let w of Dt)w.style.display="block";let p=i.childElementCount===0;T.disabled=!a||!p,T.title=a?p?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",H.disabled=!a,O.disabled=!a,U.disabled=!a;let u=i.closest("form");q.style.display=u?"block":"none",q.disabled=!u;let h=It(i,document);ut=h.prevEl,pt=h.nextEl,j=h.prevLocator,nt=h.nextLocator,Gt()};T.onclick=()=>{var a,p;if(!t||!$)return;let r=$,i=(p=(a=t.textContent)==null?void 0:a.trim())!=null?p:"";lt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async u=>{let h=u.alt.trim();if(!h){d("\u26A0 Enter alternative wording to test.",!1);return}if(h===u.current.trim()){d("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let w=ht("text",r,t);d("Saving\u2026");let L=await z(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}}]}});L==="ok"&&(R(),vt(w)),Y(L,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let gt=null,ye=(r,i,a)=>{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 L,A,x;d("Saving\u2026");let u=await Ve(e,`/v1/editor/arrangements/${encodeURIComponent(r.id)}/instantiate`,{fields:p});if(u.r!=="ok"||!((L=u.data)!=null&&L.blocks)){u.r==="expired"?Y("expired",""):d(`\u26A0 ${(x=(A=u.data)==null?void 0:A.reason)!=null?x:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let h=ht("arrange",i,a),w=await z(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{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(h)),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.")})};O.onclick=async()=>{var p;if(!t||!$)return;let r=$,i=t;if(R(),d("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){d("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}d("Pick an arrangement to test against this section.");for(let u of gt){let h=l("button",V(D({},b("#374151")),{textAlign:"left"}));h.append(l("div",{fontWeight:"600"},u.name),l("div",{fontSize:"11px",opacity:"0.7"},u.description)),h.onclick=()=>ye(u,r,i),C.append(h)}let a=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Cancel");a.onclick=R,C.append(a)};let Et=null,be=r=>{Et=r,tt.style.display="block"};tt.onclick=async()=>{if(!Et)return;tt.disabled=!0,d("Activating\u2026");let r=await z(e,`/v1/editor/goals/${encodeURIComponent(Et)}/publish`,{});tt.disabled=!1,r==="ok"?(d("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),tt.style.display="none",Et=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 Ht=(r,i)=>`${Rt(r)||"goal"}-${le(i)}`.slice(0,128),wt=async(r,i)=>{d("Saving\u2026");let a=await z(e,`/v1/editor/goals/${encodeURIComponent(r)}`,i);a==="ok"&&be(r),Y(a,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};U.onclick=()=>{var i;if(!t||!$)return;let r=Ht(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify($));wt(r,{event:"click",locator:$})},q.onclick=()=>{var p,u;let r=t==null?void 0:t.closest("form");if(!r)return;let i=mt(r,document),a=(u=(p=r.getAttribute("id"))!=null?p:r.getAttribute("name"))!=null?u:"form-submitted";wt(Ht(a,JSON.stringify(i)),{event:"form_submit",locator:i})},at.onclick=()=>{let r=window.location.pathname||"/",i=Rt(r)?`reached-${Rt(r)}`:"page-visited";wt(Ht(i,r),{event:"url_reached",urlPattern:r})};let Ot=[{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:Ot.map(r=>r.label)}],"Track it",r=>{var p;let i=(p=Ot.find(u=>u.label===r.depth))!=null?p:Ot[2],a=Math.round(i.value*100);wt(`read-${a}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,d("Turning on\u2026");let r=await z(e,`/v1/editor/funnels/${encodeURIComponent(St)}/publish`,{});X.disabled=!1,r==="ok"?(d("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),X.style.display="none",St=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 _t(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 a=[],p=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=l("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"});C.append(p,u);let h=l("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");C.append(h);let w=new Map,L=()=>{var m,v;for(let[k,I]of w){let rt=a.indexOf(k),it=(v=(m=i.find(ke=>ke.goal_id===k))==null?void 0:m.display_name)!=null?v:k;I.textContent=rt===-1?it:`${rt+1}. ${it}`,I.style.background=rt===-1?"#374151":"#6366f1"}};for(let m of i){let v=l("button",V(D({},b("#374151")),{textAlign:"left"}));w.set(m.goal_id,v),v.onclick=()=>{a=re(a,m.goal_id),L()},C.append(v)}L();let A=l("button",b("#6366f1"),"Save funnel"),x=l("button",V(D({},b("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=R,A.onclick=async()=>{let m=ie(u.value,a);if(!m.ok){d(`\u26A0 ${m.error}`,!1);return}d("Saving\u2026");let v=await z(e,`/v1/editor/funnels/${encodeURIComponent(m.funnelId)}`,m.body);v==="ok"&&(R(),xe(m.funnelId)),Y(v,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},C.append(A,x)},F.onclick=async()=>{var L,A;let r=ct;if(!r)return;d("Loading funnels\u2026");let i=await _t(e,"/v1/editor/funnels"),a=(L=i==null?void 0:i.funnels)!=null?L:[];if(a.length===0){d("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let p=await _t(e,"/v1/editor/goals"),u=new Map(((A=p==null?void 0:p.goals)!=null?A:[]).map(x=>[x.goal_id,x.display_name]));lt([{key:"funnel",label:"Funnel",type:"select",options:a.map(x=>$t(x))},{key:"step",label:"Which step does this element serve?",type:"select",options:At(a[0],u).map(x=>x.label)}],"Attach",async x=>{var k;let g=(k=a.find(I=>$t(I)===x.funnel))!=null?k:a[0],m=At(g,u).findIndex(I=>I.label===x.step);if(m<0){d("\u26A0 Pick which step this element serves.",!1);return}d("Attaching\u2026");let v=await z(e,`/v1/editor/funnels/${encodeURIComponent(g.funnel_id)}/assign`,{slotId:r,stepIndex:m});v==="ok"&&R(),Y(v,`\u2713 Attached \u2014 this test now works toward \u201C${g.display_name}\u201D.`)});let h=C.querySelector('select[data-field="funnel"]'),w=C.querySelector('select[data-field="step"]');h&&w&&h.addEventListener("change",()=>{var g;let x=(g=a.find(m=>$t(m)===h.value))!=null?g:a[0];w.length=1;for(let m of At(x,u)){let v=document.createElement("option");v.value=m.label,v.textContent=m.label,w.append(v)}})},H.onclick=()=>{if(!t||!$)return;let r=$;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,a)=>{var A;let{style:p,errors:u}=fe(i),h=!1;for(let x of ue)a(x,(A=u[x])!=null?A:null),u[x]&&(h=!0);if(h){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 w=ht("style",r,t);d("Saving\u2026");let L=await z(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}}]}});L==="ok"&&(R(),vt(w)),Y(L,"\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 a=It(t,document);ut=a.prevEl,pt=a.nextEl,j=a.prevLocator,nt=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(p){}s(),Pt(!0),d("Previewing the new position \u2014 keep moving, save, or undo.")};Z.onclick=()=>Yt("up"),K.onclick=()=>Yt("down"),xt.onclick=()=>{Ut(),d("Move undone \u2014 back to the original position.")},bt.onclick=async()=>{if(!t||!$||!ot||!dt)return;let r=j?"moveAfter":"moveBefore",i=j!=null?j:nt;if(!i){d("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=ht("move",$,t);d("Saving\u2026");let p=await z(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:$,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:i}}]}});p==="ok"&&(ot=!1,ft=null,kt=null,Pt(!1),vt(a)),Y(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let ve=()=>{var r;document.removeEventListener("mousemove",qt,!0),document.removeEventListener("click",Wt,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c),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",qt,!0),document.addEventListener("click",Wt,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c)}function b(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 N,B,G,M,_,P,T,H,O,U,q,at;let n=null;try{let S=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});S.ok&&(n=(B=((N=(await S.json()).slots)!=null?N:[]).find(F=>F.slot_id===t&&F.kind==="arms"))!=null?B:null)}catch(S){}let o=l("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=l("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 W of["sentient_editor","sentient_preview","sentient_arm"])S.searchParams.delete(W);location.assign(S.toString())};let c=(P=(_=(G=n==null?void 0:n.draft_config)==null?void 0:G.arms)!=null?_:(M=n==null?void 0:n.published_config)==null?void 0:M.arms)!=null?P:[];if(!n||c.length===0){o.append(l("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),s),((T=document.body)!=null?T:document.documentElement).append(o);return}let f=new URLSearchParams(location.search).get("sentient_arm"),E=(O=(H=c.find(S=>S.id===f))!=null?H:c[1])!=null?O:c[0];o.append(l("span",{fontWeight:"700"},`Previewing: ${(U=n.display_name)!=null?U:n.slot_id}`));let y=n.target&&typeof n.target=="object"?et(n.target,document):null;if(!y)o.append(l("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(y,E.ops,`preview-${n.slot_id}`,document);try{y.scrollIntoView({block:"center"})}catch(S){}for(let S of c){let W=l("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:S.id===E.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(q=S.displayName)!=null?q:S.id);W.onclick=()=>{let F=new URL(location.href);F.searchParams.set("sentient_arm",S.id),location.assign(F.toString())},o.append(W)}}o.append(s),((at=document.body)!=null?at:document.documentElement).append(o)}async function nn(){if(typeof document=="undefined")return;let e=We();if(!e)return;let t=await Ye(e);if(!t.ok){t.unauthorized?(Tt(),ae(Ue)):ae(qe);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&&z(e,"/v1/editor/palette",o);let s=await Je(e);de(s,document)}nn();return $e(on);})();
24
+ `,((e=document.head)!=null?e:document.documentElement).appendChild(t)}function Yt(t){var i,u;Xt(),(i=document.getElementById(Qe))==null||i.remove();let e=s("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"});e.id=Qe;let o=s("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});e.append(o,s("div",{},t)),((u=document.body)!=null?u:document.documentElement).appendChild(e),e.addEventListener("click",()=>e.remove()),setTimeout(()=>e.remove(),1e4)}function On(){let t=window.__sentientEditor;return t&&typeof t.token=="string"&&typeof t.apiBase=="string"?t:null}async function zn(t){try{let e=await fetch(`${t.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${t.token}`}});if(e.status===401)return{ok:!1,unauthorized:!0};if(!e.ok)return{ok:!1,unauthorized:!1};let o=(await e.json()).projectId;return o?{ok:!0,projectId:o}:{ok:!1,unauthorized:!1}}catch(e){return{ok:!1,unauthorized:!1}}}function Zt(t,e){return _(_(_(_({r:t===401?"expired":"error",status:t},typeof(e==null?void 0:e.error)=="string"?{code:e.error}:{}),typeof(e==null?void 0:e.message)=="string"?{message:e.message}:{}),typeof(e==null?void 0:e.feature)=="string"?{feature:e.feature}:{}),typeof(e==null?void 0:e.plan)=="string"?{plan:e.plan}:{})}async function q(t,e,o){try{let i=await fetch(`${t.apiBase}${e}`,{method:"POST",headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(o)});if(i.ok)return{r:"ok"};let u=await i.json().catch(()=>null);return Zt(i.status,u)}catch(i){return{r:"error"}}}async function Nn(t,e,o){try{let i=await fetch(`${t.apiBase}${e}`,{method:"POST",headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(o)}),u=await i.json().catch(()=>null);return i.ok?{r:"ok",data:u,outcome:{r:"ok"}}:{r:i.status===401?"expired":"error",data:u,outcome:Zt(i.status,u)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var ut=[];function Vt(t){if(/^#[0-9a-fA-F]{6}$/.test(t))return t;let e=/^rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(t);if(!e)return t;let o=i=>Number(i).toString(16).padStart(2,"0");return`#${o(e[1])}${o(e[2])}${o(e[3])}`}var Q=null;async function jn(t){try{let e=await fetch(`${t.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${t.token}`}});if(!e.ok)return[];let o=await e.json();return ut=Array.isArray(o.fonts)?o.fonts.filter(i=>typeof i=="string"):[],Array.isArray(o.targets)?o.targets:[]}catch(e){return[]}}async function Xe(t,e){try{let o=await fetch(`${t.apiBase}${e}`,{headers:{authorization:`Bearer ${t.token}`}});return o.ok?await o.json():null}catch(o){return null}}function Ee(t=document){for(let e of Array.from(t.querySelectorAll(`.${ct}`)))e.remove()}function Kt(t,e=document){var i;Ee(e);let o=0;for(let u of t){if(o>=In)break;let p=ye(u.locator,e);if(!p)continue;let k=p.getBoundingClientRect(),C=s("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${k.left}px`,top:`${k.top}px`,width:`${k.width}px`,height:`${k.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});C.className=ct;let L=s("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${k.left}px`,top:`${Math.max(0,k.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},u.label);L.className=ct,((i=e.body)!=null?i:e.documentElement).append(C,L),o+=1}}function Ke(t,e){let o=t.previousElementSibling,i=t.nextElementSibling,u=o?ke(o,e):null,p=i?ke(i,e):null;return{prevEl:o,nextEl:i,prevLocator:o&&u&&Me(u,o,e)?u:null,nextLocator:i&&p&&Me(p,i,e)?p:null}}var pt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Fn=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,qn=new Set(["left","center","right","justify","start","end"]),Dn=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Un=/^(rgb|rgba|hsl|hsla)\(/i;function Gn(t){return Dn.test(t)||Un.test(t)}function Qt(t,e){switch(t){case"fontSize":case"borderRadius":return Fn.test(e)?null:"Add a unit, e.g. 20px or 1.5rem.";case"fontWeight":return/^(normal|bold|bolder|lighter)$/i.test(e)||/^\d{1,4}$/.test(e)&&+e>=1&&+e<=1e3?null:"Use 100\u2013900, or normal/bold.";case"textAlign":return qn.has(e.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Gn(e)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let o=e.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return e.length<=120&&o.length>=1&&o.length<=5&&o.every(i=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(i))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function ft(t){let e={},o={};for(let i of pt){let u=t[i];if(typeof u!="string")continue;let p=u.trim();if(p==="")continue;if(!Ie(p)){o[i]="That value isn\u2019t allowed.";continue}let k=Qt(i,p);if(k){o[i]=k;continue}e[i]=p}return{style:e,errors:o}}function s(t,e,o){let i=document.createElement(t);return Object.assign(i.style,e),o!==void 0&&(i.textContent=o),i}function en(t){var It;let e=null,o=[],i=null,u=()=>{if(o.length===0)return;let n=o.splice(0,20);try{fetch(`${t.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify({events:n})}).catch(()=>{})}catch(r){}},p=(n,r)=>{o.push(_({kind:n},r?{meta:r}:{})),i&&clearTimeout(i),i=setTimeout(u,2e3)};window.addEventListener("pagehide",u);let k=s("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});k.id=Rn;let C=s("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});C.id=Mn;let L=()=>{if(!e||!e.isConnected){C.style.display="none";return}let n=e.getBoundingClientRect();Object.assign(C.style,{display:"block",left:`${n.left-2}px`,top:`${n.top-2}px`,width:`${n.width}px`,height:`${n.height}px`})},H=()=>L();Xt();let A=s("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"408px",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)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",overscrollBehavior:"contain"});A.id=we;let ae=s("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});ae.className="sntedi-dot";let D=s("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});D.append(ae,s("span",{},"SentientUI"));let F=s("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),R=!1,z=s("button",S("#374151"),"Pause selecting");z.onclick=()=>{R=!R,z.textContent=R?"Resume selecting":"Pause selecting",R?(k.style.display="none",Ee(document),y("Selection paused \u2014 browse normally, then resume.")):y("Click any element on the page to adapt it.")};let W=s("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"}),Y=s("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),M=s("button",S("#6366f1"),"Test different text here"),N=s("button",S("#374151"),"Change style"),ee=s("button",S("#374151"),"Try a different arrangement"),U=s("button",S("#374151"),"Track clicks as a goal"),T=s("button",S("#374151"),"Track form submissions as a goal"),V=s("button",S("#374151"),"Track page visits as a goal"),te=s("button",S("#374151"),"Track reading this far as a goal"),gt=s("button",S("#374151"),"Set up a funnel"),Pe=s("button",S("#374151"),"Attach this test to a funnel step"),le=s("button",S("#10b981"),"Turn the funnel on"),de=s("button",S("#374151"),"Move up"),ce=s("button",S("#374151"),"Move down"),Oe=s("button",S("#6366f1"),"Save this arrangement"),ze=s("button",S("#374151"),"Undo"),et=s("button",j(_({},S("transparent")),{opacity:"0.6"}),"Close editor"),ue=s("button",S("#10b981"),"Publish now \u2014 go live"),pe=s("button",S("#10b981"),"Start tracking now");for(let n of[M,N,ee,U,de,ce])n.disabled=!0;let mt=[M,N,ee,U,T,de,ce];for(let n of mt)n.style.display="none";Oe.style.display="none",ze.style.display="none",ue.style.display="none",pe.style.display="none",Pe.style.display="none",le.style.display="none";let fe=s("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),Se=s("div",{}),ht=[{id:"text",label:"Text",icon:"\u270F\uFE0F"},{id:"style",label:"Style",icon:"\u{1F3A8}"},{id:"layout",label:"Layout",icon:"\u{1F9F1}"},{id:"goals",label:"Goals",icon:"\u{1F3AF}"},{id:"funnels",label:"Funnels",icon:"\u{1F9ED}"},{id:"drafts",label:"Drafts",icon:"\u{1F5C2}\uFE0F"}],G="text",yt=new Map,ne=new Map,tt=new Map,bt=s("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),xt=s("div",{paddingTop:"10px"});for(let n of ht){let r=s("button",{background:"transparent",border:"none",cursor:"pointer",font:"600 11.5px system-ui, sans-serif",color:"#9ca3af",whiteSpace:"nowrap",padding:"7px 5px",borderBottom:"2px solid transparent",marginBottom:"-1px"});r.append(s("span",{fontSize:"11px",marginRight:"3px"},n.icon),s("span",{},n.label)),r.onclick=()=>Ne(n.id),yt.set(n.id,r),bt.append(r);let a=s("div",{display:"none"}),c=s("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});a.append(c),tt.set(n.id,c),ne.set(n.id,a),xt.append(a)}ne.get("text").append(M),ne.get("style").append(N),ne.get("layout").append(ee,de,ce,Oe,ze),ne.get("goals").append(U,T,V,te,pe),ne.get("funnels").append(gt,Pe,le);let be=s("div",{});ne.get("drafts").append(be);let nt=()=>{var r,a;for(let c of ht){let l=c.id===G,g=yt.get(c.id);g.style.color=l?"#ffffff":"#9ca3af",g.style.borderBottom=l?"2px solid #6366f1":"2px solid transparent",ne.get(c.id).style.display=l?"block":"none",tt.get(c.id).style.display="none"}let n=c=>{let l=tt.get(G);l.textContent=c,l.style.display="block"};G==="text"?e?M.disabled?n(M.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(r=M.onclick)==null||r.call(M,new MouseEvent("click")):n("Click any text on the page to test a different wording."):G==="style"?e?N.disabled?n("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(a=N.onclick)==null||a.call(N,new MouseEvent("click")):n("Click any element on the page to change how it looks."):G==="layout"?e||n("Click a section to rearrange it, move it, or test a catalog layout against it."):G==="goals"?e||n("Page-level goals work right away; click a button or form to track it specifically."):G==="funnels"?n("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):G==="drafts"&&vt()},vt=async()=>{var a,c,l,g,d,f,b,x,m,h,w,E;be.textContent="",be.append(s("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let n=[];try{let v=await fetch(`${t.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${t.token}`}});v.ok&&(n=(a=(await v.json()).slots)!=null?a:[])}catch(v){}if(G!=="drafts")return;be.textContent="";let r=n.filter(v=>{var $,I,Z,re,he,ie;return((Z=(I=($=v.draft_config)==null?void 0:$.arms)==null?void 0:I.length)!=null?Z:0)>0||((ie=(he=(re=v.published_config)==null?void 0:re.arms)==null?void 0:he.length)!=null?ie:0)>0});if(r.length===0){be.append(s("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes you save land here, previewable before they go live."));return}for(let v of r){let $=s("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),I=s("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},(c=v.display_name)!=null?c:v.slot_id),Z=s("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:v.status==="published"?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:v.status==="published"?"#6ee7b7":"#c7d2fe"},v.status==="published"?"live":"draft"),re=(f=(d=(l=v.draft_config)==null?void 0:l.arms)!=null?d:(g=v.published_config)==null?void 0:g.arms)!=null?f:[],he=(m=(b=re[1])==null?void 0:b.id)!=null?m:(x=re[0])==null?void 0:x.id,ie=s("button",j(_({},S("#374151")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),"Preview");if(ie.onclick=()=>{let K=new URL(window.location.href);K.searchParams.delete("sentient_editor"),K.searchParams.set("sentient_preview",v.slot_id),he&&K.searchParams.set("sentient_arm",he),window.location.assign(K.toString())},$.append(I,Z,ie),v.status!=="published"&&((E=(w=(h=v.draft_config)==null?void 0:h.arms)==null?void 0:w.length)!=null?E:0)>0){let K=s("button",j(_({},S("#10b981")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),"Publish");K.onclick=async()=>{K.disabled=!0;let Ht=await q(t,`/v1/editor/slots/${encodeURIComponent(v.slot_id)}/publish`,{});K.disabled=!1,J(Ht,"\u2713 Published \u2014 live for new visitors."),Ht.r==="ok"&&(p("published",{kind:"slot"}),vt())},$.append(K)}be.append($)}},Ne=n=>{G!==n&&P(),G=n,nt()},kt=s("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(D.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let wt=!1,ge=s("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"46px",height:"46px",borderRadius:"50%",border:"1px solid rgba(99,102,241,0.55)",background:"#111827",color:"#fff",cursor:"pointer",display:"none",alignItems:"center",justifyContent:"center",gap:"4px",font:"700 15px system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"}),Et=s("span",{width:"7px",height:"7px",borderRadius:"50%",background:"#34d399",display:"inline-block"});Et.className="sntedi-dot",ge.append(Et,s("span",{},"S")),ge.title="Open the SentientUI editor";let St=s("button",{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",color:"#fff",border:"none",cursor:"pointer",whiteSpace:"nowrap"},"Minimize");St.onclick=()=>{A.style.display="none",ge.style.display="flex",wt=R,R=!0,k.style.display="none",Ee(document)},ge.onclick=()=>{A.style.display="block",ge.style.display="none",R=wt},Object.assign(z.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Object.assign(et.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",whiteSpace:"nowrap"}),kt.append(D,z,St,et);let Tt=s("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"});Object.assign(Y.style,{marginBottom:"4px"}),Tt.append(Y,ue);let oe=s("button",{display:"none",width:"auto",margin:"0",padding:"5px 10px",flex:"0 0 auto",fontSize:"11px",borderRadius:"999px",background:"rgba(250,204,21,0.15)",border:"1px solid rgba(250,204,21,0.45)",color:"#fde68a",cursor:"pointer",whiteSpace:"nowrap"},"\u{1F4A1} Suggest"),ot=s("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(W.style,{flex:"1 1 auto",marginBottom:"0"}),ot.append(W,oe),Object.assign(ot.style,{marginBottom:"6px"});let Te=s("div",{}),B=s("div",{marginTop:"4px"});A.append(kt,F,ot,fe,Se,Te,bt,xt,B,Tt),((It=document.body)!=null?It:document.documentElement).append(k,C,A,ge);let me=null,Lt=()=>{me==null||me(),me=null},Ct=()=>{me=null},P=()=>{Lt(),B.textContent=""},Le=(n,r,a)=>{var x;P();let c={},l={},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 m of n){let h=s("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},m.label);if(B.append(h),m.type==="select"){let E=s("select",g);E.setAttribute("data-field",m.key);let v=document.createElement("option");v.value="",v.textContent="\u2014 no change \u2014",E.append(v);for(let $ of(x=m.options)!=null?x:[]){let I=document.createElement("option");I.value=$,I.textContent=$,E.append(I)}c[m.key]=()=>E.value,B.append(E)}else if(m.type==="color"){let E=s("input",j(_({},g),{padding:"2px",height:"34px"}));E.type="color",E.setAttribute("data-field",m.key);let v=!1;E.addEventListener("input",()=>{v=!0}),c[m.key]=()=>v?E.value:"",B.append(E)}else{let E=s("input",g);E.setAttribute("data-field",m.key),m.value!==void 0&&(E.value=m.value),c[m.key]=()=>E.value,B.append(E)}let w=s("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});w.setAttribute("data-feedback",m.key),l[m.key]=w,B.append(w)}let d=(m,h)=>{let w=l[m];w&&(w.textContent=h!=null?h:"",w.style.display=h?"block":"none")},f=s("button",S("#6366f1"),r),b=s("button",j(_({},S("transparent")),{opacity:"0.6"}),"Cancel");f.onclick=()=>a(Object.fromEntries(Object.entries(c).map(([m,h])=>[m,h()])),d),b.onclick=P,B.append(f,b)},y=(n,r=!0)=>{Y.textContent=n,Y.style.color=r?"#a7f3d0":"#fca5a5"},rt=(n,r)=>{var c,l;if(p("error_shown",{code:(l=n.code)!=null?l:`http_${(c=n.status)!=null?c:"network"}`}),n.code==="plan_limit_reached"){let g=n.feature==="live_goals"?"live goal":"of these",d=n.plan?`${n.plan} plan`:"plan";return n.feature==="live_goals"?`Your ${d} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${d} has reached its limit for ${g}. Manage them in your dashboard, or upgrade for more.`}if(n.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(n.code==="demo_read_only"&&n.message)return n.message;let a=n.status?` (HTTP ${n.status})`:"";return`\u26A0 Couldn\u2019t ${r} \u2014 try again.${a}`},J=(n,r)=>{n.r==="ok"?y(r,!0):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):y(rt(n,"save"),!1)},Ce=null,je=n=>{Ce=n,ue.style.display="block",Pe.style.display="block"};ue.onclick=async()=>{if(!Ce)return;ue.disabled=!0,y("Publishing\u2026");let n=await q(t,`/v1/editor/slots/${encodeURIComponent(Ce)}/publish`,{});ue.disabled=!1,n.r==="ok"?(p("published",{kind:"slot"}),y("\u2713 Published \u2014 live for new visitors.",!0),ue.style.display="none",Ce=null):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):y(rt(n,"publish"),!1)};let O=null,Be=!1,_e=null,$e=null,X=null,xe=null,Ae=null,Fe=null,ve=!1,Bt=(n,r)=>Be?n?"":`Nothing to swap with ${r} \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.",_t=()=>{de.disabled=!Be||!X,ce.disabled=!Be||!xe,de.title=de.disabled?Bt(X,"above"):"",ce.title=ce.disabled?Bt(xe,"below"):""},it=n=>{Oe.style.display=n?"block":"none",ze.style.display=n?"block":"none",_t()},$t=()=>{if(ve&&e&&Ae&&Ae.insertBefore(e,Fe),ve=!1,Ae=null,Fe=null,e){let n=Ke(e,document);_e=n.prevEl,$e=n.nextEl,X=n.prevLocator,xe=n.nextLocator}L(),it(!1)},At=n=>{if(R)return;let r=n.target;if(!r||A.contains(r)||r===k)return;Ee(document);let a=r.getBoundingClientRect();Object.assign(k.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},st=n=>{var a;let r=((a=n.textContent)!=null?a:"").trim().replace(/\s+/g," ");return r?r.length>40?`${r.slice(0,37)}\u2026`:r:n.tagName.toLowerCase()},nn=n=>!!n.id||["section","header","footer","nav","main","form","article","aside"].includes(n.tagName.toLowerCase())||!!n.querySelector(":scope > h1, :scope > h2, :scope > h3"),on=n=>{var c;let r=n.querySelector("h1, h2, h3"),a=(c=r==null?void 0:r.textContent)==null?void 0:c.replace(/\s+/g," ").trim();return a?a.length>28?`${a.slice(0,25)}\u2026`:a:n.id?`#${n.id.length>24?`${n.id.slice(0,21)}\u2026`:n.id}`:`<${n.tagName.toLowerCase()}>`},rn=n=>{fe.textContent="";let r=[];for(let g=n.parentElement;g&&g!==document.body&&r.length<3;g=g.parentElement)nn(g)&&r.push(g);let a=st(n),c=()=>s("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),l=!0;for(let g of r){let d=on(g);if(d===a||a.startsWith(d))continue;let f=s("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},d);f.onclick=()=>at(g),l||fe.append(c()),fe.append(f),l=!1}l||fe.append(c()),fe.append(s("span",{opacity:"0.6"},"Page")),fe.style.display="block"},sn=n=>{Se.textContent="";let r=null,a=0;for(let l=n.parentElement;l&&l!==document.body&&a<6;l=l.parentElement,a++)if(Me(ke(l,document),l,document)){r=l;break}let c=s("div",{marginBottom:"8px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(252,165,165,0.12)",border:"1px solid rgba(252,165,165,0.4)"});if(r){let l=r;c.append(s("div",{marginBottom:"6px"},"This exact element can\u2019t be tracked safely \u2014 it looks identical to others on the page. You can pick something more specific inside it, or work with the whole block, which we can target reliably."));let g=s("button",j(_({},S("#6366f1")),{marginTop:"0"}),`Select \u201C${st(l)}\u201D instead`);g.onclick=()=>at(l);let d=s("button",j(_({},S("transparent")),{opacity:"0.6"}),"Pick something else");d.onclick=()=>{Se.textContent=""},c.append(g,d)}else c.append(s("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));Se.append(c)},at=n=>{$t(),P(),Se.textContent="",e=n,O=ke(n,document);let r=Me(O,n,document);Be=r,L(),W.style.display="block",W.textContent=`Selected: ${st(n)}`,rn(n),p("element_selected",{unique:r}),y(r?"\u2713 Matches exactly 1 element":"",r),r||sn(n),F.style.display="none",oe.style.display="inline-block",Te.textContent="";for(let g of mt)g.style.display="block";M.style.display="none",N.style.display="none";let a=n.childElementCount===0;M.disabled=!r||!a,M.title=r?a?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",N.disabled=!r,ee.disabled=!r,U.disabled=!r;let c=n.closest("form");T.style.display=c?"block":"none",T.disabled=!c;let l=Ke(n,document);_e=l.prevEl,$e=l.nextEl,X=l.prevLocator,xe=l.nextLocator,_t(),nt()},Rt=n=>{if(R)return;let r=n.target;!r||A.contains(r)||(n.preventDefault(),n.stopPropagation(),at(r))};M.onclick=()=>{var g,d,f;if(!e||!O)return;p("form_opened",{kind:"text"});let n=O,r=(d=(g=e.textContent)==null?void 0:g.trim())!=null?d:"";Le([{key:"current",label:"Current wording",value:r},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async b=>{let x=b.alt.trim();if(!x){y("\u26A0 Enter alternative wording to test.",!1);return}if(x===b.current.trim()){y("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let m=He("text",n,e);y("Saving\u2026");let h=await q(t,`/v1/editor/slots/${encodeURIComponent(m)}`,{kind:"arms",target:n,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:b.current}},{id:"b",displayName:"Alternative",ops:{text:b.alt}}]}});h.r==="ok"&&(p("draft_saved",{kind:"slot"}),Ct(),P(),je(m)),J(h,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")});let a=e,c=(f=a.textContent)!=null?f:"";me=()=>{a.textContent=c};let l=B.querySelector('input[data-field="alt"]');l==null||l.addEventListener("input",()=>{a.textContent=l.value.trim()===""?c:l.value})};let Re=null,an=n=>{let r=d=>{var f;return((f=d.textContent)!=null?f:"").replace(/\s+/g," ").trim()},a=Array.from(n.querySelectorAll("h1,h2,h3,h4")).map(r).filter(Boolean);if(a.length===0){let d=n.closest("h1,h2,h3,h4");d&&a.push(r(d))}let c=Array.from(n.querySelectorAll("p")).map(r).filter(d=>d.length>0&&d.length<=300),l=[];for(let d of Array.from(n.querySelectorAll("a[href], button"))){let f=r(d);if(!f||f.length>60)continue;let b="",x=d.getAttribute("href");if(x)try{let m=new URL(x,window.location.href);m.protocol==="https:"&&(b=m.href)}catch(m){}l.push({label:f,href:b})}let g=Array.from(n.querySelectorAll("blockquote, q")).map(r).filter(Boolean);return{headings:a,paragraphs:c,links:l,quotes:g}},ln=(n,r)=>{var c,l,g,d,f,b,x,m,h,w,E,v,$,I,Z,re;let a=he=>{var ie;return r.paragraphs.length>=3&&(ie=r.paragraphs[r.paragraphs.length-3+he])!=null?ie:""};switch(n){case"headline":return(c=r.headings[0])!=null?c:"";case"supporting":return(l=r.paragraphs[0])!=null?l:"";case"cta_label":return(d=(g=r.links[0])==null?void 0:g.label)!=null?d:"";case"cta_href":return(b=(f=r.links[0])==null?void 0:f.href)!=null?b:"";case"secondary_label":return(m=(x=r.links[1])==null?void 0:x.label)!=null?m:"";case"secondary_href":return(w=(h=r.links[1])==null?void 0:h.href)!=null?w:"";case"quote":case"q1":return(E=r.quotes[0])!=null?E:"";case"q2":return(v=r.quotes[1])!=null?v:"";case"q3":return($=r.quotes[2])!=null?$:"";case"f1_title":return(I=r.headings[1])!=null?I:"";case"f2_title":return(Z=r.headings[2])!=null?Z:"";case"f3_title":return(re=r.headings[3])!=null?re:"";case"f1_body":return a(0);case"f2_body":return a(1);case"f3_body":return a(2);default:return""}},dn=(n,r,a)=>{p("form_opened",{kind:"arrangement"});let c=an(a);Le(n.fields.map(l=>({key:l.id,label:l.kind==="href"?`${l.label} (https link \u2014 required)`:l.label,value:ln(l.id,c)||l.default||""})),"Save draft",async(l,g)=>{var m,h,w,E;let d=!1;for(let v of n.fields){if(v.kind!=="href")continue;let $=!1;try{$=new URL((m=l[v.id])!=null?m:"").protocol==="https:"}catch(I){}g(v.id,$?null:"Links need to start with https://"),$||(d=!0)}if(d){y("\u26A0 Fix the highlighted link(s).",!1);return}y("Saving\u2026");let f=await Nn(t,`/v1/editor/arrangements/${encodeURIComponent(n.id)}/instantiate`,{fields:l});if(f.r!=="ok"||!((h=f.data)!=null&&h.blocks)){f.r==="expired"?J(f.outcome,""):y(`\u26A0 ${(E=(w=f.data)==null?void 0:w.reason)!=null?E:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let b=He("arrange",r,a),x=await q(t,`/v1/editor/slots/${encodeURIComponent(b)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:n.id,displayName:n.name,blocks:f.data.blocks}],baseline:"original"}});x.r==="ok"&&(p("draft_saved",{kind:"arrangement"}),P(),je(b)),J(x,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish now\u201D to go live.")})};ee.onclick=async()=>{var c,l;if(!e||!O)return;let n=O,r=e;if(P(),y("Loading arrangements\u2026"),!Re){let g=await Xe(t,"/v1/editor/arrangements");Re=(c=g==null?void 0:g.arrangements)!=null?c:null}if(!Re||Re.length===0){y("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}y("Pick an arrangement to test against this section.");for(let g of Re){let d=s("button",j(_({},S("#374151")),{textAlign:"left"}));d.append(s("div",{fontWeight:"600"},g.name),s("div",{fontSize:"11px",opacity:"0.7"},g.description)),d.onclick=()=>dn(g,n,r),B.append(d)}let a=s("button",j(_({},S("transparent")),{opacity:"0.6"}),"Cancel");a.onclick=P,B.append(a),(l=B.scrollIntoView)==null||l.call(B,{block:"nearest"})};let qe=null,cn=n=>{qe=n,pe.style.display="block"};pe.onclick=async()=>{if(!qe)return;pe.disabled=!0,y("Activating\u2026");let n=await q(t,`/v1/editor/goals/${encodeURIComponent(qe)}/publish`,{});pe.disabled=!1,n.r==="ok"?(p("published",{kind:"goal"}),y("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),pe.style.display="none",qe=null):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):y(rt(n,"activate"),!1)};let lt=(n,r)=>`${Ze(n)||"goal"}-${Jt(r)}`.slice(0,128),De=async(n,r)=>{y("Saving\u2026");let a=await q(t,`/v1/editor/goals/${encodeURIComponent(n)}`,r);a.r==="ok"&&(p("draft_saved",{kind:"goal"}),cn(n)),J(a,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};U.onclick=()=>{var r;if(!e||!O)return;let n=lt(((r=e.textContent)!=null?r:"").trim()||"element-clicked",JSON.stringify(O));De(n,{event:"click",locator:O})},T.onclick=()=>{var c,l;let n=e==null?void 0:e.closest("form");if(!n)return;let r=ke(n,document),a=(l=(c=n.getAttribute("id"))!=null?c:n.getAttribute("name"))!=null?l:"form-submitted";De(lt(a,JSON.stringify(r)),{event:"form_submit",locator:r})},V.onclick=()=>{let n=window.location.pathname||"/",r=Ze(n)?`reached-${Ze(n)}`:"page-visited";De(lt(r,n),{event:"url_reached",urlPattern:n})};let dt=[{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}];te.onclick=()=>{Le([{key:"depth",label:"Counts once a visitor reads",type:"select",options:dt.map(n=>n.label)}],"Track it",n=>{var c;let r=(c=dt.find(l=>l.label===n.depth))!=null?c:dt[2],a=Math.round(r.value*100);De(`read-${a}pct`,{event:"scroll_depth",threshold:r.value}),P()})};let Ue=null,un=n=>{Ue=n,le.style.display="block"};le.onclick=async()=>{if(!Ue)return;le.disabled=!0,y("Turning on\u2026");let n=await q(t,`/v1/editor/funnels/${encodeURIComponent(Ue)}/publish`,{});le.disabled=!1,n.r==="ok"?(p("published",{kind:"funnel"}),y("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),le.style.display="none",Ue=null):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):y("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},gt.onclick=async()=>{var m;y("Loading your goals\u2026");let n=await Xe(t,"/v1/editor/goals"),r=(m=n==null?void 0:n.goals)!=null?m:[];if(r.length<2){y("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}y("Pick the steps in order \u2014 first click = first step."),P();let a=[],c=s("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),l=s("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"});B.append(c,l);let g=s("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");B.append(g);let d=new Map,f=()=>{var h,w;for(let[E,v]of d){let $=a.indexOf(E),I=(w=(h=r.find(Z=>Z.goal_id===E))==null?void 0:h.display_name)!=null?w:E;v.textContent=$===-1?I:`${$+1}. ${I}`,v.style.background=$===-1?"#374151":"#6366f1"}};for(let h of r){let w=s("button",j(_({},S("#374151")),{textAlign:"left"}));d.set(h.goal_id,w),w.onclick=()=>{a=Ut(a,h.goal_id),f()},B.append(w)}f();let b=s("button",S("#6366f1"),"Save funnel"),x=s("button",j(_({},S("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=P,b.onclick=async()=>{let h=Gt(l.value,a);if(!h.ok){y(`\u26A0 ${h.error}`,!1);return}y("Saving\u2026");let w=await q(t,`/v1/editor/funnels/${encodeURIComponent(h.funnelId)}`,h.body);w.r==="ok"&&(p("draft_saved",{kind:"funnel"}),P(),un(h.funnelId)),J(w,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},B.append(b,x)},Pe.onclick=async()=>{var f,b;let n=Ce;if(!n)return;y("Loading funnels\u2026");let r=await Xe(t,"/v1/editor/funnels"),a=(f=r==null?void 0:r.funnels)!=null?f:[];if(a.length===0){y("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let c=await Xe(t,"/v1/editor/goals"),l=new Map(((b=c==null?void 0:c.goals)!=null?b:[]).map(x=>[x.goal_id,x.display_name]));Le([{key:"funnel",label:"Funnel",type:"select",options:a.map(x=>Ve(x))},{key:"step",label:"Which step does this element serve?",type:"select",options:Je(a[0],l).map(x=>x.label)}],"Attach",async x=>{var E;let m=(E=a.find(v=>Ve(v)===x.funnel))!=null?E:a[0],h=Je(m,l).findIndex(v=>v.label===x.step);if(h<0){y("\u26A0 Pick which step this element serves.",!1);return}y("Attaching\u2026");let w=await q(t,`/v1/editor/funnels/${encodeURIComponent(m.funnel_id)}/assign`,{slotId:n,stepIndex:h});w.r==="ok"&&P(),J(w,`\u2713 Attached \u2014 this test now works toward \u201C${m.display_name}\u201D.`)});let g=B.querySelector('select[data-field="funnel"]'),d=B.querySelector('select[data-field="step"]');g&&d&&g.addEventListener("change",()=>{var m;let x=(m=a.find(h=>Ve(h)===g.value))!=null?m:a[0];d.length=1;for(let h of Je(x,l)){let w=document.createElement("option");w.value=h.label,w.textContent=h.label,d.append(w)}})},N.onclick=()=>{if(!e||!O)return;p("form_opened",{kind:"style"});let n=O;Le([{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:ut.length?`Font (this site has: ${ut.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(d,f)=>{var E;let{style:b,errors:x}=ft(d),m=!1;for(let v of pt)f(v,(E=x[v])!=null?E:null),x[v]&&(m=!0);if(m){y("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(b).length===0){y("\u26A0 Enter at least one style change.",!1);return}let h=He("style",n,e);y("Saving\u2026");let w=await q(t,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:n,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:b}}]}});w.r==="ok"&&(p("draft_saved",{kind:"slot"}),Ct(),P(),je(h)),J(w,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")});let r=e,a=r.style.cssText;me=()=>{r.style.cssText=a};let c={},l=()=>{let{style:d}=ft(c);r.style.cssText=a;for(let[f,b]of Object.entries(d)){let x=Ye[f];x&&Ie(b)&&r.style.setProperty(x,b.trim(),"important")}};for(let d of pt){let f=B.querySelector(`[data-field="${d}"]`);if(!f)continue;let b=()=>{c[d]=f.value,l()};f.addEventListener("input",b),f.addEventListener("change",b)}let g=[Q==null?void 0:Q.primaryBg,Q==null?void 0:Q.primaryText,"#ffffff"].filter((d,f,b)=>!!d&&b.indexOf(d)===f);for(let d of["color","background"]){let f=B.querySelector(`input[data-field="${d}"]`);if(!f)continue;let b=s("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let x of g){let m=s("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:x,padding:"0"});m.title=x,m.onclick=()=>{f.value=Vt(x),f.dispatchEvent(new Event("input"))},b.append(m)}f.after(b)}},oe.onclick=async()=>{var l,g;if(!e)return;oe.disabled=!0;let n=oe.textContent;oe.textContent="Thinking\u2026",Te.textContent="",p("form_opened",{kind:"suggest"});let r={};try{let d=await fetch(`${t.apiBase}/v1/editor/suggest`,{method:"POST",headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(_({element:{tag:e.tagName.toLowerCase(),text:((l=e.textContent)!=null?l:"").replace(/\s+/g," ").trim().slice(0,400)},pageUrl:window.location.pathname},Q?{palette:Q}:{}))});d.ok&&(r=await d.json())}catch(d){}if(oe.disabled=!1,oe.textContent=n,r.locked){y("AI suggestions aren\u2019t included in this plan.",!1);return}let a=(g=r.suggestions)!=null?g:[];if(a.length===0){y("No safe suggestions for this element \u2014 try a headline, a button, or a section.",!1);return}let c=(d,f)=>{let b=B.querySelector(`[data-field="${d}"]`);b&&(b.value=f,b.dispatchEvent(new Event("input")))};for(let d of a){let f=s("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",fontSize:"12px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"});f.append(s("div",{fontWeight:"600",marginBottom:"2px"},d.title),s("div",{opacity:"0.75",marginBottom:"6px"},d.reason));let b=s("button",j(_({},S("#6366f1")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 10px",fontSize:"11px"}),"Try it");b.onclick=()=>{var x,m;if(Te.textContent="",d.kind==="text")Ne("text"),c("alt",d.variant);else if(d.kind==="style"){Ne("style");for(let[h,w]of Object.entries(d.style))c(h,h==="color"||h==="background"?Vt(w):w)}else Ne("goals"),d.goalType==="form_submit"&&!T.disabled?(x=T.onclick)==null||x.call(T,new MouseEvent("click")):(m=U.onclick)==null||m.call(U,new MouseEvent("click"))},f.append(b),Te.append(f)}};let Mt=n=>{if(!e)return;let r=e.parentElement;if(!r)return;ve||(Ae=r,Fe=e.nextSibling,ve=!0),n==="up"&&_e?r.insertBefore(e,_e):n==="down"&&$e&&r.insertBefore(e,$e.nextSibling);let a=Ke(e,document);_e=a.prevEl,$e=a.nextEl,X=a.prevLocator,xe=a.nextLocator;try{e.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(c){}L(),it(!0),y("Previewing the new position \u2014 keep moving, save, or undo.")};de.onclick=()=>Mt("up"),ce.onclick=()=>Mt("down"),ze.onclick=()=>{$t(),y("Move undone \u2014 back to the original position.")},Oe.onclick=async()=>{if(!e||!O||!ve||!Be)return;let n=X?"moveAfter":"moveBefore",r=X!=null?X:xe;if(!r){y("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=He("move",O,e);y("Saving\u2026");let c=await q(t,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:O,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[n]:r}}]}});c.r==="ok"&&(p("draft_saved",{kind:"move"}),ve=!1,Ae=null,Fe=null,it(!1),je(a)),J(c,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let pn=()=>{var n;p("editor_closed"),u(),window.removeEventListener("pagehide",u),i&&clearTimeout(i),Lt(),document.removeEventListener("mousemove",At,!0),document.removeEventListener("click",Rt,!0),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H),Ee(document),k.remove(),C.remove(),A.remove(),ge.remove(),window.__sentientEditor=null,(n=document.querySelector("meta[data-sentient-editor]"))==null||n.remove(),We()};et.onclick=pn,document.addEventListener("mousemove",At,!0),document.addEventListener("click",Rt,!0),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),nt(),p("editor_opened")}function S(t){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:t,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}var tn="sentient-preview-bar";async function Wn(t,e){var A,ae,D,F,R,z,W,Y,M,N,ee,U;try{fetch(`${t.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify({events:[{kind:"previewed"}]})}).catch(()=>{})}catch(T){}let o=null;try{let T=await fetch(`${t.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${t.token}`}});T.ok&&(o=(ae=((A=(await T.json()).slots)!=null?A:[]).find(te=>te.slot_id===e&&te.kind==="arms"))!=null?ae:null)}catch(T){}let i=s("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)"});i.id=tn;let u=s("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");u.onclick=()=>{We();let T=new URL(location.href);for(let V of["sentient_editor","sentient_preview","sentient_arm"])T.searchParams.delete(V);location.assign(T.toString())};let p=s("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"#6366f1",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Back to editor");p.onclick=()=>{let T=new URL(location.href);for(let V of["sentient_preview","sentient_arm"])T.searchParams.delete(V);location.assign(T.toString())};let k=(z=(R=(D=o==null?void 0:o.draft_config)==null?void 0:D.arms)!=null?R:(F=o==null?void 0:o.published_config)==null?void 0:F.arms)!=null?z:[];if(!o||k.length===0){i.append(s("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),p,u),((W=document.body)!=null?W:document.documentElement).append(i);return}let C=new URLSearchParams(location.search).get("sentient_arm"),L=(M=(Y=k.find(T=>T.id===C))!=null?Y:k[1])!=null?M:k[0];i.append(s("span",{fontWeight:"700"},`Previewing: ${(N=o.display_name)!=null?N:o.slot_id}`));let H=o.target&&typeof o.target=="object"?ye(o.target,document):null;if(!H)i.append(s("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{Dt(H,L.ops,`preview-${o.slot_id}`,document);try{H.scrollIntoView({block:"center"})}catch(T){}for(let T of k){let V=s("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:T.id===L.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ee=T.displayName)!=null?ee:T.id);V.onclick=()=>{let te=new URL(location.href);te.searchParams.set("sentient_arm",T.id),location.assign(te.toString())},i.append(V)}}i.append(p,u),((U=document.body)!=null?U:document.documentElement).append(i)}async function Yn(){if(typeof document=="undefined")return;let t=On();if(!t)return;let e=await zn(t);if(!e.ok){e.unauthorized?(We(),Yt(Hn)):Yt(Pn);return}let o=new URLSearchParams(location.search).get("sentient_preview");if(o){document.getElementById(tn)||await Wn(t,o);return}if(document.getElementById(we))return;en(t);let i=jt(document);Q=i,i&&q(t,"/v1/editor/palette",i);let u=await jn(t);Kt(u,document)}Yn();return vn(Vn);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var Ue=Object.defineProperty;var Vn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames,Ot=Object.getOwnPropertySymbols;var Tt=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var Lt=(e,t,n)=>t in e?Ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Z=(e,t)=>{for(var n in t||(t={}))Tt.call(t,n)&&Lt(e,n,t[n]);if(Ot)for(var n of Ot(t))Yn.call(t,n)&&Lt(e,n,t[n]);return e};var Rt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Pt=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Xn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!Tt.call(e,o)&&o!==n&&Ue(e,o,{get:()=>t[o],enumerable:!(r=Vn(t,o))||r.enumerable});return e};var Zn=e=>Xn(Ue({},"__esModule",{value:!0}),e);var Qn,er,tr,Dt,nr,rr,Bt,L,Le,ze=Rt(()=>{"use strict";Qn=Object.defineProperty,er=Object.defineProperties,tr=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,nr=Object.prototype.hasOwnProperty,rr=Object.prototype.propertyIsEnumerable,Bt=(e,t,n)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||(t={}))nr.call(t,n)&&Bt(e,n,t[n]);if(Dt)for(var n of Dt(t))rr.call(t,n)&&Bt(e,n,t[n]);return e},Le=(e,t)=>er(e,tr(t))});var Ft={};Pt(Ft,{LOCAL_ENGINE_AVAILABLE:()=>cr,createLocalEngine:()=>ur});function ur(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var cr,Wt=Rt(()=>{"use strict";cr=!1});var bo={};Pt(bo,{applyPersonaAttributes:()=>tt,applyRegistrySlots:()=>ot,applySlotArms:()=>rt,applySlotAttributes:()=>nt,parseEditorToken:()=>zn,parsePersonaPreview:()=>Wn,parsePreview:()=>Fn,parseSnippetConfig:()=>Xe,reapply:()=>It,run:()=>Hn,version:()=>At});ze();var or=["buyer","researcher","deal_seeker","browser"];var ir={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function qe(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Mt(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function ut(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return qe(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[c,i]of Object.entries((n=e.dims)!=null?n:{}))o[c]=(r=i[0])!=null?r:"";return qe(o)}function Kt(e,t){var n,r;return e.dims!=null?(r=(n=Mt(t))!=null?n:Mt(ut(e)))!=null?r:{}:t}function ye(e){return e>=.3?e<.7?"medium":"high":"low"}var xo=or.map(e=>({key:e,displayName:ir[e]}));function Fe(e){return e?`_${e.slice(0,12)}`:""}var sr="_snt_uid";function Nt(e){return`${sr}${Fe(e)}`}var ar=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function $t(e){return lr(e)!==null}function lr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=ar.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function jt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Gt(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Ut(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function zt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function dt(e){return L(L(L({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function pt(e){let t=dt(e);return Kt(t,ut(t))}function qt(e){return typeof e=="string"?e:qe(e)}ze();function Xt(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var dr="_snt_uid",pr=365,We="_snt_uid";function fr(){return Xt()}function Ht(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function gr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function ft(e){try{return localStorage.getItem(e)}catch(t){return null}}function Vt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Jt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function mr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function hr(e){try{sessionStorage.removeItem(e)}catch(t){}}function yr(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function vr(e){try{localStorage.removeItem(e)}catch(t){}}function wr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var br={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Zt(e){var t,n,r,o,c,i,a;if(typeof window=="undefined")return br;let l=Fe(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Nt(e==null?void 0:e.apiKey),s=`${We}${l}`,d=`${We}_tomb${l}`,y=((n=e==null?void 0:e.cookieTTLDays)!=null?n:pr)*24*60*60,m=w=>w&&w.length>0?w:null,g=()=>{var w,k;return l&&!(e!=null&&e.cookieName)&&ft(d)===null?(k=(w=m(Ht(dr)))!=null?w:m(ft(We)))!=null?k:m(Jt(We)):null},p=(a=(i=(c=(o=(r=m(Ht(u)))!=null?r:m(ft(s)))!=null?o:m(Jt(s)))!=null?c:g())!=null?i:m(e==null?void 0:e.ssrSessionId))!=null?a:fr();gr(u,p,y);let A=Vt(s,p),_=yr(u),I=A?!1:mr(s,p),v=!A&&!_&&!I;return{getSessionId:()=>p,isEphemeral:()=>v,destroy:()=>{p=null,wr(u),vr(s),hr(s),l&&!(e!=null&&e.cookieName)&&Vt(d,"1")}}}function Re(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function yt(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Qt(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function xe(e,t,n){try{let r=(()=>{try{let c=localStorage.getItem(n);if(!c)return[];let i=JSON.parse(c);return Array.isArray(i)?i:[]}catch(c){return[]}})(),o=new Map;for(let c of r)o.set(c.id,c);for(let c of e)o.set(c.id,c);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function en(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),c=r.filter(i=>!o.has(i.id));if(c.length===r.length)return;c.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(c))}catch(n){}}var Sr=500,Ar=56*1024;function tn(e){return`_snt_retry_${e.slice(0,12)}`}var xr={push:()=>{},flush:()=>{},destroy:()=>{}};function Er(e){var t,n,r;if(typeof window=="undefined")return xr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,a=e.ingestUrl,l=e.apiKey,u=tn(l),s=[],d=new Set,y=[],m=f=>{for(let b of f)g.delete(b),!d.has(b)&&(d.add(b),y.push(b));for(;y.length>Sr;){let b=y.shift();b&&d.delete(b)}en(f,u)},g=new Set,p=()=>{for(;s.length>i;){let f=s.shift();f&&g.delete(f.id)}},A=f=>{d.has(f.id)||g.has(f.id)||(g.add(f.id),s.push(f),p())},_=f=>{for(let b of f)d.has(b.id)||(g.add(b.id),s.push(b));p()},I=Qt(u,i);for(let f of I)A(f);let v=0,w=0,k=(f,b=!0)=>{if(f.length===0)return;let C=JSON.stringify(f),W=f.map(me=>me.id),G;try{G=fetch(a,{method:"POST",keepalive:!0,body:C,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(me){xe(f,i,u),_(f),w++,v=Date.now()+Re(w);return}let _e=me=>{if(yt(me)!=="retry"){if(!me.ok&&b){let re=f.filter(oe=>oe.eventType!=="pageview");if(re.length>0&&re.length<f.length){m(f.filter(oe=>oe.eventType==="pageview").map(oe=>oe.id)),k(re,!1);return}}m(W),w=0,v=0;return}xe(f,i,u),_(f),w++,v=Date.now()+Re(w)};G instanceof Promise?G.then(_e).catch(()=>{xe(f,i,u),_(f),w++,v=Date.now()+Re(w)}):_e(G)},N=typeof TextEncoder!="undefined"?new TextEncoder:null,E=f=>N?N.encode(f).length:f.length,P=f=>{let b=[],C=2;for(let W of f){let G=E(JSON.stringify(W))+1;if(b.length>0&&C+G>Ar||b.length>=c)break;b.push(W),C+=G}return b},j=()=>{try{if(Date.now()<v)return;for(;s.length>0&&!(Date.now()<v);){let f=s.filter(C=>!d.has(C.id));if(s.length=0,f.length===0)break;let b=P(f);if(b.length===0)break;b.length<f.length&&s.push(...f.slice(b.length)),k(b)}}catch(f){}},O=!0,X=null;X=setInterval(()=>{O&&j()},o);let ee=()=>{document.visibilityState==="hidden"&&j()},x=()=>{j()};return document.addEventListener("visibilitychange",ee),window.addEventListener("pagehide",x),{push(f){A(f),s.length>=c&&j()},flush:j,destroy(){O=!1,X!==null&&(clearInterval(X),X=null),document.removeEventListener("visibilitychange",ee),window.removeEventListener("pagehide",x),j()}}}var kr=200;function nn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ir={send:()=>{},flush:()=>{},destroy:()=>{}};function _r(e){var t,n,r;if(typeof window=="undefined")return Ir;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,a=nn(e.apiKey),l=[],u=new Set,s=new Set,d=[],y=0,m=0,g=!1,p=E=>{for(u.delete(E.id),s.has(E.id)||(s.add(E.id),d.push(E.id));d.length>kr;){let P=d.shift();P&&s.delete(P)}en([E.id],a)},A=E=>{xe([E],c,a),!s.has(E.id)&&!u.has(E.id)&&(u.add(E.id),l.push(E)),Date.now()>=y&&(m++,y=Date.now()+Re(m))},_=E=>{let P;try{P=fetch(e.url,{method:"POST",keepalive:!0,body:E.body,headers:e.headers})}catch(O){A(E);return}let j=O=>{var X;let ee=yt(O);if(ee==="retry"){A(E);return}ee==="dropped"&&((X=e.onDrop)==null||X.call(e,E,O.status)),p(E),m=0,y=0};P instanceof Promise?P.then(j).catch(()=>A(E)):j(P)},I=()=>{try{if(g||Date.now()<y)return;let E=0;for(;l.length>0&&E<i&&!(Date.now()<y);){let P=l.shift();u.delete(P.id),!s.has(P.id)&&(E++,_(P))}}catch(E){}},v=Qt(a,c);for(let E of v)u.has(E.id)||(u.add(E.id),l.push(E));v.length>0&&xe(v,c,a);let w=setInterval(I,o),k=()=>{document.visibilityState==="hidden"&&I()},N=()=>I();return document.addEventListener("visibilitychange",k),window.addEventListener("pagehide",N),{send(E){if(!g&&!(s.has(E.id)||u.has(E.id))){if(Date.now()<y){xe([E],c,a),u.add(E.id),l.push(E);return}_(E)}},flush:I,destroy(){clearInterval(w),document.removeEventListener("visibilitychange",k),window.removeEventListener("pagehide",N),I(),g=!0}}}var Cr=1800*1e3;function He(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Or(e=Cr,t){let n=new Map,r=`_snt_asgn${Fe(t)}_`,o=(l,u)=>`${r}${encodeURIComponent(l)}:${encodeURIComponent(u)}`,c=l=>{let u=l.slice(r.length),s=u.indexOf(":");if(s<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,s)),segment:decodeURIComponent(u.slice(s+1))}}catch(d){return null}},i=()=>{try{let l=[];for(let u=0;u<localStorage.length;u++){let s=localStorage.key(u);s!=null&&s.startsWith(r)&&l.push(s)}return l}catch(l){return[]}},a=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of i())try{let u=localStorage.getItem(l);if(!u)continue;let s=JSON.parse(u);if(a(s)){localStorage.removeItem(l);continue}let d=c(l);if(!d)continue;n.set(He(d.componentId,d.segment),s)}catch(u){}})(),{get(l,u){let s=n.get(He(l,u));return s?a(s)?(n.delete(He(l,u)),null):s:null},set(l,u,s){let d=He(l,u);n.set(d,s);try{localStorage.setItem(o(l,u),JSON.stringify(s))}catch(y){}},clear(){n.clear();for(let l of i())try{localStorage.removeItem(l)}catch(u){}}}}var Ye="_snt_snap:",Lr=["low","medium","high"];function Pe(e){try{let t=localStorage.getItem(Ye+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Lr.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function De(e,t){try{localStorage.setItem(Ye+e,JSON.stringify(t))}catch(n){}}var mt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",rn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Yt=!1,Ve=!1;function Tr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Rr(e){var t;let n=Zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Tr(),c=Promise.resolve().then(()=>(Wt(),Ft)).then(s=>{let d=s;return d.LOCAL_ENGINE_AVAILABLE?(Yt||(Yt=!0,console.info(rn)),d):(Ve||(Ve=!0,console.error(mt)),null)}).catch(()=>(Ve||(Ve=!0,console.error(mt)),null)),i=null,a={low:.15,medium:.5,high:.85},l=(()=>{var s;if(e.initialPersona)return L({},e.initialPersona);let d=Pe(e.apiKey||"local");return d?{persona:d.persona,confidence:(s=a[d.band])!=null?s:.15}:null})();function u(s){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=s.persona,d.dataset.sentientConfidence=ye(s.confidence))}return{isLocal:!0,async decide(s){var d,y,m;let g=await c;if(!g)return null;let p=g.createLocalEngine({sessionId:r,forcedPersona:o}).decide(s);return i=Le(L({},p),{layoutOrder:(y=(d=p.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?y:null,slots:L(L({},(m=i==null?void 0:i.slots)!=null?m:{}),p.slots)}),De(e.apiKey||"local",{v:1,persona:i.persona,band:ye(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(p),p},getSlotResult(s){var d,y,m;return(m=(y=i==null?void 0:i.slots[s])!=null?y:(d=e.initialSlots)==null?void 0:d[s])!=null?m:null},getPersona(){let s=i!=null?i:l;return s?{persona:s.persona,confidence:s.confidence,band:ye(s.confidence)}:null},async assign(s,d){var y;let m=await c;return!m||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(y=m.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:s,variantIds:d}]}).assignments[s])!=null?y:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Be(e,t,n,r){let o=[];{let c=!1,i=[],a=()=>{if(c)return;let l=Date.now();for(i.push(l);i.length>0&&l-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",a),o.push(()=>t.removeEventListener("click",a))}{let c=!1,i=a=>{if(c||!(a.target instanceof Node)||!t.contains(a.target)&&t!==a.target)return;c=!0;let l=typeof window!="undefined"?window.getSelection():null,u=l?l.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,a=null,l=()=>{a!==null&&(clearTimeout(a),a=null)},u=()=>{c||!i||(l(),a=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},s=()=>{l(),u()},d=m=>{for(let g of m)i=g.intersectionRatio>.3,i?u():l()},y=new IntersectionObserver(d,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",s,{passive:!0}),o.push(()=>{y.disconnect(),window.removeEventListener("scroll",s),l()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),a=()=>{if(c||document.visibilityState!=="hidden")return;let l=Date.now()-i;l<15e3&&(c=!0,e("tab_loss",{timeOnPage:l}))};document.addEventListener("visibilitychange",a),o.push(()=>document.removeEventListener("visibilitychange",a))}return()=>{for(let c of o)c()}}var on="https://api.sentient-ui.com/v1/events",Q=new Map,sn=null;function Pr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Dr=3;function gt(){return Xt()}function Je(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Br(){let e=new WeakMap,t=new Map,n=!1,r=(a,l,u)=>{let s=a.get(l);return u===null?s?!0:(a.set(l,new Set),!1):s?s.has(u)?!0:(s.add(u),!1):(a.set(l,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{if(!o)return;let a=window.event;return typeof Event=="function"&&a instanceof Event?a:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let a=!1,l=()=>{a||(a=!0,n=!1,t.clear())};if(setTimeout(l,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),l()},u.port2.postMessage(0)}};return{firedBefore(a,l){let u=c();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,a,l)}let s=r(t,a,l);return!s&&!n&&(n=!0,i()),s}}}var an=new Set;function Mr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let u=Je();!u||u===c||(c=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},a=[];for(let u of["pushState","replaceState"]){let s=r[u],d=function(...y){let m=s.apply(this,y);return i(),m};r[u]=d,a.push([u,s,d])}window.addEventListener("popstate",i);let l=Je();return l&&an.has(`${t}:${l}`)?c=l:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,s,d]of a)r[u]===d&&(r[u]=s)}}}var Te={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Kr(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function ln(e){return e.replace(/\/events\/?$/,"")}function ve(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function vt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:sn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=Q.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:c,reinit:i}=r;if(!c){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&ve())return;let a=(i!=null?i:Me)(Le(L({},o),{consent:!0}));c(a);let l=(t=Q.get(n))==null?void 0:t.dispose;Q.set(n,{config:Le(L({},o),{consent:!0}),upgrade:null,dispose:l})}function Nr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=ln((t=e.ingestUrl)!=null?t:on),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(s,d,y){if(!n)return Promise.resolve(null);let m=c.get(s);return m?Promise.resolve(m):ht(i,s,async()=>{try{let g=new URLSearchParams({componentId:s});for(let _ of d!=null?d:[])g.append("variantIds[]",_);let p=await fetch(`${r}/winner?${g.toString()}`,{headers:o});if(!p.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let A={variantId:(await p.json()).variantId,assignmentTtlMs:0};return c.set(s,A),A}catch(g){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:s=>a.track(s),goal:((s,d,y,m)=>a.goal(s,d,y,m)),componentGoal:(s,d,y)=>a.componentGoal(s,d,y),identify:s=>a.identify(s),getAssignment:(s,d)=>a.getAssignment(s,d),assign:(s,d,y,m)=>a.assign(s,d,y,m),decide:s=>a.decide(s),getSlotResult:s=>a.getSlotResult(s),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function u(s){a=s}return{proxy:l,setInner:u}}function ht(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function Me(e){var t,n,r,o,c,i,a,l,u;if(typeof window=="undefined")return Te;sn=e.apiKey||"local";let s=Q.get(e.apiKey||"local");if(s!=null&&s.dispose)try{s.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&ve(),y=e.consent===!1||d,m=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!m&&e.localMode!==!1)return Q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),y?Te:Rr(e);if(y){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Q.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Te;let{proxy:h,setInner:S}=Nr(e);return Q.set(e.apiKey,{config:e,upgrade:d?null:S}),h}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Te;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Te;let g=(t=e.ingestUrl)!=null?t:on,p=Date.now(),A=Zt({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),_=Or(void 0,e.apiKey),I=Er({ingestUrl:g,apiKey:e.apiKey}),v=ln(g),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},k=new Set,N=_r({url:`${v}/goals`,apiKey:e.apiKey,headers:w,onDrop:(h,S)=>{if(!e.debug){if(k.has(S))return;k.add(S)}console.warn(`[sentient] goal dropped (HTTP ${S}) \u2014 this will not be retried. `+(S===400?"The session was not found: call init() and let the session upsert complete before firing goals.":S===401||S===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),E=jt((n=navigator.userAgent)!=null?n:""),P=window.location.origin,j=Gt((r=document.referrer)!=null?r:"",P),O=(o=e.sessionSegment)!=null?o:`${E}:${j}`,X=new Map,ee=new Map,x=new Map,f=null,b=h=>{for(let S of h)x.has(S.id)||x.set(S.id,pt(S))};if(e.initialSlots)for(let[h,S]of Object.entries(e.initialSlots))x.set(h,S);let C=Pe(e.apiKey);if(C)for(let[h,S]of Object.entries(C.slots))x.has(h)||x.set(h,S);let W={low:.15,medium:.5,high:.85};if(e.initialPersona)f=L({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?f={persona:h.sentientPersona,confidence:(i=W[(c=h.sentientConfidence)!=null?c:"low"])!=null?i:.15}:C&&(f={persona:C.persona,confidence:(a=W[C.band])!=null?a:.15})}if(e.initialAssignments)for(let[h,S]of Object.entries(e.initialAssignments))_.set(h,O,{variantId:S,assignedAt:Date.now(),segment:O,confidence:1});let G=Promise.resolve(),_e=A.getSessionId();if(_e){let h=Ut((l=document.referrer)!=null?l:""),S=L(L(L({sessionId:_e,deviceClass:E,trafficSource:j,referrerDomain:h,utmParams:Kr(),timeOfDay:zt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||$t((u=navigator.userAgent)!=null?u:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),D=async()=>{for(let z=0;;z++){try{let M=await fetch(`${v}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(S),headers:w});if(M.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(M.ok||yt(M)==="dropped")return}catch(M){}if(z>=Dr){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(M=>setTimeout(M,Re(z+1)))}};try{G=D()}catch(z){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:I});let me=Br(),re=null,oe=!1,Ae={goal(h,S={},D=1,z=0){var M,B,H,V,J,he,ce;let Ce=A.getSessionId();if(!Ce)return;let Y=Pr(S)?S:{metadata:S},Oe=[h,(M=Y.externalId)!=null?M:"",(B=Y.stepIndex)!=null?B:z,(H=Y.weight)!=null?H:D].join("\0"),T=Y.value!==void 0?`${Y.value}\0${(V=Y.currency)!=null?V:""}`:null;if(me.firedBefore(Oe,T)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let ie=gt(),Ge={sessionId:Ce,name:h,metadata:(J=Y.metadata)!=null?J:{},weight:(he=Y.weight)!=null?he:D,stepIndex:(ce=Y.stepIndex)!=null?ce:z,goalId:ie,value:Y.value,currency:Y.currency,externalId:Y.externalId};e.debug&&console.log("[sentient] goal",Ge);let q={id:ie,body:JSON.stringify(Ge)};G.then(()=>N.send(q))},componentGoal(h,S,D){var z,M,B;let H=A.getSessionId();if(!H)return;let V=_.get(h,O),J=V?null:(z=x.get(h))!=null?z:null;if(!V&&J===null){e.debug&&console.warn(`[sentient] componentGoal("${h}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let he=V?V.variantId:qt(J),ce={id:gt(),sessionId:H,projectId:e.apiKey,componentId:h,variantId:he,eventType:"goal_achieved",goalType:S,payload:L({reward:(M=D==null?void 0:D.reward)!=null?M:1,goalValue:D==null?void 0:D.value,currency:D==null?void 0:D.currency},(B=D==null?void 0:D.metadata)!=null?B:{}),timestamp:Date.now(),timeInSession:Date.now()-p,path:Je()};e.debug&&console.log("[sentient] componentGoal",ce),G.then(()=>I.push(ce))},identify(h){let S=A.getSessionId();S&&G.then(()=>{fetch(`${v}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:S,userId:h,ephemeral:A.isEphemeral()}),headers:w}).catch(()=>{})})},track(h){let S=A.getSessionId();if(!S)return;let D=Le(L({path:Je()},h),{id:gt(),sessionId:S,timestamp:Date.now(),timeInSession:Date.now()-p});e.debug&&console.log("[sentient] track",D),G.then(()=>I.push(D))},getAssignment(h,S){return _.get(h,S)},async assign(h,S,D,z){let M=A.getSessionId();if(!M)return null;let B=_.get(h,O);if(B&&(S!=null&&S.length||B.content!==void 0)){let H=B.ttlMs&&B.ttlMs>0?Math.max(0,B.assignedAt+B.ttlMs-Date.now()):0;return{variantId:B.variantId,assignmentTtlMs:H,content:B.content}}return ht(X,h,async()=>{await G;try{let H={sessionId:M,componentId:h,variantIds:S};z!==void 0?H.agentDataByVariant=z:D!==void 0&&(H.agentData=D);let V=await fetch(`${v}/assign`,{method:"POST",body:JSON.stringify(H),headers:w});if(!V.ok)return null;let J=await V.json();return _.set(h,O,L({variantId:J.variantId,assignedAt:Date.now(),segment:O,confidence:1,content:J.content},J.assignmentTtlMs&&J.assignmentTtlMs>0?{ttlMs:J.assignmentTtlMs}:{})),J}catch(H){return null}})},async decide(h){var S,D;let z=A.getSessionId();if(!z)return null;let M=(S=h.slots)!=null?S:[],B={sessionId:z};h.sections&&h.sections.length>0&&(B.sections=h.sections.map(V=>({id:V}))),B.components=(D=h.components)!=null?D:[],M.length>0&&(B.slots=M.map(dt)),h.slotsFrom==="registry"&&(B.slotsFrom="registry"),h.v&&(B.v=h.v),e.persona&&(B.persona=e.persona);let H=JSON.stringify(B);return ht(ee,H,async()=>{var V,J,he,ce,Ce,Y;await G;try{let Oe=await fetch(`${v}/decide`,{method:"POST",body:H,headers:w});if(!Oe.ok)return b(M),null;let T=await Oe.json(),ie={};for(let q of M){let ue=(V=T.slots)==null?void 0:V[q.id];if(ue!==void 0){ie[q.id]=ue,x.set(q.id,ue);continue}let _t=x.get(q.id);if(_t!==void 0)ie[q.id]=_t;else{let Ct=pt(q);ie[q.id]=Ct,x.set(q.id,Ct)}}if(T.slots)for(let[q,ue]of Object.entries(T.slots))q in ie||(ie[q]=ue,x.set(q,ue));let Ge=f!=null&&f.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&Ge)?f={persona:T.persona,confidence:(J=T.confidence)!=null?J:0}:f||(f={persona:"unknown",confidence:0});for(let[q,ue]of Object.entries((he=T.assignments)!=null?he:{}))_.set(q,O,{variantId:ue,assignedAt:Date.now(),segment:O,confidence:1});return De(e.apiKey,L(L({v:1,persona:f.persona,band:ye(f.confidence),slots:Object.fromEntries(x),layoutOrder:(ce=T.layoutOrder)!=null?ce:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.palette?{palette:T.palette}:{})),L(L(L(L({layoutOrder:(Ce=T.layoutOrder)!=null?Ce:null,assignments:(Y=T.assignments)!=null?Y:{},slots:ie,persona:f.persona,confidence:f.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{}),T.palette?{palette:T.palette}:{})}catch(Oe){return b(M),null}})},getSlotResult(h){var S;return(S=x.get(h))!=null?S:null},getPersona(){return f?{persona:f.persona,confidence:f.confidence,band:ye(f.confidence)}:null},async fetchWeights(){var h;try{let S=await fetch(`${v}/weights`,{headers:w});return S.ok?(h=(await S.json()).components)!=null?h:[]:[]}catch(S){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;re==null||re(),oe=!0,I.destroy(),N.destroy(),((h=Q.get(e.apiKey))==null?void 0:h.dispose)===Ae.dispose&&Q.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;re==null||re(),oe=!0,I.destroy(),N.destroy(),A.destroy(),_.clear(),((h=Q.get(e.apiKey))==null?void 0:h.dispose)===Ae.dispose&&Q.delete(e.apiKey);try{localStorage.removeItem(Ye+e.apiKey),localStorage.removeItem(tn(e.apiKey)),localStorage.removeItem(nn(e.apiKey))}catch(S){}e.debug&&console.log("[sentient] destroyed")}};if(Q.set(e.apiKey,{config:e,upgrade:null,dispose:Ae.dispose}),re=Mr(Ae,e.apiKey,h=>{G.then(()=>{oe||an.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=Ae)}return Ae}var cn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],$r=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],jr=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function Gr(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function un(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of $r)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of jr)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function dn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Gr(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function pn(e){return un(dn(e)).type}ze();var Ur="section, header, footer, nav, main > div, [data-sentient-section]",zr=2e4;function qr(e){let t=Array.from(e.querySelectorAll(Ur)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function Fr(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var fn=()=>{};function gn(e,t){var n,r,o,c,i,a,l,u,s;let d=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!d||typeof IntersectionObserver=="undefined"||ve()||!t.apiKey||!t.apiKey.startsWith("pk_"))return fn;let y=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),m=qr(d);if(m.length===0)return fn;let g=new Map,p=new Map,A=new Map;for(let x of m){let f=x.getAttribute("data-sentient-type"),b=f&&cn.includes(f)?f:null,C=(c=b!=null?b:(o=t.typeOf)==null?void 0:o.call(t,x))!=null?c:pn(x),W=`nc-${C}`;g.set(x,W),p.set(W,C),b?A.set(W,"markup"):A.has(W)||A.set(W,"auto")}let _=(u=(l=(a=(i=d.defaultView)!=null?i:typeof window!="undefined"?window:void 0)==null?void 0:a.location)==null?void 0:l.pathname)!=null?u:"/";Fr(t.apiKey,y,_,[...p.entries()].map(([x,f])=>{var b;return{componentId:x,semanticType:f,source:(b=A.get(x))!=null?b:"auto"}}));let I=new Map,v=x=>{let f=I.get(x);return f||(f={ms:0,scroll:0,enterAt:null,intersecting:!1},I.set(x,f)),f},w=new IntersectionObserver(x=>{for(let f of x){let b=g.get(f.target);if(!b)continue;let C=v(b);f.isIntersecting?(C.intersecting=!0,C.enterAt=Date.now(),f.intersectionRatio>C.scroll&&(C.scroll=f.intersectionRatio)):(C.intersecting=!1,C.enterAt!=null&&(C.ms+=Date.now()-C.enterAt,C.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let x of g.keys())w.observe(x);let k=()=>{let x=Date.now();for(let[f,b]of I)if(b.enterAt!=null&&(b.ms+=x-b.enterAt,b.enterAt=null),!(b.ms<=0)){try{e.track({projectId:t.apiKey,componentId:f,eventType:"dwell",payload:{dwell_time:Math.round(b.ms),scroll_depth:Number(b.scroll.toFixed(2))}})}catch(C){}b.ms=0}},N=()=>{if(d.hidden)k();else{let x=Date.now();for(let f of I.values())f.intersecting&&(f.enterAt=x)}},E=!1,P=x=>{if(k(),x!=null&&x.persisted){E=!0;return}try{w.disconnect()}catch(f){}},j=x=>{if(!(x!=null&&x.persisted)||!E)return;E=!1;let f=Date.now();for(let b of I.values())b.enterAt=b.intersecting&&!d.hidden?f:null};d.addEventListener("visibilitychange",N);let O=(s=d.defaultView)!=null?s:typeof window!="undefined"?window:void 0;O==null||O.addEventListener("pagehide",P),O==null||O.addEventListener("pageshow",j);let X=setInterval(()=>{if(d.hidden||E)return;k();let x=Date.now();for(let f of I.values())f.intersecting&&(f.enterAt=x)},zr),ee=[];return t.microSignals&&[...g.entries()].forEach(([x,f],b)=>{ee.push(Be((C,W={})=>{try{e.track({projectId:t.apiKey,componentId:f,eventType:"micro_signal",payload:L({signalType:C},W)})}catch(G){}},x,void 0,{tabLoss:b===0}))}),()=>{k(),clearInterval(X),d.removeEventListener("visibilitychange",N),O==null||O.removeEventListener("pagehide",P),O==null||O.removeEventListener("pageshow",j);for(let x of ee)x();try{w.disconnect()}catch(x){}}}var Wr=["landing","ecommerce","saas","marketplace"];function Hr(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(c=>typeof c=="string"))return null;n[r]=o}return n}function Vr(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Jr(e){try{return e()}catch(t){return}}function Xe(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=Wr.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,a]of Object.entries(t.slots)){if(typeof a!="object"||a===null)continue;let l=a,u=Hr(l.dims);if(!u||l.target!==void 0&&typeof l.target!="string")continue;let s=l.arms!==void 0?Vr(l.arms):null,d={dims:u};typeof l.target=="string"&&(d.target=l.target),s&&(d.arms=s),r[i]=d}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let c=typeof t.persona=="function"?Jr(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),Array.isArray(t.sections)){let i=t.sections.filter(a=>typeof a=="string"&&a.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function Ze(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Yr(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").trim().toLowerCase(),o=t.text.trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function mn(e,t){return!!(e!=null&&e.urlMatch)&&!Ze(t).includes(e.urlMatch)}var Xr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function de(e,t){var o;if(e.urlMatch&&!Ze(t).includes(e.urlMatch))return null;let n=[];if(e.id){let c=t.getElementById(e.id);n=c?[c]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&Xr.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(c){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Yr(r,e.fingerprint)?null:r}var hn={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Zr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function yn(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Zr.test((r=n[1])!=null?r:""))return!1;return!0}var vn=/^https:\/\//i,wn=new Map,pe=null;function Qr(e){return e.replace(/["\\]/g,"\\$&")}function eo(e){var t;(!pe||!pe.isConnected)&&(pe=e.querySelector("style[data-sentient-ops]"),pe||(pe=e.createElement("style"),pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(pe))),pe.textContent=[...wn.entries()].map(([n,r])=>`[data-snt-e="${Qr(n)}"]{${r}}`).join(`
2
- `)}function bn(e,t,n,r){var a;let o=!1,c=(a=t.moveBefore)!=null?a:t.moveAfter;if(c){let l=de(c,r);!l||l===e||l.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&vn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&vn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[l,u]of Object.entries(t.style)){let s=hn[l];s&&typeof u=="string"&&yn(u)&&i.push(`${s}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),wn.set(n,i.join(";")),eo(r)),{anchorMiss:o}}var Ke="data-sentient-block-arm",te=null;function Ne(e){te=e!=null?e:null}var ae="data-sentient-blocks-hid",Qe={none:"0",sm:"8px",md:"16px",lg:"24px"},wt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Sn={sm:"0.875em",md:"1em",lg:"1.25em"},to={sm:"1.25em",md:"1.5em",lg:"2em"},no={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},An={sm:"8px",md:"16px",lg:"32px"},ro={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},oo={normal:"400",medium:"500",bold:"700"};function se(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function xn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function En(e,t){var n,r,o,c,i,a,l,u,s,d,y,m;try{switch(e.type){case"stack":case"grid":{let g=t.createElement("div");if(e.type==="stack"){let p=e;se(g,{display:"flex","flex-direction":p.direction,gap:(r=Qe[(n=p.gap)!=null?n:"md"])!=null?r:Qe.md,"align-items":p.align?wt[p.align]:void 0,"justify-content":p.justify?wt[p.justify]:void 0,"flex-wrap":p.wrap?"wrap":void 0})}else{let p=e,A=(c=Qe[(o=p.gap)!=null?o:"md"])!=null?c:Qe.md;se(g,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${p.columns-1} * ${A}) / ${p.columns})), 1fr))`,gap:A,"align-items":p.align?wt[p.align]:void 0})}for(let p of(i=e.children)!=null?i:[]){let A=En(p,t);A&&g.appendChild(A)}return g}case"text":{let g=t.createElement("p");return g.textContent=e.value,se(g,Z({margin:"0","font-size":e.size?Sn[e.size]:void 0,"font-weight":e.weight?oo[e.weight]:void 0,"text-align":e.align},xn(e.tone)))}case"heading":{let g=t.createElement(`h${e.level}`);return g.textContent=e.value,se(g,{margin:"0","font-size":to[(a=e.size)!=null?a:"md"],"text-align":e.align})}case"button":{let g=t.createElement("a");g.textContent=e.label,g.href=e.href,e.tag&&g.setAttribute("data-sentient-tag",e.tag);let p=(l=e.emphasis)!=null?l:"primary";return se(g,{display:"inline-block",padding:no[(u=e.size)!=null?u:"md"],"border-radius":(s=te==null?void 0:te.radius)!=null?s:"8px",font:"inherit","font-size":e.size?Sn[e.size]:void 0,"text-decoration":p==="ghost"?"underline":"none",cursor:"pointer",background:p==="primary"?(d=te==null?void 0:te.primaryBg)!=null?d:"#111827":"transparent",color:p==="primary"?(y=te==null?void 0:te.primaryText)!=null?y:"#ffffff":"inherit",border:p==="secondary"?"1px solid currentColor":"none"})}case"link":{let g=t.createElement("a");return g.textContent=e.label,g.href=e.href,e.tag&&g.setAttribute("data-sentient-tag",e.tag),se(g,{color:"inherit","text-decoration":"underline"})}case"image":{let g=t.createElement("img");return g.src=e.src,g.alt=e.alt,se(g,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?ro[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let g=t.createElement("span");return g.textContent=e.value,se(g,Z({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},xn(e.tone)))}case"spacer":return se(t.createElement("div"),{height:(m=An[e.size])!=null?m:An.md});default:return null}}catch(g){return null}}function kn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let a=i.getAttribute(Ke);a!==null&&(t[a]===void 0?i.remove():o.add(a))}for(let[i,a]of Object.entries(t)){if(o.has(i))continue;let l=En(a,r);if(!l)continue;let u=r.createElement("div");u.setAttribute(Ke,i),u.style.display="none",u.appendChild(l),e.appendChild(u)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let a=i.getAttribute(Ke),l=i;a!==null?l.style.display=c&&a===n?"":"none":c?l.hasAttribute(ae)||(l.setAttribute(ae,l.style.display),l.style.display="none"):l.hasAttribute(ae)&&(l.style.display=l.getAttribute(ae),l.removeAttribute(ae))}}catch(o){}}function io(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ke)!==null){n.remove();continue}n.hasAttribute(ae)&&(n.style.display=n.getAttribute(ae),n.removeAttribute(ae))}}catch(t){}}function et(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ke}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ae}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||io(r)}catch(n){}}function bt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function tt(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function nt(e,t,n){var r;for(let[o,c]of Object.entries(t)){let i=e[o];if(!i||typeof i=="string")continue;let a=bt(c.target,n);for(let l of a)for(let[u,s]of Object.entries(i))(r=c.dims[u])!=null&&r.includes(s)&&l.setAttribute(`data-${u}`,s)}}function rt(e,t,n){for(let[r,o]of Object.entries(t)){let c=e[r];if(typeof c!="string"||!o.arms||!o.arms.includes(c))continue;let i=bt(o.target,n);for(let a of i)a.setAttribute("data-sentient-arm",c)}}function ot(e,t,n,r){var a,l;let o=new Set,c=(a=r==null?void 0:r.contentAndOps)!=null?a:!0,i=[];for(let[u,s]of Object.entries(t)){if(mn(s.locator,n))continue;let d;if(s.locator){let m=de(s.locator,n);d=m?[m]:[]}else d=bt(s.target,n);(s.locator||s.target)&&d.length===0&&i.push(u);let y=e[u];for(let m of d){if(y!==void 0)if(typeof y=="string")m.setAttribute("data-sentient-arm",y),c&&((l=r==null?void 0:r.onApplied)==null||l.call(r,u,y,m));else for(let[g,p]of Object.entries(y))m.setAttribute(`data-${g}`,p);s.blocks&&!ao(n)&&(kn(m,s.blocks,typeof y=="string"?y:void 0,n),o.add(m)),c&&(typeof s.content=="string"&&(m.textContent=s.content),s.ops&&bn(m,s.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u))}}return et(n,o),i}var so=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function ao(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:so.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var lo=800;function it(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},a)=>{r.push(Be((y,m={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:Z({signalType:y},m)})}catch(g){}},i,void 0,{tabLoss:a===0}));let l=null,u=0,s=()=>{u=Date.now(),l=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(y){}l=null},lo)},d=()=>{l!==null&&(clearTimeout(l),l=null)};i.addEventListener("mouseenter",s),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",s),i.removeEventListener("mouseleave",d),l!==null&&clearTimeout(l)})}),()=>{for(let o of r)o()}}function co(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function _n(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var uo="_snt_fired_goals";function Cn(e,t){try{e==null||e.sessionStorage.removeItem(_n(t)),e==null||e.sessionStorage.removeItem(uo)}catch(n){}}function In(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function po(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function fo(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function st(e,t,n,r){var _,I;let o=(_=n.defaultView)!=null?_:typeof window!="undefined"?window:null,c=_n(r),i=po(o,c),a=v=>{let w=In(v);if(!i.has(w))try{v.slotId?t.componentGoal(v.slotId,v.goalId):t.goal(v.goalId),i.add(w),fo(o,c,i)}catch(k){}},l=e.filter(v=>v.event==="click"),u=e.filter(v=>v.event==="form_submit"),s=e.filter(v=>v.event==="url_reached"),d=e.filter(v=>v.event==="scroll_depth"),y=(v,w)=>{if(!v.locator)return!1;let k=de(v.locator,n);return!!k&&(k===w||k.contains(w))},m=v=>{let w=v.target;if(!(!w||typeof w.closest!="function"))for(let k of l)y(k,w)&&a(k)},g=v=>{let w=v.target;if(w)for(let k of u)y(k,w)&&a(k)},p=()=>{if(s.length===0)return;let v=Ze(n);for(let w of s)w.urlPattern&&co(w.urlPattern,v)&&a(w)},A=()=>{var k;let v=n.documentElement,w=v.scrollHeight>0?(v.scrollTop+v.clientHeight)/v.scrollHeight:0;for(let N of d)w>=((k=N.threshold)!=null?k:.75)&&a(N);d.every(N=>i.has(In(N)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",m,!0),n.addEventListener("submit",g,!0),(I=n.defaultView)==null||I.addEventListener("popstate",p),p(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:p,teardown:()=>{var v;n.removeEventListener("click",m,!0),n.removeEventListener("submit",g,!0),(v=n.defaultView)==null||v.removeEventListener("popstate",p),d.length>0&&n.removeEventListener("scroll",A)}}}var On="__snt_editor_token";function Ln(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(On):null}catch(e){return null}}function Tn(e){try{sessionStorage.setItem(On,e)}catch(t){}}var At="0.18.0",$n=5e3,go=50,jn=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),F=null,R=null,le={},ge=null,$=null,fe=null,U=null,ne=null,K=null,we=null,Rn=!1,St=null,at=null,ct=null,Ee=!1,$e=!1,Se=!1;function Gn(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function be(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function ke(e,t){return F?(F.personaAttributes&&K&&tt(K.persona,K.band,e),nt(le,F.slots,e),rt(le,F.slots,e),ge?ot(le,ge,e,t):(et(e,new Set),[])):[]}function Un(e){var n;let t=new Map;for(let r of(n=F==null?void 0:F.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function xt(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Un(t);if(n.size!==e.length)return;let r=[];for(let i of e){let a=n.get(i);if(!a)return;r.push(a)}let o=r[0].parentNode;if(!o||!r.every(i=>i.parentNode===o))return;let c=r.slice().sort((i,a)=>i.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let i=0;i<r.length;i++){let a=r[i];c[i]!==a&&(o.insertBefore(a,c[i]),c.splice(c.indexOf(a),1),c.splice(i,0,a))}}catch(n){}}function mo(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ie(){return!!(F&&R&&F.sectionCapture!==!1&&(F.consent!==!1||$e)&&!ve())}function ho(){if(!R||!F||!Ie()||ne)return;let e=[];ke(document,{contentAndOps:Ee,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),kt();try{U==null||U(),U=it(R,F.apiKey,e)}catch(t){}}function kt(){if(typeof document=="undefined"||!Ie())return;let e;try{if(at&&at.length>0){let t=new Map;for(let n of at){if(n.urlMatch!==window.location.pathname)continue;let r=de(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ne=gn(R,Z({apiKey:F.apiKey,apiBase:F.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),ct=window.location.pathname}catch(t){}}function It(){try{let e=[];if(U==null||U(),U=null,ke(document,{contentAndOps:Ee,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),xt(we,document),e.length>0&&Ie())try{U=it(R,F.apiKey,e)}catch(t){}try{typeof window!="undefined"&&ct!==null&&window.location.pathname!==ct&&Ie()&&(ne==null||ne(),ne=null,kt())}catch(t){}}catch(e){}}function Pn(){St===null&&(St=setTimeout(()=>{St=null,It();try{$==null||$.checkUrl()}catch(e){}},go))}function Et(){if(!(Rn||typeof window=="undefined"||typeof history=="undefined")){Rn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,c){let i=n.call(this,r,o,c!=null?c:null);return Pn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Pn)}catch(e){}}}function lt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function zn(e){return new URLSearchParams(e).get("sentient_editor")}function yo(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function vo(e,t){var n,r,o,c;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let l=document.createElement("meta");l.name="referrer",l.content="no-referrer",l.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(l)}catch(l){}let i=(o=e.editorSrc)!=null?o:yo();if(!i){Bn();return}let a=document.createElement("script");a.src=i,a.async=!0,a.onerror=()=>Bn(),((c=document.head)!=null?c:document.documentElement).appendChild(a)}catch(i){}}var Dn="sentient-editor-load-notice",qn={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Bn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Dn))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Dn,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,qn,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function Fn(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),c=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!c||!i))if(i.includes("=")){let a={};for(let l of i.split(",")){let[u,s]=l.split("=");u&&s&&(a[u]=s)}Object.keys(a).length&&(n[c]=a)}else n[c]=i}return Object.keys(n).length?n:null}function Wn(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Mn="sentient-persona-preview-banner";function Kn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Mn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Mn,o.setAttribute("role","status"),Object.assign(o.style,qn,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let c=document.createElement("span");c.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let a=new URL(window.location.href);a.searchParams.delete("sentient_persona"),window.location.href=a.pathname+a.search+a.hash}catch(a){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function wo(e,t){var u,s,d,y,m,g,p,A,_,I;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((s=e.registry)!=null?s:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([v,w])=>({id:v,dims:w.dims}))},c=await Gn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(v=>v.ok?v.json():null).catch(()=>null),$n);if(!c){je(e),be(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;le=(d=i.slots)!=null?d:{},ge=(y=i.slotConfig)!=null?y:null,Ne(i.palette);let a=(p=(g=(m=i.personaAttributes)==null?void 0:m.persona)!=null?g:i.persona)!=null?p:t,l=(_=(A=i.personaAttributes)==null?void 0:A.confidence)!=null?_:"high";K={persona:a,band:l},ke(document),Ee=!0,Et(),je(e),i.recognized===!1?Kn(t,!0):Kn((I=i.personaDisplay)!=null?I:a)}function je(e){let t={goal(n,r){try{R==null||R.goal(n,r)}catch(o){}},componentGoal(n,r){try{R==null||R.componentGoal(n,r)}catch(o){}},grantConsent(){try{!R&&Se?(R=Me({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona}),fe&&fe.length>0&&($==null||$.teardown(),$=st(fe,R,document,e.apiKey))):(vt(e.apiKey),R&&fe&&fe.length>0&&($==null||$.teardown(),$=st(fe,R,document,e.apiKey))),Se=!1}catch(n){}$e=!0;try{ho()}catch(n){}},revokeConsent(){try{ne==null||ne(),ne=null,ct=null,U==null||U(),U=null,$==null||$.teardown(),$=null,Cn(typeof window!="undefined"?window:null,e.apiKey),$e=!1,Se=!0,R==null||R.destroy(),R=null}catch(n){}},reapply:It,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=K==null?void 0:K.persona)!=null?n:null,band:(r=K==null?void 0:K.band)!=null?r:null,slots:le,matchCounts:lt(e),consent:!Se&&(e.consent!==!1||$e)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of jn.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Nn(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},jn.length=0}catch(t){}}async function Hn(){var e;try{let t=Xe(window.sentient);if(!t){Nn();return}F=t,Ee=!1,we=null,Ne(null),$e=!1,Se=!1,fe=null;let n=typeof window!="undefined"?zn(window.location.search):null;if(n){Tn(n);try{let p=new URL(window.location.href);p.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",p.pathname+p.search+p.hash)}catch(p){}}let r=n!=null?n:Ln();if(r){vo(t,r),je(t),be(t,"editor mode");return}let o=typeof window!="undefined"?Fn(window.location.search):null;if(o){le=o,K=null,ke(document),Et(),je(t),be(t,"preview mode",o);return}let c=typeof window!="undefined"?Wn(window.location.search):null;if(c){await wo(t,c),be(t,"persona preview",c);return}let i=(e=t.registry)!=null?e:Object.keys(t.slots).length===0,a=Pe(t.apiKey);a&&(K={persona:a.persona,band:a.band},le=a.slots,a.slotConfig&&(ge=a.slotConfig),a.palette&&Ne(a.palette),ke(document,{contentAndOps:!1}),a.layoutOrder&&(we=a.layoutOrder,xt(we,document)));let l=Me({apiKey:t.apiKey,context:t.context,consent:t.consent,preConsentBehavior:t.preConsentBehavior,debug:t.debug,persona:t.persona});R=l,je(t),Et();let u=Object.entries(t.slots).map(([p,A])=>({id:p,dims:A.dims})),s=At!=="0.0.0-dev"?{v:At}:{},d=Array.from(Un(document).keys()),y=l.decide(Z(Z(Z({slots:u},s),d.length>=2?{sections:d}:{}),i?{slotsFrom:"registry"}:{})),m=await Gn(y,$n),g=p=>{var I,v,w,k,N,E;let A=l.getPersona();A?K={persona:A.persona,band:A.band}:p.persona&&(K={persona:p.persona,band:"low"}),le=p.slots,i?ge=(I=p.slotConfig)!=null?I:null:p.slotConfig&&(ge=p.slotConfig),p.palette&&Ne(p.palette),we=(v=p.layoutOrder)!=null?v:we;let _=()=>{let P=[];if(mo(t,ke(document,{onApplied:(j,O,X)=>P.push({slotId:j,arm:O,el:X})})),xt(we,document),Ee=!0,Ie())try{U==null||U(),U=it(R,t.apiKey,P)}catch(j){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_,{once:!0}):_(),fe=(w=p.goals)!=null?w:null,p.goals&&p.goals.length>0&&t.consent!==!1&&R)try{$==null||$.teardown(),$=st(p.goals,R,document,t.apiKey)}catch(P){}at=(k=p.sectionMap)!=null?k:null,Ie()&&kt(),be(t,"applied",{persona:K,slots:le,matches:lt(t)}),!Se&&De(t.apiKey,Z(Z({v:1,persona:(N=K==null?void 0:K.persona)!=null?N:p.persona,band:(E=K==null?void 0:K.band)!=null?E:"low",slots:p.slots,layoutOrder:p.layoutOrder,savedAt:Date.now()},ge?{slotConfig:ge}:{}),p.palette?{palette:p.palette}:{}))};if(!m){be(t,"decide timeout/null \u2014 snapshot state stands",lt(t)),y.then(p=>{!p||Ee||Se||R!==l||(g(p),be(t,"late decide applied",lt(t)))}).catch(()=>{});return}g(m)}catch(t){Nn()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Hn())}return Zn(bo);})();
1
+ "use strict";var SentientSnippet=(()=>{var qe=Object.defineProperty;var rr=Object.getOwnPropertyDescriptor;var or=Object.getOwnPropertyNames,Rt=Object.getOwnPropertySymbols;var Dt=Object.prototype.hasOwnProperty,ir=Object.prototype.propertyIsEnumerable;var Pt=(e,t,n)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ne=(e,t)=>{for(var n in t||(t={}))Dt.call(t,n)&&Pt(e,n,t[n]);if(Rt)for(var n of Rt(t))ir.call(t,n)&&Pt(e,n,t[n]);return e};var Mt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Bt=(e,t)=>{for(var n in t)qe(e,n,{get:t[n],enumerable:!0})},sr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of or(t))!Dt.call(e,o)&&o!==n&&qe(e,o,{get:()=>t[o],enumerable:!(r=rr(t,o))||r.enumerable});return e};var ar=e=>sr(qe({},"__esModule",{value:!0}),e);var lr,cr,ur,Nt,dr,fr,$t,_,be,Te=Mt(()=>{"use strict";lr=Object.defineProperty,cr=Object.defineProperties,ur=Object.getOwnPropertyDescriptors,Nt=Object.getOwnPropertySymbols,dr=Object.prototype.hasOwnProperty,fr=Object.prototype.propertyIsEnumerable,$t=(e,t,n)=>t in e?lr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_=(e,t)=>{for(var n in t||(t={}))dr.call(t,n)&&$t(e,n,t[n]);if(Nt)for(var n of Nt(t))fr.call(t,n)&&$t(e,n,t[n]);return e},be=(e,t)=>cr(e,ur(t))});var Yt={};Bt(Yt,{LOCAL_ENGINE_AVAILABLE:()=>br,createLocalEngine:()=>wr});function wr(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var br,Xt=Mt(()=>{"use strict";br=!1});var Do={};Bt(Do,{applyPersonaAttributes:()=>nt,applyRegistrySlots:()=>it,applySlotArms:()=>ot,applySlotAttributes:()=>rt,parseEditorToken:()=>Zn,parsePersonaPreview:()=>tr,parsePreview:()=>er,parseSnippetConfig:()=>Ze,reapply:()=>Ot,run:()=>nr,version:()=>Et});Te();var pr=["buyer","researcher","deal_seeker","browser"];var gr={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Fe(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Kt(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function dt(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return Fe(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[l,i]of Object.entries((n=e.dims)!=null?n:{}))o[l]=(r=i[0])!=null?r:"";return Fe(o)}function jt(e,t){var n,r;return e.dims!=null?(r=(n=Kt(t))!=null?n:Kt(dt(e)))!=null?r:{}:t}function Gt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t}function we(e){return e>=.3?e<.7?"medium":"high":"low"}var No=pr.map(e=>({key:e,displayName:gr[e]}));function We(e){return e?`_${e.slice(0,12)}`:""}var mr="_snt_uid";function Ut(e){return`${mr}${We(e)}`}var hr=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function zt(e){return yr(e)!==null}function yr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=hr.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function qt(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Ft(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Wt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var vr=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function Ht(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,l])=>{let i=Array.isArray(l)?l[0]:l;return i===void 0?[]:[[o,i]]});for(let[o,l]of r)o.startsWith("utm_")?o in t||(t[o]=l):vr.includes(o)&&(o in n||(n[o]=l))}catch(r){}return{utmParams:t,clickIds:n}}function Jt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function ft(e){return _(_(_({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function pt(e){let t=ft(e);return jt(t,dt(t))}function Vt(e){return typeof e=="string"?e:Fe(e)}Te();function nn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Sr="_snt_uid",Ar=365,He="_snt_uid";function xr(){return nn()}function Zt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function kr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function gt(e){try{return localStorage.getItem(e)}catch(t){return null}}function Qt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function en(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Er(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Cr(e){try{sessionStorage.removeItem(e)}catch(t){}}function _r(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 Ir(e){try{localStorage.removeItem(e)}catch(t){}}function Or(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Lr={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function rn(e){var t,n,r,o,l,i,s;if(typeof window=="undefined")return Lr;let c=We(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Ut(e==null?void 0:e.apiKey),a=`${He}${c}`,d=`${He}_tomb${c}`,g=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Ar)*24*60*60,m=w=>w&&w.length>0?w:null,p=()=>{var w,I;return c&&!(e!=null&&e.cookieName)&&gt(d)===null?(I=(w=m(Zt(Sr)))!=null?w:m(gt(He)))!=null?I:m(en(He)):null},f=(s=(i=(l=(o=(r=m(Zt(u)))!=null?r:m(gt(a)))!=null?o:m(en(a)))!=null?l:p())!=null?i:m(e==null?void 0:e.ssrSessionId))!=null?s:xr();kr(u,f,g);let A=Qt(a,f),C=_r(u),L=A?!1:Er(a,f),y=!A&&!C&&!L;return{getSessionId:()=>f,isEphemeral:()=>y,destroy:()=>{f=null,Or(u),Ir(a),Cr(a),c&&!(e!=null&&e.cookieName)&&Qt(d,"1")}}}function Pe(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function vt(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function on(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function Ee(e,t,n){try{let r=(()=>{try{let l=localStorage.getItem(n);if(!l)return[];let i=JSON.parse(l);return Array.isArray(i)?i:[]}catch(l){return[]}})(),o=new Map;for(let l of r)o.set(l.id,l);for(let l of e)o.set(l.id,l);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function sn(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),l=r.filter(i=>!o.has(i.id));if(l.length===r.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var Tr=500,Rr=56*1024;function an(e){return`_snt_retry_${e.slice(0,12)}`}var Pr={push:()=>{},flush:()=>{},destroy:()=>{}};function Dr(e){var t,n,r;if(typeof window=="undefined")return Pr;let o=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,c=e.apiKey,u=an(c),a=[],d=new Set,g=[],m=v=>{for(let b of v)p.delete(b),!d.has(b)&&(d.add(b),g.push(b));for(;g.length>Tr;){let b=g.shift();b&&d.delete(b)}sn(v,u)},p=new Set,f=()=>{for(;a.length>i;){let v=a.shift();v&&p.delete(v.id)}},A=v=>{d.has(v.id)||p.has(v.id)||(p.add(v.id),a.push(v),f())},C=v=>{for(let b of v)d.has(b.id)||(p.add(b.id),a.push(b));f()},L=on(u,i);for(let v of L)A(v);let y=0,w=0,I=(v,b=!0)=>{if(v.length===0)return;let k=JSON.stringify(v),O=v.map(J=>J.id),E;try{E=fetch(s,{method:"POST",keepalive:!0,body:k,headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`}})}catch(J){Ee(v,i,u),C(v),w++,y=Date.now()+Pe(w);return}let oe=J=>{if(vt(J)!=="retry"){if(!J.ok&&b){let ee=v.filter(te=>te.eventType!=="pageview");if(ee.length>0&&ee.length<v.length){m(v.filter(te=>te.eventType==="pageview").map(te=>te.id)),I(ee,!1);return}}m(O),w=0,y=0;return}Ee(v,i,u),C(v),w++,y=Date.now()+Pe(w)};E instanceof Promise?E.then(oe).catch(()=>{Ee(v,i,u),C(v),w++,y=Date.now()+Pe(w)}):oe(E)},N=typeof TextEncoder!="undefined"?new TextEncoder:null,x=v=>N?N.encode(v).length:v.length,D=v=>{let b=[],k=2;for(let O of v){let E=x(JSON.stringify(O))+1;if(b.length>0&&k+E>Rr||b.length>=l)break;b.push(O),k+=E}return b},K=()=>{try{if(Date.now()<y)return;for(;a.length>0&&!(Date.now()<y);){let v=a.filter(k=>!d.has(k.id));if(a.length=0,v.length===0)break;let b=D(v);if(b.length===0)break;b.length<v.length&&a.push(...v.slice(b.length)),I(b)}}catch(v){}},j=!0,Z=null;Z=setInterval(()=>{j&&K()},o);let q=()=>{document.visibilityState==="hidden"&&K()},U=()=>{K()};return document.addEventListener("visibilitychange",q),window.addEventListener("pagehide",U),{push(v){A(v),a.length>=l&&K()},flush:K,destroy(){j=!1,Z!==null&&(clearInterval(Z),Z=null),document.removeEventListener("visibilitychange",q),window.removeEventListener("pagehide",U),K()}}}var Mr=200;function ln(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Br={send:()=>{},flush:()=>{},destroy:()=>{}};function Nr(e){var t,n,r;if(typeof window=="undefined")return Br;let o=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=ln(e.apiKey),c=[],u=new Set,a=new Set,d=[],g=0,m=0,p=!1,f=x=>{for(u.delete(x.id),a.has(x.id)||(a.add(x.id),d.push(x.id));d.length>Mr;){let D=d.shift();D&&a.delete(D)}sn([x.id],s)},A=x=>{Ee([x],l,s),!a.has(x.id)&&!u.has(x.id)&&(u.add(x.id),c.push(x)),Date.now()>=g&&(m++,g=Date.now()+Pe(m))},C=x=>{let D;try{D=fetch(e.url,{method:"POST",keepalive:!0,body:x.body,headers:e.headers})}catch(j){A(x);return}let K=j=>{var Z;let q=vt(j);if(q==="retry"){A(x);return}q==="dropped"&&((Z=e.onDrop)==null||Z.call(e,x,j.status)),f(x),m=0,g=0};D instanceof Promise?D.then(K).catch(()=>A(x)):K(D)},L=()=>{try{if(p||Date.now()<g)return;let x=0;for(;c.length>0&&x<i&&!(Date.now()<g);){let D=c.shift();u.delete(D.id),!a.has(D.id)&&(x++,C(D))}}catch(x){}},y=on(s,l);for(let x of y)u.has(x.id)||(u.add(x.id),c.push(x));y.length>0&&Ee(y,l,s);let w=setInterval(L,o),I=()=>{document.visibilityState==="hidden"&&L()},N=()=>L();return document.addEventListener("visibilitychange",I),window.addEventListener("pagehide",N),{send(x){if(!p&&!(a.has(x.id)||u.has(x.id))){if(Date.now()<g){Ee([x],l,s),u.add(x.id),c.push(x);return}C(x)}},flush:L,destroy(){clearInterval(w),document.removeEventListener("visibilitychange",I),window.removeEventListener("pagehide",N),L(),p=!0}}}var $r=1800*1e3;function Je(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Kr(e=$r,t){let n=new Map,r=`_snt_asgn${We(t)}_`,o=(c,u)=>`${r}${encodeURIComponent(c)}:${encodeURIComponent(u)}`,l=c=>{let u=c.slice(r.length),a=u.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,a)),segment:decodeURIComponent(u.slice(a+1))}}catch(d){return null}},i=()=>{try{let c=[];for(let u=0;u<localStorage.length;u++){let a=localStorage.key(u);a!=null&&a.startsWith(r)&&c.push(a)}return c}catch(c){return[]}},s=c=>c.assignedAt+(c.ttlMs&&c.ttlMs>0?c.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let c of i())try{let u=localStorage.getItem(c);if(!u)continue;let a=JSON.parse(u);if(s(a)){localStorage.removeItem(c);continue}let d=l(c);if(!d)continue;n.set(Je(d.componentId,d.segment),a)}catch(u){}})(),{get(c,u){let a=n.get(Je(c,u));return a?s(a)?(n.delete(Je(c,u)),null):a:null},set(c,u,a){let d=Je(c,u);n.set(d,a);try{localStorage.setItem(o(c,u),JSON.stringify(a))}catch(g){}},clear(){n.clear();for(let c of i())try{localStorage.removeItem(c)}catch(u){}}}}var Xe="_snt_snap:",jr=["low","medium","high"];function De(e){try{let t=localStorage.getItem(Xe+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!jr.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function Me(e,t){try{localStorage.setItem(Xe+e,JSON.stringify(t))}catch(n){}}var ht="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",cn="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",tn=!1,Ve=!1;function Gr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Ur(e){var t;let n=rn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Gr(),l=Promise.resolve().then(()=>(Xt(),Yt)).then(a=>{let d=a;return d.LOCAL_ENGINE_AVAILABLE?(tn||(tn=!0,console.info(cn)),d):(Ve||(Ve=!0,console.error(ht)),null)}).catch(()=>(Ve||(Ve=!0,console.error(ht)),null)),i=null,s={low:.15,medium:.5,high:.85},c=(()=>{var a;if(e.initialPersona)return _({},e.initialPersona);let d=De(e.apiKey||"local");return d?{persona:d.persona,confidence:(a=s[d.band])!=null?a:.15}:null})();function u(a){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=a.persona,d.dataset.sentientConfidence=we(a.confidence))}return{isLocal:!0,async decide(a){var d,g,m;let p=await l;if(!p)return null;let f=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide(a);return i=be(_({},f),{layoutOrder:(g=(d=f.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?g:null,slots:_(_({},(m=i==null?void 0:i.slots)!=null?m:{}),f.slots)}),Me(e.apiKey||"local",{v:1,persona:i.persona,band:we(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(f),f},getSlotResult(a){var d,g,m;return(m=(g=i==null?void 0:i.slots[a])!=null?g:(d=e.initialSlots)==null?void 0:d[a])!=null?m:null},getPersona(){let a=i!=null?i:c;return a?{persona:a.persona,confidence:a.confidence,band:we(a.confidence)}:null},async assign(a,d){var g;let m=await l;return!m||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(g=m.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:a,variantIds:d}]}).assignments[a])!=null?g:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Be(e,t,n,r){let o=[];{let l=!1,i=[],s=()=>{if(l)return;let c=Date.now();for(i.push(c);i.length>0&&c-i[0]>500;)i.shift();i.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let l=!1,i=s=>{if(l||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;l=!0;let c=typeof window!="undefined"?window.getSelection():null,u=c?c.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let l=!1,i=!1,s=null,c=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{l||!i||(c(),s=setTimeout(()=>{!l&&i&&(l=!0,e("scroll_hesitation"))},3e3))},a=()=>{c(),u()},d=m=>{for(let p of m)i=p.intersectionRatio>.3,i?u():c()},g=new IntersectionObserver(d,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",a,{passive:!0}),o.push(()=>{g.disconnect(),window.removeEventListener("scroll",a),c()})}if((r==null?void 0:r.tabLoss)!==!1){let l=!1,i=n!=null?n:Date.now(),s=()=>{if(l||document.visibilityState!=="hidden")return;let c=Date.now()-i;c<15e3&&(l=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let l of o)l()}}var un="https://api.sentient-ui.com/v1/events",re=new Map,dn=null;function zr(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var qr=3;function mt(){return nn()}function Ye(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Fr(){let e=new WeakMap,t=new Map,n=!1,r=(s,c,u)=>{let a=s.get(c);return u===null?a?!0:(s.set(c,new Set),!1):a?a.has(u)?!0:(a.add(u),!1):(s.set(c,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,l=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,c=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(c,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),c()},u.port2.postMessage(0)}};return{firedBefore(s,c){let u=l();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,c)}let a=r(t,s,c);return!a&&!n&&(n=!0,i()),a}}}var fn=new Set;function Wr(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,l,i=()=>{if(o)return;let u=Ye();!u||u===l||(l=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},s=[];for(let u of["pushState","replaceState"]){let a=r[u],d=function(...g){let m=a.apply(this,g);return i(),m};r[u]=d,s.push([u,a,d])}window.addEventListener("popstate",i);let c=Ye();return c&&fn.has(`${t}:${c}`)?l=c:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,a,d]of s)r[u]===d&&(r[u]=a)}}}var Re={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Hr(){try{return Ht(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function pn(e){return e.replace(/\/events\/?$/,"")}function Se(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function bt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:dn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=re.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:l,reinit:i}=r;if(!l){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Se())return;let s=(i!=null?i:Ne)(be(_({},o),{consent:!0}));l(s);let c=(t=re.get(n))==null?void 0:t.dispose;re.set(n,{config:be(_({},o),{consent:!0}),upgrade:null,dispose:c})}function Jr(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=pn((t=e.ingestUrl)!=null?t:un),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},l=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(a,d,g){if(!n)return Promise.resolve(null);let m=l.get(a);return m?Promise.resolve(m):yt(i,a,async()=>{try{let p=new URLSearchParams({componentId:a});for(let C of d!=null?d:[])p.append("variantIds[]",C);let f=await fetch(`${r}/winner?${p.toString()}`,{headers:o});if(!f.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let A={variantId:(await f.json()).variantId,assignmentTtlMs:0};return l.set(a,A),A}catch(p){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},c={track:a=>s.track(a),goal:((a,d,g,m)=>s.goal(a,d,g,m)),componentGoal:(a,d,g)=>s.componentGoal(a,d,g),identify:a=>s.identify(a),getAssignment:(a,d)=>s.getAssignment(a,d),assign:(a,d,g,m)=>s.assign(a,d,g,m),decide:a=>s.decide(a),getSlotResult:a=>s.getSlotResult(a),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function u(a){s=a}return{proxy:c,setInner:u}}function yt(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function Ne(e){var t,n,r,o,l,i,s,c,u;if(typeof window=="undefined")return Re;dn=e.apiKey||"local";let a=re.get(e.apiKey||"local");if(a!=null&&a.dispose)try{a.dispose()}catch(h){}let d=e.respectDoNotTrack!==!1&&Se(),g=e.consent===!1||d,m=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!m&&e.localMode!==!1)return re.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),g?Re:Ur(e);if(g){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),re.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),Re;let{proxy:h,setInner:S}=Jr(e);return re.set(e.apiKey,{config:e,upgrade:d?null:S}),h}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Re;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Re;let p=(t=e.ingestUrl)!=null?t:un,f=Date.now(),A=rn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),C=Kr(void 0,e.apiKey),L=Dr({ingestUrl:p,apiKey:e.apiKey}),y=pn(p),w={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},I=new Set,N=Nr({url:`${y}/goals`,apiKey:e.apiKey,headers:w,onDrop:(h,S)=>{if(!e.debug){if(I.has(S))return;I.add(S)}console.warn(`[sentient] goal dropped (HTTP ${S}) \u2014 this will not be retried. `+(S===400?"The session was not found: call init() and let the session upsert complete before firing goals.":S===401||S===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),h)}}),x=qt((n=navigator.userAgent)!=null?n:""),D=window.location.origin,K=Ft((r=document.referrer)!=null?r:"",D),j=(o=e.sessionSegment)!=null?o:`${x}:${K}`,Z=new Map,q=new Map,U=new Map,v=null,b=h=>{for(let S of h)U.has(S.id)||U.set(S.id,pt(S))};if(e.initialSlots)for(let[h,S]of Object.entries(e.initialSlots))U.set(h,S);let k=De(e.apiKey);if(k)for(let[h,S]of Object.entries(k.slots))U.has(h)||U.set(h,S);let O={low:.15,medium:.5,high:.85};if(e.initialPersona)v=_({},e.initialPersona);else{let h=document.documentElement.dataset;h.sentientPersona?v={persona:h.sentientPersona,confidence:(i=O[(l=h.sentientConfidence)!=null?l:"low"])!=null?i:.15}:k&&(v={persona:k.persona,confidence:(s=O[k.band])!=null?s:.15})}if(e.initialAssignments)for(let[h,S]of Object.entries(e.initialAssignments))C.set(h,j,{variantId:S,assignedAt:Date.now(),segment:j,confidence:1});let E=Promise.resolve(),oe=A.getSessionId();if(oe){let h=Wt((c=document.referrer)!=null?c:""),{utmParams:S,clickIds:M}=Hr(),Q=_(_(_({sessionId:oe,deviceClass:x,trafficSource:K,referrerDomain:h,utmParams:S,clickIds:M,timeOfDay:Jt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||zt((u=navigator.userAgent)!=null?u:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),F=async()=>{for(let T=0;;T++){try{let B=await fetch(`${y}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(Q),headers:w});if(B.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(B.ok||vt(B)==="dropped")return}catch(B){}if(T>=qr){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(B=>setTimeout(B,Pe(T+1)))}};try{E=F()}catch(T){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:L});let J=Fr(),ee=null,te=!1,ie={goal(h,S={},M=1,Q=0){var F,T,B,V,Y,ve,fe;let Oe=A.getSessionId();if(!Oe)return;let X=zr(S)?S:{metadata:S},Le=[h,(F=X.externalId)!=null?F:"",(T=X.stepIndex)!=null?T:Q,(B=X.weight)!=null?B:M].join("\0"),R=X.value!==void 0?`${X.value}\0${(V=X.currency)!=null?V:""}`:null;if(J.firedBefore(Le,R)){e.debug&&console.log(`[sentient] goal("${h}") already recorded for this action \u2014 not sent twice`);return}let le=mt(),ze={sessionId:Oe,name:h,metadata:(Y=X.metadata)!=null?Y:{},weight:(ve=X.weight)!=null?ve:M,stepIndex:(fe=X.stepIndex)!=null?fe:Q,goalId:le,value:X.value,currency:X.currency,externalId:X.externalId};e.debug&&console.log("[sentient] goal",ze);let W={id:le,body:JSON.stringify(ze)};E.then(()=>N.send(W))},componentGoal(h,S,M){var Q,F,T;let B=A.getSessionId();if(!B)return;let V=C.get(h,j),Y=V?null:(Q=U.get(h))!=null?Q:null;if(!V&&Y===null){e.debug&&console.warn(`[sentient] componentGoal("${h}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let ve=V?V.variantId:Vt(Y),fe={id:mt(),sessionId:B,projectId:e.apiKey,componentId:h,variantId:ve,eventType:"goal_achieved",goalType:S,payload:_({reward:(F=M==null?void 0:M.reward)!=null?F:1,goalValue:M==null?void 0:M.value,currency:M==null?void 0:M.currency},(T=M==null?void 0:M.metadata)!=null?T:{}),timestamp:Date.now(),timeInSession:Date.now()-f,path:Ye()};e.debug&&console.log("[sentient] componentGoal",fe),E.then(()=>L.push(fe))},identify(h){let S=A.getSessionId();S&&E.then(()=>{fetch(`${y}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:S,userId:h,ephemeral:A.isEphemeral()}),headers:w}).catch(()=>{})})},track(h){let S=A.getSessionId();if(!S)return;let M=be(_({path:Ye()},h),{id:mt(),sessionId:S,timestamp:Date.now(),timeInSession:Date.now()-f});e.debug&&console.log("[sentient] track",M),E.then(()=>L.push(M))},getAssignment(h,S){return C.get(h,S)},async assign(h,S,M,Q){let F=A.getSessionId();if(!F)return null;let T=C.get(h,j);if(T&&(S!=null&&S.length||T.content!==void 0)){let B=T.ttlMs&&T.ttlMs>0?Math.max(0,T.assignedAt+T.ttlMs-Date.now()):0;return{variantId:T.variantId,assignmentTtlMs:B,content:T.content}}return yt(Z,h,async()=>{await E;try{let B={sessionId:F,componentId:h,variantIds:S};Q!==void 0?B.agentDataByVariant=Q:M!==void 0&&(B.agentData=M);let V=await fetch(`${y}/assign`,{method:"POST",body:JSON.stringify(B),headers:w});if(!V.ok)return null;let Y=await V.json();return C.set(h,j,_({variantId:Y.variantId,assignedAt:Date.now(),segment:j,confidence:1,content:Y.content},Y.assignmentTtlMs&&Y.assignmentTtlMs>0?{ttlMs:Y.assignmentTtlMs}:{})),Y}catch(B){return null}})},async decide(h){var S,M;let Q=A.getSessionId();if(!Q)return null;let F=(S=h.slots)!=null?S:[],T={sessionId:Q};h.sections&&h.sections.length>0&&(T.sections=h.sections.map(V=>({id:V}))),T.components=(M=h.components)!=null?M:[],F.length>0&&(T.slots=F.map(ft)),h.slotsFrom==="registry"&&(T.slotsFrom="registry"),h.v&&(T.v=h.v),e.persona&&(T.persona=e.persona);let B=JSON.stringify(T);return yt(q,B,async()=>{var V,Y,ve,fe,Oe,X;await E;try{let Le=await fetch(`${y}/decide`,{method:"POST",body:B,headers:w});if(!Le.ok)return b(F),null;let R=await Le.json(),le={};for(let W of F){let pe=(V=R.slots)==null?void 0:V[W.id];if(pe!==void 0){le[W.id]=pe,U.set(W.id,pe);continue}let Lt=U.get(W.id);if(Lt!==void 0)le[W.id]=Lt;else{let Tt=pt(W);le[W.id]=Tt,U.set(W.id,Tt)}}if(R.slots)for(let[W,pe]of Object.entries(R.slots))W in le||(le[W]=pe,U.set(W,pe));let ze=v!=null&&v.persona!=="unknown";R.persona&&!(R.persona==="unknown"&&ze)?v={persona:R.persona,confidence:(Y=R.confidence)!=null?Y:0}:v||(v={persona:"unknown",confidence:0});for(let[W,pe]of Object.entries((ve=R.assignments)!=null?ve:{}))C.set(W,j,{variantId:pe,assignedAt:Date.now(),segment:j,confidence:1});return Me(e.apiKey,_(_({v:1,persona:v.persona,band:we(v.confidence),slots:Object.fromEntries(U),layoutOrder:(fe=R.layoutOrder)!=null?fe:null,savedAt:Date.now()},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.palette?{palette:R.palette}:{})),_(_(_(_({layoutOrder:(Oe=R.layoutOrder)!=null?Oe:null,assignments:(X=R.assignments)!=null?X:{},slots:le,persona:v.persona,confidence:v.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{}),R.sectionMap?{sectionMap:R.sectionMap}:{}),R.palette?{palette:R.palette}:{})}catch(Le){return b(F),null}})},getSlotResult(h){var S;return(S=U.get(h))!=null?S:null},getPersona(){return v?{persona:v.persona,confidence:v.confidence,band:we(v.confidence)}:null},async fetchWeights(){var h;try{let S=await fetch(`${y}/weights`,{headers:w});return S.ok?(h=(await S.json()).components)!=null?h:[]:[]}catch(S){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var h;ee==null||ee(),te=!0,L.destroy(),N.destroy(),((h=re.get(e.apiKey))==null?void 0:h.dispose)===ie.dispose&&re.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var h;ee==null||ee(),te=!0,L.destroy(),N.destroy(),A.destroy(),C.clear(),((h=re.get(e.apiKey))==null?void 0:h.dispose)===ie.dispose&&re.delete(e.apiKey);try{localStorage.removeItem(Xe+e.apiKey),localStorage.removeItem(an(e.apiKey)),localStorage.removeItem(ln(e.apiKey))}catch(S){}e.debug&&console.log("[sentient] destroyed")}};if(re.set(e.apiKey,{config:e,upgrade:null,dispose:ie.dispose}),ee=Wr(ie,e.apiKey,h=>{E.then(()=>{te||fn.add(h)})}),e.debug){let h=window;h.__sentient&&(h.__sentient.client=ie)}return ie}var Vr=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function wt(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function Yr(e){return{tag:e.tagName.toLowerCase(),text:wt(e).slice(0,40)}}function gn(e){return e.replace(/["\\\]]/g,"\\$&")}function $e(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function mn(e,t){var n;let r=e.tagName.toLowerCase();if(!r)return null;let o=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),l=[r,...o.map(s=>`${r}.${s}`)];for(let s of l)if($e(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=mn(i,t);if(s){for(let d of l){let g=`${s} > ${d}`;if($e(t,g))return g}let c=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=c.indexOf(e),a=c.some(d=>d!==e&&wt(d)!==wt(e));if(u>=0&&a){let d=`${s} > ${r}:nth-of-type(${u+1})`;if($e(t,d))return d}}}return null}function hn(e,t){let n=Yr(e),r=e.getAttribute("id");if(r&&$e(t,`#${gn(r)}`))return{v:1,id:r,fingerprint:n};for(let l of Vr){let i=e.getAttribute(l);if(i&&$e(t,`[${l}="${gn(i)}"]`))return{v:1,dataAttr:{name:l,value:i},fingerprint:n}}let o=mn(e,t);return o?{v:1,selector:o,fingerprint:n}:null}Te();var vn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Xr={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Zr(e){let t=e.ariaRole?Xr[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function Qr(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var eo=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],St=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],yn={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function to(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function bn(e){var t,n;let r=Zr(e);if(r)return{type:(t=yn[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of eo)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of St)if(s.test(e.bodyText))return{type:i,strength:"strong"};let l=Qr(e);return{type:(n=yn[l])!=null?n:"generic",strength:"weak"}}function wn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return _({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:to(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}Te();var no="section, header, footer, nav, main > div, [data-sentient-section]",ro=2e4;function oo(e){let t=Array.from(e.querySelectorAll(no)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function io(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var Sn=()=>{};function An(e,t){var n,r,o,l,i,s,c,u,a,d,g,m;let p=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!p||typeof IntersectionObserver=="undefined"||Se()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Sn;let f=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),A=oo(p);if(A.length===0)return Sn;let C=new Map,L=[];for(let b of A){let k=b.getAttribute("data-sentient-type"),O=k&&vn.includes(k)?k:null,E=wn(b),oe=(l=O!=null?O:(o=t.typeOf)==null?void 0:o.call(t,b))!=null?l:bn(E).type,J=hn(b,p),ee=J?`nc-${oe}-${Gt(JSON.stringify({id:(i=J.id)!=null?i:null,dataAttr:(s=J.dataAttr)!=null?s:null,selector:(c=J.selector)!=null?c:null})).toString(36)}`:`nc-${oe}`;C.set(b,ee);let te=St.filter(([,ie])=>ie.test(E.bodyText)).map(([ie])=>ie);L.push(be(_({componentId:ee,semanticType:oe,source:O?"markup":"auto"},J?{locator:J}:{}),{observation:_(_({tag:E.tag,idClass:E.idClass.slice(0,200),headingText:E.headingText,textLength:E.textLength,actionCount:E.actionCount},E.ariaRole?{ariaRole:E.ariaRole}:{}),te.length>0?{patternFlags:te}:{})}))}let y=(g=(d=(a=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0)==null?void 0:a.location)==null?void 0:d.pathname)!=null?g:"/";io(t.apiKey,f,y,L);let w=new Map,I=b=>{let k=w.get(b);return k||(k={ms:0,scroll:0,enterAt:null,intersecting:!1},w.set(b,k)),k},N=new IntersectionObserver(b=>{for(let k of b){let O=C.get(k.target);if(!O)continue;let E=I(O);k.isIntersecting?(E.intersecting=!0,E.enterAt=Date.now(),k.intersectionRatio>E.scroll&&(E.scroll=k.intersectionRatio)):(E.intersecting=!1,E.enterAt!=null&&(E.ms+=Date.now()-E.enterAt,E.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let b of C.keys())N.observe(b);let x=()=>{let b=Date.now();for(let[k,O]of w)if(O.enterAt!=null&&(O.ms+=b-O.enterAt,O.enterAt=null),!(O.ms<=0)){try{e.track({projectId:t.apiKey,componentId:k,eventType:"dwell",payload:{dwell_time:Math.round(O.ms),scroll_depth:Number(O.scroll.toFixed(2))}})}catch(E){}O.ms=0}},D=()=>{if(p.hidden)x();else{let b=Date.now();for(let k of w.values())k.intersecting&&(k.enterAt=b)}},K=!1,j=b=>{if(x(),b!=null&&b.persisted){K=!0;return}try{N.disconnect()}catch(k){}},Z=b=>{if(!(b!=null&&b.persisted)||!K)return;K=!1;let k=Date.now();for(let O of w.values())O.enterAt=O.intersecting&&!p.hidden?k:null};p.addEventListener("visibilitychange",D);let q=(m=p.defaultView)!=null?m:typeof window!="undefined"?window:void 0;q==null||q.addEventListener("pagehide",j),q==null||q.addEventListener("pageshow",Z);let U=setInterval(()=>{if(p.hidden||K)return;x();let b=Date.now();for(let k of w.values())k.intersecting&&(k.enterAt=b)},ro),v=[];return t.microSignals&&[...C.entries()].forEach(([b,k],O)=>{v.push(Be((E,oe={})=>{try{e.track({projectId:t.apiKey,componentId:k,eventType:"micro_signal",payload:_({signalType:E},oe)})}catch(J){}},b,void 0,{tabLoss:O===0}))}),()=>{x(),clearInterval(U),p.removeEventListener("visibilitychange",D),q==null||q.removeEventListener("pagehide",j),q==null||q.removeEventListener("pageshow",Z);for(let b of v)b();try{N.disconnect()}catch(b){}}}var so=["landing","ecommerce","saas","marketplace"];function ao(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(l=>typeof l=="string"))return null;n[r]=o}return n}function lo(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function co(e){try{return e()}catch(t){return}}function Ze(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n=so.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let c=s,u=ao(c.dims);if(!u||c.target!==void 0&&typeof c.target!="string")continue;let a=c.arms!==void 0?lo(c.arms):null,d={dims:u};typeof c.target=="string"&&(d.target=c.target),a&&(d.arms=a),r[i]=d}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture);let l=typeof t.persona=="function"?co(t.persona):t.persona;if(typeof l=="string"&&l.trim()!==""&&(o.persona=l),Array.isArray(t.sections)){let i=t.sections.filter(s=>typeof s=="string"&&s.trim()!=="").slice(0,50);i.length>=2&&(o.sections=i)}return o}function Qe(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function uo(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:"").replace(/\s+/g," ").trim().toLowerCase(),o=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function xn(e,t){return!!(e!=null&&e.urlMatch)&&!Qe(t).includes(e.urlMatch)}var fo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ge(e,t){var o;if(e.urlMatch&&!Qe(t).includes(e.urlMatch))return null;let n=[];if(e.id){let l=t.getElementById(e.id);n=l?[l]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name)&&fo.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&&!uo(r,e.fingerprint)?null:r}var kn={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},po=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function En(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!po.test((r=n[1])!=null?r:""))return!1;return!0}var Cn=/^https:\/\//i,_n=new Map,me=null;function go(e){return e.replace(/["\\]/g,"\\$&")}function mo(e){var t;(!me||!me.isConnected)&&(me=e.querySelector("style[data-sentient-ops]"),me||(me=e.createElement("style"),me.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(me))),me.textContent=[..._n.entries()].map(([n,r])=>`[data-snt-e="${go(n)}"]{${r}}`).join(`
2
+ `)}function In(e,t,n,r){var s;let o=!1,l=(s=t.moveBefore)!=null?s:t.moveAfter;if(l){let c=ge(l,r);!c||c===e||c.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,c):e.parentElement.insertBefore(e,c.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Cn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Cn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[c,u]of Object.entries(t.style)){let a=kn[c];a&&typeof u=="string"&&En(u)&&i.push(`${a}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),_n.set(n,i.join(";")),mo(r)),{anchorMiss:o}}var Ke="data-sentient-block-arm",se=null;function je(e){se=e!=null?e:null}var ue="data-sentient-blocks-hid",et={none:"0",sm:"8px",md:"16px",lg:"24px"},At={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},On={sm:"0.875em",md:"1em",lg:"1.25em"},ho={sm:"1.25em",md:"1.5em",lg:"2em"},yo={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ln={sm:"8px",md:"16px",lg:"32px"},vo={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},bo={normal:"400",medium:"500",bold:"700"};function ce(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function Tn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function Rn(e,t){var n,r,o,l,i,s,c,u,a,d,g,m;try{switch(e.type){case"stack":case"grid":{let p=t.createElement("div");if(e.type==="stack"){let f=e;ce(p,{display:"flex","flex-direction":f.direction,gap:(r=et[(n=f.gap)!=null?n:"md"])!=null?r:et.md,"align-items":f.align?At[f.align]:void 0,"justify-content":f.justify?At[f.justify]:void 0,"flex-wrap":f.wrap?"wrap":void 0})}else{let f=e,A=(l=et[(o=f.gap)!=null?o:"md"])!=null?l:et.md;ce(p,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${f.columns-1} * ${A}) / ${f.columns})), 1fr))`,gap:A,"align-items":f.align?At[f.align]:void 0})}for(let f of(i=e.children)!=null?i:[]){let A=Rn(f,t);A&&p.appendChild(A)}return p}case"text":{let p=t.createElement("p");return p.textContent=e.value,ce(p,ne({margin:"0","font-size":e.size?On[e.size]:void 0,"font-weight":e.weight?bo[e.weight]:void 0,"text-align":e.align},Tn(e.tone)))}case"heading":{let p=t.createElement(`h${e.level}`);return p.textContent=e.value,ce(p,{margin:"0","font-size":ho[(s=e.size)!=null?s:"md"],"text-align":e.align})}case"button":{let p=t.createElement("a");p.textContent=e.label,p.href=e.href,e.tag&&p.setAttribute("data-sentient-tag",e.tag);let f=(c=e.emphasis)!=null?c:"primary";return ce(p,{display:"inline-block",padding:yo[(u=e.size)!=null?u:"md"],"border-radius":(a=se==null?void 0:se.radius)!=null?a:"8px",font:"inherit","font-size":e.size?On[e.size]:void 0,"text-decoration":f==="ghost"?"underline":"none",cursor:"pointer",background:f==="primary"?(d=se==null?void 0:se.primaryBg)!=null?d:"#111827":"transparent",color:f==="primary"?(g=se==null?void 0:se.primaryText)!=null?g:"#ffffff":"inherit",border:f==="secondary"?"1px solid currentColor":"none"})}case"link":{let p=t.createElement("a");return p.textContent=e.label,p.href=e.href,e.tag&&p.setAttribute("data-sentient-tag",e.tag),ce(p,{color:"inherit","text-decoration":"underline"})}case"image":{let p=t.createElement("img");return p.src=e.src,p.alt=e.alt,ce(p,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?vo[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let p=t.createElement("span");return p.textContent=e.value,ce(p,ne({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},Tn(e.tone)))}case"spacer":return ce(t.createElement("div"),{height:(m=Ln[e.size])!=null?m:Ln.md});default:return null}}catch(p){return null}}function Pn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(Ke);s!==null&&(t[s]===void 0?i.remove():o.add(s))}for(let[i,s]of Object.entries(t)){if(o.has(i))continue;let c=Rn(s,r);if(!c)continue;let u=r.createElement("div");u.setAttribute(Ke,i),u.style.display="none",u.appendChild(c),e.appendChild(u)}let l=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(Ke),c=i;s!==null?c.style.display=l&&s===n?"":"none":l?c.hasAttribute(ue)||(c.setAttribute(ue,c.style.display),c.style.display="none"):c.hasAttribute(ue)&&(c.style.display=c.getAttribute(ue),c.removeAttribute(ue))}}catch(o){}}function wo(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ke)!==null){n.remove();continue}n.hasAttribute(ue)&&(n.style.display=n.getAttribute(ue),n.removeAttribute(ue))}}catch(t){}}function tt(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ke}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ue}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||wo(r)}catch(n){}}function xt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function nt(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function rt(e,t,n){var r;for(let[o,l]of Object.entries(t)){let i=e[o];if(!i||typeof i=="string")continue;let s=xt(l.target,n);for(let c of s)for(let[u,a]of Object.entries(i))(r=l.dims[u])!=null&&r.includes(a)&&c.setAttribute(`data-${u}`,a)}}function ot(e,t,n){for(let[r,o]of Object.entries(t)){let l=e[r];if(typeof l!="string"||!o.arms||!o.arms.includes(l))continue;let i=xt(o.target,n);for(let s of i)s.setAttribute("data-sentient-arm",l)}}function it(e,t,n,r){var s,c;let o=new Set,l=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[u,a]of Object.entries(t)){if(xn(a.locator,n))continue;let d;if(a.locator){let m=ge(a.locator,n);d=m?[m]:[]}else d=xt(a.target,n);(a.locator||a.target)&&d.length===0&&i.push(u);let g=e[u];for(let m of d){if(g!==void 0)if(typeof g=="string")m.setAttribute("data-sentient-arm",g),l&&((c=r==null?void 0:r.onApplied)==null||c.call(r,u,g,m));else for(let[p,f]of Object.entries(g))m.setAttribute(`data-${p}`,f);a.blocks&&!Ao(n)&&(Pn(m,a.blocks,typeof g=="string"?g:void 0,n),o.add(m)),l&&(typeof a.content=="string"&&(m.textContent=a.content),a.ops&&In(m,a.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u))}}return tt(n,o),i}var So=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Ao(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:So.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var xo=800;function st(e,t,n){let r=[];return n.forEach(({slotId:o,arm:l,el:i},s)=>{r.push(Be((g,m={})=>{try{e.track({projectId:t,componentId:o,variantId:l,eventType:"micro_signal",payload:ne({signalType:g},m)})}catch(p){}},i,void 0,{tabLoss:s===0}));let c=null,u=0,a=()=>{u=Date.now(),c=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:l,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(g){}c=null},xo)},d=()=>{c!==null&&(clearTimeout(c),c=null)};i.addEventListener("mouseenter",a),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",a),i.removeEventListener("mouseleave",d),c!==null&&clearTimeout(c)})}),()=>{for(let o of r)o()}}function ko(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function Mn(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var Eo="_snt_fired_goals";function Bn(e,t){try{e==null||e.sessionStorage.removeItem(Mn(t)),e==null||e.sessionStorage.removeItem(Eo)}catch(n){}}function Dn(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Co(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function _o(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function at(e,t,n,r){var C,L;let o=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,l=Mn(r),i=Co(o,l),s=y=>{let w=Dn(y);if(!i.has(w))try{y.slotId?t.componentGoal(y.slotId,y.goalId):t.goal(y.goalId),i.add(w),_o(o,l,i)}catch(I){}},c=e.filter(y=>y.event==="click"),u=e.filter(y=>y.event==="form_submit"),a=e.filter(y=>y.event==="url_reached"),d=e.filter(y=>y.event==="scroll_depth"),g=(y,w)=>{if(!y.locator)return!1;let I=ge(y.locator,n);return!!I&&(I===w||I.contains(w))},m=y=>{let w=y.target;if(!(!w||typeof w.closest!="function"))for(let I of c)g(I,w)&&s(I)},p=y=>{let w=y.target;if(w)for(let I of u)g(I,w)&&s(I)},f=()=>{if(a.length===0)return;let y=Qe(n);for(let w of a)w.urlPattern&&ko(w.urlPattern,y)&&s(w)},A=()=>{var I;let y=n.documentElement,w=y.scrollHeight>0?(y.scrollTop+y.clientHeight)/y.scrollHeight:0;for(let N of d)w>=((I=N.threshold)!=null?I:.75)&&s(N);d.every(N=>i.has(Dn(N)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",m,!0),n.addEventListener("submit",p,!0),(L=n.defaultView)==null||L.addEventListener("popstate",f),f(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:f,teardown:()=>{var y;n.removeEventListener("click",m,!0),n.removeEventListener("submit",p,!0),(y=n.defaultView)==null||y.removeEventListener("popstate",f),d.length>0&&n.removeEventListener("scroll",A)}}}var Nn="__snt_editor_token";function $n(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Nn):null}catch(e){return null}}function Kn(e){try{sessionStorage.setItem(Nn,e)}catch(t){}}var Et="0.20.0",Hn=5e3,Io=50,Jn=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),H=null,P=null,de={},ye=null,G=null,he=null,z=null,ae=null,$=null,Ae=null,jn=!1,kt=null,lt=null,ut=null,Ce=!1,Ge=!1,ke=!1;function Vn(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function xe(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function _e(e,t){return H?(H.personaAttributes&&$&&nt($.persona,$.band,e),rt(de,H.slots,e),ot(de,H.slots,e),ye?it(de,ye,e,t):(tt(e,new Set),[])):[]}function Yn(e){var n;let t=new Map;for(let r of(n=H==null?void 0:H.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function Ct(e,t){try{if(!e||e.length<2||new Set(e).size!==e.length)return;let n=Yn(t);if(n.size!==e.length)return;let r=[];for(let i of e){let s=n.get(i);if(!s)return;r.push(s)}let o=r[0].parentNode;if(!o||!r.every(i=>i.parentNode===o))return;let l=r.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let i=0;i<r.length;i++){let s=r[i];l[i]!==s&&(o.insertBefore(s,l[i]),l.splice(l.indexOf(s),1),l.splice(i,0,s))}}catch(n){}}function Xn(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function Oo(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Ie(){return!!(H&&P&&H.sectionCapture!==!1&&(H.consent!==!1||Ge)&&!Se())}function Lo(){if(!P||!H||!Ie()||ae)return;let e=[];_e(document,{contentAndOps:Ce,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),It();try{z==null||z(),z=st(P,H.apiKey,e)}catch(t){}}function It(){if(typeof document=="undefined"||!Ie())return;let e;try{if(lt&&lt.length>0){let t=new Map;for(let n of lt){if(n.urlMatch!==window.location.pathname)continue;let r=ge(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{ae=An(P,ne({apiKey:H.apiKey,apiBase:H.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),ut=window.location.pathname}catch(t){}}function Ot(){try{let e=[];if(z==null||z(),z=null,_e(document,{contentAndOps:Ce,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Ct(Ae,document),e.length>0&&Ie())try{z=st(P,H.apiKey,e)}catch(t){}try{typeof window!="undefined"&&ut!==null&&window.location.pathname!==ut&&Ie()&&(ae==null||ae(),ae=null,It())}catch(t){}}catch(e){}}function Gn(){kt===null&&(kt=setTimeout(()=>{kt=null,Ot();try{G==null||G.checkUrl()}catch(e){}},Io))}function _t(){if(!(jn||typeof window=="undefined"||typeof history=="undefined")){jn=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,l){let i=n.call(this,r,o,l!=null?l:null);return Gn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Gn)}catch(e){}}}function ct(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function Zn(e){return new URLSearchParams(e).get("sentient_editor")}function To(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function Ro(e,t){var n,r,o,l;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let c=document.createElement("meta");c.name="referrer",c.content="no-referrer",c.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(c)}catch(c){}let i=(o=e.editorSrc)!=null?o:To();if(!i){zn();return}let s=document.createElement("script");s.src=i,s.async=!0,s.onerror=()=>zn(),((l=document.head)!=null?l:document.documentElement).appendChild(s)}catch(i){}}var Un="sentient-editor-load-notice",Qn={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function zn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Un))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Un,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,Qn,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function er(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),l=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!l||!i))if(i.includes("=")){let s={};for(let c of i.split(",")){let[u,a]=c.split("=");u&&a&&(s[u]=a)}Object.keys(s).length&&(n[l]=s)}else n[l]=i}return Object.keys(n).length?n:null}function tr(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var qn="sentient-persona-preview-banner";function Fn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(qn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=qn,o.setAttribute("role","status"),Object.assign(o.style,Qn,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let l=document.createElement("span");l.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(l),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Po(e,t){var u,a,d,g,m,p,f,A,C,L;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((a=e.registry)!=null?a:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([y,w])=>({id:y,dims:w.dims}))},l=await Vn(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(y=>y.ok?y.json():null).catch(()=>null),Hn);if(!l){Ue(e),xe(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=l;de=(d=i.slots)!=null?d:{},ye=(g=i.slotConfig)!=null?g:null,je(i.palette);let s=(f=(p=(m=i.personaAttributes)==null?void 0:m.persona)!=null?p:i.persona)!=null?f:t,c=(C=(A=i.personaAttributes)==null?void 0:A.confidence)!=null?C:"high";$={persona:s,band:c},_e(document),Ce=!0,_t(),Ue(e),i.recognized===!1?Fn(t,!0):Fn((L=i.personaDisplay)!=null?L:s)}function Ue(e){let t={goal(n,r){try{P==null||P.goal(n,r)}catch(o){}},componentGoal(n,r){try{P==null||P.componentGoal(n,r)}catch(o){}},grantConsent(){try{!P&&ke?(P=Ne({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:Xn(e)}),he&&he.length>0&&(G==null||G.teardown(),G=at(he,P,document,e.apiKey))):(bt(e.apiKey),P&&he&&he.length>0&&(G==null||G.teardown(),G=at(he,P,document,e.apiKey))),ke=!1}catch(n){}Ge=!0;try{Lo()}catch(n){}},revokeConsent(){try{ae==null||ae(),ae=null,ut=null,z==null||z(),z=null,G==null||G.teardown(),G=null,Bn(typeof window!="undefined"?window:null,e.apiKey),Ge=!1,ke=!0,P==null||P.destroy(),P=null}catch(n){}},reapply:Ot,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=$==null?void 0:$.persona)!=null?n:null,band:(r=$==null?void 0:$.band)!=null?r:null,slots:de,matchCounts:ct(e),consent:!ke&&(e.consent!==!1||Ge)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of Jn.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Wn(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},Jn.length=0}catch(t){}}async function nr(){var e;try{let t=Ze(window.sentient);if(!t){Wn();return}H=t,Ce=!1,Ae=null,je(null),Ge=!1,ke=!1,he=null;let n=typeof window!="undefined"?Zn(window.location.search):null;if(n){Kn(n);try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}}let r=n!=null?n:$n();if(r){Ro(t,r),Ue(t),xe(t,"editor mode");return}let o=typeof window!="undefined"?er(window.location.search):null;if(o){de=o,$=null,_e(document),_t(),Ue(t),xe(t,"preview mode",o);return}let l=typeof window!="undefined"?tr(window.location.search):null;if(l){await Po(t,l),xe(t,"persona preview",l);return}let i=(e=t.registry)!=null?e:Object.keys(t.slots).length===0,s=De(t.apiKey);s&&($={persona:s.persona,band:s.band},de=s.slots,s.slotConfig&&(ye=s.slotConfig),s.palette&&je(s.palette),_e(document,{contentAndOps:!1}),s.layoutOrder&&(Ae=s.layoutOrder,Ct(Ae,document)));let c=Ne({apiKey:t.apiKey,context:t.context,consent:t.consent,preConsentBehavior:t.preConsentBehavior,debug:t.debug,persona:t.persona,ingestUrl:Xn(t)});P=c,Ue(t),_t();let u=Object.entries(t.slots).map(([f,A])=>({id:f,dims:A.dims})),a=Et!=="0.0.0-dev"?{v:Et}:{},d=Array.from(Yn(document).keys()),g=c.decide(ne(ne(ne({slots:u},a),d.length>=2?{sections:d}:{}),i?{slotsFrom:"registry"}:{})),m=await Vn(g,Hn),p=f=>{var L,y,w,I,N,x;let A=c.getPersona();A?$={persona:A.persona,band:A.band}:f.persona&&($={persona:f.persona,band:"low"}),de=f.slots,i?ye=(L=f.slotConfig)!=null?L:null:f.slotConfig&&(ye=f.slotConfig),f.palette&&je(f.palette),Ae=(y=f.layoutOrder)!=null?y:Ae;let C=()=>{let D=[];if(Oo(t,_e(document,{onApplied:(K,j,Z)=>D.push({slotId:K,arm:j,el:Z})})),Ct(Ae,document),Ce=!0,Ie())try{z==null||z(),z=st(P,t.apiKey,D)}catch(K){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C,{once:!0}):C(),he=(w=f.goals)!=null?w:null,f.goals&&f.goals.length>0&&t.consent!==!1&&P)try{G==null||G.teardown(),G=at(f.goals,P,document,t.apiKey)}catch(D){}lt=(I=f.sectionMap)!=null?I:null,Ie()&&It(),xe(t,"applied",{persona:$,slots:de,matches:ct(t)}),!ke&&Me(t.apiKey,ne(ne({v:1,persona:(N=$==null?void 0:$.persona)!=null?N:f.persona,band:(x=$==null?void 0:$.band)!=null?x:"low",slots:f.slots,layoutOrder:f.layoutOrder,savedAt:Date.now()},ye?{slotConfig:ye}:{}),f.palette?{palette:f.palette}:{}))};if(!m){xe(t,"decide timeout/null \u2014 snapshot state stands",ct(t)),g.then(f=>{!f||Ce||ke||P!==c||(p(f),xe(t,"late decide applied",ct(t)))}).catch(()=>{});return}p(m)}catch(t){Wn()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,queueMicrotask(()=>{nr()}))}return ar(Do);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.18.0",
3
+ "version": "0.20.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.22.0"
27
+ "@sentientui/core": "0.25.0"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "tsup",