@sentientui/react 0.30.0 → 0.31.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.
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- "use strict";var se=Object.create;var h=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,T=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&F(e,n,t[n]);if(T)for(var n of T(t))fe.call(t,n)&&F(e,n,t[n]);return e},$=(e,t)=>ae(e,ce(t));var ge=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!B.call(e,i)&&i!==n&&h(e,i,{get:()=>t[i],enumerable:!(s=le(t,i))||s.enumerable});return e};var U=(e,t,n)=>(n=e!=null?se(ue(e)):{},V(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(h({},"__esModule",{value:!0}),e);var Pe={};ge(Pe,{renderWithSentient:()=>ke});module.exports=pe(Pe);var oe=require("@testing-library/react");var r=require("react"),k=require("@sentientui/core");var me=new Map,ve=new Map;function z(e,t){me.set(e,t);let n=ve.get(e);if(n)for(let s of n)try{s(t)}catch(i){}}var _e={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function A(){return j().on}function H(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function q(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,s,i)=>e.assign(t,n,s,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ye="sentient:overrides-changed";function x(){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(ye))}function X(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function R(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function O(){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 we(){O().version+=1;for(let e of O().listeners)e()}function I(e){R()&&(O().sections=[...e],we())}var J="0.30.0",D=J!=="0.0.0-dev"?{name:"react",version:J}:void 0;function he(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function L(e,t){he()[e]=t}function be(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function G(e,t){be()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",M="sentient-cell-preview-bar",W="__preview__";function Z(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(M))return;let t,n;try{let g=new URLSearchParams(window.location.search);t=g.get(Q),n=g.get(Y)}catch(g){return}if(!t||!n)return;let s=n.lastIndexOf("~");if(s<=0)return;let i=n.slice(0,s),f=n.slice(s+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async g=>{if(!g.ok){E(g.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await g.json();if(c.blocks!=null)L(i,{kind:"arms",blocks:{[W]:c.blocks}}),G(i,W);else if(c.content!=null)L(i,{kind:"arms",content:c.content}),G(i,W);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${i}"]`))==null||y.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var i;if(document.getElementById(M))return;let t=document.createElement("div");t.id=M,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let s=document.createElement("button");s.textContent="Exit preview",Object.assign(s.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),s.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(Q),f.searchParams.delete(Y),window.location.assign(f.toString())},t.append(n,s),((i=document.body)!=null?i:document.documentElement).append(t)}var ne=require("react/jsx-runtime");function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,k.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ee="https://api.sentient-ui.com/v1",xe=(0,r.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ee,debug:!1});function Re(e){let[t,n]=(0,r.useState)(!1),s=(0,r.useRef)(e);s.current=e;let{cookie:i,value:f,event:_}=e!=null?e:{},g=typeof(e==null?void 0:e.check)=="function";return(0,r.useEffect)(()=>{let c=()=>{var w;let d=s.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let b=`${d.cookie}=${(w=d.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(P=>P.trim()===b)};if(n(c()),!_)return;let y=()=>{n(c())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[i,f,_,g]),t}function te(e){var K,N;let[t,n]=(0,r.useState)(null),[s]=(0,r.useState)(()=>{var o;return(o=e.sessionSegment)!=null?o:Ce()}),[i,f]=(0,r.useState)(A());(0,r.useEffect)(()=>H(()=>f(A())),[]),(0,r.useEffect)(()=>{Z(e.apiBaseUrl)},[]);let _=Re(e.consentFrom),g=e.consentFrom?e.consent===!0||_:e.consent,c=(0,r.useRef)(null);(0,r.useEffect)(()=>{var S;if(g===!1&&!e.preConsentBehavior){(S=c.current)==null||S.destroy(),c.current=null,n(null);return}let o=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:s,consent:g,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),u=!1,a=null,l=null,p=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{u||(l=C(m,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:m})=>{u||(a=m($(v({},o),{graph:!0,captureDomText:e.captureDomText===!0})),c.current=a,n(a),p(a))}):(a=(0,k.init)(o),c.current=a,n(a),p(a)),()=>{u=!0,l==null||l(),a==null||a.dispose()}},[g]),(0,r.useEffect)(()=>{if(!t)return;let o=!1,u=async()=>{if(o)return;let l;try{l=await t.fetchWeights()}catch(p){return}if(!o)for(let p of l){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(m=>{var C;return{variantId:m.variantId,pulls:m.pulls,avgReward:(C=m.avgReward)!=null?C:0}})};z(p.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{o=!0,clearInterval(a)}},[t]);let y=(K=e.ssrFallback)!=null?K:"first",d=((N=e.apiBaseUrl)!=null?N:ee).replace(/\/$/,""),b=(0,r.useRef)(null);(0,r.useEffect)(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let o={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=b.current;if(b.current=o,u!==null)for(let l of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[l],o[l])||console.warn(`[sentient] AdaptiveProvider: \`${l}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,d]),(0,r.useEffect)(()=>{var o;typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production"||X({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,r.useEffect)(()=>{let o=e.initialLayoutOrder;if(o&&o.length>0){I(o);return}e.declaredSections&&e.declaredSections.length>0&&I(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,r.useEffect)(()=>{if(!R())return;let o=e.declaredSections;if(!o||o.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),l=>l.getAttribute("data-sentient-id"))),a=o.filter(l=>!u.has(l));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(l=>`"${l}"`).join(", ")} ${a.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let w=(0,r.useMemo)(()=>t&&i?q(t):t,[t,i]),P=(0,r.useMemo)(()=>{var o,u,a,l,p,S,m;return{client:w,apiKey:e.apiKey,initialAssignments:(o=e.initialAssignments)!=null?o:{},sessionSegment:s,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(l=e.initialSlotConfig)!=null?l:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:d,debug:(m=e.debug)!=null?m:!1}},[w,e.apiKey,e.initialAssignments,s,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ne.jsx)(xe.Provider,{value:P,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,s,i;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(s=e.confidence)!=null?s:1};try{let f=document.documentElement;f.setAttribute("data-sentient-persona",e.persona),f.setAttribute("data-sentient-confidence",Ee((i=e.confidence)!=null?i:1))}catch(f){}}else delete t.__sentient_persona_override;x()}var re=require("react/jsx-runtime");function ke(e,t={},n){return ie(t),(0,oe.render)((0,re.jsx)(te,{apiKey:"pk_test",context:"saas",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
2
+ "use strict";var se=Object.create;var h=Object.defineProperty,ae=Object.defineProperties,le=Object.getOwnPropertyDescriptor,ce=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,T=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&F(e,n,t[n]);if(T)for(var n of T(t))fe.call(t,n)&&F(e,n,t[n]);return e},$=(e,t)=>ae(e,ce(t));var ge=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of de(t))!B.call(e,i)&&i!==n&&h(e,i,{get:()=>t[i],enumerable:!(s=le(t,i))||s.enumerable});return e};var U=(e,t,n)=>(n=e!=null?se(ue(e)):{},V(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),pe=e=>V(h({},"__esModule",{value:!0}),e);var Pe={};ge(Pe,{renderWithSentient:()=>ke});module.exports=pe(Pe);var oe=require("@testing-library/react");var r=require("react"),k=require("@sentientui/core");var me=new Map,ve=new Map;function z(e,t){me.set(e,t);let n=ve.get(e);if(n)for(let s of n)try{s(t)}catch(i){}}var _e={on:!1,listeners:new Set};function j(){if(typeof window=="undefined")return _e;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function A(){return j().on}function H(e){let t=j().listeners;return t.add(e),()=>{t.delete(e)}}function q(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,s,i)=>e.assign(t,n,s,i),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ye="sentient:overrides-changed";function x(){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(ye))}function X(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function R(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var Se={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function O(){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 we(){O().version+=1;for(let e of O().listeners)e()}function I(e){R()&&(O().sections=[...e],we())}var J="0.31.0",D=J!=="0.0.0-dev"?{name:"react",version:J}:void 0;function he(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function L(e,t){he()[e]=t}function be(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function G(e,t){be()[e]=t}var Q="sentient_editor",Y="sentient_preview_cell",M="sentient-cell-preview-bar",W="__preview__";function Z(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(M))return;let t,n;try{let g=new URLSearchParams(window.location.search);t=g.get(Q),n=g.get(Y)}catch(g){return}if(!t||!n)return;let s=n.lastIndexOf("~");if(s<=0)return;let i=n.slice(0,s),f=n.slice(s+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(i)}&persona=${encodeURIComponent(f)}`,{headers:{authorization:`Bearer ${t}`}}).then(async g=>{if(!g.ok){E(g.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let c=await g.json();if(c.blocks!=null)L(i,{kind:"arms",blocks:{[W]:c.blocks}}),G(i,W);else if(c.content!=null)L(i,{kind:"arms",content:c.content}),G(i,W);else{E("Nothing to preview in that square yet.");return}x(),E(`Previewing \u201C${c.slotName}\u201D for ${c.personaDisplay}${c.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${i}"]`))==null||y.scrollIntoView({block:"center"})}catch(d){}},300)}).catch(()=>E("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function E(e){var i;if(document.getElementById(M))return;let t=document.createElement("div");t.id=M,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let s=document.createElement("button");s.textContent="Exit preview",Object.assign(s.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),s.onclick=()=>{let f=new URL(window.location.href);f.searchParams.delete(Q),f.searchParams.delete(Y),window.location.assign(f.toString())},t.append(n,s),((i=document.body)!=null?i:document.documentElement).append(t)}var ne=require("react/jsx-runtime");function Ce(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return(0,k.deriveSessionSegment)({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var ee="https://api.sentient-ui.com/v1",xe=(0,r.createContext)({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:ee,debug:!1});function Re(e){let[t,n]=(0,r.useState)(!1),s=(0,r.useRef)(e);s.current=e;let{cookie:i,value:f,event:_}=e!=null?e:{},g=typeof(e==null?void 0:e.check)=="function";return(0,r.useEffect)(()=>{let c=()=>{var w;let d=s.current;if(!d)return!1;if(d.check)return d.check()===!0;if(!d.cookie||typeof document=="undefined")return!1;let b=`${d.cookie}=${(w=d.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(P=>P.trim()===b)};if(n(c()),!_)return;let y=()=>{n(c())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[i,f,_,g]),t}function te(e){var K,N;let[t,n]=(0,r.useState)(null),[s]=(0,r.useState)(()=>{var o;return(o=e.sessionSegment)!=null?o:Ce()}),[i,f]=(0,r.useState)(A());(0,r.useEffect)(()=>H(()=>f(A())),[]),(0,r.useEffect)(()=>{Z(e.apiBaseUrl)},[]);let _=Re(e.consentFrom),g=e.consentFrom?e.consent===!0||_:e.consent,c=(0,r.useRef)(null);(0,r.useEffect)(()=>{var S;if(g===!1&&!e.preConsentBehavior){(S=c.current)==null||S.destroy(),c.current=null,n(null);return}let o=v({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:s,consent:g,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},D?{sdk:D}:{}),u=!1,a=null,l=null,p=m=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:C})=>{u||(l=C(m,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:m})=>{u||(a=m($(v({},o),{graph:!0,captureDomText:e.captureDomText===!0})),c.current=a,n(a),p(a))}):(a=(0,k.init)(o),c.current=a,n(a),p(a)),()=>{u=!0,l==null||l(),a==null||a.dispose()}},[g]),(0,r.useEffect)(()=>{if(!t)return;let o=!1,u=async()=>{if(o)return;let l;try{l=await t.fetchWeights()}catch(p){return}if(!o)for(let p of l){let S={componentId:p.componentId,updatedAt:p.updatedAt,variants:p.variants.map(m=>{var C;return{variantId:m.variantId,pulls:m.pulls,avgReward:(C=m.avgReward)!=null?C:0}})};z(p.componentId,S)}};u();let a=setInterval(()=>{u()},6e4);return()=>{o=!0,clearInterval(a)}},[t]);let y=(K=e.ssrFallback)!=null?K:"first",d=((N=e.apiBaseUrl)!=null?N:ee).replace(/\/$/,""),b=(0,r.useRef)(null);(0,r.useEffect)(()=>{var a;if(typeof process!="undefined"&&((a=process.env)==null?void 0:a.NODE_ENV)==="production")return;let o={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:d},u=b.current;if(b.current=o,u!==null)for(let l of["apiKey","context","country","persona","apiBaseUrl"])Object.is(u[l],o[l])||console.warn(`[sentient] AdaptiveProvider: \`${l}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,d]),(0,r.useEffect)(()=>{var o;typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production"||X({apiKey:e.apiKey,apiBaseUrl:d,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,d]),(0,r.useEffect)(()=>{let o=e.initialLayoutOrder;if(o&&o.length>0){I(o);return}e.declaredSections&&e.declaredSections.length>0&&I(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),(0,r.useEffect)(()=>{if(!R())return;let o=e.declaredSections;if(!o||o.length===0||typeof document=="undefined")return;let u=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),l=>l.getAttribute("data-sentient-id"))),a=o.filter(l=>!u.has(l));a.length>0&&console.warn(`[SentientUI] Declared section${a.length>1?"s":""} ${a.map(l=>`"${l}"`).join(", ")} ${a.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let w=(0,r.useMemo)(()=>t&&i?q(t):t,[t,i]),P=(0,r.useMemo)(()=>{var o,u,a,l,p,S,m;return{client:w,apiKey:e.apiKey,initialAssignments:(o=e.initialAssignments)!=null?o:{},sessionSegment:s,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(u=e.initialLayoutOrder)!=null?u:null,initialSlots:(a=e.initialSlots)!=null?a:{},initialSlotConfig:(l=e.initialSlotConfig)!=null?l:{},initialPalette:(p=e.initialPalette)!=null?p:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:d,debug:(m=e.debug)!=null?m:!1}},[w,e.apiKey,e.initialAssignments,s,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,d,e.debug]);return(0,ne.jsx)(xe.Provider,{value:P,children:e.children})}function Ee(e){return e<.3?"low":e<.7?"medium":"high"}function ie(e={}){var n,s,i;let t=window;if(t.__sentient_overrides=v({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=v({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=v({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(s=e.confidence)!=null?s:1};try{let f=document.documentElement;f.setAttribute("data-sentient-persona",e.persona),f.setAttribute("data-sentient-confidence",Ee((i=e.confidence)!=null?i:1))}catch(f){}}else delete t.__sentient_persona_override;x()}var re=require("react/jsx-runtime");function ke(e,t={},n){return ie(t),(0,oe.render)((0,re.jsx)(te,{apiKey:"pk_test",context:"saas",consent:!1,children:e}),n)}0&&(module.exports={renderWithSentient});
3
3
  //# sourceMappingURL=react.js.map
@@ -1,3 +1,3 @@
1
1
  'use client';
2
- var te=Object.defineProperty,ne=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&F(e,n,t[n]);if(T)for(var n of T(t))re.call(t,n)&&F(e,n,t[n]);return e},B=(e,t)=>ne(e,ie(t));import{render as be}from"@testing-library/react";import{createContext as pe,useContext as $e,useEffect as v,useMemo as Q,useRef as M,useState as E,useSyncExternalStore as Ve}from"react";import{deriveSessionSegment as me,init as ve}from"@sentientui/core";var se=new Map,ae=new Map;function $(e,t){se.set(e,t);let n=ae.get(e);if(n)for(let r of n)try{r(t)}catch(s){}}var le={on:!1,listeners:new Set};function V(){if(typeof window=="undefined")return le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function P(){return V().on}function U(e){let t=V().listeners;return t.add(e),()=>{t.delete(e)}}function z(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,s)=>e.assign(t,n,r,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ce="sentient:overrides-changed";function C(){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(ce))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function x(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var de={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function A(){if(typeof window=="undefined")return de;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 ue(){A().version+=1;for(let e of A().listeners)e()}function O(e){x()&&(A().sections=[...e],ue())}var H="0.30.0",I=H!=="0.0.0-dev"?{name:"react",version:H}:void 0;function fe(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function D(e,t){fe()[e]=t}function ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function L(e,t){ge()[e]=t}var q="sentient_editor",X="sentient_preview_cell",W="sentient-cell-preview-bar",G="__preview__";function J(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(W))return;let t,n;try{let f=new URLSearchParams(window.location.search);t=f.get(q),n=f.get(X)}catch(f){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let s=n.slice(0,r),u=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(s)}&persona=${encodeURIComponent(u)}`,{headers:{authorization:`Bearer ${t}`}}).then(async f=>{if(!f.ok){R(f.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let l=await f.json();if(l.blocks!=null)D(s,{kind:"arms",blocks:{[G]:l.blocks}}),L(s,G);else if(l.content!=null)D(s,{kind:"arms",content:l.content}),L(s,G);else{R("Nothing to preview in that square yet.");return}C(),R(`Previewing \u201C${l.slotName}\u201D for ${l.personaDisplay}${l.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${s}"]`))==null||y.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>R("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function R(e){var s;if(document.getElementById(W))return;let t=document.createElement("div");t.id=W,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{let u=new URL(window.location.href);u.searchParams.delete(q),u.searchParams.delete(X),window.location.assign(u.toString())},t.append(n,r),((s=document.body)!=null?s:document.documentElement).append(t)}import{jsx as we}from"react/jsx-runtime";function _e(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Y="https://api.sentient-ui.com/v1",ye=pe({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:Y,debug:!1});function Se(e){let[t,n]=E(!1),r=M(e);r.current=e;let{cookie:s,value:u,event:_}=e!=null?e:{},f=typeof(e==null?void 0:e.check)=="function";return v(()=>{let l=()=>{var w;let c=r.current;if(!c)return!1;if(c.check)return c.check()===!0;if(!c.cookie||typeof document=="undefined")return!1;let h=`${c.cookie}=${(w=c.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===h)};if(n(l()),!_)return;let y=()=>{n(l())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[s,u,_,f]),t}function Z(e){var K,N;let[t,n]=E(null),[r]=E(()=>{var i;return(i=e.sessionSegment)!=null?i:_e()}),[s,u]=E(P());v(()=>U(()=>u(P())),[]),v(()=>{J(e.apiBaseUrl)},[]);let _=Se(e.consentFrom),f=e.consentFrom?e.consent===!0||_:e.consent,l=M(null);v(()=>{var S;if(f===!1&&!e.preConsentBehavior){(S=l.current)==null||S.destroy(),l.current=null,n(null);return}let i=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:f,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},I?{sdk:I}:{}),d=!1,o=null,a=null,g=p=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{d||(a=b(p,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:p})=>{d||(o=p(B(m({},i),{graph:!0,captureDomText:e.captureDomText===!0})),l.current=o,n(o),g(o))}):(o=ve(i),l.current=o,n(o),g(o)),()=>{d=!0,a==null||a(),o==null||o.dispose()}},[f]),v(()=>{if(!t)return;let i=!1,d=async()=>{if(i)return;let a;try{a=await t.fetchWeights()}catch(g){return}if(!i)for(let g of a){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(p=>{var b;return{variantId:p.variantId,pulls:p.pulls,avgReward:(b=p.avgReward)!=null?b:0}})};$(g.componentId,S)}};d();let o=setInterval(()=>{d()},6e4);return()=>{i=!0,clearInterval(o)}},[t]);let y=(K=e.ssrFallback)!=null?K:"first",c=((N=e.apiBaseUrl)!=null?N:Y).replace(/\/$/,""),h=M(null);v(()=>{var o;if(typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:c},d=h.current;if(h.current=i,d!==null)for(let a of["apiKey","context","country","persona","apiBaseUrl"])Object.is(d[a],i[a])||console.warn(`[sentient] AdaptiveProvider: \`${a}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,c]),v(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:c,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,c]),v(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){O(i);return}e.declaredSections&&e.declaredSections.length>0&&O(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),v(()=>{if(!x())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let d=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),a=>a.getAttribute("data-sentient-id"))),o=i.filter(a=>!d.has(a));o.length>0&&console.warn(`[SentientUI] Declared section${o.length>1?"s":""} ${o.map(a=>`"${a}"`).join(", ")} ${o.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let w=Q(()=>t&&s?z(t):t,[t,s]),k=Q(()=>{var i,d,o,a,g,S,p;return{client:w,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(d=e.initialLayoutOrder)!=null?d:null,initialSlots:(o=e.initialSlots)!=null?o:{},initialSlotConfig:(a=e.initialSlotConfig)!=null?a:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:c,debug:(p=e.debug)!=null?p:!1}},[w,e.apiKey,e.initialAssignments,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,c,e.debug]);return we(ye.Provider,{value:k,children:e.children})}function he(e){return e<.3?"low":e<.7?"medium":"high"}function ee(e={}){var n,r,s;let t=window;if(t.__sentient_overrides=m({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=m({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=m({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",he((s=e.confidence)!=null?s:1))}catch(u){}}else delete t.__sentient_persona_override;C()}import{jsx as Ce}from"react/jsx-runtime";function at(e,t={},n){return ee(t),be(Ce(Z,{apiKey:"pk_test",context:"saas",consent:!1,children:e}),n)}export{at as renderWithSentient};
2
+ var te=Object.defineProperty,ne=Object.defineProperties;var ie=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var F=(e,t,n)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,m=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&F(e,n,t[n]);if(T)for(var n of T(t))re.call(t,n)&&F(e,n,t[n]);return e},B=(e,t)=>ne(e,ie(t));import{render as be}from"@testing-library/react";import{createContext as pe,useContext as $e,useEffect as v,useMemo as Q,useRef as M,useState as E,useSyncExternalStore as Ve}from"react";import{deriveSessionSegment as me,init as ve}from"@sentientui/core";var se=new Map,ae=new Map;function $(e,t){se.set(e,t);let n=ae.get(e);if(n)for(let r of n)try{r(t)}catch(s){}}var le={on:!1,listeners:new Set};function V(){if(typeof window=="undefined")return le;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function P(){return V().on}function U(e){let t=V().listeners;return t.add(e),()=>{t.delete(e)}}function z(e){return{isLocal:e.isLocal,track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},fetchWeights:()=>Promise.resolve([]),getAssignment:(t,n)=>e.getAssignment(t,n),assign:(t,n,r,s)=>e.assign(t,n,r,s),decide:()=>Promise.resolve(null),getSlotResult:t=>e.getSlotResult(t),getSlotConfig:t=>e.getSlotConfig(t),getSitePalette:()=>e.getSitePalette(),reportSlots:t=>e.reportSlots(t),getPersona:()=>e.getPersona(),getGraph:()=>e.getGraph(),dispose:()=>e.dispose(),destroy:()=>e.destroy()}}var ce="sentient:overrides-changed";function C(){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(ce))}function j(e){typeof window!="undefined"&&(window.__sentient_devtools_config=e)}function x(){var e;return typeof process=="undefined"||((e=process.env)==null?void 0:e.NODE_ENV)!=="production"}var de={components:new Map,slots:new Map,sections:[],listeners:new Set,version:0};function A(){if(typeof window=="undefined")return de;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 ue(){A().version+=1;for(let e of A().listeners)e()}function O(e){x()&&(A().sections=[...e],ue())}var H="0.31.0",I=H!=="0.0.0-dev"?{name:"react",version:H}:void 0;function fe(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function D(e,t){fe()[e]=t}function ge(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function L(e,t){ge()[e]=t}var q="sentient_editor",X="sentient_preview_cell",W="sentient-cell-preview-bar",G="__preview__";function J(e){if(typeof window=="undefined"||typeof document=="undefined"||document.getElementById(W))return;let t,n;try{let f=new URLSearchParams(window.location.search);t=f.get(q),n=f.get(X)}catch(f){return}if(!t||!n)return;let r=n.lastIndexOf("~");if(r<=0)return;let s=n.slice(0,r),u=n.slice(r+1),_=(e!=null?e:"https://api.sentient-ui.com/v1").replace(/\/$/,"");fetch(`${_}/editor/cell-preview?slotId=${encodeURIComponent(s)}&persona=${encodeURIComponent(u)}`,{headers:{authorization:`Bearer ${t}`}}).then(async f=>{if(!f.ok){R(f.status===401?"This preview link has expired \u2014 reopen it from your dashboard.":"Couldn\u2019t load this preview \u2014 reopen it from your dashboard.");return}let l=await f.json();if(l.blocks!=null)D(s,{kind:"arms",blocks:{[G]:l.blocks}}),L(s,G);else if(l.content!=null)D(s,{kind:"arms",content:l.content}),L(s,G);else{R("Nothing to preview in that square yet.");return}C(),R(`Previewing \u201C${l.slotName}\u201D for ${l.personaDisplay}${l.status==="review"?" \u2014 waiting for your approval":""}. Nothing is being tracked.`),setTimeout(()=>{var y;try{(y=document.querySelector(`[data-sentient-slot="${s}"]`))==null||y.scrollIntoView({block:"center"})}catch(c){}},300)}).catch(()=>R("Couldn\u2019t load this preview \u2014 check your connection and reopen it from your dashboard."))}function R(e){var s;if(document.getElementById(W))return;let t=document.createElement("div");t.id=W,Object.assign(t.style,{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",zIndex:"2147483647",display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"12px",maxWidth:"90vw",background:"#111827",color:"#fff",font:"13px system-ui, sans-serif",border:"1px solid rgba(139,92,246,0.6)",boxShadow:"0 10px 34px rgba(0,0,0,0.45)"});let n=document.createElement("span");n.textContent=e;let r=document.createElement("button");r.textContent="Exit preview",Object.assign(r.style,{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(255,255,255,0.35)",background:"transparent",color:"#fff",font:"12px system-ui, sans-serif",cursor:"pointer"}),r.onclick=()=>{let u=new URL(window.location.href);u.searchParams.delete(q),u.searchParams.delete(X),window.location.assign(u.toString())},t.append(n,r),((s=document.body)!=null?s:document.documentElement).append(t)}import{jsx as we}from"react/jsx-runtime";function _e(){var e,t;if(typeof window=="undefined")return"desktop:direct";try{return me({userAgent:(e=navigator.userAgent)!=null?e:"",referer:(t=document.referrer)!=null?t:"",appOrigin:window.location.origin})}catch(n){return"desktop:direct"}}var Y="https://api.sentient-ui.com/v1",ye=pe({client:null,apiKey:"",initialAssignments:{},sessionSegment:"desktop:direct",ssrFallback:"first",onAssignment:void 0,initialLayoutOrder:null,initialSlots:{},initialSlotConfig:{},initialPalette:null,initialPersona:null,apiBaseUrl:Y,debug:!1});function Se(e){let[t,n]=E(!1),r=M(e);r.current=e;let{cookie:s,value:u,event:_}=e!=null?e:{},f=typeof(e==null?void 0:e.check)=="function";return v(()=>{let l=()=>{var w;let c=r.current;if(!c)return!1;if(c.check)return c.check()===!0;if(!c.cookie||typeof document=="undefined")return!1;let h=`${c.cookie}=${(w=c.value)!=null?w:"accepted"}`;return document.cookie.split("; ").some(k=>k.trim()===h)};if(n(l()),!_)return;let y=()=>{n(l())};return window.addEventListener(_,y),()=>window.removeEventListener(_,y)},[s,u,_,f]),t}function Z(e){var K,N;let[t,n]=E(null),[r]=E(()=>{var i;return(i=e.sessionSegment)!=null?i:_e()}),[s,u]=E(P());v(()=>U(()=>u(P())),[]),v(()=>{J(e.apiBaseUrl)},[]);let _=Se(e.consentFrom),f=e.consentFrom?e.consent===!0||_:e.consent,l=M(null);v(()=>{var S;if(f===!1&&!e.preConsentBehavior){(S=l.current)==null||S.destroy(),l.current=null,n(null);return}let i=m({apiKey:e.apiKey,context:e.context,debug:e.debug,initialAssignments:e.initialAssignments,sessionSegment:r,consent:f,preConsentBehavior:e.preConsentBehavior,respectDoNotTrack:e.respectDoNotTrack,ssrSessionId:e.ssrSessionId,country:e.country,persona:e.persona,localMode:e.localMode,initialSlots:e.initialSlots,initialSlotConfig:e.initialSlotConfig,initialPalette:e.initialPalette,initialPersona:e.initialPersona,ingestUrl:e.apiBaseUrl?`${e.apiBaseUrl.replace(/\/$/,"")}/events`:void 0},I?{sdk:I}:{}),d=!1,o=null,a=null,g=p=>{e.engagement!==!1&&import("@sentientui/core/engagement").then(({startEngagementCapture:b})=>{d||(a=b(p,{apiKey:e.apiKey,apiBase:e.apiBaseUrl?e.apiBaseUrl.replace(/\/$/,""):void 0}))})};return e.enableGraph!==!1?import("@sentientui/core/graph").then(({init:p})=>{d||(o=p(B(m({},i),{graph:!0,captureDomText:e.captureDomText===!0})),l.current=o,n(o),g(o))}):(o=ve(i),l.current=o,n(o),g(o)),()=>{d=!0,a==null||a(),o==null||o.dispose()}},[f]),v(()=>{if(!t)return;let i=!1,d=async()=>{if(i)return;let a;try{a=await t.fetchWeights()}catch(g){return}if(!i)for(let g of a){let S={componentId:g.componentId,updatedAt:g.updatedAt,variants:g.variants.map(p=>{var b;return{variantId:p.variantId,pulls:p.pulls,avgReward:(b=p.avgReward)!=null?b:0}})};$(g.componentId,S)}};d();let o=setInterval(()=>{d()},6e4);return()=>{i=!0,clearInterval(o)}},[t]);let y=(K=e.ssrFallback)!=null?K:"first",c=((N=e.apiBaseUrl)!=null?N:Y).replace(/\/$/,""),h=M(null);v(()=>{var o;if(typeof process!="undefined"&&((o=process.env)==null?void 0:o.NODE_ENV)==="production")return;let i={apiKey:e.apiKey,context:e.context,country:e.country,persona:e.persona,apiBaseUrl:c},d=h.current;if(h.current=i,d!==null)for(let a of["apiKey","context","country","persona","apiBaseUrl"])Object.is(d[a],i[a])||console.warn(`[sentient] AdaptiveProvider: \`${a}\` changed after initialisation, but the SDK client is stable for the session and only re-inits on \`consent\` \u2014 the new value is ignored. Remount the provider (e.g. via a changing \`key\` prop) to apply it.`)},[e.apiKey,e.context,e.country,e.persona,c]),v(()=>{var i;typeof process!="undefined"&&((i=process.env)==null?void 0:i.NODE_ENV)==="production"||j({apiKey:e.apiKey,apiBaseUrl:c,isLocal:(t==null?void 0:t.isLocal)===!0})},[t,e.apiKey,c]),v(()=>{let i=e.initialLayoutOrder;if(i&&i.length>0){O(i);return}e.declaredSections&&e.declaredSections.length>0&&O(e.declaredSections)},[e.initialLayoutOrder,e.declaredSections]),v(()=>{if(!x())return;let i=e.declaredSections;if(!i||i.length===0||typeof document=="undefined")return;let d=new Set(Array.from(document.querySelectorAll("[data-sentient-id]"),a=>a.getAttribute("data-sentient-id"))),o=i.filter(a=>!d.has(a));o.length>0&&console.warn(`[SentientUI] Declared section${o.length>1?"s":""} ${o.map(a=>`"${a}"`).join(", ")} ${o.length>1?"have":"has"} no matching data-sentient-id element, so the layout engine cannot learn what they are and will serve the same order to every persona. Add data-sentient-id="<sectionId>" (plus optional data-sentient-type) to each section's element.`)},[e.declaredSections]);let w=Q(()=>t&&s?z(t):t,[t,s]),k=Q(()=>{var i,d,o,a,g,S,p;return{client:w,apiKey:e.apiKey,initialAssignments:(i=e.initialAssignments)!=null?i:{},sessionSegment:r,ssrFallback:y,onAssignment:e.onAssignment,initialLayoutOrder:(d=e.initialLayoutOrder)!=null?d:null,initialSlots:(o=e.initialSlots)!=null?o:{},initialSlotConfig:(a=e.initialSlotConfig)!=null?a:{},initialPalette:(g=e.initialPalette)!=null?g:null,initialPersona:(S=e.initialPersona)!=null?S:null,apiBaseUrl:c,debug:(p=e.debug)!=null?p:!1}},[w,e.apiKey,e.initialAssignments,r,y,e.onAssignment,e.initialLayoutOrder,e.initialSlots,e.initialSlotConfig,e.initialPalette,e.initialPersona,c,e.debug]);return we(ye.Provider,{value:k,children:e.children})}function he(e){return e<.3?"low":e<.7?"medium":"high"}function ee(e={}){var n,r,s;let t=window;if(t.__sentient_overrides=m({},(n=e.variants)!=null?n:{}),e.layout?t.__sentient_layout_override=e.layout:delete t.__sentient_layout_override,e.slots?t.__sentient_slot_overrides=m({},e.slots):delete t.__sentient_slot_overrides,e.slotConfig?t.__sentient_slot_config_overrides=m({},e.slotConfig):delete t.__sentient_slot_config_overrides,e.persona){t.__sentient_persona_override={persona:e.persona,confidence:(r=e.confidence)!=null?r:1};try{let u=document.documentElement;u.setAttribute("data-sentient-persona",e.persona),u.setAttribute("data-sentient-confidence",he((s=e.confidence)!=null?s:1))}catch(u){}}else delete t.__sentient_persona_override;C()}import{jsx as Ce}from"react/jsx-runtime";function at(e,t={},n){return ee(t),be(Ce(Z,{apiKey:"pk_test",context:"saas",consent:!1,children:e}),n)}export{at as renderWithSentient};
3
3
  //# sourceMappingURL=react.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -75,8 +75,8 @@
75
75
  "llms.txt"
76
76
  ],
77
77
  "dependencies": {
78
- "@sentientui/core": "0.28.0",
79
- "@sentientui/policy": "0.9.0"
78
+ "@sentientui/policy": "0.9.0",
79
+ "@sentientui/core": "0.29.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "@testing-library/react": ">=14.0.0",