@sentientui/react 0.36.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- "use strict";var tr=Object.create;var Ae=Object.defineProperty,nr=Object.defineProperties,rr=Object.getOwnPropertyDescriptor,ir=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertyNames,Le=Object.getOwnPropertySymbols,sr=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable;var wt=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Qe.call(t,n)&&wt(e,n,t[n]);if(Le)for(var n of Le(t))kt.call(t,n)&&wt(e,n,t[n]);return e},N=(e,t)=>nr(e,ir(t));var De=(e,t)=>{var n={};for(var r in e)Qe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Le)for(var r of Le(e))t.indexOf(r)<0&&kt.call(e,r)&&(n[r]=e[r]);return n};var ar=(e,t)=>{for(var n in t)Ae(e,n,{get:t[n],enumerable:!0})},Rt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of or(t))!Qe.call(e,i)&&i!==n&&Ae(e,i,{get:()=>t[i],enumerable:!(r=rr(t,i))||r.enumerable});return e};var Ne=(e,t,n)=>(n=e!=null?tr(sr(e)):{},Rt(t||!e||!e.__esModule?Ae(n,"default",{value:e,enumerable:!0}):n,e)),lr=e=>Rt(Ae({},"__esModule",{value:!0}),e);var Lr={};ar(Lr,{Adaptive:()=>On,AdaptiveGroup:()=>Kn,AdaptiveProvider:()=>Zt,AdaptiveSlot:()=>Pe,AdaptiveText:()=>En,SentientPersonaScript:()=>Nn,buildAgentFeed:()=>Xn,consentWatcher:()=>Yn.consentWatcher,defineAgentContent:()=>Hn,detectSegment:()=>yt.deriveSessionSegment,getAgentContent:()=>vt,grantConsent:()=>Zn.grantConsent,renderAgentJsonLd:()=>zn,renderAgentJsonLdBody:()=>St,renderAgentMarkdown:()=>qn,renderBlocks:()=>ge,renderCompose:()=>Je,useAdaptive:()=>Wn,useAdaptiveApiBaseUrl:()=>sn,useAdaptiveGoal:()=>qe,useAdaptivePersona:()=>Fn,useAdaptiveTokens:()=>Bn,useAssignment:()=>We,useInitialAssignments:()=>Fe,useLayoutOrder:()=>en,usePageGoal:()=>Gn,useSentient:()=>I});module.exports=lr(Lr);var A=require("react"),Ve=require("@sentientui/core");var Ct=new Map,Ie=new Map;function At(e,t){let n=Ie.get(e);return n||(n=new Set,Ie.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ie.delete(e)}}function _t(e,t){Ct.set(e,t);let n=Ie.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function et(e){var t;return(t=Ct.get(e))!=null?t:null}var ur={on:!1,listeners:new Set};function Ot(){if(typeof window=="undefined")return ur;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function tt(){return Ot().on}function Et(e){let t=Ot().listeners;return t.add(e),()=>{t.delete(e)}}function Pt(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(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var nt="sentient:overrides-changed";function Gt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function rt(){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(nt))}function J(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(nt,e),()=>window.removeEventListener(nt,e))}function Tt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function T(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function U(e){return typeof e=="string"?{type:"click"}:e}function se(e){return typeof e=="string"?e:e.type}function ee(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var it=new Set,ot=!1;function Lt(e){if(it.has(e))return!0;if(it.add(e),!ot){ot=!0;let t=()=>{ot=!1,it.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 cr(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Dt(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(cr(r))return!0;r=r.parentElement}return!1}function te(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,v=[];return t.steps.forEach(({goal:f,name:h,weight:R},d)=>{let u=(m=!1)=>{s.has(d)||m&&r!==void 0&&Lt(`step\0${h}\0${R}\0${d}`)||(s.add(d),n.fireStep(h,R,d))};if(f.type==="click"){let m=g=>{let l=g.target;l instanceof Element&&Dt(l,e,f.selector)&&u()};e.addEventListener("click",m),v.push(()=>e.removeEventListener("click",m));return}if(f.type==="form_submit"){let m=g=>{g.target instanceof HTMLFormElement&&e.contains(g.target)&&u()};e.addEventListener("submit",m),v.push(()=>e.removeEventListener("submit",m));return}if(f.type==="scroll_depth"){let m=Math.max(0,Math.min(1,f.threshold)),g=new IntersectionObserver(l=>{for(let S of l)if(S.intersectionRatio>=m){u(!0),g.disconnect();break}},{threshold:[m]});g.observe(e),v.push(()=>g.disconnect())}}),()=>{for(let f of v)f()}}let i=t.type==="composite"?t.all:[t],a=new Set(i.map((s,v)=>v)),c=()=>{r!==void 0&&Lt(r)||n.fireGoal()},o=(s,v=!1)=>{a.delete(s),a.size===0&&(v?c():n.fireGoal())},p=[];return i.forEach((s,v)=>{if(s.type==="click"){let f=h=>{let R=h.target;R instanceof Element&&Dt(R,e,s.selector)&&(t.type==="composite"?o(v):n.fireGoal())};e.addEventListener("click",f),p.push(()=>e.removeEventListener("click",f));return}if(s.type==="form_submit"){let f=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?o(v):n.fireGoal())};e.addEventListener("submit",f),p.push(()=>e.removeEventListener("submit",f));return}if(s.type==="scroll_depth"){let f=Math.max(0,Math.min(1,s.threshold)),h=new IntersectionObserver(R=>{for(let d of R)if(d.intersectionRatio>=f){t.type==="composite"?o(v,!0):c(),h.disconnect();break}},{threshold:[f]});h.observe(e),p.push(()=>h.disconnect());return}}),()=>{for(let s of p)s()}}var Nt=new Set,It=new Set;function ye(e,t,n,r,i){let a=`${r}|${n}`;if(It.has(a))return;It.add(a);let c=i.type==="weighted_composite"&&!Nt.has(r);c&&Nt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:c?{funnelId:r,steps:i.steps.map(o=>({goalId:o.name,weight:o.weight}))}:{funnelId:r}})}function ae(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var dr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function de(){if(typeof window=="undefined")return dr;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 _e(){de().version+=1;for(let e of de().listeners)e()}var Vt=()=>{};function Ft(e){return T()?(de().components.set(e.id,e),_e(),()=>{de().components.delete(e.id),_e()}):Vt}function ve(e){return T()?(de().slots.set(e.id,e),_e(),()=>{de().slots.delete(e.id),_e()}):Vt}function st(e){T()&&(de().sections=[...e],_e())}var Mt="0.36.1",at=Mt!=="0.0.0-dev"?{name:"react",version:Mt}:void 0;function fr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Se(e,t){fr()[e]=t}function $t(e){window.__sentient_vocabulary_override=e}function Bt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function gr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function he(e,t){gr()[e]=t}var jt="sentient_editor",Wt="sentient_preview_cell",Kt="sentient_refresh_region",lt="sentient-cell-preview-bar",fe="__preview__",be=null;function Jt(e){if((be==null?void 0:be.slotId)!==e)return null;let t=be;return be=null,t}function Ut(e,t){fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${e.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))}).then(n=>xe(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>xe("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Ht(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(lt))return;let t,n,r;try{let p=new URLSearchParams(window.location.search);t=p.get(jt),n=p.get(Wt),r=p.get(Kt)}catch(p){return}if(t&&r){be={slotId:r,token:t,base:(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"")},Se(r,{kind:"arms"}),he(r,fe),rt();return}if(!t||!n)return;let i=n.lastIndexOf("~");if(i<=0)return;let a=n.slice(0,i),c=n.slice(i+1),o=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${o}/editor/cell-preview?slotId=${encodeURIComponent(a)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${t}`}}).then(async p=>{if(!p.ok){xe(p.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await p.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&$t(s.vocabulary),s.compose!=null)Se(a,{kind:"arms",compose:{[fe]:s.compose}}),he(a,fe);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Se(a,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),he(a,fe);else if(s.blocks!=null)Se(a,{kind:"arms",blocks:{[fe]:s.blocks}}),he(a,fe);else if(s.content!=null)Se(a,{kind:"arms",content:s.content}),he(a,fe);else{xe("Nothing to preview in that square yet.");return}rt(),xe(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var v;try{(v=document.querySelector(`[data-sentient-slot="${a}"]`))==null||v.scrollIntoView({block:"center"})}catch(f){}},300)}).catch(()=>xe("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function xe(e){var i;if(document.getElementById(lt))return;let t=document.createElement("div");t.id=lt,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 a=new URL(window.location.href);a.searchParams.delete(jt),a.searchParams.delete(Wt),a.searchParams.delete(Kt),window.location.assign(a.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var mr="sentient_editor",Xt=!1;function zt(e){if(Xt||typeof window=="undefined")return;let t=null;try{t=new URLSearchParams(window.location.search).get(mr)}catch(i){return}if(!t)return;Xt=!0;let n=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),r=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${n}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?r():window.addEventListener("load",r,{once:!0})}var an=require("react/jsx-runtime");function pr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Ve.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var qt="https://api.sentient-ui.com/v1",B=(0,A.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:qt,debug:!1});function yr(e){let[t,n]=(0,A.useState)(null),r=(0,A.useRef)(e);r.current=e;let i=e===void 0?"":typeof e=="string"?e:JSON.stringify(N(y({},e),{check:typeof e.check}));return(0,A.useEffect)(()=>{let a=r.current;if(a===void 0||typeof window=="undefined")return;let c,o=!1;return import("@sentientui/core/consent").then(({consentWatcher:p})=>{if(o)return;let s=p(typeof a=="object"&&a.cmp===void 0&&a.check?N(y({},a),{check:()=>r.current.check()}):a);n(s.read()),c=s.subscribe(()=>n(s.read()))}),()=>{o=!0,c==null||c()}},[i]),t}function Zt(e){var d,u;let[t,n]=(0,A.useState)(null),[r]=(0,A.useState)(()=>{var m;return(m=e.sessionSegment)!=null?m:pr()}),[i,a]=(0,A.useState)(tt());(0,A.useEffect)(()=>Et(()=>a(tt())),[]),(0,A.useEffect)(()=>{Ht(e.apiBaseUrl),zt(e.apiBaseUrl)},[]);let c=yr(e.consentFrom),o=e.consentFrom?c!=null?c:e.consent===!0:e.consent,p=(0,A.useRef)(null);(0,A.useEffect)(()=>{var C;if(o===!1&&!e.preConsentBehavior){(C=p.current)==null||C.destroy(),p.current=null,n(null);return}let m=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:o,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},at?{sdk:at}:{}),g=!1,l=null,S=null,x=E=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{g||(S=b(E,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:E})=>{g||(l=E(N(y({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),p.current=l,n(l),x(l))}):(l=(0,Ve.init)(m),p.current=l,n(l),x(l)),()=>{g=!0,S==null||S(),l==null||l.dispose()}},[o]),(0,A.useEffect)(()=>{if(!t)return;let m=!1,g=async()=>{if(m)return;let S;try{S=await t.fetchWeights()}catch(x){return}if(!m)for(let x of S){let C={componentId:x.componentId,updatedAt:x.updatedAt,variants:x.variants.map(E=>{var b;return{variantId:E.variantId,pulls:E.pulls,avgReward:(b=E.avgReward)!=null?b:0}})};_t(x.componentId,C)}};g();let l=setInterval(()=>{g()},6e4);return()=>{m=!0,clearInterval(l)}},[t]);let s=(d=e.ssrFallback)!=null?d:"first",v=((u=e.apiBaseUrl)!=null?u:qt).replace(/\/$/,""),f=(0,A.useRef)(null);(0,A.useEffect)(()=>{var l;if(typeof process!="undefined"&&((l=process.env)==null?void 0:l.NODE_ENV)==="production")return;let m={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:v},g=f.current;if(f.current=m,g!==null)for(let S of["apiKey","context","country","persona","apiBaseUrl"])Object.is(g[S],m[S])||console.warn(`[sentient] AdaptiveProvider: \`${S}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,v]),(0,A.useEffect)(()=>{var m;typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production"||Tt({apiKey:e.apiKey,apiBaseUrl:v,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,v]),(0,A.useEffect)(()=>{let m=e.initialLayoutOrder;if(m&&m.length>0){st(m);return}e.declaredSections&&e.declaredSections.length>0&&st(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,A.useEffect)(()=>{if(!T())return;let m=e.declaredSections;if(!m||m.length===0||typeof document=="undefined")return;let g=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),S=>S.getAttribute("data-sentient-id"))),l=m.filter(S=>!g.has(S));l.length>0&&console.warn(`[SentientUI] Declared section${l.length>1?"s":""} ${l.map(S=>`"${S}"`).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 h=(0,A.useMemo)(()=>t&&i?Pt(t):t,[t,i]),R=(0,A.useMemo)(()=>{var m,g,l,S,x,C,E,b;return{client:h,apiKey:e.apiKey,initialAssignments:(m=e.initialAssignments)!=null?m:{},sessionSegment:r,ssrFallback:s,onAssignment:e.onAssignment,initialLayoutOrder:(g=e.initialLayoutOrder)!=null?g:null,initialSlots:(l=e.initialSlots)!=null?l:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(x=e.initialPalette)!=null?x:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(E=e.initialPersona)!=null?E:null,apiBaseUrl:v,debug:(b=e.debug)!=null?b:!1}},[h,e.apiKey,e.initialAssignments,r,s,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,v,e.debug]);return(0,an.jsx)(B.Provider,{value:R,children:e.children})}function I(){return(0,A.useContext)(B).client}function ne(){return(0,A.useContext)(B).apiKey}function Fe(){return(0,A.useContext)(B).initialAssignments}function Me(){return(0,A.useContext)(B).sessionSegment}function Yt(){return(0,A.useContext)(B).ssrFallback}function $e(){return(0,A.useContext)(B).onAssignment}function Qt(){return(0,A.useContext)(B).debug}function en(){let e=(0,A.useContext)(B).initialLayoutOrder,t=(0,A.useSyncExternalStore)(J,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Be(){return(0,A.useContext)(B).initialSlots}function tn(){return(0,A.useContext)(B).initialPersona}function nn(){return(0,A.useContext)(B).initialSlotConfig}function rn(){return(0,A.useContext)(B).initialPalette}function on(){return(0,A.useContext)(B).initialVocabulary}function sn(){return(0,A.useContext)(B).apiBaseUrl}var ke=require("react");var V=require("react"),ln=require("@sentientui/core");var H=require("react"),je=require("@sentientui/policy");function we(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 a=i.indexOf(":");if(a!==-1&&i.slice(0,a)===e)return i.slice(a+1)}}catch(r){}return null}function We(e,t,n,r){let i=Fe(),a=Yt(),c=I(),o=Me(),p=$e(),s=Qt(),v=(0,H.useRef)(null),f=(0,H.useSyncExternalStore)(J,()=>we(e),()=>null),h=f&&t.includes(f)?f:null,R=(0,H.useRef)(null);(0,H.useEffect)(()=>{s&&h&&R.current!==h&&(R.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[s,h,e]);let[d,u]=(0,H.useState)(()=>{var S,x;if(h)return{variantId:h,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}:a==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let g=c.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content))return{variantId:g.variantId,content:(S=g.content)!=null?S:null,isLoading:!1,settled:!0};let l=et(e);if(l){let C=(0,je.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}}),m=g=>{p&&v.current!==g&&(v.current=g,p(e,g))};return(0,H.useEffect)(()=>{var S;if(h||!c)return;let g=c.getAssignment(e,o);if(g&&(t.includes(g.variantId)||g.content)){u({variantId:g.variantId,content:(S=g.content)!=null?S:null,isLoading:!1,settled:!0}),m(g.variantId);return}let l=et(e);if(l&&d.settled&&d.variantId&&d.variantId===(0,je.pickFromWeights)(l.variants,t)){m(d.variantId);return}u(x=>{var C;return x.variantId?x:{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}})},[h,c,e,o]),(0,H.useEffect)(()=>{if(h||!c)return;let g=c.getAssignment(e,o);if(g&&t.includes(g.variantId))return;let l=!1;return c.assign(e,t,n,r).then(S=>{var x;l||S&&(!t.includes(S.variantId)&&!S.content||(u({variantId:S.variantId,content:(x=S.content)!=null?x:null,isLoading:!1,settled:!0}),m(S.variantId)))}),()=>{l=!0}},[h,c,e,o]),(0,H.useEffect)(()=>{if(!h&&c)return At(e,g=>{var x;let l=c.getAssignment(e,o);if(l&&(t.includes(l.variantId)||l.content)){u({variantId:l.variantId,content:(x=l.content)!=null?x:null,isLoading:!1,settled:!0}),m(l.variantId);return}let S=(0,je.pickFromWeights)(g.variants,t);S&&(u({variantId:S,content:null,isLoading:!1,settled:!0}),m(S))})},[h,c,e,o]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:d}function Ke(e,t,n){let r=I(),i=ne(),a=Object.keys(t).join("\0"),c=(0,V.useMemo)(()=>Object.keys(t),[a]),{variantId:o,content:p,isOverride:s=!1,settled:v}=We(e,c,n.agentData,n.agentDataByVariant),[f,h]=(0,V.useState)(null),R=(0,V.useRef)(null),d=(0,V.useCallback)(O=>{R.current=O,h(O)},[]),u=n.goal,m=typeof u=="string"?u:JSON.stringify(u),g=(0,V.useMemo)(()=>u?U(u):null,[m]),l=u?se(u):"";(0,V.useEffect)(()=>Ft({id:e,variantIds:c,goal:l}),[e,c,l]);let S=(0,V.useRef)(null);(0,V.useEffect)(()=>{s||v&&(!r||!o||!i||!f||S.current!==o&&(S.current=o,ae(r,i,e,o)))},[r,o,i,e,f,s,v]);let x=(0,V.useRef)(!1),C=(0,V.useRef)(new Set);(0,V.useEffect)(()=>{x.current=!1,C.current=new Set},[o,g]);let E=n.funnel;(0,V.useEffect)(()=>{s||!v||!r||!E||!g||ye(r,i,e,E,g)},[r,i,e,E,g,s,v]);let b=n.cursorSignal===!0;(0,V.useEffect)(()=>{if(!b||s||!v||!r||!o||!f)return;let O=null,P=0,M=()=>{P=Date.now(),O=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-P}}),O=null},800)},D=()=>{O!==null&&(clearTimeout(O),O=null)};return f.addEventListener("mouseenter",M),f.addEventListener("mouseleave",D),()=>{f.removeEventListener("mouseenter",M),f.removeEventListener("mouseleave",D),O!==null&&clearTimeout(O)}},[b,r,o,i,e,f,s,v]);let k=(0,V.useRef)(n.microSignalGoals);k.current=n.microSignalGoals;let w=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,V.useEffect)(()=>{if(s||!v||!r||!o||!f)return;let O=Date.now();return(0,ln.attachMicroSignalDetectors)((P,M={})=>{var oe,ue,Y;r.track({projectId:i,componentId:e,variantId:o,eventType:"micro_signal",payload:y({signalType:P},M)});let D=(oe=k.current)==null?void 0:oe[P];if(!D||C.current.has(P))return;C.current.add(P);let q=typeof D=="string"?D:D.name,Z=typeof D=="string"?1:(ue=D.weight)!=null?ue:1,ie=typeof D=="string"?0:(Y=D.stepIndex)!=null?Y:0;r.goal(q,{metadata:y({signalType:P},M),weight:Z,stepIndex:ie})},f,O)},[r,o,i,e,f,w,s,v]),(0,V.useEffect)(()=>{if(s||!v||!r||!o||!f||!g)return;let O=ee(g);return te(f,g,{fireGoal:()=>{x.current||(x.current=!0,r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:l,payload:y({reward:1},O!==void 0?{goalValue:O}:{})}),r.goal(l,y({metadata:{componentId:e,variantId:o},weight:1,stepIndex:0},O!==void 0?{value:O}:{})))},fireStep:(P,M,D)=>{r.track({projectId:i,componentId:e,variantId:o,eventType:"goal_achieved",goalType:P,payload:{reward:M}}),r.goal(P,{metadata:{},weight:M,stepIndex:D})}},l)},[r,o,i,e,f,g,l,s,v]),{client:r,variantIds:c,variantId:o,content:p,settled:v,isOverride:s,goalLabel:l,ref:d,nodeRef:R}}var F=require("react"),Ee=require("@sentientui/core"),pt=require("@sentientui/core/region");var W=require("react"),cn=require("@sentientui/core");var un=new Set;function dn(e,t){var x,C,E;let n=I(),r=(0,W.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,W.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let a=(0,W.useRef)(t==null?void 0:t.skeleton);a.current=t==null?void 0:t.skeleton;let c=Be(),o=nn(),p=rn(),s=on(),v=(0,W.useSyncExternalStore)(J,()=>{var b;return typeof window!="undefined"?(b=window.__sentient_slot_config_overrides)==null?void 0:b[e]:void 0},()=>{}),f=(0,W.useSyncExternalStore)(J,()=>{var b;return typeof window!="undefined"?(b=window.__sentient_slot_overrides)==null?void 0:b[e]:void 0},()=>{}),h=b=>b==null?"":(0,cn.armOfResult)(b),R=(0,W.useCallback)(b=>{var k,w;return(w=(k=n==null?void 0:n.onSlotsChanged)==null?void 0:k.call(n,b))!=null?w:(()=>{})},[n]);(0,W.useSyncExternalStore)(R,()=>{var b;return(b=n==null?void 0:n.getSlotConfig(e))!=null?b:null},()=>null),(0,W.useSyncExternalStore)(R,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let d=v===void 0?o[e]:void 0,u=v===void 0&&d===void 0&&n?n.getSlotConfig(e):null,m=(x=p!=null?p:n==null?void 0:n.getSitePalette())!=null?x:null,g=(E=s!=null?s:(C=n==null?void 0:n.getStyleVocabulary)==null?void 0:C.call(n))!=null?E:null,l=(()=>{var b,k,w;if(v!==void 0)return{config:v,arm:h(f),palette:m,vocabulary:(b=Bt())!=null?b:g,source:"override"};if(d!==void 0)return{config:d,arm:h((k=c[e])!=null?k:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:g,source:"preloaded"};if(u!==null){let O=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:u,arm:h((w=n==null?void 0:n.getSlotResult(e))!=null?w:c[e]),palette:m,vocabulary:g,source:O?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:g,source:"none"}})(),S=l.source==="preloaded"||l.source==="override";return(0,W.useEffect)(()=>{var q,Z,ie,oe,ue;if(!n||n.isLocal===!0||S)return;let b=l.source==="none",k=b&&(Z=(q=r.current)==null?void 0:q.call(r))!=null?Z:null,w=k!=null&&k!==""?{[e]:k}:void 0,O=(ie=i.current)==null?void 0:ie.call(i),P=b&&(ue=(oe=a.current)==null?void 0:oe.call(a))!=null?ue:null,M=y(y({},O?{render:{[e]:O}}:{}),P?{skeletons:{[e]:P}}:{}),D=Object.keys(M).length>0;return n.requestSlots?D?n.requestSlots([e],w,M):w?n.requestSlots([e],w):n.requestSlots([e]):b&&(P?n.reportSlots([e],w!=null?w:{},{[e]:P}):w?n.reportSlots([e],w):n.reportSlots([e])),()=>{var Y;return(Y=n.cancelSlots)==null?void 0:Y.call(n,[e])}},[n,S,l.source,e]),(0,W.useEffect)(()=>{!T()||(n==null?void 0:n.isLocal)!==!0||l.source!=="none"||un.has(e)||(un.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,l.source,e]),l}var Oe=require("react");var L=require("react/jsx-runtime"),le={none:"0",sm:"8px",md:"16px",lg:"24px"},ut={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},pn={sm:"0.875em",md:"1em",lg:"1.25em"},vr={sm:"1.25em",md:"1.5em",lg:"2em"},fn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},gn={sm:"8px",md:"16px",lg:"32px"},Sr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},hr={normal:"400",medium:"500",bold:"700"};function mn(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function yn(e,t,n){var i,a,c,o;let r=t==null?void 0:t.accent;return N(y({display:"inline-block",padding:(i=fn[n!=null?n:"md"])!=null?i:fn.md,borderRadius:(a=t==null?void 0:t.radius)!=null?a:"8px",font:"inherit"},n?{fontSize:pn[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"?(o=t==null?void 0:t.primaryText)!=null?o:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function br({node:e,opts:t}){var i,a,c,o,p;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(c=(a=t.palette)==null?void 0:a.border)!=null?c:"currentColor"}`,borderRadius:(p=(o=t.palette)==null?void 0:o.radius)!=null?p:"8px"};return(0,L.jsxs)("form",{onSubmit:s=>{var h,R,d;s.preventDefault();let v=new FormData(s.currentTarget),f={};for(let u of e.fields)f[u.name]=String((h=v.get(u.name))!=null?h:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(d=t.onFormSubmit)==null||d.call(t,f)}catch(u){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var v,f;return(0,L.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,L.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,L.jsx)("select",{name:s.name,required:s.required,style:r,children:((v=s.options)!=null?v:[]).map(h=>(0,L.jsx)("option",{value:h,children:h},h))}):(0,L.jsx)("input",{name:s.name,type:(f=s.inputType)!=null?f:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,L.jsx)("button",{type:"submit",style:yn(n,t.palette),children:e.submitLabel})]})}function xr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(a=>a.id===n))==null?void 0:i.classes:void 0}function vn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function ge(e,t){var i;let n=wr(e,t),r=vn(e.like,t);return n&&r?(0,Oe.cloneElement)(n,{style:N(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function wr(e,t){var n,r,i,a,c,o,p,s,v,f,h,R,d,u,m,g,l,S,x,C,E,b,k;try{let w=xr(e,t);switch(e.type){case"stack":{let O=(r=le[(n=e.gap)!=null?n:"md"])!=null?r:le.md,P=e.surface==="raised"&&!w,M=(i=e.pad)!=null?i:P?"md":void 0;return(0,L.jsx)("div",N(y({},w?{className:w}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:O},e.align?{alignItems:ut[e.align]}:{}),e.justify?{justifyContent:ut[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),M?{padding:(a=le[M])!=null?a:le.md}:{}),P?N(y(y({},(c=t.palette)!=null&&c.surface?{background:t.palette.surface}:{}),(o=t.palette)!=null&&o.surface&&((p=t.palette)!=null&&p.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(v=(s=t.palette)==null?void 0:s.border)!=null?v:"currentColor"}`,borderRadius:(h=(f=t.palette)==null?void 0:f.radius)!=null?h:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((D,q)=>{let Z=ge(D,t);return Z===null?null:(0,L.jsx)(Oe.Fragment,{children:Z},q)})}))}case"grid":{let O=(u=le[(d=e.gap)!=null?d:"md"])!=null?u:le.md;return(0,L.jsx)("div",N(y({},w?{className:w}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${O}) / ${e.columns})), 1fr))`,gap:O},e.align?{alignItems:ut[e.align]}:{}),e.pad?{padding:(m=le[e.pad])!=null?m:le.md}:{}),children:((g=e.children)!=null?g:[]).map((P,M)=>{let D=ge(P,t);return D===null?null:(0,L.jsx)(Oe.Fragment,{children:D},M)})}))}case"text":return w?(0,L.jsx)("p",{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:pn[e.size]}:{}),e.weight?{fontWeight:hr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),mn(e.tone,t.palette)),children:e.value});case"heading":{let O=`h${e.level}`;return w?(0,L.jsx)(O,{className:w,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)(O,{style:y(y({margin:0,fontSize:vr[(l=e.size)!=null?l:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let O=(S=e.emphasis)!=null?S:"primary";return(0,L.jsx)("a",N(y(y({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),w?{className:w}:{style:yn(O,t.palette,e.size)}),{children:e.label}))}case"link":return(0,L.jsx)("a",N(y(y({href:e.href},e.tag?{"data-sentient-tag":e.tag}:{}),w?{className:w}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,L.jsx)("img",N(y({src:e.src,alt:e.alt},w?{className:w}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Sr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return w?(0,L.jsx)("span",{className:w,children:e.value}):(0,L.jsx)("span",{style:y({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"}`},mn(e.tone,t.palette)),children:e.value});case"spacer":return(0,L.jsx)("div",{style:{height:(E=gn[e.size])!=null?E:gn.md}});case"divider":return(0,L.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,L.jsx)(br,{node:e,opts:t});default:return null}}catch(w){return null}}function Je(e,t){var a,c,o,p;let n=ge(e.tree,t);if(n===null)return null;let r=(a=e.surface)!=null&&a.like?(o=(c=t.vocabulary)==null?void 0:c.entries.find(s=>s.id===e.surface.like))==null?void 0:o.classes:void 0,i=vn((p=e.surface)==null?void 0:p.like,t);return r?(0,L.jsx)("div",N(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}var re=require("react"),Ue=require("@sentientui/core/region");function He(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Xe(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function me(e){return He(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+me(n),0):(0,re.isValidElement)(e)?me(Xe(e)):0}function kr(e,t){return Array.isArray(t)?(0,re.cloneElement)(e,void 0,...t):(0,re.cloneElement)(e,void 0,t)}function ct(e,t){if(He(e))return t;if(Array.isArray(e))return e.map(n=>ct(n,t));if((0,re.isValidElement)(e)){let n=Xe(e);return me(n)===0?e:kr(e,ct(n,t))}return e}function Sn(e,t){return me(e)===1?ct(e,t):null}var K=e=>e.join("/");function dt(e,t,n){if(He(e)){n.leafPaths.push(t),n.texts.push((0,Ue.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>dt(r,[...t,i],n));return}(0,re.isValidElement)(e)&&(n.elements.set(K(t),e),dt(Xe(e),[...t,"c"],n))}function gt(e){let t={leafPaths:[],texts:[],elements:new Map};return dt(e,[],t),t}function Rr(e){return gt(e).texts}function hn(e){let t=Rr(e);return t.length===0?null:(0,Ue.skeletonFingerprint)(t)}function Cr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function bn(e,t){let n=t.reduce((i,a)=>Math.max(i,a+1),0),r=[];for(let i=0;i<n;i++){let a=t.flatMap((o,p)=>o===i?[Cr(e.leafPaths[p])]:[]);if(a.length===0){r.push(null);continue}let c=a[0];for(let o of a.slice(1)){let p=new Set(o.map(K));c=c.filter(s=>p.has(K(s)))}r.push(c.length>0?c[c.length-1]:null)}return r}function ft(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function mt(e,t){let n=gt(t);if(n.texts.length!==e.leaves.length||n.texts.some((a,c)=>a!==e.leaves[c]))return null;let r=bn(n,e.leafToNode),i=e.nodes.map((a,c)=>{let o=r[c],p=o?n.elements.get(K(o)):void 0,s=!!p&&(typeof p.type=="string"||ft(p)!==void 0);return N(y({},a),{restylable:s})});return N(y({},e),{nodes:i})}function xn(e,t,n){var d;let r=gt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((u,m)=>Math.max(u,m+1),0);for(let u of Object.keys(t.nodes))if(!/^\d+$/.test(u)||Number(u)>=i)return null;let a=bn(r,n),c=new Map;n.forEach((u,m)=>{c.has(u)||c.set(u,m)});let o=new Map(r.leafPaths.map((u,m)=>[K(u),m])),p=new Set,s=new Map,v=!1;for(let[u,m]of Object.entries(t.nodes)){let g=Number(u),l=a[g];if(m.hidden&&(l?p.add(K(l)):v=!0),m.like!==void 0){let S=a[m.like],x=l?r.elements.get(K(l)):void 0,C=S?ft(r.elements.get(K(S))):void 0;!l||C===void 0||ft(x)===void 0?v=!0:s.set(K(l),C)}}let f=new Map(Object.entries((d=t.order)!=null?d:{})),h=(u,m)=>{var g;if(He(u)){let l=o.get(K(m));if(l===void 0)return u;let S=n[l],x=(g=t.nodes[String(S)])==null?void 0:g.text;return x===void 0?u:c.get(S)===l?x:""}if(Array.isArray(u)){let l=u.map((S,x)=>h(S,[...m,x]));for(let[S,x]of f){let C=x.map(k=>{let w=a[k];return!w||w.length!==m.length+1||K(w.slice(0,-1))!==K(m)?-1:w[w.length-1]});if(C.some(k=>k<0))continue;let E=[...C].sort((k,w)=>k-w),b=[...l];E.forEach((k,w)=>{l[k]=b[C[w]]}),f.delete(S)}return l}if((0,re.isValidElement)(u)){let l=K(m);if(p.has(l))return null;let S=Xe(u);if(me(S)===0)return u;let x=h(S,[...m,"c"]),C=s.get(l),E=C!==void 0?{className:C}:void 0;return Array.isArray(x)?(0,re.cloneElement)(u,E,...x):(0,re.cloneElement)(u,E,x)}return u},R=h(e,[]);return v||f.size>0?null:R}var An=require("react/jsx-runtime"),wn=new Set,kn=new Set,Rn=new Set,Cn="authored.";function Pe({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:a,reportBaselineText:c=!0}){var ht,bt;let o=I(),p=ne(),s=(0,F.useRef)(null),v=(0,F.useMemo)(()=>hn(t),[t]),f=n?Object.keys(n).join("|"):"",h=(0,F.useMemo)(()=>y({fp:v!=null?v:"0000000000000000",forms:!!r,compose:!0,content:me(t)===1},f!==""?{authored:f.split("|"),children:!0}:{}),[v,t,r,f]),R=()=>{var Q;let _=s.current;if(!_||!c)return null;let G=(0,pt.captureRegionSkeleton)(_);return G.skeleton?(Q=mt(G.skeleton,t))!=null?Q:N(y({},G.skeleton),{editable:!1,nodes:G.skeleton.nodes.map(ce=>N(y({},ce),{restylable:!1}))}):{status:G.reason}},{config:d,arm:u,palette:m,vocabulary:g,source:l}=dn(e,{baselineText:c?()=>{var _,G;return(G=(_=s.current)==null?void 0:_.textContent)!=null?G:null}:void 0,render:()=>h,skeleton:R}),S=u!==""?(ht=d==null?void 0:d.blocks)==null?void 0:ht[u]:void 0,x=u!==""?(bt=d==null?void 0:d.compose)==null?void 0:bt[u]:void 0,C=(S!==void 0&&(0,Ee.containsFormBlock)(S)||x!==void 0&&(0,Ee.containsFormBlock)(x.tree))&&!r;(0,F.useEffect)(()=>{!C||!T()||wn.has(e)||(wn.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.`))},[C,e]);let E=_=>{!o||l==="override"||(l!=="seeded"&&o.componentGoal(e,_),o.goal(_,{metadata:{componentId:e,arm:u},weight:1,stepIndex:0}))},b=t,k=!1,w=u.startsWith(Cn)?u.slice(Cn.length):null;if((d==null?void 0:d.blocked)==="variant_history")k=!0;else if(w!==null)n&&Object.prototype.hasOwnProperty.call(n,w)?b=n[w]:k=!0;else if(x!==void 0){let _=C?null:Je(x,{palette:m,vocabulary:g,onFormSubmit:r,onFormGoal:E});_===null?k=!0:b=_}else if(S!==void 0){let _=C?null:ge(S,{palette:m,vocabulary:g,onFormSubmit:r,onFormGoal:E});_===null?k=!0:b=_}else if((d==null?void 0:d.edits)!==void 0&&l!=="none"){let _=d.edits,G=_.fp===v?xn(t,_.edits,_.leafToNode):null;G===null?k=!0:b=G}else if((d==null?void 0:d.content)!==void 0&&l!=="none"){let _=Sn(t,d.content);_===null?k=!0:b=_}let O=k&&S===void 0&&x===void 0&&(d==null?void 0:d.edits)===void 0&&w===null&&(d==null?void 0:d.blocked)===void 0;(0,F.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!T()||Rn.has(e)||(Rn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let P=w!==null&&!k?w:null;(0,F.useEffect)(()=>{var Ce;if(!P||!c||!o)return;let _=s.current;if(!_)return;let G=(0,pt.captureRegionSkeleton)(_),Q=G.skeleton?mt(G.skeleton,n==null?void 0:n[P]):null,ce=(Ce=_.textContent)==null?void 0:Ce.trim();o.reportSlots([],void 0,void 0,{[e]:[y(y({key:P},ce?{text:ce}:{}),Q?{skeleton:Q}:{})]})},[P,o,e]);let M=k&&(d==null?void 0:d.edits)!==void 0&&(l==="preloaded"||l==="client");(0,F.useEffect)(()=>{var _;!M||!(d!=null&&d.edits)||(_=o==null?void 0:o.reportDrift)==null||_.call(o,e,d.edits.fp,v,d.edits.fp===v?"unaddressable":"fp_mismatch")},[M,e,v,o]);let D=b===t;(0,F.useEffect)(()=>{var G;if(!(d!=null&&d.needsSkeleton)||!D)return;let _=R();_&&((G=o==null?void 0:o.reportSkeleton)==null||G.call(o,e,_))},[d==null?void 0:d.needsSkeleton,D,e,o]),(0,F.useEffect)(()=>{if(!D)return;let _=Jt(e);if(!_)return;let G=R();Ut(_,G&&"status"in G?{status:G.status}:{skeleton:G})},[e,D]),(0,F.useEffect)(()=>{!O||!T()||kn.has(e)||(kn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[O,e]);let q=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";(0,F.useEffect)(()=>ve({id:e,arms:q===""?void 0:q.split("|")}),[e,q]);let Z=(0,F.useRef)(null);(0,F.useEffect)(()=>{!o||l==="none"||l==="seeded"||l==="override"||u===""||k||Z.current!==u&&(Z.current=u,ae(o,p,e,u))},[o,p,e,u,l,k]);let ie=l!=="none"&&l!=="seeded"&&!k,oe=ie?u:"",ue=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,F.useEffect)(()=>{if(!o||!i||l==="override")return;let _=s.current;if(!_)return;let G=se(i),Q=ee(i),ce=!1;return te(_,U(i),{fireGoal:()=>{ce||(ce=!0,ie&&(Q!==void 0?o.componentGoal(e,G,{value:Q}):o.componentGoal(e,G)),o.goal(G,y({metadata:{componentId:e,arm:oe},weight:1,stepIndex:0},Q!==void 0?{value:Q}:{})))},fireStep:(Ce,xt,er)=>{ie&&o.componentGoal(e,Ce,{reward:xt}),o.goal(Ce,{metadata:{componentId:e,arm:oe},weight:xt,stepIndex:er})}},G)},[o,e,ue,u,l,k,ie,oe]);let Y=(0,F.useRef)(null);(0,F.useEffect)(()=>{let _=s.current;if(_){if(Y.current===null){Y.current=u;return}Y.current!==u&&(Y.current=u,(0,Ee.reveal)(_))}},[u]);let Qn=(0,F.useMemo)(()=>y({"data-sentient-slot":e},u!==""?{"data-sentient-arm":u}:{}),[e,u]);return(0,An.jsx)("div",N(y({ref:s,className:a},Qn),{children:b}))}var Ge=require("react/jsx-runtime");function Ar(e){var s;let{client:t,variantId:n,content:r,ref:i}=Ke(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[a,c]=(0,ke.useState)(!1);if((0,ke.useEffect)(()=>{c(!0)},[]),e.clientOnly&&(!a||!t)||!n)return null;let o=(s=e.variants[n])!=null?s:null,p=o===null?r:null;return T()&&o===null&&p===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,Ge.jsx)("div",{ref:i,"data-sentient-id":e.id,"data-sentient-variant":n,children:o!=null?o:p})}var _r=(0,ke.memo)(Ar,(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 On(e){if(e.variants===void 0)return(0,Ge.jsx)(Pe,y({},e));let t=e;if(t.children!=null){T()&&Or(t);let n=t,{funnel:r,microSignalGoals:i,agentData:a,agentDataByVariant:c,clientOnly:o,variants:p}=n,s=De(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return(0,Ge.jsx)(Pe,N(y({},s),{children:t.children,variants:p}))}return(0,Ge.jsx)(_r,y({},t))}var _n=new Set;function Or(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||_n.has(e.id)||(_n.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}var $=require("react");var Pn=require("react/jsx-runtime");function En({id:e,default:t,component:n="span",className:r,goal:i}){var E;let a=I(),c=ne(),o=$e(),p=Me(),s=(0,$.useRef)(null),v=(0,$.useRef)(null),f=(0,$.useSyncExternalStore)(J,()=>we(e),()=>null),[h,R]=(0,$.useState)(()=>{var b,k;return(k=(b=a==null?void 0:a.getAssignment(e,p))==null?void 0:b.content)!=null?k:null}),[d,u]=(0,$.useState)(()=>{var b,k;return(k=(b=a==null?void 0:a.getAssignment(e,p))==null?void 0:b.variantId)!=null?k:null});(0,$.useEffect)(()=>{if(f||!a)return;let b=a.getAssignment(e,p);if((b==null?void 0:b.content)!==void 0){u(b.variantId),R(b.content);return}let k=!1;return a.assign(e).then(w=>{if(!k){if(!w){T()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}u(w.variantId),w.content&&R(w.content)}}),()=>{k=!0}},[a,e,p,f]),(0,$.useEffect)(()=>{f||!a||!d||!c||s.current!==d&&(s.current=d,a.track({projectId:c,componentId:e,variantId:d,eventType:"variant_assigned",payload:{}}),o==null||o(e,d))},[a,d,c,e,o,f]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),g=(0,$.useMemo)(()=>i===void 0?null:U(i),[m]),l=i===void 0?null:typeof i=="string"?i:g.type,S=(0,$.useRef)(!1);(0,$.useEffect)(()=>{S.current=!1},[d,m]),(0,$.useEffect)(()=>{if(f||!a||!d||!c||!g||!l)return;let b=v.current;if(!b)return;let k=ee(g);return te(b,g,{fireGoal:()=>{S.current||(S.current=!0,a.track({projectId:c,componentId:e,variantId:d,eventType:"goal_achieved",goalType:l,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),a.goal(l,y({metadata:{componentId:e,variantId:d},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(w,O,P)=>{a.track({projectId:c,componentId:e,variantId:d,eventType:"goal_achieved",goalType:w,payload:{reward:O}}),a.goal(w,{metadata:{},weight:O,stepIndex:P})}})},[a,d,c,e,g,l,f]);let x=h!=null?h:t;if(f){let b=a==null?void 0:a.getAssignment(e,p);x=b&&b.variantId===f&&(E=b.content)!=null?E:t}return(0,Pn.jsx)(n,{ref:b=>{v.current=b},className:r,children:x})}var ze=require("react");function qe(e){let t=I(),n=(0,ze.useRef)(new Set);return(0,ze.useCallback)((r,i)=>{var a,c;if(!we(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,y(y(y({metadata:(a=i==null?void 0:i.metadata)!=null?a:{},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 Te=require("react");function Gn(e,t={}){let p=t,{componentId:n}=p,r=De(p,["componentId"]),i=I(),a=qe(n!=null?n:""),c=(0,Te.useRef)(!1),o=(0,Te.useRef)(r);o.current=r,(0,Te.useEffect)(()=>{if(!i||c.current)return;c.current=!0;let{metadata:s,reward:v,value:f,currency:h,externalId:R}=o.current;if(n){a(e,o.current);return}i.goal(e,y(y(y({metadata:s!=null?s:{},weight:v!=null?v:1,stepIndex:0},f!==void 0?{value:f}:{}),h!==void 0?{currency:h}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,a])}var Ln=require("@sentientui/core"),Dn=require("@sentientui/policy"),In=require("react/jsx-runtime");function Tn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Er(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Tn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Tn((0,Dn.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Ln.renderPrePaintScript)(e.apiKey)}function Nn(e){return(0,In.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Er(e)}})}var z=require("react"),$n=require("@sentientui/policy");var X=require("react"),pe=require("@sentientui/core"),Vn=require("@sentientui/policy");function Ze(e,t){let n=I(),r=Be(),[,i]=(0,X.useReducer)(f=>f+1,0),a=(0,X.useSyncExternalStore)(J,()=>{var f;return typeof window!="undefined"?(f=window.__sentient_slot_overrides)==null?void 0:f[e]:void 0},()=>{}),c=a===void 0?r[e]:void 0,o=a===void 0&&c===void 0&&n?n.getSlotResult(e):null,p=(n==null?void 0:n.isLocal)===!0&&a===void 0&&c===void 0&&o===null;(0,X.useEffect)(()=>{if(!p||!n)return;let f=!1;return n.decide({slots:[t]}).then(h=>{!f&&h&&i()}),()=>{f=!0}},[n,e,p]);let s=(()=>{if(a!==void 0)return{result:a,arm:(0,pe.armOfResult)(a),source:"override"};if(c!==void 0)return{result:c,arm:(0,pe.armOfResult)(c),source:"preloaded"};if(o!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:o,arm:(0,pe.armOfResult)(o),source:h?"client":"seeded"}}let f=(0,pe.baselineResultFor)(t);return{result:f,arm:(0,pe.armOfResult)(f),source:"baseline"}})(),v=s.source==="preloaded"||s.source==="override";return(0,X.useEffect)(()=>{var h;if(!n||n.isLocal===!0||v||!n.decideSlots)return;let f=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),f==null||f()}},[n,e,v]),s}function Pr(){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 Fn(){let e=I(),t=tn();(0,X.useSyncExternalStore)(J,Gt,()=>0);let[n,r]=(0,X.useState)(!1);(0,X.useEffect)(()=>r(!0),[]);let i=o=>({persona:o.persona,confidence:o.confidence,band:(0,Vn.confidenceBand)(o.confidence)});if(!n)return t?i(t):null;let a=Pr();if(a)return i(a);if(t)return i(t);let c=e?e.getPersona():null;return c?i(c):null}var Mn=new Set;function Gr(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Bn(e,t,n){let r=I(),i=ne(),a=JSON.stringify(t),c=(0,z.useMemo)(()=>({id:e,dims:t}),[e,a]),{result:o,arm:p,source:s}=Ze(e,c),v=(0,z.useMemo)(()=>typeof o=="string"?{}:o,[p]);if(T()&&!Mn.has(e)){Mn.add(e);let u=(0,$n.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([g,l])=>[g,[...l]]))}),m=Object.values(t).reduce((g,l)=>g*l.length,1);u.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} 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 ${u.reason}. Serving baseline.`)}let f=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,z.useEffect)(()=>ve({id:e,dims:t}),[e]);let h=(0,z.useRef)(null);(0,z.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||h.current===p||(h.current=p,ae(r,i,e,p))},[r,i,e,p,s]);let R=n==null?void 0:n.funnel;(0,z.useEffect)(()=>{var u;!r||!R||s==="override"||ye(r,i,e,R,U((u=n==null?void 0:n.goal)!=null?u:"click"))},[r,i,e,R,f,s]),(0,z.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let u=document.querySelector(`[data-sentient-slot="${Gr(e)}"]`);if(!u){T()&&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 m=se(n.goal),g=ee(n.goal),l=!1;return te(u,U(n.goal),{fireGoal:()=>{l||(l=!0,g!==void 0?r.componentGoal(e,m,{value:g}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:p},weight:1,stepIndex:0},g!==void 0?{value:g}:{})))},fireStep:(S,x,C)=>{r.componentGoal(e,S,{reward:x}),r.goal(S,{metadata:{componentId:e,arm:p},weight:x,stepIndex:C})}},m)},[r,e,f,p,s]);let d=(0,z.useMemo)(()=>{let u={"data-sentient-slot":e};for(let[m,g]of Object.entries(v))u[`data-${m}`]=g;return u},[e,v]);return{tokens:v,props:d}}var Re=require("react");var jn=new Set;function Wn(e,t){var R;if(T()&&!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:a,goalLabel:c,ref:o,nodeRef:p}=Ke(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(R=i!=null?i:r[0])!=null?R:"",v=t.variants[s];(0,Re.useEffect)(()=>{if(!T()||!n)return;let d=setTimeout(()=>{!p.current&&!jn.has(e)&&(jn.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(d)},[n,e]);let f=(0,Re.useCallback)((d,u)=>{var g,l;if(a)return;let m=d!=null?d:c;m&&(n==null||n.componentGoal(e,m,u),n==null||n.goal(m,y(y(y({metadata:(g=u==null?void 0:u.metadata)!=null?g:{},weight:(l=u==null?void 0:u.reward)!=null?l:1,stepIndex:0},(u==null?void 0:u.value)!==void 0?{value:u.value}:{}),(u==null?void 0:u.currency)!==void 0?{currency:u.currency}:{}),(u==null?void 0:u.externalId)!==void 0?{externalId:u.externalId}:{})))},[n,e,c,a]),h=(0,Re.useMemo)(()=>({ref:o,"data-sentient-id":e,"data-sentient-variant":s}),[o,e,s]);return{variant:s,value:v,bind:h,fireGoal:f}}var j=require("react");var Jn=require("react/jsx-runtime"),Ye=new Set;function Kn(e){var g;let t=I(),n=ne(),r=(0,j.useRef)(null),i=Object.keys(e.arrangements).join(" "),a=(0,j.useMemo)(()=>Object.keys(e.arrangements),[i]),c=(0,j.useMemo)(()=>y({id:e.id,arms:a},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,a,e.baseline]),{arm:o,source:p}=Ze(e.id,c);T()&&e.baseline!==void 0&&e.baseline!==a[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 ("${a[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=j.Children.toArray(e.children).filter(j.isValidElement),v=new Map;for(let l of s)v.set(String((g=l.key)!=null?g:"").replace(/^\.\$/,""),l);let f=e.arrangements[o],h=f!==void 0&&f.length===s.length&&f.every(l=>v.has(l));T()&&f!==void 0&&!h&&!Ye.has(e.id+":keys")&&(Ye.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${o}" [${f.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let R=h?f.map(l=>v.get(l)):s;(0,j.useEffect)(()=>ve({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let d=(0,j.useRef)(null);(0,j.useEffect)(()=>{!t||p==="baseline"||p==="seeded"||p==="override"||d.current===o||(d.current=o,ae(t,n,e.id,o))},[t,n,e.id,o,p]);let u=e.funnel;(0,j.useEffect)(()=>{var l;!t||!u||p==="override"||ye(t,n,e.id,u,U((l=e.goal)!=null?l:"click"))},[t,n,e.id,u,p]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,j.useEffect)(()=>{if(!t||e.goal===void 0||p==="override"||p==="baseline"||p==="seeded")return;let l=r.current;if(!l)return;let S=se(e.goal),x=ee(e.goal),C=!1;return te(l,U(e.goal),{fireGoal:()=>{C||(C=!0,x!==void 0?t.componentGoal(e.id,S,{value:x}):t.componentGoal(e.id,S),t.goal(S,y({metadata:{componentId:e.id,arm:o},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(E,b,k)=>{t.componentGoal(e.id,E,{reward:b}),t.goal(E,{metadata:{componentId:e.id,arm:o},weight:b,stepIndex:k})}},S)},[t,e.id,m,o,p]),(0,Jn.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":o,children:R})}var yt=require("@sentientui/core");var Tr=["page","blocks","layoutOrder"],Un=new Map;function Hn(e,t){Un.set(e,t)}function vt(e){return Un.get(e)}function Xn(e){var i,a;let t=(a=(i=e.content)!=null?i:vt(e.page))!=null?a:{},n={};for(let[c,o]of Object.entries(t))Tr.includes(c)||(n[c]=o);let r=N(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function zn(e){return`<script type="application/ld+json">${St(e)}</script>`}function St(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function qn(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 dr=Object.create;var Oe=Object.defineProperty,fr=Object.defineProperties,gr=Object.getOwnPropertyDescriptor,mr=Object.getOwnPropertyDescriptors,pr=Object.getOwnPropertyNames,De=Object.getOwnPropertySymbols,yr=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var Et=(e,t,n)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))nt.call(t,n)&&Et(e,n,t[n]);if(De)for(var n of De(t))Pt.call(t,n)&&Et(e,n,t[n]);return e},D=(e,t)=>fr(e,mr(t));var Ve=(e,t)=>{var n={};for(var r in e)nt.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&&Pt.call(e,r)&&(n[r]=e[r]);return n};var vr=(e,t)=>{for(var n in t)Oe(e,n,{get:t[n],enumerable:!0})},Gt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pr(t))!nt.call(e,i)&&i!==n&&Oe(e,i,{get:()=>t[i],enumerable:!(r=gr(t,i))||r.enumerable});return e};var Fe=(e,t,n)=>(n=e!=null?dr(yr(e)):{},Gt(t||!e||!e.__esModule?Oe(n,"default",{value:e,enumerable:!0}):n,e)),Sr=e=>Gt(Oe({},"__esModule",{value:!0}),e);var Kr={};vr(Kr,{Adaptive:()=>Fn,AdaptiveGroup:()=>er,AdaptiveProvider:()=>ln,AdaptiveSlot:()=>Te,AdaptiveText:()=>Mn,SentientPersonaScript:()=>Jn,buildAgentFeed:()=>ir,consentWatcher:()=>lr.consentWatcher,defineAgentContent:()=>rr,detectSegment:()=>kt.deriveSessionSegment,getAgentContent:()=>Rt,grantConsent:()=>ar.grantConsent,renderAgentJsonLd:()=>or,renderAgentJsonLdBody:()=>Ct,renderAgentMarkdown:()=>sr,renderBlocks:()=>me,renderCompose:()=>Xe,useAdaptive:()=>Qn,useAdaptiveApiBaseUrl:()=>yn,useAdaptiveGoal:()=>Qe,useAdaptivePersona:()=>Xn,useAdaptiveTokens:()=>Yn,useAssignment:()=>Ue,useInitialAssignments:()=>je,useLayoutOrder:()=>dn,usePageGoal:()=>$n,useSentient:()=>F,useSessionSegment:()=>ke});module.exports=Sr(Kr);var _=require("react"),$e=require("@sentientui/core");var Tt=new Map,Me=new Map;function Nt(e,t){let n=Me.get(e);return n||(n=new Set,Me.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Me.delete(e)}}function It(e,t){Tt.set(e,t);let n=Me.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function rt(e){var t;return(t=Tt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Lt(){if(typeof window=="undefined")return hr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function it(){return Lt().on}function Dt(e){let t=Lt().listeners;return t.add(e),()=>{t.delete(e)}}function Vt(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(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ot="sentient:overrides-changed";function Ft(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function st(){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(ot))}function z(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ot,e),()=>window.removeEventListener(ot,e))}function Mt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function I(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function q(e){return typeof e=="string"?{type:"click"}:e}function ae(e){return typeof e=="string"?e:e.type}function ne(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var at=new Set,lt=!1;function Bt(e){if(at.has(e))return!0;if(at.add(e),!lt){lt=!0;let t=()=>{lt=!1,at.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 br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function $t(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(br(r))return!0;r=r.parentElement}return!1}function re(e,t,n,r){if(t.type==="weighted_composite"){let a=new Set,p=[];return t.steps.forEach(({goal:u,name:h,weight:A},w)=>{let o=(m=!1)=>{a.has(w)||m&&r!==void 0&&Bt(`step\0${h}\0${A}\0${w}`)||(a.add(w),n.fireStep(h,A,w))};if(u.type==="click"){let m=v=>{let f=v.target;f instanceof Element&&$t(f,e,u.selector)&&o()};e.addEventListener("click",m),p.push(()=>e.removeEventListener("click",m));return}if(u.type==="form_submit"){let m=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&o()};e.addEventListener("submit",m),p.push(()=>e.removeEventListener("submit",m));return}if(u.type==="scroll_depth"){let m=Math.max(0,Math.min(1,u.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=m){o(!0),v.disconnect();break}},{threshold:[m]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let u of p)u()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((a,p)=>p)),d=()=>{r!==void 0&&Bt(r)||n.fireGoal()},c=(a,p=!1)=>{l.delete(a),l.size===0&&(p?d():n.fireGoal())},s=[];return i.forEach((a,p)=>{if(a.type==="click"){let u=h=>{let A=h.target;A instanceof Element&&$t(A,e,a.selector)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("click",u),s.push(()=>e.removeEventListener("click",u));return}if(a.type==="form_submit"){let u=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("submit",u),s.push(()=>e.removeEventListener("submit",u));return}if(a.type==="scroll_depth"){let u=Math.max(0,Math.min(1,a.threshold)),h=new IntersectionObserver(A=>{for(let w of A)if(w.intersectionRatio>=u){t.type==="composite"?c(p,!0):d(),h.disconnect();break}},{threshold:[u]});h.observe(e),s.push(()=>h.disconnect());return}}),()=>{for(let a of s)a()}}var jt=new Set,Wt=new Set;function ve(e,t,n,r,i){let l=`${r}|${n}`;if(Wt.has(l))return;Wt.add(l);let d=i.type==="weighted_composite"&&!jt.has(r);d&&jt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:d?{funnelId:r,steps:i.steps.map(c=>({goalId:c.name,weight:c.weight}))}:{funnelId:r}})}function le(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var xr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function de(){if(typeof window=="undefined")return xr;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 Ee(){de().version+=1;for(let e of de().listeners)e()}var Kt=()=>{};function Jt(e){return I()?(de().components.set(e.id,e),Ee(),()=>{de().components.delete(e.id),Ee()}):Kt}function Se(e){return I()?(de().slots.set(e.id,e),Ee(),()=>{de().slots.delete(e.id),Ee()}):Kt}function ut(e){I()&&(de().sections=[...e],Ee())}var Ut="0.37.0",ct=Ut!=="0.0.0-dev"?{name:"react",version:Ut}:void 0;function wr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){wr()[e]=t}function Ht(e){window.__sentient_vocabulary_override=e}function Xt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function kr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){kr()[e]=t}function zt(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let l=n.slice(0,r.index)+i;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var ft="__snt_editor_token",xe=null,dt=!1;function qt(){return dt}function Rr(){try{return sessionStorage.getItem(ft)}catch(e){return null}}function Be(e){if(xe)return xe;let t=typeof window=="undefined"?null:zt("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Rr();return dt=!!n,xe=Promise.resolve(n?{token:n,fresh:!1}:null),xe}return dt=!0,xe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(ft,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),xe}function Yt(){try{sessionStorage.removeItem(ft)}catch(e){}}var Zt="sentient_preview_cell",Qt="sentient_refresh_region",gt="sentient-cell-preview-bar",fe="__preview__",we=null;function en(e){if((we==null?void 0:we.slotId)!==e)return null;let t=we;return we=null,t}function tn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))})}).then(n=>ge(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ge("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function nn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(gt))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(Zt),n=s.get(Qt)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Be(r);if(!qt())return;if(n){we={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,fe),st();return}if(!t)return;let l=t.lastIndexOf("~");if(l<=0)return;let d=t.slice(0,l),c=t.slice(l+1);i.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(d)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${s.token}`}}):(ge(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;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 a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&Ht(a.vocabulary),a.compose!=null)he(d,{kind:"arms",compose:{[fe]:a.compose}}),be(d,fe);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))he(d,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),be(d,fe);else if(a.blocks!=null)he(d,{kind:"arms",blocks:{[fe]:a.blocks}}),be(d,fe);else if(a.content!=null)he(d,{kind:"arms",content:a.content}),be(d,fe);else{ge("Nothing to preview in that square yet.");return}st(),ge(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${d}"]`))==null||p.scrollIntoView({block:"center"})}catch(u){}},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(gt))return;let t=document.createElement("div");t.id=gt,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=()=>{Yt();let l=new URL(window.location.href);l.searchParams.delete(Zt),l.searchParams.delete(Qt),window.location.assign(l.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var rn=!1;function on(e){if(rn||typeof window=="undefined")return;rn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Be(t).then(n=>{!n||!("token"in n)||!n.fresh||Cr(t,n.token)})}function Cr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var vn=require("react/jsx-runtime");function Ar(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,$e.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var an="https://api.sentient-ui.com/v1",K=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:an,debug:!1}),sn=!1,mt=new Set;function _r(e,t,n){let r=(0,_.useRef)(n);r.current=n;let[i,l]=(0,_.useState)(null),[d,c]=(0,_.useState)(!1),s=(0,_.useRef)(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(D(y({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,_.useEffect)(()=>{let p=s.current;if(p===void 0||typeof window=="undefined")return;let u,h=!1;return import("@sentientui/core/consent").then(({consentWatcher:A,forgetVisitor:w})=>{if(h)return;let o=A(typeof p=="object"&&p.cmp===void 0&&p.check?y(D(y({},p),{check:()=>s.current.check()}),p.refused?{refused:()=>{var f,b;return((b=(f=s.current).refused)==null?void 0:b.call(f))===!0}}:{}):p),m=!1,v=()=>{let f=o.refused()&&o.read()!==!0;f&&!m&&(w(t),r.current()),m=f,c(f);let b=o.read();b!==null&&mt.add(t),l(b!=null?b:mt.has(t)?!1:null)};v(),u=o.subscribe(v)}),()=>{h=!0,u==null||u()}},[a,t]),{granted:i,refused:d}}function ln(e){var C,O,T;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:Ar()}),[i,l]=(0,_.useState)(it());(0,_.useEffect)(()=>Dt(()=>l(it())),[]),(0,_.useEffect)(()=>{nn(e.apiBaseUrl),on(e.apiBaseUrl)},[]);let d=(0,_.useRef)(()=>{}),c=_r(e.consentFrom,e.apiKey,()=>d.current()),s=e.consentFrom?(C=c.granted)!=null?C:mt.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?c.refused:!0,p=(0,_.useRef)(a);p.current=a;let u=(0,_.useRef)(null),h=(0,_.useRef)(!1),A=(0,_.useRef)([]),w=(0,_.useRef)(!1);d.current=()=>{var x;A.current=[],w.current=!0;let g=u.current;g!=null&&g.gated?g.dispose():(x=g==null?void 0:g.takeHeld)==null||x.call(g)},(0,_.useEffect)(()=>{var U,ee;if(p.current&&s===!1&&(A.current=[]),s===!1&&h.current&&(p.current&&((U=u.current)==null||U.destroy()),u.current=null,h.current=!1),s===!1&&!e.preConsentBehavior){p.current&&((ee=u.current)==null||ee.destroy()),u.current=null,n(null);return}let g=s!==!1;g&&(w.current=!1);let x=V=>{!g&&w.current&&V.gated&&V.dispose()},S=y({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,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},ct?{sdk:ct}:{}),k=!1,R=null,G=null,P=V=>{for(let j of A.current.splice(0))setTimeout(()=>{if(u.current!==V){w.current||A.current.push(j);return}try{j(V)}catch(se){}},0)},B=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:j})=>{k||(G=j(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{k||(R=V(D(y({},S),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),x(R),u.current=R,h.current=g,P(R),n(R),B(R))}):(R=(0,$e.init)(S),x(R),u.current=R,h.current=g,P(R),n(R),B(R)),()=>{var V,j;k=!0,G==null||G(),A.current=A.current.concat((j=(V=R==null?void 0:R.takeHeld)==null?void 0:V.call(R))!=null?j:[]),R==null||R.dispose()}},[s]),(0,_.useEffect)(()=>{if(!t)return;let g=!1,x=async()=>{if(g)return;let k;try{k=await t.fetchWeights()}catch(R){return}if(!g)for(let R of k){let G={componentId:R.componentId,updatedAt:R.updatedAt,variants:R.variants.map(P=>{var B;return{variantId:P.variantId,pulls:P.pulls,avgReward:(B=P.avgReward)!=null?B:0}})};It(R.componentId,G)}};x();let S=setInterval(()=>{x()},6e4);return()=>{g=!0,clearInterval(S)}},[t]);let o=(O=e.ssrFallback)!=null?O:"first",m=((T=e.apiBaseUrl)!=null?T:an).replace(/\/$/,""),v=(0,_.useRef)(null);(0,_.useEffect)(()=>{var S;if(typeof process!="undefined"&&((S=process.env)==null?void 0:S.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:m},x=v.current;if(v.current=g,x!==null)for(let k of["apiKey","context","country","persona","apiBaseUrl"])Object.is(x[k],g[k])||console.warn(`[sentient] AdaptiveProvider: \`${k}\` 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,m]),(0,_.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||Mt({apiKey:e.apiKey,apiBaseUrl:m,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,m]),(0,_.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){ut(g);return}e.declaredSections&&e.declaredSections.length>0&&ut(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{!I()||e.consent!==void 0||e.consentFrom!==void 0||sn||(sn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,_.useEffect)(()=>{if(!I())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let x=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),k=>k.getAttribute("data-sentient-id"))),S=g.filter(k=>!x.has(k));S.length>0&&console.warn(`[SentientUI] Declared section${S.length>1?"s":""} ${S.map(k=>`"${k}"`).join(", ")} ${S.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 f=(0,_.useMemo)(()=>t&&i?Vt(t):t,[t,i]),b=(0,_.useMemo)(()=>{var g,x,S,k,R,G,P,B;return{client:f,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(x=e.initialLayoutOrder)!=null?x:null,initialSlots:(S=e.initialSlots)!=null?S:{},initialSlotConfig:(k=e.initialSlotConfig)!=null?k:{},initialPalette:(R=e.initialPalette)!=null?R:null,initialVocabulary:(G=e.initialVocabulary)!=null?G:null,initialPersona:(P=e.initialPersona)!=null?P:null,apiBaseUrl:m,debug:(B=e.debug)!=null?B:!1}},[f,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,m,e.debug]);return(0,vn.jsx)(K.Provider,{value:b,children:e.children})}function F(){return(0,_.useContext)(K).client}function ie(){return(0,_.useContext)(K).apiKey}function je(){return(0,_.useContext)(K).initialAssignments}function ke(){return(0,_.useContext)(K).sessionSegment}function un(){return(0,_.useContext)(K).ssrFallback}function We(){return(0,_.useContext)(K).onAssignment}function cn(){return(0,_.useContext)(K).debug}function dn(){let e=(0,_.useContext)(K).initialLayoutOrder,t=(0,_.useSyncExternalStore)(z,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ke(){return(0,_.useContext)(K).initialSlots}function fn(){return(0,_.useContext)(K).initialPersona}function gn(){return(0,_.useContext)(K).initialSlotConfig}function mn(){return(0,_.useContext)(K).initialPalette}function pn(){return(0,_.useContext)(K).initialVocabulary}function yn(){return(0,_.useContext)(K).apiBaseUrl}var Ce=require("react");var M=require("react"),Sn=require("@sentientui/core");var Y=require("react"),Je=require("@sentientui/policy");function Re(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 l=i.indexOf(":");if(l!==-1&&i.slice(0,l)===e)return i.slice(l+1)}}catch(r){}return null}function Ue(e,t,n,r){let i=je(),l=un(),d=F(),c=ke(),s=We(),a=cn(),p=(0,Y.useRef)(null),u=(0,Y.useSyncExternalStore)(z,()=>Re(e),()=>null),h=u&&t.includes(u)?u:null,A=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{a&&h&&A.current!==h&&(A.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[a,h,e]);let[w,o]=(0,Y.useState)(()=>{var b,C;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!d){let O=i[e];return O&&t.includes(O)?{variantId:O,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content))return{variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0};let f=rt(e);if(f){let O=(0,Je.pickFromWeights)(f.variants,t);if(O)return{variantId:O,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),m=v=>{s&&p.current!==v&&(p.current=v,s(e,v))};return(0,Y.useEffect)(()=>{var b;if(h||!d)return;let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content)){o({variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0}),m(v.variantId);return}let f=rt(e);if(f&&w.settled&&w.variantId&&w.variantId===(0,Je.pickFromWeights)(f.variants,t)){m(w.variantId);return}o(C=>{var O;return C.variantId?C:{variantId:(O=t[0])!=null?O:null,content:null,isLoading:!1,settled:!1}})},[h,d,e,c]),(0,Y.useEffect)(()=>{if(h||!d)return;let v=d.getAssignment(e,c);if(v&&t.includes(v.variantId))return;let f=!1;return d.assign(e,t,n,r).then(b=>{var C;f||b&&(!t.includes(b.variantId)&&!b.content||(o({variantId:b.variantId,content:(C=b.content)!=null?C:null,isLoading:!1,settled:!0}),m(b.variantId)))}),()=>{f=!0}},[h,d,e,c]),(0,Y.useEffect)(()=>{if(!h&&d)return Nt(e,v=>{var C;let f=d.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){o({variantId:f.variantId,content:(C=f.content)!=null?C:null,isLoading:!1,settled:!0}),m(f.variantId);return}let b=(0,Je.pickFromWeights)(v.variants,t);b&&(o({variantId:b,content:null,isLoading:!1,settled:!0}),m(b))})},[h,d,e,c]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}function He(e,t,n){let r=F(),i=ie(),l=Object.keys(t).join("\0"),d=(0,M.useMemo)(()=>Object.keys(t),[l]),{variantId:c,content:s,isOverride:a=!1,settled:p}=Ue(e,d,n.agentData,n.agentDataByVariant),[u,h]=(0,M.useState)(null),A=(0,M.useRef)(null),w=(0,M.useCallback)(k=>{A.current=k,h(k)},[]),o=n.goal,m=typeof o=="string"?o:JSON.stringify(o),v=(0,M.useMemo)(()=>o?q(o):null,[m]),f=o?ae(o):"";(0,M.useEffect)(()=>Jt({id:e,variantIds:d,goal:f}),[e,d,f]);let b=(0,M.useRef)(null);(0,M.useEffect)(()=>{a||p&&(!r||!c||!i||!u||b.current!==c&&(b.current=c,le(r,i,e,c)))},[r,c,i,e,u,a,p]);let C=(0,M.useRef)(!1),O=(0,M.useRef)(new Set);(0,M.useEffect)(()=>{C.current=!1,O.current=new Set},[c,v]);let T=n.funnel;(0,M.useEffect)(()=>{a||!p||!r||!T||!v||ve(r,i,e,T,v)},[r,i,e,T,v,a,p]);let g=n.cursorSignal===!0;(0,M.useEffect)(()=>{if(!g||a||!p||!r||!c||!u)return;let k=null,R=0,G=()=>{R=Date.now(),k=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),k=null},800)},P=()=>{k!==null&&(clearTimeout(k),k=null)};return u.addEventListener("mouseenter",G),u.addEventListener("mouseleave",P),()=>{u.removeEventListener("mouseenter",G),u.removeEventListener("mouseleave",P),k!==null&&clearTimeout(k)}},[g,r,c,i,e,u,a,p]);let x=(0,M.useRef)(n.microSignalGoals);x.current=n.microSignalGoals;let S=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,M.useEffect)(()=>{if(a||!p||!r||!c||!u)return;let k=Date.now();return(0,Sn.attachMicroSignalDetectors)((R,G={})=>{var V,j,se;r.track({projectId:i,componentId:e,variantId:c,eventType:"micro_signal",payload:y({signalType:R},G)});let P=(V=x.current)==null?void 0:V[R];if(!P||O.current.has(R))return;O.current.add(R);let B=typeof P=="string"?P:P.name,U=typeof P=="string"?1:(j=P.weight)!=null?j:1,ee=typeof P=="string"?0:(se=P.stepIndex)!=null?se:0;r.goal(B,{metadata:y({signalType:R},G),weight:U,stepIndex:ee})},u,k)},[r,c,i,e,u,S,a,p]),(0,M.useEffect)(()=>{if(a||!p||!r||!c||!u||!v)return;let k=ne(v);return re(u,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:f,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),r.goal(f,y({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(R,G,P)=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:R,payload:{reward:G}}),r.goal(R,{metadata:{},weight:G,stepIndex:P})}},f)},[r,c,i,e,u,v,f,a,p]),{client:r,variantIds:d,variantId:c,content:s,settled:p,isOverride:a,goalLabel:f,ref:w,nodeRef:A}}var $=require("react"),Ge=require("@sentientui/core"),wt=require("@sentientui/core/region");var H=require("react"),bn=require("@sentientui/core");var hn=new Set;function xn(e,t){var C,O,T;let n=F(),r=(0,H.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,H.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let l=(0,H.useRef)(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Ke(),c=gn(),s=mn(),a=pn(),p=(0,H.useSyncExternalStore)(z,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_config_overrides)==null?void 0:g[e]:void 0},()=>{}),u=(0,H.useSyncExternalStore)(z,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_overrides)==null?void 0:g[e]:void 0},()=>{}),h=g=>g==null?"":(0,bn.armOfResult)(g),A=(0,H.useCallback)(g=>{var x,S;return(S=(x=n==null?void 0:n.onSlotsChanged)==null?void 0:x.call(n,g))!=null?S:(()=>{})},[n]);(0,H.useSyncExternalStore)(A,()=>{var g;return(g=n==null?void 0:n.getSlotConfig(e))!=null?g:null},()=>null),(0,H.useSyncExternalStore)(A,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let w=p===void 0?c[e]:void 0,o=p===void 0&&w===void 0&&n?n.getSlotConfig(e):null,m=(C=s!=null?s:n==null?void 0:n.getSitePalette())!=null?C:null,v=(T=a!=null?a:(O=n==null?void 0:n.getStyleVocabulary)==null?void 0:O.call(n))!=null?T:null,f=(()=>{var g,x,S;if(p!==void 0)return{config:p,arm:h(u),palette:m,vocabulary:(g=Xt())!=null?g:v,source:"override"};if(w!==void 0)return{config:w,arm:h((x=d[e])!=null?x:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:v,source:"preloaded"};if(o!==null){let k=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:o,arm:h((S=n==null?void 0:n.getSlotResult(e))!=null?S:d[e]),palette:m,vocabulary:v,source:k?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:v,source:"none"}})(),b=f.source==="preloaded"||f.source==="override";return(0,H.useEffect)(()=>{var B,U,ee,V,j;if(!n||n.isLocal===!0||b)return;let g=f.source==="none",x=g&&(U=(B=r.current)==null?void 0:B.call(r))!=null?U:null,S=x!=null&&x!==""?{[e]:x}:void 0,k=(ee=i.current)==null?void 0:ee.call(i),R=g&&(j=(V=l.current)==null?void 0:V.call(l))!=null?j:null,G=y(y({},k?{render:{[e]:k}}:{}),R?{skeletons:{[e]:R}}:{}),P=Object.keys(G).length>0;return n.requestSlots?P?n.requestSlots([e],S,G):S?n.requestSlots([e],S):n.requestSlots([e]):g&&(R?n.reportSlots([e],S!=null?S:{},{[e]:R}):S?n.reportSlots([e],S):n.reportSlots([e])),()=>{var se;return(se=n.cancelSlots)==null?void 0:se.call(n,[e])}},[n,b,f.source,e]),(0,H.useEffect)(()=>{!I()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||hn.has(e)||(hn.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,f.source,e]),f}var Pe=require("react");var L=require("react/jsx-runtime");function pt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ue={none:"0",sm:"8px",md:"16px",lg:"24px"},yt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Cn={sm:"0.875em",md:"1em",lg:"1.25em"},Or={sm:"1.25em",md:"1.5em",lg:"2em"},wn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},kn={sm:"8px",md:"16px",lg:"32px"},Er={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Pr={normal:"400",medium:"500",bold:"700"};function Rn(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function An(e,t,n){var i,l,d,c;let r=t==null?void 0:t.accent;return D(y({display:"inline-block",padding:(i=wn[n!=null?n:"md"])!=null?i:wn.md,borderRadius:(l=t==null?void 0:t.radius)!=null?l:"8px",font:"inherit"},n?{fontSize:Cn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(d=t==null?void 0:t.primaryBg)!=null?d:"#111827":"transparent",color:e==="primary"?(c=t==null?void 0:t.primaryText)!=null?c:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Gr({node:e,opts:t}){var i,l,d,c,s;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(d=(l=t.palette)==null?void 0:l.border)!=null?d:"currentColor"}`,borderRadius:(s=(c=t.palette)==null?void 0:c.radius)!=null?s:"8px"};return(0,L.jsxs)("form",{onSubmit:a=>{var h,A,w;a.preventDefault();let p=new FormData(a.currentTarget),u={};for(let o of e.fields)u[o.name]=String((h=p.get(o.name))!=null?h:"");(A=t.onFormGoal)==null||A.call(t,e.submitGoal);try{(w=t.onFormSubmit)==null||w.call(t,u)}catch(o){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(a=>{var p,u;return(0,L.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[a.label,a.kind==="textarea"?(0,L.jsx)("textarea",{name:a.name,required:a.required,placeholder:a.placeholder,rows:3,style:r}):a.kind==="select"?(0,L.jsx)("select",{name:a.name,required:a.required,style:r,children:((p=a.options)!=null?p:[]).map(h=>(0,L.jsx)("option",{value:h,children:h},h))}):(0,L.jsx)("input",{name:a.name,type:(u=a.inputType)!=null?u:"text",required:a.required,placeholder:a.placeholder,style:r})]},a.name)}),(0,L.jsx)("button",{type:"submit",style:An(n,t.palette),children:e.submitLabel})]})}function Tr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(l=>l.id===n))==null?void 0:i.classes:void 0}function _n(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function me(e,t){var i;let n=Nr(e,t),r=_n(e.like,t);return n&&r?(0,Pe.cloneElement)(n,{style:D(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Nr(e,t){var n,r,i,l,d,c,s,a,p,u,h,A,w,o,m,v,f,b,C,O,T,g,x;try{let S=Tr(e,t);switch(e.type){case"stack":{let k=(r=ue[(n=e.gap)!=null?n:"md"])!=null?r:ue.md,R=e.surface==="raised"&&!S,G=(i=e.pad)!=null?i:R?"md":void 0;return(0,L.jsx)("div",D(y({},S?{className:S}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:yt[e.align]}:{}),e.justify?{justifyContent:yt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),G?{padding:(l=ue[G])!=null?l:ue.md}:{}),R?D(y(y({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(c=t.palette)!=null&&c.surface&&((s=t.palette)!=null&&s.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(a=t.palette)==null?void 0:a.border)!=null?p:"currentColor"}`,borderRadius:(h=(u=t.palette)==null?void 0:u.radius)!=null?h:"8px"}):{}),children:((A=e.children)!=null?A:[]).map((P,B)=>{let U=me(P,t);return U===null?null:(0,L.jsx)(Pe.Fragment,{children:U},B)})}))}case"grid":{let k=(o=ue[(w=e.gap)!=null?w:"md"])!=null?o:ue.md;return(0,L.jsx)("div",D(y({},S?{className:S}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:yt[e.align]}:{}),e.pad?{padding:(m=ue[e.pad])!=null?m:ue.md}:{}),children:((v=e.children)!=null?v:[]).map((R,G)=>{let P=me(R,t);return P===null?null:(0,L.jsx)(Pe.Fragment,{children:P},G)})}))}case"text":return S?(0,L.jsx)("p",{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:Cn[e.size]}:{}),e.weight?{fontWeight:Pr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Rn(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return S?(0,L.jsx)(k,{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)(k,{style:y(y({margin:0,fontSize:Or[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(b=e.emphasis)!=null?b:"primary";return(0,L.jsx)("a",D(y(y({href:pt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:An(k,t.palette,e.size)}),{children:e.label}))}case"link":return(0,L.jsx)("a",D(y(y({href:pt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,L.jsx)("img",D(y({src:pt(e.src),alt:e.alt},S?{className:S}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Er[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return S?(0,L.jsx)("span",{className:S,children:e.value}):(0,L.jsx)("span",{style:y({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(O=(C=t.palette)==null?void 0:C.border)!=null?O:"currentColor"}`},Rn(e.tone,t.palette)),children:e.value});case"spacer":return(0,L.jsx)("div",{style:{height:(T=kn[e.size])!=null?T:kn.md}});case"divider":return(0,L.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(x=(g=t.palette)==null?void 0:g.border)!=null?x:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,L.jsx)(Gr,{node:e,opts:t});default:return null}}catch(S){return null}}function Xe(e,t){var l,d,c,s;let n=me(e.tree,t);if(n===null)return null;let r=(l=e.surface)!=null&&l.like?(c=(d=t.vocabulary)==null?void 0:d.entries.find(a=>a.id===e.surface.like))==null?void 0:c.classes:void 0,i=_n((s=e.surface)==null?void 0:s.like,t);return r?(0,L.jsx)("div",D(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}var oe=require("react"),ze=require("@sentientui/core/region");function qe(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Ye(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function pe(e){return qe(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+pe(n),0):(0,oe.isValidElement)(e)?pe(Ye(e)):0}function Ir(e,t){return Array.isArray(t)?(0,oe.cloneElement)(e,void 0,...t):(0,oe.cloneElement)(e,void 0,t)}function vt(e,t){if(qe(e))return t;if(Array.isArray(e))return e.map(n=>vt(n,t));if((0,oe.isValidElement)(e)){let n=Ye(e);return pe(n)===0?e:Ir(e,vt(n,t))}return e}function On(e,t){return pe(e)===1?vt(e,t):null}var X=e=>e.join("/");function St(e,t,n){if(qe(e)){n.leafPaths.push(t),n.texts.push((0,ze.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>St(r,[...t,i],n));return}(0,oe.isValidElement)(e)&&(n.elements.set(X(t),e),St(Ye(e),[...t,"c"],n))}function bt(e){let t={leafPaths:[],texts:[],elements:new Map};return St(e,[],t),t}function Lr(e){return bt(e).texts}function En(e){let t=Lr(e);return t.length===0?null:(0,ze.skeletonFingerprint)(t)}function Dr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Pn(e,t){let n=t.reduce((i,l)=>Math.max(i,l+1),0),r=[];for(let i=0;i<n;i++){let l=t.flatMap((c,s)=>c===i?[Dr(e.leafPaths[s])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let c of l.slice(1)){let s=new Set(c.map(X));d=d.filter(a=>s.has(X(a)))}r.push(d.length>0?d[d.length-1]:null)}return r}function ht(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function xt(e,t){let n=bt(t);if(n.texts.length!==e.leaves.length||n.texts.some((l,d)=>l!==e.leaves[d]))return null;let r=Pn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let c=r[d],s=c?n.elements.get(X(c)):void 0,a=!!s&&(typeof s.type=="string"||ht(s)!==void 0);return D(y({},l),{restylable:a})});return D(y({},e),{nodes:i})}function Gn(e,t,n){var w;let r=bt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((o,m)=>Math.max(o,m+1),0);for(let o of Object.keys(t.nodes))if(!/^\d+$/.test(o)||Number(o)>=i)return null;let l=Pn(r,n),d=new Map;n.forEach((o,m)=>{d.has(o)||d.set(o,m)});let c=new Map(r.leafPaths.map((o,m)=>[X(o),m])),s=new Set,a=new Map,p=!1;for(let[o,m]of Object.entries(t.nodes)){let v=Number(o),f=l[v];if(m.hidden&&(f?s.add(X(f)):p=!0),m.like!==void 0){let b=l[m.like],C=f?r.elements.get(X(f)):void 0,O=b?ht(r.elements.get(X(b))):void 0;!f||O===void 0||ht(C)===void 0?p=!0:a.set(X(f),O)}}let u=new Map(Object.entries((w=t.order)!=null?w:{})),h=(o,m)=>{var v;if(qe(o)){let f=c.get(X(m));if(f===void 0)return o;let b=n[f],C=(v=t.nodes[String(b)])==null?void 0:v.text;return C===void 0?o:d.get(b)===f?C:""}if(Array.isArray(o)){let f=o.map((b,C)=>h(b,[...m,C]));for(let[b,C]of u){let O=C.map(x=>{let S=l[x];return!S||S.length!==m.length+1||X(S.slice(0,-1))!==X(m)?-1:S[S.length-1]});if(O.some(x=>x<0))continue;let T=[...O].sort((x,S)=>x-S),g=[...f];T.forEach((x,S)=>{f[x]=g[O[S]]}),u.delete(b)}return f}if((0,oe.isValidElement)(o)){let f=X(m);if(s.has(f))return null;let b=Ye(o);if(pe(b)===0)return o;let C=h(b,[...m,"c"]),O=a.get(f),T=O!==void 0?{className:O}:void 0;return Array.isArray(C)?(0,oe.cloneElement)(o,T,...C):(0,oe.cloneElement)(o,T,C)}return o},A=h(e,[]);return p||u.size>0?null:A}var Dn=require("react/jsx-runtime"),Tn=new Set,Nn=new Set,In=new Set,Ln="authored.";function Te({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,as:d="div",reportBaselineText:c=!0}){var At,_t;let s=F(),a=ie(),p=(0,$.useRef)(null),u=(0,$.useMemo)(()=>En(t),[t]),h=n?Object.keys(n).join("|"):"",A=(0,$.useMemo)(()=>y({fp:u!=null?u:"0000000000000000",forms:!!r,compose:!0,content:pe(t)===1},h!==""?{authored:h.split("|"),children:!0}:{}),[u,t,r,h]),w=()=>{var te;let E=p.current;if(!E||!c)return null;let N=(0,wt.captureRegionSkeleton)(E);return N.skeleton?(te=xt(N.skeleton,t))!=null?te:D(y({},N.skeleton),{editable:!1,nodes:N.skeleton.nodes.map(ce=>D(y({},ce),{restylable:!1}))}):{status:N.reason}},{config:o,arm:m,palette:v,vocabulary:f,source:b}=xn(e,{baselineText:c?()=>{var E,N;return(N=(E=p.current)==null?void 0:E.textContent)!=null?N:null}:void 0,render:()=>A,skeleton:w}),C=m!==""?(At=o==null?void 0:o.blocks)==null?void 0:At[m]:void 0,O=m!==""?(_t=o==null?void 0:o.compose)==null?void 0:_t[m]:void 0,T=(C!==void 0&&(0,Ge.containsFormBlock)(C)||O!==void 0&&(0,Ge.containsFormBlock)(O.tree))&&!r;(0,$.useEffect)(()=>{!T||!I()||Tn.has(e)||(Tn.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.`))},[T,e]);let g=E=>{!s||b==="override"||(b!=="seeded"&&s.componentGoal(e,E),s.goal(E,{metadata:{componentId:e,arm:m},weight:1,stepIndex:0}))},x=t,S=!1,k=m.startsWith(Ln)?m.slice(Ln.length):null;if((o==null?void 0:o.blocked)==="variant_history")S=!0;else if(k!==null)n&&Object.prototype.hasOwnProperty.call(n,k)?x=n[k]:S=!0;else if(O!==void 0){let E=T?null:Xe(O,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});E===null?S=!0:x=E}else if(C!==void 0){let E=T?null:me(C,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});E===null?S=!0:x=E}else if((o==null?void 0:o.edits)!==void 0&&b!=="none"){let E=o.edits,N=E.fp===u?Gn(t,E.edits,E.leafToNode):null;N===null?S=!0:x=N}else if((o==null?void 0:o.content)!==void 0&&b!=="none"){let E=On(t,o.content);E===null?S=!0:x=E}let R=S&&C===void 0&&O===void 0&&(o==null?void 0:o.edits)===void 0&&k===null&&(o==null?void 0:o.blocked)===void 0;(0,$.useEffect)(()=>{(o==null?void 0:o.blocked)!=="variant_history"||!I()||In.has(e)||(In.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[o==null?void 0:o.blocked,e]);let G=k!==null&&!S?k:null;(0,$.useEffect)(()=>{var _e;if(!G||!c||!s)return;let E=p.current;if(!E)return;let N=(0,wt.captureRegionSkeleton)(E),te=N.skeleton?xt(N.skeleton,n==null?void 0:n[G]):null,ce=(_e=E.textContent)==null?void 0:_e.trim();s.reportSlots([],void 0,void 0,{[e]:[y(y({key:G},ce?{text:ce}:{}),te?{skeleton:te}:{})]})},[G,s,e]);let P=S&&(o==null?void 0:o.edits)!==void 0&&(b==="preloaded"||b==="client");(0,$.useEffect)(()=>{var E;!P||!(o!=null&&o.edits)||(E=s==null?void 0:s.reportDrift)==null||E.call(s,e,o.edits.fp,u,o.edits.fp===u?"unaddressable":"fp_mismatch")},[P,e,u,s]);let B=x===t;(0,$.useEffect)(()=>{var N;if(!(o!=null&&o.needsSkeleton)||!B)return;let E=w();E&&((N=s==null?void 0:s.reportSkeleton)==null||N.call(s,e,E))},[o==null?void 0:o.needsSkeleton,B,e,s]),(0,$.useEffect)(()=>{if(!B)return;let E=en(e);if(!E)return;let N=w();tn(E,N&&"status"in N?{status:N.status}:{skeleton:N})},[e,B]),(0,$.useEffect)(()=>{!R||!I()||Nn.has(e)||(Nn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[R,e]);let U=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,$.useEffect)(()=>Se({id:e,arms:U===""?void 0:U.split("|")}),[e,U]);let ee=(0,$.useRef)(null);(0,$.useEffect)(()=>{!s||b==="none"||b==="seeded"||b==="override"||m===""||S||ee.current!==m&&(ee.current=m,le(s,a,e,m))},[s,a,e,m,b,S]);let V=b!=="none"&&b!=="seeded"&&!S,j=V?m:"",se=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,$.useEffect)(()=>{if(!s||!i||b==="override")return;let E=p.current;if(!E)return;let N=ae(i),te=ne(i),ce=!1;return re(E,q(i),{fireGoal:()=>{ce||(ce=!0,V&&(te!==void 0?s.componentGoal(e,N,{value:te}):s.componentGoal(e,N)),s.goal(N,y({metadata:{componentId:e,arm:j},weight:1,stepIndex:0},te!==void 0?{value:te}:{})))},fireStep:(_e,Ot,cr)=>{V&&s.componentGoal(e,_e,{reward:Ot}),s.goal(_e,{metadata:{componentId:e,arm:j},weight:Ot,stepIndex:cr})}},N)},[s,e,se,m,b,S,V,j]);let Le=(0,$.useRef)(null);(0,$.useEffect)(()=>{let E=p.current;if(E){if(Le.current===null){Le.current=m;return}Le.current!==m&&(Le.current=m,(0,Ge.reveal)(E))}},[m]);let ur=(0,$.useMemo)(()=>y({"data-sentient-slot":e},m!==""?{"data-sentient-arm":m}:{}),[e,m]);return(0,Dn.jsx)(d,D(y({ref:p,className:l},ur),{children:x}))}var Ne=require("react/jsx-runtime");function Vr(e){var p,u;let{client:t,variantId:n,content:r,ref:i}=He(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=(0,Ce.useState)(!1);(0,Ce.useEffect)(()=>{d(!0)},[]);let c=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!l||!t)||!n)return null;let s=(u=e.variants[n])!=null?u:null,a=s===null?r:null;return I()&&s===null&&a===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,Ne.jsx)(c,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:a})}var Fr=(0,Ce.memo)(Vr,(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.as!==t.as||e.className!==t.className||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 Fn(e){if(e.variants===void 0)return(0,Ne.jsx)(Te,y({},e));let t=e;if(t.children!=null){I()&&Mr(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:c,variants:s}=n,a=Ve(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return(0,Ne.jsx)(Te,D(y({},a),{children:t.children,variants:s}))}return(0,Ne.jsx)(Fr,y({},t))}var Vn=new Set;function Mr(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||Vn.has(e.id)||(Vn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}var W=require("react");var Bn=require("react/jsx-runtime");function Mn({id:e,default:t,component:n="span",className:r,goal:i}){var T;let l=F(),d=ie(),c=We(),s=ke(),a=(0,W.useRef)(null),p=(0,W.useRef)(null),u=(0,W.useSyncExternalStore)(z,()=>Re(e),()=>null),[h,A]=(0,W.useState)(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.content)!=null?x:null}),[w,o]=(0,W.useState)(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.variantId)!=null?x:null});(0,W.useEffect)(()=>{if(u||!l)return;let g=l.getAssignment(e,s);if((g==null?void 0:g.content)!==void 0){o(g.variantId),A(g.content);return}let x=!1;return l.assign(e).then(S=>{if(!x){if(!S){I()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}o(S.variantId),S.content&&A(S.content)}}),()=>{x=!0}},[l,e,s,u]),(0,W.useEffect)(()=>{u||!l||!w||!d||a.current!==w&&(a.current=w,l.track({projectId:d,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),c==null||c(e,w))},[l,w,d,e,c,u]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,W.useMemo)(()=>i===void 0?null:q(i),[m]),f=i===void 0?null:typeof i=="string"?i:v.type,b=(0,W.useRef)(!1);(0,W.useEffect)(()=>{b.current=!1},[w,m]),(0,W.useEffect)(()=>{if(u||!l||!w||!d||!v||!f)return;let g=p.current;if(!g)return;let x=ne(v);return re(g,v,{fireGoal:()=>{b.current||(b.current=!0,l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:f,payload:y({reward:1},x!==void 0?{goalValue:x}:{})}),l.goal(f,y({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(S,k,R)=>{l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:S,payload:{reward:k}}),l.goal(S,{metadata:{},weight:k,stepIndex:R})}})},[l,w,d,e,v,f,u]);let C=h!=null?h:t;if(u){let g=l==null?void 0:l.getAssignment(e,s);C=g&&g.variantId===u&&(T=g.content)!=null?T:t}return(0,Bn.jsx)(n,{ref:g=>{p.current=g},className:r,children:C})}var Ze=require("react");function Qe(e){let t=F(),n=(0,Ze.useRef)(new Set);return(0,Ze.useCallback)((r,i)=>{var l,d;if(!Re(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,y(y(y({metadata:(l=i==null?void 0:i.metadata)!=null?l:{},weight:(d=i==null?void 0:i.reward)!=null?d: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 Ie=require("react");function $n(e,t={}){let s=t,{componentId:n}=s,r=Ve(s,["componentId"]),i=F(),l=Qe(n!=null?n:""),d=(0,Ie.useRef)(!1),c=(0,Ie.useRef)(r);c.current=r,(0,Ie.useEffect)(()=>{if(!i||d.current||i.gated)return;d.current=!0;let{metadata:a,reward:p,value:u,currency:h,externalId:A}=c.current;if(n){l(e,c.current);return}i.goal(e,y(y(y({metadata:a!=null?a:{},weight:p!=null?p:1,stepIndex:0},u!==void 0?{value:u}:{}),h!==void 0?{currency:h}:{}),A!==void 0?{externalId:A}:{}))},[i,n,e,l])}var Wn=require("@sentientui/core"),Kn=require("@sentientui/policy"),Un=require("react/jsx-runtime");function jn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Br(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+jn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+jn((0,Kn.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Wn.renderPrePaintScript)(e.apiKey)}function Jn(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,Un.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Br(e)}})}var Q=require("react"),qn=require("@sentientui/policy");var Z=require("react"),ye=require("@sentientui/core"),Hn=require("@sentientui/policy");function et(e,t){let n=F(),r=Ke(),[,i]=(0,Z.useReducer)(u=>u+1,0),l=(0,Z.useSyncExternalStore)(z,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),d=l===void 0?r[e]:void 0,c=l===void 0&&d===void 0&&n?n.getSlotResult(e):null,s=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&c===null;(0,Z.useEffect)(()=>{if(!s||!n)return;let u=!1;return n.decide({slots:[t]}).then(h=>{!u&&h&&i()}),()=>{u=!0}},[n,e,s]);let a=(()=>{if(l!==void 0)return{result:l,arm:(0,ye.armOfResult)(l),source:"override"};if(d!==void 0)return{result:d,arm:(0,ye.armOfResult)(d),source:"preloaded"};if(c!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:c,arm:(0,ye.armOfResult)(c),source:h?"client":"seeded"}}let u=(0,ye.baselineResultFor)(t);return{result:u,arm:(0,ye.armOfResult)(u),source:"baseline"}})(),p=a.source==="preloaded"||a.source==="override";return(0,Z.useEffect)(()=>{var h;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let u=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var A;(A=n.cancelSlots)==null||A.call(n,[e]),u==null||u()}},[n,e,p]),a}function $r(){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 Xn(){let e=F(),t=fn();(0,Z.useSyncExternalStore)(z,Ft,()=>0);let[n,r]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>r(!0),[]);let i=c=>({persona:c.persona,confidence:c.confidence,band:(0,Hn.confidenceBand)(c.confidence)});if(!n)return t?i(t):null;let l=$r();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var zn=new Set;function jr(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Yn(e,t,n){let r=F(),i=ie(),l=JSON.stringify(t),d=(0,Q.useMemo)(()=>({id:e,dims:t}),[e,l]),{result:c,arm:s,source:a}=et(e,d),p=(0,Q.useMemo)(()=>typeof c=="string"?{}:c,[s]);if(I()&&!zn.has(e)){zn.add(e);let o=(0,qn.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),m=Object.values(t).reduce((v,f)=>v*f.length,1);o.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} 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 ${o.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,Q.useEffect)(()=>Se({id:e,dims:t}),[e]);let h=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{!r||a==="baseline"||a==="seeded"||a==="override"||h.current===s||(h.current=s,le(r,i,e,s))},[r,i,e,s,a]);let A=n==null?void 0:n.funnel;(0,Q.useEffect)(()=>{var o;!r||!A||a==="override"||ve(r,i,e,A,q((o=n==null?void 0:n.goal)!=null?o:"click"))},[r,i,e,A,u,a]),(0,Q.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||a==="override"||a==="baseline"||a==="seeded")return;let o=document.querySelector(`[data-sentient-slot="${jr(e)}"]`);if(!o){I()&&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 m=ae(n.goal),v=ne(n.goal),f=!1;return re(o,q(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,m,{value:v}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:s},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,C,O)=>{r.componentGoal(e,b,{reward:C}),r.goal(b,{metadata:{componentId:e,arm:s},weight:C,stepIndex:O})}},m)},[r,e,u,s,a]);let w=(0,Q.useMemo)(()=>{let o={"data-sentient-slot":e};for(let[m,v]of Object.entries(p))o[`data-${m}`]=v;return o},[e,p]);return{tokens:p,props:w}}var Ae=require("react");var Zn=new Set;function Qn(e,t){var A;if(I()&&!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:l,goalLabel:d,ref:c,nodeRef:s}=He(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),a=(A=i!=null?i:r[0])!=null?A:"",p=t.variants[a];(0,Ae.useEffect)(()=>{if(!I()||!n)return;let w=setTimeout(()=>{!s.current&&!Zn.has(e)&&(Zn.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(w)},[n,e]);let u=(0,Ae.useCallback)((w,o)=>{var v,f;if(l)return;let m=w!=null?w:d;m&&(n==null||n.componentGoal(e,m,o),n==null||n.goal(m,y(y(y({metadata:(v=o==null?void 0:o.metadata)!=null?v:{},weight:(f=o==null?void 0:o.reward)!=null?f:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{})))},[n,e,d,l]),h=(0,Ae.useMemo)(()=>({ref:c,"data-sentient-id":e,"data-sentient-variant":a}),[c,e,a]);return{variant:a,value:p,bind:h,fireGoal:u}}var J=require("react");var tr=require("react/jsx-runtime"),tt=new Set;function er(e){var v;let t=F(),n=ie(),r=(0,J.useRef)(null),i=Object.keys(e.arrangements).join(" "),l=(0,J.useMemo)(()=>Object.keys(e.arrangements),[i]),d=(0,J.useMemo)(()=>y({id:e.id,arms:l},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,l,e.baseline]),{arm:c,source:s}=et(e.id,d);I()&&e.baseline!==void 0&&e.baseline!==l[0]&&!tt.has(e.id+":baseline")&&(tt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${l[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let a=J.Children.toArray(e.children).filter(J.isValidElement),p=new Map;for(let f of a)p.set(String((v=f.key)!=null?v:"").replace(/^\.\$/,""),f);let u=e.arrangements[c],h=u!==void 0&&u.length===a.length&&u.every(f=>p.has(f));I()&&u!==void 0&&!h&&!tt.has(e.id+":keys")&&(tt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${c}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let A=h?u.map(f=>p.get(f)):a;(0,J.useEffect)(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=(0,J.useRef)(null);(0,J.useEffect)(()=>{!t||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,le(t,n,e.id,c))},[t,n,e.id,c,s]);let o=e.funnel;(0,J.useEffect)(()=>{var f;!t||!o||s==="override"||ve(t,n,e.id,o,q((f=e.goal)!=null?f:"click"))},[t,n,e.id,o,s]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,J.useEffect)(()=>{if(!t||e.goal===void 0||s==="override"||s==="baseline"||s==="seeded")return;let f=r.current;if(!f)return;let b=ae(e.goal),C=ne(e.goal),O=!1;return re(f,q(e.goal),{fireGoal:()=>{O||(O=!0,C!==void 0?t.componentGoal(e.id,b,{value:C}):t.componentGoal(e.id,b),t.goal(b,y({metadata:{componentId:e.id,arm:c},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(T,g,x)=>{t.componentGoal(e.id,T,{reward:g}),t.goal(T,{metadata:{componentId:e.id,arm:c},weight:g,stepIndex:x})}},b)},[t,e.id,m,c,s]),(0,tr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":c,children:A})}var kt=require("@sentientui/core");var Wr=["page","blocks","layoutOrder"],nr=new Map;function rr(e,t){nr.set(e,t)}function Rt(e){return nr.get(e)}function ir(e){var i,l;let t=(l=(i=e.content)!=null?i:Rt(e.page))!=null?l:{},n={};for(let[d,c]of Object.entries(t))Wr.includes(d)||(n[d]=c);let r=D(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function or(e){return`<script type="application/ld+json">${Ct(e)}</script>`}function Ct(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function sr(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
- `}var Zn=require("@sentientui/core"),Yn=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient});
4
+ `}var ar=require("@sentientui/core"),lr=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient,useSessionSegment});
5
5
  //# sourceMappingURL=index.js.map