@sentientui/snippet 0.30.3 → 0.31.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.
- package/dist/editor.global.js +8 -8
- package/dist/snippet.global.js +2 -2
- package/package.json +2 -2
package/dist/editor.global.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var 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,vr,ro,br,xr,io,ce,st,un=pr(()=>{"use strict";hr=Object.defineProperty,yr=Object.defineProperties,vr=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,br=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={}))br.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,vr(t))});var bi={};fr(bi,{buildStyleOps:()=>In,clearTargetHighlights:()=>gt,computeMoveAnchors:()=>Jt,deriveSlotId:()=>Te,drawTargetHighlights:()=>Uo,isHex6:()=>An,mount:()=>Fo,registerAuditTargets:()=>jo,sectionTypesFor:()=>Ko,styleFieldError:()=>Go,toHexColor:()=>En});var ki=56*1024;var Si=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",O=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"?O!=null&&O.muted?{color:O.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:O==null?void 0:O.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,v,M,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 B=e;he(A,{display:"flex","flex-direction":B.direction,gap:(r=lt[(n=B.gap)!=null?n:"md"])!=null?r:lt.md,"align-items":B.align?gn[B.align]:void 0,"justify-content":B.justify?gn[B.justify]:void 0,"flex-wrap":B.wrap?"wrap":void 0})}else{let B=e,q=(u=lt[(s=B.gap)!=null?s:"md"])!=null?u:lt.md;he(A,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${B.columns-1} * ${q}) / ${B.columns})), 1fr))`,gap:q,"align-items":B.align?gn[B.align]:void 0})}R&&(A.className=R);let D=!R&&e.type==="stack"&&e.surface==="raised",Q=(m=e.pad)!=null?m:D?"md":void 0;Q&&he(A,{padding:(w=lt[Q])!=null?w:lt.md}),D&&he(A,{background:O==null?void 0:O.surface,color:O!=null&&O.surface?O==null?void 0:O.surfaceText:void 0,border:`1px solid ${(g=O==null?void 0:O.border)!=null?g:"currentColor"}`,"border-radius":(k=O==null?void 0:O.radius)!=null?k:"8px"});for(let B of(v=e.children)!=null?v:[]){let q=fo(B,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[(M=e.size)!=null?M:"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 D=(I=e.emphasis)!=null?I:"primary";return he(A,{display:"inline-block",padding:Tr[(H=e.size)!=null?H:"md"],"border-radius":(S=O==null?void 0:O.radius)!=null?S:"8px",font:"inherit","font-size":e.size?ao[e.size]:void 0,"text-decoration":D==="ghost"?"underline":"none",cursor:"pointer",background:D==="primary"?(z=O==null?void 0:O.primaryBg)!=null?z:"#111827":"transparent",color:D==="primary"?(J=O==null?void 0:O.primaryText)!=null?J:"#ffffff":(X=O==null?void 0:O.accent)!=null?X:"inherit",border:D==="secondary"?`1px solid ${(K=O==null?void 0:O.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=O==null?void 0:O.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=O==null?void 0:O.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 v="tree"in k?k:null,M=fo(v?v.tree:k,r);if(!M)continue;let I=r.createElement("div");I.setAttribute(fn,g),I.style.display="none";let H=v?uo((s=v.surface)==null?void 0:s.like):void 0;if(H){let S=r.createElement("div");S.className=H;let z=po((u=v.surface)==null?void 0:u.like);z&&(S.style.color=z),S.appendChild(M),I.appendChild(S)}else I.appendChild(M);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),v=g;k!==null?v.style.display=w&&k===n?"":"none":w?v.hasAttribute(Lt)||(v.setAttribute(Lt,v.style.display),v.style.display="none"):v.hasAttribute(Lt)&&(v.style.display=v.getAttribute(Lt),v.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 vo(e){let t=e.join("");return mo(t,2166136261)+mo(t,1523705862)}var Or=new Set(["A","BUTTON"]),bo=/^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(bo.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 v=u.nextNode();v;v=u.nextNode())if(((n=v.nodeValue)!=null?n:"").trim()!==""&&!Pr.has((s=(r=v.parentElement)==null?void 0:r.tagName)!=null?s:"")&&(m.push(v),m.length>120))return{reason:"too_large"};if(m.length===0)return{reason:"empty"};let w=[],g=[];for(let v of m){let M=Dr(v,e),I=w.indexOf(M);I===-1&&(w.push(M),I=w.length-1),g.push(I)}if(w.length>t)return{reason:"too_large"};let k=m.map(v=>{var M;return yo((M=v.nodeValue)!=null?M:"")});return{textNodes:m,ownerEls:w,leafToNode:g,leaves:k,fp:vo(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,v=[],M=u.map((S,z)=>{var J,X;let K=k==null?void 0:k.getComputedStyle(S),Y=(J=S.parentElement)!=null?J:e,ne=v.indexOf(Y);ne===-1&&(v.push(Y),ne=v.length-1);let Z=bo.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:M,leaves:w,leafToNode:m,fp:vo(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 v;return(v=k.getAttribute("class"))!=null?v:""})},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 v=Number(g),M=s.ownerEls[v];if(M){if(typeof k.text=="string"){let I=!0;s.leafToNode.forEach((H,S)=>{H===v&&(s.textNodes[S].nodeValue=I?k.text:"",I=!1)})}k.like!==void 0&&s.classes[k.like]!==void 0&&M.setAttribute("class",s.classes[k.like]),k.hidden&&((u=M.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),v=(w=k[0])==null?void 0:w.parentElement;if(!v||k.length!==g.length||k.some(S=>S.parentElement!==v))continue;let M=new Set(k),I=0;Array.from(v.children).map(S=>M.has(S)?k[I++]:S).forEach((S,z)=>{var J;v.children[z]!==S&&v.insertBefore(S,(J=v.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}}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 Kr(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),v=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 M=e.nextElementSibling;if(Gt(e)&&u<=.9*n.bodySize&&(t.textTransform==="uppercase"||Ne(t.letterSpacing)>.05*u)&&M!==null&&/^H[1-4]$/.test(M.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&&!(v>0&&v>=.9*n.vw)?"card":/^(SECTION|DIV|HEADER|MAIN|ASIDE)$/.test(s)&&(w||g)&&e.querySelector("h1,h2,h3")!==null&&(v===0||v>=.9*n.vw)?"section":null}function Lo(e,t){var n,r,s,u,m,w,g,k,v;let M=e.defaultView;if(!M||!e.body)return{entries:[],images:[]};_t=e;let I=M.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:M,vw:M.innerWidth||0},X=(s=(r=M.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 D of R)try{if(D.tagName==="IMG"){let ee=D,_e=((m=ee.getAttribute("alt"))!=null?m:"").trim(),V=ee.naturalWidth||Number(ee.getAttribute("width"))||0,Qe=ee.naturalHeight||Number(ee.getAttribute("height"))||0,be=ee.getAttribute("src");if(_e&&V>=200&&be){let $e=new URL(be,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=D.getAttribute("class"))!=null?w:"").replace(/\s+/g," ").trim();if(Q==="")continue;let B=M.getComputedStyle(D),q=D.tagName==="IMG"?((g=D.getAttribute("alt"))!=null?g:"").trim()?"image":null:Kr(D,B,J);if(!q)continue;let Se=`${q}|${Q}`,ze=D.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(B.backgroundImage).map(De).filter(ee=>ee!==null),ue,je;if(Wt(B.backgroundColor))ue=ke(B.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=B.borderTopLeftRadius||B.borderRadius;Y.set(Se,{id:q,role:q,classes:Q,computed:ce(ce(ce(ce(ce(ce(ce({},ke(B.color,e)?{color:ke(B.color,e)}:{}),D.parentElement&&M.getComputedStyle(D.parentElement).color===B.color?{inheritsColor:!0}:{}),ue?{bg:ue}:{}),je?{bgDark:je}:{}),B.fontSize?{fontSize:B.fontSize}:{}),B.fontWeight?{fontWeight:B.fontWeight}:{}),pe&&Ne(pe)>0?{radius:pe}:{}),seen:{url:X,count:1,at:K}})}catch(Q){}let re=new Map;for(let D of Y.values())re.set(D.role,[...(v=re.get(D.role))!=null?v:[],D]);let ie=[],A=D=>{var Q;return(Q=ne.get(`${D.role}|${D.classes}`))!=null?Q:0};for(let[D,Q]of re)Q.sort((B,q)=>(D.startsWith("button-")?A(q)-A(B):0)||q.seen.count-B.seen.count).slice(0,jr).forEach((B,q)=>ie.push(st(ce({},B),{id:q===0?D:`${D}-${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 Gr(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=Gr(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 Fr="__snt_editor_token";function $t(){try{sessionStorage.removeItem(Fr)}catch(e){}}var Wr=/rgba\([^)]*,\s*0\s*\)$/,qr=/^\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||Wr.test(z))continue;let J=(t=(S.borderRadius||"").split(" ")[0])!=null?t:"",X=`${z}|${S.color}|${qr.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,v,M]=w.split("|");return{primaryBg:k,primaryText:v,radius:M}}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"},Vr=/^(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(!Vr.test((r=n[1])!=null?r:""))return!1;return!0}var $o=/^https:\/\//i,Bo=new Map,He=null;function Jr(e){return e.replace(/["\\]/g,"\\$&")}function Yr(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="${Jr(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
|
|
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=`
|
|
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); }
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
@media (prefers-reduced-motion: reduce) {
|
|
22
22
|
#${ft}, #${ft} .sntedi-dot, #${Yt} { animation: none !important; }
|
|
23
23
|
}
|
|
24
|
-
`,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function bn(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 oi(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function ri(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 ii(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 ai(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 si(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>=ei)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 li=/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"],di=/^(0|\d*\.?\d+(px|rem|em|%|vh|vw|vmin|vmax|ch|pt))$/i,ci=new Set(["left","center","right","justify","start","end"]),ui=/^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,pi=/^(rgb|rgba|hsl|hsla)\(/i;function fi(e){return ui.test(e)||pi.test(e)}function Go(e,t){switch(e){case"fontSize":case"borderRadius":return di.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 ci.has(t.toLowerCase())?null:"Choose left, center, right, or justify.";case"color":case"background":return fi(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=Zr;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=Qr;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 v=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"});v.id=ft;let M=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});M.className="sntedi-dot";let I=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});I.append(M,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"),D=d("button",F("#374151"),"Attach this test to a funnel step"),Q=d("button",F("#10b981"),"Turn the funnel on"),B=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,B,q])o.disabled=!0;let je=[K,Y,ne,Z,R,B,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",D.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,be=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),be.set(o.id,a),$n.append(a)}be.get("text").append(K),be.get("style").append(Y),be.get("layout").append(ne,B,q,Se,ze),be.get("goals").append(Z,R,re,ie),be.get("funnels").append(A,D,Q);let xe=d("div",{});be.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",be.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 ii(e,o);l.disabled=!1,ve(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,b,P,T,N,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=(b=(h=(C=L.draft_config)==null?void 0:C.arms)!=null?h:(_=L.published_config)==null?void 0:_.arms)!=null?b:[],Le=(N=(P=se[1])==null?void 0:P.id)!=null?N:(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,ve(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,ve(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(mi(26)),Be.title="Open the SentientUI editor",Be.setAttribute("aria-label","Open the SentientUI editor");let Pn=xn("minimize","Minimize");Pn.onclick=()=>{v.style.display="none",Be.style.display="flex",Rn=S,S=!0,m.style.display="none",gt(document)},Be.onclick=()=>{v.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}),v.append(Mn,H,Zt,pe,ee,Pt,_n,$n,W,Nn),((Qn=document.body)!=null?Qn:document.documentElement).append(m,w,v,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 b=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},h.label);if(W.append(b),h.type==="select"){let T=d("select",y);T.setAttribute("data-field",h.key);let N=document.createElement("option");N.value="",N.textContent="\u2014 no change \u2014",T.append(N);for(let 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 N=!1;T.addEventListener("input",()=>{N=!0}),c[h.key]=()=>N?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,b)=>{let P=p[h];P&&(P.textContent=b!=null?b:"",P.style.display=b?"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,b])=>[h,b()])),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 vn(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}},vt=(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}`},ve=(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",D.style.display="none",Ue.textContent="")},Un=o=>{it===o&&(it=null,ue.style.display="none",Ue.textContent="")},bt=(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",D.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=()=>{B.disabled=!Me||!Ee,q.disabled=!Me||!Ge,B.title=B.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||v.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"?B: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||v.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:vt(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(),bt(_,Re(t),"b")),ve(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&&li.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,b,P,T,N,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(b=(h=i.links[1])==null?void 0:h.href)!=null?b:"";case"quote":case"q1":return(P=i.quotes[0])!=null?P:"";case"q2":return(T=i.quotes[1])!=null?T:"";case"q3":return(N=i.quotes[2])!=null?N:"";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 N=c,{[yt]:x}=N,C=oo(N,[no(yt)]),_=await ai(e,`/v1/editor/arrangements/${encodeURIComponent(o.id)}/instantiate`,{fields:C});if(_.r!=="ok"||!((G=_.data)!=null&&G.blocks)){_.r==="expired"?ve(_.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),b=await de(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:vt(i,x),draftConfig:{arms:[{id:"original",displayName:"Your page today"},{id:o.id,displayName:o.name,blocks:_.data.blocks}],baseline:"original"}});b.r==="ok"&&(u("draft_saved",{kind:"arrangement"}),ae(),bt(h,o.name,o.id)),ve(b,"\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)),ve(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,b;for(let[P,T]of y){let N=a.indexOf(P),G=(b=(h=i.find($=>$.goal_id===P))==null?void 0:h.display_name)!=null?b:P;T.textContent=N===-1?G:`${N+1}. ${G}`,T.style.background=N===-1?"#374151":"#6366f1"}};for(let h of i){let b=d("button",le(U({},F("#374151")),{textAlign:"left"}));y.set(h.goal_id,b),b.onclick=()=>{a=Ro(a,h.goal_id),f()},W.append(b)}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 b=await de(e,`/v1/editor/funnels/${encodeURIComponent(h.funnelId)}`,h.body);b.r==="ok"&&(u("draft_saved",{kind:"funnel"}),ae(),tr(h.funnelId)),ve(b,"\u2713 Funnel saved as a draft. Click \u201CTurn the funnel on\u201D to start measuring.")},W.append(x,C)},D.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 b=await de(e,`/v1/editor/funnels/${encodeURIComponent(_.funnel_id)}/assign`,{slotId:o,stepIndex:h});b.r==="ok"&&ae(),ve(b,`\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 b=document.createElement("option");b.value=h.label,b.textContent=h.label,y.append(b)}})},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 b=await de(e,`/v1/editor/slots/${encodeURIComponent(h)}`,{kind:"arms",target:vt(o,y[yt]),draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:x}}]}});b.r==="ok"&&(u("draft_saved",{kind:"slot"}),Hn(),ae(),bt(h,Re(t),"b")),ve(b,"\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(N=>typeof N.ops.text=="string"),p=Te(c?"text":"style",l,a),y=vn(location.pathname,en[p])[0];E("Saving\u2026");let f=await de(e,`/v1/editor/slots/${encodeURIComponent(p)}`,{kind:"arms",target:vt(l,y),draftConfig:{arms:[{id:"a",displayName:"Original",ops:c?{text:((P=a.textContent)!=null?P:"").trim()}:{}},...o.versions]}});if(ve(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(N){}bt(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=[],b=(N,G)=>{for(let $ of h)$.style.background="#374151";N.style.background="#6366f1",Xn(x,G),mt=p};for(let[N,G]of[["Original",null],...o.versions.map($=>[$.displayName,$.ops])]){let $=Ie("#374151",N);$.onclick=()=>b($,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 b=h.node.closest("form");if(!b)return"\u26A0 That element isn\u2019t inside a form.";let P=Ye(b,document);if(!dt(P,b,document))return"\u26A0 This form can\u2019t be targeted reliably, so it can\u2019t be tracked.";i=b,a=at((y=(p=b.getAttribute("id"))!=null?p:b.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 b;try{b=JSON.parse(h)}catch(N){return}if(b.error){p.push("\u26A0 The assistant hit a problem \u2014 try again.");return}if(b.type==="delta"&&b.text)c&&l&&(l+=`
|
|
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+=`
|
|
25
25
|
|
|
26
|
-
`),c=!1,l+=
|
|
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?`
|
|
27
27
|
|
|
28
|
-
`:"")+
|
|
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(`
|
|
29
29
|
|
|
30
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}),
|
|
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+=`
|
|
32
32
|
|
|
33
|
-
`,
|
|
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.")};B.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:vt(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),bt(a,Re(t),"b")),ve(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(),v.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 gi="http://www.w3.org/2000/svg";function Ze(e,t){let n=document.createElementNS(gi,e);for(let[r,s]of Object.entries(t))n.setAttribute(r,s);return n}function mi(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 hi(e,t){var v,M,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=(M=((v=(await R.json()).slots)!=null?v:[]).find(ie=>ie.slot_id===t&&ie.kind==="arms"))!=null?M: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 yi(e,t){var v,M,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:(v=g.compose)!=null?v: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: ${(M=g.slotName)!=null?M: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 vi(){if(typeof document=="undefined")return;let e=oi();if(!e)return;let t=await ri(e);if(!t.ok){t.unauthorized?($t(),bn(ti)):bn(ni);return}let n=new URLSearchParams(location.search).get("sentient_preview");if(n){document.getElementById(Xt)||await hi(e,n);return}let r=new URLSearchParams(location.search).get("sentient_preview_cell");if(r){document.getElementById(Xt)||await yi(e,r),Do(e);return}let s=new URLSearchParams(location.search).get("sentient_refresh_region");if(s){let w=await No(e,s);bn(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 si(e);jo(m),Uo(m,document)}vi();return mr(bi);})();
|
|
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);})();
|
package/dist/snippet.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var SentientSnippet=(()=>{var Et=Object.defineProperty,vo=Object.defineProperties,bo=Object.getOwnPropertyDescriptor,wo=Object.getOwnPropertyDescriptors,So=Object.getOwnPropertyNames,On=Object.getOwnPropertySymbols;var Ln=Object.prototype.hasOwnProperty,Eo=Object.prototype.propertyIsEnumerable;var In=(e,t,n)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||(t={}))Ln.call(t,n)&&In(e,n,t[n]);if(On)for(var n of On(t))Eo.call(t,n)&&In(e,n,t[n]);return e},Te=(e,t)=>vo(e,wo(t));var Tn=(e,t)=>()=>(e&&(t=e(e=0)),t);var Rn=(e,t)=>{for(var n in t)Et(e,n,{get:t[n],enumerable:!0})},Ao=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of So(t))!Ln.call(e,o)&&o!==n&&Et(e,o,{get:()=>t[o],enumerable:!(r=bo(t,o))||r.enumerable});return e};var xo=e=>Ao(Et({},"__esModule",{value:!0}),e);var ko,Co,_o,Pn,Oo,Io,Dn,B,Re,nt=Tn(()=>{"use strict";ko=Object.defineProperty,Co=Object.defineProperties,_o=Object.getOwnPropertyDescriptors,Pn=Object.getOwnPropertySymbols,Oo=Object.prototype.hasOwnProperty,Io=Object.prototype.propertyIsEnumerable,Dn=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,B=(e,t)=>{for(var n in t||(t={}))Oo.call(t,n)&&Dn(e,n,t[n]);if(Pn)for(var n of Pn(t))Io.call(t,n)&&Dn(e,n,t[n]);return e},Re=(e,t)=>Co(e,_o(t))});var Hn={};Rn(Hn,{LOCAL_ENGINE_AVAILABLE:()=>Do,createLocalEngine:()=>No});function No(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Do,Wn=Tn(()=>{"use strict";Do=!1});var bs={};Rn(bs,{applyPersonaAttributes:()=>Mt,applyRegistrySlots:()=>Kt,applySlotArms:()=>Bt,applySlotAttributes:()=>$t,parseEditorToken:()=>co,parsePersonaPreview:()=>mo,parsePreview:()=>po,parseSnippetConfig:()=>Rt,planReorder:()=>Gt,reapply:()=>yt,run:()=>go,version:()=>pt});nt();function At(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function Nn(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function Zt(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return At(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[l,i]of Object.entries((n=e.dims)!=null?n:{}))o[l]=(r=i[0])!=null?r:"";return At(o)}function Mn(e,t){var n,r;return e.dims!=null?(r=(n=Nn(t))!=null?n:Nn(Zt(e)))!=null?r:{}:t}function $n(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t}function $e(e){return e>=.3?e<.7?"medium":"high":"low"}function xt(e){return e?`_${e.slice(0,12)}`:""}var Lo="_snt_uid";function Bn(e){return`${Lo}${xt(e)}`}var To=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function Kn(e){return Ro(e)!==null}function Ro(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=To.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function jn(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Un(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Gn(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var Po=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function Fn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,l])=>{let i=Array.isArray(l)?l[0]:l;return i===void 0?[]:[[o,i]]});for(let[o,l]of r)o.startsWith("utm_")?o in t||(t[o]=l):Po.includes(o)&&(o in n||(n[o]=l))}catch(r){}return{utmParams:t,clickIds:n}}function zn(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Qt(e){return B(B(B({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function en(e){let t=Qt(e);return Mn(t,Zt(t))}function Vn(e){return typeof e=="string"?e:At(e)}nt();function Qn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Mo="_snt_uid",$o=365,kt="_snt_uid";function Bo(){return Qn()}function qn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Ko(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function tn(e){try{return localStorage.getItem(e)}catch(t){return null}}function Jn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Yn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function jo(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Uo(e){try{sessionStorage.removeItem(e)}catch(t){}}function Go(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function Fo(e){try{localStorage.removeItem(e)}catch(t){}}function zo(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var Vo={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function er(e){var t,n,r,o,l,i,s;if(typeof window=="undefined")return Vo;let c=xt(e==null?void 0:e.apiKey),u=(t=e==null?void 0:e.cookieName)!=null?t:Bn(e==null?void 0:e.apiKey),a=`${kt}${c}`,d=`${kt}_tomb${c}`,h=((n=e==null?void 0:e.cookieTTLDays)!=null?n:$o)*24*60*60,C=b=>b&&b.length>0?b:null,f=()=>{var b,g;return c&&!(e!=null&&e.cookieName)&&tn(d)===null?(g=(b=C(qn(Mo)))!=null?b:C(tn(kt)))!=null?g:C(Yn(kt)):null},m=(s=(i=(l=(o=(r=C(qn(u)))!=null?r:C(tn(a)))!=null?o:C(Yn(a)))!=null?l:f())!=null?i:C(e==null?void 0:e.ssrSessionId))!=null?s:Bo();Ko(u,m,h);let A=Jn(a,m),y=Go(u),E=A?!1:jo(a,m),w=!A&&!y&&!E;return{getSessionId:()=>m,isEphemeral:()=>w,destroy:()=>{m=null,zo(u),Fo(a),Uo(a),c&&!(e!=null&&e.cookieName)&&Jn(d,"1")}}}function Fe(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ln(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function tr(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function ze(e,t,n){try{let r=(()=>{try{let l=localStorage.getItem(n);if(!l)return[];let i=JSON.parse(l);return Array.isArray(i)?i:[]}catch(l){return[]}})(),o=new Map;for(let l of r)o.set(l.id,l);for(let l of e)o.set(l.id,l);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function nr(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),l=r.filter(i=>!o.has(i.id));if(l.length===r.length)return;l.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(l))}catch(n){}}var Ho=500,Wo=56*1024;function rr(e){return`_snt_retry_${e.slice(0,12)}`}var qo={push:()=>{},flush:()=>{},destroy:()=>{}};function Jo(e){var t,n,r;if(typeof window=="undefined")return qo;let o=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,c=e.apiKey,u=rr(c),a=[],d=new Set,h=[],C=x=>{for(let N of x)f.delete(N),!d.has(N)&&(d.add(N),h.push(N));for(;h.length>Ho;){let N=h.shift();N&&d.delete(N)}nr(x,u)},f=new Set,m=()=>{for(;a.length>i;){let x=a.shift();x&&f.delete(x.id)}},A=x=>{d.has(x.id)||f.has(x.id)||(f.add(x.id),a.push(x),m())},y=x=>{for(let N of x)d.has(N.id)||(f.add(N.id),a.push(N));m()},E=tr(u,i);for(let x of E)A(x);let w=0,b=0,g=(x,N=!0)=>{if(x.length===0)return;let X=JSON.stringify(x),Y=x.map(L=>L.id),ie;try{ie=fetch(s,{method:"POST",keepalive:!0,body:X,headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`}})}catch(L){ze(x,i,u),y(x),b++,w=Date.now()+Fe(b);return}let Z=L=>{if(ln(L)!=="retry"){if(!L.ok&&N){let _=x.filter(U=>U.eventType!=="pageview");if(_.length>0&&_.length<x.length){C(x.filter(U=>U.eventType==="pageview").map(U=>U.id)),g(_,!1);return}}C(Y),b=0,w=0;return}ze(x,i,u),y(x),b++,w=Date.now()+Fe(b)};ie instanceof Promise?ie.then(Z).catch(()=>{ze(x,i,u),y(x),b++,w=Date.now()+Fe(b)}):Z(ie)},P=typeof TextEncoder!="undefined"?new TextEncoder:null,I=x=>P?P.encode(x).length:x.length,F=x=>{let N=[],X=2;for(let Y of x){let ie=I(JSON.stringify(Y))+1;if(N.length>0&&X+ie>Wo||N.length>=l)break;N.push(Y),X+=ie}return N},S=()=>{try{if(Date.now()<w)return;for(;a.length>0&&!(Date.now()<w);){let x=a.filter(X=>!d.has(X.id));if(a.length=0,x.length===0)break;let N=F(x);if(N.length===0)break;N.length<x.length&&a.push(...x.slice(N.length)),g(N)}}catch(x){}},J=!0,z=null;z=setInterval(()=>{J&&S()},o);let K=()=>{document.visibilityState==="hidden"&&S()},oe=()=>{S()};return document.addEventListener("visibilitychange",K),window.addEventListener("pagehide",oe),{push(x){A(x),a.length>=l&&S()},flush:S,destroy(){J=!1,z!==null&&(clearInterval(z),z=null),document.removeEventListener("visibilitychange",K),window.removeEventListener("pagehide",oe),S()}}}var Yo=200;function or(e){return`_snt_goal_retry_${e.slice(0,12)}`}var Xo={send:()=>{},flush:()=>{},destroy:()=>{}};function Zo(e){var t,n,r;if(typeof window=="undefined")return Xo;let o=(t=e.flushIntervalMs)!=null?t:5e3,l=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=or(e.apiKey),c=[],u=new Set,a=new Set,d=[],h=0,C=0,f=!1,m=I=>{for(u.delete(I.id),a.has(I.id)||(a.add(I.id),d.push(I.id));d.length>Yo;){let F=d.shift();F&&a.delete(F)}nr([I.id],s)},A=I=>{ze([I],l,s),!a.has(I.id)&&!u.has(I.id)&&(u.add(I.id),c.push(I)),Date.now()>=h&&(C++,h=Date.now()+Fe(C))},y=I=>{let F;try{F=fetch(e.url,{method:"POST",keepalive:!0,body:I.body,headers:e.headers})}catch(J){A(I);return}let S=J=>{var z;let K=ln(J);if(K==="retry"){A(I);return}K==="dropped"&&((z=e.onDrop)==null||z.call(e,I,J.status)),m(I),C=0,h=0};F instanceof Promise?F.then(S).catch(()=>A(I)):S(F)},E=()=>{try{if(f||Date.now()<h)return;let I=0;for(;c.length>0&&I<i&&!(Date.now()<h);){let F=c.shift();u.delete(F.id),!a.has(F.id)&&(I++,y(F))}}catch(I){}},w=tr(s,l);for(let I of w)u.has(I.id)||(u.add(I.id),c.push(I));w.length>0&&ze(w,l,s);let b=setInterval(E,o),g=()=>{document.visibilityState==="hidden"&&E()},P=()=>E();return document.addEventListener("visibilitychange",g),window.addEventListener("pagehide",P),{send(I){if(!f&&!(a.has(I.id)||u.has(I.id))){if(Date.now()<h){ze([I],l,s),u.add(I.id),c.push(I);return}y(I)}},flush:E,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",g),window.removeEventListener("pagehide",P),E(),f=!0}}}var Qo=1800*1e3;function Ct(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ei(e=Qo,t){let n=new Map,r=`_snt_asgn${xt(t)}_`,o=(c,u)=>`${r}${encodeURIComponent(c)}:${encodeURIComponent(u)}`,l=c=>{let u=c.slice(r.length),a=u.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(u.slice(0,a)),segment:decodeURIComponent(u.slice(a+1))}}catch(d){return null}},i=()=>{try{let c=[];for(let u=0;u<localStorage.length;u++){let a=localStorage.key(u);a!=null&&a.startsWith(r)&&c.push(a)}return c}catch(c){return[]}},s=c=>c.assignedAt+(c.ttlMs&&c.ttlMs>0?c.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let c of i())try{let u=localStorage.getItem(c);if(!u)continue;let a=JSON.parse(u);if(s(a)){localStorage.removeItem(c);continue}let d=l(c);if(!d)continue;n.set(Ct(d.componentId,d.segment),a)}catch(u){}})(),{get(c,u){let a=n.get(Ct(c,u));return a?s(a)?(n.delete(Ct(c,u)),null):a:null},set(c,u,a){let d=Ct(c,u);n.set(d,a);try{localStorage.setItem(o(c,u),JSON.stringify(a))}catch(h){}},clear(){n.clear();for(let c of i())try{localStorage.removeItem(c)}catch(u){}}}}var It="_snt_snap:",ti=["low","medium","high"];function ot(e){try{let t=localStorage.getItem(It+e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!ti.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig)))return null;let r=n.vocabulary;return r!==void 0&&(typeof r!="object"||r===null||!Array.isArray(r.entries)||!Array.isArray(r.images))&&delete n.vocabulary,n}catch(t){return null}}function He(e,t){try{localStorage.setItem(It+e,JSON.stringify(t))}catch(n){}}var sn="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",ir="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",Xn=!1,_t=!1;function ni(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function ri(e){var t;let n=er({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=ni(),l=Promise.resolve().then(()=>(Wn(),Hn)).then(a=>{let d=a;return d.LOCAL_ENGINE_AVAILABLE?(Xn||(Xn=!0,console.info(ir)),d):(_t||(_t=!0,console.error(sn)),null)}).catch(()=>(_t||(_t=!0,console.error(sn)),null)),i=null,s={low:.15,medium:.5,high:.85},c=(()=>{var a;if(e.initialPersona)return B({},e.initialPersona);let d=ot(e.apiKey||"local");return d?{persona:d.persona,confidence:(a=s[d.band])!=null?a:.15}:null})();function u(a){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=a.persona,d.dataset.sentientConfidence=$e(a.confidence))}return{isLocal:!0,async decide(a){var d,h,C;let f=await l;if(!f)return null;let m=f.createLocalEngine({sessionId:r,forcedPersona:o}).decide(a);return i=Re(B({},m),{layoutOrder:(h=(d=m.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?h:null,slots:B(B({},(C=i==null?void 0:i.slots)!=null?C:{}),m.slots)}),He(e.apiKey||"local",{v:1,persona:i.persona,band:$e(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(m),m},getSlotResult(a){var d,h,C;return(C=(h=i==null?void 0:i.slots[a])!=null?h:(d=e.initialSlots)==null?void 0:d[a])!=null?C:null},getSlotConfig(a){var d,h;return(h=(d=e.initialSlotConfig)==null?void 0:d[a])!=null?h:null},getSitePalette(){var a;return(a=e.initialPalette)!=null?a:null},reportSlots(){},getPersona(){let a=i!=null?i:c;return a?{persona:a.persona,confidence:a.confidence,band:$e(a.confidence)}:null},async assign(a,d){var h;let C=await l;return!C||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(h=C.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:a,variantIds:d}]}).assignments[a])!=null?h:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var Lt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function nn(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function un(e,t){if(e===void 0||!Lt.test(e))return!1;if(e==="*")return!0;let n=nn(t);if(e.endsWith("/*")){let r=nn(e.slice(0,-2));return n.startsWith(r==="/"?"/":`${r}/`)&&n!==r}return n===nn(e)}function it(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(it):!1}var Zn="sentient-reveal",Ve="sentient-revealed";var rn=!1;function oi(e){if(rn||e.getElementById(Zn)){rn=!0;return}let t=e.createElement("style");t.id=Zn,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${Ve}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${Ve}{animation:${Ve} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),rn=!0}function cn(e,t={}){var n;let r=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!r||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;oi(r),e.classList.remove(Ve),e.offsetWidth,e.classList.add(Ve);let o=()=>{e.classList.remove(Ve),e.removeEventListener("animationend",o)};return e.addEventListener("animationend",o),!0}function st(e,t,n,r){let o=[];{let l=!1,i=[],s=()=>{if(l)return;let c=Date.now();for(i.push(c);i.length>0&&c-i[0]>500;)i.shift();i.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let l=!1,i=s=>{if(l||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;l=!0;let c=typeof window!="undefined"?window.getSelection():null,u=c?c.toString().length:0;e("text_copy",{selectionLength:u})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let l=!1,i=!1,s=null,c=()=>{s!==null&&(clearTimeout(s),s=null)},u=()=>{l||!i||(c(),s=setTimeout(()=>{!l&&i&&(l=!0,e("scroll_hesitation"))},3e3))},a=()=>{c(),u()},d=C=>{for(let f of C)i=f.intersectionRatio>.3,i?u():c()},h=new IntersectionObserver(d,{threshold:[.3]});h.observe(t),window.addEventListener("scroll",a,{passive:!0}),o.push(()=>{h.disconnect(),window.removeEventListener("scroll",a),c()})}if((r==null?void 0:r.tabLoss)!==!1){let l=!1,i=n!=null?n:Date.now(),s=()=>{if(l||document.visibilityState!=="hidden")return;let c=Date.now()-i;c<15e3&&(l=!0,e("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let l of o)l()}}function ii(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var sr="https://api.sentient-ui.com/v1/events",we=new Map,ar=null;function si(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var ai=3;function on(){return Qn()}function Ot(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function li(){let e=new WeakMap,t=new Map,n=!1,r=(s,c,u)=>{let a=s.get(c);return u===null?a?!0:(s.set(c,new Set),!1):a?a.has(u)?!0:(a.add(u),!1):(s.set(c,new Set([u])),!1)},o=typeof window!="undefined"&&"event"in window,l=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,c=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(c,0),typeof MessageChannel=="function"){let u=new MessageChannel;u.port1.onmessage=()=>{u.port1.close(),u.port2.close(),c()},u.port2.postMessage(0)}};return{firedBefore(s,c){let u=l();if(u){let d=e.get(u);return d||(d=new Map,e.set(u,d)),r(d,s,c)}let a=r(t,s,c);return!a&&!n&&(n=!0,i()),a}}}var lr=new Set;function ui(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,l,i=()=>{if(o)return;let u=Ot();!u||u===l||(l=u,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${u}`))},s=[];for(let u of["pushState","replaceState"]){let a=r[u],d=function(...h){let C=a.apply(this,h);return i(),C};r[u]=d,s.push([u,a,d])}window.addEventListener("popstate",i);let c=Ot();return c&&lr.has(`${t}:${c}`)?l=c:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[u,a,d]of s)r[u]===d&&(r[u]=a)}}}var rt={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function ci(){try{return Fn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function ur(e){return e.replace(/\/events\/?$/,"")}function Be(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function dn(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:ar;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=we.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:l,reinit:i}=r;if(!l){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Be())return;let s=(i!=null?i:at)(Re(B({},o),{consent:!0}));l(s);let c=(t=we.get(n))==null?void 0:t.dispose;we.set(n,{config:Re(B({},o),{consent:!0}),upgrade:null,dispose:c})}function di(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=ur((t=e.ingestUrl)!=null?t:sr),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},l=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(f,m,A){if(!n)return Promise.resolve(null);let y=l.get(f);return y?Promise.resolve(y):an(i,f,async()=>{try{let E=new URLSearchParams({componentId:f});for(let g of m!=null?m:[])E.append("variantIds[]",g);let w=await fetch(`${r}/winner?${E.toString()}`,{headers:o});if(!w.ok)return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null;let b={variantId:(await w.json()).variantId,assignmentTtlMs:0};return l.set(f,b),b}catch(E){return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},c=!1,u=new Set,a=[],d=[],h={track:f=>s.track(f),goal:((f,m,A,y)=>s.goal(f,m,A,y)),componentGoal:(f,m,A)=>s.componentGoal(f,m,A),identify:f=>s.identify(f),getAssignment:(f,m)=>s.getAssignment(f,m),assign:(f,m,A,y)=>s.assign(f,m,A,y),decide:f=>s.decide(f),getSlotResult:f=>s.getSlotResult(f),isSlotDecided:f=>{var m,A;return(A=(m=s.isSlotDecided)==null?void 0:m.call(s,f))!=null?A:!0},getSlotConfig:f=>s.getSlotConfig(f),getSitePalette:()=>s.getSitePalette(),getStyleVocabulary:()=>{var f,m;return(m=(f=s.getStyleVocabulary)==null?void 0:f.call(s))!=null?m:null},reportSlots:(f,m,A,y)=>s.reportSlots(f,m,A,y),reportSkeleton:(f,m)=>{var A;return(A=s.reportSkeleton)==null?void 0:A.call(s,f,m)},reportDrift:(f,m,A,y)=>{var E;return(E=s.reportDrift)==null?void 0:E.call(s,f,m,A,y)},requestSlots:(f,m,A)=>{var y;return c?(y=s.requestSlots)==null?void 0:y.call(s,f,m,A):a.push([f,m,A])},decideSlots:f=>{var m;return c?(m=s.decideSlots)==null?void 0:m.call(s,f):d.push(...f)},cancelSlots:f=>{var m;if(c)return(m=s.cancelSlots)==null?void 0:m.call(s,f);let A=new Set(f);for(let y of a)y[0]=y[0].filter(E=>!A.has(E));d=d.filter(y=>!A.has(y.id))},onSlotsChanged:f=>(u.add(f),()=>{u.delete(f)}),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),flush:()=>s.flush(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function C(f){var m,A,y;s=f,c=!0,(m=f.onSlotsChanged)==null||m.call(f,()=>u.forEach(E=>E()));for(let[E,w,b]of a.splice(0))E.length>0&&((A=f.requestSlots)==null||A.call(f,E,w,b));d.length>0&&((y=f.decideSlots)==null||y.call(f,d.splice(0)))}return{proxy:h,setInner:C}}function an(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function at(e){var t,n,r,o,l,i,s,c,u,a;if(typeof window=="undefined")return rt;ar=e.apiKey||"local";let d=we.get(e.apiKey||"local");if(d!=null&&d.dispose)try{d.dispose()}catch(p){}let h=e.respectDoNotTrack!==!1&&Be(),C=e.consent===!1||h,f=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!f&&e.localMode!==!1)return we.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),C?rt:ri(e);if(C){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),we.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),rt;let{proxy:p,setInner:v}=di(e);return we.set(e.apiKey,{config:e,upgrade:h?null:v}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),rt;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),rt;let m=(t=e.ingestUrl)!=null?t:sr,A=Date.now(),y=er({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),E=ei(void 0,e.apiKey),w=Jo({ingestUrl:m,apiKey:e.apiKey}),b=ur(m),g={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},P=new Set,I=Zo({url:`${b}/goals`,apiKey:e.apiKey,headers:g,onDrop:(p,v)=>{if(!e.debug){if(P.has(v))return;P.add(v)}console.warn(`[sentient] goal dropped (HTTP ${v}) \u2014 this will not be retried. `+(v===400?"The session was not found: call init() and let the session upsert complete before firing goals.":v===401||v===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),F=jn((n=navigator.userAgent)!=null?n:""),S=window.location.origin,J=Un((r=document.referrer)!=null?r:"",S),z=(o=e.sessionSegment)!=null?o:`${F}:${J}`,K=new Map,oe=new Map,x=new Map,N=new Set,X=new Map,Y=null,ie=null,Z=null,L=new Set,_=new Set,U=new Map,Q=new Map,T=new Set,re=new Set,be=new Set,me=null,vt=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,wn=new Set,bt=new Set,wt=new Set,Qe=new Map,qt=null,St=new Set,et=new Map,Jt=null,ho=2,Sn=new Map,Yt=!1,En=(p,v,M)=>{var H;let G=new Set,k=1;for(let O of p){v.delete(O);let $=((H=Sn.get(O))!=null?H:0)+1;Sn.set(O,$),$<=ho&&(G.add(O),$>k&&(k=$))}G.size>0&&setTimeout(()=>{Yt||M(G)},Fe(k))},An=p=>{for(let v of p)x.has(v.id)||x.set(v.id,en(v))};if(e.initialSlots)for(let[p,v]of Object.entries(e.initialSlots))x.set(p,v),N.add(p);if(e.initialSlotConfig)for(let[p,v]of Object.entries(e.initialSlotConfig))X.set(p,v);e.initialPalette&&(Y=e.initialPalette),e.initialVocabulary&&(ie=e.initialVocabulary);let xe=ot(e.apiKey);if(xe){for(let[p,v]of Object.entries(xe.slots))x.has(p)||x.set(p,v);for(let[p,v]of Object.entries((l=xe.slotConfig)!=null?l:{}))X.has(p)||X.set(p,v);!Y&&xe.palette&&(Y=xe.palette),!ie&&xe.vocabulary&&(ie=xe.vocabulary)}let xn={low:.15,medium:.5,high:.85};if(e.initialPersona)Z=B({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?Z={persona:p.sentientPersona,confidence:(s=xn[(i=p.sentientConfidence)!=null?i:"low"])!=null?s:.15}:xe&&(Z={persona:xe.persona,confidence:(c=xn[xe.band])!=null?c:.15})}if(e.initialAssignments)for(let[p,v]of Object.entries(e.initialAssignments))E.set(p,z,{variantId:v,assignedAt:Date.now(),segment:z,confidence:1});let Ie=Promise.resolve(),kn=y.getSessionId();if(kn){let p=Gn((u=document.referrer)!=null?u:""),{utmParams:v,clickIds:M}=ci(),H=B(B(B(B({sessionId:kn,deviceClass:F,trafficSource:J,referrerDomain:p,utmParams:v,clickIds:M,timeOfDay:zn(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:y.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Kn((a=navigator.userAgent)!=null?a:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),G=async()=>{for(let k=0;;k++){try{let O=await fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(H),headers:g});if(O.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(O.ok||ln(O)==="dropped")return}catch(O){}if(k>=ai){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(O=>setTimeout(O,Fe(k+1)))}};try{Ie=G()}catch(k){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:w});let yo=li(),tt=null,Xt=!1,de={goal(p,v={},M=1,H=0){var G,k,O,$,W,ee,ae;let ue=y.getSessionId();if(!ue)return;let q=si(v)?v:{metadata:v},ge=[p,(G=q.externalId)!=null?G:"",(k=q.stepIndex)!=null?k:H,(O=q.weight)!=null?O:M].join("\0"),Ee=q.value!==void 0?`${q.value}\0${($=q.currency)!=null?$:""}`:null;if(yo.firedBefore(ge,Ee)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}let pe=on(),D={sessionId:ue,name:p,metadata:(W=q.metadata)!=null?W:{},weight:(ee=q.weight)!=null?ee:M,stepIndex:(ae=q.stepIndex)!=null?ae:H,goalId:pe,value:q.value,currency:q.currency,externalId:q.externalId};e.debug&&console.log("[sentient] goal",D);let fe={id:pe,body:JSON.stringify(D)};Ie.then(()=>I.send(fe))},componentGoal(p,v,M){var H,G,k;let O=y.getSessionId();if(!O)return;let $=E.get(p,z),W=$?null:(H=x.get(p))!=null?H:null;if(!$&&W===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!$&&!N.has(p)){e.debug&&console.warn(`[sentient] componentGoal("${p}"): slot not decided this session \u2014 not attributed`);return}let ee=$?$.variantId:Vn(W),ae={id:on(),sessionId:O,projectId:e.apiKey,componentId:p,variantId:ee,eventType:"goal_achieved",goalType:v,payload:B({reward:(G=M==null?void 0:M.reward)!=null?G:1,goalValue:M==null?void 0:M.value,currency:M==null?void 0:M.currency},(k=M==null?void 0:M.metadata)!=null?k:{}),timestamp:Date.now(),timeInSession:Date.now()-A,path:Ot()};e.debug&&console.log("[sentient] componentGoal",ae),Ie.then(()=>w.push(ae))},identify(p){let v=y.getSessionId();v&&Ie.then(()=>{fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:v,userId:p,ephemeral:y.isEphemeral()}),headers:g}).catch(()=>{})})},track(p){let v=y.getSessionId();if(!v||p.eventType==="variant_assigned"&&x.get(p.componentId)!==void 0&&!N.has(p.componentId)&&!E.get(p.componentId,z))return;let M=Re(B({path:Ot()},p),{id:on(),sessionId:v,timestamp:Date.now(),timeInSession:Date.now()-A});e.debug&&console.log("[sentient] track",M),Ie.then(()=>w.push(M))},getAssignment(p,v){return E.get(p,v)},async assign(p,v,M,H){let G=y.getSessionId();if(!G)return null;let k=E.get(p,z);if(k&&(v!=null&&v.length||k.content!==void 0)){let O=k.ttlMs&&k.ttlMs>0?Math.max(0,k.assignedAt+k.ttlMs-Date.now()):0;return{variantId:k.variantId,assignmentTtlMs:O,content:k.content}}return an(K,p,async()=>{await Ie;try{let O={sessionId:G,componentId:p,variantIds:v};H!==void 0?O.agentDataByVariant=H:M!==void 0&&(O.agentData=M);let $=await fetch(`${b}/assign`,{method:"POST",body:JSON.stringify(O),headers:g});if(!$.ok)return null;let W=await $.json();return E.set(p,z,B({variantId:W.variantId,assignedAt:Date.now(),segment:z,confidence:1,content:W.content},W.assignmentTtlMs&&W.assignmentTtlMs>0?{ttlMs:W.assignmentTtlMs}:{})),W}catch(O){return null}})},async decide(p){var v,M;let H=y.getSessionId();if(!H)return null;let G=(v=p.slots)!=null?v:[],k={sessionId:H};p.sections&&p.sections.length>0&&(k.sections=p.sections.map($=>({id:$}))),k.components=(M=p.components)!=null?M:[],G.length>0&&(k.slots=G.map(Qt)),p.slotsFrom==="registry"&&(k.slotsFrom="registry",p.registrySlotIds&&(k.registrySlotIds=p.registrySlotIds),p.bootstrap===!1&&(k.bootstrap=!1),p.render&&Object.keys(p.render).length>0&&(k.render=p.render)),p.v&&(k.v=p.v),typeof p.pp=="number"&&(k.pp=p.pp),e.persona&&(k.persona=e.persona);let O=JSON.stringify(k);return an(oe,O,async()=>{var $,W,ee,ae,ue,q,ge,Ee;await Ie;try{let pe=await fetch(`${b}/decide`,{method:"POST",body:O,headers:g});if(!pe.ok)return An(G),null;let D=await pe.json(),fe={};for(let te of G){let ke=($=D.slots)==null?void 0:$[te.id];if(ke!==void 0){fe[te.id]=ke,x.set(te.id,ke),N.add(te.id);continue}let Cn=x.get(te.id);if(Cn!==void 0)fe[te.id]=Cn;else{let _n=en(te);fe[te.id]=_n,x.set(te.id,_n)}}if(D.slots)for(let[te,ke]of Object.entries(D.slots))te in fe||(fe[te]=ke,x.set(te,ke),N.add(te));let Le=Z!=null&&Z.persona!=="unknown";D.persona&&!(D.persona==="unknown"&&Le)?Z={persona:D.persona,confidence:(W=D.confidence)!=null?W:0}:Z||(Z={persona:"unknown",confidence:0});for(let[te,ke]of Object.entries((ee=D.assignments)!=null?ee:{}))E.set(te,z,{variantId:ke,assignedAt:Date.now(),segment:z,confidence:1});if(D.slotConfig)for(let[te,ke]of Object.entries(D.slotConfig))X.set(te,ke);D.palette&&(Y=D.palette),D.vocabulary&&(ie=D.vocabulary);for(let te of(ae=p.registrySlotIds)!=null?ae:[])(ue=D.slotConfig)!=null&&ue[te]||(X.delete(te),x.delete(te),N.delete(te));return He(e.apiKey,B(B(B({v:1,persona:Z.persona,band:$e(Z.confidence),slots:Object.fromEntries(x),layoutOrder:(q=D.layoutOrder)!=null?q:null,savedAt:Date.now()},X.size>0?{slotConfig:Object.fromEntries(X)}:{}),Y?{palette:Y}:{}),ie?{vocabulary:ie}:{})),B(B(B(B(B({layoutOrder:(ge=D.layoutOrder)!=null?ge:null,assignments:(Ee=D.assignments)!=null?Ee:{},slots:fe,persona:Z.persona,confidence:Z.confidence},D.slotConfig?{slotConfig:D.slotConfig}:{}),D.goals?{goals:D.goals}:{}),D.sectionMap?{sectionMap:D.sectionMap}:{}),D.palette?{palette:D.palette}:{}),D.vocabulary?{vocabulary:D.vocabulary}:{})}catch(pe){return An(G),null}})},getSlotResult(p){var v;return(v=x.get(p))!=null?v:null},isSlotDecided(p){return N.has(p)},getSlotConfig(p){var v;return(v=X.get(p))!=null?v:null},reportSlots(p,v,M,H){var G;let k={};for(let[O,$]of Object.entries(H!=null?H:{}))for(let W of $){let ee=`${O}|${W.key}`;!vt.test(O)||be.has(ee)||(be.add(ee),((G=k[O])!=null?G:k[O]=[]).push(W))}Object.keys(k).length>0&&fetch(`${b}/slots/observed`,{method:"POST",headers:g,body:JSON.stringify({slotIds:Object.keys(k),authoredArms:k})}).catch(()=>{});for(let O of p)if(!(typeof O!="string"||O.length===0)){if(!vt.test(O)){ii()&&!wn.has(O)&&(wn.add(O),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(O)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!L.has(O)){L.add(O),_.add(O);let $=v==null?void 0:v[O];if(typeof $=="string"){let ee=$.replace(/\s+/g," ").trim().slice(0,400);ee!==""&&U.set(O,ee)}let W=M==null?void 0:M[O];W!==void 0&&Q.set(O,W)}}_.size===0||me!=null||(me=setTimeout(()=>{me=null;let O=[..._];_.clear();for(let $=0;$<O.length;$+=20){let W=O.slice($,$+20),ee={},ae={};for(let ue of W){let q=U.get(ue);q!==void 0&&(ee[ue]=q,U.delete(ue));let ge=Q.get(ue);ge!==void 0&&(ae[ue]=ge,Q.delete(ue))}fetch(`${b}/slots/observed`,{method:"POST",headers:g,body:JSON.stringify(Re(B(B({slotIds:W},Object.keys(ee).length>0?{baselineTexts:ee}:{}),Object.keys(ae).length>0?{baselineSkeletons:ae}:{}),{pagePaths:Object.fromEntries(W.map(ue=>[ue,location.pathname]))}))}).catch(()=>{})}},1e3))},reportSkeleton(p,v){!vt.test(p)||T.has(p)||(T.add(p),fetch(`${b}/slots/observed`,{method:"POST",headers:g,body:JSON.stringify({slotIds:[p],baselineSkeletons:{[p]:v}})}).catch(()=>{}))},reportDrift(p,v,M,H){let G=`${p}|${v}`,k=y.getSessionId();!k||re.has(G)||(re.add(G),fetch(`${b}/slots/drift`,{method:"POST",headers:g,body:JSON.stringify({sessionId:k,reports:[{slotId:p,expectedFp:v,observedFp:M,reason:H}]})}).catch(()=>{}))},requestSlots(p,v,M){var H,G;for(let k of p)wt.has(k)||(wt.add(k),vt.test(k)?Qe.set(k,{text:v==null?void 0:v[k],render:(H=M==null?void 0:M.render)==null?void 0:H[k],skeleton:(G=M==null?void 0:M.skeletons)==null?void 0:G[k]}):de.reportSlots([k]));Qe.size===0||qt!=null||(qt=setTimeout(()=>{qt=null;let k=[...Qe];Qe.clear();for(let O=0;O<k.length;O+=50){let $=k.slice(O,O+50),W={};for(let[ee,ae]of $)ae.render&&(W[ee]=ae.render);de.decide({slotsFrom:"registry",registrySlotIds:$.map(([ee])=>ee),bootstrap:!1,render:W}).then(ee=>{var ae,ue;if(ee){let q={},ge={},Ee=[];for(let[pe,D]of $){let fe=(ae=ee.slotConfig)==null?void 0:ae[pe];if(fe){fe.needsSkeleton&&D.skeleton&&((ue=de.reportSkeleton)==null||ue.call(de,pe,D.skeleton));continue}Ee.push(pe),D.text&&(q[pe]=D.text),D.skeleton&&(ge[pe]=D.skeleton)}Ee.length>0&&de.reportSlots(Ee,q,ge)}else En($.map(([q])=>q),wt,q=>{var ge;let Ee={},pe={},D={};for(let[fe,Le]of $)q.has(fe)&&(Le.text&&(Ee[fe]=Le.text),Le.render&&(pe[fe]=Le.render),Le.skeleton&&(D[fe]=Le.skeleton));(ge=de.requestSlots)==null||ge.call(de,[...q],Ee,{render:pe,skeletons:D})});bt.forEach(q=>q())})}},0))},decideSlots(p){for(let v of p)St.has(v.id)||(St.add(v.id),et.set(v.id,v));et.size===0||Jt!=null||(Jt=setTimeout(()=>{Jt=null;let v=[...et.values()];et.clear();for(let M=0;M<v.length;M+=30){let H=v.slice(M,M+30);de.decide({slots:H}).then(G=>{G||En(H.map(k=>k.id),St,k=>{var O;return(O=de.decideSlots)==null?void 0:O.call(de,H.filter($=>k.has($.id)))}),bt.forEach(k=>k())})}},0))},cancelSlots(p){for(let v of p)Qe.delete(v)&&wt.delete(v),et.delete(v)&&St.delete(v)},onSlotsChanged(p){return bt.add(p),()=>{bt.delete(p)}},getStyleVocabulary(){return ie},getSitePalette(){return Y},getPersona(){return Z?{persona:Z.persona,confidence:Z.confidence,band:$e(Z.confidence)}:null},async fetchWeights(){var p;try{let v=await fetch(`${b}/weights`,{headers:g});return v.ok?(p=(await v.json()).components)!=null?p:[]:[]}catch(v){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){w.flush(),I.flush()},dispose(){var p;tt==null||tt(),Xt=!0,Yt=!0,w.destroy(),I.destroy(),((p=we.get(e.apiKey))==null?void 0:p.dispose)===de.dispose&&we.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;tt==null||tt(),Xt=!0,Yt=!0,w.destroy(),I.destroy(),y.destroy(),E.clear(),((p=we.get(e.apiKey))==null?void 0:p.dispose)===de.dispose&&we.delete(e.apiKey);try{localStorage.removeItem(It+e.apiKey),localStorage.removeItem(rr(e.apiKey)),localStorage.removeItem(or(e.apiKey))}catch(v){}e.debug&&console.log("[sentient] destroyed")}};if(we.set(e.apiKey,{config:e,upgrade:null,dispose:de.dispose}),tt=ui(de,e.apiKey,p=>{Ie.then(()=>{Xt||lr.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=de)}return de}function fi(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function cr(e,t){let n=t>>>0;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619)>>>0;return n.toString(16).padStart(8,"0")}function pi(e){let t=e.join("");return cr(t,2166136261)+cr(t,1523705862)}var mi=new Set(["A","BUTTON"]),gi=/^H([1-6])$/,hi=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]);var yi=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function vi(e){return mi.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function bi(e){if(gi.test(e.tagName)||hi.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function wi(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(vi(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||bi(r))return r;return t}function Tt(e,t=40){var n,r,o;let l=e.ownerDocument.createTreeWalker(e,4),i=[];for(let a=l.nextNode();a;a=l.nextNode())if(((n=a.nodeValue)!=null?n:"").trim()!==""&&!yi.has((o=(r=a.parentElement)==null?void 0:r.tagName)!=null?o:"")&&(i.push(a),i.length>120))return{reason:"too_large"};if(i.length===0)return{reason:"empty"};let s=[],c=[];for(let a of i){let d=wi(a,e),h=s.indexOf(d);h===-1&&(s.push(d),h=s.length-1),c.push(h)}if(s.length>t)return{reason:"too_large"};let u=i.map(a=>{var d;return fi((d=a.nodeValue)!=null?d:"")});return{textNodes:i,ownerEls:s,leafToNode:c,leaves:u,fp:pi(u)}}var Si=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function fn(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function Ei(e){return{tag:e.tagName.toLowerCase(),text:fn(e).slice(0,40)}}function dr(e){return e.replace(/["\\\]]/g,"\\$&")}function lt(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function fr(e,t){var n;let r=e.tagName.toLowerCase();if(!r)return null;let o=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),l=[r,...o.map(s=>`${r}.${s}`)];for(let s of l)if(lt(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=fr(i,t);if(s){for(let d of l){let h=`${s} > ${d}`;if(lt(t,h))return h}let c=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),u=c.indexOf(e),a=c.some(d=>d!==e&&fn(d)!==fn(e));if(u>=0&&a){let d=`${s} > ${r}:nth-of-type(${u+1})`;if(lt(t,d))return d}}}return null}function pr(e,t){let n=Ei(e),r=e.getAttribute("id");if(r&<(t,`#${dr(r)}`))return{v:1,id:r,fingerprint:n};for(let l of Si){let i=e.getAttribute(l);if(i&<(t,`[${l}="${dr(i)}"]`))return{v:1,dataAttr:{name:l,value:i},fingerprint:n}}let o=fr(e,t);return o?{v:1,selector:o,fingerprint:n}:null}nt();var gr=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Ai={banner:"hero",navigation:"navigation",contentinfo:"footer"};function xi(e){let t=e.ariaRole?Ai[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 ki(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Ci=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],pn=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],mr={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function _i(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function hr(e){var t,n;let r=xi(e);if(r)return{type:(t=mr[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of Ci)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of pn)if(s.test(e.bodyText))return{type:i,strength:"strong"};let l=ki(e);return{type:(n=mr[l])!=null?n:"generic",strength:"weak"}}function yr(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return B({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:_i(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}nt();var vr=[100,300,1e3,3e3,1e4],Oi=250,Ii=1e3,Li=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function br(e,t){e.n++;let n=t-e.mean;e.mean+=n/e.n,e.m2+=n*(t-e.mean)}var wr=e=>e.n>1?Math.sqrt(e.m2/e.n):0;function Ti(e){var t;try{let n=e.createElement("canvas"),r=n.getContext("webgl")||n.getContext("experimental-webgl");if(!r)return"unknown";let o=r.getExtension("WEBGL_debug_renderer_info"),l=o?String((t=r.getParameter(o.UNMASKED_RENDERER_WEBGL))!=null?t:""):"";return l?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(l)?"sw":"hw":"unknown"}catch(n){return"unknown"}}function Ri(e,t=Date.now){var n,r;let o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0,l={n:0,mean:0,m2:0},i={n:0,mean:0,m2:0},s=[0,0,0,0,0,0],c=0,u=0,a=0,d=0,h=0,C=0,f=0,m=0,A=0,y=0,E=-1/0,w=-1/0,b=null,g=null,P=null,I=(r=o==null?void 0:o.scrollY)!=null?r:0,F=0,S=e.hidden?null:t(),J=()=>{let T=t();if(P!=null){let re=T-P,be=0;for(;be<vr.length&&re>=vr[be];)be++;s[be]++}P=T},z=()=>{c++,E=t()},K=()=>{u++,w=t()},oe=()=>{b=t()},x=()=>{b!=null&&(br(l,t()-b),b=null)},N=()=>{let T=t();a++,T-E>Oi&&T-w>Ii&&d++,J()},X=()=>{h++},Y=()=>{var T;let re=(T=o==null?void 0:o.scrollY)!=null?T:0;C+=Math.abs(re-I),I=re,J()},ie=T=>{let re=t();f++,(T.key==="Backspace"||T.key==="Delete")&&A++,Li.has(T.key)&&y++,g!=null&&br(i,re-g),g=re,J()},Z=T=>{let re=T.data;typeof re=="string"&&(m+=re.length),J()},L=()=>{let T=t();e.hidden?S!=null&&(F+=T-S,S=null):S==null&&(S=T)},_={passive:!0,capture:!0};e.addEventListener("mousemove",z,_),e.addEventListener("touchstart",K,_),e.addEventListener("touchmove",X,_),e.addEventListener("mousedown",oe,_),e.addEventListener("mouseup",x,_),e.addEventListener("click",N,_),e.addEventListener("wheel",X,_),e.addEventListener("keydown",ie,_),e.addEventListener("input",Z,_),e.addEventListener("visibilitychange",L),o==null||o.addEventListener("scroll",Y,_);let U=Ti(e),Q=(()=>{var T;try{return((T=o==null?void 0:o.matchMedia)==null?void 0:T.call(o,"(prefers-reduced-motion: reduce)").matches)===!0}catch(re){return!1}})();return{snapshot(){var T,re;let be=t(),me=F+(S!=null?be-S:0);return{v:1,active_ms:Math.round(me),mm:c,mm_rate:me>0?Number((c*1e3/me).toFixed(2)):0,touches:u,clicks:a,hold_n:l.n,hold_mean:Math.round(l.mean),hold_std:Math.round(wr(l)),teleport:d,wheel:h,scroll_px:Math.round(C),keydowns:f,input_chars:m,ik_cv:i.mean>0?Number((wr(i)/i.mean).toFixed(2)):0,backspaces:A,gaps:[...s],reduced_motion:Q,kb_nav:y,renderer:U,vp:[(T=o==null?void 0:o.innerWidth)!=null?T:0,(re=o==null?void 0:o.innerHeight)!=null?re:0],dpr:(o==null?void 0:o.devicePixelRatio)||1}},stop(){e.removeEventListener("mousemove",z,_),e.removeEventListener("touchstart",K,_),e.removeEventListener("touchmove",X,_),e.removeEventListener("mousedown",oe,_),e.removeEventListener("mouseup",x,_),e.removeEventListener("click",N,_),e.removeEventListener("wheel",X,_),e.removeEventListener("keydown",ie,_),e.removeEventListener("input",Z,_),e.removeEventListener("visibilitychange",L),o==null||o.removeEventListener("scroll",Y,_)}}}var Pi="section, header, footer, nav, main > div, [data-sentient-section]",Di=2e4,Ni="__session__";function Mi(e){let t=Array.from(e.querySelectorAll(Pi)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function $i(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var Sr=()=>{};function Er(e,t){var n,r,o,l,i,s,c,u,a,d,h,C,f,m,A;let y=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!y||typeof IntersectionObserver=="undefined"||Be()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Sr;let E=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),w=Mi(y);if(w.length===0)return Sr;let b=new Map,g=[];for(let L of w){let _=(i=[(l=t.sectionTypes)==null?void 0:l[(o=L.getAttribute("data-sentient-id"))!=null?o:""],L.getAttribute("data-sentient-type")].find(me=>gr.includes(me)))!=null?i:null,U=yr(L),Q=(c=_!=null?_:(s=t.typeOf)==null?void 0:s.call(t,L))!=null?c:hr(U).type,T=pr(L,y),re=T?`nc-${Q}-${$n(JSON.stringify({id:(u=T.id)!=null?u:null,dataAttr:(a=T.dataAttr)!=null?a:null,selector:(d=T.selector)!=null?d:null})).toString(36)}`:`nc-${Q}`;b.set(L,re);let be=pn.filter(([,me])=>me.test(U.bodyText)).map(([me])=>me);g.push(Re(B({componentId:re,semanticType:Q,source:_?"markup":"auto"},T?{locator:T}:{}),{observation:B(B({tag:U.tag,idClass:U.idClass.slice(0,200),headingText:U.headingText,textLength:U.textLength,actionCount:U.actionCount},U.ariaRole?{ariaRole:U.ariaRole}:{}),be.length>0?{patternFlags:be}:{})}))}let P=(m=(f=(C=(h=y.defaultView)!=null?h:typeof window!="undefined"?window:void 0)==null?void 0:C.location)==null?void 0:f.pathname)!=null?m:"/";$i(t.apiKey,E,P,g);let I=Ri(y),F=()=>{let L;try{L=I.snapshot()}catch(_){return}try{e.track({projectId:t.apiKey,componentId:Ni,eventType:"interaction_stats",payload:L})}catch(_){}},S=new Map,J=L=>{let _=S.get(L);return _||(_={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(L,_)),_},z=new IntersectionObserver(L=>{for(let _ of L){let U=b.get(_.target);if(!U)continue;let Q=J(U);_.isIntersecting?(Q.intersecting=!0,Q.enterAt=Date.now(),_.intersectionRatio>Q.scroll&&(Q.scroll=_.intersectionRatio)):(Q.intersecting=!1,Q.enterAt!=null&&(Q.ms+=Date.now()-Q.enterAt,Q.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let L of b.keys())z.observe(L);let K=(L=!1)=>{var _;let U=Date.now();for(let[Q,T]of S)if(T.enterAt!=null&&(T.ms+=U-T.enterAt,T.enterAt=null),!(T.ms<=0)){try{e.track({projectId:t.apiKey,componentId:Q,eventType:"dwell",payload:{dwell_time:Math.round(T.ms),scroll_depth:Number(T.scroll.toFixed(2))}})}catch(re){}T.ms=0}if(F(),L)try{(_=e.flush)==null||_.call(e)}catch(Q){}},oe=()=>{if(y.hidden)K(!0);else{let L=Date.now();for(let _ of S.values())_.intersecting&&(_.enterAt=L)}},x=!1,N=L=>{if(K(!0),L!=null&&L.persisted){x=!0;return}try{z.disconnect()}catch(_){}},X=L=>{if(!(L!=null&&L.persisted)||!x)return;x=!1;let _=Date.now();for(let U of S.values())U.enterAt=U.intersecting&&!y.hidden?_:null};y.addEventListener("visibilitychange",oe);let Y=(A=y.defaultView)!=null?A:typeof window!="undefined"?window:void 0;Y==null||Y.addEventListener("pagehide",N),Y==null||Y.addEventListener("pageshow",X);let ie=setInterval(()=>{if(y.hidden||x)return;K();let L=Date.now();for(let _ of S.values())_.intersecting&&(_.enterAt=L)},Di),Z=[];return t.microSignals&&[...b.entries()].forEach(([L,_],U)=>{Z.push(st((Q,T={})=>{try{e.track({projectId:t.apiKey,componentId:_,eventType:"micro_signal",payload:B({signalType:Q},T)})}catch(re){}},L,void 0,{tabLoss:U===0}))}),()=>{K(!0),clearInterval(ie),I.stop(),y.removeEventListener("visibilitychange",oe),Y==null||Y.removeEventListener("pagehide",N),Y==null||Y.removeEventListener("pageshow",X);for(let L of Z)L();try{z.disconnect()}catch(L){}}}function Bi(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(l=>typeof l=="string"))return null;n[r]=o}return n}function Ki(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function ji(e){try{return e()}catch(t){return}}function Rt(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[l,i]of Object.entries(t.slots)){if(typeof i!="object"||i===null)continue;let s=i,c=Bi(s.dims);if(!c||s.target!==void 0&&typeof s.target!="string")continue;let u=s.arms!==void 0?Ki(s.arms):null,a={dims:c};typeof s.target=="string"&&(a.target=s.target),u&&(a.arms=u),n[l]=a}let r={apiKey:t.apiKey,personaAttributes:t.personaAttributes===!0,slots:n};typeof t.consent=="boolean"&&(r.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(r.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(r.debug=!0),typeof t.registry=="boolean"&&(r.registry=t.registry),typeof t.editorSrc=="string"&&(r.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(r.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(r.sectionCapture=t.sectionCapture);let o=typeof t.persona=="function"?ji(t.persona):t.persona;if(typeof o=="string"&&o.trim()!==""&&(r.persona=o),Array.isArray(t.sections)){let l=t.sections.filter(i=>typeof i=="string"&&i.trim()!=="").slice(0,50);l.length>=2&&(r.sections=l)}return r}var Ar=new WeakMap;function xr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function kr(e,t,n){var l,i,s;let r=Ar.get(e);if(r){if(r.fp!==n.fp||!xr(r.leafToNode,n.leafToNode))return"mismatch"}else{let c=Tt(e);if(!("fp"in c)||(r={fp:c.fp,leafToNode:c.leafToNode,textNodes:c.textNodes,ownerEls:c.ownerEls,classes:c.ownerEls.map(u=>{var a;return(a=u.getAttribute("class"))!=null?a:""})},r.fp!==n.fp||!xr(r.leafToNode,n.leafToNode)))return"mismatch";Ar.set(e,r)}let o=r;for(let[c,u]of Object.entries(t.nodes)){let a=Number(c),d=o.ownerEls[a];if(d){if(typeof u.text=="string"){let h=!0;o.leafToNode.forEach((C,f)=>{C===a&&(o.textNodes[f].nodeValue=h?u.text:"",h=!1)})}u.like!==void 0&&o.classes[u.like]!==void 0&&d.setAttribute("class",o.classes[u.like]),u.hidden&&((l=d.style)==null||l.setProperty("display","none","important"))}}for(let c of Object.values((i=t.order)!=null?i:{})){let u=c.map(f=>o.ownerEls[f]).filter(f=>!!f),a=(s=u[0])==null?void 0:s.parentElement;if(!a||u.length!==c.length||u.some(f=>f.parentElement!==a))continue;let d=new Set(u),h=0;Array.from(a.children).map(f=>d.has(f)?u[h++]:f).forEach((f,m)=>{var A;a.children[m]!==f&&a.insertBefore(f,(A=a.children[m])!=null?A:null)})}return"applied"}function ut(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Ui(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim().toLowerCase(),o=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function Pt(e,t){return!!(e!=null&&e.urlMatch)&&!ut(t).includes(e.urlMatch)}var Gi=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Cr(e,t){var r;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Gi.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}return n}function Ce(e,t){if(e.urlMatch&&!ut(t).includes(e.urlMatch))return null;let n=Cr(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Ui(r,e.fingerprint)?null:r}function _r(e,t){return Pt(e,t)?!1:!!e.selector&&!e.dataAttr&&!e.id&&!e.fingerprint&&e.page===void 0?Or(e,t):Ce(e,t)!==null}function Or(e,t){return Cr(e,t).length>0}function Dt(e,t){return Pt(e,t)?!1:e.page!==void 0&&Lt.test(e.page)?un(e.page,ut(t)):Or(e,t)}var Ir={color:"color",background:"background",fontSize:"font-size",fontWeight:"font-weight",textAlign:"text-align",padding:"padding",margin:"margin",borderRadius:"border-radius",width:"width",height:"height",maxWidth:"max-width",border:"border",boxShadow:"box-shadow",opacity:"opacity",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",gap:"gap",fontFamily:"font-family"},Fi=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Lr(e){var r;if(e.trim().length===0||/[;{}<>]/.test(e))return!1;let t=/([A-Za-z-]*)\(/g,n;for(;(n=t.exec(e))!==null;)if(!Fi.test((r=n[1])!=null?r:""))return!1;return!0}var Tr=/^https:\/\//i,Rr=new Map,Pe=null;function zi(e){return e.replace(/["\\]/g,"\\$&")}function Vi(e){var t;(!Pe||!Pe.isConnected)&&(Pe=e.querySelector("style[data-sentient-ops]"),Pe||(Pe=e.createElement("style"),Pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Pe))),Pe.textContent=[...Rr.entries()].map(([n,r])=>`[data-snt-e="${zi(n)}"]{${r}}`).join(`
|
|
2
|
-
`)}function Pr(e,t,n,r){var s;let o=!1,l=(s=t.moveBefore)!=null?s:t.moveAfter;if(l){let c=Ce(l,r);!c||c===e||c.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,c):e.parentElement.insertBefore(e,c.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Tr.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Tr.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[c,u]of Object.entries(t.style)){let a=Ir[c];a&&typeof u=="string"&&Lr(u)&&i.push(`${a}:${u.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Rr.set(n,i.join(";")),Vi(r)),{anchorMiss:o}}var ct="data-sentient-block-arm",R=null;function qe(e){R=e!=null?e:null}var Ke=null;function Je(e){Ke=e!=null?e:null}var $r=e=>{var t;return typeof e=="string"?(t=Ke==null?void 0:Ke.entries.find(n=>n.id===e))==null?void 0:t.classes:void 0},Br=e=>{let t=typeof e=="string"?Ke==null?void 0:Ke.entries.find(n=>n.id===e):void 0;return t!=null&&t.computed.inheritsColor?t.computed.color:void 0},Oe="data-sentient-blocks-hid",We={none:"0",sm:"8px",md:"16px",lg:"24px"},mn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Dr={sm:"0.875em",md:"1em",lg:"1.25em"},Hi={sm:"1.25em",md:"1.5em",lg:"2em"},Wi={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Nr={sm:"8px",md:"16px",lg:"32px"},qi={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Ji={normal:"400",medium:"500",bold:"700"};function he(e,t){for(let[n,r]of Object.entries(t))r!==void 0&&e.style.setProperty(n,r);return e}function Mr(e){return e==="muted"?R!=null&&R.muted?{color:R.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:R==null?void 0:R.accent}:{}}function Kr(e,t){let n=Yi(e,t),r=Br(e.like);return n&&r&&(n.style.color=r),n}function Yi(e,t){var n,r,o,l,i,s,c,u,a,d,h,C,f,m,A,y,E,w,b,g;try{let P=$r(e.like),I=e.maxWidth==="measure"?"65ch":void 0,F=S=>(S.className=P,he(S,{"max-width":I}));switch(e.type){case"stack":case"grid":{let S=t.createElement("div");if(e.type==="stack"){let K=e;he(S,{display:"flex","flex-direction":K.direction,gap:(r=We[(n=K.gap)!=null?n:"md"])!=null?r:We.md,"align-items":K.align?mn[K.align]:void 0,"justify-content":K.justify?mn[K.justify]:void 0,"flex-wrap":K.wrap?"wrap":void 0})}else{let K=e,oe=(l=We[(o=K.gap)!=null?o:"md"])!=null?l:We.md;he(S,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${K.columns-1} * ${oe}) / ${K.columns})), 1fr))`,gap:oe,"align-items":K.align?mn[K.align]:void 0})}P&&(S.className=P);let J=!P&&e.type==="stack"&&e.surface==="raised",z=(i=e.pad)!=null?i:J?"md":void 0;z&&he(S,{padding:(s=We[z])!=null?s:We.md}),J&&he(S,{background:R==null?void 0:R.surface,color:R!=null&&R.surface?R==null?void 0:R.surfaceText:void 0,border:`1px solid ${(c=R==null?void 0:R.border)!=null?c:"currentColor"}`,"border-radius":(u=R==null?void 0:R.radius)!=null?u:"8px"});for(let K of(a=e.children)!=null?a:[]){let oe=Kr(K,t);oe&&S.appendChild(oe)}return S}case"text":{let S=t.createElement("p");return S.textContent=e.value,P?F(S):he(S,Te(V({margin:"0","font-size":e.size?Dr[e.size]:void 0,"font-weight":e.weight?Ji[e.weight]:void 0,"text-align":e.align},Mr(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let S=t.createElement(`h${e.level}`);return S.textContent=e.value,P?F(S):he(S,{margin:"0","font-size":Hi[(d=e.size)!=null?d:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let S=t.createElement("a");if(S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),P)return F(S);let J=(h=e.emphasis)!=null?h:"primary";return he(S,{display:"inline-block",padding:Wi[(C=e.size)!=null?C:"md"],"border-radius":(f=R==null?void 0:R.radius)!=null?f:"8px",font:"inherit","font-size":e.size?Dr[e.size]:void 0,"text-decoration":J==="ghost"?"underline":"none",cursor:"pointer",background:J==="primary"?(m=R==null?void 0:R.primaryBg)!=null?m:"#111827":"transparent",color:J==="primary"?(A=R==null?void 0:R.primaryText)!=null?A:"#ffffff":(y=R==null?void 0:R.accent)!=null?y:"inherit",border:J==="secondary"?`1px solid ${(E=R==null?void 0:R.accent)!=null?E:"currentColor"}`:"none"})}case"link":{let S=t.createElement("a");return S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),P?F(S):he(S,{color:"inherit","text-decoration":"underline"})}case"image":{let S=t.createElement("img");return S.src=e.src,S.alt=e.alt,P&&(S.className=P),he(S,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?qi[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let S=t.createElement("span");return S.textContent=e.value,P?F(S):he(S,V({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(w=R==null?void 0:R.border)!=null?w:"currentColor"}`},Mr(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(b=Nr[e.size])!=null?b:Nr.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(g=R==null?void 0:R.border)!=null?g:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(P){return null}}function jr(e,t,n,r){var o,l;try{let i=new Set;for(let c of Array.from(e.children)){let u=c.getAttribute(ct);u!==null&&(t[u]===void 0?c.remove():i.add(u))}for(let[c,u]of Object.entries(t)){if(i.has(c))continue;let a="tree"in u?u:null,d=Kr(a?a.tree:u,r);if(!d)continue;let h=r.createElement("div");h.setAttribute(ct,c),h.style.display="none";let C=a?$r((o=a.surface)==null?void 0:o.like):void 0;if(C){let f=r.createElement("div");f.className=C;let m=Br((l=a.surface)==null?void 0:l.like);m&&(f.style.color=m),f.appendChild(d),h.appendChild(f)}else h.appendChild(d);e.appendChild(h)}let s=n!==void 0&&t[n]!==void 0;for(let c of Array.from(e.children)){let u=c.getAttribute(ct),a=c;u!==null?a.style.display=s&&u===n?"":"none":s?a.hasAttribute(Oe)||(a.setAttribute(Oe,a.style.display),a.style.display="none"):a.hasAttribute(Oe)&&(a.style.display=a.getAttribute(Oe),a.removeAttribute(Oe))}}catch(i){}}function Xi(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(ct)!==null){n.remove();continue}n.hasAttribute(Oe)&&(n.style.display=n.getAttribute(Oe),n.removeAttribute(Oe))}}catch(t){}}function Nt(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${ct}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${Oe}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||Xi(r)}catch(n){}}function gn(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function Mt(e,t,n,r){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t),r==null||r(n.documentElement,"data-sentient-persona"),r==null||r(n.documentElement,"data-sentient-confidence")}function $t(e,t,n,r){var o;for(let[l,i]of Object.entries(t)){let s=e[l];if(!s||typeof s=="string")continue;let c=gn(i.target,n);for(let u of c)for(let[a,d]of Object.entries(s))(o=i.dims[a])!=null&&o.includes(d)&&(u.setAttribute(`data-${a}`,d),r==null||r(u,`data-${a}`))}}function Bt(e,t,n,r){for(let[o,l]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!l.arms||!l.arms.includes(i))continue;let s=gn(l.target,n);for(let c of s)c.setAttribute("data-sentient-arm",i),r==null||r(c,"data-sentient-arm")}}function Zi(e,t){var o,l;let n=e.ownerDocument.createTreeWalker(e,4),r=null;for(let i=n.nextNode();i!==null;i=n.nextNode()){if(((o=i.nodeValue)!=null?o:"").trim()==="")continue;let s=(l=i.parentElement)==null?void 0:l.tagName;if(!(s==="SCRIPT"||s==="STYLE"||s==="TEMPLATE")){if(r!==null){e.textContent=t;return}r=i}}r!==null?r.nodeValue=t:e.textContent=t}function Kt(e,t,n,r){var s,c,u,a,d,h,C;let o=new Set,l=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[f,m]of Object.entries(t)){if(Pt(m.locator,n))continue;let A;if(m.locator){let E=Ce(m.locator,n);A=E?[E]:[],!E&&Dt(m.locator,n)&&i.push(f)}else A=gn(m.target,n);let y=e[f];for(let E of A){if(y!==void 0)if(typeof y=="string")E.setAttribute("data-sentient-arm",y),(c=r==null?void 0:r.onAttr)==null||c.call(r,E,"data-sentient-arm"),l&&((u=r==null?void 0:r.onApplied)==null||u.call(r,f,y,E));else for(let[b,g]of Object.entries(y))E.setAttribute(`data-${b}`,g),(a=r==null?void 0:r.onAttr)==null||a.call(r,E,`data-${b}`);if((m.blocks||m.compose)&&!es(n)){let b=Object.fromEntries([...Object.entries((d=m.blocks)!=null?d:{}).filter(([,g])=>!it(g)),...Object.entries((h=m.compose)!=null?h:{}).filter(([,g])=>!it(g.tree))]);Object.keys(b).length>0&&(jr(E,b,typeof y=="string"?y:void 0,n),o.add(E))}if(!l)continue;let w=E.textContent;m.edits?kr(E,m.edits.edits,m.edits)==="mismatch"&&((C=r==null?void 0:r.onDrift)==null||C.call(r,f,m.edits.fp)):typeof m.content=="string"&&Zi(E,m.content),m.ops&&Pr(E,m.ops,f,n).anchorMiss&&!i.includes(f)&&i.push(f),cn(E,Te(V(V({previous:w},typeof y=="string"?{arm:y}:{}),(r==null?void 0:r.persona)!==void 0?{persona:r.persona}:{}),{doc:n}))}}return Nt(n,o),i}var Qi=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function es(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:Qi.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var ts=800;function jt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:l,el:i},s)=>{r.push(st((h,C={})=>{try{e.track({projectId:t,componentId:o,variantId:l,eventType:"micro_signal",payload:V({signalType:h},C)})}catch(f){}},i,void 0,{tabLoss:s===0}));let c=null,u=0,a=()=>{u=Date.now(),c=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:l,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}})}catch(h){}c=null},ts)},d=()=>{c!==null&&(clearTimeout(c),c=null)};i.addEventListener("mouseenter",a),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",a),i.removeEventListener("mouseleave",d),c!==null&&clearTimeout(c)})}),()=>{for(let o of r)o()}}function ns(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function Gr(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var rs="_snt_fired_goals";function Fr(e,t){try{e==null||e.sessionStorage.removeItem(Gr(t)),e==null||e.sessionStorage.removeItem(rs)}catch(n){}}function Ur(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function os(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function is(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function Ut(e,t,n,r){var y,E;let o=(y=n.defaultView)!=null?y:typeof window!="undefined"?window:null,l=Gr(r),i=os(o,l),s=w=>{let b=Ur(w);if(!i.has(b))try{w.slotId?t.componentGoal(w.slotId,w.goalId):t.goal(w.goalId),i.add(b),is(o,l,i)}catch(g){}},c=e.filter(w=>w.event==="click"),u=e.filter(w=>w.event==="form_submit"),a=e.filter(w=>w.event==="url_reached"),d=e.filter(w=>w.event==="scroll_depth"),h=(w,b)=>{if(!w.locator)return!1;let g=Ce(w.locator,n);return!!g&&(g===b||g.contains(b))},C=w=>{let b=w.target;if(!(!b||typeof b.closest!="function"))for(let g of c)h(g,b)&&s(g)},f=w=>{let b=w.target;if(b)for(let g of u)h(g,b)&&s(g)},m=()=>{if(a.length===0)return;let w=ut(n);for(let b of a)b.urlPattern&&ns(b.urlPattern,w)&&s(b)},A=()=>{var g;let w=n.documentElement,b=w.scrollHeight>0?(w.scrollTop+w.clientHeight)/w.scrollHeight:0;for(let P of d)b>=((g=P.threshold)!=null?g:.75)&&s(P);d.every(P=>i.has(Ur(P)))&&n.removeEventListener("scroll",A)};return n.addEventListener("click",C,!0),n.addEventListener("submit",f,!0),(E=n.defaultView)==null||E.addEventListener("popstate",m),m(),d.length>0&&(n.addEventListener("scroll",A,{passive:!0}),A()),{checkUrl:m,teardown:()=>{var w;n.removeEventListener("click",C,!0),n.removeEventListener("submit",f,!0),(w=n.defaultView)==null||w.removeEventListener("popstate",m),d.length>0&&n.removeEventListener("scroll",A)}}}function Gt(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),l=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(l.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return l}var zr="__snt_editor_token";function Vr(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(zr):null}catch(e){return null}}function Hr(e){try{sessionStorage.setItem(zr,e)}catch(t){}}var pt="0.30.3",Vt=pt!=="0.0.0-dev"?{name:"snippet",version:pt}:void 0,eo=pt!=="0.0.0-dev"?{v:pt}:{},mt=5e3,ss=50,to=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),le=null,j=null,Se={},ve=null,se=null,De=null,ce=null,_e=null,ne=null,je=null,Wr=!1,hn=null,Ft=null,Ht=null,Ue=!1,dt=!1,Ne=!1,Ge=null,Me=[],Wt=null,ft=null,ye=null,as=3e3,ls=100;function gt(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function Ae(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Ye(e,t){return le?(le.personaAttributes&&ne&&Mt(ne.persona,ne.band,e,t==null?void 0:t.onAttr),$t(Se,le.slots,e,t==null?void 0:t.onAttr),Bt(Se,le.slots,e,t==null?void 0:t.onAttr),ve?Kt(Se,ve,e,V(Te(V({},t),{onDrift:(n,r)=>{var o,l;return(l=j==null?void 0:j.reportDrift)==null?void 0:l.call(j,n,r,(o=io[n])!=null?o:null,"fp_mismatch")}}),ne?{persona:ne.persona}:{})):(Nt(e,new Set),[])):[]}function no(e){var n;let t=new Map;for(let r of(n=le==null?void 0:le.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function yn(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=Gt(e,no(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function us(e,t,n){let r=(o,l)=>t.some(([i,s])=>i===o&&s===l);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[l,i,s]=o;!l||typeof i!="string"||r(l,i)||(s==null?l.removeAttribute(i):l.setAttribute(i,s))}if(Array.isArray(e.html))for(let o of e.html)typeof o!="string"||r(n.documentElement,o)||n.documentElement.removeAttribute(o)}catch(o){}}function cs(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function ro(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function ht(e){var t;return(t=e.apiBase)!=null?t:"https://api.sentient-ui.com"}function ds(e){return Promise.resolve().then(()=>fetch(`${ht(e)}/v1/registry/locators`,{headers:{authorization:`Bearer ${e.apiKey}`}})).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t==null?void 0:t.slots)?t.slots:null).catch(()=>null)}function oo(e,t){let n=[],r=[];for(let o of e)try{if(typeof(o==null?void 0:o.id)!="string")continue;!o.locator||_r(o.locator,t)?n.push(o.id):Dt(o.locator,t)&&r.push(o.id)}catch(l){}return[n,r]}var io={};function so(e,t){var r;let n={};for(let o of e){let l=(r=Ge==null?void 0:Ge.find(u=>u.id===o))==null?void 0:r.locator,i=l?Ce(l,t):null,s=i?Tt(i):null,c=s&&"fp"in s?s.fp:void 0;c&&(io[o]=c),n[o]=Te(V({},c?{fp:c}:{}),{forms:!1,compose:!0,content:!0})}return n}function ao(e,t){let n=null;for(let r of t)e!=null&&e[r]&&((n!=null?n:n={})[r]=e[r]);return n}function lo(){!Ge||!Ue||Wt===window.location.pathname||(Wt=window.location.pathname,fs())}function fs(){ye==null||ye();let e=le,t=Ge;if(!e||!t)return;let n,r,o=()=>{clearTimeout(n),clearTimeout(s),r==null||r.disconnect(),ye===o&&(ye=null)},l=null,i=c=>{let[u,a]=oo(t,document),d=u.filter(h=>!Me.includes(h));l!==null&&u.some(h=>!l.has(h)&&!d.includes(h))&&yt(),l=new Set(u),d.length>0&&ps(d).catch(()=>{}),(c||a.length===0&&!t.some(h=>!u.includes(h.id)&&!Me.includes(h.id)))&&(o(),uo(e,a))},s=setTimeout(()=>i(!0),as);if(ye=o,i(),ye===o)try{r=new MutationObserver(()=>{clearTimeout(n),n=setTimeout(i,ls)}),r.observe(document.documentElement,{childList:!0,subtree:!0})}catch(c){}}async function ps(e){let t=le,n=j;if(!t||!n)return;Me=Me.concat(e);let r=await gt(n.decide(V({slotsFrom:"registry",registrySlotIds:e,render:so(e,document)},eo)),mt);if(r||(Me=Me.filter(l=>!e.includes(l))),!r||Ne||j!==n)return;Se=V(V({},Se),r.slots);let o=ao(r.slotConfig,e);o&&(ve=V(V({},ve),o)),yt(),Ae(t,"late decide",e),ft&&He(t.apiKey,ft=V(Te(V({},ft),{slots:Se,savedAt:Date.now()}),ve?{slotConfig:ve}:{}))}function uo(e,t){if(t.length!==0)try{fetch(`${ht(e)}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(n){}}function Xe(){return!!(le&&j&&le.sectionCapture!==!1&&(le.consent!==!1||dt)&&!Be())}function ms(){if(!j||!le||!Xe()||_e)return;let e=[];Ye(document,{contentAndOps:Ue,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),vn();try{ce==null||ce(),ce=jt(j,le.apiKey,e)}catch(t){}}function vn(){if(typeof document=="undefined"||!Xe())return;let e;try{if(Ft&&Ft.length>0){let t=new Map;for(let n of Ft){if(n.urlMatch!==window.location.pathname)continue;let r=Ce(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{_e=Er(j,V({apiKey:le.apiKey,apiBase:le.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Ht=window.location.pathname}catch(t){}}function yt(){try{let e=[];if(ce==null||ce(),ce=null,Ye(document,{contentAndOps:Ue,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),yn(je,document),e.length>0&&Xe())try{ce=jt(j,le.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Ht!==null&&window.location.pathname!==Ht&&Xe()&&(_e==null||_e(),_e=null,vn())}catch(t){}}catch(e){}}function qr(){hn===null&&(hn=setTimeout(()=>{hn=null,yt();try{se==null||se.checkUrl()}catch(e){}lo()},ss))}function bn(){if(!(Wr||typeof window=="undefined"||typeof history=="undefined")){Wr=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,l){let i=n.call(this,r,o,l!=null?l:null);return qr(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",qr)}catch(e){}}}function zt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function co(e){return new URLSearchParams(e).get("sentient_editor")}function gs(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function hs(e,t){var n,r,o;try{window.__sentientEditor={token:t,apiBase:ht(e)};try{let s=document.createElement("meta");s.name="referrer",s.content="no-referrer",s.setAttribute("data-sentient-editor",""),((n=document.head)!=null?n:document.documentElement).appendChild(s)}catch(s){}let l=(r=e.editorSrc)!=null?r:gs();if(!l){Yr();return}let i=document.createElement("script");i.src=l,i.async=!0,i.onerror=()=>Yr(),((o=document.head)!=null?o:document.documentElement).appendChild(i)}catch(l){}}var Jr="sentient-editor-load-notice",fo={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function Yr(){var e,t;try{if(typeof document=="undefined"||document.getElementById(Jr))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=Jr,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,fo,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function po(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),l=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!l||!i))if(i.includes("=")){let s={};for(let c of i.split(",")){let[u,a]=c.split("=");u&&a&&(s[u]=a)}Object.keys(s).length&&(n[l]=s)}else n[l]=i}return Object.keys(n).length?n:null}function mo(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var Xr="sentient-persona-preview-banner";function Zr(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(Xr))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=Xr,o.setAttribute("role","status"),Object.assign(o.style,fo,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let l=document.createElement("span");l.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(l),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function ys(e,t){var r;if((r=e.registry)!=null?r:Object.keys(e.slots).length===0){let o=ht(e),i=await gt(fetch(`${o}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slotsFrom:"registry",includeDrafts:!0,force:Object.fromEntries(Object.entries(t).filter(s=>typeof s[1]=="string"))})}).then(s=>s.ok?s.json():null).catch(()=>null),mt);if(!(i!=null&&i.slotConfig)){Ze(e),Ae(e,"preview mode: slot config unavailable \u2014 page left as-is");return}ve=i.slotConfig,qe(i.palette),Je(i.vocabulary)}Se=t,ne=null,Ye(document),bn(),Ze(e),Ae(e,"preview mode",t)}async function vs(e,t){var u,a,d,h,C,f,m,A,y;let n=ht(e),o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([E,w])=>({id:E,dims:w.dims}))},l=await gt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(E=>E.ok?E.json():null).catch(()=>null),mt);if(!l){Ze(e),Ae(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=l;Se=(a=i.slots)!=null?a:{},ve=(d=i.slotConfig)!=null?d:null,qe(i.palette),Je(i.vocabulary);let s=(f=(C=(h=i.personaAttributes)==null?void 0:h.persona)!=null?C:i.persona)!=null?f:t,c=(A=(m=i.personaAttributes)==null?void 0:m.confidence)!=null?A:"high";ne={persona:s,band:c},Ye(document),Ue=!0,bn(),Ze(e),i.recognized===!1?Zr(t,!0):Zr((y=i.personaDisplay)!=null?y:s)}function Ze(e){let t={goal(n,r){try{j==null||j.goal(n,r)}catch(o){}},componentGoal(n,r){try{j==null||j.componentGoal(n,r)}catch(o){}},grantConsent(){try{!j&&Ne?(j=at(V({apiKey:e.apiKey,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:ro(e)},Vt?{sdk:Vt}:{})),De&&De.length>0&&(se==null||se.teardown(),se=Ut(De,j,document,e.apiKey))):(dn(e.apiKey),j&&De&&De.length>0&&(se==null||se.teardown(),se=Ut(De,j,document,e.apiKey))),Ne=!1}catch(n){}dt=!0;try{ms()}catch(n){}},revokeConsent(){try{_e==null||_e(),_e=null,Ht=null,ce==null||ce(),ce=null,ye==null||ye(),se==null||se.teardown(),se=null,Fr(typeof window!="undefined"?window:null,e.apiKey),dt=!1,Ne=!0,j==null||j.destroy(),j=null}catch(n){}},reapply:yt,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=ne==null?void 0:ne.persona)!=null?n:null,band:(r=ne==null?void 0:ne.band)!=null?r:null,slots:Se,matchCounts:zt(e),consent:!Ne&&(e.consent!==!1||dt)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};window.SentientSnippet=t;for(let n of to.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function Qr(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},to.length=0}catch(t){}}async function go(){var e,t;try{let n=Rt(window.sentient);if(!n){Qr();return}le=n,Ue=!1,je=null,qe(null),Je(null),dt=!1,Ne=!1,De=null,Ge=null,Me=[],Wt=null,ft=null,ye==null||ye();let r=typeof window!="undefined"?co(window.location.search):null;if(r){Hr(r);try{let g=new URL(window.location.href);g.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",g.pathname+g.search+g.hash)}catch(g){}}let o=r!=null?r:Vr();if(o){hs(n,o),Ze(n),Ae(n,"editor mode");return}let l=typeof window!="undefined"?po(window.location.search):null;if(l){await ys(n,l);return}let i=typeof window!="undefined"?mo(window.location.search):null;if(i){await vs(n,i),Ae(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0;n.registry===void 0&&!s&&Ae(n,"slots declared without registry: true, so dashboard-published components are not applied");let c=s?ds(n):null,u=cs();try{(t=u==null?void 0:u.stop)==null||t.call(u)}catch(g){}let a=ot(n.apiKey),d=[];a&&(ne={persona:a.persona,band:a.band},Se=a.slots,a.slotConfig&&(ve=a.slotConfig),a.palette&&qe(a.palette),a.vocabulary&&Je(a.vocabulary),Ye(document,V({contentAndOps:!1},u?{onAttr:(g,P)=>d.push([g,P])}:{})),a.layoutOrder&&(je=a.layoutOrder,yn(je,document))),u&&us(u,d,document);let h=at(V({apiKey:n.apiKey,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:ro(n)},Vt?{sdk:Vt}:{}));j=h,Ze(n),bn();let C=Object.entries(n.slots).map(([g,P])=>({id:g,dims:P.dims})),f=eo,m={pp:u?u.v:0},A=Array.from(no(document).keys()),y=[];if(c){let[g]=await Promise.all([gt(c,mt),document.readyState==="loading"?new Promise(P=>document.addEventListener("DOMContentLoaded",P,{once:!0})):null]);Ge=g,g&&(Me=y=oo(g,document)[0]),Ae(n,"registry scope",g&&y)}let E=h.decide(V(V(V(V({slots:C},f),m),A.length>=2?{sections:A}:{}),s?{slotsFrom:"registry",registrySlotIds:y,render:so(y,document)}:{})),w=await gt(E,mt),b=g=>{var F,S,J,z,K;let P=h.getPersona();P?ne={persona:P.persona,band:P.band}:g.persona&&(ne={persona:g.persona,band:"low"}),Se=g.slots,s?ve=ao(g.slotConfig,y):g.slotConfig&&(ve=g.slotConfig),g.palette&&qe(g.palette),g.vocabulary&&Je(g.vocabulary),je=(F=g.layoutOrder)!=null?F:je;let I=()=>{let oe=[],x=Ye(document,{onApplied:(N,X,Y)=>oe.push({slotId:N,arm:X,el:Y})});if(s||uo(n,x),yn(je,document),Ue=!0,Xe())try{ce==null||ce(),ce=jt(j,n.apiKey,oe)}catch(N){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",I,{once:!0}):I(),De=(S=g.goals)!=null?S:null,g.goals&&g.goals.length>0&&n.consent!==!1&&j)try{se==null||se.teardown(),se=Ut(g.goals,j,document,n.apiKey)}catch(oe){}Ft=(J=g.sectionMap)!=null?J:null,Xe()&&vn(),Ae(n,"applied",{persona:ne,slots:Se,matches:zt(n)}),!Ne&&(He(n.apiKey,ft=V(V(V({v:1,persona:(z=ne==null?void 0:ne.persona)!=null?z:g.persona,band:(K=ne==null?void 0:ne.band)!=null?K:"low",slots:g.slots,layoutOrder:g.layoutOrder,savedAt:Date.now()},ve?{slotConfig:ve}:{}),g.palette?{palette:g.palette}:{}),g.vocabulary?{vocabulary:g.vocabulary}:{})),Wt=null,lo())};if(!w){Ae(n,"decide timeout/null \u2014 snapshot state stands",zt(n)),E.then(g=>{!g||Ue||Ne||j!==h||(b(g),Ae(n,"late decide applied",zt(n)))}).catch(()=>{});return}b(w)}catch(n){Qr()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{go()}))}return xo(bs);})();
|
|
1
|
+
"use strict";var SentientSnippet=(()=>{var At=Object.defineProperty,Ao=Object.defineProperties,xo=Object.getOwnPropertyDescriptor,Co=Object.getOwnPropertyDescriptors,_o=Object.getOwnPropertyNames,Pn=Object.getOwnPropertySymbols;var Nn=Object.prototype.hasOwnProperty,Oo=Object.prototype.propertyIsEnumerable;var Dn=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,V=(e,t)=>{for(var n in t||(t={}))Nn.call(t,n)&&Dn(e,n,t[n]);if(Pn)for(var n of Pn(t))Oo.call(t,n)&&Dn(e,n,t[n]);return e},Te=(e,t)=>Ao(e,Co(t));var Mn=(e,t)=>()=>(e&&(t=e(e=0)),t);var $n=(e,t)=>{for(var n in t)At(e,n,{get:t[n],enumerable:!0})},Io=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _o(t))!Nn.call(e,o)&&o!==n&&At(e,o,{get:()=>t[o],enumerable:!(r=xo(t,o))||r.enumerable});return e};var Lo=e=>Io(At({},"__esModule",{value:!0}),e);var To,Ro,Po,Bn,Do,No,Kn,B,Re,ot=Mn(()=>{"use strict";To=Object.defineProperty,Ro=Object.defineProperties,Po=Object.getOwnPropertyDescriptors,Bn=Object.getOwnPropertySymbols,Do=Object.prototype.hasOwnProperty,No=Object.prototype.propertyIsEnumerable,Kn=(e,t,n)=>t in e?To(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,B=(e,t)=>{for(var n in t||(t={}))Do.call(t,n)&&Kn(e,n,t[n]);if(Bn)for(var n of Bn(t))No.call(t,n)&&Kn(e,n,t[n]);return e},Re=(e,t)=>Ro(e,Po(t))});var Xn={};$n(Xn,{LOCAL_ENGINE_AVAILABLE:()=>Vo,createLocalEngine:()=>Wo});function Wo(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Vo,Zn=Mn(()=>{"use strict";Vo=!1});var Ls={};$n(Ls,{applyPersonaAttributes:()=>Ut,applyRegistrySlots:()=>zt,applySlotArms:()=>Ft,applySlotAttributes:()=>Gt,consentWatcher:()=>$e,parseEditorToken:()=>yo,parsePersonaPreview:()=>wo,parsePreview:()=>bo,parseSnippetConfig:()=>$t,planReorder:()=>Ht,reapply:()=>bt,run:()=>So,version:()=>gt});var _t=e=>{try{return decodeURIComponent(e)}catch(t){return e}};function xt(e,t){if(e)for(let n of e.cookie.split(";")){let r=n.indexOf("=");if(r>0&&n.slice(0,r).trim()===t)return n.slice(r+1).trim()}}function Ct(e,t,n){let r=[e,...e.document?[e.document]:[]];for(let o of r)for(let a of t)o.addEventListener(a,n);return()=>{for(let o of r)for(let a of t)o.removeEventListener(a,n)}}function Mo(e,t="statistics"){if(e==null||e==="")return null;let n=_t(e).trim();if(n==="-1")return!0;if(n==="0")return!1;let r=new RegExp(`[{,]\\s*${t}\\s*:\\s*(true|false)`).exec(n);return r?r[1]==="true":null}function $o(e,t="C0002"){var n;if(e==null||e==="")return null;let r=(n=/(?:^|&)groups=([^&]*)/.exec(_t(e)))==null?void 0:n[1];if(r==null)return null;for(let o of _t(r).split(",")){let[a,i]=o.split(":");if(a===t)return i==="1"}return null}function Bo(e,t="analytics"){if(e==null||e==="")return null;let n=new RegExp(`(?:^|,)${t}:(yes|no)(?:,|$)`).exec(_t(e));return n?n[1]==="yes":null}function Ko(e){var t,n,r,o,a,i;let s=typeof e=="string"?{cmp:e}:e;switch(s.cmp){case"cookiebot":return{cmp:"cookiebot",category:(t=s.category)!=null?t:"statistics"};case"onetrust":return{cmp:"onetrust",group:(n=s.group)!=null?n:"C0002"};case"cookieyes":return{cmp:"cookieyes",category:(r=s.category)!=null?r:"analytics"};case"tcf":return{cmp:"tcf",purposes:s.purposes&&s.purposes.length>0?s.purposes:[1]};case"google-consent-mode":return{cmp:"google-consent-mode",type:(o=s.type)!=null?o:"analytics_storage",dataLayer:(a=s.dataLayer)!=null?a:"dataLayer"};default:return{cmp:"custom",cookie:s.cookie,value:(i=s.value)!=null?i:"accepted",check:s.check,event:s.event}}}function jo(e,t="analytics_storage"){var n;if(!Array.isArray(e))return null;let r=null;for(let o of e){let a=o&&typeof o=="object"&&"length"in o?Array.prototype.slice.call(o):null;if(!a||a[0]!=="consent"||a[1]!=="default"&&a[1]!=="update")continue;let i=(n=a[2])==null?void 0:n[t];i==="granted"?r=!0:i==="denied"&&(r=!1)}return r}function $e(e,t=window){let n=Ko(e),r=t,o=t.document;switch(n.cmp){case"cookiebot":return{read:()=>{let a=r.Cookiebot;return a!=null&&a.consent&&typeof a.consent[n.category]=="boolean"?a.consent[n.category]===!0:Mo(xt(o,"CookieConsent"),n.category)},subscribe:a=>Ct(t,["CookiebotOnAccept","CookiebotOnDecline","CookiebotOnConsentReady","CookiebotOnLoad"],a)};case"onetrust":return{read:()=>{let a=r.OnetrustActiveGroups;return typeof a=="string"?`,${a},`.includes(`,${n.group},`):$o(xt(o,"OptanonConsent"),n.group)},subscribe:a=>Ct(t,["OneTrustGroupsUpdated"],a)};case"cookieyes":return{read:()=>{var a;let i=r.getCkyConsent;if(typeof i=="function")try{let s=(a=i())==null?void 0:a.categories;if(s&&typeof s[n.category]=="boolean")return s[n.category]===!0}catch(s){}return Bo(xt(o,"cookieyes-consent"),n.category)},subscribe:a=>Ct(t,["cookieyes_consent_update","cookieyes_banner_load","cookieyes_banner_loaded"],a)};case"tcf":{let a=null;return{read:()=>a,subscribe:i=>{let s,u=!1,c=(g,x)=>{!x||u||(typeof g.listenerId=="number"&&(s=g.listenerId),g.eventStatus==="cmpuishown"?a=!1:a=g.gdprApplies===!1||n.purposes.every(f=>{var m,E;return((E=(m=g.purpose)==null?void 0:m.consents)==null?void 0:E[f])===!0}),i())},l=0,d=()=>{if(u)return;let g=r.__tcfapi;typeof g=="function"?g("addEventListener",2,c):l++<40&&window.setTimeout(d,250)};return d(),()=>{u=!0;let g=r.__tcfapi;typeof g=="function"&&s!==void 0&&g("removeEventListener",2,()=>{},s)}}}}case"google-consent-mode":{let a=()=>r[n.dataLayer];return{read:()=>jo(a(),n.type),subscribe:i=>{var s,u;let c=(u=r[s=n.dataLayer])!=null?u:r[s]=[],l=c.push,d=function(...x){let f=l.apply(c,x);return i(),f};c.push=d;let g=window.setInterval(i,1e3);return()=>{window.clearInterval(g),c.push===d&&(c.push=l)}}}}case"custom":return{read:()=>{if(n.check)try{return n.check()===!0}catch(i){return!1}if(!n.cookie)return null;let a=xt(o,n.cookie);return a===void 0?null:a===n.value},subscribe:a=>n.event?Ct(t,[n.event],a):()=>{}}}}ot();function Ot(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function jn(e){if(e.length===0)return null;let t={};for(let n of e.split("|")){let r=n.indexOf("=");if(r<=0||r!==n.lastIndexOf("=")||r===n.length-1)return null;let o=n.slice(0,r);if(o in t)return null;t[o]=n.slice(r+1)}return t}function rn(e){var t,n,r;if(e.arms)return typeof e.baseline=="string"?e.baseline:(t=e.arms[0])!=null?t:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return Ot(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[a,i]of Object.entries((n=e.dims)!=null?n:{}))o[a]=(r=i[0])!=null?r:"";return Ot(o)}function Un(e,t){var n,r;return e.dims!=null?(r=(n=jn(t))!=null?n:jn(rn(e)))!=null?r:{}:t}function Gn(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=t+((t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24))>>>0;return t}function Be(e){return e>=.3?e<.7?"medium":"high":"low"}function It(e){return e?`_${e.slice(0,12)}`:""}var Uo="_snt_uid";function Fn(e){return`${Uo}${It(e)}`}var Go=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function zn(e){return Fo(e)!==null}function Fo(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=Go.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Vn(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function Wn(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(o){}let r=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(r)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(r)?"social":"referral"}catch(n){return"direct"}}function Hn(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var zo=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function qn(e){let t={},n={};try{let r=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([o,a])=>{let i=Array.isArray(a)?a[0]:a;return i===void 0?[]:[[o,i]]});for(let[o,a]of r)o.startsWith("utm_")?o in t||(t[o]=a):zo.includes(o)&&(o in n||(n[o]=a))}catch(r){}return{utmParams:t,clickIds:n}}function Jn(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function on(e){return B(B(B({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function sn(e){let t=on(e);return Un(t,rn(t))}function Yn(e){return typeof e=="string"?e:Ot(e)}ot();function or(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Ho="_snt_uid",qo=365,Lt="_snt_uid";function Jo(){return or()}function Qn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Yo(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function an(e){try{return localStorage.getItem(e)}catch(t){return null}}function er(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function tr(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Xo(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Zo(e){try{sessionStorage.removeItem(e)}catch(t){}}function Qo(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function ei(e){try{localStorage.removeItem(e)}catch(t){}}function ti(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var ni={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ir(e){var t,n,r,o,a,i,s;if(typeof window=="undefined")return ni;let u=It(e==null?void 0:e.apiKey),c=(t=e==null?void 0:e.cookieName)!=null?t:Fn(e==null?void 0:e.apiKey),l=`${Lt}${u}`,d=`${Lt}_tomb${u}`,g=((n=e==null?void 0:e.cookieTTLDays)!=null?n:qo)*24*60*60,x=b=>b&&b.length>0?b:null,f=()=>{var b,h;return u&&!(e!=null&&e.cookieName)&&an(d)===null?(h=(b=x(Qn(Ho)))!=null?b:x(an(Lt)))!=null?h:x(tr(Lt)):null},m=(s=(i=(a=(o=(r=x(Qn(c)))!=null?r:x(an(l)))!=null?o:x(tr(l)))!=null?a:f())!=null?i:x(e==null?void 0:e.ssrSessionId))!=null?s:Jo();Yo(c,m,g);let E=er(l,m),y=Qo(c),k=E?!1:Xo(l,m),w=!E&&!y&&!k;return{getSessionId:()=>m,isEphemeral:()=>w,destroy:()=>{m=null,ti(c),ei(l),Zo(l),u&&!(e!=null&&e.cookieName)&&er(d,"1")}}}function ze(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function pn(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function sr(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(e),r.slice(-t)):[]}catch(n){return[]}}function Ve(e,t,n){try{let r=(()=>{try{let a=localStorage.getItem(n);if(!a)return[];let i=JSON.parse(a);return Array.isArray(i)?i:[]}catch(a){return[]}})(),o=new Map;for(let a of r)o.set(a.id,a);for(let a of e)o.set(a.id,a);localStorage.setItem(n,JSON.stringify([...o.values()].slice(-t)))}catch(r){}}function ar(e,t){try{let n=localStorage.getItem(t);if(!n)return;let r=JSON.parse(n);if(!Array.isArray(r))return;let o=new Set(e),a=r.filter(i=>!o.has(i.id));if(a.length===r.length)return;a.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(a))}catch(n){}}var ri=500,oi=56*1024;function lr(e){return`_snt_retry_${e.slice(0,12)}`}var ii={push:()=>{},flush:()=>{},destroy:()=>{}};function si(e){var t,n,r;if(typeof window=="undefined")return ii;let o=(t=e.flushIntervalMs)!=null?t:5e3,a=(n=e.maxBatchSize)!=null?n:20,i=(r=e.maxRetrySize)!=null?r:100,s=e.ingestUrl,u=e.apiKey,c=lr(u),l=[],d=new Set,g=[],x=A=>{for(let N of A)f.delete(N),!d.has(N)&&(d.add(N),g.push(N));for(;g.length>ri;){let N=g.shift();N&&d.delete(N)}ar(A,c)},f=new Set,m=()=>{for(;l.length>i;){let A=l.shift();A&&f.delete(A.id)}},E=A=>{d.has(A.id)||f.has(A.id)||(f.add(A.id),l.push(A),m())},y=A=>{for(let N of A)d.has(N.id)||(f.add(N.id),l.push(N));m()},k=sr(c,i);for(let A of k)E(A);let w=0,b=0,h=(A,N=!0)=>{if(A.length===0)return;let X=JSON.stringify(A),Y=A.map(L=>L.id),ie;try{ie=fetch(s,{method:"POST",keepalive:!0,body:X,headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`}})}catch(L){Ve(A,i,c),y(A),b++,w=Date.now()+ze(b);return}let Z=L=>{if(pn(L)!=="retry"){if(!L.ok&&N){let _=A.filter(U=>U.eventType!=="pageview");if(_.length>0&&_.length<A.length){x(A.filter(U=>U.eventType==="pageview").map(U=>U.id)),h(_,!1);return}}x(Y),b=0,w=0;return}Ve(A,i,c),y(A),b++,w=Date.now()+ze(b)};ie instanceof Promise?ie.then(Z).catch(()=>{Ve(A,i,c),y(A),b++,w=Date.now()+ze(b)}):Z(ie)},P=typeof TextEncoder!="undefined"?new TextEncoder:null,I=A=>P?P.encode(A).length:A.length,F=A=>{let N=[],X=2;for(let Y of A){let ie=I(JSON.stringify(Y))+1;if(N.length>0&&X+ie>oi||N.length>=a)break;N.push(Y),X+=ie}return N},S=()=>{try{if(Date.now()<w)return;for(;l.length>0&&!(Date.now()<w);){let A=l.filter(X=>!d.has(X.id));if(l.length=0,A.length===0)break;let N=F(A);if(N.length===0)break;N.length<A.length&&l.push(...A.slice(N.length)),h(N)}}catch(A){}},J=!0,z=null;z=setInterval(()=>{J&&S()},o);let K=()=>{document.visibilityState==="hidden"&&S()},oe=()=>{S()};return document.addEventListener("visibilitychange",K),window.addEventListener("pagehide",oe),{push(A){E(A),l.length>=a&&S()},flush:S,destroy(){J=!1,z!==null&&(clearInterval(z),z=null),document.removeEventListener("visibilitychange",K),window.removeEventListener("pagehide",oe),S()}}}var ai=200;function ur(e){return`_snt_goal_retry_${e.slice(0,12)}`}var li={send:()=>{},flush:()=>{},destroy:()=>{}};function ui(e){var t,n,r;if(typeof window=="undefined")return li;let o=(t=e.flushIntervalMs)!=null?t:5e3,a=(n=e.maxRetrySize)!=null?n:100,i=(r=e.maxPerFlush)!=null?r:5,s=ur(e.apiKey),u=[],c=new Set,l=new Set,d=[],g=0,x=0,f=!1,m=I=>{for(c.delete(I.id),l.has(I.id)||(l.add(I.id),d.push(I.id));d.length>ai;){let F=d.shift();F&&l.delete(F)}ar([I.id],s)},E=I=>{Ve([I],a,s),!l.has(I.id)&&!c.has(I.id)&&(c.add(I.id),u.push(I)),Date.now()>=g&&(x++,g=Date.now()+ze(x))},y=I=>{let F;try{F=fetch(e.url,{method:"POST",keepalive:!0,body:I.body,headers:e.headers})}catch(J){E(I);return}let S=J=>{var z;let K=pn(J);if(K==="retry"){E(I);return}K==="dropped"&&((z=e.onDrop)==null||z.call(e,I,J.status)),m(I),x=0,g=0};F instanceof Promise?F.then(S).catch(()=>E(I)):S(F)},k=()=>{try{if(f||Date.now()<g)return;let I=0;for(;u.length>0&&I<i&&!(Date.now()<g);){let F=u.shift();c.delete(F.id),!l.has(F.id)&&(I++,y(F))}}catch(I){}},w=sr(s,a);for(let I of w)c.has(I.id)||(c.add(I.id),u.push(I));w.length>0&&Ve(w,a,s);let b=setInterval(k,o),h=()=>{document.visibilityState==="hidden"&&k()},P=()=>k();return document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",P),{send(I){if(!f&&!(l.has(I.id)||c.has(I.id))){if(Date.now()<g){Ve([I],a,s),c.add(I.id),u.push(I);return}y(I)}},flush:k,destroy(){clearInterval(b),document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",P),k(),f=!0}}}var ci=1800*1e3;function Tt(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function di(e=ci,t){let n=new Map,r=`_snt_asgn${It(t)}_`,o=(u,c)=>`${r}${encodeURIComponent(u)}:${encodeURIComponent(c)}`,a=u=>{let c=u.slice(r.length),l=c.indexOf(":");if(l<0)return null;try{return{componentId:decodeURIComponent(c.slice(0,l)),segment:decodeURIComponent(c.slice(l+1))}}catch(d){return null}},i=()=>{try{let u=[];for(let c=0;c<localStorage.length;c++){let l=localStorage.key(c);l!=null&&l.startsWith(r)&&u.push(l)}return u}catch(u){return[]}},s=u=>u.assignedAt+(u.ttlMs&&u.ttlMs>0?u.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let u of i())try{let c=localStorage.getItem(u);if(!c)continue;let l=JSON.parse(c);if(s(l)){localStorage.removeItem(u);continue}let d=a(u);if(!d)continue;n.set(Tt(d.componentId,d.segment),l)}catch(c){}})(),{get(u,c){let l=n.get(Tt(u,c));return l?s(l)?(n.delete(Tt(u,c)),null):l:null},set(u,c,l){let d=Tt(u,c);n.set(d,l);try{localStorage.setItem(o(u,c),JSON.stringify(l))}catch(g){}},clear(){n.clear();for(let u of i())try{localStorage.removeItem(u)}catch(c){}}}}var Dt="_snt_snap:",fi=["low","medium","high"];function st(e){try{let t=localStorage.getItem(Dt+e);if(!t)return null;let n=JSON.parse(t);if(!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!fi.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig)))return null;let r=n.vocabulary;return r!==void 0&&(typeof r!="object"||r===null||!Array.isArray(r.entries)||!Array.isArray(r.images))&&delete n.vocabulary,n}catch(t){return null}}function He(e,t){try{localStorage.setItem(Dt+e,JSON.stringify(t))}catch(n){}}var dn="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",cr="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",nr=!1,Rt=!1;function pi(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function mi(e){var t;let n=ir({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=(t=n.getSessionId())!=null?t:"local",o=pi(),a=Promise.resolve().then(()=>(Zn(),Xn)).then(l=>{let d=l;return d.LOCAL_ENGINE_AVAILABLE?(nr||(nr=!0,console.info(cr)),d):(Rt||(Rt=!0,console.error(dn)),null)}).catch(()=>(Rt||(Rt=!0,console.error(dn)),null)),i=null,s={low:.15,medium:.5,high:.85},u=(()=>{var l;if(e.initialPersona)return B({},e.initialPersona);let d=st(e.apiKey||"local");return d?{persona:d.persona,confidence:(l=s[d.band])!=null?l:.15}:null})();function c(l){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=l.persona,d.dataset.sentientConfidence=Be(l.confidence))}return{isLocal:!0,async decide(l){var d,g,x;let f=await a;if(!f)return null;let m=f.createLocalEngine({sessionId:r,forcedPersona:o}).decide(l);return i=Re(B({},m),{layoutOrder:(g=(d=m.layoutOrder)!=null?d:i==null?void 0:i.layoutOrder)!=null?g:null,slots:B(B({},(x=i==null?void 0:i.slots)!=null?x:{}),m.slots)}),He(e.apiKey||"local",{v:1,persona:i.persona,band:Be(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),c(m),m},getSlotResult(l){var d,g,x;return(x=(g=i==null?void 0:i.slots[l])!=null?g:(d=e.initialSlots)==null?void 0:d[l])!=null?x:null},getSlotConfig(l){var d,g;return(g=(d=e.initialSlotConfig)==null?void 0:d[l])!=null?g:null},getSitePalette(){var l;return(l=e.initialPalette)!=null?l:null},reportSlots(){},getPersona(){let l=i!=null?i:u;return l?{persona:l.persona,confidence:l.confidence,band:Be(l.confidence)}:null},async assign(l,d){var g;let x=await a;return!x||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(g=x.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:l,variantIds:d}]}).assignments[l])!=null?g:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var Nt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function ln(e){let t=e.split(/[?#]/)[0]||"/";return t.length>1?t.replace(/\/+$/,"")||"/":t}function mn(e,t){if(e===void 0||!Nt.test(e))return!1;if(e==="*")return!0;let n=ln(t);if(e.endsWith("/*")){let r=ln(e.slice(0,-2));return n.startsWith(r==="/"?"/":`${r}/`)&&n!==r}return n===ln(e)}function at(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return t.type==="form"?!0:Array.isArray(t.children)?t.children.some(at):!1}var rr="sentient-reveal",We="sentient-revealed";var un=!1;function gi(e){if(un||e.getElementById(rr)){un=!0;return}let t=e.createElement("style");t.id=rr,t.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${We}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${We}{animation:${We} 240ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(t),un=!0}function gn(e,t={}){var n;let r=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!r||!(e instanceof Element)||(t.arm!==void 0&&e.setAttribute("data-sentient-arm",t.arm),t.persona!==void 0&&e.setAttribute("data-sentient-persona",t.persona),t.previous!==void 0&&t.previous===e.textContent))return!1;gi(r),e.classList.remove(We),e.offsetWidth,e.classList.add(We);let o=()=>{e.classList.remove(We),e.removeEventListener("animationend",o)};return e.addEventListener("animationend",o),!0}function lt(e,t,n,r){let o=[];{let a=!1,i=[],s=()=>{if(a)return;let u=Date.now();for(i.push(u);i.length>0&&u-i[0]>500;)i.shift();i.length>=3&&(a=!0,e("rage_click"))};t.addEventListener("click",s),o.push(()=>t.removeEventListener("click",s))}{let a=!1,i=s=>{if(a||!(s.target instanceof Node)||!t.contains(s.target)&&t!==s.target)return;a=!0;let u=typeof window!="undefined"?window.getSelection():null,c=u?u.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",i),o.push(()=>document.removeEventListener("copy",i))}{let a=!1,i=!1,s=null,u=()=>{s!==null&&(clearTimeout(s),s=null)},c=()=>{a||!i||(u(),s=setTimeout(()=>{!a&&i&&(a=!0,e("scroll_hesitation"))},3e3))},l=()=>{u(),c()},d=x=>{for(let f of x)i=f.intersectionRatio>.3,i?c():u()},g=new IntersectionObserver(d,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",l,{passive:!0}),o.push(()=>{g.disconnect(),window.removeEventListener("scroll",l),u()})}if((r==null?void 0:r.tabLoss)!==!1){let a=!1,i=n!=null?n:Date.now(),s=()=>{if(a||document.visibilityState!=="hidden")return;let u=Date.now()-i;u<15e3&&(a=!0,e("tab_loss",{timeOnPage:u}))};document.addEventListener("visibilitychange",s),o.push(()=>document.removeEventListener("visibilitychange",s))}return()=>{for(let a of o)a()}}function hi(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var dr="https://api.sentient-ui.com/v1/events",we=new Map,fr=null;function yi(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var vi=3;function cn(){return or()}function Pt(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function bi(){let e=new WeakMap,t=new Map,n=!1,r=(s,u,c)=>{let l=s.get(u);return c===null?l?!0:(s.set(u,new Set),!1):l?l.has(c)?!0:(l.add(c),!1):(s.set(u,new Set([c])),!1)},o=typeof window!="undefined"&&"event"in window,a=()=>{if(!o)return;let s=window.event;return typeof Event=="function"&&s instanceof Event?s:void 0},i=()=>{if(o){Promise.resolve().then(()=>{n=!1,t.clear()});return}let s=!1,u=()=>{s||(s=!0,n=!1,t.clear())};if(setTimeout(u,0),typeof MessageChannel=="function"){let c=new MessageChannel;c.port1.onmessage=()=>{c.port1.close(),c.port2.close(),u()},c.port2.postMessage(0)}};return{firedBefore(s,u){let c=a();if(c){let d=e.get(c);return d||(d=new Map,e.set(c,d)),r(d,s,u)}let l=r(t,s,u);return!l&&!n&&(n=!0,i()),l}}}var pr=new Set;function wi(e,t,n){let r=typeof window=="undefined"?null:window.history;if(!r)return()=>{};let o=!1,a,i=()=>{if(o)return;let c=Pt();!c||c===a||(a=c,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${c}`))},s=[];for(let c of["pushState","replaceState"]){let l=r[c],d=function(...g){let x=l.apply(this,g);return i(),x};r[c]=d,s.push([c,l,d])}window.addEventListener("popstate",i);let u=Pt();return u&&pr.has(`${t}:${u}`)?a=u:i(),()=>{if(!o){o=!0,window.removeEventListener("popstate",i);for(let[c,l,d]of s)r[c]===d&&(r[c]=l)}}}var it={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function Si(){try{return qn(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function mr(e){return e.replace(/\/events\/?$/,"")}function Ke(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function hn(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:fr;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=we.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:a,reinit:i}=r;if(!a){r.upgradeBlockedReason&&console.warn(r.upgradeBlockedReason);return}if(o.respectDoNotTrack!==!1&&Ke())return;let s=(i!=null?i:ut)(Re(B({},o),{consent:!0}));a(s);let u=(t=we.get(n))==null?void 0:t.dispose;we.set(n,{config:Re(B({},o),{consent:!0}),upgrade:null,dispose:u})}function Ei(e){var t;let n=e.preConsentBehavior==="statistical_winner",r=mr((t=e.ingestUrl)!=null?t:dr),o={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a=new Map,i=new Map,s={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(f,m,E){if(!n)return Promise.resolve(null);let y=a.get(f);return y?Promise.resolve(y):fn(i,f,async()=>{try{let k=new URLSearchParams({componentId:f});for(let h of m!=null?m:[])k.append("variantIds[]",h);let w=await fetch(`${r}/winner?${k.toString()}`,{headers:o});if(!w.ok)return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null;let b={variantId:(await w.json()).variantId,assignmentTtlMs:0};return a.set(f,b),b}catch(k){return m!=null&&m[0]?{variantId:m[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},u=!1,c=new Set,l=[],d=[],g={track:f=>s.track(f),goal:((f,m,E,y)=>s.goal(f,m,E,y)),componentGoal:(f,m,E)=>s.componentGoal(f,m,E),identify:f=>s.identify(f),getAssignment:(f,m)=>s.getAssignment(f,m),assign:(f,m,E,y)=>s.assign(f,m,E,y),decide:f=>s.decide(f),getSlotResult:f=>s.getSlotResult(f),isSlotDecided:f=>{var m,E;return(E=(m=s.isSlotDecided)==null?void 0:m.call(s,f))!=null?E:!0},getSlotConfig:f=>s.getSlotConfig(f),getSitePalette:()=>s.getSitePalette(),getStyleVocabulary:()=>{var f,m;return(m=(f=s.getStyleVocabulary)==null?void 0:f.call(s))!=null?m:null},reportSlots:(f,m,E,y)=>s.reportSlots(f,m,E,y),reportSkeleton:(f,m)=>{var E;return(E=s.reportSkeleton)==null?void 0:E.call(s,f,m)},reportDrift:(f,m,E,y)=>{var k;return(k=s.reportDrift)==null?void 0:k.call(s,f,m,E,y)},requestSlots:(f,m,E)=>{var y;return u?(y=s.requestSlots)==null?void 0:y.call(s,f,m,E):l.push([f,m,E])},decideSlots:f=>{var m;return u?(m=s.decideSlots)==null?void 0:m.call(s,f):d.push(...f)},cancelSlots:f=>{var m;if(u)return(m=s.cancelSlots)==null?void 0:m.call(s,f);let E=new Set(f);for(let y of l)y[0]=y[0].filter(k=>!E.has(k));d=d.filter(y=>!E.has(y.id))},onSlotsChanged:f=>(c.add(f),()=>{c.delete(f)}),getPersona:()=>s.getPersona(),fetchWeights:()=>s.fetchWeights(),getGraph:()=>s.getGraph(),flush:()=>s.flush(),dispose:()=>s.dispose(),destroy:()=>s.destroy()};function x(f){var m,E,y;s=f,u=!0,(m=f.onSlotsChanged)==null||m.call(f,()=>c.forEach(k=>k()));for(let[k,w,b]of l.splice(0))k.length>0&&((E=f.requestSlots)==null||E.call(f,k,w,b));d.length>0&&((y=f.decideSlots)==null||y.call(f,d.splice(0)))}return{proxy:g,setInner:x}}function fn(e,t,n){let r=e.get(t);if(r)return r;let o=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,o),o}function ut(e){var t,n,r,o,a,i,s,u,c,l;if(typeof window=="undefined")return it;fr=e.apiKey||"local";let d=we.get(e.apiKey||"local");if(d!=null&&d.dispose)try{d.dispose()}catch(p){}let g=e.respectDoNotTrack!==!1&&Ke(),x=e.consent===!1||g,f=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!f&&e.localMode!==!1)return we.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),x?it:mi(e);if(x){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),we.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),it;let{proxy:p,setInner:v}=Ei(e);return we.set(e.apiKey,{config:e,upgrade:g?null:v}),p}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),it;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),it;let m=(t=e.ingestUrl)!=null?t:dr,E=Date.now(),y=ir({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),k=di(void 0,e.apiKey),w=si({ingestUrl:m,apiKey:e.apiKey}),b=mr(m),h={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},P=new Set,I=ui({url:`${b}/goals`,apiKey:e.apiKey,headers:h,onDrop:(p,v)=>{if(!e.debug){if(P.has(v))return;P.add(v)}console.warn(`[sentient] goal dropped (HTTP ${v}) \u2014 this will not be retried. `+(v===400?"The session was not found: call init() and let the session upsert complete before firing goals.":v===401||v===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),p)}}),F=Vn((n=navigator.userAgent)!=null?n:""),S=window.location.origin,J=Wn((r=document.referrer)!=null?r:"",S),z=(o=e.sessionSegment)!=null?o:`${F}:${J}`,K=new Map,oe=new Map,A=new Map,N=new Set,X=new Map,Y=null,ie=null,Z=null,L=new Set,_=new Set,U=new Map,Q=new Map,T=new Set,re=new Set,be=new Set,me=null,wt=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,xn=new Set,St=new Set,Et=new Set,tt=new Map,Qt=null,kt=new Set,nt=new Map,en=null,Eo=2,Cn=new Map,tn=!1,_n=(p,v,M)=>{var W;let G=new Set,C=1;for(let O of p){v.delete(O);let $=((W=Cn.get(O))!=null?W:0)+1;Cn.set(O,$),$<=Eo&&(G.add(O),$>C&&(C=$))}G.size>0&&setTimeout(()=>{tn||M(G)},ze(C))},On=p=>{for(let v of p)A.has(v.id)||A.set(v.id,sn(v))};if(e.initialSlots)for(let[p,v]of Object.entries(e.initialSlots))A.set(p,v),N.add(p);if(e.initialSlotConfig)for(let[p,v]of Object.entries(e.initialSlotConfig))X.set(p,v);e.initialPalette&&(Y=e.initialPalette),e.initialVocabulary&&(ie=e.initialVocabulary);let Ae=st(e.apiKey);if(Ae){for(let[p,v]of Object.entries(Ae.slots))A.has(p)||A.set(p,v);for(let[p,v]of Object.entries((a=Ae.slotConfig)!=null?a:{}))X.has(p)||X.set(p,v);!Y&&Ae.palette&&(Y=Ae.palette),!ie&&Ae.vocabulary&&(ie=Ae.vocabulary)}let In={low:.15,medium:.5,high:.85};if(e.initialPersona)Z=B({},e.initialPersona);else{let p=document.documentElement.dataset;p.sentientPersona?Z={persona:p.sentientPersona,confidence:(s=In[(i=p.sentientConfidence)!=null?i:"low"])!=null?s:.15}:Ae&&(Z={persona:Ae.persona,confidence:(u=In[Ae.band])!=null?u:.15})}if(e.initialAssignments)for(let[p,v]of Object.entries(e.initialAssignments))k.set(p,z,{variantId:v,assignedAt:Date.now(),segment:z,confidence:1});let Ie=Promise.resolve(),Ln=y.getSessionId();if(Ln){let p=Hn((c=document.referrer)!=null?c:""),{utmParams:v,clickIds:M}=Si(),W=B(B(B(B({sessionId:Ln,deviceClass:F,trafficSource:J,referrerDomain:p,utmParams:v,clickIds:M,timeOfDay:Jn(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:y.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||zn((l=navigator.userAgent)!=null?l:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),G=async()=>{for(let C=0;;C++){try{let O=await fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(W),headers:h});if(O.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(O.ok||pn(O)==="dropped")return}catch(O){}if(C>=vi){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(O=>setTimeout(O,ze(C+1)))}};try{Ie=G()}catch(C){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:w});let ko=bi(),rt=null,nn=!1,de={goal(p,v={},M=1,W=0){var G,C,O,$,H,ee,ae;let ue=y.getSessionId();if(!ue)return;let q=yi(v)?v:{metadata:v},ge=[p,(G=q.externalId)!=null?G:"",(C=q.stepIndex)!=null?C:W,(O=q.weight)!=null?O:M].join("\0"),Ee=q.value!==void 0?`${q.value}\0${($=q.currency)!=null?$:""}`:null;if(ko.firedBefore(ge,Ee)){e.debug&&console.log(`[sentient] goal("${p}") already recorded for this action \u2014 not sent twice`);return}let pe=cn(),D={sessionId:ue,name:p,metadata:(H=q.metadata)!=null?H:{},weight:(ee=q.weight)!=null?ee:M,stepIndex:(ae=q.stepIndex)!=null?ae:W,goalId:pe,value:q.value,currency:q.currency,externalId:q.externalId};e.debug&&console.log("[sentient] goal",D);let fe={id:pe,body:JSON.stringify(D)};Ie.then(()=>I.send(fe))},componentGoal(p,v,M){var W,G,C;let O=y.getSessionId();if(!O)return;let $=k.get(p,z),H=$?null:(W=A.get(p))!=null?W:null;if(!$&&H===null){e.debug&&console.warn(`[sentient] componentGoal("${p}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!$&&!N.has(p)){e.debug&&console.warn(`[sentient] componentGoal("${p}"): slot not decided this session \u2014 not attributed`);return}let ee=$?$.variantId:Yn(H),ae={id:cn(),sessionId:O,projectId:e.apiKey,componentId:p,variantId:ee,eventType:"goal_achieved",goalType:v,payload:B({reward:(G=M==null?void 0:M.reward)!=null?G:1,goalValue:M==null?void 0:M.value,currency:M==null?void 0:M.currency},(C=M==null?void 0:M.metadata)!=null?C:{}),timestamp:Date.now(),timeInSession:Date.now()-E,path:Pt()};e.debug&&console.log("[sentient] componentGoal",ae),Ie.then(()=>w.push(ae))},identify(p){let v=y.getSessionId();v&&Ie.then(()=>{fetch(`${b}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:v,userId:p,ephemeral:y.isEphemeral()}),headers:h}).catch(()=>{})})},track(p){let v=y.getSessionId();if(!v||p.eventType==="variant_assigned"&&A.get(p.componentId)!==void 0&&!N.has(p.componentId)&&!k.get(p.componentId,z))return;let M=Re(B({path:Pt()},p),{id:cn(),sessionId:v,timestamp:Date.now(),timeInSession:Date.now()-E});e.debug&&console.log("[sentient] track",M),Ie.then(()=>w.push(M))},getAssignment(p,v){return k.get(p,v)},async assign(p,v,M,W){let G=y.getSessionId();if(!G)return null;let C=k.get(p,z);if(C&&(v!=null&&v.length||C.content!==void 0)){let O=C.ttlMs&&C.ttlMs>0?Math.max(0,C.assignedAt+C.ttlMs-Date.now()):0;return{variantId:C.variantId,assignmentTtlMs:O,content:C.content}}return fn(K,p,async()=>{await Ie;try{let O={sessionId:G,componentId:p,variantIds:v};W!==void 0?O.agentDataByVariant=W:M!==void 0&&(O.agentData=M);let $=await fetch(`${b}/assign`,{method:"POST",body:JSON.stringify(O),headers:h});if(!$.ok)return null;let H=await $.json();return k.set(p,z,B({variantId:H.variantId,assignedAt:Date.now(),segment:z,confidence:1,content:H.content},H.assignmentTtlMs&&H.assignmentTtlMs>0?{ttlMs:H.assignmentTtlMs}:{})),H}catch(O){return null}})},async decide(p){var v,M;let W=y.getSessionId();if(!W)return null;let G=(v=p.slots)!=null?v:[],C={sessionId:W};p.sections&&p.sections.length>0&&(C.sections=p.sections.map($=>({id:$}))),C.components=(M=p.components)!=null?M:[],G.length>0&&(C.slots=G.map(on)),p.slotsFrom==="registry"&&(C.slotsFrom="registry",p.registrySlotIds&&(C.registrySlotIds=p.registrySlotIds),p.bootstrap===!1&&(C.bootstrap=!1),p.render&&Object.keys(p.render).length>0&&(C.render=p.render)),p.v&&(C.v=p.v),typeof p.pp=="number"&&(C.pp=p.pp),e.persona&&(C.persona=e.persona);let O=JSON.stringify(C);return fn(oe,O,async()=>{var $,H,ee,ae,ue,q,ge,Ee;await Ie;try{let pe=await fetch(`${b}/decide`,{method:"POST",body:O,headers:h});if(!pe.ok)return On(G),null;let D=await pe.json(),fe={};for(let te of G){let xe=($=D.slots)==null?void 0:$[te.id];if(xe!==void 0){fe[te.id]=xe,A.set(te.id,xe),N.add(te.id);continue}let Tn=A.get(te.id);if(Tn!==void 0)fe[te.id]=Tn;else{let Rn=sn(te);fe[te.id]=Rn,A.set(te.id,Rn)}}if(D.slots)for(let[te,xe]of Object.entries(D.slots))te in fe||(fe[te]=xe,A.set(te,xe),N.add(te));let Le=Z!=null&&Z.persona!=="unknown";D.persona&&!(D.persona==="unknown"&&Le)?Z={persona:D.persona,confidence:(H=D.confidence)!=null?H:0}:Z||(Z={persona:"unknown",confidence:0});for(let[te,xe]of Object.entries((ee=D.assignments)!=null?ee:{}))k.set(te,z,{variantId:xe,assignedAt:Date.now(),segment:z,confidence:1});if(D.slotConfig)for(let[te,xe]of Object.entries(D.slotConfig))X.set(te,xe);D.palette&&(Y=D.palette),D.vocabulary&&(ie=D.vocabulary);for(let te of(ae=p.registrySlotIds)!=null?ae:[])(ue=D.slotConfig)!=null&&ue[te]||(X.delete(te),A.delete(te),N.delete(te));return He(e.apiKey,B(B(B({v:1,persona:Z.persona,band:Be(Z.confidence),slots:Object.fromEntries(A),layoutOrder:(q=D.layoutOrder)!=null?q:null,savedAt:Date.now()},X.size>0?{slotConfig:Object.fromEntries(X)}:{}),Y?{palette:Y}:{}),ie?{vocabulary:ie}:{})),B(B(B(B(B({layoutOrder:(ge=D.layoutOrder)!=null?ge:null,assignments:(Ee=D.assignments)!=null?Ee:{},slots:fe,persona:Z.persona,confidence:Z.confidence},D.slotConfig?{slotConfig:D.slotConfig}:{}),D.goals?{goals:D.goals}:{}),D.sectionMap?{sectionMap:D.sectionMap}:{}),D.palette?{palette:D.palette}:{}),D.vocabulary?{vocabulary:D.vocabulary}:{})}catch(pe){return On(G),null}})},getSlotResult(p){var v;return(v=A.get(p))!=null?v:null},isSlotDecided(p){return N.has(p)},getSlotConfig(p){var v;return(v=X.get(p))!=null?v:null},reportSlots(p,v,M,W){var G;let C={};for(let[O,$]of Object.entries(W!=null?W:{}))for(let H of $){let ee=`${O}|${H.key}`;!wt.test(O)||be.has(ee)||(be.add(ee),((G=C[O])!=null?G:C[O]=[]).push(H))}Object.keys(C).length>0&&fetch(`${b}/slots/observed`,{method:"POST",headers:h,body:JSON.stringify({slotIds:Object.keys(C),authoredArms:C})}).catch(()=>{});for(let O of p)if(!(typeof O!="string"||O.length===0)){if(!wt.test(O)){hi()&&!xn.has(O)&&(xn.add(O),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(O)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!L.has(O)){L.add(O),_.add(O);let $=v==null?void 0:v[O];if(typeof $=="string"){let ee=$.replace(/\s+/g," ").trim().slice(0,400);ee!==""&&U.set(O,ee)}let H=M==null?void 0:M[O];H!==void 0&&Q.set(O,H)}}_.size===0||me!=null||(me=setTimeout(()=>{me=null;let O=[..._];_.clear();for(let $=0;$<O.length;$+=20){let H=O.slice($,$+20),ee={},ae={};for(let ue of H){let q=U.get(ue);q!==void 0&&(ee[ue]=q,U.delete(ue));let ge=Q.get(ue);ge!==void 0&&(ae[ue]=ge,Q.delete(ue))}fetch(`${b}/slots/observed`,{method:"POST",headers:h,body:JSON.stringify(Re(B(B({slotIds:H},Object.keys(ee).length>0?{baselineTexts:ee}:{}),Object.keys(ae).length>0?{baselineSkeletons:ae}:{}),{pagePaths:Object.fromEntries(H.map(ue=>[ue,location.pathname]))}))}).catch(()=>{})}},1e3))},reportSkeleton(p,v){!wt.test(p)||T.has(p)||(T.add(p),fetch(`${b}/slots/observed`,{method:"POST",headers:h,body:JSON.stringify({slotIds:[p],baselineSkeletons:{[p]:v}})}).catch(()=>{}))},reportDrift(p,v,M,W){let G=`${p}|${v}`,C=y.getSessionId();!C||re.has(G)||(re.add(G),fetch(`${b}/slots/drift`,{method:"POST",headers:h,body:JSON.stringify({sessionId:C,reports:[{slotId:p,expectedFp:v,observedFp:M,reason:W}]})}).catch(()=>{}))},requestSlots(p,v,M){var W,G;for(let C of p)Et.has(C)||(Et.add(C),wt.test(C)?tt.set(C,{text:v==null?void 0:v[C],render:(W=M==null?void 0:M.render)==null?void 0:W[C],skeleton:(G=M==null?void 0:M.skeletons)==null?void 0:G[C]}):de.reportSlots([C]));tt.size===0||Qt!=null||(Qt=setTimeout(()=>{Qt=null;let C=[...tt];tt.clear();for(let O=0;O<C.length;O+=50){let $=C.slice(O,O+50),H={};for(let[ee,ae]of $)ae.render&&(H[ee]=ae.render);de.decide({slotsFrom:"registry",registrySlotIds:$.map(([ee])=>ee),bootstrap:!1,render:H}).then(ee=>{var ae,ue;if(ee){let q={},ge={},Ee=[];for(let[pe,D]of $){let fe=(ae=ee.slotConfig)==null?void 0:ae[pe];if(fe){fe.needsSkeleton&&D.skeleton&&((ue=de.reportSkeleton)==null||ue.call(de,pe,D.skeleton));continue}Ee.push(pe),D.text&&(q[pe]=D.text),D.skeleton&&(ge[pe]=D.skeleton)}Ee.length>0&&de.reportSlots(Ee,q,ge)}else _n($.map(([q])=>q),Et,q=>{var ge;let Ee={},pe={},D={};for(let[fe,Le]of $)q.has(fe)&&(Le.text&&(Ee[fe]=Le.text),Le.render&&(pe[fe]=Le.render),Le.skeleton&&(D[fe]=Le.skeleton));(ge=de.requestSlots)==null||ge.call(de,[...q],Ee,{render:pe,skeletons:D})});St.forEach(q=>q())})}},0))},decideSlots(p){for(let v of p)kt.has(v.id)||(kt.add(v.id),nt.set(v.id,v));nt.size===0||en!=null||(en=setTimeout(()=>{en=null;let v=[...nt.values()];nt.clear();for(let M=0;M<v.length;M+=30){let W=v.slice(M,M+30);de.decide({slots:W}).then(G=>{G||_n(W.map(C=>C.id),kt,C=>{var O;return(O=de.decideSlots)==null?void 0:O.call(de,W.filter($=>C.has($.id)))}),St.forEach(C=>C())})}},0))},cancelSlots(p){for(let v of p)tt.delete(v)&&Et.delete(v),nt.delete(v)&&kt.delete(v)},onSlotsChanged(p){return St.add(p),()=>{St.delete(p)}},getStyleVocabulary(){return ie},getSitePalette(){return Y},getPersona(){return Z?{persona:Z.persona,confidence:Z.confidence,band:Be(Z.confidence)}:null},async fetchWeights(){var p;try{let v=await fetch(`${b}/weights`,{headers:h});return v.ok?(p=(await v.json()).components)!=null?p:[]:[]}catch(v){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){w.flush(),I.flush()},dispose(){var p;rt==null||rt(),nn=!0,tn=!0,w.destroy(),I.destroy(),((p=we.get(e.apiKey))==null?void 0:p.dispose)===de.dispose&&we.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var p;rt==null||rt(),nn=!0,tn=!0,w.destroy(),I.destroy(),y.destroy(),k.clear(),((p=we.get(e.apiKey))==null?void 0:p.dispose)===de.dispose&&we.delete(e.apiKey);try{localStorage.removeItem(Dt+e.apiKey),localStorage.removeItem(lr(e.apiKey)),localStorage.removeItem(ur(e.apiKey))}catch(v){}e.debug&&console.log("[sentient] destroyed")}};if(we.set(e.apiKey,{config:e,upgrade:null,dispose:de.dispose}),rt=wi(de,e.apiKey,p=>{Ie.then(()=>{nn||pr.add(p)})}),e.debug){let p=window;p.__sentient&&(p.__sentient.client=de)}return de}function ki(e){return e.replace(/\s+/g," ").trim().slice(0,300)}function gr(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 Ai(e){let t=e.join("");return gr(t,2166136261)+gr(t,1523705862)}var xi=new Set(["A","BUTTON"]),Ci=/^H([1-6])$/,_i=new Set(["P","LI","LABEL","BLOCKQUOTE","FIGCAPTION","DT","DD","TD","TH"]);var Oi=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT"]);function Ii(e){return xi.has(e.tagName)||e.getAttribute("role")==="button"?!0:e.tagName==="INPUT"&&/^(submit|button)$/i.test(e.type)}function Li(e){if(Ci.test(e.tagName)||_i.has(e.tagName))return!0;let t=e.ownerDocument.defaultView,n=t?t.getComputedStyle(e).display:"";return n!==""&&n!=="inline"&&n!=="contents"}function Ti(e,t){let n=null;for(let r=e.parentElement;r&&r!==t.parentElement;r=r.parentElement){if(Ii(r)){n=r;break}if(r===t)break}if(n)return n;for(let r=e.parentElement;r;r=r.parentElement)if(r===t||Li(r))return r;return t}function Mt(e,t=40){var n,r,o;let a=e.ownerDocument.createTreeWalker(e,4),i=[];for(let l=a.nextNode();l;l=a.nextNode())if(((n=l.nodeValue)!=null?n:"").trim()!==""&&!Oi.has((o=(r=l.parentElement)==null?void 0:r.tagName)!=null?o:"")&&(i.push(l),i.length>120))return{reason:"too_large"};if(i.length===0)return{reason:"empty"};let s=[],u=[];for(let l of i){let d=Ti(l,e),g=s.indexOf(d);g===-1&&(s.push(d),g=s.length-1),u.push(g)}if(s.length>t)return{reason:"too_large"};let c=i.map(l=>{var d;return ki((d=l.nodeValue)!=null?d:"")});return{textNodes:i,ownerEls:s,leafToNode:u,leaves:c,fp:Ai(c)}}var Ri=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function yn(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function Pi(e){return{tag:e.tagName.toLowerCase(),text:yn(e).slice(0,40)}}function hr(e){return e.replace(/["\\\]]/g,"\\$&")}function ct(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function yr(e,t){var n;let r=e.tagName.toLowerCase();if(!r)return null;let o=((n=e.getAttribute("class"))!=null?n:"").split(/\s+/).filter(s=>/^[a-zA-Z][\w-]*$/.test(s)),a=[r,...o.map(s=>`${r}.${s}`)];for(let s of a)if(ct(t,s))return s;let i=e.parentElement;if(i&&i!==t){let s=yr(i,t);if(s){for(let d of a){let g=`${s} > ${d}`;if(ct(t,g))return g}let u=Array.from(i.children).filter(d=>d.tagName.toLowerCase()===r),c=u.indexOf(e),l=u.some(d=>d!==e&&yn(d)!==yn(e));if(c>=0&&l){let d=`${s} > ${r}:nth-of-type(${c+1})`;if(ct(t,d))return d}}}return null}function vr(e,t){let n=Pi(e),r=e.getAttribute("id");if(r&&ct(t,`#${hr(r)}`))return{v:1,id:r,fingerprint:n};for(let a of Ri){let i=e.getAttribute(a);if(i&&ct(t,`[${a}="${hr(i)}"]`))return{v:1,dataAttr:{name:a,value:i},fingerprint:n}}let o=yr(e,t);return o?{v:1,selector:o,fingerprint:n}:null}ot();var wr=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Di={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Ni(e){let t=e.ariaRole?Di[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 Mi(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var $i=[["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]],vn=[["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]],br={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Bi(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function Sr(e){var t,n;let r=Ni(e);if(r)return{type:(t=br[r])!=null?t:"generic",strength:"strong"};let o=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[i,s]of $i)if(s.test(o))return{type:i,strength:"strong"};for(let[i,s]of vn)if(s.test(e.bodyText))return{type:i,strength:"strong"};let a=Mi(e);return{type:(n=br[a])!=null?n:"generic",strength:"weak"}}function Er(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim(),o=e.getAttribute("role");return B({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Bi(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length},o?{ariaRole:o}:{})}ot();var kr=[100,300,1e3,3e3,1e4],Ki=250,ji=1e3,Ui=new Set(["Tab","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function Ar(e,t){e.n++;let n=t-e.mean;e.mean+=n/e.n,e.m2+=n*(t-e.mean)}var xr=e=>e.n>1?Math.sqrt(e.m2/e.n):0;function Gi(e){var t;try{let n=e.createElement("canvas"),r=n.getContext("webgl")||n.getContext("experimental-webgl");if(!r)return"unknown";let o=r.getExtension("WEBGL_debug_renderer_info"),a=o?String((t=r.getParameter(o.UNMASKED_RENDERER_WEBGL))!=null?t:""):"";return a?/swiftshader|llvmpipe|softpipe|software|mesa offscreen/i.test(a)?"sw":"hw":"unknown"}catch(n){return"unknown"}}function Fi(e,t=Date.now){var n,r;let o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0,a={n:0,mean:0,m2:0},i={n:0,mean:0,m2:0},s=[0,0,0,0,0,0],u=0,c=0,l=0,d=0,g=0,x=0,f=0,m=0,E=0,y=0,k=-1/0,w=-1/0,b=null,h=null,P=null,I=(r=o==null?void 0:o.scrollY)!=null?r:0,F=0,S=e.hidden?null:t(),J=()=>{let T=t();if(P!=null){let re=T-P,be=0;for(;be<kr.length&&re>=kr[be];)be++;s[be]++}P=T},z=()=>{u++,k=t()},K=()=>{c++,w=t()},oe=()=>{b=t()},A=()=>{b!=null&&(Ar(a,t()-b),b=null)},N=()=>{let T=t();l++,T-k>Ki&&T-w>ji&&d++,J()},X=()=>{g++},Y=()=>{var T;let re=(T=o==null?void 0:o.scrollY)!=null?T:0;x+=Math.abs(re-I),I=re,J()},ie=T=>{let re=t();f++,(T.key==="Backspace"||T.key==="Delete")&&E++,Ui.has(T.key)&&y++,h!=null&&Ar(i,re-h),h=re,J()},Z=T=>{let re=T.data;typeof re=="string"&&(m+=re.length),J()},L=()=>{let T=t();e.hidden?S!=null&&(F+=T-S,S=null):S==null&&(S=T)},_={passive:!0,capture:!0};e.addEventListener("mousemove",z,_),e.addEventListener("touchstart",K,_),e.addEventListener("touchmove",X,_),e.addEventListener("mousedown",oe,_),e.addEventListener("mouseup",A,_),e.addEventListener("click",N,_),e.addEventListener("wheel",X,_),e.addEventListener("keydown",ie,_),e.addEventListener("input",Z,_),e.addEventListener("visibilitychange",L),o==null||o.addEventListener("scroll",Y,_);let U=Gi(e),Q=(()=>{var T;try{return((T=o==null?void 0:o.matchMedia)==null?void 0:T.call(o,"(prefers-reduced-motion: reduce)").matches)===!0}catch(re){return!1}})();return{snapshot(){var T,re;let be=t(),me=F+(S!=null?be-S:0);return{v:1,active_ms:Math.round(me),mm:u,mm_rate:me>0?Number((u*1e3/me).toFixed(2)):0,touches:c,clicks:l,hold_n:a.n,hold_mean:Math.round(a.mean),hold_std:Math.round(xr(a)),teleport:d,wheel:g,scroll_px:Math.round(x),keydowns:f,input_chars:m,ik_cv:i.mean>0?Number((xr(i)/i.mean).toFixed(2)):0,backspaces:E,gaps:[...s],reduced_motion:Q,kb_nav:y,renderer:U,vp:[(T=o==null?void 0:o.innerWidth)!=null?T:0,(re=o==null?void 0:o.innerHeight)!=null?re:0],dpr:(o==null?void 0:o.devicePixelRatio)||1}},stop(){e.removeEventListener("mousemove",z,_),e.removeEventListener("touchstart",K,_),e.removeEventListener("touchmove",X,_),e.removeEventListener("mousedown",oe,_),e.removeEventListener("mouseup",A,_),e.removeEventListener("click",N,_),e.removeEventListener("wheel",X,_),e.removeEventListener("keydown",ie,_),e.removeEventListener("input",Z,_),e.removeEventListener("visibilitychange",L),o==null||o.removeEventListener("scroll",Y,_)}}}var zi="section, header, footer, nav, main > div, [data-sentient-section]",Vi=2e4,Wi="__session__";function Hi(e){let t=Array.from(e.querySelectorAll(zi)),n=t.filter(r=>t.filter(o=>o!==r&&r.contains(o)).length<2);return n.filter(r=>!n.some(o=>o!==r&&o.contains(r)))}function qi(e,t,n,r){try{fetch(`${t}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(o){}}var Cr=()=>{};function _r(e,t){var n,r,o,a,i,s,u,c,l,d,g,x,f,m,E;let y=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!y||typeof IntersectionObserver=="undefined"||Ke()||!t.apiKey||!t.apiKey.startsWith("pk_"))return Cr;let k=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),w=Hi(y);if(w.length===0)return Cr;let b=new Map,h=[];for(let L of w){let _=(i=[(a=t.sectionTypes)==null?void 0:a[(o=L.getAttribute("data-sentient-id"))!=null?o:""],L.getAttribute("data-sentient-type")].find(me=>wr.includes(me)))!=null?i:null,U=Er(L),Q=(u=_!=null?_:(s=t.typeOf)==null?void 0:s.call(t,L))!=null?u:Sr(U).type,T=vr(L,y),re=T?`nc-${Q}-${Gn(JSON.stringify({id:(c=T.id)!=null?c:null,dataAttr:(l=T.dataAttr)!=null?l:null,selector:(d=T.selector)!=null?d:null})).toString(36)}`:`nc-${Q}`;b.set(L,re);let be=vn.filter(([,me])=>me.test(U.bodyText)).map(([me])=>me);h.push(Re(B({componentId:re,semanticType:Q,source:_?"markup":"auto"},T?{locator:T}:{}),{observation:B(B({tag:U.tag,idClass:U.idClass.slice(0,200),headingText:U.headingText,textLength:U.textLength,actionCount:U.actionCount},U.ariaRole?{ariaRole:U.ariaRole}:{}),be.length>0?{patternFlags:be}:{})}))}let P=(m=(f=(x=(g=y.defaultView)!=null?g:typeof window!="undefined"?window:void 0)==null?void 0:x.location)==null?void 0:f.pathname)!=null?m:"/";qi(t.apiKey,k,P,h);let I=Fi(y),F=()=>{let L;try{L=I.snapshot()}catch(_){return}try{e.track({projectId:t.apiKey,componentId:Wi,eventType:"interaction_stats",payload:L})}catch(_){}},S=new Map,J=L=>{let _=S.get(L);return _||(_={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(L,_)),_},z=new IntersectionObserver(L=>{for(let _ of L){let U=b.get(_.target);if(!U)continue;let Q=J(U);_.isIntersecting?(Q.intersecting=!0,Q.enterAt=Date.now(),_.intersectionRatio>Q.scroll&&(Q.scroll=_.intersectionRatio)):(Q.intersecting=!1,Q.enterAt!=null&&(Q.ms+=Date.now()-Q.enterAt,Q.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let L of b.keys())z.observe(L);let K=(L=!1)=>{var _;let U=Date.now();for(let[Q,T]of S)if(T.enterAt!=null&&(T.ms+=U-T.enterAt,T.enterAt=null),!(T.ms<=0)){try{e.track({projectId:t.apiKey,componentId:Q,eventType:"dwell",payload:{dwell_time:Math.round(T.ms),scroll_depth:Number(T.scroll.toFixed(2))}})}catch(re){}T.ms=0}if(F(),L)try{(_=e.flush)==null||_.call(e)}catch(Q){}},oe=()=>{if(y.hidden)K(!0);else{let L=Date.now();for(let _ of S.values())_.intersecting&&(_.enterAt=L)}},A=!1,N=L=>{if(K(!0),L!=null&&L.persisted){A=!0;return}try{z.disconnect()}catch(_){}},X=L=>{if(!(L!=null&&L.persisted)||!A)return;A=!1;let _=Date.now();for(let U of S.values())U.enterAt=U.intersecting&&!y.hidden?_:null};y.addEventListener("visibilitychange",oe);let Y=(E=y.defaultView)!=null?E:typeof window!="undefined"?window:void 0;Y==null||Y.addEventListener("pagehide",N),Y==null||Y.addEventListener("pageshow",X);let ie=setInterval(()=>{if(y.hidden||A)return;K();let L=Date.now();for(let _ of S.values())_.intersecting&&(_.enterAt=L)},Vi),Z=[];return t.microSignals&&[...b.entries()].forEach(([L,_],U)=>{Z.push(lt((Q,T={})=>{try{e.track({projectId:t.apiKey,componentId:_,eventType:"micro_signal",payload:B({signalType:Q},T)})}catch(re){}},L,void 0,{tabLoss:U===0}))}),()=>{K(!0),clearInterval(ie),I.stop(),y.removeEventListener("visibilitychange",oe),Y==null||Y.removeEventListener("pagehide",N),Y==null||Y.removeEventListener("pageshow",X);for(let L of Z)L();try{z.disconnect()}catch(L){}}}var Or=["cookiebot","onetrust","cookieyes","tcf","google-consent-mode"];function Ji(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;let t=Object.entries(e);if(t.length<1||t.length>4)return null;let n={};for(let[r,o]of t){if(!Array.isArray(o)||o.length<2||o.length>6||!o.every(a=>typeof a=="string"))return null;n[r]=o}return n}function Yi(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Xi(e){try{return e()}catch(t){return}}function $t(e){if(typeof e!="object"||e===null)return null;let t=e;if(typeof t.apiKey!="string"||!t.apiKey.startsWith("pk_"))return null;let n={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let u=s,c=Ji(u.dims);if(!c||u.target!==void 0&&typeof u.target!="string")continue;let l=u.arms!==void 0?Yi(u.arms):null,d={dims:c};typeof u.target=="string"&&(d.target=u.target),l&&(d.arms=l),n[i]=d}let r={apiKey:t.apiKey,personaAttributes:t.personaAttributes===!0,slots:n};typeof t.consent=="boolean"&&(r.consent=t.consent);let o=t.consentFrom;if(typeof o=="string"&&Or.includes(o))r.consentFrom=o;else if(o&&typeof o=="object"&&!Array.isArray(o)){let i=o;(typeof i.cmp=="string"&&Or.includes(i.cmp)||i.cmp===void 0&&(typeof i.cookie=="string"||typeof i.check=="function"))&&(r.consentFrom=i)}(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(r.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(r.debug=!0),typeof t.registry=="boolean"&&(r.registry=t.registry),typeof t.editorSrc=="string"&&(r.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(r.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(r.sectionCapture=t.sectionCapture);let a=typeof t.persona=="function"?Xi(t.persona):t.persona;if(typeof a=="string"&&a.trim()!==""&&(r.persona=a),Array.isArray(t.sections)){let i=t.sections.filter(s=>typeof s=="string"&&s.trim()!=="").slice(0,50);i.length>=2&&(r.sections=i)}return r}var Ir=new WeakMap;function Lr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function Tr(e,t,n){var a,i,s;let r=Ir.get(e);if(r){if(r.fp!==n.fp||!Lr(r.leafToNode,n.leafToNode))return"mismatch"}else{let u=Mt(e);if(!("fp"in u)||(r={fp:u.fp,leafToNode:u.leafToNode,textNodes:u.textNodes,ownerEls:u.ownerEls,classes:u.ownerEls.map(c=>{var l;return(l=c.getAttribute("class"))!=null?l:""})},r.fp!==n.fp||!Lr(r.leafToNode,n.leafToNode)))return"mismatch";Ir.set(e,r)}let o=r;for(let[u,c]of Object.entries(t.nodes)){let l=Number(u),d=o.ownerEls[l];if(d){if(typeof c.text=="string"){let g=!0;o.leafToNode.forEach((x,f)=>{x===l&&(o.textNodes[f].nodeValue=g?c.text:"",g=!1)})}c.like!==void 0&&o.classes[c.like]!==void 0&&d.setAttribute("class",o.classes[c.like]),c.hidden&&((a=d.style)==null||a.setProperty("display","none","important"))}}for(let u of Object.values((i=t.order)!=null?i:{})){let c=u.map(f=>o.ownerEls[f]).filter(f=>!!f),l=(s=c[0])==null?void 0:s.parentElement;if(!l||c.length!==u.length||c.some(f=>f.parentElement!==l))continue;let d=new Set(c),g=0;Array.from(l.children).map(f=>d.has(f)?c[g++]:f).forEach((f,m)=>{var E;l.children[m]!==f&&l.insertBefore(f,(E=l.children[m])!=null?E:null)})}return"applied"}function dt(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Zi(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let r=((n=e.textContent)!=null?n:"").replace(/\s+/g," ").trim().toLowerCase(),o=t.text.replace(/\s+/g," ").trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function Bt(e,t){return!!(e!=null&&e.urlMatch)&&!dt(t).includes(e.urlMatch)}var Qi=/^[a-zA-Z_][-a-zA-Z0-9_]*$/;function Rr(e,t){var r;let n=[];if(e.id){let o=t.getElementById(e.id);n=o?[o]:[]}if(n.length===0&&((r=e.dataAttr)!=null&&r.name)&&Qi.test(e.dataAttr.name))try{let o=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${o}"]`))}catch(o){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(o){n=[]}return n}function Ce(e,t){if(e.urlMatch&&!dt(t).includes(e.urlMatch))return null;let n=Rr(e,t);if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Zi(r,e.fingerprint)?null:r}function Pr(e,t){return Bt(e,t)?!1:!!e.selector&&!e.dataAttr&&!e.id&&!e.fingerprint&&e.page===void 0?Dr(e,t):Ce(e,t)!==null}function Dr(e,t){return Rr(e,t).length>0}function Kt(e,t){return Bt(e,t)?!1:e.page!==void 0&&Nt.test(e.page)?mn(e.page,dt(t)):Dr(e,t)}var Nr={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"},es=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Mr(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(!es.test((r=n[1])!=null?r:""))return!1;return!0}var $r=/^https:\/\//i,Br=new Map,Pe=null;function ts(e){return e.replace(/["\\]/g,"\\$&")}function ns(e){var t;(!Pe||!Pe.isConnected)&&(Pe=e.querySelector("style[data-sentient-ops]"),Pe||(Pe=e.createElement("style"),Pe.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(Pe))),Pe.textContent=[...Br.entries()].map(([n,r])=>`[data-snt-e="${ts(n)}"]{${r}}`).join(`
|
|
2
|
+
`)}function Kr(e,t,n,r){var s;let o=!1,a=(s=t.moveBefore)!=null?s:t.moveAfter;if(a){let u=Ce(a,r);!u||u===e||u.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,u):e.parentElement.insertBefore(e,u.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&$r.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&$r.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let i=[];if(t.hidden&&i.push("display:none !important"),t.style)for(let[u,c]of Object.entries(t.style)){let l=Nr[u];l&&typeof c=="string"&&Mr(c)&&i.push(`${l}:${c.trim()} !important`)}return i.length>0&&(e.setAttribute("data-snt-e",n),Br.set(n,i.join(";")),ns(r)),{anchorMiss:o}}var ft="data-sentient-block-arm",R=null;function Je(e){R=e!=null?e:null}var je=null;function Ye(e){je=e!=null?e:null}var Fr=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},zr=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},Oe="data-sentient-blocks-hid",qe={none:"0",sm:"8px",md:"16px",lg:"24px"},bn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},jr={sm:"0.875em",md:"1em",lg:"1.25em"},rs={sm:"1.25em",md:"1.5em",lg:"2em"},os={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Ur={sm:"8px",md:"16px",lg:"32px"},is={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ss={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 Gr(e){return e==="muted"?R!=null&&R.muted?{color:R.muted}:{opacity:"0.7"}:e==="accent"?{"font-weight":"600",color:R==null?void 0:R.accent}:{}}function Vr(e,t){let n=as(e,t),r=zr(e.like);return n&&r&&(n.style.color=r),n}function as(e,t){var n,r,o,a,i,s,u,c,l,d,g,x,f,m,E,y,k,w,b,h;try{let P=Fr(e.like),I=e.maxWidth==="measure"?"65ch":void 0,F=S=>(S.className=P,he(S,{"max-width":I}));switch(e.type){case"stack":case"grid":{let S=t.createElement("div");if(e.type==="stack"){let K=e;he(S,{display:"flex","flex-direction":K.direction,gap:(r=qe[(n=K.gap)!=null?n:"md"])!=null?r:qe.md,"align-items":K.align?bn[K.align]:void 0,"justify-content":K.justify?bn[K.justify]:void 0,"flex-wrap":K.wrap?"wrap":void 0})}else{let K=e,oe=(a=qe[(o=K.gap)!=null?o:"md"])!=null?a:qe.md;he(S,{display:"grid","grid-template-columns":`repeat(auto-fit, minmax(max(200px, calc((100% - ${K.columns-1} * ${oe}) / ${K.columns})), 1fr))`,gap:oe,"align-items":K.align?bn[K.align]:void 0})}P&&(S.className=P);let J=!P&&e.type==="stack"&&e.surface==="raised",z=(i=e.pad)!=null?i:J?"md":void 0;z&&he(S,{padding:(s=qe[z])!=null?s:qe.md}),J&&he(S,{background:R==null?void 0:R.surface,color:R!=null&&R.surface?R==null?void 0:R.surfaceText:void 0,border:`1px solid ${(u=R==null?void 0:R.border)!=null?u:"currentColor"}`,"border-radius":(c=R==null?void 0:R.radius)!=null?c:"8px"});for(let K of(l=e.children)!=null?l:[]){let oe=Vr(K,t);oe&&S.appendChild(oe)}return S}case"text":{let S=t.createElement("p");return S.textContent=e.value,P?F(S):he(S,Te(V({margin:"0","font-size":e.size?jr[e.size]:void 0,"font-weight":e.weight?ss[e.weight]:void 0,"text-align":e.align},Gr(e.tone)),{"max-width":e.maxWidth==="measure"?"65ch":void 0}))}case"heading":{let S=t.createElement(`h${e.level}`);return S.textContent=e.value,P?F(S):he(S,{margin:"0","font-size":rs[(d=e.size)!=null?d:"md"],"text-align":e.align,"max-width":e.maxWidth==="measure"?"65ch":void 0})}case"button":{let S=t.createElement("a");if(S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),P)return F(S);let J=(g=e.emphasis)!=null?g:"primary";return he(S,{display:"inline-block",padding:os[(x=e.size)!=null?x:"md"],"border-radius":(f=R==null?void 0:R.radius)!=null?f:"8px",font:"inherit","font-size":e.size?jr[e.size]:void 0,"text-decoration":J==="ghost"?"underline":"none",cursor:"pointer",background:J==="primary"?(m=R==null?void 0:R.primaryBg)!=null?m:"#111827":"transparent",color:J==="primary"?(E=R==null?void 0:R.primaryText)!=null?E:"#ffffff":(y=R==null?void 0:R.accent)!=null?y:"inherit",border:J==="secondary"?`1px solid ${(k=R==null?void 0:R.accent)!=null?k:"currentColor"}`:"none"})}case"link":{let S=t.createElement("a");return S.textContent=e.label,S.href=e.href,e.tag&&S.setAttribute("data-sentient-tag",e.tag),P?F(S):he(S,{color:"inherit","text-decoration":"underline"})}case"image":{let S=t.createElement("img");return S.src=e.src,S.alt=e.alt,P&&(S.className=P),he(S,{display:"block","max-width":"100%","aspect-ratio":e.ratio&&e.ratio!=="auto"?is[e.ratio]:void 0,"object-fit":e.fit,width:e.ratio&&e.ratio!=="auto"?"100%":void 0})}case"badge":{let S=t.createElement("span");return S.textContent=e.value,P?F(S):he(S,V({display:"inline-block",padding:"2px 10px","border-radius":"999px","font-size":"0.75em",border:`1px solid ${(w=R==null?void 0:R.border)!=null?w:"currentColor"}`},Gr(e.tone)))}case"spacer":return he(t.createElement("div"),{height:(b=Ur[e.size])!=null?b:Ur.md});case"divider":return he(t.createElement("hr"),{border:"none","border-top":`1px solid ${(h=R==null?void 0:R.border)!=null?h:"currentColor"}`,margin:"0",width:"100%"});default:return null}}catch(P){return null}}function Wr(e,t,n,r){var o,a;try{let i=new Set;for(let u of Array.from(e.children)){let c=u.getAttribute(ft);c!==null&&(t[c]===void 0?u.remove():i.add(c))}for(let[u,c]of Object.entries(t)){if(i.has(u))continue;let l="tree"in c?c:null,d=Vr(l?l.tree:c,r);if(!d)continue;let g=r.createElement("div");g.setAttribute(ft,u),g.style.display="none";let x=l?Fr((o=l.surface)==null?void 0:o.like):void 0;if(x){let f=r.createElement("div");f.className=x;let m=zr((a=l.surface)==null?void 0:a.like);m&&(f.style.color=m),f.appendChild(d),g.appendChild(f)}else g.appendChild(d);e.appendChild(g)}let s=n!==void 0&&t[n]!==void 0;for(let u of Array.from(e.children)){let c=u.getAttribute(ft),l=u;c!==null?l.style.display=s&&c===n?"":"none":s?l.hasAttribute(Oe)||(l.setAttribute(Oe,l.style.display),l.style.display="none"):l.hasAttribute(Oe)&&(l.style.display=l.getAttribute(Oe),l.removeAttribute(Oe))}}catch(i){}}function ls(e){try{for(let t of Array.from(e.children)){let n=t;if(n.getAttribute(ft)!==null){n.remove();continue}n.hasAttribute(Oe)&&(n.style.display=n.getAttribute(Oe),n.removeAttribute(Oe))}}catch(t){}}function jt(e,t){try{let n=new Set;for(let r of Array.from(e.querySelectorAll(`[${ft}]`)))r.parentElement&&n.add(r.parentElement);for(let r of Array.from(e.querySelectorAll(`[${Oe}]`)))r.parentElement&&n.add(r.parentElement);for(let r of n)t.has(r)||ls(r)}catch(n){}}function wn(e,t){if(!e)return[t.documentElement];try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}function Ut(e,t,n,r){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t),r==null||r(n.documentElement,"data-sentient-persona"),r==null||r(n.documentElement,"data-sentient-confidence")}function Gt(e,t,n,r){var o;for(let[a,i]of Object.entries(t)){let s=e[a];if(!s||typeof s=="string")continue;let u=wn(i.target,n);for(let c of u)for(let[l,d]of Object.entries(s))(o=i.dims[l])!=null&&o.includes(d)&&(c.setAttribute(`data-${l}`,d),r==null||r(c,`data-${l}`))}}function Ft(e,t,n,r){for(let[o,a]of Object.entries(t)){let i=e[o];if(typeof i!="string"||!a.arms||!a.arms.includes(i))continue;let s=wn(a.target,n);for(let u of s)u.setAttribute("data-sentient-arm",i),r==null||r(u,"data-sentient-arm")}}function us(e,t){var o,a;let n=e.ownerDocument.createTreeWalker(e,4),r=null;for(let i=n.nextNode();i!==null;i=n.nextNode()){if(((o=i.nodeValue)!=null?o:"").trim()==="")continue;let s=(a=i.parentElement)==null?void 0:a.tagName;if(!(s==="SCRIPT"||s==="STYLE"||s==="TEMPLATE")){if(r!==null){e.textContent=t;return}r=i}}r!==null?r.nodeValue=t:e.textContent=t}function zt(e,t,n,r){var s,u,c,l,d,g,x;let o=new Set,a=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[f,m]of Object.entries(t)){if(Bt(m.locator,n))continue;let E;if(m.locator){let k=Ce(m.locator,n);E=k?[k]:[],!k&&Kt(m.locator,n)&&i.push(f)}else E=wn(m.target,n);let y=e[f];for(let k of E){if(y!==void 0)if(typeof y=="string")k.setAttribute("data-sentient-arm",y),(u=r==null?void 0:r.onAttr)==null||u.call(r,k,"data-sentient-arm"),a&&((c=r==null?void 0:r.onApplied)==null||c.call(r,f,y,k));else for(let[b,h]of Object.entries(y))k.setAttribute(`data-${b}`,h),(l=r==null?void 0:r.onAttr)==null||l.call(r,k,`data-${b}`);if((m.blocks||m.compose)&&!ds(n)){let b=Object.fromEntries([...Object.entries((d=m.blocks)!=null?d:{}).filter(([,h])=>!at(h)),...Object.entries((g=m.compose)!=null?g:{}).filter(([,h])=>!at(h.tree))]);Object.keys(b).length>0&&(Wr(k,b,typeof y=="string"?y:void 0,n),o.add(k))}if(!a)continue;let w=k.textContent;m.edits?Tr(k,m.edits.edits,m.edits)==="mismatch"&&((x=r==null?void 0:r.onDrift)==null||x.call(r,f,m.edits.fp)):typeof m.content=="string"&&us(k,m.content),m.ops&&Kr(k,m.ops,f,n).anchorMiss&&!i.includes(f)&&i.push(f),gn(k,Te(V(V({previous:w},typeof y=="string"?{arm:y}:{}),(r==null?void 0:r.persona)!==void 0?{persona:r.persona}:{}),{doc:n}))}}return jt(n,o),i}var cs=/bot|crawler|spider|crawling|googlebot|bingbot|duckduckbot|baiduspider|yandexbot|slurp|gptbot|claudebot|anthropic|perplexity|ccbot|applebot|headlesschrome/i;function ds(e){var t,n,r;try{let o=(n=(t=e.defaultView)!=null?t:typeof window!="undefined"?window:void 0)==null?void 0:n.navigator;return o?o.webdriver===!0?!0:cs.test((r=o.userAgent)!=null?r:""):!1}catch(o){return!1}}var fs=800;function Vt(e,t,n){let r=[];return n.forEach(({slotId:o,arm:a,el:i},s)=>{r.push(lt((g,x={})=>{try{e.track({projectId:t,componentId:o,variantId:a,eventType:"micro_signal",payload:V({signalType:g},x)})}catch(f){}},i,void 0,{tabLoss:s===0}));let u=null,c=0,l=()=>{c=Date.now(),u=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-c}})}catch(g){}u=null},fs)},d=()=>{u!==null&&(clearTimeout(u),u=null)};i.addEventListener("mouseenter",l),i.addEventListener("mouseleave",d),r.push(()=>{i.removeEventListener("mouseenter",l),i.removeEventListener("mouseleave",d),u!==null&&clearTimeout(u)})}),()=>{for(let o of r)o()}}function ps(e,t){if(!e)return!1;if(e==="/")return t==="/";let n=e.endsWith("/")?e.slice(0,-1):e;return t===n||t.startsWith(`${n}/`)}function qr(e){return e?`_snt_fired_goals_${e.slice(0,12)}`:"_snt_fired_goals"}var ms="_snt_fired_goals";function Jr(e,t){try{e==null||e.sessionStorage.removeItem(qr(t)),e==null||e.sessionStorage.removeItem(ms)}catch(n){}}function Hr(e){var t;return[(t=e.slotId)!=null?t:"",e.goalId,e.event,e.locator?JSON.stringify(e.locator):""].join("|")}function gs(e,t){try{let n=e==null?void 0:e.sessionStorage.getItem(t);if(!n)return new Set;let r=JSON.parse(n);return Array.isArray(r)?new Set(r.filter(o=>typeof o=="string")):new Set}catch(n){return new Set}}function hs(e,t,n){try{e==null||e.sessionStorage.setItem(t,JSON.stringify([...n]))}catch(r){}}function Wt(e,t,n,r){var y,k;let o=(y=n.defaultView)!=null?y:typeof window!="undefined"?window:null,a=qr(r),i=gs(o,a),s=w=>{let b=Hr(w);if(!i.has(b))try{w.slotId?t.componentGoal(w.slotId,w.goalId):t.goal(w.goalId),i.add(b),hs(o,a,i)}catch(h){}},u=e.filter(w=>w.event==="click"),c=e.filter(w=>w.event==="form_submit"),l=e.filter(w=>w.event==="url_reached"),d=e.filter(w=>w.event==="scroll_depth"),g=(w,b)=>{if(!w.locator)return!1;let h=Ce(w.locator,n);return!!h&&(h===b||h.contains(b))},x=w=>{let b=w.target;if(!(!b||typeof b.closest!="function"))for(let h of u)g(h,b)&&s(h)},f=w=>{let b=w.target;if(b)for(let h of c)g(h,b)&&s(h)},m=()=>{if(l.length===0)return;let w=dt(n);for(let b of l)b.urlPattern&&ps(b.urlPattern,w)&&s(b)},E=()=>{var h;let w=n.documentElement,b=w.scrollHeight>0?(w.scrollTop+w.clientHeight)/w.scrollHeight:0;for(let P of d)b>=((h=P.threshold)!=null?h:.75)&&s(P);d.every(P=>i.has(Hr(P)))&&n.removeEventListener("scroll",E)};return n.addEventListener("click",x,!0),n.addEventListener("submit",f,!0),(k=n.defaultView)==null||k.addEventListener("popstate",m),m(),d.length>0&&(n.addEventListener("scroll",E,{passive:!0}),E()),{checkUrl:m,teardown:()=>{var w;n.removeEventListener("click",x,!0),n.removeEventListener("submit",f,!0),(w=n.defaultView)==null||w.removeEventListener("popstate",m),d.length>0&&n.removeEventListener("scroll",E)}}}function Ht(e,t){if(!e||e.length<2||t.size!==e.length)return null;let n=[];for(let i of e){let s=t.get(i);if(!s||n.includes(s))return null;n.push(s)}let r=n[0].parentNode;if(!r||!n.every(i=>i.parentNode===r))return null;let o=n.slice().sort((i,s)=>i.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),a=[];for(let i=0;i<n.length;i++){let s=n[i];o[i]!==s&&(a.push({el:s,before:o[i]}),o.splice(o.indexOf(s),1),o.splice(i,0,s))}return a}var Yr="__snt_editor_token";function Xr(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(Yr):null}catch(e){return null}}function Zr(e){try{sessionStorage.setItem(Yr,e)}catch(t){}}var gt="0.31.1",Yt=gt!=="0.0.0-dev"?{name:"snippet",version:gt}:void 0,so=gt!=="0.0.0-dev"?{v:gt}:{},ht=5e3,ys=50,ao=(()=>{try{if(typeof window=="undefined")return[];let e=window.SentientSnippet;return Array.isArray(e==null?void 0:e.q)?e.q:[]}catch(e){return[]}})(),le=null,j=null,Se={},ve=null,se=null,De=null,ce=null,_e=null,ne=null,Ue=null,Qr=!1,Sn=null,qt=null,Xt=null,Ge=!1,pt=!1,Xe=null,Ne=!1,Fe=null,Me=[],Zt=null,mt=null,ye=null,vs=3e3,bs=100;function yt(e,t){let n,r=new Promise(o=>{n=setTimeout(()=>o(null),t)});return Promise.race([e,r]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}function ke(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function Ze(e,t){return le?(le.personaAttributes&&ne&&Ut(ne.persona,ne.band,e,t==null?void 0:t.onAttr),Gt(Se,le.slots,e,t==null?void 0:t.onAttr),Ft(Se,le.slots,e,t==null?void 0:t.onAttr),ve?zt(Se,ve,e,V(Te(V({},t),{onDrift:(n,r)=>{var o,a;return(a=j==null?void 0:j.reportDrift)==null?void 0:a.call(j,n,r,(o=fo[n])!=null?o:null,"fp_mismatch")}}),ne?{persona:ne.persona}:{})):(jt(e,new Set),[])):[]}function lo(e){var n;let t=new Map;for(let r of(n=le==null?void 0:le.sections)!=null?n:[])try{let o=e.querySelectorAll(r);o.length===1&&t.set(r,o[0])}catch(o){}return t}function En(e,t){var n,r;try{if(!e||e.length<2)return;for(let o of(n=Ht(e,lo(t)))!=null?n:[])(r=o.before.parentNode)==null||r.insertBefore(o.el,o.before)}catch(o){}}function ws(e,t,n){let r=(o,a)=>t.some(([i,s])=>i===o&&s===a);try{if(Array.isArray(e.stamped))for(let o of e.stamped){if(!Array.isArray(o))continue;let[a,i,s]=o;!a||typeof i!="string"||r(a,i)||(s==null?a.removeAttribute(i):a.setAttribute(i,s))}if(Array.isArray(e.html))for(let o of e.html)typeof o!="string"||r(n.documentElement,o)||n.documentElement.removeAttribute(o)}catch(o){}}function Ss(){try{let e=window.__sntPP;return e&&typeof e=="object"&&typeof e.v=="number"?e:null}catch(e){return null}}function uo(e){return e.apiBase?`${e.apiBase.replace(/\/+$/,"")}/v1/events`:void 0}function vt(e){var t;return(t=e.apiBase)!=null?t:"https://api.sentient-ui.com"}function Es(e){return Promise.resolve().then(()=>fetch(`${vt(e)}/v1/registry/locators`,{headers:{authorization:`Bearer ${e.apiKey}`}})).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t==null?void 0:t.slots)?t.slots:null).catch(()=>null)}function co(e,t){let n=[],r=[];for(let o of e)try{if(typeof(o==null?void 0:o.id)!="string")continue;!o.locator||Pr(o.locator,t)?n.push(o.id):Kt(o.locator,t)&&r.push(o.id)}catch(a){}return[n,r]}var fo={};function po(e,t){var r;let n={};for(let o of e){let a=(r=Fe==null?void 0:Fe.find(c=>c.id===o))==null?void 0:r.locator,i=a?Ce(a,t):null,s=i?Mt(i):null,u=s&&"fp"in s?s.fp:void 0;u&&(fo[o]=u),n[o]=Te(V({},u?{fp:u}:{}),{forms:!1,compose:!0,content:!0})}return n}function mo(e,t){let n=null;for(let r of t)e!=null&&e[r]&&((n!=null?n:n={})[r]=e[r]);return n}function go(){!Fe||!Ge||Zt===window.location.pathname||(Zt=window.location.pathname,ks())}function ks(){ye==null||ye();let e=le,t=Fe;if(!e||!t)return;let n,r,o=()=>{clearTimeout(n),clearTimeout(s),r==null||r.disconnect(),ye===o&&(ye=null)},a=null,i=u=>{let[c,l]=co(t,document),d=c.filter(g=>!Me.includes(g));a!==null&&c.some(g=>!a.has(g)&&!d.includes(g))&&bt(),a=new Set(c),d.length>0&&As(d).catch(()=>{}),(u||l.length===0&&!t.some(g=>!c.includes(g.id)&&!Me.includes(g.id)))&&(o(),ho(e,l))},s=setTimeout(()=>i(!0),vs);if(ye=o,i(),ye===o)try{r=new MutationObserver(()=>{clearTimeout(n),n=setTimeout(i,bs)}),r.observe(document.documentElement,{childList:!0,subtree:!0})}catch(u){}}async function As(e){let t=le,n=j;if(!t||!n)return;Me=Me.concat(e);let r=await yt(n.decide(V({slotsFrom:"registry",registrySlotIds:e,render:po(e,document)},so)),ht);if(r||(Me=Me.filter(a=>!e.includes(a))),!r||Ne||j!==n)return;Se=V(V({},Se),r.slots);let o=mo(r.slotConfig,e);o&&(ve=V(V({},ve),o)),bt(),ke(t,"late decide",e),mt&&He(t.apiKey,mt=V(Te(V({},mt),{slots:Se,savedAt:Date.now()}),ve?{slotConfig:ve}:{}))}function ho(e,t){if(t.length!==0)try{fetch(`${vt(e)}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(n){}}function Qe(){return!!(le&&j&&le.sectionCapture!==!1&&(le.consent!==!1||pt)&&!Ke())}function xs(){if(!j||!le||!Qe()||_e)return;let e=[];Ze(document,{contentAndOps:Ge,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),kn();try{ce==null||ce(),ce=Vt(j,le.apiKey,e)}catch(t){}}function kn(){if(typeof document=="undefined"||!Qe())return;let e;try{if(qt&&qt.length>0){let t=new Map;for(let n of qt){if(n.urlMatch!==window.location.pathname)continue;let r=Ce(n.locator,document);r&&t.set(r,n.type)}t.size>0&&(e=n=>{var r;return(r=t.get(n))!=null?r:null})}}catch(t){}try{_e=_r(j,V({apiKey:le.apiKey,apiBase:le.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Xt=window.location.pathname}catch(t){}}function bt(){try{let e=[];if(ce==null||ce(),ce=null,Ze(document,{contentAndOps:Ge,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),En(Ue,document),e.length>0&&Qe())try{ce=Vt(j,le.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Xt!==null&&window.location.pathname!==Xt&&Qe()&&(_e==null||_e(),_e=null,kn())}catch(t){}}catch(e){}}function eo(){Sn===null&&(Sn=setTimeout(()=>{Sn=null,bt();try{se==null||se.checkUrl()}catch(e){}go()},ys))}function An(){if(!(Qr||typeof window=="undefined"||typeof history=="undefined")){Qr=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,a){let i=n.call(this,r,o,a!=null?a:null);return eo(),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",eo)}catch(e){}}}function Jt(e){let t={};for(let[n,r]of Object.entries(e.slots))try{t[n]=r.target?document.querySelectorAll(r.target).length:1}catch(o){t[n]=0}return t}function yo(e){return new URLSearchParams(e).get("sentient_editor")}function Cs(){try{let e=Array.from(document.getElementsByTagName("script")),t=/(^|\/)snippet(\.global)?\.js(\?|$)/,n=e.find(r=>t.test(r.src));if(n!=null&&n.src)return n.src.replace(t,"$1editor.global.js$3")}catch(e){}return null}function _s(e,t){var n,r,o;try{window.__sentientEditor={token:t,apiBase:vt(e)};try{let s=document.createElement("meta");s.name="referrer",s.content="no-referrer",s.setAttribute("data-sentient-editor",""),((n=document.head)!=null?n:document.documentElement).appendChild(s)}catch(s){}let a=(r=e.editorSrc)!=null?r:Cs();if(!a){no();return}let i=document.createElement("script");i.src=a,i.async=!0,i.onerror=()=>no(),((o=document.head)!=null?o:document.documentElement).appendChild(i)}catch(a){}}var to="sentient-editor-load-notice",vo={position:"fixed",bottom:"16px",zIndex:"2147483647",background:"#111827",color:"#fff",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"};function no(){var e,t;try{if(typeof document=="undefined"||document.getElementById(to))return;(e=document.querySelector('meta[name="referrer"][data-sentient-editor]'))==null||e.remove();let n=document.createElement("div");n.id=to,n.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(n.style,vo,{right:"16px",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",cursor:"pointer"}),n.addEventListener("click",()=>n.remove()),((t=document.body)!=null?t:document.documentElement).appendChild(n),setTimeout(()=>n.remove(),1e4)}catch(n){}}function bo(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let o=r.indexOf(":"),a=o===-1?"":r.slice(0,o),i=o===-1?"":r.slice(o+1);if(!(!a||!i))if(i.includes("=")){let s={};for(let u of i.split(",")){let[c,l]=u.split("=");c&&l&&(s[c]=l)}Object.keys(s).length&&(n[a]=s)}else n[a]=i}return Object.keys(n).length?n:null}function wo(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var ro="sentient-persona-preview-banner";function oo(e,t){var n;try{if(typeof document=="undefined"||document.getElementById(ro))return;let r=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),o=document.createElement("div");o.id=ro,o.setAttribute("role","status"),Object.assign(o.style,vo,{left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",font:"13px/1 system-ui, sans-serif",border:"1px solid rgba(255,255,255,0.14)"});let a=document.createElement("span");a.textContent=t?`\u201C${e}\u201D isn\u2019t in your personas \u2014 showing the default experience`:`Previewing as ${r}`;let i=document.createElement("button");i.type="button",i.textContent="Exit preview",Object.assign(i.style,{cursor:"pointer",border:"1px solid rgba(255,255,255,0.3)",background:"transparent",color:"#fff",font:"inherit",padding:"4px 10px",borderRadius:"999px"}),i.addEventListener("click",()=>{try{let s=new URL(window.location.href);s.searchParams.delete("sentient_persona"),window.location.href=s.pathname+s.search+s.hash}catch(s){}}),o.appendChild(a),o.appendChild(i),((n=document.body)!=null?n:document.documentElement).appendChild(o)}catch(r){}}async function Os(e,t){var r;if((r=e.registry)!=null?r:Object.keys(e.slots).length===0){let o=vt(e),i=await yt(fetch(`${o}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slotsFrom:"registry",includeDrafts:!0,force:Object.fromEntries(Object.entries(t).filter(s=>typeof s[1]=="string"))})}).then(s=>s.ok?s.json():null).catch(()=>null),ht);if(!(i!=null&&i.slotConfig)){et(e),ke(e,"preview mode: slot config unavailable \u2014 page left as-is");return}ve=i.slotConfig,Je(i.palette),Ye(i.vocabulary)}Se=t,ne=null,Ze(document),An(),et(e),ke(e,"preview mode",t)}async function Is(e,t){var c,l,d,g,x,f,m,E,y;let n=vt(e),o=((c=e.registry)!=null?c:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([k,w])=>({id:k,dims:w.dims}))},a=await yt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(k=>k.ok?k.json():null).catch(()=>null),ht);if(!a){et(e),ke(e,"persona preview: explain unavailable \u2014 page left as-is");return}let i=a;Se=(l=i.slots)!=null?l:{},ve=(d=i.slotConfig)!=null?d:null,Je(i.palette),Ye(i.vocabulary);let s=(f=(x=(g=i.personaAttributes)==null?void 0:g.persona)!=null?x:i.persona)!=null?f:t,u=(E=(m=i.personaAttributes)==null?void 0:m.confidence)!=null?E:"high";ne={persona:s,band:u},Ze(document),Ge=!0,An(),et(e),i.recognized===!1?oo(t,!0):oo((y=i.personaDisplay)!=null?y:s)}function et(e){let t={consentWatcher:$e,goal(n,r){try{j==null||j.goal(n,r)}catch(o){}},componentGoal(n,r){try{j==null||j.componentGoal(n,r)}catch(o){}},grantConsent(){try{!j&&Ne?(j=ut(V({apiKey:e.apiKey,consent:!0,preConsentBehavior:e.preConsentBehavior,debug:e.debug,persona:e.persona,ingestUrl:uo(e)},Yt?{sdk:Yt}:{})),De&&De.length>0&&(se==null||se.teardown(),se=Wt(De,j,document,e.apiKey))):(hn(e.apiKey),j&&De&&De.length>0&&(se==null||se.teardown(),se=Wt(De,j,document,e.apiKey))),Ne=!1}catch(n){}pt=!0;try{xs()}catch(n){}},revokeConsent(){try{_e==null||_e(),_e=null,Xt=null,ce==null||ce(),ce=null,ye==null||ye(),se==null||se.teardown(),se=null,Jr(typeof window!="undefined"?window:null,e.apiKey),pt=!1,Ne=!0,j==null||j.destroy(),j=null}catch(n){}},reapply:bt,getState(){var n,r;try{return{apiKey:e.apiKey,persona:(n=ne==null?void 0:ne.persona)!=null?n:null,band:(r=ne==null?void 0:ne.band)!=null?r:null,slots:Se,matchCounts:Jt(e),consent:!Ne&&(e.consent!==!1||pt)}}catch(o){return{apiKey:e.apiKey,persona:null,band:null,slots:{},matchCounts:{},consent:!1}}}};if(window.SentientSnippet=t,e.consentFrom&&!Xe)try{let n=$e(e.consentFrom),r=e.consent!==!1;Xe=n.subscribe(()=>{let o=n.read();o===!0&&!r?(r=!0,t.grantConsent()):o===!1&&r&&(r=!1,t.revokeConsent())})}catch(n){}for(let n of ao.splice(0))try{n[0]==="goal"&&t.goal(n[1],n[2])}catch(r){}}function io(){var e;try{if(typeof window=="undefined")return;let t=window;if(typeof((e=t.SentientSnippet)==null?void 0:e.goal)=="function")return;let n=()=>{};t.SentientSnippet={goal:n,componentGoal:n,grantConsent:n,revokeConsent:n,reapply:n,consentWatcher:$e,getState:()=>({apiKey:"",persona:null,band:null,slots:{},matchCounts:{},consent:!1})},ao.length=0}catch(t){}}async function So(){var e,t;try{let n=$t(window.sentient);if(!n){io();return}if(le=n,Xe==null||Xe(),Xe=null,n.consentFrom&&n.consent===void 0)try{n.consent=$e(n.consentFrom).read()===!0}catch(h){n.consent=!1}Ge=!1,Ue=null,Je(null),Ye(null),pt=!1,Ne=!1,De=null,Fe=null,Me=[],Zt=null,mt=null,ye==null||ye();let r=typeof window!="undefined"?yo(window.location.search):null;if(r){Zr(r);try{let h=new URL(window.location.href);h.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",h.pathname+h.search+h.hash)}catch(h){}}let o=r!=null?r:Xr();if(o){_s(n,o),et(n),ke(n,"editor mode");return}let a=typeof window!="undefined"?bo(window.location.search):null;if(a){await Os(n,a);return}let i=typeof window!="undefined"?wo(window.location.search):null;if(i){await Is(n,i),ke(n,"persona preview",i);return}let s=(e=n.registry)!=null?e:Object.keys(n.slots).length===0;n.registry===void 0&&!s&&ke(n,"slots declared without registry: true, so dashboard-published components are not applied");let u=s?Es(n):null,c=Ss();try{(t=c==null?void 0:c.stop)==null||t.call(c)}catch(h){}let l=st(n.apiKey),d=[];l&&(ne={persona:l.persona,band:l.band},Se=l.slots,l.slotConfig&&(ve=l.slotConfig),l.palette&&Je(l.palette),l.vocabulary&&Ye(l.vocabulary),Ze(document,V({contentAndOps:!1},c?{onAttr:(h,P)=>d.push([h,P])}:{})),l.layoutOrder&&(Ue=l.layoutOrder,En(Ue,document))),c&&ws(c,d,document);let g=ut(V({apiKey:n.apiKey,consent:n.consent,preConsentBehavior:n.preConsentBehavior,debug:n.debug,persona:n.persona,ingestUrl:uo(n)},Yt?{sdk:Yt}:{}));j=g,et(n),An();let x=Object.entries(n.slots).map(([h,P])=>({id:h,dims:P.dims})),f=so,m={pp:c?c.v:0},E=Array.from(lo(document).keys()),y=[];if(u){let[h]=await Promise.all([yt(u,ht),document.readyState==="loading"?new Promise(P=>document.addEventListener("DOMContentLoaded",P,{once:!0})):null]);Fe=h,h&&(Me=y=co(h,document)[0]),ke(n,"registry scope",h&&y)}let k=g.decide(V(V(V(V({slots:x},f),m),E.length>=2?{sections:E}:{}),s?{slotsFrom:"registry",registrySlotIds:y,render:po(y,document)}:{})),w=await yt(k,ht),b=h=>{var F,S,J,z,K;let P=g.getPersona();P?ne={persona:P.persona,band:P.band}:h.persona&&(ne={persona:h.persona,band:"low"}),Se=h.slots,s?ve=mo(h.slotConfig,y):h.slotConfig&&(ve=h.slotConfig),h.palette&&Je(h.palette),h.vocabulary&&Ye(h.vocabulary),Ue=(F=h.layoutOrder)!=null?F:Ue;let I=()=>{let oe=[],A=Ze(document,{onApplied:(N,X,Y)=>oe.push({slotId:N,arm:X,el:Y})});if(s||ho(n,A),En(Ue,document),Ge=!0,Qe())try{ce==null||ce(),ce=Vt(j,n.apiKey,oe)}catch(N){}};if(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",I,{once:!0}):I(),De=(S=h.goals)!=null?S:null,h.goals&&h.goals.length>0&&n.consent!==!1&&j)try{se==null||se.teardown(),se=Wt(h.goals,j,document,n.apiKey)}catch(oe){}qt=(J=h.sectionMap)!=null?J:null,Qe()&&kn(),ke(n,"applied",{persona:ne,slots:Se,matches:Jt(n)}),!Ne&&(He(n.apiKey,mt=V(V(V({v:1,persona:(z=ne==null?void 0:ne.persona)!=null?z:h.persona,band:(K=ne==null?void 0:ne.band)!=null?K:"low",slots:h.slots,layoutOrder:h.layoutOrder,savedAt:Date.now()},ve?{slotConfig:ve}:{}),h.palette?{palette:h.palette}:{}),h.vocabulary?{vocabulary:h.vocabulary}:{})),Zt=null,go())};if(!w){ke(n,"decide timeout/null \u2014 snapshot state stands",Jt(n)),k.then(h=>{!h||Ge||Ne||j!==g||(b(h),ke(n,"late decide applied",Jt(n)))}).catch(()=>{});return}b(w)}catch(n){io()}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Promise.resolve().then(()=>{So()}))}return Lo(Ls);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/snippet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "SentientUI Style-rung snippet for non-React sites — persona attributes and adaptive style tokens from one script tag",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tsx": "^4.19.2",
|
|
39
39
|
"typescript": "^5.7.2",
|
|
40
40
|
"vitest": "^2.1.8",
|
|
41
|
-
"@sentientui/core": "0.
|
|
41
|
+
"@sentientui/core": "0.35.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsup",
|