@sentientui/snippet 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.global.js +13 -13
- package/dist/snippet.global.js +2 -2
- package/package.json +2 -2
package/dist/editor.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var At=Object.defineProperty,Co=Object.defineProperties,To=Object.getOwnPropertyDescriptor,_o=Object.getOwnPropertyDescriptors,Lo=Object.getOwnPropertyNames,It=Object.getOwnPropertySymbols;var Yt=Object.prototype.hasOwnProperty,Dn=Object.prototype.propertyIsEnumerable;var Nn=(e,n,r)=>n in e?At(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r,B=(e,n)=>{for(var r in n||(n={}))Yt.call(n,r)&&Nn(e,r,n[r]);if(It)for(var r of It(n))Dn.call(n,r)&&Nn(e,r,n[r]);return e},V=(e,n)=>Co(e,_o(n));var Hn=e=>typeof e=="symbol"?e:e+"",zn=(e,n)=>{var r={};for(var i in e)Yt.call(e,i)&&n.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&It)for(var i of It(e))n.indexOf(i)<0&&Dn.call(e,i)&&(r[i]=e[i]);return r};var Io=(e,n)=>{for(var r in n)At(e,r,{get:n[r],enumerable:!0})},Ao=(e,n,r,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of Lo(n))!Yt.call(e,c)&&c!==r&&At(e,c,{get:()=>n[c],enumerable:!(i=To(n,c))||i.enumerable});return e};var $o=e=>Ao(At({},"__esModule",{value:!0}),e);var mr={};Io(mr,{buildStyleOps:()=>ln,clearTargetHighlights:()=>et,computeMoveAnchors:()=>Mt,deriveSlotId:()=>me,drawTargetHighlights:()=>ro,isHex6:()=>cn,mount:()=>ao,registerAuditTargets:()=>oo,sectionTypesFor:()=>io,styleFieldError:()=>so,toHexColor:()=>rn});var yr=56*1024;var vr=1800*1e3;var Vt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Bo(e){var r,i,c;let n=(i=(r=e.defaultView)!=null?r:typeof window!="undefined"?window:void 0)==null?void 0:i.location;return(c=n==null?void 0:n.pathname)!=null?c:""}function Mo(e,n){var r;if(n.tag&&e.tagName.toLowerCase()!==n.tag.toLowerCase())return!1;if(n.text){let i=((r=e.textContent)!=null?r:"").replace(/\s+/g," ").trim().toLowerCase(),c=n.text.replace(/\s+/g," ").trim().toLowerCase();if(!(i===c||i.startsWith(c)||c.startsWith(i)))return!1}return!0}var Oo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Po(e,n){var i;let r=[];if(e.id){let c=n.getElementById(e.id);r=c?[c]:[]}if(r.length===0&&((i=e.dataAttr)!=null&&i.name)&&Oo.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");r=Array.from(n.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){r=[]}if(r.length===0&&e.selector)try{r=Array.from(n.querySelectorAll(e.selector))}catch(c){r=[]}return r}function ge(e,n){if(e.urlMatch&&!Bo(n).includes(e.urlMatch))return null;let r=Po(e,n);if(r.length!==1)return null;let i=r[0];return e.fingerprint&&!Mo(i,e.fingerprint)?null:i}var Xt="data-sentient-block-arm",_=null;var ht="data-sentient-blocks-hid",Ye={none:"0",sm:"8px",md:"16px",lg:"24px"},Zt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},jn={sm:"0.875em",md:"1em",lg:"1.25em"},Ro={sm:"1.25em",md:"1.5em",lg:"2em"},No={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Kn={sm:"8px",md:"16px",lg:"32px"},Do={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Ho={normal:"400",medium:"500",bold:"700"};function ie(e,n){for(let[r,i]of Object.entries(n))i!==void 0&&e.style.setProperty(r,i);return e}function Gn(e){return e==="muted"?_!=null&&_.muted?{color:_.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:_==null?void 0:_.accent}:{}}function Un(e,n){var r,i,c,m,b,L,v,M,H,ee,F,R,D,J,X,Z,K,Y,se,ae;try{switch(e.type){case"stack":case"grid":{let x=n.createElement("div");if(e.type==="stack"){let U=e;ie(x,{display:"flex","flex-direction":U.direction,gap:(i=Ye[(r=U.gap)!=null?r:"md"])!=null?i:Ye.md,"align-items":U.align?Zt[U.align]:void 0,"justify-content":U.justify?Zt[U.justify]:void 0,"flex-wrap":U.wrap?"wrap":void 0})}else{let U=e,de=(m=Ye[(c=U.gap)!=null?c:"md"])!=null?m:Ye.md;ie(x,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${U.columns-1} * ${de}) / ${U.columns})), 1fr))`,gap:de,"align-items":U.align?Zt[U.align]:void 0})}let G=e.type==="stack"&&e.surface==="raised",le=(b=e.pad)!=null?b:G?"md":void 0;le&&ie(x,{padding:(L=Ye[le])!=null?L:Ye.md}),G&&ie(x,{background:_==null?void 0:_.surface,color:_!=null&&_.surface?_==null?void 0:_.surfaceText:void 0,border:`1px solid ${(v=_==null?void 0:_.border)!=null?v:"currentColor"}`,"border-radius":(M=_==null?void 0:_.radius)!=null?M:"8px"});for(let U of(H=e.children)!=null?H:[]){let de=Un(U,n);de&&x.appendChild(de)}return x}case"text":{let x=n.createElement("p");return x.textContent=e.value,ie(x,V(B({margin:"0","font-size":e.size?jn[e.size]:void 0,"font-weight":e.weight?Ho[e.weight]:void 0,"text-align":e.align},Gn(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let x=n.createElement(`h${e.level}`);return x.textContent=e.value,ie(x,{margin:"0","font-size":Ro[(ee=e.size)!=null?ee:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let x=n.createElement("a");x.textContent=e.label,x.href=e.href,e.tag&&x.setAttribute("data-sentient-tag",e.tag);let G=(F=e.emphasis)!=null?F:"primary";return ie(x,{display:"inline-block",padding:No[(R=e.size)!=null?R:"md"],"border-radius":(D=_==null?void 0:_.radius)!=null?D:"8px",font:"inherit","font-size":e.size?jn[e.size]:void 0,"text-decoration":G==="ghost"?"underline":"none",cursor:"pointer",background:G==="primary"?(J=_==null?void 0:_.primaryBg)!=null?J:"#111827":"transparent",color:G==="primary"?(X=_==null?void 0:_.primaryText)!=null?X:"#ffffff":(Z=_==null?void 0:_.accent)!=null?Z:"inherit",border:G==="secondary"?`1px solid ${(K=_==null?void 0:_.accent)!=null?K:"currentColor"}`:"none"})}case"link":{let x=n.createElement("a");return x.textContent=e.label,x.href=e.href,e.tag&&x.setAttribute("data-sentient-tag",e.tag),ie(x,{color:"inherit","text-decoration":"underline"})}case"image":{let x=n.createElement("img");return x.src=e.src,x.alt=e.alt,ie(x,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Do[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let x=n.createElement("span");return x.textContent=e.value,ie(x,B({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(Y=_==null?void 0:_.border)!=null?Y:"currentColor"}`},Gn(e.tone)))}case"spacer":return ie(n.createElement("div"),{height:(se=Kn[e.size])!=null?se:Kn.md});case"divider":return ie(n.createElement("hr"),{border:"none","border-top":`1px solid ${(ae=_==null?void 0:_.border)!=null?ae:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(x){return null}}function Fn(e,n,r,i){try{let c=new Set;for(let b of Array.from(e.children)){let L=b.getAttribute(Xt);L!==null&&(n[L]===void 0?b.remove():c.add(L))}for(let[b,L]of Object.entries(n)){if(c.has(b))continue;let v=Un(L,i);if(!v)continue;let M=i.createElement("div");M.setAttribute(Xt,b),M.style.display="none",M.appendChild(v),e.appendChild(M)}let m=r!==void 0&&n[r]!==void 0;for(let b of Array.from(e.children)){let L=b.getAttribute(Xt),v=b;L!==null?v.style.display=m&&L===r?"":"none":m?v.hasAttribute(ht)||(v.setAttribute(ht,v.style.display),v.style.display="none"):v.hasAttribute(ht)&&(v.style.display=v.getAttribute(ht),v.removeAttribute(ht))}}catch(c){}}function Wn(e){let n=globalThis;if(n.CSS&&typeof n.CSS.escape=="function")return n.CSS.escape(e);let r="";for(let i=0;i<e.length;i++){let c=e[i],m=c>="0"&&c<="9";i===0&&m||i===1&&m&&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 zo(e,n){if(e.id)return`#${Wn(e.id)}`;let r=[],i=e,c=0;for(;i&&i!==n.body&&i!==n.documentElement&&c<6;){if(i.id){r.unshift(`#${Wn(i.id)}`);break}let m=i.tagName.toLowerCase(),b=i.parentElement;if(b){let L=Array.from(b.children).filter(v=>v.tagName===i.tagName);L.length>1&&(m+=`:nth-of-type(${L.indexOf(i)+1})`)}r.unshift(m),i=i.parentElement,c++}return r.join(" > ")}function De(e,n){var c;let r={v:1};e.id&&(r.id=e.id);for(let m of["data-framer-name","data-w-id","data-sentient-name"]){let b=e.getAttribute(m);if(b){r.dataAttr={name:m,value:b};break}}r.selector=zo(e,n);let i=((c=e.textContent)!=null?c:"").trim().replace(/\s+/g," ").slice(0,80);return r.fingerprint=B({tag:e.tagName.toLowerCase()},i?{text:i}:{}),r}function Ve(e,n,r){return ge(e,r)===n}var jo="__snt_editor_token";function yt(){try{sessionStorage.removeItem(jo)}catch(e){}}var Ko=/rgba\([^)]*,\s*0\s*\)$/,Go=/^\d+(\.\d+)?px$/;function qn(e){var n,r;try{let i=e.defaultView;if(!i||!e.body)return null;let c=i.getComputedStyle(e.body).backgroundColor,m=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),b=new Map;for(let F of Array.from(m).slice(0,300)){let R=F.getBoundingClientRect();if(R.width>0&&(R.width<48||R.height<24))continue;let D=i.getComputedStyle(F),J=D.backgroundColor;if(!J||J==="transparent"||J===c||Ko.test(J))continue;let X=(n=(D.borderRadius||"").split(" ")[0])!=null?n:"",Z=`${J}|${D.color}|${Go.test(X)?X:"8px"}`;b.set(Z,((r=b.get(Z))!=null?r:0)+1)}let L=null,v=0;for(let[F,R]of b)R>v&&(L=F,v=R);if(!L)return null;let[M,H,ee]=L.split("|");return{primaryBg:M,primaryText:H,radius:ee}}catch(i){return null}}var vt={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"},Uo=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Xe(e){var i;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let n=/([A-Za-z-]*)\(/g,r;for(;(r=n.exec(e))!==null;)if(!Uo.test((i=r[1])!=null?i:""))return!1;return!0}var Jn=/^https:\/\//i,Yn=new Map,Ie=null;function Fo(e){return e.replace(/["\\]/g,"\\$&")}function Wo(e){var n;(!Ie||!Ie.isConnected)&&(Ie=e.querySelector("style[data-sentient-ops]"),Ie||(Ie=e.createElement("style"),Ie.setAttribute("data-sentient-ops",""),((n=e.head)!=null?n:e.documentElement).appendChild(Ie))),Ie.textContent=[...Yn.entries()].map(([r,i])=>`[data-snt-e="${Fo(r)}"]{${i}}`).join(`
|
|
2
|
-
`)}function
|
|
1
|
+
"use strict";var SentientSnippet=(()=>{var Nt=Object.defineProperty,nr=Object.defineProperties,or=Object.getOwnPropertyDescriptor,rr=Object.getOwnPropertyDescriptors,ir=Object.getOwnPropertyNames,Pt=Object.getOwnPropertySymbols;var rn=Object.prototype.hasOwnProperty,Yn=Object.prototype.propertyIsEnumerable;var Jn=(e,t,o)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,j=(e,t)=>{for(var o in t||(t={}))rn.call(t,o)&&Jn(e,o,t[o]);if(Pt)for(var o of Pt(t))Yn.call(t,o)&&Jn(e,o,t[o]);return e},se=(e,t)=>nr(e,rr(t));var Xn=e=>typeof e=="symbol"?e:e+"",Zn=(e,t)=>{var o={};for(var r in e)rn.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&Pt)for(var r of Pt(e))t.indexOf(r)<0&&Yn.call(e,r)&&(o[r]=e[r]);return o};var ar=(e,t)=>()=>(e&&(t=e(e=0)),t);var sr=(e,t)=>{for(var o in t)Nt(e,o,{get:t[o],enumerable:!0})},lr=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ir(t))!rn.call(e,s)&&s!==o&&Nt(e,s,{get:()=>t[s],enumerable:!(r=or(t,s))||r.enumerable});return e};var dr=e=>lr(Nt({},"__esModule",{value:!0}),e);var cr,ur,pr,Qn,fr,gr,eo,ue,ot,an=ar(()=>{"use strict";cr=Object.defineProperty,ur=Object.defineProperties,pr=Object.getOwnPropertyDescriptors,Qn=Object.getOwnPropertySymbols,fr=Object.prototype.hasOwnProperty,gr=Object.prototype.propertyIsEnumerable,eo=(e,t,o)=>t in e?cr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,ue=(e,t)=>{for(var o in t||(t={}))fr.call(t,o)&&eo(e,o,t[o]);if(Qn)for(var o of Qn(t))gr.call(t,o)&&eo(e,o,t[o]);return e},ot=(e,t)=>ur(e,pr(t))});var di={};sr(di,{buildStyleOps:()=>wn,clearTargetHighlights:()=>ct,computeMoveAnchors:()=>Kt,deriveSlotId:()=>Ee,drawTargetHighlights:()=>No,isHex6:()=>Sn,mount:()=>Ho,registerAuditTargets:()=>Po,sectionTypesFor:()=>Ro,styleFieldError:()=>Do,toHexColor:()=>vn});var pi=56*1024;var fi=1800*1e3;var sn=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function mr(e){var o,r,s;let t=(r=(o=e.defaultView)!=null?o:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function hr(e,t){var o;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((o=e.textContent)!=null?o:"").replace(/\s+/g," ").trim().toLowerCase(),s=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}var yr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function vr(e,t){var r;let o=[];if(e.id){let s=t.getElementById(e.id);o=s?[s]:[]}if(o.length===0&&((r=e.dataAttr)!=null&&r.name)&&yr.test(e.dataAttr.name))try{let s=e.dataAttr.value.replace(/["\\]/g,"\\$&");o=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${s}"]`))}catch(s){o=[]}if(o.length===0&&e.selector)try{o=Array.from(t.querySelectorAll(e.selector))}catch(s){o=[]}return o}function xe(e,t){if(e.urlMatch&&!mr(t).includes(e.urlMatch))return null;let o=vr(e,t);if(o.length!==1)return null;let r=o[0];return e.fingerprint&&!hr(r,e.fingerprint)?null:r}var ln="data-sentient-block-arm",O=null;var Rt=null;function ro(e){Rt=e!=null?e:null}var io=e=>{var t;return typeof e=="string"?(t=Rt==null?void 0:Rt.entries.find(o=>o.id===e))==null?void 0:t.classes:void 0},Et="data-sentient-blocks-hid",rt={none:"0",sm:"8px",md:"16px",lg:"24px"},dn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},to={sm:"0.875em",md:"1em",lg:"1.25em"},br={sm:"1.25em",md:"1.5em",lg:"2em"},xr={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},no={sm:"8px",md:"16px",lg:"32px"},wr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},kr={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[o,r]of Object.entries(t))r!==void 0&&e.style.setProperty(o,r);return e}function oo(e){return e==="muted"?O!=null&&O.muted?{color:O.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:O==null?void 0:O.accent}:{}}function ao(e,t){var o,r,s,u,m,k,p,b,w,I,R,D,A,P,Y,Z,W,q,Q,ne;try{let $=io(e.like),H=e.maxWidth==="measure"?"65ch":void 0,V=S=>(S.className=$,he(S,{"max-width":H}));switch(e.type){case"stack":case"grid":{let S=t.createElement("div");if(e.type==="stack"){let U=e;he(S,{display:"flex","flex-direction":U.direction,gap:(r=rt[(o=U.gap)!=null?o:"md"])!=null?r:rt.md,"align-items":U.align?dn[U.align]:void 0,"justify-content":U.justify?dn[U.justify]:void 0,"flex-wrap":U.wrap?"wrap":void 0})}else{let U=e,oe=(u=rt[(s=U.gap)!=null?s:"md"])!=null?u:rt.md;he(S,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${U.columns-1} * ${oe}) / ${U.columns})), 1fr))`,gap:oe,"align-items":U.align?dn[U.align]:void 0})}$&&(S.className=$);let J=!$&&e.type==="stack"&&e.surface==="raised",de=(m=e.pad)!=null?m:J?"md":void 0;de&&he(S,{padding:(k=rt[de])!=null?k:rt.md}),J&&he(S,{background:O==null?void 0:O.surface,color:O!=null&&O.surface?O==null?void 0:O.surfaceText:void 0,border:`1px solid ${(p=O==null?void 0:O.border)!=null?p:"currentColor"}`,"border-radius":(b=O==null?void 0:O.radius)!=null?b:"8px"});for(let U of(w=e.children)!=null?w:[]){let oe=ao(U,t);oe&&S.appendChild(oe)}return S}case"text":{let S=t.createElement("p");return S.textContent=e.value,$?V(S):he(S,se(j({margin:"0","font-size":e.size?to[e.size]:void 0,"font-weight":e.weight?kr[e.weight]:void 0,"text-align":e.align},oo(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let S=t.createElement(`h${e.level}`);return S.textContent=e.value,$?V(S):he(S,{margin:"0","font-size":br[(I=e.size)!=null?I:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let S=t.createElement("a");if(S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),$)return V(S);let J=(R=e.emphasis)!=null?R:"primary";return he(S,{display:"inline-block",padding:xr[(D=e.size)!=null?D:"md"],"border-radius":(A=O==null?void 0:O.radius)!=null?A:"8px",font:"inherit","font-size":e.size?to[e.size]:void 0,"text-decoration":J==="ghost"?"underline":"none",cursor:"pointer",background:J==="primary"?(P=O==null?void 0:O.primaryBg)!=null?P:"#111827":"transparent",color:J==="primary"?(Y=O==null?void 0:O.primaryText)!=null?Y:"#ffffff":(Z=O==null?void 0:O.accent)!=null?Z:"inherit",border:J==="secondary"?`1px solid ${(W=O==null?void 0:O.accent)!=null?W:"currentColor"}`:"none"})}case"link":{let S=t.createElement("a");return S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),$?V(S):he(S,{color:"inherit","text-decoration":"underline"})}case"image":{let S=t.createElement("img");return S.src=e.src,S.alt=e.alt,$&&(S.className=$),he(S,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?wr[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let S=t.createElement("span");return S.textContent=e.value,$?V(S):he(S,j({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(q=O==null?void 0:O.border)!=null?q:"currentColor"}`},oo(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(Q=no[e.size])!=null?Q:no.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(ne=O==null?void 0:O.border)!=null?ne:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch($){return null}}function so(e,t,o,r){var s;try{let u=new Set;for(let k of Array.from(e.children)){let p=k.getAttribute(ln);p!==null&&(t[p]===void 0?k.remove():u.add(p))}for(let[k,p]of Object.entries(t)){if(u.has(k))continue;let b="tree"in p?p:null,w=ao(b?b.tree:p,r);if(!w)continue;let I=r.createElement("div");I.setAttribute(ln,k),I.style.display="none";let R=b?io((s=b.surface)==null?void 0:s.like):void 0;if(R){let D=r.createElement("div");D.className=R,D.appendChild(w),I.appendChild(D)}else I.appendChild(w);e.appendChild(I)}let m=o!==void 0&&t[o]!==void 0;for(let k of Array.from(e.children)){let p=k.getAttribute(ln),b=k;p!==null?b.style.display=m&&p===o?"":"none":m?b.hasAttribute(Et)||(b.setAttribute(Et,b.style.display),b.style.display="none"):b.hasAttribute(Et)&&(b.style.display=b.getAttribute(Et),b.removeAttribute(Et))}}catch(u){}}an();function uo(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function lo(e,t){let o=t>>>0;for(let r=0;r<e.length;r++)o^=e.charCodeAt(r),o=Math.imul(o,16777619)>>>0;return o.toString(16).padStart(8,"0")}function po(e){let t=e.join("");return lo(t,2166136261)+lo(t,1523705862)}var Sr=new Set(["A","BUTTON"]),fo=/^H([1-6])$/,Er=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]),Cr=new Set(["LABEL","FIGCAPTION","DT"]),Tr=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function go(e){return Sr.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function Ar(e){if(fo.test(e.tagName)||Er.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,o=t?t.getComputedStyle(e).display:"";return o!==""&&o!=="inline"&&o!=="contents"}function Ir(e,t){let o=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(go(r)){o=r;break}if(r===t)break}if(o)return o;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||Ar(r))return r;return t}function co(e,t){var o,r;if(e)try{let s=new URL(e,(r=(o=t.location)==null?void 0:o.href)!=null?r:"https://relative.invalid/");return s.protocol!=="https:"&&s.protocol!=="http:"?void 0:t.location&&s.origin===t.location.origin?s.pathname:`${s.origin}${s.pathname}`}catch(s){return}}function mo(e){return e===""||e==="transparent"||/rgba\([^)]*,\s*0\)$/.test(e)}function Lr(e){var t;let o=e.ownerDocument.defaultView;if(!o)return{bg:null};for(let r=e;r;r=r.parentElement){let s=o.getComputedStyle(r),u=s.backgroundImage;if(u&&u!=="none"&&/gradient/.test(u)){let m=(t=u.match(/rgba?\([^)]+\)|#[0-9a-f]{3,8}/gi))!=null?t:[];if(m.length>0)return ue({bg:m[0]},m.length>1?{alt:m[m.length-1]}:{})}if(!mo(s.backgroundColor))return{bg:s.backgroundColor}}return{bg:null}}function cn(e,t=40){var o,r,s;let u=e.ownerDocument.createTreeWalker(e,4),m=[];for(let w=u.nextNode();w;w=u.nextNode())if(((o=w.nodeValue)!=null?o:"").trim()!==""&&!Tr.has((s=(r=w.parentElement)==null?void 0:r.tagName)!=null?s:"")&&(m.push(w),m.length>120))return{reason:"too_large"};if(m.length===0)return{reason:"empty"};let k=[],p=[];for(let w of m){let I=Ir(w,e),R=k.indexOf(I);R===-1&&(k.push(I),R=k.length-1),p.push(R)}if(k.length>t)return{reason:"too_large"};let b=m.map(w=>{var I;return uo((I=w.nodeValue)!=null?I:"")});return{textNodes:m,ownerEls:k,leafToNode:p,leaves:b,fp:po(b)}}function _r(e,t=40){var o,r;let s=cn(e,t);if(!("fp"in s))return{skeleton:null,reason:s.reason};let{textNodes:u,ownerEls:m,leafToNode:k,leaves:p}=s,b=e.ownerDocument,w=b.defaultView,I=[],R=m.map((P,Y)=>{var Z,W,q;let Q=w==null?void 0:w.getComputedStyle(P),ne=(Z=P.parentElement)!=null?Z:e,$=I.indexOf(ne);$===-1&&(I.push(ne),$=I.length-1);let H=fo.exec(P.tagName),V=go(P)?"action":H?"heading":Cr.has(P.tagName)?"label":"text",S=uo(p.filter((J,de)=>k[de]===Y).join(" "));return ot(ue(ot(ue({tag:P.tagName.toLowerCase(),role:V},H?{level:Number(H[1])}:{}),{text:S,classes:((W=P.getAttribute("class"))!=null?W:"").replace(/\s+/g," ").trim()}),V==="action"?ue({filled:!!Q&&(!mo(Q.backgroundColor)||Q.backgroundImage!==""&&Q.backgroundImage!=="none")},co(P.getAttribute("href"),b)!==void 0?{href:co(P.getAttribute("href"),b)}:{}):{}),{color:(q=Q==null?void 0:Q.color)!=null?q:"",group:$,restylable:!0})}),D=Lr(e),A=w==null?void 0:w.getComputedStyle(e);return{skeleton:{v:1,root:ot(ue({tag:e.tagName.toLowerCase(),classes:((o=e.getAttribute("class"))!=null?o:"").replace(/\s+/g," ").trim(),ambientBg:D.bg},D.alt?{ambientBgAlt:D.alt}:{}),{ambientText:(r=A==null?void 0:A.color)!=null?r:""}),nodes:R,leaves:p,leafToNode:k,fp:po(p)},textNodes:u,ownerEls:m}}function ho(e,t){try{let o=_r(e,t==null?void 0:t.maxNodes);return o.skeleton?{skeleton:o.skeleton}:o}catch(o){return{skeleton:null,reason:"unaddressable"}}}var yo=new WeakMap;function vo(e,t){return e.length===t.length&&e.every((o,r)=>o===t[r])}function bo(e,t,o){var u,m,k;let r=yo.get(e);if(r){if(r.fp!==o.fp||!vo(r.leafToNode,o.leafToNode))return"mismatch"}else{let p=cn(e);if(!("fp"in p)||(r={fp:p.fp,leafToNode:p.leafToNode,textNodes:p.textNodes,ownerEls:p.ownerEls,classes:p.ownerEls.map(b=>{var w;return(w=b.getAttribute("class"))!=null?w:""})},r.fp!==o.fp||!vo(r.leafToNode,o.leafToNode)))return"mismatch";yo.set(e,r)}let s=r;for(let[p,b]of Object.entries(t.nodes)){let w=Number(p),I=s.ownerEls[w];if(I){if(typeof b.text=="string"){let R=!0;s.leafToNode.forEach((D,A)=>{D===w&&(s.textNodes[A].nodeValue=R?b.text:"",R=!1)})}b.like!==void 0&&s.classes[b.like]!==void 0&&I.setAttribute("class",s.classes[b.like]),b.hidden&&((u=I.style)==null||u.setProperty("display","none","important"))}}for(let p of Object.values((m=t.order)!=null?m:{})){let b=p.map(A=>s.ownerEls[A]).filter(A=>!!A),w=(k=b[0])==null?void 0:k.parentElement;if(!w||b.length!==p.length||b.some(A=>A.parentElement!==w))continue;let I=new Set(b),R=0;Array.from(w.children).map(A=>I.has(A)?b[R++]:A).forEach((A,P)=>{var Y;w.children[P]!==A&&w.insertBefore(A,(Y=w.children[P])!=null?Y:null)})}return"applied"}an();var $r=new Set(["inline-block","block","flex","inline-flex"]),xo={H1:"heading-1",H2:"heading-2",H3:"heading-3"};function Re(e){let t=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)/i.exec(e);if(!t)return null;let o=t[4]===void 0?1:t[4].endsWith("%")?Number.parseFloat(t[4])/100:Number(t[4]);return{r:Number(t[1]),g:Number(t[2]),b:Number(t[3]),a:o}}function Ht(e){let t=o=>{let r=o/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function wo(e,t){let[o,r]=[Ht(e),Ht(t)].sort((s,u)=>u-s);return(o+.05)/(r+.05)}var zt=e=>{let t=Re(e);return t!==null&&t.a>0};function un(e){var t;return!e||e==="none"||!/gradient/i.test(e)?[]:(t=e.match(/rgba?\([^)]+\)/gi))!=null?t:[]}var Ne=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};function Br(e,t){for(let o=e;o;o=o.parentElement){let r=t.getComputedStyle(o);if(zt(r.backgroundColor))return Re(r.backgroundColor);let s=un(r.backgroundImage);if(s.length>0)return Re(s[0])}return{r:255,g:255,b:255,a:1}}function Dt(e){var t;for(let o of Array.from(e.childNodes))if(o.nodeType===3&&((t=o.nodeValue)!=null?t:"").trim()!=="")return!0;return!1}function Or(e,t,o){let r=e.tagName,s=Ne(t.fontSize)||o.bodySize,u=Number(t.fontWeight)||400,m=zt(t.backgroundColor),k=un(t.backgroundImage).length>0,p=Ne(t.borderTopLeftRadius||t.borderRadius),b=e.getBoundingClientRect().width;if(r==="BUTTON"||e.getAttribute("role")==="button"||r==="INPUT"&&/^(submit|button)$/i.test(e.type)||r==="A"&&$r.has(t.display)&&Ne(t.paddingLeft)>=8){let I=Re(t.backgroundColor);return m&&I&&!(I.r===o.pageBg.r&&I.g===o.pageBg.g&&I.b===o.pageBg.b)?"button-primary":Ne(t.borderTopWidth)>0?"button-secondary":"button-ghost"}if(r==="A")return"link";if(xo[r])return xo[r];if(Dt(e)&&s>=1.8*o.bodySize&&u>=600)return s>=2.5*o.bodySize?"heading-1":s>=2*o.bodySize?"heading-2":"heading-3";let w=e.nextElementSibling;if(Dt(e)&&s<=.9*o.bodySize&&(t.textTransform==="uppercase"||Ne(t.letterSpacing)>.05*s)&&w!==null&&/^H[1-4]$/.test(w.tagName))return"eyebrow";if(r==="UL"||r==="OL")return e.querySelectorAll(":scope > li").length>=2?"list":null;if(r==="P"&&Dt(e)){if(s>=1.1*o.bodySize)return"text-lead";if(s<=.85*o.bodySize)return"text-small";let I=Re(t.color);return I&&wo(I,Br(e,o.view))<o.bodyContrast*.8?"text-muted":"text-body"}return(r==="SPAN"||r==="DIV")&&m&&Dt(e)&&e.children.length===0&&p>=999?"badge":/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(r)&&(m||k)&&p>0&&Ne(t.paddingTop)>=16&&!(b>0&&b>=.9*o.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(r)&&(m||k)&&e.querySelector("h1,h2,h3")!==null&&(b===0||b>=.9*o.vw)?"section":null}function ko(e,t){var o,r,s,u,m,k,p,b;let w=e.defaultView;if(!w||!e.body)return{entries:[],images:[]};let I=w.getComputedStyle(e.body),R=Ne(I.fontSize)||16,D=zt(I.backgroundColor)?Re(I.backgroundColor):{r:255,g:255,b:255,a:1},A=(o=Re(I.color))!=null?o:{r:17,g:24,b:39,a:1},P={bodySize:R,pageBg:D,bodyContrast:wo(A,D),view:w,vw:w.innerWidth||0},Y=(s=(r=w.location)==null?void 0:r.pathname)!=null?s:"/",Z=new Date().toISOString(),W=new Map,q=new Map,Q=Array.from(e.body.querySelectorAll("*")).slice(0,(u=t==null?void 0:t.maxElements)!=null?u:4e3);for(let H of Q)try{if(H.tagName==="IMG"){let X=H,ce=((m=X.getAttribute("alt"))!=null?m:"").trim(),re=X.naturalWidth||Number(X.getAttribute("width"))||0,pe=X.naturalHeight||Number(X.getAttribute("height"))||0,Te=X.getAttribute("src");if(ce&&re>=200&&Te){let He=new URL(Te,e.baseURI).href;He.startsWith("https://")&&!q.has(He)&&q.set(He,{id:`img-${q.size+1}`,src:He,alt:ce.slice(0,200),w:re,h:pe,seenOn:Y})}}let V=((k=H.getAttribute("class"))!=null?k:"").replace(/\s+/g," ").trim();if(V==="")continue;let S=w.getComputedStyle(H),J=H.tagName==="IMG"?((p=H.getAttribute("alt"))!=null?p:"").trim()?"image":null:Or(H,S,P);if(!J)continue;let de=`${J}|${V}`,U=W.get(de);if(U){U.seen.count++;continue}let oe=un(S.backgroundImage).map(Re).filter(X=>X!==null),we,Le;if(zt(S.backgroundColor))we=S.backgroundColor;else if(oe.length>0){let X=[...oe].sort((re,pe)=>Ht(re)-Ht(pe)),ce=re=>re.a<1?`rgba(${re.r}, ${re.g}, ${re.b}, ${re.a})`:`rgb(${re.r}, ${re.g}, ${re.b})`;we=ce(X[0]),X.length>1&&(Le=ce(X[X.length-1]))}let Ce=S.borderTopLeftRadius||S.borderRadius;W.set(de,{id:J,role:J,classes:V,computed:ue(ue(ue(ue(ue(ue({},S.color?{color:S.color}:{}),we?{bg:we}:{}),Le?{bgDark:Le}:{}),S.fontSize?{fontSize:S.fontSize}:{}),S.fontWeight?{fontWeight:S.fontWeight}:{}),Ce&&Ne(Ce)>0?{radius:Ce}:{}),seen:{url:Y,count:1,at:Z}})}catch(V){}let ne=new Map;for(let H of W.values())ne.set(H.role,[...(b=ne.get(H.role))!=null?b:[],H]);let $=[];for(let[H,V]of ne)V.sort((S,J)=>J.seen.count-S.seen.count).slice(0,4).forEach((S,J)=>$.push(ot(ue({},S),{id:J===0?H:`${H}-${J+1}`})));return{entries:$,images:[...q.values()]}}function So(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let o="";for(let r=0;r<e.length;r++){let s=e[r],u=s>="0"&&s<="9";r===0&&u||r===1&&u&&e[0]==="-"?o+=`\\3${s} `:r===0&&s==="-"&&e.length===1?o+="\\-":/[a-zA-Z0-9_-]/.test(s)?o+=s:o+=`\\${s}`}return o}function Mr(e,t){if(e.id)return`#${So(e.id)}`;let o=[],r=e,s=0;for(;r&&r!==t.body&&r!==t.documentElement&&s<6;){if(r.id){o.unshift(`#${So(r.id)}`);break}let u=r.tagName.toLowerCase(),m=r.parentElement;if(m){let k=Array.from(m.children).filter(p=>p.tagName===r.tagName);k.length>1&&(u+=`:nth-of-type(${k.indexOf(r)+1})`)}o.unshift(u),r=r.parentElement,s++}return o.join(" > ")}function qe(e,t){var s;let o={v:1};e.id&&(o.id=e.id);for(let u of["data-framer-name","data-w-id","data-sentient-name"]){let m=e.getAttribute(u);if(m){o.dataAttr={name:u,value:m};break}}o.selector=Mr(e,t);let r=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return o.fingerprint=j({tag:e.tagName.toLowerCase()},r?{text:r}:{}),o}function it(e,t,o){return xe(e,o)===t}var Pr="__snt_editor_token";function Ct(){try{sessionStorage.removeItem(Pr)}catch(e){}}var Nr=/rgba\([^)]*,\s*0\s*\)$/,Rr=/^\d+(\.\d+)?px$/;function Eo(e){var t,o;try{let r=e.defaultView;if(!r||!e.body)return null;let s=r.getComputedStyle(e.body).backgroundColor,u=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),m=new Map;for(let R of Array.from(u).slice(0,300)){let D=R.getBoundingClientRect();if(D.width>0&&(D.width<48||D.height<24))continue;let A=r.getComputedStyle(R),P=A.backgroundColor;if(!P||P==="transparent"||P===s||Nr.test(P))continue;let Y=(t=(A.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${P}|${A.color}|${Rr.test(Y)?Y:"8px"}`;m.set(Z,((o=m.get(Z))!=null?o:0)+1)}let k=null,p=0;for(let[R,D]of m)D>p&&(k=R,p=D);if(!k)return null;let[b,w,I]=k.split("|");return{primaryBg:b,primaryText:w,radius:I}}catch(r){return null}}var Tt={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Dr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function at(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,o;for(;(o=t.exec(e))!==null;)if(!Dr.test((r=o[1])!=null?r:""))return!1;return!0}var Co=/^https:\/\//i,To=new Map,De=null;function Hr(e){return e.replace(/["\\]/g,"\\$&")}function zr(e){var t;(!De||!De.isConnected)&&(De=e.querySelector("style[data-sentient-ops]"),De||(De=e.createElement("style"),De.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(De))),De.textContent=[...To.entries()].map(([o,r])=>`[data-snt-e="${Hr(o)}"]{${r}}`).join(`
|
|
2
|
+
`)}function Ao(e,t,o,r){var k;let s=!1,u=(k=t.moveBefore)!=null?k:t.moveAfter;if(u){let p=xe(u,r);!p||p===e||p.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,p):e.parentElement.insertBefore(e,p.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Co.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Co.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let m=[];if(t.hidden&&m.push("display:none !important"),t.style)for(let[p,b]of Object.entries(t.style)){let w=Tt[p];w&&typeof b=="string"&&at(b)&&m.push(`${w}:${b.trim()} !important`)}return m.length>0&&(e.setAttribute("data-snt-e",o),To.set(o,m.join(";")),zr(r)),{anchorMiss:s}}function At(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function Io(e,t){return e==="*"?"Every page":e.endsWith("/*")?`All pages under ${e.slice(0,-1)}`:e===t?`This page (${e})`:`Only on ${e}`}function pn(e,t){let o=At(e),r=o.split("/").filter(Boolean),s=[o,"*"];return r.length>=2&&s.push(`/${r[0]}/*`),(t?[t,...s.filter(u=>u!==t)]:s).filter(u=>sn.test(u))}function jt(e){let t=e.steps.length,o=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${o}`}function Ut(e,t){return e.steps.map(o=>{var r;return{value:o.step_index,label:`${o.step_index+1}. ${(r=t.get(o.goal_id))!=null?r:o.goal_id}`}})}function Lo(e,t){return e.includes(t)?e.filter(o=>o!==t):[...e,t]}function jr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function _o(e,t){let o=e.trim();return o?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:jr(o),body:{displayName:o.slice(0,128),steps:t.map(r=>({goalId:r}))}}:{ok:!1,error:"Give the funnel a name."}}function Oo(e){let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o)>>>0;return t.toString(36)}function st(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Ee(e,t,o){var k,p;let r=t.id||((k=t.dataAttr)==null?void 0:k.value)||((p=o.textContent)!=null?p:"").trim()||o.tagName,s=st(r)||"el",u=Oo(JSON.stringify(t));return`${e}-${s}-${u}`.slice(0,128)}var Ur="sentient-editor-highlight",Kr="sentient-editor-selection",dt="sentient-editor-panel",Gt="sentient-editor-toast",mn="sentient-editor-styles",hn="sentient-editor-target-highlight",Gr=10,Fr="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Wr="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Mo(){var t;if(document.getElementById(mn))return;let e=document.createElement("style");e.id=mn,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,23 +12,23 @@
|
|
|
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
|
-
#${
|
|
15
|
+
#${dt} {
|
|
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
|
-
#${
|
|
20
|
-
#${
|
|
19
|
+
#${dt} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
|
|
20
|
+
#${Gt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
|
|
21
21
|
@media (prefers-reduced-motion: reduce) {
|
|
22
|
-
#${
|
|
22
|
+
#${dt}, #${dt} .sntedi-dot, #${Gt} { animation: none !important; }
|
|
23
23
|
}
|
|
24
|
-
`,((n=document.head)!=null?n:document.documentElement).appendChild(e)}function eo(e){var i,c;no(),(i=document.getElementById(Ot))==null||i.remove();let n=l("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});n.id=Ot;let r=l("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});n.append(r,l("div",{},e)),((c=document.body)!=null?c:document.documentElement).appendChild(n),n.addEventListener("click",()=>n.remove()),setTimeout(()=>n.remove(),1e4)}function Qo(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function er(e){try{let n=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(n.status===401)return{ok:!1,unauthorized:!0};if(!n.ok)return{ok:!1,unauthorized:!1};let r=(await n.json()).projectId;return r?{ok:!0,projectId:r}:{ok:!1,unauthorized:!1}}catch(n){return{ok:!1,unauthorized:!1}}}function dn(e,n){return B(B(B(B({r:e===401?"expired":"error",status:e},typeof(n==null?void 0:n.error)=="string"?{code:n.error}:{}),typeof(n==null?void 0:n.message)=="string"?{message:n.message}:{}),typeof(n==null?void 0:n.feature)=="string"?{feature:n.feature}:{}),typeof(n==null?void 0:n.plan)=="string"?{plan:n.plan}:{})}async function Q(e,n,r){try{let i=await fetch(`${e.apiBase}${n}`,{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 dn(i.status,c)}catch(i){return{r:"error"}}}async function tr(e,n){try{let r=await fetch(`${e.apiBase}${n}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(r.ok)return{r:"ok"};let i=await r.json().catch(()=>null);return dn(r.status,i)}catch(r){return{r:"error"}}}async function nr(e,n,r){try{let i=await fetch(`${e.apiBase}${n}`,{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:dn(i.status,c)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var on=[];function cn(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function rn(e){let n=e.trim();if(cn(n))return n;let r=/^#([0-9a-fA-F]{3})$/.exec(n);if(r)return`#${r[1].split("").map(m=>m+m).join("")}`;let i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(n);if(!i)return n;let c=m=>Math.min(255,Number(m)).toString(16).padStart(2,"0");return`#${c(i[1])}${c(i[2])}${c(i[3])}`}var He=null,sn=[];function oo(e){sn=e}async function or(e){try{let n=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!n.ok)return[];let r=await n.json();return on=Array.isArray(r.fonts)?r.fonts.filter(i=>typeof i=="string"):[],Array.isArray(r.targets)?r.targets:[]}catch(n){return[]}}async function xt(e,n){try{let r=await fetch(`${e.apiBase}${n}`,{headers:{authorization:`Bearer ${e.token}`}});return r.ok?await r.json():null}catch(r){return null}}function et(e=document){for(let n of Array.from(e.querySelectorAll(`.${nn}`)))n.remove()}function ro(e,n=document){var i;et(n);let r=0;for(let c of e){if(r>=Vo)break;let m=ge(c.locator,n);if(!m)continue;let b=m.getBoundingClientRect(),L=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${b.left}px`,top:`${b.top}px`,width:`${b.width}px`,height:`${b.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});L.className=nn;let v=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${b.left}px`,top:`${Math.max(0,b.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},c.label);v.className=nn,((i=n.body)!=null?i:n.documentElement).append(L,v),r+=1}}function Mt(e,n){let r=e.previousElementSibling,i=e.nextElementSibling,c=r?De(r,n):null,m=i?De(i,n):null;return{prevEl:r,nextEl:i,prevLocator:r&&c&&Ve(c,r,n)?c:null,nextLocator:i&&m&&Ve(m,i,n)?m:null}}var rr=/testimonial|review|quote/i;function io(e){let n=[],r=e.headings.length>=1,i=e.links.length>=1;return r&&i&&n.push("hero","cta_band"),e.headings.length>=2&&e.paragraphs.length>=2&&n.push("feature_grid"),e.quotes.length>=1&&n.push("testimonial"),n}var an=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],ir=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,sr=new Set(["left","center","right","justify","start","end"]),ar=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,lr=/^(rgb|rgba|hsl|hsla)\(/i;function dr(e){return ar.test(e)||lr.test(e)}function so(e,n){switch(e){case"fontSize":case"borderRadius":return ir.test(n)?null:"Add a unit, e.g. 20px or 1.5rem.";case"fontWeight":return/^(normal|bold|bolder|lighter)$/i.test(n)||/^\d{1,4}$/.test(n)&&+n>=1&&+n<=1e3?null:"Use 100\u2013900, or normal/bold.";case"textAlign":return sr.has(n.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return dr(n)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let r=n.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return n.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 ln(e){let n={},r={};for(let i of an){let c=e[i];if(typeof c!="string")continue;let m=c.trim();if(m==="")continue;if(!Xe(m)){r[i]="That value isn\u2019t allowed.";continue}let b=so(i,m);if(b){r[i]=b;continue}n[i]=m}return{style:n,errors:r}}function l(e,n,r){let i=document.createElement(e);return Object.assign(i.style,n),r!==void 0&&(i.textContent=r),i}function ao(e){var Rn;let n=null,r=[],i=null,c=()=>{for(;r.length>0;){let t=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:t})}).catch(()=>{})}catch(o){}}},m=(t,o)=>{r.push(B({kind:t},o?{meta:o}:{})),i&&clearTimeout(i),i=setTimeout(c,2e3)};window.addEventListener("pagehide",c);let b=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});b.id=Jo;let L=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});L.id=Yo;let v=()=>{if(!n||!n.isConnected){L.style.display="none";return}let t=n.getBoundingClientRect();Object.assign(L.style,{display:"block",left:`${t.left-2}px`,top:`${t.top-2}px`,width:`${t.width}px`,height:`${t.height}px`})},M=()=>v();no();let H=l("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"});H.id=Qe;let ee=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});ee.className="sntedi-dot";let F=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});F.append(ee,l("span",{},"SentientUI"));let R=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),D=!1,J=l("button",P("#374151"),"Pause selecting");J.onclick=()=>{D=!D,J.textContent=D?"Resume selecting":"Pause selecting",D?(b.style.display="none",et(document),w("Selection paused \u2014 browse normally, then resume.")):w("Click any element on the page to adapt it.")};let X=l("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Z=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),K=l("button",P("#6366f1"),"Test different text here"),Y=l("button",P("#374151"),"Change style"),se=l("button",P("#374151"),"Try a different layout for this section"),ae=l("button",P("#374151"),"Track clicks as a goal"),x=l("button",P("#374151"),"Track form submissions as a goal"),G=l("button",P("#374151"),"Track page visits as a goal"),le=l("button",P("#374151"),"Track reading this far as a goal"),U=l("button",P("#374151"),"Set up a funnel"),de=l("button",P("#374151"),"Attach this test to a funnel step"),Ae=l("button",P("#10b981"),"Turn the funnel on"),we=l("button",P("#374151"),"Move up"),ke=l("button",P("#374151"),"Move down"),tt=l("button",P("#6366f1"),"Save this arrangement"),wt=l("button",P("#374151"),"Undo"),nt=en("close","Close editor"),he=l("button",P("#10b981"),"Publish now \u2014 go live"),ye=l("button",P("#10b981"),"Start tracking now");for(let t of[K,Y,se,ae,we,ke])t.disabled=!0;let Rt=[K,Y,se,ae,x,we,ke];for(let t of Rt)t.style.display="none";tt.style.display="none",wt.style.display="none",he.style.display="none",ye.style.display="none",de.style.display="none",Ae.style.display="none";let ve=l("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),je=l("div",{}),un=[{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"}],ce="text",pn=new Map,Se=new Map,Nt=new Map,fn=l("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),gn=l("div",{paddingTop:"10px"});for(let t of un){let o=l("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(l("span",{fontSize:"11px",marginRight:"3px"},t.icon),l("span",{},t.label)),o.onclick=()=>lo(t.id),pn.set(t.id,o),fn.append(o);let s=l("div",{display:"none"}),a=l("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});s.append(a),Nt.set(t.id,a),Se.set(t.id,s),gn.append(s)}Se.get("text").append(K),Se.get("style").append(Y),Se.get("layout").append(se,we,ke,tt,wt),Se.get("goals").append(ae,x,G,le),Se.get("funnels").append(U,de,Ae);let ue=l("div",{});Se.get("drafts").append(ue);let kt=()=>{var o,s;for(let a of un){let d=a.id===ce,u=pn.get(a.id);u.style.color=d?"#ffffff":"#9ca3af",u.style.borderBottom=d?"2px solid #6366f1":"2px solid transparent",Se.get(a.id).style.display=d?"block":"none",Nt.get(a.id).style.display="none"}let t=a=>{let d=Nt.get(ce);d.textContent=a,d.style.display="block"};ce==="text"?n?K.disabled?t(K.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(o=K.onclick)==null||o.call(K,new MouseEvent("click")):t("Click any text on the page to test a different wording."):ce==="style"?n?Y.disabled?t("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(s=Y.onclick)==null||s.call(Y,new MouseEvent("click")):t("Click any element on the page to change how it looks."):ce==="layout"?n||t("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."):ce==="goals"?n||t("Page-level goals work right away; click a button or form to track it specifically."):ce==="funnels"?t("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):ce==="drafts"&&Ke()},be=(t,o)=>l("button",V(B({},P(t)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),o),mn=(t,o)=>{let s=new URL(window.location.href);s.searchParams.delete("sentient_editor"),s.searchParams.set("sentient_preview",t),o&&s.searchParams.set("sentient_arm",o),window.location.assign(s.toString())},St=(t,o,s)=>{let a=be("#374151","Discard");return a.onclick=async()=>{a.disabled=!0;let d=await tr(e,t);a.disabled=!1,re(d,o),d.r==="ok"&&s()},a},hn=(t,o)=>{$e.textContent="";let s=l("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)"}),a=l("div",{display:"flex",gap:"6px",flexWrap:"wrap"});a.append(...o),s.append(l("div",{marginBottom:"6px"},t),a),$e.append(s)},Ke=async()=>{var y,k,C,f,h,I,S,A,O,T,ne,oe;ue.textContent="",ue.append(l("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let t=[],o=[],s=null,a=!1;if(await Promise.all([(async()=>{var E;try{let $=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});$.ok?t=(E=(await $.json()).slots)!=null?E:[]:s=$.status===401?"expired":"error"}catch($){s="error"}})(),(async()=>{var E;try{let $=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});$.ok?o=(E=(await $.json()).goals)!=null?E:[]:a=!0}catch($){a=!0}})()]),ce!=="drafts")return;if(ue.textContent="",s){if(ue.append(l("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=be("#374151","Retry");E.onclick=()=>{Ke()},ue.append(E)}return}let d=t.filter(E=>{var $,q,xe,Le,Ne,mt;return((xe=(q=($=E.draft_config)==null?void 0:$.arms)==null?void 0:q.length)!=null?xe:0)>0||((mt=(Ne=(Le=E.published_config)==null?void 0:Le.arms)==null?void 0:Ne.length)!=null?mt:0)>0}),u=o.filter(E=>E.event!=="custom"&&(E.status==="draft"||E.status==="active"));if(d.length===0&&u.length===0&&!a){ue.append(l("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 g=E=>l("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 $=l("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),q=l("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},E);return $.append(q),{row:$,name:q}};for(let E of d){let{row:$}=p((y=E.display_name)!=null?y:E.slot_id);$.append(g(E.status==="published"));let q=(h=(f=(k=E.draft_config)==null?void 0:k.arms)!=null?f:(C=E.published_config)==null?void 0:C.arms)!=null?h:[],xe=(A=(I=q[1])==null?void 0:I.id)!=null?A:(S=q[0])==null?void 0:S.id,Le=be("#374151","Preview");if(Le.onclick=()=>mn(E.slot_id,xe),$.append(Le),E.status!=="published"&&((ne=(T=(O=E.draft_config)==null?void 0:O.arms)==null?void 0:T.length)!=null?ne:0)>0){let Ne=be("#10b981","Publish");Ne.onclick=async()=>{Ne.disabled=!0;let mt=await Q(e,`/v1/editor/slots/${encodeURIComponent(E.slot_id)}/publish`,{});Ne.disabled=!1,re(mt,"\u2713 Published \u2014 live for new visitors."),mt.r==="ok"&&(m("published",{kind:"slot"}),Ke())},$.append(Ne)}E.status!=="published"&&$.append(St(`/v1/editor/slots/${encodeURIComponent(E.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{En(E.slot_id),Ke()})),ue.append($)}if(a)ue.append(l("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(u.length>0){ue.append(l("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let E of u){let{row:$}=p((oe=E.display_name)!=null?oe:E.goal_id);if($.append(g(E.status==="active")),E.status==="draft"){let q=be("#10b981","Start tracking");q.onclick=async()=>{q.disabled=!0;let xe=await Q(e,`/v1/editor/goals/${encodeURIComponent(E.goal_id)}/publish`,{});q.disabled=!1,re(xe,"\u2713 Tracking is live \u2014 it counts from your next visitor."),xe.r==="ok"&&(m("published",{kind:"goal"}),Ke())},$.append(q,St(`/v1/editor/goals/${encodeURIComponent(E.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Cn(E.goal_id),Ke()}))}ue.append($)}}},lo=t=>{ce!==t&&(W(),dt(),ce=t,kt())},yn=l("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(F.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let vn=!1,Ee=l("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"44px",height:"44px",borderRadius:"12px",border:"1px solid #2a2a2a",background:"#000",cursor:"pointer",display:"none",padding:"0",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 18px rgba(0,0,0,0.4)"});Ee.append(ur(26)),Ee.title="Open the SentientUI editor",Ee.setAttribute("aria-label","Open the SentientUI editor");let bn=en("minimize","Minimize");bn.onclick=()=>{H.style.display="none",Ee.style.display="flex",vn=D,D=!0,b.style.display="none",et(document)},Ee.onclick=()=>{H.style.display="block",Ee.style.display="none",D=vn},Object.assign(J.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),yn.append(F,J,bn,nt);let xn=l("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),$e=l("div",{});Object.assign(Z.style,{marginBottom:"4px"}),xn.append($e,Z,he,ye);let wn=l("button",{display:"inline-block",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"),Dt=l("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(X.style,{flex:"1 1 auto",marginBottom:"0"}),Dt.append(X,wn),Object.assign(Dt.style,{marginBottom:"6px"});let Et=l("div",{}),N=l("div",{marginTop:"4px"});N.addEventListener("input",()=>{Ge=!0}),N.addEventListener("change",()=>{Ge=!0}),H.append(yn,R,Dt,ve,je,Et,fn,gn,N,xn),((Rn=document.body)!=null?Rn:document.documentElement).append(b,L,H,Ee);let Ce=null,Ct=()=>{Ce==null||Ce(),Ce=null},kn=()=>{Ce=null},ot=null,Ge=!1,Ht=null,W=()=>{Ct(),ot=null,N.textContent="",Ge=!1,Ht=null,Jt=!1},rt=(t,o,s,a)=>{var C;W();let d={},u={},g={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let f of t){let h=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},f.label);if(N.append(h),f.type==="select"){let S=l("select",g);S.setAttribute("data-field",f.key);let A=document.createElement("option");A.value="",A.textContent="\u2014 no change \u2014",S.append(A);for(let O of(C=f.options)!=null?C:[]){let T=document.createElement("option");T.value=O,T.textContent=O,S.append(T)}d[f.key]=()=>S.value,N.append(S)}else if(f.type==="color"){let S=l("input",V(B({},g),{padding:"2px",height:"34px"}));S.type="color",S.setAttribute("data-field",f.key);let A=!1;S.addEventListener("input",()=>{A=!0}),d[f.key]=()=>A?S.value:"",N.append(S)}else{let S=l("input",g);S.setAttribute("data-field",f.key),f.value!==void 0&&(S.value=f.value),d[f.key]=()=>S.value,N.append(S)}let I=l("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});I.setAttribute("data-feedback",f.key),u[f.key]=I,N.append(I)}let p=(f,h)=>{let I=u[f];I&&(I.textContent=h!=null?h:"",I.style.display=h?"block":"none")};if(a){let f=Sn(a);N.append(f.node),d[it]=f.value}let y=l("button",P("#6366f1"),o),k=l("button",V(B({},P("transparent")),{opacity:"0.6"}),"Cancel");y.onclick=()=>s(Object.fromEntries(Object.entries(d).map(([f,h])=>[f,h()])),p),k.onclick=W,N.append(y,k)},it="__page",zt={},co=t=>{var o;for(let s of t!=null?t:[])zt[s.slot_id]=(o=s.target)==null?void 0:o.page};xt(e,"/v1/editor/slots").then(t=>co(t==null?void 0:t.slots));let Sn=t=>{let o=bt(location.pathname),s=l("div",{}),a=l("select",{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"});a.setAttribute("data-field","page");for(let d of Qt(o,zt[t])){let u=document.createElement("option");u.value=d,u.textContent=Xn(d,o),a.append(u)}return s.append(l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),a,l("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:s,value:()=>a.value}},st=(t,o)=>o?V(B({},t),{page:o}):t,w=(t,o=!0)=>{Z.textContent=t,Z.style.color=o?"#a7f3d0":"#fca5a5"},jt=(t,o)=>{var a,d;if(m("error_shown",{code:(d=t.code)!=null?d:`http_${(a=t.status)!=null?a:"network"}`}),t.code==="plan_limit_reached"){let u=t.feature==="live_goals"?"live goal":"of these",g=t.plan?`${t.plan} plan`:"plan";return t.feature==="live_goals"?`Your ${g} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${g} has reached its limit for ${u}. Manage them in your dashboard, or upgrade for more.`}if(t.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(t.code==="demo_read_only"&&t.message)return t.message;let s=t.status?` (HTTP ${t.status})`:"";return`\u26A0 Couldn\u2019t ${o} \u2014 try again.${s}`},re=(t,o)=>{t.r==="ok"?w(o,!0):t.r==="expired"?w("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):w(jt(t,"save"),!1)},Be=null,Tt=t=>t.length>30?`${t.slice(0,27)}\u2026`:t,En=t=>{Be===t&&(ot===t&&(Ct(),ot=null),Be=null,he.style.display="none",de.style.display="none",$e.textContent="")},Cn=t=>{qe===t&&(qe=null,ye.style.display="none",$e.textContent="")},at=(t,o,s)=>{Be=t,he.textContent=o?`Publish \u201C${Tt(o)}\u201D \u2014 go live`:"Publish now \u2014 go live",he.style.display="block",de.style.display="block";let a=[];if(s){let d=be("#374151","Preview");d.onclick=()=>mn(t,s),a.push(d)}a.push(St(`/v1/editor/slots/${encodeURIComponent(t)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>En(t))),hn(o?`Draft saved for \u201C${Tt(o)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",a)};he.onclick=async()=>{if(!Be)return;he.disabled=!0,w("Publishing\u2026");let t=await Q(e,`/v1/editor/slots/${encodeURIComponent(Be)}/publish`,{});he.disabled=!1,t.r==="ok"?(m("published",{kind:"slot"}),w("\u2713 Published \u2014 live for new visitors.",!0),he.style.display="none",Be=null,$e.textContent=""):t.r==="expired"?w("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):w(jt(t,"publish"),!1)};let j=null,Te=!1,Ue=null,Fe=null,pe=null,Me=null,lt=null,_t=null,Oe=!1,Tn=(t,o)=>Te?t?"":`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.",_n=()=>{we.disabled=!Te||!pe,ke.disabled=!Te||!Me,we.title=we.disabled?Tn(pe,"above"):"",ke.title=ke.disabled?Tn(Me,"below"):""},fe=null,Kt=t=>{t&&!fe&&n&&j?(fe=Sn(me("move",j,n)),tt.before(fe.node)):t||(fe==null||fe.node.remove(),fe=null),tt.style.display=t?"block":"none",wt.style.display=t?"block":"none",_n()},dt=()=>{if(Oe&&n&<&<.insertBefore(n,_t),Oe=!1,lt=null,_t=null,n){let t=Mt(n,document);Ue=t.prevEl,Fe=t.nextEl,pe=t.prevLocator,Me=t.nextLocator}v(),Kt(!1)},Ln=t=>{if(D)return;let o=t.target;if(!o||H.contains(o)||o===b)return;et(document);let s=o.getBoundingClientRect();Object.assign(b.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},_e=t=>{var s;let o=((s=t.textContent)!=null?s:"").trim().replace(/\s+/g," ");return o?o.length>40?`${o.slice(0,37)}\u2026`:o:t.tagName.toLowerCase()},uo=t=>!!t.id||["section","header","footer","nav","main","form","article","aside"].includes(t.tagName.toLowerCase())||!!t.querySelector(":scope > h1, :scope > h2, :scope > h3"),po=t=>{var a;let o=t.querySelector("h1, h2, h3"),s=(a=o==null?void 0:o.textContent)==null?void 0:a.replace(/\s+/g," ").trim();return s?s.length>28?`${s.slice(0,25)}\u2026`:s:t.id?`#${t.id.length>24?`${t.id.slice(0,21)}\u2026`:t.id}`:`<${t.tagName.toLowerCase()}>`},fo=t=>{ve.textContent="";let o=[];for(let g=t.parentElement;g&&g!==document.body&&o.length<3;g=g.parentElement)uo(g)&&o.push(g);let s=_e(t),a=()=>l("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),d=!0;for(let g of o){let p=po(g);if(p===s||s.startsWith(p))continue;let y=l("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);y.onclick=()=>ct(g),d||ve.append(a()),ve.append(y),d=!1}d||ve.append(a());let u=l("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");u.onclick=()=>In(),ve.append(u),ve.style.display="block"},go=t=>{je.textContent="";let o=null,s=0;for(let d=t.parentElement;d&&d!==document.body&&s<6;d=d.parentElement,s++)if(Ve(De(d,document),d,document)){o=d;break}let a=l("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;a.append(l("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 u=l("button",V(B({},P("#6366f1")),{marginTop:"0"}),`Select \u201C${_e(d)}\u201D instead`);u.onclick=()=>ct(d);let g=l("button",V(B({},P("transparent")),{opacity:"0.6"}),"Pick something else");g.onclick=()=>{je.textContent=""},a.append(u,g)}else a.append(l("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));je.append(a)},ct=t=>{dt(),W(),je.textContent="",n=t,j=De(t,document);let o=Ve(j,t,document);Te=o,v(),X.style.display="block",X.textContent=`Selected: ${_e(t)}`,fo(t),m("element_selected",{unique:o}),w(o?"\u2713 Matches exactly 1 element":"",o),o||go(t),R.style.display="none",Wt();for(let u of Rt)u.style.display="block";K.style.display="none",Y.style.display="none";let s=t.childElementCount===0;K.disabled=!o||!s,K.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.":"",Y.disabled=!o,se.disabled=!o,ae.disabled=!o;let a=t.closest("form");x.style.display=a?"block":"none",x.disabled=!a;let d=Mt(t,document);Ue=d.prevEl,Fe=d.nextEl,pe=d.prevLocator,Me=d.nextLocator,_n(),kt()},In=()=>{dt(),W(),n=null,j=null,Te=!1,Ue=null,Fe=null,pe=null,Me=null,v(),je.textContent="",Wt(),ve.textContent="",ve.style.display="none",X.textContent="",X.style.display="none";for(let t of Rt)t.style.display="none";R.style.display="block",w(""),kt()},We=!1,Gt=-1,An=t=>{var a,d;let o=t.target,s=!!((a=o==null?void 0:o.closest)!=null&&a.call(o,'input, textarea, select, [contenteditable="true"]'));if(t.key==="Escape"){if(N.childElementCount>0){W(),We=!1;return}if(n){In(),We=!1;return}if(!We){We=!0,w("Press Esc again to close the editor.");return}We=!1,(d=nt.onclick)==null||d.call(nt,new MouseEvent("click"));return}if(We=!1,!(s||D)){if(t.key==="ArrowUp"||t.key==="ArrowDown"){if(!n||(t.key==="ArrowUp"?we:ke).disabled)return;t.preventDefault(),qt(t.key==="ArrowUp"?"up":"down");return}if(t.key==="Tab"){let u=[];for(let p of sn){let y=ge(p.locator,document);y&&!u.includes(y)&&u.push(y)}if(u.length===0)return;if(Ge){w("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),t.preventDefault();return}t.preventDefault(),Gt=(Gt+(t.shiftKey?-1:1)+u.length)%u.length;let g=u[Gt];ct(g);try{g.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},$n=t=>{if(D)return;let o=t.target;if(!(!o||H.contains(o))){if(t.preventDefault(),t.stopPropagation(),Ge&&o!==n&&Ht!==o){Ht=o,w("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}ct(o)}};K.onclick=()=>{var u,g,p;if(!n||!j)return;m("form_opened",{kind:"text"});let t=j,o=(g=(u=n.textContent)==null?void 0:u.trim())!=null?g:"";rt([{key:"current",label:"Current wording",value:o},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async y=>{let k=y.alt.trim();if(!k){w("\u26A0 Enter alternative wording to test.",!1);return}if(k===y.current.trim()){w("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let C=me("text",t,n);w("Saving\u2026");let f=await Q(e,`/v1/editor/slots/${encodeURIComponent(C)}`,{kind:"arms",target:st(t,y[it]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:y.current}},{id:"b",displayName:"Alternative",ops:{text:y.alt}}]}});f.r==="ok"&&(m("draft_saved",{kind:"slot"}),kn(),W(),at(C,_e(n),"b")),re(f,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},me("text",t,n));let s=n,a=(p=s.textContent)!=null?p:"";Ce=()=>{s.textContent=a};let d=N.querySelector('input[data-field="alt"]');d==null||d.addEventListener("input",()=>{s.textContent=d.value.trim()===""?a:d.value})};let ut=null,Bn=t=>{let o=p=>{var y;return((y=p.textContent)!=null?y:"").replace(/\s+/g," ").trim()},s=Array.from(t.querySelectorAll("h1,h2,h3,h4")).map(o).filter(Boolean);if(s.length===0){let p=t.closest("h1,h2,h3,h4");p&&s.push(o(p))}let a=Array.from(t.querySelectorAll("p")).map(o).filter(p=>p.length>0&&p.length<=300),d=[];for(let p of Array.from(t.querySelectorAll("a[href], button"))){let y=o(p);if(!y||y.length>60)continue;let k="",C=p.getAttribute("href");if(C)try{let f=new URL(C,window.location.href);f.protocol==="https:"&&(k=f.href)}catch(f){}d.push({label:y,href:k})}let u=Array.from(t.querySelectorAll("blockquote, q")).map(o).filter(Boolean);if(u.length===0&&rr.test(`${t.className} ${t.id}`))for(let p of a)p.length>=20&&u.push(p);let g=Array.from(t.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(o).filter(p=>p.length>0&&p.length<=80);return{headings:s,paragraphs:a,links:d,quotes:u,attributions:g}},mo=(t,o)=>{var a,d,u,g,p,y,k,C,f,h,I,S,A,O,T,ne,oe,E,$,q;let s=xe=>{var Le;return o.paragraphs.length>=3&&(Le=o.paragraphs[o.paragraphs.length-3+xe])!=null?Le:""};switch(t){case"headline":return(a=o.headings[0])!=null?a:"";case"supporting":return(d=o.paragraphs[0])!=null?d:"";case"cta_label":return(g=(u=o.links[0])==null?void 0:u.label)!=null?g:"";case"cta_href":return(y=(p=o.links[0])==null?void 0:p.href)!=null?y:"";case"secondary_label":return(C=(k=o.links[1])==null?void 0:k.label)!=null?C:"";case"secondary_href":return(h=(f=o.links[1])==null?void 0:f.href)!=null?h:"";case"quote":case"q1":return(I=o.quotes[0])!=null?I:"";case"q2":return(S=o.quotes[1])!=null?S:"";case"q3":return(A=o.quotes[2])!=null?A:"";case"name":case"n1":return(O=o.attributions[0])!=null?O:"";case"n2":return(T=o.attributions[1])!=null?T:"";case"n3":return(ne=o.attributions[2])!=null?ne:"";case"role":return(oe=o.attributions[1])!=null?oe:"";case"eyebrow":return"";case"f1_title":return(E=o.headings[1])!=null?E:"";case"f2_title":return($=o.headings[2])!=null?$:"";case"f3_title":return(q=o.headings[3])!=null?q:"";case"f1_body":return s(0);case"f2_body":return s(1);case"f3_body":return s(2);default:return""}},ho=(t,o,s)=>{m("form_opened",{kind:"arrangement"});let a=Bn(s);rt(t.fields.map(d=>({key:d.id,label:d.kind==="href"?`${d.label} (https link \u2014 required)`:d.label,value:mo(d.id,a)})),"Save draft",async(d,u)=>{var I,S,O,T,ne;let g=!1,p=!1;for(let oe of t.fields){if(oe.kind==="href"){let $=!1;try{$=new URL((I=d[oe.id])!=null?I:"").protocol==="https:"}catch(q){}u(oe.id,$?null:"Links need to start with https://"),$||(g=!0);continue}let E=((S=d[oe.id])!=null?S:"").trim()==="";u(oe.id,E?"Fill this in with your own words":null),E&&(p=!0)}if(g){w("\u26A0 Fix the highlighted link(s).",!1);return}if(p){w("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}w("Saving\u2026");let A=d,{[it]:y}=A,k=zn(A,[Hn(it)]),C=await nr(e,`/v1/editor/arrangements/${encodeURIComponent(t.id)}/instantiate`,{fields:k});if(C.r!=="ok"||!((O=C.data)!=null&&O.blocks)){C.r==="expired"?re(C.outcome,""):w(`\u26A0 ${(ne=(T=C.data)==null?void 0:T.reason)!=null?ne:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let f=me("arrange",o,s),h=await Q(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:st(o,y),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:t.id,displayName:t.name,blocks:C.data.blocks}],baseline:"original"}});h.r==="ok"&&(m("draft_saved",{kind:"arrangement"}),W(),at(f,t.name,t.id)),re(h,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")},me("arrange",o,s))};se.onclick=async()=>{var u,g;if(!n||!j)return;let t=j,o=n;if(W(),w("Loading arrangements\u2026"),!ut){let p=await xt(e,"/v1/editor/arrangements");ut=(u=p==null?void 0:p.arrangements)!=null?u:null}if(!ut||ut.length===0){w("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let s=io(Bn(o)),a=ut.filter(p=>s.includes(p.sectionType));if(a.length===0){w("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}w("Pick a layout for this section \u2014 your own words are carried across.");for(let p of a){let y=l("button",V(B({},P("#374151")),{textAlign:"left"}));y.append(l("div",{fontWeight:"600"},p.name),l("div",{fontSize:"11px",opacity:"0.7"},p.description)),y.onclick=()=>ho(p,t,o),N.append(y)}let d=l("button",V(B({},P("transparent")),{opacity:"0.6"}),"Cancel");d.onclick=W,N.append(d),(g=N.scrollIntoView)==null||g.call(N,{block:"nearest"})};let qe=null,yo=(t,o)=>{qe=t,ye.textContent=o?`Start tracking \u201C${Tt(o)}\u201D now`:"Start tracking now",ye.style.display="block",hn(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.",[St(`/v1/editor/goals/${encodeURIComponent(t)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Cn(t))])};ye.onclick=async()=>{if(!qe)return;ye.disabled=!0,w("Activating\u2026");let t=await Q(e,`/v1/editor/goals/${encodeURIComponent(qe)}/publish`,{});ye.disabled=!1,t.r==="ok"?(m("published",{kind:"goal"}),w("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ye.style.display="none",qe=null,$e.textContent=""):t.r==="expired"?w("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):w(jt(t,"activate"),!1)};let Je=(t,o)=>`${Ze(t)||"goal"}-${to(o)}`.slice(0,128),Mn=t=>{var a,d,u;let o=((a=t.textContent)!=null?a:"").replace(/\s+/g," ").trim();return o&&o.length<=60?o:((u=(d=t.getAttribute("aria-label"))!=null?d:t.getAttribute("id"))!=null?u:"").trim()||"element-clicked"},pt=async(t,o,s)=>{w("Saving\u2026");let a=await Q(e,`/v1/editor/goals/${encodeURIComponent(t)}`,o);return a.r==="ok"&&(m("draft_saved",{kind:"goal"}),yo(t,s)),re(a,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live."),a};ae.onclick=()=>{if(!n||!j)return;let t=Je(Mn(n),JSON.stringify(j));pt(t,{event:"click",locator:j},_e(n))},x.onclick=()=>{var a,d;let t=n==null?void 0:n.closest("form");if(!t)return;let o=De(t,document),s=(d=(a=t.getAttribute("id"))!=null?a:t.getAttribute("name"))!=null?d:"form-submitted";pt(Je(s,JSON.stringify(o)),{event:"form_submit",locator:o},s)},G.onclick=()=>{let t=window.location.pathname||"/",o=Ze(t)?`reached-${Ze(t)}`:"page-visited";pt(Je(o,t),{event:"url_reached",urlPattern:t},t)};let Ut=[{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}];le.onclick=()=>{rt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Ut.map(t=>t.label)}],"Track it",t=>{var a;let o=(a=Ut.find(d=>d.label===t.depth))!=null?a:Ut[2],s=Math.round(o.value*100);pt(`read-${s}pct`,{event:"scroll_depth",threshold:o.value},`read ${s}%`),W()})};let Lt=null,vo=t=>{Lt=t,Ae.style.display="block"};Ae.onclick=async()=>{if(!Lt)return;Ae.disabled=!0,w("Turning on\u2026");let t=await Q(e,`/v1/editor/funnels/${encodeURIComponent(Lt)}/publish`,{});Ae.disabled=!1,t.r==="ok"?(m("published",{kind:"funnel"}),w("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),Ae.style.display="none",Lt=null):t.r==="expired"?w("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):w("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},U.onclick=async()=>{var C;w("Loading your goals\u2026");let t=await xt(e,"/v1/editor/goals"),o=(C=t==null?void 0:t.goals)!=null?C:[];if(o.length<2){w("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}w("Pick the steps in order \u2014 first click = first step."),W();let s=[],a=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),d=l("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});N.append(a,d);let u=l("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");N.append(u);let g=new Map,p=()=>{var f,h;for(let[I,S]of g){let A=s.indexOf(I),O=(h=(f=o.find(T=>T.goal_id===I))==null?void 0:f.display_name)!=null?h:I;S.textContent=A===-1?O:`${A+1}. ${O}`,S.style.background=A===-1?"#374151":"#6366f1"}};for(let f of o){let h=l("button",V(B({},P("#374151")),{textAlign:"left"}));g.set(f.goal_id,h),h.onclick=()=>{s=Zn(s,f.goal_id),p()},N.append(h)}p();let y=l("button",P("#6366f1"),"Save funnel"),k=l("button",V(B({},P("transparent")),{opacity:"0.6"}),"Cancel");k.onclick=W,y.onclick=async()=>{let f=Qn(d.value,s);if(!f.ok){w(`\u26A0 ${f.error}`,!1);return}w("Saving\u2026");let h=await Q(e,`/v1/editor/funnels/${encodeURIComponent(f.funnelId)}`,f.body);h.r==="ok"&&(m("draft_saved",{kind:"funnel"}),W(),vo(f.funnelId)),re(h,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},N.append(y,k)},de.onclick=async()=>{var p,y;let t=Be;if(!t)return;w("Loading funnels\u2026");let o=await xt(e,"/v1/editor/funnels"),s=(p=o==null?void 0:o.funnels)!=null?p:[];if(s.length===0){w("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let a=await xt(e,"/v1/editor/goals"),d=new Map(((y=a==null?void 0:a.goals)!=null?y:[]).map(k=>[k.goal_id,k.display_name]));rt([{key:"funnel",label:"Funnel",type:"select",options:s.map(k=>$t(k))},{key:"step",label:"Which step does this element serve?",type:"select",options:Bt(s[0],d).map(k=>k.label)}],"Attach",async k=>{var I;let C=(I=s.find(S=>$t(S)===k.funnel))!=null?I:s[0],f=Bt(C,d).findIndex(S=>S.label===k.step);if(f<0){w("\u26A0 Pick which step this element serves.",!1);return}w("Attaching\u2026");let h=await Q(e,`/v1/editor/funnels/${encodeURIComponent(C.funnel_id)}/assign`,{slotId:t,stepIndex:f});h.r==="ok"&&W(),re(h,`\u2713 Attached \u2014 this test now works toward \u201C${C.display_name}\u201D.`)});let u=N.querySelector('select[data-field="funnel"]'),g=N.querySelector('select[data-field="step"]');u&&g&&u.addEventListener("change",()=>{var C;let k=(C=s.find(f=>$t(f)===u.value))!=null?C:s[0];g.length=1;for(let f of Bt(k,d)){let h=document.createElement("option");h.value=f.label,h.textContent=f.label,g.append(h)}})},Y.onclick=()=>{if(!n||!j)return;m("form_opened",{kind:"style"});let t=j;rt([{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:on.length?`Font (this site has: ${on.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(g,p)=>{var I;let{style:y,errors:k}=ln(g),C=!1;for(let S of an)p(S,(I=k[S])!=null?I:null),k[S]&&(C=!0);if(C){w("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(y).length===0){w("\u26A0 Enter at least one style change.",!1);return}let f=me("style",t,n);w("Saving\u2026");let h=await Q(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:st(t,g[it]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:y}}]}});h.r==="ok"&&(m("draft_saved",{kind:"slot"}),kn(),W(),at(f,_e(n),"b")),re(h,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},me("style",t,n));let o=n,s=o.style.cssText;Ce=()=>{o.style.cssText=s};let a={},d=()=>{let{style:g}=ln(a);o.style.cssText=s;for(let[p,y]of Object.entries(g)){let k=vt[p];k&&Xe(y)&&o.style.setProperty(k,y.trim(),"important")}};for(let g of an){let p=N.querySelector(`[data-field="${g}"]`);if(!p)continue;let y=()=>{a[g]=p.value,d()};p.addEventListener("input",y),p.addEventListener("change",y)}let u=[He==null?void 0:He.primaryBg,He==null?void 0:He.primaryText,"#ffffff"].filter(g=>!!g).map(rn).filter((g,p,y)=>cn(g)&&y.indexOf(g)===p);for(let g of["color","background"]){let p=N.querySelector(`input[data-field="${g}"]`);if(!p)continue;let y=l("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let k of u){let C=l("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:k,padding:"0"});C.title=k,C.onclick=()=>{p.value=rn(k),p.dispatchEvent(new Event("input"))},y.append(C)}p.after(y)}};let Pe=[],ft=new Map,Ft=!1,te=null,z=null,gt=null,bo=()=>{ft.clear();let t=[],o=(s,a,d)=>{var p;if(t.length>=16||[...ft.values()].some(y=>y.node===s))return;let u=s===n,g=u?"selected":`e${t.length}`;ft.set(g,{node:s,locator:a}),t.push(B(B({ref:g,tag:s.tagName.toLowerCase().slice(0,16),text:((p=s.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,300),isLeaf:s.childElementCount===0,inForm:!!s.closest("form")},u?{selected:!0}:{}),d?{label:d.slice(0,120)}:{}))};n&&j&&Te&&o(n,j);for(let s of sn){let a=ge(s.locator,document);a&&o(a,s.locator,s.label)}return{pagePath:bt(location.pathname),pageTitle:document.title.slice(0,200),elements:t}},Re=(t,o="")=>{let s=t==="user",a=l("div",{margin:"6px 0",padding:"7px 10px",borderRadius:"10px",fontSize:"12px",lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"88%",marginLeft:s?"auto":"0",background:s?"#6366f1":t==="note"?"transparent":"rgba(255,255,255,0.07)",opacity:t==="note"?"0.75":"1"},o);return te==null||te.append(a),te&&(te.scrollTop=te.scrollHeight),a},Wt=()=>{gt&&(gt.textContent=n?Te?`Looking at: ${_e(n)}`:"This element can\u2019t be targeted reliably \u2014 pick a heading, button, or section.":"Nothing selected \u2014 click an element, or ask for a page goal.")},On=(t,o)=>{var d,u;Ct();let s=(d=t.textContent)!=null?d:"",a=t.style.cssText;if(Ce=()=>{t.textContent=s,t.style.cssText=a},!!o){typeof o.text=="string"&&(t.textContent=o.text);for(let[g,p]of Object.entries((u=o.style)!=null?u:{})){let y=vt[g];y&&typeof p=="string"&&Xe(p)&&t.style.setProperty(y,p.trim(),"important")}}},xo=async t=>{var I,S;let o=ft.get(t.ref);if(!o||!o.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";let{node:s,locator:a}=o,d=t.versions.some(A=>typeof A.ops.text=="string"),u=me(d?"text":"style",a,s),g=Qt(location.pathname,zt[u])[0];w("Saving\u2026");let p=await Q(e,`/v1/editor/slots/${encodeURIComponent(u)}`,{kind:"arms",target:st(a,g),draftConfig:{arms:[{id:"a",displayName:"Original",ops:d?{text:((I=s.textContent)!=null?I:"").trim()}:{}},...t.versions]}});if(re(p,"\u2713 Draft saved and previewing \u2014 nothing is live until you publish."),p.r!=="ok")return(S=Z.textContent)!=null?S:"\u26A0 Couldn\u2019t save the draft.";m("draft_saved",{kind:"slot",via:"chat"}),s!==n&&ct(s),W();let y=s;On(y,t.versions[0].ops),ot=u;try{y.scrollIntoView({block:"center",behavior:"smooth"})}catch(A){}at(u,t.label,t.versions[0].id);let k=Re("assistant");k.textContent="",k.append(l("div",{fontWeight:"600",marginBottom:"6px"},`Draft: ${t.label}`));let C=l("div",{display:"flex",gap:"5px",flexWrap:"wrap"}),f=[],h=(A,O)=>{for(let T of f)T.style.background="#374151";A.style.background="#6366f1",On(y,O),ot=u};for(let[A,O]of[["Original",null],...t.versions.map(T=>[T.displayName,T.ops])]){let T=be("#374151",A);T.onclick=()=>h(T,O),f.push(T),C.append(T)}return f[1].style.background="#6366f1",k.append(C),`[Created draft "${t.label}" with ${t.versions.length} version(s)]`},wo=(t,o,s)=>{var g;let a=[],d={position:"absolute",pointerEvents:"none",zIndex:"2147483645",padding:"2px 6px",borderRadius:"4px",background:"#f59e0b",color:"#111827",font:"600 11px system-ui, sans-serif",whiteSpace:"nowrap"},u=null;if(t){let p=t.getBoundingClientRect();u=p.top+window.scrollY,a.push(l("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:`${p.left+window.scrollX-3}px`,top:`${u-3}px`,width:`${p.width+6}px`,height:`${p.height+6}px`,border:"2px dashed #f59e0b",borderRadius:"6px"}),l("div",V(B({},d),{left:`${p.left+window.scrollX}px`,top:`${Math.max(0,u-24)}px`}),`Goal: ${s}`))}else o!==void 0&&(u=Math.round(document.documentElement.scrollHeight*o),a.push(l("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:"0",right:"0",top:`${u}px`,borderTop:"2px dashed #f59e0b"}),l("div",V(B({},d),{left:"16px",top:`${u+4}px`}),`Goal counts here: ${s}`)));if(a.length!==0){if(((g=document.body)!=null?g:document.documentElement).append(...a),u!==null)try{window.scrollTo({top:Math.max(0,u-window.innerHeight/3),behavior:"smooth"})}catch(p){}setTimeout(()=>{for(let p of a)p.remove()},6e3)}},ko=async t=>{var u,g,p,y,k,C;let o=null,s,a;if(t.event==="click"||t.event==="form_submit"){let f=t.ref?ft.get(t.ref):void 0;if(!f||!f.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";if(t.event==="click")o=f.node,s=Je(Mn(o),JSON.stringify(f.locator)),a={event:"click",locator:f.locator};else{let h=f.node.closest("form");if(!h)return"\u26A0 That element isn\u2019t inside a form.";let I=De(h,document);if(!Ve(I,h,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";o=h,s=Je((g=(u=h.getAttribute("id"))!=null?u:h.getAttribute("name"))!=null?g:"form-submitted",JSON.stringify(I)),a={event:"form_submit",locator:I}}}else if(t.event==="url_reached"){let f=(p=t.urlPattern)!=null?p:bt(location.pathname);s=Je(Ze(f)?`reached-${Ze(f)}`:"page-visited",f),a={event:"url_reached",urlPattern:f}}else s=`read-${Math.round(((y=t.threshold)!=null?y:.75)*100)}pct`,a={event:"scroll_depth",threshold:(k=t.threshold)!=null?k:.75};return(await pt(s,V(B({},a),{displayName:t.displayName}),t.displayName)).r!=="ok"?(C=Z.textContent)!=null?C:"\u26A0 Couldn\u2019t save the goal.":(wo(o,t.event==="scroll_depth"?a.threshold:void 0,t.displayName),`[Created draft goal "${t.displayName}"]`)},Pn=async t=>{var y,k,C;let o=t.trim();if(!o||Ft)return;Ft=!0,z&&(z.value="",z.disabled=!0),Re("user",o),Pe.push({role:"user",content:o.slice(0,4e3)}),m("form_opened",{kind:"chat"});let s=Re("assistant","\u2026"),a="",d=!1,u=[],g=[],p=f=>{var I,S;if(f==="[DONE]")return;let h;try{h=JSON.parse(f)}catch(A){return}if(h.error){u.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(h.type==="delta"&&h.text)d&&a&&(a+=`
|
|
24
|
+
`,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function fn(e){var r,s;Mo(),(r=document.getElementById(Gt))==null||r.remove();let t=d("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=Gt;let o=d("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(o,d("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function qr(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Vr(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 o=(await t.json()).projectId;return o?{ok:!0,projectId:o}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function kn(e,t){return j(j(j(j({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 le(e,t,o){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(o)});if(r.ok)return{r:"ok"};let s=await r.json().catch(()=>null);return kn(r.status,s)}catch(r){return{r:"error"}}}async function Jr(e,t){try{let o=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(o.ok)return{r:"ok"};let r=await o.json().catch(()=>null);return kn(o.status,r)}catch(o){return{r:"error"}}}async function Yr(e,t,o){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(o)}),s=await r.json().catch(()=>null);return r.ok?{r:"ok",data:s,outcome:{r:"ok"}}:{r:r.status===401?"expired":"error",data:s,outcome:kn(r.status,s)}}catch(r){return{r:"error",data:null,outcome:{r:"error"}}}}var yn=[];function Sn(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function vn(e){let t=e.trim();if(Sn(t))return t;let o=/^#([0-9a-fA-F]{3})$/.exec(t);if(o)return`#${o[1].split("").map(u=>u+u).join("")}`;let r=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!r)return t;let s=u=>Math.min(255,Number(u)).toString(16).padStart(2,"0");return`#${s(r[1])}${s(r[2])}${s(r[3])}`}var Ve=null,bn=[];function Po(e){bn=e}async function Xr(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let o=await t.json();return yn=Array.isArray(o.fonts)?o.fonts.filter(r=>typeof r=="string"):[],Array.isArray(o.targets)?o.targets:[]}catch(t){return[]}}async function lt(e,t){try{let o=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return o.ok?await o.json():null}catch(o){return null}}function ct(e=document){for(let t of Array.from(e.querySelectorAll(`.${hn}`)))t.remove()}function No(e,t=document){var r;ct(t);let o=0;for(let s of e){if(o>=Gr)break;let u=xe(s.locator,t);if(!u)continue;let m=u.getBoundingClientRect(),k=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});k.className=hn;let p=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${Math.max(0,m.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);p.className=hn,((r=t.body)!=null?r:t.documentElement).append(k,p),o+=1}}function Kt(e,t){let o=e.previousElementSibling,r=e.nextElementSibling,s=o?qe(o,t):null,u=r?qe(r,t):null;return{prevEl:o,nextEl:r,prevLocator:o&&s&&it(s,o,t)?s:null,nextLocator:r&&u&&it(u,r,t)?u:null}}var Zr=/testimonial|review|quote/i;function Ro(e){let t=[],o=e.headings.length>=1,r=e.links.length>=1;return o&&r&&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 xn=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],Qr=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,ei=new Set(["left","center","right","justify","start","end"]),ti=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ni=/^(rgb|rgba|hsl|hsla)\(/i;function oi(e){return ti.test(e)||ni.test(e)}function Do(e,t){switch(e){case"fontSize":case"borderRadius":return Qr.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 ei.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return oi(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let o=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&o.length>=1&&o.length<=5&&o.every(r=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(r))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function wn(e){let t={},o={};for(let r of xn){let s=e[r];if(typeof s!="string")continue;let u=s.trim();if(u==="")continue;if(!at(u)){o[r]="That value isn\u2019t allowed.";continue}let m=Do(r,u);if(m){o[r]=m;continue}t[r]=u}return{style:t,errors:o}}function d(e,t,o){let r=document.createElement(e);return Object.assign(r.style,t),o!==void 0&&(r.textContent=o),r}function Ho(e){var Vn;let t=null,o=[],r=null,s=()=>{for(;o.length>0;){let n=o.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(i){}}},u=(n,i)=>{o.push(j({kind:n},i?{meta:i}:{})),r&&clearTimeout(r),r=setTimeout(s,2e3)};window.addEventListener("pagehide",s);let m=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});m.id=Ur;let k=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});k.id=Kr;let p=()=>{if(!t||!t.isConnected){k.style.display="none";return}let n=t.getBoundingClientRect();Object.assign(k.style,{display:"block",left:`${n.left-2}px`,top:`${n.top-2}px`,width:`${n.width}px`,height:`${n.height}px`})},b=()=>p();Mo();let w=d("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"});w.id=dt;let I=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});I.className="sntedi-dot";let R=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});R.append(I,d("span",{},"SentientUI"));let D=d("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),A=!1,P=d("button",G("#374151"),"Pause selecting");P.onclick=()=>{A=!A,P.textContent=A?"Resume selecting":"Pause selecting",A?(m.style.display="none",ct(document),E("Selection paused \u2014 browse normally, then resume.")):E("Click any element on the page to adapt it.")};let Y=d("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=d("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),W=d("button",G("#6366f1"),"Test different text here"),q=d("button",G("#374151"),"Change style"),Q=d("button",G("#374151"),"Try a different layout for this section"),ne=d("button",G("#374151"),"Track clicks as a goal"),$=d("button",G("#374151"),"Track form submissions as a goal"),H=d("button",G("#374151"),"Track page visits as a goal"),V=d("button",G("#374151"),"Track reading this far as a goal"),S=d("button",G("#374151"),"Set up a funnel"),J=d("button",G("#374151"),"Attach this test to a funnel step"),de=d("button",G("#10b981"),"Turn the funnel on"),U=d("button",G("#374151"),"Move up"),oe=d("button",G("#374151"),"Move down"),we=d("button",G("#6366f1"),"Save this arrangement"),Le=d("button",G("#374151"),"Undo"),Ce=gn("close","Close editor"),X=d("button",G("#10b981"),"Publish now \u2014 go live"),ce=d("button",G("#10b981"),"Start tracking now");for(let n of[W,q,Q,ne,U,oe])n.disabled=!0;let re=[W,q,Q,ne,$,U,oe];for(let n of re)n.style.display="none";we.style.display="none",Le.style.display="none",X.style.display="none",ce.style.display="none",J.style.display="none",de.style.display="none";let pe=d("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),Te=d("div",{}),He=[{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"}],ve="text",En=new Map,_e=new Map,Wt=new Map,Cn=d("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Tn=d("div",{paddingTop:"10px"});for(let n of He){let i=d("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"});i.append(d("span",{fontSize:"11px",marginRight:"3px"},n.icon),d("span",{},n.label)),i.onclick=()=>zo(n.id),En.set(n.id,i),Cn.append(i);let a=d("div",{display:"none"}),l=d("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});a.append(l),Wt.set(n.id,l),_e.set(n.id,a),Tn.append(a)}_e.get("text").append(W),_e.get("style").append(q),_e.get("layout").append(Q,U,oe,we,Le),_e.get("goals").append(ne,$,H,V),_e.get("funnels").append(S,J,de);let be=d("div",{});_e.get("drafts").append(be);let It=()=>{var i,a;for(let l of He){let c=l.id===ve,f=En.get(l.id);f.style.color=c?"#ffffff":"#9ca3af",f.style.borderBottom=c?"2px solid #6366f1":"2px solid transparent",_e.get(l.id).style.display=c?"block":"none",Wt.get(l.id).style.display="none"}let n=l=>{let c=Wt.get(ve);c.textContent=l,c.style.display="block"};ve==="text"?t?W.disabled?n(W.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(i=W.onclick)==null||i.call(W,new MouseEvent("click")):n("Click any text on the page to test a different wording."):ve==="style"?t?q.disabled?n("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(a=q.onclick)==null||a.call(q,new MouseEvent("click")):n("Click any element on the page to change how it looks."):ve==="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."):ve==="goals"?t||n("Page-level goals work right away; click a button or form to track it specifically."):ve==="funnels"?n("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):ve==="drafts"&&Ye()},Ae=(n,i)=>d("button",se(j({},G(n)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),i),An=(n,i)=>{let a=new URL(window.location.href);a.searchParams.delete("sentient_editor"),a.searchParams.set("sentient_preview",n),i&&a.searchParams.set("sentient_arm",i),window.location.assign(a.toString())},Lt=(n,i,a)=>{let l=Ae("#374151","Discard");return l.onclick=async()=>{l.disabled=!0;let c=await Jr(e,n);l.disabled=!1,ye(c,i),c.r==="ok"&&a()},l},In=(n,i)=>{ze.textContent="";let a=d("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=d("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...i),a.append(d("div",{marginBottom:"6px"},n),l),ze.append(a)},Ye=async()=>{var x,C,_,h,v,M,T,N,K,B,ge,me;be.textContent="",be.append(d("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let n=[],i=[],a=null,l=!1;if(await Promise.all([(async()=>{var L;try{let z=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});z.ok?n=(L=(await z.json()).slots)!=null?L:[]:a=z.status===401?"expired":"error"}catch(z){a="error"}})(),(async()=>{var L;try{let z=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});z.ok?i=(L=(await z.json()).goals)!=null?L:[]:l=!0}catch(z){l=!0}})()]),ve!=="drafts")return;if(be.textContent="",a){if(be.append(d("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},a==="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.")),a==="error"){let L=Ae("#374151","Retry");L.onclick=()=>{Ye()},be.append(L)}return}let c=n.filter(L=>{var z,ae,Ie,Pe,We,St;return((Ie=(ae=(z=L.draft_config)==null?void 0:z.arms)==null?void 0:ae.length)!=null?Ie:0)>0||((St=(We=(Pe=L.published_config)==null?void 0:Pe.arms)==null?void 0:We.length)!=null?St:0)>0}),f=i.filter(L=>L.event!=="custom"&&(L.status==="draft"||L.status==="active"));if(c.length===0&&f.length===0&&!l){be.append(d("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 y=L=>d("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:L?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:L?"#6ee7b7":"#c7d2fe"},L?"live":"draft"),g=L=>{let z=d("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),ae=d("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},L);return z.append(ae),{row:z,name:ae}};for(let L of c){let{row:z}=g((x=L.display_name)!=null?x:L.slot_id);z.append(y(L.status==="published"));let ae=(v=(h=(C=L.draft_config)==null?void 0:C.arms)!=null?h:(_=L.published_config)==null?void 0:_.arms)!=null?v:[],Ie=(N=(M=ae[1])==null?void 0:M.id)!=null?N:(T=ae[0])==null?void 0:T.id,Pe=Ae("#374151","Preview");if(Pe.onclick=()=>An(L.slot_id,Ie),z.append(Pe),L.status!=="published"&&((ge=(B=(K=L.draft_config)==null?void 0:K.arms)==null?void 0:B.length)!=null?ge:0)>0){let We=Ae("#10b981","Publish");We.onclick=async()=>{We.disabled=!0;let St=await le(e,`/v1/editor/slots/${encodeURIComponent(L.slot_id)}/publish`,{});We.disabled=!1,ye(St,"\u2713 Published \u2014 live for new visitors."),St.r==="ok"&&(u("published",{kind:"slot"}),Ye())},z.append(We)}L.status!=="published"&&z.append(Lt(`/v1/editor/slots/${encodeURIComponent(L.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{Nn(L.slot_id),Ye()})),be.append(z)}if(l)be.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(f.length>0){be.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let L of f){let{row:z}=g((me=L.display_name)!=null?me:L.goal_id);if(z.append(y(L.status==="active")),L.status==="draft"){let ae=Ae("#10b981","Start tracking");ae.onclick=async()=>{ae.disabled=!0;let Ie=await le(e,`/v1/editor/goals/${encodeURIComponent(L.goal_id)}/publish`,{});ae.disabled=!1,ye(Ie,"\u2713 Tracking is live \u2014 it counts from your next visitor."),Ie.r==="ok"&&(u("published",{kind:"goal"}),Ye())},z.append(ae,Lt(`/v1/editor/goals/${encodeURIComponent(L.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Rn(L.goal_id),Ye()}))}be.append(z)}}},zo=n=>{ve!==n&&(ie(),yt(),ve=n,It())},Ln=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(R.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let _n=!1,$e=d("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"44px",height:"44px",borderRadius:"12px",border:"1px solid #2a2a2a",background:"#000",cursor:"pointer",display:"none",padding:"0",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 18px rgba(0,0,0,0.4)"});$e.append(ii(26)),$e.title="Open the SentientUI editor",$e.setAttribute("aria-label","Open the SentientUI editor");let $n=gn("minimize","Minimize");$n.onclick=()=>{w.style.display="none",$e.style.display="flex",_n=A,A=!0,m.style.display="none",ct(document)},$e.onclick=()=>{w.style.display="block",$e.style.display="none",A=_n},Object.assign(P.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Ln.append(R,P,$n,Ce);let Bn=d("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),ze=d("div",{});Object.assign(Z.style,{marginBottom:"4px"}),Bn.append(ze,Z,X,ce);let On=d("button",{display:"inline-block",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"),qt=d("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(Y.style,{flex:"1 1 auto",marginBottom:"0"}),qt.append(Y,On),Object.assign(qt.style,{marginBottom:"6px"});let _t=d("div",{}),F=d("div",{marginTop:"4px"});F.addEventListener("input",()=>{Xe=!0}),F.addEventListener("change",()=>{Xe=!0}),w.append(Ln,D,qt,pe,Te,_t,Cn,Tn,F,Bn),((Vn=document.body)!=null?Vn:document.documentElement).append(m,k,w,$e);let Be=null,$t=()=>{Be==null||Be(),Be=null},Mn=()=>{Be=null},ut=null,Xe=!1,Vt=null,ie=()=>{$t(),ut=null,F.textContent="",Xe=!1,Vt=null,on=!1},pt=(n,i,a,l)=>{var _;ie();let c={},f={},y={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 h of n){let v=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},h.label);if(F.append(v),h.type==="select"){let T=d("select",y);T.setAttribute("data-field",h.key);let N=document.createElement("option");N.value="",N.textContent="\u2014 no change \u2014",T.append(N);for(let K of(_=h.options)!=null?_:[]){let B=document.createElement("option");B.value=K,B.textContent=K,T.append(B)}c[h.key]=()=>T.value,F.append(T)}else if(h.type==="color"){let T=d("input",se(j({},y),{padding:"2px",height:"34px"}));T.type="color",T.setAttribute("data-field",h.key);let N=!1;T.addEventListener("input",()=>{N=!0}),c[h.key]=()=>N?T.value:"",F.append(T)}else{let T=d("input",y);T.setAttribute("data-field",h.key),h.value!==void 0&&(T.value=h.value),c[h.key]=()=>T.value,F.append(T)}let M=d("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});M.setAttribute("data-feedback",h.key),f[h.key]=M,F.append(M)}let g=(h,v)=>{let M=f[h];M&&(M.textContent=v!=null?v:"",M.style.display=v?"block":"none")};if(l){let h=Pn(l);F.append(h.node),c[ft]=h.value}let x=d("button",G("#6366f1"),i),C=d("button",se(j({},G("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=()=>a(Object.fromEntries(Object.entries(c).map(([h,v])=>[h,v()])),g),C.onclick=ie,F.append(x,C)},ft="__page",Jt={},jo=n=>{var i;for(let a of n!=null?n:[])Jt[a.slot_id]=(i=a.target)==null?void 0:i.page};lt(e,"/v1/editor/slots").then(n=>jo(n==null?void 0:n.slots));let Pn=n=>{let i=At(location.pathname),a=d("div",{}),l=d("select",{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"});l.setAttribute("data-field","page");for(let c of pn(i,Jt[n])){let f=document.createElement("option");f.value=c,f.textContent=Io(c,i),l.append(f)}return a.append(d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),l,d("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:a,value:()=>l.value}},gt=(n,i)=>i?se(j({},n),{page:i}):n,E=(n,i=!0)=>{Z.textContent=n,Z.style.color=i?"#a7f3d0":"#fca5a5"},Yt=(n,i)=>{var l,c;if(u("error_shown",{code:(c=n.code)!=null?c:`http_${(l=n.status)!=null?l:"network"}`}),n.code==="plan_limit_reached"){let f=n.feature==="live_goals"?"live goal":"of these",y=n.plan?`${n.plan} plan`:"plan";return n.feature==="live_goals"?`Your ${y} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${y} has reached its limit for ${f}. Manage them in your dashboard, or upgrade for more.`}if(n.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(n.code==="demo_read_only"&&n.message)return n.message;let a=n.status?` (HTTP ${n.status})`:"";return`\u26A0 Couldn\u2019t ${i} \u2014 try again.${a}`},ye=(n,i)=>{n.r==="ok"?E(i,!0):n.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):E(Yt(n,"save"),!1)},je=null,Bt=n=>n.length>30?`${n.slice(0,27)}\u2026`:n,Nn=n=>{je===n&&(ut===n&&($t(),ut=null),je=null,X.style.display="none",J.style.display="none",ze.textContent="")},Rn=n=>{tt===n&&(tt=null,ce.style.display="none",ze.textContent="")},mt=(n,i,a)=>{je=n,X.textContent=i?`Publish \u201C${Bt(i)}\u201D \u2014 go live`:"Publish now \u2014 go live",X.style.display="block",J.style.display="block";let l=[];if(a){let c=Ae("#374151","Preview");c.onclick=()=>An(n,a),l.push(c)}l.push(Lt(`/v1/editor/slots/${encodeURIComponent(n)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>Nn(n))),In(i?`Draft saved for \u201C${Bt(i)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};X.onclick=async()=>{if(!je)return;X.disabled=!0,E("Publishing\u2026");let n=await le(e,`/v1/editor/slots/${encodeURIComponent(je)}/publish`,{});X.disabled=!1,n.r==="ok"?(u("published",{kind:"slot"}),E("\u2713 Published \u2014 live for new visitors.",!0),X.style.display="none",je=null,ze.textContent=""):n.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):E(Yt(n,"publish"),!1)};let te=null,Oe=!1,Ze=null,Qe=null,ke=null,Ue=null,ht=null,Ot=null,Ke=!1,Dn=(n,i)=>Oe?n?"":`Nothing to swap with ${i} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Hn=()=>{U.disabled=!Oe||!ke,oe.disabled=!Oe||!Ue,U.title=U.disabled?Dn(ke,"above"):"",oe.title=oe.disabled?Dn(Ue,"below"):""},Se=null,Xt=n=>{n&&!Se&&t&&te?(Se=Pn(Ee("move",te,t)),we.before(Se.node)):n||(Se==null||Se.node.remove(),Se=null),we.style.display=n?"block":"none",Le.style.display=n?"block":"none",Hn()},yt=()=>{if(Ke&&t&&ht&&ht.insertBefore(t,Ot),Ke=!1,ht=null,Ot=null,t){let n=Kt(t,document);Ze=n.prevEl,Qe=n.nextEl,ke=n.prevLocator,Ue=n.nextLocator}p(),Xt(!1)},zn=n=>{if(A)return;let i=n.target;if(!i||w.contains(i)||i===m)return;ct(document);let a=i.getBoundingClientRect();Object.assign(m.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},Me=n=>{var a;let i=((a=n.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:n.tagName.toLowerCase()},Uo=n=>!!n.id||["section","header","footer","nav","main","form","article","aside"].includes(n.tagName.toLowerCase())||!!n.querySelector(":scope > h1, :scope > h2, :scope > h3"),Ko=n=>{var l;let i=n.querySelector("h1, h2, h3"),a=(l=i==null?void 0:i.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return a?a.length>28?`${a.slice(0,25)}\u2026`:a:n.id?`#${n.id.length>24?`${n.id.slice(0,21)}\u2026`:n.id}`:`<${n.tagName.toLowerCase()}>`},Go=n=>{pe.textContent="";let i=[];for(let y=n.parentElement;y&&y!==document.body&&i.length<3;y=y.parentElement)Uo(y)&&i.push(y);let a=Me(n),l=()=>d("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),c=!0;for(let y of i){let g=Ko(y);if(g===a||a.startsWith(g))continue;let x=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},g);x.onclick=()=>vt(y),c||pe.append(l()),pe.append(x),c=!1}c||pe.append(l());let f=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");f.onclick=()=>jn(),pe.append(f),pe.style.display="block"},Fo=n=>{Te.textContent="";let i=null,a=0;for(let c=n.parentElement;c&&c!==document.body&&a<6;c=c.parentElement,a++)if(it(qe(c,document),c,document)){i=c;break}let l=d("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(i){let c=i;l.append(d("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 f=d("button",se(j({},G("#6366f1")),{marginTop:"0"}),`Select \u201C${Me(c)}\u201D instead`);f.onclick=()=>vt(c);let y=d("button",se(j({},G("transparent")),{opacity:"0.6"}),"Pick something else");y.onclick=()=>{Te.textContent=""},l.append(f,y)}else l.append(d("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));Te.append(l)},vt=n=>{yt(),ie(),Te.textContent="",t=n,te=qe(n,document);let i=it(te,n,document);Oe=i,p(),Y.style.display="block",Y.textContent=`Selected: ${Me(n)}`,Go(n),u("element_selected",{unique:i}),E(i?"\u2713 Matches exactly 1 element":"",i),i||Fo(n),D.style.display="none",tn();for(let f of re)f.style.display="block";W.style.display="none",q.style.display="none";let a=n.childElementCount===0;W.disabled=!i||!a,W.title=i?a?"":"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=!i,Q.disabled=!i,ne.disabled=!i;let l=n.closest("form");$.style.display=l?"block":"none",$.disabled=!l;let c=Kt(n,document);Ze=c.prevEl,Qe=c.nextEl,ke=c.prevLocator,Ue=c.nextLocator,Hn(),It()},jn=()=>{yt(),ie(),t=null,te=null,Oe=!1,Ze=null,Qe=null,ke=null,Ue=null,p(),Te.textContent="",tn(),pe.textContent="",pe.style.display="none",Y.textContent="",Y.style.display="none";for(let n of re)n.style.display="none";D.style.display="block",E(""),It()},et=!1,Zt=-1,Un=n=>{var l,c;let i=n.target,a=!!((l=i==null?void 0:i.closest)!=null&&l.call(i,'input, textarea, select, [contenteditable="true"]'));if(n.key==="Escape"){if(F.childElementCount>0){ie(),et=!1;return}if(t){jn(),et=!1;return}if(!et){et=!0,E("Press Esc again to close the editor.");return}et=!1,(c=Ce.onclick)==null||c.call(Ce,new MouseEvent("click"));return}if(et=!1,!(a||A)){if(n.key==="ArrowUp"||n.key==="ArrowDown"){if(!t||(n.key==="ArrowUp"?U:oe).disabled)return;n.preventDefault(),nn(n.key==="ArrowUp"?"up":"down");return}if(n.key==="Tab"){let f=[];for(let g of bn){let x=xe(g.locator,document);x&&!f.includes(x)&&f.push(x)}if(f.length===0)return;if(Xe){E("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),n.preventDefault();return}n.preventDefault(),Zt=(Zt+(n.shiftKey?-1:1)+f.length)%f.length;let y=f[Zt];vt(y);try{y.scrollIntoView({block:"center",behavior:"smooth"})}catch(g){}}}},Kn=n=>{if(A)return;let i=n.target;if(!(!i||w.contains(i))){if(n.preventDefault(),n.stopPropagation(),Xe&&i!==t&&Vt!==i){Vt=i,E("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}vt(i)}};W.onclick=()=>{var f,y,g;if(!t||!te)return;u("form_opened",{kind:"text"});let n=te,i=(y=(f=t.textContent)==null?void 0:f.trim())!=null?y:"";pt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async x=>{let C=x.alt.trim();if(!C){E("\u26A0 Enter alternative wording to test.",!1);return}if(C===x.current.trim()){E("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let _=Ee("text",n,t);E("Saving\u2026");let h=await le(e,`/v1/editor/slots/${encodeURIComponent(_)}`,{kind:"arms",target:gt(n,x[ft]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:x.current}},{id:"b",displayName:"Alternative",ops:{text:x.alt}}]}});h.r==="ok"&&(u("draft_saved",{kind:"slot"}),Mn(),ie(),mt(_,Me(t),"b")),ye(h,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Ee("text",n,t));let a=t,l=(g=a.textContent)!=null?g:"";Be=()=>{a.textContent=l};let c=F.querySelector('input[data-field="alt"]');c==null||c.addEventListener("input",()=>{a.textContent=c.value.trim()===""?l:c.value})};let bt=null,Gn=n=>{let i=g=>{var x;return((x=g.textContent)!=null?x:"").replace(/\s+/g," ").trim()},a=Array.from(n.querySelectorAll("h1,h2,h3,h4")).map(i).filter(Boolean);if(a.length===0){let g=n.closest("h1,h2,h3,h4");g&&a.push(i(g))}let l=Array.from(n.querySelectorAll("p")).map(i).filter(g=>g.length>0&&g.length<=300),c=[];for(let g of Array.from(n.querySelectorAll("a[href], button"))){let x=i(g);if(!x||x.length>60)continue;let C="",_=g.getAttribute("href");if(_)try{let h=new URL(_,window.location.href);h.protocol==="https:"&&(C=h.href)}catch(h){}c.push({label:x,href:C})}let f=Array.from(n.querySelectorAll("blockquote, q")).map(i).filter(Boolean);if(f.length===0&&Zr.test(`${n.className} ${n.id}`))for(let g of l)g.length>=20&&f.push(g);let y=Array.from(n.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(i).filter(g=>g.length>0&&g.length<=80);return{headings:a,paragraphs:l,links:c,quotes:f,attributions:y}},Wo=(n,i)=>{var l,c,f,y,g,x,C,_,h,v,M,T,N,K,B,ge,me,L,z,ae;let a=Ie=>{var Pe;return i.paragraphs.length>=3&&(Pe=i.paragraphs[i.paragraphs.length-3+Ie])!=null?Pe:""};switch(n){case"headline":return(l=i.headings[0])!=null?l:"";case"supporting":return(c=i.paragraphs[0])!=null?c:"";case"cta_label":return(y=(f=i.links[0])==null?void 0:f.label)!=null?y:"";case"cta_href":return(x=(g=i.links[0])==null?void 0:g.href)!=null?x:"";case"secondary_label":return(_=(C=i.links[1])==null?void 0:C.label)!=null?_:"";case"secondary_href":return(v=(h=i.links[1])==null?void 0:h.href)!=null?v:"";case"quote":case"q1":return(M=i.quotes[0])!=null?M:"";case"q2":return(T=i.quotes[1])!=null?T:"";case"q3":return(N=i.quotes[2])!=null?N:"";case"name":case"n1":return(K=i.attributions[0])!=null?K:"";case"n2":return(B=i.attributions[1])!=null?B:"";case"n3":return(ge=i.attributions[2])!=null?ge:"";case"role":return(me=i.attributions[1])!=null?me:"";case"eyebrow":return"";case"f1_title":return(L=i.headings[1])!=null?L:"";case"f2_title":return(z=i.headings[2])!=null?z:"";case"f3_title":return(ae=i.headings[3])!=null?ae:"";case"f1_body":return a(0);case"f2_body":return a(1);case"f3_body":return a(2);default:return""}},qo=(n,i,a)=>{u("form_opened",{kind:"arrangement"});let l=Gn(a);pt(n.fields.map(c=>({key:c.id,label:c.kind==="href"?`${c.label} (https link \u2014 required)`:c.label,value:Wo(c.id,l)})),"Save draft",async(c,f)=>{var M,T,K,B,ge;let y=!1,g=!1;for(let me of n.fields){if(me.kind==="href"){let z=!1;try{z=new URL((M=c[me.id])!=null?M:"").protocol==="https:"}catch(ae){}f(me.id,z?null:"Links need to start with https://"),z||(y=!0);continue}let L=((T=c[me.id])!=null?T:"").trim()==="";f(me.id,L?"Fill this in with your own words":null),L&&(g=!0)}if(y){E("\u26A0 Fix the highlighted link(s).",!1);return}if(g){E("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}E("Saving\u2026");let N=c,{[ft]:x}=N,C=Zn(N,[Xn(ft)]),_=await Yr(e,`/v1/editor/arrangements/${encodeURIComponent(n.id)}/instantiate`,{fields:C});if(_.r!=="ok"||!((K=_.data)!=null&&K.blocks)){_.r==="expired"?ye(_.outcome,""):E(`\u26A0 ${(ge=(B=_.data)==null?void 0:B.reason)!=null?ge:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let h=Ee("arrange",i,a),v=await le(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:gt(i,x),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:n.id,displayName:n.name,blocks:_.data.blocks}],baseline:"original"}});v.r==="ok"&&(u("draft_saved",{kind:"arrangement"}),ie(),mt(h,n.name,n.id)),ye(v,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")},Ee("arrange",i,a))};Q.onclick=async()=>{var f,y;if(!t||!te)return;let n=te,i=t;if(ie(),E("Loading arrangements\u2026"),!bt){let g=await lt(e,"/v1/editor/arrangements");bt=(f=g==null?void 0:g.arrangements)!=null?f:null}if(!bt||bt.length===0){E("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let a=Ro(Gn(i)),l=bt.filter(g=>a.includes(g.sectionType));if(l.length===0){E("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}E("Pick a layout for this section \u2014 your own words are carried across.");for(let g of l){let x=d("button",se(j({},G("#374151")),{textAlign:"left"}));x.append(d("div",{fontWeight:"600"},g.name),d("div",{fontSize:"11px",opacity:"0.7"},g.description)),x.onclick=()=>qo(g,n,i),F.append(x)}let c=d("button",se(j({},G("transparent")),{opacity:"0.6"}),"Cancel");c.onclick=ie,F.append(c),(y=F.scrollIntoView)==null||y.call(F,{block:"nearest"})};let tt=null,Vo=(n,i)=>{tt=n,ce.textContent=i?`Start tracking \u201C${Bt(i)}\u201D now`:"Start tracking now",ce.style.display="block",In(i?`Goal \u201C${Bt(i)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[Lt(`/v1/editor/goals/${encodeURIComponent(n)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Rn(n))])};ce.onclick=async()=>{if(!tt)return;ce.disabled=!0,E("Activating\u2026");let n=await le(e,`/v1/editor/goals/${encodeURIComponent(tt)}/publish`,{});ce.disabled=!1,n.r==="ok"?(u("published",{kind:"goal"}),E("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ce.style.display="none",tt=null,ze.textContent=""):n.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):E(Yt(n,"activate"),!1)};let nt=(n,i)=>`${st(n)||"goal"}-${Oo(i)}`.slice(0,128),Fn=n=>{var l,c,f;let i=((l=n.textContent)!=null?l:"").replace(/\s+/g," ").trim();return i&&i.length<=60?i:((f=(c=n.getAttribute("aria-label"))!=null?c:n.getAttribute("id"))!=null?f:"").trim()||"element-clicked"},xt=async(n,i,a)=>{E("Saving\u2026");let l=await le(e,`/v1/editor/goals/${encodeURIComponent(n)}`,i);return l.r==="ok"&&(u("draft_saved",{kind:"goal"}),Vo(n,a)),ye(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live."),l};ne.onclick=()=>{if(!t||!te)return;let n=nt(Fn(t),JSON.stringify(te));xt(n,{event:"click",locator:te},Me(t))},$.onclick=()=>{var l,c;let n=t==null?void 0:t.closest("form");if(!n)return;let i=qe(n,document),a=(c=(l=n.getAttribute("id"))!=null?l:n.getAttribute("name"))!=null?c:"form-submitted";xt(nt(a,JSON.stringify(i)),{event:"form_submit",locator:i},a)},H.onclick=()=>{let n=window.location.pathname||"/",i=st(n)?`reached-${st(n)}`:"page-visited";xt(nt(i,n),{event:"url_reached",urlPattern:n},n)};let Qt=[{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}];V.onclick=()=>{pt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Qt.map(n=>n.label)}],"Track it",n=>{var l;let i=(l=Qt.find(c=>c.label===n.depth))!=null?l:Qt[2],a=Math.round(i.value*100);xt(`read-${a}pct`,{event:"scroll_depth",threshold:i.value},`read ${a}%`),ie()})};let Mt=null,Jo=n=>{Mt=n,de.style.display="block"};de.onclick=async()=>{if(!Mt)return;de.disabled=!0,E("Turning on\u2026");let n=await le(e,`/v1/editor/funnels/${encodeURIComponent(Mt)}/publish`,{});de.disabled=!1,n.r==="ok"?(u("published",{kind:"funnel"}),E("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),de.style.display="none",Mt=null):n.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):E("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},S.onclick=async()=>{var _;E("Loading your goals\u2026");let n=await lt(e,"/v1/editor/goals"),i=(_=n==null?void 0:n.goals)!=null?_:[];if(i.length<2){E("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}E("Pick the steps in order \u2014 first click = first step."),ie();let a=[],l=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),c=d("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"});F.append(l,c);let f=d("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");F.append(f);let y=new Map,g=()=>{var h,v;for(let[M,T]of y){let N=a.indexOf(M),K=(v=(h=i.find(B=>B.goal_id===M))==null?void 0:h.display_name)!=null?v:M;T.textContent=N===-1?K:`${N+1}. ${K}`,T.style.background=N===-1?"#374151":"#6366f1"}};for(let h of i){let v=d("button",se(j({},G("#374151")),{textAlign:"left"}));y.set(h.goal_id,v),v.onclick=()=>{a=Lo(a,h.goal_id),g()},F.append(v)}g();let x=d("button",G("#6366f1"),"Save funnel"),C=d("button",se(j({},G("transparent")),{opacity:"0.6"}),"Cancel");C.onclick=ie,x.onclick=async()=>{let h=_o(c.value,a);if(!h.ok){E(`\u26A0 ${h.error}`,!1);return}E("Saving\u2026");let v=await le(e,`/v1/editor/funnels/${encodeURIComponent(h.funnelId)}`,h.body);v.r==="ok"&&(u("draft_saved",{kind:"funnel"}),ie(),Jo(h.funnelId)),ye(v,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},F.append(x,C)},J.onclick=async()=>{var g,x;let n=je;if(!n)return;E("Loading funnels\u2026");let i=await lt(e,"/v1/editor/funnels"),a=(g=i==null?void 0:i.funnels)!=null?g:[];if(a.length===0){E("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await lt(e,"/v1/editor/goals"),c=new Map(((x=l==null?void 0:l.goals)!=null?x:[]).map(C=>[C.goal_id,C.display_name]));pt([{key:"funnel",label:"Funnel",type:"select",options:a.map(C=>jt(C))},{key:"step",label:"Which step does this element serve?",type:"select",options:Ut(a[0],c).map(C=>C.label)}],"Attach",async C=>{var M;let _=(M=a.find(T=>jt(T)===C.funnel))!=null?M:a[0],h=Ut(_,c).findIndex(T=>T.label===C.step);if(h<0){E("\u26A0 Pick which step this element serves.",!1);return}E("Attaching\u2026");let v=await le(e,`/v1/editor/funnels/${encodeURIComponent(_.funnel_id)}/assign`,{slotId:n,stepIndex:h});v.r==="ok"&&ie(),ye(v,`\u2713 Attached \u2014 this test now works toward \u201C${_.display_name}\u201D.`)});let f=F.querySelector('select[data-field="funnel"]'),y=F.querySelector('select[data-field="step"]');f&&y&&f.addEventListener("change",()=>{var _;let C=(_=a.find(h=>jt(h)===f.value))!=null?_:a[0];y.length=1;for(let h of Ut(C,c)){let v=document.createElement("option");v.value=h.label,v.textContent=h.label,y.append(v)}})},q.onclick=()=>{if(!t||!te)return;u("form_opened",{kind:"style"});let n=te;pt([{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:yn.length?`Font (this site has: ${yn.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(y,g)=>{var M;let{style:x,errors:C}=wn(y),_=!1;for(let T of xn)g(T,(M=C[T])!=null?M:null),C[T]&&(_=!0);if(_){E("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(x).length===0){E("\u26A0 Enter at least one style change.",!1);return}let h=Ee("style",n,t);E("Saving\u2026");let v=await le(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:gt(n,y[ft]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:x}}]}});v.r==="ok"&&(u("draft_saved",{kind:"slot"}),Mn(),ie(),mt(h,Me(t),"b")),ye(v,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Ee("style",n,t));let i=t,a=i.style.cssText;Be=()=>{i.style.cssText=a};let l={},c=()=>{let{style:y}=wn(l);i.style.cssText=a;for(let[g,x]of Object.entries(y)){let C=Tt[g];C&&at(x)&&i.style.setProperty(C,x.trim(),"important")}};for(let y of xn){let g=F.querySelector(`[data-field="${y}"]`);if(!g)continue;let x=()=>{l[y]=g.value,c()};g.addEventListener("input",x),g.addEventListener("change",x)}let f=[Ve==null?void 0:Ve.primaryBg,Ve==null?void 0:Ve.primaryText,"#ffffff"].filter(y=>!!y).map(vn).filter((y,g,x)=>Sn(y)&&x.indexOf(y)===g);for(let y of["color","background"]){let g=F.querySelector(`input[data-field="${y}"]`);if(!g)continue;let x=d("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let C of f){let _=d("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:C,padding:"0"});_.title=C,_.onclick=()=>{g.value=vn(C),g.dispatchEvent(new Event("input"))},x.append(_)}g.after(x)}};let Ge=[],wt=new Map,en=!1,fe=null,ee=null,kt=null,Yo=()=>{wt.clear();let n=[],i=(a,l,c)=>{var g;if(n.length>=16||[...wt.values()].some(x=>x.node===a))return;let f=a===t,y=f?"selected":`e${n.length}`;wt.set(y,{node:a,locator:l}),n.push(j(j({ref:y,tag:a.tagName.toLowerCase().slice(0,16),text:((g=a.textContent)!=null?g:"").replace(/\s+/g," ").trim().slice(0,300),isLeaf:a.childElementCount===0,inForm:!!a.closest("form")},f?{selected:!0}:{}),c?{label:c.slice(0,120)}:{}))};t&&te&&Oe&&i(t,te);for(let a of bn){let l=xe(a.locator,document);l&&i(l,a.locator,a.label)}return{pagePath:At(location.pathname),pageTitle:document.title.slice(0,200),elements:n}},Fe=(n,i="")=>{let a=n==="user",l=d("div",{margin:"6px 0",padding:"7px 10px",borderRadius:"10px",fontSize:"12px",lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"88%",marginLeft:a?"auto":"0",background:a?"#6366f1":n==="note"?"transparent":"rgba(255,255,255,0.07)",opacity:n==="note"?"0.75":"1"},i);return fe==null||fe.append(l),fe&&(fe.scrollTop=fe.scrollHeight),l},tn=()=>{kt&&(kt.textContent=t?Oe?`Looking at: ${Me(t)}`:"This element can\u2019t be targeted reliably \u2014 pick a heading, button, or section.":"Nothing selected \u2014 click an element, or ask for a page goal.")},Wn=(n,i)=>{var c,f;$t();let a=(c=n.textContent)!=null?c:"",l=n.style.cssText;if(Be=()=>{n.textContent=a,n.style.cssText=l},!!i){typeof i.text=="string"&&(n.textContent=i.text);for(let[y,g]of Object.entries((f=i.style)!=null?f:{})){let x=Tt[y];x&&typeof g=="string"&&at(g)&&n.style.setProperty(x,g.trim(),"important")}}},Xo=async n=>{var M,T;let i=wt.get(n.ref);if(!i||!i.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";let{node:a,locator:l}=i,c=n.versions.some(N=>typeof N.ops.text=="string"),f=Ee(c?"text":"style",l,a),y=pn(location.pathname,Jt[f])[0];E("Saving\u2026");let g=await le(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:gt(l,y),draftConfig:{arms:[{id:"a",displayName:"Original",ops:c?{text:((M=a.textContent)!=null?M:"").trim()}:{}},...n.versions]}});if(ye(g,"\u2713 Draft saved and previewing \u2014 nothing is live until you publish."),g.r!=="ok")return(T=Z.textContent)!=null?T:"\u26A0 Couldn\u2019t save the draft.";u("draft_saved",{kind:"slot",via:"chat"}),a!==t&&vt(a),ie();let x=a;Wn(x,n.versions[0].ops),ut=f;try{x.scrollIntoView({block:"center",behavior:"smooth"})}catch(N){}mt(f,n.label,n.versions[0].id);let C=Fe("assistant");C.textContent="",C.append(d("div",{fontWeight:"600",marginBottom:"6px"},`Draft: ${n.label}`));let _=d("div",{display:"flex",gap:"5px",flexWrap:"wrap"}),h=[],v=(N,K)=>{for(let B of h)B.style.background="#374151";N.style.background="#6366f1",Wn(x,K),ut=f};for(let[N,K]of[["Original",null],...n.versions.map(B=>[B.displayName,B.ops])]){let B=Ae("#374151",N);B.onclick=()=>v(B,K),h.push(B),_.append(B)}return h[1].style.background="#6366f1",C.append(_),`[Created draft "${n.label}" with ${n.versions.length} version(s)]`},Zo=(n,i,a)=>{var y;let l=[],c={position:"absolute",pointerEvents:"none",zIndex:"2147483645",padding:"2px 6px",borderRadius:"4px",background:"#f59e0b",color:"#111827",font:"600 11px system-ui, sans-serif",whiteSpace:"nowrap"},f=null;if(n){let g=n.getBoundingClientRect();f=g.top+window.scrollY,l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:`${g.left+window.scrollX-3}px`,top:`${f-3}px`,width:`${g.width+6}px`,height:`${g.height+6}px`,border:"2px dashed #f59e0b",borderRadius:"6px"}),d("div",se(j({},c),{left:`${g.left+window.scrollX}px`,top:`${Math.max(0,f-24)}px`}),`Goal: ${a}`))}else i!==void 0&&(f=Math.round(document.documentElement.scrollHeight*i),l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:"0",right:"0",top:`${f}px`,borderTop:"2px dashed #f59e0b"}),d("div",se(j({},c),{left:"16px",top:`${f+4}px`}),`Goal counts here: ${a}`)));if(l.length!==0){if(((y=document.body)!=null?y:document.documentElement).append(...l),f!==null)try{window.scrollTo({top:Math.max(0,f-window.innerHeight/3),behavior:"smooth"})}catch(g){}setTimeout(()=>{for(let g of l)g.remove()},6e3)}},Qo=async n=>{var f,y,g,x,C,_;let i=null,a,l;if(n.event==="click"||n.event==="form_submit"){let h=n.ref?wt.get(n.ref):void 0;if(!h||!h.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";if(n.event==="click")i=h.node,a=nt(Fn(i),JSON.stringify(h.locator)),l={event:"click",locator:h.locator};else{let v=h.node.closest("form");if(!v)return"\u26A0 That element isn\u2019t inside a form.";let M=qe(v,document);if(!it(M,v,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";i=v,a=nt((y=(f=v.getAttribute("id"))!=null?f:v.getAttribute("name"))!=null?y:"form-submitted",JSON.stringify(M)),l={event:"form_submit",locator:M}}}else if(n.event==="url_reached"){let h=(g=n.urlPattern)!=null?g:At(location.pathname);a=nt(st(h)?`reached-${st(h)}`:"page-visited",h),l={event:"url_reached",urlPattern:h}}else a=`read-${Math.round(((x=n.threshold)!=null?x:.75)*100)}pct`,l={event:"scroll_depth",threshold:(C=n.threshold)!=null?C:.75};return(await xt(a,se(j({},l),{displayName:n.displayName}),n.displayName)).r!=="ok"?(_=Z.textContent)!=null?_:"\u26A0 Couldn\u2019t save the goal.":(Zo(i,n.event==="scroll_depth"?l.threshold:void 0,n.displayName),`[Created draft goal "${n.displayName}"]`)},qn=async n=>{var x,C,_;let i=n.trim();if(!i||en)return;en=!0,ee&&(ee.value="",ee.disabled=!0),Fe("user",i),Ge.push({role:"user",content:i.slice(0,4e3)}),u("form_opened",{kind:"chat"});let a=Fe("assistant","\u2026"),l="",c=!1,f=[],y=[],g=h=>{var M,T;if(h==="[DONE]")return;let v;try{v=JSON.parse(h)}catch(N){return}if(v.error){f.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(v.type==="delta"&&v.text)c&&l&&(l+=`
|
|
25
25
|
|
|
26
|
-
`),
|
|
26
|
+
`),c=!1,l+=v.text,a.textContent=l,fe&&(fe.scrollTop=fe.scrollHeight);else if(v.type==="tool_status")c=!0,v.state==="running"&&!l&&(a.textContent=(M=v.name)!=null&&M.startsWith("create_")?"Creating a draft\u2026":"Thinking\u2026");else if(v.type==="choice_prompt"&&v.question){l+=(l?`
|
|
27
27
|
|
|
28
|
-
`:"")+
|
|
28
|
+
`:"")+v.question,a.textContent=l;let N=d("div",{display:"flex",gap:"5px",flexWrap:"wrap",marginTop:"6px"});for(let K of(T=v.options)!=null?T:[]){let B=Ae("#374151",K.label);B.onclick=()=>{qn(K.label)},N.append(B)}a.append(N)}else if(v.type==="artifact"&&v.artifact){let N=v.artifact.type==="editor_component_draft"?Xo(v.artifact.payload):v.artifact.type==="editor_goal_draft"?Qo(v.artifact.payload):null;N&&y.push(N.then(K=>{f.push(K),K.startsWith("\u26A0")&&Fe("note",K)}))}};try{let h=Ge.slice(-20);for(;((x=h[0])==null?void 0:x.role)==="assistant";)h=h.slice(1);let v=await fetch(`${e.apiBase}/v1/editor/chat`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({messages:h,context:Yo()})});if(!v.ok){let B=(C=await v.json().catch(()=>null))==null?void 0:C.error;a.textContent=v.status===401?"Editor session expired \u2014 reopen it from your dashboard. Your drafts are safe.":B==="rate_limit"?"You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.":B==="plan_required"?"AI chat isn\u2019t included in this plan.":B==="ai_unavailable"?"The assistant is unavailable right now \u2014 try again later.":`\u26A0 Couldn\u2019t reach the assistant \u2014 try again. (HTTP ${v.status})`,Ge.pop();return}let M=(_=v.body)==null?void 0:_.getReader(),T="",N=()=>{let B;for(;(B=T.indexOf(`
|
|
29
29
|
|
|
30
|
-
`))>=0;){for(let
|
|
31
|
-
`))
|
|
30
|
+
`))>=0;){for(let ge of T.slice(0,B).split(`
|
|
31
|
+
`))ge.startsWith("data: ")&&g(ge.slice(6));T=T.slice(B+2)}};if(M){let B=new TextDecoder;for(;;){let{done:ge,value:me}=await M.read();if(ge)break;T+=B.decode(me,{stream:!0}),N()}}else T=await v.text();T+=`
|
|
32
32
|
|
|
33
|
-
`,
|
|
34
|
-
`);Pe.push({role:"assistant",content:(O||"(no reply)").slice(0,4e3)})}catch(f){s.textContent="\u26A0 Couldn\u2019t reach the assistant \u2014 check your connection and try again.",Pe.pop()}finally{Ft=!1,z&&(z.disabled=!1,z.focus())}},So=()=>{if(te){z==null||z.focus();return}let t=l("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.06)",border:"1px solid rgba(250,204,21,0.3)"});t.setAttribute("data-sentient-chat","");let o=l("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"}),s=en("close","Close AI chat");if(s.onclick=()=>{Et.textContent="",te=null,z=null,gt=null},o.append(l("div",{fontWeight:"600",flex:"1 1 auto"},"\u2728 AI"),s),gt=l("div",{fontSize:"11px",opacity:"0.7",marginBottom:"4px"}),Wt(),te=l("div",{maxHeight:"260px",overflowY:"auto",overscrollBehavior:"contain"}),Pe.length===0)Re("note","Tell me what to try \u2014 e.g. \u201Cmake this headline more urgent\u201D or \u201Ctrack clicks on the signup button\u201D. I\u2019ll create a draft and show it on the page. Nothing goes live until you publish.");else for(let u of Pe)Re(u.role,u.content);let a=l("div",{display:"flex",gap:"6px",marginTop:"6px"});z=l("input",{flex:"1 1 auto",minWidth:"0",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"}),z.type="text",z.maxLength=1e3,z.placeholder="What do you want to change or track?",z.setAttribute("data-field","ai-chat");let d=be("#6366f1","Send");d.setAttribute("data-action","ai-send"),d.onclick=()=>{z&&Pn(z.value)},z.onkeydown=u=>{var g;u.key==="Enter"&&(u.preventDefault(),(g=d.onclick)==null||g.call(d,new MouseEvent("click")))},a.append(z,d),t.append(o,gt,te,a),Et.textContent="",Et.append(t),z.focus()};wn.onclick=()=>So();let qt=t=>{if(!n)return;let o=n.parentElement;if(!o)return;Oe||(lt=o,_t=n.nextSibling,Oe=!0),t==="up"&&Ue?o.insertBefore(n,Ue):t==="down"&&Fe&&o.insertBefore(n,Fe.nextSibling);let s=Mt(n,document);Ue=s.prevEl,Fe=s.nextEl,pe=s.prevLocator,Me=s.nextLocator;try{n.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(a){}v(),Kt(!0),w("Previewing the new position \u2014 keep moving, save, or undo.")};we.onclick=()=>qt("up"),ke.onclick=()=>qt("down"),wt.onclick=()=>{dt(),w("Move undone \u2014 back to the original position.")},tt.onclick=async()=>{if(!n||!j||!Oe||!Te)return;let t=pe?"moveAfter":"moveBefore",o=pe!=null?pe:Me;if(!o){w("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=me("move",j,n);w("Saving\u2026");let a=await Q(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:st(j,fe==null?void 0:fe.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[t]:o}}]}});a.r==="ok"&&(m("draft_saved",{kind:"move"}),Oe=!1,lt=null,_t=null,Kt(!1),at(s,_e(n),"b")),re(a,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let Eo=()=>{var t,o;m("editor_closed"),c(),window.removeEventListener("pagehide",c),i&&clearTimeout(i),dt(),Ct(),document.removeEventListener("mousemove",Ln,!0),document.removeEventListener("click",$n,!0),document.removeEventListener("keydown",An,!0),window.removeEventListener("scroll",M,!0),window.removeEventListener("resize",M),et(document),(t=document.getElementById(tn))==null||t.remove(),b.remove(),L.remove(),H.remove(),Ee.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),yt()},Jt=!1;nt.onclick=()=>{if((Ge||Oe)&&!Jt){Jt=!0,w("\u26A0 Unsaved changes \u2014 click \xD7 again to discard them.",!1);return}Eo()},document.addEventListener("mousemove",Ln,!0),document.addEventListener("click",$n,!0),document.addEventListener("keydown",An,!0),window.addEventListener("scroll",M,!0),window.addEventListener("resize",M),kt(),m("editor_opened")}var cr="http://www.w3.org/2000/svg";function ze(e,n){let r=document.createElementNS(cr,e);for(let[i,c]of Object.entries(n))r.setAttribute(i,c);return r}function ur(e){let n=ze("svg",{width:String(e),height:String(e),viewBox:"0 0 32 32",fill:"none","aria-hidden":"true"}),r={stroke:"#fff","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"};return n.append(ze("path",B({d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6"},r)),ze("path",B({d:"M10 22H17"},r)),ze("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})),n}function en(e,n){let r=l("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",width:"24px",height:"24px",margin:"0",padding:"0",borderRadius:"6px",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer"});r.setAttribute("aria-label",n),r.title=n;let i=ze("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"}),c={stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"};return e==="minimize"?i.append(ze("path",B({d:"M3 7h8"},c))):i.append(ze("path",B({d:"M3.5 3.5l7 7M10.5 3.5l-7 7"},c))),r.append(i),r.onmouseenter=()=>{r.style.background="rgba(255,255,255,0.1)",r.style.color="#fff"},r.onmouseleave=()=>{r.style.background="transparent",r.style.color="#9ca3af"},r}function P(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 Pt="sentient-preview-bar";async function pr(e,n){var H,ee,F,R,D,J,X,Z,K,Y,se,ae;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(x){}let r=null;try{let x=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});x.ok&&(r=(ee=((H=(await x.json()).slots)!=null?H:[]).find(le=>le.slot_id===n&&le.kind==="arms"))!=null?ee:null)}catch(x){}let i=l("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});i.id=Pt;let c=l("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");c.onclick=()=>{yt();let x=new URL(location.href);for(let G of["sentient_editor","sentient_preview","sentient_arm"])x.searchParams.delete(G);location.assign(x.toString())};let m=l("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");m.onclick=()=>{let x=new URL(location.href);for(let G of["sentient_preview","sentient_arm"])x.searchParams.delete(G);location.assign(x.toString())};let b=(J=(D=(F=r==null?void 0:r.draft_config)==null?void 0:F.arms)!=null?D:(R=r==null?void 0:r.published_config)==null?void 0:R.arms)!=null?J:[];if(!r||b.length===0){i.append(l("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),m,c),((X=document.body)!=null?X:document.documentElement).append(i);return}let L=new URLSearchParams(location.search).get("sentient_arm"),v=(K=(Z=b.find(x=>x.id===L))!=null?Z:b[1])!=null?K:b[0];i.append(l("span",{fontWeight:"700"},`Previewing: ${(Y=r.display_name)!=null?Y:r.slot_id}`));let M=r.target&&typeof r.target=="object"?ge(r.target,document):null;if(!M)i.append(l("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{Vn(M,v.ops,`preview-${r.slot_id}`,document);try{M.scrollIntoView({block:"center"})}catch(x){}for(let x of b){let G=l("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:x.id===v.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(se=x.displayName)!=null?se:x.id);G.onclick=()=>{let le=new URL(location.href);le.searchParams.set("sentient_arm",x.id),location.assign(le.toString())},i.append(G)}}i.append(m,c),((ae=document.body)!=null?ae:document.documentElement).append(i)}async function fr(e,n){var H,ee,F;let r=n.lastIndexOf("~"),i=r>0?n.slice(0,r):n,c=r>0?n.slice(r+1):"",m=l("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});m.id=Pt;let b=l("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Exit preview");b.onclick=()=>{yt();let R=new URL(location.href);for(let D of["sentient_editor","sentient_preview_cell"])R.searchParams.delete(D);location.assign(R.toString())};let L=R=>{var D;m.append(l("span",{},R),b),((D=document.body)!=null?D:document.documentElement).append(m)},v=null;try{let R=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${e.token}`}});R.ok&&(v=await R.json())}catch(R){}if(!v)return L("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let M=v.target&&typeof v.target=="object"?ge(v.target,document):null;if(!M)return L("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(v.blocks!=null)Fn(M,{preview:v.blocks},"preview",document);else if(typeof v.content=="string")M.textContent=v.content;else return L("Nothing to preview in that square yet.");try{M.scrollIntoView({block:"center"})}catch(R){}m.append(l("span",{fontWeight:"700"},`Previewing: ${(H=v.slotName)!=null?H:i}`),l("span",{opacity:"0.85"},`for ${(ee=v.personaDisplay)!=null?ee:c}${v.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),b),((F=document.body)!=null?F:document.documentElement).append(m)}async function gr(){if(typeof document=="undefined")return;let e=Qo();if(!e)return;let n=await er(e);if(!n.ok){n.unauthorized?(yt(),eo(Xo)):eo(Zo);return}let r=new URLSearchParams(location.search).get("sentient_preview");if(r){document.getElementById(Pt)||await pr(e,r);return}let i=new URLSearchParams(location.search).get("sentient_preview_cell");if(i){document.getElementById(Pt)||await fr(e,i);return}if(document.getElementById(Qe))return;ao(e);let c=qn(document);He=c,c&&Q(e,"/v1/editor/palette",c);let m=await or(e);oo(m),ro(m,document)}gr();return $o(mr);})();
|
|
33
|
+
`,N(),await Promise.all(y),l||(a.textContent=f.some(B=>B.startsWith("["))?"Done \u2014 have a look at the page.":"No reply \u2014 try rephrasing.");for(let B of f)B.startsWith("\u26A0 The assistant")&&Fe("note",B);let K=[l,...f.filter(B=>B.startsWith("["))].filter(Boolean).join(`
|
|
34
|
+
`);Ge.push({role:"assistant",content:(K||"(no reply)").slice(0,4e3)})}catch(h){a.textContent="\u26A0 Couldn\u2019t reach the assistant \u2014 check your connection and try again.",Ge.pop()}finally{en=!1,ee&&(ee.disabled=!1,ee.focus())}},er=()=>{if(fe){ee==null||ee.focus();return}let n=d("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.06)",border:"1px solid rgba(250,204,21,0.3)"});n.setAttribute("data-sentient-chat","");let i=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"}),a=gn("close","Close AI chat");if(a.onclick=()=>{_t.textContent="",fe=null,ee=null,kt=null},i.append(d("div",{fontWeight:"600",flex:"1 1 auto"},"\u2728 AI"),a),kt=d("div",{fontSize:"11px",opacity:"0.7",marginBottom:"4px"}),tn(),fe=d("div",{maxHeight:"260px",overflowY:"auto",overscrollBehavior:"contain"}),Ge.length===0)Fe("note","Tell me what to try \u2014 e.g. \u201Cmake this headline more urgent\u201D or \u201Ctrack clicks on the signup button\u201D. I\u2019ll create a draft and show it on the page. Nothing goes live until you publish.");else for(let f of Ge)Fe(f.role,f.content);let l=d("div",{display:"flex",gap:"6px",marginTop:"6px"});ee=d("input",{flex:"1 1 auto",minWidth:"0",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"}),ee.type="text",ee.maxLength=1e3,ee.placeholder="What do you want to change or track?",ee.setAttribute("data-field","ai-chat");let c=Ae("#6366f1","Send");c.setAttribute("data-action","ai-send"),c.onclick=()=>{ee&&qn(ee.value)},ee.onkeydown=f=>{var y;f.key==="Enter"&&(f.preventDefault(),(y=c.onclick)==null||y.call(c,new MouseEvent("click")))},l.append(ee,c),n.append(i,kt,fe,l),_t.textContent="",_t.append(n),ee.focus()};On.onclick=()=>er();let nn=n=>{if(!t)return;let i=t.parentElement;if(!i)return;Ke||(ht=i,Ot=t.nextSibling,Ke=!0),n==="up"&&Ze?i.insertBefore(t,Ze):n==="down"&&Qe&&i.insertBefore(t,Qe.nextSibling);let a=Kt(t,document);Ze=a.prevEl,Qe=a.nextEl,ke=a.prevLocator,Ue=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}p(),Xt(!0),E("Previewing the new position \u2014 keep moving, save, or undo.")};U.onclick=()=>nn("up"),oe.onclick=()=>nn("down"),Le.onclick=()=>{yt(),E("Move undone \u2014 back to the original position.")},we.onclick=async()=>{if(!t||!te||!Ke||!Oe)return;let n=ke?"moveAfter":"moveBefore",i=ke!=null?ke:Ue;if(!i){E("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=Ee("move",te,t);E("Saving\u2026");let l=await le(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:gt(te,Se==null?void 0:Se.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[n]:i}}]}});l.r==="ok"&&(u("draft_saved",{kind:"move"}),Ke=!1,ht=null,Ot=null,Xt(!1),mt(a,Me(t),"b")),ye(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let tr=()=>{var n,i;u("editor_closed"),s(),window.removeEventListener("pagehide",s),r&&clearTimeout(r),yt(),$t(),document.removeEventListener("mousemove",zn,!0),document.removeEventListener("click",Kn,!0),document.removeEventListener("keydown",Un,!0),window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",b),ct(document),(n=document.getElementById(mn))==null||n.remove(),m.remove(),k.remove(),w.remove(),$e.remove(),window.__sentientEditor=null,(i=document.querySelector("meta[data-sentient-editor]"))==null||i.remove(),Ct()},on=!1;Ce.onclick=()=>{if((Xe||Ke)&&!on){on=!0,E("\u26A0 Unsaved changes \u2014 click \xD7 again to discard them.",!1);return}tr()},document.addEventListener("mousemove",zn,!0),document.addEventListener("click",Kn,!0),document.addEventListener("keydown",Un,!0),window.addEventListener("scroll",b,!0),window.addEventListener("resize",b),It(),u("editor_opened")}var ri="http://www.w3.org/2000/svg";function Je(e,t){let o=document.createElementNS(ri,e);for(let[r,s]of Object.entries(t))o.setAttribute(r,s);return o}function ii(e){let t=Je("svg",{width:String(e),height:String(e),viewBox:"0 0 32 32",fill:"none","aria-hidden":"true"}),o={stroke:"#fff","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"};return t.append(Je("path",j({d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6"},o)),Je("path",j({d:"M10 22H17"},o)),Je("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})),t}function gn(e,t){let o=d("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",width:"24px",height:"24px",margin:"0",padding:"0",borderRadius:"6px",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer"});o.setAttribute("aria-label",t),o.title=t;let r=Je("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"}),s={stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"};return e==="minimize"?r.append(Je("path",j({d:"M3 7h8"},s))):r.append(Je("path",j({d:"M3.5 3.5l7 7M10.5 3.5l-7 7"},s))),o.append(r),o.onmouseenter=()=>{o.style.background="rgba(255,255,255,0.1)",o.style.color="#fff"},o.onmouseleave=()=>{o.style.background="transparent",o.style.color="#9ca3af"},o}function G(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 Ft="sentient-preview-bar";async function ai(e,t){var w,I,R,D,A,P,Y,Z,W,q,Q,ne;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($){}let o=null;try{let $=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});$.ok&&(o=(I=((w=(await $.json()).slots)!=null?w:[]).find(V=>V.slot_id===t&&V.kind==="arms"))!=null?I:null)}catch($){}let r=d("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)"});r.id=Ft;let s=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");s.onclick=()=>{Ct();let $=new URL(location.href);for(let H of["sentient_editor","sentient_preview","sentient_arm"])$.searchParams.delete(H);location.assign($.toString())};let u=d("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 $=new URL(location.href);for(let H of["sentient_preview","sentient_arm"])$.searchParams.delete(H);location.assign($.toString())};let m=(P=(A=(R=o==null?void 0:o.draft_config)==null?void 0:R.arms)!=null?A:(D=o==null?void 0:o.published_config)==null?void 0:D.arms)!=null?P:[];if(!o||m.length===0){r.append(d("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),u,s),((Y=document.body)!=null?Y:document.documentElement).append(r);return}let k=new URLSearchParams(location.search).get("sentient_arm"),p=(W=(Z=m.find($=>$.id===k))!=null?Z:m[1])!=null?W:m[0];r.append(d("span",{fontWeight:"700"},`Previewing: ${(q=o.display_name)!=null?q:o.slot_id}`));let b=o.target&&typeof o.target=="object"?xe(o.target,document):null;if(!b)r.append(d("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{Ao(b,p.ops,`preview-${o.slot_id}`,document);try{b.scrollIntoView({block:"center"})}catch($){}for(let $ of m){let H=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:$.id===p.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(Q=$.displayName)!=null?Q:$.id);H.onclick=()=>{let V=new URL(location.href);V.searchParams.set("sentient_arm",$.id),location.assign(V.toString())},r.append(H)}}r.append(u,s),((ne=document.body)!=null?ne:document.documentElement).append(r)}async function si(e,t){var w,I,R,D;let o=t.lastIndexOf("~"),r=o>0?t.slice(0,o):t,s=o>0?t.slice(o+1):"",u=d("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=Ft;let m=d("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");m.onclick=()=>{Ct();let A=new URL(location.href);for(let P of["sentient_editor","sentient_preview_cell","sentient_refresh_region"])A.searchParams.delete(P);location.assign(A.toString())};let k=A=>{var P;u.append(d("span",{},A),m),((P=document.body)!=null?P:document.documentElement).append(u)},p=null;try{let A=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(r)}&persona=${encodeURIComponent(s)}`,{headers:{authorization:`Bearer ${e.token}`}});A.ok&&(p=await A.json())}catch(A){}if(!p)return k("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let b=p.target&&typeof p.target=="object"?xe(p.target,document):null;if(!b)return k("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(p.edits!=null&&typeof p.skeletonFp=="string"&&Array.isArray(p.leafToNode)){if(bo(b,p.edits,{fp:p.skeletonFp,leafToNode:p.leafToNode})==="mismatch")return k("This part of the page changed since this version was written \u2014 regenerate it from your dashboard.")}else if(p.compose!=null||p.blocks!=null)p.vocabulary&&Array.isArray(p.vocabulary.entries)&&ro(p.vocabulary),so(b,{preview:(w=p.compose)!=null?w:p.blocks},"preview",document);else if(typeof p.content=="string")b.textContent=p.content;else return k("Nothing to preview in that square yet.");try{b.scrollIntoView({block:"center"})}catch(A){}u.append(d("span",{fontWeight:"700"},`Previewing: ${(I=p.slotName)!=null?I:r}`),d("span",{opacity:"0.85"},`for ${(R=p.personaDisplay)!=null?R:s}${p.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),m),((D=document.body)!=null?D:document.documentElement).append(u)}async function $o(e,t){var u;let o=await lt(e,"/v1/editor/slots"),r=((u=o==null?void 0:o.slots)!=null?u:[]).filter(m=>t?m.slot_id===t:m.region_skeleton_status==null),s=r.length===0&&t?"missing":"none";for(let m of r){let k=m.target&&typeof m.target=="object"?xe(m.target,document):null;if(!k){t&&(s="missing");continue}let p=ho(k),b=p.skeleton?{slotId:m.slot_id,skeleton:p.skeleton}:{slotId:m.slot_id,status:p.reason};s=(await le(e,"/v1/editor/region-skeleton",b)).r==="ok"?"ok":"failed"}return s}async function Bo(e){try{await le(e,"/v1/editor/style-vocabulary",ko(document))}catch(t){}}async function li(){if(typeof document=="undefined")return;let e=qr();if(!e)return;let t=await Vr(e);if(!t.ok){t.unauthorized?(Ct(),fn(Fr)):fn(Wr);return}let o=new URLSearchParams(location.search).get("sentient_preview");if(o){document.getElementById(Ft)||await ai(e,o);return}let r=new URLSearchParams(location.search).get("sentient_preview_cell");if(r){document.getElementById(Ft)||await si(e,r),Bo(e);return}let s=new URLSearchParams(location.search).get("sentient_refresh_region");if(s){let k=await $o(e,s);fn(k==="ok"?"Region refreshed \u2014 you can regenerate its versions now.":k==="missing"?"We couldn\u2019t find that part of the page here. It may live on another page.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.");return}if(document.getElementById(dt))return;Ho(e);let u=Eo(document);Ve=u,u&&le(e,"/v1/editor/palette",u),Bo(e),$o(e).catch(()=>{});let m=await Xr(e);Po(m),No(m,document)}li();return dr(di);})();
|
package/dist/snippet.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var ut=Object.defineProperty,Zr=Object.defineProperties,Qr=Object.getOwnPropertyDescriptor,eo=Object.getOwnPropertyDescriptors,to=Object.getOwnPropertyNames,bn=Object.getOwnPropertySymbols;var wn=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var Sn=(e,t,n)=>t in e?ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t)=>{for(var n in t||(t={}))wn.call(t,n)&&Sn(e,n,t[n]);if(bn)for(var n of bn(t))no.call(t,n)&&Sn(e,n,t[n]);return e},De=(e,t)=>Zr(e,eo(t));var En=(e,t)=>()=>(e&&(t=e(e=0)),t);var An=(e,t)=>{for(var n in t)ut(e,n,{get:t[n],enumerable:!0})},ro=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of to(t))!wn.call(e,o)&&o!==n&&ut(e,o,{get:()=>t[o],enumerable:!(r=Qr(t,o))||r.enumerable});return e};var oo=e=>ro(ut({},"__esModule",{value:!0}),e);var io,so,ao,xn,lo,co,kn,N,_e,We=En(()=>{"use strict";io=Object.defineProperty,so=Object.defineProperties,ao=Object.getOwnPropertyDescriptors,xn=Object.getOwnPropertySymbols,lo=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,kn=(e,t,n)=>t in e?io(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,N=(e,t)=>{for(var n in t||(t={}))lo.call(t,n)&&kn(e,n,t[n]);if(xn)for(var n of xn(t))co.call(t,n)&&kn(e,n,t[n]);return e},_e=(e,t)=>so(e,ao(t))});var Bn={};An(Bn,{LOCAL_ENGINE_AVAILABLE:()=>mo,createLocalEngine:()=>ho});function ho(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var mo,Nn=En(()=>{"use strict";mo=!1});var $i={};An($i,{applyPersonaAttributes:()=>xt,applyRegistrySlots:()=>_t,applySlotArms:()=>Ct,applySlotAttributes:()=>kt,parseEditorToken:()=>zr,parsePersonaPreview:()=>Hr,parsePreview:()=>Wr,parseSnippetConfig:()=>St,planReorder:()=>Lt,reapply:()=>it,run:()=>Vr,version:()=>ot});We();function dt(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Cn(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 zt(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 dt(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[a,i]of Object.entries((n=e.dims)!=null?n:{}))o[a]=(r=i[0])!=null?r:"";return dt(o)}function _n(e,t){var n,r;return e.dims!=null?(r=(n=Cn(t))!=null?n:Cn(zt(e)))!=null?r:{}:t}function On(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 Oe(e){return e>=.3?e<.7?"medium":"high":"low"}function ft(e){return e?`_${e.slice(0,12)}`:""}var uo="_snt_uid";function In(e){return`${uo}${ft(e)}`}var fo=["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 Ln(e){return po(e)!==null}function po(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=fo.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Tn(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 Rn(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 Pn(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var go=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function Dn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,a])=>{let i=Array.isArray(a)?a[0]:a;return i===void 0?[]:[[o,i]]});for(let[o,a]of r)o.startsWith("utm_")?o in t||(t[o]=a):go.includes(o)&&(o in n||(n[o]=a))}catch(r){}return{utmParams:t,clickIds:n}}function Mn(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function qt(e){return N(N(N({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 Wt(e){let t=qt(e);return _n(t,zt(t))}function $n(e){return typeof e=="string"?e:dt(e)}We();function zn(){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 yo="_snt_uid",vo=365,pt="_snt_uid";function bo(){return zn()}function Kn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function So(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Ht(e){try{return localStorage.getItem(e)}catch(t){return null}}function jn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Gn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function wo(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Eo(e){try{sessionStorage.removeItem(e)}catch(t){}}function Ao(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 xo(e){try{localStorage.removeItem(e)}catch(t){}}function ko(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Co={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function qn(e){var t,n,r,o,a,i,s;if(typeof window=="undefined")return Co;let l=ft(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:In(e==null?void 0:e.apiKey),c=`${pt}${l}`,d=`${pt}_tomb${l}`,m=((n=e==null?void 0:e.cookieTTLDays)!=null?n:vo)*24*60*60,C=w=>w&&w.length>0?w:null,p=()=>{var w,h;return l&&!(e!=null&&e.cookieName)&&Ht(d)===null?(h=(w=C(Kn(yo)))!=null?w:C(Ht(pt)))!=null?h:C(Gn(pt)):null},g=(s=(i=(a=(o=(r=C(Kn(u)))!=null?r:C(Ht(c)))!=null?o:C(Gn(c)))!=null?a:p())!=null?i:C(e==null?void 0:e.ssrSessionId))!=null?s:bo();So(u,g,m);let _=jn(c,g),v=Ao(u),O=_?!1:wo(c,g),b=!_&&!v&&!O;return{getSessionId:()=>g,isEphemeral:()=>b,destroy:()=>{g=null,ko(u),xo(c),Eo(c),l&&!(e!=null&&e.cookieName)&&jn(d,"1")}}}function Me(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function Qt(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 Wn(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 a=localStorage.getItem(n);if(!a)return[];let i=JSON.parse(a);return Array.isArray(i)?i:[]}catch(a){return[]}})(),o=new Map;for(let a of r)o.set(a.id,a);for(let a of e)o.set(a.id,a);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function Hn(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),a=r.filter(i=>!o.has(i.id));if(a.length===r.length)return;a.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(a))}catch(n){}}var _o=500,Oo=56*1024;function Vn(e){return`_snt_retry_${e.slice(0,12)}`}var Io={push:()=>{},flush:()=>{},destroy:()=>{}};function Lo(e){var t,n,r;if(typeof window=="undefined")return Io;let o=(t=e.flushIntervalMs)!=null?t:5e3,a=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,l=e.apiKey,u=Vn(l),c=[],d=new Set,m=[],C=S=>{for(let T of S)p.delete(T),!d.has(T)&&(d.add(T),m.push(T));for(;m.length>_o;){let T=m.shift();T&&d.delete(T)}Hn(S,u)},p=new Set,g=()=>{for(;c.length>i;){let S=c.shift();S&&p.delete(S.id)}},_=S=>{d.has(S.id)||p.has(S.id)||(p.add(S.id),c.push(S),g())},v=S=>{for(let T of S)d.has(T.id)||(p.add(T.id),c.push(T));g()},O=Wn(u,i);for(let S of O)_(S);let b=0,w=0,h=(S,T=!0)=>{if(S.length===0)return;let Y=JSON.stringify(S),ee=S.map(R=>R.id),x;try{x=fetch(s,{method:"POST",keepalive:!0,body:Y,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`}})}catch(R){$e(S,i,u),v(S),w++,b=Date.now()+Me(w);return}let K=R=>{if(Qt(R)!=="retry"){if(!R.ok&&T){let z=S.filter(Z=>Z.eventType!=="pageview");if(z.length>0&&z.length<S.length){C(S.filter(Z=>Z.eventType==="pageview").map(Z=>Z.id)),h(z,!1);return}}C(ee),w=0,b=0;return}$e(S,i,u),v(S),w++,b=Date.now()+Me(w)};x instanceof Promise?x.then(K).catch(()=>{$e(S,i,u),v(S),w++,b=Date.now()+Me(w)}):K(x)},A=typeof TextEncoder!="undefined"?new TextEncoder:null,E=S=>A?A.encode(S).length:S.length,F=S=>{let T=[],Y=2;for(let ee of S){let x=E(JSON.stringify(ee))+1;if(T.length>0&&Y+x>Oo||T.length>=a)break;T.push(ee),Y+=x}return T},M=()=>{try{if(Date.now()<b)return;for(;c.length>0&&!(Date.now()<b);){let S=c.filter(Y=>!d.has(Y.id));if(c.length=0,S.length===0)break;let T=F(S);if(T.length===0)break;T.length<S.length&&c.push(...S.slice(T.length)),h(T)}}catch(S){}},q=!0,W=null;W=setInterval(()=>{q&&M()},o);let ne=()=>{document.visibilityState==="hidden"&&M()},fe=()=>{M()};return document.addEventListener("visibilitychange",ne),window.addEventListener("pagehide",fe),{push(S){_(S),c.length>=a&&M()},flush:M,destroy(){q=!1,W!==null&&(clearInterval(W),W=null),document.removeEventListener("visibilitychange",ne),window.removeEventListener("pagehide",fe),M()}}}var To=200;function Jn(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Ro={send:()=>{},flush:()=>{},destroy:()=>{}};function Po(e){var t,n,r;if(typeof window=="undefined")return Ro;let o=(t=e.flushIntervalMs)!=null?t:5e3,a=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=Jn(e.apiKey),l=[],u=new Set,c=new Set,d=[],m=0,C=0,p=!1,g=E=>{for(u.delete(E.id),c.has(E.id)||(c.add(E.id),d.push(E.id));d.length>To;){let F=d.shift();F&&c.delete(F)}Hn([E.id],s)},_=E=>{$e([E],a,s),!c.has(E.id)&&!u.has(E.id)&&(u.add(E.id),l.push(E)),Date.now()>=m&&(C++,m=Date.now()+Me(C))},v=E=>{let F;try{F=fetch(e.url,{method:"POST",keepalive:!0,body:E.body,headers:e.headers})}catch(q){_(E);return}let M=q=>{var W;let ne=Qt(q);if(ne==="retry"){_(E);return}ne==="dropped"&&((W=e.onDrop)==null||W.call(e,E,q.status)),g(E),C=0,m=0};F instanceof Promise?F.then(M).catch(()=>_(E)):M(F)},O=()=>{try{if(p||Date.now()<m)return;let E=0;for(;l.length>0&&E<i&&!(Date.now()<m);){let F=l.shift();u.delete(F.id),!c.has(F.id)&&(E++,v(F))}}catch(E){}},b=Wn(s,a);for(let E of b)u.has(E.id)||(u.add(E.id),l.push(E));b.length>0&&$e(b,a,s);let w=setInterval(O,o),h=()=>{document.visibilityState==="hidden"&&O()},A=()=>O();return document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",A),{send(E){if(!p&&!(c.has(E.id)||u.has(E.id))){if(Date.now()<m){$e([E],a,s),u.add(E.id),l.push(E);return}v(E)}},flush:O,destroy(){clearInterval(w),document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",A),O(),p=!0}}}var Do=1800*1e3;function gt(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Mo(e=Do,t){let n=new Map,r=`_snt_asgn${ft(t)}_`,o=(l,u)=>`${r}${encodeURIComponent(l)}:${encodeURIComponent(u)}`,a=l=>{let u=l.slice(r.length),c=u.indexOf(":");if(c<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,c)),segment:decodeURIComponent(u.slice(c+1))}}catch(d){return null}},i=()=>{try{let l=[];for(let u=0;u<localStorage.length;u++){let c=localStorage.key(u);c!=null&&c.startsWith(r)&&l.push(c)}return l}catch(l){return[]}},s=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of i())try{let u=localStorage.getItem(l);if(!u)continue;let c=JSON.parse(u);if(s(c)){localStorage.removeItem(l);continue}let d=a(l);if(!d)continue;n.set(gt(d.componentId,d.segment),c)}catch(u){}})(),{get(l,u){let c=n.get(gt(l,u));return c?s(c)?(n.delete(gt(l,u)),null):c:null},set(l,u,c){let d=gt(l,u);n.set(d,c);try{localStorage.setItem(o(l,u),JSON.stringify(c))}catch(m){}},clear(){n.clear();for(let l of i())try{localStorage.removeItem(l)}catch(u){}}}}var yt="_snt_snap:",$o=["low","medium","high"];function Ve(e){try{let t=localStorage.getItem(yt+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"||!$o.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 Ne(e,t){try{localStorage.setItem(yt+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,mt=!1;function Bo(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function No(e){var t;let n=qn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=Bo(),a=Promise.resolve().then(()=>(Nn(),Bn)).then(c=>{let d=c;return d.LOCAL_ENGINE_AVAILABLE?(Un||(Un=!0,console.info(Yn)),d):(mt||(mt=!0,console.error(Xt)),null)}).catch(()=>(mt||(mt=!0,console.error(Xt)),null)),i=null,s={low:.15,medium:.5,high:.85},l=(()=>{var c;if(e.initialPersona)return N({},e.initialPersona);let d=Ve(e.apiKey||"local");return d?{persona:d.persona,confidence:(c=s[d.band])!=null?c:.15}:null})();function u(c){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=c.persona,d.dataset.sentientConfidence=Oe(c.confidence))}return{isLocal:!0,async decide(c){var d,m,C;let p=await a;if(!p)return null;let g=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide(c);return i=_e(N({},g),{layoutOrder:(m=(d=g.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?m:null,slots:N(N({},(C=i==null?void 0:i.slots)!=null?C:{}),g.slots)}),Ne(e.apiKey||"local",{v:1,persona:i.persona,band:Oe(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(g),g},getSlotResult(c){var d,m,C;return(C=(m=i==null?void 0:i.slots[c])!=null?m:(d=e.initialSlots)==null?void 0:d[c])!=null?C:null},getSlotConfig(c){var d,m;return(m=(d=e.initialSlotConfig)==null?void 0:d[c])!=null?m:null},getSitePalette(){var c;return(c=e.initialPalette)!=null?c:null},reportSlots(){},getPersona(){let c=i!=null?i:l;return c?{persona:c.persona,confidence:c.confidence,band:Oe(c.confidence)}:null},async assign(c,d){var m;let C=await a;return!C||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(m=C.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:c,variantIds:d}]}).assignments[c])!=null?m:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}var vt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Vt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function en(e,t){if(e===void 0||!vt.test(e))return!1;if(e==="*")return!0;let n=Vt(t);if(e.endsWith("/*")){let r=Vt(e.slice(0,-2));return n.startsWith(r==="/"?"/":`${r}/`)&&n!==r}return n===Vt(e)}function bt(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(bt):!1}var Fn="sentient-reveal",Be="sentient-revealed";var Jt=!1;function Ko(e){if(Jt||e.getElementById(Fn)){Jt=!0;return}let t=e.createElement("style");t.id=Fn,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${Be}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${Be}{animation:${Be} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),Jt=!0}function tn(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;Ko(r),e.classList.remove(Be),e.offsetWidth,e.classList.add(Be);let o=()=>{e.classList.remove(Be),e.removeEventListener("animationend",o)};return e.addEventListener("animationend",o),!0}function Je(e,t,n,r){let o=[];{let a=!1,i=[],s=()=>{if(a)return;let l=Date.now();for(i.push(l);i.length>0&&l-i[0]>500;)i.shift();i.length>=3&&(a=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let a=!1,i=s=>{if(a||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;a=!0;let l=typeof window!="undefined"?window.getSelection():null,u=l?l.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let a=!1,i=!1,s=null,l=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{a||!i||(l(),s=setTimeout(()=>{!a&&i&&(a=!0,e("scroll_hesitation"))},3e3))},c=()=>{l(),u()},d=C=>{for(let p of C)i=p.intersectionRatio>.3,i?u():l()},m=new IntersectionObserver(d,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",c,{passive:!0}),o.push(()=>{m.disconnect(),window.removeEventListener("scroll",c),l()})}if((r==null?void 0:r.tabLoss)!==!1){let a=!1,i=n!=null?n:Date.now(),s=()=>{if(a||document.visibilityState!=="hidden")return;let l=Date.now()-i;l<15e3&&(a=!0,e("tab_loss",{timeOnPage:l}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let a of o)a()}}function jo(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Xn="https://api.sentient-ui.com/v1/events",le=new Map,Zn=null;function Go(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Uo=3;function Yt(){return zn()}function ht(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Fo(){let e=new WeakMap,t=new Map,n=!1,r=(s,l,u)=>{let c=s.get(l);return u===null?c?!0:(s.set(l,new Set),!1):c?c.has(u)?!0:(c.add(u),!1):(s.set(l,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,a=()=>{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,l=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(l,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),l()},u.port2.postMessage(0)}};return{firedBefore(s,l){let u=a();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,l)}let c=r(t,s,l);return!c&&!n&&(n=!0,i()),c}}}var Qn=new Set;function zo(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,a,i=()=>{if(o)return;let u=ht();!u||u===a||(a=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},s=[];for(let u of["pushState","replaceState"]){let c=r[u],d=function(...m){let C=c.apply(this,m);return i(),C};r[u]=d,s.push([u,c,d])}window.addEventListener("popstate",i);let l=ht();return l&&Qn.has(`${t}:${l}`)?a=l:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,c,d]of s)r[u]===d&&(r[u]=c)}}}var He={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 qo(){try{return Dn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function er(e){return e.replace(/\/events\/?$/,"")}function Ie(){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 nn(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:Zn;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=le.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:a,reinit:i}=r;if(!a){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Ie())return;let s=(i!=null?i:Ye)(_e(N({},o),{consent:!0}));a(s);let l=(t=le.get(n))==null?void 0:t.dispose;le.set(n,{config:_e(N({},o),{consent:!0}),upgrade:null,dispose:l})}function Wo(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=er((t=e.ingestUrl)!=null?t:Xn),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(p,g,_){if(!n)return Promise.resolve(null);let v=a.get(p);return v?Promise.resolve(v):Zt(i,p,async()=>{try{let O=new URLSearchParams({componentId:p});for(let h of g!=null?g:[])O.append("variantIds[]",h);let b=await fetch(`${r}/winner?${O.toString()}`,{headers:o});if(!b.ok)return g!=null&&g[0]?{variantId:g[0],assignmentTtlMs:0}:null;let w={variantId:(await b.json()).variantId,assignmentTtlMs:0};return a.set(p,w),w}catch(O){return g!=null&&g[0]?{variantId:g[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l=!1,u=new Set,c=[],d=[],m={track:p=>s.track(p),goal:((p,g,_,v)=>s.goal(p,g,_,v)),componentGoal:(p,g,_)=>s.componentGoal(p,g,_),identify:p=>s.identify(p),getAssignment:(p,g)=>s.getAssignment(p,g),assign:(p,g,_,v)=>s.assign(p,g,_,v),decide:p=>s.decide(p),getSlotResult:p=>s.getSlotResult(p),isSlotDecided:p=>{var g,_;return(_=(g=s.isSlotDecided)==null?void 0:g.call(s,p))!=null?_:!0},getSlotConfig:p=>s.getSlotConfig(p),getSitePalette:()=>s.getSitePalette(),reportSlots:(p,g)=>s.reportSlots(p,g),requestSlots:(p,g)=>{var _;return l?(_=s.requestSlots)==null?void 0:_.call(s,p,g):c.push([p,g])},decideSlots:p=>{var g;return l?(g=s.decideSlots)==null?void 0:g.call(s,p):d.push(...p)},cancelSlots:p=>{var g;if(l)return(g=s.cancelSlots)==null?void 0:g.call(s,p);let _=new Set(p);for(let v of c)v[0]=v[0].filter(O=>!_.has(O));d=d.filter(v=>!_.has(v.id))},onSlotsChanged:p=>(u.add(p),()=>{u.delete(p)}),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function C(p){var g,_,v;s=p,l=!0,(g=p.onSlotsChanged)==null||g.call(p,()=>u.forEach(O=>O()));for(let[O,b]of c.splice(0))O.length>0&&((_=p.requestSlots)==null||_.call(p,O,b));d.length>0&&((v=p.decideSlots)==null||v.call(p,d.splice(0)))}return{proxy:m,setInner:C}}function Zt(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 Ye(e){var t,n,r,o,a,i,s,l,u,c;if(typeof window=="undefined")return He;Zn=e.apiKey||"local";let d=le.get(e.apiKey||"local");if(d!=null&&d.dispose)try{d.dispose()}catch(f){}let m=e.respectDoNotTrack!==!1&&Ie(),C=e.consent===!1||m,p=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!p&&e.localMode!==!1)return le.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."}),C?He:No(e);if(C){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."),le.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."}),He;let{proxy:f,setInner:y}=Wo(e);return le.set(e.apiKey,{config:e,upgrade:m?null:y}),f}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."),He;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),He;let g=(t=e.ingestUrl)!=null?t:Xn,_=Date.now(),v=qn({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),O=Mo(void 0,e.apiKey),b=Lo({ingestUrl:g,apiKey:e.apiKey}),w=er(g),h={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},A=new Set,E=Po({url:`${w}/goals`,apiKey:e.apiKey,headers:h,onDrop:(f,y)=>{if(!e.debug){if(A.has(y))return;A.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."),f)}}),F=Tn((n=navigator.userAgent)!=null?n:""),M=window.location.origin,q=Rn((r=document.referrer)!=null?r:"",M),W=(o=e.sessionSegment)!=null?o:`${F}:${q}`,ne=new Map,fe=new Map,S=new Map,T=new Set,Y=new Map,ee=null,x=null,K=new Set,R=new Set,z=new Map,Z=null,Re=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,Ue=new Set,pe=new Set,st=new Set,Fe=new Map,jt=null,at=new Set,ze=new Map,Gt=null,Jr=2,fn=new Map,Ut=!1,pn=(f,y,k)=>{var $;let B=new Set,I=1;for(let P of f){y.delete(P);let D=(($=fn.get(P))!=null?$:0)+1;fn.set(P,D),D<=Jr&&(B.add(P),D>I&&(I=D))}B.size>0&&setTimeout(()=>{Ut||k(B)},Me(I))},gn=f=>{for(let y of f)S.has(y.id)||S.set(y.id,Wt(y))};if(e.initialSlots)for(let[f,y]of Object.entries(e.initialSlots))S.set(f,y),T.add(f);if(e.initialSlotConfig)for(let[f,y]of Object.entries(e.initialSlotConfig))Y.set(f,y);e.initialPalette&&(ee=e.initialPalette);let be=Ve(e.apiKey);if(be){for(let[f,y]of Object.entries(be.slots))S.has(f)||S.set(f,y);for(let[f,y]of Object.entries((a=be.slotConfig)!=null?a:{}))Y.has(f)||Y.set(f,y);!ee&&be.palette&&(ee=be.palette)}let mn={low:.15,medium:.5,high:.85};if(e.initialPersona)x=N({},e.initialPersona);else{let f=document.documentElement.dataset;f.sentientPersona?x={persona:f.sentientPersona,confidence:(s=mn[(i=f.sentientConfidence)!=null?i:"low"])!=null?s:.15}:be&&(x={persona:be.persona,confidence:(l=mn[be.band])!=null?l:.15})}if(e.initialAssignments)for(let[f,y]of Object.entries(e.initialAssignments))O.set(f,W,{variantId:y,assignedAt:Date.now(),segment:W,confidence:1});let Se=Promise.resolve(),hn=v.getSessionId();if(hn){let f=Pn((u=document.referrer)!=null?u:""),{utmParams:y,clickIds:k}=qo(),$=N(N(N(N({sessionId:hn,deviceClass:F,trafficSource:q,referrerDomain:f,utmParams:y,clickIds:k,timeOfDay:Mn(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:v.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ln((c=navigator.userAgent)!=null?c:"")},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}:{}),B=async()=>{for(let I=0;;I++){try{let P=await fetch(`${w}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify($),headers:h});if(P.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(P.ok||Qt(P)==="dropped")return}catch(P){}if(I>=Uo){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(P=>setTimeout(P,Me(I+1)))}};try{Se=B()}catch(I){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:b});let Yr=Fo(),qe=null,Ft=!1,oe={goal(f,y={},k=1,$=0){var B,I,P,D,J,ie,se;let we=v.getSessionId();if(!we)return;let re=Go(y)?y:{metadata:y},lt=[f,(B=re.externalId)!=null?B:"",(I=re.stepIndex)!=null?I:$,(P=re.weight)!=null?P:k].join("\0"),ct=re.value!==void 0?`${re.value}\0${(D=re.currency)!=null?D:""}`:null;if(Yr.firedBefore(lt,ct)){e.debug&&console.log(`[sentient] goal("${f}") already recorded for this action \u2014 not sent twice`);return}let Pe=Yt(),G={sessionId:we,name:f,metadata:(J=re.metadata)!=null?J:{},weight:(ie=re.weight)!=null?ie:k,stepIndex:(se=re.stepIndex)!=null?se:$,goalId:Pe,value:re.value,currency:re.currency,externalId:re.externalId};e.debug&&console.log("[sentient] goal",G);let Ee={id:Pe,body:JSON.stringify(G)};Se.then(()=>E.send(Ee))},componentGoal(f,y,k){var $,B,I;let P=v.getSessionId();if(!P)return;let D=O.get(f,W),J=D?null:($=S.get(f))!=null?$:null;if(!D&&J===null){e.debug&&console.warn(`[sentient] componentGoal("${f}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!D&&!T.has(f)){e.debug&&console.warn(`[sentient] componentGoal("${f}"): slot not decided this session \u2014 not attributed`);return}let ie=D?D.variantId:$n(J),se={id:Yt(),sessionId:P,projectId:e.apiKey,componentId:f,variantId:ie,eventType:"goal_achieved",goalType:y,payload:N({reward:(B=k==null?void 0:k.reward)!=null?B:1,goalValue:k==null?void 0:k.value,currency:k==null?void 0:k.currency},(I=k==null?void 0:k.metadata)!=null?I:{}),timestamp:Date.now(),timeInSession:Date.now()-_,path:ht()};e.debug&&console.log("[sentient] componentGoal",se),Se.then(()=>b.push(se))},identify(f){let y=v.getSessionId();y&&Se.then(()=>{fetch(`${w}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:f,ephemeral:v.isEphemeral()}),headers:h}).catch(()=>{})})},track(f){let y=v.getSessionId();if(!y||f.eventType==="variant_assigned"&&S.get(f.componentId)!==void 0&&!T.has(f.componentId)&&!O.get(f.componentId,W))return;let k=_e(N({path:ht()},f),{id:Yt(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-_});e.debug&&console.log("[sentient] track",k),Se.then(()=>b.push(k))},getAssignment(f,y){return O.get(f,y)},async assign(f,y,k,$){let B=v.getSessionId();if(!B)return null;let I=O.get(f,W);if(I&&(y!=null&&y.length||I.content!==void 0)){let P=I.ttlMs&&I.ttlMs>0?Math.max(0,I.assignedAt+I.ttlMs-Date.now()):0;return{variantId:I.variantId,assignmentTtlMs:P,content:I.content}}return Zt(ne,f,async()=>{await Se;try{let P={sessionId:B,componentId:f,variantIds:y};$!==void 0?P.agentDataByVariant=$:k!==void 0&&(P.agentData=k);let D=await fetch(`${w}/assign`,{method:"POST",body:JSON.stringify(P),headers:h});if(!D.ok)return null;let J=await D.json();return O.set(f,W,N({variantId:J.variantId,assignedAt:Date.now(),segment:W,confidence:1,content:J.content},J.assignmentTtlMs&&J.assignmentTtlMs>0?{ttlMs:J.assignmentTtlMs}:{})),J}catch(P){return null}})},async decide(f){var y,k;let $=v.getSessionId();if(!$)return null;let B=(y=f.slots)!=null?y:[],I={sessionId:$};f.sections&&f.sections.length>0&&(I.sections=f.sections.map(D=>({id:D}))),I.components=(k=f.components)!=null?k:[],B.length>0&&(I.slots=B.map(qt)),f.slotsFrom==="registry"&&(I.slotsFrom="registry",f.registrySlotIds&&(I.registrySlotIds=f.registrySlotIds),f.bootstrap===!1&&(I.bootstrap=!1)),f.v&&(I.v=f.v),typeof f.pp=="number"&&(I.pp=f.pp),e.persona&&(I.persona=e.persona);let P=JSON.stringify(I);return Zt(fe,P,async()=>{var D,J,ie,se,we,re,lt,ct;await Se;try{let Pe=await fetch(`${w}/decide`,{method:"POST",body:P,headers:h});if(!Pe.ok)return gn(B),null;let G=await Pe.json(),Ee={};for(let H of B){let ge=(D=G.slots)==null?void 0:D[H.id];if(ge!==void 0){Ee[H.id]=ge,S.set(H.id,ge),T.add(H.id);continue}let yn=S.get(H.id);if(yn!==void 0)Ee[H.id]=yn;else{let vn=Wt(H);Ee[H.id]=vn,S.set(H.id,vn)}}if(G.slots)for(let[H,ge]of Object.entries(G.slots))H in Ee||(Ee[H]=ge,S.set(H,ge),T.add(H));let Xr=x!=null&&x.persona!=="unknown";G.persona&&!(G.persona==="unknown"&&Xr)?x={persona:G.persona,confidence:(J=G.confidence)!=null?J:0}:x||(x={persona:"unknown",confidence:0});for(let[H,ge]of Object.entries((ie=G.assignments)!=null?ie:{}))O.set(H,W,{variantId:ge,assignedAt:Date.now(),segment:W,confidence:1});if(G.slotConfig)for(let[H,ge]of Object.entries(G.slotConfig))Y.set(H,ge);G.palette&&(ee=G.palette);for(let H of(se=f.registrySlotIds)!=null?se:[])(we=G.slotConfig)!=null&&we[H]||(Y.delete(H),S.delete(H),T.delete(H));return Ne(e.apiKey,N(N({v:1,persona:x.persona,band:Oe(x.confidence),slots:Object.fromEntries(S),layoutOrder:(re=G.layoutOrder)!=null?re:null,savedAt:Date.now()},Y.size>0?{slotConfig:Object.fromEntries(Y)}:{}),ee?{palette:ee}:{})),N(N(N(N({layoutOrder:(lt=G.layoutOrder)!=null?lt:null,assignments:(ct=G.assignments)!=null?ct:{},slots:Ee,persona:x.persona,confidence:x.confidence},G.slotConfig?{slotConfig:G.slotConfig}:{}),G.goals?{goals:G.goals}:{}),G.sectionMap?{sectionMap:G.sectionMap}:{}),G.palette?{palette:G.palette}:{})}catch(Pe){return gn(B),null}})},getSlotResult(f){var y;return(y=S.get(f))!=null?y:null},isSlotDecided(f){return T.has(f)},getSlotConfig(f){var y;return(y=Y.get(f))!=null?y:null},reportSlots(f,y){for(let k of f)if(!(typeof k!="string"||k.length===0)){if(!Re.test(k)){jo()&&!Ue.has(k)&&(Ue.add(k),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(k)} 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(!K.has(k)){K.add(k),R.add(k);let $=y==null?void 0:y[k];if(typeof $=="string"){let B=$.replace(/\s+/g," ").trim().slice(0,400);B!==""&&z.set(k,B)}}}R.size===0||Z!=null||(Z=setTimeout(()=>{Z=null;let k=[...R];R.clear();for(let $=0;$<k.length;$+=20){let B=k.slice($,$+20),I={};for(let P of B){let D=z.get(P);D!==void 0&&(I[P]=D,z.delete(P))}fetch(`${w}/slots/observed`,{method:"POST",headers:h,body:JSON.stringify(N({slotIds:B},Object.keys(I).length>0?{baselineTexts:I}:{}))}).catch(()=>{})}},1e3))},requestSlots(f,y){for(let k of f)st.has(k)||(st.add(k),Re.test(k)?Fe.set(k,y==null?void 0:y[k]):oe.reportSlots([k]));Fe.size===0||jt!=null||(jt=setTimeout(()=>{jt=null;let k=[...Fe];Fe.clear();for(let $=0;$<k.length;$+=50){let B=k.slice($,$+50);oe.decide({slotsFrom:"registry",registrySlotIds:B.map(([I])=>I),bootstrap:!1}).then(I=>{var P;if(I){let D={},J=[];for(let[ie,se]of B)(P=I.slotConfig)!=null&&P[ie]||(J.push(ie),se&&(D[ie]=se));J.length>0&&oe.reportSlots(J,D)}else pn(B.map(([D])=>D),st,D=>{var J;let ie={};for(let[se,we]of B)D.has(se)&&we&&(ie[se]=we);(J=oe.requestSlots)==null||J.call(oe,[...D],ie)});pe.forEach(D=>D())})}},0))},decideSlots(f){for(let y of f)at.has(y.id)||(at.add(y.id),ze.set(y.id,y));ze.size===0||Gt!=null||(Gt=setTimeout(()=>{Gt=null;let y=[...ze.values()];ze.clear();for(let k=0;k<y.length;k+=30){let $=y.slice(k,k+30);oe.decide({slots:$}).then(B=>{B||pn($.map(I=>I.id),at,I=>{var P;return(P=oe.decideSlots)==null?void 0:P.call(oe,$.filter(D=>I.has(D.id)))}),pe.forEach(I=>I())})}},0))},cancelSlots(f){for(let y of f)Fe.delete(y)&&st.delete(y),ze.delete(y)&&at.delete(y)},onSlotsChanged(f){return pe.add(f),()=>{pe.delete(f)}},getSitePalette(){return ee},getPersona(){return x?{persona:x.persona,confidence:x.confidence,band:Oe(x.confidence)}:null},async fetchWeights(){var f;try{let y=await fetch(`${w}/weights`,{headers:h});return y.ok?(f=(await y.json()).components)!=null?f:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var f;qe==null||qe(),Ft=!0,Ut=!0,b.destroy(),E.destroy(),((f=le.get(e.apiKey))==null?void 0:f.dispose)===oe.dispose&&le.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var f;qe==null||qe(),Ft=!0,Ut=!0,b.destroy(),E.destroy(),v.destroy(),O.clear(),((f=le.get(e.apiKey))==null?void 0:f.dispose)===oe.dispose&&le.delete(e.apiKey);try{localStorage.removeItem(yt+e.apiKey),localStorage.removeItem(Vn(e.apiKey)),localStorage.removeItem(Jn(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(le.set(e.apiKey,{config:e,upgrade:null,dispose:oe.dispose}),qe=zo(oe,e.apiKey,f=>{Se.then(()=>{Ft||Qn.add(f)})}),e.debug){let f=window;f.__sentient&&(f.__sentient.client=oe)}return oe}var Ho=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function rn(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function Vo(e){return{tag:e.tagName.toLowerCase(),text:rn(e).slice(0,40)}}function tr(e){return e.replace(/["\\\]]/g,"\\$&")}function Xe(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function nr(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)),a=[r,...o.map(s=>`${r}.${s}`)];for(let s of a)if(Xe(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=nr(i,t);if(s){for(let d of a){let m=`${s} > ${d}`;if(Xe(t,m))return m}let l=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=l.indexOf(e),c=l.some(d=>d!==e&&rn(d)!==rn(e));if(u>=0&&c){let d=`${s} > ${r}:nth-of-type(${u+1})`;if(Xe(t,d))return d}}}return null}function rr(e,t){let n=Vo(e),r=e.getAttribute("id");if(r&&Xe(t,`#${tr(r)}`))return{v:1,id:r,fingerprint:n};for(let a of Ho){let i=e.getAttribute(a);if(i&&Xe(t,`[${a}="${tr(i)}"]`))return{v:1,dataAttr:{name:a,value:i},fingerprint:n}}let o=nr(e,t);return o?{v:1,selector:o,fingerprint:n}:null}We();var ir=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Jo={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Yo(e){let t=e.ariaRole?Jo[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 Xo(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Zo=[["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]],on=[["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]],or={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Qo(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function sr(e){var t,n;let r=Yo(e);if(r)return{type:(t=or[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of Zo)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of on)if(s.test(e.bodyText))return{type:i,strength:"strong"};let a=Xo(e);return{type:(n=or[a])!=null?n:"generic",strength:"weak"}}function ar(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return N({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Qo(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}We();var ei="section, header, footer, nav, main > div, [data-sentient-section]",ti=2e4;function ni(e){let t=Array.from(e.querySelectorAll(ei)),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 ri(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 lr=()=>{};function cr(e,t){var n,r,o,a,i,s,l,u,c,d,m,C,p,g,_;let v=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!v||typeof IntersectionObserver=="undefined"||Ie()||!t.apiKey||!t.apiKey.startsWith("pk_"))return lr;let O=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),b=ni(v);if(b.length===0)return lr;let w=new Map,h=[];for(let x of b){let K=(i=[(a=t.sectionTypes)==null?void 0:a[(o=x.getAttribute("data-sentient-id"))!=null?o:""],x.getAttribute("data-sentient-type")].find(pe=>ir.includes(pe)))!=null?i:null,R=ar(x),z=(l=K!=null?K:(s=t.typeOf)==null?void 0:s.call(t,x))!=null?l:sr(R).type,Z=rr(x,v),Re=Z?`nc-${z}-${On(JSON.stringify({id:(u=Z.id)!=null?u:null,dataAttr:(c=Z.dataAttr)!=null?c:null,selector:(d=Z.selector)!=null?d:null})).toString(36)}`:`nc-${z}`;w.set(x,Re);let Ue=on.filter(([,pe])=>pe.test(R.bodyText)).map(([pe])=>pe);h.push(_e(N({componentId:Re,semanticType:z,source:K?"markup":"auto"},Z?{locator:Z}:{}),{observation:N(N({tag:R.tag,idClass:R.idClass.slice(0,200),headingText:R.headingText,textLength:R.textLength,actionCount:R.actionCount},R.ariaRole?{ariaRole:R.ariaRole}:{}),Ue.length>0?{patternFlags:Ue}:{})}))}let A=(g=(p=(C=(m=v.defaultView)!=null?m:typeof window!="undefined"?window:void 0)==null?void 0:C.location)==null?void 0:p.pathname)!=null?g:"/";ri(t.apiKey,O,A,h);let E=new Map,F=x=>{let K=E.get(x);return K||(K={ms:0,scroll:0,enterAt:null,intersecting:!1},E.set(x,K)),K},M=new IntersectionObserver(x=>{for(let K of x){let R=w.get(K.target);if(!R)continue;let z=F(R);K.isIntersecting?(z.intersecting=!0,z.enterAt=Date.now(),K.intersectionRatio>z.scroll&&(z.scroll=K.intersectionRatio)):(z.intersecting=!1,z.enterAt!=null&&(z.ms+=Date.now()-z.enterAt,z.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let x of w.keys())M.observe(x);let q=()=>{let x=Date.now();for(let[K,R]of E)if(R.enterAt!=null&&(R.ms+=x-R.enterAt,R.enterAt=null),!(R.ms<=0)){try{e.track({projectId:t.apiKey,componentId:K,eventType:"dwell",payload:{dwell_time:Math.round(R.ms),scroll_depth:Number(R.scroll.toFixed(2))}})}catch(z){}R.ms=0}},W=()=>{if(v.hidden)q();else{let x=Date.now();for(let K of E.values())K.intersecting&&(K.enterAt=x)}},ne=!1,fe=x=>{if(q(),x!=null&&x.persisted){ne=!0;return}try{M.disconnect()}catch(K){}},S=x=>{if(!(x!=null&&x.persisted)||!ne)return;ne=!1;let K=Date.now();for(let R of E.values())R.enterAt=R.intersecting&&!v.hidden?K:null};v.addEventListener("visibilitychange",W);let T=(_=v.defaultView)!=null?_:typeof window!="undefined"?window:void 0;T==null||T.addEventListener("pagehide",fe),T==null||T.addEventListener("pageshow",S);let Y=setInterval(()=>{if(v.hidden||ne)return;q();let x=Date.now();for(let K of E.values())K.intersecting&&(K.enterAt=x)},ti),ee=[];return t.microSignals&&[...w.entries()].forEach(([x,K],R)=>{ee.push(Je((z,Z={})=>{try{e.track({projectId:t.apiKey,componentId:K,eventType:"micro_signal",payload:N({signalType:z},Z)})}catch(Re){}},x,void 0,{tabLoss:R===0}))}),()=>{q(),clearInterval(Y),v.removeEventListener("visibilitychange",W),T==null||T.removeEventListener("pagehide",fe),T==null||T.removeEventListener("pageshow",S);for(let x of ee)x();try{M.disconnect()}catch(x){}}}function oi(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(a=>typeof a=="string"))return null;n[r]=o}return n}function ii(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function si(e){try{return e()}catch(t){return}}function St(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={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[a,i]of Object.entries(t.slots)){if(typeof i!="object"||i===null)continue;let s=i,l=oi(s.dims);if(!l||s.target!==void 0&&typeof s.target!="string")continue;let u=s.arms!==void 0?ii(s.arms):null,c={dims:l};typeof s.target=="string"&&(c.target=s.target),u&&(c.arms=u),n[a]=c}let r={apiKey:t.apiKey,personaAttributes:t.personaAttributes===!0,slots:n};typeof t.consent=="boolean"&&(r.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(r.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(r.debug=!0),typeof t.registry=="boolean"&&(r.registry=t.registry),typeof t.editorSrc=="string"&&(r.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(r.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(r.sectionCapture=t.sectionCapture);let o=typeof t.persona=="function"?si(t.persona):t.persona;if(typeof o=="string"&&o.trim()!==""&&(r.persona=o),Array.isArray(t.sections)){let a=t.sections.filter(i=>typeof i=="string"&&i.trim()!=="").slice(0,50);a.length>=2&&(r.sections=a)}return r}function Ze(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function ai(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 wt(e,t){return!!(e!=null&&e.urlMatch)&&!Ze(t).includes(e.urlMatch)}var li=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ur(e,t){var r;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&li.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}return n}function ye(e,t){if(e.urlMatch&&!Ze(t).includes(e.urlMatch))return null;let n=ur(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!ai(r,e.fingerprint)?null:r}function dr(e,t){return wt(e,t)?!1:!!e.selector&&!e.dataAttr&&!e.id&&!e.fingerprint&&e.page===void 0?fr(e,t):ye(e,t)!==null}function fr(e,t){return ur(e,t).length>0}function Et(e,t){return wt(e,t)?!1:e.page!==void 0&&vt.test(e.page)?en(e.page,Ze(t)):fr(e,t)}var pr={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"},ci=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function gr(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(!ci.test((r=n[1])!=null?r:""))return!1;return!0}var mr=/^https:\/\//i,hr=new Map,Ae=null;function ui(e){return e.replace(/["\\]/g,"\\$&")}function di(e){var t;(!Ae||!Ae.isConnected)&&(Ae=e.querySelector("style[data-sentient-ops]"),Ae||(Ae=e.createElement("style"),Ae.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Ae))),Ae.textContent=[...hr.entries()].map(([n,r])=>`[data-snt-e="${ui(n)}"]{${r}}`).join(`
|
|
2
|
-
`)}function yr(e,t,n,r){var s;let o=!1,a=(s=t.moveBefore)!=null?s:t.moveAfter;if(a){let l=ye(a,r);!l||l===e||l.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,l):e.parentElement.insertBefore(e,l.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&mr.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&mr.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[l,u]of Object.entries(t.style)){let c=pr[l];c&&typeof u=="string"&&gr(u)&&i.push(`${c}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),hr.set(n,i.join(";")),di(r)),{anchorMiss:o}}var Qe="data-sentient-block-arm",L=null;function et(e){L=e!=null?e:null}var ve="data-sentient-blocks-hid",Ke={none:"0",sm:"8px",md:"16px",lg:"24px"},sn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},vr={sm:"0.875em",md:"1em",lg:"1.25em"},fi={sm:"1.25em",md:"1.5em",lg:"2em"},pi={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},br={sm:"8px",md:"16px",lg:"32px"},gi={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},mi={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 Sr(e){return e==="muted"?L!=null&&L.muted?{color:L.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:L==null?void 0:L.accent}:{}}function wr(e,t){var n,r,o,a,i,s,l,u,c,d,m,C,p,g,_,v,O,b,w,h;try{switch(e.type){case"stack":case"grid":{let A=t.createElement("div");if(e.type==="stack"){let M=e;ce(A,{display:"flex","flex-direction":M.direction,gap:(r=Ke[(n=M.gap)!=null?n:"md"])!=null?r:Ke.md,"align-items":M.align?sn[M.align]:void 0,"justify-content":M.justify?sn[M.justify]:void 0,"flex-wrap":M.wrap?"wrap":void 0})}else{let M=e,q=(a=Ke[(o=M.gap)!=null?o:"md"])!=null?a:Ke.md;ce(A,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${M.columns-1} * ${q}) / ${M.columns})), 1fr))`,gap:q,"align-items":M.align?sn[M.align]:void 0})}let E=e.type==="stack"&&e.surface==="raised",F=(i=e.pad)!=null?i:E?"md":void 0;F&&ce(A,{padding:(s=Ke[F])!=null?s:Ke.md}),E&&ce(A,{background:L==null?void 0:L.surface,color:L!=null&&L.surface?L==null?void 0:L.surfaceText:void 0,border:`1px solid ${(l=L==null?void 0:L.border)!=null?l:"currentColor"}`,"border-radius":(u=L==null?void 0:L.radius)!=null?u:"8px"});for(let M of(c=e.children)!=null?c:[]){let q=wr(M,t);q&&A.appendChild(q)}return A}case"text":{let A=t.createElement("p");return A.textContent=e.value,ce(A,De(j({margin:"0","font-size":e.size?vr[e.size]:void 0,"font-weight":e.weight?mi[e.weight]:void 0,"text-align":e.align},Sr(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let A=t.createElement(`h${e.level}`);return A.textContent=e.value,ce(A,{margin:"0","font-size":fi[(d=e.size)!=null?d:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let A=t.createElement("a");A.textContent=e.label,A.href=e.href,e.tag&&A.setAttribute("data-sentient-tag",e.tag);let E=(m=e.emphasis)!=null?m:"primary";return ce(A,{display:"inline-block",padding:pi[(C=e.size)!=null?C:"md"],"border-radius":(p=L==null?void 0:L.radius)!=null?p:"8px",font:"inherit","font-size":e.size?vr[e.size]:void 0,"text-decoration":E==="ghost"?"underline":"none",cursor:"pointer",background:E==="primary"?(g=L==null?void 0:L.primaryBg)!=null?g:"#111827":"transparent",color:E==="primary"?(_=L==null?void 0:L.primaryText)!=null?_:"#ffffff":(v=L==null?void 0:L.accent)!=null?v:"inherit",border:E==="secondary"?`1px solid ${(O=L==null?void 0:L.accent)!=null?O:"currentColor"}`:"none"})}case"link":{let A=t.createElement("a");return A.textContent=e.label,A.href=e.href,e.tag&&A.setAttribute("data-sentient-tag",e.tag),ce(A,{color:"inherit","text-decoration":"underline"})}case"image":{let A=t.createElement("img");return A.src=e.src,A.alt=e.alt,ce(A,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?gi[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let A=t.createElement("span");return A.textContent=e.value,ce(A,j({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(b=L==null?void 0:L.border)!=null?b:"currentColor"}`},Sr(e.tone)))}case"spacer":return ce(t.createElement("div"),{height:(w=br[e.size])!=null?w:br.md});case"divider":return ce(t.createElement("hr"),{border:"none","border-top":`1px solid ${(h=L==null?void 0:L.border)!=null?h:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(A){return null}}function Er(e,t,n,r){try{let o=new Set;for(let i of Array.from(e.children)){let s=i.getAttribute(Qe);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 l=wr(s,r);if(!l)continue;let u=r.createElement("div");u.setAttribute(Qe,i),u.style.display="none",u.appendChild(l),e.appendChild(u)}let a=n!==void 0&&t[n]!==void 0;for(let i of Array.from(e.children)){let s=i.getAttribute(Qe),l=i;s!==null?l.style.display=a&&s===n?"":"none":a?l.hasAttribute(ve)||(l.setAttribute(ve,l.style.display),l.style.display="none"):l.hasAttribute(ve)&&(l.style.display=l.getAttribute(ve),l.removeAttribute(ve))}}catch(o){}}function hi(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(Qe)!==null){n.remove();continue}n.hasAttribute(ve)&&(n.style.display=n.getAttribute(ve),n.removeAttribute(ve))}}catch(t){}}function At(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${Qe}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${ve}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||hi(r)}catch(n){}}function an(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function xt(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 kt(e,t,n,r){var o;for(let[a,i]of Object.entries(t)){let s=e[a];if(!s||typeof s=="string")continue;let l=an(i.target,n);for(let u of l)for(let[c,d]of Object.entries(s))(o=i.dims[c])!=null&&o.includes(d)&&(u.setAttribute(`data-${c}`,d),r==null||r(u,`data-${c}`))}}function Ct(e,t,n,r){for(let[o,a]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!a.arms||!a.arms.includes(i))continue;let s=an(a.target,n);for(let l of s)l.setAttribute("data-sentient-arm",i),r==null||r(l,"data-sentient-arm")}}function _t(e,t,n,r){var s,l,u,c;let o=new Set,a=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[d,m]of Object.entries(t)){if(wt(m.locator,n))continue;let C;if(m.locator){let g=ye(m.locator,n);C=g?[g]:[],!g&&Et(m.locator,n)&&i.push(d)}else C=an(m.target,n);let p=e[d];for(let g of C){if(p!==void 0)if(typeof p=="string")g.setAttribute("data-sentient-arm",p),(l=r==null?void 0:r.onAttr)==null||l.call(r,g,"data-sentient-arm"),a&&((u=r==null?void 0:r.onApplied)==null||u.call(r,d,p,g));else for(let[v,O]of Object.entries(p))g.setAttribute(`data-${v}`,O),(c=r==null?void 0:r.onAttr)==null||c.call(r,g,`data-${v}`);if(m.blocks&&!vi(n)){let v=Object.fromEntries(Object.entries(m.blocks).filter(([,O])=>!bt(O)));Object.keys(v).length>0&&(Er(g,v,typeof p=="string"?p:void 0,n),o.add(g))}if(!a)continue;let _=g.textContent;typeof m.content=="string"&&(g.textContent=m.content),m.ops&&yr(g,m.ops,d,n).anchorMiss&&!i.includes(d)&&i.push(d),tn(g,De(j(j({previous:_},typeof p=="string"?{arm:p}:{}),(r==null?void 0:r.persona)!==void 0?{persona:r.persona}:{}),{doc:n}))}}return At(n,o),i}var yi=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function vi(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:yi.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var bi=800;function Ot(e,t,n){let r=[];return n.forEach(({slotId:o,arm:a,el:i},s)=>{r.push(Je((m,C={})=>{try{e.track({projectId:t,componentId:o,variantId:a,eventType:"micro_signal",payload:j({signalType:m},C)})}catch(p){}},i,void 0,{tabLoss:s===0}));let l=null,u=0,c=()=>{u=Date.now(),l=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(m){}l=null},bi)},d=()=>{l!==null&&(clearTimeout(l),l=null)};i.addEventListener("mouseenter",c),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",c),i.removeEventListener("mouseleave",d),l!==null&&clearTimeout(l)})}),()=>{for(let o of r)o()}}function Si(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 xr(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var wi="_snt_fired_goals";function kr(e,t){try{e==null||e.sessionStorage.removeItem(xr(t)),e==null||e.sessionStorage.removeItem(wi)}catch(n){}}function Ar(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function Ei(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 Ai(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function It(e,t,n,r){var v,O;let o=(v=n.defaultView)!=null?v:typeof window!="undefined"?window:null,a=xr(r),i=Ei(o,a),s=b=>{let w=Ar(b);if(!i.has(w))try{b.slotId?t.componentGoal(b.slotId,b.goalId):t.goal(b.goalId),i.add(w),Ai(o,a,i)}catch(h){}},l=e.filter(b=>b.event==="click"),u=e.filter(b=>b.event==="form_submit"),c=e.filter(b=>b.event==="url_reached"),d=e.filter(b=>b.event==="scroll_depth"),m=(b,w)=>{if(!b.locator)return!1;let h=ye(b.locator,n);return!!h&&(h===w||h.contains(w))},C=b=>{let w=b.target;if(!(!w||typeof w.closest!="function"))for(let h of l)m(h,w)&&s(h)},p=b=>{let w=b.target;if(w)for(let h of u)m(h,w)&&s(h)},g=()=>{if(c.length===0)return;let b=Ze(n);for(let w of c)w.urlPattern&&Si(w.urlPattern,b)&&s(w)},_=()=>{var h;let b=n.documentElement,w=b.scrollHeight>0?(b.scrollTop+b.clientHeight)/b.scrollHeight:0;for(let A of d)w>=((h=A.threshold)!=null?h:.75)&&s(A);d.every(A=>i.has(Ar(A)))&&n.removeEventListener("scroll",_)};return n.addEventListener("click",C,!0),n.addEventListener("submit",p,!0),(O=n.defaultView)==null||O.addEventListener("popstate",g),g(),d.length>0&&(n.addEventListener("scroll",_,{passive:!0}),_()),{checkUrl:g,teardown:()=>{var b;n.removeEventListener("click",C,!0),n.removeEventListener("submit",p,!0),(b=n.defaultView)==null||b.removeEventListener("popstate",g),d.length>0&&n.removeEventListener("scroll",_)}}}function Lt(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),a=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(a.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return a}var Cr="__snt_editor_token";function _r(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Cr):null}catch(e){return null}}function Or(e){try{sessionStorage.setItem(Cr,e)}catch(t){}}var ot="0.28.0",Pt=ot!=="0.0.0-dev"?{name:"snippet",version:ot}:void 0,$r=ot!=="0.0.0-dev"?{v:ot}:{},Dt=5e3,xi=50,Br=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),Q=null,U=null,de={},ue=null,X=null,xe=null,te=null,he=null,V=null,Le=null,Ir=!1,ln=null,Tt=null,Mt=null,Te=!1,tt=!1,ke=!1,$t=null,Ce=[],Bt=null,nt=null,ae=null,ki=3e3,Ci=100;function Nt(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 me(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function je(e,t){return Q?(Q.personaAttributes&&V&&xt(V.persona,V.band,e,t==null?void 0:t.onAttr),kt(de,Q.slots,e,t==null?void 0:t.onAttr),Ct(de,Q.slots,e,t==null?void 0:t.onAttr),ue?_t(de,ue,e,j(j({},t),V?{persona:V.persona}:{})):(At(e,new Set),[])):[]}function Nr(e){var n;let t=new Map;for(let r of(n=Q==null?void 0:Q.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function cn(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=Lt(e,Nr(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function _i(e,t,n){let r=(o,a)=>t.some(([i,s])=>i===o&&s===a);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[a,i,s]=o;!a||typeof i!="string"||r(a,i)||(s==null?a.removeAttribute(i):a.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 Oi(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function Kr(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function Kt(e){var t;return(t=e.apiBase)!=null?t:"https://api.sentient-ui.com"}function Ii(e){return Promise.resolve().then(()=>fetch(`${Kt(e)}/v1/registry/locators`,{headers:{authorization:`Bearer ${e.apiKey}`}})).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t==null?void 0:t.slots)?t.slots:null).catch(()=>null)}function jr(e,t){let n=[],r=[];for(let o of e)try{if(typeof(o==null?void 0:o.id)!="string")continue;!o.locator||dr(o.locator,t)?n.push(o.id):Et(o.locator,t)&&r.push(o.id)}catch(a){}return[n,r]}function Gr(e,t){let n=null;for(let r of t)e!=null&&e[r]&&((n!=null?n:n={})[r]=e[r]);return n}function Ur(){!$t||!Te||Bt===window.location.pathname||(Bt=window.location.pathname,Li())}function Li(){ae==null||ae();let e=Q,t=$t;if(!e||!t)return;let n,r,o=()=>{clearTimeout(n),clearTimeout(s),r==null||r.disconnect(),ae===o&&(ae=null)},a=null,i=l=>{let[u,c]=jr(t,document),d=u.filter(m=>!Ce.includes(m));a!==null&&u.some(m=>!a.has(m)&&!d.includes(m))&&it(),a=new Set(u),d.length>0&&Ti(d).catch(()=>{}),(l||c.length===0&&!t.some(m=>!u.includes(m.id)&&!Ce.includes(m.id)))&&(o(),Fr(e,c))},s=setTimeout(()=>i(!0),ki);if(ae=o,i(),ae===o)try{r=new MutationObserver(()=>{clearTimeout(n),n=setTimeout(i,Ci)}),r.observe(document.documentElement,{childList:!0,subtree:!0})}catch(l){}}async function Ti(e){let t=Q,n=U;if(!t||!n)return;Ce=Ce.concat(e);let r=await Nt(n.decide(j({slotsFrom:"registry",registrySlotIds:e},$r)),Dt);if(r||(Ce=Ce.filter(a=>!e.includes(a))),!r||ke||U!==n)return;de=j(j({},de),r.slots);let o=Gr(r.slotConfig,e);o&&(ue=j(j({},ue),o)),it(),me(t,"late decide",e),nt&&Ne(t.apiKey,nt=j(De(j({},nt),{slots:de,savedAt:Date.now()}),ue?{slotConfig:ue}:{}))}function Fr(e,t){if(t.length!==0)try{fetch(`${Kt(e)}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(n){}}function Ge(){return!!(Q&&U&&Q.sectionCapture!==!1&&(Q.consent!==!1||tt)&&!Ie())}function Ri(){if(!U||!Q||!Ge()||he)return;let e=[];je(document,{contentAndOps:Te,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),dn();try{te==null||te(),te=Ot(U,Q.apiKey,e)}catch(t){}}function dn(){if(typeof document=="undefined"||!Ge())return;let e;try{if(Tt&&Tt.length>0){let t=new Map;for(let n of Tt){if(n.urlMatch!==window.location.pathname)continue;let r=ye(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{he=cr(U,j({apiKey:Q.apiKey,apiBase:Q.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Mt=window.location.pathname}catch(t){}}function it(){try{let e=[];if(te==null||te(),te=null,je(document,{contentAndOps:Te,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),cn(Le,document),e.length>0&&Ge())try{te=Ot(U,Q.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Mt!==null&&window.location.pathname!==Mt&&Ge()&&(he==null||he(),he=null,dn())}catch(t){}}catch(e){}}function Lr(){ln===null&&(ln=setTimeout(()=>{ln=null,it();try{X==null||X.checkUrl()}catch(e){}Ur()},xi))}function un(){if(!(Ir||typeof window=="undefined"||typeof history=="undefined")){Ir=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,a){let i=n.call(this,r,o,a!=null?a:null);return Lr(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Lr)}catch(e){}}}function Rt(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 zr(e){return new URLSearchParams(e).get("sentient_editor")}function Pi(){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 Di(e,t){var n,r,o;try{window.__sentientEditor={token:t,apiBase:Kt(e)};try{let s=document.createElement("meta");s.name="referrer",s.content="no-referrer",s.setAttribute("data-sentient-editor",""),((n=document.head)!=null?n:document.documentElement).appendChild(s)}catch(s){}let a=(r=e.editorSrc)!=null?r:Pi();if(!a){Rr();return}let i=document.createElement("script");i.src=a,i.async=!0,i.onerror=()=>Rr(),((o=document.head)!=null?o:document.documentElement).appendChild(i)}catch(a){}}var Tr="sentient-editor-load-notice",qr={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Rr(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Tr))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Tr,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,qr,{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 Wr(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(":"),a=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!a||!i))if(i.includes("=")){let s={};for(let l of i.split(",")){let[u,c]=l.split("=");u&&c&&(s[u]=c)}Object.keys(s).length&&(n[a]=s)}else n[a]=i}return Object.keys(n).length?n:null}function Hr(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Pr="sentient-persona-preview-banner";function Dr(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Pr))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Pr,o.setAttribute("role","status"),Object.assign(o.style,qr,{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 a=document.createElement("span");a.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(a),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Mi(e,t){var u,c,d,m,C,p,g,_,v;let n=Kt(e),o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([O,b])=>({id:O,dims:b.dims}))},a=await Nt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(O=>O.ok?O.json():null).catch(()=>null),Dt);if(!a){rt(e),me(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=a;de=(c=i.slots)!=null?c:{},ue=(d=i.slotConfig)!=null?d:null,et(i.palette);let s=(p=(C=(m=i.personaAttributes)==null?void 0:m.persona)!=null?C:i.persona)!=null?p:t,l=(_=(g=i.personaAttributes)==null?void 0:g.confidence)!=null?_:"high";V={persona:s,band:l},je(document),Te=!0,un(),rt(e),i.recognized===!1?Dr(t,!0):Dr((v=i.personaDisplay)!=null?v:s)}function rt(e){let t={goal(n,r){try{U==null||U.goal(n,r)}catch(o){}},componentGoal(n,r){try{U==null||U.componentGoal(n,r)}catch(o){}},grantConsent(){try{!U&&ke?(U=Ye(j({apiKey:e.apiKey,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:Kr(e)},Pt?{sdk:Pt}:{})),xe&&xe.length>0&&(X==null||X.teardown(),X=It(xe,U,document,e.apiKey))):(nn(e.apiKey),U&&xe&&xe.length>0&&(X==null||X.teardown(),X=It(xe,U,document,e.apiKey))),ke=!1}catch(n){}tt=!0;try{Ri()}catch(n){}},revokeConsent(){try{he==null||he(),he=null,Mt=null,te==null||te(),te=null,ae==null||ae(),X==null||X.teardown(),X=null,kr(typeof window!="undefined"?window:null,e.apiKey),tt=!1,ke=!0,U==null||U.destroy(),U=null}catch(n){}},reapply:it,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=V==null?void 0:V.persona)!=null?n:null,band:(r=V==null?void 0:V.band)!=null?r:null,slots:de,matchCounts:Rt(e),consent:!ke&&(e.consent!==!1||tt)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of Br.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Mr(){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})},Br.length=0}catch(t){}}async function Vr(){var e,t;try{let n=St(window.sentient);if(!n){Mr();return}Q=n,Te=!1,Le=null,et(null),tt=!1,ke=!1,xe=null,$t=null,Ce=[],Bt=null,nt=null,ae==null||ae();let r=typeof window!="undefined"?zr(window.location.search):null;if(r){Or(r);try{let h=new URL(window.location.href);h.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",h.pathname+h.search+h.hash)}catch(h){}}let o=r!=null?r:_r();if(o){Di(n,o),rt(n),me(n,"editor mode");return}let a=typeof window!="undefined"?Wr(window.location.search):null;if(a){de=a,V=null,je(document),un(),rt(n),me(n,"preview mode",a);return}let i=typeof window!="undefined"?Hr(window.location.search):null;if(i){await Mi(n,i),me(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0;n.registry===void 0&&!s&&me(n,"slots declared without registry: true, so dashboard-published components are not applied");let l=s?Ii(n):null,u=Oi();try{(t=u==null?void 0:u.stop)==null||t.call(u)}catch(h){}let c=Ve(n.apiKey),d=[];c&&(V={persona:c.persona,band:c.band},de=c.slots,c.slotConfig&&(ue=c.slotConfig),c.palette&&et(c.palette),je(document,j({contentAndOps:!1},u?{onAttr:(h,A)=>d.push([h,A])}:{})),c.layoutOrder&&(Le=c.layoutOrder,cn(Le,document))),u&&_i(u,d,document);let m=Ye(j({apiKey:n.apiKey,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:Kr(n)},Pt?{sdk:Pt}:{}));U=m,rt(n),un();let C=Object.entries(n.slots).map(([h,A])=>({id:h,dims:A.dims})),p=$r,g={pp:u?u.v:0},_=Array.from(Nr(document).keys()),v=[];if(l){let[h]=await Promise.all([Nt(l,Dt),document.readyState==="loading"?new Promise(A=>document.addEventListener("DOMContentLoaded",A,{once:!0})):null]);$t=h,h&&(Ce=v=jr(h,document)[0]),me(n,"registry scope",h&&v)}let O=m.decide(j(j(j(j({slots:C},p),g),_.length>=2?{sections:_}:{}),s?{slotsFrom:"registry",registrySlotIds:v}:{})),b=await Nt(O,Dt),w=h=>{var F,M,q,W,ne;let A=m.getPersona();A?V={persona:A.persona,band:A.band}:h.persona&&(V={persona:h.persona,band:"low"}),de=h.slots,s?ue=Gr(h.slotConfig,v):h.slotConfig&&(ue=h.slotConfig),h.palette&&et(h.palette),Le=(F=h.layoutOrder)!=null?F:Le;let E=()=>{let fe=[],S=je(document,{onApplied:(T,Y,ee)=>fe.push({slotId:T,arm:Y,el:ee})});if(s||Fr(n,S),cn(Le,document),Te=!0,Ge())try{te==null||te(),te=Ot(U,n.apiKey,fe)}catch(T){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E,{once:!0}):E(),xe=(M=h.goals)!=null?M:null,h.goals&&h.goals.length>0&&n.consent!==!1&&U)try{X==null||X.teardown(),X=It(h.goals,U,document,n.apiKey)}catch(fe){}Tt=(q=h.sectionMap)!=null?q:null,Ge()&&dn(),me(n,"applied",{persona:V,slots:de,matches:Rt(n)}),!ke&&(Ne(n.apiKey,nt=j(j({v:1,persona:(W=V==null?void 0:V.persona)!=null?W:h.persona,band:(ne=V==null?void 0:V.band)!=null?ne:"low",slots:h.slots,layoutOrder:h.layoutOrder,savedAt:Date.now()},ue?{slotConfig:ue}:{}),h.palette?{palette:h.palette}:{})),Bt=null,Ur())};if(!b){me(n,"decide timeout/null \u2014 snapshot state stands",Rt(n)),O.then(h=>{!h||Te||ke||U!==m||(w(h),me(n,"late decide applied",Rt(n)))}).catch(()=>{});return}w(b)}catch(n){Mr()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{Vr()}))}return oo($i);})();
|
|
1
|
+
"use strict";var SentientSnippet=(()=>{var St=Object.defineProperty,yo=Object.defineProperties,vo=Object.getOwnPropertyDescriptor,bo=Object.getOwnPropertyDescriptors,wo=Object.getOwnPropertyNames,On=Object.getOwnPropertySymbols;var Ln=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable;var In=(e,t,n)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||(t={}))Ln.call(t,n)&&In(e,n,t[n]);if(On)for(var n of On(t))So.call(t,n)&&In(e,n,t[n]);return e},Te=(e,t)=>yo(e,bo(t));var Tn=(e,t)=>()=>(e&&(t=e(e=0)),t);var Rn=(e,t)=>{for(var n in t)St(e,n,{get:t[n],enumerable:!0})},Eo=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wo(t))!Ln.call(e,o)&&o!==n&&St(e,o,{get:()=>t[o],enumerable:!(r=vo(t,o))||r.enumerable});return e};var Ao=e=>Eo(St({},"__esModule",{value:!0}),e);var xo,ko,Co,Pn,_o,Oo,Nn,B,Re,tt=Tn(()=>{"use strict";xo=Object.defineProperty,ko=Object.defineProperties,Co=Object.getOwnPropertyDescriptors,Pn=Object.getOwnPropertySymbols,_o=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable,Nn=(e,t,n)=>t in e?xo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,B=(e,t)=>{for(var n in t||(t={}))_o.call(t,n)&&Nn(e,n,t[n]);if(Pn)for(var n of Pn(t))Oo.call(t,n)&&Nn(e,n,t[n]);return e},Re=(e,t)=>ko(e,Co(t))});var Wn={};Rn(Wn,{LOCAL_ENGINE_AVAILABLE:()=>Po,createLocalEngine:()=>No});function No(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Po,Hn=Tn(()=>{"use strict";Po=!1});var ys={};Rn(ys,{applyPersonaAttributes:()=>Mt,applyRegistrySlots:()=>Kt,applySlotArms:()=>Bt,applySlotAttributes:()=>$t,parseEditorToken:()=>uo,parsePersonaPreview:()=>po,parsePreview:()=>fo,parseSnippetConfig:()=>Tt,planReorder:()=>Gt,reapply:()=>ht,run:()=>mo,version:()=>ft});tt();function Et(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Dn(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 Zt(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 Et(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[a,i]of Object.entries((n=e.dims)!=null?n:{}))o[a]=(r=i[0])!=null?r:"";return Et(o)}function Mn(e,t){var n,r;return e.dims!=null?(r=(n=Dn(t))!=null?n:Dn(Zt(e)))!=null?r:{}:t}function $n(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 $e(e){return e>=.3?e<.7?"medium":"high":"low"}function At(e){return e?`_${e.slice(0,12)}`:""}var Io="_snt_uid";function Bn(e){return`${Io}${At(e)}`}var Lo=["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 Kn(e){return To(e)!==null}function To(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Lo.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function jn(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 Un(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 Gn(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var Ro=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function Fn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,a])=>{let i=Array.isArray(a)?a[0]:a;return i===void 0?[]:[[o,i]]});for(let[o,a]of r)o.startsWith("utm_")?o in t||(t[o]=a):Ro.includes(o)&&(o in n||(n[o]=a))}catch(r){}return{utmParams:t,clickIds:n}}function zn(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Qt(e){return B(B(B({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 en(e){let t=Qt(e);return Mn(t,Zt(t))}function Vn(e){return typeof e=="string"?e:Et(e)}tt();function Qn(){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 Do="_snt_uid",Mo=365,xt="_snt_uid";function $o(){return Qn()}function qn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Bo(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function tn(e){try{return localStorage.getItem(e)}catch(t){return null}}function Jn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Yn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Ko(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function jo(e){try{sessionStorage.removeItem(e)}catch(t){}}function Uo(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 Go(e){try{localStorage.removeItem(e)}catch(t){}}function Fo(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var zo={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function er(e){var t,n,r,o,a,i,s;if(typeof window=="undefined")return zo;let c=At(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Bn(e==null?void 0:e.apiKey),l=`${xt}${c}`,d=`${xt}_tomb${c}`,h=((n=e==null?void 0:e.cookieTTLDays)!=null?n:Mo)*24*60*60,C=b=>b&&b.length>0?b:null,f=()=>{var b,g;return c&&!(e!=null&&e.cookieName)&&tn(d)===null?(g=(b=C(qn(Do)))!=null?b:C(tn(xt)))!=null?g:C(Yn(xt)):null},m=(s=(i=(a=(o=(r=C(qn(u)))!=null?r:C(tn(l)))!=null?o:C(Yn(l)))!=null?a:f())!=null?i:C(e==null?void 0:e.ssrSessionId))!=null?s:$o();Bo(u,m,h);let A=Jn(l,m),y=Uo(u),E=A?!1:Ko(l,m),w=!A&&!y&&!E;return{getSessionId:()=>m,isEphemeral:()=>w,destroy:()=>{m=null,Fo(u),Go(l),jo(l),c&&!(e!=null&&e.cookieName)&&Jn(d,"1")}}}function Ge(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ln(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 tr(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 Fe(e,t,n){try{let r=(()=>{try{let a=localStorage.getItem(n);if(!a)return[];let i=JSON.parse(a);return Array.isArray(i)?i:[]}catch(a){return[]}})(),o=new Map;for(let a of r)o.set(a.id,a);for(let a of e)o.set(a.id,a);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function nr(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),a=r.filter(i=>!o.has(i.id));if(a.length===r.length)return;a.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(a))}catch(n){}}var Vo=500,Wo=56*1024;function rr(e){return`_snt_retry_${e.slice(0,12)}`}var Ho={push:()=>{},flush:()=>{},destroy:()=>{}};function qo(e){var t,n,r;if(typeof window=="undefined")return Ho;let o=(t=e.flushIntervalMs)!=null?t:5e3,a=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,c=e.apiKey,u=rr(c),l=[],d=new Set,h=[],C=x=>{for(let D of x)f.delete(D),!d.has(D)&&(d.add(D),h.push(D));for(;h.length>Vo;){let D=h.shift();D&&d.delete(D)}nr(x,u)},f=new Set,m=()=>{for(;l.length>i;){let x=l.shift();x&&f.delete(x.id)}},A=x=>{d.has(x.id)||f.has(x.id)||(f.add(x.id),l.push(x),m())},y=x=>{for(let D of x)d.has(D.id)||(f.add(D.id),l.push(D));m()},E=tr(u,i);for(let x of E)A(x);let w=0,b=0,g=(x,D=!0)=>{if(x.length===0)return;let X=JSON.stringify(x),Y=x.map(L=>L.id),ie;try{ie=fetch(s,{method:"POST",keepalive:!0,body:X,headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`}})}catch(L){Fe(x,i,u),y(x),b++,w=Date.now()+Ge(b);return}let Z=L=>{if(ln(L)!=="retry"){if(!L.ok&&D){let _=x.filter(U=>U.eventType!=="pageview");if(_.length>0&&_.length<x.length){C(x.filter(U=>U.eventType==="pageview").map(U=>U.id)),g(_,!1);return}}C(Y),b=0,w=0;return}Fe(x,i,u),y(x),b++,w=Date.now()+Ge(b)};ie instanceof Promise?ie.then(Z).catch(()=>{Fe(x,i,u),y(x),b++,w=Date.now()+Ge(b)}):Z(ie)},P=typeof TextEncoder!="undefined"?new TextEncoder:null,I=x=>P?P.encode(x).length:x.length,F=x=>{let D=[],X=2;for(let Y of x){let ie=I(JSON.stringify(Y))+1;if(D.length>0&&X+ie>Wo||D.length>=a)break;D.push(Y),X+=ie}return D},S=()=>{try{if(Date.now()<w)return;for(;l.length>0&&!(Date.now()<w);){let x=l.filter(X=>!d.has(X.id));if(l.length=0,x.length===0)break;let D=F(x);if(D.length===0)break;D.length<x.length&&l.push(...x.slice(D.length)),g(D)}}catch(x){}},J=!0,z=null;z=setInterval(()=>{J&&S()},o);let K=()=>{document.visibilityState==="hidden"&&S()},oe=()=>{S()};return document.addEventListener("visibilitychange",K),window.addEventListener("pagehide",oe),{push(x){A(x),l.length>=a&&S()},flush:S,destroy(){J=!1,z!==null&&(clearInterval(z),z=null),document.removeEventListener("visibilitychange",K),window.removeEventListener("pagehide",oe),S()}}}var Jo=200;function or(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Yo={send:()=>{},flush:()=>{},destroy:()=>{}};function Xo(e){var t,n,r;if(typeof window=="undefined")return Yo;let o=(t=e.flushIntervalMs)!=null?t:5e3,a=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=or(e.apiKey),c=[],u=new Set,l=new Set,d=[],h=0,C=0,f=!1,m=I=>{for(u.delete(I.id),l.has(I.id)||(l.add(I.id),d.push(I.id));d.length>Jo;){let F=d.shift();F&&l.delete(F)}nr([I.id],s)},A=I=>{Fe([I],a,s),!l.has(I.id)&&!u.has(I.id)&&(u.add(I.id),c.push(I)),Date.now()>=h&&(C++,h=Date.now()+Ge(C))},y=I=>{let F;try{F=fetch(e.url,{method:"POST",keepalive:!0,body:I.body,headers:e.headers})}catch(J){A(I);return}let S=J=>{var z;let K=ln(J);if(K==="retry"){A(I);return}K==="dropped"&&((z=e.onDrop)==null||z.call(e,I,J.status)),m(I),C=0,h=0};F instanceof Promise?F.then(S).catch(()=>A(I)):S(F)},E=()=>{try{if(f||Date.now()<h)return;let I=0;for(;c.length>0&&I<i&&!(Date.now()<h);){let F=c.shift();u.delete(F.id),!l.has(F.id)&&(I++,y(F))}}catch(I){}},w=tr(s,a);for(let I of w)u.has(I.id)||(u.add(I.id),c.push(I));w.length>0&&Fe(w,a,s);let b=setInterval(E,o),g=()=>{document.visibilityState==="hidden"&&E()},P=()=>E();return document.addEventListener("visibilitychange",g),window.addEventListener("pagehide",P),{send(I){if(!f&&!(l.has(I.id)||u.has(I.id))){if(Date.now()<h){Fe([I],a,s),u.add(I.id),c.push(I);return}y(I)}},flush:E,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",g),window.removeEventListener("pagehide",P),E(),f=!0}}}var Zo=1800*1e3;function kt(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Qo(e=Zo,t){let n=new Map,r=`_snt_asgn${At(t)}_`,o=(c,u)=>`${r}${encodeURIComponent(c)}:${encodeURIComponent(u)}`,a=c=>{let u=c.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 c=[];for(let u=0;u<localStorage.length;u++){let l=localStorage.key(u);l!=null&&l.startsWith(r)&&c.push(l)}return c}catch(c){return[]}},s=c=>c.assignedAt+(c.ttlMs&&c.ttlMs>0?c.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let c of i())try{let u=localStorage.getItem(c);if(!u)continue;let l=JSON.parse(u);if(s(l)){localStorage.removeItem(c);continue}let d=a(c);if(!d)continue;n.set(kt(d.componentId,d.segment),l)}catch(u){}})(),{get(c,u){let l=n.get(kt(c,u));return l?s(l)?(n.delete(kt(c,u)),null):l:null},set(c,u,l){let d=kt(c,u);n.set(d,l);try{localStorage.setItem(o(c,u),JSON.stringify(l))}catch(h){}},clear(){n.clear();for(let c of i())try{localStorage.removeItem(c)}catch(u){}}}}var Ot="_snt_snap:",ei=["low","medium","high"];function rt(e){try{let t=localStorage.getItem(Ot+e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!ei.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)))return null;let r=n.vocabulary;return r!==void 0&&(typeof r!="object"||r===null||!Array.isArray(r.entries)||!Array.isArray(r.images))&&delete n.vocabulary,n}catch(t){return null}}function Ve(e,t){try{localStorage.setItem(Ot+e,JSON.stringify(t))}catch(n){}}var sn="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",ir="[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.",Xn=!1,Ct=!1;function ti(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function ni(e){var t;let n=er({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=ti(),a=Promise.resolve().then(()=>(Hn(),Wn)).then(l=>{let d=l;return d.LOCAL_ENGINE_AVAILABLE?(Xn||(Xn=!0,console.info(ir)),d):(Ct||(Ct=!0,console.error(sn)),null)}).catch(()=>(Ct||(Ct=!0,console.error(sn)),null)),i=null,s={low:.15,medium:.5,high:.85},c=(()=>{var l;if(e.initialPersona)return B({},e.initialPersona);let d=rt(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=$e(l.confidence))}return{isLocal:!0,async decide(l){var d,h,C;let f=await a;if(!f)return null;let m=f.createLocalEngine({sessionId:r,forcedPersona:o}).decide(l);return i=Re(B({},m),{layoutOrder:(h=(d=m.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?h:null,slots:B(B({},(C=i==null?void 0:i.slots)!=null?C:{}),m.slots)}),Ve(e.apiKey||"local",{v:1,persona:i.persona,band:$e(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(m),m},getSlotResult(l){var d,h,C;return(C=(h=i==null?void 0:i.slots[l])!=null?h:(d=e.initialSlots)==null?void 0:d[l])!=null?C:null},getSlotConfig(l){var d,h;return(h=(d=e.initialSlotConfig)==null?void 0:d[l])!=null?h:null},getSitePalette(){var l;return(l=e.initialPalette)!=null?l:null},reportSlots(){},getPersona(){let l=i!=null?i:c;return l?{persona:l.persona,confidence:l.confidence,band:$e(l.confidence)}:null},async assign(l,d){var h;let C=await a;return!C||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(h=C.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:l,variantIds:d}]}).assignments[l])!=null?h:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var It=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function nn(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function un(e,t){if(e===void 0||!It.test(e))return!1;if(e==="*")return!0;let n=nn(t);if(e.endsWith("/*")){let r=nn(e.slice(0,-2));return n.startsWith(r==="/"?"/":`${r}/`)&&n!==r}return n===nn(e)}function ot(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(ot):!1}var Zn="sentient-reveal",ze="sentient-revealed";var rn=!1;function ri(e){if(rn||e.getElementById(Zn)){rn=!0;return}let t=e.createElement("style");t.id=Zn,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${ze}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${ze}{animation:${ze} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),rn=!0}function cn(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;ri(r),e.classList.remove(ze),e.offsetWidth,e.classList.add(ze);let o=()=>{e.classList.remove(ze),e.removeEventListener("animationend",o)};return e.addEventListener("animationend",o),!0}function it(e,t,n,r){let o=[];{let a=!1,i=[],s=()=>{if(a)return;let c=Date.now();for(i.push(c);i.length>0&&c-i[0]>500;)i.shift();i.length>=3&&(a=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let a=!1,i=s=>{if(a||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;a=!0;let c=typeof window!="undefined"?window.getSelection():null,u=c?c.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let a=!1,i=!1,s=null,c=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{a||!i||(c(),s=setTimeout(()=>{!a&&i&&(a=!0,e("scroll_hesitation"))},3e3))},l=()=>{c(),u()},d=C=>{for(let f of C)i=f.intersectionRatio>.3,i?u():c()},h=new IntersectionObserver(d,{threshold:[.3]});h.observe(t),window.addEventListener("scroll",l,{passive:!0}),o.push(()=>{h.disconnect(),window.removeEventListener("scroll",l),c()})}if((r==null?void 0:r.tabLoss)!==!1){let a=!1,i=n!=null?n:Date.now(),s=()=>{if(a||document.visibilityState!=="hidden")return;let c=Date.now()-i;c<15e3&&(a=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let a of o)a()}}function oi(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var sr="https://api.sentient-ui.com/v1/events",we=new Map,ar=null;function ii(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var si=3;function on(){return Qn()}function _t(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function ai(){let e=new WeakMap,t=new Map,n=!1,r=(s,c,u)=>{let l=s.get(c);return u===null?l?!0:(s.set(c,new Set),!1):l?l.has(u)?!0:(l.add(u),!1):(s.set(c,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,a=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,c=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(c,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),c()},u.port2.postMessage(0)}};return{firedBefore(s,c){let u=a();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,c)}let l=r(t,s,c);return!l&&!n&&(n=!0,i()),l}}}var lr=new Set;function li(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,a,i=()=>{if(o)return;let u=_t();!u||u===a||(a=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(...h){let C=l.apply(this,h);return i(),C};r[u]=d,s.push([u,l,d])}window.addEventListener("popstate",i);let c=_t();return c&&lr.has(`${t}:${c}`)?a=c:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,l,d]of s)r[u]===d&&(r[u]=l)}}}var nt={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}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function ui(){try{return Fn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function ur(e){return e.replace(/\/events\/?$/,"")}function Be(){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 dn(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:ar;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=we.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:a,reinit:i}=r;if(!a){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Be())return;let s=(i!=null?i:st)(Re(B({},o),{consent:!0}));a(s);let c=(t=we.get(n))==null?void 0:t.dispose;we.set(n,{config:Re(B({},o),{consent:!0}),upgrade:null,dispose:c})}function ci(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=ur((t=e.ingestUrl)!=null?t:sr),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(f,m,A){if(!n)return Promise.resolve(null);let y=a.get(f);return y?Promise.resolve(y):an(i,f,async()=>{try{let E=new URLSearchParams({componentId:f});for(let g of m!=null?m:[])E.append("variantIds[]",g);let w=await fetch(`${r}/winner?${E.toString()}`,{headers:o});if(!w.ok)return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null;let b={variantId:(await w.json()).variantId,assignmentTtlMs:0};return a.set(f,b),b}catch(E){return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},c=!1,u=new Set,l=[],d=[],h={track:f=>s.track(f),goal:((f,m,A,y)=>s.goal(f,m,A,y)),componentGoal:(f,m,A)=>s.componentGoal(f,m,A),identify:f=>s.identify(f),getAssignment:(f,m)=>s.getAssignment(f,m),assign:(f,m,A,y)=>s.assign(f,m,A,y),decide:f=>s.decide(f),getSlotResult:f=>s.getSlotResult(f),isSlotDecided:f=>{var m,A;return(A=(m=s.isSlotDecided)==null?void 0:m.call(s,f))!=null?A:!0},getSlotConfig:f=>s.getSlotConfig(f),getSitePalette:()=>s.getSitePalette(),getStyleVocabulary:()=>{var f,m;return(m=(f=s.getStyleVocabulary)==null?void 0:f.call(s))!=null?m:null},reportSlots:(f,m,A,y)=>s.reportSlots(f,m,A,y),reportSkeleton:(f,m)=>{var A;return(A=s.reportSkeleton)==null?void 0:A.call(s,f,m)},reportDrift:(f,m,A,y)=>{var E;return(E=s.reportDrift)==null?void 0:E.call(s,f,m,A,y)},requestSlots:(f,m,A)=>{var y;return c?(y=s.requestSlots)==null?void 0:y.call(s,f,m,A):l.push([f,m,A])},decideSlots:f=>{var m;return c?(m=s.decideSlots)==null?void 0:m.call(s,f):d.push(...f)},cancelSlots:f=>{var m;if(c)return(m=s.cancelSlots)==null?void 0:m.call(s,f);let A=new Set(f);for(let y of l)y[0]=y[0].filter(E=>!A.has(E));d=d.filter(y=>!A.has(y.id))},onSlotsChanged:f=>(u.add(f),()=>{u.delete(f)}),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),flush:()=>s.flush(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function C(f){var m,A,y;s=f,c=!0,(m=f.onSlotsChanged)==null||m.call(f,()=>u.forEach(E=>E()));for(let[E,w,b]of l.splice(0))E.length>0&&((A=f.requestSlots)==null||A.call(f,E,w,b));d.length>0&&((y=f.decideSlots)==null||y.call(f,d.splice(0)))}return{proxy:h,setInner:C}}function an(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 st(e){var t,n,r,o,a,i,s,c,u,l;if(typeof window=="undefined")return nt;ar=e.apiKey||"local";let d=we.get(e.apiKey||"local");if(d!=null&&d.dispose)try{d.dispose()}catch(p){}let h=e.respectDoNotTrack!==!1&&Be(),C=e.consent===!1||h,f=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!f&&e.localMode!==!1)return we.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."}),C?nt:ni(e);if(C){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."),we.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."}),nt;let{proxy:p,setInner:v}=ci(e);return we.set(e.apiKey,{config:e,upgrade:h?null:v}),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."),nt;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),nt;let m=(t=e.ingestUrl)!=null?t:sr,A=Date.now(),y=er({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),E=Qo(void 0,e.apiKey),w=qo({ingestUrl:m,apiKey:e.apiKey}),b=ur(m),g={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},P=new Set,I=Xo({url:`${b}/goals`,apiKey:e.apiKey,headers:g,onDrop:(p,v)=>{if(!e.debug){if(P.has(v))return;P.add(v)}console.warn(`[sentient] goal dropped (HTTP ${v}) \u2014 this will not be retried. `+(v===400?"The session was not found: call init() and let the session upsert complete before firing goals.":v===401||v===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),F=jn((n=navigator.userAgent)!=null?n:""),S=window.location.origin,J=Un((r=document.referrer)!=null?r:"",S),z=(o=e.sessionSegment)!=null?o:`${F}:${J}`,K=new Map,oe=new Map,x=new Map,D=new Set,X=new Map,Y=null,ie=null,Z=null,L=new Set,_=new Set,U=new Map,Q=new Map,T=new Set,re=new Set,be=new Set,me=null,yt=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,wn=new Set,vt=new Set,bt=new Set,Ze=new Map,qt=null,wt=new Set,Qe=new Map,Jt=null,go=2,Sn=new Map,Yt=!1,En=(p,v,M)=>{var W;let G=new Set,k=1;for(let O of p){v.delete(O);let $=((W=Sn.get(O))!=null?W:0)+1;Sn.set(O,$),$<=go&&(G.add(O),$>k&&(k=$))}G.size>0&&setTimeout(()=>{Yt||M(G)},Ge(k))},An=p=>{for(let v of p)x.has(v.id)||x.set(v.id,en(v))};if(e.initialSlots)for(let[p,v]of Object.entries(e.initialSlots))x.set(p,v),D.add(p);if(e.initialSlotConfig)for(let[p,v]of Object.entries(e.initialSlotConfig))X.set(p,v);e.initialPalette&&(Y=e.initialPalette),e.initialVocabulary&&(ie=e.initialVocabulary);let xe=rt(e.apiKey);if(xe){for(let[p,v]of Object.entries(xe.slots))x.has(p)||x.set(p,v);for(let[p,v]of Object.entries((a=xe.slotConfig)!=null?a:{}))X.has(p)||X.set(p,v);!Y&&xe.palette&&(Y=xe.palette),!ie&&xe.vocabulary&&(ie=xe.vocabulary)}let xn={low:.15,medium:.5,high:.85};if(e.initialPersona)Z=B({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?Z={persona:p.sentientPersona,confidence:(s=xn[(i=p.sentientConfidence)!=null?i:"low"])!=null?s:.15}:xe&&(Z={persona:xe.persona,confidence:(c=xn[xe.band])!=null?c:.15})}if(e.initialAssignments)for(let[p,v]of Object.entries(e.initialAssignments))E.set(p,z,{variantId:v,assignedAt:Date.now(),segment:z,confidence:1});let Ie=Promise.resolve(),kn=y.getSessionId();if(kn){let p=Gn((u=document.referrer)!=null?u:""),{utmParams:v,clickIds:M}=ui(),W=B(B(B(B({sessionId:kn,deviceClass:F,trafficSource:J,referrerDomain:p,utmParams:v,clickIds:M,timeOfDay:zn(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:y.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Kn((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}:{}),G=async()=>{for(let k=0;;k++){try{let O=await fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(W),headers:g});if(O.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(O.ok||ln(O)==="dropped")return}catch(O){}if(k>=si){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(O=>setTimeout(O,Ge(k+1)))}};try{Ie=G()}catch(k){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:w});let ho=ai(),et=null,Xt=!1,de={goal(p,v={},M=1,W=0){var G,k,O,$,H,ee,ae;let ue=y.getSessionId();if(!ue)return;let q=ii(v)?v:{metadata:v},ge=[p,(G=q.externalId)!=null?G:"",(k=q.stepIndex)!=null?k:W,(O=q.weight)!=null?O:M].join("\0"),Ee=q.value!==void 0?`${q.value}\0${($=q.currency)!=null?$:""}`:null;if(ho.firedBefore(ge,Ee)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}let pe=on(),N={sessionId:ue,name:p,metadata:(H=q.metadata)!=null?H:{},weight:(ee=q.weight)!=null?ee:M,stepIndex:(ae=q.stepIndex)!=null?ae:W,goalId:pe,value:q.value,currency:q.currency,externalId:q.externalId};e.debug&&console.log("[sentient] goal",N);let fe={id:pe,body:JSON.stringify(N)};Ie.then(()=>I.send(fe))},componentGoal(p,v,M){var W,G,k;let O=y.getSessionId();if(!O)return;let $=E.get(p,z),H=$?null:(W=x.get(p))!=null?W:null;if(!$&&H===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}if(!$&&!D.has(p)){e.debug&&console.warn(`[sentient] componentGoal("${p}"): slot not decided this session \u2014 not attributed`);return}let ee=$?$.variantId:Vn(H),ae={id:on(),sessionId:O,projectId:e.apiKey,componentId:p,variantId:ee,eventType:"goal_achieved",goalType:v,payload:B({reward:(G=M==null?void 0:M.reward)!=null?G:1,goalValue:M==null?void 0:M.value,currency:M==null?void 0:M.currency},(k=M==null?void 0:M.metadata)!=null?k:{}),timestamp:Date.now(),timeInSession:Date.now()-A,path:_t()};e.debug&&console.log("[sentient] componentGoal",ae),Ie.then(()=>w.push(ae))},identify(p){let v=y.getSessionId();v&&Ie.then(()=>{fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:v,userId:p,ephemeral:y.isEphemeral()}),headers:g}).catch(()=>{})})},track(p){let v=y.getSessionId();if(!v||p.eventType==="variant_assigned"&&x.get(p.componentId)!==void 0&&!D.has(p.componentId)&&!E.get(p.componentId,z))return;let M=Re(B({path:_t()},p),{id:on(),sessionId:v,timestamp:Date.now(),timeInSession:Date.now()-A});e.debug&&console.log("[sentient] track",M),Ie.then(()=>w.push(M))},getAssignment(p,v){return E.get(p,v)},async assign(p,v,M,W){let G=y.getSessionId();if(!G)return null;let k=E.get(p,z);if(k&&(v!=null&&v.length||k.content!==void 0)){let O=k.ttlMs&&k.ttlMs>0?Math.max(0,k.assignedAt+k.ttlMs-Date.now()):0;return{variantId:k.variantId,assignmentTtlMs:O,content:k.content}}return an(K,p,async()=>{await Ie;try{let O={sessionId:G,componentId:p,variantIds:v};W!==void 0?O.agentDataByVariant=W:M!==void 0&&(O.agentData=M);let $=await fetch(`${b}/assign`,{method:"POST",body:JSON.stringify(O),headers:g});if(!$.ok)return null;let H=await $.json();return E.set(p,z,B({variantId:H.variantId,assignedAt:Date.now(),segment:z,confidence:1,content:H.content},H.assignmentTtlMs&&H.assignmentTtlMs>0?{ttlMs:H.assignmentTtlMs}:{})),H}catch(O){return null}})},async decide(p){var v,M;let W=y.getSessionId();if(!W)return null;let G=(v=p.slots)!=null?v:[],k={sessionId:W};p.sections&&p.sections.length>0&&(k.sections=p.sections.map($=>({id:$}))),k.components=(M=p.components)!=null?M:[],G.length>0&&(k.slots=G.map(Qt)),p.slotsFrom==="registry"&&(k.slotsFrom="registry",p.registrySlotIds&&(k.registrySlotIds=p.registrySlotIds),p.bootstrap===!1&&(k.bootstrap=!1),p.render&&Object.keys(p.render).length>0&&(k.render=p.render)),p.v&&(k.v=p.v),typeof p.pp=="number"&&(k.pp=p.pp),e.persona&&(k.persona=e.persona);let O=JSON.stringify(k);return an(oe,O,async()=>{var $,H,ee,ae,ue,q,ge,Ee;await Ie;try{let pe=await fetch(`${b}/decide`,{method:"POST",body:O,headers:g});if(!pe.ok)return An(G),null;let N=await pe.json(),fe={};for(let te of G){let ke=($=N.slots)==null?void 0:$[te.id];if(ke!==void 0){fe[te.id]=ke,x.set(te.id,ke),D.add(te.id);continue}let Cn=x.get(te.id);if(Cn!==void 0)fe[te.id]=Cn;else{let _n=en(te);fe[te.id]=_n,x.set(te.id,_n)}}if(N.slots)for(let[te,ke]of Object.entries(N.slots))te in fe||(fe[te]=ke,x.set(te,ke),D.add(te));let Le=Z!=null&&Z.persona!=="unknown";N.persona&&!(N.persona==="unknown"&&Le)?Z={persona:N.persona,confidence:(H=N.confidence)!=null?H:0}:Z||(Z={persona:"unknown",confidence:0});for(let[te,ke]of Object.entries((ee=N.assignments)!=null?ee:{}))E.set(te,z,{variantId:ke,assignedAt:Date.now(),segment:z,confidence:1});if(N.slotConfig)for(let[te,ke]of Object.entries(N.slotConfig))X.set(te,ke);N.palette&&(Y=N.palette),N.vocabulary&&(ie=N.vocabulary);for(let te of(ae=p.registrySlotIds)!=null?ae:[])(ue=N.slotConfig)!=null&&ue[te]||(X.delete(te),x.delete(te),D.delete(te));return Ve(e.apiKey,B(B(B({v:1,persona:Z.persona,band:$e(Z.confidence),slots:Object.fromEntries(x),layoutOrder:(q=N.layoutOrder)!=null?q:null,savedAt:Date.now()},X.size>0?{slotConfig:Object.fromEntries(X)}:{}),Y?{palette:Y}:{}),ie?{vocabulary:ie}:{})),B(B(B(B(B({layoutOrder:(ge=N.layoutOrder)!=null?ge:null,assignments:(Ee=N.assignments)!=null?Ee:{},slots:fe,persona:Z.persona,confidence:Z.confidence},N.slotConfig?{slotConfig:N.slotConfig}:{}),N.goals?{goals:N.goals}:{}),N.sectionMap?{sectionMap:N.sectionMap}:{}),N.palette?{palette:N.palette}:{}),N.vocabulary?{vocabulary:N.vocabulary}:{})}catch(pe){return An(G),null}})},getSlotResult(p){var v;return(v=x.get(p))!=null?v:null},isSlotDecided(p){return D.has(p)},getSlotConfig(p){var v;return(v=X.get(p))!=null?v:null},reportSlots(p,v,M,W){var G;let k={};for(let[O,$]of Object.entries(W!=null?W:{}))for(let H of $){let ee=`${O}|${H.key}`;!yt.test(O)||be.has(ee)||(be.add(ee),((G=k[O])!=null?G:k[O]=[]).push(H))}Object.keys(k).length>0&&fetch(`${b}/slots/observed`,{method:"POST",headers:g,body:JSON.stringify({slotIds:Object.keys(k),authoredArms:k})}).catch(()=>{});for(let O of p)if(!(typeof O!="string"||O.length===0)){if(!yt.test(O)){oi()&&!wn.has(O)&&(wn.add(O),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(O)} 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(!L.has(O)){L.add(O),_.add(O);let $=v==null?void 0:v[O];if(typeof $=="string"){let ee=$.replace(/\s+/g," ").trim().slice(0,400);ee!==""&&U.set(O,ee)}let H=M==null?void 0:M[O];H!==void 0&&Q.set(O,H)}}_.size===0||me!=null||(me=setTimeout(()=>{me=null;let O=[..._];_.clear();for(let $=0;$<O.length;$+=20){let H=O.slice($,$+20),ee={},ae={};for(let ue of H){let q=U.get(ue);q!==void 0&&(ee[ue]=q,U.delete(ue));let ge=Q.get(ue);ge!==void 0&&(ae[ue]=ge,Q.delete(ue))}fetch(`${b}/slots/observed`,{method:"POST",headers:g,body:JSON.stringify(Re(B(B({slotIds:H},Object.keys(ee).length>0?{baselineTexts:ee}:{}),Object.keys(ae).length>0?{baselineSkeletons:ae}:{}),{pagePaths:Object.fromEntries(H.map(ue=>[ue,location.pathname]))}))}).catch(()=>{})}},1e3))},reportSkeleton(p,v){!yt.test(p)||T.has(p)||(T.add(p),fetch(`${b}/slots/observed`,{method:"POST",headers:g,body:JSON.stringify({slotIds:[p],baselineSkeletons:{[p]:v}})}).catch(()=>{}))},reportDrift(p,v,M,W){let G=`${p}|${v}`,k=y.getSessionId();!k||re.has(G)||(re.add(G),fetch(`${b}/slots/drift`,{method:"POST",headers:g,body:JSON.stringify({sessionId:k,reports:[{slotId:p,expectedFp:v,observedFp:M,reason:W}]})}).catch(()=>{}))},requestSlots(p,v,M){var W,G;for(let k of p)bt.has(k)||(bt.add(k),yt.test(k)?Ze.set(k,{text:v==null?void 0:v[k],render:(W=M==null?void 0:M.render)==null?void 0:W[k],skeleton:(G=M==null?void 0:M.skeletons)==null?void 0:G[k]}):de.reportSlots([k]));Ze.size===0||qt!=null||(qt=setTimeout(()=>{qt=null;let k=[...Ze];Ze.clear();for(let O=0;O<k.length;O+=50){let $=k.slice(O,O+50),H={};for(let[ee,ae]of $)ae.render&&(H[ee]=ae.render);de.decide({slotsFrom:"registry",registrySlotIds:$.map(([ee])=>ee),bootstrap:!1,render:H}).then(ee=>{var ae,ue;if(ee){let q={},ge={},Ee=[];for(let[pe,N]of $){let fe=(ae=ee.slotConfig)==null?void 0:ae[pe];if(fe){fe.needsSkeleton&&N.skeleton&&((ue=de.reportSkeleton)==null||ue.call(de,pe,N.skeleton));continue}Ee.push(pe),N.text&&(q[pe]=N.text),N.skeleton&&(ge[pe]=N.skeleton)}Ee.length>0&&de.reportSlots(Ee,q,ge)}else En($.map(([q])=>q),bt,q=>{var ge;let Ee={},pe={},N={};for(let[fe,Le]of $)q.has(fe)&&(Le.text&&(Ee[fe]=Le.text),Le.render&&(pe[fe]=Le.render),Le.skeleton&&(N[fe]=Le.skeleton));(ge=de.requestSlots)==null||ge.call(de,[...q],Ee,{render:pe,skeletons:N})});vt.forEach(q=>q())})}},0))},decideSlots(p){for(let v of p)wt.has(v.id)||(wt.add(v.id),Qe.set(v.id,v));Qe.size===0||Jt!=null||(Jt=setTimeout(()=>{Jt=null;let v=[...Qe.values()];Qe.clear();for(let M=0;M<v.length;M+=30){let W=v.slice(M,M+30);de.decide({slots:W}).then(G=>{G||En(W.map(k=>k.id),wt,k=>{var O;return(O=de.decideSlots)==null?void 0:O.call(de,W.filter($=>k.has($.id)))}),vt.forEach(k=>k())})}},0))},cancelSlots(p){for(let v of p)Ze.delete(v)&&bt.delete(v),Qe.delete(v)&&wt.delete(v)},onSlotsChanged(p){return vt.add(p),()=>{vt.delete(p)}},getStyleVocabulary(){return ie},getSitePalette(){return Y},getPersona(){return Z?{persona:Z.persona,confidence:Z.confidence,band:$e(Z.confidence)}:null},async fetchWeights(){var p;try{let v=await fetch(`${b}/weights`,{headers:g});return v.ok?(p=(await v.json()).components)!=null?p:[]:[]}catch(v){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){w.flush(),I.flush()},dispose(){var p;et==null||et(),Xt=!0,Yt=!0,w.destroy(),I.destroy(),((p=we.get(e.apiKey))==null?void 0:p.dispose)===de.dispose&&we.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;et==null||et(),Xt=!0,Yt=!0,w.destroy(),I.destroy(),y.destroy(),E.clear(),((p=we.get(e.apiKey))==null?void 0:p.dispose)===de.dispose&&we.delete(e.apiKey);try{localStorage.removeItem(Ot+e.apiKey),localStorage.removeItem(rr(e.apiKey)),localStorage.removeItem(or(e.apiKey))}catch(v){}e.debug&&console.log("[sentient] destroyed")}};if(we.set(e.apiKey,{config:e,upgrade:null,dispose:de.dispose}),et=li(de,e.apiKey,p=>{Ie.then(()=>{Xt||lr.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=de)}return de}function di(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function cr(e,t){let n=t>>>0;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function fi(e){let t=e.join("");return cr(t,2166136261)+cr(t,1523705862)}var pi=new Set(["A","BUTTON"]),mi=/^H([1-6])$/,gi=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]);var hi=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function yi(e){return pi.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function vi(e){if(mi.test(e.tagName)||gi.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function bi(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(yi(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||vi(r))return r;return t}function Lt(e,t=40){var n,r,o;let a=e.ownerDocument.createTreeWalker(e,4),i=[];for(let l=a.nextNode();l;l=a.nextNode())if(((n=l.nodeValue)!=null?n:"").trim()!==""&&!hi.has((o=(r=l.parentElement)==null?void 0:r.tagName)!=null?o:"")&&(i.push(l),i.length>120))return{reason:"too_large"};if(i.length===0)return{reason:"empty"};let s=[],c=[];for(let l of i){let d=bi(l,e),h=s.indexOf(d);h===-1&&(s.push(d),h=s.length-1),c.push(h)}if(s.length>t)return{reason:"too_large"};let u=i.map(l=>{var d;return di((d=l.nodeValue)!=null?d:"")});return{textNodes:i,ownerEls:s,leafToNode:c,leaves:u,fp:fi(u)}}var wi=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function fn(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function Si(e){return{tag:e.tagName.toLowerCase(),text:fn(e).slice(0,40)}}function dr(e){return e.replace(/["\\\]]/g,"\\$&")}function at(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function fr(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)),a=[r,...o.map(s=>`${r}.${s}`)];for(let s of a)if(at(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=fr(i,t);if(s){for(let d of a){let h=`${s} > ${d}`;if(at(t,h))return h}let c=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=c.indexOf(e),l=c.some(d=>d!==e&&fn(d)!==fn(e));if(u>=0&&l){let d=`${s} > ${r}:nth-of-type(${u+1})`;if(at(t,d))return d}}}return null}function pr(e,t){let n=Si(e),r=e.getAttribute("id");if(r&&at(t,`#${dr(r)}`))return{v:1,id:r,fingerprint:n};for(let a of wi){let i=e.getAttribute(a);if(i&&at(t,`[${a}="${dr(i)}"]`))return{v:1,dataAttr:{name:a,value:i},fingerprint:n}}let o=fr(e,t);return o?{v:1,selector:o,fingerprint:n}:null}tt();var gr=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Ei={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Ai(e){let t=e.ariaRole?Ei[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 xi(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var ki=[["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]],pn=[["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]],mr={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Ci(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function hr(e){var t,n;let r=Ai(e);if(r)return{type:(t=mr[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of ki)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of pn)if(s.test(e.bodyText))return{type:i,strength:"strong"};let a=xi(e);return{type:(n=mr[a])!=null?n:"generic",strength:"weak"}}function yr(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return B({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Ci(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}tt();var vr=[100,300,1e3,3e3,1e4],_i=250,Oi=1e3,Ii=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function br(e,t){e.n++;let n=t-e.mean;e.mean+=n/e.n,e.m2+=n*(t-e.mean)}var wr=e=>e.n>1?Math.sqrt(e.m2/e.n):0;function Li(e){var t;try{let n=e.createElement("canvas"),r=n.getContext("webgl")||n.getContext("experimental-webgl");if(!r)return"unknown";let o=r.getExtension("WEBGL_debug_renderer_info"),a=o?String((t=r.getParameter(o.UNMASKED_RENDERER_WEBGL))!=null?t:""):"";return a?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(a)?"sw":"hw":"unknown"}catch(n){return"unknown"}}function Ti(e,t=Date.now){var n,r;let o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0,a={n:0,mean:0,m2:0},i={n:0,mean:0,m2:0},s=[0,0,0,0,0,0],c=0,u=0,l=0,d=0,h=0,C=0,f=0,m=0,A=0,y=0,E=-1/0,w=-1/0,b=null,g=null,P=null,I=(r=o==null?void 0:o.scrollY)!=null?r:0,F=0,S=e.hidden?null:t(),J=()=>{let T=t();if(P!=null){let re=T-P,be=0;for(;be<vr.length&&re>=vr[be];)be++;s[be]++}P=T},z=()=>{c++,E=t()},K=()=>{u++,w=t()},oe=()=>{b=t()},x=()=>{b!=null&&(br(a,t()-b),b=null)},D=()=>{let T=t();l++,T-E>_i&&T-w>Oi&&d++,J()},X=()=>{h++},Y=()=>{var T;let re=(T=o==null?void 0:o.scrollY)!=null?T:0;C+=Math.abs(re-I),I=re,J()},ie=T=>{let re=t();f++,(T.key==="Backspace"||T.key==="Delete")&&A++,Ii.has(T.key)&&y++,g!=null&&br(i,re-g),g=re,J()},Z=T=>{let re=T.data;typeof re=="string"&&(m+=re.length),J()},L=()=>{let T=t();e.hidden?S!=null&&(F+=T-S,S=null):S==null&&(S=T)},_={passive:!0,capture:!0};e.addEventListener("mousemove",z,_),e.addEventListener("touchstart",K,_),e.addEventListener("touchmove",X,_),e.addEventListener("mousedown",oe,_),e.addEventListener("mouseup",x,_),e.addEventListener("click",D,_),e.addEventListener("wheel",X,_),e.addEventListener("keydown",ie,_),e.addEventListener("input",Z,_),e.addEventListener("visibilitychange",L),o==null||o.addEventListener("scroll",Y,_);let U=Li(e),Q=(()=>{var T;try{return((T=o==null?void 0:o.matchMedia)==null?void 0:T.call(o,"(prefers-reduced-motion: reduce)").matches)===!0}catch(re){return!1}})();return{snapshot(){var T,re;let be=t(),me=F+(S!=null?be-S:0);return{v:1,active_ms:Math.round(me),mm:c,mm_rate:me>0?Number((c*1e3/me).toFixed(2)):0,touches:u,clicks:l,hold_n:a.n,hold_mean:Math.round(a.mean),hold_std:Math.round(wr(a)),teleport:d,wheel:h,scroll_px:Math.round(C),keydowns:f,input_chars:m,ik_cv:i.mean>0?Number((wr(i)/i.mean).toFixed(2)):0,backspaces:A,gaps:[...s],reduced_motion:Q,kb_nav:y,renderer:U,vp:[(T=o==null?void 0:o.innerWidth)!=null?T:0,(re=o==null?void 0:o.innerHeight)!=null?re:0],dpr:(o==null?void 0:o.devicePixelRatio)||1}},stop(){e.removeEventListener("mousemove",z,_),e.removeEventListener("touchstart",K,_),e.removeEventListener("touchmove",X,_),e.removeEventListener("mousedown",oe,_),e.removeEventListener("mouseup",x,_),e.removeEventListener("click",D,_),e.removeEventListener("wheel",X,_),e.removeEventListener("keydown",ie,_),e.removeEventListener("input",Z,_),e.removeEventListener("visibilitychange",L),o==null||o.removeEventListener("scroll",Y,_)}}}var Ri="section, header, footer, nav, main > div, [data-sentient-section]",Pi=2e4,Ni="__session__";function Di(e){let t=Array.from(e.querySelectorAll(Ri)),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 Mi(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 Sr=()=>{};function Er(e,t){var n,r,o,a,i,s,c,u,l,d,h,C,f,m,A;let y=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!y||typeof IntersectionObserver=="undefined"||Be()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Sr;let E=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),w=Di(y);if(w.length===0)return Sr;let b=new Map,g=[];for(let L of w){let _=(i=[(a=t.sectionTypes)==null?void 0:a[(o=L.getAttribute("data-sentient-id"))!=null?o:""],L.getAttribute("data-sentient-type")].find(me=>gr.includes(me)))!=null?i:null,U=yr(L),Q=(c=_!=null?_:(s=t.typeOf)==null?void 0:s.call(t,L))!=null?c:hr(U).type,T=pr(L,y),re=T?`nc-${Q}-${$n(JSON.stringify({id:(u=T.id)!=null?u:null,dataAttr:(l=T.dataAttr)!=null?l:null,selector:(d=T.selector)!=null?d:null})).toString(36)}`:`nc-${Q}`;b.set(L,re);let be=pn.filter(([,me])=>me.test(U.bodyText)).map(([me])=>me);g.push(Re(B({componentId:re,semanticType:Q,source:_?"markup":"auto"},T?{locator:T}:{}),{observation:B(B({tag:U.tag,idClass:U.idClass.slice(0,200),headingText:U.headingText,textLength:U.textLength,actionCount:U.actionCount},U.ariaRole?{ariaRole:U.ariaRole}:{}),be.length>0?{patternFlags:be}:{})}))}let P=(m=(f=(C=(h=y.defaultView)!=null?h:typeof window!="undefined"?window:void 0)==null?void 0:C.location)==null?void 0:f.pathname)!=null?m:"/";Mi(t.apiKey,E,P,g);let I=Ti(y),F=()=>{let L;try{L=I.snapshot()}catch(_){return}try{e.track({projectId:t.apiKey,componentId:Ni,eventType:"interaction_stats",payload:L})}catch(_){}},S=new Map,J=L=>{let _=S.get(L);return _||(_={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(L,_)),_},z=new IntersectionObserver(L=>{for(let _ of L){let U=b.get(_.target);if(!U)continue;let Q=J(U);_.isIntersecting?(Q.intersecting=!0,Q.enterAt=Date.now(),_.intersectionRatio>Q.scroll&&(Q.scroll=_.intersectionRatio)):(Q.intersecting=!1,Q.enterAt!=null&&(Q.ms+=Date.now()-Q.enterAt,Q.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let L of b.keys())z.observe(L);let K=(L=!1)=>{var _;let U=Date.now();for(let[Q,T]of S)if(T.enterAt!=null&&(T.ms+=U-T.enterAt,T.enterAt=null),!(T.ms<=0)){try{e.track({projectId:t.apiKey,componentId:Q,eventType:"dwell",payload:{dwell_time:Math.round(T.ms),scroll_depth:Number(T.scroll.toFixed(2))}})}catch(re){}T.ms=0}if(F(),L)try{(_=e.flush)==null||_.call(e)}catch(Q){}},oe=()=>{if(y.hidden)K(!0);else{let L=Date.now();for(let _ of S.values())_.intersecting&&(_.enterAt=L)}},x=!1,D=L=>{if(K(!0),L!=null&&L.persisted){x=!0;return}try{z.disconnect()}catch(_){}},X=L=>{if(!(L!=null&&L.persisted)||!x)return;x=!1;let _=Date.now();for(let U of S.values())U.enterAt=U.intersecting&&!y.hidden?_:null};y.addEventListener("visibilitychange",oe);let Y=(A=y.defaultView)!=null?A:typeof window!="undefined"?window:void 0;Y==null||Y.addEventListener("pagehide",D),Y==null||Y.addEventListener("pageshow",X);let ie=setInterval(()=>{if(y.hidden||x)return;K();let L=Date.now();for(let _ of S.values())_.intersecting&&(_.enterAt=L)},Pi),Z=[];return t.microSignals&&[...b.entries()].forEach(([L,_],U)=>{Z.push(it((Q,T={})=>{try{e.track({projectId:t.apiKey,componentId:_,eventType:"micro_signal",payload:B({signalType:Q},T)})}catch(re){}},L,void 0,{tabLoss:U===0}))}),()=>{K(!0),clearInterval(ie),I.stop(),y.removeEventListener("visibilitychange",oe),Y==null||Y.removeEventListener("pagehide",D),Y==null||Y.removeEventListener("pageshow",X);for(let L of Z)L();try{z.disconnect()}catch(L){}}}function $i(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(a=>typeof a=="string"))return null;n[r]=o}return n}function Bi(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Ki(e){try{return e()}catch(t){return}}function Tt(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={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[a,i]of Object.entries(t.slots)){if(typeof i!="object"||i===null)continue;let s=i,c=$i(s.dims);if(!c||s.target!==void 0&&typeof s.target!="string")continue;let u=s.arms!==void 0?Bi(s.arms):null,l={dims:c};typeof s.target=="string"&&(l.target=s.target),u&&(l.arms=u),n[a]=l}let r={apiKey:t.apiKey,personaAttributes:t.personaAttributes===!0,slots:n};typeof t.consent=="boolean"&&(r.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(r.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(r.debug=!0),typeof t.registry=="boolean"&&(r.registry=t.registry),typeof t.editorSrc=="string"&&(r.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(r.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(r.sectionCapture=t.sectionCapture);let o=typeof t.persona=="function"?Ki(t.persona):t.persona;if(typeof o=="string"&&o.trim()!==""&&(r.persona=o),Array.isArray(t.sections)){let a=t.sections.filter(i=>typeof i=="string"&&i.trim()!=="").slice(0,50);a.length>=2&&(r.sections=a)}return r}var Ar=new WeakMap;function xr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function kr(e,t,n){var a,i,s;let r=Ar.get(e);if(r){if(r.fp!==n.fp||!xr(r.leafToNode,n.leafToNode))return"mismatch"}else{let c=Lt(e);if(!("fp"in c)||(r={fp:c.fp,leafToNode:c.leafToNode,textNodes:c.textNodes,ownerEls:c.ownerEls,classes:c.ownerEls.map(u=>{var l;return(l=u.getAttribute("class"))!=null?l:""})},r.fp!==n.fp||!xr(r.leafToNode,n.leafToNode)))return"mismatch";Ar.set(e,r)}let o=r;for(let[c,u]of Object.entries(t.nodes)){let l=Number(c),d=o.ownerEls[l];if(d){if(typeof u.text=="string"){let h=!0;o.leafToNode.forEach((C,f)=>{C===l&&(o.textNodes[f].nodeValue=h?u.text:"",h=!1)})}u.like!==void 0&&o.classes[u.like]!==void 0&&d.setAttribute("class",o.classes[u.like]),u.hidden&&((a=d.style)==null||a.setProperty("display","none","important"))}}for(let c of Object.values((i=t.order)!=null?i:{})){let u=c.map(f=>o.ownerEls[f]).filter(f=>!!f),l=(s=u[0])==null?void 0:s.parentElement;if(!l||u.length!==c.length||u.some(f=>f.parentElement!==l))continue;let d=new Set(u),h=0;Array.from(l.children).map(f=>d.has(f)?u[h++]:f).forEach((f,m)=>{var A;l.children[m]!==f&&l.insertBefore(f,(A=l.children[m])!=null?A:null)})}return"applied"}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 ji(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 Rt(e,t){return!!(e!=null&&e.urlMatch)&&!lt(t).includes(e.urlMatch)}var Ui=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Cr(e,t){var r;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Ui.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}return n}function Ce(e,t){if(e.urlMatch&&!lt(t).includes(e.urlMatch))return null;let n=Cr(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!ji(r,e.fingerprint)?null:r}function _r(e,t){return Rt(e,t)?!1:!!e.selector&&!e.dataAttr&&!e.id&&!e.fingerprint&&e.page===void 0?Or(e,t):Ce(e,t)!==null}function Or(e,t){return Cr(e,t).length>0}function Pt(e,t){return Rt(e,t)?!1:e.page!==void 0&&It.test(e.page)?un(e.page,lt(t)):Or(e,t)}var Ir={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"},Gi=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Lr(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(!Gi.test((r=n[1])!=null?r:""))return!1;return!0}var Tr=/^https:\/\//i,Rr=new Map,Pe=null;function Fi(e){return e.replace(/["\\]/g,"\\$&")}function zi(e){var t;(!Pe||!Pe.isConnected)&&(Pe=e.querySelector("style[data-sentient-ops]"),Pe||(Pe=e.createElement("style"),Pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Pe))),Pe.textContent=[...Rr.entries()].map(([n,r])=>`[data-snt-e="${Fi(n)}"]{${r}}`).join(`
|
|
2
|
+
`)}function Pr(e,t,n,r){var s;let o=!1,a=(s=t.moveBefore)!=null?s:t.moveAfter;if(a){let c=Ce(a,r);!c||c===e||c.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,c):e.parentElement.insertBefore(e,c.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Tr.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Tr.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[c,u]of Object.entries(t.style)){let l=Ir[c];l&&typeof u=="string"&&Lr(u)&&i.push(`${l}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Rr.set(n,i.join(";")),zi(r)),{anchorMiss:o}}var ut="data-sentient-block-arm",R=null;function He(e){R=e!=null?e:null}var Nt=null;function qe(e){Nt=e!=null?e:null}var $r=e=>{var t;return typeof e=="string"?(t=Nt==null?void 0:Nt.entries.find(n=>n.id===e))==null?void 0:t.classes:void 0},Oe="data-sentient-blocks-hid",We={none:"0",sm:"8px",md:"16px",lg:"24px"},mn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Nr={sm:"0.875em",md:"1em",lg:"1.25em"},Vi={sm:"1.25em",md:"1.5em",lg:"2em"},Wi={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Dr={sm:"8px",md:"16px",lg:"32px"},Hi={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},qi={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function Mr(e){return e==="muted"?R!=null&&R.muted?{color:R.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:R==null?void 0:R.accent}:{}}function Br(e,t){var n,r,o,a,i,s,c,u,l,d,h,C,f,m,A,y,E,w,b,g;try{let P=$r(e.like),I=e.maxWidth==="measure"?"65ch":void 0,F=S=>(S.className=P,he(S,{"max-width":I}));switch(e.type){case"stack":case"grid":{let S=t.createElement("div");if(e.type==="stack"){let K=e;he(S,{display:"flex","flex-direction":K.direction,gap:(r=We[(n=K.gap)!=null?n:"md"])!=null?r:We.md,"align-items":K.align?mn[K.align]:void 0,"justify-content":K.justify?mn[K.justify]:void 0,"flex-wrap":K.wrap?"wrap":void 0})}else{let K=e,oe=(a=We[(o=K.gap)!=null?o:"md"])!=null?a:We.md;he(S,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${K.columns-1} * ${oe}) / ${K.columns})), 1fr))`,gap:oe,"align-items":K.align?mn[K.align]:void 0})}P&&(S.className=P);let J=!P&&e.type==="stack"&&e.surface==="raised",z=(i=e.pad)!=null?i:J?"md":void 0;z&&he(S,{padding:(s=We[z])!=null?s:We.md}),J&&he(S,{background:R==null?void 0:R.surface,color:R!=null&&R.surface?R==null?void 0:R.surfaceText:void 0,border:`1px solid ${(c=R==null?void 0:R.border)!=null?c:"currentColor"}`,"border-radius":(u=R==null?void 0:R.radius)!=null?u:"8px"});for(let K of(l=e.children)!=null?l:[]){let oe=Br(K,t);oe&&S.appendChild(oe)}return S}case"text":{let S=t.createElement("p");return S.textContent=e.value,P?F(S):he(S,Te(V({margin:"0","font-size":e.size?Nr[e.size]:void 0,"font-weight":e.weight?qi[e.weight]:void 0,"text-align":e.align},Mr(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let S=t.createElement(`h${e.level}`);return S.textContent=e.value,P?F(S):he(S,{margin:"0","font-size":Vi[(d=e.size)!=null?d:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let S=t.createElement("a");if(S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),P)return F(S);let J=(h=e.emphasis)!=null?h:"primary";return he(S,{display:"inline-block",padding:Wi[(C=e.size)!=null?C:"md"],"border-radius":(f=R==null?void 0:R.radius)!=null?f:"8px",font:"inherit","font-size":e.size?Nr[e.size]:void 0,"text-decoration":J==="ghost"?"underline":"none",cursor:"pointer",background:J==="primary"?(m=R==null?void 0:R.primaryBg)!=null?m:"#111827":"transparent",color:J==="primary"?(A=R==null?void 0:R.primaryText)!=null?A:"#ffffff":(y=R==null?void 0:R.accent)!=null?y:"inherit",border:J==="secondary"?`1px solid ${(E=R==null?void 0:R.accent)!=null?E:"currentColor"}`:"none"})}case"link":{let S=t.createElement("a");return S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),P?F(S):he(S,{color:"inherit","text-decoration":"underline"})}case"image":{let S=t.createElement("img");return S.src=e.src,S.alt=e.alt,P&&(S.className=P),he(S,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Hi[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let S=t.createElement("span");return S.textContent=e.value,P?F(S):he(S,V({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(w=R==null?void 0:R.border)!=null?w:"currentColor"}`},Mr(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(b=Dr[e.size])!=null?b:Dr.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(g=R==null?void 0:R.border)!=null?g:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(P){return null}}function Kr(e,t,n,r){var o;try{let a=new Set;for(let s of Array.from(e.children)){let c=s.getAttribute(ut);c!==null&&(t[c]===void 0?s.remove():a.add(c))}for(let[s,c]of Object.entries(t)){if(a.has(s))continue;let u="tree"in c?c:null,l=Br(u?u.tree:c,r);if(!l)continue;let d=r.createElement("div");d.setAttribute(ut,s),d.style.display="none";let h=u?$r((o=u.surface)==null?void 0:o.like):void 0;if(h){let C=r.createElement("div");C.className=h,C.appendChild(l),d.appendChild(C)}else d.appendChild(l);e.appendChild(d)}let i=n!==void 0&&t[n]!==void 0;for(let s of Array.from(e.children)){let c=s.getAttribute(ut),u=s;c!==null?u.style.display=i&&c===n?"":"none":i?u.hasAttribute(Oe)||(u.setAttribute(Oe,u.style.display),u.style.display="none"):u.hasAttribute(Oe)&&(u.style.display=u.getAttribute(Oe),u.removeAttribute(Oe))}}catch(a){}}function Ji(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(ut)!==null){n.remove();continue}n.hasAttribute(Oe)&&(n.style.display=n.getAttribute(Oe),n.removeAttribute(Oe))}}catch(t){}}function Dt(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${ut}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${Oe}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||Ji(r)}catch(n){}}function gn(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function Mt(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 $t(e,t,n,r){var o;for(let[a,i]of Object.entries(t)){let s=e[a];if(!s||typeof s=="string")continue;let c=gn(i.target,n);for(let u of c)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 Bt(e,t,n,r){for(let[o,a]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!a.arms||!a.arms.includes(i))continue;let s=gn(a.target,n);for(let c of s)c.setAttribute("data-sentient-arm",i),r==null||r(c,"data-sentient-arm")}}function Yi(e,t){var o,a;let n=e.ownerDocument.createTreeWalker(e,4),r=null;for(let i=n.nextNode();i!==null;i=n.nextNode()){if(((o=i.nodeValue)!=null?o:"").trim()==="")continue;let s=(a=i.parentElement)==null?void 0:a.tagName;if(!(s==="SCRIPT"||s==="STYLE"||s==="TEMPLATE")){if(r!==null){e.textContent=t;return}r=i}}r!==null?r.nodeValue=t:e.textContent=t}function Kt(e,t,n,r){var s,c,u,l,d,h,C;let o=new Set,a=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[f,m]of Object.entries(t)){if(Rt(m.locator,n))continue;let A;if(m.locator){let E=Ce(m.locator,n);A=E?[E]:[],!E&&Pt(m.locator,n)&&i.push(f)}else A=gn(m.target,n);let y=e[f];for(let E of A){if(y!==void 0)if(typeof y=="string")E.setAttribute("data-sentient-arm",y),(c=r==null?void 0:r.onAttr)==null||c.call(r,E,"data-sentient-arm"),a&&((u=r==null?void 0:r.onApplied)==null||u.call(r,f,y,E));else for(let[b,g]of Object.entries(y))E.setAttribute(`data-${b}`,g),(l=r==null?void 0:r.onAttr)==null||l.call(r,E,`data-${b}`);if((m.blocks||m.compose)&&!Zi(n)){let b=Object.fromEntries([...Object.entries((d=m.blocks)!=null?d:{}).filter(([,g])=>!ot(g)),...Object.entries((h=m.compose)!=null?h:{}).filter(([,g])=>!ot(g.tree))]);Object.keys(b).length>0&&(Kr(E,b,typeof y=="string"?y:void 0,n),o.add(E))}if(!a)continue;let w=E.textContent;m.edits?kr(E,m.edits.edits,m.edits)==="mismatch"&&((C=r==null?void 0:r.onDrift)==null||C.call(r,f,m.edits.fp)):typeof m.content=="string"&&Yi(E,m.content),m.ops&&Pr(E,m.ops,f,n).anchorMiss&&!i.includes(f)&&i.push(f),cn(E,Te(V(V({previous:w},typeof y=="string"?{arm:y}:{}),(r==null?void 0:r.persona)!==void 0?{persona:r.persona}:{}),{doc:n}))}}return Dt(n,o),i}var Xi=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function Zi(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:Xi.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var Qi=800;function jt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:a,el:i},s)=>{r.push(it((h,C={})=>{try{e.track({projectId:t,componentId:o,variantId:a,eventType:"micro_signal",payload:V({signalType:h},C)})}catch(f){}},i,void 0,{tabLoss:s===0}));let c=null,u=0,l=()=>{u=Date.now(),c=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(h){}c=null},Qi)},d=()=>{c!==null&&(clearTimeout(c),c=null)};i.addEventListener("mouseenter",l),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",l),i.removeEventListener("mouseleave",d),c!==null&&clearTimeout(c)})}),()=>{for(let o of r)o()}}function es(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 Ur(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var ts="_snt_fired_goals";function Gr(e,t){try{e==null||e.sessionStorage.removeItem(Ur(t)),e==null||e.sessionStorage.removeItem(ts)}catch(n){}}function jr(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function ns(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 rs(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function Ut(e,t,n,r){var y,E;let o=(y=n.defaultView)!=null?y:typeof window!="undefined"?window:null,a=Ur(r),i=ns(o,a),s=w=>{let b=jr(w);if(!i.has(b))try{w.slotId?t.componentGoal(w.slotId,w.goalId):t.goal(w.goalId),i.add(b),rs(o,a,i)}catch(g){}},c=e.filter(w=>w.event==="click"),u=e.filter(w=>w.event==="form_submit"),l=e.filter(w=>w.event==="url_reached"),d=e.filter(w=>w.event==="scroll_depth"),h=(w,b)=>{if(!w.locator)return!1;let g=Ce(w.locator,n);return!!g&&(g===b||g.contains(b))},C=w=>{let b=w.target;if(!(!b||typeof b.closest!="function"))for(let g of c)h(g,b)&&s(g)},f=w=>{let b=w.target;if(b)for(let g of u)h(g,b)&&s(g)},m=()=>{if(l.length===0)return;let w=lt(n);for(let b of l)b.urlPattern&&es(b.urlPattern,w)&&s(b)},A=()=>{var g;let w=n.documentElement,b=w.scrollHeight>0?(w.scrollTop+w.clientHeight)/w.scrollHeight:0;for(let P of d)b>=((g=P.threshold)!=null?g:.75)&&s(P);d.every(P=>i.has(jr(P)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",C,!0),n.addEventListener("submit",f,!0),(E=n.defaultView)==null||E.addEventListener("popstate",m),m(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:m,teardown:()=>{var w;n.removeEventListener("click",C,!0),n.removeEventListener("submit",f,!0),(w=n.defaultView)==null||w.removeEventListener("popstate",m),d.length>0&&n.removeEventListener("scroll",A)}}}function Gt(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),a=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(a.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return a}var Fr="__snt_editor_token";function zr(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Fr):null}catch(e){return null}}function Vr(e){try{sessionStorage.setItem(Fr,e)}catch(t){}}var ft="0.30.0",Vt=ft!=="0.0.0-dev"?{name:"snippet",version:ft}:void 0,Qr=ft!=="0.0.0-dev"?{v:ft}:{},pt=5e3,os=50,eo=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),le=null,j=null,Se={},ve=null,se=null,Ne=null,ce=null,_e=null,ne=null,Ke=null,Wr=!1,hn=null,Ft=null,Wt=null,je=!1,ct=!1,De=!1,Ue=null,Me=[],Ht=null,dt=null,ye=null,is=3e3,ss=100;function mt(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 Ae(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Je(e,t){return le?(le.personaAttributes&&ne&&Mt(ne.persona,ne.band,e,t==null?void 0:t.onAttr),$t(Se,le.slots,e,t==null?void 0:t.onAttr),Bt(Se,le.slots,e,t==null?void 0:t.onAttr),ve?Kt(Se,ve,e,V(Te(V({},t),{onDrift:(n,r)=>{var o,a;return(a=j==null?void 0:j.reportDrift)==null?void 0:a.call(j,n,r,(o=oo[n])!=null?o:null,"fp_mismatch")}}),ne?{persona:ne.persona}:{})):(Dt(e,new Set),[])):[]}function to(e){var n;let t=new Map;for(let r of(n=le==null?void 0:le.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function yn(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=Gt(e,to(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function as(e,t,n){let r=(o,a)=>t.some(([i,s])=>i===o&&s===a);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[a,i,s]=o;!a||typeof i!="string"||r(a,i)||(s==null?a.removeAttribute(i):a.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 ls(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function no(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function gt(e){var t;return(t=e.apiBase)!=null?t:"https://api.sentient-ui.com"}function us(e){return Promise.resolve().then(()=>fetch(`${gt(e)}/v1/registry/locators`,{headers:{authorization:`Bearer ${e.apiKey}`}})).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t==null?void 0:t.slots)?t.slots:null).catch(()=>null)}function ro(e,t){let n=[],r=[];for(let o of e)try{if(typeof(o==null?void 0:o.id)!="string")continue;!o.locator||_r(o.locator,t)?n.push(o.id):Pt(o.locator,t)&&r.push(o.id)}catch(a){}return[n,r]}var oo={};function io(e,t){var r;let n={};for(let o of e){let a=(r=Ue==null?void 0:Ue.find(u=>u.id===o))==null?void 0:r.locator,i=a?Ce(a,t):null,s=i?Lt(i):null,c=s&&"fp"in s?s.fp:void 0;c&&(oo[o]=c),n[o]=Te(V({},c?{fp:c}:{}),{forms:!1,compose:!0,content:!0})}return n}function so(e,t){let n=null;for(let r of t)e!=null&&e[r]&&((n!=null?n:n={})[r]=e[r]);return n}function ao(){!Ue||!je||Ht===window.location.pathname||(Ht=window.location.pathname,cs())}function cs(){ye==null||ye();let e=le,t=Ue;if(!e||!t)return;let n,r,o=()=>{clearTimeout(n),clearTimeout(s),r==null||r.disconnect(),ye===o&&(ye=null)},a=null,i=c=>{let[u,l]=ro(t,document),d=u.filter(h=>!Me.includes(h));a!==null&&u.some(h=>!a.has(h)&&!d.includes(h))&&ht(),a=new Set(u),d.length>0&&ds(d).catch(()=>{}),(c||l.length===0&&!t.some(h=>!u.includes(h.id)&&!Me.includes(h.id)))&&(o(),lo(e,l))},s=setTimeout(()=>i(!0),is);if(ye=o,i(),ye===o)try{r=new MutationObserver(()=>{clearTimeout(n),n=setTimeout(i,ss)}),r.observe(document.documentElement,{childList:!0,subtree:!0})}catch(c){}}async function ds(e){let t=le,n=j;if(!t||!n)return;Me=Me.concat(e);let r=await mt(n.decide(V({slotsFrom:"registry",registrySlotIds:e,render:io(e,document)},Qr)),pt);if(r||(Me=Me.filter(a=>!e.includes(a))),!r||De||j!==n)return;Se=V(V({},Se),r.slots);let o=so(r.slotConfig,e);o&&(ve=V(V({},ve),o)),ht(),Ae(t,"late decide",e),dt&&Ve(t.apiKey,dt=V(Te(V({},dt),{slots:Se,savedAt:Date.now()}),ve?{slotConfig:ve}:{}))}function lo(e,t){if(t.length!==0)try{fetch(`${gt(e)}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(n){}}function Ye(){return!!(le&&j&&le.sectionCapture!==!1&&(le.consent!==!1||ct)&&!Be())}function fs(){if(!j||!le||!Ye()||_e)return;let e=[];Je(document,{contentAndOps:je,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),vn();try{ce==null||ce(),ce=jt(j,le.apiKey,e)}catch(t){}}function vn(){if(typeof document=="undefined"||!Ye())return;let e;try{if(Ft&&Ft.length>0){let t=new Map;for(let n of Ft){if(n.urlMatch!==window.location.pathname)continue;let r=Ce(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{_e=Er(j,V({apiKey:le.apiKey,apiBase:le.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Wt=window.location.pathname}catch(t){}}function ht(){try{let e=[];if(ce==null||ce(),ce=null,Je(document,{contentAndOps:je,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),yn(Ke,document),e.length>0&&Ye())try{ce=jt(j,le.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Wt!==null&&window.location.pathname!==Wt&&Ye()&&(_e==null||_e(),_e=null,vn())}catch(t){}}catch(e){}}function Hr(){hn===null&&(hn=setTimeout(()=>{hn=null,ht();try{se==null||se.checkUrl()}catch(e){}ao()},os))}function bn(){if(!(Wr||typeof window=="undefined"||typeof history=="undefined")){Wr=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,a){let i=n.call(this,r,o,a!=null?a:null);return Hr(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Hr)}catch(e){}}}function zt(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 uo(e){return new URLSearchParams(e).get("sentient_editor")}function ps(){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 ms(e,t){var n,r,o;try{window.__sentientEditor={token:t,apiBase:gt(e)};try{let s=document.createElement("meta");s.name="referrer",s.content="no-referrer",s.setAttribute("data-sentient-editor",""),((n=document.head)!=null?n:document.documentElement).appendChild(s)}catch(s){}let a=(r=e.editorSrc)!=null?r:ps();if(!a){Jr();return}let i=document.createElement("script");i.src=a,i.async=!0,i.onerror=()=>Jr(),((o=document.head)!=null?o:document.documentElement).appendChild(i)}catch(a){}}var qr="sentient-editor-load-notice",co={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Jr(){var e,t;try{if(typeof document=="undefined"||document.getElementById(qr))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=qr,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,co,{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 fo(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(":"),a=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!a||!i))if(i.includes("=")){let s={};for(let c of i.split(",")){let[u,l]=c.split("=");u&&l&&(s[u]=l)}Object.keys(s).length&&(n[a]=s)}else n[a]=i}return Object.keys(n).length?n:null}function po(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Yr="sentient-persona-preview-banner";function Xr(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Yr))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Yr,o.setAttribute("role","status"),Object.assign(o.style,co,{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 a=document.createElement("span");a.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(a),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function gs(e,t){var r;if((r=e.registry)!=null?r:Object.keys(e.slots).length===0){let o=gt(e),i=await mt(fetch(`${o}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slotsFrom:"registry",includeDrafts:!0,force:Object.fromEntries(Object.entries(t).filter(s=>typeof s[1]=="string"))})}).then(s=>s.ok?s.json():null).catch(()=>null),pt);if(!(i!=null&&i.slotConfig)){Xe(e),Ae(e,"preview mode: slot config unavailable \u2014 page left as-is");return}ve=i.slotConfig,He(i.palette),qe(i.vocabulary)}Se=t,ne=null,Je(document),bn(),Xe(e),Ae(e,"preview mode",t)}async function hs(e,t){var u,l,d,h,C,f,m,A,y;let n=gt(e),o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([E,w])=>({id:E,dims:w.dims}))},a=await mt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(E=>E.ok?E.json():null).catch(()=>null),pt);if(!a){Xe(e),Ae(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=a;Se=(l=i.slots)!=null?l:{},ve=(d=i.slotConfig)!=null?d:null,He(i.palette),qe(i.vocabulary);let s=(f=(C=(h=i.personaAttributes)==null?void 0:h.persona)!=null?C:i.persona)!=null?f:t,c=(A=(m=i.personaAttributes)==null?void 0:m.confidence)!=null?A:"high";ne={persona:s,band:c},Je(document),je=!0,bn(),Xe(e),i.recognized===!1?Xr(t,!0):Xr((y=i.personaDisplay)!=null?y:s)}function Xe(e){let t={goal(n,r){try{j==null||j.goal(n,r)}catch(o){}},componentGoal(n,r){try{j==null||j.componentGoal(n,r)}catch(o){}},grantConsent(){try{!j&&De?(j=st(V({apiKey:e.apiKey,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:no(e)},Vt?{sdk:Vt}:{})),Ne&&Ne.length>0&&(se==null||se.teardown(),se=Ut(Ne,j,document,e.apiKey))):(dn(e.apiKey),j&&Ne&&Ne.length>0&&(se==null||se.teardown(),se=Ut(Ne,j,document,e.apiKey))),De=!1}catch(n){}ct=!0;try{fs()}catch(n){}},revokeConsent(){try{_e==null||_e(),_e=null,Wt=null,ce==null||ce(),ce=null,ye==null||ye(),se==null||se.teardown(),se=null,Gr(typeof window!="undefined"?window:null,e.apiKey),ct=!1,De=!0,j==null||j.destroy(),j=null}catch(n){}},reapply:ht,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=ne==null?void 0:ne.persona)!=null?n:null,band:(r=ne==null?void 0:ne.band)!=null?r:null,slots:Se,matchCounts:zt(e),consent:!De&&(e.consent!==!1||ct)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of eo.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Zr(){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})},eo.length=0}catch(t){}}async function mo(){var e,t;try{let n=Tt(window.sentient);if(!n){Zr();return}le=n,je=!1,Ke=null,He(null),qe(null),ct=!1,De=!1,Ne=null,Ue=null,Me=[],Ht=null,dt=null,ye==null||ye();let r=typeof window!="undefined"?uo(window.location.search):null;if(r){Vr(r);try{let g=new URL(window.location.href);g.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",g.pathname+g.search+g.hash)}catch(g){}}let o=r!=null?r:zr();if(o){ms(n,o),Xe(n),Ae(n,"editor mode");return}let a=typeof window!="undefined"?fo(window.location.search):null;if(a){await gs(n,a);return}let i=typeof window!="undefined"?po(window.location.search):null;if(i){await hs(n,i),Ae(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0;n.registry===void 0&&!s&&Ae(n,"slots declared without registry: true, so dashboard-published components are not applied");let c=s?us(n):null,u=ls();try{(t=u==null?void 0:u.stop)==null||t.call(u)}catch(g){}let l=rt(n.apiKey),d=[];l&&(ne={persona:l.persona,band:l.band},Se=l.slots,l.slotConfig&&(ve=l.slotConfig),l.palette&&He(l.palette),l.vocabulary&&qe(l.vocabulary),Je(document,V({contentAndOps:!1},u?{onAttr:(g,P)=>d.push([g,P])}:{})),l.layoutOrder&&(Ke=l.layoutOrder,yn(Ke,document))),u&&as(u,d,document);let h=st(V({apiKey:n.apiKey,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:no(n)},Vt?{sdk:Vt}:{}));j=h,Xe(n),bn();let C=Object.entries(n.slots).map(([g,P])=>({id:g,dims:P.dims})),f=Qr,m={pp:u?u.v:0},A=Array.from(to(document).keys()),y=[];if(c){let[g]=await Promise.all([mt(c,pt),document.readyState==="loading"?new Promise(P=>document.addEventListener("DOMContentLoaded",P,{once:!0})):null]);Ue=g,g&&(Me=y=ro(g,document)[0]),Ae(n,"registry scope",g&&y)}let E=h.decide(V(V(V(V({slots:C},f),m),A.length>=2?{sections:A}:{}),s?{slotsFrom:"registry",registrySlotIds:y,render:io(y,document)}:{})),w=await mt(E,pt),b=g=>{var F,S,J,z,K;let P=h.getPersona();P?ne={persona:P.persona,band:P.band}:g.persona&&(ne={persona:g.persona,band:"low"}),Se=g.slots,s?ve=so(g.slotConfig,y):g.slotConfig&&(ve=g.slotConfig),g.palette&&He(g.palette),g.vocabulary&&qe(g.vocabulary),Ke=(F=g.layoutOrder)!=null?F:Ke;let I=()=>{let oe=[],x=Je(document,{onApplied:(D,X,Y)=>oe.push({slotId:D,arm:X,el:Y})});if(s||lo(n,x),yn(Ke,document),je=!0,Ye())try{ce==null||ce(),ce=jt(j,n.apiKey,oe)}catch(D){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",I,{once:!0}):I(),Ne=(S=g.goals)!=null?S:null,g.goals&&g.goals.length>0&&n.consent!==!1&&j)try{se==null||se.teardown(),se=Ut(g.goals,j,document,n.apiKey)}catch(oe){}Ft=(J=g.sectionMap)!=null?J:null,Ye()&&vn(),Ae(n,"applied",{persona:ne,slots:Se,matches:zt(n)}),!De&&(Ve(n.apiKey,dt=V(V(V({v:1,persona:(z=ne==null?void 0:ne.persona)!=null?z:g.persona,band:(K=ne==null?void 0:ne.band)!=null?K:"low",slots:g.slots,layoutOrder:g.layoutOrder,savedAt:Date.now()},ve?{slotConfig:ve}:{}),g.palette?{palette:g.palette}:{}),g.vocabulary?{vocabulary:g.vocabulary}:{})),Ht=null,ao())};if(!w){Ae(n,"decide timeout/null \u2014 snapshot state stands",zt(n)),E.then(g=>{!g||je||De||j!==h||(b(g),Ae(n,"late decide applied",zt(n)))}).catch(()=>{});return}b(w)}catch(n){Zr()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{mo()}))}return Ao(ys);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/snippet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.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.
|
|
41
|
+
"@sentientui/core": "0.34.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup",
|