@sentientui/react 0.41.1 → 0.42.0

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