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