@sentientui/core 0.16.4 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-VJZDW3BH.mjs +2 -0
- package/dist/chunk-VJZDW3BH.mjs.map +1 -0
- package/dist/{index-CTs3AM9E.d.ts → index-BpGkrzI3.d.ts} +16 -1
- package/dist/index-engagement.js +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-engagement.mjs.map +1 -1
- package/dist/index-graph.d.cts +2 -2
- package/dist/index-graph.d.ts +2 -2
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-local.d.cts +1 -1
- package/dist/index-local.d.ts +1 -1
- package/dist/{index-DqbtJfra.d.cts → index-oQoVHiWq.d.cts} +16 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-SHGSYP75.mjs +0 -2
- package/dist/chunk-SHGSYP75.mjs.map +0 -1
package/dist/index-graph.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as v,d as w}from"./chunk-CD2A55US.mjs";import{h as N,j as T}from"./chunk-
|
|
1
|
+
import{a as v,d as w}from"./chunk-CD2A55US.mjs";import{h as N,j as T}from"./chunk-VJZDW3BH.mjs";import{d as R,e as P,f as D,g as k,h as G}from"./chunk-L5TA3FAB.mjs";import{a as h,b}from"./chunk-TMCGHANO.mjs";var $=new Set(["SECTION","ARTICLE","MAIN","DIV"]),j="h1, h2, h3",L={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function S(e,t,o){return o<=t?0:Math.max(0,Math.min(1,(e-t)/(o-t)))}function U(e){var t,o,m;try{let u=e;for(let s of Object.keys(u)){if(!s.startsWith("__reactFiber")&&!s.startsWith("__reactInternalInstance"))continue;let n=u[s],r=(m=(t=n==null?void 0:n.type)==null?void 0:t.displayName)!=null?m:(o=n==null?void 0:n.type)==null?void 0:o.name;if(r&&r.length>1)return r}}catch(u){}}function F(e){let t={};for(let o of Array.from(e.attributes))o.name.startsWith("data-")&&(t[o.name]=o.value);return t}var A=new Set(v);function K(e){let t=e.getAttribute("data-sentient-type");if(t&&A.has(t))return t;let o=e.getAttribute("role");return o&&A.has(o)?o:w(e)}function q(e){var t,o;return(o=(t=e.getAttribute("data-sentient-id"))!=null?t:e.getAttribute("id"))!=null?o:e.tagName.toLowerCase()}function z(e){let t=0,o=e.parentElement;for(;o;)t++,o=o.parentElement;return t}function I(e,t){var m,u,s;let o=e.querySelector(j);return{componentId:q(e),semanticType:K(e),ariaLabel:(m=e.getAttribute("aria-label"))!=null?m:void 0,headingText:(s=(u=o==null?void 0:o.textContent)==null?void 0:u.trim())!=null?s:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:z(e),reactComponentName:U(e),dataAttributes:F(e)}}function x(e){var s;let t=[],o=new Set,m="__root__",u=new Map;for(let[n,r]of e){let i=n.parentElement,c=m;for(;i;){if(e.has(i)){c=e.get(i);let a=e.get(n),g=`${c}->${a}`;!o.has(g)&&c!==a&&(o.add(g),t.push({fromComponentId:c,toComponentId:a,weight:.6}));break}i=i.parentElement}let d=(s=u.get(c))!=null?s:[];d.push(n),u.set(c,d)}for(let n of u.values())if(!(n.length<2))for(let r=0;r<n.length;r++)for(let i=r+1;i<n.length;i++){let c=e.get(n[r]),d=e.get(n[i]);if(c===d)continue;let a=`${c}->${d}::sib`,g=`${d}->${c}::sib`;o.has(a)||(o.add(a),t.push({fromComponentId:c,toComponentId:d,weight:.3})),o.has(g)||(o.add(g),t.push({fromComponentId:d,toComponentId:c,weight:.3}))}return t}function B(e){let t=[],o=new Set,m=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(n=>{if(n instanceof Element&&!o.has(n)){o.add(n);let r=I(n,e);t.push(r),m.set(n,r.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(n=>{if(!(n instanceof Element)||o.has(n))return;let r=n.hasAttribute("aria-label"),i=n.hasAttribute("data-sentient-id");if(!r&&!i)return;o.add(n);let c=I(n,e);t.push(c),m.set(n,c.componentId)}),{nodes:t,edges:x(m)}}function _(){if(typeof window=="undefined")return L;let e=null,t=0,o=null,m=r=>{try{let i=window.getComputedStyle(r),c=parseFloat(i.fontSize)||12,d=parseFloat(i.zIndex)||0,a=r.getBoundingClientRect(),g=Math.max(a.top,0),p=window.innerHeight||1,l=1/(g/p+1),f=S(c,12,48)*.4+S(l,0,1)*.4+S(d,0,100)*.2;return Math.max(0,Math.min(1,f))}catch(i){return .5}};return{scan:()=>new Promise(r=>{let i=()=>{let{nodes:c,edges:d}=B(m);r({nodes:c,edges:d,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(i,{timeout:100}):i()}catch(c){i()}}),observe:r=>{o=r;try{e=new MutationObserver(i=>{let c=[],d=new Map;for(let a of i)a.type==="childList"&&a.addedNodes.forEach(g=>{if(!(g instanceof Element)||!$.has(g.tagName))return;let p=g.hasAttribute("data-sentient-id"),l=g.hasAttribute("aria-label");if(!p&&!l)return;let f=I(g,m);c.push(f),d.set(g,f.componentId)});c.length>0&&o&&o({nodes:c,edges:x(d),addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(i){}},getProminenceScore:m,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(r){}t=0,o=null}}}var E="_snt_graph_nodes",O="_snt_graph_edges",H={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function J(e){var t;return(t=H[e])!=null?t:[]}function V(e,t){try{let o=localStorage.getItem(e);return o?JSON.parse(o):t}catch(o){return t}}function Y(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(o){}}var W=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Q(e){return W.has(e)?e:"generic"}function X(e,t,o){let m=`${e}:${t}:${o.join(",")}`,u=5381;for(let s=0;s<m.length;s++)u=(u<<5)+u+m.charCodeAt(s)&4294967295;return(u>>>0).toString(16).padStart(8,"0")}function M(e){let t=new Map,o=new Map,m=()=>{typeof window!="undefined"&&Y(E,[...t.values()])},u=s=>{var n;try{let r=JSON.parse(s);t.clear();for(let i of(n=r.pageNodes)!=null?n:[])t.set(i.componentId,i)}catch(r){}};if(typeof window!="undefined"){let s=V(E,[]);for(let n of s)t.set(n.componentId,n);try{localStorage.removeItem(O)}catch(n){}}return{addPageNode(s){t.set(s.componentId,s),m()},addStructuralEdge(s){let n=`${s.fromComponentId}->${s.toComponentId}`;o.set(n,s)},syncOnce(){var n,r;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let s=[...t.values()];if(s.length!==0)try{let i=new Map;for(let p of s){let l=(n=i.get(p.semanticType))!=null?n:[];l.push(p),i.set(p.semanticType,l)}let c=[],d=new Set;for(let p of s)for(let l of J(p.semanticType)){let f=(r=i.get(l))!=null?r:[];for(let y of f){if(y.componentId===p.componentId)continue;let C=`semantic:${p.componentId}->${y.componentId}`;d.has(C)||(d.add(C),c.push({fromComponentId:p.componentId,toComponentId:y.componentId,type:"semantic",weight:.4,confidence:.9}))}}let a=new Set(s.map(p=>p.componentId));for(let p of o.values()){if(!a.has(p.fromComponentId)||!a.has(p.toComponentId))continue;let l=`structural:${p.fromComponentId}->${p.toComponentId}`;d.has(l)||(d.add(l),c.push({fromComponentId:p.fromComponentId,toComponentId:p.toComponentId,type:"structural",weight:p.weight,confidence:1}))}let g={pageUrl:window.location.href,nodes:s.map(p=>{let l=Q(p.semanticType);return{componentId:p.componentId,semanticType:l,answers:p.answers,contentHash:X(p.componentId,l,p.answers),prominenceScore:p.prominenceScore,depthInPage:p.depth}}),edges:c};fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:h({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(g)}).catch(()=>{})}catch(i){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},serialize(){return JSON.stringify({pageNodes:[...t.values()]})},restore:u,destroy(){if(typeof window!="undefined")try{localStorage.removeItem(E),localStorage.removeItem(O)}catch(s){}}}}var Z="https://api.sentient-ui.com/v1/events";function ee(){try{let e=document.cookie.match(/(?:^|; )_snt_uid=([^;]*)/);return e?decodeURIComponent(e[1]):void 0}catch(e){return}}function ce(e){var c;let t=T(e),o=e.respectDoNotTrack!==!1&&N(),m=e.consent===!1||o;if(!e.graph||!e.apiKey||m||typeof window=="undefined")return t;let u=_(),s=(c=e.ingestUrl)!=null?c:Z,n=M({syncUrl:s.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:ee()});try{let d=localStorage.getItem("_snt_graph_nodes");d&&n.restore(JSON.stringify({pageNodes:JSON.parse(d)}))}catch(d){}u.scan().then(d=>{for(let a of d.nodes)n.addPageNode({id:a.componentId,componentId:a.componentId,semanticType:a.semanticType,answers:a.headingText?[a.headingText]:[],prominenceScore:a.prominenceScore,depth:a.depth});for(let a of d.edges)n.addStructuralEdge(a);n.syncOnce()});let r=null,i=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,n.syncOnce()},500)};return u.observe(d=>{for(let a of d.nodes)n.addPageNode({id:a.componentId,componentId:a.componentId,semanticType:a.semanticType,answers:a.headingText?[a.headingText]:[],prominenceScore:a.prominenceScore,depth:a.depth});for(let a of d.edges)n.addStructuralEdge(a);i()}),b(h({},t),{getGraph:()=>n.snapshot(),dispose:()=>{r!==null&&clearTimeout(r),u.destroy(),n.destroy(),t.dispose()},destroy:()=>{r!==null&&clearTimeout(r),u.destroy(),n.destroy(),t.destroy()}})}export{G as deriveSessionSegment,R as detectDeviceClass,k as detectTimeOfDay,P as detectTrafficSource,ce as init,D as referrerDomainFromReferer};
|
|
2
2
|
//# sourceMappingURL=index-graph.mjs.map
|
package/dist/index-local.d.cts
CHANGED
package/dist/index-local.d.ts
CHANGED
|
@@ -54,6 +54,12 @@ type Assignment = {
|
|
|
54
54
|
segment: string;
|
|
55
55
|
confidence: number;
|
|
56
56
|
content?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Per-entry expiry (ms from `assignedAt`). When present it overrides the
|
|
59
|
+
* cache-wide default TTL — lets the server-provided `assignmentTtlMs` govern
|
|
60
|
+
* how long this specific assignment stays valid. Persists across reloads.
|
|
61
|
+
*/
|
|
62
|
+
ttlMs?: number;
|
|
57
63
|
};
|
|
58
64
|
type AssignmentCache = {
|
|
59
65
|
get(componentId: string, segment: string): Assignment | null;
|
|
@@ -280,6 +286,14 @@ type GoalDefinition = {
|
|
|
280
286
|
urlPattern?: string;
|
|
281
287
|
slotId?: string;
|
|
282
288
|
};
|
|
289
|
+
/** One served section-classification row (registry mode): where it is on the
|
|
290
|
+
* page (url match + compound locator) and its semantic type. The snippet
|
|
291
|
+
* resolves the locator to build capture's `typeOf` hook. */
|
|
292
|
+
type SectionMapEntry = {
|
|
293
|
+
urlMatch: string;
|
|
294
|
+
locator: CompoundLocator;
|
|
295
|
+
type: string;
|
|
296
|
+
};
|
|
283
297
|
type DecideOutcome = {
|
|
284
298
|
layoutOrder: string[] | null;
|
|
285
299
|
assignments: Record<string, string>;
|
|
@@ -288,6 +302,7 @@ type DecideOutcome = {
|
|
|
288
302
|
confidence: number;
|
|
289
303
|
slotConfig?: Record<string, SlotConfigEntry>;
|
|
290
304
|
goals?: GoalDefinition[];
|
|
305
|
+
sectionMap?: SectionMapEntry[];
|
|
291
306
|
};
|
|
292
307
|
type DecideInput = {
|
|
293
308
|
sections?: string[];
|
|
@@ -393,4 +408,4 @@ declare function grantConsent(apiKey?: string): void;
|
|
|
393
408
|
*/
|
|
394
409
|
declare function init(config: SentientConfig): SentientClient;
|
|
395
410
|
|
|
396
|
-
export { type AssignResult as A, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, 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
|
|
411
|
+
export { type AssignResult as A, writeSnapshot as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, 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 };
|
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
|
|
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, B as writeSnapshot } from './index-oQoVHiWq.cjs';
|
|
2
2
|
export { a as SlotDeclInput, b as agentUaList, c as armOfResult, d as baselineResultFor, e as baselineSlots, g as deriveSessionSegment, h as detectDeviceClass, i as detectTimeOfDay, j as detectTrafficSource, m as matchedAgentToken, r as referrerDomainFromReferer, t as toWireSlot, u as uaTokenMatch } from './session-meta-DU_3mY7U.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
|
|
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, B as writeSnapshot } from './index-BpGkrzI3.js';
|
|
2
2
|
export { a as SlotDeclInput, b as agentUaList, c as armOfResult, d as baselineResultFor, e as baselineSlots, g as deriveSessionSegment, h as detectDeviceClass, i as detectTimeOfDay, j as detectTrafficSource, m as matchedAgentToken, r as referrerDomainFromReferer, t as toWireSlot, u as uaTokenMatch } from './session-meta-DU_3mY7U.js';
|
|
3
3
|
export { SlotResult } from '@sentientui/policy';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var He=Object.create;var oe=Object.defineProperty,ze=Object.defineProperties,Ve=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,Ze=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var Te=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))Le.call(t,n)&&Te(e,n,t[n]);if(Oe)for(var n of Oe(t))et.call(t,n)&&Te(e,n,t[n]);return e},F=(e,t)=>ze(e,qe(t));var tt=(e,t)=>{for(var n in t)oe(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Xe(t))!Le.call(e,c)&&c!==n&&oe(e,c,{get:()=>t[c],enumerable:!(a=Ve(t,c))||a.enumerable});return e};var nt=(e,t,n)=>(n=e!=null?He(Ze(e)):{},Pe(t||!e||!e.__esModule?oe(n,"default",{value:e,enumerable:!0}):n,e)),ot=e=>Pe(oe({},"__esModule",{value:!0}),e);var _t={};tt(_t,{LOCAL_MODE_BANNER:()=>Ie,PROD_KEYLESS_ERROR:()=>Se,SNAPSHOT_STORAGE_KEY_PREFIX:()=>W,agentUaList:()=>Ee,armOfResult:()=>fe,attachMicroSignalDetectors:()=>je,baselineResultFor:()=>Y,baselineSlots:()=>Ge,deriveSessionSegment:()=>Ke,detectDeviceClass:()=>se,detectTimeOfDay:()=>le,detectTrafficSource:()=>ie,grantConsent:()=>It,init:()=>Ye,isDoNotTrackEnabled:()=>Re,matchedAgentToken:()=>xe,readSnapshot:()=>pe,referrerDomainFromReferer:()=>ae,renderPrePaintScript:()=>Be,toWireSlot:()=>ce,uaTokenMatch:()=>re,writeSnapshot:()=>H});module.exports=ot(_t);var rt="_snt_uid";var J="_snt_uid";function st(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(t){}let e=()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${e()}-${e()}-${e()}-${e()}`}function it(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function at(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(a){}}function lt(e){try{return localStorage.getItem(e)}catch(t){return null}}function ct(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function dt(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function ut(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function gt(e){try{sessionStorage.removeItem(e)}catch(t){}}function ft(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,/(?:^|; )_snt_uid_probe=1/.test(document.cookie)||document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function pt(e){try{localStorage.removeItem(e)}catch(t){}}function mt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var yt={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ue(e){var d,g,p,v,E,S;if(typeof window=="undefined")return yt;let t=(d=e==null?void 0:e.cookieName)!=null?d:rt,a=((g=e==null?void 0:e.cookieTTLDays)!=null?g:365)*24*60*60,c=(S=(E=(v=(p=it(t))!=null?p:lt(J))!=null?v:dt(J))!=null?E:e==null?void 0:e.ssrSessionId)!=null?S:st();at(t,c,a);let s=ct(J,c),l=ft(t),r=s?!1:ut(J,c),o=!s&&!l&&!r;return{getSessionId:()=>c,isEphemeral:()=>o,destroy:()=>{c=null,mt(t),pt(J),gt(J)}}}function ve(e){return`_snt_retry_${e.slice(0,12)}`}var St={push:()=>{},flush:()=>{},destroy:()=>{}};function ht(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let a=JSON.parse(n);return Array.isArray(a)?(localStorage.removeItem(t),a.slice(-e)):[]}catch(n){return[]}}function he(e,t,n){try{let c=[...(()=>{try{let s=localStorage.getItem(n);if(!s)return[];let l=JSON.parse(s);return Array.isArray(l)?l:[]}catch(s){return[]}})(),...e].slice(-t);localStorage.setItem(n,JSON.stringify(c))}catch(a){}}function Me(e){var X,Z,ee;if(typeof window=="undefined")return St;let t=(X=e.flushIntervalMs)!=null?X:5e3,n=(Z=e.maxBatchSize)!=null?Z:20,a=(ee=e.maxRetrySize)!=null?ee:100,c=e.ingestUrl,s=e.apiKey,l=ve(s),r=[],o=new Set,d=[],g=f=>{for(let y of f)p.delete(y),!o.has(y)&&(o.add(y),d.push(y));for(;d.length>500;){let y=d.shift();y&&o.delete(y)}},p=new Set,v=f=>{o.has(f.id)||p.has(f.id)||(p.add(f.id),r.push(f))},E=ht(a,l);for(let f of E)v(f);let S=0,R=0,k=f=>{if(f.length===0)return;let y=JSON.stringify(f),I=f.map(i=>i.id),D;try{D=fetch(c,{method:"POST",keepalive:!0,body:y,headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})}catch(i){he(f,a,l);for(let u of I)p.delete(u);R++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(R,6));return}let M=i=>{if(i.ok||i.status>=400&&i.status<500&&i.status!==429){g(I),R=0,S=0;return}he(f,a,l);for(let u of I)p.delete(u);R++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(R,6))};D instanceof Promise?D.then(M).catch(()=>{he(f,a,l);for(let i of I)p.delete(i);R++,S=Date.now()+Math.min(6e4,1e3*2**Math.min(R,6))}):M(D)},b=typeof TextEncoder!="undefined"?new TextEncoder:null,de=f=>b?b.encode(f).length:f.length,K=f=>{let y=[],I=2;for(let D of f){let M=de(JSON.stringify(D))+1;if(y.length>0&&I+M>57344||y.length>=n)break;y.push(D),I+=M}return y},L=()=>{try{if(Date.now()<S)return;for(;r.length>0;){let f=r.filter(I=>!o.has(I.id));if(r.length=0,f.length===0)break;let y=K(f);if(y.length===0)break;y.length<f.length&&r.push(...f.slice(y.length)),k(y)}}catch(f){}},A=!0,G=null;G=setInterval(()=>{A&&L()},t);let V=()=>{document.visibilityState==="hidden"&&L()},q=()=>{L()};return document.addEventListener("visibilitychange",V),window.addEventListener("pagehide",q),{push(f){v(f),r.length>=n&&L()},flush:L,destroy(){A=!1,G!==null&&(clearInterval(G),G=null),document.removeEventListener("visibilitychange",V),window.removeEventListener("pagehide",q),L()}}}var we="_snt_asgn_";function ge(e,t){return`${e}:${t}`}function vt(e,t){return`${we}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ne(e){let t=e.slice(we.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(a){return null}}function be(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(we)&&e.push(n)}return e}catch(e){return[]}}function Ue(e=18e5){let t=new Map,n=c=>c.assignedAt+e<Date.now();return typeof window!="undefined"&&(()=>{for(let c of be())try{let s=localStorage.getItem(c);if(!s)continue;let l=JSON.parse(s);if(n(l)){localStorage.removeItem(c);continue}let r=Ne(c);if(!r)continue;t.set(ge(r.componentId,r.segment),l)}catch(s){}})(),{get(c,s){let l=t.get(ge(c,s));return l?n(l)?(t.delete(ge(c,s)),null):l:null},set(c,s,l){let r=ge(c,s);t.set(r,l);try{localStorage.setItem(vt(c,s),JSON.stringify(l))}catch(o){}},invalidate(c){let s=`${c}:`;for(let l of[...t.keys()])l.startsWith(s)&&t.delete(l);for(let l of be()){let r=Ne(l);if((r==null?void 0:r.componentId)===c)try{localStorage.removeItem(l)}catch(o){}}},clear(){t.clear();for(let c of be())try{localStorage.removeItem(c)}catch(s){}}}}var Ee=["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 xe(e)!==null}function xe(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=Ee.find(a=>t.includes(a.toLowerCase())))!=null?n:null}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(c){}let a=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(a)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(a)?"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 Ke(e){let t=bt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function bt(e,t){var s,l,r,o,d,g,p;let n=(l=(s=t==null?void 0:t.userAgent)==null?void 0:s.trim())!=null?l:"",a=(o=(r=t==null?void 0:t.referer)==null?void 0:r.trim())!=null?o:"",c=(d=t==null?void 0:t.now)!=null?d:new Date;return{sessionId:e,ephemeral:!1,utmParams:(g=t==null?void 0:t.utmParams)!=null?g:{},deviceClass:n?se(n):"desktop",trafficSource:a?ie(a,t==null?void 0:t.appOrigin):"direct",referrerDomain:ae(a),timeOfDay:le(c),dayOfWeek:(p=["sun","mon","tue","wed","thu","fri","sat"][c.getDay()])!=null?p:"sun",automation:(t==null?void 0:t.webdriver)===!0||re(n)}}var Q=require("@sentientui/policy");function ce(e){return h(h(h({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 Y(e){let t=ce(e);return(0,Q.slotResultFor)(t,(0,Q.slotBaselineArm)(t))}function Ge(e){let t={};for(let n of e)t[n.id]=Y(n);return t}function fe(e){return typeof e=="string"?e:(0,Q.canonicalArm)(e)}var W="_snt_snap:",wt=["low","medium","high"];function pe(e){try{let t=localStorage.getItem(W+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"||!wt.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(W+e,JSON.stringify(t))}catch(n){}}function Be(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(W+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 _e=require("@sentientui/policy");var ye=require("@sentientui/policy");var Se="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",Ie="[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.",$e=!1,me=!1;function Et(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function We(e){var r;let t=ue({ssrSessionId:e.ssrSessionId}),n=(r=t.getSessionId())!=null?r:"local",a=Et(),c=import("@sentientui/core/local").then(o=>{let d=o;return d.LOCAL_ENGINE_AVAILABLE?($e||($e=!0,console.info(Ie)),d):(me||(me=!0,console.error(Se)),null)}).catch(()=>(me||(me=!0,console.error(Se)),null)),s=null;function l(o){let d=document.documentElement;d.dataset.sentientPersona===void 0&&(d.dataset.sentientPersona=o.persona,d.dataset.sentientConfidence=(0,ye.confidenceBand)(o.confidence))}return{isLocal:!0,async decide(o){var p,v,E;let d=await c;if(!d)return null;let g=d.createLocalEngine({sessionId:n,forcedPersona:a}).decide(o);return s=F(h({},g),{layoutOrder:(v=(p=g.layoutOrder)!=null?p:s==null?void 0:s.layoutOrder)!=null?v:null,slots:h(h({},(E=s==null?void 0:s.slots)!=null?E:{}),g.slots)}),H(e.apiKey||"local",{v:1,persona:s.persona,band:(0,ye.confidenceBand)(s.confidence),slots:s.slots,layoutOrder:s.layoutOrder,savedAt:Date.now()}),l(g),g},getSlotResult(o){var d,g,p;return(p=(g=s==null?void 0:s.slots[o])!=null?g:(d=e.initialSlots)==null?void 0:d[o])!=null?p:null},getPersona(){return s?{persona:s.persona,confidence:s.confidence,band:(0,ye.confidenceBand)(s.confidence)}:null},async assign(o,d){var v;let g=await c;return!g||!d||d.length===0?d!=null&&d[0]?{variantId:d[0],assignmentTtlMs:0}:null:{variantId:(v=g.createLocalEngine({sessionId:n,forcedPersona:a}).decide({components:[{id:o,variantIds:d}]}).assignments[o])!=null?v:d[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}function je(e,t,n,a){let c=[];{let r=!1,o=[],d=()=>{if(r)return;let g=Date.now();for(o.push(g);o.length>0&&g-o[0]>500;)o.shift();o.length>=3&&(r=!0,e("rage_click"))};t.addEventListener("click",d),c.push(()=>t.removeEventListener("click",d))}{let s=!1,l=r=>{if(s||!(r.target instanceof Node)||!t.contains(r.target)&&t!==r.target)return;s=!0;let o=typeof window!="undefined"?window.getSelection():null,d=o?o.toString().length:0;e("text_copy",{selectionLength:d})};document.addEventListener("copy",l),c.push(()=>document.removeEventListener("copy",l))}{let s=!1,l=!1,r=null,o=()=>{r!==null&&(clearTimeout(r),r=null)},d=()=>{s||!l||(o(),r=setTimeout(()=>{!s&&l&&(s=!0,e("scroll_hesitation"))},3e3))},g=()=>{o(),d()},p=E=>{for(let S of E)l=S.intersectionRatio>.3,l?d():o()},v=new IntersectionObserver(p,{threshold:[.3]});v.observe(t),window.addEventListener("scroll",g,{passive:!0}),c.push(()=>{v.disconnect(),window.removeEventListener("scroll",g),o()})}if((a==null?void 0:a.tabLoss)!==!1){let s=!1,l=n!=null?n:Date.now(),r=()=>{if(s||document.visibilityState!=="hidden")return;let o=Date.now()-l;o<15e3&&(s=!0,e("tab_loss",{timeOnPage:o}))};document.addEventListener("visibilitychange",r),c.push(()=>document.removeEventListener("visibilitychange",r))}return()=>{for(let s of c)s()}}var Fe="https://api.sentient-ui.com/v1/events",j=new Map,Je=null;function Ce(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}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)})}var z={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 xt(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,a]of t)n.startsWith("utm_")&&(e[n]=a);return e}catch(e){return{}}}function Qe(e){return e.replace(/\/events\/?$/,"")}function Re(){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 It(e){if(typeof window=="undefined")return;let t=e!=null?e:Je;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=j.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:a,upgrade:c}=n;if(!c||a.respectDoNotTrack!==!1&&Re())return;let s=Ye(F(h({},a),{consent:!0}));c(s),j.set(t,{config:F(h({},a),{consent:!0}),upgrade:null})}function Ct(e){var l;let t=Qe((l=e.ingestUrl)!=null?l:Fe),n={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(r,o,d){try{let g=new URLSearchParams({componentId:r});for(let E of o!=null?o:[])g.append("variantIds[]",E);let p=await fetch(`${t}/winner?${g.toString()}`,{headers:n});return p.ok?{variantId:(await p.json()).variantId,assignmentTtlMs:0}:o!=null&&o[0]?{variantId:o[0],assignmentTtlMs:0}:null}catch(g){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:()=>{}},c={track:r=>a.track(r),goal:(r,o,d,g)=>a.goal(r,o,d,g),componentGoal:(r,o,d)=>a.componentGoal(r,o,d),identify:r=>a.identify(r),getAssignment:(r,o)=>a.getAssignment(r,o),assign:(r,o,d,g)=>a.assign(r,o,d,g),decide:r=>a.decide(r),getSlotResult:r=>a.getSlotResult(r),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function s(r){a=r}return{proxy:c,setInner:s}}function Ye(e){var q,X,Z,ee,f,y,I,D,M;if(typeof window=="undefined")return z;Je=e.apiKey;let t=e.respectDoNotTrack!==!1&&Re(),n=e.consent===!1||t,a=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!a&&e.localMode!==!1)return n?(j.set(e.apiKey||"local",{config:e,upgrade:null}),z):(j.set(e.apiKey||"local",{config:e,upgrade:null}),We(e));if(n){if(e.preConsentBehavior==="statistical_winner"){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."),z;let{proxy:i,setInner:u}=Ct(e);return j.set(e.apiKey,{config:e,upgrade:t?null:u}),i}return j.set(e.apiKey,{config:e,upgrade:null}),z}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."),z;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),z;let c=(q=e.ingestUrl)!=null?q:Fe,s=Date.now(),l=ue({ssrSessionId:e.ssrSessionId}),r=Ue(),o=Me({ingestUrl:c,apiKey:e.apiKey}),d=Qe(c),g={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},p=se((X=navigator.userAgent)!=null?X:""),v=typeof window!="undefined"?window.location.origin:void 0,E=ie((Z=document.referrer)!=null?Z:"",v),S=(ee=e.sessionSegment)!=null?ee:`${p}:${E}`,R=new Map,k=new Map,b=null,de=i=>{for(let u of i)k.has(u.id)||k.set(u.id,Y(u))};if(e.initialSlots)for(let[i,u]of Object.entries(e.initialSlots))k.set(i,u);let K=pe(e.apiKey);if(K)for(let[i,u]of Object.entries(K.slots))k.has(i)||k.set(i,u);let L={low:.15,medium:.5,high:.85};if(e.initialPersona)b=h({},e.initialPersona);else{let i=document.documentElement.dataset;i.sentientPersona?b={persona:i.sentientPersona,confidence:(y=L[(f=i.sentientConfidence)!=null?f:"low"])!=null?y:.15}:K&&(b={persona:K.persona,confidence:(I=L[K.band])!=null?I:.15})}if(e.initialAssignments)for(let[i,u]of Object.entries(e.initialAssignments))r.set(i,S,{variantId:u,assignedAt:Date.now(),segment:S,confidence:1});let A=Promise.resolve(),G=l.getSessionId();if(G){let i=ae((D=document.referrer)!=null?D:""),u=h(h({sessionId:G,deviceClass:p,trafficSource:E,referrerDomain:i,utmParams:xt(),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((M=navigator.userAgent)!=null?M:"")},e.userId?{userId:e.userId}:{}),e.country?{country:e.country}:{});try{A=fetch(`${d}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(u),headers:g}).then(m=>{m.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(m){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let V={goal(i,u={},m=1,O=0){let x=l.getSessionId();if(!x)return;let C=Ce();A.then(()=>{fetch(`${d}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:x,name:i,metadata:u,weight:m,stepIndex:O,goalId:C}),headers:g}).catch(()=>{})})},componentGoal(i,u,m){var T,U,P;let O=l.getSessionId();if(!O)return;let x=r.get(i,S),C=x?null:(T=k.get(i))!=null?T:null;if(!x&&C===null){e.debug&&console.warn(`[sentient] componentGoal("${i}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let B=x?x.variantId:fe(C),N={id:Ce(),sessionId:O,projectId:e.apiKey,componentId:i,variantId:B,eventType:"goal_achieved",goalType:u,payload:h({reward:(U=m==null?void 0:m.reward)!=null?U:1},(P=m==null?void 0:m.metadata)!=null?P:{}),timestamp:Date.now(),timeInSession:Date.now()-s};e.debug&&console.log("[sentient] componentGoal",N),A.then(()=>o.push(N))},identify(i){let u=l.getSessionId();u&&A.then(()=>{fetch(`${d}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:u,userId:i,ephemeral:l.isEphemeral()}),headers:g}).catch(()=>{})})},track(i){let u=l.getSessionId();if(!u)return;let m=F(h({},i),{id:Ce(),sessionId:u,timestamp:Date.now(),timeInSession:Date.now()-s});e.debug&&console.log("[sentient] track",m),A.then(()=>o.push(m))},getAssignment(i,u){return r.get(i,u)},async assign(i,u,m,O){let x=l.getSessionId();if(!x)return null;let C=r.get(i,S);if(C&&(u!=null&&u.length||C.content!==void 0))return{variantId:C.variantId,assignmentTtlMs:0,content:C.content};let B=R.get(i);if(B)return B;let N=(async()=>{await A;try{let T={sessionId:x,componentId:i,variantIds:u};O!==void 0?T.agentDataByVariant=O:m!==void 0&&(T.agentData=m);let U=await fetch(`${d}/assign`,{method:"POST",body:JSON.stringify(T),headers:g});if(!U.ok)return null;let P=await U.json();return r.set(i,S,{variantId:P.variantId,assignedAt:Date.now(),segment:S,confidence:1,content:P.content}),P}catch(T){return null}finally{R.delete(i)}})();return R.set(i,N),N},async decide(i){var O,x,C,B,N,T,U,P,ke,Ae;let u=l.getSessionId();if(!u)return null;let m=(O=i.slots)!=null?O:[];await A;try{let $={sessionId:u};i.sections&&i.sections.length>0&&($.sections=i.sections.map(_=>({id:_}))),$.components=(x=i.components)!=null?x:[],m.length>0&&($.slots=m.map(ce)),i.slotsFrom==="registry"&&($.slotsFrom="registry"),i.v&&($.v=i.v);let De=await fetch(`${d}/decide`,{method:"POST",body:JSON.stringify($),headers:g});if(!De.ok)return de(m),null;let w=await De.json(),te={};for(let _ of m)te[_.id]=(B=(C=w.slots)==null?void 0:C[_.id])!=null?B:Y(_);if(w.slots)for(let[_,ne]of Object.entries(w.slots))_ in te||(te[_]=ne);for(let[_,ne]of Object.entries(te))k.set(_,ne);b={persona:(N=w.persona)!=null?N:"unknown",confidence:(T=w.confidence)!=null?T:0};for(let[_,ne]of Object.entries((U=w.assignments)!=null?U:{}))r.set(_,S,{variantId:ne,assignedAt:Date.now(),segment:S,confidence:1});return H(e.apiKey,h({v:1,persona:b.persona,band:(0,_e.confidenceBand)(b.confidence),slots:Object.fromEntries(k),layoutOrder:(P=w.layoutOrder)!=null?P:null,savedAt:Date.now()},w.slotConfig?{slotConfig:w.slotConfig}:{})),h(h({layoutOrder:(ke=w.layoutOrder)!=null?ke:null,assignments:(Ae=w.assignments)!=null?Ae:{},slots:te,persona:b.persona,confidence:b.confidence},w.slotConfig?{slotConfig:w.slotConfig}:{}),w.goals?{goals:w.goals}:{})}catch($){return de(m),null}},getSlotResult(i){var u;return(u=k.get(i))!=null?u:null},getPersona(){return b?{persona:b.persona,confidence:b.confidence,band:(0,_e.confidenceBand)(b.confidence)}:null},async fetchWeights(){var i;try{let u=await fetch(`${d}/weights`,{headers:g});return u.ok?(i=(await u.json()).components)!=null?i:[]:[]}catch(u){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){o.destroy(),e.debug&&console.log("[sentient] disposed")},destroy(){o.destroy(),l.destroy();try{localStorage.removeItem(W+e.apiKey),localStorage.removeItem(ve(e.apiKey))}catch(i){}e.debug&&console.log("[sentient] destroyed")}};if(j.set(e.apiKey,{config:e,upgrade:null}),e.debug){let i=window;i.__sentient&&(i.__sentient.client=V)}return V}0&&(module.exports={LOCAL_MODE_BANNER,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,toWireSlot,uaTokenMatch,writeSnapshot});
|
|
1
|
+
"use strict";var ze=Object.create;var se=Object.defineProperty,Ve=Object.defineProperties,qe=Object.getOwnPropertyDescriptor,Xe=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,et=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var Te=(e,t,n)=>t in e?se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S=(e,t)=>{for(var n in t||(t={}))Le.call(t,n)&&Te(e,n,t[n]);if(Oe)for(var n of Oe(t))tt.call(t,n)&&Te(e,n,t[n]);return e},Q=(e,t)=>Ve(e,Xe(t));var nt=(e,t)=>{for(var n in t)se(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Ze(t))!Le.call(e,l)&&l!==n&&se(e,l,{get:()=>t[l],enumerable:!(a=qe(t,l))||a.enumerable});return e};var ot=(e,t,n)=>(n=e!=null?ze(et(e)):{},Pe(t||!e||!e.__esModule?se(n,"default",{value:e,enumerable:!0}):n,e)),st=e=>Pe(se({},"__esModule",{value:!0}),e);var kt={};nt(kt,{LOCAL_MODE_BANNER:()=>Ce,PROD_KEYLESS_ERROR:()=>he,SNAPSHOT_STORAGE_KEY_PREFIX:()=>J,agentUaList:()=>xe,armOfResult:()=>fe,attachMicroSignalDetectors:()=>je,baselineResultFor:()=>z,baselineSlots:()=>Ge,deriveSessionSegment:()=>Ke,detectDeviceClass:()=>ie,detectTimeOfDay:()=>ce,detectTrafficSource:()=>ae,grantConsent:()=>Ct,init:()=>Ye,isDoNotTrackEnabled:()=>_e,matchedAgentToken:()=>Ie,readSnapshot:()=>me,referrerDomainFromReferer:()=>le,renderPrePaintScript:()=>Be,toWireSlot:()=>de,uaTokenMatch:()=>re,writeSnapshot:()=>V});module.exports=st(kt);var rt="_snt_uid";var Y="_snt_uid";function it(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch(t){}let e=()=>Math.floor(Math.random()*4294967295).toString(16).padStart(8,"0");return`${e()}-${e()}-${e()}-${e()}`}function at(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function lt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(a){}}function ct(e){try{return localStorage.getItem(e)}catch(t){return null}}function dt(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function ut(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function gt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function pt(e){try{sessionStorage.removeItem(e)}catch(t){}}function ft(e){try{return document.cookie=`${e}_probe=1; max-age=1; SameSite=strict; path=/`,/(?:^|; )_snt_uid_probe=1/.test(document.cookie)||document.cookie.indexOf(`${e}_probe=1`)!==-1}catch(t){return!1}}function mt(e){try{localStorage.removeItem(e)}catch(t){}}function yt(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var St={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function ge(e){var c,g,f,w,E,P;if(typeof window=="undefined")return St;let t=(c=e==null?void 0:e.cookieName)!=null?c:rt,a=((g=e==null?void 0:e.cookieTTLDays)!=null?g:365)*24*60*60,l=(P=(E=(w=(f=at(t))!=null?f:ct(Y))!=null?w:ut(Y))!=null?E:e==null?void 0:e.ssrSessionId)!=null?P:it();lt(t,l,a);let i=dt(Y,l),d=ft(t),o=i?!1:gt(Y,l),s=!i&&!d&&!o;return{getSessionId:()=>l,isEphemeral:()=>s,destroy:()=>{l=null,yt(t),mt(Y),pt(Y)}}}function we(e){return`_snt_retry_${e.slice(0,12)}`}var ht={push:()=>{},flush:()=>{},destroy:()=>{}};function vt(e,t){try{let n=localStorage.getItem(t);if(!n)return[];let a=JSON.parse(n);return Array.isArray(a)?(localStorage.removeItem(t),a.slice(-e)):[]}catch(n){return[]}}function ve(e,t,n){try{let l=[...(()=>{try{let i=localStorage.getItem(n);if(!i)return[];let d=JSON.parse(i);return Array.isArray(d)?d:[]}catch(i){return[]}})(),...e].slice(-t);localStorage.setItem(n,JSON.stringify(l))}catch(a){}}function Me(e){var Z,ee,te;if(typeof window=="undefined")return ht;let t=(Z=e.flushIntervalMs)!=null?Z:5e3,n=(ee=e.maxBatchSize)!=null?ee:20,a=(te=e.maxRetrySize)!=null?te:100,l=e.ingestUrl,i=e.apiKey,d=we(i),o=[],s=new Set,c=[],g=p=>{for(let m of p)f.delete(m),!s.has(m)&&(s.add(m),c.push(m));for(;c.length>500;){let m=c.shift();m&&s.delete(m)}},f=new Set,w=p=>{s.has(p.id)||f.has(p.id)||(f.add(p.id),o.push(p))},E=p=>{for(let m of p)s.has(m.id)||(f.add(m.id),o.push(m))},P=vt(a,d);for(let p of P)w(p);let x=0,A=0,D=p=>{if(p.length===0)return;let m=JSON.stringify(p),U=p.map(r=>r.id),T;try{T=fetch(l,{method:"POST",keepalive:!0,body:m,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(r){ve(p,a,d),E(p),A++,x=Date.now()+Math.min(6e4,1e3*2**Math.min(A,6));return}let K=r=>{if(r.ok||r.status>=400&&r.status<500&&r.status!==429){g(U),A=0,x=0;return}ve(p,a,d),E(p),A++,x=Date.now()+Math.min(6e4,1e3*2**Math.min(A,6))};T instanceof Promise?T.then(K).catch(()=>{ve(p,a,d),E(p),A++,x=Date.now()+Math.min(6e4,1e3*2**Math.min(A,6))}):K(T)},h=typeof TextEncoder!="undefined"?new TextEncoder:null,ue=p=>h?h.encode(p).length:p.length,$=p=>{let m=[],U=2;for(let T of p){let K=ue(JSON.stringify(T))+1;if(m.length>0&&U+K>57344||m.length>=n)break;m.push(T),U+=K}return m},M=()=>{try{if(Date.now()<x)return;for(;o.length>0&&!(Date.now()<x);){let p=o.filter(U=>!s.has(U.id));if(o.length=0,p.length===0)break;let m=$(p);if(m.length===0)break;m.length<p.length&&o.push(...p.slice(m.length)),D(m)}}catch(p){}},O=!0,W=null;W=setInterval(()=>{O&&M()},t);let N=()=>{document.visibilityState==="hidden"&&M()},X=()=>{M()};return document.addEventListener("visibilitychange",N),window.addEventListener("pagehide",X),{push(p){w(p),o.length>=n&&M()},flush:M,destroy(){O=!1,W!==null&&(clearInterval(W),W=null),document.removeEventListener("visibilitychange",N),window.removeEventListener("pagehide",X),M()}}}var Ee="_snt_asgn_";function pe(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function wt(e,t){return`${Ee}${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ue(e){let t=e.slice(Ee.length),n=t.indexOf(":");if(n<0)return null;try{return{componentId:decodeURIComponent(t.slice(0,n)),segment:decodeURIComponent(t.slice(n+1))}}catch(a){return null}}function be(){try{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n!=null&&n.startsWith(Ee)&&e.push(n)}return e}catch(e){return[]}}function Ne(e=18e5){let t=new Map,n=l=>l.assignedAt+(l.ttlMs&&l.ttlMs>0?l.ttlMs:e)<Date.now();return typeof window!="undefined"&&(()=>{for(let l of be())try{let i=localStorage.getItem(l);if(!i)continue;let d=JSON.parse(i);if(n(d)){localStorage.removeItem(l);continue}let o=Ue(l);if(!o)continue;t.set(pe(o.componentId,o.segment),d)}catch(i){}})(),{get(l,i){let d=t.get(pe(l,i));return d?n(d)?(t.delete(pe(l,i)),null):d:null},set(l,i,d){let o=pe(l,i);t.set(o,d);try{localStorage.setItem(wt(l,i),JSON.stringify(d))}catch(s){}},invalidate(l){let i=`${encodeURIComponent(l)}:`;for(let d of[...t.keys()])d.startsWith(i)&&t.delete(d);for(let d of be()){let o=Ue(d);if((o==null?void 0:o.componentId)===l)try{localStorage.removeItem(d)}catch(s){}}},clear(){t.clear();for(let l of be())try{localStorage.removeItem(l)}catch(i){}}}}var xe=["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=xe.find(a=>t.includes(a.toLowerCase())))!=null?n:null}function ie(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 ae(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(l){}let a=n.hostname.toLowerCase();return/(^|\.)(google|bing|duckduckgo|yahoo)\./.test(a)?"search":/(^|\.)(twitter\.com|x\.com|facebook\.com|linkedin\.com|reddit\.com|t\.co)$/.test(a)?"social":"referral"}catch(n){return"direct"}}function le(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}function ce(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function Ke(e){let t=bt("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function bt(e,t){var i,d,o,s,c,g,f;let n=(d=(i=t==null?void 0:t.userAgent)==null?void 0:i.trim())!=null?d:"",a=(s=(o=t==null?void 0:t.referer)==null?void 0:o.trim())!=null?s:"",l=(c=t==null?void 0:t.now)!=null?c:new Date;return{sessionId:e,ephemeral:!1,utmParams:(g=t==null?void 0:t.utmParams)!=null?g:{},deviceClass:n?ie(n):"desktop",trafficSource:a?ae(a,t==null?void 0:t.appOrigin):"direct",referrerDomain:le(a),timeOfDay:ce(l),dayOfWeek:(f=["sun","mon","tue","wed","thu","fri","sat"][l.getDay()])!=null?f:"sun",automation:(t==null?void 0:t.webdriver)===!0||re(n)}}var H=require("@sentientui/policy");function de(e){return S(S(S({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=de(e);return(0,H.slotResultFor)(t,(0,H.slotBaselineArm)(t))}function Ge(e){let t={};for(let n of e)t[n.id]=z(n);return t}function fe(e){return typeof e=="string"?e:(0,H.canonicalArm)(e)}var J="_snt_snap:",Et=["low","medium","high"];function me(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"||!Et.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 V(e,t){try{localStorage.setItem(J+e,JSON.stringify(t))}catch(n){}}function Be(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 ke=require("@sentientui/policy");var Se=require("@sentientui/policy");var he="[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.",$e=!1,ye=!1;function xt(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function We(e){var o;let t=ge({ssrSessionId:e.ssrSessionId}),n=(o=t.getSessionId())!=null?o:"local",a=xt(),l=import("@sentientui/core/local").then(s=>{let c=s;return c.LOCAL_ENGINE_AVAILABLE?($e||($e=!0,console.info(Ce)),c):(ye||(ye=!0,console.error(he)),null)}).catch(()=>(ye||(ye=!0,console.error(he)),null)),i=null;function d(s){let c=document.documentElement;c.dataset.sentientPersona===void 0&&(c.dataset.sentientPersona=s.persona,c.dataset.sentientConfidence=(0,Se.confidenceBand)(s.confidence))}return{isLocal:!0,async decide(s){var f,w,E;let c=await l;if(!c)return null;let g=c.createLocalEngine({sessionId:n,forcedPersona:a}).decide(s);return i=Q(S({},g),{layoutOrder:(w=(f=g.layoutOrder)!=null?f:i==null?void 0:i.layoutOrder)!=null?w:null,slots:S(S({},(E=i==null?void 0:i.slots)!=null?E:{}),g.slots)}),V(e.apiKey||"local",{v:1,persona:i.persona,band:(0,Se.confidenceBand)(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),d(g),g},getSlotResult(s){var c,g,f;return(f=(g=i==null?void 0:i.slots[s])!=null?g:(c=e.initialSlots)==null?void 0:c[s])!=null?f:null},getPersona(){return i?{persona:i.persona,confidence:i.confidence,band:(0,Se.confidenceBand)(i.confidence)}:null},async assign(s,c){var w;let g=await l;return!g||!c||c.length===0?c!=null&&c[0]?{variantId:c[0],assignmentTtlMs:0}:null:{variantId:(w=g.createLocalEngine({sessionId:n,forcedPersona:a}).decide({components:[{id:s,variantIds:c}]}).assignments[s])!=null?w:c[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}function je(e,t,n,a){let l=[];{let o=!1,s=[],c=()=>{if(o)return;let g=Date.now();for(s.push(g);s.length>0&&g-s[0]>500;)s.shift();s.length>=3&&(o=!0,e("rage_click"))};t.addEventListener("click",c),l.push(()=>t.removeEventListener("click",c))}{let i=!1,d=o=>{if(i||!(o.target instanceof Node)||!t.contains(o.target)&&t!==o.target)return;i=!0;let s=typeof window!="undefined"?window.getSelection():null,c=s?s.toString().length:0;e("text_copy",{selectionLength:c})};document.addEventListener("copy",d),l.push(()=>document.removeEventListener("copy",d))}{let i=!1,d=!1,o=null,s=()=>{o!==null&&(clearTimeout(o),o=null)},c=()=>{i||!d||(s(),o=setTimeout(()=>{!i&&d&&(i=!0,e("scroll_hesitation"))},3e3))},g=()=>{s(),c()},f=E=>{for(let P of E)d=P.intersectionRatio>.3,d?c():s()},w=new IntersectionObserver(f,{threshold:[.3]});w.observe(t),window.addEventListener("scroll",g,{passive:!0}),l.push(()=>{w.disconnect(),window.removeEventListener("scroll",g),s()})}if((a==null?void 0:a.tabLoss)!==!1){let i=!1,d=n!=null?n:Date.now(),o=()=>{if(i||document.visibilityState!=="hidden")return;let s=Date.now()-d;s<15e3&&(i=!0,e("tab_loss",{timeOnPage:s}))};document.addEventListener("visibilitychange",o),l.push(()=>document.removeEventListener("visibilitychange",o))}return()=>{for(let i of l)i()}}var Fe="https://api.sentient-ui.com/v1/events",C=new Map,Je=null;function Re(){try{if(typeof crypto!="undefined"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}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)})}var q={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 It(){try{let e={},t=new URLSearchParams(window.location.search);for(let[n,a]of t)n.startsWith("utm_")&&(e[n]=a);return e}catch(e){return{}}}function Qe(e){return e.replace(/\/events\/?$/,"")}function _e(){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 Ct(e){var o;if(typeof window=="undefined")return;let t=e!=null?e:Je;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=C.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:a,upgrade:l}=n;if(!l||a.respectDoNotTrack!==!1&&_e())return;let i=Ye(Q(S({},a),{consent:!0}));l(i);let d=(o=C.get(t))==null?void 0:o.dispose;C.set(t,{config:Q(S({},a),{consent:!0}),upgrade:null,dispose:d})}function Rt(e){var d;let t=Qe((d=e.ingestUrl)!=null?d:Fe),n={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),async assign(o,s,c){try{let g=new URLSearchParams({componentId:o});for(let E of s!=null?s:[])g.append("variantIds[]",E);let f=await fetch(`${t}/winner?${g.toString()}`,{headers:n});return f.ok?{variantId:(await f.json()).variantId,assignmentTtlMs:0}:s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}catch(g){return s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null}},decide:()=>Promise.resolve(null),getSlotResult:()=>null,getPersona:()=>null,getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>{}},l={track:o=>a.track(o),goal:(o,s,c,g)=>a.goal(o,s,c,g),componentGoal:(o,s,c)=>a.componentGoal(o,s,c),identify:o=>a.identify(o),getAssignment:(o,s)=>a.getAssignment(o,s),assign:(o,s,c,g)=>a.assign(o,s,c,g),decide:o=>a.decide(o),getSlotResult:o=>a.getSlotResult(o),getPersona:()=>a.getPersona(),fetchWeights:()=>a.fetchWeights(),getGraph:()=>a.getGraph(),dispose:()=>a.dispose(),destroy:()=>a.destroy()};function i(o){a=o}return{proxy:l,setInner:i}}function Ye(e){var X,Z,ee,te,p,m,U,T,K;if(typeof window=="undefined")return q;Je=e.apiKey;let t=C.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(r){}let n=e.respectDoNotTrack!==!1&&_e(),a=e.consent===!1||n,l=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!l&&e.localMode!==!1)return a?(C.set(e.apiKey||"local",{config:e,upgrade:null}),q):(C.set(e.apiKey||"local",{config:e,upgrade:null}),We(e));if(a){if(e.preConsentBehavior==="statistical_winner"){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."),q;let{proxy:r,setInner:u}=Rt(e);return C.set(e.apiKey,{config:e,upgrade:n?null:u}),r}return C.set(e.apiKey,{config:e,upgrade:null}),q}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."),q;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),q;let i=(X=e.ingestUrl)!=null?X:Fe,d=Date.now(),o=ge({ssrSessionId:e.ssrSessionId}),s=Ne(),c=Me({ingestUrl:i,apiKey:e.apiKey}),g=Qe(i),f={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},w=ie((Z=navigator.userAgent)!=null?Z:""),E=typeof window!="undefined"?window.location.origin:void 0,P=ae((ee=document.referrer)!=null?ee:"",E),x=(te=e.sessionSegment)!=null?te:`${w}:${P}`,A=new Map,D=new Map,h=null,ue=r=>{for(let u of r)D.has(u.id)||D.set(u.id,z(u))};if(e.initialSlots)for(let[r,u]of Object.entries(e.initialSlots))D.set(r,u);let $=me(e.apiKey);if($)for(let[r,u]of Object.entries($.slots))D.has(r)||D.set(r,u);let M={low:.15,medium:.5,high:.85};if(e.initialPersona)h=S({},e.initialPersona);else{let r=document.documentElement.dataset;r.sentientPersona?h={persona:r.sentientPersona,confidence:(m=M[(p=r.sentientConfidence)!=null?p:"low"])!=null?m:.15}:$&&(h={persona:$.persona,confidence:(U=M[$.band])!=null?U:.15})}if(e.initialAssignments)for(let[r,u]of Object.entries(e.initialAssignments))s.set(r,x,{variantId:u,assignedAt:Date.now(),segment:x,confidence:1});let O=Promise.resolve(),W=o.getSessionId();if(W){let r=le((T=document.referrer)!=null?T:""),u=S(S({sessionId:W,deviceClass:w,trafficSource:P,referrerDomain:r,utmParams:It(),timeOfDay:ce(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:o.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{O=fetch(`${g}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(u),headers:f}).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:c});let N={goal(r,u={},y=1,L=0){let I=o.getSessionId();if(!I)return;let b=Re();O.then(()=>{fetch(`${g}/goals`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:I,name:r,metadata:u,weight:y,stepIndex:L,goalId:b}),headers:f}).catch(()=>{})})},componentGoal(r,u,y){var R,B,k;let L=o.getSessionId();if(!L)return;let I=s.get(r,x),b=I?null:(R=D.get(r))!=null?R:null;if(!I&&b===null){e.debug&&console.warn(`[sentient] componentGoal("${r}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let j=I?I.variantId:fe(b),G={id:Re(),sessionId:L,projectId:e.apiKey,componentId:r,variantId:j,eventType:"goal_achieved",goalType:u,payload:S({reward:(B=y==null?void 0:y.reward)!=null?B:1},(k=y==null?void 0:y.metadata)!=null?k:{}),timestamp:Date.now(),timeInSession:Date.now()-d};e.debug&&console.log("[sentient] componentGoal",G),O.then(()=>c.push(G))},identify(r){let u=o.getSessionId();u&&O.then(()=>{fetch(`${g}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:u,userId:r,ephemeral:o.isEphemeral()}),headers:f}).catch(()=>{})})},track(r){let u=o.getSessionId();if(!u)return;let y=Q(S({},r),{id:Re(),sessionId:u,timestamp:Date.now(),timeInSession:Date.now()-d});e.debug&&console.log("[sentient] track",y),O.then(()=>c.push(y))},getAssignment(r,u){return s.get(r,u)},async assign(r,u,y,L){let I=o.getSessionId();if(!I)return null;let b=s.get(r,x);if(b&&(u!=null&&u.length||b.content!==void 0)){let R=b.ttlMs&&b.ttlMs>0?Math.max(0,b.assignedAt+b.ttlMs-Date.now()):0;return{variantId:b.variantId,assignmentTtlMs:R,content:b.content}}let j=A.get(r);if(j)return j;let G=(async()=>{await O;try{let R={sessionId:I,componentId:r,variantIds:u};L!==void 0?R.agentDataByVariant=L:y!==void 0&&(R.agentData=y);let B=await fetch(`${g}/assign`,{method:"POST",body:JSON.stringify(R),headers:f});if(!B.ok)return null;let k=await B.json();return s.set(r,x,S({variantId:k.variantId,assignedAt:Date.now(),segment:x,confidence:1,content:k.content},k.assignmentTtlMs&&k.assignmentTtlMs>0?{ttlMs:k.assignmentTtlMs}:{})),k}catch(R){return null}finally{A.delete(r)}})();return A.set(r,G),G},async decide(r){var L,I,b,j,G,R,B,k,Ae;let u=o.getSessionId();if(!u)return null;let y=(L=r.slots)!=null?L:[];await O;try{let F={sessionId:u};r.sections&&r.sections.length>0&&(F.sections=r.sections.map(_=>({id:_}))),F.components=(I=r.components)!=null?I:[],y.length>0&&(F.slots=y.map(de)),r.slotsFrom==="registry"&&(F.slotsFrom="registry"),r.v&&(F.v=r.v);let De=await fetch(`${g}/decide`,{method:"POST",body:JSON.stringify(F),headers:f});if(!De.ok)return ue(y),null;let v=await De.json(),ne={};for(let _ of y)ne[_.id]=(j=(b=v.slots)==null?void 0:b[_.id])!=null?j:z(_);if(v.slots)for(let[_,oe]of Object.entries(v.slots))_ in ne||(ne[_]=oe);for(let[_,oe]of Object.entries(ne))D.set(_,oe);let He=h!=null&&h.persona!=="unknown";v.persona&&!(v.persona==="unknown"&&He)?h={persona:v.persona,confidence:(G=v.confidence)!=null?G:0}:h||(h={persona:"unknown",confidence:0});for(let[_,oe]of Object.entries((R=v.assignments)!=null?R:{}))s.set(_,x,{variantId:oe,assignedAt:Date.now(),segment:x,confidence:1});return V(e.apiKey,S({v:1,persona:h.persona,band:(0,ke.confidenceBand)(h.confidence),slots:Object.fromEntries(D),layoutOrder:(B=v.layoutOrder)!=null?B:null,savedAt:Date.now()},v.slotConfig?{slotConfig:v.slotConfig}:{})),S(S(S({layoutOrder:(k=v.layoutOrder)!=null?k:null,assignments:(Ae=v.assignments)!=null?Ae:{},slots:ne,persona:h.persona,confidence:h.confidence},v.slotConfig?{slotConfig:v.slotConfig}:{}),v.goals?{goals:v.goals}:{}),v.sectionMap?{sectionMap:v.sectionMap}:{})}catch(F){return ue(y),null}},getSlotResult(r){var u;return(u=D.get(r))!=null?u:null},getPersona(){return h?{persona:h.persona,confidence:h.confidence,band:(0,ke.confidenceBand)(h.confidence)}:null},async fetchWeights(){var r;try{let u=await fetch(`${g}/weights`,{headers:f});return u.ok?(r=(await u.json()).components)!=null?r:[]:[]}catch(u){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var r;c.destroy(),((r=C.get(e.apiKey))==null?void 0:r.dispose)===N.dispose&&C.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var r;c.destroy(),o.destroy(),((r=C.get(e.apiKey))==null?void 0:r.dispose)===N.dispose&&C.delete(e.apiKey);try{localStorage.removeItem(J+e.apiKey),localStorage.removeItem(we(e.apiKey))}catch(u){}e.debug&&console.log("[sentient] destroyed")}};if(C.set(e.apiKey,{config:e,upgrade:null,dispose:N.dispose}),e.debug){let r=window;r.__sentient&&(r.__sentient.client=N)}return N}0&&(module.exports={LOCAL_MODE_BANNER,PROD_KEYLESS_ERROR,SNAPSHOT_STORAGE_KEY_PREFIX,agentUaList,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,matchedAgentToken,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,toWireSlot,uaTokenMatch,writeSnapshot});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|