@sentientui/react 0.37.2 → 0.37.4

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/README.md CHANGED
@@ -17,11 +17,13 @@ npx @sentientui/cli init
17
17
  # then follow its printed instructions: wrap your app with <AdaptiveRoot> (or
18
18
  # <AdaptiveProvider>) and mount the generated components/adaptive-example.tsx
19
19
  npm run dev
20
- # open http://localhost:3000?sentient_persona=a, then ?sentient_persona=b — the example adapts
20
+ # open http://localhost:3000?sentient_persona=a, then ?sentient_persona=b — <html data-sentient-persona> follows it
21
21
  ```
22
22
 
23
23
  The CLI installs the package, writes `.env.local`, and generates an example component — it does
24
- **not** edit your layout, so nothing adapts until you do the wrap-and-mount step it prints.
24
+ **not** edit your layout, so nothing adapts until you do the wrap-and-mount step it prints. The
25
+ example hero itself looks the same under both personas: it shows your original until a version
26
+ is published from the dashboard, which needs a real key.
25
27
 
26
28
  With no API key the SDK runs in keyless **local mode**: deterministic simulated decisions, zero
27
29
  network. Add a `pk_…` key from [sentient-ui.com](https://sentient-ui.com) to learn from real
@@ -77,8 +79,7 @@ stored on the visitor's device, which has to wait for consent. `AdaptiveRoot` do
77
79
  ### Rung 0 — Observe
78
80
 
79
81
  Install is the integration. The dashboard immediately shows who is arriving: persona mix, device
80
- and traffic-source segments, engagement signals. The "Suggested next step" card tells you which
81
- rung to climb next, with a copy-pasteable snippet.
82
+ and traffic-source segments, engagement signals.
82
83
 
83
84
  ### Rung 1 — Style (CSS only)
84
85
 
@@ -89,8 +90,8 @@ data-sentient-persona = <vocabulary key> | unknown
89
90
  data-sentient-confidence = low | medium | high
90
91
  ```
91
92
 
92
- The persona value is a key from the project's persona vocabulary (dashboard → Settings →
93
- Personas) — declared by your app via the `persona` prop, or discovered from behavior. The
93
+ The persona value is a key from the project's persona vocabulary (dashboard → Matrix →
94
+ Audiences) — declared by your app via the `persona` prop, or discovered from behavior. The
94
95
  vocabulary starts empty (every visitor is `unknown` until a persona exists). Renaming a persona in
95
96
  the dashboard keeps the old key resolving as an alias, so existing CSS stays intact.
96
97
 
@@ -228,14 +229,18 @@ Imported from `@sentientui/react/next`.
228
229
  | `registrySlotIds` | `string[]` *(optional)* | The generated-mode `<Adaptive id>`s this page renders. Decides their published versions in the same SSR round trip and serializes the served content into the HTML, so first paint shows the version instead of the original children. Scoped to exactly these ids — an unscoped registry decide would record a trial for every published slot on every page. Omit and the regions decide client-side after mount. |
229
230
  | `sectionTypes` | `Partial<Record<string, SemanticType>>` *(optional)* | What each section is, keyed by `data-sentient-id`: `{ about: 'trust', contact: 'cta' }`. Sections are classified from their content, so declare only the ones it gets wrong — a band with little signal-bearing copy (an "About us" block, a contact form) reads `generic` and is ordered the same for every persona. Any section with a `data-sentient-id` can appear, reorderable or not. Also accepted by `AdaptiveProvider`. |
230
231
  | `apiKey` | `string` | `pk_…` key — used by both the browser SDK and server-side SSR requests. |
231
- | `appOrigin` | `string` *(default `http://localhost:3001`)* | Your app origin (e.g. `https://yourapp.com`). Must be on the project's allowed-origins list. Always set in production. |
232
+ | `slots` | `Array<{ id, dims? \| arms?, baseline? }>` *(optional)* | The `useAdaptiveTokens` / `<AdaptiveGroup>` slots this tree renders. Declaring them decides them in the same SSR round trip, so their values serialize into the server HTML; undeclared ones decide after mount. |
233
+ | `appOrigin` | `string` *(optional)* | Your app origin (e.g. `https://yourapp.com`). Must be on the project's allowed domains. Defaults to `https://<Host header>` in production and `http://localhost:3001` in development — set it explicitly in production. |
234
+ | `searchParams` | page `searchParams` *(optional)* | Pass the page's `searchParams` on landing pages that get ad traffic: a Server Component can't read the request URL, so without it the SSR session carries no `utm_*` or click IDs. |
232
235
  | `context` | `'landing' \| 'ecommerce' \| 'saas' \| 'marketplace'` *(optional, deprecated)* | Unused — the project's type is set in the dashboard. Safe to omit. |
233
- | `persona` | `string` *(optional)* | Declared persona — the role your app already knows for this visitor (e.g. from your auth context). Must be a key in the project's persona vocabulary (dashboard → Settings → Personas); unrecognized values are ignored server-side. Served at full confidence, overriding the inferred persona; forwarded through both SSR paths. Stable for the session — remount to apply a new value. Never a user id or email. |
236
+ | `persona` | `string` *(optional)* | Declared persona — the role your app already knows for this visitor (e.g. from your auth context). Must be a key in the project's persona vocabulary (dashboard → Matrix → Audiences); unrecognized values are ignored server-side. Served at full confidence, overriding the inferred persona; forwarded through both SSR paths. Stable for the session — remount to apply a new value. Never a user id or email. |
234
237
  | `consent` | `boolean` *(default `true`)* | Set `false` to skip SDK init (no cookies, no events). Flip to `true` after the visitor accepts. |
235
238
  | `respectDoNotTrack` | `boolean` *(default `true`)* | Honor the browser's Do Not Track signal. When on and DNT is enabled, the SDK sets no cookies and sends no tracking data (overriding `consent: true`), and `grantConsent()` won't re-enable it. Set `false` to make your own consent gate authoritative. |
236
239
  | `consentFrom` | preset or `{ cookie, value, event }` *(optional)* | Your consent platform — see [Consent management](#consent-management-gdpr). Cookie-based sources are also read on the server, so a consented visitor gets personalized HTML and a non-consented one gets none. |
237
240
  | `timeoutMs` | `number` *(default `1000`)* | Server-side fetch timeout before falling back to the first variant. Typical decide is well under 150 ms; the full budget is only reached on a cold start or an API distant from your SSR host. |
238
241
  | `nonce` | `string` *(optional)* | CSP nonce for the inline pre-paint script and the `<style>` the client injects. |
242
+ | `captureAgents` | `boolean` *(default `true`)* | Logs a known AI-agent fetch (GPTBot, Claude-User, PerplexityBot, …, matched by user-agent) to your agent analytics — machine telemetry only, no cookie or session. Set `false` to opt out. |
243
+ | `agentFeed` | `{ path?, content? }` *(optional)* | Emits a server-rendered JSON-LD block describing the page's winning variants and layout for AI crawlers that don't run JS. Omit to emit nothing. |
239
244
  | `debug` | `boolean` | Log assignment and event activity to the console. |
240
245
 
241
246
  #### What `<AdaptiveRoot>` costs your rendering
@@ -545,7 +550,8 @@ export async function getServerSideProps({ req }) {
545
550
  const { assignments, sessionId } = await loadAdaptiveAssignments(
546
551
  [{ id: 'hero_cta', variantIds: ['control', 'variant_a'] }],
547
552
  {
548
- cookies: req.cookies,
553
+ // Pages Router's req.cookies is a plain object; the helper reads cookies via get(name).
554
+ cookies: { get: (name) => (req.cookies[name] ? { value: req.cookies[name] } : undefined) },
549
555
  apiKey: process.env.NEXT_PUBLIC_SENTIENT_API_KEY!,
550
556
  baseUrl: 'https://api.sentient-ui.com/v1',
551
557
  origin: process.env.NEXT_PUBLIC_APP_URL,
@@ -596,7 +602,7 @@ DOM graph scanning and behavioral engagement capture are **on by default** — n
596
602
 
597
603
  Both modules are loaded on demand after init, so the base bundle stays lean, and neither ever runs for a Do-Not-Track, Global Privacy Control, or consent-gated visitor (see Consent below).
598
604
 
599
- What they cost, so you can decide: about 21 KB gzip on top of the ~16 KB core client, fetched after hydration (never on the critical path). One `MutationObserver` watches the page for sections added later, and it batches a burst of DOM changes into a single scan 200 ms after the burst starts, so a chat or a live list doesn't make it do work on every frame. Turn graph scanning off and the dashboard's page-structure view goes empty. Turn engagement off and audiences stop learning from on-page behaviour.
605
+ What they cost, so you can decide: about 21 KB gzip on top of the ~17 KB core client, fetched after hydration (never on the critical path). One `MutationObserver` watches the page for sections added later, and it batches a burst of DOM changes into a single scan 200 ms after the burst starts, so a chat or a live list doesn't make it do work on every frame. Turn graph scanning off and the dashboard's page-structure view goes empty. Turn engagement off and audiences stop learning from on-page behaviour.
600
606
 
601
607
  Opt out per feature:
602
608
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- "use strict";var dr=Object.create;var Oe=Object.defineProperty,fr=Object.defineProperties,gr=Object.getOwnPropertyDescriptor,mr=Object.getOwnPropertyDescriptors,pr=Object.getOwnPropertyNames,De=Object.getOwnPropertySymbols,yr=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var Et=(e,t,n)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))nt.call(t,n)&&Et(e,n,t[n]);if(De)for(var n of De(t))Pt.call(t,n)&&Et(e,n,t[n]);return e},D=(e,t)=>fr(e,mr(t));var Ve=(e,t)=>{var n={};for(var r in e)nt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&De)for(var r of De(e))t.indexOf(r)<0&&Pt.call(e,r)&&(n[r]=e[r]);return n};var vr=(e,t)=>{for(var n in t)Oe(e,n,{get:t[n],enumerable:!0})},Gt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pr(t))!nt.call(e,i)&&i!==n&&Oe(e,i,{get:()=>t[i],enumerable:!(r=gr(t,i))||r.enumerable});return e};var Fe=(e,t,n)=>(n=e!=null?dr(yr(e)):{},Gt(t||!e||!e.__esModule?Oe(n,"default",{value:e,enumerable:!0}):n,e)),Sr=e=>Gt(Oe({},"__esModule",{value:!0}),e);var Kr={};vr(Kr,{Adaptive:()=>Fn,AdaptiveGroup:()=>er,AdaptiveProvider:()=>ln,AdaptiveSlot:()=>Te,AdaptiveText:()=>Mn,SentientPersonaScript:()=>Jn,buildAgentFeed:()=>ir,consentWatcher:()=>lr.consentWatcher,defineAgentContent:()=>rr,detectSegment:()=>kt.deriveSessionSegment,getAgentContent:()=>Rt,grantConsent:()=>ar.grantConsent,renderAgentJsonLd:()=>or,renderAgentJsonLdBody:()=>Ct,renderAgentMarkdown:()=>sr,renderBlocks:()=>me,renderCompose:()=>Xe,useAdaptive:()=>Qn,useAdaptiveApiBaseUrl:()=>yn,useAdaptiveGoal:()=>Qe,useAdaptivePersona:()=>Xn,useAdaptiveTokens:()=>Yn,useAssignment:()=>Ue,useInitialAssignments:()=>je,useLayoutOrder:()=>dn,usePageGoal:()=>$n,useSentient:()=>F,useSessionSegment:()=>ke});module.exports=Sr(Kr);var _=require("react"),$e=require("@sentientui/core");var Tt=new Map,Me=new Map;function Nt(e,t){let n=Me.get(e);return n||(n=new Set,Me.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Me.delete(e)}}function It(e,t){Tt.set(e,t);let n=Me.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function rt(e){var t;return(t=Tt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Lt(){if(typeof window=="undefined")return hr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function it(){return Lt().on}function Dt(e){let t=Lt().listeners;return t.add(e),()=>{t.delete(e)}}function Vt(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ot="sentient:overrides-changed";function Ft(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function st(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(ot))}function z(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ot,e),()=>window.removeEventListener(ot,e))}function Mt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function I(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function q(e){return typeof e=="string"?{type:"click"}:e}function ae(e){return typeof e=="string"?e:e.type}function ne(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var at=new Set,lt=!1;function Bt(e){if(at.has(e))return!0;if(at.add(e),!lt){lt=!0;let t=()=>{lt=!1,at.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function $t(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(br(r))return!0;r=r.parentElement}return!1}function re(e,t,n,r){if(t.type==="weighted_composite"){let a=new Set,p=[];return t.steps.forEach(({goal:u,name:h,weight:A},w)=>{let o=(m=!1)=>{a.has(w)||m&&r!==void 0&&Bt(`step\0${h}\0${A}\0${w}`)||(a.add(w),n.fireStep(h,A,w))};if(u.type==="click"){let m=v=>{let f=v.target;f instanceof Element&&$t(f,e,u.selector)&&o()};e.addEventListener("click",m),p.push(()=>e.removeEventListener("click",m));return}if(u.type==="form_submit"){let m=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&o()};e.addEventListener("submit",m),p.push(()=>e.removeEventListener("submit",m));return}if(u.type==="scroll_depth"){let m=Math.max(0,Math.min(1,u.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=m){o(!0),v.disconnect();break}},{threshold:[m]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let u of p)u()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((a,p)=>p)),d=()=>{r!==void 0&&Bt(r)||n.fireGoal()},c=(a,p=!1)=>{l.delete(a),l.size===0&&(p?d():n.fireGoal())},s=[];return i.forEach((a,p)=>{if(a.type==="click"){let u=h=>{let A=h.target;A instanceof Element&&$t(A,e,a.selector)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("click",u),s.push(()=>e.removeEventListener("click",u));return}if(a.type==="form_submit"){let u=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("submit",u),s.push(()=>e.removeEventListener("submit",u));return}if(a.type==="scroll_depth"){let u=Math.max(0,Math.min(1,a.threshold)),h=new IntersectionObserver(A=>{for(let w of A)if(w.intersectionRatio>=u){t.type==="composite"?c(p,!0):d(),h.disconnect();break}},{threshold:[u]});h.observe(e),s.push(()=>h.disconnect());return}}),()=>{for(let a of s)a()}}var jt=new Set,Wt=new Set;function ve(e,t,n,r,i){let l=`${r}|${n}`;if(Wt.has(l))return;Wt.add(l);let d=i.type==="weighted_composite"&&!jt.has(r);d&&jt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:d?{funnelId:r,steps:i.steps.map(c=>({goalId:c.name,weight:c.weight}))}:{funnelId:r}})}function le(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var xr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function de(){if(typeof window=="undefined")return xr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function Ee(){de().version+=1;for(let e of de().listeners)e()}var Kt=()=>{};function Jt(e){return I()?(de().components.set(e.id,e),Ee(),()=>{de().components.delete(e.id),Ee()}):Kt}function Se(e){return I()?(de().slots.set(e.id,e),Ee(),()=>{de().slots.delete(e.id),Ee()}):Kt}function ut(e){I()&&(de().sections=[...e],Ee())}var Ut="0.37.2",ct=Ut!=="0.0.0-dev"?{name:"react",version:Ut}:void 0;function wr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){wr()[e]=t}function Ht(e){window.__sentient_vocabulary_override=e}function Xt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function kr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){kr()[e]=t}function zt(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let l=n.slice(0,r.index)+i;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var ft="__snt_editor_token",xe=null,dt=!1;function qt(){return dt}function Rr(){try{return sessionStorage.getItem(ft)}catch(e){return null}}function Be(e){if(xe)return xe;let t=typeof window=="undefined"?null:zt("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Rr();return dt=!!n,xe=Promise.resolve(n?{token:n,fresh:!1}:null),xe}return dt=!0,xe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(ft,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),xe}function Yt(){try{sessionStorage.removeItem(ft)}catch(e){}}var Zt="sentient_preview_cell",Qt="sentient_refresh_region",gt="sentient-cell-preview-bar",fe="__preview__",we=null;function en(e){if((we==null?void 0:we.slotId)!==e)return null;let t=we;return we=null,t}function tn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))})}).then(n=>ge(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ge("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function nn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(gt))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(Zt),n=s.get(Qt)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Be(r);if(!qt())return;if(n){we={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,fe),st();return}if(!t)return;let l=t.lastIndexOf("~");if(l<=0)return;let d=t.slice(0,l),c=t.slice(l+1);i.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(d)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${s.token}`}}):(ge(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){ge(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&Ht(a.vocabulary),a.compose!=null)he(d,{kind:"arms",compose:{[fe]:a.compose}}),be(d,fe);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))he(d,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),be(d,fe);else if(a.blocks!=null)he(d,{kind:"arms",blocks:{[fe]:a.blocks}}),be(d,fe);else if(a.content!=null)he(d,{kind:"arms",content:a.content}),be(d,fe);else{ge("Nothing to preview in that square yet.");return}st(),ge(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${d}"]`))==null||p.scrollIntoView({block:"center"})}catch(u){}},300)}).catch(()=>ge("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ge(e){var i;if(document.getElementById(gt))return;let t=document.createElement("div");t.id=gt,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{Yt();let l=new URL(window.location.href);l.searchParams.delete(Zt),l.searchParams.delete(Qt),window.location.assign(l.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var rn=!1;function on(e){if(rn||typeof window=="undefined")return;rn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Be(t).then(n=>{!n||!("token"in n)||!n.fresh||Cr(t,n.token)})}function Cr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var vn=require("react/jsx-runtime");function Ar(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,$e.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var an="https://api.sentient-ui.com/v1",K=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:an,debug:!1}),sn=!1,mt=new Set;function _r(e,t,n){let r=(0,_.useRef)(n);r.current=n;let[i,l]=(0,_.useState)(null),[d,c]=(0,_.useState)(!1),s=(0,_.useRef)(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(D(y({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,_.useEffect)(()=>{let p=s.current;if(p===void 0||typeof window=="undefined")return;let u,h=!1;return import("@sentientui/core/consent").then(({consentWatcher:A,forgetVisitor:w})=>{if(h)return;let o=A(typeof p=="object"&&p.cmp===void 0&&p.check?y(D(y({},p),{check:()=>s.current.check()}),p.refused?{refused:()=>{var f,b;return((b=(f=s.current).refused)==null?void 0:b.call(f))===!0}}:{}):p),m=!1,v=()=>{let f=o.refused()&&o.read()!==!0;f&&!m&&(w(t),r.current()),m=f,c(f);let b=o.read();b!==null&&mt.add(t),l(b!=null?b:mt.has(t)?!1:null)};v(),u=o.subscribe(v)}),()=>{h=!0,u==null||u()}},[a,t]),{granted:i,refused:d}}function ln(e){var C,O,T;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:Ar()}),[i,l]=(0,_.useState)(it());(0,_.useEffect)(()=>Dt(()=>l(it())),[]),(0,_.useEffect)(()=>{nn(e.apiBaseUrl),on(e.apiBaseUrl)},[]);let d=(0,_.useRef)(()=>{}),c=_r(e.consentFrom,e.apiKey,()=>d.current()),s=e.consentFrom?(C=c.granted)!=null?C:mt.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?c.refused:!0,p=(0,_.useRef)(a);p.current=a;let u=(0,_.useRef)(null),h=(0,_.useRef)(!1),A=(0,_.useRef)([]),w=(0,_.useRef)(!1);d.current=()=>{var x;A.current=[],w.current=!0;let g=u.current;g!=null&&g.gated?g.dispose():(x=g==null?void 0:g.takeHeld)==null||x.call(g)},(0,_.useEffect)(()=>{var U,ee;if(p.current&&s===!1&&(A.current=[]),s===!1&&h.current&&(p.current&&((U=u.current)==null||U.destroy()),u.current=null,h.current=!1),s===!1&&!e.preConsentBehavior){p.current&&((ee=u.current)==null||ee.destroy()),u.current=null,n(null);return}let g=s!==!1;g&&(w.current=!1);let x=V=>{!g&&w.current&&V.gated&&V.dispose()},S=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},ct?{sdk:ct}:{}),k=!1,R=null,G=null,P=V=>{for(let j of A.current.splice(0))setTimeout(()=>{if(u.current!==V){w.current||A.current.push(j);return}try{j(V)}catch(se){}},0)},B=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:j})=>{k||(G=j(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{k||(R=V(D(y({},S),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),x(R),u.current=R,h.current=g,P(R),n(R),B(R))}):(R=(0,$e.init)(S),x(R),u.current=R,h.current=g,P(R),n(R),B(R)),()=>{var V,j;k=!0,G==null||G(),A.current=A.current.concat((j=(V=R==null?void 0:R.takeHeld)==null?void 0:V.call(R))!=null?j:[]),R==null||R.dispose()}},[s]),(0,_.useEffect)(()=>{if(!t)return;let g=!1,x=async()=>{if(g)return;let k;try{k=await t.fetchWeights()}catch(R){return}if(!g)for(let R of k){let G={componentId:R.componentId,updatedAt:R.updatedAt,variants:R.variants.map(P=>{var B;return{variantId:P.variantId,pulls:P.pulls,avgReward:(B=P.avgReward)!=null?B:0}})};It(R.componentId,G)}};x();let S=setInterval(()=>{x()},6e4);return()=>{g=!0,clearInterval(S)}},[t]);let o=(O=e.ssrFallback)!=null?O:"first",m=((T=e.apiBaseUrl)!=null?T:an).replace(/\/$/,""),v=(0,_.useRef)(null);(0,_.useEffect)(()=>{var S;if(typeof process!="undefined"&&((S=process.env)==null?void 0:S.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:m},x=v.current;if(v.current=g,x!==null)for(let k of["apiKey","context","country","persona","apiBaseUrl"])Object.is(x[k],g[k])||console.warn(`[sentient] AdaptiveProvider: \`${k}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,m]),(0,_.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||Mt({apiKey:e.apiKey,apiBaseUrl:m,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,m]),(0,_.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){ut(g);return}e.declaredSections&&e.declaredSections.length>0&&ut(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{!I()||e.consent!==void 0||e.consentFrom!==void 0||sn||(sn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,_.useEffect)(()=>{if(!I())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let x=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),k=>k.getAttribute("data-sentient-id"))),S=g.filter(k=>!x.has(k));S.length>0&&console.warn(`[SentientUI] Declared section${S.length>1?"s":""} ${S.map(k=>`"${k}"`).join(", ")} ${S.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let f=(0,_.useMemo)(()=>t&&i?Vt(t):t,[t,i]),b=(0,_.useMemo)(()=>{var g,x,S,k,R,G,P,B;return{client:f,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(x=e.initialLayoutOrder)!=null?x:null,initialSlots:(S=e.initialSlots)!=null?S:{},initialSlotConfig:(k=e.initialSlotConfig)!=null?k:{},initialPalette:(R=e.initialPalette)!=null?R:null,initialVocabulary:(G=e.initialVocabulary)!=null?G:null,initialPersona:(P=e.initialPersona)!=null?P:null,apiBaseUrl:m,debug:(B=e.debug)!=null?B:!1}},[f,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,m,e.debug]);return(0,vn.jsx)(K.Provider,{value:b,children:e.children})}function F(){return(0,_.useContext)(K).client}function ie(){return(0,_.useContext)(K).apiKey}function je(){return(0,_.useContext)(K).initialAssignments}function ke(){return(0,_.useContext)(K).sessionSegment}function un(){return(0,_.useContext)(K).ssrFallback}function We(){return(0,_.useContext)(K).onAssignment}function cn(){return(0,_.useContext)(K).debug}function dn(){let e=(0,_.useContext)(K).initialLayoutOrder,t=(0,_.useSyncExternalStore)(z,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ke(){return(0,_.useContext)(K).initialSlots}function fn(){return(0,_.useContext)(K).initialPersona}function gn(){return(0,_.useContext)(K).initialSlotConfig}function mn(){return(0,_.useContext)(K).initialPalette}function pn(){return(0,_.useContext)(K).initialVocabulary}function yn(){return(0,_.useContext)(K).apiBaseUrl}var Ce=require("react");var M=require("react"),Sn=require("@sentientui/core");var Y=require("react"),Je=require("@sentientui/policy");function Re(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let l=i.indexOf(":");if(l!==-1&&i.slice(0,l)===e)return i.slice(l+1)}}catch(r){}return null}function Ue(e,t,n,r){let i=je(),l=un(),d=F(),c=ke(),s=We(),a=cn(),p=(0,Y.useRef)(null),u=(0,Y.useSyncExternalStore)(z,()=>Re(e),()=>null),h=u&&t.includes(u)?u:null,A=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{a&&h&&A.current!==h&&(A.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[a,h,e]);let[w,o]=(0,Y.useState)(()=>{var b,C;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!d){let O=i[e];return O&&t.includes(O)?{variantId:O,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content))return{variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0};let f=rt(e);if(f){let O=(0,Je.pickFromWeights)(f.variants,t);if(O)return{variantId:O,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),m=v=>{s&&p.current!==v&&(p.current=v,s(e,v))};return(0,Y.useEffect)(()=>{var b;if(h||!d)return;let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content)){o({variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0}),m(v.variantId);return}let f=rt(e);if(f&&w.settled&&w.variantId&&w.variantId===(0,Je.pickFromWeights)(f.variants,t)){m(w.variantId);return}o(C=>{var O;return C.variantId?C:{variantId:(O=t[0])!=null?O:null,content:null,isLoading:!1,settled:!1}})},[h,d,e,c]),(0,Y.useEffect)(()=>{if(h||!d)return;let v=d.getAssignment(e,c);if(v&&t.includes(v.variantId))return;let f=!1;return d.assign(e,t,n,r).then(b=>{var C;f||b&&(!t.includes(b.variantId)&&!b.content||(o({variantId:b.variantId,content:(C=b.content)!=null?C:null,isLoading:!1,settled:!0}),m(b.variantId)))}),()=>{f=!0}},[h,d,e,c]),(0,Y.useEffect)(()=>{if(!h&&d)return Nt(e,v=>{var C;let f=d.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){o({variantId:f.variantId,content:(C=f.content)!=null?C:null,isLoading:!1,settled:!0}),m(f.variantId);return}let b=(0,Je.pickFromWeights)(v.variants,t);b&&(o({variantId:b,content:null,isLoading:!1,settled:!0}),m(b))})},[h,d,e,c]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}function He(e,t,n){let r=F(),i=ie(),l=Object.keys(t).join("\0"),d=(0,M.useMemo)(()=>Object.keys(t),[l]),{variantId:c,content:s,isOverride:a=!1,settled:p}=Ue(e,d,n.agentData,n.agentDataByVariant),[u,h]=(0,M.useState)(null),A=(0,M.useRef)(null),w=(0,M.useCallback)(k=>{A.current=k,h(k)},[]),o=n.goal,m=typeof o=="string"?o:JSON.stringify(o),v=(0,M.useMemo)(()=>o?q(o):null,[m]),f=o?ae(o):"";(0,M.useEffect)(()=>Jt({id:e,variantIds:d,goal:f}),[e,d,f]);let b=(0,M.useRef)(null);(0,M.useEffect)(()=>{a||p&&(!r||!c||!i||!u||b.current!==c&&(b.current=c,le(r,i,e,c)))},[r,c,i,e,u,a,p]);let C=(0,M.useRef)(!1),O=(0,M.useRef)(new Set);(0,M.useEffect)(()=>{C.current=!1,O.current=new Set},[c,v]);let T=n.funnel;(0,M.useEffect)(()=>{a||!p||!r||!T||!v||ve(r,i,e,T,v)},[r,i,e,T,v,a,p]);let g=n.cursorSignal===!0;(0,M.useEffect)(()=>{if(!g||a||!p||!r||!c||!u)return;let k=null,R=0,G=()=>{R=Date.now(),k=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),k=null},800)},P=()=>{k!==null&&(clearTimeout(k),k=null)};return u.addEventListener("mouseenter",G),u.addEventListener("mouseleave",P),()=>{u.removeEventListener("mouseenter",G),u.removeEventListener("mouseleave",P),k!==null&&clearTimeout(k)}},[g,r,c,i,e,u,a,p]);let x=(0,M.useRef)(n.microSignalGoals);x.current=n.microSignalGoals;let S=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,M.useEffect)(()=>{if(a||!p||!r||!c||!u)return;let k=Date.now();return(0,Sn.attachMicroSignalDetectors)((R,G={})=>{var V,j,se;r.track({projectId:i,componentId:e,variantId:c,eventType:"micro_signal",payload:y({signalType:R},G)});let P=(V=x.current)==null?void 0:V[R];if(!P||O.current.has(R))return;O.current.add(R);let B=typeof P=="string"?P:P.name,U=typeof P=="string"?1:(j=P.weight)!=null?j:1,ee=typeof P=="string"?0:(se=P.stepIndex)!=null?se:0;r.goal(B,{metadata:y({signalType:R},G),weight:U,stepIndex:ee})},u,k)},[r,c,i,e,u,S,a,p]),(0,M.useEffect)(()=>{if(a||!p||!r||!c||!u||!v)return;let k=ne(v);return re(u,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:f,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),r.goal(f,y({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(R,G,P)=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:R,payload:{reward:G}}),r.goal(R,{metadata:{},weight:G,stepIndex:P})}},f)},[r,c,i,e,u,v,f,a,p]),{client:r,variantIds:d,variantId:c,content:s,settled:p,isOverride:a,goalLabel:f,ref:w,nodeRef:A}}var $=require("react"),Ge=require("@sentientui/core"),wt=require("@sentientui/core/region");var H=require("react"),bn=require("@sentientui/core");var hn=new Set;function xn(e,t){var C,O,T;let n=F(),r=(0,H.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,H.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let l=(0,H.useRef)(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Ke(),c=gn(),s=mn(),a=pn(),p=(0,H.useSyncExternalStore)(z,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_config_overrides)==null?void 0:g[e]:void 0},()=>{}),u=(0,H.useSyncExternalStore)(z,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_overrides)==null?void 0:g[e]:void 0},()=>{}),h=g=>g==null?"":(0,bn.armOfResult)(g),A=(0,H.useCallback)(g=>{var x,S;return(S=(x=n==null?void 0:n.onSlotsChanged)==null?void 0:x.call(n,g))!=null?S:(()=>{})},[n]);(0,H.useSyncExternalStore)(A,()=>{var g;return(g=n==null?void 0:n.getSlotConfig(e))!=null?g:null},()=>null),(0,H.useSyncExternalStore)(A,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let w=p===void 0?c[e]:void 0,o=p===void 0&&w===void 0&&n?n.getSlotConfig(e):null,m=(C=s!=null?s:n==null?void 0:n.getSitePalette())!=null?C:null,v=(T=a!=null?a:(O=n==null?void 0:n.getStyleVocabulary)==null?void 0:O.call(n))!=null?T:null,f=(()=>{var g,x,S;if(p!==void 0)return{config:p,arm:h(u),palette:m,vocabulary:(g=Xt())!=null?g:v,source:"override"};if(w!==void 0)return{config:w,arm:h((x=d[e])!=null?x:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:v,source:"preloaded"};if(o!==null){let k=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:o,arm:h((S=n==null?void 0:n.getSlotResult(e))!=null?S:d[e]),palette:m,vocabulary:v,source:k?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:v,source:"none"}})(),b=f.source==="preloaded"||f.source==="override";return(0,H.useEffect)(()=>{var B,U,ee,V,j;if(!n||n.isLocal===!0||b)return;let g=f.source==="none",x=g&&(U=(B=r.current)==null?void 0:B.call(r))!=null?U:null,S=x!=null&&x!==""?{[e]:x}:void 0,k=(ee=i.current)==null?void 0:ee.call(i),R=g&&(j=(V=l.current)==null?void 0:V.call(l))!=null?j:null,G=y(y({},k?{render:{[e]:k}}:{}),R?{skeletons:{[e]:R}}:{}),P=Object.keys(G).length>0;return n.requestSlots?P?n.requestSlots([e],S,G):S?n.requestSlots([e],S):n.requestSlots([e]):g&&(R?n.reportSlots([e],S!=null?S:{},{[e]:R}):S?n.reportSlots([e],S):n.reportSlots([e])),()=>{var se;return(se=n.cancelSlots)==null?void 0:se.call(n,[e])}},[n,b,f.source,e]),(0,H.useEffect)(()=>{!I()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||hn.has(e)||(hn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var Pe=require("react");var L=require("react/jsx-runtime");function pt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ue={none:"0",sm:"8px",md:"16px",lg:"24px"},yt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Cn={sm:"0.875em",md:"1em",lg:"1.25em"},Or={sm:"1.25em",md:"1.5em",lg:"2em"},wn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},kn={sm:"8px",md:"16px",lg:"32px"},Er={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Pr={normal:"400",medium:"500",bold:"700"};function Rn(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function An(e,t,n){var i,l,d,c;let r=t==null?void 0:t.accent;return D(y({display:"inline-block",padding:(i=wn[n!=null?n:"md"])!=null?i:wn.md,borderRadius:(l=t==null?void 0:t.radius)!=null?l:"8px",font:"inherit"},n?{fontSize:Cn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(d=t==null?void 0:t.primaryBg)!=null?d:"#111827":"transparent",color:e==="primary"?(c=t==null?void 0:t.primaryText)!=null?c:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Gr({node:e,opts:t}){var i,l,d,c,s;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(d=(l=t.palette)==null?void 0:l.border)!=null?d:"currentColor"}`,borderRadius:(s=(c=t.palette)==null?void 0:c.radius)!=null?s:"8px"};return(0,L.jsxs)("form",{onSubmit:a=>{var h,A,w;a.preventDefault();let p=new FormData(a.currentTarget),u={};for(let o of e.fields)u[o.name]=String((h=p.get(o.name))!=null?h:"");(A=t.onFormGoal)==null||A.call(t,e.submitGoal);try{(w=t.onFormSubmit)==null||w.call(t,u)}catch(o){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(a=>{var p,u;return(0,L.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[a.label,a.kind==="textarea"?(0,L.jsx)("textarea",{name:a.name,required:a.required,placeholder:a.placeholder,rows:3,style:r}):a.kind==="select"?(0,L.jsx)("select",{name:a.name,required:a.required,style:r,children:((p=a.options)!=null?p:[]).map(h=>(0,L.jsx)("option",{value:h,children:h},h))}):(0,L.jsx)("input",{name:a.name,type:(u=a.inputType)!=null?u:"text",required:a.required,placeholder:a.placeholder,style:r})]},a.name)}),(0,L.jsx)("button",{type:"submit",style:An(n,t.palette),children:e.submitLabel})]})}function Tr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(l=>l.id===n))==null?void 0:i.classes:void 0}function _n(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function me(e,t){var i;let n=Nr(e,t),r=_n(e.like,t);return n&&r?(0,Pe.cloneElement)(n,{style:D(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Nr(e,t){var n,r,i,l,d,c,s,a,p,u,h,A,w,o,m,v,f,b,C,O,T,g,x;try{let S=Tr(e,t);switch(e.type){case"stack":{let k=(r=ue[(n=e.gap)!=null?n:"md"])!=null?r:ue.md,R=e.surface==="raised"&&!S,G=(i=e.pad)!=null?i:R?"md":void 0;return(0,L.jsx)("div",D(y({},S?{className:S}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:yt[e.align]}:{}),e.justify?{justifyContent:yt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),G?{padding:(l=ue[G])!=null?l:ue.md}:{}),R?D(y(y({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(c=t.palette)!=null&&c.surface&&((s=t.palette)!=null&&s.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(a=t.palette)==null?void 0:a.border)!=null?p:"currentColor"}`,borderRadius:(h=(u=t.palette)==null?void 0:u.radius)!=null?h:"8px"}):{}),children:((A=e.children)!=null?A:[]).map((P,B)=>{let U=me(P,t);return U===null?null:(0,L.jsx)(Pe.Fragment,{children:U},B)})}))}case"grid":{let k=(o=ue[(w=e.gap)!=null?w:"md"])!=null?o:ue.md;return(0,L.jsx)("div",D(y({},S?{className:S}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:yt[e.align]}:{}),e.pad?{padding:(m=ue[e.pad])!=null?m:ue.md}:{}),children:((v=e.children)!=null?v:[]).map((R,G)=>{let P=me(R,t);return P===null?null:(0,L.jsx)(Pe.Fragment,{children:P},G)})}))}case"text":return S?(0,L.jsx)("p",{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:Cn[e.size]}:{}),e.weight?{fontWeight:Pr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Rn(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return S?(0,L.jsx)(k,{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)(k,{style:y(y({margin:0,fontSize:Or[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(b=e.emphasis)!=null?b:"primary";return(0,L.jsx)("a",D(y(y({href:pt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:An(k,t.palette,e.size)}),{children:e.label}))}case"link":return(0,L.jsx)("a",D(y(y({href:pt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,L.jsx)("img",D(y({src:pt(e.src),alt:e.alt},S?{className:S}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Er[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return S?(0,L.jsx)("span",{className:S,children:e.value}):(0,L.jsx)("span",{style:y({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(O=(C=t.palette)==null?void 0:C.border)!=null?O:"currentColor"}`},Rn(e.tone,t.palette)),children:e.value});case"spacer":return(0,L.jsx)("div",{style:{height:(T=kn[e.size])!=null?T:kn.md}});case"divider":return(0,L.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(x=(g=t.palette)==null?void 0:g.border)!=null?x:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,L.jsx)(Gr,{node:e,opts:t});default:return null}}catch(S){return null}}function Xe(e,t){var l,d,c,s;let n=me(e.tree,t);if(n===null)return null;let r=(l=e.surface)!=null&&l.like?(c=(d=t.vocabulary)==null?void 0:d.entries.find(a=>a.id===e.surface.like))==null?void 0:c.classes:void 0,i=_n((s=e.surface)==null?void 0:s.like,t);return r?(0,L.jsx)("div",D(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}var oe=require("react"),ze=require("@sentientui/core/region");function qe(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Ye(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function pe(e){return qe(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+pe(n),0):(0,oe.isValidElement)(e)?pe(Ye(e)):0}function Ir(e,t){return Array.isArray(t)?(0,oe.cloneElement)(e,void 0,...t):(0,oe.cloneElement)(e,void 0,t)}function vt(e,t){if(qe(e))return t;if(Array.isArray(e))return e.map(n=>vt(n,t));if((0,oe.isValidElement)(e)){let n=Ye(e);return pe(n)===0?e:Ir(e,vt(n,t))}return e}function On(e,t){return pe(e)===1?vt(e,t):null}var X=e=>e.join("/");function St(e,t,n){if(qe(e)){n.leafPaths.push(t),n.texts.push((0,ze.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>St(r,[...t,i],n));return}(0,oe.isValidElement)(e)&&(n.elements.set(X(t),e),St(Ye(e),[...t,"c"],n))}function bt(e){let t={leafPaths:[],texts:[],elements:new Map};return St(e,[],t),t}function Lr(e){return bt(e).texts}function En(e){let t=Lr(e);return t.length===0?null:(0,ze.skeletonFingerprint)(t)}function Dr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Pn(e,t){let n=t.reduce((i,l)=>Math.max(i,l+1),0),r=[];for(let i=0;i<n;i++){let l=t.flatMap((c,s)=>c===i?[Dr(e.leafPaths[s])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let c of l.slice(1)){let s=new Set(c.map(X));d=d.filter(a=>s.has(X(a)))}r.push(d.length>0?d[d.length-1]:null)}return r}function ht(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function xt(e,t){let n=bt(t);if(n.texts.length!==e.leaves.length||n.texts.some((l,d)=>l!==e.leaves[d]))return null;let r=Pn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let c=r[d],s=c?n.elements.get(X(c)):void 0,a=!!s&&(typeof s.type=="string"||ht(s)!==void 0);return D(y({},l),{restylable:a})});return D(y({},e),{nodes:i})}function Gn(e,t,n){var w;let r=bt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((o,m)=>Math.max(o,m+1),0);for(let o of Object.keys(t.nodes))if(!/^\d+$/.test(o)||Number(o)>=i)return null;let l=Pn(r,n),d=new Map;n.forEach((o,m)=>{d.has(o)||d.set(o,m)});let c=new Map(r.leafPaths.map((o,m)=>[X(o),m])),s=new Set,a=new Map,p=!1;for(let[o,m]of Object.entries(t.nodes)){let v=Number(o),f=l[v];if(m.hidden&&(f?s.add(X(f)):p=!0),m.like!==void 0){let b=l[m.like],C=f?r.elements.get(X(f)):void 0,O=b?ht(r.elements.get(X(b))):void 0;!f||O===void 0||ht(C)===void 0?p=!0:a.set(X(f),O)}}let u=new Map(Object.entries((w=t.order)!=null?w:{})),h=(o,m)=>{var v;if(qe(o)){let f=c.get(X(m));if(f===void 0)return o;let b=n[f],C=(v=t.nodes[String(b)])==null?void 0:v.text;return C===void 0?o:d.get(b)===f?C:""}if(Array.isArray(o)){let f=o.map((b,C)=>h(b,[...m,C]));for(let[b,C]of u){let O=C.map(x=>{let S=l[x];return!S||S.length!==m.length+1||X(S.slice(0,-1))!==X(m)?-1:S[S.length-1]});if(O.some(x=>x<0))continue;let T=[...O].sort((x,S)=>x-S),g=[...f];T.forEach((x,S)=>{f[x]=g[O[S]]}),u.delete(b)}return f}if((0,oe.isValidElement)(o)){let f=X(m);if(s.has(f))return null;let b=Ye(o);if(pe(b)===0)return o;let C=h(b,[...m,"c"]),O=a.get(f),T=O!==void 0?{className:O}:void 0;return Array.isArray(C)?(0,oe.cloneElement)(o,T,...C):(0,oe.cloneElement)(o,T,C)}return o},A=h(e,[]);return p||u.size>0?null:A}var Dn=require("react/jsx-runtime"),Tn=new Set,Nn=new Set,In=new Set,Ln="authored.";function Te({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,as:d="div",reportBaselineText:c=!0}){var At,_t;let s=F(),a=ie(),p=(0,$.useRef)(null),u=(0,$.useMemo)(()=>En(t),[t]),h=n?Object.keys(n).join("|"):"",A=(0,$.useMemo)(()=>y({fp:u!=null?u:"0000000000000000",forms:!!r,compose:!0,content:pe(t)===1},h!==""?{authored:h.split("|"),children:!0}:{}),[u,t,r,h]),w=()=>{var te;let E=p.current;if(!E||!c)return null;let N=(0,wt.captureRegionSkeleton)(E);return N.skeleton?(te=xt(N.skeleton,t))!=null?te:D(y({},N.skeleton),{editable:!1,nodes:N.skeleton.nodes.map(ce=>D(y({},ce),{restylable:!1}))}):{status:N.reason}},{config:o,arm:m,palette:v,vocabulary:f,source:b}=xn(e,{baselineText:c?()=>{var E,N;return(N=(E=p.current)==null?void 0:E.textContent)!=null?N:null}:void 0,render:()=>A,skeleton:w}),C=m!==""?(At=o==null?void 0:o.blocks)==null?void 0:At[m]:void 0,O=m!==""?(_t=o==null?void 0:o.compose)==null?void 0:_t[m]:void 0,T=(C!==void 0&&(0,Ge.containsFormBlock)(C)||O!==void 0&&(0,Ge.containsFormBlock)(O.tree))&&!r;(0,$.useEffect)(()=>{!T||!I()||Tn.has(e)||(Tn.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[T,e]);let g=E=>{!s||b==="override"||(b!=="seeded"&&s.componentGoal(e,E),s.goal(E,{metadata:{componentId:e,arm:m},weight:1,stepIndex:0}))},x=t,S=!1,k=m.startsWith(Ln)?m.slice(Ln.length):null;if((o==null?void 0:o.blocked)==="variant_history")S=!0;else if(k!==null)n&&Object.prototype.hasOwnProperty.call(n,k)?x=n[k]:S=!0;else if(O!==void 0){let E=T?null:Xe(O,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});E===null?S=!0:x=E}else if(C!==void 0){let E=T?null:me(C,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});E===null?S=!0:x=E}else if((o==null?void 0:o.edits)!==void 0&&b!=="none"){let E=o.edits,N=E.fp===u?Gn(t,E.edits,E.leafToNode):null;N===null?S=!0:x=N}else if((o==null?void 0:o.content)!==void 0&&b!=="none"){let E=On(t,o.content);E===null?S=!0:x=E}let R=S&&C===void 0&&O===void 0&&(o==null?void 0:o.edits)===void 0&&k===null&&(o==null?void 0:o.blocked)===void 0;(0,$.useEffect)(()=>{(o==null?void 0:o.blocked)!=="variant_history"||!I()||In.has(e)||(In.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[o==null?void 0:o.blocked,e]);let G=k!==null&&!S?k:null;(0,$.useEffect)(()=>{var _e;if(!G||!c||!s)return;let E=p.current;if(!E)return;let N=(0,wt.captureRegionSkeleton)(E),te=N.skeleton?xt(N.skeleton,n==null?void 0:n[G]):null,ce=(_e=E.textContent)==null?void 0:_e.trim();s.reportSlots([],void 0,void 0,{[e]:[y(y({key:G},ce?{text:ce}:{}),te?{skeleton:te}:{})]})},[G,s,e]);let P=S&&(o==null?void 0:o.edits)!==void 0&&(b==="preloaded"||b==="client");(0,$.useEffect)(()=>{var E;!P||!(o!=null&&o.edits)||(E=s==null?void 0:s.reportDrift)==null||E.call(s,e,o.edits.fp,u,o.edits.fp===u?"unaddressable":"fp_mismatch")},[P,e,u,s]);let B=x===t;(0,$.useEffect)(()=>{var N;if(!(o!=null&&o.needsSkeleton)||!B)return;let E=w();E&&((N=s==null?void 0:s.reportSkeleton)==null||N.call(s,e,E))},[o==null?void 0:o.needsSkeleton,B,e,s]),(0,$.useEffect)(()=>{if(!B)return;let E=en(e);if(!E)return;let N=w();tn(E,N&&"status"in N?{status:N.status}:{skeleton:N})},[e,B]),(0,$.useEffect)(()=>{!R||!I()||Nn.has(e)||(Nn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[R,e]);let U=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,$.useEffect)(()=>Se({id:e,arms:U===""?void 0:U.split("|")}),[e,U]);let ee=(0,$.useRef)(null);(0,$.useEffect)(()=>{!s||b==="none"||b==="seeded"||b==="override"||m===""||S||ee.current!==m&&(ee.current=m,le(s,a,e,m))},[s,a,e,m,b,S]);let V=b!=="none"&&b!=="seeded"&&!S,j=V?m:"",se=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,$.useEffect)(()=>{if(!s||!i||b==="override")return;let E=p.current;if(!E)return;let N=ae(i),te=ne(i),ce=!1;return re(E,q(i),{fireGoal:()=>{ce||(ce=!0,V&&(te!==void 0?s.componentGoal(e,N,{value:te}):s.componentGoal(e,N)),s.goal(N,y({metadata:{componentId:e,arm:j},weight:1,stepIndex:0},te!==void 0?{value:te}:{})))},fireStep:(_e,Ot,cr)=>{V&&s.componentGoal(e,_e,{reward:Ot}),s.goal(_e,{metadata:{componentId:e,arm:j},weight:Ot,stepIndex:cr})}},N)},[s,e,se,m,b,S,V,j]);let Le=(0,$.useRef)(null);(0,$.useEffect)(()=>{let E=p.current;if(E){if(Le.current===null){Le.current=m;return}Le.current!==m&&(Le.current=m,(0,Ge.reveal)(E))}},[m]);let ur=(0,$.useMemo)(()=>y({"data-sentient-slot":e},m!==""?{"data-sentient-arm":m}:{}),[e,m]);return(0,Dn.jsx)(d,D(y({ref:p,className:l},ur),{children:x}))}var Ne=require("react/jsx-runtime");function Vr(e){var p,u;let{client:t,variantId:n,content:r,ref:i}=He(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=(0,Ce.useState)(!1);(0,Ce.useEffect)(()=>{d(!0)},[]);let c=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!l||!t)||!n)return null;let s=(u=e.variants[n])!=null?u:null,a=s===null?r:null;return I()&&s===null&&a===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ne.jsx)(c,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:a})}var Fr=(0,Ce.memo)(Vr,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Fn(e){if(e.variants===void 0)return(0,Ne.jsx)(Te,y({},e));let t=e;if(t.children!=null){I()&&Mr(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:c,variants:s}=n,a=Ve(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return(0,Ne.jsx)(Te,D(y({},a),{children:t.children,variants:s}))}return(0,Ne.jsx)(Fr,y({},t))}var Vn=new Set;function Mr(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||Vn.has(e.id)||(Vn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}var W=require("react");var Bn=require("react/jsx-runtime");function Mn({id:e,default:t,component:n="span",className:r,goal:i}){var T;let l=F(),d=ie(),c=We(),s=ke(),a=(0,W.useRef)(null),p=(0,W.useRef)(null),u=(0,W.useSyncExternalStore)(z,()=>Re(e),()=>null),[h,A]=(0,W.useState)(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.content)!=null?x:null}),[w,o]=(0,W.useState)(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.variantId)!=null?x:null});(0,W.useEffect)(()=>{if(u||!l)return;let g=l.getAssignment(e,s);if((g==null?void 0:g.content)!==void 0){o(g.variantId),A(g.content);return}let x=!1;return l.assign(e).then(S=>{if(!x){if(!S){I()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}o(S.variantId),S.content&&A(S.content)}}),()=>{x=!0}},[l,e,s,u]),(0,W.useEffect)(()=>{u||!l||!w||!d||a.current!==w&&(a.current=w,l.track({projectId:d,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),c==null||c(e,w))},[l,w,d,e,c,u]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,W.useMemo)(()=>i===void 0?null:q(i),[m]),f=i===void 0?null:typeof i=="string"?i:v.type,b=(0,W.useRef)(!1);(0,W.useEffect)(()=>{b.current=!1},[w,m]),(0,W.useEffect)(()=>{if(u||!l||!w||!d||!v||!f)return;let g=p.current;if(!g)return;let x=ne(v);return re(g,v,{fireGoal:()=>{b.current||(b.current=!0,l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:f,payload:y({reward:1},x!==void 0?{goalValue:x}:{})}),l.goal(f,y({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(S,k,R)=>{l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:S,payload:{reward:k}}),l.goal(S,{metadata:{},weight:k,stepIndex:R})}})},[l,w,d,e,v,f,u]);let C=h!=null?h:t;if(u){let g=l==null?void 0:l.getAssignment(e,s);C=g&&g.variantId===u&&(T=g.content)!=null?T:t}return(0,Bn.jsx)(n,{ref:g=>{p.current=g},className:r,children:C})}var Ze=require("react");function Qe(e){let t=F(),n=(0,Ze.useRef)(new Set);return(0,Ze.useCallback)((r,i)=>{var l,d;if(!Re(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,y(y(y({metadata:(l=i==null?void 0:i.metadata)!=null?l:{},weight:(d=i==null?void 0:i.reward)!=null?d:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var Ie=require("react");function $n(e,t={}){let s=t,{componentId:n}=s,r=Ve(s,["componentId"]),i=F(),l=Qe(n!=null?n:""),d=(0,Ie.useRef)(!1),c=(0,Ie.useRef)(r);c.current=r,(0,Ie.useEffect)(()=>{if(!i||d.current||i.gated)return;d.current=!0;let{metadata:a,reward:p,value:u,currency:h,externalId:A}=c.current;if(n){l(e,c.current);return}i.goal(e,y(y(y({metadata:a!=null?a:{},weight:p!=null?p:1,stepIndex:0},u!==void 0?{value:u}:{}),h!==void 0?{currency:h}:{}),A!==void 0?{externalId:A}:{}))},[i,n,e,l])}var Wn=require("@sentientui/core"),Kn=require("@sentientui/policy"),Un=require("react/jsx-runtime");function jn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Br(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+jn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+jn((0,Kn.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Wn.renderPrePaintScript)(e.apiKey)}function Jn(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,Un.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Br(e)}})}var Q=require("react"),qn=require("@sentientui/policy");var Z=require("react"),ye=require("@sentientui/core"),Hn=require("@sentientui/policy");function et(e,t){let n=F(),r=Ke(),[,i]=(0,Z.useReducer)(u=>u+1,0),l=(0,Z.useSyncExternalStore)(z,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),d=l===void 0?r[e]:void 0,c=l===void 0&&d===void 0&&n?n.getSlotResult(e):null,s=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&c===null;(0,Z.useEffect)(()=>{if(!s||!n)return;let u=!1;return n.decide({slots:[t]}).then(h=>{!u&&h&&i()}),()=>{u=!0}},[n,e,s]);let a=(()=>{if(l!==void 0)return{result:l,arm:(0,ye.armOfResult)(l),source:"override"};if(d!==void 0)return{result:d,arm:(0,ye.armOfResult)(d),source:"preloaded"};if(c!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:c,arm:(0,ye.armOfResult)(c),source:h?"client":"seeded"}}let u=(0,ye.baselineResultFor)(t);return{result:u,arm:(0,ye.armOfResult)(u),source:"baseline"}})(),p=a.source==="preloaded"||a.source==="override";return(0,Z.useEffect)(()=>{var h;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let u=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var A;(A=n.cancelSlots)==null||A.call(n,[e]),u==null||u()}},[n,e,p]),a}function $r(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Xn(){let e=F(),t=fn();(0,Z.useSyncExternalStore)(z,Ft,()=>0);let[n,r]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>r(!0),[]);let i=c=>({persona:c.persona,confidence:c.confidence,band:(0,Hn.confidenceBand)(c.confidence)});if(!n)return t?i(t):null;let l=$r();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var zn=new Set;function jr(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Yn(e,t,n){let r=F(),i=ie(),l=JSON.stringify(t),d=(0,Q.useMemo)(()=>({id:e,dims:t}),[e,l]),{result:c,arm:s,source:a}=et(e,d),p=(0,Q.useMemo)(()=>typeof c=="string"?{}:c,[s]);if(I()&&!zn.has(e)){zn.add(e);let o=(0,qn.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),m=Object.values(t).reduce((v,f)=>v*f.length,1);o.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${o.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,Q.useEffect)(()=>Se({id:e,dims:t}),[e]);let h=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{!r||a==="baseline"||a==="seeded"||a==="override"||h.current===s||(h.current=s,le(r,i,e,s))},[r,i,e,s,a]);let A=n==null?void 0:n.funnel;(0,Q.useEffect)(()=>{var o;!r||!A||a==="override"||ve(r,i,e,A,q((o=n==null?void 0:n.goal)!=null?o:"click"))},[r,i,e,A,u,a]),(0,Q.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||a==="override"||a==="baseline"||a==="seeded")return;let o=document.querySelector(`[data-sentient-slot="${jr(e)}"]`);if(!o){I()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let m=ae(n.goal),v=ne(n.goal),f=!1;return re(o,q(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,m,{value:v}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:s},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,C,O)=>{r.componentGoal(e,b,{reward:C}),r.goal(b,{metadata:{componentId:e,arm:s},weight:C,stepIndex:O})}},m)},[r,e,u,s,a]);let w=(0,Q.useMemo)(()=>{let o={"data-sentient-slot":e};for(let[m,v]of Object.entries(p))o[`data-${m}`]=v;return o},[e,p]);return{tokens:p,props:w}}var Ae=require("react");var Zn=new Set;function Qn(e,t){var A;if(I()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:l,goalLabel:d,ref:c,nodeRef:s}=He(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),a=(A=i!=null?i:r[0])!=null?A:"",p=t.variants[a];(0,Ae.useEffect)(()=>{if(!I()||!n)return;let w=setTimeout(()=>{!s.current&&!Zn.has(e)&&(Zn.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(w)},[n,e]);let u=(0,Ae.useCallback)((w,o)=>{var v,f;if(l)return;let m=w!=null?w:d;m&&(n==null||n.componentGoal(e,m,o),n==null||n.goal(m,y(y(y({metadata:(v=o==null?void 0:o.metadata)!=null?v:{},weight:(f=o==null?void 0:o.reward)!=null?f:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{})))},[n,e,d,l]),h=(0,Ae.useMemo)(()=>({ref:c,"data-sentient-id":e,"data-sentient-variant":a}),[c,e,a]);return{variant:a,value:p,bind:h,fireGoal:u}}var J=require("react");var tr=require("react/jsx-runtime"),tt=new Set;function er(e){var v;let t=F(),n=ie(),r=(0,J.useRef)(null),i=Object.keys(e.arrangements).join(" "),l=(0,J.useMemo)(()=>Object.keys(e.arrangements),[i]),d=(0,J.useMemo)(()=>y({id:e.id,arms:l},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,l,e.baseline]),{arm:c,source:s}=et(e.id,d);I()&&e.baseline!==void 0&&e.baseline!==l[0]&&!tt.has(e.id+":baseline")&&(tt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${l[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let a=J.Children.toArray(e.children).filter(J.isValidElement),p=new Map;for(let f of a)p.set(String((v=f.key)!=null?v:"").replace(/^\.\$/,""),f);let u=e.arrangements[c],h=u!==void 0&&u.length===a.length&&u.every(f=>p.has(f));I()&&u!==void 0&&!h&&!tt.has(e.id+":keys")&&(tt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${c}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let A=h?u.map(f=>p.get(f)):a;(0,J.useEffect)(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=(0,J.useRef)(null);(0,J.useEffect)(()=>{!t||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,le(t,n,e.id,c))},[t,n,e.id,c,s]);let o=e.funnel;(0,J.useEffect)(()=>{var f;!t||!o||s==="override"||ve(t,n,e.id,o,q((f=e.goal)!=null?f:"click"))},[t,n,e.id,o,s]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,J.useEffect)(()=>{if(!t||e.goal===void 0||s==="override"||s==="baseline"||s==="seeded")return;let f=r.current;if(!f)return;let b=ae(e.goal),C=ne(e.goal),O=!1;return re(f,q(e.goal),{fireGoal:()=>{O||(O=!0,C!==void 0?t.componentGoal(e.id,b,{value:C}):t.componentGoal(e.id,b),t.goal(b,y({metadata:{componentId:e.id,arm:c},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(T,g,x)=>{t.componentGoal(e.id,T,{reward:g}),t.goal(T,{metadata:{componentId:e.id,arm:c},weight:g,stepIndex:x})}},b)},[t,e.id,m,c,s]),(0,tr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":c,children:A})}var kt=require("@sentientui/core");var Wr=["page","blocks","layoutOrder"],nr=new Map;function rr(e,t){nr.set(e,t)}function Rt(e){return nr.get(e)}function ir(e){var i,l;let t=(l=(i=e.content)!=null?i:Rt(e.page))!=null?l:{},n={};for(let[d,c]of Object.entries(t))Wr.includes(d)||(n[d]=c);let r=D(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function or(e){return`<script type="application/ld+json">${Ct(e)}</script>`}function Ct(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function sr(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
2
+ "use strict";var dr=Object.create;var Oe=Object.defineProperty,fr=Object.defineProperties,gr=Object.getOwnPropertyDescriptor,mr=Object.getOwnPropertyDescriptors,pr=Object.getOwnPropertyNames,De=Object.getOwnPropertySymbols,yr=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var Et=(e,t,n)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))nt.call(t,n)&&Et(e,n,t[n]);if(De)for(var n of De(t))Pt.call(t,n)&&Et(e,n,t[n]);return e},D=(e,t)=>fr(e,mr(t));var Ve=(e,t)=>{var n={};for(var r in e)nt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&De)for(var r of De(e))t.indexOf(r)<0&&Pt.call(e,r)&&(n[r]=e[r]);return n};var vr=(e,t)=>{for(var n in t)Oe(e,n,{get:t[n],enumerable:!0})},Gt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of pr(t))!nt.call(e,i)&&i!==n&&Oe(e,i,{get:()=>t[i],enumerable:!(r=gr(t,i))||r.enumerable});return e};var Fe=(e,t,n)=>(n=e!=null?dr(yr(e)):{},Gt(t||!e||!e.__esModule?Oe(n,"default",{value:e,enumerable:!0}):n,e)),Sr=e=>Gt(Oe({},"__esModule",{value:!0}),e);var Kr={};vr(Kr,{Adaptive:()=>Fn,AdaptiveGroup:()=>er,AdaptiveProvider:()=>ln,AdaptiveSlot:()=>Te,AdaptiveText:()=>Mn,SentientPersonaScript:()=>Jn,buildAgentFeed:()=>ir,consentWatcher:()=>lr.consentWatcher,defineAgentContent:()=>rr,detectSegment:()=>kt.deriveSessionSegment,getAgentContent:()=>Rt,grantConsent:()=>ar.grantConsent,renderAgentJsonLd:()=>or,renderAgentJsonLdBody:()=>Ct,renderAgentMarkdown:()=>sr,renderBlocks:()=>me,renderCompose:()=>Xe,useAdaptive:()=>Qn,useAdaptiveApiBaseUrl:()=>yn,useAdaptiveGoal:()=>Qe,useAdaptivePersona:()=>Xn,useAdaptiveTokens:()=>Yn,useAssignment:()=>Ue,useInitialAssignments:()=>je,useLayoutOrder:()=>dn,usePageGoal:()=>$n,useSentient:()=>F,useSessionSegment:()=>ke});module.exports=Sr(Kr);var _=require("react"),$e=require("@sentientui/core");var Tt=new Map,Me=new Map;function Nt(e,t){let n=Me.get(e);return n||(n=new Set,Me.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Me.delete(e)}}function It(e,t){Tt.set(e,t);let n=Me.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function rt(e){var t;return(t=Tt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Lt(){if(typeof window=="undefined")return hr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function it(){return Lt().on}function Dt(e){let t=Lt().listeners;return t.add(e),()=>{t.delete(e)}}function Vt(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ot="sentient:overrides-changed";function Ft(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function st(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(ot))}function z(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(ot,e),()=>window.removeEventListener(ot,e))}function Mt(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function I(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function q(e){return typeof e=="string"?{type:"click"}:e}function ae(e){return typeof e=="string"?e:e.type}function ne(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var at=new Set,lt=!1;function Bt(e){if(at.has(e))return!0;if(at.add(e),!lt){lt=!0;let t=()=>{lt=!1,at.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function $t(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(br(r))return!0;r=r.parentElement}return!1}function re(e,t,n,r){if(t.type==="weighted_composite"){let a=new Set,p=[];return t.steps.forEach(({goal:u,name:h,weight:A},w)=>{let o=(m=!1)=>{a.has(w)||m&&r!==void 0&&Bt(`step\0${h}\0${A}\0${w}`)||(a.add(w),n.fireStep(h,A,w))};if(u.type==="click"){let m=v=>{let f=v.target;f instanceof Element&&$t(f,e,u.selector)&&o()};e.addEventListener("click",m),p.push(()=>e.removeEventListener("click",m));return}if(u.type==="form_submit"){let m=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&o()};e.addEventListener("submit",m),p.push(()=>e.removeEventListener("submit",m));return}if(u.type==="scroll_depth"){let m=Math.max(0,Math.min(1,u.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=m){o(!0),v.disconnect();break}},{threshold:[m]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let u of p)u()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((a,p)=>p)),d=()=>{r!==void 0&&Bt(r)||n.fireGoal()},c=(a,p=!1)=>{l.delete(a),l.size===0&&(p?d():n.fireGoal())},s=[];return i.forEach((a,p)=>{if(a.type==="click"){let u=h=>{let A=h.target;A instanceof Element&&$t(A,e,a.selector)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("click",u),s.push(()=>e.removeEventListener("click",u));return}if(a.type==="form_submit"){let u=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("submit",u),s.push(()=>e.removeEventListener("submit",u));return}if(a.type==="scroll_depth"){let u=Math.max(0,Math.min(1,a.threshold)),h=new IntersectionObserver(A=>{for(let w of A)if(w.intersectionRatio>=u){t.type==="composite"?c(p,!0):d(),h.disconnect();break}},{threshold:[u]});h.observe(e),s.push(()=>h.disconnect());return}}),()=>{for(let a of s)a()}}var jt=new Set,Wt=new Set;function ve(e,t,n,r,i){let l=`${r}|${n}`;if(Wt.has(l))return;Wt.add(l);let d=i.type==="weighted_composite"&&!jt.has(r);d&&jt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:d?{funnelId:r,steps:i.steps.map(c=>({goalId:c.name,weight:c.weight}))}:{funnelId:r}})}function le(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var xr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function de(){if(typeof window=="undefined")return xr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function Ee(){de().version+=1;for(let e of de().listeners)e()}var Kt=()=>{};function Jt(e){return I()?(de().components.set(e.id,e),Ee(),()=>{de().components.delete(e.id),Ee()}):Kt}function Se(e){return I()?(de().slots.set(e.id,e),Ee(),()=>{de().slots.delete(e.id),Ee()}):Kt}function ut(e){I()&&(de().sections=[...e],Ee())}var Ut="0.37.4",ct=Ut!=="0.0.0-dev"?{name:"react",version:Ut}:void 0;function wr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){wr()[e]=t}function Ht(e){window.__sentient_vocabulary_override=e}function Xt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function kr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){kr()[e]=t}function zt(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let l=n.slice(0,r.index)+i;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var ft="__snt_editor_token",xe=null,dt=!1;function qt(){return dt}function Rr(){try{return sessionStorage.getItem(ft)}catch(e){return null}}function Be(e){if(xe)return xe;let t=typeof window=="undefined"?null:zt("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Rr();return dt=!!n,xe=Promise.resolve(n?{token:n,fresh:!1}:null),xe}return dt=!0,xe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(ft,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),xe}function Yt(){try{sessionStorage.removeItem(ft)}catch(e){}}var Zt="sentient_preview_cell",Qt="sentient_refresh_region",gt="sentient-cell-preview-bar",fe="__preview__",we=null;function en(e){if((we==null?void 0:we.slotId)!==e)return null;let t=we;return we=null,t}function tn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))})}).then(n=>ge(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ge("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function nn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(gt))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(Zt),n=s.get(Qt)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Be(r);if(!qt())return;if(n){we={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,fe),st();return}if(!t)return;let l=t.lastIndexOf("~");if(l<=0)return;let d=t.slice(0,l),c=t.slice(l+1);i.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(d)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${s.token}`}}):(ge(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){ge(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&Ht(a.vocabulary),a.compose!=null)he(d,{kind:"arms",compose:{[fe]:a.compose}}),be(d,fe);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))he(d,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),be(d,fe);else if(a.blocks!=null)he(d,{kind:"arms",blocks:{[fe]:a.blocks}}),be(d,fe);else if(a.content!=null)he(d,{kind:"arms",content:a.content}),be(d,fe);else{ge("Nothing to preview in that square yet.");return}st(),ge(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${d}"]`))==null||p.scrollIntoView({block:"center"})}catch(u){}},300)}).catch(()=>ge("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ge(e){var i;if(document.getElementById(gt))return;let t=document.createElement("div");t.id=gt,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{Yt();let l=new URL(window.location.href);l.searchParams.delete(Zt),l.searchParams.delete(Qt),window.location.assign(l.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var rn=!1;function on(e){if(rn||typeof window=="undefined")return;rn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Be(t).then(n=>{!n||!("token"in n)||!n.fresh||Cr(t,n.token)})}function Cr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var vn=require("react/jsx-runtime");function Ar(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,$e.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var an="https://api.sentient-ui.com/v1",K=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:an,debug:!1}),sn=!1,mt=new Set;function _r(e,t,n){let r=(0,_.useRef)(n);r.current=n;let[i,l]=(0,_.useState)(null),[d,c]=(0,_.useState)(!1),s=(0,_.useRef)(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(D(y({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,_.useEffect)(()=>{let p=s.current;if(p===void 0||typeof window=="undefined")return;let u,h=!1;return import("@sentientui/core/consent").then(({consentWatcher:A,forgetVisitor:w})=>{if(h)return;let o=A(typeof p=="object"&&p.cmp===void 0&&p.check?y(D(y({},p),{check:()=>s.current.check()}),p.refused?{refused:()=>{var f,b;return((b=(f=s.current).refused)==null?void 0:b.call(f))===!0}}:{}):p),m=!1,v=()=>{let f=o.refused()&&o.read()!==!0;f&&!m&&(w(t),r.current()),m=f,c(f);let b=o.read();b!==null&&mt.add(t),l(b!=null?b:mt.has(t)?!1:null)};v(),u=o.subscribe(v)}),()=>{h=!0,u==null||u()}},[a,t]),{granted:i,refused:d}}function ln(e){var C,O,T;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:Ar()}),[i,l]=(0,_.useState)(it());(0,_.useEffect)(()=>Dt(()=>l(it())),[]),(0,_.useEffect)(()=>{nn(e.apiBaseUrl),on(e.apiBaseUrl)},[]);let d=(0,_.useRef)(()=>{}),c=_r(e.consentFrom,e.apiKey,()=>d.current()),s=e.consentFrom?(C=c.granted)!=null?C:mt.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?c.refused:!0,p=(0,_.useRef)(a);p.current=a;let u=(0,_.useRef)(null),h=(0,_.useRef)(!1),A=(0,_.useRef)([]),w=(0,_.useRef)(!1);d.current=()=>{var x;A.current=[],w.current=!0;let g=u.current;g!=null&&g.gated?g.dispose():(x=g==null?void 0:g.takeHeld)==null||x.call(g)},(0,_.useEffect)(()=>{var U,ee;if(p.current&&s===!1&&(A.current=[]),s===!1&&h.current&&(p.current&&((U=u.current)==null||U.destroy()),u.current=null,h.current=!1),s===!1&&!e.preConsentBehavior){p.current&&((ee=u.current)==null||ee.destroy()),u.current=null,n(null);return}let g=s!==!1;g&&(w.current=!1);let x=V=>{!g&&w.current&&V.gated&&V.dispose()},S=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},ct?{sdk:ct}:{}),k=!1,R=null,G=null,P=V=>{for(let j of A.current.splice(0))setTimeout(()=>{if(u.current!==V){w.current||A.current.push(j);return}try{j(V)}catch(se){}},0)},B=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:j})=>{k||(G=j(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{k||(R=V(D(y({},S),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),x(R),u.current=R,h.current=g,P(R),n(R),B(R))}):(R=(0,$e.init)(S),x(R),u.current=R,h.current=g,P(R),n(R),B(R)),()=>{var V,j;k=!0,G==null||G(),A.current=A.current.concat((j=(V=R==null?void 0:R.takeHeld)==null?void 0:V.call(R))!=null?j:[]),R==null||R.dispose()}},[s]),(0,_.useEffect)(()=>{if(!t)return;let g=!1,x=async()=>{if(g)return;let k;try{k=await t.fetchWeights()}catch(R){return}if(!g)for(let R of k){let G={componentId:R.componentId,updatedAt:R.updatedAt,variants:R.variants.map(P=>{var B;return{variantId:P.variantId,pulls:P.pulls,avgReward:(B=P.avgReward)!=null?B:0}})};It(R.componentId,G)}};x();let S=setInterval(()=>{x()},6e4);return()=>{g=!0,clearInterval(S)}},[t]);let o=(O=e.ssrFallback)!=null?O:"first",m=((T=e.apiBaseUrl)!=null?T:an).replace(/\/$/,""),v=(0,_.useRef)(null);(0,_.useEffect)(()=>{var S;if(typeof process!="undefined"&&((S=process.env)==null?void 0:S.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:m},x=v.current;if(v.current=g,x!==null)for(let k of["apiKey","context","country","persona","apiBaseUrl"])Object.is(x[k],g[k])||console.warn(`[sentient] AdaptiveProvider: \`${k}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,m]),(0,_.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||Mt({apiKey:e.apiKey,apiBaseUrl:m,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,m]),(0,_.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){ut(g);return}e.declaredSections&&e.declaredSections.length>0&&ut(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{!I()||e.consent!==void 0||e.consentFrom!==void 0||sn||(sn=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,_.useEffect)(()=>{if(!I())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let x=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),k=>k.getAttribute("data-sentient-id"))),S=g.filter(k=>!x.has(k));S.length>0&&console.warn(`[SentientUI] Declared section${S.length>1?"s":""} ${S.map(k=>`"${k}"`).join(", ")} ${S.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let f=(0,_.useMemo)(()=>t&&i?Vt(t):t,[t,i]),b=(0,_.useMemo)(()=>{var g,x,S,k,R,G,P,B;return{client:f,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(x=e.initialLayoutOrder)!=null?x:null,initialSlots:(S=e.initialSlots)!=null?S:{},initialSlotConfig:(k=e.initialSlotConfig)!=null?k:{},initialPalette:(R=e.initialPalette)!=null?R:null,initialVocabulary:(G=e.initialVocabulary)!=null?G:null,initialPersona:(P=e.initialPersona)!=null?P:null,apiBaseUrl:m,debug:(B=e.debug)!=null?B:!1}},[f,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,m,e.debug]);return(0,vn.jsx)(K.Provider,{value:b,children:e.children})}function F(){return(0,_.useContext)(K).client}function ie(){return(0,_.useContext)(K).apiKey}function je(){return(0,_.useContext)(K).initialAssignments}function ke(){return(0,_.useContext)(K).sessionSegment}function un(){return(0,_.useContext)(K).ssrFallback}function We(){return(0,_.useContext)(K).onAssignment}function cn(){return(0,_.useContext)(K).debug}function dn(){let e=(0,_.useContext)(K).initialLayoutOrder,t=(0,_.useSyncExternalStore)(z,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ke(){return(0,_.useContext)(K).initialSlots}function fn(){return(0,_.useContext)(K).initialPersona}function gn(){return(0,_.useContext)(K).initialSlotConfig}function mn(){return(0,_.useContext)(K).initialPalette}function pn(){return(0,_.useContext)(K).initialVocabulary}function yn(){return(0,_.useContext)(K).apiBaseUrl}var Ce=require("react");var M=require("react"),Sn=require("@sentientui/core");var Y=require("react"),Je=require("@sentientui/policy");function Re(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let l=i.indexOf(":");if(l!==-1&&i.slice(0,l)===e)return i.slice(l+1)}}catch(r){}return null}function Ue(e,t,n,r){let i=je(),l=un(),d=F(),c=ke(),s=We(),a=cn(),p=(0,Y.useRef)(null),u=(0,Y.useSyncExternalStore)(z,()=>Re(e),()=>null),h=u&&t.includes(u)?u:null,A=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{a&&h&&A.current!==h&&(A.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[a,h,e]);let[w,o]=(0,Y.useState)(()=>{var b,C;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!d){let O=i[e];return O&&t.includes(O)?{variantId:O,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content))return{variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0};let f=rt(e);if(f){let O=(0,Je.pickFromWeights)(f.variants,t);if(O)return{variantId:O,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),m=v=>{s&&p.current!==v&&(p.current=v,s(e,v))};return(0,Y.useEffect)(()=>{var b;if(h||!d)return;let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content)){o({variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0}),m(v.variantId);return}let f=rt(e);if(f&&w.settled&&w.variantId&&w.variantId===(0,Je.pickFromWeights)(f.variants,t)){m(w.variantId);return}o(C=>{var O;return C.variantId?C:{variantId:(O=t[0])!=null?O:null,content:null,isLoading:!1,settled:!1}})},[h,d,e,c]),(0,Y.useEffect)(()=>{if(h||!d)return;let v=d.getAssignment(e,c);if(v&&t.includes(v.variantId))return;let f=!1;return d.assign(e,t,n,r).then(b=>{var C;f||b&&(!t.includes(b.variantId)&&!b.content||(o({variantId:b.variantId,content:(C=b.content)!=null?C:null,isLoading:!1,settled:!0}),m(b.variantId)))}),()=>{f=!0}},[h,d,e,c]),(0,Y.useEffect)(()=>{if(!h&&d)return Nt(e,v=>{var C;let f=d.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){o({variantId:f.variantId,content:(C=f.content)!=null?C:null,isLoading:!1,settled:!0}),m(f.variantId);return}let b=(0,Je.pickFromWeights)(v.variants,t);b&&(o({variantId:b,content:null,isLoading:!1,settled:!0}),m(b))})},[h,d,e,c]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}function He(e,t,n){let r=F(),i=ie(),l=Object.keys(t).join("\0"),d=(0,M.useMemo)(()=>Object.keys(t),[l]),{variantId:c,content:s,isOverride:a=!1,settled:p}=Ue(e,d,n.agentData,n.agentDataByVariant),[u,h]=(0,M.useState)(null),A=(0,M.useRef)(null),w=(0,M.useCallback)(k=>{A.current=k,h(k)},[]),o=n.goal,m=typeof o=="string"?o:JSON.stringify(o),v=(0,M.useMemo)(()=>o?q(o):null,[m]),f=o?ae(o):"";(0,M.useEffect)(()=>Jt({id:e,variantIds:d,goal:f}),[e,d,f]);let b=(0,M.useRef)(null);(0,M.useEffect)(()=>{a||p&&(!r||!c||!i||!u||b.current!==c&&(b.current=c,le(r,i,e,c)))},[r,c,i,e,u,a,p]);let C=(0,M.useRef)(!1),O=(0,M.useRef)(new Set);(0,M.useEffect)(()=>{C.current=!1,O.current=new Set},[c,v]);let T=n.funnel;(0,M.useEffect)(()=>{a||!p||!r||!T||!v||ve(r,i,e,T,v)},[r,i,e,T,v,a,p]);let g=n.cursorSignal===!0;(0,M.useEffect)(()=>{if(!g||a||!p||!r||!c||!u)return;let k=null,R=0,G=()=>{R=Date.now(),k=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),k=null},800)},P=()=>{k!==null&&(clearTimeout(k),k=null)};return u.addEventListener("mouseenter",G),u.addEventListener("mouseleave",P),()=>{u.removeEventListener("mouseenter",G),u.removeEventListener("mouseleave",P),k!==null&&clearTimeout(k)}},[g,r,c,i,e,u,a,p]);let x=(0,M.useRef)(n.microSignalGoals);x.current=n.microSignalGoals;let S=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,M.useEffect)(()=>{if(a||!p||!r||!c||!u)return;let k=Date.now();return(0,Sn.attachMicroSignalDetectors)((R,G={})=>{var V,j,se;r.track({projectId:i,componentId:e,variantId:c,eventType:"micro_signal",payload:y({signalType:R},G)});let P=(V=x.current)==null?void 0:V[R];if(!P||O.current.has(R))return;O.current.add(R);let B=typeof P=="string"?P:P.name,U=typeof P=="string"?1:(j=P.weight)!=null?j:1,ee=typeof P=="string"?0:(se=P.stepIndex)!=null?se:0;r.goal(B,{metadata:y({signalType:R},G),weight:U,stepIndex:ee})},u,k)},[r,c,i,e,u,S,a,p]),(0,M.useEffect)(()=>{if(a||!p||!r||!c||!u||!v)return;let k=ne(v);return re(u,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:f,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),r.goal(f,y({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(R,G,P)=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:R,payload:{reward:G}}),r.goal(R,{metadata:{},weight:G,stepIndex:P})}},f)},[r,c,i,e,u,v,f,a,p]),{client:r,variantIds:d,variantId:c,content:s,settled:p,isOverride:a,goalLabel:f,ref:w,nodeRef:A}}var $=require("react"),Ge=require("@sentientui/core"),wt=require("@sentientui/core/region");var H=require("react"),bn=require("@sentientui/core");var hn=new Set;function xn(e,t){var C,O,T;let n=F(),r=(0,H.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,H.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let l=(0,H.useRef)(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Ke(),c=gn(),s=mn(),a=pn(),p=(0,H.useSyncExternalStore)(z,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_config_overrides)==null?void 0:g[e]:void 0},()=>{}),u=(0,H.useSyncExternalStore)(z,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_overrides)==null?void 0:g[e]:void 0},()=>{}),h=g=>g==null?"":(0,bn.armOfResult)(g),A=(0,H.useCallback)(g=>{var x,S;return(S=(x=n==null?void 0:n.onSlotsChanged)==null?void 0:x.call(n,g))!=null?S:(()=>{})},[n]);(0,H.useSyncExternalStore)(A,()=>{var g;return(g=n==null?void 0:n.getSlotConfig(e))!=null?g:null},()=>null),(0,H.useSyncExternalStore)(A,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let w=p===void 0?c[e]:void 0,o=p===void 0&&w===void 0&&n?n.getSlotConfig(e):null,m=(C=s!=null?s:n==null?void 0:n.getSitePalette())!=null?C:null,v=(T=a!=null?a:(O=n==null?void 0:n.getStyleVocabulary)==null?void 0:O.call(n))!=null?T:null,f=(()=>{var g,x,S;if(p!==void 0)return{config:p,arm:h(u),palette:m,vocabulary:(g=Xt())!=null?g:v,source:"override"};if(w!==void 0)return{config:w,arm:h((x=d[e])!=null?x:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:v,source:"preloaded"};if(o!==null){let k=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:o,arm:h((S=n==null?void 0:n.getSlotResult(e))!=null?S:d[e]),palette:m,vocabulary:v,source:k?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:v,source:"none"}})(),b=f.source==="preloaded"||f.source==="override";return(0,H.useEffect)(()=>{var B,U,ee,V,j;if(!n||n.isLocal===!0||b)return;let g=f.source==="none",x=g&&(U=(B=r.current)==null?void 0:B.call(r))!=null?U:null,S=x!=null&&x!==""?{[e]:x}:void 0,k=(ee=i.current)==null?void 0:ee.call(i),R=g&&(j=(V=l.current)==null?void 0:V.call(l))!=null?j:null,G=y(y({},k?{render:{[e]:k}}:{}),R?{skeletons:{[e]:R}}:{}),P=Object.keys(G).length>0;return n.requestSlots?P?n.requestSlots([e],S,G):S?n.requestSlots([e],S):n.requestSlots([e]):g&&(R?n.reportSlots([e],S!=null?S:{},{[e]:R}):S?n.reportSlots([e],S):n.reportSlots([e])),()=>{var se;return(se=n.cancelSlots)==null?void 0:se.call(n,[e])}},[n,b,f.source,e]),(0,H.useEffect)(()=>{!I()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||hn.has(e)||(hn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var Pe=require("react");var L=require("react/jsx-runtime");function pt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ue={none:"0",sm:"8px",md:"16px",lg:"24px"},yt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Cn={sm:"0.875em",md:"1em",lg:"1.25em"},Or={sm:"1.25em",md:"1.5em",lg:"2em"},wn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},kn={sm:"8px",md:"16px",lg:"32px"},Er={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Pr={normal:"400",medium:"500",bold:"700"};function Rn(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function An(e,t,n){var i,l,d,c;let r=t==null?void 0:t.accent;return D(y({display:"inline-block",padding:(i=wn[n!=null?n:"md"])!=null?i:wn.md,borderRadius:(l=t==null?void 0:t.radius)!=null?l:"8px",font:"inherit"},n?{fontSize:Cn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(d=t==null?void 0:t.primaryBg)!=null?d:"#111827":"transparent",color:e==="primary"?(c=t==null?void 0:t.primaryText)!=null?c:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Gr({node:e,opts:t}){var i,l,d,c,s;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(d=(l=t.palette)==null?void 0:l.border)!=null?d:"currentColor"}`,borderRadius:(s=(c=t.palette)==null?void 0:c.radius)!=null?s:"8px"};return(0,L.jsxs)("form",{onSubmit:a=>{var h,A,w;a.preventDefault();let p=new FormData(a.currentTarget),u={};for(let o of e.fields)u[o.name]=String((h=p.get(o.name))!=null?h:"");(A=t.onFormGoal)==null||A.call(t,e.submitGoal);try{(w=t.onFormSubmit)==null||w.call(t,u)}catch(o){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(a=>{var p,u;return(0,L.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[a.label,a.kind==="textarea"?(0,L.jsx)("textarea",{name:a.name,required:a.required,placeholder:a.placeholder,rows:3,style:r}):a.kind==="select"?(0,L.jsx)("select",{name:a.name,required:a.required,style:r,children:((p=a.options)!=null?p:[]).map(h=>(0,L.jsx)("option",{value:h,children:h},h))}):(0,L.jsx)("input",{name:a.name,type:(u=a.inputType)!=null?u:"text",required:a.required,placeholder:a.placeholder,style:r})]},a.name)}),(0,L.jsx)("button",{type:"submit",style:An(n,t.palette),children:e.submitLabel})]})}function Tr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(l=>l.id===n))==null?void 0:i.classes:void 0}function _n(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function me(e,t){var i;let n=Nr(e,t),r=_n(e.like,t);return n&&r?(0,Pe.cloneElement)(n,{style:D(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Nr(e,t){var n,r,i,l,d,c,s,a,p,u,h,A,w,o,m,v,f,b,C,O,T,g,x;try{let S=Tr(e,t);switch(e.type){case"stack":{let k=(r=ue[(n=e.gap)!=null?n:"md"])!=null?r:ue.md,R=e.surface==="raised"&&!S,G=(i=e.pad)!=null?i:R?"md":void 0;return(0,L.jsx)("div",D(y({},S?{className:S}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:yt[e.align]}:{}),e.justify?{justifyContent:yt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),G?{padding:(l=ue[G])!=null?l:ue.md}:{}),R?D(y(y({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(c=t.palette)!=null&&c.surface&&((s=t.palette)!=null&&s.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(a=t.palette)==null?void 0:a.border)!=null?p:"currentColor"}`,borderRadius:(h=(u=t.palette)==null?void 0:u.radius)!=null?h:"8px"}):{}),children:((A=e.children)!=null?A:[]).map((P,B)=>{let U=me(P,t);return U===null?null:(0,L.jsx)(Pe.Fragment,{children:U},B)})}))}case"grid":{let k=(o=ue[(w=e.gap)!=null?w:"md"])!=null?o:ue.md;return(0,L.jsx)("div",D(y({},S?{className:S}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:yt[e.align]}:{}),e.pad?{padding:(m=ue[e.pad])!=null?m:ue.md}:{}),children:((v=e.children)!=null?v:[]).map((R,G)=>{let P=me(R,t);return P===null?null:(0,L.jsx)(Pe.Fragment,{children:P},G)})}))}case"text":return S?(0,L.jsx)("p",{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:Cn[e.size]}:{}),e.weight?{fontWeight:Pr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Rn(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return S?(0,L.jsx)(k,{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,L.jsx)(k,{style:y(y({margin:0,fontSize:Or[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(b=e.emphasis)!=null?b:"primary";return(0,L.jsx)("a",D(y(y({href:pt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:An(k,t.palette,e.size)}),{children:e.label}))}case"link":return(0,L.jsx)("a",D(y(y({href:pt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,L.jsx)("img",D(y({src:pt(e.src),alt:e.alt},S?{className:S}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Er[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return S?(0,L.jsx)("span",{className:S,children:e.value}):(0,L.jsx)("span",{style:y({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(O=(C=t.palette)==null?void 0:C.border)!=null?O:"currentColor"}`},Rn(e.tone,t.palette)),children:e.value});case"spacer":return(0,L.jsx)("div",{style:{height:(T=kn[e.size])!=null?T:kn.md}});case"divider":return(0,L.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(x=(g=t.palette)==null?void 0:g.border)!=null?x:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,L.jsx)(Gr,{node:e,opts:t});default:return null}}catch(S){return null}}function Xe(e,t){var l,d,c,s;let n=me(e.tree,t);if(n===null)return null;let r=(l=e.surface)!=null&&l.like?(c=(d=t.vocabulary)==null?void 0:d.entries.find(a=>a.id===e.surface.like))==null?void 0:c.classes:void 0,i=_n((s=e.surface)==null?void 0:s.like,t);return r?(0,L.jsx)("div",D(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}var oe=require("react"),ze=require("@sentientui/core/region");function qe(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Ye(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function pe(e){return qe(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+pe(n),0):(0,oe.isValidElement)(e)?pe(Ye(e)):0}function Ir(e,t){return Array.isArray(t)?(0,oe.cloneElement)(e,void 0,...t):(0,oe.cloneElement)(e,void 0,t)}function vt(e,t){if(qe(e))return t;if(Array.isArray(e))return e.map(n=>vt(n,t));if((0,oe.isValidElement)(e)){let n=Ye(e);return pe(n)===0?e:Ir(e,vt(n,t))}return e}function On(e,t){return pe(e)===1?vt(e,t):null}var X=e=>e.join("/");function St(e,t,n){if(qe(e)){n.leafPaths.push(t),n.texts.push((0,ze.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>St(r,[...t,i],n));return}(0,oe.isValidElement)(e)&&(n.elements.set(X(t),e),St(Ye(e),[...t,"c"],n))}function bt(e){let t={leafPaths:[],texts:[],elements:new Map};return St(e,[],t),t}function Lr(e){return bt(e).texts}function En(e){let t=Lr(e);return t.length===0?null:(0,ze.skeletonFingerprint)(t)}function Dr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Pn(e,t){let n=t.reduce((i,l)=>Math.max(i,l+1),0),r=[];for(let i=0;i<n;i++){let l=t.flatMap((c,s)=>c===i?[Dr(e.leafPaths[s])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let c of l.slice(1)){let s=new Set(c.map(X));d=d.filter(a=>s.has(X(a)))}r.push(d.length>0?d[d.length-1]:null)}return r}function ht(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function xt(e,t){let n=bt(t);if(n.texts.length!==e.leaves.length||n.texts.some((l,d)=>l!==e.leaves[d]))return null;let r=Pn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let c=r[d],s=c?n.elements.get(X(c)):void 0,a=!!s&&(typeof s.type=="string"||ht(s)!==void 0);return D(y({},l),{restylable:a})});return D(y({},e),{nodes:i})}function Gn(e,t,n){var w;let r=bt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((o,m)=>Math.max(o,m+1),0);for(let o of Object.keys(t.nodes))if(!/^\d+$/.test(o)||Number(o)>=i)return null;let l=Pn(r,n),d=new Map;n.forEach((o,m)=>{d.has(o)||d.set(o,m)});let c=new Map(r.leafPaths.map((o,m)=>[X(o),m])),s=new Set,a=new Map,p=!1;for(let[o,m]of Object.entries(t.nodes)){let v=Number(o),f=l[v];if(m.hidden&&(f?s.add(X(f)):p=!0),m.like!==void 0){let b=l[m.like],C=f?r.elements.get(X(f)):void 0,O=b?ht(r.elements.get(X(b))):void 0;!f||O===void 0||ht(C)===void 0?p=!0:a.set(X(f),O)}}let u=new Map(Object.entries((w=t.order)!=null?w:{})),h=(o,m)=>{var v;if(qe(o)){let f=c.get(X(m));if(f===void 0)return o;let b=n[f],C=(v=t.nodes[String(b)])==null?void 0:v.text;return C===void 0?o:d.get(b)===f?C:""}if(Array.isArray(o)){let f=o.map((b,C)=>h(b,[...m,C]));for(let[b,C]of u){let O=C.map(x=>{let S=l[x];return!S||S.length!==m.length+1||X(S.slice(0,-1))!==X(m)?-1:S[S.length-1]});if(O.some(x=>x<0))continue;let T=[...O].sort((x,S)=>x-S),g=[...f];T.forEach((x,S)=>{f[x]=g[O[S]]}),u.delete(b)}return f}if((0,oe.isValidElement)(o)){let f=X(m);if(s.has(f))return null;let b=Ye(o);if(pe(b)===0)return o;let C=h(b,[...m,"c"]),O=a.get(f),T=O!==void 0?{className:O}:void 0;return Array.isArray(C)?(0,oe.cloneElement)(o,T,...C):(0,oe.cloneElement)(o,T,C)}return o},A=h(e,[]);return p||u.size>0?null:A}var Dn=require("react/jsx-runtime"),Tn=new Set,Nn=new Set,In=new Set,Ln="authored.";function Te({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,as:d="div",reportBaselineText:c=!0}){var At,_t;let s=F(),a=ie(),p=(0,$.useRef)(null),u=(0,$.useMemo)(()=>En(t),[t]),h=n?Object.keys(n).join("|"):"",A=(0,$.useMemo)(()=>y({fp:u!=null?u:"0000000000000000",forms:!!r,compose:!0,content:pe(t)===1},h!==""?{authored:h.split("|"),children:!0}:{}),[u,t,r,h]),w=()=>{var te;let E=p.current;if(!E||!c)return null;let N=(0,wt.captureRegionSkeleton)(E);return N.skeleton?(te=xt(N.skeleton,t))!=null?te:D(y({},N.skeleton),{editable:!1,nodes:N.skeleton.nodes.map(ce=>D(y({},ce),{restylable:!1}))}):{status:N.reason}},{config:o,arm:m,palette:v,vocabulary:f,source:b}=xn(e,{baselineText:c?()=>{var E,N;return(N=(E=p.current)==null?void 0:E.textContent)!=null?N:null}:void 0,render:()=>A,skeleton:w}),C=m!==""?(At=o==null?void 0:o.blocks)==null?void 0:At[m]:void 0,O=m!==""?(_t=o==null?void 0:o.compose)==null?void 0:_t[m]:void 0,T=(C!==void 0&&(0,Ge.containsFormBlock)(C)||O!==void 0&&(0,Ge.containsFormBlock)(O.tree))&&!r;(0,$.useEffect)(()=>{!T||!I()||Tn.has(e)||(Tn.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[T,e]);let g=E=>{!s||b==="override"||(b!=="seeded"&&s.componentGoal(e,E),s.goal(E,{metadata:{componentId:e,arm:m},weight:1,stepIndex:0}))},x=t,S=!1,k=m.startsWith(Ln)?m.slice(Ln.length):null;if((o==null?void 0:o.blocked)==="variant_history")S=!0;else if(k!==null)n&&Object.prototype.hasOwnProperty.call(n,k)?x=n[k]:S=!0;else if(O!==void 0){let E=T?null:Xe(O,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});E===null?S=!0:x=E}else if(C!==void 0){let E=T?null:me(C,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});E===null?S=!0:x=E}else if((o==null?void 0:o.edits)!==void 0&&b!=="none"){let E=o.edits,N=E.fp===u?Gn(t,E.edits,E.leafToNode):null;N===null?S=!0:x=N}else if((o==null?void 0:o.content)!==void 0&&b!=="none"){let E=On(t,o.content);E===null?S=!0:x=E}let R=S&&C===void 0&&O===void 0&&(o==null?void 0:o.edits)===void 0&&k===null&&(o==null?void 0:o.blocked)===void 0;(0,$.useEffect)(()=>{(o==null?void 0:o.blocked)!=="variant_history"||!I()||In.has(e)||(In.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[o==null?void 0:o.blocked,e]);let G=k!==null&&!S?k:null;(0,$.useEffect)(()=>{var _e;if(!G||!c||!s)return;let E=p.current;if(!E)return;let N=(0,wt.captureRegionSkeleton)(E),te=N.skeleton?xt(N.skeleton,n==null?void 0:n[G]):null,ce=(_e=E.textContent)==null?void 0:_e.trim();s.reportSlots([],void 0,void 0,{[e]:[y(y({key:G},ce?{text:ce}:{}),te?{skeleton:te}:{})]})},[G,s,e]);let P=S&&(o==null?void 0:o.edits)!==void 0&&(b==="preloaded"||b==="client");(0,$.useEffect)(()=>{var E;!P||!(o!=null&&o.edits)||(E=s==null?void 0:s.reportDrift)==null||E.call(s,e,o.edits.fp,u,o.edits.fp===u?"unaddressable":"fp_mismatch")},[P,e,u,s]);let B=x===t;(0,$.useEffect)(()=>{var N;if(!(o!=null&&o.needsSkeleton)||!B)return;let E=w();E&&((N=s==null?void 0:s.reportSkeleton)==null||N.call(s,e,E))},[o==null?void 0:o.needsSkeleton,B,e,s]),(0,$.useEffect)(()=>{if(!B)return;let E=en(e);if(!E)return;let N=w();tn(E,N&&"status"in N?{status:N.status}:{skeleton:N})},[e,B]),(0,$.useEffect)(()=>{!R||!I()||Nn.has(e)||(Nn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[R,e]);let U=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";(0,$.useEffect)(()=>Se({id:e,arms:U===""?void 0:U.split("|")}),[e,U]);let ee=(0,$.useRef)(null);(0,$.useEffect)(()=>{!s||b==="none"||b==="seeded"||b==="override"||m===""||S||ee.current!==m&&(ee.current=m,le(s,a,e,m))},[s,a,e,m,b,S]);let V=b!=="none"&&b!=="seeded"&&!S,j=V?m:"",se=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,$.useEffect)(()=>{if(!s||!i||b==="override")return;let E=p.current;if(!E)return;let N=ae(i),te=ne(i),ce=!1;return re(E,q(i),{fireGoal:()=>{ce||(ce=!0,V&&(te!==void 0?s.componentGoal(e,N,{value:te}):s.componentGoal(e,N)),s.goal(N,y({metadata:{componentId:e,arm:j},weight:1,stepIndex:0},te!==void 0?{value:te}:{})))},fireStep:(_e,Ot,cr)=>{V&&s.componentGoal(e,_e,{reward:Ot}),s.goal(_e,{metadata:{componentId:e,arm:j},weight:Ot,stepIndex:cr})}},N)},[s,e,se,m,b,S,V,j]);let Le=(0,$.useRef)(null);(0,$.useEffect)(()=>{let E=p.current;if(E){if(Le.current===null){Le.current=m;return}Le.current!==m&&(Le.current=m,(0,Ge.reveal)(E))}},[m]);let ur=(0,$.useMemo)(()=>y({"data-sentient-slot":e},m!==""?{"data-sentient-arm":m}:{}),[e,m]);return(0,Dn.jsx)(d,D(y({ref:p,className:l},ur),{children:x}))}var Ne=require("react/jsx-runtime");function Vr(e){var p,u;let{client:t,variantId:n,content:r,ref:i}=He(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=(0,Ce.useState)(!1);(0,Ce.useEffect)(()=>{d(!0)},[]);let c=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!l||!t)||!n)return null;let s=(u=e.variants[n])!=null?u:null,a=s===null?r:null;return I()&&s===null&&a===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ne.jsx)(c,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:a})}var Fr=(0,Ce.memo)(Vr,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Fn(e){if(e.variants===void 0)return(0,Ne.jsx)(Te,y({},e));let t=e;if(t.children!=null){I()&&Mr(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:c,variants:s}=n,a=Ve(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return(0,Ne.jsx)(Te,D(y({},a),{children:t.children,variants:s}))}return(0,Ne.jsx)(Fr,y({},t))}var Vn=new Set;function Mr(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||Vn.has(e.id)||(Vn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}var W=require("react");var Bn=require("react/jsx-runtime");function Mn({id:e,default:t,component:n="span",className:r,goal:i}){var T;let l=F(),d=ie(),c=We(),s=ke(),a=(0,W.useRef)(null),p=(0,W.useRef)(null),u=(0,W.useSyncExternalStore)(z,()=>Re(e),()=>null),[h,A]=(0,W.useState)(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.content)!=null?x:null}),[w,o]=(0,W.useState)(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.variantId)!=null?x:null});(0,W.useEffect)(()=>{if(u||!l)return;let g=l.getAssignment(e,s);if((g==null?void 0:g.content)!==void 0){o(g.variantId),A(g.content);return}let x=!1;return l.assign(e).then(S=>{if(!x){if(!S){I()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}o(S.variantId),S.content&&A(S.content)}}),()=>{x=!0}},[l,e,s,u]),(0,W.useEffect)(()=>{u||!l||!w||!d||a.current!==w&&(a.current=w,l.track({projectId:d,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),c==null||c(e,w))},[l,w,d,e,c,u]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,W.useMemo)(()=>i===void 0?null:q(i),[m]),f=i===void 0?null:typeof i=="string"?i:v.type,b=(0,W.useRef)(!1);(0,W.useEffect)(()=>{b.current=!1},[w,m]),(0,W.useEffect)(()=>{if(u||!l||!w||!d||!v||!f)return;let g=p.current;if(!g)return;let x=ne(v);return re(g,v,{fireGoal:()=>{b.current||(b.current=!0,l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:f,payload:y({reward:1},x!==void 0?{goalValue:x}:{})}),l.goal(f,y({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(S,k,R)=>{l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:S,payload:{reward:k}}),l.goal(S,{metadata:{},weight:k,stepIndex:R})}})},[l,w,d,e,v,f,u]);let C=h!=null?h:t;if(u){let g=l==null?void 0:l.getAssignment(e,s);C=g&&g.variantId===u&&(T=g.content)!=null?T:t}return(0,Bn.jsx)(n,{ref:g=>{p.current=g},className:r,children:C})}var Ze=require("react");function Qe(e){let t=F(),n=(0,Ze.useRef)(new Set);return(0,Ze.useCallback)((r,i)=>{var l,d;if(!Re(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,y(y(y({metadata:(l=i==null?void 0:i.metadata)!=null?l:{},weight:(d=i==null?void 0:i.reward)!=null?d:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var Ie=require("react");function $n(e,t={}){let s=t,{componentId:n}=s,r=Ve(s,["componentId"]),i=F(),l=Qe(n!=null?n:""),d=(0,Ie.useRef)(!1),c=(0,Ie.useRef)(r);c.current=r,(0,Ie.useEffect)(()=>{if(!i||d.current||i.gated)return;d.current=!0;let{metadata:a,reward:p,value:u,currency:h,externalId:A}=c.current;if(n){l(e,c.current);return}i.goal(e,y(y(y({metadata:a!=null?a:{},weight:p!=null?p:1,stepIndex:0},u!==void 0?{value:u}:{}),h!==void 0?{currency:h}:{}),A!==void 0?{externalId:A}:{}))},[i,n,e,l])}var Wn=require("@sentientui/core"),Kn=require("@sentientui/policy"),Un=require("react/jsx-runtime");function jn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Br(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+jn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+jn((0,Kn.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,Wn.renderPrePaintScript)(e.apiKey)}function Jn(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,Un.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Br(e)}})}var Q=require("react"),qn=require("@sentientui/policy");var Z=require("react"),ye=require("@sentientui/core"),Hn=require("@sentientui/policy");function et(e,t){let n=F(),r=Ke(),[,i]=(0,Z.useReducer)(u=>u+1,0),l=(0,Z.useSyncExternalStore)(z,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),d=l===void 0?r[e]:void 0,c=l===void 0&&d===void 0&&n?n.getSlotResult(e):null,s=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&c===null;(0,Z.useEffect)(()=>{if(!s||!n)return;let u=!1;return n.decide({slots:[t]}).then(h=>{!u&&h&&i()}),()=>{u=!0}},[n,e,s]);let a=(()=>{if(l!==void 0)return{result:l,arm:(0,ye.armOfResult)(l),source:"override"};if(d!==void 0)return{result:d,arm:(0,ye.armOfResult)(d),source:"preloaded"};if(c!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:c,arm:(0,ye.armOfResult)(c),source:h?"client":"seeded"}}let u=(0,ye.baselineResultFor)(t);return{result:u,arm:(0,ye.armOfResult)(u),source:"baseline"}})(),p=a.source==="preloaded"||a.source==="override";return(0,Z.useEffect)(()=>{var h;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let u=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var A;(A=n.cancelSlots)==null||A.call(n,[e]),u==null||u()}},[n,e,p]),a}function $r(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function Xn(){let e=F(),t=fn();(0,Z.useSyncExternalStore)(z,Ft,()=>0);let[n,r]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>r(!0),[]);let i=c=>({persona:c.persona,confidence:c.confidence,band:(0,Hn.confidenceBand)(c.confidence)});if(!n)return t?i(t):null;let l=$r();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var zn=new Set;function jr(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Yn(e,t,n){let r=F(),i=ie(),l=JSON.stringify(t),d=(0,Q.useMemo)(()=>({id:e,dims:t}),[e,l]),{result:c,arm:s,source:a}=et(e,d),p=(0,Q.useMemo)(()=>typeof c=="string"?{}:c,[s]);if(I()&&!zn.has(e)){zn.add(e);let o=(0,qn.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),m=Object.values(t).reduce((v,f)=>v*f.length,1);o.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${o.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,Q.useEffect)(()=>Se({id:e,dims:t}),[e]);let h=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{!r||a==="baseline"||a==="seeded"||a==="override"||h.current===s||(h.current=s,le(r,i,e,s))},[r,i,e,s,a]);let A=n==null?void 0:n.funnel;(0,Q.useEffect)(()=>{var o;!r||!A||a==="override"||ve(r,i,e,A,q((o=n==null?void 0:n.goal)!=null?o:"click"))},[r,i,e,A,u,a]),(0,Q.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||a==="override"||a==="baseline"||a==="seeded")return;let o=document.querySelector(`[data-sentient-slot="${jr(e)}"]`);if(!o){I()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let m=ae(n.goal),v=ne(n.goal),f=!1;return re(o,q(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,m,{value:v}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:s},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,C,O)=>{r.componentGoal(e,b,{reward:C}),r.goal(b,{metadata:{componentId:e,arm:s},weight:C,stepIndex:O})}},m)},[r,e,u,s,a]);let w=(0,Q.useMemo)(()=>{let o={"data-sentient-slot":e};for(let[m,v]of Object.entries(p))o[`data-${m}`]=v;return o},[e,p]);return{tokens:p,props:w}}var Ae=require("react");var Zn=new Set;function Qn(e,t){var A;if(I()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:l,goalLabel:d,ref:c,nodeRef:s}=He(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),a=(A=i!=null?i:r[0])!=null?A:"",p=t.variants[a];(0,Ae.useEffect)(()=>{if(!I()||!n)return;let w=setTimeout(()=>{!s.current&&!Zn.has(e)&&(Zn.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(w)},[n,e]);let u=(0,Ae.useCallback)((w,o)=>{var v,f;if(l)return;let m=w!=null?w:d;m&&(n==null||n.componentGoal(e,m,o),n==null||n.goal(m,y(y(y({metadata:(v=o==null?void 0:o.metadata)!=null?v:{},weight:(f=o==null?void 0:o.reward)!=null?f:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{})))},[n,e,d,l]),h=(0,Ae.useMemo)(()=>({ref:c,"data-sentient-id":e,"data-sentient-variant":a}),[c,e,a]);return{variant:a,value:p,bind:h,fireGoal:u}}var J=require("react");var tr=require("react/jsx-runtime"),tt=new Set;function er(e){var v;let t=F(),n=ie(),r=(0,J.useRef)(null),i=Object.keys(e.arrangements).join(" "),l=(0,J.useMemo)(()=>Object.keys(e.arrangements),[i]),d=(0,J.useMemo)(()=>y({id:e.id,arms:l},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,l,e.baseline]),{arm:c,source:s}=et(e.id,d);I()&&e.baseline!==void 0&&e.baseline!==l[0]&&!tt.has(e.id+":baseline")&&(tt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${l[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let a=J.Children.toArray(e.children).filter(J.isValidElement),p=new Map;for(let f of a)p.set(String((v=f.key)!=null?v:"").replace(/^\.\$/,""),f);let u=e.arrangements[c],h=u!==void 0&&u.length===a.length&&u.every(f=>p.has(f));I()&&u!==void 0&&!h&&!tt.has(e.id+":keys")&&(tt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${c}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let A=h?u.map(f=>p.get(f)):a;(0,J.useEffect)(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=(0,J.useRef)(null);(0,J.useEffect)(()=>{!t||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,le(t,n,e.id,c))},[t,n,e.id,c,s]);let o=e.funnel;(0,J.useEffect)(()=>{var f;!t||!o||s==="override"||ve(t,n,e.id,o,q((f=e.goal)!=null?f:"click"))},[t,n,e.id,o,s]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,J.useEffect)(()=>{if(!t||e.goal===void 0||s==="override"||s==="baseline"||s==="seeded")return;let f=r.current;if(!f)return;let b=ae(e.goal),C=ne(e.goal),O=!1;return re(f,q(e.goal),{fireGoal:()=>{O||(O=!0,C!==void 0?t.componentGoal(e.id,b,{value:C}):t.componentGoal(e.id,b),t.goal(b,y({metadata:{componentId:e.id,arm:c},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(T,g,x)=>{t.componentGoal(e.id,T,{reward:g}),t.goal(T,{metadata:{componentId:e.id,arm:c},weight:g,stepIndex:x})}},b)},[t,e.id,m,c,s]),(0,tr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":c,children:A})}var kt=require("@sentientui/core");var Wr=["page","blocks","layoutOrder"],nr=new Map;function rr(e,t){nr.set(e,t)}function Rt(e){return nr.get(e)}function ir(e){var i,l;let t=(l=(i=e.content)!=null?i:Rt(e.page))!=null?l:{},n={};for(let[d,c]of Object.entries(t))Wr.includes(d)||(n[d]=c);let r=D(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function or(e){return`<script type="application/ld+json">${Ct(e)}</script>`}function Ct(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function sr(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
3
3
  `).trimEnd()+`
4
4
  `}var ar=require("@sentientui/core"),lr=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient,useSessionSegment});
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var Hn=Object.defineProperty,Xn=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable;var Rt=(e,t,n)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ct.call(t,n)&&Rt(e,n,t[n]);if(Re)for(var n of Re(t))At.call(t,n)&&Rt(e,n,t[n]);return e},I=(e,t)=>Xn(e,zn(t));var Ce=(e,t)=>{var n={};for(var r in e)Ct.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Re)for(var r of Re(e))t.indexOf(r)<0&&At.call(e,r)&&(n[r]=e[r]);return n};import{createContext as rr,useContext as j,useEffect as Y,useMemo as en,useRef as Q,useState as be,useSyncExternalStore as ir}from"react";import{deriveSessionSegment as or,init as sr}from"@sentientui/core";var _t=new Map,Ae=new Map;function Ot(e,t){let n=Ae.get(e);return n||(n=new Set,Ae.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ae.delete(e)}}function Et(e,t){_t.set(e,t);let n=Ae.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Je(e){var t;return(t=_t.get(e))!=null?t:null}var qn={on:!1,listeners:new Set};function Pt(){if(typeof window=="undefined")return qn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function Ue(){return Pt().on}function Gt(e){let t=Pt().listeners;return t.add(e),()=>{t.delete(e)}}function Tt(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var He="sentient:overrides-changed";function Nt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function Xe(){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(He))}function K(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(He,e),()=>window.removeEventListener(He,e))}function It(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function N(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function J(e){return typeof e=="string"?{type:"click"}:e}function te(e){return typeof e=="string"?e:e.type}function z(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ze=new Set,qe=!1;function Lt(e){if(ze.has(e))return!0;if(ze.add(e),!qe){qe=!0;let t=()=>{qe=!1,ze.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 Yn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Dt(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Yn(r))return!0;r=r.parentElement}return!1}function q(e,t,n,r){if(t.type==="weighted_composite"){let a=new Set,p=[];return t.steps.forEach(({goal:u,name:h,weight:A},w)=>{let o=(m=!1)=>{a.has(w)||m&&r!==void 0&&Lt(`step\0${h}\0${A}\0${w}`)||(a.add(w),n.fireStep(h,A,w))};if(u.type==="click"){let m=v=>{let f=v.target;f instanceof Element&&Dt(f,e,u.selector)&&o()};e.addEventListener("click",m),p.push(()=>e.removeEventListener("click",m));return}if(u.type==="form_submit"){let m=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&o()};e.addEventListener("submit",m),p.push(()=>e.removeEventListener("submit",m));return}if(u.type==="scroll_depth"){let m=Math.max(0,Math.min(1,u.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=m){o(!0),v.disconnect();break}},{threshold:[m]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let u of p)u()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((a,p)=>p)),d=()=>{r!==void 0&&Lt(r)||n.fireGoal()},c=(a,p=!1)=>{l.delete(a),l.size===0&&(p?d():n.fireGoal())},s=[];return i.forEach((a,p)=>{if(a.type==="click"){let u=h=>{let A=h.target;A instanceof Element&&Dt(A,e,a.selector)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("click",u),s.push(()=>e.removeEventListener("click",u));return}if(a.type==="form_submit"){let u=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("submit",u),s.push(()=>e.removeEventListener("submit",u));return}if(a.type==="scroll_depth"){let u=Math.max(0,Math.min(1,a.threshold)),h=new IntersectionObserver(A=>{for(let w of A)if(w.intersectionRatio>=u){t.type==="composite"?c(p,!0):d(),h.disconnect();break}},{threshold:[u]});h.observe(e),s.push(()=>h.disconnect());return}}),()=>{for(let a of s)a()}}var Vt=new Set,Ft=new Set;function ce(e,t,n,r,i){let l=`${r}|${n}`;if(Ft.has(l))return;Ft.add(l);let d=i.type==="weighted_composite"&&!Vt.has(r);d&&Vt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:d?{funnelId:r,steps:i.steps.map(c=>({goalId:c.name,weight:c.weight}))}:{funnelId:r}})}function ne(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function oe(){if(typeof window=="undefined")return Zn;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 he(){oe().version+=1;for(let e of oe().listeners)e()}var Mt=()=>{};function Bt(e){return N()?(oe().components.set(e.id,e),he(),()=>{oe().components.delete(e.id),he()}):Mt}function de(e){return N()?(oe().slots.set(e.id,e),he(),()=>{oe().slots.delete(e.id),he()}):Mt}function Ye(e){N()&&(oe().sections=[...e],he())}var $t="0.37.2",Ze=$t!=="0.0.0-dev"?{name:"react",version:$t}:void 0;function Qn(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function fe(e,t){Qn()[e]=t}function jt(e){window.__sentient_vocabulary_override=e}function Wt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function er(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function ge(e,t){er()[e]=t}function Kt(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let l=n.slice(0,r.index)+i;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var et="__snt_editor_token",me=null,Qe=!1;function Jt(){return Qe}function tr(){try{return sessionStorage.getItem(et)}catch(e){return null}}function _e(e){if(me)return me;let t=typeof window=="undefined"?null:Kt("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:tr();return Qe=!!n,me=Promise.resolve(n?{token:n,fresh:!1}:null),me}return Qe=!0,me=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(et,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),me}function Ut(){try{sessionStorage.removeItem(et)}catch(e){}}var Ht="sentient_preview_cell",Xt="sentient_refresh_region",tt="sentient-cell-preview-bar",se="__preview__",pe=null;function zt(e){if((pe==null?void 0:pe.slotId)!==e)return null;let t=pe;return pe=null,t}function qt(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))})}).then(n=>ae(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ae("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Yt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(tt))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(Ht),n=s.get(Xt)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=_e(r);if(!Jt())return;if(n){pe={slotId:n,session:i,base:r},fe(n,{kind:"arms"}),ge(n,se),Xe();return}if(!t)return;let l=t.lastIndexOf("~");if(l<=0)return;let d=t.slice(0,l),c=t.slice(l+1);i.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(d)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${s.token}`}}):(ae(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){ae(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&jt(a.vocabulary),a.compose!=null)fe(d,{kind:"arms",compose:{[se]:a.compose}}),ge(d,se);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))fe(d,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),ge(d,se);else if(a.blocks!=null)fe(d,{kind:"arms",blocks:{[se]:a.blocks}}),ge(d,se);else if(a.content!=null)fe(d,{kind:"arms",content:a.content}),ge(d,se);else{ae("Nothing to preview in that square yet.");return}Xe(),ae(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${d}"]`))==null||p.scrollIntoView({block:"center"})}catch(u){}},300)}).catch(()=>ae("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ae(e){var i;if(document.getElementById(tt))return;let t=document.createElement("div");t.id=tt,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=()=>{Ut();let l=new URL(window.location.href);l.searchParams.delete(Ht),l.searchParams.delete(Xt),window.location.assign(l.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Zt=!1;function Qt(e){if(Zt||typeof window=="undefined")return;Zt=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");_e(t).then(n=>{!n||!("token"in n)||!n.fresh||nr(t,n.token)})}function nr(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})}import{jsx as fr}from"react/jsx-runtime";function ar(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return or({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",B=rr({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:nn,debug:!1}),tn=!1,nt=new Set;function lr(e,t,n){let r=Q(n);r.current=n;let[i,l]=be(null),[d,c]=be(!1),s=Q(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(I(y({},e),{check:typeof e.check,refused:typeof e.refused}));return Y(()=>{let p=s.current;if(p===void 0||typeof window=="undefined")return;let u,h=!1;return import("@sentientui/core/consent").then(({consentWatcher:A,forgetVisitor:w})=>{if(h)return;let o=A(typeof p=="object"&&p.cmp===void 0&&p.check?y(I(y({},p),{check:()=>s.current.check()}),p.refused?{refused:()=>{var f,b;return((b=(f=s.current).refused)==null?void 0:b.call(f))===!0}}:{}):p),m=!1,v=()=>{let f=o.refused()&&o.read()!==!0;f&&!m&&(w(t),r.current()),m=f,c(f);let b=o.read();b!==null&&nt.add(t),l(b!=null?b:nt.has(t)?!1:null)};v(),u=o.subscribe(v)}),()=>{h=!0,u==null||u()}},[a,t]),{granted:i,refused:d}}function ur(e){var C,_,G;let[t,n]=be(null),[r]=be(()=>{var g;return(g=e.sessionSegment)!=null?g:ar()}),[i,l]=be(Ue());Y(()=>Gt(()=>l(Ue())),[]),Y(()=>{Yt(e.apiBaseUrl),Qt(e.apiBaseUrl)},[]);let d=Q(()=>{}),c=lr(e.consentFrom,e.apiKey,()=>d.current()),s=e.consentFrom?(C=c.granted)!=null?C:nt.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?c.refused:!0,p=Q(a);p.current=a;let u=Q(null),h=Q(!1),A=Q([]),w=Q(!1);d.current=()=>{var x;A.current=[],w.current=!0;let g=u.current;g!=null&&g.gated?g.dispose():(x=g==null?void 0:g.takeHeld)==null||x.call(g)},Y(()=>{var $,H;if(p.current&&s===!1&&(A.current=[]),s===!1&&h.current&&(p.current&&(($=u.current)==null||$.destroy()),u.current=null,h.current=!1),s===!1&&!e.preConsentBehavior){p.current&&((H=u.current)==null||H.destroy()),u.current=null,n(null);return}let g=s!==!1;g&&(w.current=!1);let x=L=>{!g&&w.current&&L.gated&&L.dispose()},S=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},Ze?{sdk:Ze}:{}),k=!1,R=null,P=null,E=L=>{for(let M of A.current.splice(0))setTimeout(()=>{if(u.current!==L){w.current||A.current.push(M);return}try{M(L)}catch(ee){}},0)},F=L=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:M})=>{k||(P=M(L,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:L})=>{k||(R=L(I(y({},S),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),x(R),u.current=R,h.current=g,E(R),n(R),F(R))}):(R=sr(S),x(R),u.current=R,h.current=g,E(R),n(R),F(R)),()=>{var L,M;k=!0,P==null||P(),A.current=A.current.concat((M=(L=R==null?void 0:R.takeHeld)==null?void 0:L.call(R))!=null?M:[]),R==null||R.dispose()}},[s]),Y(()=>{if(!t)return;let g=!1,x=async()=>{if(g)return;let k;try{k=await t.fetchWeights()}catch(R){return}if(!g)for(let R of k){let P={componentId:R.componentId,updatedAt:R.updatedAt,variants:R.variants.map(E=>{var F;return{variantId:E.variantId,pulls:E.pulls,avgReward:(F=E.avgReward)!=null?F:0}})};Et(R.componentId,P)}};x();let S=setInterval(()=>{x()},6e4);return()=>{g=!0,clearInterval(S)}},[t]);let o=(_=e.ssrFallback)!=null?_:"first",m=((G=e.apiBaseUrl)!=null?G:nn).replace(/\/$/,""),v=Q(null);Y(()=>{var S;if(typeof process!="undefined"&&((S=process.env)==null?void 0:S.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:m},x=v.current;if(v.current=g,x!==null)for(let k of["apiKey","context","country","persona","apiBaseUrl"])Object.is(x[k],g[k])||console.warn(`[sentient] AdaptiveProvider: \`${k}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,m]),Y(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||It({apiKey:e.apiKey,apiBaseUrl:m,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,m]),Y(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){Ye(g);return}e.declaredSections&&e.declaredSections.length>0&&Ye(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),Y(()=>{!N()||e.consent!==void 0||e.consentFrom!==void 0||tn||(tn=!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'))},[]),Y(()=>{if(!N())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let x=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),k=>k.getAttribute("data-sentient-id"))),S=g.filter(k=>!x.has(k));S.length>0&&console.warn(`[SentientUI] Declared section${S.length>1?"s":""} ${S.map(k=>`"${k}"`).join(", ")} ${S.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let f=en(()=>t&&i?Tt(t):t,[t,i]),b=en(()=>{var g,x,S,k,R,P,E,F;return{client:f,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(x=e.initialLayoutOrder)!=null?x:null,initialSlots:(S=e.initialSlots)!=null?S:{},initialSlotConfig:(k=e.initialSlotConfig)!=null?k:{},initialPalette:(R=e.initialPalette)!=null?R:null,initialVocabulary:(P=e.initialVocabulary)!=null?P:null,initialPersona:(E=e.initialPersona)!=null?E:null,apiBaseUrl:m,debug:(F=e.debug)!=null?F:!1}},[f,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,m,e.debug]);return fr(B.Provider,{value:b,children:e.children})}function D(){return j(B).client}function Z(){return j(B).apiKey}function rt(){return j(B).initialAssignments}function xe(){return j(B).sessionSegment}function rn(){return j(B).ssrFallback}function Oe(){return j(B).onAssignment}function on(){return j(B).debug}function cr(){let e=j(B).initialLayoutOrder,t=ir(K,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ee(){return j(B).initialSlots}function sn(){return j(B).initialPersona}function an(){return j(B).initialSlotConfig}function ln(){return j(B).initialPalette}function un(){return j(B).initialVocabulary}function dr(){return j(B).apiBaseUrl}import{memo as Ir,useEffect as Lr,useState as Dr}from"react";import{useCallback as pr,useEffect as le,useMemo as dn,useRef as we,useState as yr}from"react";import{attachMicroSignalDetectors as vr}from"@sentientui/core";import{useEffect as Pe,useRef as cn,useState as gr,useSyncExternalStore as mr}from"react";import{pickFromWeights as it}from"@sentientui/policy";function ye(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let l=i.indexOf(":");if(l!==-1&&i.slice(0,l)===e)return i.slice(l+1)}}catch(r){}return null}function ot(e,t,n,r){let i=rt(),l=rn(),d=D(),c=xe(),s=Oe(),a=on(),p=cn(null),u=mr(K,()=>ye(e),()=>null),h=u&&t.includes(u)?u:null,A=cn(null);Pe(()=>{a&&h&&A.current!==h&&(A.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[a,h,e]);let[w,o]=gr(()=>{var b,C;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!d){let _=i[e];return _&&t.includes(_)?{variantId:_,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content))return{variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0};let f=Je(e);if(f){let _=it(f.variants,t);if(_)return{variantId:_,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),m=v=>{s&&p.current!==v&&(p.current=v,s(e,v))};return Pe(()=>{var b;if(h||!d)return;let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content)){o({variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0}),m(v.variantId);return}let f=Je(e);if(f&&w.settled&&w.variantId&&w.variantId===it(f.variants,t)){m(w.variantId);return}o(C=>{var _;return C.variantId?C:{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}})},[h,d,e,c]),Pe(()=>{if(h||!d)return;let v=d.getAssignment(e,c);if(v&&t.includes(v.variantId))return;let f=!1;return d.assign(e,t,n,r).then(b=>{var C;f||b&&(!t.includes(b.variantId)&&!b.content||(o({variantId:b.variantId,content:(C=b.content)!=null?C:null,isLoading:!1,settled:!0}),m(b.variantId)))}),()=>{f=!0}},[h,d,e,c]),Pe(()=>{if(!h&&d)return Ot(e,v=>{var C;let f=d.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){o({variantId:f.variantId,content:(C=f.content)!=null?C:null,isLoading:!1,settled:!0}),m(f.variantId);return}let b=it(v.variants,t);b&&(o({variantId:b,content:null,isLoading:!1,settled:!0}),m(b))})},[h,d,e,c]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}function Ge(e,t,n){let r=D(),i=Z(),l=Object.keys(t).join("\0"),d=dn(()=>Object.keys(t),[l]),{variantId:c,content:s,isOverride:a=!1,settled:p}=ot(e,d,n.agentData,n.agentDataByVariant),[u,h]=yr(null),A=we(null),w=pr(k=>{A.current=k,h(k)},[]),o=n.goal,m=typeof o=="string"?o:JSON.stringify(o),v=dn(()=>o?J(o):null,[m]),f=o?te(o):"";le(()=>Bt({id:e,variantIds:d,goal:f}),[e,d,f]);let b=we(null);le(()=>{a||p&&(!r||!c||!i||!u||b.current!==c&&(b.current=c,ne(r,i,e,c)))},[r,c,i,e,u,a,p]);let C=we(!1),_=we(new Set);le(()=>{C.current=!1,_.current=new Set},[c,v]);let G=n.funnel;le(()=>{a||!p||!r||!G||!v||ce(r,i,e,G,v)},[r,i,e,G,v,a,p]);let g=n.cursorSignal===!0;le(()=>{if(!g||a||!p||!r||!c||!u)return;let k=null,R=0,P=()=>{R=Date.now(),k=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),k=null},800)},E=()=>{k!==null&&(clearTimeout(k),k=null)};return u.addEventListener("mouseenter",P),u.addEventListener("mouseleave",E),()=>{u.removeEventListener("mouseenter",P),u.removeEventListener("mouseleave",E),k!==null&&clearTimeout(k)}},[g,r,c,i,e,u,a,p]);let x=we(n.microSignalGoals);x.current=n.microSignalGoals;let S=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return le(()=>{if(a||!p||!r||!c||!u)return;let k=Date.now();return vr((R,P={})=>{var L,M,ee;r.track({projectId:i,componentId:e,variantId:c,eventType:"micro_signal",payload:y({signalType:R},P)});let E=(L=x.current)==null?void 0:L[R];if(!E||_.current.has(R))return;_.current.add(R);let F=typeof E=="string"?E:E.name,$=typeof E=="string"?1:(M=E.weight)!=null?M:1,H=typeof E=="string"?0:(ee=E.stepIndex)!=null?ee:0;r.goal(F,{metadata:y({signalType:R},P),weight:$,stepIndex:H})},u,k)},[r,c,i,e,u,S,a,p]),le(()=>{if(a||!p||!r||!c||!u||!v)return;let k=z(v);return q(u,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:f,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),r.goal(f,y({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(R,P,E)=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:R,payload:{reward:P}}),r.goal(R,{metadata:{},weight:P,stepIndex:E})}},f)},[r,c,i,e,u,v,f,a,p]),{client:r,variantIds:d,variantId:c,content:s,settled:p,isOverride:a,goalLabel:f,ref:w,nodeRef:A}}import{useEffect as U,useMemo as pt,useRef as yt}from"react";import{containsFormBlock as _n,reveal as Tr}from"@sentientui/core";import{captureRegionSkeleton as On}from"@sentientui/core/region";import{useCallback as Sr,useEffect as fn,useRef as st,useSyncExternalStore as Te}from"react";import{armOfResult as hr}from"@sentientui/core";var gn=new Set;function mn(e,t){var C,_,G;let n=D(),r=st(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=st(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let l=st(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Ee(),c=an(),s=ln(),a=un(),p=Te(K,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_config_overrides)==null?void 0:g[e]:void 0},()=>{}),u=Te(K,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_overrides)==null?void 0:g[e]:void 0},()=>{}),h=g=>g==null?"":hr(g),A=Sr(g=>{var x,S;return(S=(x=n==null?void 0:n.onSlotsChanged)==null?void 0:x.call(n,g))!=null?S:(()=>{})},[n]);Te(A,()=>{var g;return(g=n==null?void 0:n.getSlotConfig(e))!=null?g:null},()=>null),Te(A,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let w=p===void 0?c[e]:void 0,o=p===void 0&&w===void 0&&n?n.getSlotConfig(e):null,m=(C=s!=null?s:n==null?void 0:n.getSitePalette())!=null?C:null,v=(G=a!=null?a:(_=n==null?void 0:n.getStyleVocabulary)==null?void 0:_.call(n))!=null?G:null,f=(()=>{var g,x,S;if(p!==void 0)return{config:p,arm:h(u),palette:m,vocabulary:(g=Wt())!=null?g:v,source:"override"};if(w!==void 0)return{config:w,arm:h((x=d[e])!=null?x:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:v,source:"preloaded"};if(o!==null){let k=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:o,arm:h((S=n==null?void 0:n.getSlotResult(e))!=null?S:d[e]),palette:m,vocabulary:v,source:k?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:v,source:"none"}})(),b=f.source==="preloaded"||f.source==="override";return fn(()=>{var F,$,H,L,M;if(!n||n.isLocal===!0||b)return;let g=f.source==="none",x=g&&($=(F=r.current)==null?void 0:F.call(r))!=null?$:null,S=x!=null&&x!==""?{[e]:x}:void 0,k=(H=i.current)==null?void 0:H.call(i),R=g&&(M=(L=l.current)==null?void 0:L.call(l))!=null?M:null,P=y(y({},k?{render:{[e]:k}}:{}),R?{skeletons:{[e]:R}}:{}),E=Object.keys(P).length>0;return n.requestSlots?E?n.requestSlots([e],S,P):S?n.requestSlots([e],S):n.requestSlots([e]):g&&(R?n.reportSlots([e],S!=null?S:{},{[e]:R}):S?n.reportSlots([e],S):n.reportSlots([e])),()=>{var ee;return(ee=n.cancelSlots)==null?void 0:ee.call(n,[e])}},[n,b,f.source,e]),fn(()=>{!N()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||gn.has(e)||(gn.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}import{cloneElement as br,Fragment as pn}from"react";import{jsx as V,jsxs as hn}from"react/jsx-runtime";function at(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var re={none:"0",sm:"8px",md:"16px",lg:"24px"},lt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},bn={sm:"0.875em",md:"1em",lg:"1.25em"},xr={sm:"1.25em",md:"1.5em",lg:"2em"},yn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},vn={sm:"8px",md:"16px",lg:"32px"},wr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},kr={normal:"400",medium:"500",bold:"700"};function Sn(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function xn(e,t,n){var i,l,d,c;let r=t==null?void 0:t.accent;return I(y({display:"inline-block",padding:(i=yn[n!=null?n:"md"])!=null?i:yn.md,borderRadius:(l=t==null?void 0:t.radius)!=null?l:"8px",font:"inherit"},n?{fontSize:bn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(d=t==null?void 0:t.primaryBg)!=null?d:"#111827":"transparent",color:e==="primary"?(c=t==null?void 0:t.primaryText)!=null?c:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Rr({node:e,opts:t}){var i,l,d,c,s;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(d=(l=t.palette)==null?void 0:l.border)!=null?d:"currentColor"}`,borderRadius:(s=(c=t.palette)==null?void 0:c.radius)!=null?s:"8px"};return hn("form",{onSubmit:a=>{var h,A,w;a.preventDefault();let p=new FormData(a.currentTarget),u={};for(let o of e.fields)u[o.name]=String((h=p.get(o.name))!=null?h:"");(A=t.onFormGoal)==null||A.call(t,e.submitGoal);try{(w=t.onFormSubmit)==null||w.call(t,u)}catch(o){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(a=>{var p,u;return hn("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[a.label,a.kind==="textarea"?V("textarea",{name:a.name,required:a.required,placeholder:a.placeholder,rows:3,style:r}):a.kind==="select"?V("select",{name:a.name,required:a.required,style:r,children:((p=a.options)!=null?p:[]).map(h=>V("option",{value:h,children:h},h))}):V("input",{name:a.name,type:(u=a.inputType)!=null?u:"text",required:a.required,placeholder:a.placeholder,style:r})]},a.name)}),V("button",{type:"submit",style:xn(n,t.palette),children:e.submitLabel})]})}function Cr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(l=>l.id===n))==null?void 0:i.classes:void 0}function wn(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 ve(e,t){var i;let n=Ar(e,t),r=wn(e.like,t);return n&&r?br(n,{style:I(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Ar(e,t){var n,r,i,l,d,c,s,a,p,u,h,A,w,o,m,v,f,b,C,_,G,g,x;try{let S=Cr(e,t);switch(e.type){case"stack":{let k=(r=re[(n=e.gap)!=null?n:"md"])!=null?r:re.md,R=e.surface==="raised"&&!S,P=(i=e.pad)!=null?i:R?"md":void 0;return V("div",I(y({},S?{className:S}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:lt[e.align]}:{}),e.justify?{justifyContent:lt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),P?{padding:(l=re[P])!=null?l:re.md}:{}),R?I(y(y({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(c=t.palette)!=null&&c.surface&&((s=t.palette)!=null&&s.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(a=t.palette)==null?void 0:a.border)!=null?p:"currentColor"}`,borderRadius:(h=(u=t.palette)==null?void 0:u.radius)!=null?h:"8px"}):{}),children:((A=e.children)!=null?A:[]).map((E,F)=>{let $=ve(E,t);return $===null?null:V(pn,{children:$},F)})}))}case"grid":{let k=(o=re[(w=e.gap)!=null?w:"md"])!=null?o:re.md;return V("div",I(y({},S?{className:S}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:lt[e.align]}:{}),e.pad?{padding:(m=re[e.pad])!=null?m:re.md}:{}),children:((v=e.children)!=null?v:[]).map((R,P)=>{let E=ve(R,t);return E===null?null:V(pn,{children:E},P)})}))}case"text":return S?V("p",{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:bn[e.size]}:{}),e.weight?{fontWeight:kr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Sn(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return S?V(k,{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V(k,{style:y(y({margin:0,fontSize:xr[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(b=e.emphasis)!=null?b:"primary";return V("a",I(y(y({href:at(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:xn(k,t.palette,e.size)}),{children:e.label}))}case"link":return V("a",I(y(y({href:at(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return V("img",I(y({src:at(e.src),alt:e.alt},S?{className:S}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:wr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return S?V("span",{className:S,children:e.value}):V("span",{style:y({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(C=t.palette)==null?void 0:C.border)!=null?_:"currentColor"}`},Sn(e.tone,t.palette)),children:e.value});case"spacer":return V("div",{style:{height:(G=vn[e.size])!=null?G:vn.md}});case"divider":return V("hr",{style:{border:"none",borderTop:`1px solid ${(x=(g=t.palette)==null?void 0:g.border)!=null?x:"currentColor"}`,margin:0,width:"100%"}});case"form":return V(Rr,{node:e,opts:t});default:return null}}catch(S){return null}}function ut(e,t){var l,d,c,s;let n=ve(e.tree,t);if(n===null)return null;let r=(l=e.surface)!=null&&l.like?(c=(d=t.vocabulary)==null?void 0:d.entries.find(a=>a.id===e.surface.like))==null?void 0:c.classes:void 0,i=wn((s=e.surface)==null?void 0:s.like,t);return r?V("div",I(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ne,isValidElement as Ie}from"react";import{normalizeLeafText as _r,skeletonFingerprint as Or}from"@sentientui/core/region";function Le(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function De(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ue(e){return Le(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ue(n),0):Ie(e)?ue(De(e)):0}function Er(e,t){return Array.isArray(t)?Ne(e,void 0,...t):Ne(e,void 0,t)}function ct(e,t){if(Le(e))return t;if(Array.isArray(e))return e.map(n=>ct(n,t));if(Ie(e)){let n=De(e);return ue(n)===0?e:Er(e,ct(n,t))}return e}function kn(e,t){return ue(e)===1?ct(e,t):null}var W=e=>e.join("/");function dt(e,t,n){if(Le(e)){n.leafPaths.push(t),n.texts.push(_r(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>dt(r,[...t,i],n));return}Ie(e)&&(n.elements.set(W(t),e),dt(De(e),[...t,"c"],n))}function gt(e){let t={leafPaths:[],texts:[],elements:new Map};return dt(e,[],t),t}function Pr(e){return gt(e).texts}function Rn(e){let t=Pr(e);return t.length===0?null:Or(t)}function Gr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Cn(e,t){let n=t.reduce((i,l)=>Math.max(i,l+1),0),r=[];for(let i=0;i<n;i++){let l=t.flatMap((c,s)=>c===i?[Gr(e.leafPaths[s])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let c of l.slice(1)){let s=new Set(c.map(W));d=d.filter(a=>s.has(W(a)))}r.push(d.length>0?d[d.length-1]:null)}return r}function ft(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function mt(e,t){let n=gt(t);if(n.texts.length!==e.leaves.length||n.texts.some((l,d)=>l!==e.leaves[d]))return null;let r=Cn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let c=r[d],s=c?n.elements.get(W(c)):void 0,a=!!s&&(typeof s.type=="string"||ft(s)!==void 0);return I(y({},l),{restylable:a})});return I(y({},e),{nodes:i})}function An(e,t,n){var w;let r=gt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((o,m)=>Math.max(o,m+1),0);for(let o of Object.keys(t.nodes))if(!/^\d+$/.test(o)||Number(o)>=i)return null;let l=Cn(r,n),d=new Map;n.forEach((o,m)=>{d.has(o)||d.set(o,m)});let c=new Map(r.leafPaths.map((o,m)=>[W(o),m])),s=new Set,a=new Map,p=!1;for(let[o,m]of Object.entries(t.nodes)){let v=Number(o),f=l[v];if(m.hidden&&(f?s.add(W(f)):p=!0),m.like!==void 0){let b=l[m.like],C=f?r.elements.get(W(f)):void 0,_=b?ft(r.elements.get(W(b))):void 0;!f||_===void 0||ft(C)===void 0?p=!0:a.set(W(f),_)}}let u=new Map(Object.entries((w=t.order)!=null?w:{})),h=(o,m)=>{var v;if(Le(o)){let f=c.get(W(m));if(f===void 0)return o;let b=n[f],C=(v=t.nodes[String(b)])==null?void 0:v.text;return C===void 0?o:d.get(b)===f?C:""}if(Array.isArray(o)){let f=o.map((b,C)=>h(b,[...m,C]));for(let[b,C]of u){let _=C.map(x=>{let S=l[x];return!S||S.length!==m.length+1||W(S.slice(0,-1))!==W(m)?-1:S[S.length-1]});if(_.some(x=>x<0))continue;let G=[..._].sort((x,S)=>x-S),g=[...f];G.forEach((x,S)=>{f[x]=g[_[S]]}),u.delete(b)}return f}if(Ie(o)){let f=W(m);if(s.has(f))return null;let b=De(o);if(ue(b)===0)return o;let C=h(b,[...m,"c"]),_=a.get(f),G=_!==void 0?{className:_}:void 0;return Array.isArray(C)?Ne(o,G,...C):Ne(o,G,C)}return o},A=h(e,[]);return p||u.size>0?null:A}import{jsx as Nr}from"react/jsx-runtime";var En=new Set,Pn=new Set,Gn=new Set,Tn="authored.";function Ve({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,as:d="div",reportBaselineText:c=!0}){var xt,wt;let s=D(),a=Z(),p=yt(null),u=pt(()=>Rn(t),[t]),h=n?Object.keys(n).join("|"):"",A=pt(()=>y({fp:u!=null?u:"0000000000000000",forms:!!r,compose:!0,content:ue(t)===1},h!==""?{authored:h.split("|"),children:!0}:{}),[u,t,r,h]),w=()=>{var X;let O=p.current;if(!O||!c)return null;let T=On(O);return T.skeleton?(X=mt(T.skeleton,t))!=null?X:I(y({},T.skeleton),{editable:!1,nodes:T.skeleton.nodes.map(ie=>I(y({},ie),{restylable:!1}))}):{status:T.reason}},{config:o,arm:m,palette:v,vocabulary:f,source:b}=mn(e,{baselineText:c?()=>{var O,T;return(T=(O=p.current)==null?void 0:O.textContent)!=null?T:null}:void 0,render:()=>A,skeleton:w}),C=m!==""?(xt=o==null?void 0:o.blocks)==null?void 0:xt[m]:void 0,_=m!==""?(wt=o==null?void 0:o.compose)==null?void 0:wt[m]:void 0,G=(C!==void 0&&_n(C)||_!==void 0&&_n(_.tree))&&!r;U(()=>{!G||!N()||En.has(e)||(En.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.`))},[G,e]);let g=O=>{!s||b==="override"||(b!=="seeded"&&s.componentGoal(e,O),s.goal(O,{metadata:{componentId:e,arm:m},weight:1,stepIndex:0}))},x=t,S=!1,k=m.startsWith(Tn)?m.slice(Tn.length):null;if((o==null?void 0:o.blocked)==="variant_history")S=!0;else if(k!==null)n&&Object.prototype.hasOwnProperty.call(n,k)?x=n[k]:S=!0;else if(_!==void 0){let O=G?null:ut(_,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});O===null?S=!0:x=O}else if(C!==void 0){let O=G?null:ve(C,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});O===null?S=!0:x=O}else if((o==null?void 0:o.edits)!==void 0&&b!=="none"){let O=o.edits,T=O.fp===u?An(t,O.edits,O.leafToNode):null;T===null?S=!0:x=T}else if((o==null?void 0:o.content)!==void 0&&b!=="none"){let O=kn(t,o.content);O===null?S=!0:x=O}let R=S&&C===void 0&&_===void 0&&(o==null?void 0:o.edits)===void 0&&k===null&&(o==null?void 0:o.blocked)===void 0;U(()=>{(o==null?void 0:o.blocked)!=="variant_history"||!N()||Gn.has(e)||(Gn.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.`))},[o==null?void 0:o.blocked,e]);let P=k!==null&&!S?k:null;U(()=>{var Se;if(!P||!c||!s)return;let O=p.current;if(!O)return;let T=On(O),X=T.skeleton?mt(T.skeleton,n==null?void 0:n[P]):null,ie=(Se=O.textContent)==null?void 0:Se.trim();s.reportSlots([],void 0,void 0,{[e]:[y(y({key:P},ie?{text:ie}:{}),X?{skeleton:X}:{})]})},[P,s,e]);let E=S&&(o==null?void 0:o.edits)!==void 0&&(b==="preloaded"||b==="client");U(()=>{var O;!E||!(o!=null&&o.edits)||(O=s==null?void 0:s.reportDrift)==null||O.call(s,e,o.edits.fp,u,o.edits.fp===u?"unaddressable":"fp_mismatch")},[E,e,u,s]);let F=x===t;U(()=>{var T;if(!(o!=null&&o.needsSkeleton)||!F)return;let O=w();O&&((T=s==null?void 0:s.reportSkeleton)==null||T.call(s,e,O))},[o==null?void 0:o.needsSkeleton,F,e,s]),U(()=>{if(!F)return;let O=zt(e);if(!O)return;let T=w();qt(O,T&&"status"in T?{status:T.status}:{skeleton:T})},[e,F]),U(()=>{!R||!N()||Pn.has(e)||(Pn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[R,e]);let $=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";U(()=>de({id:e,arms:$===""?void 0:$.split("|")}),[e,$]);let H=yt(null);U(()=>{!s||b==="none"||b==="seeded"||b==="override"||m===""||S||H.current!==m&&(H.current=m,ne(s,a,e,m))},[s,a,e,m,b,S]);let L=b!=="none"&&b!=="seeded"&&!S,M=L?m:"",ee=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);U(()=>{if(!s||!i||b==="override")return;let O=p.current;if(!O)return;let T=te(i),X=z(i),ie=!1;return q(O,J(i),{fireGoal:()=>{ie||(ie=!0,L&&(X!==void 0?s.componentGoal(e,T,{value:X}):s.componentGoal(e,T)),s.goal(T,y({metadata:{componentId:e,arm:M},weight:1,stepIndex:0},X!==void 0?{value:X}:{})))},fireStep:(Se,kt,Un)=>{L&&s.componentGoal(e,Se,{reward:kt}),s.goal(Se,{metadata:{componentId:e,arm:M},weight:kt,stepIndex:Un})}},T)},[s,e,ee,m,b,S,L,M]);let ke=yt(null);U(()=>{let O=p.current;if(O){if(ke.current===null){ke.current=m;return}ke.current!==m&&(ke.current=m,Tr(O))}},[m]);let Jn=pt(()=>y({"data-sentient-slot":e},m!==""?{"data-sentient-arm":m}:{}),[e,m]);return Nr(d,I(y({ref:p,className:l},Jn),{children:x}))}import{jsx as Fe}from"react/jsx-runtime";function Vr(e){var p,u;let{client:t,variantId:n,content:r,ref:i}=Ge(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=Dr(!1);Lr(()=>{d(!0)},[]);let c=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!l||!t)||!n)return null;let s=(u=e.variants[n])!=null?u:null,a=s===null?r:null;return N()&&s===null&&a===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Fe(c,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:a})}var Fr=Ir(Vr,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Mr(e){if(e.variants===void 0)return Fe(Ve,y({},e));let t=e;if(t.children!=null){N()&&Br(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:c,variants:s}=n,a=Ce(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return Fe(Ve,I(y({},a),{children:t.children,variants:s}))}return Fe(Fr,y({},t))}var Nn=new Set;function Br(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||Nn.has(e.id)||(Nn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}import{useEffect as Me,useMemo as $r,useRef as vt,useState as In,useSyncExternalStore as jr}from"react";import{jsx as Kr}from"react/jsx-runtime";function Wr({id:e,default:t,component:n="span",className:r,goal:i}){var G;let l=D(),d=Z(),c=Oe(),s=xe(),a=vt(null),p=vt(null),u=jr(K,()=>ye(e),()=>null),[h,A]=In(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.content)!=null?x:null}),[w,o]=In(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.variantId)!=null?x:null});Me(()=>{if(u||!l)return;let g=l.getAssignment(e,s);if((g==null?void 0:g.content)!==void 0){o(g.variantId),A(g.content);return}let x=!1;return l.assign(e).then(S=>{if(!x){if(!S){N()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}o(S.variantId),S.content&&A(S.content)}}),()=>{x=!0}},[l,e,s,u]),Me(()=>{u||!l||!w||!d||a.current!==w&&(a.current=w,l.track({projectId:d,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),c==null||c(e,w))},[l,w,d,e,c,u]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=$r(()=>i===void 0?null:J(i),[m]),f=i===void 0?null:typeof i=="string"?i:v.type,b=vt(!1);Me(()=>{b.current=!1},[w,m]),Me(()=>{if(u||!l||!w||!d||!v||!f)return;let g=p.current;if(!g)return;let x=z(v);return q(g,v,{fireGoal:()=>{b.current||(b.current=!0,l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:f,payload:y({reward:1},x!==void 0?{goalValue:x}:{})}),l.goal(f,y({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(S,k,R)=>{l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:S,payload:{reward:k}}),l.goal(S,{metadata:{},weight:k,stepIndex:R})}})},[l,w,d,e,v,f,u]);let C=h!=null?h:t;if(u){let g=l==null?void 0:l.getAssignment(e,s);C=g&&g.variantId===u&&(G=g.content)!=null?G:t}return Kr(n,{ref:g=>{p.current=g},className:r,children:C})}import{useCallback as Jr,useRef as Ur}from"react";function St(e){let t=D(),n=Ur(new Set);return Jr((r,i)=>{var l,d;if(!ye(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,y(y(y({metadata:(l=i==null?void 0:i.metadata)!=null?l:{},weight:(d=i==null?void 0:i.reward)!=null?d:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as Hr,useRef as Ln}from"react";function Xr(e,t={}){let s=t,{componentId:n}=s,r=Ce(s,["componentId"]),i=D(),l=St(n!=null?n:""),d=Ln(!1),c=Ln(r);c.current=r,Hr(()=>{if(!i||d.current||i.gated)return;d.current=!0;let{metadata:a,reward:p,value:u,currency:h,externalId:A}=c.current;if(n){l(e,c.current);return}i.goal(e,y(y(y({metadata:a!=null?a:{},weight:p!=null?p:1,stepIndex:0},u!==void 0?{value:u}:{}),h!==void 0?{currency:h}:{}),A!==void 0?{externalId:A}:{}))},[i,n,e,l])}import{renderPrePaintScript as zr}from"@sentientui/core";import{confidenceBand as qr}from"@sentientui/policy";import{jsx as Qr}from"react/jsx-runtime";function Dn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Yr(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Dn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Dn(qr(e.persona.confidence))+");}catch(e){}})();":zr(e.apiKey)}function Zr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:Qr("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Yr(e)}})}import{useEffect as je,useMemo as bt,useRef as si}from"react";import{validateSlotDecl as ai}from"@sentientui/policy";import{useEffect as ht,useReducer as ei,useState as ti,useSyncExternalStore as Vn}from"react";import{armOfResult as Be,baselineResultFor as ni}from"@sentientui/core";import{confidenceBand as ri}from"@sentientui/policy";function $e(e,t){let n=D(),r=Ee(),[,i]=ei(u=>u+1,0),l=Vn(K,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),d=l===void 0?r[e]:void 0,c=l===void 0&&d===void 0&&n?n.getSlotResult(e):null,s=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&c===null;ht(()=>{if(!s||!n)return;let u=!1;return n.decide({slots:[t]}).then(h=>{!u&&h&&i()}),()=>{u=!0}},[n,e,s]);let a=(()=>{if(l!==void 0)return{result:l,arm:Be(l),source:"override"};if(d!==void 0)return{result:d,arm:Be(d),source:"preloaded"};if(c!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:c,arm:Be(c),source:h?"client":"seeded"}}let u=ni(t);return{result:u,arm:Be(u),source:"baseline"}})(),p=a.source==="preloaded"||a.source==="override";return ht(()=>{var h;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let u=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var A;(A=n.cancelSlots)==null||A.call(n,[e]),u==null||u()}},[n,e,p]),a}function ii(){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 oi(){let e=D(),t=sn();Vn(K,Nt,()=>0);let[n,r]=ti(!1);ht(()=>r(!0),[]);let i=c=>({persona:c.persona,confidence:c.confidence,band:ri(c.confidence)});if(!n)return t?i(t):null;let l=ii();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var Fn=new Set;function li(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function ui(e,t,n){let r=D(),i=Z(),l=JSON.stringify(t),d=bt(()=>({id:e,dims:t}),[e,l]),{result:c,arm:s,source:a}=$e(e,d),p=bt(()=>typeof c=="string"?{}:c,[s]);if(N()&&!Fn.has(e)){Fn.add(e);let o=ai({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),m=Object.values(t).reduce((v,f)=>v*f.length,1);o.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${o.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);je(()=>de({id:e,dims:t}),[e]);let h=si(null);je(()=>{!r||a==="baseline"||a==="seeded"||a==="override"||h.current===s||(h.current=s,ne(r,i,e,s))},[r,i,e,s,a]);let A=n==null?void 0:n.funnel;je(()=>{var o;!r||!A||a==="override"||ce(r,i,e,A,J((o=n==null?void 0:n.goal)!=null?o:"click"))},[r,i,e,A,u,a]),je(()=>{if(!r||!(n!=null&&n.goal)||a==="override"||a==="baseline"||a==="seeded")return;let o=document.querySelector(`[data-sentient-slot="${li(e)}"]`);if(!o){N()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let m=te(n.goal),v=z(n.goal),f=!1;return q(o,J(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,m,{value:v}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:s},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,C,_)=>{r.componentGoal(e,b,{reward:C}),r.goal(b,{metadata:{componentId:e,arm:s},weight:C,stepIndex:_})}},m)},[r,e,u,s,a]);let w=bt(()=>{let o={"data-sentient-slot":e};for(let[m,v]of Object.entries(p))o[`data-${m}`]=v;return o},[e,p]);return{tokens:p,props:w}}import{useCallback as ci,useEffect as di,useMemo as fi}from"react";var Mn=new Set;function gi(e,t){var A;if(N()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:l,goalLabel:d,ref:c,nodeRef:s}=Ge(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),a=(A=i!=null?i:r[0])!=null?A:"",p=t.variants[a];di(()=>{if(!N()||!n)return;let w=setTimeout(()=>{!s.current&&!Mn.has(e)&&(Mn.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(w)},[n,e]);let u=ci((w,o)=>{var v,f;if(l)return;let m=w!=null?w:d;m&&(n==null||n.componentGoal(e,m,o),n==null||n.goal(m,y(y(y({metadata:(v=o==null?void 0:o.metadata)!=null?v:{},weight:(f=o==null?void 0:o.reward)!=null?f:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{})))},[n,e,d,l]),h=fi(()=>({ref:c,"data-sentient-id":e,"data-sentient-variant":a}),[c,e,a]);return{variant:a,value:p,bind:h,fireGoal:u}}import{Children as mi,isValidElement as pi,useEffect as We,useMemo as Bn,useRef as $n}from"react";import{jsx as vi}from"react/jsx-runtime";var Ke=new Set;function yi(e){var v;let t=D(),n=Z(),r=$n(null),i=Object.keys(e.arrangements).join(" "),l=Bn(()=>Object.keys(e.arrangements),[i]),d=Bn(()=>y({id:e.id,arms:l},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,l,e.baseline]),{arm:c,source:s}=$e(e.id,d);N()&&e.baseline!==void 0&&e.baseline!==l[0]&&!Ke.has(e.id+":baseline")&&(Ke.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${l[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let a=mi.toArray(e.children).filter(pi),p=new Map;for(let f of a)p.set(String((v=f.key)!=null?v:"").replace(/^\.\$/,""),f);let u=e.arrangements[c],h=u!==void 0&&u.length===a.length&&u.every(f=>p.has(f));N()&&u!==void 0&&!h&&!Ke.has(e.id+":keys")&&(Ke.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${c}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let A=h?u.map(f=>p.get(f)):a;We(()=>de({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=$n(null);We(()=>{!t||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,ne(t,n,e.id,c))},[t,n,e.id,c,s]);let o=e.funnel;We(()=>{var f;!t||!o||s==="override"||ce(t,n,e.id,o,J((f=e.goal)!=null?f:"click"))},[t,n,e.id,o,s]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return We(()=>{if(!t||e.goal===void 0||s==="override"||s==="baseline"||s==="seeded")return;let f=r.current;if(!f)return;let b=te(e.goal),C=z(e.goal),_=!1;return q(f,J(e.goal),{fireGoal:()=>{_||(_=!0,C!==void 0?t.componentGoal(e.id,b,{value:C}):t.componentGoal(e.id,b),t.goal(b,y({metadata:{componentId:e.id,arm:c},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(G,g,x)=>{t.componentGoal(e.id,G,{reward:g}),t.goal(G,{metadata:{componentId:e.id,arm:c},weight:g,stepIndex:x})}},b)},[t,e.id,m,c,s]),vi("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":c,children:A})}import{deriveSessionSegment as Si}from"@sentientui/core";var hi=["page","blocks","layoutOrder"],jn=new Map;function bi(e,t){jn.set(e,t)}function Wn(e){return jn.get(e)}function xi(e){var i,l;let t=(l=(i=e.content)!=null?i:Wn(e.page))!=null?l:{},n={};for(let[d,c]of Object.entries(t))hi.includes(d)||(n[d]=c);let r=I(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function wi(e){return`<script type="application/ld+json">${Kn(e)}</script>`}function Kn(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function ki(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
2
+ var Hn=Object.defineProperty,Xn=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Re=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,At=Object.prototype.propertyIsEnumerable;var Rt=(e,t,n)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ct.call(t,n)&&Rt(e,n,t[n]);if(Re)for(var n of Re(t))At.call(t,n)&&Rt(e,n,t[n]);return e},I=(e,t)=>Xn(e,zn(t));var Ce=(e,t)=>{var n={};for(var r in e)Ct.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Re)for(var r of Re(e))t.indexOf(r)<0&&At.call(e,r)&&(n[r]=e[r]);return n};import{createContext as rr,useContext as j,useEffect as Y,useMemo as en,useRef as Q,useState as be,useSyncExternalStore as ir}from"react";import{deriveSessionSegment as or,init as sr}from"@sentientui/core";var _t=new Map,Ae=new Map;function Ot(e,t){let n=Ae.get(e);return n||(n=new Set,Ae.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ae.delete(e)}}function Et(e,t){_t.set(e,t);let n=Ae.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function Je(e){var t;return(t=_t.get(e))!=null?t:null}var qn={on:!1,listeners:new Set};function Pt(){if(typeof window=="undefined")return qn;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function Ue(){return Pt().on}function Gt(e){let t=Pt().listeners;return t.add(e),()=>{t.delete(e)}}function Tt(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,i)=>e.assign(t,n,r,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var He="sentient:overrides-changed";function Nt(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function Xe(){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(He))}function K(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(He,e),()=>window.removeEventListener(He,e))}function It(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function N(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function J(e){return typeof e=="string"?{type:"click"}:e}function te(e){return typeof e=="string"?e:e.type}function z(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ze=new Set,qe=!1;function Lt(e){if(ze.has(e))return!0;if(ze.add(e),!qe){qe=!0;let t=()=>{qe=!1,ze.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 Yn(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function Dt(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Yn(r))return!0;r=r.parentElement}return!1}function q(e,t,n,r){if(t.type==="weighted_composite"){let a=new Set,p=[];return t.steps.forEach(({goal:u,name:h,weight:A},w)=>{let o=(m=!1)=>{a.has(w)||m&&r!==void 0&&Lt(`step\0${h}\0${A}\0${w}`)||(a.add(w),n.fireStep(h,A,w))};if(u.type==="click"){let m=v=>{let f=v.target;f instanceof Element&&Dt(f,e,u.selector)&&o()};e.addEventListener("click",m),p.push(()=>e.removeEventListener("click",m));return}if(u.type==="form_submit"){let m=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&o()};e.addEventListener("submit",m),p.push(()=>e.removeEventListener("submit",m));return}if(u.type==="scroll_depth"){let m=Math.max(0,Math.min(1,u.threshold)),v=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=m){o(!0),v.disconnect();break}},{threshold:[m]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let u of p)u()}}let i=t.type==="composite"?t.all:[t],l=new Set(i.map((a,p)=>p)),d=()=>{r!==void 0&&Lt(r)||n.fireGoal()},c=(a,p=!1)=>{l.delete(a),l.size===0&&(p?d():n.fireGoal())},s=[];return i.forEach((a,p)=>{if(a.type==="click"){let u=h=>{let A=h.target;A instanceof Element&&Dt(A,e,a.selector)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("click",u),s.push(()=>e.removeEventListener("click",u));return}if(a.type==="form_submit"){let u=h=>{h.target instanceof HTMLFormElement&&e.contains(h.target)&&(t.type==="composite"?c(p):n.fireGoal())};e.addEventListener("submit",u),s.push(()=>e.removeEventListener("submit",u));return}if(a.type==="scroll_depth"){let u=Math.max(0,Math.min(1,a.threshold)),h=new IntersectionObserver(A=>{for(let w of A)if(w.intersectionRatio>=u){t.type==="composite"?c(p,!0):d(),h.disconnect();break}},{threshold:[u]});h.observe(e),s.push(()=>h.disconnect());return}}),()=>{for(let a of s)a()}}var Vt=new Set,Ft=new Set;function ce(e,t,n,r,i){let l=`${r}|${n}`;if(Ft.has(l))return;Ft.add(l);let d=i.type==="weighted_composite"&&!Vt.has(r);d&&Vt.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:d?{funnelId:r,steps:i.steps.map(c=>({goalId:c.name,weight:c.weight}))}:{funnelId:r}})}function ne(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Zn={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function oe(){if(typeof window=="undefined")return Zn;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 he(){oe().version+=1;for(let e of oe().listeners)e()}var Mt=()=>{};function Bt(e){return N()?(oe().components.set(e.id,e),he(),()=>{oe().components.delete(e.id),he()}):Mt}function de(e){return N()?(oe().slots.set(e.id,e),he(),()=>{oe().slots.delete(e.id),he()}):Mt}function Ye(e){N()&&(oe().sections=[...e],he())}var $t="0.37.4",Ze=$t!=="0.0.0-dev"?{name:"react",version:$t}:void 0;function Qn(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function fe(e,t){Qn()[e]=t}function jt(e){window.__sentient_vocabulary_override=e}function Wt(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function er(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function ge(e,t){er()[e]=t}function Kt(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let l=n.slice(0,r.index)+i;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var et="__snt_editor_token",me=null,Qe=!1;function Jt(){return Qe}function tr(){try{return sessionStorage.getItem(et)}catch(e){return null}}function _e(e){if(me)return me;let t=typeof window=="undefined"?null:Kt("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:tr();return Qe=!!n,me=Promise.resolve(n?{token:n,fresh:!1}:null),me}return Qe=!0,me=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(et,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),me}function Ut(){try{sessionStorage.removeItem(et)}catch(e){}}var Ht="sentient_preview_cell",Xt="sentient_refresh_region",tt="sentient-cell-preview-bar",se="__preview__",pe=null;function zt(e){if((pe==null?void 0:pe.slotId)!==e)return null;let t=pe;return pe=null,t}function qt(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(y({slotId:e.slotId},t))})}).then(n=>ae(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>ae("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Yt(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(tt))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(Ht),n=s.get(Xt)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=_e(r);if(!Jt())return;if(n){pe={slotId:n,session:i,base:r},fe(n,{kind:"arms"}),ge(n,se),Xe();return}if(!t)return;let l=t.lastIndexOf("~");if(l<=0)return;let d=t.slice(0,l),c=t.slice(l+1);i.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(d)}&persona=${encodeURIComponent(c)}`,{headers:{authorization:`Bearer ${s.token}`}}):(ae(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){ae(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&jt(a.vocabulary),a.compose!=null)fe(d,{kind:"arms",compose:{[se]:a.compose}}),ge(d,se);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))fe(d,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),ge(d,se);else if(a.blocks!=null)fe(d,{kind:"arms",blocks:{[se]:a.blocks}}),ge(d,se);else if(a.content!=null)fe(d,{kind:"arms",content:a.content}),ge(d,se);else{ae("Nothing to preview in that square yet.");return}Xe(),ae(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${d}"]`))==null||p.scrollIntoView({block:"center"})}catch(u){}},300)}).catch(()=>ae("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function ae(e){var i;if(document.getElementById(tt))return;let t=document.createElement("div");t.id=tt,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=()=>{Ut();let l=new URL(window.location.href);l.searchParams.delete(Ht),l.searchParams.delete(Xt),window.location.assign(l.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var Zt=!1;function Qt(e){if(Zt||typeof window=="undefined")return;Zt=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");_e(t).then(n=>{!n||!("token"in n)||!n.fresh||nr(t,n.token)})}function nr(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})}import{jsx as fr}from"react/jsx-runtime";function ar(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return or({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",B=rr({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:nn,debug:!1}),tn=!1,nt=new Set;function lr(e,t,n){let r=Q(n);r.current=n;let[i,l]=be(null),[d,c]=be(!1),s=Q(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(I(y({},e),{check:typeof e.check,refused:typeof e.refused}));return Y(()=>{let p=s.current;if(p===void 0||typeof window=="undefined")return;let u,h=!1;return import("@sentientui/core/consent").then(({consentWatcher:A,forgetVisitor:w})=>{if(h)return;let o=A(typeof p=="object"&&p.cmp===void 0&&p.check?y(I(y({},p),{check:()=>s.current.check()}),p.refused?{refused:()=>{var f,b;return((b=(f=s.current).refused)==null?void 0:b.call(f))===!0}}:{}):p),m=!1,v=()=>{let f=o.refused()&&o.read()!==!0;f&&!m&&(w(t),r.current()),m=f,c(f);let b=o.read();b!==null&&nt.add(t),l(b!=null?b:nt.has(t)?!1:null)};v(),u=o.subscribe(v)}),()=>{h=!0,u==null||u()}},[a,t]),{granted:i,refused:d}}function ur(e){var C,_,G;let[t,n]=be(null),[r]=be(()=>{var g;return(g=e.sessionSegment)!=null?g:ar()}),[i,l]=be(Ue());Y(()=>Gt(()=>l(Ue())),[]),Y(()=>{Yt(e.apiBaseUrl),Qt(e.apiBaseUrl)},[]);let d=Q(()=>{}),c=lr(e.consentFrom,e.apiKey,()=>d.current()),s=e.consentFrom?(C=c.granted)!=null?C:nt.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?c.refused:!0,p=Q(a);p.current=a;let u=Q(null),h=Q(!1),A=Q([]),w=Q(!1);d.current=()=>{var x;A.current=[],w.current=!0;let g=u.current;g!=null&&g.gated?g.dispose():(x=g==null?void 0:g.takeHeld)==null||x.call(g)},Y(()=>{var $,H;if(p.current&&s===!1&&(A.current=[]),s===!1&&h.current&&(p.current&&(($=u.current)==null||$.destroy()),u.current=null,h.current=!1),s===!1&&!e.preConsentBehavior){p.current&&((H=u.current)==null||H.destroy()),u.current=null,n(null);return}let g=s!==!1;g&&(w.current=!1);let x=L=>{!g&&w.current&&L.gated&&L.dispose()},S=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},Ze?{sdk:Ze}:{}),k=!1,R=null,P=null,E=L=>{for(let M of A.current.splice(0))setTimeout(()=>{if(u.current!==L){w.current||A.current.push(M);return}try{M(L)}catch(ee){}},0)},F=L=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:M})=>{k||(P=M(L,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:L})=>{k||(R=L(I(y({},S),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),x(R),u.current=R,h.current=g,E(R),n(R),F(R))}):(R=sr(S),x(R),u.current=R,h.current=g,E(R),n(R),F(R)),()=>{var L,M;k=!0,P==null||P(),A.current=A.current.concat((M=(L=R==null?void 0:R.takeHeld)==null?void 0:L.call(R))!=null?M:[]),R==null||R.dispose()}},[s]),Y(()=>{if(!t)return;let g=!1,x=async()=>{if(g)return;let k;try{k=await t.fetchWeights()}catch(R){return}if(!g)for(let R of k){let P={componentId:R.componentId,updatedAt:R.updatedAt,variants:R.variants.map(E=>{var F;return{variantId:E.variantId,pulls:E.pulls,avgReward:(F=E.avgReward)!=null?F:0}})};Et(R.componentId,P)}};x();let S=setInterval(()=>{x()},6e4);return()=>{g=!0,clearInterval(S)}},[t]);let o=(_=e.ssrFallback)!=null?_:"first",m=((G=e.apiBaseUrl)!=null?G:nn).replace(/\/$/,""),v=Q(null);Y(()=>{var S;if(typeof process!="undefined"&&((S=process.env)==null?void 0:S.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:m},x=v.current;if(v.current=g,x!==null)for(let k of["apiKey","context","country","persona","apiBaseUrl"])Object.is(x[k],g[k])||console.warn(`[sentient] AdaptiveProvider: \`${k}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,m]),Y(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||It({apiKey:e.apiKey,apiBaseUrl:m,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,m]),Y(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){Ye(g);return}e.declaredSections&&e.declaredSections.length>0&&Ye(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),Y(()=>{!N()||e.consent!==void 0||e.consentFrom!==void 0||tn||(tn=!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'))},[]),Y(()=>{if(!N())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let x=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),k=>k.getAttribute("data-sentient-id"))),S=g.filter(k=>!x.has(k));S.length>0&&console.warn(`[SentientUI] Declared section${S.length>1?"s":""} ${S.map(k=>`"${k}"`).join(", ")} ${S.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let f=en(()=>t&&i?Tt(t):t,[t,i]),b=en(()=>{var g,x,S,k,R,P,E,F;return{client:f,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},sessionSegment:r,ssrFallback:o,onAssignment:e.onAssignment,initialLayoutOrder:(x=e.initialLayoutOrder)!=null?x:null,initialSlots:(S=e.initialSlots)!=null?S:{},initialSlotConfig:(k=e.initialSlotConfig)!=null?k:{},initialPalette:(R=e.initialPalette)!=null?R:null,initialVocabulary:(P=e.initialVocabulary)!=null?P:null,initialPersona:(E=e.initialPersona)!=null?E:null,apiBaseUrl:m,debug:(F=e.debug)!=null?F:!1}},[f,e.apiKey,e.initialAssignments,r,o,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,m,e.debug]);return fr(B.Provider,{value:b,children:e.children})}function D(){return j(B).client}function Z(){return j(B).apiKey}function rt(){return j(B).initialAssignments}function xe(){return j(B).sessionSegment}function rn(){return j(B).ssrFallback}function Oe(){return j(B).onAssignment}function on(){return j(B).debug}function cr(){let e=j(B).initialLayoutOrder,t=ir(K,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ee(){return j(B).initialSlots}function sn(){return j(B).initialPersona}function an(){return j(B).initialSlotConfig}function ln(){return j(B).initialPalette}function un(){return j(B).initialVocabulary}function dr(){return j(B).apiBaseUrl}import{memo as Ir,useEffect as Lr,useState as Dr}from"react";import{useCallback as pr,useEffect as le,useMemo as dn,useRef as we,useState as yr}from"react";import{attachMicroSignalDetectors as vr}from"@sentientui/core";import{useEffect as Pe,useRef as cn,useState as gr,useSyncExternalStore as mr}from"react";import{pickFromWeights as it}from"@sentientui/policy";function ye(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let l=i.indexOf(":");if(l!==-1&&i.slice(0,l)===e)return i.slice(l+1)}}catch(r){}return null}function ot(e,t,n,r){let i=rt(),l=rn(),d=D(),c=xe(),s=Oe(),a=on(),p=cn(null),u=mr(K,()=>ye(e),()=>null),h=u&&t.includes(u)?u:null,A=cn(null);Pe(()=>{a&&h&&A.current!==h&&(A.current=h,console.info(`[sentient] override active: ${e} -> ${h}`))},[a,h,e]);let[w,o]=gr(()=>{var b,C;if(h)return{variantId:h,content:null,isLoading:!1,settled:!0};if(!d){let _=i[e];return _&&t.includes(_)?{variantId:_,content:null,isLoading:!1,settled:!0}:l==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content))return{variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0};let f=Je(e);if(f){let _=it(f.variants,t);if(_)return{variantId:_,content:null,isLoading:!1,settled:!0}}return{variantId:(C=t[0])!=null?C:null,content:null,isLoading:!1,settled:!1}}),m=v=>{s&&p.current!==v&&(p.current=v,s(e,v))};return Pe(()=>{var b;if(h||!d)return;let v=d.getAssignment(e,c);if(v&&(t.includes(v.variantId)||v.content)){o({variantId:v.variantId,content:(b=v.content)!=null?b:null,isLoading:!1,settled:!0}),m(v.variantId);return}let f=Je(e);if(f&&w.settled&&w.variantId&&w.variantId===it(f.variants,t)){m(w.variantId);return}o(C=>{var _;return C.variantId?C:{variantId:(_=t[0])!=null?_:null,content:null,isLoading:!1,settled:!1}})},[h,d,e,c]),Pe(()=>{if(h||!d)return;let v=d.getAssignment(e,c);if(v&&t.includes(v.variantId))return;let f=!1;return d.assign(e,t,n,r).then(b=>{var C;f||b&&(!t.includes(b.variantId)&&!b.content||(o({variantId:b.variantId,content:(C=b.content)!=null?C:null,isLoading:!1,settled:!0}),m(b.variantId)))}),()=>{f=!0}},[h,d,e,c]),Pe(()=>{if(!h&&d)return Ot(e,v=>{var C;let f=d.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){o({variantId:f.variantId,content:(C=f.content)!=null?C:null,isLoading:!1,settled:!0}),m(f.variantId);return}let b=it(v.variants,t);b&&(o({variantId:b,content:null,isLoading:!1,settled:!0}),m(b))})},[h,d,e,c]),h?{variantId:h,content:null,isLoading:!1,settled:!0,isOverride:!0}:w}function Ge(e,t,n){let r=D(),i=Z(),l=Object.keys(t).join("\0"),d=dn(()=>Object.keys(t),[l]),{variantId:c,content:s,isOverride:a=!1,settled:p}=ot(e,d,n.agentData,n.agentDataByVariant),[u,h]=yr(null),A=we(null),w=pr(k=>{A.current=k,h(k)},[]),o=n.goal,m=typeof o=="string"?o:JSON.stringify(o),v=dn(()=>o?J(o):null,[m]),f=o?te(o):"";le(()=>Bt({id:e,variantIds:d,goal:f}),[e,d,f]);let b=we(null);le(()=>{a||p&&(!r||!c||!i||!u||b.current!==c&&(b.current=c,ne(r,i,e,c)))},[r,c,i,e,u,a,p]);let C=we(!1),_=we(new Set);le(()=>{C.current=!1,_.current=new Set},[c,v]);let G=n.funnel;le(()=>{a||!p||!r||!G||!v||ce(r,i,e,G,v)},[r,i,e,G,v,a,p]);let g=n.cursorSignal===!0;le(()=>{if(!g||a||!p||!r||!c||!u)return;let k=null,R=0,P=()=>{R=Date.now(),k=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-R}}),k=null},800)},E=()=>{k!==null&&(clearTimeout(k),k=null)};return u.addEventListener("mouseenter",P),u.addEventListener("mouseleave",E),()=>{u.removeEventListener("mouseenter",P),u.removeEventListener("mouseleave",E),k!==null&&clearTimeout(k)}},[g,r,c,i,e,u,a,p]);let x=we(n.microSignalGoals);x.current=n.microSignalGoals;let S=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return le(()=>{if(a||!p||!r||!c||!u)return;let k=Date.now();return vr((R,P={})=>{var L,M,ee;r.track({projectId:i,componentId:e,variantId:c,eventType:"micro_signal",payload:y({signalType:R},P)});let E=(L=x.current)==null?void 0:L[R];if(!E||_.current.has(R))return;_.current.add(R);let F=typeof E=="string"?E:E.name,$=typeof E=="string"?1:(M=E.weight)!=null?M:1,H=typeof E=="string"?0:(ee=E.stepIndex)!=null?ee:0;r.goal(F,{metadata:y({signalType:R},P),weight:$,stepIndex:H})},u,k)},[r,c,i,e,u,S,a,p]),le(()=>{if(a||!p||!r||!c||!u||!v)return;let k=z(v);return q(u,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:f,payload:y({reward:1},k!==void 0?{goalValue:k}:{})}),r.goal(f,y({metadata:{componentId:e,variantId:c},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(R,P,E)=>{r.track({projectId:i,componentId:e,variantId:c,eventType:"goal_achieved",goalType:R,payload:{reward:P}}),r.goal(R,{metadata:{},weight:P,stepIndex:E})}},f)},[r,c,i,e,u,v,f,a,p]),{client:r,variantIds:d,variantId:c,content:s,settled:p,isOverride:a,goalLabel:f,ref:w,nodeRef:A}}import{useEffect as U,useMemo as pt,useRef as yt}from"react";import{containsFormBlock as _n,reveal as Tr}from"@sentientui/core";import{captureRegionSkeleton as On}from"@sentientui/core/region";import{useCallback as Sr,useEffect as fn,useRef as st,useSyncExternalStore as Te}from"react";import{armOfResult as hr}from"@sentientui/core";var gn=new Set;function mn(e,t){var C,_,G;let n=D(),r=st(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=st(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let l=st(t==null?void 0:t.skeleton);l.current=t==null?void 0:t.skeleton;let d=Ee(),c=an(),s=ln(),a=un(),p=Te(K,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_config_overrides)==null?void 0:g[e]:void 0},()=>{}),u=Te(K,()=>{var g;return typeof window!="undefined"?(g=window.__sentient_slot_overrides)==null?void 0:g[e]:void 0},()=>{}),h=g=>g==null?"":hr(g),A=Sr(g=>{var x,S;return(S=(x=n==null?void 0:n.onSlotsChanged)==null?void 0:x.call(n,g))!=null?S:(()=>{})},[n]);Te(A,()=>{var g;return(g=n==null?void 0:n.getSlotConfig(e))!=null?g:null},()=>null),Te(A,()=>h(n==null?void 0:n.getSlotResult(e)),()=>"");let w=p===void 0?c[e]:void 0,o=p===void 0&&w===void 0&&n?n.getSlotConfig(e):null,m=(C=s!=null?s:n==null?void 0:n.getSitePalette())!=null?C:null,v=(G=a!=null?a:(_=n==null?void 0:n.getStyleVocabulary)==null?void 0:_.call(n))!=null?G:null,f=(()=>{var g,x,S;if(p!==void 0)return{config:p,arm:h(u),palette:m,vocabulary:(g=Wt())!=null?g:v,source:"override"};if(w!==void 0)return{config:w,arm:h((x=d[e])!=null?x:n==null?void 0:n.getSlotResult(e)),palette:m,vocabulary:v,source:"preloaded"};if(o!==null){let k=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:o,arm:h((S=n==null?void 0:n.getSlotResult(e))!=null?S:d[e]),palette:m,vocabulary:v,source:k?"client":"seeded"}}return{config:null,arm:"",palette:m,vocabulary:v,source:"none"}})(),b=f.source==="preloaded"||f.source==="override";return fn(()=>{var F,$,H,L,M;if(!n||n.isLocal===!0||b)return;let g=f.source==="none",x=g&&($=(F=r.current)==null?void 0:F.call(r))!=null?$:null,S=x!=null&&x!==""?{[e]:x}:void 0,k=(H=i.current)==null?void 0:H.call(i),R=g&&(M=(L=l.current)==null?void 0:L.call(l))!=null?M:null,P=y(y({},k?{render:{[e]:k}}:{}),R?{skeletons:{[e]:R}}:{}),E=Object.keys(P).length>0;return n.requestSlots?E?n.requestSlots([e],S,P):S?n.requestSlots([e],S):n.requestSlots([e]):g&&(R?n.reportSlots([e],S!=null?S:{},{[e]:R}):S?n.reportSlots([e],S):n.reportSlots([e])),()=>{var ee;return(ee=n.cancelSlots)==null?void 0:ee.call(n,[e])}},[n,b,f.source,e]),fn(()=>{!N()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||gn.has(e)||(gn.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}import{cloneElement as br,Fragment as pn}from"react";import{jsx as V,jsxs as hn}from"react/jsx-runtime";function at(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var re={none:"0",sm:"8px",md:"16px",lg:"24px"},lt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},bn={sm:"0.875em",md:"1em",lg:"1.25em"},xr={sm:"1.25em",md:"1.5em",lg:"2em"},yn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},vn={sm:"8px",md:"16px",lg:"32px"},wr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},kr={normal:"400",medium:"500",bold:"700"};function Sn(e,t){return y(y({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?y({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function xn(e,t,n){var i,l,d,c;let r=t==null?void 0:t.accent;return I(y({display:"inline-block",padding:(i=yn[n!=null?n:"md"])!=null?i:yn.md,borderRadius:(l=t==null?void 0:t.radius)!=null?l:"8px",font:"inherit"},n?{fontSize:bn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(d=t==null?void 0:t.primaryBg)!=null?d:"#111827":"transparent",color:e==="primary"?(c=t==null?void 0:t.primaryText)!=null?c:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Rr({node:e,opts:t}){var i,l,d,c,s;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(d=(l=t.palette)==null?void 0:l.border)!=null?d:"currentColor"}`,borderRadius:(s=(c=t.palette)==null?void 0:c.radius)!=null?s:"8px"};return hn("form",{onSubmit:a=>{var h,A,w;a.preventDefault();let p=new FormData(a.currentTarget),u={};for(let o of e.fields)u[o.name]=String((h=p.get(o.name))!=null?h:"");(A=t.onFormGoal)==null||A.call(t,e.submitGoal);try{(w=t.onFormSubmit)==null||w.call(t,u)}catch(o){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(a=>{var p,u;return hn("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[a.label,a.kind==="textarea"?V("textarea",{name:a.name,required:a.required,placeholder:a.placeholder,rows:3,style:r}):a.kind==="select"?V("select",{name:a.name,required:a.required,style:r,children:((p=a.options)!=null?p:[]).map(h=>V("option",{value:h,children:h},h))}):V("input",{name:a.name,type:(u=a.inputType)!=null?u:"text",required:a.required,placeholder:a.placeholder,style:r})]},a.name)}),V("button",{type:"submit",style:xn(n,t.palette),children:e.submitLabel})]})}function Cr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(l=>l.id===n))==null?void 0:i.classes:void 0}function wn(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 ve(e,t){var i;let n=Ar(e,t),r=wn(e.like,t);return n&&r?br(n,{style:I(y({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Ar(e,t){var n,r,i,l,d,c,s,a,p,u,h,A,w,o,m,v,f,b,C,_,G,g,x;try{let S=Cr(e,t);switch(e.type){case"stack":{let k=(r=re[(n=e.gap)!=null?n:"md"])!=null?r:re.md,R=e.surface==="raised"&&!S,P=(i=e.pad)!=null?i:R?"md":void 0;return V("div",I(y({},S?{className:S}:{}),{style:y(y(y(y(y({display:"flex",flexDirection:e.direction,gap:k},e.align?{alignItems:lt[e.align]}:{}),e.justify?{justifyContent:lt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),P?{padding:(l=re[P])!=null?l:re.md}:{}),R?I(y(y({},(d=t.palette)!=null&&d.surface?{background:t.palette.surface}:{}),(c=t.palette)!=null&&c.surface&&((s=t.palette)!=null&&s.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(a=t.palette)==null?void 0:a.border)!=null?p:"currentColor"}`,borderRadius:(h=(u=t.palette)==null?void 0:u.radius)!=null?h:"8px"}):{}),children:((A=e.children)!=null?A:[]).map((E,F)=>{let $=ve(E,t);return $===null?null:V(pn,{children:$},F)})}))}case"grid":{let k=(o=re[(w=e.gap)!=null?w:"md"])!=null?o:re.md;return V("div",I(y({},S?{className:S}:{}),{style:y(y({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${k}) / ${e.columns})), 1fr))`,gap:k},e.align?{alignItems:lt[e.align]}:{}),e.pad?{padding:(m=re[e.pad])!=null?m:re.md}:{}),children:((v=e.children)!=null?v:[]).map((R,P)=>{let E=ve(R,t);return E===null?null:V(pn,{children:E},P)})}))}case"text":return S?V("p",{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V("p",{style:y(y(y(y(y({margin:0},e.size?{fontSize:bn[e.size]}:{}),e.weight?{fontWeight:kr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Sn(e.tone,t.palette)),children:e.value});case"heading":{let k=`h${e.level}`;return S?V(k,{className:S,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V(k,{style:y(y({margin:0,fontSize:xr[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let k=(b=e.emphasis)!=null?b:"primary";return V("a",I(y(y({href:at(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:xn(k,t.palette,e.size)}),{children:e.label}))}case"link":return V("a",I(y(y({href:at(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),S?{className:S}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return V("img",I(y({src:at(e.src),alt:e.alt},S?{className:S}:{}),{style:y(y({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:wr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return S?V("span",{className:S,children:e.value}):V("span",{style:y({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(_=(C=t.palette)==null?void 0:C.border)!=null?_:"currentColor"}`},Sn(e.tone,t.palette)),children:e.value});case"spacer":return V("div",{style:{height:(G=vn[e.size])!=null?G:vn.md}});case"divider":return V("hr",{style:{border:"none",borderTop:`1px solid ${(x=(g=t.palette)==null?void 0:g.border)!=null?x:"currentColor"}`,margin:0,width:"100%"}});case"form":return V(Rr,{node:e,opts:t});default:return null}}catch(S){return null}}function ut(e,t){var l,d,c,s;let n=ve(e.tree,t);if(n===null)return null;let r=(l=e.surface)!=null&&l.like?(c=(d=t.vocabulary)==null?void 0:d.entries.find(a=>a.id===e.surface.like))==null?void 0:c.classes:void 0,i=wn((s=e.surface)==null?void 0:s.like,t);return r?V("div",I(y({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ne,isValidElement as Ie}from"react";import{normalizeLeafText as _r,skeletonFingerprint as Or}from"@sentientui/core/region";function Le(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function De(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ue(e){return Le(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ue(n),0):Ie(e)?ue(De(e)):0}function Er(e,t){return Array.isArray(t)?Ne(e,void 0,...t):Ne(e,void 0,t)}function ct(e,t){if(Le(e))return t;if(Array.isArray(e))return e.map(n=>ct(n,t));if(Ie(e)){let n=De(e);return ue(n)===0?e:Er(e,ct(n,t))}return e}function kn(e,t){return ue(e)===1?ct(e,t):null}var W=e=>e.join("/");function dt(e,t,n){if(Le(e)){n.leafPaths.push(t),n.texts.push(_r(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>dt(r,[...t,i],n));return}Ie(e)&&(n.elements.set(W(t),e),dt(De(e),[...t,"c"],n))}function gt(e){let t={leafPaths:[],texts:[],elements:new Map};return dt(e,[],t),t}function Pr(e){return gt(e).texts}function Rn(e){let t=Pr(e);return t.length===0?null:Or(t)}function Gr(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Cn(e,t){let n=t.reduce((i,l)=>Math.max(i,l+1),0),r=[];for(let i=0;i<n;i++){let l=t.flatMap((c,s)=>c===i?[Gr(e.leafPaths[s])]:[]);if(l.length===0){r.push(null);continue}let d=l[0];for(let c of l.slice(1)){let s=new Set(c.map(W));d=d.filter(a=>s.has(W(a)))}r.push(d.length>0?d[d.length-1]:null)}return r}function ft(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function mt(e,t){let n=gt(t);if(n.texts.length!==e.leaves.length||n.texts.some((l,d)=>l!==e.leaves[d]))return null;let r=Cn(n,e.leafToNode),i=e.nodes.map((l,d)=>{let c=r[d],s=c?n.elements.get(W(c)):void 0,a=!!s&&(typeof s.type=="string"||ft(s)!==void 0);return I(y({},l),{restylable:a})});return I(y({},e),{nodes:i})}function An(e,t,n){var w;let r=gt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((o,m)=>Math.max(o,m+1),0);for(let o of Object.keys(t.nodes))if(!/^\d+$/.test(o)||Number(o)>=i)return null;let l=Cn(r,n),d=new Map;n.forEach((o,m)=>{d.has(o)||d.set(o,m)});let c=new Map(r.leafPaths.map((o,m)=>[W(o),m])),s=new Set,a=new Map,p=!1;for(let[o,m]of Object.entries(t.nodes)){let v=Number(o),f=l[v];if(m.hidden&&(f?s.add(W(f)):p=!0),m.like!==void 0){let b=l[m.like],C=f?r.elements.get(W(f)):void 0,_=b?ft(r.elements.get(W(b))):void 0;!f||_===void 0||ft(C)===void 0?p=!0:a.set(W(f),_)}}let u=new Map(Object.entries((w=t.order)!=null?w:{})),h=(o,m)=>{var v;if(Le(o)){let f=c.get(W(m));if(f===void 0)return o;let b=n[f],C=(v=t.nodes[String(b)])==null?void 0:v.text;return C===void 0?o:d.get(b)===f?C:""}if(Array.isArray(o)){let f=o.map((b,C)=>h(b,[...m,C]));for(let[b,C]of u){let _=C.map(x=>{let S=l[x];return!S||S.length!==m.length+1||W(S.slice(0,-1))!==W(m)?-1:S[S.length-1]});if(_.some(x=>x<0))continue;let G=[..._].sort((x,S)=>x-S),g=[...f];G.forEach((x,S)=>{f[x]=g[_[S]]}),u.delete(b)}return f}if(Ie(o)){let f=W(m);if(s.has(f))return null;let b=De(o);if(ue(b)===0)return o;let C=h(b,[...m,"c"]),_=a.get(f),G=_!==void 0?{className:_}:void 0;return Array.isArray(C)?Ne(o,G,...C):Ne(o,G,C)}return o},A=h(e,[]);return p||u.size>0?null:A}import{jsx as Nr}from"react/jsx-runtime";var En=new Set,Pn=new Set,Gn=new Set,Tn="authored.";function Ve({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:l,as:d="div",reportBaselineText:c=!0}){var xt,wt;let s=D(),a=Z(),p=yt(null),u=pt(()=>Rn(t),[t]),h=n?Object.keys(n).join("|"):"",A=pt(()=>y({fp:u!=null?u:"0000000000000000",forms:!!r,compose:!0,content:ue(t)===1},h!==""?{authored:h.split("|"),children:!0}:{}),[u,t,r,h]),w=()=>{var X;let O=p.current;if(!O||!c)return null;let T=On(O);return T.skeleton?(X=mt(T.skeleton,t))!=null?X:I(y({},T.skeleton),{editable:!1,nodes:T.skeleton.nodes.map(ie=>I(y({},ie),{restylable:!1}))}):{status:T.reason}},{config:o,arm:m,palette:v,vocabulary:f,source:b}=mn(e,{baselineText:c?()=>{var O,T;return(T=(O=p.current)==null?void 0:O.textContent)!=null?T:null}:void 0,render:()=>A,skeleton:w}),C=m!==""?(xt=o==null?void 0:o.blocks)==null?void 0:xt[m]:void 0,_=m!==""?(wt=o==null?void 0:o.compose)==null?void 0:wt[m]:void 0,G=(C!==void 0&&_n(C)||_!==void 0&&_n(_.tree))&&!r;U(()=>{!G||!N()||En.has(e)||(En.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.`))},[G,e]);let g=O=>{!s||b==="override"||(b!=="seeded"&&s.componentGoal(e,O),s.goal(O,{metadata:{componentId:e,arm:m},weight:1,stepIndex:0}))},x=t,S=!1,k=m.startsWith(Tn)?m.slice(Tn.length):null;if((o==null?void 0:o.blocked)==="variant_history")S=!0;else if(k!==null)n&&Object.prototype.hasOwnProperty.call(n,k)?x=n[k]:S=!0;else if(_!==void 0){let O=G?null:ut(_,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});O===null?S=!0:x=O}else if(C!==void 0){let O=G?null:ve(C,{palette:v,vocabulary:f,onFormSubmit:r,onFormGoal:g});O===null?S=!0:x=O}else if((o==null?void 0:o.edits)!==void 0&&b!=="none"){let O=o.edits,T=O.fp===u?An(t,O.edits,O.leafToNode):null;T===null?S=!0:x=T}else if((o==null?void 0:o.content)!==void 0&&b!=="none"){let O=kn(t,o.content);O===null?S=!0:x=O}let R=S&&C===void 0&&_===void 0&&(o==null?void 0:o.edits)===void 0&&k===null&&(o==null?void 0:o.blocked)===void 0;U(()=>{(o==null?void 0:o.blocked)!=="variant_history"||!N()||Gn.has(e)||(Gn.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.`))},[o==null?void 0:o.blocked,e]);let P=k!==null&&!S?k:null;U(()=>{var Se;if(!P||!c||!s)return;let O=p.current;if(!O)return;let T=On(O),X=T.skeleton?mt(T.skeleton,n==null?void 0:n[P]):null,ie=(Se=O.textContent)==null?void 0:Se.trim();s.reportSlots([],void 0,void 0,{[e]:[y(y({key:P},ie?{text:ie}:{}),X?{skeleton:X}:{})]})},[P,s,e]);let E=S&&(o==null?void 0:o.edits)!==void 0&&(b==="preloaded"||b==="client");U(()=>{var O;!E||!(o!=null&&o.edits)||(O=s==null?void 0:s.reportDrift)==null||O.call(s,e,o.edits.fp,u,o.edits.fp===u?"unaddressable":"fp_mismatch")},[E,e,u,s]);let F=x===t;U(()=>{var T;if(!(o!=null&&o.needsSkeleton)||!F)return;let O=w();O&&((T=s==null?void 0:s.reportSkeleton)==null||T.call(s,e,O))},[o==null?void 0:o.needsSkeleton,F,e,s]),U(()=>{if(!F)return;let O=zt(e);if(!O)return;let T=w();qt(O,T&&"status"in T?{status:T.status}:{skeleton:T})},[e,F]),U(()=>{!R||!N()||Pn.has(e)||(Pn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[R,e]);let $=o!=null&&o.blocks?Object.keys(o.blocks).sort().join("|"):"";U(()=>de({id:e,arms:$===""?void 0:$.split("|")}),[e,$]);let H=yt(null);U(()=>{!s||b==="none"||b==="seeded"||b==="override"||m===""||S||H.current!==m&&(H.current=m,ne(s,a,e,m))},[s,a,e,m,b,S]);let L=b!=="none"&&b!=="seeded"&&!S,M=L?m:"",ee=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);U(()=>{if(!s||!i||b==="override")return;let O=p.current;if(!O)return;let T=te(i),X=z(i),ie=!1;return q(O,J(i),{fireGoal:()=>{ie||(ie=!0,L&&(X!==void 0?s.componentGoal(e,T,{value:X}):s.componentGoal(e,T)),s.goal(T,y({metadata:{componentId:e,arm:M},weight:1,stepIndex:0},X!==void 0?{value:X}:{})))},fireStep:(Se,kt,Un)=>{L&&s.componentGoal(e,Se,{reward:kt}),s.goal(Se,{metadata:{componentId:e,arm:M},weight:kt,stepIndex:Un})}},T)},[s,e,ee,m,b,S,L,M]);let ke=yt(null);U(()=>{let O=p.current;if(O){if(ke.current===null){ke.current=m;return}ke.current!==m&&(ke.current=m,Tr(O))}},[m]);let Jn=pt(()=>y({"data-sentient-slot":e},m!==""?{"data-sentient-arm":m}:{}),[e,m]);return Nr(d,I(y({ref:p,className:l},Jn),{children:x}))}import{jsx as Fe}from"react/jsx-runtime";function Vr(e){var p,u;let{client:t,variantId:n,content:r,ref:i}=Ge(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0}),[l,d]=Dr(!1);Lr(()=>{d(!0)},[]);let c=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!l||!t)||!n)return null;let s=(u=e.variants[n])!=null?u:null,a=s===null?r:null;return N()&&s===null&&a===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Fe(c,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:s!=null?s:a})}var Fr=Ir(Vr,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function Mr(e){if(e.variants===void 0)return Fe(Ve,y({},e));let t=e;if(t.children!=null){N()&&Br(t);let n=t,{funnel:r,microSignalGoals:i,agentData:l,agentDataByVariant:d,clientOnly:c,variants:s}=n,a=Ce(n,["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly","variants"]);return Fe(Ve,I(y({},a),{children:t.children,variants:s}))}return Fe(Fr,y({},t))}var Nn=new Set;function Br(e){let t=["funnel","microSignalGoals","agentData","agentDataByVariant","clientOnly"].filter(n=>e[n]!==void 0);t.length===0||Nn.has(e.id)||(Nn.add(e.id),console.warn(`[sentient] <Adaptive id="${e.id}"> has both variants and children, so it runs as one experiment with your original and generated versions. These props only apply to a variants-only component and are ignored here: ${t.join(", ")}.`))}import{useEffect as Me,useMemo as $r,useRef as vt,useState as In,useSyncExternalStore as jr}from"react";import{jsx as Kr}from"react/jsx-runtime";function Wr({id:e,default:t,component:n="span",className:r,goal:i}){var G;let l=D(),d=Z(),c=Oe(),s=xe(),a=vt(null),p=vt(null),u=jr(K,()=>ye(e),()=>null),[h,A]=In(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.content)!=null?x:null}),[w,o]=In(()=>{var g,x;return(x=(g=l==null?void 0:l.getAssignment(e,s))==null?void 0:g.variantId)!=null?x:null});Me(()=>{if(u||!l)return;let g=l.getAssignment(e,s);if((g==null?void 0:g.content)!==void 0){o(g.variantId),A(g.content);return}let x=!1;return l.assign(e).then(S=>{if(!x){if(!S){N()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}o(S.variantId),S.content&&A(S.content)}}),()=>{x=!0}},[l,e,s,u]),Me(()=>{u||!l||!w||!d||a.current!==w&&(a.current=w,l.track({projectId:d,componentId:e,variantId:w,eventType:"variant_assigned",payload:{}}),c==null||c(e,w))},[l,w,d,e,c,u]);let m=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=$r(()=>i===void 0?null:J(i),[m]),f=i===void 0?null:typeof i=="string"?i:v.type,b=vt(!1);Me(()=>{b.current=!1},[w,m]),Me(()=>{if(u||!l||!w||!d||!v||!f)return;let g=p.current;if(!g)return;let x=z(v);return q(g,v,{fireGoal:()=>{b.current||(b.current=!0,l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:f,payload:y({reward:1},x!==void 0?{goalValue:x}:{})}),l.goal(f,y({metadata:{componentId:e,variantId:w},weight:1,stepIndex:0},x!==void 0?{value:x}:{})))},fireStep:(S,k,R)=>{l.track({projectId:d,componentId:e,variantId:w,eventType:"goal_achieved",goalType:S,payload:{reward:k}}),l.goal(S,{metadata:{},weight:k,stepIndex:R})}})},[l,w,d,e,v,f,u]);let C=h!=null?h:t;if(u){let g=l==null?void 0:l.getAssignment(e,s);C=g&&g.variantId===u&&(G=g.content)!=null?G:t}return Kr(n,{ref:g=>{p.current=g},className:r,children:C})}import{useCallback as Jr,useRef as Ur}from"react";function St(e){let t=D(),n=Ur(new Set);return Jr((r,i)=>{var l,d;if(!ye(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,y(y(y({metadata:(l=i==null?void 0:i.metadata)!=null?l:{},weight:(d=i==null?void 0:i.reward)!=null?d:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as Hr,useRef as Ln}from"react";function Xr(e,t={}){let s=t,{componentId:n}=s,r=Ce(s,["componentId"]),i=D(),l=St(n!=null?n:""),d=Ln(!1),c=Ln(r);c.current=r,Hr(()=>{if(!i||d.current||i.gated)return;d.current=!0;let{metadata:a,reward:p,value:u,currency:h,externalId:A}=c.current;if(n){l(e,c.current);return}i.goal(e,y(y(y({metadata:a!=null?a:{},weight:p!=null?p:1,stepIndex:0},u!==void 0?{value:u}:{}),h!==void 0?{currency:h}:{}),A!==void 0?{externalId:A}:{}))},[i,n,e,l])}import{renderPrePaintScript as zr}from"@sentientui/core";import{confidenceBand as qr}from"@sentientui/policy";import{jsx as Qr}from"react/jsx-runtime";function Dn(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Yr(e){return e.persona?'(function(){try{var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Dn(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Dn(qr(e.persona.confidence))+");}catch(e){}})();":zr(e.apiKey)}function Zr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:Qr("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Yr(e)}})}import{useEffect as je,useMemo as bt,useRef as si}from"react";import{validateSlotDecl as ai}from"@sentientui/policy";import{useEffect as ht,useReducer as ei,useState as ti,useSyncExternalStore as Vn}from"react";import{armOfResult as Be,baselineResultFor as ni}from"@sentientui/core";import{confidenceBand as ri}from"@sentientui/policy";function $e(e,t){let n=D(),r=Ee(),[,i]=ei(u=>u+1,0),l=Vn(K,()=>{var u;return typeof window!="undefined"?(u=window.__sentient_slot_overrides)==null?void 0:u[e]:void 0},()=>{}),d=l===void 0?r[e]:void 0,c=l===void 0&&d===void 0&&n?n.getSlotResult(e):null,s=(n==null?void 0:n.isLocal)===!0&&l===void 0&&d===void 0&&c===null;ht(()=>{if(!s||!n)return;let u=!1;return n.decide({slots:[t]}).then(h=>{!u&&h&&i()}),()=>{u=!0}},[n,e,s]);let a=(()=>{if(l!==void 0)return{result:l,arm:Be(l),source:"override"};if(d!==void 0)return{result:d,arm:Be(d),source:"preloaded"};if(c!==null){let h=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:c,arm:Be(c),source:h?"client":"seeded"}}let u=ni(t);return{result:u,arm:Be(u),source:"baseline"}})(),p=a.source==="preloaded"||a.source==="override";return ht(()=>{var h;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let u=(h=n.onSlotsChanged)==null?void 0:h.call(n,i);return n.decideSlots([t]),()=>{var A;(A=n.cancelSlots)==null||A.call(n,[e]),u==null||u()}},[n,e,p]),a}function ii(){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 oi(){let e=D(),t=sn();Vn(K,Nt,()=>0);let[n,r]=ti(!1);ht(()=>r(!0),[]);let i=c=>({persona:c.persona,confidence:c.confidence,band:ri(c.confidence)});if(!n)return t?i(t):null;let l=ii();if(l)return i(l);if(t)return i(t);let d=e?e.getPersona():null;return d?i(d):null}var Fn=new Set;function li(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function ui(e,t,n){let r=D(),i=Z(),l=JSON.stringify(t),d=bt(()=>({id:e,dims:t}),[e,l]),{result:c,arm:s,source:a}=$e(e,d),p=bt(()=>typeof c=="string"?{}:c,[s]);if(N()&&!Fn.has(e)){Fn.add(e);let o=ai({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,f])=>[v,[...f]]))}),m=Object.values(t).reduce((v,f)=>v*f.length,1);o.ok?m>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${m} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${o.reason}. Serving baseline.`)}let u=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);je(()=>de({id:e,dims:t}),[e]);let h=si(null);je(()=>{!r||a==="baseline"||a==="seeded"||a==="override"||h.current===s||(h.current=s,ne(r,i,e,s))},[r,i,e,s,a]);let A=n==null?void 0:n.funnel;je(()=>{var o;!r||!A||a==="override"||ce(r,i,e,A,J((o=n==null?void 0:n.goal)!=null?o:"click"))},[r,i,e,A,u,a]),je(()=>{if(!r||!(n!=null&&n.goal)||a==="override"||a==="baseline"||a==="seeded")return;let o=document.querySelector(`[data-sentient-slot="${li(e)}"]`);if(!o){N()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let m=te(n.goal),v=z(n.goal),f=!1;return q(o,J(n.goal),{fireGoal:()=>{f||(f=!0,v!==void 0?r.componentGoal(e,m,{value:v}):r.componentGoal(e,m),r.goal(m,y({metadata:{componentId:e,arm:s},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(b,C,_)=>{r.componentGoal(e,b,{reward:C}),r.goal(b,{metadata:{componentId:e,arm:s},weight:C,stepIndex:_})}},m)},[r,e,u,s,a]);let w=bt(()=>{let o={"data-sentient-slot":e};for(let[m,v]of Object.entries(p))o[`data-${m}`]=v;return o},[e,p]);return{tokens:p,props:w}}import{useCallback as ci,useEffect as di,useMemo as fi}from"react";var Mn=new Set;function gi(e,t){var A;if(N()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:l,goalLabel:d,ref:c,nodeRef:s}=Ge(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),a=(A=i!=null?i:r[0])!=null?A:"",p=t.variants[a];di(()=>{if(!N()||!n)return;let w=setTimeout(()=>{!s.current&&!Mn.has(e)&&(Mn.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(w)},[n,e]);let u=ci((w,o)=>{var v,f;if(l)return;let m=w!=null?w:d;m&&(n==null||n.componentGoal(e,m,o),n==null||n.goal(m,y(y(y({metadata:(v=o==null?void 0:o.metadata)!=null?v:{},weight:(f=o==null?void 0:o.reward)!=null?f:1,stepIndex:0},(o==null?void 0:o.value)!==void 0?{value:o.value}:{}),(o==null?void 0:o.currency)!==void 0?{currency:o.currency}:{}),(o==null?void 0:o.externalId)!==void 0?{externalId:o.externalId}:{})))},[n,e,d,l]),h=fi(()=>({ref:c,"data-sentient-id":e,"data-sentient-variant":a}),[c,e,a]);return{variant:a,value:p,bind:h,fireGoal:u}}import{Children as mi,isValidElement as pi,useEffect as We,useMemo as Bn,useRef as $n}from"react";import{jsx as vi}from"react/jsx-runtime";var Ke=new Set;function yi(e){var v;let t=D(),n=Z(),r=$n(null),i=Object.keys(e.arrangements).join(" "),l=Bn(()=>Object.keys(e.arrangements),[i]),d=Bn(()=>y({id:e.id,arms:l},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,l,e.baseline]),{arm:c,source:s}=$e(e.id,d);N()&&e.baseline!==void 0&&e.baseline!==l[0]&&!Ke.has(e.id+":baseline")&&(Ke.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${l[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let a=mi.toArray(e.children).filter(pi),p=new Map;for(let f of a)p.set(String((v=f.key)!=null?v:"").replace(/^\.\$/,""),f);let u=e.arrangements[c],h=u!==void 0&&u.length===a.length&&u.every(f=>p.has(f));N()&&u!==void 0&&!h&&!Ke.has(e.id+":keys")&&(Ke.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${c}" [${u.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let A=h?u.map(f=>p.get(f)):a;We(()=>de({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let w=$n(null);We(()=>{!t||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,ne(t,n,e.id,c))},[t,n,e.id,c,s]);let o=e.funnel;We(()=>{var f;!t||!o||s==="override"||ce(t,n,e.id,o,J((f=e.goal)!=null?f:"click"))},[t,n,e.id,o,s]);let m=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return We(()=>{if(!t||e.goal===void 0||s==="override"||s==="baseline"||s==="seeded")return;let f=r.current;if(!f)return;let b=te(e.goal),C=z(e.goal),_=!1;return q(f,J(e.goal),{fireGoal:()=>{_||(_=!0,C!==void 0?t.componentGoal(e.id,b,{value:C}):t.componentGoal(e.id,b),t.goal(b,y({metadata:{componentId:e.id,arm:c},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(G,g,x)=>{t.componentGoal(e.id,G,{reward:g}),t.goal(G,{metadata:{componentId:e.id,arm:c},weight:g,stepIndex:x})}},b)},[t,e.id,m,c,s]),vi("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":c,children:A})}import{deriveSessionSegment as Si}from"@sentientui/core";var hi=["page","blocks","layoutOrder"],jn=new Map;function bi(e,t){jn.set(e,t)}function Wn(e){return jn.get(e)}function xi(e){var i,l;let t=(l=(i=e.content)!=null?i:Wn(e.page))!=null?l:{},n={};for(let[d,c]of Object.entries(t))hi.includes(d)||(n[d]=c);let r=I(y({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function wi(e){return`<script type="application/ld+json">${Kn(e)}</script>`}function Kn(e){return JSON.stringify(y({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function ki(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
3
3
  `).trimEnd()+`
4
4
  `}import{grantConsent as ka}from"@sentientui/core";import{consentWatcher as Aa}from"@sentientui/core/consent";export{Mr as Adaptive,yi as AdaptiveGroup,ur as AdaptiveProvider,Ve as AdaptiveSlot,Wr as AdaptiveText,Zr as SentientPersonaScript,xi as buildAgentFeed,Aa as consentWatcher,bi as defineAgentContent,Si as detectSegment,Wn as getAgentContent,ka as grantConsent,wi as renderAgentJsonLd,Kn as renderAgentJsonLdBody,ki as renderAgentMarkdown,ve as renderBlocks,ut as renderCompose,gi as useAdaptive,dr as useAdaptiveApiBaseUrl,St as useAdaptiveGoal,oi as useAdaptivePersona,ui as useAdaptiveTokens,ot as useAssignment,rt as useInitialAssignments,cr as useLayoutOrder,Xr as usePageGoal,D as useSentient,xe as useSessionSegment};
5
5
  //# sourceMappingURL=index.mjs.map
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- "use strict";var Ae=Object.create;var G=Object.defineProperty,Oe=Object.defineProperties,Ie=Object.getOwnPropertyDescriptor,Te=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,De=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var re=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&re(e,n,t[n]);if(ie)for(var n of ie(t))Le.call(t,n)&&re(e,n,t[n]);return e},M=(e,t)=>Oe(e,Te(t));var Ge=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ve(t))!oe.call(e,a)&&a!==n&&G(e,a,{get:()=>t[a],enumerable:!(i=Ie(t,a))||i.enumerable});return e};var $=(e,t,n)=>(n=e!=null?Ae(De(e)):{},se(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),Fe=e=>se(G({},"__esModule",{value:!0}),e);var et={};Ge(et,{renderWithSentient:()=>Ze});module.exports=Fe(et);var Ee=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Ne=new Map,We=new Map;function ae(e,t){Ne.set(e,t);let n=We.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Me={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Me;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function U(){return le().on}function ce(e){let t=le().listeners;return t.add(e),()=>{t.delete(e)}}function de(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,a)=>e.assign(t,n,i,a),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 $e="sentient:overrides-changed";function F(){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($e))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function N(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ke={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function j(){if(typeof window=="undefined")return Ke;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 Be(){j().version+=1;for(let e of j().listeners)e()}function H(e){N()&&(j().sections=[...e],Be())}var fe="0.37.2",z=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function Ue(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Ue()[e]=t}function ge(e){window.__sentient_vocabulary_override=e}function je(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){je()[e]=t}function pe(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let a=n.slice(i.index+i[0].length);i[1]!="&"&&a[0]=="&"&&(a=i[1]+a.slice(1));let u=n.slice(0,i.index)+a;history.replaceState(history.state,"",u?"#"+u:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",D=null,J=!1;function me(){return J}function He(){try{return sessionStorage.getItem(q)}catch(e){return null}}function K(e){if(D)return D;let t=typeof window=="undefined"?null:pe("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:He();return J=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return J=!0,D=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(q,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function ye(){try{sessionStorage.removeItem(q)}catch(e){}}var ve="sentient_preview_cell",_e="sentient_refresh_region",X="sentient-cell-preview-bar",A="__preview__",ze=null;function Se(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(X))return;let t,n;try{let l=new URLSearchParams(window.location.search);t=l.get(ve),n=l.get(_e)}catch(l){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),a=K(i);if(!me())return;if(n){ze={slotId:n,session:a,base:i},T(n,{kind:"arms"}),V(n,A),F();return}if(!t)return;let u=t.lastIndexOf("~");if(u<=0)return;let g=t.slice(0,u),O=t.slice(u+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(W(l.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 l=>{if(!l)return;if(!l.ok){W(l.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await l.json();if(c.vocabulary&&Array.isArray(c.vocabulary.entries)&&ge(c.vocabulary),c.compose!=null)T(g,{kind:"arms",compose:{[A]:c.compose}}),V(g,A);else if(c.edits!=null&&typeof c.skeletonFp=="string"&&Array.isArray(c.leafToNode))T(g,{kind:"arms",edits:{edits:c.edits,fp:c.skeletonFp,leafToNode:c.leafToNode}}),V(g,A);else if(c.blocks!=null)T(g,{kind:"arms",blocks:{[A]:c.blocks}}),V(g,A);else if(c.content!=null)T(g,{kind:"arms",content:c.content}),V(g,A);else{W("Nothing to preview in that square yet.");return}F(),W(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${g}"]`))==null||p.scrollIntoView({block:"center"})}catch(y){}},300)}).catch(()=>W("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function W(e){var a;if(document.getElementById(X))return;let t=document.createElement("div");t.id=X,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{ye();let u=new URL(window.location.href);u.searchParams.delete(ve),u.searchParams.delete(_e),window.location.assign(u.toString())},t.append(n,i),((a=document.body)!=null?a:document.documentElement).append(t)}var he=!1;function we(e){if(he||typeof window=="undefined")return;he=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Je(t,n.token)})}function Je(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Re=require("react/jsx-runtime");function qe(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,B.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Ce="https://api.sentient-ui.com/v1",Xe=(0,o.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Ce,debug:!1}),be=!1,Y=new Set;function Ye(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,u]=(0,o.useState)(null),[g,O]=(0,o.useState)(!1),l=(0,o.useRef)(e);l.current=e;let c=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(v({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,o.useEffect)(()=>{let p=l.current;if(p===void 0||typeof window=="undefined")return;let y,k=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:I})=>{if(k)return;let E=x(typeof p=="object"&&p.cmp===void 0&&p.check?v(M(v({},p),{check:()=>l.current.check()}),p.refused?{refused:()=>{var h,w;return((w=(h=l.current).refused)==null?void 0:w.call(h))===!0}}:{}):p),S=!1,L=()=>{let h=E.refused()&&E.read()!==!0;h&&!S&&(I(t),i.current()),S=h,O(h);let w=E.read();w!==null&&Y.add(t),u(w!=null?w:Y.has(t)?!1:null)};L(),y=E.subscribe(L)}),()=>{k=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function xe(e){var Q,Z,ee;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:qe()}),[a,u]=(0,o.useState)(U());(0,o.useEffect)(()=>ce(()=>u(U())),[]),(0,o.useEffect)(()=>{Se(e.apiBaseUrl),we(e.apiBaseUrl)},[]);let g=(0,o.useRef)(()=>{}),O=Ye(e.consentFrom,e.apiKey,()=>g.current()),l=e.consentFrom?(Q=O.granted)!=null?Q:Y.has(e.apiKey)?!1:e.consent===!0:e.consent,c=e.consentFrom?O.refused:!0,p=(0,o.useRef)(c);p.current=c;let y=(0,o.useRef)(null),k=(0,o.useRef)(!1),x=(0,o.useRef)([]),I=(0,o.useRef)(!1);g.current=()=>{var f;x.current=[],I.current=!0;let r=y.current;r!=null&&r.gated?r.dispose():(f=r==null?void 0:r.takeHeld)==null||f.call(r)},(0,o.useEffect)(()=>{var te,ne;if(p.current&&l===!1&&(x.current=[]),l===!1&&k.current&&(p.current&&((te=y.current)==null||te.destroy()),y.current=null,k.current=!1),l===!1&&!e.preConsentBehavior){p.current&&((ne=y.current)==null||ne.destroy()),y.current=null,n(null);return}let r=l!==!1;r&&(I.current=!1);let f=_=>{!r&&I.current&&_.gated&&_.dispose()},m=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!1,s=null,b=null,C=_=>{for(let P of x.current.splice(0))setTimeout(()=>{if(y.current!==_){I.current||x.current.push(P);return}try{P(_)}catch(tt){}},0)},R=_=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{d||(b=P(_,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:_})=>{d||(s=_(M(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),f(s),y.current=s,k.current=r,C(s),n(s),R(s))}):(s=(0,B.init)(m),f(s),y.current=s,k.current=r,C(s),n(s),R(s)),()=>{var _,P;d=!0,b==null||b(),x.current=x.current.concat((P=(_=s==null?void 0:s.takeHeld)==null?void 0:_.call(s))!=null?P:[]),s==null||s.dispose()}},[l]),(0,o.useEffect)(()=>{if(!t)return;let r=!1,f=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(s){return}if(!r)for(let s of d){let b={componentId:s.componentId,updatedAt:s.updatedAt,variants:s.variants.map(C=>{var R;return{variantId:C.variantId,pulls:C.pulls,avgReward:(R=C.avgReward)!=null?R:0}})};ae(s.componentId,b)}};f();let m=setInterval(()=>{f()},6e4);return()=>{r=!0,clearInterval(m)}},[t]);let E=(Z=e.ssrFallback)!=null?Z:"first",S=((ee=e.apiBaseUrl)!=null?ee:Ce).replace(/\/$/,""),L=(0,o.useRef)(null);(0,o.useEffect)(()=>{var m;if(typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:S},f=L.current;if(L.current=r,f!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[d],r[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,S]),(0,o.useEffect)(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||ue({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]),(0,o.useEffect)(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){H(r);return}e.declaredSections&&e.declaredSections.length>0&&H(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!N()||e.consent!==void 0||e.consentFrom!==void 0||be||(be=!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,o.useEffect)(()=>{if(!N())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),m=r.filter(d=>!f.has(d));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(d=>`"${d}"`).join(", ")} ${m.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let h=(0,o.useMemo)(()=>t&&a?de(t):t,[t,a]),w=(0,o.useMemo)(()=>{var r,f,m,d,s,b,C,R;return{client:h,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(f=e.initialLayoutOrder)!=null?f:null,initialSlots:(m=e.initialSlots)!=null?m:{},initialSlotConfig:(d=e.initialSlotConfig)!=null?d:{},initialPalette:(s=e.initialPalette)!=null?s:null,initialVocabulary:(b=e.initialVocabulary)!=null?b:null,initialPersona:(C=e.initialPersona)!=null?C:null,apiBaseUrl:S,debug:(R=e.debug)!=null?R:!1}},[h,e.apiKey,e.initialAssignments,i,E,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return(0,Re.jsx)(Xe.Provider,{value:w,children:e.children})}function Qe(e){return e<.3?"low":e<.7?"medium":"high"}function ke(e={}){var n,i,a;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",Qe((a=e.confidence)!=null?a:1))}catch(u){}}else delete t.__sentient_persona_override;F()}var Pe=require("react/jsx-runtime");function Ze(e,t={},n){return ke(t),(0,Ee.render)((0,Pe.jsx)(xe,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
2
+ "use strict";var Ae=Object.create;var G=Object.defineProperty,Oe=Object.defineProperties,Ie=Object.getOwnPropertyDescriptor,Te=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,De=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var re=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&re(e,n,t[n]);if(ie)for(var n of ie(t))Le.call(t,n)&&re(e,n,t[n]);return e},M=(e,t)=>Oe(e,Te(t));var Ge=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ve(t))!oe.call(e,a)&&a!==n&&G(e,a,{get:()=>t[a],enumerable:!(i=Ie(t,a))||i.enumerable});return e};var $=(e,t,n)=>(n=e!=null?Ae(De(e)):{},se(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),Fe=e=>se(G({},"__esModule",{value:!0}),e);var et={};Ge(et,{renderWithSentient:()=>Ze});module.exports=Fe(et);var Ee=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Ne=new Map,We=new Map;function ae(e,t){Ne.set(e,t);let n=We.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Me={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Me;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function U(){return le().on}function ce(e){let t=le().listeners;return t.add(e),()=>{t.delete(e)}}function de(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,i,a)=>e.assign(t,n,i,a),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 $e="sentient:overrides-changed";function F(){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($e))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function N(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ke={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function j(){if(typeof window=="undefined")return Ke;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 Be(){j().version+=1;for(let e of j().listeners)e()}function H(e){N()&&(j().sections=[...e],Be())}var fe="0.37.4",z=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function Ue(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Ue()[e]=t}function ge(e){window.__sentient_vocabulary_override=e}function je(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){je()[e]=t}function pe(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let a=n.slice(i.index+i[0].length);i[1]!="&"&&a[0]=="&"&&(a=i[1]+a.slice(1));let u=n.slice(0,i.index)+a;history.replaceState(history.state,"",u?"#"+u:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",D=null,J=!1;function me(){return J}function He(){try{return sessionStorage.getItem(q)}catch(e){return null}}function K(e){if(D)return D;let t=typeof window=="undefined"?null:pe("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:He();return J=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return J=!0,D=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(q,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function ye(){try{sessionStorage.removeItem(q)}catch(e){}}var ve="sentient_preview_cell",_e="sentient_refresh_region",X="sentient-cell-preview-bar",A="__preview__",ze=null;function Se(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(X))return;let t,n;try{let l=new URLSearchParams(window.location.search);t=l.get(ve),n=l.get(_e)}catch(l){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),a=K(i);if(!me())return;if(n){ze={slotId:n,session:a,base:i},T(n,{kind:"arms"}),V(n,A),F();return}if(!t)return;let u=t.lastIndexOf("~");if(u<=0)return;let g=t.slice(0,u),O=t.slice(u+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(W(l.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 l=>{if(!l)return;if(!l.ok){W(l.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await l.json();if(c.vocabulary&&Array.isArray(c.vocabulary.entries)&&ge(c.vocabulary),c.compose!=null)T(g,{kind:"arms",compose:{[A]:c.compose}}),V(g,A);else if(c.edits!=null&&typeof c.skeletonFp=="string"&&Array.isArray(c.leafToNode))T(g,{kind:"arms",edits:{edits:c.edits,fp:c.skeletonFp,leafToNode:c.leafToNode}}),V(g,A);else if(c.blocks!=null)T(g,{kind:"arms",blocks:{[A]:c.blocks}}),V(g,A);else if(c.content!=null)T(g,{kind:"arms",content:c.content}),V(g,A);else{W("Nothing to preview in that square yet.");return}F(),W(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${g}"]`))==null||p.scrollIntoView({block:"center"})}catch(y){}},300)}).catch(()=>W("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function W(e){var a;if(document.getElementById(X))return;let t=document.createElement("div");t.id=X,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{ye();let u=new URL(window.location.href);u.searchParams.delete(ve),u.searchParams.delete(_e),window.location.assign(u.toString())},t.append(n,i),((a=document.body)!=null?a:document.documentElement).append(t)}var he=!1;function we(e){if(he||typeof window=="undefined")return;he=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Je(t,n.token)})}function Je(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Re=require("react/jsx-runtime");function qe(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,B.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Ce="https://api.sentient-ui.com/v1",Xe=(0,o.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Ce,debug:!1}),be=!1,Y=new Set;function Ye(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,u]=(0,o.useState)(null),[g,O]=(0,o.useState)(!1),l=(0,o.useRef)(e);l.current=e;let c=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(v({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,o.useEffect)(()=>{let p=l.current;if(p===void 0||typeof window=="undefined")return;let y,k=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:I})=>{if(k)return;let E=x(typeof p=="object"&&p.cmp===void 0&&p.check?v(M(v({},p),{check:()=>l.current.check()}),p.refused?{refused:()=>{var h,w;return((w=(h=l.current).refused)==null?void 0:w.call(h))===!0}}:{}):p),S=!1,L=()=>{let h=E.refused()&&E.read()!==!0;h&&!S&&(I(t),i.current()),S=h,O(h);let w=E.read();w!==null&&Y.add(t),u(w!=null?w:Y.has(t)?!1:null)};L(),y=E.subscribe(L)}),()=>{k=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function xe(e){var Q,Z,ee;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:qe()}),[a,u]=(0,o.useState)(U());(0,o.useEffect)(()=>ce(()=>u(U())),[]),(0,o.useEffect)(()=>{Se(e.apiBaseUrl),we(e.apiBaseUrl)},[]);let g=(0,o.useRef)(()=>{}),O=Ye(e.consentFrom,e.apiKey,()=>g.current()),l=e.consentFrom?(Q=O.granted)!=null?Q:Y.has(e.apiKey)?!1:e.consent===!0:e.consent,c=e.consentFrom?O.refused:!0,p=(0,o.useRef)(c);p.current=c;let y=(0,o.useRef)(null),k=(0,o.useRef)(!1),x=(0,o.useRef)([]),I=(0,o.useRef)(!1);g.current=()=>{var f;x.current=[],I.current=!0;let r=y.current;r!=null&&r.gated?r.dispose():(f=r==null?void 0:r.takeHeld)==null||f.call(r)},(0,o.useEffect)(()=>{var te,ne;if(p.current&&l===!1&&(x.current=[]),l===!1&&k.current&&(p.current&&((te=y.current)==null||te.destroy()),y.current=null,k.current=!1),l===!1&&!e.preConsentBehavior){p.current&&((ne=y.current)==null||ne.destroy()),y.current=null,n(null);return}let r=l!==!1;r&&(I.current=!1);let f=_=>{!r&&I.current&&_.gated&&_.dispose()},m=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!1,s=null,b=null,C=_=>{for(let P of x.current.splice(0))setTimeout(()=>{if(y.current!==_){I.current||x.current.push(P);return}try{P(_)}catch(tt){}},0)},R=_=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{d||(b=P(_,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:_})=>{d||(s=_(M(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),f(s),y.current=s,k.current=r,C(s),n(s),R(s))}):(s=(0,B.init)(m),f(s),y.current=s,k.current=r,C(s),n(s),R(s)),()=>{var _,P;d=!0,b==null||b(),x.current=x.current.concat((P=(_=s==null?void 0:s.takeHeld)==null?void 0:_.call(s))!=null?P:[]),s==null||s.dispose()}},[l]),(0,o.useEffect)(()=>{if(!t)return;let r=!1,f=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(s){return}if(!r)for(let s of d){let b={componentId:s.componentId,updatedAt:s.updatedAt,variants:s.variants.map(C=>{var R;return{variantId:C.variantId,pulls:C.pulls,avgReward:(R=C.avgReward)!=null?R:0}})};ae(s.componentId,b)}};f();let m=setInterval(()=>{f()},6e4);return()=>{r=!0,clearInterval(m)}},[t]);let E=(Z=e.ssrFallback)!=null?Z:"first",S=((ee=e.apiBaseUrl)!=null?ee:Ce).replace(/\/$/,""),L=(0,o.useRef)(null);(0,o.useEffect)(()=>{var m;if(typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:S},f=L.current;if(L.current=r,f!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[d],r[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,S]),(0,o.useEffect)(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||ue({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]),(0,o.useEffect)(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){H(r);return}e.declaredSections&&e.declaredSections.length>0&&H(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!N()||e.consent!==void 0||e.consentFrom!==void 0||be||(be=!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,o.useEffect)(()=>{if(!N())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),m=r.filter(d=>!f.has(d));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(d=>`"${d}"`).join(", ")} ${m.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let h=(0,o.useMemo)(()=>t&&a?de(t):t,[t,a]),w=(0,o.useMemo)(()=>{var r,f,m,d,s,b,C,R;return{client:h,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(f=e.initialLayoutOrder)!=null?f:null,initialSlots:(m=e.initialSlots)!=null?m:{},initialSlotConfig:(d=e.initialSlotConfig)!=null?d:{},initialPalette:(s=e.initialPalette)!=null?s:null,initialVocabulary:(b=e.initialVocabulary)!=null?b:null,initialPersona:(C=e.initialPersona)!=null?C:null,apiBaseUrl:S,debug:(R=e.debug)!=null?R:!1}},[h,e.apiKey,e.initialAssignments,i,E,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return(0,Re.jsx)(Xe.Provider,{value:w,children:e.children})}function Qe(e){return e<.3?"low":e<.7?"medium":"high"}function ke(e={}){var n,i,a;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",Qe((a=e.confidence)!=null?a:1))}catch(u){}}else delete t.__sentient_persona_override;F()}var Pe=require("react/jsx-runtime");function Ze(e,t={},n){return ke(t),(0,Ee.render)((0,Pe.jsx)(xe,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
3
3
  //# sourceMappingURL=react.js.map
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- var xe=Object.defineProperty,Re=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var ie=(e,t,n)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ee.call(t,n)&&ie(e,n,t[n]);if(ne)for(var n of ne(t))Pe.call(t,n)&&ie(e,n,t[n]);return e},$=(e,t)=>Re(e,ke(t));import{render as Je}from"@testing-library/react";import{createContext as Me,useContext as Ct,useEffect as _,useMemo as Se,useRef as x,useState as M,useSyncExternalStore as xt}from"react";import{deriveSessionSegment as $e,init as Ke}from"@sentientui/core";var Ae=new Map,Oe=new Map;function re(e,t){Ae.set(e,t);let n=Oe.get(e);if(n)for(let r of n)try{r(t)}catch(l){}}var Ie={on:!1,listeners:new Set};function oe(){if(typeof window=="undefined")return Ie;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function B(){return oe().on}function se(e){let t=oe().listeners;return t.add(e),()=>{t.delete(e)}}function ae(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,l)=>e.assign(t,n,r,l),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Te="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Te))}function le(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function N(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ve={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function U(){if(typeof window=="undefined")return Ve;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 De(){U().version+=1;for(let e of U().listeners)e()}function j(e){N()&&(U().sections=[...e],De())}var ce="0.37.2",H=ce!=="0.0.0-dev"?{name:"react",version:ce}:void 0;function Le(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function V(e,t){Le()[e]=t}function de(e){window.__sentient_vocabulary_override=e}function Ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ge()[e]=t}function ue(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let l=n.slice(r.index+r[0].length);r[1]!="&"&&l[0]=="&"&&(l=r[1]+l.slice(1));let d=n.slice(0,r.index)+l;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var J="__snt_editor_token",L=null,z=!1;function fe(){return z}function Fe(){try{return sessionStorage.getItem(J)}catch(e){return null}}function K(e){if(L)return L;let t=typeof window=="undefined"?null:ue("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Fe();return z=!!n,L=Promise.resolve(n?{token:n,fresh:!1}:null),L}return z=!0,L=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(J,r)}catch(l){}return{token:r,fresh:!0}}).catch(()=>({error:0})),L}function ge(){try{sessionStorage.removeItem(J)}catch(e){}}var pe="sentient_preview_cell",me="sentient_refresh_region",q="sentient-cell-preview-bar",O="__preview__",Ne=null;function ye(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(q))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(pe),n=s.get(me)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(r);if(!fe())return;if(n){Ne={slotId:n,session:l,base:r},V(n,{kind:"arms"}),D(n,O),F();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let f=t.slice(0,d),I=t.slice(d+1);l.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(W(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){W(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&de(a.vocabulary),a.compose!=null)V(f,{kind:"arms",compose:{[O]:a.compose}}),D(f,O);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))V(f,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),D(f,O);else if(a.blocks!=null)V(f,{kind:"arms",blocks:{[O]:a.blocks}}),D(f,O);else if(a.content!=null)V(f,{kind:"arms",content:a.content}),D(f,O);else{W("Nothing to preview in that square yet.");return}F(),W(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var g;try{(g=document.querySelector(`[data-sentient-slot="${f}"]`))==null||g.scrollIntoView({block:"center"})}catch(m){}},300)}).catch(()=>W("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function W(e){var l;if(document.getElementById(q))return;let t=document.createElement("div");t.id=q,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=()=>{ge();let d=new URL(window.location.href);d.searchParams.delete(pe),d.searchParams.delete(me),window.location.assign(d.toString())},t.append(n,r),((l=document.body)!=null?l:document.documentElement).append(t)}var ve=!1;function _e(e){if(ve||typeof window=="undefined")return;ve=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||We(t,n.token)})}function We(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})}import{jsx as He}from"react/jsx-runtime";function Be(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return $e({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var we="https://api.sentient-ui.com/v1",Ue=Me({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:we,debug:!1}),he=!1,X=new Set;function je(e,t,n){let r=x(n);r.current=n;let[l,d]=M(null),[f,I]=M(!1),s=x(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify($(y({},e),{check:typeof e.check,refused:typeof e.refused}));return _(()=>{let g=s.current;if(g===void 0||typeof window=="undefined")return;let m,E=!1;return import("@sentientui/core/consent").then(({consentWatcher:R,forgetVisitor:T})=>{if(E)return;let P=R(typeof g=="object"&&g.cmp===void 0&&g.check?y($(y({},g),{check:()=>s.current.check()}),g.refused?{refused:()=>{var h,w;return((w=(h=s.current).refused)==null?void 0:w.call(h))===!0}}:{}):g),S=!1,G=()=>{let h=P.refused()&&P.read()!==!0;h&&!S&&(T(t),r.current()),S=h,I(h);let w=P.read();w!==null&&X.add(t),d(w!=null?w:X.has(t)?!1:null)};G(),m=P.subscribe(G)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function be(e){var Y,Q,Z;let[t,n]=M(null),[r]=M(()=>{var i;return(i=e.sessionSegment)!=null?i:Be()}),[l,d]=M(B());_(()=>se(()=>d(B())),[]),_(()=>{ye(e.apiBaseUrl),_e(e.apiBaseUrl)},[]);let f=x(()=>{}),I=je(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Y=I.granted)!=null?Y:X.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?I.refused:!0,g=x(a);g.current=a;let m=x(null),E=x(!1),R=x([]),T=x(!1);f.current=()=>{var u;R.current=[],T.current=!0;let i=m.current;i!=null&&i.gated?i.dispose():(u=i==null?void 0:i.takeHeld)==null||u.call(i)},_(()=>{var ee,te;if(g.current&&s===!1&&(R.current=[]),s===!1&&E.current&&(g.current&&((ee=m.current)==null||ee.destroy()),m.current=null,E.current=!1),s===!1&&!e.preConsentBehavior){g.current&&((te=m.current)==null||te.destroy()),m.current=null,n(null);return}let i=s!==!1;i&&(T.current=!1);let u=v=>{!i&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},H?{sdk:H}:{}),c=!1,o=null,b=null,C=v=>{for(let A of R.current.splice(0))setTimeout(()=>{if(m.current!==v){T.current||R.current.push(A);return}try{A(v)}catch(Xe){}},0)},k=v=>{e.engagement===!1||!i||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{c||(b=A(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{c||(o=v($(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=i,C(o),n(o),k(o))}):(o=Ke(p),u(o),m.current=o,E.current=i,C(o),n(o),k(o)),()=>{var v,A;c=!0,b==null||b(),R.current=R.current.concat((A=(v=o==null?void 0:o.takeHeld)==null?void 0:v.call(o))!=null?A:[]),o==null||o.dispose()}},[s]),_(()=>{if(!t)return;let i=!1,u=async()=>{if(i)return;let c;try{c=await t.fetchWeights()}catch(o){return}if(!i)for(let o of c){let b={componentId:o.componentId,updatedAt:o.updatedAt,variants:o.variants.map(C=>{var k;return{variantId:C.variantId,pulls:C.pulls,avgReward:(k=C.avgReward)!=null?k:0}})};re(o.componentId,b)}};u();let p=setInterval(()=>{u()},6e4);return()=>{i=!0,clearInterval(p)}},[t]);let P=(Q=e.ssrFallback)!=null?Q:"first",S=((Z=e.apiBaseUrl)!=null?Z:we).replace(/\/$/,""),G=x(null);_(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:S},u=G.current;if(G.current=i,u!==null)for(let c of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[c],i[c])||console.warn(`[sentient] AdaptiveProvider: \`${c}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,S]),_(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||le({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]),_(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){j(i);return}e.declaredSections&&e.declaredSections.length>0&&j(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),_(()=>{!N()||e.consent!==void 0||e.consentFrom!==void 0||he||(he=!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'))},[]),_(()=>{if(!N())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),c=>c.getAttribute("data-sentient-id"))),p=i.filter(c=>!u.has(c));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(c=>`"${c}"`).join(", ")} ${p.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let h=Se(()=>t&&l?ae(t):t,[t,l]),w=Se(()=>{var i,u,p,c,o,b,C,k;return{client:h,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:P,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(p=e.initialSlots)!=null?p:{},initialSlotConfig:(c=e.initialSlotConfig)!=null?c:{},initialPalette:(o=e.initialPalette)!=null?o:null,initialVocabulary:(b=e.initialVocabulary)!=null?b:null,initialPersona:(C=e.initialPersona)!=null?C:null,apiBaseUrl:S,debug:(k=e.debug)!=null?k:!1}},[h,e.apiKey,e.initialAssignments,r,P,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return He(Ue.Provider,{value:w,children:e.children})}function ze(e){return e<.3?"low":e<.7?"medium":"high"}function Ce(e={}){var n,r,l;let t=window;if(t.__sentient_overrides=y({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=y({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=y({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",ze((l=e.confidence)!=null?l:1))}catch(d){}}else delete t.__sentient_persona_override;F()}import{jsx as qe}from"react/jsx-runtime";function Bt(e,t={},n){return Ce(t),Je(qe(be,{apiKey:"pk_test",consent:!1,children:e}),n)}export{Bt as renderWithSentient};
2
+ var xe=Object.defineProperty,Re=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var ne=Object.getOwnPropertySymbols;var Ee=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var ie=(e,t,n)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ee.call(t,n)&&ie(e,n,t[n]);if(ne)for(var n of ne(t))Pe.call(t,n)&&ie(e,n,t[n]);return e},$=(e,t)=>Re(e,ke(t));import{render as Je}from"@testing-library/react";import{createContext as Me,useContext as Ct,useEffect as _,useMemo as Se,useRef as x,useState as M,useSyncExternalStore as xt}from"react";import{deriveSessionSegment as $e,init as Ke}from"@sentientui/core";var Ae=new Map,Oe=new Map;function re(e,t){Ae.set(e,t);let n=Oe.get(e);if(n)for(let r of n)try{r(t)}catch(l){}}var Ie={on:!1,listeners:new Set};function oe(){if(typeof window=="undefined")return Ie;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function B(){return oe().on}function se(e){let t=oe().listeners;return t.add(e),()=>{t.delete(e)}}function ae(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,l)=>e.assign(t,n,r,l),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Te="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Te))}function le(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function N(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ve={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function U(){if(typeof window=="undefined")return Ve;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 De(){U().version+=1;for(let e of U().listeners)e()}function j(e){N()&&(U().sections=[...e],De())}var ce="0.37.4",H=ce!=="0.0.0-dev"?{name:"react",version:ce}:void 0;function Le(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function V(e,t){Le()[e]=t}function de(e){window.__sentient_vocabulary_override=e}function Ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ge()[e]=t}function ue(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let l=n.slice(r.index+r[0].length);r[1]!="&"&&l[0]=="&"&&(l=r[1]+l.slice(1));let d=n.slice(0,r.index)+l;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var J="__snt_editor_token",L=null,z=!1;function fe(){return z}function Fe(){try{return sessionStorage.getItem(J)}catch(e){return null}}function K(e){if(L)return L;let t=typeof window=="undefined"?null:ue("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Fe();return z=!!n,L=Promise.resolve(n?{token:n,fresh:!1}:null),L}return z=!0,L=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(J,r)}catch(l){}return{token:r,fresh:!0}}).catch(()=>({error:0})),L}function ge(){try{sessionStorage.removeItem(J)}catch(e){}}var pe="sentient_preview_cell",me="sentient_refresh_region",q="sentient-cell-preview-bar",O="__preview__",Ne=null;function ye(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(q))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(pe),n=s.get(me)}catch(s){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(r);if(!fe())return;if(n){Ne={slotId:n,session:l,base:r},V(n,{kind:"arms"}),D(n,O),F();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let f=t.slice(0,d),I=t.slice(d+1);l.then(s=>s?"token"in s?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(W(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){W(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&de(a.vocabulary),a.compose!=null)V(f,{kind:"arms",compose:{[O]:a.compose}}),D(f,O);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))V(f,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),D(f,O);else if(a.blocks!=null)V(f,{kind:"arms",blocks:{[O]:a.blocks}}),D(f,O);else if(a.content!=null)V(f,{kind:"arms",content:a.content}),D(f,O);else{W("Nothing to preview in that square yet.");return}F(),W(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var g;try{(g=document.querySelector(`[data-sentient-slot="${f}"]`))==null||g.scrollIntoView({block:"center"})}catch(m){}},300)}).catch(()=>W("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function W(e){var l;if(document.getElementById(q))return;let t=document.createElement("div");t.id=q,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=()=>{ge();let d=new URL(window.location.href);d.searchParams.delete(pe),d.searchParams.delete(me),window.location.assign(d.toString())},t.append(n,r),((l=document.body)!=null?l:document.documentElement).append(t)}var ve=!1;function _e(e){if(ve||typeof window=="undefined")return;ve=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||We(t,n.token)})}function We(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})}import{jsx as He}from"react/jsx-runtime";function Be(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return $e({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var we="https://api.sentient-ui.com/v1",Ue=Me({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:we,debug:!1}),he=!1,X=new Set;function je(e,t,n){let r=x(n);r.current=n;let[l,d]=M(null),[f,I]=M(!1),s=x(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify($(y({},e),{check:typeof e.check,refused:typeof e.refused}));return _(()=>{let g=s.current;if(g===void 0||typeof window=="undefined")return;let m,E=!1;return import("@sentientui/core/consent").then(({consentWatcher:R,forgetVisitor:T})=>{if(E)return;let P=R(typeof g=="object"&&g.cmp===void 0&&g.check?y($(y({},g),{check:()=>s.current.check()}),g.refused?{refused:()=>{var h,w;return((w=(h=s.current).refused)==null?void 0:w.call(h))===!0}}:{}):g),S=!1,G=()=>{let h=P.refused()&&P.read()!==!0;h&&!S&&(T(t),r.current()),S=h,I(h);let w=P.read();w!==null&&X.add(t),d(w!=null?w:X.has(t)?!1:null)};G(),m=P.subscribe(G)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function be(e){var Y,Q,Z;let[t,n]=M(null),[r]=M(()=>{var i;return(i=e.sessionSegment)!=null?i:Be()}),[l,d]=M(B());_(()=>se(()=>d(B())),[]),_(()=>{ye(e.apiBaseUrl),_e(e.apiBaseUrl)},[]);let f=x(()=>{}),I=je(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Y=I.granted)!=null?Y:X.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?I.refused:!0,g=x(a);g.current=a;let m=x(null),E=x(!1),R=x([]),T=x(!1);f.current=()=>{var u;R.current=[],T.current=!0;let i=m.current;i!=null&&i.gated?i.dispose():(u=i==null?void 0:i.takeHeld)==null||u.call(i)},_(()=>{var ee,te;if(g.current&&s===!1&&(R.current=[]),s===!1&&E.current&&(g.current&&((ee=m.current)==null||ee.destroy()),m.current=null,E.current=!1),s===!1&&!e.preConsentBehavior){g.current&&((te=m.current)==null||te.destroy()),m.current=null,n(null);return}let i=s!==!1;i&&(T.current=!1);let u=v=>{!i&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},H?{sdk:H}:{}),c=!1,o=null,b=null,C=v=>{for(let A of R.current.splice(0))setTimeout(()=>{if(m.current!==v){T.current||R.current.push(A);return}try{A(v)}catch(Xe){}},0)},k=v=>{e.engagement===!1||!i||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{c||(b=A(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{c||(o=v($(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=i,C(o),n(o),k(o))}):(o=Ke(p),u(o),m.current=o,E.current=i,C(o),n(o),k(o)),()=>{var v,A;c=!0,b==null||b(),R.current=R.current.concat((A=(v=o==null?void 0:o.takeHeld)==null?void 0:v.call(o))!=null?A:[]),o==null||o.dispose()}},[s]),_(()=>{if(!t)return;let i=!1,u=async()=>{if(i)return;let c;try{c=await t.fetchWeights()}catch(o){return}if(!i)for(let o of c){let b={componentId:o.componentId,updatedAt:o.updatedAt,variants:o.variants.map(C=>{var k;return{variantId:C.variantId,pulls:C.pulls,avgReward:(k=C.avgReward)!=null?k:0}})};re(o.componentId,b)}};u();let p=setInterval(()=>{u()},6e4);return()=>{i=!0,clearInterval(p)}},[t]);let P=(Q=e.ssrFallback)!=null?Q:"first",S=((Z=e.apiBaseUrl)!=null?Z:we).replace(/\/$/,""),G=x(null);_(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:S},u=G.current;if(G.current=i,u!==null)for(let c of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[c],i[c])||console.warn(`[sentient] AdaptiveProvider: \`${c}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,S]),_(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||le({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]),_(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){j(i);return}e.declaredSections&&e.declaredSections.length>0&&j(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),_(()=>{!N()||e.consent!==void 0||e.consentFrom!==void 0||he||(he=!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'))},[]),_(()=>{if(!N())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),c=>c.getAttribute("data-sentient-id"))),p=i.filter(c=>!u.has(c));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(c=>`"${c}"`).join(", ")} ${p.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let h=Se(()=>t&&l?ae(t):t,[t,l]),w=Se(()=>{var i,u,p,c,o,b,C,k;return{client:h,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:P,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(p=e.initialSlots)!=null?p:{},initialSlotConfig:(c=e.initialSlotConfig)!=null?c:{},initialPalette:(o=e.initialPalette)!=null?o:null,initialVocabulary:(b=e.initialVocabulary)!=null?b:null,initialPersona:(C=e.initialPersona)!=null?C:null,apiBaseUrl:S,debug:(k=e.debug)!=null?k:!1}},[h,e.apiKey,e.initialAssignments,r,P,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return He(Ue.Provider,{value:w,children:e.children})}function ze(e){return e<.3?"low":e<.7?"medium":"high"}function Ce(e={}){var n,r,l;let t=window;if(t.__sentient_overrides=y({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=y({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=y({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",ze((l=e.confidence)!=null?l:1))}catch(d){}}else delete t.__sentient_persona_override;F()}import{jsx as qe}from"react/jsx-runtime";function Bt(e,t={},n){return Ce(t),Je(qe(be,{apiKey:"pk_test",consent:!1,children:e}),n)}export{Bt as renderWithSentient};
3
3
  //# sourceMappingURL=react.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.37.2",
3
+ "version": "0.37.4",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -78,8 +78,8 @@
78
78
  "llms.txt"
79
79
  ],
80
80
  "dependencies": {
81
- "@sentientui/core": "0.36.2",
82
- "@sentientui/policy": "0.13.1"
81
+ "@sentientui/core": "0.36.4",
82
+ "@sentientui/policy": "0.15.0"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@testing-library/react": ">=14.0.0 <17.0.0",