@sentientui/snippet 0.11.2 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var SentientSnippet=(()=>{var J=Object.defineProperty,_t=Object.defineProperties,Pt=Object.getOwnPropertyDescriptor,Dt=Object.getOwnPropertyDescriptors,Gt=Object.getOwnPropertyNames,wt=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,jt=Object.prototype.propertyIsEnumerable;var Ct=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))Lt.call(t,n)&&Ct(e,n,t[n]);if(wt)for(var n of wt(t))jt.call(t,n)&&Ct(e,n,t[n]);return e},ct=(e,t)=>_t(e,Dt(t));var Ut=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},qt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Gt(t))!Lt.call(e,a)&&a!==n&&J(e,a,{get:()=>t[a],enumerable:!(r=Pt(t,a))||r.enumerable});return e};var Wt=e=>qt(J({},"__esModule",{value:!0}),e);var se={};Ut(se,{buildStyleOps:()=>Mt,clearTargetHighlights:()=>nt,computeMoveAnchors:()=>tt,deriveSlotId:()=>Q,drawTargetHighlights:()=>At,mount:()=>Rt});function Yt(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function Vt(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:"").trim().toLowerCase(),a=t.text.trim().toLowerCase();if(!(r===a||r.startsWith(a)||a.startsWith(r)))return!1}return!0}function K(e,t){var a;if(e.urlMatch&&!Yt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let d=t.getElementById(e.id);n=d?[d]:[]}if(n.length===0&&((a=e.dataAttr)!=null&&a.name))try{let d=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${d}"]`))}catch(d){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(d){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Vt(r,e.fingerprint)?null:r}function St(e){let t=globalThis;return t.CSS&&typeof t.CSS.escape=="function"?t.CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`)}function Ft(e,t){if(e.id)return`#${St(e.id)}`;let n=[],r=e,a=0;for(;r&&r!==t.body&&r!==t.documentElement&&a<6;){if(r.id){n.unshift(`#${St(r.id)}`);break}let d=r.tagName.toLowerCase(),f=r.parentElement;if(f){let b=Array.from(f.children).filter(x=>x.tagName===r.tagName);b.length>1&&(d+=`:nth-of-type(${b.indexOf(r)+1})`)}n.unshift(d),r=r.parentElement,a++}return n.join(" > ")}function D(e,t){var a;let n={v:1};e.id&&(n.id=e.id);for(let d of["data-framer-name","data-w-id","data-sentient-name"]){let f=e.getAttribute(d);if(f){n.dataAttr={name:d,value:f};break}}n.selector=Ft(e,t);let r=((a=e.textContent)!=null?a:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=P({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function X(e,t,n){return K(e,n)===t}var Jt="__snt_editor_token";function ut(){try{sessionStorage.removeItem(Jt)}catch(e){}}function $t(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 Z(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Q(e,t,n){var b,x;let r=t.id||((b=t.dataAttr)==null?void 0:b.value)||((x=n.textContent)!=null?x:"").trim()||n.tagName,a=Z(r)||"el",d=$t(JSON.stringify(t));return`${e}-${a}-${d}`.slice(0,128)}var Kt="sentient-editor-highlight",Xt="sentient-editor-selection",$="sentient-editor-panel",et="sentient-editor-toast",Tt="sentient-editor-styles",pt="sentient-editor-target-highlight",Zt=10,Qt="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",te="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function It(){var t;if(document.getElementById(Tt))return;let e=document.createElement("style");e.id=Tt,e.textContent=`
1
+ "use strict";var SentientSnippet=(()=>{var J=Object.defineProperty,Ot=Object.defineProperties,Pt=Object.getOwnPropertyDescriptor,Dt=Object.getOwnPropertyDescriptors,Gt=Object.getOwnPropertyNames,wt=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,jt=Object.prototype.propertyIsEnumerable;var Lt=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,P=(e,t)=>{for(var n in t||(t={}))Ct.call(t,n)&&Lt(e,n,t[n]);if(wt)for(var n of wt(t))jt.call(t,n)&&Lt(e,n,t[n]);return e},ct=(e,t)=>Ot(e,Dt(t));var Ut=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},qt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Gt(t))!Ct.call(e,a)&&a!==n&&J(e,a,{get:()=>t[a],enumerable:!(r=Pt(t,a))||r.enumerable});return e};var Wt=e=>qt(J({},"__esModule",{value:!0}),e);var ae={};Ut(ae,{buildStyleOps:()=>Mt,clearTargetHighlights:()=>nt,computeMoveAnchors:()=>tt,deriveSlotId:()=>Q,drawTargetHighlights:()=>At,mount:()=>Rt});function Yt(e){var n,r,a;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(a=t==null?void 0:t.pathname)!=null?a:""}function Ft(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:"").trim().toLowerCase(),a=t.text.trim().toLowerCase();if(!(r===a||r.startsWith(a)||a.startsWith(r)))return!1}return!0}function K(e,t){var a;if(e.urlMatch&&!Yt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let d=t.getElementById(e.id);n=d?[d]:[]}if(n.length===0&&((a=e.dataAttr)!=null&&a.name))try{let d=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${d}"]`))}catch(d){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(d){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Ft(r,e.fingerprint)?null:r}function St(e){let t=globalThis;return t.CSS&&typeof t.CSS.escape=="function"?t.CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`)}function Vt(e,t){if(e.id)return`#${St(e.id)}`;let n=[],r=e,a=0;for(;r&&r!==t.body&&r!==t.documentElement&&a<6;){if(r.id){n.unshift(`#${St(r.id)}`);break}let d=r.tagName.toLowerCase(),f=r.parentElement;if(f){let b=Array.from(f.children).filter(x=>x.tagName===r.tagName);b.length>1&&(d+=`:nth-of-type(${b.indexOf(r)+1})`)}n.unshift(d),r=r.parentElement,a++}return n.join(" > ")}function D(e,t){var a;let n={v:1};e.id&&(n.id=e.id);for(let d of["data-framer-name","data-w-id","data-sentient-name"]){let f=e.getAttribute(d);if(f){n.dataAttr={name:d,value:f};break}}n.selector=Vt(e,t);let r=((a=e.textContent)!=null?a:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=P({tag:e.tagName.toLowerCase()},r?{text:r}:{}),n}function X(e,t,n){return K(e,n)===t}var Jt="__snt_editor_token";function ut(){try{sessionStorage.removeItem(Jt)}catch(e){}}function $t(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 Z(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function Q(e,t,n){var b,x;let r=t.id||((b=t.dataAttr)==null?void 0:b.value)||((x=n.textContent)!=null?x:"").trim()||n.tagName,a=Z(r)||"el",d=$t(JSON.stringify(t));return`${e}-${a}-${d}`.slice(0,128)}var Kt="sentient-editor-highlight",Xt="sentient-editor-selection",$="sentient-editor-panel",et="sentient-editor-toast",Tt="sentient-editor-styles",pt="sentient-editor-target-highlight",Zt=10,Qt="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.",te="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.";function It(){var t;if(document.getElementById(Tt))return;let e=document.createElement("style");e.id=Tt,e.textContent=`
2
2
  @keyframes sntedi-in {
3
3
  from { opacity: 0; transform: translateY(28px) scale(0.94); }
4
4
  to { opacity: 1; transform: translateY(0) scale(1); }
@@ -20,4 +20,4 @@
20
20
  @media (prefers-reduced-motion: reduce) {
21
21
  #${$}, #${$} .sntedi-dot, #${et} { animation: none !important; }
22
22
  }
23
- `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Bt(e){var r;It(),(r=document.getElementById(et))==null||r.remove();let t=l("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=et;let n=l("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,l("div",{},e)),document.body.appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function ee(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function ne(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}}}async function B(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)});return r.ok?"ok":r.status===401?"expired":"error"}catch(r){return"error"}}async function oe(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 Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}function nt(e=document){for(let t of Array.from(e.querySelectorAll(`.${pt}`)))t.remove()}function At(e,t=document){nt(t);let n=0;for(let r of e){if(n>=Zt)break;let a=K(r.locator,t);if(!a)continue;let d=a.getBoundingClientRect(),f=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${d.left}px`,top:`${d.top}px`,width:`${d.width}px`,height:`${d.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});f.className=pt;let b=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${d.left}px`,top:`${Math.max(0,d.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},r.label);b.className=pt,t.body.append(f,b),n+=1}}function tt(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,a=n?D(n,t):null,d=r?D(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&a&&X(a,n,t)?a:null,nextLocator:r&&d&&X(d,r,t)?d:null}}function re(e){return e.length>0&&!/[;{}<>]/.test(e)}function Mt(e){let t={};for(let n of["color","background","fontSize","fontWeight","borderRadius","textAlign"]){let r=e[n];typeof r=="string"&&re(r.trim())&&(t[n]=r.trim())}return t}function l(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function Rt(e){let t=null,n=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=Kt;let r=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});r.id=Xt;let a=()=>{if(!t||!t.isConnected){r.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(r.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},d=()=>a();It();let f=l("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"320px",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)"});f.id=$;let b=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});b.className="sntedi-dot";let x=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});x.append(b,l("span",{},"SentientUI editor"));let Ht=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),ot=l("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),rt=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),it=o=>l("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},o),I=l("button",g("#6366f1"),"Test different text here"),A=l("button",g("#374151"),"Change style"),M=l("button",g("#374151"),"Track clicks as a goal"),R=l("button",g("#374151"),"Track form submissions as a goal"),ft=l("button",g("#374151"),"Track page visits as a goal"),y=l("button",g("#374151"),"Move up"),k=l("button",g("#374151"),"Move down"),G=l("button",g("#6366f1"),"Save this arrangement"),j=l("button",g("#374151"),"Undo"),gt=l("button",ct(P({},g("transparent")),{opacity:"0.6"}),"Close editor"),E=l("button",g("#10b981"),"Publish now \u2014 go live"),w=l("button",g("#10b981"),"Start tracking now");for(let o of[I,A,M,y,k])o.disabled=!0;let mt=[I,A,M,R,y,k];for(let o of mt)o.style.display="none";G.style.display="none",j.style.display="none",E.style.display="none",w.style.display="none",f.append(x,Ht,ot,rt,it("Content & style"),I,A,it("Track a goal"),M,R,ft,it("Move"),y,k,G,j,E,w,gt),document.body.append(n,r,f);let U=l("div",{marginTop:"10px"});f.append(U);let H=()=>{U.textContent=""},bt=(o,i,s)=>{H();let u={};for(let v of o){let T=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},v.label),F=l("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});F.setAttribute("data-field",v.key),v.value!==void 0&&(F.value=v.value),u[v.key]=F,U.append(T,F)}let p=l("button",g("#6366f1"),i),C=l("button",ct(P({},g("transparent")),{opacity:"0.6"}),"Cancel");p.onclick=()=>s(Object.fromEntries(Object.entries(u).map(([v,T])=>[v,T.value]))),C.onclick=H,U.append(p,C)},c=(o,i=!0)=>{rt.textContent=o,rt.style.color=i?"#a7f3d0":"#fca5a5"},q=(o,i)=>{o==="ok"?c(i,!0):c(o==="expired"?"Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.":"\u26A0 Couldn\u2019t save \u2014 try again.",!1)},W=null,st=o=>{W=o,E.style.display="block"};E.onclick=async()=>{if(!W)return;E.disabled=!0,c("Publishing\u2026");let o=await B(e,`/v1/editor/slots/${encodeURIComponent(W)}/publish`,{});E.disabled=!1,o==="ok"?(c("\u2713 Published \u2014 live for new visitors.",!0),E.style.display="none",W=null):c(o==="expired"?"Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.":"\u26A0 Couldn\u2019t publish \u2014 try again.",!1)};let m=null,z=!1,N=null,O=null,h=null,L=null,_=null,Y=null,S=!1,vt=(o,i)=>z?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.",ht=()=>{y.disabled=!z||!h,k.disabled=!z||!L,y.title=y.disabled?vt(h,"above"):"",k.title=k.disabled?vt(L,"below"):""},at=o=>{G.style.display=o?"block":"none",j.style.display=o?"block":"none",ht()},xt=()=>{if(S&&t&&_&&_.insertBefore(t,Y),S=!1,_=null,Y=null,t){let o=tt(t,document);N=o.prevEl,O=o.nextEl,h=o.prevLocator,L=o.nextLocator}a(),at(!1)},yt=o=>{let i=o.target;if(!i||f.contains(i)||i===n)return;nt(document);let s=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},zt=o=>{var s;let i=((s=o.textContent)!=null?s:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},kt=o=>{let i=o.target;if(!i||f.contains(i))return;o.preventDefault(),o.stopPropagation(),xt(),H(),t=i,m=D(i,document);let s=X(m,i,document);z=s,a(),ot.style.display="block",ot.textContent=`Selected: ${zt(i)}`,c(s?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",s);for(let C of mt)C.style.display="block";I.disabled=!s,A.disabled=!s,M.disabled=!s;let u=i.closest("form");R.style.display=u?"block":"none",R.disabled=!u;let p=tt(i,document);N=p.prevEl,O=p.nextEl,h=p.prevLocator,L=p.nextLocator,ht()};I.onclick=()=>{var s,u;if(!t||!m)return;let o=m,i=(u=(s=t.textContent)==null?void 0:s.trim())!=null?u:"";bt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async p=>{let C=p.alt.trim();if(!C){c("\u26A0 Enter alternative wording to test.",!1);return}if(C===p.current.trim()){c("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let v=Q("text",o,t);c("Saving\u2026");let T=await B(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:p.current}},{id:"b",displayName:"Alternative",ops:{text:p.alt}}]}});T==="ok"&&(H(),st(v)),q(T,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let V=null,Nt=o=>{V=o,w.style.display="block"};w.onclick=async()=>{if(!V)return;w.disabled=!0,c("Activating\u2026");let o=await B(e,`/v1/editor/goals/${encodeURIComponent(V)}/publish`,{});w.disabled=!1,o==="ok"?(c("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),w.style.display="none",V=null):c(o==="expired"?"Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.":"\u26A0 Couldn\u2019t activate \u2014 try again.",!1)};let lt=(o,i)=>`${Z(o)||"goal"}-${$t(i)}`.slice(0,128),dt=async(o,i)=>{c("Saving\u2026");let s=await B(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);s==="ok"&&Nt(o),q(s,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};M.onclick=()=>{var i;if(!t||!m)return;let o=lt(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify(m));dt(o,{event:"click",locator:m})},R.onclick=()=>{var u,p;let o=t==null?void 0:t.closest("form");if(!o)return;let i=D(o,document),s=(p=(u=o.getAttribute("id"))!=null?u:o.getAttribute("name"))!=null?p:"form-submitted";dt(lt(s,JSON.stringify(i)),{event:"form_submit",locator:i})},ft.onclick=()=>{let o=window.location.pathname||"/",i=Z(o)?`reached-${Z(o)}`:"page-visited";dt(lt(i,o),{event:"url_reached",urlPattern:o})},A.onclick=()=>{if(!t||!m)return;let o=m;bt([{key:"color",label:"Text colour (e.g. #1a1a1a)",value:""},{key:"background",label:"Background colour",value:""},{key:"fontSize",label:"Font size (e.g. 20px)",value:""},{key:"fontWeight",label:"Font weight (e.g. 700)",value:""},{key:"borderRadius",label:"Corner radius (e.g. 8px)",value:""},{key:"textAlign",label:"Alignment (left/center/right)",value:""}],"Save draft",async i=>{let s=Mt(i);if(Object.keys(s).length===0){c("\u26A0 Enter at least one style change.",!1);return}let u=Q("style",o,t);c("Saving\u2026");let p=await B(e,`/v1/editor/slots/${encodeURIComponent(u)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:s}}]}});p==="ok"&&(H(),st(u)),q(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Et=o=>{if(!t)return;let i=t.parentElement;if(!i)return;S||(_=i,Y=t.nextSibling,S=!0),o==="up"&&N?i.insertBefore(t,N):o==="down"&&O&&i.insertBefore(t,O.nextSibling);let s=tt(t,document);N=s.prevEl,O=s.nextEl,h=s.prevLocator,L=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(u){}a(),at(!0),c("Previewing the new position \u2014 keep moving, save, or undo.")};y.onclick=()=>Et("up"),k.onclick=()=>Et("down"),j.onclick=()=>{xt(),c("Move undone \u2014 back to the original position.")},G.onclick=async()=>{if(!t||!m||!S||!z)return;let o=h?"moveAfter":"moveBefore",i=h!=null?h:L;if(!i){c("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=Q("move",m,t);c("Saving\u2026");let u=await B(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:m,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});u==="ok"&&(S=!1,_=null,Y=null,at(!1),st(s)),q(u,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let Ot=()=>{document.removeEventListener("mousemove",yt,!0),document.removeEventListener("click",kt,!0),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d),nt(document),n.remove(),r.remove(),f.remove(),ut()};gt.onclick=Ot,document.addEventListener("mousemove",yt,!0),document.addEventListener("click",kt,!0),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d)}function g(e){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:e,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}async function ie(){if(typeof document=="undefined")return;let e=ee();if(!e)return;let t=await ne(e);if(!t.ok){t.unauthorized?(ut(),Bt(Qt)):Bt(te);return}if(document.getElementById($))return;Rt(e);let n=await oe(e);At(n,document)}ie();return Wt(se);})();
23
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Bt(e){var r;It(),(r=document.getElementById(et))==null||r.remove();let t=l("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=et;let n=l("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,l("div",{},e)),document.body.appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function ee(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function ne(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}}}async function B(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)});return r.ok?"ok":r.status===401?"expired":"error"}catch(r){return"error"}}async function oe(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 Array.isArray(n.targets)?n.targets:[]}catch(t){return[]}}function nt(e=document){for(let t of Array.from(e.querySelectorAll(`.${pt}`)))t.remove()}function At(e,t=document){nt(t);let n=0;for(let r of e){if(n>=Zt)break;let a=K(r.locator,t);if(!a)continue;let d=a.getBoundingClientRect(),f=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${d.left}px`,top:`${d.top}px`,width:`${d.width}px`,height:`${d.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});f.className=pt;let b=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${d.left}px`,top:`${Math.max(0,d.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},r.label);b.className=pt,t.body.append(f,b),n+=1}}function tt(e,t){let n=e.previousElementSibling,r=e.nextElementSibling,a=n?D(n,t):null,d=r?D(r,t):null;return{prevEl:n,nextEl:r,prevLocator:n&&a&&X(a,n,t)?a:null,nextLocator:r&&d&&X(d,r,t)?d:null}}var re=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function ie(e){var t;if(e.length===0||/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!re.test((t=n[1])!=null?t:""))return!1;return!0}function Mt(e){let t={};for(let n of["color","background","fontSize","fontWeight","borderRadius","textAlign"]){let r=e[n];typeof r=="string"&&ie(r.trim())&&(t[n]=r.trim())}return t}function l(e,t,n){let r=document.createElement(e);return Object.assign(r.style,t),n!==void 0&&(r.textContent=n),r}function Rt(e){let t=null,n=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=Kt;let r=l("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #10b981",background:"rgba(16,185,129,0.10)",borderRadius:"4px",display:"none"});r.id=Xt;let a=()=>{if(!t||!t.isConnected){r.style.display="none";return}let o=t.getBoundingClientRect();Object.assign(r.style,{display:"block",left:`${o.left-2}px`,top:`${o.top-2}px`,width:`${o.width}px`,height:`${o.height}px`})},d=()=>a();It();let f=l("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"320px",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)"});f.id=$;let b=l("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});b.className="sntedi-dot";let x=l("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});x.append(b,l("span",{},"SentientUI editor"));let Ht=l("div",{opacity:"0.85",marginBottom:"8px"},"Click any element on the page to adapt it."),ot=l("div",{fontSize:"12px",marginBottom:"6px",padding:"5px 8px",borderRadius:"8px",background:"rgba(16,185,129,0.14)",border:"1px solid rgba(16,185,129,0.45)",display:"none",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}),rt=l("div",{fontSize:"12px",marginBottom:"8px",minHeight:"16px"}),it=o=>l("div",{fontSize:"10px",letterSpacing:"0.08em",textTransform:"uppercase",opacity:"0.55",marginTop:"10px",marginBottom:"2px"},o),I=l("button",g("#6366f1"),"Test different text here"),A=l("button",g("#374151"),"Change style"),M=l("button",g("#374151"),"Track clicks as a goal"),R=l("button",g("#374151"),"Track form submissions as a goal"),ft=l("button",g("#374151"),"Track page visits as a goal"),y=l("button",g("#374151"),"Move up"),k=l("button",g("#374151"),"Move down"),G=l("button",g("#6366f1"),"Save this arrangement"),j=l("button",g("#374151"),"Undo"),gt=l("button",ct(P({},g("transparent")),{opacity:"0.6"}),"Close editor"),E=l("button",g("#10b981"),"Publish now \u2014 go live"),w=l("button",g("#10b981"),"Start tracking now");for(let o of[I,A,M,y,k])o.disabled=!0;let mt=[I,A,M,R,y,k];for(let o of mt)o.style.display="none";G.style.display="none",j.style.display="none",E.style.display="none",w.style.display="none",f.append(x,Ht,ot,rt,it("Content & style"),I,A,it("Track a goal"),M,R,ft,it("Move"),y,k,G,j,E,w,gt),document.body.append(n,r,f);let U=l("div",{marginTop:"10px"});f.append(U);let H=()=>{U.textContent=""},bt=(o,i,s)=>{H();let u={};for(let v of o){let T=l("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},v.label),V=l("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});V.setAttribute("data-field",v.key),v.value!==void 0&&(V.value=v.value),u[v.key]=V,U.append(T,V)}let p=l("button",g("#6366f1"),i),L=l("button",ct(P({},g("transparent")),{opacity:"0.6"}),"Cancel");p.onclick=()=>s(Object.fromEntries(Object.entries(u).map(([v,T])=>[v,T.value]))),L.onclick=H,U.append(p,L)},c=(o,i=!0)=>{rt.textContent=o,rt.style.color=i?"#a7f3d0":"#fca5a5"},q=(o,i)=>{o==="ok"?c(i,!0):c(o==="expired"?"Editor session expired \u2014 reopen it from your dashboard to save this. Your earlier changes are safe.":"\u26A0 Couldn\u2019t save \u2014 try again.",!1)},W=null,st=o=>{W=o,E.style.display="block"};E.onclick=async()=>{if(!W)return;E.disabled=!0,c("Publishing\u2026");let o=await B(e,`/v1/editor/slots/${encodeURIComponent(W)}/publish`,{});E.disabled=!1,o==="ok"?(c("\u2713 Published \u2014 live for new visitors.",!0),E.style.display="none",W=null):c(o==="expired"?"Editor session expired \u2014 reopen it from your dashboard to publish. Your saved draft is safe.":"\u26A0 Couldn\u2019t publish \u2014 try again.",!1)};let m=null,z=!1,_=null,N=null,h=null,C=null,O=null,Y=null,S=!1,vt=(o,i)=>z?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.",ht=()=>{y.disabled=!z||!h,k.disabled=!z||!C,y.title=y.disabled?vt(h,"above"):"",k.title=k.disabled?vt(C,"below"):""},at=o=>{G.style.display=o?"block":"none",j.style.display=o?"block":"none",ht()},xt=()=>{if(S&&t&&O&&O.insertBefore(t,Y),S=!1,O=null,Y=null,t){let o=tt(t,document);_=o.prevEl,N=o.nextEl,h=o.prevLocator,C=o.nextLocator}a(),at(!1)},yt=o=>{let i=o.target;if(!i||f.contains(i)||i===n)return;nt(document);let s=i.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},zt=o=>{var s;let i=((s=o.textContent)!=null?s:"").trim().replace(/\s+/g," ");return i?i.length>40?`${i.slice(0,37)}\u2026`:i:o.tagName.toLowerCase()},kt=o=>{let i=o.target;if(!i||f.contains(i))return;o.preventDefault(),o.stopPropagation(),xt(),H(),t=i,m=D(i,document);let s=X(m,i,document);z=s,a(),ot.style.display="block",ot.textContent=`Selected: ${zt(i)}`,c(s?"\u2713 Matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",s);for(let L of mt)L.style.display="block";I.disabled=!s,A.disabled=!s,M.disabled=!s;let u=i.closest("form");R.style.display=u?"block":"none",R.disabled=!u;let p=tt(i,document);_=p.prevEl,N=p.nextEl,h=p.prevLocator,C=p.nextLocator,ht()};I.onclick=()=>{var s,u;if(!t||!m)return;let o=m,i=(u=(s=t.textContent)==null?void 0:s.trim())!=null?u:"";bt([{key:"current",label:"Current wording",value:i},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async p=>{let L=p.alt.trim();if(!L){c("\u26A0 Enter alternative wording to test.",!1);return}if(L===p.current.trim()){c("\u26A0 Enter different wording \u2014 the alternative matches the current text.",!1);return}let v=Q("text",o,t);c("Saving\u2026");let T=await B(e,`/v1/editor/slots/${encodeURIComponent(v)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:p.current}},{id:"b",displayName:"Alternative",ops:{text:p.alt}}]}});T==="ok"&&(H(),st(v)),q(T,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let F=null,_t=o=>{F=o,w.style.display="block"};w.onclick=async()=>{if(!F)return;w.disabled=!0,c("Activating\u2026");let o=await B(e,`/v1/editor/goals/${encodeURIComponent(F)}/publish`,{});w.disabled=!1,o==="ok"?(c("\u2713 Tracking is live \u2014 it counts from your next visitor.",!0),w.style.display="none",F=null):c(o==="expired"?"Editor session expired \u2014 reopen it from your dashboard to activate. Your saved goal is safe.":"\u26A0 Couldn\u2019t activate \u2014 try again.",!1)};let lt=(o,i)=>`${Z(o)||"goal"}-${$t(i)}`.slice(0,128),dt=async(o,i)=>{c("Saving\u2026");let s=await B(e,`/v1/editor/goals/${encodeURIComponent(o)}`,i);s==="ok"&&_t(o),q(s,"\u2713 Goal saved. Click \u201CStart tracking now\u201D to go live.")};M.onclick=()=>{var i;if(!t||!m)return;let o=lt(((i=t.textContent)!=null?i:"").trim()||"element-clicked",JSON.stringify(m));dt(o,{event:"click",locator:m})},R.onclick=()=>{var u,p;let o=t==null?void 0:t.closest("form");if(!o)return;let i=D(o,document),s=(p=(u=o.getAttribute("id"))!=null?u:o.getAttribute("name"))!=null?p:"form-submitted";dt(lt(s,JSON.stringify(i)),{event:"form_submit",locator:i})},ft.onclick=()=>{let o=window.location.pathname||"/",i=Z(o)?`reached-${Z(o)}`:"page-visited";dt(lt(i,o),{event:"url_reached",urlPattern:o})},A.onclick=()=>{if(!t||!m)return;let o=m;bt([{key:"color",label:"Text colour (e.g. #1a1a1a)",value:""},{key:"background",label:"Background colour",value:""},{key:"fontSize",label:"Font size (e.g. 20px)",value:""},{key:"fontWeight",label:"Font weight (e.g. 700)",value:""},{key:"borderRadius",label:"Corner radius (e.g. 8px)",value:""},{key:"textAlign",label:"Alignment (left/center/right)",value:""}],"Save draft",async i=>{let s=Mt(i);if(Object.keys(s).length===0){c("\u26A0 Enter at least one style change.",!1);return}let u=Q("style",o,t);c("Saving\u2026");let p=await B(e,`/v1/editor/slots/${encodeURIComponent(u)}`,{kind:"arms",target:o,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:s}}]}});p==="ok"&&(H(),st(u)),q(p,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")})};let Et=o=>{if(!t)return;let i=t.parentElement;if(!i)return;S||(O=i,Y=t.nextSibling,S=!0),o==="up"&&_?i.insertBefore(t,_):o==="down"&&N&&i.insertBefore(t,N.nextSibling);let s=tt(t,document);_=s.prevEl,N=s.nextEl,h=s.prevLocator,C=s.nextLocator;try{t.scrollIntoView({block:"nearest",behavior:"smooth"})}catch(u){}a(),at(!0),c("Previewing the new position \u2014 keep moving, save, or undo.")};y.onclick=()=>Et("up"),k.onclick=()=>Et("down"),j.onclick=()=>{xt(),c("Move undone \u2014 back to the original position.")},G.onclick=async()=>{if(!t||!m||!S||!z)return;let o=h?"moveAfter":"moveBefore",i=h!=null?h:C;if(!i){c("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=Q("move",m,t);c("Saving\u2026");let u=await B(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:m,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[o]:i}}]}});u==="ok"&&(S=!1,O=null,Y=null,at(!1),st(s)),q(u,"\u2713 Saved as a draft. Click \u201CPublish now\u201D to go live.")};let Nt=()=>{document.removeEventListener("mousemove",yt,!0),document.removeEventListener("click",kt,!0),window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d),nt(document),n.remove(),r.remove(),f.remove(),ut()};gt.onclick=Nt,document.addEventListener("mousemove",yt,!0),document.addEventListener("click",kt,!0),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d)}function g(e){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:e,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}async function se(){if(typeof document=="undefined")return;let e=ee();if(!e)return;let t=await ne(e);if(!t.ok){t.unauthorized?(ut(),Bt(Qt)):Bt(te);return}if(document.getElementById($))return;Rt(e);let n=await oe(e);At(n,document)}se();return Wt(ae);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var ve=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames,Xe=Object.getOwnPropertySymbols;var Qe=Object.prototype.hasOwnProperty,en=Object.prototype.propertyIsEnumerable;var Ze=(e,t,n)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,re=(e,t)=>{for(var n in t||(t={}))Qe.call(t,n)&&Ze(e,n,t[n]);if(Xe)for(var n of Xe(t))en.call(t,n)&&Ze(e,n,t[n]);return e};var et=(e,t)=>()=>(e&&(t=e(e=0)),t);var tt=(e,t)=>{for(var n in t)ve(e,n,{get:t[n],enumerable:!0})},tn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qt(t))!Qe.call(e,o)&&o!==n&&ve(e,o,{get:()=>t[o],enumerable:!(r=Zt(t,o))||r.enumerable});return e};var nn=e=>tn(ve({},"__esModule",{value:!0}),e);var rn,on,sn,nt,an,ln,rt,I,ge,be=et(()=>{"use strict";rn=Object.defineProperty,on=Object.defineProperties,sn=Object.getOwnPropertyDescriptors,nt=Object.getOwnPropertySymbols,an=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable,rt=(e,t,n)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))an.call(t,n)&&rt(e,n,t[n]);if(nt)for(var n of nt(t))ln.call(t,n)&&rt(e,n,t[n]);return e},ge=(e,t)=>on(e,sn(t))});var pt={};tt(pt,{LOCAL_ENGINE_AVAILABLE:()=>dn,createLocalEngine:()=>pn});function pn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var dn,ft=et(()=>{"use strict";dn=!1});var or={};tt(or,{applyPersonaAttributes:()=>Oe,applyRegistrySlots:()=>Re,applySlotArms:()=>_e,applySlotAttributes:()=>Ce,parseEditorToken:()=>Vt,parsePersonaPreview:()=>Ht,parsePreview:()=>Ft,parseSnippetConfig:()=>Ie,reapply:()=>Fe,run:()=>Xt,version:()=>Je});be();function we(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function ot(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 je(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 we(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[i,s]of Object.entries((n=e.dims)!=null?n:{}))o[i]=(r=s[0])!=null?r:"";return we(o)}function it(e,t){var n,r;return e.dims!=null?(r=(n=ot(t))!=null?n:ot(je(e)))!=null?r:{}:t}function oe(e){return e>=.3?e<.7?"medium":"high":"low"}var cn=["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 st(e){return un(e)!==null}function un(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=cn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function at(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 lt(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 ct(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ut(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Me(e){return I(I(I({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 Ne(e){let t=Me(e);return it(t,je(t))}function dt(e){return typeof e=="string"?e:we(e)}be();var fn="_snt_uid",le="_snt_uid";function gn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(t){}let e=()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${e()}-${e()}-${e()}-${e()}`}function mn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function hn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function yn(e){try{return localStorage.getItem(e)}catch(t){return null}}function vn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function bn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function wn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function Sn(e){try{sessionStorage.removeItem(e)}catch(t){}}function xn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,/(?:^|; )_snt_uid_probe=1/.test(document.cookie)||document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function kn(e){try{localStorage.removeItem(e)}catch(t){}}function An(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var En={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ht(e){var t,n,r,o,i,s;if(typeof window=="undefined")return En;let l=(t=e==null?void 0:e.cookieName)!=null?t:fn,a=((n=e==null?void 0:e.cookieTTLDays)!=null?n:365)*24*60*60,c=(s=(i=(o=(r=mn(l))!=null?r:yn(le))!=null?o:bn(le))!=null?i:e==null?void 0:e.ssrSessionId)!=null?s:gn();hn(l,c,a);let u=vn(le,c),p=xn(l),v=u?!1:wn(le,c),g=!u&&!p&&!v;return{getSessionId:()=>c,isEphemeral:()=>g,destroy:()=>{c=null,An(l),kn(le),Sn(le)}}}function yt(e){return`_snt_retry_${e.slice(0,12)}`}var In={push:()=>{},flush:()=>{},destroy:()=>{}};function On(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(t),r.slice(-e)):[]}catch(n){return[]}}function $e(e,t,n){try{let r=[...(()=>{try{let o=localStorage.getItem(n);if(!o)return[];let i=JSON.parse(o);return Array.isArray(i)?i:[]}catch(o){return[]}})(),...e].slice(-t);localStorage.setItem(n,JSON.stringify(r))}catch(r){}}function Cn(e){var t,n,r;if(typeof window=="undefined")return In;let o=(t=e.flushIntervalMs)!=null?t:5e3,i=(n=e.maxBatchSize)!=null?n:20,s=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,a=e.apiKey,c=yt(a),u=[],p=new Set,v=[],g=f=>{for(let w of f)b.delete(w),!p.has(w)&&(p.add(w),v.push(w));for(;v.length>500;){let w=v.shift();w&&p.delete(w)}},b=new Set,m=f=>{p.has(f.id)||b.has(f.id)||(b.add(f.id),u.push(f))},E=On(s,c);for(let f of E)m(f);let O=0,S=0,L=f=>{if(f.length===0)return;let w=JSON.stringify(f),k=f.map(d=>d.id),B;try{B=fetch(l,{method:"POST",keepalive:!0,body:w,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(d){$e(f,s,c);for(let h of k)b.delete(h);S++,O=Date.now()+Math.min(6e4,1e3*2**Math.min(S,6));return}let F=d=>{if(d.ok||d.status>=400&&d.status<500&&d.status!==429){g(k),S=0,O=0;return}$e(f,s,c);for(let h of k)b.delete(h);S++,O=Date.now()+Math.min(6e4,1e3*2**Math.min(S,6))};B instanceof Promise?B.then(F).catch(()=>{$e(f,s,c);for(let d of k)b.delete(d);S++,O=Date.now()+Math.min(6e4,1e3*2**Math.min(S,6))}):F(B)},N=typeof TextEncoder!="undefined"?new TextEncoder:null,Q=f=>N?N.encode(f).length:f.length,ee=f=>{let w=[],k=2;for(let B of f){let F=Q(JSON.stringify(B))+1;if(w.length>0&&k+F>57344||w.length>=i)break;w.push(B),k+=F}return w},C=()=>{try{if(Date.now()<O)return;for(;u.length>0;){let f=u.filter(k=>!p.has(k.id));if(u.length=0,f.length===0)break;let w=ee(f);if(w.length===0)break;w.length<f.length&&u.push(...f.slice(w.length)),L(w)}}catch(f){}},$=!0,R=null;R=setInterval(()=>{$&&C()},o);let y=()=>{document.visibilityState==="hidden"&&C()},x=()=>{C()};return document.addEventListener("visibilitychange",y),window.addEventListener("pagehide",x),{push(f){m(f),u.length>=i&&C()},flush:C,destroy(){$=!1,R!==null&&(clearInterval(R),R=null),document.removeEventListener("visibilitychange",y),window.removeEventListener("pagehide",x),C()}}}var Ge="_snt_asgn_";function Se(e,t){return`${e}:${t}`}function _n(e,t){return`${Ge}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function gt(e){let t=e.slice(Ge.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(r){return null}}function Be(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(Ge)&&e.push(n)}return e}catch(e){return[]}}function Rn(e=18e5){let t=new Map,n=r=>r.assignedAt+e<Date.now();return typeof window!="undefined"&&(()=>{for(let r of Be())try{let o=localStorage.getItem(r);if(!o)continue;let i=JSON.parse(o);if(n(i)){localStorage.removeItem(r);continue}let s=gt(r);if(!s)continue;t.set(Se(s.componentId,s.segment),i)}catch(o){}})(),{get(r,o){let i=t.get(Se(r,o));return i?n(i)?(t.delete(Se(r,o)),null):i:null},set(r,o,i){let s=Se(r,o);t.set(s,i);try{localStorage.setItem(_n(r,o),JSON.stringify(i))}catch(l){}},invalidate(r){let o=`${r}:`;for(let i of[...t.keys()])i.startsWith(o)&&t.delete(i);for(let i of Be()){let s=gt(i);if((s==null?void 0:s.componentId)===r)try{localStorage.removeItem(i)}catch(l){}}},clear(){t.clear();for(let r of Be())try{localStorage.removeItem(r)}catch(o){}}}}var ke="_snt_snap:",Ln=["low","medium","high"];function Ae(e){try{let t=localStorage.getItem(ke+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Ln.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function me(e,t){try{localStorage.setItem(ke+e,JSON.stringify(t))}catch(n){}}var Ue="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",vt="[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.",mt=!1,xe=!1;function Pn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Tn(e){var t;let n=ht({ssrSessionId:e.ssrSessionId}),r=(t=n.getSessionId())!=null?t:"local",o=Pn(),i=Promise.resolve().then(()=>(ft(),pt)).then(a=>{let c=a;return c.LOCAL_ENGINE_AVAILABLE?(mt||(mt=!0,console.info(vt)),c):(xe||(xe=!0,console.error(Ue)),null)}).catch(()=>(xe||(xe=!0,console.error(Ue)),null)),s=null;function l(a){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=a.persona,c.dataset.sentientConfidence=oe(a.confidence))}return{isLocal:!0,async decide(a){var c,u,p;let v=await i;if(!v)return null;let g=v.createLocalEngine({sessionId:r,forcedPersona:o}).decide(a);return s=ge(I({},g),{layoutOrder:(u=(c=g.layoutOrder)!=null?c:s==null?void 0:s.layoutOrder)!=null?u:null,slots:I(I({},(p=s==null?void 0:s.slots)!=null?p:{}),g.slots)}),me(e.apiKey||"local",{v:1,persona:s.persona,band:oe(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),l(g),g},getSlotResult(a){var c,u,p;return(p=(u=s==null?void 0:s.slots[a])!=null?u:(c=e.initialSlots)==null?void 0:c[a])!=null?p:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:oe(s.confidence)}:null},async assign(a,c){var u;let p=await i;return!p||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(u=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:a,variantIds:c}]}).assignments[a])!=null?u:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function he(e,t,n,r){let o=[];{let i=!1,s=[],l=()=>{if(i)return;let a=Date.now();for(s.push(a);s.length>0&&a-s[0]>500;)s.shift();s.length>=3&&(i=!0,e("rage_click"))};t.addEventListener("click",l),o.push(()=>t.removeEventListener("click",l))}{let i=!1,s=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let a=typeof window!="undefined"?window.getSelection():null,c=a?a.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",s),o.push(()=>document.removeEventListener("copy",s))}{let i=!1,s=!1,l=null,a=()=>{l!==null&&(clearTimeout(l),l=null)},c=()=>{i||!s||(a(),l=setTimeout(()=>{!i&&s&&(i=!0,e("scroll_hesitation"))},3e3))},u=()=>{a(),c()},p=g=>{for(let b of g)s=b.intersectionRatio>.3,s?c():a()},v=new IntersectionObserver(p,{threshold:[.3]});v.observe(t),window.addEventListener("scroll",u,{passive:!0}),o.push(()=>{v.disconnect(),window.removeEventListener("scroll",u),a()})}if((r==null?void 0:r.tabLoss)!==!1){let i=!1,s=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let a=Date.now()-s;a<15e3&&(i=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of o)i()}}var bt="https://api.sentient-ui.com/v1/events",ie=new Map,wt=null;function Ke(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}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 ce={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function Dn(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function St(e){return e.replace(/\/events\/?$/,"")}function se(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function qe(e){if(typeof window=="undefined")return;let t=e!=null?e:wt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=ie.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:r,upgrade:o}=n;if(!o||r.respectDoNotTrack!==!1&&se())return;let i=Ee(ge(I({},r),{consent:!0}));o(i),ie.set(t,{config:ge(I({},r),{consent:!0}),upgrade:null})}function jn(e){var t;let n=St((t=e.ingestUrl)!=null?t:bt),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(l,a,c){try{let u=new URLSearchParams({componentId:l});for(let v of a!=null?a:[])u.append("variantIds[]",v);let p=await fetch(`${n}/winner?${u.toString()}`,{headers:r});return p.ok?{variantId:(await p.json()).variantId,assignmentTtlMs:0}:a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}catch(u){return a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},i={track:l=>o.track(l),goal:(l,a,c,u)=>o.goal(l,a,c,u),componentGoal:(l,a,c)=>o.componentGoal(l,a,c),identify:l=>o.identify(l),getAssignment:(l,a)=>o.getAssignment(l,a),assign:(l,a,c,u)=>o.assign(l,a,c,u),decide:l=>o.decide(l),getSlotResult:l=>o.getSlotResult(l),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function s(l){o=l}return{proxy:i,setInner:s}}function Ee(e){var t,n,r,o,i,s,l,a,c;if(typeof window=="undefined")return ce;wt=e.apiKey;let u=e.respectDoNotTrack!==!1&&se(),p=e.consent===!1||u,v=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!v&&e.localMode!==!1)return p?(ie.set(e.apiKey||"local",{config:e,upgrade:null}),ce):(ie.set(e.apiKey||"local",{config:e,upgrade:null}),Tn(e));if(p){if(e.preConsentBehavior==="statistical_winner"){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."),ce;let{proxy:d,setInner:h}=jn(e);return ie.set(e.apiKey,{config:e,upgrade:u?null:h}),d}return ie.set(e.apiKey,{config:e,upgrade:null}),ce}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."),ce;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ce;let g=(t=e.ingestUrl)!=null?t:bt,b=Date.now(),m=ht({ssrSessionId:e.ssrSessionId}),E=Rn(),O=Cn({ingestUrl:g,apiKey:e.apiKey}),S=St(g),L={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},N=at((n=navigator.userAgent)!=null?n:""),Q=typeof window!="undefined"?window.location.origin:void 0,ee=lt((r=document.referrer)!=null?r:"",Q),C=(o=e.sessionSegment)!=null?o:`${N}:${ee}`,$=new Map,R=new Map,y=null,x=d=>{for(let h of d)R.has(h.id)||R.set(h.id,Ne(h))};if(e.initialSlots)for(let[d,h]of Object.entries(e.initialSlots))R.set(d,h);let f=Ae(e.apiKey);if(f)for(let[d,h]of Object.entries(f.slots))R.has(d)||R.set(d,h);let w={low:.15,medium:.5,high:.85};if(e.initialPersona)y=I({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?y={persona:d.sentientPersona,confidence:(s=w[(i=d.sentientConfidence)!=null?i:"low"])!=null?s:.15}:f&&(y={persona:f.persona,confidence:(l=w[f.band])!=null?l:.15})}if(e.initialAssignments)for(let[d,h]of Object.entries(e.initialAssignments))E.set(d,C,{variantId:h,assignedAt:Date.now(),segment:C,confidence:1});let k=Promise.resolve(),B=m.getSessionId();if(B){let d=ct((a=document.referrer)!=null?a:""),h=I(I({sessionId:B,deviceClass:N,trafficSource:ee,referrerDomain:d,utmParams:Dn(),timeOfDay:ut(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:m.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||st((c=navigator.userAgent)!=null?c:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{k=fetch(`${S}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(h),headers:L}).then(_=>{_.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")}).catch(()=>{})}catch(_){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:O});let F={goal(d,h={},_=1,G=0){let K=m.getSessionId();if(!K)return;let D=Ke();k.then(()=>{fetch(`${S}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:K,name:d,metadata:h,weight:_,stepIndex:G,goalId:D}),headers:L}).catch(()=>{})})},componentGoal(d,h,_){var G,K,D;let H=m.getSessionId();if(!H)return;let q=E.get(d,C),W=q?null:(G=R.get(d))!=null?G:null;if(!q&&W===null){e.debug&&console.warn(`[sentient] componentGoal("${d}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let te=q?q.variantId:dt(W),z={id:Ke(),sessionId:H,projectId:e.apiKey,componentId:d,variantId:te,eventType:"goal_achieved",goalType:h,payload:I({reward:(K=_==null?void 0:_.reward)!=null?K:1},(D=_==null?void 0:_.metadata)!=null?D:{}),timestamp:Date.now(),timeInSession:Date.now()-b};e.debug&&console.log("[sentient] componentGoal",z),k.then(()=>O.push(z))},identify(d){let h=m.getSessionId();h&&k.then(()=>{fetch(`${S}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:h,userId:d,ephemeral:m.isEphemeral()}),headers:L}).catch(()=>{})})},track(d){let h=m.getSessionId();if(!h)return;let _=ge(I({},d),{id:Ke(),sessionId:h,timestamp:Date.now(),timeInSession:Date.now()-b});e.debug&&console.log("[sentient] track",_),k.then(()=>O.push(_))},getAssignment(d,h){return E.get(d,h)},async assign(d,h,_,G){let K=m.getSessionId();if(!K)return null;let D=E.get(d,C);if(D&&(h!=null&&h.length||D.content!==void 0))return{variantId:D.variantId,assignmentTtlMs:0,content:D.content};let H=$.get(d);if(H)return H;let q=(async()=>{await k;try{let W={sessionId:K,componentId:d,variantIds:h};G!==void 0?W.agentDataByVariant=G:_!==void 0&&(W.agentData=_);let te=await fetch(`${S}/assign`,{method:"POST",body:JSON.stringify(W),headers:L});if(!te.ok)return null;let z=await te.json();return E.set(d,C,{variantId:z.variantId,assignedAt:Date.now(),segment:C,confidence:1,content:z.content}),z}catch(W){return null}finally{$.delete(d)}})();return $.set(d,q),q},async decide(d){var h,_,G,K,D,H,q,W,te,z;let He=m.getSessionId();if(!He)return null;let de=(h=d.slots)!=null?h:[];await k;try{let ne={sessionId:He};d.sections&&d.sections.length>0&&(ne.sections=d.sections.map(j=>({id:j}))),ne.components=(_=d.components)!=null?_:[],de.length>0&&(ne.slots=de.map(Me)),d.slotsFrom==="registry"&&(ne.slotsFrom="registry"),d.v&&(ne.v=d.v);let Ye=await fetch(`${S}/decide`,{method:"POST",body:JSON.stringify(ne),headers:L});if(!Ye.ok)return x(de),null;let T=await Ye.json(),pe={};for(let j of de)pe[j.id]=(K=(G=T.slots)==null?void 0:G[j.id])!=null?K:Ne(j);if(T.slots)for(let[j,fe]of Object.entries(T.slots))j in pe||(pe[j]=fe);for(let[j,fe]of Object.entries(pe))R.set(j,fe);y={persona:(D=T.persona)!=null?D:"unknown",confidence:(H=T.confidence)!=null?H:0};for(let[j,fe]of Object.entries((q=T.assignments)!=null?q:{}))E.set(j,C,{variantId:fe,assignedAt:Date.now(),segment:C,confidence:1});return me(e.apiKey,I({v:1,persona:y.persona,band:oe(y.confidence),slots:Object.fromEntries(R),layoutOrder:(W=T.layoutOrder)!=null?W:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{})),I(I({layoutOrder:(te=T.layoutOrder)!=null?te:null,assignments:(z=T.assignments)!=null?z:{},slots:pe,persona:y.persona,confidence:y.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{})}catch(ne){return x(de),null}},getSlotResult(d){var h;return(h=R.get(d))!=null?h:null},getPersona(){return y?{persona:y.persona,confidence:y.confidence,band:oe(y.confidence)}:null},async fetchWeights(){var d;try{let h=await fetch(`${S}/weights`,{headers:L});return h.ok?(d=(await h.json()).components)!=null?d:[]:[]}catch(h){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){O.destroy(),e.debug&&console.log("[sentient] disposed")},destroy(){O.destroy(),m.destroy();try{localStorage.removeItem(ke+e.apiKey),localStorage.removeItem(yt(e.apiKey))}catch(d){}e.debug&&console.log("[sentient] destroyed")}};if(ie.set(e.apiKey,{config:e,upgrade:null}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=F)}return F}var xt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Mn=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],Nn=[["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|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]];function $n(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function kt(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of Mn)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of Nn)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function At(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:$n(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function Et(e){return kt(At(e)).type}be();var Ot="section, header, footer, nav, main > div, [data-sentient-section]";function Bn(e){var t;return((t=e.parentElement)==null?void 0:t.closest(Ot))!=null}function Kn(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 It=()=>{};function Ct(e,t){var n,r,o,i,s,l,a,c,u;let p=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!p||typeof IntersectionObserver=="undefined"||se()||!t.apiKey)return It;let v=(r=t.apiBase)!=null?r:"https://api.sentient-ui.com",g=Array.from(p.querySelectorAll(Ot)).filter(y=>!Bn(y));if(g.length===0)return It;let b=new Map,m=new Map,E=new Map;for(let y of g){let x=y.getAttribute("data-sentient-type"),f=x&&xt.includes(x)?x:null,w=(i=f!=null?f:(o=t.typeOf)==null?void 0:o.call(t,y))!=null?i:Et(y),k=`nc-${w}`;b.set(y,k),m.set(k,w),f?E.set(k,"markup"):E.has(k)||E.set(k,"auto")}let O=(c=(a=(l=(s=p.defaultView)!=null?s:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:a.pathname)!=null?c:"/";Kn(t.apiKey,v,O,[...m.entries()].map(([y,x])=>{var f;return{componentId:y,semanticType:x,source:(f=E.get(y))!=null?f:"auto"}}));let S=new Map,L=y=>{let x=S.get(y);return x||(x={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(y,x)),x},N=new IntersectionObserver(y=>{for(let x of y){let f=b.get(x.target);if(!f)continue;let w=L(f);x.isIntersecting?(w.intersecting=!0,w.enterAt=Date.now(),x.intersectionRatio>w.scroll&&(w.scroll=x.intersectionRatio)):(w.intersecting=!1,w.enterAt!=null&&(w.ms+=Date.now()-w.enterAt,w.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let y of b.keys())N.observe(y);let Q=()=>{let y=Date.now();for(let[x,f]of S)if(f.enterAt!=null&&(f.ms+=y-f.enterAt,f.enterAt=null),!(f.ms<=0)){try{e.track({projectId:t.apiKey,componentId:x,eventType:"dwell",payload:{dwell_time:Math.round(f.ms),scroll_depth:Number(f.scroll.toFixed(2))}})}catch(w){}f.ms=0}},ee=()=>{if(p.hidden)Q();else{let y=Date.now();for(let x of S.values())x.intersecting&&(x.enterAt=y)}},C=()=>{Q();try{N.disconnect()}catch(y){}};p.addEventListener("visibilitychange",ee);let $=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0;$==null||$.addEventListener("pagehide",C);let R=[];return t.microSignals&&[...b.entries()].forEach(([y,x],f)=>{R.push(he((w,k={})=>{try{e.track({projectId:t.apiKey,componentId:x,eventType:"micro_signal",payload:I({signalType:w},k)})}catch(B){}},y,void 0,{tabLoss:f===0}))}),()=>{Q(),p.removeEventListener("visibilitychange",ee),$==null||$.removeEventListener("pagehide",C);for(let y of R)y();try{N.disconnect()}catch(y){}}}var Un=["landing","ecommerce","saas","marketplace"];function Gn(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(i=>typeof i=="string"))return null;n[r]=o}return n}function qn(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Ie(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=Un.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let l=s,a=Gn(l.dims);if(!a||l.target!==void 0&&typeof l.target!="string")continue;let c=l.arms!==void 0?qn(l.arms):null,u={dims:a};typeof l.target=="string"&&(u.target=l.target),c&&(u.arms=c),r[i]=u}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};return typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture),o}function _t(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 Wn(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:"").trim().toLowerCase(),o=t.text.trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function Rt(e,t){return!!(e!=null&&e.urlMatch)&&!_t(t).includes(e.urlMatch)}function Y(e,t){var o;if(e.urlMatch&&!_t(t).includes(e.urlMatch))return null;let n=[];if(e.id){let i=t.getElementById(e.id);n=i?[i]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name))try{let i=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${i}"]`))}catch(i){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(i){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Wn(r,e.fingerprint)?null:r}var Lt=/^https:\/\//i,zn={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"};function Jn(e){return!/[;{}<>]/.test(e)}var Pt=new Map,X=null;function Vn(e){return e.replace(/["\\]/g,"\\$&")}function Fn(e){var t;(!X||!X.isConnected)&&(X=e.querySelector("style[data-sentient-ops]"),X||(X=e.createElement("style"),X.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(X))),X.textContent=[...Pt.entries()].map(([n,r])=>`[data-snt-e="${Vn(n)}"]{${r}}`).join(`
2
- `)}function Tt(e,t,n,r){var l;let o=!1,i=(l=t.moveBefore)!=null?l:t.moveAfter;if(i){let a=Y(i,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Lt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Lt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let s=[];if(t.hidden&&s.push("display:none !important"),t.style)for(let[a,c]of Object.entries(t.style)){let u=zn[a];u&&typeof c=="string"&&Jn(c)&&s.push(`${u}:${c.trim()} !important`)}return s.length>0&&(e.setAttribute("data-snt-e",n),Pt.set(n,s.join(";")),Fn(r)),{anchorMiss:o}}function Oe(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Ce(e,t,n){var r;for(let[o,i]of Object.entries(t)){let s=e[o];if(!s||typeof s=="string")continue;let l=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let a of l)for(let[c,u]of Object.entries(s))(r=i.dims[c])!=null&&r.includes(u)&&a.setAttribute(`data-${c}`,u)}}function _e(e,t,n){for(let[r,o]of Object.entries(t)){let i=e[r];if(typeof i!="string"||!o.arms||!o.arms.includes(i))continue;let s=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let l of s)l.setAttribute("data-sentient-arm",i)}}function Re(e,t,n,r){var s,l;let o=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[a,c]of Object.entries(t)){if(Rt(c.locator,n))continue;let u;if(c.locator){let v=Y(c.locator,n);u=v?[v]:[]}else c.target?u=Array.from(n.querySelectorAll(c.target)):u=[n.documentElement];(c.locator||c.target)&&u.length===0&&i.push(a);let p=e[a];for(let v of u){if(p!==void 0)if(typeof p=="string")v.setAttribute("data-sentient-arm",p),o&&((l=r==null?void 0:r.onApplied)==null||l.call(r,a,p,v));else for(let[g,b]of Object.entries(p))v.setAttribute(`data-${g}`,b);o&&(typeof c.content=="string"&&(v.textContent=c.content),c.ops&&Tt(v,c.ops,a,n).anchorMiss&&!i.includes(a)&&i.push(a))}}return i}var Hn=800;function We(e,t,n){let r=[];return n.forEach(({slotId:o,arm:i,el:s},l)=>{r.push(he((v,g={})=>{try{e.track({projectId:t,componentId:o,variantId:i,eventType:"micro_signal",payload:re({signalType:v},g)})}catch(b){}},s,void 0,{tabLoss:l===0}));let a=null,c=0,u=()=>{c=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-c}})}catch(v){}a=null},Hn)},p=()=>{a!==null&&(clearTimeout(a),a=null)};s.addEventListener("mouseenter",u),s.addEventListener("mouseleave",p),r.push(()=>{s.removeEventListener("mouseenter",u),s.removeEventListener("mouseleave",p),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function Yn(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 Xn(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 Dt(e,t,n){var v;let r=new Set,o=g=>{if(!r.has(g.goalId)){r.add(g.goalId);try{g.slotId?t.componentGoal(g.slotId,g.goalId):t.goal(g.goalId)}catch(b){}}},i=e.filter(g=>g.event==="click"),s=e.filter(g=>g.event==="form_submit"),l=e.filter(g=>g.event==="url_reached"),a=(g,b)=>{if(!g.locator)return!1;let m=Y(g.locator,n);return!!m&&(m===b||m.contains(b))},c=g=>{let b=g.target;if(!(!b||typeof b.closest!="function"))for(let m of i)a(m,b)&&o(m)},u=g=>{let b=g.target;if(b)for(let m of s)a(m,b)&&o(m)},p=()=>{if(l.length===0)return;let g=Yn(n);for(let b of l)b.urlPattern&&Xn(b.urlPattern,g)&&o(b)};return n.addEventListener("click",c,!0),n.addEventListener("submit",u,!0),(v=n.defaultView)==null||v.addEventListener("popstate",p),p(),{checkUrl:p,teardown:()=>{var g;n.removeEventListener("click",c,!0),n.removeEventListener("submit",u,!0),(g=n.defaultView)==null||g.removeEventListener("popstate",p)}}}var jt="__snt_editor_token";function Mt(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem(jt):null}catch(e){return null}}function Nt(e){try{sessionStorage.setItem(jt,e)}catch(t){}}var Je="0.11.2",Wt=5e3,Zn=50,U=null,P=null,J={},Z=null,ae=null,M=null,V=null,A=null,$t=!1,ze=null,Le=null,Pe=null,Te=!1;function zt(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function ue(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function ye(e,t){return U?(U.personaAttributes&&A&&Oe(A.persona,A.band,e),Ce(J,U.slots,e),_e(J,U.slots,e),Z?Re(J,Z,e,t):[]):[]}function Qn(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function De(){return!!(U&&P&&U.sectionCapture!==!1&&U.consent!==!1&&!se())}function Jt(){if(typeof document=="undefined"||!De())return;let e;try{if(Le&&Le.length>0){let t=new Map;for(let n of Le){if(n.urlMatch!==window.location.pathname)continue;let r=Y(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{V=Ct(P,re({apiKey:U.apiKey,apiBase:U.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),Pe=window.location.pathname}catch(t){}}function Fe(){try{let e=[];if(ye(document,{contentAndOps:Te,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&De())try{M==null||M(),M=We(P,U.apiKey,e)}catch(t){}try{typeof window!="undefined"&&Pe!==null&&window.location.pathname!==Pe&&De()&&(V==null||V(),V=null,Jt())}catch(t){}}catch(e){}}function Bt(){ze===null&&(ze=setTimeout(()=>{ze=null,Fe();try{ae==null||ae.checkUrl()}catch(e){}},Zn))}function Kt(){if(!($t||typeof window=="undefined"||typeof history=="undefined")){$t=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,i){let s=n.call(this,r,o,i!=null?i:null);return Bt(),s}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Bt)}catch(e){}}}function Ve(e){let t={};for(let[n,r]of Object.entries(e.slots))t[n]=r.target?document.querySelectorAll(r.target).length:1;return t}function Vt(e){return new URLSearchParams(e).get("sentient_editor")}function er(){try{let t=Array.from(document.getElementsByTagName("script")).find(n=>/snippet(\.global)?\.js/.test(n.src));if(t!=null&&t.src)return t.src.replace(/snippet(\.global)?\.js/,"editor.global.js")}catch(e){}return null}function tr(e,t){var n,r,o,i;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let a=document.createElement("meta");a.name="referrer",a.content="no-referrer",((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let s=(o=e.editorSrc)!=null?o:er();if(!s){Gt();return}let l=document.createElement("script");l.src=s,l.async=!0,l.onerror=()=>Gt(),((i=document.head)!=null?i:document.documentElement).appendChild(l)}catch(s){}}var Ut="sentient-editor-load-notice";function Gt(){var e;try{if(typeof document=="undefined"||document.getElementById(Ut))return;let t=document.createElement("div");t.id=Ut,t.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(t.style,{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)",cursor:"pointer"}),t.addEventListener("click",()=>t.remove()),((e=document.body)!=null?e:document.documentElement).appendChild(t),setTimeout(()=>t.remove(),1e4)}catch(t){}}function Ft(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(":"),i=o===-1?"":r.slice(0,o),s=o===-1?"":r.slice(o+1);if(!(!i||!s))if(s.includes("=")){let l={};for(let a of s.split(",")){let[c,u]=a.split("=");c&&u&&(l[c]=u)}Object.keys(l).length&&(n[i]=l)}else n[i]=s}return Object.keys(n).length?n:null}function Ht(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var qt="sentient-persona-preview-banner";function nr(e){var t;try{if(typeof document=="undefined"||document.getElementById(qt))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=qt,r.setAttribute("role","status"),Object.assign(r.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",background:"#111827",color:"#fff",font:"13px/1 system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.14)"});let o=document.createElement("span");o.textContent=`Previewing as ${n}`;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){}}),r.appendChild(o),r.appendChild(i),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function rr(e,t){var c,u,p,v,g,b,m,E,O;let n=(c=e.apiBase)!=null?c:"https://api.sentient-ui.com",o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([S,L])=>({id:S,dims:L.dims}))},i=await zt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(S=>S.ok?S.json():null).catch(()=>null),Wt);if(!i){ue(e,"persona preview: explain unavailable \u2014 page left as-is");return}let s=i;J=(p=s.slots)!=null?p:{},Z=(v=s.slotConfig)!=null?v:null;let l=(m=(b=(g=s.personaAttributes)==null?void 0:g.persona)!=null?b:s.persona)!=null?m:t,a=(O=(E=s.personaAttributes)==null?void 0:E.confidence)!=null?O:"high";A={persona:l,band:a},ye(document),Te=!0,Yt(e),nr(l)}function Yt(e){let t={goal(n,r){try{P==null||P.goal(n,r)}catch(o){}},componentGoal(n,r){try{P==null||P.componentGoal(n,r)}catch(o){}},grantConsent(){try{qe(e.apiKey)}catch(n){}},revokeConsent(){try{V==null||V(),V=null,Pe=null,M==null||M(),M=null,P==null||P.destroy()}catch(n){}},reapply:Fe,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=A==null?void 0:A.persona)!=null?n:null,band:(r=A==null?void 0:A.band)!=null?r:null,slots:J,matchCounts:Ve(e),consent:e.consent!==!1}}};window.SentientSnippet=t}async function Xt(){var e,t,n,r,o;try{let i=Ie(window.sentient);if(!i)return;U=i,Te=!1;let s=typeof window!="undefined"?Vt(window.location.search):null;if(s){Nt(s);try{let S=new URL(window.location.href);S.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",S.pathname+S.search+S.hash)}catch(S){}}let l=s!=null?s:Mt();if(l){tr(i,l),ue(i,"editor mode");return}let a=typeof window!="undefined"?Ft(window.location.search):null;if(a){J=a,A=null,ye(document),Kt(),ue(i,"preview mode",a);return}let c=typeof window!="undefined"?Ht(window.location.search):null;if(c){await rr(i,c),ue(i,"persona preview",c);return}let u=(e=i.registry)!=null?e:Object.keys(i.slots).length===0,p=Ae(i.apiKey);p&&(A={persona:p.persona,band:p.band},J=p.slots,p.slotConfig&&(Z=p.slotConfig),ye(document,{contentAndOps:!1}));let v=Ee({apiKey:i.apiKey,context:i.context,consent:i.consent,preConsentBehavior:i.preConsentBehavior,debug:i.debug});P=v,Yt(i),Kt();let g=Object.entries(i.slots).map(([S,L])=>({id:S,dims:L.dims})),b=Je!=="0.0.0-dev"?{v:Je}:{},m=await zt(v.decide(re(re({slots:g},b),u?{slotsFrom:"registry"}:{})),Wt);if(!m){ue(i,"decide timeout/null \u2014 snapshot state stands",Ve(i));return}let E=v.getPersona();E?A={persona:E.persona,band:E.band}:m.persona&&(A={persona:m.persona,band:"low"}),J=m.slots,u?Z=(t=m.slotConfig)!=null?t:null:m.slotConfig&&(Z=m.slotConfig);let O=[];if(Qn(i,ye(document,{onApplied:(S,L,N)=>O.push({slotId:S,arm:L,el:N})})),Te=!0,m.goals&&m.goals.length>0&&i.consent!==!1&&P)try{ae==null||ae.teardown(),ae=Dt(m.goals,P,document)}catch(S){}if(Le=(n=m.sectionMap)!=null?n:null,De()){Jt();try{M==null||M(),M=We(P,i.apiKey,O)}catch(S){}}ue(i,"applied",{persona:A,slots:J,matches:Ve(i)}),me(i.apiKey,re({v:1,persona:(r=A==null?void 0:A.persona)!=null?r:m.persona,band:(o=A==null?void 0:A.band)!=null?o:"low",slots:m.slots,layoutOrder:m.layoutOrder,savedAt:Date.now()},Z?{slotConfig:Z}:{}))}catch(i){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Xt())}return nn(or);})();
1
+ "use strict";var SentientSnippet=(()=>{var Se=Object.defineProperty;var en=Object.getOwnPropertyDescriptor;var tn=Object.getOwnPropertyNames,Qe=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,nn=Object.prototype.propertyIsEnumerable;var et=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ie=(e,t)=>{for(var n in t||(t={}))tt.call(t,n)&&et(e,n,t[n]);if(Qe)for(var n of Qe(t))nn.call(t,n)&&et(e,n,t[n]);return e};var nt=(e,t)=>()=>(e&&(t=e(e=0)),t);var rt=(e,t)=>{for(var n in t)Se(e,n,{get:t[n],enumerable:!0})},rn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of tn(t))!tt.call(e,o)&&o!==n&&Se(e,o,{get:()=>t[o],enumerable:!(r=en(t,o))||r.enumerable});return e};var on=e=>rn(Se({},"__esModule",{value:!0}),e);var sn,an,ln,ot,cn,un,it,E,he,xe=nt(()=>{"use strict";sn=Object.defineProperty,an=Object.defineProperties,ln=Object.getOwnPropertyDescriptors,ot=Object.getOwnPropertySymbols,cn=Object.prototype.hasOwnProperty,un=Object.prototype.propertyIsEnumerable,it=(e,t,n)=>t in e?sn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))cn.call(t,n)&&it(e,n,t[n]);if(ot)for(var n of ot(t))un.call(t,n)&&it(e,n,t[n]);return e},he=(e,t)=>an(e,ln(t))});var gt={};rt(gt,{LOCAL_ENGINE_AVAILABLE:()=>fn,createLocalEngine:()=>gn});function gn(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var fn,mt=nt(()=>{"use strict";fn=!1});var lr={};rt(lr,{applyPersonaAttributes:()=>Re,applyRegistrySlots:()=>Pe,applySlotArms:()=>Te,applySlotAttributes:()=>Le,parseEditorToken:()=>Ft,parsePersonaPreview:()=>Yt,parsePreview:()=>Ht,parseSnippetConfig:()=>_e,reapply:()=>Xe,run:()=>Zt,version:()=>Fe});xe();function Ae(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function st(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 Ne(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 Ae(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[i,s]of Object.entries((n=e.dims)!=null?n:{}))o[i]=(r=s[0])!=null?r:"";return Ae(o)}function at(e,t){var n,r;return e.dims!=null?(r=(n=st(t))!=null?n:st(Ne(e)))!=null?r:{}:t}function se(e){return e>=.3?e<.7?"medium":"high":"low"}var dn=["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 lt(e){return pn(e)!==null}function pn(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=dn.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function ct(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 ut(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 dt(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function pt(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ke(e){return E(E(E({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 Be(e){let t=Ke(e);return at(t,Ne(t))}function ft(e){return typeof e=="string"?e:Ae(e)}xe();var mn="_snt_uid",ce="_snt_uid";function hn(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(t){}let e=()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${e()}-${e()}-${e()}-${e()}`}function yn(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function vn(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function bn(e){try{return localStorage.getItem(e)}catch(t){return null}}function wn(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function Sn(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function xn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function An(e){try{sessionStorage.removeItem(e)}catch(t){}}function kn(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,/(?:^|; )_snt_uid_probe=1/.test(document.cookie)||document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function In(e){try{localStorage.removeItem(e)}catch(t){}}function En(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var On={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function vt(e){var t,n,r,o,i,s;if(typeof window=="undefined")return On;let l=(t=e==null?void 0:e.cookieName)!=null?t:mn,a=((n=e==null?void 0:e.cookieTTLDays)!=null?n:365)*24*60*60,c=(s=(i=(o=(r=yn(l))!=null?r:bn(ce))!=null?o:Sn(ce))!=null?i:e==null?void 0:e.ssrSessionId)!=null?s:hn();vn(l,c,a);let u=wn(ce,c),p=kn(l),y=u?!1:xn(ce,c),g=!u&&!p&&!y;return{getSessionId:()=>c,isEphemeral:()=>g,destroy:()=>{c=null,En(l),In(ce),An(ce)}}}function bt(e){return`_snt_retry_${e.slice(0,12)}`}var Cn={push:()=>{},flush:()=>{},destroy:()=>{}};function _n(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?(localStorage.removeItem(t),r.slice(-e)):[]}catch(n){return[]}}function Ue(e,t,n){try{let r=[...(()=>{try{let o=localStorage.getItem(n);if(!o)return[];let i=JSON.parse(o);return Array.isArray(i)?i:[]}catch(o){return[]}})(),...e].slice(-t);localStorage.setItem(n,JSON.stringify(r))}catch(r){}}function Rn(e){var t,n,r;if(typeof window=="undefined")return Cn;let o=(t=e.flushIntervalMs)!=null?t:5e3,i=(n=e.maxBatchSize)!=null?n:20,s=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,a=e.apiKey,c=bt(a),u=[],p=new Set,y=[],g=f=>{for(let x of f)b.delete(x),!p.has(x)&&(p.add(x),y.push(x));for(;y.length>500;){let x=y.shift();x&&p.delete(x)}},b=new Set,w=f=>{p.has(f.id)||b.has(f.id)||(b.add(f.id),u.push(f))},A=f=>{for(let x of f)p.has(x.id)||(b.add(x.id),u.push(x))},P=_n(s,c);for(let f of P)w(f);let S=0,I=0,j=f=>{if(f.length===0)return;let x=JSON.stringify(f),M=f.map(d=>d.id),z;try{z=fetch(l,{method:"POST",keepalive:!0,body:x,headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})}catch(d){Ue(f,s,c),A(f),I++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6));return}let G=d=>{if(d.ok||d.status>=400&&d.status<500&&d.status!==429){g(M),I=0,S=0;return}Ue(f,s,c),A(f),I++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))};z instanceof Promise?z.then(G).catch(()=>{Ue(f,s,c),A(f),I++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))}):G(z)},H=typeof TextEncoder!="undefined"?new TextEncoder:null,le=f=>H?H.encode(f).length:f.length,ne=f=>{let x=[],M=2;for(let z of f){let G=le(JSON.stringify(z))+1;if(x.length>0&&M+G>57344||x.length>=i)break;x.push(z),M+=G}return x},C=()=>{try{if(Date.now()<S)return;for(;u.length>0&&!(Date.now()<S);){let f=u.filter(M=>!p.has(M.id));if(u.length=0,f.length===0)break;let x=ne(f);if(x.length===0)break;x.length<f.length&&u.push(...f.slice(x.length)),j(x)}}catch(f){}},Y=!0,h=null;h=setInterval(()=>{Y&&C()},o);let m=()=>{document.visibilityState==="hidden"&&C()},k=()=>{C()};return document.addEventListener("visibilitychange",m),window.addEventListener("pagehide",k),{push(f){w(f),u.length>=i&&C()},flush:C,destroy(){Y=!1,h!==null&&(clearInterval(h),h=null),document.removeEventListener("visibilitychange",m),window.removeEventListener("pagehide",k),C()}}}var ze="_snt_asgn_";function ke(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ln(e,t){return`${ze}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ht(e){let t=e.slice(ze.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(r){return null}}function Ge(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(ze)&&e.push(n)}return e}catch(e){return[]}}function Tn(e=18e5){let t=new Map,n=r=>r.assignedAt+(r.ttlMs&&r.ttlMs>0?r.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let r of Ge())try{let o=localStorage.getItem(r);if(!o)continue;let i=JSON.parse(o);if(n(i)){localStorage.removeItem(r);continue}let s=ht(r);if(!s)continue;t.set(ke(s.componentId,s.segment),i)}catch(o){}})(),{get(r,o){let i=t.get(ke(r,o));return i?n(i)?(t.delete(ke(r,o)),null):i:null},set(r,o,i){let s=ke(r,o);t.set(s,i);try{localStorage.setItem(Ln(r,o),JSON.stringify(i))}catch(l){}},invalidate(r){let o=`${encodeURIComponent(r)}:`;for(let i of[...t.keys()])i.startsWith(o)&&t.delete(i);for(let i of Ge()){let s=ht(i);if((s==null?void 0:s.componentId)===r)try{localStorage.removeItem(i)}catch(l){}}},clear(){t.clear();for(let r of Ge())try{localStorage.removeItem(r)}catch(o){}}}}var Ee="_snt_snap:",Pn=["low","medium","high"];function Oe(e){try{let t=localStorage.getItem(Ee+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!Pn.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function ye(e,t){try{localStorage.setItem(Ee+e,JSON.stringify(t))}catch(n){}}var We="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",wt="[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.",yt=!1,Ie=!1;function Dn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function Mn(e){var t;let n=vt({ssrSessionId:e.ssrSessionId}),r=(t=n.getSessionId())!=null?t:"local",o=Dn(),i=Promise.resolve().then(()=>(mt(),gt)).then(a=>{let c=a;return c.LOCAL_ENGINE_AVAILABLE?(yt||(yt=!0,console.info(wt)),c):(Ie||(Ie=!0,console.error(We)),null)}).catch(()=>(Ie||(Ie=!0,console.error(We)),null)),s=null;function l(a){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=a.persona,c.dataset.sentientConfidence=se(a.confidence))}return{isLocal:!0,async decide(a){var c,u,p;let y=await i;if(!y)return null;let g=y.createLocalEngine({sessionId:r,forcedPersona:o}).decide(a);return s=he(E({},g),{layoutOrder:(u=(c=g.layoutOrder)!=null?c:s==null?void 0:s.layoutOrder)!=null?u:null,slots:E(E({},(p=s==null?void 0:s.slots)!=null?p:{}),g.slots)}),ye(e.apiKey||"local",{v:1,persona:s.persona,band:se(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),l(g),g},getSlotResult(a){var c,u,p;return(p=(u=s==null?void 0:s.slots[a])!=null?u:(c=e.initialSlots)==null?void 0:c[a])!=null?p:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:se(s.confidence)}:null},async assign(a,c){var u;let p=await i;return!p||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(u=p.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:a,variantIds:c}]}).assignments[a])!=null?u:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function ve(e,t,n,r){let o=[];{let i=!1,s=[],l=()=>{if(i)return;let a=Date.now();for(s.push(a);s.length>0&&a-s[0]>500;)s.shift();s.length>=3&&(i=!0,e("rage_click"))};t.addEventListener("click",l),o.push(()=>t.removeEventListener("click",l))}{let i=!1,s=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let a=typeof window!="undefined"?window.getSelection():null,c=a?a.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",s),o.push(()=>document.removeEventListener("copy",s))}{let i=!1,s=!1,l=null,a=()=>{l!==null&&(clearTimeout(l),l=null)},c=()=>{i||!s||(a(),l=setTimeout(()=>{!i&&s&&(i=!0,e("scroll_hesitation"))},3e3))},u=()=>{a(),c()},p=g=>{for(let b of g)s=b.intersectionRatio>.3,s?c():a()},y=new IntersectionObserver(p,{threshold:[.3]});y.observe(t),window.addEventListener("scroll",u,{passive:!0}),o.push(()=>{y.disconnect(),window.removeEventListener("scroll",u),a()})}if((r==null?void 0:r.tabLoss)!==!1){let i=!1,s=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let a=Date.now()-s;a<15e3&&(i=!0,e("tab_loss",{timeOnPage:a}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of o)i()}}var St="https://api.sentient-ui.com/v1/events",$=new Map,xt=null;function qe(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}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 ue={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function jn(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,r]of t)n.startsWith("utm_")&&(e[n]=r);return e}catch(e){return{}}}function At(e){return e.replace(/\/events\/?$/,"")}function ae(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}function Je(e){var t;if(typeof window=="undefined")return;let n=e!=null?e:xt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let r=$.get(n);if(!r){console.warn("[sentient] grantConsent() called before init()");return}let{config:o,upgrade:i}=r;if(!i||o.respectDoNotTrack!==!1&&ae())return;let s=Ce(he(E({},o),{consent:!0}));i(s);let l=(t=$.get(n))==null?void 0:t.dispose;$.set(n,{config:he(E({},o),{consent:!0}),upgrade:null,dispose:l})}function $n(e){var t;let n=At((t=e.ingestUrl)!=null?t:St),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(l,a,c){try{let u=new URLSearchParams({componentId:l});for(let y of a!=null?a:[])u.append("variantIds[]",y);let p=await fetch(`${n}/winner?${u.toString()}`,{headers:r});return p.ok?{variantId:(await p.json()).variantId,assignmentTtlMs:0}:a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}catch(u){return a!=null&&a[0]?{variantId:a[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},i={track:l=>o.track(l),goal:(l,a,c,u)=>o.goal(l,a,c,u),componentGoal:(l,a,c)=>o.componentGoal(l,a,c),identify:l=>o.identify(l),getAssignment:(l,a)=>o.getAssignment(l,a),assign:(l,a,c,u)=>o.assign(l,a,c,u),decide:l=>o.decide(l),getSlotResult:l=>o.getSlotResult(l),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),dispose:()=>o.dispose(),destroy:()=>o.destroy()};function s(l){o=l}return{proxy:i,setInner:s}}function Ce(e){var t,n,r,o,i,s,l,a,c;if(typeof window=="undefined")return ue;xt=e.apiKey;let u=$.get(e.apiKey||"local");if(u!=null&&u.dispose)try{u.dispose()}catch(d){}let p=e.respectDoNotTrack!==!1&&ae(),y=e.consent===!1||p,g=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!g&&e.localMode!==!1)return y?($.set(e.apiKey||"local",{config:e,upgrade:null}),ue):($.set(e.apiKey||"local",{config:e,upgrade:null}),Mn(e));if(y){if(e.preConsentBehavior==="statistical_winner"){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."),ue;let{proxy:d,setInner:v}=$n(e);return $.set(e.apiKey,{config:e,upgrade:p?null:v}),d}return $.set(e.apiKey,{config:e,upgrade:null}),ue}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."),ue;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ue;let b=(t=e.ingestUrl)!=null?t:St,w=Date.now(),A=vt({ssrSessionId:e.ssrSessionId}),P=Tn(),S=Rn({ingestUrl:b,apiKey:e.apiKey}),I=At(b),j={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},H=ct((n=navigator.userAgent)!=null?n:""),le=typeof window!="undefined"?window.location.origin:void 0,ne=ut((r=document.referrer)!=null?r:"",le),C=(o=e.sessionSegment)!=null?o:`${H}:${ne}`,Y=new Map,h=new Map,m=null,k=d=>{for(let v of d)h.has(v.id)||h.set(v.id,Be(v))};if(e.initialSlots)for(let[d,v]of Object.entries(e.initialSlots))h.set(d,v);let f=Oe(e.apiKey);if(f)for(let[d,v]of Object.entries(f.slots))h.has(d)||h.set(d,v);let x={low:.15,medium:.5,high:.85};if(e.initialPersona)m=E({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?m={persona:d.sentientPersona,confidence:(s=x[(i=d.sentientConfidence)!=null?i:"low"])!=null?s:.15}:f&&(m={persona:f.persona,confidence:(l=x[f.band])!=null?l:.15})}if(e.initialAssignments)for(let[d,v]of Object.entries(e.initialAssignments))P.set(d,C,{variantId:v,assignedAt:Date.now(),segment:C,confidence:1});let M=Promise.resolve(),z=A.getSessionId();if(z){let d=dt((a=document.referrer)!=null?a:""),v=E(E({sessionId:z,deviceClass:H,trafficSource:ne,referrerDomain:d,utmParams:jn(),timeOfDay:pt(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:A.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||lt((c=navigator.userAgent)!=null?c:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{M=fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(v),headers:j}).then(R=>{R.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")}).catch(()=>{})}catch(R){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:S});let G={goal(d,v={},R=1,J=0){let q=A.getSessionId();if(!q)return;let D=qe();M.then(()=>{fetch(`${I}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:q,name:d,metadata:v,weight:R,stepIndex:J,goalId:D}),headers:j}).catch(()=>{})})},componentGoal(d,v,R){var J,q,D;let Z=A.getSessionId();if(!Z)return;let V=P.get(d,C),K=V?null:(J=h.get(d))!=null?J:null;if(!V&&K===null){e.debug&&console.warn(`[sentient] componentGoal("${d}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let re=V?V.variantId:ft(K),B={id:qe(),sessionId:Z,projectId:e.apiKey,componentId:d,variantId:re,eventType:"goal_achieved",goalType:v,payload:E({reward:(q=R==null?void 0:R.reward)!=null?q:1},(D=R==null?void 0:R.metadata)!=null?D:{}),timestamp:Date.now(),timeInSession:Date.now()-w};e.debug&&console.log("[sentient] componentGoal",B),M.then(()=>S.push(B))},identify(d){let v=A.getSessionId();v&&M.then(()=>{fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:v,userId:d,ephemeral:A.isEphemeral()}),headers:j}).catch(()=>{})})},track(d){let v=A.getSessionId();if(!v)return;let R=he(E({},d),{id:qe(),sessionId:v,timestamp:Date.now(),timeInSession:Date.now()-w});e.debug&&console.log("[sentient] track",R),M.then(()=>S.push(R))},getAssignment(d,v){return P.get(d,v)},async assign(d,v,R,J){let q=A.getSessionId();if(!q)return null;let D=P.get(d,C);if(D&&(v!=null&&v.length||D.content!==void 0)){let K=D.ttlMs&&D.ttlMs>0?Math.max(0,D.assignedAt+D.ttlMs-Date.now()):0;return{variantId:D.variantId,assignmentTtlMs:K,content:D.content}}let Z=Y.get(d);if(Z)return Z;let V=(async()=>{await M;try{let K={sessionId:q,componentId:d,variantIds:v};J!==void 0?K.agentDataByVariant=J:R!==void 0&&(K.agentData=R);let re=await fetch(`${I}/assign`,{method:"POST",body:JSON.stringify(K),headers:j});if(!re.ok)return null;let B=await re.json();return P.set(d,C,E({variantId:B.variantId,assignedAt:Date.now(),segment:C,confidence:1,content:B.content},B.assignmentTtlMs&&B.assignmentTtlMs>0?{ttlMs:B.assignmentTtlMs}:{})),B}catch(K){return null}finally{Y.delete(d)}})();return Y.set(d,V),V},async decide(d){var v,R,J,q,D,Z,V,K,re;let B=A.getSessionId();if(!B)return null;let fe=(v=d.slots)!=null?v:[];await M;try{let oe={sessionId:B};d.sections&&d.sections.length>0&&(oe.sections=d.sections.map(U=>({id:U}))),oe.components=(R=d.components)!=null?R:[],fe.length>0&&(oe.slots=fe.map(Ke)),d.slotsFrom==="registry"&&(oe.slotsFrom="registry"),d.v&&(oe.v=d.v);let Ze=await fetch(`${I}/decide`,{method:"POST",body:JSON.stringify(oe),headers:j});if(!Ze.ok)return k(fe),null;let _=await Ze.json(),ge={};for(let U of fe)ge[U.id]=(q=(J=_.slots)==null?void 0:J[U.id])!=null?q:Be(U);if(_.slots)for(let[U,me]of Object.entries(_.slots))U in ge||(ge[U]=me);for(let[U,me]of Object.entries(ge))h.set(U,me);let Qt=m!=null&&m.persona!=="unknown";_.persona&&!(_.persona==="unknown"&&Qt)?m={persona:_.persona,confidence:(D=_.confidence)!=null?D:0}:m||(m={persona:"unknown",confidence:0});for(let[U,me]of Object.entries((Z=_.assignments)!=null?Z:{}))P.set(U,C,{variantId:me,assignedAt:Date.now(),segment:C,confidence:1});return ye(e.apiKey,E({v:1,persona:m.persona,band:se(m.confidence),slots:Object.fromEntries(h),layoutOrder:(V=_.layoutOrder)!=null?V:null,savedAt:Date.now()},_.slotConfig?{slotConfig:_.slotConfig}:{})),E(E(E({layoutOrder:(K=_.layoutOrder)!=null?K:null,assignments:(re=_.assignments)!=null?re:{},slots:ge,persona:m.persona,confidence:m.confidence},_.slotConfig?{slotConfig:_.slotConfig}:{}),_.goals?{goals:_.goals}:{}),_.sectionMap?{sectionMap:_.sectionMap}:{})}catch(oe){return k(fe),null}},getSlotResult(d){var v;return(v=h.get(d))!=null?v:null},getPersona(){return m?{persona:m.persona,confidence:m.confidence,band:se(m.confidence)}:null},async fetchWeights(){var d;try{let v=await fetch(`${I}/weights`,{headers:j});return v.ok?(d=(await v.json()).components)!=null?d:[]:[]}catch(v){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var d;S.destroy(),((d=$.get(e.apiKey))==null?void 0:d.dispose)===G.dispose&&$.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var d;S.destroy(),A.destroy(),((d=$.get(e.apiKey))==null?void 0:d.dispose)===G.dispose&&$.delete(e.apiKey);try{localStorage.removeItem(Ee+e.apiKey),localStorage.removeItem(bt(e.apiKey))}catch(v){}e.debug&&console.log("[sentient] destroyed")}};if($.set(e.apiKey,{config:e,upgrade:null,dispose:G.dispose}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=G)}return G}var kt=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Nn=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],Kn=[["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|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]];function Bn(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function It(e){if(e.tag==="nav"||e.tag==="footer")return{type:"navigation",strength:"weak"};let t=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[n,r]of Nn)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of Kn)if(r.test(e.bodyText))return{type:n,strength:"strong"};return e.actionCount>=1&&e.textLength>0&&e.textLength<200?{type:"cta",strength:"weak"}:e.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(t)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function Et(e){var t,n;let r=((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim();return{tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((n=e.className)!=null?n:"")}`,headingText:Bn(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function Ot(e){return It(Et(e)).type}xe();var _t="section, header, footer, nav, main > div, [data-sentient-section]";function Un(e){var t;return((t=e.parentElement)==null?void 0:t.closest(_t))!=null}function Gn(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 Ct=()=>{};function Rt(e,t){var n,r,o,i,s,l,a,c,u;let p=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!p||typeof IntersectionObserver=="undefined"||ae()||!t.apiKey)return Ct;let y=((r=t.apiBase)!=null?r:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),g=Array.from(p.querySelectorAll(_t)).filter(h=>!Un(h));if(g.length===0)return Ct;let b=new Map,w=new Map,A=new Map;for(let h of g){let m=h.getAttribute("data-sentient-type"),k=m&&kt.includes(m)?m:null,f=(i=k!=null?k:(o=t.typeOf)==null?void 0:o.call(t,h))!=null?i:Ot(h),x=`nc-${f}`;b.set(h,x),w.set(x,f),k?A.set(x,"markup"):A.has(x)||A.set(x,"auto")}let P=(c=(a=(l=(s=p.defaultView)!=null?s:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:a.pathname)!=null?c:"/";Gn(t.apiKey,y,P,[...w.entries()].map(([h,m])=>{var k;return{componentId:h,semanticType:m,source:(k=A.get(h))!=null?k:"auto"}}));let S=new Map,I=h=>{let m=S.get(h);return m||(m={ms:0,scroll:0,enterAt:null,intersecting:!1},S.set(h,m)),m},j=new IntersectionObserver(h=>{for(let m of h){let k=b.get(m.target);if(!k)continue;let f=I(k);m.isIntersecting?(f.intersecting=!0,f.enterAt=Date.now(),m.intersectionRatio>f.scroll&&(f.scroll=m.intersectionRatio)):(f.intersecting=!1,f.enterAt!=null&&(f.ms+=Date.now()-f.enterAt,f.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let h of b.keys())j.observe(h);let H=()=>{let h=Date.now();for(let[m,k]of S)if(k.enterAt!=null&&(k.ms+=h-k.enterAt,k.enterAt=null),!(k.ms<=0)){try{e.track({projectId:t.apiKey,componentId:m,eventType:"dwell",payload:{dwell_time:Math.round(k.ms),scroll_depth:Number(k.scroll.toFixed(2))}})}catch(f){}k.ms=0}},le=()=>{if(p.hidden)H();else{let h=Date.now();for(let m of S.values())m.intersecting&&(m.enterAt=h)}},ne=()=>{H();try{j.disconnect()}catch(h){}};p.addEventListener("visibilitychange",le);let C=(u=p.defaultView)!=null?u:typeof window!="undefined"?window:void 0;C==null||C.addEventListener("pagehide",ne);let Y=[];return t.microSignals&&[...b.entries()].forEach(([h,m],k)=>{Y.push(ve((f,x={})=>{try{e.track({projectId:t.apiKey,componentId:m,eventType:"micro_signal",payload:E({signalType:f},x)})}catch(M){}},h,void 0,{tabLoss:k===0}))}),()=>{H(),p.removeEventListener("visibilitychange",le),C==null||C.removeEventListener("pagehide",ne);for(let h of Y)h();try{j.disconnect()}catch(h){}}}var qn=["landing","ecommerce","saas","marketplace"];function Wn(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(i=>typeof i=="string"))return null;n[r]=o}return n}function zn(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function _e(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=qn.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,s]of Object.entries(t.slots)){if(typeof s!="object"||s===null)continue;let l=s,a=Wn(l.dims);if(!a||l.target!==void 0&&typeof l.target!="string")continue;let c=l.arms!==void 0?zn(l.arms):null,u={dims:a};typeof l.target=="string"&&(u.target=l.target),c&&(u.arms=c),r[i]=u}let o={apiKey:t.apiKey,context:n,personaAttributes:t.personaAttributes===!0,slots:r};return typeof t.consent=="boolean"&&(o.consent=t.consent),(t.preConsentBehavior==="statistical_winner"||t.preConsentBehavior==="control")&&(o.preConsentBehavior=t.preConsentBehavior),t.debug===!0&&(o.debug=!0),typeof t.registry=="boolean"&&(o.registry=t.registry),typeof t.editorSrc=="string"&&(o.editorSrc=t.editorSrc),typeof t.apiBase=="string"&&(o.apiBase=t.apiBase),typeof t.sectionCapture=="boolean"&&(o.sectionCapture=t.sectionCapture),o}function Lt(e){var n,r,o;let t=(r=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:r.location;return(o=t==null?void 0:t.pathname)!=null?o:""}function Jn(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:"").trim().toLowerCase(),o=t.text.trim().toLowerCase();if(!(r===o||r.startsWith(o)||o.startsWith(r)))return!1}return!0}function Tt(e,t){return!!(e!=null&&e.urlMatch)&&!Lt(t).includes(e.urlMatch)}function Q(e,t){var o;if(e.urlMatch&&!Lt(t).includes(e.urlMatch))return null;let n=[];if(e.id){let i=t.getElementById(e.id);n=i?[i]:[]}if(n.length===0&&((o=e.dataAttr)!=null&&o.name))try{let i=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${i}"]`))}catch(i){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(i){n=[]}if(n.length!==1)return null;let r=n[0];return e.fingerprint&&!Jn(r,e.fingerprint)?null:r}var Pt=/^https:\/\//i,Vn={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"},Fn=/^(rgb|rgba|hsl|hsla|calc|var|min|max|clamp)$/i;function Hn(e){var t;if(/[;{}<>]/.test(e))return!1;for(let n of e.matchAll(/([A-Za-z-]*)\(/g))if(!Fn.test((t=n[1])!=null?t:""))return!1;return!0}var Dt=new Map,ee=null;function Yn(e){return e.replace(/["\\]/g,"\\$&")}function Xn(e){var t;(!ee||!ee.isConnected)&&(ee=e.querySelector("style[data-sentient-ops]"),ee||(ee=e.createElement("style"),ee.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(ee))),ee.textContent=[...Dt.entries()].map(([n,r])=>`[data-snt-e="${Yn(n)}"]{${r}}`).join(`
2
+ `)}function Mt(e,t,n,r){var l;let o=!1,i=(l=t.moveBefore)!=null?l:t.moveAfter;if(i){let a=Q(i,r);!a||a===e||a.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,a):e.parentElement.insertBefore(e,a.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Pt.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Pt.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let s=[];if(t.hidden&&s.push("display:none !important"),t.style)for(let[a,c]of Object.entries(t.style)){let u=Vn[a];u&&typeof c=="string"&&Hn(c)&&s.push(`${u}:${c.trim()} !important`)}return s.length>0&&(e.setAttribute("data-snt-e",n),Dt.set(n,s.join(";")),Xn(r)),{anchorMiss:o}}function Re(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Le(e,t,n){var r;for(let[o,i]of Object.entries(t)){let s=e[o];if(!s||typeof s=="string")continue;let l=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let a of l)for(let[c,u]of Object.entries(s))(r=i.dims[c])!=null&&r.includes(u)&&a.setAttribute(`data-${c}`,u)}}function Te(e,t,n){for(let[r,o]of Object.entries(t)){let i=e[r];if(typeof i!="string"||!o.arms||!o.arms.includes(i))continue;let s=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let l of s)l.setAttribute("data-sentient-arm",i)}}function Pe(e,t,n,r){var s,l;let o=(s=r==null?void 0:r.contentAndOps)!=null?s:!0,i=[];for(let[a,c]of Object.entries(t)){if(Tt(c.locator,n))continue;let u;if(c.locator){let y=Q(c.locator,n);u=y?[y]:[]}else c.target?u=Array.from(n.querySelectorAll(c.target)):u=[n.documentElement];(c.locator||c.target)&&u.length===0&&i.push(a);let p=e[a];for(let y of u){if(p!==void 0)if(typeof p=="string")y.setAttribute("data-sentient-arm",p),o&&((l=r==null?void 0:r.onApplied)==null||l.call(r,a,p,y));else for(let[g,b]of Object.entries(p))y.setAttribute(`data-${g}`,b);o&&(typeof c.content=="string"&&(y.textContent=c.content),c.ops&&Mt(y,c.ops,a,n).anchorMiss&&!i.includes(a)&&i.push(a))}}return i}var Zn=800;function De(e,t,n){let r=[];return n.forEach(({slotId:o,arm:i,el:s},l)=>{r.push(ve((y,g={})=>{try{e.track({projectId:t,componentId:o,variantId:i,eventType:"micro_signal",payload:ie({signalType:y},g)})}catch(b){}},s,void 0,{tabLoss:l===0}));let a=null,c=0,u=()=>{c=Date.now(),a=setTimeout(()=>{try{e.track({projectId:t,componentId:o,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-c}})}catch(y){}a=null},Zn)},p=()=>{a!==null&&(clearTimeout(a),a=null)};s.addEventListener("mouseenter",u),s.addEventListener("mouseleave",p),r.push(()=>{s.removeEventListener("mouseenter",u),s.removeEventListener("mouseleave",p),a!==null&&clearTimeout(a)})}),()=>{for(let o of r)o()}}function Qn(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 er(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 jt(e,t,n){var y;let r=new Set,o=g=>{if(!r.has(g.goalId)){r.add(g.goalId);try{g.slotId?t.componentGoal(g.slotId,g.goalId):t.goal(g.goalId)}catch(b){}}},i=e.filter(g=>g.event==="click"),s=e.filter(g=>g.event==="form_submit"),l=e.filter(g=>g.event==="url_reached"),a=(g,b)=>{if(!g.locator)return!1;let w=Q(g.locator,n);return!!w&&(w===b||w.contains(b))},c=g=>{let b=g.target;if(!(!b||typeof b.closest!="function"))for(let w of i)a(w,b)&&o(w)},u=g=>{let b=g.target;if(b)for(let w of s)a(w,b)&&o(w)},p=()=>{if(l.length===0)return;let g=Qn(n);for(let b of l)b.urlPattern&&er(b.urlPattern,g)&&o(b)};return n.addEventListener("click",c,!0),n.addEventListener("submit",u,!0),(y=n.defaultView)==null||y.addEventListener("popstate",p),p(),{checkUrl:p,teardown:()=>{var g;n.removeEventListener("click",c,!0),n.removeEventListener("submit",u,!0),(g=n.defaultView)==null||g.removeEventListener("popstate",p)}}}var $t="__snt_editor_token";function Nt(){try{return typeof sessionStorage!="undefined"?sessionStorage.getItem($t):null}catch(e){return null}}function Kt(e){try{sessionStorage.setItem($t,e)}catch(t){}}var Fe="0.11.3",Jt=5e3,tr=50,N=null,L=null,X={},te=null,W=null,T=null,F=null,O=null,Bt=!1,Ve=null,Me=null,je=null,be=!1,$e=!1;function Vt(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function de(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function pe(e,t){return N?(N.personaAttributes&&O&&Re(O.persona,O.band,e),Le(X,N.slots,e),Te(X,N.slots,e),te?Pe(X,te,e,t):[]):[]}function nr(e,t){var n;if(t.length!==0)try{let r=(n=e.apiBase)!=null?n:"https://api.sentient-ui.com";fetch(`${r}/v1/locator-miss`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({slots:t})}).catch(()=>{})}catch(r){}}function we(){return!!(N&&L&&N.sectionCapture!==!1&&(N.consent!==!1||$e)&&!ae())}function rr(){if(!L||!N||!we()||F)return;let e=[];pe(document,{contentAndOps:be,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),Ye();try{T==null||T(),T=De(L,N.apiKey,e)}catch(t){}}function Ye(){if(typeof document=="undefined"||!we())return;let e;try{if(Me&&Me.length>0){let t=new Map;for(let n of Me){if(n.urlMatch!==window.location.pathname)continue;let r=Q(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{F=Rt(L,ie({apiKey:N.apiKey,apiBase:N.apiBase,doc:document,microSignals:!0},e?{typeOf:e}:{})),je=window.location.pathname}catch(t){}}function Xe(){try{let e=[];if(T==null||T(),T=null,pe(document,{contentAndOps:be,onApplied:(t,n,r)=>e.push({slotId:t,arm:n,el:r})}),e.length>0&&we())try{T=De(L,N.apiKey,e)}catch(t){}try{typeof window!="undefined"&&je!==null&&window.location.pathname!==je&&we()&&(F==null||F(),F=null,Ye())}catch(t){}}catch(e){}}function Ut(){Ve===null&&(Ve=setTimeout(()=>{Ve=null,Xe();try{W==null||W.checkUrl()}catch(e){}},tr))}function Gt(){if(!(Bt||typeof window=="undefined"||typeof history=="undefined")){Bt=!0;try{let e=t=>{let n=history[t];history[t]=function(r,o,i){let s=n.call(this,r,o,i!=null?i:null);return Ut(),s}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Ut)}catch(e){}}}function He(e){let t={};for(let[n,r]of Object.entries(e.slots))t[n]=r.target?document.querySelectorAll(r.target).length:1;return t}function Ft(e){return new URLSearchParams(e).get("sentient_editor")}function or(){try{let t=Array.from(document.getElementsByTagName("script")).find(n=>/snippet(\.global)?\.js/.test(n.src));if(t!=null&&t.src)return t.src.replace(/snippet(\.global)?\.js/,"editor.global.js")}catch(e){}return null}function ir(e,t){var n,r,o,i;try{window.__sentientEditor={token:t,apiBase:(n=e.apiBase)!=null?n:"https://api.sentient-ui.com"};try{let a=document.createElement("meta");a.name="referrer",a.content="no-referrer",((r=document.head)!=null?r:document.documentElement).appendChild(a)}catch(a){}let s=(o=e.editorSrc)!=null?o:or();if(!s){Wt();return}let l=document.createElement("script");l.src=s,l.async=!0,l.onerror=()=>Wt(),((i=document.head)!=null?i:document.documentElement).appendChild(l)}catch(s){}}var qt="sentient-editor-load-notice";function Wt(){var e;try{if(typeof document=="undefined"||document.getElementById(qt))return;let t=document.createElement("div");t.id=qt,t.textContent="Couldn\u2019t load the editor \u2014 check your connection and reopen it from your dashboard.",Object.assign(t.style,{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)",cursor:"pointer"}),t.addEventListener("click",()=>t.remove()),((e=document.body)!=null?e:document.documentElement).appendChild(t),setTimeout(()=>t.remove(),1e4)}catch(t){}}function Ht(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(":"),i=o===-1?"":r.slice(0,o),s=o===-1?"":r.slice(o+1);if(!(!i||!s))if(s.includes("=")){let l={};for(let a of s.split(",")){let[c,u]=a.split("=");c&&u&&(l[c]=u)}Object.keys(l).length&&(n[i]=l)}else n[i]=s}return Object.keys(n).length?n:null}function Yt(e){try{return new URLSearchParams(e).get("sentient_persona")||null}catch(t){return null}}var zt="sentient-persona-preview-banner";function sr(e){var t;try{if(typeof document=="undefined"||document.getElementById(zt))return;let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/[_-]+/g," "),r=document.createElement("div");r.id=zt,r.setAttribute("role","status"),Object.assign(r.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"999px",background:"#111827",color:"#fff",font:"13px/1 system-ui, sans-serif",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",border:"1px solid rgba(255,255,255,0.14)"});let o=document.createElement("span");o.textContent=`Previewing as ${n}`;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){}}),r.appendChild(o),r.appendChild(i),((t=document.body)!=null?t:document.documentElement).appendChild(r)}catch(n){}}async function ar(e,t){var c,u,p,y,g,b,w,A,P;let n=(c=e.apiBase)!=null?c:"https://api.sentient-ui.com",o=((u=e.registry)!=null?u:Object.keys(e.slots).length===0)?{persona:t,slotsFrom:"registry"}:{persona:t,slots:Object.entries(e.slots).map(([S,I])=>({id:S,dims:I.dims}))},i=await Vt(fetch(`${n}/v1/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify(o)}).then(S=>S.ok?S.json():null).catch(()=>null),Jt);if(!i){de(e,"persona preview: explain unavailable \u2014 page left as-is");return}let s=i;X=(p=s.slots)!=null?p:{},te=(y=s.slotConfig)!=null?y:null;let l=(w=(b=(g=s.personaAttributes)==null?void 0:g.persona)!=null?b:s.persona)!=null?w:t,a=(P=(A=s.personaAttributes)==null?void 0:A.confidence)!=null?P:"high";O={persona:l,band:a},pe(document),be=!0,Xt(e),sr(l)}function Xt(e){let t={goal(n,r){try{L==null||L.goal(n,r)}catch(o){}},componentGoal(n,r){try{L==null||L.componentGoal(n,r)}catch(o){}},grantConsent(){try{Je(e.apiKey)}catch(n){}$e=!0;try{rr()}catch(n){}},revokeConsent(){try{F==null||F(),F=null,je=null,T==null||T(),T=null,W==null||W.teardown(),W=null,$e=!1,L==null||L.destroy()}catch(n){}},reapply:Xe,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=O==null?void 0:O.persona)!=null?n:null,band:(r=O==null?void 0:O.band)!=null?r:null,slots:X,matchCounts:He(e),consent:e.consent!==!1}}};window.SentientSnippet=t}async function Zt(){var e,t,n,r,o;try{let i=_e(window.sentient);if(!i)return;N=i,be=!1,$e=!1;let s=typeof window!="undefined"?Ft(window.location.search):null;if(s){Kt(s);try{let S=new URL(window.location.href);S.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",S.pathname+S.search+S.hash)}catch(S){}}let l=s!=null?s:Nt();if(l){ir(i,l),de(i,"editor mode");return}let a=typeof window!="undefined"?Ht(window.location.search):null;if(a){X=a,O=null,pe(document),Gt(),de(i,"preview mode",a);return}let c=typeof window!="undefined"?Yt(window.location.search):null;if(c){await ar(i,c),de(i,"persona preview",c);return}let u=(e=i.registry)!=null?e:Object.keys(i.slots).length===0,p=Oe(i.apiKey);p&&(O={persona:p.persona,band:p.band},X=p.slots,p.slotConfig&&(te=p.slotConfig),pe(document,{contentAndOps:!1}));let y=Ce({apiKey:i.apiKey,context:i.context,consent:i.consent,preConsentBehavior:i.preConsentBehavior,debug:i.debug});L=y,Xt(i),Gt();let g=Object.entries(i.slots).map(([S,I])=>({id:S,dims:I.dims})),b=Fe!=="0.0.0-dev"?{v:Fe}:{},w=await Vt(y.decide(ie(ie({slots:g},b),u?{slotsFrom:"registry"}:{})),Jt);if(!w){de(i,"decide timeout/null \u2014 snapshot state stands",He(i));return}let A=y.getPersona();A?O={persona:A.persona,band:A.band}:w.persona&&(O={persona:w.persona,band:"low"}),X=w.slots,u?te=(t=w.slotConfig)!=null?t:null:w.slotConfig&&(te=w.slotConfig);let P=[];if(nr(i,pe(document,{onApplied:(S,I,j)=>P.push({slotId:S,arm:I,el:j})})),be=!0,w.goals&&w.goals.length>0&&i.consent!==!1&&L)try{W==null||W.teardown(),W=jt(w.goals,L,document)}catch(S){}if(Me=(n=w.sectionMap)!=null?n:null,we()){Ye();try{T==null||T(),T=De(L,i.apiKey,P)}catch(S){}}de(i,"applied",{persona:O,slots:X,matches:He(i)}),ye(i.apiKey,ie({v:1,persona:(r=O==null?void 0:O.persona)!=null?r:w.persona,band:(o=O==null?void 0:O.band)!=null?o:"low",slots:w.slots,layoutOrder:w.layoutOrder,savedAt:Date.now()},te?{slotConfig:te}:{}))}catch(i){}}if(typeof window!="undefined"&&window.sentient){let e=window;e.__sentientInitialized||(e.__sentientInitialized=!0,Zt())}return on(lr);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
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",
@@ -22,7 +22,7 @@
22
22
  "tsx": "^4.19.2",
23
23
  "typescript": "^5.7.2",
24
24
  "vitest": "^2.1.8",
25
- "@sentientui/core": "0.16.4"
25
+ "@sentientui/core": "0.16.5"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsup",