@sentientui/snippet 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,23 @@
1
- "use strict";var SentientSnippet=(()=>{var $=Object.defineProperty,Z=Object.defineProperties,Q=Object.getOwnPropertyDescriptor,Y=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertyNames,z=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var G=(t,e,n)=>e in t?$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,I=(t,e)=>{for(var n in e||(e={}))W.call(e,n)&&G(t,n,e[n]);if(z)for(var n of z(e))et.call(e,n)&&G(t,n,e[n]);return t},F=(t,e)=>Z(t,Y(e));var nt=(t,e)=>{for(var n in e)$(t,n,{get:e[n],enumerable:!0})},ot=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of tt(e))!W.call(t,i)&&i!==n&&$(t,i,{get:()=>e[i],enumerable:!(o=Q(e,i))||o.enumerable});return t};var rt=t=>ot($({},"__esModule",{value:!0}),t);var gt={};nt(gt,{clearTargetHighlights:()=>D,drawTargetHighlights:()=>V});function it(t){var n,o,i;let e=(o=(n=t.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(i=e==null?void 0:e.pathname)!=null?i:""}function at(t,e){var n;if(e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())return!1;if(e.text){let o=((n=t.textContent)!=null?n:"").trim().toLowerCase(),i=e.text.trim().toLowerCase();if(!(o===i||o.startsWith(i)||i.startsWith(o)))return!1}return!0}function H(t,e){var i;if(t.urlMatch&&!it(e).includes(t.urlMatch))return null;let n=[];if(t.id){let s=e.getElementById(t.id);n=s?[s]:[]}if(n.length===0&&((i=t.dataAttr)!=null&&i.name))try{let s=t.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(e.querySelectorAll(`[${t.dataAttr.name}="${s}"]`))}catch(s){n=[]}if(n.length===0&&t.selector)try{n=Array.from(e.querySelectorAll(t.selector))}catch(s){n=[]}if(n.length!==1)return null;let o=n[0];return t.fingerprint&&!at(o,t.fingerprint)?null:o}function J(t){let e=globalThis;return e.CSS&&typeof e.CSS.escape=="function"?e.CSS.escape(t):t.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`)}function st(t,e){if(t.id)return`#${J(t.id)}`;let n=[],o=t,i=0;for(;o&&o!==e.body&&o!==e.documentElement&&i<6;){if(o.id){n.unshift(`#${J(o.id)}`);break}let s=o.tagName.toLowerCase(),d=o.parentElement;if(d){let u=Array.from(d.children).filter(h=>h.tagName===o.tagName);u.length>1&&(s+=`:nth-of-type(${u.indexOf(o)+1})`)}n.unshift(s),o=o.parentElement,i++}return n.join(" > ")}function N(t,e){var i;let n={v:1};t.id&&(n.id=t.id);for(let s of["data-framer-name","data-w-id","data-sentient-name"]){let d=t.getAttribute(s);if(d){n.dataAttr={name:s,value:d};break}}n.selector=st(t,e);let o=((i=t.textContent)!=null?i:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=I({tag:t.tagName.toLowerCase()},o?{text:o}:{}),n}function P(t,e,n){return H(t,n)===e}var lt="sentient-editor-highlight",K="sentient-editor-panel",U="sentient-editor-target-highlight",ct=10;function dt(){let t=window.__sentientEditor;return t&&typeof t.token=="string"&&typeof t.apiBase=="string"?t:null}async function ut(t){var e;try{let n=await fetch(`${t.apiBase}/v1/editor/verify`,{headers:{authorization:`Bearer ${t.token}`}});return n.ok&&(e=(await n.json()).projectId)!=null?e:null}catch(n){return null}}async function _(t,e,n){try{return(await fetch(`${t.apiBase}${e}`,{method:"POST",headers:{authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(n)})).ok}catch(o){return!1}}async function pt(t){try{let e=await fetch(`${t.apiBase}/v1/editor/targets`,{headers:{authorization:`Bearer ${t.token}`}});if(!e.ok)return[];let n=await e.json();return Array.isArray(n.targets)?n.targets:[]}catch(e){return[]}}function D(t=document){for(let e of Array.from(t.querySelectorAll(`.${U}`)))e.remove()}function V(t,e=document){D(e);let n=0;for(let o of t){if(n>=ct)break;let i=H(o.locator,e);if(!i)continue;let s=i.getBoundingClientRect(),d=c("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});d.className=U;let u=c("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${s.left}px`,top:`${Math.max(0,s.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},o.label);u.className=U,e.body.append(d,u),n+=1}}function c(t,e,n){let o=document.createElement(t);return Object.assign(o.style,e),n!==void 0&&(o.textContent=n),o}function mt(t){let e=null,n=c("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=lt;let o=c("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",width:"300px",padding:"14px",borderRadius:"12px",background:"#111827",color:"#fff",font:"13px/1.4 system-ui, sans-serif",boxShadow:"0 8px 30px rgba(0,0,0,0.4)"});o.id=K;let i=c("div",{fontWeight:"600",marginBottom:"6px"},"SentientUI editor"),s=c("div",{opacity:"0.7",marginBottom:"10px"},"Click any element on the page to adapt it."),d=c("div",{fontSize:"12px",marginBottom:"10px",minHeight:"16px"}),u=c("button",x("#6366f1"),"Test different text here"),h=c("button",x("#374151"),"Track clicks as a goal"),w=c("button",x("#374151"),"Move up"),L=c("button",x("#374151"),"Move down"),S=c("button",x("#6366f1"),"Save this arrangement"),k=c("button",x("#374151"),"Undo"),T=c("button",F(I({},x("transparent")),{opacity:"0.6"}),"Close editor");for(let r of[u,h,w,L,T])r.disabled=!0;S.style.display="none",k.style.display="none",o.append(i,s,d,u,h,w,L,S,k,T),document.body.append(n,o);let m=(r,a=!0)=>{d.textContent=r,d.style.color=a?"#a7f3d0":"#fca5a5"},g=null,A=!1,v=null,y=null,E=null,C=null,p=null,B=r=>{S.style.display=r?"block":"none",k.style.display=r?"block":"none",w.disabled=r||!A||!E,L.disabled=r||!A||!C},j=()=>{if(!p||!e){p=null,B(!1);return}p.origParent.insertBefore(e,p.origNext),p=null,B(!1)},O=r=>{let a=r.target;if(!a||o.contains(a)||a===n)return;D(document);let l=a.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${l.left}px`,top:`${l.top}px`,width:`${l.width}px`,height:`${l.height}px`})},R=r=>{let a=r.target;if(!a||o.contains(a))return;r.preventDefault(),r.stopPropagation(),j(),e=a,g=N(a,document);let l=P(g,a,document);A=l,m(l?"\u2713 Selected \u2014 matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",l);for(let M of[u,h,T])M.disabled=!1;u.disabled=!l,h.disabled=!l,v=a.previousElementSibling,y=a.nextElementSibling;let f=v?N(v,document):null,b=y?N(y,document):null;E=v&&f&&P(f,v,document)?f:null,C=y&&b&&P(b,y,document)?b:null,w.disabled=!l||!E,L.disabled=!l||!C};u.onclick=async()=>{var b,M,q;if(!e||!g)return;let r=window.prompt("First wording (what you show today):",(M=(b=e.textContent)==null?void 0:b.trim())!=null?M:"");if(r===null)return;let a=window.prompt("Alternative wording to test:","");if(a===null)return;let l=((q=window.prompt("Name this slot:","hero-cta"))!=null?q:"hero-cta").trim()||"hero-cta";m("Saving\u2026");let f=await _(t,`/v1/editor/slots/${encodeURIComponent(l)}`,{kind:"arms",target:g,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:r}},{id:"b",displayName:"Alternative",ops:{text:a}}]}});m(f?"\u2713 Saved as a draft \u2014 publish it from your dashboard.":"\u26A0 Couldn\u2019t save \u2014 try again.",f)},h.onclick=async()=>{var l;if(!e||!g)return;let r=((l=window.prompt("Name this goal:","demo_requested"))!=null?l:"").trim();if(!r)return;m("Saving\u2026");let a=await _(t,`/v1/editor/goals/${encodeURIComponent(r)}`,{event:"click",locator:g});m(a?"\u2713 Goal saved as a draft.":"\u26A0 Couldn\u2019t save \u2014 try again.",a)},w.onclick=()=>{if(!e||!v||!E)return;let r=e.parentElement;if(!r)return;let a=e.nextSibling;r.insertBefore(e,v),p={direction:"up",origParent:r,origNext:a,anchorLocator:E},B(!0),m("Previewing the new position \u2014 save it or undo.")},L.onclick=()=>{if(!e||!y||!C)return;let r=e.parentElement;if(!r)return;let a=e.nextSibling;r.insertBefore(e,y.nextSibling),p={direction:"down",origParent:r,origNext:a,anchorLocator:C},B(!0),m("Previewing the new position \u2014 save it or undo.")},k.onclick=()=>{j(),m("Move undone \u2014 back to the original position.")},S.onclick=async()=>{var f;if(!e||!g||!p||!A)return;let r=((f=window.prompt("Name this slot:","reorder-slot"))!=null?f:"reorder-slot").trim()||"reorder-slot";m("Saving\u2026");let a=p.direction==="up"?"moveBefore":"moveAfter",l=await _(t,`/v1/editor/slots/${encodeURIComponent(r)}`,{kind:"arms",target:g,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[a]:p.anchorLocator}}]}});l&&(p=null,B(!1)),m(l?"\u2713 Saved as a draft \u2014 publish it from your dashboard.":"\u26A0 Couldn\u2019t save \u2014 try again.",l)};let X=()=>{document.removeEventListener("mousemove",O,!0),document.removeEventListener("click",R,!0),D(document),n.remove(),o.remove()};T.onclick=X,document.addEventListener("mousemove",O,!0),document.addEventListener("click",R,!0)}function x(t){return{display:"block",width:"100%",marginTop:"8px",padding:"8px 10px",borderRadius:"8px",border:"none",background:t,color:"#fff",font:"13px system-ui, sans-serif",cursor:"pointer",textAlign:"left"}}async function ft(){if(typeof document=="undefined")return;let t=dt();if(!t||!await ut(t)||document.getElementById(K))return;mt(t);let n=await pt(t);V(n,document)}ft();return rt(gt);})();
1
+ "use strict";var SentientSnippet=(()=>{var j=Object.defineProperty,xt=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,it=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,yt=Object.prototype.propertyIsEnumerable;var at=(e,t,n)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||(t={}))st.call(t,n)&&at(e,n,t[n]);if(it)for(var n of it(t))yt.call(t,n)&&at(e,n,t[n]);return e},Q=(e,t)=>xt(e,bt(t));var kt=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Et=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ht(t))!st.call(e,i)&&i!==n&&j(e,i,{get:()=>t[i],enumerable:!(o=vt(t,i))||o.enumerable});return e};var Lt=e=>Et(j({},"__esModule",{value:!0}),e);var Ot={};kt(Ot,{buildStyleOps:()=>pt,clearTargetHighlights:()=>J,computeMoveAnchors:()=>V,deriveSlotId:()=>F,drawTargetHighlights:()=>ut,mount:()=>ft});function St(e){var n,o,i;let t=(o=(n=e.defaultView)!=null?n:typeof window!="undefined"?window:void 0)==null?void 0:o.location;return(i=t==null?void 0:t.pathname)!=null?i:""}function wt(e,t){var n;if(t.tag&&e.tagName.toLowerCase()!==t.tag.toLowerCase())return!1;if(t.text){let o=((n=e.textContent)!=null?n:"").trim().toLowerCase(),i=t.text.trim().toLowerCase();if(!(o===i||o.startsWith(i)||i.startsWith(o)))return!1}return!0}function U(e,t){var i;if(e.urlMatch&&!St(t).includes(e.urlMatch))return null;let n=[];if(e.id){let l=t.getElementById(e.id);n=l?[l]:[]}if(n.length===0&&((i=e.dataAttr)!=null&&i.name))try{let l=e.dataAttr.value.replace(/["\\]/g,"\\$&");n=Array.from(t.querySelectorAll(`[${e.dataAttr.name}="${l}"]`))}catch(l){n=[]}if(n.length===0&&e.selector)try{n=Array.from(t.querySelectorAll(e.selector))}catch(l){n=[]}if(n.length!==1)return null;let o=n[0];return e.fingerprint&&!wt(o,e.fingerprint)?null:o}function lt(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 Ct(e,t){if(e.id)return`#${lt(e.id)}`;let n=[],o=e,i=0;for(;o&&o!==t.body&&o!==t.documentElement&&i<6;){if(o.id){n.unshift(`#${lt(o.id)}`);break}let l=o.tagName.toLowerCase(),f=o.parentElement;if(f){let p=Array.from(f.children).filter(g=>g.tagName===o.tagName);p.length>1&&(l+=`:nth-of-type(${p.indexOf(o)+1})`)}n.unshift(l),o=o.parentElement,i++}return n.join(" > ")}function G(e,t){var i;let n={v:1};e.id&&(n.id=e.id);for(let l of["data-framer-name","data-w-id","data-sentient-name"]){let f=e.getAttribute(l);if(f){n.dataAttr={name:l,value:f};break}}n.selector=Ct(e,t);let o=((i=e.textContent)!=null?i:"").trim().replace(/\s+/g," ").slice(0,80);return n.fingerprint=I({tag:e.tagName.toLowerCase()},o?{text:o}:{}),n}function q(e,t,n){return U(e,n)===t}function Bt(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 Tt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function F(e,t,n){var p,g;let o=t.id||((p=t.dataAttr)==null?void 0:p.value)||((g=n.textContent)!=null?g:"").trim()||n.tagName,i=Tt(o)||"el",l=Bt(JSON.stringify(t));return`${e}-${i}-${l}`.slice(0,128)}var At="sentient-editor-highlight",E="sentient-editor-panel",Y="sentient-editor-toast",dt="sentient-editor-styles",tt="sentient-editor-target-highlight",$t=10,It="Editor session expired. Reopen it from your dashboard to keep editing \u2014 your saved changes are safe.";function ct(){var t;if(document.getElementById(dt))return;let e=document.createElement("style");e.id=dt,e.textContent=`
2
+ @keyframes sntedi-in {
3
+ from { opacity: 0; transform: translateY(28px) scale(0.94); }
4
+ to { opacity: 1; transform: translateY(0) scale(1); }
5
+ }
6
+ @keyframes sntedi-attn {
7
+ 0%, 100% { box-shadow: 0 10px 34px rgba(0,0,0,0.45), 0 0 0 0 rgba(99,102,241,0); }
8
+ 50% { box-shadow: 0 10px 34px rgba(0,0,0,0.55), 0 0 0 7px rgba(99,102,241,0.40); }
9
+ }
10
+ @keyframes sntedi-dot {
11
+ 0%, 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
12
+ 50% { box-shadow: 0 0 0 5px rgba(52,211,153,0); }
13
+ }
14
+ #${E} {
15
+ animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both,
16
+ sntedi-attn 1.7s ease-in-out 0.42s 3;
17
+ }
18
+ #${E} .sntedi-dot { animation: sntedi-dot 1.4s ease-in-out infinite; }
19
+ #${Y} { animation: sntedi-in 0.42s cubic-bezier(0.2,0.9,0.25,1.15) both; }
20
+ @media (prefers-reduced-motion: reduce) {
21
+ #${E}, #${E} .sntedi-dot, #${Y} { animation: none !important; }
22
+ }
23
+ `,((t=document.head)!=null?t:document.documentElement).appendChild(e)}function Mt(e){var o;ct(),(o=document.getElementById(Y))==null||o.remove();let t=d("div",{position:"fixed",bottom:"16px",right:"16px",zIndex:"2147483647",maxWidth:"320px",padding:"14px 16px",borderRadius:"14px",background:"#111827",color:"#fff",font:"13px/1.45 system-ui, sans-serif",border:"1px solid rgba(245,158,11,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)",display:"flex",gap:"10px",alignItems:"flex-start",cursor:"pointer"});t.id=Y;let n=d("span",{width:"9px",height:"9px",marginTop:"4px",borderRadius:"50%",background:"#f59e0b",flex:"0 0 auto"});t.append(n,d("div",{},e)),document.body.appendChild(t),t.addEventListener("click",()=>t.remove()),setTimeout(()=>t.remove(),1e4)}function Ht(){let e=window.__sentientEditor;return e&&typeof e.token=="string"&&typeof e.apiBase=="string"?e:null}async function Rt(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 W(e,t,n){try{let o=await fetch(`${e.apiBase}${t}`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(n)});return o.ok?"ok":o.status===401?"expired":"error"}catch(o){return"error"}}async function zt(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 J(e=document){for(let t of Array.from(e.querySelectorAll(`.${tt}`)))t.remove()}function ut(e,t=document){J(t);let n=0;for(let o of e){if(n>=$t)break;let i=U(o.locator,t);if(!i)continue;let l=i.getBoundingClientRect(),f=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${l.left}px`,top:`${l.top}px`,width:`${l.width}px`,height:`${l.height}px`,border:"2px dashed #10b981",background:"rgba(16,185,129,0.08)"});f.className=tt;let p=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483645",left:`${l.left}px`,top:`${Math.max(0,l.top-20)}px`,padding:"2px 6px",borderRadius:"4px",background:"#10b981",color:"#fff",font:"11px system-ui, sans-serif",whiteSpace:"nowrap"},o.label);p.className=tt,t.body.append(f,p),n+=1}}function V(e,t){let n=e.previousElementSibling,o=e.nextElementSibling,i=n?G(n,t):null,l=o?G(o,t):null;return{prevEl:n,nextEl:o,prevLocator:n&&i&&q(i,n,t)?i:null,nextLocator:o&&l&&q(l,o,t)?l:null}}function Nt(e){return e.length>0&&!/[;{}<>]/.test(e)}function pt(e){let t={};for(let n of["color","background","fontSize","fontWeight","borderRadius","textAlign"]){let o=e[n];typeof o=="string"&&Nt(o.trim())&&(t[n]=o.trim())}return t}function d(e,t,n){let o=document.createElement(e);return Object.assign(o.style,t),n!==void 0&&(o.textContent=n),o}function ft(e){let t=null,n=d("div",{position:"fixed",pointerEvents:"none",zIndex:"2147483646",border:"2px solid #6366f1",background:"rgba(99,102,241,0.12)",display:"none"});n.id=At,ct();let o=d("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)"});o.id=E;let i=d("span",{width:"9px",height:"9px",borderRadius:"50%",background:"#34d399",display:"inline-block",flex:"0 0 auto"});i.className="sntedi-dot";let l=d("div",{display:"flex",alignItems:"center",gap:"8px",fontWeight:"700",fontSize:"14px",marginBottom:"6px"});l.append(i,d("span",{},"SentientUI editor"));let f=d("div",{opacity:"0.85",marginBottom:"10px"},"Click any element on the page to adapt it."),p=d("div",{fontSize:"12px",marginBottom:"10px",minHeight:"16px"}),g=d("button",b("#6366f1"),"Test different text here"),L=d("button",b("#374151"),"Change style"),S=d("button",b("#374151"),"Track clicks as a goal"),w=d("button",b("#374151"),"Move up"),C=d("button",b("#374151"),"Move down"),M=d("button",b("#6366f1"),"Save this arrangement"),H=d("button",b("#374151"),"Undo"),R=d("button",Q(I({},b("transparent")),{opacity:"0.6"}),"Close editor");for(let r of[g,L,S,w,C,R])r.disabled=!0;M.style.display="none",H.style.display="none",o.append(l,f,p,g,L,S,w,C,M,H,R),document.body.append(n,o);let z=d("div",{marginTop:"10px"});o.append(z);let B=()=>{z.textContent=""},X=(r,a,s)=>{B();let c={};for(let v of r){let Z=d("label",{display:"block",fontSize:"12px",opacity:"0.85",marginTop:"8px"},v.label),P=d("input",{display:"block",width:"100%",marginTop:"4px",padding:"7px 9px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.18)",background:"#1f2937",color:"#fff",font:"13px system-ui, sans-serif"});P.setAttribute("data-field",v.key),v.value!==void 0&&(P.value=v.value),c[v.key]=P,z.append(Z,P)}let x=d("button",b("#6366f1"),a),_=d("button",Q(I({},b("transparent")),{opacity:"0.6"}),"Cancel");x.onclick=()=>s(Object.fromEntries(Object.entries(c).map(([v,Z])=>[v,Z.value]))),_.onclick=B,z.append(x,_)},u=(r,a=!0)=>{p.textContent=r,p.style.color=a?"#a7f3d0":"#fca5a5"},N=(r,a)=>{r==="ok"?u(a,!0):u(r==="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)},m=null,D=!1,T=null,A=null,h=null,y=null,$=null,O=null,k=!1,mt=()=>{w.disabled=!D||!h,C.disabled=!D||!y},K=r=>{M.style.display=r?"block":"none",H.style.display=r?"block":"none",mt()},et=()=>{if(k&&t&&$&&$.insertBefore(t,O),k=!1,$=null,O=null,t){let r=V(t,document);T=r.prevEl,A=r.nextEl,h=r.prevLocator,y=r.nextLocator}K(!1)},nt=r=>{let a=r.target;if(!a||o.contains(a)||a===n)return;J(document);let s=a.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})},ot=r=>{let a=r.target;if(!a||o.contains(a))return;r.preventDefault(),r.stopPropagation(),et(),t=a,m=G(a,document);let s=q(m,a,document);D=s,u(s?"\u2713 Selected \u2014 matches exactly 1 element":"\u26A0 Couldn\u2019t target this element uniquely",s);for(let x of[g,L,S,R])x.disabled=!1;g.disabled=!s,L.disabled=!s,S.disabled=!s;let c=V(a,document);T=c.prevEl,A=c.nextEl,h=c.prevLocator,y=c.nextLocator,w.disabled=!s||!h,C.disabled=!s||!y};g.onclick=()=>{var s,c;if(!t||!m)return;let r=m,a=(c=(s=t.textContent)==null?void 0:s.trim())!=null?c:"";X([{key:"current",label:"Current wording",value:a},{key:"alt",label:"Alternative wording to test",value:""}],"Save draft",async x=>{let _=F("text",r,t);u("Saving\u2026");let v=await W(e,`/v1/editor/slots/${encodeURIComponent(_)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Original",ops:{text:x.current}},{id:"b",displayName:"Alternative",ops:{text:x.alt}}]}});v==="ok"&&B(),N(v,"\u2713 Saved as a draft \u2014 publish it from your dashboard.")})},S.onclick=()=>{if(!t||!m)return;let r=m;X([{key:"goal",label:"Goal name",value:"demo_requested"}],"Save goal",async a=>{let s=a.goal.trim();if(!s){u("\u26A0 Enter a goal name.",!1);return}u("Saving\u2026");let c=await W(e,`/v1/editor/goals/${encodeURIComponent(s)}`,{event:"click",locator:r});c==="ok"&&B(),N(c,"\u2713 Goal saved as a draft.")})},L.onclick=()=>{if(!t||!m)return;let r=m;X([{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 a=>{let s=pt(a);if(Object.keys(s).length===0){u("\u26A0 Enter at least one style change.",!1);return}let c=F("style",r,t);u("Saving\u2026");let x=await W(e,`/v1/editor/slots/${encodeURIComponent(c)}`,{kind:"arms",target:r,draftConfig:{arms:[{id:"a",displayName:"Current look",ops:{}},{id:"b",displayName:"New look",ops:{style:s}}]}});x==="ok"&&B(),N(x,"\u2713 Saved as a draft \u2014 publish it from your dashboard.")})};let rt=r=>{if(!t)return;let a=t.parentElement;if(!a)return;k||($=a,O=t.nextSibling,k=!0),r==="up"&&T?a.insertBefore(t,T):r==="down"&&A&&a.insertBefore(t,A.nextSibling);let s=V(t,document);T=s.prevEl,A=s.nextEl,h=s.prevLocator,y=s.nextLocator,K(!0),u("Previewing the new position \u2014 keep moving, save, or undo.")};w.onclick=()=>rt("up"),C.onclick=()=>rt("down"),H.onclick=()=>{et(),u("Move undone \u2014 back to the original position.")},M.onclick=async()=>{if(!t||!m||!k||!D)return;let r=h?"moveAfter":"moveBefore",a=h!=null?h:y;if(!a){u("\u26A0 Couldn\u2019t anchor the new position \u2014 nudge it next to a section with an id.",!1);return}let s=F("move",m,t);u("Saving\u2026");let c=await W(e,`/v1/editor/slots/${encodeURIComponent(s)}`,{kind:"arms",target:m,draftConfig:{arms:[{id:"a",ops:{}},{id:"b",ops:{[r]:a}}]}});c==="ok"&&(k=!1,$=null,O=null,K(!1)),N(c,"\u2713 Saved as a draft \u2014 publish it from your dashboard.")};let gt=()=>{document.removeEventListener("mousemove",nt,!0),document.removeEventListener("click",ot,!0),J(document),n.remove(),o.remove()};R.onclick=gt,document.addEventListener("mousemove",nt,!0),document.addEventListener("click",ot,!0)}function b(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 Dt(){if(typeof document=="undefined")return;let e=Ht();if(!e)return;let t=await Rt(e);if(!t.ok){t.unauthorized&&Mt(It);return}if(document.getElementById(E))return;ft(e);let n=await zt(e);ut(n,document)}Dt();return Lt(Ot);})();
@@ -1,2 +1,2 @@
1
- "use strict";var SentientSnippet=(()=>{var pe=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames,He=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var Ye=(e,t,n)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ge=(e,t)=>{for(var n in t||(t={}))Xe.call(t,n)&&Ye(e,n,t[n]);if(He)for(var n of He(t))$t.call(t,n)&&Ye(e,n,t[n]);return e};var Ze=(e,t)=>()=>(e&&(t=e(e=0)),t);var Qe=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},Bt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Nt(t))!Xe.call(e,o)&&o!==n&&pe(e,o,{get:()=>t[o],enumerable:!(r=Mt(t,o))||r.enumerable});return e};var Kt=e=>Bt(pe({},"__esModule",{value:!0}),e);var Ut,Gt,qt,et,Wt,Jt,tt,A,ue,re=Ze(()=>{"use strict";Ut=Object.defineProperty,Gt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,Wt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,tt=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,A=(e,t)=>{for(var n in t||(t={}))Wt.call(t,n)&&tt(e,n,t[n]);if(et)for(var n of et(t))Jt.call(t,n)&&tt(e,n,t[n]);return e},ue=(e,t)=>Gt(e,qt(t))});var st={};Qe(st,{LOCAL_ENGINE_AVAILABLE:()=>Vt,createLocalEngine:()=>zt});function zt(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Vt,at=Ze(()=>{"use strict";re();Vt=!1});var Bn={};Qe(Bn,{applyPersonaAttributes:()=>xe,applyRegistrySlots:()=>Ee,applySlotArms:()=>Ie,applySlotAttributes:()=>Oe,parseEditorToken:()=>Dt,parsePreview:()=>Tt,parseSnippetConfig:()=>Ae,reapply:()=>Ve,run:()=>jt,version:()=>Pt});re();function me(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function nt(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 Re(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 me(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[i,a]of Object.entries((n=e.dims)!=null?n:{}))o[i]=(r=a[0])!=null?r:"";return me(o)}function rt(e,t){var n,r;return e.dims!=null?(r=(n=nt(t))!=null?n:nt(Re(e)))!=null?r:{}:t}function Q(e){return e>=.3?e<.7?"medium":"high":"low"}var ot=["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 Le(e){return it(e)!==null}function it(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=ot.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Pe(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 De(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 Te(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function je(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function he(e){return A(A(A({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 ye(e){let t=he(e);return rt(t,Re(t))}function Me(e){return typeof e=="string"?e:me(e)}re();var Ft="_snt_uid",oe="_snt_uid";function Ht(){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 Yt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Xt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Zt(e){try{return localStorage.getItem(e)}catch(t){return null}}function Qt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function en(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function tn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function nn(e){try{sessionStorage.removeItem(e)}catch(t){}}function rn(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 on(e){try{localStorage.removeItem(e)}catch(t){}}function sn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var an={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ut(e){var t,n,r,o,i,a;if(typeof window=="undefined")return an;let l=(t=e==null?void 0:e.cookieName)!=null?t:Ft,s=((n=e==null?void 0:e.cookieTTLDays)!=null?n:365)*24*60*60,c=(a=(i=(o=(r=Yt(l))!=null?r:Zt(oe))!=null?o:en(oe))!=null?i:e==null?void 0:e.ssrSessionId)!=null?a:Ht();Xt(l,c,s);let u=Qt(oe,c),g=rn(l),S=u?!1:tn(oe,c),f=!u&&!g&&!S;return{getSessionId:()=>c,isEphemeral:()=>f,destroy:()=>{c=null,sn(l),on(oe),nn(oe)}}}function dt(e){return`_snt_retry_${e.slice(0,12)}`}var ln={push:()=>{},flush:()=>{},destroy:()=>{}};function cn(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 Ne(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 un(e){var t,n,r;if(typeof window=="undefined")return ln;let o=(t=e.flushIntervalMs)!=null?t:5e3,i=(n=e.maxBatchSize)!=null?n:20,a=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,s=e.apiKey,c=dt(s),u=[],g=new Set,S=[],f=p=>{for(let y of p)v.delete(y),!g.has(y)&&(g.add(y),S.push(y));for(;S.length>500;){let y=S.shift();y&&g.delete(y)}},v=new Set,b=p=>{g.has(p.id)||v.has(p.id)||(v.add(p.id),u.push(p))},O=cn(a,c);for(let p of O)b(p);let P=0,I=0,N=p=>{if(p.length===0)return;let y=JSON.stringify(p),k=p.map(d=>d.id),$;try{$=fetch(l,{method:"POST",keepalive:!0,body:y,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(d){Ne(p,a,c);for(let m of k)v.delete(m);I++,P=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6));return}let W=d=>{if(d.ok||d.status>=400&&d.status<500&&d.status!==429){f(k),I=0,P=0;return}Ne(p,a,c);for(let m of k)v.delete(m);I++,P=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))};$ instanceof Promise?$.then(W).catch(()=>{Ne(p,a,c);for(let d of k)v.delete(d);I++,P=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))}):W($)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,H=p=>G?G.encode(p).length:p.length,Y=p=>{let y=[],k=2;for(let $ of p){let W=H(JSON.stringify($))+1;if(y.length>0&&k+W>57344||y.length>=i)break;y.push($),k+=W}return y},E=()=>{try{if(Date.now()<P)return;for(;u.length>0;){let p=u.filter(k=>!g.has(k.id));if(u.length=0,p.length===0)break;let y=Y(p);if(y.length===0)break;y.length<p.length&&u.push(...p.slice(y.length)),N(y)}}catch(p){}},j=!0,_=null;_=setInterval(()=>{j&&E()},o);let h=()=>{document.visibilityState==="hidden"&&E()},w=()=>{E()};return document.addEventListener("visibilitychange",h),window.addEventListener("beforeunload",w),{push(p){b(p),u.length>=i&&E()},flush:E,destroy(){j=!1,_!==null&&(clearInterval(_),_=null),document.removeEventListener("visibilitychange",h),window.removeEventListener("beforeunload",w),E()}}}var Ue="_snt_asgn_";function ve(e,t){return`${e}:${t}`}function dn(e,t){return`${Ue}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function lt(e){let t=e.slice(Ue.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 $e(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(Ue)&&e.push(n)}return e}catch(e){return[]}}function fn(e=18e5){let t=new Map,n=r=>r.assignedAt+e<Date.now();return typeof window!="undefined"&&(()=>{for(let r of $e())try{let o=localStorage.getItem(r);if(!o)continue;let i=JSON.parse(o);if(n(i)){localStorage.removeItem(r);continue}let a=lt(r);if(!a)continue;t.set(ve(a.componentId,a.segment),i)}catch(o){}})(),{get(r,o){let i=t.get(ve(r,o));return i?n(i)?(t.delete(ve(r,o)),null):i:null},set(r,o,i){let a=ve(r,o);t.set(a,i);try{localStorage.setItem(dn(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 $e()){let a=lt(i);if((a==null?void 0:a.componentId)===r)try{localStorage.removeItem(i)}catch(l){}}},clear(){t.clear();for(let r of $e())try{localStorage.removeItem(r)}catch(o){}}}}var we="_snt_snap:",pn=["low","medium","high"];function Se(e){try{let t=localStorage.getItem(we+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 de(e,t){try{localStorage.setItem(we+e,JSON.stringify(t))}catch(n){}}var Ke="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",ft="[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.",ct=!1,be=!1;function gn(){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=ut({ssrSessionId:e.ssrSessionId}),r=(t=n.getSessionId())!=null?t:"local",o=gn(),i=Promise.resolve().then(()=>(at(),st)).then(s=>{let c=s;return c.LOCAL_ENGINE_AVAILABLE?(ct||(ct=!0,console.info(ft)),c):(be||(be=!0,console.error(Ke)),null)}).catch(()=>(be||(be=!0,console.error(Ke)),null)),a=null;function l(s){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=s.persona,c.dataset.sentientConfidence=Q(s.confidence))}return{isLocal:!0,async decide(s){var c,u,g;let S=await i;if(!S)return null;let f=S.createLocalEngine({sessionId:r,forcedPersona:o}).decide(s);return a=ue(A({},f),{layoutOrder:(u=(c=f.layoutOrder)!=null?c:a==null?void 0:a.layoutOrder)!=null?u:null,slots:A(A({},(g=a==null?void 0:a.slots)!=null?g:{}),f.slots)}),de(e.apiKey||"local",{v:1,persona:a.persona,band:Q(a.confidence),slots:a.slots,layoutOrder:a.layoutOrder,savedAt:Date.now()}),l(f),f},getSlotResult(s){var c,u,g;return(g=(u=a==null?void 0:a.slots[s])!=null?u:(c=e.initialSlots)==null?void 0:c[s])!=null?g:null},getPersona(){return a?{persona:a.persona,confidence:a.confidence,band:Q(a.confidence)}:null},async assign(s,c){var u;let g=await i;return!g||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(u=g.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:s,variantIds:c}]}).assignments[s])!=null?u:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Ge(e,t,n){var r;let o=[];{let i=!1,a=[],l=()=>{if(i)return;let s=Date.now();for(a.push(s);a.length>0&&s-a[0]>500;)a.shift();a.length>=3&&(i=!0,e("rage_click"))};t.addEventListener("click",l),o.push(()=>t.removeEventListener("click",l))}{let i=!1,a=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let s=typeof window!="undefined"?window.getSelection():null,c=s?s.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",a),o.push(()=>document.removeEventListener("copy",a))}{let i=!1,a=!1,l=null,s=()=>{l!==null&&(clearTimeout(l),l=null)},c=()=>{i||!a||(s(),l=setTimeout(()=>{!i&&a&&(i=!0,e("scroll_hesitation"))},3e3))},u=()=>{s(),c()},g=f=>{for(let v of f)a=v.intersectionRatio>.3,a?c():s()};typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)!=="production"&&(window.__lastIOCallback=g);let S=new IntersectionObserver(g,{threshold:[.3]});S.observe(t),window.addEventListener("scroll",u,{passive:!0}),o.push(()=>{S.disconnect(),window.removeEventListener("scroll",u),s()})}{let i=!1,a=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let s=Date.now()-a;s<15e3&&(i=!0,e("tab_loss",{timeOnPage:s}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of o)i()}}var pt="https://api.sentient-ui.com/v1/events",ee=new Map,gt=null;function Be(){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 ie={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 hn(){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 mt(e){return e.replace(/\/events\/?$/,"")}function te(){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:gt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=ee.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:r,upgrade:o}=n;if(!o||r.respectDoNotTrack!==!1&&te())return;let i=ke(ue(A({},r),{consent:!0}));o(i),ee.set(t,{config:ue(A({},r),{consent:!0}),upgrade:null})}function yn(e){var t;let n=mt((t=e.ingestUrl)!=null?t:pt),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(l,s,c){try{let u=new URLSearchParams({componentId:l});for(let S of s!=null?s:[])u.append("variantIds[]",S);let g=await fetch(`${n}/winner?${u.toString()}`,{headers:r});return g.ok?{variantId:(await g.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(u){return s!=null&&s[0]?{variantId:s[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,s,c,u)=>o.goal(l,s,c,u),componentGoal:(l,s,c)=>o.componentGoal(l,s,c),identify:l=>o.identify(l),getAssignment:(l,s)=>o.getAssignment(l,s),assign:(l,s,c,u)=>o.assign(l,s,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 a(l){o=l}return{proxy:i,setInner:a}}function ke(e){var t,n,r,o,i,a,l,s,c;if(typeof window=="undefined")return ie;gt=e.apiKey;let u=e.respectDoNotTrack!==!1&&te(),g=e.consent===!1||u,S=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!S&&e.localMode!==!1)return g?(ee.set(e.apiKey||"local",{config:e,upgrade:null}),ie):(ee.set(e.apiKey||"local",{config:e,upgrade:null}),mn(e));if(g){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."),ie;let{proxy:d,setInner:m}=yn(e);return ee.set(e.apiKey,{config:e,upgrade:u?null:m}),d}return ee.set(e.apiKey,{config:e,upgrade:null}),ie}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."),ie;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ie;let f=(t=e.ingestUrl)!=null?t:pt,v=Date.now(),b=ut({ssrSessionId:e.ssrSessionId}),O=fn(),P=un({ingestUrl:f,apiKey:e.apiKey}),I=mt(f),N={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},G=Pe((n=navigator.userAgent)!=null?n:""),H=typeof window!="undefined"?window.location.origin:void 0,Y=De((r=document.referrer)!=null?r:"",H),E=(o=e.sessionSegment)!=null?o:`${G}:${Y}`,j=new Map,_=new Map,h=null,w=d=>{for(let m of d)_.has(m.id)||_.set(m.id,ye(m))};if(e.initialSlots)for(let[d,m]of Object.entries(e.initialSlots))_.set(d,m);let p=Se(e.apiKey);if(p)for(let[d,m]of Object.entries(p.slots))_.has(d)||_.set(d,m);let y={low:.15,medium:.5,high:.85};if(e.initialPersona)h=A({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?h={persona:d.sentientPersona,confidence:(a=y[(i=d.sentientConfidence)!=null?i:"low"])!=null?a:.15}:p&&(h={persona:p.persona,confidence:(l=y[p.band])!=null?l:.15})}if(e.initialAssignments)for(let[d,m]of Object.entries(e.initialAssignments))O.set(d,E,{variantId:m,assignedAt:Date.now(),segment:E,confidence:1});let k=Promise.resolve(),$=b.getSessionId();if($){let d=Te((s=document.referrer)!=null?s:""),m=A(A({sessionId:$,deviceClass:G,trafficSource:Y,referrerDomain:d,utmParams:hn(),timeOfDay:je(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:b.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Le((c=navigator.userAgent)!=null?c:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{k=fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(m),headers:N}).then(C=>{C.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(C){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:P});let W={goal(d,m={},C=1,B=0){let M=b.getSessionId();if(!M)return;let D=Be();k.then(()=>{fetch(`${I}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:M,name:d,metadata:m,weight:C,stepIndex:B,goalId:D}),headers:N}).catch(()=>{})})},componentGoal(d,m,C){var B,M,D;let J=b.getSessionId();if(!J)return;let K=O.get(d,E),U=K?null:(B=_.get(d))!=null?B:null;if(!K&&U===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 X=K?K.variantId:Me(U),q={id:Be(),sessionId:J,projectId:e.apiKey,componentId:d,variantId:X,eventType:"goal_achieved",goalType:m,payload:A({reward:(M=C==null?void 0:C.reward)!=null?M:1},(D=C==null?void 0:C.metadata)!=null?D:{}),timestamp:Date.now(),timeInSession:Date.now()-v};e.debug&&console.log("[sentient] componentGoal",q),k.then(()=>P.push(q))},identify(d){let m=b.getSessionId();m&&k.then(()=>{fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:m,userId:d,ephemeral:b.isEphemeral()}),headers:N}).catch(()=>{})})},track(d){let m=b.getSessionId();if(!m)return;let C=ue(A({},d),{id:Be(),sessionId:m,timestamp:Date.now(),timeInSession:Date.now()-v});e.debug&&console.log("[sentient] track",C),k.then(()=>P.push(C))},getAssignment(d,m){return O.get(d,m)},async assign(d,m,C,B){let M=b.getSessionId();if(!M)return null;let D=O.get(d,E);if(D&&(m!=null&&m.length||D.content!==void 0))return{variantId:D.variantId,assignmentTtlMs:0,content:D.content};let J=j.get(d);if(J)return J;let K=(async()=>{await k;try{let U={sessionId:M,componentId:d,variantIds:m};B!==void 0?U.agentDataByVariant=B:C!==void 0&&(U.agentData=C);let X=await fetch(`${I}/assign`,{method:"POST",body:JSON.stringify(U),headers:N});if(!X.ok)return null;let q=await X.json();return O.set(d,E,{variantId:q.variantId,assignedAt:Date.now(),segment:E,confidence:1,content:q.content}),q}catch(U){return null}finally{j.delete(d)}})();return j.set(d,K),K},async decide(d){var m,C,B,M,D,J,K,U,X,q;let ze=b.getSessionId();if(!ze)return null;let ae=(m=d.slots)!=null?m:[];await k;try{let Z={sessionId:ze};d.sections&&d.sections.length>0&&(Z.sections=d.sections.map(T=>({id:T}))),Z.components=(C=d.components)!=null?C:[],ae.length>0&&(Z.slots=ae.map(he)),d.slotsFrom==="registry"&&(Z.slotsFrom="registry"),d.v&&(Z.v=d.v);let Fe=await fetch(`${I}/decide`,{method:"POST",body:JSON.stringify(Z),headers:N});if(!Fe.ok)return w(ae),null;let R=await Fe.json(),le={};for(let T of ae)le[T.id]=(M=(B=R.slots)==null?void 0:B[T.id])!=null?M:ye(T);if(R.slots)for(let[T,ce]of Object.entries(R.slots))T in le||(le[T]=ce);for(let[T,ce]of Object.entries(le))_.set(T,ce);h={persona:(D=R.persona)!=null?D:"unknown",confidence:(J=R.confidence)!=null?J:0};for(let[T,ce]of Object.entries((K=R.assignments)!=null?K:{}))O.set(T,E,{variantId:ce,assignedAt:Date.now(),segment:E,confidence:1});return de(e.apiKey,A({v:1,persona:h.persona,band:Q(h.confidence),slots:Object.fromEntries(_),layoutOrder:(U=R.layoutOrder)!=null?U:null,savedAt:Date.now()},R.slotConfig?{slotConfig:R.slotConfig}:{})),A(A({layoutOrder:(X=R.layoutOrder)!=null?X:null,assignments:(q=R.assignments)!=null?q:{},slots:le,persona:h.persona,confidence:h.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{})}catch(Z){return w(ae),null}},getSlotResult(d){var m;return(m=_.get(d))!=null?m:null},getPersona(){return h?{persona:h.persona,confidence:h.confidence,band:Q(h.confidence)}:null},async fetchWeights(){var d;try{let m=await fetch(`${I}/weights`,{headers:N});return m.ok?(d=(await m.json()).components)!=null?d:[]:[]}catch(m){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){P.destroy(),e.debug&&console.log("[sentient] disposed")},destroy(){P.destroy(),b.destroy();try{localStorage.removeItem(we+e.apiKey),localStorage.removeItem(dt(e.apiKey))}catch(d){}e.debug&&console.log("[sentient] destroyed")}};if(ee.set(e.apiKey,{config:e,upgrade:null}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=W)}return W}re();var ht=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],vn=[["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]],bn=[["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 wn(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function yt(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 vn)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of bn)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 vt(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:wn(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function bt(e){return yt(vt(e)).type}re();var St="section, header, footer, nav, main > div, [data-sentient-section]";function Sn(e){var t;return((t=e.parentElement)==null?void 0:t.closest(St))!=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 wt=()=>{};function kt(e,t){var n,r,o,i,a,l,s,c,u;let g=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!g||typeof IntersectionObserver=="undefined"||te())return wt;let S=(r=t.apiBase)!=null?r:"https://api.sentient-ui.com",f=Array.from(g.querySelectorAll(St)).filter(h=>!Sn(h));if(f.length===0)return wt;let v=new Map,b=new Map,O=new Map;for(let h of f){let w=h.getAttribute("data-sentient-type"),p=w&&ht.includes(w)?w:null,y=(i=p!=null?p:(o=t.typeOf)==null?void 0:o.call(t,h))!=null?i:bt(h),k=`nc-${y}`;v.set(h,k),b.set(k,y),p?O.set(k,"markup"):O.has(k)||O.set(k,"auto")}let P=(c=(s=(l=(a=g.defaultView)!=null?a:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:s.pathname)!=null?c:"/";kn(t.apiKey,S,P,[...b.entries()].map(([h,w])=>{var p;return{componentId:h,semanticType:w,source:(p=O.get(h))!=null?p:"auto"}}));let I=new Map,N=h=>{let w=I.get(h);return w||(w={ms:0,scroll:0,enterAt:null,intersecting:!1},I.set(h,w)),w},G=new IntersectionObserver(h=>{for(let w of h){let p=v.get(w.target);if(!p)continue;let y=N(p);w.isIntersecting?(y.intersecting=!0,y.enterAt=Date.now(),w.intersectionRatio>y.scroll&&(y.scroll=w.intersectionRatio)):(y.intersecting=!1,y.enterAt!=null&&(y.ms+=Date.now()-y.enterAt,y.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let h of v.keys())G.observe(h);let H=()=>{let h=Date.now();for(let[w,p]of I)if(p.enterAt!=null&&(p.ms+=h-p.enterAt,p.enterAt=null),!(p.ms<=0)){try{e.track({projectId:t.apiKey,componentId:w,eventType:"dwell",payload:{dwell_time:Math.round(p.ms),scroll_depth:Number(p.scroll.toFixed(2))}})}catch(y){}p.ms=0}},Y=()=>{if(g.hidden)H();else{let h=Date.now();for(let w of I.values())w.intersecting&&(w.enterAt=h)}},E=()=>{H();try{G.disconnect()}catch(h){}};g.addEventListener("visibilitychange",Y);let j=(u=g.defaultView)!=null?u:typeof window!="undefined"?window:void 0;j==null||j.addEventListener("pagehide",E);let _=[];if(t.microSignals)for(let[h,w]of v)_.push(Ge((p,y={})=>{try{e.track({projectId:t.apiKey,componentId:w,eventType:"micro_signal",payload:A({signalType:p},y)})}catch(k){}},h));return()=>{H(),g.removeEventListener("visibilitychange",Y),j==null||j.removeEventListener("pagehide",E);for(let h of _)h();try{G.disconnect()}catch(h){}}}var An=["landing","ecommerce","saas","marketplace"];function xn(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 On(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Ae(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=An.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,a]of Object.entries(t.slots)){if(typeof a!="object"||a===null)continue;let l=a,s=xn(l.dims);if(!s||l.target!==void 0&&typeof l.target!="string")continue;let c=l.arms!==void 0?On(l.arms):null,u={dims:s};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 At(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 In(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 xt(e,t){return!!(e!=null&&e.urlMatch)&&!At(t).includes(e.urlMatch)}function V(e,t){var o;if(e.urlMatch&&!At(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&&!In(r,e.fingerprint)?null:r}var Ot=/^https:\/\//i,En={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 Cn(e){return!/[;{}<>]/.test(e)}var It=new Map,z=null;function _n(e){return e.replace(/["\\]/g,"\\$&")}function Rn(e){var t;(!z||!z.isConnected)&&(z=e.querySelector("style[data-sentient-ops]"),z||(z=e.createElement("style"),z.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(z))),z.textContent=[...It.entries()].map(([n,r])=>`[data-snt-e="${_n(n)}"]{${r}}`).join(`
2
- `)}function Et(e,t,n,r){var l;let o=!1,i=(l=t.moveBefore)!=null?l:t.moveAfter;if(i){let s=V(i,r);!s||s===e||s.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,s):e.parentElement.insertBefore(e,s.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Ot.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Ot.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let a=[];if(t.hidden&&a.push("display:none !important"),t.style)for(let[s,c]of Object.entries(t.style)){let u=En[s];u&&typeof c=="string"&&Cn(c)&&a.push(`${u}:${c.trim()} !important`)}return a.length>0&&(e.setAttribute("data-snt-e",n),It.set(n,a.join(";")),Rn(r)),{anchorMiss:o}}function xe(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Oe(e,t,n){var r;for(let[o,i]of Object.entries(t)){let a=e[o];if(!a||typeof a=="string")continue;let l=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let s of l)for(let[c,u]of Object.entries(a))(r=i.dims[c])!=null&&r.includes(u)&&s.setAttribute(`data-${c}`,u)}}function Ie(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 a=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let l of a)l.setAttribute("data-sentient-arm",i)}}function Ee(e,t,n,r){var a;let o=(a=r==null?void 0:r.contentAndOps)!=null?a:!0,i=[];for(let[l,s]of Object.entries(t)){if(xt(s.locator,n))continue;let c;if(s.locator){let g=V(s.locator,n);c=g?[g]:[]}else s.target?c=Array.from(n.querySelectorAll(s.target)):c=[n.documentElement];(s.locator||s.target)&&c.length===0&&i.push(l);let u=e[l];for(let g of c){if(u!==void 0)if(typeof u=="string")g.setAttribute("data-sentient-arm",u);else for(let[S,f]of Object.entries(u))g.setAttribute(`data-${S}`,f);o&&(typeof s.content=="string"&&(g.textContent=s.content),s.ops&&Et(g,s.ops,l,n).anchorMiss&&!i.includes(l)&&i.push(l))}}return i}function Ln(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 Ct(e,t,n){var S;let r=new Set,o=f=>{if(!r.has(f.goalId)){r.add(f.goalId);try{f.slotId?t.componentGoal(f.slotId,f.goalId):t.goal(f.goalId)}catch(v){}}},i=e.filter(f=>f.event==="click"),a=e.filter(f=>f.event==="form_submit"),l=e.filter(f=>f.event==="url_reached"),s=(f,v)=>{if(!f.locator)return!1;let b=V(f.locator,n);return!!b&&(b===v||b.contains(v))},c=f=>{let v=f.target;if(!(!v||typeof v.closest!="function"))for(let b of i)s(b,v)&&o(b)},u=f=>{let v=f.target;if(v)for(let b of a)s(b,v)&&o(b)},g=()=>{if(l.length===0)return;let f=Ln(n);for(let v of l)v.urlPattern&&f.includes(v.urlPattern)&&o(v)};return n.addEventListener("click",c,!0),n.addEventListener("submit",u,!0),(S=n.defaultView)==null||S.addEventListener("popstate",g),g(),{checkUrl:g,teardown:()=>{var f;n.removeEventListener("click",c,!0),n.removeEventListener("submit",u,!0),(f=n.defaultView)==null||f.removeEventListener("popstate",g)}}}var Pt="0.6.0",Pn=5e3,Dn=50,fe=null,L=null,F={},se=null,ne=null,x=null,_t=!1,We=null;function Tn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function Ce(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function _e(e,t){return fe?(fe.personaAttributes&&x&&xe(x.persona,x.band,e),Oe(F,fe.slots,e),Ie(F,fe.slots,e),se?Ee(F,se,e,t):[]):[]}function jn(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 Ve(){try{_e(document)}catch(e){}}function Rt(){We===null&&(We=setTimeout(()=>{We=null,Ve();try{ne==null||ne.checkUrl()}catch(e){}},Dn))}function Lt(){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 a=n.call(this,r,o,i!=null?i:null);return Rt(),a}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Rt)}catch(e){}}}function Je(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 Dt(e){return new URLSearchParams(e).get("sentient_editor")}function Mn(){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 Nn(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 s=document.createElement("meta");s.name="referrer",s.content="no-referrer",((r=document.head)!=null?r:document.documentElement).appendChild(s)}catch(s){}let a=(o=e.editorSrc)!=null?o:Mn();if(!a)return;let l=document.createElement("script");l.src=a,l.async=!0,((i=document.head)!=null?i:document.documentElement).appendChild(l)}catch(a){}}function Tt(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let[o,i]=r.split(":");if(!(!o||!i))if(i.includes("=")){let a={};for(let l of i.split(",")){let[s,c]=l.split("=");s&&c&&(a[s]=c)}Object.keys(a).length&&(n[o]=a)}else n[o]=i}return Object.keys(n).length?n:null}function $n(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{qe(e.apiKey)}catch(n){}},revokeConsent(){try{L==null||L.destroy()}catch(n){}},reapply:Ve,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=x==null?void 0:x.persona)!=null?n:null,band:(r=x==null?void 0:x.band)!=null?r:null,slots:F,matchCounts:Je(e),consent:e.consent!==!1}}};window.SentientSnippet=t}async function jt(){var e,t,n;try{let r=Ae(window.sentient);if(!r)return;fe=r;let o=typeof window!="undefined"?Dt(window.location.search):null;if(o){try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}Nn(r,o),Ce(r,"editor mode");return}let i=typeof window!="undefined"?Tt(window.location.search):null;if(i){F=i,x=null,_e(document),Lt(),Ce(r,"preview mode",i);return}let a=(e=r.registry)!=null?e:Object.keys(r.slots).length===0,l=Se(r.apiKey);l&&(x={persona:l.persona,band:l.band},F=l.slots,l.slotConfig&&(se=l.slotConfig),_e(document,{contentAndOps:!1}));let s=ke({apiKey:r.apiKey,context:r.context,consent:r.consent,preConsentBehavior:r.preConsentBehavior,debug:r.debug});L=s,$n(r),Lt();let c=Object.entries(r.slots).map(([f,v])=>({id:f,dims:v.dims})),u=await Tn(s.decide(ge({slots:c,v:Pt},a?{slotsFrom:"registry"}:{})),Pn);if(!u){Ce(r,"decide timeout/null \u2014 snapshot state stands",Je(r));return}let g=s.getPersona();if(g?x={persona:g.persona,band:g.band}:u.persona&&(x={persona:u.persona,band:"low"}),F=u.slots,u.slotConfig&&(se=u.slotConfig),jn(r,_e(document)),u.goals&&u.goals.length>0&&r.consent!==!1&&L)try{ne==null||ne.teardown(),ne=Ct(u.goals,L,document)}catch(f){}let S;try{let f=u.sectionMap;if(f&&f.length>0){let v=new Map;for(let b of f){if(b.urlMatch!==window.location.pathname)continue;let O=V(b.locator,document);O&&v.set(O,b.type)}v.size>0&&(S=b=>{var O;return(O=v.get(b))!=null?O:null})}}catch(f){}if(r.sectionCapture!==!1&&r.consent!==!1&&L&&!te())try{kt(L,ge({apiKey:r.apiKey,apiBase:r.apiBase,doc:document,microSignals:!0},S?{typeOf:S}:{}))}catch(f){}Ce(r,"applied",{persona:x,slots:F,matches:Je(r)}),de(r.apiKey,ge({v:1,persona:(t=x==null?void 0:x.persona)!=null?t:u.persona,band:(n=x==null?void 0:x.band)!=null?n:"low",slots:u.slots,layoutOrder:u.layoutOrder,savedAt:Date.now()},se?{slotConfig:se}:{}))}catch(r){}}typeof window!="undefined"&&window.sentient&&jt();return Kt(Bn);})();
1
+ "use strict";var SentientSnippet=(()=>{var pe=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames,He=Object.getOwnPropertySymbols;var Xe=Object.prototype.hasOwnProperty,$t=Object.prototype.propertyIsEnumerable;var Ye=(e,t,n)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ge=(e,t)=>{for(var n in t||(t={}))Xe.call(t,n)&&Ye(e,n,t[n]);if(He)for(var n of He(t))$t.call(t,n)&&Ye(e,n,t[n]);return e};var Ze=(e,t)=>()=>(e&&(t=e(e=0)),t);var Qe=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},Bt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Nt(t))!Xe.call(e,o)&&o!==n&&pe(e,o,{get:()=>t[o],enumerable:!(r=Mt(t,o))||r.enumerable});return e};var Kt=e=>Bt(pe({},"__esModule",{value:!0}),e);var Ut,Gt,qt,et,Wt,Jt,tt,A,ue,re=Ze(()=>{"use strict";Ut=Object.defineProperty,Gt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,Wt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable,tt=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,A=(e,t)=>{for(var n in t||(t={}))Wt.call(t,n)&&tt(e,n,t[n]);if(et)for(var n of et(t))Jt.call(t,n)&&tt(e,n,t[n]);return e},ue=(e,t)=>Gt(e,qt(t))});var st={};Qe(st,{LOCAL_ENGINE_AVAILABLE:()=>Vt,createLocalEngine:()=>zt});function zt(e){throw new Error("[sentient] createLocalEngine is not available in production builds. The local engine only exists under the `development` export condition.")}var Vt,at=Ze(()=>{"use strict";re();Vt=!1});var Bn={};Qe(Bn,{applyPersonaAttributes:()=>xe,applyRegistrySlots:()=>Ee,applySlotArms:()=>Ie,applySlotAttributes:()=>Oe,parseEditorToken:()=>Dt,parsePreview:()=>Tt,parseSnippetConfig:()=>Ae,reapply:()=>Ve,run:()=>jt,version:()=>Pt});re();function me(e){return Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join("|")}function nt(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 Re(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 me(e.baseline);if(typeof e.baseline=="string")return e.baseline;let o={};for(let[i,a]of Object.entries((n=e.dims)!=null?n:{}))o[i]=(r=a[0])!=null?r:"";return me(o)}function rt(e,t){var n,r;return e.dims!=null?(r=(n=nt(t))!=null?n:nt(Re(e)))!=null?r:{}:t}function Q(e){return e>=.3?e<.7?"medium":"high":"low"}var ot=["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 Le(e){return it(e)!==null}function it(e){var t;if(!e)return null;let n=e.toLowerCase();return(t=ot.find(r=>n.includes(r.toLowerCase())))!=null?t:null}function Pe(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 De(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 Te(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function je(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function he(e){return A(A(A({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 ye(e){let t=he(e);return rt(t,Re(t))}function Me(e){return typeof e=="string"?e:me(e)}re();var Ft="_snt_uid",oe="_snt_uid";function Ht(){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 Yt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Xt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(r){}}function Zt(e){try{return localStorage.getItem(e)}catch(t){return null}}function Qt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function en(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function tn(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function nn(e){try{sessionStorage.removeItem(e)}catch(t){}}function rn(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 on(e){try{localStorage.removeItem(e)}catch(t){}}function sn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var an={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ut(e){var t,n,r,o,i,a;if(typeof window=="undefined")return an;let l=(t=e==null?void 0:e.cookieName)!=null?t:Ft,s=((n=e==null?void 0:e.cookieTTLDays)!=null?n:365)*24*60*60,c=(a=(i=(o=(r=Yt(l))!=null?r:Zt(oe))!=null?o:en(oe))!=null?i:e==null?void 0:e.ssrSessionId)!=null?a:Ht();Xt(l,c,s);let u=Qt(oe,c),g=rn(l),S=u?!1:tn(oe,c),f=!u&&!g&&!S;return{getSessionId:()=>c,isEphemeral:()=>f,destroy:()=>{c=null,sn(l),on(oe),nn(oe)}}}function dt(e){return`_snt_retry_${e.slice(0,12)}`}var ln={push:()=>{},flush:()=>{},destroy:()=>{}};function cn(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 Ne(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 un(e){var t,n,r;if(typeof window=="undefined")return ln;let o=(t=e.flushIntervalMs)!=null?t:5e3,i=(n=e.maxBatchSize)!=null?n:20,a=(r=e.maxRetrySize)!=null?r:100,l=e.ingestUrl,s=e.apiKey,c=dt(s),u=[],g=new Set,S=[],f=p=>{for(let y of p)v.delete(y),!g.has(y)&&(g.add(y),S.push(y));for(;S.length>500;){let y=S.shift();y&&g.delete(y)}},v=new Set,b=p=>{g.has(p.id)||v.has(p.id)||(v.add(p.id),u.push(p))},O=cn(a,c);for(let p of O)b(p);let P=0,I=0,N=p=>{if(p.length===0)return;let y=JSON.stringify(p),k=p.map(d=>d.id),$;try{$=fetch(l,{method:"POST",keepalive:!0,body:y,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(d){Ne(p,a,c);for(let m of k)v.delete(m);I++,P=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6));return}let W=d=>{if(d.ok||d.status>=400&&d.status<500&&d.status!==429){f(k),I=0,P=0;return}Ne(p,a,c);for(let m of k)v.delete(m);I++,P=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))};$ instanceof Promise?$.then(W).catch(()=>{Ne(p,a,c);for(let d of k)v.delete(d);I++,P=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))}):W($)},G=typeof TextEncoder!="undefined"?new TextEncoder:null,H=p=>G?G.encode(p).length:p.length,Y=p=>{let y=[],k=2;for(let $ of p){let W=H(JSON.stringify($))+1;if(y.length>0&&k+W>57344||y.length>=i)break;y.push($),k+=W}return y},E=()=>{try{if(Date.now()<P)return;for(;u.length>0;){let p=u.filter(k=>!g.has(k.id));if(u.length=0,p.length===0)break;let y=Y(p);if(y.length===0)break;y.length<p.length&&u.push(...p.slice(y.length)),N(y)}}catch(p){}},j=!0,_=null;_=setInterval(()=>{j&&E()},o);let h=()=>{document.visibilityState==="hidden"&&E()},w=()=>{E()};return document.addEventListener("visibilitychange",h),window.addEventListener("beforeunload",w),{push(p){b(p),u.length>=i&&E()},flush:E,destroy(){j=!1,_!==null&&(clearInterval(_),_=null),document.removeEventListener("visibilitychange",h),window.removeEventListener("beforeunload",w),E()}}}var Ue="_snt_asgn_";function ve(e,t){return`${e}:${t}`}function dn(e,t){return`${Ue}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function lt(e){let t=e.slice(Ue.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 $e(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(Ue)&&e.push(n)}return e}catch(e){return[]}}function fn(e=18e5){let t=new Map,n=r=>r.assignedAt+e<Date.now();return typeof window!="undefined"&&(()=>{for(let r of $e())try{let o=localStorage.getItem(r);if(!o)continue;let i=JSON.parse(o);if(n(i)){localStorage.removeItem(r);continue}let a=lt(r);if(!a)continue;t.set(ve(a.componentId,a.segment),i)}catch(o){}})(),{get(r,o){let i=t.get(ve(r,o));return i?n(i)?(t.delete(ve(r,o)),null):i:null},set(r,o,i){let a=ve(r,o);t.set(a,i);try{localStorage.setItem(dn(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 $e()){let a=lt(i);if((a==null?void 0:a.componentId)===r)try{localStorage.removeItem(i)}catch(l){}}},clear(){t.clear();for(let r of $e())try{localStorage.removeItem(r)}catch(o){}}}}var we="_snt_snap:",pn=["low","medium","high"];function Se(e){try{let t=localStorage.getItem(we+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 de(e,t){try{localStorage.setItem(we+e,JSON.stringify(t))}catch(n){}}var Ke="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",ft="[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.",ct=!1,be=!1;function gn(){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=ut({ssrSessionId:e.ssrSessionId}),r=(t=n.getSessionId())!=null?t:"local",o=gn(),i=Promise.resolve().then(()=>(at(),st)).then(s=>{let c=s;return c.LOCAL_ENGINE_AVAILABLE?(ct||(ct=!0,console.info(ft)),c):(be||(be=!0,console.error(Ke)),null)}).catch(()=>(be||(be=!0,console.error(Ke)),null)),a=null;function l(s){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=s.persona,c.dataset.sentientConfidence=Q(s.confidence))}return{isLocal:!0,async decide(s){var c,u,g;let S=await i;if(!S)return null;let f=S.createLocalEngine({sessionId:r,forcedPersona:o}).decide(s);return a=ue(A({},f),{layoutOrder:(u=(c=f.layoutOrder)!=null?c:a==null?void 0:a.layoutOrder)!=null?u:null,slots:A(A({},(g=a==null?void 0:a.slots)!=null?g:{}),f.slots)}),de(e.apiKey||"local",{v:1,persona:a.persona,band:Q(a.confidence),slots:a.slots,layoutOrder:a.layoutOrder,savedAt:Date.now()}),l(f),f},getSlotResult(s){var c,u,g;return(g=(u=a==null?void 0:a.slots[s])!=null?u:(c=e.initialSlots)==null?void 0:c[s])!=null?g:null},getPersona(){return a?{persona:a.persona,confidence:a.confidence,band:Q(a.confidence)}:null},async assign(s,c){var u;let g=await i;return!g||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(u=g.createLocalEngine({sessionId:r,forcedPersona:o}).decide({components:[{id:s,variantIds:c}]}).assignments[s])!=null?u:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>n.destroy()}}function Ge(e,t,n){var r;let o=[];{let i=!1,a=[],l=()=>{if(i)return;let s=Date.now();for(a.push(s);a.length>0&&s-a[0]>500;)a.shift();a.length>=3&&(i=!0,e("rage_click"))};t.addEventListener("click",l),o.push(()=>t.removeEventListener("click",l))}{let i=!1,a=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let s=typeof window!="undefined"?window.getSelection():null,c=s?s.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",a),o.push(()=>document.removeEventListener("copy",a))}{let i=!1,a=!1,l=null,s=()=>{l!==null&&(clearTimeout(l),l=null)},c=()=>{i||!a||(s(),l=setTimeout(()=>{!i&&a&&(i=!0,e("scroll_hesitation"))},3e3))},u=()=>{s(),c()},g=f=>{for(let v of f)a=v.intersectionRatio>.3,a?c():s()};typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)!=="production"&&(window.__lastIOCallback=g);let S=new IntersectionObserver(g,{threshold:[.3]});S.observe(t),window.addEventListener("scroll",u,{passive:!0}),o.push(()=>{S.disconnect(),window.removeEventListener("scroll",u),s()})}{let i=!1,a=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let s=Date.now()-a;s<15e3&&(i=!0,e("tab_loss",{timeOnPage:s}))};document.addEventListener("visibilitychange",l),o.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of o)i()}}var pt="https://api.sentient-ui.com/v1/events",ee=new Map,gt=null;function Be(){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 ie={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 hn(){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 mt(e){return e.replace(/\/events\/?$/,"")}function te(){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:gt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=ee.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:r,upgrade:o}=n;if(!o||r.respectDoNotTrack!==!1&&te())return;let i=ke(ue(A({},r),{consent:!0}));o(i),ee.set(t,{config:ue(A({},r),{consent:!0}),upgrade:null})}function yn(e){var t;let n=mt((t=e.ingestUrl)!=null?t:pt),r={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(l,s,c){try{let u=new URLSearchParams({componentId:l});for(let S of s!=null?s:[])u.append("variantIds[]",S);let g=await fetch(`${n}/winner?${u.toString()}`,{headers:r});return g.ok?{variantId:(await g.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(u){return s!=null&&s[0]?{variantId:s[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,s,c,u)=>o.goal(l,s,c,u),componentGoal:(l,s,c)=>o.componentGoal(l,s,c),identify:l=>o.identify(l),getAssignment:(l,s)=>o.getAssignment(l,s),assign:(l,s,c,u)=>o.assign(l,s,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 a(l){o=l}return{proxy:i,setInner:a}}function ke(e){var t,n,r,o,i,a,l,s,c;if(typeof window=="undefined")return ie;gt=e.apiKey;let u=e.respectDoNotTrack!==!1&&te(),g=e.consent===!1||u,S=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!S&&e.localMode!==!1)return g?(ee.set(e.apiKey||"local",{config:e,upgrade:null}),ie):(ee.set(e.apiKey||"local",{config:e,upgrade:null}),mn(e));if(g){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."),ie;let{proxy:d,setInner:m}=yn(e);return ee.set(e.apiKey,{config:e,upgrade:u?null:m}),d}return ee.set(e.apiKey,{config:e,upgrade:null}),ie}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."),ie;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ie;let f=(t=e.ingestUrl)!=null?t:pt,v=Date.now(),b=ut({ssrSessionId:e.ssrSessionId}),O=fn(),P=un({ingestUrl:f,apiKey:e.apiKey}),I=mt(f),N={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},G=Pe((n=navigator.userAgent)!=null?n:""),H=typeof window!="undefined"?window.location.origin:void 0,Y=De((r=document.referrer)!=null?r:"",H),E=(o=e.sessionSegment)!=null?o:`${G}:${Y}`,j=new Map,_=new Map,h=null,w=d=>{for(let m of d)_.has(m.id)||_.set(m.id,ye(m))};if(e.initialSlots)for(let[d,m]of Object.entries(e.initialSlots))_.set(d,m);let p=Se(e.apiKey);if(p)for(let[d,m]of Object.entries(p.slots))_.has(d)||_.set(d,m);let y={low:.15,medium:.5,high:.85};if(e.initialPersona)h=A({},e.initialPersona);else{let d=document.documentElement.dataset;d.sentientPersona?h={persona:d.sentientPersona,confidence:(a=y[(i=d.sentientConfidence)!=null?i:"low"])!=null?a:.15}:p&&(h={persona:p.persona,confidence:(l=y[p.band])!=null?l:.15})}if(e.initialAssignments)for(let[d,m]of Object.entries(e.initialAssignments))O.set(d,E,{variantId:m,assignedAt:Date.now(),segment:E,confidence:1});let k=Promise.resolve(),$=b.getSessionId();if($){let d=Te((s=document.referrer)!=null?s:""),m=A(A({sessionId:$,deviceClass:G,trafficSource:Y,referrerDomain:d,utmParams:hn(),timeOfDay:je(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:b.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Le((c=navigator.userAgent)!=null?c:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{k=fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(m),headers:N}).then(C=>{C.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(C){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:P});let W={goal(d,m={},C=1,B=0){let M=b.getSessionId();if(!M)return;let D=Be();k.then(()=>{fetch(`${I}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:M,name:d,metadata:m,weight:C,stepIndex:B,goalId:D}),headers:N}).catch(()=>{})})},componentGoal(d,m,C){var B,M,D;let J=b.getSessionId();if(!J)return;let K=O.get(d,E),U=K?null:(B=_.get(d))!=null?B:null;if(!K&&U===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 X=K?K.variantId:Me(U),q={id:Be(),sessionId:J,projectId:e.apiKey,componentId:d,variantId:X,eventType:"goal_achieved",goalType:m,payload:A({reward:(M=C==null?void 0:C.reward)!=null?M:1},(D=C==null?void 0:C.metadata)!=null?D:{}),timestamp:Date.now(),timeInSession:Date.now()-v};e.debug&&console.log("[sentient] componentGoal",q),k.then(()=>P.push(q))},identify(d){let m=b.getSessionId();m&&k.then(()=>{fetch(`${I}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:m,userId:d,ephemeral:b.isEphemeral()}),headers:N}).catch(()=>{})})},track(d){let m=b.getSessionId();if(!m)return;let C=ue(A({},d),{id:Be(),sessionId:m,timestamp:Date.now(),timeInSession:Date.now()-v});e.debug&&console.log("[sentient] track",C),k.then(()=>P.push(C))},getAssignment(d,m){return O.get(d,m)},async assign(d,m,C,B){let M=b.getSessionId();if(!M)return null;let D=O.get(d,E);if(D&&(m!=null&&m.length||D.content!==void 0))return{variantId:D.variantId,assignmentTtlMs:0,content:D.content};let J=j.get(d);if(J)return J;let K=(async()=>{await k;try{let U={sessionId:M,componentId:d,variantIds:m};B!==void 0?U.agentDataByVariant=B:C!==void 0&&(U.agentData=C);let X=await fetch(`${I}/assign`,{method:"POST",body:JSON.stringify(U),headers:N});if(!X.ok)return null;let q=await X.json();return O.set(d,E,{variantId:q.variantId,assignedAt:Date.now(),segment:E,confidence:1,content:q.content}),q}catch(U){return null}finally{j.delete(d)}})();return j.set(d,K),K},async decide(d){var m,C,B,M,D,J,K,U,X,q;let ze=b.getSessionId();if(!ze)return null;let ae=(m=d.slots)!=null?m:[];await k;try{let Z={sessionId:ze};d.sections&&d.sections.length>0&&(Z.sections=d.sections.map(T=>({id:T}))),Z.components=(C=d.components)!=null?C:[],ae.length>0&&(Z.slots=ae.map(he)),d.slotsFrom==="registry"&&(Z.slotsFrom="registry"),d.v&&(Z.v=d.v);let Fe=await fetch(`${I}/decide`,{method:"POST",body:JSON.stringify(Z),headers:N});if(!Fe.ok)return w(ae),null;let R=await Fe.json(),le={};for(let T of ae)le[T.id]=(M=(B=R.slots)==null?void 0:B[T.id])!=null?M:ye(T);if(R.slots)for(let[T,ce]of Object.entries(R.slots))T in le||(le[T]=ce);for(let[T,ce]of Object.entries(le))_.set(T,ce);h={persona:(D=R.persona)!=null?D:"unknown",confidence:(J=R.confidence)!=null?J:0};for(let[T,ce]of Object.entries((K=R.assignments)!=null?K:{}))O.set(T,E,{variantId:ce,assignedAt:Date.now(),segment:E,confidence:1});return de(e.apiKey,A({v:1,persona:h.persona,band:Q(h.confidence),slots:Object.fromEntries(_),layoutOrder:(U=R.layoutOrder)!=null?U:null,savedAt:Date.now()},R.slotConfig?{slotConfig:R.slotConfig}:{})),A(A({layoutOrder:(X=R.layoutOrder)!=null?X:null,assignments:(q=R.assignments)!=null?q:{},slots:le,persona:h.persona,confidence:h.confidence},R.slotConfig?{slotConfig:R.slotConfig}:{}),R.goals?{goals:R.goals}:{})}catch(Z){return w(ae),null}},getSlotResult(d){var m;return(m=_.get(d))!=null?m:null},getPersona(){return h?{persona:h.persona,confidence:h.confidence,band:Q(h.confidence)}:null},async fetchWeights(){var d;try{let m=await fetch(`${I}/weights`,{headers:N});return m.ok?(d=(await m.json()).components)!=null?d:[]:[]}catch(m){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){P.destroy(),e.debug&&console.log("[sentient] disposed")},destroy(){P.destroy(),b.destroy();try{localStorage.removeItem(we+e.apiKey),localStorage.removeItem(dt(e.apiKey))}catch(d){}e.debug&&console.log("[sentient] destroyed")}};if(ee.set(e.apiKey,{config:e,upgrade:null}),e.debug){let d=window;d.__sentient&&(d.__sentient.client=W)}return W}re();var ht=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],vn=[["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]],bn=[["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 wn(e){var t;let n=e.querySelector("h1, h2, h3");return((t=n==null?void 0:n.textContent)!=null?t:"").slice(0,160)}function yt(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 vn)if(r.test(t))return{type:n,strength:"strong"};for(let[n,r]of bn)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 vt(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:wn(e),bodyText:r.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:r.length}}function bt(e){return yt(vt(e)).type}re();var St="section, header, footer, nav, main > div, [data-sentient-section]";function Sn(e){var t;return((t=e.parentElement)==null?void 0:t.closest(St))!=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 wt=()=>{};function kt(e,t){var n,r,o,i,a,l,s,c,u;let g=(n=t.doc)!=null?n:typeof document!="undefined"?document:void 0;if(!g||typeof IntersectionObserver=="undefined"||te()||!t.apiKey)return wt;let S=(r=t.apiBase)!=null?r:"https://api.sentient-ui.com",f=Array.from(g.querySelectorAll(St)).filter(h=>!Sn(h));if(f.length===0)return wt;let v=new Map,b=new Map,O=new Map;for(let h of f){let w=h.getAttribute("data-sentient-type"),p=w&&ht.includes(w)?w:null,y=(i=p!=null?p:(o=t.typeOf)==null?void 0:o.call(t,h))!=null?i:bt(h),k=`nc-${y}`;v.set(h,k),b.set(k,y),p?O.set(k,"markup"):O.has(k)||O.set(k,"auto")}let P=(c=(s=(l=(a=g.defaultView)!=null?a:typeof window!="undefined"?window:void 0)==null?void 0:l.location)==null?void 0:s.pathname)!=null?c:"/";kn(t.apiKey,S,P,[...b.entries()].map(([h,w])=>{var p;return{componentId:h,semanticType:w,source:(p=O.get(h))!=null?p:"auto"}}));let I=new Map,N=h=>{let w=I.get(h);return w||(w={ms:0,scroll:0,enterAt:null,intersecting:!1},I.set(h,w)),w},G=new IntersectionObserver(h=>{for(let w of h){let p=v.get(w.target);if(!p)continue;let y=N(p);w.isIntersecting?(y.intersecting=!0,y.enterAt=Date.now(),w.intersectionRatio>y.scroll&&(y.scroll=w.intersectionRatio)):(y.intersecting=!1,y.enterAt!=null&&(y.ms+=Date.now()-y.enterAt,y.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let h of v.keys())G.observe(h);let H=()=>{let h=Date.now();for(let[w,p]of I)if(p.enterAt!=null&&(p.ms+=h-p.enterAt,p.enterAt=null),!(p.ms<=0)){try{e.track({projectId:t.apiKey,componentId:w,eventType:"dwell",payload:{dwell_time:Math.round(p.ms),scroll_depth:Number(p.scroll.toFixed(2))}})}catch(y){}p.ms=0}},Y=()=>{if(g.hidden)H();else{let h=Date.now();for(let w of I.values())w.intersecting&&(w.enterAt=h)}},E=()=>{H();try{G.disconnect()}catch(h){}};g.addEventListener("visibilitychange",Y);let j=(u=g.defaultView)!=null?u:typeof window!="undefined"?window:void 0;j==null||j.addEventListener("pagehide",E);let _=[];if(t.microSignals)for(let[h,w]of v)_.push(Ge((p,y={})=>{try{e.track({projectId:t.apiKey,componentId:w,eventType:"micro_signal",payload:A({signalType:p},y)})}catch(k){}},h));return()=>{H(),g.removeEventListener("visibilitychange",Y),j==null||j.removeEventListener("pagehide",E);for(let h of _)h();try{G.disconnect()}catch(h){}}}var An=["landing","ecommerce","saas","marketplace"];function xn(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 On(e){return!Array.isArray(e)||e.length<2||e.length>12||!e.every(t=>typeof t=="string")?null:e}function Ae(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=An.includes(t.context)?t.context:"landing",r={};if(typeof t.slots=="object"&&t.slots!==null&&!Array.isArray(t.slots))for(let[i,a]of Object.entries(t.slots)){if(typeof a!="object"||a===null)continue;let l=a,s=xn(l.dims);if(!s||l.target!==void 0&&typeof l.target!="string")continue;let c=l.arms!==void 0?On(l.arms):null,u={dims:s};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 At(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 In(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 xt(e,t){return!!(e!=null&&e.urlMatch)&&!At(t).includes(e.urlMatch)}function V(e,t){var o;if(e.urlMatch&&!At(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&&!In(r,e.fingerprint)?null:r}var Ot=/^https:\/\//i,En={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 Cn(e){return!/[;{}<>]/.test(e)}var It=new Map,z=null;function _n(e){return e.replace(/["\\]/g,"\\$&")}function Rn(e){var t;(!z||!z.isConnected)&&(z=e.querySelector("style[data-sentient-ops]"),z||(z=e.createElement("style"),z.setAttribute("data-sentient-ops",""),((t=e.head)!=null?t:e.documentElement).appendChild(z))),z.textContent=[...It.entries()].map(([n,r])=>`[data-snt-e="${_n(n)}"]{${r}}`).join(`
2
+ `)}function Et(e,t,n,r){var l;let o=!1,i=(l=t.moveBefore)!=null?l:t.moveAfter;if(i){let s=V(i,r);!s||s===e||s.parentElement!==e.parentElement||!e.parentElement?o=!0:t.moveBefore?e.parentElement.insertBefore(e,s):e.parentElement.insertBefore(e,s.nextSibling)}typeof t.text=="string"&&(e.textContent=t.text),typeof t.href=="string"&&Ot.test(t.href)&&e.setAttribute("href",t.href),typeof t.imageSrc=="string"&&Ot.test(t.imageSrc)&&e.setAttribute("src",t.imageSrc),typeof t.imageAlt=="string"&&e.setAttribute("alt",t.imageAlt);let a=[];if(t.hidden&&a.push("display:none !important"),t.style)for(let[s,c]of Object.entries(t.style)){let u=En[s];u&&typeof c=="string"&&Cn(c)&&a.push(`${u}:${c.trim()} !important`)}return a.length>0&&(e.setAttribute("data-snt-e",n),It.set(n,a.join(";")),Rn(r)),{anchorMiss:o}}function xe(e,t,n){n.documentElement.setAttribute("data-sentient-persona",e),n.documentElement.setAttribute("data-sentient-confidence",t)}function Oe(e,t,n){var r;for(let[o,i]of Object.entries(t)){let a=e[o];if(!a||typeof a=="string")continue;let l=i.target?Array.from(n.querySelectorAll(i.target)):[n.documentElement];for(let s of l)for(let[c,u]of Object.entries(a))(r=i.dims[c])!=null&&r.includes(u)&&s.setAttribute(`data-${c}`,u)}}function Ie(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 a=o.target?Array.from(n.querySelectorAll(o.target)):[n.documentElement];for(let l of a)l.setAttribute("data-sentient-arm",i)}}function Ee(e,t,n,r){var a;let o=(a=r==null?void 0:r.contentAndOps)!=null?a:!0,i=[];for(let[l,s]of Object.entries(t)){if(xt(s.locator,n))continue;let c;if(s.locator){let g=V(s.locator,n);c=g?[g]:[]}else s.target?c=Array.from(n.querySelectorAll(s.target)):c=[n.documentElement];(s.locator||s.target)&&c.length===0&&i.push(l);let u=e[l];for(let g of c){if(u!==void 0)if(typeof u=="string")g.setAttribute("data-sentient-arm",u);else for(let[S,f]of Object.entries(u))g.setAttribute(`data-${S}`,f);o&&(typeof s.content=="string"&&(g.textContent=s.content),s.ops&&Et(g,s.ops,l,n).anchorMiss&&!i.includes(l)&&i.push(l))}}return i}function Ln(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 Ct(e,t,n){var S;let r=new Set,o=f=>{if(!r.has(f.goalId)){r.add(f.goalId);try{f.slotId?t.componentGoal(f.slotId,f.goalId):t.goal(f.goalId)}catch(v){}}},i=e.filter(f=>f.event==="click"),a=e.filter(f=>f.event==="form_submit"),l=e.filter(f=>f.event==="url_reached"),s=(f,v)=>{if(!f.locator)return!1;let b=V(f.locator,n);return!!b&&(b===v||b.contains(v))},c=f=>{let v=f.target;if(!(!v||typeof v.closest!="function"))for(let b of i)s(b,v)&&o(b)},u=f=>{let v=f.target;if(v)for(let b of a)s(b,v)&&o(b)},g=()=>{if(l.length===0)return;let f=Ln(n);for(let v of l)v.urlPattern&&f.includes(v.urlPattern)&&o(v)};return n.addEventListener("click",c,!0),n.addEventListener("submit",u,!0),(S=n.defaultView)==null||S.addEventListener("popstate",g),g(),{checkUrl:g,teardown:()=>{var f;n.removeEventListener("click",c,!0),n.removeEventListener("submit",u,!0),(f=n.defaultView)==null||f.removeEventListener("popstate",g)}}}var Pt="0.8.0",Pn=5e3,Dn=50,fe=null,L=null,F={},se=null,ne=null,x=null,_t=!1,We=null;function Tn(e,t){return Promise.race([e,new Promise(n=>setTimeout(()=>n(null),t))])}function Ce(e,...t){e!=null&&e.debug&&console.log("[sentient-snippet]",...t)}function _e(e,t){return fe?(fe.personaAttributes&&x&&xe(x.persona,x.band,e),Oe(F,fe.slots,e),Ie(F,fe.slots,e),se?Ee(F,se,e,t):[]):[]}function jn(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 Ve(){try{_e(document)}catch(e){}}function Rt(){We===null&&(We=setTimeout(()=>{We=null,Ve();try{ne==null||ne.checkUrl()}catch(e){}},Dn))}function Lt(){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 a=n.call(this,r,o,i!=null?i:null);return Rt(),a}};e("pushState"),e("replaceState"),window.addEventListener("popstate",Rt)}catch(e){}}}function Je(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 Dt(e){return new URLSearchParams(e).get("sentient_editor")}function Mn(){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 Nn(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 s=document.createElement("meta");s.name="referrer",s.content="no-referrer",((r=document.head)!=null?r:document.documentElement).appendChild(s)}catch(s){}let a=(o=e.editorSrc)!=null?o:Mn();if(!a)return;let l=document.createElement("script");l.src=a,l.async=!0,((i=document.head)!=null?i:document.documentElement).appendChild(l)}catch(a){}}function Tt(e){let t=new URLSearchParams(e).get("sentient_preview");if(!t)return null;let n={};for(let r of t.split("|")){let[o,i]=r.split(":");if(!(!o||!i))if(i.includes("=")){let a={};for(let l of i.split(",")){let[s,c]=l.split("=");s&&c&&(a[s]=c)}Object.keys(a).length&&(n[o]=a)}else n[o]=i}return Object.keys(n).length?n:null}function $n(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{qe(e.apiKey)}catch(n){}},revokeConsent(){try{L==null||L.destroy()}catch(n){}},reapply:Ve,getState(){var n,r;return{apiKey:e.apiKey,persona:(n=x==null?void 0:x.persona)!=null?n:null,band:(r=x==null?void 0:x.band)!=null?r:null,slots:F,matchCounts:Je(e),consent:e.consent!==!1}}};window.SentientSnippet=t}async function jt(){var e,t,n;try{let r=Ae(window.sentient);if(!r)return;fe=r;let o=typeof window!="undefined"?Dt(window.location.search):null;if(o){try{let f=new URL(window.location.href);f.searchParams.delete("sentient_editor"),window.history.replaceState(null,"",f.pathname+f.search+f.hash)}catch(f){}Nn(r,o),Ce(r,"editor mode");return}let i=typeof window!="undefined"?Tt(window.location.search):null;if(i){F=i,x=null,_e(document),Lt(),Ce(r,"preview mode",i);return}let a=(e=r.registry)!=null?e:Object.keys(r.slots).length===0,l=Se(r.apiKey);l&&(x={persona:l.persona,band:l.band},F=l.slots,l.slotConfig&&(se=l.slotConfig),_e(document,{contentAndOps:!1}));let s=ke({apiKey:r.apiKey,context:r.context,consent:r.consent,preConsentBehavior:r.preConsentBehavior,debug:r.debug});L=s,$n(r),Lt();let c=Object.entries(r.slots).map(([f,v])=>({id:f,dims:v.dims})),u=await Tn(s.decide(ge({slots:c,v:Pt},a?{slotsFrom:"registry"}:{})),Pn);if(!u){Ce(r,"decide timeout/null \u2014 snapshot state stands",Je(r));return}let g=s.getPersona();if(g?x={persona:g.persona,band:g.band}:u.persona&&(x={persona:u.persona,band:"low"}),F=u.slots,u.slotConfig&&(se=u.slotConfig),jn(r,_e(document)),u.goals&&u.goals.length>0&&r.consent!==!1&&L)try{ne==null||ne.teardown(),ne=Ct(u.goals,L,document)}catch(f){}let S;try{let f=u.sectionMap;if(f&&f.length>0){let v=new Map;for(let b of f){if(b.urlMatch!==window.location.pathname)continue;let O=V(b.locator,document);O&&v.set(O,b.type)}v.size>0&&(S=b=>{var O;return(O=v.get(b))!=null?O:null})}}catch(f){}if(r.sectionCapture!==!1&&r.consent!==!1&&L&&!te())try{kt(L,ge({apiKey:r.apiKey,apiBase:r.apiBase,doc:document,microSignals:!0},S?{typeOf:S}:{}))}catch(f){}Ce(r,"applied",{persona:x,slots:F,matches:Je(r)}),de(r.apiKey,ge({v:1,persona:(t=x==null?void 0:x.persona)!=null?t:u.persona,band:(n=x==null?void 0:x.band)!=null?n:"low",slots:u.slots,layoutOrder:u.layoutOrder,savedAt:Date.now()},se?{slotConfig:se}:{}))}catch(r){}}typeof window!="undefined"&&window.sentient&&jt();return Kt(Bn);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/snippet",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "private": false,
5
5
  "description": "SentientUI Style-rung snippet for non-React sites — persona attributes and adaptive style tokens from one script tag",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "tsx": "^4.19.2",
17
17
  "typescript": "^5.7.2",
18
18
  "vitest": "^2.1.8",
19
- "@sentientui/core": "0.16.0"
19
+ "@sentientui/core": "0.16.1"
20
20
  },
21
21
  "scripts": {
22
22
  "build": "tsup",