@sentientui/react 0.36.0 → 0.36.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.
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- "use strict";var de=Object.create;var x=Object.defineProperty,ue=Object.defineProperties,fe=Object.getOwnPropertyDescriptor,ge=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,M=Object.getOwnPropertySymbols,me=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var K=(e,t,n)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))$.call(t,n)&&K(e,n,t[n]);if(M)for(var n of M(t))ve.call(t,n)&&K(e,n,t[n]);return e},k=(e,t)=>ue(e,ge(t));var ye=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},B=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pe(t))!$.call(e,r)&&r!==n&&x(e,r,{get:()=>t[r],enumerable:!(i=fe(t,r))||i.enumerable});return e};var E=(e,t,n)=>(n=e!=null?de(me(e)):{},B(t||!e||!e.__esModule?x(n,"default",{value:e,enumerable:!0}):n,e)),_e=e=>B(x({},"__esModule",{value:!0}),e);var Le={};ye(Le,{renderWithSentient:()=>Te});module.exports=_e(Le);var ae=require("@testing-library/react");var a=require("react"),O=require("@sentientui/core");var Se=new Map,he=new Map;function U(e,t){Se.set(e,t);let n=he.get(e);if(n)for(let i of n)try{i(t)}catch(r){}}var we={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return we;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function V(){return j().on}function z(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function H(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,r)=>e.assign(t,n,i,r),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var be="sentient:overrides-changed";function R(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(be))}function J(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function A(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ce={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function T(){if(typeof window=="undefined")return Ce;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 xe(){T().version+=1;for(let e of T().listeners)e()}function L(e){A()&&(T().sections=[...e],xe())}var q="0.36.0",D=q!=="0.0.0-dev"?{name:"react",version:q}:void 0;function Re(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function b(e,t){Re()[e]=t}function X(e){window.__sentient_vocabulary_override=e}function ke(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function C(e,t){ke()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",Z="sentient_refresh_region",G="sentient-cell-preview-bar",w="__preview__",Ee=null;function ee(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(G))return;let t,n,i;try{let u=new URLSearchParams(window.location.search);t=u.get(Q),n=u.get(Y),i=u.get(Z)}catch(u){return}if(t&&i){Ee={slotId:i,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},b(i,{kind:"arms"}),C(i,w),R();return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let o=n.slice(0,r),m=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(o)}&persona=${encodeURIComponent(m)}`,{headers:{authorization:`Bearer ${t}`}}).then(async u=>{if(!u.ok){P(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let l=await u.json();if(l.vocabulary&&Array.isArray(l.vocabulary.entries)&&X(l.vocabulary),l.compose!=null)b(o,{kind:"arms",compose:{[w]:l.compose}}),C(o,w);else if(l.edits!=null&&typeof l.skeletonFp=="string"&&Array.isArray(l.leafToNode))b(o,{kind:"arms",edits:{edits:l.edits,fp:l.skeletonFp,leafToNode:l.leafToNode}}),C(o,w);else if(l.blocks!=null)b(o,{kind:"arms",blocks:{[w]:l.blocks}}),C(o,w);else if(l.content!=null)b(o,{kind:"arms",content:l.content}),C(o,w);else{P("Nothing to preview in that square yet.");return}R(),P(`Previewing \u201C${l.slotName}\u201D for ${l.personaDisplay}${l.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${o}"]`))==null||y.scrollIntoView({block:"center"})}catch(I){}},300)}).catch(()=>P("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function P(e){var r;if(document.getElementById(G))return;let t=document.createElement("div");t.id=G,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{let o=new URL(window.location.href);o.searchParams.delete(Q),o.searchParams.delete(Y),o.searchParams.delete(Z),window.location.assign(o.toString())},t.append(n,i),((r=document.body)!=null?r:document.documentElement).append(t)}var Ae="sentient_editor",te=!1;function ne(e){if(te||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(Ae)}catch(r){return}if(!t)return;te=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?i():window.addEventListener("load",i,{once:!0})}var re=require("react/jsx-runtime");function Pe(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,O.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ie="https://api.sentient-ui.com/v1",Oe=(0,a.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:ie,debug:!1});function Ie(e){let[t,n]=(0,a.useState)(null),i=(0,a.useRef)(e);i.current=e;let r=e===void 0?"":typeof e=="string"?e:JSON.stringify(k(g({},e),{check:typeof e.check}));return(0,a.useEffect)(()=>{let o=i.current;if(o===void 0||typeof window=="undefined")return;let m,_=!1;return import("@sentientui/core/consent").then(({consentWatcher:u})=>{if(_)return;let l=u(typeof o=="object"&&o.cmp===void 0&&o.check?k(g({},o),{check:()=>i.current.check()}):o);n(l.read()),m=l.subscribe(()=>n(l.read()))}),()=>{_=!0,m==null||m()}},[r]),t}function oe(e){var W,F;let[t,n]=(0,a.useState)(null),[i]=(0,a.useState)(()=>{var s;return(s=e.sessionSegment)!=null?s:Pe()}),[r,o]=(0,a.useState)(V());(0,a.useEffect)(()=>z(()=>o(V())),[]),(0,a.useEffect)(()=>{ee(e.apiBaseUrl),ne(e.apiBaseUrl)},[]);let m=Ie(e.consentFrom),_=e.consentFrom?m!=null?m:e.consent===!0:e.consent,u=(0,a.useRef)(null);(0,a.useEffect)(()=>{var S;if(_===!1&&!e.preConsentBehavior){(S=u.current)==null||S.destroy(),u.current=null,n(null);return}let s=g({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:_,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),f=!1,c=null,d=null,p=v=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:h})=>{f||(d=h(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{f||(c=v(k(g({},s),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u.current=c,n(c),p(c))}):(c=(0,O.init)(s),u.current=c,n(c),p(c)),()=>{f=!0,d==null||d(),c==null||c.dispose()}},[_]),(0,a.useEffect)(()=>{if(!t)return;let s=!1,f=async()=>{if(s)return;let d;try{d=await t.fetchWeights()}catch(p){return}if(!s)for(let p of d){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(v=>{var h;return{variantId:v.variantId,pulls:v.pulls,avgReward:(h=v.avgReward)!=null?h:0}})};U(p.componentId,S)}};f();let c=setInterval(()=>{f()},6e4);return()=>{s=!0,clearInterval(c)}},[t]);let l=(W=e.ssrFallback)!=null?W:"first",y=((F=e.apiBaseUrl)!=null?F:ie).replace(/\/$/,""),I=(0,a.useRef)(null);(0,a.useEffect)(()=>{var c;if(typeof process!="undefined"&&((c=process.env)==null?void 0:c.NODE_ENV)==="production")return;let s={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:y},f=I.current;if(I.current=s,f!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[d],s[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,y]),(0,a.useEffect)(()=>{var s;typeof process!="undefined"&&((s=process.env)==null?void 0:s.NODE_ENV)==="production"||J({apiKey:e.apiKey,apiBaseUrl:y,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,y]),(0,a.useEffect)(()=>{let s=e.initialLayoutOrder;if(s&&s.length>0){L(s);return}e.declaredSections&&e.declaredSections.length>0&&L(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,a.useEffect)(()=>{if(!A())return;let s=e.declaredSections;if(!s||s.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),c=s.filter(d=>!f.has(d));c.length>0&&console.warn(`[SentientUI] Declared section${c.length>1?"s":""} ${c.map(d=>`"${d}"`).join(", ")} ${c.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let N=(0,a.useMemo)(()=>t&&r?H(t):t,[t,r]),ce=(0,a.useMemo)(()=>{var s,f,c,d,p,S,v,h;return{client:N,apiKey:e.apiKey,initialAssignments:(s=e.initialAssignments)!=null?s:{},sessionSegment:i,ssrFallback:l,onAssignment:e.onAssignment,initialLayoutOrder:(f=e.initialLayoutOrder)!=null?f:null,initialSlots:(c=e.initialSlots)!=null?c:{},initialSlotConfig:(d=e.initialSlotConfig)!=null?d:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialVocabulary:(S=e.initialVocabulary)!=null?S:null,initialPersona:(v=e.initialPersona)!=null?v:null,apiBaseUrl:y,debug:(h=e.debug)!=null?h:!1}},[N,e.apiKey,e.initialAssignments,i,l,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,y,e.debug]);return(0,re.jsx)(Oe.Provider,{value:ce,children:e.children})}function Ve(e){return e<.3?"low":e<.7?"medium":"high"}function se(e={}){var n,i,r;let t=window;if(t.__sentient_overrides=g({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=g({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=g({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let o=document.documentElement;o.setAttribute("data-sentient-persona",e.persona),o.setAttribute("data-sentient-confidence",Ve((r=e.confidence)!=null?r:1))}catch(o){}}else delete t.__sentient_persona_override;R()}var le=require("react/jsx-runtime");function Te(e,t={},n){return se(t),(0,ae.render)((0,le.jsx)(oe,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
2
+ "use strict";var de=Object.create;var x=Object.defineProperty,ue=Object.defineProperties,fe=Object.getOwnPropertyDescriptor,ge=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,M=Object.getOwnPropertySymbols,me=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var K=(e,t,n)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))$.call(t,n)&&K(e,n,t[n]);if(M)for(var n of M(t))ve.call(t,n)&&K(e,n,t[n]);return e},k=(e,t)=>ue(e,ge(t));var ye=(e,t)=>{for(var n in t)x(e,n,{get:t[n],enumerable:!0})},B=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pe(t))!$.call(e,r)&&r!==n&&x(e,r,{get:()=>t[r],enumerable:!(i=fe(t,r))||i.enumerable});return e};var E=(e,t,n)=>(n=e!=null?de(me(e)):{},B(t||!e||!e.__esModule?x(n,"default",{value:e,enumerable:!0}):n,e)),_e=e=>B(x({},"__esModule",{value:!0}),e);var Le={};ye(Le,{renderWithSentient:()=>Te});module.exports=_e(Le);var ae=require("@testing-library/react");var a=require("react"),O=require("@sentientui/core");var Se=new Map,he=new Map;function U(e,t){Se.set(e,t);let n=he.get(e);if(n)for(let i of n)try{i(t)}catch(r){}}var we={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return we;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function V(){return j().on}function z(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function H(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,r)=>e.assign(t,n,i,r),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var be="sentient:overrides-changed";function R(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(be))}function J(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function A(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ce={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function T(){if(typeof window=="undefined")return Ce;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 xe(){T().version+=1;for(let e of T().listeners)e()}function L(e){A()&&(T().sections=[...e],xe())}var q="0.36.1",D=q!=="0.0.0-dev"?{name:"react",version:q}:void 0;function Re(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function b(e,t){Re()[e]=t}function X(e){window.__sentient_vocabulary_override=e}function ke(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function C(e,t){ke()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",Z="sentient_refresh_region",G="sentient-cell-preview-bar",w="__preview__",Ee=null;function ee(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(G))return;let t,n,i;try{let u=new URLSearchParams(window.location.search);t=u.get(Q),n=u.get(Y),i=u.get(Z)}catch(u){return}if(t&&i){Ee={slotId:i,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},b(i,{kind:"arms"}),C(i,w),R();return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let o=n.slice(0,r),m=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(o)}&persona=${encodeURIComponent(m)}`,{headers:{authorization:`Bearer ${t}`}}).then(async u=>{if(!u.ok){P(u.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let l=await u.json();if(l.vocabulary&&Array.isArray(l.vocabulary.entries)&&X(l.vocabulary),l.compose!=null)b(o,{kind:"arms",compose:{[w]:l.compose}}),C(o,w);else if(l.edits!=null&&typeof l.skeletonFp=="string"&&Array.isArray(l.leafToNode))b(o,{kind:"arms",edits:{edits:l.edits,fp:l.skeletonFp,leafToNode:l.leafToNode}}),C(o,w);else if(l.blocks!=null)b(o,{kind:"arms",blocks:{[w]:l.blocks}}),C(o,w);else if(l.content!=null)b(o,{kind:"arms",content:l.content}),C(o,w);else{P("Nothing to preview in that square yet.");return}R(),P(`Previewing \u201C${l.slotName}\u201D for ${l.personaDisplay}${l.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${o}"]`))==null||y.scrollIntoView({block:"center"})}catch(I){}},300)}).catch(()=>P("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function P(e){var r;if(document.getElementById(G))return;let t=document.createElement("div");t.id=G,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{let o=new URL(window.location.href);o.searchParams.delete(Q),o.searchParams.delete(Y),o.searchParams.delete(Z),window.location.assign(o.toString())},t.append(n,i),((r=document.body)!=null?r:document.documentElement).append(t)}var Ae="sentient_editor",te=!1;function ne(e){if(te||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(Ae)}catch(r){return}if(!t)return;te=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?i():window.addEventListener("load",i,{once:!0})}var re=require("react/jsx-runtime");function Pe(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,O.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ie="https://api.sentient-ui.com/v1",Oe=(0,a.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:ie,debug:!1});function Ie(e){let[t,n]=(0,a.useState)(null),i=(0,a.useRef)(e);i.current=e;let r=e===void 0?"":typeof e=="string"?e:JSON.stringify(k(g({},e),{check:typeof e.check}));return(0,a.useEffect)(()=>{let o=i.current;if(o===void 0||typeof window=="undefined")return;let m,_=!1;return import("@sentientui/core/consent").then(({consentWatcher:u})=>{if(_)return;let l=u(typeof o=="object"&&o.cmp===void 0&&o.check?k(g({},o),{check:()=>i.current.check()}):o);n(l.read()),m=l.subscribe(()=>n(l.read()))}),()=>{_=!0,m==null||m()}},[r]),t}function oe(e){var W,F;let[t,n]=(0,a.useState)(null),[i]=(0,a.useState)(()=>{var s;return(s=e.sessionSegment)!=null?s:Pe()}),[r,o]=(0,a.useState)(V());(0,a.useEffect)(()=>z(()=>o(V())),[]),(0,a.useEffect)(()=>{ee(e.apiBaseUrl),ne(e.apiBaseUrl)},[]);let m=Ie(e.consentFrom),_=e.consentFrom?m!=null?m:e.consent===!0:e.consent,u=(0,a.useRef)(null);(0,a.useEffect)(()=>{var S;if(_===!1&&!e.preConsentBehavior){(S=u.current)==null||S.destroy(),u.current=null,n(null);return}let s=g({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:_,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),f=!1,c=null,d=null,p=v=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:h})=>{f||(d=h(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{f||(c=v(k(g({},s),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u.current=c,n(c),p(c))}):(c=(0,O.init)(s),u.current=c,n(c),p(c)),()=>{f=!0,d==null||d(),c==null||c.dispose()}},[_]),(0,a.useEffect)(()=>{if(!t)return;let s=!1,f=async()=>{if(s)return;let d;try{d=await t.fetchWeights()}catch(p){return}if(!s)for(let p of d){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(v=>{var h;return{variantId:v.variantId,pulls:v.pulls,avgReward:(h=v.avgReward)!=null?h:0}})};U(p.componentId,S)}};f();let c=setInterval(()=>{f()},6e4);return()=>{s=!0,clearInterval(c)}},[t]);let l=(W=e.ssrFallback)!=null?W:"first",y=((F=e.apiBaseUrl)!=null?F:ie).replace(/\/$/,""),I=(0,a.useRef)(null);(0,a.useEffect)(()=>{var c;if(typeof process!="undefined"&&((c=process.env)==null?void 0:c.NODE_ENV)==="production")return;let s={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:y},f=I.current;if(I.current=s,f!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[d],s[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,y]),(0,a.useEffect)(()=>{var s;typeof process!="undefined"&&((s=process.env)==null?void 0:s.NODE_ENV)==="production"||J({apiKey:e.apiKey,apiBaseUrl:y,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,y]),(0,a.useEffect)(()=>{let s=e.initialLayoutOrder;if(s&&s.length>0){L(s);return}e.declaredSections&&e.declaredSections.length>0&&L(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,a.useEffect)(()=>{if(!A())return;let s=e.declaredSections;if(!s||s.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),c=s.filter(d=>!f.has(d));c.length>0&&console.warn(`[SentientUI] Declared section${c.length>1?"s":""} ${c.map(d=>`"${d}"`).join(", ")} ${c.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let N=(0,a.useMemo)(()=>t&&r?H(t):t,[t,r]),ce=(0,a.useMemo)(()=>{var s,f,c,d,p,S,v,h;return{client:N,apiKey:e.apiKey,initialAssignments:(s=e.initialAssignments)!=null?s:{},sessionSegment:i,ssrFallback:l,onAssignment:e.onAssignment,initialLayoutOrder:(f=e.initialLayoutOrder)!=null?f:null,initialSlots:(c=e.initialSlots)!=null?c:{},initialSlotConfig:(d=e.initialSlotConfig)!=null?d:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialVocabulary:(S=e.initialVocabulary)!=null?S:null,initialPersona:(v=e.initialPersona)!=null?v:null,apiBaseUrl:y,debug:(h=e.debug)!=null?h:!1}},[N,e.apiKey,e.initialAssignments,i,l,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,y,e.debug]);return(0,re.jsx)(Oe.Provider,{value:ce,children:e.children})}function Ve(e){return e<.3?"low":e<.7?"medium":"high"}function se(e={}){var n,i,r;let t=window;if(t.__sentient_overrides=g({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=g({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=g({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let o=document.documentElement;o.setAttribute("data-sentient-persona",e.persona),o.setAttribute("data-sentient-confidence",Ve((r=e.confidence)!=null?r:1))}catch(o){}}else delete t.__sentient_persona_override;R()}var le=require("react/jsx-runtime");function Te(e,t={},n){return se(t),(0,ae.render)((0,le.jsx)(oe,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
3
3
  //# sourceMappingURL=react.js.map
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- var re=Object.defineProperty,se=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var M=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&M(e,n,t[n]);if(F)for(var n of F(t))ce.call(t,n)&&M(e,n,t[n]);return e},R=(e,t)=>se(e,ae(t));import{render as Ae}from"@testing-library/react";import{createContext as he,useContext as Xe,useEffect as y,useMemo as ee,useRef as D,useState as A,useSyncExternalStore as Qe}from"react";import{deriveSessionSegment as we,init as be}from"@sentientui/core";var de=new Map,ue=new Map;function K(e,t){de.set(e,t);let n=ue.get(e);if(n)for(let i of n)try{i(t)}catch(l){}}var fe={on:!1,listeners:new Set};function $(){if(typeof window=="undefined")return fe;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function O(){return $().on}function B(e){let t=$().listeners;return t.add(e),()=>{t.delete(e)}}function U(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,l)=>e.assign(t,n,i,l),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ge="sentient:overrides-changed";function x(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(ge))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function k(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var pe={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function I(){if(typeof window=="undefined")return pe;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 me(){I().version+=1;for(let e of I().listeners)e()}function V(e){k()&&(I().sections=[...e],me())}var z="0.36.0",T=z!=="0.0.0-dev"?{name:"react",version:z}:void 0;function ve(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function b(e,t){ve()[e]=t}function H(e){window.__sentient_vocabulary_override=e}function ye(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function C(e,t){ye()[e]=t}var J="sentient_editor",q="sentient_preview_cell",X="sentient_refresh_region",L="sentient-cell-preview-bar",w="__preview__",_e=null;function Q(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(L))return;let t,n,i;try{let d=new URLSearchParams(window.location.search);t=d.get(J),n=d.get(q),i=d.get(X)}catch(d){return}if(t&&i){_e={slotId:i,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},b(i,{kind:"arms"}),C(i,w),x();return}if(!t||!n)return;let l=n.lastIndexOf("~");if(l<=0)return;let o=n.slice(0,l),p=n.slice(l+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(o)}&persona=${encodeURIComponent(p)}`,{headers:{authorization:`Bearer ${t}`}}).then(async d=>{if(!d.ok){E(d.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await d.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&H(s.vocabulary),s.compose!=null)b(o,{kind:"arms",compose:{[w]:s.compose}}),C(o,w);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))b(o,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),C(o,w);else if(s.blocks!=null)b(o,{kind:"arms",blocks:{[w]:s.blocks}}),C(o,w);else if(s.content!=null)b(o,{kind:"arms",content:s.content}),C(o,w);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var v;try{(v=document.querySelector(`[data-sentient-slot="${o}"]`))==null||v.scrollIntoView({block:"center"})}catch(P){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var l;if(document.getElementById(L))return;let t=document.createElement("div");t.id=L,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{let o=new URL(window.location.href);o.searchParams.delete(J),o.searchParams.delete(q),o.searchParams.delete(X),window.location.assign(o.toString())},t.append(n,i),((l=document.body)!=null?l:document.documentElement).append(t)}var Se="sentient_editor",Y=!1;function Z(e){if(Y||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(Se)}catch(l){return}if(!t)return;Y=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:l})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(l(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?i():window.addEventListener("load",i,{once:!0})}import{jsx as ke}from"react/jsx-runtime";function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return we({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var te="https://api.sentient-ui.com/v1",xe=he({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:te,debug:!1});function Re(e){let[t,n]=A(null),i=D(e);i.current=e;let l=e===void 0?"":typeof e=="string"?e:JSON.stringify(R(f({},e),{check:typeof e.check}));return y(()=>{let o=i.current;if(o===void 0||typeof window=="undefined")return;let p,_=!1;return import("@sentientui/core/consent").then(({consentWatcher:d})=>{if(_)return;let s=d(typeof o=="object"&&o.cmp===void 0&&o.check?R(f({},o),{check:()=>i.current.check()}):o);n(s.read()),p=s.subscribe(()=>n(s.read()))}),()=>{_=!0,p==null||p()}},[l]),t}function ne(e){var N,W;let[t,n]=A(null),[i]=A(()=>{var r;return(r=e.sessionSegment)!=null?r:Ce()}),[l,o]=A(O());y(()=>B(()=>o(O())),[]),y(()=>{Q(e.apiBaseUrl),Z(e.apiBaseUrl)},[]);let p=Re(e.consentFrom),_=e.consentFrom?p!=null?p:e.consent===!0:e.consent,d=D(null);y(()=>{var S;if(_===!1&&!e.preConsentBehavior){(S=d.current)==null||S.destroy(),d.current=null,n(null);return}let r=f({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:_,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},T?{sdk:T}:{}),u=!1,a=null,c=null,g=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:h})=>{u||(c=h(m,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:m})=>{u||(a=m(R(f({},r),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),d.current=a,n(a),g(a))}):(a=be(r),d.current=a,n(a),g(a)),()=>{u=!0,c==null||c(),a==null||a.dispose()}},[_]),y(()=>{if(!t)return;let r=!1,u=async()=>{if(r)return;let c;try{c=await t.fetchWeights()}catch(g){return}if(!r)for(let g of c){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(m=>{var h;return{variantId:m.variantId,pulls:m.pulls,avgReward:(h=m.avgReward)!=null?h:0}})};K(g.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{r=!0,clearInterval(a)}},[t]);let s=(N=e.ssrFallback)!=null?N:"first",v=((W=e.apiBaseUrl)!=null?W:te).replace(/\/$/,""),P=D(null);y(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:v},u=P.current;if(P.current=r,u!==null)for(let c of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[c],r[c])||console.warn(`[sentient] AdaptiveProvider: \`${c}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,v]),y(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:v,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,v]),y(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){V(r);return}e.declaredSections&&e.declaredSections.length>0&&V(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),y(()=>{if(!k())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),c=>c.getAttribute("data-sentient-id"))),a=r.filter(c=>!u.has(c));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(c=>`"${c}"`).join(", ")} ${a.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let G=ee(()=>t&&l?U(t):t,[t,l]),oe=ee(()=>{var r,u,a,c,g,S,m,h;return{client:G,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},sessionSegment:i,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(c=e.initialSlotConfig)!=null?c:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialVocabulary:(S=e.initialVocabulary)!=null?S:null,initialPersona:(m=e.initialPersona)!=null?m:null,apiBaseUrl:v,debug:(h=e.debug)!=null?h:!1}},[G,e.apiKey,e.initialAssignments,i,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,v,e.debug]);return ke(xe.Provider,{value:oe,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,i,l;let t=window;if(t.__sentient_overrides=f({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=f({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=f({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let o=document.documentElement;o.setAttribute("data-sentient-persona",e.persona),o.setAttribute("data-sentient-confidence",Ee((l=e.confidence)!=null?l:1))}catch(o){}}else delete t.__sentient_persona_override;x()}import{jsx as Pe}from"react/jsx-runtime";function vt(e,t={},n){return ie(t),Ae(Pe(ne,{apiKey:"pk_test",consent:!1,children:e}),n)}export{vt as renderWithSentient};
2
+ var re=Object.defineProperty,se=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var M=(e,t,n)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&M(e,n,t[n]);if(F)for(var n of F(t))ce.call(t,n)&&M(e,n,t[n]);return e},R=(e,t)=>se(e,ae(t));import{render as Ae}from"@testing-library/react";import{createContext as he,useContext as Xe,useEffect as y,useMemo as ee,useRef as D,useState as A,useSyncExternalStore as Qe}from"react";import{deriveSessionSegment as we,init as be}from"@sentientui/core";var de=new Map,ue=new Map;function K(e,t){de.set(e,t);let n=ue.get(e);if(n)for(let i of n)try{i(t)}catch(l){}}var fe={on:!1,listeners:new Set};function $(){if(typeof window=="undefined")return fe;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function O(){return $().on}function B(e){let t=$().listeners;return t.add(e),()=>{t.delete(e)}}function U(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,l)=>e.assign(t,n,i,l),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ge="sentient:overrides-changed";function x(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(ge))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function k(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var pe={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function I(){if(typeof window=="undefined")return pe;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 me(){I().version+=1;for(let e of I().listeners)e()}function V(e){k()&&(I().sections=[...e],me())}var z="0.36.1",T=z!=="0.0.0-dev"?{name:"react",version:z}:void 0;function ve(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function b(e,t){ve()[e]=t}function H(e){window.__sentient_vocabulary_override=e}function ye(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function C(e,t){ye()[e]=t}var J="sentient_editor",q="sentient_preview_cell",X="sentient_refresh_region",L="sentient-cell-preview-bar",w="__preview__",_e=null;function Q(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(L))return;let t,n,i;try{let d=new URLSearchParams(window.location.search);t=d.get(J),n=d.get(q),i=d.get(X)}catch(d){return}if(t&&i){_e={slotId:i,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},b(i,{kind:"arms"}),C(i,w),x();return}if(!t||!n)return;let l=n.lastIndexOf("~");if(l<=0)return;let o=n.slice(0,l),p=n.slice(l+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(o)}&persona=${encodeURIComponent(p)}`,{headers:{authorization:`Bearer ${t}`}}).then(async d=>{if(!d.ok){E(d.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await d.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&H(s.vocabulary),s.compose!=null)b(o,{kind:"arms",compose:{[w]:s.compose}}),C(o,w);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))b(o,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),C(o,w);else if(s.blocks!=null)b(o,{kind:"arms",blocks:{[w]:s.blocks}}),C(o,w);else if(s.content!=null)b(o,{kind:"arms",content:s.content}),C(o,w);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var v;try{(v=document.querySelector(`[data-sentient-slot="${o}"]`))==null||v.scrollIntoView({block:"center"})}catch(P){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var l;if(document.getElementById(L))return;let t=document.createElement("div");t.id=L,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{let o=new URL(window.location.href);o.searchParams.delete(J),o.searchParams.delete(q),o.searchParams.delete(X),window.location.assign(o.toString())},t.append(n,i),((l=document.body)!=null?l:document.documentElement).append(t)}var Se="sentient_editor",Y=!1;function Z(e){if(Y||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(Se)}catch(l){return}if(!t)return;Y=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:l})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(l(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?i():window.addEventListener("load",i,{once:!0})}import{jsx as ke}from"react/jsx-runtime";function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return we({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var te="https://api.sentient-ui.com/v1",xe=he({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:te,debug:!1});function Re(e){let[t,n]=A(null),i=D(e);i.current=e;let l=e===void 0?"":typeof e=="string"?e:JSON.stringify(R(f({},e),{check:typeof e.check}));return y(()=>{let o=i.current;if(o===void 0||typeof window=="undefined")return;let p,_=!1;return import("@sentientui/core/consent").then(({consentWatcher:d})=>{if(_)return;let s=d(typeof o=="object"&&o.cmp===void 0&&o.check?R(f({},o),{check:()=>i.current.check()}):o);n(s.read()),p=s.subscribe(()=>n(s.read()))}),()=>{_=!0,p==null||p()}},[l]),t}function ne(e){var N,W;let[t,n]=A(null),[i]=A(()=>{var r;return(r=e.sessionSegment)!=null?r:Ce()}),[l,o]=A(O());y(()=>B(()=>o(O())),[]),y(()=>{Q(e.apiBaseUrl),Z(e.apiBaseUrl)},[]);let p=Re(e.consentFrom),_=e.consentFrom?p!=null?p:e.consent===!0:e.consent,d=D(null);y(()=>{var S;if(_===!1&&!e.preConsentBehavior){(S=d.current)==null||S.destroy(),d.current=null,n(null);return}let r=f({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:_,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},T?{sdk:T}:{}),u=!1,a=null,c=null,g=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:h})=>{u||(c=h(m,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:m})=>{u||(a=m(R(f({},r),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),d.current=a,n(a),g(a))}):(a=be(r),d.current=a,n(a),g(a)),()=>{u=!0,c==null||c(),a==null||a.dispose()}},[_]),y(()=>{if(!t)return;let r=!1,u=async()=>{if(r)return;let c;try{c=await t.fetchWeights()}catch(g){return}if(!r)for(let g of c){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(m=>{var h;return{variantId:m.variantId,pulls:m.pulls,avgReward:(h=m.avgReward)!=null?h:0}})};K(g.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{r=!0,clearInterval(a)}},[t]);let s=(N=e.ssrFallback)!=null?N:"first",v=((W=e.apiBaseUrl)!=null?W:te).replace(/\/$/,""),P=D(null);y(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:v},u=P.current;if(P.current=r,u!==null)for(let c of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[c],r[c])||console.warn(`[sentient] AdaptiveProvider: \`${c}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,v]),y(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:v,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,v]),y(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){V(r);return}e.declaredSections&&e.declaredSections.length>0&&V(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),y(()=>{if(!k())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),c=>c.getAttribute("data-sentient-id"))),a=r.filter(c=>!u.has(c));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(c=>`"${c}"`).join(", ")} ${a.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let G=ee(()=>t&&l?U(t):t,[t,l]),oe=ee(()=>{var r,u,a,c,g,S,m,h;return{client:G,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},sessionSegment:i,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(c=e.initialSlotConfig)!=null?c:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialVocabulary:(S=e.initialVocabulary)!=null?S:null,initialPersona:(m=e.initialPersona)!=null?m:null,apiBaseUrl:v,debug:(h=e.debug)!=null?h:!1}},[G,e.apiKey,e.initialAssignments,i,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,v,e.debug]);return ke(xe.Provider,{value:oe,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,i,l;let t=window;if(t.__sentient_overrides=f({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=f({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=f({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let o=document.documentElement;o.setAttribute("data-sentient-persona",e.persona),o.setAttribute("data-sentient-confidence",Ee((l=e.confidence)!=null?l:1))}catch(o){}}else delete t.__sentient_persona_override;x()}import{jsx as Pe}from"react/jsx-runtime";function vt(e,t={},n){return ie(t),Ae(Pe(ne,{apiKey:"pk_test",consent:!1,children:e}),n)}export{vt as renderWithSentient};
3
3
  //# sourceMappingURL=react.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.36.0",
3
+ "version": "0.36.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -75,8 +75,8 @@
75
75
  "llms.txt"
76
76
  ],
77
77
  "dependencies": {
78
- "@sentientui/core": "0.35.0",
79
- "@sentientui/policy": "0.12.0"
78
+ "@sentientui/policy": "0.12.0",
79
+ "@sentientui/core": "0.35.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@testing-library/react": ">=14.0.0",
package/dist/server.d.cts DELETED
@@ -1,103 +0,0 @@
1
- import * as _sentientui_core_server from '@sentientui/core/server';
2
- import { ServerAssignments } from '@sentientui/core/server';
3
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie } from '@sentientui/core/server';
4
-
5
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
6
- type LoadAdaptiveAssignmentsResult = {
7
- assignments: ServerAssignments;
8
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
9
- sessionId: string;
10
- };
11
- type LoadAdaptiveAssignmentsOptions = {
12
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
13
- cookies: {
14
- get(name: string): {
15
- value: string;
16
- } | undefined;
17
- };
18
- apiKey: string;
19
- baseUrl: string;
20
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
21
- createSessionId?: () => string;
22
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
23
- origin?: string;
24
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
25
- userAgent?: string;
26
- /** From Next.js `headers().get('referer')`. */
27
- referer?: string;
28
- /**
29
- * `utm_*` params from the landing URL. The Referer header never carries the
30
- * page's OWN query string, so without this the SSR-minted session has no
31
- * campaign attribution until the client SDK hydrates and re-upserts.
32
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
33
- */
34
- utmParams?: Record<string, string>;
35
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
36
- clickIds?: Record<string, string>;
37
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
38
- doNotTrack?: boolean;
39
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
40
- timeoutMs?: number;
41
- /**
42
- * Declared persona — the role your app already knows for this visitor (e.g.
43
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
44
- * project's persona vocabulary; unrecognized values are ignored server-side.
45
- * Never a user id or email.
46
- */
47
- persona?: string;
48
- };
49
- /**
50
- * Fetches bandit assignments on the server for SEO-safe HTML.
51
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
52
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
53
- */
54
- declare function loadAdaptiveAssignments(components: Array<{
55
- id: string;
56
- variantIds: string[];
57
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
58
-
59
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
60
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
61
- sessionId: string;
62
- };
63
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
64
- /**
65
- * Section IDs in default order. Passed to /v1/decide as the candidate
66
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
67
- * one of `sections`/`components`/`slots` must be non-empty).
68
- */
69
- sections?: string[];
70
- /** Components to assign in the same decide call. */
71
- components?: Array<{
72
- id: string;
73
- variantIds?: string[];
74
- }>;
75
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
76
- slots?: _sentientui_core_server.SlotDeclInput[];
77
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
78
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
79
- * Requires `registrySlotIds`. */
80
- slotsFrom?: 'request' | 'registry';
81
- /**
82
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
83
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
84
- * the call downgrades to request mode (with a console.error) instead of
85
- * recording a close-out trial for every published slot on every page.
86
- */
87
- registrySlotIds?: string[];
88
- };
89
- /**
90
- * SSR helper for pages with a declared section layout and/or adaptive slots.
91
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
92
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
93
- * adopts the same session on first visit.
94
- *
95
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
96
- * Under the `development` export condition the decision is computed by the
97
- * deterministic local engine with the same sessionId the client will adopt —
98
- * server and client agree by construction. In production the engine resolves
99
- * to a stub and defaults are returned with one console.error.
100
- */
101
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
102
-
103
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };
package/dist/server.d.ts DELETED
@@ -1,103 +0,0 @@
1
- import * as _sentientui_core_server from '@sentientui/core/server';
2
- import { ServerAssignments } from '@sentientui/core/server';
3
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie } from '@sentientui/core/server';
4
-
5
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
6
- type LoadAdaptiveAssignmentsResult = {
7
- assignments: ServerAssignments;
8
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
9
- sessionId: string;
10
- };
11
- type LoadAdaptiveAssignmentsOptions = {
12
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
13
- cookies: {
14
- get(name: string): {
15
- value: string;
16
- } | undefined;
17
- };
18
- apiKey: string;
19
- baseUrl: string;
20
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
21
- createSessionId?: () => string;
22
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
23
- origin?: string;
24
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
25
- userAgent?: string;
26
- /** From Next.js `headers().get('referer')`. */
27
- referer?: string;
28
- /**
29
- * `utm_*` params from the landing URL. The Referer header never carries the
30
- * page's OWN query string, so without this the SSR-minted session has no
31
- * campaign attribution until the client SDK hydrates and re-upserts.
32
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
33
- */
34
- utmParams?: Record<string, string>;
35
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
36
- clickIds?: Record<string, string>;
37
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
38
- doNotTrack?: boolean;
39
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
40
- timeoutMs?: number;
41
- /**
42
- * Declared persona — the role your app already knows for this visitor (e.g.
43
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
44
- * project's persona vocabulary; unrecognized values are ignored server-side.
45
- * Never a user id or email.
46
- */
47
- persona?: string;
48
- };
49
- /**
50
- * Fetches bandit assignments on the server for SEO-safe HTML.
51
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
52
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
53
- */
54
- declare function loadAdaptiveAssignments(components: Array<{
55
- id: string;
56
- variantIds: string[];
57
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
58
-
59
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
60
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
61
- sessionId: string;
62
- };
63
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
64
- /**
65
- * Section IDs in default order. Passed to /v1/decide as the candidate
66
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
67
- * one of `sections`/`components`/`slots` must be non-empty).
68
- */
69
- sections?: string[];
70
- /** Components to assign in the same decide call. */
71
- components?: Array<{
72
- id: string;
73
- variantIds?: string[];
74
- }>;
75
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
76
- slots?: _sentientui_core_server.SlotDeclInput[];
77
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
78
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
79
- * Requires `registrySlotIds`. */
80
- slotsFrom?: 'request' | 'registry';
81
- /**
82
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
83
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
84
- * the call downgrades to request mode (with a console.error) instead of
85
- * recording a close-out trial for every published slot on every page.
86
- */
87
- registrySlotIds?: string[];
88
- };
89
- /**
90
- * SSR helper for pages with a declared section layout and/or adaptive slots.
91
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
92
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
93
- * adopts the same session on first visit.
94
- *
95
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
96
- * Under the `development` export condition the decision is computed by the
97
- * deterministic local engine with the same sessionId the client will adopt —
98
- * server and client agree by construction. In production the engine resolves
99
- * to a stub and defaults are returned with one console.error.
100
- */
101
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
102
-
103
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };