@sentientui/core 0.38.0 → 0.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +43 -1
  2. package/dist/{chunk-NCLBL5V3.mjs → chunk-EVF5PQ4U.mjs} +1 -1
  3. package/dist/{chunk-NCLBL5V3.mjs.map → chunk-EVF5PQ4U.mjs.map} +1 -1
  4. package/dist/chunk-QEIHHO3T.mjs +2 -0
  5. package/dist/chunk-QEIHHO3T.mjs.map +1 -0
  6. package/dist/{index-BdpO3Qlm.d.cts → index-BAfi7_FG.d.cts} +60 -5
  7. package/dist/{index-DzGhQhSK.d.ts → index-DyKtujwf.d.ts} +60 -5
  8. package/dist/index-engagement.js +1 -1
  9. package/dist/index-engagement.js.map +1 -1
  10. package/dist/index-engagement.mjs +1 -1
  11. package/dist/index-graph.d.cts +5 -5
  12. package/dist/index-graph.d.ts +5 -5
  13. package/dist/index-graph.js +1 -1
  14. package/dist/index-graph.js.map +1 -1
  15. package/dist/index-graph.mjs +1 -1
  16. package/dist/index-local.d.cts +3 -3
  17. package/dist/index-local.d.ts +3 -3
  18. package/dist/index-region.d.cts +1 -1
  19. package/dist/index-region.d.ts +1 -1
  20. package/dist/index-region.mjs +1 -1
  21. package/dist/index-server.d.cts +73 -5
  22. package/dist/index-server.d.ts +73 -5
  23. package/dist/index-server.js +1 -1
  24. package/dist/index-server.js.map +1 -1
  25. package/dist/index-server.mjs +1 -1
  26. package/dist/index-server.mjs.map +1 -1
  27. package/dist/index.d.cts +3 -3
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +1 -1
  32. package/dist/{region-skeleton-D2ahkcbe.d.cts → region-skeleton-BRIVB-qf.d.cts} +1 -0
  33. package/dist/{region-skeleton-D2ahkcbe.d.ts → region-skeleton-BRIVB-qf.d.ts} +1 -0
  34. package/dist/{session-meta-CvEwPQCX.d.ts → session-meta-BtRtwsHI.d.ts} +1 -1
  35. package/dist/{session-meta-USVMwvsR.d.cts → session-meta-qx4kIL5y.d.cts} +1 -1
  36. package/package.json +1 -1
  37. package/dist/chunk-VLFWHJNJ.mjs +0 -2
  38. package/dist/chunk-VLFWHJNJ.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{A as Z,B as _,C as $,D as aa,E as ba,F as ca,G as da,H as ea,I as fa,J as ja,K as ka,L as la,M as ma,N as na,O as oa,P as pa,Q as qa,R as ra,a as i,b as j,c as k,d as C,e as D,f as E,g as F,h as G,i as H,j as I,k as J,l as K,m as L,n as M,o as N,p as O,q as P,r as Q,s as R,t as S,u as T,v as U,w as V,x as W,y as X,z as Y}from"./chunk-VLFWHJNJ.mjs";import{a as d,b as e,c as f,d as g,m as h}from"./chunk-XZRKD2GS.mjs";import{a as ga,b as ha,c as ia}from"./chunk-NCLBL5V3.mjs";import{a as l,b as m,c as n,d as o,e as p,f as q,g as r,h as s,i as t,j as u,k as v,l as w,m as x,o as y,p as z,q as A,r as B}from"./chunk-MKM7TD3L.mjs";import{b as a,c as b,e as c}from"./chunk-J5EL7HKC.mjs";import"./chunk-TMCGHANO.mjs";export{o as AGENT_INTENTS,K as BLOCK_ALIGNS,P as BLOCK_EMPHASES,S as BLOCK_FITS,J as BLOCK_GAPS,T as BLOCK_GRID_COLUMNS,U as BLOCK_HEADING_LEVELS,L as BLOCK_JUSTIFIES,X as BLOCK_MAX_WIDTHS,W as BLOCK_PADS,R as BLOCK_RATIOS,M as BLOCK_SIZES,V as BLOCK_SURFACES,Q as BLOCK_TEXT_ALIGNS,O as BLOCK_TONES,N as BLOCK_WEIGHTS,u as CLICK_ID_KEYS,Y as FORM_FIELD_KINDS,Z as FORM_INPUT_TYPES,a as LEGACY_SESSION_COOKIE_NAME,G as LOCAL_MODE_BANNER,da as MAX_BLOCK_ARMS,ca as MAX_BLOCK_CHILDREN,ba as MAX_BLOCK_DEPTH,aa as MAX_BLOCK_NODES,ea as MAX_BLOCK_TEXT_LEN,_ as MAX_FORM_FIELDS,$ as MAX_FORM_SELECT_OPTIONS,ha as MAX_SKELETON_LEAVES,ga as MAX_SKELETON_NODES,ia as MAX_SKELETON_TEXT,H as PAGE_SCOPE_RE,F as PROD_KEYLESS_ERROR,ja as REVEAL_MS,d as SNAPSHOT_STORAGE_KEY_PREFIX,C as STAGE_ATTRIBUTE,na as _registerConsentUpgradeInit,p as agentIntent,l as agentUaList,k as applyNonce,B as armOfResult,ma as attachMicroSignalDetectors,z as baselineResultFor,A as baselineSlots,q as classifiedAgents,fa as containsFormBlock,j as cspNonce,x as deriveSessionSegment,r as detectDeviceClass,w as detectTimeOfDay,s as detectTrafficSource,D as exposedStage,v as extractTrackedParams,c as forgetGeneration,h as forgetVisitor,pa as grantConsent,ra as init,oa as isDoNotTrackEnabled,n as matchedAgentToken,I as pageScopeMatches,e as readSnapshot,t as referrerDomainFromReferer,g as renderPrePaintScript,ka as resetRevealStyles,la as reveal,qa as routeKey,b as sessionCookieName,i as setCspNonce,E as setStageAttribute,y as toWireSlot,m as uaTokenMatch,f as writeSnapshot};
1
+ import{A as Z,B as _,C as $,D as aa,E as ba,F as ca,G as da,H as ea,I as fa,J as ga,K as ha,L as la,M as ma,N as na,O as oa,P as pa,Q as qa,R as ra,S as sa,T as ta,a as i,b as j,c as k,d as C,e as D,f as E,g as F,h as G,i as H,j as I,k as J,l as K,m as L,n as M,o as N,p as O,q as P,r as Q,s as R,t as S,u as T,v as U,w as V,x as W,y as X,z as Y}from"./chunk-QEIHHO3T.mjs";import{a as d,b as e,c as f,d as g,m as h}from"./chunk-XZRKD2GS.mjs";import{a as ia,b as ja,c as ka}from"./chunk-EVF5PQ4U.mjs";import{a as l,b as m,c as n,d as o,e as p,f as q,g as r,h as s,i as t,j as u,k as v,l as w,m as x,o as y,p as z,q as A,r as B}from"./chunk-MKM7TD3L.mjs";import{b as a,c as b,e as c}from"./chunk-J5EL7HKC.mjs";import"./chunk-TMCGHANO.mjs";export{o as AGENT_INTENTS,M as BLOCK_ALIGNS,R as BLOCK_EMPHASES,U as BLOCK_FITS,L as BLOCK_GAPS,V as BLOCK_GRID_COLUMNS,W as BLOCK_HEADING_LEVELS,N as BLOCK_JUSTIFIES,Z as BLOCK_MAX_WIDTHS,Y as BLOCK_PADS,T as BLOCK_RATIOS,O as BLOCK_SIZES,X as BLOCK_SURFACES,S as BLOCK_TEXT_ALIGNS,Q as BLOCK_TONES,P as BLOCK_WEIGHTS,u as CLICK_ID_KEYS,_ as FORM_FIELD_KINDS,$ as FORM_INPUT_TYPES,a as LEGACY_SESSION_COOKIE_NAME,G as LOCAL_MODE_BANNER,fa as MAX_BLOCK_ARMS,ea as MAX_BLOCK_CHILDREN,da as MAX_BLOCK_DEPTH,ca as MAX_BLOCK_NODES,ga as MAX_BLOCK_TEXT_LEN,aa as MAX_FORM_FIELDS,ba as MAX_FORM_SELECT_OPTIONS,ja as MAX_SKELETON_LEAVES,ia as MAX_SKELETON_NODES,ka as MAX_SKELETON_TEXT,H as PAGE_SCOPE_RE,F as PROD_KEYLESS_ERROR,la as REVEAL_MS,d as SNAPSHOT_STORAGE_KEY_PREFIX,C as STAGE_ATTRIBUTE,pa as _registerConsentUpgradeInit,p as agentIntent,l as agentUaList,k as applyNonce,B as armOfResult,oa as attachMicroSignalDetectors,z as baselineResultFor,A as baselineSlots,q as classifiedAgents,ha as containsFormBlock,j as cspNonce,x as deriveSessionSegment,r as detectDeviceClass,w as detectTimeOfDay,s as detectTrafficSource,D as exposedStage,v as extractTrackedParams,c as forgetGeneration,h as forgetVisitor,ra as grantConsent,ta as init,qa as isDoNotTrackEnabled,n as matchedAgentToken,K as normalizeUrlPattern,I as pageScopeMatches,e as readSnapshot,t as referrerDomainFromReferer,g as renderPrePaintScript,ma as resetRevealStyles,na as reveal,sa as routeKey,b as sessionCookieName,i as setCspNonce,E as setStageAttribute,y as toWireSlot,m as uaTokenMatch,J as urlMatches,f as writeSnapshot};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -49,6 +49,7 @@ type RenderCaps = {
49
49
  compose: boolean;
50
50
  authored?: string[];
51
51
  content?: boolean;
52
+ ops?: boolean;
52
53
  children?: boolean;
53
54
  };
54
55
  /** How the server serves an `edits` arm (SlotConfigEntry.edits). */
@@ -49,6 +49,7 @@ type RenderCaps = {
49
49
  compose: boolean;
50
50
  authored?: string[];
51
51
  content?: boolean;
52
+ ops?: boolean;
52
53
  children?: boolean;
53
54
  };
54
55
  /** How the server serves an `edits` arm (SlotConfigEntry.edits). */
@@ -1,6 +1,6 @@
1
1
  import { SlotResult, SlotDecl } from '@sentientui/policy';
2
2
  import { v as BlockNode, F as ComposeArm, $ as SitePalette, a4 as StyleVocabulary } from './style-vocabulary-Ba_g6_DD.js';
3
- import { S as ServedEdits } from './region-skeleton-D2ahkcbe.js';
3
+ import { S as ServedEdits } from './region-skeleton-BRIVB-qf.js';
4
4
 
5
5
  /**
6
6
  * Slot declaration helpers shared by the browser client (decide) and the
@@ -1,6 +1,6 @@
1
1
  import { SlotResult, SlotDecl } from '@sentientui/policy';
2
2
  import { v as BlockNode, F as ComposeArm, $ as SitePalette, a4 as StyleVocabulary } from './style-vocabulary-Ba_g6_DD.cjs';
3
- import { S as ServedEdits } from './region-skeleton-D2ahkcbe.cjs';
3
+ import { S as ServedEdits } from './region-skeleton-BRIVB-qf.cjs';
4
4
 
5
5
  /**
6
6
  * Slot declaration helpers shared by the browser client (decide) and the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/core",
3
- "version": "0.38.0",
3
+ "version": "0.39.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,2 +0,0 @@
1
- import{a as Ne,b as fe,c as me,e as ce,f as Ge,g as $e,h as Lt,i as Bt,j as Pt,k as Mt,l as Kt,m as Ue}from"./chunk-XZRKD2GS.mjs";import{b as je,g as Fe,h as We,i as Ve,k as He,l as ze,o as qe,p as xe,r as Je}from"./chunk-MKM7TD3L.mjs";import{a as le,c as Ke,d as Dt,e as ve}from"./chunk-J5EL7HKC.mjs";import{a as I,b as ne}from"./chunk-TMCGHANO.mjs";var Xe;function Ye(e){Xe=typeof e=="string"&&e!==""?e:void 0}function Nt(e=document){if(Xe)return Xe;try{let n=e.querySelector("script[nonce]");return(n==null?void 0:n.nonce)||(n==null?void 0:n.getAttribute("nonce"))||void 0}catch(n){return}}function Qe(e,n=document){let c=Nt(n);return c&&e.setAttribute("nonce",c),e}function we(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let n="";for(let c=0;c<16;c++)n+=e[c].toString(16).padStart(2,"0"),(c===3||c===5||c===7||c===9)&&(n+="-");return n}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let n=Math.random()*16|0;return(e==="x"?n:n&3|8).toString(16)})}var Gt="_snt_uid",rn=365,de="_snt_uid";function an(){return we()}function Ze(e){try{let n=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return n?decodeURIComponent(n[1]):null}catch(n){return null}}function tt(){try{return location.protocol==="https:"?"; Secure":""}catch(e){return""}}function ln(e,n,c){try{document.cookie=`${e}=${encodeURIComponent(n)}; max-age=${c}; SameSite=lax; path=/${tt()}`}catch(y){}}function Ee(e){try{return localStorage.getItem(e)}catch(n){return null}}function $t(e,n){try{return localStorage.setItem(e,n),!0}catch(c){return!1}}function et(e){try{return sessionStorage.getItem(e)}catch(n){return null}}function cn(e,n){try{return sessionStorage.setItem(e,n),!0}catch(c){return!1}}function dn(e){try{sessionStorage.removeItem(e)}catch(n){}}function un(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=lax; path=/${tt()}`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(n){return!1}}function pn(e){try{localStorage.removeItem(e)}catch(n){}}function gn(e){try{document.cookie=`${e}=; max-age=0; SameSite=lax; path=/${tt()}`}catch(n){}}var fn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ce(e){var R,L,Z,V,ee,ie,oe;if(typeof window=="undefined")return fn;let n=le(e==null?void 0:e.apiKey),c=(R=e==null?void 0:e.cookieName)!=null?R:Ke(e==null?void 0:e.apiKey),y=`${de}${n}`,x=`${de}_tomb${n}`,C=((L=e==null?void 0:e.cookieTTLDays)!=null?L:rn)*24*60*60,o=P=>P&&P.length>0?P:null,g=()=>{var P,se;return n&&!(e!=null&&e.cookieName)&&Ee(x)===null?(se=(P=o(Ze(Gt)))!=null?P:o(Ee(de)))!=null?se:o(et(de)):null},a=(oe=(ie=(ee=(V=(Z=o(Ze(c)))!=null?Z:o(Ee(y)))!=null?V:o(et(y)))!=null?ee:g())!=null?ie:o(e==null?void 0:e.ssrSessionId))!=null?oe:an();ln(c,a,C);let i=$t(y,a),r=un(c),k=i?!1:cn(y,a),A=!i&&!r&&!k;return{getSessionId:()=>a,isEphemeral:()=>A,destroy:()=>{a=null,gn(c),pn(y),dn(y),n&&!(e!=null&&e.cookieName)&&(Ze(Gt)!==null||Ee(de)!==null||et(de)!==null)&&$t(x,"1")}}}var mn=1800*1e3;function Ie(e,n){return`${encodeURIComponent(e)}:${encodeURIComponent(n)}`}function Ut(e=mn,n){let c=new Map,y=`_snt_asgn${le(n)}_`,x=(a,i)=>`${y}${encodeURIComponent(a)}:${encodeURIComponent(i)}`,m=a=>{let i=a.slice(y.length),r=i.indexOf(":");if(r<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,r)),segment:decodeURIComponent(i.slice(r+1))}}catch(k){return null}},C=()=>{try{let a=[];for(let i=0;i<localStorage.length;i++){let r=localStorage.key(i);r!=null&&r.startsWith(y)&&a.push(r)}return a}catch(a){return[]}},o=a=>a.assignedAt+(a.ttlMs&&a.ttlMs>0?a.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let a of C())try{let i=localStorage.getItem(a);if(!i)continue;let r=JSON.parse(i);if(o(r)){localStorage.removeItem(a);continue}let k=m(a);if(!k)continue;c.set(Ie(k.componentId,k.segment),r)}catch(i){}})(),{get(a,i){let r=c.get(Ie(a,i));return r?o(r)?(c.delete(Ie(a,i)),null):r:null},set(a,i,r){let k=Ie(a,i);c.set(k,r);try{localStorage.setItem(x(a,i),JSON.stringify(r))}catch(A){}},clear(){c.clear();for(let a of C())try{localStorage.removeItem(a)}catch(i){}}}}import{STAGE_KEYS as yn}from"@sentientui/policy";var nt="data-sentient-stage";function ot(e,n){return!n||typeof e!="string"||!(e==="returning"||yn.includes(e))?null:n!=="detailed"&&(e==="customer"||e==="lapsed")?"returning":e}function st(e,n=document){try{e?n.documentElement.setAttribute(nt,e):n.documentElement.removeAttribute(nt)}catch(c){}}import{confidenceBand as Jt}from"@sentientui/policy";import{confidenceBand as rt}from"@sentientui/policy";var it="[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.",jt=!1,_e=!1;function Sn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(n){return}}function Wt(e){var a;let n=Ce({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),c=(a=n.getSessionId())!=null?a:"local",y=Sn(),x=import("@sentientui/core/local").then(i=>{let r=i;return r.LOCAL_ENGINE_AVAILABLE?(jt||(jt=!0,console.info(Ft)),r):(_e||(_e=!0,console.error(it)),null)}).catch(()=>(_e||(_e=!0,console.error(it)),null)),m=null,C={low:.15,medium:.5,high:.85},o=(()=>{var r;if(e.initialPersona)return I({},e.initialPersona);let i=fe(e.apiKey||"local");return i?{persona:i.persona,confidence:(r=C[i.band])!=null?r:.15}:null})();function g(i){let r=document.documentElement;r.dataset.sentientPersona===void 0&&(r.dataset.sentientPersona=i.persona,r.dataset.sentientConfidence=rt(i.confidence))}return{isLocal:!0,async decide(i){var A,R,L;let r=await x;if(!r)return null;let k=r.createLocalEngine({sessionId:c,forcedPersona:y}).decide(i);return m=ne(I({},k),{layoutOrder:(R=(A=k.layoutOrder)!=null?A:m==null?void 0:m.layoutOrder)!=null?R:null,slots:I(I({},(L=m==null?void 0:m.slots)!=null?L:{}),k.slots)}),me(e.apiKey||"local",{v:1,persona:m.persona,band:rt(m.confidence),slots:m.slots,layoutOrder:m.layoutOrder,savedAt:Date.now()}),g(k),k},getSlotResult(i){var r,k,A;return(A=(k=m==null?void 0:m.slots[i])!=null?k:(r=e.initialSlots)==null?void 0:r[i])!=null?A:null},getSlotConfig(i){var r,k;return(k=(r=e.initialSlotConfig)==null?void 0:r[i])!=null?k:null},getSitePalette(){var i;return(i=e.initialPalette)!=null?i:null},reportSlots(){},getPersona(){let i=m!=null?m:o;return i?{persona:i.persona,confidence:i.confidence,band:rt(i.confidence)}:null},async assign(i,r){var R;let k=await x;return!k||!r||r.length===0?r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null:{variantId:(R=k.createLocalEngine({sessionId:c,forcedPersona:y}).decide({components:[{id:i,variantIds:r}]}).assignments[i])!=null?R:r[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var Vt=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function at(e){let n=e.split(/[?#]/)[0]||"/";return n.length>1?n.replace(/\/+$/,"")||"/":n}function hn(e,n){if(e===void 0||!Vt.test(e))return!1;if(e==="*")return!0;let c=at(n);if(e.endsWith("/*")){let y=at(e.slice(0,-2));return c.startsWith(y==="/"?"/":`${y}/`)&&c!==y}return c===at(e)}var zn=["none","sm","md","lg"],qn=["start","center","end","stretch"],Jn=["start","center","end","between"],Xn=["sm","md","lg"],Yn=["normal","medium","bold"],Qn=["default","muted","accent"],Zn=["primary","secondary","ghost"],eo=["left","center","right"],to=["auto","square","landscape","wide"],no=["cover","contain"],oo=[2,3,4],so=[1,2,3,4],ro=["default","raised"],io=["none","sm","md","lg"],ao=["measure"],lo=["input","textarea","select"],co=["text","email","number","tel"],uo=5,po=8,go=64,fo=5,mo=12,yo=4,So=500;function kn(e){if(e==null||typeof e!="object"||Array.isArray(e))return!1;let n=e;return n.type==="form"?!0:Array.isArray(n.children)?n.children.some(kn):!1}var lt="sentient-reveal",ue="sentient-revealed",Ht=240,Re=!1;function bn(){var e;Re=!1,typeof document!="undefined"&&((e=document.getElementById(lt))==null||e.remove())}function vn(e){if(Re||e.getElementById(lt)){Re=!0;return}let n=Qe(e.createElement("style"),e);n.id=lt,n.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${ue}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${ue}{animation:${ue} ${Ht}ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(n),Re=!0}function xn(e,n={}){var x;let c=(x=n.doc)!=null?x:typeof document!="undefined"?document:void 0;if(!c||!(e instanceof Element)||(n.arm!==void 0&&e.setAttribute("data-sentient-arm",n.arm),n.persona!==void 0&&e.setAttribute("data-sentient-persona",n.persona),n.previous!==void 0&&n.previous===e.textContent))return!1;vn(c),e.classList.remove(ue),e.offsetWidth,e.classList.add(ue);let y=()=>{e.classList.remove(ue),e.removeEventListener("animationend",y)};return e.addEventListener("animationend",y),!0}function wn(e,n,c,y){let x=[];{let o=!1,g=[],a=()=>{if(o)return;let i=Date.now();for(g.push(i);g.length>0&&i-g[0]>500;)g.shift();g.length>=3&&(o=!0,e("rage_click"))};n.addEventListener("click",a),x.push(()=>n.removeEventListener("click",a))}{let m=!1,C=o=>{if(m||!(o.target instanceof Node)||!n.contains(o.target)&&n!==o.target)return;m=!0;let g=typeof window!="undefined"?window.getSelection():null,a=g?g.toString().length:0;e("text_copy",{selectionLength:a})};document.addEventListener("copy",C),x.push(()=>document.removeEventListener("copy",C))}{let m=!1,C=!1,o=null,g=()=>{o!==null&&(clearTimeout(o),o=null)},a=()=>{m||!C||(g(),o=setTimeout(()=>{!m&&C&&(m=!0,e("scroll_hesitation"))},3e3))},i=()=>{g(),a()},r=A=>{for(let R of A)C=R.intersectionRatio>.3,C?a():g()},k=new IntersectionObserver(r,{threshold:[.3]});k.observe(n),window.addEventListener("scroll",i,{passive:!0}),x.push(()=>{k.disconnect(),window.removeEventListener("scroll",i),g()})}if((y==null?void 0:y.tabLoss)!==!1){let m=!1,C=c!=null?c:Date.now(),o=()=>{if(m||document.visibilityState!=="hidden")return;let g=Date.now()-C;g<15e3&&(m=!0,e("tab_loss",{timeOnPage:g}))};document.addEventListener("visibilitychange",o),x.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let m of x)m()}}function En(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Yt="https://api.sentient-ui.com/v1/events",j=new Map,Qt=null;function qo(e,n){let c=j.get(e);c&&c.upgrade&&(c.reinit=n)}function Cn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var In=3;function ct(){return we()}function Te(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function _n(){let e=new WeakMap,n=new Map,c=!1,y=(o,g,a)=>{let i=o.get(g);return a===null?i?!0:(o.set(g,new Set),!1):i?i.has(a)?!0:(i.add(a),!1):(o.set(g,new Set([a])),!1)},x=typeof window!="undefined"&&"event"in window,m=()=>{if(!x)return;let o=window.event;return typeof Event=="function"&&o instanceof Event?o:void 0},C=()=>{if(x){Promise.resolve().then(()=>{c=!1,n.clear()});return}let o=!1,g=()=>{o||(o=!0,c=!1,n.clear())};if(setTimeout(g,0),typeof MessageChannel=="function"){let a=new MessageChannel;a.port1.onmessage=()=>{a.port1.close(),a.port2.close(),g()},a.port2.postMessage(0)}};return{firedBefore(o,g){let a=m();if(a){let r=e.get(a);return r||(r=new Map,e.set(a,r)),y(r,o,g)}let i=y(n,o,g);return!i&&!c&&(c=!0,C()),i}}}var Zt=new Set;function Rn(e,n,c){let y=typeof window=="undefined"?null:window.history;if(!y)return()=>{};let x=!1,m,C=()=>{if(x)return;let a=Te();!a||a===m||(m=a,e.track({projectId:n,componentId:"__page__",eventType:"pageview",payload:{}}),c(`${n}:${a}`))},o=[];for(let a of["pushState","replaceState"]){let i=y[a],r=function(...k){let A=i.apply(this,k);return C(),A};y[a]=r,o.push([a,i,r])}window.addEventListener("popstate",C);let g=Te();return g&&Zt.has(`${n}:${g}`)?m=g:C(),()=>{if(!x){x=!0,window.removeEventListener("popstate",C);for(let[a,i,r]of o)y[a]===r&&(y[a]=i)}}}var ye={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}};function Tn(){try{return He(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function en(e){return e.replace(/\/events\/?$/,"")}function tn(){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(n=>n==="1"||n==="yes")}function Jo(e){var g;if(typeof window=="undefined")return;let n=e!=null?e:Qt;if(!n){console.warn("[sentient] grantConsent() called before init()");return}let c=j.get(n);if(!c){console.warn("[sentient] grantConsent() called before init()");return}let{config:y,upgrade:x,reinit:m}=c;if(!x){c.upgradeBlockedReason&&console.warn(c.upgradeBlockedReason);return}if(y.respectDoNotTrack!==!1&&tn())return;let C=(m!=null?m:On)(ne(I({},y),{consent:!0}));x(C);let o=(g=j.get(n))==null?void 0:g.dispose;j.set(n,{config:ne(I({},y),{consent:!0}),upgrade:null,dispose:o})}function An(e,n){var se;let c=e.preConsentBehavior==="statistical_winner",y=en((se=e.ingestUrl)!=null?se:Yt),x={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},m=new Map,C=new Map,o={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(l,d,w){if(!c)return Promise.resolve(null);let _=m.get(l);return _?Promise.resolve(_):ut(C,l,async()=>{try{let B=new URLSearchParams({componentId:l});for(let Q of d!=null?d:[])B.append("variantIds[]",Q);let N=ce(5e3),O;try{let Q=await fetch(`${y}/winner?${B.toString()}`,{headers:x,signal:N.signal});if(!Q.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;O=await Q.json()}finally{N.clear()}let z={variantId:O.variantId,assignmentTtlMs:0};return m.set(l,z),z}catch(B){return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null}})},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getSlotConfig:()=>null,getSitePalette:()=>null,reportSlots:()=>{},getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>{}},g=!1,a=new Set,i=[],r=[],k=[],A=()=>{for(let[,,l]of k.splice(0))l(null);R.length=0},R=[],L=!1,Z=()=>{if(g)return;L=!0;let l=j.get(e.apiKey);(l==null?void 0:l.upgrade)===P&&j.set(e.apiKey,{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): client released before consent; call init() again"})},V=[],ee=()=>{setTimeout(()=>{var l;try{(l=V.shift())==null||l(o)}catch(d){}V.length&&ee()})},ie=l=>{g?V.length?V.push(l):l(o):!n&&!L&&R.length<100?R.push(l):L&&e.debug&&console.warn("[sentient] goal dropped: client released")},oe={get gated(){return!g&&!n},get released(){return L&&!g},takeHeld:()=>R.splice(0),track:l=>o.track(l),goal:((l,d,w,_)=>ie(B=>B.goal(l,d,w,_))),componentGoal:(l,d,w)=>o.componentGoal(l,d,w),identify:l=>o.identify(l),getAssignment:(l,d)=>o.getAssignment(l,d),assign:(l,d,w,_)=>o.assign(l,d,w,_),decide:l=>g?o.decide(l):L||n?Promise.resolve(null):new Promise(d=>k.push([l,Xt(),d])),getSlotResult:l=>o.getSlotResult(l),isSlotDecided:l=>{var d,w;return(w=(d=o.isSlotDecided)==null?void 0:d.call(o,l))!=null?w:!0},getSlotConfig:l=>o.getSlotConfig(l),getSitePalette:()=>o.getSitePalette(),getStyleVocabulary:()=>{var l,d;return(d=(l=o.getStyleVocabulary)==null?void 0:l.call(o))!=null?d:null},reportSlots:(l,d,w,_)=>o.reportSlots(l,d,w,_),reportSkeleton:(l,d)=>{var w;return(w=o.reportSkeleton)==null?void 0:w.call(o,l,d)},reportDrift:(l,d,w,_)=>{var B;return(B=o.reportDrift)==null?void 0:B.call(o,l,d,w,_)},requestSlots:(l,d,w)=>{var _;return g?(_=o.requestSlots)==null?void 0:_.call(o,l,d,w):i.push([l,d,w])},decideSlots:l=>{var d;return g?(d=o.decideSlots)==null?void 0:d.call(o,l):r.push(...l)},cancelSlots:l=>{var w;if(g)return(w=o.cancelSlots)==null?void 0:w.call(o,l);let d=new Set(l);for(let _ of i)_[0]=_[0].filter(B=>!d.has(B));r=r.filter(_=>!d.has(_.id))},onSlotsChanged:l=>(a.add(l),()=>{a.delete(l)}),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),flush:()=>o.flush(),dispose:()=>(Z(),A(),o.dispose()),destroy:()=>(Z(),A(),g?o.destroy():Ue(e.apiKey))};function P(l){var w,_,B;o=l,g=!0,R.length&&(V.push(...R.splice(0)),ee());let d=Xt();for(let[N,O,z]of k.splice(0))O!==d?z(null):l.decide(N).then(z,()=>z(null));(w=l.onSlotsChanged)==null||w.call(l,()=>a.forEach(N=>N()));for(let[N,O,z]of i.splice(0))N.length>0&&((_=l.requestSlots)==null||_.call(l,N,O,z));r.length>0&&((B=l.decideSlots)==null||B.call(l,r.splice(0)))}return{proxy:oe,setInner:P}}function Xt(){return typeof location=="undefined"?"":location.pathname+(/^#!?\//.test(location.hash)?location.hash:"")}function ut(e,n,c){let y=e.get(n);if(y)return y;let x=(async()=>{try{return await c()}finally{e.delete(n)}})();return e.set(n,x),x}function On(e){var bt,vt,xt,wt,Et,Ct,It,_t,Rt,Tt;if(typeof window=="undefined")return ye;e.nonce&&Ye(e.nonce),Qt=e.apiKey||"local";let n=j.get(e.apiKey||"local");if(n!=null&&n.dispose)try{n.dispose()}catch(t){}let c=e.respectDoNotTrack!==!1&&tn(),y=e.consent===!1||c,x=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!x&&e.localMode!==!1)return j.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),y?ye:Wt(e);if(y){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),j.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),ye;let{proxy:t,setInner:s}=An(e,c);return j.set(e.apiKey,{config:e,upgrade:c?null:s}),t}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."),ye;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),ye;let m=(bt=e.ingestUrl)!=null?bt:Yt,C=Date.now(),o=Ce({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),g=Ut(void 0,e.apiKey),a=!1,i=ve(e.apiKey),r=()=>!a&&ve(e.apiKey)===i,k=ne(I({},g),{set:(...t)=>{r()&&g.set(...t)}}),A=Pt({ingestUrl:m,apiKey:e.apiKey}),R=en(m),L={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},Z=new Set,V=Kt({url:`${R}/goals`,apiKey:e.apiKey,headers:L,onDrop:(t,s)=>{if(!e.debug){if(Z.has(s))return;Z.add(s)}console.warn(`[sentient] goal dropped (HTTP ${s}) \u2014 this will not be retried. `+(s===400?"The session was not found: call init() and let the session upsert complete before firing goals.":s===401||s===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),t)}}),ee=Fe((vt=navigator.userAgent)!=null?vt:""),ie=window.location.origin,oe=We((xt=document.referrer)!=null?xt:"",ie),P=(wt=e.sessionSegment)!=null?wt:`${ee}:${oe}`,se=new Map,l=new Map,d=new Map,w=new Set,_=new Map,B=null,N=null,O=null,z=new Set,Q=new Set,Ae=new Map,Oe=new Map,pt=new Set,gt=new Set,ft=new Set,De=null,Se=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,mt=new Set,he=new Set,ke=new Set,pe=new Map,Le=null,be=new Set,ge=new Map,Be=null,nn=2,yt=new Map,q=!1,St=(t,s,p)=>{var u;let b=new Set,v=1;for(let f of t){s.delete(f);let S=((u=yt.get(f))!=null?u:0)+1;yt.set(f,S),S<=nn&&(b.add(f),S>v&&(v=S))}b.size>0&&setTimeout(()=>{q||p(b)},$e(v))},Pe=t=>{for(let s of t)d.has(s.id)||d.set(s.id,xe(s))};if(e.initialSlots)for(let[t,s]of Object.entries(e.initialSlots))d.set(t,s),w.add(t);if(e.initialSlotConfig)for(let[t,s]of Object.entries(e.initialSlotConfig))_.set(t,s);e.initialPalette&&(B=e.initialPalette),e.initialVocabulary&&(N=e.initialVocabulary);let J=fe(e.apiKey);if(J){for(let[t,s]of Object.entries(J.slots))d.has(t)||d.set(t,s);for(let[t,s]of Object.entries((Et=J.slotConfig)!=null?Et:{}))_.has(t)||_.set(t,s);!B&&J.palette&&(B=J.palette),!N&&J.vocabulary&&(N=J.vocabulary)}let ht={low:.15,medium:.5,high:.85};if(e.initialPersona)O=I({},e.initialPersona);else{let t=document.documentElement.dataset;t.sentientPersona?O={persona:t.sentientPersona,confidence:(It=ht[(Ct=t.sentientConfidence)!=null?Ct:"low"])!=null?It:.15}:J&&(O={persona:J.persona,confidence:(_t=ht[J.band])!=null?_t:.15})}if(e.initialAssignments)for(let[t,s]of Object.entries(e.initialAssignments))k.set(t,P,{variantId:s,assignedAt:Date.now(),segment:P,confidence:1});let te=Promise.resolve(),kt=o.getSessionId();if(kt){let t=Ve((Rt=document.referrer)!=null?Rt:""),{utmParams:s,clickIds:p}=Tn(),b=I(I(I(I({sessionId:kt,deviceClass:ee,trafficSource:oe,referrerDomain:t,utmParams:s,clickIds:p,landingPath:typeof location!="undefined"?location.pathname:void 0,timeOfDay:ze(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||je((Tt=navigator.userAgent)!=null?Tt:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),v=async()=>{for(let u=0;;u++){if(q||!r())return;let f=ce(5e3);try{let S=await fetch(`${R}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(b),headers:L,signal:f.signal});if(S.status===402){console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing");return}if(S.ok||Lt(S)==="dropped")return}catch(S){}finally{f.clear()}if(u>=In){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(S=>setTimeout(S,$e(u+1)))}};try{te=v()}catch(u){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:A});let on=_n(),re=null,Me=!1,M={goal(t,s={},p=1,b=0){var $,K,F,H,W,U,h;let v=o.getSessionId();if(!v||q||!r())return;let u=Cn(s)?s:{metadata:s},f=[t,($=u.externalId)!=null?$:"",(K=u.stepIndex)!=null?K:b,(F=u.weight)!=null?F:p].join("\0"),S=u.value!==void 0?`${u.value}\0${(H=u.currency)!=null?H:""}`:null;if(on.firedBefore(f,S)){e.debug&&console.log(`[sentient] goal("${t}") already recorded for this action \u2014 not sent twice`);return}let T=ct(),E={sessionId:v,name:t,metadata:(W=u.metadata)!=null?W:{},weight:(U=u.weight)!=null?U:p,stepIndex:(h=u.stepIndex)!=null?h:b,goalId:T,value:u.value,currency:u.currency,externalId:u.externalId};e.debug&&console.log("[sentient] goal",E);let G={id:T,body:JSON.stringify(E)};te.then(()=>V.send(G))},componentGoal(t,s,p){var T,E,G;let b=o.getSessionId();if(!b||q||!r())return;let v=k.get(t,P),u=v?null:(T=d.get(t))!=null?T:null;if(!v&&u===null){e.debug&&console.warn(`[sentient] componentGoal("${t}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}if(!v&&!w.has(t)){e.debug&&console.warn(`[sentient] componentGoal("${t}"): slot not decided this session \u2014 not attributed`);return}let f=v?v.variantId:Je(u),S={id:ct(),sessionId:b,projectId:e.apiKey,componentId:t,variantId:f,eventType:"goal_achieved",goalType:s,payload:I({reward:(E=p==null?void 0:p.reward)!=null?E:1,goalValue:p==null?void 0:p.value,currency:p==null?void 0:p.currency},(G=p==null?void 0:p.metadata)!=null?G:{}),timestamp:Date.now(),timeInSession:Date.now()-C,path:Te()};e.debug&&console.log("[sentient] componentGoal",S),te.then(()=>{!q&&r()&&A.push(S)})},identify(t){let s=o.getSessionId();!s||q||!r()||te.then(()=>{fetch(`${R}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:s,userId:t,ephemeral:o.isEphemeral()}),headers:L}).catch(()=>{})})},track(t){let s=o.getSessionId();if(!s||q||!r()||t.eventType==="variant_assigned"&&d.get(t.componentId)!==void 0&&!w.has(t.componentId)&&!k.get(t.componentId,P))return;let p=ne(I({path:Te()},t),{id:ct(),sessionId:s,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",p),te.then(()=>A.push(p))},getAssignment(t,s){return k.get(t,s)},async assign(t,s,p,b){let v=o.getSessionId();if(!v)return null;let u=k.get(t,P);if(u&&(s!=null&&s.length||u.content!==void 0)){let f=u.ttlMs&&u.ttlMs>0?Math.max(0,u.assignedAt+u.ttlMs-Date.now()):0;return{variantId:u.variantId,assignmentTtlMs:f,content:u.content}}return ut(se,t,async()=>{if(!await Ge(te,2500)||q||!r())return null;let f=ce(3e4);try{let S={sessionId:v,componentId:t,variantIds:s};b!==void 0?S.agentDataByVariant=b:p!==void 0&&(S.agentData=p);let T=await fetch(`${R}/assign`,{method:"POST",body:JSON.stringify(S),headers:L,signal:f.signal});if(!T.ok)return null;let E=await T.json();return k.set(t,P,I({variantId:E.variantId,assignedAt:Date.now(),segment:P,confidence:1,content:E.content},E.assignmentTtlMs&&E.assignmentTtlMs>0?{ttlMs:E.assignmentTtlMs}:{})),E}catch(S){return null}finally{f.clear()}})},async decide(t){var u,f;let s=o.getSessionId();if(!s)return null;let p=(u=t.slots)!=null?u:[],b={sessionId:s};t.sections&&t.sections.length>0&&(b.sections=t.sections.map(S=>({id:S}))),b.components=(f=t.components)!=null?f:[],p.length>0&&(b.slots=p.map(qe)),t.slotsFrom==="registry"&&(b.slotsFrom="registry",t.registrySlotIds&&(b.registrySlotIds=t.registrySlotIds),t.bootstrap===!1&&(b.bootstrap=!1),t.render&&Object.keys(t.render).length>0&&(b.render=t.render)),t.v&&(b.v=t.v),typeof t.pp=="number"&&(b.pp=t.pp),e.persona&&(b.persona=e.persona);let v=JSON.stringify(b);return ut(l,v,async()=>{var T,E,G,$,K,F,H,W;if(!await Ge(te,2500)||q||!r())return Pe(p),null;let S=ce(3e4);try{let U=await fetch(`${R}/decide`,{method:"POST",body:v,headers:L,signal:S.signal});if(!U.ok)return Pe(p),null;let h=await U.json(),X=ot(h.stage,e.stageAttributes);e.stageAttributes&&st(X);let ae={};for(let D of p){let Y=(T=h.slots)==null?void 0:T[D.id];if(Y!==void 0){ae[D.id]=Y,d.set(D.id,Y),w.add(D.id);continue}let At=d.get(D.id);if(At!==void 0)ae[D.id]=At;else{let Ot=xe(D);ae[D.id]=Ot,d.set(D.id,Ot)}}if(h.slots)for(let[D,Y]of Object.entries(h.slots))D in ae||(ae[D]=Y,d.set(D,Y),w.add(D));let sn=O!=null&&O.persona!=="unknown";h.persona&&!(h.persona==="unknown"&&sn)?O={persona:h.persona,confidence:(E=h.confidence)!=null?E:0}:O||(O={persona:"unknown",confidence:0});for(let[D,Y]of Object.entries((G=h.assignments)!=null?G:{}))k.set(D,P,{variantId:Y,assignedAt:Date.now(),segment:P,confidence:1});if(h.slotConfig)for(let[D,Y]of Object.entries(h.slotConfig))_.set(D,Y);h.palette&&(B=h.palette),h.vocabulary&&(N=h.vocabulary);for(let D of($=t.registrySlotIds)!=null?$:[])(K=h.slotConfig)!=null&&K[D]||(_.delete(D),d.delete(D),w.delete(D));return r()&&me(e.apiKey,I(I(I(I({v:1,persona:O.persona,band:Jt(O.confidence),slots:Object.fromEntries(d),layoutOrder:(F=h.layoutOrder)!=null?F:null,savedAt:Date.now()},_.size>0?{slotConfig:Object.fromEntries(_)}:{}),B?{palette:B}:{}),N?{vocabulary:N}:{}),X?{stage:X}:{})),I(I(I(I(I(I(I({layoutOrder:(H=h.layoutOrder)!=null?H:null,assignments:(W=h.assignments)!=null?W:{},slots:ae,persona:O.persona,confidence:O.confidence},h.slotConfig?{slotConfig:h.slotConfig}:{}),h.goals?{goals:h.goals}:{}),h.sectionMap?{sectionMap:h.sectionMap}:{}),h.palette?{palette:h.palette}:{}),h.vocabulary?{vocabulary:h.vocabulary}:{}),h.stage?{stage:h.stage}:{}),h.context?{context:h.context}:{})}catch(U){return Pe(p),null}finally{S.clear()}})},getSlotResult(t){var s;return(s=d.get(t))!=null?s:null},isSlotDecided(t){return w.has(t)},getSlotConfig(t){var s;return(s=_.get(t))!=null?s:null},reportSlots(t,s,p,b){var u;let v={};for(let[f,S]of Object.entries(b!=null?b:{}))for(let T of S){let E=`${f}|${T.key}`;!Se.test(f)||ft.has(E)||(ft.add(E),((u=v[f])!=null?u:v[f]=[]).push(T))}Object.keys(v).length>0&&fetch(`${R}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:Object.keys(v),authoredArms:v})}).catch(()=>{});for(let f of t)if(!(typeof f!="string"||f.length===0)){if(!Se.test(f)){En()&&!mt.has(f)&&(mt.add(f),console.warn(`[sentient] reportSlots: slot id ${JSON.stringify(f)} will not register \u2014 ids must start with a letter or digit and contain only letters, digits, '_' or '-' (max 128 chars): /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.`));continue}if(!z.has(f)){z.add(f),Q.add(f);let S=s==null?void 0:s[f];if(typeof S=="string"){let E=S.replace(/\s+/g," ").trim().slice(0,400);E!==""&&Ae.set(f,E)}let T=p==null?void 0:p[f];T!==void 0&&Oe.set(f,T)}}Q.size===0||De!=null||(De=setTimeout(()=>{De=null;let f=[...Q];Q.clear();for(let S=0;S<f.length;S+=20){let T=f.slice(S,S+20),E={},G={};for(let $ of T){let K=Ae.get($);K!==void 0&&(E[$]=K,Ae.delete($));let F=Oe.get($);F!==void 0&&(G[$]=F,Oe.delete($))}fetch(`${R}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify(I(ne(I(I({slotIds:T},Object.keys(E).length>0?{baselineTexts:E}:{}),Object.keys(G).length>0?{baselineSkeletons:G}:{}),{pagePaths:Object.fromEntries(T.map($=>[$,location.pathname]))}),Object.keys(E).length>0&&o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{})}},1e3))},reportSkeleton(t,s){!Se.test(t)||pt.has(t)||(pt.add(t),fetch(`${R}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:[t],baselineSkeletons:{[t]:s}})}).catch(()=>{}))},reportDrift(t,s,p,b){let v=`${t}|${s}`,u=o.getSessionId();!u||gt.has(v)||(gt.add(v),fetch(`${R}/slots/drift`,{method:"POST",headers:L,body:JSON.stringify({sessionId:u,reports:[{slotId:t,expectedFp:s,observedFp:p,reason:b}]})}).catch(()=>{}))},requestSlots(t,s,p){var b,v;for(let u of t)ke.has(u)||(ke.add(u),Se.test(u)?pe.set(u,{text:s==null?void 0:s[u],render:(b=p==null?void 0:p.render)==null?void 0:b[u],skeleton:(v=p==null?void 0:p.skeletons)==null?void 0:v[u]}):M.reportSlots([u]));pe.size===0||Le!=null||(Le=setTimeout(()=>{Le=null;let u=[...pe];pe.clear();for(let f=0;f<u.length;f+=50){let S=u.slice(f,f+50),T={};for(let[E,G]of S)G.render&&(T[E]=G.render);M.decide({slotsFrom:"registry",registrySlotIds:S.map(([E])=>E),bootstrap:!1,render:T}).then(E=>{var G,$;if(E){let K={},F={},H=[];for(let[W,U]of S){let h=(G=E.slotConfig)==null?void 0:G[W];if(h){h.needsSkeleton&&U.skeleton&&(($=M.reportSkeleton)==null||$.call(M,W,U.skeleton));continue}H.push(W),U.text&&(K[W]=U.text),U.skeleton&&(F[W]=U.skeleton)}H.length>0&&M.reportSlots(H,K,F)}else St(S.map(([K])=>K),ke,K=>{var U;let F={},H={},W={};for(let[h,X]of S)K.has(h)&&(X.text&&(F[h]=X.text),X.render&&(H[h]=X.render),X.skeleton&&(W[h]=X.skeleton));(U=M.requestSlots)==null||U.call(M,[...K],F,{render:H,skeletons:W})});he.forEach(K=>K())})}},0))},decideSlots(t){for(let s of t)be.has(s.id)||(be.add(s.id),ge.set(s.id,s));ge.size===0||Be!=null||(Be=setTimeout(()=>{Be=null;let s=[...ge.values()];ge.clear();for(let p=0;p<s.length;p+=30){let b=s.slice(p,p+30);M.decide({slots:b}).then(v=>{v||St(b.map(u=>u.id),be,u=>{var f;return(f=M.decideSlots)==null?void 0:f.call(M,b.filter(S=>u.has(S.id)))}),he.forEach(u=>u())})}},0))},cancelSlots(t){for(let s of t)pe.delete(s)&&ke.delete(s),ge.delete(s)&&be.delete(s)},onSlotsChanged(t){return he.add(t),()=>{he.delete(t)}},getStyleVocabulary(){return N},getSitePalette(){return B},getPersona(){return O?{persona:O.persona,confidence:O.confidence,band:Jt(O.confidence)}:null},async fetchWeights(){var s;let t=ce(5e3);try{let p=await fetch(`${R}/weights`,{headers:L,signal:t.signal});return p.ok?(s=(await p.json()).components)!=null?s:[]:[]}catch(p){return[]}finally{t.clear()}},getGraph(){return{pageNodes:[],capturedAt:0}},flush(){A.flush(),V.flush()},dispose(){var t;re==null||re(),Me=!0,q=!0,A.destroy(),V.destroy(),((t=j.get(e.apiKey))==null?void 0:t.dispose)===M.dispose&&j.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var t;re==null||re(),Me=!0,q=!0,a=!0,Dt(e.apiKey),A.destroy({forget:!0}),V.destroy({forget:!0}),o.destroy(),k.clear(),((t=j.get(e.apiKey))==null?void 0:t.dispose)===M.dispose&&j.delete(e.apiKey);try{localStorage.removeItem(Ne+e.apiKey),localStorage.removeItem(Bt(e.apiKey)),localStorage.removeItem(Mt(e.apiKey)),localStorage.removeItem(`_snt_graph_nodes${le(e.apiKey)}`),localStorage.removeItem("_snt_graph_edges")}catch(s){}e.debug&&console.log("[sentient] destroyed")}};if(j.set(e.apiKey,{config:e,upgrade:null,dispose:M.dispose}),re=Rn(M,e.apiKey,t=>{te.then(()=>{Me||Zt.add(t)})}),e.debug){let t=window;t.__sentient&&(t.__sentient.client=M)}return M}export{Ye as a,Nt as b,Qe as c,nt as d,ot as e,st as f,it as g,Ft as h,Vt as i,hn as j,zn as k,qn as l,Jn as m,Xn as n,Yn as o,Qn as p,Zn as q,eo as r,to as s,no as t,oo as u,so as v,ro as w,io as x,ao as y,lo as z,co as A,uo as B,po as C,go as D,fo as E,mo as F,yo as G,So as H,kn as I,Ht as J,bn as K,xn as L,wn as M,qo as N,tn as O,Jo as P,Xt as Q,On as R};
2
- //# sourceMappingURL=chunk-VLFWHJNJ.mjs.map