@sentientui/core 0.37.0 → 0.39.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.
Files changed (45) 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-VE2K45X4.mjs +2 -0
  5. package/dist/chunk-VE2K45X4.mjs.map +1 -0
  6. package/dist/chunk-XZRKD2GS.mjs +2 -0
  7. package/dist/chunk-XZRKD2GS.mjs.map +1 -0
  8. package/dist/{index-C-meVCmm.d.cts → index-BAfi7_FG.d.cts} +90 -5
  9. package/dist/{index-DbpGK3Dj.d.ts → index-DyKtujwf.d.ts} +90 -5
  10. package/dist/index-consent.js.map +1 -1
  11. package/dist/index-consent.mjs +1 -1
  12. package/dist/index-engagement.js +1 -1
  13. package/dist/index-engagement.js.map +1 -1
  14. package/dist/index-engagement.mjs +1 -1
  15. package/dist/index-graph.d.cts +5 -5
  16. package/dist/index-graph.d.ts +5 -5
  17. package/dist/index-graph.js +1 -1
  18. package/dist/index-graph.js.map +1 -1
  19. package/dist/index-graph.mjs +1 -1
  20. package/dist/index-graph.mjs.map +1 -1
  21. package/dist/index-local.d.cts +3 -3
  22. package/dist/index-local.d.ts +3 -3
  23. package/dist/index-region.d.cts +1 -1
  24. package/dist/index-region.d.ts +1 -1
  25. package/dist/index-region.mjs +1 -1
  26. package/dist/index-server.d.cts +78 -5
  27. package/dist/index-server.d.ts +78 -5
  28. package/dist/index-server.js +1 -1
  29. package/dist/index-server.js.map +1 -1
  30. package/dist/index-server.mjs +1 -1
  31. package/dist/index-server.mjs.map +1 -1
  32. package/dist/index.d.cts +3 -3
  33. package/dist/index.d.ts +3 -3
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +1 -1
  37. package/dist/{region-skeleton-D2ahkcbe.d.cts → region-skeleton-BRIVB-qf.d.cts} +1 -0
  38. package/dist/{region-skeleton-D2ahkcbe.d.ts → region-skeleton-BRIVB-qf.d.ts} +1 -0
  39. package/dist/{session-meta-DlCp0tyi.d.ts → session-meta-BtRtwsHI.d.ts} +7 -2
  40. package/dist/{session-meta-CJ-QAskZ.d.cts → session-meta-qx4kIL5y.d.cts} +7 -2
  41. package/package.json +1 -1
  42. package/dist/chunk-5CCBWT6H.mjs +0 -2
  43. package/dist/chunk-5CCBWT6H.mjs.map +0 -1
  44. package/dist/chunk-DU3AXQHR.mjs +0 -2
  45. package/dist/chunk-DU3AXQHR.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 ga,H as ha,I as ia,J as ja,K as ka,L as la,M as ma,N as na,O as oa,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-5CCBWT6H.mjs";import{a as d,b as e,c as f,d as g,m as h}from"./chunk-DU3AXQHR.mjs";import{a as da,b as ea,c as fa}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,H as BLOCK_ALIGNS,M as BLOCK_EMPHASES,P as BLOCK_FITS,G as BLOCK_GAPS,Q as BLOCK_GRID_COLUMNS,R as BLOCK_HEADING_LEVELS,I as BLOCK_JUSTIFIES,U as BLOCK_MAX_WIDTHS,T as BLOCK_PADS,O as BLOCK_RATIOS,J as BLOCK_SIZES,S as BLOCK_SURFACES,N as BLOCK_TEXT_ALIGNS,L as BLOCK_TONES,K as BLOCK_WEIGHTS,u as CLICK_ID_KEYS,V as FORM_FIELD_KINDS,W as FORM_INPUT_TYPES,a as LEGACY_SESSION_COOKIE_NAME,D as LOCAL_MODE_BANNER,aa as MAX_BLOCK_ARMS,$ as MAX_BLOCK_CHILDREN,_ as MAX_BLOCK_DEPTH,Z as MAX_BLOCK_NODES,ba as MAX_BLOCK_TEXT_LEN,X as MAX_FORM_FIELDS,Y as MAX_FORM_SELECT_OPTIONS,ea as MAX_SKELETON_LEAVES,da as MAX_SKELETON_NODES,fa as MAX_SKELETON_TEXT,E as PAGE_SCOPE_RE,C as PROD_KEYLESS_ERROR,ga as REVEAL_MS,d as SNAPSHOT_STORAGE_KEY_PREFIX,ka as _registerConsentUpgradeInit,p as agentIntent,l as agentUaList,k as applyNonce,B as armOfResult,ja as attachMicroSignalDetectors,z as baselineResultFor,A as baselineSlots,q as classifiedAgents,ca as containsFormBlock,j as cspNonce,x as deriveSessionSegment,r as detectDeviceClass,w as detectTimeOfDay,s as detectTrafficSource,v as extractTrackedParams,c as forgetGeneration,h as forgetVisitor,ma as grantConsent,oa as init,la as isDoNotTrackEnabled,n as matchedAgentToken,F as pageScopeMatches,e as readSnapshot,t as referrerDomainFromReferer,g as renderPrePaintScript,ha as resetRevealStyles,ia as reveal,na as routeKey,b as sessionCookieName,i as setCspNonce,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-VE2K45X4.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
@@ -107,6 +107,9 @@ type DecisionSnapshot = {
107
107
  /** The site-style entries the served compose arms reference — cached so the
108
108
  * pre-paint render already borrows the site's classes. Additive (v stays 1). */
109
109
  vocabulary?: StyleVocabulary;
110
+ /** The `data-sentient-stage` value last decided — already coarsened, and
111
+ * present only for a `stageAttributes` install (additive, v stays 1). */
112
+ stage?: string;
110
113
  };
111
114
  /** Returns null on missing, corrupt, or wrong-version data — never throws. */
112
115
  declare function readSnapshot(apiKey: string): DecisionSnapshot | null;
@@ -123,7 +126,9 @@ declare function writeSnapshot(apiKey: string, snap: DecisionSnapshot): void;
123
126
  * - Built by string concatenation and contains no backticks, so the output
124
127
  * survives being embedded in template-literal-based renderers.
125
128
  */
126
- declare function renderPrePaintScript(apiKey: string): string;
129
+ declare function renderPrePaintScript(apiKey: string, opts?: {
130
+ stage?: boolean;
131
+ }): string;
127
132
 
128
133
  /** Session metadata helpers (browser + Node). No DOM APIs. */
129
134
  /**
@@ -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
@@ -107,6 +107,9 @@ type DecisionSnapshot = {
107
107
  /** The site-style entries the served compose arms reference — cached so the
108
108
  * pre-paint render already borrows the site's classes. Additive (v stays 1). */
109
109
  vocabulary?: StyleVocabulary;
110
+ /** The `data-sentient-stage` value last decided — already coarsened, and
111
+ * present only for a `stageAttributes` install (additive, v stays 1). */
112
+ stage?: string;
110
113
  };
111
114
  /** Returns null on missing, corrupt, or wrong-version data — never throws. */
112
115
  declare function readSnapshot(apiKey: string): DecisionSnapshot | null;
@@ -123,7 +126,9 @@ declare function writeSnapshot(apiKey: string, snap: DecisionSnapshot): void;
123
126
  * - Built by string concatenation and contains no backticks, so the output
124
127
  * survives being embedded in template-literal-based renderers.
125
128
  */
126
- declare function renderPrePaintScript(apiKey: string): string;
129
+ declare function renderPrePaintScript(apiKey: string, opts?: {
130
+ stage?: boolean;
131
+ }): string;
127
132
 
128
133
  /** Session metadata helpers (browser + Node). No DOM APIs. */
129
134
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/core",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,2 +0,0 @@
1
- import{a as Ke,b as ge,c as fe,e as le,f as Ne,g as Ge,h as Ot,i as Tt,j as At,k as Dt,l as Lt,m as $e}from"./chunk-DU3AXQHR.mjs";import{b as Ue,g as je,h as Fe,i as We,k as Ve,l as He,o as ze,p as ve,r as qe}from"./chunk-MKM7TD3L.mjs";import{a as ae,c as Me,d as Rt,e as be}from"./chunk-J5EL7HKC.mjs";import{a as R,b as ne}from"./chunk-TMCGHANO.mjs";var Je;function Xe(e){Je=typeof e=="string"&&e!==""?e:void 0}function Bt(e=document){if(Je)return Je;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 Ye(e,n=document){let c=Bt(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 Pt="_snt_uid",tn=365,ce="_snt_uid";function nn(){return we()}function Qe(e){try{let n=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return n?decodeURIComponent(n[1]):null}catch(n){return null}}function et(){try{return location.protocol==="https:"?"; Secure":""}catch(e){return""}}function on(e,n,c){try{document.cookie=`${e}=${encodeURIComponent(n)}; max-age=${c}; SameSite=lax; path=/${et()}`}catch(y){}}function xe(e){try{return localStorage.getItem(e)}catch(n){return null}}function Mt(e,n){try{return localStorage.setItem(e,n),!0}catch(c){return!1}}function Ze(e){try{return sessionStorage.getItem(e)}catch(n){return null}}function sn(e,n){try{return sessionStorage.setItem(e,n),!0}catch(c){return!1}}function rn(e){try{sessionStorage.removeItem(e)}catch(n){}}function an(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=lax; path=/${et()}`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(n){return!1}}function ln(e){try{localStorage.removeItem(e)}catch(n){}}function cn(e){try{document.cookie=`${e}=; max-age=0; SameSite=lax; path=/${et()}`}catch(n){}}var dn={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function Ee(e){var _,L,Z,V,ee,ie,oe;if(typeof window=="undefined")return dn;let n=ae(e==null?void 0:e.apiKey),c=(_=e==null?void 0:e.cookieName)!=null?_:Me(e==null?void 0:e.apiKey),y=`${ce}${n}`,w=`${ce}_tomb${n}`,C=((L=e==null?void 0:e.cookieTTLDays)!=null?L:tn)*24*60*60,o=P=>P&&P.length>0?P:null,g=()=>{var P,se;return n&&!(e!=null&&e.cookieName)&&xe(w)===null?(se=(P=o(Qe(Pt)))!=null?P:o(xe(ce)))!=null?se:o(Ze(ce)):null},a=(oe=(ie=(ee=(V=(Z=o(Qe(c)))!=null?Z:o(xe(y)))!=null?V:o(Ze(y)))!=null?ee:g())!=null?ie:o(e==null?void 0:e.ssrSessionId))!=null?oe:nn();on(c,a,C);let i=Mt(y,a),r=an(c),h=i?!1:sn(y,a),T=!i&&!r&&!h;return{getSessionId:()=>a,isEphemeral:()=>T,destroy:()=>{a=null,cn(c),ln(y),rn(y),n&&!(e!=null&&e.cookieName)&&(Qe(Pt)!==null||xe(ce)!==null||Ze(ce)!==null)&&Mt(w,"1")}}}var un=1800*1e3;function Ce(e,n){return`${encodeURIComponent(e)}:${encodeURIComponent(n)}`}function Kt(e=un,n){let c=new Map,y=`_snt_asgn${ae(n)}_`,w=(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(h){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 h=m(a);if(!h)continue;c.set(Ce(h.componentId,h.segment),r)}catch(i){}})(),{get(a,i){let r=c.get(Ce(a,i));return r?o(r)?(c.delete(Ce(a,i)),null):r:null},set(a,i,r){let h=Ce(a,i);c.set(h,r);try{localStorage.setItem(w(a,i),JSON.stringify(r))}catch(T){}},clear(){c.clear();for(let a of C())try{localStorage.removeItem(a)}catch(i){}}}}import{confidenceBand as Vt}from"@sentientui/policy";import{confidenceBand as tt}from"@sentientui/policy";var nt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Gt="[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.",Nt=!1,Ie=!1;function pn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(n){return}}function $t(e){var a;let n=Ee({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),c=(a=n.getSessionId())!=null?a:"local",y=pn(),w=import("@sentientui/core/local").then(i=>{let r=i;return r.LOCAL_ENGINE_AVAILABLE?(Nt||(Nt=!0,console.info(Gt)),r):(Ie||(Ie=!0,console.error(nt)),null)}).catch(()=>(Ie||(Ie=!0,console.error(nt)),null)),m=null,C={low:.15,medium:.5,high:.85},o=(()=>{var r;if(e.initialPersona)return R({},e.initialPersona);let i=ge(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=tt(i.confidence))}return{isLocal:!0,async decide(i){var T,_,L;let r=await w;if(!r)return null;let h=r.createLocalEngine({sessionId:c,forcedPersona:y}).decide(i);return m=ne(R({},h),{layoutOrder:(_=(T=h.layoutOrder)!=null?T:m==null?void 0:m.layoutOrder)!=null?_:null,slots:R(R({},(L=m==null?void 0:m.slots)!=null?L:{}),h.slots)}),fe(e.apiKey||"local",{v:1,persona:m.persona,band:tt(m.confidence),slots:m.slots,layoutOrder:m.layoutOrder,savedAt:Date.now()}),g(h),h},getSlotResult(i){var r,h,T;return(T=(h=m==null?void 0:m.slots[i])!=null?h:(r=e.initialSlots)==null?void 0:r[i])!=null?T:null},getSlotConfig(i){var r,h;return(h=(r=e.initialSlotConfig)==null?void 0:r[i])!=null?h: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:tt(i.confidence)}:null},async assign(i,r){var _;let h=await w;return!h||!r||r.length===0?r!=null&&r[0]?{variantId:r[0],assignmentTtlMs:0}:null:{variantId:(_=h.createLocalEngine({sessionId:c,forcedPersona:y}).decide({components:[{id:i,variantIds:r}]}).assignments[i])!=null?_:r[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),flush:()=>{},dispose:()=>{},destroy:()=>n.destroy()}}var Ut=/^(\*|\/[^\s?#*]*(\/\*)?)$/;function ot(e){let n=e.split(/[?#]/)[0]||"/";return n.length>1?n.replace(/\/+$/,"")||"/":n}function gn(e,n){if(e===void 0||!Ut.test(e))return!1;if(e==="*")return!0;let c=ot(n);if(e.endsWith("/*")){let y=ot(e.slice(0,-2));return c.startsWith(y==="/"?"/":`${y}/`)&&c!==y}return c===ot(e)}var $n=["none","sm","md","lg"],Un=["start","center","end","stretch"],jn=["start","center","end","between"],Fn=["sm","md","lg"],Wn=["normal","medium","bold"],Vn=["default","muted","accent"],Hn=["primary","secondary","ghost"],zn=["left","center","right"],qn=["auto","square","landscape","wide"],Jn=["cover","contain"],Xn=[2,3,4],Yn=[1,2,3,4],Qn=["default","raised"],Zn=["none","sm","md","lg"],eo=["measure"],to=["input","textarea","select"],no=["text","email","number","tel"],oo=5,so=8,ro=64,io=5,ao=12,lo=4,co=500;function fn(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(fn):!1}var st="sentient-reveal",de="sentient-revealed",jt=240,_e=!1;function mn(){var e;_e=!1,typeof document!="undefined"&&((e=document.getElementById(st))==null||e.remove())}function yn(e){if(_e||e.getElementById(st)){_e=!0;return}let n=Ye(e.createElement("style"),e);n.id=st,n.textContent=`@media (prefers-reduced-motion: no-preference){@keyframes ${de}{from{opacity:.55;transform:translateY(2px)}to{opacity:1;transform:none}}.${de}{animation:${de} ${jt}ms cubic-bezier(.2,.6,.2,1) both}}`,e.head.appendChild(n),_e=!0}function Sn(e,n={}){var w;let c=(w=n.doc)!=null?w: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;yn(c),e.classList.remove(de),e.offsetWidth,e.classList.add(de);let y=()=>{e.classList.remove(de),e.removeEventListener("animationend",y)};return e.addEventListener("animationend",y),!0}function hn(e,n,c,y){let w=[];{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),w.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),w.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=T=>{for(let _ of T)C=_.intersectionRatio>.3,C?a():g()},h=new IntersectionObserver(r,{threshold:[.3]});h.observe(n),window.addEventListener("scroll",i,{passive:!0}),w.push(()=>{h.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),w.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let m of w)m()}}function kn(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var zt="https://api.sentient-ui.com/v1/events",j=new Map,qt=null;function $o(e,n){let c=j.get(e);c&&c.upgrade&&(c.reinit=n)}function bn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var vn=3;function rt(){return we()}function Re(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function wn(){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)},w=typeof window!="undefined"&&"event"in window,m=()=>{if(!w)return;let o=window.event;return typeof Event=="function"&&o instanceof Event?o:void 0},C=()=>{if(w){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 Jt=new Set;function xn(e,n,c){let y=typeof window=="undefined"?null:window.history;if(!y)return()=>{};let w=!1,m,C=()=>{if(w)return;let a=Re();!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(...h){let T=i.apply(this,h);return C(),T};y[a]=r,o.push([a,i,r])}window.addEventListener("popstate",C);let g=Re();return g&&Jt.has(`${n}:${g}`)?m=g:C(),()=>{if(!w){w=!0,window.removeEventListener("popstate",C);for(let[a,i,r]of o)y[a]===r&&(y[a]=i)}}}var me={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 En(){try{return Ve(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Xt(e){return e.replace(/\/events\/?$/,"")}function Yt(){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 Uo(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:w,reinit:m}=c;if(!w){c.upgradeBlockedReason&&console.warn(c.upgradeBlockedReason);return}if(y.respectDoNotTrack!==!1&&Yt())return;let C=(m!=null?m:In)(ne(R({},y),{consent:!0}));w(C);let o=(g=j.get(n))==null?void 0:g.dispose;j.set(n,{config:ne(R({},y),{consent:!0}),upgrade:null,dispose:o})}function Cn(e,n){var se;let c=e.preConsentBehavior==="statistical_winner",y=Xt((se=e.ingestUrl)!=null?se:zt),w={"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,x){if(!c)return Promise.resolve(null);let I=m.get(l);return I?Promise.resolve(I):at(C,l,async()=>{try{let B=new URLSearchParams({componentId:l});for(let Q of d!=null?d:[])B.append("variantIds[]",Q);let N=le(5e3),A;try{let Q=await fetch(`${y}/winner?${B.toString()}`,{headers:w,signal:N.signal});if(!Q.ok)return d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null;A=await Q.json()}finally{N.clear()}let q={variantId:A.variantId,assignmentTtlMs:0};return m.set(l,q),q}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=[],h=[],T=()=>{for(let[,,l]of h.splice(0))l(null);_.length=0},_=[],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&&_.length<100?_.push(l):L&&e.debug&&console.warn("[sentient] goal dropped: client released")},oe={get gated(){return!g&&!n},get released(){return L&&!g},takeHeld:()=>_.splice(0),track:l=>o.track(l),goal:((l,d,x,I)=>ie(B=>B.goal(l,d,x,I))),componentGoal:(l,d,x)=>o.componentGoal(l,d,x),identify:l=>o.identify(l),getAssignment:(l,d)=>o.getAssignment(l,d),assign:(l,d,x,I)=>o.assign(l,d,x,I),decide:l=>g?o.decide(l):L||n?Promise.resolve(null):new Promise(d=>h.push([l,Ht(),d])),getSlotResult:l=>o.getSlotResult(l),isSlotDecided:l=>{var d,x;return(x=(d=o.isSlotDecided)==null?void 0:d.call(o,l))!=null?x:!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,x,I)=>o.reportSlots(l,d,x,I),reportSkeleton:(l,d)=>{var x;return(x=o.reportSkeleton)==null?void 0:x.call(o,l,d)},reportDrift:(l,d,x,I)=>{var B;return(B=o.reportDrift)==null?void 0:B.call(o,l,d,x,I)},requestSlots:(l,d,x)=>{var I;return g?(I=o.requestSlots)==null?void 0:I.call(o,l,d,x):i.push([l,d,x])},decideSlots:l=>{var d;return g?(d=o.decideSlots)==null?void 0:d.call(o,l):r.push(...l)},cancelSlots:l=>{var x;if(g)return(x=o.cancelSlots)==null?void 0:x.call(o,l);let d=new Set(l);for(let I of i)I[0]=I[0].filter(B=>!d.has(B));r=r.filter(I=>!d.has(I.id))},onSlotsChanged:l=>(a.add(l),()=>{a.delete(l)}),getPersona:()=>o.getPersona(),fetchWeights:()=>o.fetchWeights(),getGraph:()=>o.getGraph(),flush:()=>o.flush(),dispose:()=>(Z(),T(),o.dispose()),destroy:()=>(Z(),T(),g?o.destroy():$e(e.apiKey))};function P(l){var x,I,B;o=l,g=!0,_.length&&(V.push(..._.splice(0)),ee());let d=Ht();for(let[N,A,q]of h.splice(0))A!==d?q(null):l.decide(N).then(q,()=>q(null));(x=l.onSlotsChanged)==null||x.call(l,()=>a.forEach(N=>N()));for(let[N,A,q]of i.splice(0))N.length>0&&((I=l.requestSlots)==null||I.call(l,N,A,q));r.length>0&&((B=l.decideSlots)==null||B.call(l,r.splice(0)))}return{proxy:oe,setInner:P}}function Ht(){return typeof location=="undefined"?"":location.pathname+(/^#!?\//.test(location.hash)?location.hash:"")}function at(e,n,c){let y=e.get(n);if(y)return y;let w=(async()=>{try{return await c()}finally{e.delete(n)}})();return e.set(n,w),w}function In(e){var yt,St,ht,kt,bt,vt,wt,xt,Et,Ct;if(typeof window=="undefined")return me;e.nonce&&Xe(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&&Yt(),y=e.consent===!1||c,w=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!w&&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?me:$t(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."}),me;let{proxy:t,setInner:s}=Cn(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."),me;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),me;let m=(yt=e.ingestUrl)!=null?yt:zt,C=Date.now(),o=Ee({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),g=Kt(void 0,e.apiKey),a=!1,i=be(e.apiKey),r=()=>!a&&be(e.apiKey)===i,h=ne(R({},g),{set:(...t)=>{r()&&g.set(...t)}}),T=At({ingestUrl:m,apiKey:e.apiKey}),_=Xt(m),L={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},Z=new Set,V=Lt({url:`${_}/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=je((St=navigator.userAgent)!=null?St:""),ie=window.location.origin,oe=Fe((ht=document.referrer)!=null?ht:"",ie),P=(kt=e.sessionSegment)!=null?kt:`${ee}:${oe}`,se=new Map,l=new Map,d=new Map,x=new Set,I=new Map,B=null,N=null,A=null,q=new Set,Q=new Set,Oe=new Map,Te=new Map,lt=new Set,ct=new Set,dt=new Set,Ae=null,ye=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,ut=new Set,Se=new Set,he=new Set,ue=new Map,De=null,ke=new Set,pe=new Map,Le=null,Qt=2,pt=new Map,J=!1,gt=(t,s,p)=>{var u;let k=new Set,v=1;for(let f of t){s.delete(f);let S=((u=pt.get(f))!=null?u:0)+1;pt.set(f,S),S<=Qt&&(k.add(f),S>v&&(v=S))}k.size>0&&setTimeout(()=>{J||p(k)},Ge(v))},Be=t=>{for(let s of t)d.has(s.id)||d.set(s.id,ve(s))};if(e.initialSlots)for(let[t,s]of Object.entries(e.initialSlots))d.set(t,s),x.add(t);if(e.initialSlotConfig)for(let[t,s]of Object.entries(e.initialSlotConfig))I.set(t,s);e.initialPalette&&(B=e.initialPalette),e.initialVocabulary&&(N=e.initialVocabulary);let X=ge(e.apiKey);if(X){for(let[t,s]of Object.entries(X.slots))d.has(t)||d.set(t,s);for(let[t,s]of Object.entries((bt=X.slotConfig)!=null?bt:{}))I.has(t)||I.set(t,s);!B&&X.palette&&(B=X.palette),!N&&X.vocabulary&&(N=X.vocabulary)}let ft={low:.15,medium:.5,high:.85};if(e.initialPersona)A=R({},e.initialPersona);else{let t=document.documentElement.dataset;t.sentientPersona?A={persona:t.sentientPersona,confidence:(wt=ft[(vt=t.sentientConfidence)!=null?vt:"low"])!=null?wt:.15}:X&&(A={persona:X.persona,confidence:(xt=ft[X.band])!=null?xt:.15})}if(e.initialAssignments)for(let[t,s]of Object.entries(e.initialAssignments))h.set(t,P,{variantId:s,assignedAt:Date.now(),segment:P,confidence:1});let te=Promise.resolve(),mt=o.getSessionId();if(mt){let t=We((Et=document.referrer)!=null?Et:""),{utmParams:s,clickIds:p}=En(),k=R(R(R(R({sessionId:mt,deviceClass:ee,trafficSource:oe,referrerDomain:t,utmParams:s,clickIds:p,landingPath:typeof location!="undefined"?location.pathname:void 0,timeOfDay:He(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ue((Ct=navigator.userAgent)!=null?Ct:"")},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(J||!r())return;let f=le(5e3);try{let S=await fetch(`${_}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(k),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||Ot(S)==="dropped")return}catch(S){}finally{f.clear()}if(u>=vn){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,Ge(u+1)))}};try{te=v()}catch(u){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:T});let Zt=wn(),re=null,Pe=!1,M={goal(t,s={},p=1,k=0){var $,K,F,z,W,U,b;let v=o.getSessionId();if(!v||J||!r())return;let u=bn(s)?s:{metadata:s},f=[t,($=u.externalId)!=null?$:"",(K=u.stepIndex)!=null?K:k,(F=u.weight)!=null?F:p].join("\0"),S=u.value!==void 0?`${u.value}\0${(z=u.currency)!=null?z:""}`:null;if(Zt.firedBefore(f,S)){e.debug&&console.log(`[sentient] goal("${t}") already recorded for this action \u2014 not sent twice`);return}let O=rt(),E={sessionId:v,name:t,metadata:(W=u.metadata)!=null?W:{},weight:(U=u.weight)!=null?U:p,stepIndex:(b=u.stepIndex)!=null?b:k,goalId:O,value:u.value,currency:u.currency,externalId:u.externalId};e.debug&&console.log("[sentient] goal",E);let G={id:O,body:JSON.stringify(E)};te.then(()=>V.send(G))},componentGoal(t,s,p){var O,E,G;let k=o.getSessionId();if(!k||J||!r())return;let v=h.get(t,P),u=v?null:(O=d.get(t))!=null?O: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&&!x.has(t)){e.debug&&console.warn(`[sentient] componentGoal("${t}"): slot not decided this session \u2014 not attributed`);return}let f=v?v.variantId:qe(u),S={id:rt(),sessionId:k,projectId:e.apiKey,componentId:t,variantId:f,eventType:"goal_achieved",goalType:s,payload:R({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:Re()};e.debug&&console.log("[sentient] componentGoal",S),te.then(()=>{!J&&r()&&T.push(S)})},identify(t){let s=o.getSessionId();!s||J||!r()||te.then(()=>{fetch(`${_}/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||J||!r()||t.eventType==="variant_assigned"&&d.get(t.componentId)!==void 0&&!x.has(t.componentId)&&!h.get(t.componentId,P))return;let p=ne(R({path:Re()},t),{id:rt(),sessionId:s,timestamp:Date.now(),timeInSession:Date.now()-C});e.debug&&console.log("[sentient] track",p),te.then(()=>T.push(p))},getAssignment(t,s){return h.get(t,s)},async assign(t,s,p,k){let v=o.getSessionId();if(!v)return null;let u=h.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 at(se,t,async()=>{if(!await Ne(te,2500)||J||!r())return null;let f=le(3e4);try{let S={sessionId:v,componentId:t,variantIds:s};k!==void 0?S.agentDataByVariant=k:p!==void 0&&(S.agentData=p);let O=await fetch(`${_}/assign`,{method:"POST",body:JSON.stringify(S),headers:L,signal:f.signal});if(!O.ok)return null;let E=await O.json();return h.set(t,P,R({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:[],k={sessionId:s};t.sections&&t.sections.length>0&&(k.sections=t.sections.map(S=>({id:S}))),k.components=(f=t.components)!=null?f:[],p.length>0&&(k.slots=p.map(ze)),t.slotsFrom==="registry"&&(k.slotsFrom="registry",t.registrySlotIds&&(k.registrySlotIds=t.registrySlotIds),t.bootstrap===!1&&(k.bootstrap=!1),t.render&&Object.keys(t.render).length>0&&(k.render=t.render)),t.v&&(k.v=t.v),typeof t.pp=="number"&&(k.pp=t.pp),e.persona&&(k.persona=e.persona);let v=JSON.stringify(k);return at(l,v,async()=>{var O,E,G,$,K,F,z,W;if(!await Ne(te,2500)||J||!r())return Be(p),null;let S=le(3e4);try{let U=await fetch(`${_}/decide`,{method:"POST",body:v,headers:L,signal:S.signal});if(!U.ok)return Be(p),null;let b=await U.json(),H={};for(let D of p){let Y=(O=b.slots)==null?void 0:O[D.id];if(Y!==void 0){H[D.id]=Y,d.set(D.id,Y),x.add(D.id);continue}let It=d.get(D.id);if(It!==void 0)H[D.id]=It;else{let _t=ve(D);H[D.id]=_t,d.set(D.id,_t)}}if(b.slots)for(let[D,Y]of Object.entries(b.slots))D in H||(H[D]=Y,d.set(D,Y),x.add(D));let en=A!=null&&A.persona!=="unknown";b.persona&&!(b.persona==="unknown"&&en)?A={persona:b.persona,confidence:(E=b.confidence)!=null?E:0}:A||(A={persona:"unknown",confidence:0});for(let[D,Y]of Object.entries((G=b.assignments)!=null?G:{}))h.set(D,P,{variantId:Y,assignedAt:Date.now(),segment:P,confidence:1});if(b.slotConfig)for(let[D,Y]of Object.entries(b.slotConfig))I.set(D,Y);b.palette&&(B=b.palette),b.vocabulary&&(N=b.vocabulary);for(let D of($=t.registrySlotIds)!=null?$:[])(K=b.slotConfig)!=null&&K[D]||(I.delete(D),d.delete(D),x.delete(D));return r()&&fe(e.apiKey,R(R(R({v:1,persona:A.persona,band:Vt(A.confidence),slots:Object.fromEntries(d),layoutOrder:(F=b.layoutOrder)!=null?F:null,savedAt:Date.now()},I.size>0?{slotConfig:Object.fromEntries(I)}:{}),B?{palette:B}:{}),N?{vocabulary:N}:{})),R(R(R(R(R({layoutOrder:(z=b.layoutOrder)!=null?z:null,assignments:(W=b.assignments)!=null?W:{},slots:H,persona:A.persona,confidence:A.confidence},b.slotConfig?{slotConfig:b.slotConfig}:{}),b.goals?{goals:b.goals}:{}),b.sectionMap?{sectionMap:b.sectionMap}:{}),b.palette?{palette:b.palette}:{}),b.vocabulary?{vocabulary:b.vocabulary}:{})}catch(U){return Be(p),null}finally{S.clear()}})},getSlotResult(t){var s;return(s=d.get(t))!=null?s:null},isSlotDecided(t){return x.has(t)},getSlotConfig(t){var s;return(s=I.get(t))!=null?s:null},reportSlots(t,s,p,k){var u;let v={};for(let[f,S]of Object.entries(k!=null?k:{}))for(let O of S){let E=`${f}|${O.key}`;!ye.test(f)||dt.has(E)||(dt.add(E),((u=v[f])!=null?u:v[f]=[]).push(O))}Object.keys(v).length>0&&fetch(`${_}/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(!ye.test(f)){kn()&&!ut.has(f)&&(ut.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(!q.has(f)){q.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!==""&&Oe.set(f,E)}let O=p==null?void 0:p[f];O!==void 0&&Te.set(f,O)}}Q.size===0||Ae!=null||(Ae=setTimeout(()=>{Ae=null;let f=[...Q];Q.clear();for(let S=0;S<f.length;S+=20){let O=f.slice(S,S+20),E={},G={};for(let $ of O){let K=Oe.get($);K!==void 0&&(E[$]=K,Oe.delete($));let F=Te.get($);F!==void 0&&(G[$]=F,Te.delete($))}fetch(`${_}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify(R(ne(R(R({slotIds:O},Object.keys(E).length>0?{baselineTexts:E}:{}),Object.keys(G).length>0?{baselineSkeletons:G}:{}),{pagePaths:Object.fromEntries(O.map($=>[$,location.pathname]))}),Object.keys(E).length>0&&o.getSessionId()?{sessionId:o.getSessionId()}:{}))}).catch(()=>{})}},1e3))},reportSkeleton(t,s){!ye.test(t)||lt.has(t)||(lt.add(t),fetch(`${_}/slots/observed`,{method:"POST",headers:L,body:JSON.stringify({slotIds:[t],baselineSkeletons:{[t]:s}})}).catch(()=>{}))},reportDrift(t,s,p,k){let v=`${t}|${s}`,u=o.getSessionId();!u||ct.has(v)||(ct.add(v),fetch(`${_}/slots/drift`,{method:"POST",headers:L,body:JSON.stringify({sessionId:u,reports:[{slotId:t,expectedFp:s,observedFp:p,reason:k}]})}).catch(()=>{}))},requestSlots(t,s,p){var k,v;for(let u of t)he.has(u)||(he.add(u),ye.test(u)?ue.set(u,{text:s==null?void 0:s[u],render:(k=p==null?void 0:p.render)==null?void 0:k[u],skeleton:(v=p==null?void 0:p.skeletons)==null?void 0:v[u]}):M.reportSlots([u]));ue.size===0||De!=null||(De=setTimeout(()=>{De=null;let u=[...ue];ue.clear();for(let f=0;f<u.length;f+=50){let S=u.slice(f,f+50),O={};for(let[E,G]of S)G.render&&(O[E]=G.render);M.decide({slotsFrom:"registry",registrySlotIds:S.map(([E])=>E),bootstrap:!1,render:O}).then(E=>{var G,$;if(E){let K={},F={},z=[];for(let[W,U]of S){let b=(G=E.slotConfig)==null?void 0:G[W];if(b){b.needsSkeleton&&U.skeleton&&(($=M.reportSkeleton)==null||$.call(M,W,U.skeleton));continue}z.push(W),U.text&&(K[W]=U.text),U.skeleton&&(F[W]=U.skeleton)}z.length>0&&M.reportSlots(z,K,F)}else gt(S.map(([K])=>K),he,K=>{var U;let F={},z={},W={};for(let[b,H]of S)K.has(b)&&(H.text&&(F[b]=H.text),H.render&&(z[b]=H.render),H.skeleton&&(W[b]=H.skeleton));(U=M.requestSlots)==null||U.call(M,[...K],F,{render:z,skeletons:W})});Se.forEach(K=>K())})}},0))},decideSlots(t){for(let s of t)ke.has(s.id)||(ke.add(s.id),pe.set(s.id,s));pe.size===0||Le!=null||(Le=setTimeout(()=>{Le=null;let s=[...pe.values()];pe.clear();for(let p=0;p<s.length;p+=30){let k=s.slice(p,p+30);M.decide({slots:k}).then(v=>{v||gt(k.map(u=>u.id),ke,u=>{var f;return(f=M.decideSlots)==null?void 0:f.call(M,k.filter(S=>u.has(S.id)))}),Se.forEach(u=>u())})}},0))},cancelSlots(t){for(let s of t)ue.delete(s)&&he.delete(s),pe.delete(s)&&ke.delete(s)},onSlotsChanged(t){return Se.add(t),()=>{Se.delete(t)}},getStyleVocabulary(){return N},getSitePalette(){return B},getPersona(){return A?{persona:A.persona,confidence:A.confidence,band:Vt(A.confidence)}:null},async fetchWeights(){var s;let t=le(5e3);try{let p=await fetch(`${_}/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(){T.flush(),V.flush()},dispose(){var t;re==null||re(),Pe=!0,J=!0,T.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(),Pe=!0,J=!0,a=!0,Rt(e.apiKey),T.destroy({forget:!0}),V.destroy({forget:!0}),o.destroy(),h.clear(),((t=j.get(e.apiKey))==null?void 0:t.dispose)===M.dispose&&j.delete(e.apiKey);try{localStorage.removeItem(Ke+e.apiKey),localStorage.removeItem(Tt(e.apiKey)),localStorage.removeItem(Dt(e.apiKey)),localStorage.removeItem(`_snt_graph_nodes${ae(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=xn(M,e.apiKey,t=>{te.then(()=>{Pe||Jt.add(t)})}),e.debug){let t=window;t.__sentient&&(t.__sentient.client=M)}return M}export{Xe as a,Bt as b,Ye as c,nt as d,Gt as e,Ut as f,gn as g,$n as h,Un as i,jn as j,Fn as k,Wn as l,Vn as m,Hn as n,zn as o,qn as p,Jn as q,Xn as r,Yn as s,Qn as t,Zn as u,eo as v,to as w,no as x,oo as y,so as z,ro as A,io as B,ao as C,lo as D,co as E,fn as F,jt as G,mn as H,Sn as I,hn as J,$o as K,Yt as L,Uo as M,Ht as N,In as O};
2
- //# sourceMappingURL=chunk-5CCBWT6H.mjs.map