@sentientui/snippet 0.31.1 → 0.32.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";var SentientSnippet=(()=>{var Ut=Object.defineProperty,lr=Object.defineProperties,dr=Object.getOwnPropertyDescriptor,cr=Object.getOwnPropertyDescriptors,ur=Object.getOwnPropertyNames,jt=Object.getOwnPropertySymbols;var cn=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable;var eo=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,U=(e,t)=>{for(var n in t||(t={}))cn.call(t,n)&&eo(e,n,t[n]);if(jt)for(var n of jt(t))to.call(t,n)&&eo(e,n,t[n]);return e},le=(e,t)=>lr(e,cr(t));var no=e=>typeof e=="symbol"?e:e+"",oo=(e,t)=>{var n={};for(var r in e)cn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&jt)for(var r of jt(e))t.indexOf(r)<0&&to.call(e,r)&&(n[r]=e[r]);return n};var pr=(e,t)=>()=>(e&&(t=e(e=0)),t);var fr=(e,t)=>{for(var n in t)Ut(e,n,{get:t[n],enumerable:!0})},gr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ur(t))!cn.call(e,s)&&s!==n&&Ut(e,s,{get:()=>t[s],enumerable:!(r=dr(t,s))||r.enumerable});return e};var mr=e=>gr(Ut({},"__esModule",{value:!0}),e);var hr,yr,br,ro,vr,xr,io,ce,st,un=pr(()=>{"use strict";hr=Object.defineProperty,yr=Object.defineProperties,br=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,xr=Object.prototype.propertyIsEnumerable,io=(e,t,n)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ce=(e,t)=>{for(var n in t||(t={}))vr.call(t,n)&&io(e,n,t[n]);if(ro)for(var n of ro(t))xr.call(t,n)&&io(e,n,t[n]);return e},st=(e,t)=>yr(e,br(t))});var wi={};fr(wi,{buildStyleOps:()=>In,clearTargetHighlights:()=>gt,computeMoveAnchors:()=>Jt,deriveSlotId:()=>Te,drawTargetHighlights:()=>Uo,isHex6:()=>An,mount:()=>Fo,registerAuditTargets:()=>jo,sectionTypesFor:()=>Ko,styleFieldError:()=>Go,toHexColor:()=>En});var Ei=56*1024;var Ci=1800*1e3;var pn=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function wr(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function kr(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(),s=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}var Sr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Er(e,t){var r;let n=[];if(e.id){let s=t.getElementById(e.id);n=s?[s]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Sr.test(e.dataAttr.name))try{let s=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${s}"]`))}catch(s){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(s){n=[]}return n}function we(e,t){if(e.urlMatch&&!wr(t).includes(e.urlMatch))return null;let n=Er(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!kr(r,e.fingerprint)?null:r}var fn="data-sentient-block-arm",M=null;var Je=null;function co(e){Je=e!=null?e:null}var uo=e=>{var t;return typeof e=="string"?(t=Je==null?void 0:Je.entries.find(n=>n.id===e))==null?void 0:t.classes:void 0},po=e=>{let t=typeof e=="string"?Je==null?void 0:Je.entries.find(n=>n.id===e):void 0;return t!=null&&t.computed.inheritsColor?t.computed.color:void 0},Lt="data-sentient-blocks-hid",lt={none:"0",sm:"8px",md:"16px",lg:"24px"},gn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},ao={sm:"0.875em",md:"1em",lg:"1.25em"},Cr={sm:"1.25em",md:"1.5em",lg:"2em"},Tr={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},so={sm:"8px",md:"16px",lg:"32px"},Ir={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Lr={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function lo(e){return e==="muted"?M!=null&&M.muted?{color:M.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:M==null?void 0:M.accent}:{}}function fo(e,t){let n=Ar(e,t),r=po(e.like);return n&&r&&(n.style.color=r),n}function Ar(e,t){var n,r,s,u,m,w,g,k,b,B,I,H,S,z,J,X,K,Y,ne,Z;try{let R=uo(e.like),re=e.maxWidth==="measure"?"65ch":void 0,ie=A=>(A.className=R,he(A,{"max-width":re}));switch(e.type){case"stack":case"grid":{let A=t.createElement("div");if(e.type==="stack"){let O=e;he(A,{display:"flex","flex-direction":O.direction,gap:(r=lt[(n=O.gap)!=null?n:"md"])!=null?r:lt.md,"align-items":O.align?gn[O.align]:void 0,"justify-content":O.justify?gn[O.justify]:void 0,"flex-wrap":O.wrap?"wrap":void 0})}else{let O=e,q=(u=lt[(s=O.gap)!=null?s:"md"])!=null?u:lt.md;he(A,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${O.columns-1} * ${q}) / ${O.columns})), 1fr))`,gap:q,"align-items":O.align?gn[O.align]:void 0})}R&&(A.className=R);let N=!R&&e.type==="stack"&&e.surface==="raised",Q=(m=e.pad)!=null?m:N?"md":void 0;Q&&he(A,{padding:(w=lt[Q])!=null?w:lt.md}),N&&he(A,{background:M==null?void 0:M.surface,color:M!=null&&M.surface?M==null?void 0:M.surfaceText:void 0,border:`1px solid ${(g=M==null?void 0:M.border)!=null?g:"currentColor"}`,"border-radius":(k=M==null?void 0:M.radius)!=null?k:"8px"});for(let O of(b=e.children)!=null?b:[]){let q=fo(O,t);q&&A.appendChild(q)}return A}case"text":{let A=t.createElement("p");return A.textContent=e.value,R?ie(A):he(A,le(U({margin:"0","font-size":e.size?ao[e.size]:void 0,"font-weight":e.weight?Lr[e.weight]:void 0,"text-align":e.align},lo(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let A=t.createElement(`h${e.level}`);return A.textContent=e.value,R?ie(A):he(A,{margin:"0","font-size":Cr[(B=e.size)!=null?B:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let A=t.createElement("a");if(A.textContent=e.label,A.href=e.href,e.tag&&A.setAttribute("data-sentient-tag",e.tag),R)return ie(A);let N=(I=e.emphasis)!=null?I:"primary";return he(A,{display:"inline-block",padding:Tr[(H=e.size)!=null?H:"md"],"border-radius":(S=M==null?void 0:M.radius)!=null?S:"8px",font:"inherit","font-size":e.size?ao[e.size]:void 0,"text-decoration":N==="ghost"?"underline":"none",cursor:"pointer",background:N==="primary"?(z=M==null?void 0:M.primaryBg)!=null?z:"#111827":"transparent",color:N==="primary"?(J=M==null?void 0:M.primaryText)!=null?J:"#ffffff":(X=M==null?void 0:M.accent)!=null?X:"inherit",border:N==="secondary"?`1px solid ${(K=M==null?void 0:M.accent)!=null?K:"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),R?ie(A):he(A,{color:"inherit","text-decoration":"underline"})}case"image":{let A=t.createElement("img");return A.src=e.src,A.alt=e.alt,R&&(A.className=R),he(A,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Ir[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,R?ie(A):he(A,U({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(Y=M==null?void 0:M.border)!=null?Y:"currentColor"}`},lo(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(ne=so[e.size])!=null?ne:so.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(Z=M==null?void 0:M.border)!=null?Z:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(R){return null}}function go(e,t,n,r){var s,u;try{let m=new Set;for(let g of Array.from(e.children)){let k=g.getAttribute(fn);k!==null&&(t[k]===void 0?g.remove():m.add(k))}for(let[g,k]of Object.entries(t)){if(m.has(g))continue;let b="tree"in k?k:null,B=fo(b?b.tree:k,r);if(!B)continue;let I=r.createElement("div");I.setAttribute(fn,g),I.style.display="none";let H=b?uo((s=b.surface)==null?void 0:s.like):void 0;if(H){let S=r.createElement("div");S.className=H;let z=po((u=b.surface)==null?void 0:u.like);z&&(S.style.color=z),S.appendChild(B),I.appendChild(S)}else I.appendChild(B);e.appendChild(I)}let w=n!==void 0&&t[n]!==void 0;for(let g of Array.from(e.children)){let k=g.getAttribute(fn),b=g;k!==null?b.style.display=w&&k===n?"":"none":w?b.hasAttribute(Lt)||(b.setAttribute(Lt,b.style.display),b.style.display="none"):b.hasAttribute(Lt)&&(b.style.display=b.getAttribute(Lt),b.removeAttribute(Lt))}}catch(m){}}var _r=/(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)|#[0-9a-f]{3,8}\b/gi,$r=/^rgba?\(\s*[\d.]+[,\s]+[\d.]+[,\s]+[\d.]+(?:[,\s/]+[\d.]+%?)?\s*\)$/i,At;function Br(e){if(At!==void 0)return At;try{let t=e.createElement("canvas");t.width=t.height=1,At=t.getContext("2d",{willReadFrequently:!0})}catch(t){At=null}return At}function ke(e,t){let n=(e!=null?e:"").trim();if(n===""||n==="transparent")return n==="transparent"?"rgba(0, 0, 0, 0)":"";if($r.test(n)||/^#[0-9a-f]{3,8}$/i.test(n))return n;let r=Br(t);if(!r)return"";try{if(r.fillStyle="#010203",r.fillStyle=n,String(r.fillStyle).toLowerCase()==="#010203"&&n.toLowerCase()!=="#010203")return"";r.clearRect(0,0,1,1),r.fillRect(0,0,1,1);let[s,u,m,w]=r.getImageData(0,0,1,1).data;return w===255?`rgb(${s}, ${u}, ${m})`:`rgba(${s}, ${u}, ${m}, ${Math.round(w/255*1e3)/1e3})`}catch(s){return""}}function Kt(e,t){var n;return!e||e==="none"||!/gradient/i.test(e)?[]:((n=e.match(_r))!=null?n:[]).map(r=>ke(r,t)).filter(r=>r!=="")}un();function yo(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function mo(e,t){let n=t>>>0;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function bo(e){let t=e.join("");return mo(t,2166136261)+mo(t,1523705862)}var Or=new Set(["A","BUTTON"]),vo=/^H([1-6])$/,Mr=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]),Rr=new Set(["LABEL","FIGCAPTION","DT"]),Pr=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function xo(e){return Or.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function Nr(e){if(vo.test(e.tagName)||Mr.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function Dr(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(xo(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||Nr(r))return r;return t}function ho(e,t){var n,r;if(e)try{let s=new URL(e,(r=(n=t.location)==null?void 0:n.href)!=null?r:"https://relative.invalid/");return s.protocol!=="https:"&&s.protocol!=="http:"?void 0:t.location&&s.origin===t.location.origin?s.pathname:`${s.origin}${s.pathname}`}catch(s){return}}function wo(e){return e===""||e==="transparent"||/rgba\([^)]*,\s*0\)$/.test(e)}function Hr(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{bg:null};for(let r=e;r;r=r.parentElement){let s=n.getComputedStyle(r),u=Kt(s.backgroundImage,t);if(u.length>0)return ce({bg:u[0]},u.length>1?{alt:u[u.length-1]}:{});let m=ke(s.backgroundColor,t);if(!wo(m))return{bg:m}}return{bg:null}}function mn(e,t=40){var n,r,s;let u=e.ownerDocument.createTreeWalker(e,4),m=[];for(let b=u.nextNode();b;b=u.nextNode())if(((n=b.nodeValue)!=null?n:"").trim()!==""&&!Pr.has((s=(r=b.parentElement)==null?void 0:r.tagName)!=null?s:"")&&(m.push(b),m.length>120))return{reason:"too_large"};if(m.length===0)return{reason:"empty"};let w=[],g=[];for(let b of m){let B=Dr(b,e),I=w.indexOf(B);I===-1&&(w.push(B),I=w.length-1),g.push(I)}if(w.length>t)return{reason:"too_large"};let k=m.map(b=>{var B;return yo((B=b.nodeValue)!=null?B:"")});return{textNodes:m,ownerEls:w,leafToNode:g,leaves:k,fp:bo(k)}}function zr(e,t=40){var n;let r=mn(e,t);if(!("fp"in r))return{skeleton:null,reason:r.reason};let{textNodes:s,ownerEls:u,leafToNode:m,leaves:w}=r,g=e.ownerDocument,k=g.defaultView,b=[],B=u.map((S,z)=>{var J,X;let K=k==null?void 0:k.getComputedStyle(S),Y=(J=S.parentElement)!=null?J:e,ne=b.indexOf(Y);ne===-1&&(b.push(Y),ne=b.length-1);let Z=vo.exec(S.tagName),R=xo(S)?"action":Z?"heading":Rr.has(S.tagName)?"label":"text",re=yo(w.filter((ie,A)=>m[A]===z).join(" "));return st(ce(st(ce({tag:S.tagName.toLowerCase(),role:R},Z?{level:Number(Z[1])}:{}),{text:re,classes:((X=S.getAttribute("class"))!=null?X:"").replace(/\s+/g," ").trim()}),R==="action"?ce({filled:!!K&&(!wo(ke(K.backgroundColor,e.ownerDocument))||K.backgroundImage!==""&&K.backgroundImage!=="none")},ho(S.getAttribute("href"),g)!==void 0?{href:ho(S.getAttribute("href"),g)}:{}):{}),{color:ke(K==null?void 0:K.color,e.ownerDocument),group:ne,restylable:!0})}),I=Hr(e),H=k==null?void 0:k.getComputedStyle(e);return{skeleton:{v:1,root:st(ce({tag:e.tagName.toLowerCase(),classes:((n=e.getAttribute("class"))!=null?n:"").replace(/\s+/g," ").trim(),ambientBg:I.bg},I.alt?{ambientBgAlt:I.alt}:{}),{ambientText:ke(H==null?void 0:H.color,e.ownerDocument)}),nodes:B,leaves:w,leafToNode:m,fp:bo(w)},textNodes:s,ownerEls:u}}function ko(e,t){try{let n=zr(e,t==null?void 0:t.maxNodes);return n.skeleton?{skeleton:n.skeleton}:n}catch(n){return{skeleton:null,reason:"unaddressable"}}}var So=new WeakMap;function Eo(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Co(e,t,n){var u,m,w;let r=So.get(e);if(r){if(r.fp!==n.fp||!Eo(r.leafToNode,n.leafToNode))return"mismatch"}else{let g=mn(e);if(!("fp"in g)||(r={fp:g.fp,leafToNode:g.leafToNode,textNodes:g.textNodes,ownerEls:g.ownerEls,classes:g.ownerEls.map(k=>{var b;return(b=k.getAttribute("class"))!=null?b:""})},r.fp!==n.fp||!Eo(r.leafToNode,n.leafToNode)))return"mismatch";So.set(e,r)}let s=r;for(let[g,k]of Object.entries(t.nodes)){let b=Number(g),B=s.ownerEls[b];if(B){if(typeof k.text=="string"){let I=!0;s.leafToNode.forEach((H,S)=>{H===b&&(s.textNodes[S].nodeValue=I?k.text:"",I=!1)})}k.like!==void 0&&s.classes[k.like]!==void 0&&B.setAttribute("class",s.classes[k.like]),k.hidden&&((u=B.style)==null||u.setProperty("display","none","important"))}}for(let g of Object.values((m=t.order)!=null?m:{})){let k=g.map(S=>s.ownerEls[S]).filter(S=>!!S),b=(w=k[0])==null?void 0:w.parentElement;if(!b||k.length!==g.length||k.some(S=>S.parentElement!==b))continue;let B=new Set(k),I=0;Array.from(b.children).map(S=>B.has(S)?k[I++]:S).forEach((S,z)=>{var J;b.children[z]!==S&&b.insertBefore(S,(J=b.children[z])!=null?J:null)})}return"applied"}un();var jr=4,Ur=new Set(["inline-block","block","flex","inline-flex"]),To={H1:"heading-1",H2:"heading-2",H3:"heading-3"},_t=null;function De(e){let t=_t?ke(e,_t):e,n=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)/i.exec(t);if(!n)return null;let r=n[4]===void 0?1:n[4].endsWith("%")?Number.parseFloat(n[4])/100:Number(n[4]);return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:r}}function Ft(e){let t=n=>{let r=n/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function hn(e,t){let[n,r]=[Ft(e),Ft(t)].sort((s,u)=>u-s);return(n+.05)/(r+.05)}var Wt=e=>{let t=De(e);return t!==null&&t.a>0};function yn(e){return _t?Kt(e,_t):[]}var Ne=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};function Io(e,t){for(let n=e;n;n=n.parentElement){let r=t.getComputedStyle(n);if(Wt(r.backgroundColor))return De(r.backgroundColor);let s=yn(r.backgroundImage);if(s.length>0)return De(s[0])}return{r:255,g:255,b:255,a:1}}var Kr='#CybotCookiebotDialog, #onetrust-consent-sdk, #usercentrics-root, #usercentrics-cmp-ui, .cky-consent-container, .cky-modal, #didomi-host, #qc-cmp2-container, #cmplz-cookiebanner-container, .cc-window, #cc-main, #iubenda-cs-banner, #truste-consent-track, [id^="sp_message_container"], #termly-code-snippet-support';function Gr(e,t,n){if(e.closest(Kr))return!0;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement){let s=t.getComputedStyle(r).position;if(s==="fixed"||s==="sticky"){let u=r.getBoundingClientRect().width;return u>0&&n>0&&u<.6*n}}return!1}function Gt(e){var t;for(let n of Array.from(e.childNodes))if(n.nodeType===3&&((t=n.nodeValue)!=null?t:"").trim()!=="")return!0;return!1}function Fr(e,t,n){var r;let s=e.tagName,u=Ne(t.fontSize)||n.bodySize,m=Number(t.fontWeight)||400,w=Wt(t.backgroundColor),g=yn(t.backgroundImage).length>0,k=Ne(t.borderTopLeftRadius||t.borderRadius),b=e.getBoundingClientRect().width;if(s==="BUTTON"||e.getAttribute("role")==="button"||s==="INPUT"&&/^(submit|button)$/i.test(e.type)||s==="A"&&Ur.has(t.display)&&Ne(t.paddingLeft)>=8){if(((r=e.textContent)!=null?r:"").trim()==="")return null;let I=De(t.backgroundColor),H=e.parentElement?Io(e.parentElement,n.view):n.pageBg;return w&&I&&I.a>=.9&&hn(I,H)>=1.5?"button-primary":w||Ne(t.borderTopWidth)>0?"button-secondary":"button-ghost"}if(s==="A")return"link";if(To[s])return To[s];if(Gt(e)&&u>=1.8*n.bodySize&&m>=600)return u>=2.5*n.bodySize?"heading-1":u>=2*n.bodySize?"heading-2":"heading-3";let B=e.nextElementSibling;if(Gt(e)&&u<=.9*n.bodySize&&(t.textTransform==="uppercase"||Ne(t.letterSpacing)>.05*u)&&B!==null&&/^H[1-4]$/.test(B.tagName))return"eyebrow";if(s==="UL"||s==="OL")return e.querySelectorAll(":scope > li").length>=2?"list":null;if(s==="P"&&Gt(e)){if(u>=1.1*n.bodySize)return"text-lead";if(u<=.85*n.bodySize)return"text-small";let I=De(t.color);return I&&hn(I,Io(e,n.view))<n.bodyContrast*.8?"text-muted":"text-body"}return(s==="SPAN"||s==="DIV")&&w&&Gt(e)&&e.children.length===0&&k>=999?"badge":/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(s)&&(w||g)&&k>0&&Ne(t.paddingTop)>=16&&!(b>0&&b>=.9*n.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(s)&&(w||g)&&e.querySelector("h1,h2,h3")!==null&&(b===0||b>=.9*n.vw)?"section":null}function Lo(e,t){var n,r,s,u,m,w,g,k,b;let B=e.defaultView;if(!B||!e.body)return{entries:[],images:[]};_t=e;let I=B.getComputedStyle(e.body),H=Ne(I.fontSize)||16,S=Wt(I.backgroundColor)?De(I.backgroundColor):{r:255,g:255,b:255,a:1},z=(n=De(I.color))!=null?n:{r:17,g:24,b:39,a:1},J={bodySize:H,pageBg:S,bodyContrast:hn(z,S),view:B,vw:B.innerWidth||0},X=(s=(r=B.location)==null?void 0:r.pathname)!=null?s:"/",K=new Date().toISOString(),Y=new Map,ne=new Map,Z=new Map,R=Array.from(e.body.querySelectorAll("*")).slice(0,(u=t==null?void 0:t.maxElements)!=null?u:4e3);for(let N of R)try{if(N.tagName==="IMG"){let ee=N,_e=((m=ee.getAttribute("alt"))!=null?m:"").trim(),V=ee.naturalWidth||Number(ee.getAttribute("width"))||0,Qe=ee.naturalHeight||Number(ee.getAttribute("height"))||0,ve=ee.getAttribute("src");if(_e&&V>=200&&ve){let $e=new URL(ve,e.baseURI).href;$e.startsWith("https://")&&!Z.has($e)&&Z.set($e,{id:`img-${Z.size+1}`,src:$e,alt:_e.slice(0,200),w:V,h:Qe,seenOn:X})}}let Q=((w=N.getAttribute("class"))!=null?w:"").replace(/\s+/g," ").trim();if(Q===""||Gr(N,B,J.vw))continue;let O=B.getComputedStyle(N),q=N.tagName==="IMG"?((g=N.getAttribute("alt"))!=null?g:"").trim()?"image":null:Fr(N,O,J);if(!q)continue;let Se=`${q}|${Q}`,ze=N.getBoundingClientRect();ne.set(Se,Math.max((k=ne.get(Se))!=null?k:0,ze.width*ze.height));let Ae=Y.get(Se);if(Ae){Ae.seen.count++;continue}let ye=yn(O.backgroundImage).map(De).filter(ee=>ee!==null),ue,je;if(Wt(O.backgroundColor))ue=ke(O.backgroundColor,e);else if(ye.length>0){let ee=[...ye].sort((V,Qe)=>Ft(V)-Ft(Qe)),_e=V=>V.a<1?`rgba(${V.r}, ${V.g}, ${V.b}, ${V.a})`:`rgb(${V.r}, ${V.g}, ${V.b})`;ue=_e(ee[0]),ee.length>1&&(je=_e(ee[ee.length-1]))}let pe=O.borderTopLeftRadius||O.borderRadius;Y.set(Se,{id:q,role:q,classes:Q,computed:ce(ce(ce(ce(ce(ce(ce({},ke(O.color,e)?{color:ke(O.color,e)}:{}),N.parentElement&&B.getComputedStyle(N.parentElement).color===O.color?{inheritsColor:!0}:{}),ue?{bg:ue}:{}),je?{bgDark:je}:{}),O.fontSize?{fontSize:O.fontSize}:{}),O.fontWeight?{fontWeight:O.fontWeight}:{}),pe&&Ne(pe)>0?{radius:pe}:{}),seen:{url:X,count:1,at:K}})}catch(Q){}let re=new Map;for(let N of Y.values())re.set(N.role,[...(b=re.get(N.role))!=null?b:[],N]);let ie=[],A=N=>{var Q;return(Q=ne.get(`${N.role}|${N.classes}`))!=null?Q:0};for(let[N,Q]of re)Q.sort((O,q)=>(N.startsWith("button-")?A(q)-A(O):0)||q.seen.count-O.seen.count).slice(0,jr).forEach((O,q)=>ie.push(st(ce({},O),{id:q===0?N:`${N}-${q+1}`})));return{entries:ie,images:[...Z.values()]}}function Ao(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let r=0;r<e.length;r++){let s=e[r],u=s>="0"&&s<="9";r===0&&u||r===1&&u&&e[0]==="-"?n+=`\\3${s} `:r===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function Wr(e,t){if(e.id)return`#${Ao(e.id)}`;let n=[],r=e,s=0;for(;r&&r!==t.body&&r!==t.documentElement&&s<6;){if(r.id){n.unshift(`#${Ao(r.id)}`);break}let u=r.tagName.toLowerCase(),m=r.parentElement;if(m){let w=Array.from(m.children).filter(g=>g.tagName===r.tagName);w.length>1&&(u+=`:nth-of-type(${w.indexOf(r)+1})`)}n.unshift(u),r=r.parentElement,s++}return n.join(" > ")}function Ye(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let u of["data-framer-name","data-w-id","data-sentient-name"]){let m=e.getAttribute(u);if(m){n.dataAttr={name:u,value:m};break}}n.selector=Wr(e,t);let r=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=U({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function dt(e,t,n){return we(e,n)===t}var qr="__snt_editor_token";function $t(){try{sessionStorage.removeItem(qr)}catch(e){}}var Vr=/rgba\([^)]*,\s*0\s*\)$/,Jr=/^\d+(\.\d+)?px$/;function _o(e){var t,n;try{let r=e.defaultView;if(!r||!e.body)return null;let s=r.getComputedStyle(e.body).backgroundColor,u=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),m=new Map;for(let I of Array.from(u).slice(0,300)){let H=I.getBoundingClientRect();if(H.width>0&&(H.width<48||H.height<24))continue;let S=r.getComputedStyle(I),z=S.backgroundColor;if(!z||z==="transparent"||z===s||Vr.test(z))continue;let J=(t=(S.borderRadius||"").split(" ")[0])!=null?t:"",X=`${z}|${S.color}|${Jr.test(J)?J:"8px"}`;m.set(X,((n=m.get(X))!=null?n:0)+1)}let w=null,g=0;for(let[I,H]of m)H>g&&(w=I,g=H);if(!w)return null;let[k,b,B]=w.split("|");return{primaryBg:k,primaryText:b,radius:B}}catch(r){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"},Yr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function ct(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(!Yr.test((r=n[1])!=null?r:""))return!1;return!0}var $o=/^https:\/\//i,Bo=new Map,He=null;function Xr(e){return e.replace(/["\\]/g,"\\$&")}function Zr(e){var t;(!He||!He.isConnected)&&(He=e.querySelector("style[data-sentient-ops]"),He||(He=e.createElement("style"),He.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(He))),He.textContent=[...Bo.entries()].map(([n,r])=>`[data-snt-e="${Xr(n)}"]{${r}}`).join(`
2
- `)}function Oo(e,t,n,r){var w;let s=!1,u=(w=t.moveBefore)!=null?w:t.moveAfter;if(u){let g=we(u,r);!g||g===e||g.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,g):e.parentElement.insertBefore(e,g.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&$o.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&$o.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let m=[];if(t.hidden&&m.push("display:none !important"),t.style)for(let[g,k]of Object.entries(t.style)){let b=Bt[g];b&&typeof k=="string"&&ct(k)&&m.push(`${b}:${k.trim()} !important`)}return m.length>0&&(e.setAttribute("data-snt-e",n),Bo.set(n,m.join(";")),Zr(r)),{anchorMiss:s}}function Ot(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function Mo(e,t){return e==="*"?"Every page":e.endsWith("/*")?`All pages under ${e.slice(0,-1)}`:e===t?`This page (${e})`:`Only on ${e}`}function bn(e,t){let n=Ot(e),r=n.split("/").filter(Boolean),s=[n,"*"];return r.length>=2&&s.push(`/${r[0]}/*`),(t?[t,...s.filter(u=>u!==t)]:s).filter(u=>pn.test(u))}function qt(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Vt(e,t){return e.steps.map(n=>{var r;return{value:n.step_index,label:`${n.step_index+1}. ${(r=t.get(n.goal_id))!=null?r:n.goal_id}`}})}function Ro(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Qr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function Po(e,t){let n=e.trim();return n?t.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:t.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:Qr(n),body:{displayName:n.slice(0,128),steps:t.map(r=>({goalId:r}))}}:{ok:!1,error:"Give the funnel a name."}}function Ho(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)}function ut(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Te(e,t,n){var w,g;let r=t.id||((w=t.dataAttr)==null?void 0:w.value)||((g=n.textContent)!=null?g:"").trim()||n.tagName,s=ut(r)||"el",u=Ho(JSON.stringify(t));return`${e}-${s}-${u}`.slice(0,128)}var ei="sentient-editor-highlight",ti="sentient-editor-selection",ft="sentient-editor-panel",Yt="sentient-editor-toast",wn="sentient-editor-styles",kn="sentient-editor-target-highlight",ni=10,oi="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",ri="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function zo(){var t;if(document.getElementById(wn))return;let e=document.createElement("style");e.id=wn,e.textContent=`
1
+ "use strict";var __sentientEditorBundle=(()=>{var Gt=Object.defineProperty,wr=Object.defineProperties,kr=Object.getOwnPropertyDescriptor,Sr=Object.getOwnPropertyDescriptors,Er=Object.getOwnPropertyNames,Ut=Object.getOwnPropertySymbols;var gn=Object.prototype.hasOwnProperty,lo=Object.prototype.propertyIsEnumerable;var so=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t)=>{for(var n in t||(t={}))gn.call(t,n)&&so(e,n,t[n]);if(Ut)for(var n of Ut(t))lo.call(t,n)&&so(e,n,t[n]);return e},le=(e,t)=>wr(e,Sr(t));var co=e=>typeof e=="symbol"?e:e+"",uo=(e,t)=>{var n={};for(var r in e)gn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ut)for(var r of Ut(e))t.indexOf(r)<0&&lo.call(e,r)&&(n[r]=e[r]);return n};var Tr=(e,t)=>()=>(e&&(t=e(e=0)),t);var Cr=(e,t)=>{for(var n in t)Gt(e,n,{get:t[n],enumerable:!0})},Lr=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Er(t))!gn.call(e,s)&&s!==n&&Gt(e,s,{get:()=>t[s],enumerable:!(r=kr(t,s))||r.enumerable});return e};var _r=e=>Lr(Gt({},"__esModule",{value:!0}),e);var Ir,Ar,$r,po,Br,Or,fo,de,lt,mn=Tr(()=>{"use strict";Ir=Object.defineProperty,Ar=Object.defineProperties,$r=Object.getOwnPropertyDescriptors,po=Object.getOwnPropertySymbols,Br=Object.prototype.hasOwnProperty,Or=Object.prototype.propertyIsEnumerable,fo=(e,t,n)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,de=(e,t)=>{for(var n in t||(t={}))Br.call(t,n)&&fo(e,n,t[n]);if(po)for(var n of po(t))Or.call(t,n)&&fo(e,n,t[n]);return e},lt=(e,t)=>Ar(e,$r(t))});var $i={};Cr($i,{buildStyleOps:()=>Mn,clearTargetHighlights:()=>mt,computeMoveAnchors:()=>Qt,deriveSlotId:()=>Ce,drawTargetHighlights:()=>tr,exchangeCode:()=>Qo,isHex6:()=>Pn,mount:()=>rr,registerAuditTargets:()=>er,sectionTypesFor:()=>nr,styleFieldError:()=>or,toHexColor:()=>$n});var go;function mo(e=document){if(go)return go;try{let t=e.querySelector("script[nonce]");return(t==null?void 0:t.nonce)||(t==null?void 0:t.getAttribute("nonce"))||void 0}catch(t){return}}function It(e,t=document){let n=mo(t);return n&&e.setAttribute("nonce",n),e}var Mi=1800*1e3;var hn=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function Mr(e){var n,r,s;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(s=t==null?void 0:t.pathname)!=null?s:""}function Nr(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(),s=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===s||r.startsWith(s)||s.startsWith(r)))return!1}return!0}var Pr=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Rr(e,t){var r;let n=[];if(e.id){let s=t.getElementById(e.id);n=s?[s]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Pr.test(e.dataAttr.name))try{let s=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${s}"]`))}catch(s){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(s){n=[]}return n}function we(e,t){if(e.urlMatch&&!Mr(t).includes(e.urlMatch))return null;let n=Rr(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Nr(r,e.fingerprint)?null:r}var At={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Dr=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function ct(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(!Dr.test((r=n[1])!=null?r:""))return!1;return!0}function yn(e){var r,s;let t=e.ownerDocument.createTreeWalker(e,4),n=null;for(let c=t.nextNode();c!==null;c=t.nextNode()){if(((r=c.nodeValue)!=null?r:"").trim()==="")continue;let m=(s=c.parentElement)==null?void 0:s.tagName;if(!(m==="SCRIPT"||m==="STYLE"||m==="TEMPLATE")){if(n!==null)return null;n=c}}return n}function bn(e){return e.childElementCount===0||yn(e)!==null}function vn(e){var t,n,r;return(r=(n=(t=yn(e))==null?void 0:t.nodeValue)!=null?n:e.textContent)!=null?r:""}function Ye(e,t){let n=yn(e);n!==null?n.nodeValue=t:e.textContent=t}var xn=/^https:\/\//i;function Ft(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(xn.test(e)||e[0]==="/"&&e[1]!=="/")?e:null}var ho=new Map,Re=null;function Hr(e){return e.replace(/["\\]/g,"\\$&")}function zr(e){var t;(!Re||!Re.isConnected)&&(Re=e.querySelector("style[data-sentient-ops]"),Re||(Re=It(e.createElement("style"),e),Re.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Re))),Re.textContent=[...ho.entries()].map(([n,r])=>`[data-snt-e="${Hr(n)}"]{${r}}`).join(`
2
+ `)}function yo(e,t,n,r){var x;let s=!1,c=(x=t.moveBefore)!=null?x:t.moveAfter;if(c){let g=we(c,r);!g||g===e||g.parentElement!==e.parentElement||!e.parentElement?s=!0:t.moveBefore?e.parentElement.insertBefore(e,g):e.parentElement.insertBefore(e,g.nextSibling)}typeof t.text=="string"&&Ye(e,t.text),typeof t.href=="string"&&xn.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&xn.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let m=[];if(t.hidden&&m.push("display:none !important"),t.style)for(let[g,w]of Object.entries(t.style)){let b=At[g];b&&typeof w=="string"&&ct(w)&&m.push(`${b}:${w.trim()} !important`)}return m.length>0&&(e.setAttribute("data-snt-e",n),ho.set(n,m.join(";")),zr(r)),{anchorMiss:s}}var wn="data-sentient-block-arm",M=null;var Je=null;function wo(e){Je=e!=null?e:null}var ko=e=>{var t;return typeof e=="string"?(t=Je==null?void 0:Je.entries.find(n=>n.id===e))==null?void 0:t.classes:void 0},So=e=>{let t=typeof e=="string"?Je==null?void 0:Je.entries.find(n=>n.id===e):void 0;return t!=null&&t.computed.inheritsColor?t.computed.color:void 0},$t="data-sentient-blocks-hid",dt={none:"0",sm:"8px",md:"16px",lg:"24px"},kn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},bo={sm:"0.875em",md:"1em",lg:"1.25em"},jr={sm:"1.25em",md:"1.5em",lg:"2em"},Kr={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},vo={sm:"8px",md:"16px",lg:"32px"},Ur={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Gr={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function xo(e){return e==="muted"?M!=null&&M.muted?{color:M.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:M==null?void 0:M.accent}:{}}function Eo(e,t){let n=Fr(e,t),r=So(e.like);return n&&r&&(n.style.color=r),n}function Fr(e,t){var n,r,s,c,m,x,g,w,b,B,L,H,S,z,J,Z,U,X,ne,Q;try{let N=ko(e.like),re=e.maxWidth==="measure"?"65ch":void 0,ie=I=>(I.className=N,he(I,{"max-width":re}));switch(e.type){case"stack":case"grid":{let I=t.createElement("div");if(e.type==="stack"){let O=e;he(I,{display:"flex","flex-direction":O.direction,gap:(r=dt[(n=O.gap)!=null?n:"md"])!=null?r:dt.md,"align-items":O.align?kn[O.align]:void 0,"justify-content":O.justify?kn[O.justify]:void 0,"flex-wrap":O.wrap?"wrap":void 0})}else{let O=e,V=(c=dt[(s=O.gap)!=null?s:"md"])!=null?c:dt.md;he(I,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${O.columns-1} * ${V}) / ${O.columns})), 1fr))`,gap:V,"align-items":O.align?kn[O.align]:void 0})}N&&(I.className=N);let P=!N&&e.type==="stack"&&e.surface==="raised",q=(m=e.pad)!=null?m:P?"md":void 0;q&&he(I,{padding:(x=dt[q])!=null?x:dt.md}),P&&he(I,{background:M==null?void 0:M.surface,color:M!=null&&M.surface?M==null?void 0:M.surfaceText:void 0,border:`1px solid ${(g=M==null?void 0:M.border)!=null?g:"currentColor"}`,"border-radius":(w=M==null?void 0:M.radius)!=null?w:"8px"});for(let O of(b=e.children)!=null?b:[]){let V=Eo(O,t);V&&I.appendChild(V)}return I}case"text":{let I=t.createElement("p");return I.textContent=e.value,N?ie(I):he(I,le(K({margin:"0","font-size":e.size?bo[e.size]:void 0,"font-weight":e.weight?Gr[e.weight]:void 0,"text-align":e.align},xo(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let I=t.createElement(`h${e.level}`);return I.textContent=e.value,N?ie(I):he(I,{margin:"0","font-size":jr[(B=e.size)!=null?B:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let I=t.createElement("a");I.textContent=e.label;let P=Ft(e.href);if(P&&(I.href=P),e.tag&&I.setAttribute("data-sentient-tag",e.tag),N)return ie(I);let q=(L=e.emphasis)!=null?L:"primary";return he(I,{display:"inline-block",padding:Kr[(H=e.size)!=null?H:"md"],"border-radius":(S=M==null?void 0:M.radius)!=null?S:"8px",font:"inherit","font-size":e.size?bo[e.size]:void 0,"text-decoration":q==="ghost"?"underline":"none",cursor:"pointer",background:q==="primary"?(z=M==null?void 0:M.primaryBg)!=null?z:"#111827":"transparent",color:q==="primary"?(J=M==null?void 0:M.primaryText)!=null?J:"#ffffff":(Z=M==null?void 0:M.accent)!=null?Z:"inherit",border:q==="secondary"?`1px solid ${(U=M==null?void 0:M.accent)!=null?U:"currentColor"}`:"none"})}case"link":{let I=t.createElement("a");I.textContent=e.label;let P=Ft(e.href);return P&&(I.href=P),e.tag&&I.setAttribute("data-sentient-tag",e.tag),N?ie(I):he(I,{color:"inherit","text-decoration":"underline"})}case"image":{let I=t.createElement("img"),P=Ft(e.src);return P&&(I.src=P),I.alt=e.alt,N&&(I.className=N),he(I,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?Ur[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let I=t.createElement("span");return I.textContent=e.value,N?ie(I):he(I,K({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(X=M==null?void 0:M.border)!=null?X:"currentColor"}`},xo(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(ne=vo[e.size])!=null?ne:vo.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(Q=M==null?void 0:M.border)!=null?Q:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(N){return null}}function To(e,t,n,r){var s,c;try{let m=new Set;for(let g of Array.from(e.children)){let w=g.getAttribute(wn);w!==null&&(t[w]===void 0?g.remove():m.add(w))}for(let[g,w]of Object.entries(t)){if(m.has(g))continue;let b="tree"in w?w:null,B=Eo(b?b.tree:w,r);if(!B)continue;let L=r.createElement("div");L.setAttribute(wn,g),L.style.display="none";let H=b?ko((s=b.surface)==null?void 0:s.like):void 0;if(H){let S=r.createElement("div");S.className=H;let z=So((c=b.surface)==null?void 0:c.like);z&&(S.style.color=z),S.appendChild(B),L.appendChild(S)}else L.appendChild(B);e.appendChild(L)}let x=n!==void 0&&t[n]!==void 0;for(let g of Array.from(e.children)){let w=g.getAttribute(wn),b=g;w!==null?b.style.display=x&&w===n?"":"none":x?b.hasAttribute($t)||(b.setAttribute($t,b.style.display),b.style.display="none"):b.hasAttribute($t)&&(b.style.display=b.getAttribute($t),b.removeAttribute($t))}}catch(m){}}var Wr=/(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([^()]*\)|#[0-9a-f]{3,8}\b/gi,qr=/^rgba?\(\s*[\d.]+[,\s]+[\d.]+[,\s]+[\d.]+(?:[,\s/]+[\d.]+%?)?\s*\)$/i,Bt;function Vr(e){if(Bt!==void 0)return Bt;try{let t=e.createElement("canvas");t.width=t.height=1,Bt=t.getContext("2d",{willReadFrequently:!0})}catch(t){Bt=null}return Bt}function ke(e,t){let n=(e!=null?e:"").trim();if(n===""||n==="transparent")return n==="transparent"?"rgba(0, 0, 0, 0)":"";if(qr.test(n)||/^#[0-9a-f]{3,8}$/i.test(n))return n;let r=Vr(t);if(!r)return"";try{if(r.fillStyle="#010203",r.fillStyle=n,String(r.fillStyle).toLowerCase()==="#010203"&&n.toLowerCase()!=="#010203")return"";r.clearRect(0,0,1,1),r.fillRect(0,0,1,1);let[s,c,m,x]=r.getImageData(0,0,1,1).data;return x===255?`rgb(${s}, ${c}, ${m})`:`rgba(${s}, ${c}, ${m}, ${Math.round(x/255*1e3)/1e3})`}catch(s){return""}}function Wt(e,t){var n;return!e||e==="none"||!/gradient/i.test(e)?[]:((n=e.match(Wr))!=null?n:[]).map(r=>ke(r,t)).filter(r=>r!=="")}mn();function _o(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function Co(e,t){let n=t>>>0;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function Io(e){let t=e.join("");return Co(t,2166136261)+Co(t,1523705862)}var Yr=new Set(["A","BUTTON"]),Ao=/^H([1-6])$/,Jr=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]),Xr=new Set(["LABEL","FIGCAPTION","DT"]),Zr=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function $o(e){return Yr.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function Qr(e){if(Ao.test(e.tagName)||Jr.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function ei(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if($o(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||Qr(r))return r;return t}function Lo(e,t){var n,r;if(e)try{let s=new URL(e,(r=(n=t.location)==null?void 0:n.href)!=null?r:"https://relative.invalid/");return s.protocol!=="https:"&&s.protocol!=="http:"?void 0:t.location&&s.origin===t.location.origin?s.pathname:`${s.origin}${s.pathname}`}catch(s){return}}function Bo(e){return e===""||e==="transparent"||/rgba\([^)]*,\s*0\)$/.test(e)}function ti(e){let t=e.ownerDocument,n=t.defaultView;if(!n)return{bg:null};for(let r=e;r;r=r.parentElement){let s=n.getComputedStyle(r),c=Wt(s.backgroundImage,t);if(c.length>0)return de({bg:c[0]},c.length>1?{alt:c[c.length-1]}:{});let m=ke(s.backgroundColor,t);if(!Bo(m))return{bg:m}}return{bg:null}}function Sn(e,t=40){var n,r,s;let c=e.ownerDocument.createTreeWalker(e,4),m=[];for(let b=c.nextNode();b;b=c.nextNode())if(((n=b.nodeValue)!=null?n:"").trim()!==""&&!Zr.has((s=(r=b.parentElement)==null?void 0:r.tagName)!=null?s:"")&&(m.push(b),m.length>120))return{reason:"too_large"};if(m.length===0)return{reason:"empty"};let x=[],g=[];for(let b of m){let B=ei(b,e),L=x.indexOf(B);L===-1&&(x.push(B),L=x.length-1),g.push(L)}if(x.length>t)return{reason:"too_large"};let w=m.map(b=>{var B;return _o((B=b.nodeValue)!=null?B:"")});return{textNodes:m,ownerEls:x,leafToNode:g,leaves:w,fp:Io(w)}}function ni(e,t=40){var n;let r=Sn(e,t);if(!("fp"in r))return{skeleton:null,reason:r.reason};let{textNodes:s,ownerEls:c,leafToNode:m,leaves:x}=r,g=e.ownerDocument,w=g.defaultView,b=[],B=c.map((S,z)=>{var J,Z;let U=w==null?void 0:w.getComputedStyle(S),X=(J=S.parentElement)!=null?J:e,ne=b.indexOf(X);ne===-1&&(b.push(X),ne=b.length-1);let Q=Ao.exec(S.tagName),N=$o(S)?"action":Q?"heading":Xr.has(S.tagName)?"label":"text",re=_o(x.filter((ie,I)=>m[I]===z).join(" "));return lt(de(lt(de({tag:S.tagName.toLowerCase(),role:N},Q?{level:Number(Q[1])}:{}),{text:re,classes:((Z=S.getAttribute("class"))!=null?Z:"").replace(/\s+/g," ").trim()}),N==="action"?de({filled:!!U&&(!Bo(ke(U.backgroundColor,e.ownerDocument))||U.backgroundImage!==""&&U.backgroundImage!=="none")},Lo(S.getAttribute("href"),g)!==void 0?{href:Lo(S.getAttribute("href"),g)}:{}):{}),{color:ke(U==null?void 0:U.color,e.ownerDocument),group:ne,restylable:!0})}),L=ti(e),H=w==null?void 0:w.getComputedStyle(e);return{skeleton:{v:1,root:lt(de({tag:e.tagName.toLowerCase(),classes:((n=e.getAttribute("class"))!=null?n:"").replace(/\s+/g," ").trim(),ambientBg:L.bg},L.alt?{ambientBgAlt:L.alt}:{}),{ambientText:ke(H==null?void 0:H.color,e.ownerDocument)}),nodes:B,leaves:x,leafToNode:m,fp:Io(x)},textNodes:s,ownerEls:c}}function Oo(e,t){try{let n=ni(e,t==null?void 0:t.maxNodes);return n.skeleton?{skeleton:n.skeleton}:n}catch(n){return{skeleton:null,reason:"unaddressable"}}}var Mo=new WeakMap;function No(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Po(e,t,n){var c,m,x;let r=Mo.get(e);if(r){if(r.fp!==n.fp||!No(r.leafToNode,n.leafToNode))return"mismatch"}else{let g=Sn(e);if(!("fp"in g)||(r={fp:g.fp,leafToNode:g.leafToNode,textNodes:g.textNodes,ownerEls:g.ownerEls,classes:g.ownerEls.map(w=>{var b;return(b=w.getAttribute("class"))!=null?b:""})},r.fp!==n.fp||!No(r.leafToNode,n.leafToNode)))return"mismatch";Mo.set(e,r)}let s=r;for(let[g,w]of Object.entries(t.nodes)){let b=Number(g),B=s.ownerEls[b];if(B){if(typeof w.text=="string"){let L=!0;s.leafToNode.forEach((H,S)=>{H===b&&(s.textNodes[S].nodeValue=L?w.text:"",L=!1)})}w.like!==void 0&&s.classes[w.like]!==void 0&&B.setAttribute("class",s.classes[w.like]),w.hidden&&((c=B.style)==null||c.setProperty("display","none","important"))}}for(let g of Object.values((m=t.order)!=null?m:{})){let w=g.map(S=>s.ownerEls[S]).filter(S=>!!S),b=(x=w[0])==null?void 0:x.parentElement;if(!b||w.length!==g.length||w.some(S=>S.parentElement!==b))continue;let B=new Set(w),L=0;Array.from(b.children).map(S=>B.has(S)?w[L++]:S).forEach((S,z)=>{var J;b.children[z]!==S&&b.insertBefore(S,(J=b.children[z])!=null?J:null)})}return"applied"}mn();var oi=4,ri=new Set(["inline-block","block","flex","inline-flex"]),Ro={H1:"heading-1",H2:"heading-2",H3:"heading-3"},Ot=null;function He(e){let t=Ot?ke(e,Ot):e,n=/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?\s*\)/i.exec(t);if(!n)return null;let r=n[4]===void 0?1:n[4].endsWith("%")?Number.parseFloat(n[4])/100:Number(n[4]);return{r:Number(n[1]),g:Number(n[2]),b:Number(n[3]),a:r}}function Vt(e){let t=n=>{let r=n/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function En(e,t){let[n,r]=[Vt(e),Vt(t)].sort((s,c)=>c-s);return(n+.05)/(r+.05)}var Yt=e=>{let t=He(e);return t!==null&&t.a>0};function Tn(e){return Ot?Wt(e,Ot):[]}var De=e=>{let t=Number.parseFloat(e);return Number.isFinite(t)?t:0};function Do(e,t){for(let n=e;n;n=n.parentElement){let r=t.getComputedStyle(n);if(Yt(r.backgroundColor))return He(r.backgroundColor);let s=Tn(r.backgroundImage);if(s.length>0)return He(s[0])}return{r:255,g:255,b:255,a:1}}var ii='#CybotCookiebotDialog, #onetrust-consent-sdk, #usercentrics-root, #usercentrics-cmp-ui, .cky-consent-container, .cky-modal, #didomi-host, #qc-cmp2-container, #cmplz-cookiebanner-container, .cc-window, #cc-main, #iubenda-cs-banner, #truste-consent-track, [id^="sp_message_container"], #termly-code-snippet-support';function ai(e,t,n){if(e.closest(ii))return!0;for(let r=e;r&&r!==e.ownerDocument.body;r=r.parentElement){let s=t.getComputedStyle(r).position;if(s==="fixed"||s==="sticky"){let c=r.getBoundingClientRect().width;return c>0&&n>0&&c<.6*n}}return!1}function qt(e){var t;for(let n of Array.from(e.childNodes))if(n.nodeType===3&&((t=n.nodeValue)!=null?t:"").trim()!=="")return!0;return!1}function si(e,t,n){var r;let s=e.tagName,c=De(t.fontSize)||n.bodySize,m=Number(t.fontWeight)||400,x=Yt(t.backgroundColor),g=Tn(t.backgroundImage).length>0,w=De(t.borderTopLeftRadius||t.borderRadius),b=e.getBoundingClientRect().width;if(s==="BUTTON"||e.getAttribute("role")==="button"||s==="INPUT"&&/^(submit|button)$/i.test(e.type)||s==="A"&&ri.has(t.display)&&De(t.paddingLeft)>=8){if(((r=e.textContent)!=null?r:"").trim()==="")return null;let L=He(t.backgroundColor),H=e.parentElement?Do(e.parentElement,n.view):n.pageBg;return x&&L&&L.a>=.9&&En(L,H)>=1.5?"button-primary":x||De(t.borderTopWidth)>0?"button-secondary":"button-ghost"}if(s==="A")return"link";if(Ro[s])return Ro[s];if(qt(e)&&c>=1.8*n.bodySize&&m>=600)return c>=2.5*n.bodySize?"heading-1":c>=2*n.bodySize?"heading-2":"heading-3";let B=e.nextElementSibling;if(qt(e)&&c<=.9*n.bodySize&&(t.textTransform==="uppercase"||De(t.letterSpacing)>.05*c)&&B!==null&&/^H[1-4]$/.test(B.tagName))return"eyebrow";if(s==="UL"||s==="OL")return e.querySelectorAll(":scope > li").length>=2?"list":null;if(s==="P"&&qt(e)){if(c>=1.1*n.bodySize)return"text-lead";if(c<=.85*n.bodySize)return"text-small";let L=He(t.color);return L&&En(L,Do(e,n.view))<n.bodyContrast*.8?"text-muted":"text-body"}return(s==="SPAN"||s==="DIV")&&x&&qt(e)&&e.children.length===0&&w>=999?"badge":/^(DIV|ARTICLE|LI|SECTION|ASIDE)$/.test(s)&&(x||g)&&w>0&&De(t.paddingTop)>=16&&!(b>0&&b>=.9*n.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(s)&&(x||g)&&e.querySelector("h1,h2,h3")!==null&&(b===0||b>=.9*n.vw)?"section":null}function Ho(e,t){var n,r,s,c,m,x,g,w,b;let B=e.defaultView;if(!B||!e.body)return{entries:[],images:[]};Ot=e;let L=B.getComputedStyle(e.body),H=De(L.fontSize)||16,S=Yt(L.backgroundColor)?He(L.backgroundColor):{r:255,g:255,b:255,a:1},z=(n=He(L.color))!=null?n:{r:17,g:24,b:39,a:1},J={bodySize:H,pageBg:S,bodyContrast:En(z,S),view:B,vw:B.innerWidth||0},Z=(s=(r=B.location)==null?void 0:r.pathname)!=null?s:"/",U=new Date().toISOString(),X=new Map,ne=new Map,Q=new Map,N=Array.from(e.body.querySelectorAll("*")).slice(0,(c=t==null?void 0:t.maxElements)!=null?c:4e3);for(let P of N)try{if(P.tagName==="IMG"){let ee=P,Ae=((m=ee.getAttribute("alt"))!=null?m:"").trim(),Y=ee.naturalWidth||Number(ee.getAttribute("width"))||0,et=ee.naturalHeight||Number(ee.getAttribute("height"))||0,ve=ee.getAttribute("src");if(Ae&&Y>=200&&ve){let $e=new URL(ve,e.baseURI).href;$e.startsWith("https://")&&!Q.has($e)&&Q.set($e,{id:`img-${Q.size+1}`,src:$e,alt:Ae.slice(0,200),w:Y,h:et,seenOn:Z})}}let q=((x=P.getAttribute("class"))!=null?x:"").replace(/\s+/g," ").trim();if(q===""||ai(P,B,J.vw))continue;let O=B.getComputedStyle(P),V=P.tagName==="IMG"?((g=P.getAttribute("alt"))!=null?g:"").trim()?"image":null:si(P,O,J);if(!V)continue;let Se=`${V}|${q}`,ze=P.getBoundingClientRect();ne.set(Se,Math.max((w=ne.get(Se))!=null?w:0,ze.width*ze.height));let Ie=X.get(Se);if(Ie){Ie.seen.count++;continue}let ye=Tn(O.backgroundImage).map(He).filter(ee=>ee!==null),ue,je;if(Yt(O.backgroundColor))ue=ke(O.backgroundColor,e);else if(ye.length>0){let ee=[...ye].sort((Y,et)=>Vt(Y)-Vt(et)),Ae=Y=>Y.a<1?`rgba(${Y.r}, ${Y.g}, ${Y.b}, ${Y.a})`:`rgb(${Y.r}, ${Y.g}, ${Y.b})`;ue=Ae(ee[0]),ee.length>1&&(je=Ae(ee[ee.length-1]))}let pe=O.borderTopLeftRadius||O.borderRadius;X.set(Se,{id:V,role:V,classes:q,computed:de(de(de(de(de(de(de({},ke(O.color,e)?{color:ke(O.color,e)}:{}),P.parentElement&&B.getComputedStyle(P.parentElement).color===O.color?{inheritsColor:!0}:{}),ue?{bg:ue}:{}),je?{bgDark:je}:{}),O.fontSize?{fontSize:O.fontSize}:{}),O.fontWeight?{fontWeight:O.fontWeight}:{}),pe&&De(pe)>0?{radius:pe}:{}),seen:{url:Z,count:1,at:U}})}catch(q){}let re=new Map;for(let P of X.values())re.set(P.role,[...(b=re.get(P.role))!=null?b:[],P]);let ie=[],I=P=>{var q;return(q=ne.get(`${P.role}|${P.classes}`))!=null?q:0};for(let[P,q]of re)q.sort((O,V)=>(P.startsWith("button-")?I(V)-I(O):0)||V.seen.count-O.seen.count).slice(0,oi).forEach((O,V)=>ie.push(lt(de({},O),{id:V===0?P:`${P}-${V+1}`})));return{entries:ie,images:[...Q.values()]}}function zo(e){let t=globalThis;if(t.CSS&&typeof t.CSS.escape=="function")return t.CSS.escape(e);let n="";for(let r=0;r<e.length;r++){let s=e[r],c=s>="0"&&s<="9";r===0&&c||r===1&&c&&e[0]==="-"?n+=`\\3${s} `:r===0&&s==="-"&&e.length===1?n+="\\-":/[a-zA-Z0-9_-]/.test(s)?n+=s:n+=`\\${s}`}return n}function li(e,t){if(e.id)return`#${zo(e.id)}`;let n=[],r=e,s=0;for(;r&&r!==t.body&&r!==t.documentElement&&s<6;){if(r.id){n.unshift(`#${zo(r.id)}`);break}let c=r.tagName.toLowerCase(),m=r.parentElement;if(m){let x=Array.from(m.children).filter(g=>g.tagName===r.tagName);x.length>1&&(c+=`:nth-of-type(${x.indexOf(r)+1})`)}n.unshift(c),r=r.parentElement,s++}return n.join(" > ")}function Xe(e,t){var s;let n={v:1};e.id&&(n.id=e.id);for(let c of["data-framer-name","data-w-id","data-sentient-name"]){let m=e.getAttribute(c);if(m){n.dataAttr={name:c,value:m};break}}n.selector=li(e,t);let r=((s=e.textContent)!=null?s:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=K({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function ut(e,t,n){return we(e,n)===t}var jo="__snt_editor_token";function Ko(e){try{sessionStorage.setItem(jo,e)}catch(t){}}function Mt(){try{sessionStorage.removeItem(jo)}catch(e){}}var ci=/rgba\([^)]*,\s*0\s*\)$/,di=/^\d+(\.\d+)?px$/;function Uo(e){var t,n;try{let r=e.defaultView;if(!r||!e.body)return null;let s=r.getComputedStyle(e.body).backgroundColor,c=e.querySelectorAll('button, [role="button"], input[type="submit"], a[class*="btn" i], a[class*="button" i]'),m=new Map;for(let L of Array.from(c).slice(0,300)){let H=L.getBoundingClientRect();if(H.width>0&&(H.width<48||H.height<24))continue;let S=r.getComputedStyle(L),z=S.backgroundColor;if(!z||z==="transparent"||z===s||ci.test(z))continue;let J=(t=(S.borderRadius||"").split(" ")[0])!=null?t:"",Z=`${z}|${S.color}|${di.test(J)?J:"8px"}`;m.set(Z,((n=m.get(Z))!=null?n:0)+1)}let x=null,g=0;for(let[L,H]of m)H>g&&(x=L,g=H);if(!x)return null;let[w,b,B]=x.split("|");return{primaryBg:w,primaryText:b,radius:B}}catch(r){return null}}function Nt(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function Go(e,t){return e==="*"?"Every page":e.endsWith("/*")?`All pages under ${e.slice(0,-1)}`:e===t?`This page (${e})`:`Only on ${e}`}function Cn(e,t){let n=Nt(e),r=n.split("/").filter(Boolean),s=[n,"*"];return r.length>=2&&s.push(`/${r[0]}/*`),(t?[t,...s.filter(c=>c!==t)]:s).filter(c=>hn.test(c))}function Jt(e){let t=e.steps.length,n=e.status==="active"?"":` (${e.status})`;return`${e.display_name} \u2014 ${t} step${t===1?"":"s"}${n}`}function Xt(e,t){return e.steps.map(n=>{var r;return{value:n.step_index,label:`${n.step_index+1}. ${(r=t.get(n.goal_id))!=null?r:n.goal_id}`}})}function Fo(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function ui(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"funnel"}function Wo(e,t){let n=e.trim();return n?t.length<2?{ok:!1,error:"Pick at least 2 goals \u2014 a funnel is a sequence."}:t.length>12?{ok:!1,error:"A funnel can have at most 12 steps."}:{ok:!0,funnelId:ui(n),body:{displayName:n.slice(0,128),steps:t.map(r=>({goalId:r}))}}:{ok:!1,error:"Give the funnel a name."}}function Xo(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)>>>0;return t.toString(36)}function pt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Ce(e,t,n){var x,g;let r=t.id||((x=t.dataAttr)==null?void 0:x.value)||((g=n.textContent)!=null?g:"").trim()||n.tagName,s=pt(r)||"el",c=Xo(JSON.stringify(t));return`${e}-${s}-${c}`.slice(0,128)}var pi="sentient-editor-highlight",fi="sentient-editor-selection",gt="sentient-editor-panel",en="sentient-editor-toast",_n="sentient-editor-styles",In="sentient-editor-target-highlight",gi=10,qo="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",Vo="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function Zo(){var t;if(document.getElementById(_n))return;let e=It(document.createElement("style"));e.id=_n,e.textContent=`
3
3
  @keyframes sntedi-in {
4
4
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
5
5
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -12,23 +12,23 @@
12
12
  0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
13
13
  50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
14
14
  }
15
- #${ft} {
15
+ #${gt} {
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
- #${ft} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
- #${Yt} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
19
+ #${gt} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
20
+ #${en} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
21
21
  @media (prefers-reduced-motion: reduce) {
22
- #${ft}, #${ft} .sntedi-dot, #${Yt} { animation: none !important; }
22
+ #${gt}, #${gt} .sntedi-dot, #${en} { animation: none !important; }
23
23
  }
24
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function vn(e){var r,s;zo(),(r=document.getElementById(Yt))==null||r.remove();let t=d("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=Yt;let n=d("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,d("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function ii(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function ai(e){try{let t=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let n=(await t.json()).projectId;return n?{ok:!0,projectId:n}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function Ln(e,t){return U(U(U(U({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 de(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});if(r.ok)return{r:"ok"};let s=await r.json().catch(()=>null);return Ln(r.status,s)}catch(r){return{r:"error"}}}async function si(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(n.ok)return{r:"ok"};let r=await n.json().catch(()=>null);return Ln(n.status,r)}catch(n){return{r:"error"}}}async function li(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await r.json().catch(()=>null);return r.ok?{r:"ok",data:s,outcome:{r:"ok"}}:{r:r.status===401?"expired":"error",data:s,outcome:Ln(r.status,s)}}catch(r){return{r:"error",data:null,outcome:{r:"error"}}}}var Sn=[];function An(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function En(e){let t=e.trim();if(An(t))return t;let n=/^#([0-9a-fA-F]{3})$/.exec(t);if(n)return`#${n[1].split("").map(u=>u+u).join("")}`;let r=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!r)return t;let s=u=>Math.min(255,Number(u)).toString(16).padStart(2,"0");return`#${s(r[1])}${s(r[2])}${s(r[3])}`}var Xe=null,Cn=[];function jo(e){Cn=e}async function di(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let n=await t.json();return Sn=Array.isArray(n.fonts)?n.fonts.filter(r=>typeof r=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function pt(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return n.ok?await n.json():null}catch(n){return null}}function gt(e=document){for(let t of Array.from(e.querySelectorAll(`.${kn}`)))t.remove()}function Uo(e,t=document){var r;gt(t);let n=0;for(let s of e){if(n>=ni)break;let u=we(s.locator,t);if(!u)continue;let m=u.getBoundingClientRect(),w=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});w.className=kn;let g=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${Math.max(0,m.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);g.className=kn,((r=t.body)!=null?r:t.documentElement).append(w,g),n+=1}}function Jt(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,s=n?Ye(n,t):null,u=r?Ye(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&s&&dt(s,n,t)?s:null,nextLocator:r&&u&&dt(u,r,t)?u:null}}var ci=/testimonial|review|quote/i;function Ko(e){let t=[],n=e.headings.length>=1,r=e.links.length>=1;return n&&r&&t.push("hero","cta_band"),e.headings.length>=2&&e.paragraphs.length>=2&&t.push("feature_grid"),e.quotes.length>=1&&t.push("testimonial"),t}var Tn=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],ui=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,pi=new Set(["left","center","right","justify","start","end"]),fi=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,gi=/^(rgb|rgba|hsl|hsla)\(/i;function mi(e){return fi.test(e)||gi.test(e)}function Go(e,t){switch(e){case"fontSize":case"borderRadius":return ui.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 pi.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return mi(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(r=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(r))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function In(e){let t={},n={};for(let r of Tn){let s=e[r];if(typeof s!="string")continue;let u=s.trim();if(u==="")continue;if(!ct(u)){n[r]="That value isn\u2019t allowed.";continue}let m=Go(r,u);if(m){n[r]=m;continue}t[r]=u}return{style:t,errors:n}}function d(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function Fo(e){var Qn;let t=null,n=[],r=null,s=()=>{for(;n.length>0;){let o=n.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:o})}).catch(()=>{})}catch(i){}}},u=(o,i)=>{n.push(U({kind:o},i?{meta:i}:{})),r&&clearTimeout(r),r=setTimeout(s,2e3)};window.addEventListener("pagehide",s);let m=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});m.id=ei;let w=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});w.id=ti;let g=()=>{if(!t||!t.isConnected){w.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(w.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},k=()=>g();zo();let b=d("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",overscrollBehavior:"contain"});b.id=ft;let B=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});B.className="sntedi-dot";let I=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});I.append(B,d("span",{},"SentientUI"));let H=d("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),S=!1,z=d("button",F("#374151"),"Pause selecting");z.onclick=()=>{S=!S,z.textContent=S?"Resume selecting":"Pause selecting",S?(m.style.display="none",gt(document),E("Selection paused \u2014 browse normally, then resume.")):E("Click any element on the page to adapt it.")};let J=d("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),X=d("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),K=d("button",F("#6366f1"),"Test different text here"),Y=d("button",F("#374151"),"Change style"),ne=d("button",F("#374151"),"Try a different layout for this section"),Z=d("button",F("#374151"),"Track clicks as a goal"),R=d("button",F("#374151"),"Track form submissions as a goal"),re=d("button",F("#374151"),"Track page visits as a goal"),ie=d("button",F("#374151"),"Track reading this far as a goal"),A=d("button",F("#374151"),"Set up a funnel"),N=d("button",F("#374151"),"Attach this test to a funnel step"),Q=d("button",F("#10b981"),"Turn the funnel on"),O=d("button",F("#374151"),"Move up"),q=d("button",F("#374151"),"Move down"),Se=d("button",F("#6366f1"),"Save this arrangement"),ze=d("button",F("#374151"),"Undo"),Ae=xn("close","Close editor"),ye=d("button",F("#10b981"),"Publish now \u2014 go live"),ue=d("button",F("#10b981"),"Start tracking now");for(let o of[K,Y,ne,Z,O,q])o.disabled=!0;let je=[K,Y,ne,Z,R,O,q];for(let o of je)o.style.display="none";Se.style.display="none",ze.style.display="none",ye.style.display="none",ue.style.display="none",N.style.display="none",Q.style.display="none";let pe=d("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),ee=d("div",{}),_e=[{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"}],V="text",Qe=new Map,ve=new Map,$e=new Map,_n=d("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),$n=d("div",{paddingTop:"10px"});for(let o of _e){let i=d("button",{background:"transparent",border:"none",cursor:"pointer",font:"600 11.5px system-ui, sans-serif",color:"#9ca3af",whiteSpace:"nowrap",padding:"7px 5px",borderBottom:"2px solid transparent",marginBottom:"-1px"});i.append(d("span",{fontSize:"11px",marginRight:"3px"},o.icon),d("span",{},o.label)),i.onclick=()=>Wo(o.id),Qe.set(o.id,i),_n.append(i);let a=d("div",{display:"none"}),l=d("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});a.append(l),$e.set(o.id,l),ve.set(o.id,a),$n.append(a)}ve.get("text").append(K),ve.get("style").append(Y),ve.get("layout").append(ne,O,q,Se,ze),ve.get("goals").append(Z,R,re,ie),ve.get("funnels").append(A,N,Q);let xe=d("div",{});ve.get("drafts").append(xe);let Mt=()=>{var i,a;for(let l of _e){let c=l.id===V,p=Qe.get(l.id);p.style.color=c?"#ffffff":"#9ca3af",p.style.borderBottom=c?"2px solid #6366f1":"2px solid transparent",ve.get(l.id).style.display=c?"block":"none",$e.get(l.id).style.display="none"}let o=l=>{let c=$e.get(V);c.textContent=l,c.style.display="block"};V==="text"?t?K.disabled?o(K.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(i=K.onclick)==null||i.call(K,new MouseEvent("click")):o("Click any text on the page to test a different wording."):V==="style"?t?Y.disabled?o("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(a=Y.onclick)==null||a.call(Y,new MouseEvent("click")):o("Click any element on the page to change how it looks."):V==="layout"?t||o("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."):V==="goals"?t||o("Page-level goals work right away; click a button or form to track it specifically."):V==="funnels"?o("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):V==="drafts"&&et()},Ie=(o,i)=>d("button",le(U({},F(o)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),i),Bn=(o,i)=>{let a=new URL(window.location.href);a.searchParams.delete("sentient_editor"),a.searchParams.set("sentient_preview",o),i&&a.searchParams.set("sentient_arm",i),window.location.assign(a.toString())},Rt=(o,i,a)=>{let l=Ie("#374151","Discard");return l.onclick=async()=>{l.disabled=!0;let c=await si(e,o);l.disabled=!1,be(c,i),c.r==="ok"&&a()},l},On=(o,i)=>{Ue.textContent="";let a=d("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=d("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...i),a.append(d("div",{marginBottom:"6px"},o),l),Ue.append(a)},et=async()=>{var x,C,_,h,v,P,T,D,G,$,ge,me;xe.textContent="",xe.append(d("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let o=[],i=[],a=null,l=!1;if(await Promise.all([(async()=>{var L;try{let j=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?o=(L=(await j.json()).slots)!=null?L:[]:a=j.status===401?"expired":"error"}catch(j){a="error"}})(),(async()=>{var L;try{let j=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?i=(L=(await j.json()).goals)!=null?L:[]:l=!0}catch(j){l=!0}})()]),V!=="drafts")return;if(xe.textContent="",a){if(xe.append(d("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},a==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),a==="error"){let L=Ie("#374151","Retry");L.onclick=()=>{et()},xe.append(L)}return}let c=o.filter(L=>{var j,se,Le,Pe,Ve,It;return((Le=(se=(j=L.draft_config)==null?void 0:j.arms)==null?void 0:se.length)!=null?Le:0)>0||((It=(Ve=(Pe=L.published_config)==null?void 0:Pe.arms)==null?void 0:Ve.length)!=null?It:0)>0}),p=i.filter(L=>L.event!=="custom"&&(L.status==="draft"||L.status==="active"));if(c.length===0&&p.length===0&&!l){xe.append(d("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let y=L=>d("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:L?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:L?"#6ee7b7":"#c7d2fe"},L?"live":"draft"),f=L=>{let j=d("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),se=d("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},L);return j.append(se),{row:j,name:se}};for(let L of c){let{row:j}=f((x=L.display_name)!=null?x:L.slot_id);j.append(y(L.status==="published"));let se=(v=(h=(C=L.draft_config)==null?void 0:C.arms)!=null?h:(_=L.published_config)==null?void 0:_.arms)!=null?v:[],Le=(D=(P=se[1])==null?void 0:P.id)!=null?D:(T=se[0])==null?void 0:T.id,Pe=Ie("#374151","Preview");if(Pe.onclick=()=>Bn(L.slot_id,Le),j.append(Pe),L.status!=="published"&&((ge=($=(G=L.draft_config)==null?void 0:G.arms)==null?void 0:$.length)!=null?ge:0)>0){let Ve=Ie("#10b981","Publish");Ve.onclick=async()=>{Ve.disabled=!0;let It=await de(e,`/v1/editor/slots/${encodeURIComponent(L.slot_id)}/publish`,{});Ve.disabled=!1,be(It,"\u2713 Published \u2014 live for new visitors."),It.r==="ok"&&(u("published",{kind:"slot"}),et())},j.append(Ve)}L.status!=="published"&&j.append(Rt(`/v1/editor/slots/${encodeURIComponent(L.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{jn(L.slot_id),et()})),xe.append(j)}if(l)xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(p.length>0){xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let L of p){let{row:j}=f((me=L.display_name)!=null?me:L.goal_id);if(j.append(y(L.status==="active")),L.status==="draft"){let se=Ie("#10b981","Start tracking");se.onclick=async()=>{se.disabled=!0;let Le=await de(e,`/v1/editor/goals/${encodeURIComponent(L.goal_id)}/publish`,{});se.disabled=!1,be(Le,"\u2713 Tracking is live \u2014 it counts from your next visitor."),Le.r==="ok"&&(u("published",{kind:"goal"}),et())},j.append(se,Rt(`/v1/editor/goals/${encodeURIComponent(L.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Un(L.goal_id),et()}))}xe.append(j)}}},Wo=o=>{V!==o&&(ae(),wt(),V=o,Mt())},Mn=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(I.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Rn=!1,Be=d("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"44px",height:"44px",borderRadius:"12px",border:"1px solid #2a2a2a",background:"#000",cursor:"pointer",display:"none",padding:"0",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 18px rgba(0,0,0,0.4)"});Be.append(yi(26)),Be.title="Open the SentientUI editor",Be.setAttribute("aria-label","Open the SentientUI editor");let Pn=xn("minimize","Minimize");Pn.onclick=()=>{b.style.display="none",Be.style.display="flex",Rn=S,S=!0,m.style.display="none",gt(document)},Be.onclick=()=>{b.style.display="block",Be.style.display="none",S=Rn},Object.assign(z.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),Mn.append(I,z,Pn,Ae);let Nn=d("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),Ue=d("div",{});Object.assign(X.style,{marginBottom:"4px"}),Nn.append(Ue,X,ye,ue);let Dn=d("button",{display:"inline-block",width:"auto",margin:"0",padding:"5px 10px",flex:"0 0 auto",fontSize:"11px",borderRadius:"999px",background:"rgba(250,204,21,0.15)",border:"1px solid rgba(250,204,21,0.45)",color:"#fde68a",cursor:"pointer",whiteSpace:"nowrap"},"\u2728 Ask AI"),Zt=d("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(J.style,{flex:"1 1 auto",marginBottom:"0"}),Zt.append(J,Dn),Object.assign(Zt.style,{marginBottom:"6px"});let Pt=d("div",{}),W=d("div",{marginTop:"4px"});W.addEventListener("input",()=>{tt=!0}),W.addEventListener("change",()=>{tt=!0}),b.append(Mn,H,Zt,pe,ee,Pt,_n,$n,W,Nn),((Qn=document.body)!=null?Qn:document.documentElement).append(m,w,b,Be);let Oe=null,Nt=()=>{Oe==null||Oe(),Oe=null},Hn=()=>{Oe=null},mt=null,tt=!1,Qt=null,ae=()=>{Nt(),mt=null,W.textContent="",tt=!1,Qt=null,dn=!1},ht=(o,i,a,l)=>{var _;ae();let c={},p={},y={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let h of o){let v=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},h.label);if(W.append(v),h.type==="select"){let T=d("select",y);T.setAttribute("data-field",h.key);let D=document.createElement("option");D.value="",D.textContent="\u2014 no change \u2014",T.append(D);for(let G of(_=h.options)!=null?_:[]){let $=document.createElement("option");$.value=G,$.textContent=G,T.append($)}c[h.key]=()=>T.value,W.append(T)}else if(h.type==="color"){let T=d("input",le(U({},y),{padding:"2px",height:"34px"}));T.type="color",T.setAttribute("data-field",h.key);let D=!1;T.addEventListener("input",()=>{D=!0}),c[h.key]=()=>D?T.value:"",W.append(T)}else{let T=d("input",y);T.setAttribute("data-field",h.key),h.value!==void 0&&(T.value=h.value),c[h.key]=()=>T.value,W.append(T)}let P=d("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});P.setAttribute("data-feedback",h.key),p[h.key]=P,W.append(P)}let f=(h,v)=>{let P=p[h];P&&(P.textContent=v!=null?v:"",P.style.display=v?"block":"none")};if(l){let h=zn(l);W.append(h.node),c[yt]=h.value}let x=d("button",F("#6366f1"),i),C=d("button",le(U({},F("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=()=>a(Object.fromEntries(Object.entries(c).map(([h,v])=>[h,v()])),f),C.onclick=ae,W.append(x,C)},yt="__page",en={},qo=o=>{var i;for(let a of o!=null?o:[])en[a.slot_id]=(i=a.target)==null?void 0:i.page};pt(e,"/v1/editor/slots").then(o=>qo(o==null?void 0:o.slots));let zn=o=>{let i=Ot(location.pathname),a=d("div",{}),l=d("select",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});l.setAttribute("data-field","page");for(let c of bn(i,en[o])){let p=document.createElement("option");p.value=c,p.textContent=Mo(c,i),l.append(p)}return a.append(d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),l,d("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:a,value:()=>l.value}},bt=(o,i)=>i?le(U({},o),{page:i}):o,E=(o,i=!0)=>{X.textContent=o,X.style.color=i?"#a7f3d0":"#fca5a5"},tn=(o,i)=>{var l,c;if(u("error_shown",{code:(c=o.code)!=null?c:`http_${(l=o.status)!=null?l:"network"}`}),o.code==="plan_limit_reached"){let p=o.feature==="live_goals"?"live goal":"of these",y=o.plan?`${o.plan} plan`:"plan";return o.feature==="live_goals"?`Your ${y} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${y} has reached its limit for ${p}. Manage them in your dashboard, or upgrade for more.`}if(o.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(o.code==="demo_read_only"&&o.message)return o.message;let a=o.status?` (HTTP ${o.status})`:"";return`\u26A0 Couldn\u2019t ${i} \u2014 try again.${a}`},be=(o,i)=>{o.r==="ok"?E(i,!0):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):E(tn(o,"save"),!1)},Ke=null,Dt=o=>o.length>30?`${o.slice(0,27)}\u2026`:o,jn=o=>{Ke===o&&(mt===o&&(Nt(),mt=null),Ke=null,ye.style.display="none",N.style.display="none",Ue.textContent="")},Un=o=>{it===o&&(it=null,ue.style.display="none",Ue.textContent="")},vt=(o,i,a)=>{Ke=o,ye.textContent=i?`Publish \u201C${Dt(i)}\u201D \u2014 go live`:"Publish now \u2014 go live",ye.style.display="block",N.style.display="block";let l=[];if(a){let c=Ie("#374151","Preview");c.onclick=()=>Bn(o,a),l.push(c)}l.push(Rt(`/v1/editor/slots/${encodeURIComponent(o)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>jn(o))),On(i?`Draft saved for \u201C${Dt(i)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ye.onclick=async()=>{if(!Ke)return;ye.disabled=!0,E("Publishing\u2026");let o=await de(e,`/v1/editor/slots/${encodeURIComponent(Ke)}/publish`,{});ye.disabled=!1,o.r==="ok"?(u("published",{kind:"slot"}),E("\u2713 Published \u2014 live for new visitors.",!0),ye.style.display="none",Ke=null,Ue.textContent=""):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):E(tn(o,"publish"),!1)};let oe=null,Me=!1,nt=null,ot=null,Ee=null,Ge=null,xt=null,Ht=null,Fe=!1,Kn=(o,i)=>Me?o?"":`Nothing to swap with ${i} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Gn=()=>{O.disabled=!Me||!Ee,q.disabled=!Me||!Ge,O.title=O.disabled?Kn(Ee,"above"):"",q.title=q.disabled?Kn(Ge,"below"):""},Ce=null,nn=o=>{o&&!Ce&&t&&oe?(Ce=zn(Te("move",oe,t)),Se.before(Ce.node)):o||(Ce==null||Ce.node.remove(),Ce=null),Se.style.display=o?"block":"none",ze.style.display=o?"block":"none",Gn()},wt=()=>{if(Fe&&t&&xt&&xt.insertBefore(t,Ht),Fe=!1,xt=null,Ht=null,t){let o=Jt(t,document);nt=o.prevEl,ot=o.nextEl,Ee=o.prevLocator,Ge=o.nextLocator}g(),nn(!1)},Fn=o=>{if(S)return;let i=o.target;if(!i||b.contains(i)||i===m)return;gt(document);let a=i.getBoundingClientRect();Object.assign(m.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},Re=o=>{var a;let i=((a=o.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},Vo=o=>!!o.id||["section","header","footer","nav","main","form","article","aside"].includes(o.tagName.toLowerCase())||!!o.querySelector(":scope > h1, :scope > h2, :scope > h3"),Jo=o=>{var l;let i=o.querySelector("h1, h2, h3"),a=(l=i==null?void 0:i.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return a?a.length>28?`${a.slice(0,25)}\u2026`:a:o.id?`#${o.id.length>24?`${o.id.slice(0,21)}\u2026`:o.id}`:`<${o.tagName.toLowerCase()}>`},Yo=o=>{pe.textContent="";let i=[];for(let y=o.parentElement;y&&y!==document.body&&i.length<3;y=y.parentElement)Vo(y)&&i.push(y);let a=Re(o),l=()=>d("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),c=!0;for(let y of i){let f=Jo(y);if(f===a||a.startsWith(f))continue;let x=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},f);x.onclick=()=>kt(y),c||pe.append(l()),pe.append(x),c=!1}c||pe.append(l());let p=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");p.onclick=()=>Wn(),pe.append(p),pe.style.display="block"},Xo=o=>{ee.textContent="";let i=null,a=0;for(let c=o.parentElement;c&&c!==document.body&&a<6;c=c.parentElement,a++)if(dt(Ye(c,document),c,document)){i=c;break}let l=d("div",{marginBottom:"8px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(252,165,165,0.12)",border:"1px solid rgba(252,165,165,0.4)"});if(i){let c=i;l.append(d("div",{marginBottom:"6px"},"This exact element can\u2019t be tracked safely \u2014 it looks identical to others on the page. You can pick something more specific inside it, or work with the whole block, which we can target reliably."));let p=d("button",le(U({},F("#6366f1")),{marginTop:"0"}),`Select \u201C${Re(c)}\u201D instead`);p.onclick=()=>kt(c);let y=d("button",le(U({},F("transparent")),{opacity:"0.6"}),"Pick something else");y.onclick=()=>{ee.textContent=""},l.append(p,y)}else l.append(d("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));ee.append(l)},kt=o=>{wt(),ae(),ee.textContent="",t=o,oe=Ye(o,document);let i=dt(oe,o,document);Me=i,g(),J.style.display="block",J.textContent=`Selected: ${Re(o)}`,Yo(o),u("element_selected",{unique:i}),E(i?"\u2713 Matches exactly 1 element":"",i),i||Xo(o),H.style.display="none",sn();for(let p of je)p.style.display="block";K.style.display="none",Y.style.display="none";let a=o.childElementCount===0;K.disabled=!i||!a,K.title=i?a?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",Y.disabled=!i,ne.disabled=!i,Z.disabled=!i;let l=o.closest("form");R.style.display=l?"block":"none",R.disabled=!l;let c=Jt(o,document);nt=c.prevEl,ot=c.nextEl,Ee=c.prevLocator,Ge=c.nextLocator,Gn(),Mt()},Wn=()=>{wt(),ae(),t=null,oe=null,Me=!1,nt=null,ot=null,Ee=null,Ge=null,g(),ee.textContent="",sn(),pe.textContent="",pe.style.display="none",J.textContent="",J.style.display="none";for(let o of je)o.style.display="none";H.style.display="block",E(""),Mt()},rt=!1,on=-1,qn=o=>{var l,c;let i=o.target,a=!!((l=i==null?void 0:i.closest)!=null&&l.call(i,'input, textarea, select, [contenteditable="true"]'));if(o.key==="Escape"){if(W.childElementCount>0){ae(),rt=!1;return}if(t){Wn(),rt=!1;return}if(!rt){rt=!0,E("Press Esc again to close the editor.");return}rt=!1,(c=Ae.onclick)==null||c.call(Ae,new MouseEvent("click"));return}if(rt=!1,!(a||S)){if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!t||(o.key==="ArrowUp"?O:q).disabled)return;o.preventDefault(),ln(o.key==="ArrowUp"?"up":"down");return}if(o.key==="Tab"){let p=[];for(let f of Cn){let x=we(f.locator,document);x&&!p.includes(x)&&p.push(x)}if(p.length===0)return;if(tt){E("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),o.preventDefault();return}o.preventDefault(),on=(on+(o.shiftKey?-1:1)+p.length)%p.length;let y=p[on];kt(y);try{y.scrollIntoView({block:"center",behavior:"smooth"})}catch(f){}}}},Vn=o=>{if(S)return;let i=o.target;if(!(!i||b.contains(i))){if(o.preventDefault(),o.stopPropagation(),tt&&i!==t&&Qt!==i){Qt=i,E("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}kt(i)}};K.onclick=()=>{var p,y,f;if(!t||!oe)return;u("form_opened",{kind:"text"});let o=oe,i=(y=(p=t.textContent)==null?void 0:p.trim())!=null?y:"";ht([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async x=>{let C=x.alt.trim();if(!C){E("\u26A0 Enter alternative wording to test.",!1);return}if(C===x.current.trim()){E("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let _=Te("text",o,t);E("Saving\u2026");let h=await de(e,`/v1/editor/slots/${encodeURIComponent(_)}`,{kind:"arms",target:bt(o,x[yt]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:x.current}},{id:"b",displayName:"Alternative",ops:{text:x.alt}}]}});h.r==="ok"&&(u("draft_saved",{kind:"slot"}),Hn(),ae(),vt(_,Re(t),"b")),be(h,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Te("text",o,t));let a=t,l=(f=a.textContent)!=null?f:"";Oe=()=>{a.textContent=l};let c=W.querySelector('input[data-field="alt"]');c==null||c.addEventListener("input",()=>{a.textContent=c.value.trim()===""?l:c.value})};let St=null,Jn=o=>{let i=f=>{var x;return((x=f.textContent)!=null?x:"").replace(/\s+/g," ").trim()},a=Array.from(o.querySelectorAll("h1,h2,h3,h4")).map(i).filter(Boolean);if(a.length===0){let f=o.closest("h1,h2,h3,h4");f&&a.push(i(f))}let l=Array.from(o.querySelectorAll("p")).map(i).filter(f=>f.length>0&&f.length<=300),c=[];for(let f of Array.from(o.querySelectorAll("a[href], button"))){let x=i(f);if(!x||x.length>60)continue;let C="",_=f.getAttribute("href");if(_)try{let h=new URL(_,window.location.href);h.protocol==="https:"&&(C=h.href)}catch(h){}c.push({label:x,href:C})}let p=Array.from(o.querySelectorAll("blockquote, q")).map(i).filter(Boolean);if(p.length===0&&ci.test(`${o.className} ${o.id}`))for(let f of l)f.length>=20&&p.push(f);let y=Array.from(o.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(i).filter(f=>f.length>0&&f.length<=80);return{headings:a,paragraphs:l,links:c,quotes:p,attributions:y}},Zo=(o,i)=>{var l,c,p,y,f,x,C,_,h,v,P,T,D,G,$,ge,me,L,j,se;let a=Le=>{var Pe;return i.paragraphs.length>=3&&(Pe=i.paragraphs[i.paragraphs.length-3+Le])!=null?Pe:""};switch(o){case"headline":return(l=i.headings[0])!=null?l:"";case"supporting":return(c=i.paragraphs[0])!=null?c:"";case"cta_label":return(y=(p=i.links[0])==null?void 0:p.label)!=null?y:"";case"cta_href":return(x=(f=i.links[0])==null?void 0:f.href)!=null?x:"";case"secondary_label":return(_=(C=i.links[1])==null?void 0:C.label)!=null?_:"";case"secondary_href":return(v=(h=i.links[1])==null?void 0:h.href)!=null?v:"";case"quote":case"q1":return(P=i.quotes[0])!=null?P:"";case"q2":return(T=i.quotes[1])!=null?T:"";case"q3":return(D=i.quotes[2])!=null?D:"";case"name":case"n1":return(G=i.attributions[0])!=null?G:"";case"n2":return($=i.attributions[1])!=null?$:"";case"n3":return(ge=i.attributions[2])!=null?ge:"";case"role":return(me=i.attributions[1])!=null?me:"";case"eyebrow":return"";case"f1_title":return(L=i.headings[1])!=null?L:"";case"f2_title":return(j=i.headings[2])!=null?j:"";case"f3_title":return(se=i.headings[3])!=null?se:"";case"f1_body":return a(0);case"f2_body":return a(1);case"f3_body":return a(2);default:return""}},Qo=(o,i,a)=>{u("form_opened",{kind:"arrangement"});let l=Jn(a);ht(o.fields.map(c=>({key:c.id,label:c.kind==="href"?`${c.label} (https link \u2014 required)`:c.label,value:Zo(c.id,l)})),"Save draft",async(c,p)=>{var P,T,G,$,ge;let y=!1,f=!1;for(let me of o.fields){if(me.kind==="href"){let j=!1;try{j=new URL((P=c[me.id])!=null?P:"").protocol==="https:"}catch(se){}p(me.id,j?null:"Links need to start with https://"),j||(y=!0);continue}let L=((T=c[me.id])!=null?T:"").trim()==="";p(me.id,L?"Fill this in with your own words":null),L&&(f=!0)}if(y){E("\u26A0 Fix the highlighted link(s).",!1);return}if(f){E("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}E("Saving\u2026");let D=c,{[yt]:x}=D,C=oo(D,[no(yt)]),_=await li(e,`/v1/editor/arrangements/${encodeURIComponent(o.id)}/instantiate`,{fields:C});if(_.r!=="ok"||!((G=_.data)!=null&&G.blocks)){_.r==="expired"?be(_.outcome,""):E(`\u26A0 ${(ge=($=_.data)==null?void 0:$.reason)!=null?ge:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let h=Te("arrange",i,a),v=await de(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:bt(i,x),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:o.id,displayName:o.name,blocks:_.data.blocks}],baseline:"original"}});v.r==="ok"&&(u("draft_saved",{kind:"arrangement"}),ae(),vt(h,o.name,o.id)),be(v,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")},Te("arrange",i,a))};ne.onclick=async()=>{var p,y;if(!t||!oe)return;let o=oe,i=t;if(ae(),E("Loading arrangements\u2026"),!St){let f=await pt(e,"/v1/editor/arrangements");St=(p=f==null?void 0:f.arrangements)!=null?p:null}if(!St||St.length===0){E("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let a=Ko(Jn(i)),l=St.filter(f=>a.includes(f.sectionType));if(l.length===0){E("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}E("Pick a layout for this section \u2014 your own words are carried across.");for(let f of l){let x=d("button",le(U({},F("#374151")),{textAlign:"left"}));x.append(d("div",{fontWeight:"600"},f.name),d("div",{fontSize:"11px",opacity:"0.7"},f.description)),x.onclick=()=>Qo(f,o,i),W.append(x)}let c=d("button",le(U({},F("transparent")),{opacity:"0.6"}),"Cancel");c.onclick=ae,W.append(c),(y=W.scrollIntoView)==null||y.call(W,{block:"nearest"})};let it=null,er=(o,i)=>{it=o,ue.textContent=i?`Start tracking \u201C${Dt(i)}\u201D now`:"Start tracking now",ue.style.display="block",On(i?`Goal \u201C${Dt(i)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[Rt(`/v1/editor/goals/${encodeURIComponent(o)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Un(o))])};ue.onclick=async()=>{if(!it)return;ue.disabled=!0,E("Activating\u2026");let o=await de(e,`/v1/editor/goals/${encodeURIComponent(it)}/publish`,{});ue.disabled=!1,o.r==="ok"?(u("published",{kind:"goal"}),E("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ue.style.display="none",it=null,Ue.textContent=""):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):E(tn(o,"activate"),!1)};let at=(o,i)=>`${ut(o)||"goal"}-${Ho(i)}`.slice(0,128),Yn=o=>{var l,c,p;let i=((l=o.textContent)!=null?l:"").replace(/\s+/g," ").trim();return i&&i.length<=60?i:((p=(c=o.getAttribute("aria-label"))!=null?c:o.getAttribute("id"))!=null?p:"").trim()||"element-clicked"},Et=async(o,i,a)=>{E("Saving\u2026");let l=await de(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);return l.r==="ok"&&(u("draft_saved",{kind:"goal"}),er(o,a)),be(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live."),l};Z.onclick=()=>{if(!t||!oe)return;let o=at(Yn(t),JSON.stringify(oe));Et(o,{event:"click",locator:oe},Re(t))},R.onclick=()=>{var l,c;let o=t==null?void 0:t.closest("form");if(!o)return;let i=Ye(o,document),a=(c=(l=o.getAttribute("id"))!=null?l:o.getAttribute("name"))!=null?c:"form-submitted";Et(at(a,JSON.stringify(i)),{event:"form_submit",locator:i},a)},re.onclick=()=>{let o=window.location.pathname||"/",i=ut(o)?`reached-${ut(o)}`:"page-visited";Et(at(i,o),{event:"url_reached",urlPattern:o},o)};let rn=[{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}];ie.onclick=()=>{ht([{key:"depth",label:"Counts once a visitor reads",type:"select",options:rn.map(o=>o.label)}],"Track it",o=>{var l;let i=(l=rn.find(c=>c.label===o.depth))!=null?l:rn[2],a=Math.round(i.value*100);Et(`read-${a}pct`,{event:"scroll_depth",threshold:i.value},`read ${a}%`),ae()})};let zt=null,tr=o=>{zt=o,Q.style.display="block"};Q.onclick=async()=>{if(!zt)return;Q.disabled=!0,E("Turning on\u2026");let o=await de(e,`/v1/editor/funnels/${encodeURIComponent(zt)}/publish`,{});Q.disabled=!1,o.r==="ok"?(u("published",{kind:"funnel"}),E("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),Q.style.display="none",zt=null):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):E("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},A.onclick=async()=>{var _;E("Loading your goals\u2026");let o=await pt(e,"/v1/editor/goals"),i=(_=o==null?void 0:o.goals)!=null?_:[];if(i.length<2){E("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}E("Pick the steps in order \u2014 first click = first step."),ae();let a=[],l=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),c=d("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});W.append(l,c);let p=d("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");W.append(p);let y=new Map,f=()=>{var h,v;for(let[P,T]of y){let D=a.indexOf(P),G=(v=(h=i.find($=>$.goal_id===P))==null?void 0:h.display_name)!=null?v:P;T.textContent=D===-1?G:`${D+1}. ${G}`,T.style.background=D===-1?"#374151":"#6366f1"}};for(let h of i){let v=d("button",le(U({},F("#374151")),{textAlign:"left"}));y.set(h.goal_id,v),v.onclick=()=>{a=Ro(a,h.goal_id),f()},W.append(v)}f();let x=d("button",F("#6366f1"),"Save funnel"),C=d("button",le(U({},F("transparent")),{opacity:"0.6"}),"Cancel");C.onclick=ae,x.onclick=async()=>{let h=Po(c.value,a);if(!h.ok){E(`\u26A0 ${h.error}`,!1);return}E("Saving\u2026");let v=await de(e,`/v1/editor/funnels/${encodeURIComponent(h.funnelId)}`,h.body);v.r==="ok"&&(u("draft_saved",{kind:"funnel"}),ae(),tr(h.funnelId)),be(v,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},W.append(x,C)},N.onclick=async()=>{var f,x;let o=Ke;if(!o)return;E("Loading funnels\u2026");let i=await pt(e,"/v1/editor/funnels"),a=(f=i==null?void 0:i.funnels)!=null?f:[];if(a.length===0){E("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await pt(e,"/v1/editor/goals"),c=new Map(((x=l==null?void 0:l.goals)!=null?x:[]).map(C=>[C.goal_id,C.display_name]));ht([{key:"funnel",label:"Funnel",type:"select",options:a.map(C=>qt(C))},{key:"step",label:"Which step does this element serve?",type:"select",options:Vt(a[0],c).map(C=>C.label)}],"Attach",async C=>{var P;let _=(P=a.find(T=>qt(T)===C.funnel))!=null?P:a[0],h=Vt(_,c).findIndex(T=>T.label===C.step);if(h<0){E("\u26A0 Pick which step this element serves.",!1);return}E("Attaching\u2026");let v=await de(e,`/v1/editor/funnels/${encodeURIComponent(_.funnel_id)}/assign`,{slotId:o,stepIndex:h});v.r==="ok"&&ae(),be(v,`\u2713 Attached \u2014 this test now works toward \u201C${_.display_name}\u201D.`)});let p=W.querySelector('select[data-field="funnel"]'),y=W.querySelector('select[data-field="step"]');p&&y&&p.addEventListener("change",()=>{var _;let C=(_=a.find(h=>qt(h)===p.value))!=null?_:a[0];y.length=1;for(let h of Vt(C,c)){let v=document.createElement("option");v.value=h.label,v.textContent=h.label,y.append(v)}})},Y.onclick=()=>{if(!t||!oe)return;u("form_opened",{kind:"style"});let o=oe;ht([{key:"color",label:"Text colour",type:"color"},{key:"background",label:"Background colour",type:"color"},{key:"fontSize",label:"Font size (e.g. 20px)"},{key:"fontWeight",label:"Font weight (e.g. 700)"},{key:"fontFamily",label:Sn.length?`Font (this site has: ${Sn.slice(0,3).join(", ")})`:"Font (e.g. Georgia, serif)"},{key:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(y,f)=>{var P;let{style:x,errors:C}=In(y),_=!1;for(let T of Tn)f(T,(P=C[T])!=null?P:null),C[T]&&(_=!0);if(_){E("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(x).length===0){E("\u26A0 Enter at least one style change.",!1);return}let h=Te("style",o,t);E("Saving\u2026");let v=await de(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:bt(o,y[yt]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:x}}]}});v.r==="ok"&&(u("draft_saved",{kind:"slot"}),Hn(),ae(),vt(h,Re(t),"b")),be(v,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Te("style",o,t));let i=t,a=i.style.cssText;Oe=()=>{i.style.cssText=a};let l={},c=()=>{let{style:y}=In(l);i.style.cssText=a;for(let[f,x]of Object.entries(y)){let C=Bt[f];C&&ct(x)&&i.style.setProperty(C,x.trim(),"important")}};for(let y of Tn){let f=W.querySelector(`[data-field="${y}"]`);if(!f)continue;let x=()=>{l[y]=f.value,c()};f.addEventListener("input",x),f.addEventListener("change",x)}let p=[Xe==null?void 0:Xe.primaryBg,Xe==null?void 0:Xe.primaryText,"#ffffff"].filter(y=>!!y).map(En).filter((y,f,x)=>An(y)&&x.indexOf(y)===f);for(let y of["color","background"]){let f=W.querySelector(`input[data-field="${y}"]`);if(!f)continue;let x=d("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let C of p){let _=d("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:C,padding:"0"});_.title=C,_.onclick=()=>{f.value=En(C),f.dispatchEvent(new Event("input"))},x.append(_)}f.after(x)}};let We=[],Ct=new Map,an=!1,fe=null,te=null,Tt=null,nr=()=>{Ct.clear();let o=[],i=(a,l,c)=>{var f;if(o.length>=16||[...Ct.values()].some(x=>x.node===a))return;let p=a===t,y=p?"selected":`e${o.length}`;Ct.set(y,{node:a,locator:l}),o.push(U(U({ref:y,tag:a.tagName.toLowerCase().slice(0,16),text:((f=a.textContent)!=null?f:"").replace(/\s+/g," ").trim().slice(0,300),isLeaf:a.childElementCount===0,inForm:!!a.closest("form")},p?{selected:!0}:{}),c?{label:c.slice(0,120)}:{}))};t&&oe&&Me&&i(t,oe);for(let a of Cn){let l=we(a.locator,document);l&&i(l,a.locator,a.label)}return{pagePath:Ot(location.pathname),pageTitle:document.title.slice(0,200),elements:o}},qe=(o,i="")=>{let a=o==="user",l=d("div",{margin:"6px 0",padding:"7px 10px",borderRadius:"10px",fontSize:"12px",lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"88%",marginLeft:a?"auto":"0",background:a?"#6366f1":o==="note"?"transparent":"rgba(255,255,255,0.07)",opacity:o==="note"?"0.75":"1"},i);return fe==null||fe.append(l),fe&&(fe.scrollTop=fe.scrollHeight),l},sn=()=>{Tt&&(Tt.textContent=t?Me?`Looking at: ${Re(t)}`:"This element can\u2019t be targeted reliably \u2014 pick a heading, button, or section.":"Nothing selected \u2014 click an element, or ask for a page goal.")},Xn=(o,i)=>{var c,p;Nt();let a=(c=o.textContent)!=null?c:"",l=o.style.cssText;if(Oe=()=>{o.textContent=a,o.style.cssText=l},!!i){typeof i.text=="string"&&(o.textContent=i.text);for(let[y,f]of Object.entries((p=i.style)!=null?p:{})){let x=Bt[y];x&&typeof f=="string"&&ct(f)&&o.style.setProperty(x,f.trim(),"important")}}},or=async o=>{var P,T;let i=Ct.get(o.ref);if(!i||!i.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";let{node:a,locator:l}=i,c=o.versions.some(D=>typeof D.ops.text=="string"),p=Te(c?"text":"style",l,a),y=bn(location.pathname,en[p])[0];E("Saving\u2026");let f=await de(e,`/v1/editor/slots/${encodeURIComponent(p)}`,{kind:"arms",target:bt(l,y),draftConfig:{arms:[{id:"a",displayName:"Original",ops:c?{text:((P=a.textContent)!=null?P:"").trim()}:{}},...o.versions]}});if(be(f,"\u2713 Draft saved and previewing \u2014 nothing is live until you publish."),f.r!=="ok")return(T=X.textContent)!=null?T:"\u26A0 Couldn\u2019t save the draft.";u("draft_saved",{kind:"slot",via:"chat"}),a!==t&&kt(a),ae();let x=a;Xn(x,o.versions[0].ops),mt=p;try{x.scrollIntoView({block:"center",behavior:"smooth"})}catch(D){}vt(p,o.label,o.versions[0].id);let C=qe("assistant");C.textContent="",C.append(d("div",{fontWeight:"600",marginBottom:"6px"},`Draft: ${o.label}`));let _=d("div",{display:"flex",gap:"5px",flexWrap:"wrap"}),h=[],v=(D,G)=>{for(let $ of h)$.style.background="#374151";D.style.background="#6366f1",Xn(x,G),mt=p};for(let[D,G]of[["Original",null],...o.versions.map($=>[$.displayName,$.ops])]){let $=Ie("#374151",D);$.onclick=()=>v($,G),h.push($),_.append($)}return h[1].style.background="#6366f1",C.append(_),`[Created draft "${o.label}" with ${o.versions.length} version(s)]`},rr=(o,i,a)=>{var y;let l=[],c={position:"absolute",pointerEvents:"none",zIndex:"2147483645",padding:"2px 6px",borderRadius:"4px",background:"#f59e0b",color:"#111827",font:"600 11px system-ui, sans-serif",whiteSpace:"nowrap"},p=null;if(o){let f=o.getBoundingClientRect();p=f.top+window.scrollY,l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:`${f.left+window.scrollX-3}px`,top:`${p-3}px`,width:`${f.width+6}px`,height:`${f.height+6}px`,border:"2px dashed #f59e0b",borderRadius:"6px"}),d("div",le(U({},c),{left:`${f.left+window.scrollX}px`,top:`${Math.max(0,p-24)}px`}),`Goal: ${a}`))}else i!==void 0&&(p=Math.round(document.documentElement.scrollHeight*i),l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:"0",right:"0",top:`${p}px`,borderTop:"2px dashed #f59e0b"}),d("div",le(U({},c),{left:"16px",top:`${p+4}px`}),`Goal counts here: ${a}`)));if(l.length!==0){if(((y=document.body)!=null?y:document.documentElement).append(...l),p!==null)try{window.scrollTo({top:Math.max(0,p-window.innerHeight/3),behavior:"smooth"})}catch(f){}setTimeout(()=>{for(let f of l)f.remove()},6e3)}},ir=async o=>{var p,y,f,x,C,_;let i=null,a,l;if(o.event==="click"||o.event==="form_submit"){let h=o.ref?Ct.get(o.ref):void 0;if(!h||!h.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";if(o.event==="click")i=h.node,a=at(Yn(i),JSON.stringify(h.locator)),l={event:"click",locator:h.locator};else{let v=h.node.closest("form");if(!v)return"\u26A0 That element isn\u2019t inside a form.";let P=Ye(v,document);if(!dt(P,v,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";i=v,a=at((y=(p=v.getAttribute("id"))!=null?p:v.getAttribute("name"))!=null?y:"form-submitted",JSON.stringify(P)),l={event:"form_submit",locator:P}}}else if(o.event==="url_reached"){let h=(f=o.urlPattern)!=null?f:Ot(location.pathname);a=at(ut(h)?`reached-${ut(h)}`:"page-visited",h),l={event:"url_reached",urlPattern:h}}else a=`read-${Math.round(((x=o.threshold)!=null?x:.75)*100)}pct`,l={event:"scroll_depth",threshold:(C=o.threshold)!=null?C:.75};return(await Et(a,le(U({},l),{displayName:o.displayName}),o.displayName)).r!=="ok"?(_=X.textContent)!=null?_:"\u26A0 Couldn\u2019t save the goal.":(rr(i,o.event==="scroll_depth"?l.threshold:void 0,o.displayName),`[Created draft goal "${o.displayName}"]`)},Zn=async o=>{var x,C,_;let i=o.trim();if(!i||an)return;an=!0,te&&(te.value="",te.disabled=!0),qe("user",i),We.push({role:"user",content:i.slice(0,4e3)}),u("form_opened",{kind:"chat"});let a=qe("assistant","\u2026"),l="",c=!1,p=[],y=[],f=h=>{var P,T;if(h==="[DONE]")return;let v;try{v=JSON.parse(h)}catch(D){return}if(v.error){p.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(v.type==="delta"&&v.text)c&&l&&(l+=`
24
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Zt(e){var r,s;Zo(),(r=document.getElementById(en))==null||r.remove();let t=d("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=en;let n=d("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,d("div",{},e)),((s=document.body)!=null?s:document.documentElement).appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function mi(){let e=window.__sentientEditor;return e&&typeof e.apiBase=="string"&&(typeof e.token=="string"||typeof e.code=="string")?e:null}async function Qo(e){try{let t=await fetch(`${e.apiBase}/v1/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e.code})}),n=t.ok?(await t.json()).token:null;return e.code=null,n?(e.token=n,Ko(n),200):t.ok?500:t.status}catch(t){return 0}}async function hi(e){try{let t=await fetch(`${e.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${e.token}`}});if(t.status===401)return{ok:!1,unauthorized:!0};if(!t.ok)return{ok:!1,unauthorized:!1};let n=(await t.json()).projectId;return n?{ok:!0,projectId:n}:{ok:!1,unauthorized:!1}}catch(t){return{ok:!1,unauthorized:!1}}}function Nn(e,t){return K(K(K(K({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 ce(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});if(r.ok)return{r:"ok"};let s=await r.json().catch(()=>null);return Nn(r.status,s)}catch(r){return{r:"error"}}}async function yi(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{method:"DELETE",headers:{authorization:`Bearer ${e.token}`}});if(n.ok)return{r:"ok"};let r=await n.json().catch(()=>null);return Nn(n.status,r)}catch(n){return{r:"error"}}}async function bi(e,t,n){try{let r=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)}),s=await r.json().catch(()=>null);return r.ok?{r:"ok",data:s,outcome:{r:"ok"}}:{r:r.status===401?"expired":"error",data:s,outcome:Nn(r.status,s)}}catch(r){return{r:"error",data:null,outcome:{r:"error"}}}}var An=[];function Pn(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function $n(e){let t=e.trim();if(Pn(t))return t;let n=/^#([0-9a-fA-F]{3})$/.exec(t);if(n)return`#${n[1].split("").map(c=>c+c).join("")}`;let r=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/.exec(t);if(!r)return t;let s=c=>Math.min(255,Number(c)).toString(16).padStart(2,"0");return`#${s(r[1])}${s(r[2])}${s(r[3])}`}var Ze=null,Bn=[];function er(e){Bn=e}async function vi(e){try{let t=await fetch(`${e.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${e.token}`}});if(!t.ok)return[];let n=await t.json();return An=Array.isArray(n.fonts)?n.fonts.filter(r=>typeof r=="string"):[],Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}async function ft(e,t){try{let n=await fetch(`${e.apiBase}${t}`,{headers:{authorization:`Bearer ${e.token}`}});return n.ok?await n.json():null}catch(n){return null}}function mt(e=document){for(let t of Array.from(e.querySelectorAll(`.${In}`)))t.remove()}function tr(e,t=document){var r;mt(t);let n=0;for(let s of e){if(n>=gi)break;let c=we(s.locator,t);if(!c)continue;let m=c.getBoundingClientRect(),x=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${m.top}px`,width:`${m.width}px`,height:`${m.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});x.className=In;let g=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${m.left}px`,top:`${Math.max(0,m.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},s.label);g.className=In,((r=t.body)!=null?r:t.documentElement).append(x,g),n+=1}}function Qt(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,s=n?Xe(n,t):null,c=r?Xe(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&s&&ut(s,n,t)?s:null,nextLocator:r&&c&&ut(c,r,t)?c:null}}var xi=/testimonial|review|quote/i;function nr(e){let t=[],n=e.headings.length>=1,r=e.links.length>=1;return n&&r&&t.push("hero","cta_band"),e.headings.length>=2&&e.paragraphs.length>=2&&t.push("feature_grid"),e.quotes.length>=1&&t.push("testimonial"),t}var On=["color","background","fontSize","fontWeight","borderRadius","textAlign","fontFamily"],wi=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,ki=new Set(["left","center","right","justify","start","end"]),Si=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Ei=/^(rgb|rgba|hsl|hsla)\(/i;function Ti(e){return Si.test(e)||Ei.test(e)}function or(e,t){switch(e){case"fontSize":case"borderRadius":return wi.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 ki.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return Ti(t)?null:"Enter a colour, e.g. #1a1a1a.";case"fontFamily":{let n=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,""));return t.length<=120&&n.length>=1&&n.length<=5&&n.every(r=>/^[A-Za-z0-9][A-Za-z0-9 -]*$/.test(r))?null:"Use a font name, e.g. Georgia, serif."}default:return null}}function Mn(e){let t={},n={};for(let r of On){let s=e[r];if(typeof s!="string")continue;let c=s.trim();if(c==="")continue;if(!ct(c)){n[r]="That value isn\u2019t allowed.";continue}let m=or(r,c);if(m){n[r]=m;continue}t[r]=c}return{style:t,errors:n}}function d(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function rr(e){var ao;let t=null,n=[],r=null,s=()=>{for(;n.length>0;){let o=n.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:o})}).catch(()=>{})}catch(i){}}},c=(o,i)=>{n.push(K({kind:o},i?{meta:i}:{})),r&&clearTimeout(r),r=setTimeout(s,2e3)};window.addEventListener("pagehide",s);let m=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});m.id=pi;let x=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});x.id=fi;let g=()=>{if(!t||!t.isConnected){x.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(x.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},w=()=>g();Zo();let b=d("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"min(408px, calc(100vw - 32px))",padding:"16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",overscrollBehavior:"contain"});b.id=gt;let B=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});B.className="sntedi-dot";let L=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});L.append(B,d("span",{},"SentientUI"));let H=d("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),S=!1,z=d("button",F("#374151"),"Pause selecting");z.onclick=()=>{S=!S,z.textContent=S?"Resume selecting":"Pause selecting",S?(m.style.display="none",mt(document),E("Selection paused \u2014 browse normally, then resume.")):E("Click any element on the page to adapt it.")};let J=d("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),Z=d("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),U=d("button",F("#6366f1"),"Test different text here"),X=d("button",F("#374151"),"Change style"),ne=d("button",F("#374151"),"Try a different layout for this section"),Q=d("button",F("#374151"),"Track clicks as a goal"),N=d("button",F("#374151"),"Track form submissions as a goal"),re=d("button",F("#374151"),"Track page visits as a goal"),ie=d("button",F("#374151"),"Track reading this far as a goal"),I=d("button",F("#374151"),"Set up a funnel"),P=d("button",F("#374151"),"Attach this test to a funnel step"),q=d("button",F("#10b981"),"Turn the funnel on"),O=d("button",F("#374151"),"Move up"),V=d("button",F("#374151"),"Move down"),Se=d("button",F("#6366f1"),"Save this arrangement"),ze=d("button",F("#374151"),"Undo"),Ie=Ln("close","Close editor"),ye=d("button",F("#10b981"),"Publish now \u2014 go live"),ue=d("button",F("#10b981"),"Start tracking now");for(let o of[U,X,ne,Q,O,V])o.disabled=!0;let je=[U,X,ne,Q,N,O,V];for(let o of je)o.style.display="none";Se.style.display="none",ze.style.display="none",ye.style.display="none",ue.style.display="none",P.style.display="none",q.style.display="none";let pe=d("div",{display:"none",fontSize:"11px",opacity:"0.75",marginBottom:"2px",lineHeight:"1.8",overflow:"hidden",textOverflow:"ellipsis"}),ee=d("div",{}),Ae=[{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"}],Y="text",et=new Map,ve=new Map,$e=new Map,Rn=d("div",{display:"flex",gap:"0",margin:"10px 0 0",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.1)"}),Dn=d("div",{paddingTop:"10px"});for(let o of Ae){let i=d("button",{background:"transparent",border:"none",cursor:"pointer",font:"600 11.5px system-ui, sans-serif",color:"#9ca3af",whiteSpace:"nowrap",padding:"7px 5px",borderBottom:"2px solid transparent",marginBottom:"-1px"});i.append(d("span",{fontSize:"11px",marginRight:"3px"},o.icon),d("span",{},o.label)),i.onclick=()=>ir(o.id),et.set(o.id,i),Rn.append(i);let a=d("div",{display:"none"}),l=d("div",{fontSize:"12px",opacity:"0.7",padding:"2px 0 6px",display:"none"});a.append(l),$e.set(o.id,l),ve.set(o.id,a),Dn.append(a)}ve.get("text").append(U),ve.get("style").append(X),ve.get("layout").append(ne,O,V,Se,ze),ve.get("goals").append(Q,N,re,ie),ve.get("funnels").append(I,P,q);let xe=d("div",{});ve.get("drafts").append(xe);let Pt=()=>{var i,a;for(let l of Ae){let u=l.id===Y,f=et.get(l.id);f.style.color=u?"#ffffff":"#9ca3af",f.style.borderBottom=u?"2px solid #6366f1":"2px solid transparent",ve.get(l.id).style.display=u?"block":"none",$e.get(l.id).style.display="none"}let o=l=>{let u=$e.get(Y);u.textContent=l,u.style.display="block"};Y==="text"?t?U.disabled?o(U.title||"This element can\u2019t be targeted reliably \u2014 try its heading or a button."):(i=U.onclick)==null||i.call(U,new MouseEvent("click")):o("Click any text on the page to test a different wording."):Y==="style"?t?X.disabled?o("This element can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section."):(a=X.onclick)==null||a.call(X,new MouseEvent("click")):o("Click any element on the page to change how it looks."):Y==="layout"?t||o("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."):Y==="goals"?t||o("Page-level goals work right away; click a button or form to track it specifically."):Y==="funnels"?o("Chain tracked goals into a journey \u2014 the drop-off view fills in as visitors move through it."):Y==="drafts"&&tt()},Le=(o,i)=>d("button",le(K({},F(o)),{display:"inline-block",width:"auto",margin:"0",padding:"4px 9px",fontSize:"11px",flex:"0 0 auto"}),i),Hn=(o,i)=>{let a=new URL(window.location.href);a.searchParams.set("sentient_preview",o),i&&a.searchParams.set("sentient_arm",i),window.location.assign(a.toString())},Rt=(o,i,a)=>{let l=Le("#374151","Discard");return l.onclick=async()=>{l.disabled=!0;let u=await yi(e,o);l.disabled=!1,be(u,i),u.r==="ok"&&a()},l},zn=(o,i)=>{Ke.textContent="";let a=d("div",{margin:"0 0 6px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.35)"}),l=d("div",{display:"flex",gap:"6px",flexWrap:"wrap"});l.append(...i),a.append(d("div",{marginBottom:"6px"},o),l),Ke.append(a)},tt=async()=>{var k,T,A,h,v,R,C,D,G,$,ge,me;xe.textContent="",xe.append(d("div",{fontSize:"12px",opacity:"0.6",padding:"4px 0"},"Loading\u2026"));let o=[],i=[],a=null,l=!1;if(await Promise.all([(async()=>{var _;try{let j=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?o=(_=(await j.json()).slots)!=null?_:[]:a=j.status===401?"expired":"error"}catch(j){a="error"}})(),(async()=>{var _;try{let j=await fetch(`${e.apiBase}/v1/editor/goals`,{headers:{authorization:`Bearer ${e.token}`}});j.ok?i=(_=(await j.json()).goals)!=null?_:[]:l=!0}catch(j){l=!0}})()]),Y!=="drafts")return;if(xe.textContent="",a){if(xe.append(d("div",{fontSize:"12px",opacity:"0.8",padding:"4px 0"},a==="expired"?"Editor session expired \u2014 reopen it from your dashboard to see your drafts. They\u2019re safe.":"Couldn\u2019t load your drafts \u2014 they\u2019re safe; check your connection and retry.")),a==="error"){let _=Le("#374151","Retry");_.onclick=()=>{tt()},xe.append(_)}return}let u=o.filter(_=>{var j,se,_e,Pe,Ve,_t;return((_e=(se=(j=_.draft_config)==null?void 0:j.arms)==null?void 0:se.length)!=null?_e:0)>0||((_t=(Ve=(Pe=_.published_config)==null?void 0:Pe.arms)==null?void 0:Ve.length)!=null?_t:0)>0}),f=i.filter(_=>_.event!=="custom"&&(_.status==="draft"||_.status==="active"));if(u.length===0&&f.length===0&&!l){xe.append(d("div",{fontSize:"12px",opacity:"0.7",padding:"4px 0"},"Nothing saved yet \u2014 changes and goals you save land here, previewable before they go live."));return}let y=_=>d("span",{fontSize:"10px",padding:"2px 7px",borderRadius:"999px",flex:"0 0 auto",background:_?"rgba(16,185,129,0.2)":"rgba(99,102,241,0.25)",color:_?"#6ee7b7":"#c7d2fe"},_?"live":"draft"),p=_=>{let j=d("div",{display:"flex",alignItems:"center",gap:"6px",padding:"7px 0",borderBottom:"1px solid rgba(255,255,255,0.08)",fontSize:"12px"}),se=d("div",{flex:"1 1 auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},_);return j.append(se),{row:j,name:se}};for(let _ of u){let{row:j}=p((k=_.display_name)!=null?k:_.slot_id);j.append(y(_.status==="published"));let se=(v=(h=(T=_.draft_config)==null?void 0:T.arms)!=null?h:(A=_.published_config)==null?void 0:A.arms)!=null?v:[],_e=(D=(R=se[1])==null?void 0:R.id)!=null?D:(C=se[0])==null?void 0:C.id,Pe=Le("#374151","Preview");if(Pe.onclick=()=>Hn(_.slot_id,_e),j.append(Pe),_.status!=="published"&&((ge=($=(G=_.draft_config)==null?void 0:G.arms)==null?void 0:$.length)!=null?ge:0)>0){let Ve=Le("#10b981","Publish");Ve.onclick=async()=>{Ve.disabled=!0;let _t=await ce(e,`/v1/editor/slots/${encodeURIComponent(_.slot_id)}/publish`,{});Ve.disabled=!1,be(_t,"\u2713 Published \u2014 live for new visitors."),_t.r==="ok"&&(c("published",{kind:"slot"}),tt())},j.append(Ve)}_.status!=="published"&&j.append(Rt(`/v1/editor/slots/${encodeURIComponent(_.slot_id)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>{Vn(_.slot_id),tt()})),xe.append(j)}if(l)xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"6px 0 2px"},"Couldn\u2019t load your goals right now \u2014 they\u2019re safe."));else if(f.length>0){xe.append(d("div",{fontSize:"11px",opacity:"0.6",padding:"8px 0 2px"},"Goals"));for(let _ of f){let{row:j}=p((me=_.display_name)!=null?me:_.goal_id);if(j.append(y(_.status==="active")),_.status==="draft"){let se=Le("#10b981","Start tracking");se.onclick=async()=>{se.disabled=!0;let _e=await ce(e,`/v1/editor/goals/${encodeURIComponent(_.goal_id)}/publish`,{});se.disabled=!1,be(_e,"\u2713 Tracking is live \u2014 it counts from your next visitor."),_e.r==="ok"&&(c("published",{kind:"goal"}),tt())},j.append(se,Rt(`/v1/editor/goals/${encodeURIComponent(_.goal_id)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>{Yn(_.goal_id),tt()}))}xe.append(j)}}},ir=o=>{Y!==o&&(ae(),kt(),Y=o,Pt())},jn=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"});Object.assign(L.style,{marginBottom:"0",flex:"1 1 auto",fontSize:"13px",whiteSpace:"nowrap"});let Kn=!1,Be=d("button",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"44px",height:"44px",borderRadius:"12px",border:"1px solid #2a2a2a",background:"#000",cursor:"pointer",display:"none",padding:"0",alignItems:"center",justifyContent:"center",boxShadow:"0 6px 18px rgba(0,0,0,0.4)"});Be.append(Li(26)),Be.title="Open the SentientUI editor",Be.setAttribute("aria-label","Open the SentientUI editor");let Un=Ln("minimize","Minimize");Un.onclick=()=>{b.style.display="none",Be.style.display="flex",Kn=S,S=!0,m.style.display="none",mt(document)},Be.onclick=()=>{b.style.display="block",Be.style.display="none",S=Kn},Object.assign(z.style,{display:"inline-block",width:"auto",margin:"0",padding:"3px 8px",fontSize:"10.5px",borderRadius:"999px",background:"#374151",whiteSpace:"nowrap"}),jn.append(L,z,Un,Ie);let Gn=d("div",{marginTop:"10px",borderTop:"1px solid rgba(255,255,255,0.1)",paddingTop:"8px"}),Ke=d("div",{});Object.assign(Z.style,{marginBottom:"4px"}),Gn.append(Ke,Z,ye,ue);let Fn=d("button",{display:"inline-block",width:"auto",margin:"0",padding:"5px 10px",flex:"0 0 auto",fontSize:"11px",borderRadius:"999px",background:"rgba(250,204,21,0.15)",border:"1px solid rgba(250,204,21,0.45)",color:"#fde68a",cursor:"pointer",whiteSpace:"nowrap"},"\u2728 Ask AI"),nn=d("div",{display:"flex",alignItems:"center",gap:"6px"});Object.assign(J.style,{flex:"1 1 auto",marginBottom:"0"}),nn.append(J,Fn),Object.assign(nn.style,{marginBottom:"6px"});let Dt=d("div",{}),W=d("div",{marginTop:"4px"});W.addEventListener("input",()=>{nt=!0}),W.addEventListener("change",()=>{nt=!0}),b.append(jn,H,nn,pe,ee,Dt,Rn,Dn,W,Gn),((ao=document.body)!=null?ao:document.documentElement).append(m,x,b,Be);let Oe=null,Ht=()=>{Oe==null||Oe(),Oe=null},Wn=()=>{Oe=null},ht=null,nt=!1,on=null,ae=()=>{Ht(),ht=null,W.textContent="",nt=!1,on=null,fn=!1},yt=(o,i,a,l)=>{var A;ae();let u={},f={},y={display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"};for(let h of o){let v=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},h.label);if(W.append(v),h.type==="select"){let C=d("select",y);C.setAttribute("data-field",h.key);let D=document.createElement("option");D.value="",D.textContent="\u2014 no change \u2014",C.append(D);for(let G of(A=h.options)!=null?A:[]){let $=document.createElement("option");$.value=G,$.textContent=G,C.append($)}u[h.key]=()=>C.value,W.append(C)}else if(h.type==="color"){let C=d("input",le(K({},y),{padding:"2px",height:"34px"}));C.type="color",C.setAttribute("data-field",h.key);let D=!1;C.addEventListener("input",()=>{D=!0}),u[h.key]=()=>D?C.value:"",W.append(C)}else{let C=d("input",y);C.setAttribute("data-field",h.key),h.value!==void 0&&(C.value=h.value),u[h.key]=()=>C.value,W.append(C)}let R=d("div",{fontSize:"11px",color:"#fca5a5",marginTop:"3px",display:"none"});R.setAttribute("data-feedback",h.key),f[h.key]=R,W.append(R)}let p=(h,v)=>{let R=f[h];R&&(R.textContent=v!=null?v:"",R.style.display=v?"block":"none")};if(l){let h=qn(l);W.append(h.node),u[bt]=h.value}let k=d("button",F("#6366f1"),i),T=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");k.onclick=()=>a(Object.fromEntries(Object.entries(u).map(([h,v])=>[h,v()])),p),T.onclick=ae,W.append(k,T)},bt="__page",rn={},ar=o=>{var i;for(let a of o!=null?o:[])rn[a.slot_id]=(i=a.target)==null?void 0:i.page};ft(e,"/v1/editor/slots").then(o=>ar(o==null?void 0:o.slots));let qn=o=>{let i=Nt(location.pathname),a=d("div",{}),l=d("select",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});l.setAttribute("data-field","page");for(let u of Cn(i,rn[o])){let f=document.createElement("option");f.value=u,f.textContent=Go(u,i),l.append(f)}return a.append(d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Where does this appear?"),l,d("div",{fontSize:"11px",opacity:"0.6",marginTop:"3px"},"Helps us tell a moved element from a page it isn\u2019t on.")),{node:a,value:()=>l.value}},vt=(o,i)=>i?le(K({},o),{page:i}):o,E=(o,i=!0)=>{Z.textContent=o,Z.style.color=i?"#a7f3d0":"#fca5a5"},an=(o,i)=>{var l,u;if(c("error_shown",{code:(u=o.code)!=null?u:`http_${(l=o.status)!=null?l:"network"}`}),o.code==="plan_limit_reached"){let f=o.feature==="live_goals"?"live goal":"of these",y=o.plan?`${o.plan} plan`:"plan";return o.feature==="live_goals"?`Your ${y} includes 1 live goal. Pause another goal in your dashboard, or upgrade to track more.`:`Your ${y} has reached its limit for ${f}. Manage them in your dashboard, or upgrade for more.`}if(o.code==="role_required")return"Your account can view but not edit this project \u2014 ask an admin for editor access.";if(o.code==="demo_read_only"&&o.message)return o.message;let a=o.status?` (HTTP ${o.status})`:"";return`\u26A0 Couldn\u2019t ${i} \u2014 try again.${a}`},be=(o,i)=>{o.r==="ok"?E(i,!0):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.",!1):E(an(o,"save"),!1)},Ue=null,zt=o=>o.length>30?`${o.slice(0,27)}\u2026`:o,Vn=o=>{Ue===o&&(ht===o&&(Ht(),ht=null),Ue=null,ye.style.display="none",P.style.display="none",Ke.textContent="")},Yn=o=>{at===o&&(at=null,ue.style.display="none",Ke.textContent="")},xt=(o,i,a)=>{Ue=o,ye.textContent=i?`Publish \u201C${zt(i)}\u201D \u2014 go live`:"Publish now \u2014 go live",ye.style.display="block",P.style.display="block";let l=[];if(a){let u=Le("#374151","Preview");u.onclick=()=>Hn(o,a),l.push(u)}l.push(Rt(`/v1/editor/slots/${encodeURIComponent(o)}`,"\u{1F5D1} Draft discarded \u2014 nothing changed for your visitors.",()=>Vn(o))),zn(i?`Draft saved for \u201C${zt(i)}\u201D \u2014 nothing is live for visitors yet.`:"Draft saved \u2014 nothing is live for visitors yet.",l)};ye.onclick=async()=>{if(!Ue)return;ye.disabled=!0,E("Publishing\u2026");let o=await ce(e,`/v1/editor/slots/${encodeURIComponent(Ue)}/publish`,{});ye.disabled=!1,o.r==="ok"?(c("published",{kind:"slot"}),E("\u2713 Published \u2014 live for new visitors.",!0),ye.style.display="none",Ue=null,Ke.textContent=""):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.",!1):E(an(o,"publish"),!1)};let oe=null,Me=!1,ot=null,rt=null,Ee=null,Ge=null,wt=null,jt=null,Fe=!1,Jn=(o,i)=>Me?o?"":`Nothing to swap with ${i} \u2014 it\u2019s at the edge, or that neighbor can\u2019t be targeted reliably.`:"This element can\u2019t be targeted reliably, so it can\u2019t be moved.",Xn=()=>{O.disabled=!Me||!Ee,V.disabled=!Me||!Ge,O.title=O.disabled?Jn(Ee,"above"):"",V.title=V.disabled?Jn(Ge,"below"):""},Te=null,sn=o=>{o&&!Te&&t&&oe?(Te=qn(Ce("move",oe,t)),Se.before(Te.node)):o||(Te==null||Te.node.remove(),Te=null),Se.style.display=o?"block":"none",ze.style.display=o?"block":"none",Xn()},kt=()=>{if(Fe&&t&&wt&&wt.insertBefore(t,jt),Fe=!1,wt=null,jt=null,t){let o=Qt(t,document);ot=o.prevEl,rt=o.nextEl,Ee=o.prevLocator,Ge=o.nextLocator}g(),sn(!1)},Zn=o=>{if(S)return;let i=o.target;if(!i||b.contains(i)||i===m)return;mt(document);let a=i.getBoundingClientRect();Object.assign(m.style,{display:"block",left:`${a.left}px`,top:`${a.top}px`,width:`${a.width}px`,height:`${a.height}px`})},Ne=o=>{var a;let i=((a=o.textContent)!=null?a:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},sr=o=>!!o.id||["section","header","footer","nav","main","form","article","aside"].includes(o.tagName.toLowerCase())||!!o.querySelector(":scope > h1, :scope > h2, :scope > h3"),lr=o=>{var l;let i=o.querySelector("h1, h2, h3"),a=(l=i==null?void 0:i.textContent)==null?void 0:l.replace(/\s+/g," ").trim();return a?a.length>28?`${a.slice(0,25)}\u2026`:a:o.id?`#${o.id.length>24?`${o.id.slice(0,21)}\u2026`:o.id}`:`<${o.tagName.toLowerCase()}>`},cr=o=>{pe.textContent="";let i=[];for(let y=o.parentElement;y&&y!==document.body&&i.length<3;y=y.parentElement)sr(y)&&i.push(y);let a=Ne(o),l=()=>d("span",{opacity:"0.5",margin:"0 4px"},"\u2039"),u=!0;for(let y of i){let p=lr(y);if(p===a||a.startsWith(p))continue;let k=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline"},p);k.onclick=()=>St(y),u||pe.append(l()),pe.append(k),u=!1}u||pe.append(l());let f=d("button",{background:"transparent",border:"none",color:"#a5b4fc",cursor:"pointer",font:"inherit",padding:"0",textDecoration:"underline",opacity:"0.7"},"Page");f.onclick=()=>Qn(),pe.append(f),pe.style.display="block"},dr=o=>{ee.textContent="";let i=null,a=0;for(let u=o.parentElement;u&&u!==document.body&&a<6;u=u.parentElement,a++)if(ut(Xe(u,document),u,document)){i=u;break}let l=d("div",{marginBottom:"8px",padding:"8px 10px",borderRadius:"8px",fontSize:"12px",background:"rgba(252,165,165,0.12)",border:"1px solid rgba(252,165,165,0.4)"});if(i){let u=i;l.append(d("div",{marginBottom:"6px"},"This exact element can\u2019t be tracked safely \u2014 it looks identical to others on the page. You can pick something more specific inside it, or work with the whole block, which we can target reliably."));let f=d("button",le(K({},F("#6366f1")),{marginTop:"0"}),`Select \u201C${Ne(u)}\u201D instead`);f.onclick=()=>St(u);let y=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Pick something else");y.onclick=()=>{ee.textContent=""},l.append(f,y)}else l.append(d("div",{},"This part of the page can\u2019t be targeted reliably \u2014 try a heading, a button, or a whole section instead."));ee.append(l)},St=o=>{kt(),ae(),ee.textContent="",t=o,oe=Xe(o,document);let i=ut(oe,o,document);Me=i,g(),J.style.display="block",J.textContent=`Selected: ${Ne(o)}`,cr(o),c("element_selected",{unique:i}),E(i?"\u2713 Matches exactly 1 element":"",i),i||dr(o),H.style.display="none",un();for(let f of je)f.style.display="block";U.style.display="none",X.style.display="none";let a=bn(o);U.disabled=!i||!a,U.title=i?a?"":"This element contains other elements, so testing text here would replace them. Pick the text itself (e.g. the heading), not its container.":"",X.disabled=!i,ne.disabled=!i,Q.disabled=!i;let l=o.closest("form");N.style.display=l?"block":"none",N.disabled=!l;let u=Qt(o,document);ot=u.prevEl,rt=u.nextEl,Ee=u.prevLocator,Ge=u.nextLocator,Xn(),Pt()},Qn=()=>{kt(),ae(),t=null,oe=null,Me=!1,ot=null,rt=null,Ee=null,Ge=null,g(),ee.textContent="",un(),pe.textContent="",pe.style.display="none",J.textContent="",J.style.display="none";for(let o of je)o.style.display="none";H.style.display="block",E(""),Pt()},it=!1,ln=-1,eo=o=>{var l,u;let i=o.target,a=!!((l=i==null?void 0:i.closest)!=null&&l.call(i,'input, textarea, select, [contenteditable="true"]'));if(o.key==="Escape"){if(W.childElementCount>0){ae(),it=!1;return}if(t){Qn(),it=!1;return}if(!it){it=!0,E("Press Esc again to close the editor.");return}it=!1,(u=Ie.onclick)==null||u.call(Ie,new MouseEvent("click"));return}if(it=!1,!(a||S)){if(o.key==="ArrowUp"||o.key==="ArrowDown"){if(!t||(o.key==="ArrowUp"?O:V).disabled)return;o.preventDefault(),pn(o.key==="ArrowUp"?"up":"down");return}if(o.key==="Tab"){let f=[];for(let p of Bn){let k=we(p.locator,document);k&&!f.includes(k)&&f.push(k)}if(f.length===0)return;if(nt){E("\u26A0 You have unsaved changes \u2014 Save or Cancel before picking another element.",!1),o.preventDefault();return}o.preventDefault(),ln=(ln+(o.shiftKey?-1:1)+f.length)%f.length;let y=f[ln];St(y);try{y.scrollIntoView({block:"center",behavior:"smooth"})}catch(p){}}}},to=o=>{if(S)return;let i=o.target;if(!(!i||b.contains(i))){if(o.preventDefault(),o.stopPropagation(),nt&&i!==t&&on!==i){on=i,E("\u26A0 You have unsaved changes \u2014 Save or Cancel first, or click that element again to discard them.",!1);return}St(i)}};U.onclick=()=>{var f,y;if(!t||!oe)return;c("form_opened",{kind:"text"});let o=oe,i=(y=(f=t.textContent)==null?void 0:f.trim())!=null?y:"";yt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async p=>{let k=p.alt.trim();if(!k){E("\u26A0 Enter alternative wording to test.",!1);return}if(k===p.current.trim()){E("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let T=Ce("text",o,t);E("Saving\u2026");let A=await ce(e,`/v1/editor/slots/${encodeURIComponent(T)}`,{kind:"arms",target:vt(o,p[bt]),draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:p.current}},{id:"b",displayName:"Alternative",ops:{text:p.alt}}]}});A.r==="ok"&&(c("draft_saved",{kind:"slot"}),Wn(),ae(),xt(T,Ne(t),"b")),be(A,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Ce("text",o,t));let a=t,l=vn(a);Oe=()=>{Ye(a,l)};let u=W.querySelector('input[data-field="alt"]');u==null||u.addEventListener("input",()=>{Ye(a,u.value.trim()===""?l:u.value)})};let Et=null,no=o=>{let i=p=>{var k;return((k=p.textContent)!=null?k:"").replace(/\s+/g," ").trim()},a=Array.from(o.querySelectorAll("h1,h2,h3,h4")).map(i).filter(Boolean);if(a.length===0){let p=o.closest("h1,h2,h3,h4");p&&a.push(i(p))}let l=Array.from(o.querySelectorAll("p")).map(i).filter(p=>p.length>0&&p.length<=300),u=[];for(let p of Array.from(o.querySelectorAll("a[href], button"))){let k=i(p);if(!k||k.length>60)continue;let T="",A=p.getAttribute("href");if(A)try{let h=new URL(A,window.location.href);h.protocol==="https:"&&(T=h.href)}catch(h){}u.push({label:k,href:T})}let f=Array.from(o.querySelectorAll("blockquote, q")).map(i).filter(Boolean);if(f.length===0&&xi.test(`${o.className} ${o.id}`))for(let p of l)p.length>=20&&f.push(p);let y=Array.from(o.querySelectorAll('cite, figcaption, footer, [class*="author"]')).map(i).filter(p=>p.length>0&&p.length<=80);return{headings:a,paragraphs:l,links:u,quotes:f,attributions:y}},ur=(o,i)=>{var l,u,f,y,p,k,T,A,h,v,R,C,D,G,$,ge,me,_,j,se;let a=_e=>{var Pe;return i.paragraphs.length>=3&&(Pe=i.paragraphs[i.paragraphs.length-3+_e])!=null?Pe:""};switch(o){case"headline":return(l=i.headings[0])!=null?l:"";case"supporting":return(u=i.paragraphs[0])!=null?u:"";case"cta_label":return(y=(f=i.links[0])==null?void 0:f.label)!=null?y:"";case"cta_href":return(k=(p=i.links[0])==null?void 0:p.href)!=null?k:"";case"secondary_label":return(A=(T=i.links[1])==null?void 0:T.label)!=null?A:"";case"secondary_href":return(v=(h=i.links[1])==null?void 0:h.href)!=null?v:"";case"quote":case"q1":return(R=i.quotes[0])!=null?R:"";case"q2":return(C=i.quotes[1])!=null?C:"";case"q3":return(D=i.quotes[2])!=null?D:"";case"name":case"n1":return(G=i.attributions[0])!=null?G:"";case"n2":return($=i.attributions[1])!=null?$:"";case"n3":return(ge=i.attributions[2])!=null?ge:"";case"role":return(me=i.attributions[1])!=null?me:"";case"eyebrow":return"";case"f1_title":return(_=i.headings[1])!=null?_:"";case"f2_title":return(j=i.headings[2])!=null?j:"";case"f3_title":return(se=i.headings[3])!=null?se:"";case"f1_body":return a(0);case"f2_body":return a(1);case"f3_body":return a(2);default:return""}},pr=(o,i,a)=>{c("form_opened",{kind:"arrangement"});let l=no(a);yt(o.fields.map(u=>({key:u.id,label:u.kind==="href"?`${u.label} (https link \u2014 required)`:u.label,value:ur(u.id,l)})),"Save draft",async(u,f)=>{var R,C,G,$,ge;let y=!1,p=!1;for(let me of o.fields){if(me.kind==="href"){let j=!1;try{j=new URL((R=u[me.id])!=null?R:"").protocol==="https:"}catch(se){}f(me.id,j?null:"Links need to start with https://"),j||(y=!0);continue}let _=((C=u[me.id])!=null?C:"").trim()==="";f(me.id,_?"Fill this in with your own words":null),_&&(p=!0)}if(y){E("\u26A0 Fix the highlighted link(s).",!1);return}if(p){E("\u26A0 Every field needs your own words \u2014 this layout re-arranges your copy, it doesn\u2019t write any.",!1);return}E("Saving\u2026");let D=u,{[bt]:k}=D,T=uo(D,[co(bt)]),A=await bi(e,`/v1/editor/arrangements/${encodeURIComponent(o.id)}/instantiate`,{fields:T});if(A.r!=="ok"||!((G=A.data)!=null&&G.blocks)){A.r==="expired"?be(A.outcome,""):E(`\u26A0 ${(ge=($=A.data)==null?void 0:$.reason)!=null?ge:"Couldn\u2019t build the arrangement \u2014 check the fields."}`,!1);return}let h=Ce("arrange",i,a),v=await ce(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:vt(i,k),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:o.id,displayName:o.name,blocks:A.data.blocks}],baseline:"original"}});v.r==="ok"&&(c("draft_saved",{kind:"arrangement"}),ae(),xt(h,o.name,o.id)),be(v,"\u2713 Saved as a draft \u2014 it will test against this section as it is today. Click \u201CPublish\u201D below to go live.")},Ce("arrange",i,a))};ne.onclick=async()=>{var f,y;if(!t||!oe)return;let o=oe,i=t;if(ae(),E("Loading arrangements\u2026"),!Et){let p=await ft(e,"/v1/editor/arrangements");Et=(f=p==null?void 0:p.arrangements)!=null?f:null}if(!Et||Et.length===0){E("\u26A0 Couldn\u2019t load the arrangements \u2014 try again.",!1);return}let a=nr(no(i)),l=Et.filter(p=>a.includes(p.sectionType));if(l.length===0){E("No other layout fits this section. Layouts re-arrange the words already here \u2014 they don\u2019t add sections your page doesn\u2019t have.",!1);return}E("Pick a layout for this section \u2014 your own words are carried across.");for(let p of l){let k=d("button",le(K({},F("#374151")),{textAlign:"left"}));k.append(d("div",{fontWeight:"600"},p.name),d("div",{fontSize:"11px",opacity:"0.7"},p.description)),k.onclick=()=>pr(p,o,i),W.append(k)}let u=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");u.onclick=ae,W.append(u),(y=W.scrollIntoView)==null||y.call(W,{block:"nearest"})};let at=null,fr=(o,i)=>{at=o,ue.textContent=i?`Start tracking \u201C${zt(i)}\u201D now`:"Start tracking now",ue.style.display="block",zn(i?`Goal \u201C${zt(i)}\u201D saved \u2014 it isn\u2019t counting anything until you start it.`:"Goal saved \u2014 it isn\u2019t counting anything until you start it.",[Rt(`/v1/editor/goals/${encodeURIComponent(o)}`,"\u{1F5D1} Draft goal discarded \u2014 it never tracked anything.",()=>Yn(o))])};ue.onclick=async()=>{if(!at)return;ue.disabled=!0,E("Activating\u2026");let o=await ce(e,`/v1/editor/goals/${encodeURIComponent(at)}/publish`,{});ue.disabled=!1,o.r==="ok"?(c("published",{kind:"goal"}),E("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),ue.style.display="none",at=null,Ke.textContent=""):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.",!1):E(an(o,"activate"),!1)};let st=(o,i)=>`${pt(o)||"goal"}-${Xo(i)}`.slice(0,128),oo=o=>{var l,u,f;let i=((l=o.textContent)!=null?l:"").replace(/\s+/g," ").trim();return i&&i.length<=60?i:((f=(u=o.getAttribute("aria-label"))!=null?u:o.getAttribute("id"))!=null?f:"").trim()||"element-clicked"},Tt=async(o,i,a)=>{E("Saving\u2026");let l=await ce(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);return l.r==="ok"&&(c("draft_saved",{kind:"goal"}),fr(o,a)),be(l,"\u2713 Goal saved. Click \u201CStart tracking\u201D below to go live."),l};Q.onclick=()=>{if(!t||!oe)return;let o=st(oo(t),JSON.stringify(oe));Tt(o,{event:"click",locator:oe},Ne(t))},N.onclick=()=>{var l,u;let o=t==null?void 0:t.closest("form");if(!o)return;let i=Xe(o,document),a=(u=(l=o.getAttribute("id"))!=null?l:o.getAttribute("name"))!=null?u:"form-submitted";Tt(st(a,JSON.stringify(i)),{event:"form_submit",locator:i},a)},re.onclick=()=>{let o=window.location.pathname||"/",i=pt(o)?`reached-${pt(o)}`:"page-visited";Tt(st(i,o),{event:"url_reached",urlPattern:o},o)};let cn=[{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}];ie.onclick=()=>{yt([{key:"depth",label:"Counts once a visitor reads",type:"select",options:cn.map(o=>o.label)}],"Track it",o=>{var l;let i=(l=cn.find(u=>u.label===o.depth))!=null?l:cn[2],a=Math.round(i.value*100);Tt(`read-${a}pct`,{event:"scroll_depth",threshold:i.value},`read ${a}%`),ae()})};let Kt=null,gr=o=>{Kt=o,q.style.display="block"};q.onclick=async()=>{if(!Kt)return;q.disabled=!0,E("Turning on\u2026");let o=await ce(e,`/v1/editor/funnels/${encodeURIComponent(Kt)}/publish`,{});q.disabled=!1,o.r==="ok"?(c("published",{kind:"funnel"}),E("\u2713 Funnel is on \u2014 the drop-off view fills in as visitors move through it.",!0),q.style.display="none",Kt=null):o.r==="expired"?E("Editor session expired \u2014 reopen it from your dashboard to turn the funnel on. Your draft is safe.",!1):E("\u26A0 Couldn\u2019t turn the funnel on \u2014 try again.",!1)},I.onclick=async()=>{var A;E("Loading your goals\u2026");let o=await ft(e,"/v1/editor/goals"),i=(A=o==null?void 0:o.goals)!=null?A:[];if(i.length<2){E("Track at least 2 goals first \u2014 a funnel is a sequence of them (e.g. \u201Cviewed pricing\u201D \u2192 \u201Csigned up\u201D).",!1);return}E("Pick the steps in order \u2014 first click = first step."),ae();let a=[],l=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},"Funnel name"),u=d("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});W.append(l,u);let f=d("div",{fontSize:"11px",opacity:"0.7",marginTop:"6px"},"Steps (click in journey order):");W.append(f);let y=new Map,p=()=>{var h,v;for(let[R,C]of y){let D=a.indexOf(R),G=(v=(h=i.find($=>$.goal_id===R))==null?void 0:h.display_name)!=null?v:R;C.textContent=D===-1?G:`${D+1}. ${G}`,C.style.background=D===-1?"#374151":"#6366f1"}};for(let h of i){let v=d("button",le(K({},F("#374151")),{textAlign:"left"}));y.set(h.goal_id,v),v.onclick=()=>{a=Fo(a,h.goal_id),p()},W.append(v)}p();let k=d("button",F("#6366f1"),"Save funnel"),T=d("button",le(K({},F("transparent")),{opacity:"0.6"}),"Cancel");T.onclick=ae,k.onclick=async()=>{let h=Wo(u.value,a);if(!h.ok){E(`\u26A0 ${h.error}`,!1);return}E("Saving\u2026");let v=await ce(e,`/v1/editor/funnels/${encodeURIComponent(h.funnelId)}`,h.body);v.r==="ok"&&(c("draft_saved",{kind:"funnel"}),ae(),gr(h.funnelId)),be(v,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},W.append(k,T)},P.onclick=async()=>{var p,k;let o=Ue;if(!o)return;E("Loading funnels\u2026");let i=await ft(e,"/v1/editor/funnels"),a=(p=i==null?void 0:i.funnels)!=null?p:[];if(a.length===0){E("No funnels yet \u2014 click \u201CSet up a funnel\u201D first.",!1);return}let l=await ft(e,"/v1/editor/goals"),u=new Map(((k=l==null?void 0:l.goals)!=null?k:[]).map(T=>[T.goal_id,T.display_name]));yt([{key:"funnel",label:"Funnel",type:"select",options:a.map(T=>Jt(T))},{key:"step",label:"Which step does this element serve?",type:"select",options:Xt(a[0],u).map(T=>T.label)}],"Attach",async T=>{var R;let A=(R=a.find(C=>Jt(C)===T.funnel))!=null?R:a[0],h=Xt(A,u).findIndex(C=>C.label===T.step);if(h<0){E("\u26A0 Pick which step this element serves.",!1);return}E("Attaching\u2026");let v=await ce(e,`/v1/editor/funnels/${encodeURIComponent(A.funnel_id)}/assign`,{slotId:o,stepIndex:h});v.r==="ok"&&ae(),be(v,`\u2713 Attached \u2014 this test now works toward \u201C${A.display_name}\u201D.`)});let f=W.querySelector('select[data-field="funnel"]'),y=W.querySelector('select[data-field="step"]');f&&y&&f.addEventListener("change",()=>{var A;let T=(A=a.find(h=>Jt(h)===f.value))!=null?A:a[0];y.length=1;for(let h of Xt(T,u)){let v=document.createElement("option");v.value=h.label,v.textContent=h.label,y.append(v)}})},X.onclick=()=>{if(!t||!oe)return;c("form_opened",{kind:"style"});let o=oe;yt([{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:An.length?`Font (this site has: ${An.slice(0,3).join(", ")})`:"Font (e.g. Georgia, serif)"},{key:"borderRadius",label:"Corner radius (e.g. 8px)"},{key:"textAlign",label:"Alignment",type:"select",options:["left","center","right","justify"]}],"Save draft",async(y,p)=>{var R;let{style:k,errors:T}=Mn(y),A=!1;for(let C of On)p(C,(R=T[C])!=null?R:null),T[C]&&(A=!0);if(A){E("\u26A0 Fix the highlighted field(s).",!1);return}if(Object.keys(k).length===0){E("\u26A0 Enter at least one style change.",!1);return}let h=Ce("style",o,t);E("Saving\u2026");let v=await ce(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:vt(o,y[bt]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:k}}]}});v.r==="ok"&&(c("draft_saved",{kind:"slot"}),Wn(),ae(),xt(h,Ne(t),"b")),be(v,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")},Ce("style",o,t));let i=t,a=i.style.cssText;Oe=()=>{i.style.cssText=a};let l={},u=()=>{let{style:y}=Mn(l);i.style.cssText=a;for(let[p,k]of Object.entries(y)){let T=At[p];T&&ct(k)&&i.style.setProperty(T,k.trim(),"important")}};for(let y of On){let p=W.querySelector(`[data-field="${y}"]`);if(!p)continue;let k=()=>{l[y]=p.value,u()};p.addEventListener("input",k),p.addEventListener("change",k)}let f=[Ze==null?void 0:Ze.primaryBg,Ze==null?void 0:Ze.primaryText,"#ffffff"].filter(y=>!!y).map($n).filter((y,p,k)=>Pn(y)&&k.indexOf(y)===p);for(let y of["color","background"]){let p=W.querySelector(`input[data-field="${y}"]`);if(!p)continue;let k=d("div",{display:"flex",gap:"6px",marginTop:"4px"});for(let T of f){let A=d("button",{width:"22px",height:"22px",borderRadius:"6px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.35)",background:T,padding:"0"});A.title=T,A.onclick=()=>{p.value=$n(T),p.dispatchEvent(new Event("input"))},k.append(A)}p.after(k)}};let We=[],Ct=new Map,dn=!1,fe=null,te=null,Lt=null,mr=()=>{Ct.clear();let o=[],i=(a,l,u)=>{var p;if(o.length>=16||[...Ct.values()].some(k=>k.node===a))return;let f=a===t,y=f?"selected":`e${o.length}`;Ct.set(y,{node:a,locator:l}),o.push(K(K({ref:y,tag:a.tagName.toLowerCase().slice(0,16),text:((p=a.textContent)!=null?p:"").replace(/\s+/g," ").trim().slice(0,300),isLeaf:bn(a),inForm:!!a.closest("form")},f?{selected:!0}:{}),u?{label:u.slice(0,120)}:{}))};t&&oe&&Me&&i(t,oe);for(let a of Bn){let l=we(a.locator,document);l&&i(l,a.locator,a.label)}return{pagePath:Nt(location.pathname),pageTitle:document.title.slice(0,200),elements:o}},qe=(o,i="")=>{let a=o==="user",l=d("div",{margin:"6px 0",padding:"7px 10px",borderRadius:"10px",fontSize:"12px",lineHeight:"1.45",whiteSpace:"pre-wrap",wordBreak:"break-word",maxWidth:"88%",marginLeft:a?"auto":"0",background:a?"#6366f1":o==="note"?"transparent":"rgba(255,255,255,0.07)",opacity:o==="note"?"0.75":"1"},i);return fe==null||fe.append(l),fe&&(fe.scrollTop=fe.scrollHeight),l},un=()=>{Lt&&(Lt.textContent=t?Me?`Looking at: ${Ne(t)}`:"This element can\u2019t be targeted reliably \u2014 pick a heading, button, or section.":"Nothing selected \u2014 click an element, or ask for a page goal.")},ro=(o,i)=>{var u;Ht();let a=vn(o),l=o.style.cssText;if(Oe=()=>{Ye(o,a),o.style.cssText=l},!!i){typeof i.text=="string"&&Ye(o,i.text);for(let[f,y]of Object.entries((u=i.style)!=null?u:{})){let p=At[f];p&&typeof y=="string"&&ct(y)&&o.style.setProperty(p,y.trim(),"important")}}},hr=async o=>{var R,C;let i=Ct.get(o.ref);if(!i||!i.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";let{node:a,locator:l}=i,u=o.versions.some(D=>typeof D.ops.text=="string"),f=Ce(u?"text":"style",l,a),y=Cn(location.pathname,rn[f])[0];E("Saving\u2026");let p=await ce(e,`/v1/editor/slots/${encodeURIComponent(f)}`,{kind:"arms",target:vt(l,y),draftConfig:{arms:[{id:"a",displayName:"Original",ops:u?{text:((R=a.textContent)!=null?R:"").trim()}:{}},...o.versions]}});if(be(p,"\u2713 Draft saved and previewing \u2014 nothing is live until you publish."),p.r!=="ok")return(C=Z.textContent)!=null?C:"\u26A0 Couldn\u2019t save the draft.";c("draft_saved",{kind:"slot",via:"chat"}),a!==t&&St(a),ae();let k=a;ro(k,o.versions[0].ops),ht=f;try{k.scrollIntoView({block:"center",behavior:"smooth"})}catch(D){}xt(f,o.label,o.versions[0].id);let T=qe("assistant");T.textContent="",T.append(d("div",{fontWeight:"600",marginBottom:"6px"},`Draft: ${o.label}`));let A=d("div",{display:"flex",gap:"5px",flexWrap:"wrap"}),h=[],v=(D,G)=>{for(let $ of h)$.style.background="#374151";D.style.background="#6366f1",ro(k,G),ht=f};for(let[D,G]of[["Original",null],...o.versions.map($=>[$.displayName,$.ops])]){let $=Le("#374151",D);$.onclick=()=>v($,G),h.push($),A.append($)}return h[1].style.background="#6366f1",T.append(A),`[Created draft "${o.label}" with ${o.versions.length} version(s)]`},yr=(o,i,a)=>{var y;let l=[],u={position:"absolute",pointerEvents:"none",zIndex:"2147483645",padding:"2px 6px",borderRadius:"4px",background:"#f59e0b",color:"#111827",font:"600 11px system-ui, sans-serif",whiteSpace:"nowrap"},f=null;if(o){let p=o.getBoundingClientRect();f=p.top+window.scrollY,l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:`${p.left+window.scrollX-3}px`,top:`${f-3}px`,width:`${p.width+6}px`,height:`${p.height+6}px`,border:"2px dashed #f59e0b",borderRadius:"6px"}),d("div",le(K({},u),{left:`${p.left+window.scrollX}px`,top:`${Math.max(0,f-24)}px`}),`Goal: ${a}`))}else i!==void 0&&(f=Math.round(document.documentElement.scrollHeight*i),l.push(d("div",{position:"absolute",pointerEvents:"none",zIndex:"2147483645",left:"0",right:"0",top:`${f}px`,borderTop:"2px dashed #f59e0b"}),d("div",le(K({},u),{left:"16px",top:`${f+4}px`}),`Goal counts here: ${a}`)));if(l.length!==0){if(((y=document.body)!=null?y:document.documentElement).append(...l),f!==null)try{window.scrollTo({top:Math.max(0,f-window.innerHeight/3),behavior:"smooth"})}catch(p){}setTimeout(()=>{for(let p of l)p.remove()},6e3)}},br=async o=>{var f,y,p,k,T,A;let i=null,a,l;if(o.event==="click"||o.event==="form_submit"){let h=o.ref?Ct.get(o.ref):void 0;if(!h||!h.node.isConnected)return"\u26A0 That element is no longer on the page \u2014 click it and ask again.";if(o.event==="click")i=h.node,a=st(oo(i),JSON.stringify(h.locator)),l={event:"click",locator:h.locator};else{let v=h.node.closest("form");if(!v)return"\u26A0 That element isn\u2019t inside a form.";let R=Xe(v,document);if(!ut(R,v,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";i=v,a=st((y=(f=v.getAttribute("id"))!=null?f:v.getAttribute("name"))!=null?y:"form-submitted",JSON.stringify(R)),l={event:"form_submit",locator:R}}}else if(o.event==="url_reached"){let h=(p=o.urlPattern)!=null?p:Nt(location.pathname);a=st(pt(h)?`reached-${pt(h)}`:"page-visited",h),l={event:"url_reached",urlPattern:h}}else a=`read-${Math.round(((k=o.threshold)!=null?k:.75)*100)}pct`,l={event:"scroll_depth",threshold:(T=o.threshold)!=null?T:.75};return(await Tt(a,le(K({},l),{displayName:o.displayName}),o.displayName)).r!=="ok"?(A=Z.textContent)!=null?A:"\u26A0 Couldn\u2019t save the goal.":(yr(i,o.event==="scroll_depth"?l.threshold:void 0,o.displayName),`[Created draft goal "${o.displayName}"]`)},io=async o=>{var k,T,A;let i=o.trim();if(!i||dn)return;dn=!0,te&&(te.value="",te.disabled=!0),qe("user",i),We.push({role:"user",content:i.slice(0,4e3)}),c("form_opened",{kind:"chat"});let a=qe("assistant","\u2026"),l="",u=!1,f=[],y=[],p=h=>{var R,C;if(h==="[DONE]")return;let v;try{v=JSON.parse(h)}catch(D){return}if(v.error){f.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(v.type==="delta"&&v.text)u&&l&&(l+=`
25
25
 
26
- `),c=!1,l+=v.text,a.textContent=l,fe&&(fe.scrollTop=fe.scrollHeight);else if(v.type==="tool_status")c=!0,v.state==="running"&&!l&&(a.textContent=(P=v.name)!=null&&P.startsWith("create_")?"Creating a draft\u2026":"Thinking\u2026");else if(v.type==="choice_prompt"&&v.question){l+=(l?`
26
+ `),u=!1,l+=v.text,a.textContent=l,fe&&(fe.scrollTop=fe.scrollHeight);else if(v.type==="tool_status")u=!0,v.state==="running"&&!l&&(a.textContent=(R=v.name)!=null&&R.startsWith("create_")?"Creating a draft\u2026":"Thinking\u2026");else if(v.type==="choice_prompt"&&v.question){l+=(l?`
27
27
 
28
- `:"")+v.question,a.textContent=l;let D=d("div",{display:"flex",gap:"5px",flexWrap:"wrap",marginTop:"6px"});for(let G of(T=v.options)!=null?T:[]){let $=Ie("#374151",G.label);$.onclick=()=>{Zn(G.label)},D.append($)}a.append(D)}else if(v.type==="artifact"&&v.artifact){let D=v.artifact.type==="editor_component_draft"?or(v.artifact.payload):v.artifact.type==="editor_goal_draft"?ir(v.artifact.payload):null;D&&y.push(D.then(G=>{p.push(G),G.startsWith("\u26A0")&&qe("note",G)}))}};try{let h=We.slice(-20);for(;((x=h[0])==null?void 0:x.role)==="assistant";)h=h.slice(1);let v=await fetch(`${e.apiBase}/v1/editor/chat`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({messages:h,context:nr()})});if(!v.ok){let $=(C=await v.json().catch(()=>null))==null?void 0:C.error;a.textContent=v.status===401?"Editor session expired \u2014 reopen it from your dashboard. Your drafts are safe.":$==="rate_limit"?"You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.":$==="plan_required"?"AI chat isn\u2019t included in this plan.":$==="ai_unavailable"?"The assistant is unavailable right now \u2014 try again later.":`\u26A0 Couldn\u2019t reach the assistant \u2014 try again. (HTTP ${v.status})`,We.pop();return}let P=(_=v.body)==null?void 0:_.getReader(),T="",D=()=>{let $;for(;($=T.indexOf(`
28
+ `:"")+v.question,a.textContent=l;let D=d("div",{display:"flex",gap:"5px",flexWrap:"wrap",marginTop:"6px"});for(let G of(C=v.options)!=null?C:[]){let $=Le("#374151",G.label);$.onclick=()=>{io(G.label)},D.append($)}a.append(D)}else if(v.type==="artifact"&&v.artifact){let D=v.artifact.type==="editor_component_draft"?hr(v.artifact.payload):v.artifact.type==="editor_goal_draft"?br(v.artifact.payload):null;D&&y.push(D.then(G=>{f.push(G),G.startsWith("\u26A0")&&qe("note",G)}))}};try{let h=We.slice(-20);for(;((k=h[0])==null?void 0:k.role)==="assistant";)h=h.slice(1);let v=await fetch(`${e.apiBase}/v1/editor/chat`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify({messages:h,context:mr()})});if(!v.ok){let $=(T=await v.json().catch(()=>null))==null?void 0:T.error;a.textContent=v.status===401?"Editor session expired \u2014 reopen it from your dashboard. Your drafts are safe.":$==="rate_limit"?"You\u2019ve used today\u2019s AI allowance \u2014 more tomorrow, or upgrade for a bigger daily budget.":$==="plan_required"?"AI chat isn\u2019t included in this plan.":$==="ai_unavailable"?"The assistant is unavailable right now \u2014 try again later.":`\u26A0 Couldn\u2019t reach the assistant \u2014 try again. (HTTP ${v.status})`,We.pop();return}let R=(A=v.body)==null?void 0:A.getReader(),C="",D=()=>{let $;for(;($=C.indexOf(`
29
29
 
30
- `))>=0;){for(let ge of T.slice(0,$).split(`
31
- `))ge.startsWith("data: ")&&f(ge.slice(6));T=T.slice($+2)}};if(P){let $=new TextDecoder;for(;;){let{done:ge,value:me}=await P.read();if(ge)break;T+=$.decode(me,{stream:!0}),D()}}else T=await v.text();T+=`
30
+ `))>=0;){for(let ge of C.slice(0,$).split(`
31
+ `))ge.startsWith("data: ")&&p(ge.slice(6));C=C.slice($+2)}};if(R){let $=new TextDecoder;for(;;){let{done:ge,value:me}=await R.read();if(ge)break;C+=$.decode(me,{stream:!0}),D()}}else C=await v.text();C+=`
32
32
 
33
- `,D(),await Promise.all(y),l||(a.textContent=p.some($=>$.startsWith("["))?"Done \u2014 have a look at the page.":"No reply \u2014 try rephrasing.");for(let $ of p)$.startsWith("\u26A0 The assistant")&&qe("note",$);let G=[l,...p.filter($=>$.startsWith("["))].filter(Boolean).join(`
34
- `);We.push({role:"assistant",content:(G||"(no reply)").slice(0,4e3)})}catch(h){a.textContent="\u26A0 Couldn\u2019t reach the assistant \u2014 check your connection and try again.",We.pop()}finally{an=!1,te&&(te.disabled=!1,te.focus())}},ar=()=>{if(fe){te==null||te.focus();return}let o=d("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.06)",border:"1px solid rgba(250,204,21,0.3)"});o.setAttribute("data-sentient-chat","");let i=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"}),a=xn("close","Close AI chat");if(a.onclick=()=>{Pt.textContent="",fe=null,te=null,Tt=null},i.append(d("div",{fontWeight:"600",flex:"1 1 auto"},"\u2728 AI"),a),Tt=d("div",{fontSize:"11px",opacity:"0.7",marginBottom:"4px"}),sn(),fe=d("div",{maxHeight:"260px",overflowY:"auto",overscrollBehavior:"contain"}),We.length===0)qe("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 p of We)qe(p.role,p.content);let l=d("div",{display:"flex",gap:"6px",marginTop:"6px"});te=d("input",{flex:"1 1 auto",minWidth:"0",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"}),te.type="text",te.maxLength=1e3,te.placeholder="What do you want to change or track?",te.setAttribute("data-field","ai-chat");let c=Ie("#6366f1","Send");c.setAttribute("data-action","ai-send"),c.onclick=()=>{te&&Zn(te.value)},te.onkeydown=p=>{var y;p.key==="Enter"&&(p.preventDefault(),(y=c.onclick)==null||y.call(c,new MouseEvent("click")))},l.append(te,c),o.append(i,Tt,fe,l),Pt.textContent="",Pt.append(o),te.focus()};Dn.onclick=()=>ar();let ln=o=>{if(!t)return;let i=t.parentElement;if(!i)return;Fe||(xt=i,Ht=t.nextSibling,Fe=!0),o==="up"&&nt?i.insertBefore(t,nt):o==="down"&&ot&&i.insertBefore(t,ot.nextSibling);let a=Jt(t,document);nt=a.prevEl,ot=a.nextEl,Ee=a.prevLocator,Ge=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}g(),nn(!0),E("Previewing the new position \u2014 keep moving, save, or undo.")};O.onclick=()=>ln("up"),q.onclick=()=>ln("down"),ze.onclick=()=>{wt(),E("Move undone \u2014 back to the original position.")},Se.onclick=async()=>{if(!t||!oe||!Fe||!Me)return;let o=Ee?"moveAfter":"moveBefore",i=Ee!=null?Ee:Ge;if(!i){E("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=Te("move",oe,t);E("Saving\u2026");let l=await de(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:bt(oe,Ce==null?void 0:Ce.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});l.r==="ok"&&(u("draft_saved",{kind:"move"}),Fe=!1,xt=null,Ht=null,nn(!1),vt(a,Re(t),"b")),be(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let sr=()=>{var o,i;u("editor_closed"),s(),window.removeEventListener("pagehide",s),r&&clearTimeout(r),wt(),Nt(),document.removeEventListener("mousemove",Fn,!0),document.removeEventListener("click",Vn,!0),document.removeEventListener("keydown",qn,!0),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),gt(document),(o=document.getElementById(wn))==null||o.remove(),m.remove(),w.remove(),b.remove(),Be.remove(),window.__sentientEditor=null,(i=document.querySelector("meta[data-sentient-editor]"))==null||i.remove(),$t()},dn=!1;Ae.onclick=()=>{if((tt||Fe)&&!dn){dn=!0,E("\u26A0 Unsaved changes \u2014 click \xD7 again to discard them.",!1);return}sr()},document.addEventListener("mousemove",Fn,!0),document.addEventListener("click",Vn,!0),document.addEventListener("keydown",qn,!0),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),Mt(),u("editor_opened")}var hi="http://www.w3.org/2000/svg";function Ze(e,t){let n=document.createElementNS(hi,e);for(let[r,s]of Object.entries(t))n.setAttribute(r,s);return n}function yi(e){let t=Ze("svg",{width:String(e),height:String(e),viewBox:"0 0 32 32",fill:"none","aria-hidden":"true"}),n={stroke:"#fff","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"};return t.append(Ze("path",U({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"},n)),Ze("path",U({d:"M10 22H17"},n)),Ze("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})),t}function xn(e,t){let n=d("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",width:"24px",height:"24px",margin:"0",padding:"0",borderRadius:"6px",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer"});n.setAttribute("aria-label",t),n.title=t;let r=Ze("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"}),s={stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"};return e==="minimize"?r.append(Ze("path",U({d:"M3 7h8"},s))):r.append(Ze("path",U({d:"M3.5 3.5l7 7M10.5 3.5l-7 7"},s))),n.append(r),n.onmouseenter=()=>{n.style.background="rgba(255,255,255,0.1)",n.style.color="#fff"},n.onmouseleave=()=>{n.style.background="transparent",n.style.color="#9ca3af"},n}function F(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 Xt="sentient-preview-bar";async function bi(e,t){var b,B,I,H,S,z,J,X,K,Y,ne,Z;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(R){}let n=null;try{let R=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});R.ok&&(n=(B=((b=(await R.json()).slots)!=null?b:[]).find(ie=>ie.slot_id===t&&ie.kind==="arms"))!=null?B:null)}catch(R){}let r=d("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});r.id=Xt;let s=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");s.onclick=()=>{$t();let R=new URL(location.href);for(let re of["sentient_editor","sentient_preview","sentient_arm"])R.searchParams.delete(re);location.assign(R.toString())};let u=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"#6366f1",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Back to editor");u.onclick=()=>{let R=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])R.searchParams.delete(re);location.assign(R.toString())};let m=(z=(S=(I=n==null?void 0:n.draft_config)==null?void 0:I.arms)!=null?S:(H=n==null?void 0:n.published_config)==null?void 0:H.arms)!=null?z:[];if(!n||m.length===0){r.append(d("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),u,s),((J=document.body)!=null?J:document.documentElement).append(r);return}let w=new URLSearchParams(location.search).get("sentient_arm"),g=(K=(X=m.find(R=>R.id===w))!=null?X:m[1])!=null?K:m[0];r.append(d("span",{fontWeight:"700"},`Previewing: ${(Y=n.display_name)!=null?Y:n.slot_id}`));let k=n.target&&typeof n.target=="object"?we(n.target,document):null;if(!k)r.append(d("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{Oo(k,g.ops,`preview-${n.slot_id}`,document);try{k.scrollIntoView({block:"center"})}catch(R){}for(let R of m){let re=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:R.id===g.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ne=R.displayName)!=null?ne:R.id);re.onclick=()=>{let ie=new URL(location.href);ie.searchParams.set("sentient_arm",R.id),location.assign(ie.toString())},r.append(re)}}r.append(u,s),((Z=document.body)!=null?Z:document.documentElement).append(r)}async function vi(e,t){var b,B,I,H;let n=t.lastIndexOf("~"),r=n>0?t.slice(0,n):t,s=n>0?t.slice(n+1):"",u=d("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});u.id=Xt;let m=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Exit preview");m.onclick=()=>{$t();let S=new URL(location.href);for(let z of["sentient_editor","sentient_preview_cell","sentient_refresh_region"])S.searchParams.delete(z);location.assign(S.toString())};let w=S=>{var z;u.append(d("span",{},S),m),((z=document.body)!=null?z:document.documentElement).append(u)},g=null;try{let S=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(r)}&persona=${encodeURIComponent(s)}`,{headers:{authorization:`Bearer ${e.token}`}});S.ok&&(g=await S.json())}catch(S){}if(!g)return w("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let k=g.target&&typeof g.target=="object"?we(g.target,document):null;if(!k)return w("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(g.edits!=null&&typeof g.skeletonFp=="string"&&Array.isArray(g.leafToNode)){if(Co(k,g.edits,{fp:g.skeletonFp,leafToNode:g.leafToNode})==="mismatch")return w("This part of the page changed since this version was written \u2014 regenerate it from your dashboard.")}else if(g.compose!=null||g.blocks!=null)g.vocabulary&&Array.isArray(g.vocabulary.entries)&&co(g.vocabulary),go(k,{preview:(b=g.compose)!=null?b:g.blocks},"preview",document);else if(typeof g.content=="string")k.textContent=g.content;else return w("Nothing to preview in that square yet.");try{k.scrollIntoView({block:"center"})}catch(S){}u.append(d("span",{fontWeight:"700"},`Previewing: ${(B=g.slotName)!=null?B:r}`),d("span",{opacity:"0.85"},`for ${(I=g.personaDisplay)!=null?I:s}${g.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),m),((H=document.body)!=null?H:document.documentElement).append(u)}async function No(e,t){var u;let n=await pt(e,"/v1/editor/slots"),r=((u=n==null?void 0:n.slots)!=null?u:[]).filter(m=>t?m.slot_id===t:m.region_skeleton_status==null),s=r.length===0&&t?"missing":"none";for(let m of r){let w=m.target&&typeof m.target=="object"?we(m.target,document):null;if(!w){t&&(s="missing");continue}let g=ko(w),k=g.skeleton?{slotId:m.slot_id,skeleton:g.skeleton}:{slotId:m.slot_id,status:g.reason};s=(await de(e,"/v1/editor/region-skeleton",k)).r==="ok"?"ok":"failed"}return s}async function Do(e){try{await de(e,"/v1/editor/style-vocabulary",Lo(document))}catch(t){}}async function xi(){if(typeof document=="undefined")return;let e=ii();if(!e)return;let t=await ai(e);if(!t.ok){t.unauthorized?($t(),vn(oi)):vn(ri);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(Xt)||await bi(e,n);return}let r=new URLSearchParams(location.search).get("sentient_preview_cell");if(r){document.getElementById(Xt)||await vi(e,r),Do(e);return}let s=new URLSearchParams(location.search).get("sentient_refresh_region");if(s){let w=await No(e,s);vn(w==="ok"?"Region refreshed \u2014 you can regenerate its versions now.":w==="missing"?"We couldn\u2019t find that part of the page here. It may live on another page.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.");return}if(document.getElementById(ft))return;Fo(e);let u=_o(document);Xe=u,u&&de(e,"/v1/editor/palette",u),Do(e),No(e).catch(()=>{});let m=await di(e);jo(m),Uo(m,document)}xi();return mr(wi);})();
33
+ `,D(),await Promise.all(y),l||(a.textContent=f.some($=>$.startsWith("["))?"Done \u2014 have a look at the page.":"No reply \u2014 try rephrasing.");for(let $ of f)$.startsWith("\u26A0 The assistant")&&qe("note",$);let G=[l,...f.filter($=>$.startsWith("["))].filter(Boolean).join(`
34
+ `);We.push({role:"assistant",content:(G||"(no reply)").slice(0,4e3)})}catch(h){a.textContent="\u26A0 Couldn\u2019t reach the assistant \u2014 check your connection and try again.",We.pop()}finally{dn=!1,te&&(te.disabled=!1,te.focus())}},vr=()=>{if(fe){te==null||te.focus();return}let o=d("div",{margin:"0 0 8px",padding:"9px 11px",borderRadius:"10px",background:"rgba(250,204,21,0.06)",border:"1px solid rgba(250,204,21,0.3)"});o.setAttribute("data-sentient-chat","");let i=d("div",{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"}),a=Ln("close","Close AI chat");if(a.onclick=()=>{Dt.textContent="",fe=null,te=null,Lt=null},i.append(d("div",{fontWeight:"600",flex:"1 1 auto"},"\u2728 AI"),a),Lt=d("div",{fontSize:"11px",opacity:"0.7",marginBottom:"4px"}),un(),fe=d("div",{maxHeight:"260px",overflowY:"auto",overscrollBehavior:"contain"}),We.length===0)qe("note","Tell me what to try \u2014 e.g. \u201Cmake this headline more urgent\u201D or \u201Ctrack clicks on the signup button\u201D. I\u2019ll create a draft and show it on the page. Nothing goes live until you publish.");else for(let f of We)qe(f.role,f.content);let l=d("div",{display:"flex",gap:"6px",marginTop:"6px"});te=d("input",{flex:"1 1 auto",minWidth:"0",boxSizing:"border-box",padding:"6px 8px",borderRadius:"7px",border:"1px solid rgba(255,255,255,0.18)",background:"rgba(0,0,0,0.25)",color:"#fff",font:"12px system-ui, sans-serif"}),te.type="text",te.maxLength=1e3,te.placeholder="What do you want to change or track?",te.setAttribute("data-field","ai-chat");let u=Le("#6366f1","Send");u.setAttribute("data-action","ai-send"),u.onclick=()=>{te&&io(te.value)},te.onkeydown=f=>{var y;f.key==="Enter"&&(f.preventDefault(),(y=u.onclick)==null||y.call(u,new MouseEvent("click")))},l.append(te,u),o.append(i,Lt,fe,l),Dt.textContent="",Dt.append(o),te.focus()};Fn.onclick=()=>vr();let pn=o=>{if(!t)return;let i=t.parentElement;if(!i)return;Fe||(wt=i,jt=t.nextSibling,Fe=!0),o==="up"&&ot?i.insertBefore(t,ot):o==="down"&&rt&&i.insertBefore(t,rt.nextSibling);let a=Qt(t,document);ot=a.prevEl,rt=a.nextEl,Ee=a.prevLocator,Ge=a.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(l){}g(),sn(!0),E("Previewing the new position \u2014 keep moving, save, or undo.")};O.onclick=()=>pn("up"),V.onclick=()=>pn("down"),ze.onclick=()=>{kt(),E("Move undone \u2014 back to the original position.")},Se.onclick=async()=>{if(!t||!oe||!Fe||!Me)return;let o=Ee?"moveAfter":"moveBefore",i=Ee!=null?Ee:Ge;if(!i){E("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let a=Ce("move",oe,t);E("Saving\u2026");let l=await ce(e,`/v1/editor/slots/${encodeURIComponent(a)}`,{kind:"arms",target:vt(oe,Te==null?void 0:Te.value()),draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});l.r==="ok"&&(c("draft_saved",{kind:"move"}),Fe=!1,wt=null,jt=null,sn(!1),xt(a,Ne(t),"b")),be(l,"\u2713 Saved as a draft. Click \u201CPublish\u201D below to go live.")};let xr=()=>{var o,i;c("editor_closed"),s(),window.removeEventListener("pagehide",s),r&&clearTimeout(r),kt(),Ht(),document.removeEventListener("mousemove",Zn,!0),document.removeEventListener("click",to,!0),document.removeEventListener("keydown",eo,!0),window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),mt(document),(o=document.getElementById(_n))==null||o.remove(),m.remove(),x.remove(),b.remove(),Be.remove(),window.__sentientEditor=null,(i=document.querySelector("meta[data-sentient-editor]"))==null||i.remove(),Mt()},fn=!1;Ie.onclick=()=>{if((nt||Fe)&&!fn){fn=!0,E("\u26A0 Unsaved changes \u2014 click \xD7 again to discard them.",!1);return}xr()},document.addEventListener("mousemove",Zn,!0),document.addEventListener("click",to,!0),document.addEventListener("keydown",eo,!0),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),Pt(),c("editor_opened")}var Ci="http://www.w3.org/2000/svg";function Qe(e,t){let n=document.createElementNS(Ci,e);for(let[r,s]of Object.entries(t))n.setAttribute(r,s);return n}function Li(e){let t=Qe("svg",{width:String(e),height:String(e),viewBox:"0 0 32 32",fill:"none","aria-hidden":"true"}),n={stroke:"#fff","stroke-width":"2.2","stroke-linecap":"round","stroke-linejoin":"round"};return t.append(Qe("path",K({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"},n)),Qe("path",K({d:"M10 22H17"},n)),Qe("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})),t}function Ln(e,t){let n=d("button",{display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",width:"24px",height:"24px",margin:"0",padding:"0",borderRadius:"6px",background:"transparent",border:"none",color:"#9ca3af",cursor:"pointer"});n.setAttribute("aria-label",t),n.title=t;let r=Qe("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"}),s={stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round"};return e==="minimize"?r.append(Qe("path",K({d:"M3 7h8"},s))):r.append(Qe("path",K({d:"M3.5 3.5l7 7M10.5 3.5l-7 7"},s))),n.append(r),n.onmouseenter=()=>{n.style.background="rgba(255,255,255,0.1)",n.style.color="#fff"},n.onmouseleave=()=>{n.style.background="transparent",n.style.color="#9ca3af"},n}function F(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 tn="sentient-preview-bar";async function _i(e,t){var b,B,L,H,S,z,J,Z,U,X,ne,Q;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(N){}let n=null;try{let N=await fetch(`${e.apiBase}/v1/editor/slots`,{headers:{authorization:`Bearer ${e.token}`}});N.ok&&(n=(B=((b=(await N.json()).slots)!=null?b:[]).find(ie=>ie.slot_id===t&&ie.kind==="arms"))!=null?B:null)}catch(N){}let r=d("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(99,102,241,0.55)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});r.id=tn;let s=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer",opacity:"0.7"},"Exit preview");s.onclick=()=>{Mt();let N=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])N.searchParams.delete(re);location.assign(N.toString())};let c=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"#6366f1",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Back to editor");c.onclick=()=>{let N=new URL(location.href);for(let re of["sentient_preview","sentient_arm"])N.searchParams.delete(re);location.assign(N.toString())};let m=(z=(S=(L=n==null?void 0:n.draft_config)==null?void 0:L.arms)!=null?S:(H=n==null?void 0:n.published_config)==null?void 0:H.arms)!=null?z:[];if(!n||m.length===0){r.append(d("span",{},"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),c,s),((J=document.body)!=null?J:document.documentElement).append(r);return}let x=new URLSearchParams(location.search).get("sentient_arm"),g=(U=(Z=m.find(N=>N.id===x))!=null?Z:m[1])!=null?U:m[0];r.append(d("span",{fontWeight:"700"},`Previewing: ${(X=n.display_name)!=null?X:n.slot_id}`));let w=n.target&&typeof n.target=="object"?we(n.target,document):null;if(!w)r.append(d("span",{opacity:"0.85"},"\u2014 we couldn\u2019t find this component on this page. It may live on another page, or the page changed."));else{yo(w,g.ops,`preview-${n.slot_id}`,document);try{w.scrollIntoView({block:"center"})}catch(N){}for(let N of m){let re=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",cursor:"pointer",background:N.id===g.id?"#6366f1":"transparent",color:"#fff",font:"12px system-ui, sans-serif"},(ne=N.displayName)!=null?ne:N.id);re.onclick=()=>{let ie=new URL(location.href);ie.searchParams.set("sentient_arm",N.id),location.assign(ie.toString())},r.append(re)}}r.append(c,s),((Q=document.body)!=null?Q:document.documentElement).append(r)}async function Ii(e,t){var b,B,L,H;let n=t.lastIndexOf("~"),r=n>0?t.slice(0,n):t,s=n>0?t.slice(n+1):"",c=d("div",{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",flexWrap:"wrap",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});c.id=tn;let m=d("button",{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"},"Exit preview");m.onclick=()=>{Mt();let S=new URL(location.href);for(let z of["sentient_preview_cell","sentient_refresh_region"])S.searchParams.delete(z);location.assign(S.toString())};let x=S=>{var z;c.append(d("span",{},S),m),((z=document.body)!=null?z:document.documentElement).append(c)},g=null;try{let S=await fetch(`${e.apiBase}/v1/editor/cell-preview?slotId=${encodeURIComponent(r)}&persona=${encodeURIComponent(s)}`,{headers:{authorization:`Bearer ${e.token}`}});S.ok&&(g=await S.json())}catch(S){}if(!g)return x("Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");let w=g.target&&typeof g.target=="object"?we(g.target,document):null;if(!w)return x("\u2014 we couldn\u2019t find this part of the page here. It may live on another page.");if(g.edits!=null&&typeof g.skeletonFp=="string"&&Array.isArray(g.leafToNode)){if(Po(w,g.edits,{fp:g.skeletonFp,leafToNode:g.leafToNode})==="mismatch")return x("This part of the page changed since this version was written \u2014 regenerate it from your dashboard.")}else if(g.compose!=null||g.blocks!=null)g.vocabulary&&Array.isArray(g.vocabulary.entries)&&wo(g.vocabulary),To(w,{preview:(b=g.compose)!=null?b:g.blocks},"preview",document);else if(typeof g.content=="string")w.textContent=g.content;else return x("Nothing to preview in that square yet.");try{w.scrollIntoView({block:"center"})}catch(S){}c.append(d("span",{fontWeight:"700"},`Previewing: ${(B=g.slotName)!=null?B:r}`),d("span",{opacity:"0.85"},`for ${(L=g.personaDisplay)!=null?L:s}${g.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),m),((H=document.body)!=null?H:document.documentElement).append(c)}async function Yo(e,t){var c;let n=await ft(e,"/v1/editor/slots"),r=((c=n==null?void 0:n.slots)!=null?c:[]).filter(m=>t?m.slot_id===t:m.region_skeleton_status==null),s=r.length===0&&t?"missing":"none";for(let m of r){let x=m.target&&typeof m.target=="object"?we(m.target,document):null;if(!x){t&&(s="missing");continue}let g=Oo(x),w=g.skeleton?{slotId:m.slot_id,skeleton:g.skeleton}:{slotId:m.slot_id,status:g.reason};s=(await ce(e,"/v1/editor/region-skeleton",w)).r==="ok"?"ok":"failed"}return s}async function Jo(e){try{await ce(e,"/v1/editor/style-vocabulary",Ho(document))}catch(t){}}async function Ai(){if(typeof document=="undefined")return;let e=mi();if(!e)return;if(e.code){let x=await Qo(e);if(x!==200){Zt(x===401?qo:Vo);return}}let t=await hi(e);if(!t.ok){t.unauthorized?(Mt(),Zt(qo)):Zt(Vo);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(tn)||await _i(e,n);return}let r=new URLSearchParams(location.search).get("sentient_preview_cell");if(r){document.getElementById(tn)||await Ii(e,r),Jo(e);return}let s=new URLSearchParams(location.search).get("sentient_refresh_region");if(s){let x=await Yo(e,s);Zt(x==="ok"?"Region refreshed \u2014 you can regenerate its versions now.":x==="missing"?"We couldn\u2019t find that part of the page here. It may live on another page.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.");return}if(document.getElementById(gt))return;rr(e);let c=Uo(document);Ze=c,c&&ce(e,"/v1/editor/palette",c),Jo(e),Yo(e).catch(()=>{});let m=await vi(e);er(m),tr(m,document)}Ai();return _r($i);})();
@@ -0,0 +1 @@
1
+ "use strict";var __sentientEngagement=(()=>{var V=Object.defineProperty;var ge=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var he=Object.prototype.hasOwnProperty;var ve=(e,t)=>()=>(e&&(t=e(e=0)),t);var ye=(e,t)=>{for(var n in t)V(e,n,{get:t[n],enumerable:!0})},we=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of me(t))!he.call(e,r)&&r!==n&&V(e,r,{get:()=>t[r],enumerable:!(a=ge(t,r))||a.enumerable});return e};var be=e=>we(V({},"__esModule",{value:!0}),e);var Ie,xe,_e,X,Ae,Ee,ee,$,te,Y=ve(()=>{"use strict";Ie=Object.defineProperty,xe=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,ee=(e,t,n)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$=(e,t)=>{for(var n in t||(t={}))Ae.call(t,n)&&ee(e,n,t[n]);if(X)for(var n of X(t))Ee.call(t,n)&&ee(e,n,t[n]);return e},te=(e,t)=>xe(e,_e(t))});var qe={};ye(qe,{startEngagementCapture:()=>pe});var Se=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function W(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function ke(e){return{tag:e.tagName.toLowerCase(),text:W(e).slice(0,40)}}function H(e){return e.replace(/["\\\]]/g,"\\$&")}function F(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function Z(e,t){var n;let a=e.tagName.toLowerCase();if(!a)return null;let r=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(u=>/^[a-zA-Z][\w-]*$/.test(u)),c=[a,...r.map(u=>`${a}.${u}`)];for(let u of c)if(F(t,u))return u;let i=e.parentElement;if(i&&i!==t){let u=Z(i,t);if(u){for(let m of c){let w=`${u} > ${m}`;if(F(t,w))return w}let d=Array.from(i.children).filter(m=>m.tagName.toLowerCase()===a),y=d.indexOf(e),S=d.some(m=>m!==e&&W(m)!==W(e));if(y>=0&&S){let m=`${u} > ${a}:nth-of-type(${y+1})`;if(F(t,m))return m}}}return null}function Q(e,t){let n=ke(e),a=e.getAttribute("id");if(a&&F(t,`#${H(a)}`))return{v:1,id:a,fingerprint:n};for(let c of Se){let i=e.getAttribute(c);if(i&&F(t,`[${c}="${H(i)}"]`))return{v:1,dataAttr:{name:c,value:i},fingerprint:n}}let r=Z(e,t);return r?{v:1,selector:r,fingerprint:n}:null}Y();var re=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Ce={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Oe(e){let t=e.ariaRole?Ce[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 $e(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Le=[["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]],J=[["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]],ne={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Me(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function oe(e){var t,n;let a=Oe(e);if(a)return{type:(t=ne[a])!=null?t:"generic",strength:"strong"};let r=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,u]of Le)if(u.test(r))return{type:i,strength:"strong"};for(let[i,u]of J)if(u.test(e.bodyText))return{type:i,strength:"strong"};let c=$e(e);return{type:(n=ne[c])!=null?n:"generic",strength:"weak"}}function le(e){var t,n;let a=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),r=e.getAttribute("role");return $({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Me(e),bodyText:a.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:a.length},r?{ariaRole:r}:{})}function ae(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}var He=1800*1e3;function ie(e,t,n,a){let r=[];{let c=!1,i=[],u=()=>{if(c)return;let d=Date.now();for(i.push(d);i.length>0&&d-i[0]>500;)i.shift();i.length>=3&&(c=!0,e("rage_click"))};t.addEventListener("click",u),r.push(()=>t.removeEventListener("click",u))}{let c=!1,i=u=>{if(c||!(u.target instanceof Node)||!t.contains(u.target)&&t!==u.target)return;c=!0;let d=typeof window!="undefined"?window.getSelection():null,y=d?d.toString().length:0;e("text_copy",{selectionLength:y})};document.addEventListener("copy",i),r.push(()=>document.removeEventListener("copy",i))}{let c=!1,i=!1,u=null,d=()=>{u!==null&&(clearTimeout(u),u=null)},y=()=>{c||!i||(d(),u=setTimeout(()=>{!c&&i&&(c=!0,e("scroll_hesitation"))},3e3))},S=()=>{d(),y()},m=_=>{for(let A of _)i=A.intersectionRatio>.3,i?y():d()},w=new IntersectionObserver(m,{threshold:[.3]});w.observe(t),window.addEventListener("scroll",S,{passive:!0}),r.push(()=>{w.disconnect(),window.removeEventListener("scroll",S),d()})}if((a==null?void 0:a.tabLoss)!==!1){let c=!1,i=n!=null?n:Date.now(),u=()=>{if(c||document.visibilityState!=="hidden")return;let d=Date.now()-i;d<15e3&&(c=!0,e("tab_loss",{timeOnPage:d}))};document.addEventListener("visibilitychange",u),r.push(()=>document.removeEventListener("visibilitychange",u))}return()=>{for(let c of r)c()}}function se(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}Y();var ue=[100,300,1e3,3e3,1e4],Pe=250,Te=1e3,Ne=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function ce(e,t){e.n++;let n=t-e.mean;e.mean+=n/e.n,e.m2+=n*(t-e.mean)}var de=e=>e.n>1?Math.sqrt(e.m2/e.n):0;function Ke(e){var t;try{let n=e.createElement("canvas"),a=n.getContext("webgl")||n.getContext("experimental-webgl");if(!a)return"unknown";let r=a.getExtension("WEBGL_debug_renderer_info"),c=r?String((t=a.getParameter(r.UNMASKED_RENDERER_WEBGL))!=null?t:""):"";return c?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(c)?"sw":"hw":"unknown"}catch(n){return"unknown"}}function De(e,t=Date.now){var n,a;let r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0,c={n:0,mean:0,m2:0},i={n:0,mean:0,m2:0},u=[0,0,0,0,0,0],d=0,y=0,S=0,m=0,w=0,_=0,A=0,T=0,N=0,h=0,q=-1/0,K=-1/0,k=null,L=null,D=null,R=(a=r==null?void 0:r.scrollY)!=null?a:0,z=0,v=e.hidden?null:t(),M=()=>{let l=t();if(D!=null){let g=l-D,I=0;for(;I<ue.length&&g>=ue[I];)I++;u[I]++}D=l},P=()=>{d++,q=t()},E=()=>{y++,K=t()},j=()=>{k=t()},C=()=>{k!=null&&(ce(c,t()-k),k=null)},U=()=>{let l=t();S++,l-q>Pe&&l-K>Te&&m++,M()},O=()=>{w++},b=()=>{var l;let g=(l=r==null?void 0:r.scrollY)!=null?l:0;_+=Math.abs(g-R),R=g,M()},G=l=>{let g=t();A++,(l.key==="Backspace"||l.key==="Delete")&&N++,Ne.has(l.key)&&h++,L!=null&&ce(i,g-L),L=g,M()},B=l=>{let g=l.data;typeof g=="string"&&(T+=g.length),M()},s=()=>{let l=t();e.hidden?v!=null&&(z+=l-v,v=null):v==null&&(v=l)},o={passive:!0,capture:!0};e.addEventListener("mousemove",P,o),e.addEventListener("touchstart",E,o),e.addEventListener("touchmove",O,o),e.addEventListener("mousedown",j,o),e.addEventListener("mouseup",C,o),e.addEventListener("click",U,o),e.addEventListener("wheel",O,o),e.addEventListener("keydown",G,o),e.addEventListener("input",B,o),e.addEventListener("visibilitychange",s),r==null||r.addEventListener("scroll",b,o);let f=Ke(e),p=(()=>{var l;try{return((l=r==null?void 0:r.matchMedia)==null?void 0:l.call(r,"(prefers-reduced-motion: reduce)").matches)===!0}catch(g){return!1}})();return{snapshot(){var l,g;let I=t(),x=z+(v!=null?I-v:0);return{v:1,active_ms:Math.round(x),mm:d,mm_rate:x>0?Number((d*1e3/x).toFixed(2)):0,touches:y,clicks:S,hold_n:c.n,hold_mean:Math.round(c.mean),hold_std:Math.round(de(c)),teleport:m,wheel:w,scroll_px:Math.round(_),keydowns:A,input_chars:T,ik_cv:i.mean>0?Number((de(i)/i.mean).toFixed(2)):0,backspaces:N,gaps:[...u],reduced_motion:p,kb_nav:h,renderer:f,vp:[(l=r==null?void 0:r.innerWidth)!=null?l:0,(g=r==null?void 0:r.innerHeight)!=null?g:0],dpr:(r==null?void 0:r.devicePixelRatio)||1}},stop(){e.removeEventListener("mousemove",P,o),e.removeEventListener("touchstart",E,o),e.removeEventListener("touchmove",O,o),e.removeEventListener("mousedown",j,o),e.removeEventListener("mouseup",C,o),e.removeEventListener("click",U,o),e.removeEventListener("wheel",O,o),e.removeEventListener("keydown",G,o),e.removeEventListener("input",B,o),e.removeEventListener("visibilitychange",s),r==null||r.removeEventListener("scroll",b,o)}}}var Re="section, header, footer, nav, main > div, [data-sentient-section]",je=2e4,Ue="__session__";function Be(e){let t=Array.from(e.querySelectorAll(Re)),n=t.filter(a=>t.filter(r=>r!==a&&a.contains(r)).length<2);return n.filter(a=>!n.some(r=>r!==a&&r.contains(a)))}function Fe(e,t,n,a){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:a})}).catch(()=>{})}catch(r){}}var fe=()=>{};function pe(e,t){var n,a,r,c,i,u,d,y,S,m,w,_,A,T,N;let h=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!h||typeof IntersectionObserver=="undefined"||se()||!t.apiKey||!t.apiKey.startsWith("pk_"))return fe;let q=((a=t.apiBase)!=null?a:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),K=Be(h);if(K.length===0)return fe;let k=new Map,L=[];for(let s of K){let o=(i=[(c=t.sectionTypes)==null?void 0:c[(r=s.getAttribute("data-sentient-id"))!=null?r:""],s.getAttribute("data-sentient-type")].find(x=>re.includes(x)))!=null?i:null,f=le(s),p=(d=o!=null?o:(u=t.typeOf)==null?void 0:u.call(t,s))!=null?d:oe(f).type,l=Q(s,h),g=l?`nc-${p}-${ae(JSON.stringify({id:(y=l.id)!=null?y:null,dataAttr:(S=l.dataAttr)!=null?S:null,selector:(m=l.selector)!=null?m:null})).toString(36)}`:`nc-${p}`;k.set(s,g);let I=J.filter(([,x])=>x.test(f.bodyText)).map(([x])=>x);L.push(te($({componentId:g,semanticType:p,source:o?"markup":"auto"},l?{locator:l}:{}),{observation:$($({tag:f.tag,idClass:f.idClass.slice(0,200),headingText:f.headingText,textLength:f.textLength,actionCount:f.actionCount},f.ariaRole?{ariaRole:f.ariaRole}:{}),I.length>0?{patternFlags:I}:{})}))}let D=(T=(A=(_=(w=h.defaultView)!=null?w:typeof window!="undefined"?window:void 0)==null?void 0:_.location)==null?void 0:A.pathname)!=null?T:"/";Fe(t.apiKey,q,D,L);let R=De(h),z=()=>{let s;try{s=R.snapshot()}catch(o){return}try{e.track({projectId:t.apiKey,componentId:Ue,eventType:"interaction_stats",payload:s})}catch(o){}},v=new Map,M=s=>{let o=v.get(s);return o||(o={ms:0,scroll:0,enterAt:null,intersecting:!1},v.set(s,o)),o},P=new IntersectionObserver(s=>{for(let o of s){let f=k.get(o.target);if(!f)continue;let p=M(f);o.isIntersecting?(p.intersecting=!0,p.enterAt=Date.now(),o.intersectionRatio>p.scroll&&(p.scroll=o.intersectionRatio)):(p.intersecting=!1,p.enterAt!=null&&(p.ms+=Date.now()-p.enterAt,p.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let s of k.keys())P.observe(s);let E=(s=!1)=>{var o;let f=Date.now();for(let[p,l]of v)if(l.enterAt!=null&&(l.ms+=f-l.enterAt,l.enterAt=null),!(l.ms<=0)){try{e.track({projectId:t.apiKey,componentId:p,eventType:"dwell",payload:{dwell_time:Math.round(l.ms),scroll_depth:Number(l.scroll.toFixed(2))}})}catch(g){}l.ms=0}if(z(),s)try{(o=e.flush)==null||o.call(e)}catch(p){}},j=()=>{if(h.hidden)E(!0);else{let s=Date.now();for(let o of v.values())o.intersecting&&(o.enterAt=s)}},C=!1,U=s=>{if(E(!0),s!=null&&s.persisted){C=!0;return}try{P.disconnect()}catch(o){}},O=s=>{if(!(s!=null&&s.persisted)||!C)return;C=!1;let o=Date.now();for(let f of v.values())f.enterAt=f.intersecting&&!h.hidden?o:null};h.addEventListener("visibilitychange",j);let b=(N=h.defaultView)!=null?N:typeof window!="undefined"?window:void 0;b==null||b.addEventListener("pagehide",U),b==null||b.addEventListener("pageshow",O);let G=setInterval(()=>{if(h.hidden||C)return;E();let s=Date.now();for(let o of v.values())o.intersecting&&(o.enterAt=s)},je),B=[];return t.microSignals&&[...k.entries()].forEach(([s,o],f)=>{B.push(ie((p,l={})=>{try{e.track({projectId:t.apiKey,componentId:o,eventType:"micro_signal",payload:$({signalType:p},l)})}catch(g){}},s,void 0,{tabLoss:f===0}))}),()=>{E(!0),clearInterval(G),R.stop(),h.removeEventListener("visibilitychange",j),b==null||b.removeEventListener("pagehide",U),b==null||b.removeEventListener("pageshow",O);for(let s of B)s();try{P.disconnect()}catch(s){}}}return be(qe);})();