@sentientui/react 0.41.0 → 0.41.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/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/testing/react.js +1 -1
- package/dist/testing/react.mjs +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Tr=Object.create;var Le=Object.defineProperty,Ir=Object.defineProperties,Nr=Object.getOwnPropertyDescriptor,Dr=Object.getOwnPropertyDescriptors,Lr=Object.getOwnPropertyNames,We=Object.getOwnPropertySymbols,Fr=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Zt=(e,t,n)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))pt.call(t,n)&&Zt(e,n,t[n]);if(We)for(var n of We(t))Qt.call(t,n)&&Zt(e,n,t[n]);return e},V=(e,t)=>Ir(e,Dr(t));var Fe=(e,t)=>{var n={};for(var r in e)pt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&We)for(var r of We(e))t.indexOf(r)<0&&Qt.call(e,r)&&(n[r]=e[r]);return n};var Vr=(e,t)=>{for(var n in t)Le(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lr(t))!pt.call(e,i)&&i!==n&&Le(e,i,{get:()=>t[i],enumerable:!(r=Nr(t,i))||r.enumerable});return e};var Ke=(e,t,n)=>(n=e!=null?Tr(Fr(e)):{},en(t||!e||!e.__esModule?Le(n,"default",{value:e,enumerable:!0}):n,e)),Mr=e=>en(Le({},"__esModule",{value:!0}),e);var yi={};Vr(yi,{Adaptive:()=>or,AdaptiveGroup:()=>wr,AdaptiveProvider:()=>Gn,AdaptiveSlot:()=>Ne,AdaptiveText:()=>sr,SentientPersonaScript:()=>dr,buildAgentFeed:()=>Ar,consentWatcher:()=>Er.consentWatcher,defineAgentContent:()=>Rr,detectSegment:()=>Ft.deriveSessionSegment,getAgentContent:()=>Vt,grantConsent:()=>Or.grantConsent,renderAgentJsonLd:()=>Cr,renderAgentJsonLdBody:()=>Mt,renderAgentMarkdown:()=>_r,renderBlocks:()=>xe,renderCompose:()=>nt,useAdaptive:()=>br,useAdaptiveApiBaseUrl:()=>Mn,useAdaptiveGoal:()=>lt,useAdaptivePersona:()=>mr,useAdaptiveTokens:()=>vr,useAssignment:()=>et,useInitialAssignments:()=>ze,useLayoutOrder:()=>Nn,usePageGoal:()=>lr,useSentient:()=>$,useSessionSegment:()=>Ie});module.exports=Mr(yi);var C=require("react"),Xe=require("@sentientui/core");var tn=new Map,Je=new Map;function nn(e,t){let n=Je.get(e);return n||(n=new Set,Je.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Je.delete(e)}}function rn(e,t){tn.set(e,t);let n=Je.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function yt(e){var t;return(t=tn.get(e))!=null?t:null}var $r={on:!1,listeners:new Set};function on(){if(typeof window=="undefined")return $r;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function vt(){return on().on}function sn(e){let t=on().listeners;return t.add(e),()=>{t.delete(e)}}function an(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var St="sentient:overrides-changed";function ln(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ht(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(St))}function Q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(St,e),()=>window.removeEventListener(St,e))}function un(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function te(e){return typeof e=="string"?{type:"click"}:e}function pe(e){return typeof e=="string"?e:e.type}function le(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var bt=new Set,wt=!1;function cn(e){if(bt.has(e))return!0;if(bt.add(e),!wt){wt=!0;let t=()=>{wt=!1,bt.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function dn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Br(r))return!0;r=r.parentElement}return!1}function ue(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,y=[];return t.steps.forEach(({goal:l,name:w,weight:x},m)=>{let v=(h=!1)=>{s.has(m)||h&&r!==void 0&&cn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(l.type==="click"){let h=S=>{let f=S.target;f instanceof Element&&dn(f,e,l.selector)&&v()};e.addEventListener("click",h),y.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=S=>{S.target instanceof HTMLFormElement&&e.contains(S.target)&&v()};e.addEventListener("submit",h),y.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),S=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){v(!0),S.disconnect();break}},{threshold:[h]});S.observe(e),y.push(()=>S.disconnect())}}),()=>{for(let l of y)l()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,y)=>y)),u=()=>{r!==void 0&&cn(r)||n.fireGoal()},a=(s,y=!1)=>{o.delete(s),o.size===0&&(y?u():n.fireGoal())},c=[];return i.forEach((s,y)=>{if(s.type==="click"){let l=w=>{let x=w.target;x instanceof Element&&dn(x,e,s.selector)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(s.type==="form_submit"){let l=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(s.type==="scroll_depth"){let l=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=l){t.type==="composite"?a(y,!0):u(),w.disconnect();break}},{threshold:[l]});w.observe(e),c.push(()=>w.disconnect());return}}),()=>{for(let s of c)s()}}var fn=new Set,gn=new Set;function Ur(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var jr=12;function Wr(e,t){let n=new Set,r=[];for(let o of t.steps){let u=o.name;!u||u.length>128||u.startsWith("funnel:")||n.has(u)||r.length===jr||(n.add(u),r.push({goalId:u,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,u)=>o.weight-u.weight);return(r.length<t.steps.length||i.some((o,u)=>o!==r[u]))&&F()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function ce(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,u=r!=null?r:o?Ur(n):void 0;if(!u)return;let a=`${u}|${n}`;if(gn.has(a))return;gn.add(a);let c=o&&!fn.has(u)?Wr(n,o):null,s=c!==null&&c.length>=2;s&&fn.add(u),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:u,steps:c}:{funnelId:u}})}function ye(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Kr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function he(){if(typeof window=="undefined")return Kr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function Ve(){he().version+=1;for(let e of he().listeners)e()}var mn=()=>{};function pn(e){return F()?(he().components.set(e.id,e),Ve(),()=>{he().components.delete(e.id),Ve()}):mn}function Oe(e){return F()?(he().slots.set(e.id,e),Ve(),()=>{he().slots.delete(e.id),Ve()}):mn}function xt(e){F()&&(he().sections=[...e],Ve())}var yn="0.41.0",kt=yn!=="0.0.0-dev"?{name:"react",version:yn}:void 0;function Jr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Ee(e,t){Jr()[e]=t}function vn(e){window.__sentient_vocabulary_override=e}function Sn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Hr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Pe(e,t){Hr()[e]=t}function hn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var At="__snt_editor_token",Ge=null,Rt=!1;function bn(){return Rt}function Xr(){try{return sessionStorage.getItem(At)}catch(e){return null}}function He(e){if(Ge)return Ge;let t=typeof window=="undefined"?null:hn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Xr();return Rt=!!n,Ge=Promise.resolve(n?{token:n,fresh:!1}:null),Ge}return Rt=!0,Ge=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(At,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Ge}function wn(){try{sessionStorage.removeItem(At)}catch(e){}}var xn="sentient_preview_cell",kn="sentient_refresh_region",Ct="sentient-cell-preview-bar",be="__preview__",Te=null;function Rn(e){if((Te==null?void 0:Te.slotId)!==e)return null;let t=Te;return Te=null,t}function An(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>we(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>we("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Cn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ct))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(xn),n=c.get(kn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=He(r);if(!bn())return;if(n){Te={slotId:n,session:i,base:r},Ee(n,{kind:"arms"}),Pe(n,be),ht();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let u=t.slice(0,o),a=t.slice(o+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(u)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(we(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){we(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await c.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&vn(s.vocabulary),s.compose!=null)Ee(u,{kind:"arms",compose:{[be]:s.compose}}),Pe(u,be);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Ee(u,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Pe(u,be);else if(s.blocks!=null)Ee(u,{kind:"arms",blocks:{[be]:s.blocks}}),Pe(u,be);else if(s.content!=null)Ee(u,{kind:"arms",content:s.content}),Pe(u,be);else{we("Nothing to preview in that square yet.");return}ht(),we(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${u}"]`))==null||y.scrollIntoView({block:"center"})}catch(l){}},300)}).catch(()=>we("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function we(e){var i;if(document.getElementById(Ct))return;let t=document.createElement("div");t.id=Ct,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{wn();let o=new URL(window.location.href);o.searchParams.delete(xn),o.searchParams.delete(kn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var _n=!1;function On(e){if(_n||typeof window=="undefined")return;_n=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");He(t).then(n=>{!n||!("token"in n)||!n.fresh||zr(t,n.token)})}function zr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var $n=require("react/jsx-runtime");function qr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Xe.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Pn="https://api.sentient-ui.com/v1",Y=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Pn,debug:!1}),En=!1,_t=new Set;function Yr(e,t,n){let r=(0,C.useRef)(n);r.current=n;let[i,o]=(0,C.useState)(null),[u,a]=(0,C.useState)(!1),c=(0,C.useRef)(e);c.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(V(p({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,C.useEffect)(()=>{let y=c.current;if(y===void 0||typeof window=="undefined")return;let l,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let v=x(typeof y=="object"&&y.cmp===void 0&&y.check?p(V(p({},y),{check:()=>c.current.check()}),y.refused?{refused:()=>{var f,b;return((b=(f=c.current).refused)==null?void 0:b.call(f))===!0}}:{}):y),h=!1,S=()=>{let f=v.refused()&&v.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=v.read();b!==null&&_t.add(t),o(b!=null?b:_t.has(t)?!1:null)};S(),l=v.subscribe(S)}),()=>{w=!0,l==null||l()}},[s,t]),{granted:i,refused:u}}function Gn(e){var T,E,R,A,d;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:qr()}),[i,o]=(0,C.useState)(vt());(0,C.useEffect)(()=>sn(()=>o(vt())),[]),(0,C.useEffect)(()=>{Cn(e.apiBaseUrl),On(e.apiBaseUrl)},[]);let u=(0,C.useRef)(()=>{}),a=Yr(e.consentFrom,e.apiKey,()=>u.current()),c=e.consentFrom?(T=a.granted)!=null?T:_t.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,y=(0,C.useRef)(s);y.current=s;let l=(0,C.useRef)(null),w=(0,C.useRef)(!1),x=(0,C.useRef)([]),m=(0,C.useRef)(!1);u.current=()=>{var N;x.current=[],m.current=!0;let g=l.current;g!=null&&g.gated?g.dispose():(N=g==null?void 0:g.takeHeld)==null||N.call(g)},(0,C.useEffect)(()=>{var K,J;if(y.current&&c===!1&&(x.current=[]),c===!1&&w.current&&(y.current&&((K=l.current)==null||K.destroy()),l.current=null,w.current=!1),c===!1&&!e.preConsentBehavior){y.current&&((J=l.current)==null||J.destroy()),l.current=null,n(null);return}let g=c!==!1;g&&(m.current=!1);let N=B=>{!g&&m.current&&B.gated&&B.dispose()},I=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},kt?{sdk:kt}:{}),_=!1,G=null,j=null,W=B=>{for(let se of x.current.splice(0))setTimeout(()=>{if(l.current!==B){m.current||x.current.push(se);return}try{se(B)}catch(De){}},0)},X=B=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:se})=>{_||(j=se(B,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:B})=>{_||(G=B(V(p({},I),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),N(G),l.current=G,w.current=g,W(G),n(G),X(G))}):(G=(0,Xe.init)(I),N(G),l.current=G,w.current=g,W(G),n(G),X(G)),()=>{var B,se;_=!0,j==null||j(),x.current=x.current.concat((se=(B=G==null?void 0:G.takeHeld)==null?void 0:B.call(G))!=null?se:[]),G==null||G.dispose()}},[c]),(0,C.useEffect)(()=>{if(!t)return;let g=!1,N=async()=>{if(g)return;let _;try{_=await t.fetchWeights()}catch(G){return}if(!g)for(let G of _){let j={componentId:G.componentId,updatedAt:G.updatedAt,variants:G.variants.map(W=>{var X;return{variantId:W.variantId,pulls:W.pulls,avgReward:(X=W.avgReward)!=null?X:0}})};rn(G.componentId,j)}};N();let I=setInterval(()=>{N()},6e4);return()=>{g=!0,clearInterval(I)}},[t]);let v=(E=e.ssrFallback)!=null?E:"first",h=((R=e.apiBaseUrl)!=null?R:Pn).replace(/\/$/,""),S=(0,C.useRef)(null);(0,C.useEffect)(()=>{var I;if(typeof process!="undefined"&&((I=process.env)==null?void 0:I.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},N=S.current;if(S.current=g,N!==null)for(let _ of["apiKey","context","country","persona","apiBaseUrl"])Object.is(N[_],g[_])||console.warn(`[sentient] AdaptiveProvider: \`${_}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),(0,C.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||un({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;(0,C.useEffect)(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),(0,C.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){xt(g);return}e.declaredSections&&e.declaredSections.length>0&&xt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||En||(En=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,C.useEffect)(()=>{if(!F())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let N=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),_=>_.getAttribute("data-sentient-id"))),I=g.filter(_=>!N.has(_));I.length>0&&console.warn(`[SentientUI] Declared section${I.length>1?"s":""} ${I.map(_=>`"${_}"`).join(", ")} ${I.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=(0,C.useMemo)(()=>t&&i?an(t):t,[t,i]),P=(0,C.useMemo)(()=>{var g,N,I,_,G,j,W,X,K;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(N=e.initialUnified)!=null?N:Zr,sessionSegment:r,ssrFallback:v,onAssignment:e.onAssignment,initialLayoutOrder:(I=e.initialLayoutOrder)!=null?I:null,initialSlots:(_=e.initialSlots)!=null?_:{},initialSlotConfig:(G=e.initialSlotConfig)!=null?G:{},initialPalette:(j=e.initialPalette)!=null?j:null,initialVocabulary:(W=e.initialVocabulary)!=null?W:null,initialPersona:(X=e.initialPersona)!=null?X:null,apiBaseUrl:h,debug:(K=e.debug)!=null?K:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,v,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,$n.jsx)(Y.Provider,{value:P,children:e.children})}function $(){return(0,C.useContext)(Y).client}function de(){return(0,C.useContext)(Y).apiKey}function ze(){return(0,C.useContext)(Y).initialAssignments}var Zr=[];function qe(){return(0,C.useContext)(Y).initialUnified}function Ie(){return(0,C.useContext)(Y).sessionSegment}function Tn(){return(0,C.useContext)(Y).ssrFallback}function Ye(){return(0,C.useContext)(Y).onAssignment}function In(){return(0,C.useContext)(Y).debug}function Nn(){let e=(0,C.useContext)(Y).initialLayoutOrder,t=(0,C.useSyncExternalStore)(Q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ze(){return(0,C.useContext)(Y).initialSlots}function Dn(){return(0,C.useContext)(Y).initialPersona}function Ln(){return(0,C.useContext)(Y).initialSlotConfig}function Fn(){return(0,C.useContext)(Y).initialPalette}function Vn(){return(0,C.useContext)(Y).initialVocabulary}function Mn(){return(0,C.useContext)(Y).apiBaseUrl}var ge=require("react");var U=require("react"),Bn=require("@sentientui/core");var re=require("react"),Qe=require("@sentientui/policy");function ve(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function et(e,t,n,r,i){let o=ze(),u=Tn(),a=$(),c=Ie(),s=Ye(),y=In(),l=(0,re.useRef)(null),w=(0,re.useSyncExternalStore)(Q,()=>ve(e),()=>null),x=w&&t.includes(w)?w:null,m=(0,re.useRef)(null);(0,re.useEffect)(()=>{y&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[y,x,e]);let[v,h]=(0,re.useState)(()=>{var k,P;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let T=o[e];return T&&t.includes(T)?{variantId:T,content:null,isLoading:!1,settled:!0}:u==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=yt(e);if(b){let T=(0,Qe.pickFromWeights)(b.variants,t);if(T)return{variantId:T,content:null,isLoading:!1,settled:!0}}return{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}}),S=f=>{s&&l.current!==f&&(l.current=f,s(e,f))};return(0,re.useEffect)(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),S(f.variantId);return}let b=yt(e);if(b&&v.settled&&v.variantId&&v.variantId===(0,Qe.pickFromWeights)(b.variants,t)){S(v.variantId);return}h(P=>{var T;return P.variantId?P:{variantId:(T=t[0])!=null?T:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,c]),(0,re.useEffect)(()=>{if(x||!a)return;let f=a.getAssignment(e,c);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(T=>{var E;if(!b&&T){if(T.unified===!0){k==null||k();return}!t.includes(T.variantId)&&!T.content||(h({variantId:T.variantId,content:(E=T.content)!=null?E:null,isLoading:!1,settled:!0}),S(T.variantId))}}),()=>{b=!0}},[x,a,e,c]),(0,re.useEffect)(()=>{if(!x&&a)return nn(e,f=>{var P;let b=a.getAssignment(e,c);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(P=b.content)!=null?P:null,isLoading:!1,settled:!0}),S(b.variantId);return}let k=(0,Qe.pickFromWeights)(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),S(k))})},[x,a,e,c]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:v}function tt(e,t,n){let r=$(),i=de(),o=Object.keys(t).join("\0"),u=(0,U.useMemo)(()=>Object.keys(t),[o]),{variantId:a,content:c,isOverride:s=!1,settled:y}=et(e,u,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,w]=(0,U.useState)(null),x=(0,U.useRef)(null),m=(0,U.useCallback)(d=>{x.current=d,w(d)},[]),v=n.goal,h=typeof v=="string"?v:JSON.stringify(v),S=(0,U.useMemo)(()=>v?te(v):null,[h]),f=v?pe(v):"";(0,U.useEffect)(()=>pn({id:e,variantIds:u,goal:f}),[e,u,f]);let b=(0,U.useRef)(null);(0,U.useEffect)(()=>{s||y&&(!r||!a||!i||!l||b.current!==a&&(b.current=a,ye(r,i,e,a)))},[r,a,i,e,l,s,y]);let k=(0,U.useRef)(!1),P=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{k.current=!1,P.current=new Set},[a,S]);let T=n.funnel;(0,U.useEffect)(()=>{s||!y||!r||!S||ce(r,i,e,T,S)},[r,i,e,T,S,s,y]);let E=n.cursorSignal===!0;(0,U.useEffect)(()=>{if(!E||s||!y||!r||!a||!l)return;let d=null,g=0,N=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},I=()=>{d!==null&&(clearTimeout(d),d=null)};return l.addEventListener("mouseenter",N),l.addEventListener("mouseleave",I),()=>{l.removeEventListener("mouseenter",N),l.removeEventListener("mouseleave",I),d!==null&&clearTimeout(d)}},[E,r,a,i,e,l,s,y]);let R=(0,U.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,U.useEffect)(()=>{if(s||!y||!r||!a||!l)return;let d=Date.now();return(0,Bn.attachMicroSignalDetectors)((g,N={})=>{var W,X,K;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},N)});let I=(W=R.current)==null?void 0:W[g];if(!I||P.current.has(g))return;P.current.add(g);let _=typeof I=="string"?I:I.name,G=typeof I=="string"?1:(X=I.weight)!=null?X:1,j=typeof I=="string"?0:(K=I.stepIndex)!=null?K:0;r.goal(_,{metadata:p({signalType:g},N),weight:G,stepIndex:j})},l,d)},[r,a,i,e,l,A,s,y]),(0,U.useEffect)(()=>{if(s||!y||!r||!a||!l||!S)return;let d=le(S);return ue(l,S,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,N,I)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:N}}),r.goal(g,{metadata:{},weight:N,stepIndex:I})}},f)},[r,a,i,e,l,S,f,s,y]),{client:r,variantIds:u,variantId:a,content:c,settled:y,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}var L=require("react"),Re=require("@sentientui/core"),Dt=require("@sentientui/core/region");var ee=require("react"),jn=require("@sentientui/core");var Un=new Set,Qr={kind:"arms"};function Wn(e,t){var P,T,E;let n=$(),r=(0,ee.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,ee.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=(0,ee.useRef)(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let u=Ze(),a=Ln(),c=Fn(),s=Vn(),y=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),l=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":(0,jn.armOfResult)(R),x=(0,ee.useCallback)(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);(0,ee.useSyncExternalStore)(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),(0,ee.useSyncExternalStore)(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=y===void 0?a[e]:void 0,v=y===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(P=c!=null?c:n==null?void 0:n.getSitePalette())!=null?P:null,S=(E=s!=null?s:(T=n==null?void 0:n.getStyleVocabulary)==null?void 0:T.call(n))!=null?E:null,f=(()=>{var R,A,d;if(y!==void 0)return{config:y,arm:w(l),palette:h,vocabulary:(R=Sn())!=null?R:S,source:"override"};if(t!=null&&t.forcedArm)return{config:Qr,arm:t.forcedArm,palette:h,vocabulary:S,source:"override"};if(m!==void 0)return{config:m,arm:w((A=u[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:S,source:"preloaded"};if(v!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:v,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:u[e]),palette:h,vocabulary:S,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:S,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return(0,ee.useEffect)(()=>{var G,j,W,X,K;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&(j=(G=r.current)==null?void 0:G.call(r))!=null?j:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(W=i.current)==null?void 0:W.call(i),N=R&&(K=(X=o.current)==null?void 0:X.call(o))!=null?K:null,I=p(p({},g?{render:{[e]:g}}:{}),N?{skeletons:{[e]:N}}:{}),_=Object.keys(I).length>0;return n.requestSlots?_?n.requestSlots([e],d,I):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(N?n.reportSlots([e],d!=null?d:{},{[e]:N}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,k,f.source,e,b]),(0,ee.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Un.has(e)||(Un.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var Me=require("react");var M=require("react/jsx-runtime");function Ot(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var Se={none:"0",sm:"8px",md:"16px",lg:"24px"},Et={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Xn={sm:"0.875em",md:"1em",lg:"1.25em"},ei={sm:"1.25em",md:"1.5em",lg:"2em"},Kn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Jn={sm:"8px",md:"16px",lg:"32px"},ti={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ni={normal:"400",medium:"500",bold:"700"};function Hn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function zn(e,t,n){var i,o,u,a;let r=t==null?void 0:t.accent;return V(p({display:"inline-block",padding:(i=Kn[n!=null?n:"md"])!=null?i:Kn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Xn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(u=t==null?void 0:t.primaryBg)!=null?u:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ri({node:e,opts:t}){var i,o,u,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(u=(o=t.palette)==null?void 0:o.border)!=null?u:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return(0,M.jsxs)("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let y=new FormData(s.currentTarget),l={};for(let v of e.fields)l[v.name]=String((w=y.get(v.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,l)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var y,l;return(0,M.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,M.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,M.jsx)("select",{name:s.name,required:s.required,style:r,children:((y=s.options)!=null?y:[]).map(w=>(0,M.jsx)("option",{value:w,children:w},w))}):(0,M.jsx)("input",{name:s.name,type:(l=s.inputType)!=null?l:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,M.jsx)("button",{type:"submit",style:zn(n,t.palette),children:e.submitLabel})]})}function ii(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function qn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=oi(e,t),r=qn(e.like,t);return n&&r?(0,Me.cloneElement)(n,{style:V(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function oi(e,t){var n,r,i,o,u,a,c,s,y,l,w,x,m,v,h,S,f,b,k,P,T,E,R;try{let A=ii(e,t);switch(e.type){case"stack":{let d=(r=Se[(n=e.gap)!=null?n:"md"])!=null?r:Se.md,g=e.surface==="raised"&&!A,N=(i=e.pad)!=null?i:g?"md":void 0;return(0,M.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Et[e.align]}:{}),e.justify?{justifyContent:Et[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),N?{padding:(o=Se[N])!=null?o:Se.md}:{}),g?V(p(p({},(u=t.palette)!=null&&u.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(y=(s=t.palette)==null?void 0:s.border)!=null?y:"currentColor"}`,borderRadius:(w=(l=t.palette)==null?void 0:l.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((I,_)=>{let G=xe(I,t);return G===null?null:(0,M.jsx)(Me.Fragment,{children:G},_)})}))}case"grid":{let d=(v=Se[(m=e.gap)!=null?m:"md"])!=null?v:Se.md;return(0,M.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Et[e.align]}:{}),e.pad?{padding:(h=Se[e.pad])!=null?h:Se.md}:{}),children:((S=e.children)!=null?S:[]).map((g,N)=>{let I=xe(g,t);return I===null?null:(0,M.jsx)(Me.Fragment,{children:I},N)})}))}case"text":return A?(0,M.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,M.jsx)("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:Xn[e.size]}:{}),e.weight?{fontWeight:ni[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Hn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?(0,M.jsx)(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,M.jsx)(d,{style:p(p({margin:0,fontSize:ei[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return(0,M.jsx)("a",V(p(p({href:Ot(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:zn(d,t.palette,e.size)}),{children:e.label}))}case"link":return(0,M.jsx)("a",V(p(p({href:Ot(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,M.jsx)("img",V(p({src:Ot(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:ti[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,M.jsx)("span",{className:A,children:e.value}):(0,M.jsx)("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(P=(k=t.palette)==null?void 0:k.border)!=null?P:"currentColor"}`},Hn(e.tone,t.palette)),children:e.value});case"spacer":return(0,M.jsx)("div",{style:{height:(T=Jn[e.size])!=null?T:Jn.md}});case"divider":return(0,M.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(E=t.palette)==null?void 0:E.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,M.jsx)(ri,{node:e,opts:t});default:return null}}catch(A){return null}}function nt(e,t){var o,u,a,c;let n=xe(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(u=t.vocabulary)==null?void 0:u.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=qn((c=e.surface)==null?void 0:c.like,t);return r?(0,M.jsx)("div",V(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}var fe=require("react"),rt=require("@sentientui/core/region");function it(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function ot(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ke(e){return it(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ke(n),0):(0,fe.isValidElement)(e)?ke(ot(e)):0}function si(e,t){return Array.isArray(t)?(0,fe.cloneElement)(e,void 0,...t):(0,fe.cloneElement)(e,void 0,t)}function Pt(e,t){if(it(e))return t;if(Array.isArray(e))return e.map(n=>Pt(n,t));if((0,fe.isValidElement)(e)){let n=ot(e);return ke(n)===0?e:si(e,Pt(n,t))}return e}function Yn(e,t){return ke(e)===1?Pt(e,t):null}var ne=e=>e.join("/");function Gt(e,t,n){if(it(e)){n.leafPaths.push(t),n.texts.push((0,rt.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Gt(r,[...t,i],n));return}(0,fe.isValidElement)(e)&&(n.elements.set(ne(t),e),Gt(ot(e),[...t,"c"],n))}function It(e){let t={leafPaths:[],texts:[],elements:new Map};return Gt(e,[],t),t}function ai(e){return It(e).texts}function Zn(e){let t=ai(e);return t.length===0?null:(0,rt.skeletonFingerprint)(t)}function li(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Qn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,c)=>a===i?[li(e.leafPaths[c])]:[]);if(o.length===0){r.push(null);continue}let u=o[0];for(let a of o.slice(1)){let c=new Set(a.map(ne));u=u.filter(s=>c.has(ne(s)))}r.push(u.length>0?u[u.length-1]:null)}return r}function Tt(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function Nt(e,t){let n=It(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,u)=>o!==e.leaves[u]))return null;let r=Qn(n,e.leafToNode),i=e.nodes.map((o,u)=>{let a=r[u],c=a?n.elements.get(ne(a)):void 0,s=!!c&&(typeof c.type=="string"||Tt(c)!==void 0);return V(p({},o),{restylable:s})});return V(p({},e),{nodes:i})}function er(e,t,n){var m;let r=It(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((v,h)=>Math.max(v,h+1),0);for(let v of Object.keys(t.nodes))if(!/^\d+$/.test(v)||Number(v)>=i)return null;let o=Qn(r,n),u=new Map;n.forEach((v,h)=>{u.has(v)||u.set(v,h)});let a=new Map(r.leafPaths.map((v,h)=>[ne(v),h])),c=new Set,s=new Map,y=!1;for(let[v,h]of Object.entries(t.nodes)){let S=Number(v),f=o[S];if(h.hidden&&(f?c.add(ne(f)):y=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(ne(f)):void 0,P=b?Tt(r.elements.get(ne(b))):void 0;!f||P===void 0||Tt(k)===void 0?y=!0:s.set(ne(f),P)}}let l=new Map(Object.entries((m=t.order)!=null?m:{})),w=(v,h)=>{var S;if(it(v)){let f=a.get(ne(h));if(f===void 0)return v;let b=n[f],k=(S=t.nodes[String(b)])==null?void 0:S.text;return k===void 0?v:u.get(b)===f?k:""}if(Array.isArray(v)){let f=v.map((b,k)=>w(b,[...h,k]));for(let[b,k]of l){let P=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||ne(A.slice(0,-1))!==ne(h)?-1:A[A.length-1]});if(P.some(R=>R<0))continue;let T=[...P].sort((R,A)=>R-A),E=[...f];T.forEach((R,A)=>{f[R]=E[P[A]]}),l.delete(b)}return f}if((0,fe.isValidElement)(v)){let f=ne(h);if(c.has(f))return null;let b=ot(v);if(ke(b)===0)return v;let k=w(b,[...h,"c"]),P=s.get(f),T=P!==void 0?{className:P}:void 0;return Array.isArray(k)?(0,fe.cloneElement)(v,T,...k):(0,fe.cloneElement)(v,T,k)}return v},x=w(e,[]);return y||l.size>0?null:x}var ir=require("react/jsx-runtime"),tr=new Set,nr=new Set,rr=new Set,st="authored.";function Ne({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:u="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:s,clientOnly:y,agentDataByVariant:l,agentData:w,variantsOnly:x=!1}){var Ht,Xt;let m=$(),v=de(),h=(0,L.useRef)(null),[S,f]=(0,L.useState)(!1);(0,L.useEffect)(()=>{f(!0)},[]);let b=y===!0&&(!S||!m),k=(0,L.useMemo)(()=>Zn(t),[t]),P=n?Object.keys(n).join("|"):"",T=(0,L.useMemo)(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ke(t)===1,ops:!1},P!==""?{authored:P.split("|"),children:!x}:{}),[k,t,r,P,x]),E=()=>{var q;let O=h.current;if(!O||!a)return null;let D=(0,Dt.captureRegionSkeleton)(O);return D.skeleton?(q=Nt(D.skeleton,t))!=null?q:V(p({},D.skeleton),{editable:!1,nodes:D.skeleton.nodes.map(H=>V(p({},H),{restylable:!1}))}):{status:D.reason}},R=(0,L.useSyncExternalStore)(Q,()=>n?ve(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${st}${R}`:x?`${st}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:N,vocabulary:I,source:_}=Wn(e,{forcedArm:A,baselineText:a?()=>{var O,D;return(D=(O=h.current)==null?void 0:O.textContent)!=null?D:null}:void 0,render:()=>T,skeleton:E,defer:b}),G=g!==""?(Ht=d==null?void 0:d.blocks)==null?void 0:Ht[g]:void 0,j=g!==""?(Xt=d==null?void 0:d.compose)==null?void 0:Xt[g]:void 0,W=(G!==void 0&&(0,Re.containsFormBlock)(G)||j!==void 0&&(0,Re.containsFormBlock)(j.tree))&&!r;(0,L.useEffect)(()=>{!W||!F()||tr.has(e)||(tr.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[W,e]);let X=O=>{!m||_==="override"||(_!=="seeded"&&m.componentGoal(e,O),m.goal(O,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},K=t,J=!1,B=g.startsWith(st)?g.slice(st.length):null;if((d==null?void 0:d.blocked)==="variant_history")J=!0;else if(B!==null)n&&Object.prototype.hasOwnProperty.call(n,B)?K=n[B]:J=!0;else if(j!==void 0){let O=W?null:nt(j,{palette:N,vocabulary:I,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if(G!==void 0){let O=W?null:xe(G,{palette:N,vocabulary:I,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if((d==null?void 0:d.edits)!==void 0&&_!=="none"){let O=d.edits,D=O.fp===k?er(t,O.edits,O.leafToNode):null;D===null?J=!0:K=D}else if((d==null?void 0:d.content)!==void 0&&_!=="none"){let O=Yn(t,d.content);O===null?J=!0:K=O}let se=J&&G===void 0&&j===void 0&&(d==null?void 0:d.edits)===void 0&&B===null&&(d==null?void 0:d.blocked)===void 0;(0,L.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!F()||rr.has(e)||(rr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let De=B!==null&&!J?B:null;(0,L.useEffect)(()=>{var ae;if(!De||!a||!m)return;let O=h.current;if(!O)return;let D=(0,Dt.captureRegionSkeleton)(O),q=D.skeleton?Nt(D.skeleton,n==null?void 0:n[De]):null,H=(ae=O.textContent)==null?void 0:ae.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:De},H?{text:H}:{}),q?{skeleton:q}:{})]})},[De,m,e,b]);let $t=J&&(d==null?void 0:d.edits)!==void 0&&(_==="preloaded"||_==="client");(0,L.useEffect)(()=>{var O;!$t||!(d!=null&&d.edits)||(O=m==null?void 0:m.reportDrift)==null||O.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[$t,e,k,m]);let Be=K===t;(0,L.useEffect)(()=>{var D;if(!(d!=null&&d.needsSkeleton)||!Be)return;let O=E();O&&((D=m==null?void 0:m.reportSkeleton)==null||D.call(m,e,O))},[d==null?void 0:d.needsSkeleton,Be,e,m,b]),(0,L.useEffect)(()=>{if(!Be)return;let O=Rn(e);if(!O)return;let D=E();An(O,D&&"status"in D?{status:D.status}:{skeleton:D})},[e,Be,b]),(0,L.useEffect)(()=>{!se||!F()||nr.has(e)||(nr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[se,e]);let dt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";(0,L.useEffect)(()=>Oe({id:e,arms:dt===""?void 0:dt.split("|")}),[e,dt]);let Bt=(0,L.useRef)(null);(0,L.useEffect)(()=>{!m||_==="none"||_==="seeded"||_==="override"||g===""||J||Bt.current!==g&&(Bt.current=g,ye(m,v,e,g))},[m,v,e,g,_,J]);let me=_!=="none"&&_!=="seeded"&&!J,ft=me?g:"",Ut=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,L.useEffect)(()=>{if(!m||!i||_==="override")return;let O=h.current;if(!O)return;let D=pe(i),q=le(i),H=!1;return ue(O,te(i),{fireGoal:()=>{H||(H=!0,me&&(q!==void 0?m.componentGoal(e,D,{value:q}):m.componentGoal(e,D)),m.goal(D,p({metadata:{componentId:e,arm:ft},weight:1,stepIndex:0},q!==void 0?{value:q}:{})))},fireStep:(ae,je,mt)=>{me&&m.componentGoal(e,ae,{reward:je}),m.goal(ae,{metadata:{componentId:e,arm:ft},weight:je,stepIndex:mt})}},D)},[m,e,Ut,g,_,J,me,ft,b]);let gt=(0,L.useMemo)(()=>i?te(i):null,[Ut]);(0,L.useEffect)(()=>{_==="override"||!m||!gt||ce(m,v,e,c,gt)},[m,v,e,c,gt,_]);let jt=(0,L.useRef)(s);jt.current=s;let Wt=(0,L.useRef)(new Set),Pr=s?JSON.stringify(s):"";(0,L.useEffect)(()=>{if(!m||_==="override"||!me||g==="")return;let O=h.current;if(O)return(0,Re.attachMicroSignalDetectors)((D,q={})=>{var zt,qt,Yt;m.track({projectId:v,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:D},q)});let H=(zt=jt.current)==null?void 0:zt[D];if(!H||Wt.current.has(D))return;Wt.current.add(D);let ae=typeof H=="string"?H:H.name,je=typeof H=="string"?1:(qt=H.weight)!=null?qt:1,mt=typeof H=="string"?0:(Yt=H.stepIndex)!=null?Yt:0;m.goal(ae,{metadata:p({componentId:e,arm:g,signalType:D},q),weight:je,stepIndex:mt})},O,Date.now())},[m,v,e,g,_,me,Pr,b]);let Kt=(0,L.useRef)({agentData:w,agentDataByVariant:l});Kt.current={agentData:w,agentDataByVariant:l};let Jt=(0,L.useRef)(null);(0,L.useEffect)(()=>{var ae;if(!m||_==="override"||!me||g===""||Jt.current===g)return;let{agentData:O,agentDataByVariant:D}=Kt.current,q=B!=null?B:g,H=D!==void 0?Object.prototype.hasOwnProperty.call(D,q)?D[q]:void 0:O;H!==void 0&&(Jt.current=g,(ae=m.reportAgentData)==null||ae.call(m,e,g,H))},[m,e,g,me,B,_]);let Ue=(0,L.useRef)(null);(0,L.useEffect)(()=>{let O=h.current;if(O){if(Ue.current===null){Ue.current=g;return}Ue.current!==g&&(Ue.current=g,(0,Re.reveal)(O))}},[g,b]);let Gr=(0,L.useMemo)(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:(0,ir.jsx)(u,V(p({ref:h,className:o},Gr),{children:K}))}var Ae=require("react/jsx-runtime");function ui(e){var y,l;let{client:t,variantId:n,content:r,ref:i}=tt(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,u]=(0,ge.useState)(!1);(0,ge.useEffect)(()=>{u(!0)},[]);let a=(y=e.as)!=null?y:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,s=c===null?r:null;return F()&&c===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:s})}var ci=(0,ge.memo)(ui,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function or(e){if(e.variants===void 0)return(0,Ae.jsx)(Ne,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Fe(n,["variants"]);return(0,Ae.jsx)(Ne,V(p({},i),{children:t.children,variants:r}))}return(0,Ae.jsx)(di,p({},t))}function di(e){var l;let[t,n]=(0,ge.useState)(null),{id:r}=e,i=(0,ge.useCallback)(()=>n(r),[r]),o=$(),u=qe().includes(r)||((l=o==null?void 0:o.isUnified)==null?void 0:l.call(o,r))===!0;if(t!==r&&!u)return(0,Ae.jsx)(ci,V(p({},e),{onUnified:i}));let w=e,{variants:a,children:c}=w,s=Fe(w,["variants","children"]),y=Object.keys(a)[0];return(0,Ae.jsx)(Ne,V(p({},s),{variants:a,variantsOnly:!0,children:y!==void 0?a[y]:null}))}var z=require("react");var ar=require("react/jsx-runtime");function sr({id:e,default:t,component:n="span",className:r,goal:i}){var T;let o=$(),u=de(),a=Ye(),c=Ie(),s=(0,z.useRef)(null),y=(0,z.useRef)(null),l=(0,z.useSyncExternalStore)(Q,()=>ve(e),()=>null),[w,x]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,c))==null?void 0:E.content)!=null?R:null}),[m,v]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,c))==null?void 0:E.variantId)!=null?R:null});(0,z.useEffect)(()=>{if(l||!o)return;let E=o.getAssignment(e,c);if((E==null?void 0:E.content)!==void 0){v(E.variantId),x(E.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,c,l]),(0,z.useEffect)(()=>{l||!o||!m||!u||s.current!==m&&(s.current=m,o.track({projectId:u,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,u,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),S=(0,z.useMemo)(()=>i===void 0?null:te(i),[h]),f=i===void 0?null:typeof i=="string"?i:S.type,b=(0,z.useRef)(!1);(0,z.useEffect)(()=>{b.current=!1},[m,h]),(0,z.useEffect)(()=>{l||!o||!u||ce(o,u,e,void 0,S)},[o,u,e,S,l]),(0,z.useEffect)(()=>{if(l||!o||!m||!u||!S||!f)return;let E=y.current;if(!E)return;let R=le(S);return ue(E,S,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,u,e,S,f,l]);let k=w!=null?w:t;if(l){let E=o==null?void 0:o.getAssignment(e,c);k=E&&E.variantId===l&&(T=E.content)!=null?T:t}return(0,ar.jsx)(n,{ref:E=>{y.current=E},className:r,children:k})}var at=require("react");function lt(e){let t=$(),n=(0,at.useRef)(new Set);return(0,at.useCallback)((r,i)=>{var o,u;if(!ve(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,p(p(p({metadata:(o=i==null?void 0:i.metadata)!=null?o:{},weight:(u=i==null?void 0:i.reward)!=null?u:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var $e=require("react");function lr(e,t={}){let c=t,{componentId:n}=c,r=Fe(c,["componentId"]),i=$(),o=lt(n!=null?n:""),u=(0,$e.useRef)(!1),a=(0,$e.useRef)(r);a.current=r,(0,$e.useEffect)(()=>{if(!i||u.current||i.gated)return;u.current=!0;let{metadata:s,reward:y,value:l,currency:w,externalId:x}=a.current;if(n){o(e,a.current);return}i.goal(e,p(p(p({metadata:s!=null?s:{},weight:y!=null?y:1,stepIndex:0},l!==void 0?{value:l}:{}),w!==void 0?{currency:w}:{}),x!==void 0?{externalId:x}:{}))},[i,n,e,o])}var ur=require("@sentientui/core"),cr=require("@sentientui/policy"),fr=require("react/jsx-runtime");function Lt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function fi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Lt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Lt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Lt((0,cr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,ur.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function dr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,fr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:fi(e)}})}var oe=require("react"),yr=require("@sentientui/policy");var ie=require("react"),Ce=require("@sentientui/core"),gr=require("@sentientui/policy");function ut(e,t){let n=$(),r=Ze(),[,i]=(0,ie.useReducer)(l=>l+1,0),o=(0,ie.useSyncExternalStore)(Q,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),u=o===void 0?r[e]:void 0,a=o===void 0&&u===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&o===void 0&&u===void 0&&a===null;(0,ie.useEffect)(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(w=>{!l&&w&&i()}),()=>{l=!0}},[n,e,c]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,Ce.armOfResult)(o),source:"override"};if(u!==void 0)return{result:u,arm:(0,Ce.armOfResult)(u),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ce.armOfResult)(a),source:w?"client":"seeded"}}let l=(0,Ce.baselineResultFor)(t);return{result:l,arm:(0,Ce.armOfResult)(l),source:"baseline"}})(),y=s.source==="preloaded"||s.source==="override";return(0,ie.useEffect)(()=>{var w;if(!n||n.isLocal===!0||y||!n.decideSlots)return;let l=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),l==null||l()}},[n,e,y]),s}function gi(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function mr(){let e=$(),t=Dn();(0,ie.useSyncExternalStore)(Q,ln,()=>0);let[n,r]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,gr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=gi();if(o)return i(o);if(t)return i(t);let u=e?e.getPersona():null;return u?i(u):null}var pr=new Set;function mi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function vr(e,t,n){let r=$(),i=de(),o=JSON.stringify(t),u=(0,oe.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:c,source:s}=ut(e,u),y=(0,oe.useMemo)(()=>typeof a=="string"?{}:a,[c]);if(F()&&!pr.has(e)){pr.add(e);let v=(0,yr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([S,f])=>[S,[...f]]))}),h=Object.values(t).reduce((S,f)=>S*f.length,1);v.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,oe.useEffect)(()=>Oe({id:e,dims:t}),[e]);let w=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,ye(r,i,e,c))},[r,i,e,c,s]);let x=n==null?void 0:n.funnel;(0,oe.useEffect)(()=>{var v;!r||s==="override"||ce(r,i,e,x,te((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,x,l,s]),(0,oe.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${mi(e)}"]`);if(!v){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=pe(n.goal),S=le(n.goal),f=!1;return ue(v,te(n.goal),{fireGoal:()=>{f||(f=!0,S!==void 0?r.componentGoal(e,h,{value:S}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},S!==void 0?{value:S}:{})))},fireStep:(b,k,P)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:c},weight:k,stepIndex:P})}},h)},[r,e,l,c,s]);let m=(0,oe.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[h,S]of Object.entries(y))v[`data-${h}`]=S;return v},[e,y]);return{tokens:y,props:m}}var _e=require("react");var Sr=new Set,hr=new Set;function br(e,t){var m,v;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:u,ref:a,nodeRef:c}=tt(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",y=t.variants[s],l=qe().includes(e)||((v=n==null?void 0:n.isUnified)==null?void 0:v.call(n,e))===!0;(0,_e.useEffect)(()=>{!l||!F()||hr.has(e)||(hr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),(0,_e.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!c.current&&!Sr.has(e)&&(Sr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=(0,_e.useCallback)((h,S)=>{var b,k;if(o)return;let f=h!=null?h:u;f&&(n==null||n.componentGoal(e,f,S),n==null||n.goal(f,p(p(p({metadata:(b=S==null?void 0:S.metadata)!=null?b:{},weight:(k=S==null?void 0:S.reward)!=null?k:1,stepIndex:0},(S==null?void 0:S.value)!==void 0?{value:S.value}:{}),(S==null?void 0:S.currency)!==void 0?{currency:S.currency}:{}),(S==null?void 0:S.externalId)!==void 0?{externalId:S.externalId}:{})))},[n,e,u,o]),x=(0,_e.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:y,bind:x,fireGoal:w}}var Z=require("react");var xr=require("react/jsx-runtime"),ct=new Set;function wr(e){var f;let t=$(),n=de(),r=(0,Z.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,Z.useMemo)(()=>Object.keys(e.arrangements),[i]),u=(0,Z.useMemo)(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:c}=ut(e.id,u);F()&&e.baseline!==void 0&&e.baseline!==o[0]&&!ct.has(e.id+":baseline")&&(ct.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Z.Children.toArray(e.children).filter(Z.isValidElement),y=new Map;for(let b of s)y.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let l=e.arrangements[a],w=l!==void 0&&l.length===s.length&&l.every(b=>y.has(b));F()&&l!==void 0&&!w&&!ct.has(e.id+":keys")&&(ct.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?l.map(b=>y.get(b)):s;(0,Z.useEffect)(()=>Oe({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||m.current===a||(m.current=a,ye(t,n,e.id,a))},[t,n,e.id,a,c]);let v=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);(0,Z.useEffect)(()=>{var b;!t||c==="override"||ce(t,n,e.id,v,te((b=e.goal)!=null?b:"click"))},[t,n,e.id,v,h,c]);let S=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,Z.useEffect)(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let b=r.current;if(!b)return;let k=pe(e.goal),P=le(e.goal),T=!1;return ue(b,te(e.goal),{fireGoal:()=>{T||(T=!0,P!==void 0?t.componentGoal(e.id,k,{value:P}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},P!==void 0?{value:P}:{})))},fireStep:(E,R,A)=>{t.componentGoal(e.id,E,{reward:R}),t.goal(E,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,S,a,c]),(0,xr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var Ft=require("@sentientui/core");var pi=["page","blocks","layoutOrder"],kr=new Map;function Rr(e,t){kr.set(e,t)}function Vt(e){return kr.get(e)}function Ar(e){var i,o;let t=(o=(i=e.content)!=null?i:Vt(e.page))!=null?o:{},n={};for(let[u,a]of Object.entries(t))pi.includes(u)||(n[u]=a);let r=V(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Cr(e){return`<script type="application/ld+json">${Mt(e)}</script>`}function Mt(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function _r(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
2
|
+
"use strict";var Tr=Object.create;var Le=Object.defineProperty,Ir=Object.defineProperties,Nr=Object.getOwnPropertyDescriptor,Dr=Object.getOwnPropertyDescriptors,Lr=Object.getOwnPropertyNames,We=Object.getOwnPropertySymbols,Fr=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Zt=(e,t,n)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))pt.call(t,n)&&Zt(e,n,t[n]);if(We)for(var n of We(t))Qt.call(t,n)&&Zt(e,n,t[n]);return e},V=(e,t)=>Ir(e,Dr(t));var Fe=(e,t)=>{var n={};for(var r in e)pt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&We)for(var r of We(e))t.indexOf(r)<0&&Qt.call(e,r)&&(n[r]=e[r]);return n};var Vr=(e,t)=>{for(var n in t)Le(e,n,{get:t[n],enumerable:!0})},en=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Lr(t))!pt.call(e,i)&&i!==n&&Le(e,i,{get:()=>t[i],enumerable:!(r=Nr(t,i))||r.enumerable});return e};var Ke=(e,t,n)=>(n=e!=null?Tr(Fr(e)):{},en(t||!e||!e.__esModule?Le(n,"default",{value:e,enumerable:!0}):n,e)),Mr=e=>en(Le({},"__esModule",{value:!0}),e);var yi={};Vr(yi,{Adaptive:()=>or,AdaptiveGroup:()=>wr,AdaptiveProvider:()=>Gn,AdaptiveSlot:()=>Ne,AdaptiveText:()=>sr,SentientPersonaScript:()=>dr,buildAgentFeed:()=>Ar,consentWatcher:()=>Er.consentWatcher,defineAgentContent:()=>Rr,detectSegment:()=>Ft.deriveSessionSegment,getAgentContent:()=>Vt,grantConsent:()=>Or.grantConsent,renderAgentJsonLd:()=>Cr,renderAgentJsonLdBody:()=>Mt,renderAgentMarkdown:()=>_r,renderBlocks:()=>xe,renderCompose:()=>nt,useAdaptive:()=>br,useAdaptiveApiBaseUrl:()=>Mn,useAdaptiveGoal:()=>lt,useAdaptivePersona:()=>mr,useAdaptiveTokens:()=>vr,useAssignment:()=>et,useInitialAssignments:()=>ze,useLayoutOrder:()=>Nn,usePageGoal:()=>lr,useSentient:()=>$,useSessionSegment:()=>Ie});module.exports=Mr(yi);var C=require("react"),Xe=require("@sentientui/core");var tn=new Map,Je=new Map;function nn(e,t){let n=Je.get(e);return n||(n=new Set,Je.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Je.delete(e)}}function rn(e,t){tn.set(e,t);let n=Je.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function yt(e){var t;return(t=tn.get(e))!=null?t:null}var $r={on:!1,listeners:new Set};function on(){if(typeof window=="undefined")return $r;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function vt(){return on().on}function sn(e){let t=on().listeners;return t.add(e),()=>{t.delete(e)}}function an(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,o)=>e.assign(t,n,r,i,o),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var St="sentient:overrides-changed";function ln(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ht(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(St))}function Q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(St,e),()=>window.removeEventListener(St,e))}function un(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function F(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function te(e){return typeof e=="string"?{type:"click"}:e}function pe(e){return typeof e=="string"?e:e.type}function le(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var bt=new Set,wt=!1;function cn(e){if(bt.has(e))return!0;if(bt.add(e),!wt){wt=!0;let t=()=>{wt=!1,bt.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function Br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function dn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(Br(r))return!0;r=r.parentElement}return!1}function ue(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,y=[];return t.steps.forEach(({goal:l,name:w,weight:x},m)=>{let v=(h=!1)=>{s.has(m)||h&&r!==void 0&&cn(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(l.type==="click"){let h=S=>{let f=S.target;f instanceof Element&&dn(f,e,l.selector)&&v()};e.addEventListener("click",h),y.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=S=>{S.target instanceof HTMLFormElement&&e.contains(S.target)&&v()};e.addEventListener("submit",h),y.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),S=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){v(!0),S.disconnect();break}},{threshold:[h]});S.observe(e),y.push(()=>S.disconnect())}}),()=>{for(let l of y)l()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,y)=>y)),u=()=>{r!==void 0&&cn(r)||n.fireGoal()},a=(s,y=!1)=>{o.delete(s),o.size===0&&(y?u():n.fireGoal())},c=[];return i.forEach((s,y)=>{if(s.type==="click"){let l=w=>{let x=w.target;x instanceof Element&&dn(x,e,s.selector)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(s.type==="form_submit"){let l=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(s.type==="scroll_depth"){let l=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=l){t.type==="composite"?a(y,!0):u(),w.disconnect();break}},{threshold:[l]});w.observe(e),c.push(()=>w.disconnect());return}}),()=>{for(let s of c)s()}}var fn=new Set,gn=new Set;function Ur(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var jr=12;function Wr(e,t){let n=new Set,r=[];for(let o of t.steps){let u=o.name;!u||u.length>128||u.startsWith("funnel:")||n.has(u)||r.length===jr||(n.add(u),r.push({goalId:u,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,u)=>o.weight-u.weight);return(r.length<t.steps.length||i.some((o,u)=>o!==r[u]))&&F()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function ce(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,u=r!=null?r:o?Ur(n):void 0;if(!u)return;let a=`${u}|${n}`;if(gn.has(a))return;gn.add(a);let c=o&&!fn.has(u)?Wr(n,o):null,s=c!==null&&c.length>=2;s&&fn.add(u),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:u,steps:c}:{funnelId:u}})}function ye(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Kr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function he(){if(typeof window=="undefined")return Kr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function Ve(){he().version+=1;for(let e of he().listeners)e()}var mn=()=>{};function pn(e){return F()?(he().components.set(e.id,e),Ve(),()=>{he().components.delete(e.id),Ve()}):mn}function Oe(e){return F()?(he().slots.set(e.id,e),Ve(),()=>{he().slots.delete(e.id),Ve()}):mn}function xt(e){F()&&(he().sections=[...e],Ve())}var yn="0.41.1",kt=yn!=="0.0.0-dev"?{name:"react",version:yn}:void 0;function Jr(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function Ee(e,t){Jr()[e]=t}function vn(e){window.__sentient_vocabulary_override=e}function Sn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Hr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function Pe(e,t){Hr()[e]=t}function hn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var At="__snt_editor_token",Ge=null,Rt=!1;function bn(){return Rt}function Xr(){try{return sessionStorage.getItem(At)}catch(e){return null}}function He(e){if(Ge)return Ge;let t=typeof window=="undefined"?null:hn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:Xr();return Rt=!!n,Ge=Promise.resolve(n?{token:n,fresh:!1}:null),Ge}return Rt=!0,Ge=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let r=n.ok?(await n.json()).token:void 0;if(!r)return{error:n.ok?500:n.status};try{sessionStorage.setItem(At,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),Ge}function wn(){try{sessionStorage.removeItem(At)}catch(e){}}var xn="sentient_preview_cell",kn="sentient_refresh_region",Ct="sentient-cell-preview-bar",be="__preview__",Te=null;function Rn(e){if((Te==null?void 0:Te.slotId)!==e)return null;let t=Te;return Te=null,t}function An(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>we(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>we("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function Cn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Ct))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(xn),n=c.get(kn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=He(r);if(!bn())return;if(n){Te={slotId:n,session:i,base:r},Ee(n,{kind:"arms"}),Pe(n,be),ht();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let u=t.slice(0,o),a=t.slice(o+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(u)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(we(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){we(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await c.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&vn(s.vocabulary),s.compose!=null)Ee(u,{kind:"arms",compose:{[be]:s.compose}}),Pe(u,be);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))Ee(u,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),Pe(u,be);else if(s.blocks!=null)Ee(u,{kind:"arms",blocks:{[be]:s.blocks}}),Pe(u,be);else if(s.content!=null)Ee(u,{kind:"arms",content:s.content}),Pe(u,be);else{we("Nothing to preview in that square yet.");return}ht(),we(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${u}"]`))==null||y.scrollIntoView({block:"center"})}catch(l){}},300)}).catch(()=>we("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function we(e){var i;if(document.getElementById(Ct))return;let t=document.createElement("div");t.id=Ct,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{wn();let o=new URL(window.location.href);o.searchParams.delete(xn),o.searchParams.delete(kn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var _n=!1;function On(e){if(_n||typeof window=="undefined")return;_n=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");He(t).then(n=>{!n||!("token"in n)||!n.fresh||zr(t,n.token)})}function zr(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:r})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var $n=require("react/jsx-runtime");function qr(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,Xe.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Pn="https://api.sentient-ui.com/v1",Y=(0,C.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Pn,debug:!1}),En=!1,_t=new Set;function Yr(e,t,n){let r=(0,C.useRef)(n);r.current=n;let[i,o]=(0,C.useState)(null),[u,a]=(0,C.useState)(!1),c=(0,C.useRef)(e);c.current=e;let s=e===void 0?"":typeof e=="string"?e:JSON.stringify(V(p({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,C.useEffect)(()=>{let y=c.current;if(y===void 0||typeof window=="undefined")return;let l,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let v=x(typeof y=="object"&&y.cmp===void 0&&y.check?p(V(p({},y),{check:()=>c.current.check()}),y.refused?{refused:()=>{var f,b;return((b=(f=c.current).refused)==null?void 0:b.call(f))===!0}}:{}):y),h=!1,S=()=>{let f=v.refused()&&v.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=v.read();b!==null&&_t.add(t),o(b!=null?b:_t.has(t)?!1:null)};S(),l=v.subscribe(S)}),()=>{w=!0,l==null||l()}},[s,t]),{granted:i,refused:u}}function Gn(e){var T,E,R,A,d;let[t,n]=(0,C.useState)(null),[r]=(0,C.useState)(()=>{var g;return(g=e.sessionSegment)!=null?g:qr()}),[i,o]=(0,C.useState)(vt());(0,C.useEffect)(()=>sn(()=>o(vt())),[]),(0,C.useEffect)(()=>{Cn(e.apiBaseUrl),On(e.apiBaseUrl)},[]);let u=(0,C.useRef)(()=>{}),a=Yr(e.consentFrom,e.apiKey,()=>u.current()),c=e.consentFrom?(T=a.granted)!=null?T:_t.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,y=(0,C.useRef)(s);y.current=s;let l=(0,C.useRef)(null),w=(0,C.useRef)(!1),x=(0,C.useRef)([]),m=(0,C.useRef)(!1);u.current=()=>{var N;x.current=[],m.current=!0;let g=l.current;g!=null&&g.gated?g.dispose():(N=g==null?void 0:g.takeHeld)==null||N.call(g)},(0,C.useEffect)(()=>{var K,J;if(y.current&&c===!1&&(x.current=[]),c===!1&&w.current&&(y.current&&((K=l.current)==null||K.destroy()),l.current=null,w.current=!1),c===!1&&!e.preConsentBehavior){y.current&&((J=l.current)==null||J.destroy()),l.current=null,n(null);return}let g=c!==!1;g&&(m.current=!1);let N=B=>{!g&&m.current&&B.gated&&B.dispose()},I=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},kt?{sdk:kt}:{}),_=!1,G=null,j=null,W=B=>{for(let se of x.current.splice(0))setTimeout(()=>{if(l.current!==B){m.current||x.current.push(se);return}try{se(B)}catch(De){}},0)},X=B=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:se})=>{_||(j=se(B,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:B})=>{_||(G=B(V(p({},I),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),N(G),l.current=G,w.current=g,W(G),n(G),X(G))}):(G=(0,Xe.init)(I),N(G),l.current=G,w.current=g,W(G),n(G),X(G)),()=>{var B,se;_=!0,j==null||j(),x.current=x.current.concat((se=(B=G==null?void 0:G.takeHeld)==null?void 0:B.call(G))!=null?se:[]),G==null||G.dispose()}},[c]),(0,C.useEffect)(()=>{if(!t)return;let g=!1,N=async()=>{if(g)return;let _;try{_=await t.fetchWeights()}catch(G){return}if(!g)for(let G of _){let j={componentId:G.componentId,updatedAt:G.updatedAt,variants:G.variants.map(W=>{var X;return{variantId:W.variantId,pulls:W.pulls,avgReward:(X=W.avgReward)!=null?X:0}})};rn(G.componentId,j)}};N();let I=setInterval(()=>{N()},6e4);return()=>{g=!0,clearInterval(I)}},[t]);let v=(E=e.ssrFallback)!=null?E:"first",h=((R=e.apiBaseUrl)!=null?R:Pn).replace(/\/$/,""),S=(0,C.useRef)(null);(0,C.useEffect)(()=>{var I;if(typeof process!="undefined"&&((I=process.env)==null?void 0:I.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},N=S.current;if(S.current=g,N!==null)for(let _ of["apiKey","context","country","persona","apiBaseUrl"])Object.is(N[_],g[_])||console.warn(`[sentient] AdaptiveProvider: \`${_}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),(0,C.useEffect)(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||un({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;(0,C.useEffect)(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),(0,C.useEffect)(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){xt(g);return}e.declaredSections&&e.declaredSections.length>0&&xt(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,C.useEffect)(()=>{!F()||e.consent!==void 0||e.consentFrom!==void 0||En||(En=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,C.useEffect)(()=>{if(!F())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let N=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),_=>_.getAttribute("data-sentient-id"))),I=g.filter(_=>!N.has(_));I.length>0&&console.warn(`[SentientUI] Declared section${I.length>1?"s":""} ${I.map(_=>`"${_}"`).join(", ")} ${I.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=(0,C.useMemo)(()=>t&&i?an(t):t,[t,i]),P=(0,C.useMemo)(()=>{var g,N,I,_,G,j,W,X,K;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(N=e.initialUnified)!=null?N:Zr,sessionSegment:r,ssrFallback:v,onAssignment:e.onAssignment,initialLayoutOrder:(I=e.initialLayoutOrder)!=null?I:null,initialSlots:(_=e.initialSlots)!=null?_:{},initialSlotConfig:(G=e.initialSlotConfig)!=null?G:{},initialPalette:(j=e.initialPalette)!=null?j:null,initialVocabulary:(W=e.initialVocabulary)!=null?W:null,initialPersona:(X=e.initialPersona)!=null?X:null,apiBaseUrl:h,debug:(K=e.debug)!=null?K:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,v,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return(0,$n.jsx)(Y.Provider,{value:P,children:e.children})}function $(){return(0,C.useContext)(Y).client}function de(){return(0,C.useContext)(Y).apiKey}function ze(){return(0,C.useContext)(Y).initialAssignments}var Zr=[];function qe(){return(0,C.useContext)(Y).initialUnified}function Ie(){return(0,C.useContext)(Y).sessionSegment}function Tn(){return(0,C.useContext)(Y).ssrFallback}function Ye(){return(0,C.useContext)(Y).onAssignment}function In(){return(0,C.useContext)(Y).debug}function Nn(){let e=(0,C.useContext)(Y).initialLayoutOrder,t=(0,C.useSyncExternalStore)(Q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Ze(){return(0,C.useContext)(Y).initialSlots}function Dn(){return(0,C.useContext)(Y).initialPersona}function Ln(){return(0,C.useContext)(Y).initialSlotConfig}function Fn(){return(0,C.useContext)(Y).initialPalette}function Vn(){return(0,C.useContext)(Y).initialVocabulary}function Mn(){return(0,C.useContext)(Y).apiBaseUrl}var ge=require("react");var U=require("react"),Bn=require("@sentientui/core");var re=require("react"),Qe=require("@sentientui/policy");function ve(e){var n;if(typeof window=="undefined")return null;let t=(n=window.__sentient_overrides)==null?void 0:n[e];if(t)return t;if(!window.location.search)return null;try{let r=new URLSearchParams(window.location.search);for(let i of r.getAll("sentient_variant")){let o=i.indexOf(":");if(o!==-1&&i.slice(0,o)===e)return i.slice(o+1)}}catch(r){}return null}function et(e,t,n,r,i){let o=ze(),u=Tn(),a=$(),c=Ie(),s=Ye(),y=In(),l=(0,re.useRef)(null),w=(0,re.useSyncExternalStore)(Q,()=>ve(e),()=>null),x=w&&t.includes(w)?w:null,m=(0,re.useRef)(null);(0,re.useEffect)(()=>{y&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[y,x,e]);let[v,h]=(0,re.useState)(()=>{var k,P;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let T=o[e];return T&&t.includes(T)?{variantId:T,content:null,isLoading:!1,settled:!0}:u==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=yt(e);if(b){let T=(0,Qe.pickFromWeights)(b.variants,t);if(T)return{variantId:T,content:null,isLoading:!1,settled:!0}}return{variantId:(P=t[0])!=null?P:null,content:null,isLoading:!1,settled:!1}}),S=f=>{s&&l.current!==f&&(l.current=f,s(e,f))};return(0,re.useEffect)(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),S(f.variantId);return}let b=yt(e);if(b&&v.settled&&v.variantId&&v.variantId===(0,Qe.pickFromWeights)(b.variants,t)){S(v.variantId);return}h(P=>{var T;return P.variantId?P:{variantId:(T=t[0])!=null?T:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,c]),(0,re.useEffect)(()=>{if(x||!a)return;let f=a.getAssignment(e,c);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(T=>{var E;if(!b&&T){if(T.unified===!0){k==null||k();return}!t.includes(T.variantId)&&!T.content||(h({variantId:T.variantId,content:(E=T.content)!=null?E:null,isLoading:!1,settled:!0}),S(T.variantId))}}),()=>{b=!0}},[x,a,e,c]),(0,re.useEffect)(()=>{if(!x&&a)return nn(e,f=>{var P;let b=a.getAssignment(e,c);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(P=b.content)!=null?P:null,isLoading:!1,settled:!0}),S(b.variantId);return}let k=(0,Qe.pickFromWeights)(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),S(k))})},[x,a,e,c]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:v}function tt(e,t,n){let r=$(),i=de(),o=Object.keys(t).join("\0"),u=(0,U.useMemo)(()=>Object.keys(t),[o]),{variantId:a,content:c,isOverride:s=!1,settled:y}=et(e,u,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,w]=(0,U.useState)(null),x=(0,U.useRef)(null),m=(0,U.useCallback)(d=>{x.current=d,w(d)},[]),v=n.goal,h=typeof v=="string"?v:JSON.stringify(v),S=(0,U.useMemo)(()=>v?te(v):null,[h]),f=v?pe(v):"";(0,U.useEffect)(()=>pn({id:e,variantIds:u,goal:f}),[e,u,f]);let b=(0,U.useRef)(null);(0,U.useEffect)(()=>{s||y&&(!r||!a||!i||!l||b.current!==a&&(b.current=a,ye(r,i,e,a)))},[r,a,i,e,l,s,y]);let k=(0,U.useRef)(!1),P=(0,U.useRef)(new Set);(0,U.useEffect)(()=>{k.current=!1,P.current=new Set},[a,S]);let T=n.funnel;(0,U.useEffect)(()=>{s||!y||!r||!S||ce(r,i,e,T,S)},[r,i,e,T,S,s,y]);let E=n.cursorSignal===!0;(0,U.useEffect)(()=>{if(!E||s||!y||!r||!a||!l)return;let d=null,g=0,N=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},I=()=>{d!==null&&(clearTimeout(d),d=null)};return l.addEventListener("mouseenter",N),l.addEventListener("mouseleave",I),()=>{l.removeEventListener("mouseenter",N),l.removeEventListener("mouseleave",I),d!==null&&clearTimeout(d)}},[E,r,a,i,e,l,s,y]);let R=(0,U.useRef)(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return(0,U.useEffect)(()=>{if(s||!y||!r||!a||!l)return;let d=Date.now();return(0,Bn.attachMicroSignalDetectors)((g,N={})=>{var W,X,K;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},N)});let I=(W=R.current)==null?void 0:W[g];if(!I||P.current.has(g))return;P.current.add(g);let _=typeof I=="string"?I:I.name,G=typeof I=="string"?1:(X=I.weight)!=null?X:1,j=typeof I=="string"?0:(K=I.stepIndex)!=null?K:0;r.goal(_,{metadata:p({signalType:g},N),weight:G,stepIndex:j})},l,d)},[r,a,i,e,l,A,s,y]),(0,U.useEffect)(()=>{if(s||!y||!r||!a||!l||!S)return;let d=le(S);return ue(l,S,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,N,I)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:N}}),r.goal(g,{metadata:{},weight:N,stepIndex:I})}},f)},[r,a,i,e,l,S,f,s,y]),{client:r,variantIds:u,variantId:a,content:c,settled:y,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}var L=require("react"),Re=require("@sentientui/core"),Dt=require("@sentientui/core/region");var ee=require("react"),jn=require("@sentientui/core");var Un=new Set,Qr={kind:"arms"};function Wn(e,t){var P,T,E;let n=$(),r=(0,ee.useRef)(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=(0,ee.useRef)(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=(0,ee.useRef)(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let u=Ze(),a=Ln(),c=Fn(),s=Vn(),y=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),l=(0,ee.useSyncExternalStore)(Q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":(0,jn.armOfResult)(R),x=(0,ee.useCallback)(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);(0,ee.useSyncExternalStore)(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),(0,ee.useSyncExternalStore)(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=y===void 0?a[e]:void 0,v=y===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(P=c!=null?c:n==null?void 0:n.getSitePalette())!=null?P:null,S=(E=s!=null?s:(T=n==null?void 0:n.getStyleVocabulary)==null?void 0:T.call(n))!=null?E:null,f=(()=>{var R,A,d;if(y!==void 0)return{config:y,arm:w(l),palette:h,vocabulary:(R=Sn())!=null?R:S,source:"override"};if(t!=null&&t.forcedArm)return{config:Qr,arm:t.forcedArm,palette:h,vocabulary:S,source:"override"};if(m!==void 0)return{config:m,arm:w((A=u[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:S,source:"preloaded"};if(v!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:v,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:u[e]),palette:h,vocabulary:S,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:S,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return(0,ee.useEffect)(()=>{var G,j,W,X,K;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&(j=(G=r.current)==null?void 0:G.call(r))!=null?j:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(W=i.current)==null?void 0:W.call(i),N=R&&(K=(X=o.current)==null?void 0:X.call(o))!=null?K:null,I=p(p({},g?{render:{[e]:g}}:{}),N?{skeletons:{[e]:N}}:{}),_=Object.keys(I).length>0;return n.requestSlots?_?n.requestSlots([e],d,I):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(N?n.reportSlots([e],d!=null?d:{},{[e]:N}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var J;return(J=n.cancelSlots)==null?void 0:J.call(n,[e])}},[n,k,f.source,e,b]),(0,ee.useEffect)(()=>{!F()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Un.has(e)||(Un.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}var Me=require("react");var M=require("react/jsx-runtime");function Ot(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var Se={none:"0",sm:"8px",md:"16px",lg:"24px"},Et={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},Xn={sm:"0.875em",md:"1em",lg:"1.25em"},ei={sm:"1.25em",md:"1.5em",lg:"2em"},Kn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},Jn={sm:"8px",md:"16px",lg:"32px"},ti={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},ni={normal:"400",medium:"500",bold:"700"};function Hn(e,t){return p(p({},e==="muted"?t!=null&&t.muted?{color:t.muted}:{opacity:.7}:{}),e==="accent"?p({fontWeight:600},t!=null&&t.accent?{color:t.accent}:{}):{})}function zn(e,t,n){var i,o,u,a;let r=t==null?void 0:t.accent;return V(p({display:"inline-block",padding:(i=Kn[n!=null?n:"md"])!=null?i:Kn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:Xn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(u=t==null?void 0:t.primaryBg)!=null?u:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function ri({node:e,opts:t}){var i,o,u,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(u=(o=t.palette)==null?void 0:o.border)!=null?u:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return(0,M.jsxs)("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let y=new FormData(s.currentTarget),l={};for(let v of e.fields)l[v.name]=String((w=y.get(v.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,l)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var y,l;return(0,M.jsxs)("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?(0,M.jsx)("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?(0,M.jsx)("select",{name:s.name,required:s.required,style:r,children:((y=s.options)!=null?y:[]).map(w=>(0,M.jsx)("option",{value:w,children:w},w))}):(0,M.jsx)("input",{name:s.name,type:(l=s.inputType)!=null?l:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),(0,M.jsx)("button",{type:"submit",style:zn(n,t.palette),children:e.submitLabel})]})}function ii(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function qn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function xe(e,t){var i;let n=oi(e,t),r=qn(e.like,t);return n&&r?(0,Me.cloneElement)(n,{style:V(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function oi(e,t){var n,r,i,o,u,a,c,s,y,l,w,x,m,v,h,S,f,b,k,P,T,E,R;try{let A=ii(e,t);switch(e.type){case"stack":{let d=(r=Se[(n=e.gap)!=null?n:"md"])!=null?r:Se.md,g=e.surface==="raised"&&!A,N=(i=e.pad)!=null?i:g?"md":void 0;return(0,M.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:Et[e.align]}:{}),e.justify?{justifyContent:Et[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),N?{padding:(o=Se[N])!=null?o:Se.md}:{}),g?V(p(p({},(u=t.palette)!=null&&u.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(y=(s=t.palette)==null?void 0:s.border)!=null?y:"currentColor"}`,borderRadius:(w=(l=t.palette)==null?void 0:l.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((I,_)=>{let G=xe(I,t);return G===null?null:(0,M.jsx)(Me.Fragment,{children:G},_)})}))}case"grid":{let d=(v=Se[(m=e.gap)!=null?m:"md"])!=null?v:Se.md;return(0,M.jsx)("div",V(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:Et[e.align]}:{}),e.pad?{padding:(h=Se[e.pad])!=null?h:Se.md}:{}),children:((S=e.children)!=null?S:[]).map((g,N)=>{let I=xe(g,t);return I===null?null:(0,M.jsx)(Me.Fragment,{children:I},N)})}))}case"text":return A?(0,M.jsx)("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,M.jsx)("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:Xn[e.size]}:{}),e.weight?{fontWeight:ni[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Hn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?(0,M.jsx)(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):(0,M.jsx)(d,{style:p(p({margin:0,fontSize:ei[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return(0,M.jsx)("a",V(p(p({href:Ot(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:zn(d,t.palette,e.size)}),{children:e.label}))}case"link":return(0,M.jsx)("a",V(p(p({href:Ot(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return(0,M.jsx)("img",V(p({src:Ot(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:ti[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?(0,M.jsx)("span",{className:A,children:e.value}):(0,M.jsx)("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(P=(k=t.palette)==null?void 0:k.border)!=null?P:"currentColor"}`},Hn(e.tone,t.palette)),children:e.value});case"spacer":return(0,M.jsx)("div",{style:{height:(T=Jn[e.size])!=null?T:Jn.md}});case"divider":return(0,M.jsx)("hr",{style:{border:"none",borderTop:`1px solid ${(R=(E=t.palette)==null?void 0:E.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return(0,M.jsx)(ri,{node:e,opts:t});default:return null}}catch(A){return null}}function nt(e,t){var o,u,a,c;let n=xe(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(u=t.vocabulary)==null?void 0:u.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=qn((c=e.surface)==null?void 0:c.like,t);return r?(0,M.jsx)("div",V(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}var fe=require("react"),rt=require("@sentientui/core/region");function it(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function ot(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ke(e){return it(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ke(n),0):(0,fe.isValidElement)(e)?ke(ot(e)):0}function si(e,t){return Array.isArray(t)?(0,fe.cloneElement)(e,void 0,...t):(0,fe.cloneElement)(e,void 0,t)}function Pt(e,t){if(it(e))return t;if(Array.isArray(e))return e.map(n=>Pt(n,t));if((0,fe.isValidElement)(e)){let n=ot(e);return ke(n)===0?e:si(e,Pt(n,t))}return e}function Yn(e,t){return ke(e)===1?Pt(e,t):null}var ne=e=>e.join("/");function Gt(e,t,n){if(it(e)){n.leafPaths.push(t),n.texts.push((0,rt.normalizeLeafText)(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Gt(r,[...t,i],n));return}(0,fe.isValidElement)(e)&&(n.elements.set(ne(t),e),Gt(ot(e),[...t,"c"],n))}function It(e){let t={leafPaths:[],texts:[],elements:new Map};return Gt(e,[],t),t}function ai(e){return It(e).texts}function Zn(e){let t=ai(e);return t.length===0?null:(0,rt.skeletonFingerprint)(t)}function li(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Qn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,c)=>a===i?[li(e.leafPaths[c])]:[]);if(o.length===0){r.push(null);continue}let u=o[0];for(let a of o.slice(1)){let c=new Set(a.map(ne));u=u.filter(s=>c.has(ne(s)))}r.push(u.length>0?u[u.length-1]:null)}return r}function Tt(e){var n;let t=(n=e==null?void 0:e.props)==null?void 0:n.className;return typeof t=="string"?t:void 0}function Nt(e,t){let n=It(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,u)=>o!==e.leaves[u]))return null;let r=Qn(n,e.leafToNode),i=e.nodes.map((o,u)=>{let a=r[u],c=a?n.elements.get(ne(a)):void 0,s=!!c&&(typeof c.type=="string"||Tt(c)!==void 0);return V(p({},o),{restylable:s})});return V(p({},e),{nodes:i})}function er(e,t,n){var m;let r=It(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((v,h)=>Math.max(v,h+1),0);for(let v of Object.keys(t.nodes))if(!/^\d+$/.test(v)||Number(v)>=i)return null;let o=Qn(r,n),u=new Map;n.forEach((v,h)=>{u.has(v)||u.set(v,h)});let a=new Map(r.leafPaths.map((v,h)=>[ne(v),h])),c=new Set,s=new Map,y=!1;for(let[v,h]of Object.entries(t.nodes)){let S=Number(v),f=o[S];if(h.hidden&&(f?c.add(ne(f)):y=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(ne(f)):void 0,P=b?Tt(r.elements.get(ne(b))):void 0;!f||P===void 0||Tt(k)===void 0?y=!0:s.set(ne(f),P)}}let l=new Map(Object.entries((m=t.order)!=null?m:{})),w=(v,h)=>{var S;if(it(v)){let f=a.get(ne(h));if(f===void 0)return v;let b=n[f],k=(S=t.nodes[String(b)])==null?void 0:S.text;return k===void 0?v:u.get(b)===f?k:""}if(Array.isArray(v)){let f=v.map((b,k)=>w(b,[...h,k]));for(let[b,k]of l){let P=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||ne(A.slice(0,-1))!==ne(h)?-1:A[A.length-1]});if(P.some(R=>R<0))continue;let T=[...P].sort((R,A)=>R-A),E=[...f];T.forEach((R,A)=>{f[R]=E[P[A]]}),l.delete(b)}return f}if((0,fe.isValidElement)(v)){let f=ne(h);if(c.has(f))return null;let b=ot(v);if(ke(b)===0)return v;let k=w(b,[...h,"c"]),P=s.get(f),T=P!==void 0?{className:P}:void 0;return Array.isArray(k)?(0,fe.cloneElement)(v,T,...k):(0,fe.cloneElement)(v,T,k)}return v},x=w(e,[]);return y||l.size>0?null:x}var ir=require("react/jsx-runtime"),tr=new Set,nr=new Set,rr=new Set,st="authored.";function Ne({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:u="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:s,clientOnly:y,agentDataByVariant:l,agentData:w,variantsOnly:x=!1}){var Ht,Xt;let m=$(),v=de(),h=(0,L.useRef)(null),[S,f]=(0,L.useState)(!1);(0,L.useEffect)(()=>{f(!0)},[]);let b=y===!0&&(!S||!m),k=(0,L.useMemo)(()=>Zn(t),[t]),P=n?Object.keys(n).join("|"):"",T=(0,L.useMemo)(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ke(t)===1,ops:!1},P!==""?{authored:P.split("|"),children:!x}:{}),[k,t,r,P,x]),E=()=>{var q;let O=h.current;if(!O||!a)return null;let D=(0,Dt.captureRegionSkeleton)(O);return D.skeleton?(q=Nt(D.skeleton,t))!=null?q:V(p({},D.skeleton),{editable:!1,nodes:D.skeleton.nodes.map(H=>V(p({},H),{restylable:!1}))}):{status:D.reason}},R=(0,L.useSyncExternalStore)(Q,()=>n?ve(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${st}${R}`:x?`${st}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:N,vocabulary:I,source:_}=Wn(e,{forcedArm:A,baselineText:a?()=>{var O,D;return(D=(O=h.current)==null?void 0:O.textContent)!=null?D:null}:void 0,render:()=>T,skeleton:E,defer:b}),G=g!==""?(Ht=d==null?void 0:d.blocks)==null?void 0:Ht[g]:void 0,j=g!==""?(Xt=d==null?void 0:d.compose)==null?void 0:Xt[g]:void 0,W=(G!==void 0&&(0,Re.containsFormBlock)(G)||j!==void 0&&(0,Re.containsFormBlock)(j.tree))&&!r;(0,L.useEffect)(()=>{!W||!F()||tr.has(e)||(tr.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[W,e]);let X=O=>{!m||_==="override"||(_!=="seeded"&&m.componentGoal(e,O),m.goal(O,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},K=t,J=!1,B=g.startsWith(st)?g.slice(st.length):null;if((d==null?void 0:d.blocked)==="variant_history")J=!0;else if(B!==null)n&&Object.prototype.hasOwnProperty.call(n,B)?K=n[B]:J=!0;else if(j!==void 0){let O=W?null:nt(j,{palette:N,vocabulary:I,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if(G!==void 0){let O=W?null:xe(G,{palette:N,vocabulary:I,onFormSubmit:r,onFormGoal:X});O===null?J=!0:K=O}else if((d==null?void 0:d.edits)!==void 0&&_!=="none"){let O=d.edits,D=O.fp===k?er(t,O.edits,O.leafToNode):null;D===null?J=!0:K=D}else if((d==null?void 0:d.content)!==void 0&&_!=="none"){let O=Yn(t,d.content);O===null?J=!0:K=O}let se=J&&G===void 0&&j===void 0&&(d==null?void 0:d.edits)===void 0&&B===null&&(d==null?void 0:d.blocked)===void 0;(0,L.useEffect)(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!F()||rr.has(e)||(rr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let De=B!==null&&!J?B:null;(0,L.useEffect)(()=>{var ae;if(!De||!a||!m)return;let O=h.current;if(!O)return;let D=(0,Dt.captureRegionSkeleton)(O),q=D.skeleton?Nt(D.skeleton,n==null?void 0:n[De]):null,H=(ae=O.textContent)==null?void 0:ae.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:De},H?{text:H}:{}),q?{skeleton:q}:{})]})},[De,m,e,b]);let $t=J&&(d==null?void 0:d.edits)!==void 0&&(_==="preloaded"||_==="client");(0,L.useEffect)(()=>{var O;!$t||!(d!=null&&d.edits)||(O=m==null?void 0:m.reportDrift)==null||O.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[$t,e,k,m]);let Be=K===t;(0,L.useEffect)(()=>{var D;if(!(d!=null&&d.needsSkeleton)||!Be)return;let O=E();O&&((D=m==null?void 0:m.reportSkeleton)==null||D.call(m,e,O))},[d==null?void 0:d.needsSkeleton,Be,e,m,b]),(0,L.useEffect)(()=>{if(!Be)return;let O=Rn(e);if(!O)return;let D=E();An(O,D&&"status"in D?{status:D.status}:{skeleton:D})},[e,Be,b]),(0,L.useEffect)(()=>{!se||!F()||nr.has(e)||(nr.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[se,e]);let dt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";(0,L.useEffect)(()=>Oe({id:e,arms:dt===""?void 0:dt.split("|")}),[e,dt]);let Bt=(0,L.useRef)(null);(0,L.useEffect)(()=>{!m||_==="none"||_==="seeded"||_==="override"||g===""||J||Bt.current!==g&&(Bt.current=g,ye(m,v,e,g))},[m,v,e,g,_,J]);let me=_!=="none"&&_!=="seeded"&&!J,ft=me?g:"",Ut=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);(0,L.useEffect)(()=>{if(!m||!i||_==="override")return;let O=h.current;if(!O)return;let D=pe(i),q=le(i),H=!1;return ue(O,te(i),{fireGoal:()=>{H||(H=!0,me&&(q!==void 0?m.componentGoal(e,D,{value:q}):m.componentGoal(e,D)),m.goal(D,p({metadata:{componentId:e,arm:ft},weight:1,stepIndex:0},q!==void 0?{value:q}:{})))},fireStep:(ae,je,mt)=>{me&&m.componentGoal(e,ae,{reward:je}),m.goal(ae,{metadata:{componentId:e,arm:ft},weight:je,stepIndex:mt})}},D)},[m,e,Ut,g,_,J,me,ft,b]);let gt=(0,L.useMemo)(()=>i?te(i):null,[Ut]);(0,L.useEffect)(()=>{_==="override"||!m||!gt||ce(m,v,e,c,gt)},[m,v,e,c,gt,_]);let jt=(0,L.useRef)(s);jt.current=s;let Wt=(0,L.useRef)(new Set),Pr=s?JSON.stringify(s):"";(0,L.useEffect)(()=>{if(!m||_==="override"||!me||g==="")return;let O=h.current;if(O)return(0,Re.attachMicroSignalDetectors)((D,q={})=>{var zt,qt,Yt;m.track({projectId:v,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:D},q)});let H=(zt=jt.current)==null?void 0:zt[D];if(!H||Wt.current.has(D))return;Wt.current.add(D);let ae=typeof H=="string"?H:H.name,je=typeof H=="string"?1:(qt=H.weight)!=null?qt:1,mt=typeof H=="string"?0:(Yt=H.stepIndex)!=null?Yt:0;m.goal(ae,{metadata:p({componentId:e,arm:g,signalType:D},q),weight:je,stepIndex:mt})},O,Date.now())},[m,v,e,g,_,me,Pr,b]);let Kt=(0,L.useRef)({agentData:w,agentDataByVariant:l});Kt.current={agentData:w,agentDataByVariant:l};let Jt=(0,L.useRef)(null);(0,L.useEffect)(()=>{var ae;if(!m||_==="override"||!me||g===""||Jt.current===g)return;let{agentData:O,agentDataByVariant:D}=Kt.current,q=B!=null?B:g,H=D!==void 0?Object.prototype.hasOwnProperty.call(D,q)?D[q]:void 0:O;H!==void 0&&(Jt.current=g,(ae=m.reportAgentData)==null||ae.call(m,e,g,H))},[m,e,g,me,B,_]);let Ue=(0,L.useRef)(null);(0,L.useEffect)(()=>{let O=h.current;if(O){if(Ue.current===null){Ue.current=g;return}Ue.current!==g&&(Ue.current=g,(0,Re.reveal)(O))}},[g,b]);let Gr=(0,L.useMemo)(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:(0,ir.jsx)(u,V(p({ref:h,className:o},Gr),{children:K}))}var Ae=require("react/jsx-runtime");function ui(e){var y,l;let{client:t,variantId:n,content:r,ref:i}=tt(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,u]=(0,ge.useState)(!1);(0,ge.useEffect)(()=>{u(!0)},[]);let a=(y=e.as)!=null?y:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,s=c===null?r:null;return F()&&c===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),(0,Ae.jsx)(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:s})}var ci=(0,ge.memo)(ui,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function or(e){if(e.variants===void 0)return(0,Ae.jsx)(Ne,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Fe(n,["variants"]);return(0,Ae.jsx)(Ne,V(p({},i),{children:t.children,variants:r}))}return(0,Ae.jsx)(di,p({},t))}function di(e){var l;let[t,n]=(0,ge.useState)(null),{id:r}=e,i=(0,ge.useCallback)(()=>n(r),[r]),o=$(),u=qe().includes(r)||((l=o==null?void 0:o.isUnified)==null?void 0:l.call(o,r))===!0;if(t!==r&&!u)return(0,Ae.jsx)(ci,V(p({},e),{onUnified:i}));let w=e,{variants:a,children:c}=w,s=Fe(w,["variants","children"]),y=Object.keys(a)[0];return(0,Ae.jsx)(Ne,V(p({},s),{variants:a,variantsOnly:!0,children:y!==void 0?a[y]:null}))}var z=require("react");var ar=require("react/jsx-runtime");function sr({id:e,default:t,component:n="span",className:r,goal:i}){var T;let o=$(),u=de(),a=Ye(),c=Ie(),s=(0,z.useRef)(null),y=(0,z.useRef)(null),l=(0,z.useSyncExternalStore)(Q,()=>ve(e),()=>null),[w,x]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,c))==null?void 0:E.content)!=null?R:null}),[m,v]=(0,z.useState)(()=>{var E,R;return(R=(E=o==null?void 0:o.getAssignment(e,c))==null?void 0:E.variantId)!=null?R:null});(0,z.useEffect)(()=>{if(l||!o)return;let E=o.getAssignment(e,c);if((E==null?void 0:E.content)!==void 0){v(E.variantId),x(E.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){F()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,c,l]),(0,z.useEffect)(()=>{l||!o||!m||!u||s.current!==m&&(s.current=m,o.track({projectId:u,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,u,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),S=(0,z.useMemo)(()=>i===void 0?null:te(i),[h]),f=i===void 0?null:typeof i=="string"?i:S.type,b=(0,z.useRef)(!1);(0,z.useEffect)(()=>{b.current=!1},[m,h]),(0,z.useEffect)(()=>{l||!o||!u||ce(o,u,e,void 0,S)},[o,u,e,S,l]),(0,z.useEffect)(()=>{if(l||!o||!m||!u||!S||!f)return;let E=y.current;if(!E)return;let R=le(S);return ue(E,S,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,u,e,S,f,l]);let k=w!=null?w:t;if(l){let E=o==null?void 0:o.getAssignment(e,c);k=E&&E.variantId===l&&(T=E.content)!=null?T:t}return(0,ar.jsx)(n,{ref:E=>{y.current=E},className:r,children:k})}var at=require("react");function lt(e){let t=$(),n=(0,at.useRef)(new Set);return(0,at.useCallback)((r,i)=>{var o,u;if(!ve(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,p(p(p({metadata:(o=i==null?void 0:i.metadata)!=null?o:{},weight:(u=i==null?void 0:i.reward)!=null?u:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}var $e=require("react");function lr(e,t={}){let c=t,{componentId:n}=c,r=Fe(c,["componentId"]),i=$(),o=lt(n!=null?n:""),u=(0,$e.useRef)(!1),a=(0,$e.useRef)(r);a.current=r,(0,$e.useEffect)(()=>{if(!i||u.current||i.gated)return;u.current=!0;let{metadata:s,reward:y,value:l,currency:w,externalId:x}=a.current;if(n){o(e,a.current);return}i.goal(e,p(p(p({metadata:s!=null?s:{},weight:y!=null?y:1,stepIndex:0},l!==void 0?{value:l}:{}),w!==void 0?{currency:w}:{}),x!==void 0?{externalId:x}:{}))},[i,n,e,o])}var ur=require("@sentientui/core"),cr=require("@sentientui/policy"),fr=require("react/jsx-runtime");function Lt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function fi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Lt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Lt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Lt((0,cr.confidenceBand)(e.persona.confidence))+");}catch(e){}})();":(0,ur.renderPrePaintScript)(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function dr(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:(0,fr.jsx)("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:fi(e)}})}var oe=require("react"),yr=require("@sentientui/policy");var ie=require("react"),Ce=require("@sentientui/core"),gr=require("@sentientui/policy");function ut(e,t){let n=$(),r=Ze(),[,i]=(0,ie.useReducer)(l=>l+1,0),o=(0,ie.useSyncExternalStore)(Q,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),u=o===void 0?r[e]:void 0,a=o===void 0&&u===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&o===void 0&&u===void 0&&a===null;(0,ie.useEffect)(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(w=>{!l&&w&&i()}),()=>{l=!0}},[n,e,c]);let s=(()=>{if(o!==void 0)return{result:o,arm:(0,Ce.armOfResult)(o),source:"override"};if(u!==void 0)return{result:u,arm:(0,Ce.armOfResult)(u),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:(0,Ce.armOfResult)(a),source:w?"client":"seeded"}}let l=(0,Ce.baselineResultFor)(t);return{result:l,arm:(0,Ce.armOfResult)(l),source:"baseline"}})(),y=s.source==="preloaded"||s.source==="override";return(0,ie.useEffect)(()=>{var w;if(!n||n.isLocal===!0||y||!n.decideSlots)return;let l=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),l==null||l()}},[n,e,y]),s}function gi(){var t;if(typeof window=="undefined")return null;let e=window.__sentient_persona_override;if(e!=null&&e.persona)return{persona:e.persona,confidence:(t=e.confidence)!=null?t:1};try{let n=new URLSearchParams(window.location.search).get("sentient_persona");if(n)return{persona:n,confidence:1}}catch(n){}return null}function mr(){let e=$(),t=Dn();(0,ie.useSyncExternalStore)(Q,ln,()=>0);let[n,r]=(0,ie.useState)(!1);(0,ie.useEffect)(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:(0,gr.confidenceBand)(a.confidence)});if(!n)return t?i(t):null;let o=gi();if(o)return i(o);if(t)return i(t);let u=e?e.getPersona():null;return u?i(u):null}var pr=new Set;function mi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function vr(e,t,n){let r=$(),i=de(),o=JSON.stringify(t),u=(0,oe.useMemo)(()=>({id:e,dims:t}),[e,o]),{result:a,arm:c,source:s}=ut(e,u),y=(0,oe.useMemo)(()=>typeof a=="string"?{}:a,[c]);if(F()&&!pr.has(e)){pr.add(e);let v=(0,yr.validateSlotDecl)({id:e,dims:Object.fromEntries(Object.entries(t).map(([S,f])=>[S,[...f]]))}),h=Object.values(t).reduce((S,f)=>S*f.length,1);v.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);(0,oe.useEffect)(()=>Oe({id:e,dims:t}),[e]);let w=(0,oe.useRef)(null);(0,oe.useEffect)(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,ye(r,i,e,c))},[r,i,e,c,s]);let x=n==null?void 0:n.funnel;(0,oe.useEffect)(()=>{var v;!r||s==="override"||ce(r,i,e,x,te((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,x,l,s]),(0,oe.useEffect)(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${mi(e)}"]`);if(!v){F()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=pe(n.goal),S=le(n.goal),f=!1;return ue(v,te(n.goal),{fireGoal:()=>{f||(f=!0,S!==void 0?r.componentGoal(e,h,{value:S}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},S!==void 0?{value:S}:{})))},fireStep:(b,k,P)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:c},weight:k,stepIndex:P})}},h)},[r,e,l,c,s]);let m=(0,oe.useMemo)(()=>{let v={"data-sentient-slot":e};for(let[h,S]of Object.entries(y))v[`data-${h}`]=S;return v},[e,y]);return{tokens:y,props:m}}var _e=require("react");var Sr=new Set,hr=new Set;function br(e,t){var m,v;if(F()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:u,ref:a,nodeRef:c}=tt(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",y=t.variants[s],l=qe().includes(e)||((v=n==null?void 0:n.isUnified)==null?void 0:v.call(n,e))===!0;(0,_e.useEffect)(()=>{!l||!F()||hr.has(e)||(hr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),(0,_e.useEffect)(()=>{if(!F()||!n)return;let h=setTimeout(()=>{!c.current&&!Sr.has(e)&&(Sr.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=(0,_e.useCallback)((h,S)=>{var b,k;if(o)return;let f=h!=null?h:u;f&&(n==null||n.componentGoal(e,f,S),n==null||n.goal(f,p(p(p({metadata:(b=S==null?void 0:S.metadata)!=null?b:{},weight:(k=S==null?void 0:S.reward)!=null?k:1,stepIndex:0},(S==null?void 0:S.value)!==void 0?{value:S.value}:{}),(S==null?void 0:S.currency)!==void 0?{currency:S.currency}:{}),(S==null?void 0:S.externalId)!==void 0?{externalId:S.externalId}:{})))},[n,e,u,o]),x=(0,_e.useMemo)(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:y,bind:x,fireGoal:w}}var Z=require("react");var xr=require("react/jsx-runtime"),ct=new Set;function wr(e){var f;let t=$(),n=de(),r=(0,Z.useRef)(null),i=Object.keys(e.arrangements).join(" "),o=(0,Z.useMemo)(()=>Object.keys(e.arrangements),[i]),u=(0,Z.useMemo)(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:c}=ut(e.id,u);F()&&e.baseline!==void 0&&e.baseline!==o[0]&&!ct.has(e.id+":baseline")&&(ct.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Z.Children.toArray(e.children).filter(Z.isValidElement),y=new Map;for(let b of s)y.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let l=e.arrangements[a],w=l!==void 0&&l.length===s.length&&l.every(b=>y.has(b));F()&&l!==void 0&&!w&&!ct.has(e.id+":keys")&&(ct.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?l.map(b=>y.get(b)):s;(0,Z.useEffect)(()=>Oe({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||m.current===a||(m.current=a,ye(t,n,e.id,a))},[t,n,e.id,a,c]);let v=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);(0,Z.useEffect)(()=>{var b;!t||c==="override"||ce(t,n,e.id,v,te((b=e.goal)!=null?b:"click"))},[t,n,e.id,v,h,c]);let S=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return(0,Z.useEffect)(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let b=r.current;if(!b)return;let k=pe(e.goal),P=le(e.goal),T=!1;return ue(b,te(e.goal),{fireGoal:()=>{T||(T=!0,P!==void 0?t.componentGoal(e.id,k,{value:P}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},P!==void 0?{value:P}:{})))},fireStep:(E,R,A)=>{t.componentGoal(e.id,E,{reward:R}),t.goal(E,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,S,a,c]),(0,xr.jsx)("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}var Ft=require("@sentientui/core");var pi=["page","blocks","layoutOrder"],kr=new Map;function Rr(e,t){kr.set(e,t)}function Vt(e){return kr.get(e)}function Ar(e){var i,o;let t=(o=(i=e.content)!=null?i:Vt(e.page))!=null?o:{},n={};for(let[u,a]of Object.entries(t))pi.includes(u)||(n[u]=a);let r=V(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Cr(e){return`<script type="application/ld+json">${Mt(e)}</script>`}function Mt(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function _r(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
4
|
`}var Or=require("@sentientui/core"),Er=require("@sentientui/core/consent");0&&(module.exports={Adaptive,AdaptiveGroup,AdaptiveProvider,AdaptiveSlot,AdaptiveText,SentientPersonaScript,buildAgentFeed,consentWatcher,defineAgentContent,detectSegment,getAgentContent,grantConsent,renderAgentJsonLd,renderAgentJsonLdBody,renderAgentMarkdown,renderBlocks,renderCompose,useAdaptive,useAdaptiveApiBaseUrl,useAdaptiveGoal,useAdaptivePersona,useAdaptiveTokens,useAssignment,useInitialAssignments,useLayoutOrder,usePageGoal,useSentient,useSessionSegment});
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var yr=Object.defineProperty,vr=Object.defineProperties;var Sr=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Ht=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))Xt.call(t,n)&&Ht(e,n,t[n]);if(Le)for(var n of Le(t))zt.call(t,n)&&Ht(e,n,t[n]);return e},L=(e,t)=>vr(e,Sr(t));var Ce=(e,t)=>{var n={};for(var r in e)Xt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Le)for(var r of Le(e))t.indexOf(r)<0&&zt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Er,useContext as X,useEffect as Q,useMemo as Rn,useRef as se,useState as Oe,useSyncExternalStore as Pr}from"react";import{deriveSessionSegment as Gr,init as Tr}from"@sentientui/core";var qt=new Map,Fe=new Map;function Yt(e,t){let n=Fe.get(e);return n||(n=new Set,Fe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Fe.delete(e)}}function Zt(e,t){qt.set(e,t);let n=Fe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function st(e){var t;return(t=qt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Qt(){if(typeof window=="undefined")return hr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function at(){return Qt().on}function en(e){let t=Qt().listeners;return t.add(e),()=>{t.delete(e)}}function tn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,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 lt="sentient:overrides-changed";function nn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ut(){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(lt))}function q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(lt,e),()=>window.removeEventListener(lt,e))}function rn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function Y(e){return typeof e=="string"?{type:"click"}:e}function le(e){return typeof e=="string"?e:e.type}function ne(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ct=new Set,dt=!1;function on(e){if(ct.has(e))return!0;if(ct.add(e),!dt){dt=!0;let t=()=>{dt=!1,ct.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function sn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(br(r))return!0;r=r.parentElement}return!1}function re(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,y=[];return t.steps.forEach(({goal:l,name:w,weight:x},m)=>{let v=(h=!1)=>{s.has(m)||h&&r!==void 0&&on(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(l.type==="click"){let h=S=>{let f=S.target;f instanceof Element&&sn(f,e,l.selector)&&v()};e.addEventListener("click",h),y.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=S=>{S.target instanceof HTMLFormElement&&e.contains(S.target)&&v()};e.addEventListener("submit",h),y.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),S=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){v(!0),S.disconnect();break}},{threshold:[h]});S.observe(e),y.push(()=>S.disconnect())}}),()=>{for(let l of y)l()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,y)=>y)),u=()=>{r!==void 0&&on(r)||n.fireGoal()},a=(s,y=!1)=>{o.delete(s),o.size===0&&(y?u():n.fireGoal())},c=[];return i.forEach((s,y)=>{if(s.type==="click"){let l=w=>{let x=w.target;x instanceof Element&&sn(x,e,s.selector)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(s.type==="form_submit"){let l=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(s.type==="scroll_depth"){let l=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=l){t.type==="composite"?a(y,!0):u(),w.disconnect();break}},{threshold:[l]});w.observe(e),c.push(()=>w.disconnect());return}}),()=>{for(let s of c)s()}}var an=new Set,ln=new Set;function wr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var xr=12;function kr(e,t){let n=new Set,r=[];for(let o of t.steps){let u=o.name;!u||u.length>128||u.startsWith("funnel:")||n.has(u)||r.length===xr||(n.add(u),r.push({goalId:u,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,u)=>o.weight-u.weight);return(r.length<t.steps.length||i.some((o,u)=>o!==r[u]))&&D()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function ie(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,u=r!=null?r:o?wr(n):void 0;if(!u)return;let a=`${u}|${n}`;if(ln.has(a))return;ln.add(a);let c=o&&!an.has(u)?kr(n,o):null,s=c!==null&&c.length>=2;s&&an.add(u),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:u,steps:c}:{funnelId:u}})}function ue(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Rr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function fe(){if(typeof window=="undefined")return Rr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function _e(){fe().version+=1;for(let e of fe().listeners)e()}var un=()=>{};function cn(e){return D()?(fe().components.set(e.id,e),_e(),()=>{fe().components.delete(e.id),_e()}):un}function Se(e){return D()?(fe().slots.set(e.id,e),_e(),()=>{fe().slots.delete(e.id),_e()}):un}function ft(e){D()&&(fe().sections=[...e],_e())}var dn="0.41.0",gt=dn!=="0.0.0-dev"?{name:"react",version:dn}:void 0;function Ar(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){Ar()[e]=t}function fn(e){window.__sentient_vocabulary_override=e}function gn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Cr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){Cr()[e]=t}function mn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var pt="__snt_editor_token",we=null,mt=!1;function pn(){return mt}function _r(){try{return sessionStorage.getItem(pt)}catch(e){return null}}function Ve(e){if(we)return we;let t=typeof window=="undefined"?null:mn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:_r();return mt=!!n,we=Promise.resolve(n?{token:n,fresh:!1}:null),we}return mt=!0,we=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(pt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),we}function yn(){try{sessionStorage.removeItem(pt)}catch(e){}}var vn="sentient_preview_cell",Sn="sentient_refresh_region",yt="sentient-cell-preview-bar",ge="__preview__",xe=null;function hn(e){if((xe==null?void 0:xe.slotId)!==e)return null;let t=xe;return xe=null,t}function bn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>me(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>me("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function wn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(yt))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(vn),n=c.get(Sn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Ve(r);if(!pn())return;if(n){xe={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,ge),ut();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let u=t.slice(0,o),a=t.slice(o+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(u)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(me(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){me(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await c.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&fn(s.vocabulary),s.compose!=null)he(u,{kind:"arms",compose:{[ge]:s.compose}}),be(u,ge);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))he(u,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),be(u,ge);else if(s.blocks!=null)he(u,{kind:"arms",blocks:{[ge]:s.blocks}}),be(u,ge);else if(s.content!=null)he(u,{kind:"arms",content:s.content}),be(u,ge);else{me("Nothing to preview in that square yet.");return}ut(),me(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${u}"]`))==null||y.scrollIntoView({block:"center"})}catch(l){}},300)}).catch(()=>me("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function me(e){var i;if(document.getElementById(yt))return;let t=document.createElement("div");t.id=yt,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{yn();let o=new URL(window.location.href);o.searchParams.delete(vn),o.searchParams.delete(Sn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var xn=!1;function kn(e){if(xn||typeof window=="undefined")return;xn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Ve(t).then(n=>{!n||!("token"in n)||!n.fresh||Or(t,n.token)})}function Or(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 Mr}from"react/jsx-runtime";function Ir(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Gr({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Cn="https://api.sentient-ui.com/v1",H=Er({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Cn,debug:!1}),An=!1,vt=new Set;function Nr(e,t,n){let r=se(n);r.current=n;let[i,o]=Oe(null),[u,a]=Oe(!1),c=se(e);c.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 Q(()=>{let y=c.current;if(y===void 0||typeof window=="undefined")return;let l,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let v=x(typeof y=="object"&&y.cmp===void 0&&y.check?p(L(p({},y),{check:()=>c.current.check()}),y.refused?{refused:()=>{var f,b;return((b=(f=c.current).refused)==null?void 0:b.call(f))===!0}}:{}):y),h=!1,S=()=>{let f=v.refused()&&v.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=v.read();b!==null&&vt.add(t),o(b!=null?b:vt.has(t)?!1:null)};S(),l=v.subscribe(S)}),()=>{w=!0,l==null||l()}},[s,t]),{granted:i,refused:u}}function Dr(e){var G,O,R,A,d;let[t,n]=Oe(null),[r]=Oe(()=>{var g;return(g=e.sessionSegment)!=null?g:Ir()}),[i,o]=Oe(at());Q(()=>en(()=>o(at())),[]),Q(()=>{wn(e.apiBaseUrl),kn(e.apiBaseUrl)},[]);let u=se(()=>{}),a=Nr(e.consentFrom,e.apiKey,()=>u.current()),c=e.consentFrom?(G=a.granted)!=null?G:vt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,y=se(s);y.current=s;let l=se(null),w=se(!1),x=se([]),m=se(!1);u.current=()=>{var I;x.current=[],m.current=!0;let g=l.current;g!=null&&g.gated?g.dispose():(I=g==null?void 0:g.takeHeld)==null||I.call(g)},Q(()=>{var U,j;if(y.current&&c===!1&&(x.current=[]),c===!1&&w.current&&(y.current&&((U=l.current)==null||U.destroy()),l.current=null,w.current=!1),c===!1&&!e.preConsentBehavior){y.current&&((j=l.current)==null||j.destroy()),l.current=null,n(null);return}let g=c!==!1;g&&(m.current=!1);let I=V=>{!g&&m.current&&V.gated&&V.dispose()},T=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},gt?{sdk:gt}:{}),C=!1,P=null,$=null,B=V=>{for(let ee of x.current.splice(0))setTimeout(()=>{if(l.current!==V){m.current||x.current.push(ee);return}try{ee(V)}catch(Ae){}},0)},K=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:ee})=>{C||($=ee(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{C||(P=V(L(p({},T),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),I(P),l.current=P,w.current=g,B(P),n(P),K(P))}):(P=Tr(T),I(P),l.current=P,w.current=g,B(P),n(P),K(P)),()=>{var V,ee;C=!0,$==null||$(),x.current=x.current.concat((ee=(V=P==null?void 0:P.takeHeld)==null?void 0:V.call(P))!=null?ee:[]),P==null||P.dispose()}},[c]),Q(()=>{if(!t)return;let g=!1,I=async()=>{if(g)return;let C;try{C=await t.fetchWeights()}catch(P){return}if(!g)for(let P of C){let $={componentId:P.componentId,updatedAt:P.updatedAt,variants:P.variants.map(B=>{var K;return{variantId:B.variantId,pulls:B.pulls,avgReward:(K=B.avgReward)!=null?K:0}})};Zt(P.componentId,$)}};I();let T=setInterval(()=>{I()},6e4);return()=>{g=!0,clearInterval(T)}},[t]);let v=(O=e.ssrFallback)!=null?O:"first",h=((R=e.apiBaseUrl)!=null?R:Cn).replace(/\/$/,""),S=se(null);Q(()=>{var T;if(typeof process!="undefined"&&((T=process.env)==null?void 0:T.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},I=S.current;if(S.current=g,I!==null)for(let C of["apiKey","context","country","persona","apiBaseUrl"])Object.is(I[C],g[C])||console.warn(`[sentient] AdaptiveProvider: \`${C}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),Q(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||rn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;Q(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),Q(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){ft(g);return}e.declaredSections&&e.declaredSections.length>0&&ft(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),Q(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||An||(An=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),Q(()=>{if(!D())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let I=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),C=>C.getAttribute("data-sentient-id"))),T=g.filter(C=>!I.has(C));T.length>0&&console.warn(`[SentientUI] Declared section${T.length>1?"s":""} ${T.map(C=>`"${C}"`).join(", ")} ${T.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=Rn(()=>t&&i?tn(t):t,[t,i]),E=Rn(()=>{var g,I,T,C,P,$,B,K,U;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(I=e.initialUnified)!=null?I:Lr,sessionSegment:r,ssrFallback:v,onAssignment:e.onAssignment,initialLayoutOrder:(T=e.initialLayoutOrder)!=null?T:null,initialSlots:(C=e.initialSlots)!=null?C:{},initialSlotConfig:(P=e.initialSlotConfig)!=null?P:{},initialPalette:($=e.initialPalette)!=null?$:null,initialVocabulary:(B=e.initialVocabulary)!=null?B:null,initialPersona:(K=e.initialPersona)!=null?K:null,apiBaseUrl:h,debug:(U=e.debug)!=null?U:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,v,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return Mr(H.Provider,{value:E,children:e.children})}function F(){return X(H).client}function oe(){return X(H).apiKey}function St(){return X(H).initialAssignments}var Lr=[];function Me(){return X(H).initialUnified}function Ee(){return X(H).sessionSegment}function _n(){return X(H).ssrFallback}function $e(){return X(H).onAssignment}function On(){return X(H).debug}function Fr(){let e=X(H).initialLayoutOrder,t=Pr(q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Be(){return X(H).initialSlots}function En(){return X(H).initialPersona}function Pn(){return X(H).initialSlotConfig}function Gn(){return X(H).initialPalette}function Tn(){return X(H).initialVocabulary}function Vr(){return X(H).apiBaseUrl}import{memo as di,useCallback as fi,useEffect as gi,useState as tr}from"react";import{useCallback as Ur,useEffect as pe,useMemo as Nn,useRef as Pe,useState as jr}from"react";import{attachMicroSignalDetectors as Wr}from"@sentientui/core";import{useEffect as Ue,useRef as In,useState as $r,useSyncExternalStore as Br}from"react";import{pickFromWeights as ht}from"@sentientui/policy";function ce(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 bt(e,t,n,r,i){let o=St(),u=_n(),a=F(),c=Ee(),s=$e(),y=On(),l=In(null),w=Br(q,()=>ce(e),()=>null),x=w&&t.includes(w)?w:null,m=In(null);Ue(()=>{y&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[y,x,e]);let[v,h]=$r(()=>{var k,E;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let G=o[e];return G&&t.includes(G)?{variantId:G,content:null,isLoading:!1,settled:!0}:u==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=st(e);if(b){let G=ht(b.variants,t);if(G)return{variantId:G,content:null,isLoading:!1,settled:!0}}return{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}}),S=f=>{s&&l.current!==f&&(l.current=f,s(e,f))};return Ue(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),S(f.variantId);return}let b=st(e);if(b&&v.settled&&v.variantId&&v.variantId===ht(b.variants,t)){S(v.variantId);return}h(E=>{var G;return E.variantId?E:{variantId:(G=t[0])!=null?G:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,c]),Ue(()=>{if(x||!a)return;let f=a.getAssignment(e,c);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(G=>{var O;if(!b&&G){if(G.unified===!0){k==null||k();return}!t.includes(G.variantId)&&!G.content||(h({variantId:G.variantId,content:(O=G.content)!=null?O:null,isLoading:!1,settled:!0}),S(G.variantId))}}),()=>{b=!0}},[x,a,e,c]),Ue(()=>{if(!x&&a)return Yt(e,f=>{var E;let b=a.getAssignment(e,c);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(E=b.content)!=null?E:null,isLoading:!1,settled:!0}),S(b.variantId);return}let k=ht(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),S(k))})},[x,a,e,c]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:v}function je(e,t,n){let r=F(),i=oe(),o=Object.keys(t).join("\0"),u=Nn(()=>Object.keys(t),[o]),{variantId:a,content:c,isOverride:s=!1,settled:y}=bt(e,u,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,w]=jr(null),x=Pe(null),m=Ur(d=>{x.current=d,w(d)},[]),v=n.goal,h=typeof v=="string"?v:JSON.stringify(v),S=Nn(()=>v?Y(v):null,[h]),f=v?le(v):"";pe(()=>cn({id:e,variantIds:u,goal:f}),[e,u,f]);let b=Pe(null);pe(()=>{s||y&&(!r||!a||!i||!l||b.current!==a&&(b.current=a,ue(r,i,e,a)))},[r,a,i,e,l,s,y]);let k=Pe(!1),E=Pe(new Set);pe(()=>{k.current=!1,E.current=new Set},[a,S]);let G=n.funnel;pe(()=>{s||!y||!r||!S||ie(r,i,e,G,S)},[r,i,e,G,S,s,y]);let O=n.cursorSignal===!0;pe(()=>{if(!O||s||!y||!r||!a||!l)return;let d=null,g=0,I=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},T=()=>{d!==null&&(clearTimeout(d),d=null)};return l.addEventListener("mouseenter",I),l.addEventListener("mouseleave",T),()=>{l.removeEventListener("mouseenter",I),l.removeEventListener("mouseleave",T),d!==null&&clearTimeout(d)}},[O,r,a,i,e,l,s,y]);let R=Pe(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return pe(()=>{if(s||!y||!r||!a||!l)return;let d=Date.now();return Wr((g,I={})=>{var B,K,U;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},I)});let T=(B=R.current)==null?void 0:B[g];if(!T||E.current.has(g))return;E.current.add(g);let C=typeof T=="string"?T:T.name,P=typeof T=="string"?1:(K=T.weight)!=null?K:1,$=typeof T=="string"?0:(U=T.stepIndex)!=null?U:0;r.goal(C,{metadata:p({signalType:g},I),weight:P,stepIndex:$})},l,d)},[r,a,i,e,l,A,s,y]),pe(()=>{if(s||!y||!r||!a||!l||!S)return;let d=ne(S);return re(l,S,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:I}}),r.goal(g,{metadata:{},weight:I,stepIndex:T})}},f)},[r,a,i,e,l,S,f,s,y]),{client:r,variantIds:u,variantId:a,content:c,settled:y,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}import{useEffect as z,useMemo as ze,useRef as ve,useState as si,useSyncExternalStore as ai}from"react";import{attachMicroSignalDetectors as li,containsFormBlock as qn,reveal as ui}from"@sentientui/core";import{captureRegionSkeleton as Yn}from"@sentientui/core/region";import{useCallback as Kr,useEffect as Dn,useRef as wt,useSyncExternalStore as We}from"react";import{armOfResult as Jr}from"@sentientui/core";var Ln=new Set,Hr={kind:"arms"};function Fn(e,t){var E,G,O;let n=F(),r=wt(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=wt(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=wt(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let u=Be(),a=Pn(),c=Gn(),s=Tn(),y=We(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),l=We(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":Jr(R),x=Kr(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);We(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),We(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=y===void 0?a[e]:void 0,v=y===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(E=c!=null?c:n==null?void 0:n.getSitePalette())!=null?E:null,S=(O=s!=null?s:(G=n==null?void 0:n.getStyleVocabulary)==null?void 0:G.call(n))!=null?O:null,f=(()=>{var R,A,d;if(y!==void 0)return{config:y,arm:w(l),palette:h,vocabulary:(R=gn())!=null?R:S,source:"override"};if(t!=null&&t.forcedArm)return{config:Hr,arm:t.forcedArm,palette:h,vocabulary:S,source:"override"};if(m!==void 0)return{config:m,arm:w((A=u[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:S,source:"preloaded"};if(v!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:v,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:u[e]),palette:h,vocabulary:S,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:S,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return Dn(()=>{var P,$,B,K,U;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&($=(P=r.current)==null?void 0:P.call(r))!=null?$:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(B=i.current)==null?void 0:B.call(i),I=R&&(U=(K=o.current)==null?void 0:K.call(o))!=null?U:null,T=p(p({},g?{render:{[e]:g}}:{}),I?{skeletons:{[e]:I}}:{}),C=Object.keys(T).length>0;return n.requestSlots?C?n.requestSlots([e],d,T):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(I?n.reportSlots([e],d!=null?d:{},{[e]:I}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var j;return(j=n.cancelSlots)==null?void 0:j.call(n,[e])}},[n,k,f.source,e,b]),Dn(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Ln.has(e)||(Ln.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}import{cloneElement as Xr,Fragment as Vn}from"react";import{jsx as M,jsxs as Un}from"react/jsx-runtime";function xt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var de={none:"0",sm:"8px",md:"16px",lg:"24px"},kt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},jn={sm:"0.875em",md:"1em",lg:"1.25em"},zr={sm:"1.25em",md:"1.5em",lg:"2em"},Mn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},$n={sm:"8px",md:"16px",lg:"32px"},qr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Yr={normal:"400",medium:"500",bold:"700"};function Bn(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 Wn(e,t,n){var i,o,u,a;let r=t==null?void 0:t.accent;return L(p({display:"inline-block",padding:(i=Mn[n!=null?n:"md"])!=null?i:Mn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:jn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(u=t==null?void 0:t.primaryBg)!=null?u:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Zr({node:e,opts:t}){var i,o,u,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(u=(o=t.palette)==null?void 0:o.border)!=null?u:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return Un("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let y=new FormData(s.currentTarget),l={};for(let v of e.fields)l[v.name]=String((w=y.get(v.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,l)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var y,l;return Un("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?M("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?M("select",{name:s.name,required:s.required,style:r,children:((y=s.options)!=null?y:[]).map(w=>M("option",{value:w,children:w},w))}):M("input",{name:s.name,type:(l=s.inputType)!=null?l:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),M("button",{type:"submit",style:Wn(n,t.palette),children:e.submitLabel})]})}function Qr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Kn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function ke(e,t){var i;let n=ei(e,t),r=Kn(e.like,t);return n&&r?Xr(n,{style:L(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ei(e,t){var n,r,i,o,u,a,c,s,y,l,w,x,m,v,h,S,f,b,k,E,G,O,R;try{let A=Qr(e,t);switch(e.type){case"stack":{let d=(r=de[(n=e.gap)!=null?n:"md"])!=null?r:de.md,g=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:g?"md":void 0;return M("div",L(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:kt[e.align]}:{}),e.justify?{justifyContent:kt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(o=de[I])!=null?o:de.md}:{}),g?L(p(p({},(u=t.palette)!=null&&u.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(y=(s=t.palette)==null?void 0:s.border)!=null?y:"currentColor"}`,borderRadius:(w=(l=t.palette)==null?void 0:l.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((T,C)=>{let P=ke(T,t);return P===null?null:M(Vn,{children:P},C)})}))}case"grid":{let d=(v=de[(m=e.gap)!=null?m:"md"])!=null?v:de.md;return M("div",L(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:kt[e.align]}:{}),e.pad?{padding:(h=de[e.pad])!=null?h:de.md}:{}),children:((S=e.children)!=null?S:[]).map((g,I)=>{let T=ke(g,t);return T===null?null:M(Vn,{children:T},I)})}))}case"text":return A?M("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:jn[e.size]}:{}),e.weight?{fontWeight:Yr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?M(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M(d,{style:p(p({margin:0,fontSize:zr[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return M("a",L(p(p({href:xt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Wn(d,t.palette,e.size)}),{children:e.label}))}case"link":return M("a",L(p(p({href:xt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return M("img",L(p({src:xt(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:qr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?M("span",{className:A,children:e.value}):M("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(E=(k=t.palette)==null?void 0:k.border)!=null?E:"currentColor"}`},Bn(e.tone,t.palette)),children:e.value});case"spacer":return M("div",{style:{height:(G=$n[e.size])!=null?G:$n.md}});case"divider":return M("hr",{style:{border:"none",borderTop:`1px solid ${(R=(O=t.palette)==null?void 0:O.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return M(Zr,{node:e,opts:t});default:return null}}catch(A){return null}}function Rt(e,t){var o,u,a,c;let n=ke(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(u=t.vocabulary)==null?void 0:u.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Kn((c=e.surface)==null?void 0:c.like,t);return r?M("div",L(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ke,isValidElement as Je}from"react";import{normalizeLeafText as ti,skeletonFingerprint as ni}from"@sentientui/core/region";function He(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Xe(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ye(e){return He(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ye(n),0):Je(e)?ye(Xe(e)):0}function ri(e,t){return Array.isArray(t)?Ke(e,void 0,...t):Ke(e,void 0,t)}function At(e,t){if(He(e))return t;if(Array.isArray(e))return e.map(n=>At(n,t));if(Je(e)){let n=Xe(e);return ye(n)===0?e:ri(e,At(n,t))}return e}function Jn(e,t){return ye(e)===1?At(e,t):null}var Z=e=>e.join("/");function Ct(e,t,n){if(He(e)){n.leafPaths.push(t),n.texts.push(ti(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Ct(r,[...t,i],n));return}Je(e)&&(n.elements.set(Z(t),e),Ct(Xe(e),[...t,"c"],n))}function Ot(e){let t={leafPaths:[],texts:[],elements:new Map};return Ct(e,[],t),t}function ii(e){return Ot(e).texts}function Hn(e){let t=ii(e);return t.length===0?null:ni(t)}function oi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Xn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,c)=>a===i?[oi(e.leafPaths[c])]:[]);if(o.length===0){r.push(null);continue}let u=o[0];for(let a of o.slice(1)){let c=new Set(a.map(Z));u=u.filter(s=>c.has(Z(s)))}r.push(u.length>0?u[u.length-1]:null)}return r}function _t(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 Et(e,t){let n=Ot(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,u)=>o!==e.leaves[u]))return null;let r=Xn(n,e.leafToNode),i=e.nodes.map((o,u)=>{let a=r[u],c=a?n.elements.get(Z(a)):void 0,s=!!c&&(typeof c.type=="string"||_t(c)!==void 0);return L(p({},o),{restylable:s})});return L(p({},e),{nodes:i})}function zn(e,t,n){var m;let r=Ot(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((v,h)=>Math.max(v,h+1),0);for(let v of Object.keys(t.nodes))if(!/^\d+$/.test(v)||Number(v)>=i)return null;let o=Xn(r,n),u=new Map;n.forEach((v,h)=>{u.has(v)||u.set(v,h)});let a=new Map(r.leafPaths.map((v,h)=>[Z(v),h])),c=new Set,s=new Map,y=!1;for(let[v,h]of Object.entries(t.nodes)){let S=Number(v),f=o[S];if(h.hidden&&(f?c.add(Z(f)):y=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(Z(f)):void 0,E=b?_t(r.elements.get(Z(b))):void 0;!f||E===void 0||_t(k)===void 0?y=!0:s.set(Z(f),E)}}let l=new Map(Object.entries((m=t.order)!=null?m:{})),w=(v,h)=>{var S;if(He(v)){let f=a.get(Z(h));if(f===void 0)return v;let b=n[f],k=(S=t.nodes[String(b)])==null?void 0:S.text;return k===void 0?v:u.get(b)===f?k:""}if(Array.isArray(v)){let f=v.map((b,k)=>w(b,[...h,k]));for(let[b,k]of l){let E=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||Z(A.slice(0,-1))!==Z(h)?-1:A[A.length-1]});if(E.some(R=>R<0))continue;let G=[...E].sort((R,A)=>R-A),O=[...f];G.forEach((R,A)=>{f[R]=O[E[A]]}),l.delete(b)}return f}if(Je(v)){let f=Z(h);if(c.has(f))return null;let b=Xe(v);if(ye(b)===0)return v;let k=w(b,[...h,"c"]),E=s.get(f),G=E!==void 0?{className:E}:void 0;return Array.isArray(k)?Ke(v,G,...k):Ke(v,G,k)}return v},x=w(e,[]);return y||l.size>0?null:x}import{jsx as ci}from"react/jsx-runtime";var Zn=new Set,Qn=new Set,er=new Set,qe="authored.";function Ge({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:u="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:s,clientOnly:y,agentDataByVariant:l,agentData:w,variantsOnly:x=!1}){var Ut,jt;let m=F(),v=oe(),h=ve(null),[S,f]=si(!1);z(()=>{f(!0)},[]);let b=y===!0&&(!S||!m),k=ze(()=>Hn(t),[t]),E=n?Object.keys(n).join("|"):"",G=ze(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ye(t)===1,ops:!1},E!==""?{authored:E.split("|"),children:!x}:{}),[k,t,r,E,x]),O=()=>{var J;let _=h.current;if(!_||!a)return null;let N=Yn(_);return N.skeleton?(J=Et(N.skeleton,t))!=null?J:L(p({},N.skeleton),{editable:!1,nodes:N.skeleton.nodes.map(W=>L(p({},W),{restylable:!1}))}):{status:N.reason}},R=ai(q,()=>n?ce(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${qe}${R}`:x?`${qe}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:I,vocabulary:T,source:C}=Fn(e,{forcedArm:A,baselineText:a?()=>{var _,N;return(N=(_=h.current)==null?void 0:_.textContent)!=null?N:null}:void 0,render:()=>G,skeleton:O,defer:b}),P=g!==""?(Ut=d==null?void 0:d.blocks)==null?void 0:Ut[g]:void 0,$=g!==""?(jt=d==null?void 0:d.compose)==null?void 0:jt[g]:void 0,B=(P!==void 0&&qn(P)||$!==void 0&&qn($.tree))&&!r;z(()=>{!B||!D()||Zn.has(e)||(Zn.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[B,e]);let K=_=>{!m||C==="override"||(C!=="seeded"&&m.componentGoal(e,_),m.goal(_,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},U=t,j=!1,V=g.startsWith(qe)?g.slice(qe.length):null;if((d==null?void 0:d.blocked)==="variant_history")j=!0;else if(V!==null)n&&Object.prototype.hasOwnProperty.call(n,V)?U=n[V]:j=!0;else if($!==void 0){let _=B?null:Rt($,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:K});_===null?j=!0:U=_}else if(P!==void 0){let _=B?null:ke(P,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:K});_===null?j=!0:U=_}else if((d==null?void 0:d.edits)!==void 0&&C!=="none"){let _=d.edits,N=_.fp===k?zn(t,_.edits,_.leafToNode):null;N===null?j=!0:U=N}else if((d==null?void 0:d.content)!==void 0&&C!=="none"){let _=Jn(t,d.content);_===null?j=!0:U=_}let ee=j&&P===void 0&&$===void 0&&(d==null?void 0:d.edits)===void 0&&V===null&&(d==null?void 0:d.blocked)===void 0;z(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!D()||er.has(e)||(er.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Ae=V!==null&&!j?V:null;z(()=>{var te;if(!Ae||!a||!m)return;let _=h.current;if(!_)return;let N=Yn(_),J=N.skeleton?Et(N.skeleton,n==null?void 0:n[Ae]):null,W=(te=_.textContent)==null?void 0:te.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Ae},W?{text:W}:{}),J?{skeleton:J}:{})]})},[Ae,m,e,b]);let Dt=j&&(d==null?void 0:d.edits)!==void 0&&(C==="preloaded"||C==="client");z(()=>{var _;!Dt||!(d!=null&&d.edits)||(_=m==null?void 0:m.reportDrift)==null||_.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Dt,e,k,m]);let Ie=U===t;z(()=>{var N;if(!(d!=null&&d.needsSkeleton)||!Ie)return;let _=O();_&&((N=m==null?void 0:m.reportSkeleton)==null||N.call(m,e,_))},[d==null?void 0:d.needsSkeleton,Ie,e,m,b]),z(()=>{if(!Ie)return;let _=hn(e);if(!_)return;let N=O();bn(_,N&&"status"in N?{status:N.status}:{skeleton:N})},[e,Ie,b]),z(()=>{!ee||!D()||Qn.has(e)||(Qn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[ee,e]);let nt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";z(()=>Se({id:e,arms:nt===""?void 0:nt.split("|")}),[e,nt]);let Lt=ve(null);z(()=>{!m||C==="none"||C==="seeded"||C==="override"||g===""||j||Lt.current!==g&&(Lt.current=g,ue(m,v,e,g))},[m,v,e,g,C,j]);let ae=C!=="none"&&C!=="seeded"&&!j,rt=ae?g:"",Ft=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);z(()=>{if(!m||!i||C==="override")return;let _=h.current;if(!_)return;let N=le(i),J=ne(i),W=!1;return re(_,Y(i),{fireGoal:()=>{W||(W=!0,ae&&(J!==void 0?m.componentGoal(e,N,{value:J}):m.componentGoal(e,N)),m.goal(N,p({metadata:{componentId:e,arm:rt},weight:1,stepIndex:0},J!==void 0?{value:J}:{})))},fireStep:(te,De,ot)=>{ae&&m.componentGoal(e,te,{reward:De}),m.goal(te,{metadata:{componentId:e,arm:rt},weight:De,stepIndex:ot})}},N)},[m,e,Ft,g,C,j,ae,rt,b]);let it=ze(()=>i?Y(i):null,[Ft]);z(()=>{C==="override"||!m||!it||ie(m,v,e,c,it)},[m,v,e,c,it,C]);let Vt=ve(s);Vt.current=s;let Mt=ve(new Set),mr=s?JSON.stringify(s):"";z(()=>{if(!m||C==="override"||!ae||g==="")return;let _=h.current;if(_)return li((N,J={})=>{var Wt,Kt,Jt;m.track({projectId:v,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:N},J)});let W=(Wt=Vt.current)==null?void 0:Wt[N];if(!W||Mt.current.has(N))return;Mt.current.add(N);let te=typeof W=="string"?W:W.name,De=typeof W=="string"?1:(Kt=W.weight)!=null?Kt:1,ot=typeof W=="string"?0:(Jt=W.stepIndex)!=null?Jt:0;m.goal(te,{metadata:p({componentId:e,arm:g,signalType:N},J),weight:De,stepIndex:ot})},_,Date.now())},[m,v,e,g,C,ae,mr,b]);let $t=ve({agentData:w,agentDataByVariant:l});$t.current={agentData:w,agentDataByVariant:l};let Bt=ve(null);z(()=>{var te;if(!m||C==="override"||!ae||g===""||Bt.current===g)return;let{agentData:_,agentDataByVariant:N}=$t.current,J=V!=null?V:g,W=N!==void 0?Object.prototype.hasOwnProperty.call(N,J)?N[J]:void 0:_;W!==void 0&&(Bt.current=g,(te=m.reportAgentData)==null||te.call(m,e,g,W))},[m,e,g,ae,V,C]);let Ne=ve(null);z(()=>{let _=h.current;if(_){if(Ne.current===null){Ne.current=g;return}Ne.current!==g&&(Ne.current=g,ui(_))}},[g,b]);let pr=ze(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:ci(u,L(p({ref:h,className:o},pr),{children:U}))}import{jsx as Re}from"react/jsx-runtime";function mi(e){var y,l;let{client:t,variantId:n,content:r,ref:i}=je(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,u]=tr(!1);gi(()=>{u(!0)},[]);let a=(y=e.as)!=null?y:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,s=c===null?r:null;return D()&&c===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Re(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:s})}var pi=di(mi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function yi(e){if(e.variants===void 0)return Re(Ge,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Ce(n,["variants"]);return Re(Ge,L(p({},i),{children:t.children,variants:r}))}return Re(vi,p({},t))}function vi(e){var l;let[t,n]=tr(null),{id:r}=e,i=fi(()=>n(r),[r]),o=F(),u=Me().includes(r)||((l=o==null?void 0:o.isUnified)==null?void 0:l.call(o,r))===!0;if(t!==r&&!u)return Re(pi,L(p({},e),{onUnified:i}));let w=e,{variants:a,children:c}=w,s=Ce(w,["variants","children"]),y=Object.keys(a)[0];return Re(Ge,L(p({},s),{variants:a,variantsOnly:!0,children:y!==void 0?a[y]:null}))}import{useEffect as Te,useMemo as Si,useRef as Pt,useState as nr,useSyncExternalStore as hi}from"react";import{jsx as wi}from"react/jsx-runtime";function bi({id:e,default:t,component:n="span",className:r,goal:i}){var G;let o=F(),u=oe(),a=$e(),c=Ee(),s=Pt(null),y=Pt(null),l=hi(q,()=>ce(e),()=>null),[w,x]=nr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,c))==null?void 0:O.content)!=null?R:null}),[m,v]=nr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,c))==null?void 0:O.variantId)!=null?R:null});Te(()=>{if(l||!o)return;let O=o.getAssignment(e,c);if((O==null?void 0:O.content)!==void 0){v(O.variantId),x(O.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,c,l]),Te(()=>{l||!o||!m||!u||s.current!==m&&(s.current=m,o.track({projectId:u,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,u,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),S=Si(()=>i===void 0?null:Y(i),[h]),f=i===void 0?null:typeof i=="string"?i:S.type,b=Pt(!1);Te(()=>{b.current=!1},[m,h]),Te(()=>{l||!o||!u||ie(o,u,e,void 0,S)},[o,u,e,S,l]),Te(()=>{if(l||!o||!m||!u||!S||!f)return;let O=y.current;if(!O)return;let R=ne(S);return re(O,S,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,u,e,S,f,l]);let k=w!=null?w:t;if(l){let O=o==null?void 0:o.getAssignment(e,c);k=O&&O.variantId===l&&(G=O.content)!=null?G:t}return wi(n,{ref:O=>{y.current=O},className:r,children:k})}import{useCallback as xi,useRef as ki}from"react";function Gt(e){let t=F(),n=ki(new Set);return xi((r,i)=>{var o,u;if(!ce(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,p(p(p({metadata:(o=i==null?void 0:i.metadata)!=null?o:{},weight:(u=i==null?void 0:i.reward)!=null?u:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as Ri,useRef as rr}from"react";function Ai(e,t={}){let c=t,{componentId:n}=c,r=Ce(c,["componentId"]),i=F(),o=Gt(n!=null?n:""),u=rr(!1),a=rr(r);a.current=r,Ri(()=>{if(!i||u.current||i.gated)return;u.current=!0;let{metadata:s,reward:y,value:l,currency:w,externalId:x}=a.current;if(n){o(e,a.current);return}i.goal(e,p(p(p({metadata:s!=null?s:{},weight:y!=null?y:1,stepIndex:0},l!==void 0?{value:l}:{}),w!==void 0?{currency:w}:{}),x!==void 0?{externalId:x}:{}))},[i,n,e,o])}import{renderPrePaintScript as Ci}from"@sentientui/core";import{confidenceBand as _i}from"@sentientui/policy";import{jsx as Pi}from"react/jsx-runtime";function Tt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Oi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Tt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Tt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Tt(_i(e.persona.confidence))+");}catch(e){}})();":Ci(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Ei(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:Pi("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Oi(e)}})}import{useEffect as Qe,useMemo as Nt,useRef as Fi}from"react";import{validateSlotDecl as Vi}from"@sentientui/policy";import{useEffect as It,useReducer as Gi,useState as Ti,useSyncExternalStore as ir}from"react";import{armOfResult as Ye,baselineResultFor as Ii}from"@sentientui/core";import{confidenceBand as Ni}from"@sentientui/policy";function Ze(e,t){let n=F(),r=Be(),[,i]=Gi(l=>l+1,0),o=ir(q,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),u=o===void 0?r[e]:void 0,a=o===void 0&&u===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&o===void 0&&u===void 0&&a===null;It(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(w=>{!l&&w&&i()}),()=>{l=!0}},[n,e,c]);let s=(()=>{if(o!==void 0)return{result:o,arm:Ye(o),source:"override"};if(u!==void 0)return{result:u,arm:Ye(u),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:Ye(a),source:w?"client":"seeded"}}let l=Ii(t);return{result:l,arm:Ye(l),source:"baseline"}})(),y=s.source==="preloaded"||s.source==="override";return It(()=>{var w;if(!n||n.isLocal===!0||y||!n.decideSlots)return;let l=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),l==null||l()}},[n,e,y]),s}function Di(){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 Li(){let e=F(),t=En();ir(q,nn,()=>0);let[n,r]=Ti(!1);It(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Ni(a.confidence)});if(!n)return t?i(t):null;let o=Di();if(o)return i(o);if(t)return i(t);let u=e?e.getPersona():null;return u?i(u):null}var or=new Set;function Mi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function $i(e,t,n){let r=F(),i=oe(),o=JSON.stringify(t),u=Nt(()=>({id:e,dims:t}),[e,o]),{result:a,arm:c,source:s}=Ze(e,u),y=Nt(()=>typeof a=="string"?{}:a,[c]);if(D()&&!or.has(e)){or.add(e);let v=Vi({id:e,dims:Object.fromEntries(Object.entries(t).map(([S,f])=>[S,[...f]]))}),h=Object.values(t).reduce((S,f)=>S*f.length,1);v.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);Qe(()=>Se({id:e,dims:t}),[e]);let w=Fi(null);Qe(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,ue(r,i,e,c))},[r,i,e,c,s]);let x=n==null?void 0:n.funnel;Qe(()=>{var v;!r||s==="override"||ie(r,i,e,x,Y((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,x,l,s]),Qe(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Mi(e)}"]`);if(!v){D()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=le(n.goal),S=ne(n.goal),f=!1;return re(v,Y(n.goal),{fireGoal:()=>{f||(f=!0,S!==void 0?r.componentGoal(e,h,{value:S}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},S!==void 0?{value:S}:{})))},fireStep:(b,k,E)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:c},weight:k,stepIndex:E})}},h)},[r,e,l,c,s]);let m=Nt(()=>{let v={"data-sentient-slot":e};for(let[h,S]of Object.entries(y))v[`data-${h}`]=S;return v},[e,y]);return{tokens:y,props:m}}import{useCallback as Bi,useEffect as sr,useMemo as Ui}from"react";var ar=new Set,lr=new Set;function ji(e,t){var m,v;if(D()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:u,ref:a,nodeRef:c}=je(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",y=t.variants[s],l=Me().includes(e)||((v=n==null?void 0:n.isUnified)==null?void 0:v.call(n,e))===!0;sr(()=>{!l||!D()||lr.has(e)||(lr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),sr(()=>{if(!D()||!n)return;let h=setTimeout(()=>{!c.current&&!ar.has(e)&&(ar.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=Bi((h,S)=>{var b,k;if(o)return;let f=h!=null?h:u;f&&(n==null||n.componentGoal(e,f,S),n==null||n.goal(f,p(p(p({metadata:(b=S==null?void 0:S.metadata)!=null?b:{},weight:(k=S==null?void 0:S.reward)!=null?k:1,stepIndex:0},(S==null?void 0:S.value)!==void 0?{value:S.value}:{}),(S==null?void 0:S.currency)!==void 0?{currency:S.currency}:{}),(S==null?void 0:S.externalId)!==void 0?{externalId:S.externalId}:{})))},[n,e,u,o]),x=Ui(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:y,bind:x,fireGoal:w}}import{Children as Wi,isValidElement as Ki,useEffect as et,useMemo as ur,useRef as cr}from"react";import{jsx as Hi}from"react/jsx-runtime";var tt=new Set;function Ji(e){var f;let t=F(),n=oe(),r=cr(null),i=Object.keys(e.arrangements).join(" "),o=ur(()=>Object.keys(e.arrangements),[i]),u=ur(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:c}=Ze(e.id,u);D()&&e.baseline!==void 0&&e.baseline!==o[0]&&!tt.has(e.id+":baseline")&&(tt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Wi.toArray(e.children).filter(Ki),y=new Map;for(let b of s)y.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let l=e.arrangements[a],w=l!==void 0&&l.length===s.length&&l.every(b=>y.has(b));D()&&l!==void 0&&!w&&!tt.has(e.id+":keys")&&(tt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?l.map(b=>y.get(b)):s;et(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=cr(null);et(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||m.current===a||(m.current=a,ue(t,n,e.id,a))},[t,n,e.id,a,c]);let v=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);et(()=>{var b;!t||c==="override"||ie(t,n,e.id,v,Y((b=e.goal)!=null?b:"click"))},[t,n,e.id,v,h,c]);let S=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return et(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let b=r.current;if(!b)return;let k=le(e.goal),E=ne(e.goal),G=!1;return re(b,Y(e.goal),{fireGoal:()=>{G||(G=!0,E!==void 0?t.componentGoal(e.id,k,{value:E}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},E!==void 0?{value:E}:{})))},fireStep:(O,R,A)=>{t.componentGoal(e.id,O,{reward:R}),t.goal(O,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,S,a,c]),Hi("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}import{deriveSessionSegment as Xi}from"@sentientui/core";var zi=["page","blocks","layoutOrder"],dr=new Map;function qi(e,t){dr.set(e,t)}function fr(e){return dr.get(e)}function Yi(e){var i,o;let t=(o=(i=e.content)!=null?i:fr(e.page))!=null?o:{},n={};for(let[u,a]of Object.entries(t))zi.includes(u)||(n[u]=a);let r=L(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Zi(e){return`<script type="application/ld+json">${gr(e)}</script>`}function gr(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Qi(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
2
|
+
var yr=Object.defineProperty,vr=Object.defineProperties;var Sr=Object.getOwnPropertyDescriptors;var Le=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Ht=(e,t,n)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))Xt.call(t,n)&&Ht(e,n,t[n]);if(Le)for(var n of Le(t))zt.call(t,n)&&Ht(e,n,t[n]);return e},L=(e,t)=>vr(e,Sr(t));var Ce=(e,t)=>{var n={};for(var r in e)Xt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Le)for(var r of Le(e))t.indexOf(r)<0&&zt.call(e,r)&&(n[r]=e[r]);return n};import{createContext as Er,useContext as X,useEffect as Q,useMemo as Rn,useRef as se,useState as Oe,useSyncExternalStore as Pr}from"react";import{deriveSessionSegment as Gr,init as Tr}from"@sentientui/core";var qt=new Map,Fe=new Map;function Yt(e,t){let n=Fe.get(e);return n||(n=new Set,Fe.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Fe.delete(e)}}function Zt(e,t){qt.set(e,t);let n=Fe.get(e);if(n)for(let r of n)try{r(t)}catch(i){}}function st(e){var t;return(t=qt.get(e))!=null?t:null}var hr={on:!1,listeners:new Set};function Qt(){if(typeof window=="undefined")return hr;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function at(){return Qt().on}function en(e){let t=Qt().listeners;return t.add(e),()=>{t.delete(e)}}function tn(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,r;return(r=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?r:!1},assign:(t,n,r,i,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 lt="sentient:overrides-changed";function nn(){var e;return typeof window=="undefined"?0:(e=window.__sentient_overrides_version)!=null?e:0}function ut(){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(lt))}function q(e){return typeof window=="undefined"?()=>{}:(window.addEventListener(lt,e),()=>window.removeEventListener(lt,e))}function rn(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function D(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}function Y(e){return typeof e=="string"?{type:"click"}:e}function le(e){return typeof e=="string"?e:e.type}function ne(e){if(typeof e!="string"&&(e.type==="click"||e.type==="form_submit"||e.type==="scroll_depth"))return e.value}var ct=new Set,dt=!1;function on(e){if(ct.has(e))return!0;if(ct.add(e),!dt){dt=!0;let t=()=>{dt=!1,ct.clear()};if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),n.port2.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)}return!1}function br(e){if(!(e instanceof Element))return!1;let t=e.tagName.toLowerCase();return t==="a"||t==="button"?!0:e.getAttribute("role")==="button"}function sn(e,t,n){if(n){try{let i=e;for(;i&&i!==t;){if(i.matches(n))return!0;i=i.parentElement}}catch(i){}return!1}let r=e;for(;r&&r!==t;){if(br(r))return!0;r=r.parentElement}return!1}function re(e,t,n,r){if(t.type==="weighted_composite"){let s=new Set,y=[];return t.steps.forEach(({goal:l,name:w,weight:x},m)=>{let v=(h=!1)=>{s.has(m)||h&&r!==void 0&&on(`step\0${w}\0${x}\0${m}`)||(s.add(m),n.fireStep(w,x,m))};if(l.type==="click"){let h=S=>{let f=S.target;f instanceof Element&&sn(f,e,l.selector)&&v()};e.addEventListener("click",h),y.push(()=>e.removeEventListener("click",h));return}if(l.type==="form_submit"){let h=S=>{S.target instanceof HTMLFormElement&&e.contains(S.target)&&v()};e.addEventListener("submit",h),y.push(()=>e.removeEventListener("submit",h));return}if(l.type==="scroll_depth"){let h=Math.max(0,Math.min(1,l.threshold)),S=new IntersectionObserver(f=>{for(let b of f)if(b.intersectionRatio>=h){v(!0),S.disconnect();break}},{threshold:[h]});S.observe(e),y.push(()=>S.disconnect())}}),()=>{for(let l of y)l()}}let i=t.type==="composite"?t.all:[t],o=new Set(i.map((s,y)=>y)),u=()=>{r!==void 0&&on(r)||n.fireGoal()},a=(s,y=!1)=>{o.delete(s),o.size===0&&(y?u():n.fireGoal())},c=[];return i.forEach((s,y)=>{if(s.type==="click"){let l=w=>{let x=w.target;x instanceof Element&&sn(x,e,s.selector)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("click",l),c.push(()=>e.removeEventListener("click",l));return}if(s.type==="form_submit"){let l=w=>{w.target instanceof HTMLFormElement&&e.contains(w.target)&&(t.type==="composite"?a(y):n.fireGoal())};e.addEventListener("submit",l),c.push(()=>e.removeEventListener("submit",l));return}if(s.type==="scroll_depth"){let l=Math.max(0,Math.min(1,s.threshold)),w=new IntersectionObserver(x=>{for(let m of x)if(m.intersectionRatio>=l){t.type==="composite"?a(y,!0):u(),w.disconnect();break}},{threshold:[l]});w.observe(e),c.push(()=>w.disconnect());return}}),()=>{for(let s of c)s()}}var an=new Set,ln=new Set;function wr(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100);if(t&&t===e)return`${t}-steps`;let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n+e.charCodeAt(r)>>>0;return`${t||"component"}-${n.toString(36)}-steps`}var xr=12;function kr(e,t){let n=new Set,r=[];for(let o of t.steps){let u=o.name;!u||u.length>128||u.startsWith("funnel:")||n.has(u)||r.length===xr||(n.add(u),r.push({goalId:u,weight:Math.min(1,Math.max(0,o.weight||0))}))}let i=[...r].sort((o,u)=>o.weight-u.weight);return(r.length<t.steps.length||i.some((o,u)=>o!==r[u]))&&D()&&console.warn(`[SentientUI] "${e}": weighted_composite steps adjusted for its funnel (skipped invalid/repeated/over-12 steps, or ordered by weight)`),i}function ie(e,t,n,r,i){let o=(i==null?void 0:i.type)==="weighted_composite"?i:null,u=r!=null?r:o?wr(n):void 0;if(!u)return;let a=`${u}|${n}`;if(ln.has(a))return;ln.add(a);let c=o&&!an.has(u)?kr(n,o):null,s=c!==null&&c.length>=2;s&&an.add(u),!(!s&&r===void 0)&&e.track({projectId:t,componentId:n,eventType:"funnel_declared",payload:s?{funnelId:u,steps:c}:{funnelId:u}})}function ue(e,t,n,r){e.track({projectId:t,componentId:n,variantId:r,eventType:"variant_assigned",payload:{}})}var Rr={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function fe(){if(typeof window=="undefined")return Rr;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function _e(){fe().version+=1;for(let e of fe().listeners)e()}var un=()=>{};function cn(e){return D()?(fe().components.set(e.id,e),_e(),()=>{fe().components.delete(e.id),_e()}):un}function Se(e){return D()?(fe().slots.set(e.id,e),_e(),()=>{fe().slots.delete(e.id),_e()}):un}function ft(e){D()&&(fe().sections=[...e],_e())}var dn="0.41.1",gt=dn!=="0.0.0-dev"?{name:"react",version:dn}:void 0;function Ar(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function he(e,t){Ar()[e]=t}function fn(e){window.__sentient_vocabulary_override=e}function gn(){var e;return typeof window=="undefined"?null:(e=window.__sentient_vocabulary_override)!=null?e:null}function Cr(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function be(e,t){Cr()[e]=t}function mn(e){let t=null;try{let n=location.hash.slice(1),r=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(r){t=r[2];let i=n.slice(r.index+r[0].length);r[1]!="&"&&i[0]=="&"&&(i=r[1]+i.slice(1));let o=n.slice(0,r.index)+i;history.replaceState(history.state,"",o?"#"+o:location.pathname+location.search)}}catch(n){}return t}var pt="__snt_editor_token",we=null,mt=!1;function pn(){return mt}function _r(){try{return sessionStorage.getItem(pt)}catch(e){return null}}function Ve(e){if(we)return we;let t=typeof window=="undefined"?null:mn("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:_r();return mt=!!n,we=Promise.resolve(n?{token:n,fresh:!1}:null),we}return mt=!0,we=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(pt,r)}catch(i){}return{token:r,fresh:!0}}).catch(()=>({error:0})),we}function yn(){try{sessionStorage.removeItem(pt)}catch(e){}}var vn="sentient_preview_cell",Sn="sentient_refresh_region",yt="sentient-cell-preview-bar",ge="__preview__",xe=null;function hn(e){if((xe==null?void 0:xe.slotId)!==e)return null;let t=xe;return xe=null,t}function bn(e,t){e.session.then(n=>{if(!n||!("token"in n))throw new Error("no editor session");return fetch(`${e.base}/editor/region-skeleton`,{method:"POST",headers:{authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(p({slotId:e.slotId},t))})}).then(n=>me(n.ok?"Region refreshed \u2014 you can regenerate its versions now.":"Couldn\u2019t refresh this region \u2014 reopen the link from your dashboard.")).catch(()=>me("Couldn\u2019t refresh this region \u2014 check your connection and reopen the link from your dashboard."))}function wn(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(yt))return;let t,n;try{let c=new URLSearchParams(window.location.search);t=c.get(vn),n=c.get(Sn)}catch(c){return}if(!t&&!n)return;let r=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=Ve(r);if(!pn())return;if(n){xe={slotId:n,session:i,base:r},he(n,{kind:"arms"}),be(n,ge),ut();return}if(!t)return;let o=t.lastIndexOf("~");if(o<=0)return;let u=t.slice(0,o),a=t.slice(o+1);i.then(c=>c?"token"in c?fetch(`${r}/editor/cell-preview?slotId=${encodeURIComponent(u)}&persona=${encodeURIComponent(a)}`,{headers:{authorization:`Bearer ${c.token}`}}):(me(c.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async c=>{if(!c)return;if(!c.ok){me(c.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let s=await c.json();if(s.vocabulary&&Array.isArray(s.vocabulary.entries)&&fn(s.vocabulary),s.compose!=null)he(u,{kind:"arms",compose:{[ge]:s.compose}}),be(u,ge);else if(s.edits!=null&&typeof s.skeletonFp=="string"&&Array.isArray(s.leafToNode))he(u,{kind:"arms",edits:{edits:s.edits,fp:s.skeletonFp,leafToNode:s.leafToNode}}),be(u,ge);else if(s.blocks!=null)he(u,{kind:"arms",blocks:{[ge]:s.blocks}}),be(u,ge);else if(s.content!=null)he(u,{kind:"arms",content:s.content}),be(u,ge);else{me("Nothing to preview in that square yet.");return}ut(),me(`Previewing \u201C${s.slotName}\u201D for ${s.personaDisplay}${s.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${u}"]`))==null||y.scrollIntoView({block:"center"})}catch(l){}},300)}).catch(()=>me("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function me(e){var i;if(document.getElementById(yt))return;let t=document.createElement("div");t.id=yt,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{yn();let o=new URL(window.location.href);o.searchParams.delete(vn),o.searchParams.delete(Sn),window.location.assign(o.toString())},t.append(n,r),((i=document.body)!=null?i:document.documentElement).append(t)}var xn=!1;function kn(e){if(xn||typeof window=="undefined")return;xn=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");Ve(t).then(n=>{!n||!("token"in n)||!n.fresh||Or(t,n.token)})}function Or(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 Mr}from"react/jsx-runtime";function Ir(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return Gr({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Cn="https://api.sentient-ui.com/v1",H=Er({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Cn,debug:!1}),An=!1,vt=new Set;function Nr(e,t,n){let r=se(n);r.current=n;let[i,o]=Oe(null),[u,a]=Oe(!1),c=se(e);c.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 Q(()=>{let y=c.current;if(y===void 0||typeof window=="undefined")return;let l,w=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:m})=>{if(w)return;let v=x(typeof y=="object"&&y.cmp===void 0&&y.check?p(L(p({},y),{check:()=>c.current.check()}),y.refused?{refused:()=>{var f,b;return((b=(f=c.current).refused)==null?void 0:b.call(f))===!0}}:{}):y),h=!1,S=()=>{let f=v.refused()&&v.read()!==!0;f&&!h&&(m(t),r.current()),h=f,a(f);let b=v.read();b!==null&&vt.add(t),o(b!=null?b:vt.has(t)?!1:null)};S(),l=v.subscribe(S)}),()=>{w=!0,l==null||l()}},[s,t]),{granted:i,refused:u}}function Dr(e){var G,O,R,A,d;let[t,n]=Oe(null),[r]=Oe(()=>{var g;return(g=e.sessionSegment)!=null?g:Ir()}),[i,o]=Oe(at());Q(()=>en(()=>o(at())),[]),Q(()=>{wn(e.apiBaseUrl),kn(e.apiBaseUrl)},[]);let u=se(()=>{}),a=Nr(e.consentFrom,e.apiKey,()=>u.current()),c=e.consentFrom?(G=a.granted)!=null?G:vt.has(e.apiKey)?!1:e.consent===!0:e.consent,s=e.consentFrom?a.refused:!0,y=se(s);y.current=s;let l=se(null),w=se(!1),x=se([]),m=se(!1);u.current=()=>{var I;x.current=[],m.current=!0;let g=l.current;g!=null&&g.gated?g.dispose():(I=g==null?void 0:g.takeHeld)==null||I.call(g)},Q(()=>{var U,j;if(y.current&&c===!1&&(x.current=[]),c===!1&&w.current&&(y.current&&((U=l.current)==null||U.destroy()),l.current=null,w.current=!1),c===!1&&!e.preConsentBehavior){y.current&&((j=l.current)==null||j.destroy()),l.current=null,n(null);return}let g=c!==!1;g&&(m.current=!1);let I=V=>{!g&&m.current&&V.gated&&V.dispose()},T=p({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:r,consent:c,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},gt?{sdk:gt}:{}),C=!1,P=null,$=null,B=V=>{for(let ee of x.current.splice(0))setTimeout(()=>{if(l.current!==V){m.current||x.current.push(ee);return}try{ee(V)}catch(Ae){}},0)},K=V=>{e.engagement===!1||!g||import("@sentientui/core/engagement").then(({startEngagementCapture:ee})=>{C||($=ee(V,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:V})=>{C||(P=V(L(p({},T),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),I(P),l.current=P,w.current=g,B(P),n(P),K(P))}):(P=Tr(T),I(P),l.current=P,w.current=g,B(P),n(P),K(P)),()=>{var V,ee;C=!0,$==null||$(),x.current=x.current.concat((ee=(V=P==null?void 0:P.takeHeld)==null?void 0:V.call(P))!=null?ee:[]),P==null||P.dispose()}},[c]),Q(()=>{if(!t)return;let g=!1,I=async()=>{if(g)return;let C;try{C=await t.fetchWeights()}catch(P){return}if(!g)for(let P of C){let $={componentId:P.componentId,updatedAt:P.updatedAt,variants:P.variants.map(B=>{var K;return{variantId:B.variantId,pulls:B.pulls,avgReward:(K=B.avgReward)!=null?K:0}})};Zt(P.componentId,$)}};I();let T=setInterval(()=>{I()},6e4);return()=>{g=!0,clearInterval(T)}},[t]);let v=(O=e.ssrFallback)!=null?O:"first",h=((R=e.apiBaseUrl)!=null?R:Cn).replace(/\/$/,""),S=se(null);Q(()=>{var T;if(typeof process!="undefined"&&((T=process.env)==null?void 0:T.NODE_ENV)==="production")return;let g={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:h},I=S.current;if(S.current=g,I!==null)for(let C of["apiKey","context","country","persona","apiBaseUrl"])Object.is(I[C],g[C])||console.warn(`[sentient] AdaptiveProvider: \`${C}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,h]),Q(()=>{var g;typeof process!="undefined"&&((g=process.env)==null?void 0:g.NODE_ENV)==="production"||rn({apiKey:e.apiKey,apiBaseUrl:h,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,h]);let f=(A=e.identity)==null?void 0:A.userId,b=(d=e.identity)==null?void 0:d.userHash;Q(()=>{t&&f&&t.identify(f,{userHash:b})},[t,f,b]),Q(()=>{let g=e.initialLayoutOrder;if(g&&g.length>0){ft(g);return}e.declaredSections&&e.declaredSections.length>0&&ft(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),Q(()=>{!D()||e.consent!==void 0||e.consentFrom!==void 0||An||(An=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),Q(()=>{if(!D())return;let g=e.declaredSections;if(!g||g.length===0||typeof document=="undefined")return;let I=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),C=>C.getAttribute("data-sentient-id"))),T=g.filter(C=>!I.has(C));T.length>0&&console.warn(`[SentientUI] Declared section${T.length>1?"s":""} ${T.map(C=>`"${C}"`).join(", ")} ${T.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let k=Rn(()=>t&&i?tn(t):t,[t,i]),E=Rn(()=>{var g,I,T,C,P,$,B,K,U;return{client:k,apiKey:e.apiKey,initialAssignments:(g=e.initialAssignments)!=null?g:{},initialUnified:(I=e.initialUnified)!=null?I:Lr,sessionSegment:r,ssrFallback:v,onAssignment:e.onAssignment,initialLayoutOrder:(T=e.initialLayoutOrder)!=null?T:null,initialSlots:(C=e.initialSlots)!=null?C:{},initialSlotConfig:(P=e.initialSlotConfig)!=null?P:{},initialPalette:($=e.initialPalette)!=null?$:null,initialVocabulary:(B=e.initialVocabulary)!=null?B:null,initialPersona:(K=e.initialPersona)!=null?K:null,apiBaseUrl:h,debug:(U=e.debug)!=null?U:!1}},[k,e.apiKey,e.initialAssignments,e.initialUnified,r,v,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,h,e.debug]);return Mr(H.Provider,{value:E,children:e.children})}function F(){return X(H).client}function oe(){return X(H).apiKey}function St(){return X(H).initialAssignments}var Lr=[];function Me(){return X(H).initialUnified}function Ee(){return X(H).sessionSegment}function _n(){return X(H).ssrFallback}function $e(){return X(H).onAssignment}function On(){return X(H).debug}function Fr(){let e=X(H).initialLayoutOrder,t=Pr(q,()=>{var n;return typeof window=="undefined"?null:(n=window.__sentient_layout_override)!=null?n:null},()=>null);return t!=null?t:e}function Be(){return X(H).initialSlots}function En(){return X(H).initialPersona}function Pn(){return X(H).initialSlotConfig}function Gn(){return X(H).initialPalette}function Tn(){return X(H).initialVocabulary}function Vr(){return X(H).apiBaseUrl}import{memo as di,useCallback as fi,useEffect as gi,useState as tr}from"react";import{useCallback as Ur,useEffect as pe,useMemo as Nn,useRef as Pe,useState as jr}from"react";import{attachMicroSignalDetectors as Wr}from"@sentientui/core";import{useEffect as Ue,useRef as In,useState as $r,useSyncExternalStore as Br}from"react";import{pickFromWeights as ht}from"@sentientui/policy";function ce(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 bt(e,t,n,r,i){let o=St(),u=_n(),a=F(),c=Ee(),s=$e(),y=On(),l=In(null),w=Br(q,()=>ce(e),()=>null),x=w&&t.includes(w)?w:null,m=In(null);Ue(()=>{y&&x&&m.current!==x&&(m.current=x,console.info(`[sentient] override active: ${e} -> ${x}`))},[y,x,e]);let[v,h]=$r(()=>{var k,E;if(x)return{variantId:x,content:null,isLoading:!1,settled:!0};if(!a){let G=o[e];return G&&t.includes(G)?{variantId:G,content:null,isLoading:!1,settled:!0}:u==="first"&&t.length>0?{variantId:t[0],content:null,isLoading:!1,settled:!1}:{variantId:null,content:null,isLoading:!0,settled:!1}}let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content))return{variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0};let b=st(e);if(b){let G=ht(b.variants,t);if(G)return{variantId:G,content:null,isLoading:!1,settled:!0}}return{variantId:(E=t[0])!=null?E:null,content:null,isLoading:!1,settled:!1}}),S=f=>{s&&l.current!==f&&(l.current=f,s(e,f))};return Ue(()=>{var k;if(x||!a)return;let f=a.getAssignment(e,c);if(f&&(t.includes(f.variantId)||f.content)){h({variantId:f.variantId,content:(k=f.content)!=null?k:null,isLoading:!1,settled:!0}),S(f.variantId);return}let b=st(e);if(b&&v.settled&&v.variantId&&v.variantId===ht(b.variants,t)){S(v.variantId);return}h(E=>{var G;return E.variantId?E:{variantId:(G=t[0])!=null?G:null,content:null,isLoading:!1,settled:!1}})},[x,a,e,c]),Ue(()=>{if(x||!a)return;let f=a.getAssignment(e,c);if(f&&t.includes(f.variantId))return;let b=!1,k=i==null?void 0:i.onUnified;return(k?a.assign(e,t,n,r,{unified:!0}):a.assign(e,t,n,r)).then(G=>{var O;if(!b&&G){if(G.unified===!0){k==null||k();return}!t.includes(G.variantId)&&!G.content||(h({variantId:G.variantId,content:(O=G.content)!=null?O:null,isLoading:!1,settled:!0}),S(G.variantId))}}),()=>{b=!0}},[x,a,e,c]),Ue(()=>{if(!x&&a)return Yt(e,f=>{var E;let b=a.getAssignment(e,c);if(b&&(t.includes(b.variantId)||b.content)){h({variantId:b.variantId,content:(E=b.content)!=null?E:null,isLoading:!1,settled:!0}),S(b.variantId);return}let k=ht(f.variants,t);k&&(h({variantId:k,content:null,isLoading:!1,settled:!0}),S(k))})},[x,a,e,c]),x?{variantId:x,content:null,isLoading:!1,settled:!0,isOverride:!0}:v}function je(e,t,n){let r=F(),i=oe(),o=Object.keys(t).join("\0"),u=Nn(()=>Object.keys(t),[o]),{variantId:a,content:c,isOverride:s=!1,settled:y}=bt(e,u,n.agentData,n.agentDataByVariant,n.onUnified?{onUnified:n.onUnified}:void 0),[l,w]=jr(null),x=Pe(null),m=Ur(d=>{x.current=d,w(d)},[]),v=n.goal,h=typeof v=="string"?v:JSON.stringify(v),S=Nn(()=>v?Y(v):null,[h]),f=v?le(v):"";pe(()=>cn({id:e,variantIds:u,goal:f}),[e,u,f]);let b=Pe(null);pe(()=>{s||y&&(!r||!a||!i||!l||b.current!==a&&(b.current=a,ue(r,i,e,a)))},[r,a,i,e,l,s,y]);let k=Pe(!1),E=Pe(new Set);pe(()=>{k.current=!1,E.current=new Set},[a,S]);let G=n.funnel;pe(()=>{s||!y||!r||!S||ie(r,i,e,G,S)},[r,i,e,G,S,s,y]);let O=n.cursorSignal===!0;pe(()=>{if(!O||s||!y||!r||!a||!l)return;let d=null,g=0,I=()=>{g=Date.now(),d=setTimeout(()=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"cursor_signal",payload:{hoverDuration:Date.now()-g}}),d=null},800)},T=()=>{d!==null&&(clearTimeout(d),d=null)};return l.addEventListener("mouseenter",I),l.addEventListener("mouseleave",T),()=>{l.removeEventListener("mouseenter",I),l.removeEventListener("mouseleave",T),d!==null&&clearTimeout(d)}},[O,r,a,i,e,l,s,y]);let R=Pe(n.microSignalGoals);R.current=n.microSignalGoals;let A=n.microSignalGoals?JSON.stringify(n.microSignalGoals):"";return pe(()=>{if(s||!y||!r||!a||!l)return;let d=Date.now();return Wr((g,I={})=>{var B,K,U;r.track({projectId:i,componentId:e,variantId:a,eventType:"micro_signal",payload:p({signalType:g},I)});let T=(B=R.current)==null?void 0:B[g];if(!T||E.current.has(g))return;E.current.add(g);let C=typeof T=="string"?T:T.name,P=typeof T=="string"?1:(K=T.weight)!=null?K:1,$=typeof T=="string"?0:(U=T.stepIndex)!=null?U:0;r.goal(C,{metadata:p({signalType:g},I),weight:P,stepIndex:$})},l,d)},[r,a,i,e,l,A,s,y]),pe(()=>{if(s||!y||!r||!a||!l||!S)return;let d=ne(S);return re(l,S,{fireGoal:()=>{k.current||(k.current=!0,r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:f,payload:p({reward:1},d!==void 0?{goalValue:d}:{})}),r.goal(f,p({metadata:{componentId:e,variantId:a},weight:1,stepIndex:0},d!==void 0?{value:d}:{})))},fireStep:(g,I,T)=>{r.track({projectId:i,componentId:e,variantId:a,eventType:"goal_achieved",goalType:g,payload:{reward:I}}),r.goal(g,{metadata:{},weight:I,stepIndex:T})}},f)},[r,a,i,e,l,S,f,s,y]),{client:r,variantIds:u,variantId:a,content:c,settled:y,isOverride:s,goalLabel:f,ref:m,nodeRef:x}}import{useEffect as z,useMemo as ze,useRef as ve,useState as si,useSyncExternalStore as ai}from"react";import{attachMicroSignalDetectors as li,containsFormBlock as qn,reveal as ui}from"@sentientui/core";import{captureRegionSkeleton as Yn}from"@sentientui/core/region";import{useCallback as Kr,useEffect as Dn,useRef as wt,useSyncExternalStore as We}from"react";import{armOfResult as Jr}from"@sentientui/core";var Ln=new Set,Hr={kind:"arms"};function Fn(e,t){var E,G,O;let n=F(),r=wt(t==null?void 0:t.baselineText);r.current=t==null?void 0:t.baselineText;let i=wt(t==null?void 0:t.render);i.current=t==null?void 0:t.render;let o=wt(t==null?void 0:t.skeleton);o.current=t==null?void 0:t.skeleton;let u=Be(),a=Pn(),c=Gn(),s=Tn(),y=We(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_config_overrides)==null?void 0:R[e]:void 0},()=>{}),l=We(q,()=>{var R;return typeof window!="undefined"?(R=window.__sentient_slot_overrides)==null?void 0:R[e]:void 0},()=>{}),w=R=>R==null?"":Jr(R),x=Kr(R=>{var A,d;return(d=(A=n==null?void 0:n.onSlotsChanged)==null?void 0:A.call(n,R))!=null?d:(()=>{})},[n]);We(x,()=>{var R;return(R=n==null?void 0:n.getSlotConfig(e))!=null?R:null},()=>null),We(x,()=>w(n==null?void 0:n.getSlotResult(e)),()=>"");let m=y===void 0?a[e]:void 0,v=y===void 0&&m===void 0&&n?n.getSlotConfig(e):null,h=(E=c!=null?c:n==null?void 0:n.getSitePalette())!=null?E:null,S=(O=s!=null?s:(G=n==null?void 0:n.getStyleVocabulary)==null?void 0:G.call(n))!=null?O:null,f=(()=>{var R,A,d;if(y!==void 0)return{config:y,arm:w(l),palette:h,vocabulary:(R=gn())!=null?R:S,source:"override"};if(t!=null&&t.forcedArm)return{config:Hr,arm:t.forcedArm,palette:h,vocabulary:S,source:"override"};if(m!==void 0)return{config:m,arm:w((A=u[e])!=null?A:n==null?void 0:n.getSlotResult(e)),palette:h,vocabulary:S,source:"preloaded"};if(v!==null){let g=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{config:v,arm:w((d=n==null?void 0:n.getSlotResult(e))!=null?d:u[e]),palette:h,vocabulary:S,source:g?"client":"seeded"}}return{config:null,arm:"",palette:h,vocabulary:S,source:"none"}})(),b=(t==null?void 0:t.defer)===!0,k=f.source==="preloaded"||f.source==="override";return Dn(()=>{var P,$,B,K,U;if(!n||n.isLocal===!0||k||b)return;let R=f.source==="none",A=R&&($=(P=r.current)==null?void 0:P.call(r))!=null?$:null,d=A!=null&&A!==""?{[e]:A}:void 0,g=(B=i.current)==null?void 0:B.call(i),I=R&&(U=(K=o.current)==null?void 0:K.call(o))!=null?U:null,T=p(p({},g?{render:{[e]:g}}:{}),I?{skeletons:{[e]:I}}:{}),C=Object.keys(T).length>0;return n.requestSlots?C?n.requestSlots([e],d,T):d?n.requestSlots([e],d):n.requestSlots([e]):R&&(I?n.reportSlots([e],d!=null?d:{},{[e]:I}):d?n.reportSlots([e],d):n.reportSlots([e])),()=>{var j;return(j=n.cancelSlots)==null?void 0:j.call(n,[e])}},[n,k,f.source,e,b]),Dn(()=>{!D()||(n==null?void 0:n.isLocal)!==!0||f.source!=="none"||Ln.has(e)||(Ln.add(e),console.warn(`[sentient] <Adaptive id="${e}"> is rendering its baseline children: in local/keyless mode <Adaptive> serves ONLY what you pass as \`initialSlotConfig\` (there is no registry to decide from). Pass initialSlotConfig/initialSlots to <AdaptiveProvider> to preview arms locally.`))},[n,f.source,e]),f}import{cloneElement as Xr,Fragment as Vn}from"react";import{jsx as M,jsxs as Un}from"react/jsx-runtime";function xt(e){return typeof e=="string"&&!/[\s\x00-\x1f\\]/.test(e)&&(/^https:\/\//i.test(e)||e[0]==="/"&&e[1]!=="/")?e:void 0}var de={none:"0",sm:"8px",md:"16px",lg:"24px"},kt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",between:"space-between"},jn={sm:"0.875em",md:"1em",lg:"1.25em"},zr={sm:"1.25em",md:"1.5em",lg:"2em"},Mn={sm:"6px 14px",md:"10px 20px",lg:"14px 28px"},$n={sm:"8px",md:"16px",lg:"32px"},qr={square:"1 / 1",landscape:"4 / 3",wide:"16 / 9"},Yr={normal:"400",medium:"500",bold:"700"};function Bn(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 Wn(e,t,n){var i,o,u,a;let r=t==null?void 0:t.accent;return L(p({display:"inline-block",padding:(i=Mn[n!=null?n:"md"])!=null?i:Mn.md,borderRadius:(o=t==null?void 0:t.radius)!=null?o:"8px",font:"inherit"},n?{fontSize:jn[n]}:{}),{textDecoration:e==="ghost"?"underline":"none",cursor:"pointer",background:e==="primary"?(u=t==null?void 0:t.primaryBg)!=null?u:"#111827":"transparent",color:e==="primary"?(a=t==null?void 0:t.primaryText)!=null?a:"#ffffff":r!=null?r:"inherit",border:e==="secondary"?`1px solid ${r!=null?r:"currentColor"}`:"none"})}function Zr({node:e,opts:t}){var i,o,u,a,c;let n=(i=e.emphasis)!=null?i:"primary",r={padding:"8px 10px",font:"inherit",border:`1px solid ${(u=(o=t.palette)==null?void 0:o.border)!=null?u:"currentColor"}`,borderRadius:(c=(a=t.palette)==null?void 0:a.radius)!=null?c:"8px"};return Un("form",{onSubmit:s=>{var w,x,m;s.preventDefault();let y=new FormData(s.currentTarget),l={};for(let v of e.fields)l[v.name]=String((w=y.get(v.name))!=null?w:"");(x=t.onFormGoal)==null||x.call(t,e.submitGoal);try{(m=t.onFormSubmit)==null||m.call(t,l)}catch(v){}},style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.fields.map(s=>{var y,l;return Un("label",{style:{display:"flex",flexDirection:"column",gap:"4px",font:"inherit"},children:[s.label,s.kind==="textarea"?M("textarea",{name:s.name,required:s.required,placeholder:s.placeholder,rows:3,style:r}):s.kind==="select"?M("select",{name:s.name,required:s.required,style:r,children:((y=s.options)!=null?y:[]).map(w=>M("option",{value:w,children:w},w))}):M("input",{name:s.name,type:(l=s.inputType)!=null?l:"text",required:s.required,placeholder:s.placeholder,style:r})]},s.name)}),M("button",{type:"submit",style:Wn(n,t.palette),children:e.submitLabel})]})}function Qr(e,t){var r,i;let n=e.like;return n?(i=(r=t.vocabulary)==null?void 0:r.entries.find(o=>o.id===n))==null?void 0:i.classes:void 0}function Kn(e,t){var r;let n=e?(r=t.vocabulary)==null?void 0:r.entries.find(i=>i.id===e):void 0;return n!=null&&n.computed.inheritsColor?n.computed.color:void 0}function ke(e,t){var i;let n=ei(e,t),r=Kn(e.like,t);return n&&r?Xr(n,{style:L(p({},(i=n.props.style)!=null?i:{}),{color:r})}):n}function ei(e,t){var n,r,i,o,u,a,c,s,y,l,w,x,m,v,h,S,f,b,k,E,G,O,R;try{let A=Qr(e,t);switch(e.type){case"stack":{let d=(r=de[(n=e.gap)!=null?n:"md"])!=null?r:de.md,g=e.surface==="raised"&&!A,I=(i=e.pad)!=null?i:g?"md":void 0;return M("div",L(p({},A?{className:A}:{}),{style:p(p(p(p(p({display:"flex",flexDirection:e.direction,gap:d},e.align?{alignItems:kt[e.align]}:{}),e.justify?{justifyContent:kt[e.justify]}:{}),e.wrap?{flexWrap:"wrap"}:{}),I?{padding:(o=de[I])!=null?o:de.md}:{}),g?L(p(p({},(u=t.palette)!=null&&u.surface?{background:t.palette.surface}:{}),(a=t.palette)!=null&&a.surface&&((c=t.palette)!=null&&c.surfaceText)?{color:t.palette.surfaceText}:{}),{border:`1px solid ${(y=(s=t.palette)==null?void 0:s.border)!=null?y:"currentColor"}`,borderRadius:(w=(l=t.palette)==null?void 0:l.radius)!=null?w:"8px"}):{}),children:((x=e.children)!=null?x:[]).map((T,C)=>{let P=ke(T,t);return P===null?null:M(Vn,{children:P},C)})}))}case"grid":{let d=(v=de[(m=e.gap)!=null?m:"md"])!=null?v:de.md;return M("div",L(p({},A?{className:A}:{}),{style:p(p({display:"grid",gridTemplateColumns:`repeat(auto-fit, minmax(max(200px, calc((100% - ${e.columns-1} * ${d}) / ${e.columns})), 1fr))`,gap:d},e.align?{alignItems:kt[e.align]}:{}),e.pad?{padding:(h=de[e.pad])!=null?h:de.md}:{}),children:((S=e.children)!=null?S:[]).map((g,I)=>{let T=ke(g,t);return T===null?null:M(Vn,{children:T},I)})}))}case"text":return A?M("p",{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M("p",{style:p(p(p(p(p({margin:0},e.size?{fontSize:jn[e.size]}:{}),e.weight?{fontWeight:Yr[e.weight]}:{}),e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),Bn(e.tone,t.palette)),children:e.value});case"heading":{let d=`h${e.level}`;return A?M(d,{className:A,style:e.maxWidth==="measure"?{maxWidth:"65ch"}:void 0,children:e.value}):M(d,{style:p(p({margin:0,fontSize:zr[(f=e.size)!=null?f:"md"]},e.align?{textAlign:e.align}:{}),e.maxWidth==="measure"?{maxWidth:"65ch"}:{}),children:e.value})}case"button":{let d=(b=e.emphasis)!=null?b:"primary";return M("a",L(p(p({href:xt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:Wn(d,t.palette,e.size)}),{children:e.label}))}case"link":return M("a",L(p(p({href:xt(e.href)},e.tag?{"data-sentient-tag":e.tag}:{}),A?{className:A}:{style:{color:"inherit",textDecoration:"underline"}}),{children:e.label}));case"image":return M("img",L(p({src:xt(e.src),alt:e.alt},A?{className:A}:{}),{style:p(p({display:"block",maxWidth:"100%"},e.ratio&&e.ratio!=="auto"?{aspectRatio:qr[e.ratio],width:"100%"}:{}),e.fit?{objectFit:e.fit}:{})}));case"badge":return A?M("span",{className:A,children:e.value}):M("span",{style:p({display:"inline-block",padding:"2px 10px",borderRadius:"999px",fontSize:"0.75em",border:`1px solid ${(E=(k=t.palette)==null?void 0:k.border)!=null?E:"currentColor"}`},Bn(e.tone,t.palette)),children:e.value});case"spacer":return M("div",{style:{height:(G=$n[e.size])!=null?G:$n.md}});case"divider":return M("hr",{style:{border:"none",borderTop:`1px solid ${(R=(O=t.palette)==null?void 0:O.border)!=null?R:"currentColor"}`,margin:0,width:"100%"}});case"form":return M(Zr,{node:e,opts:t});default:return null}}catch(A){return null}}function Rt(e,t){var o,u,a,c;let n=ke(e.tree,t);if(n===null)return null;let r=(o=e.surface)!=null&&o.like?(a=(u=t.vocabulary)==null?void 0:u.entries.find(s=>s.id===e.surface.like))==null?void 0:a.classes:void 0,i=Kn((c=e.surface)==null?void 0:c.like,t);return r?M("div",L(p({className:r},i?{style:{color:i}}:{}),{children:n})):n}import{cloneElement as Ke,isValidElement as Je}from"react";import{normalizeLeafText as ti,skeletonFingerprint as ni}from"@sentientui/core/region";function He(e){return typeof e=="string"&&e.trim()!==""||typeof e=="number"}function Xe(e){let t=e.props;if(t.dangerouslySetInnerHTML==null)return t.children}function ye(e){return He(e)?1:Array.isArray(e)?e.reduce((t,n)=>t+ye(n),0):Je(e)?ye(Xe(e)):0}function ri(e,t){return Array.isArray(t)?Ke(e,void 0,...t):Ke(e,void 0,t)}function At(e,t){if(He(e))return t;if(Array.isArray(e))return e.map(n=>At(n,t));if(Je(e)){let n=Xe(e);return ye(n)===0?e:ri(e,At(n,t))}return e}function Jn(e,t){return ye(e)===1?At(e,t):null}var Z=e=>e.join("/");function Ct(e,t,n){if(He(e)){n.leafPaths.push(t),n.texts.push(ti(String(e)));return}if(Array.isArray(e)){e.forEach((r,i)=>Ct(r,[...t,i],n));return}Je(e)&&(n.elements.set(Z(t),e),Ct(Xe(e),[...t,"c"],n))}function Ot(e){let t={leafPaths:[],texts:[],elements:new Map};return Ct(e,[],t),t}function ii(e){return Ot(e).texts}function Hn(e){let t=ii(e);return t.length===0?null:ni(t)}function oi(e){let t=[];return e.forEach((n,r)=>{n==="c"&&t.push(e.slice(0,r))}),t}function Xn(e,t){let n=t.reduce((i,o)=>Math.max(i,o+1),0),r=[];for(let i=0;i<n;i++){let o=t.flatMap((a,c)=>a===i?[oi(e.leafPaths[c])]:[]);if(o.length===0){r.push(null);continue}let u=o[0];for(let a of o.slice(1)){let c=new Set(a.map(Z));u=u.filter(s=>c.has(Z(s)))}r.push(u.length>0?u[u.length-1]:null)}return r}function _t(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 Et(e,t){let n=Ot(t);if(n.texts.length!==e.leaves.length||n.texts.some((o,u)=>o!==e.leaves[u]))return null;let r=Xn(n,e.leafToNode),i=e.nodes.map((o,u)=>{let a=r[u],c=a?n.elements.get(Z(a)):void 0,s=!!c&&(typeof c.type=="string"||_t(c)!==void 0);return L(p({},o),{restylable:s})});return L(p({},e),{nodes:i})}function zn(e,t,n){var m;let r=Ot(e);if(r.leafPaths.length!==n.length)return null;let i=n.reduce((v,h)=>Math.max(v,h+1),0);for(let v of Object.keys(t.nodes))if(!/^\d+$/.test(v)||Number(v)>=i)return null;let o=Xn(r,n),u=new Map;n.forEach((v,h)=>{u.has(v)||u.set(v,h)});let a=new Map(r.leafPaths.map((v,h)=>[Z(v),h])),c=new Set,s=new Map,y=!1;for(let[v,h]of Object.entries(t.nodes)){let S=Number(v),f=o[S];if(h.hidden&&(f?c.add(Z(f)):y=!0),h.like!==void 0){let b=o[h.like],k=f?r.elements.get(Z(f)):void 0,E=b?_t(r.elements.get(Z(b))):void 0;!f||E===void 0||_t(k)===void 0?y=!0:s.set(Z(f),E)}}let l=new Map(Object.entries((m=t.order)!=null?m:{})),w=(v,h)=>{var S;if(He(v)){let f=a.get(Z(h));if(f===void 0)return v;let b=n[f],k=(S=t.nodes[String(b)])==null?void 0:S.text;return k===void 0?v:u.get(b)===f?k:""}if(Array.isArray(v)){let f=v.map((b,k)=>w(b,[...h,k]));for(let[b,k]of l){let E=k.map(R=>{let A=o[R];return!A||A.length!==h.length+1||Z(A.slice(0,-1))!==Z(h)?-1:A[A.length-1]});if(E.some(R=>R<0))continue;let G=[...E].sort((R,A)=>R-A),O=[...f];G.forEach((R,A)=>{f[R]=O[E[A]]}),l.delete(b)}return f}if(Je(v)){let f=Z(h);if(c.has(f))return null;let b=Xe(v);if(ye(b)===0)return v;let k=w(b,[...h,"c"]),E=s.get(f),G=E!==void 0?{className:E}:void 0;return Array.isArray(k)?Ke(v,G,...k):Ke(v,G,k)}return v},x=w(e,[]);return y||l.size>0?null:x}import{jsx as ci}from"react/jsx-runtime";var Zn=new Set,Qn=new Set,er=new Set,qe="authored.";function Ge({id:e,children:t,variants:n,onFormSubmit:r,goal:i,className:o,as:u="div",reportBaselineText:a=!0,funnel:c,microSignalGoals:s,clientOnly:y,agentDataByVariant:l,agentData:w,variantsOnly:x=!1}){var Ut,jt;let m=F(),v=oe(),h=ve(null),[S,f]=si(!1);z(()=>{f(!0)},[]);let b=y===!0&&(!S||!m),k=ze(()=>Hn(t),[t]),E=n?Object.keys(n).join("|"):"",G=ze(()=>p({fp:k!=null?k:"0000000000000000",forms:!!r,compose:!0,content:ye(t)===1,ops:!1},E!==""?{authored:E.split("|"),children:!x}:{}),[k,t,r,E,x]),O=()=>{var J;let _=h.current;if(!_||!a)return null;let N=Yn(_);return N.skeleton?(J=Et(N.skeleton,t))!=null?J:L(p({},N.skeleton),{editable:!1,nodes:N.skeleton.nodes.map(W=>L(p({},W),{restylable:!1}))}):{status:N.reason}},R=ai(q,()=>n?ce(e):null,()=>null),A=R===null||!n?null:Object.prototype.hasOwnProperty.call(n,R)?`${qe}${R}`:x?`${qe}${Object.keys(n)[0]}`:"baseline",{config:d,arm:g,palette:I,vocabulary:T,source:C}=Fn(e,{forcedArm:A,baselineText:a?()=>{var _,N;return(N=(_=h.current)==null?void 0:_.textContent)!=null?N:null}:void 0,render:()=>G,skeleton:O,defer:b}),P=g!==""?(Ut=d==null?void 0:d.blocks)==null?void 0:Ut[g]:void 0,$=g!==""?(jt=d==null?void 0:d.compose)==null?void 0:jt[g]:void 0,B=(P!==void 0&&qn(P)||$!==void 0&&qn($.tree))&&!r;z(()=>{!B||!D()||Zn.has(e)||(Zn.add(e),console.warn(`[sentient] AdaptiveSlot "${e}" was served a form arm but has no onFormSubmit handler \u2014 rendering its baseline children instead. Pass onFormSubmit to render generated forms.`))},[B,e]);let K=_=>{!m||C==="override"||(C!=="seeded"&&m.componentGoal(e,_),m.goal(_,{metadata:{componentId:e,arm:g},weight:1,stepIndex:0}))},U=t,j=!1,V=g.startsWith(qe)?g.slice(qe.length):null;if((d==null?void 0:d.blocked)==="variant_history")j=!0;else if(V!==null)n&&Object.prototype.hasOwnProperty.call(n,V)?U=n[V]:j=!0;else if($!==void 0){let _=B?null:Rt($,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:K});_===null?j=!0:U=_}else if(P!==void 0){let _=B?null:ke(P,{palette:I,vocabulary:T,onFormSubmit:r,onFormGoal:K});_===null?j=!0:U=_}else if((d==null?void 0:d.edits)!==void 0&&C!=="none"){let _=d.edits,N=_.fp===k?zn(t,_.edits,_.leafToNode):null;N===null?j=!0:U=N}else if((d==null?void 0:d.content)!==void 0&&C!=="none"){let _=Jn(t,d.content);_===null?j=!0:U=_}let ee=j&&P===void 0&&$===void 0&&(d==null?void 0:d.edits)===void 0&&V===null&&(d==null?void 0:d.blocked)===void 0;z(()=>{(d==null?void 0:d.blocked)!=="variant_history"||!D()||er.has(e)||(er.add(e),console.warn(`[sentient] <Adaptive id="${e}"> has results from its earlier variants experiment, so it is showing your original until you migrate it: Matrix \u2192 Components \u2192 "${e}" \u2192 Migrate. Deploying code never switches an experiment.`))},[d==null?void 0:d.blocked,e]);let Ae=V!==null&&!j?V:null;z(()=>{var te;if(!Ae||!a||!m)return;let _=h.current;if(!_)return;let N=Yn(_),J=N.skeleton?Et(N.skeleton,n==null?void 0:n[Ae]):null,W=(te=_.textContent)==null?void 0:te.trim();m.reportSlots([],void 0,void 0,{[e]:[p(p({key:Ae},W?{text:W}:{}),J?{skeleton:J}:{})]})},[Ae,m,e,b]);let Dt=j&&(d==null?void 0:d.edits)!==void 0&&(C==="preloaded"||C==="client");z(()=>{var _;!Dt||!(d!=null&&d.edits)||(_=m==null?void 0:m.reportDrift)==null||_.call(m,e,d.edits.fp,k,d.edits.fp===k?"unaddressable":"fp_mismatch")},[Dt,e,k,m]);let Ie=U===t;z(()=>{var N;if(!(d!=null&&d.needsSkeleton)||!Ie)return;let _=O();_&&((N=m==null?void 0:m.reportSkeleton)==null||N.call(m,e,_))},[d==null?void 0:d.needsSkeleton,Ie,e,m,b]),z(()=>{if(!Ie)return;let _=hn(e);if(!_)return;let N=O();bn(_,N&&"status"in N?{status:N.status}:{skeleton:N})},[e,Ie,b]),z(()=>{!ee||!D()||Qn.has(e)||(Qn.add(e),console.warn(`[sentient] <Adaptive id="${e}"> was served a text version, but its children have several separate texts or none Sentient can reach \u2014 rendering the original instead. Regenerate the version (new versions edit each text in place), or put a single text inline.`))},[ee,e]);let nt=d!=null&&d.blocks?Object.keys(d.blocks).sort().join("|"):"";z(()=>Se({id:e,arms:nt===""?void 0:nt.split("|")}),[e,nt]);let Lt=ve(null);z(()=>{!m||C==="none"||C==="seeded"||C==="override"||g===""||j||Lt.current!==g&&(Lt.current=g,ue(m,v,e,g))},[m,v,e,g,C,j]);let ae=C!=="none"&&C!=="seeded"&&!j,rt=ae?g:"",Ft=i===void 0?null:typeof i=="string"?i:JSON.stringify(i);z(()=>{if(!m||!i||C==="override")return;let _=h.current;if(!_)return;let N=le(i),J=ne(i),W=!1;return re(_,Y(i),{fireGoal:()=>{W||(W=!0,ae&&(J!==void 0?m.componentGoal(e,N,{value:J}):m.componentGoal(e,N)),m.goal(N,p({metadata:{componentId:e,arm:rt},weight:1,stepIndex:0},J!==void 0?{value:J}:{})))},fireStep:(te,De,ot)=>{ae&&m.componentGoal(e,te,{reward:De}),m.goal(te,{metadata:{componentId:e,arm:rt},weight:De,stepIndex:ot})}},N)},[m,e,Ft,g,C,j,ae,rt,b]);let it=ze(()=>i?Y(i):null,[Ft]);z(()=>{C==="override"||!m||!it||ie(m,v,e,c,it)},[m,v,e,c,it,C]);let Vt=ve(s);Vt.current=s;let Mt=ve(new Set),mr=s?JSON.stringify(s):"";z(()=>{if(!m||C==="override"||!ae||g==="")return;let _=h.current;if(_)return li((N,J={})=>{var Wt,Kt,Jt;m.track({projectId:v,componentId:e,variantId:g,eventType:"micro_signal",payload:p({signalType:N},J)});let W=(Wt=Vt.current)==null?void 0:Wt[N];if(!W||Mt.current.has(N))return;Mt.current.add(N);let te=typeof W=="string"?W:W.name,De=typeof W=="string"?1:(Kt=W.weight)!=null?Kt:1,ot=typeof W=="string"?0:(Jt=W.stepIndex)!=null?Jt:0;m.goal(te,{metadata:p({componentId:e,arm:g,signalType:N},J),weight:De,stepIndex:ot})},_,Date.now())},[m,v,e,g,C,ae,mr,b]);let $t=ve({agentData:w,agentDataByVariant:l});$t.current={agentData:w,agentDataByVariant:l};let Bt=ve(null);z(()=>{var te;if(!m||C==="override"||!ae||g===""||Bt.current===g)return;let{agentData:_,agentDataByVariant:N}=$t.current,J=V!=null?V:g,W=N!==void 0?Object.prototype.hasOwnProperty.call(N,J)?N[J]:void 0:_;W!==void 0&&(Bt.current=g,(te=m.reportAgentData)==null||te.call(m,e,g,W))},[m,e,g,ae,V,C]);let Ne=ve(null);z(()=>{let _=h.current;if(_){if(Ne.current===null){Ne.current=g;return}Ne.current!==g&&(Ne.current=g,ui(_))}},[g,b]);let pr=ze(()=>p({"data-sentient-slot":e},g!==""?{"data-sentient-arm":g}:{}),[e,g]);return b?null:ci(u,L(p({ref:h,className:o},pr),{children:U}))}import{jsx as Re}from"react/jsx-runtime";function mi(e){var y,l;let{client:t,variantId:n,content:r,ref:i}=je(e.id,e.variants,{goal:e.goal,funnel:e.funnel,microSignalGoals:e.microSignalGoals,agentData:e.agentData,agentDataByVariant:e.agentDataByVariant,cursorSignal:!0,onUnified:e.onUnified}),[o,u]=tr(!1);gi(()=>{u(!0)},[]);let a=(y=e.as)!=null?y:"div";if(e.clientOnly&&(!o||!t)||!n)return null;let c=(l=e.variants[n])!=null?l:null,s=c===null?r:null;return D()&&c===null&&s===null&&console.warn(`[sentient] <Adaptive id="${e.id}"> was assigned variant "${n}" but no matching key exists in props.variants. If this is a dashboard-managed text variant, use <AdaptiveText id="${e.id}"> instead.`),Re(a,{ref:i,className:e.className,"data-sentient-id":e.id,"data-sentient-variant":n,children:c!=null?c:s})}var pi=di(mi,(e,t)=>{if(e.id!==t.id||e.goal!==t.goal&&JSON.stringify(e.goal)!==JSON.stringify(t.goal)||e.microSignalGoals!==t.microSignalGoals||e.funnel!==t.funnel||e.clientOnly!==t.clientOnly||e.as!==t.as||e.className!==t.className||e.agentData!==t.agentData||e.agentDataByVariant!==t.agentDataByVariant||e.onUnified!==t.onUnified)return!1;if(e.variants===t.variants)return!0;let n=Object.keys(e.variants),r=Object.keys(t.variants);return n.length!==r.length?!1:n.every(i=>i in t.variants&&Object.is(e.variants[i],t.variants[i]))});function yi(e){if(e.variants===void 0)return Re(Ge,p({},e));let t=e;if(t.children!=null){let n=t,{variants:r}=n,i=Ce(n,["variants"]);return Re(Ge,L(p({},i),{children:t.children,variants:r}))}return Re(vi,p({},t))}function vi(e){var l;let[t,n]=tr(null),{id:r}=e,i=fi(()=>n(r),[r]),o=F(),u=Me().includes(r)||((l=o==null?void 0:o.isUnified)==null?void 0:l.call(o,r))===!0;if(t!==r&&!u)return Re(pi,L(p({},e),{onUnified:i}));let w=e,{variants:a,children:c}=w,s=Ce(w,["variants","children"]),y=Object.keys(a)[0];return Re(Ge,L(p({},s),{variants:a,variantsOnly:!0,children:y!==void 0?a[y]:null}))}import{useEffect as Te,useMemo as Si,useRef as Pt,useState as nr,useSyncExternalStore as hi}from"react";import{jsx as wi}from"react/jsx-runtime";function bi({id:e,default:t,component:n="span",className:r,goal:i}){var G;let o=F(),u=oe(),a=$e(),c=Ee(),s=Pt(null),y=Pt(null),l=hi(q,()=>ce(e),()=>null),[w,x]=nr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,c))==null?void 0:O.content)!=null?R:null}),[m,v]=nr(()=>{var O,R;return(R=(O=o==null?void 0:o.getAssignment(e,c))==null?void 0:O.variantId)!=null?R:null});Te(()=>{if(l||!o)return;let O=o.getAssignment(e,c);if((O==null?void 0:O.content)!==void 0){v(O.variantId),x(O.content);return}let R=!1;return o.assign(e).then(A=>{if(!R){if(!A){D()&&console.warn(`[sentient] <AdaptiveText id="${e}"> assignment failed \u2014 showing default text.`);return}v(A.variantId),A.content&&x(A.content)}}),()=>{R=!0}},[o,e,c,l]),Te(()=>{l||!o||!m||!u||s.current!==m&&(s.current=m,o.track({projectId:u,componentId:e,variantId:m,eventType:"variant_assigned",payload:{}}),a==null||a(e,m))},[o,m,u,e,a,l]);let h=i===void 0?"":typeof i=="string"?i:JSON.stringify(i),S=Si(()=>i===void 0?null:Y(i),[h]),f=i===void 0?null:typeof i=="string"?i:S.type,b=Pt(!1);Te(()=>{b.current=!1},[m,h]),Te(()=>{l||!o||!u||ie(o,u,e,void 0,S)},[o,u,e,S,l]),Te(()=>{if(l||!o||!m||!u||!S||!f)return;let O=y.current;if(!O)return;let R=ne(S);return re(O,S,{fireGoal:()=>{b.current||(b.current=!0,o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:f,payload:p({reward:1},R!==void 0?{goalValue:R}:{})}),o.goal(f,p({metadata:{componentId:e,variantId:m},weight:1,stepIndex:0},R!==void 0?{value:R}:{})))},fireStep:(A,d,g)=>{o.track({projectId:u,componentId:e,variantId:m,eventType:"goal_achieved",goalType:A,payload:{reward:d}}),o.goal(A,{metadata:{},weight:d,stepIndex:g})}})},[o,m,u,e,S,f,l]);let k=w!=null?w:t;if(l){let O=o==null?void 0:o.getAssignment(e,c);k=O&&O.variantId===l&&(G=O.content)!=null?G:t}return wi(n,{ref:O=>{y.current=O},className:r,children:k})}import{useCallback as xi,useRef as ki}from"react";function Gt(e){let t=F(),n=ki(new Set);return xi((r,i)=>{var o,u;if(!ce(e)){if(i!=null&&i.once){if(n.current.has(r))return;n.current.add(r)}t==null||t.componentGoal(e,r,i),t==null||t.goal(r,p(p(p({metadata:(o=i==null?void 0:i.metadata)!=null?o:{},weight:(u=i==null?void 0:i.reward)!=null?u:1,stepIndex:0},(i==null?void 0:i.value)!==void 0?{value:i.value}:{}),(i==null?void 0:i.currency)!==void 0?{currency:i.currency}:{}),(i==null?void 0:i.externalId)!==void 0?{externalId:i.externalId}:{}))}},[t,e])}import{useEffect as Ri,useRef as rr}from"react";function Ai(e,t={}){let c=t,{componentId:n}=c,r=Ce(c,["componentId"]),i=F(),o=Gt(n!=null?n:""),u=rr(!1),a=rr(r);a.current=r,Ri(()=>{if(!i||u.current||i.gated)return;u.current=!0;let{metadata:s,reward:y,value:l,currency:w,externalId:x}=a.current;if(n){o(e,a.current);return}i.goal(e,p(p(p({metadata:s!=null?s:{},weight:y!=null?y:1,stepIndex:0},l!==void 0?{value:l}:{}),w!==void 0?{currency:w}:{}),x!==void 0?{externalId:x}:{}))},[i,n,e,o])}import{renderPrePaintScript as Ci}from"@sentientui/core";import{confidenceBand as _i}from"@sentientui/policy";import{jsx as Pi}from"react/jsx-runtime";function Tt(e){return JSON.stringify(e).replace(/</g,"\\u003c")}function Oi(e){return e.persona?"(function(){try{var d=document.documentElement;"+(e.stage?'if(!d.hasAttribute("data-sentient-stage"))d.setAttribute("data-sentient-stage",'+Tt(e.stage)+");":"")+'if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",'+Tt(e.persona.persona)+');d.setAttribute("data-sentient-confidence",'+Tt(_i(e.persona.confidence))+");}catch(e){}})();":Ci(e.apiKey,e.stageAttributes?{stage:!0}:void 0)}function Ei(e){return!e.persona&&(e.consent===!1||e.consentFrom!==void 0&&e.consent!==!0)?null:Pi("script",{"data-sentient-persona-script":"",nonce:e.nonce,dangerouslySetInnerHTML:{__html:Oi(e)}})}import{useEffect as Qe,useMemo as Nt,useRef as Fi}from"react";import{validateSlotDecl as Vi}from"@sentientui/policy";import{useEffect as It,useReducer as Gi,useState as Ti,useSyncExternalStore as ir}from"react";import{armOfResult as Ye,baselineResultFor as Ii}from"@sentientui/core";import{confidenceBand as Ni}from"@sentientui/policy";function Ze(e,t){let n=F(),r=Be(),[,i]=Gi(l=>l+1,0),o=ir(q,()=>{var l;return typeof window!="undefined"?(l=window.__sentient_slot_overrides)==null?void 0:l[e]:void 0},()=>{}),u=o===void 0?r[e]:void 0,a=o===void 0&&u===void 0&&n?n.getSlotResult(e):null,c=(n==null?void 0:n.isLocal)===!0&&o===void 0&&u===void 0&&a===null;It(()=>{if(!c||!n)return;let l=!1;return n.decide({slots:[t]}).then(w=>{!l&&w&&i()}),()=>{l=!0}},[n,e,c]);let s=(()=>{if(o!==void 0)return{result:o,arm:Ye(o),source:"override"};if(u!==void 0)return{result:u,arm:Ye(u),source:"preloaded"};if(a!==null){let w=n!=null&&n.isSlotDecided?n.isSlotDecided(e):!0;return{result:a,arm:Ye(a),source:w?"client":"seeded"}}let l=Ii(t);return{result:l,arm:Ye(l),source:"baseline"}})(),y=s.source==="preloaded"||s.source==="override";return It(()=>{var w;if(!n||n.isLocal===!0||y||!n.decideSlots)return;let l=(w=n.onSlotsChanged)==null?void 0:w.call(n,i);return n.decideSlots([t]),()=>{var x;(x=n.cancelSlots)==null||x.call(n,[e]),l==null||l()}},[n,e,y]),s}function Di(){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 Li(){let e=F(),t=En();ir(q,nn,()=>0);let[n,r]=Ti(!1);It(()=>r(!0),[]);let i=a=>({persona:a.persona,confidence:a.confidence,band:Ni(a.confidence)});if(!n)return t?i(t):null;let o=Di();if(o)return i(o);if(t)return i(t);let u=e?e.getPersona():null;return u?i(u):null}var or=new Set;function Mi(e){return typeof CSS!="undefined"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/[\\"]/g,"\\$&")}function $i(e,t,n){let r=F(),i=oe(),o=JSON.stringify(t),u=Nt(()=>({id:e,dims:t}),[e,o]),{result:a,arm:c,source:s}=Ze(e,u),y=Nt(()=>typeof a=="string"?{}:a,[c]);if(D()&&!or.has(e)){or.add(e);let v=Vi({id:e,dims:Object.fromEntries(Object.entries(t).map(([S,f])=>[S,[...f]]))}),h=Object.values(t).reduce((S,f)=>S*f.length,1);v.ok?h>4&&console.warn(`[sentient] useAdaptiveTokens("${e}") declares ${h} combinations \u2014 more than the recommended 4. Each extra combination needs more traffic to learn; consider fewer dims/values.`):console.warn(`[sentient] useAdaptiveTokens("${e}"): invalid declaration \u2014 ${v.reason}. Serving baseline.`)}let l=(n==null?void 0:n.goal)===void 0?null:typeof n.goal=="string"?n.goal:JSON.stringify(n.goal);Qe(()=>Se({id:e,dims:t}),[e]);let w=Fi(null);Qe(()=>{!r||s==="baseline"||s==="seeded"||s==="override"||w.current===c||(w.current=c,ue(r,i,e,c))},[r,i,e,c,s]);let x=n==null?void 0:n.funnel;Qe(()=>{var v;!r||s==="override"||ie(r,i,e,x,Y((v=n==null?void 0:n.goal)!=null?v:"click"))},[r,i,e,x,l,s]),Qe(()=>{if(!r||!(n!=null&&n.goal)||s==="override"||s==="baseline"||s==="seeded")return;let v=document.querySelector(`[data-sentient-slot="${Mi(e)}"]`);if(!v){D()&&console.warn(`[sentient] useAdaptiveTokens("${e}"): a goal is declared but no element carries the returned props \u2014 spread {...props} on the slot's element.`);return}let h=le(n.goal),S=ne(n.goal),f=!1;return re(v,Y(n.goal),{fireGoal:()=>{f||(f=!0,S!==void 0?r.componentGoal(e,h,{value:S}):r.componentGoal(e,h),r.goal(h,p({metadata:{componentId:e,arm:c},weight:1,stepIndex:0},S!==void 0?{value:S}:{})))},fireStep:(b,k,E)=>{r.componentGoal(e,b,{reward:k}),r.goal(b,{metadata:{componentId:e,arm:c},weight:k,stepIndex:E})}},h)},[r,e,l,c,s]);let m=Nt(()=>{let v={"data-sentient-slot":e};for(let[h,S]of Object.entries(y))v[`data-${h}`]=S;return v},[e,y]);return{tokens:y,props:m}}import{useCallback as Bi,useEffect as sr,useMemo as Ui}from"react";var ar=new Set,lr=new Set;function ji(e,t){var m,v;if(D()&&!t.goal)throw new Error(`[sentient] useAdaptive("${e}"): a goal is required \u2014 without one the optimizer accumulates exposures with no rewards and cannot learn. Pass e.g. goal: 'buy_click'.`);let{client:n,variantIds:r,variantId:i,isOverride:o,goalLabel:u,ref:a,nodeRef:c}=je(e,t.variants,{goal:t.goal,funnel:t.funnel,microSignalGoals:t.microSignalGoals}),s=(m=i!=null?i:r[0])!=null?m:"",y=t.variants[s],l=Me().includes(e)||((v=n==null?void 0:n.isUnified)==null?void 0:v.call(n,e))===!0;sr(()=>{!l||!D()||lr.has(e)||(lr.add(e),console.warn(`[sentient] useAdaptive("${e}"): this component was moved to the shared track, which useAdaptive cannot render yet. It keeps showing the frozen result and learns nothing \u2014 render it with <Adaptive id="${e}" variants={...}> instead.`))},[l,e]),sr(()=>{if(!D()||!n)return;let h=setTimeout(()=>{!c.current&&!ar.has(e)&&(ar.add(e),console.warn(`[sentient] useAdaptive("${e}"): bind was never attached \u2014 spread {...bind} on the rendered element, otherwise exposure and goal tracking cannot work and the optimizer learns nothing.`))},0);return()=>clearTimeout(h)},[n,e]);let w=Bi((h,S)=>{var b,k;if(o)return;let f=h!=null?h:u;f&&(n==null||n.componentGoal(e,f,S),n==null||n.goal(f,p(p(p({metadata:(b=S==null?void 0:S.metadata)!=null?b:{},weight:(k=S==null?void 0:S.reward)!=null?k:1,stepIndex:0},(S==null?void 0:S.value)!==void 0?{value:S.value}:{}),(S==null?void 0:S.currency)!==void 0?{currency:S.currency}:{}),(S==null?void 0:S.externalId)!==void 0?{externalId:S.externalId}:{})))},[n,e,u,o]),x=Ui(()=>({ref:a,"data-sentient-id":e,"data-sentient-variant":s}),[a,e,s]);return{variant:s,value:y,bind:x,fireGoal:w}}import{Children as Wi,isValidElement as Ki,useEffect as et,useMemo as ur,useRef as cr}from"react";import{jsx as Hi}from"react/jsx-runtime";var tt=new Set;function Ji(e){var f;let t=F(),n=oe(),r=cr(null),i=Object.keys(e.arrangements).join(" "),o=ur(()=>Object.keys(e.arrangements),[i]),u=ur(()=>p({id:e.id,arms:o},e.baseline!==void 0?{baseline:e.baseline}:{}),[e.id,o,e.baseline]),{arm:a,source:c}=Ze(e.id,u);D()&&e.baseline!==void 0&&e.baseline!==o[0]&&!tt.has(e.id+":baseline")&&(tt.add(e.id+":baseline"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: baseline "${e.baseline}" is not the first-declared arrangement ("${o[0]}"). The first arrangement should usually be the page's real incumbent (the holdout sees it).`));let s=Wi.toArray(e.children).filter(Ki),y=new Map;for(let b of s)y.set(String((f=b.key)!=null?f:"").replace(/^\.\$/,""),b);let l=e.arrangements[a],w=l!==void 0&&l.length===s.length&&l.every(b=>y.has(b));D()&&l!==void 0&&!w&&!tt.has(e.id+":keys")&&(tt.add(e.id+":keys"),console.warn(`[sentient] <AdaptiveGroup id="${e.id}">: arrangement "${a}" [${l.join(", ")}] does not match the children's keys \u2014 rendering declaration order (fail-safe).`));let x=w?l.map(b=>y.get(b)):s;et(()=>Se({id:e.id,arms:Object.keys(e.arrangements)}),[e.id]);let m=cr(null);et(()=>{!t||c==="baseline"||c==="seeded"||c==="override"||m.current===a||(m.current=a,ue(t,n,e.id,a))},[t,n,e.id,a,c]);let v=e.funnel,h=e.goal===void 0||typeof e.goal=="string"?"":JSON.stringify(e.goal);et(()=>{var b;!t||c==="override"||ie(t,n,e.id,v,Y((b=e.goal)!=null?b:"click"))},[t,n,e.id,v,h,c]);let S=e.goal===void 0?null:typeof e.goal=="string"?e.goal:JSON.stringify(e.goal);return et(()=>{if(!t||e.goal===void 0||c==="override"||c==="baseline"||c==="seeded")return;let b=r.current;if(!b)return;let k=le(e.goal),E=ne(e.goal),G=!1;return re(b,Y(e.goal),{fireGoal:()=>{G||(G=!0,E!==void 0?t.componentGoal(e.id,k,{value:E}):t.componentGoal(e.id,k),t.goal(k,p({metadata:{componentId:e.id,arm:a},weight:1,stepIndex:0},E!==void 0?{value:E}:{})))},fireStep:(O,R,A)=>{t.componentGoal(e.id,O,{reward:R}),t.goal(O,{metadata:{componentId:e.id,arm:a},weight:R,stepIndex:A})}},k)},[t,e.id,S,a,c]),Hi("div",{ref:r,"data-sentient-id":e.id,"data-sentient-variant":a,children:x})}import{deriveSessionSegment as Xi}from"@sentientui/core";var zi=["page","blocks","layoutOrder"],dr=new Map;function qi(e,t){dr.set(e,t)}function fr(e){return dr.get(e)}function Yi(e){var i,o;let t=(o=(i=e.content)!=null?i:fr(e.page))!=null?o:{},n={};for(let[u,a]of Object.entries(t))zi.includes(u)||(n[u]=a);let r=L(p({},n),{page:e.page,blocks:e.blocks});return e.layoutOrder&&(r.layoutOrder=e.layoutOrder),r}function Zi(e){return`<script type="application/ld+json">${gr(e)}</script>`}function gr(e){return JSON.stringify(p({"@context":"https://schema.org","@type":"WebPage"},e)).replace(/</g,"\\u003c")}function Qi(e){let t=[];e.title&&t.push(`# ${e.title}`,""),e.summary&&t.push(String(e.summary),"");for(let[n,r]of Object.entries(e))["page","title","summary","blocks","layoutOrder"].includes(n)||t.push(`## ${n}`,"","```json",JSON.stringify(r,null,2),"```","");if(e.blocks.length>0){t.push("## blocks","");for(let n of e.blocks)t.push(`- **${n.id}** \u2192 variant \`${n.variant}\``),n.content!==void 0&&t.push(""," ```json",JSON.stringify(n.content,null,2)," ```");t.push("")}return t.join(`
|
|
3
3
|
`).trimEnd()+`
|
|
4
4
|
`}import{grantConsent as rl}from"@sentientui/core";import{consentWatcher as sl}from"@sentientui/core/consent";export{yi as Adaptive,Ji as AdaptiveGroup,Dr as AdaptiveProvider,Ge as AdaptiveSlot,bi as AdaptiveText,Ei as SentientPersonaScript,Yi as buildAgentFeed,sl as consentWatcher,qi as defineAgentContent,Xi as detectSegment,fr as getAgentContent,rl as grantConsent,Zi as renderAgentJsonLd,gr as renderAgentJsonLdBody,Qi as renderAgentMarkdown,ke as renderBlocks,Rt as renderCompose,ji as useAdaptive,Vr as useAdaptiveApiBaseUrl,Gt as useAdaptiveGoal,Li as useAdaptivePersona,$i as useAdaptiveTokens,bt as useAssignment,St as useInitialAssignments,Fr as useLayoutOrder,Ai as usePageGoal,F as useSentient,Ee as useSessionSegment};
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
package/dist/testing/react.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var Ve=Object.create;var G=Object.defineProperty,De=Object.defineProperties,Le=Object.getOwnPropertyDescriptor,Ne=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertyNames,se=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var ae=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&ae(e,n,t[n]);if(se)for(var n of se(t))We.call(t,n)&&ae(e,n,t[n]);return e},$=(e,t)=>De(e,Ne(t));var Ue=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},ce=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ge(t))!le.call(e,a)&&a!==n&&G(e,a,{get:()=>t[a],enumerable:!(i=Le(t,a))||i.enumerable});return e};var M=(e,t,n)=>(n=e!=null?Ve(Fe(e)):{},ce(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),$e=e=>ce(G({},"__esModule",{value:!0}),e);var ot={};Ue(ot,{renderWithSentient:()=>rt});module.exports=$e(ot);var Oe=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Me=new Map,Ke=new Map;function de(e,t){Me.set(e,t);let n=Ke.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Be={on:!1,listeners:new Set};function ue(){if(typeof window=="undefined")return Be;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function H(){return ue().on}function fe(e){let t=ue().listeners;return t.add(e),()=>{t.delete(e)}}function ge(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,a,d)=>e.assign(t,n,i,a,d),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var He="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(He))}function pe(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var je={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function j(){if(typeof window=="undefined")return je;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 ze(){j().version+=1;for(let e of j().listeners)e()}function z(e){W()&&(j().sections=[...e],ze())}var me="0.41.0",J=me!=="0.0.0-dev"?{name:"react",version:me}:void 0;function Je(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Je()[e]=t}function ye(e){window.__sentient_vocabulary_override=e}function Xe(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){Xe()[e]=t}function ve(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let a=n.slice(i.index+i[0].length);i[1]!="&"&&a[0]=="&"&&(a=i[1]+a.slice(1));let d=n.slice(0,i.index)+a;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",D=null,X=!1;function he(){return X}function qe(){try{return sessionStorage.getItem(q)}catch(e){return null}}function K(e){if(D)return D;let t=typeof window=="undefined"?null:ve("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:qe();return X=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return X=!0,D=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(q,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function _e(){try{sessionStorage.removeItem(q)}catch(e){}}var Se="sentient_preview_cell",we="sentient_refresh_region",Y="sentient-cell-preview-bar",P="__preview__",Ye=null;function be(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Y))return;let t,n;try{let l=new URLSearchParams(window.location.search);t=l.get(Se),n=l.get(we)}catch(l){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),a=K(i);if(!he())return;if(n){Ye={slotId:n,session:a,base:i},T(n,{kind:"arms"}),V(n,P),F();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let g=t.slice(0,d),O=t.slice(d+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(U(l.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async l=>{if(!l)return;if(!l.ok){U(l.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await l.json();if(c.vocabulary&&Array.isArray(c.vocabulary.entries)&&ye(c.vocabulary),c.compose!=null)T(g,{kind:"arms",compose:{[P]:c.compose}}),V(g,P);else if(c.edits!=null&&typeof c.skeletonFp=="string"&&Array.isArray(c.leafToNode))T(g,{kind:"arms",edits:{edits:c.edits,fp:c.skeletonFp,leafToNode:c.leafToNode}}),V(g,P);else if(c.blocks!=null)T(g,{kind:"arms",blocks:{[P]:c.blocks}}),V(g,P);else if(c.content!=null)T(g,{kind:"arms",content:c.content}),V(g,P);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${g}"]`))==null||p.scrollIntoView({block:"center"})}catch(y){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var a;if(document.getElementById(Y))return;let t=document.createElement("div");t.id=Y,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{_e();let d=new URL(window.location.href);d.searchParams.delete(Se),d.searchParams.delete(we),window.location.assign(d.toString())},t.append(n,i),((a=document.body)!=null?a:document.documentElement).append(t)}var Ce=!1;function xe(e){if(Ce||typeof window=="undefined")return;Ce=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Qe(t,n.token)})}function Qe(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Ae=require("react/jsx-runtime");function Ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,B.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Re="https://api.sentient-ui.com/v1",et=(0,o.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Re,debug:!1}),ke=!1,Q=new Set;function tt(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,d]=(0,o.useState)(null),[g,O]=(0,o.useState)(!1),l=(0,o.useRef)(e);l.current=e;let c=e===void 0?"":typeof e=="string"?e:JSON.stringify($(v({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,o.useEffect)(()=>{let p=l.current;if(p===void 0||typeof window=="undefined")return;let y,R=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:I})=>{if(R)return;let E=x(typeof p=="object"&&p.cmp===void 0&&p.check?v($(v({},p),{check:()=>l.current.check()}),p.refused?{refused:()=>{var _,S;return((S=(_=l.current).refused)==null?void 0:S.call(_))===!0}}:{}):p),w=!1,L=()=>{let _=E.refused()&&E.read()!==!0;_&&!w&&(I(t),i.current()),w=_,O(_);let S=E.read();S!==null&&Q.add(t),d(S!=null?S:Q.has(t)?!1:null)};L(),y=E.subscribe(L)}),()=>{R=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function Ee(e){var ee,te,ne,ie,re;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:Ze()}),[a,d]=(0,o.useState)(H());(0,o.useEffect)(()=>fe(()=>d(H())),[]),(0,o.useEffect)(()=>{be(e.apiBaseUrl),xe(e.apiBaseUrl)},[]);let g=(0,o.useRef)(()=>{}),O=tt(e.consentFrom,e.apiKey,()=>g.current()),l=e.consentFrom?(ee=O.granted)!=null?ee:Q.has(e.apiKey)?!1:e.consent===!0:e.consent,c=e.consentFrom?O.refused:!0,p=(0,o.useRef)(c);p.current=c;let y=(0,o.useRef)(null),R=(0,o.useRef)(!1),x=(0,o.useRef)([]),I=(0,o.useRef)(!1);g.current=()=>{var f;x.current=[],I.current=!0;let r=y.current;r!=null&&r.gated?r.dispose():(f=r==null?void 0:r.takeHeld)==null||f.call(r)},(0,o.useEffect)(()=>{var N,oe;if(p.current&&l===!1&&(x.current=[]),l===!1&&R.current&&(p.current&&((N=y.current)==null||N.destroy()),y.current=null,R.current=!1),l===!1&&!e.preConsentBehavior){p.current&&((oe=y.current)==null||oe.destroy()),y.current=null,n(null);return}let r=l!==!1;r&&(I.current=!1);let f=h=>{!r&&I.current&&h.gated&&h.dispose()},m=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},J?{sdk:J}:{}),u=!1,s=null,b=null,C=h=>{for(let A of x.current.splice(0))setTimeout(()=>{if(y.current!==h){I.current||x.current.push(A);return}try{A(h)}catch(st){}},0)},k=h=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{u||(b=A(h,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:h})=>{u||(s=h($(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),f(s),y.current=s,R.current=r,C(s),n(s),k(s))}):(s=(0,B.init)(m),f(s),y.current=s,R.current=r,C(s),n(s),k(s)),()=>{var h,A;u=!0,b==null||b(),x.current=x.current.concat((A=(h=s==null?void 0:s.takeHeld)==null?void 0:h.call(s))!=null?A:[]),s==null||s.dispose()}},[l]),(0,o.useEffect)(()=>{if(!t)return;let r=!1,f=async()=>{if(r)return;let u;try{u=await t.fetchWeights()}catch(s){return}if(!r)for(let s of u){let b={componentId:s.componentId,updatedAt:s.updatedAt,variants:s.variants.map(C=>{var k;return{variantId:C.variantId,pulls:C.pulls,avgReward:(k=C.avgReward)!=null?k:0}})};de(s.componentId,b)}};f();let m=setInterval(()=>{f()},6e4);return()=>{r=!0,clearInterval(m)}},[t]);let E=(te=e.ssrFallback)!=null?te:"first",w=((ne=e.apiBaseUrl)!=null?ne:Re).replace(/\/$/,""),L=(0,o.useRef)(null);(0,o.useEffect)(()=>{var m;if(typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},f=L.current;if(L.current=r,f!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[u],r[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),(0,o.useEffect)(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||pe({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ie=e.identity)==null?void 0:ie.userId,S=(re=e.identity)==null?void 0:re.userHash;(0,o.useEffect)(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),(0,o.useEffect)(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){z(r);return}e.declaredSections&&e.declaredSections.length>0&&z(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||ke||(ke=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,o.useEffect)(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),m=r.filter(u=>!f.has(u));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(u=>`"${u}"`).join(", ")} ${m.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Z=(0,o.useMemo)(()=>t&&a?ge(t):t,[t,a]),Te=(0,o.useMemo)(()=>{var r,f,m,u,s,b,C,k,N;return{client:Z,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(f=e.initialUnified)!=null?f:nt,sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(m=e.initialLayoutOrder)!=null?m:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(s=e.initialSlotConfig)!=null?s:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:w,debug:(N=e.debug)!=null?N:!1}},[Z,e.apiKey,e.initialAssignments,e.initialUnified,i,E,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return(0,Ae.jsx)(et.Provider,{value:Te,children:e.children})}var nt=[];function it(e){return e<.3?"low":e<.7?"medium":"high"}function Pe(e={}){var n,i,a;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",it((a=e.confidence)!=null?a:1))}catch(d){}}else delete t.__sentient_persona_override;F()}var Ie=require("react/jsx-runtime");function rt(e,t={},n){return Pe(t),(0,Oe.render)((0,Ie.jsx)(Ee,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
|
|
2
|
+
"use strict";var Ve=Object.create;var G=Object.defineProperty,De=Object.defineProperties,Le=Object.getOwnPropertyDescriptor,Ne=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertyNames,se=Object.getOwnPropertySymbols,Fe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable;var ae=(e,t,n)=>t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))le.call(t,n)&&ae(e,n,t[n]);if(se)for(var n of se(t))We.call(t,n)&&ae(e,n,t[n]);return e},$=(e,t)=>De(e,Ne(t));var Ue=(e,t)=>{for(var n in t)G(e,n,{get:t[n],enumerable:!0})},ce=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ge(t))!le.call(e,a)&&a!==n&&G(e,a,{get:()=>t[a],enumerable:!(i=Le(t,a))||i.enumerable});return e};var M=(e,t,n)=>(n=e!=null?Ve(Fe(e)):{},ce(t||!e||!e.__esModule?G(n,"default",{value:e,enumerable:!0}):n,e)),$e=e=>ce(G({},"__esModule",{value:!0}),e);var ot={};Ue(ot,{renderWithSentient:()=>rt});module.exports=$e(ot);var Oe=require("@testing-library/react");var o=require("react"),B=require("@sentientui/core");var Me=new Map,Ke=new Map;function de(e,t){Me.set(e,t);let n=Ke.get(e);if(n)for(let i of n)try{i(t)}catch(a){}}var Be={on:!1,listeners:new Set};function ue(){if(typeof window=="undefined")return Be;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function H(){return ue().on}function fe(e){let t=ue().listeners;return t.add(e),()=>{t.delete(e)}}function ge(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,a,d)=>e.assign(t,n,i,a,d),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var He="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(He))}function pe(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var je={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function j(){if(typeof window=="undefined")return je;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 ze(){j().version+=1;for(let e of j().listeners)e()}function z(e){W()&&(j().sections=[...e],ze())}var me="0.41.1",J=me!=="0.0.0-dev"?{name:"react",version:me}:void 0;function Je(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function T(e,t){Je()[e]=t}function ye(e){window.__sentient_vocabulary_override=e}function Xe(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){Xe()[e]=t}function ve(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let a=n.slice(i.index+i[0].length);i[1]!="&"&&a[0]=="&"&&(a=i[1]+a.slice(1));let d=n.slice(0,i.index)+a;history.replaceState(history.state,"",d?"#"+d:location.pathname+location.search)}}catch(n){}return t}var q="__snt_editor_token",D=null,X=!1;function he(){return X}function qe(){try{return sessionStorage.getItem(q)}catch(e){return null}}function K(e){if(D)return D;let t=typeof window=="undefined"?null:ve("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:qe();return X=!!n,D=Promise.resolve(n?{token:n,fresh:!1}:null),D}return X=!0,D=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(q,i)}catch(a){}return{token:i,fresh:!0}}).catch(()=>({error:0})),D}function _e(){try{sessionStorage.removeItem(q)}catch(e){}}var Se="sentient_preview_cell",we="sentient_refresh_region",Y="sentient-cell-preview-bar",P="__preview__",Ye=null;function be(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(Y))return;let t,n;try{let l=new URLSearchParams(window.location.search);t=l.get(Se),n=l.get(we)}catch(l){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),a=K(i);if(!he())return;if(n){Ye={slotId:n,session:a,base:i},T(n,{kind:"arms"}),V(n,P),F();return}if(!t)return;let d=t.lastIndexOf("~");if(d<=0)return;let g=t.slice(0,d),O=t.slice(d+1);a.then(l=>l?"token"in l?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(g)}&persona=${encodeURIComponent(O)}`,{headers:{authorization:`Bearer ${l.token}`}}):(U(l.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async l=>{if(!l)return;if(!l.ok){U(l.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await l.json();if(c.vocabulary&&Array.isArray(c.vocabulary.entries)&&ye(c.vocabulary),c.compose!=null)T(g,{kind:"arms",compose:{[P]:c.compose}}),V(g,P);else if(c.edits!=null&&typeof c.skeletonFp=="string"&&Array.isArray(c.leafToNode))T(g,{kind:"arms",edits:{edits:c.edits,fp:c.skeletonFp,leafToNode:c.leafToNode}}),V(g,P);else if(c.blocks!=null)T(g,{kind:"arms",blocks:{[P]:c.blocks}}),V(g,P);else if(c.content!=null)T(g,{kind:"arms",content:c.content}),V(g,P);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var p;try{(p=document.querySelector(`[data-sentient-slot="${g}"]`))==null||p.scrollIntoView({block:"center"})}catch(y){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var a;if(document.getElementById(Y))return;let t=document.createElement("div");t.id=Y,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{_e();let d=new URL(window.location.href);d.searchParams.delete(Se),d.searchParams.delete(we),window.location.assign(d.toString())},t.append(n,i),((a=document.body)!=null?a:document.documentElement).append(t)}var Ce=!1;function xe(e){if(Ce||typeof window=="undefined")return;Ce=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Qe(t,n.token)})}function Qe(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}var Ae=require("react/jsx-runtime");function Ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,B.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Re="https://api.sentient-ui.com/v1",et=(0,o.createContext)({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:Re,debug:!1}),ke=!1,Q=new Set;function tt(e,t,n){let i=(0,o.useRef)(n);i.current=n;let[a,d]=(0,o.useState)(null),[g,O]=(0,o.useState)(!1),l=(0,o.useRef)(e);l.current=e;let c=e===void 0?"":typeof e=="string"?e:JSON.stringify($(v({},e),{check:typeof e.check,refused:typeof e.refused}));return(0,o.useEffect)(()=>{let p=l.current;if(p===void 0||typeof window=="undefined")return;let y,R=!1;return import("@sentientui/core/consent").then(({consentWatcher:x,forgetVisitor:I})=>{if(R)return;let E=x(typeof p=="object"&&p.cmp===void 0&&p.check?v($(v({},p),{check:()=>l.current.check()}),p.refused?{refused:()=>{var _,S;return((S=(_=l.current).refused)==null?void 0:S.call(_))===!0}}:{}):p),w=!1,L=()=>{let _=E.refused()&&E.read()!==!0;_&&!w&&(I(t),i.current()),w=_,O(_);let S=E.read();S!==null&&Q.add(t),d(S!=null?S:Q.has(t)?!1:null)};L(),y=E.subscribe(L)}),()=>{R=!0,y==null||y()}},[c,t]),{granted:a,refused:g}}function Ee(e){var ee,te,ne,ie,re;let[t,n]=(0,o.useState)(null),[i]=(0,o.useState)(()=>{var r;return(r=e.sessionSegment)!=null?r:Ze()}),[a,d]=(0,o.useState)(H());(0,o.useEffect)(()=>fe(()=>d(H())),[]),(0,o.useEffect)(()=>{be(e.apiBaseUrl),xe(e.apiBaseUrl)},[]);let g=(0,o.useRef)(()=>{}),O=tt(e.consentFrom,e.apiKey,()=>g.current()),l=e.consentFrom?(ee=O.granted)!=null?ee:Q.has(e.apiKey)?!1:e.consent===!0:e.consent,c=e.consentFrom?O.refused:!0,p=(0,o.useRef)(c);p.current=c;let y=(0,o.useRef)(null),R=(0,o.useRef)(!1),x=(0,o.useRef)([]),I=(0,o.useRef)(!1);g.current=()=>{var f;x.current=[],I.current=!0;let r=y.current;r!=null&&r.gated?r.dispose():(f=r==null?void 0:r.takeHeld)==null||f.call(r)},(0,o.useEffect)(()=>{var N,oe;if(p.current&&l===!1&&(x.current=[]),l===!1&&R.current&&(p.current&&((N=y.current)==null||N.destroy()),y.current=null,R.current=!1),l===!1&&!e.preConsentBehavior){p.current&&((oe=y.current)==null||oe.destroy()),y.current=null,n(null);return}let r=l!==!1;r&&(I.current=!1);let f=h=>{!r&&I.current&&h.gated&&h.dispose()},m=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:l,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},J?{sdk:J}:{}),u=!1,s=null,b=null,C=h=>{for(let A of x.current.splice(0))setTimeout(()=>{if(y.current!==h){I.current||x.current.push(A);return}try{A(h)}catch(st){}},0)},k=h=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:A})=>{u||(b=A(h,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:h})=>{u||(s=h($(v({},m),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),f(s),y.current=s,R.current=r,C(s),n(s),k(s))}):(s=(0,B.init)(m),f(s),y.current=s,R.current=r,C(s),n(s),k(s)),()=>{var h,A;u=!0,b==null||b(),x.current=x.current.concat((A=(h=s==null?void 0:s.takeHeld)==null?void 0:h.call(s))!=null?A:[]),s==null||s.dispose()}},[l]),(0,o.useEffect)(()=>{if(!t)return;let r=!1,f=async()=>{if(r)return;let u;try{u=await t.fetchWeights()}catch(s){return}if(!r)for(let s of u){let b={componentId:s.componentId,updatedAt:s.updatedAt,variants:s.variants.map(C=>{var k;return{variantId:C.variantId,pulls:C.pulls,avgReward:(k=C.avgReward)!=null?k:0}})};de(s.componentId,b)}};f();let m=setInterval(()=>{f()},6e4);return()=>{r=!0,clearInterval(m)}},[t]);let E=(te=e.ssrFallback)!=null?te:"first",w=((ne=e.apiBaseUrl)!=null?ne:Re).replace(/\/$/,""),L=(0,o.useRef)(null);(0,o.useEffect)(()=>{var m;if(typeof process!="undefined"&&((m=process.env)==null?void 0:m.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},f=L.current;if(L.current=r,f!==null)for(let u of["apiKey","context","country","persona","apiBaseUrl"])Object.is(f[u],r[u])||console.warn(`[sentient] AdaptiveProvider: \`${u}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),(0,o.useEffect)(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||pe({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ie=e.identity)==null?void 0:ie.userId,S=(re=e.identity)==null?void 0:re.userHash;(0,o.useEffect)(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),(0,o.useEffect)(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){z(r);return}e.declaredSections&&e.declaredSections.length>0&&z(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,o.useEffect)(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||ke||(ke=!0,console.warn('[SentientUI] No consent gate: every visitor is tracked from first paint. Pass consentFrom="<your CMP>" (or consent={true} to silence). https://sentient-ui.com/docs#consent'))},[]),(0,o.useEffect)(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let f=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),u=>u.getAttribute("data-sentient-id"))),m=r.filter(u=>!f.has(u));m.length>0&&console.warn(`[SentientUI] Declared section${m.length>1?"s":""} ${m.map(u=>`"${u}"`).join(", ")} ${m.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Z=(0,o.useMemo)(()=>t&&a?ge(t):t,[t,a]),Te=(0,o.useMemo)(()=>{var r,f,m,u,s,b,C,k,N;return{client:Z,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(f=e.initialUnified)!=null?f:nt,sessionSegment:i,ssrFallback:E,onAssignment:e.onAssignment,initialLayoutOrder:(m=e.initialLayoutOrder)!=null?m:null,initialSlots:(u=e.initialSlots)!=null?u:{},initialSlotConfig:(s=e.initialSlotConfig)!=null?s:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(k=e.initialPersona)!=null?k:null,apiBaseUrl:w,debug:(N=e.debug)!=null?N:!1}},[Z,e.apiKey,e.initialAssignments,e.initialUnified,i,E,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return(0,Ae.jsx)(et.Provider,{value:Te,children:e.children})}var nt=[];function it(e){return e<.3?"low":e<.7?"medium":"high"}function Pe(e={}){var n,i,a;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let d=document.documentElement;d.setAttribute("data-sentient-persona",e.persona),d.setAttribute("data-sentient-confidence",it((a=e.confidence)!=null?a:1))}catch(d){}}else delete t.__sentient_persona_override;F()}var Ie=require("react/jsx-runtime");function rt(e,t={},n){return Pe(t),(0,Oe.render)((0,Ie.jsx)(Ee,{apiKey:"pk_test",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
|
|
3
3
|
//# sourceMappingURL=react.js.map
|
package/dist/testing/react.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
var Ae=Object.defineProperty,Pe=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var se=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ie.call(t,n)&&se(e,n,t[n]);if(oe)for(var n of oe(t))Te.call(t,n)&&se(e,n,t[n]);return e},M=(e,t)=>Pe(e,Oe(t));import{render as Ze}from"@testing-library/react";import{createContext as Be,useContext as At,useEffect as h,useMemo as be,useRef as x,useState as $,useSyncExternalStore as Pt}from"react";import{deriveSessionSegment as He,init as je}from"@sentientui/core";var Ve=new Map,De=new Map;function ae(e,t){Ve.set(e,t);let n=De.get(e);if(n)for(let i of n)try{i(t)}catch(l){}}var Le={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function B(){return le().on}function ce(e){let t=le().listeners;return t.add(e),()=>{t.delete(e)}}function de(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,l,c)=>e.assign(t,n,i,l,c),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Ne="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Ne))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ge={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function H(){if(typeof window=="undefined")return Ge;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 Fe(){H().version+=1;for(let e of H().listeners)e()}function j(e){W()&&(H().sections=[...e],Fe())}var fe="0.41.0",z=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function We(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function V(e,t){We()[e]=t}function ge(e){window.__sentient_vocabulary_override=e}function Ue(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ue()[e]=t}function pe(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let l=n.slice(i.index+i[0].length);i[1]!="&"&&l[0]=="&"&&(l=i[1]+l.slice(1));let c=n.slice(0,i.index)+l;history.replaceState(history.state,"",c?"#"+c:location.pathname+location.search)}}catch(n){}return t}var X="__snt_editor_token",L=null,J=!1;function me(){return J}function $e(){try{return sessionStorage.getItem(X)}catch(e){return null}}function K(e){if(L)return L;let t=typeof window=="undefined"?null:pe("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:$e();return J=!!n,L=Promise.resolve(n?{token:n,fresh:!1}:null),L}return J=!0,L=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(X,i)}catch(l){}return{token:i,fresh:!0}}).catch(()=>({error:0})),L}function ye(){try{sessionStorage.removeItem(X)}catch(e){}}var ve="sentient_preview_cell",he="sentient_refresh_region",q="sentient-cell-preview-bar",O="__preview__",Me=null;function _e(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(q))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ve),n=s.get(he)}catch(s){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(i);if(!me())return;if(n){Me={slotId:n,session:l,base:i},V(n,{kind:"arms"}),D(n,O),F();return}if(!t)return;let c=t.lastIndexOf("~");if(c<=0)return;let f=t.slice(0,c),I=t.slice(c+1);l.then(s=>s?"token"in s?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(U(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){U(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&ge(a.vocabulary),a.compose!=null)V(f,{kind:"arms",compose:{[O]:a.compose}}),D(f,O);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))V(f,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),D(f,O);else if(a.blocks!=null)V(f,{kind:"arms",blocks:{[O]:a.blocks}}),D(f,O);else if(a.content!=null)V(f,{kind:"arms",content:a.content}),D(f,O);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var g;try{(g=document.querySelector(`[data-sentient-slot="${f}"]`))==null||g.scrollIntoView({block:"center"})}catch(m){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var l;if(document.getElementById(q))return;let t=document.createElement("div");t.id=q,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{ye();let c=new URL(window.location.href);c.searchParams.delete(ve),c.searchParams.delete(he),window.location.assign(c.toString())},t.append(n,i),((l=document.body)!=null?l:document.documentElement).append(t)}var Se=!1;function we(e){if(Se||typeof window=="undefined")return;Se=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Ke(t,n.token)})}function Ke(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Ye}from"react/jsx-runtime";function ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return He({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xe="https://api.sentient-ui.com/v1",Je=Be({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:xe,debug:!1}),Ce=!1,Y=new Set;function Xe(e,t,n){let i=x(n);i.current=n;let[l,c]=$(null),[f,I]=$(!1),s=x(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(y({},e),{check:typeof e.check,refused:typeof e.refused}));return h(()=>{let g=s.current;if(g===void 0||typeof window=="undefined")return;let m,E=!1;return import("@sentientui/core/consent").then(({consentWatcher:k,forgetVisitor:T})=>{if(E)return;let A=k(typeof g=="object"&&g.cmp===void 0&&g.check?y(M(y({},g),{check:()=>s.current.check()}),g.refused?{refused:()=>{var _,S;return((S=(_=s.current).refused)==null?void 0:S.call(_))===!0}}:{}):g),w=!1,N=()=>{let _=A.refused()&&A.read()!==!0;_&&!w&&(T(t),i.current()),w=_,I(_);let S=A.read();S!==null&&Y.add(t),c(S!=null?S:Y.has(t)?!1:null)};N(),m=A.subscribe(N)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function ke(e){var Z,ee,te,ne,ie;let[t,n]=$(null),[i]=$(()=>{var r;return(r=e.sessionSegment)!=null?r:ze()}),[l,c]=$(B());h(()=>ce(()=>c(B())),[]),h(()=>{_e(e.apiBaseUrl),we(e.apiBaseUrl)},[]);let f=x(()=>{}),I=Xe(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Z=I.granted)!=null?Z:Y.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?I.refused:!0,g=x(a);g.current=a;let m=x(null),E=x(!1),k=x([]),T=x(!1);f.current=()=>{var u;k.current=[],T.current=!0;let r=m.current;r!=null&&r.gated?r.dispose():(u=r==null?void 0:r.takeHeld)==null||u.call(r)},h(()=>{var G,re;if(g.current&&s===!1&&(k.current=[]),s===!1&&E.current&&(g.current&&((G=m.current)==null||G.destroy()),m.current=null,E.current=!1),s===!1&&!e.preConsentBehavior){g.current&&((re=m.current)==null||re.destroy()),m.current=null,n(null);return}let r=s!==!1;r&&(T.current=!1);let u=v=>{!r&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!1,o=null,b=null,C=v=>{for(let P of k.current.splice(0))setTimeout(()=>{if(m.current!==v){T.current||k.current.push(P);return}try{P(v)}catch(tt){}},0)},R=v=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{d||(b=P(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{d||(o=v(M(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=r,C(o),n(o),R(o))}):(o=je(p),u(o),m.current=o,E.current=r,C(o),n(o),R(o)),()=>{var v,P;d=!0,b==null||b(),k.current=k.current.concat((P=(v=o==null?void 0:o.takeHeld)==null?void 0:v.call(o))!=null?P:[]),o==null||o.dispose()}},[s]),h(()=>{if(!t)return;let r=!1,u=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(o){return}if(!r)for(let o of d){let b={componentId:o.componentId,updatedAt:o.updatedAt,variants:o.variants.map(C=>{var R;return{variantId:C.variantId,pulls:C.pulls,avgReward:(R=C.avgReward)!=null?R:0}})};ae(o.componentId,b)}};u();let p=setInterval(()=>{u()},6e4);return()=>{r=!0,clearInterval(p)}},[t]);let A=(ee=e.ssrFallback)!=null?ee:"first",w=((te=e.apiBaseUrl)!=null?te:xe).replace(/\/$/,""),N=x(null);h(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},u=N.current;if(N.current=r,u!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[d],r[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),h(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||ue({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ne=e.identity)==null?void 0:ne.userId,S=(ie=e.identity)==null?void 0:ie.userHash;h(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),h(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){j(r);return}e.declaredSections&&e.declaredSections.length>0&&j(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),h(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||Ce||(Ce=!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'))},[]),h(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),p=r.filter(d=>!u.has(d));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(d=>`"${d}"`).join(", ")} ${p.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Q=be(()=>t&&l?de(t):t,[t,l]),Ee=be(()=>{var r,u,p,d,o,b,C,R,G;return{client:Q,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(u=e.initialUnified)!=null?u:qe,sessionSegment:i,ssrFallback:A,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(d=e.initialSlots)!=null?d:{},initialSlotConfig:(o=e.initialSlotConfig)!=null?o:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(R=e.initialPersona)!=null?R:null,apiBaseUrl:w,debug:(G=e.debug)!=null?G:!1}},[Q,e.apiKey,e.initialAssignments,e.initialUnified,i,A,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return Ye(Je.Provider,{value:Ee,children:e.children})}var qe=[];function Qe(e){return e<.3?"low":e<.7?"medium":"high"}function Re(e={}){var n,i,l;let t=window;if(t.__sentient_overrides=y({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=y({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=y({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let c=document.documentElement;c.setAttribute("data-sentient-persona",e.persona),c.setAttribute("data-sentient-confidence",Qe((l=e.confidence)!=null?l:1))}catch(c){}}else delete t.__sentient_persona_override;F()}import{jsx as et}from"react/jsx-runtime";function Jt(e,t={},n){return Re(t),Ze(et(ke,{apiKey:"pk_test",consent:!1,children:e}),n)}export{Jt as renderWithSentient};
|
|
2
|
+
var Ae=Object.defineProperty,Pe=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Ie=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable;var se=(e,t,n)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y=(e,t)=>{for(var n in t||(t={}))Ie.call(t,n)&&se(e,n,t[n]);if(oe)for(var n of oe(t))Te.call(t,n)&&se(e,n,t[n]);return e},M=(e,t)=>Pe(e,Oe(t));import{render as Ze}from"@testing-library/react";import{createContext as Be,useContext as At,useEffect as h,useMemo as be,useRef as x,useState as $,useSyncExternalStore as Pt}from"react";import{deriveSessionSegment as He,init as je}from"@sentientui/core";var Ve=new Map,De=new Map;function ae(e,t){Ve.set(e,t);let n=De.get(e);if(n)for(let i of n)try{i(t)}catch(l){}}var Le={on:!1,listeners:new Set};function le(){if(typeof window=="undefined")return Le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function B(){return le().on}function ce(e){let t=le().listeners;return t.add(e),()=>{t.delete(e)}}function de(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),isUnified:t=>{var n,i;return(i=(n=e.isUnified)==null?void 0:n.call(e,t))!=null?i:!1},assign:(t,n,i,l,c)=>e.assign(t,n,i,l,c),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),flush:()=>e.flush(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var Ne="sentient:overrides-changed";function F(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(Ne))}function ue(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function W(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Ge={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function H(){if(typeof window=="undefined")return Ge;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 Fe(){H().version+=1;for(let e of H().listeners)e()}function j(e){W()&&(H().sections=[...e],Fe())}var fe="0.41.1",z=fe!=="0.0.0-dev"?{name:"react",version:fe}:void 0;function We(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function V(e,t){We()[e]=t}function ge(e){window.__sentient_vocabulary_override=e}function Ue(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function D(e,t){Ue()[e]=t}function pe(e){let t=null;try{let n=location.hash.slice(1),i=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(i){t=i[2];let l=n.slice(i.index+i[0].length);i[1]!="&"&&l[0]=="&"&&(l=i[1]+l.slice(1));let c=n.slice(0,i.index)+l;history.replaceState(history.state,"",c?"#"+c:location.pathname+location.search)}}catch(n){}return t}var X="__snt_editor_token",L=null,J=!1;function me(){return J}function $e(){try{return sessionStorage.getItem(X)}catch(e){return null}}function K(e){if(L)return L;let t=typeof window=="undefined"?null:pe("sentient_editor_code");if(!t){let n=typeof window=="undefined"?null:$e();return J=!!n,L=Promise.resolve(n?{token:n,fresh:!1}:null),L}return J=!0,L=fetch(`${e}/editor/exchange`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:t})}).then(async n=>{let i=n.ok?(await n.json()).token:void 0;if(!i)return{error:n.ok?500:n.status};try{sessionStorage.setItem(X,i)}catch(l){}return{token:i,fresh:!0}}).catch(()=>({error:0})),L}function ye(){try{sessionStorage.removeItem(X)}catch(e){}}var ve="sentient_preview_cell",he="sentient_refresh_region",q="sentient-cell-preview-bar",O="__preview__",Me=null;function _e(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(q))return;let t,n;try{let s=new URLSearchParams(window.location.search);t=s.get(ve),n=s.get(he)}catch(s){return}if(!t&&!n)return;let i=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,""),l=K(i);if(!me())return;if(n){Me={slotId:n,session:l,base:i},V(n,{kind:"arms"}),D(n,O),F();return}if(!t)return;let c=t.lastIndexOf("~");if(c<=0)return;let f=t.slice(0,c),I=t.slice(c+1);l.then(s=>s?"token"in s?fetch(`${i}/editor/cell-preview?slotId=${encodeURIComponent(f)}&persona=${encodeURIComponent(I)}`,{headers:{authorization:`Bearer ${s.token}`}}):(U(s.error===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard."),null):null).then(async s=>{if(!s)return;if(!s.ok){U(s.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let a=await s.json();if(a.vocabulary&&Array.isArray(a.vocabulary.entries)&&ge(a.vocabulary),a.compose!=null)V(f,{kind:"arms",compose:{[O]:a.compose}}),D(f,O);else if(a.edits!=null&&typeof a.skeletonFp=="string"&&Array.isArray(a.leafToNode))V(f,{kind:"arms",edits:{edits:a.edits,fp:a.skeletonFp,leafToNode:a.leafToNode}}),D(f,O);else if(a.blocks!=null)V(f,{kind:"arms",blocks:{[O]:a.blocks}}),D(f,O);else if(a.content!=null)V(f,{kind:"arms",content:a.content}),D(f,O);else{U("Nothing to preview in that square yet.");return}F(),U(`Previewing \u201C${a.slotName}\u201D for ${a.personaDisplay}${a.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var g;try{(g=document.querySelector(`[data-sentient-slot="${f}"]`))==null||g.scrollIntoView({block:"center"})}catch(m){}},300)}).catch(()=>U("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function U(e){var l;if(document.getElementById(q))return;let t=document.createElement("div");t.id=q,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let i=document.createElement("button");i.textContent="Exit preview",Object.assign(i.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),i.onclick=()=>{ye();let c=new URL(window.location.href);c.searchParams.delete(ve),c.searchParams.delete(he),window.location.assign(c.toString())},t.append(n,i),((l=document.body)!=null?l:document.documentElement).append(t)}var Se=!1;function we(e){if(Se||typeof window=="undefined")return;Se=!0;let t=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");K(t).then(n=>{!n||!("token"in n)||!n.fresh||Ke(t,n.token)})}function Ke(e,t){let n=()=>{window.setTimeout(()=>{import("@sentientui/core/style-sample").then(({sampleStyleVocabulary:i})=>fetch(`${e}/editor/style-vocabulary`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(i(document))})).catch(()=>{})},1e3)};document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}import{jsx as Ye}from"react/jsx-runtime";function ze(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return He({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var xe="https://api.sentient-ui.com/v1",Je=Be({client:null,apiKey:"",initialAssignments:{},initialUnified:[],sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialVocabulary:null,initialPersona:null,apiBaseUrl:xe,debug:!1}),Ce=!1,Y=new Set;function Xe(e,t,n){let i=x(n);i.current=n;let[l,c]=$(null),[f,I]=$(!1),s=x(e);s.current=e;let a=e===void 0?"":typeof e=="string"?e:JSON.stringify(M(y({},e),{check:typeof e.check,refused:typeof e.refused}));return h(()=>{let g=s.current;if(g===void 0||typeof window=="undefined")return;let m,E=!1;return import("@sentientui/core/consent").then(({consentWatcher:k,forgetVisitor:T})=>{if(E)return;let A=k(typeof g=="object"&&g.cmp===void 0&&g.check?y(M(y({},g),{check:()=>s.current.check()}),g.refused?{refused:()=>{var _,S;return((S=(_=s.current).refused)==null?void 0:S.call(_))===!0}}:{}):g),w=!1,N=()=>{let _=A.refused()&&A.read()!==!0;_&&!w&&(T(t),i.current()),w=_,I(_);let S=A.read();S!==null&&Y.add(t),c(S!=null?S:Y.has(t)?!1:null)};N(),m=A.subscribe(N)}),()=>{E=!0,m==null||m()}},[a,t]),{granted:l,refused:f}}function ke(e){var Z,ee,te,ne,ie;let[t,n]=$(null),[i]=$(()=>{var r;return(r=e.sessionSegment)!=null?r:ze()}),[l,c]=$(B());h(()=>ce(()=>c(B())),[]),h(()=>{_e(e.apiBaseUrl),we(e.apiBaseUrl)},[]);let f=x(()=>{}),I=Xe(e.consentFrom,e.apiKey,()=>f.current()),s=e.consentFrom?(Z=I.granted)!=null?Z:Y.has(e.apiKey)?!1:e.consent===!0:e.consent,a=e.consentFrom?I.refused:!0,g=x(a);g.current=a;let m=x(null),E=x(!1),k=x([]),T=x(!1);f.current=()=>{var u;k.current=[],T.current=!0;let r=m.current;r!=null&&r.gated?r.dispose():(u=r==null?void 0:r.takeHeld)==null||u.call(r)},h(()=>{var G,re;if(g.current&&s===!1&&(k.current=[]),s===!1&&E.current&&(g.current&&((G=m.current)==null||G.destroy()),m.current=null,E.current=!1),s===!1&&!e.preConsentBehavior){g.current&&((re=m.current)==null||re.destroy()),m.current=null,n(null);return}let r=s!==!1;r&&(T.current=!1);let u=v=>{!r&&T.current&&v.gated&&v.dispose()},p=y({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,initialUnified:e.initialUnified,sessionSegment:i,consent:s,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,cookieDomain:e.cookieDomain,country:e.country,persona:e.persona,stageAttributes:e.stageAttributes,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialVocabulary:e.initialVocabulary,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0,nonce:e.nonce},z?{sdk:z}:{}),d=!1,o=null,b=null,C=v=>{for(let P of k.current.splice(0))setTimeout(()=>{if(m.current!==v){T.current||k.current.push(P);return}try{P(v)}catch(tt){}},0)},R=v=>{e.engagement===!1||!r||import("@sentientui/core/engagement").then(({startEngagementCapture:P})=>{d||(b=P(v,{apiKey:e.apiKey,sectionTypes:e.sectionTypes,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:v})=>{d||(o=v(M(y({},p),{graph:!0,captureDomText:e.captureDomText===!0,sectionTypes:e.sectionTypes})),u(o),m.current=o,E.current=r,C(o),n(o),R(o))}):(o=je(p),u(o),m.current=o,E.current=r,C(o),n(o),R(o)),()=>{var v,P;d=!0,b==null||b(),k.current=k.current.concat((P=(v=o==null?void 0:o.takeHeld)==null?void 0:v.call(o))!=null?P:[]),o==null||o.dispose()}},[s]),h(()=>{if(!t)return;let r=!1,u=async()=>{if(r)return;let d;try{d=await t.fetchWeights()}catch(o){return}if(!r)for(let o of d){let b={componentId:o.componentId,updatedAt:o.updatedAt,variants:o.variants.map(C=>{var R;return{variantId:C.variantId,pulls:C.pulls,avgReward:(R=C.avgReward)!=null?R:0}})};ae(o.componentId,b)}};u();let p=setInterval(()=>{u()},6e4);return()=>{r=!0,clearInterval(p)}},[t]);let A=(ee=e.ssrFallback)!=null?ee:"first",w=((te=e.apiBaseUrl)!=null?te:xe).replace(/\/$/,""),N=x(null);h(()=>{var p;if(typeof process!="undefined"&&((p=process.env)==null?void 0:p.NODE_ENV)==="production")return;let r={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:w},u=N.current;if(N.current=r,u!==null)for(let d of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[d],r[d])||console.warn(`[sentient] AdaptiveProvider: \`${d}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,w]),h(()=>{var r;typeof process!="undefined"&&((r=process.env)==null?void 0:r.NODE_ENV)==="production"||ue({apiKey:e.apiKey,apiBaseUrl:w,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,w]);let _=(ne=e.identity)==null?void 0:ne.userId,S=(ie=e.identity)==null?void 0:ie.userHash;h(()=>{t&&_&&t.identify(_,{userHash:S})},[t,_,S]),h(()=>{let r=e.initialLayoutOrder;if(r&&r.length>0){j(r);return}e.declaredSections&&e.declaredSections.length>0&&j(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),h(()=>{!W()||e.consent!==void 0||e.consentFrom!==void 0||Ce||(Ce=!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'))},[]),h(()=>{if(!W())return;let r=e.declaredSections;if(!r||r.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),d=>d.getAttribute("data-sentient-id"))),p=r.filter(d=>!u.has(d));p.length>0&&console.warn(`[SentientUI] Declared section${p.length>1?"s":""} ${p.map(d=>`"${d}"`).join(", ")} ${p.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" to each section's element.`)},[e.declaredSections]);let Q=be(()=>t&&l?de(t):t,[t,l]),Ee=be(()=>{var r,u,p,d,o,b,C,R,G;return{client:Q,apiKey:e.apiKey,initialAssignments:(r=e.initialAssignments)!=null?r:{},initialUnified:(u=e.initialUnified)!=null?u:qe,sessionSegment:i,ssrFallback:A,onAssignment:e.onAssignment,initialLayoutOrder:(p=e.initialLayoutOrder)!=null?p:null,initialSlots:(d=e.initialSlots)!=null?d:{},initialSlotConfig:(o=e.initialSlotConfig)!=null?o:{},initialPalette:(b=e.initialPalette)!=null?b:null,initialVocabulary:(C=e.initialVocabulary)!=null?C:null,initialPersona:(R=e.initialPersona)!=null?R:null,apiBaseUrl:w,debug:(G=e.debug)!=null?G:!1}},[Q,e.apiKey,e.initialAssignments,e.initialUnified,i,A,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialVocabulary,e.initialPersona,w,e.debug]);return Ye(Je.Provider,{value:Ee,children:e.children})}var qe=[];function Qe(e){return e<.3?"low":e<.7?"medium":"high"}function Re(e={}){var n,i,l;let t=window;if(t.__sentient_overrides=y({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=y({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=y({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(i=e.confidence)!=null?i:1};try{let c=document.documentElement;c.setAttribute("data-sentient-persona",e.persona),c.setAttribute("data-sentient-confidence",Qe((l=e.confidence)!=null?l:1))}catch(c){}}else delete t.__sentient_persona_override;F()}import{jsx as et}from"react/jsx-runtime";function Jt(e,t={},n){return Re(t),Ze(et(ke,{apiKey:"pk_test",consent:!1,children:e}),n)}export{Jt as renderWithSentient};
|
|
3
3
|
//# sourceMappingURL=react.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentientui/react",
|
|
3
|
-
"version": "0.41.
|
|
3
|
+
"version": "0.41.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"llms.txt"
|
|
79
79
|
],
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@sentientui/
|
|
82
|
-
"@sentientui/
|
|
81
|
+
"@sentientui/core": "0.40.1",
|
|
82
|
+
"@sentientui/policy": "0.16.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@testing-library/react": ">=14.0.0 <17.0.0",
|