@sentientui/react 0.34.0 → 0.34.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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- "use strict";var gn=Object.create;var le=Object.defineProperty,mn=Object.defineProperties,pn=Object.getOwnPropertyDescriptor,vn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols,Sn=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable;var ze=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Oe.call(t,n)&&ze(e,n,t[n]);if(de)for(var n of de(t))qe.call(t,n)&&ze(e,n,t[n]);return e},W=(e,t)=>mn(e,vn(t));var Ze=(e,t)=>{var n={};for(var r in e)Oe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&de)for(var r of de(e))t.indexOf(r)<0&&qe.call(e,r)&&(n[r]=e[r]);return n};var hn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yn(t))!Oe.call(e,i)&&i!==n&&le(e,i,{get:()=>t[i],enumerable:!(r=pn(t,i))||r.enumerable});return e};var Qe=(e,t,n)=>(n=e!=null?gn(Sn(e)):{},Ye(t||!e||!e.__esModule?le(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>Ye(le({},"__esModule",{value:!0}),e);var Mn={};hn(Mn,{Adaptive:()=>Vt,AdaptiveGroup:()=>nn,AdaptiveProvider:()=>bt,AdaptiveSlot:()=>Ce,AdaptiveText:()=>Nt,SentientPersonaScript:()=>Xt,buildAgentFeed:()=>an,defineAgentContent:()=>sn,detectSegment:()=>Ke.deriveSessionSegment,getAgentContent:()=>We,grantConsent:()=>un.grantConsent,renderAgentJsonLd:()=>ln,renderAgentJsonLdBody:()=>Ue,renderAgentMarkdown:()=>cn,renderBlocks:()=>oe,useAdaptive:()=>tn,useAdaptiveApiBaseUrl:()=>kt,useAdaptiveGoal:()=>Re,useAdaptivePersona:()=>qt,useAdaptiveTokens:()=>Qt,useAssignment:()=>be,useInitialAssignments:()=>pe,useLayoutOrder:()=>Ct,usePageGoal:()=>Kt,useSentient:()=>E});module.exports=bn(Mn);var w=require("react"),me=require("@sentientui/core");var et=new Map,fe=new Map;function tt(e,t){let n=fe.get(e);return n||(n=new Set,fe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&fe.delete(e)}}function nt(e,t){et.set(e,t);let n=fe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Ee(e){var t;return(t=et.get(e))!=null?t:null}var xn={on:!1,listeners:new Set};function rt(){if(typeof window=="undefined")return xn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function Pe(){return rt().on}function it(e){let t=rt().listeners;return t.add(e),()=>{t.delete(e)}}function ot(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Te="sentient:overrides-changed";function st(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function at(){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(Te))}function $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Te,e),()=>window.removeEventListener(Te,e))}function lt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function O(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function V(e){return typeof e=="string"?{type:"click"}:e}function q(e){return typeof e=="string"?e:e.type}function X(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var De=new Set,Le=!1;function ct(e){if(De.has(e))return!0;if(De.add(e),!Le){Le=!0;let t=()=>{Le=!1,De.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function wn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function ut(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 r=e;for(;r&&r!==t;){if(wn(r))return!0;r=r.parentElement}return!1}function H(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&ct(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&ut(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&ct(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&ut(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var dt=new Set,ft=new Set;function ne(e,t,n,r,i){let f=`${r}|${n}`;if(ft.has(f))return;ft.add(f);let c=i.type==="weighted_composite"&&!dt.has(r);c&&dt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function Z(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Cn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function Q(){if(typeof window=="undefined")return Cn;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 ce(){Q().version+=1;for(let e of Q().listeners)e()}var gt=()=>{};function mt(e){return O()?(Q().components.set(e.id,e),ce(),()=>{Q().components.delete(e.id),ce()}):gt}function re(e){return O()?(Q().slots.set(e.id,e),ce(),()=>{Q().slots.delete(e.id),ce()}):gt}function Ie(e){O()&&(Q().sections=[...e],ce())}var pt="0.34.0",Fe=pt!=="0.0.0-dev"?{name:"react",version:pt}:void 0;function An(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Be(e,t){An()[e]=t}function _n(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Me(e,t){_n()[e]=t}var vt="sentient_editor",yt="sentient_preview_cell",Ve="sentient-cell-preview-bar",$e="__preview__";function St(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ve))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(vt),n=s.get(yt)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){ge(s.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 m=await s.json();if(m.blocks!=null)Be(i,{kind:"arms",blocks:{[$e]:m.blocks}}),Me(i,$e);else if(m.content!=null)Be(i,{kind:"arms",content:m.content}),Me(i,$e);else{ge("Nothing to preview in that square yet.");return}at(),ge(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>ge("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ge(e){var i;if(document.getElementById(Ve))return;let t=document.createElement("div");t.id=Ve,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 r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.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"}),r.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(vt),f.searchParams.delete(yt),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Gt=require("react/jsx-runtime");function Rn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,me.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ht="https://api.sentient-ui.com/v1",M=(0,w.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ht,debug:!1});function kn(e){let[t,n]=(0,w.useState)(!1),r=(0,w.useRef)(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return(0,w.useEffect)(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function bt(e){var h,v;let[t,n]=(0,w.useState)(null),[r]=(0,w.useState)(()=>{var p;return(p=e.sessionSegment)!=null?p:Rn()}),[i,f]=(0,w.useState)(Pe());(0,w.useEffect)(()=>it(()=>f(Pe())),[]),(0,w.useEffect)(()=>{St(e.apiBaseUrl)},[]);let c=kn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=(0,w.useRef)(null);(0,w.useEffect)(()=>{var C;if(s===!1&&!e.preConsentBehavior){(C=m.current)==null||C.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Fe?{sdk:Fe}:{}),a=!1,l=null,y=null,x=G=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{a||(y=A(G,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:G})=>{a||(l=G(W(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=(0,me.init)(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),(0,w.useEffect)(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let C={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(G=>{var A;return{variantId:G.variantId,pulls:G.pulls,avgReward:(A=G.avgReward)!=null?A:0}})};nt(x.componentId,C)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:ht).replace(/\/$/,""),u=(0,w.useRef)(null);(0,w.useEffect)(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),(0,w.useEffect)(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||lt({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,w.useEffect)(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Ie(p);return}e.declaredSections&&e.declaredSections.length>0&&Ie(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,w.useEffect)(()=>{if(!O())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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=(0,w.useMemo)(()=>t&&i?ot(t):t,[t,i]),b=(0,w.useMemo)(()=>{var p,a,l,y,x,C,G;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(C=e.initialPersona)!=null?C:null,apiBaseUrl:d,debug:(G=e.debug)!=null?G:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,Gt.jsx)(M.Provider,{value:b,children:e.children})}function E(){return(0,w.useContext)(M).client}function z(){return(0,w.useContext)(M).apiKey}function pe(){return(0,w.useContext)(M).initialAssignments}function ve(){return(0,w.useContext)(M).sessionSegment}function xt(){return(0,w.useContext)(M).ssrFallback}function ye(){return(0,w.useContext)(M).onAssignment}function wt(){return(0,w.useContext)(M).debug}function Ct(){let e=(0,w.useContext)(M).initialLayoutOrder,t=(0,w.useSyncExternalStore)($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Se(){return(0,w.useContext)(M).initialSlots}function At(){return(0,w.useContext)(M).initialPersona}function _t(){return(0,w.useContext)(M).initialSlotConfig}function Rt(){return(0,w.useContext)(M).initialPalette}function kt(){return(0,w.useContext)(M).apiBaseUrl}var se=require("react");var D=require("react"),Ot=require("@sentientui/core");var N=require("react"),he=require("@sentientui/policy");function ie(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function be(e,t,n,r){let i=pe(),f=xt(),c=E(),s=ve(),m=ye(),o=wt(),d=(0,N.useRef)(null),u=(0,N.useSyncExternalStore)($,()=>ie(e),()=>null),g=u&&t.includes(u)?u:null,b=(0,N.useRef)(null);(0,N.useEffect)(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=(0,N.useState)(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let C=i[e];return C&&t.includes(C)?{variantId:C,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Ee(e);if(l){let C=(0,he.pickFromWeights)(l.variants,t);if(C)return{variantId:C,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return(0,N.useEffect)(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Ee(e);if(l&&h.settled&&h.variantId&&h.variantId===(0,he.pickFromWeights)(l.variants,t)){p(h.variantId);return}v(x=>{var C;return x.variantId?x:{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),(0,N.useEffect)(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),(0,N.useEffect)(()=>{if(!g&&c)return tt(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=(0,he.pickFromWeights)(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function xe(e,t,n){let r=E(),i=z(),f=Object.keys(t).join("\0"),c=(0,D.useMemo)(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=be(e,c,n.agentData,n.agentDataByVariant),[u,g]=(0,D.useState)(null),b=(0,D.useRef)(null),h=(0,D.useCallback)(R=>{b.current=R,g(R)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=(0,D.useMemo)(()=>v?V(v):null,[p]),l=v?q(v):"";(0,D.useEffect)(()=>mt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=(0,D.useRef)(null);(0,D.useEffect)(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,Z(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=(0,D.useRef)(!1),C=(0,D.useRef)(new Set);(0,D.useEffect)(()=>{x.current=!1,C.current=new Set},[s,a]);let G=n.funnel;(0,D.useEffect)(()=>{o||!d||!r||!G||!a||ne(r,i,e,G,a)},[r,i,e,G,a,o,d]);let A=n.cursorSignal===!0;(0,D.useEffect)(()=>{if(!A||o||!d||!r||!s||!u)return;let R=null,T=0,I=()=>{T=Date.now(),R=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-T}}),R=null},800)},L=()=>{R!==null&&(clearTimeout(R),R=null)};return u.addEventListener("mouseenter",I),u.addEventListener("mouseleave",L),()=>{u.removeEventListener("mouseenter",I),u.removeEventListener("mouseleave",L),R!==null&&clearTimeout(R)}},[A,r,s,i,e,u,o,d]);let _=(0,D.useRef)(n.microSignalGoals);_.current=n.microSignalGoals;let k=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u)return;let R=Date.now();return(0,Ot.attachMicroSignalDetectors)((T,I={})=>{var Je,Xe,He;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:T},I)});let L=(Je=_.current)==null?void 0:Je[T];if(!L||C.current.has(T))return;C.current.add(T);let te=typeof L=="string"?L:L.name,dn=typeof L=="string"?1:(Xe=L.weight)!=null?Xe:1,fn=typeof L=="string"?0:(He=L.stepIndex)!=null?He:0;r.goal(te,{metadata:S({signalType:T},I),weight:dn,stepIndex:fn})},u,R)},[r,s,i,e,u,k,o,d]),(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u||!a)return;let R=X(a);return H(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},R!==void 0?{goalValue:R}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(T,I,L)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:T,payload:{reward:I}}),r.goal(T,{metadata:{},weight:I,stepIndex:L})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}var K=require("react"),we=require("@sentientui/core");var j=require("react"),Pt=require("@sentientui/core");var Et=new Set;function Tt(e,t){var p;let n=E(),r=(0,j.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=Se(),f=_t(),c=Rt(),s=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":(0,Pt.armOfResult)(a),d=(0,j.useCallback)(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);(0,j.useSyncExternalStore)(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),(0,j.useSyncExternalStore)(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return(0,j.useEffect)(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var C;return(C=n.cancelSlots)==null?void 0:C.call(n,[e])}},[n,v,h.source,e]),(0,j.useEffect)(()=>{!O()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Et.has(e)||(Et.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,h.source,e]),h}var je=require("react");var P=require("react/jsx-runtime"),Y={none:"0",sm:"8px",md:"16px",lg:"24px"},Ne={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Ft={sm:"0.875em",md:"1em",lg:"1.25em"},Gn={sm:"1.25em",md:"1.5em",lg:"2em"},Dt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Lt={sm:"8px",md:"16px",lg:"32px"},On={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},En={normal:"400",medium:"500",bold:"700"};function It(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Bt(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return W(S({display:"inline-block",padding:(i=Dt[n!=null?n:"md"])!=null?i:Dt.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Ft[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Pn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return(0,P.jsxs)("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return(0,P.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,P.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,P.jsx)("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>(0,P.jsx)("option",{value:g,children:g},g))}):(0,P.jsx)("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,P.jsx)("button",{type:"submit",style:Bt(n,t.palette),children:e.submitLabel})]})}function oe(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,C,G,A,_;try{switch(e.type){case"stack":{let k=(r=Y[(n=e.gap)!=null?n:"md"])!=null?r:Y.md,R=e.surface==="raised",T=(i=e.pad)!=null?i:R?"md":void 0;return(0,P.jsx)("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:Ne[e.align]}:{}),e.justify?{justifyContent:Ne[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),T?{padding:(f=Y[T])!=null?f:Y.md}:{}),R?W(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((I,L)=>{let te=oe(I,t);return te===null?null:(0,P.jsx)(je.Fragment,{children:te},L)})})}case"grid":{let k=(v=Y[(h=e.gap)!=null?h:"md"])!=null?v:Y.md;return(0,P.jsx)("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:Ne[e.align]}:{}),e.pad?{padding:(p=Y[e.pad])!=null?p:Y.md}:{}),children:((a=e.children)!=null?a:[]).map((R,T)=>{let I=oe(R,t);return I===null?null:(0,P.jsx)(je.Fragment,{children:I},T)})})}case"text":return(0,P.jsx)("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Ft[e.size]}:{}),e.weight?{fontWeight:En[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),It(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return(0,P.jsx)(k,{style:S(S({margin:0,fontSize:Gn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(y=e.emphasis)!=null?y:"primary";return(0,P.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Bt(k,t.palette,e.size),children:e.label}))}case"link":return(0,P.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,P.jsx)("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:On[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,P.jsx)("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(C=(x=t.palette)==null?void 0:x.border)!=null?C:"currentColor"}`},It(e.tone,t.palette)),children:e.value});case"spacer":return(0,P.jsx)("div",{style:{height:(G=Lt[e.size])!=null?G:Lt.md}});case"divider":return(0,P.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(_=(A=t.palette)==null?void 0:A.border)!=null?_:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,P.jsx)(Pn,{node:e,opts:t});default:return null}}catch(k){return null}}var $t=require("react/jsx-runtime"),Mt=new Set;function Ce({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var A;let c=E(),s=z(),m=(0,K.useRef)(null),{config:o,arm:d,palette:u,source:g}=Tt(e,{baselineText:f?()=>{var _,k;return(k=(_=m.current)==null?void 0:_.textContent)!=null?k:null}:void 0}),b=d!==""?(A=o==null?void 0:o.blocks)==null?void 0:A[d]:void 0,h=b!==void 0&&(0,we.containsFormBlock)(b)&&!n;(0,K.useEffect)(()=>{!h||!O()||Mt.has(e)||(Mt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[h,e]);let v=_=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,_),c.goal(_,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let _=h?null:oe(b,{palette:u,onFormSubmit:n,onFormGoal:v});_===null?a=!0:p=_}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,K.useEffect)(()=>re({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=(0,K.useRef)(null);(0,K.useEffect)(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,Z(c,s,e,d))},[c,s,e,d,g,a]);let x=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,K.useEffect)(()=>{if(!c||!r||g==="override"||g==="none"||g==="seeded"||a)return;let _=m.current;if(!_)return;let k=q(r),R=X(r),T=!1;return H(_,V(r),{fireGoal:()=>{T||(T=!0,R!==void 0?c.componentGoal(e,k,{value:R}):c.componentGoal(e,k),c.goal(k,S({metadata:{componentId:e,arm:d},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(I,L,te)=>{c.componentGoal(e,I,{reward:L}),c.goal(I,{metadata:{componentId:e,arm:d},weight:L,stepIndex:te})}},k)},[c,e,x,d,g,a]);let C=(0,K.useRef)(null);(0,K.useEffect)(()=>{let _=m.current;if(_){if(C.current===null){C.current=d;return}C.current!==d&&(C.current=d,(0,we.reveal)(_))}},[d]);let G=(0,K.useMemo)(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return(0,$t.jsx)("div",W(S({ref:m,className:i},G),{children:p}))}var Ae=require("react/jsx-runtime");function Tn(e){var o;let{client:t,variantId:n,content:r,ref:i}=xe(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=(0,se.useState)(!1);if((0,se.useEffect)(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return O()&&s===null&&m===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Dn=(0,se.memo)(Tn,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||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),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Vt(e){return e.variants===void 0?(0,Ae.jsx)(Ce,S({},e)):(O()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),(0,Ae.jsx)(Dn,S({},e)))}var F=require("react");var jt=require("react/jsx-runtime");function Nt({id:e,default:t,component:n="span",className:r,goal:i}){var G;let f=E(),c=z(),s=ye(),m=ve(),o=(0,F.useRef)(null),d=(0,F.useRef)(null),u=(0,F.useSyncExternalStore)($,()=>ie(e),()=>null),[g,b]=(0,F.useState)(()=>{var A,_;return(_=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.content)!=null?_:null}),[h,v]=(0,F.useState)(()=>{var A,_;return(_=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.variantId)!=null?_:null});(0,F.useEffect)(()=>{if(u||!f)return;let A=f.getAssignment(e,m);if((A==null?void 0:A.content)!==void 0){v(A.variantId),b(A.content);return}let _=!1;return f.assign(e).then(k=>{if(!_){if(!k){O()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(k.variantId),k.content&&b(k.content)}}),()=>{_=!0}},[f,e,m,u]),(0,F.useEffect)(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=(0,F.useMemo)(()=>i===void 0?null:V(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=(0,F.useRef)(!1);(0,F.useEffect)(()=>{y.current=!1},[h,p]),(0,F.useEffect)(()=>{if(u||!f||!h||!c||!a||!l)return;let A=d.current;if(!A)return;let _=X(a);return H(A,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},_!==void 0?{goalValue:_}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(k,R,T)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:k,payload:{reward:R}}),f.goal(k,{metadata:{},weight:R,stepIndex:T})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let A=f==null?void 0:f.getAssignment(e,m);x=A&&A.variantId===u&&(G=A.content)!=null?G:t}return(0,jt.jsx)(n,{ref:A=>{d.current=A},className:r,children:x})}var _e=require("react");function Re(e){let t=E(),n=(0,_e.useRef)(new Set);return(0,_e.useCallback)((r,i)=>{var f,c;if(!ie(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var ue=require("react");function Kt(e,t={}){let m=t,{componentId:n}=m,r=Ze(m,["componentId"]),i=E(),f=Re(n!=null?n:""),c=(0,ue.useRef)(!1),s=(0,ue.useRef)(r);s.current=r,(0,ue.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}var Ut=require("@sentientui/core"),Jt=require("@sentientui/policy"),Ht=require("react/jsx-runtime");function Wt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ln(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Wt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Wt((0,Jt.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Ut.renderPrePaintScript)(e.apiKey)}function Xt(e){return(0,Ht.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ln(e)}})}var J=require("react"),Yt=require("@sentientui/policy");var U=require("react"),ee=require("@sentientui/core"),zt=require("@sentientui/policy");function ke(e,t){let n=E(),r=Se(),[,i]=(0,U.useReducer)(u=>u+1,0),f=(0,U.useSyncExternalStore)($,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;(0,U.useEffect)(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:(0,ee.armOfResult)(f),source:"override"};if(c!==void 0)return{result:c,arm:(0,ee.armOfResult)(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:(0,ee.armOfResult)(s),source:g?"client":"seeded"}}let u=(0,ee.baselineResultFor)(t);return{result:u,arm:(0,ee.armOfResult)(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return(0,U.useEffect)(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function In(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function qt(){let e=E(),t=At();(0,U.useSyncExternalStore)($,st,()=>0);let[n,r]=(0,U.useState)(!1);(0,U.useEffect)(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:(0,zt.confidenceBand)(s.confidence)});if(!n)return t?i(t):null;let f=In();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Zt=new Set;function Fn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Qt(e,t,n){let r=E(),i=z(),f=JSON.stringify(t),c=(0,J.useMemo)(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=ke(e,c),d=(0,J.useMemo)(()=>typeof s=="string"?{}:s,[m]);if(O()&&!Zt.has(e)){Zt.add(e);let v=(0,Yt.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&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.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,J.useEffect)(()=>re({id:e,dims:t}),[e]);let g=(0,J.useRef)(null);(0,J.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,Z(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;(0,J.useEffect)(()=>{var v;!r||!b||o==="override"||ne(r,i,e,b,V((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),(0,J.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Fn(e)}"]`);if(!v){O()&&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=q(n.goal),a=X(n.goal),l=!1;return H(v,V(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,C)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:C})}},p)},[r,e,u,m,o]);let h=(0,J.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}var ae=require("react");var en=new Set;function tn(e,t){var b;if(O()&&!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{client:n,variantIds:r,variantId:i,isOverride:f,goalLabel:c,ref:s,nodeRef:m}=xe(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];(0,ae.useEffect)(()=>{if(!O()||!n)return;let h=setTimeout(()=>{!m.current&&!en.has(e)&&(en.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(h)},[n,e]);let u=(0,ae.useCallback)((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,c,f]),g=(0,ae.useMemo)(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}var B=require("react");var rn=require("react/jsx-runtime"),Ge=new Set;function nn(e){var a;let t=E(),n=z(),r=(0,B.useRef)(null),i=Object.keys(e.arrangements).join(" "),f=(0,B.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,B.useMemo)(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=ke(e.id,c);O()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Ge.has(e.id+":baseline")&&(Ge.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=B.Children.toArray(e.children).filter(B.isValidElement),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));O()&&u!==void 0&&!g&&!Ge.has(e.id+":keys")&&(Ge.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;(0,B.useEffect)(()=>re({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=(0,B.useRef)(null);(0,B.useEffect)(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,Z(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;(0,B.useEffect)(()=>{var l;!t||!v||m==="override"||ne(t,n,e.id,v,V((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,B.useEffect)(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=q(e.goal),x=X(e.goal),C=!1;return H(l,V(e.goal),{fireGoal:()=>{C||(C=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(G,A,_)=>{t.componentGoal(e.id,G,{reward:A}),t.goal(G,{metadata:{componentId:e.id,arm:s},weight:A,stepIndex:_})}},y)},[t,e.id,p,s,m]),(0,rn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}var Ke=require("@sentientui/core");var Bn=["page","blocks","layoutOrder"],on=new Map;function sn(e,t){on.set(e,t)}function We(e){return on.get(e)}function an(e){var i,f;let t=(f=(i=e.content)!=null?i:We(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))Bn.includes(c)||(n[c]=s);let r=W(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function ln(e){return`<script type="application/ld+json">${Ue(e)}</script>`}function Ue(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function cn(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,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 gn=Object.create;var le=Object.defineProperty,mn=Object.defineProperties,pn=Object.getOwnPropertyDescriptor,vn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertyNames,de=Object.getOwnPropertySymbols,Sn=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable;var ze=(e,t,n)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Oe.call(t,n)&&ze(e,n,t[n]);if(de)for(var n of de(t))qe.call(t,n)&&ze(e,n,t[n]);return e},W=(e,t)=>mn(e,vn(t));var Ze=(e,t)=>{var n={};for(var r in e)Oe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&de)for(var r of de(e))t.indexOf(r)<0&&qe.call(e,r)&&(n[r]=e[r]);return n};var hn=(e,t)=>{for(var n in t)le(e,n,{get:t[n],enumerable:!0})},Ye=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yn(t))!Oe.call(e,i)&&i!==n&&le(e,i,{get:()=>t[i],enumerable:!(r=pn(t,i))||r.enumerable});return e};var Qe=(e,t,n)=>(n=e!=null?gn(Sn(e)):{},Ye(t||!e||!e.__esModule?le(n,"default",{value:e,enumerable:!0}):n,e)),bn=e=>Ye(le({},"__esModule",{value:!0}),e);var Mn={};hn(Mn,{Adaptive:()=>Vt,AdaptiveGroup:()=>nn,AdaptiveProvider:()=>bt,AdaptiveSlot:()=>Ce,AdaptiveText:()=>Nt,SentientPersonaScript:()=>Xt,buildAgentFeed:()=>an,defineAgentContent:()=>sn,detectSegment:()=>Ke.deriveSessionSegment,getAgentContent:()=>We,grantConsent:()=>un.grantConsent,renderAgentJsonLd:()=>ln,renderAgentJsonLdBody:()=>Ue,renderAgentMarkdown:()=>cn,renderBlocks:()=>oe,useAdaptive:()=>tn,useAdaptiveApiBaseUrl:()=>kt,useAdaptiveGoal:()=>Re,useAdaptivePersona:()=>qt,useAdaptiveTokens:()=>Qt,useAssignment:()=>be,useInitialAssignments:()=>pe,useLayoutOrder:()=>Ct,usePageGoal:()=>Kt,useSentient:()=>E});module.exports=bn(Mn);var w=require("react"),me=require("@sentientui/core");var et=new Map,fe=new Map;function tt(e,t){let n=fe.get(e);return n||(n=new Set,fe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&fe.delete(e)}}function nt(e,t){et.set(e,t);let n=fe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Ee(e){var t;return(t=et.get(e))!=null?t:null}var xn={on:!1,listeners:new Set};function rt(){if(typeof window=="undefined")return xn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function Pe(){return rt().on}function it(e){let t=rt().listeners;return t.add(e),()=>{t.delete(e)}}function ot(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Te="sentient:overrides-changed";function st(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function at(){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(Te))}function $(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(Te,e),()=>window.removeEventListener(Te,e))}function lt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function O(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function V(e){return typeof e=="string"?{type:"click"}:e}function q(e){return typeof e=="string"?e:e.type}function X(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var De=new Set,Le=!1;function ct(e){if(De.has(e))return!0;if(De.add(e),!Le){Le=!0;let t=()=>{Le=!1,De.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function wn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function ut(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 r=e;for(;r&&r!==t;){if(wn(r))return!0;r=r.parentElement}return!1}function H(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&ct(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&ut(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&ct(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&ut(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var dt=new Set,ft=new Set;function ne(e,t,n,r,i){let f=`${r}|${n}`;if(ft.has(f))return;ft.add(f);let c=i.type==="weighted_composite"&&!dt.has(r);c&&dt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function Z(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Cn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function Q(){if(typeof window=="undefined")return Cn;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 ce(){Q().version+=1;for(let e of Q().listeners)e()}var gt=()=>{};function mt(e){return O()?(Q().components.set(e.id,e),ce(),()=>{Q().components.delete(e.id),ce()}):gt}function re(e){return O()?(Q().slots.set(e.id,e),ce(),()=>{Q().slots.delete(e.id),ce()}):gt}function Ie(e){O()&&(Q().sections=[...e],ce())}var pt="0.34.1",Fe=pt!=="0.0.0-dev"?{name:"react",version:pt}:void 0;function An(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Be(e,t){An()[e]=t}function _n(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Me(e,t){_n()[e]=t}var vt="sentient_editor",yt="sentient_preview_cell",Ve="sentient-cell-preview-bar",$e="__preview__";function St(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ve))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(vt),n=s.get(yt)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){ge(s.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 m=await s.json();if(m.blocks!=null)Be(i,{kind:"arms",blocks:{[$e]:m.blocks}}),Me(i,$e);else if(m.content!=null)Be(i,{kind:"arms",content:m.content}),Me(i,$e);else{ge("Nothing to preview in that square yet.");return}at(),ge(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>ge("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ge(e){var i;if(document.getElementById(Ve))return;let t=document.createElement("div");t.id=Ve,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 r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.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"}),r.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(vt),f.searchParams.delete(yt),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Gt=require("react/jsx-runtime");function Rn(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,me.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ht="https://api.sentient-ui.com/v1",M=(0,w.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ht,debug:!1});function kn(e){let[t,n]=(0,w.useState)(!1),r=(0,w.useRef)(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return(0,w.useEffect)(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function bt(e){var h,v;let[t,n]=(0,w.useState)(null),[r]=(0,w.useState)(()=>{var p;return(p=e.sessionSegment)!=null?p:Rn()}),[i,f]=(0,w.useState)(Pe());(0,w.useEffect)(()=>it(()=>f(Pe())),[]),(0,w.useEffect)(()=>{St(e.apiBaseUrl)},[]);let c=kn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=(0,w.useRef)(null);(0,w.useEffect)(()=>{var C;if(s===!1&&!e.preConsentBehavior){(C=m.current)==null||C.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Fe?{sdk:Fe}:{}),a=!1,l=null,y=null,x=G=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{a||(y=A(G,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:G})=>{a||(l=G(W(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=(0,me.init)(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),(0,w.useEffect)(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let C={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(G=>{var A;return{variantId:G.variantId,pulls:G.pulls,avgReward:(A=G.avgReward)!=null?A:0}})};nt(x.componentId,C)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:ht).replace(/\/$/,""),u=(0,w.useRef)(null);(0,w.useEffect)(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),(0,w.useEffect)(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||lt({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,w.useEffect)(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Ie(p);return}e.declaredSections&&e.declaredSections.length>0&&Ie(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,w.useEffect)(()=>{if(!O())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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=(0,w.useMemo)(()=>t&&i?ot(t):t,[t,i]),b=(0,w.useMemo)(()=>{var p,a,l,y,x,C,G;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(C=e.initialPersona)!=null?C:null,apiBaseUrl:d,debug:(G=e.debug)!=null?G:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,Gt.jsx)(M.Provider,{value:b,children:e.children})}function E(){return(0,w.useContext)(M).client}function z(){return(0,w.useContext)(M).apiKey}function pe(){return(0,w.useContext)(M).initialAssignments}function ve(){return(0,w.useContext)(M).sessionSegment}function xt(){return(0,w.useContext)(M).ssrFallback}function ye(){return(0,w.useContext)(M).onAssignment}function wt(){return(0,w.useContext)(M).debug}function Ct(){let e=(0,w.useContext)(M).initialLayoutOrder,t=(0,w.useSyncExternalStore)($,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Se(){return(0,w.useContext)(M).initialSlots}function At(){return(0,w.useContext)(M).initialPersona}function _t(){return(0,w.useContext)(M).initialSlotConfig}function Rt(){return(0,w.useContext)(M).initialPalette}function kt(){return(0,w.useContext)(M).apiBaseUrl}var se=require("react");var D=require("react"),Ot=require("@sentientui/core");var N=require("react"),he=require("@sentientui/policy");function ie(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function be(e,t,n,r){let i=pe(),f=xt(),c=E(),s=ve(),m=ye(),o=wt(),d=(0,N.useRef)(null),u=(0,N.useSyncExternalStore)($,()=>ie(e),()=>null),g=u&&t.includes(u)?u:null,b=(0,N.useRef)(null);(0,N.useEffect)(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=(0,N.useState)(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let C=i[e];return C&&t.includes(C)?{variantId:C,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Ee(e);if(l){let C=(0,he.pickFromWeights)(l.variants,t);if(C)return{variantId:C,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return(0,N.useEffect)(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Ee(e);if(l&&h.settled&&h.variantId&&h.variantId===(0,he.pickFromWeights)(l.variants,t)){p(h.variantId);return}v(x=>{var C;return x.variantId?x:{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),(0,N.useEffect)(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),(0,N.useEffect)(()=>{if(!g&&c)return tt(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=(0,he.pickFromWeights)(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function xe(e,t,n){let r=E(),i=z(),f=Object.keys(t).join("\0"),c=(0,D.useMemo)(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=be(e,c,n.agentData,n.agentDataByVariant),[u,g]=(0,D.useState)(null),b=(0,D.useRef)(null),h=(0,D.useCallback)(R=>{b.current=R,g(R)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=(0,D.useMemo)(()=>v?V(v):null,[p]),l=v?q(v):"";(0,D.useEffect)(()=>mt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=(0,D.useRef)(null);(0,D.useEffect)(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,Z(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=(0,D.useRef)(!1),C=(0,D.useRef)(new Set);(0,D.useEffect)(()=>{x.current=!1,C.current=new Set},[s,a]);let G=n.funnel;(0,D.useEffect)(()=>{o||!d||!r||!G||!a||ne(r,i,e,G,a)},[r,i,e,G,a,o,d]);let A=n.cursorSignal===!0;(0,D.useEffect)(()=>{if(!A||o||!d||!r||!s||!u)return;let R=null,T=0,I=()=>{T=Date.now(),R=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-T}}),R=null},800)},L=()=>{R!==null&&(clearTimeout(R),R=null)};return u.addEventListener("mouseenter",I),u.addEventListener("mouseleave",L),()=>{u.removeEventListener("mouseenter",I),u.removeEventListener("mouseleave",L),R!==null&&clearTimeout(R)}},[A,r,s,i,e,u,o,d]);let _=(0,D.useRef)(n.microSignalGoals);_.current=n.microSignalGoals;let k=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u)return;let R=Date.now();return(0,Ot.attachMicroSignalDetectors)((T,I={})=>{var Je,Xe,He;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:T},I)});let L=(Je=_.current)==null?void 0:Je[T];if(!L||C.current.has(T))return;C.current.add(T);let te=typeof L=="string"?L:L.name,dn=typeof L=="string"?1:(Xe=L.weight)!=null?Xe:1,fn=typeof L=="string"?0:(He=L.stepIndex)!=null?He:0;r.goal(te,{metadata:S({signalType:T},I),weight:dn,stepIndex:fn})},u,R)},[r,s,i,e,u,k,o,d]),(0,D.useEffect)(()=>{if(o||!d||!r||!s||!u||!a)return;let R=X(a);return H(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},R!==void 0?{goalValue:R}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(T,I,L)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:T,payload:{reward:I}}),r.goal(T,{metadata:{},weight:I,stepIndex:L})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}var K=require("react"),we=require("@sentientui/core");var j=require("react"),Pt=require("@sentientui/core");var Et=new Set;function Tt(e,t){var p;let n=E(),r=(0,j.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=Se(),f=_t(),c=Rt(),s=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=(0,j.useSyncExternalStore)($,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":(0,Pt.armOfResult)(a),d=(0,j.useCallback)(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);(0,j.useSyncExternalStore)(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),(0,j.useSyncExternalStore)(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return(0,j.useEffect)(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var C;return(C=n.cancelSlots)==null?void 0:C.call(n,[e])}},[n,v,h.source,e]),(0,j.useEffect)(()=>{!O()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Et.has(e)||(Et.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,h.source,e]),h}var je=require("react");var P=require("react/jsx-runtime"),Y={none:"0",sm:"8px",md:"16px",lg:"24px"},Ne={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Ft={sm:"0.875em",md:"1em",lg:"1.25em"},Gn={sm:"1.25em",md:"1.5em",lg:"2em"},Dt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Lt={sm:"8px",md:"16px",lg:"32px"},On={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},En={normal:"400",medium:"500",bold:"700"};function It(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Bt(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return W(S({display:"inline-block",padding:(i=Dt[n!=null?n:"md"])!=null?i:Dt.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Ft[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Pn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return(0,P.jsxs)("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return(0,P.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,P.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,P.jsx)("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>(0,P.jsx)("option",{value:g,children:g},g))}):(0,P.jsx)("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,P.jsx)("button",{type:"submit",style:Bt(n,t.palette),children:e.submitLabel})]})}function oe(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,C,G,A,_;try{switch(e.type){case"stack":{let k=(r=Y[(n=e.gap)!=null?n:"md"])!=null?r:Y.md,R=e.surface==="raised",T=(i=e.pad)!=null?i:R?"md":void 0;return(0,P.jsx)("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:Ne[e.align]}:{}),e.justify?{justifyContent:Ne[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),T?{padding:(f=Y[T])!=null?f:Y.md}:{}),R?W(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((I,L)=>{let te=oe(I,t);return te===null?null:(0,P.jsx)(je.Fragment,{children:te},L)})})}case"grid":{let k=(v=Y[(h=e.gap)!=null?h:"md"])!=null?v:Y.md;return(0,P.jsx)("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:Ne[e.align]}:{}),e.pad?{padding:(p=Y[e.pad])!=null?p:Y.md}:{}),children:((a=e.children)!=null?a:[]).map((R,T)=>{let I=oe(R,t);return I===null?null:(0,P.jsx)(je.Fragment,{children:I},T)})})}case"text":return(0,P.jsx)("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Ft[e.size]}:{}),e.weight?{fontWeight:En[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),It(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return(0,P.jsx)(k,{style:S(S({margin:0,fontSize:Gn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(y=e.emphasis)!=null?y:"primary";return(0,P.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Bt(k,t.palette,e.size),children:e.label}))}case"link":return(0,P.jsx)("a",W(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return(0,P.jsx)("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:On[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return(0,P.jsx)("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(C=(x=t.palette)==null?void 0:x.border)!=null?C:"currentColor"}`},It(e.tone,t.palette)),children:e.value});case"spacer":return(0,P.jsx)("div",{style:{height:(G=Lt[e.size])!=null?G:Lt.md}});case"divider":return(0,P.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(_=(A=t.palette)==null?void 0:A.border)!=null?_:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,P.jsx)(Pn,{node:e,opts:t});default:return null}}catch(k){return null}}var $t=require("react/jsx-runtime"),Mt=new Set;function Ce({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var A;let c=E(),s=z(),m=(0,K.useRef)(null),{config:o,arm:d,palette:u,source:g}=Tt(e,{baselineText:f?()=>{var _,k;return(k=(_=m.current)==null?void 0:_.textContent)!=null?k:null}:void 0}),b=d!==""?(A=o==null?void 0:o.blocks)==null?void 0:A[d]:void 0,h=b!==void 0&&(0,we.containsFormBlock)(b)&&!n;(0,K.useEffect)(()=>{!h||!O()||Mt.has(e)||(Mt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[h,e]);let v=_=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,_),c.goal(_,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let _=h?null:oe(b,{palette:u,onFormSubmit:n,onFormGoal:v});_===null?a=!0:p=_}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,K.useEffect)(()=>re({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=(0,K.useRef)(null);(0,K.useEffect)(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,Z(c,s,e,d))},[c,s,e,d,g,a]);let x=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);(0,K.useEffect)(()=>{if(!c||!r||g==="override"||g==="none"||g==="seeded"||a)return;let _=m.current;if(!_)return;let k=q(r),R=X(r),T=!1;return H(_,V(r),{fireGoal:()=>{T||(T=!0,R!==void 0?c.componentGoal(e,k,{value:R}):c.componentGoal(e,k),c.goal(k,S({metadata:{componentId:e,arm:d},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(I,L,te)=>{c.componentGoal(e,I,{reward:L}),c.goal(I,{metadata:{componentId:e,arm:d},weight:L,stepIndex:te})}},k)},[c,e,x,d,g,a]);let C=(0,K.useRef)(null);(0,K.useEffect)(()=>{let _=m.current;if(_){if(C.current===null){C.current=d;return}C.current!==d&&(C.current=d,(0,we.reveal)(_))}},[d]);let G=(0,K.useMemo)(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return(0,$t.jsx)("div",W(S({ref:m,className:i},G),{children:p}))}var Ae=require("react/jsx-runtime");function Tn(e){var o;let{client:t,variantId:n,content:r,ref:i}=xe(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=(0,se.useState)(!1);if((0,se.useEffect)(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return O()&&s===null&&m===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Dn=(0,se.memo)(Tn,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||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),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Vt(e){return e.variants===void 0?(0,Ae.jsx)(Ce,S({},e)):(O()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),(0,Ae.jsx)(Dn,S({},e)))}var F=require("react");var jt=require("react/jsx-runtime");function Nt({id:e,default:t,component:n="span",className:r,goal:i}){var G;let f=E(),c=z(),s=ye(),m=ve(),o=(0,F.useRef)(null),d=(0,F.useRef)(null),u=(0,F.useSyncExternalStore)($,()=>ie(e),()=>null),[g,b]=(0,F.useState)(()=>{var A,_;return(_=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.content)!=null?_:null}),[h,v]=(0,F.useState)(()=>{var A,_;return(_=(A=f==null?void 0:f.getAssignment(e,m))==null?void 0:A.variantId)!=null?_:null});(0,F.useEffect)(()=>{if(u||!f)return;let A=f.getAssignment(e,m);if((A==null?void 0:A.content)!==void 0){v(A.variantId),b(A.content);return}let _=!1;return f.assign(e).then(k=>{if(!_){if(!k){O()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(k.variantId),k.content&&b(k.content)}}),()=>{_=!0}},[f,e,m,u]),(0,F.useEffect)(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=(0,F.useMemo)(()=>i===void 0?null:V(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=(0,F.useRef)(!1);(0,F.useEffect)(()=>{y.current=!1},[h,p]),(0,F.useEffect)(()=>{if(u||!f||!h||!c||!a||!l)return;let A=d.current;if(!A)return;let _=X(a);return H(A,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},_!==void 0?{goalValue:_}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(k,R,T)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:k,payload:{reward:R}}),f.goal(k,{metadata:{},weight:R,stepIndex:T})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let A=f==null?void 0:f.getAssignment(e,m);x=A&&A.variantId===u&&(G=A.content)!=null?G:t}return(0,jt.jsx)(n,{ref:A=>{d.current=A},className:r,children:x})}var _e=require("react");function Re(e){let t=E(),n=(0,_e.useRef)(new Set);return(0,_e.useCallback)((r,i)=>{var f,c;if(!ie(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var ue=require("react");function Kt(e,t={}){let m=t,{componentId:n}=m,r=Ze(m,["componentId"]),i=E(),f=Re(n!=null?n:""),c=(0,ue.useRef)(!1),s=(0,ue.useRef)(r);s.current=r,(0,ue.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}var Ut=require("@sentientui/core"),Jt=require("@sentientui/policy"),Ht=require("react/jsx-runtime");function Wt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ln(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Wt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Wt((0,Jt.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Ut.renderPrePaintScript)(e.apiKey)}function Xt(e){return(0,Ht.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ln(e)}})}var J=require("react"),Yt=require("@sentientui/policy");var U=require("react"),ee=require("@sentientui/core"),zt=require("@sentientui/policy");function ke(e,t){let n=E(),r=Se(),[,i]=(0,U.useReducer)(u=>u+1,0),f=(0,U.useSyncExternalStore)($,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;(0,U.useEffect)(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:(0,ee.armOfResult)(f),source:"override"};if(c!==void 0)return{result:c,arm:(0,ee.armOfResult)(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:(0,ee.armOfResult)(s),source:g?"client":"seeded"}}let u=(0,ee.baselineResultFor)(t);return{result:u,arm:(0,ee.armOfResult)(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return(0,U.useEffect)(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function In(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function qt(){let e=E(),t=At();(0,U.useSyncExternalStore)($,st,()=>0);let[n,r]=(0,U.useState)(!1);(0,U.useEffect)(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:(0,zt.confidenceBand)(s.confidence)});if(!n)return t?i(t):null;let f=In();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Zt=new Set;function Fn(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Qt(e,t,n){let r=E(),i=z(),f=JSON.stringify(t),c=(0,J.useMemo)(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=ke(e,c),d=(0,J.useMemo)(()=>typeof s=="string"?{}:s,[m]);if(O()&&!Zt.has(e)){Zt.add(e);let v=(0,Yt.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&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.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,J.useEffect)(()=>re({id:e,dims:t}),[e]);let g=(0,J.useRef)(null);(0,J.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,Z(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;(0,J.useEffect)(()=>{var v;!r||!b||o==="override"||ne(r,i,e,b,V((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),(0,J.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Fn(e)}"]`);if(!v){O()&&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=q(n.goal),a=X(n.goal),l=!1;return H(v,V(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,C)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:C})}},p)},[r,e,u,m,o]);let h=(0,J.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}var ae=require("react");var en=new Set;function tn(e,t){var b;if(O()&&!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{client:n,variantIds:r,variantId:i,isOverride:f,goalLabel:c,ref:s,nodeRef:m}=xe(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];(0,ae.useEffect)(()=>{if(!O()||!n)return;let h=setTimeout(()=>{!m.current&&!en.has(e)&&(en.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(h)},[n,e]);let u=(0,ae.useCallback)((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,c,f]),g=(0,ae.useMemo)(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}var B=require("react");var rn=require("react/jsx-runtime"),Ge=new Set;function nn(e){var a;let t=E(),n=z(),r=(0,B.useRef)(null),i=Object.keys(e.arrangements).join(" "),f=(0,B.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,B.useMemo)(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=ke(e.id,c);O()&&e.baseline!==void 0&&e.baseline!==f[0]&&!Ge.has(e.id+":baseline")&&(Ge.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=B.Children.toArray(e.children).filter(B.isValidElement),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));O()&&u!==void 0&&!g&&!Ge.has(e.id+":keys")&&(Ge.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;(0,B.useEffect)(()=>re({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=(0,B.useRef)(null);(0,B.useEffect)(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,Z(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;(0,B.useEffect)(()=>{var l;!t||!v||m==="override"||ne(t,n,e.id,v,V((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,B.useEffect)(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=q(e.goal),x=X(e.goal),C=!1;return H(l,V(e.goal),{fireGoal:()=>{C||(C=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(G,A,_)=>{t.componentGoal(e.id,G,{reward:A}),t.goal(G,{metadata:{componentId:e.id,arm:s},weight:A,stepIndex:_})}},y)},[t,e.id,p,s,m]),(0,rn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}var Ke=require("@sentientui/core");var Bn=["page","blocks","layoutOrder"],on=new Map;function sn(e,t){on.set(e,t)}function We(e){return on.get(e)}function an(e){var i,f;let t=(f=(i=e.content)!=null?i:We(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))Bn.includes(c)||(n[c]=s);let r=W(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function ln(e){return`<script type="application/ld+json">${Ue(e)}</script>`}function Ue(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function cn(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,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
4
  `}var un=require("@sentientui/core");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient});
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var Jt=Object.defineProperty,Xt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Ue=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable;var We=(e,t,n)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Ue.call(t,n)&&We(e,n,t[n]);if(ne)for(var n of ne(t))Je.call(t,n)&&We(e,n,t[n]);return e},M=(e,t)=>Xt(e,Ht(t));var Xe=(e,t)=>{var n={};for(var r in e)Ue.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ne)for(var r of ne(e))t.indexOf(r)<0&&Je.call(e,r)&&(n[r]=e[r]);return n};import{createContext as en,useContext as I,useEffect as j,useMemo as gt,useRef as Oe,useState as oe,useSyncExternalStore as tn}from"react";import{deriveSessionSegment as nn,init as rn}from"@sentientui/core";var He=new Map,re=new Map;function ze(e,t){let n=re.get(e);return n||(n=new Set,re.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&re.delete(e)}}function qe(e,t){He.set(e,t);let n=re.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Se(e){var t;return(t=He.get(e))!=null?t:null}var zt={on:!1,listeners:new Set};function Ze(){if(typeof window=="undefined")return zt;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function he(){return Ze().on}function Ye(e){let t=Ze().listeners;return t.add(e),()=>{t.delete(e)}}function Qe(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var be="sentient:overrides-changed";function et(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function tt(){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 F(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(be,e),()=>window.removeEventListener(be,e))}function nt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function B(e){return typeof e=="string"?{type:"click"}:e}function K(e){return typeof e=="string"?e:e.type}function $(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var xe=new Set,we=!1;function rt(e){if(xe.has(e))return!0;if(xe.add(e),!we){we=!0;let t=()=>{we=!1,xe.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function qt(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function it(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 r=e;for(;r&&r!==t;){if(qt(r))return!0;r=r.parentElement}return!1}function V(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&rt(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&it(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&rt(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&it(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var ot=new Set,st=new Set;function z(e,t,n,r,i){let f=`${r}|${n}`;if(st.has(f))return;st.add(f);let c=i.type==="weighted_composite"&&!ot.has(r);c&&ot.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function W(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function J(){if(typeof window=="undefined")return Zt;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 Y(){J().version+=1;for(let e of J().listeners)e()}var at=()=>{};function lt(e){return G()?(J().components.set(e.id,e),Y(),()=>{J().components.delete(e.id),Y()}):at}function q(e){return G()?(J().slots.set(e.id,e),Y(),()=>{J().slots.delete(e.id),Y()}):at}function Ce(e){G()&&(J().sections=[...e],Y())}var ct="0.34.0",Ae=ct!=="0.0.0-dev"?{name:"react",version:ct}:void 0;function Yt(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function _e(e,t){Yt()[e]=t}function Qt(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Re(e,t){Qt()[e]=t}var ut="sentient_editor",dt="sentient_preview_cell",Ge="sentient-cell-preview-bar",ke="__preview__";function ft(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ge))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ut),n=s.get(dt)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){ie(s.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 m=await s.json();if(m.blocks!=null)_e(i,{kind:"arms",blocks:{[ke]:m.blocks}}),Re(i,ke);else if(m.content!=null)_e(i,{kind:"arms",content:m.content}),Re(i,ke);else{ie("Nothing to preview in that square yet.");return}tt(),ie(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>ie("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ie(e){var i;if(document.getElementById(Ge))return;let t=document.createElement("div");t.id=Ge,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 r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.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"}),r.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(ut),f.searchParams.delete(dt),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}import{jsx as un}from"react/jsx-runtime";function on(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return nn({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var mt="https://api.sentient-ui.com/v1",L=en({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:mt,debug:!1});function sn(e){let[t,n]=oe(!1),r=Oe(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return j(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function an(e){var h,v;let[t,n]=oe(null),[r]=oe(()=>{var p;return(p=e.sessionSegment)!=null?p:on()}),[i,f]=oe(he());j(()=>Ye(()=>f(he())),[]),j(()=>{ft(e.apiBaseUrl)},[]);let c=sn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=Oe(null);j(()=>{var w;if(s===!1&&!e.preConsentBehavior){(w=m.current)==null||w.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Ae?{sdk:Ae}:{}),a=!1,l=null,y=null,x=k=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{a||(y=C(k,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:k})=>{a||(l=k(M(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=rn(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),j(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let w={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(k=>{var C;return{variantId:k.variantId,pulls:k.pulls,avgReward:(C=k.avgReward)!=null?C:0}})};qe(x.componentId,w)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:mt).replace(/\/$/,""),u=Oe(null);j(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),j(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||nt({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),j(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Ce(p);return}e.declaredSections&&e.declaredSections.length>0&&Ce(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),j(()=>{if(!G())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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=gt(()=>t&&i?Qe(t):t,[t,i]),b=gt(()=>{var p,a,l,y,x,w,k;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(w=e.initialPersona)!=null?w:null,apiBaseUrl:d,debug:(k=e.debug)!=null?k:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return un(L.Provider,{value:b,children:e.children})}function O(){return I(L).client}function N(){return I(L).apiKey}function Ee(){return I(L).initialAssignments}function se(){return I(L).sessionSegment}function pt(){return I(L).ssrFallback}function ae(){return I(L).onAssignment}function vt(){return I(L).debug}function ln(){let e=I(L).initialLayoutOrder,t=tn(F,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function le(){return I(L).initialSlots}function yt(){return I(L).initialPersona}function St(){return I(L).initialSlotConfig}function ht(){return I(L).initialPalette}function cn(){return I(L).apiBaseUrl}import{memo as kn,useEffect as Gn,useState as On}from"react";import{useCallback as gn,useEffect as X,useMemo as xt,useRef as Q,useState as mn}from"react";import{attachMicroSignalDetectors as pn}from"@sentientui/core";import{useEffect as ce,useRef as bt,useState as dn,useSyncExternalStore as fn}from"react";import{pickFromWeights as Pe}from"@sentientui/policy";function Z(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function Te(e,t,n,r){let i=Ee(),f=pt(),c=O(),s=se(),m=ae(),o=vt(),d=bt(null),u=fn(F,()=>Z(e),()=>null),g=u&&t.includes(u)?u:null,b=bt(null);ce(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=dn(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let w=i[e];return w&&t.includes(w)?{variantId:w,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Se(e);if(l){let w=Pe(l.variants,t);if(w)return{variantId:w,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return ce(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Se(e);if(l&&h.settled&&h.variantId&&h.variantId===Pe(l.variants,t)){p(h.variantId);return}v(x=>{var w;return x.variantId?x:{variantId:(w=t[0])!=null?w:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),ce(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),ce(()=>{if(!g&&c)return ze(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=Pe(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function ue(e,t,n){let r=O(),i=N(),f=Object.keys(t).join("\0"),c=xt(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=Te(e,c,n.agentData,n.agentDataByVariant),[u,g]=mn(null),b=Q(null),h=gn(_=>{b.current=_,g(_)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=xt(()=>v?B(v):null,[p]),l=v?K(v):"";X(()=>lt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=Q(null);X(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,W(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=Q(!1),w=Q(new Set);X(()=>{x.current=!1,w.current=new Set},[s,a]);let k=n.funnel;X(()=>{o||!d||!r||!k||!a||z(r,i,e,k,a)},[r,i,e,k,a,o,d]);let C=n.cursorSignal===!0;X(()=>{if(!C||o||!d||!r||!s||!u)return;let _=null,E=0,D=()=>{E=Date.now(),_=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-E}}),_=null},800)},P=()=>{_!==null&&(clearTimeout(_),_=null)};return u.addEventListener("mouseenter",D),u.addEventListener("mouseleave",P),()=>{u.removeEventListener("mouseenter",D),u.removeEventListener("mouseleave",P),_!==null&&clearTimeout(_)}},[C,r,s,i,e,u,o,d]);let A=Q(n.microSignalGoals);A.current=n.microSignalGoals;let R=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return X(()=>{if(o||!d||!r||!s||!u)return;let _=Date.now();return pn((E,D={})=>{var Ne,je,Ke;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:E},D)});let P=(Ne=A.current)==null?void 0:Ne[E];if(!P||w.current.has(E))return;w.current.add(E);let H=typeof P=="string"?P:P.name,Wt=typeof P=="string"?1:(je=P.weight)!=null?je:1,Ut=typeof P=="string"?0:(Ke=P.stepIndex)!=null?Ke:0;r.goal(H,{metadata:S({signalType:E},D),weight:Wt,stepIndex:Ut})},u,_)},[r,s,i,e,u,R,o,d]),X(()=>{if(o||!d||!r||!s||!u||!a)return;let _=$(a);return V(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},_!==void 0?{goalValue:_}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(E,D,P)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:E,payload:{reward:D}}),r.goal(E,{metadata:{},weight:D,stepIndex:P})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}import{useEffect as te,useMemo as Cn,useRef as Le}from"react";import{containsFormBlock as An,reveal as _n}from"@sentientui/core";import{useCallback as vn,useEffect as wt,useRef as yn,useSyncExternalStore as de}from"react";import{armOfResult as Sn}from"@sentientui/core";var Ct=new Set;function At(e,t){var p;let n=O(),r=yn(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=le(),f=St(),c=ht(),s=de(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=de(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":Sn(a),d=vn(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);de(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),de(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return wt(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var w;return(w=n.cancelSlots)==null?void 0:w.call(n,[e])}},[n,v,h.source,e]),wt(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Ct.has(e)||(Ct.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,h.source,e]),h}import{Fragment as _t}from"react";import{jsx as T,jsxs as Ot}from"react/jsx-runtime";var U={none:"0",sm:"8px",md:"16px",lg:"24px"},De={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Et={sm:"0.875em",md:"1em",lg:"1.25em"},hn={sm:"1.25em",md:"1.5em",lg:"2em"},Rt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},kt={sm:"8px",md:"16px",lg:"32px"},bn={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},xn={normal:"400",medium:"500",bold:"700"};function Gt(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Pt(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return M(S({display:"inline-block",padding:(i=Rt[n!=null?n:"md"])!=null?i:Rt.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Et[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function wn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return Ot("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return Ot("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?T("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?T("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>T("option",{value:g,children:g},g))}):T("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),T("button",{type:"submit",style:Pt(n,t.palette),children:e.submitLabel})]})}function ee(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,w,k,C,A;try{switch(e.type){case"stack":{let R=(r=U[(n=e.gap)!=null?n:"md"])!=null?r:U.md,_=e.surface==="raised",E=(i=e.pad)!=null?i:_?"md":void 0;return T("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:R},e.align?{alignItems:De[e.align]}:{}),e.justify?{justifyContent:De[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),E?{padding:(f=U[E])!=null?f:U.md}:{}),_?M(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((D,P)=>{let H=ee(D,t);return H===null?null:T(_t,{children:H},P)})})}case"grid":{let R=(v=U[(h=e.gap)!=null?h:"md"])!=null?v:U.md;return T("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${R}) / ${e.columns})), 1fr))`,gap:R},e.align?{alignItems:De[e.align]}:{}),e.pad?{padding:(p=U[e.pad])!=null?p:U.md}:{}),children:((a=e.children)!=null?a:[]).map((_,E)=>{let D=ee(_,t);return D===null?null:T(_t,{children:D},E)})})}case"text":return T("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Et[e.size]}:{}),e.weight?{fontWeight:xn[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Gt(e.tone,t.palette)),children:e.value});case"heading":{let R=`h${e.level}`;return T(R,{style:S(S({margin:0,fontSize:hn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let R=(y=e.emphasis)!=null?y:"primary";return T("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Pt(R,t.palette,e.size),children:e.label}))}case"link":return T("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return T("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:bn[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return T("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(w=(x=t.palette)==null?void 0:x.border)!=null?w:"currentColor"}`},Gt(e.tone,t.palette)),children:e.value});case"spacer":return T("div",{style:{height:(k=kt[e.size])!=null?k:kt.md}});case"divider":return T("hr",{style:{border:"none",borderTop:`1px solid ${(A=(C=t.palette)==null?void 0:C.border)!=null?A:"currentColor"}`,margin:0,width:"100%"}});case"form":return T(wn,{node:e,opts:t});default:return null}}catch(R){return null}}import{jsx as Rn}from"react/jsx-runtime";var Tt=new Set;function Ie({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var C;let c=O(),s=N(),m=Le(null),{config:o,arm:d,palette:u,source:g}=At(e,{baselineText:f?()=>{var A,R;return(R=(A=m.current)==null?void 0:A.textContent)!=null?R:null}:void 0}),b=d!==""?(C=o==null?void 0:o.blocks)==null?void 0:C[d]:void 0,h=b!==void 0&&An(b)&&!n;te(()=>{!h||!G()||Tt.has(e)||(Tt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[h,e]);let v=A=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,A),c.goal(A,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let A=h?null:ee(b,{palette:u,onFormSubmit:n,onFormGoal:v});A===null?a=!0:p=A}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";te(()=>q({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=Le(null);te(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,W(c,s,e,d))},[c,s,e,d,g,a]);let x=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);te(()=>{if(!c||!r||g==="override"||g==="none"||g==="seeded"||a)return;let A=m.current;if(!A)return;let R=K(r),_=$(r),E=!1;return V(A,B(r),{fireGoal:()=>{E||(E=!0,_!==void 0?c.componentGoal(e,R,{value:_}):c.componentGoal(e,R),c.goal(R,S({metadata:{componentId:e,arm:d},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(D,P,H)=>{c.componentGoal(e,D,{reward:P}),c.goal(D,{metadata:{componentId:e,arm:d},weight:P,stepIndex:H})}},R)},[c,e,x,d,g,a]);let w=Le(null);te(()=>{let A=m.current;if(A){if(w.current===null){w.current=d;return}w.current!==d&&(w.current=d,_n(A))}},[d]);let k=Cn(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return Rn("div",M(S({ref:m,className:i},k),{children:p}))}import{jsx as Fe}from"react/jsx-runtime";function En(e){var o;let{client:t,variantId:n,content:r,ref:i}=ue(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=On(!1);if(Gn(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return G()&&s===null&&m===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Fe("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Pn=kn(En,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||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),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Tn(e){return e.variants===void 0?Fe(Ie,S({},e)):(G()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),Fe(Pn,S({},e)))}import{useEffect as fe,useMemo as Dn,useRef as Be,useState as Dt,useSyncExternalStore as Ln}from"react";import{jsx as Fn}from"react/jsx-runtime";function In({id:e,default:t,component:n="span",className:r,goal:i}){var k;let f=O(),c=N(),s=ae(),m=se(),o=Be(null),d=Be(null),u=Ln(F,()=>Z(e),()=>null),[g,b]=Dt(()=>{var C,A;return(A=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.content)!=null?A:null}),[h,v]=Dt(()=>{var C,A;return(A=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.variantId)!=null?A:null});fe(()=>{if(u||!f)return;let C=f.getAssignment(e,m);if((C==null?void 0:C.content)!==void 0){v(C.variantId),b(C.content);return}let A=!1;return f.assign(e).then(R=>{if(!A){if(!R){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(R.variantId),R.content&&b(R.content)}}),()=>{A=!0}},[f,e,m,u]),fe(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=Dn(()=>i===void 0?null:B(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=Be(!1);fe(()=>{y.current=!1},[h,p]),fe(()=>{if(u||!f||!h||!c||!a||!l)return;let C=d.current;if(!C)return;let A=$(a);return V(C,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},A!==void 0?{goalValue:A}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(R,_,E)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:R,payload:{reward:_}}),f.goal(R,{metadata:{},weight:_,stepIndex:E})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let C=f==null?void 0:f.getAssignment(e,m);x=C&&C.variantId===u&&(k=C.content)!=null?k:t}return Fn(n,{ref:C=>{d.current=C},className:r,children:x})}import{useCallback as Bn,useRef as Mn}from"react";function Me(e){let t=O(),n=Mn(new Set);return Bn((r,i)=>{var f,c;if(!Z(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as $n,useRef as Lt}from"react";function Vn(e,t={}){let m=t,{componentId:n}=m,r=Xe(m,["componentId"]),i=O(),f=Me(n!=null?n:""),c=Lt(!1),s=Lt(r);s.current=r,$n(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}import{renderPrePaintScript as Nn}from"@sentientui/core";import{confidenceBand as jn}from"@sentientui/policy";import{jsx as Un}from"react/jsx-runtime";function It(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Kn(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+It(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+It(jn(e.persona.confidence))+");}catch(e){}})();":Nn(e.apiKey)}function Wn(e){return Un("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Kn(e)}})}import{useEffect as pe,useMemo as Ve,useRef as Yn}from"react";import{validateSlotDecl as Qn}from"@sentientui/policy";import{useEffect as $e,useReducer as Jn,useState as Xn,useSyncExternalStore as Ft}from"react";import{armOfResult as ge,baselineResultFor as Hn}from"@sentientui/core";import{confidenceBand as zn}from"@sentientui/policy";function me(e,t){let n=O(),r=le(),[,i]=Jn(u=>u+1,0),f=Ft(F,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;$e(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:ge(f),source:"override"};if(c!==void 0)return{result:c,arm:ge(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:ge(s),source:g?"client":"seeded"}}let u=Hn(t);return{result:u,arm:ge(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return $e(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function qn(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Zn(){let e=O(),t=yt();Ft(F,et,()=>0);let[n,r]=Xn(!1);$e(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:zn(s.confidence)});if(!n)return t?i(t):null;let f=qn();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Bt=new Set;function er(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tr(e,t,n){let r=O(),i=N(),f=JSON.stringify(t),c=Ve(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=me(e,c),d=Ve(()=>typeof s=="string"?{}:s,[m]);if(G()&&!Bt.has(e)){Bt.add(e);let v=Qn({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&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.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);pe(()=>q({id:e,dims:t}),[e]);let g=Yn(null);pe(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,W(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;pe(()=>{var v;!r||!b||o==="override"||z(r,i,e,b,B((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),pe(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${er(e)}"]`);if(!v){G()&&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=K(n.goal),a=$(n.goal),l=!1;return V(v,B(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,w)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:w})}},p)},[r,e,u,m,o]);let h=Ve(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}import{useCallback as nr,useEffect as rr,useMemo as ir}from"react";var Mt=new Set;function or(e,t){var b;if(G()&&!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{client:n,variantIds:r,variantId:i,isOverride:f,goalLabel:c,ref:s,nodeRef:m}=ue(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];rr(()=>{if(!G()||!n)return;let h=setTimeout(()=>{!m.current&&!Mt.has(e)&&(Mt.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(h)},[n,e]);let u=nr((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,c,f]),g=ir(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}import{Children as sr,isValidElement as ar,useEffect as ve,useMemo as $t,useRef as Vt}from"react";import{jsx as cr}from"react/jsx-runtime";var ye=new Set;function lr(e){var a;let t=O(),n=N(),r=Vt(null),i=Object.keys(e.arrangements).join(" "),f=$t(()=>Object.keys(e.arrangements),[i]),c=$t(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=me(e.id,c);G()&&e.baseline!==void 0&&e.baseline!==f[0]&&!ye.has(e.id+":baseline")&&(ye.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=sr.toArray(e.children).filter(ar),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));G()&&u!==void 0&&!g&&!ye.has(e.id+":keys")&&(ye.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;ve(()=>q({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=Vt(null);ve(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,W(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;ve(()=>{var l;!t||!v||m==="override"||z(t,n,e.id,v,B((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return ve(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=K(e.goal),x=$(e.goal),w=!1;return V(l,B(e.goal),{fireGoal:()=>{w||(w=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(k,C,A)=>{t.componentGoal(e.id,k,{reward:C}),t.goal(k,{metadata:{componentId:e.id,arm:s},weight:C,stepIndex:A})}},y)},[t,e.id,p,s,m]),cr("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}import{deriveSessionSegment as ur}from"@sentientui/core";var dr=["page","blocks","layoutOrder"],Nt=new Map;function fr(e,t){Nt.set(e,t)}function jt(e){return Nt.get(e)}function gr(e){var i,f;let t=(f=(i=e.content)!=null?i:jt(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))dr.includes(c)||(n[c]=s);let r=M(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function mr(e){return`<script type="application/ld+json">${Kt(e)}</script>`}function Kt(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function pr(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,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
+ var Jt=Object.defineProperty,Xt=Object.defineProperties;var Ht=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Ue=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable;var We=(e,t,n)=>t in e?Jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Ue.call(t,n)&&We(e,n,t[n]);if(ne)for(var n of ne(t))Je.call(t,n)&&We(e,n,t[n]);return e},M=(e,t)=>Xt(e,Ht(t));var Xe=(e,t)=>{var n={};for(var r in e)Ue.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&ne)for(var r of ne(e))t.indexOf(r)<0&&Je.call(e,r)&&(n[r]=e[r]);return n};import{createContext as en,useContext as I,useEffect as j,useMemo as gt,useRef as Oe,useState as oe,useSyncExternalStore as tn}from"react";import{deriveSessionSegment as nn,init as rn}from"@sentientui/core";var He=new Map,re=new Map;function ze(e,t){let n=re.get(e);return n||(n=new Set,re.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&re.delete(e)}}function qe(e,t){He.set(e,t);let n=re.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Se(e){var t;return(t=He.get(e))!=null?t:null}var zt={on:!1,listeners:new Set};function Ze(){if(typeof window=="undefined")return zt;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function he(){return Ze().on}function Ye(e){let t=Ze().listeners;return t.add(e),()=>{t.delete(e)}}function Qe(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var be="sentient:overrides-changed";function et(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function tt(){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 F(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(be,e),()=>window.removeEventListener(be,e))}function nt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function G(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function B(e){return typeof e=="string"?{type:"click"}:e}function K(e){return typeof e=="string"?e:e.type}function $(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var xe=new Set,we=!1;function rt(e){if(xe.has(e))return!0;if(xe.add(e),!we){we=!0;let t=()=>{we=!1,xe.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function qt(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function it(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 r=e;for(;r&&r!==t;){if(qt(r))return!0;r=r.parentElement}return!1}function V(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,d=[];return t.steps.forEach(({goal:u,name:g,weight:b},h)=>{let v=(p=!1)=>{o.has(h)||p&&r!==void 0&&rt(`step\0${g}\0${b}\0${h}`)||(o.add(h),n.fireStep(g,b,h))};if(u.type==="click"){let p=a=>{let l=a.target;l instanceof Element&&it(l,e,u.selector)&&v()};e.addEventListener("click",p),d.push(()=>e.removeEventListener("click",p));return}if(u.type==="form_submit"){let p=a=>{a.target instanceof HTMLFormElement&&e.contains(a.target)&&v()};e.addEventListener("submit",p),d.push(()=>e.removeEventListener("submit",p));return}if(u.type==="scroll_depth"){let p=Math.max(0,Math.min(1,u.threshold)),a=new IntersectionObserver(l=>{for(let y of l)if(y.intersectionRatio>=p){v(!0),a.disconnect();break}},{threshold:[p]});a.observe(e),d.push(()=>a.disconnect())}}),()=>{for(let u of d)u()}}let i=t.type==="composite"?t.all:[t],f=new Set(i.map((o,d)=>d)),c=()=>{r!==void 0&&rt(r)||n.fireGoal()},s=(o,d=!1)=>{f.delete(o),f.size===0&&(d?c():n.fireGoal())},m=[];return i.forEach((o,d)=>{if(o.type==="click"){let u=g=>{let b=g.target;b instanceof Element&&it(b,e,o.selector)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("click",u),m.push(()=>e.removeEventListener("click",u));return}if(o.type==="form_submit"){let u=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&(t.type==="composite"?s(d):n.fireGoal())};e.addEventListener("submit",u),m.push(()=>e.removeEventListener("submit",u));return}if(o.type==="scroll_depth"){let u=Math.max(0,Math.min(1,o.threshold)),g=new IntersectionObserver(b=>{for(let h of b)if(h.intersectionRatio>=u){t.type==="composite"?s(d,!0):c(),g.disconnect();break}},{threshold:[u]});g.observe(e),m.push(()=>g.disconnect());return}}),()=>{for(let o of m)o()}}var ot=new Set,st=new Set;function z(e,t,n,r,i){let f=`${r}|${n}`;if(st.has(f))return;st.add(f);let c=i.type==="weighted_composite"&&!ot.has(r);c&&ot.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(s=>({goalId:s.name,weight:s.weight}))}:{funnelId:r}})}function W(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zt={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function J(){if(typeof window=="undefined")return Zt;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 Y(){J().version+=1;for(let e of J().listeners)e()}var at=()=>{};function lt(e){return G()?(J().components.set(e.id,e),Y(),()=>{J().components.delete(e.id),Y()}):at}function q(e){return G()?(J().slots.set(e.id,e),Y(),()=>{J().slots.delete(e.id),Y()}):at}function Ce(e){G()&&(J().sections=[...e],Y())}var ct="0.34.1",Ae=ct!=="0.0.0-dev"?{name:"react",version:ct}:void 0;function Yt(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function _e(e,t){Yt()[e]=t}function Qt(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Re(e,t){Qt()[e]=t}var ut="sentient_editor",dt="sentient_preview_cell",Ge="sentient-cell-preview-bar",ke="__preview__";function ft(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ge))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ut),n=s.get(dt)}catch(s){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let i=n.slice(0,r),f=n.slice(r+1),c=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${c}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async s=>{if(!s.ok){ie(s.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 m=await s.json();if(m.blocks!=null)_e(i,{kind:"arms",blocks:{[ke]:m.blocks}}),Re(i,ke);else if(m.content!=null)_e(i,{kind:"arms",content:m.content}),Re(i,ke);else{ie("Nothing to preview in that square yet.");return}tt(),ie(`Previewing \u201C${m.slotName}\u201D for ${m.personaDisplay}${m.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var o;try{(o=document.querySelector(`[data-sentient-slot="${i}"]`))==null||o.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>ie("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ie(e){var i;if(document.getElementById(Ge))return;let t=document.createElement("div");t.id=Ge,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 r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.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"}),r.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(ut),f.searchParams.delete(dt),window.location.assign(f.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}import{jsx as un}from"react/jsx-runtime";function on(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return nn({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var mt="https://api.sentient-ui.com/v1",L=en({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:mt,debug:!1});function sn(e){let[t,n]=oe(!1),r=Oe(e);r.current=e;let{cookie:i,value:f,event:c}=e!=null?e:{},s=typeof(e==null?void 0:e.check)=="function";return j(()=>{let m=()=>{var g;let d=r.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let u=`${d.cookie}=${(g=d.value)!=null?g:"accepted"}`;return document.cookie.split("; ").some(b=>b.trim()===u)};if(n(m()),!c)return;let o=()=>{n(m())};return window.addEventListener(c,o),()=>window.removeEventListener(c,o)},[i,f,c,s]),t}function an(e){var h,v;let[t,n]=oe(null),[r]=oe(()=>{var p;return(p=e.sessionSegment)!=null?p:on()}),[i,f]=oe(he());j(()=>Ye(()=>f(he())),[]),j(()=>{ft(e.apiBaseUrl)},[]);let c=sn(e.consentFrom),s=e.consentFrom?e.consent===!0||c:e.consent,m=Oe(null);j(()=>{var w;if(s===!1&&!e.preConsentBehavior){(w=m.current)==null||w.destroy(),m.current=null,n(null);return}let p=S({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},Ae?{sdk:Ae}:{}),a=!1,l=null,y=null,x=k=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{a||(y=C(k,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:k})=>{a||(l=k(M(S({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),m.current=l,n(l),x(l))}):(l=rn(p),m.current=l,n(l),x(l)),()=>{a=!0,y==null||y(),l==null||l.dispose()}},[s]),j(()=>{if(!t)return;let p=!1,a=async()=>{if(p)return;let y;try{y=await t.fetchWeights()}catch(x){return}if(!p)for(let x of y){let w={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(k=>{var C;return{variantId:k.variantId,pulls:k.pulls,avgReward:(C=k.avgReward)!=null?C:0}})};qe(x.componentId,w)}};a();let l=setInterval(()=>{a()},6e4);return()=>{p=!0,clearInterval(l)}},[t]);let o=(h=e.ssrFallback)!=null?h:"first",d=((v=e.apiBaseUrl)!=null?v:mt).replace(/\/$/,""),u=Oe(null);j(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let p={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},a=u.current;if(u.current=p,a!==null)for(let y of["apiKey","context","country","persona","apiBaseUrl"])Object.is(a[y],p[y])||console.warn(`[sentient] AdaptiveProvider: \`${y}\` 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,d]),j(()=>{var p;typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production"||nt({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),j(()=>{let p=e.initialLayoutOrder;if(p&&p.length>0){Ce(p);return}e.declaredSections&&e.declaredSections.length>0&&Ce(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),j(()=>{if(!G())return;let p=e.declaredSections;if(!p||p.length===0||typeof document=="undefined")return;let a=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),y=>y.getAttribute("data-sentient-id"))),l=p.filter(y=>!a.has(y));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(y=>`"${y}"`).join(", ")} ${l.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=gt(()=>t&&i?Qe(t):t,[t,i]),b=gt(()=>{var p,a,l,y,x,w,k;return{client:g,apiKey:e.apiKey,initialAssignments:(p=e.initialAssignments)!=null?p:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(a=e.initialLayoutOrder)!=null?a:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(y=e.initialSlotConfig)!=null?y:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialPersona:(w=e.initialPersona)!=null?w:null,apiBaseUrl:d,debug:(k=e.debug)!=null?k:!1}},[g,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return un(L.Provider,{value:b,children:e.children})}function O(){return I(L).client}function N(){return I(L).apiKey}function Ee(){return I(L).initialAssignments}function se(){return I(L).sessionSegment}function pt(){return I(L).ssrFallback}function ae(){return I(L).onAssignment}function vt(){return I(L).debug}function ln(){let e=I(L).initialLayoutOrder,t=tn(F,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function le(){return I(L).initialSlots}function yt(){return I(L).initialPersona}function St(){return I(L).initialSlotConfig}function ht(){return I(L).initialPalette}function cn(){return I(L).apiBaseUrl}import{memo as kn,useEffect as Gn,useState as On}from"react";import{useCallback as gn,useEffect as X,useMemo as xt,useRef as Q,useState as mn}from"react";import{attachMicroSignalDetectors as pn}from"@sentientui/core";import{useEffect as ce,useRef as bt,useState as dn,useSyncExternalStore as fn}from"react";import{pickFromWeights as Pe}from"@sentientui/policy";function Z(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let f=i.indexOf(":");if(f!==-1&&i.slice(0,f)===e)return i.slice(f+1)}}catch(r){}return null}function Te(e,t,n,r){let i=Ee(),f=pt(),c=O(),s=se(),m=ae(),o=vt(),d=bt(null),u=fn(F,()=>Z(e),()=>null),g=u&&t.includes(u)?u:null,b=bt(null);ce(()=>{o&&g&&b.current!==g&&(b.current=g,console.info(`[sentient] override active: ${e} -> ${g}`))},[o,g,e]);let[h,v]=dn(()=>{var y,x;if(g)return{variantId:g,content:null,isLoading:!1,settled:!0};if(!c){let w=i[e];return w&&t.includes(w)?{variantId:w,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content))return{variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0};let l=Se(e);if(l){let w=Pe(l.variants,t);if(w)return{variantId:w,content:null,isLoading:!1,settled:!0}}return{variantId:(x=t[0])!=null?x:null,content:null,isLoading:!1,settled:!1}}),p=a=>{m&&d.current!==a&&(d.current=a,m(e,a))};return ce(()=>{var y;if(g||!c)return;let a=c.getAssignment(e,s);if(a&&(t.includes(a.variantId)||a.content)){v({variantId:a.variantId,content:(y=a.content)!=null?y:null,isLoading:!1,settled:!0}),p(a.variantId);return}let l=Se(e);if(l&&h.settled&&h.variantId&&h.variantId===Pe(l.variants,t)){p(h.variantId);return}v(x=>{var w;return x.variantId?x:{variantId:(w=t[0])!=null?w:null,content:null,isLoading:!1,settled:!1}})},[g,c,e,s]),ce(()=>{if(g||!c)return;let a=c.getAssignment(e,s);if(a&&t.includes(a.variantId))return;let l=!1;return c.assign(e,t,n,r).then(y=>{var x;l||y&&(!t.includes(y.variantId)&&!y.content||(v({variantId:y.variantId,content:(x=y.content)!=null?x:null,isLoading:!1,settled:!0}),p(y.variantId)))}),()=>{l=!0}},[g,c,e,s]),ce(()=>{if(!g&&c)return ze(e,a=>{var x;let l=c.getAssignment(e,s);if(l&&(t.includes(l.variantId)||l.content)){v({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),p(l.variantId);return}let y=Pe(a.variants,t);y&&(v({variantId:y,content:null,isLoading:!1,settled:!0}),p(y))})},[g,c,e,s]),g?{variantId:g,content:null,isLoading:!1,settled:!0,isOverride:!0}:h}function ue(e,t,n){let r=O(),i=N(),f=Object.keys(t).join("\0"),c=xt(()=>Object.keys(t),[f]),{variantId:s,content:m,isOverride:o=!1,settled:d}=Te(e,c,n.agentData,n.agentDataByVariant),[u,g]=mn(null),b=Q(null),h=gn(_=>{b.current=_,g(_)},[]),v=n.goal,p=typeof v=="string"?v:JSON.stringify(v),a=xt(()=>v?B(v):null,[p]),l=v?K(v):"";X(()=>lt({id:e,variantIds:c,goal:l}),[e,c,l]);let y=Q(null);X(()=>{o||d&&(!r||!s||!i||!u||y.current!==s&&(y.current=s,W(r,i,e,s)))},[r,s,i,e,u,o,d]);let x=Q(!1),w=Q(new Set);X(()=>{x.current=!1,w.current=new Set},[s,a]);let k=n.funnel;X(()=>{o||!d||!r||!k||!a||z(r,i,e,k,a)},[r,i,e,k,a,o,d]);let C=n.cursorSignal===!0;X(()=>{if(!C||o||!d||!r||!s||!u)return;let _=null,E=0,D=()=>{E=Date.now(),_=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-E}}),_=null},800)},P=()=>{_!==null&&(clearTimeout(_),_=null)};return u.addEventListener("mouseenter",D),u.addEventListener("mouseleave",P),()=>{u.removeEventListener("mouseenter",D),u.removeEventListener("mouseleave",P),_!==null&&clearTimeout(_)}},[C,r,s,i,e,u,o,d]);let A=Q(n.microSignalGoals);A.current=n.microSignalGoals;let R=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return X(()=>{if(o||!d||!r||!s||!u)return;let _=Date.now();return pn((E,D={})=>{var Ne,je,Ke;r.track({projectId:i,componentId:e,variantId:s,eventType:"micro_signal",payload:S({signalType:E},D)});let P=(Ne=A.current)==null?void 0:Ne[E];if(!P||w.current.has(E))return;w.current.add(E);let H=typeof P=="string"?P:P.name,Wt=typeof P=="string"?1:(je=P.weight)!=null?je:1,Ut=typeof P=="string"?0:(Ke=P.stepIndex)!=null?Ke:0;r.goal(H,{metadata:S({signalType:E},D),weight:Wt,stepIndex:Ut})},u,_)},[r,s,i,e,u,R,o,d]),X(()=>{if(o||!d||!r||!s||!u||!a)return;let _=$(a);return V(u,a,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:l,payload:S({reward:1},_!==void 0?{goalValue:_}:{})}),r.goal(l,S({metadata:{componentId:e,variantId:s},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(E,D,P)=>{r.track({projectId:i,componentId:e,variantId:s,eventType:"goal_achieved",goalType:E,payload:{reward:D}}),r.goal(E,{metadata:{},weight:D,stepIndex:P})}},l)},[r,s,i,e,u,a,l,o,d]),{client:r,variantIds:c,variantId:s,content:m,settled:d,isOverride:o,goalLabel:l,ref:h,nodeRef:b}}import{useEffect as te,useMemo as Cn,useRef as Le}from"react";import{containsFormBlock as An,reveal as _n}from"@sentientui/core";import{useCallback as vn,useEffect as wt,useRef as yn,useSyncExternalStore as de}from"react";import{armOfResult as Sn}from"@sentientui/core";var Ct=new Set;function At(e,t){var p;let n=O(),r=yn(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=le(),f=St(),c=ht(),s=de(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_config_overrides)==null?void 0:a[e]:void 0},()=>{}),m=de(F,()=>{var a;return typeof window!="undefined"?(a=window.__sentient_slot_overrides)==null?void 0:a[e]:void 0},()=>{}),o=a=>a==null?"":Sn(a),d=vn(a=>{var l,y;return(y=(l=n==null?void 0:n.onSlotsChanged)==null?void 0:l.call(n,a))!=null?y:(()=>{})},[n]);de(d,()=>{var a;return(a=n==null?void 0:n.getSlotConfig(e))!=null?a:null},()=>null),de(d,()=>o(n==null?void 0:n.getSlotResult(e)),()=>"");let u=s===void 0?f[e]:void 0,g=s===void 0&&u===void 0&&n?n.getSlotConfig(e):null,b=(p=c!=null?c:n==null?void 0:n.getSitePalette())!=null?p:null,h=(()=>{var a,l;if(s!==void 0)return{config:s,arm:o(m),palette:b,source:"override"};if(u!==void 0)return{config:u,arm:o((a=i[e])!=null?a:n==null?void 0:n.getSlotResult(e)),palette:b,source:"preloaded"};if(g!==null){let y=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:g,arm:o((l=n==null?void 0:n.getSlotResult(e))!=null?l:i[e]),palette:b,source:y?"client":"seeded"}}return{config:null,arm:"",palette:b,source:"none"}})(),v=h.source==="preloaded"||h.source==="override";return wt(()=>{var y,x;if(!n||n.isLocal===!0||v)return;let a=h.source==="none"&&(x=(y=r.current)==null?void 0:y.call(r))!=null?x:null,l=a!=null&&a!==""?[[e],{[e]:a}]:[[e]];return n.requestSlots?n.requestSlots(...l):h.source==="none"&&n.reportSlots(...l),()=>{var w;return(w=n.cancelSlots)==null?void 0:w.call(n,[e])}},[n,v,h.source,e]),wt(()=>{!G()||(n==null?void 0:n.isLocal)!==!0||h.source!=="none"||Ct.has(e)||(Ct.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,h.source,e]),h}import{Fragment as _t}from"react";import{jsx as T,jsxs as Ot}from"react/jsx-runtime";var U={none:"0",sm:"8px",md:"16px",lg:"24px"},De={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Et={sm:"0.875em",md:"1em",lg:"1.25em"},hn={sm:"1.25em",md:"1.5em",lg:"2em"},Rt={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},kt={sm:"8px",md:"16px",lg:"32px"},bn={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},xn={normal:"400",medium:"500",bold:"700"};function Gt(e,t){return S(S({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?S({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Pt(e,t,n){var i,f,c,s;let r=t==null?void 0:t.accent;return M(S({display:"inline-block",padding:(i=Rt[n!=null?n:"md"])!=null?i:Rt.md,borderRadius:(f=t==null?void 0:t.radius)!=null?f:"8px",font:"inherit"},n?{fontSize:Et[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(c=t==null?void 0:t.primaryBg)!=null?c:"#111827":"transparent",color:e==="primary"?(s=t==null?void 0:t.primaryText)!=null?s:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function wn({node:e,opts:t}){var i,f,c,s,m;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(f=t.palette)==null?void 0:f.border)!=null?c:"currentColor"}`,borderRadius:(m=(s=t.palette)==null?void 0:s.radius)!=null?m:"8px"};return Ot("form",{onSubmit:o=>{var g,b,h;o.preventDefault();let d=new FormData(o.currentTarget),u={};for(let v of e.fields)u[v.name]=String((g=d.get(v.name))!=null?g:"");(b=t.onFormGoal)==null||b.call(t,e.submitGoal);try{(h=t.onFormSubmit)==null||h.call(t,u)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var d,u;return Ot("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?T("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?T("select",{name:o.name,required:o.required,style:r,children:((d=o.options)!=null?d:[]).map(g=>T("option",{value:g,children:g},g))}):T("input",{name:o.name,type:(u=o.inputType)!=null?u:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),T("button",{type:"submit",style:Pt(n,t.palette),children:e.submitLabel})]})}function ee(e,t){var n,r,i,f,c,s,m,o,d,u,g,b,h,v,p,a,l,y,x,w,k,C,A;try{switch(e.type){case"stack":{let R=(r=U[(n=e.gap)!=null?n:"md"])!=null?r:U.md,_=e.surface==="raised",E=(i=e.pad)!=null?i:_?"md":void 0;return T("div",{style:S(S(S(S(S({display:"flex",flexDirection:e.direction,gap:R},e.align?{alignItems:De[e.align]}:{}),e.justify?{justifyContent:De[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),E?{padding:(f=U[E])!=null?f:U.md}:{}),_?M(S(S({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(s=t.palette)!=null&&s.surface&&((m=t.palette)!=null&&m.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(d=(o=t.palette)==null?void 0:o.border)!=null?d:"currentColor"}`,borderRadius:(g=(u=t.palette)==null?void 0:u.radius)!=null?g:"8px"}):{}),children:((b=e.children)!=null?b:[]).map((D,P)=>{let H=ee(D,t);return H===null?null:T(_t,{children:H},P)})})}case"grid":{let R=(v=U[(h=e.gap)!=null?h:"md"])!=null?v:U.md;return T("div",{style:S(S({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${R}) / ${e.columns})), 1fr))`,gap:R},e.align?{alignItems:De[e.align]}:{}),e.pad?{padding:(p=U[e.pad])!=null?p:U.md}:{}),children:((a=e.children)!=null?a:[]).map((_,E)=>{let D=ee(_,t);return D===null?null:T(_t,{children:D},E)})})}case"text":return T("p",{style:S(S(S(S(S({margin:0},e.size?{fontSize:Et[e.size]}:{}),e.weight?{fontWeight:xn[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Gt(e.tone,t.palette)),children:e.value});case"heading":{let R=`h${e.level}`;return T(R,{style:S(S({margin:0,fontSize:hn[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let R=(y=e.emphasis)!=null?y:"primary";return T("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:Pt(R,t.palette,e.size),children:e.label}))}case"link":return T("a",M(S({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),{style:{color:"inherit",textDecoration:"underline"},children:e.label}));case"image":return T("img",{src:e.src,alt:e.alt,style:S(S({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:bn[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})});case"badge":return T("span",{style:S({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(w=(x=t.palette)==null?void 0:x.border)!=null?w:"currentColor"}`},Gt(e.tone,t.palette)),children:e.value});case"spacer":return T("div",{style:{height:(k=kt[e.size])!=null?k:kt.md}});case"divider":return T("hr",{style:{border:"none",borderTop:`1px solid ${(A=(C=t.palette)==null?void 0:C.border)!=null?A:"currentColor"}`,margin:0,width:"100%"}});case"form":return T(wn,{node:e,opts:t});default:return null}}catch(R){return null}}import{jsx as Rn}from"react/jsx-runtime";var Tt=new Set;function Ie({id:e,children:t,onFormSubmit:n,goal:r,className:i,reportBaselineText:f=!0}){var C;let c=O(),s=N(),m=Le(null),{config:o,arm:d,palette:u,source:g}=At(e,{baselineText:f?()=>{var A,R;return(R=(A=m.current)==null?void 0:A.textContent)!=null?R:null}:void 0}),b=d!==""?(C=o==null?void 0:o.blocks)==null?void 0:C[d]:void 0,h=b!==void 0&&An(b)&&!n;te(()=>{!h||!G()||Tt.has(e)||(Tt.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[h,e]);let v=A=>{!c||g==="override"||(g!=="seeded"&&c.componentGoal(e,A),c.goal(A,{metadata:{componentId:e,arm:d},weight:1,stepIndex:0}))},p=t,a=!1;if(b!==void 0){let A=h?null:ee(b,{palette:u,onFormSubmit:n,onFormGoal:v});A===null?a=!0:p=A}else(o==null?void 0:o.content)!==void 0&&g!=="none"&&(p=o.content);let l=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";te(()=>q({id:e,arms:l===""?void 0:l.split("|")}),[e,l]);let y=Le(null);te(()=>{!c||g==="none"||g==="seeded"||g==="override"||d===""||a||y.current!==d&&(y.current=d,W(c,s,e,d))},[c,s,e,d,g,a]);let x=r===void 0?null:typeof r=="string"?r:JSON.stringify(r);te(()=>{if(!c||!r||g==="override"||g==="none"||g==="seeded"||a)return;let A=m.current;if(!A)return;let R=K(r),_=$(r),E=!1;return V(A,B(r),{fireGoal:()=>{E||(E=!0,_!==void 0?c.componentGoal(e,R,{value:_}):c.componentGoal(e,R),c.goal(R,S({metadata:{componentId:e,arm:d},weight:1,stepIndex:0},_!==void 0?{value:_}:{})))},fireStep:(D,P,H)=>{c.componentGoal(e,D,{reward:P}),c.goal(D,{metadata:{componentId:e,arm:d},weight:P,stepIndex:H})}},R)},[c,e,x,d,g,a]);let w=Le(null);te(()=>{let A=m.current;if(A){if(w.current===null){w.current=d;return}w.current!==d&&(w.current=d,_n(A))}},[d]);let k=Cn(()=>S({"data-sentient-slot":e},d!==""?{"data-sentient-arm":d}:{}),[e,d]);return Rn("div",M(S({ref:m,className:i},k),{children:p}))}import{jsx as Fe}from"react/jsx-runtime";function En(e){var o;let{client:t,variantId:n,content:r,ref:i}=ue(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[f,c]=On(!1);if(Gn(()=>{c(!0)},[]),e.clientOnly&&(!f||!t)||!n)return null;let s=(o=e.variants[n])!=null?o:null,m=s===null?r:null;return G()&&s===null&&m===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Fe("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:m})}var Pn=kn(En,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||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),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Tn(e){return e.variants===void 0?Fe(Ie,S({},e)):(G()&&e.children!=null&&console.warn(`[sentient] <Adaptive id="${e.id}"> got both variants and children \u2014 rendering variants; children are ignored.`),Fe(Pn,S({},e)))}import{useEffect as fe,useMemo as Dn,useRef as Be,useState as Dt,useSyncExternalStore as Ln}from"react";import{jsx as Fn}from"react/jsx-runtime";function In({id:e,default:t,component:n="span",className:r,goal:i}){var k;let f=O(),c=N(),s=ae(),m=se(),o=Be(null),d=Be(null),u=Ln(F,()=>Z(e),()=>null),[g,b]=Dt(()=>{var C,A;return(A=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.content)!=null?A:null}),[h,v]=Dt(()=>{var C,A;return(A=(C=f==null?void 0:f.getAssignment(e,m))==null?void 0:C.variantId)!=null?A:null});fe(()=>{if(u||!f)return;let C=f.getAssignment(e,m);if((C==null?void 0:C.content)!==void 0){v(C.variantId),b(C.content);return}let A=!1;return f.assign(e).then(R=>{if(!A){if(!R){G()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(R.variantId),R.content&&b(R.content)}}),()=>{A=!0}},[f,e,m,u]),fe(()=>{u||!f||!h||!c||o.current!==h&&(o.current=h,f.track({projectId:c,componentId:e,variantId:h,eventType:"variant_assigned",payload:{}}),s==null||s(e,h))},[f,h,c,e,s,u]);let p=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),a=Dn(()=>i===void 0?null:B(i),[p]),l=i===void 0?null:typeof i=="string"?i:a.type,y=Be(!1);fe(()=>{y.current=!1},[h,p]),fe(()=>{if(u||!f||!h||!c||!a||!l)return;let C=d.current;if(!C)return;let A=$(a);return V(C,a,{fireGoal:()=>{y.current||(y.current=!0,f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:l,payload:S({reward:1},A!==void 0?{goalValue:A}:{})}),f.goal(l,S({metadata:{componentId:e,variantId:h},weight:1,stepIndex:0},A!==void 0?{value:A}:{})))},fireStep:(R,_,E)=>{f.track({projectId:c,componentId:e,variantId:h,eventType:"goal_achieved",goalType:R,payload:{reward:_}}),f.goal(R,{metadata:{},weight:_,stepIndex:E})}})},[f,h,c,e,a,l,u]);let x=g!=null?g:t;if(u){let C=f==null?void 0:f.getAssignment(e,m);x=C&&C.variantId===u&&(k=C.content)!=null?k:t}return Fn(n,{ref:C=>{d.current=C},className:r,children:x})}import{useCallback as Bn,useRef as Mn}from"react";function Me(e){let t=O(),n=Mn(new Set);return Bn((r,i)=>{var f,c;if(!Z(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,S(S(S({metadata:(f=i==null?void 0:i.metadata)!=null?f:{},weight:(c=i==null?void 0:i.reward)!=null?c:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as $n,useRef as Lt}from"react";function Vn(e,t={}){let m=t,{componentId:n}=m,r=Xe(m,["componentId"]),i=O(),f=Me(n!=null?n:""),c=Lt(!1),s=Lt(r);s.current=r,$n(()=>{if(!i||c.current)return;c.current=!0;let{metadata:o,reward:d,value:u,currency:g,externalId:b}=s.current;if(n){f(e,s.current);return}i.goal(e,S(S(S({metadata:o!=null?o:{},weight:d!=null?d:1,stepIndex:0},u!==void 0?{value:u}:{}),g!==void 0?{currency:g}:{}),b!==void 0?{externalId:b}:{}))},[i,n,e,f])}import{renderPrePaintScript as Nn}from"@sentientui/core";import{confidenceBand as jn}from"@sentientui/policy";import{jsx as Un}from"react/jsx-runtime";function It(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Kn(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+It(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+It(jn(e.persona.confidence))+");}catch(e){}})();":Nn(e.apiKey)}function Wn(e){return Un("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Kn(e)}})}import{useEffect as pe,useMemo as Ve,useRef as Yn}from"react";import{validateSlotDecl as Qn}from"@sentientui/policy";import{useEffect as $e,useReducer as Jn,useState as Xn,useSyncExternalStore as Ft}from"react";import{armOfResult as ge,baselineResultFor as Hn}from"@sentientui/core";import{confidenceBand as zn}from"@sentientui/policy";function me(e,t){let n=O(),r=le(),[,i]=Jn(u=>u+1,0),f=Ft(F,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),c=f===void 0?r[e]:void 0,s=f===void 0&&c===void 0&&n?n.getSlotResult(e):null,m=(n==null?void 0:n.isLocal)===!0&&f===void 0&&c===void 0&&s===null;$e(()=>{if(!m||!n)return;let u=!1;return n.decide({slots:[t]}).then(g=>{!u&&g&&i()}),()=>{u=!0}},[n,e,m]);let o=(()=>{if(f!==void 0)return{result:f,arm:ge(f),source:"override"};if(c!==void 0)return{result:c,arm:ge(c),source:"preloaded"};if(s!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:s,arm:ge(s),source:g?"client":"seeded"}}let u=Hn(t);return{result:u,arm:ge(u),source:"baseline"}})(),d=o.source==="preloaded"||o.source==="override";return $e(()=>{var g;if(!n||n.isLocal===!0||d||!n.decideSlots)return;let u=(g=n.onSlotsChanged)==null?void 0:g.call(n,i);return n.decideSlots([t]),()=>{var b;(b=n.cancelSlots)==null||b.call(n,[e]),u==null||u()}},[n,e,d]),o}function qn(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Zn(){let e=O(),t=yt();Ft(F,et,()=>0);let[n,r]=Xn(!1);$e(()=>r(!0),[]);let i=s=>({persona:s.persona,confidence:s.confidence,band:zn(s.confidence)});if(!n)return t?i(t):null;let f=qn();if(f)return i(f);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Bt=new Set;function er(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function tr(e,t,n){let r=O(),i=N(),f=JSON.stringify(t),c=Ve(()=>({id:e,dims:t}),[e,f]),{result:s,arm:m,source:o}=me(e,c),d=Ve(()=>typeof s=="string"?{}:s,[m]);if(G()&&!Bt.has(e)){Bt.add(e);let v=Qn({id:e,dims:Object.fromEntries(Object.entries(t).map(([a,l])=>[a,[...l]]))}),p=Object.values(t).reduce((a,l)=>a*l.length,1);v.ok?p>4&&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.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);pe(()=>q({id:e,dims:t}),[e]);let g=Yn(null);pe(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||g.current===m||(g.current=m,W(r,i,e,m))},[r,i,e,m,o]);let b=n==null?void 0:n.funnel;pe(()=>{var v;!r||!b||o==="override"||z(r,i,e,b,B((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,b,u,o]),pe(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${er(e)}"]`);if(!v){G()&&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=K(n.goal),a=$(n.goal),l=!1;return V(v,B(n.goal),{fireGoal:()=>{l||(l=!0,a!==void 0?r.componentGoal(e,p,{value:a}):r.componentGoal(e,p),r.goal(p,S({metadata:{componentId:e,arm:m},weight:1,stepIndex:0},a!==void 0?{value:a}:{})))},fireStep:(y,x,w)=>{r.componentGoal(e,y,{reward:x}),r.goal(y,{metadata:{componentId:e,arm:m},weight:x,stepIndex:w})}},p)},[r,e,u,m,o]);let h=Ve(()=>{let v={"data-sentient-slot":e};for(let[p,a]of Object.entries(d))v[`data-${p}`]=a;return v},[e,d]);return{tokens:d,props:h}}import{useCallback as nr,useEffect as rr,useMemo as ir}from"react";var Mt=new Set;function or(e,t){var b;if(G()&&!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{client:n,variantIds:r,variantId:i,isOverride:f,goalLabel:c,ref:s,nodeRef:m}=ue(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(b=i!=null?i:r[0])!=null?b:"",d=t.variants[o];rr(()=>{if(!G()||!n)return;let h=setTimeout(()=>{!m.current&&!Mt.has(e)&&(Mt.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(h)},[n,e]);let u=nr((h,v)=>{var a,l;if(f)return;let p=h!=null?h:c;p&&(n==null||n.componentGoal(e,p,v),n==null||n.goal(p,S(S(S({metadata:(a=v==null?void 0:v.metadata)!=null?a:{},weight:(l=v==null?void 0:v.reward)!=null?l:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,c,f]),g=ir(()=>({ref:s,"data-sentient-id":e,"data-sentient-variant":o}),[s,e,o]);return{variant:o,value:d,bind:g,fireGoal:u}}import{Children as sr,isValidElement as ar,useEffect as ve,useMemo as $t,useRef as Vt}from"react";import{jsx as cr}from"react/jsx-runtime";var ye=new Set;function lr(e){var a;let t=O(),n=N(),r=Vt(null),i=Object.keys(e.arrangements).join(" "),f=$t(()=>Object.keys(e.arrangements),[i]),c=$t(()=>S({id:e.id,arms:f},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,f,e.baseline]),{arm:s,source:m}=me(e.id,c);G()&&e.baseline!==void 0&&e.baseline!==f[0]&&!ye.has(e.id+":baseline")&&(ye.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${f[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=sr.toArray(e.children).filter(ar),d=new Map;for(let l of o)d.set(String((a=l.key)!=null?a:"").replace(/^\.\$/,""),l);let u=e.arrangements[s],g=u!==void 0&&u.length===o.length&&u.every(l=>d.has(l));G()&&u!==void 0&&!g&&!ye.has(e.id+":keys")&&(ye.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${s}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let b=g?u.map(l=>d.get(l)):o;ve(()=>q({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let h=Vt(null);ve(()=>{!t||m==="baseline"||m==="seeded"||m==="override"||h.current===s||(h.current=s,W(t,n,e.id,s))},[t,n,e.id,s,m]);let v=e.funnel;ve(()=>{var l;!t||!v||m==="override"||z(t,n,e.id,v,B((l=e.goal)!=null?l:"click"))},[t,n,e.id,v,m]);let p=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return ve(()=>{if(!t||e.goal===void 0||m==="override"||m==="baseline"||m==="seeded")return;let l=r.current;if(!l)return;let y=K(e.goal),x=$(e.goal),w=!1;return V(l,B(e.goal),{fireGoal:()=>{w||(w=!0,x!==void 0?t.componentGoal(e.id,y,{value:x}):t.componentGoal(e.id,y),t.goal(y,S({metadata:{componentId:e.id,arm:s},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(k,C,A)=>{t.componentGoal(e.id,k,{reward:C}),t.goal(k,{metadata:{componentId:e.id,arm:s},weight:C,stepIndex:A})}},y)},[t,e.id,p,s,m]),cr("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":s,children:b})}import{deriveSessionSegment as ur}from"@sentientui/core";var dr=["page","blocks","layoutOrder"],Nt=new Map;function fr(e,t){Nt.set(e,t)}function jt(e){return Nt.get(e)}function gr(e){var i,f;let t=(f=(i=e.content)!=null?i:jt(e.page))!=null?f:{},n={};for(let[c,s]of Object.entries(t))dr.includes(c)||(n[c]=s);let r=M(S({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function mr(e){return`<script type="application/ld+json">${Kt(e)}</script>`}function Kt(e){return JSON.stringify(S({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function pr(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,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
4
  `}import{grantConsent as Zo}from"@sentientui/core";export{Tn as Adaptive,lr as AdaptiveGroup,an as AdaptiveProvider,Ie as AdaptiveSlot,In as AdaptiveText,Wn as SentientPersonaScript,gr as buildAgentFeed,fr as defineAgentContent,ur as detectSegment,jt as getAgentContent,Zo as grantConsent,mr as renderAgentJsonLd,Kt as renderAgentJsonLdBody,pr as renderAgentMarkdown,ee as renderBlocks,or as useAdaptive,cn as useAdaptiveApiBaseUrl,Me as useAdaptiveGoal,Zn as useAdaptivePersona,tr as useAdaptiveTokens,Te as useAssignment,Ee as useInitialAssignments,ln as useLayoutOrder,Vn as usePageGoal,O as useSentient};
5
5
  //# sourceMappingURL=index.mjs.map
@@ -279,8 +279,13 @@ type AdaptiveRootProps = Omit<AdaptiveProviderProps, 'initialAssignments' | 'onA
279
279
  */
280
280
  consentFrom?: Omit<NonNullable<AdaptiveProviderProps['consentFrom']>, 'check'>;
281
281
  /**
282
- * Components to assign server-side (SEO-safe). Optional — omit when the
283
- * tree uses only slots/sections, or assigns client-side via hooks.
282
+ * Code-variant components to assign server-side (SEO-safe). Optional — an
283
+ * `<Adaptive>` works without an entry here and assigns after mount.
284
+ *
285
+ * List only ids this tree actually renders. Each one is assigned on every
286
+ * request, rendered or not, and every assignment logs an impression (or a
287
+ * holdout exposure). An id the page never renders therefore accrues trials
288
+ * that cannot convert, and in a root layout that happens on every route.
284
289
  */
285
290
  components?: PreloadComponent[];
286
291
  /**
@@ -384,7 +389,8 @@ type AdaptiveRootProps = Omit<AdaptiveProviderProps, 'initialAssignments' | 'onA
384
389
  * Without `sections`, individual `/v1/assign` calls are made per component.
385
390
  *
386
391
  * @example
387
- * // app/page.tsx — with section layout
392
+ * // app/page.tsx — with section layout. Declared on the page (not the root
393
+ * // layout) because hero_cta renders only here; see the `components` prop.
388
394
  * import { AdaptiveRoot } from '@sentientui/react/next';
389
395
  *
390
396
  * export default async function Page() {
@@ -1,4 +1,4 @@
1
- var he=Object.defineProperty,Se=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var Z=(e,t,n)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))ee.call(t,n)&&Z(e,n,t[n]);if(O)for(var n of O(t))te.call(t,n)&&Z(e,n,t[n]);return e},A=(e,t)=>Se(e,ve(t));var ne=(e,t)=>{var n={};for(var s in e)ee.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&O)for(var s of O(e))t.indexOf(s)<0&&te.call(e,s)&&(n[s]=e[s]);return n};import{deriveSessionSegment as De,extractTrackedParams as Ce,matchedAgentToken as Ke}from"@sentientui/core";import{cookies as Ue,headers as _e}from"next/headers";import{renderPrePaintScript as ke}from"@sentientui/core";import{confidenceBand as Re}from"@sentientui/policy";import{jsx as be}from"react/jsx-runtime";function se(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ie(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+se(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+se(Re(e.persona.confidence))+");}catch(e){}})();":ke(e.apiKey)}function re(e){return be("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ie(e)}})}import{preloadAssignments as Pe,readSessionCookie as we}from"@sentientui/core/server";import{preloadDecisions as Ge}from"@sentientui/core/server";function oe(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`snt-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}async function ie(e,t){var r,o,i;let n=(i=(o=we(t.cookies,t.apiKey))!=null?o:(r=t.createSessionId)==null?void 0:r.call(t))!=null?i:oe();return{assignments:await Pe(e,n,{apiKey:t.apiKey,baseUrl:t.baseUrl,origin:t.origin,userAgent:t.userAgent,referer:t.referer,utmParams:t.utmParams,clickIds:t.clickIds,doNotTrack:t.doNotTrack,timeoutMs:t.timeoutMs,persona:t.persona}),sessionId:n}}async function ae(e){var i,d,S,v,p,b,k,P,a,l;let{preloadDecisions:t,readSessionCookie:n}=await import("@sentientui/core/server"),s=(S=(d=n(e.cookies,e.apiKey))!=null?d:(i=e.createSessionId)==null?void 0:i.call(e))!=null?S:oe();if(!(typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_"))){let m={layoutOrder:(v=e.sections)!=null?v:[],assignments:{},slots:{},persona:"unknown",confidence:0,sessionId:s};try{let f=await import("@sentientui/core/local");if(!f.LOCAL_ENGINE_AVAILABLE)return console.error("[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development."),m;let c=f.createLocalEngine({sessionId:s}).decide({sections:e.sections,components:(p=e.components)!=null?p:[],slots:(b=e.slots)!=null?b:[]});return{layoutOrder:(P=(k=c.layoutOrder)!=null?k:e.sections)!=null?P:[],assignments:c.assignments,slots:c.slots,persona:c.persona,confidence:c.confidence,sessionId:s}}catch(f){return m}}let o=await t({sections:e.sections,components:(a=e.components)!=null?a:[],slots:(l=e.slots)!=null?l:[],slotsFrom:e.slotsFrom,registrySlotIds:e.registrySlotIds},s,{apiKey:e.apiKey,baseUrl:e.baseUrl,origin:e.origin,userAgent:e.userAgent,referer:e.referer,utmParams:e.utmParams,clickIds:e.clickIds,doNotTrack:e.doNotTrack,timeoutMs:e.timeoutMs,persona:e.persona});return A(u({},o),{sessionId:s})}import{AdaptiveRootClient as Te}from"./adaptive-root-client.js";var Fe=["page","blocks","layoutOrder"],ce=new Map;function Oe(e,t){ce.set(e,t)}function xe(e){return ce.get(e)}function D(e){var r,o;let t=(o=(r=e.content)!=null?r:xe(e.page))!=null?o:{},n={};for(let[i,d]of Object.entries(t))Fe.includes(i)||(n[i]=d);let s=A(u({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(s.layoutOrder=e.layoutOrder),s}function de(e){return JSON.stringify(u({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function le(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,s]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(s,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(`
1
+ var he=Object.defineProperty,Se=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var Z=(e,t,n)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))ee.call(t,n)&&Z(e,n,t[n]);if(F)for(var n of F(t))te.call(t,n)&&Z(e,n,t[n]);return e},A=(e,t)=>Se(e,ve(t));var ne=(e,t)=>{var n={};for(var s in e)ee.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&F)for(var s of F(e))t.indexOf(s)<0&&te.call(e,s)&&(n[s]=e[s]);return n};import{deriveSessionSegment as De,extractTrackedParams as Ce,matchedAgentToken as Ke}from"@sentientui/core";import{cookies as Ue,headers as _e}from"next/headers";import{renderPrePaintScript as ke}from"@sentientui/core";import{confidenceBand as Re}from"@sentientui/policy";import{jsx as be}from"react/jsx-runtime";function se(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ie(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+se(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+se(Re(e.persona.confidence))+");}catch(e){}})();":ke(e.apiKey)}function re(e){return be("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ie(e)}})}import{preloadAssignments as Pe,readSessionCookie as we}from"@sentientui/core/server";import{preloadDecisions as Ge}from"@sentientui/core/server";function oe(){return typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`snt-${Date.now()}-${Math.random().toString(36).slice(2,11)}`}async function ie(e,t){var r,o,i;let n=(i=(o=we(t.cookies,t.apiKey))!=null?o:(r=t.createSessionId)==null?void 0:r.call(t))!=null?i:oe();return{assignments:await Pe(e,n,{apiKey:t.apiKey,baseUrl:t.baseUrl,origin:t.origin,userAgent:t.userAgent,referer:t.referer,utmParams:t.utmParams,clickIds:t.clickIds,doNotTrack:t.doNotTrack,timeoutMs:t.timeoutMs,persona:t.persona}),sessionId:n}}async function ae(e){var i,l,S,v,p,b,k,P,a,g;let{preloadDecisions:t,readSessionCookie:n}=await import("@sentientui/core/server"),s=(S=(l=n(e.cookies,e.apiKey))!=null?l:(i=e.createSessionId)==null?void 0:i.call(e))!=null?S:oe();if(!(typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_"))){let m={layoutOrder:(v=e.sections)!=null?v:[],assignments:{},slots:{},persona:"unknown",confidence:0,sessionId:s};try{let f=await import("@sentientui/core/local");if(!f.LOCAL_ENGINE_AVAILABLE)return console.error("[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development."),m;let c=f.createLocalEngine({sessionId:s}).decide({sections:e.sections,components:(p=e.components)!=null?p:[],slots:(b=e.slots)!=null?b:[]});return{layoutOrder:(P=(k=c.layoutOrder)!=null?k:e.sections)!=null?P:[],assignments:c.assignments,slots:c.slots,persona:c.persona,confidence:c.confidence,sessionId:s}}catch(f){return m}}let o=await t({sections:e.sections,components:(a=e.components)!=null?a:[],slots:(g=e.slots)!=null?g:[],slotsFrom:e.slotsFrom,registrySlotIds:e.registrySlotIds},s,{apiKey:e.apiKey,baseUrl:e.baseUrl,origin:e.origin,userAgent:e.userAgent,referer:e.referer,utmParams:e.utmParams,clickIds:e.clickIds,doNotTrack:e.doNotTrack,timeoutMs:e.timeoutMs,persona:e.persona});return A(u({},o),{sessionId:s})}import{AdaptiveRootClient as Te}from"./adaptive-root-client.js";var Fe=["page","blocks","layoutOrder"],ce=new Map;function Oe(e,t){ce.set(e,t)}function xe(e){return ce.get(e)}function E(e){var r,o;let t=(o=(r=e.content)!=null?r:xe(e.page))!=null?o:{},n={};for(let[i,l]of Object.entries(t))Fe.includes(i)||(n[i]=l);let s=A(u({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(s.layoutOrder=e.layoutOrder),s}function de(e){return JSON.stringify(u({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function le(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,s]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(s,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
2
  `).trimEnd()+`
3
- `}function ge(e,t={}){var s,r;let n=(s=t.fetchImpl)!=null?s:fetch;try{n(`${e.baseUrl}/crawler-events`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({path:e.path,botName:e.botName,userAgent:(r=e.userAgent)!=null?r:null,source:"ssr"})}).catch(()=>{})}catch(o){}}import{matchedAgentToken as Le}from"@sentientui/core";function Ne(e,t){return e.pathname.endsWith(".md")||t.toLowerCase().includes("text/markdown")}function Ee(e){return async t=>{var d;let n=new URL(t.url),s=(d=t.headers.get("accept"))!=null?d:"",r=t.headers.get("user-agent"),o=n.pathname.replace(/\.(md|json)$/,"");if(e.onRead)try{Promise.resolve(e.onRead({path:o,userAgent:r,botName:Le(r!=null?r:"")})).catch(()=>{})}catch(S){}let i=await e.getFeed(t);return Ne(n,s)?new Response(le(i),{headers:{"content-type":"text/markdown; charset=utf-8"}}):new Response(JSON.stringify(i),{headers:{"content-type":"application/json; charset=utf-8"}})}}import{matchedAgentToken as ft,uaTokenMatch as At,agentIntent as yt,classifiedAgents as ht}from"@sentientui/core";import{Fragment as pe,jsx as C,jsxs as ue}from"react/jsx-runtime";var Be="https://api.sentient-ui.com/v1";function Me(e){return Object.entries(e).map(([t,n])=>{var s;return{id:t,variant:typeof n=="string"?n:(s=n==null?void 0:n.variantId)!=null?s:""}})}async function lt(e){var X,q,H,W,G,z,Y,Q;let V=e,{components:t=[],sections:n,slots:s,registrySlotIds:r,appOrigin:o,searchParams:i,initialAssignments:d,ssrSessionId:S,timeoutMs:v,agentFeed:p,captureAgents:b,nonce:k,children:P}=V,a=ne(V,["components","sections","slots","registrySlotIds","appOrigin","searchParams","initialAssignments","ssrSessionId","timeoutMs","agentFeed","captureAgents","nonce","children"]),l=await _e(),m=l.get("host");!o&&process.env.NODE_ENV==="production"&&!m&&console.error("[SentientUI] AdaptiveRoot: Host header is absent and no appOrigin was provided. Pass appOrigin explicitly \u2014 the https://localhost fallback will likely fail allowed_origins validation.");let f=o!=null?o:process.env.NODE_ENV==="production"?`https://${m!=null?m:"localhost"}`:"http://localhost:3001",c=(X=l.get("user-agent"))!=null?X:void 0,x=(q=l.get("referer"))!=null?q:void 0,{utmParams:K,clickIds:U}=Ce(i!=null?i:{}),me=l.get("dnt")==="1"||l.get("sec-gpc")==="1",fe=De({userAgent:c,referer:x,appOrigin:f}),L=await Ue(),y=a.consentFrom,N=(G=a.consent)!=null?G:y!=null&&y.cookie?((H=L.get(y.cookie))==null?void 0:H.value)===((W=y.value)!=null?W:"accepted"):void 0,Ae=me||N===!1||y!=null&&N!==!0,E=a.apiBaseUrl?a.apiBaseUrl.replace(/\/$/,""):Be,_=(Y=(z=p==null?void 0:p.path)!=null?z:l.get("x-pathname"))!=null?Y:"/",T=Ke(c!=null?c:"");b!==!1&&T&&ge({baseUrl:E,apiKey:a.apiKey,path:_,botName:T,userAgent:c});let h,R=null,B,M,J,I=null,w;if(d)h=d,w=S;else if(Ae)h={};else if(n&&n.length>0||s&&s.length>0||r&&r.length>0){let F=r&&r.length>0,g=await ae(A(u({sections:n!=null?n:[],components:t,slots:s},F?{slotsFrom:"registry",registrySlotIds:r}:{}),{cookies:L,apiKey:a.apiKey,baseUrl:E,origin:f,userAgent:c,referer:x,utmParams:K,clickIds:U,timeoutMs:v,persona:a.persona}));h=g.assignments,R=g.layoutOrder,B=g.slots,M=g.slotConfig,J=g.palette,I=g.persona!==void 0?{persona:g.persona,confidence:(Q=g.confidence)!=null?Q:0}:null,w=g.sessionId}else{let F=await ie(t,{cookies:L,apiKey:a.apiKey,baseUrl:E,origin:f,userAgent:c,referer:x,utmParams:K,clickIds:U,timeoutMs:v,persona:a.persona});h=F.assignments,w=F.sessionId}let j=C(re,{apiKey:a.apiKey,persona:I,nonce:k}),$=C(Te,A(u({},a),{consent:N,initialAssignments:h,initialLayoutOrder:R,declaredSections:n,initialSlots:B,initialSlotConfig:M,initialPalette:J,initialPersona:I!=null?I:void 0,sessionSegment:fe,ssrSessionId:w,children:P}));if(!p)return ue(pe,{children:[j,$]});let ye=D({page:_,blocks:Me(h),layoutOrder:R!=null?R:void 0,content:p.content});return ue(pe,{children:[j,C("script",{type:"application/ld+json",nonce:k,dangerouslySetInnerHTML:{__html:de(ye)}}),$]})}export{lt as AdaptiveRoot,yt as agentIntent,D as buildAgentFeedFor,ht as classifiedAgents,Ee as createAgentFeed,Oe as defineAgentContent,ft as matchedAgentToken,At as uaTokenMatch};
3
+ `}function ge(e,t={}){var s,r;let n=(s=t.fetchImpl)!=null?s:fetch;try{n(`${e.baseUrl}/crawler-events`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({path:e.path,botName:e.botName,userAgent:(r=e.userAgent)!=null?r:null,source:"ssr"})}).catch(()=>{})}catch(o){}}import{matchedAgentToken as Le}from"@sentientui/core";function Ne(e,t){return e.pathname.endsWith(".md")||t.toLowerCase().includes("text/markdown")}function Ee(e){return async t=>{var l;let n=new URL(t.url),s=(l=t.headers.get("accept"))!=null?l:"",r=t.headers.get("user-agent"),o=n.pathname.replace(/\.(md|json)$/,"");if(e.onRead)try{Promise.resolve(e.onRead({path:o,userAgent:r,botName:Le(r!=null?r:"")})).catch(()=>{})}catch(S){}let i=await e.getFeed(t);return Ne(n,s)?new Response(le(i),{headers:{"content-type":"text/markdown; charset=utf-8"}}):new Response(JSON.stringify(i),{headers:{"content-type":"application/json; charset=utf-8"}})}}import{matchedAgentToken as ft,uaTokenMatch as At,agentIntent as yt,classifiedAgents as ht}from"@sentientui/core";import{Fragment as pe,jsx as D,jsxs as ue}from"react/jsx-runtime";var Be="https://api.sentient-ui.com/v1";function Me(e){return Object.entries(e).map(([t,n])=>{var s;return{id:t,variant:typeof n=="string"?n:(s=n==null?void 0:n.variantId)!=null?s:""}})}async function lt(e){var X,q,H,W,G,z,Y,Q;let V=e,{components:t=[],sections:n,slots:s,registrySlotIds:r,appOrigin:o,searchParams:i,initialAssignments:l,ssrSessionId:S,timeoutMs:v,agentFeed:p,captureAgents:b,nonce:k,children:P}=V,a=ne(V,["components","sections","slots","registrySlotIds","appOrigin","searchParams","initialAssignments","ssrSessionId","timeoutMs","agentFeed","captureAgents","nonce","children"]),g=await _e(),m=g.get("host");!o&&process.env.NODE_ENV==="production"&&!m&&console.error("[SentientUI] AdaptiveRoot: Host header is absent and no appOrigin was provided. Pass appOrigin explicitly \u2014 the https://localhost fallback will likely fail allowed_origins validation.");let f=o!=null?o:process.env.NODE_ENV==="production"?`https://${m!=null?m:"localhost"}`:"http://localhost:3001",c=(X=g.get("user-agent"))!=null?X:void 0,O=(q=g.get("referer"))!=null?q:void 0,{utmParams:C,clickIds:K}=Ce(i!=null?i:{}),me=g.get("dnt")==="1"||g.get("sec-gpc")==="1",fe=De({userAgent:c,referer:O,appOrigin:f}),x=await Ue(),y=a.consentFrom,L=(G=a.consent)!=null?G:y!=null&&y.cookie?((H=x.get(y.cookie))==null?void 0:H.value)===((W=y.value)!=null?W:"accepted"):void 0,Ae=me||L===!1||y!=null&&L!==!0,N=a.apiBaseUrl?a.apiBaseUrl.replace(/\/$/,""):Be,U=(Y=(z=p==null?void 0:p.path)!=null?z:g.get("x-pathname"))!=null?Y:"/",_=Ke(c!=null?c:"");b!==!1&&_&&ge({baseUrl:N,apiKey:a.apiKey,path:U,botName:_,userAgent:c});let h,R=null,T,B,M,I=null,w,J=!!(r!=null&&r.length);if(l)h=l,w=S;else if(Ae)h={};else if(n&&n.length>0||s&&s.length>0||J){let d=await ae(A(u({sections:n!=null?n:[],components:t,slots:s},J?{slotsFrom:"registry",registrySlotIds:r}:{}),{cookies:x,apiKey:a.apiKey,baseUrl:N,origin:f,userAgent:c,referer:O,utmParams:C,clickIds:K,timeoutMs:v,persona:a.persona}));h=d.assignments,R=d.layoutOrder,T=d.slots,B=d.slotConfig,M=d.palette,I=d.persona!==void 0?{persona:d.persona,confidence:(Q=d.confidence)!=null?Q:0}:null,w=d.sessionId}else{let d=await ie(t,{cookies:x,apiKey:a.apiKey,baseUrl:N,origin:f,userAgent:c,referer:O,utmParams:C,clickIds:K,timeoutMs:v,persona:a.persona});h=d.assignments,w=d.sessionId}let j=D(re,{apiKey:a.apiKey,persona:I,nonce:k}),$=D(Te,A(u({},a),{consent:L,initialAssignments:h,initialLayoutOrder:R,declaredSections:n,initialSlots:T,initialSlotConfig:B,initialPalette:M,initialPersona:I!=null?I:void 0,sessionSegment:fe,ssrSessionId:w,children:P}));if(!p)return ue(pe,{children:[j,$]});let ye=E({page:U,blocks:Me(h),layoutOrder:R!=null?R:void 0,content:p.content});return ue(pe,{children:[j,D("script",{type:"application/ld+json",nonce:k,dangerouslySetInnerHTML:{__html:de(ye)}}),$]})}export{lt as AdaptiveRoot,yt as agentIntent,E as buildAgentFeedFor,ht as classifiedAgents,Ee as createAgentFeed,Oe as defineAgentContent,ft as matchedAgentToken,At as uaTokenMatch};
4
4
  //# sourceMappingURL=adaptive-root.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/next/adaptive-root.tsx","../../src/persona-script.tsx","../../src/server.ts","../../src/agent-feed.ts","../../src/next/log-agent-fetch.ts","../../src/next/agent-feed-route.ts"],"sourcesContent":["import { deriveSessionSegment, extractTrackedParams, matchedAgentToken } from '@sentientui/core';\nimport type { SlotDeclInput, SlotResult } from '@sentientui/core';\nimport { cookies, headers } from 'next/headers';\n// `type JSX` from react, not the global namespace removed in @types/react@19\n// (peers allow react >=18) — see adaptive-text.tsx.\nimport type { JSX, ReactNode } from 'react';\nimport type { AdaptiveProviderProps } from '../provider.js';\nimport { SentientPersonaScript } from '../persona-script.js';\nimport {\n loadAdaptiveAssignments,\n loadAdaptiveDecision,\n type LoadAdaptiveDecisionResult,\n type ServerAssignments,\n} from '../server.js';\nimport { AdaptiveRootClient } from './adaptive-root-client.js';\nimport { buildAgentFeed, renderAgentJsonLdBody, type AgentBlock } from '../agent-feed.js';\nimport { logAgentFetch } from './log-agent-fetch.js';\n\nexport { createAgentFeed } from './agent-feed-route.js';\nexport type { AgentFeedRouteConfig, AgentFeedReadEntry } from './agent-feed-route.js';\nexport { defineAgentContent, buildAgentFeed as buildAgentFeedFor } from '../agent-feed.js';\n// Re-exported from core on the SERVER entry (this module is server-only — it\n// imports next/headers). Lets server components do agent detection with just the\n// `@sentientui/react` package, no direct core dependency. Do NOT add this to the\n// package's client index: re-exporting a plain function through a 'use client'\n// module turns it into a client reference that throws when called during SSR.\nexport { matchedAgentToken, uaTokenMatch, agentIntent, classifiedAgents } from '@sentientui/core';\nexport type { AgentIntent } from '@sentientui/core';\nexport type { AgentFeed } from '../agent-feed.js';\n\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport type PreloadComponent = { id: string; variantIds: string[] };\n\nexport type AdaptiveRootProps = Omit<\n AdaptiveProviderProps,\n // Every provider prop AdaptiveRoot itself resolves and passes AFTER the\n // {...providerProps} spread must be omitted here: a caller-supplied value\n // would typecheck but be silently clobbered by the spread order\n // (initialLayoutOrder, declaredSections and sessionSegment were missing\n // from this list and suffered exactly that).\n | 'initialAssignments'\n | 'onAssignment'\n | 'initialSlots'\n | 'initialSlotConfig'\n | 'initialPalette'\n | 'initialPersona'\n | 'initialLayoutOrder'\n | 'declaredSections'\n | 'sessionSegment'\n | 'consentFrom'\n> & {\n /**\n * Cookie-based consent source — see `AdaptiveProviderProps.consentFrom`.\n *\n * Narrowed to the cookie form: AdaptiveRoot is a Server Component and spreads\n * this straight into its client boundary, and a function prop crossing the\n * server→client boundary throws at render (\"Functions cannot be passed\n * directly to Client Components\"). The provider's type accepted `check`, so\n * a Cookiebot-style predicate typechecked here and then crashed the layout.\n * Need a JS-API CMP predicate? Use `<AdaptiveProvider>` in a client component.\n */\n consentFrom?: Omit<NonNullable<AdaptiveProviderProps['consentFrom']>, 'check'>;\n /**\n * Components to assign server-side (SEO-safe). Optional — omit when the\n * tree uses only slots/sections, or assigns client-side via hooks.\n */\n components?: PreloadComponent[];\n /**\n * Declare page section IDs in their default order. When provided,\n * AdaptiveRoot calls `/v1/decide` (single round trip) instead of\n * individual `/v1/assign` calls, and `useLayoutOrder()` returns the\n * persona-specific order on first render.\n *\n * Give each section's rendered element `data-sentient-id=\"<sectionId>\"` —\n * the only markup a section needs — so the DOM graph scanner can register\n * it under the same id. Without it the server never learns what the section\n * IS, types it `generic`, and serves the identity order to every persona —\n * the integration looks live but cannot personalize. The provider warns\n * about unresolvable ids in development. Correct a section the content\n * classifier mistypes with `sectionTypes`, not extra markup.\n *\n * @example sections={['hero', 'pricing', 'features', 'social_proof']}\n * // …and in the tree: <section data-sentient-id=\"pricing\">\n */\n sections?: string[];\n /**\n * Adaptive-slot declarations used by `useAdaptiveTokens` / `AdaptiveGroup`\n * in this tree. Declaring them here decides them in the same SSR\n * round trip, so their values serialize into the server HTML.\n */\n slots?: SlotDeclInput[];\n /**\n * The generated-mode `<Adaptive id>`s THIS page renders. Declaring them\n * decides their published versions in the same SSR round trip\n * (`/v1/decide` registry mode) and serializes the served content into the\n * server HTML, so the first paint shows the version rather than the\n * original children until the client-side decide answers. Without it a\n * registry slot renders its children first and swaps after mount.\n *\n * Scoped to exactly these ids on purpose: an unscoped registry decide\n * records a close-out trial for every published slot on every page.\n *\n * @example registrySlotIds={['hero-headline', 'pricing-cta']}\n */\n registrySlotIds?: string[];\n /** App origin — must be in the project's `allowed_origins`. */\n appOrigin?: string;\n /**\n * The page's `searchParams` prop (or an equivalent query string /\n * URLSearchParams). Server Components cannot read the request URL from\n * `headers()`, so without this the SSR-minted session carries no `utm_*`\n * params and no ad click IDs (gclid, fbclid, ttclid, …) — campaign\n * attribution only lands after client hydration, and never for visits the\n * client SDK doesn't get to finish (bounce before hydrate). Pass it on\n * landing pages that receive ad traffic:\n *\n * ```tsx\n * export default async function Page({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {\n * return <AdaptiveRoot ... searchParams={await searchParams}>...</AdaptiveRoot>;\n * }\n * ```\n */\n searchParams?: Record<string, string | string[] | undefined> | URLSearchParams | string;\n /** Override: when set no network fetch is made. Useful for tests. */\n initialAssignments?: ServerAssignments;\n /**\n * Milliseconds to wait for the API before rendering default variants.\n * Defaults to 1000. The hot path typically returns in well under 150 ms;\n * the full 1 s budget is only reached on a cold start or an API\n * geographically distant from your SSR host. Lower it if your API is\n * co-located and warm.\n */\n timeoutMs?: number;\n /**\n * When set, AdaptiveRoot emits a server-rendered inline JSON-LD block\n * describing the page's winning variants, layout order, and developer-supplied\n * content — readable by passive AI crawlers (which do not run JS). Invisible to\n * humans (a JSON-LD script renders no visible DOM). Omit to emit nothing.\n */\n agentFeed?: {\n /** Page path for the feed. Falls back to the `x-pathname` request header, then '/'. */\n path?: string;\n /** Structured page content. Falls back to the `defineAgentContent` registry for this path. */\n content?: Record<string, unknown>;\n };\n /**\n * When true (default), a known AI-agent fetch (matched by user-agent —\n * GPTBot, ChatGPT-User, Claude-User, PerplexityBot, …) is logged server-side\n * to your agent analytics. Machine telemetry only (no cookie, no session);\n * fire-and-forget, never affects render. Set false to opt out.\n */\n captureAgents?: boolean;\n /**\n * CSP nonce for the inline persona (and optional agent JSON-LD) scripts.\n * Pass through from Next.js middleware / `headers()` when using a strict CSP.\n */\n nonce?: string;\n children: ReactNode;\n};\n\n/** Build agent blocks from SSR assignments (Record<id, variantId | { variantId }>). */\nfunction assignmentsToBlocks(assignments: ServerAssignments): AgentBlock[] {\n return Object.entries(assignments as Record<string, unknown>).map(([id, v]) => ({\n id,\n variant: typeof v === 'string' ? v : ((v as { variantId?: string })?.variantId ?? ''),\n }));\n}\n\n/**\n * Next.js Server Component that resolves variant assignments (and optionally\n * section layout order) server-side for zero layout shift on first paint.\n *\n * When `sections` is provided, a single `POST /v1/decide` call returns both\n * the persona-specific section order and all component assignments.\n * Without `sections`, individual `/v1/assign` calls are made per component.\n *\n * @example\n * // app/page.tsx — with section layout\n * import { AdaptiveRoot } from '@sentientui/react/next';\n *\n * export default async function Page() {\n * return (\n * <AdaptiveRoot\n * apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}\n * sections={['hero', 'pricing', 'features', 'social_proof']}\n * components={[\n * { id: 'hero_cta', variantIds: ['default', 'accent'] },\n * ]}\n * >\n * <HeroSection />\n * <PricingSection />\n * <FeaturesSection />\n * <SocialProofSection />\n * </AdaptiveRoot>\n * );\n * }\n */\nexport async function AdaptiveRoot(props: AdaptiveRootProps): Promise<JSX.Element> {\n const {\n components = [],\n sections,\n slots,\n registrySlotIds,\n appOrigin,\n searchParams,\n initialAssignments: initialAssignmentsOverride,\n ssrSessionId: ssrSessionIdProp,\n timeoutMs,\n agentFeed,\n captureAgents,\n nonce,\n children,\n ...providerProps\n } = props;\n\n const headerStore = await headers();\n const host = headerStore.get('host');\n if (!appOrigin && process.env.NODE_ENV === 'production' && !host) {\n console.error(\n '[SentientUI] AdaptiveRoot: Host header is absent and no appOrigin was provided. ' +\n 'Pass appOrigin explicitly — the https://localhost fallback will likely fail allowed_origins validation.',\n );\n }\n const resolvedOrigin = appOrigin ??\n (process.env.NODE_ENV === 'production'\n ? `https://${host ?? 'localhost'}`\n : 'http://localhost:3001');\n const userAgent = headerStore.get('user-agent') ?? undefined;\n const referer = headerStore.get('referer') ?? undefined;\n // Landing-URL attribution (utm_* + ad click IDs). Only available when the\n // page passes its searchParams down — headers() never carries the request's\n // own query string, and the Referer is the PREVIOUS page, not this one.\n const { utmParams, clickIds } = extractTrackedParams(searchParams ?? {});\n // Honor a tracking opt-out at SSR: `DNT: 1` or the legally-enforceable\n // `Sec-GPC: 1`. When set we skip the session upsert + assign/decide so no\n // session row is minted for the visitor (audit P4) — matching the client SDK,\n // which already no-ops for these signals.\n const doNotTrack = headerStore.get('dnt') === '1' || headerStore.get('sec-gpc') === '1';\n // `consent: false` must gate the SERVER too, not just the client. Without\n // this the SSR decide/assign still ran and still minted a session row for a\n // visitor who had not consented — contradicting the documented contract\n // (\"no SDK is initialised, no cookies are written, no events are sent\") and\n // forcing sites to hide AdaptiveRoot behind a conditional render, which is\n // what made consent-after-load cost a full server round trip.\n const sessionSegment = deriveSessionSegment({ userAgent, referer, appOrigin: resolvedOrigin });\n const cookieStore = await cookies();\n\n // This is a Server Component and already has the request cookies, so resolve\n // a cookie-based `consentFrom` here rather than making the app read the same\n // cookie again just to pass `consent` — naming it twice only invites drift.\n // An already-consented visitor therefore gets SSR variant assignment (zero\n // layout shift) with no extra code.\n //\n // An explicit `consent` prop always wins — it is the escape hatch for apps\n // that track consent elsewhere. (No `check()` form here: see the prop type.)\n //\n // Consent gates the SERVER too, not just the client: without it the SSR\n // decide/assign still ran and still minted a session row for a visitor who\n // had not consented, contradicting the documented contract (\"no SDK is\n // initialised, no cookies are written, no events are sent\").\n const cf = providerProps.consentFrom;\n const consent =\n providerProps.consent ??\n (cf?.cookie\n ? cookieStore.get(cf.cookie)?.value === (cf.value ?? 'accepted')\n : undefined);\n const skipSsr = doNotTrack || consent === false || (cf != null && consent !== true);\n\n // SSR preload MUST hit the same API host the client will use, otherwise the\n // SSR-minted session lives on the wrong host and the client's first /assign\n // misses it and re-mints — silently breaking SSR→client continuity for any\n // non-default / self-hosted deployment. The client derives its base from\n // apiBaseUrl too (see provider.tsx), so thread the same value here.\n const baseUrl = providerProps.apiBaseUrl\n ? providerProps.apiBaseUrl.replace(/\\/$/, '')\n : DEFAULT_API_BASE_URL;\n\n // Server-side agent-fetch capture (spec: nextjs-agent-fetch-capture). JS-less\n // assistants (GPTBot / ChatGPT-User / Claude-User / PerplexityBot / …) never\n // run client JS, but they trigger SSR — so AdaptiveRoot sees their UA here.\n // Fire-and-forget; never blocks or breaks render. `agentPath` is reused by the\n // agentFeed JSON-LD below.\n const agentPath = agentFeed?.path ?? headerStore.get('x-pathname') ?? '/';\n const agentBot = matchedAgentToken(userAgent ?? '');\n if (captureAgents !== false && agentBot) {\n logAgentFetch({ baseUrl, apiKey: providerProps.apiKey, path: agentPath, botName: agentBot, userAgent });\n }\n\n let initialAssignments: ServerAssignments;\n let initialLayoutOrder: string[] | null = null;\n let initialSlots: Record<string, SlotResult> | undefined;\n let initialSlotConfig: LoadAdaptiveDecisionResult['slotConfig'];\n let initialPalette: LoadAdaptiveDecisionResult['palette'];\n let initialPersona: { persona: string; confidence: number } | null = null;\n let ssrSessionId: string | undefined;\n\n if (initialAssignmentsOverride) {\n initialAssignments = initialAssignmentsOverride;\n ssrSessionId = ssrSessionIdProp;\n } else if (skipSsr) {\n // Nothing server-side: no decide, no assign, no session. Components fall\n // back to `ssrFallback`, and the client starts only if the visitor later\n // consents — via the `consent` prop or grantConsent(), neither of which\n // needs a page reload.\n initialAssignments = {};\n } else if (\n (sections && sections.length > 0) ||\n (slots && slots.length > 0) ||\n (registrySlotIds && registrySlotIds.length > 0)\n ) {\n // Registry mode only when ids were declared: `loadAdaptiveDecision` already\n // accepted `registrySlotIds` but AdaptiveRoot never passed them, so an\n // `<Adaptive id>` under AdaptiveRoot showed its original children on first\n // paint until the client-side decide returned.\n const registry = registrySlotIds && registrySlotIds.length > 0;\n const decision = await loadAdaptiveDecision({\n sections: sections ?? [],\n components,\n slots,\n ...(registry ? { slotsFrom: 'registry' as const, registrySlotIds } : {}),\n cookies: cookieStore,\n apiKey: providerProps.apiKey,\n baseUrl,\n origin: resolvedOrigin,\n userAgent,\n referer,\n utmParams,\n clickIds,\n // doNotTrack is deliberately not passed: it is necessarily false on this\n // branch — a DNT/GPC or consent-gated request already took the skipSsr\n // arm above and never reaches this loader.\n timeoutMs,\n persona: providerProps.persona,\n });\n initialAssignments = decision.assignments;\n initialLayoutOrder = decision.layoutOrder;\n initialSlots = decision.slots;\n initialSlotConfig = decision.slotConfig;\n initialPalette = decision.palette;\n initialPersona =\n decision.persona !== undefined\n ? { persona: decision.persona, confidence: decision.confidence ?? 0 }\n : null;\n ssrSessionId = decision.sessionId;\n } else {\n const result = await loadAdaptiveAssignments(components, {\n cookies: cookieStore,\n apiKey: providerProps.apiKey,\n baseUrl,\n origin: resolvedOrigin,\n userAgent,\n referer,\n utmParams,\n clickIds,\n // doNotTrack is deliberately not passed: it is necessarily false on this\n // branch — a DNT/GPC or consent-gated request already took the skipSsr\n // arm above and never reaches this loader.\n timeoutMs,\n persona: providerProps.persona,\n });\n initialAssignments = result.assignments;\n ssrSessionId = result.sessionId;\n }\n\n // Single-writer inline script — ALWAYS the first child, before any markup\n // that CSS keyed on the persona attributes could style.\n const personaScript = (\n <SentientPersonaScript apiKey={providerProps.apiKey} persona={initialPersona} nonce={nonce} />\n );\n\n const client = (\n <AdaptiveRootClient\n {...providerProps}\n // Forward the server-resolved value so a consented visitor's client does\n // not start gated and re-resolve the same cookie on mount.\n consent={consent}\n initialAssignments={initialAssignments}\n initialLayoutOrder={initialLayoutOrder}\n // Declared regardless of what came back, so devtools can preview layout on\n // a page whose decision was gated or timed out.\n declaredSections={sections}\n initialSlots={initialSlots}\n // Registry-mode preload: the hook treats a preloaded slot config as\n // settled, so the client does not decide the same slot a second time.\n initialSlotConfig={initialSlotConfig}\n initialPalette={initialPalette}\n initialPersona={initialPersona ?? undefined}\n sessionSegment={sessionSegment}\n ssrSessionId={ssrSessionId}\n >\n {children}\n </AdaptiveRootClient>\n );\n\n if (!agentFeed) {\n return (\n <>\n {personaScript}\n {client}\n </>\n );\n }\n\n // Server-rendered inline JSON-LD for AI crawlers. Emitted only on the server\n // path so passive crawlers (no JS) see it in the raw HTML. The body escapes\n // '<' so page content cannot break out of the <script> element.\n const feed = buildAgentFeed({\n page: agentPath,\n blocks: assignmentsToBlocks(initialAssignments),\n layoutOrder: initialLayoutOrder ?? undefined,\n content: agentFeed.content,\n });\n\n return (\n <>\n {personaScript}\n <script\n type=\"application/ld+json\"\n nonce={nonce}\n dangerouslySetInnerHTML={{ __html: renderAgentJsonLdBody(feed) }}\n />\n {client}\n </>\n );\n}\n","// `type JSX` from react, not the global namespace removed in @types/react@19\n// (peers allow react >=18) — see adaptive-text.tsx.\nimport type { JSX } from 'react';\nimport { renderPrePaintScript } from '@sentientui/core';\nimport { confidenceBand } from '@sentientui/policy';\n\nexport type SentientPersonaScriptProps = {\n /** Publishable API key — selects the localStorage snapshot in the fallback path. */\n apiKey: string;\n /**\n * CSP nonce for the inline pre-paint script. Pass the same nonce your\n * `Content-Security-Policy` `script-src` allows (e.g. from Next.js middleware).\n * Required for strict CSP deployments that block `'unsafe-inline'`.\n */\n nonce?: string;\n /**\n * SSR-decided persona (from `loadAdaptiveDecision`). When present the\n * script embeds the literal values; when absent it reads the local\n * decision snapshot (SPA / return-visit path).\n */\n persona?: { persona: string; confidence: number } | null;\n};\n\n/** JSON string literal that is also safe inside an inline <script> element. */\nfunction inlineJsString(value: string): string {\n return JSON.stringify(value).replace(/</g, '\\\\u003c');\n}\n\n/** Exported for tests. Builds the inline JS (concatenation only — no backticks). */\nexport function personaScriptBody(props: SentientPersonaScriptProps): string {\n if (props.persona) {\n return (\n '(function(){try{var d=document.documentElement;' +\n 'if(d.hasAttribute(\"data-sentient-persona\"))return;' +\n 'd.setAttribute(\"data-sentient-persona\",' + inlineJsString(props.persona.persona) + ');' +\n 'd.setAttribute(\"data-sentient-confidence\",' + inlineJsString(confidenceBand(props.persona.confidence)) + ');' +\n '}catch(e){}})();'\n );\n }\n return renderPrePaintScript(props.apiKey);\n}\n\n/**\n * Single writer of the Rung-1a `<html>` attributes\n * (`data-sentient-persona`, `data-sentient-confidence`), executed pre-paint.\n *\n * `AdaptiveRoot` renders this automatically as its first child. For Pages\n * Router / Remix, render it yourself in `_document` / the root layout.\n *\n * IMPORTANT (install docs): add `suppressHydrationWarning` to your `<html>`\n * element — this script mutates documentElement before React hydrates it\n * (the same pattern next-themes uses). The client SDK adopts the attributes\n * as truth and never rewrites them mid-session.\n */\nexport function SentientPersonaScript(props: SentientPersonaScriptProps): JSX.Element {\n return (\n <script\n data-sentient-persona-script=\"\"\n nonce={props.nonce}\n dangerouslySetInnerHTML={{ __html: personaScriptBody(props) }}\n />\n );\n}\n","/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core/server';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\n/** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */\nexport type LoadAdaptiveAssignmentsResult = {\n assignments: ServerAssignments;\n /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */\n sessionId: string;\n};\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n /**\n * `utm_*` params from the landing URL. The Referer header never carries the\n * page's OWN query string, so without this the SSR-minted session has no\n * campaign attribution until the client SDK hydrates and re-upserts.\n * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.\n */\n utmParams?: Record<string, string>;\n /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */\n clickIds?: Record<string, string>;\n /** 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. */\n doNotTrack?: boolean;\n /** 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). */\n timeoutMs?: number;\n /**\n * Declared persona — the role your app already knows for this visitor (e.g.\n * from your auth context: 'admin', 'evaluator'). Must be a key in the\n * project's persona vocabulary; unrecognized values are ignored server-side.\n * Never a user id or email.\n */\n persona?: string;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`\n * on `<AdaptiveProvider>` so the client adopts the same session on first visit.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<LoadAdaptiveAssignmentsResult> {\n // apiKey is not optional here: the client writes the per-project suffixed\n // cookie, so an un-keyed read missed every returning visitor and minted a\n // fresh orphan session per SSR request (see readSessionCookie in core).\n const sessionId =\n readSessionCookie(options.cookies, options.apiKey) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n const assignments = await preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n utmParams: options.utmParams,\n clickIds: options.clickIds,\n doNotTrack: options.doNotTrack,\n timeoutMs: options.timeoutMs,\n persona: options.persona,\n });\n\n return { assignments, sessionId };\n}\n\nexport { preloadDecisions } from '@sentientui/core/server';\nexport type { DecideResult, SlotDeclInput, SlotResult } from '@sentientui/core/server';\n\n/** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */\nexport type LoadAdaptiveDecisionResult = import('@sentientui/core/server').DecideResult & {\n sessionId: string;\n};\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /**\n * Section IDs in default order. Passed to /v1/decide as the candidate\n * layout. Optional since 0.13.0 — slot-only pages may omit it (at least\n * one of `sections`/`components`/`slots` must be non-empty).\n */\n sections?: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */\n slots?: import('@sentientui/core/server').SlotDeclInput[];\n /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)\n * and is the only way `slotConfig`/`palette` come back. Default 'request'.\n * Requires `registrySlotIds`. */\n slotsFrom?: 'request' | 'registry';\n /**\n * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is\n * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it\n * the call downgrades to request mode (with a console.error) instead of\n * recording a close-out trial for every published slot on every page.\n */\n registrySlotIds?: string[];\n};\n\n/**\n * SSR helper for pages with a declared section layout and/or adaptive slots.\n * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.\n * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client\n * adopts the same session on first visit.\n *\n * Keyless: with no valid `pk_` key this never fetches (no timeout burn).\n * Under the `development` export condition the decision is computed by the\n * deterministic local engine with the same sessionId the client will adopt —\n * server and client agree by construction. In production the engine resolves\n * to a stub and defaults are returned with one console.error.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<LoadAdaptiveDecisionResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core/server');\n\n // Keyed read — the client's cookie name is suffixed per project (see\n // loadAdaptiveAssignments above). Works for keyless too: with no pk_ key the\n // client writes the bare legacy name, which the un-suffixed read falls back to.\n const sessionId =\n readSessionCookie(options.cookies, options.apiKey) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n const keyValid = typeof options.apiKey === 'string' && options.apiKey.startsWith('pk_');\n if (!keyValid) {\n const fallback: LoadAdaptiveDecisionResult = {\n layoutOrder: options.sections ?? [],\n assignments: {},\n slots: {},\n persona: 'unknown',\n confidence: 0,\n sessionId,\n };\n try {\n const mod = (await import('@sentientui/core/local')) as unknown as {\n LOCAL_ENGINE_AVAILABLE: boolean;\n createLocalEngine(opts: { sessionId: string }): {\n decide(input: {\n sections?: string[];\n components?: Array<{ id: string; variantIds?: string[] }>;\n slots?: LoadAdaptiveDecisionOptions['slots'];\n }): {\n layoutOrder: string[] | null;\n assignments: Record<string, string>;\n slots: Record<string, string | Record<string, string>>;\n persona: string;\n confidence: number;\n };\n };\n };\n if (!mod.LOCAL_ENGINE_AVAILABLE) {\n // Pinned message — must byte-match PROD_KEYLESS_ERROR in @sentientui/core.\n console.error(\n '[sentient] No API key configured — nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.',\n );\n return fallback;\n }\n const outcome = mod.createLocalEngine({ sessionId }).decide({\n sections: options.sections,\n components: options.components ?? [],\n slots: options.slots ?? [],\n });\n return {\n layoutOrder: outcome.layoutOrder ?? options.sections ?? [],\n assignments: outcome.assignments,\n slots: outcome.slots,\n persona: outcome.persona,\n confidence: outcome.confidence,\n sessionId,\n };\n } catch {\n return fallback;\n }\n }\n\n const result = await preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n slots: options.slots ?? [],\n slotsFrom: options.slotsFrom,\n registrySlotIds: options.registrySlotIds,\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n utmParams: options.utmParams,\n clickIds: options.clickIds,\n doNotTrack: options.doNotTrack,\n timeoutMs: options.timeoutMs,\n persona: options.persona,\n },\n );\n\n return { ...result, sessionId };\n}\n","/**\n * Agent-readable content feed. Merges SDK-known data (winning variants, layout\n * order) with developer-supplied page content, and renders it either as a\n * server-rendered inline JSON-LD block (read by passive AI crawlers, which do\n * not run JS) or as Markdown (for agents that content-negotiate `text/markdown`).\n *\n * No React or DOM APIs — safe to import in server components, route handlers,\n * and middleware.\n */\n\nexport type AgentBlock = {\n /** Component ID. */\n id: string;\n /** Winning variant ID currently served. */\n variant: string;\n /** Agent-readable data attached to the served variant, if any. */\n content?: unknown;\n};\n\nexport type AgentFeed = {\n page: string;\n title?: string;\n summary?: string;\n layoutOrder?: string[];\n blocks: AgentBlock[];\n /** Developer-supplied extra fields (products, specs, arbitrary JSON). */\n [key: string]: unknown;\n};\n\n/** Fields the SDK owns — developer content can never overwrite these. */\nconst RESERVED_FIELDS = ['page', 'blocks', 'layoutOrder'] as const;\n\nconst registry = new Map<string, Record<string, unknown>>();\n\n/**\n * Register page-level structured content the SDK can't infer (title, summary,\n * product fields, arbitrary JSON), keyed by page path. Call at module load.\n */\nexport function defineAgentContent(page: string, content: Record<string, unknown>): void {\n registry.set(page, content);\n}\n\n/** Look up registered content for a page. */\nexport function getAgentContent(page: string): Record<string, unknown> | undefined {\n return registry.get(page);\n}\n\n/** Clear the registry — intended for tests. */\nexport function clearAgentContent(): void {\n registry.clear();\n}\n\n/**\n * Merge SDK-known data with developer-supplied content into a single feed.\n * Developer content fills in title/summary/etc. but can never overwrite the\n * SDK-authoritative fields (`page`, `blocks`, `layoutOrder`).\n */\nexport function buildAgentFeed(input: {\n page: string;\n blocks: AgentBlock[];\n layoutOrder?: string[];\n content?: Record<string, unknown>;\n}): AgentFeed {\n const supplied = input.content ?? getAgentContent(input.page) ?? {};\n const safe: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(supplied)) {\n if (!(RESERVED_FIELDS as readonly string[]).includes(k)) safe[k] = v;\n }\n const feed: AgentFeed = {\n ...safe,\n page: input.page,\n blocks: input.blocks,\n };\n if (input.layoutOrder) feed.layoutOrder = input.layoutOrder;\n return feed;\n}\n\n/**\n * Render the feed as a server-rendered inline JSON-LD `<script>` string. `<` is\n * escaped to `<` so embedded content cannot break out of the script\n * element. MUST be emitted on the server — passive crawlers never run client JS.\n */\nexport function renderAgentJsonLd(feed: AgentFeed): string {\n return `<script type=\"application/ld+json\">${renderAgentJsonLdBody(feed)}</script>`;\n}\n\n/**\n * The escaped JSON-LD body only (no `<script>` wrapper). For React server\n * components, inject via `<script type=\"application/ld+json\"\n * dangerouslySetInnerHTML={{ __html: renderAgentJsonLdBody(feed) }} />`.\n */\nexport function renderAgentJsonLdBody(feed: AgentFeed): string {\n return JSON.stringify({ '@context': 'https://schema.org', '@type': 'WebPage', ...feed })\n .replace(/</g, '\\\\u003c');\n}\n\n/** Render the feed as Markdown for agents that negotiate `text/markdown`. */\nexport function renderAgentMarkdown(feed: AgentFeed): string {\n const lines: string[] = [];\n if (feed.title) lines.push(`# ${feed.title}`, '');\n if (feed.summary) lines.push(String(feed.summary), '');\n\n for (const [k, v] of Object.entries(feed)) {\n if (['page', 'title', 'summary', 'blocks', 'layoutOrder'].includes(k)) continue;\n lines.push(`## ${k}`, '', '```json', JSON.stringify(v, null, 2), '```', '');\n }\n\n if (feed.blocks.length > 0) {\n lines.push('## blocks', '');\n for (const b of feed.blocks) {\n lines.push(`- **${b.id}** → variant \\`${b.variant}\\``);\n if (b.content !== undefined) {\n lines.push('', ' ```json', JSON.stringify(b.content, null, 2), ' ```');\n }\n }\n lines.push('');\n }\n\n return lines.join('\\n').trimEnd() + '\\n';\n}\n","// Fire-and-forget server-side log of a known AI-agent fetch to crawler_requests\n// (via POST /v1/crawler-events). Machine telemetry — no cookie, no session.\n// MUST NOT throw or be awaited into the render path.\nexport type AgentFetchLog = {\n baseUrl: string; // API base ending in /v1\n apiKey: string; // public pk_ key\n path: string;\n botName: string;\n userAgent?: string;\n};\n\nexport function logAgentFetch(entry: AgentFetchLog, deps: { fetchImpl?: typeof fetch } = {}): void {\n const doFetch = deps.fetchImpl ?? fetch;\n try {\n void doFetch(`${entry.baseUrl}/crawler-events`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${entry.apiKey}` },\n body: JSON.stringify({\n path: entry.path,\n botName: entry.botName,\n userAgent: entry.userAgent ?? null,\n source: 'ssr',\n }),\n }).catch(() => {});\n } catch {\n /* never break render */\n }\n}\n","/**\n * `createAgentFeed` — a framework-standard Route Handler (Web `Request` →\n * `Response`) that serves the agent-readable feed via HTTP content negotiation:\n * `text/markdown` (Accept header or `.md` URL) → Markdown, otherwise JSON.\n *\n * This is the secondary channel of the agent-readable design — for agents that\n * *ask* (coding agents, agents the customer controls, future crawlers). The\n * primary channel is the server-rendered inline JSON-LD from `<AdaptiveRoot>`.\n *\n * Every fetch is reported to `onRead` (best-effort) so it can be logged to\n * `crawler_requests` and counted in the dashboard traffic breakdown.\n */\nimport { matchedAgentToken } from '@sentientui/core';\nimport { renderAgentMarkdown, type AgentFeed } from '../agent-feed.js';\n\nexport type AgentFeedReadEntry = {\n path: string;\n userAgent: string | null;\n botName: string | null;\n};\n\nexport type AgentFeedRouteConfig = {\n /** Resolve the feed for a request (winning variants + layout + dev content). */\n getFeed: (request: Request) => Promise<AgentFeed> | AgentFeed;\n /** Best-effort per-fetch hook — log to `crawler_requests` here. Never awaited into the response. */\n onRead?: (entry: AgentFeedReadEntry) => void | Promise<void>;\n};\n\nfunction wantsMarkdown(url: URL, accept: string): boolean {\n return url.pathname.endsWith('.md') || accept.toLowerCase().includes('text/markdown');\n}\n\nexport function createAgentFeed(\n config: AgentFeedRouteConfig,\n): (request: Request) => Promise<Response> {\n return async (request: Request): Promise<Response> => {\n const url = new URL(request.url);\n const accept = request.headers.get('accept') ?? '';\n const userAgent = request.headers.get('user-agent');\n // Strip the .md/.json suffix so the feed path matches the page path.\n const path = url.pathname.replace(/\\.(md|json)$/, '');\n\n if (config.onRead) {\n try {\n void Promise.resolve(\n config.onRead({ path, userAgent, botName: matchedAgentToken(userAgent ?? '') }),\n ).catch(() => {});\n } catch {\n /* logging must never break the response */\n }\n }\n\n const feed = await config.getFeed(request);\n\n if (wantsMarkdown(url, accept)) {\n return new Response(renderAgentMarkdown(feed), {\n headers: { 'content-type': 'text/markdown; charset=utf-8' },\n });\n }\n return new Response(JSON.stringify(feed), {\n headers: { 'content-type': 'application/json; charset=utf-8' },\n });\n };\n}\n"],"mappings":"4lBAAA,OAAS,wBAAAA,GAAsB,wBAAAC,GAAsB,qBAAAC,OAAyB,mBAE9E,OAAS,WAAAC,GAAS,WAAAC,OAAe,eCCjC,OAAS,wBAAAC,OAA4B,mBACrC,OAAS,kBAAAC,OAAsB,qBAoD3B,cAAAC,OAAA,oBAhCJ,SAASC,GAAeC,EAAuB,CAC7C,OAAO,KAAK,UAAUA,CAAK,EAAE,QAAQ,KAAM,SAAS,CACtD,CAGO,SAASC,GAAkBC,EAA2C,CAC3E,OAAIA,EAAM,QAEN,2IAE4CH,GAAeG,EAAM,QAAQ,OAAO,EAAI,+CACrCH,GAAeF,GAAeK,EAAM,QAAQ,UAAU,CAAC,EAAI,qBAIvGN,GAAqBM,EAAM,MAAM,CAC1C,CAcO,SAASC,GAAsBD,EAAgD,CACpF,OACEJ,GAAC,UACC,+BAA6B,GAC7B,MAAOI,EAAM,MACb,wBAAyB,CAAE,OAAQD,GAAkBC,CAAK,CAAE,EAC9D,CAEJ,CC3DA,OACE,sBAAAE,GACA,qBAAAC,OAGK,0BAuFP,OAAS,oBAAAC,OAAwB,0BAxCjC,SAASC,IAA2B,CAClC,OAAI,OAAO,QAAW,aAAe,OAAO,OAAO,YAAe,WACzD,OAAO,WAAW,EAEpB,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,EAAE,CAAC,EACrE,CAOA,eAAsBC,GACpBC,EACAC,EACwC,CAtE1C,IAAAC,EAAAC,EAAAC,EA0EE,IAAMC,GACJD,GAAAD,EAAAG,GAAkBL,EAAQ,QAASA,EAAQ,MAAM,IAAjD,KAAAE,GACAD,EAAAD,EAAQ,kBAAR,YAAAC,EAAA,KAAAD,KADA,KAAAG,EAEAN,GAAiB,EAenB,MAAO,CAAE,YAbW,MAAMS,GAAmBP,EAAYK,EAAW,CAClE,OAAQJ,EAAQ,OAChB,QAASA,EAAQ,QACjB,OAAQA,EAAQ,OAChB,UAAWA,EAAQ,UACnB,QAASA,EAAQ,QACjB,UAAWA,EAAQ,UACnB,SAAUA,EAAQ,SAClB,WAAYA,EAAQ,WACpB,UAAWA,EAAQ,UACnB,QAASA,EAAQ,OACnB,CAAC,EAEqB,UAAAI,CAAU,CAClC,CA8CA,eAAsBG,GACpBP,EACqC,CA7IvC,IAAAC,EAAAC,EAAAC,EAAAK,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EA8IE,GAAM,CAAE,iBAAAC,EAAkB,kBAAAV,CAAkB,EAAI,KAAM,QAAO,yBAAyB,EAKhFD,GACJD,GAAAD,EAAAG,EAAkBL,EAAQ,QAASA,EAAQ,MAAM,IAAjD,KAAAE,GACAD,EAAAD,EAAQ,kBAAR,YAAAC,EAAA,KAAAD,KADA,KAAAG,EAEAN,GAAiB,EAGnB,GAAI,EADa,OAAOG,EAAQ,QAAW,UAAYA,EAAQ,OAAO,WAAW,KAAK,GACvE,CACb,IAAMgB,EAAuC,CAC3C,aAAaR,EAAAR,EAAQ,WAAR,KAAAQ,EAAoB,CAAC,EAClC,YAAa,CAAC,EACd,MAAO,CAAC,EACR,QAAS,UACT,WAAY,EACZ,UAAAJ,CACF,EACA,GAAI,CACF,IAAMa,EAAO,KAAM,QAAO,wBAAwB,EAgBlD,GAAI,CAACA,EAAI,uBAEP,eAAQ,MACN,mJACF,EACOD,EAET,IAAME,EAAUD,EAAI,kBAAkB,CAAE,UAAAb,CAAU,CAAC,EAAE,OAAO,CAC1D,SAAUJ,EAAQ,SAClB,YAAYS,EAAAT,EAAQ,aAAR,KAAAS,EAAsB,CAAC,EACnC,OAAOC,EAAAV,EAAQ,QAAR,KAAAU,EAAiB,CAAC,CAC3B,CAAC,EACD,MAAO,CACL,aAAaE,GAAAD,EAAAO,EAAQ,cAAR,KAAAP,EAAuBX,EAAQ,WAA/B,KAAAY,EAA2C,CAAC,EACzD,YAAaM,EAAQ,YACrB,MAAOA,EAAQ,MACf,QAASA,EAAQ,QACjB,WAAYA,EAAQ,WACpB,UAAAd,CACF,CACF,OAAQe,EAAA,CACN,OAAOH,CACT,CACF,CAEA,IAAMI,EAAS,MAAML,EACnB,CACE,SAAUf,EAAQ,SAClB,YAAYa,EAAAb,EAAQ,aAAR,KAAAa,EAAsB,CAAC,EACnC,OAAOC,EAAAd,EAAQ,QAAR,KAAAc,EAAiB,CAAC,EACzB,UAAWd,EAAQ,UACnB,gBAAiBA,EAAQ,eAC3B,EACAI,EACA,CACE,OAAQJ,EAAQ,OAChB,QAASA,EAAQ,QACjB,OAAQA,EAAQ,OAChB,UAAWA,EAAQ,UACnB,QAASA,EAAQ,QACjB,UAAWA,EAAQ,UACnB,SAAUA,EAAQ,SAClB,WAAYA,EAAQ,WACpB,UAAWA,EAAQ,UACnB,QAASA,EAAQ,OACnB,CACF,EAEA,OAAOqB,EAAAC,EAAA,GAAKF,GAAL,CAAa,UAAAhB,CAAU,EAChC,CFtNA,OAAS,sBAAAmB,OAA0B,4BGgBnC,IAAMC,GAAkB,CAAC,OAAQ,SAAU,aAAa,EAElDC,GAAW,IAAI,IAMd,SAASC,GAAmBC,EAAcC,EAAwC,CACvFH,GAAS,IAAIE,EAAMC,CAAO,CAC5B,CAGO,SAASC,GAAgBF,EAAmD,CACjF,OAAOF,GAAS,IAAIE,CAAI,CAC1B,CAYO,SAASG,EAAeC,EAKjB,CA9Dd,IAAAC,EAAAC,EA+DE,IAAMC,GAAWD,GAAAD,EAAAD,EAAM,UAAN,KAAAC,EAAiBG,GAAgBJ,EAAM,IAAI,IAA3C,KAAAE,EAAgD,CAAC,EAC5DG,EAAgC,CAAC,EACvC,OAAW,CAACC,EAAGC,CAAC,IAAK,OAAO,QAAQJ,CAAQ,EACpCK,GAAsC,SAASF,CAAC,IAAGD,EAAKC,CAAC,EAAIC,GAErE,IAAME,EAAkBC,EAAAC,EAAA,GACnBN,GADmB,CAEtB,KAAML,EAAM,KACZ,OAAQA,EAAM,MAChB,GACA,OAAIA,EAAM,cAAaS,EAAK,YAAcT,EAAM,aACzCS,CACT,CAgBO,SAASG,GAAsBC,EAAyB,CAC7D,OAAO,KAAK,UAAUC,EAAA,CAAE,WAAY,qBAAsB,QAAS,WAAcD,EAAM,EACpF,QAAQ,KAAM,SAAS,CAC5B,CAGO,SAASE,GAAoBF,EAAyB,CAC3D,IAAMG,EAAkB,CAAC,EACrBH,EAAK,OAAOG,EAAM,KAAK,KAAKH,EAAK,KAAK,GAAI,EAAE,EAC5CA,EAAK,SAASG,EAAM,KAAK,OAAOH,EAAK,OAAO,EAAG,EAAE,EAErD,OAAW,CAACI,EAAGC,CAAC,IAAK,OAAO,QAAQL,CAAI,EAClC,CAAC,OAAQ,QAAS,UAAW,SAAU,aAAa,EAAE,SAASI,CAAC,GACpED,EAAM,KAAK,MAAMC,CAAC,GAAI,GAAI,UAAW,KAAK,UAAUC,EAAG,KAAM,CAAC,EAAG,MAAO,EAAE,EAG5E,GAAIL,EAAK,OAAO,OAAS,EAAG,CAC1BG,EAAM,KAAK,YAAa,EAAE,EAC1B,QAAWG,KAAKN,EAAK,OACnBG,EAAM,KAAK,OAAOG,EAAE,EAAE,uBAAkBA,EAAE,OAAO,IAAI,EACjDA,EAAE,UAAY,QAChBH,EAAM,KAAK,GAAI,YAAa,KAAK,UAAUG,EAAE,QAAS,KAAM,CAAC,EAAG,OAAO,EAG3EH,EAAM,KAAK,EAAE,CACf,CAEA,OAAOA,EAAM,KAAK;AAAA,CAAI,EAAE,QAAQ,EAAI;AAAA,CACtC,CC5GO,SAASI,GAAcC,EAAsBC,EAAqC,CAAC,EAAS,CAXnG,IAAAC,EAAAC,EAYE,IAAMC,GAAUF,EAAAD,EAAK,YAAL,KAAAC,EAAkB,MAClC,GAAI,CACGE,EAAQ,GAAGJ,EAAM,OAAO,kBAAmB,CAC9C,OAAQ,OACR,QAAS,CAAE,eAAgB,mBAAoB,cAAe,UAAUA,EAAM,MAAM,EAAG,EACvF,KAAM,KAAK,UAAU,CACnB,KAAMA,EAAM,KACZ,QAASA,EAAM,QACf,WAAWG,EAAAH,EAAM,YAAN,KAAAG,EAAmB,KAC9B,OAAQ,KACV,CAAC,CACH,CAAC,EAAE,MAAM,IAAM,CAAC,CAAC,CACnB,OAAQE,EAAA,CAER,CACF,CCfA,OAAS,qBAAAC,OAAyB,mBAgBlC,SAASC,GAAcC,EAAUC,EAAyB,CACxD,OAAOD,EAAI,SAAS,SAAS,KAAK,GAAKC,EAAO,YAAY,EAAE,SAAS,eAAe,CACtF,CAEO,SAASC,GACdC,EACyC,CACzC,MAAO,OAAOC,GAAwC,CAnCxD,IAAAC,EAoCI,IAAML,EAAM,IAAI,IAAII,EAAQ,GAAG,EACzBH,GAASI,EAAAD,EAAQ,QAAQ,IAAI,QAAQ,IAA5B,KAAAC,EAAiC,GAC1CC,EAAYF,EAAQ,QAAQ,IAAI,YAAY,EAE5CG,EAAOP,EAAI,SAAS,QAAQ,eAAgB,EAAE,EAEpD,GAAIG,EAAO,OACT,GAAI,CACG,QAAQ,QACXA,EAAO,OAAO,CAAE,KAAAI,EAAM,UAAAD,EAAW,QAASE,GAAkBF,GAAA,KAAAA,EAAa,EAAE,CAAE,CAAC,CAChF,EAAE,MAAM,IAAM,CAAC,CAAC,CAClB,OAAQG,EAAA,CAER,CAGF,IAAMC,EAAO,MAAMP,EAAO,QAAQC,CAAO,EAEzC,OAAIL,GAAcC,EAAKC,CAAM,EACpB,IAAI,SAASU,GAAoBD,CAAI,EAAG,CAC7C,QAAS,CAAE,eAAgB,8BAA+B,CAC5D,CAAC,EAEI,IAAI,SAAS,KAAK,UAAUA,CAAI,EAAG,CACxC,QAAS,CAAE,eAAgB,iCAAkC,CAC/D,CAAC,CACH,CACF,CLrCA,OAAS,qBAAAE,GAAmB,gBAAAC,GAAc,eAAAC,GAAa,oBAAAC,OAAwB,mBAsV3E,OA6BE,YAAAC,GA7BF,OAAAC,EA6BE,QAAAC,OA7BF,oBAlVJ,IAAMC,GAAuB,iCAoI7B,SAASC,GAAoBC,EAA8C,CACzE,OAAO,OAAO,QAAQA,CAAsC,EAAE,IAAI,CAAC,CAACC,EAAIC,CAAC,IAAG,CAnK9E,IAAAC,EAmKkF,OAC9E,GAAAF,EACA,QAAS,OAAOC,GAAM,SAAWA,GAAMC,EAAAD,GAAA,YAAAA,EAA8B,YAA9B,KAAAC,EAA2C,EACpF,EAAE,CACJ,CA+BA,eAAsBC,GAAaC,EAAgD,CAtMnF,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAuME,IAeIV,EAAAE,EAdF,YAAAS,EAAa,CAAC,EACd,SAAAC,EACA,MAAAC,EACA,gBAAAC,EACA,UAAAC,EACA,aAAAC,EACA,mBAAoBC,EACpB,aAAcC,EACd,UAAAC,EACA,UAAAC,EACA,cAAAC,EACA,MAAAC,EACA,SAAAC,CApNJ,EAsNMvB,EADCwB,EAAAC,GACDzB,EADC,CAbH,aACA,WACA,QACA,kBACA,YACA,eACA,qBACA,eACA,YACA,YACA,gBACA,QACA,aAII0B,EAAc,MAAMC,GAAQ,EAC5BC,EAAOF,EAAY,IAAI,MAAM,EAC/B,CAACX,GAAa,QAAQ,IAAI,WAAa,cAAgB,CAACa,GAC1D,QAAQ,MACN,8LAEF,EAEF,IAAMC,EAAiBd,GAAA,KAAAA,EACpB,QAAQ,IAAI,WAAa,aACtB,WAAWa,GAAA,KAAAA,EAAQ,WAAW,GAC9B,wBACAE,GAAY3B,EAAAuB,EAAY,IAAI,YAAY,IAA5B,KAAAvB,EAAiC,OAC7C4B,GAAU3B,EAAAsB,EAAY,IAAI,SAAS,IAAzB,KAAAtB,EAA8B,OAIxC,CAAE,UAAA4B,EAAW,SAAAC,CAAS,EAAIC,GAAqBlB,GAAA,KAAAA,EAAgB,CAAC,CAAC,EAKjEmB,GAAaT,EAAY,IAAI,KAAK,IAAM,KAAOA,EAAY,IAAI,SAAS,IAAM,IAO9EU,GAAiBC,GAAqB,CAAE,UAAAP,EAAW,QAAAC,EAAS,UAAWF,CAAe,CAAC,EACvFS,EAAc,MAAMC,GAAQ,EAe5BC,EAAKhB,EAAc,YACnBiB,GACJlC,EAAAiB,EAAc,UAAd,KAAAjB,EACCiC,GAAA,MAAAA,EAAI,SACDnC,EAAAiC,EAAY,IAAIE,EAAG,MAAM,IAAzB,YAAAnC,EAA4B,WAAWC,EAAAkC,EAAG,QAAH,KAAAlC,EAAY,YACnD,OACAoC,GAAUP,IAAcM,IAAY,IAAUD,GAAM,MAAQC,IAAY,GAOxEE,EAAUnB,EAAc,WAC1BA,EAAc,WAAW,QAAQ,MAAO,EAAE,EAC1C7B,GAOEiD,GAAYnC,GAAAD,EAAAY,GAAA,YAAAA,EAAW,OAAX,KAAAZ,EAAmBkB,EAAY,IAAI,YAAY,IAA/C,KAAAjB,EAAoD,IAChEoC,EAAWC,GAAkBhB,GAAA,KAAAA,EAAa,EAAE,EAC9CT,IAAkB,IAASwB,GAC7BE,GAAc,CAAE,QAAAJ,EAAS,OAAQnB,EAAc,OAAQ,KAAMoB,EAAW,QAASC,EAAU,UAAAf,CAAU,CAAC,EAGxG,IAAIkB,EACAC,EAAsC,KACtCC,EACAC,EACAC,EACAC,EAAiE,KACjEC,EAEJ,GAAIrC,EACF+B,EAAqB/B,EACrBqC,EAAepC,UACNwB,GAKTM,EAAqB,CAAC,UAErBpC,GAAYA,EAAS,OAAS,GAC9BC,GAASA,EAAM,OAAS,GACxBC,GAAmBA,EAAgB,OAAS,EAC7C,CAKA,IAAMyC,EAAWzC,GAAmBA,EAAgB,OAAS,EACvD0C,EAAW,MAAMC,GAAqBC,EAAAC,EAAA,CAC1C,SAAU/C,GAAA,KAAAA,EAAY,CAAC,EACvB,WAAAD,EACA,MAAAE,GACI0C,EAAW,CAAE,UAAW,WAAqB,gBAAAzC,CAAgB,EAAI,CAAC,GAJ5B,CAK1C,QAASwB,EACT,OAAQd,EAAc,OACtB,QAAAmB,EACA,OAAQd,EACR,UAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EAIA,UAAAd,EACA,QAASK,EAAc,OACzB,EAAC,EACDwB,EAAqBQ,EAAS,YAC9BP,EAAqBO,EAAS,YAC9BN,EAAeM,EAAS,MACxBL,EAAoBK,EAAS,WAC7BJ,EAAiBI,EAAS,QAC1BH,EACEG,EAAS,UAAY,OACjB,CAAE,QAASA,EAAS,QAAS,YAAY9C,EAAA8C,EAAS,aAAT,KAAA9C,EAAuB,CAAE,EAClE,KACN4C,EAAeE,EAAS,SAC1B,KAAO,CACL,IAAMI,EAAS,MAAMC,GAAwBlD,EAAY,CACvD,QAAS2B,EACT,OAAQd,EAAc,OACtB,QAAAmB,EACA,OAAQd,EACR,UAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EAIA,UAAAd,EACA,QAASK,EAAc,OACzB,CAAC,EACDwB,EAAqBY,EAAO,YAC5BN,EAAeM,EAAO,SACxB,CAIA,IAAME,EACJrE,EAACsE,GAAA,CAAsB,OAAQvC,EAAc,OAAQ,QAAS6B,EAAgB,MAAO/B,EAAO,EAGxF0C,EACJvE,EAACwE,GAAAP,EAAAC,EAAA,GACKnC,GADL,CAIC,QAASiB,EACT,mBAAoBO,EACpB,mBAAoBC,EAGpB,iBAAkBrC,EAClB,aAAcsC,EAGd,kBAAmBC,EACnB,eAAgBC,EAChB,eAAgBC,GAAA,KAAAA,EAAkB,OAClC,eAAgBjB,GAChB,aAAckB,EAEb,SAAA/B,GACH,EAGF,GAAI,CAACH,EACH,OACE1B,GAAAF,GAAA,CACG,UAAAsE,EACAE,GACH,EAOJ,IAAME,GAAOC,EAAe,CAC1B,KAAMvB,EACN,OAAQhD,GAAoBoD,CAAkB,EAC9C,YAAaC,GAAA,KAAAA,EAAsB,OACnC,QAAS7B,EAAU,OACrB,CAAC,EAED,OACE1B,GAAAF,GAAA,CACG,UAAAsE,EACDrE,EAAC,UACC,KAAK,sBACL,MAAO6B,EACP,wBAAyB,CAAE,OAAQ8C,GAAsBF,EAAI,CAAE,EACjE,EACCF,GACH,CAEJ","names":["deriveSessionSegment","extractTrackedParams","matchedAgentToken","cookies","headers","renderPrePaintScript","confidenceBand","jsx","inlineJsString","value","personaScriptBody","props","SentientPersonaScript","preloadAssignments","readSessionCookie","preloadDecisions","defaultSessionId","loadAdaptiveAssignments","components","options","_a","_b","_c","sessionId","readSessionCookie","preloadAssignments","loadAdaptiveDecision","_d","_e","_f","_g","_h","_i","_j","preloadDecisions","fallback","mod","outcome","e","result","__spreadProps","__spreadValues","AdaptiveRootClient","RESERVED_FIELDS","registry","defineAgentContent","page","content","getAgentContent","buildAgentFeed","input","_a","_b","supplied","getAgentContent","safe","k","v","RESERVED_FIELDS","feed","__spreadProps","__spreadValues","renderAgentJsonLdBody","feed","__spreadValues","renderAgentMarkdown","lines","k","v","b","logAgentFetch","entry","deps","_a","_b","doFetch","e","matchedAgentToken","wantsMarkdown","url","accept","createAgentFeed","config","request","_a","userAgent","path","matchedAgentToken","e","feed","renderAgentMarkdown","matchedAgentToken","uaTokenMatch","agentIntent","classifiedAgents","Fragment","jsx","jsxs","DEFAULT_API_BASE_URL","assignmentsToBlocks","assignments","id","v","_a","AdaptiveRoot","props","_b","_c","_d","_e","_f","_g","_h","_i","components","sections","slots","registrySlotIds","appOrigin","searchParams","initialAssignmentsOverride","ssrSessionIdProp","timeoutMs","agentFeed","captureAgents","nonce","children","providerProps","__objRest","headerStore","headers","host","resolvedOrigin","userAgent","referer","utmParams","clickIds","extractTrackedParams","doNotTrack","sessionSegment","deriveSessionSegment","cookieStore","cookies","cf","consent","skipSsr","baseUrl","agentPath","agentBot","matchedAgentToken","logAgentFetch","initialAssignments","initialLayoutOrder","initialSlots","initialSlotConfig","initialPalette","initialPersona","ssrSessionId","registry","decision","loadAdaptiveDecision","__spreadProps","__spreadValues","result","loadAdaptiveAssignments","personaScript","SentientPersonaScript","client","AdaptiveRootClient","feed","buildAgentFeed","renderAgentJsonLdBody"]}
1
+ {"version":3,"sources":["../../src/next/adaptive-root.tsx","../../src/persona-script.tsx","../../src/server.ts","../../src/agent-feed.ts","../../src/next/log-agent-fetch.ts","../../src/next/agent-feed-route.ts"],"sourcesContent":["import { deriveSessionSegment, extractTrackedParams, matchedAgentToken } from '@sentientui/core';\nimport type { SlotDeclInput, SlotResult } from '@sentientui/core';\nimport { cookies, headers } from 'next/headers';\n// `type JSX` from react, not the global namespace removed in @types/react@19\n// (peers allow react >=18) — see adaptive-text.tsx.\nimport type { JSX, ReactNode } from 'react';\nimport type { AdaptiveProviderProps } from '../provider.js';\nimport { SentientPersonaScript } from '../persona-script.js';\nimport {\n loadAdaptiveAssignments,\n loadAdaptiveDecision,\n type LoadAdaptiveDecisionResult,\n type ServerAssignments,\n} from '../server.js';\nimport { AdaptiveRootClient } from './adaptive-root-client.js';\nimport { buildAgentFeed, renderAgentJsonLdBody, type AgentBlock } from '../agent-feed.js';\nimport { logAgentFetch } from './log-agent-fetch.js';\n\nexport { createAgentFeed } from './agent-feed-route.js';\nexport type { AgentFeedRouteConfig, AgentFeedReadEntry } from './agent-feed-route.js';\nexport { defineAgentContent, buildAgentFeed as buildAgentFeedFor } from '../agent-feed.js';\n// Re-exported from core on the SERVER entry (this module is server-only — it\n// imports next/headers). Lets server components do agent detection with just the\n// `@sentientui/react` package, no direct core dependency. Do NOT add this to the\n// package's client index: re-exporting a plain function through a 'use client'\n// module turns it into a client reference that throws when called during SSR.\nexport { matchedAgentToken, uaTokenMatch, agentIntent, classifiedAgents } from '@sentientui/core';\nexport type { AgentIntent } from '@sentientui/core';\nexport type { AgentFeed } from '../agent-feed.js';\n\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport type PreloadComponent = { id: string; variantIds: string[] };\n\nexport type AdaptiveRootProps = Omit<\n AdaptiveProviderProps,\n // Every provider prop AdaptiveRoot itself resolves and passes AFTER the\n // {...providerProps} spread must be omitted here: a caller-supplied value\n // would typecheck but be silently clobbered by the spread order\n // (initialLayoutOrder, declaredSections and sessionSegment were missing\n // from this list and suffered exactly that).\n | 'initialAssignments'\n | 'onAssignment'\n | 'initialSlots'\n | 'initialSlotConfig'\n | 'initialPalette'\n | 'initialPersona'\n | 'initialLayoutOrder'\n | 'declaredSections'\n | 'sessionSegment'\n | 'consentFrom'\n> & {\n /**\n * Cookie-based consent source — see `AdaptiveProviderProps.consentFrom`.\n *\n * Narrowed to the cookie form: AdaptiveRoot is a Server Component and spreads\n * this straight into its client boundary, and a function prop crossing the\n * server→client boundary throws at render (\"Functions cannot be passed\n * directly to Client Components\"). The provider's type accepted `check`, so\n * a Cookiebot-style predicate typechecked here and then crashed the layout.\n * Need a JS-API CMP predicate? Use `<AdaptiveProvider>` in a client component.\n */\n consentFrom?: Omit<NonNullable<AdaptiveProviderProps['consentFrom']>, 'check'>;\n /**\n * Code-variant components to assign server-side (SEO-safe). Optional — an\n * `<Adaptive>` works without an entry here and assigns after mount.\n *\n * List only ids this tree actually renders. Each one is assigned on every\n * request, rendered or not, and every assignment logs an impression (or a\n * holdout exposure). An id the page never renders therefore accrues trials\n * that cannot convert, and in a root layout that happens on every route.\n */\n components?: PreloadComponent[];\n /**\n * Declare page section IDs in their default order. When provided,\n * AdaptiveRoot calls `/v1/decide` (single round trip) instead of\n * individual `/v1/assign` calls, and `useLayoutOrder()` returns the\n * persona-specific order on first render.\n *\n * Give each section's rendered element `data-sentient-id=\"<sectionId>\"` —\n * the only markup a section needs — so the DOM graph scanner can register\n * it under the same id. Without it the server never learns what the section\n * IS, types it `generic`, and serves the identity order to every persona —\n * the integration looks live but cannot personalize. The provider warns\n * about unresolvable ids in development. Correct a section the content\n * classifier mistypes with `sectionTypes`, not extra markup.\n *\n * @example sections={['hero', 'pricing', 'features', 'social_proof']}\n * // …and in the tree: <section data-sentient-id=\"pricing\">\n */\n sections?: string[];\n /**\n * Adaptive-slot declarations used by `useAdaptiveTokens` / `AdaptiveGroup`\n * in this tree. Declaring them here decides them in the same SSR\n * round trip, so their values serialize into the server HTML.\n */\n slots?: SlotDeclInput[];\n /**\n * The generated-mode `<Adaptive id>`s THIS page renders. Declaring them\n * decides their published versions in the same SSR round trip\n * (`/v1/decide` registry mode) and serializes the served content into the\n * server HTML, so the first paint shows the version rather than the\n * original children until the client-side decide answers. Without it a\n * registry slot renders its children first and swaps after mount.\n *\n * Scoped to exactly these ids on purpose: an unscoped registry decide\n * records a close-out trial for every published slot on every page.\n *\n * @example registrySlotIds={['hero-headline', 'pricing-cta']}\n */\n registrySlotIds?: string[];\n /** App origin — must be in the project's `allowed_origins`. */\n appOrigin?: string;\n /**\n * The page's `searchParams` prop (or an equivalent query string /\n * URLSearchParams). Server Components cannot read the request URL from\n * `headers()`, so without this the SSR-minted session carries no `utm_*`\n * params and no ad click IDs (gclid, fbclid, ttclid, …) — campaign\n * attribution only lands after client hydration, and never for visits the\n * client SDK doesn't get to finish (bounce before hydrate). Pass it on\n * landing pages that receive ad traffic:\n *\n * ```tsx\n * export default async function Page({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {\n * return <AdaptiveRoot ... searchParams={await searchParams}>...</AdaptiveRoot>;\n * }\n * ```\n */\n searchParams?: Record<string, string | string[] | undefined> | URLSearchParams | string;\n /** Override: when set no network fetch is made. Useful for tests. */\n initialAssignments?: ServerAssignments;\n /**\n * Milliseconds to wait for the API before rendering default variants.\n * Defaults to 1000. The hot path typically returns in well under 150 ms;\n * the full 1 s budget is only reached on a cold start or an API\n * geographically distant from your SSR host. Lower it if your API is\n * co-located and warm.\n */\n timeoutMs?: number;\n /**\n * When set, AdaptiveRoot emits a server-rendered inline JSON-LD block\n * describing the page's winning variants, layout order, and developer-supplied\n * content — readable by passive AI crawlers (which do not run JS). Invisible to\n * humans (a JSON-LD script renders no visible DOM). Omit to emit nothing.\n */\n agentFeed?: {\n /** Page path for the feed. Falls back to the `x-pathname` request header, then '/'. */\n path?: string;\n /** Structured page content. Falls back to the `defineAgentContent` registry for this path. */\n content?: Record<string, unknown>;\n };\n /**\n * When true (default), a known AI-agent fetch (matched by user-agent —\n * GPTBot, ChatGPT-User, Claude-User, PerplexityBot, …) is logged server-side\n * to your agent analytics. Machine telemetry only (no cookie, no session);\n * fire-and-forget, never affects render. Set false to opt out.\n */\n captureAgents?: boolean;\n /**\n * CSP nonce for the inline persona (and optional agent JSON-LD) scripts.\n * Pass through from Next.js middleware / `headers()` when using a strict CSP.\n */\n nonce?: string;\n children: ReactNode;\n};\n\n/** Build agent blocks from SSR assignments (Record<id, variantId | { variantId }>). */\nfunction assignmentsToBlocks(assignments: ServerAssignments): AgentBlock[] {\n return Object.entries(assignments as Record<string, unknown>).map(([id, v]) => ({\n id,\n variant: typeof v === 'string' ? v : ((v as { variantId?: string })?.variantId ?? ''),\n }));\n}\n\n/**\n * Next.js Server Component that resolves variant assignments (and optionally\n * section layout order) server-side for zero layout shift on first paint.\n *\n * When `sections` is provided, a single `POST /v1/decide` call returns both\n * the persona-specific section order and all component assignments.\n * Without `sections`, individual `/v1/assign` calls are made per component.\n *\n * @example\n * // app/page.tsx — with section layout. Declared on the page (not the root\n * // layout) because hero_cta renders only here; see the `components` prop.\n * import { AdaptiveRoot } from '@sentientui/react/next';\n *\n * export default async function Page() {\n * return (\n * <AdaptiveRoot\n * apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}\n * sections={['hero', 'pricing', 'features', 'social_proof']}\n * components={[\n * { id: 'hero_cta', variantIds: ['default', 'accent'] },\n * ]}\n * >\n * <HeroSection />\n * <PricingSection />\n * <FeaturesSection />\n * <SocialProofSection />\n * </AdaptiveRoot>\n * );\n * }\n */\nexport async function AdaptiveRoot(props: AdaptiveRootProps): Promise<JSX.Element> {\n const {\n components = [],\n sections,\n slots,\n registrySlotIds,\n appOrigin,\n searchParams,\n initialAssignments: initialAssignmentsOverride,\n ssrSessionId: ssrSessionIdProp,\n timeoutMs,\n agentFeed,\n captureAgents,\n nonce,\n children,\n ...providerProps\n } = props;\n\n const headerStore = await headers();\n const host = headerStore.get('host');\n if (!appOrigin && process.env.NODE_ENV === 'production' && !host) {\n console.error(\n '[SentientUI] AdaptiveRoot: Host header is absent and no appOrigin was provided. ' +\n 'Pass appOrigin explicitly — the https://localhost fallback will likely fail allowed_origins validation.',\n );\n }\n const resolvedOrigin = appOrigin ??\n (process.env.NODE_ENV === 'production'\n ? `https://${host ?? 'localhost'}`\n : 'http://localhost:3001');\n const userAgent = headerStore.get('user-agent') ?? undefined;\n const referer = headerStore.get('referer') ?? undefined;\n // Landing-URL attribution (utm_* + ad click IDs). Only available when the\n // page passes its searchParams down — headers() never carries the request's\n // own query string, and the Referer is the PREVIOUS page, not this one.\n const { utmParams, clickIds } = extractTrackedParams(searchParams ?? {});\n // Honor a tracking opt-out at SSR: `DNT: 1` or the legally-enforceable\n // `Sec-GPC: 1`. When set we skip the session upsert + assign/decide so no\n // session row is minted for the visitor (audit P4) — matching the client SDK,\n // which already no-ops for these signals.\n const doNotTrack = headerStore.get('dnt') === '1' || headerStore.get('sec-gpc') === '1';\n // `consent: false` must gate the SERVER too, not just the client. Without\n // this the SSR decide/assign still ran and still minted a session row for a\n // visitor who had not consented — contradicting the documented contract\n // (\"no SDK is initialised, no cookies are written, no events are sent\") and\n // forcing sites to hide AdaptiveRoot behind a conditional render, which is\n // what made consent-after-load cost a full server round trip.\n const sessionSegment = deriveSessionSegment({ userAgent, referer, appOrigin: resolvedOrigin });\n const cookieStore = await cookies();\n\n // This is a Server Component and already has the request cookies, so resolve\n // a cookie-based `consentFrom` here rather than making the app read the same\n // cookie again just to pass `consent` — naming it twice only invites drift.\n // An already-consented visitor therefore gets SSR variant assignment (zero\n // layout shift) with no extra code.\n //\n // An explicit `consent` prop always wins — it is the escape hatch for apps\n // that track consent elsewhere. (No `check()` form here: see the prop type.)\n //\n // Consent gates the SERVER too, not just the client: without it the SSR\n // decide/assign still ran and still minted a session row for a visitor who\n // had not consented, contradicting the documented contract (\"no SDK is\n // initialised, no cookies are written, no events are sent\").\n const cf = providerProps.consentFrom;\n const consent =\n providerProps.consent ??\n (cf?.cookie\n ? cookieStore.get(cf.cookie)?.value === (cf.value ?? 'accepted')\n : undefined);\n const skipSsr = doNotTrack || consent === false || (cf != null && consent !== true);\n\n // SSR preload MUST hit the same API host the client will use, otherwise the\n // SSR-minted session lives on the wrong host and the client's first /assign\n // misses it and re-mints — silently breaking SSR→client continuity for any\n // non-default / self-hosted deployment. The client derives its base from\n // apiBaseUrl too (see provider.tsx), so thread the same value here.\n const baseUrl = providerProps.apiBaseUrl\n ? providerProps.apiBaseUrl.replace(/\\/$/, '')\n : DEFAULT_API_BASE_URL;\n\n // Server-side agent-fetch capture (spec: nextjs-agent-fetch-capture). JS-less\n // assistants (GPTBot / ChatGPT-User / Claude-User / PerplexityBot / …) never\n // run client JS, but they trigger SSR — so AdaptiveRoot sees their UA here.\n // Fire-and-forget; never blocks or breaks render. `agentPath` is reused by the\n // agentFeed JSON-LD below.\n const agentPath = agentFeed?.path ?? headerStore.get('x-pathname') ?? '/';\n const agentBot = matchedAgentToken(userAgent ?? '');\n if (captureAgents !== false && agentBot) {\n logAgentFetch({ baseUrl, apiKey: providerProps.apiKey, path: agentPath, botName: agentBot, userAgent });\n }\n\n let initialAssignments: ServerAssignments;\n let initialLayoutOrder: string[] | null = null;\n let initialSlots: Record<string, SlotResult> | undefined;\n let initialSlotConfig: LoadAdaptiveDecisionResult['slotConfig'];\n let initialPalette: LoadAdaptiveDecisionResult['palette'];\n let initialPersona: { persona: string; confidence: number } | null = null;\n let ssrSessionId: string | undefined;\n\n // Registry mode only when ids were declared: an unscoped registry decide\n // records a close-out trial for every published slot on every page.\n const registry = !!registrySlotIds?.length;\n\n if (initialAssignmentsOverride) {\n initialAssignments = initialAssignmentsOverride;\n ssrSessionId = ssrSessionIdProp;\n } else if (skipSsr) {\n // Nothing server-side: no decide, no assign, no session. Components fall\n // back to `ssrFallback`, and the client starts only if the visitor later\n // consents — via the `consent` prop or grantConsent(), neither of which\n // needs a page reload.\n initialAssignments = {};\n } else if ((sections && sections.length > 0) || (slots && slots.length > 0) || registry) {\n // `loadAdaptiveDecision` accepted `registrySlotIds` long before AdaptiveRoot\n // passed them, so an `<Adaptive id>` under AdaptiveRoot showed its original\n // children on first paint until the client-side decide returned.\n const decision = await loadAdaptiveDecision({\n sections: sections ?? [],\n components,\n slots,\n ...(registry ? { slotsFrom: 'registry' as const, registrySlotIds } : {}),\n cookies: cookieStore,\n apiKey: providerProps.apiKey,\n baseUrl,\n origin: resolvedOrigin,\n userAgent,\n referer,\n utmParams,\n clickIds,\n // doNotTrack is deliberately not passed: it is necessarily false on this\n // branch — a DNT/GPC or consent-gated request already took the skipSsr\n // arm above and never reaches this loader.\n timeoutMs,\n persona: providerProps.persona,\n });\n initialAssignments = decision.assignments;\n initialLayoutOrder = decision.layoutOrder;\n initialSlots = decision.slots;\n initialSlotConfig = decision.slotConfig;\n initialPalette = decision.palette;\n initialPersona =\n decision.persona !== undefined\n ? { persona: decision.persona, confidence: decision.confidence ?? 0 }\n : null;\n ssrSessionId = decision.sessionId;\n } else {\n const result = await loadAdaptiveAssignments(components, {\n cookies: cookieStore,\n apiKey: providerProps.apiKey,\n baseUrl,\n origin: resolvedOrigin,\n userAgent,\n referer,\n utmParams,\n clickIds,\n // doNotTrack is deliberately not passed: it is necessarily false on this\n // branch — a DNT/GPC or consent-gated request already took the skipSsr\n // arm above and never reaches this loader.\n timeoutMs,\n persona: providerProps.persona,\n });\n initialAssignments = result.assignments;\n ssrSessionId = result.sessionId;\n }\n\n // Single-writer inline script — ALWAYS the first child, before any markup\n // that CSS keyed on the persona attributes could style.\n const personaScript = (\n <SentientPersonaScript apiKey={providerProps.apiKey} persona={initialPersona} nonce={nonce} />\n );\n\n const client = (\n <AdaptiveRootClient\n {...providerProps}\n // Forward the server-resolved value so a consented visitor's client does\n // not start gated and re-resolve the same cookie on mount.\n consent={consent}\n initialAssignments={initialAssignments}\n initialLayoutOrder={initialLayoutOrder}\n // Declared regardless of what came back, so devtools can preview layout on\n // a page whose decision was gated or timed out.\n declaredSections={sections}\n initialSlots={initialSlots}\n // Registry-mode preload: the hook treats a preloaded slot config as\n // settled, so the client does not decide the same slot a second time.\n initialSlotConfig={initialSlotConfig}\n initialPalette={initialPalette}\n initialPersona={initialPersona ?? undefined}\n sessionSegment={sessionSegment}\n ssrSessionId={ssrSessionId}\n >\n {children}\n </AdaptiveRootClient>\n );\n\n if (!agentFeed) {\n return (\n <>\n {personaScript}\n {client}\n </>\n );\n }\n\n // Server-rendered inline JSON-LD for AI crawlers. Emitted only on the server\n // path so passive crawlers (no JS) see it in the raw HTML. The body escapes\n // '<' so page content cannot break out of the <script> element.\n const feed = buildAgentFeed({\n page: agentPath,\n blocks: assignmentsToBlocks(initialAssignments),\n layoutOrder: initialLayoutOrder ?? undefined,\n content: agentFeed.content,\n });\n\n return (\n <>\n {personaScript}\n <script\n type=\"application/ld+json\"\n nonce={nonce}\n dangerouslySetInnerHTML={{ __html: renderAgentJsonLdBody(feed) }}\n />\n {client}\n </>\n );\n}\n","// `type JSX` from react, not the global namespace removed in @types/react@19\n// (peers allow react >=18) — see adaptive-text.tsx.\nimport type { JSX } from 'react';\nimport { renderPrePaintScript } from '@sentientui/core';\nimport { confidenceBand } from '@sentientui/policy';\n\nexport type SentientPersonaScriptProps = {\n /** Publishable API key — selects the localStorage snapshot in the fallback path. */\n apiKey: string;\n /**\n * CSP nonce for the inline pre-paint script. Pass the same nonce your\n * `Content-Security-Policy` `script-src` allows (e.g. from Next.js middleware).\n * Required for strict CSP deployments that block `'unsafe-inline'`.\n */\n nonce?: string;\n /**\n * SSR-decided persona (from `loadAdaptiveDecision`). When present the\n * script embeds the literal values; when absent it reads the local\n * decision snapshot (SPA / return-visit path).\n */\n persona?: { persona: string; confidence: number } | null;\n};\n\n/** JSON string literal that is also safe inside an inline <script> element. */\nfunction inlineJsString(value: string): string {\n return JSON.stringify(value).replace(/</g, '\\\\u003c');\n}\n\n/** Exported for tests. Builds the inline JS (concatenation only — no backticks). */\nexport function personaScriptBody(props: SentientPersonaScriptProps): string {\n if (props.persona) {\n return (\n '(function(){try{var d=document.documentElement;' +\n 'if(d.hasAttribute(\"data-sentient-persona\"))return;' +\n 'd.setAttribute(\"data-sentient-persona\",' + inlineJsString(props.persona.persona) + ');' +\n 'd.setAttribute(\"data-sentient-confidence\",' + inlineJsString(confidenceBand(props.persona.confidence)) + ');' +\n '}catch(e){}})();'\n );\n }\n return renderPrePaintScript(props.apiKey);\n}\n\n/**\n * Single writer of the Rung-1a `<html>` attributes\n * (`data-sentient-persona`, `data-sentient-confidence`), executed pre-paint.\n *\n * `AdaptiveRoot` renders this automatically as its first child. For Pages\n * Router / Remix, render it yourself in `_document` / the root layout.\n *\n * IMPORTANT (install docs): add `suppressHydrationWarning` to your `<html>`\n * element — this script mutates documentElement before React hydrates it\n * (the same pattern next-themes uses). The client SDK adopts the attributes\n * as truth and never rewrites them mid-session.\n */\nexport function SentientPersonaScript(props: SentientPersonaScriptProps): JSX.Element {\n return (\n <script\n data-sentient-persona-script=\"\"\n nonce={props.nonce}\n dangerouslySetInnerHTML={{ __html: personaScriptBody(props) }}\n />\n );\n}\n","/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core/server';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\n/** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */\nexport type LoadAdaptiveAssignmentsResult = {\n assignments: ServerAssignments;\n /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */\n sessionId: string;\n};\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n /**\n * `utm_*` params from the landing URL. The Referer header never carries the\n * page's OWN query string, so without this the SSR-minted session has no\n * campaign attribution until the client SDK hydrates and re-upserts.\n * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.\n */\n utmParams?: Record<string, string>;\n /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */\n clickIds?: Record<string, string>;\n /** 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. */\n doNotTrack?: boolean;\n /** 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). */\n timeoutMs?: number;\n /**\n * Declared persona — the role your app already knows for this visitor (e.g.\n * from your auth context: 'admin', 'evaluator'). Must be a key in the\n * project's persona vocabulary; unrecognized values are ignored server-side.\n * Never a user id or email.\n */\n persona?: string;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`\n * on `<AdaptiveProvider>` so the client adopts the same session on first visit.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<LoadAdaptiveAssignmentsResult> {\n // apiKey is not optional here: the client writes the per-project suffixed\n // cookie, so an un-keyed read missed every returning visitor and minted a\n // fresh orphan session per SSR request (see readSessionCookie in core).\n const sessionId =\n readSessionCookie(options.cookies, options.apiKey) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n const assignments = await preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n utmParams: options.utmParams,\n clickIds: options.clickIds,\n doNotTrack: options.doNotTrack,\n timeoutMs: options.timeoutMs,\n persona: options.persona,\n });\n\n return { assignments, sessionId };\n}\n\nexport { preloadDecisions } from '@sentientui/core/server';\nexport type { DecideResult, SlotDeclInput, SlotResult } from '@sentientui/core/server';\n\n/** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */\nexport type LoadAdaptiveDecisionResult = import('@sentientui/core/server').DecideResult & {\n sessionId: string;\n};\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /**\n * Section IDs in default order. Passed to /v1/decide as the candidate\n * layout. Optional since 0.13.0 — slot-only pages may omit it (at least\n * one of `sections`/`components`/`slots` must be non-empty).\n */\n sections?: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */\n slots?: import('@sentientui/core/server').SlotDeclInput[];\n /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)\n * and is the only way `slotConfig`/`palette` come back. Default 'request'.\n * Requires `registrySlotIds`. */\n slotsFrom?: 'request' | 'registry';\n /**\n * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is\n * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it\n * the call downgrades to request mode (with a console.error) instead of\n * recording a close-out trial for every published slot on every page.\n */\n registrySlotIds?: string[];\n};\n\n/**\n * SSR helper for pages with a declared section layout and/or adaptive slots.\n * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.\n * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client\n * adopts the same session on first visit.\n *\n * Keyless: with no valid `pk_` key this never fetches (no timeout burn).\n * Under the `development` export condition the decision is computed by the\n * deterministic local engine with the same sessionId the client will adopt —\n * server and client agree by construction. In production the engine resolves\n * to a stub and defaults are returned with one console.error.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<LoadAdaptiveDecisionResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core/server');\n\n // Keyed read — the client's cookie name is suffixed per project (see\n // loadAdaptiveAssignments above). Works for keyless too: with no pk_ key the\n // client writes the bare legacy name, which the un-suffixed read falls back to.\n const sessionId =\n readSessionCookie(options.cookies, options.apiKey) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n const keyValid = typeof options.apiKey === 'string' && options.apiKey.startsWith('pk_');\n if (!keyValid) {\n const fallback: LoadAdaptiveDecisionResult = {\n layoutOrder: options.sections ?? [],\n assignments: {},\n slots: {},\n persona: 'unknown',\n confidence: 0,\n sessionId,\n };\n try {\n const mod = (await import('@sentientui/core/local')) as unknown as {\n LOCAL_ENGINE_AVAILABLE: boolean;\n createLocalEngine(opts: { sessionId: string }): {\n decide(input: {\n sections?: string[];\n components?: Array<{ id: string; variantIds?: string[] }>;\n slots?: LoadAdaptiveDecisionOptions['slots'];\n }): {\n layoutOrder: string[] | null;\n assignments: Record<string, string>;\n slots: Record<string, string | Record<string, string>>;\n persona: string;\n confidence: number;\n };\n };\n };\n if (!mod.LOCAL_ENGINE_AVAILABLE) {\n // Pinned message — must byte-match PROD_KEYLESS_ERROR in @sentientui/core.\n console.error(\n '[sentient] No API key configured — nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.',\n );\n return fallback;\n }\n const outcome = mod.createLocalEngine({ sessionId }).decide({\n sections: options.sections,\n components: options.components ?? [],\n slots: options.slots ?? [],\n });\n return {\n layoutOrder: outcome.layoutOrder ?? options.sections ?? [],\n assignments: outcome.assignments,\n slots: outcome.slots,\n persona: outcome.persona,\n confidence: outcome.confidence,\n sessionId,\n };\n } catch {\n return fallback;\n }\n }\n\n const result = await preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n slots: options.slots ?? [],\n slotsFrom: options.slotsFrom,\n registrySlotIds: options.registrySlotIds,\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n utmParams: options.utmParams,\n clickIds: options.clickIds,\n doNotTrack: options.doNotTrack,\n timeoutMs: options.timeoutMs,\n persona: options.persona,\n },\n );\n\n return { ...result, sessionId };\n}\n","/**\n * Agent-readable content feed. Merges SDK-known data (winning variants, layout\n * order) with developer-supplied page content, and renders it either as a\n * server-rendered inline JSON-LD block (read by passive AI crawlers, which do\n * not run JS) or as Markdown (for agents that content-negotiate `text/markdown`).\n *\n * No React or DOM APIs — safe to import in server components, route handlers,\n * and middleware.\n */\n\nexport type AgentBlock = {\n /** Component ID. */\n id: string;\n /** Winning variant ID currently served. */\n variant: string;\n /** Agent-readable data attached to the served variant, if any. */\n content?: unknown;\n};\n\nexport type AgentFeed = {\n page: string;\n title?: string;\n summary?: string;\n layoutOrder?: string[];\n blocks: AgentBlock[];\n /** Developer-supplied extra fields (products, specs, arbitrary JSON). */\n [key: string]: unknown;\n};\n\n/** Fields the SDK owns — developer content can never overwrite these. */\nconst RESERVED_FIELDS = ['page', 'blocks', 'layoutOrder'] as const;\n\nconst registry = new Map<string, Record<string, unknown>>();\n\n/**\n * Register page-level structured content the SDK can't infer (title, summary,\n * product fields, arbitrary JSON), keyed by page path. Call at module load.\n */\nexport function defineAgentContent(page: string, content: Record<string, unknown>): void {\n registry.set(page, content);\n}\n\n/** Look up registered content for a page. */\nexport function getAgentContent(page: string): Record<string, unknown> | undefined {\n return registry.get(page);\n}\n\n/** Clear the registry — intended for tests. */\nexport function clearAgentContent(): void {\n registry.clear();\n}\n\n/**\n * Merge SDK-known data with developer-supplied content into a single feed.\n * Developer content fills in title/summary/etc. but can never overwrite the\n * SDK-authoritative fields (`page`, `blocks`, `layoutOrder`).\n */\nexport function buildAgentFeed(input: {\n page: string;\n blocks: AgentBlock[];\n layoutOrder?: string[];\n content?: Record<string, unknown>;\n}): AgentFeed {\n const supplied = input.content ?? getAgentContent(input.page) ?? {};\n const safe: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(supplied)) {\n if (!(RESERVED_FIELDS as readonly string[]).includes(k)) safe[k] = v;\n }\n const feed: AgentFeed = {\n ...safe,\n page: input.page,\n blocks: input.blocks,\n };\n if (input.layoutOrder) feed.layoutOrder = input.layoutOrder;\n return feed;\n}\n\n/**\n * Render the feed as a server-rendered inline JSON-LD `<script>` string. `<` is\n * escaped to `<` so embedded content cannot break out of the script\n * element. MUST be emitted on the server — passive crawlers never run client JS.\n */\nexport function renderAgentJsonLd(feed: AgentFeed): string {\n return `<script type=\"application/ld+json\">${renderAgentJsonLdBody(feed)}</script>`;\n}\n\n/**\n * The escaped JSON-LD body only (no `<script>` wrapper). For React server\n * components, inject via `<script type=\"application/ld+json\"\n * dangerouslySetInnerHTML={{ __html: renderAgentJsonLdBody(feed) }} />`.\n */\nexport function renderAgentJsonLdBody(feed: AgentFeed): string {\n return JSON.stringify({ '@context': 'https://schema.org', '@type': 'WebPage', ...feed })\n .replace(/</g, '\\\\u003c');\n}\n\n/** Render the feed as Markdown for agents that negotiate `text/markdown`. */\nexport function renderAgentMarkdown(feed: AgentFeed): string {\n const lines: string[] = [];\n if (feed.title) lines.push(`# ${feed.title}`, '');\n if (feed.summary) lines.push(String(feed.summary), '');\n\n for (const [k, v] of Object.entries(feed)) {\n if (['page', 'title', 'summary', 'blocks', 'layoutOrder'].includes(k)) continue;\n lines.push(`## ${k}`, '', '```json', JSON.stringify(v, null, 2), '```', '');\n }\n\n if (feed.blocks.length > 0) {\n lines.push('## blocks', '');\n for (const b of feed.blocks) {\n lines.push(`- **${b.id}** → variant \\`${b.variant}\\``);\n if (b.content !== undefined) {\n lines.push('', ' ```json', JSON.stringify(b.content, null, 2), ' ```');\n }\n }\n lines.push('');\n }\n\n return lines.join('\\n').trimEnd() + '\\n';\n}\n","// Fire-and-forget server-side log of a known AI-agent fetch to crawler_requests\n// (via POST /v1/crawler-events). Machine telemetry — no cookie, no session.\n// MUST NOT throw or be awaited into the render path.\nexport type AgentFetchLog = {\n baseUrl: string; // API base ending in /v1\n apiKey: string; // public pk_ key\n path: string;\n botName: string;\n userAgent?: string;\n};\n\nexport function logAgentFetch(entry: AgentFetchLog, deps: { fetchImpl?: typeof fetch } = {}): void {\n const doFetch = deps.fetchImpl ?? fetch;\n try {\n void doFetch(`${entry.baseUrl}/crawler-events`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${entry.apiKey}` },\n body: JSON.stringify({\n path: entry.path,\n botName: entry.botName,\n userAgent: entry.userAgent ?? null,\n source: 'ssr',\n }),\n }).catch(() => {});\n } catch {\n /* never break render */\n }\n}\n","/**\n * `createAgentFeed` — a framework-standard Route Handler (Web `Request` →\n * `Response`) that serves the agent-readable feed via HTTP content negotiation:\n * `text/markdown` (Accept header or `.md` URL) → Markdown, otherwise JSON.\n *\n * This is the secondary channel of the agent-readable design — for agents that\n * *ask* (coding agents, agents the customer controls, future crawlers). The\n * primary channel is the server-rendered inline JSON-LD from `<AdaptiveRoot>`.\n *\n * Every fetch is reported to `onRead` (best-effort) so it can be logged to\n * `crawler_requests` and counted in the dashboard traffic breakdown.\n */\nimport { matchedAgentToken } from '@sentientui/core';\nimport { renderAgentMarkdown, type AgentFeed } from '../agent-feed.js';\n\nexport type AgentFeedReadEntry = {\n path: string;\n userAgent: string | null;\n botName: string | null;\n};\n\nexport type AgentFeedRouteConfig = {\n /** Resolve the feed for a request (winning variants + layout + dev content). */\n getFeed: (request: Request) => Promise<AgentFeed> | AgentFeed;\n /** Best-effort per-fetch hook — log to `crawler_requests` here. Never awaited into the response. */\n onRead?: (entry: AgentFeedReadEntry) => void | Promise<void>;\n};\n\nfunction wantsMarkdown(url: URL, accept: string): boolean {\n return url.pathname.endsWith('.md') || accept.toLowerCase().includes('text/markdown');\n}\n\nexport function createAgentFeed(\n config: AgentFeedRouteConfig,\n): (request: Request) => Promise<Response> {\n return async (request: Request): Promise<Response> => {\n const url = new URL(request.url);\n const accept = request.headers.get('accept') ?? '';\n const userAgent = request.headers.get('user-agent');\n // Strip the .md/.json suffix so the feed path matches the page path.\n const path = url.pathname.replace(/\\.(md|json)$/, '');\n\n if (config.onRead) {\n try {\n void Promise.resolve(\n config.onRead({ path, userAgent, botName: matchedAgentToken(userAgent ?? '') }),\n ).catch(() => {});\n } catch {\n /* logging must never break the response */\n }\n }\n\n const feed = await config.getFeed(request);\n\n if (wantsMarkdown(url, accept)) {\n return new Response(renderAgentMarkdown(feed), {\n headers: { 'content-type': 'text/markdown; charset=utf-8' },\n });\n }\n return new Response(JSON.stringify(feed), {\n headers: { 'content-type': 'application/json; charset=utf-8' },\n });\n };\n}\n"],"mappings":"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","names":["deriveSessionSegment","extractTrackedParams","matchedAgentToken","cookies","headers","renderPrePaintScript","confidenceBand","jsx","inlineJsString","value","personaScriptBody","props","SentientPersonaScript","preloadAssignments","readSessionCookie","preloadDecisions","defaultSessionId","loadAdaptiveAssignments","components","options","_a","_b","_c","sessionId","readSessionCookie","preloadAssignments","loadAdaptiveDecision","_d","_e","_f","_g","_h","_i","_j","preloadDecisions","fallback","mod","outcome","e","result","__spreadProps","__spreadValues","AdaptiveRootClient","RESERVED_FIELDS","registry","defineAgentContent","page","content","getAgentContent","buildAgentFeed","input","_a","_b","supplied","getAgentContent","safe","k","v","RESERVED_FIELDS","feed","__spreadProps","__spreadValues","renderAgentJsonLdBody","feed","__spreadValues","renderAgentMarkdown","lines","k","v","b","logAgentFetch","entry","deps","_a","_b","doFetch","e","matchedAgentToken","wantsMarkdown","url","accept","createAgentFeed","config","request","_a","userAgent","path","matchedAgentToken","e","feed","renderAgentMarkdown","matchedAgentToken","uaTokenMatch","agentIntent","classifiedAgents","Fragment","jsx","jsxs","DEFAULT_API_BASE_URL","assignmentsToBlocks","assignments","id","v","_a","AdaptiveRoot","props","_b","_c","_d","_e","_f","_g","_h","_i","components","sections","slots","registrySlotIds","appOrigin","searchParams","initialAssignmentsOverride","ssrSessionIdProp","timeoutMs","agentFeed","captureAgents","nonce","children","providerProps","__objRest","headerStore","headers","host","resolvedOrigin","userAgent","referer","utmParams","clickIds","extractTrackedParams","doNotTrack","sessionSegment","deriveSessionSegment","cookieStore","cookies","cf","consent","skipSsr","baseUrl","agentPath","agentBot","matchedAgentToken","logAgentFetch","initialAssignments","initialLayoutOrder","initialSlots","initialSlotConfig","initialPalette","initialPersona","ssrSessionId","registry","decision","loadAdaptiveDecision","__spreadProps","__spreadValues","result","loadAdaptiveAssignments","personaScript","SentientPersonaScript","client","AdaptiveRootClient","feed","buildAgentFeed","renderAgentJsonLdBody"]}
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- "use strict";var se=Object.create;var h=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))fe.call(t,n)&&F(e,n,t[n]);return e},$=(e,t)=>ae(e,ce(t));var ge=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!B.call(e,i)&&i!==n&&h(e,i,{get:()=>t[i],enumerable:!(s=le(t,i))||s.enumerable});return e};var U=(e,t,n)=>(n=e!=null?se(ue(e)):{},V(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(h({},"__esModule",{value:!0}),e);var Pe={};ge(Pe,{renderWithSentient:()=>ke});module.exports=pe(Pe);var oe=require("@testing-library/react");var r=require("react"),k=require("@sentientui/core");var me=new Map,ve=new Map;function z(e,t){me.set(e,t);let n=ve.get(e);if(n)for(let s of n)try{s(t)}catch(i){}}var _e={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function A(){return j().on}function H(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function q(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,s,i)=>e.assign(t,n,s,i),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ye="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(ye))}function X(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function R(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function O(){if(typeof window=="undefined")return Se;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 we(){O().version+=1;for(let e of O().listeners)e()}function I(e){R()&&(O().sections=[...e],we())}var J="0.34.0",D=J!=="0.0.0-dev"?{name:"react",version:J}:void 0;function he(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function L(e,t){he()[e]=t}function be(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function G(e,t){be()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",W="sentient-cell-preview-bar",T="__preview__";function Z(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(W))return;let t,n;try{let g=new URLSearchParams(window.location.search);t=g.get(Q),n=g.get(Y)}catch(g){return}if(!t||!n)return;let s=n.lastIndexOf("~");if(s<=0)return;let i=n.slice(0,s),f=n.slice(s+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async g=>{if(!g.ok){E(g.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 c=await g.json();if(c.blocks!=null)L(i,{kind:"arms",blocks:{[T]:c.blocks}}),G(i,T);else if(c.content!=null)L(i,{kind:"arms",content:c.content}),G(i,T);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${i}"]`))==null||y.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var i;if(document.getElementById(W))return;let t=document.createElement("div");t.id=W,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 s=document.createElement("button");s.textContent="Exit preview",Object.assign(s.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"}),s.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(Q),f.searchParams.delete(Y),window.location.assign(f.toString())},t.append(n,s),((i=document.body)!=null?i:document.documentElement).append(t)}var ne=require("react/jsx-runtime");function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,k.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ee="https://api.sentient-ui.com/v1",xe=(0,r.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ee,debug:!1});function Re(e){let[t,n]=(0,r.useState)(!1),s=(0,r.useRef)(e);s.current=e;let{cookie:i,value:f,event:_}=e!=null?e:{},g=typeof(e==null?void 0:e.check)=="function";return(0,r.useEffect)(()=>{let c=()=>{var w;let d=s.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let b=`${d.cookie}=${(w=d.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(P=>P.trim()===b)};if(n(c()),!_)return;let y=()=>{n(c())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[i,f,_,g]),t}function te(e){var M,K;let[t,n]=(0,r.useState)(null),[s]=(0,r.useState)(()=>{var o;return(o=e.sessionSegment)!=null?o:Ce()}),[i,f]=(0,r.useState)(A());(0,r.useEffect)(()=>H(()=>f(A())),[]),(0,r.useEffect)(()=>{Z(e.apiBaseUrl)},[]);let _=Re(e.consentFrom),g=e.consentFrom?e.consent===!0||_:e.consent,c=(0,r.useRef)(null);(0,r.useEffect)(()=>{var S;if(g===!1&&!e.preConsentBehavior){(S=c.current)==null||S.destroy(),c.current=null,n(null);return}let o=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:s,consent:g,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),u=!1,a=null,l=null,p=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{u||(l=C(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($(v({},o),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),c.current=a,n(a),p(a))}):(a=(0,k.init)(o),c.current=a,n(a),p(a)),()=>{u=!0,l==null||l(),a==null||a.dispose()}},[g]),(0,r.useEffect)(()=>{if(!t)return;let o=!1,u=async()=>{if(o)return;let l;try{l=await t.fetchWeights()}catch(p){return}if(!o)for(let p of l){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(m=>{var C;return{variantId:m.variantId,pulls:m.pulls,avgReward:(C=m.avgReward)!=null?C:0}})};z(p.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{o=!0,clearInterval(a)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",d=((K=e.apiBaseUrl)!=null?K:ee).replace(/\/$/,""),b=(0,r.useRef)(null);(0,r.useEffect)(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let o={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=b.current;if(b.current=o,u!==null)for(let l of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[l],o[l])||console.warn(`[sentient] AdaptiveProvider: \`${l}\` 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,d]),(0,r.useEffect)(()=>{var o;typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production"||X({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,r.useEffect)(()=>{let o=e.initialLayoutOrder;if(o&&o.length>0){I(o);return}e.declaredSections&&e.declaredSections.length>0&&I(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,r.useEffect)(()=>{if(!R())return;let o=e.declaredSections;if(!o||o.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),l=>l.getAttribute("data-sentient-id"))),a=o.filter(l=>!u.has(l));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(l=>`"${l}"`).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 w=(0,r.useMemo)(()=>t&&i?q(t):t,[t,i]),P=(0,r.useMemo)(()=>{var o,u,a,l,p,S,m;return{client:w,apiKey:e.apiKey,initialAssignments:(o=e.initialAssignments)!=null?o:{},sessionSegment:s,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(l=e.initialSlotConfig)!=null?l:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:d,debug:(m=e.debug)!=null?m:!1}},[w,e.apiKey,e.initialAssignments,s,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ne.jsx)(xe.Provider,{value:P,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,s,i;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(s=e.confidence)!=null?s:1};try{let f=document.documentElement;f.setAttribute("data-sentient-persona",e.persona),f.setAttribute("data-sentient-confidence",Ee((i=e.confidence)!=null?i:1))}catch(f){}}else delete t.__sentient_persona_override;x()}var re=require("react/jsx-runtime");function ke(e,t={},n){return ie(t),(0,oe.render)((0,re.jsx)(te,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
2
+ "use strict";var se=Object.create;var h=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))fe.call(t,n)&&F(e,n,t[n]);return e},$=(e,t)=>ae(e,ce(t));var ge=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!B.call(e,i)&&i!==n&&h(e,i,{get:()=>t[i],enumerable:!(s=le(t,i))||s.enumerable});return e};var U=(e,t,n)=>(n=e!=null?se(ue(e)):{},V(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(h({},"__esModule",{value:!0}),e);var Pe={};ge(Pe,{renderWithSentient:()=>ke});module.exports=pe(Pe);var oe=require("@testing-library/react");var r=require("react"),k=require("@sentientui/core");var me=new Map,ve=new Map;function z(e,t){me.set(e,t);let n=ve.get(e);if(n)for(let s of n)try{s(t)}catch(i){}}var _e={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function A(){return j().on}function H(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function q(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,s,i)=>e.assign(t,n,s,i),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ye="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(ye))}function X(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function R(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function O(){if(typeof window=="undefined")return Se;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 we(){O().version+=1;for(let e of O().listeners)e()}function I(e){R()&&(O().sections=[...e],we())}var J="0.34.1",D=J!=="0.0.0-dev"?{name:"react",version:J}:void 0;function he(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function L(e,t){he()[e]=t}function be(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function G(e,t){be()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",W="sentient-cell-preview-bar",T="__preview__";function Z(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(W))return;let t,n;try{let g=new URLSearchParams(window.location.search);t=g.get(Q),n=g.get(Y)}catch(g){return}if(!t||!n)return;let s=n.lastIndexOf("~");if(s<=0)return;let i=n.slice(0,s),f=n.slice(s+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async g=>{if(!g.ok){E(g.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 c=await g.json();if(c.blocks!=null)L(i,{kind:"arms",blocks:{[T]:c.blocks}}),G(i,T);else if(c.content!=null)L(i,{kind:"arms",content:c.content}),G(i,T);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${i}"]`))==null||y.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var i;if(document.getElementById(W))return;let t=document.createElement("div");t.id=W,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 s=document.createElement("button");s.textContent="Exit preview",Object.assign(s.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"}),s.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(Q),f.searchParams.delete(Y),window.location.assign(f.toString())},t.append(n,s),((i=document.body)!=null?i:document.documentElement).append(t)}var ne=require("react/jsx-runtime");function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,k.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ee="https://api.sentient-ui.com/v1",xe=(0,r.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ee,debug:!1});function Re(e){let[t,n]=(0,r.useState)(!1),s=(0,r.useRef)(e);s.current=e;let{cookie:i,value:f,event:_}=e!=null?e:{},g=typeof(e==null?void 0:e.check)=="function";return(0,r.useEffect)(()=>{let c=()=>{var w;let d=s.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let b=`${d.cookie}=${(w=d.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(P=>P.trim()===b)};if(n(c()),!_)return;let y=()=>{n(c())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[i,f,_,g]),t}function te(e){var M,K;let[t,n]=(0,r.useState)(null),[s]=(0,r.useState)(()=>{var o;return(o=e.sessionSegment)!=null?o:Ce()}),[i,f]=(0,r.useState)(A());(0,r.useEffect)(()=>H(()=>f(A())),[]),(0,r.useEffect)(()=>{Z(e.apiBaseUrl)},[]);let _=Re(e.consentFrom),g=e.consentFrom?e.consent===!0||_:e.consent,c=(0,r.useRef)(null);(0,r.useEffect)(()=>{var S;if(g===!1&&!e.preConsentBehavior){(S=c.current)==null||S.destroy(),c.current=null,n(null);return}let o=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:s,consent:g,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),u=!1,a=null,l=null,p=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{u||(l=C(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($(v({},o),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),c.current=a,n(a),p(a))}):(a=(0,k.init)(o),c.current=a,n(a),p(a)),()=>{u=!0,l==null||l(),a==null||a.dispose()}},[g]),(0,r.useEffect)(()=>{if(!t)return;let o=!1,u=async()=>{if(o)return;let l;try{l=await t.fetchWeights()}catch(p){return}if(!o)for(let p of l){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(m=>{var C;return{variantId:m.variantId,pulls:m.pulls,avgReward:(C=m.avgReward)!=null?C:0}})};z(p.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{o=!0,clearInterval(a)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",d=((K=e.apiBaseUrl)!=null?K:ee).replace(/\/$/,""),b=(0,r.useRef)(null);(0,r.useEffect)(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let o={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=b.current;if(b.current=o,u!==null)for(let l of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[l],o[l])||console.warn(`[sentient] AdaptiveProvider: \`${l}\` 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,d]),(0,r.useEffect)(()=>{var o;typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production"||X({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,r.useEffect)(()=>{let o=e.initialLayoutOrder;if(o&&o.length>0){I(o);return}e.declaredSections&&e.declaredSections.length>0&&I(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,r.useEffect)(()=>{if(!R())return;let o=e.declaredSections;if(!o||o.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),l=>l.getAttribute("data-sentient-id"))),a=o.filter(l=>!u.has(l));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(l=>`"${l}"`).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 w=(0,r.useMemo)(()=>t&&i?q(t):t,[t,i]),P=(0,r.useMemo)(()=>{var o,u,a,l,p,S,m;return{client:w,apiKey:e.apiKey,initialAssignments:(o=e.initialAssignments)!=null?o:{},sessionSegment:s,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(l=e.initialSlotConfig)!=null?l:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:d,debug:(m=e.debug)!=null?m:!1}},[w,e.apiKey,e.initialAssignments,s,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ne.jsx)(xe.Provider,{value:P,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,s,i;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(s=e.confidence)!=null?s:1};try{let f=document.documentElement;f.setAttribute("data-sentient-persona",e.persona),f.setAttribute("data-sentient-confidence",Ee((i=e.confidence)!=null?i:1))}catch(f){}}else delete t.__sentient_persona_override;x()}var re=require("react/jsx-runtime");function ke(e,t={},n){return ie(t),(0,oe.render)((0,re.jsx)(te,{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 te=Object.defineProperty,ne=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))re.call(t,n)&&F(e,n,t[n]);return e},B=(e,t)=>ne(e,ie(t));import{render as be}from"@testing-library/react";import{createContext as pe,useContext as $e,useEffect as v,useMemo as Q,useRef as W,useState as E,useSyncExternalStore as Ve}from"react";import{deriveSessionSegment as me,init as ve}from"@sentientui/core";var se=new Map,ae=new Map;function $(e,t){se.set(e,t);let n=ae.get(e);if(n)for(let r of n)try{r(t)}catch(s){}}var le={on:!1,listeners:new Set};function V(){if(typeof window=="undefined")return le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function P(){return V().on}function U(e){let t=V().listeners;return t.add(e),()=>{t.delete(e)}}function z(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,s)=>e.assign(t,n,r,s),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ce="sentient:overrides-changed";function C(){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(ce))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function x(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var de={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function A(){if(typeof window=="undefined")return de;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 ue(){A().version+=1;for(let e of A().listeners)e()}function O(e){x()&&(A().sections=[...e],ue())}var H="0.34.0",I=H!=="0.0.0-dev"?{name:"react",version:H}:void 0;function fe(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function D(e,t){fe()[e]=t}function ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function L(e,t){ge()[e]=t}var q="sentient_editor",X="sentient_preview_cell",T="sentient-cell-preview-bar",G="__preview__";function J(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(T))return;let t,n;try{let f=new URLSearchParams(window.location.search);t=f.get(q),n=f.get(X)}catch(f){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let s=n.slice(0,r),u=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(s)}&persona=${encodeURIComponent(u)}`,{headers:{authorization:`Bearer ${t}`}}).then(async f=>{if(!f.ok){R(f.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 f.json();if(l.blocks!=null)D(s,{kind:"arms",blocks:{[G]:l.blocks}}),L(s,G);else if(l.content!=null)D(s,{kind:"arms",content:l.content}),L(s,G);else{R("Nothing to preview in that square yet.");return}C(),R(`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="${s}"]`))==null||y.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>R("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function R(e){var s;if(document.getElementById(T))return;let t=document.createElement("div");t.id=T,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 r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.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"}),r.onclick=()=>{let u=new URL(window.location.href);u.searchParams.delete(q),u.searchParams.delete(X),window.location.assign(u.toString())},t.append(n,r),((s=document.body)!=null?s:document.documentElement).append(t)}import{jsx as we}from"react/jsx-runtime";function _e(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Y="https://api.sentient-ui.com/v1",ye=pe({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:Y,debug:!1});function Se(e){let[t,n]=E(!1),r=W(e);r.current=e;let{cookie:s,value:u,event:_}=e!=null?e:{},f=typeof(e==null?void 0:e.check)=="function";return v(()=>{let l=()=>{var w;let c=r.current;if(!c)return!1;if(c.check)return c.check()===!0;if(!c.cookie||typeof document=="undefined")return!1;let h=`${c.cookie}=${(w=c.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===h)};if(n(l()),!_)return;let y=()=>{n(l())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[s,u,_,f]),t}function Z(e){var M,K;let[t,n]=E(null),[r]=E(()=>{var i;return(i=e.sessionSegment)!=null?i:_e()}),[s,u]=E(P());v(()=>U(()=>u(P())),[]),v(()=>{J(e.apiBaseUrl)},[]);let _=Se(e.consentFrom),f=e.consentFrom?e.consent===!0||_:e.consent,l=W(null);v(()=>{var S;if(f===!1&&!e.preConsentBehavior){(S=l.current)==null||S.destroy(),l.current=null,n(null);return}let i=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:f,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},I?{sdk:I}:{}),d=!1,o=null,a=null,g=p=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{d||(a=b(p,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:p})=>{d||(o=p(B(m({},i),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),l.current=o,n(o),g(o))}):(o=ve(i),l.current=o,n(o),g(o)),()=>{d=!0,a==null||a(),o==null||o.dispose()}},[f]),v(()=>{if(!t)return;let i=!1,d=async()=>{if(i)return;let a;try{a=await t.fetchWeights()}catch(g){return}if(!i)for(let g of a){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(p=>{var b;return{variantId:p.variantId,pulls:p.pulls,avgReward:(b=p.avgReward)!=null?b:0}})};$(g.componentId,S)}};d();let o=setInterval(()=>{d()},6e4);return()=>{i=!0,clearInterval(o)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",c=((K=e.apiBaseUrl)!=null?K:Y).replace(/\/$/,""),h=W(null);v(()=>{var o;if(typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:c},d=h.current;if(h.current=i,d!==null)for(let a of["apiKey","context","country","persona","apiBaseUrl"])Object.is(d[a],i[a])||console.warn(`[sentient] AdaptiveProvider: \`${a}\` 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,c]),v(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:c,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,c]),v(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){O(i);return}e.declaredSections&&e.declaredSections.length>0&&O(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),v(()=>{if(!x())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let d=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),a=>a.getAttribute("data-sentient-id"))),o=i.filter(a=>!d.has(a));o.length>0&&console.warn(`[SentientUI] Declared section${o.length>1?"s":""} ${o.map(a=>`"${a}"`).join(", ")} ${o.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 w=Q(()=>t&&s?z(t):t,[t,s]),k=Q(()=>{var i,d,o,a,g,S,p;return{client:w,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(d=e.initialLayoutOrder)!=null?d:null,initialSlots:(o=e.initialSlots)!=null?o:{},initialSlotConfig:(a=e.initialSlotConfig)!=null?a:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:c,debug:(p=e.debug)!=null?p:!1}},[w,e.apiKey,e.initialAssignments,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,c,e.debug]);return we(ye.Provider,{value:k,children:e.children})}function he(e){return e<.3?"low":e<.7?"medium":"high"}function ee(e={}){var n,r,s;let t=window;if(t.__sentient_overrides=m({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=m({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=m({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",he((s=e.confidence)!=null?s:1))}catch(u){}}else delete t.__sentient_persona_override;C()}import{jsx as Ce}from"react/jsx-runtime";function at(e,t={},n){return ee(t),be(Ce(Z,{apiKey:"pk_test",consent:!1,children:e}),n)}export{at as renderWithSentient};
2
+ var te=Object.defineProperty,ne=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&F(e,n,t[n]);if(N)for(var n of N(t))re.call(t,n)&&F(e,n,t[n]);return e},B=(e,t)=>ne(e,ie(t));import{render as be}from"@testing-library/react";import{createContext as pe,useContext as $e,useEffect as v,useMemo as Q,useRef as W,useState as E,useSyncExternalStore as Ve}from"react";import{deriveSessionSegment as me,init as ve}from"@sentientui/core";var se=new Map,ae=new Map;function $(e,t){se.set(e,t);let n=ae.get(e);if(n)for(let r of n)try{r(t)}catch(s){}}var le={on:!1,listeners:new Set};function V(){if(typeof window=="undefined")return le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function P(){return V().on}function U(e){let t=V().listeners;return t.add(e),()=>{t.delete(e)}}function z(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,s)=>e.assign(t,n,r,s),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(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ce="sentient:overrides-changed";function C(){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(ce))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function x(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var de={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function A(){if(typeof window=="undefined")return de;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 ue(){A().version+=1;for(let e of A().listeners)e()}function O(e){x()&&(A().sections=[...e],ue())}var H="0.34.1",I=H!=="0.0.0-dev"?{name:"react",version:H}:void 0;function fe(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function D(e,t){fe()[e]=t}function ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function L(e,t){ge()[e]=t}var q="sentient_editor",X="sentient_preview_cell",T="sentient-cell-preview-bar",G="__preview__";function J(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(T))return;let t,n;try{let f=new URLSearchParams(window.location.search);t=f.get(q),n=f.get(X)}catch(f){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let s=n.slice(0,r),u=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(s)}&persona=${encodeURIComponent(u)}`,{headers:{authorization:`Bearer ${t}`}}).then(async f=>{if(!f.ok){R(f.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 f.json();if(l.blocks!=null)D(s,{kind:"arms",blocks:{[G]:l.blocks}}),L(s,G);else if(l.content!=null)D(s,{kind:"arms",content:l.content}),L(s,G);else{R("Nothing to preview in that square yet.");return}C(),R(`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="${s}"]`))==null||y.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>R("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function R(e){var s;if(document.getElementById(T))return;let t=document.createElement("div");t.id=T,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 r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.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"}),r.onclick=()=>{let u=new URL(window.location.href);u.searchParams.delete(q),u.searchParams.delete(X),window.location.assign(u.toString())},t.append(n,r),((s=document.body)!=null?s:document.documentElement).append(t)}import{jsx as we}from"react/jsx-runtime";function _e(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Y="https://api.sentient-ui.com/v1",ye=pe({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:Y,debug:!1});function Se(e){let[t,n]=E(!1),r=W(e);r.current=e;let{cookie:s,value:u,event:_}=e!=null?e:{},f=typeof(e==null?void 0:e.check)=="function";return v(()=>{let l=()=>{var w;let c=r.current;if(!c)return!1;if(c.check)return c.check()===!0;if(!c.cookie||typeof document=="undefined")return!1;let h=`${c.cookie}=${(w=c.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===h)};if(n(l()),!_)return;let y=()=>{n(l())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[s,u,_,f]),t}function Z(e){var M,K;let[t,n]=E(null),[r]=E(()=>{var i;return(i=e.sessionSegment)!=null?i:_e()}),[s,u]=E(P());v(()=>U(()=>u(P())),[]),v(()=>{J(e.apiBaseUrl)},[]);let _=Se(e.consentFrom),f=e.consentFrom?e.consent===!0||_:e.consent,l=W(null);v(()=>{var S;if(f===!1&&!e.preConsentBehavior){(S=l.current)==null||S.destroy(),l.current=null,n(null);return}let i=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:f,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,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},I?{sdk:I}:{}),d=!1,o=null,a=null,g=p=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{d||(a=b(p,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:p})=>{d||(o=p(B(m({},i),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),l.current=o,n(o),g(o))}):(o=ve(i),l.current=o,n(o),g(o)),()=>{d=!0,a==null||a(),o==null||o.dispose()}},[f]),v(()=>{if(!t)return;let i=!1,d=async()=>{if(i)return;let a;try{a=await t.fetchWeights()}catch(g){return}if(!i)for(let g of a){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(p=>{var b;return{variantId:p.variantId,pulls:p.pulls,avgReward:(b=p.avgReward)!=null?b:0}})};$(g.componentId,S)}};d();let o=setInterval(()=>{d()},6e4);return()=>{i=!0,clearInterval(o)}},[t]);let y=(M=e.ssrFallback)!=null?M:"first",c=((K=e.apiBaseUrl)!=null?K:Y).replace(/\/$/,""),h=W(null);v(()=>{var o;if(typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:c},d=h.current;if(h.current=i,d!==null)for(let a of["apiKey","context","country","persona","apiBaseUrl"])Object.is(d[a],i[a])||console.warn(`[sentient] AdaptiveProvider: \`${a}\` 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,c]),v(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:c,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,c]),v(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){O(i);return}e.declaredSections&&e.declaredSections.length>0&&O(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),v(()=>{if(!x())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let d=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),a=>a.getAttribute("data-sentient-id"))),o=i.filter(a=>!d.has(a));o.length>0&&console.warn(`[SentientUI] Declared section${o.length>1?"s":""} ${o.map(a=>`"${a}"`).join(", ")} ${o.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 w=Q(()=>t&&s?z(t):t,[t,s]),k=Q(()=>{var i,d,o,a,g,S,p;return{client:w,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(d=e.initialLayoutOrder)!=null?d:null,initialSlots:(o=e.initialSlots)!=null?o:{},initialSlotConfig:(a=e.initialSlotConfig)!=null?a:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:c,debug:(p=e.debug)!=null?p:!1}},[w,e.apiKey,e.initialAssignments,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,c,e.debug]);return we(ye.Provider,{value:k,children:e.children})}function he(e){return e<.3?"low":e<.7?"medium":"high"}function ee(e={}){var n,r,s;let t=window;if(t.__sentient_overrides=m({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=m({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=m({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",he((s=e.confidence)!=null?s:1))}catch(u){}}else delete t.__sentient_persona_override;C()}import{jsx as Ce}from"react/jsx-runtime";function at(e,t={},n){return ee(t),be(Ce(Z,{apiKey:"pk_test",consent:!1,children:e}),n)}export{at 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.34.0",
3
+ "version": "0.34.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "sideEffects": false,