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