@sentientui/react 0.40.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -299,7 +299,7 @@ never both. `AdaptiveProps` is the union of the two exported prop types below.
|
|
|
299
299
|
| `goal` | `string \| GoalConfig` | Conversion goal (required). A string is a click-goal label; an object is an explicit `GoalConfig`. |
|
|
300
300
|
| `funnel` | `string` *(optional)* | Funnel this component serves — see [Funnels](#funnels--funnel-prop). |
|
|
301
301
|
| `microSignalGoals` | `MicroSignalGoals` *(optional)* | When a passive micro-signal fires on this component, also record a named goal: micro-signal type → goal name (or `{ name, weight?, stepIndex? }`), e.g. `{ rage_click: 'confused_by_hero' }`. |
|
|
302
|
-
| `agentDataByVariant` | `Record<string, unknown>` *(optional)* | Structured data keyed by variant ID that AI agents can consume via `GET /v1/agent/layout`. Only the assigned variant's entry is sent to the server. Preferred over `agentData`. |
|
|
302
|
+
| `agentDataByVariant` | `Record<string, unknown>` *(optional)* | Structured data keyed by variant ID that AI agents can consume via `GET /v1/agent/layout`. Only the assigned variant's entry is sent to the server. Preferred over `agentData`. A new or changed value is served to agents once visitors on a few different networks have reported it, so one forged request cannot rewrite it. |
|
|
303
303
|
| `agentData` | `unknown` *(optional, deprecated)* | Deprecated in favour of `agentDataByVariant`. Single value stored once regardless of which variant is shown; kept for backward compatibility. |
|
|
304
304
|
| `as`, `className` | *(optional)* | Wrapper element and its class, as for generated versions. |
|
|
305
305
|
| `clientOnly` | `boolean` | Render nothing on the server; resolve on the client only. Use for cookie-dependent components. Without it, a component with no preloaded assignment server-renders its first variant. (This replaces the deprecated provider-level `ssrFallback="none"`, which is still accepted.) |
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Tr=Object.create;var Ne=Object.defineProperty,Ir=Object.defineProperties,Nr=Object.getOwnPropertyDescriptor,Dr=Object.getOwnPropertyDescriptors,Lr=Object.getOwnPropertyNames,Ue=Object.getOwnPropertySymbols,Fr=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Zt=(e,t,n)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))mt.call(t,n)&&Zt(e,n,t[n]);if(Ue)for(var n of Ue(t))Qt.call(t,n)&&Zt(e,n,t[n]);return e},L=(e,t)=>Ir(e,Dr(t));var De=(e,t)=>{var n={};for(var r in e)mt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ue)for(var r of Ue(e))t.indexOf(r)<0&&Qt.call(e,r)&&(n[r]=e[r]);return n};var Vr=(e,t)=>{for(var n in t)Ne(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lr(t))!mt.call(e,i)&&i!==n&&Ne(e,i,{get:()=>t[i],enumerable:!(r=Nr(t,i))||r.enumerable});return e};var We=(e,t,n)=>(n=e!=null?Tr(Fr(e)):{},en(t||!e||!e.__esModule?Ne(n,"default",{value:e,enumerable:!0}):n,e)),Mr=e=>en(Ne({},"__esModule",{value:!0}),e);var gi={};Vr(gi,{Adaptive:()=>or,AdaptiveGroup:()=>wr,AdaptiveProvider:()=>Gn,AdaptiveSlot:()=>Ie,AdaptiveText:()=>sr,SentientPersonaScript:()=>dr,buildAgentFeed:()=>Ar,consentWatcher:()=>Er.consentWatcher,defineAgentContent:()=>Rr,detectSegment:()=>Lt.deriveSessionSegment,getAgentContent:()=>Ft,grantConsent:()=>Or.grantConsent,renderAgentJsonLd:()=>Cr,renderAgentJsonLdBody:()=>Vt,renderAgentMarkdown:()=>_r,renderBlocks:()=>we,renderCompose:()=>tt,useAdaptive:()=>br,useAdaptiveApiBaseUrl:()=>Mn,useAdaptiveGoal:()=>at,useAdaptivePersona:()=>mr,useAdaptiveTokens:()=>vr,useAssignment:()=>Qe,useInitialAssignments:()=>Xe,useLayoutOrder:()=>Nn,usePageGoal:()=>lr,useSentient:()=>M,useSessionSegment:()=>Te});module.exports=Mr(gi);var _=require("react"),He=require("@sentientui/core");var tn=new Map,Ke=new Map;function nn(e,t){let n=Ke.get(e);return n||(n=new Set,Ke.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ke.delete(e)}}function rn(e,t){tn.set(e,t);let n=Ke.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function pt(e){var t;return(t=tn.get(e))!=null?t:null}var $r={on:!1,listeners:new Set};function on(){if(typeof window=="undefined")return $r;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function yt(){return on().on}function sn(e){let t=on().listeners;return t.add(e),()=>{t.delete(e)}}function an(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,s)=>e.assign(t,n,r,i,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var vt="sentient:overrides-changed";function ln(){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(vt))}function Y(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(vt,e),()=>window.removeEventListener(vt,e))}function un(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function ee(e){return typeof e=="string"?{type:"click"}:e}function ge(e){return typeof e=="string"?e:e.type}function ae(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ht=new Set,bt=!1;function cn(e){if(ht.has(e))return!0;if(ht.add(e),!bt){bt=!0;let t=()=>{bt=!1,ht.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function dn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Br(r))return!0;r=r.parentElement}return!1}function le(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,p=[];return t.steps.forEach(({goal:l,name:x,weight:R},g)=>{let y=(h=!1)=>{o.has(g)||h&&r!==void 0&&cn(`step\0${x}\0${R}\0${g}`)||(o.add(g),n.fireStep(x,R,g))};if(l.type==="click"){let h=v=>{let d=v.target;d instanceof Element&&dn(d,e,l.selector)&&y()};e.addEventListener("click",h),p.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),p.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),v=new IntersectionObserver(d=>{for(let w of d)if(w.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let l of p)l()}}let i=t.type==="composite"?t.all:[t],s=new Set(i.map((o,p)=>p)),f=()=>{r!==void 0&&cn(r)||n.fireGoal()},a=(o,p=!1)=>{s.delete(o),s.size===0&&(p?f():n.fireGoal())},c=[];return i.forEach((o,p)=>{if(o.type==="click"){let l=x=>{let R=x.target;R instanceof Element&&dn(R,e,o.selector)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(o.type==="form_submit"){let l=x=>{x.target instanceof HTMLFormElement&&e.contains(x.target)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(o.type==="scroll_depth"){let l=Math.max(0,Math.min(1,o.threshold)),x=new IntersectionObserver(R=>{for(let g of R)if(g.intersectionRatio>=l){t.type==="composite"?a(p,!0):f(),x.disconnect();break}},{threshold:[l]});x.observe(e),c.push(()=>x.disconnect());return}}),()=>{for(let o of c)o()}}var fn=new Set,gn=new Set;function me(e,t,n,r,i){let s=`${r}|${n}`;if(gn.has(s))return;gn.add(s);let f=i.type==="weighted_composite"&&!fn.has(r);f&&fn.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:f?{funnelId:r,steps:i.steps.map(a=>({goalId:a.name,weight:a.weight}))}:{funnelId:r}})}function pe(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var jr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function Se(){if(typeof window=="undefined")return jr;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 Le(){Se().version+=1;for(let e of Se().listeners)e()}var mn=()=>{};function pn(e){return F()?(Se().components.set(e.id,e),Le(),()=>{Se().components.delete(e.id),Le()}):mn}function _e(e){return F()?(Se().slots.set(e.id,e),Le(),()=>{Se().slots.delete(e.id),Le()}):mn}function wt(e){F()&&(Se().sections=[...e],Le())}var yn="0.40.0",xt=yn!=="0.0.0-dev"?{name:"react",version:yn}:void 0;function Ur(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Oe(e,t){Ur()[e]=t}function vn(e){window.__sentient_vocabulary_override=e}function Sn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Wr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ee(e,t){Wr()[e]=t}function hn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let s=n.slice(0,r.index)+i;history.replaceState(history.state,"",s?"#"+s:location.pathname+location.search)}}catch(n){}return t}var Rt="__snt_editor_token",Pe=null,kt=!1;function bn(){return kt}function Kr(){try{return sessionStorage.getItem(Rt)}catch(e){return null}}function Je(e){if(Pe)return Pe;let t=typeof window=="undefined"?null:hn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Kr();return kt=!!n,Pe=Promise.resolve(n?{token:n,fresh:!1}:null),Pe}return kt=!0,Pe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(Rt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Pe}function wn(){try{sessionStorage.removeItem(Rt)}catch(e){}}var xn="sentient_preview_cell",kn="sentient_refresh_region",At="sentient-cell-preview-bar",he="__preview__",Ge=null;function Rn(e){if((Ge==null?void 0:Ge.slotId)!==e)return null;let t=Ge;return Ge=null,t}function An(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(m({slotId:e.slotId},t))})}).then(n=>be(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>be("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Cn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(At))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(xn),n=c.get(kn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Je(r);if(!bn())return;if(n){Ge={slotId:n,session:i,base:r},Oe(n,{kind:"arms"}),Ee(n,he),St();return}if(!t)return;let s=t.lastIndexOf("~");if(s<=0)return;let f=t.slice(0,s),a=t.slice(s+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(be(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){be(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let o=await c.json();if(o.vocabulary&&Array.isArray(o.vocabulary.entries)&&vn(o.vocabulary),o.compose!=null)Oe(f,{kind:"arms",compose:{[he]:o.compose}}),Ee(f,he);else if(o.edits!=null&&typeof o.skeletonFp=="string"&&Array.isArray(o.leafToNode))Oe(f,{kind:"arms",edits:{edits:o.edits,fp:o.skeletonFp,leafToNode:o.leafToNode}}),Ee(f,he);else if(o.blocks!=null)Oe(f,{kind:"arms",blocks:{[he]:o.blocks}}),Ee(f,he);else if(o.content!=null)Oe(f,{kind:"arms",content:o.content}),Ee(f,he);else{be("Nothing to preview in that square yet.");return}St(),be(`Previewing \u201C${o.slotName}\u201D for ${o.personaDisplay}${o.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${f}"]`))==null||p.scrollIntoView({block:"center"})}catch(l){}},300)}).catch(()=>be("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function be(e){var i;if(document.getElementById(At))return;let t=document.createElement("div");t.id=At,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{wn();let s=new URL(window.location.href);s.searchParams.delete(xn),s.searchParams.delete(kn),window.location.assign(s.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var _n=!1;function On(e){if(_n||typeof window=="undefined")return;_n=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Je(t).then(n=>{!n||!("token"in n)||!n.fresh||Jr(t,n.token)})}function Jr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var $n=require("react/jsx-runtime");function Hr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,He.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Pn="https://api.sentient-ui.com/v1",H=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Pn,debug:!1}),En=!1,Ct=new Set;function Xr(e,t,n){let r=(0,_.useRef)(n);r.current=n;let[i,s]=(0,_.useState)(null),[f,a]=(0,_.useState)(!1),c=(0,_.useRef)(e);c.current=e;let o=e===void 0?"":typeof e=="string"?e:JSON.stringify(L(m({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,_.useEffect)(()=>{let p=c.current;if(p===void 0||typeof window=="undefined")return;let l,x=!1;return import("@sentientui/core/consent").then(({consentWatcher:R,forgetVisitor:g})=>{if(x)return;let y=R(typeof p=="object"&&p.cmp===void 0&&p.check?m(L(m({},p),{check:()=>c.current.check()}),p.refused?{refused:()=>{var d,w;return((w=(d=c.current).refused)==null?void 0:w.call(d))===!0}}:{}):p),h=!1,v=()=>{let d=y.refused()&&y.read()!==!0;d&&!h&&(g(t),r.current()),h=d,a(d);let w=y.read();w!==null&&Ct.add(t),s(w!=null?w:Ct.has(t)?!1:null)};v(),l=y.subscribe(v)}),()=>{x=!0,l==null||l()}},[o,t]),{granted:i,refused:f}}function Gn(e){var C,P,E;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var b;return(b=e.sessionSegment)!=null?b:Hr()}),[i,s]=(0,_.useState)(yt());(0,_.useEffect)(()=>sn(()=>s(yt())),[]),(0,_.useEffect)(()=>{Cn(e.apiBaseUrl),On(e.apiBaseUrl)},[]);let f=(0,_.useRef)(()=>{}),a=Xr(e.consentFrom,e.apiKey,()=>f.current()),c=e.consentFrom?(C=a.granted)!=null?C:Ct.has(e.apiKey)?!1:e.consent===!0:e.consent,o=e.consentFrom?a.refused:!0,p=(0,_.useRef)(o);p.current=o;let l=(0,_.useRef)(null),x=(0,_.useRef)(!1),R=(0,_.useRef)([]),g=(0,_.useRef)(!1);f.current=()=>{var k;R.current=[],g.current=!0;let b=l.current;b!=null&&b.gated?b.dispose():(k=b==null?void 0:b.takeHeld)==null||k.call(b)},(0,_.useEffect)(()=>{var j,Q;if(p.current&&c===!1&&(R.current=[]),c===!1&&x.current&&(p.current&&((j=l.current)==null||j.destroy()),l.current=null,x.current=!1),c===!1&&!e.preConsentBehavior){p.current&&((Q=l.current)==null||Q.destroy()),l.current=null,n(null);return}let b=c!==!1;b&&(g.current=!1);let k=$=>{!b&&g.current&&$.gated&&$.dispose()},A=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},xt?{sdk:xt}:{}),u=!1,S=null,D=null,I=$=>{for(let W of R.current.splice(0))setTimeout(()=>{if(l.current!==$){g.current||R.current.push(W);return}try{W($)}catch(q){}},0)},T=$=>{e.engagement===!1||!b||import("@sentientui/core/engagement").then(({startEngagementCapture:W})=>{u||(D=W($,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:$})=>{u||(S=$(L(m({},A),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),k(S),l.current=S,x.current=b,I(S),n(S),T(S))}):(S=(0,He.init)(A),k(S),l.current=S,x.current=b,I(S),n(S),T(S)),()=>{var $,W;u=!0,D==null||D(),R.current=R.current.concat((W=($=S==null?void 0:S.takeHeld)==null?void 0:$.call(S))!=null?W:[]),S==null||S.dispose()}},[c]),(0,_.useEffect)(()=>{if(!t)return;let b=!1,k=async()=>{if(b)return;let u;try{u=await t.fetchWeights()}catch(S){return}if(!b)for(let S of u){let D={componentId:S.componentId,updatedAt:S.updatedAt,variants:S.variants.map(I=>{var T;return{variantId:I.variantId,pulls:I.pulls,avgReward:(T=I.avgReward)!=null?T:0}})};rn(S.componentId,D)}};k();let A=setInterval(()=>{k()},6e4);return()=>{b=!0,clearInterval(A)}},[t]);let y=(P=e.ssrFallback)!=null?P:"first",h=((E=e.apiBaseUrl)!=null?E:Pn).replace(/\/$/,""),v=(0,_.useRef)(null);(0,_.useEffect)(()=>{var A;if(typeof process!="undefined"&&((A=process.env)==null?void 0:A.NODE_ENV)==="production")return;let b={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},k=v.current;if(v.current=b,k!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(k[u],b[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),(0,_.useEffect)(()=>{var b;typeof process!="undefined"&&((b=process.env)==null?void 0:b.NODE_ENV)==="production"||un({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]),(0,_.useEffect)(()=>{let b=e.initialLayoutOrder;if(b&&b.length>0){wt(b);return}e.declaredSections&&e.declaredSections.length>0&&wt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||En||(En=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,_.useEffect)(()=>{if(!F())return;let b=e.declaredSections;if(!b||b.length===0||typeof document=="undefined")return;let k=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),A=b.filter(u=>!k.has(u));A.length>0&&console.warn(`[SentientUI] Declared section${A.length>1?"s":""} ${A.map(u=>`"${u}"`).join(", ")} ${A.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let d=(0,_.useMemo)(()=>t&&i?an(t):t,[t,i]),w=(0,_.useMemo)(()=>{var b,k,A,u,S,D,I,T,j;return{client:d,apiKey:e.apiKey,initialAssignments:(b=e.initialAssignments)!=null?b:{},initialUnified:(k=e.initialUnified)!=null?k:zr,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(A=e.initialLayoutOrder)!=null?A:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(D=e.initialPalette)!=null?D:null,initialVocabulary:(I=e.initialVocabulary)!=null?I:null,initialPersona:(T=e.initialPersona)!=null?T:null,apiBaseUrl:h,debug:(j=e.debug)!=null?j:!1}},[d,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,$n.jsx)(H.Provider,{value:w,children:e.children})}function M(){return(0,_.useContext)(H).client}function ue(){return(0,_.useContext)(H).apiKey}function Xe(){return(0,_.useContext)(H).initialAssignments}var zr=[];function ze(){return(0,_.useContext)(H).initialUnified}function Te(){return(0,_.useContext)(H).sessionSegment}function Tn(){return(0,_.useContext)(H).ssrFallback}function qe(){return(0,_.useContext)(H).onAssignment}function In(){return(0,_.useContext)(H).debug}function Nn(){let e=(0,_.useContext)(H).initialLayoutOrder,t=(0,_.useSyncExternalStore)(Y,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ye(){return(0,_.useContext)(H).initialSlots}function Dn(){return(0,_.useContext)(H).initialPersona}function Ln(){return(0,_.useContext)(H).initialSlotConfig}function Fn(){return(0,_.useContext)(H).initialPalette}function Vn(){return(0,_.useContext)(H).initialVocabulary}function Mn(){return(0,_.useContext)(H).apiBaseUrl}var de=require("react");var B=require("react"),Bn=require("@sentientui/core");var ne=require("react"),Ze=require("@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 s=i.indexOf(":");if(s!==-1&&i.slice(0,s)===e)return i.slice(s+1)}}catch(r){}return null}function Qe(e,t,n,r,i){let s=Xe(),f=Tn(),a=M(),c=Te(),o=qe(),p=In(),l=(0,ne.useRef)(null),x=(0,ne.useSyncExternalStore)(Y,()=>ye(e),()=>null),R=x&&t.includes(x)?x:null,g=(0,ne.useRef)(null);(0,ne.useEffect)(()=>{p&&R&&g.current!==R&&(g.current=R,console.info(`[sentient] override active: ${e} -> ${R}`))},[p,R,e]);let[y,h]=(0,ne.useState)(()=>{var C,P;if(R)return{variantId:R,content:null,isLoading:!1,settled:!0};if(!a){let E=s[e];return E&&t.includes(E)?{variantId:E,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content))return{variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0};let w=pt(e);if(w){let E=(0,Ze.pickFromWeights)(w.variants,t);if(E)return{variantId:E,content:null,isLoading:!1,settled:!0}}return{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}}),v=d=>{o&&l.current!==d&&(l.current=d,o(e,d))};return(0,ne.useEffect)(()=>{var C;if(R||!a)return;let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content)){h({variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0}),v(d.variantId);return}let w=pt(e);if(w&&y.settled&&y.variantId&&y.variantId===(0,Ze.pickFromWeights)(w.variants,t)){v(y.variantId);return}h(P=>{var E;return P.variantId?P:{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}})},[R,a,e,c]),(0,ne.useEffect)(()=>{if(R||!a)return;let d=a.getAssignment(e,c);if(d&&t.includes(d.variantId))return;let w=!1,C=i==null?void 0:i.onUnified;return(C?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(E=>{var b;if(!w&&E){if(E.unified===!0){C==null||C();return}!t.includes(E.variantId)&&!E.content||(h({variantId:E.variantId,content:(b=E.content)!=null?b:null,isLoading:!1,settled:!0}),v(E.variantId))}}),()=>{w=!0}},[R,a,e,c]),(0,ne.useEffect)(()=>{if(!R&&a)return nn(e,d=>{var P;let w=a.getAssignment(e,c);if(w&&(t.includes(w.variantId)||w.content)){h({variantId:w.variantId,content:(P=w.content)!=null?P:null,isLoading:!1,settled:!0}),v(w.variantId);return}let C=(0,Ze.pickFromWeights)(d.variants,t);C&&(h({variantId:C,content:null,isLoading:!1,settled:!0}),v(C))})},[R,a,e,c]),R?{variantId:R,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function et(e,t,n){let r=M(),i=ue(),s=Object.keys(t).join("\0"),f=(0,B.useMemo)(()=>Object.keys(t),[s]),{variantId:a,content:c,isOverride:o=!1,settled:p}=Qe(e,f,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,x]=(0,B.useState)(null),R=(0,B.useRef)(null),g=(0,B.useCallback)(u=>{R.current=u,x(u)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=(0,B.useMemo)(()=>y?ee(y):null,[h]),d=y?ge(y):"";(0,B.useEffect)(()=>pn({id:e,variantIds:f,goal:d}),[e,f,d]);let w=(0,B.useRef)(null);(0,B.useEffect)(()=>{o||p&&(!r||!a||!i||!l||w.current!==a&&(w.current=a,pe(r,i,e,a)))},[r,a,i,e,l,o,p]);let C=(0,B.useRef)(!1),P=(0,B.useRef)(new Set);(0,B.useEffect)(()=>{C.current=!1,P.current=new Set},[a,v]);let E=n.funnel;(0,B.useEffect)(()=>{o||!p||!r||!E||!v||me(r,i,e,E,v)},[r,i,e,E,v,o,p]);let b=n.cursorSignal===!0;(0,B.useEffect)(()=>{if(!b||o||!p||!r||!a||!l)return;let u=null,S=0,D=()=>{S=Date.now(),u=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-S}}),u=null},800)},I=()=>{u!==null&&(clearTimeout(u),u=null)};return l.addEventListener("mouseenter",D),l.addEventListener("mouseleave",I),()=>{l.removeEventListener("mouseenter",D),l.removeEventListener("mouseleave",I),u!==null&&clearTimeout(u)}},[b,r,a,i,e,l,o,p]);let k=(0,B.useRef)(n.microSignalGoals);k.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,B.useEffect)(()=>{if(o||!p||!r||!a||!l)return;let u=Date.now();return(0,Bn.attachMicroSignalDetectors)((S,D={})=>{var $,W,q;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:m({signalType:S},D)});let I=($=k.current)==null?void 0:$[S];if(!I||P.current.has(S))return;P.current.add(S);let T=typeof I=="string"?I:I.name,j=typeof I=="string"?1:(W=I.weight)!=null?W:1,Q=typeof I=="string"?0:(q=I.stepIndex)!=null?q:0;r.goal(T,{metadata:m({signalType:S},D),weight:j,stepIndex:Q})},l,u)},[r,a,i,e,l,A,o,p]),(0,B.useEffect)(()=>{if(o||!p||!r||!a||!l||!v)return;let u=ae(v);return le(l,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:d,payload:m({reward:1},u!==void 0?{goalValue:u}:{})}),r.goal(d,m({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},u!==void 0?{value:u}:{})))},fireStep:(S,D,I)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:S,payload:{reward:D}}),r.goal(S,{metadata:{},weight:D,stepIndex:I})}},d)},[r,a,i,e,l,v,d,o,p]),{client:r,variantIds:f,variantId:a,content:c,settled:p,isOverride:o,goalLabel:d,ref:g,nodeRef:R}}var N=require("react"),ke=require("@sentientui/core"),Nt=require("@sentientui/core/region");var Z=require("react"),Un=require("@sentientui/core");var jn=new Set,qr={kind:"arms"};function Wn(e,t){var P,E,b;let n=M(),r=(0,Z.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,Z.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let s=(0,Z.useRef)(t==null?void 0:t.skeleton);s.current=t==null?void 0:t.skeleton;let f=Ye(),a=Ln(),c=Fn(),o=Vn(),p=(0,Z.useSyncExternalStore)(Y,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_config_overrides)==null?void 0:k[e]:void 0},()=>{}),l=(0,Z.useSyncExternalStore)(Y,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_overrides)==null?void 0:k[e]:void 0},()=>{}),x=k=>k==null?"":(0,Un.armOfResult)(k),R=(0,Z.useCallback)(k=>{var A,u;return(u=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,k))!=null?u:(()=>{})},[n]);(0,Z.useSyncExternalStore)(R,()=>{var k;return(k=n==null?void 0:n.getSlotConfig(e))!=null?k:null},()=>null),(0,Z.useSyncExternalStore)(R,()=>x(n==null?void 0:n.getSlotResult(e)),()=>"");let g=p===void 0?a[e]:void 0,y=p===void 0&&g===void 0&&n?n.getSlotConfig(e):null,h=(P=c!=null?c:n==null?void 0:n.getSitePalette())!=null?P:null,v=(b=o!=null?o:(E=n==null?void 0:n.getStyleVocabulary)==null?void 0:E.call(n))!=null?b:null,d=(()=>{var k,A,u;if(p!==void 0)return{config:p,arm:x(l),palette:h,vocabulary:(k=Sn())!=null?k:v,source:"override"};if(t!=null&&t.forcedArm)return{config:qr,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(g!==void 0)return{config:g,arm:x((A=f[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let S=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:x((u=n==null?void 0:n.getSlotResult(e))!=null?u:f[e]),palette:h,vocabulary:v,source:S?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),w=(t==null?void 0:t.defer)===!0,C=d.source==="preloaded"||d.source==="override";return(0,Z.useEffect)(()=>{var j,Q,$,W,q;if(!n||n.isLocal===!0||C||w)return;let k=d.source==="none",A=k&&(Q=(j=r.current)==null?void 0:j.call(r))!=null?Q:null,u=A!=null&&A!==""?{[e]:A}:void 0,S=($=i.current)==null?void 0:$.call(i),D=k&&(q=(W=s.current)==null?void 0:W.call(s))!=null?q:null,I=m(m({},S?{render:{[e]:S}}:{}),D?{skeletons:{[e]:D}}:{}),T=Object.keys(I).length>0;return n.requestSlots?T?n.requestSlots([e],u,I):u?n.requestSlots([e],u):n.requestSlots([e]):k&&(D?n.reportSlots([e],u!=null?u:{},{[e]:D}):u?n.reportSlots([e],u):n.reportSlots([e])),()=>{var K;return(K=n.cancelSlots)==null?void 0:K.call(n,[e])}},[n,C,d.source,e,w]),(0,Z.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||d.source!=="none"||jn.has(e)||(jn.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,d.source,e]),d}var Fe=require("react");var V=require("react/jsx-runtime");function _t(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ve={none:"0",sm:"8px",md:"16px",lg:"24px"},Ot={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Xn={sm:"0.875em",md:"1em",lg:"1.25em"},Yr={sm:"1.25em",md:"1.5em",lg:"2em"},Kn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Jn={sm:"8px",md:"16px",lg:"32px"},Zr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Qr={normal:"400",medium:"500",bold:"700"};function Hn(e,t){return m(m({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?m({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function zn(e,t,n){var i,s,f,a;let r=t==null?void 0:t.accent;return L(m({display:"inline-block",padding:(i=Kn[n!=null?n:"md"])!=null?i:Kn.md,borderRadius:(s=t==null?void 0:t.radius)!=null?s:"8px",font:"inherit"},n?{fontSize:Xn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(f=t==null?void 0:t.primaryBg)!=null?f:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ei({node:e,opts:t}){var i,s,f,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(f=(s=t.palette)==null?void 0:s.border)!=null?f:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return(0,V.jsxs)("form",{onSubmit:o=>{var x,R,g;o.preventDefault();let p=new FormData(o.currentTarget),l={};for(let y of e.fields)l[y.name]=String((x=p.get(y.name))!=null?x:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,l)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var p,l;return(0,V.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,V.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,V.jsx)("select",{name:o.name,required:o.required,style:r,children:((p=o.options)!=null?p:[]).map(x=>(0,V.jsx)("option",{value:x,children:x},x))}):(0,V.jsx)("input",{name:o.name,type:(l=o.inputType)!=null?l:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,V.jsx)("button",{type:"submit",style:zn(n,t.palette),children:e.submitLabel})]})}function ti(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(s=>s.id===n))==null?void 0:i.classes:void 0}function qn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function we(e,t){var i;let n=ni(e,t),r=qn(e.like,t);return n&&r?(0,Fe.cloneElement)(n,{style:L(m({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ni(e,t){var n,r,i,s,f,a,c,o,p,l,x,R,g,y,h,v,d,w,C,P,E,b,k;try{let A=ti(e,t);switch(e.type){case"stack":{let u=(r=ve[(n=e.gap)!=null?n:"md"])!=null?r:ve.md,S=e.surface==="raised"&&!A,D=(i=e.pad)!=null?i:S?"md":void 0;return(0,V.jsx)("div",L(m({},A?{className:A}:{}),{style:m(m(m(m(m({display:"flex",flexDirection:e.direction,gap:u},e.align?{alignItems:Ot[e.align]}:{}),e.justify?{justifyContent:Ot[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),D?{padding:(s=ve[D])!=null?s:ve.md}:{}),S?L(m(m({},(f=t.palette)!=null&&f.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(o=t.palette)==null?void 0:o.border)!=null?p:"currentColor"}`,borderRadius:(x=(l=t.palette)==null?void 0:l.radius)!=null?x:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((I,T)=>{let j=we(I,t);return j===null?null:(0,V.jsx)(Fe.Fragment,{children:j},T)})}))}case"grid":{let u=(y=ve[(g=e.gap)!=null?g:"md"])!=null?y:ve.md;return(0,V.jsx)("div",L(m({},A?{className:A}:{}),{style:m(m({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${u}) / ${e.columns})), 1fr))`,gap:u},e.align?{alignItems:Ot[e.align]}:{}),e.pad?{padding:(h=ve[e.pad])!=null?h:ve.md}:{}),children:((v=e.children)!=null?v:[]).map((S,D)=>{let I=we(S,t);return I===null?null:(0,V.jsx)(Fe.Fragment,{children:I},D)})}))}case"text":return A?(0,V.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,V.jsx)("p",{style:m(m(m(m(m({margin:0},e.size?{fontSize:Xn[e.size]}:{}),e.weight?{fontWeight:Qr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Hn(e.tone,t.palette)),children:e.value});case"heading":{let u=`h${e.level}`;return A?(0,V.jsx)(u,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,V.jsx)(u,{style:m(m({margin:0,fontSize:Yr[(d=e.size)!=null?d:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let u=(w=e.emphasis)!=null?w:"primary";return(0,V.jsx)("a",L(m(m({href:_t(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:zn(u,t.palette,e.size)}),{children:e.label}))}case"link":return(0,V.jsx)("a",L(m(m({href:_t(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,V.jsx)("img",L(m({src:_t(e.src),alt:e.alt},A?{className:A}:{}),{style:m(m({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Zr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,V.jsx)("span",{className:A,children:e.value}):(0,V.jsx)("span",{style:m({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(P=(C=t.palette)==null?void 0:C.border)!=null?P:"currentColor"}`},Hn(e.tone,t.palette)),children:e.value});case"spacer":return(0,V.jsx)("div",{style:{height:(E=Jn[e.size])!=null?E:Jn.md}});case"divider":return(0,V.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,V.jsx)(ei,{node:e,opts:t});default:return null}}catch(A){return null}}function tt(e,t){var s,f,a,c;let n=we(e.tree,t);if(n===null)return null;let r=(s=e.surface)!=null&&s.like?(a=(f=t.vocabulary)==null?void 0:f.entries.find(o=>o.id===e.surface.like))==null?void 0:a.classes:void 0,i=qn((c=e.surface)==null?void 0:c.like,t);return r?(0,V.jsx)("div",L(m({className:r},i?{style:{color:i}}:{}),{children:n})):n}var ce=require("react"),nt=require("@sentientui/core/region");function rt(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function it(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function xe(e){return rt(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+xe(n),0):(0,ce.isValidElement)(e)?xe(it(e)):0}function ri(e,t){return Array.isArray(t)?(0,ce.cloneElement)(e,void 0,...t):(0,ce.cloneElement)(e,void 0,t)}function Et(e,t){if(rt(e))return t;if(Array.isArray(e))return e.map(n=>Et(n,t));if((0,ce.isValidElement)(e)){let n=it(e);return xe(n)===0?e:ri(e,Et(n,t))}return e}function Yn(e,t){return xe(e)===1?Et(e,t):null}var te=e=>e.join("/");function Pt(e,t,n){if(rt(e)){n.leafPaths.push(t),n.texts.push((0,nt.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Pt(r,[...t,i],n));return}(0,ce.isValidElement)(e)&&(n.elements.set(te(t),e),Pt(it(e),[...t,"c"],n))}function Tt(e){let t={leafPaths:[],texts:[],elements:new Map};return Pt(e,[],t),t}function ii(e){return Tt(e).texts}function Zn(e){let t=ii(e);return t.length===0?null:(0,nt.skeletonFingerprint)(t)}function oi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Qn(e,t){let n=t.reduce((i,s)=>Math.max(i,s+1),0),r=[];for(let i=0;i<n;i++){let s=t.flatMap((a,c)=>a===i?[oi(e.leafPaths[c])]:[]);if(s.length===0){r.push(null);continue}let f=s[0];for(let a of s.slice(1)){let c=new Set(a.map(te));f=f.filter(o=>c.has(te(o)))}r.push(f.length>0?f[f.length-1]:null)}return r}function Gt(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 It(e,t){let n=Tt(t);if(n.texts.length!==e.leaves.length||n.texts.some((s,f)=>s!==e.leaves[f]))return null;let r=Qn(n,e.leafToNode),i=e.nodes.map((s,f)=>{let a=r[f],c=a?n.elements.get(te(a)):void 0,o=!!c&&(typeof c.type=="string"||Gt(c)!==void 0);return L(m({},s),{restylable:o})});return L(m({},e),{nodes:i})}function er(e,t,n){var g;let r=Tt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let s=Qn(r,n),f=new Map;n.forEach((y,h)=>{f.has(y)||f.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[te(y),h])),c=new Set,o=new Map,p=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),d=s[v];if(h.hidden&&(d?c.add(te(d)):p=!0),h.like!==void 0){let w=s[h.like],C=d?r.elements.get(te(d)):void 0,P=w?Gt(r.elements.get(te(w))):void 0;!d||P===void 0||Gt(C)===void 0?p=!0:o.set(te(d),P)}}let l=new Map(Object.entries((g=t.order)!=null?g:{})),x=(y,h)=>{var v;if(rt(y)){let d=a.get(te(h));if(d===void 0)return y;let w=n[d],C=(v=t.nodes[String(w)])==null?void 0:v.text;return C===void 0?y:f.get(w)===d?C:""}if(Array.isArray(y)){let d=y.map((w,C)=>x(w,[...h,C]));for(let[w,C]of l){let P=C.map(k=>{let A=s[k];return!A||A.length!==h.length+1||te(A.slice(0,-1))!==te(h)?-1:A[A.length-1]});if(P.some(k=>k<0))continue;let E=[...P].sort((k,A)=>k-A),b=[...d];E.forEach((k,A)=>{d[k]=b[P[A]]}),l.delete(w)}return d}if((0,ce.isValidElement)(y)){let d=te(h);if(c.has(d))return null;let w=it(y);if(xe(w)===0)return y;let C=x(w,[...h,"c"]),P=o.get(d),E=P!==void 0?{className:P}:void 0;return Array.isArray(C)?(0,ce.cloneElement)(y,E,...C):(0,ce.cloneElement)(y,E,C)}return y},R=x(e,[]);return p||l.size>0?null:R}var ir=require("react/jsx-runtime"),tr=new Set,nr=new Set,rr=new Set,ot="authored.";function Ie({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:s,as:f="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:o,clientOnly:p,agentDataByVariant:l,agentData:x,variantsOnly:R=!1}){var Ht,Xt;let g=M(),y=ue(),h=(0,N.useRef)(null),[v,d]=(0,N.useState)(!1);(0,N.useEffect)(()=>{d(!0)},[]);let w=p===!0&&(!v||!g),C=(0,N.useMemo)(()=>Zn(t),[t]),P=n?Object.keys(n).join("|"):"",E=(0,N.useMemo)(()=>m({fp:C!=null?C:"0000000000000000",forms:!!r,compose:!0,content:xe(t)===1,ops:!1},P!==""?{authored:P.split("|"),children:!R}:{}),[C,t,r,P,R]),b=()=>{var J;let O=h.current;if(!O||!a)return null;let G=(0,Nt.captureRegionSkeleton)(O);return G.skeleton?(J=It(G.skeleton,t))!=null?J:L(m({},G.skeleton),{editable:!1,nodes:G.skeleton.nodes.map(U=>L(m({},U),{restylable:!1}))}):{status:G.reason}},k=(0,N.useSyncExternalStore)(Y,()=>n?ye(e):null,()=>null),A=k===null||!n?null:Object.prototype.hasOwnProperty.call(n,k)?`${ot}${k}`:R?`${ot}${Object.keys(n)[0]}`:"baseline",{config:u,arm:S,palette:D,vocabulary:I,source:T}=Wn(e,{forcedArm:A,baselineText:a?()=>{var O,G;return(G=(O=h.current)==null?void 0:O.textContent)!=null?G:null}:void 0,render:()=>E,skeleton:b,defer:w}),j=S!==""?(Ht=u==null?void 0:u.blocks)==null?void 0:Ht[S]:void 0,Q=S!==""?(Xt=u==null?void 0:u.compose)==null?void 0:Xt[S]:void 0,$=(j!==void 0&&(0,ke.containsFormBlock)(j)||Q!==void 0&&(0,ke.containsFormBlock)(Q.tree))&&!r;(0,N.useEffect)(()=>{!$||!F()||tr.has(e)||(tr.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[$,e]);let W=O=>{!g||T==="override"||(T!=="seeded"&&g.componentGoal(e,O),g.goal(O,{metadata:{componentId:e,arm:S},weight:1,stepIndex:0}))},q=t,K=!1,oe=S.startsWith(ot)?S.slice(ot.length):null;if((u==null?void 0:u.blocked)==="variant_history")K=!0;else if(oe!==null)n&&Object.prototype.hasOwnProperty.call(n,oe)?q=n[oe]:K=!0;else if(Q!==void 0){let O=$?null:tt(Q,{palette:D,vocabulary:I,onFormSubmit:r,onFormGoal:W});O===null?K=!0:q=O}else if(j!==void 0){let O=$?null:we(j,{palette:D,vocabulary:I,onFormSubmit:r,onFormGoal:W});O===null?K=!0:q=O}else if((u==null?void 0:u.edits)!==void 0&&T!=="none"){let O=u.edits,G=O.fp===C?er(t,O.edits,O.leafToNode):null;G===null?K=!0:q=G}else if((u==null?void 0:u.content)!==void 0&&T!=="none"){let O=Yn(t,u.content);O===null?K=!0:q=O}let Mt=K&&j===void 0&&Q===void 0&&(u==null?void 0:u.edits)===void 0&&oe===null&&(u==null?void 0:u.blocked)===void 0;(0,N.useEffect)(()=>{(u==null?void 0:u.blocked)!=="variant_history"||!F()||rr.has(e)||(rr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[u==null?void 0:u.blocked,e]);let Me=oe!==null&&!K?oe:null;(0,N.useEffect)(()=>{var se;if(!Me||!a||!g)return;let O=h.current;if(!O)return;let G=(0,Nt.captureRegionSkeleton)(O),J=G.skeleton?It(G.skeleton,n==null?void 0:n[Me]):null,U=(se=O.textContent)==null?void 0:se.trim();g.reportSlots([],void 0,void 0,{[e]:[m(m({key:Me},U?{text:U}:{}),J?{skeleton:J}:{})]})},[Me,g,e,w]);let $t=K&&(u==null?void 0:u.edits)!==void 0&&(T==="preloaded"||T==="client");(0,N.useEffect)(()=>{var O;!$t||!(u!=null&&u.edits)||(O=g==null?void 0:g.reportDrift)==null||O.call(g,e,u.edits.fp,C,u.edits.fp===C?"unaddressable":"fp_mismatch")},[$t,e,C,g]);let $e=q===t;(0,N.useEffect)(()=>{var G;if(!(u!=null&&u.needsSkeleton)||!$e)return;let O=b();O&&((G=g==null?void 0:g.reportSkeleton)==null||G.call(g,e,O))},[u==null?void 0:u.needsSkeleton,$e,e,g,w]),(0,N.useEffect)(()=>{if(!$e)return;let O=Rn(e);if(!O)return;let G=b();An(O,G&&"status"in G?{status:G.status}:{skeleton:G})},[e,$e,w]),(0,N.useEffect)(()=>{!Mt||!F()||nr.has(e)||(nr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[Mt,e]);let ct=u!=null&&u.blocks?Object.keys(u.blocks).sort().join("|"):"";(0,N.useEffect)(()=>_e({id:e,arms:ct===""?void 0:ct.split("|")}),[e,ct]);let Bt=(0,N.useRef)(null);(0,N.useEffect)(()=>{!g||T==="none"||T==="seeded"||T==="override"||S===""||K||Bt.current!==S&&(Bt.current=S,pe(g,y,e,S))},[g,y,e,S,T,K]);let fe=T!=="none"&&T!=="seeded"&&!K,dt=fe?S:"",jt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,N.useEffect)(()=>{if(!g||!i||T==="override")return;let O=h.current;if(!O)return;let G=ge(i),J=ae(i),U=!1;return le(O,ee(i),{fireGoal:()=>{U||(U=!0,fe&&(J!==void 0?g.componentGoal(e,G,{value:J}):g.componentGoal(e,G)),g.goal(G,m({metadata:{componentId:e,arm:dt},weight:1,stepIndex:0},J!==void 0?{value:J}:{})))},fireStep:(se,je,gt)=>{fe&&g.componentGoal(e,se,{reward:je}),g.goal(se,{metadata:{componentId:e,arm:dt},weight:je,stepIndex:gt})}},G)},[g,e,jt,S,T,K,fe,dt,w]);let ft=(0,N.useMemo)(()=>i?ee(i):null,[jt]);(0,N.useEffect)(()=>{T==="override"||!g||!c||!ft||me(g,y,e,c,ft)},[g,y,e,c,ft,T]);let Ut=(0,N.useRef)(o);Ut.current=o;let Wt=(0,N.useRef)(new Set),Pr=o?JSON.stringify(o):"";(0,N.useEffect)(()=>{if(!g||T==="override"||!fe||S==="")return;let O=h.current;if(O)return(0,ke.attachMicroSignalDetectors)((G,J={})=>{var zt,qt,Yt;g.track({projectId:y,componentId:e,variantId:S,eventType:"micro_signal",payload:m({signalType:G},J)});let U=(zt=Ut.current)==null?void 0:zt[G];if(!U||Wt.current.has(G))return;Wt.current.add(G);let se=typeof U=="string"?U:U.name,je=typeof U=="string"?1:(qt=U.weight)!=null?qt:1,gt=typeof U=="string"?0:(Yt=U.stepIndex)!=null?Yt:0;g.goal(se,{metadata:m({componentId:e,arm:S,signalType:G},J),weight:je,stepIndex:gt})},O,Date.now())},[g,y,e,S,T,fe,Pr,w]);let Kt=(0,N.useRef)({agentData:x,agentDataByVariant:l});Kt.current={agentData:x,agentDataByVariant:l};let Jt=(0,N.useRef)(null);(0,N.useEffect)(()=>{var se;if(!g||T==="override"||!fe||S===""||Jt.current===S)return;let{agentData:O,agentDataByVariant:G}=Kt.current,J=oe!=null?oe:S,U=G!==void 0?Object.prototype.hasOwnProperty.call(G,J)?G[J]:void 0:O;U!==void 0&&(Jt.current=S,(se=g.reportAgentData)==null||se.call(g,e,S,U))},[g,e,S,fe,oe,T]);let Be=(0,N.useRef)(null);(0,N.useEffect)(()=>{let O=h.current;if(O){if(Be.current===null){Be.current=S;return}Be.current!==S&&(Be.current=S,(0,ke.reveal)(O))}},[S,w]);let Gr=(0,N.useMemo)(()=>m({"data-sentient-slot":e},S!==""?{"data-sentient-arm":S}:{}),[e,S]);return w?null:(0,ir.jsx)(f,L(m({ref:h,className:s},Gr),{children:q}))}var Re=require("react/jsx-runtime");function si(e){var p,l;let{client:t,variantId:n,content:r,ref:i}=et(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[s,f]=(0,de.useState)(!1);(0,de.useEffect)(()=>{f(!0)},[]);let a=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!s||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,o=c===null?r:null;return F()&&c===null&&o===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,Re.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:o})}var ai=(0,de.memo)(si,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function or(e){if(e.variants===void 0)return(0,Re.jsx)(Ie,m({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=De(n,["variants"]);return(0,Re.jsx)(Ie,L(m({},i),{children:t.children,variants:r}))}return(0,Re.jsx)(li,m({},t))}function li(e){var l;let[t,n]=(0,de.useState)(null),{id:r}=e,i=(0,de.useCallback)(()=>n(r),[r]),s=M(),f=ze().includes(r)||((l=s==null?void 0:s.isUnified)==null?void 0:l.call(s,r))===!0;if(t!==r&&!f)return(0,Re.jsx)(ai,L(m({},e),{onUnified:i}));let x=e,{variants:a,children:c}=x,o=De(x,["variants","children"]),p=Object.keys(a)[0];return(0,Re.jsx)(Ie,L(m({},o),{variants:a,variantsOnly:!0,children:p!==void 0?a[p]:null}))}var X=require("react");var ar=require("react/jsx-runtime");function sr({id:e,default:t,component:n="span",className:r,goal:i}){var E;let s=M(),f=ue(),a=qe(),c=Te(),o=(0,X.useRef)(null),p=(0,X.useRef)(null),l=(0,X.useSyncExternalStore)(Y,()=>ye(e),()=>null),[x,R]=(0,X.useState)(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.content)!=null?k:null}),[g,y]=(0,X.useState)(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.variantId)!=null?k:null});(0,X.useEffect)(()=>{if(l||!s)return;let b=s.getAssignment(e,c);if((b==null?void 0:b.content)!==void 0){y(b.variantId),R(b.content);return}let k=!1;return s.assign(e).then(A=>{if(!k){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&R(A.content)}}),()=>{k=!0}},[s,e,c,l]),(0,X.useEffect)(()=>{l||!s||!g||!f||o.current!==g&&(o.current=g,s.track({projectId:f,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[s,g,f,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,X.useMemo)(()=>i===void 0?null:ee(i),[h]),d=i===void 0?null:typeof i=="string"?i:v.type,w=(0,X.useRef)(!1);(0,X.useEffect)(()=>{w.current=!1},[g,h]),(0,X.useEffect)(()=>{if(l||!s||!g||!f||!v||!d)return;let b=p.current;if(!b)return;let k=ae(v);return le(b,v,{fireGoal:()=>{w.current||(w.current=!0,s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:d,payload:m({reward:1},k!==void 0?{goalValue:k}:{})}),s.goal(d,m({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(A,u,S)=>{s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:A,payload:{reward:u}}),s.goal(A,{metadata:{},weight:u,stepIndex:S})}})},[s,g,f,e,v,d,l]);let C=x!=null?x:t;if(l){let b=s==null?void 0:s.getAssignment(e,c);C=b&&b.variantId===l&&(E=b.content)!=null?E:t}return(0,ar.jsx)(n,{ref:b=>{p.current=b},className:r,children:C})}var st=require("react");function at(e){let t=M(),n=(0,st.useRef)(new Set);return(0,st.useCallback)((r,i)=>{var s,f;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,m(m(m({metadata:(s=i==null?void 0:i.metadata)!=null?s:{},weight:(f=i==null?void 0:i.reward)!=null?f: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 Ve=require("react");function lr(e,t={}){let c=t,{componentId:n}=c,r=De(c,["componentId"]),i=M(),s=at(n!=null?n:""),f=(0,Ve.useRef)(!1),a=(0,Ve.useRef)(r);a.current=r,(0,Ve.useEffect)(()=>{if(!i||f.current||i.gated)return;f.current=!0;let{metadata:o,reward:p,value:l,currency:x,externalId:R}=a.current;if(n){s(e,a.current);return}i.goal(e,m(m(m({metadata:o!=null?o:{},weight:p!=null?p:1,stepIndex:0},l!==void 0?{value:l}:{}),x!==void 0?{currency:x}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,s])}var ur=require("@sentientui/core"),cr=require("@sentientui/policy"),fr=require("react/jsx-runtime");function Dt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function ui(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Dt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Dt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Dt((0,cr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,ur.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function dr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,fr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:ui(e)}})}var ie=require("react"),yr=require("@sentientui/policy");var re=require("react"),Ae=require("@sentientui/core"),gr=require("@sentientui/policy");function lt(e,t){let n=M(),r=Ye(),[,i]=(0,re.useReducer)(l=>l+1,0),s=(0,re.useSyncExternalStore)(Y,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),f=s===void 0?r[e]:void 0,a=s===void 0&&f===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&s===void 0&&f===void 0&&a===null;(0,re.useEffect)(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(x=>{!l&&x&&i()}),()=>{l=!0}},[n,e,c]);let o=(()=>{if(s!==void 0)return{result:s,arm:(0,Ae.armOfResult)(s),source:"override"};if(f!==void 0)return{result:f,arm:(0,Ae.armOfResult)(f),source:"preloaded"};if(a!==null){let x=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ae.armOfResult)(a),source:x?"client":"seeded"}}let l=(0,Ae.baselineResultFor)(t);return{result:l,arm:(0,Ae.armOfResult)(l),source:"baseline"}})(),p=o.source==="preloaded"||o.source==="override";return(0,re.useEffect)(()=>{var x;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let l=(x=n.onSlotsChanged)==null?void 0:x.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),l==null||l()}},[n,e,p]),o}function ci(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function mr(){let e=M(),t=Dn();(0,re.useSyncExternalStore)(Y,ln,()=>0);let[n,r]=(0,re.useState)(!1);(0,re.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,gr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let s=ci();if(s)return i(s);if(t)return i(t);let f=e?e.getPersona():null;return f?i(f):null}var pr=new Set;function di(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function vr(e,t,n){let r=M(),i=ue(),s=JSON.stringify(t),f=(0,ie.useMemo)(()=>({id:e,dims:t}),[e,s]),{result:a,arm:c,source:o}=lt(e,f),p=(0,ie.useMemo)(()=>typeof a=="string"?{}:a,[c]);if(F()&&!pr.has(e)){pr.add(e);let y=(0,yr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,d])=>[v,[...d]]))}),h=Object.values(t).reduce((v,d)=>v*d.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,ie.useEffect)(()=>_e({id:e,dims:t}),[e]);let x=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||x.current===c||(x.current=c,pe(r,i,e,c))},[r,i,e,c,o]);let R=n==null?void 0:n.funnel;(0,ie.useEffect)(()=>{var y;!r||!R||o==="override"||me(r,i,e,R,ee((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,R,l,o]),(0,ie.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${di(e)}"]`);if(!y){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=ge(n.goal),v=ae(n.goal),d=!1;return le(y,ee(n.goal),{fireGoal:()=>{d||(d=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,m({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(w,C,P)=>{r.componentGoal(e,w,{reward:C}),r.goal(w,{metadata:{componentId:e,arm:c},weight:C,stepIndex:P})}},h)},[r,e,l,c,o]);let g=(0,ie.useMemo)(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(p))y[`data-${h}`]=v;return y},[e,p]);return{tokens:p,props:g}}var Ce=require("react");var Sr=new Set,hr=new Set;function br(e,t){var g,y;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:s,goalLabel:f,ref:a,nodeRef:c}=et(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(g=i!=null?i:r[0])!=null?g:"",p=t.variants[o],l=ze().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;(0,Ce.useEffect)(()=>{!l||!F()||hr.has(e)||(hr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),(0,Ce.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!c.current&&!Sr.has(e)&&(Sr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let x=(0,Ce.useCallback)((h,v)=>{var w,C;if(s)return;let d=h!=null?h:f;d&&(n==null||n.componentGoal(e,d,v),n==null||n.goal(d,m(m(m({metadata:(w=v==null?void 0:v.metadata)!=null?w:{},weight:(C=v==null?void 0:v.reward)!=null?C:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,f,s]),R=(0,Ce.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":o}),[a,e,o]);return{variant:o,value:p,bind:R,fireGoal:x}}var z=require("react");var xr=require("react/jsx-runtime"),ut=new Set;function wr(e){var v;let t=M(),n=ue(),r=(0,z.useRef)(null),i=Object.keys(e.arrangements).join(" "),s=(0,z.useMemo)(()=>Object.keys(e.arrangements),[i]),f=(0,z.useMemo)(()=>m({id:e.id,arms:s},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,s,e.baseline]),{arm:a,source:c}=lt(e.id,f);F()&&e.baseline!==void 0&&e.baseline!==s[0]&&!ut.has(e.id+":baseline")&&(ut.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${s[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=z.Children.toArray(e.children).filter(z.isValidElement),p=new Map;for(let d of o)p.set(String((v=d.key)!=null?v:"").replace(/^\.\$/,""),d);let l=e.arrangements[a],x=l!==void 0&&l.length===o.length&&l.every(d=>p.has(d));F()&&l!==void 0&&!x&&!ut.has(e.id+":keys")&&(ut.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let R=x?l.map(d=>p.get(d)):o;(0,z.useEffect)(()=>_e({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=(0,z.useRef)(null);(0,z.useEffect)(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||g.current===a||(g.current=a,pe(t,n,e.id,a))},[t,n,e.id,a,c]);let y=e.funnel;(0,z.useEffect)(()=>{var d;!t||!y||c==="override"||me(t,n,e.id,y,ee((d=e.goal)!=null?d:"click"))},[t,n,e.id,y,c]);let h=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,z.useEffect)(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let d=r.current;if(!d)return;let w=ge(e.goal),C=ae(e.goal),P=!1;return le(d,ee(e.goal),{fireGoal:()=>{P||(P=!0,C!==void 0?t.componentGoal(e.id,w,{value:C}):t.componentGoal(e.id,w),t.goal(w,m({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(E,b,k)=>{t.componentGoal(e.id,E,{reward:b}),t.goal(E,{metadata:{componentId:e.id,arm:a},weight:b,stepIndex:k})}},w)},[t,e.id,h,a,c]),(0,xr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:R})}var Lt=require("@sentientui/core");var fi=["page","blocks","layoutOrder"],kr=new Map;function Rr(e,t){kr.set(e,t)}function Ft(e){return kr.get(e)}function Ar(e){var i,s;let t=(s=(i=e.content)!=null?i:Ft(e.page))!=null?s:{},n={};for(let[f,a]of Object.entries(t))fi.includes(f)||(n[f]=a);let r=L(m({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Cr(e){return`<script type="application/ld+json">${Vt(e)}</script>`}function Vt(e){return JSON.stringify(m({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function _r(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
2
|
+
"use strict";var Tr=Object.create;var Ne=Object.defineProperty,Ir=Object.defineProperties,Nr=Object.getOwnPropertyDescriptor,Dr=Object.getOwnPropertyDescriptors,Lr=Object.getOwnPropertyNames,Ue=Object.getOwnPropertySymbols,Fr=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Zt=(e,t,n)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))mt.call(t,n)&&Zt(e,n,t[n]);if(Ue)for(var n of Ue(t))Qt.call(t,n)&&Zt(e,n,t[n]);return e},L=(e,t)=>Ir(e,Dr(t));var De=(e,t)=>{var n={};for(var r in e)mt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ue)for(var r of Ue(e))t.indexOf(r)<0&&Qt.call(e,r)&&(n[r]=e[r]);return n};var Vr=(e,t)=>{for(var n in t)Ne(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lr(t))!mt.call(e,i)&&i!==n&&Ne(e,i,{get:()=>t[i],enumerable:!(r=Nr(t,i))||r.enumerable});return e};var We=(e,t,n)=>(n=e!=null?Tr(Fr(e)):{},en(t||!e||!e.__esModule?Ne(n,"default",{value:e,enumerable:!0}):n,e)),Mr=e=>en(Ne({},"__esModule",{value:!0}),e);var gi={};Vr(gi,{Adaptive:()=>or,AdaptiveGroup:()=>wr,AdaptiveProvider:()=>Gn,AdaptiveSlot:()=>Ie,AdaptiveText:()=>sr,SentientPersonaScript:()=>dr,buildAgentFeed:()=>Ar,consentWatcher:()=>Er.consentWatcher,defineAgentContent:()=>Rr,detectSegment:()=>Lt.deriveSessionSegment,getAgentContent:()=>Ft,grantConsent:()=>Or.grantConsent,renderAgentJsonLd:()=>Cr,renderAgentJsonLdBody:()=>Vt,renderAgentMarkdown:()=>_r,renderBlocks:()=>we,renderCompose:()=>tt,useAdaptive:()=>br,useAdaptiveApiBaseUrl:()=>Mn,useAdaptiveGoal:()=>at,useAdaptivePersona:()=>mr,useAdaptiveTokens:()=>vr,useAssignment:()=>Qe,useInitialAssignments:()=>Xe,useLayoutOrder:()=>Nn,usePageGoal:()=>lr,useSentient:()=>M,useSessionSegment:()=>Te});module.exports=Mr(gi);var _=require("react"),He=require("@sentientui/core");var tn=new Map,Ke=new Map;function nn(e,t){let n=Ke.get(e);return n||(n=new Set,Ke.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Ke.delete(e)}}function rn(e,t){tn.set(e,t);let n=Ke.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function pt(e){var t;return(t=tn.get(e))!=null?t:null}var $r={on:!1,listeners:new Set};function on(){if(typeof window=="undefined")return $r;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function yt(){return on().on}function sn(e){let t=on().listeners;return t.add(e),()=>{t.delete(e)}}function an(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,s)=>e.assign(t,n,r,i,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var vt="sentient:overrides-changed";function ln(){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(vt))}function Y(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(vt,e),()=>window.removeEventListener(vt,e))}function un(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function ee(e){return typeof e=="string"?{type:"click"}:e}function ge(e){return typeof e=="string"?e:e.type}function ae(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ht=new Set,bt=!1;function cn(e){if(ht.has(e))return!0;if(ht.add(e),!bt){bt=!0;let t=()=>{bt=!1,ht.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function dn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Br(r))return!0;r=r.parentElement}return!1}function le(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,p=[];return t.steps.forEach(({goal:l,name:x,weight:R},g)=>{let y=(h=!1)=>{o.has(g)||h&&r!==void 0&&cn(`step\0${x}\0${R}\0${g}`)||(o.add(g),n.fireStep(x,R,g))};if(l.type==="click"){let h=v=>{let d=v.target;d instanceof Element&&dn(d,e,l.selector)&&y()};e.addEventListener("click",h),p.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),p.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),v=new IntersectionObserver(d=>{for(let w of d)if(w.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let l of p)l()}}let i=t.type==="composite"?t.all:[t],s=new Set(i.map((o,p)=>p)),f=()=>{r!==void 0&&cn(r)||n.fireGoal()},a=(o,p=!1)=>{s.delete(o),s.size===0&&(p?f():n.fireGoal())},c=[];return i.forEach((o,p)=>{if(o.type==="click"){let l=x=>{let R=x.target;R instanceof Element&&dn(R,e,o.selector)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(o.type==="form_submit"){let l=x=>{x.target instanceof HTMLFormElement&&e.contains(x.target)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(o.type==="scroll_depth"){let l=Math.max(0,Math.min(1,o.threshold)),x=new IntersectionObserver(R=>{for(let g of R)if(g.intersectionRatio>=l){t.type==="composite"?a(p,!0):f(),x.disconnect();break}},{threshold:[l]});x.observe(e),c.push(()=>x.disconnect());return}}),()=>{for(let o of c)o()}}var fn=new Set,gn=new Set;function me(e,t,n,r,i){let s=`${r}|${n}`;if(gn.has(s))return;gn.add(s);let f=i.type==="weighted_composite"&&!fn.has(r);f&&fn.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:f?{funnelId:r,steps:i.steps.map(a=>({goalId:a.name,weight:a.weight}))}:{funnelId:r}})}function pe(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var jr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function Se(){if(typeof window=="undefined")return jr;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 Le(){Se().version+=1;for(let e of Se().listeners)e()}var mn=()=>{};function pn(e){return F()?(Se().components.set(e.id,e),Le(),()=>{Se().components.delete(e.id),Le()}):mn}function _e(e){return F()?(Se().slots.set(e.id,e),Le(),()=>{Se().slots.delete(e.id),Le()}):mn}function wt(e){F()&&(Se().sections=[...e],Le())}var yn="0.40.1",xt=yn!=="0.0.0-dev"?{name:"react",version:yn}:void 0;function Ur(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Oe(e,t){Ur()[e]=t}function vn(e){window.__sentient_vocabulary_override=e}function Sn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Wr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Ee(e,t){Wr()[e]=t}function hn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let s=n.slice(0,r.index)+i;history.replaceState(history.state,"",s?"#"+s:location.pathname+location.search)}}catch(n){}return t}var Rt="__snt_editor_token",Pe=null,kt=!1;function bn(){return kt}function Kr(){try{return sessionStorage.getItem(Rt)}catch(e){return null}}function Je(e){if(Pe)return Pe;let t=typeof window=="undefined"?null:hn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Kr();return kt=!!n,Pe=Promise.resolve(n?{token:n,fresh:!1}:null),Pe}return kt=!0,Pe=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(Rt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Pe}function wn(){try{sessionStorage.removeItem(Rt)}catch(e){}}var xn="sentient_preview_cell",kn="sentient_refresh_region",At="sentient-cell-preview-bar",he="__preview__",Ge=null;function Rn(e){if((Ge==null?void 0:Ge.slotId)!==e)return null;let t=Ge;return Ge=null,t}function An(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(m({slotId:e.slotId},t))})}).then(n=>be(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>be("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Cn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(At))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(xn),n=c.get(kn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Je(r);if(!bn())return;if(n){Ge={slotId:n,session:i,base:r},Oe(n,{kind:"arms"}),Ee(n,he),St();return}if(!t)return;let s=t.lastIndexOf("~");if(s<=0)return;let f=t.slice(0,s),a=t.slice(s+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(be(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){be(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let o=await c.json();if(o.vocabulary&&Array.isArray(o.vocabulary.entries)&&vn(o.vocabulary),o.compose!=null)Oe(f,{kind:"arms",compose:{[he]:o.compose}}),Ee(f,he);else if(o.edits!=null&&typeof o.skeletonFp=="string"&&Array.isArray(o.leafToNode))Oe(f,{kind:"arms",edits:{edits:o.edits,fp:o.skeletonFp,leafToNode:o.leafToNode}}),Ee(f,he);else if(o.blocks!=null)Oe(f,{kind:"arms",blocks:{[he]:o.blocks}}),Ee(f,he);else if(o.content!=null)Oe(f,{kind:"arms",content:o.content}),Ee(f,he);else{be("Nothing to preview in that square yet.");return}St(),be(`Previewing \u201C${o.slotName}\u201D for ${o.personaDisplay}${o.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${f}"]`))==null||p.scrollIntoView({block:"center"})}catch(l){}},300)}).catch(()=>be("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function be(e){var i;if(document.getElementById(At))return;let t=document.createElement("div");t.id=At,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{wn();let s=new URL(window.location.href);s.searchParams.delete(xn),s.searchParams.delete(kn),window.location.assign(s.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var _n=!1;function On(e){if(_n||typeof window=="undefined")return;_n=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Je(t).then(n=>{!n||!("token"in n)||!n.fresh||Jr(t,n.token)})}function Jr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var $n=require("react/jsx-runtime");function Hr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,He.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Pn="https://api.sentient-ui.com/v1",H=(0,_.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Pn,debug:!1}),En=!1,Ct=new Set;function Xr(e,t,n){let r=(0,_.useRef)(n);r.current=n;let[i,s]=(0,_.useState)(null),[f,a]=(0,_.useState)(!1),c=(0,_.useRef)(e);c.current=e;let o=e===void 0?"":typeof e=="string"?e:JSON.stringify(L(m({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,_.useEffect)(()=>{let p=c.current;if(p===void 0||typeof window=="undefined")return;let l,x=!1;return import("@sentientui/core/consent").then(({consentWatcher:R,forgetVisitor:g})=>{if(x)return;let y=R(typeof p=="object"&&p.cmp===void 0&&p.check?m(L(m({},p),{check:()=>c.current.check()}),p.refused?{refused:()=>{var d,w;return((w=(d=c.current).refused)==null?void 0:w.call(d))===!0}}:{}):p),h=!1,v=()=>{let d=y.refused()&&y.read()!==!0;d&&!h&&(g(t),r.current()),h=d,a(d);let w=y.read();w!==null&&Ct.add(t),s(w!=null?w:Ct.has(t)?!1:null)};v(),l=y.subscribe(v)}),()=>{x=!0,l==null||l()}},[o,t]),{granted:i,refused:f}}function Gn(e){var C,P,E;let[t,n]=(0,_.useState)(null),[r]=(0,_.useState)(()=>{var b;return(b=e.sessionSegment)!=null?b:Hr()}),[i,s]=(0,_.useState)(yt());(0,_.useEffect)(()=>sn(()=>s(yt())),[]),(0,_.useEffect)(()=>{Cn(e.apiBaseUrl),On(e.apiBaseUrl)},[]);let f=(0,_.useRef)(()=>{}),a=Xr(e.consentFrom,e.apiKey,()=>f.current()),c=e.consentFrom?(C=a.granted)!=null?C:Ct.has(e.apiKey)?!1:e.consent===!0:e.consent,o=e.consentFrom?a.refused:!0,p=(0,_.useRef)(o);p.current=o;let l=(0,_.useRef)(null),x=(0,_.useRef)(!1),R=(0,_.useRef)([]),g=(0,_.useRef)(!1);f.current=()=>{var k;R.current=[],g.current=!0;let b=l.current;b!=null&&b.gated?b.dispose():(k=b==null?void 0:b.takeHeld)==null||k.call(b)},(0,_.useEffect)(()=>{var j,Q;if(p.current&&c===!1&&(R.current=[]),c===!1&&x.current&&(p.current&&((j=l.current)==null||j.destroy()),l.current=null,x.current=!1),c===!1&&!e.preConsentBehavior){p.current&&((Q=l.current)==null||Q.destroy()),l.current=null,n(null);return}let b=c!==!1;b&&(g.current=!1);let k=$=>{!b&&g.current&&$.gated&&$.dispose()},A=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},xt?{sdk:xt}:{}),u=!1,S=null,D=null,I=$=>{for(let W of R.current.splice(0))setTimeout(()=>{if(l.current!==$){g.current||R.current.push(W);return}try{W($)}catch(q){}},0)},T=$=>{e.engagement===!1||!b||import("@sentientui/core/engagement").then(({startEngagementCapture:W})=>{u||(D=W($,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:$})=>{u||(S=$(L(m({},A),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),k(S),l.current=S,x.current=b,I(S),n(S),T(S))}):(S=(0,He.init)(A),k(S),l.current=S,x.current=b,I(S),n(S),T(S)),()=>{var $,W;u=!0,D==null||D(),R.current=R.current.concat((W=($=S==null?void 0:S.takeHeld)==null?void 0:$.call(S))!=null?W:[]),S==null||S.dispose()}},[c]),(0,_.useEffect)(()=>{if(!t)return;let b=!1,k=async()=>{if(b)return;let u;try{u=await t.fetchWeights()}catch(S){return}if(!b)for(let S of u){let D={componentId:S.componentId,updatedAt:S.updatedAt,variants:S.variants.map(I=>{var T;return{variantId:I.variantId,pulls:I.pulls,avgReward:(T=I.avgReward)!=null?T:0}})};rn(S.componentId,D)}};k();let A=setInterval(()=>{k()},6e4);return()=>{b=!0,clearInterval(A)}},[t]);let y=(P=e.ssrFallback)!=null?P:"first",h=((E=e.apiBaseUrl)!=null?E:Pn).replace(/\/$/,""),v=(0,_.useRef)(null);(0,_.useEffect)(()=>{var A;if(typeof process!="undefined"&&((A=process.env)==null?void 0:A.NODE_ENV)==="production")return;let b={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},k=v.current;if(v.current=b,k!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(k[u],b[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),(0,_.useEffect)(()=>{var b;typeof process!="undefined"&&((b=process.env)==null?void 0:b.NODE_ENV)==="production"||un({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]),(0,_.useEffect)(()=>{let b=e.initialLayoutOrder;if(b&&b.length>0){wt(b);return}e.declaredSections&&e.declaredSections.length>0&&wt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,_.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||En||(En=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,_.useEffect)(()=>{if(!F())return;let b=e.declaredSections;if(!b||b.length===0||typeof document=="undefined")return;let k=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),A=b.filter(u=>!k.has(u));A.length>0&&console.warn(`[SentientUI] Declared section${A.length>1?"s":""} ${A.map(u=>`"${u}"`).join(", ")} ${A.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let d=(0,_.useMemo)(()=>t&&i?an(t):t,[t,i]),w=(0,_.useMemo)(()=>{var b,k,A,u,S,D,I,T,j;return{client:d,apiKey:e.apiKey,initialAssignments:(b=e.initialAssignments)!=null?b:{},initialUnified:(k=e.initialUnified)!=null?k:zr,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(A=e.initialLayoutOrder)!=null?A:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(D=e.initialPalette)!=null?D:null,initialVocabulary:(I=e.initialVocabulary)!=null?I:null,initialPersona:(T=e.initialPersona)!=null?T:null,apiBaseUrl:h,debug:(j=e.debug)!=null?j:!1}},[d,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,$n.jsx)(H.Provider,{value:w,children:e.children})}function M(){return(0,_.useContext)(H).client}function ue(){return(0,_.useContext)(H).apiKey}function Xe(){return(0,_.useContext)(H).initialAssignments}var zr=[];function ze(){return(0,_.useContext)(H).initialUnified}function Te(){return(0,_.useContext)(H).sessionSegment}function Tn(){return(0,_.useContext)(H).ssrFallback}function qe(){return(0,_.useContext)(H).onAssignment}function In(){return(0,_.useContext)(H).debug}function Nn(){let e=(0,_.useContext)(H).initialLayoutOrder,t=(0,_.useSyncExternalStore)(Y,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ye(){return(0,_.useContext)(H).initialSlots}function Dn(){return(0,_.useContext)(H).initialPersona}function Ln(){return(0,_.useContext)(H).initialSlotConfig}function Fn(){return(0,_.useContext)(H).initialPalette}function Vn(){return(0,_.useContext)(H).initialVocabulary}function Mn(){return(0,_.useContext)(H).apiBaseUrl}var de=require("react");var B=require("react"),Bn=require("@sentientui/core");var ne=require("react"),Ze=require("@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 s=i.indexOf(":");if(s!==-1&&i.slice(0,s)===e)return i.slice(s+1)}}catch(r){}return null}function Qe(e,t,n,r,i){let s=Xe(),f=Tn(),a=M(),c=Te(),o=qe(),p=In(),l=(0,ne.useRef)(null),x=(0,ne.useSyncExternalStore)(Y,()=>ye(e),()=>null),R=x&&t.includes(x)?x:null,g=(0,ne.useRef)(null);(0,ne.useEffect)(()=>{p&&R&&g.current!==R&&(g.current=R,console.info(`[sentient] override active: ${e} -> ${R}`))},[p,R,e]);let[y,h]=(0,ne.useState)(()=>{var C,P;if(R)return{variantId:R,content:null,isLoading:!1,settled:!0};if(!a){let E=s[e];return E&&t.includes(E)?{variantId:E,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content))return{variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0};let w=pt(e);if(w){let E=(0,Ze.pickFromWeights)(w.variants,t);if(E)return{variantId:E,content:null,isLoading:!1,settled:!0}}return{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}}),v=d=>{o&&l.current!==d&&(l.current=d,o(e,d))};return(0,ne.useEffect)(()=>{var C;if(R||!a)return;let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content)){h({variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0}),v(d.variantId);return}let w=pt(e);if(w&&y.settled&&y.variantId&&y.variantId===(0,Ze.pickFromWeights)(w.variants,t)){v(y.variantId);return}h(P=>{var E;return P.variantId?P:{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}})},[R,a,e,c]),(0,ne.useEffect)(()=>{if(R||!a)return;let d=a.getAssignment(e,c);if(d&&t.includes(d.variantId))return;let w=!1,C=i==null?void 0:i.onUnified;return(C?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(E=>{var b;if(!w&&E){if(E.unified===!0){C==null||C();return}!t.includes(E.variantId)&&!E.content||(h({variantId:E.variantId,content:(b=E.content)!=null?b:null,isLoading:!1,settled:!0}),v(E.variantId))}}),()=>{w=!0}},[R,a,e,c]),(0,ne.useEffect)(()=>{if(!R&&a)return nn(e,d=>{var P;let w=a.getAssignment(e,c);if(w&&(t.includes(w.variantId)||w.content)){h({variantId:w.variantId,content:(P=w.content)!=null?P:null,isLoading:!1,settled:!0}),v(w.variantId);return}let C=(0,Ze.pickFromWeights)(d.variants,t);C&&(h({variantId:C,content:null,isLoading:!1,settled:!0}),v(C))})},[R,a,e,c]),R?{variantId:R,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function et(e,t,n){let r=M(),i=ue(),s=Object.keys(t).join("\0"),f=(0,B.useMemo)(()=>Object.keys(t),[s]),{variantId:a,content:c,isOverride:o=!1,settled:p}=Qe(e,f,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,x]=(0,B.useState)(null),R=(0,B.useRef)(null),g=(0,B.useCallback)(u=>{R.current=u,x(u)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=(0,B.useMemo)(()=>y?ee(y):null,[h]),d=y?ge(y):"";(0,B.useEffect)(()=>pn({id:e,variantIds:f,goal:d}),[e,f,d]);let w=(0,B.useRef)(null);(0,B.useEffect)(()=>{o||p&&(!r||!a||!i||!l||w.current!==a&&(w.current=a,pe(r,i,e,a)))},[r,a,i,e,l,o,p]);let C=(0,B.useRef)(!1),P=(0,B.useRef)(new Set);(0,B.useEffect)(()=>{C.current=!1,P.current=new Set},[a,v]);let E=n.funnel;(0,B.useEffect)(()=>{o||!p||!r||!E||!v||me(r,i,e,E,v)},[r,i,e,E,v,o,p]);let b=n.cursorSignal===!0;(0,B.useEffect)(()=>{if(!b||o||!p||!r||!a||!l)return;let u=null,S=0,D=()=>{S=Date.now(),u=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-S}}),u=null},800)},I=()=>{u!==null&&(clearTimeout(u),u=null)};return l.addEventListener("mouseenter",D),l.addEventListener("mouseleave",I),()=>{l.removeEventListener("mouseenter",D),l.removeEventListener("mouseleave",I),u!==null&&clearTimeout(u)}},[b,r,a,i,e,l,o,p]);let k=(0,B.useRef)(n.microSignalGoals);k.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,B.useEffect)(()=>{if(o||!p||!r||!a||!l)return;let u=Date.now();return(0,Bn.attachMicroSignalDetectors)((S,D={})=>{var $,W,q;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:m({signalType:S},D)});let I=($=k.current)==null?void 0:$[S];if(!I||P.current.has(S))return;P.current.add(S);let T=typeof I=="string"?I:I.name,j=typeof I=="string"?1:(W=I.weight)!=null?W:1,Q=typeof I=="string"?0:(q=I.stepIndex)!=null?q:0;r.goal(T,{metadata:m({signalType:S},D),weight:j,stepIndex:Q})},l,u)},[r,a,i,e,l,A,o,p]),(0,B.useEffect)(()=>{if(o||!p||!r||!a||!l||!v)return;let u=ae(v);return le(l,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:d,payload:m({reward:1},u!==void 0?{goalValue:u}:{})}),r.goal(d,m({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},u!==void 0?{value:u}:{})))},fireStep:(S,D,I)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:S,payload:{reward:D}}),r.goal(S,{metadata:{},weight:D,stepIndex:I})}},d)},[r,a,i,e,l,v,d,o,p]),{client:r,variantIds:f,variantId:a,content:c,settled:p,isOverride:o,goalLabel:d,ref:g,nodeRef:R}}var N=require("react"),ke=require("@sentientui/core"),Nt=require("@sentientui/core/region");var Z=require("react"),Un=require("@sentientui/core");var jn=new Set,qr={kind:"arms"};function Wn(e,t){var P,E,b;let n=M(),r=(0,Z.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,Z.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let s=(0,Z.useRef)(t==null?void 0:t.skeleton);s.current=t==null?void 0:t.skeleton;let f=Ye(),a=Ln(),c=Fn(),o=Vn(),p=(0,Z.useSyncExternalStore)(Y,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_config_overrides)==null?void 0:k[e]:void 0},()=>{}),l=(0,Z.useSyncExternalStore)(Y,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_overrides)==null?void 0:k[e]:void 0},()=>{}),x=k=>k==null?"":(0,Un.armOfResult)(k),R=(0,Z.useCallback)(k=>{var A,u;return(u=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,k))!=null?u:(()=>{})},[n]);(0,Z.useSyncExternalStore)(R,()=>{var k;return(k=n==null?void 0:n.getSlotConfig(e))!=null?k:null},()=>null),(0,Z.useSyncExternalStore)(R,()=>x(n==null?void 0:n.getSlotResult(e)),()=>"");let g=p===void 0?a[e]:void 0,y=p===void 0&&g===void 0&&n?n.getSlotConfig(e):null,h=(P=c!=null?c:n==null?void 0:n.getSitePalette())!=null?P:null,v=(b=o!=null?o:(E=n==null?void 0:n.getStyleVocabulary)==null?void 0:E.call(n))!=null?b:null,d=(()=>{var k,A,u;if(p!==void 0)return{config:p,arm:x(l),palette:h,vocabulary:(k=Sn())!=null?k:v,source:"override"};if(t!=null&&t.forcedArm)return{config:qr,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(g!==void 0)return{config:g,arm:x((A=f[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let S=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:x((u=n==null?void 0:n.getSlotResult(e))!=null?u:f[e]),palette:h,vocabulary:v,source:S?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),w=(t==null?void 0:t.defer)===!0,C=d.source==="preloaded"||d.source==="override";return(0,Z.useEffect)(()=>{var j,Q,$,W,q;if(!n||n.isLocal===!0||C||w)return;let k=d.source==="none",A=k&&(Q=(j=r.current)==null?void 0:j.call(r))!=null?Q:null,u=A!=null&&A!==""?{[e]:A}:void 0,S=($=i.current)==null?void 0:$.call(i),D=k&&(q=(W=s.current)==null?void 0:W.call(s))!=null?q:null,I=m(m({},S?{render:{[e]:S}}:{}),D?{skeletons:{[e]:D}}:{}),T=Object.keys(I).length>0;return n.requestSlots?T?n.requestSlots([e],u,I):u?n.requestSlots([e],u):n.requestSlots([e]):k&&(D?n.reportSlots([e],u!=null?u:{},{[e]:D}):u?n.reportSlots([e],u):n.reportSlots([e])),()=>{var K;return(K=n.cancelSlots)==null?void 0:K.call(n,[e])}},[n,C,d.source,e,w]),(0,Z.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||d.source!=="none"||jn.has(e)||(jn.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,d.source,e]),d}var Fe=require("react");var V=require("react/jsx-runtime");function _t(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ve={none:"0",sm:"8px",md:"16px",lg:"24px"},Ot={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Xn={sm:"0.875em",md:"1em",lg:"1.25em"},Yr={sm:"1.25em",md:"1.5em",lg:"2em"},Kn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Jn={sm:"8px",md:"16px",lg:"32px"},Zr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Qr={normal:"400",medium:"500",bold:"700"};function Hn(e,t){return m(m({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?m({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function zn(e,t,n){var i,s,f,a;let r=t==null?void 0:t.accent;return L(m({display:"inline-block",padding:(i=Kn[n!=null?n:"md"])!=null?i:Kn.md,borderRadius:(s=t==null?void 0:t.radius)!=null?s:"8px",font:"inherit"},n?{fontSize:Xn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(f=t==null?void 0:t.primaryBg)!=null?f:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ei({node:e,opts:t}){var i,s,f,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(f=(s=t.palette)==null?void 0:s.border)!=null?f:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return(0,V.jsxs)("form",{onSubmit:o=>{var x,R,g;o.preventDefault();let p=new FormData(o.currentTarget),l={};for(let y of e.fields)l[y.name]=String((x=p.get(y.name))!=null?x:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,l)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var p,l;return(0,V.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?(0,V.jsx)("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?(0,V.jsx)("select",{name:o.name,required:o.required,style:r,children:((p=o.options)!=null?p:[]).map(x=>(0,V.jsx)("option",{value:x,children:x},x))}):(0,V.jsx)("input",{name:o.name,type:(l=o.inputType)!=null?l:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),(0,V.jsx)("button",{type:"submit",style:zn(n,t.palette),children:e.submitLabel})]})}function ti(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(s=>s.id===n))==null?void 0:i.classes:void 0}function qn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function we(e,t){var i;let n=ni(e,t),r=qn(e.like,t);return n&&r?(0,Fe.cloneElement)(n,{style:L(m({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ni(e,t){var n,r,i,s,f,a,c,o,p,l,x,R,g,y,h,v,d,w,C,P,E,b,k;try{let A=ti(e,t);switch(e.type){case"stack":{let u=(r=ve[(n=e.gap)!=null?n:"md"])!=null?r:ve.md,S=e.surface==="raised"&&!A,D=(i=e.pad)!=null?i:S?"md":void 0;return(0,V.jsx)("div",L(m({},A?{className:A}:{}),{style:m(m(m(m(m({display:"flex",flexDirection:e.direction,gap:u},e.align?{alignItems:Ot[e.align]}:{}),e.justify?{justifyContent:Ot[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),D?{padding:(s=ve[D])!=null?s:ve.md}:{}),S?L(m(m({},(f=t.palette)!=null&&f.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(o=t.palette)==null?void 0:o.border)!=null?p:"currentColor"}`,borderRadius:(x=(l=t.palette)==null?void 0:l.radius)!=null?x:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((I,T)=>{let j=we(I,t);return j===null?null:(0,V.jsx)(Fe.Fragment,{children:j},T)})}))}case"grid":{let u=(y=ve[(g=e.gap)!=null?g:"md"])!=null?y:ve.md;return(0,V.jsx)("div",L(m({},A?{className:A}:{}),{style:m(m({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${u}) / ${e.columns})), 1fr))`,gap:u},e.align?{alignItems:Ot[e.align]}:{}),e.pad?{padding:(h=ve[e.pad])!=null?h:ve.md}:{}),children:((v=e.children)!=null?v:[]).map((S,D)=>{let I=we(S,t);return I===null?null:(0,V.jsx)(Fe.Fragment,{children:I},D)})}))}case"text":return A?(0,V.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,V.jsx)("p",{style:m(m(m(m(m({margin:0},e.size?{fontSize:Xn[e.size]}:{}),e.weight?{fontWeight:Qr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Hn(e.tone,t.palette)),children:e.value});case"heading":{let u=`h${e.level}`;return A?(0,V.jsx)(u,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,V.jsx)(u,{style:m(m({margin:0,fontSize:Yr[(d=e.size)!=null?d:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let u=(w=e.emphasis)!=null?w:"primary";return(0,V.jsx)("a",L(m(m({href:_t(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:zn(u,t.palette,e.size)}),{children:e.label}))}case"link":return(0,V.jsx)("a",L(m(m({href:_t(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,V.jsx)("img",L(m({src:_t(e.src),alt:e.alt},A?{className:A}:{}),{style:m(m({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Zr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,V.jsx)("span",{className:A,children:e.value}):(0,V.jsx)("span",{style:m({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(P=(C=t.palette)==null?void 0:C.border)!=null?P:"currentColor"}`},Hn(e.tone,t.palette)),children:e.value});case"spacer":return(0,V.jsx)("div",{style:{height:(E=Jn[e.size])!=null?E:Jn.md}});case"divider":return(0,V.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,V.jsx)(ei,{node:e,opts:t});default:return null}}catch(A){return null}}function tt(e,t){var s,f,a,c;let n=we(e.tree,t);if(n===null)return null;let r=(s=e.surface)!=null&&s.like?(a=(f=t.vocabulary)==null?void 0:f.entries.find(o=>o.id===e.surface.like))==null?void 0:a.classes:void 0,i=qn((c=e.surface)==null?void 0:c.like,t);return r?(0,V.jsx)("div",L(m({className:r},i?{style:{color:i}}:{}),{children:n})):n}var ce=require("react"),nt=require("@sentientui/core/region");function rt(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function it(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function xe(e){return rt(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+xe(n),0):(0,ce.isValidElement)(e)?xe(it(e)):0}function ri(e,t){return Array.isArray(t)?(0,ce.cloneElement)(e,void 0,...t):(0,ce.cloneElement)(e,void 0,t)}function Et(e,t){if(rt(e))return t;if(Array.isArray(e))return e.map(n=>Et(n,t));if((0,ce.isValidElement)(e)){let n=it(e);return xe(n)===0?e:ri(e,Et(n,t))}return e}function Yn(e,t){return xe(e)===1?Et(e,t):null}var te=e=>e.join("/");function Pt(e,t,n){if(rt(e)){n.leafPaths.push(t),n.texts.push((0,nt.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Pt(r,[...t,i],n));return}(0,ce.isValidElement)(e)&&(n.elements.set(te(t),e),Pt(it(e),[...t,"c"],n))}function Tt(e){let t={leafPaths:[],texts:[],elements:new Map};return Pt(e,[],t),t}function ii(e){return Tt(e).texts}function Zn(e){let t=ii(e);return t.length===0?null:(0,nt.skeletonFingerprint)(t)}function oi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Qn(e,t){let n=t.reduce((i,s)=>Math.max(i,s+1),0),r=[];for(let i=0;i<n;i++){let s=t.flatMap((a,c)=>a===i?[oi(e.leafPaths[c])]:[]);if(s.length===0){r.push(null);continue}let f=s[0];for(let a of s.slice(1)){let c=new Set(a.map(te));f=f.filter(o=>c.has(te(o)))}r.push(f.length>0?f[f.length-1]:null)}return r}function Gt(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 It(e,t){let n=Tt(t);if(n.texts.length!==e.leaves.length||n.texts.some((s,f)=>s!==e.leaves[f]))return null;let r=Qn(n,e.leafToNode),i=e.nodes.map((s,f)=>{let a=r[f],c=a?n.elements.get(te(a)):void 0,o=!!c&&(typeof c.type=="string"||Gt(c)!==void 0);return L(m({},s),{restylable:o})});return L(m({},e),{nodes:i})}function er(e,t,n){var g;let r=Tt(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let s=Qn(r,n),f=new Map;n.forEach((y,h)=>{f.has(y)||f.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[te(y),h])),c=new Set,o=new Map,p=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),d=s[v];if(h.hidden&&(d?c.add(te(d)):p=!0),h.like!==void 0){let w=s[h.like],C=d?r.elements.get(te(d)):void 0,P=w?Gt(r.elements.get(te(w))):void 0;!d||P===void 0||Gt(C)===void 0?p=!0:o.set(te(d),P)}}let l=new Map(Object.entries((g=t.order)!=null?g:{})),x=(y,h)=>{var v;if(rt(y)){let d=a.get(te(h));if(d===void 0)return y;let w=n[d],C=(v=t.nodes[String(w)])==null?void 0:v.text;return C===void 0?y:f.get(w)===d?C:""}if(Array.isArray(y)){let d=y.map((w,C)=>x(w,[...h,C]));for(let[w,C]of l){let P=C.map(k=>{let A=s[k];return!A||A.length!==h.length+1||te(A.slice(0,-1))!==te(h)?-1:A[A.length-1]});if(P.some(k=>k<0))continue;let E=[...P].sort((k,A)=>k-A),b=[...d];E.forEach((k,A)=>{d[k]=b[P[A]]}),l.delete(w)}return d}if((0,ce.isValidElement)(y)){let d=te(h);if(c.has(d))return null;let w=it(y);if(xe(w)===0)return y;let C=x(w,[...h,"c"]),P=o.get(d),E=P!==void 0?{className:P}:void 0;return Array.isArray(C)?(0,ce.cloneElement)(y,E,...C):(0,ce.cloneElement)(y,E,C)}return y},R=x(e,[]);return p||l.size>0?null:R}var ir=require("react/jsx-runtime"),tr=new Set,nr=new Set,rr=new Set,ot="authored.";function Ie({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:s,as:f="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:o,clientOnly:p,agentDataByVariant:l,agentData:x,variantsOnly:R=!1}){var Ht,Xt;let g=M(),y=ue(),h=(0,N.useRef)(null),[v,d]=(0,N.useState)(!1);(0,N.useEffect)(()=>{d(!0)},[]);let w=p===!0&&(!v||!g),C=(0,N.useMemo)(()=>Zn(t),[t]),P=n?Object.keys(n).join("|"):"",E=(0,N.useMemo)(()=>m({fp:C!=null?C:"0000000000000000",forms:!!r,compose:!0,content:xe(t)===1,ops:!1},P!==""?{authored:P.split("|"),children:!R}:{}),[C,t,r,P,R]),b=()=>{var J;let O=h.current;if(!O||!a)return null;let G=(0,Nt.captureRegionSkeleton)(O);return G.skeleton?(J=It(G.skeleton,t))!=null?J:L(m({},G.skeleton),{editable:!1,nodes:G.skeleton.nodes.map(U=>L(m({},U),{restylable:!1}))}):{status:G.reason}},k=(0,N.useSyncExternalStore)(Y,()=>n?ye(e):null,()=>null),A=k===null||!n?null:Object.prototype.hasOwnProperty.call(n,k)?`${ot}${k}`:R?`${ot}${Object.keys(n)[0]}`:"baseline",{config:u,arm:S,palette:D,vocabulary:I,source:T}=Wn(e,{forcedArm:A,baselineText:a?()=>{var O,G;return(G=(O=h.current)==null?void 0:O.textContent)!=null?G:null}:void 0,render:()=>E,skeleton:b,defer:w}),j=S!==""?(Ht=u==null?void 0:u.blocks)==null?void 0:Ht[S]:void 0,Q=S!==""?(Xt=u==null?void 0:u.compose)==null?void 0:Xt[S]:void 0,$=(j!==void 0&&(0,ke.containsFormBlock)(j)||Q!==void 0&&(0,ke.containsFormBlock)(Q.tree))&&!r;(0,N.useEffect)(()=>{!$||!F()||tr.has(e)||(tr.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[$,e]);let W=O=>{!g||T==="override"||(T!=="seeded"&&g.componentGoal(e,O),g.goal(O,{metadata:{componentId:e,arm:S},weight:1,stepIndex:0}))},q=t,K=!1,oe=S.startsWith(ot)?S.slice(ot.length):null;if((u==null?void 0:u.blocked)==="variant_history")K=!0;else if(oe!==null)n&&Object.prototype.hasOwnProperty.call(n,oe)?q=n[oe]:K=!0;else if(Q!==void 0){let O=$?null:tt(Q,{palette:D,vocabulary:I,onFormSubmit:r,onFormGoal:W});O===null?K=!0:q=O}else if(j!==void 0){let O=$?null:we(j,{palette:D,vocabulary:I,onFormSubmit:r,onFormGoal:W});O===null?K=!0:q=O}else if((u==null?void 0:u.edits)!==void 0&&T!=="none"){let O=u.edits,G=O.fp===C?er(t,O.edits,O.leafToNode):null;G===null?K=!0:q=G}else if((u==null?void 0:u.content)!==void 0&&T!=="none"){let O=Yn(t,u.content);O===null?K=!0:q=O}let Mt=K&&j===void 0&&Q===void 0&&(u==null?void 0:u.edits)===void 0&&oe===null&&(u==null?void 0:u.blocked)===void 0;(0,N.useEffect)(()=>{(u==null?void 0:u.blocked)!=="variant_history"||!F()||rr.has(e)||(rr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[u==null?void 0:u.blocked,e]);let Me=oe!==null&&!K?oe:null;(0,N.useEffect)(()=>{var se;if(!Me||!a||!g)return;let O=h.current;if(!O)return;let G=(0,Nt.captureRegionSkeleton)(O),J=G.skeleton?It(G.skeleton,n==null?void 0:n[Me]):null,U=(se=O.textContent)==null?void 0:se.trim();g.reportSlots([],void 0,void 0,{[e]:[m(m({key:Me},U?{text:U}:{}),J?{skeleton:J}:{})]})},[Me,g,e,w]);let $t=K&&(u==null?void 0:u.edits)!==void 0&&(T==="preloaded"||T==="client");(0,N.useEffect)(()=>{var O;!$t||!(u!=null&&u.edits)||(O=g==null?void 0:g.reportDrift)==null||O.call(g,e,u.edits.fp,C,u.edits.fp===C?"unaddressable":"fp_mismatch")},[$t,e,C,g]);let $e=q===t;(0,N.useEffect)(()=>{var G;if(!(u!=null&&u.needsSkeleton)||!$e)return;let O=b();O&&((G=g==null?void 0:g.reportSkeleton)==null||G.call(g,e,O))},[u==null?void 0:u.needsSkeleton,$e,e,g,w]),(0,N.useEffect)(()=>{if(!$e)return;let O=Rn(e);if(!O)return;let G=b();An(O,G&&"status"in G?{status:G.status}:{skeleton:G})},[e,$e,w]),(0,N.useEffect)(()=>{!Mt||!F()||nr.has(e)||(nr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[Mt,e]);let ct=u!=null&&u.blocks?Object.keys(u.blocks).sort().join("|"):"";(0,N.useEffect)(()=>_e({id:e,arms:ct===""?void 0:ct.split("|")}),[e,ct]);let Bt=(0,N.useRef)(null);(0,N.useEffect)(()=>{!g||T==="none"||T==="seeded"||T==="override"||S===""||K||Bt.current!==S&&(Bt.current=S,pe(g,y,e,S))},[g,y,e,S,T,K]);let fe=T!=="none"&&T!=="seeded"&&!K,dt=fe?S:"",jt=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,N.useEffect)(()=>{if(!g||!i||T==="override")return;let O=h.current;if(!O)return;let G=ge(i),J=ae(i),U=!1;return le(O,ee(i),{fireGoal:()=>{U||(U=!0,fe&&(J!==void 0?g.componentGoal(e,G,{value:J}):g.componentGoal(e,G)),g.goal(G,m({metadata:{componentId:e,arm:dt},weight:1,stepIndex:0},J!==void 0?{value:J}:{})))},fireStep:(se,je,gt)=>{fe&&g.componentGoal(e,se,{reward:je}),g.goal(se,{metadata:{componentId:e,arm:dt},weight:je,stepIndex:gt})}},G)},[g,e,jt,S,T,K,fe,dt,w]);let ft=(0,N.useMemo)(()=>i?ee(i):null,[jt]);(0,N.useEffect)(()=>{T==="override"||!g||!c||!ft||me(g,y,e,c,ft)},[g,y,e,c,ft,T]);let Ut=(0,N.useRef)(o);Ut.current=o;let Wt=(0,N.useRef)(new Set),Pr=o?JSON.stringify(o):"";(0,N.useEffect)(()=>{if(!g||T==="override"||!fe||S==="")return;let O=h.current;if(O)return(0,ke.attachMicroSignalDetectors)((G,J={})=>{var zt,qt,Yt;g.track({projectId:y,componentId:e,variantId:S,eventType:"micro_signal",payload:m({signalType:G},J)});let U=(zt=Ut.current)==null?void 0:zt[G];if(!U||Wt.current.has(G))return;Wt.current.add(G);let se=typeof U=="string"?U:U.name,je=typeof U=="string"?1:(qt=U.weight)!=null?qt:1,gt=typeof U=="string"?0:(Yt=U.stepIndex)!=null?Yt:0;g.goal(se,{metadata:m({componentId:e,arm:S,signalType:G},J),weight:je,stepIndex:gt})},O,Date.now())},[g,y,e,S,T,fe,Pr,w]);let Kt=(0,N.useRef)({agentData:x,agentDataByVariant:l});Kt.current={agentData:x,agentDataByVariant:l};let Jt=(0,N.useRef)(null);(0,N.useEffect)(()=>{var se;if(!g||T==="override"||!fe||S===""||Jt.current===S)return;let{agentData:O,agentDataByVariant:G}=Kt.current,J=oe!=null?oe:S,U=G!==void 0?Object.prototype.hasOwnProperty.call(G,J)?G[J]:void 0:O;U!==void 0&&(Jt.current=S,(se=g.reportAgentData)==null||se.call(g,e,S,U))},[g,e,S,fe,oe,T]);let Be=(0,N.useRef)(null);(0,N.useEffect)(()=>{let O=h.current;if(O){if(Be.current===null){Be.current=S;return}Be.current!==S&&(Be.current=S,(0,ke.reveal)(O))}},[S,w]);let Gr=(0,N.useMemo)(()=>m({"data-sentient-slot":e},S!==""?{"data-sentient-arm":S}:{}),[e,S]);return w?null:(0,ir.jsx)(f,L(m({ref:h,className:s},Gr),{children:q}))}var Re=require("react/jsx-runtime");function si(e){var p,l;let{client:t,variantId:n,content:r,ref:i}=et(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[s,f]=(0,de.useState)(!1);(0,de.useEffect)(()=>{f(!0)},[]);let a=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!s||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,o=c===null?r:null;return F()&&c===null&&o===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,Re.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:o})}var ai=(0,de.memo)(si,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function or(e){if(e.variants===void 0)return(0,Re.jsx)(Ie,m({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=De(n,["variants"]);return(0,Re.jsx)(Ie,L(m({},i),{children:t.children,variants:r}))}return(0,Re.jsx)(li,m({},t))}function li(e){var l;let[t,n]=(0,de.useState)(null),{id:r}=e,i=(0,de.useCallback)(()=>n(r),[r]),s=M(),f=ze().includes(r)||((l=s==null?void 0:s.isUnified)==null?void 0:l.call(s,r))===!0;if(t!==r&&!f)return(0,Re.jsx)(ai,L(m({},e),{onUnified:i}));let x=e,{variants:a,children:c}=x,o=De(x,["variants","children"]),p=Object.keys(a)[0];return(0,Re.jsx)(Ie,L(m({},o),{variants:a,variantsOnly:!0,children:p!==void 0?a[p]:null}))}var X=require("react");var ar=require("react/jsx-runtime");function sr({id:e,default:t,component:n="span",className:r,goal:i}){var E;let s=M(),f=ue(),a=qe(),c=Te(),o=(0,X.useRef)(null),p=(0,X.useRef)(null),l=(0,X.useSyncExternalStore)(Y,()=>ye(e),()=>null),[x,R]=(0,X.useState)(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.content)!=null?k:null}),[g,y]=(0,X.useState)(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.variantId)!=null?k:null});(0,X.useEffect)(()=>{if(l||!s)return;let b=s.getAssignment(e,c);if((b==null?void 0:b.content)!==void 0){y(b.variantId),R(b.content);return}let k=!1;return s.assign(e).then(A=>{if(!k){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&R(A.content)}}),()=>{k=!0}},[s,e,c,l]),(0,X.useEffect)(()=>{l||!s||!g||!f||o.current!==g&&(o.current=g,s.track({projectId:f,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[s,g,f,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=(0,X.useMemo)(()=>i===void 0?null:ee(i),[h]),d=i===void 0?null:typeof i=="string"?i:v.type,w=(0,X.useRef)(!1);(0,X.useEffect)(()=>{w.current=!1},[g,h]),(0,X.useEffect)(()=>{if(l||!s||!g||!f||!v||!d)return;let b=p.current;if(!b)return;let k=ae(v);return le(b,v,{fireGoal:()=>{w.current||(w.current=!0,s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:d,payload:m({reward:1},k!==void 0?{goalValue:k}:{})}),s.goal(d,m({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(A,u,S)=>{s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:A,payload:{reward:u}}),s.goal(A,{metadata:{},weight:u,stepIndex:S})}})},[s,g,f,e,v,d,l]);let C=x!=null?x:t;if(l){let b=s==null?void 0:s.getAssignment(e,c);C=b&&b.variantId===l&&(E=b.content)!=null?E:t}return(0,ar.jsx)(n,{ref:b=>{p.current=b},className:r,children:C})}var st=require("react");function at(e){let t=M(),n=(0,st.useRef)(new Set);return(0,st.useCallback)((r,i)=>{var s,f;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,m(m(m({metadata:(s=i==null?void 0:i.metadata)!=null?s:{},weight:(f=i==null?void 0:i.reward)!=null?f: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 Ve=require("react");function lr(e,t={}){let c=t,{componentId:n}=c,r=De(c,["componentId"]),i=M(),s=at(n!=null?n:""),f=(0,Ve.useRef)(!1),a=(0,Ve.useRef)(r);a.current=r,(0,Ve.useEffect)(()=>{if(!i||f.current||i.gated)return;f.current=!0;let{metadata:o,reward:p,value:l,currency:x,externalId:R}=a.current;if(n){s(e,a.current);return}i.goal(e,m(m(m({metadata:o!=null?o:{},weight:p!=null?p:1,stepIndex:0},l!==void 0?{value:l}:{}),x!==void 0?{currency:x}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,s])}var ur=require("@sentientui/core"),cr=require("@sentientui/policy"),fr=require("react/jsx-runtime");function Dt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function ui(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Dt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Dt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Dt((0,cr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,ur.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function dr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,fr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:ui(e)}})}var ie=require("react"),yr=require("@sentientui/policy");var re=require("react"),Ae=require("@sentientui/core"),gr=require("@sentientui/policy");function lt(e,t){let n=M(),r=Ye(),[,i]=(0,re.useReducer)(l=>l+1,0),s=(0,re.useSyncExternalStore)(Y,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),f=s===void 0?r[e]:void 0,a=s===void 0&&f===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&s===void 0&&f===void 0&&a===null;(0,re.useEffect)(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(x=>{!l&&x&&i()}),()=>{l=!0}},[n,e,c]);let o=(()=>{if(s!==void 0)return{result:s,arm:(0,Ae.armOfResult)(s),source:"override"};if(f!==void 0)return{result:f,arm:(0,Ae.armOfResult)(f),source:"preloaded"};if(a!==null){let x=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ae.armOfResult)(a),source:x?"client":"seeded"}}let l=(0,Ae.baselineResultFor)(t);return{result:l,arm:(0,Ae.armOfResult)(l),source:"baseline"}})(),p=o.source==="preloaded"||o.source==="override";return(0,re.useEffect)(()=>{var x;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let l=(x=n.onSlotsChanged)==null?void 0:x.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),l==null||l()}},[n,e,p]),o}function ci(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function mr(){let e=M(),t=Dn();(0,re.useSyncExternalStore)(Y,ln,()=>0);let[n,r]=(0,re.useState)(!1);(0,re.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,gr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let s=ci();if(s)return i(s);if(t)return i(t);let f=e?e.getPersona():null;return f?i(f):null}var pr=new Set;function di(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function vr(e,t,n){let r=M(),i=ue(),s=JSON.stringify(t),f=(0,ie.useMemo)(()=>({id:e,dims:t}),[e,s]),{result:a,arm:c,source:o}=lt(e,f),p=(0,ie.useMemo)(()=>typeof a=="string"?{}:a,[c]);if(F()&&!pr.has(e)){pr.add(e);let y=(0,yr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,d])=>[v,[...d]]))}),h=Object.values(t).reduce((v,d)=>v*d.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,ie.useEffect)(()=>_e({id:e,dims:t}),[e]);let x=(0,ie.useRef)(null);(0,ie.useEffect)(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||x.current===c||(x.current=c,pe(r,i,e,c))},[r,i,e,c,o]);let R=n==null?void 0:n.funnel;(0,ie.useEffect)(()=>{var y;!r||!R||o==="override"||me(r,i,e,R,ee((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,R,l,o]),(0,ie.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${di(e)}"]`);if(!y){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=ge(n.goal),v=ae(n.goal),d=!1;return le(y,ee(n.goal),{fireGoal:()=>{d||(d=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,m({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(w,C,P)=>{r.componentGoal(e,w,{reward:C}),r.goal(w,{metadata:{componentId:e,arm:c},weight:C,stepIndex:P})}},h)},[r,e,l,c,o]);let g=(0,ie.useMemo)(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(p))y[`data-${h}`]=v;return y},[e,p]);return{tokens:p,props:g}}var Ce=require("react");var Sr=new Set,hr=new Set;function br(e,t){var g,y;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:s,goalLabel:f,ref:a,nodeRef:c}=et(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(g=i!=null?i:r[0])!=null?g:"",p=t.variants[o],l=ze().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;(0,Ce.useEffect)(()=>{!l||!F()||hr.has(e)||(hr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),(0,Ce.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!c.current&&!Sr.has(e)&&(Sr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let x=(0,Ce.useCallback)((h,v)=>{var w,C;if(s)return;let d=h!=null?h:f;d&&(n==null||n.componentGoal(e,d,v),n==null||n.goal(d,m(m(m({metadata:(w=v==null?void 0:v.metadata)!=null?w:{},weight:(C=v==null?void 0:v.reward)!=null?C:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,f,s]),R=(0,Ce.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":o}),[a,e,o]);return{variant:o,value:p,bind:R,fireGoal:x}}var z=require("react");var xr=require("react/jsx-runtime"),ut=new Set;function wr(e){var v;let t=M(),n=ue(),r=(0,z.useRef)(null),i=Object.keys(e.arrangements).join(" "),s=(0,z.useMemo)(()=>Object.keys(e.arrangements),[i]),f=(0,z.useMemo)(()=>m({id:e.id,arms:s},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,s,e.baseline]),{arm:a,source:c}=lt(e.id,f);F()&&e.baseline!==void 0&&e.baseline!==s[0]&&!ut.has(e.id+":baseline")&&(ut.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${s[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=z.Children.toArray(e.children).filter(z.isValidElement),p=new Map;for(let d of o)p.set(String((v=d.key)!=null?v:"").replace(/^\.\$/,""),d);let l=e.arrangements[a],x=l!==void 0&&l.length===o.length&&l.every(d=>p.has(d));F()&&l!==void 0&&!x&&!ut.has(e.id+":keys")&&(ut.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let R=x?l.map(d=>p.get(d)):o;(0,z.useEffect)(()=>_e({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=(0,z.useRef)(null);(0,z.useEffect)(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||g.current===a||(g.current=a,pe(t,n,e.id,a))},[t,n,e.id,a,c]);let y=e.funnel;(0,z.useEffect)(()=>{var d;!t||!y||c==="override"||me(t,n,e.id,y,ee((d=e.goal)!=null?d:"click"))},[t,n,e.id,y,c]);let h=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,z.useEffect)(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let d=r.current;if(!d)return;let w=ge(e.goal),C=ae(e.goal),P=!1;return le(d,ee(e.goal),{fireGoal:()=>{P||(P=!0,C!==void 0?t.componentGoal(e.id,w,{value:C}):t.componentGoal(e.id,w),t.goal(w,m({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(E,b,k)=>{t.componentGoal(e.id,E,{reward:b}),t.goal(E,{metadata:{componentId:e.id,arm:a},weight:b,stepIndex:k})}},w)},[t,e.id,h,a,c]),(0,xr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:R})}var Lt=require("@sentientui/core");var fi=["page","blocks","layoutOrder"],kr=new Map;function Rr(e,t){kr.set(e,t)}function Ft(e){return kr.get(e)}function Ar(e){var i,s;let t=(s=(i=e.content)!=null?i:Ft(e.page))!=null?s:{},n={};for(let[f,a]of Object.entries(t))fi.includes(f)||(n[f]=a);let r=L(m({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Cr(e){return`<script type="application/ld+json">${Vt(e)}</script>`}function Vt(e){return JSON.stringify(m({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function _r(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
4
|
`}var Or=require("@sentientui/core"),Er=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient,useSessionSegment});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var yr=Object.defineProperty,vr=Object.defineProperties;var Sr=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Ht=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))Xt.call(t,n)&&Ht(e,n,t[n]);if(Ne)for(var n of Ne(t))zt.call(t,n)&&Ht(e,n,t[n]);return e},N=(e,t)=>vr(e,Sr(t));var Re=(e,t)=>{var n={};for(var r in e)Xt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ne)for(var r of Ne(e))t.indexOf(r)<0&&zt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Cr,useContext as K,useEffect as ne,useMemo as Rn,useRef as ie,useState as Ce,useSyncExternalStore as _r}from"react";import{deriveSessionSegment as Or,init as Er}from"@sentientui/core";var qt=new Map,De=new Map;function Yt(e,t){let n=De.get(e);return n||(n=new Set,De.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&De.delete(e)}}function Zt(e,t){qt.set(e,t);let n=De.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function ot(e){var t;return(t=qt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Qt(){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 st(){return Qt().on}function en(e){let t=Qt().listeners;return t.add(e),()=>{t.delete(e)}}function tn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,s)=>e.assign(t,n,r,i,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var at="sentient:overrides-changed";function nn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function lt(){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(at))}function X(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(at,e),()=>window.removeEventListener(at,e))}function rn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){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 se(e){return typeof e=="string"?e:e.type}function ee(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ut=new Set,ct=!1;function on(e){if(ut.has(e))return!0;if(ut.add(e),!ct){ct=!0;let t=()=>{ct=!1,ut.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 sn(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 te(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,p=[];return t.steps.forEach(({goal:l,name:x,weight:R},g)=>{let y=(h=!1)=>{o.has(g)||h&&r!==void 0&&on(`step\0${x}\0${R}\0${g}`)||(o.add(g),n.fireStep(x,R,g))};if(l.type==="click"){let h=v=>{let d=v.target;d instanceof Element&&sn(d,e,l.selector)&&y()};e.addEventListener("click",h),p.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),p.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),v=new IntersectionObserver(d=>{for(let w of d)if(w.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let l of p)l()}}let i=t.type==="composite"?t.all:[t],s=new Set(i.map((o,p)=>p)),f=()=>{r!==void 0&&on(r)||n.fireGoal()},a=(o,p=!1)=>{s.delete(o),s.size===0&&(p?f():n.fireGoal())},c=[];return i.forEach((o,p)=>{if(o.type==="click"){let l=x=>{let R=x.target;R instanceof Element&&sn(R,e,o.selector)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(o.type==="form_submit"){let l=x=>{x.target instanceof HTMLFormElement&&e.contains(x.target)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(o.type==="scroll_depth"){let l=Math.max(0,Math.min(1,o.threshold)),x=new IntersectionObserver(R=>{for(let g of R)if(g.intersectionRatio>=l){t.type==="composite"?a(p,!0):f(),x.disconnect();break}},{threshold:[l]});x.observe(e),c.push(()=>x.disconnect());return}}),()=>{for(let o of c)o()}}var an=new Set,ln=new Set;function ae(e,t,n,r,i){let s=`${r}|${n}`;if(ln.has(s))return;ln.add(s);let f=i.type==="weighted_composite"&&!an.has(r);f&&an.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:f?{funnelId:r,steps:i.steps.map(a=>({goalId:a.name,weight:a.weight}))}:{funnelId:r}})}function le(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var wr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function de(){if(typeof window=="undefined")return wr;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 Ae(){de().version+=1;for(let e of de().listeners)e()}var un=()=>{};function cn(e){return D()?(de().components.set(e.id,e),Ae(),()=>{de().components.delete(e.id),Ae()}):un}function ve(e){return D()?(de().slots.set(e.id,e),Ae(),()=>{de().slots.delete(e.id),Ae()}):un}function dt(e){D()&&(de().sections=[...e],Ae())}var dn="0.40.0",ft=dn!=="0.0.0-dev"?{name:"react",version:dn}:void 0;function xr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Se(e,t){xr()[e]=t}function fn(e){window.__sentient_vocabulary_override=e}function gn(){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 he(e,t){kr()[e]=t}function mn(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 s=n.slice(0,r.index)+i;history.replaceState(history.state,"",s?"#"+s:location.pathname+location.search)}}catch(n){}return t}var mt="__snt_editor_token",be=null,gt=!1;function pn(){return gt}function Rr(){try{return sessionStorage.getItem(mt)}catch(e){return null}}function Le(e){if(be)return be;let t=typeof window=="undefined"?null:mn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Rr();return gt=!!n,be=Promise.resolve(n?{token:n,fresh:!1}:null),be}return gt=!0,be=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(mt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),be}function yn(){try{sessionStorage.removeItem(mt)}catch(e){}}var vn="sentient_preview_cell",Sn="sentient_refresh_region",pt="sentient-cell-preview-bar",fe="__preview__",we=null;function hn(e){if((we==null?void 0:we.slotId)!==e)return null;let t=we;return we=null,t}function bn(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(m({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 wn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(pt))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(vn),n=c.get(Sn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Le(r);if(!pn())return;if(n){we={slotId:n,session:i,base:r},Se(n,{kind:"arms"}),he(n,fe),lt();return}if(!t)return;let s=t.lastIndexOf("~");if(s<=0)return;let f=t.slice(0,s),a=t.slice(s+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(ge(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){ge(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let o=await c.json();if(o.vocabulary&&Array.isArray(o.vocabulary.entries)&&fn(o.vocabulary),o.compose!=null)Se(f,{kind:"arms",compose:{[fe]:o.compose}}),he(f,fe);else if(o.edits!=null&&typeof o.skeletonFp=="string"&&Array.isArray(o.leafToNode))Se(f,{kind:"arms",edits:{edits:o.edits,fp:o.skeletonFp,leafToNode:o.leafToNode}}),he(f,fe);else if(o.blocks!=null)Se(f,{kind:"arms",blocks:{[fe]:o.blocks}}),he(f,fe);else if(o.content!=null)Se(f,{kind:"arms",content:o.content}),he(f,fe);else{ge("Nothing to preview in that square yet.");return}lt(),ge(`Previewing \u201C${o.slotName}\u201D for ${o.personaDisplay}${o.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${f}"]`))==null||p.scrollIntoView({block:"center"})}catch(l){}},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(pt))return;let t=document.createElement("div");t.id=pt,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=()=>{yn();let s=new URL(window.location.href);s.searchParams.delete(vn),s.searchParams.delete(Sn),window.location.assign(s.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var xn=!1;function kn(e){if(xn||typeof window=="undefined")return;xn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Le(t).then(n=>{!n||!("token"in n)||!n.fresh||Ar(t,n.token)})}function Ar(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 Lr}from"react/jsx-runtime";function Pr(){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 Cn="https://api.sentient-ui.com/v1",W=Cr({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Cn,debug:!1}),An=!1,yt=new Set;function Gr(e,t,n){let r=ie(n);r.current=n;let[i,s]=Ce(null),[f,a]=Ce(!1),c=ie(e);c.current=e;let o=e===void 0?"":typeof e=="string"?e:JSON.stringify(N(m({},e),{check:typeof e.check,refused:typeof e.refused}));return ne(()=>{let p=c.current;if(p===void 0||typeof window=="undefined")return;let l,x=!1;return import("@sentientui/core/consent").then(({consentWatcher:R,forgetVisitor:g})=>{if(x)return;let y=R(typeof p=="object"&&p.cmp===void 0&&p.check?m(N(m({},p),{check:()=>c.current.check()}),p.refused?{refused:()=>{var d,w;return((w=(d=c.current).refused)==null?void 0:w.call(d))===!0}}:{}):p),h=!1,v=()=>{let d=y.refused()&&y.read()!==!0;d&&!h&&(g(t),r.current()),h=d,a(d);let w=y.read();w!==null&&yt.add(t),s(w!=null?w:yt.has(t)?!1:null)};v(),l=y.subscribe(v)}),()=>{x=!0,l==null||l()}},[o,t]),{granted:i,refused:f}}function Tr(e){var C,E,O;let[t,n]=Ce(null),[r]=Ce(()=>{var b;return(b=e.sessionSegment)!=null?b:Pr()}),[i,s]=Ce(st());ne(()=>en(()=>s(st())),[]),ne(()=>{wn(e.apiBaseUrl),kn(e.apiBaseUrl)},[]);let f=ie(()=>{}),a=Gr(e.consentFrom,e.apiKey,()=>f.current()),c=e.consentFrom?(C=a.granted)!=null?C:yt.has(e.apiKey)?!1:e.consent===!0:e.consent,o=e.consentFrom?a.refused:!0,p=ie(o);p.current=o;let l=ie(null),x=ie(!1),R=ie([]),g=ie(!1);f.current=()=>{var k;R.current=[],g.current=!0;let b=l.current;b!=null&&b.gated?b.dispose():(k=b==null?void 0:b.takeHeld)==null||k.call(b)},ne(()=>{var M,z;if(p.current&&c===!1&&(R.current=[]),c===!1&&x.current&&(p.current&&((M=l.current)==null||M.destroy()),l.current=null,x.current=!1),c===!1&&!e.preConsentBehavior){p.current&&((z=l.current)==null||z.destroy()),l.current=null,n(null);return}let b=c!==!1;b&&(g.current=!1);let k=F=>{!b&&g.current&&F.gated&&F.dispose()},A=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},ft?{sdk:ft}:{}),u=!1,S=null,I=null,T=F=>{for(let B of R.current.splice(0))setTimeout(()=>{if(l.current!==F){g.current||R.current.push(B);return}try{B(F)}catch(H){}},0)},G=F=>{e.engagement===!1||!b||import("@sentientui/core/engagement").then(({startEngagementCapture:B})=>{u||(I=B(F,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:F})=>{u||(S=F(N(m({},A),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),k(S),l.current=S,x.current=b,T(S),n(S),G(S))}):(S=Er(A),k(S),l.current=S,x.current=b,T(S),n(S),G(S)),()=>{var F,B;u=!0,I==null||I(),R.current=R.current.concat((B=(F=S==null?void 0:S.takeHeld)==null?void 0:F.call(S))!=null?B:[]),S==null||S.dispose()}},[c]),ne(()=>{if(!t)return;let b=!1,k=async()=>{if(b)return;let u;try{u=await t.fetchWeights()}catch(S){return}if(!b)for(let S of u){let I={componentId:S.componentId,updatedAt:S.updatedAt,variants:S.variants.map(T=>{var G;return{variantId:T.variantId,pulls:T.pulls,avgReward:(G=T.avgReward)!=null?G:0}})};Zt(S.componentId,I)}};k();let A=setInterval(()=>{k()},6e4);return()=>{b=!0,clearInterval(A)}},[t]);let y=(E=e.ssrFallback)!=null?E:"first",h=((O=e.apiBaseUrl)!=null?O:Cn).replace(/\/$/,""),v=ie(null);ne(()=>{var A;if(typeof process!="undefined"&&((A=process.env)==null?void 0:A.NODE_ENV)==="production")return;let b={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},k=v.current;if(v.current=b,k!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(k[u],b[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),ne(()=>{var b;typeof process!="undefined"&&((b=process.env)==null?void 0:b.NODE_ENV)==="production"||rn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]),ne(()=>{let b=e.initialLayoutOrder;if(b&&b.length>0){dt(b);return}e.declaredSections&&e.declaredSections.length>0&&dt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),ne(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||An||(An=!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'))},[]),ne(()=>{if(!D())return;let b=e.declaredSections;if(!b||b.length===0||typeof document=="undefined")return;let k=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),A=b.filter(u=>!k.has(u));A.length>0&&console.warn(`[SentientUI] Declared section${A.length>1?"s":""} ${A.map(u=>`"${u}"`).join(", ")} ${A.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let d=Rn(()=>t&&i?tn(t):t,[t,i]),w=Rn(()=>{var b,k,A,u,S,I,T,G,M;return{client:d,apiKey:e.apiKey,initialAssignments:(b=e.initialAssignments)!=null?b:{},initialUnified:(k=e.initialUnified)!=null?k:Ir,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(A=e.initialLayoutOrder)!=null?A:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(I=e.initialPalette)!=null?I:null,initialVocabulary:(T=e.initialVocabulary)!=null?T:null,initialPersona:(G=e.initialPersona)!=null?G:null,apiBaseUrl:h,debug:(M=e.debug)!=null?M:!1}},[d,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return Lr(W.Provider,{value:w,children:e.children})}function L(){return K(W).client}function re(){return K(W).apiKey}function vt(){return K(W).initialAssignments}var Ir=[];function Fe(){return K(W).initialUnified}function _e(){return K(W).sessionSegment}function _n(){return K(W).ssrFallback}function Ve(){return K(W).onAssignment}function On(){return K(W).debug}function Nr(){let e=K(W).initialLayoutOrder,t=_r(X,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Me(){return K(W).initialSlots}function En(){return K(W).initialPersona}function Pn(){return K(W).initialSlotConfig}function Gn(){return K(W).initialPalette}function Tn(){return K(W).initialVocabulary}function Dr(){return K(W).apiBaseUrl}import{memo as li,useCallback as ui,useEffect as ci,useState as tr}from"react";import{useCallback as Mr,useEffect as me,useMemo as Nn,useRef as Oe,useState as $r}from"react";import{attachMicroSignalDetectors as Br}from"@sentientui/core";import{useEffect as $e,useRef as In,useState as Fr,useSyncExternalStore as Vr}from"react";import{pickFromWeights as St}from"@sentientui/policy";function ue(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 s=i.indexOf(":");if(s!==-1&&i.slice(0,s)===e)return i.slice(s+1)}}catch(r){}return null}function ht(e,t,n,r,i){let s=vt(),f=_n(),a=L(),c=_e(),o=Ve(),p=On(),l=In(null),x=Vr(X,()=>ue(e),()=>null),R=x&&t.includes(x)?x:null,g=In(null);$e(()=>{p&&R&&g.current!==R&&(g.current=R,console.info(`[sentient] override active: ${e} -> ${R}`))},[p,R,e]);let[y,h]=Fr(()=>{var C,E;if(R)return{variantId:R,content:null,isLoading:!1,settled:!0};if(!a){let O=s[e];return O&&t.includes(O)?{variantId:O,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content))return{variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0};let w=ot(e);if(w){let O=St(w.variants,t);if(O)return{variantId:O,content:null,isLoading:!1,settled:!0}}return{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}}),v=d=>{o&&l.current!==d&&(l.current=d,o(e,d))};return $e(()=>{var C;if(R||!a)return;let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content)){h({variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0}),v(d.variantId);return}let w=ot(e);if(w&&y.settled&&y.variantId&&y.variantId===St(w.variants,t)){v(y.variantId);return}h(E=>{var O;return E.variantId?E:{variantId:(O=t[0])!=null?O:null,content:null,isLoading:!1,settled:!1}})},[R,a,e,c]),$e(()=>{if(R||!a)return;let d=a.getAssignment(e,c);if(d&&t.includes(d.variantId))return;let w=!1,C=i==null?void 0:i.onUnified;return(C?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(O=>{var b;if(!w&&O){if(O.unified===!0){C==null||C();return}!t.includes(O.variantId)&&!O.content||(h({variantId:O.variantId,content:(b=O.content)!=null?b:null,isLoading:!1,settled:!0}),v(O.variantId))}}),()=>{w=!0}},[R,a,e,c]),$e(()=>{if(!R&&a)return Yt(e,d=>{var E;let w=a.getAssignment(e,c);if(w&&(t.includes(w.variantId)||w.content)){h({variantId:w.variantId,content:(E=w.content)!=null?E:null,isLoading:!1,settled:!0}),v(w.variantId);return}let C=St(d.variants,t);C&&(h({variantId:C,content:null,isLoading:!1,settled:!0}),v(C))})},[R,a,e,c]),R?{variantId:R,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function Be(e,t,n){let r=L(),i=re(),s=Object.keys(t).join("\0"),f=Nn(()=>Object.keys(t),[s]),{variantId:a,content:c,isOverride:o=!1,settled:p}=ht(e,f,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,x]=$r(null),R=Oe(null),g=Mr(u=>{R.current=u,x(u)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=Nn(()=>y?q(y):null,[h]),d=y?se(y):"";me(()=>cn({id:e,variantIds:f,goal:d}),[e,f,d]);let w=Oe(null);me(()=>{o||p&&(!r||!a||!i||!l||w.current!==a&&(w.current=a,le(r,i,e,a)))},[r,a,i,e,l,o,p]);let C=Oe(!1),E=Oe(new Set);me(()=>{C.current=!1,E.current=new Set},[a,v]);let O=n.funnel;me(()=>{o||!p||!r||!O||!v||ae(r,i,e,O,v)},[r,i,e,O,v,o,p]);let b=n.cursorSignal===!0;me(()=>{if(!b||o||!p||!r||!a||!l)return;let u=null,S=0,I=()=>{S=Date.now(),u=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-S}}),u=null},800)},T=()=>{u!==null&&(clearTimeout(u),u=null)};return l.addEventListener("mouseenter",I),l.addEventListener("mouseleave",T),()=>{l.removeEventListener("mouseenter",I),l.removeEventListener("mouseleave",T),u!==null&&clearTimeout(u)}},[b,r,a,i,e,l,o,p]);let k=Oe(n.microSignalGoals);k.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return me(()=>{if(o||!p||!r||!a||!l)return;let u=Date.now();return Br((S,I={})=>{var F,B,H;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:m({signalType:S},I)});let T=(F=k.current)==null?void 0:F[S];if(!T||E.current.has(S))return;E.current.add(S);let G=typeof T=="string"?T:T.name,M=typeof T=="string"?1:(B=T.weight)!=null?B:1,z=typeof T=="string"?0:(H=T.stepIndex)!=null?H:0;r.goal(G,{metadata:m({signalType:S},I),weight:M,stepIndex:z})},l,u)},[r,a,i,e,l,A,o,p]),me(()=>{if(o||!p||!r||!a||!l||!v)return;let u=ee(v);return te(l,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:d,payload:m({reward:1},u!==void 0?{goalValue:u}:{})}),r.goal(d,m({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},u!==void 0?{value:u}:{})))},fireStep:(S,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:S,payload:{reward:I}}),r.goal(S,{metadata:{},weight:I,stepIndex:T})}},d)},[r,a,i,e,l,v,d,o,p]),{client:r,variantIds:f,variantId:a,content:c,settled:p,isOverride:o,goalLabel:d,ref:g,nodeRef:R}}import{useEffect as J,useMemo as He,useRef as ye,useState as ri,useSyncExternalStore as ii}from"react";import{attachMicroSignalDetectors as oi,containsFormBlock as qn,reveal as si}from"@sentientui/core";import{captureRegionSkeleton as Yn}from"@sentientui/core/region";import{useCallback as jr,useEffect as Dn,useRef as bt,useSyncExternalStore as je}from"react";import{armOfResult as Ur}from"@sentientui/core";var Ln=new Set,Wr={kind:"arms"};function Fn(e,t){var E,O,b;let n=L(),r=bt(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=bt(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let s=bt(t==null?void 0:t.skeleton);s.current=t==null?void 0:t.skeleton;let f=Me(),a=Pn(),c=Gn(),o=Tn(),p=je(X,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_config_overrides)==null?void 0:k[e]:void 0},()=>{}),l=je(X,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_overrides)==null?void 0:k[e]:void 0},()=>{}),x=k=>k==null?"":Ur(k),R=jr(k=>{var A,u;return(u=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,k))!=null?u:(()=>{})},[n]);je(R,()=>{var k;return(k=n==null?void 0:n.getSlotConfig(e))!=null?k:null},()=>null),je(R,()=>x(n==null?void 0:n.getSlotResult(e)),()=>"");let g=p===void 0?a[e]:void 0,y=p===void 0&&g===void 0&&n?n.getSlotConfig(e):null,h=(E=c!=null?c:n==null?void 0:n.getSitePalette())!=null?E:null,v=(b=o!=null?o:(O=n==null?void 0:n.getStyleVocabulary)==null?void 0:O.call(n))!=null?b:null,d=(()=>{var k,A,u;if(p!==void 0)return{config:p,arm:x(l),palette:h,vocabulary:(k=gn())!=null?k:v,source:"override"};if(t!=null&&t.forcedArm)return{config:Wr,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(g!==void 0)return{config:g,arm:x((A=f[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let S=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:x((u=n==null?void 0:n.getSlotResult(e))!=null?u:f[e]),palette:h,vocabulary:v,source:S?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),w=(t==null?void 0:t.defer)===!0,C=d.source==="preloaded"||d.source==="override";return Dn(()=>{var M,z,F,B,H;if(!n||n.isLocal===!0||C||w)return;let k=d.source==="none",A=k&&(z=(M=r.current)==null?void 0:M.call(r))!=null?z:null,u=A!=null&&A!==""?{[e]:A}:void 0,S=(F=i.current)==null?void 0:F.call(i),I=k&&(H=(B=s.current)==null?void 0:B.call(s))!=null?H:null,T=m(m({},S?{render:{[e]:S}}:{}),I?{skeletons:{[e]:I}}:{}),G=Object.keys(T).length>0;return n.requestSlots?G?n.requestSlots([e],u,T):u?n.requestSlots([e],u):n.requestSlots([e]):k&&(I?n.reportSlots([e],u!=null?u:{},{[e]:I}):u?n.reportSlots([e],u):n.reportSlots([e])),()=>{var j;return(j=n.cancelSlots)==null?void 0:j.call(n,[e])}},[n,C,d.source,e,w]),Dn(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||d.source!=="none"||Ln.has(e)||(Ln.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,d.source,e]),d}import{cloneElement as Kr,Fragment as Vn}from"react";import{jsx as V,jsxs as jn}from"react/jsx-runtime";function wt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ce={none:"0",sm:"8px",md:"16px",lg:"24px"},xt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Un={sm:"0.875em",md:"1em",lg:"1.25em"},Jr={sm:"1.25em",md:"1.5em",lg:"2em"},Mn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},$n={sm:"8px",md:"16px",lg:"32px"},Hr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Xr={normal:"400",medium:"500",bold:"700"};function Bn(e,t){return m(m({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?m({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Wn(e,t,n){var i,s,f,a;let r=t==null?void 0:t.accent;return N(m({display:"inline-block",padding:(i=Mn[n!=null?n:"md"])!=null?i:Mn.md,borderRadius:(s=t==null?void 0:t.radius)!=null?s:"8px",font:"inherit"},n?{fontSize:Un[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(f=t==null?void 0:t.primaryBg)!=null?f:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function zr({node:e,opts:t}){var i,s,f,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(f=(s=t.palette)==null?void 0:s.border)!=null?f:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return jn("form",{onSubmit:o=>{var x,R,g;o.preventDefault();let p=new FormData(o.currentTarget),l={};for(let y of e.fields)l[y.name]=String((x=p.get(y.name))!=null?x:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,l)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var p,l;return jn("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?V("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?V("select",{name:o.name,required:o.required,style:r,children:((p=o.options)!=null?p:[]).map(x=>V("option",{value:x,children:x},x))}):V("input",{name:o.name,type:(l=o.inputType)!=null?l:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),V("button",{type:"submit",style:Wn(n,t.palette),children:e.submitLabel})]})}function qr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(s=>s.id===n))==null?void 0:i.classes:void 0}function Kn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=Yr(e,t),r=Kn(e.like,t);return n&&r?Kr(n,{style:N(m({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Yr(e,t){var n,r,i,s,f,a,c,o,p,l,x,R,g,y,h,v,d,w,C,E,O,b,k;try{let A=qr(e,t);switch(e.type){case"stack":{let u=(r=ce[(n=e.gap)!=null?n:"md"])!=null?r:ce.md,S=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:S?"md":void 0;return V("div",N(m({},A?{className:A}:{}),{style:m(m(m(m(m({display:"flex",flexDirection:e.direction,gap:u},e.align?{alignItems:xt[e.align]}:{}),e.justify?{justifyContent:xt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(s=ce[I])!=null?s:ce.md}:{}),S?N(m(m({},(f=t.palette)!=null&&f.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(o=t.palette)==null?void 0:o.border)!=null?p:"currentColor"}`,borderRadius:(x=(l=t.palette)==null?void 0:l.radius)!=null?x:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((T,G)=>{let M=xe(T,t);return M===null?null:V(Vn,{children:M},G)})}))}case"grid":{let u=(y=ce[(g=e.gap)!=null?g:"md"])!=null?y:ce.md;return V("div",N(m({},A?{className:A}:{}),{style:m(m({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${u}) / ${e.columns})), 1fr))`,gap:u},e.align?{alignItems:xt[e.align]}:{}),e.pad?{padding:(h=ce[e.pad])!=null?h:ce.md}:{}),children:((v=e.children)!=null?v:[]).map((S,I)=>{let T=xe(S,t);return T===null?null:V(Vn,{children:T},I)})}))}case"text":return A?V("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V("p",{style:m(m(m(m(m({margin:0},e.size?{fontSize:Un[e.size]}:{}),e.weight?{fontWeight:Xr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bn(e.tone,t.palette)),children:e.value});case"heading":{let u=`h${e.level}`;return A?V(u,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V(u,{style:m(m({margin:0,fontSize:Jr[(d=e.size)!=null?d:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let u=(w=e.emphasis)!=null?w:"primary";return V("a",N(m(m({href:wt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Wn(u,t.palette,e.size)}),{children:e.label}))}case"link":return V("a",N(m(m({href:wt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return V("img",N(m({src:wt(e.src),alt:e.alt},A?{className:A}:{}),{style:m(m({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Hr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?V("span",{className:A,children:e.value}):V("span",{style:m({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(E=(C=t.palette)==null?void 0:C.border)!=null?E:"currentColor"}`},Bn(e.tone,t.palette)),children:e.value});case"spacer":return V("div",{style:{height:(O=$n[e.size])!=null?O:$n.md}});case"divider":return V("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return V(zr,{node:e,opts:t});default:return null}}catch(A){return null}}function kt(e,t){var s,f,a,c;let n=xe(e.tree,t);if(n===null)return null;let r=(s=e.surface)!=null&&s.like?(a=(f=t.vocabulary)==null?void 0:f.entries.find(o=>o.id===e.surface.like))==null?void 0:a.classes:void 0,i=Kn((c=e.surface)==null?void 0:c.like,t);return r?V("div",N(m({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ue,isValidElement as We}from"react";import{normalizeLeafText as Zr,skeletonFingerprint as Qr}from"@sentientui/core/region";function Ke(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Je(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function pe(e){return Ke(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+pe(n),0):We(e)?pe(Je(e)):0}function ei(e,t){return Array.isArray(t)?Ue(e,void 0,...t):Ue(e,void 0,t)}function Rt(e,t){if(Ke(e))return t;if(Array.isArray(e))return e.map(n=>Rt(n,t));if(We(e)){let n=Je(e);return pe(n)===0?e:ei(e,Rt(n,t))}return e}function Jn(e,t){return pe(e)===1?Rt(e,t):null}var Y=e=>e.join("/");function At(e,t,n){if(Ke(e)){n.leafPaths.push(t),n.texts.push(Zr(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>At(r,[...t,i],n));return}We(e)&&(n.elements.set(Y(t),e),At(Je(e),[...t,"c"],n))}function _t(e){let t={leafPaths:[],texts:[],elements:new Map};return At(e,[],t),t}function ti(e){return _t(e).texts}function Hn(e){let t=ti(e);return t.length===0?null:Qr(t)}function ni(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Xn(e,t){let n=t.reduce((i,s)=>Math.max(i,s+1),0),r=[];for(let i=0;i<n;i++){let s=t.flatMap((a,c)=>a===i?[ni(e.leafPaths[c])]:[]);if(s.length===0){r.push(null);continue}let f=s[0];for(let a of s.slice(1)){let c=new Set(a.map(Y));f=f.filter(o=>c.has(Y(o)))}r.push(f.length>0?f[f.length-1]:null)}return r}function Ct(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 Ot(e,t){let n=_t(t);if(n.texts.length!==e.leaves.length||n.texts.some((s,f)=>s!==e.leaves[f]))return null;let r=Xn(n,e.leafToNode),i=e.nodes.map((s,f)=>{let a=r[f],c=a?n.elements.get(Y(a)):void 0,o=!!c&&(typeof c.type=="string"||Ct(c)!==void 0);return N(m({},s),{restylable:o})});return N(m({},e),{nodes:i})}function zn(e,t,n){var g;let r=_t(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let s=Xn(r,n),f=new Map;n.forEach((y,h)=>{f.has(y)||f.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[Y(y),h])),c=new Set,o=new Map,p=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),d=s[v];if(h.hidden&&(d?c.add(Y(d)):p=!0),h.like!==void 0){let w=s[h.like],C=d?r.elements.get(Y(d)):void 0,E=w?Ct(r.elements.get(Y(w))):void 0;!d||E===void 0||Ct(C)===void 0?p=!0:o.set(Y(d),E)}}let l=new Map(Object.entries((g=t.order)!=null?g:{})),x=(y,h)=>{var v;if(Ke(y)){let d=a.get(Y(h));if(d===void 0)return y;let w=n[d],C=(v=t.nodes[String(w)])==null?void 0:v.text;return C===void 0?y:f.get(w)===d?C:""}if(Array.isArray(y)){let d=y.map((w,C)=>x(w,[...h,C]));for(let[w,C]of l){let E=C.map(k=>{let A=s[k];return!A||A.length!==h.length+1||Y(A.slice(0,-1))!==Y(h)?-1:A[A.length-1]});if(E.some(k=>k<0))continue;let O=[...E].sort((k,A)=>k-A),b=[...d];O.forEach((k,A)=>{d[k]=b[E[A]]}),l.delete(w)}return d}if(We(y)){let d=Y(h);if(c.has(d))return null;let w=Je(y);if(pe(w)===0)return y;let C=x(w,[...h,"c"]),E=o.get(d),O=E!==void 0?{className:E}:void 0;return Array.isArray(C)?Ue(y,O,...C):Ue(y,O,C)}return y},R=x(e,[]);return p||l.size>0?null:R}import{jsx as ai}from"react/jsx-runtime";var Zn=new Set,Qn=new Set,er=new Set,Xe="authored.";function Ee({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:s,as:f="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:o,clientOnly:p,agentDataByVariant:l,agentData:x,variantsOnly:R=!1}){var jt,Ut;let g=L(),y=re(),h=ye(null),[v,d]=ri(!1);J(()=>{d(!0)},[]);let w=p===!0&&(!v||!g),C=He(()=>Hn(t),[t]),E=n?Object.keys(n).join("|"):"",O=He(()=>m({fp:C!=null?C:"0000000000000000",forms:!!r,compose:!0,content:pe(t)===1,ops:!1},E!==""?{authored:E.split("|"),children:!R}:{}),[C,t,r,E,R]),b=()=>{var U;let _=h.current;if(!_||!a)return null;let P=Yn(_);return P.skeleton?(U=Ot(P.skeleton,t))!=null?U:N(m({},P.skeleton),{editable:!1,nodes:P.skeleton.nodes.map($=>N(m({},$),{restylable:!1}))}):{status:P.reason}},k=ii(X,()=>n?ue(e):null,()=>null),A=k===null||!n?null:Object.prototype.hasOwnProperty.call(n,k)?`${Xe}${k}`:R?`${Xe}${Object.keys(n)[0]}`:"baseline",{config:u,arm:S,palette:I,vocabulary:T,source:G}=Fn(e,{forcedArm:A,baselineText:a?()=>{var _,P;return(P=(_=h.current)==null?void 0:_.textContent)!=null?P:null}:void 0,render:()=>O,skeleton:b,defer:w}),M=S!==""?(jt=u==null?void 0:u.blocks)==null?void 0:jt[S]:void 0,z=S!==""?(Ut=u==null?void 0:u.compose)==null?void 0:Ut[S]:void 0,F=(M!==void 0&&qn(M)||z!==void 0&&qn(z.tree))&&!r;J(()=>{!F||!D()||Zn.has(e)||(Zn.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.`))},[F,e]);let B=_=>{!g||G==="override"||(G!=="seeded"&&g.componentGoal(e,_),g.goal(_,{metadata:{componentId:e,arm:S},weight:1,stepIndex:0}))},H=t,j=!1,Z=S.startsWith(Xe)?S.slice(Xe.length):null;if((u==null?void 0:u.blocked)==="variant_history")j=!0;else if(Z!==null)n&&Object.prototype.hasOwnProperty.call(n,Z)?H=n[Z]:j=!0;else if(z!==void 0){let _=F?null:kt(z,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:B});_===null?j=!0:H=_}else if(M!==void 0){let _=F?null:xe(M,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:B});_===null?j=!0:H=_}else if((u==null?void 0:u.edits)!==void 0&&G!=="none"){let _=u.edits,P=_.fp===C?zn(t,_.edits,_.leafToNode):null;P===null?j=!0:H=P}else if((u==null?void 0:u.content)!==void 0&&G!=="none"){let _=Jn(t,u.content);_===null?j=!0:H=_}let Nt=j&&M===void 0&&z===void 0&&(u==null?void 0:u.edits)===void 0&&Z===null&&(u==null?void 0:u.blocked)===void 0;J(()=>{(u==null?void 0:u.blocked)!=="variant_history"||!D()||er.has(e)||(er.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.`))},[u==null?void 0:u.blocked,e]);let Pe=Z!==null&&!j?Z:null;J(()=>{var Q;if(!Pe||!a||!g)return;let _=h.current;if(!_)return;let P=Yn(_),U=P.skeleton?Ot(P.skeleton,n==null?void 0:n[Pe]):null,$=(Q=_.textContent)==null?void 0:Q.trim();g.reportSlots([],void 0,void 0,{[e]:[m(m({key:Pe},$?{text:$}:{}),U?{skeleton:U}:{})]})},[Pe,g,e,w]);let Dt=j&&(u==null?void 0:u.edits)!==void 0&&(G==="preloaded"||G==="client");J(()=>{var _;!Dt||!(u!=null&&u.edits)||(_=g==null?void 0:g.reportDrift)==null||_.call(g,e,u.edits.fp,C,u.edits.fp===C?"unaddressable":"fp_mismatch")},[Dt,e,C,g]);let Ge=H===t;J(()=>{var P;if(!(u!=null&&u.needsSkeleton)||!Ge)return;let _=b();_&&((P=g==null?void 0:g.reportSkeleton)==null||P.call(g,e,_))},[u==null?void 0:u.needsSkeleton,Ge,e,g,w]),J(()=>{if(!Ge)return;let _=hn(e);if(!_)return;let P=b();bn(_,P&&"status"in P?{status:P.status}:{skeleton:P})},[e,Ge,w]),J(()=>{!Nt||!D()||Qn.has(e)||(Qn.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.`))},[Nt,e]);let tt=u!=null&&u.blocks?Object.keys(u.blocks).sort().join("|"):"";J(()=>ve({id:e,arms:tt===""?void 0:tt.split("|")}),[e,tt]);let Lt=ye(null);J(()=>{!g||G==="none"||G==="seeded"||G==="override"||S===""||j||Lt.current!==S&&(Lt.current=S,le(g,y,e,S))},[g,y,e,S,G,j]);let oe=G!=="none"&&G!=="seeded"&&!j,nt=oe?S:"",Ft=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);J(()=>{if(!g||!i||G==="override")return;let _=h.current;if(!_)return;let P=se(i),U=ee(i),$=!1;return te(_,q(i),{fireGoal:()=>{$||($=!0,oe&&(U!==void 0?g.componentGoal(e,P,{value:U}):g.componentGoal(e,P)),g.goal(P,m({metadata:{componentId:e,arm:nt},weight:1,stepIndex:0},U!==void 0?{value:U}:{})))},fireStep:(Q,Ie,it)=>{oe&&g.componentGoal(e,Q,{reward:Ie}),g.goal(Q,{metadata:{componentId:e,arm:nt},weight:Ie,stepIndex:it})}},P)},[g,e,Ft,S,G,j,oe,nt,w]);let rt=He(()=>i?q(i):null,[Ft]);J(()=>{G==="override"||!g||!c||!rt||ae(g,y,e,c,rt)},[g,y,e,c,rt,G]);let Vt=ye(o);Vt.current=o;let Mt=ye(new Set),mr=o?JSON.stringify(o):"";J(()=>{if(!g||G==="override"||!oe||S==="")return;let _=h.current;if(_)return oi((P,U={})=>{var Wt,Kt,Jt;g.track({projectId:y,componentId:e,variantId:S,eventType:"micro_signal",payload:m({signalType:P},U)});let $=(Wt=Vt.current)==null?void 0:Wt[P];if(!$||Mt.current.has(P))return;Mt.current.add(P);let Q=typeof $=="string"?$:$.name,Ie=typeof $=="string"?1:(Kt=$.weight)!=null?Kt:1,it=typeof $=="string"?0:(Jt=$.stepIndex)!=null?Jt:0;g.goal(Q,{metadata:m({componentId:e,arm:S,signalType:P},U),weight:Ie,stepIndex:it})},_,Date.now())},[g,y,e,S,G,oe,mr,w]);let $t=ye({agentData:x,agentDataByVariant:l});$t.current={agentData:x,agentDataByVariant:l};let Bt=ye(null);J(()=>{var Q;if(!g||G==="override"||!oe||S===""||Bt.current===S)return;let{agentData:_,agentDataByVariant:P}=$t.current,U=Z!=null?Z:S,$=P!==void 0?Object.prototype.hasOwnProperty.call(P,U)?P[U]:void 0:_;$!==void 0&&(Bt.current=S,(Q=g.reportAgentData)==null||Q.call(g,e,S,$))},[g,e,S,oe,Z,G]);let Te=ye(null);J(()=>{let _=h.current;if(_){if(Te.current===null){Te.current=S;return}Te.current!==S&&(Te.current=S,si(_))}},[S,w]);let pr=He(()=>m({"data-sentient-slot":e},S!==""?{"data-sentient-arm":S}:{}),[e,S]);return w?null:ai(f,N(m({ref:h,className:s},pr),{children:H}))}import{jsx as ke}from"react/jsx-runtime";function di(e){var p,l;let{client:t,variantId:n,content:r,ref:i}=Be(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[s,f]=tr(!1);ci(()=>{f(!0)},[]);let a=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!s||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,o=c===null?r:null;return D()&&c===null&&o===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.`),ke(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:o})}var fi=li(di,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function gi(e){if(e.variants===void 0)return ke(Ee,m({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Re(n,["variants"]);return ke(Ee,N(m({},i),{children:t.children,variants:r}))}return ke(mi,m({},t))}function mi(e){var l;let[t,n]=tr(null),{id:r}=e,i=ui(()=>n(r),[r]),s=L(),f=Fe().includes(r)||((l=s==null?void 0:s.isUnified)==null?void 0:l.call(s,r))===!0;if(t!==r&&!f)return ke(fi,N(m({},e),{onUnified:i}));let x=e,{variants:a,children:c}=x,o=Re(x,["variants","children"]),p=Object.keys(a)[0];return ke(Ee,N(m({},o),{variants:a,variantsOnly:!0,children:p!==void 0?a[p]:null}))}import{useEffect as ze,useMemo as pi,useRef as Et,useState as nr,useSyncExternalStore as yi}from"react";import{jsx as Si}from"react/jsx-runtime";function vi({id:e,default:t,component:n="span",className:r,goal:i}){var O;let s=L(),f=re(),a=Ve(),c=_e(),o=Et(null),p=Et(null),l=yi(X,()=>ue(e),()=>null),[x,R]=nr(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.content)!=null?k:null}),[g,y]=nr(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.variantId)!=null?k:null});ze(()=>{if(l||!s)return;let b=s.getAssignment(e,c);if((b==null?void 0:b.content)!==void 0){y(b.variantId),R(b.content);return}let k=!1;return s.assign(e).then(A=>{if(!k){if(!A){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&R(A.content)}}),()=>{k=!0}},[s,e,c,l]),ze(()=>{l||!s||!g||!f||o.current!==g&&(o.current=g,s.track({projectId:f,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[s,g,f,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=pi(()=>i===void 0?null:q(i),[h]),d=i===void 0?null:typeof i=="string"?i:v.type,w=Et(!1);ze(()=>{w.current=!1},[g,h]),ze(()=>{if(l||!s||!g||!f||!v||!d)return;let b=p.current;if(!b)return;let k=ee(v);return te(b,v,{fireGoal:()=>{w.current||(w.current=!0,s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:d,payload:m({reward:1},k!==void 0?{goalValue:k}:{})}),s.goal(d,m({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(A,u,S)=>{s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:A,payload:{reward:u}}),s.goal(A,{metadata:{},weight:u,stepIndex:S})}})},[s,g,f,e,v,d,l]);let C=x!=null?x:t;if(l){let b=s==null?void 0:s.getAssignment(e,c);C=b&&b.variantId===l&&(O=b.content)!=null?O:t}return Si(n,{ref:b=>{p.current=b},className:r,children:C})}import{useCallback as hi,useRef as bi}from"react";function Pt(e){let t=L(),n=bi(new Set);return hi((r,i)=>{var s,f;if(!ue(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,m(m(m({metadata:(s=i==null?void 0:i.metadata)!=null?s:{},weight:(f=i==null?void 0:i.reward)!=null?f: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 wi,useRef as rr}from"react";function xi(e,t={}){let c=t,{componentId:n}=c,r=Re(c,["componentId"]),i=L(),s=Pt(n!=null?n:""),f=rr(!1),a=rr(r);a.current=r,wi(()=>{if(!i||f.current||i.gated)return;f.current=!0;let{metadata:o,reward:p,value:l,currency:x,externalId:R}=a.current;if(n){s(e,a.current);return}i.goal(e,m(m(m({metadata:o!=null?o:{},weight:p!=null?p:1,stepIndex:0},l!==void 0?{value:l}:{}),x!==void 0?{currency:x}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,s])}import{renderPrePaintScript as ki}from"@sentientui/core";import{confidenceBand as Ri}from"@sentientui/policy";import{jsx as _i}from"react/jsx-runtime";function Gt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ai(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Gt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Gt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Gt(Ri(e.persona.confidence))+");}catch(e){}})();":ki(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Ci(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:_i("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ai(e)}})}import{useEffect as Ze,useMemo as It,useRef as Ni}from"react";import{validateSlotDecl as Di}from"@sentientui/policy";import{useEffect as Tt,useReducer as Oi,useState as Ei,useSyncExternalStore as ir}from"react";import{armOfResult as qe,baselineResultFor as Pi}from"@sentientui/core";import{confidenceBand as Gi}from"@sentientui/policy";function Ye(e,t){let n=L(),r=Me(),[,i]=Oi(l=>l+1,0),s=ir(X,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),f=s===void 0?r[e]:void 0,a=s===void 0&&f===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&s===void 0&&f===void 0&&a===null;Tt(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(x=>{!l&&x&&i()}),()=>{l=!0}},[n,e,c]);let o=(()=>{if(s!==void 0)return{result:s,arm:qe(s),source:"override"};if(f!==void 0)return{result:f,arm:qe(f),source:"preloaded"};if(a!==null){let x=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:qe(a),source:x?"client":"seeded"}}let l=Pi(t);return{result:l,arm:qe(l),source:"baseline"}})(),p=o.source==="preloaded"||o.source==="override";return Tt(()=>{var x;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let l=(x=n.onSlotsChanged)==null?void 0:x.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),l==null||l()}},[n,e,p]),o}function Ti(){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 Ii(){let e=L(),t=En();ir(X,nn,()=>0);let[n,r]=Ei(!1);Tt(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Gi(a.confidence)});if(!n)return t?i(t):null;let s=Ti();if(s)return i(s);if(t)return i(t);let f=e?e.getPersona():null;return f?i(f):null}var or=new Set;function Li(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Fi(e,t,n){let r=L(),i=re(),s=JSON.stringify(t),f=It(()=>({id:e,dims:t}),[e,s]),{result:a,arm:c,source:o}=Ye(e,f),p=It(()=>typeof a=="string"?{}:a,[c]);if(D()&&!or.has(e)){or.add(e);let y=Di({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,d])=>[v,[...d]]))}),h=Object.values(t).reduce((v,d)=>v*d.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);Ze(()=>ve({id:e,dims:t}),[e]);let x=Ni(null);Ze(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||x.current===c||(x.current=c,le(r,i,e,c))},[r,i,e,c,o]);let R=n==null?void 0:n.funnel;Ze(()=>{var y;!r||!R||o==="override"||ae(r,i,e,R,q((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,R,l,o]),Ze(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${Li(e)}"]`);if(!y){D()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=se(n.goal),v=ee(n.goal),d=!1;return te(y,q(n.goal),{fireGoal:()=>{d||(d=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,m({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(w,C,E)=>{r.componentGoal(e,w,{reward:C}),r.goal(w,{metadata:{componentId:e,arm:c},weight:C,stepIndex:E})}},h)},[r,e,l,c,o]);let g=It(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(p))y[`data-${h}`]=v;return y},[e,p]);return{tokens:p,props:g}}import{useCallback as Vi,useEffect as sr,useMemo as Mi}from"react";var ar=new Set,lr=new Set;function $i(e,t){var g,y;if(D()&&!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:s,goalLabel:f,ref:a,nodeRef:c}=Be(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(g=i!=null?i:r[0])!=null?g:"",p=t.variants[o],l=Fe().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;sr(()=>{!l||!D()||lr.has(e)||(lr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),sr(()=>{if(!D()||!n)return;let h=setTimeout(()=>{!c.current&&!ar.has(e)&&(ar.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let x=Vi((h,v)=>{var w,C;if(s)return;let d=h!=null?h:f;d&&(n==null||n.componentGoal(e,d,v),n==null||n.goal(d,m(m(m({metadata:(w=v==null?void 0:v.metadata)!=null?w:{},weight:(C=v==null?void 0:v.reward)!=null?C:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,f,s]),R=Mi(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":o}),[a,e,o]);return{variant:o,value:p,bind:R,fireGoal:x}}import{Children as Bi,isValidElement as ji,useEffect as Qe,useMemo as ur,useRef as cr}from"react";import{jsx as Wi}from"react/jsx-runtime";var et=new Set;function Ui(e){var v;let t=L(),n=re(),r=cr(null),i=Object.keys(e.arrangements).join(" "),s=ur(()=>Object.keys(e.arrangements),[i]),f=ur(()=>m({id:e.id,arms:s},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,s,e.baseline]),{arm:a,source:c}=Ye(e.id,f);D()&&e.baseline!==void 0&&e.baseline!==s[0]&&!et.has(e.id+":baseline")&&(et.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${s[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=Bi.toArray(e.children).filter(ji),p=new Map;for(let d of o)p.set(String((v=d.key)!=null?v:"").replace(/^\.\$/,""),d);let l=e.arrangements[a],x=l!==void 0&&l.length===o.length&&l.every(d=>p.has(d));D()&&l!==void 0&&!x&&!et.has(e.id+":keys")&&(et.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let R=x?l.map(d=>p.get(d)):o;Qe(()=>ve({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=cr(null);Qe(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||g.current===a||(g.current=a,le(t,n,e.id,a))},[t,n,e.id,a,c]);let y=e.funnel;Qe(()=>{var d;!t||!y||c==="override"||ae(t,n,e.id,y,q((d=e.goal)!=null?d:"click"))},[t,n,e.id,y,c]);let h=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return Qe(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let d=r.current;if(!d)return;let w=se(e.goal),C=ee(e.goal),E=!1;return te(d,q(e.goal),{fireGoal:()=>{E||(E=!0,C!==void 0?t.componentGoal(e.id,w,{value:C}):t.componentGoal(e.id,w),t.goal(w,m({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(O,b,k)=>{t.componentGoal(e.id,O,{reward:b}),t.goal(O,{metadata:{componentId:e.id,arm:a},weight:b,stepIndex:k})}},w)},[t,e.id,h,a,c]),Wi("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:R})}import{deriveSessionSegment as Ki}from"@sentientui/core";var Ji=["page","blocks","layoutOrder"],dr=new Map;function Hi(e,t){dr.set(e,t)}function fr(e){return dr.get(e)}function Xi(e){var i,s;let t=(s=(i=e.content)!=null?i:fr(e.page))!=null?s:{},n={};for(let[f,a]of Object.entries(t))Ji.includes(f)||(n[f]=a);let r=N(m({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function zi(e){return`<script type="application/ld+json">${gr(e)}</script>`}function gr(e){return JSON.stringify(m({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function qi(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 yr=Object.defineProperty,vr=Object.defineProperties;var Sr=Object.getOwnPropertyDescriptors;var Ne=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Ht=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))Xt.call(t,n)&&Ht(e,n,t[n]);if(Ne)for(var n of Ne(t))zt.call(t,n)&&Ht(e,n,t[n]);return e},N=(e,t)=>vr(e,Sr(t));var Re=(e,t)=>{var n={};for(var r in e)Xt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ne)for(var r of Ne(e))t.indexOf(r)<0&&zt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Cr,useContext as K,useEffect as ne,useMemo as Rn,useRef as ie,useState as Ce,useSyncExternalStore as _r}from"react";import{deriveSessionSegment as Or,init as Er}from"@sentientui/core";var qt=new Map,De=new Map;function Yt(e,t){let n=De.get(e);return n||(n=new Set,De.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&De.delete(e)}}function Zt(e,t){qt.set(e,t);let n=De.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function ot(e){var t;return(t=qt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Qt(){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 st(){return Qt().on}function en(e){let t=Qt().listeners;return t.add(e),()=>{t.delete(e)}}function tn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,s)=>e.assign(t,n,r,i,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var at="sentient:overrides-changed";function nn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function lt(){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(at))}function X(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(at,e),()=>window.removeEventListener(at,e))}function rn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){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 se(e){return typeof e=="string"?e:e.type}function ee(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ut=new Set,ct=!1;function on(e){if(ut.has(e))return!0;if(ut.add(e),!ct){ct=!0;let t=()=>{ct=!1,ut.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 sn(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 te(e,t,n,r){if(t.type==="weighted_composite"){let o=new Set,p=[];return t.steps.forEach(({goal:l,name:x,weight:R},g)=>{let y=(h=!1)=>{o.has(g)||h&&r!==void 0&&on(`step\0${x}\0${R}\0${g}`)||(o.add(g),n.fireStep(x,R,g))};if(l.type==="click"){let h=v=>{let d=v.target;d instanceof Element&&sn(d,e,l.selector)&&y()};e.addEventListener("click",h),p.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=v=>{v.target instanceof HTMLFormElement&&e.contains(v.target)&&y()};e.addEventListener("submit",h),p.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),v=new IntersectionObserver(d=>{for(let w of d)if(w.intersectionRatio>=h){y(!0),v.disconnect();break}},{threshold:[h]});v.observe(e),p.push(()=>v.disconnect())}}),()=>{for(let l of p)l()}}let i=t.type==="composite"?t.all:[t],s=new Set(i.map((o,p)=>p)),f=()=>{r!==void 0&&on(r)||n.fireGoal()},a=(o,p=!1)=>{s.delete(o),s.size===0&&(p?f():n.fireGoal())},c=[];return i.forEach((o,p)=>{if(o.type==="click"){let l=x=>{let R=x.target;R instanceof Element&&sn(R,e,o.selector)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(o.type==="form_submit"){let l=x=>{x.target instanceof HTMLFormElement&&e.contains(x.target)&&(t.type==="composite"?a(p):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(o.type==="scroll_depth"){let l=Math.max(0,Math.min(1,o.threshold)),x=new IntersectionObserver(R=>{for(let g of R)if(g.intersectionRatio>=l){t.type==="composite"?a(p,!0):f(),x.disconnect();break}},{threshold:[l]});x.observe(e),c.push(()=>x.disconnect());return}}),()=>{for(let o of c)o()}}var an=new Set,ln=new Set;function ae(e,t,n,r,i){let s=`${r}|${n}`;if(ln.has(s))return;ln.add(s);let f=i.type==="weighted_composite"&&!an.has(r);f&&an.add(r),e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:f?{funnelId:r,steps:i.steps.map(a=>({goalId:a.name,weight:a.weight}))}:{funnelId:r}})}function le(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var wr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function de(){if(typeof window=="undefined")return wr;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 Ae(){de().version+=1;for(let e of de().listeners)e()}var un=()=>{};function cn(e){return D()?(de().components.set(e.id,e),Ae(),()=>{de().components.delete(e.id),Ae()}):un}function ve(e){return D()?(de().slots.set(e.id,e),Ae(),()=>{de().slots.delete(e.id),Ae()}):un}function dt(e){D()&&(de().sections=[...e],Ae())}var dn="0.40.1",ft=dn!=="0.0.0-dev"?{name:"react",version:dn}:void 0;function xr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Se(e,t){xr()[e]=t}function fn(e){window.__sentient_vocabulary_override=e}function gn(){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 he(e,t){kr()[e]=t}function mn(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 s=n.slice(0,r.index)+i;history.replaceState(history.state,"",s?"#"+s:location.pathname+location.search)}}catch(n){}return t}var mt="__snt_editor_token",be=null,gt=!1;function pn(){return gt}function Rr(){try{return sessionStorage.getItem(mt)}catch(e){return null}}function Le(e){if(be)return be;let t=typeof window=="undefined"?null:mn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Rr();return gt=!!n,be=Promise.resolve(n?{token:n,fresh:!1}:null),be}return gt=!0,be=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(mt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),be}function yn(){try{sessionStorage.removeItem(mt)}catch(e){}}var vn="sentient_preview_cell",Sn="sentient_refresh_region",pt="sentient-cell-preview-bar",fe="__preview__",we=null;function hn(e){if((we==null?void 0:we.slotId)!==e)return null;let t=we;return we=null,t}function bn(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(m({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 wn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(pt))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(vn),n=c.get(Sn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Le(r);if(!pn())return;if(n){we={slotId:n,session:i,base:r},Se(n,{kind:"arms"}),he(n,fe),lt();return}if(!t)return;let s=t.lastIndexOf("~");if(s<=0)return;let f=t.slice(0,s),a=t.slice(s+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(ge(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){ge(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let o=await c.json();if(o.vocabulary&&Array.isArray(o.vocabulary.entries)&&fn(o.vocabulary),o.compose!=null)Se(f,{kind:"arms",compose:{[fe]:o.compose}}),he(f,fe);else if(o.edits!=null&&typeof o.skeletonFp=="string"&&Array.isArray(o.leafToNode))Se(f,{kind:"arms",edits:{edits:o.edits,fp:o.skeletonFp,leafToNode:o.leafToNode}}),he(f,fe);else if(o.blocks!=null)Se(f,{kind:"arms",blocks:{[fe]:o.blocks}}),he(f,fe);else if(o.content!=null)Se(f,{kind:"arms",content:o.content}),he(f,fe);else{ge("Nothing to preview in that square yet.");return}lt(),ge(`Previewing \u201C${o.slotName}\u201D for ${o.personaDisplay}${o.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${f}"]`))==null||p.scrollIntoView({block:"center"})}catch(l){}},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(pt))return;let t=document.createElement("div");t.id=pt,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=()=>{yn();let s=new URL(window.location.href);s.searchParams.delete(vn),s.searchParams.delete(Sn),window.location.assign(s.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var xn=!1;function kn(e){if(xn||typeof window=="undefined")return;xn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Le(t).then(n=>{!n||!("token"in n)||!n.fresh||Ar(t,n.token)})}function Ar(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 Lr}from"react/jsx-runtime";function Pr(){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 Cn="https://api.sentient-ui.com/v1",W=Cr({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Cn,debug:!1}),An=!1,yt=new Set;function Gr(e,t,n){let r=ie(n);r.current=n;let[i,s]=Ce(null),[f,a]=Ce(!1),c=ie(e);c.current=e;let o=e===void 0?"":typeof e=="string"?e:JSON.stringify(N(m({},e),{check:typeof e.check,refused:typeof e.refused}));return ne(()=>{let p=c.current;if(p===void 0||typeof window=="undefined")return;let l,x=!1;return import("@sentientui/core/consent").then(({consentWatcher:R,forgetVisitor:g})=>{if(x)return;let y=R(typeof p=="object"&&p.cmp===void 0&&p.check?m(N(m({},p),{check:()=>c.current.check()}),p.refused?{refused:()=>{var d,w;return((w=(d=c.current).refused)==null?void 0:w.call(d))===!0}}:{}):p),h=!1,v=()=>{let d=y.refused()&&y.read()!==!0;d&&!h&&(g(t),r.current()),h=d,a(d);let w=y.read();w!==null&&yt.add(t),s(w!=null?w:yt.has(t)?!1:null)};v(),l=y.subscribe(v)}),()=>{x=!0,l==null||l()}},[o,t]),{granted:i,refused:f}}function Tr(e){var C,E,O;let[t,n]=Ce(null),[r]=Ce(()=>{var b;return(b=e.sessionSegment)!=null?b:Pr()}),[i,s]=Ce(st());ne(()=>en(()=>s(st())),[]),ne(()=>{wn(e.apiBaseUrl),kn(e.apiBaseUrl)},[]);let f=ie(()=>{}),a=Gr(e.consentFrom,e.apiKey,()=>f.current()),c=e.consentFrom?(C=a.granted)!=null?C:yt.has(e.apiKey)?!1:e.consent===!0:e.consent,o=e.consentFrom?a.refused:!0,p=ie(o);p.current=o;let l=ie(null),x=ie(!1),R=ie([]),g=ie(!1);f.current=()=>{var k;R.current=[],g.current=!0;let b=l.current;b!=null&&b.gated?b.dispose():(k=b==null?void 0:b.takeHeld)==null||k.call(b)},ne(()=>{var M,z;if(p.current&&c===!1&&(R.current=[]),c===!1&&x.current&&(p.current&&((M=l.current)==null||M.destroy()),l.current=null,x.current=!1),c===!1&&!e.preConsentBehavior){p.current&&((z=l.current)==null||z.destroy()),l.current=null,n(null);return}let b=c!==!1;b&&(g.current=!1);let k=F=>{!b&&g.current&&F.gated&&F.dispose()},A=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},ft?{sdk:ft}:{}),u=!1,S=null,I=null,T=F=>{for(let B of R.current.splice(0))setTimeout(()=>{if(l.current!==F){g.current||R.current.push(B);return}try{B(F)}catch(H){}},0)},G=F=>{e.engagement===!1||!b||import("@sentientui/core/engagement").then(({startEngagementCapture:B})=>{u||(I=B(F,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:F})=>{u||(S=F(N(m({},A),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),k(S),l.current=S,x.current=b,T(S),n(S),G(S))}):(S=Er(A),k(S),l.current=S,x.current=b,T(S),n(S),G(S)),()=>{var F,B;u=!0,I==null||I(),R.current=R.current.concat((B=(F=S==null?void 0:S.takeHeld)==null?void 0:F.call(S))!=null?B:[]),S==null||S.dispose()}},[c]),ne(()=>{if(!t)return;let b=!1,k=async()=>{if(b)return;let u;try{u=await t.fetchWeights()}catch(S){return}if(!b)for(let S of u){let I={componentId:S.componentId,updatedAt:S.updatedAt,variants:S.variants.map(T=>{var G;return{variantId:T.variantId,pulls:T.pulls,avgReward:(G=T.avgReward)!=null?G:0}})};Zt(S.componentId,I)}};k();let A=setInterval(()=>{k()},6e4);return()=>{b=!0,clearInterval(A)}},[t]);let y=(E=e.ssrFallback)!=null?E:"first",h=((O=e.apiBaseUrl)!=null?O:Cn).replace(/\/$/,""),v=ie(null);ne(()=>{var A;if(typeof process!="undefined"&&((A=process.env)==null?void 0:A.NODE_ENV)==="production")return;let b={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},k=v.current;if(v.current=b,k!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(k[u],b[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),ne(()=>{var b;typeof process!="undefined"&&((b=process.env)==null?void 0:b.NODE_ENV)==="production"||rn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]),ne(()=>{let b=e.initialLayoutOrder;if(b&&b.length>0){dt(b);return}e.declaredSections&&e.declaredSections.length>0&&dt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),ne(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||An||(An=!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'))},[]),ne(()=>{if(!D())return;let b=e.declaredSections;if(!b||b.length===0||typeof document=="undefined")return;let k=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),A=b.filter(u=>!k.has(u));A.length>0&&console.warn(`[SentientUI] Declared section${A.length>1?"s":""} ${A.map(u=>`"${u}"`).join(", ")} ${A.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let d=Rn(()=>t&&i?tn(t):t,[t,i]),w=Rn(()=>{var b,k,A,u,S,I,T,G,M;return{client:d,apiKey:e.apiKey,initialAssignments:(b=e.initialAssignments)!=null?b:{},initialUnified:(k=e.initialUnified)!=null?k:Ir,sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(A=e.initialLayoutOrder)!=null?A:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(S=e.initialSlotConfig)!=null?S:{},initialPalette:(I=e.initialPalette)!=null?I:null,initialVocabulary:(T=e.initialVocabulary)!=null?T:null,initialPersona:(G=e.initialPersona)!=null?G:null,apiBaseUrl:h,debug:(M=e.debug)!=null?M:!1}},[d,e.apiKey,e.initialAssignments,e.initialUnified,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return Lr(W.Provider,{value:w,children:e.children})}function L(){return K(W).client}function re(){return K(W).apiKey}function vt(){return K(W).initialAssignments}var Ir=[];function Fe(){return K(W).initialUnified}function _e(){return K(W).sessionSegment}function _n(){return K(W).ssrFallback}function Ve(){return K(W).onAssignment}function On(){return K(W).debug}function Nr(){let e=K(W).initialLayoutOrder,t=_r(X,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Me(){return K(W).initialSlots}function En(){return K(W).initialPersona}function Pn(){return K(W).initialSlotConfig}function Gn(){return K(W).initialPalette}function Tn(){return K(W).initialVocabulary}function Dr(){return K(W).apiBaseUrl}import{memo as li,useCallback as ui,useEffect as ci,useState as tr}from"react";import{useCallback as Mr,useEffect as me,useMemo as Nn,useRef as Oe,useState as $r}from"react";import{attachMicroSignalDetectors as Br}from"@sentientui/core";import{useEffect as $e,useRef as In,useState as Fr,useSyncExternalStore as Vr}from"react";import{pickFromWeights as St}from"@sentientui/policy";function ue(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 s=i.indexOf(":");if(s!==-1&&i.slice(0,s)===e)return i.slice(s+1)}}catch(r){}return null}function ht(e,t,n,r,i){let s=vt(),f=_n(),a=L(),c=_e(),o=Ve(),p=On(),l=In(null),x=Vr(X,()=>ue(e),()=>null),R=x&&t.includes(x)?x:null,g=In(null);$e(()=>{p&&R&&g.current!==R&&(g.current=R,console.info(`[sentient] override active: ${e} -> ${R}`))},[p,R,e]);let[y,h]=Fr(()=>{var C,E;if(R)return{variantId:R,content:null,isLoading:!1,settled:!0};if(!a){let O=s[e];return O&&t.includes(O)?{variantId:O,content:null,isLoading:!1,settled:!0}:f==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content))return{variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0};let w=ot(e);if(w){let O=St(w.variants,t);if(O)return{variantId:O,content:null,isLoading:!1,settled:!0}}return{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}}),v=d=>{o&&l.current!==d&&(l.current=d,o(e,d))};return $e(()=>{var C;if(R||!a)return;let d=a.getAssignment(e,c);if(d&&(t.includes(d.variantId)||d.content)){h({variantId:d.variantId,content:(C=d.content)!=null?C:null,isLoading:!1,settled:!0}),v(d.variantId);return}let w=ot(e);if(w&&y.settled&&y.variantId&&y.variantId===St(w.variants,t)){v(y.variantId);return}h(E=>{var O;return E.variantId?E:{variantId:(O=t[0])!=null?O:null,content:null,isLoading:!1,settled:!1}})},[R,a,e,c]),$e(()=>{if(R||!a)return;let d=a.getAssignment(e,c);if(d&&t.includes(d.variantId))return;let w=!1,C=i==null?void 0:i.onUnified;return(C?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(O=>{var b;if(!w&&O){if(O.unified===!0){C==null||C();return}!t.includes(O.variantId)&&!O.content||(h({variantId:O.variantId,content:(b=O.content)!=null?b:null,isLoading:!1,settled:!0}),v(O.variantId))}}),()=>{w=!0}},[R,a,e,c]),$e(()=>{if(!R&&a)return Yt(e,d=>{var E;let w=a.getAssignment(e,c);if(w&&(t.includes(w.variantId)||w.content)){h({variantId:w.variantId,content:(E=w.content)!=null?E:null,isLoading:!1,settled:!0}),v(w.variantId);return}let C=St(d.variants,t);C&&(h({variantId:C,content:null,isLoading:!1,settled:!0}),v(C))})},[R,a,e,c]),R?{variantId:R,content:null,isLoading:!1,settled:!0,isOverride:!0}:y}function Be(e,t,n){let r=L(),i=re(),s=Object.keys(t).join("\0"),f=Nn(()=>Object.keys(t),[s]),{variantId:a,content:c,isOverride:o=!1,settled:p}=ht(e,f,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,x]=$r(null),R=Oe(null),g=Mr(u=>{R.current=u,x(u)},[]),y=n.goal,h=typeof y=="string"?y:JSON.stringify(y),v=Nn(()=>y?q(y):null,[h]),d=y?se(y):"";me(()=>cn({id:e,variantIds:f,goal:d}),[e,f,d]);let w=Oe(null);me(()=>{o||p&&(!r||!a||!i||!l||w.current!==a&&(w.current=a,le(r,i,e,a)))},[r,a,i,e,l,o,p]);let C=Oe(!1),E=Oe(new Set);me(()=>{C.current=!1,E.current=new Set},[a,v]);let O=n.funnel;me(()=>{o||!p||!r||!O||!v||ae(r,i,e,O,v)},[r,i,e,O,v,o,p]);let b=n.cursorSignal===!0;me(()=>{if(!b||o||!p||!r||!a||!l)return;let u=null,S=0,I=()=>{S=Date.now(),u=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-S}}),u=null},800)},T=()=>{u!==null&&(clearTimeout(u),u=null)};return l.addEventListener("mouseenter",I),l.addEventListener("mouseleave",T),()=>{l.removeEventListener("mouseenter",I),l.removeEventListener("mouseleave",T),u!==null&&clearTimeout(u)}},[b,r,a,i,e,l,o,p]);let k=Oe(n.microSignalGoals);k.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return me(()=>{if(o||!p||!r||!a||!l)return;let u=Date.now();return Br((S,I={})=>{var F,B,H;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:m({signalType:S},I)});let T=(F=k.current)==null?void 0:F[S];if(!T||E.current.has(S))return;E.current.add(S);let G=typeof T=="string"?T:T.name,M=typeof T=="string"?1:(B=T.weight)!=null?B:1,z=typeof T=="string"?0:(H=T.stepIndex)!=null?H:0;r.goal(G,{metadata:m({signalType:S},I),weight:M,stepIndex:z})},l,u)},[r,a,i,e,l,A,o,p]),me(()=>{if(o||!p||!r||!a||!l||!v)return;let u=ee(v);return te(l,v,{fireGoal:()=>{C.current||(C.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:d,payload:m({reward:1},u!==void 0?{goalValue:u}:{})}),r.goal(d,m({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},u!==void 0?{value:u}:{})))},fireStep:(S,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:S,payload:{reward:I}}),r.goal(S,{metadata:{},weight:I,stepIndex:T})}},d)},[r,a,i,e,l,v,d,o,p]),{client:r,variantIds:f,variantId:a,content:c,settled:p,isOverride:o,goalLabel:d,ref:g,nodeRef:R}}import{useEffect as J,useMemo as He,useRef as ye,useState as ri,useSyncExternalStore as ii}from"react";import{attachMicroSignalDetectors as oi,containsFormBlock as qn,reveal as si}from"@sentientui/core";import{captureRegionSkeleton as Yn}from"@sentientui/core/region";import{useCallback as jr,useEffect as Dn,useRef as bt,useSyncExternalStore as je}from"react";import{armOfResult as Ur}from"@sentientui/core";var Ln=new Set,Wr={kind:"arms"};function Fn(e,t){var E,O,b;let n=L(),r=bt(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=bt(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let s=bt(t==null?void 0:t.skeleton);s.current=t==null?void 0:t.skeleton;let f=Me(),a=Pn(),c=Gn(),o=Tn(),p=je(X,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_config_overrides)==null?void 0:k[e]:void 0},()=>{}),l=je(X,()=>{var k;return typeof window!="undefined"?(k=window.__sentient_slot_overrides)==null?void 0:k[e]:void 0},()=>{}),x=k=>k==null?"":Ur(k),R=jr(k=>{var A,u;return(u=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,k))!=null?u:(()=>{})},[n]);je(R,()=>{var k;return(k=n==null?void 0:n.getSlotConfig(e))!=null?k:null},()=>null),je(R,()=>x(n==null?void 0:n.getSlotResult(e)),()=>"");let g=p===void 0?a[e]:void 0,y=p===void 0&&g===void 0&&n?n.getSlotConfig(e):null,h=(E=c!=null?c:n==null?void 0:n.getSitePalette())!=null?E:null,v=(b=o!=null?o:(O=n==null?void 0:n.getStyleVocabulary)==null?void 0:O.call(n))!=null?b:null,d=(()=>{var k,A,u;if(p!==void 0)return{config:p,arm:x(l),palette:h,vocabulary:(k=gn())!=null?k:v,source:"override"};if(t!=null&&t.forcedArm)return{config:Wr,arm:t.forcedArm,palette:h,vocabulary:v,source:"override"};if(g!==void 0)return{config:g,arm:x((A=f[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:v,source:"preloaded"};if(y!==null){let S=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:y,arm:x((u=n==null?void 0:n.getSlotResult(e))!=null?u:f[e]),palette:h,vocabulary:v,source:S?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:v,source:"none"}})(),w=(t==null?void 0:t.defer)===!0,C=d.source==="preloaded"||d.source==="override";return Dn(()=>{var M,z,F,B,H;if(!n||n.isLocal===!0||C||w)return;let k=d.source==="none",A=k&&(z=(M=r.current)==null?void 0:M.call(r))!=null?z:null,u=A!=null&&A!==""?{[e]:A}:void 0,S=(F=i.current)==null?void 0:F.call(i),I=k&&(H=(B=s.current)==null?void 0:B.call(s))!=null?H:null,T=m(m({},S?{render:{[e]:S}}:{}),I?{skeletons:{[e]:I}}:{}),G=Object.keys(T).length>0;return n.requestSlots?G?n.requestSlots([e],u,T):u?n.requestSlots([e],u):n.requestSlots([e]):k&&(I?n.reportSlots([e],u!=null?u:{},{[e]:I}):u?n.reportSlots([e],u):n.reportSlots([e])),()=>{var j;return(j=n.cancelSlots)==null?void 0:j.call(n,[e])}},[n,C,d.source,e,w]),Dn(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||d.source!=="none"||Ln.has(e)||(Ln.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,d.source,e]),d}import{cloneElement as Kr,Fragment as Vn}from"react";import{jsx as V,jsxs as jn}from"react/jsx-runtime";function wt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var ce={none:"0",sm:"8px",md:"16px",lg:"24px"},xt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Un={sm:"0.875em",md:"1em",lg:"1.25em"},Jr={sm:"1.25em",md:"1.5em",lg:"2em"},Mn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},$n={sm:"8px",md:"16px",lg:"32px"},Hr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Xr={normal:"400",medium:"500",bold:"700"};function Bn(e,t){return m(m({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?m({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function Wn(e,t,n){var i,s,f,a;let r=t==null?void 0:t.accent;return N(m({display:"inline-block",padding:(i=Mn[n!=null?n:"md"])!=null?i:Mn.md,borderRadius:(s=t==null?void 0:t.radius)!=null?s:"8px",font:"inherit"},n?{fontSize:Un[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(f=t==null?void 0:t.primaryBg)!=null?f:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function zr({node:e,opts:t}){var i,s,f,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(f=(s=t.palette)==null?void 0:s.border)!=null?f:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return jn("form",{onSubmit:o=>{var x,R,g;o.preventDefault();let p=new FormData(o.currentTarget),l={};for(let y of e.fields)l[y.name]=String((x=p.get(y.name))!=null?x:"");(R=t.onFormGoal)==null||R.call(t,e.submitGoal);try{(g=t.onFormSubmit)==null||g.call(t,l)}catch(y){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(o=>{var p,l;return jn("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[o.label,o.kind==="textarea"?V("textarea",{name:o.name,required:o.required,placeholder:o.placeholder,rows:3,style:r}):o.kind==="select"?V("select",{name:o.name,required:o.required,style:r,children:((p=o.options)!=null?p:[]).map(x=>V("option",{value:x,children:x},x))}):V("input",{name:o.name,type:(l=o.inputType)!=null?l:"text",required:o.required,placeholder:o.placeholder,style:r})]},o.name)}),V("button",{type:"submit",style:Wn(n,t.palette),children:e.submitLabel})]})}function qr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(s=>s.id===n))==null?void 0:i.classes:void 0}function Kn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=Yr(e,t),r=Kn(e.like,t);return n&&r?Kr(n,{style:N(m({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function Yr(e,t){var n,r,i,s,f,a,c,o,p,l,x,R,g,y,h,v,d,w,C,E,O,b,k;try{let A=qr(e,t);switch(e.type){case"stack":{let u=(r=ce[(n=e.gap)!=null?n:"md"])!=null?r:ce.md,S=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:S?"md":void 0;return V("div",N(m({},A?{className:A}:{}),{style:m(m(m(m(m({display:"flex",flexDirection:e.direction,gap:u},e.align?{alignItems:xt[e.align]}:{}),e.justify?{justifyContent:xt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(s=ce[I])!=null?s:ce.md}:{}),S?N(m(m({},(f=t.palette)!=null&&f.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(p=(o=t.palette)==null?void 0:o.border)!=null?p:"currentColor"}`,borderRadius:(x=(l=t.palette)==null?void 0:l.radius)!=null?x:"8px"}):{}),children:((R=e.children)!=null?R:[]).map((T,G)=>{let M=xe(T,t);return M===null?null:V(Vn,{children:M},G)})}))}case"grid":{let u=(y=ce[(g=e.gap)!=null?g:"md"])!=null?y:ce.md;return V("div",N(m({},A?{className:A}:{}),{style:m(m({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${u}) / ${e.columns})), 1fr))`,gap:u},e.align?{alignItems:xt[e.align]}:{}),e.pad?{padding:(h=ce[e.pad])!=null?h:ce.md}:{}),children:((v=e.children)!=null?v:[]).map((S,I)=>{let T=xe(S,t);return T===null?null:V(Vn,{children:T},I)})}))}case"text":return A?V("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V("p",{style:m(m(m(m(m({margin:0},e.size?{fontSize:Un[e.size]}:{}),e.weight?{fontWeight:Xr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bn(e.tone,t.palette)),children:e.value});case"heading":{let u=`h${e.level}`;return A?V(u,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):V(u,{style:m(m({margin:0,fontSize:Jr[(d=e.size)!=null?d:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let u=(w=e.emphasis)!=null?w:"primary";return V("a",N(m(m({href:wt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Wn(u,t.palette,e.size)}),{children:e.label}))}case"link":return V("a",N(m(m({href:wt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return V("img",N(m({src:wt(e.src),alt:e.alt},A?{className:A}:{}),{style:m(m({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:Hr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?V("span",{className:A,children:e.value}):V("span",{style:m({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(E=(C=t.palette)==null?void 0:C.border)!=null?E:"currentColor"}`},Bn(e.tone,t.palette)),children:e.value});case"spacer":return V("div",{style:{height:(O=$n[e.size])!=null?O:$n.md}});case"divider":return V("hr",{style:{border:"none",borderTop:`1px solid ${(k=(b=t.palette)==null?void 0:b.border)!=null?k:"currentColor"}`,margin:0,width:"100%"}});case"form":return V(zr,{node:e,opts:t});default:return null}}catch(A){return null}}function kt(e,t){var s,f,a,c;let n=xe(e.tree,t);if(n===null)return null;let r=(s=e.surface)!=null&&s.like?(a=(f=t.vocabulary)==null?void 0:f.entries.find(o=>o.id===e.surface.like))==null?void 0:a.classes:void 0,i=Kn((c=e.surface)==null?void 0:c.like,t);return r?V("div",N(m({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ue,isValidElement as We}from"react";import{normalizeLeafText as Zr,skeletonFingerprint as Qr}from"@sentientui/core/region";function Ke(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Je(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function pe(e){return Ke(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+pe(n),0):We(e)?pe(Je(e)):0}function ei(e,t){return Array.isArray(t)?Ue(e,void 0,...t):Ue(e,void 0,t)}function Rt(e,t){if(Ke(e))return t;if(Array.isArray(e))return e.map(n=>Rt(n,t));if(We(e)){let n=Je(e);return pe(n)===0?e:ei(e,Rt(n,t))}return e}function Jn(e,t){return pe(e)===1?Rt(e,t):null}var Y=e=>e.join("/");function At(e,t,n){if(Ke(e)){n.leafPaths.push(t),n.texts.push(Zr(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>At(r,[...t,i],n));return}We(e)&&(n.elements.set(Y(t),e),At(Je(e),[...t,"c"],n))}function _t(e){let t={leafPaths:[],texts:[],elements:new Map};return At(e,[],t),t}function ti(e){return _t(e).texts}function Hn(e){let t=ti(e);return t.length===0?null:Qr(t)}function ni(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Xn(e,t){let n=t.reduce((i,s)=>Math.max(i,s+1),0),r=[];for(let i=0;i<n;i++){let s=t.flatMap((a,c)=>a===i?[ni(e.leafPaths[c])]:[]);if(s.length===0){r.push(null);continue}let f=s[0];for(let a of s.slice(1)){let c=new Set(a.map(Y));f=f.filter(o=>c.has(Y(o)))}r.push(f.length>0?f[f.length-1]:null)}return r}function Ct(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 Ot(e,t){let n=_t(t);if(n.texts.length!==e.leaves.length||n.texts.some((s,f)=>s!==e.leaves[f]))return null;let r=Xn(n,e.leafToNode),i=e.nodes.map((s,f)=>{let a=r[f],c=a?n.elements.get(Y(a)):void 0,o=!!c&&(typeof c.type=="string"||Ct(c)!==void 0);return N(m({},s),{restylable:o})});return N(m({},e),{nodes:i})}function zn(e,t,n){var g;let r=_t(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((y,h)=>Math.max(y,h+1),0);for(let y of Object.keys(t.nodes))if(!/^\d+$/.test(y)||Number(y)>=i)return null;let s=Xn(r,n),f=new Map;n.forEach((y,h)=>{f.has(y)||f.set(y,h)});let a=new Map(r.leafPaths.map((y,h)=>[Y(y),h])),c=new Set,o=new Map,p=!1;for(let[y,h]of Object.entries(t.nodes)){let v=Number(y),d=s[v];if(h.hidden&&(d?c.add(Y(d)):p=!0),h.like!==void 0){let w=s[h.like],C=d?r.elements.get(Y(d)):void 0,E=w?Ct(r.elements.get(Y(w))):void 0;!d||E===void 0||Ct(C)===void 0?p=!0:o.set(Y(d),E)}}let l=new Map(Object.entries((g=t.order)!=null?g:{})),x=(y,h)=>{var v;if(Ke(y)){let d=a.get(Y(h));if(d===void 0)return y;let w=n[d],C=(v=t.nodes[String(w)])==null?void 0:v.text;return C===void 0?y:f.get(w)===d?C:""}if(Array.isArray(y)){let d=y.map((w,C)=>x(w,[...h,C]));for(let[w,C]of l){let E=C.map(k=>{let A=s[k];return!A||A.length!==h.length+1||Y(A.slice(0,-1))!==Y(h)?-1:A[A.length-1]});if(E.some(k=>k<0))continue;let O=[...E].sort((k,A)=>k-A),b=[...d];O.forEach((k,A)=>{d[k]=b[E[A]]}),l.delete(w)}return d}if(We(y)){let d=Y(h);if(c.has(d))return null;let w=Je(y);if(pe(w)===0)return y;let C=x(w,[...h,"c"]),E=o.get(d),O=E!==void 0?{className:E}:void 0;return Array.isArray(C)?Ue(y,O,...C):Ue(y,O,C)}return y},R=x(e,[]);return p||l.size>0?null:R}import{jsx as ai}from"react/jsx-runtime";var Zn=new Set,Qn=new Set,er=new Set,Xe="authored.";function Ee({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:s,as:f="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:o,clientOnly:p,agentDataByVariant:l,agentData:x,variantsOnly:R=!1}){var jt,Ut;let g=L(),y=re(),h=ye(null),[v,d]=ri(!1);J(()=>{d(!0)},[]);let w=p===!0&&(!v||!g),C=He(()=>Hn(t),[t]),E=n?Object.keys(n).join("|"):"",O=He(()=>m({fp:C!=null?C:"0000000000000000",forms:!!r,compose:!0,content:pe(t)===1,ops:!1},E!==""?{authored:E.split("|"),children:!R}:{}),[C,t,r,E,R]),b=()=>{var U;let _=h.current;if(!_||!a)return null;let P=Yn(_);return P.skeleton?(U=Ot(P.skeleton,t))!=null?U:N(m({},P.skeleton),{editable:!1,nodes:P.skeleton.nodes.map($=>N(m({},$),{restylable:!1}))}):{status:P.reason}},k=ii(X,()=>n?ue(e):null,()=>null),A=k===null||!n?null:Object.prototype.hasOwnProperty.call(n,k)?`${Xe}${k}`:R?`${Xe}${Object.keys(n)[0]}`:"baseline",{config:u,arm:S,palette:I,vocabulary:T,source:G}=Fn(e,{forcedArm:A,baselineText:a?()=>{var _,P;return(P=(_=h.current)==null?void 0:_.textContent)!=null?P:null}:void 0,render:()=>O,skeleton:b,defer:w}),M=S!==""?(jt=u==null?void 0:u.blocks)==null?void 0:jt[S]:void 0,z=S!==""?(Ut=u==null?void 0:u.compose)==null?void 0:Ut[S]:void 0,F=(M!==void 0&&qn(M)||z!==void 0&&qn(z.tree))&&!r;J(()=>{!F||!D()||Zn.has(e)||(Zn.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.`))},[F,e]);let B=_=>{!g||G==="override"||(G!=="seeded"&&g.componentGoal(e,_),g.goal(_,{metadata:{componentId:e,arm:S},weight:1,stepIndex:0}))},H=t,j=!1,Z=S.startsWith(Xe)?S.slice(Xe.length):null;if((u==null?void 0:u.blocked)==="variant_history")j=!0;else if(Z!==null)n&&Object.prototype.hasOwnProperty.call(n,Z)?H=n[Z]:j=!0;else if(z!==void 0){let _=F?null:kt(z,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:B});_===null?j=!0:H=_}else if(M!==void 0){let _=F?null:xe(M,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:B});_===null?j=!0:H=_}else if((u==null?void 0:u.edits)!==void 0&&G!=="none"){let _=u.edits,P=_.fp===C?zn(t,_.edits,_.leafToNode):null;P===null?j=!0:H=P}else if((u==null?void 0:u.content)!==void 0&&G!=="none"){let _=Jn(t,u.content);_===null?j=!0:H=_}let Nt=j&&M===void 0&&z===void 0&&(u==null?void 0:u.edits)===void 0&&Z===null&&(u==null?void 0:u.blocked)===void 0;J(()=>{(u==null?void 0:u.blocked)!=="variant_history"||!D()||er.has(e)||(er.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.`))},[u==null?void 0:u.blocked,e]);let Pe=Z!==null&&!j?Z:null;J(()=>{var Q;if(!Pe||!a||!g)return;let _=h.current;if(!_)return;let P=Yn(_),U=P.skeleton?Ot(P.skeleton,n==null?void 0:n[Pe]):null,$=(Q=_.textContent)==null?void 0:Q.trim();g.reportSlots([],void 0,void 0,{[e]:[m(m({key:Pe},$?{text:$}:{}),U?{skeleton:U}:{})]})},[Pe,g,e,w]);let Dt=j&&(u==null?void 0:u.edits)!==void 0&&(G==="preloaded"||G==="client");J(()=>{var _;!Dt||!(u!=null&&u.edits)||(_=g==null?void 0:g.reportDrift)==null||_.call(g,e,u.edits.fp,C,u.edits.fp===C?"unaddressable":"fp_mismatch")},[Dt,e,C,g]);let Ge=H===t;J(()=>{var P;if(!(u!=null&&u.needsSkeleton)||!Ge)return;let _=b();_&&((P=g==null?void 0:g.reportSkeleton)==null||P.call(g,e,_))},[u==null?void 0:u.needsSkeleton,Ge,e,g,w]),J(()=>{if(!Ge)return;let _=hn(e);if(!_)return;let P=b();bn(_,P&&"status"in P?{status:P.status}:{skeleton:P})},[e,Ge,w]),J(()=>{!Nt||!D()||Qn.has(e)||(Qn.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.`))},[Nt,e]);let tt=u!=null&&u.blocks?Object.keys(u.blocks).sort().join("|"):"";J(()=>ve({id:e,arms:tt===""?void 0:tt.split("|")}),[e,tt]);let Lt=ye(null);J(()=>{!g||G==="none"||G==="seeded"||G==="override"||S===""||j||Lt.current!==S&&(Lt.current=S,le(g,y,e,S))},[g,y,e,S,G,j]);let oe=G!=="none"&&G!=="seeded"&&!j,nt=oe?S:"",Ft=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);J(()=>{if(!g||!i||G==="override")return;let _=h.current;if(!_)return;let P=se(i),U=ee(i),$=!1;return te(_,q(i),{fireGoal:()=>{$||($=!0,oe&&(U!==void 0?g.componentGoal(e,P,{value:U}):g.componentGoal(e,P)),g.goal(P,m({metadata:{componentId:e,arm:nt},weight:1,stepIndex:0},U!==void 0?{value:U}:{})))},fireStep:(Q,Ie,it)=>{oe&&g.componentGoal(e,Q,{reward:Ie}),g.goal(Q,{metadata:{componentId:e,arm:nt},weight:Ie,stepIndex:it})}},P)},[g,e,Ft,S,G,j,oe,nt,w]);let rt=He(()=>i?q(i):null,[Ft]);J(()=>{G==="override"||!g||!c||!rt||ae(g,y,e,c,rt)},[g,y,e,c,rt,G]);let Vt=ye(o);Vt.current=o;let Mt=ye(new Set),mr=o?JSON.stringify(o):"";J(()=>{if(!g||G==="override"||!oe||S==="")return;let _=h.current;if(_)return oi((P,U={})=>{var Wt,Kt,Jt;g.track({projectId:y,componentId:e,variantId:S,eventType:"micro_signal",payload:m({signalType:P},U)});let $=(Wt=Vt.current)==null?void 0:Wt[P];if(!$||Mt.current.has(P))return;Mt.current.add(P);let Q=typeof $=="string"?$:$.name,Ie=typeof $=="string"?1:(Kt=$.weight)!=null?Kt:1,it=typeof $=="string"?0:(Jt=$.stepIndex)!=null?Jt:0;g.goal(Q,{metadata:m({componentId:e,arm:S,signalType:P},U),weight:Ie,stepIndex:it})},_,Date.now())},[g,y,e,S,G,oe,mr,w]);let $t=ye({agentData:x,agentDataByVariant:l});$t.current={agentData:x,agentDataByVariant:l};let Bt=ye(null);J(()=>{var Q;if(!g||G==="override"||!oe||S===""||Bt.current===S)return;let{agentData:_,agentDataByVariant:P}=$t.current,U=Z!=null?Z:S,$=P!==void 0?Object.prototype.hasOwnProperty.call(P,U)?P[U]:void 0:_;$!==void 0&&(Bt.current=S,(Q=g.reportAgentData)==null||Q.call(g,e,S,$))},[g,e,S,oe,Z,G]);let Te=ye(null);J(()=>{let _=h.current;if(_){if(Te.current===null){Te.current=S;return}Te.current!==S&&(Te.current=S,si(_))}},[S,w]);let pr=He(()=>m({"data-sentient-slot":e},S!==""?{"data-sentient-arm":S}:{}),[e,S]);return w?null:ai(f,N(m({ref:h,className:s},pr),{children:H}))}import{jsx as ke}from"react/jsx-runtime";function di(e){var p,l;let{client:t,variantId:n,content:r,ref:i}=Be(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[s,f]=tr(!1);ci(()=>{f(!0)},[]);let a=(p=e.as)!=null?p:"div";if(e.clientOnly&&(!s||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,o=c===null?r:null;return D()&&c===null&&o===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.`),ke(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:o})}var fi=li(di,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function gi(e){if(e.variants===void 0)return ke(Ee,m({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Re(n,["variants"]);return ke(Ee,N(m({},i),{children:t.children,variants:r}))}return ke(mi,m({},t))}function mi(e){var l;let[t,n]=tr(null),{id:r}=e,i=ui(()=>n(r),[r]),s=L(),f=Fe().includes(r)||((l=s==null?void 0:s.isUnified)==null?void 0:l.call(s,r))===!0;if(t!==r&&!f)return ke(fi,N(m({},e),{onUnified:i}));let x=e,{variants:a,children:c}=x,o=Re(x,["variants","children"]),p=Object.keys(a)[0];return ke(Ee,N(m({},o),{variants:a,variantsOnly:!0,children:p!==void 0?a[p]:null}))}import{useEffect as ze,useMemo as pi,useRef as Et,useState as nr,useSyncExternalStore as yi}from"react";import{jsx as Si}from"react/jsx-runtime";function vi({id:e,default:t,component:n="span",className:r,goal:i}){var O;let s=L(),f=re(),a=Ve(),c=_e(),o=Et(null),p=Et(null),l=yi(X,()=>ue(e),()=>null),[x,R]=nr(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.content)!=null?k:null}),[g,y]=nr(()=>{var b,k;return(k=(b=s==null?void 0:s.getAssignment(e,c))==null?void 0:b.variantId)!=null?k:null});ze(()=>{if(l||!s)return;let b=s.getAssignment(e,c);if((b==null?void 0:b.content)!==void 0){y(b.variantId),R(b.content);return}let k=!1;return s.assign(e).then(A=>{if(!k){if(!A){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}y(A.variantId),A.content&&R(A.content)}}),()=>{k=!0}},[s,e,c,l]),ze(()=>{l||!s||!g||!f||o.current!==g&&(o.current=g,s.track({projectId:f,componentId:e,variantId:g,eventType:"variant_assigned",payload:{}}),a==null||a(e,g))},[s,g,f,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),v=pi(()=>i===void 0?null:q(i),[h]),d=i===void 0?null:typeof i=="string"?i:v.type,w=Et(!1);ze(()=>{w.current=!1},[g,h]),ze(()=>{if(l||!s||!g||!f||!v||!d)return;let b=p.current;if(!b)return;let k=ee(v);return te(b,v,{fireGoal:()=>{w.current||(w.current=!0,s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:d,payload:m({reward:1},k!==void 0?{goalValue:k}:{})}),s.goal(d,m({metadata:{componentId:e,variantId:g},weight:1,stepIndex:0},k!==void 0?{value:k}:{})))},fireStep:(A,u,S)=>{s.track({projectId:f,componentId:e,variantId:g,eventType:"goal_achieved",goalType:A,payload:{reward:u}}),s.goal(A,{metadata:{},weight:u,stepIndex:S})}})},[s,g,f,e,v,d,l]);let C=x!=null?x:t;if(l){let b=s==null?void 0:s.getAssignment(e,c);C=b&&b.variantId===l&&(O=b.content)!=null?O:t}return Si(n,{ref:b=>{p.current=b},className:r,children:C})}import{useCallback as hi,useRef as bi}from"react";function Pt(e){let t=L(),n=bi(new Set);return hi((r,i)=>{var s,f;if(!ue(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,m(m(m({metadata:(s=i==null?void 0:i.metadata)!=null?s:{},weight:(f=i==null?void 0:i.reward)!=null?f: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 wi,useRef as rr}from"react";function xi(e,t={}){let c=t,{componentId:n}=c,r=Re(c,["componentId"]),i=L(),s=Pt(n!=null?n:""),f=rr(!1),a=rr(r);a.current=r,wi(()=>{if(!i||f.current||i.gated)return;f.current=!0;let{metadata:o,reward:p,value:l,currency:x,externalId:R}=a.current;if(n){s(e,a.current);return}i.goal(e,m(m(m({metadata:o!=null?o:{},weight:p!=null?p:1,stepIndex:0},l!==void 0?{value:l}:{}),x!==void 0?{currency:x}:{}),R!==void 0?{externalId:R}:{}))},[i,n,e,s])}import{renderPrePaintScript as ki}from"@sentientui/core";import{confidenceBand as Ri}from"@sentientui/policy";import{jsx as _i}from"react/jsx-runtime";function Gt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Ai(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Gt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Gt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Gt(Ri(e.persona.confidence))+");}catch(e){}})();":ki(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Ci(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:_i("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Ai(e)}})}import{useEffect as Ze,useMemo as It,useRef as Ni}from"react";import{validateSlotDecl as Di}from"@sentientui/policy";import{useEffect as Tt,useReducer as Oi,useState as Ei,useSyncExternalStore as ir}from"react";import{armOfResult as qe,baselineResultFor as Pi}from"@sentientui/core";import{confidenceBand as Gi}from"@sentientui/policy";function Ye(e,t){let n=L(),r=Me(),[,i]=Oi(l=>l+1,0),s=ir(X,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),f=s===void 0?r[e]:void 0,a=s===void 0&&f===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&s===void 0&&f===void 0&&a===null;Tt(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(x=>{!l&&x&&i()}),()=>{l=!0}},[n,e,c]);let o=(()=>{if(s!==void 0)return{result:s,arm:qe(s),source:"override"};if(f!==void 0)return{result:f,arm:qe(f),source:"preloaded"};if(a!==null){let x=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:qe(a),source:x?"client":"seeded"}}let l=Pi(t);return{result:l,arm:qe(l),source:"baseline"}})(),p=o.source==="preloaded"||o.source==="override";return Tt(()=>{var x;if(!n||n.isLocal===!0||p||!n.decideSlots)return;let l=(x=n.onSlotsChanged)==null?void 0:x.call(n,i);return n.decideSlots([t]),()=>{var R;(R=n.cancelSlots)==null||R.call(n,[e]),l==null||l()}},[n,e,p]),o}function Ti(){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 Ii(){let e=L(),t=En();ir(X,nn,()=>0);let[n,r]=Ei(!1);Tt(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Gi(a.confidence)});if(!n)return t?i(t):null;let s=Ti();if(s)return i(s);if(t)return i(t);let f=e?e.getPersona():null;return f?i(f):null}var or=new Set;function Li(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function Fi(e,t,n){let r=L(),i=re(),s=JSON.stringify(t),f=It(()=>({id:e,dims:t}),[e,s]),{result:a,arm:c,source:o}=Ye(e,f),p=It(()=>typeof a=="string"?{}:a,[c]);if(D()&&!or.has(e)){or.add(e);let y=Di({id:e,dims:Object.fromEntries(Object.entries(t).map(([v,d])=>[v,[...d]]))}),h=Object.values(t).reduce((v,d)=>v*d.length,1);y.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${y.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);Ze(()=>ve({id:e,dims:t}),[e]);let x=Ni(null);Ze(()=>{!r||o==="baseline"||o==="seeded"||o==="override"||x.current===c||(x.current=c,le(r,i,e,c))},[r,i,e,c,o]);let R=n==null?void 0:n.funnel;Ze(()=>{var y;!r||!R||o==="override"||ae(r,i,e,R,q((y=n==null?void 0:n.goal)!=null?y:"click"))},[r,i,e,R,l,o]),Ze(()=>{if(!r||!(n!=null&&n.goal)||o==="override"||o==="baseline"||o==="seeded")return;let y=document.querySelector(`[data-sentient-slot="${Li(e)}"]`);if(!y){D()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=se(n.goal),v=ee(n.goal),d=!1;return te(y,q(n.goal),{fireGoal:()=>{d||(d=!0,v!==void 0?r.componentGoal(e,h,{value:v}):r.componentGoal(e,h),r.goal(h,m({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},v!==void 0?{value:v}:{})))},fireStep:(w,C,E)=>{r.componentGoal(e,w,{reward:C}),r.goal(w,{metadata:{componentId:e,arm:c},weight:C,stepIndex:E})}},h)},[r,e,l,c,o]);let g=It(()=>{let y={"data-sentient-slot":e};for(let[h,v]of Object.entries(p))y[`data-${h}`]=v;return y},[e,p]);return{tokens:p,props:g}}import{useCallback as Vi,useEffect as sr,useMemo as Mi}from"react";var ar=new Set,lr=new Set;function $i(e,t){var g,y;if(D()&&!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:s,goalLabel:f,ref:a,nodeRef:c}=Be(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),o=(g=i!=null?i:r[0])!=null?g:"",p=t.variants[o],l=Fe().includes(e)||((y=n==null?void 0:n.isUnified)==null?void 0:y.call(n,e))===!0;sr(()=>{!l||!D()||lr.has(e)||(lr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),sr(()=>{if(!D()||!n)return;let h=setTimeout(()=>{!c.current&&!ar.has(e)&&(ar.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let x=Vi((h,v)=>{var w,C;if(s)return;let d=h!=null?h:f;d&&(n==null||n.componentGoal(e,d,v),n==null||n.goal(d,m(m(m({metadata:(w=v==null?void 0:v.metadata)!=null?w:{},weight:(C=v==null?void 0:v.reward)!=null?C:1,stepIndex:0},(v==null?void 0:v.value)!==void 0?{value:v.value}:{}),(v==null?void 0:v.currency)!==void 0?{currency:v.currency}:{}),(v==null?void 0:v.externalId)!==void 0?{externalId:v.externalId}:{})))},[n,e,f,s]),R=Mi(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":o}),[a,e,o]);return{variant:o,value:p,bind:R,fireGoal:x}}import{Children as Bi,isValidElement as ji,useEffect as Qe,useMemo as ur,useRef as cr}from"react";import{jsx as Wi}from"react/jsx-runtime";var et=new Set;function Ui(e){var v;let t=L(),n=re(),r=cr(null),i=Object.keys(e.arrangements).join(" "),s=ur(()=>Object.keys(e.arrangements),[i]),f=ur(()=>m({id:e.id,arms:s},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,s,e.baseline]),{arm:a,source:c}=Ye(e.id,f);D()&&e.baseline!==void 0&&e.baseline!==s[0]&&!et.has(e.id+":baseline")&&(et.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${s[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let o=Bi.toArray(e.children).filter(ji),p=new Map;for(let d of o)p.set(String((v=d.key)!=null?v:"").replace(/^\.\$/,""),d);let l=e.arrangements[a],x=l!==void 0&&l.length===o.length&&l.every(d=>p.has(d));D()&&l!==void 0&&!x&&!et.has(e.id+":keys")&&(et.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let R=x?l.map(d=>p.get(d)):o;Qe(()=>ve({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let g=cr(null);Qe(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||g.current===a||(g.current=a,le(t,n,e.id,a))},[t,n,e.id,a,c]);let y=e.funnel;Qe(()=>{var d;!t||!y||c==="override"||ae(t,n,e.id,y,q((d=e.goal)!=null?d:"click"))},[t,n,e.id,y,c]);let h=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return Qe(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let d=r.current;if(!d)return;let w=se(e.goal),C=ee(e.goal),E=!1;return te(d,q(e.goal),{fireGoal:()=>{E||(E=!0,C!==void 0?t.componentGoal(e.id,w,{value:C}):t.componentGoal(e.id,w),t.goal(w,m({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},C!==void 0?{value:C}:{})))},fireStep:(O,b,k)=>{t.componentGoal(e.id,O,{reward:b}),t.goal(O,{metadata:{componentId:e.id,arm:a},weight:b,stepIndex:k})}},w)},[t,e.id,h,a,c]),Wi("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:R})}import{deriveSessionSegment as Ki}from"@sentientui/core";var Ji=["page","blocks","layoutOrder"],dr=new Map;function Hi(e,t){dr.set(e,t)}function fr(e){return dr.get(e)}function Xi(e){var i,s;let t=(s=(i=e.content)!=null?i:fr(e.page))!=null?s:{},n={};for(let[f,a]of Object.entries(t))Ji.includes(f)||(n[f]=a);let r=N(m({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function zi(e){return`<script type="application/ld+json">${gr(e)}</script>`}function gr(e){return JSON.stringify(m({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function qi(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 el}from"@sentientui/core";import{consentWatcher as rl}from"@sentientui/core/consent";export{gi as Adaptive,Ui as AdaptiveGroup,Tr as AdaptiveProvider,Ee as AdaptiveSlot,vi as AdaptiveText,Ci as SentientPersonaScript,Xi as buildAgentFeed,rl as consentWatcher,Hi as defineAgentContent,Ki as detectSegment,fr as getAgentContent,el as grantConsent,zi as renderAgentJsonLd,gr as renderAgentJsonLdBody,qi as renderAgentMarkdown,xe as renderBlocks,kt as renderCompose,$i as useAdaptive,Dr as useAdaptiveApiBaseUrl,Pt as useAdaptiveGoal,Ii as useAdaptivePersona,Fi as useAdaptiveTokens,ht as useAssignment,vt as useInitialAssignments,Nr as useLayoutOrder,xi as usePageGoal,L as useSentient,_e as useSessionSegment};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/testing/react.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Ae=Object.create;var F=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?F(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 Ne=(e,t)=>{for(var n in t)F(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&&F(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?F(n,"default",{value:e,enumerable:!0}):n,e)),Fe=e=>se(F({},"__esModule",{value:!0}),e);var tt={};Ne(tt,{renderWithSentient:()=>et});module.exports=Fe(tt);var Ee=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Ge=new Map,We=new Map;function ae(e,t){Ge.set(e,t);let n=We.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Ue={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Ue;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function j(){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),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,a,d)=>e.assign(t,n,i,a,d),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 Me="sentient:overrides-changed";function G(){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(Me))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var $e={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function H(){if(typeof window=="undefined")return $e;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 Ke(){H().version+=1;for(let e of H().listeners)e()}function z(e){W()&&(H().sections=[...e],Ke())}var fe="0.40.0",J=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function Be(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Be()[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 d=n.slice(0,i.index)+a;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var X="__snt_editor_token",D=null,q=!1;function me(){return q}function He(){try{return sessionStorage.getItem(X)}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 q=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return q=!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(X,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function ye(){try{sessionStorage.removeItem(X)}catch(e){}}var ve="sentient_preview_cell",_e="sentient_refresh_region",Y="sentient-cell-preview-bar",A="__preview__",ze=null;function Se(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Y))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),G();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let g=t.slice(0,d),O=t.slice(d+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(U(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){U(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{U("Nothing to preview in that square yet.");return}G(),U(`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(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var a;if(document.getElementById(Y))return;let t=document.createElement("div");t.id=Y,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 d=new URL(window.location.href);d.searchParams.delete(ve),d.searchParams.delete(_e),window.location.assign(d.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:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Ce,debug:!1}),be=!1,Q=new Set;function Ye(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,d]=(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&&Q.add(t),d(w!=null?w:Q.has(t)?!1:null)};L(),y=E.subscribe(L)}),()=>{k=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function xe(e){var Z,ee,te;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:qe()}),[a,d]=(0,o.useState)(j());(0,o.useEffect)(()=>ce(()=>d(j())),[]),(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?(Z=O.granted)!=null?Z:Q.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 N,ne;if(p.current&&l===!1&&(x.current=[]),l===!1&&k.current&&(p.current&&((N=y.current)==null||N.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,initialUnified:e.initialUnified,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},J?{sdk:J}:{}),u=!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(nt){}},0)},R=_=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{u||(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:_})=>{u||(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;u=!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 u;try{u=await t.fetchWeights()}catch(s){return}if(!r)for(let s of u){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=(ee=e.ssrFallback)!=null?ee:"first",S=((te=e.apiBaseUrl)!=null?te: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 u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[u],r[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` 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){z(r);return}e.declaredSections&&e.declaredSections.length>0&&z(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!W()||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(!W())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]"),u=>u.getAttribute("data-sentient-id"))),m=r.filter(u=>!f.has(u));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(u=>`"${u}"`).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,u,s,b,C,R,N;return{client:h,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(f=e.initialUnified)!=null?f:Qe,sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(m=e.initialLayoutOrder)!=null?m:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(s=e.initialSlotConfig)!=null?s:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(R=e.initialPersona)!=null?R:null,apiBaseUrl:S,debug:(N=e.debug)!=null?N:!1}},[h,e.apiKey,e.initialAssignments,e.initialUnified,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})}var Qe=[];function Ze(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 d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",Ze((a=e.confidence)!=null?a:1))}catch(d){}}else delete t.__sentient_persona_override;G()}var Pe=require("react/jsx-runtime");function et(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 F=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?F(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 Ne=(e,t)=>{for(var n in t)F(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&&F(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?F(n,"default",{value:e,enumerable:!0}):n,e)),Fe=e=>se(F({},"__esModule",{value:!0}),e);var tt={};Ne(tt,{renderWithSentient:()=>et});module.exports=Fe(tt);var Ee=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Ge=new Map,We=new Map;function ae(e,t){Ge.set(e,t);let n=We.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Ue={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Ue;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function j(){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),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,a,d)=>e.assign(t,n,i,a,d),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 Me="sentient:overrides-changed";function G(){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(Me))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var $e={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function H(){if(typeof window=="undefined")return $e;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 Ke(){H().version+=1;for(let e of H().listeners)e()}function z(e){W()&&(H().sections=[...e],Ke())}var fe="0.40.1",J=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function Be(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Be()[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 d=n.slice(0,i.index)+a;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var X="__snt_editor_token",D=null,q=!1;function me(){return q}function He(){try{return sessionStorage.getItem(X)}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 q=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return q=!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(X,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function ye(){try{sessionStorage.removeItem(X)}catch(e){}}var ve="sentient_preview_cell",_e="sentient_refresh_region",Y="sentient-cell-preview-bar",A="__preview__",ze=null;function Se(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Y))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),G();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let g=t.slice(0,d),O=t.slice(d+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(U(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){U(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{U("Nothing to preview in that square yet.");return}G(),U(`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(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var a;if(document.getElementById(Y))return;let t=document.createElement("div");t.id=Y,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 d=new URL(window.location.href);d.searchParams.delete(ve),d.searchParams.delete(_e),window.location.assign(d.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:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Ce,debug:!1}),be=!1,Q=new Set;function Ye(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,d]=(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&&Q.add(t),d(w!=null?w:Q.has(t)?!1:null)};L(),y=E.subscribe(L)}),()=>{k=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function xe(e){var Z,ee,te;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:qe()}),[a,d]=(0,o.useState)(j());(0,o.useEffect)(()=>ce(()=>d(j())),[]),(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?(Z=O.granted)!=null?Z:Q.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 N,ne;if(p.current&&l===!1&&(x.current=[]),l===!1&&k.current&&(p.current&&((N=y.current)==null||N.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,initialUnified:e.initialUnified,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},J?{sdk:J}:{}),u=!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(nt){}},0)},R=_=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{u||(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:_})=>{u||(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;u=!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 u;try{u=await t.fetchWeights()}catch(s){return}if(!r)for(let s of u){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=(ee=e.ssrFallback)!=null?ee:"first",S=((te=e.apiBaseUrl)!=null?te: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 u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[u],r[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` 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){z(r);return}e.declaredSections&&e.declaredSections.length>0&&z(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!W()||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(!W())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]"),u=>u.getAttribute("data-sentient-id"))),m=r.filter(u=>!f.has(u));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(u=>`"${u}"`).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,u,s,b,C,R,N;return{client:h,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(f=e.initialUnified)!=null?f:Qe,sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(m=e.initialLayoutOrder)!=null?m:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(s=e.initialSlotConfig)!=null?s:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(R=e.initialPersona)!=null?R:null,apiBaseUrl:S,debug:(N=e.debug)!=null?N:!1}},[h,e.apiKey,e.initialAssignments,e.initialUnified,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})}var Qe=[];function Ze(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 d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",Ze((a=e.confidence)!=null?a:1))}catch(d){}}else delete t.__sentient_persona_override;G()}var Pe=require("react/jsx-runtime");function et(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
|
package/dist/testing/react.mjs
CHANGED
|
@@ -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 qe}from"@testing-library/react";import{createContext as Ue,useContext as xt,useEffect as _,useMemo as Se,useRef as x,useState as M,useSyncExternalStore as Rt}from"react";import{deriveSessionSegment as Me,init as $e}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 i of n)try{i(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),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,l,c)=>e.assign(t,n,i,l,c),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 G(){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 W(){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 j(){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(){j().version+=1;for(let e of j().listeners)e()}function H(e){W()&&(j().sections=[...e],De())}var ce="0.40.0",z=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 Ne(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ne()[e]=t}function ue(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let l=n.slice(i.index+i[0].length);i[1]!="&"&&l[0]=="&"&&(l=i[1]+l.slice(1));let c=n.slice(0,i.index)+l;history.replaceState(history.state,"",c?"#"+c:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",L=null,J=!1;function fe(){return J}function Fe(){try{return sessionStorage.getItem(q)}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 J=!!n,L=Promise.resolve(n?{token:n,fresh:!1}:null),L}return J=!0,L=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(l){}return{token:i,fresh:!0}}).catch(()=>({error:0})),L}function ge(){try{sessionStorage.removeItem(q)}catch(e){}}var pe="sentient_preview_cell",me="sentient_refresh_region",X="sentient-cell-preview-bar",O="__preview__",Ge=null;function ye(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(X))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 i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(i);if(!fe())return;if(n){Ge={slotId:n,session:l,base:i},V(n,{kind:"arms"}),D(n,O),G();return}if(!t)return;let c=t.lastIndexOf("~");if(c<=0)return;let f=t.slice(0,c),I=t.slice(c+1);l.then(s=>s?"token"in s?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(U(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){U(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{U("Nothing to preview in that square yet.");return}G(),U(`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(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var l;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=()=>{ge();let c=new URL(window.location.href);c.searchParams.delete(pe),c.searchParams.delete(me),window.location.assign(c.toString())},t.append(n,i),((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: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})}import{jsx as ze}from"react/jsx-runtime";function Ke(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var we="https://api.sentient-ui.com/v1",Be=Ue({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:we,debug:!1}),he=!1,Y=new Set;function je(e,t,n){let i=x(n);i.current=n;let[l,c]=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,N=()=>{let h=P.refused()&&P.read()!==!0;h&&!S&&(T(t),i.current()),S=h,I(h);let w=P.read();w!==null&&Y.add(t),c(w!=null?w:Y.has(t)?!1:null)};N(),m=P.subscribe(N)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function be(e){var Q,Z,ee;let[t,n]=M(null),[i]=M(()=>{var r;return(r=e.sessionSegment)!=null?r:Ke()}),[l,c]=M(B());_(()=>se(()=>c(B())),[]),_(()=>{ye(e.apiBaseUrl),_e(e.apiBaseUrl)},[]);let f=x(()=>{}),I=je(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Q=I.granted)!=null?Q:Y.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 r=m.current;r!=null&&r.gated?r.dispose():(u=r==null?void 0:r.takeHeld)==null||u.call(r)},_(()=>{var F,te;if(g.current&&s===!1&&(R.current=[]),s===!1&&E.current&&(g.current&&((F=m.current)==null||F.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 r=s!==!1;r&&(T.current=!1);let u=v=>{!r&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!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(Ye){}},0)},k=v=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{d||(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})=>{d||(o=v($(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=r,C(o),n(o),k(o))}):(o=$e(p),u(o),m.current=o,E.current=r,C(o),n(o),k(o)),()=>{var v,A;d=!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 r=!1,u=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(o){return}if(!r)for(let o of d){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()=>{r=!0,clearInterval(p)}},[t]);let P=(Z=e.ssrFallback)!=null?Z:"first",S=((ee=e.apiBaseUrl)!=null?ee:we).replace(/\/$/,""),N=x(null);_(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:S},u=N.current;if(N.current=r,u!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[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]),_(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||le({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]),_(()=>{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]),_(()=>{!W()||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(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),p=r.filter(d=>!u.has(d));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(d=>`"${d}"`).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 r,u,p,d,o,b,C,k,F;return{client:h,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(u=e.initialUnified)!=null?u:He,sessionSegment:i,ssrFallback:P,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(d=e.initialSlots)!=null?d:{},initialSlotConfig:(o=e.initialSlotConfig)!=null?o:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:S,debug:(F=e.debug)!=null?F:!1}},[h,e.apiKey,e.initialAssignments,e.initialUnified,i,P,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return ze(Be.Provider,{value:w,children:e.children})}var He=[];function Je(e){return e<.3?"low":e<.7?"medium":"high"}function Ce(e={}){var n,i,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:(i=e.confidence)!=null?i:1};try{let c=document.documentElement;c.setAttribute("data-sentient-persona",e.persona),c.setAttribute("data-sentient-confidence",Je((l=e.confidence)!=null?l:1))}catch(c){}}else delete t.__sentient_persona_override;G()}import{jsx as Xe}from"react/jsx-runtime";function Bt(e,t={},n){return Ce(t),qe(Xe(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 qe}from"@testing-library/react";import{createContext as Ue,useContext as xt,useEffect as _,useMemo as Se,useRef as x,useState as M,useSyncExternalStore as Rt}from"react";import{deriveSessionSegment as Me,init as $e}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 i of n)try{i(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),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,l,c)=>e.assign(t,n,i,l,c),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 G(){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 W(){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 j(){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(){j().version+=1;for(let e of j().listeners)e()}function H(e){W()&&(j().sections=[...e],De())}var ce="0.40.1",z=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 Ne(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ne()[e]=t}function ue(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let l=n.slice(i.index+i[0].length);i[1]!="&"&&l[0]=="&"&&(l=i[1]+l.slice(1));let c=n.slice(0,i.index)+l;history.replaceState(history.state,"",c?"#"+c:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",L=null,J=!1;function fe(){return J}function Fe(){try{return sessionStorage.getItem(q)}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 J=!!n,L=Promise.resolve(n?{token:n,fresh:!1}:null),L}return J=!0,L=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(l){}return{token:i,fresh:!0}}).catch(()=>({error:0})),L}function ge(){try{sessionStorage.removeItem(q)}catch(e){}}var pe="sentient_preview_cell",me="sentient_refresh_region",X="sentient-cell-preview-bar",O="__preview__",Ge=null;function ye(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(X))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 i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(i);if(!fe())return;if(n){Ge={slotId:n,session:l,base:i},V(n,{kind:"arms"}),D(n,O),G();return}if(!t)return;let c=t.lastIndexOf("~");if(c<=0)return;let f=t.slice(0,c),I=t.slice(c+1);l.then(s=>s?"token"in s?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(U(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){U(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{U("Nothing to preview in that square yet.");return}G(),U(`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(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var l;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=()=>{ge();let c=new URL(window.location.href);c.searchParams.delete(pe),c.searchParams.delete(me),window.location.assign(c.toString())},t.append(n,i),((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: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})}import{jsx as ze}from"react/jsx-runtime";function Ke(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var we="https://api.sentient-ui.com/v1",Be=Ue({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:we,debug:!1}),he=!1,Y=new Set;function je(e,t,n){let i=x(n);i.current=n;let[l,c]=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,N=()=>{let h=P.refused()&&P.read()!==!0;h&&!S&&(T(t),i.current()),S=h,I(h);let w=P.read();w!==null&&Y.add(t),c(w!=null?w:Y.has(t)?!1:null)};N(),m=P.subscribe(N)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function be(e){var Q,Z,ee;let[t,n]=M(null),[i]=M(()=>{var r;return(r=e.sessionSegment)!=null?r:Ke()}),[l,c]=M(B());_(()=>se(()=>c(B())),[]),_(()=>{ye(e.apiBaseUrl),_e(e.apiBaseUrl)},[]);let f=x(()=>{}),I=je(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Q=I.granted)!=null?Q:Y.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 r=m.current;r!=null&&r.gated?r.dispose():(u=r==null?void 0:r.takeHeld)==null||u.call(r)},_(()=>{var F,te;if(g.current&&s===!1&&(R.current=[]),s===!1&&E.current&&(g.current&&((F=m.current)==null||F.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 r=s!==!1;r&&(T.current=!1);let u=v=>{!r&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!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(Ye){}},0)},k=v=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{d||(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})=>{d||(o=v($(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=r,C(o),n(o),k(o))}):(o=$e(p),u(o),m.current=o,E.current=r,C(o),n(o),k(o)),()=>{var v,A;d=!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 r=!1,u=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(o){return}if(!r)for(let o of d){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()=>{r=!0,clearInterval(p)}},[t]);let P=(Z=e.ssrFallback)!=null?Z:"first",S=((ee=e.apiBaseUrl)!=null?ee:we).replace(/\/$/,""),N=x(null);_(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:S},u=N.current;if(N.current=r,u!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[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]),_(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||le({apiKey:e.apiKey,apiBaseUrl:S,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,S]),_(()=>{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]),_(()=>{!W()||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(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),p=r.filter(d=>!u.has(d));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(d=>`"${d}"`).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 r,u,p,d,o,b,C,k,F;return{client:h,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(u=e.initialUnified)!=null?u:He,sessionSegment:i,ssrFallback:P,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(d=e.initialSlots)!=null?d:{},initialSlotConfig:(o=e.initialSlotConfig)!=null?o:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:S,debug:(F=e.debug)!=null?F:!1}},[h,e.apiKey,e.initialAssignments,e.initialUnified,i,P,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,S,e.debug]);return ze(Be.Provider,{value:w,children:e.children})}var He=[];function Je(e){return e<.3?"low":e<.7?"medium":"high"}function Ce(e={}){var n,i,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:(i=e.confidence)!=null?i:1};try{let c=document.documentElement;c.setAttribute("data-sentient-persona",e.persona),c.setAttribute("data-sentient-confidence",Je((l=e.confidence)!=null?l:1))}catch(c){}}else delete t.__sentient_persona_override;G()}import{jsx as Xe}from"react/jsx-runtime";function Bt(e,t={},n){return Ce(t),qe(Xe(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.40.
|
|
3
|
+
"version": "0.40.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"llms.txt"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@sentientui/core": "0.39.
|
|
81
|
+
"@sentientui/core": "0.39.1",
|
|
82
82
|
"@sentientui/policy": "0.16.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|