@sentientui/snippet 0.27.0 → 0.29.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 +17 -7
- 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 vt=Object.defineProperty,po=Object.defineProperties,fo=Object.getOwnPropertyDescriptor,go=Object.getOwnPropertyDescriptors,mo=Object.getOwnPropertyNames,yt=Object.getOwnPropertySymbols;var zt=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable;var En=(e,t,r)=>t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,R=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&En(e,r,t[r]);if(yt)for(var r of yt(t))Cn.call(t,r)&&En(e,r,t[r]);return e},J=(e,t)=>po(e,go(t));var Tn=e=>typeof e=="symbol"?e:e+"",Ln=(e,t)=>{var r={};for(var i in e)zt.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(e!=null&&yt)for(var i of yt(e))t.indexOf(i)<0&&Cn.call(e,i)&&(r[i]=e[i]);return r};var ho=(e,t)=>{for(var r in t)vt(e,r,{get:t[r],enumerable:!0})},yo=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of mo(t))!zt.call(e,c)&&c!==r&&vt(e,c,{get:()=>t[c],enumerable:!(i=fo(t,c))||i.enumerable});return e};var vo=e=>yo(vt({},"__esModule",{value:!0}),e);var er={};ho(er,{buildStyleOps:()=>Yt,clearTargetHighlights:()=>Je,computeMoveAnchors:()=>Et,deriveSlotId:()=>ve,drawTargetHighlights:()=>Wn,isHex6:()=>Tt,mount:()=>Vn,registerAuditTargets:()=>qn,sectionTypesFor:()=>Jn,styleFieldError:()=>Yn,toHexColor:()=>St});var nr=56*1024;var or=1800*1e3;var Kt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function bo(e){var r,i,c;let t=(i=(r=e.defaultView)!=null?r:typeof window!="undefined"?window:void 0)==null?void 0:i.location;return(c=t==null?void 0:t.pathname)!=null?c:""}function xo(e,t){var r;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let i=((r=e.textContent)!=null?r:"").replace(/\s+/g," ").trim().toLowerCase(),c=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(i===c||i.startsWith(c)||c.startsWith(i)))return!1}return!0}var wo=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function ko(e,t){var i;let r=[];if(e.id){let c=t.getElementById(e.id);r=c?[c]:[]}if(r.length===0&&((i=e.dataAttr)!=null&&i.name)&&wo.test(e.dataAttr.name))try{let c=e.dataAttr.value.replace(/["\\]/g,"\\$&");r=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${c}"]`))}catch(c){r=[]}if(r.length===0&&e.selector)try{r=Array.from(t.querySelectorAll(e.selector))}catch(c){r=[]}return r}function ye(e,t){if(e.urlMatch&&!bo(t).includes(e.urlMatch))return null;let r=ko(e,t);if(r.length!==1)return null;let i=r[0];return e.fingerprint&&!xo(i,e.fingerprint)?null:i}var jt="data-sentient-block-arm",C=null;var nt="data-sentient-blocks-hid",Ge={none:"0",sm:"8px",md:"16px",lg:"24px"},Ut={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},_n={sm:"0.875em",md:"1em",lg:"1.25em"},So={sm:"1.25em",md:"1.5em",lg:"2em"},Eo={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},In={sm:"8px",md:"16px",lg:"32px"},Co={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},To={normal:"400",medium:"500",bold:"700"};function te(e,t){for(let[r,i]of Object.entries(t))i!==void 0&&e.style.setProperty(r,i);return e}function An(e){return e==="muted"?C!=null&&C.muted?{color:C.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:C==null?void 0:C.accent}:{}}function Bn(e,t){var r,i,c,u,w,L,b,$,D,Z,K,M,O,q,Y,Q,N,j,ne,V;try{switch(e.type){case"stack":case"grid":{let h=t.createElement("div");if(e.type==="stack"){let z=e;te(h,{display:"flex","flex-direction":z.direction,gap:(i=Ge[(r=z.gap)!=null?r:"md"])!=null?i:Ge.md,"align-items":z.align?Ut[z.align]:void 0,"justify-content":z.justify?Ut[z.justify]:void 0,"flex-wrap":z.wrap?"wrap":void 0})}else{let z=e,re=(u=Ge[(c=z.gap)!=null?c:"md"])!=null?u:Ge.md;te(h,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${z.columns-1} * ${re}) / ${z.columns})), 1fr))`,gap:re,"align-items":z.align?Ut[z.align]:void 0})}let H=e.type==="stack"&&e.surface==="raised",oe=(w=e.pad)!=null?w:H?"md":void 0;oe&&te(h,{padding:(L=Ge[oe])!=null?L:Ge.md}),H&&te(h,{background:C==null?void 0:C.surface,color:C!=null&&C.surface?C==null?void 0:C.surfaceText:void 0,border:`1px solid ${(b=C==null?void 0:C.border)!=null?b:"currentColor"}`,"border-radius":($=C==null?void 0:C.radius)!=null?$:"8px"});for(let z of(D=e.children)!=null?D:[]){let re=Bn(z,t);re&&h.appendChild(re)}return h}case"text":{let h=t.createElement("p");return h.textContent=e.value,te(h,J(R({margin:"0","font-size":e.size?_n[e.size]:void 0,"font-weight":e.weight?To[e.weight]:void 0,"text-align":e.align},An(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let h=t.createElement(`h${e.level}`);return h.textContent=e.value,te(h,{margin:"0","font-size":So[(Z=e.size)!=null?Z:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let h=t.createElement("a");h.textContent=e.label,h.href=e.href,e.tag&&h.setAttribute("data-sentient-tag",e.tag);let H=(K=e.emphasis)!=null?K:"primary";return te(h,{display:"inline-block",padding:Eo[(M=e.size)!=null?M:"md"],"border-radius":(O=C==null?void 0:C.radius)!=null?O:"8px",font:"inherit","font-size":e.size?_n[e.size]:void 0,"text-decoration":H==="ghost"?"underline":"none",cursor:"pointer",background:H==="primary"?(q=C==null?void 0:C.primaryBg)!=null?q:"#111827":"transparent",color:H==="primary"?(Y=C==null?void 0:C.primaryText)!=null?Y:"#ffffff":(Q=C==null?void 0:C.accent)!=null?Q:"inherit",border:H==="secondary"?`1px solid ${(N=C==null?void 0:C.accent)!=null?N:"currentColor"}`:"none"})}case"link":{let h=t.createElement("a");return h.textContent=e.label,h.href=e.href,e.tag&&h.setAttribute("data-sentient-tag",e.tag),te(h,{color:"inherit","text-decoration":"underline"})}case"image":{let h=t.createElement("img");return h.src=e.src,h.alt=e.alt,te(h,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Co[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let h=t.createElement("span");return h.textContent=e.value,te(h,R({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(j=C==null?void 0:C.border)!=null?j:"currentColor"}`},An(e.tone)))}case"spacer":return te(t.createElement("div"),{height:(ne=In[e.size])!=null?ne:In.md});case"divider":return te(t.createElement("hr"),{border:"none","border-top":`1px solid ${(V=C==null?void 0:C.border)!=null?V:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(h){return null}}function $n(e,t,r,i){try{let c=new Set;for(let w of Array.from(e.children)){let L=w.getAttribute(jt);L!==null&&(t[L]===void 0?w.remove():c.add(L))}for(let[w,L]of Object.entries(t)){if(c.has(w))continue;let b=Bn(L,i);if(!b)continue;let $=i.createElement("div");$.setAttribute(jt,w),$.style.display="none",$.appendChild(b),e.appendChild($)}let u=r!==void 0&&t[r]!==void 0;for(let w of Array.from(e.children)){let L=w.getAttribute(jt),b=w;L!==null?b.style.display=u&&L===r?"":"none":u?b.hasAttribute(nt)||(b.setAttribute(nt,b.style.display),b.style.display="none"):b.hasAttribute(nt)&&(b.style.display=b.getAttribute(nt),b.removeAttribute(nt))}}catch(c){}}function Mn(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let r="";for(let i=0;i<e.length;i++){let c=e[i],u=c>="0"&&c<="9";i===0&&u||i===1&&u&&e[0]==="-"?r+=`\\3${c} `:i===0&&c==="-"&&e.length===1?r+="\\-":/[a-zA-Z0-9_-]/.test(c)?r+=c:r+=`\\${c}`}return r}function Lo(e,t){if(e.id)return`#${Mn(e.id)}`;let r=[],i=e,c=0;for(;i&&i!==t.body&&i!==t.documentElement&&c<6;){if(i.id){r.unshift(`#${Mn(i.id)}`);break}let u=i.tagName.toLowerCase(),w=i.parentElement;if(w){let L=Array.from(w.children).filter(b=>b.tagName===i.tagName);L.length>1&&(u+=`:nth-of-type(${L.indexOf(i)+1})`)}r.unshift(u),i=i.parentElement,c++}return r.join(" > ")}function qe(e,t){var c;let r={v:1};e.id&&(r.id=e.id);for(let u of["data-framer-name","data-w-id","data-sentient-name"]){let w=e.getAttribute(u);if(w){r.dataAttr={name:u,value:w};break}}r.selector=Lo(e,t);let i=((c=e.textContent)!=null?c:"").trim().replace(/\s+/g," ").slice(0,80);return r.fingerprint=R({tag:e.tagName.toLowerCase()},i?{text:i}:{}),r}function ot(e,t,r){return ye(e,r)===t}var _o="__snt_editor_token";function rt(){try{sessionStorage.removeItem(_o)}catch(e){}}var Io=/rgba\([^)]*,\s*0\s*\)$/,Ao=/^\d+(\.\d+)?px$/;function Rn(e){var t,r;try{let i=e.defaultView;if(!i||!e.body)return null;let c=i.getComputedStyle(e.body).backgroundColor,u=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),w=new Map;for(let K of Array.from(u).slice(0,300)){let M=K.getBoundingClientRect();if(M.width>0&&(M.width<48||M.height<24))continue;let O=i.getComputedStyle(K),q=O.backgroundColor;if(!q||q==="transparent"||q===c||Io.test(q))continue;let Y=(t=(O.borderRadius||"").split(" ")[0])!=null?t:"",Q=`${q}|${O.color}|${Ao.test(Y)?Y:"8px"}`;w.set(Q,((r=w.get(Q))!=null?r:0)+1)}let L=null,b=0;for(let[K,M]of w)M>b&&(L=K,b=M);if(!L)return null;let[$,D,Z]=L.split("|");return{primaryBg:$,primaryText:D,radius:Z}}catch(i){return null}}var bt={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Bo=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function it(e){var i;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,r;for(;(r=t.exec(e))!==null;)if(!Bo.test((i=r[1])!=null?i:""))return!1;return!0}var On=/^https:\/\//i,Pn=new Map,Ce=null;function $o(e){return e.replace(/["\\]/g,"\\$&")}function Mo(e){var t;(!Ce||!Ce.isConnected)&&(Ce=e.querySelector("style[data-sentient-ops]"),Ce||(Ce=e.createElement("style"),Ce.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Ce))),Ce.textContent=[...Pn.entries()].map(([r,i])=>`[data-snt-e="${$o(r)}"]{${i}}`).join(`
|
|
2
|
-
`)}function
|
|
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 Vn(e,n,r,i){var L;let c=!1,m=(L=n.moveBefore)!=null?L:n.moveAfter;if(m){let v=ge(m,i);!v||v===e||v.parentElement!==e.parentElement||!e.parentElement?c=!0:n.moveBefore?e.parentElement.insertBefore(e,v):e.parentElement.insertBefore(e,v.nextSibling)}typeof n.text=="string"&&(e.textContent=n.text),typeof n.href=="string"&&Jn.test(n.href)&&e.setAttribute("href",n.href),typeof n.imageSrc=="string"&&Jn.test(n.imageSrc)&&e.setAttribute("src",n.imageSrc),typeof n.imageAlt=="string"&&e.setAttribute("alt",n.imageAlt);let b=[];if(n.hidden&&b.push("display:none !important"),n.style)for(let[v,M]of Object.entries(n.style)){let H=vt[v];H&&typeof M=="string"&&Xe(M)&&b.push(`${H}:${M.trim()} !important`)}return b.length>0&&(e.setAttribute("data-snt-e",r),Yn.set(r,b.join(";")),Wo(i)),{anchorMiss:c}}function bt(e){let n=e.split(/[?#]/)[0]||"/";return n.length>1?n.replace(/\/+$/,"")||"/":n}function Xn(e,n){return e==="*"?"Every page":e.endsWith("/*")?`All pages under ${e.slice(0,-1)}`:e===n?`This page (${e})`:`Only on ${e}`}function Qt(e,n){let r=bt(e),i=r.split("/").filter(Boolean),c=[r,"*"];return i.length>=2&&c.push(`/${i[0]}/*`),(n?[n,...c.filter(m=>m!==n)]:c).filter(m=>Vt.test(m))}function $t(e){let n=e.steps.length,r=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${n} step${n===1?"":"s"}${r}`}function Bt(e,n){return e.steps.map(r=>{var i;return{value:r.step_index,label:`${r.step_index+1}. ${(i=n.get(r.goal_id))!=null?i:r.goal_id}`}})}function Zn(e,n){return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function qo(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function Qn(e,n){let r=e.trim();return r?n.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:n.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:qo(r),body:{displayName:r.slice(0,128),steps:n.map(i=>({goalId:i}))}}:{ok:!1,error:"Give the funnel a name."}}function to(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return n.toString(36)}function Ze(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function me(e,n,r){var L,v;let i=n.id||((L=n.dataAttr)==null?void 0:L.value)||((v=r.textContent)!=null?v:"").trim()||r.tagName,c=Ze(i)||"el",m=to(JSON.stringify(n));return`${e}-${c}-${m}`.slice(0,128)}var Jo="sentient-editor-highlight",Yo="sentient-editor-selection",Qe="sentient-editor-panel",Ot="sentient-editor-toast",tn="sentient-editor-styles",nn="sentient-editor-target-highlight",Vo=10,Xo="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Zo="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function no(){var n;if(document.getElementById(tn))return;let e=document.createElement("style");e.id=tn,e.textContent=`
|
|
3
3
|
@keyframes sntedi-in {
|
|
4
4
|
from { opacity: 0; transform: translateY(28px) scale(0.94); }
|
|
5
5
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
@@ -12,13 +12,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
|
+
#${Qe} {
|
|
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
|
+
#${Qe} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
|
|
20
|
+
#${Ot} { 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
|
+
#${Qe}, #${Qe} .sntedi-dot, #${Ot} { animation: none !important; }
|
|
23
23
|
}
|
|
24
|
-
`,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function jn(e){var i,c;Fn(),(i=document.getElementById(Ct))==null||i.remove();let t=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=Ct;let r=a("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(r,a("div",{},e)),((c=document.body)!=null?c:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function zo(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Ko(e){try{let t=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let r=(await t.json()).projectId;return r?{ok:!0,projectId:r}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function Vt(e,t){return R(R(R(R({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 ee(e,t,r){try{let i=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(r)});if(i.ok)return{r:"ok"};let c=await i.json().catch(()=>null);return Vt(i.status,c)}catch(i){return{r:"error"}}}async function jo(e,t){try{let r=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(r.ok)return{r:"ok"};let i=await r.json().catch(()=>null);return Vt(r.status,i)}catch(r){return{r:"error"}}}async function Uo(e,t,r){try{let i=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(r)}),c=await i.json().catch(()=>null);return i.ok?{r:"ok",data:c,outcome:{r:"ok"}}:{r:i.status===401?"expired":"error",data:c,outcome:Vt(i.status,c)}}catch(i){return{r:"error",data:null,outcome:{r:"error"}}}}var Wt=[];function Tt(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function St(e){let t=e.trim();if(Tt(t))return t;let r=/^#([0-9a-fA-F]{3})$/.exec(t);if(r)return`#${r[1].split("").map(u=>u+u).join("")}`;let i=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!i)return t;let c=u=>Math.min(255,Number(u)).toString(16).padStart(2,"0");return`#${c(i[1])}${c(i[2])}${c(i[3])}`}var be=null,Gn=[];function qn(e){Gn=e}async function Fo(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let r=await t.json();return Wt=Array.isArray(r.fonts)?r.fonts.filter(i=>typeof i=="string"):[],Array.isArray(r.targets)?r.targets:[]}catch(t){return[]}}async function st(e,t){try{let r=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return r.ok?await r.json():null}catch(r){return null}}function Je(e=document){for(let t of Array.from(e.querySelectorAll(`.${qt}`)))t.remove()}function Wn(e,t=document){var i;Je(t);let r=0;for(let c of e){if(r>=Do)break;let u=ye(c.locator,t);if(!u)continue;let w=u.getBoundingClientRect(),L=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${w.left}px`,top:`${w.top}px`,width:`${w.width}px`,height:`${w.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});L.className=qt;let b=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${w.left}px`,top:`${Math.max(0,w.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},c.label);b.className=qt,((i=t.body)!=null?i:t.documentElement).append(L,b),r+=1}}function Et(e,t){let r=e.previousElementSibling,i=e.nextElementSibling,c=r?qe(r,t):null,u=i?qe(i,t):null;return{prevEl:r,nextEl:i,prevLocator:r&&c&&ot(c,r,t)?c:null,nextLocator:i&&u&&ot(u,i,t)?u:null}}var Go=/testimonial|review|quote/i;function Jn(e){let t=[],r=e.headings.length>=1,i=e.links.length>=1;return r&&i&&t.push("hero","cta_band"),e.headings.length>=2&&e.paragraphs.length>=2&&t.push("feature_grid"),e.quotes.length>=1&&t.push("testimonial"),t}var Jt=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],qo=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,Wo=new Set(["left","center","right","justify","start","end"]),Jo=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Yo=/^(rgb|rgba|hsl|hsla)\(/i;function Vo(e){return Jo.test(e)||Yo.test(e)}function Yn(e,t){switch(e){case"fontSize":case"borderRadius":return qo.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 Wo.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Vo(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let r=t.split(",").map(i=>i.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&r.length>=1&&r.length<=5&&r.every(i=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(i))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function Yt(e){let t={},r={};for(let i of Jt){let c=e[i];if(typeof c!="string")continue;let u=c.trim();if(u==="")continue;if(!it(u)){r[i]="That value isn\u2019t allowed.";continue}let w=Yn(i,u);if(w){r[i]=w;continue}t[i]=u}return{style:t,errors:r}}function a(e,t,r){let i=document.createElement(e);return Object.assign(i.style,t),r!==void 0&&(i.textContent=r),i}function Vn(e){var Sn;let t=null,r=[],i=null,c=()=>{for(;r.length>0;){let n=r.splice(0,20);try{fetch(`${e.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({events:n})}).catch(()=>{})}catch(o){}}},u=(n,o)=>{r.push(R({kind:n},o?{meta:o}:{})),i&&clearTimeout(i),i=setTimeout(c,2e3)};window.addEventListener("pagehide",c);let w=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});w.id=Oo;let L=a("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});L.id=Po;let b=()=>{if(!t||!t.isConnected){L.style.display="none";return}let n=t.getBoundingClientRect();Object.assign(L.style,{display:"block",left:`${n.left-2}px`,top:`${n.top-2}px`,width:`${n.width}px`,height:`${n.height}px`})},$=()=>b();Fn();let D=a("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",overscrollBehavior:"contain"});D.id=We;let Z=a("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});Z.className="sntedi-dot";let K=a("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});K.append(Z,a("span",{},"SentientUI"));let M=a("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),O=!1,q=a("button",I("#374151"),"Pause selecting");q.onclick=()=>{O=!O,q.textContent=O?"Resume selecting":"Pause selecting",O?(w.style.display="none",Je(document),y("Selection paused \u2014 browse normally, then resume.")):y("Click any element on the page to adapt it.")};let Y=a("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Q=a("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),N=a("button",I("#6366f1"),"Test different text here"),j=a("button",I("#374151"),"Change style"),ne=a("button",I("#374151"),"Try a different layout for this section"),V=a("button",I("#374151"),"Track clicks as a goal"),h=a("button",I("#374151"),"Track form submissions as a goal"),H=a("button",I("#374151"),"Track page visits as a goal"),oe=a("button",I("#374151"),"Track reading this far as a goal"),z=a("button",I("#374151"),"Set up a funnel"),re=a("button",I("#374151"),"Attach this test to a funnel step"),Te=a("button",I("#10b981"),"Turn the funnel on"),xe=a("button",I("#374151"),"Move up"),we=a("button",I("#374151"),"Move down"),Ye=a("button",I("#6366f1"),"Save this arrangement"),at=a("button",I("#374151"),"Undo"),Oe=a("button",J(R({},I("transparent")),{opacity:"0.6"}),"Close editor"),ue=a("button",I("#10b981"),"Publish now \u2014 go live"),pe=a("button",I("#10b981"),"Start tracking now");for(let n of[N,j,ne,V,xe,we])n.disabled=!0;let _t=[N,j,ne,V,h,xe,we];for(let n of _t)n.style.display="none";Ye.style.display="none",at.style.display="none",ue.style.display="none",pe.style.display="none",re.style.display="none",Te.style.display="none";let fe=a("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),Pe=a("div",{}),Xt=[{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"}],ie="text",Zt=new Map,ke=new Map,It=new Map,Qt=a("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),en=a("div",{paddingTop:"10px"});for(let n of Xt){let o=a("button",{background:"transparent",border:"none",cursor:"pointer",font:"600 11.5px system-ui, sans-serif",color:"#9ca3af",whiteSpace:"nowrap",padding:"7px 5px",borderBottom:"2px solid transparent",marginBottom:"-1px"});o.append(a("span",{fontSize:"11px",marginRight:"3px"},n.icon),a("span",{},n.label)),o.onclick=()=>At(n.id),Zt.set(n.id,o),Qt.append(o);let s=a("div",{display:"none"}),l=a("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});s.append(l),It.set(n.id,l),ke.set(n.id,s),en.append(s)}ke.get("text").append(N),ke.get("style").append(j),ke.get("layout").append(ne,xe,we,Ye,at),ke.get("goals").append(V,h,H,oe),ke.get("funnels").append(z,re,Te);let se=a("div",{});ke.get("drafts").append(se);let lt=()=>{var o,s;for(let l of Xt){let d=l.id===ie,m=Zt.get(l.id);m.style.color=d?"#ffffff":"#9ca3af",m.style.borderBottom=d?"2px solid #6366f1":"2px solid transparent",ke.get(l.id).style.display=d?"block":"none",It.get(l.id).style.display="none"}let n=l=>{let d=It.get(ie);d.textContent=l,d.style.display="block"};ie==="text"?t?N.disabled?n(N.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(o=N.onclick)==null||o.call(N,new MouseEvent("click")):n("Click any text on the page to test a different wording."):ie==="style"?t?j.disabled?n("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(s=j.onclick)==null||s.call(j,new MouseEvent("click")):n("Click any element on the page to change how it looks."):ie==="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."):ie==="goals"?t||n("Page-level goals work right away; click a button or form to track it specifically."):ie==="funnels"?n("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):ie==="drafts"&&Ne()},Xn=(n,o,s)=>{n.onclick=()=>{if(n.dataset.armed==="1"){n.dataset.armed="",s();return}n.dataset.armed="1",n.textContent="Sure?",setTimeout(()=>{n.isConnected&&n.dataset.armed==="1"&&(n.dataset.armed="",n.textContent=o)},4e3)}},De=(n,o)=>a("button",J(R({},I(n)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),o),tn=(n,o)=>{let s=new URL(window.location.href);s.searchParams.delete("sentient_editor"),s.searchParams.set("sentient_preview",n),o&&s.searchParams.set("sentient_arm",o),window.location.assign(s.toString())},dt=(n,o,s)=>{let l=De("#374151","Discard");return Xn(l,"Discard",async()=>{l.disabled=!0;let d=await jo(e,n);l.disabled=!1,ae(d,o),d.r==="ok"&&s()}),l},nn=(n,o)=>{_e.textContent="";let s=a("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=a("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...o),s.append(a("div",{marginBottom:"6px"},n),l),_e.append(s)},Ne=async()=>{var v,x,E,f,T,A,S,P,F,X,Se,le;se.textContent="",se.append(a("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let n=[],o=[],s=null,l=!1;if(await Promise.all([(async()=>{var k;try{let _=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});_.ok?n=(k=(await _.json()).slots)!=null?k:[]:s=_.status===401?"expired":"error"}catch(_){s="error"}})(),(async()=>{var k;try{let _=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});_.ok?o=(k=(await _.json()).goals)!=null?k:[]:l=!0}catch(_){l=!0}})()]),ie!=="drafts")return;if(se.textContent="",s){if(se.append(a("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},s==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),s==="error"){let k=De("#374151","Retry");k.onclick=()=>{Ne()},se.append(k)}return}let d=n.filter(k=>{var _,G,he,Ee,Re,tt;return((he=(G=(_=k.draft_config)==null?void 0:_.arms)==null?void 0:G.length)!=null?he:0)>0||((tt=(Re=(Ee=k.published_config)==null?void 0:Ee.arms)==null?void 0:Re.length)!=null?tt:0)>0}),m=o.filter(k=>k.event!=="custom"&&(k.status==="draft"||k.status==="active"));if(d.length===0&&m.length===0&&!l){se.append(a("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let g=k=>a("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:k?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:k?"#6ee7b7":"#c7d2fe"},k?"live":"draft"),p=k=>{let _=a("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),G=a("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},k);return _.append(G),{row:_,name:G}};for(let k of d){let{row:_}=p((v=k.display_name)!=null?v:k.slot_id);_.append(g(k.status==="published"));let G=(T=(f=(x=k.draft_config)==null?void 0:x.arms)!=null?f:(E=k.published_config)==null?void 0:E.arms)!=null?T:[],he=(P=(A=G[1])==null?void 0:A.id)!=null?P:(S=G[0])==null?void 0:S.id,Ee=De("#374151","Preview");if(Ee.onclick=()=>tn(k.slot_id,he),_.append(Ee),k.status!=="published"&&((Se=(X=(F=k.draft_config)==null?void 0:F.arms)==null?void 0:X.length)!=null?Se:0)>0){let Re=De("#10b981","Publish");Re.onclick=async()=>{Re.disabled=!0;let tt=await ee(e,`/v1/editor/slots/${encodeURIComponent(k.slot_id)}/publish`,{});Re.disabled=!1,ae(tt,"\u2713 Published \u2014 live for new visitors."),tt.r==="ok"&&(u("published",{kind:"slot"}),Ne())},_.append(Re)}k.status!=="published"&&_.append(dt(`/v1/editor/slots/${encodeURIComponent(k.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{fn(k.slot_id),Ne()})),se.append(_)}if(l)se.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(m.length>0){se.append(a("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let k of m){let{row:_}=p((le=k.display_name)!=null?le:k.goal_id);if(_.append(g(k.status==="active")),k.status==="draft"){let G=De("#10b981","Start tracking");G.onclick=async()=>{G.disabled=!0;let he=await ee(e,`/v1/editor/goals/${encodeURIComponent(k.goal_id)}/publish`,{});G.disabled=!1,ae(he,"\u2713 Tracking is live \u2014 it counts from your next visitor."),he.r==="ok"&&(u("published",{kind:"goal"}),Ne())},_.append(G,dt(`/v1/editor/goals/${encodeURIComponent(k.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{gn(k.goal_id),Ne()}))}se.append(_)}}},At=n=>{ie!==n&&(W(),Qe(),ie=n,lt())},on=a("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(K.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let rn=!1,Le=a("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"46px",height:"46px",borderRadius:"50%",border:"1px solid rgba(99,102,241,0.55)",background:"#111827",color:"#fff",cursor:"pointer",display:"none",alignItems:"center",justifyContent:"center",gap:"4px",font:"700 15px system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"}),sn=a("span",{width:"7px",height:"7px",borderRadius:"50%",background:"#34d399",display:"inline-block"});sn.className="sntedi-dot",Le.append(sn,a("span",{},"S")),Le.title="Open the SentientUI editor";let an=a("button",{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",color:"#fff",border:"none",cursor:"pointer",whiteSpace:"nowrap"},"Minimize");an.onclick=()=>{D.style.display="none",Le.style.display="flex",rn=O,O=!0,w.style.display="none",Je(document)},Le.onclick=()=>{D.style.display="block",Le.style.display="none",O=rn},Object.assign(q.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Object.assign(Oe.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",whiteSpace:"nowrap"}),on.append(K,q,an,Oe);let ln=a("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),_e=a("div",{});Object.assign(Q.style,{marginBottom:"4px"}),ln.append(_e,Q,ue,pe);let ge=a("button",{display:"none",width:"auto",margin:"0",padding:"5px 10px",flex:"0 0 auto",fontSize:"11px",borderRadius:"999px",background:"rgba(250,204,21,0.15)",border:"1px solid rgba(250,204,21,0.45)",color:"#fde68a",cursor:"pointer",whiteSpace:"nowrap"},"\u2728 Ask AI"),Bt=a("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(Y.style,{flex:"1 1 auto",marginBottom:"0"}),Bt.append(Y,ge),Object.assign(Bt.style,{marginBottom:"6px"});let me=a("div",{}),B=a("div",{marginTop:"4px"});B.addEventListener("input",()=>{He=!0}),B.addEventListener("change",()=>{He=!0}),D.append(on,M,Bt,fe,Pe,me,Qt,en,B,ln),((Sn=document.body)!=null?Sn:document.documentElement).append(w,L,D,Le);let Ie=null,dn=()=>{Ie==null||Ie(),Ie=null},cn=()=>{Ie=null},He=!1,$t=null,W=()=>{dn(),B.textContent="",He=!1,$t=null,Ht=!1},Ve=(n,o,s,l)=>{var E;W();let d={},m={},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 n){let T=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},f.label);if(B.append(T),f.type==="select"){let S=a("select",g);S.setAttribute("data-field",f.key);let P=document.createElement("option");P.value="",P.textContent="\u2014 no change \u2014",S.append(P);for(let F of(E=f.options)!=null?E:[]){let X=document.createElement("option");X.value=F,X.textContent=F,S.append(X)}d[f.key]=()=>S.value,B.append(S)}else if(f.type==="color"){let S=a("input",J(R({},g),{padding:"2px",height:"34px"}));S.type="color",S.setAttribute("data-field",f.key);let P=!1;S.addEventListener("input",()=>{P=!0}),d[f.key]=()=>P?S.value:"",B.append(S)}else{let S=a("input",g);S.setAttribute("data-field",f.key),f.value!==void 0&&(S.value=f.value),d[f.key]=()=>S.value,B.append(S)}let A=a("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});A.setAttribute("data-feedback",f.key),m[f.key]=A,B.append(A)}let p=(f,T)=>{let A=m[f];A&&(A.textContent=T!=null?T:"",A.style.display=T?"block":"none")};if(l){let f=pn(l);B.append(f.node),d[Xe]=f.value}let v=a("button",I("#6366f1"),o),x=a("button",J(R({},I("transparent")),{opacity:"0.6"}),"Cancel");v.onclick=()=>s(Object.fromEntries(Object.entries(d).map(([f,T])=>[f,T()])),p),x.onclick=W,B.append(v,x)},Xe="__page",un={},Zn=n=>{var o;for(let s of n!=null?n:[])un[s.slot_id]=(o=s.target)==null?void 0:o.page};st(e,"/v1/editor/slots").then(n=>Zn(n==null?void 0:n.slots));let pn=n=>{let o=Ft(location.pathname),s=a("div",{}),l=a("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 d of Hn(o,un[n])){let m=document.createElement("option");m.value=d,m.textContent=Nn(d,o),l.append(m)}return s.append(a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),l,a("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:s,value:()=>l.value}},ct=(n,o)=>o?J(R({},n),{page:o}):n,y=(n,o=!0)=>{Q.textContent=n,Q.style.color=o?"#a7f3d0":"#fca5a5"},Mt=(n,o)=>{var l,d;if(u("error_shown",{code:(d=n.code)!=null?d:`http_${(l=n.status)!=null?l:"network"}`}),n.code==="plan_limit_reached"){let m=n.feature==="live_goals"?"live goal":"of these",g=n.plan?`${n.plan} plan`:"plan";return n.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 ${m}. Manage them in your dashboard, or upgrade for more.`}if(n.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(n.code==="demo_read_only"&&n.message)return n.message;let s=n.status?` (HTTP ${n.status})`:"";return`\u26A0 Couldn\u2019t ${o} \u2014 try again.${s}`},ae=(n,o)=>{n.r==="ok"?y(o,!0):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):y(Mt(n,"save"),!1)},Ae=null,ut=n=>n.length>30?`${n.slice(0,27)}\u2026`:n,fn=n=>{Ae===n&&(Ae=null,ue.style.display="none",re.style.display="none",_e.textContent="")},gn=n=>{Fe===n&&(Fe=null,pe.style.display="none",_e.textContent="")},pt=(n,o,s)=>{Ae=n,ue.textContent=o?`Publish \u201C${ut(o)}\u201D \u2014 go live`:"Publish now \u2014 go live",ue.style.display="block",re.style.display="block";let l=[];if(s){let d=De("#374151","Preview");d.onclick=()=>tn(n,s),l.push(d)}l.push(dt(`/v1/editor/slots/${encodeURIComponent(n)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>fn(n))),nn(o?`Draft saved for \u201C${ut(o)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ue.onclick=async()=>{if(!Ae)return;ue.disabled=!0,y("Publishing\u2026");let n=await ee(e,`/v1/editor/slots/${encodeURIComponent(Ae)}/publish`,{});ue.disabled=!1,n.r==="ok"?(u("published",{kind:"slot"}),y("\u2713 Published \u2014 live for new visitors.",!0),ue.style.display="none",Ae=null,_e.textContent=""):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):y(Mt(n,"publish"),!1)};let U=null,ze=!1,Ke=null,je=null,de=null,Be=null,Ze=null,ft=null,$e=!1,mn=(n,o)=>ze?n?"":`Nothing to swap with ${o} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",hn=()=>{xe.disabled=!ze||!de,we.disabled=!ze||!Be,xe.title=xe.disabled?mn(de,"above"):"",we.title=we.disabled?mn(Be,"below"):""},ce=null,Rt=n=>{n&&!ce&&t&&U?(ce=pn(ve("move",U,t)),Ye.before(ce.node)):n||(ce==null||ce.node.remove(),ce=null),Ye.style.display=n?"block":"none",at.style.display=n?"block":"none",hn()},Qe=()=>{if($e&&t&&Ze&&Ze.insertBefore(t,ft),$e=!1,Ze=null,ft=null,t){let n=Et(t,document);Ke=n.prevEl,je=n.nextEl,de=n.prevLocator,Be=n.nextLocator}b(),Rt(!1)},yn=n=>{if(O)return;let o=n.target;if(!o||D.contains(o)||o===w)return;Je(document);let s=o.getBoundingClientRect();Object.assign(w.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},Me=n=>{var s;let o=((s=n.textContent)!=null?s:"").trim().replace(/\s+/g," ");return o?o.length>40?`${o.slice(0,37)}\u2026`:o:n.tagName.toLowerCase()},Qn=n=>!!n.id||["section","header","footer","nav","main","form","article","aside"].includes(n.tagName.toLowerCase())||!!n.querySelector(":scope > h1, :scope > h2, :scope > h3"),eo=n=>{var l;let o=n.querySelector("h1, h2, h3"),s=(l=o==null?void 0:o.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return s?s.length>28?`${s.slice(0,25)}\u2026`:s:n.id?`#${n.id.length>24?`${n.id.slice(0,21)}\u2026`:n.id}`:`<${n.tagName.toLowerCase()}>`},to=n=>{fe.textContent="";let o=[];for(let g=n.parentElement;g&&g!==document.body&&o.length<3;g=g.parentElement)Qn(g)&&o.push(g);let s=Me(n),l=()=>a("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),d=!0;for(let g of o){let p=eo(g);if(p===s||s.startsWith(p))continue;let v=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);v.onclick=()=>gt(g),d||fe.append(l()),fe.append(v),d=!1}d||fe.append(l());let m=a("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");m.onclick=()=>vn(),fe.append(m),fe.style.display="block"},no=n=>{Pe.textContent="";let o=null,s=0;for(let d=n.parentElement;d&&d!==document.body&&s<6;d=d.parentElement,s++)if(ot(qe(d,document),d,document)){o=d;break}let l=a("div",{marginBottom:"8px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(252,165,165,0.12)",border:"1px solid rgba(252,165,165,0.4)"});if(o){let d=o;l.append(a("div",{marginBottom:"6px"},"This exact element can\u2019t be tracked safely \u2014 it looks identical to others on the page. You can pick something more specific inside it, or work with the whole block, which we can target reliably."));let m=a("button",J(R({},I("#6366f1")),{marginTop:"0"}),`Select \u201C${Me(d)}\u201D instead`);m.onclick=()=>gt(d);let g=a("button",J(R({},I("transparent")),{opacity:"0.6"}),"Pick something else");g.onclick=()=>{Pe.textContent=""},l.append(m,g)}else l.append(a("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));Pe.append(l)},gt=n=>{Qe(),W(),Pe.textContent="",t=n,U=qe(n,document);let o=ot(U,n,document);ze=o,b(),Y.style.display="block",Y.textContent=`Selected: ${Me(n)}`,to(n),u("element_selected",{unique:o}),y(o?"\u2713 Matches exactly 1 element":"",o),o||no(n),M.style.display="none",ge.style.display="inline-block",me.textContent="";for(let m of _t)m.style.display="block";N.style.display="none",j.style.display="none";let s=n.childElementCount===0;N.disabled=!o||!s,N.title=o?s?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",j.disabled=!o,ne.disabled=!o,V.disabled=!o;let l=n.closest("form");h.style.display=l?"block":"none",h.disabled=!l;let d=Et(n,document);Ke=d.prevEl,je=d.nextEl,de=d.prevLocator,Be=d.nextLocator,hn(),lt()},vn=()=>{Qe(),W(),t=null,U=null,ze=!1,Ke=null,je=null,de=null,Be=null,b(),Pe.textContent="",me.textContent="",fe.textContent="",fe.style.display="none",Y.textContent="",Y.style.display="none",ge.style.display="none";for(let n of _t)n.style.display="none";M.style.display="block",y(""),lt()},Ue=!1,Ot=-1,bn=n=>{var l,d;let o=n.target,s=!!((l=o==null?void 0:o.closest)!=null&&l.call(o,'input, textarea, select, [contenteditable="true"]'));if(n.key==="Escape"){if(B.childElementCount>0){W(),Ue=!1;return}if(t){vn(),Ue=!1;return}if(!Ue){Ue=!0,y("Press Esc again to close the editor.");return}Ue=!1,(d=Oe.onclick)==null||d.call(Oe,new MouseEvent("click"));return}if(Ue=!1,!(s||O)){if(n.key==="ArrowUp"||n.key==="ArrowDown"){if(!t||(n.key==="ArrowUp"?xe:we).disabled)return;n.preventDefault(),Nt(n.key==="ArrowUp"?"up":"down");return}if(n.key==="Tab"){let m=[];for(let p of Gn){let v=ye(p.locator,document);v&&!m.includes(v)&&m.push(v)}if(m.length===0)return;if(He){y("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),n.preventDefault();return}n.preventDefault(),Ot=(Ot+(n.shiftKey?-1:1)+m.length)%m.length;let g=m[Ot];gt(g);try{g.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},xn=n=>{if(O)return;let o=n.target;if(!(!o||D.contains(o))){if(n.preventDefault(),n.stopPropagation(),He&&o!==t&&$t!==o){$t=o,y("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}gt(o)}};N.onclick=()=>{var m,g,p;if(!t||!U)return;u("form_opened",{kind:"text"});let n=U,o=(g=(m=t.textContent)==null?void 0:m.trim())!=null?g:"";Ve([{key:"current",label:"Current wording",value:o},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async v=>{let x=v.alt.trim();if(!x){y("\u26A0 Enter alternative wording to test.",!1);return}if(x===v.current.trim()){y("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let E=ve("text",n,t);y("Saving\u2026");let f=await ee(e,`/v1/editor/slots/${encodeURIComponent(E)}`,{kind:"arms",target:ct(n,v[Xe]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:v.current}},{id:"b",displayName:"Alternative",ops:{text:v.alt}}]}});f.r==="ok"&&(u("draft_saved",{kind:"slot"}),cn(),W(),pt(E,Me(t),"b")),ae(f,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},ve("text",n,t));let s=t,l=(p=s.textContent)!=null?p:"";Ie=()=>{s.textContent=l};let d=B.querySelector('input[data-field="alt"]');d==null||d.addEventListener("input",()=>{s.textContent=d.value.trim()===""?l:d.value})};let et=null,wn=n=>{let o=p=>{var v;return((v=p.textContent)!=null?v:"").replace(/\s+/g," ").trim()},s=Array.from(n.querySelectorAll("h1,h2,h3,h4")).map(o).filter(Boolean);if(s.length===0){let p=n.closest("h1,h2,h3,h4");p&&s.push(o(p))}let l=Array.from(n.querySelectorAll("p")).map(o).filter(p=>p.length>0&&p.length<=300),d=[];for(let p of Array.from(n.querySelectorAll("a[href], button"))){let v=o(p);if(!v||v.length>60)continue;let x="",E=p.getAttribute("href");if(E)try{let f=new URL(E,window.location.href);f.protocol==="https:"&&(x=f.href)}catch(f){}d.push({label:v,href:x})}let m=Array.from(n.querySelectorAll("blockquote, q")).map(o).filter(Boolean);if(m.length===0&&Go.test(`${n.className} ${n.id}`))for(let p of l)p.length>=20&&m.push(p);let g=Array.from(n.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(o).filter(p=>p.length>0&&p.length<=80);return{headings:s,paragraphs:l,links:d,quotes:m,attributions:g}},oo=(n,o)=>{var l,d,m,g,p,v,x,E,f,T,A,S,P,F,X,Se,le,k,_,G;let s=he=>{var Ee;return o.paragraphs.length>=3&&(Ee=o.paragraphs[o.paragraphs.length-3+he])!=null?Ee:""};switch(n){case"headline":return(l=o.headings[0])!=null?l:"";case"supporting":return(d=o.paragraphs[0])!=null?d:"";case"cta_label":return(g=(m=o.links[0])==null?void 0:m.label)!=null?g:"";case"cta_href":return(v=(p=o.links[0])==null?void 0:p.href)!=null?v:"";case"secondary_label":return(E=(x=o.links[1])==null?void 0:x.label)!=null?E:"";case"secondary_href":return(T=(f=o.links[1])==null?void 0:f.href)!=null?T:"";case"quote":case"q1":return(A=o.quotes[0])!=null?A:"";case"q2":return(S=o.quotes[1])!=null?S:"";case"q3":return(P=o.quotes[2])!=null?P:"";case"name":case"n1":return(F=o.attributions[0])!=null?F:"";case"n2":return(X=o.attributions[1])!=null?X:"";case"n3":return(Se=o.attributions[2])!=null?Se:"";case"role":return(le=o.attributions[1])!=null?le:"";case"eyebrow":return"";case"f1_title":return(k=o.headings[1])!=null?k:"";case"f2_title":return(_=o.headings[2])!=null?_:"";case"f3_title":return(G=o.headings[3])!=null?G:"";case"f1_body":return s(0);case"f2_body":return s(1);case"f3_body":return s(2);default:return""}},ro=(n,o,s)=>{u("form_opened",{kind:"arrangement"});let l=wn(s);Ve(n.fields.map(d=>({key:d.id,label:d.kind==="href"?`${d.label} (https link \u2014 required)`:d.label,value:oo(d.id,l)})),"Save draft",async(d,m)=>{var A,S,F,X,Se;let g=!1,p=!1;for(let le of n.fields){if(le.kind==="href"){let _=!1;try{_=new URL((A=d[le.id])!=null?A:"").protocol==="https:"}catch(G){}m(le.id,_?null:"Links need to start with https://"),_||(g=!0);continue}let k=((S=d[le.id])!=null?S:"").trim()==="";m(le.id,k?"Fill this in with your own words":null),k&&(p=!0)}if(g){y("\u26A0 Fix the highlighted link(s).",!1);return}if(p){y("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}y("Saving\u2026");let P=d,{[Xe]:v}=P,x=Ln(P,[Tn(Xe)]),E=await Uo(e,`/v1/editor/arrangements/${encodeURIComponent(n.id)}/instantiate`,{fields:x});if(E.r!=="ok"||!((F=E.data)!=null&&F.blocks)){E.r==="expired"?ae(E.outcome,""):y(`\u26A0 ${(Se=(X=E.data)==null?void 0:X.reason)!=null?Se:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let f=ve("arrange",o,s),T=await ee(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:ct(o,v),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:n.id,displayName:n.name,blocks:E.data.blocks}],baseline:"original"}});T.r==="ok"&&(u("draft_saved",{kind:"arrangement"}),W(),pt(f,n.name,n.id)),ae(T,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")},ve("arrange",o,s))};ne.onclick=async()=>{var m,g;if(!t||!U)return;let n=U,o=t;if(W(),y("Loading arrangements\u2026"),!et){let p=await st(e,"/v1/editor/arrangements");et=(m=p==null?void 0:p.arrangements)!=null?m:null}if(!et||et.length===0){y("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let s=Jn(wn(o)),l=et.filter(p=>s.includes(p.sectionType));if(l.length===0){y("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}y("Pick a layout for this section \u2014 your own words are carried across.");for(let p of l){let v=a("button",J(R({},I("#374151")),{textAlign:"left"}));v.append(a("div",{fontWeight:"600"},p.name),a("div",{fontSize:"11px",opacity:"0.7"},p.description)),v.onclick=()=>ro(p,n,o),B.append(v)}let d=a("button",J(R({},I("transparent")),{opacity:"0.6"}),"Cancel");d.onclick=W,B.append(d),(g=B.scrollIntoView)==null||g.call(B,{block:"nearest"})};let Fe=null,io=(n,o)=>{Fe=n,pe.textContent=o?`Start tracking \u201C${ut(o)}\u201D now`:"Start tracking now",pe.style.display="block",nn(o?`Goal \u201C${ut(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.",[dt(`/v1/editor/goals/${encodeURIComponent(n)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>gn(n))])};pe.onclick=async()=>{if(!Fe)return;pe.disabled=!0,y("Activating\u2026");let n=await ee(e,`/v1/editor/goals/${encodeURIComponent(Fe)}/publish`,{});pe.disabled=!1,n.r==="ok"?(u("published",{kind:"goal"}),y("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),pe.style.display="none",Fe=null,_e.textContent=""):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):y(Mt(n,"activate"),!1)};let Pt=(n,o)=>`${kt(n)||"goal"}-${Un(o)}`.slice(0,128),so=n=>{var l,d,m;let o=((l=n.textContent)!=null?l:"").replace(/\s+/g," ").trim();return o&&o.length<=60?o:((m=(d=n.getAttribute("aria-label"))!=null?d:n.getAttribute("id"))!=null?m:"").trim()||"element-clicked"},mt=async(n,o,s)=>{y("Saving\u2026");let l=await ee(e,`/v1/editor/goals/${encodeURIComponent(n)}`,o);l.r==="ok"&&(u("draft_saved",{kind:"goal"}),io(n,s)),ae(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live.")};V.onclick=()=>{if(!t||!U)return;let n=Pt(so(t),JSON.stringify(U));mt(n,{event:"click",locator:U},Me(t))},h.onclick=()=>{var l,d;let n=t==null?void 0:t.closest("form");if(!n)return;let o=qe(n,document),s=(d=(l=n.getAttribute("id"))!=null?l:n.getAttribute("name"))!=null?d:"form-submitted";mt(Pt(s,JSON.stringify(o)),{event:"form_submit",locator:o},s)},H.onclick=()=>{let n=window.location.pathname||"/",o=kt(n)?`reached-${kt(n)}`:"page-visited";mt(Pt(o,n),{event:"url_reached",urlPattern:n},n)};let Dt=[{label:"25% \u2014 skimmed the top",value:.25},{label:"50% \u2014 read halfway",value:.5},{label:"75% \u2014 read most of the page",value:.75},{label:"90% \u2014 read to the end",value:.9}];oe.onclick=()=>{Ve([{key:"depth",label:"Counts once a visitor reads",type:"select",options:Dt.map(n=>n.label)}],"Track it",n=>{var l;let o=(l=Dt.find(d=>d.label===n.depth))!=null?l:Dt[2],s=Math.round(o.value*100);mt(`read-${s}pct`,{event:"scroll_depth",threshold:o.value},`read ${s}%`),W()})};let ht=null,ao=n=>{ht=n,Te.style.display="block"};Te.onclick=async()=>{if(!ht)return;Te.disabled=!0,y("Turning on\u2026");let n=await ee(e,`/v1/editor/funnels/${encodeURIComponent(ht)}/publish`,{});Te.disabled=!1,n.r==="ok"?(u("published",{kind:"funnel"}),y("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),Te.style.display="none",ht=null):n.r==="expired"?y("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):y("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},z.onclick=async()=>{var E;y("Loading your goals\u2026");let n=await st(e,"/v1/editor/goals"),o=(E=n==null?void 0:n.goals)!=null?E:[];if(o.length<2){y("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}y("Pick the steps in order \u2014 first click = first step."),W();let s=[],l=a("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),d=a("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});B.append(l,d);let m=a("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");B.append(m);let g=new Map,p=()=>{var f,T;for(let[A,S]of g){let P=s.indexOf(A),F=(T=(f=o.find(X=>X.goal_id===A))==null?void 0:f.display_name)!=null?T:A;S.textContent=P===-1?F:`${P+1}. ${F}`,S.style.background=P===-1?"#374151":"#6366f1"}};for(let f of o){let T=a("button",J(R({},I("#374151")),{textAlign:"left"}));g.set(f.goal_id,T),T.onclick=()=>{s=zn(s,f.goal_id),p()},B.append(T)}p();let v=a("button",I("#6366f1"),"Save funnel"),x=a("button",J(R({},I("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=W,v.onclick=async()=>{let f=Kn(d.value,s);if(!f.ok){y(`\u26A0 ${f.error}`,!1);return}y("Saving\u2026");let T=await ee(e,`/v1/editor/funnels/${encodeURIComponent(f.funnelId)}`,f.body);T.r==="ok"&&(u("draft_saved",{kind:"funnel"}),W(),ao(f.funnelId)),ae(T,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},B.append(v,x)},re.onclick=async()=>{var p,v;let n=Ae;if(!n)return;y("Loading funnels\u2026");let o=await st(e,"/v1/editor/funnels"),s=(p=o==null?void 0:o.funnels)!=null?p:[];if(s.length===0){y("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await st(e,"/v1/editor/goals"),d=new Map(((v=l==null?void 0:l.goals)!=null?v:[]).map(x=>[x.goal_id,x.display_name]));Ve([{key:"funnel",label:"Funnel",type:"select",options:s.map(x=>xt(x))},{key:"step",label:"Which step does this element serve?",type:"select",options:wt(s[0],d).map(x=>x.label)}],"Attach",async x=>{var A;let E=(A=s.find(S=>xt(S)===x.funnel))!=null?A:s[0],f=wt(E,d).findIndex(S=>S.label===x.step);if(f<0){y("\u26A0 Pick which step this element serves.",!1);return}y("Attaching\u2026");let T=await ee(e,`/v1/editor/funnels/${encodeURIComponent(E.funnel_id)}/assign`,{slotId:n,stepIndex:f});T.r==="ok"&&W(),ae(T,`\u2713 Attached \u2014 this test now works toward \u201C${E.display_name}\u201D.`)});let m=B.querySelector('select[data-field="funnel"]'),g=B.querySelector('select[data-field="step"]');m&&g&&m.addEventListener("change",()=>{var E;let x=(E=s.find(f=>xt(f)===m.value))!=null?E:s[0];g.length=1;for(let f of wt(x,d)){let T=document.createElement("option");T.value=f.label,T.textContent=f.label,g.append(T)}})},j.onclick=()=>{if(!t||!U)return;u("form_opened",{kind:"style"});let n=U;Ve([{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:Wt.length?`Font (this site has: ${Wt.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 A;let{style:v,errors:x}=Yt(g),E=!1;for(let S of Jt)p(S,(A=x[S])!=null?A:null),x[S]&&(E=!0);if(E){y("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(v).length===0){y("\u26A0 Enter at least one style change.",!1);return}let f=ve("style",n,t);y("Saving\u2026");let T=await ee(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:ct(n,g[Xe]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:v}}]}});T.r==="ok"&&(u("draft_saved",{kind:"slot"}),cn(),W(),pt(f,Me(t),"b")),ae(T,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},ve("style",n,t));let o=t,s=o.style.cssText;Ie=()=>{o.style.cssText=s};let l={},d=()=>{let{style:g}=Yt(l);o.style.cssText=s;for(let[p,v]of Object.entries(g)){let x=bt[p];x&&it(v)&&o.style.setProperty(x,v.trim(),"important")}};for(let g of Jt){let p=B.querySelector(`[data-field="${g}"]`);if(!p)continue;let v=()=>{l[g]=p.value,d()};p.addEventListener("input",v),p.addEventListener("change",v)}let m=[be==null?void 0:be.primaryBg,be==null?void 0:be.primaryText,"#ffffff"].filter(g=>!!g).map(St).filter((g,p,v)=>Tt(g)&&v.indexOf(g)===p);for(let g of["color","background"]){let p=B.querySelector(`input[data-field="${g}"]`);if(!p)continue;let v=a("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let x of m){let E=a("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:x,padding:"0"});E.title=x,E.onclick=()=>{p.value=St(x),p.dispatchEvent(new Event("input"))},v.append(E)}p.after(v)}};let kn=n=>{var l;let o=n==="text"?N:j;if(o.disabled)return y(o.title||"This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section.",!1),!1;At(n);let s=n==="text"?'[data-field="alt"]':'[data-field="color"]';return B.querySelector(s)||(l=o.onclick)==null||l.call(o,new MouseEvent("click")),!0},lo=()=>{if(!t)return;me.textContent="";let n=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"}),o=a("input",{width:"100%",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"});o.type="text",o.maxLength=300,o.placeholder="e.g. shorter and more urgent",o.setAttribute("data-field","ai-instruction");let s=a("button",J(R({},I("#6366f1")),{display:"inline-block",width:"auto",margin:"8px 0 0",padding:"4px 10px",fontSize:"11px"}),"Go");s.setAttribute("data-action","ai-go"),s.onclick=()=>{co(o.value.trim())},o.onkeydown=l=>{var d;l.key==="Enter"&&(l.preventDefault(),(d=s.onclick)==null||d.call(s,new MouseEvent("click")))},n.append(a("div",{fontWeight:"600",marginBottom:"4px"},"What should this element do differently?"),o,a("div",{opacity:"0.7",fontSize:"11px",marginTop:"4px"},"Leave it blank for ideas. Nothing goes live \u2014 you review and save whatever comes back."),s),me.append(n),o.focus()};ge.onclick=()=>lo();let co=async n=>{var p,v;if(!t)return;let o=t;ge.disabled=!0;let s=ge.textContent;ge.textContent="Thinking\u2026",me.textContent="",u("form_opened",{kind:"suggest"});let l={},d=null;try{let x=await fetch(`${e.apiBase}/v1/editor/suggest`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(R(R({element:{tag:o.tagName.toLowerCase(),text:((p=o.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,400)},pageUrl:window.location.pathname},n?{instruction:n.slice(0,300)}:{}),be?{palette:be}:{}))});x.ok?l=await x.json():d=x.status===401?"expired":"error"}catch(x){d="error"}if(ge.disabled=!1,ge.textContent=s,t!==o)return;if(d){y(d==="expired"?"Editor session expired \u2014 reopen it from your dashboard to keep editing.":"\u26A0 Couldn\u2019t get suggestions \u2014 check your connection and try again.",!1);return}if(l.locked){y("AI suggestions aren\u2019t included in this plan.",!1);return}if(l.exhausted){y("You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.",!1);return}let m=(v=l.suggestions)!=null?v:[];if(m.length===0){y(n?"Couldn\u2019t do that safely on this element \u2014 try asking for a smaller change, or pick a headline or a button.":"No safe suggestions for this element \u2014 try a headline, a button, or a section.",!1);return}let g=(x,E)=>{let f=B.querySelector(`[data-field="${x}"]`);f&&(f.value=E,f.dispatchEvent(new Event("input")))};for(let x of m){let E=a("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",fontSize:"12px",background:"rgba(250,204,21,0.08)",border:"1px solid rgba(250,204,21,0.3)"});E.append(a("div",{fontWeight:"600",marginBottom:"2px"},x.title),a("div",{opacity:"0.75",marginBottom:"6px"},x.reason));let f=a("button",J(R({},I("#6366f1")),{display:"inline-block",width:"auto",margin:"0",padding:"4px 10px",fontSize:"11px"}),"Try it");f.onclick=()=>{var T,A;if(t!==o){me.textContent="";return}if(me.textContent="",x.kind==="text"){if(!kn("text"))return;g("alt",x.variant)}else if(x.kind==="style"){if(!kn("style"))return;for(let[S,P]of Object.entries(x.style))if(S==="color"||S==="background"){let F=St(P);Tt(F)&&g(S,F)}else S==="textAlign"?g(S,P==="start"?"left":P==="end"?"right":P):g(S,P)}else{let S=x.goalType==="form_submit"&&!h.disabled;if(!S&&V.disabled){y("This element can\u2019t be tracked reliably \u2014 select a specific button or link instead.",!1);return}At("goals"),S?(T=h.onclick)==null||T.call(h,new MouseEvent("click")):(A=V.onclick)==null||A.call(V,new MouseEvent("click"))}},E.append(f),me.append(E)}},Nt=n=>{if(!t)return;let o=t.parentElement;if(!o)return;$e||(Ze=o,ft=t.nextSibling,$e=!0),n==="up"&&Ke?o.insertBefore(t,Ke):n==="down"&&je&&o.insertBefore(t,je.nextSibling);let s=Et(t,document);Ke=s.prevEl,je=s.nextEl,de=s.prevLocator,Be=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}b(),Rt(!0),y("Previewing the new position \u2014 keep moving, save, or undo.")};xe.onclick=()=>Nt("up"),we.onclick=()=>Nt("down"),at.onclick=()=>{Qe(),y("Move undone \u2014 back to the original position.")},Ye.onclick=async()=>{if(!t||!U||!$e||!ze)return;let n=de?"moveAfter":"moveBefore",o=de!=null?de:Be;if(!o){y("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=ve("move",U,t);y("Saving\u2026");let l=await ee(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:ct(U,ce==null?void 0:ce.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[n]:o}}]}});l.r==="ok"&&(u("draft_saved",{kind:"move"}),$e=!1,Ze=null,ft=null,Rt(!1),pt(s,Me(t),"b")),ae(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let uo=()=>{var n,o;u("editor_closed"),c(),window.removeEventListener("pagehide",c),i&&clearTimeout(i),Qe(),dn(),document.removeEventListener("mousemove",yn,!0),document.removeEventListener("click",xn,!0),document.removeEventListener("keydown",bn,!0),window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$),Je(document),(n=document.getElementById(Gt))==null||n.remove(),w.remove(),L.remove(),D.remove(),Le.remove(),window.__sentientEditor=null,(o=document.querySelector("meta[data-sentient-editor]"))==null||o.remove(),rt()},Ht=!1;Oe.onclick=()=>{if((He||$e)&&!Ht){Ht=!0,y("\u26A0 Unsaved changes \u2014 click \u201CClose editor\u201D again to discard them.",!1);return}uo()},document.addEventListener("mousemove",yn,!0),document.addEventListener("click",xn,!0),document.addEventListener("keydown",bn,!0),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),lt(),u("editor_opened")}function I(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 Lt="sentient-preview-bar";async function Xo(e,t){var D,Z,K,M,O,q,Y,Q,N,j,ne,V;try{fetch(`${e.apiBase}/v1/editor/telemetry`,{method:"POST",keepalive:!0,headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({events:[{kind:"previewed"}]})}).catch(()=>{})}catch(h){}let r=null;try{let h=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});h.ok&&(r=(Z=((D=(await h.json()).slots)!=null?D:[]).find(oe=>oe.slot_id===t&&oe.kind==="arms"))!=null?Z:null)}catch(h){}let i=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});i.id=Lt;let c=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");c.onclick=()=>{rt();let h=new URL(location.href);for(let H of["sentient_editor","sentient_preview","sentient_arm"])h.searchParams.delete(H);location.assign(h.toString())};let u=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"#6366f1",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Back to editor");u.onclick=()=>{let h=new URL(location.href);for(let H of["sentient_preview","sentient_arm"])h.searchParams.delete(H);location.assign(h.toString())};let w=(q=(O=(K=r==null?void 0:r.draft_config)==null?void 0:K.arms)!=null?O:(M=r==null?void 0:r.published_config)==null?void 0:M.arms)!=null?q:[];if(!r||w.length===0){i.append(a("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),u,c),((Y=document.body)!=null?Y:document.documentElement).append(i);return}let L=new URLSearchParams(location.search).get("sentient_arm"),b=(N=(Q=w.find(h=>h.id===L))!=null?Q:w[1])!=null?N:w[0];i.append(a("span",{fontWeight:"700"},`Previewing: ${(j=r.display_name)!=null?j:r.slot_id}`));let $=r.target&&typeof r.target=="object"?ye(r.target,document):null;if(!$)i.append(a("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{Dn($,b.ops,`preview-${r.slot_id}`,document);try{$.scrollIntoView({block:"center"})}catch(h){}for(let h of w){let H=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:h.id===b.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ne=h.displayName)!=null?ne:h.id);H.onclick=()=>{let oe=new URL(location.href);oe.searchParams.set("sentient_arm",h.id),location.assign(oe.toString())},i.append(H)}}i.append(u,c),((V=document.body)!=null?V:document.documentElement).append(i)}async function Zo(e,t){var D,Z,K;let r=t.lastIndexOf("~"),i=r>0?t.slice(0,r):t,c=r>0?t.slice(r+1):"",u=a("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});u.id=Lt;let w=a("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Exit preview");w.onclick=()=>{rt();let M=new URL(location.href);for(let O of["sentient_editor","sentient_preview_cell"])M.searchParams.delete(O);location.assign(M.toString())};let L=M=>{var O;u.append(a("span",{},M),w),((O=document.body)!=null?O:document.documentElement).append(u)},b=null;try{let M=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${e.token}`}});M.ok&&(b=await M.json())}catch(M){}if(!b)return L("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let $=b.target&&typeof b.target=="object"?ye(b.target,document):null;if(!$)return L("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(b.blocks!=null)$n($,{preview:b.blocks},"preview",document);else if(typeof b.content=="string")$.textContent=b.content;else return L("Nothing to preview in that square yet.");try{$.scrollIntoView({block:"center"})}catch(M){}u.append(a("span",{fontWeight:"700"},`Previewing: ${(D=b.slotName)!=null?D:i}`),a("span",{opacity:"0.85"},`for ${(Z=b.personaDisplay)!=null?Z:c}${b.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),w),((K=document.body)!=null?K:document.documentElement).append(u)}async function Qo(){if(typeof document=="undefined")return;let e=zo();if(!e)return;let t=await Ko(e);if(!t.ok){t.unauthorized?(rt(),jn(No)):jn(Ho);return}let r=new URLSearchParams(location.search).get("sentient_preview");if(r){document.getElementById(Lt)||await Xo(e,r);return}let i=new URLSearchParams(location.search).get("sentient_preview_cell");if(i){document.getElementById(Lt)||await Zo(e,i);return}if(document.getElementById(We))return;Vn(e);let c=Rn(document);be=c,c&&ee(e,"/v1/editor/palette",c);let u=await Fo(e);qn(u),Wn(u,document)}Qo();return vo(er);})();
|
|
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+=`
|
|
25
|
+
|
|
26
|
+
`),d=!1,a+=h.text,s.textContent=a,te&&(te.scrollTop=te.scrollHeight);else if(h.type==="tool_status")d=!0,h.state==="running"&&!a&&(s.textContent=(I=h.name)!=null&&I.startsWith("create_")?"Creating a draft\u2026":"Thinking\u2026");else if(h.type==="choice_prompt"&&h.question){a+=(a?`
|
|
27
|
+
|
|
28
|
+
`:"")+h.question,s.textContent=a;let A=l("div",{display:"flex",gap:"5px",flexWrap:"wrap",marginTop:"6px"});for(let O of(S=h.options)!=null?S:[]){let T=be("#374151",O.label);T.onclick=()=>{Pn(O.label)},A.append(T)}s.append(A)}else if(h.type==="artifact"&&h.artifact){let A=h.artifact.type==="editor_component_draft"?xo(h.artifact.payload):h.artifact.type==="editor_goal_draft"?ko(h.artifact.payload):null;A&&g.push(A.then(O=>{u.push(O),O.startsWith("\u26A0")&&Re("note",O)}))}};try{let f=Pe.slice(-20);for(;((y=f[0])==null?void 0:y.role)==="assistant";)f=f.slice(1);let h=await fetch(`${e.apiBase}/v1/editor/chat`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({messages:f,context:bo()})});if(!h.ok){let T=(k=await h.json().catch(()=>null))==null?void 0:k.error;s.textContent=h.status===401?"Editor session expired \u2014 reopen it from your dashboard. Your drafts are safe.":T==="rate_limit"?"You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.":T==="plan_required"?"AI chat isn\u2019t included in this plan.":T==="ai_unavailable"?"The assistant is unavailable right now \u2014 try again later.":`\u26A0 Couldn\u2019t reach the assistant \u2014 try again. (HTTP ${h.status})`,Pe.pop();return}let I=(C=h.body)==null?void 0:C.getReader(),S="",A=()=>{let T;for(;(T=S.indexOf(`
|
|
29
|
+
|
|
30
|
+
`))>=0;){for(let ne of S.slice(0,T).split(`
|
|
31
|
+
`))ne.startsWith("data: ")&&p(ne.slice(6));S=S.slice(T+2)}};if(I){let T=new TextDecoder;for(;;){let{done:ne,value:oe}=await I.read();if(ne)break;S+=T.decode(oe,{stream:!0}),A()}}else S=await h.text();S+=`
|
|
32
|
+
|
|
33
|
+
`,A(),await Promise.all(g),a||(s.textContent=u.some(T=>T.startsWith("["))?"Done \u2014 have a look at the page.":"No reply \u2014 try rephrasing.");for(let T of u)T.startsWith("\u26A0 The assistant")&&Re("note",T);let O=[a,...u.filter(T=>T.startsWith("["))].filter(Boolean).join(`
|
|
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);})();
|
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.27.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 pt=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?pt(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)pt(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&&pt(e,o,{get:()=>t[o],enumerable:!(r=Qr(t,o))||r.enumerable});return e};var oo=e=>ro(pt({},"__esModule",{value:!0}),e);var io,so,ao,xn,lo,co,kn,N,_e,Je=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 Bi={};An(Bi,{applyPersonaAttributes:()=>_t,applyRegistrySlots:()=>Lt,applySlotArms:()=>It,applySlotAttributes:()=>Ot,parseEditorToken:()=>zr,parsePersonaPreview:()=>Hr,parsePreview:()=>Wr,parseSnippetConfig:()=>At,planReorder:()=>Pt,reapply:()=>lt,run:()=>Jr,version:()=>ot});Je();function gt(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 gt(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 gt(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 mt(e){return e?`_${e.slice(0,12)}`:""}var uo="_snt_uid";function In(e){return`${uo}${mt(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:gt(e)}Je();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,ht="_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=mt(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:In(e==null?void 0:e.apiKey),c=`${ht}${l}`,d=`${ht}_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(ht)))!=null?h:C(Gn(ht)):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 Jn(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=Jn(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 Vn(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=Vn(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 yt(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Mo(e=Do,t){let n=new Map,r=`_snt_asgn${mt(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(yt(d.componentId,d.segment),c)}catch(u){}})(),{get(l,u){let c=n.get(yt(l,u));return c?s(c)?(n.delete(yt(l,u)),null):c:null},set(l,u,c){let d=yt(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 St="_snt_snap:",$o=["low","medium","high"];function Ye(e){try{let t=localStorage.getItem(St+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(St+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,vt=!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):(vt||(vt=!0,console.error(Xt)),null)}).catch(()=>(vt||(vt=!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=Ye(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 wt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Jt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function en(e,t){if(e===void 0||!wt.test(e))return!1;if(e==="*")return!0;let n=Jt(t);if(e.endsWith("/*")){let r=Jt(e.slice(0,-2));return n.startsWith(r==="/"?"/":`${r}/`)&&n!==r}return n===Jt(e)}function Et(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(Et):!1}var Fn="sentient-reveal",Be="sentient-revealed";var Vt=!1;function Ko(e){if(Vt||e.getElementById(Fn)){Vt=!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),Vt=!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 Xe(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",ce=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 bt(){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=bt();!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=bt();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 Ve={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=ce.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:Ze)(_e(N({},o),{consent:!0}));a(s);let l=(t=ce.get(n))==null?void 0:t.dispose;ce.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 Ze(e){var t,n,r,o,a,i,s,l,u,c;if(typeof window=="undefined")return Ve;Zn=e.apiKey||"local";let d=ce.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 ce.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?Ve: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."),ce.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."}),Ve;let{proxy:f,setInner:y}=Wo(e);return ce.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."),Ve;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),Ve;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}$/,ze=new Set,ge=new Set,ct=new Set,qe=new Map,jt=null,ut=new Set,We=new Map,Gt=null,Vr=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<=Vr&&(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=Ye(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(),He=null,Ft=!1,oe={goal(f,y={},k=1,$=0){var B,I,P,D,V,ie,se;let we=v.getSessionId();if(!we)return;let re=Go(y)?y:{metadata:y},dt=[f,(B=re.externalId)!=null?B:"",(I=re.stepIndex)!=null?I:$,(P=re.weight)!=null?P:k].join("\0"),ft=re.value!==void 0?`${re.value}\0${(D=re.currency)!=null?D:""}`:null;if(Yr.firedBefore(dt,ft)){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:(V=re.metadata)!=null?V:{},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),V=D?null:($=S.get(f))!=null?$:null;if(!D&&V===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(V),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:bt()};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:bt()},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 V=await D.json();return O.set(f,W,N({variantId:V.variantId,assignedAt:Date.now(),segment:W,confidence:1,content:V.content},V.assignmentTtlMs&&V.assignmentTtlMs>0?{ttlMs:V.assignmentTtlMs}:{})),V}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,V,ie,se,we,re,dt,ft;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 me=(D=G.slots)==null?void 0:D[H.id];if(me!==void 0){Ee[H.id]=me,S.set(H.id,me),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,me]of Object.entries(G.slots))H in Ee||(Ee[H]=me,S.set(H,me),T.add(H));let Xr=x!=null&&x.persona!=="unknown";G.persona&&!(G.persona==="unknown"&&Xr)?x={persona:G.persona,confidence:(V=G.confidence)!=null?V:0}:x||(x={persona:"unknown",confidence:0});for(let[H,me]of Object.entries((ie=G.assignments)!=null?ie:{}))O.set(H,W,{variantId:me,assignedAt:Date.now(),segment:W,confidence:1});if(G.slotConfig)for(let[H,me]of Object.entries(G.slotConfig))Y.set(H,me);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:(dt=G.layoutOrder)!=null?dt:null,assignments:(ft=G.assignments)!=null?ft:{},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()&&!ze.has(k)&&(ze.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)ct.has(k)||(ct.add(k),Re.test(k)?qe.set(k,y==null?void 0:y[k]):oe.reportSlots([k]));qe.size===0||jt!=null||(jt=setTimeout(()=>{jt=null;let k=[...qe];qe.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={},V=[];for(let[ie,se]of B)(P=I.slotConfig)!=null&&P[ie]||(V.push(ie),se&&(D[ie]=se));V.length>0&&oe.reportSlots(V,D)}else pn(B.map(([D])=>D),ct,D=>{var V;let ie={};for(let[se,we]of B)D.has(se)&&we&&(ie[se]=we);(V=oe.requestSlots)==null||V.call(oe,[...D],ie)});ge.forEach(D=>D())})}},0))},decideSlots(f){for(let y of f)ut.has(y.id)||(ut.add(y.id),We.set(y.id,y));We.size===0||Gt!=null||(Gt=setTimeout(()=>{Gt=null;let y=[...We.values()];We.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),ut,I=>{var P;return(P=oe.decideSlots)==null?void 0:P.call(oe,$.filter(D=>I.has(D.id)))}),ge.forEach(I=>I())})}},0))},cancelSlots(f){for(let y of f)qe.delete(y)&&ct.delete(y),We.delete(y)&&ut.delete(y)},onSlotsChanged(f){return ge.add(f),()=>{ge.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;He==null||He(),Ft=!0,Ut=!0,b.destroy(),E.destroy(),((f=ce.get(e.apiKey))==null?void 0:f.dispose)===oe.dispose&&ce.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var f;He==null||He(),Ft=!0,Ut=!0,b.destroy(),E.destroy(),v.destroy(),O.clear(),((f=ce.get(e.apiKey))==null?void 0:f.dispose)===oe.dispose&&ce.delete(e.apiKey);try{localStorage.removeItem(St+e.apiKey),localStorage.removeItem(Jn(e.apiKey)),localStorage.removeItem(Vn(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(ce.set(e.apiKey,{config:e,upgrade:null,dispose:oe.dispose}),He=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 Jo(e){return{tag:e.tagName.toLowerCase(),text:rn(e).slice(0,40)}}function tr(e){return e.replace(/["\\\]]/g,"\\$&")}function Qe(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(Qe(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(Qe(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(Qe(t,d))return d}}}return null}function rr(e,t){let n=Jo(e),r=e.getAttribute("id");if(r&&Qe(t,`#${tr(r)}`))return{v:1,id:r,fingerprint:n};for(let a of Ho){let i=e.getAttribute(a);if(i&&Qe(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}Je();var ir=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Vo={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Yo(e){let t=e.ariaRole?Vo[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}:{})}Je();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(ge=>ir.includes(ge)))!=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 ze=on.filter(([,ge])=>ge.test(R.bodyText)).map(([ge])=>ge);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}:{}),ze.length>0?{patternFlags:ze}:{})}))}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(Xe((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 At(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n={};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 et(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 xt(e,t){return!!(e!=null&&e.urlMatch)&&!et(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&&!et(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 xt(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 kt(e,t){return xt(e,t)?!1:e.page!==void 0&&wt.test(e.page)?en(e.page,et(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 tt="data-sentient-block-arm",L=null;function je(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 ue(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;ue(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;ue(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&&ue(A,{padding:(s=Ke[F])!=null?s:Ke.md}),E&&ue(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,ue(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,ue(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 ue(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),ue(A,{color:"inherit","text-decoration":"underline"})}case"image":{let A=t.createElement("img");return A.src=e.src,A.alt=e.alt,ue(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,ue(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 ue(t.createElement("div"),{height:(w=br[e.size])!=null?w:br.md});case"divider":return ue(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(tt);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(tt,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(tt),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(tt)!==null){n.remove();continue}n.hasAttribute(ve)&&(n.style.display=n.getAttribute(ve),n.removeAttribute(ve))}}catch(t){}}function Ct(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${tt}]`)))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 _t(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 Ot(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 It(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 Lt(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(xt(m.locator,n))continue;let C;if(m.locator){let g=ye(m.locator,n);C=g?[g]:[],!g&&kt(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])=>!Et(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 Ct(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 Tt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:a,el:i},s)=>{r.push(Xe((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 Rt(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=et(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 Pt(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),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.29.0",$t=ot!=="0.0.0-dev"?{name:"snippet",version:ot}:void 0,$r=ot!=="0.0.0-dev"?{v:ot}:{},it=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={},le=null,X=null,xe=null,te=null,he=null,J=null,Le=null,Ir=!1,ln=null,Dt=null,Bt=null,Te=!1,nt=!1,ke=!1,Nt=null,Ce=[],Kt=null,rt=null,ae=null,ki=3e3,Ci=100;function st(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 pe(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Ge(e,t){return Q?(Q.personaAttributes&&J&&_t(J.persona,J.band,e,t==null?void 0:t.onAttr),Ot(de,Q.slots,e,t==null?void 0:t.onAttr),It(de,Q.slots,e,t==null?void 0:t.onAttr),le?Lt(de,le,e,j(j({},t),J?{persona:J.persona}:{})):(Ct(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=Pt(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 at(e){var t;return(t=e.apiBase)!=null?t:"https://api.sentient-ui.com"}function Ii(e){return Promise.resolve().then(()=>fetch(`${at(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):kt(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(){!Nt||!Te||Kt===window.location.pathname||(Kt=window.location.pathname,Li())}function Li(){ae==null||ae();let e=Q,t=Nt;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))&<(),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 st(n.decide(j({slotsFrom:"registry",registrySlotIds:e},$r)),it);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&&(le=j(j({},le),o)),lt(),pe(t,"late decide",e),rt&&Ne(t.apiKey,rt=j(De(j({},rt),{slots:de,savedAt:Date.now()}),le?{slotConfig:le}:{}))}function Fr(e,t){if(t.length!==0)try{fetch(`${at(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 Ue(){return!!(Q&&U&&Q.sectionCapture!==!1&&(Q.consent!==!1||nt)&&!Ie())}function Ri(){if(!U||!Q||!Ue()||he)return;let e=[];Ge(document,{contentAndOps:Te,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),un();try{te==null||te(),te=Tt(U,Q.apiKey,e)}catch(t){}}function un(){if(typeof document=="undefined"||!Ue())return;let e;try{if(Dt&&Dt.length>0){let t=new Map;for(let n of Dt){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}:{})),Bt=window.location.pathname}catch(t){}}function lt(){try{let e=[];if(te==null||te(),te=null,Ge(document,{contentAndOps:Te,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),cn(Le,document),e.length>0&&Ue())try{te=Tt(U,Q.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Bt!==null&&window.location.pathname!==Bt&&Ue()&&(he==null||he(),he=null,un())}catch(t){}}catch(e){}}function Lr(){ln===null&&(ln=setTimeout(()=>{ln=null,lt();try{X==null||X.checkUrl()}catch(e){}Ur()},xi))}function dn(){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 Mt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function 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:at(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 r;if((r=e.registry)!=null?r:Object.keys(e.slots).length===0){let o=at(e),i=await st(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),it);if(!(i!=null&&i.slotConfig)){Fe(e),pe(e,"preview mode: slot config unavailable \u2014 page left as-is");return}le=i.slotConfig,je(i.palette)}de=t,J=null,Ge(document),dn(),Fe(e),pe(e,"preview mode",t)}async function $i(e,t){var u,c,d,m,C,p,g,_,v;let n=at(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 st(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),it);if(!a){Fe(e),pe(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=a;de=(c=i.slots)!=null?c:{},le=(d=i.slotConfig)!=null?d:null,je(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";J={persona:s,band:l},Ge(document),Te=!0,dn(),Fe(e),i.recognized===!1?Dr(t,!0):Dr((v=i.personaDisplay)!=null?v:s)}function Fe(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=Ze(j({apiKey:e.apiKey,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:Kr(e)},$t?{sdk:$t}:{})),xe&&xe.length>0&&(X==null||X.teardown(),X=Rt(xe,U,document,e.apiKey))):(nn(e.apiKey),U&&xe&&xe.length>0&&(X==null||X.teardown(),X=Rt(xe,U,document,e.apiKey))),ke=!1}catch(n){}nt=!0;try{Ri()}catch(n){}},revokeConsent(){try{he==null||he(),he=null,Bt=null,te==null||te(),te=null,ae==null||ae(),X==null||X.teardown(),X=null,kr(typeof window!="undefined"?window:null,e.apiKey),nt=!1,ke=!0,U==null||U.destroy(),U=null}catch(n){}},reapply:lt,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=J==null?void 0:J.persona)!=null?n:null,band:(r=J==null?void 0:J.band)!=null?r:null,slots:de,matchCounts:Mt(e),consent:!ke&&(e.consent!==!1||nt)}}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 Jr(){var e,t;try{let n=At(window.sentient);if(!n){Mr();return}Q=n,Te=!1,Le=null,je(null),nt=!1,ke=!1,xe=null,Nt=null,Ce=[],Kt=null,rt=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),Fe(n),pe(n,"editor mode");return}let a=typeof window!="undefined"?Wr(window.location.search):null;if(a){await Mi(n,a);return}let i=typeof window!="undefined"?Hr(window.location.search):null;if(i){await $i(n,i),pe(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0;n.registry===void 0&&!s&&pe(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=Ye(n.apiKey),d=[];c&&(J={persona:c.persona,band:c.band},de=c.slots,c.slotConfig&&(le=c.slotConfig),c.palette&&je(c.palette),Ge(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=Ze(j({apiKey:n.apiKey,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:Kr(n)},$t?{sdk:$t}:{}));U=m,Fe(n),dn();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([st(l,it),document.readyState==="loading"?new Promise(A=>document.addEventListener("DOMContentLoaded",A,{once:!0})):null]);Nt=h,h&&(Ce=v=jr(h,document)[0]),pe(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 st(O,it),w=h=>{var F,M,q,W,ne;let A=m.getPersona();A?J={persona:A.persona,band:A.band}:h.persona&&(J={persona:h.persona,band:"low"}),de=h.slots,s?le=Gr(h.slotConfig,v):h.slotConfig&&(le=h.slotConfig),h.palette&&je(h.palette),Le=(F=h.layoutOrder)!=null?F:Le;let E=()=>{let fe=[],S=Ge(document,{onApplied:(T,Y,ee)=>fe.push({slotId:T,arm:Y,el:ee})});if(s||Fr(n,S),cn(Le,document),Te=!0,Ue())try{te==null||te(),te=Tt(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=Rt(h.goals,U,document,n.apiKey)}catch(fe){}Dt=(q=h.sectionMap)!=null?q:null,Ue()&&un(),pe(n,"applied",{persona:J,slots:de,matches:Mt(n)}),!ke&&(Ne(n.apiKey,rt=j(j({v:1,persona:(W=J==null?void 0:J.persona)!=null?W:h.persona,band:(ne=J==null?void 0:J.band)!=null?ne:"low",slots:h.slots,layoutOrder:h.layoutOrder,savedAt:Date.now()},le?{slotConfig:le}:{}),h.palette?{palette:h.palette}:{})),Kt=null,Ur())};if(!b){pe(n,"decide timeout/null \u2014 snapshot state stands",Mt(n)),O.then(h=>{!h||Te||ke||U!==m||(w(h),pe(n,"late decide applied",Mt(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(()=>{Jr()}))}return oo(Bi);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/snippet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.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.31.
|
|
41
|
+
"@sentientui/core": "0.31.1"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup",
|