@sentientui/core 0.16.10 → 0.18.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,2 +1,2 @@
1
- import{a as b,d as v}from"./chunk-CD2A55US.mjs";import{a as T,i as N,k as A}from"./chunk-Q7L7OPE4.mjs";import{g as $,h as k,i as U,j as L,k as j}from"./chunk-MYT7OJBV.mjs";import{a as y,b as I}from"./chunk-TMCGHANO.mjs";var x="_snt_graph_edges",K={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function z(e){var t;return(t=K[e])!=null?t:[]}function F(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function q(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var B=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function H(e){return B.has(e)?e:"generic"}function _(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function J(e,t,n){let d=`${e}:${t}:${n.join(",")}`,p=5381;for(let m=0;m<d.length;m++)p=(p<<5)+p+d.charCodeAt(m)&4294967295;return(p>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,n=new Map,d=`_snt_graph_nodes${T(e==null?void 0:e.apiKey)}`,p=()=>{typeof window!="undefined"&&q(d,[...t.values()])},m=o=>{var a;try{let i=JSON.parse(o);t.clear();for(let c of(a=i.pageNodes)!=null?a:[])t.set(c.componentId,c)}catch(i){}};if(typeof window!="undefined"){let o=F(d,[]);for(let a of o)t.set(a.componentId,a);try{localStorage.removeItem(x)}catch(a){}}return{addPageNode(o){t.set(o.componentId,o),p()},addStructuralEdge(o){let a=`${o.fromComponentId}->${o.toComponentId}`;n.set(a,o)},syncOnce(){var a,i;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let o=[...t.values()];if(o.length!==0)try{let c=new Map;for(let s of o){let f=(a=c.get(s.semanticType))!=null?a:[];f.push(s),c.set(s.semanticType,f)}let u=[],l=new Set;for(let s of o)for(let f of z(s.semanticType)){let S=(i=c.get(f))!=null?i:[];for(let h of S){if(h.componentId===s.componentId)continue;let w=`semantic:${s.componentId}->${h.componentId}`;l.has(w)||(l.add(w),u.push({fromComponentId:s.componentId,toComponentId:h.componentId,type:"semantic",weight:.4,confidence:.9}))}}let g=new Set(o.map(s=>s.componentId));for(let s of n.values()){if(!g.has(s.fromComponentId)||!g.has(s.toComponentId))continue;let f=`structural:${s.fromComponentId}->${s.toComponentId}`;l.has(f)||(l.add(f),u.push({fromComponentId:s.fromComponentId,toComponentId:s.toComponentId,type:"structural",weight:s.weight,confidence:1}))}let r=I(y(y({pageUrl:_(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:o.map(s=>{let f=H(s.semanticType);return{componentId:s.componentId,semanticType:f,answers:s.answers,contentHash:J(s.componentId,f,s.answers),prominenceScore:s.prominenceScore,depthInPage:s.depth}}),edges:u});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:y({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(r)}).catch(()=>{})}catch(c){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:m,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(d),localStorage.removeItem(x)}catch(o){}}}}var V=new Set(["SECTION","ARTICLE","MAIN","DIV"]),W="h1, h2, h3",O=30,Y=1500,Q={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function R(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function X(e){var t,n,d;try{let p=e;for(let m of Object.keys(p)){if(!m.startsWith("__reactFiber")&&!m.startsWith("__reactInternalInstance"))continue;let o=p[m],a=(d=(t=o==null?void 0:o.type)==null?void 0:t.displayName)!=null?d:(n=o==null?void 0:o.type)==null?void 0:n.name;if(a&&a.length>1)return a}}catch(p){}}function Z(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var P=new Set(b);function ee(e){let t=e.getAttribute("data-sentient-type");if(t&&P.has(t))return t;let n=e.getAttribute("role");return n&&P.has(n)?n:v(e)}function te(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)&4294967295;return(t>>>0).toString(16).padStart(8,"0")}function ne(e){let t=[],n=e;for(;n;){let d=n.parentElement;if(!d){t.push(n.tagName.toLowerCase());break}let p=Array.prototype.indexOf.call(d.children,n);t.push(`${n.tagName.toLowerCase()}[${p}]`),n=d}return t.reverse().join("/")}function oe(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${te(ne(e))}`}function re(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function C(e,t){var d,p,m;let n=e.querySelector(W);return{componentId:oe(e),semanticType:ee(e),ariaLabel:(d=e.getAttribute("aria-label"))!=null?d:void 0,headingText:(m=(p=n==null?void 0:n.textContent)==null?void 0:p.trim())!=null?m:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:re(e),reactComponentName:X(e),dataAttributes:Z(e)}}function D(e){var m;let t=[],n=new Set,d="__root__",p=new Map;for(let[o,a]of e){let i=o.parentElement,c=d;for(;i;){if(e.has(i)){c=e.get(i);let l=e.get(o),g=`${c}->${l}`;!n.has(g)&&c!==l&&(n.add(g),t.push({fromComponentId:c,toComponentId:l,weight:.6}));break}i=i.parentElement}let u=(m=p.get(c))!=null?m:[];u.push(o),p.set(c,u)}for(let o of p.values()){if(o.length<2)continue;let a=o.length>O?o.slice(0,O):o;for(let i=0;i<a.length;i++)for(let c=i+1;c<a.length;c++){if(t.length>=Y)return t;let u=e.get(a[i]),l=e.get(a[c]);if(u===l)continue;let g=`${u}->${l}::sib`,r=`${l}->${u}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:u,toComponentId:l,weight:.3})),n.has(r)||(n.add(r),t.push({fromComponentId:l,toComponentId:u,weight:.3}))}}return t}function se(e){let t=[],n=new Set,d=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(o=>{if(o instanceof Element&&!n.has(o)){n.add(o);let a=C(o,e);t.push(a),d.set(o,a.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(o=>{if(!(o instanceof Element)||n.has(o))return;let a=o.hasAttribute("aria-label"),i=o.hasAttribute("data-sentient-id");if(!a&&!i)return;n.add(o);let c=C(o,e);t.push(c),d.set(o,c.componentId)}),{nodes:t,edges:D(d),elementToId:d}}function G(){if(typeof window=="undefined")return Q;let e=null,t=0,n=null,d=new Map,p=i=>{try{let c=window.getComputedStyle(i),u=parseFloat(c.fontSize)||12,l=parseFloat(c.zIndex)||0,g=i.getBoundingClientRect(),r=Math.max(g.top,0),s=window.innerHeight||1,f=1/(r/s+1),S=R(u,12,48)*.4+f*.4+R(l,0,100)*.2;return Math.max(0,Math.min(1,S))}catch(c){return .5}};return{scan:()=>new Promise(i=>{let c=()=>{let{nodes:u,edges:l,elementToId:g}=se(p);d.clear();for(let[r,s]of g)d.set(r,s);i({nodes:u,edges:l,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(c,{timeout:100}):c()}catch(u){c()}}),observe:i=>{n=i;try{e=new MutationObserver(c=>{let u=[],l=new Set;for(let r of c)r.type==="childList"&&r.addedNodes.forEach(s=>{if(!(s instanceof Element)||!V.has(s.tagName))return;let f=s.hasAttribute("data-sentient-id"),S=s.hasAttribute("aria-label");if(!f&&!S)return;let h=C(s,p);u.push(h),l.add(h.componentId),d.set(s,h.componentId)});if(u.length===0||!n)return;for(let r of[...d.keys()])r.isConnected||d.delete(r);let g=D(d).filter(r=>l.has(r.fromComponentId)||l.has(r.toComponentId));n({nodes:u,edges:g,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(c){}},getProminenceScore:p,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(i){}t=0,n=null,d.clear()}}}var ae="https://api.sentient-ui.com/v1/events";function ie(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var E=new Map;function he(e){var l;let t=A(e),n=e.respectDoNotTrack!==!1&&N(),d=e.consent===!1||n;if(!e.graph||!e.apiKey||d||typeof window=="undefined")return t;let p=E.get(e.apiKey);if(p)try{p()}catch(g){}let m=G(),o=(l=e.ingestUrl)!=null?l:ae,a=M({syncUrl:o.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ie()});m.scan().then(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);a.syncOnce()});let i=null,c=()=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,a.syncOnce()},500)};m.observe(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);c()});let u=()=>{i!==null&&(clearTimeout(i),i=null),m.destroy(),a.destroy(),E.get(e.apiKey)===u&&E.delete(e.apiKey)};return E.set(e.apiKey,u),I(y({},t),{getGraph:()=>a.snapshot(),dispose:()=>{u(),t.dispose()},destroy:()=>{u(),t.destroy()}})}export{j as deriveSessionSegment,$ as detectDeviceClass,L as detectTimeOfDay,k as detectTrafficSource,he as init,U as referrerDomainFromReferer,_ as sanitizePageUrl};
1
+ import{a as b,d as v}from"./chunk-CD2A55US.mjs";import{a as T,i as N,k as A}from"./chunk-5OZS6A64.mjs";import{g as $,h as k,i as U,j as L,k as j}from"./chunk-MYT7OJBV.mjs";import{a as y,b as I}from"./chunk-TMCGHANO.mjs";var x="_snt_graph_edges",K={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function z(e){var t;return(t=K[e])!=null?t:[]}function F(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function q(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var B=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function H(e){return B.has(e)?e:"generic"}function _(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function J(e,t,n){let d=`${e}:${t}:${n.join(",")}`,p=5381;for(let m=0;m<d.length;m++)p=(p<<5)+p+d.charCodeAt(m)&4294967295;return(p>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,n=new Map,d=`_snt_graph_nodes${T(e==null?void 0:e.apiKey)}`,p=()=>{typeof window!="undefined"&&q(d,[...t.values()])},m=o=>{var a;try{let i=JSON.parse(o);t.clear();for(let c of(a=i.pageNodes)!=null?a:[])t.set(c.componentId,c)}catch(i){}};if(typeof window!="undefined"){let o=F(d,[]);for(let a of o)t.set(a.componentId,a);try{localStorage.removeItem(x)}catch(a){}}return{addPageNode(o){t.set(o.componentId,o),p()},addStructuralEdge(o){let a=`${o.fromComponentId}->${o.toComponentId}`;n.set(a,o)},syncOnce(){var a,i;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let o=[...t.values()];if(o.length!==0)try{let c=new Map;for(let s of o){let f=(a=c.get(s.semanticType))!=null?a:[];f.push(s),c.set(s.semanticType,f)}let u=[],l=new Set;for(let s of o)for(let f of z(s.semanticType)){let S=(i=c.get(f))!=null?i:[];for(let h of S){if(h.componentId===s.componentId)continue;let w=`semantic:${s.componentId}->${h.componentId}`;l.has(w)||(l.add(w),u.push({fromComponentId:s.componentId,toComponentId:h.componentId,type:"semantic",weight:.4,confidence:.9}))}}let g=new Set(o.map(s=>s.componentId));for(let s of n.values()){if(!g.has(s.fromComponentId)||!g.has(s.toComponentId))continue;let f=`structural:${s.fromComponentId}->${s.toComponentId}`;l.has(f)||(l.add(f),u.push({fromComponentId:s.fromComponentId,toComponentId:s.toComponentId,type:"structural",weight:s.weight,confidence:1}))}let r=I(y(y({pageUrl:_(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:o.map(s=>{let f=H(s.semanticType);return{componentId:s.componentId,semanticType:f,answers:s.answers,contentHash:J(s.componentId,f,s.answers),prominenceScore:s.prominenceScore,depthInPage:s.depth}}),edges:u});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:y({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(r)}).catch(()=>{})}catch(c){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:m,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(d),localStorage.removeItem(x)}catch(o){}}}}var V=new Set(["SECTION","ARTICLE","MAIN","DIV"]),W="h1, h2, h3",O=30,Y=1500,Q={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function R(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function X(e){var t,n,d;try{let p=e;for(let m of Object.keys(p)){if(!m.startsWith("__reactFiber")&&!m.startsWith("__reactInternalInstance"))continue;let o=p[m],a=(d=(t=o==null?void 0:o.type)==null?void 0:t.displayName)!=null?d:(n=o==null?void 0:o.type)==null?void 0:n.name;if(a&&a.length>1)return a}}catch(p){}}function Z(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var P=new Set(b);function ee(e){let t=e.getAttribute("data-sentient-type");if(t&&P.has(t))return t;let n=e.getAttribute("role");return n&&P.has(n)?n:v(e)}function te(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)&4294967295;return(t>>>0).toString(16).padStart(8,"0")}function ne(e){let t=[],n=e;for(;n;){let d=n.parentElement;if(!d){t.push(n.tagName.toLowerCase());break}let p=Array.prototype.indexOf.call(d.children,n);t.push(`${n.tagName.toLowerCase()}[${p}]`),n=d}return t.reverse().join("/")}function oe(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${te(ne(e))}`}function re(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function C(e,t){var d,p,m;let n=e.querySelector(W);return{componentId:oe(e),semanticType:ee(e),ariaLabel:(d=e.getAttribute("aria-label"))!=null?d:void 0,headingText:(m=(p=n==null?void 0:n.textContent)==null?void 0:p.trim())!=null?m:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:re(e),reactComponentName:X(e),dataAttributes:Z(e)}}function D(e){var m;let t=[],n=new Set,d="__root__",p=new Map;for(let[o,a]of e){let i=o.parentElement,c=d;for(;i;){if(e.has(i)){c=e.get(i);let l=e.get(o),g=`${c}->${l}`;!n.has(g)&&c!==l&&(n.add(g),t.push({fromComponentId:c,toComponentId:l,weight:.6}));break}i=i.parentElement}let u=(m=p.get(c))!=null?m:[];u.push(o),p.set(c,u)}for(let o of p.values()){if(o.length<2)continue;let a=o.length>O?o.slice(0,O):o;for(let i=0;i<a.length;i++)for(let c=i+1;c<a.length;c++){if(t.length>=Y)return t;let u=e.get(a[i]),l=e.get(a[c]);if(u===l)continue;let g=`${u}->${l}::sib`,r=`${l}->${u}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:u,toComponentId:l,weight:.3})),n.has(r)||(n.add(r),t.push({fromComponentId:l,toComponentId:u,weight:.3}))}}return t}function se(e){let t=[],n=new Set,d=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(o=>{if(o instanceof Element&&!n.has(o)){n.add(o);let a=C(o,e);t.push(a),d.set(o,a.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(o=>{if(!(o instanceof Element)||n.has(o))return;let a=o.hasAttribute("aria-label"),i=o.hasAttribute("data-sentient-id");if(!a&&!i)return;n.add(o);let c=C(o,e);t.push(c),d.set(o,c.componentId)}),{nodes:t,edges:D(d),elementToId:d}}function G(){if(typeof window=="undefined")return Q;let e=null,t=0,n=null,d=new Map,p=i=>{try{let c=window.getComputedStyle(i),u=parseFloat(c.fontSize)||12,l=parseFloat(c.zIndex)||0,g=i.getBoundingClientRect(),r=Math.max(g.top,0),s=window.innerHeight||1,f=1/(r/s+1),S=R(u,12,48)*.4+f*.4+R(l,0,100)*.2;return Math.max(0,Math.min(1,S))}catch(c){return .5}};return{scan:()=>new Promise(i=>{let c=()=>{let{nodes:u,edges:l,elementToId:g}=se(p);d.clear();for(let[r,s]of g)d.set(r,s);i({nodes:u,edges:l,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(c,{timeout:100}):c()}catch(u){c()}}),observe:i=>{n=i;try{e=new MutationObserver(c=>{let u=[],l=new Set;for(let r of c)r.type==="childList"&&r.addedNodes.forEach(s=>{if(!(s instanceof Element)||!V.has(s.tagName))return;let f=s.hasAttribute("data-sentient-id"),S=s.hasAttribute("aria-label");if(!f&&!S)return;let h=C(s,p);u.push(h),l.add(h.componentId),d.set(s,h.componentId)});if(u.length===0||!n)return;for(let r of[...d.keys()])r.isConnected||d.delete(r);let g=D(d).filter(r=>l.has(r.fromComponentId)||l.has(r.toComponentId));n({nodes:u,edges:g,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(c){}},getProminenceScore:p,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(i){}t=0,n=null,d.clear()}}}var ae="https://api.sentient-ui.com/v1/events";function ie(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}var E=new Map;function he(e){var l;let t=A(e),n=e.respectDoNotTrack!==!1&&N(),d=e.consent===!1||n;if(!e.graph||!e.apiKey||d||typeof window=="undefined")return t;let p=E.get(e.apiKey);if(p)try{p()}catch(g){}let m=G(),o=(l=e.ingestUrl)!=null?l:ae,a=M({syncUrl:o.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ie()});m.scan().then(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);a.syncOnce()});let i=null,c=()=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{i=null,a.syncOnce()},500)};m.observe(g=>{for(let r of g.nodes)a.addPageNode({id:r.componentId,componentId:r.componentId,semanticType:r.semanticType,answers:e.captureDomText&&r.headingText?[r.headingText]:[],prominenceScore:r.prominenceScore,depth:r.depth});for(let r of g.edges)a.addStructuralEdge(r);c()});let u=()=>{i!==null&&(clearTimeout(i),i=null),m.destroy(),a.destroy(),E.get(e.apiKey)===u&&E.delete(e.apiKey)};return E.set(e.apiKey,u),I(y({},t),{getGraph:()=>a.snapshot(),dispose:()=>{u(),t.dispose()},destroy:()=>{u(),t.destroy()}})}export{j as deriveSessionSegment,$ as detectDeviceClass,L as detectTimeOfDay,k as detectTrafficSource,he as init,U as referrerDomainFromReferer,_ as sanitizePageUrl};
2
2
  //# sourceMappingURL=index-graph.mjs.map
@@ -1,4 +1,4 @@
1
- import { e as DecideOutcome } from './index-a8WMLbpe.cjs';
1
+ import { e as DecideOutcome } from './index-FG0YuEFa.cjs';
2
2
  import { b as SlotDeclInput } from './session-meta-BVvq5RBB.cjs';
3
3
  import '@sentientui/policy';
4
4
 
@@ -1,4 +1,4 @@
1
- import { e as DecideOutcome } from './index-sGcvT3pc.js';
1
+ import { e as DecideOutcome } from './index-uWA8sgOV.js';
2
2
  import { b as SlotDeclInput } from './session-meta-BVvq5RBB.js';
3
3
  import '@sentientui/policy';
4
4
 
@@ -292,10 +292,12 @@ type AssignResult = {
292
292
  * snippet to install delegated listeners from. */
293
293
  type GoalDefinition = {
294
294
  goalId: string;
295
- event: 'click' | 'form_submit' | 'url_reached';
295
+ event: 'click' | 'form_submit' | 'url_reached' | 'scroll_depth';
296
296
  locator?: CompoundLocator;
297
297
  urlPattern?: string;
298
298
  slotId?: string;
299
+ /** scroll_depth only: fraction of the page (0–1] that counts as read. */
300
+ threshold?: number;
299
301
  };
300
302
  /** One served section-classification row (registry mode): where it is on the
301
303
  * page (url match + compound locator) and its semantic type. The snippet
@@ -341,14 +343,30 @@ type ComponentWeightEntry = {
341
343
  updatedAt: number;
342
344
  variants: WeightEntry[];
343
345
  };
344
- type ComponentGoalOptions = {
346
+ /** Options accepted by goal() (and inherited by componentGoal / the React
347
+ * hooks / the snippet) — one shape everywhere (spec §5). */
348
+ type GoalOptions = {
349
+ /** Revenue of this conversion, in the project currency. */
350
+ value?: number;
351
+ /** ISO-4217 code, only when it differs from the project currency. */
352
+ currency?: string;
353
+ /** Merchant order/transaction id — dedupes retries, enables refunds later. */
354
+ externalId?: string;
355
+ /** Extra fields merged into the event payload / goal metadata. */
356
+ metadata?: Record<string, unknown>;
357
+ /** Advanced: partial-credit weight in [0,1] (composite steps). */
358
+ weight?: number;
359
+ /** Advanced: funnel step index (0-based). */
360
+ stepIndex?: number;
361
+ };
362
+ type ComponentGoalOptions = GoalOptions & {
345
363
  /** Reward credited to the served variant (0–1). Defaults to 1. */
346
364
  reward?: number;
347
- /** Extra fields merged into the event payload. */
348
- metadata?: Record<string, unknown>;
349
365
  };
350
366
  type SentientClient = {
351
367
  track(event: Omit<SentientEvent, 'id' | 'sessionId' | 'timestamp' | 'timeInSession'>): void;
368
+ goal(name: string, options?: GoalOptions): void;
369
+ /** @deprecated positional form — prefer goal(name, options). */
352
370
  goal(name: string, metadata?: Record<string, unknown>, weight?: number, stepIndex?: number): void;
353
371
  /**
354
372
  * Records a conversion attributed to the variant currently served for
@@ -420,4 +438,4 @@ declare function grantConsent(apiKey?: string): void;
420
438
  */
421
439
  declare function init(config: SentientConfig): SentientClient;
422
440
 
423
- export { type AssignResult as A, sanitizePageUrl as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, writeSnapshot as F, type GoalDefinition as G, LOCAL_MODE_BANNER as L, type MicroSignalEmitter as M, PROD_KEYLESS_ERROR as P, type QueueConfig as Q, SNAPSHOT_STORAGE_KEY_PREFIX as S, type WeightEntry as W, type Assignment as a, type AssignmentCache as b, type ComponentWeightEntry as c, type CompoundLocator as d, type DecideOutcome as e, type DecisionSnapshot as f, type EventType as g, type GraphClient as h, type GraphConfig as i, type GraphSnapshot as j, type MicroSignalType as k, type PageNode as l, type SectionMapEntry as m, type SentientClient as n, type SentientConfig as o, type SentientEvent as p, type SessionConfig as q, type SessionManager as r, type SlotConfigEntry as s, type SlotOps as t, attachMicroSignalDetectors as u, grantConsent as v, init as w, isDoNotTrackEnabled as x, readSnapshot as y, renderPrePaintScript as z };
441
+ export { type AssignResult as A, renderPrePaintScript as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, sanitizePageUrl as F, type GoalDefinition as G, writeSnapshot as H, LOCAL_MODE_BANNER as L, type MicroSignalEmitter as M, PROD_KEYLESS_ERROR as P, type QueueConfig as Q, SNAPSHOT_STORAGE_KEY_PREFIX as S, type WeightEntry as W, type Assignment as a, type AssignmentCache as b, type ComponentWeightEntry as c, type CompoundLocator as d, type DecideOutcome as e, type DecisionSnapshot as f, type EventType as g, type GoalOptions as h, type GraphClient as i, type GraphConfig as j, type GraphSnapshot as k, type MicroSignalType as l, type PageNode as m, type SectionMapEntry as n, type SentientClient as o, type SentientConfig as p, type SentientEvent as q, type SessionConfig as r, type SessionManager as s, type SlotConfigEntry as t, type SlotOps as u, attachMicroSignalDetectors as v, grantConsent as w, init as x, isDoNotTrackEnabled as y, readSnapshot as z };
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { A as AssignResult, a as Assignment, C as ComponentGoalOptions, c as ComponentWeightEntry, d as CompoundLocator, D as DecideInput, e as DecideOutcome, f as DecisionSnapshot, g as EventType, G as GoalDefinition, i as GraphConfig, j as GraphSnapshot, L as LOCAL_MODE_BANNER, M as MicroSignalEmitter, k as MicroSignalType, P as PROD_KEYLESS_ERROR, Q as QueueConfig, S as SNAPSHOT_STORAGE_KEY_PREFIX, m as SectionMapEntry, n as SentientClient, o as SentientConfig, p as SentientEvent, q as SessionConfig, r as SessionManager, s as SlotConfigEntry, t as SlotOps, W as WeightEntry, u as attachMicroSignalDetectors, v as grantConsent, w as init, x as isDoNotTrackEnabled, y as readSnapshot, z as renderPrePaintScript, F as writeSnapshot } from './index-a8WMLbpe.cjs';
1
+ export { A as AssignResult, a as Assignment, C as ComponentGoalOptions, c as ComponentWeightEntry, d as CompoundLocator, D as DecideInput, e as DecideOutcome, f as DecisionSnapshot, g as EventType, G as GoalDefinition, h as GoalOptions, j as GraphConfig, k as GraphSnapshot, L as LOCAL_MODE_BANNER, M as MicroSignalEmitter, l as MicroSignalType, P as PROD_KEYLESS_ERROR, Q as QueueConfig, S as SNAPSHOT_STORAGE_KEY_PREFIX, n as SectionMapEntry, o as SentientClient, p as SentientConfig, q as SentientEvent, r as SessionConfig, s as SessionManager, t as SlotConfigEntry, u as SlotOps, W as WeightEntry, v as attachMicroSignalDetectors, w as grantConsent, x as init, y as isDoNotTrackEnabled, z as readSnapshot, B as renderPrePaintScript, H as writeSnapshot } from './index-FG0YuEFa.cjs';
2
2
  export { A as AGENT_INTENTS, a as AgentIntent, b as SlotDeclInput, c as agentIntent, d as agentUaList, e as armOfResult, f as baselineResultFor, g as baselineSlots, i as classifiedAgents, j as deriveSessionSegment, k as detectDeviceClass, l as detectTimeOfDay, m as detectTrafficSource, n as matchedAgentToken, r as referrerDomainFromReferer, t as toWireSlot, u as uaTokenMatch } from './session-meta-BVvq5RBB.cjs';
3
3
  export { SlotResult } from '@sentientui/policy';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { A as AssignResult, a as Assignment, C as ComponentGoalOptions, c as ComponentWeightEntry, d as CompoundLocator, D as DecideInput, e as DecideOutcome, f as DecisionSnapshot, g as EventType, G as GoalDefinition, i as GraphConfig, j as GraphSnapshot, L as LOCAL_MODE_BANNER, M as MicroSignalEmitter, k as MicroSignalType, P as PROD_KEYLESS_ERROR, Q as QueueConfig, S as SNAPSHOT_STORAGE_KEY_PREFIX, m as SectionMapEntry, n as SentientClient, o as SentientConfig, p as SentientEvent, q as SessionConfig, r as SessionManager, s as SlotConfigEntry, t as SlotOps, W as WeightEntry, u as attachMicroSignalDetectors, v as grantConsent, w as init, x as isDoNotTrackEnabled, y as readSnapshot, z as renderPrePaintScript, F as writeSnapshot } from './index-sGcvT3pc.js';
1
+ export { A as AssignResult, a as Assignment, C as ComponentGoalOptions, c as ComponentWeightEntry, d as CompoundLocator, D as DecideInput, e as DecideOutcome, f as DecisionSnapshot, g as EventType, G as GoalDefinition, h as GoalOptions, j as GraphConfig, k as GraphSnapshot, L as LOCAL_MODE_BANNER, M as MicroSignalEmitter, l as MicroSignalType, P as PROD_KEYLESS_ERROR, Q as QueueConfig, S as SNAPSHOT_STORAGE_KEY_PREFIX, n as SectionMapEntry, o as SentientClient, p as SentientConfig, q as SentientEvent, r as SessionConfig, s as SessionManager, t as SlotConfigEntry, u as SlotOps, W as WeightEntry, v as attachMicroSignalDetectors, w as grantConsent, x as init, y as isDoNotTrackEnabled, z as readSnapshot, B as renderPrePaintScript, H as writeSnapshot } from './index-uWA8sgOV.js';
2
2
  export { A as AGENT_INTENTS, a as AgentIntent, b as SlotDeclInput, c as agentIntent, d as agentUaList, e as armOfResult, f as baselineResultFor, g as baselineSlots, i as classifiedAgents, j as deriveSessionSegment, k as detectDeviceClass, l as detectTimeOfDay, m as detectTrafficSource, n as matchedAgentToken, r as referrerDomainFromReferer, t as toWireSlot, u as uaTokenMatch } from './session-meta-BVvq5RBB.js';
3
3
  export { SlotResult } from '@sentientui/policy';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Ye=Object.create;var ne=Object.defineProperty,qe=Object.defineProperties,Xe=Object.getOwnPropertyDescriptor,Ze=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,tt=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var Te=(e,t,n)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Te(e,n,t[n]);if(Oe)for(var n of Oe(t))nt.call(t,n)&&Te(e,n,t[n]);return e},Q=(e,t)=>qe(e,Ze(t));var ot=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})},Le=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of et(t))!Pe.call(e,u)&&u!==n&&ne(e,u,{get:()=>t[u],enumerable:!(c=Xe(t,u))||c.enumerable});return e};var rt=(e,t,n)=>(n=e!=null?Ye(tt(e)):{},Le(t||!e||!e.__esModule?ne(n,"default",{value:e,enumerable:!0}):n,e)),st=e=>Le(ne({},"__esModule",{value:!0}),e);var Ot={};ot(Ot,{AGENT_INTENTS:()=>ye,LOCAL_MODE_BANNER:()=>Ce,PROD_KEYLESS_ERROR:()=>be,SNAPSHOT_STORAGE_KEY_PREFIX:()=>J,agentIntent:()=>Ue,agentUaList:()=>oe,armOfResult:()=>Se,attachMicroSignalDetectors:()=>Fe,baselineResultFor:()=>z,baselineSlots:()=>Ge,classifiedAgents:()=>Ke,deriveSessionSegment:()=>Be,detectDeviceClass:()=>se,detectTimeOfDay:()=>le,detectTrafficSource:()=>ie,grantConsent:()=>_t,init:()=>ze,isDoNotTrackEnabled:()=>ke,matchedAgentToken:()=>Ie,readSnapshot:()=>he,referrerDomainFromReferer:()=>ae,renderPrePaintScript:()=>$e,toWireSlot:()=>ce,uaTokenMatch:()=>re,writeSnapshot:()=>H});module.exports=st(Ot);function ge(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function pe(e){return e?`_${e.slice(0,12)}`:""}var it="_snt_uid",at=365,lt="_snt_uid";function ct(){return ge()}function dt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function ut(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(c){}}function gt(e){try{return localStorage.getItem(e)}catch(t){return null}}function pt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function ft(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function mt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function yt(e){try{sessionStorage.removeItem(e)}catch(t){}}function St(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function ht(e){try{localStorage.removeItem(e)}catch(t){}}function vt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var wt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function fe(e){var m,x,O,b,I,C;if(typeof window=="undefined")return wt;let t=pe(e==null?void 0:e.apiKey),n=(m=e==null?void 0:e.cookieName)!=null?m:`${it}${t}`,c=`${lt}${t}`,d=((x=e==null?void 0:e.cookieTTLDays)!=null?x:at)*24*60*60,g=h=>h&&h.length>0?h:null,l=(C=(I=(b=(O=g(dt(n)))!=null?O:g(gt(c)))!=null?b:g(ft(c)))!=null?I:g(e==null?void 0:e.ssrSessionId))!=null?C:ct();ut(n,l,d);let r=pt(c,l),o=St(n),i=r?!1:mt(c,l),a=!r&&!o&&!i;return{getSessionId:()=>l,isEphemeral:()=>a,destroy:()=>{l=null,vt(n),ht(c),yt(c)}}}function Ee(e){return`_snt_retry_${e.slice(0,12)}`}var bt={push:()=>{},flush:()=>{},destroy:()=>{}};function xt(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(t),c.slice(-e)):[]}catch(n){return[]}}function xe(e,t,n){try{let c=(()=>{try{let g=localStorage.getItem(n);if(!g)return[];let l=JSON.parse(g);return Array.isArray(l)?l:[]}catch(g){return[]}})(),u=new Map;for(let g of c)u.set(g.id,g);for(let g of e)u.set(g.id,g);let d=[...u.values()].slice(-t);localStorage.setItem(n,JSON.stringify(d))}catch(c){}}function Et(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let u=new Set(e),d=c.filter(g=>!u.has(g.id));if(d.length===c.length)return;d.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(d))}catch(n){}}function Me(e){var q,X,Z;if(typeof window=="undefined")return bt;let t=(q=e.flushIntervalMs)!=null?q:5e3,n=(X=e.maxBatchSize)!=null?X:20,c=(Z=e.maxRetrySize)!=null?Z:100,u=e.ingestUrl,d=e.apiKey,g=Ee(d),l=[],r=new Set,o=[],i=f=>{for(let y of f)a.delete(y),!r.has(y)&&(r.add(y),o.push(y));for(;o.length>500;){let y=o.shift();y&&r.delete(y)}Et(f,g)},a=new Set,m=f=>{r.has(f.id)||a.has(f.id)||(a.add(f.id),l.push(f))},x=f=>{for(let y of f)r.has(y.id)||(a.add(y.id),l.push(y))},O=xt(c,g);for(let f of O)m(f);let b=0,I=0,C=f=>{if(f.length===0)return;let y=JSON.stringify(f),N=f.map(s=>s.id),P;try{P=fetch(u,{method:"POST",keepalive:!0,body:y,headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`}})}catch(s){xe(f,c,g),x(f),I++,b=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6));return}let K=s=>{if(s.ok||s.status>=400&&s.status<500&&s.status!==429){i(N),I=0,b=0;return}xe(f,c,g),x(f),I++,b=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))};P instanceof Promise?P.then(K).catch(()=>{xe(f,c,g),x(f),I++,b=Date.now()+Math.min(6e4,1e3*2**Math.min(I,6))}):K(P)},h=typeof TextEncoder!="undefined"?new TextEncoder:null,ue=f=>h?h.encode(f).length:f.length,$=f=>{let y=[],N=2;for(let P of f){let K=ue(JSON.stringify(P))+1;if(y.length>0&&N+K>57344||y.length>=n)break;y.push(P),N+=K}return y},M=()=>{try{if(Date.now()<b)return;for(;l.length>0&&!(Date.now()<b);){let f=l.filter(N=>!r.has(N.id));if(l.length=0,f.length===0)break;let y=$(f);if(y.length===0)break;y.length<f.length&&l.push(...f.slice(y.length)),C(y)}}catch(f){}},T=!0,W=null;W=setInterval(()=>{T&&M()},t);let U=()=>{document.visibilityState==="hidden"&&M()},Y=()=>{M()};return document.addEventListener("visibilitychange",U),window.addEventListener("pagehide",Y),{push(f){m(f),l.length>=n&&M()},flush:M,destroy(){T=!1,W!==null&&(clearInterval(W),W=null),document.removeEventListener("visibilitychange",U),window.removeEventListener("pagehide",Y),M()}}}var It=1800*1e3;function me(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ne(e=It,t){let n=new Map,c=`_snt_asgn${pe(t)}_`,u=(o,i)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(i)}`,d=o=>{let i=o.slice(c.length),a=i.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,a)),segment:decodeURIComponent(i.slice(a+1))}}catch(m){return null}},g=()=>{try{let o=[];for(let i=0;i<localStorage.length;i++){let a=localStorage.key(i);a!=null&&a.startsWith(c)&&o.push(a)}return o}catch(o){return[]}},l=o=>o.assignedAt+(o.ttlMs&&o.ttlMs>0?o.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let o of g())try{let i=localStorage.getItem(o);if(!i)continue;let a=JSON.parse(i);if(l(a)){localStorage.removeItem(o);continue}let m=d(o);if(!m)continue;n.set(me(m.componentId,m.segment),a)}catch(i){}})(),{get(o,i){let a=n.get(me(o,i));return a?l(a)?(n.delete(me(o,i)),null):a:null},set(o,i,a){let m=me(o,i);n.set(m,a);try{localStorage.setItem(u(o,i),JSON.stringify(a))}catch(x){}},invalidate(o){let i=`${encodeURIComponent(o)}:`;for(let a of[...n.keys()])a.startsWith(i)&&n.delete(a);for(let a of g()){let m=d(a);if((m==null?void 0:m.componentId)===o)try{localStorage.removeItem(a)}catch(x){}}},clear(){n.clear();for(let o of g())try{localStorage.removeItem(o)}catch(i){}}}}var oe=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function re(e){return Ie(e)!==null}function Ie(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=oe.find(c=>t.includes(c.toLowerCase())))!=null?n:null}var ye={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function Ue(e){if(!e)return"other";let t=oe.find(n=>n.toLowerCase()===e.toLowerCase());return t&&ye[t]||"other"}function Ke(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of oe)e[(t=ye[n])!=null?t:"other"].push(n);return e}function se(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function ie(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(u){}let c=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(c)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(c)?"social":"referral"}catch(n){return"direct"}}function ae(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function le(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Be(e){let t=Ct("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Ct(e,t){var d,g,l,r,o,i,a;let n=(g=(d=t==null?void 0:t.userAgent)==null?void 0:d.trim())!=null?g:"",c=(r=(l=t==null?void 0:t.referer)==null?void 0:l.trim())!=null?r:"",u=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(i=t==null?void 0:t.utmParams)!=null?i:{},deviceClass:n?se(n):"desktop",trafficSource:c?ie(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:ae(c),timeOfDay:le(u),dayOfWeek:(a=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?a:"sun",automation:(t==null?void 0:t.webdriver)===!0||re(n)}}var V=require("@sentientui/policy");function ce(e){return v(v(v({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function z(e){let t=ce(e);return(0,V.slotResultFor)(t,(0,V.slotBaselineArm)(t))}function Ge(e){let t={};for(let n of e)t[n.id]=z(n);return t}function Se(e){return typeof e=="string"?e:(0,V.canonicalArm)(e)}var J="_snt_snap:",At=["low","medium","high"];function he(e){try{let t=localStorage.getItem(J+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!At.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function H(e,t){try{localStorage.setItem(J+e,JSON.stringify(t))}catch(n){}}function $e(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(J+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}var Re=require("@sentientui/policy");var we=require("@sentientui/policy");var be="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ce="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",We=!1,ve=!1;function Rt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function je(e){var l;let t=fe({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(l=t.getSessionId())!=null?l:"local",c=Rt(),u=import("@sentientui/core/local").then(r=>{let o=r;return o.LOCAL_ENGINE_AVAILABLE?(We||(We=!0,console.info(Ce)),o):(ve||(ve=!0,console.error(be)),null)}).catch(()=>(ve||(ve=!0,console.error(be)),null)),d=null;function g(r){let o=document.documentElement;o.dataset.sentientPersona===void 0&&(o.dataset.sentientPersona=r.persona,o.dataset.sentientConfidence=(0,we.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var a,m,x;let o=await u;if(!o)return null;let i=o.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return d=Q(v({},i),{layoutOrder:(m=(a=i.layoutOrder)!=null?a:d==null?void 0:d.layoutOrder)!=null?m:null,slots:v(v({},(x=d==null?void 0:d.slots)!=null?x:{}),i.slots)}),H(e.apiKey||"local",{v:1,persona:d.persona,band:(0,we.confidenceBand)(d.confidence),slots:d.slots,layoutOrder:d.layoutOrder,savedAt:Date.now()}),g(i),i},getSlotResult(r){var o,i,a;return(a=(i=d==null?void 0:d.slots[r])!=null?i:(o=e.initialSlots)==null?void 0:o[r])!=null?a:null},getPersona(){return d?{persona:d.persona,confidence:d.confidence,band:(0,we.confidenceBand)(d.confidence)}:null},async assign(r,o){var m;let i=await u;return!i||!o||o.length===0?o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null:{variantId:(m=i.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:o}]}).assignments[r])!=null?m:o[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}function Fe(e,t,n,c){let u=[];{let l=!1,r=[],o=()=>{if(l)return;let i=Date.now();for(r.push(i);r.length>0&&i-r[0]>500;)r.shift();r.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",o),u.push(()=>t.removeEventListener("click",o))}{let d=!1,g=l=>{if(d||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;d=!0;let r=typeof window!="undefined"?window.getSelection():null,o=r?r.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",g),u.push(()=>document.removeEventListener("copy",g))}{let d=!1,g=!1,l=null,r=()=>{l!==null&&(clearTimeout(l),l=null)},o=()=>{d||!g||(r(),l=setTimeout(()=>{!d&&g&&(d=!0,e("scroll_hesitation"))},3e3))},i=()=>{r(),o()},a=x=>{for(let O of x)g=O.intersectionRatio>.3,g?o():r()},m=new IntersectionObserver(a,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",i,{passive:!0}),u.push(()=>{m.disconnect(),window.removeEventListener("scroll",i),r()})}if((c==null?void 0:c.tabLoss)!==!1){let d=!1,g=n!=null?n:Date.now(),l=()=>{if(d||document.visibilityState!=="hidden")return;let r=Date.now()-g;r<15e3&&(d=!0,e("tab_loss",{timeOnPage:r}))};document.addEventListener("visibilitychange",l),u.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let d of u)d()}}var Je="https://api.sentient-ui.com/v1/events",R=new Map,Qe=null;function Ae(){return ge()}var de={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function kt(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,c]of t)n.startsWith("utm_")&&(e[n]=c);return e}catch(e){return{}}}function Ve(e){return e.replace(/\/events\/?$/,"")}function ke(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}function _t(e){var l;if(typeof window=="undefined")return;let t=e!=null?e:Qe;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=R.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:u}=n;if(!u||c.respectDoNotTrack!==!1&&ke())return;let d=ze(Q(v({},c),{consent:!0}));u(d);let g=(l=R.get(t))==null?void 0:l.dispose;R.set(t,{config:Q(v({},c),{consent:!0}),upgrade:null,dispose:g})}function Dt(e){var l;let t=e.preConsentBehavior==="statistical_winner",n=Ve((l=e.ingestUrl)!=null?l:Je),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,o,i){if(!t)return null;try{let a=new URLSearchParams({componentId:r});for(let O of o!=null?o:[])a.append("variantIds[]",O);let m=await fetch(`${n}/winner?${a.toString()}`,{headers:c});return m.ok?{variantId:(await m.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(a){return o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},d={track:r=>u.track(r),goal:(r,o,i,a)=>u.goal(r,o,i,a),componentGoal:(r,o,i)=>u.componentGoal(r,o,i),identify:r=>u.identify(r),getAssignment:(r,o)=>u.getAssignment(r,o),assign:(r,o,i,a)=>u.assign(r,o,i,a),decide:r=>u.decide(r),getSlotResult:r=>u.getSlotResult(r),getPersona:()=>u.getPersona(),fetchWeights:()=>u.fetchWeights(),getGraph:()=>u.getGraph(),dispose:()=>u.dispose(),destroy:()=>u.destroy()};function g(r){u=r}return{proxy:d,setInner:g}}function ze(e){var Y,q,X,Z,f,y,N,P,K;if(typeof window=="undefined")return de;Qe=e.apiKey;let t=R.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(s){}let n=e.respectDoNotTrack!==!1&&ke(),c=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return c?(R.set(e.apiKey||"local",{config:e,upgrade:null}),de):(R.set(e.apiKey||"local",{config:e,upgrade:null}),je(e));if(c){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),R.set(e.apiKey,{config:e,upgrade:null}),de;let{proxy:s,setInner:p}=Dt(e);return R.set(e.apiKey,{config:e,upgrade:n?null:p}),s}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),de;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),de;let d=(Y=e.ingestUrl)!=null?Y:Je,g=Date.now(),l=fe({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=Ne(void 0,e.apiKey),o=Me({ingestUrl:d,apiKey:e.apiKey}),i=Ve(d),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},m=se((q=navigator.userAgent)!=null?q:""),x=typeof window!="undefined"?window.location.origin:void 0,O=ie((X=document.referrer)!=null?X:"",x),b=(Z=e.sessionSegment)!=null?Z:`${m}:${O}`,I=new Map,C=new Map,h=null,ue=s=>{for(let p of s)C.has(p.id)||C.set(p.id,z(p))};if(e.initialSlots)for(let[s,p]of Object.entries(e.initialSlots))C.set(s,p);let $=he(e.apiKey);if($)for(let[s,p]of Object.entries($.slots))C.has(s)||C.set(s,p);let M={low:.15,medium:.5,high:.85};if(e.initialPersona)h=v({},e.initialPersona);else{let s=document.documentElement.dataset;s.sentientPersona?h={persona:s.sentientPersona,confidence:(y=M[(f=s.sentientConfidence)!=null?f:"low"])!=null?y:.15}:$&&(h={persona:$.persona,confidence:(N=M[$.band])!=null?N:.15})}if(e.initialAssignments)for(let[s,p]of Object.entries(e.initialAssignments))r.set(s,b,{variantId:p,assignedAt:Date.now(),segment:b,confidence:1});let T=Promise.resolve(),W=l.getSessionId();if(W){let s=ae((P=document.referrer)!=null?P:""),p=v(v({sessionId:W,deviceClass:m,trafficSource:O,referrerDomain:s,utmParams:kt(),timeOfDay:le(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:l.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||re((K=navigator.userAgent)!=null?K:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{T=fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(p),headers:a}).then(S=>{S.status===402&&console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing")}).catch(()=>{})}catch(S){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let U={goal(s,p={},S=1,L=0){let A=l.getSessionId();if(!A)return;let E=Ae();T.then(()=>{fetch(`${i}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:A,name:s,metadata:p,weight:S,stepIndex:L,goalId:E}),headers:a}).catch(()=>{})})},componentGoal(s,p,S){var k,G,_;let L=l.getSessionId();if(!L)return;let A=r.get(s,b),E=A?null:(k=C.get(s))!=null?k:null;if(!A&&E===null){e.debug&&console.warn(`[sentient] componentGoal("${s}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let j=A?A.variantId:Se(E),B={id:Ae(),sessionId:L,projectId:e.apiKey,componentId:s,variantId:j,eventType:"goal_achieved",goalType:p,payload:v({reward:(G=S==null?void 0:S.reward)!=null?G:1},(_=S==null?void 0:S.metadata)!=null?_:{}),timestamp:Date.now(),timeInSession:Date.now()-g};e.debug&&console.log("[sentient] componentGoal",B),T.then(()=>o.push(B))},identify(s){let p=l.getSessionId();p&&T.then(()=>{fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:p,userId:s,ephemeral:l.isEphemeral()}),headers:a}).catch(()=>{})})},track(s){let p=l.getSessionId();if(!p)return;let S=Q(v({},s),{id:Ae(),sessionId:p,timestamp:Date.now(),timeInSession:Date.now()-g});e.debug&&console.log("[sentient] track",S),T.then(()=>o.push(S))},getAssignment(s,p){return r.get(s,p)},async assign(s,p,S,L){let A=l.getSessionId();if(!A)return null;let E=r.get(s,b);if(E&&(p!=null&&p.length||E.content!==void 0)){let k=E.ttlMs&&E.ttlMs>0?Math.max(0,E.assignedAt+E.ttlMs-Date.now()):0;return{variantId:E.variantId,assignmentTtlMs:k,content:E.content}}let j=I.get(s);if(j)return j;let B=(async()=>{await T;try{let k={sessionId:A,componentId:s,variantIds:p};L!==void 0?k.agentDataByVariant=L:S!==void 0&&(k.agentData=S);let G=await fetch(`${i}/assign`,{method:"POST",body:JSON.stringify(k),headers:a});if(!G.ok)return null;let _=await G.json();return r.set(s,b,v({variantId:_.variantId,assignedAt:Date.now(),segment:b,confidence:1,content:_.content},_.assignmentTtlMs&&_.assignmentTtlMs>0?{ttlMs:_.assignmentTtlMs}:{})),_}catch(k){return null}finally{I.delete(s)}})();return I.set(s,B),B},async decide(s){var L,A,E,j,B,k,G,_,_e;let p=l.getSessionId();if(!p)return null;let S=(L=s.slots)!=null?L:[];await T;try{let F={sessionId:p};s.sections&&s.sections.length>0&&(F.sections=s.sections.map(D=>({id:D}))),F.components=(A=s.components)!=null?A:[],S.length>0&&(F.slots=S.map(ce)),s.slotsFrom==="registry"&&(F.slotsFrom="registry"),s.v&&(F.v=s.v);let De=await fetch(`${i}/decide`,{method:"POST",body:JSON.stringify(F),headers:a});if(!De.ok)return ue(S),null;let w=await De.json(),ee={};for(let D of S)ee[D.id]=(j=(E=w.slots)==null?void 0:E[D.id])!=null?j:z(D);if(w.slots)for(let[D,te]of Object.entries(w.slots))D in ee||(ee[D]=te);for(let[D,te]of Object.entries(ee))C.set(D,te);let He=h!=null&&h.persona!=="unknown";w.persona&&!(w.persona==="unknown"&&He)?h={persona:w.persona,confidence:(B=w.confidence)!=null?B:0}:h||(h={persona:"unknown",confidence:0});for(let[D,te]of Object.entries((k=w.assignments)!=null?k:{}))r.set(D,b,{variantId:te,assignedAt:Date.now(),segment:b,confidence:1});return H(e.apiKey,v({v:1,persona:h.persona,band:(0,Re.confidenceBand)(h.confidence),slots:Object.fromEntries(C),layoutOrder:(G=w.layoutOrder)!=null?G:null,savedAt:Date.now()},w.slotConfig?{slotConfig:w.slotConfig}:{})),v(v(v({layoutOrder:(_=w.layoutOrder)!=null?_:null,assignments:(_e=w.assignments)!=null?_e:{},slots:ee,persona:h.persona,confidence:h.confidence},w.slotConfig?{slotConfig:w.slotConfig}:{}),w.goals?{goals:w.goals}:{}),w.sectionMap?{sectionMap:w.sectionMap}:{})}catch(F){return ue(S),null}},getSlotResult(s){var p;return(p=C.get(s))!=null?p:null},getPersona(){return h?{persona:h.persona,confidence:h.confidence,band:(0,Re.confidenceBand)(h.confidence)}:null},async fetchWeights(){var s;try{let p=await fetch(`${i}/weights`,{headers:a});return p.ok?(s=(await p.json()).components)!=null?s:[]:[]}catch(p){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var s;o.destroy(),((s=R.get(e.apiKey))==null?void 0:s.dispose)===U.dispose&&R.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var s;o.destroy(),l.destroy(),((s=R.get(e.apiKey))==null?void 0:s.dispose)===U.dispose&&R.delete(e.apiKey);try{localStorage.removeItem(J+e.apiKey),localStorage.removeItem(Ee(e.apiKey))}catch(p){}e.debug&&console.log("[sentient] destroyed")}};if(R.set(e.apiKey,{config:e,upgrade:null,dispose:U.dispose}),e.debug){let s=window;s.__sentient&&(s.__sentient.client=U)}return U}0&&(module.exports={AGENT_INTENTS,LOCAL_MODE_BANNER,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,toWireSlot,uaTokenMatch,writeSnapshot});
1
+ "use strict";var Ye=Object.create;var ne=Object.defineProperty,qe=Object.defineProperties,Xe=Object.getOwnPropertyDescriptor,Ze=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,tt=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var Te=(e,t,n)=>t in e?ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&Te(e,n,t[n]);if(Oe)for(var n of Oe(t))nt.call(t,n)&&Te(e,n,t[n]);return e},Q=(e,t)=>qe(e,Ze(t));var ot=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})},Le=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of et(t))!Pe.call(e,u)&&u!==n&&ne(e,u,{get:()=>t[u],enumerable:!(c=Xe(t,u))||c.enumerable});return e};var rt=(e,t,n)=>(n=e!=null?Ye(tt(e)):{},Le(t||!e||!e.__esModule?ne(n,"default",{value:e,enumerable:!0}):n,e)),st=e=>Le(ne({},"__esModule",{value:!0}),e);var Tt={};ot(Tt,{AGENT_INTENTS:()=>ye,LOCAL_MODE_BANNER:()=>Ce,PROD_KEYLESS_ERROR:()=>be,SNAPSHOT_STORAGE_KEY_PREFIX:()=>J,agentIntent:()=>Ue,agentUaList:()=>oe,armOfResult:()=>he,attachMicroSignalDetectors:()=>Fe,baselineResultFor:()=>z,baselineSlots:()=>Be,classifiedAgents:()=>Ke,deriveSessionSegment:()=>Ge,detectDeviceClass:()=>se,detectTimeOfDay:()=>le,detectTrafficSource:()=>ie,grantConsent:()=>Dt,init:()=>ze,isDoNotTrackEnabled:()=>ke,matchedAgentToken:()=>Ie,readSnapshot:()=>Se,referrerDomainFromReferer:()=>ae,renderPrePaintScript:()=>$e,toWireSlot:()=>ce,uaTokenMatch:()=>re,writeSnapshot:()=>H});module.exports=st(Tt);function ge(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(e){}try{if(typeof crypto!="undefined"&&typeof crypto.getRandomValues=="function"){let e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0"),(n===3||n===5||n===7||n===9)&&(t+="-");return t}}catch(e){}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function pe(e){return e?`_${e.slice(0,12)}`:""}var it="_snt_uid",at=365,lt="_snt_uid";function ct(){return ge()}function dt(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function ut(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(c){}}function gt(e){try{return localStorage.getItem(e)}catch(t){return null}}function pt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function ft(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function mt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function yt(e){try{sessionStorage.removeItem(e)}catch(t){}}function ht(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function St(e){try{localStorage.removeItem(e)}catch(t){}}function vt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var wt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function fe(e){var m,E,O,x,A,R;if(typeof window=="undefined")return wt;let t=pe(e==null?void 0:e.apiKey),n=(m=e==null?void 0:e.cookieName)!=null?m:`${it}${t}`,c=`${lt}${t}`,d=((E=e==null?void 0:e.cookieTTLDays)!=null?E:at)*24*60*60,g=S=>S&&S.length>0?S:null,l=(R=(A=(x=(O=g(dt(n)))!=null?O:g(gt(c)))!=null?x:g(ft(c)))!=null?A:g(e==null?void 0:e.ssrSessionId))!=null?R:ct();ut(n,l,d);let r=pt(c,l),o=ht(n),i=r?!1:mt(c,l),a=!r&&!o&&!i;return{getSessionId:()=>l,isEphemeral:()=>a,destroy:()=>{l=null,vt(n),St(c),yt(c)}}}function Ee(e){return`_snt_retry_${e.slice(0,12)}`}var bt={push:()=>{},flush:()=>{},destroy:()=>{}};function xt(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(t),c.slice(-e)):[]}catch(n){return[]}}function xe(e,t,n){try{let c=(()=>{try{let g=localStorage.getItem(n);if(!g)return[];let l=JSON.parse(g);return Array.isArray(l)?l:[]}catch(g){return[]}})(),u=new Map;for(let g of c)u.set(g.id,g);for(let g of e)u.set(g.id,g);let d=[...u.values()].slice(-t);localStorage.setItem(n,JSON.stringify(d))}catch(c){}}function Et(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let u=new Set(e),d=c.filter(g=>!u.has(g.id));if(d.length===c.length)return;d.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(d))}catch(n){}}function Me(e){var q,X,Z;if(typeof window=="undefined")return bt;let t=(q=e.flushIntervalMs)!=null?q:5e3,n=(X=e.maxBatchSize)!=null?X:20,c=(Z=e.maxRetrySize)!=null?Z:100,u=e.ingestUrl,d=e.apiKey,g=Ee(d),l=[],r=new Set,o=[],i=f=>{for(let h of f)a.delete(h),!r.has(h)&&(r.add(h),o.push(h));for(;o.length>500;){let h=o.shift();h&&r.delete(h)}Et(f,g)},a=new Set,m=f=>{r.has(f.id)||a.has(f.id)||(a.add(f.id),l.push(f))},E=f=>{for(let h of f)r.has(h.id)||(a.add(h.id),l.push(h))},O=xt(c,g);for(let f of O)m(f);let x=0,A=0,R=f=>{if(f.length===0)return;let h=JSON.stringify(f),K=f.map(s=>s.id),L;try{L=fetch(u,{method:"POST",keepalive:!0,body:h,headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`}})}catch(s){xe(f,c,g),E(f),A++,x=Date.now()+Math.min(6e4,1e3*2**Math.min(A,6));return}let $=s=>{if(s.ok||s.status>=400&&s.status<500&&s.status!==429){i(K),A=0,x=0;return}xe(f,c,g),E(f),A++,x=Date.now()+Math.min(6e4,1e3*2**Math.min(A,6))};L instanceof Promise?L.then($).catch(()=>{xe(f,c,g),E(f),A++,x=Date.now()+Math.min(6e4,1e3*2**Math.min(A,6))}):$(L)},S=typeof TextEncoder!="undefined"?new TextEncoder:null,ue=f=>S?S.encode(f).length:f.length,W=f=>{let h=[],K=2;for(let L of f){let $=ue(JSON.stringify(L))+1;if(h.length>0&&K+$>57344||h.length>=n)break;h.push(L),K+=$}return h},U=()=>{try{if(Date.now()<x)return;for(;l.length>0&&!(Date.now()<x);){let f=l.filter(K=>!r.has(K.id));if(l.length=0,f.length===0)break;let h=W(f);if(h.length===0)break;h.length<f.length&&l.push(...f.slice(h.length)),R(h)}}catch(f){}},P=!0,j=null;j=setInterval(()=>{P&&U()},t);let B=()=>{document.visibilityState==="hidden"&&U()},Y=()=>{U()};return document.addEventListener("visibilitychange",B),window.addEventListener("pagehide",Y),{push(f){m(f),l.length>=n&&U()},flush:U,destroy(){P=!1,j!==null&&(clearInterval(j),j=null),document.removeEventListener("visibilitychange",B),window.removeEventListener("pagehide",Y),U()}}}var It=1800*1e3;function me(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ne(e=It,t){let n=new Map,c=`_snt_asgn${pe(t)}_`,u=(o,i)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(i)}`,d=o=>{let i=o.slice(c.length),a=i.indexOf(":");if(a<0)return null;try{return{componentId:decodeURIComponent(i.slice(0,a)),segment:decodeURIComponent(i.slice(a+1))}}catch(m){return null}},g=()=>{try{let o=[];for(let i=0;i<localStorage.length;i++){let a=localStorage.key(i);a!=null&&a.startsWith(c)&&o.push(a)}return o}catch(o){return[]}},l=o=>o.assignedAt+(o.ttlMs&&o.ttlMs>0?o.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let o of g())try{let i=localStorage.getItem(o);if(!i)continue;let a=JSON.parse(i);if(l(a)){localStorage.removeItem(o);continue}let m=d(o);if(!m)continue;n.set(me(m.componentId,m.segment),a)}catch(i){}})(),{get(o,i){let a=n.get(me(o,i));return a?l(a)?(n.delete(me(o,i)),null):a:null},set(o,i,a){let m=me(o,i);n.set(m,a);try{localStorage.setItem(u(o,i),JSON.stringify(a))}catch(E){}},invalidate(o){let i=`${encodeURIComponent(o)}:`;for(let a of[...n.keys()])a.startsWith(i)&&n.delete(a);for(let a of g()){let m=d(a);if((m==null?void 0:m.componentId)===o)try{localStorage.removeItem(a)}catch(E){}}},clear(){n.clear();for(let o of g())try{localStorage.removeItem(o)}catch(i){}}}}var oe=["GPTBot","ChatGPT-User","OAI-SearchBot","ClaudeBot","Claude-User","Claude-SearchBot","PerplexityBot","Perplexity-User","Google-Extended","Applebot-Extended","Meta-ExternalAgent","Bytespider","CCBot","Amazonbot","cohere-ai","Diffbot"];function re(e){return Ie(e)!==null}function Ie(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=oe.find(c=>t.includes(c.toLowerCase())))!=null?n:null}var ye={GPTBot:"training","ChatGPT-User":"user","OAI-SearchBot":"search",ClaudeBot:"training","Claude-User":"user","Claude-SearchBot":"search",PerplexityBot:"search","Perplexity-User":"user","Google-Extended":"training","Applebot-Extended":"training","Meta-ExternalAgent":"training",Bytespider:"training",CCBot:"training",Amazonbot:"other","cohere-ai":"training",Diffbot:"other"};function Ue(e){if(!e)return"other";let t=oe.find(n=>n.toLowerCase()===e.toLowerCase());return t&&ye[t]||"other"}function Ke(){var t;let e={user:[],search:[],training:[],other:[]};for(let n of oe)e[(t=ye[n])!=null?t:"other"].push(n);return e}function se(e){let t=e.toLowerCase();return/ipad|tablet|playbook|kindle|silk/.test(t)?"tablet":/mobi|iphone|ipod|android.*mobile|phone/.test(t)?"mobile":"desktop"}function ie(e,t){if(!e)return"direct";try{let n=new URL(e);if(t)try{if(new URL(t).host===n.host)return"direct"}catch(u){}let c=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(c)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(c)?"social":"referral"}catch(n){return"direct"}}function ae(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function le(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ge(e){let t=Ct("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function Ct(e,t){var d,g,l,r,o,i,a;let n=(g=(d=t==null?void 0:t.userAgent)==null?void 0:d.trim())!=null?g:"",c=(r=(l=t==null?void 0:t.referer)==null?void 0:l.trim())!=null?r:"",u=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(i=t==null?void 0:t.utmParams)!=null?i:{},deviceClass:n?se(n):"desktop",trafficSource:c?ie(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:ae(c),timeOfDay:le(u),dayOfWeek:(a=["sun","mon","tue","wed","thu","fri","sat"][u.getDay()])!=null?a:"sun",automation:(t==null?void 0:t.webdriver)===!0||re(n)}}var V=require("@sentientui/policy");function ce(e){return w(w(w({id:e.id},e.arms?{arms:[...e.arms]}:{}),e.dims?{dims:Object.fromEntries(Object.entries(e.dims).map(([t,n])=>[t,[...n]]))}:{}),e.baseline!==void 0?{baseline:e.baseline}:{})}function z(e){let t=ce(e);return(0,V.slotResultFor)(t,(0,V.slotBaselineArm)(t))}function Be(e){let t={};for(let n of e)t[n.id]=z(n);return t}function he(e){return typeof e=="string"?e:(0,V.canonicalArm)(e)}var J="_snt_snap:",At=["low","medium","high"];function Se(e){try{let t=localStorage.getItem(J+e);if(!t)return null;let n=JSON.parse(t);return!n||typeof n!="object"||n.v!==1||typeof n.persona!="string"||typeof n.band!="string"||!At.includes(n.band)||typeof n.slots!="object"||n.slots===null||Array.isArray(n.slots)||!(n.layoutOrder===null||Array.isArray(n.layoutOrder))||typeof n.savedAt!="number"||!(n.slotConfig===void 0||typeof n.slotConfig=="object"&&n.slotConfig!==null&&!Array.isArray(n.slotConfig))?null:n}catch(t){return null}}function H(e,t){try{localStorage.setItem(J+e,JSON.stringify(t))}catch(n){}}function $e(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(J+e).replace(/</g,"\\u003c")+');if(!r)return;var s=JSON.parse(r);if(!s||s.v!==1||typeof s.persona!=="string"||typeof s.band!=="string")return;var d=document.documentElement;if(d.hasAttribute("data-sentient-persona"))return;d.setAttribute("data-sentient-persona",s.persona);d.setAttribute("data-sentient-confidence",s.band);}catch(e){}})();'}var Re=require("@sentientui/policy");var we=require("@sentientui/policy");var be="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ce="[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.",We=!1,ve=!1;function Rt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function je(e){var l;let t=fe({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(l=t.getSessionId())!=null?l:"local",c=Rt(),u=import("@sentientui/core/local").then(r=>{let o=r;return o.LOCAL_ENGINE_AVAILABLE?(We||(We=!0,console.info(Ce)),o):(ve||(ve=!0,console.error(be)),null)}).catch(()=>(ve||(ve=!0,console.error(be)),null)),d=null;function g(r){let o=document.documentElement;o.dataset.sentientPersona===void 0&&(o.dataset.sentientPersona=r.persona,o.dataset.sentientConfidence=(0,we.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var a,m,E;let o=await u;if(!o)return null;let i=o.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return d=Q(w({},i),{layoutOrder:(m=(a=i.layoutOrder)!=null?a:d==null?void 0:d.layoutOrder)!=null?m:null,slots:w(w({},(E=d==null?void 0:d.slots)!=null?E:{}),i.slots)}),H(e.apiKey||"local",{v:1,persona:d.persona,band:(0,we.confidenceBand)(d.confidence),slots:d.slots,layoutOrder:d.layoutOrder,savedAt:Date.now()}),g(i),i},getSlotResult(r){var o,i,a;return(a=(i=d==null?void 0:d.slots[r])!=null?i:(o=e.initialSlots)==null?void 0:o[r])!=null?a:null},getPersona(){return d?{persona:d.persona,confidence:d.confidence,band:(0,we.confidenceBand)(d.confidence)}:null},async assign(r,o){var m;let i=await u;return!i||!o||o.length===0?o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null:{variantId:(m=i.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:o}]}).assignments[r])!=null?m:o[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}function Fe(e,t,n,c){let u=[];{let l=!1,r=[],o=()=>{if(l)return;let i=Date.now();for(r.push(i);r.length>0&&i-r[0]>500;)r.shift();r.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",o),u.push(()=>t.removeEventListener("click",o))}{let d=!1,g=l=>{if(d||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;d=!0;let r=typeof window!="undefined"?window.getSelection():null,o=r?r.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",g),u.push(()=>document.removeEventListener("copy",g))}{let d=!1,g=!1,l=null,r=()=>{l!==null&&(clearTimeout(l),l=null)},o=()=>{d||!g||(r(),l=setTimeout(()=>{!d&&g&&(d=!0,e("scroll_hesitation"))},3e3))},i=()=>{r(),o()},a=E=>{for(let O of E)g=O.intersectionRatio>.3,g?o():r()},m=new IntersectionObserver(a,{threshold:[.3]});m.observe(t),window.addEventListener("scroll",i,{passive:!0}),u.push(()=>{m.disconnect(),window.removeEventListener("scroll",i),r()})}if((c==null?void 0:c.tabLoss)!==!1){let d=!1,g=n!=null?n:Date.now(),l=()=>{if(d||document.visibilityState!=="hidden")return;let r=Date.now()-g;r<15e3&&(d=!0,e("tab_loss",{timeOnPage:r}))};document.addEventListener("visibilitychange",l),u.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let d of u)d()}}var Je="https://api.sentient-ui.com/v1/events",_=new Map,Qe=null;function kt(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}function Ae(){return ge()}var de={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,assign:()=>Promise.resolve(null),decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}};function _t(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,c]of t)n.startsWith("utm_")&&(e[n]=c);return e}catch(e){return{}}}function Ve(e){return e.replace(/\/events\/?$/,"")}function ke(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(t=>t==="1"||t==="yes")}function Dt(e){var l;if(typeof window=="undefined")return;let t=e!=null?e:Qe;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=_.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:u}=n;if(!u||c.respectDoNotTrack!==!1&&ke())return;let d=ze(Q(w({},c),{consent:!0}));u(d);let g=(l=_.get(t))==null?void 0:l.dispose;_.set(t,{config:Q(w({},c),{consent:!0}),upgrade:null,dispose:g})}function Ot(e){var l;let t=e.preConsentBehavior==="statistical_winner",n=Ve((l=e.ingestUrl)!=null?l:Je),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},u={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,o,i){if(!t)return null;try{let a=new URLSearchParams({componentId:r});for(let O of o!=null?o:[])a.append("variantIds[]",O);let m=await fetch(`${n}/winner?${a.toString()}`,{headers:c});return m.ok?{variantId:(await m.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(a){return o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},d={track:r=>u.track(r),goal:((r,o,i,a)=>u.goal(r,o,i,a)),componentGoal:(r,o,i)=>u.componentGoal(r,o,i),identify:r=>u.identify(r),getAssignment:(r,o)=>u.getAssignment(r,o),assign:(r,o,i,a)=>u.assign(r,o,i,a),decide:r=>u.decide(r),getSlotResult:r=>u.getSlotResult(r),getPersona:()=>u.getPersona(),fetchWeights:()=>u.fetchWeights(),getGraph:()=>u.getGraph(),dispose:()=>u.dispose(),destroy:()=>u.destroy()};function g(r){u=r}return{proxy:d,setInner:g}}function ze(e){var Y,q,X,Z,f,h,K,L,$;if(typeof window=="undefined")return de;Qe=e.apiKey;let t=_.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(s){}let n=e.respectDoNotTrack!==!1&&ke(),c=e.consent===!1||n,u=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!u&&e.localMode!==!1)return c?(_.set(e.apiKey||"local",{config:e,upgrade:null}),de):(_.set(e.apiKey||"local",{config:e,upgrade:null}),je(e));if(c){if(!e.apiKey||!e.apiKey.startsWith("pk_"))return e.preConsentBehavior==="statistical_winner"&&console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),_.set(e.apiKey,{config:e,upgrade:null}),de;let{proxy:s,setInner:p}=Ot(e);return _.set(e.apiKey,{config:e,upgrade:n?null:p}),s}if(!e.apiKey||!e.apiKey.startsWith("pk_"))return console.warn("[sentient] init() called with an invalid apiKey \u2014 expected a pk_ public key. SDK disabled."),de;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),de;let d=(Y=e.ingestUrl)!=null?Y:Je,g=Date.now(),l=fe({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),r=Ne(void 0,e.apiKey),o=Me({ingestUrl:d,apiKey:e.apiKey}),i=Ve(d),a={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},m=se((q=navigator.userAgent)!=null?q:""),E=typeof window!="undefined"?window.location.origin:void 0,O=ie((X=document.referrer)!=null?X:"",E),x=(Z=e.sessionSegment)!=null?Z:`${m}:${O}`,A=new Map,R=new Map,S=null,ue=s=>{for(let p of s)R.has(p.id)||R.set(p.id,z(p))};if(e.initialSlots)for(let[s,p]of Object.entries(e.initialSlots))R.set(s,p);let W=Se(e.apiKey);if(W)for(let[s,p]of Object.entries(W.slots))R.has(s)||R.set(s,p);let U={low:.15,medium:.5,high:.85};if(e.initialPersona)S=w({},e.initialPersona);else{let s=document.documentElement.dataset;s.sentientPersona?S={persona:s.sentientPersona,confidence:(h=U[(f=s.sentientConfidence)!=null?f:"low"])!=null?h:.15}:W&&(S={persona:W.persona,confidence:(K=U[W.band])!=null?K:.15})}if(e.initialAssignments)for(let[s,p]of Object.entries(e.initialAssignments))r.set(s,x,{variantId:p,assignedAt:Date.now(),segment:x,confidence:1});let P=Promise.resolve(),j=l.getSessionId();if(j){let s=ae((L=document.referrer)!=null?L:""),p=w(w({sessionId:j,deviceClass:m,trafficSource:O,referrerDomain:s,utmParams:_t(),timeOfDay:le(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:l.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||re(($=navigator.userAgent)!=null?$:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{P=fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(p),headers:a}).then(y=>{y.status===402&&console.warn("[SentientUI] Session limit exceeded for this project. The bandit will stop learning until the limit resets. Upgrade at sentient-ui.com/pricing")}).catch(()=>{})}catch(y){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let B={goal(s,p={},y=1,M=0){var I,T,C;let k=l.getSessionId();if(!k)return;let v=kt(p)?p:{metadata:p},G=Ae(),N={sessionId:k,name:s,metadata:(I=v.metadata)!=null?I:{},weight:(T=v.weight)!=null?T:y,stepIndex:(C=v.stepIndex)!=null?C:M,goalId:G,value:v.value,currency:v.currency,externalId:v.externalId};P.then(()=>{fetch(`${i}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify(N),headers:a}).catch(()=>{})})},componentGoal(s,p,y){var I,T,C;let M=l.getSessionId();if(!M)return;let k=r.get(s,x),v=k?null:(I=R.get(s))!=null?I:null;if(!k&&v===null){e.debug&&console.warn(`[sentient] componentGoal("${s}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let G=k?k.variantId:he(v),N={id:Ae(),sessionId:M,projectId:e.apiKey,componentId:s,variantId:G,eventType:"goal_achieved",goalType:p,payload:w({reward:(T=y==null?void 0:y.reward)!=null?T:1,goalValue:y==null?void 0:y.value,currency:y==null?void 0:y.currency},(C=y==null?void 0:y.metadata)!=null?C:{}),timestamp:Date.now(),timeInSession:Date.now()-g};e.debug&&console.log("[sentient] componentGoal",N),P.then(()=>o.push(N))},identify(s){let p=l.getSessionId();p&&P.then(()=>{fetch(`${i}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:p,userId:s,ephemeral:l.isEphemeral()}),headers:a}).catch(()=>{})})},track(s){let p=l.getSessionId();if(!p)return;let y=Q(w({},s),{id:Ae(),sessionId:p,timestamp:Date.now(),timeInSession:Date.now()-g});e.debug&&console.log("[sentient] track",y),P.then(()=>o.push(y))},getAssignment(s,p){return r.get(s,p)},async assign(s,p,y,M){let k=l.getSessionId();if(!k)return null;let v=r.get(s,x);if(v&&(p!=null&&p.length||v.content!==void 0)){let I=v.ttlMs&&v.ttlMs>0?Math.max(0,v.assignedAt+v.ttlMs-Date.now()):0;return{variantId:v.variantId,assignmentTtlMs:I,content:v.content}}let G=A.get(s);if(G)return G;let N=(async()=>{await P;try{let I={sessionId:k,componentId:s,variantIds:p};M!==void 0?I.agentDataByVariant=M:y!==void 0&&(I.agentData=y);let T=await fetch(`${i}/assign`,{method:"POST",body:JSON.stringify(I),headers:a});if(!T.ok)return null;let C=await T.json();return r.set(s,x,w({variantId:C.variantId,assignedAt:Date.now(),segment:x,confidence:1,content:C.content},C.assignmentTtlMs&&C.assignmentTtlMs>0?{ttlMs:C.assignmentTtlMs}:{})),C}catch(I){return null}finally{A.delete(s)}})();return A.set(s,N),N},async decide(s){var M,k,v,G,N,I,T,C,_e;let p=l.getSessionId();if(!p)return null;let y=(M=s.slots)!=null?M:[];await P;try{let F={sessionId:p};s.sections&&s.sections.length>0&&(F.sections=s.sections.map(D=>({id:D}))),F.components=(k=s.components)!=null?k:[],y.length>0&&(F.slots=y.map(ce)),s.slotsFrom==="registry"&&(F.slotsFrom="registry"),s.v&&(F.v=s.v);let De=await fetch(`${i}/decide`,{method:"POST",body:JSON.stringify(F),headers:a});if(!De.ok)return ue(y),null;let b=await De.json(),ee={};for(let D of y)ee[D.id]=(G=(v=b.slots)==null?void 0:v[D.id])!=null?G:z(D);if(b.slots)for(let[D,te]of Object.entries(b.slots))D in ee||(ee[D]=te);for(let[D,te]of Object.entries(ee))R.set(D,te);let He=S!=null&&S.persona!=="unknown";b.persona&&!(b.persona==="unknown"&&He)?S={persona:b.persona,confidence:(N=b.confidence)!=null?N:0}:S||(S={persona:"unknown",confidence:0});for(let[D,te]of Object.entries((I=b.assignments)!=null?I:{}))r.set(D,x,{variantId:te,assignedAt:Date.now(),segment:x,confidence:1});return H(e.apiKey,w({v:1,persona:S.persona,band:(0,Re.confidenceBand)(S.confidence),slots:Object.fromEntries(R),layoutOrder:(T=b.layoutOrder)!=null?T:null,savedAt:Date.now()},b.slotConfig?{slotConfig:b.slotConfig}:{})),w(w(w({layoutOrder:(C=b.layoutOrder)!=null?C:null,assignments:(_e=b.assignments)!=null?_e:{},slots:ee,persona:S.persona,confidence:S.confidence},b.slotConfig?{slotConfig:b.slotConfig}:{}),b.goals?{goals:b.goals}:{}),b.sectionMap?{sectionMap:b.sectionMap}:{})}catch(F){return ue(y),null}},getSlotResult(s){var p;return(p=R.get(s))!=null?p:null},getPersona(){return S?{persona:S.persona,confidence:S.confidence,band:(0,Re.confidenceBand)(S.confidence)}:null},async fetchWeights(){var s;try{let p=await fetch(`${i}/weights`,{headers:a});return p.ok?(s=(await p.json()).components)!=null?s:[]:[]}catch(p){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var s;o.destroy(),((s=_.get(e.apiKey))==null?void 0:s.dispose)===B.dispose&&_.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var s;o.destroy(),l.destroy(),((s=_.get(e.apiKey))==null?void 0:s.dispose)===B.dispose&&_.delete(e.apiKey);try{localStorage.removeItem(J+e.apiKey),localStorage.removeItem(Ee(e.apiKey))}catch(p){}e.debug&&console.log("[sentient] destroyed")}};if(_.set(e.apiKey,{config:e,upgrade:null,dispose:B.dispose}),e.debug){let s=window;s.__sentient&&(s.__sentient.client=B)}return B}0&&(module.exports={AGENT_INTENTS,LOCAL_MODE_BANNER,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentIntent,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,classifiedAgents,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,toWireSlot,uaTokenMatch,writeSnapshot});
2
2
  //# sourceMappingURL=index.js.map