@sentientui/react 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -355,7 +355,31 @@ function HeroContact({ method }: { method: string }) {
355
355
  }
356
356
  ```
357
357
 
358
- The served variant is resolved from the SDK's assignment cache (the same one `<Adaptive id="hero_headline">` populates), so render that component before firing. `opts` accepts `reward` (0–1, default 1) and `metadata`. This replaces hand-rolled helpers that call `client.track({ eventType: 'goal_achieved', componentId, variantId, … })` — you no longer need to pass or track the variant yourself.
358
+ The served variant is resolved from the SDK's assignment cache (the same one `<Adaptive id="hero_headline">` populates), so render that component before firing.
359
+
360
+ `opts.once` records the goal at most once per mounted component, however many times you call it — use it for conversions that are a *state* rather than an action ("reached step 3", an effect that may re-run). Leave it off for genuine repeat actions: each click of "add to cart" is its own conversion.
361
+ `opts` accepts `reward` (0–1, default 1) and `metadata`. This replaces hand-rolled helpers that call `client.track({ eventType: 'goal_achieved', componentId, variantId, … })` — you no longer need to pass or track the variant yourself.
362
+
363
+ ### `usePageGoal(goalName, opts?)`
364
+
365
+ Records a conversion **once, when a page or route is reached** — the funnel steps that are a destination rather than a click: landing on `/pricing`, reaching a signup form, opening checkout.
366
+
367
+ ```tsx
368
+ import { usePageGoal } from '@sentientui/react';
369
+
370
+ function PricingPage() {
371
+ // Credit reaching this page to whichever hero CTA sent the visitor here.
372
+ usePageGoal('pricing_view', { componentId: 'hero_cta' });
373
+ return <Pricing />;
374
+ }
375
+ ```
376
+
377
+ Prefer this over a click goal on the link that led here. Arrival survives the navigation, and it also counts visitors who came from the nav, a search result or a shared link — none of whom clicked the CTA you're measuring. Pass `componentId` to credit the variant currently served for it (resolved from the localStorage-backed assignment cache, so it works across the page hop); omit it for a session-level goal with no per-variant attribution. `opts` also accepts `reward` and `metadata`, like `useAdaptiveGoal`.
378
+
379
+ Two failure modes it exists to prevent, both silent if you hand-roll this with `useAdaptiveGoal` in a `useEffect`:
380
+
381
+ - **Double counting.** `useAdaptiveGoal` has no latch, so a remount — or React's double-invoked effects in development — records the same arrival twice.
382
+ - **Losing the goal to a consent gate.** Behind a cookie banner the client doesn't exist when the page mounts, so firing on mount drops the arrival for every visitor who accepts a moment later. `usePageGoal` holds it until the SDK is running.
359
383
 
360
384
  ### `useLayoutOrder()`
361
385
 
package/dist/devtools.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- "use strict";"use client";var pe=Object.create;var S=Object.defineProperty,ue=Object.defineProperties,ge=Object.getOwnPropertyDescriptor,fe=Object.getOwnPropertyDescriptors,ve=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols,me=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var G=(e,t,o)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,d=(e,t)=>{for(var o in t||(t={}))z.call(t,o)&&G(e,o,t[o]);if(U)for(var o of U(t))ye.call(t,o)&&G(e,o,t[o]);return e},h=(e,t)=>ue(e,fe(t));var _e=(e,t)=>{for(var o in t)S(e,o,{get:t[o],enumerable:!0})},F=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ve(t))!z.call(e,a)&&a!==o&&S(e,a,{get:()=>t[a],enumerable:!(r=ge(t,a))||r.enumerable});return e};var we=(e,t,o)=>(o=e!=null?pe(me(e)):{},F(t||!e||!e.__esModule?S(o,"default",{value:e,enumerable:!0}):o,e)),be=e=>F(S({},"__esModule",{value:!0}),e);var We={};_e(We,{AdaptiveDevtools:()=>Le,LOCAL_MODE_DEVTOOLS_BANNER:()=>Z});module.exports=be(We);var c=require("react"),_=require("@sentientui/policy"),Q=require("@sentientui/core");var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function x(){if(typeof window=="undefined")return Se;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 O(){return[...x().components.values()]}function A(){return[...x().slots.values()]}function L(){return[...x().sections]}function H(e){let t=x().listeners;return t.add(e),()=>{t.delete(e)}}function Y(){return x().version}function W(){let e=window;return e.__sentient_overrides||(e.__sentient_overrides={}),e.__sentient_overrides}function D(e,t){W()[e]=t}function I(e){delete W()[e]}function k(){return d({},W())}function T(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function B(e,t){T()[e]=t}function J(e){delete T()[e]}function C(){return d({},T())}var he={on:!1,listeners:new Set};function K(){if(typeof window=="undefined")return he;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function g(e){let t=K();if(t.on!==e){t.on=e;for(let o of t.listeners)o()}}function X(){return K().on}var xe="sentient:overrides-changed";function u(){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(xe))}function $(){var e;return typeof window=="undefined"?null:(e=window.__sentient_devtools_config)!=null?e:null}var i=require("react/jsx-runtime"),q,Re=typeof process!="undefined"&&((q=process.env)==null?void 0:q.NODE_ENV)==="production",Oe="https://api.sentient-ui.com/v1",Z="Local mode \u2014 decisions are simulated; add a key to learn from real traffic";function ee(e){var o,r;for(let[a,v]of Object.entries((o=e.assignments)!=null?o:{}))D(a,v);let t=window;e.layoutOrder&&e.layoutOrder.length>0&&(t.__sentient_layout_override=e.layoutOrder),e.slots&&(t.__sentient_slot_overrides=d(d({},(r=t.__sentient_slot_overrides)!=null?r:{}),e.slots)),e.personaAttributes&&(document.documentElement.dataset.sentientPersona=e.personaAttributes.persona,document.documentElement.dataset.sentientConfidence=e.personaAttributes.confidence),g(!0),u()}function ke(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return"devtools-preview"}function te(){return A().map(e=>d(d({id:e.id},e.arms?{arms:e.arms}:{}),e.dims?{dims:e.dims}:{}))}async function Ce(e,t,o){var v;let r=await fetch(`${t}/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({persona:o,sections:L().map(m=>({id:m})),components:O().map(m=>({id:m.id,variantIds:m.variantIds})),slots:te()})});if(!r.ok)return;let a=await r.json();ee(h(d({},a),{personaAttributes:(v=a.personaAttributes)!=null?v:{persona:o,confidence:"high"}}))}async function Ee(e){let t=await import("@sentientui/core/local");if(!t.LOCAL_ENGINE_AVAILABLE)return;let o=t.createLocalEngine({sessionId:ke(),forcedPersona:e}).decide({sections:L(),components:O().map(r=>({id:r.id,variantIds:r.variantIds})),slots:te()});ee({assignments:o.assignments,layoutOrder:o.layoutOrder,slots:o.slots,personaAttributes:{persona:o.persona,confidence:(0,_.confidenceBand)(o.confidence)}})}function Pe(){for(let t of Object.keys(k()))I(t);let e=window;delete e.__sentient_layout_override,delete e.__sentient_slot_overrides,delete document.documentElement.dataset.sentientPersona,delete document.documentElement.dataset.sentientConfidence;try{let t=[];for(let o=0;o<localStorage.length;o++){let r=localStorage.key(o);r&&r.startsWith(Q.SNAPSHOT_STORAGE_KEY_PREFIX)&&t.push(r)}for(let o of t)localStorage.removeItem(o)}catch(t){}g(!1),u();try{window.location.reload()}catch(t){}}var f=e=>({padding:"2px 8px",borderRadius:4,border:"1px solid #444",background:e?"#3b82f6":"#222",color:"#eee",cursor:"pointer"});function Ae({size:e=26}={}){return(0,i.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",children:[(0,i.jsx)("path",{d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M10 22H17",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round"}),(0,i.jsx)("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})]})}function Le({apiKey:e}={}){var M;let[t,o]=(0,c.useState)(!1),[r,a]=(0,c.useState)(null),[v,m]=(0,c.useState)(!1),[,y]=(0,c.useReducer)(n=>n+1,0);if((0,c.useSyncExternalStore)(H,Y,()=>0),(0,c.useEffect)(()=>m(!0),[]),Re||!v)return null;let w=(M=$())!=null?M:{apiKey:e!=null?e:"",apiBaseUrl:Oe,isLocal:!1},ne=w.isLocal||!w.apiKey,R=O(),E=A(),P=k(),N=C();function V(){Object.keys(k()).length===0&&Object.keys(C()).length===0&&g(!1)}function oe(n,s){D(n,s),g(!0),u(),y()}function ie(n){I(n),V(),u(),y()}function re(n,s){B(n,s),g(!0),u(),y()}function se(n,s,l,b){let p=C()[n],j=p&&typeof p=="object"?d({},p):Object.fromEntries(Object.entries(b!=null?b:{}).map(([le,ce])=>[le,ce[0]]));j[s]=l,B(n,j),g(!0),u(),y()}function de(n){J(n),V(),u(),y()}function ae(n){a(n),(ne?Ee(n):Ce(w.apiKey,w.apiBaseUrl,n)).then(y)}return(0,i.jsxs)("div",{style:{position:"fixed",bottom:16,right:16,zIndex:2147483647,fontFamily:"system-ui"},children:[(0,i.jsx)("div",{"aria-hidden":!t,style:{position:"absolute",bottom:52,right:0,transformOrigin:"bottom right",transition:"opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)",opacity:t?1:0,transform:t?"translateY(0) scale(1)":"translateY(6px) scale(.96)",pointerEvents:t?"auto":"none"},children:(0,i.jsxs)("div",{style:{width:300,maxHeight:460,overflowY:"auto",background:"#111",color:"#eee",borderRadius:8,padding:12,boxShadow:"0 8px 30px rgba(0,0,0,.4)",fontSize:12},children:[w.isLocal&&(0,i.jsx)("div",{style:{background:"#1e293b",border:"1px solid #334155",borderRadius:4,padding:"6px 8px",marginBottom:8},children:Z}),(0,i.jsxs)("div",{style:{opacity:.7,marginBottom:8},children:[R.length," component",R.length===1?"":"s"," \xB7 ",X()?"preview \u2014 writing nothing":"live"]}),(0,i.jsxs)("div",{style:{borderBottom:"1px solid #333",paddingBottom:8,marginBottom:8},children:[(0,i.jsx)("div",{style:{opacity:.7,marginBottom:4},children:"Preview persona"}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[_.PERSONAS.map(n=>(0,i.jsx)("button",{onClick:()=>ae(n),style:f(r===n),children:_.PERSONA_DISPLAY[n]},n)),(r!==null||Object.keys(P).length>0||Object.keys(N).length>0)&&(0,i.jsx)("button",{onClick:Pe,style:h(d({},f(!1)),{color:"#aaa"}),children:"Reset"})]})]}),R.length===0&&E.length===0&&(0,i.jsx)("div",{style:{opacity:.6},children:"No components or slots on this page yet."}),R.map(n=>(0,i.jsxs)("div",{style:{borderTop:"1px solid #333",padding:"8px 0"},children:[(0,i.jsxs)("div",{style:{fontWeight:600},children:[n.id,n.goal?` \xB7 goal: ${n.goal}`:""]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[n.variantIds.map(s=>(0,i.jsx)("button",{onClick:()=>oe(n.id,s),style:f(P[n.id]===s),children:s},s)),P[n.id]&&(0,i.jsx)("button",{onClick:()=>ie(n.id),style:h(d({},f(!1)),{color:"#aaa"}),children:"reset"})]})]},n.id)),E.length>0&&(0,i.jsxs)("div",{style:{borderTop:"1px solid #333",paddingTop:8,marginTop:4},children:[(0,i.jsx)("div",{style:{opacity:.7,marginBottom:4},children:"Slots"}),E.map(n=>{let s=N[n.id];return(0,i.jsxs)("div",{style:{padding:"6px 0"},children:[(0,i.jsx)("div",{style:{fontWeight:600},children:n.id}),n.arms&&(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:n.arms.map(l=>(0,i.jsx)("button",{onClick:()=>re(n.id,l),style:f(s===l),children:l},l))}),n.dims&&Object.entries(n.dims).map(([l,b])=>(0,i.jsxs)("div",{style:{marginTop:4},children:[(0,i.jsx)("div",{style:{opacity:.6,fontSize:11},children:l}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:b.map(p=>(0,i.jsx)("button",{onClick:()=>se(n.id,l,p,n.dims),style:f(!!s&&typeof s=="object"&&s[l]===p),children:p},p))})]},l)),s!==void 0&&(0,i.jsx)("button",{onClick:()=>de(n.id),style:h(d({},f(!1)),{color:"#aaa",marginTop:4}),children:"reset"})]},n.id)})]})]})}),(0,i.jsx)("button",{"aria-label":"Sentient DevTools","aria-expanded":t,onClick:()=>o(n=>!n),style:{width:44,height:44,borderRadius:12,border:"1px solid #2a2a2a",background:"#000",display:"flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",boxShadow:"0 6px 18px rgba(0,0,0,.4)"},children:(0,i.jsx)(Ae,{})})]})}0&&(module.exports={AdaptiveDevtools,LOCAL_MODE_DEVTOOLS_BANNER});
2
+ "use strict";"use client";var _e=Object.create;var h=Object.defineProperty,we=Object.defineProperties,be=Object.getOwnPropertyDescriptor,Se=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols,xe=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable;var G=(e,t,o)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))z.call(t,o)&&G(e,o,t[o]);if(U)for(var o of U(t))Re.call(t,o)&&G(e,o,t[o]);return e},_=(e,t)=>we(e,Se(t));var Oe=(e,t)=>{for(var o in t)h(e,o,{get:t[o],enumerable:!0})},H=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of he(t))!z.call(e,l)&&l!==o&&h(e,l,{get:()=>t[l],enumerable:!(s=be(t,l))||s.enumerable});return e};var ke=(e,t,o)=>(o=e!=null?_e(xe(e)):{},H(t||!e||!e.__esModule?h(o,"default",{value:e,enumerable:!0}):o,e)),Ce=e=>H(h({},"__esModule",{value:!0}),e);var Fe={};Oe(Fe,{AdaptiveDevtools:()=>Me,LOCAL_MODE_DEVTOOLS_BANNER:()=>ee});module.exports=Ce(Fe);var c=require("react"),w=require("@sentientui/policy"),Z=require("@sentientui/core");var Ee={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function x(){if(typeof window=="undefined")return Ee;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 O(){return[...x().components.values()]}function W(){return[...x().slots.values()]}function k(){return[...x().sections]}function Y(e){let t=x().listeners;return t.add(e),()=>{t.delete(e)}}function J(){return x().version}function B(){let e=window;return e.__sentient_overrides||(e.__sentient_overrides={}),e.__sentient_overrides}function I(e,t){B()[e]=t}function T(e){delete B()[e]}function C(){return a({},B())}function N(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function V(e,t){N()[e]=t}function K(e){delete N()[e]}function E(){return a({},N())}var Pe={on:!1,listeners:new Set};function X(){if(typeof window=="undefined")return Pe;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function m(e){let t=X();if(t.on!==e){t.on=e;for(let o of t.listeners)o()}}function $(){return X().on}var Ae="sentient:overrides-changed";function p(){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(Ae))}function q(){var e;return typeof window=="undefined"?null:(e=window.__sentient_devtools_config)!=null?e:null}var i=require("react/jsx-runtime"),Q,Le=typeof process!="undefined"&&((Q=process.env)==null?void 0:Q.NODE_ENV)==="production",De="https://api.sentient-ui.com/v1",ee="Local mode \u2014 decisions are simulated; add a key to learn from real traffic";function te(){let e=window.__sentient_layout_override,t=k();return!e||e.length===0?t:[...e,...t.filter(o=>!e.includes(o))]}function We(e,t){let o=te();if(e===t||e<0||t<0||e>=o.length||t>=o.length)return;let s=[...o],[l]=s.splice(e,1);s.splice(t,0,l),window.__sentient_layout_override=s,m(!0),p()}function Be(){delete window.__sentient_layout_override,p()}function ne(e){var o,s;for(let[l,u]of Object.entries((o=e.assignments)!=null?o:{}))I(l,u);let t=window;e.layoutOrder&&e.layoutOrder.length>0&&(t.__sentient_layout_override=e.layoutOrder),e.slots&&(t.__sentient_slot_overrides=a(a({},(s=t.__sentient_slot_overrides)!=null?s:{}),e.slots)),e.personaAttributes&&(document.documentElement.dataset.sentientPersona=e.personaAttributes.persona,document.documentElement.dataset.sentientConfidence=e.personaAttributes.confidence),m(!0),p()}function Ie(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return"devtools-preview"}function oe(){return W().map(e=>a(a({id:e.id},e.arms?{arms:e.arms}:{}),e.dims?{dims:e.dims}:{}))}async function Te(e,t,o){var u;let s=await fetch(`${t}/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({persona:o,sections:k().map(g=>({id:g})),components:O().map(g=>({id:g.id,variantIds:g.variantIds})),slots:oe()})});if(!s.ok)return;let l=await s.json();ne(_(a({},l),{personaAttributes:(u=l.personaAttributes)!=null?u:{persona:o,confidence:"high"}}))}async function Ne(e){let t=await import("@sentientui/core/local");if(!t.LOCAL_ENGINE_AVAILABLE)return;let o=t.createLocalEngine({sessionId:Ie(),forcedPersona:e}).decide({sections:k(),components:O().map(s=>({id:s.id,variantIds:s.variantIds})),slots:oe()});ne({assignments:o.assignments,layoutOrder:o.layoutOrder,slots:o.slots,personaAttributes:{persona:o.persona,confidence:(0,w.confidenceBand)(o.confidence)}})}function Ve(){for(let t of Object.keys(C()))T(t);let e=window;delete e.__sentient_layout_override,delete e.__sentient_slot_overrides,delete document.documentElement.dataset.sentientPersona,delete document.documentElement.dataset.sentientConfidence;try{let t=[];for(let o=0;o<localStorage.length;o++){let s=localStorage.key(o);s&&s.startsWith(Z.SNAPSHOT_STORAGE_KEY_PREFIX)&&t.push(s)}for(let o of t)localStorage.removeItem(o)}catch(t){}m(!1),p();try{window.location.reload()}catch(t){}}var y=e=>({padding:"2px 8px",borderRadius:4,border:"1px solid #444",background:e?"#3b82f6":"#222",color:"#eee",cursor:"pointer"});function je({size:e=26}={}){return(0,i.jsxs)("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",children:[(0,i.jsx)("path",{d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),(0,i.jsx)("path",{d:"M10 22H17",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round"}),(0,i.jsx)("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})]})}function Me({apiKey:e}={}){var M;let[t,o]=(0,c.useState)(!1),[s,l]=(0,c.useState)(null),[u,g]=(0,c.useState)(null),[ie,re]=(0,c.useState)(!1),[,f]=(0,c.useReducer)(n=>n+1,0);if((0,c.useSyncExternalStore)(Y,J,()=>0),(0,c.useEffect)(()=>re(!0),[]),Le||!ie)return null;let b=(M=q())!=null?M:{apiKey:e!=null?e:"",apiBaseUrl:De,isLocal:!1},se=b.isLocal||!b.apiKey,R=O(),P=W(),A=C(),j=E(),L=te(),de=window.__sentient_layout_override!==void 0;function ae(n,r){We(n,r),f()}function le(){Be(),D(),f()}function D(){Object.keys(C()).length===0&&Object.keys(E()).length===0&&window.__sentient_layout_override===void 0&&m(!1)}function ce(n,r){I(n,r),m(!0),p(),f()}function ue(n){T(n),D(),p(),f()}function pe(n,r){V(n,r),m(!0),p(),f()}function ge(n,r,d,S){let v=E()[n],F=v&&typeof v=="object"?a({},v):Object.fromEntries(Object.entries(S!=null?S:{}).map(([me,ye])=>[me,ye[0]]));F[r]=d,V(n,F),m(!0),p(),f()}function fe(n){K(n),D(),p(),f()}function ve(n){l(n),(se?Ne(n):Te(b.apiKey,b.apiBaseUrl,n)).then(f)}return(0,i.jsxs)("div",{style:{position:"fixed",bottom:16,right:16,zIndex:2147483647,fontFamily:"system-ui"},children:[(0,i.jsx)("div",{"aria-hidden":!t,style:{position:"absolute",bottom:52,right:0,transformOrigin:"bottom right",transition:"opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)",opacity:t?1:0,transform:t?"translateY(0) scale(1)":"translateY(6px) scale(.96)",pointerEvents:t?"auto":"none"},children:(0,i.jsxs)("div",{style:{width:300,maxHeight:460,overflowY:"auto",background:"#111",color:"#eee",borderRadius:8,padding:12,boxShadow:"0 8px 30px rgba(0,0,0,.4)",fontSize:12},children:[b.isLocal&&(0,i.jsx)("div",{style:{background:"#1e293b",border:"1px solid #334155",borderRadius:4,padding:"6px 8px",marginBottom:8},children:ee}),(0,i.jsxs)("div",{style:{opacity:.7,marginBottom:8},children:[R.length," component",R.length===1?"":"s"," \xB7 ",$()?"preview \u2014 writing nothing":"live"]}),(0,i.jsxs)("div",{style:{borderBottom:"1px solid #333",paddingBottom:8,marginBottom:8},children:[(0,i.jsx)("div",{style:{opacity:.7,marginBottom:4},children:"Preview persona"}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[w.PERSONAS.map(n=>(0,i.jsx)("button",{onClick:()=>ve(n),style:y(s===n),children:w.PERSONA_DISPLAY[n]},n)),(s!==null||Object.keys(A).length>0||Object.keys(j).length>0)&&(0,i.jsx)("button",{onClick:Ve,style:_(a({},y(!1)),{color:"#aaa"}),children:"Reset"})]})]}),L.length>0&&(0,i.jsxs)("div",{style:{borderBottom:"1px solid #333",paddingBottom:8,marginBottom:8},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[(0,i.jsx)("span",{style:{opacity:.7},children:"Layout \u2014 drag to reorder"}),de&&(0,i.jsx)("button",{"aria-label":"Reset section order",onClick:le,style:_(a({},y(!1)),{color:"#aaa"}),children:"reset"})]}),(0,i.jsx)("ul",{"aria-label":"Section order",style:{listStyle:"none",margin:0,padding:0},children:L.map((n,r)=>(0,i.jsxs)("li",{draggable:!0,onDragStart:()=>g(r),onDragOver:d=>d.preventDefault(),onDrop:d=>{d.preventDefault(),u!==null&&ae(u,r),g(null)},onDragEnd:()=>g(null),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 6px",marginBottom:2,borderRadius:4,border:"1px solid #262626",cursor:"grab",background:u===r?"#1e293b":"#181818",opacity:u!==null&&u!==r?.6:1},children:[(0,i.jsx)("span",{style:{opacity:.4,minWidth:10,fontVariantNumeric:"tabular-nums"},children:r+1}),(0,i.jsx)("span",{"aria-hidden":"true",style:{opacity:.35},children:"\u283F"}),(0,i.jsx)("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]},n))})]}),R.length===0&&P.length===0&&L.length===0&&(0,i.jsx)("div",{style:{opacity:.6},children:"No components, sections or slots on this page yet."}),R.map(n=>(0,i.jsxs)("div",{style:{borderTop:"1px solid #333",padding:"8px 0"},children:[(0,i.jsxs)("div",{style:{fontWeight:600},children:[n.id,n.goal?` \xB7 goal: ${n.goal}`:""]}),(0,i.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[n.variantIds.map(r=>(0,i.jsx)("button",{onClick:()=>ce(n.id,r),style:y(A[n.id]===r),children:r},r)),A[n.id]&&(0,i.jsx)("button",{onClick:()=>ue(n.id),style:_(a({},y(!1)),{color:"#aaa"}),children:"reset"})]})]},n.id)),P.length>0&&(0,i.jsxs)("div",{style:{borderTop:"1px solid #333",paddingTop:8,marginTop:4},children:[(0,i.jsx)("div",{style:{opacity:.7,marginBottom:4},children:"Slots"}),P.map(n=>{let r=j[n.id];return(0,i.jsxs)("div",{style:{padding:"6px 0"},children:[(0,i.jsx)("div",{style:{fontWeight:600},children:n.id}),n.arms&&(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:n.arms.map(d=>(0,i.jsx)("button",{onClick:()=>pe(n.id,d),style:y(r===d),children:d},d))}),n.dims&&Object.entries(n.dims).map(([d,S])=>(0,i.jsxs)("div",{style:{marginTop:4},children:[(0,i.jsx)("div",{style:{opacity:.6,fontSize:11},children:d}),(0,i.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:S.map(v=>(0,i.jsx)("button",{onClick:()=>ge(n.id,d,v,n.dims),style:y(!!r&&typeof r=="object"&&r[d]===v),children:v},v))})]},d)),r!==void 0&&(0,i.jsx)("button",{onClick:()=>fe(n.id),style:_(a({},y(!1)),{color:"#aaa",marginTop:4}),children:"reset"})]},n.id)})]})]})}),(0,i.jsx)("button",{"aria-label":"Sentient DevTools","aria-expanded":t,onClick:()=>o(n=>!n),style:{width:44,height:44,borderRadius:12,border:"1px solid #2a2a2a",background:"#000",display:"flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",boxShadow:"0 6px 18px rgba(0,0,0,.4)"},children:(0,i.jsx)(je,{})})]})}0&&(module.exports={AdaptiveDevtools,LOCAL_MODE_DEVTOOLS_BANNER});
3
3
  //# sourceMappingURL=devtools.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/devtools/index.tsx","../src/devtools-registry.ts","../src/devtools-overrides.ts","../src/devtools-slot-overrides.ts","../src/preview-mode.ts","../src/override-events.ts","../src/devtools-config.ts"],"sourcesContent":["'use client';\nimport { useEffect, useReducer, useState, useSyncExternalStore, type CSSProperties } from 'react';\nimport { PERSONAS, PERSONA_DISPLAY, confidenceBand } from '@sentientui/policy';\nimport { SNAPSHOT_STORAGE_KEY_PREFIX } from '@sentientui/core';\nimport {\n getRegistered,\n getRegisteredSlots,\n getRegisteredSections,\n subscribeRegistry,\n getRegistryVersion,\n type RegisteredSlot,\n} from '../devtools-registry.js';\nimport { setVariantOverride, clearVariantOverride, getOverrides } from '../devtools-overrides.js';\nimport { setSlotOverride, clearSlotOverride, getSlotOverrides } from '../devtools-slot-overrides.js';\nimport { setPreviewMode, getPreviewMode } from '../preview-mode.js';\nimport { notifyOverridesChanged } from '../override-events.js';\nimport { readDevtoolsConfig, type DevtoolsConfig } from '../devtools-config.js';\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\nconst IS_PROD = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport const LOCAL_MODE_DEVTOOLS_BANNER =\n 'Local mode — decisions are simulated; add a key to learn from real traffic';\n\ntype OutcomeToApply = {\n assignments?: Record<string, string>;\n layoutOrder?: string[] | null;\n slots?: Record<string, string | Record<string, string>>;\n personaAttributes?: { persona: string; confidence: 'low' | 'medium' | 'high' };\n};\n\ntype OverrideWindow = Window & {\n __sentient_layout_override?: string[];\n __sentient_slot_overrides?: Record<string, string | Record<string, string>>;\n};\n\n/** Apply a simulated outcome across every surface: variants, layout, slots/tokens, persona attrs. */\nfunction applyOutcome(result: OutcomeToApply): void {\n for (const [id, variantId] of Object.entries(result.assignments ?? {})) {\n setVariantOverride(id, variantId);\n }\n const w = window as unknown as OverrideWindow;\n if (result.layoutOrder && result.layoutOrder.length > 0) {\n w.__sentient_layout_override = result.layoutOrder;\n }\n if (result.slots) {\n w.__sentient_slot_overrides = { ...(w.__sentient_slot_overrides ?? {}), ...result.slots };\n }\n if (result.personaAttributes) {\n document.documentElement.dataset.sentientPersona = result.personaAttributes.persona;\n document.documentElement.dataset.sentientConfidence = result.personaAttributes.confidence;\n }\n setPreviewMode(true); // suppress events while previewing\n notifyOverridesChanged(); // re-render layout/slot consumers\n}\n\nfunction readSessionId(): string {\n try {\n const match = document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);\n if (match) return decodeURIComponent(match[1]);\n } catch {\n /* ignore */\n }\n return 'devtools-preview';\n}\n\nfunction slotDecls(): Array<{ id: string; arms?: string[]; dims?: RegisteredSlot['dims'] }> {\n return getRegisteredSlots().map((s) => ({\n id: s.id,\n ...(s.arms ? { arms: s.arms } : {}),\n ...(s.dims ? { dims: s.dims } : {}),\n }));\n}\n\n/** Keyed mode: simulate via /v1/explain (read-only, event-free). */\nasync function forcePersonaKeyed(apiKey: string, apiBaseUrl: string, persona: string): Promise<void> {\n const res = await fetch(`${apiBaseUrl}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({\n persona,\n sections: getRegisteredSections().map((id) => ({ id })),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n }),\n });\n if (!res.ok) return;\n const data = (await res.json()) as OutcomeToApply;\n applyOutcome({\n ...data,\n personaAttributes: data.personaAttributes ?? { persona, confidence: 'high' },\n });\n}\n\n/** Local mode: simulate via the deterministic local engine — zero network. */\nasync function forcePersonaLocal(persona: string): Promise<void> {\n const mod = await import('@sentientui/core/local');\n if (!mod.LOCAL_ENGINE_AVAILABLE) return;\n const outcome = mod\n .createLocalEngine({ sessionId: readSessionId(), forcedPersona: persona })\n .decide({\n sections: getRegisteredSections(),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n });\n applyOutcome({\n assignments: outcome.assignments,\n layoutOrder: outcome.layoutOrder,\n slots: outcome.slots,\n personaAttributes: {\n persona: outcome.persona,\n confidence: confidenceBand(outcome.confidence),\n },\n });\n}\n\n/** Reset: clear the decision snapshot + every override, then reload to re-decide. */\nfunction resetAll(): void {\n for (const id of Object.keys(getOverrides())) clearVariantOverride(id);\n const w = window as unknown as OverrideWindow;\n delete w.__sentient_layout_override;\n delete w.__sentient_slot_overrides;\n delete document.documentElement.dataset.sentientPersona;\n delete document.documentElement.dataset.sentientConfidence;\n try {\n const stale: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(SNAPSHOT_STORAGE_KEY_PREFIX)) stale.push(key);\n }\n for (const key of stale) localStorage.removeItem(key);\n } catch {\n /* ignore */\n }\n setPreviewMode(false);\n notifyOverridesChanged();\n try {\n window.location.reload();\n } catch {\n /* jsdom */\n }\n}\n\nconst btn = (active: boolean): CSSProperties => ({\n padding: '2px 8px',\n borderRadius: 4,\n border: '1px solid #444',\n background: active ? '#3b82f6' : '#222',\n color: '#eee',\n cursor: 'pointer',\n});\n\n/** Sentient \"S.\" wordmark, monoline — white strokes for the black launcher button. */\nfunction SentientMark({ size = 26 }: { size?: number } = {}): JSX.Element {\n return (\n <svg width={size} height={size} viewBox=\"0 0 32 32\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6\"\n stroke=\"#fff\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path d=\"M10 22H17\" stroke=\"#fff\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n <circle cx=\"20.6\" cy=\"22\" r=\"2.1\" fill=\"#fff\" />\n </svg>\n );\n}\n\nexport function AdaptiveDevtools({ apiKey }: { apiKey?: string } = {}): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const [activePersona, setActivePersona] = useState<string | null>(null);\n const [mounted, setMounted] = useState(false);\n const [, force] = useReducer((n: number) => n + 1, 0);\n // Re-render when the component/slot registry changes. useSyncExternalStore\n // (not a manual useEffect subscription) so the subscription can't go stale\n // across Next Fast Refresh — a stale listener was why the panel needed a hard\n // refresh to pick up a renamed id.\n useSyncExternalStore(subscribeRegistry, getRegistryVersion, () => 0);\n // Client-mount gate: render nothing during SSR / the first paint so the widget\n // never reads `window` on the server. Lets consumers drop `<AdaptiveDevtools/>`\n // straight into a tree without a `dynamic(..., { ssr: false })` wrapper.\n useEffect(() => setMounted(true), []);\n\n // Never render in production, even if imported by mistake. (Hooks run first\n // so the rules of hooks hold regardless of these early returns.)\n if (IS_PROD) return null;\n if (!mounted) return null;\n\n const config: DevtoolsConfig = readDevtoolsConfig() ?? {\n apiKey: apiKey ?? '',\n apiBaseUrl: DEFAULT_API_BASE_URL,\n isLocal: false,\n };\n const useLocalEngine = config.isLocal || !config.apiKey;\n const components = getRegistered();\n const slots = getRegisteredSlots();\n const overrides = getOverrides();\n const slotOverrides = getSlotOverrides();\n\n // Preview mode stays on while ANY override (variant or slot) is active.\n function maybeExitPreview(): void {\n if (Object.keys(getOverrides()).length === 0 && Object.keys(getSlotOverrides()).length === 0) {\n setPreviewMode(false);\n }\n }\n\n function choose(id: string, variantId: string): void {\n setVariantOverride(id, variantId);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetVariant(id: string): void {\n clearVariantOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function chooseSlotArm(id: string, arm: string): void {\n setSlotOverride(id, arm);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function chooseSlotDim(id: string, dim: string, value: string, dims: RegisteredSlot['dims']): void {\n const current = getSlotOverrides()[id];\n // Merge onto the existing forced object, or seed from each dim's baseline\n // (first value) so unset dims stay at baseline instead of vanishing.\n const next: Record<string, string> =\n current && typeof current === 'object'\n ? { ...current }\n : Object.fromEntries(Object.entries(dims ?? {}).map(([d, values]) => [d, values[0]!]));\n next[dim] = value;\n setSlotOverride(id, next);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetSlot(id: string): void {\n clearSlotOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function choosePersona(persona: string): void {\n setActivePersona(persona);\n const apply = useLocalEngine\n ? forcePersonaLocal(persona)\n : forcePersonaKeyed(config.apiKey, config.apiBaseUrl, persona);\n void apply.then(force);\n }\n\n return (\n <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 2147483647, fontFamily: 'system-ui' }}>\n {/* Panel stays mounted and animates in/out from the button's corner, so the\n launcher below never shifts. transform-origin is the button (bottom-right). */}\n <div\n aria-hidden={!open}\n style={{\n position: 'absolute',\n bottom: 52,\n right: 0,\n transformOrigin: 'bottom right',\n transition: 'opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)',\n opacity: open ? 1 : 0,\n transform: open ? 'translateY(0) scale(1)' : 'translateY(6px) scale(.96)',\n pointerEvents: open ? 'auto' : 'none',\n }}\n >\n <div style={{ width: 300, maxHeight: 460, overflowY: 'auto', background: '#111', color: '#eee',\n borderRadius: 8, padding: 12, boxShadow: '0 8px 30px rgba(0,0,0,.4)', fontSize: 12 }}>\n {config.isLocal && (\n <div style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4,\n padding: '6px 8px', marginBottom: 8 }}>\n {LOCAL_MODE_DEVTOOLS_BANNER}\n </div>\n )}\n <div style={{ opacity: .7, marginBottom: 8 }}>\n {components.length} component{components.length === 1 ? '' : 's'} · {getPreviewMode() ? 'preview — writing nothing' : 'live'}\n </div>\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Preview persona</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {PERSONAS.map((p) => (\n <button key={p} onClick={() => choosePersona(p)} style={btn(activePersona === p)}>\n {PERSONA_DISPLAY[p]}\n </button>\n ))}\n {(activePersona !== null || Object.keys(overrides).length > 0 || Object.keys(slotOverrides).length > 0) && (\n <button onClick={resetAll} style={{ ...btn(false), color: '#aaa' }}>\n Reset\n </button>\n )}\n </div>\n </div>\n {components.length === 0 && slots.length === 0 && (\n <div style={{ opacity: .6 }}>No components or slots on this page yet.</div>\n )}\n {components.map((c) => (\n <div key={c.id} style={{ borderTop: '1px solid #333', padding: '8px 0' }}>\n <div style={{ fontWeight: 600 }}>{c.id}{c.goal ? ` · goal: ${c.goal}` : ''}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {c.variantIds.map((v) => (\n <button key={v} onClick={() => choose(c.id, v)} style={btn(overrides[c.id] === v)}>\n {v}\n </button>\n ))}\n {overrides[c.id] && (\n <button onClick={() => resetVariant(c.id)} style={{ ...btn(false), color: '#aaa' }}>\n reset\n </button>\n )}\n </div>\n </div>\n ))}\n {slots.length > 0 && (\n <div style={{ borderTop: '1px solid #333', paddingTop: 8, marginTop: 4 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Slots</div>\n {slots.map((s) => {\n const ov = slotOverrides[s.id];\n return (\n <div key={s.id} style={{ padding: '6px 0' }}>\n <div style={{ fontWeight: 600 }}>{s.id}</div>\n {s.arms && (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {s.arms.map((arm) => (\n <button key={arm} onClick={() => chooseSlotArm(s.id, arm)} style={btn(ov === arm)}>\n {arm}\n </button>\n ))}\n </div>\n )}\n {s.dims && Object.entries(s.dims).map(([dim, values]) => (\n <div key={dim} style={{ marginTop: 4 }}>\n <div style={{ opacity: .6, fontSize: 11 }}>{dim}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {values.map((v) => (\n <button\n key={v}\n onClick={() => chooseSlotDim(s.id, dim, v, s.dims)}\n style={btn(!!ov && typeof ov === 'object' && ov[dim] === v)}\n >\n {v}\n </button>\n ))}\n </div>\n </div>\n ))}\n {ov !== undefined && (\n <button onClick={() => resetSlot(s.id)} style={{ ...btn(false), color: '#aaa', marginTop: 4 }}>\n reset\n </button>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n <button\n aria-label=\"Sentient DevTools\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n style={{ width: 44, height: 44, borderRadius: 12, border: '1px solid #2a2a2a', background: '#000',\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 0,\n cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,0,0,.4)' }}\n >\n <SentientMark />\n </button>\n </div>\n );\n}\n","import { isDevBuild } from './adaptive-shared.js';\n\nexport type RegisteredComponent = { id: string; variantIds: string[]; goal?: string };\nexport type RegisteredSlot = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n};\n\ntype RegistryState = {\n components: Map<string, RegisteredComponent>;\n slots: Map<string, RegisteredSlot>;\n sections: string[];\n listeners: Set<() => void>;\n /** Bumped on every mutation so `useSyncExternalStore` can read a stable, comparable snapshot. */\n version: number;\n};\n\n// Shared through a window global: the main entry and the /devtools entry are\n// separate bundles, each with its own copy of this module — module-local\n// state would give the devtools an always-empty registry in published apps.\nconst ssrFallback: RegistryState = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n};\n\nfunction state(): RegistryState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_registry?: RegistryState };\n if (!w.__sentient_registry) {\n w.__sentient_registry = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n };\n }\n return w.__sentient_registry;\n}\n\nfunction emit(): void {\n // Bump BEFORE notifying so a useSyncExternalStore consumer re-reading its\n // snapshot inside the notification sees the new value and re-renders.\n state().version += 1;\n for (const fn of state().listeners) fn();\n}\n\n// The registry exists solely to feed the opt-in devtools panel, which is a\n// dev-only surface. In a production build there is no panel reading it, so\n// every register call is dead work plus a `window.__sentient_registry`\n// footprint on the customer's page. Short-circuit to a noop in production —\n// every <Adaptive>/useAdaptive/slot mount calls one of these.\nconst NOOP_UNREGISTER = (): void => undefined;\n\n/** Register (or re-register) a component. Returns an unregister function. */\nexport function registerComponent(c: RegisteredComponent): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().components.set(c.id, c);\n emit();\n return () => {\n state().components.delete(c.id);\n emit();\n };\n}\n\n/** Register (or re-register) a slot declaration. Returns an unregister function. */\nexport function registerSlot(s: RegisteredSlot): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().slots.set(s.id, s);\n emit();\n return () => {\n state().slots.delete(s.id);\n emit();\n };\n}\n\n/** Register the page's declared section ids (from AdaptiveRoot/provider). */\nexport function registerSections(sections: string[]): void {\n if (!isDevBuild()) return;\n state().sections = [...sections];\n emit();\n}\n\nexport function getRegistered(): RegisteredComponent[] {\n return [...state().components.values()];\n}\n\nexport function getRegisteredSlots(): RegisteredSlot[] {\n return [...state().slots.values()];\n}\n\nexport function getRegisteredSections(): string[] {\n return [...state().sections];\n}\n\nexport function subscribeRegistry(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/** Monotonic snapshot for `useSyncExternalStore` — changes on every registry mutation. */\nexport function getRegistryVersion(): number {\n return state().version;\n}\n","function store(): Record<string, string> {\n const w = window as unknown as { __sentient_overrides?: Record<string, string> };\n if (!w.__sentient_overrides) w.__sentient_overrides = {};\n return w.__sentient_overrides;\n}\n\n/** Force `componentId` to render `variantId` — read by `useAssignment`. */\nexport function setVariantOverride(componentId: string, variantId: string): void {\n store()[componentId] = variantId;\n}\n\nexport function clearVariantOverride(componentId: string): void {\n delete store()[componentId];\n}\n\nexport function getOverrides(): Record<string, string> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n assign: (componentId, variantIds, agentData, agentDataByVariant) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","/** Provider → devtools config handoff. Window-backed: the /devtools entry is a\n * separate bundle and cannot share the provider's React context instance. */\nexport type DevtoolsConfig = {\n apiKey: string;\n apiBaseUrl: string;\n isLocal: boolean;\n};\n\ntype ConfigWindow = Window & { __sentient_devtools_config?: DevtoolsConfig };\n\nexport function publishDevtoolsConfig(config: DevtoolsConfig): void {\n if (typeof window === 'undefined') return;\n (window as ConfigWindow).__sentient_devtools_config = config;\n}\n\nexport function readDevtoolsConfig(): DevtoolsConfig | null {\n if (typeof window === 'undefined') return null;\n return (window as ConfigWindow).__sentient_devtools_config ?? null;\n}\n"],"mappings":";+6BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,sBAAAE,GAAA,+BAAAC,IAAA,eAAAC,GAAAJ,IACA,IAAAK,EAA0F,iBAC1FC,EAA0D,8BAC1DC,EAA4C,4BCkB5C,IAAMC,GAA6B,CACjC,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,EAEA,SAASC,GAAuB,CAC9B,GAAI,OAAO,QAAW,YAAa,OAAOD,GAC1C,IAAME,EAAI,OACV,OAAKA,EAAE,sBACLA,EAAE,oBAAsB,CACtB,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,GAEKA,EAAE,mBACX,CA6CO,SAASC,GAAuC,CACrD,MAAO,CAAC,GAAGC,EAAM,EAAE,WAAW,OAAO,CAAC,CACxC,CAEO,SAASC,GAAuC,CACrD,MAAO,CAAC,GAAGD,EAAM,EAAE,MAAM,OAAO,CAAC,CACnC,C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Z,CAaV,CACD,EACAa,IAAO,WACN,OAAC,UAAO,QAAS,IAAMN,GAAUzD,EAAE,EAAE,EAAG,MAAOU,EAAAjB,EAAA,GAAK4B,EAAI,EAAK,GAAd,CAAiB,MAAO,OAAQ,UAAW,CAAE,GAAG,iBAE/F,IA9BMrB,EAAE,EAgCZ,CAEJ,CAAC,GACH,GAEJ,EACF,KACA,OAAC,UACC,aAAW,oBACX,gBAAe0B,EACf,QAAS,IAAMC,EAASqC,GAAM,CAACA,CAAC,EAChC,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,aAAc,GAAI,OAAQ,oBAAqB,WAAY,OAClF,QAAS,OAAQ,WAAY,SAAU,eAAgB,SAAU,QAAS,EAC1E,OAAQ,UAAW,UAAW,2BAA4B,EAEnE,mBAACzC,GAAA,EAAa,EAChB,GACF,CAEJ","names":["devtools_exports","__export","AdaptiveDevtools","LOCAL_MODE_DEVTOOLS_BANNER","__toCommonJS","import_react","import_policy","import_core","ssrFallback","state","w","getRegistered","state","getRegisteredSlots","getRegisteredSections","subscribeRegistry","fn","listeners","getRegistryVersion","store","w","setVariantOverride","componentId","variantId","clearVariantOverride","getOverrides","__spreadValues","store","w","setSlotOverride","slotId","result","clearSlotOverride","getSlotOverrides","__spreadValues","ssrFallback","state","w","setPreviewMode","on","s","fn","getPreviewMode","EVENT","notifyOverridesChanged","_a","w","EVENT","readDevtoolsConfig","_a","import_jsx_runtime","_a","IS_PROD","DEFAULT_API_BASE_URL","LOCAL_MODE_DEVTOOLS_BANNER","applyOutcome","result","_b","id","variantId","setVariantOverride","w","__spreadValues","setPreviewMode","notifyOverridesChanged","readSessionId","match","slotDecls","getRegisteredSlots","s","forcePersonaKeyed","apiKey","apiBaseUrl","persona","res","getRegisteredSections","getRegistered","c","data","__spreadProps","forcePersonaLocal","mod","outcome","resetAll","getOverrides","clearVariantOverride","stale","i","key","e","btn","active","SentientMark","size","AdaptiveDevtools","open","setOpen","activePersona","setActivePersona","mounted","setMounted","force","subscribeRegistry","getRegistryVersion","config","readDevtoolsConfig","useLocalEngine","components","slots","overrides","slotOverrides","getSlotOverrides","maybeExitPreview","choose","resetVariant","chooseSlotArm","arm","setSlotOverride","chooseSlotDim","dim","value","dims","current","next","d","values","resetSlot","clearSlotOverride","choosePersona","getPreviewMode","p","v","ov","o"]}
1
+ {"version":3,"sources":["../src/devtools/index.tsx","../src/devtools-registry.ts","../src/devtools-overrides.ts","../src/devtools-slot-overrides.ts","../src/preview-mode.ts","../src/override-events.ts","../src/devtools-config.ts"],"sourcesContent":["'use client';\nimport { useEffect, useReducer, useState, useSyncExternalStore, type CSSProperties } from 'react';\nimport { PERSONAS, PERSONA_DISPLAY, confidenceBand } from '@sentientui/policy';\nimport { SNAPSHOT_STORAGE_KEY_PREFIX } from '@sentientui/core';\nimport {\n getRegistered,\n getRegisteredSlots,\n getRegisteredSections,\n subscribeRegistry,\n getRegistryVersion,\n type RegisteredSlot,\n} from '../devtools-registry.js';\nimport { setVariantOverride, clearVariantOverride, getOverrides } from '../devtools-overrides.js';\nimport { setSlotOverride, clearSlotOverride, getSlotOverrides } from '../devtools-slot-overrides.js';\nimport { setPreviewMode, getPreviewMode } from '../preview-mode.js';\nimport { notifyOverridesChanged } from '../override-events.js';\nimport { readDevtoolsConfig, type DevtoolsConfig } from '../devtools-config.js';\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\nconst IS_PROD = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport const LOCAL_MODE_DEVTOOLS_BANNER =\n 'Local mode — decisions are simulated; add a key to learn from real traffic';\n\ntype OutcomeToApply = {\n assignments?: Record<string, string>;\n layoutOrder?: string[] | null;\n slots?: Record<string, string | Record<string, string>>;\n personaAttributes?: { persona: string; confidence: 'low' | 'medium' | 'high' };\n};\n\ntype OverrideWindow = Window & {\n __sentient_layout_override?: string[];\n __sentient_slot_overrides?: Record<string, string | Record<string, string>>;\n};\n\n/** The order the page is rendering: a previewed override, else what was registered. */\nfunction currentLayout(): string[] {\n const forced = (window as unknown as OverrideWindow).__sentient_layout_override;\n const registered = getRegisteredSections();\n if (!forced || forced.length === 0) return registered;\n // Registered ids the override omits still render (useLayoutOrder returns the\n // override verbatim, and the app maps whatever ids it is given), so show them\n // trailing rather than dropping them from the list you are dragging.\n return [...forced, ...registered.filter((id) => !forced.includes(id))];\n}\n\n/**\n * Move `from` to `to` within the current order and preview it.\n *\n * Writes the whole order rather than swapping neighbours: the point is to try an\n * arrangement, not to walk one block up a list one press at a time.\n */\nfunction reorderLayout(from: number, to: number): void {\n const order = currentLayout();\n if (from === to || from < 0 || to < 0 || from >= order.length || to >= order.length) return;\n const next = [...order];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved!);\n (window as unknown as OverrideWindow).__sentient_layout_override = next;\n setPreviewMode(true); // an arrangement you are trying must not train the bandit\n notifyOverridesChanged();\n}\n\nfunction resetLayout(): void {\n delete (window as unknown as OverrideWindow).__sentient_layout_override;\n notifyOverridesChanged();\n}\n\n/** Apply a simulated outcome across every surface: variants, layout, slots/tokens, persona attrs. */\nfunction applyOutcome(result: OutcomeToApply): void {\n for (const [id, variantId] of Object.entries(result.assignments ?? {})) {\n setVariantOverride(id, variantId);\n }\n const w = window as unknown as OverrideWindow;\n if (result.layoutOrder && result.layoutOrder.length > 0) {\n w.__sentient_layout_override = result.layoutOrder;\n }\n if (result.slots) {\n w.__sentient_slot_overrides = { ...(w.__sentient_slot_overrides ?? {}), ...result.slots };\n }\n if (result.personaAttributes) {\n document.documentElement.dataset.sentientPersona = result.personaAttributes.persona;\n document.documentElement.dataset.sentientConfidence = result.personaAttributes.confidence;\n }\n setPreviewMode(true); // suppress events while previewing\n notifyOverridesChanged(); // re-render layout/slot consumers\n}\n\nfunction readSessionId(): string {\n try {\n const match = document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);\n if (match) return decodeURIComponent(match[1]);\n } catch {\n /* ignore */\n }\n return 'devtools-preview';\n}\n\nfunction slotDecls(): Array<{ id: string; arms?: string[]; dims?: RegisteredSlot['dims'] }> {\n return getRegisteredSlots().map((s) => ({\n id: s.id,\n ...(s.arms ? { arms: s.arms } : {}),\n ...(s.dims ? { dims: s.dims } : {}),\n }));\n}\n\n/** Keyed mode: simulate via /v1/explain (read-only, event-free). */\nasync function forcePersonaKeyed(apiKey: string, apiBaseUrl: string, persona: string): Promise<void> {\n const res = await fetch(`${apiBaseUrl}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({\n persona,\n sections: getRegisteredSections().map((id) => ({ id })),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n }),\n });\n if (!res.ok) return;\n const data = (await res.json()) as OutcomeToApply;\n applyOutcome({\n ...data,\n personaAttributes: data.personaAttributes ?? { persona, confidence: 'high' },\n });\n}\n\n/** Local mode: simulate via the deterministic local engine — zero network. */\nasync function forcePersonaLocal(persona: string): Promise<void> {\n const mod = await import('@sentientui/core/local');\n if (!mod.LOCAL_ENGINE_AVAILABLE) return;\n const outcome = mod\n .createLocalEngine({ sessionId: readSessionId(), forcedPersona: persona })\n .decide({\n sections: getRegisteredSections(),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n });\n applyOutcome({\n assignments: outcome.assignments,\n layoutOrder: outcome.layoutOrder,\n slots: outcome.slots,\n personaAttributes: {\n persona: outcome.persona,\n confidence: confidenceBand(outcome.confidence),\n },\n });\n}\n\n/** Reset: clear the decision snapshot + every override, then reload to re-decide. */\nfunction resetAll(): void {\n for (const id of Object.keys(getOverrides())) clearVariantOverride(id);\n const w = window as unknown as OverrideWindow;\n delete w.__sentient_layout_override;\n delete w.__sentient_slot_overrides;\n delete document.documentElement.dataset.sentientPersona;\n delete document.documentElement.dataset.sentientConfidence;\n try {\n const stale: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(SNAPSHOT_STORAGE_KEY_PREFIX)) stale.push(key);\n }\n for (const key of stale) localStorage.removeItem(key);\n } catch {\n /* ignore */\n }\n setPreviewMode(false);\n notifyOverridesChanged();\n try {\n window.location.reload();\n } catch {\n /* jsdom */\n }\n}\n\nconst btn = (active: boolean): CSSProperties => ({\n padding: '2px 8px',\n borderRadius: 4,\n border: '1px solid #444',\n background: active ? '#3b82f6' : '#222',\n color: '#eee',\n cursor: 'pointer',\n});\n\n/** Sentient \"S.\" wordmark, monoline — white strokes for the black launcher button. */\nfunction SentientMark({ size = 26 }: { size?: number } = {}): JSX.Element {\n return (\n <svg width={size} height={size} viewBox=\"0 0 32 32\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6\"\n stroke=\"#fff\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path d=\"M10 22H17\" stroke=\"#fff\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n <circle cx=\"20.6\" cy=\"22\" r=\"2.1\" fill=\"#fff\" />\n </svg>\n );\n}\n\nexport function AdaptiveDevtools({ apiKey }: { apiKey?: string } = {}): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const [activePersona, setActivePersona] = useState<string | null>(null);\n const [dragFrom, setDragFrom] = useState<number | null>(null);\n const [mounted, setMounted] = useState(false);\n const [, force] = useReducer((n: number) => n + 1, 0);\n // Re-render when the component/slot registry changes. useSyncExternalStore\n // (not a manual useEffect subscription) so the subscription can't go stale\n // across Next Fast Refresh — a stale listener was why the panel needed a hard\n // refresh to pick up a renamed id.\n useSyncExternalStore(subscribeRegistry, getRegistryVersion, () => 0);\n // Client-mount gate: render nothing during SSR / the first paint so the widget\n // never reads `window` on the server. Lets consumers drop `<AdaptiveDevtools/>`\n // straight into a tree without a `dynamic(..., { ssr: false })` wrapper.\n useEffect(() => setMounted(true), []);\n\n // Never render in production, even if imported by mistake. (Hooks run first\n // so the rules of hooks hold regardless of these early returns.)\n if (IS_PROD) return null;\n if (!mounted) return null;\n\n const config: DevtoolsConfig = readDevtoolsConfig() ?? {\n apiKey: apiKey ?? '',\n apiBaseUrl: DEFAULT_API_BASE_URL,\n isLocal: false,\n };\n const useLocalEngine = config.isLocal || !config.apiKey;\n const components = getRegistered();\n const slots = getRegisteredSlots();\n const overrides = getOverrides();\n const slotOverrides = getSlotOverrides();\n const sections = currentLayout();\n const layoutForced = (window as unknown as OverrideWindow).__sentient_layout_override !== undefined;\n\n function onReorder(from: number, to: number): void {\n reorderLayout(from, to);\n force();\n }\n function onResetLayout(): void {\n resetLayout();\n maybeExitPreview();\n force();\n }\n\n // Preview mode stays on while ANY override (variant, slot or layout) is\n // active. Omitting layout here let clearing the last variant re-enable event\n // recording while a previewed section order was still on screen.\n function maybeExitPreview(): void {\n if (\n Object.keys(getOverrides()).length === 0 &&\n Object.keys(getSlotOverrides()).length === 0 &&\n (window as unknown as OverrideWindow).__sentient_layout_override === undefined\n ) {\n setPreviewMode(false);\n }\n }\n\n function choose(id: string, variantId: string): void {\n setVariantOverride(id, variantId);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetVariant(id: string): void {\n clearVariantOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function chooseSlotArm(id: string, arm: string): void {\n setSlotOverride(id, arm);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function chooseSlotDim(id: string, dim: string, value: string, dims: RegisteredSlot['dims']): void {\n const current = getSlotOverrides()[id];\n // Merge onto the existing forced object, or seed from each dim's baseline\n // (first value) so unset dims stay at baseline instead of vanishing.\n const next: Record<string, string> =\n current && typeof current === 'object'\n ? { ...current }\n : Object.fromEntries(Object.entries(dims ?? {}).map(([d, values]) => [d, values[0]!]));\n next[dim] = value;\n setSlotOverride(id, next);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetSlot(id: string): void {\n clearSlotOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function choosePersona(persona: string): void {\n setActivePersona(persona);\n const apply = useLocalEngine\n ? forcePersonaLocal(persona)\n : forcePersonaKeyed(config.apiKey, config.apiBaseUrl, persona);\n void apply.then(force);\n }\n\n return (\n <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 2147483647, fontFamily: 'system-ui' }}>\n {/* Panel stays mounted and animates in/out from the button's corner, so the\n launcher below never shifts. transform-origin is the button (bottom-right). */}\n <div\n aria-hidden={!open}\n style={{\n position: 'absolute',\n bottom: 52,\n right: 0,\n transformOrigin: 'bottom right',\n transition: 'opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)',\n opacity: open ? 1 : 0,\n transform: open ? 'translateY(0) scale(1)' : 'translateY(6px) scale(.96)',\n pointerEvents: open ? 'auto' : 'none',\n }}\n >\n <div style={{ width: 300, maxHeight: 460, overflowY: 'auto', background: '#111', color: '#eee',\n borderRadius: 8, padding: 12, boxShadow: '0 8px 30px rgba(0,0,0,.4)', fontSize: 12 }}>\n {config.isLocal && (\n <div style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4,\n padding: '6px 8px', marginBottom: 8 }}>\n {LOCAL_MODE_DEVTOOLS_BANNER}\n </div>\n )}\n <div style={{ opacity: .7, marginBottom: 8 }}>\n {components.length} component{components.length === 1 ? '' : 's'} · {getPreviewMode() ? 'preview — writing nothing' : 'live'}\n </div>\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Preview persona</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {PERSONAS.map((p) => (\n <button key={p} onClick={() => choosePersona(p)} style={btn(activePersona === p)}>\n {PERSONA_DISPLAY[p]}\n </button>\n ))}\n {(activePersona !== null || Object.keys(overrides).length > 0 || Object.keys(slotOverrides).length > 0) && (\n <button onClick={resetAll} style={{ ...btn(false), color: '#aaa' }}>\n Reset\n </button>\n )}\n </div>\n </div>\n {sections.length > 0 && (\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 4 }}>\n <span style={{ opacity: .7 }}>Layout — drag to reorder</span>\n {layoutForced && (\n // Distinct accessible name: the per-variant and per-slot resets\n // below are also labelled \"reset\", and three identical buttons\n // in one panel is ambiguous to a screen reader and to tests.\n <button\n aria-label=\"Reset section order\"\n onClick={onResetLayout}\n style={{ ...btn(false), color: '#aaa' }}\n >\n reset\n </button>\n )}\n </div>\n {/* Drop-on-row inserts at that row's position, so any block can go\n anywhere in one gesture. The whole order is written on each\n drop — see reorderLayout. */}\n <ul aria-label=\"Section order\" style={{ listStyle: 'none', margin: 0, padding: 0 }}>\n {sections.map((id, i) => (\n <li\n key={id}\n draggable\n onDragStart={() => setDragFrom(i)}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => {\n e.preventDefault();\n if (dragFrom !== null) onReorder(dragFrom, i);\n setDragFrom(null);\n }}\n onDragEnd={() => setDragFrom(null)}\n style={{\n display: 'flex', alignItems: 'center', gap: 6, padding: '4px 6px', marginBottom: 2,\n borderRadius: 4, border: '1px solid #262626', cursor: 'grab',\n background: dragFrom === i ? '#1e293b' : '#181818',\n opacity: dragFrom !== null && dragFrom !== i ? .6 : 1,\n }}\n >\n <span style={{ opacity: .4, minWidth: 10, fontVariantNumeric: 'tabular-nums' }}>{i + 1}</span>\n <span aria-hidden=\"true\" style={{ opacity: .35 }}>⠿</span>\n <span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {id}\n </span>\n </li>\n ))}\n </ul>\n </div>\n )}\n {components.length === 0 && slots.length === 0 && sections.length === 0 && (\n <div style={{ opacity: .6 }}>No components, sections or slots on this page yet.</div>\n )}\n {components.map((c) => (\n <div key={c.id} style={{ borderTop: '1px solid #333', padding: '8px 0' }}>\n <div style={{ fontWeight: 600 }}>{c.id}{c.goal ? ` · goal: ${c.goal}` : ''}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {c.variantIds.map((v) => (\n <button key={v} onClick={() => choose(c.id, v)} style={btn(overrides[c.id] === v)}>\n {v}\n </button>\n ))}\n {overrides[c.id] && (\n <button onClick={() => resetVariant(c.id)} style={{ ...btn(false), color: '#aaa' }}>\n reset\n </button>\n )}\n </div>\n </div>\n ))}\n {slots.length > 0 && (\n <div style={{ borderTop: '1px solid #333', paddingTop: 8, marginTop: 4 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Slots</div>\n {slots.map((s) => {\n const ov = slotOverrides[s.id];\n return (\n <div key={s.id} style={{ padding: '6px 0' }}>\n <div style={{ fontWeight: 600 }}>{s.id}</div>\n {s.arms && (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {s.arms.map((arm) => (\n <button key={arm} onClick={() => chooseSlotArm(s.id, arm)} style={btn(ov === arm)}>\n {arm}\n </button>\n ))}\n </div>\n )}\n {s.dims && Object.entries(s.dims).map(([dim, values]) => (\n <div key={dim} style={{ marginTop: 4 }}>\n <div style={{ opacity: .6, fontSize: 11 }}>{dim}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {values.map((v) => (\n <button\n key={v}\n onClick={() => chooseSlotDim(s.id, dim, v, s.dims)}\n style={btn(!!ov && typeof ov === 'object' && ov[dim] === v)}\n >\n {v}\n </button>\n ))}\n </div>\n </div>\n ))}\n {ov !== undefined && (\n <button onClick={() => resetSlot(s.id)} style={{ ...btn(false), color: '#aaa', marginTop: 4 }}>\n reset\n </button>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n <button\n aria-label=\"Sentient DevTools\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n style={{ width: 44, height: 44, borderRadius: 12, border: '1px solid #2a2a2a', background: '#000',\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 0,\n cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,0,0,.4)' }}\n >\n <SentientMark />\n </button>\n </div>\n );\n}\n","import { isDevBuild } from './adaptive-shared.js';\n\nexport type RegisteredComponent = { id: string; variantIds: string[]; goal?: string };\nexport type RegisteredSlot = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n};\n\ntype RegistryState = {\n components: Map<string, RegisteredComponent>;\n slots: Map<string, RegisteredSlot>;\n sections: string[];\n listeners: Set<() => void>;\n /** Bumped on every mutation so `useSyncExternalStore` can read a stable, comparable snapshot. */\n version: number;\n};\n\n// Shared through a window global: the main entry and the /devtools entry are\n// separate bundles, each with its own copy of this module — module-local\n// state would give the devtools an always-empty registry in published apps.\nconst ssrFallback: RegistryState = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n};\n\nfunction state(): RegistryState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_registry?: RegistryState };\n if (!w.__sentient_registry) {\n w.__sentient_registry = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n };\n }\n return w.__sentient_registry;\n}\n\nfunction emit(): void {\n // Bump BEFORE notifying so a useSyncExternalStore consumer re-reading its\n // snapshot inside the notification sees the new value and re-renders.\n state().version += 1;\n for (const fn of state().listeners) fn();\n}\n\n// The registry exists solely to feed the opt-in devtools panel, which is a\n// dev-only surface. In a production build there is no panel reading it, so\n// every register call is dead work plus a `window.__sentient_registry`\n// footprint on the customer's page. Short-circuit to a noop in production —\n// every <Adaptive>/useAdaptive/slot mount calls one of these.\nconst NOOP_UNREGISTER = (): void => undefined;\n\n/** Register (or re-register) a component. Returns an unregister function. */\nexport function registerComponent(c: RegisteredComponent): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().components.set(c.id, c);\n emit();\n return () => {\n state().components.delete(c.id);\n emit();\n };\n}\n\n/** Register (or re-register) a slot declaration. Returns an unregister function. */\nexport function registerSlot(s: RegisteredSlot): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().slots.set(s.id, s);\n emit();\n return () => {\n state().slots.delete(s.id);\n emit();\n };\n}\n\n/** Register the page's declared section ids (from AdaptiveRoot/provider). */\nexport function registerSections(sections: string[]): void {\n if (!isDevBuild()) return;\n state().sections = [...sections];\n emit();\n}\n\nexport function getRegistered(): RegisteredComponent[] {\n return [...state().components.values()];\n}\n\nexport function getRegisteredSlots(): RegisteredSlot[] {\n return [...state().slots.values()];\n}\n\nexport function getRegisteredSections(): string[] {\n return [...state().sections];\n}\n\nexport function subscribeRegistry(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/** Monotonic snapshot for `useSyncExternalStore` — changes on every registry mutation. */\nexport function getRegistryVersion(): number {\n return state().version;\n}\n","function store(): Record<string, string> {\n const w = window as unknown as { __sentient_overrides?: Record<string, string> };\n if (!w.__sentient_overrides) w.__sentient_overrides = {};\n return w.__sentient_overrides;\n}\n\n/** Force `componentId` to render `variantId` — read by `useAssignment`. */\nexport function setVariantOverride(componentId: string, variantId: string): void {\n store()[componentId] = variantId;\n}\n\nexport function clearVariantOverride(componentId: string): void {\n delete store()[componentId];\n}\n\nexport function getOverrides(): Record<string, string> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n assign: (componentId, variantIds, agentData, agentDataByVariant) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","/** Provider → devtools config handoff. Window-backed: the /devtools entry is a\n * separate bundle and cannot share the provider's React context instance. */\nexport type DevtoolsConfig = {\n apiKey: string;\n apiBaseUrl: string;\n isLocal: boolean;\n};\n\ntype ConfigWindow = Window & { __sentient_devtools_config?: DevtoolsConfig };\n\nexport function publishDevtoolsConfig(config: DevtoolsConfig): void {\n if (typeof window === 'undefined') return;\n (window as ConfigWindow).__sentient_devtools_config = config;\n}\n\nexport function readDevtoolsConfig(): DevtoolsConfig | null {\n if (typeof window === 'undefined') return null;\n return (window as ConfigWindow).__sentient_devtools_config ?? null;\n}\n"],"mappings":";+6BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,sBAAAE,GAAA,+BAAAC,KAAA,eAAAC,GAAAJ,IACA,IAAAK,EAA0F,iBAC1FC,EAA0D,8BAC1DC,EAA4C,4BCkB5C,IAAMC,GAA6B,CACjC,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,EAEA,SAASC,GAAuB,CAC9B,GAAI,OAAO,QAAW,YAAa,OAAOD,GAC1C,I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N,OAAC,UAAO,QAAS,IAAMN,GAAU7D,EAAE,EAAE,EAAG,MAAOS,EAAAd,EAAA,GAAKyB,EAAI,EAAK,GAAd,CAAiB,MAAO,OAAQ,UAAW,CAAE,GAAG,iBAE/F,IA9BMpB,EAAE,EAgCZ,CAEJ,CAAC,GACH,GAEJ,EACF,KACA,OAAC,UACC,aAAW,oBACX,gBAAeyB,EACf,QAAS,IAAMC,EAAS0C,GAAM,CAACA,CAAC,EAChC,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,aAAc,GAAI,OAAQ,oBAAqB,WAAY,OAClF,QAAS,OAAQ,WAAY,SAAU,eAAgB,SAAU,QAAS,EAC1E,OAAQ,UAAW,UAAW,2BAA4B,EAEnE,mBAAC9C,GAAA,EAAa,EAChB,GACF,CAEJ","names":["devtools_exports","__export","AdaptiveDevtools","LOCAL_MODE_DEVTOOLS_BANNER","__toCommonJS","import_react","import_policy","import_core","ssrFallback","state","w","getRegistered","state","getRegisteredSlots","getRegisteredSections","subscribeRegistry","fn","listeners","getRegistryVersion","store","w","setVariantOverride","componentId","variantId","clearVariantOverride","getOverrides","__spreadValues","store","w","setSlotOverride","slotId","result","clearSlotOverride","getSlotOverrides","__spreadValues","ssrFallback","state","w","setPreviewMode","on","s","fn","getPreviewMode","EVENT","notifyOverridesChanged","_a","w","EVENT","readDevtoolsConfig","_a","import_jsx_runtime","_a","IS_PROD","DEFAULT_API_BASE_URL","LOCAL_MODE_DEVTOOLS_BANNER","currentLayout","forced","registered","getRegisteredSections","id","reorderLayout","from","to","order","next","moved","setPreviewMode","notifyOverridesChanged","resetLayout","applyOutcome","result","_b","variantId","setVariantOverride","w","__spreadValues","readSessionId","match","slotDecls","getRegisteredSlots","s","forcePersonaKeyed","apiKey","apiBaseUrl","persona","res","getRegistered","c","data","__spreadProps","forcePersonaLocal","mod","outcome","resetAll","getOverrides","clearVariantOverride","stale","i","key","e","btn","active","SentientMark","size","AdaptiveDevtools","open","setOpen","activePersona","setActivePersona","dragFrom","setDragFrom","mounted","setMounted","force","subscribeRegistry","getRegistryVersion","config","readDevtoolsConfig","useLocalEngine","components","slots","overrides","slotOverrides","getSlotOverrides","sections","layoutForced","onReorder","onResetLayout","maybeExitPreview","choose","resetVariant","chooseSlotArm","arm","setSlotOverride","chooseSlotDim","dim","value","dims","current","d","values","resetSlot","clearSlotOverride","choosePersona","getPreviewMode","p","v","ov","o"]}
package/dist/devtools.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- "use client";var se=Object.defineProperty,de=Object.defineProperties;var ae=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var le=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var U=(e,t,o)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,d=(e,t)=>{for(var o in t||(t={}))le.call(t,o)&&U(e,o,t[o]);if(j)for(var o of j(t))ce.call(t,o)&&U(e,o,t[o]);return e},b=(e,t)=>de(e,ae(t));import{useEffect as fe,useReducer as ve,useState as T,useSyncExternalStore as me}from"react";import{PERSONAS as ye,PERSONA_DISPLAY as _e,confidenceBand as we}from"@sentientui/policy";import{SNAPSHOT_STORAGE_KEY_PREFIX as be}from"@sentientui/core";var pe={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function S(){if(typeof window=="undefined")return pe;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 x(){return[...S().components.values()]}function E(){return[...S().slots.values()]}function P(){return[...S().sections]}function G(e){let t=S().listeners;return t.add(e),()=>{t.delete(e)}}function z(){return S().version}function A(){let e=window;return e.__sentient_overrides||(e.__sentient_overrides={}),e.__sentient_overrides}function L(e,t){A()[e]=t}function W(e){delete A()[e]}function R(){return d({},A())}function D(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function I(e,t){D()[e]=t}function F(e){delete D()[e]}function O(){return d({},D())}var ue={on:!1,listeners:new Set};function H(){if(typeof window=="undefined")return ue;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function u(e){let t=H();if(t.on!==e){t.on=e;for(let o of t.listeners)o()}}function Y(){return H().on}var ge="sentient:overrides-changed";function p(){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(ge))}function J(){var e;return typeof window=="undefined"?null:(e=window.__sentient_devtools_config)!=null?e:null}import{jsx as i,jsxs as a}from"react/jsx-runtime";var K,Se=typeof process!="undefined"&&((K=process.env)==null?void 0:K.NODE_ENV)==="production",he="https://api.sentient-ui.com/v1",xe="Local mode \u2014 decisions are simulated; add a key to learn from real traffic";function X(e){var o,s;for(let[f,v]of Object.entries((o=e.assignments)!=null?o:{}))L(f,v);let t=window;e.layoutOrder&&e.layoutOrder.length>0&&(t.__sentient_layout_override=e.layoutOrder),e.slots&&(t.__sentient_slot_overrides=d(d({},(s=t.__sentient_slot_overrides)!=null?s:{}),e.slots)),e.personaAttributes&&(document.documentElement.dataset.sentientPersona=e.personaAttributes.persona,document.documentElement.dataset.sentientConfidence=e.personaAttributes.confidence),u(!0),p()}function Re(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return"devtools-preview"}function $(){return E().map(e=>d(d({id:e.id},e.arms?{arms:e.arms}:{}),e.dims?{dims:e.dims}:{}))}async function Oe(e,t,o){var v;let s=await fetch(`${t}/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({persona:o,sections:P().map(m=>({id:m})),components:x().map(m=>({id:m.id,variantIds:m.variantIds})),slots:$()})});if(!s.ok)return;let f=await s.json();X(b(d({},f),{personaAttributes:(v=f.personaAttributes)!=null?v:{persona:o,confidence:"high"}}))}async function ke(e){let t=await import("@sentientui/core/local");if(!t.LOCAL_ENGINE_AVAILABLE)return;let o=t.createLocalEngine({sessionId:Re(),forcedPersona:e}).decide({sections:P(),components:x().map(s=>({id:s.id,variantIds:s.variantIds})),slots:$()});X({assignments:o.assignments,layoutOrder:o.layoutOrder,slots:o.slots,personaAttributes:{persona:o.persona,confidence:we(o.confidence)}})}function Ce(){for(let t of Object.keys(R()))W(t);let e=window;delete e.__sentient_layout_override,delete e.__sentient_slot_overrides,delete document.documentElement.dataset.sentientPersona,delete document.documentElement.dataset.sentientConfidence;try{let t=[];for(let o=0;o<localStorage.length;o++){let s=localStorage.key(o);s&&s.startsWith(be)&&t.push(s)}for(let o of t)localStorage.removeItem(o)}catch(t){}u(!1),p();try{window.location.reload()}catch(t){}}var g=e=>({padding:"2px 8px",borderRadius:4,border:"1px solid #444",background:e?"#3b82f6":"#222",color:"#eee",cursor:"pointer"});function Ee({size:e=26}={}){return a("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",children:[i("path",{d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M10 22H17",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round"}),i("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})]})}function Je({apiKey:e}={}){var V;let[t,o]=T(!1),[s,f]=T(null),[v,m]=T(!1),[,y]=ve(n=>n+1,0);if(me(G,z,()=>0),fe(()=>m(!0),[]),Se||!v)return null;let _=(V=J())!=null?V:{apiKey:e!=null?e:"",apiBaseUrl:he,isLocal:!1},q=_.isLocal||!_.apiKey,h=x(),k=E(),C=R(),B=O();function N(){Object.keys(R()).length===0&&Object.keys(O()).length===0&&u(!1)}function Q(n,r){L(n,r),u(!0),p(),y()}function Z(n){W(n),N(),p(),y()}function ee(n,r){I(n,r),u(!0),p(),y()}function te(n,r,l,w){let c=O()[n],M=c&&typeof c=="object"?d({},c):Object.fromEntries(Object.entries(w!=null?w:{}).map(([ie,re])=>[ie,re[0]]));M[r]=l,I(n,M),u(!0),p(),y()}function ne(n){F(n),N(),p(),y()}function oe(n){f(n),(q?ke(n):Oe(_.apiKey,_.apiBaseUrl,n)).then(y)}return a("div",{style:{position:"fixed",bottom:16,right:16,zIndex:2147483647,fontFamily:"system-ui"},children:[i("div",{"aria-hidden":!t,style:{position:"absolute",bottom:52,right:0,transformOrigin:"bottom right",transition:"opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)",opacity:t?1:0,transform:t?"translateY(0) scale(1)":"translateY(6px) scale(.96)",pointerEvents:t?"auto":"none"},children:a("div",{style:{width:300,maxHeight:460,overflowY:"auto",background:"#111",color:"#eee",borderRadius:8,padding:12,boxShadow:"0 8px 30px rgba(0,0,0,.4)",fontSize:12},children:[_.isLocal&&i("div",{style:{background:"#1e293b",border:"1px solid #334155",borderRadius:4,padding:"6px 8px",marginBottom:8},children:xe}),a("div",{style:{opacity:.7,marginBottom:8},children:[h.length," component",h.length===1?"":"s"," \xB7 ",Y()?"preview \u2014 writing nothing":"live"]}),a("div",{style:{borderBottom:"1px solid #333",paddingBottom:8,marginBottom:8},children:[i("div",{style:{opacity:.7,marginBottom:4},children:"Preview persona"}),a("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[ye.map(n=>i("button",{onClick:()=>oe(n),style:g(s===n),children:_e[n]},n)),(s!==null||Object.keys(C).length>0||Object.keys(B).length>0)&&i("button",{onClick:Ce,style:b(d({},g(!1)),{color:"#aaa"}),children:"Reset"})]})]}),h.length===0&&k.length===0&&i("div",{style:{opacity:.6},children:"No components or slots on this page yet."}),h.map(n=>a("div",{style:{borderTop:"1px solid #333",padding:"8px 0"},children:[a("div",{style:{fontWeight:600},children:[n.id,n.goal?` \xB7 goal: ${n.goal}`:""]}),a("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[n.variantIds.map(r=>i("button",{onClick:()=>Q(n.id,r),style:g(C[n.id]===r),children:r},r)),C[n.id]&&i("button",{onClick:()=>Z(n.id),style:b(d({},g(!1)),{color:"#aaa"}),children:"reset"})]})]},n.id)),k.length>0&&a("div",{style:{borderTop:"1px solid #333",paddingTop:8,marginTop:4},children:[i("div",{style:{opacity:.7,marginBottom:4},children:"Slots"}),k.map(n=>{let r=B[n.id];return a("div",{style:{padding:"6px 0"},children:[i("div",{style:{fontWeight:600},children:n.id}),n.arms&&i("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:n.arms.map(l=>i("button",{onClick:()=>ee(n.id,l),style:g(r===l),children:l},l))}),n.dims&&Object.entries(n.dims).map(([l,w])=>a("div",{style:{marginTop:4},children:[i("div",{style:{opacity:.6,fontSize:11},children:l}),i("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:w.map(c=>i("button",{onClick:()=>te(n.id,l,c,n.dims),style:g(!!r&&typeof r=="object"&&r[l]===c),children:c},c))})]},l)),r!==void 0&&i("button",{onClick:()=>ne(n.id),style:b(d({},g(!1)),{color:"#aaa",marginTop:4}),children:"reset"})]},n.id)})]})]})}),i("button",{"aria-label":"Sentient DevTools","aria-expanded":t,onClick:()=>o(n=>!n),style:{width:44,height:44,borderRadius:12,border:"1px solid #2a2a2a",background:"#000",display:"flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",boxShadow:"0 6px 18px rgba(0,0,0,.4)"},children:i(Ee,{})})]})}export{Je as AdaptiveDevtools,xe as LOCAL_MODE_DEVTOOLS_BANNER};
2
+ "use client";var ge=Object.defineProperty,fe=Object.defineProperties;var ve=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var U=(e,t,o)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,a=(e,t)=>{for(var o in t||(t={}))me.call(t,o)&&U(e,o,t[o]);if(F)for(var o of F(t))ye.call(t,o)&&U(e,o,t[o]);return e},_=(e,t)=>fe(e,ve(t));import{useEffect as Se,useReducer as he,useState as C,useSyncExternalStore as xe}from"react";import{PERSONAS as Re,PERSONA_DISPLAY as Oe,confidenceBand as ke}from"@sentientui/policy";import{SNAPSHOT_STORAGE_KEY_PREFIX as Ce}from"@sentientui/core";var _e={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function S(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_registry||(e.__sentient_registry={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0}),e.__sentient_registry}function x(){return[...S().components.values()]}function D(){return[...S().slots.values()]}function R(){return[...S().sections]}function G(e){let t=S().listeners;return t.add(e),()=>{t.delete(e)}}function z(){return S().version}function W(){let e=window;return e.__sentient_overrides||(e.__sentient_overrides={}),e.__sentient_overrides}function B(e,t){W()[e]=t}function I(e){delete W()[e]}function O(){return a({},W())}function T(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function N(e,t){T()[e]=t}function H(e){delete T()[e]}function k(){return a({},T())}var we={on:!1,listeners:new Set};function Y(){if(typeof window=="undefined")return we;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function m(e){let t=Y();if(t.on!==e){t.on=e;for(let o of t.listeners)o()}}function J(){return Y().on}var be="sentient:overrides-changed";function u(){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(be))}function K(){var e;return typeof window=="undefined"?null:(e=window.__sentient_devtools_config)!=null?e:null}import{jsx as i,jsxs as l}from"react/jsx-runtime";var X,Ee=typeof process!="undefined"&&((X=process.env)==null?void 0:X.NODE_ENV)==="production",Pe="https://api.sentient-ui.com/v1",Ae="Local mode \u2014 decisions are simulated; add a key to learn from real traffic";function $(){let e=window.__sentient_layout_override,t=R();return!e||e.length===0?t:[...e,...t.filter(o=>!e.includes(o))]}function Le(e,t){let o=$();if(e===t||e<0||t<0||e>=o.length||t>=o.length)return;let s=[...o],[p]=s.splice(e,1);s.splice(t,0,p),window.__sentient_layout_override=s,m(!0),u()}function De(){delete window.__sentient_layout_override,u()}function q(e){var o,s;for(let[p,c]of Object.entries((o=e.assignments)!=null?o:{}))B(p,c);let t=window;e.layoutOrder&&e.layoutOrder.length>0&&(t.__sentient_layout_override=e.layoutOrder),e.slots&&(t.__sentient_slot_overrides=a(a({},(s=t.__sentient_slot_overrides)!=null?s:{}),e.slots)),e.personaAttributes&&(document.documentElement.dataset.sentientPersona=e.personaAttributes.persona,document.documentElement.dataset.sentientConfidence=e.personaAttributes.confidence),m(!0),u()}function We(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);if(e)return decodeURIComponent(e[1])}catch(e){}return"devtools-preview"}function Q(){return D().map(e=>a(a({id:e.id},e.arms?{arms:e.arms}:{}),e.dims?{dims:e.dims}:{}))}async function Be(e,t,o){var c;let s=await fetch(`${t}/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({persona:o,sections:R().map(g=>({id:g})),components:x().map(g=>({id:g.id,variantIds:g.variantIds})),slots:Q()})});if(!s.ok)return;let p=await s.json();q(_(a({},p),{personaAttributes:(c=p.personaAttributes)!=null?c:{persona:o,confidence:"high"}}))}async function Ie(e){let t=await import("@sentientui/core/local");if(!t.LOCAL_ENGINE_AVAILABLE)return;let o=t.createLocalEngine({sessionId:We(),forcedPersona:e}).decide({sections:R(),components:x().map(s=>({id:s.id,variantIds:s.variantIds})),slots:Q()});q({assignments:o.assignments,layoutOrder:o.layoutOrder,slots:o.slots,personaAttributes:{persona:o.persona,confidence:ke(o.confidence)}})}function Te(){for(let t of Object.keys(O()))I(t);let e=window;delete e.__sentient_layout_override,delete e.__sentient_slot_overrides,delete document.documentElement.dataset.sentientPersona,delete document.documentElement.dataset.sentientConfidence;try{let t=[];for(let o=0;o<localStorage.length;o++){let s=localStorage.key(o);s&&s.startsWith(Ce)&&t.push(s)}for(let o of t)localStorage.removeItem(o)}catch(t){}m(!1),u();try{window.location.reload()}catch(t){}}var y=e=>({padding:"2px 8px",borderRadius:4,border:"1px solid #444",background:e?"#3b82f6":"#222",color:"#eee",cursor:"pointer"});function Ne({size:e=26}={}){return l("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none","aria-hidden":"true",children:[i("path",{d:"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),i("path",{d:"M10 22H17",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round"}),i("circle",{cx:"20.6",cy:"22",r:"2.1",fill:"#fff"})]})}function nt({apiKey:e}={}){var j;let[t,o]=C(!1),[s,p]=C(null),[c,g]=C(null),[Z,ee]=C(!1),[,f]=he(n=>n+1,0);if(xe(G,z,()=>0),Se(()=>ee(!0),[]),Ee||!Z)return null;let w=(j=K())!=null?j:{apiKey:e!=null?e:"",apiBaseUrl:Pe,isLocal:!1},te=w.isLocal||!w.apiKey,h=x(),E=D(),P=O(),V=k(),A=$(),ne=window.__sentient_layout_override!==void 0;function oe(n,r){Le(n,r),f()}function ie(){De(),L(),f()}function L(){Object.keys(O()).length===0&&Object.keys(k()).length===0&&window.__sentient_layout_override===void 0&&m(!1)}function re(n,r){B(n,r),m(!0),u(),f()}function se(n){I(n),L(),u(),f()}function de(n,r){N(n,r),m(!0),u(),f()}function ae(n,r,d,b){let v=k()[n],M=v&&typeof v=="object"?a({},v):Object.fromEntries(Object.entries(b!=null?b:{}).map(([ue,pe])=>[ue,pe[0]]));M[r]=d,N(n,M),m(!0),u(),f()}function le(n){H(n),L(),u(),f()}function ce(n){p(n),(te?Ie(n):Be(w.apiKey,w.apiBaseUrl,n)).then(f)}return l("div",{style:{position:"fixed",bottom:16,right:16,zIndex:2147483647,fontFamily:"system-ui"},children:[i("div",{"aria-hidden":!t,style:{position:"absolute",bottom:52,right:0,transformOrigin:"bottom right",transition:"opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)",opacity:t?1:0,transform:t?"translateY(0) scale(1)":"translateY(6px) scale(.96)",pointerEvents:t?"auto":"none"},children:l("div",{style:{width:300,maxHeight:460,overflowY:"auto",background:"#111",color:"#eee",borderRadius:8,padding:12,boxShadow:"0 8px 30px rgba(0,0,0,.4)",fontSize:12},children:[w.isLocal&&i("div",{style:{background:"#1e293b",border:"1px solid #334155",borderRadius:4,padding:"6px 8px",marginBottom:8},children:Ae}),l("div",{style:{opacity:.7,marginBottom:8},children:[h.length," component",h.length===1?"":"s"," \xB7 ",J()?"preview \u2014 writing nothing":"live"]}),l("div",{style:{borderBottom:"1px solid #333",paddingBottom:8,marginBottom:8},children:[i("div",{style:{opacity:.7,marginBottom:4},children:"Preview persona"}),l("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[Re.map(n=>i("button",{onClick:()=>ce(n),style:y(s===n),children:Oe[n]},n)),(s!==null||Object.keys(P).length>0||Object.keys(V).length>0)&&i("button",{onClick:Te,style:_(a({},y(!1)),{color:"#aaa"}),children:"Reset"})]})]}),A.length>0&&l("div",{style:{borderBottom:"1px solid #333",paddingBottom:8,marginBottom:8},children:[l("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[i("span",{style:{opacity:.7},children:"Layout \u2014 drag to reorder"}),ne&&i("button",{"aria-label":"Reset section order",onClick:ie,style:_(a({},y(!1)),{color:"#aaa"}),children:"reset"})]}),i("ul",{"aria-label":"Section order",style:{listStyle:"none",margin:0,padding:0},children:A.map((n,r)=>l("li",{draggable:!0,onDragStart:()=>g(r),onDragOver:d=>d.preventDefault(),onDrop:d=>{d.preventDefault(),c!==null&&oe(c,r),g(null)},onDragEnd:()=>g(null),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 6px",marginBottom:2,borderRadius:4,border:"1px solid #262626",cursor:"grab",background:c===r?"#1e293b":"#181818",opacity:c!==null&&c!==r?.6:1},children:[i("span",{style:{opacity:.4,minWidth:10,fontVariantNumeric:"tabular-nums"},children:r+1}),i("span",{"aria-hidden":"true",style:{opacity:.35},children:"\u283F"}),i("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})]},n))})]}),h.length===0&&E.length===0&&A.length===0&&i("div",{style:{opacity:.6},children:"No components, sections or slots on this page yet."}),h.map(n=>l("div",{style:{borderTop:"1px solid #333",padding:"8px 0"},children:[l("div",{style:{fontWeight:600},children:[n.id,n.goal?` \xB7 goal: ${n.goal}`:""]}),l("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[n.variantIds.map(r=>i("button",{onClick:()=>re(n.id,r),style:y(P[n.id]===r),children:r},r)),P[n.id]&&i("button",{onClick:()=>se(n.id),style:_(a({},y(!1)),{color:"#aaa"}),children:"reset"})]})]},n.id)),E.length>0&&l("div",{style:{borderTop:"1px solid #333",paddingTop:8,marginTop:4},children:[i("div",{style:{opacity:.7,marginBottom:4},children:"Slots"}),E.map(n=>{let r=V[n.id];return l("div",{style:{padding:"6px 0"},children:[i("div",{style:{fontWeight:600},children:n.id}),n.arms&&i("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:n.arms.map(d=>i("button",{onClick:()=>de(n.id,d),style:y(r===d),children:d},d))}),n.dims&&Object.entries(n.dims).map(([d,b])=>l("div",{style:{marginTop:4},children:[i("div",{style:{opacity:.6,fontSize:11},children:d}),i("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:b.map(v=>i("button",{onClick:()=>ae(n.id,d,v,n.dims),style:y(!!r&&typeof r=="object"&&r[d]===v),children:v},v))})]},d)),r!==void 0&&i("button",{onClick:()=>le(n.id),style:_(a({},y(!1)),{color:"#aaa",marginTop:4}),children:"reset"})]},n.id)})]})]})}),i("button",{"aria-label":"Sentient DevTools","aria-expanded":t,onClick:()=>o(n=>!n),style:{width:44,height:44,borderRadius:12,border:"1px solid #2a2a2a",background:"#000",display:"flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",boxShadow:"0 6px 18px rgba(0,0,0,.4)"},children:i(Ne,{})})]})}export{nt as AdaptiveDevtools,Ae as LOCAL_MODE_DEVTOOLS_BANNER};
3
3
  //# sourceMappingURL=devtools.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/devtools/index.tsx","../src/devtools-registry.ts","../src/devtools-overrides.ts","../src/devtools-slot-overrides.ts","../src/preview-mode.ts","../src/override-events.ts","../src/devtools-config.ts"],"sourcesContent":["'use client';\nimport { useEffect, useReducer, useState, useSyncExternalStore, type CSSProperties } from 'react';\nimport { PERSONAS, PERSONA_DISPLAY, confidenceBand } from '@sentientui/policy';\nimport { SNAPSHOT_STORAGE_KEY_PREFIX } from '@sentientui/core';\nimport {\n getRegistered,\n getRegisteredSlots,\n getRegisteredSections,\n subscribeRegistry,\n getRegistryVersion,\n type RegisteredSlot,\n} from '../devtools-registry.js';\nimport { setVariantOverride, clearVariantOverride, getOverrides } from '../devtools-overrides.js';\nimport { setSlotOverride, clearSlotOverride, getSlotOverrides } from '../devtools-slot-overrides.js';\nimport { setPreviewMode, getPreviewMode } from '../preview-mode.js';\nimport { notifyOverridesChanged } from '../override-events.js';\nimport { readDevtoolsConfig, type DevtoolsConfig } from '../devtools-config.js';\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\nconst IS_PROD = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport const LOCAL_MODE_DEVTOOLS_BANNER =\n 'Local mode — decisions are simulated; add a key to learn from real traffic';\n\ntype OutcomeToApply = {\n assignments?: Record<string, string>;\n layoutOrder?: string[] | null;\n slots?: Record<string, string | Record<string, string>>;\n personaAttributes?: { persona: string; confidence: 'low' | 'medium' | 'high' };\n};\n\ntype OverrideWindow = Window & {\n __sentient_layout_override?: string[];\n __sentient_slot_overrides?: Record<string, string | Record<string, string>>;\n};\n\n/** Apply a simulated outcome across every surface: variants, layout, slots/tokens, persona attrs. */\nfunction applyOutcome(result: OutcomeToApply): void {\n for (const [id, variantId] of Object.entries(result.assignments ?? {})) {\n setVariantOverride(id, variantId);\n }\n const w = window as unknown as OverrideWindow;\n if (result.layoutOrder && result.layoutOrder.length > 0) {\n w.__sentient_layout_override = result.layoutOrder;\n }\n if (result.slots) {\n w.__sentient_slot_overrides = { ...(w.__sentient_slot_overrides ?? {}), ...result.slots };\n }\n if (result.personaAttributes) {\n document.documentElement.dataset.sentientPersona = result.personaAttributes.persona;\n document.documentElement.dataset.sentientConfidence = result.personaAttributes.confidence;\n }\n setPreviewMode(true); // suppress events while previewing\n notifyOverridesChanged(); // re-render layout/slot consumers\n}\n\nfunction readSessionId(): string {\n try {\n const match = document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);\n if (match) return decodeURIComponent(match[1]);\n } catch {\n /* ignore */\n }\n return 'devtools-preview';\n}\n\nfunction slotDecls(): Array<{ id: string; arms?: string[]; dims?: RegisteredSlot['dims'] }> {\n return getRegisteredSlots().map((s) => ({\n id: s.id,\n ...(s.arms ? { arms: s.arms } : {}),\n ...(s.dims ? { dims: s.dims } : {}),\n }));\n}\n\n/** Keyed mode: simulate via /v1/explain (read-only, event-free). */\nasync function forcePersonaKeyed(apiKey: string, apiBaseUrl: string, persona: string): Promise<void> {\n const res = await fetch(`${apiBaseUrl}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({\n persona,\n sections: getRegisteredSections().map((id) => ({ id })),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n }),\n });\n if (!res.ok) return;\n const data = (await res.json()) as OutcomeToApply;\n applyOutcome({\n ...data,\n personaAttributes: data.personaAttributes ?? { persona, confidence: 'high' },\n });\n}\n\n/** Local mode: simulate via the deterministic local engine — zero network. */\nasync function forcePersonaLocal(persona: string): Promise<void> {\n const mod = await import('@sentientui/core/local');\n if (!mod.LOCAL_ENGINE_AVAILABLE) return;\n const outcome = mod\n .createLocalEngine({ sessionId: readSessionId(), forcedPersona: persona })\n .decide({\n sections: getRegisteredSections(),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n });\n applyOutcome({\n assignments: outcome.assignments,\n layoutOrder: outcome.layoutOrder,\n slots: outcome.slots,\n personaAttributes: {\n persona: outcome.persona,\n confidence: confidenceBand(outcome.confidence),\n },\n });\n}\n\n/** Reset: clear the decision snapshot + every override, then reload to re-decide. */\nfunction resetAll(): void {\n for (const id of Object.keys(getOverrides())) clearVariantOverride(id);\n const w = window as unknown as OverrideWindow;\n delete w.__sentient_layout_override;\n delete w.__sentient_slot_overrides;\n delete document.documentElement.dataset.sentientPersona;\n delete document.documentElement.dataset.sentientConfidence;\n try {\n const stale: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(SNAPSHOT_STORAGE_KEY_PREFIX)) stale.push(key);\n }\n for (const key of stale) localStorage.removeItem(key);\n } catch {\n /* ignore */\n }\n setPreviewMode(false);\n notifyOverridesChanged();\n try {\n window.location.reload();\n } catch {\n /* jsdom */\n }\n}\n\nconst btn = (active: boolean): CSSProperties => ({\n padding: '2px 8px',\n borderRadius: 4,\n border: '1px solid #444',\n background: active ? '#3b82f6' : '#222',\n color: '#eee',\n cursor: 'pointer',\n});\n\n/** Sentient \"S.\" wordmark, monoline — white strokes for the black launcher button. */\nfunction SentientMark({ size = 26 }: { size?: number } = {}): JSX.Element {\n return (\n <svg width={size} height={size} viewBox=\"0 0 32 32\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6\"\n stroke=\"#fff\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path d=\"M10 22H17\" stroke=\"#fff\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n <circle cx=\"20.6\" cy=\"22\" r=\"2.1\" fill=\"#fff\" />\n </svg>\n );\n}\n\nexport function AdaptiveDevtools({ apiKey }: { apiKey?: string } = {}): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const [activePersona, setActivePersona] = useState<string | null>(null);\n const [mounted, setMounted] = useState(false);\n const [, force] = useReducer((n: number) => n + 1, 0);\n // Re-render when the component/slot registry changes. useSyncExternalStore\n // (not a manual useEffect subscription) so the subscription can't go stale\n // across Next Fast Refresh — a stale listener was why the panel needed a hard\n // refresh to pick up a renamed id.\n useSyncExternalStore(subscribeRegistry, getRegistryVersion, () => 0);\n // Client-mount gate: render nothing during SSR / the first paint so the widget\n // never reads `window` on the server. Lets consumers drop `<AdaptiveDevtools/>`\n // straight into a tree without a `dynamic(..., { ssr: false })` wrapper.\n useEffect(() => setMounted(true), []);\n\n // Never render in production, even if imported by mistake. (Hooks run first\n // so the rules of hooks hold regardless of these early returns.)\n if (IS_PROD) return null;\n if (!mounted) return null;\n\n const config: DevtoolsConfig = readDevtoolsConfig() ?? {\n apiKey: apiKey ?? '',\n apiBaseUrl: DEFAULT_API_BASE_URL,\n isLocal: false,\n };\n const useLocalEngine = config.isLocal || !config.apiKey;\n const components = getRegistered();\n const slots = getRegisteredSlots();\n const overrides = getOverrides();\n const slotOverrides = getSlotOverrides();\n\n // Preview mode stays on while ANY override (variant or slot) is active.\n function maybeExitPreview(): void {\n if (Object.keys(getOverrides()).length === 0 && Object.keys(getSlotOverrides()).length === 0) {\n setPreviewMode(false);\n }\n }\n\n function choose(id: string, variantId: string): void {\n setVariantOverride(id, variantId);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetVariant(id: string): void {\n clearVariantOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function chooseSlotArm(id: string, arm: string): void {\n setSlotOverride(id, arm);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function chooseSlotDim(id: string, dim: string, value: string, dims: RegisteredSlot['dims']): void {\n const current = getSlotOverrides()[id];\n // Merge onto the existing forced object, or seed from each dim's baseline\n // (first value) so unset dims stay at baseline instead of vanishing.\n const next: Record<string, string> =\n current && typeof current === 'object'\n ? { ...current }\n : Object.fromEntries(Object.entries(dims ?? {}).map(([d, values]) => [d, values[0]!]));\n next[dim] = value;\n setSlotOverride(id, next);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetSlot(id: string): void {\n clearSlotOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function choosePersona(persona: string): void {\n setActivePersona(persona);\n const apply = useLocalEngine\n ? forcePersonaLocal(persona)\n : forcePersonaKeyed(config.apiKey, config.apiBaseUrl, persona);\n void apply.then(force);\n }\n\n return (\n <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 2147483647, fontFamily: 'system-ui' }}>\n {/* Panel stays mounted and animates in/out from the button's corner, so the\n launcher below never shifts. transform-origin is the button (bottom-right). */}\n <div\n aria-hidden={!open}\n style={{\n position: 'absolute',\n bottom: 52,\n right: 0,\n transformOrigin: 'bottom right',\n transition: 'opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)',\n opacity: open ? 1 : 0,\n transform: open ? 'translateY(0) scale(1)' : 'translateY(6px) scale(.96)',\n pointerEvents: open ? 'auto' : 'none',\n }}\n >\n <div style={{ width: 300, maxHeight: 460, overflowY: 'auto', background: '#111', color: '#eee',\n borderRadius: 8, padding: 12, boxShadow: '0 8px 30px rgba(0,0,0,.4)', fontSize: 12 }}>\n {config.isLocal && (\n <div style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4,\n padding: '6px 8px', marginBottom: 8 }}>\n {LOCAL_MODE_DEVTOOLS_BANNER}\n </div>\n )}\n <div style={{ opacity: .7, marginBottom: 8 }}>\n {components.length} component{components.length === 1 ? '' : 's'} · {getPreviewMode() ? 'preview — writing nothing' : 'live'}\n </div>\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Preview persona</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {PERSONAS.map((p) => (\n <button key={p} onClick={() => choosePersona(p)} style={btn(activePersona === p)}>\n {PERSONA_DISPLAY[p]}\n </button>\n ))}\n {(activePersona !== null || Object.keys(overrides).length > 0 || Object.keys(slotOverrides).length > 0) && (\n <button onClick={resetAll} style={{ ...btn(false), color: '#aaa' }}>\n Reset\n </button>\n )}\n </div>\n </div>\n {components.length === 0 && slots.length === 0 && (\n <div style={{ opacity: .6 }}>No components or slots on this page yet.</div>\n )}\n {components.map((c) => (\n <div key={c.id} style={{ borderTop: '1px solid #333', padding: '8px 0' }}>\n <div style={{ fontWeight: 600 }}>{c.id}{c.goal ? ` · goal: ${c.goal}` : ''}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {c.variantIds.map((v) => (\n <button key={v} onClick={() => choose(c.id, v)} style={btn(overrides[c.id] === v)}>\n {v}\n </button>\n ))}\n {overrides[c.id] && (\n <button onClick={() => resetVariant(c.id)} style={{ ...btn(false), color: '#aaa' }}>\n reset\n </button>\n )}\n </div>\n </div>\n ))}\n {slots.length > 0 && (\n <div style={{ borderTop: '1px solid #333', paddingTop: 8, marginTop: 4 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Slots</div>\n {slots.map((s) => {\n const ov = slotOverrides[s.id];\n return (\n <div key={s.id} style={{ padding: '6px 0' }}>\n <div style={{ fontWeight: 600 }}>{s.id}</div>\n {s.arms && (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {s.arms.map((arm) => (\n <button key={arm} onClick={() => chooseSlotArm(s.id, arm)} style={btn(ov === arm)}>\n {arm}\n </button>\n ))}\n </div>\n )}\n {s.dims && Object.entries(s.dims).map(([dim, values]) => (\n <div key={dim} style={{ marginTop: 4 }}>\n <div style={{ opacity: .6, fontSize: 11 }}>{dim}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {values.map((v) => (\n <button\n key={v}\n onClick={() => chooseSlotDim(s.id, dim, v, s.dims)}\n style={btn(!!ov && typeof ov === 'object' && ov[dim] === v)}\n >\n {v}\n </button>\n ))}\n </div>\n </div>\n ))}\n {ov !== undefined && (\n <button onClick={() => resetSlot(s.id)} style={{ ...btn(false), color: '#aaa', marginTop: 4 }}>\n reset\n </button>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n <button\n aria-label=\"Sentient DevTools\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n style={{ width: 44, height: 44, borderRadius: 12, border: '1px solid #2a2a2a', background: '#000',\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 0,\n cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,0,0,.4)' }}\n >\n <SentientMark />\n </button>\n </div>\n );\n}\n","import { isDevBuild } from './adaptive-shared.js';\n\nexport type RegisteredComponent = { id: string; variantIds: string[]; goal?: string };\nexport type RegisteredSlot = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n};\n\ntype RegistryState = {\n components: Map<string, RegisteredComponent>;\n slots: Map<string, RegisteredSlot>;\n sections: string[];\n listeners: Set<() => void>;\n /** Bumped on every mutation so `useSyncExternalStore` can read a stable, comparable snapshot. */\n version: number;\n};\n\n// Shared through a window global: the main entry and the /devtools entry are\n// separate bundles, each with its own copy of this module — module-local\n// state would give the devtools an always-empty registry in published apps.\nconst ssrFallback: RegistryState = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n};\n\nfunction state(): RegistryState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_registry?: RegistryState };\n if (!w.__sentient_registry) {\n w.__sentient_registry = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n };\n }\n return w.__sentient_registry;\n}\n\nfunction emit(): void {\n // Bump BEFORE notifying so a useSyncExternalStore consumer re-reading its\n // snapshot inside the notification sees the new value and re-renders.\n state().version += 1;\n for (const fn of state().listeners) fn();\n}\n\n// The registry exists solely to feed the opt-in devtools panel, which is a\n// dev-only surface. In a production build there is no panel reading it, so\n// every register call is dead work plus a `window.__sentient_registry`\n// footprint on the customer's page. Short-circuit to a noop in production —\n// every <Adaptive>/useAdaptive/slot mount calls one of these.\nconst NOOP_UNREGISTER = (): void => undefined;\n\n/** Register (or re-register) a component. Returns an unregister function. */\nexport function registerComponent(c: RegisteredComponent): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().components.set(c.id, c);\n emit();\n return () => {\n state().components.delete(c.id);\n emit();\n };\n}\n\n/** Register (or re-register) a slot declaration. Returns an unregister function. */\nexport function registerSlot(s: RegisteredSlot): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().slots.set(s.id, s);\n emit();\n return () => {\n state().slots.delete(s.id);\n emit();\n };\n}\n\n/** Register the page's declared section ids (from AdaptiveRoot/provider). */\nexport function registerSections(sections: string[]): void {\n if (!isDevBuild()) return;\n state().sections = [...sections];\n emit();\n}\n\nexport function getRegistered(): RegisteredComponent[] {\n return [...state().components.values()];\n}\n\nexport function getRegisteredSlots(): RegisteredSlot[] {\n return [...state().slots.values()];\n}\n\nexport function getRegisteredSections(): string[] {\n return [...state().sections];\n}\n\nexport function subscribeRegistry(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/** Monotonic snapshot for `useSyncExternalStore` — changes on every registry mutation. */\nexport function getRegistryVersion(): number {\n return state().version;\n}\n","function store(): Record<string, string> {\n const w = window as unknown as { __sentient_overrides?: Record<string, string> };\n if (!w.__sentient_overrides) w.__sentient_overrides = {};\n return w.__sentient_overrides;\n}\n\n/** Force `componentId` to render `variantId` — read by `useAssignment`. */\nexport function setVariantOverride(componentId: string, variantId: string): void {\n store()[componentId] = variantId;\n}\n\nexport function clearVariantOverride(componentId: string): void {\n delete store()[componentId];\n}\n\nexport function getOverrides(): Record<string, string> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n assign: (componentId, variantIds, agentData, agentDataByVariant) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","/** Provider → devtools config handoff. Window-backed: the /devtools entry is a\n * separate bundle and cannot share the provider's React context instance. */\nexport type DevtoolsConfig = {\n apiKey: string;\n apiBaseUrl: string;\n isLocal: boolean;\n};\n\ntype ConfigWindow = Window & { __sentient_devtools_config?: DevtoolsConfig };\n\nexport function publishDevtoolsConfig(config: DevtoolsConfig): void {\n if (typeof window === 'undefined') return;\n (window as ConfigWindow).__sentient_devtools_config = config;\n}\n\nexport function readDevtoolsConfig(): DevtoolsConfig | null {\n if (typeof window === 'undefined') return null;\n return (window as ConfigWindow).__sentient_devtools_config ?? null;\n}\n"],"mappings":";ocACA,OAAS,aAAAA,GAAW,cAAAC,GAAY,YAAAC,EAAU,wBAAAC,OAAgD,QAC1F,OAAS,YAAAC,GAAU,mBAAAC,GAAiB,kBAAAC,OAAsB,qBAC1D,OAAS,+BAAAC,OAAmC,mBCkB5C,IAAMC,GAA6B,CACjC,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,EAEA,SAASC,GAAuB,CAC9B,GAAI,OAAO,QAAW,YAAa,OAAOD,GAC1C,IAAME,EAAI,OACV,OAAKA,EAAE,sBACLA,EAAE,oBAAsB,CACtB,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,GAEKA,EAAE,mBACX,CA6CO,SAASC,GAAuC,CACrD,MAAO,CAAC,GAAGC,EAAM,EAAE,WAAW,OAAO,CAAC,CACxC,CAEO,SAASC,GAAuC,CACrD,MAAO,CAAC,GAAGD,EAAM,EAAE,MAAM,OAAO,CAAC,CACnC,CAEO,SAASE,GAAkC,CAChD,MAAO,CAAC,GAAGF,EAAM,EAAE,QAAQ,CAC7B,CAEO,SAASG,EAAkBC,EAA4B,CAC5D,IAAMC,EAAYL,EAAM,EAAE,UAC1B,OAAAK,EAAU,IAAID,CAAE,EACT,IAAM,CACXC,EAAU,OAAOD,CAAE,CACrB,CACF,CAGO,SAASE,GAA6B,CAC3C,OAAON,EAAM,EAAE,OACjB,CC9GA,SAASO,GAAgC,CACvC,IAAMC,EAAI,OACV,OAAKA,EAAE,uBAAsBA,EAAE,qBAAuB,CAAC,GAChDA,EAAE,oBACX,CAGO,SAASC,EAAmBC,EAAqBC,E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AEJ,EACF,EACApB,EAAC,UACC,aAAW,oBACX,gBAAegD,EACf,QAAS,IAAMC,EAAS2C,GAAM,CAACA,CAAC,EAChC,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,aAAc,GAAI,OAAQ,oBAAqB,WAAY,OAClF,QAAS,OAAQ,WAAY,SAAU,eAAgB,SAAU,QAAS,EAC1E,OAAQ,UAAW,UAAW,2BAA4B,EAEnE,SAAA5F,EAAC6C,GAAA,EAAa,EAChB,GACF,CAEJ","names":["useEffect","useReducer","useState","useSyncExternalStore","PERSONAS","PERSONA_DISPLAY","confidenceBand","SNAPSHOT_STORAGE_KEY_PREFIX","ssrFallback","state","w","getRegistered","state","getRegisteredSlots","getRegisteredSections","subscribeRegistry","fn","listeners","getRegistryVersion","store","w","setVariantOverride","componentId","variantId","clearVariantOverride","getOverrides","__spreadValues","store","w","setSlotOverride","slotId","result","clearSlotOverride","getSlotOverrides","__spreadValues","ssrFallback","state","w","setPreviewMode","on","s","fn","getPreviewMode","EVENT","notifyOverridesChanged","_a","w","EVENT","readDevtoolsConfig","_a","jsx","jsxs","_a","IS_PROD","DEFAULT_API_BASE_URL","LOCAL_MODE_DEVTOOLS_BANNER","applyOutcome","result","_b","id","variantId","setVariantOverride","w","__spreadValues","setPreviewMode","notifyOverridesChanged","readSessionId","match","slotDecls","getRegisteredSlots","s","forcePersonaKeyed","apiKey","apiBaseUrl","persona","res","getRegisteredSections","getRegistered","c","data","__spreadProps","forcePersonaLocal","mod","outcome","confidenceBand","resetAll","getOverrides","clearVariantOverride","stale","i","key","SNAPSHOT_STORAGE_KEY_PREFIX","e","btn","active","SentientMark","size","AdaptiveDevtools","open","setOpen","useState","activePersona","setActivePersona","mounted","setMounted","force","useReducer","useSyncExternalStore","subscribeRegistry","getRegistryVersion","useEffect","config","readDevtoolsConfig","useLocalEngine","components","slots","overrides","slotOverrides","getSlotOverrides","maybeExitPreview","choose","resetVariant","chooseSlotArm","arm","setSlotOverride","chooseSlotDim","dim","value","dims","current","next","d","values","resetSlot","clearSlotOverride","choosePersona","getPreviewMode","PERSONAS","p","PERSONA_DISPLAY","v","ov","o"]}
1
+ {"version":3,"sources":["../src/devtools/index.tsx","../src/devtools-registry.ts","../src/devtools-overrides.ts","../src/devtools-slot-overrides.ts","../src/preview-mode.ts","../src/override-events.ts","../src/devtools-config.ts"],"sourcesContent":["'use client';\nimport { useEffect, useReducer, useState, useSyncExternalStore, type CSSProperties } from 'react';\nimport { PERSONAS, PERSONA_DISPLAY, confidenceBand } from '@sentientui/policy';\nimport { SNAPSHOT_STORAGE_KEY_PREFIX } from '@sentientui/core';\nimport {\n getRegistered,\n getRegisteredSlots,\n getRegisteredSections,\n subscribeRegistry,\n getRegistryVersion,\n type RegisteredSlot,\n} from '../devtools-registry.js';\nimport { setVariantOverride, clearVariantOverride, getOverrides } from '../devtools-overrides.js';\nimport { setSlotOverride, clearSlotOverride, getSlotOverrides } from '../devtools-slot-overrides.js';\nimport { setPreviewMode, getPreviewMode } from '../preview-mode.js';\nimport { notifyOverridesChanged } from '../override-events.js';\nimport { readDevtoolsConfig, type DevtoolsConfig } from '../devtools-config.js';\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\nconst IS_PROD = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport const LOCAL_MODE_DEVTOOLS_BANNER =\n 'Local mode — decisions are simulated; add a key to learn from real traffic';\n\ntype OutcomeToApply = {\n assignments?: Record<string, string>;\n layoutOrder?: string[] | null;\n slots?: Record<string, string | Record<string, string>>;\n personaAttributes?: { persona: string; confidence: 'low' | 'medium' | 'high' };\n};\n\ntype OverrideWindow = Window & {\n __sentient_layout_override?: string[];\n __sentient_slot_overrides?: Record<string, string | Record<string, string>>;\n};\n\n/** The order the page is rendering: a previewed override, else what was registered. */\nfunction currentLayout(): string[] {\n const forced = (window as unknown as OverrideWindow).__sentient_layout_override;\n const registered = getRegisteredSections();\n if (!forced || forced.length === 0) return registered;\n // Registered ids the override omits still render (useLayoutOrder returns the\n // override verbatim, and the app maps whatever ids it is given), so show them\n // trailing rather than dropping them from the list you are dragging.\n return [...forced, ...registered.filter((id) => !forced.includes(id))];\n}\n\n/**\n * Move `from` to `to` within the current order and preview it.\n *\n * Writes the whole order rather than swapping neighbours: the point is to try an\n * arrangement, not to walk one block up a list one press at a time.\n */\nfunction reorderLayout(from: number, to: number): void {\n const order = currentLayout();\n if (from === to || from < 0 || to < 0 || from >= order.length || to >= order.length) return;\n const next = [...order];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved!);\n (window as unknown as OverrideWindow).__sentient_layout_override = next;\n setPreviewMode(true); // an arrangement you are trying must not train the bandit\n notifyOverridesChanged();\n}\n\nfunction resetLayout(): void {\n delete (window as unknown as OverrideWindow).__sentient_layout_override;\n notifyOverridesChanged();\n}\n\n/** Apply a simulated outcome across every surface: variants, layout, slots/tokens, persona attrs. */\nfunction applyOutcome(result: OutcomeToApply): void {\n for (const [id, variantId] of Object.entries(result.assignments ?? {})) {\n setVariantOverride(id, variantId);\n }\n const w = window as unknown as OverrideWindow;\n if (result.layoutOrder && result.layoutOrder.length > 0) {\n w.__sentient_layout_override = result.layoutOrder;\n }\n if (result.slots) {\n w.__sentient_slot_overrides = { ...(w.__sentient_slot_overrides ?? {}), ...result.slots };\n }\n if (result.personaAttributes) {\n document.documentElement.dataset.sentientPersona = result.personaAttributes.persona;\n document.documentElement.dataset.sentientConfidence = result.personaAttributes.confidence;\n }\n setPreviewMode(true); // suppress events while previewing\n notifyOverridesChanged(); // re-render layout/slot consumers\n}\n\nfunction readSessionId(): string {\n try {\n const match = document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);\n if (match) return decodeURIComponent(match[1]);\n } catch {\n /* ignore */\n }\n return 'devtools-preview';\n}\n\nfunction slotDecls(): Array<{ id: string; arms?: string[]; dims?: RegisteredSlot['dims'] }> {\n return getRegisteredSlots().map((s) => ({\n id: s.id,\n ...(s.arms ? { arms: s.arms } : {}),\n ...(s.dims ? { dims: s.dims } : {}),\n }));\n}\n\n/** Keyed mode: simulate via /v1/explain (read-only, event-free). */\nasync function forcePersonaKeyed(apiKey: string, apiBaseUrl: string, persona: string): Promise<void> {\n const res = await fetch(`${apiBaseUrl}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({\n persona,\n sections: getRegisteredSections().map((id) => ({ id })),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n }),\n });\n if (!res.ok) return;\n const data = (await res.json()) as OutcomeToApply;\n applyOutcome({\n ...data,\n personaAttributes: data.personaAttributes ?? { persona, confidence: 'high' },\n });\n}\n\n/** Local mode: simulate via the deterministic local engine — zero network. */\nasync function forcePersonaLocal(persona: string): Promise<void> {\n const mod = await import('@sentientui/core/local');\n if (!mod.LOCAL_ENGINE_AVAILABLE) return;\n const outcome = mod\n .createLocalEngine({ sessionId: readSessionId(), forcedPersona: persona })\n .decide({\n sections: getRegisteredSections(),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n });\n applyOutcome({\n assignments: outcome.assignments,\n layoutOrder: outcome.layoutOrder,\n slots: outcome.slots,\n personaAttributes: {\n persona: outcome.persona,\n confidence: confidenceBand(outcome.confidence),\n },\n });\n}\n\n/** Reset: clear the decision snapshot + every override, then reload to re-decide. */\nfunction resetAll(): void {\n for (const id of Object.keys(getOverrides())) clearVariantOverride(id);\n const w = window as unknown as OverrideWindow;\n delete w.__sentient_layout_override;\n delete w.__sentient_slot_overrides;\n delete document.documentElement.dataset.sentientPersona;\n delete document.documentElement.dataset.sentientConfidence;\n try {\n const stale: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(SNAPSHOT_STORAGE_KEY_PREFIX)) stale.push(key);\n }\n for (const key of stale) localStorage.removeItem(key);\n } catch {\n /* ignore */\n }\n setPreviewMode(false);\n notifyOverridesChanged();\n try {\n window.location.reload();\n } catch {\n /* jsdom */\n }\n}\n\nconst btn = (active: boolean): CSSProperties => ({\n padding: '2px 8px',\n borderRadius: 4,\n border: '1px solid #444',\n background: active ? '#3b82f6' : '#222',\n color: '#eee',\n cursor: 'pointer',\n});\n\n/** Sentient \"S.\" wordmark, monoline — white strokes for the black launcher button. */\nfunction SentientMark({ size = 26 }: { size?: number } = {}): JSX.Element {\n return (\n <svg width={size} height={size} viewBox=\"0 0 32 32\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6\"\n stroke=\"#fff\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path d=\"M10 22H17\" stroke=\"#fff\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n <circle cx=\"20.6\" cy=\"22\" r=\"2.1\" fill=\"#fff\" />\n </svg>\n );\n}\n\nexport function AdaptiveDevtools({ apiKey }: { apiKey?: string } = {}): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const [activePersona, setActivePersona] = useState<string | null>(null);\n const [dragFrom, setDragFrom] = useState<number | null>(null);\n const [mounted, setMounted] = useState(false);\n const [, force] = useReducer((n: number) => n + 1, 0);\n // Re-render when the component/slot registry changes. useSyncExternalStore\n // (not a manual useEffect subscription) so the subscription can't go stale\n // across Next Fast Refresh — a stale listener was why the panel needed a hard\n // refresh to pick up a renamed id.\n useSyncExternalStore(subscribeRegistry, getRegistryVersion, () => 0);\n // Client-mount gate: render nothing during SSR / the first paint so the widget\n // never reads `window` on the server. Lets consumers drop `<AdaptiveDevtools/>`\n // straight into a tree without a `dynamic(..., { ssr: false })` wrapper.\n useEffect(() => setMounted(true), []);\n\n // Never render in production, even if imported by mistake. (Hooks run first\n // so the rules of hooks hold regardless of these early returns.)\n if (IS_PROD) return null;\n if (!mounted) return null;\n\n const config: DevtoolsConfig = readDevtoolsConfig() ?? {\n apiKey: apiKey ?? '',\n apiBaseUrl: DEFAULT_API_BASE_URL,\n isLocal: false,\n };\n const useLocalEngine = config.isLocal || !config.apiKey;\n const components = getRegistered();\n const slots = getRegisteredSlots();\n const overrides = getOverrides();\n const slotOverrides = getSlotOverrides();\n const sections = currentLayout();\n const layoutForced = (window as unknown as OverrideWindow).__sentient_layout_override !== undefined;\n\n function onReorder(from: number, to: number): void {\n reorderLayout(from, to);\n force();\n }\n function onResetLayout(): void {\n resetLayout();\n maybeExitPreview();\n force();\n }\n\n // Preview mode stays on while ANY override (variant, slot or layout) is\n // active. Omitting layout here let clearing the last variant re-enable event\n // recording while a previewed section order was still on screen.\n function maybeExitPreview(): void {\n if (\n Object.keys(getOverrides()).length === 0 &&\n Object.keys(getSlotOverrides()).length === 0 &&\n (window as unknown as OverrideWindow).__sentient_layout_override === undefined\n ) {\n setPreviewMode(false);\n }\n }\n\n function choose(id: string, variantId: string): void {\n setVariantOverride(id, variantId);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetVariant(id: string): void {\n clearVariantOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function chooseSlotArm(id: string, arm: string): void {\n setSlotOverride(id, arm);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function chooseSlotDim(id: string, dim: string, value: string, dims: RegisteredSlot['dims']): void {\n const current = getSlotOverrides()[id];\n // Merge onto the existing forced object, or seed from each dim's baseline\n // (first value) so unset dims stay at baseline instead of vanishing.\n const next: Record<string, string> =\n current && typeof current === 'object'\n ? { ...current }\n : Object.fromEntries(Object.entries(dims ?? {}).map(([d, values]) => [d, values[0]!]));\n next[dim] = value;\n setSlotOverride(id, next);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetSlot(id: string): void {\n clearSlotOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function choosePersona(persona: string): void {\n setActivePersona(persona);\n const apply = useLocalEngine\n ? forcePersonaLocal(persona)\n : forcePersonaKeyed(config.apiKey, config.apiBaseUrl, persona);\n void apply.then(force);\n }\n\n return (\n <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 2147483647, fontFamily: 'system-ui' }}>\n {/* Panel stays mounted and animates in/out from the button's corner, so the\n launcher below never shifts. transform-origin is the button (bottom-right). */}\n <div\n aria-hidden={!open}\n style={{\n position: 'absolute',\n bottom: 52,\n right: 0,\n transformOrigin: 'bottom right',\n transition: 'opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)',\n opacity: open ? 1 : 0,\n transform: open ? 'translateY(0) scale(1)' : 'translateY(6px) scale(.96)',\n pointerEvents: open ? 'auto' : 'none',\n }}\n >\n <div style={{ width: 300, maxHeight: 460, overflowY: 'auto', background: '#111', color: '#eee',\n borderRadius: 8, padding: 12, boxShadow: '0 8px 30px rgba(0,0,0,.4)', fontSize: 12 }}>\n {config.isLocal && (\n <div style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4,\n padding: '6px 8px', marginBottom: 8 }}>\n {LOCAL_MODE_DEVTOOLS_BANNER}\n </div>\n )}\n <div style={{ opacity: .7, marginBottom: 8 }}>\n {components.length} component{components.length === 1 ? '' : 's'} · {getPreviewMode() ? 'preview — writing nothing' : 'live'}\n </div>\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Preview persona</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {PERSONAS.map((p) => (\n <button key={p} onClick={() => choosePersona(p)} style={btn(activePersona === p)}>\n {PERSONA_DISPLAY[p]}\n </button>\n ))}\n {(activePersona !== null || Object.keys(overrides).length > 0 || Object.keys(slotOverrides).length > 0) && (\n <button onClick={resetAll} style={{ ...btn(false), color: '#aaa' }}>\n Reset\n </button>\n )}\n </div>\n </div>\n {sections.length > 0 && (\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 4 }}>\n <span style={{ opacity: .7 }}>Layout — drag to reorder</span>\n {layoutForced && (\n // Distinct accessible name: the per-variant and per-slot resets\n // below are also labelled \"reset\", and three identical buttons\n // in one panel is ambiguous to a screen reader and to tests.\n <button\n aria-label=\"Reset section order\"\n onClick={onResetLayout}\n style={{ ...btn(false), color: '#aaa' }}\n >\n reset\n </button>\n )}\n </div>\n {/* Drop-on-row inserts at that row's position, so any block can go\n anywhere in one gesture. The whole order is written on each\n drop — see reorderLayout. */}\n <ul aria-label=\"Section order\" style={{ listStyle: 'none', margin: 0, padding: 0 }}>\n {sections.map((id, i) => (\n <li\n key={id}\n draggable\n onDragStart={() => setDragFrom(i)}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => {\n e.preventDefault();\n if (dragFrom !== null) onReorder(dragFrom, i);\n setDragFrom(null);\n }}\n onDragEnd={() => setDragFrom(null)}\n style={{\n display: 'flex', alignItems: 'center', gap: 6, padding: '4px 6px', marginBottom: 2,\n borderRadius: 4, border: '1px solid #262626', cursor: 'grab',\n background: dragFrom === i ? '#1e293b' : '#181818',\n opacity: dragFrom !== null && dragFrom !== i ? .6 : 1,\n }}\n >\n <span style={{ opacity: .4, minWidth: 10, fontVariantNumeric: 'tabular-nums' }}>{i + 1}</span>\n <span aria-hidden=\"true\" style={{ opacity: .35 }}>⠿</span>\n <span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {id}\n </span>\n </li>\n ))}\n </ul>\n </div>\n )}\n {components.length === 0 && slots.length === 0 && sections.length === 0 && (\n <div style={{ opacity: .6 }}>No components, sections or slots on this page yet.</div>\n )}\n {components.map((c) => (\n <div key={c.id} style={{ borderTop: '1px solid #333', padding: '8px 0' }}>\n <div style={{ fontWeight: 600 }}>{c.id}{c.goal ? ` · goal: ${c.goal}` : ''}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {c.variantIds.map((v) => (\n <button key={v} onClick={() => choose(c.id, v)} style={btn(overrides[c.id] === v)}>\n {v}\n </button>\n ))}\n {overrides[c.id] && (\n <button onClick={() => resetVariant(c.id)} style={{ ...btn(false), color: '#aaa' }}>\n reset\n </button>\n )}\n </div>\n </div>\n ))}\n {slots.length > 0 && (\n <div style={{ borderTop: '1px solid #333', paddingTop: 8, marginTop: 4 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Slots</div>\n {slots.map((s) => {\n const ov = slotOverrides[s.id];\n return (\n <div key={s.id} style={{ padding: '6px 0' }}>\n <div style={{ fontWeight: 600 }}>{s.id}</div>\n {s.arms && (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {s.arms.map((arm) => (\n <button key={arm} onClick={() => chooseSlotArm(s.id, arm)} style={btn(ov === arm)}>\n {arm}\n </button>\n ))}\n </div>\n )}\n {s.dims && Object.entries(s.dims).map(([dim, values]) => (\n <div key={dim} style={{ marginTop: 4 }}>\n <div style={{ opacity: .6, fontSize: 11 }}>{dim}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {values.map((v) => (\n <button\n key={v}\n onClick={() => chooseSlotDim(s.id, dim, v, s.dims)}\n style={btn(!!ov && typeof ov === 'object' && ov[dim] === v)}\n >\n {v}\n </button>\n ))}\n </div>\n </div>\n ))}\n {ov !== undefined && (\n <button onClick={() => resetSlot(s.id)} style={{ ...btn(false), color: '#aaa', marginTop: 4 }}>\n reset\n </button>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n <button\n aria-label=\"Sentient DevTools\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n style={{ width: 44, height: 44, borderRadius: 12, border: '1px solid #2a2a2a', background: '#000',\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 0,\n cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,0,0,.4)' }}\n >\n <SentientMark />\n </button>\n </div>\n );\n}\n","import { isDevBuild } from './adaptive-shared.js';\n\nexport type RegisteredComponent = { id: string; variantIds: string[]; goal?: string };\nexport type RegisteredSlot = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n};\n\ntype RegistryState = {\n components: Map<string, RegisteredComponent>;\n slots: Map<string, RegisteredSlot>;\n sections: string[];\n listeners: Set<() => void>;\n /** Bumped on every mutation so `useSyncExternalStore` can read a stable, comparable snapshot. */\n version: number;\n};\n\n// Shared through a window global: the main entry and the /devtools entry are\n// separate bundles, each with its own copy of this module — module-local\n// state would give the devtools an always-empty registry in published apps.\nconst ssrFallback: RegistryState = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n};\n\nfunction state(): RegistryState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_registry?: RegistryState };\n if (!w.__sentient_registry) {\n w.__sentient_registry = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n };\n }\n return w.__sentient_registry;\n}\n\nfunction emit(): void {\n // Bump BEFORE notifying so a useSyncExternalStore consumer re-reading its\n // snapshot inside the notification sees the new value and re-renders.\n state().version += 1;\n for (const fn of state().listeners) fn();\n}\n\n// The registry exists solely to feed the opt-in devtools panel, which is a\n// dev-only surface. In a production build there is no panel reading it, so\n// every register call is dead work plus a `window.__sentient_registry`\n// footprint on the customer's page. Short-circuit to a noop in production —\n// every <Adaptive>/useAdaptive/slot mount calls one of these.\nconst NOOP_UNREGISTER = (): void => undefined;\n\n/** Register (or re-register) a component. Returns an unregister function. */\nexport function registerComponent(c: RegisteredComponent): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().components.set(c.id, c);\n emit();\n return () => {\n state().components.delete(c.id);\n emit();\n };\n}\n\n/** Register (or re-register) a slot declaration. Returns an unregister function. */\nexport function registerSlot(s: RegisteredSlot): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().slots.set(s.id, s);\n emit();\n return () => {\n state().slots.delete(s.id);\n emit();\n };\n}\n\n/** Register the page's declared section ids (from AdaptiveRoot/provider). */\nexport function registerSections(sections: string[]): void {\n if (!isDevBuild()) return;\n state().sections = [...sections];\n emit();\n}\n\nexport function getRegistered(): RegisteredComponent[] {\n return [...state().components.values()];\n}\n\nexport function getRegisteredSlots(): RegisteredSlot[] {\n return [...state().slots.values()];\n}\n\nexport function getRegisteredSections(): string[] {\n return [...state().sections];\n}\n\nexport function subscribeRegistry(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/** Monotonic snapshot for `useSyncExternalStore` — changes on every registry mutation. */\nexport function getRegistryVersion(): number {\n return state().version;\n}\n","function store(): Record<string, string> {\n const w = window as unknown as { __sentient_overrides?: Record<string, string> };\n if (!w.__sentient_overrides) w.__sentient_overrides = {};\n return w.__sentient_overrides;\n}\n\n/** Force `componentId` to render `variantId` — read by `useAssignment`. */\nexport function setVariantOverride(componentId: string, variantId: string): void {\n store()[componentId] = variantId;\n}\n\nexport function clearVariantOverride(componentId: string): void {\n delete store()[componentId];\n}\n\nexport function getOverrides(): Record<string, string> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n assign: (componentId, variantIds, agentData, agentDataByVariant) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","/** Provider → devtools config handoff. Window-backed: the /devtools entry is a\n * separate bundle and cannot share the provider's React context instance. */\nexport type DevtoolsConfig = {\n apiKey: string;\n apiBaseUrl: string;\n isLocal: boolean;\n};\n\ntype ConfigWindow = Window & { __sentient_devtools_config?: DevtoolsConfig };\n\nexport function publishDevtoolsConfig(config: DevtoolsConfig): void {\n if (typeof window === 'undefined') return;\n (window as ConfigWindow).__sentient_devtools_config = config;\n}\n\nexport function readDevtoolsConfig(): DevtoolsConfig | null {\n if (typeof window === 'undefined') return null;\n return (window as ConfigWindow).__sentient_devtools_config ?? null;\n}\n"],"mappings":";ocACA,OAAS,aAAAA,GAAW,cAAAC,GAAY,YAAAC,EAAU,wBAAAC,OAAgD,QAC1F,OAAS,YAAAC,GAAU,mBAAAC,GAAiB,kBAAAC,OAAsB,qBAC1D,OAAS,+BAAAC,OAAmC,mBCkB5C,IAAMC,GAA6B,CACjC,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,EAEA,SAASC,GAAuB,CAC9B,GAAI,OAAO,QAAW,YAAa,OAAOD,GAC1C,IAAME,EAAI,OACV,OAAKA,EAAE,sBACLA,EAAE,oBAAsB,CACtB,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU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AAYA,EAAGd,CAAG,IAAM,CAAC,EAEzD,YAJI,CAKP,CACD,EACH,IAZQA,CAaV,CACD,EACAc,IAAO,QACN1G,EAAC,UAAO,QAAS,IAAMkG,GAAUnE,EAAE,EAAE,EAAG,MAAOS,EAAAd,EAAA,GAAK2B,EAAI,EAAK,GAAd,CAAiB,MAAO,OAAQ,UAAW,CAAE,GAAG,iBAE/F,IA9BMtB,EAAE,EAgCZ,CAEJ,CAAC,GACH,GAEJ,EACF,EACA/B,EAAC,UACC,aAAW,oBACX,gBAAe0D,EACf,QAAS,IAAMC,EAASgD,GAAM,CAACA,CAAC,EAChC,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,aAAc,GAAI,OAAQ,oBAAqB,WAAY,OAClF,QAAS,OAAQ,WAAY,SAAU,eAAgB,SAAU,QAAS,EAC1E,OAAQ,UAAW,UAAW,2BAA4B,EAEnE,SAAA3G,EAACuD,GAAA,EAAa,EAChB,GACF,CAEJ","names":["useEffect","useReducer","useState","useSyncExternalStore","PERSONAS","PERSONA_DISPLAY","confidenceBand","SNAPSHOT_STORAGE_KEY_PREFIX","ssrFallback","state","w","getRegistered","state","getRegisteredSlots","getRegisteredSections","subscribeRegistry","fn","listeners","getRegistryVersion","store","w","setVariantOverride","componentId","variantId","clearVariantOverride","getOverrides","__spreadValues","store","w","setSlotOverride","slotId","result","clearSlotOverride","getSlotOverrides","__spreadValues","ssrFallback","state","w","setPreviewMode","on","s","fn","getPreviewMode","EVENT","notifyOverridesChanged","_a","w","EVENT","readDevtoolsConfig","_a","jsx","jsxs","_a","IS_PROD","DEFAULT_API_BASE_URL","LOCAL_MODE_DEVTOOLS_BANNER","currentLayout","forced","registered","getRegisteredSections","id","reorderLayout","from","to","order","next","moved","setPreviewMode","notifyOverridesChanged","resetLayout","applyOutcome","result","_b","variantId","setVariantOverride","w","__spreadValues","readSessionId","match","slotDecls","getRegisteredSlots","s","forcePersonaKeyed","apiKey","apiBaseUrl","persona","res","getRegistered","c","data","__spreadProps","forcePersonaLocal","mod","outcome","confidenceBand","resetAll","getOverrides","clearVariantOverride","stale","i","key","SNAPSHOT_STORAGE_KEY_PREFIX","e","btn","active","SentientMark","size","AdaptiveDevtools","open","setOpen","useState","activePersona","setActivePersona","dragFrom","setDragFrom","mounted","setMounted","force","useReducer","useSyncExternalStore","subscribeRegistry","getRegistryVersion","useEffect","config","readDevtoolsConfig","useLocalEngine","components","slots","overrides","slotOverrides","getSlotOverrides","sections","layoutForced","onReorder","onResetLayout","maybeExitPreview","choose","resetVariant","chooseSlotArm","arm","setSlotOverride","chooseSlotDim","dim","value","dims","current","d","values","resetSlot","clearSlotOverride","choosePersona","getPreviewMode","PERSONAS","p","PERSONA_DISPLAY","v","ov","o"]}