@sentientui/snippet 0.24.1 → 0.26.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 at=Object.defineProperty,Fn=Object.defineProperties,jn=Object.getOwnPropertyDescriptor,qn=Object.getOwnPropertyDescriptors,Un=Object.getOwnPropertyNames,ln=Object.getOwnPropertySymbols;var cn=Object.prototype.hasOwnProperty,Gn=Object.prototype.propertyIsEnumerable;var dn=(n,t,r)=>t in n?at(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,A=(n,t)=>{for(var r in t||(t={}))cn.call(t,r)&&dn(n,r,t[r]);if(ln)for(var r of ln(t))Gn.call(t,r)&&dn(n,r,t[r]);return n},U=(n,t)=>Fn(n,qn(t));var Wn=(n,t)=>{for(var r in t)at(n,r,{get:t[r],enumerable:!0})},Yn=(n,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of Un(t))!cn.call(n,u)&&u!==r&&at(n,u,{get:()=>t[u],enumerable:!(i=jn(t,u))||i.enumerable});return n};var Vn=n=>Yn(at({},"__esModule",{value:!0}),n);var To={};Wn(To,{buildStyleOps:()=>Ht,clearTargetHighlights:()=>Fe,computeMoveAnchors:()=>mt,deriveSlotId:()=>Ke,drawTargetHighlights:()=>En,isHex6:()=>yt,mount:()=>Cn,registerAuditTargets:()=>wn,sectionTypesFor:()=>Sn,styleFieldError:()=>Tn,toHexColor:()=>gt});function Jn(n){var r,i,u;let t=(i=(r=n.defaultView)!=null?r:typeof window!="undefined"?window:void 0)==null?void 0:i.location;return(u=t==null?void 0:t.pathname)!=null?u:""}function Kn(n,t){var r;if(t.tag&&n.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let i=((r=n.textContent)!=null?r:"").replace(/\s+/g," ").trim().toLowerCase(),u=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(i===u||i.startsWith(u)||u.startsWith(i)))return!1}return!0}var Xn=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function he(n,t){var u;if(n.urlMatch&&!Jn(t).includes(n.urlMatch))return null;let r=[];if(n.id){let p=t.getElementById(n.id);r=p?[p]:[]}if(r.length===0&&((u=n.dataAttr)!=null&&u.name)&&Xn.test(n.dataAttr.name))try{let p=n.dataAttr.value.replace(/["\\]/g,"\\$&");r=Array.from(t.querySelectorAll(`[${n.dataAttr.name}="${p}"]`))}catch(p){r=[]}if(r.length===0&&n.selector)try{r=Array.from(t.querySelectorAll(n.selector))}catch(p){r=[]}if(r.length!==1)return null;let i=r[0];return n.fingerprint&&!Kn(i,n.fingerprint)?null:i}function un(n){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(n);let r="";for(let i=0;i<n.length;i++){let u=n[i],p=u>="0"&&u<="9";i===0&&p||i===1&&p&&n[0]==="-"?r+=`\\3${u} `:i===0&&u==="-"&&n.length===1?r+="\\-":/[a-zA-Z0-9_-]/.test(u)?r+=u:r+=`\\${u}`}return r}function Zn(n,t){if(n.id)return`#${un(n.id)}`;let r=[],i=n,u=0;for(;i&&i!==t.body&&i!==t.documentElement&&u<6;){if(i.id){r.unshift(`#${un(i.id)}`);break}let p=i.tagName.toLowerCase(),k=i.parentElement;if(k){let $=Array.from(k.children).filter(L=>L.tagName===i.tagName);$.length>1&&(p+=`:nth-of-type(${$.indexOf(i)+1})`)}r.unshift(p),i=i.parentElement,u++}return r.join(" > ")}function Ne(n,t){var u;let r={v:1};n.id&&(r.id=n.id);for(let p of["data-framer-name","data-w-id","data-sentient-name"]){let k=n.getAttribute(p);if(k){r.dataAttr={name:p,value:k};break}}r.selector=Zn(n,t);let i=((u=n.textContent)!=null?u:"").trim().replace(/\s+/g," ").slice(0,80);return r.fingerprint=A({tag:n.tagName.toLowerCase()},i?{text:i}:{}),r}function Ve(n,t,r){return he(n,r)===t}var Qn="__snt_editor_token";function lt(){try{sessionStorage.removeItem(Qn)}catch(n){}}var eo=/rgba\([^)]*,\s*0\s*\)$/,to=/^\d+(\.\d+)?px$/;function pn(n){var t,r;try{let i=n.defaultView;if(!i||!n.body)return null;let u=i.getComputedStyle(n.body).backgroundColor,p=n.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),k=new Map;for(let V of Array.from(p).slice(0,300)){let j=V.getBoundingClientRect();if(j.width>0&&(j.width<48||j.height<24))continue;let H=i.getComputedStyle(V),q=H.backgroundColor;if(!q||q==="transparent"||q===u||eo.test(q))continue;let W=(t=(H.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${q}|${H.color}|${to.test(W)?W:"8px"}`;k.set(Z,((r=k.get(Z))!=null?r:0)+1)}let $=null,L=0;for(let[V,j]of k)j>L&&($=V,L=j);if(!$)return null;let[D,I,be]=$.split("|");return{primaryBg:D,primaryText:I,radius:be}}catch(i){return null}}var dt={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"},no=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Je(n){var i;if(n.trim().length===0||/[;{}<>]/.test(n))return!1;let t=/([A-Za-z-]*)\(/g,r;for(;(r=t.exec(n))!==null;)if(!no.test((i=r[1])!=null?i:""))return!1;return!0}var fn=/^https:\/\//i,gn=new Map,ye=null;function oo(n){return n.replace(/["\\]/g,"\\$&")}function ro(n){var t;(!ye||!ye.isConnected)&&(ye=n.querySelector("style[data-sentient-ops]"),ye||(ye=n.createElement("style"),ye.setAttribute("data-sentient-ops",""),((t=n.head)!=null?t:n.documentElement).appendChild(ye))),ye.textContent=[...gn.entries()].map(([r,i])=>`[data-snt-e="${oo(r)}"]{${i}}`).join(`
2
- `)}function mn(n,t,r,i){var $;let u=!1,p=($=t.moveBefore)!=null?$:t.moveAfter;if(p){let L=he(p,i);!L||L===n||L.parentElement!==n.parentElement||!n.parentElement?u=!0:t.moveBefore?n.parentElement.insertBefore(n,L):n.parentElement.insertBefore(n,L.nextSibling)}typeof t.text=="string"&&(n.textContent=t.text),typeof t.href=="string"&&fn.test(t.href)&&n.setAttribute("href",t.href),typeof t.imageSrc=="string"&&fn.test(t.imageSrc)&&n.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&n.setAttribute("alt",t.imageAlt);let k=[];if(t.hidden&&k.push("display:none !important"),t.style)for(let[L,D]of Object.entries(t.style)){let I=dt[L];I&&typeof D=="string"&&Je(D)&&k.push(`${I}:${D.trim()} !important`)}return k.length>0&&(n.setAttribute("data-snt-e",r),gn.set(r,k.join(";")),ro(i)),{anchorMiss:u}}function ct(n){let t=n.steps.length,r=n.status==="active"?"":` (${n.status})`;return`${n.display_name} \u2014 ${t} step${t===1?"":"s"}${r}`}function ut(n,t){return n.steps.map(r=>{var i;return{value:r.step_index,label:`${r.step_index+1}. ${(i=t.get(r.goal_id))!=null?i:r.goal_id}`}})}function hn(n,t){return n.includes(t)?n.filter(r=>r!==t):[...n,t]}function io(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function yn(n,t){let r=n.trim();return r?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:io(r),body:{displayName:r.slice(0,128),steps:t.map(i=>({goalId:i}))}}:{ok:!1,error:"Give the funnel a name."}}function xn(n){let t=5381;for(let r=0;r<n.length;r++)t=(t<<5)+t+n.charCodeAt(r)>>>0;return t.toString(36)}function ft(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Ke(n,t,r){var $,L;let i=t.id||(($=t.dataAttr)==null?void 0:$.value)||((L=r.textContent)!=null?L:"").trim()||r.tagName,u=ft(i)||"el",p=xn(JSON.stringify(t));return`${n}-${u}-${p}`.slice(0,128)}var so="sentient-editor-highlight",ao="sentient-editor-selection",De="sentient-editor-panel",ht="sentient-editor-toast",$t="sentient-editor-styles",At="sentient-editor-target-highlight",lo=10,co="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",uo="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function vn(){var t;if(document.getElementById($t))return;let n=document.createElement("style");n.id=$t,n.textContent=`
1
+ "use strict";var SentientSnippet=(()=>{var ft=Object.defineProperty,Zn=Object.defineProperties,Qn=Object.getOwnPropertyDescriptor,eo=Object.getOwnPropertyDescriptors,to=Object.getOwnPropertyNames,mn=Object.getOwnPropertySymbols;var yn=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var hn=(e,t,r)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,H=(e,t)=>{for(var r in t||(t={}))yn.call(t,r)&&hn(e,r,t[r]);if(mn)for(var r of mn(t))no.call(t,r)&&hn(e,r,t[r]);return e},K=(e,t)=>Zn(e,eo(t));var oo=(e,t)=>{for(var r in t)ft(e,r,{get:t[r],enumerable:!0})},ro=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of to(t))!yn.call(e,c)&&c!==r&&ft(e,c,{get:()=>t[c],enumerable:!(i=Qn(t,c))||i.enumerable});return e};var io=e=>ro(ft({},"__esModule",{value:!0}),e);var jo={};oo(jo,{buildStyleOps:()=>Ft,clearTargetHighlights:()=>We,computeMoveAnchors:()=>vt,deriveSlotId:()=>nt,drawTargetHighlights:()=>Hn,isHex6:()=>wt,mount:()=>On,registerAuditTargets:()=>In,sectionTypesFor:()=>Pn,styleFieldError:()=>zn,toHexColor:()=>xt});function so(e){var r,i,c;let t=(i=(r=e.defaultView)!=null?r:typeof window!="undefined"?window:void 0)==null?void 0:i.location;return(c=t==null?void 0:t.pathname)!=null?c:""}function ao(e,t){var r;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let i=((r=e.textContent)!=null?r:"").replace(/\s+/g," ").trim().toLowerCase(),c=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(i===c||i.startsWith(c)||c.startsWith(i)))return!1}return!0}var lo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function he(e,t){var c;if(e.urlMatch&&!so(t).includes(e.urlMatch))return null;let r=[];if(e.id){let u=t.getElementById(e.id);r=u?[u]:[]}if(r.length===0&&((c=e.dataAttr)!=null&&c.name)&&lo.test(e.dataAttr.name))try{let u=e.dataAttr.value.replace(/["\\]/g,"\\$&");r=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${u}"]`))}catch(u){r=[]}if(r.length===0&&e.selector)try{r=Array.from(t.querySelectorAll(e.selector))}catch(u){r=[]}if(r.length!==1)return null;let i=r[0];return e.fingerprint&&!ao(i,e.fingerprint)?null:i}var Pt="data-sentient-block-arm",S=null;var Ze="data-sentient-blocks-hid",qe={none:"0",sm:"8px",md:"16px",lg:"24px"},zt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},bn={sm:"0.875em",md:"1em",lg:"1.25em"},co={sm:"1.25em",md:"1.5em",lg:"2em"},uo={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},xn={sm:"8px",md:"16px",lg:"32px"},po={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},fo={normal:"400",medium:"500",bold:"700"};function ee(e,t){for(let[r,i]of Object.entries(t))i!==void 0&&e.style.setProperty(r,i);return e}function vn(e){return e==="muted"?S!=null&&S.muted?{color:S.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:S==null?void 0:S.accent}:{}}function kn(e,t){var r,i,c,u,k,T,x,_,P,X,F,M,I,U,Y,Z,N,q,te,V;try{switch(e.type){case"stack":case"grid":{let m=t.createElement("div");if(e.type==="stack"){let j=e;ee(m,{display:"flex","flex-direction":j.direction,gap:(i=qe[(r=j.gap)!=null?r:"md"])!=null?i:qe.md,"align-items":j.align?zt[j.align]:void 0,"justify-content":j.justify?zt[j.justify]:void 0,"flex-wrap":j.wrap?"wrap":void 0})}else{let j=e,oe=(u=qe[(c=j.gap)!=null?c:"md"])!=null?u:qe.md;ee(m,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${j.columns-1} * ${oe}) / ${j.columns})), 1fr))`,gap:oe,"align-items":j.align?zt[j.align]:void 0})}let D=e.type==="stack"&&e.surface==="raised",ne=(k=e.pad)!=null?k:D?"md":void 0;ne&&ee(m,{padding:(T=qe[ne])!=null?T:qe.md}),D&&ee(m,{background:S==null?void 0:S.surface,color:S!=null&&S.surface?S==null?void 0:S.surfaceText:void 0,border:`1px solid ${(x=S==null?void 0:S.border)!=null?x:"currentColor"}`,"border-radius":(_=S==null?void 0:S.radius)!=null?_:"8px"});for(let j of(P=e.children)!=null?P:[]){let oe=kn(j,t);oe&&m.appendChild(oe)}return m}case"text":{let m=t.createElement("p");return m.textContent=e.value,ee(m,K(H({margin:"0","font-size":e.size?bn[e.size]:void 0,"font-weight":e.weight?fo[e.weight]:void 0,"text-align":e.align},vn(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let m=t.createElement(`h${e.level}`);return m.textContent=e.value,ee(m,{margin:"0","font-size":co[(X=e.size)!=null?X:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let m=t.createElement("a");m.textContent=e.label,m.href=e.href,e.tag&&m.setAttribute("data-sentient-tag",e.tag);let D=(F=e.emphasis)!=null?F:"primary";return ee(m,{display:"inline-block",padding:uo[(M=e.size)!=null?M:"md"],"border-radius":(I=S==null?void 0:S.radius)!=null?I:"8px",font:"inherit","font-size":e.size?bn[e.size]:void 0,"text-decoration":D==="ghost"?"underline":"none",cursor:"pointer",background:D==="primary"?(U=S==null?void 0:S.primaryBg)!=null?U:"#111827":"transparent",color:D==="primary"?(Y=S==null?void 0:S.primaryText)!=null?Y:"#ffffff":(Z=S==null?void 0:S.accent)!=null?Z:"inherit",border:D==="secondary"?`1px solid ${(N=S==null?void 0:S.accent)!=null?N:"currentColor"}`:"none"})}case"link":{let m=t.createElement("a");return m.textContent=e.label,m.href=e.href,e.tag&&m.setAttribute("data-sentient-tag",e.tag),ee(m,{color:"inherit","text-decoration":"underline"})}case"image":{let m=t.createElement("img");return m.src=e.src,m.alt=e.alt,ee(m,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?po[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let m=t.createElement("span");return m.textContent=e.value,ee(m,H({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(q=S==null?void 0:S.border)!=null?q:"currentColor"}`},vn(e.tone)))}case"spacer":return ee(t.createElement("div"),{height:(te=xn[e.size])!=null?te:xn.md});case"divider":return ee(t.createElement("hr"),{border:"none","border-top":`1px solid ${(V=S==null?void 0:S.border)!=null?V:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(m){return null}}function wn(e,t,r,i){try{let c=new Set;for(let k of Array.from(e.children)){let T=k.getAttribute(Pt);T!==null&&(t[T]===void 0?k.remove():c.add(T))}for(let[k,T]of Object.entries(t)){if(c.has(k))continue;let x=kn(T,i);if(!x)continue;let _=i.createElement("div");_.setAttribute(Pt,k),_.style.display="none",_.appendChild(x),e.appendChild(_)}let u=r!==void 0&&t[r]!==void 0;for(let k of Array.from(e.children)){let T=k.getAttribute(Pt),x=k;T!==null?x.style.display=u&&T===r?"":"none":u?x.hasAttribute(Ze)||(x.setAttribute(Ze,x.style.display),x.style.display="none"):x.hasAttribute(Ze)&&(x.style.display=x.getAttribute(Ze),x.removeAttribute(Ze))}}catch(c){}}function En(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let r="";for(let i=0;i<e.length;i++){let c=e[i],u=c>="0"&&c<="9";i===0&&u||i===1&&u&&e[0]==="-"?r+=`\\3${c} `:i===0&&c==="-"&&e.length===1?r+="\\-":/[a-zA-Z0-9_-]/.test(c)?r+=c:r+=`\\${c}`}return r}function go(e,t){if(e.id)return`#${En(e.id)}`;let r=[],i=e,c=0;for(;i&&i!==t.body&&i!==t.documentElement&&c<6;){if(i.id){r.unshift(`#${En(i.id)}`);break}let u=i.tagName.toLowerCase(),k=i.parentElement;if(k){let T=Array.from(k.children).filter(x=>x.tagName===i.tagName);T.length>1&&(u+=`:nth-of-type(${T.indexOf(i)+1})`)}r.unshift(u),i=i.parentElement,c++}return r.join(" > ")}function Ue(e,t){var c;let r={v:1};e.id&&(r.id=e.id);for(let u of["data-framer-name","data-w-id","data-sentient-name"]){let k=e.getAttribute(u);if(k){r.dataAttr={name:u,value:k};break}}r.selector=go(e,t);let i=((c=e.textContent)!=null?c:"").trim().replace(/\s+/g," ").slice(0,80);return r.fingerprint=H({tag:e.tagName.toLowerCase()},i?{text:i}:{}),r}function Qe(e,t,r){return he(e,r)===t}var mo="__snt_editor_token";function et(){try{sessionStorage.removeItem(mo)}catch(e){}}var ho=/rgba\([^)]*,\s*0\s*\)$/,yo=/^\d+(\.\d+)?px$/;function Sn(e){var t,r;try{let i=e.defaultView;if(!i||!e.body)return null;let c=i.getComputedStyle(e.body).backgroundColor,u=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),k=new Map;for(let F of Array.from(u).slice(0,300)){let M=F.getBoundingClientRect();if(M.width>0&&(M.width<48||M.height<24))continue;let I=i.getComputedStyle(F),U=I.backgroundColor;if(!U||U==="transparent"||U===c||ho.test(U))continue;let Y=(t=(I.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${U}|${I.color}|${yo.test(Y)?Y:"8px"}`;k.set(Z,((r=k.get(Z))!=null?r:0)+1)}let T=null,x=0;for(let[F,M]of k)M>x&&(T=F,x=M);if(!T)return null;let[_,P,X]=T.split("|");return{primaryBg:_,primaryText:P,radius:X}}catch(i){return null}}var gt={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},bo=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function tt(e){var i;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,r;for(;(r=t.exec(e))!==null;)if(!bo.test((i=r[1])!=null?i:""))return!1;return!0}var Tn=/^https:\/\//i,Cn=new Map,we=null;function xo(e){return e.replace(/["\\]/g,"\\$&")}function vo(e){var t;(!we||!we.isConnected)&&(we=e.querySelector("style[data-sentient-ops]"),we||(we=e.createElement("style"),we.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(we))),we.textContent=[...Cn.entries()].map(([r,i])=>`[data-snt-e="${xo(r)}"]{${i}}`).join(`
2
+ `)}function Ln(e,t,r,i){var T;let c=!1,u=(T=t.moveBefore)!=null?T:t.moveAfter;if(u){let x=he(u,i);!x||x===e||x.parentElement!==e.parentElement||!e.parentElement?c=!0:t.moveBefore?e.parentElement.insertBefore(e,x):e.parentElement.insertBefore(e,x.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Tn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Tn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let k=[];if(t.hidden&&k.push("display:none !important"),t.style)for(let[x,_]of Object.entries(t.style)){let P=gt[x];P&&typeof _=="string"&&tt(_)&&k.push(`${P}:${_.trim()} !important`)}return k.length>0&&(e.setAttribute("data-snt-e",r),Cn.set(r,k.join(";")),vo(i)),{anchorMiss:c}}function mt(e){let t=e.steps.length,r=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${r}`}function ht(e,t){return e.steps.map(r=>{var i;return{value:r.step_index,label:`${r.step_index+1}. ${(i=t.get(r.goal_id))!=null?i:r.goal_id}`}})}function Bn(e,t){return e.includes(t)?e.filter(r=>r!==t):[...e,t]}function ko(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function An(e,t){let r=e.trim();return r?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:ko(r),body:{displayName:r.slice(0,128),steps:t.map(i=>({goalId:i}))}}:{ok:!1,error:"Give the funnel a name."}}function $n(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)>>>0;return t.toString(36)}function bt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function nt(e,t,r){var T,x;let i=t.id||((T=t.dataAttr)==null?void 0:T.value)||((x=r.textContent)!=null?x:"").trim()||r.tagName,c=bt(i)||"el",u=$n(JSON.stringify(t));return`${e}-${c}-${u}`.slice(0,128)}var wo="sentient-editor-highlight",Eo="sentient-editor-selection",Ge="sentient-editor-panel",kt="sentient-editor-toast",Ot="sentient-editor-styles",Nt="sentient-editor-target-highlight",So=10,To="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Co="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Rn(){var t;if(document.getElementById(Ot))return;let e=document.createElement("style");e.id=Ot,e.textContent=`
3
3
  @keyframes sntedi-in {
4
4
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
5
5
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -12,13 +12,13 @@
12
12
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
13
13
  50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
14
14
  }
15
- #${De} {
15
+ #${Ge} {
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
- #${De} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
- #${ht} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
19
+ #${Ge} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
+ #${kt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
21
21
  @media (prefers-reduced-motion: reduce) {
22
- #${De}, #${De} .sntedi-dot, #${ht} { animation: none !important; }
22
+ #${Ge}, #${Ge} .sntedi-dot, #${kt} { animation: none !important; }
23
23
  }
24
- `,((t=document.head)!=null?t:document.documentElement).appendChild(n)}function bn(n){var i,u;vn(),(i=document.getElementById(ht))==null||i.remove();let t=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=ht;let r=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(r,a("div",{},n)),((u=document.body)!=null?u:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function po(){let n=window.__sentientEditor;return n&&typeof n.token=="string"&&typeof n.apiBase=="string"?n:null}async function fo(n){try{let t=await fetch(`${n.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${n.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let r=(await t.json()).projectId;return r?{ok:!0,projectId:r}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function It(n,t){return A(A(A(A({r:n===401?"expired":"error",status:n},typeof(t==null?void 0:t.error)=="string"?{code:t.error}:{}),typeof(t==null?void 0:t.message)=="string"?{message:t.message}:{}),typeof(t==null?void 0:t.feature)=="string"?{feature:t.feature}:{}),typeof(t==null?void 0:t.plan)=="string"?{plan:t.plan}:{})}async function G(n,t,r){try{let i=await fetch(`${n.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(r)});if(i.ok)return{r:"ok"};let u=await i.json().catch(()=>null);return It(i.status,u)}catch(i){return{r:"error"}}}async function go(n,t){try{let r=await fetch(`${n.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${n.token}`}});if(r.ok)return{r:"ok"};let i=await r.json().catch(()=>null);return It(r.status,i)}catch(r){return{r:"error"}}}async function mo(n,t,r){try{let i=await fetch(`${n.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(r)}),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:It(i.status,u)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var Mt=[];function yt(n){return/^#[0-9a-fA-F]{6}$/.test(n)}function gt(n){let t=n.trim();if(yt(t))return t;let r=/^#([0-9a-fA-F]{3})$/.exec(t);if(r)return`#${r[1].split("").map(p=>p+p).join("")}`;let i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!i)return t;let u=p=>Math.min(255,Number(p)).toString(16).padStart(2,"0");return`#${u(i[1])}${u(i[2])}${u(i[3])}`}var de=null,kn=[];function wn(n){kn=n}async function ho(n){try{let t=await fetch(`${n.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${n.token}`}});if(!t.ok)return[];let r=await t.json();return Mt=Array.isArray(r.fonts)?r.fonts.filter(i=>typeof i=="string"):[],Array.isArray(r.targets)?r.targets:[]}catch(t){return[]}}async function pt(n,t){try{let r=await fetch(`${n.apiBase}${t}`,{headers:{authorization:`Bearer ${n.token}`}});return r.ok?await r.json():null}catch(r){return null}}function Fe(n=document){for(let t of Array.from(n.querySelectorAll(`.${At}`)))t.remove()}function En(n,t=document){var i;Fe(t);let r=0;for(let u of n){if(r>=lo)break;let p=he(u.locator,t);if(!p)continue;let k=p.getBoundingClientRect(),$=a("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)"});$.className=At;let L=a("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=At,((i=t.body)!=null?i:t.documentElement).append($,L),r+=1}}function mt(n,t){let r=n.previousElementSibling,i=n.nextElementSibling,u=r?Ne(r,t):null,p=i?Ne(i,t):null;return{prevEl:r,nextEl:i,prevLocator:r&&u&&Ve(u,r,t)?u:null,nextLocator:i&&p&&Ve(p,i,t)?p:null}}var yo=/testimonial|review|quote/i;function Sn(n){let t=[],r=n.headings.length>=1,i=n.links.length>=1;return r&&i&&t.push("hero","cta_band"),n.headings.length>=2&&n.paragraphs.length>=2&&t.push("feature_grid"),n.quotes.length>=1&&t.push("testimonial"),t}var Rt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],bo=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,xo=new Set(["left","center","right","justify","start","end"]),vo=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ko=/^(rgb|rgba|hsl|hsla)\(/i;function wo(n){return vo.test(n)||ko.test(n)}function Tn(n,t){switch(n){case"fontSize":case"borderRadius":return bo.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 xo.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return wo(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let r=t.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&r.length>=1&&r.length<=5&&r.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 Ht(n){let t={},r={};for(let i of Rt){let u=n[i];if(typeof u!="string")continue;let p=u.trim();if(p==="")continue;if(!Je(p)){r[i]="That value isn\u2019t allowed.";continue}let k=Tn(i,p);if(k){r[i]=k;continue}t[i]=p}return{style:t,errors:r}}function a(n,t,r){let i=document.createElement(n);return Object.assign(i.style,t),r!==void 0&&(i.textContent=r),i}function Cn(n){var an;let t=null,r=[],i=null,u=()=>{for(;r.length>0;){let e=r.splice(0,20);try{fetch(`${n.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify({events:e})}).catch(()=>{})}catch(o){}}},p=(e,o)=>{r.push(A({kind:e},o?{meta:o}:{})),i&&clearTimeout(i),i=setTimeout(u,2e3)};window.addEventListener("pagehide",u);let k=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});k.id=so;let $=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});$.id=ao;let L=()=>{if(!t||!t.isConnected){$.style.display="none";return}let e=t.getBoundingClientRect();Object.assign($.style,{display:"block",left:`${e.left-2}px`,top:`${e.top-2}px`,width:`${e.width}px`,height:`${e.height}px`})},D=()=>L();vn();let I=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",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"});I.id=De;let be=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});be.className="sntedi-dot";let V=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});V.append(be,a("span",{},"SentientUI"));let j=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),H=!1,q=a("button",T("#374151"),"Pause selecting");q.onclick=()=>{H=!H,q.textContent=H?"Resume selecting":"Pause selecting",H?(k.style.display="none",Fe(document),h("Selection paused \u2014 browse normally, then resume.")):h("Click any element on the page to adapt it.")};let W=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Z=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),P=a("button",T("#6366f1"),"Test different text here"),F=a("button",T("#374151"),"Change style"),ce=a("button",T("#374151"),"Try a different layout for this section"),Y=a("button",T("#374151"),"Track clicks as a goal"),C=a("button",T("#374151"),"Track form submissions as a goal"),Q=a("button",T("#374151"),"Track page visits as a goal"),ue=a("button",T("#374151"),"Track reading this far as a goal"),Pt=a("button",T("#374151"),"Set up a funnel"),je=a("button",T("#374151"),"Attach this test to a funnel step"),xe=a("button",T("#10b981"),"Turn the funnel on"),pe=a("button",T("#374151"),"Move up"),fe=a("button",T("#374151"),"Move down"),Xe=a("button",T("#6366f1"),"Save this arrangement"),Ze=a("button",T("#374151"),"Undo"),Be=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Close editor"),ne=a("button",T("#10b981"),"Publish now \u2014 go live"),oe=a("button",T("#10b981"),"Start tracking now");for(let e of[P,F,ce,Y,pe,fe])e.disabled=!0;let bt=[P,F,ce,Y,C,pe,fe];for(let e of bt)e.style.display="none";Xe.style.display="none",Ze.style.display="none",ne.style.display="none",oe.style.display="none",je.style.display="none",xe.style.display="none";let re=a("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),_e=a("div",{}),Ot=[{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"}],J="text",zt=new Map,ge=new Map,xt=new Map,Nt=a("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Dt=a("div",{paddingTop:"10px"});for(let e of Ot){let o=a("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"});o.append(a("span",{fontSize:"11px",marginRight:"3px"},e.icon),a("span",{},e.label)),o.onclick=()=>vt(e.id),zt.set(e.id,o),Nt.append(o);let s=a("div",{display:"none"}),l=a("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});s.append(l),xt.set(e.id,l),ge.set(e.id,s),Dt.append(s)}ge.get("text").append(P),ge.get("style").append(F),ge.get("layout").append(ce,pe,fe,Xe,Ze),ge.get("goals").append(Y,C,Q,ue),ge.get("funnels").append(Pt,je,xe);let K=a("div",{});ge.get("drafts").append(K);let Qe=()=>{var o,s;for(let l of Ot){let d=l.id===J,m=zt.get(l.id);m.style.color=d?"#ffffff":"#9ca3af",m.style.borderBottom=d?"2px solid #6366f1":"2px solid transparent",ge.get(l.id).style.display=d?"block":"none",xt.get(l.id).style.display="none"}let e=l=>{let d=xt.get(J);d.textContent=l,d.style.display="block"};J==="text"?t?P.disabled?e(P.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(o=P.onclick)==null||o.call(P,new MouseEvent("click")):e("Click any text on the page to test a different wording."):J==="style"?t?F.disabled?e("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(s=F.onclick)==null||s.call(F,new MouseEvent("click")):e("Click any element on the page to change how it looks."):J==="layout"?t||e("Click a section to move it or lay it out differently. Layouts re-arrange the words already on the page \u2014 they never add a section you don\u2019t have."):J==="goals"?t||e("Page-level goals work right away; click a button or form to track it specifically."):J==="funnels"?e("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):J==="drafts"&&Ae()},Bn=(e,o,s)=>{e.onclick=()=>{if(e.dataset.armed==="1"){e.dataset.armed="",s();return}e.dataset.armed="1",e.textContent="Sure?",setTimeout(()=>{e.isConnected&&e.dataset.armed==="1"&&(e.dataset.armed="",e.textContent=o)},4e3)}},$e=(e,o)=>a("button",U(A({},T(e)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),o),Ft=(e,o)=>{let s=new URL(window.location.href);s.searchParams.delete("sentient_editor"),s.searchParams.set("sentient_preview",e),o&&s.searchParams.set("sentient_arm",o),window.location.assign(s.toString())},et=(e,o,s)=>{let l=$e("#374151","Discard");return Bn(l,"Discard",async()=>{l.disabled=!0;let d=await go(n,e);l.disabled=!1,X(d,o),d.r==="ok"&&s()}),l},jt=(e,o)=>{ke.textContent="";let s=a("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=a("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...o),s.append(a("div",{marginBottom:"6px"},e),l),ke.append(s)},Ae=async()=>{var g,y,b,x,w,E,S,M,R,te,ae,ze;K.textContent="",K.append(a("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let e=[],o=[],s=null,l=!1;if(await Promise.all([(async()=>{var v;try{let _=await fetch(`${n.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${n.token}`}});_.ok?e=(v=(await _.json()).slots)!=null?v:[]:s=_.status===401?"expired":"error"}catch(_){s="error"}})(),(async()=>{var v;try{let _=await fetch(`${n.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${n.token}`}});_.ok?o=(v=(await _.json()).goals)!=null?v:[]:l=!0}catch(_){l=!0}})()]),J!=="drafts")return;if(K.textContent="",s){if(K.append(a("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},s==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),s==="error"){let v=$e("#374151","Retry");v.onclick=()=>{Ae()},K.append(v)}return}let d=e.filter(v=>{var _,z,le,me,Le,Ye;return((le=(z=(_=v.draft_config)==null?void 0:_.arms)==null?void 0:z.length)!=null?le:0)>0||((Ye=(Le=(me=v.published_config)==null?void 0:me.arms)==null?void 0:Le.length)!=null?Ye:0)>0}),m=o.filter(v=>v.event!=="custom"&&(v.status==="draft"||v.status==="active"));if(d.length===0&&m.length===0&&!l){K.append(a("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let f=v=>a("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:v?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:v?"#6ee7b7":"#c7d2fe"},v?"live":"draft"),c=v=>{let _=a("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),z=a("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},v);return _.append(z),{row:_,name:z}};for(let v of d){let{row:_}=c((g=v.display_name)!=null?g:v.slot_id);_.append(f(v.status==="published"));let z=(w=(x=(y=v.draft_config)==null?void 0:y.arms)!=null?x:(b=v.published_config)==null?void 0:b.arms)!=null?w:[],le=(M=(E=z[1])==null?void 0:E.id)!=null?M:(S=z[0])==null?void 0:S.id,me=$e("#374151","Preview");if(me.onclick=()=>Ft(v.slot_id,le),_.append(me),v.status!=="published"&&((ae=(te=(R=v.draft_config)==null?void 0:R.arms)==null?void 0:te.length)!=null?ae:0)>0){let Le=$e("#10b981","Publish");Le.onclick=async()=>{Le.disabled=!0;let Ye=await G(n,`/v1/editor/slots/${encodeURIComponent(v.slot_id)}/publish`,{});Le.disabled=!1,X(Ye,"\u2713 Published \u2014 live for new visitors."),Ye.r==="ok"&&(p("published",{kind:"slot"}),Ae())},_.append(Le)}v.status!=="published"&&_.append(et(`/v1/editor/slots/${encodeURIComponent(v.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{Kt(v.slot_id),Ae()})),K.append(_)}if(l)K.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(m.length>0){K.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let v of m){let{row:_}=c((ze=v.display_name)!=null?ze:v.goal_id);if(_.append(f(v.status==="active")),v.status==="draft"){let z=$e("#10b981","Start tracking");z.onclick=async()=>{z.disabled=!0;let le=await G(n,`/v1/editor/goals/${encodeURIComponent(v.goal_id)}/publish`,{});z.disabled=!1,X(le,"\u2713 Tracking is live \u2014 it counts from your next visitor."),le.r==="ok"&&(p("published",{kind:"goal"}),Ae())},_.append(z,et(`/v1/editor/goals/${encodeURIComponent(v.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Xt(v.goal_id),Ae()}))}K.append(_)}}},vt=e=>{J!==e&&(O(),Ge(),J=e,Qe())},qt=a("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(V.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Ut=!1,ve=a("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)"}),Gt=a("span",{width:"7px",height:"7px",borderRadius:"50%",background:"#34d399",display:"inline-block"});Gt.className="sntedi-dot",ve.append(Gt,a("span",{},"S")),ve.title="Open the SentientUI editor";let Wt=a("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");Wt.onclick=()=>{I.style.display="none",ve.style.display="flex",Ut=H,H=!0,k.style.display="none",Fe(document)},ve.onclick=()=>{I.style.display="block",ve.style.display="none",H=Ut},Object.assign(q.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Object.assign(Be.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",whiteSpace:"nowrap"}),qt.append(V,q,Wt,Be);let Yt=a("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),ke=a("div",{});Object.assign(Z.style,{marginBottom:"4px"}),Yt.append(ke,Z,ne,oe);let ie=a("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"},"\u2728 Ask AI"),kt=a("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(W.style,{flex:"1 1 auto",marginBottom:"0"}),kt.append(W,ie),Object.assign(kt.style,{marginBottom:"6px"});let se=a("div",{}),B=a("div",{marginTop:"4px"});B.addEventListener("input",()=>{Me=!0}),B.addEventListener("change",()=>{Me=!0}),I.append(qt,j,kt,re,_e,se,Nt,Dt,B,Yt),((an=document.body)!=null?an:document.documentElement).append(k,$,I,ve);let we=null,Vt=()=>{we==null||we(),we=null},Jt=()=>{we=null},Me=!1,wt=null,O=()=>{Vt(),B.textContent="",Me=!1,wt=null,_t=!1},qe=(e,o,s)=>{var y;O();let l={},d={},m={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let b of e){let x=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},b.label);if(B.append(x),b.type==="select"){let E=a("select",m);E.setAttribute("data-field",b.key);let S=document.createElement("option");S.value="",S.textContent="\u2014 no change \u2014",E.append(S);for(let M of(y=b.options)!=null?y:[]){let R=document.createElement("option");R.value=M,R.textContent=M,E.append(R)}l[b.key]=()=>E.value,B.append(E)}else if(b.type==="color"){let E=a("input",U(A({},m),{padding:"2px",height:"34px"}));E.type="color",E.setAttribute("data-field",b.key);let S=!1;E.addEventListener("input",()=>{S=!0}),l[b.key]=()=>S?E.value:"",B.append(E)}else{let E=a("input",m);E.setAttribute("data-field",b.key),b.value!==void 0&&(E.value=b.value),l[b.key]=()=>E.value,B.append(E)}let w=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});w.setAttribute("data-feedback",b.key),d[b.key]=w,B.append(w)}let f=(b,x)=>{let w=d[b];w&&(w.textContent=x!=null?x:"",w.style.display=x?"block":"none")},c=a("button",T("#6366f1"),o),g=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Cancel");c.onclick=()=>s(Object.fromEntries(Object.entries(l).map(([b,x])=>[b,x()])),f),g.onclick=O,B.append(c,g)},h=(e,o=!0)=>{Z.textContent=e,Z.style.color=o?"#a7f3d0":"#fca5a5"},Et=(e,o)=>{var l,d;if(p("error_shown",{code:(d=e.code)!=null?d:`http_${(l=e.status)!=null?l:"network"}`}),e.code==="plan_limit_reached"){let m=e.feature==="live_goals"?"live goal":"of these",f=e.plan?`${e.plan} plan`:"plan";return e.feature==="live_goals"?`Your ${f} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${f} has reached its limit for ${m}. Manage them in your dashboard, or upgrade for more.`}if(e.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(e.code==="demo_read_only"&&e.message)return e.message;let s=e.status?` (HTTP ${e.status})`:"";return`\u26A0 Couldn\u2019t ${o} \u2014 try again.${s}`},X=(e,o)=>{e.r==="ok"?h(o,!0):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):h(Et(e,"save"),!1)},Ee=null,tt=e=>e.length>30?`${e.slice(0,27)}\u2026`:e,Kt=e=>{Ee===e&&(Ee=null,ne.style.display="none",je.style.display="none",ke.textContent="")},Xt=e=>{Oe===e&&(Oe=null,oe.style.display="none",ke.textContent="")},nt=(e,o,s)=>{Ee=e,ne.textContent=o?`Publish \u201C${tt(o)}\u201D \u2014 go live`:"Publish now \u2014 go live",ne.style.display="block",je.style.display="block";let l=[];if(s){let d=$e("#374151","Preview");d.onclick=()=>Ft(e,s),l.push(d)}l.push(et(`/v1/editor/slots/${encodeURIComponent(e)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>Kt(e))),jt(o?`Draft saved for \u201C${tt(o)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ne.onclick=async()=>{if(!Ee)return;ne.disabled=!0,h("Publishing\u2026");let e=await G(n,`/v1/editor/slots/${encodeURIComponent(Ee)}/publish`,{});ne.disabled=!1,e.r==="ok"?(p("published",{kind:"slot"}),h("\u2713 Published \u2014 live for new visitors.",!0),ne.style.display="none",Ee=null,ke.textContent=""):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):h(Et(e,"publish"),!1)};let N=null,Re=!1,He=null,Ie=null,ee=null,Se=null,Ue=null,ot=null,Te=!1,Zt=(e,o)=>Re?e?"":`Nothing to swap with ${o} \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.",Qt=()=>{pe.disabled=!Re||!ee,fe.disabled=!Re||!Se,pe.title=pe.disabled?Zt(ee,"above"):"",fe.title=fe.disabled?Zt(Se,"below"):""},St=e=>{Xe.style.display=e?"block":"none",Ze.style.display=e?"block":"none",Qt()},Ge=()=>{if(Te&&t&&Ue&&Ue.insertBefore(t,ot),Te=!1,Ue=null,ot=null,t){let e=mt(t,document);He=e.prevEl,Ie=e.nextEl,ee=e.prevLocator,Se=e.nextLocator}L(),St(!1)},en=e=>{if(H)return;let o=e.target;if(!o||I.contains(o)||o===k)return;Fe(document);let s=o.getBoundingClientRect();Object.assign(k.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},Ce=e=>{var s;let o=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ");return o?o.length>40?`${o.slice(0,37)}\u2026`:o:e.tagName.toLowerCase()},_n=e=>!!e.id||["section","header","footer","nav","main","form","article","aside"].includes(e.tagName.toLowerCase())||!!e.querySelector(":scope > h1, :scope > h2, :scope > h3"),$n=e=>{var l;let o=e.querySelector("h1, h2, h3"),s=(l=o==null?void 0:o.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return s?s.length>28?`${s.slice(0,25)}\u2026`:s:e.id?`#${e.id.length>24?`${e.id.slice(0,21)}\u2026`:e.id}`:`<${e.tagName.toLowerCase()}>`},An=e=>{re.textContent="";let o=[];for(let f=e.parentElement;f&&f!==document.body&&o.length<3;f=f.parentElement)_n(f)&&o.push(f);let s=Ce(e),l=()=>a("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),d=!0;for(let f of o){let c=$n(f);if(c===s||s.startsWith(c))continue;let g=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},c);g.onclick=()=>rt(f),d||re.append(l()),re.append(g),d=!1}d||re.append(l());let m=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");m.onclick=()=>tn(),re.append(m),re.style.display="block"},Mn=e=>{_e.textContent="";let o=null,s=0;for(let d=e.parentElement;d&&d!==document.body&&s<6;d=d.parentElement,s++)if(Ve(Ne(d,document),d,document)){o=d;break}let l=a("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(o){let d=o;l.append(a("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 m=a("button",U(A({},T("#6366f1")),{marginTop:"0"}),`Select \u201C${Ce(d)}\u201D instead`);m.onclick=()=>rt(d);let f=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Pick something else");f.onclick=()=>{_e.textContent=""},l.append(m,f)}else l.append(a("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));_e.append(l)},rt=e=>{Ge(),O(),_e.textContent="",t=e,N=Ne(e,document);let o=Ve(N,e,document);Re=o,L(),W.style.display="block",W.textContent=`Selected: ${Ce(e)}`,An(e),p("element_selected",{unique:o}),h(o?"\u2713 Matches exactly 1 element":"",o),o||Mn(e),j.style.display="none",ie.style.display="inline-block",se.textContent="";for(let m of bt)m.style.display="block";P.style.display="none",F.style.display="none";let s=e.childElementCount===0;P.disabled=!o||!s,P.title=o?s?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",F.disabled=!o,ce.disabled=!o,Y.disabled=!o;let l=e.closest("form");C.style.display=l?"block":"none",C.disabled=!l;let d=mt(e,document);He=d.prevEl,Ie=d.nextEl,ee=d.prevLocator,Se=d.nextLocator,Qt(),Qe()},tn=()=>{Ge(),O(),t=null,N=null,Re=!1,He=null,Ie=null,ee=null,Se=null,L(),_e.textContent="",se.textContent="",re.textContent="",re.style.display="none",W.textContent="",W.style.display="none",ie.style.display="none";for(let e of bt)e.style.display="none";j.style.display="block",h(""),Qe()},Pe=!1,Tt=-1,nn=e=>{var l,d;let o=e.target,s=!!((l=o==null?void 0:o.closest)!=null&&l.call(o,'input, textarea, select, [contenteditable="true"]'));if(e.key==="Escape"){if(B.childElementCount>0){O(),Pe=!1;return}if(t){tn(),Pe=!1;return}if(!Pe){Pe=!0,h("Press Esc again to close the editor.");return}Pe=!1,(d=Be.onclick)==null||d.call(Be,new MouseEvent("click"));return}if(Pe=!1,!(s||H)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){if(!t||(e.key==="ArrowUp"?pe:fe).disabled)return;e.preventDefault(),Bt(e.key==="ArrowUp"?"up":"down");return}if(e.key==="Tab"){let m=[];for(let c of kn){let g=he(c.locator,document);g&&!m.includes(g)&&m.push(g)}if(m.length===0)return;if(Me){h("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),e.preventDefault();return}e.preventDefault(),Tt=(Tt+(e.shiftKey?-1:1)+m.length)%m.length;let f=m[Tt];rt(f);try{f.scrollIntoView({block:"center",behavior:"smooth"})}catch(c){}}}},on=e=>{if(H)return;let o=e.target;if(!(!o||I.contains(o))){if(e.preventDefault(),e.stopPropagation(),Me&&o!==t&&wt!==o){wt=o,h("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}rt(o)}};P.onclick=()=>{var m,f,c;if(!t||!N)return;p("form_opened",{kind:"text"});let e=N,o=(f=(m=t.textContent)==null?void 0:m.trim())!=null?f:"";qe([{key:"current",label:"Current wording",value:o},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async g=>{let y=g.alt.trim();if(!y){h("\u26A0 Enter alternative wording to test.",!1);return}if(y===g.current.trim()){h("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let b=Ke("text",e,t);h("Saving\u2026");let x=await G(n,`/v1/editor/slots/${encodeURIComponent(b)}`,{kind:"arms",target:e,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:g.current}},{id:"b",displayName:"Alternative",ops:{text:g.alt}}]}});x.r==="ok"&&(p("draft_saved",{kind:"slot"}),Jt(),O(),nt(b,Ce(t),"b")),X(x,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let s=t,l=(c=s.textContent)!=null?c:"";we=()=>{s.textContent=l};let d=B.querySelector('input[data-field="alt"]');d==null||d.addEventListener("input",()=>{s.textContent=d.value.trim()===""?l:d.value})};let We=null,rn=e=>{let o=c=>{var g;return((g=c.textContent)!=null?g:"").replace(/\s+/g," ").trim()},s=Array.from(e.querySelectorAll("h1,h2,h3,h4")).map(o).filter(Boolean);if(s.length===0){let c=e.closest("h1,h2,h3,h4");c&&s.push(o(c))}let l=Array.from(e.querySelectorAll("p")).map(o).filter(c=>c.length>0&&c.length<=300),d=[];for(let c of Array.from(e.querySelectorAll("a[href], button"))){let g=o(c);if(!g||g.length>60)continue;let y="",b=c.getAttribute("href");if(b)try{let x=new URL(b,window.location.href);x.protocol==="https:"&&(y=x.href)}catch(x){}d.push({label:g,href:y})}let m=Array.from(e.querySelectorAll("blockquote, q")).map(o).filter(Boolean);if(m.length===0&&yo.test(`${e.className} ${e.id}`))for(let c of l)c.length>=20&&m.push(c);let f=Array.from(e.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(o).filter(c=>c.length>0&&c.length<=80);return{headings:s,paragraphs:l,links:d,quotes:m,attributions:f}},Rn=(e,o)=>{var l,d,m,f,c,g,y,b,x,w,E,S,M,R,te,ae,ze,v,_,z;let s=le=>{var me;return o.paragraphs.length>=3&&(me=o.paragraphs[o.paragraphs.length-3+le])!=null?me:""};switch(e){case"headline":return(l=o.headings[0])!=null?l:"";case"supporting":return(d=o.paragraphs[0])!=null?d:"";case"cta_label":return(f=(m=o.links[0])==null?void 0:m.label)!=null?f:"";case"cta_href":return(g=(c=o.links[0])==null?void 0:c.href)!=null?g:"";case"secondary_label":return(b=(y=o.links[1])==null?void 0:y.label)!=null?b:"";case"secondary_href":return(w=(x=o.links[1])==null?void 0:x.href)!=null?w:"";case"quote":case"q1":return(E=o.quotes[0])!=null?E:"";case"q2":return(S=o.quotes[1])!=null?S:"";case"q3":return(M=o.quotes[2])!=null?M:"";case"name":case"n1":return(R=o.attributions[0])!=null?R:"";case"n2":return(te=o.attributions[1])!=null?te:"";case"n3":return(ae=o.attributions[2])!=null?ae:"";case"role":return(ze=o.attributions[1])!=null?ze:"";case"eyebrow":return"";case"f1_title":return(v=o.headings[1])!=null?v:"";case"f2_title":return(_=o.headings[2])!=null?_:"";case"f3_title":return(z=o.headings[3])!=null?z:"";case"f1_body":return s(0);case"f2_body":return s(1);case"f3_body":return s(2);default:return""}},Hn=(e,o,s)=>{p("form_opened",{kind:"arrangement"});let l=rn(s);qe(e.fields.map(d=>({key:d.id,label:d.kind==="href"?`${d.label} (https link \u2014 required)`:d.label,value:Rn(d.id,l)})),"Save draft",async(d,m)=>{var x,w,E,S,M;let f=!1,c=!1;for(let R of e.fields){if(R.kind==="href"){let ae=!1;try{ae=new URL((x=d[R.id])!=null?x:"").protocol==="https:"}catch(ze){}m(R.id,ae?null:"Links need to start with https://"),ae||(f=!0);continue}let te=((w=d[R.id])!=null?w:"").trim()==="";m(R.id,te?"Fill this in with your own words":null),te&&(c=!0)}if(f){h("\u26A0 Fix the highlighted link(s).",!1);return}if(c){h("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}h("Saving\u2026");let g=await mo(n,`/v1/editor/arrangements/${encodeURIComponent(e.id)}/instantiate`,{fields:d});if(g.r!=="ok"||!((E=g.data)!=null&&E.blocks)){g.r==="expired"?X(g.outcome,""):h(`\u26A0 ${(M=(S=g.data)==null?void 0:S.reason)!=null?M:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let y=Ke("arrange",o,s),b=await G(n,`/v1/editor/slots/${encodeURIComponent(y)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:e.id,displayName:e.name,blocks:g.data.blocks}],baseline:"original"}});b.r==="ok"&&(p("draft_saved",{kind:"arrangement"}),O(),nt(y,e.name,e.id)),X(b,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")})};ce.onclick=async()=>{var m,f;if(!t||!N)return;let e=N,o=t;if(O(),h("Loading arrangements\u2026"),!We){let c=await pt(n,"/v1/editor/arrangements");We=(m=c==null?void 0:c.arrangements)!=null?m:null}if(!We||We.length===0){h("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let s=Sn(rn(o)),l=We.filter(c=>s.includes(c.sectionType));if(l.length===0){h("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}h("Pick a layout for this section \u2014 your own words are carried across.");for(let c of l){let g=a("button",U(A({},T("#374151")),{textAlign:"left"}));g.append(a("div",{fontWeight:"600"},c.name),a("div",{fontSize:"11px",opacity:"0.7"},c.description)),g.onclick=()=>Hn(c,e,o),B.append(g)}let d=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Cancel");d.onclick=O,B.append(d),(f=B.scrollIntoView)==null||f.call(B,{block:"nearest"})};let Oe=null,In=(e,o)=>{Oe=e,oe.textContent=o?`Start tracking \u201C${tt(o)}\u201D now`:"Start tracking now",oe.style.display="block",jt(o?`Goal \u201C${tt(o)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[et(`/v1/editor/goals/${encodeURIComponent(e)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Xt(e))])};oe.onclick=async()=>{if(!Oe)return;oe.disabled=!0,h("Activating\u2026");let e=await G(n,`/v1/editor/goals/${encodeURIComponent(Oe)}/publish`,{});oe.disabled=!1,e.r==="ok"?(p("published",{kind:"goal"}),h("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),oe.style.display="none",Oe=null,ke.textContent=""):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):h(Et(e,"activate"),!1)};let Ct=(e,o)=>`${ft(e)||"goal"}-${xn(o)}`.slice(0,128),Pn=e=>{var l,d,m;let o=((l=e.textContent)!=null?l:"").replace(/\s+/g," ").trim();return o&&o.length<=60?o:((m=(d=e.getAttribute("aria-label"))!=null?d:e.getAttribute("id"))!=null?m:"").trim()||"element-clicked"},it=async(e,o,s)=>{h("Saving\u2026");let l=await G(n,`/v1/editor/goals/${encodeURIComponent(e)}`,o);l.r==="ok"&&(p("draft_saved",{kind:"goal"}),In(e,s)),X(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live.")};Y.onclick=()=>{if(!t||!N)return;let e=Ct(Pn(t),JSON.stringify(N));it(e,{event:"click",locator:N},Ce(t))},C.onclick=()=>{var l,d;let e=t==null?void 0:t.closest("form");if(!e)return;let o=Ne(e,document),s=(d=(l=e.getAttribute("id"))!=null?l:e.getAttribute("name"))!=null?d:"form-submitted";it(Ct(s,JSON.stringify(o)),{event:"form_submit",locator:o},s)},Q.onclick=()=>{let e=window.location.pathname||"/",o=ft(e)?`reached-${ft(e)}`:"page-visited";it(Ct(o,e),{event:"url_reached",urlPattern:e},e)};let Lt=[{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}];ue.onclick=()=>{qe([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Lt.map(e=>e.label)}],"Track it",e=>{var l;let o=(l=Lt.find(d=>d.label===e.depth))!=null?l:Lt[2],s=Math.round(o.value*100);it(`read-${s}pct`,{event:"scroll_depth",threshold:o.value},`read ${s}%`),O()})};let st=null,On=e=>{st=e,xe.style.display="block"};xe.onclick=async()=>{if(!st)return;xe.disabled=!0,h("Turning on\u2026");let e=await G(n,`/v1/editor/funnels/${encodeURIComponent(st)}/publish`,{});xe.disabled=!1,e.r==="ok"?(p("published",{kind:"funnel"}),h("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),xe.style.display="none",st=null):e.r==="expired"?h("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):h("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},Pt.onclick=async()=>{var b;h("Loading your goals\u2026");let e=await pt(n,"/v1/editor/goals"),o=(b=e==null?void 0:e.goals)!=null?b:[];if(o.length<2){h("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}h("Pick the steps in order \u2014 first click = first step."),O();let s=[],l=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),d=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});B.append(l,d);let m=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");B.append(m);let f=new Map,c=()=>{var x,w;for(let[E,S]of f){let M=s.indexOf(E),R=(w=(x=o.find(te=>te.goal_id===E))==null?void 0:x.display_name)!=null?w:E;S.textContent=M===-1?R:`${M+1}. ${R}`,S.style.background=M===-1?"#374151":"#6366f1"}};for(let x of o){let w=a("button",U(A({},T("#374151")),{textAlign:"left"}));f.set(x.goal_id,w),w.onclick=()=>{s=hn(s,x.goal_id),c()},B.append(w)}c();let g=a("button",T("#6366f1"),"Save funnel"),y=a("button",U(A({},T("transparent")),{opacity:"0.6"}),"Cancel");y.onclick=O,g.onclick=async()=>{let x=yn(d.value,s);if(!x.ok){h(`\u26A0 ${x.error}`,!1);return}h("Saving\u2026");let w=await G(n,`/v1/editor/funnels/${encodeURIComponent(x.funnelId)}`,x.body);w.r==="ok"&&(p("draft_saved",{kind:"funnel"}),O(),On(x.funnelId)),X(w,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},B.append(g,y)},je.onclick=async()=>{var c,g;let e=Ee;if(!e)return;h("Loading funnels\u2026");let o=await pt(n,"/v1/editor/funnels"),s=(c=o==null?void 0:o.funnels)!=null?c:[];if(s.length===0){h("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await pt(n,"/v1/editor/goals"),d=new Map(((g=l==null?void 0:l.goals)!=null?g:[]).map(y=>[y.goal_id,y.display_name]));qe([{key:"funnel",label:"Funnel",type:"select",options:s.map(y=>ct(y))},{key:"step",label:"Which step does this element serve?",type:"select",options:ut(s[0],d).map(y=>y.label)}],"Attach",async y=>{var E;let b=(E=s.find(S=>ct(S)===y.funnel))!=null?E:s[0],x=ut(b,d).findIndex(S=>S.label===y.step);if(x<0){h("\u26A0 Pick which step this element serves.",!1);return}h("Attaching\u2026");let w=await G(n,`/v1/editor/funnels/${encodeURIComponent(b.funnel_id)}/assign`,{slotId:e,stepIndex:x});w.r==="ok"&&O(),X(w,`\u2713 Attached \u2014 this test now works toward \u201C${b.display_name}\u201D.`)});let m=B.querySelector('select[data-field="funnel"]'),f=B.querySelector('select[data-field="step"]');m&&f&&m.addEventListener("change",()=>{var b;let y=(b=s.find(x=>ct(x)===m.value))!=null?b:s[0];f.length=1;for(let x of ut(y,d)){let w=document.createElement("option");w.value=x.label,w.textContent=x.label,f.append(w)}})},F.onclick=()=>{if(!t||!N)return;p("form_opened",{kind:"style"});let e=N;qe([{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:Mt.length?`Font (this site has: ${Mt.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(f,c)=>{var E;let{style:g,errors:y}=Ht(f),b=!1;for(let S of Rt)c(S,(E=y[S])!=null?E:null),y[S]&&(b=!0);if(b){h("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(g).length===0){h("\u26A0 Enter at least one style change.",!1);return}let x=Ke("style",e,t);h("Saving\u2026");let w=await G(n,`/v1/editor/slots/${encodeURIComponent(x)}`,{kind:"arms",target:e,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:g}}]}});w.r==="ok"&&(p("draft_saved",{kind:"slot"}),Jt(),O(),nt(x,Ce(t),"b")),X(w,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let o=t,s=o.style.cssText;we=()=>{o.style.cssText=s};let l={},d=()=>{let{style:f}=Ht(l);o.style.cssText=s;for(let[c,g]of Object.entries(f)){let y=dt[c];y&&Je(g)&&o.style.setProperty(y,g.trim(),"important")}};for(let f of Rt){let c=B.querySelector(`[data-field="${f}"]`);if(!c)continue;let g=()=>{l[f]=c.value,d()};c.addEventListener("input",g),c.addEventListener("change",g)}let m=[de==null?void 0:de.primaryBg,de==null?void 0:de.primaryText,"#ffffff"].filter(f=>!!f).map(gt).filter((f,c,g)=>yt(f)&&g.indexOf(f)===c);for(let f of["color","background"]){let c=B.querySelector(`input[data-field="${f}"]`);if(!c)continue;let g=a("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let y of m){let b=a("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:y,padding:"0"});b.title=y,b.onclick=()=>{c.value=gt(y),c.dispatchEvent(new Event("input"))},g.append(b)}c.after(g)}};let sn=e=>{var l;let o=e==="text"?P:F;if(o.disabled)return h(o.title||"This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section.",!1),!1;vt(e);let s=e==="text"?'[data-field="alt"]':'[data-field="color"]';return B.querySelector(s)||(l=o.onclick)==null||l.call(o,new MouseEvent("click")),!0},zn=()=>{if(!t)return;se.textContent="";let e=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"}),o=a("input",{width:"100%",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"});o.type="text",o.maxLength=300,o.placeholder="e.g. shorter and more urgent",o.setAttribute("data-field","ai-instruction");let s=a("button",U(A({},T("#6366f1")),{display:"inline-block",width:"auto",margin:"8px 0 0",padding:"4px 10px",fontSize:"11px"}),"Go");s.setAttribute("data-action","ai-go"),s.onclick=()=>{Nn(o.value.trim())},o.onkeydown=l=>{var d;l.key==="Enter"&&(l.preventDefault(),(d=s.onclick)==null||d.call(s,new MouseEvent("click")))},e.append(a("div",{fontWeight:"600",marginBottom:"4px"},"What should this element do differently?"),o,a("div",{opacity:"0.7",fontSize:"11px",marginTop:"4px"},"Leave it blank for ideas. Nothing goes live \u2014 you review and save whatever comes back."),s),se.append(e),o.focus()};ie.onclick=()=>zn();let Nn=async e=>{var c,g;if(!t)return;let o=t;ie.disabled=!0;let s=ie.textContent;ie.textContent="Thinking\u2026",se.textContent="",p("form_opened",{kind:"suggest"});let l={},d=null;try{let y=await fetch(`${n.apiBase}/v1/editor/suggest`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(A(A({element:{tag:o.tagName.toLowerCase(),text:((c=o.textContent)!=null?c:"").replace(/\s+/g," ").trim().slice(0,400)},pageUrl:window.location.pathname},e?{instruction:e.slice(0,300)}:{}),de?{palette:de}:{}))});y.ok?l=await y.json():d=y.status===401?"expired":"error"}catch(y){d="error"}if(ie.disabled=!1,ie.textContent=s,t!==o)return;if(d){h(d==="expired"?"Editor session expired \u2014 reopen it from your dashboard to keep editing.":"\u26A0 Couldn\u2019t get suggestions \u2014 check your connection and try again.",!1);return}if(l.locked){h("AI suggestions aren\u2019t included in this plan.",!1);return}if(l.exhausted){h("You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.",!1);return}let m=(g=l.suggestions)!=null?g:[];if(m.length===0){h(e?"Couldn\u2019t do that safely on this element \u2014 try asking for a smaller change, or pick a headline or a button.":"No safe suggestions for this element \u2014 try a headline, a button, or a section.",!1);return}let f=(y,b)=>{let x=B.querySelector(`[data-field="${y}"]`);x&&(x.value=b,x.dispatchEvent(new Event("input")))};for(let y of m){let b=a("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)"});b.append(a("div",{fontWeight:"600",marginBottom:"2px"},y.title),a("div",{opacity:"0.75",marginBottom:"6px"},y.reason));let x=a("button",U(A({},T("#6366f1")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 10px",fontSize:"11px"}),"Try it");x.onclick=()=>{var w,E;if(t!==o){se.textContent="";return}if(se.textContent="",y.kind==="text"){if(!sn("text"))return;f("alt",y.variant)}else if(y.kind==="style"){if(!sn("style"))return;for(let[S,M]of Object.entries(y.style))if(S==="color"||S==="background"){let R=gt(M);yt(R)&&f(S,R)}else S==="textAlign"?f(S,M==="start"?"left":M==="end"?"right":M):f(S,M)}else{let S=y.goalType==="form_submit"&&!C.disabled;if(!S&&Y.disabled){h("This element can\u2019t be tracked reliably \u2014 select a specific button or link instead.",!1);return}vt("goals"),S?(w=C.onclick)==null||w.call(C,new MouseEvent("click")):(E=Y.onclick)==null||E.call(Y,new MouseEvent("click"))}},b.append(x),se.append(b)}},Bt=e=>{if(!t)return;let o=t.parentElement;if(!o)return;Te||(Ue=o,ot=t.nextSibling,Te=!0),e==="up"&&He?o.insertBefore(t,He):e==="down"&&Ie&&o.insertBefore(t,Ie.nextSibling);let s=mt(t,document);He=s.prevEl,Ie=s.nextEl,ee=s.prevLocator,Se=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}L(),St(!0),h("Previewing the new position \u2014 keep moving, save, or undo.")};pe.onclick=()=>Bt("up"),fe.onclick=()=>Bt("down"),Ze.onclick=()=>{Ge(),h("Move undone \u2014 back to the original position.")},Xe.onclick=async()=>{if(!t||!N||!Te||!Re)return;let e=ee?"moveAfter":"moveBefore",o=ee!=null?ee:Se;if(!o){h("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=Ke("move",N,t);h("Saving\u2026");let l=await G(n,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:N,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[e]:o}}]}});l.r==="ok"&&(p("draft_saved",{kind:"move"}),Te=!1,Ue=null,ot=null,St(!1),nt(s,Ce(t),"b")),X(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let Dn=()=>{var e,o;p("editor_closed"),u(),window.removeEventListener("pagehide",u),i&&clearTimeout(i),Ge(),Vt(),document.removeEventListener("mousemove",en,!0),document.removeEventListener("click",on,!0),document.removeEventListener("keydown",nn,!0),window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D),Fe(document),(e=document.getElementById($t))==null||e.remove(),k.remove(),$.remove(),I.remove(),ve.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),lt()},_t=!1;Be.onclick=()=>{if((Me||Te)&&!_t){_t=!0,h("\u26A0 Unsaved changes \u2014 click \u201CClose editor\u201D again to discard them.",!1);return}Dn()},document.addEventListener("mousemove",en,!0),document.addEventListener("click",on,!0),document.addEventListener("keydown",nn,!0),window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),Qe(),p("editor_opened")}function T(n){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:n,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}var Ln="sentient-preview-bar";async function Eo(n,t){var I,be,V,j,H,q,W,Z,P,F,ce,Y;try{fetch(`${n.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify({events:[{kind:"previewed"}]})}).catch(()=>{})}catch(C){}let r=null;try{let C=await fetch(`${n.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${n.token}`}});C.ok&&(r=(be=((I=(await C.json()).slots)!=null?I:[]).find(ue=>ue.slot_id===t&&ue.kind==="arms"))!=null?be:null)}catch(C){}let i=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});i.id=Ln;let u=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");u.onclick=()=>{lt();let C=new URL(location.href);for(let Q of["sentient_editor","sentient_preview","sentient_arm"])C.searchParams.delete(Q);location.assign(C.toString())};let p=a("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 C=new URL(location.href);for(let Q of["sentient_preview","sentient_arm"])C.searchParams.delete(Q);location.assign(C.toString())};let k=(q=(H=(V=r==null?void 0:r.draft_config)==null?void 0:V.arms)!=null?H:(j=r==null?void 0:r.published_config)==null?void 0:j.arms)!=null?q:[];if(!r||k.length===0){i.append(a("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 $=new URLSearchParams(location.search).get("sentient_arm"),L=(P=(Z=k.find(C=>C.id===$))!=null?Z:k[1])!=null?P:k[0];i.append(a("span",{fontWeight:"700"},`Previewing: ${(F=r.display_name)!=null?F:r.slot_id}`));let D=r.target&&typeof r.target=="object"?he(r.target,document):null;if(!D)i.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{mn(D,L.ops,`preview-${r.slot_id}`,document);try{D.scrollIntoView({block:"center"})}catch(C){}for(let C of k){let Q=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:C.id===L.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ce=C.displayName)!=null?ce:C.id);Q.onclick=()=>{let ue=new URL(location.href);ue.searchParams.set("sentient_arm",C.id),location.assign(ue.toString())},i.append(Q)}}i.append(p,u),((Y=document.body)!=null?Y:document.documentElement).append(i)}async function So(){if(typeof document=="undefined")return;let n=po();if(!n)return;let t=await fo(n);if(!t.ok){t.unauthorized?(lt(),bn(co)):bn(uo);return}let r=new URLSearchParams(location.search).get("sentient_preview");if(r){document.getElementById(Ln)||await Eo(n,r);return}if(document.getElementById(De))return;Cn(n);let i=pn(document);de=i,i&&G(n,"/v1/editor/palette",i);let u=await ho(n);wn(u),En(u,document)}So();return Vn(To);})();
24
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function _n(e){var i,c;Rn(),(i=document.getElementById(kt))==null||i.remove();let t=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=kt;let r=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(r,a("div",{},e)),((c=document.body)!=null?c:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function Lo(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Bo(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 r=(await t.json()).projectId;return r?{ok:!0,projectId:r}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function qt(e,t){return H(H(H(H({r:e===401?"expired":"error",status:e},typeof(t==null?void 0:t.error)=="string"?{code:t.error}:{}),typeof(t==null?void 0:t.message)=="string"?{message:t.message}:{}),typeof(t==null?void 0:t.feature)=="string"?{feature:t.feature}:{}),typeof(t==null?void 0:t.plan)=="string"?{plan:t.plan}:{})}async function Q(e,t,r){try{let i=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(r)});if(i.ok)return{r:"ok"};let c=await i.json().catch(()=>null);return qt(i.status,c)}catch(i){return{r:"error"}}}async function Ao(e,t){try{let r=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(r.ok)return{r:"ok"};let i=await r.json().catch(()=>null);return qt(r.status,i)}catch(r){return{r:"error"}}}async function _o(e,t,r){try{let i=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(r)}),c=await i.json().catch(()=>null);return i.ok?{r:"ok",data:c,outcome:{r:"ok"}}:{r:i.status===401?"expired":"error",data:c,outcome:qt(i.status,c)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var Dt=[];function wt(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function xt(e){let t=e.trim();if(wt(t))return t;let r=/^#([0-9a-fA-F]{3})$/.exec(t);if(r)return`#${r[1].split("").map(u=>u+u).join("")}`;let i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!i)return t;let c=u=>Math.min(255,Number(u)).toString(16).padStart(2,"0");return`#${c(i[1])}${c(i[2])}${c(i[3])}`}var ye=null,Mn=[];function In(e){Mn=e}async function $o(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let r=await t.json();return Dt=Array.isArray(r.fonts)?r.fonts.filter(i=>typeof i=="string"):[],Array.isArray(r.targets)?r.targets:[]}catch(t){return[]}}async function yt(e,t){try{let r=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return r.ok?await r.json():null}catch(r){return null}}function We(e=document){for(let t of Array.from(e.querySelectorAll(`.${Nt}`)))t.remove()}function Hn(e,t=document){var i;We(t);let r=0;for(let c of e){if(r>=So)break;let u=he(c.locator,t);if(!u)continue;let k=u.getBoundingClientRect(),T=a("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)"});T.className=Nt;let x=a("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"},c.label);x.className=Nt,((i=t.body)!=null?i:t.documentElement).append(T,x),r+=1}}function vt(e,t){let r=e.previousElementSibling,i=e.nextElementSibling,c=r?Ue(r,t):null,u=i?Ue(i,t):null;return{prevEl:r,nextEl:i,prevLocator:r&&c&&Qe(c,r,t)?c:null,nextLocator:i&&u&&Qe(u,i,t)?u:null}}var Ro=/testimonial|review|quote/i;function Pn(e){let t=[],r=e.headings.length>=1,i=e.links.length>=1;return r&&i&&t.push("hero","cta_band"),e.headings.length>=2&&e.paragraphs.length>=2&&t.push("feature_grid"),e.quotes.length>=1&&t.push("testimonial"),t}var jt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Mo=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Io=new Set(["left","center","right","justify","start","end"]),Ho=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Po=/^(rgb|rgba|hsl|hsla)\(/i;function zo(e){return Ho.test(e)||Po.test(e)}function zn(e,t){switch(e){case"fontSize":case"borderRadius":return Mo.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 Io.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return zo(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let r=t.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&r.length>=1&&r.length<=5&&r.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(e){let t={},r={};for(let i of jt){let c=e[i];if(typeof c!="string")continue;let u=c.trim();if(u==="")continue;if(!tt(u)){r[i]="That value isn\u2019t allowed.";continue}let k=zn(i,u);if(k){r[i]=k;continue}t[i]=u}return{style:t,errors:r}}function a(e,t,r){let i=document.createElement(e);return Object.assign(i.style,t),r!==void 0&&(i.textContent=r),i}function On(e){var gn;let t=null,r=[],i=null,c=()=>{for(;r.length>0;){let n=r.splice(0,20);try{fetch(`${e.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({events:n})}).catch(()=>{})}catch(o){}}},u=(n,o)=>{r.push(H({kind:n},o?{meta:o}:{})),i&&clearTimeout(i),i=setTimeout(c,2e3)};window.addEventListener("pagehide",c);let k=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});k.id=wo;let T=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});T.id=Eo;let x=()=>{if(!t||!t.isConnected){T.style.display="none";return}let n=t.getBoundingClientRect();Object.assign(T.style,{display:"block",left:`${n.left-2}px`,top:`${n.top-2}px`,width:`${n.width}px`,height:`${n.height}px`})},_=()=>x();Rn();let P=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",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"});P.id=Ge;let X=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});X.className="sntedi-dot";let F=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});F.append(X,a("span",{},"SentientUI"));let M=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),I=!1,U=a("button",A("#374151"),"Pause selecting");U.onclick=()=>{I=!I,U.textContent=I?"Resume selecting":"Pause selecting",I?(k.style.display="none",We(document),y("Selection paused \u2014 browse normally, then resume.")):y("Click any element on the page to adapt it.")};let Y=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Z=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),N=a("button",A("#6366f1"),"Test different text here"),q=a("button",A("#374151"),"Change style"),te=a("button",A("#374151"),"Try a different layout for this section"),V=a("button",A("#374151"),"Track clicks as a goal"),m=a("button",A("#374151"),"Track form submissions as a goal"),D=a("button",A("#374151"),"Track page visits as a goal"),ne=a("button",A("#374151"),"Track reading this far as a goal"),j=a("button",A("#374151"),"Set up a funnel"),oe=a("button",A("#374151"),"Attach this test to a funnel step"),Ee=a("button",A("#10b981"),"Turn the funnel on"),be=a("button",A("#374151"),"Move up"),xe=a("button",A("#374151"),"Move down"),ot=a("button",A("#6366f1"),"Save this arrangement"),rt=a("button",A("#374151"),"Undo"),Re=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Close editor"),de=a("button",A("#10b981"),"Publish now \u2014 go live"),ce=a("button",A("#10b981"),"Start tracking now");for(let n of[N,q,te,V,be,xe])n.disabled=!0;let St=[N,q,te,V,m,be,xe];for(let n of St)n.style.display="none";ot.style.display="none",rt.style.display="none",de.style.display="none",ce.style.display="none",oe.style.display="none",Ee.style.display="none";let ue=a("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),Me=a("div",{}),Ut=[{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"}],re="text",Gt=new Map,ve=new Map,Tt=new Map,Wt=a("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Yt=a("div",{paddingTop:"10px"});for(let n of Ut){let o=a("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"});o.append(a("span",{fontSize:"11px",marginRight:"3px"},n.icon),a("span",{},n.label)),o.onclick=()=>Ct(n.id),Gt.set(n.id,o),Wt.append(o);let s=a("div",{display:"none"}),l=a("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});s.append(l),Tt.set(n.id,l),ve.set(n.id,s),Yt.append(s)}ve.get("text").append(N),ve.get("style").append(q),ve.get("layout").append(te,be,xe,ot,rt),ve.get("goals").append(V,m,D,ne),ve.get("funnels").append(j,oe,Ee);let ie=a("div",{});ve.get("drafts").append(ie);let it=()=>{var o,s;for(let l of Ut){let d=l.id===re,h=Gt.get(l.id);h.style.color=d?"#ffffff":"#9ca3af",h.style.borderBottom=d?"2px solid #6366f1":"2px solid transparent",ve.get(l.id).style.display=d?"block":"none",Tt.get(l.id).style.display="none"}let n=l=>{let d=Tt.get(re);d.textContent=l,d.style.display="block"};re==="text"?t?N.disabled?n(N.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(o=N.onclick)==null||o.call(N,new MouseEvent("click")):n("Click any text on the page to test a different wording."):re==="style"?t?q.disabled?n("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(s=q.onclick)==null||s.call(q,new MouseEvent("click")):n("Click any element on the page to change how it looks."):re==="layout"?t||n("Click a section to move it or lay it out differently. Layouts re-arrange the words already on the page \u2014 they never add a section you don\u2019t have."):re==="goals"?t||n("Page-level goals work right away; click a button or form to track it specifically."):re==="funnels"?n("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):re==="drafts"&&He()},Nn=(n,o,s)=>{n.onclick=()=>{if(n.dataset.armed==="1"){n.dataset.armed="",s();return}n.dataset.armed="1",n.textContent="Sure?",setTimeout(()=>{n.isConnected&&n.dataset.armed==="1"&&(n.dataset.armed="",n.textContent=o)},4e3)}},Ie=(n,o)=>a("button",K(H({},A(n)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),o),Vt=(n,o)=>{let s=new URL(window.location.href);s.searchParams.delete("sentient_editor"),s.searchParams.set("sentient_preview",n),o&&s.searchParams.set("sentient_arm",o),window.location.assign(s.toString())},st=(n,o,s)=>{let l=Ie("#374151","Discard");return Nn(l,"Discard",async()=>{l.disabled=!0;let d=await Ao(e,n);l.disabled=!1,se(d,o),d.r==="ok"&&s()}),l},Jt=(n,o)=>{Te.textContent="";let s=a("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=a("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...o),s.append(a("div",{marginBottom:"6px"},n),l),Te.append(s)},He=async()=>{var g,b,v,w,C,L,B,z,O,le,ge,Fe;ie.textContent="",ie.append(a("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let n=[],o=[],s=null,l=!1;if(await Promise.all([(async()=>{var E;try{let R=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});R.ok?n=(E=(await R.json()).slots)!=null?E:[]:s=R.status===401?"expired":"error"}catch(R){s="error"}})(),(async()=>{var E;try{let R=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});R.ok?o=(E=(await R.json()).goals)!=null?E:[]:l=!0}catch(R){l=!0}})()]),re!=="drafts")return;if(ie.textContent="",s){if(ie.append(a("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},s==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),s==="error"){let E=Ie("#374151","Retry");E.onclick=()=>{He()},ie.append(E)}return}let d=n.filter(E=>{var R,W,me,ke,$e,Xe;return((me=(W=(R=E.draft_config)==null?void 0:R.arms)==null?void 0:W.length)!=null?me:0)>0||((Xe=($e=(ke=E.published_config)==null?void 0:ke.arms)==null?void 0:$e.length)!=null?Xe:0)>0}),h=o.filter(E=>E.event!=="custom"&&(E.status==="draft"||E.status==="active"));if(d.length===0&&h.length===0&&!l){ie.append(a("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let f=E=>a("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:E?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:E?"#6ee7b7":"#c7d2fe"},E?"live":"draft"),p=E=>{let R=a("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),W=a("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},E);return R.append(W),{row:R,name:W}};for(let E of d){let{row:R}=p((g=E.display_name)!=null?g:E.slot_id);R.append(f(E.status==="published"));let W=(C=(w=(b=E.draft_config)==null?void 0:b.arms)!=null?w:(v=E.published_config)==null?void 0:v.arms)!=null?C:[],me=(z=(L=W[1])==null?void 0:L.id)!=null?z:(B=W[0])==null?void 0:B.id,ke=Ie("#374151","Preview");if(ke.onclick=()=>Vt(E.slot_id,me),R.append(ke),E.status!=="published"&&((ge=(le=(O=E.draft_config)==null?void 0:O.arms)==null?void 0:le.length)!=null?ge:0)>0){let $e=Ie("#10b981","Publish");$e.onclick=async()=>{$e.disabled=!0;let Xe=await Q(e,`/v1/editor/slots/${encodeURIComponent(E.slot_id)}/publish`,{});$e.disabled=!1,se(Xe,"\u2713 Published \u2014 live for new visitors."),Xe.r==="ok"&&(u("published",{kind:"slot"}),He())},R.append($e)}E.status!=="published"&&R.append(st(`/v1/editor/slots/${encodeURIComponent(E.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{on(E.slot_id),He()})),ie.append(R)}if(l)ie.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(h.length>0){ie.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let E of h){let{row:R}=p((Fe=E.display_name)!=null?Fe:E.goal_id);if(R.append(f(E.status==="active")),E.status==="draft"){let W=Ie("#10b981","Start tracking");W.onclick=async()=>{W.disabled=!0;let me=await Q(e,`/v1/editor/goals/${encodeURIComponent(E.goal_id)}/publish`,{});W.disabled=!1,se(me,"\u2713 Tracking is live \u2014 it counts from your next visitor."),me.r==="ok"&&(u("published",{kind:"goal"}),He())},R.append(W,st(`/v1/editor/goals/${encodeURIComponent(E.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{rn(E.goal_id),He()}))}ie.append(R)}}},Ct=n=>{re!==n&&(G(),Je(),re=n,it())},Kt=a("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(F.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Xt=!1,Se=a("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)"}),Zt=a("span",{width:"7px",height:"7px",borderRadius:"50%",background:"#34d399",display:"inline-block"});Zt.className="sntedi-dot",Se.append(Zt,a("span",{},"S")),Se.title="Open the SentientUI editor";let Qt=a("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");Qt.onclick=()=>{P.style.display="none",Se.style.display="flex",Xt=I,I=!0,k.style.display="none",We(document)},Se.onclick=()=>{P.style.display="block",Se.style.display="none",I=Xt},Object.assign(U.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Object.assign(Re.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",whiteSpace:"nowrap"}),Kt.append(F,U,Qt,Re);let en=a("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),Te=a("div",{});Object.assign(Z.style,{marginBottom:"4px"}),en.append(Te,Z,de,ce);let pe=a("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"},"\u2728 Ask AI"),Lt=a("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(Y.style,{flex:"1 1 auto",marginBottom:"0"}),Lt.append(Y,pe),Object.assign(Lt.style,{marginBottom:"6px"});let fe=a("div",{}),$=a("div",{marginTop:"4px"});$.addEventListener("input",()=>{Pe=!0}),$.addEventListener("change",()=>{Pe=!0}),P.append(Kt,M,Lt,ue,Me,fe,Wt,Yt,$,en),((gn=document.body)!=null?gn:document.documentElement).append(k,T,P,Se);let Ce=null,tn=()=>{Ce==null||Ce(),Ce=null},nn=()=>{Ce=null},Pe=!1,Bt=null,G=()=>{tn(),$.textContent="",Pe=!1,Bt=null,Ht=!1},Ye=(n,o,s)=>{var b;G();let l={},d={},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 v of n){let w=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},v.label);if($.append(w),v.type==="select"){let L=a("select",h);L.setAttribute("data-field",v.key);let B=document.createElement("option");B.value="",B.textContent="\u2014 no change \u2014",L.append(B);for(let z of(b=v.options)!=null?b:[]){let O=document.createElement("option");O.value=z,O.textContent=z,L.append(O)}l[v.key]=()=>L.value,$.append(L)}else if(v.type==="color"){let L=a("input",K(H({},h),{padding:"2px",height:"34px"}));L.type="color",L.setAttribute("data-field",v.key);let B=!1;L.addEventListener("input",()=>{B=!0}),l[v.key]=()=>B?L.value:"",$.append(L)}else{let L=a("input",h);L.setAttribute("data-field",v.key),v.value!==void 0&&(L.value=v.value),l[v.key]=()=>L.value,$.append(L)}let C=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});C.setAttribute("data-feedback",v.key),d[v.key]=C,$.append(C)}let f=(v,w)=>{let C=d[v];C&&(C.textContent=w!=null?w:"",C.style.display=w?"block":"none")},p=a("button",A("#6366f1"),o),g=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Cancel");p.onclick=()=>s(Object.fromEntries(Object.entries(l).map(([v,w])=>[v,w()])),f),g.onclick=G,$.append(p,g)},y=(n,o=!0)=>{Z.textContent=n,Z.style.color=o?"#a7f3d0":"#fca5a5"},At=(n,o)=>{var l,d;if(u("error_shown",{code:(d=n.code)!=null?d:`http_${(l=n.status)!=null?l:"network"}`}),n.code==="plan_limit_reached"){let h=n.feature==="live_goals"?"live goal":"of these",f=n.plan?`${n.plan} plan`:"plan";return n.feature==="live_goals"?`Your ${f} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${f} has reached its limit for ${h}. 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 s=n.status?` (HTTP ${n.status})`:"";return`\u26A0 Couldn\u2019t ${o} \u2014 try again.${s}`},se=(n,o)=>{n.r==="ok"?y(o,!0):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):y(At(n,"save"),!1)},Le=null,at=n=>n.length>30?`${n.slice(0,27)}\u2026`:n,on=n=>{Le===n&&(Le=null,de.style.display="none",oe.style.display="none",Te.textContent="")},rn=n=>{je===n&&(je=null,ce.style.display="none",Te.textContent="")},lt=(n,o,s)=>{Le=n,de.textContent=o?`Publish \u201C${at(o)}\u201D \u2014 go live`:"Publish now \u2014 go live",de.style.display="block",oe.style.display="block";let l=[];if(s){let d=Ie("#374151","Preview");d.onclick=()=>Vt(n,s),l.push(d)}l.push(st(`/v1/editor/slots/${encodeURIComponent(n)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>on(n))),Jt(o?`Draft saved for \u201C${at(o)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};de.onclick=async()=>{if(!Le)return;de.disabled=!0,y("Publishing\u2026");let n=await Q(e,`/v1/editor/slots/${encodeURIComponent(Le)}/publish`,{});de.disabled=!1,n.r==="ok"?(u("published",{kind:"slot"}),y("\u2713 Published \u2014 live for new visitors.",!0),de.style.display="none",Le=null,Te.textContent=""):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):y(At(n,"publish"),!1)};let J=null,ze=!1,Oe=null,Ne=null,ae=null,Be=null,Ve=null,dt=null,Ae=!1,sn=(n,o)=>ze?n?"":`Nothing to swap with ${o} \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.",an=()=>{be.disabled=!ze||!ae,xe.disabled=!ze||!Be,be.title=be.disabled?sn(ae,"above"):"",xe.title=xe.disabled?sn(Be,"below"):""},_t=n=>{ot.style.display=n?"block":"none",rt.style.display=n?"block":"none",an()},Je=()=>{if(Ae&&t&&Ve&&Ve.insertBefore(t,dt),Ae=!1,Ve=null,dt=null,t){let n=vt(t,document);Oe=n.prevEl,Ne=n.nextEl,ae=n.prevLocator,Be=n.nextLocator}x(),_t(!1)},ln=n=>{if(I)return;let o=n.target;if(!o||P.contains(o)||o===k)return;We(document);let s=o.getBoundingClientRect();Object.assign(k.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},_e=n=>{var s;let o=((s=n.textContent)!=null?s:"").trim().replace(/\s+/g," ");return o?o.length>40?`${o.slice(0,37)}\u2026`:o:n.tagName.toLowerCase()},Dn=n=>!!n.id||["section","header","footer","nav","main","form","article","aside"].includes(n.tagName.toLowerCase())||!!n.querySelector(":scope > h1, :scope > h2, :scope > h3"),jn=n=>{var l;let o=n.querySelector("h1, h2, h3"),s=(l=o==null?void 0:o.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return s?s.length>28?`${s.slice(0,25)}\u2026`:s:n.id?`#${n.id.length>24?`${n.id.slice(0,21)}\u2026`:n.id}`:`<${n.tagName.toLowerCase()}>`},Fn=n=>{ue.textContent="";let o=[];for(let f=n.parentElement;f&&f!==document.body&&o.length<3;f=f.parentElement)Dn(f)&&o.push(f);let s=_e(n),l=()=>a("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),d=!0;for(let f of o){let p=jn(f);if(p===s||s.startsWith(p))continue;let g=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);g.onclick=()=>ct(f),d||ue.append(l()),ue.append(g),d=!1}d||ue.append(l());let h=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");h.onclick=()=>dn(),ue.append(h),ue.style.display="block"},qn=n=>{Me.textContent="";let o=null,s=0;for(let d=n.parentElement;d&&d!==document.body&&s<6;d=d.parentElement,s++)if(Qe(Ue(d,document),d,document)){o=d;break}let l=a("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(o){let d=o;l.append(a("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 h=a("button",K(H({},A("#6366f1")),{marginTop:"0"}),`Select \u201C${_e(d)}\u201D instead`);h.onclick=()=>ct(d);let f=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Pick something else");f.onclick=()=>{Me.textContent=""},l.append(h,f)}else l.append(a("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));Me.append(l)},ct=n=>{Je(),G(),Me.textContent="",t=n,J=Ue(n,document);let o=Qe(J,n,document);ze=o,x(),Y.style.display="block",Y.textContent=`Selected: ${_e(n)}`,Fn(n),u("element_selected",{unique:o}),y(o?"\u2713 Matches exactly 1 element":"",o),o||qn(n),M.style.display="none",pe.style.display="inline-block",fe.textContent="";for(let h of St)h.style.display="block";N.style.display="none",q.style.display="none";let s=n.childElementCount===0;N.disabled=!o||!s,N.title=o?s?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",q.disabled=!o,te.disabled=!o,V.disabled=!o;let l=n.closest("form");m.style.display=l?"block":"none",m.disabled=!l;let d=vt(n,document);Oe=d.prevEl,Ne=d.nextEl,ae=d.prevLocator,Be=d.nextLocator,an(),it()},dn=()=>{Je(),G(),t=null,J=null,ze=!1,Oe=null,Ne=null,ae=null,Be=null,x(),Me.textContent="",fe.textContent="",ue.textContent="",ue.style.display="none",Y.textContent="",Y.style.display="none",pe.style.display="none";for(let n of St)n.style.display="none";M.style.display="block",y(""),it()},De=!1,$t=-1,cn=n=>{var l,d;let o=n.target,s=!!((l=o==null?void 0:o.closest)!=null&&l.call(o,'input, textarea, select, [contenteditable="true"]'));if(n.key==="Escape"){if($.childElementCount>0){G(),De=!1;return}if(t){dn(),De=!1;return}if(!De){De=!0,y("Press Esc again to close the editor.");return}De=!1,(d=Re.onclick)==null||d.call(Re,new MouseEvent("click"));return}if(De=!1,!(s||I)){if(n.key==="ArrowUp"||n.key==="ArrowDown"){if(!t||(n.key==="ArrowUp"?be:xe).disabled)return;n.preventDefault(),It(n.key==="ArrowUp"?"up":"down");return}if(n.key==="Tab"){let h=[];for(let p of Mn){let g=he(p.locator,document);g&&!h.includes(g)&&h.push(g)}if(h.length===0)return;if(Pe){y("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),n.preventDefault();return}n.preventDefault(),$t=($t+(n.shiftKey?-1:1)+h.length)%h.length;let f=h[$t];ct(f);try{f.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},un=n=>{if(I)return;let o=n.target;if(!(!o||P.contains(o))){if(n.preventDefault(),n.stopPropagation(),Pe&&o!==t&&Bt!==o){Bt=o,y("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}ct(o)}};N.onclick=()=>{var h,f,p;if(!t||!J)return;u("form_opened",{kind:"text"});let n=J,o=(f=(h=t.textContent)==null?void 0:h.trim())!=null?f:"";Ye([{key:"current",label:"Current wording",value:o},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async g=>{let b=g.alt.trim();if(!b){y("\u26A0 Enter alternative wording to test.",!1);return}if(b===g.current.trim()){y("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let v=nt("text",n,t);y("Saving\u2026");let w=await Q(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:n,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:g.current}},{id:"b",displayName:"Alternative",ops:{text:g.alt}}]}});w.r==="ok"&&(u("draft_saved",{kind:"slot"}),nn(),G(),lt(v,_e(t),"b")),se(w,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let s=t,l=(p=s.textContent)!=null?p:"";Ce=()=>{s.textContent=l};let d=$.querySelector('input[data-field="alt"]');d==null||d.addEventListener("input",()=>{s.textContent=d.value.trim()===""?l:d.value})};let Ke=null,pn=n=>{let o=p=>{var g;return((g=p.textContent)!=null?g:"").replace(/\s+/g," ").trim()},s=Array.from(n.querySelectorAll("h1,h2,h3,h4")).map(o).filter(Boolean);if(s.length===0){let p=n.closest("h1,h2,h3,h4");p&&s.push(o(p))}let l=Array.from(n.querySelectorAll("p")).map(o).filter(p=>p.length>0&&p.length<=300),d=[];for(let p of Array.from(n.querySelectorAll("a[href], button"))){let g=o(p);if(!g||g.length>60)continue;let b="",v=p.getAttribute("href");if(v)try{let w=new URL(v,window.location.href);w.protocol==="https:"&&(b=w.href)}catch(w){}d.push({label:g,href:b})}let h=Array.from(n.querySelectorAll("blockquote, q")).map(o).filter(Boolean);if(h.length===0&&Ro.test(`${n.className} ${n.id}`))for(let p of l)p.length>=20&&h.push(p);let f=Array.from(n.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(o).filter(p=>p.length>0&&p.length<=80);return{headings:s,paragraphs:l,links:d,quotes:h,attributions:f}},Un=(n,o)=>{var l,d,h,f,p,g,b,v,w,C,L,B,z,O,le,ge,Fe,E,R,W;let s=me=>{var ke;return o.paragraphs.length>=3&&(ke=o.paragraphs[o.paragraphs.length-3+me])!=null?ke:""};switch(n){case"headline":return(l=o.headings[0])!=null?l:"";case"supporting":return(d=o.paragraphs[0])!=null?d:"";case"cta_label":return(f=(h=o.links[0])==null?void 0:h.label)!=null?f:"";case"cta_href":return(g=(p=o.links[0])==null?void 0:p.href)!=null?g:"";case"secondary_label":return(v=(b=o.links[1])==null?void 0:b.label)!=null?v:"";case"secondary_href":return(C=(w=o.links[1])==null?void 0:w.href)!=null?C:"";case"quote":case"q1":return(L=o.quotes[0])!=null?L:"";case"q2":return(B=o.quotes[1])!=null?B:"";case"q3":return(z=o.quotes[2])!=null?z:"";case"name":case"n1":return(O=o.attributions[0])!=null?O:"";case"n2":return(le=o.attributions[1])!=null?le:"";case"n3":return(ge=o.attributions[2])!=null?ge:"";case"role":return(Fe=o.attributions[1])!=null?Fe:"";case"eyebrow":return"";case"f1_title":return(E=o.headings[1])!=null?E:"";case"f2_title":return(R=o.headings[2])!=null?R:"";case"f3_title":return(W=o.headings[3])!=null?W:"";case"f1_body":return s(0);case"f2_body":return s(1);case"f3_body":return s(2);default:return""}},Gn=(n,o,s)=>{u("form_opened",{kind:"arrangement"});let l=pn(s);Ye(n.fields.map(d=>({key:d.id,label:d.kind==="href"?`${d.label} (https link \u2014 required)`:d.label,value:Un(d.id,l)})),"Save draft",async(d,h)=>{var w,C,L,B,z;let f=!1,p=!1;for(let O of n.fields){if(O.kind==="href"){let ge=!1;try{ge=new URL((w=d[O.id])!=null?w:"").protocol==="https:"}catch(Fe){}h(O.id,ge?null:"Links need to start with https://"),ge||(f=!0);continue}let le=((C=d[O.id])!=null?C:"").trim()==="";h(O.id,le?"Fill this in with your own words":null),le&&(p=!0)}if(f){y("\u26A0 Fix the highlighted link(s).",!1);return}if(p){y("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}y("Saving\u2026");let g=await _o(e,`/v1/editor/arrangements/${encodeURIComponent(n.id)}/instantiate`,{fields:d});if(g.r!=="ok"||!((L=g.data)!=null&&L.blocks)){g.r==="expired"?se(g.outcome,""):y(`\u26A0 ${(z=(B=g.data)==null?void 0:B.reason)!=null?z:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let b=nt("arrange",o,s),v=await Q(e,`/v1/editor/slots/${encodeURIComponent(b)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:n.id,displayName:n.name,blocks:g.data.blocks}],baseline:"original"}});v.r==="ok"&&(u("draft_saved",{kind:"arrangement"}),G(),lt(b,n.name,n.id)),se(v,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")})};te.onclick=async()=>{var h,f;if(!t||!J)return;let n=J,o=t;if(G(),y("Loading arrangements\u2026"),!Ke){let p=await yt(e,"/v1/editor/arrangements");Ke=(h=p==null?void 0:p.arrangements)!=null?h:null}if(!Ke||Ke.length===0){y("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let s=Pn(pn(o)),l=Ke.filter(p=>s.includes(p.sectionType));if(l.length===0){y("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}y("Pick a layout for this section \u2014 your own words are carried across.");for(let p of l){let g=a("button",K(H({},A("#374151")),{textAlign:"left"}));g.append(a("div",{fontWeight:"600"},p.name),a("div",{fontSize:"11px",opacity:"0.7"},p.description)),g.onclick=()=>Gn(p,n,o),$.append(g)}let d=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Cancel");d.onclick=G,$.append(d),(f=$.scrollIntoView)==null||f.call($,{block:"nearest"})};let je=null,Wn=(n,o)=>{je=n,ce.textContent=o?`Start tracking \u201C${at(o)}\u201D now`:"Start tracking now",ce.style.display="block",Jt(o?`Goal \u201C${at(o)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[st(`/v1/editor/goals/${encodeURIComponent(n)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>rn(n))])};ce.onclick=async()=>{if(!je)return;ce.disabled=!0,y("Activating\u2026");let n=await Q(e,`/v1/editor/goals/${encodeURIComponent(je)}/publish`,{});ce.disabled=!1,n.r==="ok"?(u("published",{kind:"goal"}),y("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ce.style.display="none",je=null,Te.textContent=""):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):y(At(n,"activate"),!1)};let Rt=(n,o)=>`${bt(n)||"goal"}-${$n(o)}`.slice(0,128),Yn=n=>{var l,d,h;let o=((l=n.textContent)!=null?l:"").replace(/\s+/g," ").trim();return o&&o.length<=60?o:((h=(d=n.getAttribute("aria-label"))!=null?d:n.getAttribute("id"))!=null?h:"").trim()||"element-clicked"},ut=async(n,o,s)=>{y("Saving\u2026");let l=await Q(e,`/v1/editor/goals/${encodeURIComponent(n)}`,o);l.r==="ok"&&(u("draft_saved",{kind:"goal"}),Wn(n,s)),se(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live.")};V.onclick=()=>{if(!t||!J)return;let n=Rt(Yn(t),JSON.stringify(J));ut(n,{event:"click",locator:J},_e(t))},m.onclick=()=>{var l,d;let n=t==null?void 0:t.closest("form");if(!n)return;let o=Ue(n,document),s=(d=(l=n.getAttribute("id"))!=null?l:n.getAttribute("name"))!=null?d:"form-submitted";ut(Rt(s,JSON.stringify(o)),{event:"form_submit",locator:o},s)},D.onclick=()=>{let n=window.location.pathname||"/",o=bt(n)?`reached-${bt(n)}`:"page-visited";ut(Rt(o,n),{event:"url_reached",urlPattern:n},n)};let Mt=[{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}];ne.onclick=()=>{Ye([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Mt.map(n=>n.label)}],"Track it",n=>{var l;let o=(l=Mt.find(d=>d.label===n.depth))!=null?l:Mt[2],s=Math.round(o.value*100);ut(`read-${s}pct`,{event:"scroll_depth",threshold:o.value},`read ${s}%`),G()})};let pt=null,Vn=n=>{pt=n,Ee.style.display="block"};Ee.onclick=async()=>{if(!pt)return;Ee.disabled=!0,y("Turning on\u2026");let n=await Q(e,`/v1/editor/funnels/${encodeURIComponent(pt)}/publish`,{});Ee.disabled=!1,n.r==="ok"?(u("published",{kind:"funnel"}),y("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),Ee.style.display="none",pt=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)},j.onclick=async()=>{var v;y("Loading your goals\u2026");let n=await yt(e,"/v1/editor/goals"),o=(v=n==null?void 0:n.goals)!=null?v:[];if(o.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."),G();let s=[],l=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),d=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});$.append(l,d);let h=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");$.append(h);let f=new Map,p=()=>{var w,C;for(let[L,B]of f){let z=s.indexOf(L),O=(C=(w=o.find(le=>le.goal_id===L))==null?void 0:w.display_name)!=null?C:L;B.textContent=z===-1?O:`${z+1}. ${O}`,B.style.background=z===-1?"#374151":"#6366f1"}};for(let w of o){let C=a("button",K(H({},A("#374151")),{textAlign:"left"}));f.set(w.goal_id,C),C.onclick=()=>{s=Bn(s,w.goal_id),p()},$.append(C)}p();let g=a("button",A("#6366f1"),"Save funnel"),b=a("button",K(H({},A("transparent")),{opacity:"0.6"}),"Cancel");b.onclick=G,g.onclick=async()=>{let w=An(d.value,s);if(!w.ok){y(`\u26A0 ${w.error}`,!1);return}y("Saving\u2026");let C=await Q(e,`/v1/editor/funnels/${encodeURIComponent(w.funnelId)}`,w.body);C.r==="ok"&&(u("draft_saved",{kind:"funnel"}),G(),Vn(w.funnelId)),se(C,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},$.append(g,b)},oe.onclick=async()=>{var p,g;let n=Le;if(!n)return;y("Loading funnels\u2026");let o=await yt(e,"/v1/editor/funnels"),s=(p=o==null?void 0:o.funnels)!=null?p:[];if(s.length===0){y("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await yt(e,"/v1/editor/goals"),d=new Map(((g=l==null?void 0:l.goals)!=null?g:[]).map(b=>[b.goal_id,b.display_name]));Ye([{key:"funnel",label:"Funnel",type:"select",options:s.map(b=>mt(b))},{key:"step",label:"Which step does this element serve?",type:"select",options:ht(s[0],d).map(b=>b.label)}],"Attach",async b=>{var L;let v=(L=s.find(B=>mt(B)===b.funnel))!=null?L:s[0],w=ht(v,d).findIndex(B=>B.label===b.step);if(w<0){y("\u26A0 Pick which step this element serves.",!1);return}y("Attaching\u2026");let C=await Q(e,`/v1/editor/funnels/${encodeURIComponent(v.funnel_id)}/assign`,{slotId:n,stepIndex:w});C.r==="ok"&&G(),se(C,`\u2713 Attached \u2014 this test now works toward \u201C${v.display_name}\u201D.`)});let h=$.querySelector('select[data-field="funnel"]'),f=$.querySelector('select[data-field="step"]');h&&f&&h.addEventListener("change",()=>{var v;let b=(v=s.find(w=>mt(w)===h.value))!=null?v:s[0];f.length=1;for(let w of ht(b,d)){let C=document.createElement("option");C.value=w.label,C.textContent=w.label,f.append(C)}})},q.onclick=()=>{if(!t||!J)return;u("form_opened",{kind:"style"});let n=J;Ye([{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:Dt.length?`Font (this site has: ${Dt.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(f,p)=>{var L;let{style:g,errors:b}=Ft(f),v=!1;for(let B of jt)p(B,(L=b[B])!=null?L:null),b[B]&&(v=!0);if(v){y("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(g).length===0){y("\u26A0 Enter at least one style change.",!1);return}let w=nt("style",n,t);y("Saving\u2026");let C=await Q(e,`/v1/editor/slots/${encodeURIComponent(w)}`,{kind:"arms",target:n,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:g}}]}});C.r==="ok"&&(u("draft_saved",{kind:"slot"}),nn(),G(),lt(w,_e(t),"b")),se(C,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")});let o=t,s=o.style.cssText;Ce=()=>{o.style.cssText=s};let l={},d=()=>{let{style:f}=Ft(l);o.style.cssText=s;for(let[p,g]of Object.entries(f)){let b=gt[p];b&&tt(g)&&o.style.setProperty(b,g.trim(),"important")}};for(let f of jt){let p=$.querySelector(`[data-field="${f}"]`);if(!p)continue;let g=()=>{l[f]=p.value,d()};p.addEventListener("input",g),p.addEventListener("change",g)}let h=[ye==null?void 0:ye.primaryBg,ye==null?void 0:ye.primaryText,"#ffffff"].filter(f=>!!f).map(xt).filter((f,p,g)=>wt(f)&&g.indexOf(f)===p);for(let f of["color","background"]){let p=$.querySelector(`input[data-field="${f}"]`);if(!p)continue;let g=a("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let b of h){let v=a("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:b,padding:"0"});v.title=b,v.onclick=()=>{p.value=xt(b),p.dispatchEvent(new Event("input"))},g.append(v)}p.after(g)}};let fn=n=>{var l;let o=n==="text"?N:q;if(o.disabled)return y(o.title||"This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section.",!1),!1;Ct(n);let s=n==="text"?'[data-field="alt"]':'[data-field="color"]';return $.querySelector(s)||(l=o.onclick)==null||l.call(o,new MouseEvent("click")),!0},Jn=()=>{if(!t)return;fe.textContent="";let n=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"}),o=a("input",{width:"100%",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"});o.type="text",o.maxLength=300,o.placeholder="e.g. shorter and more urgent",o.setAttribute("data-field","ai-instruction");let s=a("button",K(H({},A("#6366f1")),{display:"inline-block",width:"auto",margin:"8px 0 0",padding:"4px 10px",fontSize:"11px"}),"Go");s.setAttribute("data-action","ai-go"),s.onclick=()=>{Kn(o.value.trim())},o.onkeydown=l=>{var d;l.key==="Enter"&&(l.preventDefault(),(d=s.onclick)==null||d.call(s,new MouseEvent("click")))},n.append(a("div",{fontWeight:"600",marginBottom:"4px"},"What should this element do differently?"),o,a("div",{opacity:"0.7",fontSize:"11px",marginTop:"4px"},"Leave it blank for ideas. Nothing goes live \u2014 you review and save whatever comes back."),s),fe.append(n),o.focus()};pe.onclick=()=>Jn();let Kn=async n=>{var p,g;if(!t)return;let o=t;pe.disabled=!0;let s=pe.textContent;pe.textContent="Thinking\u2026",fe.textContent="",u("form_opened",{kind:"suggest"});let l={},d=null;try{let b=await fetch(`${e.apiBase}/v1/editor/suggest`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(H(H({element:{tag:o.tagName.toLowerCase(),text:((p=o.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,400)},pageUrl:window.location.pathname},n?{instruction:n.slice(0,300)}:{}),ye?{palette:ye}:{}))});b.ok?l=await b.json():d=b.status===401?"expired":"error"}catch(b){d="error"}if(pe.disabled=!1,pe.textContent=s,t!==o)return;if(d){y(d==="expired"?"Editor session expired \u2014 reopen it from your dashboard to keep editing.":"\u26A0 Couldn\u2019t get suggestions \u2014 check your connection and try again.",!1);return}if(l.locked){y("AI suggestions aren\u2019t included in this plan.",!1);return}if(l.exhausted){y("You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.",!1);return}let h=(g=l.suggestions)!=null?g:[];if(h.length===0){y(n?"Couldn\u2019t do that safely on this element \u2014 try asking for a smaller change, or pick a headline or a button.":"No safe suggestions for this element \u2014 try a headline, a button, or a section.",!1);return}let f=(b,v)=>{let w=$.querySelector(`[data-field="${b}"]`);w&&(w.value=v,w.dispatchEvent(new Event("input")))};for(let b of h){let v=a("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)"});v.append(a("div",{fontWeight:"600",marginBottom:"2px"},b.title),a("div",{opacity:"0.75",marginBottom:"6px"},b.reason));let w=a("button",K(H({},A("#6366f1")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 10px",fontSize:"11px"}),"Try it");w.onclick=()=>{var C,L;if(t!==o){fe.textContent="";return}if(fe.textContent="",b.kind==="text"){if(!fn("text"))return;f("alt",b.variant)}else if(b.kind==="style"){if(!fn("style"))return;for(let[B,z]of Object.entries(b.style))if(B==="color"||B==="background"){let O=xt(z);wt(O)&&f(B,O)}else B==="textAlign"?f(B,z==="start"?"left":z==="end"?"right":z):f(B,z)}else{let B=b.goalType==="form_submit"&&!m.disabled;if(!B&&V.disabled){y("This element can\u2019t be tracked reliably \u2014 select a specific button or link instead.",!1);return}Ct("goals"),B?(C=m.onclick)==null||C.call(m,new MouseEvent("click")):(L=V.onclick)==null||L.call(V,new MouseEvent("click"))}},v.append(w),fe.append(v)}},It=n=>{if(!t)return;let o=t.parentElement;if(!o)return;Ae||(Ve=o,dt=t.nextSibling,Ae=!0),n==="up"&&Oe?o.insertBefore(t,Oe):n==="down"&&Ne&&o.insertBefore(t,Ne.nextSibling);let s=vt(t,document);Oe=s.prevEl,Ne=s.nextEl,ae=s.prevLocator,Be=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}x(),_t(!0),y("Previewing the new position \u2014 keep moving, save, or undo.")};be.onclick=()=>It("up"),xe.onclick=()=>It("down"),rt.onclick=()=>{Je(),y("Move undone \u2014 back to the original position.")},ot.onclick=async()=>{if(!t||!J||!Ae||!ze)return;let n=ae?"moveAfter":"moveBefore",o=ae!=null?ae:Be;if(!o){y("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=nt("move",J,t);y("Saving\u2026");let l=await Q(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:J,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[n]:o}}]}});l.r==="ok"&&(u("draft_saved",{kind:"move"}),Ae=!1,Ve=null,dt=null,_t(!1),lt(s,_e(t),"b")),se(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let Xn=()=>{var n,o;u("editor_closed"),c(),window.removeEventListener("pagehide",c),i&&clearTimeout(i),Je(),tn(),document.removeEventListener("mousemove",ln,!0),document.removeEventListener("click",un,!0),document.removeEventListener("keydown",cn,!0),window.removeEventListener("scroll",_,!0),window.removeEventListener("resize",_),We(document),(n=document.getElementById(Ot))==null||n.remove(),k.remove(),T.remove(),P.remove(),Se.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),et()},Ht=!1;Re.onclick=()=>{if((Pe||Ae)&&!Ht){Ht=!0,y("\u26A0 Unsaved changes \u2014 click \u201CClose editor\u201D again to discard them.",!1);return}Xn()},document.addEventListener("mousemove",ln,!0),document.addEventListener("click",un,!0),document.addEventListener("keydown",cn,!0),window.addEventListener("scroll",_,!0),window.addEventListener("resize",_),it(),u("editor_opened")}function A(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 Et="sentient-preview-bar";async function Oo(e,t){var P,X,F,M,I,U,Y,Z,N,q,te,V;try{fetch(`${e.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({events:[{kind:"previewed"}]})}).catch(()=>{})}catch(m){}let r=null;try{let m=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});m.ok&&(r=(X=((P=(await m.json()).slots)!=null?P:[]).find(ne=>ne.slot_id===t&&ne.kind==="arms"))!=null?X:null)}catch(m){}let i=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});i.id=Et;let c=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");c.onclick=()=>{et();let m=new URL(location.href);for(let D of["sentient_editor","sentient_preview","sentient_arm"])m.searchParams.delete(D);location.assign(m.toString())};let u=a("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");u.onclick=()=>{let m=new URL(location.href);for(let D of["sentient_preview","sentient_arm"])m.searchParams.delete(D);location.assign(m.toString())};let k=(U=(I=(F=r==null?void 0:r.draft_config)==null?void 0:F.arms)!=null?I:(M=r==null?void 0:r.published_config)==null?void 0:M.arms)!=null?U:[];if(!r||k.length===0){i.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),u,c),((Y=document.body)!=null?Y:document.documentElement).append(i);return}let T=new URLSearchParams(location.search).get("sentient_arm"),x=(N=(Z=k.find(m=>m.id===T))!=null?Z:k[1])!=null?N:k[0];i.append(a("span",{fontWeight:"700"},`Previewing: ${(q=r.display_name)!=null?q:r.slot_id}`));let _=r.target&&typeof r.target=="object"?he(r.target,document):null;if(!_)i.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{Ln(_,x.ops,`preview-${r.slot_id}`,document);try{_.scrollIntoView({block:"center"})}catch(m){}for(let m of k){let D=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:m.id===x.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(te=m.displayName)!=null?te:m.id);D.onclick=()=>{let ne=new URL(location.href);ne.searchParams.set("sentient_arm",m.id),location.assign(ne.toString())},i.append(D)}}i.append(u,c),((V=document.body)!=null?V:document.documentElement).append(i)}async function No(e,t){var P,X,F;let r=t.lastIndexOf("~"),i=r>0?t.slice(0,r):t,c=r>0?t.slice(r+1):"",u=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});u.id=Et;let k=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Exit preview");k.onclick=()=>{et();let M=new URL(location.href);for(let I of["sentient_editor","sentient_preview_cell"])M.searchParams.delete(I);location.assign(M.toString())};let T=M=>{var I;u.append(a("span",{},M),k),((I=document.body)!=null?I:document.documentElement).append(u)},x=null;try{let M=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${e.token}`}});M.ok&&(x=await M.json())}catch(M){}if(!x)return T("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let _=x.target&&typeof x.target=="object"?he(x.target,document):null;if(!_)return T("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(x.blocks!=null)wn(_,{preview:x.blocks},"preview",document);else if(typeof x.content=="string")_.textContent=x.content;else return T("Nothing to preview in that square yet.");try{_.scrollIntoView({block:"center"})}catch(M){}u.append(a("span",{fontWeight:"700"},`Previewing: ${(P=x.slotName)!=null?P:i}`),a("span",{opacity:"0.85"},`for ${(X=x.personaDisplay)!=null?X:c}${x.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),k),((F=document.body)!=null?F:document.documentElement).append(u)}async function Do(){if(typeof document=="undefined")return;let e=Lo();if(!e)return;let t=await Bo(e);if(!t.ok){t.unauthorized?(et(),_n(To)):_n(Co);return}let r=new URLSearchParams(location.search).get("sentient_preview");if(r){document.getElementById(Et)||await Oo(e,r);return}let i=new URLSearchParams(location.search).get("sentient_preview_cell");if(i){document.getElementById(Et)||await No(e,i);return}if(document.getElementById(Ge))return;On(e);let c=Sn(document);ye=c,c&&Q(e,"/v1/editor/palette",c);let u=await $o(e);In(u),Hn(u,document)}Do();return io(jo);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var Je=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames,jt=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable;var Gt=(e,t,n)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,J=(e,t)=>{for(var n in t||(t={}))Ut.call(t,n)&&Gt(e,n,t[n]);if(jt)for(var n of jt(t))gr.call(t,n)&&Gt(e,n,t[n]);return e};var zt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Ft=(e,t)=>{for(var n in t)Je(e,n,{get:t[n],enumerable:!0})},mr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pr(t))!Ut.call(e,o)&&o!==n&&Je(e,o,{get:()=>t[o],enumerable:!(r=fr(t,o))||r.enumerable});return e};var hr=e=>mr(Je({},"__esModule",{value:!0}),e);var yr,vr,br,qt,wr,Sr,Wt,O,be,De=zt(()=>{"use strict";yr=Object.defineProperty,vr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,qt=Object.getOwnPropertySymbols,wr=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Wt=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))wr.call(t,n)&&Wt(e,n,t[n]);if(qt)for(var n of qt(t))Sr.call(t,n)&&Wt(e,n,t[n]);return e},be=(e,t)=>vr(e,br(t))});var on={};Ft(on,{LOCAL_ENGINE_AVAILABLE:()=>Ir,createLocalEngine:()=>Or});function Or(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Ir,sn=zt(()=>{"use strict";Ir=!1});var qo={};Ft(qo,{applyPersonaAttributes:()=>at,applyRegistrySlots:()=>ut,applySlotArms:()=>ct,applySlotAttributes:()=>lt,parseEditorToken:()=>sr,parsePersonaPreview:()=>cr,parsePreview:()=>lr,parseSnippetConfig:()=>rt,planReorder:()=>pt,reapply:()=>Nt,run:()=>ur,version:()=>We});De();var Ar=["buyer","researcher","deal_seeker","browser"];var Er={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"};function Ve(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Ht(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 bt(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 Ve(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 Ve(o)}function Jt(e,t){var n,r;return e.dims!=null?(r=(n=Ht(t))!=null?n:Ht(bt(e)))!=null?r:{}:t}function Vt(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 Jo=Ar.map(e=>({key:e,displayName:Er[e]}));function Xe(e){return e?`_${e.slice(0,12)}`:""}var xr="_snt_uid";function Xt(e){return`${xr}${Xe(e)}`}var kr=["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 Yt(e){return Cr(e)!==null}function Cr(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=kr.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Zt(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 Qt(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 en(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var _r=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function tn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,c])=>{let i=Array.isArray(c)?c[0]:c;return i===void 0?[]:[[o,i]]});for(let[o,c]of r)o.startsWith("utm_")?o in t||(t[o]=c):_r.includes(o)&&(o in n||(n[o]=c))}catch(r){}return{utmParams:t,clickIds:n}}function nn(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function wt(e){return O(O(O({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function St(e){let t=wt(e);return Jt(t,bt(t))}function rn(e){return typeof e=="string"?e:Ve(e)}De();function dn(){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 Pr="_snt_uid",Lr=365,Ye="_snt_uid";function Rr(){return dn()}function an(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Tr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function At(e){try{return localStorage.getItem(e)}catch(t){return null}}function ln(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function cn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Dr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Mr(e){try{sessionStorage.removeItem(e)}catch(t){}}function Nr(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Br(e){try{localStorage.removeItem(e)}catch(t){}}function $r(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Kr={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function fn(e){var t,n,r,o,c,i,s;if(typeof window=="undefined")return Kr;let a=Xe(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Xt(e==null?void 0:e.apiKey),l=`${Ye}${a}`,d=`${Ye}_tomb${a}`,m=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Lr)*24*60*60,w=b=>b&&b.length>0?b:null,p=()=>{var b,_;return a&&!(e!=null&&e.cookieName)&&At(d)===null?(_=(b=w(an(Pr)))!=null?b:w(At(Ye)))!=null?_:w(cn(Ye)):null},h=(s=(i=(c=(o=(r=w(an(u)))!=null?r:w(At(l)))!=null?o:w(cn(l)))!=null?c:p())!=null?i:w(e==null?void 0:e.ssrSessionId))!=null?s:Rr();Tr(u,h,m);let E=ln(l,h),C=Nr(u),P=E?!1:Dr(l,h),f=!E&&!C&&!P;return{getSessionId:()=>h,isEphemeral:()=>f,destroy:()=>{h=null,$r(u),Br(l),Mr(l),a&&!(e!=null&&e.cookieName)&&ln(d,"1")}}}function Ne(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Ct(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 pn(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 _e(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 gn(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 jr=500,Gr=56*1024;function mn(e){return`_snt_retry_${e.slice(0,12)}`}var Ur={push:()=>{},flush:()=>{},destroy:()=>{}};function zr(e){var t,n,r;if(typeof window=="undefined")return Ur;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,a=e.apiKey,u=mn(a),l=[],d=new Set,m=[],w=S=>{for(let v of S)p.delete(v),!d.has(v)&&(d.add(v),m.push(v));for(;m.length>jr;){let v=m.shift();v&&d.delete(v)}gn(S,u)},p=new Set,h=()=>{for(;l.length>i;){let S=l.shift();S&&p.delete(S.id)}},E=S=>{d.has(S.id)||p.has(S.id)||(p.add(S.id),l.push(S),h())},C=S=>{for(let v of S)d.has(v.id)||(p.add(v.id),l.push(v));h()},P=pn(u,i);for(let S of P)E(S);let f=0,b=0,_=(S,v=!0)=>{if(S.length===0)return;let k=JSON.stringify(S),x=S.map(F=>F.id),I;try{I=fetch(s,{method:"POST",keepalive:!0,body:k,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(F){_e(S,i,u),C(S),b++,f=Date.now()+Ne(b);return}let ee=F=>{if(Ct(F)!=="retry"){if(!F.ok&&v){let ae=S.filter(q=>q.eventType!=="pageview");if(ae.length>0&&ae.length<S.length){w(S.filter(q=>q.eventType==="pageview").map(q=>q.id)),_(ae,!1);return}}w(x),b=0,f=0;return}_e(S,i,u),C(S),b++,f=Date.now()+Ne(b)};I instanceof Promise?I.then(ee).catch(()=>{_e(S,i,u),C(S),b++,f=Date.now()+Ne(b)}):ee(I)},K=typeof TextEncoder!="undefined"?new TextEncoder:null,A=S=>K?K.encode(S).length:S.length,D=S=>{let v=[],k=2;for(let x of S){let I=A(JSON.stringify(x))+1;if(v.length>0&&k+I>Gr||v.length>=c)break;v.push(x),k+=I}return v},G=()=>{try{if(Date.now()<f)return;for(;l.length>0&&!(Date.now()<f);){let S=l.filter(k=>!d.has(k.id));if(l.length=0,S.length===0)break;let v=D(S);if(v.length===0)break;v.length<S.length&&l.push(...S.slice(v.length)),_(v)}}catch(S){}},X=!0,M=null;M=setInterval(()=>{X&&G()},o);let j=()=>{document.visibilityState==="hidden"&&G()},se=()=>{G()};return document.addEventListener("visibilitychange",j),window.addEventListener("pagehide",se),{push(S){E(S),l.length>=c&&G()},flush:G,destroy(){X=!1,M!==null&&(clearInterval(M),M=null),document.removeEventListener("visibilitychange",j),window.removeEventListener("pagehide",se),G()}}}var Fr=200;function hn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var qr={send:()=>{},flush:()=>{},destroy:()=>{}};function Wr(e){var t,n,r;if(typeof window=="undefined")return qr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=hn(e.apiKey),a=[],u=new Set,l=new Set,d=[],m=0,w=0,p=!1,h=A=>{for(u.delete(A.id),l.has(A.id)||(l.add(A.id),d.push(A.id));d.length>Fr;){let D=d.shift();D&&l.delete(D)}gn([A.id],s)},E=A=>{_e([A],c,s),!l.has(A.id)&&!u.has(A.id)&&(u.add(A.id),a.push(A)),Date.now()>=m&&(w++,m=Date.now()+Ne(w))},C=A=>{let D;try{D=fetch(e.url,{method:"POST",keepalive:!0,body:A.body,headers:e.headers})}catch(X){E(A);return}let G=X=>{var M;let j=Ct(X);if(j==="retry"){E(A);return}j==="dropped"&&((M=e.onDrop)==null||M.call(e,A,X.status)),h(A),w=0,m=0};D instanceof Promise?D.then(G).catch(()=>E(A)):G(D)},P=()=>{try{if(p||Date.now()<m)return;let A=0;for(;a.length>0&&A<i&&!(Date.now()<m);){let D=a.shift();u.delete(D.id),!l.has(D.id)&&(A++,C(D))}}catch(A){}},f=pn(s,c);for(let A of f)u.has(A.id)||(u.add(A.id),a.push(A));f.length>0&&_e(f,c,s);let b=setInterval(P,o),_=()=>{document.visibilityState==="hidden"&&P()},K=()=>P();return document.addEventListener("visibilitychange",_),window.addEventListener("pagehide",K),{send(A){if(!p&&!(l.has(A.id)||u.has(A.id))){if(Date.now()<m){_e([A],c,s),u.add(A.id),a.push(A);return}C(A)}},flush:P,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",_),window.removeEventListener("pagehide",K),P(),p=!0}}}var Hr=1800*1e3;function Ze(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Jr(e=Hr,t){let n=new Map,r=`_snt_asgn${Xe(t)}_`,o=(a,u)=>`${r}${encodeURIComponent(a)}:${encodeURIComponent(u)}`,c=a=>{let u=a.slice(r.length),l=u.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,l)),segment:decodeURIComponent(u.slice(l+1))}}catch(d){return null}},i=()=>{try{let a=[];for(let u=0;u<localStorage.length;u++){let l=localStorage.key(u);l!=null&&l.startsWith(r)&&a.push(l)}return a}catch(a){return[]}},s=a=>a.assignedAt+(a.ttlMs&&a.ttlMs>0?a.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let a of i())try{let u=localStorage.getItem(a);if(!u)continue;let l=JSON.parse(u);if(s(l)){localStorage.removeItem(a);continue}let d=c(a);if(!d)continue;n.set(Ze(d.componentId,d.segment),l)}catch(u){}})(),{get(a,u){let l=n.get(Ze(a,u));return l?s(l)?(n.delete(Ze(a,u)),null):l:null},set(a,u,l){let d=Ze(a,u);n.set(d,l);try{localStorage.setItem(o(a,u),JSON.stringify(l))}catch(m){}},clear(){n.clear();for(let a of i())try{localStorage.removeItem(a)}catch(u){}}}}var tt="_snt_snap:",Vr=["low","medium","high"];function Be(e){try{let t=localStorage.getItem(tt+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"||!Vr.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 $e(e,t){try{localStorage.setItem(tt+e,JSON.stringify(t))}catch(n){}}var xt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",yn="[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.",un=!1,Qe=!1;function Xr(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Yr(e){var t;let n=fn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Xr(),c=Promise.resolve().then(()=>(sn(),on)).then(l=>{let d=l;return d.LOCAL_ENGINE_AVAILABLE?(un||(un=!0,console.info(yn)),d):(Qe||(Qe=!0,console.error(xt)),null)}).catch(()=>(Qe||(Qe=!0,console.error(xt)),null)),i=null,s={low:.15,medium:.5,high:.85},a=(()=>{var l;if(e.initialPersona)return O({},e.initialPersona);let d=Be(e.apiKey||"local");return d?{persona:d.persona,confidence:(l=s[d.band])!=null?l:.15}:null})();function u(l){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=l.persona,d.dataset.sentientConfidence=we(l.confidence))}return{isLocal:!0,async decide(l){var d,m,w;let p=await c;if(!p)return null;let h=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide(l);return i=be(O({},h),{layoutOrder:(m=(d=h.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?m:null,slots:O(O({},(w=i==null?void 0:i.slots)!=null?w:{}),h.slots)}),$e(e.apiKey||"local",{v:1,persona:i.persona,band:we(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(h),h},getSlotResult(l){var d,m,w;return(w=(m=i==null?void 0:i.slots[l])!=null?m:(d=e.initialSlots)==null?void 0:d[l])!=null?w:null},getSlotConfig(l){var d,m;return(m=(d=e.initialSlotConfig)==null?void 0:d[l])!=null?m:null},getSitePalette(){var l;return(l=e.initialPalette)!=null?l:null},reportSlots(){},getPersona(){let l=i!=null?i:a;return l?{persona:l.persona,confidence:l.confidence,band:we(l.confidence)}:null},async assign(l,d){var m;let w=await c;return!w||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(m=w.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:l,variantIds:d}]}).assignments[l])!=null?m:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function nt(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(nt):!1}function Ke(e,t,n,r){let o=[];{let c=!1,i=[],s=()=>{if(c)return;let a=Date.now();for(i.push(a);i.length>0&&a-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let c=!1,i=s=>{if(c||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;c=!0;let a=typeof window!="undefined"?window.getSelection():null,u=a?a.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{c||!i||(a(),s=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},l=()=>{a(),u()},d=w=>{for(let p of w)i=p.intersectionRatio>.3,i?u():a()},m=new IntersectionObserver(d,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",l,{passive:!0}),o.push(()=>{m.disconnect(),window.removeEventListener("scroll",l),a()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),s=()=>{if(c||document.visibilityState!=="hidden")return;let a=Date.now()-i;a<15e3&&(c=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let c of o)c()}}var vn="https://api.sentient-ui.com/v1/events",ne=new Map,bn=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 Et(){return dn()}function et(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function eo(){let e=new WeakMap,t=new Map,n=!1,r=(s,a,u)=>{let l=s.get(a);return u===null?l?!0:(s.set(a,new Set),!1):l?l.has(u)?!0:(l.add(u),!1):(s.set(a,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{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,a=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(a,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),a()},u.port2.postMessage(0)}};return{firedBefore(s,a){let u=c();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,a)}let l=r(t,s,a);return!l&&!n&&(n=!0,i()),l}}}var wn=new Set;function to(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let u=et();!u||u===c||(c=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},s=[];for(let u of["pushState","replaceState"]){let l=r[u],d=function(...m){let w=l.apply(this,m);return i(),w};r[u]=d,s.push([u,l,d])}window.addEventListener("popstate",i);let a=et();return a&&wn.has(`${t}:${a}`)?c=a:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,l,d]of s)r[u]===d&&(r[u]=l)}}}var Me={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function no(){try{return tn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Sn(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 _t(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:bn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=ne.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&&Se())return;let s=(i!=null?i:je)(be(O({},o),{consent:!0}));c(s);let a=(t=ne.get(n))==null?void 0:t.dispose;ne.set(n,{config:be(O({},o),{consent:!0}),upgrade:null,dispose:a})}function ro(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=Sn((t=e.ingestUrl)!=null?t:vn),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(l,d,m){if(!n)return Promise.resolve(null);let w=c.get(l);return w?Promise.resolve(w):kt(i,l,async()=>{try{let p=new URLSearchParams({componentId:l});for(let C of d!=null?d:[])p.append("variantIds[]",C);let h=await fetch(`${r}/winner?${p.toString()}`,{headers:o});if(!h.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;let E={variantId:(await h.json()).variantId,assignmentTtlMs:0};return c.set(l,E),E}catch(p){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},a={track:l=>s.track(l),goal:((l,d,m,w)=>s.goal(l,d,m,w)),componentGoal:(l,d,m)=>s.componentGoal(l,d,m),identify:l=>s.identify(l),getAssignment:(l,d)=>s.getAssignment(l,d),assign:(l,d,m,w)=>s.assign(l,d,m,w),decide:l=>s.decide(l),getSlotResult:l=>s.getSlotResult(l),getSlotConfig:l=>s.getSlotConfig(l),getSitePalette:()=>s.getSitePalette(),reportSlots:l=>s.reportSlots(l),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function u(l){s=l}return{proxy:a,setInner:u}}function kt(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 je(e){var t,n,r,o,c,i,s,a,u,l;if(typeof window=="undefined")return Me;bn=e.apiKey||"local";let d=ne.get(e.apiKey||"local");if(d!=null&&d.dispose)try{d.dispose()}catch(g){}let m=e.respectDoNotTrack!==!1&&Se(),w=e.consent===!1||m,p=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!p&&e.localMode!==!1)return ne.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."}),w?Me:Yr(e);if(w){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."),ne.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."}),Me;let{proxy:g,setInner:y}=ro(e);return ne.set(e.apiKey,{config:e,upgrade:m?null:y}),g}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Me;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Me;let h=(t=e.ingestUrl)!=null?t:vn,E=Date.now(),C=fn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),P=Jr(void 0,e.apiKey),f=zr({ingestUrl:h,apiKey:e.apiKey}),b=Sn(h),_={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},K=new Set,A=Wr({url:`${b}/goals`,apiKey:e.apiKey,headers:_,onDrop:(g,y)=>{if(!e.debug){if(K.has(y))return;K.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),g)}}),D=Zt((n=navigator.userAgent)!=null?n:""),G=window.location.origin,X=Qt((r=document.referrer)!=null?r:"",G),M=(o=e.sessionSegment)!=null?o:`${D}:${X}`,j=new Map,se=new Map,S=new Map,v=new Map,k=null,x=null,I=new Set,ee=new Set,F=null,ae=g=>{for(let y of g)S.has(y.id)||S.set(y.id,St(y))};if(e.initialSlots)for(let[g,y]of Object.entries(e.initialSlots))S.set(g,y);if(e.initialSlotConfig)for(let[g,y]of Object.entries(e.initialSlotConfig))v.set(g,y);e.initialPalette&&(k=e.initialPalette);let q=Be(e.apiKey);if(q){for(let[g,y]of Object.entries(q.slots))S.has(g)||S.set(g,y);for(let[g,y]of Object.entries((c=q.slotConfig)!=null?c:{}))v.has(g)||v.set(g,y);!k&&q.palette&&(k=q.palette)}let ke={low:.15,medium:.5,high:.85};if(e.initialPersona)x=O({},e.initialPersona);else{let g=document.documentElement.dataset;g.sentientPersona?x={persona:g.sentientPersona,confidence:(s=ke[(i=g.sentientConfidence)!=null?i:"low"])!=null?s:.15}:q&&(x={persona:q.persona,confidence:(a=ke[q.band])!=null?a:.15})}if(e.initialAssignments)for(let[g,y]of Object.entries(e.initialAssignments))P.set(g,M,{variantId:y,assignedAt:Date.now(),segment:M,confidence:1});let fe=Promise.resolve(),Bt=C.getSessionId();if(Bt){let g=en((u=document.referrer)!=null?u:""),{utmParams:y,clickIds:N}=no(),te=O(O(O(O({sessionId:Bt,deviceClass:D,trafficSource:X,referrerDomain:g,utmParams:y,clickIds:N,timeOfDay:nn(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:C.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Yt((l=navigator.userAgent)!=null?l:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),H=async()=>{for(let L=0;;L++){try{let B=await fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(te),headers:_});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||Ct(B)==="dropped")return}catch(B){}if(L>=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,Ne(L+1)))}};try{fe=H()}catch(L){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let dr=eo(),Le=null,vt=!1,Ce={goal(g,y={},N=1,te=0){var H,L,B,Y,Z,ve,pe;let Re=C.getSessionId();if(!Re)return;let Q=Zr(y)?y:{metadata:y},Te=[g,(H=Q.externalId)!=null?H:"",(L=Q.stepIndex)!=null?L:te,(B=Q.weight)!=null?B:N].join("\0"),R=Q.value!==void 0?`${Q.value}\0${(Y=Q.currency)!=null?Y:""}`:null;if(dr.firedBefore(Te,R)){e.debug&&console.log(`[sentient] goal("${g}") already recorded for this action \u2014 not sent twice`);return}let le=Et(),He={sessionId:Re,name:g,metadata:(Z=Q.metadata)!=null?Z:{},weight:(ve=Q.weight)!=null?ve:N,stepIndex:(pe=Q.stepIndex)!=null?pe:te,goalId:le,value:Q.value,currency:Q.currency,externalId:Q.externalId};e.debug&&console.log("[sentient] goal",He);let z={id:le,body:JSON.stringify(He)};fe.then(()=>A.send(z))},componentGoal(g,y,N){var te,H,L;let B=C.getSessionId();if(!B)return;let Y=P.get(g,M),Z=Y?null:(te=S.get(g))!=null?te:null;if(!Y&&Z===null){e.debug&&console.warn(`[sentient] componentGoal("${g}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let ve=Y?Y.variantId:rn(Z),pe={id:Et(),sessionId:B,projectId:e.apiKey,componentId:g,variantId:ve,eventType:"goal_achieved",goalType:y,payload:O({reward:(H=N==null?void 0:N.reward)!=null?H:1,goalValue:N==null?void 0:N.value,currency:N==null?void 0:N.currency},(L=N==null?void 0:N.metadata)!=null?L:{}),timestamp:Date.now(),timeInSession:Date.now()-E,path:et()};e.debug&&console.log("[sentient] componentGoal",pe),fe.then(()=>f.push(pe))},identify(g){let y=C.getSessionId();y&&fe.then(()=>{fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:g,ephemeral:C.isEphemeral()}),headers:_}).catch(()=>{})})},track(g){let y=C.getSessionId();if(!y)return;let N=be(O({path:et()},g),{id:Et(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-E});e.debug&&console.log("[sentient] track",N),fe.then(()=>f.push(N))},getAssignment(g,y){return P.get(g,y)},async assign(g,y,N,te){let H=C.getSessionId();if(!H)return null;let L=P.get(g,M);if(L&&(y!=null&&y.length||L.content!==void 0)){let B=L.ttlMs&&L.ttlMs>0?Math.max(0,L.assignedAt+L.ttlMs-Date.now()):0;return{variantId:L.variantId,assignmentTtlMs:B,content:L.content}}return kt(j,g,async()=>{await fe;try{let B={sessionId:H,componentId:g,variantIds:y};te!==void 0?B.agentDataByVariant=te:N!==void 0&&(B.agentData=N);let Y=await fetch(`${b}/assign`,{method:"POST",body:JSON.stringify(B),headers:_});if(!Y.ok)return null;let Z=await Y.json();return P.set(g,M,O({variantId:Z.variantId,assignedAt:Date.now(),segment:M,confidence:1,content:Z.content},Z.assignmentTtlMs&&Z.assignmentTtlMs>0?{ttlMs:Z.assignmentTtlMs}:{})),Z}catch(B){return null}})},async decide(g){var y,N;let te=C.getSessionId();if(!te)return null;let H=(y=g.slots)!=null?y:[],L={sessionId:te};g.sections&&g.sections.length>0&&(L.sections=g.sections.map(Y=>({id:Y}))),L.components=(N=g.components)!=null?N:[],H.length>0&&(L.slots=H.map(wt)),g.slotsFrom==="registry"&&(L.slotsFrom="registry"),g.v&&(L.v=g.v),typeof g.pp=="number"&&(L.pp=g.pp),e.persona&&(L.persona=e.persona);let B=JSON.stringify(L);return kt(se,B,async()=>{var Y,Z,ve,pe,Re,Q;await fe;try{let Te=await fetch(`${b}/decide`,{method:"POST",body:B,headers:_});if(!Te.ok)return ae(H),null;let R=await Te.json(),le={};for(let z of H){let re=(Y=R.slots)==null?void 0:Y[z.id];if(re!==void 0){le[z.id]=re,S.set(z.id,re);continue}let $t=S.get(z.id);if($t!==void 0)le[z.id]=$t;else{let Kt=St(z);le[z.id]=Kt,S.set(z.id,Kt)}}if(R.slots)for(let[z,re]of Object.entries(R.slots))z in le||(le[z]=re,S.set(z,re));let He=x!=null&&x.persona!=="unknown";R.persona&&!(R.persona==="unknown"&&He)?x={persona:R.persona,confidence:(Z=R.confidence)!=null?Z:0}:x||(x={persona:"unknown",confidence:0});for(let[z,re]of Object.entries((ve=R.assignments)!=null?ve:{}))P.set(z,M,{variantId:re,assignedAt:Date.now(),segment:M,confidence:1});if(R.slotConfig)for(let[z,re]of Object.entries(R.slotConfig))v.set(z,re);return R.palette&&(k=R.palette),$e(e.apiKey,O(O({v:1,persona:x.persona,band:we(x.confidence),slots:Object.fromEntries(S),layoutOrder:(pe=R.layoutOrder)!=null?pe:null,savedAt:Date.now()},v.size>0?{slotConfig:Object.fromEntries(v)}:{}),k?{palette:k}:{})),O(O(O(O({layoutOrder:(Re=R.layoutOrder)!=null?Re:null,assignments:(Q=R.assignments)!=null?Q:{},slots:le,persona:x.persona,confidence:x.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{}),R.sectionMap?{sectionMap:R.sectionMap}:{}),R.palette?{palette:R.palette}:{})}catch(Te){return ae(H),null}})},getSlotResult(g){var y;return(y=S.get(g))!=null?y:null},getSlotConfig(g){var y;return(y=v.get(g))!=null?y:null},reportSlots(g){for(let y of g)typeof y=="string"&&y.length>0&&!I.has(y)&&(I.add(y),ee.add(y));ee.size===0||F!=null||(F=setTimeout(()=>{F=null;let y=[...ee].slice(0,20);ee.clear(),y.length!==0&&fetch(`${b}/slots/observed`,{method:"POST",headers:_,body:JSON.stringify({slotIds:y})}).catch(()=>{})},1e3))},getSitePalette(){return k},getPersona(){return x?{persona:x.persona,confidence:x.confidence,band:we(x.confidence)}:null},async fetchWeights(){var g;try{let y=await fetch(`${b}/weights`,{headers:_});return y.ok?(g=(await y.json()).components)!=null?g:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var g;Le==null||Le(),vt=!0,f.destroy(),A.destroy(),((g=ne.get(e.apiKey))==null?void 0:g.dispose)===Ce.dispose&&ne.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var g;Le==null||Le(),vt=!0,f.destroy(),A.destroy(),C.destroy(),P.clear(),((g=ne.get(e.apiKey))==null?void 0:g.dispose)===Ce.dispose&&ne.delete(e.apiKey);try{localStorage.removeItem(tt+e.apiKey),localStorage.removeItem(mn(e.apiKey)),localStorage.removeItem(hn(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(ne.set(e.apiKey,{config:e,upgrade:null,dispose:Ce.dispose}),Le=to(Ce,e.apiKey,g=>{fe.then(()=>{vt||wn.add(g)})}),e.debug){let g=window;g.__sentient&&(g.__sentient.client=Ce)}return Ce}var oo=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function It(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function io(e){return{tag:e.tagName.toLowerCase(),text:It(e).slice(0,40)}}function An(e){return e.replace(/["\\\]]/g,"\\$&")}function Ge(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function En(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)),c=[r,...o.map(s=>`${r}.${s}`)];for(let s of c)if(Ge(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=En(i,t);if(s){for(let d of c){let m=`${s} > ${d}`;if(Ge(t,m))return m}let a=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=a.indexOf(e),l=a.some(d=>d!==e&&It(d)!==It(e));if(u>=0&&l){let d=`${s} > ${r}:nth-of-type(${u+1})`;if(Ge(t,d))return d}}}return null}function xn(e,t){let n=io(e),r=e.getAttribute("id");if(r&&Ge(t,`#${An(r)}`))return{v:1,id:r,fingerprint:n};for(let c of oo){let i=e.getAttribute(c);if(i&&Ge(t,`[${c}="${An(i)}"]`))return{v:1,dataAttr:{name:c,value:i},fingerprint:n}}let o=En(e,t);return o?{v:1,selector:o,fingerprint:n}:null}De();var Cn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],so={banner:"hero",navigation:"navigation",contentinfo:"footer"};function ao(e){let t=e.ariaRole?so[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 lo(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var co=[["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]],Ot=[["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]],kn={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function uo(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function _n(e){var t,n;let r=ao(e);if(r)return{type:(t=kn[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of co)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of Ot)if(s.test(e.bodyText))return{type:i,strength:"strong"};let c=lo(e);return{type:(n=kn[c])!=null?n:"generic",strength:"weak"}}function In(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return O({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:uo(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}De();var fo="section, header, footer, nav, main > div, [data-sentient-section]",po=2e4;function go(e){let t=Array.from(e.querySelectorAll(fo)),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 mo(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 On=()=>{};function Pn(e,t){var n,r,o,c,i,s,a,u,l,d,m,w;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 On;let h=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),E=go(p);if(E.length===0)return On;let C=new Map,P=[];for(let v of E){let k=v.getAttribute("data-sentient-type"),x=k&&Cn.includes(k)?k:null,I=In(v),ee=(c=x!=null?x:(o=t.typeOf)==null?void 0:o.call(t,v))!=null?c:_n(I).type,F=xn(v,p),ae=F?`nc-${ee}-${Vt(JSON.stringify({id:(i=F.id)!=null?i:null,dataAttr:(s=F.dataAttr)!=null?s:null,selector:(a=F.selector)!=null?a:null})).toString(36)}`:`nc-${ee}`;C.set(v,ae);let q=Ot.filter(([,ke])=>ke.test(I.bodyText)).map(([ke])=>ke);P.push(be(O({componentId:ae,semanticType:ee,source:x?"markup":"auto"},F?{locator:F}:{}),{observation:O(O({tag:I.tag,idClass:I.idClass.slice(0,200),headingText:I.headingText,textLength:I.textLength,actionCount:I.actionCount},I.ariaRole?{ariaRole:I.ariaRole}:{}),q.length>0?{patternFlags:q}:{})}))}let f=(m=(d=(l=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:d.pathname)!=null?m:"/";mo(t.apiKey,h,f,P);let b=new Map,_=v=>{let k=b.get(v);return k||(k={ms:0,scroll:0,enterAt:null,intersecting:!1},b.set(v,k)),k},K=new IntersectionObserver(v=>{for(let k of v){let x=C.get(k.target);if(!x)continue;let I=_(x);k.isIntersecting?(I.intersecting=!0,I.enterAt=Date.now(),k.intersectionRatio>I.scroll&&(I.scroll=k.intersectionRatio)):(I.intersecting=!1,I.enterAt!=null&&(I.ms+=Date.now()-I.enterAt,I.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let v of C.keys())K.observe(v);let A=()=>{let v=Date.now();for(let[k,x]of b)if(x.enterAt!=null&&(x.ms+=v-x.enterAt,x.enterAt=null),!(x.ms<=0)){try{e.track({projectId:t.apiKey,componentId:k,eventType:"dwell",payload:{dwell_time:Math.round(x.ms),scroll_depth:Number(x.scroll.toFixed(2))}})}catch(I){}x.ms=0}},D=()=>{if(p.hidden)A();else{let v=Date.now();for(let k of b.values())k.intersecting&&(k.enterAt=v)}},G=!1,X=v=>{if(A(),v!=null&&v.persisted){G=!0;return}try{K.disconnect()}catch(k){}},M=v=>{if(!(v!=null&&v.persisted)||!G)return;G=!1;let k=Date.now();for(let x of b.values())x.enterAt=x.intersecting&&!p.hidden?k:null};p.addEventListener("visibilitychange",D);let j=(w=p.defaultView)!=null?w:typeof window!="undefined"?window:void 0;j==null||j.addEventListener("pagehide",X),j==null||j.addEventListener("pageshow",M);let se=setInterval(()=>{if(p.hidden||G)return;A();let v=Date.now();for(let k of b.values())k.intersecting&&(k.enterAt=v)},po),S=[];return t.microSignals&&[...C.entries()].forEach(([v,k],x)=>{S.push(Ke((I,ee={})=>{try{e.track({projectId:t.apiKey,componentId:k,eventType:"micro_signal",payload:O({signalType:I},ee)})}catch(F){}},v,void 0,{tabLoss:x===0}))}),()=>{A(),clearInterval(se),p.removeEventListener("visibilitychange",D),j==null||j.removeEventListener("pagehide",X),j==null||j.removeEventListener("pageshow",M);for(let v of S)v();try{K.disconnect()}catch(v){}}}var ho=["landing","ecommerce","saas","marketplace"];function yo(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 vo(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function bo(e){try{return e()}catch(t){return}}function rt(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=ho.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 a=s,u=yo(a.dims);if(!u||a.target!==void 0&&typeof a.target!="string")continue;let l=a.arms!==void 0?vo(a.arms):null,d={dims:u};typeof a.target=="string"&&(d.target=a.target),l&&(d.arms=l),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"?bo(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),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 ot(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 wo(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 Ln(e,t){return!!(e!=null&&e.urlMatch)&&!ot(t).includes(e.urlMatch)}var So=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ge(e,t){var o;if(e.urlMatch&&!ot(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)&&So.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&&!wo(r,e.fingerprint)?null:r}var Rn={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"},Ao=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Tn(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(!Ao.test((r=n[1])!=null?r:""))return!1;return!0}var Dn=/^https:\/\//i,Mn=new Map,me=null;function Eo(e){return e.replace(/["\\]/g,"\\$&")}function xo(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=[...Mn.entries()].map(([n,r])=>`[data-snt-e="${Eo(n)}"]{${r}}`).join(`
2
- `)}function Nn(e,t,n,r){var s;let o=!1,c=(s=t.moveBefore)!=null?s:t.moveAfter;if(c){let a=ge(c,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Dn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Dn.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[a,u]of Object.entries(t.style)){let l=Rn[a];l&&typeof u=="string"&&Tn(u)&&i.push(`${l}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Mn.set(n,i.join(";")),xo(r)),{anchorMiss:o}}var Ue="data-sentient-block-arm",oe=null;function ze(e){oe=e!=null?e:null}var ue="data-sentient-blocks-hid",it={none:"0",sm:"8px",md:"16px",lg:"24px"},Pt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Bn={sm:"0.875em",md:"1em",lg:"1.25em"},ko={sm:"1.25em",md:"1.5em",lg:"2em"},Co={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},$n={sm:"8px",md:"16px",lg:"32px"},_o={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Io={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 Kn(e){return{opacity:e==="muted"?"0.7":void 0,"font-weight":e==="accent"?"600":void 0}}function jn(e,t){var n,r,o,c,i,s,a,u,l,d,m,w;try{switch(e.type){case"stack":case"grid":{let p=t.createElement("div");if(e.type==="stack"){let h=e;ce(p,{display:"flex","flex-direction":h.direction,gap:(r=it[(n=h.gap)!=null?n:"md"])!=null?r:it.md,"align-items":h.align?Pt[h.align]:void 0,"justify-content":h.justify?Pt[h.justify]:void 0,"flex-wrap":h.wrap?"wrap":void 0})}else{let h=e,E=(c=it[(o=h.gap)!=null?o:"md"])!=null?c:it.md;ce(p,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${h.columns-1} * ${E}) / ${h.columns})), 1fr))`,gap:E,"align-items":h.align?Pt[h.align]:void 0})}for(let h of(i=e.children)!=null?i:[]){let E=jn(h,t);E&&p.appendChild(E)}return p}case"text":{let p=t.createElement("p");return p.textContent=e.value,ce(p,J({margin:"0","font-size":e.size?Bn[e.size]:void 0,"font-weight":e.weight?Io[e.weight]:void 0,"text-align":e.align},Kn(e.tone)))}case"heading":{let p=t.createElement(`h${e.level}`);return p.textContent=e.value,ce(p,{margin:"0","font-size":ko[(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 h=(a=e.emphasis)!=null?a:"primary";return ce(p,{display:"inline-block",padding:Co[(u=e.size)!=null?u:"md"],"border-radius":(l=oe==null?void 0:oe.radius)!=null?l:"8px",font:"inherit","font-size":e.size?Bn[e.size]:void 0,"text-decoration":h==="ghost"?"underline":"none",cursor:"pointer",background:h==="primary"?(d=oe==null?void 0:oe.primaryBg)!=null?d:"#111827":"transparent",color:h==="primary"?(m=oe==null?void 0:oe.primaryText)!=null?m:"#ffffff":"inherit",border:h==="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"?_o[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,J({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:"1px solid currentColor"},Kn(e.tone)))}case"spacer":return ce(t.createElement("div"),{height:(w=$n[e.size])!=null?w:$n.md});default:return null}}catch(p){return null}}function Gn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(Ue);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 a=jn(s,r);if(!a)continue;let u=r.createElement("div");u.setAttribute(Ue,i),u.style.display="none",u.appendChild(a),e.appendChild(u)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(Ue),a=i;s!==null?a.style.display=c&&s===n?"":"none":c?a.hasAttribute(ue)||(a.setAttribute(ue,a.style.display),a.style.display="none"):a.hasAttribute(ue)&&(a.style.display=a.getAttribute(ue),a.removeAttribute(ue))}}catch(o){}}function Oo(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Ue)!==null){n.remove();continue}n.hasAttribute(ue)&&(n.style.display=n.getAttribute(ue),n.removeAttribute(ue))}}catch(t){}}function st(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Ue}]`)))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)||Oo(r)}catch(n){}}function Lt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function at(e,t,n,r){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t),r==null||r(n.documentElement,"data-sentient-persona"),r==null||r(n.documentElement,"data-sentient-confidence")}function lt(e,t,n,r){var o;for(let[c,i]of Object.entries(t)){let s=e[c];if(!s||typeof s=="string")continue;let a=Lt(i.target,n);for(let u of a)for(let[l,d]of Object.entries(s))(o=i.dims[l])!=null&&o.includes(d)&&(u.setAttribute(`data-${l}`,d),r==null||r(u,`data-${l}`))}}function ct(e,t,n,r){for(let[o,c]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!c.arms||!c.arms.includes(i))continue;let s=Lt(c.target,n);for(let a of s)a.setAttribute("data-sentient-arm",i),r==null||r(a,"data-sentient-arm")}}function ut(e,t,n,r){var s,a,u,l;let o=new Set,c=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[d,m]of Object.entries(t)){if(Ln(m.locator,n))continue;let w;if(m.locator){let h=ge(m.locator,n);w=h?[h]:[]}else w=Lt(m.target,n);(m.locator||m.target)&&w.length===0&&i.push(d);let p=e[d];for(let h of w){if(p!==void 0)if(typeof p=="string")h.setAttribute("data-sentient-arm",p),(a=r==null?void 0:r.onAttr)==null||a.call(r,h,"data-sentient-arm"),c&&((u=r==null?void 0:r.onApplied)==null||u.call(r,d,p,h));else for(let[E,C]of Object.entries(p))h.setAttribute(`data-${E}`,C),(l=r==null?void 0:r.onAttr)==null||l.call(r,h,`data-${E}`);if(m.blocks&&!Lo(n)){let E=Object.fromEntries(Object.entries(m.blocks).filter(([,C])=>!nt(C)));Object.keys(E).length>0&&(Gn(h,E,typeof p=="string"?p:void 0,n),o.add(h))}c&&(typeof m.content=="string"&&(h.textContent=m.content),m.ops&&Nn(h,m.ops,d,n).anchorMiss&&!i.includes(d)&&i.push(d))}}return st(n,o),i}var Po=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Lo(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:Po.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var Ro=800;function dt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},s)=>{r.push(Ke((m,w={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:J({signalType:m},w)})}catch(p){}},i,void 0,{tabLoss:s===0}));let a=null,u=0,l=()=>{u=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(m){}a=null},Ro)},d=()=>{a!==null&&(clearTimeout(a),a=null)};i.addEventListener("mouseenter",l),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",l),i.removeEventListener("mouseleave",d),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function To(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 zn(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var Do="_snt_fired_goals";function Fn(e,t){try{e==null||e.sessionStorage.removeItem(zn(t)),e==null||e.sessionStorage.removeItem(Do)}catch(n){}}function Un(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Mo(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 No(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function ft(e,t,n,r){var C,P;let o=(C=n.defaultView)!=null?C:typeof window!="undefined"?window:null,c=zn(r),i=Mo(o,c),s=f=>{let b=Un(f);if(!i.has(b))try{f.slotId?t.componentGoal(f.slotId,f.goalId):t.goal(f.goalId),i.add(b),No(o,c,i)}catch(_){}},a=e.filter(f=>f.event==="click"),u=e.filter(f=>f.event==="form_submit"),l=e.filter(f=>f.event==="url_reached"),d=e.filter(f=>f.event==="scroll_depth"),m=(f,b)=>{if(!f.locator)return!1;let _=ge(f.locator,n);return!!_&&(_===b||_.contains(b))},w=f=>{let b=f.target;if(!(!b||typeof b.closest!="function"))for(let _ of a)m(_,b)&&s(_)},p=f=>{let b=f.target;if(b)for(let _ of u)m(_,b)&&s(_)},h=()=>{if(l.length===0)return;let f=ot(n);for(let b of l)b.urlPattern&&To(b.urlPattern,f)&&s(b)},E=()=>{var _;let f=n.documentElement,b=f.scrollHeight>0?(f.scrollTop+f.clientHeight)/f.scrollHeight:0;for(let K of d)b>=((_=K.threshold)!=null?_:.75)&&s(K);d.every(K=>i.has(Un(K)))&&n.removeEventListener("scroll",E)};return n.addEventListener("click",w,!0),n.addEventListener("submit",p,!0),(P=n.defaultView)==null||P.addEventListener("popstate",h),h(),d.length>0&&(n.addEventListener("scroll",E,{passive:!0}),E()),{checkUrl:h,teardown:()=>{var f;n.removeEventListener("click",w,!0),n.removeEventListener("submit",p,!0),(f=n.defaultView)==null||f.removeEventListener("popstate",h),d.length>0&&n.removeEventListener("scroll",E)}}}function pt(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),c=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(c.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return c}var qn="__snt_editor_token";function Wn(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(qn):null}catch(e){return null}}function Hn(e){try{sessionStorage.setItem(qn,e)}catch(t){}}var We="0.24.1",ht=We!=="0.0.0-dev"?{name:"snippet",version:We}:void 0,tr=5e3,Bo=50,nr=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),V=null,T=null,de={},ye=null,U=null,he=null,W=null,ie=null,$=null,Ae=null,Jn=!1,Rt=null,gt=null,yt=null,Ie=!1,Fe=!1,xe=!1;function rr(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 Ee(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Oe(e,t){return V?(V.personaAttributes&&$&&at($.persona,$.band,e,t==null?void 0:t.onAttr),lt(de,V.slots,e,t==null?void 0:t.onAttr),ct(de,V.slots,e,t==null?void 0:t.onAttr),ye?ut(de,ye,e,t):(st(e,new Set),[])):[]}function or(e){var n;let t=new Map;for(let r of(n=V==null?void 0:V.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function Tt(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=pt(e,or(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function $o(e,t,n){let r=(o,c)=>t.some(([i,s])=>i===o&&s===c);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[c,i,s]=o;!c||typeof i!="string"||r(c,i)||(s==null?c.removeAttribute(i):c.setAttribute(i,s))}if(Array.isArray(e.html))for(let o of e.html)typeof o!="string"||r(n.documentElement,o)||n.documentElement.removeAttribute(o)}catch(o){}}function Ko(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function ir(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function jo(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function Pe(){return!!(V&&T&&V.sectionCapture!==!1&&(V.consent!==!1||Fe)&&!Se())}function Go(){if(!T||!V||!Pe()||ie)return;let e=[];Oe(document,{contentAndOps:Ie,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Mt();try{W==null||W(),W=dt(T,V.apiKey,e)}catch(t){}}function Mt(){if(typeof document=="undefined"||!Pe())return;let e;try{if(gt&&gt.length>0){let t=new Map;for(let n of gt){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{ie=Pn(T,J({apiKey:V.apiKey,apiBase:V.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),yt=window.location.pathname}catch(t){}}function Nt(){try{let e=[];if(W==null||W(),W=null,Oe(document,{contentAndOps:Ie,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Tt(Ae,document),e.length>0&&Pe())try{W=dt(T,V.apiKey,e)}catch(t){}try{typeof window!="undefined"&&yt!==null&&window.location.pathname!==yt&&Pe()&&(ie==null||ie(),ie=null,Mt())}catch(t){}}catch(e){}}function Vn(){Rt===null&&(Rt=setTimeout(()=>{Rt=null,Nt();try{U==null||U.checkUrl()}catch(e){}},Bo))}function Dt(){if(!(Jn||typeof window=="undefined"||typeof history=="undefined")){Jn=!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 Vn(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Vn)}catch(e){}}}function mt(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 sr(e){return new URLSearchParams(e).get("sentient_editor")}function Uo(){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 zo(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 a=document.createElement("meta");a.name="referrer",a.content="no-referrer",a.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let i=(o=e.editorSrc)!=null?o:Uo();if(!i){Yn();return}let s=document.createElement("script");s.src=i,s.async=!0,s.onerror=()=>Yn(),((c=document.head)!=null?c:document.documentElement).appendChild(s)}catch(i){}}var Xn="sentient-editor-load-notice",ar={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Yn(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Xn))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Xn,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,ar,{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 lr(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 s={};for(let a of i.split(",")){let[u,l]=a.split("=");u&&l&&(s[u]=l)}Object.keys(s).length&&(n[c]=s)}else n[c]=i}return Object.keys(n).length?n:null}function cr(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Zn="sentient-persona-preview-banner";function Qn(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Zn))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Zn,o.setAttribute("role","status"),Object.assign(o.style,ar,{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 s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Fo(e,t){var u,l,d,m,w,p,h,E,C,P;let n=(u=e.apiBase)!=null?u:"https://api.sentient-ui.com",o=((l=e.registry)!=null?l:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,b])=>({id:f,dims:b.dims}))},c=await rr(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(f=>f.ok?f.json():null).catch(()=>null),tr);if(!c){qe(e),Ee(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;de=(d=i.slots)!=null?d:{},ye=(m=i.slotConfig)!=null?m:null,ze(i.palette);let s=(h=(p=(w=i.personaAttributes)==null?void 0:w.persona)!=null?p:i.persona)!=null?h:t,a=(C=(E=i.personaAttributes)==null?void 0:E.confidence)!=null?C:"high";$={persona:s,band:a},Oe(document),Ie=!0,Dt(),qe(e),i.recognized===!1?Qn(t,!0):Qn((P=i.personaDisplay)!=null?P:s)}function qe(e){let t={goal(n,r){try{T==null||T.goal(n,r)}catch(o){}},componentGoal(n,r){try{T==null||T.componentGoal(n,r)}catch(o){}},grantConsent(){try{!T&&xe?(T=je(J({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:ir(e)},ht?{sdk:ht}:{})),he&&he.length>0&&(U==null||U.teardown(),U=ft(he,T,document,e.apiKey))):(_t(e.apiKey),T&&he&&he.length>0&&(U==null||U.teardown(),U=ft(he,T,document,e.apiKey))),xe=!1}catch(n){}Fe=!0;try{Go()}catch(n){}},revokeConsent(){try{ie==null||ie(),ie=null,yt=null,W==null||W(),W=null,U==null||U.teardown(),U=null,Fn(typeof window!="undefined"?window:null,e.apiKey),Fe=!1,xe=!0,T==null||T.destroy(),T=null}catch(n){}},reapply:Nt,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:mt(e),consent:!xe&&(e.consent!==!1||Fe)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of nr.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function er(){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})},nr.length=0}catch(t){}}async function ur(){var e,t;try{let n=rt(window.sentient);if(!n){er();return}V=n,Ie=!1,Ae=null,ze(null),Fe=!1,xe=!1,he=null;let r=typeof window!="undefined"?sr(window.location.search):null;if(r){Hn(r);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 o=r!=null?r:Wn();if(o){zo(n,o),qe(n),Ee(n,"editor mode");return}let c=typeof window!="undefined"?lr(window.location.search):null;if(c){de=c,$=null,Oe(document),Dt(),qe(n),Ee(n,"preview mode",c);return}let i=typeof window!="undefined"?cr(window.location.search):null;if(i){await Fo(n,i),Ee(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0,a=Ko();try{(t=a==null?void 0:a.stop)==null||t.call(a)}catch(f){}let u=Be(n.apiKey),l=[];u&&($={persona:u.persona,band:u.band},de=u.slots,u.slotConfig&&(ye=u.slotConfig),u.palette&&ze(u.palette),Oe(document,J({contentAndOps:!1},a?{onAttr:(f,b)=>l.push([f,b])}:{})),u.layoutOrder&&(Ae=u.layoutOrder,Tt(Ae,document))),a&&$o(a,l,document);let d=je(J({apiKey:n.apiKey,context:n.context,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:ir(n)},ht?{sdk:ht}:{}));T=d,qe(n),Dt();let m=Object.entries(n.slots).map(([f,b])=>({id:f,dims:b.dims})),w=We!=="0.0.0-dev"?{v:We}:{},p={pp:a?a.v:0},h=Array.from(or(document).keys()),E=d.decide(J(J(J(J({slots:m},w),p),h.length>=2?{sections:h}:{}),s?{slotsFrom:"registry"}:{})),C=await rr(E,tr),P=f=>{var K,A,D,G,X,M;let b=d.getPersona();b?$={persona:b.persona,band:b.band}:f.persona&&($={persona:f.persona,band:"low"}),de=f.slots,s?ye=(K=f.slotConfig)!=null?K:null:f.slotConfig&&(ye=f.slotConfig),f.palette&&ze(f.palette),Ae=(A=f.layoutOrder)!=null?A:Ae;let _=()=>{let j=[];if(jo(n,Oe(document,{onApplied:(se,S,v)=>j.push({slotId:se,arm:S,el:v})})),Tt(Ae,document),Ie=!0,Pe())try{W==null||W(),W=dt(T,n.apiKey,j)}catch(se){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",_,{once:!0}):_(),he=(D=f.goals)!=null?D:null,f.goals&&f.goals.length>0&&n.consent!==!1&&T)try{U==null||U.teardown(),U=ft(f.goals,T,document,n.apiKey)}catch(j){}gt=(G=f.sectionMap)!=null?G:null,Pe()&&Mt(),Ee(n,"applied",{persona:$,slots:de,matches:mt(n)}),!xe&&$e(n.apiKey,J(J({v:1,persona:(X=$==null?void 0:$.persona)!=null?X:f.persona,band:(M=$==null?void 0:$.band)!=null?M:"low",slots:f.slots,layoutOrder:f.layoutOrder,savedAt:Date.now()},ye?{slotConfig:ye}:{}),f.palette?{palette:f.palette}:{}))};if(!C){Ee(n,"decide timeout/null \u2014 snapshot state stands",mt(n)),E.then(f=>{!f||Ie||xe||T!==d||(P(f),Ee(n,"late decide applied",mt(n)))}).catch(()=>{});return}P(C)}catch(n){er()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{ur()}))}return hr(qo);})();
1
+ "use strict";var SentientSnippet=(()=>{var Xe=Object.defineProperty,wr=Object.defineProperties,Sr=Object.getOwnPropertyDescriptor,Ar=Object.getOwnPropertyDescriptors,xr=Object.getOwnPropertyNames,Ht=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Er=Object.prototype.propertyIsEnumerable;var Jt=(e,t,n)=>t in e?Xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))Vt.call(t,n)&&Jt(e,n,t[n]);if(Ht)for(var n of Ht(t))Er.call(t,n)&&Jt(e,n,t[n]);return e},Ze=(e,t)=>wr(e,Ar(t));var Yt=(e,t)=>()=>(e&&(t=e(e=0)),t);var Xt=(e,t)=>{for(var n in t)Xe(e,n,{get:t[n],enumerable:!0})},kr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xr(t))!Vt.call(e,o)&&o!==n&&Xe(e,o,{get:()=>t[o],enumerable:!(r=Sr(t,o))||r.enumerable});return e};var _r=e=>kr(Xe({},"__esModule",{value:!0}),e);var Cr,Or,Ir,Zt,Lr,Rr,Qt,D,we,$e=Yt(()=>{"use strict";Cr=Object.defineProperty,Or=Object.defineProperties,Ir=Object.getOwnPropertyDescriptors,Zt=Object.getOwnPropertySymbols,Lr=Object.prototype.hasOwnProperty,Rr=Object.prototype.propertyIsEnumerable,Qt=(e,t,n)=>t in e?Cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,D=(e,t)=>{for(var n in t||(t={}))Lr.call(t,n)&&Qt(e,n,t[n]);if(Zt)for(var n of Zt(t))Rr.call(t,n)&&Qt(e,n,t[n]);return e},we=(e,t)=>Or(e,Ir(t))});var fn={};Xt(fn,{LOCAL_ENGINE_AVAILABLE:()=>Nr,createLocalEngine:()=>Kr});function Kr(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Nr,pn=Yt(()=>{"use strict";Nr=!1});var ri={};Xt(ri,{applyPersonaAttributes:()=>ut,applyRegistrySlots:()=>pt,applySlotArms:()=>ft,applySlotAttributes:()=>dt,parseEditorToken:()=>gr,parsePersonaPreview:()=>yr,parsePreview:()=>hr,parseSnippetConfig:()=>at,planReorder:()=>ht,reapply:()=>Gt,run:()=>vr,version:()=>Ve});$e();var Pr=["buyer","researcher","deal_seeker","browser"];var Tr={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 en(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 At(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 tn(e,t){var n,r;return e.dims!=null?(r=(n=en(t))!=null?n:en(At(e)))!=null?r:{}:t}function nn(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 Se(e){return e>=.3?e<.7?"medium":"high":"low"}var si=Pr.map(e=>({key:e,displayName:Tr[e]}));function et(e){return e?`_${e.slice(0,12)}`:""}var Dr="_snt_uid";function rn(e){return`${Dr}${et(e)}`}var Mr=["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 on(e){return Br(e)!==null}function Br(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Mr.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function sn(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 an(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 ln(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var $r=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function cn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,c])=>{let i=Array.isArray(c)?c[0]:c;return i===void 0?[]:[[o,i]]});for(let[o,c]of r)o.startsWith("utm_")?o in t||(t[o]=c):$r.includes(o)&&(o in n||(n[o]=c))}catch(r){}return{utmParams:t,clickIds:n}}function un(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function xt(e){return D(D(D({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 Et(e){let t=xt(e);return tn(t,At(t))}function dn(e){return typeof e=="string"?e:Qe(e)}$e();function bn(){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 jr="_snt_uid",Gr=365,tt="_snt_uid";function Ur(){return bn()}function gn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Fr(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function kt(e){try{return localStorage.getItem(e)}catch(t){return null}}function mn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function hn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function zr(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Wr(e){try{sessionStorage.removeItem(e)}catch(t){}}function qr(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 Hr(e){try{localStorage.removeItem(e)}catch(t){}}function Jr(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Vr={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function wn(e){var t,n,r,o,c,i,s;if(typeof window=="undefined")return Vr;let a=et(e==null?void 0:e.apiKey),d=(t=e==null?void 0:e.cookieName)!=null?t:rn(e==null?void 0:e.apiKey),l=`${tt}${a}`,u=`${tt}_tomb${a}`,g=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Gr)*24*60*60,v=m=>m&&m.length>0?m:null,w=()=>{var m,O;return a&&!(e!=null&&e.cookieName)&&kt(u)===null?(O=(m=v(gn(jr)))!=null?m:v(kt(tt)))!=null?O:v(hn(tt)):null},A=(s=(i=(c=(o=(r=v(gn(d)))!=null?r:v(kt(l)))!=null?o:v(hn(l)))!=null?c:w())!=null?i:v(e==null?void 0:e.ssrSessionId))!=null?s:Ur();Fr(d,A,g);let P=mn(l,A),E=qr(d),L=P?!1:zr(l,A),f=!P&&!E&&!L;return{getSessionId:()=>A,isEphemeral:()=>f,destroy:()=>{A=null,Jr(d),Hr(l),Wr(l),a&&!(e!=null&&e.cookieName)&&mn(u,"1")}}}function Ke(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Lt(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 Sn(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 Oe(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 An(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 Yr=500,Xr=56*1024;function xn(e){return`_snt_retry_${e.slice(0,12)}`}var Zr={push:()=>{},flush:()=>{},destroy:()=>{}};function Qr(e){var t,n,r;if(typeof window=="undefined")return Zr;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,a=e.apiKey,d=xn(a),l=[],u=new Set,g=[],v=b=>{for(let h of b)w.delete(h),!u.has(h)&&(u.add(h),g.push(h));for(;g.length>Yr;){let h=g.shift();h&&u.delete(h)}An(b,d)},w=new Set,A=()=>{for(;l.length>i;){let b=l.shift();b&&w.delete(b.id)}},P=b=>{u.has(b.id)||w.has(b.id)||(w.add(b.id),l.push(b),A())},E=b=>{for(let h of b)u.has(h.id)||(w.add(h.id),l.push(h));A()},L=Sn(d,i);for(let b of L)P(b);let f=0,m=0,O=(b,h=!0)=>{if(b.length===0)return;let C=JSON.stringify(b),_=b.map(Y=>Y.id),T;try{T=fetch(s,{method:"POST",keepalive:!0,body:C,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(Y){Oe(b,i,d),E(b),m++,f=Date.now()+Ke(m);return}let te=Y=>{if(Lt(Y)!=="retry"){if(!Y.ok&&h){let oe=b.filter(ie=>ie.eventType!=="pageview");if(oe.length>0&&oe.length<b.length){v(b.filter(ie=>ie.eventType==="pageview").map(ie=>ie.id)),O(oe,!1);return}}v(_),m=0,f=0;return}Oe(b,i,d),E(b),m++,f=Date.now()+Ke(m)};T instanceof Promise?T.then(te).catch(()=>{Oe(b,i,d),E(b),m++,f=Date.now()+Ke(m)}):te(T)},x=typeof TextEncoder!="undefined"?new TextEncoder:null,S=b=>x?x.encode(b).length:b.length,$=b=>{let h=[],C=2;for(let _ of b){let T=S(JSON.stringify(_))+1;if(h.length>0&&C+T>Xr||h.length>=c)break;h.push(_),C+=T}return h},R=()=>{try{if(Date.now()<f)return;for(;l.length>0&&!(Date.now()<f);){let b=l.filter(C=>!u.has(C.id));if(l.length=0,b.length===0)break;let h=$(b);if(h.length===0)break;h.length<b.length&&l.push(...b.slice(h.length)),O(h)}}catch(b){}},F=!0,G=null;G=setInterval(()=>{F&&R()},o);let q=()=>{document.visibilityState==="hidden"&&R()},le=()=>{R()};return document.addEventListener("visibilitychange",q),window.addEventListener("pagehide",le),{push(b){P(b),l.length>=c&&R()},flush:R,destroy(){F=!1,G!==null&&(clearInterval(G),G=null),document.removeEventListener("visibilitychange",q),window.removeEventListener("pagehide",le),R()}}}var eo=200;function En(e){return`_snt_goal_retry_${e.slice(0,12)}`}var to={send:()=>{},flush:()=>{},destroy:()=>{}};function no(e){var t,n,r;if(typeof window=="undefined")return to;let o=(t=e.flushIntervalMs)!=null?t:5e3,c=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=En(e.apiKey),a=[],d=new Set,l=new Set,u=[],g=0,v=0,w=!1,A=S=>{for(d.delete(S.id),l.has(S.id)||(l.add(S.id),u.push(S.id));u.length>eo;){let $=u.shift();$&&l.delete($)}An([S.id],s)},P=S=>{Oe([S],c,s),!l.has(S.id)&&!d.has(S.id)&&(d.add(S.id),a.push(S)),Date.now()>=g&&(v++,g=Date.now()+Ke(v))},E=S=>{let $;try{$=fetch(e.url,{method:"POST",keepalive:!0,body:S.body,headers:e.headers})}catch(F){P(S);return}let R=F=>{var G;let q=Lt(F);if(q==="retry"){P(S);return}q==="dropped"&&((G=e.onDrop)==null||G.call(e,S,F.status)),A(S),v=0,g=0};$ instanceof Promise?$.then(R).catch(()=>P(S)):R($)},L=()=>{try{if(w||Date.now()<g)return;let S=0;for(;a.length>0&&S<i&&!(Date.now()<g);){let $=a.shift();d.delete($.id),!l.has($.id)&&(S++,E($))}}catch(S){}},f=Sn(s,c);for(let S of f)d.has(S.id)||(d.add(S.id),a.push(S));f.length>0&&Oe(f,c,s);let m=setInterval(L,o),O=()=>{document.visibilityState==="hidden"&&L()},x=()=>L();return document.addEventListener("visibilitychange",O),window.addEventListener("pagehide",x),{send(S){if(!w&&!(l.has(S.id)||d.has(S.id))){if(Date.now()<g){Oe([S],c,s),d.add(S.id),a.push(S);return}E(S)}},flush:L,destroy(){clearInterval(m),document.removeEventListener("visibilitychange",O),window.removeEventListener("pagehide",x),L(),w=!0}}}var ro=1800*1e3;function nt(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function oo(e=ro,t){let n=new Map,r=`_snt_asgn${et(t)}_`,o=(a,d)=>`${r}${encodeURIComponent(a)}:${encodeURIComponent(d)}`,c=a=>{let d=a.slice(r.length),l=d.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(d.slice(0,l)),segment:decodeURIComponent(d.slice(l+1))}}catch(u){return null}},i=()=>{try{let a=[];for(let d=0;d<localStorage.length;d++){let l=localStorage.key(d);l!=null&&l.startsWith(r)&&a.push(l)}return a}catch(a){return[]}},s=a=>a.assignedAt+(a.ttlMs&&a.ttlMs>0?a.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let a of i())try{let d=localStorage.getItem(a);if(!d)continue;let l=JSON.parse(d);if(s(l)){localStorage.removeItem(a);continue}let u=c(a);if(!u)continue;n.set(nt(u.componentId,u.segment),l)}catch(d){}})(),{get(a,d){let l=n.get(nt(a,d));return l?s(l)?(n.delete(nt(a,d)),null):l:null},set(a,d,l){let u=nt(a,d);n.set(u,l);try{localStorage.setItem(o(a,d),JSON.stringify(l))}catch(g){}},clear(){n.clear();for(let a of i())try{localStorage.removeItem(a)}catch(d){}}}}var it="_snt_snap:",io=["low","medium","high"];function je(e){try{let t=localStorage.getItem(it+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"||!io.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 Ge(e,t){try{localStorage.setItem(it+e,JSON.stringify(t))}catch(n){}}var Ot="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",kn="[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.",yn=!1,rt=!1;function so(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function ao(e){var t;let n=wn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=so(),c=Promise.resolve().then(()=>(pn(),fn)).then(l=>{let u=l;return u.LOCAL_ENGINE_AVAILABLE?(yn||(yn=!0,console.info(kn)),u):(rt||(rt=!0,console.error(Ot)),null)}).catch(()=>(rt||(rt=!0,console.error(Ot)),null)),i=null,s={low:.15,medium:.5,high:.85},a=(()=>{var l;if(e.initialPersona)return D({},e.initialPersona);let u=je(e.apiKey||"local");return u?{persona:u.persona,confidence:(l=s[u.band])!=null?l:.15}:null})();function d(l){let u=document.documentElement;u.dataset.sentientPersona===void 0&&(u.dataset.sentientPersona=l.persona,u.dataset.sentientConfidence=Se(l.confidence))}return{isLocal:!0,async decide(l){var u,g,v;let w=await c;if(!w)return null;let A=w.createLocalEngine({sessionId:r,forcedPersona:o}).decide(l);return i=we(D({},A),{layoutOrder:(g=(u=A.layoutOrder)!=null?u:i==null?void 0:i.layoutOrder)!=null?g:null,slots:D(D({},(v=i==null?void 0:i.slots)!=null?v:{}),A.slots)}),Ge(e.apiKey||"local",{v:1,persona:i.persona,band:Se(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),d(A),A},getSlotResult(l){var u,g,v;return(v=(g=i==null?void 0:i.slots[l])!=null?g:(u=e.initialSlots)==null?void 0:u[l])!=null?v:null},getSlotConfig(l){var u,g;return(g=(u=e.initialSlotConfig)==null?void 0:u[l])!=null?g:null},getSitePalette(){var l;return(l=e.initialPalette)!=null?l:null},reportSlots(){},getPersona(){let l=i!=null?i:a;return l?{persona:l.persona,confidence:l.confidence,band:Se(l.confidence)}:null},async assign(l,u){var g;let v=await c;return!v||!u||u.length===0?u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null:{variantId:(g=v.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:l,variantIds:u}]}).assignments[l])!=null?g:u[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function st(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(st):!1}var vn="sentient-reveal",Ie="sentient-revealed";var _t=!1;function lo(e){if(_t||e.getElementById(vn)){_t=!0;return}let t=e.createElement("style");t.id=vn,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${Ie}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${Ie}{animation:${Ie} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),_t=!0}function Rt(e,t={}){var n;let r=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!r||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;lo(r),e.classList.remove(Ie),e.offsetWidth,e.classList.add(Ie);let o=()=>{e.classList.remove(Ie),e.removeEventListener("animationend",o)};return e.addEventListener("animationend",o),!0}function Ue(e,t,n,r){let o=[];{let c=!1,i=[],s=()=>{if(c)return;let a=Date.now();for(i.push(a);i.length>0&&a-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let c=!1,i=s=>{if(c||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;c=!0;let a=typeof window!="undefined"?window.getSelection():null,d=a?a.toString().length:0;e("text_copy",{selectionLength:d})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null)},d=()=>{c||!i||(a(),s=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},l=()=>{a(),d()},u=v=>{for(let w of v)i=w.intersectionRatio>.3,i?d():a()},g=new IntersectionObserver(u,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",l,{passive:!0}),o.push(()=>{g.disconnect(),window.removeEventListener("scroll",l),a()})}if((r==null?void 0:r.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),s=()=>{if(c||document.visibilityState!=="hidden")return;let a=Date.now()-i;a<15e3&&(c=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let c of o)c()}}function co(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var _n="https://api.sentient-ui.com/v1/events",ne=new Map,Cn=null;function uo(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var fo=3;function Ct(){return bn()}function ot(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function po(){let e=new WeakMap,t=new Map,n=!1,r=(s,a,d)=>{let l=s.get(a);return d===null?l?!0:(s.set(a,new Set),!1):l?l.has(d)?!0:(l.add(d),!1):(s.set(a,new Set([d])),!1)},o=typeof window!="undefined"&&"event"in window,c=()=>{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,a=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(a,0),typeof MessageChannel=="function"){let d=new MessageChannel;d.port1.onmessage=()=>{d.port1.close(),d.port2.close(),a()},d.port2.postMessage(0)}};return{firedBefore(s,a){let d=c();if(d){let u=e.get(d);return u||(u=new Map,e.set(d,u)),r(u,s,a)}let l=r(t,s,a);return!l&&!n&&(n=!0,i()),l}}}var On=new Set;function go(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,c,i=()=>{if(o)return;let d=ot();!d||d===c||(c=d,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${d}`))},s=[];for(let d of["pushState","replaceState"]){let l=r[d],u=function(...g){let v=l.apply(this,g);return i(),v};r[d]=u,s.push([d,l,u])}window.addEventListener("popstate",i);let a=ot();return a&&On.has(`${t}:${a}`)?c=a:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[d,l,u]of s)r[d]===u&&(r[d]=l)}}}var Ne={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function mo(){try{return cn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function In(e){return e.replace(/\/events\/?$/,"")}function Ae(){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 Pt(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Cn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=ne.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&&Ae())return;let s=(i!=null?i:Fe)(we(D({},o),{consent:!0}));c(s);let a=(t=ne.get(n))==null?void 0:t.dispose;ne.set(n,{config:we(D({},o),{consent:!0}),upgrade:null,dispose:a})}function ho(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=In((t=e.ingestUrl)!=null?t:_n),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},c=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(l,u,g){if(!n)return Promise.resolve(null);let v=c.get(l);return v?Promise.resolve(v):It(i,l,async()=>{try{let w=new URLSearchParams({componentId:l});for(let E of u!=null?u:[])w.append("variantIds[]",E);let A=await fetch(`${r}/winner?${w.toString()}`,{headers:o});if(!A.ok)return u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null;let P={variantId:(await A.json()).variantId,assignmentTtlMs:0};return c.set(l,P),P}catch(w){return u!=null&&u[0]?{variantId:u[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},a={track:l=>s.track(l),goal:((l,u,g,v)=>s.goal(l,u,g,v)),componentGoal:(l,u,g)=>s.componentGoal(l,u,g),identify:l=>s.identify(l),getAssignment:(l,u)=>s.getAssignment(l,u),assign:(l,u,g,v)=>s.assign(l,u,g,v),decide:l=>s.decide(l),getSlotResult:l=>s.getSlotResult(l),getSlotConfig:l=>s.getSlotConfig(l),getSitePalette:()=>s.getSitePalette(),reportSlots:(l,u)=>s.reportSlots(l,u),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function d(l){s=l}return{proxy:a,setInner:d}}function It(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 Fe(e){var t,n,r,o,c,i,s,a,d,l;if(typeof window=="undefined")return Ne;Cn=e.apiKey||"local";let u=ne.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(p){}let g=e.respectDoNotTrack!==!1&&Ae(),v=e.consent===!1||g,w=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!w&&e.localMode!==!1)return ne.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."}),v?Ne:ao(e);if(v){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."),ne.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."}),Ne;let{proxy:p,setInner:y}=ho(e);return ne.set(e.apiKey,{config:e,upgrade:g?null:y}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),Ne;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Ne;let A=(t=e.ingestUrl)!=null?t:_n,P=Date.now(),E=wn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),L=oo(void 0,e.apiKey),f=Qr({ingestUrl:A,apiKey:e.apiKey}),m=In(A),O={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},x=new Set,S=no({url:`${m}/goals`,apiKey:e.apiKey,headers:O,onDrop:(p,y)=>{if(!e.debug){if(x.has(y))return;x.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),$=sn((n=navigator.userAgent)!=null?n:""),R=window.location.origin,F=an((r=document.referrer)!=null?r:"",R),G=(o=e.sessionSegment)!=null?o:`${$}:${F}`,q=new Map,le=new Map,b=new Map,h=new Map,C=null,_=null,T=new Set,te=new Set,Y=new Map,oe=null,ie=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,_e=new Set,Ut=p=>{for(let y of p)b.has(y.id)||b.set(y.id,Et(y))};if(e.initialSlots)for(let[p,y]of Object.entries(e.initialSlots))b.set(p,y);if(e.initialSlotConfig)for(let[p,y]of Object.entries(e.initialSlotConfig))h.set(p,y);e.initialPalette&&(C=e.initialPalette);let fe=je(e.apiKey);if(fe){for(let[p,y]of Object.entries(fe.slots))b.has(p)||b.set(p,y);for(let[p,y]of Object.entries((c=fe.slotConfig)!=null?c:{}))h.has(p)||h.set(p,y);!C&&fe.palette&&(C=fe.palette)}let Ft={low:.15,medium:.5,high:.85};if(e.initialPersona)_=D({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?_={persona:p.sentientPersona,confidence:(s=Ft[(i=p.sentientConfidence)!=null?i:"low"])!=null?s:.15}:fe&&(_={persona:fe.persona,confidence:(a=Ft[fe.band])!=null?a:.15})}if(e.initialAssignments)for(let[p,y]of Object.entries(e.initialAssignments))L.set(p,G,{variantId:y,assignedAt:Date.now(),segment:G,confidence:1});let pe=Promise.resolve(),zt=E.getSessionId();if(zt){let p=ln((d=document.referrer)!=null?d:""),{utmParams:y,clickIds:I}=mo(),z=D(D(D(D({sessionId:zt,deviceClass:$,trafficSource:F,referrerDomain:p,utmParams:y,clickIds:I,timeOfDay:un(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:E.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||on((l=navigator.userAgent)!=null?l:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),U=async()=>{for(let M=0;;M++){try{let B=await fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(z),headers:O});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||Lt(B)==="dropped")return}catch(B){}if(M>=fo){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,Ke(M+1)))}};try{pe=U()}catch(M){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:f});let br=po(),De=null,St=!1,Ce={goal(p,y={},I=1,z=0){var U,M,B,J,Q,be,ge;let Me=E.getSessionId();if(!Me)return;let ee=uo(y)?y:{metadata:y},Be=[p,(U=ee.externalId)!=null?U:"",(M=ee.stepIndex)!=null?M:z,(B=ee.weight)!=null?B:I].join("\0"),N=ee.value!==void 0?`${ee.value}\0${(J=ee.currency)!=null?J:""}`:null;if(br.firedBefore(Be,N)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}let ce=Ct(),Ye={sessionId:Me,name:p,metadata:(Q=ee.metadata)!=null?Q:{},weight:(be=ee.weight)!=null?be:I,stepIndex:(ge=ee.stepIndex)!=null?ge:z,goalId:ce,value:ee.value,currency:ee.currency,externalId:ee.externalId};e.debug&&console.log("[sentient] goal",Ye);let V={id:ce,body:JSON.stringify(Ye)};pe.then(()=>S.send(V))},componentGoal(p,y,I){var z,U,M;let B=E.getSessionId();if(!B)return;let J=L.get(p,G),Q=J?null:(z=b.get(p))!=null?z:null;if(!J&&Q===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let be=J?J.variantId:dn(Q),ge={id:Ct(),sessionId:B,projectId:e.apiKey,componentId:p,variantId:be,eventType:"goal_achieved",goalType:y,payload:D({reward:(U=I==null?void 0:I.reward)!=null?U:1,goalValue:I==null?void 0:I.value,currency:I==null?void 0:I.currency},(M=I==null?void 0:I.metadata)!=null?M:{}),timestamp:Date.now(),timeInSession:Date.now()-P,path:ot()};e.debug&&console.log("[sentient] componentGoal",ge),pe.then(()=>f.push(ge))},identify(p){let y=E.getSessionId();y&&pe.then(()=>{fetch(`${m}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:p,ephemeral:E.isEphemeral()}),headers:O}).catch(()=>{})})},track(p){let y=E.getSessionId();if(!y)return;let I=we(D({path:ot()},p),{id:Ct(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-P});e.debug&&console.log("[sentient] track",I),pe.then(()=>f.push(I))},getAssignment(p,y){return L.get(p,y)},async assign(p,y,I,z){let U=E.getSessionId();if(!U)return null;let M=L.get(p,G);if(M&&(y!=null&&y.length||M.content!==void 0)){let B=M.ttlMs&&M.ttlMs>0?Math.max(0,M.assignedAt+M.ttlMs-Date.now()):0;return{variantId:M.variantId,assignmentTtlMs:B,content:M.content}}return It(q,p,async()=>{await pe;try{let B={sessionId:U,componentId:p,variantIds:y};z!==void 0?B.agentDataByVariant=z:I!==void 0&&(B.agentData=I);let J=await fetch(`${m}/assign`,{method:"POST",body:JSON.stringify(B),headers:O});if(!J.ok)return null;let Q=await J.json();return L.set(p,G,D({variantId:Q.variantId,assignedAt:Date.now(),segment:G,confidence:1,content:Q.content},Q.assignmentTtlMs&&Q.assignmentTtlMs>0?{ttlMs:Q.assignmentTtlMs}:{})),Q}catch(B){return null}})},async decide(p){var y,I;let z=E.getSessionId();if(!z)return null;let U=(y=p.slots)!=null?y:[],M={sessionId:z};p.sections&&p.sections.length>0&&(M.sections=p.sections.map(J=>({id:J}))),M.components=(I=p.components)!=null?I:[],U.length>0&&(M.slots=U.map(xt)),p.slotsFrom==="registry"&&(M.slotsFrom="registry"),p.v&&(M.v=p.v),typeof p.pp=="number"&&(M.pp=p.pp),e.persona&&(M.persona=e.persona);let B=JSON.stringify(M);return It(le,B,async()=>{var J,Q,be,ge,Me,ee;await pe;try{let Be=await fetch(`${m}/decide`,{method:"POST",body:B,headers:O});if(!Be.ok)return Ut(U),null;let N=await Be.json(),ce={};for(let V of U){let se=(J=N.slots)==null?void 0:J[V.id];if(se!==void 0){ce[V.id]=se,b.set(V.id,se);continue}let Wt=b.get(V.id);if(Wt!==void 0)ce[V.id]=Wt;else{let qt=Et(V);ce[V.id]=qt,b.set(V.id,qt)}}if(N.slots)for(let[V,se]of Object.entries(N.slots))V in ce||(ce[V]=se,b.set(V,se));let Ye=_!=null&&_.persona!=="unknown";N.persona&&!(N.persona==="unknown"&&Ye)?_={persona:N.persona,confidence:(Q=N.confidence)!=null?Q:0}:_||(_={persona:"unknown",confidence:0});for(let[V,se]of Object.entries((be=N.assignments)!=null?be:{}))L.set(V,G,{variantId:se,assignedAt:Date.now(),segment:G,confidence:1});if(N.slotConfig)for(let[V,se]of Object.entries(N.slotConfig))h.set(V,se);return N.palette&&(C=N.palette),Ge(e.apiKey,D(D({v:1,persona:_.persona,band:Se(_.confidence),slots:Object.fromEntries(b),layoutOrder:(ge=N.layoutOrder)!=null?ge:null,savedAt:Date.now()},h.size>0?{slotConfig:Object.fromEntries(h)}:{}),C?{palette:C}:{})),D(D(D(D({layoutOrder:(Me=N.layoutOrder)!=null?Me:null,assignments:(ee=N.assignments)!=null?ee:{},slots:ce,persona:_.persona,confidence:_.confidence},N.slotConfig?{slotConfig:N.slotConfig}:{}),N.goals?{goals:N.goals}:{}),N.sectionMap?{sectionMap:N.sectionMap}:{}),N.palette?{palette:N.palette}:{})}catch(Be){return Ut(U),null}})},getSlotResult(p){var y;return(y=b.get(p))!=null?y:null},getSlotConfig(p){var y;return(y=h.get(p))!=null?y:null},reportSlots(p,y){for(let I of p)if(!(typeof I!="string"||I.length===0)){if(!ie.test(I)){co()&&!_e.has(I)&&(_e.add(I),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(I)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!T.has(I)){T.add(I),te.add(I);let z=y==null?void 0:y[I];if(typeof z=="string"){let U=z.replace(/\s+/g," ").trim().slice(0,400);U!==""&&Y.set(I,U)}}}te.size===0||oe!=null||(oe=setTimeout(()=>{oe=null;let I=[...te];te.clear();for(let z=0;z<I.length;z+=20){let U=I.slice(z,z+20),M={};for(let B of U){let J=Y.get(B);J!==void 0&&(M[B]=J,Y.delete(B))}fetch(`${m}/slots/observed`,{method:"POST",headers:O,body:JSON.stringify(D({slotIds:U},Object.keys(M).length>0?{baselineTexts:M}:{}))}).catch(()=>{})}},1e3))},getSitePalette(){return C},getPersona(){return _?{persona:_.persona,confidence:_.confidence,band:Se(_.confidence)}:null},async fetchWeights(){var p;try{let y=await fetch(`${m}/weights`,{headers:O});return y.ok?(p=(await y.json()).components)!=null?p:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var p;De==null||De(),St=!0,f.destroy(),S.destroy(),((p=ne.get(e.apiKey))==null?void 0:p.dispose)===Ce.dispose&&ne.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;De==null||De(),St=!0,f.destroy(),S.destroy(),E.destroy(),L.clear(),((p=ne.get(e.apiKey))==null?void 0:p.dispose)===Ce.dispose&&ne.delete(e.apiKey);try{localStorage.removeItem(it+e.apiKey),localStorage.removeItem(xn(e.apiKey)),localStorage.removeItem(En(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(ne.set(e.apiKey,{config:e,upgrade:null,dispose:Ce.dispose}),De=go(Ce,e.apiKey,p=>{pe.then(()=>{St||On.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=Ce)}return Ce}var yo=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function Tt(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function vo(e){return{tag:e.tagName.toLowerCase(),text:Tt(e).slice(0,40)}}function Ln(e){return e.replace(/["\\\]]/g,"\\$&")}function ze(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function Rn(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)),c=[r,...o.map(s=>`${r}.${s}`)];for(let s of c)if(ze(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=Rn(i,t);if(s){for(let u of c){let g=`${s} > ${u}`;if(ze(t,g))return g}let a=Array.from(i.children).filter(u=>u.tagName.toLowerCase()===r),d=a.indexOf(e),l=a.some(u=>u!==e&&Tt(u)!==Tt(e));if(d>=0&&l){let u=`${s} > ${r}:nth-of-type(${d+1})`;if(ze(t,u))return u}}}return null}function Pn(e,t){let n=vo(e),r=e.getAttribute("id");if(r&&ze(t,`#${Ln(r)}`))return{v:1,id:r,fingerprint:n};for(let c of yo){let i=e.getAttribute(c);if(i&&ze(t,`[${c}="${Ln(i)}"]`))return{v:1,dataAttr:{name:c,value:i},fingerprint:n}}let o=Rn(e,t);return o?{v:1,selector:o,fingerprint:n}:null}$e();var Dn=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],bo={banner:"hero",navigation:"navigation",contentinfo:"footer"};function wo(e){let t=e.ariaRole?bo[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 So(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Ao=[["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]],Dt=[["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]],Tn={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function xo(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Mn(e){var t,n;let r=wo(e);if(r)return{type:(t=Tn[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of Ao)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of Dt)if(s.test(e.bodyText))return{type:i,strength:"strong"};let c=So(e);return{type:(n=Tn[c])!=null?n:"generic",strength:"weak"}}function Bn(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return D({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:xo(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}$e();var Eo="section, header, footer, nav, main > div, [data-sentient-section]",ko=2e4;function _o(e){let t=Array.from(e.querySelectorAll(Eo)),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 Co(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 $n=()=>{};function Nn(e,t){var n,r,o,c,i,s,a,d,l,u,g,v;let w=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!w||typeof IntersectionObserver=="undefined"||Ae()||!t.apiKey||!t.apiKey.startsWith("pk_"))return $n;let A=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),P=_o(w);if(P.length===0)return $n;let E=new Map,L=[];for(let h of P){let C=h.getAttribute("data-sentient-type"),_=C&&Dn.includes(C)?C:null,T=Bn(h),te=(c=_!=null?_:(o=t.typeOf)==null?void 0:o.call(t,h))!=null?c:Mn(T).type,Y=Pn(h,w),oe=Y?`nc-${te}-${nn(JSON.stringify({id:(i=Y.id)!=null?i:null,dataAttr:(s=Y.dataAttr)!=null?s:null,selector:(a=Y.selector)!=null?a:null})).toString(36)}`:`nc-${te}`;E.set(h,oe);let ie=Dt.filter(([,_e])=>_e.test(T.bodyText)).map(([_e])=>_e);L.push(we(D({componentId:oe,semanticType:te,source:_?"markup":"auto"},Y?{locator:Y}:{}),{observation:D(D({tag:T.tag,idClass:T.idClass.slice(0,200),headingText:T.headingText,textLength:T.textLength,actionCount:T.actionCount},T.ariaRole?{ariaRole:T.ariaRole}:{}),ie.length>0?{patternFlags:ie}:{})}))}let f=(g=(u=(l=(d=w.defaultView)!=null?d:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:u.pathname)!=null?g:"/";Co(t.apiKey,A,f,L);let m=new Map,O=h=>{let C=m.get(h);return C||(C={ms:0,scroll:0,enterAt:null,intersecting:!1},m.set(h,C)),C},x=new IntersectionObserver(h=>{for(let C of h){let _=E.get(C.target);if(!_)continue;let T=O(_);C.isIntersecting?(T.intersecting=!0,T.enterAt=Date.now(),C.intersectionRatio>T.scroll&&(T.scroll=C.intersectionRatio)):(T.intersecting=!1,T.enterAt!=null&&(T.ms+=Date.now()-T.enterAt,T.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let h of E.keys())x.observe(h);let S=()=>{let h=Date.now();for(let[C,_]of m)if(_.enterAt!=null&&(_.ms+=h-_.enterAt,_.enterAt=null),!(_.ms<=0)){try{e.track({projectId:t.apiKey,componentId:C,eventType:"dwell",payload:{dwell_time:Math.round(_.ms),scroll_depth:Number(_.scroll.toFixed(2))}})}catch(T){}_.ms=0}},$=()=>{if(w.hidden)S();else{let h=Date.now();for(let C of m.values())C.intersecting&&(C.enterAt=h)}},R=!1,F=h=>{if(S(),h!=null&&h.persisted){R=!0;return}try{x.disconnect()}catch(C){}},G=h=>{if(!(h!=null&&h.persisted)||!R)return;R=!1;let C=Date.now();for(let _ of m.values())_.enterAt=_.intersecting&&!w.hidden?C:null};w.addEventListener("visibilitychange",$);let q=(v=w.defaultView)!=null?v:typeof window!="undefined"?window:void 0;q==null||q.addEventListener("pagehide",F),q==null||q.addEventListener("pageshow",G);let le=setInterval(()=>{if(w.hidden||R)return;S();let h=Date.now();for(let C of m.values())C.intersecting&&(C.enterAt=h)},ko),b=[];return t.microSignals&&[...E.entries()].forEach(([h,C],_)=>{b.push(Ue((T,te={})=>{try{e.track({projectId:t.apiKey,componentId:C,eventType:"micro_signal",payload:D({signalType:T},te)})}catch(Y){}},h,void 0,{tabLoss:_===0}))}),()=>{S(),clearInterval(le),w.removeEventListener("visibilitychange",$),q==null||q.removeEventListener("pagehide",F),q==null||q.removeEventListener("pageshow",G);for(let h of b)h();try{x.disconnect()}catch(h){}}}var Oo=["landing","ecommerce","saas","marketplace"];function Io(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 Lo(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Ro(e){try{return e()}catch(t){return}}function at(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=Oo.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 a=s,d=Io(a.dims);if(!d||a.target!==void 0&&typeof a.target!="string")continue;let l=a.arms!==void 0?Lo(a.arms):null,u={dims:d};typeof a.target=="string"&&(u.target=a.target),l&&(u.arms=l),r[i]=u}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"?Ro(t.persona):t.persona;if(typeof c=="string"&&c.trim()!==""&&(o.persona=c),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 lt(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 Po(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 Kn(e,t){return!!(e!=null&&e.urlMatch)&&!lt(t).includes(e.urlMatch)}var To=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function me(e,t){var o;if(e.urlMatch&&!lt(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)&&To.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&&!Po(r,e.fingerprint)?null:r}var jn={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"},Do=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Gn(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(!Do.test((r=n[1])!=null?r:""))return!1;return!0}var Un=/^https:\/\//i,Fn=new Map,he=null;function Mo(e){return e.replace(/["\\]/g,"\\$&")}function Bo(e){var t;(!he||!he.isConnected)&&(he=e.querySelector("style[data-sentient-ops]"),he||(he=e.createElement("style"),he.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(he))),he.textContent=[...Fn.entries()].map(([n,r])=>`[data-snt-e="${Mo(n)}"]{${r}}`).join(`
2
+ `)}function zn(e,t,n,r){var s;let o=!1,c=(s=t.moveBefore)!=null?s:t.moveAfter;if(c){let a=me(c,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Un.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Un.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[a,d]of Object.entries(t.style)){let l=jn[a];l&&typeof d=="string"&&Gn(d)&&i.push(`${l}:${d.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Fn.set(n,i.join(";")),Bo(r)),{anchorMiss:o}}var We="data-sentient-block-arm",k=null;function qe(e){k=e!=null?e:null}var ue="data-sentient-blocks-hid",Le={none:"0",sm:"8px",md:"16px",lg:"24px"},Mt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Wn={sm:"0.875em",md:"1em",lg:"1.25em"},$o={sm:"1.25em",md:"1.5em",lg:"2em"},No={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},qn={sm:"8px",md:"16px",lg:"32px"},Ko={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},jo={normal:"400",medium:"500",bold:"700"};function re(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function Hn(e){return e==="muted"?k!=null&&k.muted?{color:k.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:k==null?void 0:k.accent}:{}}function Jn(e,t){var n,r,o,c,i,s,a,d,l,u,g,v,w,A,P,E,L,f,m,O;try{switch(e.type){case"stack":case"grid":{let x=t.createElement("div");if(e.type==="stack"){let R=e;re(x,{display:"flex","flex-direction":R.direction,gap:(r=Le[(n=R.gap)!=null?n:"md"])!=null?r:Le.md,"align-items":R.align?Mt[R.align]:void 0,"justify-content":R.justify?Mt[R.justify]:void 0,"flex-wrap":R.wrap?"wrap":void 0})}else{let R=e,F=(c=Le[(o=R.gap)!=null?o:"md"])!=null?c:Le.md;re(x,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${R.columns-1} * ${F}) / ${R.columns})), 1fr))`,gap:F,"align-items":R.align?Mt[R.align]:void 0})}let S=e.type==="stack"&&e.surface==="raised",$=(i=e.pad)!=null?i:S?"md":void 0;$&&re(x,{padding:(s=Le[$])!=null?s:Le.md}),S&&re(x,{background:k==null?void 0:k.surface,color:k!=null&&k.surface?k==null?void 0:k.surfaceText:void 0,border:`1px solid ${(a=k==null?void 0:k.border)!=null?a:"currentColor"}`,"border-radius":(d=k==null?void 0:k.radius)!=null?d:"8px"});for(let R of(l=e.children)!=null?l:[]){let F=Jn(R,t);F&&x.appendChild(F)}return x}case"text":{let x=t.createElement("p");return x.textContent=e.value,re(x,Ze(W({margin:"0","font-size":e.size?Wn[e.size]:void 0,"font-weight":e.weight?jo[e.weight]:void 0,"text-align":e.align},Hn(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let x=t.createElement(`h${e.level}`);return x.textContent=e.value,re(x,{margin:"0","font-size":$o[(u=e.size)!=null?u:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let x=t.createElement("a");x.textContent=e.label,x.href=e.href,e.tag&&x.setAttribute("data-sentient-tag",e.tag);let S=(g=e.emphasis)!=null?g:"primary";return re(x,{display:"inline-block",padding:No[(v=e.size)!=null?v:"md"],"border-radius":(w=k==null?void 0:k.radius)!=null?w:"8px",font:"inherit","font-size":e.size?Wn[e.size]:void 0,"text-decoration":S==="ghost"?"underline":"none",cursor:"pointer",background:S==="primary"?(A=k==null?void 0:k.primaryBg)!=null?A:"#111827":"transparent",color:S==="primary"?(P=k==null?void 0:k.primaryText)!=null?P:"#ffffff":(E=k==null?void 0:k.accent)!=null?E:"inherit",border:S==="secondary"?`1px solid ${(L=k==null?void 0:k.accent)!=null?L:"currentColor"}`:"none"})}case"link":{let x=t.createElement("a");return x.textContent=e.label,x.href=e.href,e.tag&&x.setAttribute("data-sentient-tag",e.tag),re(x,{color:"inherit","text-decoration":"underline"})}case"image":{let x=t.createElement("img");return x.src=e.src,x.alt=e.alt,re(x,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Ko[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let x=t.createElement("span");return x.textContent=e.value,re(x,W({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(f=k==null?void 0:k.border)!=null?f:"currentColor"}`},Hn(e.tone)))}case"spacer":return re(t.createElement("div"),{height:(m=qn[e.size])!=null?m:qn.md});case"divider":return re(t.createElement("hr"),{border:"none","border-top":`1px solid ${(O=k==null?void 0:k.border)!=null?O:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(x){return null}}function Vn(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(We);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 a=Jn(s,r);if(!a)continue;let d=r.createElement("div");d.setAttribute(We,i),d.style.display="none",d.appendChild(a),e.appendChild(d)}let c=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(We),a=i;s!==null?a.style.display=c&&s===n?"":"none":c?a.hasAttribute(ue)||(a.setAttribute(ue,a.style.display),a.style.display="none"):a.hasAttribute(ue)&&(a.style.display=a.getAttribute(ue),a.removeAttribute(ue))}}catch(o){}}function Go(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(We)!==null){n.remove();continue}n.hasAttribute(ue)&&(n.style.display=n.getAttribute(ue),n.removeAttribute(ue))}}catch(t){}}function ct(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${We}]`)))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)||Go(r)}catch(n){}}function Bt(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function ut(e,t,n,r){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t),r==null||r(n.documentElement,"data-sentient-persona"),r==null||r(n.documentElement,"data-sentient-confidence")}function dt(e,t,n,r){var o;for(let[c,i]of Object.entries(t)){let s=e[c];if(!s||typeof s=="string")continue;let a=Bt(i.target,n);for(let d of a)for(let[l,u]of Object.entries(s))(o=i.dims[l])!=null&&o.includes(u)&&(d.setAttribute(`data-${l}`,u),r==null||r(d,`data-${l}`))}}function ft(e,t,n,r){for(let[o,c]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!c.arms||!c.arms.includes(i))continue;let s=Bt(c.target,n);for(let a of s)a.setAttribute("data-sentient-arm",i),r==null||r(a,"data-sentient-arm")}}function pt(e,t,n,r){var s,a,d,l;let o=new Set,c=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[u,g]of Object.entries(t)){if(Kn(g.locator,n))continue;let v;if(g.locator){let A=me(g.locator,n);v=A?[A]:[]}else v=Bt(g.target,n);(g.locator||g.target)&&v.length===0&&i.push(u);let w=e[u];for(let A of v){if(w!==void 0)if(typeof w=="string")A.setAttribute("data-sentient-arm",w),(a=r==null?void 0:r.onAttr)==null||a.call(r,A,"data-sentient-arm"),c&&((d=r==null?void 0:r.onApplied)==null||d.call(r,u,w,A));else for(let[E,L]of Object.entries(w))A.setAttribute(`data-${E}`,L),(l=r==null?void 0:r.onAttr)==null||l.call(r,A,`data-${E}`);if(g.blocks&&!Fo(n)){let E=Object.fromEntries(Object.entries(g.blocks).filter(([,L])=>!st(L)));Object.keys(E).length>0&&(Vn(A,E,typeof w=="string"?w:void 0,n),o.add(A))}if(!c)continue;let P=A.textContent;typeof g.content=="string"&&(A.textContent=g.content),g.ops&&zn(A,g.ops,u,n).anchorMiss&&!i.includes(u)&&i.push(u),Rt(A,Ze(W(W({previous:P},typeof w=="string"?{arm:w}:{}),(r==null?void 0:r.persona)!==void 0?{persona:r.persona}:{}),{doc:n}))}}return ct(n,o),i}var Uo=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Fo(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:Uo.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var zo=800;function gt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:c,el:i},s)=>{r.push(Ue((g,v={})=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"micro_signal",payload:W({signalType:g},v)})}catch(w){}},i,void 0,{tabLoss:s===0}));let a=null,d=0,l=()=>{d=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-d}})}catch(g){}a=null},zo)},u=()=>{a!==null&&(clearTimeout(a),a=null)};i.addEventListener("mouseenter",l),i.addEventListener("mouseleave",u),r.push(()=>{i.removeEventListener("mouseenter",l),i.removeEventListener("mouseleave",u),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function Wo(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 Xn(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var qo="_snt_fired_goals";function Zn(e,t){try{e==null||e.sessionStorage.removeItem(Xn(t)),e==null||e.sessionStorage.removeItem(qo)}catch(n){}}function Yn(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Ho(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 Jo(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function mt(e,t,n,r){var E,L;let o=(E=n.defaultView)!=null?E:typeof window!="undefined"?window:null,c=Xn(r),i=Ho(o,c),s=f=>{let m=Yn(f);if(!i.has(m))try{f.slotId?t.componentGoal(f.slotId,f.goalId):t.goal(f.goalId),i.add(m),Jo(o,c,i)}catch(O){}},a=e.filter(f=>f.event==="click"),d=e.filter(f=>f.event==="form_submit"),l=e.filter(f=>f.event==="url_reached"),u=e.filter(f=>f.event==="scroll_depth"),g=(f,m)=>{if(!f.locator)return!1;let O=me(f.locator,n);return!!O&&(O===m||O.contains(m))},v=f=>{let m=f.target;if(!(!m||typeof m.closest!="function"))for(let O of a)g(O,m)&&s(O)},w=f=>{let m=f.target;if(m)for(let O of d)g(O,m)&&s(O)},A=()=>{if(l.length===0)return;let f=lt(n);for(let m of l)m.urlPattern&&Wo(m.urlPattern,f)&&s(m)},P=()=>{var O;let f=n.documentElement,m=f.scrollHeight>0?(f.scrollTop+f.clientHeight)/f.scrollHeight:0;for(let x of u)m>=((O=x.threshold)!=null?O:.75)&&s(x);u.every(x=>i.has(Yn(x)))&&n.removeEventListener("scroll",P)};return n.addEventListener("click",v,!0),n.addEventListener("submit",w,!0),(L=n.defaultView)==null||L.addEventListener("popstate",A),A(),u.length>0&&(n.addEventListener("scroll",P,{passive:!0}),P()),{checkUrl:A,teardown:()=>{var f;n.removeEventListener("click",v,!0),n.removeEventListener("submit",w,!0),(f=n.defaultView)==null||f.removeEventListener("popstate",A),u.length>0&&n.removeEventListener("scroll",P)}}}function ht(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),c=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(c.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return c}var Qn="__snt_editor_token";function er(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Qn):null}catch(e){return null}}function tr(e){try{sessionStorage.setItem(Qn,e)}catch(t){}}var Ve="0.26.0",bt=Ve!=="0.0.0-dev"?{name:"snippet",version:Ve}:void 0,cr=5e3,Vo=50,ur=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),Z=null,K=null,de={},ve=null,H=null,ye=null,X=null,ae=null,j=null,xe=null,nr=!1,$t=null,yt=null,wt=null,Re=!1,He=!1,ke=!1;function dr(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 Ee(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Pe(e,t){return Z?(Z.personaAttributes&&j&&ut(j.persona,j.band,e,t==null?void 0:t.onAttr),dt(de,Z.slots,e,t==null?void 0:t.onAttr),ft(de,Z.slots,e,t==null?void 0:t.onAttr),ve?pt(de,ve,e,W(W({},t),j?{persona:j.persona}:{})):(ct(e,new Set),[])):[]}function fr(e){var n;let t=new Map;for(let r of(n=Z==null?void 0:Z.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function Nt(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=ht(e,fr(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function Yo(e,t,n){let r=(o,c)=>t.some(([i,s])=>i===o&&s===c);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[c,i,s]=o;!c||typeof i!="string"||r(c,i)||(s==null?c.removeAttribute(i):c.setAttribute(i,s))}if(Array.isArray(e.html))for(let o of e.html)typeof o!="string"||r(n.documentElement,o)||n.documentElement.removeAttribute(o)}catch(o){}}function Xo(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function pr(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function Zo(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 Te(){return!!(Z&&K&&Z.sectionCapture!==!1&&(Z.consent!==!1||He)&&!Ae())}function Qo(){if(!K||!Z||!Te()||ae)return;let e=[];Pe(document,{contentAndOps:Re,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),jt();try{X==null||X(),X=gt(K,Z.apiKey,e)}catch(t){}}function jt(){if(typeof document=="undefined"||!Te())return;let e;try{if(yt&&yt.length>0){let t=new Map;for(let n of yt){if(n.urlMatch!==window.location.pathname)continue;let r=me(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=Nn(K,W({apiKey:Z.apiKey,apiBase:Z.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),wt=window.location.pathname}catch(t){}}function Gt(){try{let e=[];if(X==null||X(),X=null,Pe(document,{contentAndOps:Re,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Nt(xe,document),e.length>0&&Te())try{X=gt(K,Z.apiKey,e)}catch(t){}try{typeof window!="undefined"&&wt!==null&&window.location.pathname!==wt&&Te()&&(ae==null||ae(),ae=null,jt())}catch(t){}}catch(e){}}function rr(){$t===null&&($t=setTimeout(()=>{$t=null,Gt();try{H==null||H.checkUrl()}catch(e){}},Vo))}function Kt(){if(!(nr||typeof window=="undefined"||typeof history=="undefined")){nr=!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 rr(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",rr)}catch(e){}}}function vt(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 gr(e){return new URLSearchParams(e).get("sentient_editor")}function ei(){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 ti(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 a=document.createElement("meta");a.name="referrer",a.content="no-referrer",a.setAttribute("data-sentient-editor",""),((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let i=(o=e.editorSrc)!=null?o:ei();if(!i){ir();return}let s=document.createElement("script");s.src=i,s.async=!0,s.onerror=()=>ir(),((c=document.head)!=null?c:document.documentElement).appendChild(s)}catch(i){}}var or="sentient-editor-load-notice",mr={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function ir(){var e,t;try{if(typeof document=="undefined"||document.getElementById(or))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=or,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,mr,{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 hr(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 s={};for(let a of i.split(",")){let[d,l]=a.split("=");d&&l&&(s[d]=l)}Object.keys(s).length&&(n[c]=s)}else n[c]=i}return Object.keys(n).length?n:null}function yr(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var sr="sentient-persona-preview-banner";function ar(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(sr))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=sr,o.setAttribute("role","status"),Object.assign(o.style,mr,{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 s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(c),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function ni(e,t){var d,l,u,g,v,w,A,P,E,L;let n=(d=e.apiBase)!=null?d:"https://api.sentient-ui.com",o=((l=e.registry)!=null?l:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([f,m])=>({id:f,dims:m.dims}))},c=await dr(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(f=>f.ok?f.json():null).catch(()=>null),cr);if(!c){Je(e),Ee(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=c;de=(u=i.slots)!=null?u:{},ve=(g=i.slotConfig)!=null?g:null,qe(i.palette);let s=(A=(w=(v=i.personaAttributes)==null?void 0:v.persona)!=null?w:i.persona)!=null?A:t,a=(E=(P=i.personaAttributes)==null?void 0:P.confidence)!=null?E:"high";j={persona:s,band:a},Pe(document),Re=!0,Kt(),Je(e),i.recognized===!1?ar(t,!0):ar((L=i.personaDisplay)!=null?L:s)}function Je(e){let t={goal(n,r){try{K==null||K.goal(n,r)}catch(o){}},componentGoal(n,r){try{K==null||K.componentGoal(n,r)}catch(o){}},grantConsent(){try{!K&&ke?(K=Fe(W({apiKey:e.apiKey,context:e.context,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:pr(e)},bt?{sdk:bt}:{})),ye&&ye.length>0&&(H==null||H.teardown(),H=mt(ye,K,document,e.apiKey))):(Pt(e.apiKey),K&&ye&&ye.length>0&&(H==null||H.teardown(),H=mt(ye,K,document,e.apiKey))),ke=!1}catch(n){}He=!0;try{Qo()}catch(n){}},revokeConsent(){try{ae==null||ae(),ae=null,wt=null,X==null||X(),X=null,H==null||H.teardown(),H=null,Zn(typeof window!="undefined"?window:null,e.apiKey),He=!1,ke=!0,K==null||K.destroy(),K=null}catch(n){}},reapply:Gt,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=j==null?void 0:j.persona)!=null?n:null,band:(r=j==null?void 0:j.band)!=null?r:null,slots:de,matchCounts:vt(e),consent:!ke&&(e.consent!==!1||He)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of ur.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function lr(){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})},ur.length=0}catch(t){}}async function vr(){var e,t;try{let n=at(window.sentient);if(!n){lr();return}Z=n,Re=!1,xe=null,qe(null),He=!1,ke=!1,ye=null;let r=typeof window!="undefined"?gr(window.location.search):null;if(r){tr(r);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 o=r!=null?r:er();if(o){ti(n,o),Je(n),Ee(n,"editor mode");return}let c=typeof window!="undefined"?hr(window.location.search):null;if(c){de=c,j=null,Pe(document),Kt(),Je(n),Ee(n,"preview mode",c);return}let i=typeof window!="undefined"?yr(window.location.search):null;if(i){await ni(n,i),Ee(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0,a=Xo();try{(t=a==null?void 0:a.stop)==null||t.call(a)}catch(f){}let d=je(n.apiKey),l=[];d&&(j={persona:d.persona,band:d.band},de=d.slots,d.slotConfig&&(ve=d.slotConfig),d.palette&&qe(d.palette),Pe(document,W({contentAndOps:!1},a?{onAttr:(f,m)=>l.push([f,m])}:{})),d.layoutOrder&&(xe=d.layoutOrder,Nt(xe,document))),a&&Yo(a,l,document);let u=Fe(W({apiKey:n.apiKey,context:n.context,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:pr(n)},bt?{sdk:bt}:{}));K=u,Je(n),Kt();let g=Object.entries(n.slots).map(([f,m])=>({id:f,dims:m.dims})),v=Ve!=="0.0.0-dev"?{v:Ve}:{},w={pp:a?a.v:0},A=Array.from(fr(document).keys()),P=u.decide(W(W(W(W({slots:g},v),w),A.length>=2?{sections:A}:{}),s?{slotsFrom:"registry"}:{})),E=await dr(P,cr),L=f=>{var x,S,$,R,F,G;let m=u.getPersona();m?j={persona:m.persona,band:m.band}:f.persona&&(j={persona:f.persona,band:"low"}),de=f.slots,s?ve=(x=f.slotConfig)!=null?x:null:f.slotConfig&&(ve=f.slotConfig),f.palette&&qe(f.palette),xe=(S=f.layoutOrder)!=null?S:xe;let O=()=>{let q=[];if(Zo(n,Pe(document,{onApplied:(le,b,h)=>q.push({slotId:le,arm:b,el:h})})),Nt(xe,document),Re=!0,Te())try{X==null||X(),X=gt(K,n.apiKey,q)}catch(le){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",O,{once:!0}):O(),ye=($=f.goals)!=null?$:null,f.goals&&f.goals.length>0&&n.consent!==!1&&K)try{H==null||H.teardown(),H=mt(f.goals,K,document,n.apiKey)}catch(q){}yt=(R=f.sectionMap)!=null?R:null,Te()&&jt(),Ee(n,"applied",{persona:j,slots:de,matches:vt(n)}),!ke&&Ge(n.apiKey,W(W({v:1,persona:(F=j==null?void 0:j.persona)!=null?F:f.persona,band:(G=j==null?void 0:j.band)!=null?G:"low",slots:f.slots,layoutOrder:f.layoutOrder,savedAt:Date.now()},ve?{slotConfig:ve}:{}),f.palette?{palette:f.palette}:{}))};if(!E){Ee(n,"decide timeout/null \u2014 snapshot state stands",vt(n)),P.then(f=>{!f||Re||ke||K!==u||(L(f),Ee(n,"late decide applied",vt(n)))}).catch(()=>{});return}L(E)}catch(n){lr()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{vr()}))}return _r(ri);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.24.1",
3
+ "version": "0.26.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",
@@ -38,7 +38,7 @@
38
38
  "tsx": "^4.19.2",
39
39
  "typescript": "^5.7.2",
40
40
  "vitest": "^2.1.8",
41
- "@sentientui/core": "0.27.0"
41
+ "@sentientui/core": "0.29.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsup",