@sentientui/react 0.16.3 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.d.cts +17 -17
- package/dist/index.d.ts +17 -17
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +5 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Carlos Sánchez Campos / SentientUI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.cts
CHANGED
|
@@ -216,8 +216,23 @@ type AdaptiveTextProps = {
|
|
|
216
216
|
default: string;
|
|
217
217
|
component?: keyof JSX.IntrinsicElements;
|
|
218
218
|
className?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Optional conversion goal to optimize this copy toward. Without it, the
|
|
221
|
+
* variant is served and logged but never scored — the copy rotates and never
|
|
222
|
+
* learns. Provide a goal (a name string or a GoalConfig) to make the optimizer
|
|
223
|
+
* attribute conversions to the winning wording, exactly like `<Adaptive>`.
|
|
224
|
+
*/
|
|
225
|
+
goal?: string | GoalConfig;
|
|
219
226
|
};
|
|
220
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Dashboard-managed copy for a single element. The variants are **text only** —
|
|
229
|
+
* they change the wording, never the CSS, markup, or layout of the element
|
|
230
|
+
* (managed variants created from the dashboard/MCP carry text, nothing else).
|
|
231
|
+
* For anything structural — style, markup shape, position — write the change in
|
|
232
|
+
* code with `<Adaptive>` (any JSX per variant) or use adaptive slots on no-code
|
|
233
|
+
* sites. Pass `goal` to make the managed copy optimizable (see below).
|
|
234
|
+
*/
|
|
235
|
+
declare function AdaptiveText({ id, default: defaultText, component: Tag, className, goal: goalProp, }: AdaptiveTextProps): react_jsx_runtime.JSX.Element;
|
|
221
236
|
|
|
222
237
|
declare global {
|
|
223
238
|
interface Window {
|
|
@@ -382,21 +397,6 @@ type ComponentWeights = {
|
|
|
382
397
|
variants: VariantWeight[];
|
|
383
398
|
updatedAt: number;
|
|
384
399
|
};
|
|
385
|
-
type Listener = (weights: ComponentWeights) => void;
|
|
386
|
-
/**
|
|
387
|
-
* Subscribes a listener to a single component. Returns an unsubscribe function.
|
|
388
|
-
* Updates to other components never trigger this listener.
|
|
389
|
-
*/
|
|
390
|
-
declare function subscribe(componentId: string, cb: Listener): () => void;
|
|
391
|
-
/**
|
|
392
|
-
* Replaces the weights for a component and notifies only that component's
|
|
393
|
-
* subscribers.
|
|
394
|
-
*/
|
|
395
|
-
declare function update(componentId: string, weights: ComponentWeights): void;
|
|
396
|
-
/**
|
|
397
|
-
* Returns the latest known weights for a component, or null if none seen.
|
|
398
|
-
*/
|
|
399
|
-
declare function getWeights(componentId: string): ComponentWeights | null;
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
402
|
* Agent-readable content feed. Merges SDK-known data (winning variants, layout
|
|
@@ -457,4 +457,4 @@ declare function renderAgentJsonLdBody(feed: AgentFeed): string;
|
|
|
457
457
|
/** Render the feed as Markdown for agents that negotiate `text/markdown`. */
|
|
458
458
|
declare function renderAgentMarkdown(feed: AgentFeed): string;
|
|
459
459
|
|
|
460
|
-
export { Adaptive, AdaptiveGroup, type AdaptiveGroupProps, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveText, type AdaptiveTextProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent,
|
|
460
|
+
export { Adaptive, AdaptiveGroup, type AdaptiveGroupProps, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveText, type AdaptiveTextProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, useSentient };
|
package/dist/index.d.ts
CHANGED
|
@@ -216,8 +216,23 @@ type AdaptiveTextProps = {
|
|
|
216
216
|
default: string;
|
|
217
217
|
component?: keyof JSX.IntrinsicElements;
|
|
218
218
|
className?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Optional conversion goal to optimize this copy toward. Without it, the
|
|
221
|
+
* variant is served and logged but never scored — the copy rotates and never
|
|
222
|
+
* learns. Provide a goal (a name string or a GoalConfig) to make the optimizer
|
|
223
|
+
* attribute conversions to the winning wording, exactly like `<Adaptive>`.
|
|
224
|
+
*/
|
|
225
|
+
goal?: string | GoalConfig;
|
|
219
226
|
};
|
|
220
|
-
|
|
227
|
+
/**
|
|
228
|
+
* Dashboard-managed copy for a single element. The variants are **text only** —
|
|
229
|
+
* they change the wording, never the CSS, markup, or layout of the element
|
|
230
|
+
* (managed variants created from the dashboard/MCP carry text, nothing else).
|
|
231
|
+
* For anything structural — style, markup shape, position — write the change in
|
|
232
|
+
* code with `<Adaptive>` (any JSX per variant) or use adaptive slots on no-code
|
|
233
|
+
* sites. Pass `goal` to make the managed copy optimizable (see below).
|
|
234
|
+
*/
|
|
235
|
+
declare function AdaptiveText({ id, default: defaultText, component: Tag, className, goal: goalProp, }: AdaptiveTextProps): react_jsx_runtime.JSX.Element;
|
|
221
236
|
|
|
222
237
|
declare global {
|
|
223
238
|
interface Window {
|
|
@@ -382,21 +397,6 @@ type ComponentWeights = {
|
|
|
382
397
|
variants: VariantWeight[];
|
|
383
398
|
updatedAt: number;
|
|
384
399
|
};
|
|
385
|
-
type Listener = (weights: ComponentWeights) => void;
|
|
386
|
-
/**
|
|
387
|
-
* Subscribes a listener to a single component. Returns an unsubscribe function.
|
|
388
|
-
* Updates to other components never trigger this listener.
|
|
389
|
-
*/
|
|
390
|
-
declare function subscribe(componentId: string, cb: Listener): () => void;
|
|
391
|
-
/**
|
|
392
|
-
* Replaces the weights for a component and notifies only that component's
|
|
393
|
-
* subscribers.
|
|
394
|
-
*/
|
|
395
|
-
declare function update(componentId: string, weights: ComponentWeights): void;
|
|
396
|
-
/**
|
|
397
|
-
* Returns the latest known weights for a component, or null if none seen.
|
|
398
|
-
*/
|
|
399
|
-
declare function getWeights(componentId: string): ComponentWeights | null;
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
402
|
* Agent-readable content feed. Merges SDK-known data (winning variants, layout
|
|
@@ -457,4 +457,4 @@ declare function renderAgentJsonLdBody(feed: AgentFeed): string;
|
|
|
457
457
|
/** Render the feed as Markdown for agents that negotiate `text/markdown`. */
|
|
458
458
|
declare function renderAgentMarkdown(feed: AgentFeed): string;
|
|
459
459
|
|
|
460
|
-
export { Adaptive, AdaptiveGroup, type AdaptiveGroupProps, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveText, type AdaptiveTextProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent,
|
|
460
|
+
export { Adaptive, AdaptiveGroup, type AdaptiveGroupProps, type AdaptiveProps, AdaptiveProvider, type AdaptiveProviderProps, AdaptiveText, type AdaptiveTextProps, type AgentBlock, type AgentFeed, type AssignmentState, type ClickGoal, type ComponentWeights, type CompositeGoal, type FireGoal, type FormSubmitGoal, type GoalConfig, type MicroSignalGoalConfig, type MicroSignalGoals, type ScrollDepthGoal, SentientPersonaScript, type SentientPersonaScriptProps, type SsrFallback, type UseAdaptiveBind, type UseAdaptiveResult, type UseAdaptiveTokensOptions, type UseAdaptiveTokensResult, type VariantWeight, type WeightedCompositeGoal, type WeightedStep, buildAgentFeed, defineAgentContent, getAgentContent, renderAgentJsonLd, renderAgentJsonLdBody, renderAgentMarkdown, useAdaptive, useAdaptiveApiBaseUrl, useAdaptiveGoal, useAdaptiveTokens, useAssignment, useInitialAssignments, useLayoutOrder, useSentient };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var ct=Object.create;var J=Object.defineProperty,ut=Object.defineProperties,dt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertyNames,me=Object.getOwnPropertySymbols,pt=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,mt=Object.prototype.propertyIsEnumerable;var ve=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))ye.call(t,n)&&ve(e,n,t[n]);if(me)for(var n of me(t))mt.call(t,n)&&ve(e,n,t[n]);return e},H=(e,t)=>ut(e,ft(t));var vt=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},Se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of gt(t))!ye.call(e,i)&&i!==n&&J(e,i,{get:()=>t[i],enumerable:!(o=dt(t,i))||o.enumerable});return e};var he=(e,t,n)=>(n=e!=null?ct(pt(e)):{},Se(t||!e||!e.__esModule?J(n,"default",{value:e,enumerable:!0}):n,e)),yt=e=>Se(J({},"__esModule",{value:!0}),e);var Gt={};vt(Gt,{Adaptive:()=>We,AdaptiveGroup:()=>Ze,AdaptiveProvider:()=>Ge,AdaptiveText:()=>Fe,SentientPersonaScript:()=>Je,buildAgentFeed:()=>it,defineAgentContent:()=>nt,detectSegment:()=>ce.deriveSessionSegment,getAgentContent:()=>ue,getWeights:()=>Y,renderAgentJsonLd:()=>rt,renderAgentJsonLdBody:()=>de,renderAgentMarkdown:()=>ot,subscribeWeights:()=>q,updateWeights:()=>Q,useAdaptive:()=>Ye,useAdaptiveApiBaseUrl:()=>Ie,useAdaptiveGoal:()=>Ne,useAdaptiveTokens:()=>Xe,useAssignment:()=>U,useInitialAssignments:()=>ne,useLayoutOrder:()=>Ee,useSentient:()=>C});module.exports=yt(Gt);var A=require("react"),N=require("@sentientui/core");var we=new Map,X=new Map;function q(e,t){let n=X.get(e);return n||(n=new Set,X.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&X.delete(e)}}function Q(e,t){we.set(e,t);let n=X.get(e);if(n)for(let o of n)try{o(t)}catch(i){}}function Y(e){var t;return(t=we.get(e))!=null?t:null}var St={on:!1,listeners:new Set};function be(){if(typeof window=="undefined")return St;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function ae(){return be().on}function Ae(e){let t=be().listeners;return t.add(e),()=>{t.delete(e)}}function xe(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,o,i)=>e.assign(t,n,o,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ke="sentient:overrides-changed";function Z(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function K(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ke,e),()=>window.removeEventListener(ke,e))}function Ce(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}var ht={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function F(){if(typeof window=="undefined")return ht;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function z(){F().version+=1;for(let e of F().listeners)e()}function ee(e){return F().components.set(e.id,e),z(),()=>{F().components.delete(e.id),z()}}function te(e){return F().slots.set(e.id,e),z(),()=>{F().slots.delete(e.id),z()}}function _e(e){F().sections=[...e],z()}var Pe=require("react/jsx-runtime");function wt(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{let n=(0,N.detectDeviceClass)((e=navigator.userAgent)!=null?e:""),o=(0,N.detectTrafficSource)((t=document.referrer)!=null?t:"",window.location.origin);return`${n}:${o}`}catch(n){return"desktop:direct"}}var Re="https://api.sentient-ui.com/v1",I=(0,A.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialPersona:null,apiBaseUrl:Re});function Ge(e){var v,u;let[t,n]=(0,A.useState)(null),[o]=(0,A.useState)(()=>{var d;return(d=e.sessionSegment)!=null?d:wt()}),[i,p]=(0,A.useState)(ae());(0,A.useEffect)(()=>Ae(()=>p(ae())),[]),(0,A.useEffect)(()=>{if(e.consent===!1&&!e.preConsentBehavior){n(f=>(f==null||f.destroy(),null));return}let d={apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:o,consent:e.consent,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,localMode:e.localMode,initialSlots:e.initialSlots,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},g=!1,l=null,a=null,h=f=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:w})=>{g||(a=w(f,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:f})=>{g||(l=f(H(O({},d),{graph:!0})),n(l),h(l))}):(l=(0,N.init)(d),n(l),h(l)),()=>{g=!0,a==null||a(),l==null||l.dispose()}},[e.consent]),(0,A.useEffect)(()=>{if(!t)return;let d=!1,g=async()=>{if(d)return;let a;try{a=await t.fetchWeights()}catch(h){return}if(!d)for(let h of a){let f={componentId:h.componentId,updatedAt:h.updatedAt,variants:h.variants.map(w=>{var y;return{variantId:w.variantId,pulls:w.pulls,avgReward:(y=w.avgReward)!=null?y:0}})};Q(h.componentId,f)}};g();let l=setInterval(()=>{g()},6e4);return()=>{d=!0,clearInterval(l)}},[t]);let s=(v=e.ssrFallback)!=null?v:"first",r=(u=e.apiBaseUrl)!=null?u:Re;(0,A.useEffect)(()=>{var d;typeof process!="undefined"&&((d=process.env)==null?void 0:d.NODE_ENV)==="production"||Ce({apiKey:e.apiKey,apiBaseUrl:r,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,r]),(0,A.useEffect)(()=>{e.initialLayoutOrder&&e.initialLayoutOrder.length>0&&_e(e.initialLayoutOrder)},[e.initialLayoutOrder]);let m=(0,A.useMemo)(()=>t&&i?xe(t):t,[t,i]),c=(0,A.useMemo)(()=>{var d,g,l,a;return{client:m,apiKey:e.apiKey,initialAssignments:(d=e.initialAssignments)!=null?d:{},sessionSegment:o,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(g=e.initialLayoutOrder)!=null?g:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialPersona:(a=e.initialPersona)!=null?a:null,apiBaseUrl:r}},[m,e.apiKey,e.initialAssignments,o,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialPersona,r]);return(0,Pe.jsx)(I.Provider,{value:c,children:e.children})}function C(){return(0,A.useContext)(I).client}function P(){return(0,A.useContext)(I).apiKey}function ne(){return(0,A.useContext)(I).initialAssignments}function ie(){return(0,A.useContext)(I).sessionSegment}function Oe(){return(0,A.useContext)(I).ssrFallback}function re(){return(0,A.useContext)(I).onAssignment}function Ee(){let e=(0,A.useContext)(I).initialLayoutOrder,t=(0,A.useSyncExternalStore)(K,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Le(){return(0,A.useContext)(I).initialSlots}function Ie(){return(0,A.useContext)(I).apiBaseUrl}var x=require("react"),Me=require("@sentientui/core");var L=require("react");function bt(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;try{let o=new URLSearchParams(window.location.search);for(let i of o.getAll("sentient_variant")){let p=i.indexOf(":");if(p!==-1&&i.slice(0,p)===e)return i.slice(p+1)}}catch(o){}return null}function Te(e,t){var o;let n=null;for(let i of e.variants)t.includes(i.variantId)&&(!n||i.avgReward>n.avgReward)&&(n={variantId:i.variantId,avgReward:i.avgReward});return(o=n==null?void 0:n.variantId)!=null?o:null}function U(e,t,n,o){let i=ne(),p=Oe(),s=C(),r=ie(),m=re(),c=(0,L.useRef)(null);(0,L.useSyncExternalStore)(K,Z,()=>0);let v=bt(e),u=v&&t.includes(v)?v:null,d=(0,L.useRef)(null);u&&d.current!==u&&(d.current=u,console.info(`[sentient] override active: ${e} -> ${u}`));let g=(()=>{var y,b;if(u)return{variantId:u,content:null,isLoading:!1};if(!s){let S=i[e];return S&&t.includes(S)?{variantId:S,content:null,isLoading:!1}:p==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1}:{variantId:null,content:null,isLoading:!0}}let f=s.getAssignment(e,r);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(y=f.content)!=null?y:null,isLoading:!1};let w=Y(e);if(w){let S=Te(w,t);if(S)return{variantId:S,content:null,isLoading:!1}}return{variantId:(b=t[0])!=null?b:null,content:null,isLoading:!1}})(),[l,a]=(0,L.useState)(g),h=f=>{m&&c.current!==f&&(c.current=f,m(e,f))};return(0,L.useEffect)(()=>{var w;if(u||!s)return;let f=s.getAssignment(e,r);if(f&&(t.includes(f.variantId)||f.content)){a({variantId:f.variantId,content:(w=f.content)!=null?w:null,isLoading:!1}),h(f.variantId);return}a(y=>{var b;return y.variantId?y:{variantId:(b=t[0])!=null?b:null,content:null,isLoading:!1}})},[u,s,e,r]),(0,L.useEffect)(()=>{if(u||!s)return;let f=s.getAssignment(e,r);if(f&&t.includes(f.variantId))return;let w=!1;return s.assign(e,t,n,o).then(y=>{var b;w||y&&(!t.includes(y.variantId)&&!y.content||(a({variantId:y.variantId,content:(b=y.content)!=null?b:null,isLoading:!1}),h(y.variantId)))}),()=>{w=!0}},[u,s,e,r]),(0,L.useEffect)(()=>{if(!u&&s)return q(e,f=>{var b;let w=s.getAssignment(e,r);if(w&&(t.includes(w.variantId)||w.content)){a({variantId:w.variantId,content:(b=w.content)!=null?b:null,isLoading:!1});return}let y=Te(f,t);y&&a({variantId:y,content:null,isLoading:!1})})},[u,s,e,r]),u?{variantId:u,content:null,isLoading:!1,isOverride:!0}:l}function E(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function D(e){return typeof e=="string"?{type:"click"}:e}function $(e){return typeof e=="string"?e:e.type}function At(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function De(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let o=e;for(;o&&o!==t;){if(At(o))return!0;o=o.parentElement}return!1}function M(e,t,n){if(t.type==="weighted_composite"){let r=new Set,m=[];return t.steps.forEach(({goal:c,name:v,weight:u},d)=>{let g=()=>{r.has(d)||(r.add(d),n.fireStep(v,u,d))};if(c.type==="click"){let l=a=>{let h=a.target;h instanceof Element&&De(h,e,c.selector)&&g()};e.addEventListener("click",l),m.push(()=>e.removeEventListener("click",l));return}if(c.type==="form_submit"){let l=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&g()};e.addEventListener("submit",l),m.push(()=>e.removeEventListener("submit",l));return}if(c.type==="scroll_depth"){let l=Math.max(0,Math.min(1,c.threshold)),a=new IntersectionObserver(h=>{for(let f of h)if(f.intersectionRatio>=l){g(),a.disconnect();break}},{threshold:[l]});a.observe(e),m.push(()=>a.disconnect())}}),()=>{for(let c of m)c()}}let o=t.type==="composite"?t.all:[t],i=new Set(o.map((r,m)=>m)),p=r=>{i.delete(r),i.size===0&&n.fireGoal()},s=[];return o.forEach((r,m)=>{if(r.type==="click"){let c=v=>{let u=v.target;u instanceof Element&&De(u,e,r.selector)&&(t.type==="composite"?p(m):n.fireGoal())};e.addEventListener("click",c),s.push(()=>e.removeEventListener("click",c));return}if(r.type==="form_submit"){let c=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&(t.type==="composite"?p(m):n.fireGoal())};e.addEventListener("submit",c),s.push(()=>e.removeEventListener("submit",c));return}if(r.type==="scroll_depth"){let c=Math.max(0,Math.min(1,r.threshold)),v=new IntersectionObserver(u=>{for(let d of u)if(d.intersectionRatio>=c){t.type==="composite"?p(m):n.fireGoal(),v.disconnect();break}},{threshold:[c]});v.observe(e),s.push(()=>v.disconnect());return}}),()=>{for(let r of s)r()}}function W(e,t,n,o){e.track({projectId:t,componentId:n,variantId:o,eventType:"variant_assigned",payload:{}})}var Be=require("react/jsx-runtime");function xt(e){var w;let t=C(),n=P(),o=(0,x.useMemo)(()=>Object.keys(e.variants),[e.variants]),{variantId:i,content:p,isOverride:s}=U(e.id,o,e.agentData,e.agentDataByVariant),r=(0,x.useRef)(null),[m,c]=(0,x.useState)(!1);(0,x.useEffect)(()=>{c(!0)},[]);let v=(0,x.useRef)(!1),u=(0,x.useRef)(new Set),d=(0,x.useRef)(null),g=typeof e.goal=="string"?e.goal:JSON.stringify(e.goal),l=(0,x.useMemo)(()=>D(e.goal),[g]),a=typeof e.goal=="string"?e.goal:l.type;if((0,x.useEffect)(()=>ee({id:e.id,variantIds:o,goal:a}),[e.id,o,a]),(0,x.useEffect)(()=>{s||!t||!i||!n||d.current!==i&&(d.current=i,W(t,n,e.id,i))},[t,i,n,e.id,s]),(0,x.useEffect)(()=>{v.current=!1,u.current=new Set},[i,l]),(0,x.useEffect)(()=>{if(s||!t||!i)return;let y=r.current;if(!y)return;let b=null,S=0,R=()=>{S=Date.now(),b=setTimeout(()=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-S}}),b=null},800)},_=()=>{b!==null&&(clearTimeout(b),b=null)};return y.addEventListener("mouseenter",R),y.addEventListener("mouseleave",_),()=>{y.removeEventListener("mouseenter",R),y.removeEventListener("mouseleave",_),b!==null&&clearTimeout(b)}},[t,i,n,e.id,s]),(0,x.useEffect)(()=>{if(s||!t||!i)return;let y=r.current;if(!y)return;let b=Date.now();return(0,Me.attachMicroSignalDetectors)((S,R={})=>{var fe,ge,pe;t.track({projectId:n,componentId:e.id,variantId:i,eventType:"micro_signal",payload:O({signalType:S},R)});let _=(fe=e.microSignalGoals)==null?void 0:fe[S];if(!_||u.current.has(S))return;u.current.add(S);let st=typeof _=="string"?_:_.name,at=typeof _=="string"?1:(ge=_.weight)!=null?ge:1,lt=typeof _=="string"?0:(pe=_.stepIndex)!=null?pe:0;t.goal(st,O({signalType:S},R),at,lt)},y,b)},[t,i,n,e.id,e.microSignalGoals,s]),(0,x.useEffect)(()=>{if(s||!t||!i)return;let y=r.current;if(y)return M(y,l,{fireGoal:()=>{v.current||(v.current=!0,t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:a,payload:{reward:1}}),t.goal(a,{componentId:e.id,variantId:i},1,0))},fireStep:(b,S,R)=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:b,payload:{reward:S}}),t.goal(b,{},S,R)}})},[t,i,n,e.id,l,a,s]),e.clientOnly&&(!m||!t)||!i)return null;let h=(w=e.variants[i])!=null?w:null,f=h===null?p:null;return E()&&h===null&&f===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${i}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Be.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":i,children:h!=null?h:f})}var We=(0,x.memo)(xt,(e,t)=>{if(e.id!==t.id||JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.clientOnly!==t.clientOnly||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),o=Object.keys(t.variants);return n.length!==o.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});var B=require("react");var je=require("react/jsx-runtime");function Fe({id:e,default:t,component:n="span",className:o}){let i=C(),p=P(),s=re(),r=ie(),m=(0,B.useRef)(null),[c,v]=(0,B.useState)(()=>{var g,l;return(l=(g=i==null?void 0:i.getAssignment(e,r))==null?void 0:g.content)!=null?l:null}),[u,d]=(0,B.useState)(()=>{var g,l;return(l=(g=i==null?void 0:i.getAssignment(e,r))==null?void 0:g.variantId)!=null?l:null});return(0,B.useEffect)(()=>{var l;if(!i||((l=i.getAssignment(e,r))==null?void 0:l.content)!==void 0)return;let g=!1;return i.assign(e).then(a=>{if(!g){if(!a){E()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}d(a.variantId),a.content&&v(a.content)}}),()=>{g=!0}},[i,e,r]),(0,B.useEffect)(()=>{!i||!u||!p||m.current!==u&&(m.current=u,i.track({projectId:p,componentId:e,variantId:u,eventType:"variant_assigned",payload:{}}),s==null||s(e,u))},[i,u,p,e,s]),(0,je.jsx)(n,{className:o,children:c!=null?c:t})}var Ke=require("react");function Ne(e){let t=C();return(0,Ke.useCallback)((n,o)=>{t==null||t.componentGoal(e,n,o)},[t,e])}var $e=require("@sentientui/core"),Ve=require("@sentientui/policy"),He=require("react/jsx-runtime");function Ue(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function kt(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Ue(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Ue((0,Ve.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,$e.renderPrePaintScript)(e.apiKey)}function Je(e){return(0,He.jsx)("script",{"data-sentient-persona-script":"",dangerouslySetInnerHTML:{__html:kt(e)}})}var T=require("react"),ze=require("@sentientui/policy");var V=require("react"),j=require("@sentientui/core"),Ct=require("@sentientui/policy");function oe(e,t){var v;(0,V.useSyncExternalStore)(K,Z,()=>0);let n=C(),o=Le(),[,i]=(0,V.useReducer)(u=>u+1,0),p=typeof window!="undefined"?(v=window.__sentient_slot_overrides)==null?void 0:v[e]:void 0,s=p===void 0?o[e]:void 0,r=p===void 0&&s===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&p===void 0&&s===void 0&&r===null;if((0,V.useEffect)(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(d=>{!u&&d&&i()}),()=>{u=!0}},[n,e,m]),p!==void 0)return{result:p,arm:(0,j.armOfResult)(p),source:"override"};if(s!==void 0)return{result:s,arm:(0,j.armOfResult)(s),source:"preloaded"};if(r!==null)return{result:r,arm:(0,j.armOfResult)(r),source:"client"};let c=(0,j.baselineResultFor)(t);return{result:c,arm:(0,j.armOfResult)(c),source:"baseline"}}var le=new Set;function _t(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}function Xe(e,t,n){let o=C(),i=P(),p=(0,T.useMemo)(()=>({id:e,dims:t}),[e]),{result:s,arm:r}=oe(e,p),m=(0,T.useMemo)(()=>typeof s=="string"?{}:s,[r]);if(E()&&!le.has(e)){let d=(0,ze.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([l,a])=>[l,[...a]]))}),g=Object.values(t).reduce((l,a)=>l*a.length,1);d.ok?g>4&&(le.add(e),console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${g} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`)):(le.add(e),console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${d.reason}. Serving baseline.`))}let c=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,T.useEffect)(()=>te({id:e,dims:t}),[e]);let v=(0,T.useRef)(null);(0,T.useEffect)(()=>{!o||v.current===r||(v.current=r,W(o,i,e,r))},[o,i,e,r]),(0,T.useEffect)(()=>{if(!o||!(n!=null&&n.goal))return;let d=document.querySelector(`[data-sentient-slot="${_t(e)}"]`);if(!d){E()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let g=$(n.goal),l=!1;return M(d,D(n.goal),{fireGoal:()=>{l||(l=!0,o.componentGoal(e,g))},fireStep:(a,h)=>{o.componentGoal(e,a,{reward:h})}})},[o,e,c,r]);let u=(0,T.useMemo)(()=>{let d={"data-sentient-slot":e};for(let[g,l]of Object.entries(m))d[`data-${g}`]=l;return d},[e,m]);return{tokens:m,props:u}}var k=require("react"),Qe=require("@sentientui/core");var qe=new Set;function Ye(e,t){var b;if(E()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let n=C(),o=P(),i=(0,k.useMemo)(()=>Object.keys(t.variants),[e]),{variantId:p,isOverride:s}=U(e,i),r=(b=p!=null?p:i[0])!=null?b:"",m=t.variants[r],[c,v]=(0,k.useState)(null),u=(0,k.useRef)(null),d=(0,k.useCallback)(S=>{u.current=S,v(S)},[]),g=typeof t.goal=="string"?t.goal:JSON.stringify(t.goal),l=(0,k.useMemo)(()=>D(t.goal),[g]),a=$(t.goal);(0,k.useEffect)(()=>ee({id:e,variantIds:i,goal:a}),[e,i,a]);let h=(0,k.useRef)(null);(0,k.useEffect)(()=>{s||!n||!r||!c||h.current!==r&&(h.current=r,W(n,o,e,r))},[n,o,e,r,c,s]);let f=(0,k.useRef)(!1);(0,k.useEffect)(()=>{f.current=!1},[r,g]),(0,k.useEffect)(()=>{if(!s&&!(!n||!r||!c))return M(c,l,{fireGoal:()=>{f.current||(f.current=!0,n.track({projectId:o,componentId:e,variantId:r,eventType:"goal_achieved",goalType:a,payload:{reward:1}}),n.goal(a,{componentId:e,variantId:r},1,0))},fireStep:(S,R,_)=>{n.track({projectId:o,componentId:e,variantId:r,eventType:"goal_achieved",goalType:S,payload:{reward:R}}),n.goal(S,{},R,_)}})},[n,c,r,o,e,l,a,s]),(0,k.useEffect)(()=>{if(s||!n||!r||!c)return;let S=Date.now();return(0,Qe.attachMicroSignalDetectors)((R,_={})=>{n.track({projectId:o,componentId:e,variantId:r,eventType:"micro_signal",payload:O({signalType:R},_)})},c,S)},[n,c,r,o,e,s]),(0,k.useEffect)(()=>{if(!E()||!n)return;let S=setTimeout(()=>{!u.current&&!qe.has(e)&&(qe.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(S)},[n,e]);let w=(0,k.useCallback)((S,R)=>{s||n==null||n.componentGoal(e,S!=null?S:a,R)},[n,e,a,s]),y=(0,k.useMemo)(()=>({ref:d,"data-sentient-id":e,"data-sentient-variant":r}),[d,e,r]);return{variant:r,value:m,bind:y,fireGoal:w}}var G=require("react");var et=require("react/jsx-runtime"),se=new Set;function Ze(e){var l;let t=C(),n=P(),o=(0,G.useRef)(null),i=(0,G.useMemo)(()=>Object.keys(e.arrangements),[e.id]),p=(0,G.useMemo)(()=>O({id:e.id,arms:i},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,i,e.baseline]),{arm:s}=oe(e.id,p);E()&&e.baseline!==void 0&&e.baseline!==i[0]&&!se.has(e.id+":baseline")&&(se.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${i[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let r=G.Children.toArray(e.children).filter(G.isValidElement),m=new Map;for(let a of r)m.set(String((l=a.key)!=null?l:"").replace(/^\.\$/,""),a);let c=e.arrangements[s],v=c!==void 0&&c.length===r.length&&c.every(a=>m.has(a));E()&&c!==void 0&&!v&&!se.has(e.id+":keys")&&(se.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${c.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let u=v?c.map(a=>m.get(a)):r;(0,G.useEffect)(()=>te({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let d=(0,G.useRef)(null);(0,G.useEffect)(()=>{!t||d.current===s||(d.current=s,W(t,n,e.id,s))},[t,n,e.id,s]);let g=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,G.useEffect)(()=>{if(!t||e.goal===void 0)return;let a=o.current;if(!a)return;let h=$(e.goal),f=!1;return M(a,D(e.goal),{fireGoal:()=>{f||(f=!0,t.componentGoal(e.id,h))},fireStep:(w,y)=>{t.componentGoal(e.id,w,{reward:y})}})},[t,e.id,g,s]),(0,et.jsx)("div",{ref:o,"data-sentient-id":e.id,"data-sentient-variant":s,children:u})}var ce=require("@sentientui/core");var Rt=["page","blocks","layoutOrder"],tt=new Map;function nt(e,t){tt.set(e,t)}function ue(e){return tt.get(e)}function it(e){var i,p;let t=(p=(i=e.content)!=null?i:ue(e.page))!=null?p:{},n={};for(let[s,r]of Object.entries(t))Rt.includes(s)||(n[s]=r);let o=H(O({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(o.layoutOrder=e.layoutOrder),o}function rt(e){return`<script type="application/ld+json">${de(e)}</script>`}function de(e){return JSON.stringify(O({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function ot(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,o]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(o,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
2
|
+
"use strict";var ut=Object.create;var J=Object.defineProperty,dt=Object.defineProperties,ft=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertyNames,fe=Object.getOwnPropertySymbols,mt=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var ge=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))pe.call(t,n)&&ge(e,n,t[n]);if(fe)for(var n of fe(t))vt.call(t,n)&&ge(e,n,t[n]);return e},H=(e,t)=>dt(e,gt(t));var yt=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pt(t))!pe.call(e,i)&&i!==n&&J(e,i,{get:()=>t[i],enumerable:!(o=ft(t,i))||o.enumerable});return e};var ve=(e,t,n)=>(n=e!=null?ut(mt(e)):{},me(t||!e||!e.__esModule?J(n,"default",{value:e,enumerable:!0}):n,e)),St=e=>me(J({},"__esModule",{value:!0}),e);var Et={};yt(Et,{Adaptive:()=>Be,AdaptiveGroup:()=>et,AdaptiveProvider:()=>Ge,AdaptiveText:()=>Ke,SentientPersonaScript:()=>He,buildAgentFeed:()=>rt,defineAgentContent:()=>it,detectSegment:()=>se.deriveSessionSegment,getAgentContent:()=>ae,renderAgentJsonLd:()=>ot,renderAgentJsonLdBody:()=>le,renderAgentMarkdown:()=>st,useAdaptive:()=>Ze,useAdaptiveApiBaseUrl:()=>Te,useAdaptiveGoal:()=>Ue,useAdaptiveTokens:()=>qe,useAssignment:()=>U,useInitialAssignments:()=>Z,useLayoutOrder:()=>Le,useSentient:()=>_});module.exports=St(Et);var x=require("react"),N=require("@sentientui/core");var ye=new Map,X=new Map;function Se(e,t){let n=X.get(e);return n||(n=new Set,X.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&X.delete(e)}}function he(e,t){ye.set(e,t);let n=X.get(e);if(n)for(let o of n)try{o(t)}catch(i){}}function be(e){var t;return(t=ye.get(e))!=null?t:null}var ht={on:!1,listeners:new Set};function we(){if(typeof window=="undefined")return ht;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function re(){return we().on}function Ae(e){let t=we().listeners;return t.add(e),()=>{t.delete(e)}}function xe(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,o,i)=>e.assign(t,n,o,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ke="sentient:overrides-changed";function q(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function j(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ke,e),()=>window.removeEventListener(ke,e))}function Ce(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}var bt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function W(){if(typeof window=="undefined")return bt;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function z(){W().version+=1;for(let e of W().listeners)e()}function Q(e){return W().components.set(e.id,e),z(),()=>{W().components.delete(e.id),z()}}function Y(e){return W().slots.set(e.id,e),z(),()=>{W().slots.delete(e.id),z()}}function _e(e){W().sections=[...e],z()}var Pe=require("react/jsx-runtime");function wt(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{let n=(0,N.detectDeviceClass)((e=navigator.userAgent)!=null?e:""),o=(0,N.detectTrafficSource)((t=document.referrer)!=null?t:"",window.location.origin);return`${n}:${o}`}catch(n){return"desktop:direct"}}var Re="https://api.sentient-ui.com/v1",T=(0,x.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialPersona:null,apiBaseUrl:Re,debug:!1});function Ge(e){var S,b;let[t,n]=(0,x.useState)(null),[o]=(0,x.useState)(()=>{var a;return(a=e.sessionSegment)!=null?a:wt()}),[i,c]=(0,x.useState)(re());(0,x.useEffect)(()=>Ae(()=>c(re())),[]),(0,x.useEffect)(()=>{if(e.consent===!1&&!e.preConsentBehavior){n(w=>(w==null||w.destroy(),null));return}let a={apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:o,consent:e.consent,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,localMode:e.localMode,initialSlots:e.initialSlots,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},p=!1,f=null,l=null,m=w=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:v})=>{p||(l=v(w,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:w})=>{p||(f=w(H(O({},a),{graph:!0})),n(f),m(f))}):(f=(0,N.init)(a),n(f),m(f)),()=>{p=!0,l==null||l(),f==null||f.dispose()}},[e.consent]),(0,x.useEffect)(()=>{if(!t)return;let a=!1,p=async()=>{if(a)return;let l;try{l=await t.fetchWeights()}catch(m){return}if(!a)for(let m of l){let w={componentId:m.componentId,updatedAt:m.updatedAt,variants:m.variants.map(v=>{var h;return{variantId:v.variantId,pulls:v.pulls,avgReward:(h=v.avgReward)!=null?h:0}})};he(m.componentId,w)}};p();let f=setInterval(()=>{p()},6e4);return()=>{a=!0,clearInterval(f)}},[t]);let s=(S=e.ssrFallback)!=null?S:"first",r=(b=e.apiBaseUrl)!=null?b:Re;(0,x.useEffect)(()=>{var a;typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production"||Ce({apiKey:e.apiKey,apiBaseUrl:r,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,r]),(0,x.useEffect)(()=>{e.initialLayoutOrder&&e.initialLayoutOrder.length>0&&_e(e.initialLayoutOrder)},[e.initialLayoutOrder]);let y=(0,x.useMemo)(()=>t&&i?xe(t):t,[t,i]),d=(0,x.useMemo)(()=>{var a,p,f,l,m;return{client:y,apiKey:e.apiKey,initialAssignments:(a=e.initialAssignments)!=null?a:{},sessionSegment:o,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(f=e.initialSlots)!=null?f:{},initialPersona:(l=e.initialPersona)!=null?l:null,apiBaseUrl:r,debug:(m=e.debug)!=null?m:!1}},[y,e.apiKey,e.initialAssignments,o,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialPersona,r,e.debug]);return(0,Pe.jsx)(T.Provider,{value:d,children:e.children})}function _(){return(0,x.useContext)(T).client}function P(){return(0,x.useContext)(T).apiKey}function Z(){return(0,x.useContext)(T).initialAssignments}function ee(){return(0,x.useContext)(T).sessionSegment}function Ee(){return(0,x.useContext)(T).ssrFallback}function te(){return(0,x.useContext)(T).onAssignment}function Oe(){return(0,x.useContext)(T).debug}function Le(){let e=(0,x.useContext)(T).initialLayoutOrder,t=(0,x.useSyncExternalStore)(j,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ie(){return(0,x.useContext)(T).initialSlots}function Te(){return(0,x.useContext)(T).apiBaseUrl}var k=require("react"),Fe=require("@sentientui/core");var I=require("react");function At(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;try{let o=new URLSearchParams(window.location.search);for(let i of o.getAll("sentient_variant")){let c=i.indexOf(":");if(c!==-1&&i.slice(0,c)===e)return i.slice(c+1)}}catch(o){}return null}function De(e,t){var o;let n=null;for(let i of e.variants)t.includes(i.variantId)&&(!n||i.avgReward>n.avgReward)&&(n={variantId:i.variantId,avgReward:i.avgReward});return(o=n==null?void 0:n.variantId)!=null?o:null}function U(e,t,n,o){let i=Z(),c=Ee(),s=_(),r=ee(),y=te(),d=Oe(),S=(0,I.useRef)(null);(0,I.useSyncExternalStore)(j,q,()=>0);let b=At(e),a=b&&t.includes(b)?b:null,p=(0,I.useRef)(null);(0,I.useEffect)(()=>{d&&a&&p.current!==a&&(p.current=a,console.info(`[sentient] override active: ${e} -> ${a}`))},[d,a,e]);let f=(()=>{var g,u;if(a)return{variantId:a,content:null,isLoading:!1};if(!s){let A=i[e];return A&&t.includes(A)?{variantId:A,content:null,isLoading:!1}:c==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1}:{variantId:null,content:null,isLoading:!0}}let v=s.getAssignment(e,r);if(v&&(t.includes(v.variantId)||v.content))return{variantId:v.variantId,content:(g=v.content)!=null?g:null,isLoading:!1};let h=be(e);if(h){let A=De(h,t);if(A)return{variantId:A,content:null,isLoading:!1}}return{variantId:(u=t[0])!=null?u:null,content:null,isLoading:!1}})(),[l,m]=(0,I.useState)(f),w=v=>{y&&S.current!==v&&(S.current=v,y(e,v))};return(0,I.useEffect)(()=>{var h;if(a||!s)return;let v=s.getAssignment(e,r);if(v&&(t.includes(v.variantId)||v.content)){m({variantId:v.variantId,content:(h=v.content)!=null?h:null,isLoading:!1}),w(v.variantId);return}m(g=>{var u;return g.variantId?g:{variantId:(u=t[0])!=null?u:null,content:null,isLoading:!1}})},[a,s,e,r]),(0,I.useEffect)(()=>{if(a||!s)return;let v=s.getAssignment(e,r);if(v&&t.includes(v.variantId))return;let h=!1;return s.assign(e,t,n,o).then(g=>{var u;h||g&&(!t.includes(g.variantId)&&!g.content||(m({variantId:g.variantId,content:(u=g.content)!=null?u:null,isLoading:!1}),w(g.variantId)))}),()=>{h=!0}},[a,s,e,r]),(0,I.useEffect)(()=>{if(!a&&s)return Se(e,v=>{var u;let h=s.getAssignment(e,r);if(h&&(t.includes(h.variantId)||h.content)){m({variantId:h.variantId,content:(u=h.content)!=null?u:null,isLoading:!1});return}let g=De(v,t);g&&m({variantId:g,content:null,isLoading:!1})})},[a,s,e,r]),a?{variantId:a,content:null,isLoading:!1,isOverride:!0}:l}function L(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function D(e){return typeof e=="string"?{type:"click"}:e}function $(e){return typeof e=="string"?e:e.type}function xt(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Me(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let o=e;for(;o&&o!==t;){if(xt(o))return!0;o=o.parentElement}return!1}function M(e,t,n){if(t.type==="weighted_composite"){let r=new Set,y=[];return t.steps.forEach(({goal:d,name:S,weight:b},a)=>{let p=()=>{r.has(a)||(r.add(a),n.fireStep(S,b,a))};if(d.type==="click"){let f=l=>{let m=l.target;m instanceof Element&&Me(m,e,d.selector)&&p()};e.addEventListener("click",f),y.push(()=>e.removeEventListener("click",f));return}if(d.type==="form_submit"){let f=l=>{l.target instanceof HTMLFormElement&&e.contains(l.target)&&p()};e.addEventListener("submit",f),y.push(()=>e.removeEventListener("submit",f));return}if(d.type==="scroll_depth"){let f=Math.max(0,Math.min(1,d.threshold)),l=new IntersectionObserver(m=>{for(let w of m)if(w.intersectionRatio>=f){p(),l.disconnect();break}},{threshold:[f]});l.observe(e),y.push(()=>l.disconnect())}}),()=>{for(let d of y)d()}}let o=t.type==="composite"?t.all:[t],i=new Set(o.map((r,y)=>y)),c=r=>{i.delete(r),i.size===0&&n.fireGoal()},s=[];return o.forEach((r,y)=>{if(r.type==="click"){let d=S=>{let b=S.target;b instanceof Element&&Me(b,e,r.selector)&&(t.type==="composite"?c(y):n.fireGoal())};e.addEventListener("click",d),s.push(()=>e.removeEventListener("click",d));return}if(r.type==="form_submit"){let d=S=>{S.target instanceof HTMLFormElement&&e.contains(S.target)&&(t.type==="composite"?c(y):n.fireGoal())};e.addEventListener("submit",d),s.push(()=>e.removeEventListener("submit",d));return}if(r.type==="scroll_depth"){let d=Math.max(0,Math.min(1,r.threshold)),S=new IntersectionObserver(b=>{for(let a of b)if(a.intersectionRatio>=d){t.type==="composite"?c(y):n.fireGoal(),S.disconnect();break}},{threshold:[d]});S.observe(e),s.push(()=>S.disconnect());return}}),()=>{for(let r of s)r()}}function B(e,t,n,o){e.track({projectId:t,componentId:n,variantId:o,eventType:"variant_assigned",payload:{}})}var We=require("react/jsx-runtime");function kt(e){var v;let t=_(),n=P(),o=(0,k.useMemo)(()=>Object.keys(e.variants),[e.variants]),{variantId:i,content:c,isOverride:s}=U(e.id,o,e.agentData,e.agentDataByVariant),r=(0,k.useRef)(null),[y,d]=(0,k.useState)(!1);(0,k.useEffect)(()=>{d(!0)},[]);let S=(0,k.useRef)(!1),b=(0,k.useRef)(new Set),a=(0,k.useRef)(null),p=typeof e.goal=="string"?e.goal:JSON.stringify(e.goal),f=(0,k.useMemo)(()=>D(e.goal),[p]),l=typeof e.goal=="string"?e.goal:f.type;if((0,k.useEffect)(()=>Q({id:e.id,variantIds:o,goal:l}),[e.id,o,l]),(0,k.useEffect)(()=>{s||!t||!i||!n||a.current!==i&&(a.current=i,B(t,n,e.id,i))},[t,i,n,e.id,s]),(0,k.useEffect)(()=>{S.current=!1,b.current=new Set},[i,f]),(0,k.useEffect)(()=>{if(s||!t||!i)return;let h=r.current;if(!h)return;let g=null,u=0,A=()=>{u=Date.now(),g=setTimeout(()=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-u}}),g=null},800)},R=()=>{g!==null&&(clearTimeout(g),g=null)};return h.addEventListener("mouseenter",A),h.addEventListener("mouseleave",R),()=>{h.removeEventListener("mouseenter",A),h.removeEventListener("mouseleave",R),g!==null&&clearTimeout(g)}},[t,i,n,e.id,s]),(0,k.useEffect)(()=>{if(s||!t||!i)return;let h=r.current;if(!h)return;let g=Date.now();return(0,Fe.attachMicroSignalDetectors)((u,A={})=>{var ce,ue,de;t.track({projectId:n,componentId:e.id,variantId:i,eventType:"micro_signal",payload:O({signalType:u},A)});let R=(ce=e.microSignalGoals)==null?void 0:ce[u];if(!R||b.current.has(u))return;b.current.add(u);let at=typeof R=="string"?R:R.name,lt=typeof R=="string"?1:(ue=R.weight)!=null?ue:1,ct=typeof R=="string"?0:(de=R.stepIndex)!=null?de:0;t.goal(at,O({signalType:u},A),lt,ct)},h,g)},[t,i,n,e.id,e.microSignalGoals,s]),(0,k.useEffect)(()=>{if(s||!t||!i)return;let h=r.current;if(h)return M(h,f,{fireGoal:()=>{S.current||(S.current=!0,t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:l,payload:{reward:1}}),t.goal(l,{componentId:e.id,variantId:i},1,0))},fireStep:(g,u,A)=>{t.track({projectId:n,componentId:e.id,variantId:i,eventType:"goal_achieved",goalType:g,payload:{reward:u}}),t.goal(g,{},u,A)}})},[t,i,n,e.id,f,l,s]),e.clientOnly&&(!y||!t)||!i)return null;let m=(v=e.variants[i])!=null?v:null,w=m===null?c:null;return L()&&m===null&&w===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${i}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,We.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":i,children:m!=null?m:w})}var Be=(0,k.memo)(kt,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.clientOnly!==t.clientOnly||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),o=Object.keys(t.variants);return n.length!==o.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});var G=require("react");var je=require("react/jsx-runtime");function Ke({id:e,default:t,component:n="span",className:o,goal:i}){let c=_(),s=P(),r=te(),y=ee(),d=(0,G.useRef)(null),S=(0,G.useRef)(null),[b,a]=(0,G.useState)(()=>{var g,u;return(u=(g=c==null?void 0:c.getAssignment(e,y))==null?void 0:g.content)!=null?u:null}),[p,f]=(0,G.useState)(()=>{var g,u;return(u=(g=c==null?void 0:c.getAssignment(e,y))==null?void 0:g.variantId)!=null?u:null});(0,G.useEffect)(()=>{var u;if(!c||((u=c.getAssignment(e,y))==null?void 0:u.content)!==void 0)return;let g=!1;return c.assign(e).then(A=>{if(!g){if(!A){L()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}f(A.variantId),A.content&&a(A.content)}}),()=>{g=!0}},[c,e,y]),(0,G.useEffect)(()=>{!c||!p||!s||d.current!==p&&(d.current=p,c.track({projectId:s,componentId:e,variantId:p,eventType:"variant_assigned",payload:{}}),r==null||r(e,p))},[c,p,s,e,r]);let l=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),m=(0,G.useMemo)(()=>i===void 0?null:D(i),[l]),w=i===void 0?null:typeof i=="string"?i:m.type,v=(0,G.useRef)(!1);return(0,G.useEffect)(()=>{v.current=!1},[p,l]),(0,G.useEffect)(()=>{if(!c||!p||!s||!m||!w)return;let g=S.current;if(g)return M(g,m,{fireGoal:()=>{v.current||(v.current=!0,c.track({projectId:s,componentId:e,variantId:p,eventType:"goal_achieved",goalType:w,payload:{reward:1}}),c.goal(w,{componentId:e,variantId:p},1,0))},fireStep:(u,A,R)=>{c.track({projectId:s,componentId:e,variantId:p,eventType:"goal_achieved",goalType:u,payload:{reward:A}}),c.goal(u,{},A,R)}})},[c,p,s,e,m,w]),(0,je.jsx)(n,{ref:g=>{S.current=g},className:o,children:b!=null?b:t})}var Ne=require("react");function Ue(e){let t=_();return(0,Ne.useCallback)((n,o)=>{t==null||t.componentGoal(e,n,o)},[t,e])}var Ve=require("@sentientui/core"),Je=require("@sentientui/policy"),ze=require("react/jsx-runtime");function $e(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ct(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+$e(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+$e((0,Je.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Ve.renderPrePaintScript)(e.apiKey)}function He(e){return(0,ze.jsx)("script",{"data-sentient-persona-script":"",dangerouslySetInnerHTML:{__html:Ct(e)}})}var F=require("react"),Xe=require("@sentientui/policy");var V=require("react"),K=require("@sentientui/core"),_t=require("@sentientui/policy");function ne(e,t){var S;(0,V.useSyncExternalStore)(j,q,()=>0);let n=_(),o=Ie(),[,i]=(0,V.useReducer)(b=>b+1,0),c=typeof window!="undefined"?(S=window.__sentient_slot_overrides)==null?void 0:S[e]:void 0,s=c===void 0?o[e]:void 0,r=c===void 0&&s===void 0&&n?n.getSlotResult(e):null,y=(n==null?void 0:n.isLocal)===!0&&c===void 0&&s===void 0&&r===null;if((0,V.useEffect)(()=>{if(!y||!n)return;let b=!1;return n.decide({slots:[t]}).then(a=>{!b&&a&&i()}),()=>{b=!0}},[n,e,y]),c!==void 0)return{result:c,arm:(0,K.armOfResult)(c),source:"override"};if(s!==void 0)return{result:s,arm:(0,K.armOfResult)(s),source:"preloaded"};if(r!==null)return{result:r,arm:(0,K.armOfResult)(r),source:"client"};let d=(0,K.baselineResultFor)(t);return{result:d,arm:(0,K.armOfResult)(d),source:"baseline"}}var oe=new Set;function Rt(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}function qe(e,t,n){let o=_(),i=P(),c=(0,F.useMemo)(()=>({id:e,dims:t}),[e]),{result:s,arm:r}=ne(e,c),y=(0,F.useMemo)(()=>typeof s=="string"?{}:s,[r]);if(L()&&!oe.has(e)){let a=(0,Xe.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([f,l])=>[f,[...l]]))}),p=Object.values(t).reduce((f,l)=>f*l.length,1);a.ok?p>4&&(oe.add(e),console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${p} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`)):(oe.add(e),console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${a.reason}. Serving baseline.`))}let d=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,F.useEffect)(()=>Y({id:e,dims:t}),[e]);let S=(0,F.useRef)(null);(0,F.useEffect)(()=>{!o||S.current===r||(S.current=r,B(o,i,e,r))},[o,i,e,r]),(0,F.useEffect)(()=>{if(!o||!(n!=null&&n.goal))return;let a=document.querySelector(`[data-sentient-slot="${Rt(e)}"]`);if(!a){L()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let p=$(n.goal),f=!1;return M(a,D(n.goal),{fireGoal:()=>{f||(f=!0,o.componentGoal(e,p))},fireStep:(l,m)=>{o.componentGoal(e,l,{reward:m})}})},[o,e,d,r]);let b=(0,F.useMemo)(()=>{let a={"data-sentient-slot":e};for(let[p,f]of Object.entries(y))a[`data-${p}`]=f;return a},[e,y]);return{tokens:y,props:b}}var C=require("react"),Ye=require("@sentientui/core");var Qe=new Set;function Ze(e,t){var g;if(L()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let n=_(),o=P(),i=(0,C.useMemo)(()=>Object.keys(t.variants),[e]),{variantId:c,isOverride:s}=U(e,i),r=(g=c!=null?c:i[0])!=null?g:"",y=t.variants[r],[d,S]=(0,C.useState)(null),b=(0,C.useRef)(null),a=(0,C.useCallback)(u=>{b.current=u,S(u)},[]),p=typeof t.goal=="string"?t.goal:JSON.stringify(t.goal),f=(0,C.useMemo)(()=>D(t.goal),[p]),l=$(t.goal);(0,C.useEffect)(()=>Q({id:e,variantIds:i,goal:l}),[e,i,l]);let m=(0,C.useRef)(null);(0,C.useEffect)(()=>{s||!n||!r||!d||m.current!==r&&(m.current=r,B(n,o,e,r))},[n,o,e,r,d,s]);let w=(0,C.useRef)(!1);(0,C.useEffect)(()=>{w.current=!1},[r,p]),(0,C.useEffect)(()=>{if(!s&&!(!n||!r||!d))return M(d,f,{fireGoal:()=>{w.current||(w.current=!0,n.track({projectId:o,componentId:e,variantId:r,eventType:"goal_achieved",goalType:l,payload:{reward:1}}),n.goal(l,{componentId:e,variantId:r},1,0))},fireStep:(u,A,R)=>{n.track({projectId:o,componentId:e,variantId:r,eventType:"goal_achieved",goalType:u,payload:{reward:A}}),n.goal(u,{},A,R)}})},[n,d,r,o,e,f,l,s]),(0,C.useEffect)(()=>{if(s||!n||!r||!d)return;let u=Date.now();return(0,Ye.attachMicroSignalDetectors)((A,R={})=>{n.track({projectId:o,componentId:e,variantId:r,eventType:"micro_signal",payload:O({signalType:A},R)})},d,u)},[n,d,r,o,e,s]),(0,C.useEffect)(()=>{if(!L()||!n)return;let u=setTimeout(()=>{!b.current&&!Qe.has(e)&&(Qe.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(u)},[n,e]);let v=(0,C.useCallback)((u,A)=>{s||n==null||n.componentGoal(e,u!=null?u:l,A)},[n,e,l,s]),h=(0,C.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":r}),[a,e,r]);return{variant:r,value:y,bind:h,fireGoal:v}}var E=require("react");var tt=require("react/jsx-runtime"),ie=new Set;function et(e){var f;let t=_(),n=P(),o=(0,E.useRef)(null),i=(0,E.useMemo)(()=>Object.keys(e.arrangements),[e.id]),c=(0,E.useMemo)(()=>O({id:e.id,arms:i},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,i,e.baseline]),{arm:s}=ne(e.id,c);L()&&e.baseline!==void 0&&e.baseline!==i[0]&&!ie.has(e.id+":baseline")&&(ie.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${i[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let r=E.Children.toArray(e.children).filter(E.isValidElement),y=new Map;for(let l of r)y.set(String((f=l.key)!=null?f:"").replace(/^\.\$/,""),l);let d=e.arrangements[s],S=d!==void 0&&d.length===r.length&&d.every(l=>y.has(l));L()&&d!==void 0&&!S&&!ie.has(e.id+":keys")&&(ie.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${d.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=S?d.map(l=>y.get(l)):r;(0,E.useEffect)(()=>Y({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let a=(0,E.useRef)(null);(0,E.useEffect)(()=>{!t||a.current===s||(a.current=s,B(t,n,e.id,s))},[t,n,e.id,s]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,E.useEffect)(()=>{if(!t||e.goal===void 0)return;let l=o.current;if(!l)return;let m=$(e.goal),w=!1;return M(l,D(e.goal),{fireGoal:()=>{w||(w=!0,t.componentGoal(e.id,m))},fireStep:(v,h)=>{t.componentGoal(e.id,v,{reward:h})}})},[t,e.id,p,s]),(0,tt.jsx)("div",{ref:o,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}var se=require("@sentientui/core");var Gt=["page","blocks","layoutOrder"],nt=new Map;function it(e,t){nt.set(e,t)}function ae(e){return nt.get(e)}function rt(e){var i,c;let t=(c=(i=e.content)!=null?i:ae(e.page))!=null?c:{},n={};for(let[s,r]of Object.entries(t))Gt.includes(s)||(n[s]=r);let o=H(O({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(o.layoutOrder=e.layoutOrder),o}function ot(e){return`<script type="application/ld+json">${le(e)}</script>`}function le(e){return JSON.stringify(O({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function st(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,o]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(o,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
|
-
`}0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveText,SentientPersonaScript,buildAgentFeed,defineAgentContent,detectSegment,getAgentContent,
|
|
4
|
+
`}0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveText,SentientPersonaScript,buildAgentFeed,defineAgentContent,detectSegment,getAgentContent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,useSentient});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|