@sentientui/core 0.24.0 → 0.26.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.
Files changed (38) hide show
  1. package/dist/{chunk-RL5B6M4G.mjs → chunk-RCN2SIB6.mjs} +2 -2
  2. package/dist/chunk-RCN2SIB6.mjs.map +1 -0
  3. package/dist/chunk-WKXD7KI3.mjs +2 -0
  4. package/dist/chunk-WKXD7KI3.mjs.map +1 -0
  5. package/dist/chunk-Z6ILOYBD.mjs +2 -0
  6. package/dist/chunk-Z6ILOYBD.mjs.map +1 -0
  7. package/dist/{index-Cd0gMdJv.d.cts → index-Ce3IPLrF.d.cts} +16 -0
  8. package/dist/{index-BjVvN7cU.d.ts → index-DubrRV6l.d.ts} +16 -0
  9. package/dist/index-engagement.d.cts +1 -1
  10. package/dist/index-engagement.d.ts +1 -1
  11. package/dist/index-engagement.js +1 -1
  12. package/dist/index-engagement.js.map +1 -1
  13. package/dist/index-engagement.mjs +1 -1
  14. package/dist/index-engagement.mjs.map +1 -1
  15. package/dist/index-graph.d.cts +2 -2
  16. package/dist/index-graph.d.ts +2 -2
  17. package/dist/index-graph.js +1 -1
  18. package/dist/index-graph.js.map +1 -1
  19. package/dist/index-graph.mjs +1 -1
  20. package/dist/index-local.d.cts +1 -1
  21. package/dist/index-local.d.ts +1 -1
  22. package/dist/index-topics.d.cts +16 -1
  23. package/dist/index-topics.d.ts +16 -1
  24. package/dist/index-topics.js +1 -1
  25. package/dist/index-topics.js.map +1 -1
  26. package/dist/index-topics.mjs +1 -1
  27. package/dist/index-topics.mjs.map +1 -1
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.mjs +1 -1
  33. package/package.json +2 -2
  34. package/dist/chunk-EWP6FTHE.mjs +0 -2
  35. package/dist/chunk-EWP6FTHE.mjs.map +0 -1
  36. package/dist/chunk-KIP52DUJ.mjs +0 -2
  37. package/dist/chunk-KIP52DUJ.mjs.map +0 -1
  38. package/dist/chunk-RL5B6M4G.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{a as B}from"./chunk-KIP52DUJ.mjs";import{a as E,d as j,e as V,f as S}from"./chunk-EWP6FTHE.mjs";import{x as K,z as P}from"./chunk-RL5B6M4G.mjs";import"./chunk-2NVSFI4V.mjs";import{a as v}from"./chunk-TMCGHANO.mjs";var z="section, header, footer, nav, main > div, [data-sentient-section]",H=2e4;function Y(l){let o=Array.from(l.querySelectorAll(z)),r=o.filter(a=>o.filter(c=>c!==a&&a.contains(c)).length<2);return r.filter(a=>!r.some(c=>c!==a&&c.contains(a)))}function q(l,o,r,a){try{fetch(`${o}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${l}`},body:JSON.stringify({pageUrl:r,sections:a})}).catch(()=>{})}catch(c){}}var y=()=>{};function J(l,o){var C,O,k,D,_,L,M,N,x;let r=(C=o.doc)!=null?C:typeof document!="undefined"?document:void 0;if(!r||typeof IntersectionObserver=="undefined"||P()||!o.apiKey||!o.apiKey.startsWith("pk_"))return y;let a=((O=o.apiBase)!=null?O:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),c=Y(r);if(c.length===0)return y;let p=new Map,w=[];for(let e of c){let t=e.getAttribute("data-sentient-type"),n=t&&E.includes(t)?t:null,i=(D=n!=null?n:(k=o.typeOf)==null?void 0:k.call(o,e))!=null?D:S(e),m=`nc-${i}`;p.set(e,m);let h=B(e,r);w.push(v({componentId:m,semanticType:i,source:n?"markup":"auto"},h?{locator:h}:{}))}let F=(N=(M=(L=(_=r.defaultView)!=null?_:typeof window!="undefined"?window:void 0)==null?void 0:L.location)==null?void 0:M.pathname)!=null?N:"/";q(o.apiKey,a,F,w);let d=new Map,R=e=>{let t=d.get(e);return t||(t={ms:0,scroll:0,enterAt:null,intersecting:!1},d.set(e,t)),t},g=new IntersectionObserver(e=>{for(let t of e){let n=p.get(t.target);if(!n)continue;let i=R(n);t.isIntersecting?(i.intersecting=!0,i.enterAt=Date.now(),t.intersectionRatio>i.scroll&&(i.scroll=t.intersectionRatio)):(i.intersecting=!1,i.enterAt!=null&&(i.ms+=Date.now()-i.enterAt,i.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let e of p.keys())g.observe(e);let u=()=>{let e=Date.now();for(let[t,n]of d)if(n.enterAt!=null&&(n.ms+=e-n.enterAt,n.enterAt=null),!(n.ms<=0)){try{l.track({projectId:o.apiKey,componentId:t,eventType:"dwell",payload:{dwell_time:Math.round(n.ms),scroll_depth:Number(n.scroll.toFixed(2))}})}catch(i){}n.ms=0}},A=()=>{if(r.hidden)u();else{let e=Date.now();for(let t of d.values())t.intersecting&&(t.enterAt=e)}},f=!1,T=e=>{if(u(),e!=null&&e.persisted){f=!0;return}try{g.disconnect()}catch(t){}},b=e=>{if(!(e!=null&&e.persisted)||!f)return;f=!1;let t=Date.now();for(let n of d.values())n.enterAt=n.intersecting&&!r.hidden?t:null};r.addEventListener("visibilitychange",A);let s=(x=r.defaultView)!=null?x:typeof window!="undefined"?window:void 0;s==null||s.addEventListener("pagehide",T),s==null||s.addEventListener("pageshow",b);let $=setInterval(()=>{if(r.hidden||f)return;u();let e=Date.now();for(let t of d.values())t.intersecting&&(t.enterAt=e)},H),I=[];return o.microSignals&&[...p.entries()].forEach(([e,t],n)=>{I.push(K((i,m={})=>{try{l.track({projectId:o.apiKey,componentId:t,eventType:"micro_signal",payload:v({signalType:i},m)})}catch(h){}},e,void 0,{tabLoss:n===0}))}),()=>{u(),clearInterval($),r.removeEventListener("visibilitychange",A),s==null||s.removeEventListener("pagehide",T),s==null||s.removeEventListener("pageshow",b);for(let e of I)e();try{g.disconnect()}catch(e){}}}export{E as SEMANTIC_TYPES,j as classifyFeatures,S as classifySection,V as featuresFromElement,J as startEngagementCapture};
1
+ import{a as Y}from"./chunk-WKXD7KI3.mjs";import{a as T,d as z,e as E,f as b,g as G}from"./chunk-Z6ILOYBD.mjs";import{x as H,z as J}from"./chunk-RCN2SIB6.mjs";import"./chunk-2NVSFI4V.mjs";import{a as f,b as V}from"./chunk-TMCGHANO.mjs";import{fnv1a as Q}from"@sentientui/policy";var X="section, header, footer, nav, main > div, [data-sentient-section]",Z=2e4;function ee(d){let r=Array.from(d.querySelectorAll(X)),i=r.filter(a=>r.filter(c=>c!==a&&a.contains(c)).length<2);return i.filter(a=>!i.some(c=>c!==a&&c.contains(a)))}function te(d,r,i,a){try{fetch(`${r}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${d}`},body:JSON.stringify({pageUrl:i,sections:a})}).catch(()=>{})}catch(c){}}var h=()=>{};function ne(d,r){var k,x,L,N,D,R,_,F,M,P,$,K;let i=(k=r.doc)!=null?k:typeof document!="undefined"?document:void 0;if(!i||typeof IntersectionObserver=="undefined"||J()||!r.apiKey||!r.apiKey.startsWith("pk_"))return h;let a=((x=r.apiBase)!=null?x:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),c=ee(i);if(c.length===0)return h;let m=new Map,A=[];for(let e of c){let t=e.getAttribute("data-sentient-type"),o=t&&T.includes(t)?t:null,n=b(e),p=(N=o!=null?o:(L=r.typeOf)==null?void 0:L.call(r,e))!=null?N:E(n).type,l=Y(e,i),B=l?`nc-${p}-${Q(JSON.stringify({id:(D=l.id)!=null?D:null,dataAttr:(R=l.dataAttr)!=null?R:null,selector:(_=l.selector)!=null?_:null})).toString(36)}`:`nc-${p}`;m.set(e,B);let j=z.filter(([,S])=>S.test(n.bodyText)).map(([S])=>S);A.push(V(f({componentId:B,semanticType:p,source:o?"markup":"auto"},l?{locator:l}:{}),{observation:f(f({tag:n.tag,idClass:n.idClass.slice(0,200),headingText:n.headingText,textLength:n.textLength,actionCount:n.actionCount},n.ariaRole?{ariaRole:n.ariaRole}:{}),j.length>0?{patternFlags:j}:{})}))}let q=($=(P=(M=(F=i.defaultView)!=null?F:typeof window!="undefined"?window:void 0)==null?void 0:M.location)==null?void 0:P.pathname)!=null?$:"/";te(r.apiKey,a,q,A);let u=new Map,U=e=>{let t=u.get(e);return t||(t={ms:0,scroll:0,enterAt:null,intersecting:!1},u.set(e,t)),t},v=new IntersectionObserver(e=>{for(let t of e){let o=m.get(t.target);if(!o)continue;let n=U(o);t.isIntersecting?(n.intersecting=!0,n.enterAt=Date.now(),t.intersectionRatio>n.scroll&&(n.scroll=t.intersectionRatio)):(n.intersecting=!1,n.enterAt!=null&&(n.ms+=Date.now()-n.enterAt,n.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let e of m.keys())v.observe(e);let g=()=>{let e=Date.now();for(let[t,o]of u)if(o.enterAt!=null&&(o.ms+=e-o.enterAt,o.enterAt=null),!(o.ms<=0)){try{d.track({projectId:r.apiKey,componentId:t,eventType:"dwell",payload:{dwell_time:Math.round(o.ms),scroll_depth:Number(o.scroll.toFixed(2))}})}catch(n){}o.ms=0}},w=()=>{if(i.hidden)g();else{let e=Date.now();for(let t of u.values())t.intersecting&&(t.enterAt=e)}},y=!1,C=e=>{if(g(),e!=null&&e.persisted){y=!0;return}try{v.disconnect()}catch(t){}},O=e=>{if(!(e!=null&&e.persisted)||!y)return;y=!1;let t=Date.now();for(let o of u.values())o.enterAt=o.intersecting&&!i.hidden?t:null};i.addEventListener("visibilitychange",w);let s=(K=i.defaultView)!=null?K:typeof window!="undefined"?window:void 0;s==null||s.addEventListener("pagehide",C),s==null||s.addEventListener("pageshow",O);let W=setInterval(()=>{if(i.hidden||y)return;g();let e=Date.now();for(let t of u.values())t.intersecting&&(t.enterAt=e)},Z),I=[];return r.microSignals&&[...m.entries()].forEach(([e,t],o)=>{I.push(H((n,p={})=>{try{d.track({projectId:r.apiKey,componentId:t,eventType:"micro_signal",payload:f({signalType:n},p)})}catch(l){}},e,void 0,{tabLoss:o===0}))}),()=>{g(),clearInterval(W),i.removeEventListener("visibilitychange",w),s==null||s.removeEventListener("pagehide",C),s==null||s.removeEventListener("pageshow",O);for(let e of I)e();try{v.disconnect()}catch(e){}}}export{T as SEMANTIC_TYPES,E as classifyFeatures,G as classifySection,b as featuresFromElement,ne as startEngagementCapture};
2
2
  //# sourceMappingURL=index-engagement.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/engagement/capture.ts"],"sourcesContent":["import { classifySection, SEMANTIC_TYPES, type SemanticType } from './classify';\nimport { isDoNotTrackEnabled } from '../index.js';\nimport { attachMicroSignalDetectors } from '../micro-signals.js';\nimport { locatorFromElement } from '../locator-from-dom.js';\n\n// Shared engagement capture (spec 2026-07-22-persona-signal-capture). Detects\n// semantic sections, registers them via /v1/section-map, and records per-section\n// dwell/scroll via IntersectionObserver — emitting the same 'dwell' events the\n// persona pipeline consumes. Used by the React provider (default on) and the\n// no-code snippet. Defense-in-depth: checks DNT internally even though callers\n// gate on consent/DNT too; a missing IntersectionObserver → no-op.\n\ntype CaptureClient = {\n track(event: { projectId: string; componentId: string; eventType: string; payload: Record<string, unknown> }): void;\n};\n\nexport type EngagementCaptureOptions = {\n apiKey: string;\n /** API base, no trailing slash. Defaults to the hosted API. */\n apiBase?: string;\n doc?: Document;\n /**\n * Also attach per-section micro-signal detectors (rage click, text copy,\n * scroll hesitation, tab loss), attributed to the section's `nc-<type>`\n * component. For the no-code snippet, whose pages have no `<Adaptive>`\n * components carrying their own detectors. Default false — the React SDK\n * keeps its per-component detectors and must not double-attach.\n */\n microSignals?: boolean;\n /**\n * Server-served section-map lookup (persona-coverage auto-classification):\n * consulted after explicit `data-sentient-type` markup, before the local\n * heuristic. Return null when the element has no served label.\n */\n typeOf?: (el: Element) => SemanticType | null;\n};\n\nconst SECTION_SELECTOR = 'section, header, footer, nav, main > div, [data-sentient-section]';\n\n/** Bank cadence for visible dwell. Dwell used to leave the page only on\n * visibilitychange/pagehide, and in production that path delivered for ~5-8%\n * of sessions (Bodyshop audit 2026-08-30): a visitor who reads and closes the\n * tab races the unload pipeline, and mobile browsers can kill a page with no\n * lifecycle event at all. The heartbeat caps the loss at one interval. */\nconst HEARTBEAT_MS = 20_000;\n\n/**\n * Pick the elements to observe. Two rules, in order:\n * 1. A candidate that CONTAINS two or more other candidates is a layout\n * wrapper, not a section — drop it. Pages built from bare divs match\n * `main > div` with their page-wide content wrapper; keeping that outer\n * match swallowed every real <section> inside it, collapsing the whole page\n * into one nc-generic component whose intersectionRatio could never exceed\n * viewport-height / page-height (a constant ~0.05 scroll_depth on the\n * audited site). A candidate with exactly one nested candidate (header >\n * nav) is NOT a wrapper — rule 2 keeps the outer one, as before.\n * 2. Of what remains, skip a section nested inside another kept section\n * (avoid double count).\n */\nfunction selectSections(doc: Document): Element[] {\n const candidates = Array.from(doc.querySelectorAll(SECTION_SELECTOR));\n const kept = candidates.filter(\n (el) => candidates.filter((c) => c !== el && el.contains(c)).length < 2,\n );\n return kept.filter((el) => !kept.some((k) => k !== el && k.contains(el)));\n}\n\nfunction registerSections(\n apiKey: string,\n apiBase: string,\n pageUrl: string,\n sections: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n }>,\n): void {\n try {\n void fetch(`${apiBase}/v1/section-map`, {\n method: 'POST',\n keepalive: true,\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({ pageUrl, sections }),\n }).catch(() => undefined);\n } catch {\n /* fail-safe */\n }\n}\n\nconst NOOP = (): void => undefined;\n\nexport function startEngagementCapture(\n client: CaptureClient,\n opts: EngagementCaptureOptions,\n): () => void {\n const doc = opts.doc ?? (typeof document !== 'undefined' ? document : undefined);\n if (!doc || typeof IntersectionObserver === 'undefined') return NOOP;\n if (isDoNotTrackEnabled()) return NOOP;\n // Keyless zero-network contract: capture exists to feed the hosted persona\n // pipeline — with no api key there is nothing to feed, and the section-map\n // registration fetch must never fire. Same validity rule as init() and the\n // graph entry: this used to check truthiness only, so an invalid non-`pk_`\n // (typo'd) key still fired /v1/section-map registration and dwell events\n // into a client that discards everything.\n if (!opts.apiKey || !opts.apiKey.startsWith('pk_')) return NOOP;\n // Normalize so both a ROOT base (`https://api.sentient-ui.com`) and a\n // `/v1`-suffixed base resolve to exactly one `/v1/section-map` — some callers\n // pass the versioned base, which would otherwise produce `/v1/v1/section-map`\n // (a silent 404). Strip trailing slashes, then a single trailing `/v1`.\n const apiBase = (opts.apiBase ?? 'https://api.sentient-ui.com')\n .replace(/\\/+$/, '')\n .replace(/\\/v1$/, '');\n\n const els = selectSections(doc);\n if (els.length === 0) return NOOP;\n\n // Collapse to one component per semantic type per page (the matrix aggregates\n // by semantic type anyway). Per-element precedence: explicit data-sentient-type\n // markup → served section map (opts.typeOf) → local heuristic.\n const componentOf = new Map<Element, string>();\n // One entry PER ELEMENT for the section map, even though componentId still\n // collapses by type. The server derives a distinct section_key from each\n // locator, so a page whose bands all classify `generic` still gets one\n // identity per band instead of a single nc-generic covering all of them.\n // Dwell keeps keying on the collapsed componentId — that is unchanged here.\n const entries: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n }> = [];\n for (const el of els) {\n const explicit = el.getAttribute('data-sentient-type');\n const markup = explicit && (SEMANTIC_TYPES as readonly string[]).includes(explicit)\n ? (explicit as SemanticType)\n : null;\n const type = markup ?? opts.typeOf?.(el) ?? classifySection(el);\n const componentId = `nc-${type}`;\n componentOf.set(el, componentId);\n // `source` is now per ELEMENT, not per collapsed component. Previously,\n // markup on any one element made the whole collapsed component report as\n // 'markup'; with one row per section the server can record each section's\n // real provenance instead of the most-confident of its siblings'.\n const locator = locatorFromElement(el, doc);\n entries.push({\n componentId,\n semanticType: type,\n source: markup ? 'markup' : 'auto',\n ...(locator ? { locator } : {}),\n });\n }\n\n const pageUrl = (doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined))?.location?.pathname ?? '/';\n registerSections(opts.apiKey, apiBase, pageUrl, entries);\n\n // Accumulate visible dwell (ms) + max scroll ratio per component. `intersecting`\n // tracks in-viewport state independently of `enterAt` (the running clock) so a\n // tab-hide can pause the clock and a tab-show can resume it for still-visible\n // sections — IntersectionObserver does not re-fire on visibilitychange.\n const state = new Map<string, { ms: number; scroll: number; enterAt: number | null; intersecting: boolean }>();\n const get = (id: string) => {\n let s = state.get(id);\n if (!s) { s = { ms: 0, scroll: 0, enterAt: null, intersecting: false }; state.set(id, s); }\n return s;\n };\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n const id = componentOf.get(entry.target);\n if (!id) continue;\n const s = get(id);\n if (entry.isIntersecting) {\n s.intersecting = true;\n s.enterAt = Date.now();\n if (entry.intersectionRatio > s.scroll) s.scroll = entry.intersectionRatio;\n } else {\n s.intersecting = false;\n if (s.enterAt != null) { s.ms += Date.now() - s.enterAt; s.enterAt = null; }\n }\n }\n }, { threshold: [0, 0.25, 0.5, 0.75, 1] });\n for (const el of componentOf.keys()) observer.observe(el);\n\n // Bank accumulated dwell and RESET the accumulators (so a later emit can't\n // double-count) WITHOUT disconnecting — a visitor who hides/re-shows the tab\n // or tab-switches keeps being measured. Pauses the running clock; the tab-show\n // handler restarts it for still-visible sections so hidden time isn't counted.\n const emit = (): void => {\n const now = Date.now();\n for (const [id, s] of state) {\n if (s.enterAt != null) { s.ms += now - s.enterAt; s.enterAt = null; }\n if (s.ms <= 0) continue;\n try {\n client.track({\n projectId: opts.apiKey, // SDK convention: server derives the real project from the key\n componentId: id,\n eventType: 'dwell',\n payload: { dwell_time: Math.round(s.ms), scroll_depth: Number(s.scroll.toFixed(2)) },\n });\n } catch {\n /* fail-safe */\n }\n s.ms = 0;\n }\n };\n\n const onVisibility = (): void => {\n if (doc.hidden) {\n emit(); // bank + pause\n } else {\n const now = Date.now(); // resume the clock for sections still on screen\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }\n };\n // A page can be FROZEN into the bfcache rather than torn down. Timers keep\n // firing on restore, and `intersecting` still holds whatever it held at\n // pagehide — so without this the heartbeat kept banking dwell for sections the\n // visitor had scrolled far past, forever, while the observer that could have\n // corrected them had been disconnected. Freeze the clocks instead, and only\n // tear down for real when the page is genuinely going away.\n let frozen = false;\n const onPageHide = (event?: { persisted?: boolean }): void => {\n emit(); // bank whatever is measured either way\n if (event?.persisted) {\n frozen = true; // bfcache: keep the observer, stop counting\n return;\n }\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n const onPageShow = (event?: { persisted?: boolean }): void => {\n if (!event?.persisted || !frozen) return;\n frozen = false;\n // The observer stayed connected, so it will correct `intersecting` for\n // anything that moved. Restart clocks only for what is on screen NOW.\n const now = Date.now();\n for (const s of state.values()) s.enterAt = s.intersecting && !doc.hidden ? now : null;\n };\n doc.addEventListener('visibilitychange', onVisibility);\n const win = doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n win?.addEventListener('pagehide', onPageHide);\n win?.addEventListener('pageshow', onPageShow);\n\n // See HEARTBEAT_MS: bank visible dwell periodically so a hard close (or a\n // mobile page kill) loses at most one interval instead of the whole visit.\n // Hidden tabs skip the emit — their clock is already paused, and an empty\n // state map makes emit a no-op anyway.\n const heartbeat = setInterval(() => {\n if (doc.hidden || frozen) return;\n emit();\n // emit() pauses every running clock and only the tab-show handler restarts\n // them — here the page never went hidden, so restart the clock ourselves\n // or accumulation silently stops after the first heartbeat.\n const now = Date.now();\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }, HEARTBEAT_MS);\n\n // Per-section micro-signal detectors (opt-in; see EngagementCaptureOptions).\n // Attributed to the section's nc-<type> id with no variant — they feed the\n // persona attention fallback and auto-discovery, never rewards.\n const detectorCleanups: Array<() => void> = [];\n if (opts.microSignals) {\n // tab_loss is a single document-level `visibilitychange` signal, so enabling\n // it on every section detector would emit one tab_loss per nc-<type> section\n // on a single tab-hide — attributing one page-level exit to every section\n // (audit M5). Enable it on only the first section so the exit is recorded\n // once, mirroring the per-option path in slot-signals.ts ({ tabLoss: index === 0 }).\n [...componentOf.entries()].forEach(([el, componentId], i) => {\n detectorCleanups.push(\n attachMicroSignalDetectors((signalType, extra = {}) => {\n try {\n client.track({\n projectId: opts.apiKey,\n componentId,\n eventType: 'micro_signal',\n payload: { signalType, ...extra },\n });\n } catch {\n /* fail-safe */\n }\n }, el, undefined, { tabLoss: i === 0 }),\n );\n });\n }\n\n // Cleanup: bank any remaining dwell, then detach everything (provider unmount\n // / consent re-init must not leak observers or listeners).\n return () => {\n emit();\n clearInterval(heartbeat);\n doc.removeEventListener('visibilitychange', onVisibility);\n win?.removeEventListener('pagehide', onPageHide);\n win?.removeEventListener('pageshow', onPageShow);\n for (const c of detectorCleanups) c();\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n}\n"],"mappings":"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","names":["SECTION_SELECTOR","HEARTBEAT_MS","selectSections","doc","candidates","kept","el","k","registerSections","apiKey","apiBase","pageUrl","sections","e","NOOP","startEngagementCapture","client","opts","_a","_b","_c","_d","_e","_f","_g","_h","_i","isDoNotTrackEnabled","els","componentOf","entries","explicit","markup","SEMANTIC_TYPES","type","classifySection","componentId","locator","locatorFromElement","__spreadValues","state","get","id","s","observer","entry","emit","now","onVisibility","frozen","onPageHide","event","onPageShow","win","heartbeat","detectorCleanups","i","attachMicroSignalDetectors","signalType","extra","c"]}
1
+ {"version":3,"sources":["../src/engagement/capture.ts"],"sourcesContent":["import {\n classifyFeatures,\n featuresFromElement,\n CONTENT_PATTERNS,\n SEMANTIC_TYPES,\n type SemanticType,\n} from './classify';\nimport { fnv1a } from '@sentientui/policy';\nimport { isDoNotTrackEnabled } from '../index.js';\nimport { attachMicroSignalDetectors } from '../micro-signals.js';\nimport { locatorFromElement } from '../locator-from-dom.js';\n\n// Shared engagement capture (spec 2026-07-22-persona-signal-capture). Detects\n// semantic sections, registers them via /v1/section-map, and records per-section\n// dwell/scroll via IntersectionObserver — emitting the same 'dwell' events the\n// persona pipeline consumes. Used by the React provider (default on) and the\n// no-code snippet. Defense-in-depth: checks DNT internally even though callers\n// gate on consent/DNT too; a missing IntersectionObserver → no-op.\n\ntype CaptureClient = {\n track(event: { projectId: string; componentId: string; eventType: string; payload: Record<string, unknown> }): void;\n};\n\nexport type EngagementCaptureOptions = {\n apiKey: string;\n /** API base, no trailing slash. Defaults to the hosted API. */\n apiBase?: string;\n doc?: Document;\n /**\n * Also attach per-section micro-signal detectors (rage click, text copy,\n * scroll hesitation, tab loss), attributed to the section's per-element `nc-*`\n * component. For the no-code snippet, whose pages have no `<Adaptive>`\n * components carrying their own detectors. Default false — the React SDK\n * keeps its per-component detectors and must not double-attach.\n */\n microSignals?: boolean;\n /**\n * Server-served section-map lookup (persona-coverage auto-classification):\n * consulted after explicit `data-sentient-type` markup, before the local\n * heuristic. Return null when the element has no served label.\n */\n typeOf?: (el: Element) => SemanticType | null;\n};\n\nconst SECTION_SELECTOR = 'section, header, footer, nav, main > div, [data-sentient-section]';\n\n/** Bank cadence for visible dwell. Dwell used to leave the page only on\n * visibilitychange/pagehide, and in production that path delivered for ~5-8%\n * of sessions (Bodyshop audit 2026-08-30): a visitor who reads and closes the\n * tab races the unload pipeline, and mobile browsers can kill a page with no\n * lifecycle event at all. The heartbeat caps the loss at one interval. */\nconst HEARTBEAT_MS = 20_000;\n\n/**\n * Pick the elements to observe. Two rules, in order:\n * 1. A candidate that CONTAINS two or more other candidates is a layout\n * wrapper, not a section — drop it. Pages built from bare divs match\n * `main > div` with their page-wide content wrapper; keeping that outer\n * match swallowed every real <section> inside it, collapsing the whole page\n * into one nc-generic component whose intersectionRatio could never exceed\n * viewport-height / page-height (a constant ~0.05 scroll_depth on the\n * audited site). A candidate with exactly one nested candidate (header >\n * nav) is NOT a wrapper — rule 2 keeps the outer one, as before.\n * 2. Of what remains, skip a section nested inside another kept section\n * (avoid double count).\n */\nfunction selectSections(doc: Document): Element[] {\n const candidates = Array.from(doc.querySelectorAll(SECTION_SELECTOR));\n const kept = candidates.filter(\n (el) => candidates.filter((c) => c !== el && el.contains(c)).length < 2,\n );\n return kept.filter((el) => !kept.some((k) => k !== el && k.contains(el)));\n}\n\n/** Client-sensor observation riding each section-map entry (spec 2026-09-04\n * §2): structure, headings, and which CONTENT_PATTERNS matched — never body\n * text, so nothing beyond headings leaves the page. Lets the server's richer\n * topic classifier label pages the crawler cannot fetch (CSR, auth-walled). */\ntype SectionObservation = {\n tag: string;\n idClass: string;\n headingText: string;\n textLength: number;\n actionCount: number;\n ariaRole?: string;\n patternFlags?: SemanticType[];\n};\n\nfunction registerSections(\n apiKey: string,\n apiBase: string,\n pageUrl: string,\n sections: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n observation?: SectionObservation;\n }>,\n): void {\n try {\n void fetch(`${apiBase}/v1/section-map`, {\n method: 'POST',\n keepalive: true,\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({ pageUrl, sections }),\n }).catch(() => undefined);\n } catch {\n /* fail-safe */\n }\n}\n\nconst NOOP = (): void => undefined;\n\nexport function startEngagementCapture(\n client: CaptureClient,\n opts: EngagementCaptureOptions,\n): () => void {\n const doc = opts.doc ?? (typeof document !== 'undefined' ? document : undefined);\n if (!doc || typeof IntersectionObserver === 'undefined') return NOOP;\n if (isDoNotTrackEnabled()) return NOOP;\n // Keyless zero-network contract: capture exists to feed the hosted persona\n // pipeline — with no api key there is nothing to feed, and the section-map\n // registration fetch must never fire. Same validity rule as init() and the\n // graph entry: this used to check truthiness only, so an invalid non-`pk_`\n // (typo'd) key still fired /v1/section-map registration and dwell events\n // into a client that discards everything.\n if (!opts.apiKey || !opts.apiKey.startsWith('pk_')) return NOOP;\n // Normalize so both a ROOT base (`https://api.sentient-ui.com`) and a\n // `/v1`-suffixed base resolve to exactly one `/v1/section-map` — some callers\n // pass the versioned base, which would otherwise produce `/v1/v1/section-map`\n // (a silent 404). Strip trailing slashes, then a single trailing `/v1`.\n const apiBase = (opts.apiBase ?? 'https://api.sentient-ui.com')\n .replace(/\\/+$/, '')\n .replace(/\\/v1$/, '');\n\n const els = selectSections(doc);\n if (els.length === 0) return NOOP;\n\n // One component per ELEMENT (nc-* retirement, 2026-09-05): the id carries a\n // short locator hash — `nc-<type>-<hash>` — so two same-typed bands no longer\n // collapse into one row with summed dwell, which is what made \"which features\n // band holds attention?\" unanswerable. The hash is over the locator's\n // identity fields (the same subset section_key hashes server-side), so the id\n // is stable across visits. An element with no resolvable locator falls back\n // to the collapsed `nc-<type>` — no identity means no better name exists.\n // The type-level matrix is unaffected (it aggregates via graph_nodes\n // semantic_type); pre-change dwell history stays keyed to collapsed ids and\n // ages out of the reporting windows.\n // Per-element precedence: explicit data-sentient-type markup → served\n // section map (opts.typeOf) → local heuristic.\n const componentOf = new Map<Element, string>();\n const entries: Array<{\n componentId: string;\n semanticType: SemanticType;\n source: 'markup' | 'auto';\n locator?: unknown;\n observation?: SectionObservation;\n }> = [];\n for (const el of els) {\n const explicit = el.getAttribute('data-sentient-type');\n const markup = explicit && (SEMANTIC_TYPES as readonly string[]).includes(explicit)\n ? (explicit as SemanticType)\n : null;\n const f = featuresFromElement(el);\n const type = markup ?? opts.typeOf?.(el) ?? classifyFeatures(f).type;\n const locator = locatorFromElement(el, doc) as\n | { id?: string; dataAttr?: unknown; selector?: string }\n | null;\n const componentId = locator\n ? `nc-${type}-${fnv1a(\n JSON.stringify({ id: locator.id ?? null, dataAttr: locator.dataAttr ?? null, selector: locator.selector ?? null }),\n ).toString(36)}`\n : `nc-${type}`;\n componentOf.set(el, componentId);\n // Client-sensor observation: which shipped CONTENT_PATTERNS matched the\n // body text (booleans — the text itself never leaves the page), plus the\n // structural features the server classifier keys on.\n const patternFlags = CONTENT_PATTERNS.filter(([, re]) => re.test(f.bodyText)).map(([t]) => t);\n entries.push({\n componentId,\n semanticType: type,\n // `source` is per ELEMENT: with one row per section the server records\n // each section's real provenance, not the most-confident of its siblings'.\n source: markup ? 'markup' : 'auto',\n ...(locator ? { locator } : {}),\n observation: {\n tag: f.tag,\n idClass: f.idClass.slice(0, 200),\n headingText: f.headingText,\n textLength: f.textLength,\n actionCount: f.actionCount,\n ...(f.ariaRole ? { ariaRole: f.ariaRole } : {}),\n ...(patternFlags.length > 0 ? { patternFlags } : {}),\n },\n });\n }\n\n const pageUrl = (doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined))?.location?.pathname ?? '/';\n registerSections(opts.apiKey, apiBase, pageUrl, entries);\n\n // Accumulate visible dwell (ms) + max scroll ratio per component. `intersecting`\n // tracks in-viewport state independently of `enterAt` (the running clock) so a\n // tab-hide can pause the clock and a tab-show can resume it for still-visible\n // sections — IntersectionObserver does not re-fire on visibilitychange.\n const state = new Map<string, { ms: number; scroll: number; enterAt: number | null; intersecting: boolean }>();\n const get = (id: string) => {\n let s = state.get(id);\n if (!s) { s = { ms: 0, scroll: 0, enterAt: null, intersecting: false }; state.set(id, s); }\n return s;\n };\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n const id = componentOf.get(entry.target);\n if (!id) continue;\n const s = get(id);\n if (entry.isIntersecting) {\n s.intersecting = true;\n s.enterAt = Date.now();\n if (entry.intersectionRatio > s.scroll) s.scroll = entry.intersectionRatio;\n } else {\n s.intersecting = false;\n if (s.enterAt != null) { s.ms += Date.now() - s.enterAt; s.enterAt = null; }\n }\n }\n }, { threshold: [0, 0.25, 0.5, 0.75, 1] });\n for (const el of componentOf.keys()) observer.observe(el);\n\n // Bank accumulated dwell and RESET the accumulators (so a later emit can't\n // double-count) WITHOUT disconnecting — a visitor who hides/re-shows the tab\n // or tab-switches keeps being measured. Pauses the running clock; the tab-show\n // handler restarts it for still-visible sections so hidden time isn't counted.\n const emit = (): void => {\n const now = Date.now();\n for (const [id, s] of state) {\n if (s.enterAt != null) { s.ms += now - s.enterAt; s.enterAt = null; }\n if (s.ms <= 0) continue;\n try {\n client.track({\n projectId: opts.apiKey, // SDK convention: server derives the real project from the key\n componentId: id,\n eventType: 'dwell',\n payload: { dwell_time: Math.round(s.ms), scroll_depth: Number(s.scroll.toFixed(2)) },\n });\n } catch {\n /* fail-safe */\n }\n s.ms = 0;\n }\n };\n\n const onVisibility = (): void => {\n if (doc.hidden) {\n emit(); // bank + pause\n } else {\n const now = Date.now(); // resume the clock for sections still on screen\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }\n };\n // A page can be FROZEN into the bfcache rather than torn down. Timers keep\n // firing on restore, and `intersecting` still holds whatever it held at\n // pagehide — so without this the heartbeat kept banking dwell for sections the\n // visitor had scrolled far past, forever, while the observer that could have\n // corrected them had been disconnected. Freeze the clocks instead, and only\n // tear down for real when the page is genuinely going away.\n let frozen = false;\n const onPageHide = (event?: { persisted?: boolean }): void => {\n emit(); // bank whatever is measured either way\n if (event?.persisted) {\n frozen = true; // bfcache: keep the observer, stop counting\n return;\n }\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n const onPageShow = (event?: { persisted?: boolean }): void => {\n if (!event?.persisted || !frozen) return;\n frozen = false;\n // The observer stayed connected, so it will correct `intersecting` for\n // anything that moved. Restart clocks only for what is on screen NOW.\n const now = Date.now();\n for (const s of state.values()) s.enterAt = s.intersecting && !doc.hidden ? now : null;\n };\n doc.addEventListener('visibilitychange', onVisibility);\n const win = doc.defaultView ?? (typeof window !== 'undefined' ? window : undefined);\n win?.addEventListener('pagehide', onPageHide);\n win?.addEventListener('pageshow', onPageShow);\n\n // See HEARTBEAT_MS: bank visible dwell periodically so a hard close (or a\n // mobile page kill) loses at most one interval instead of the whole visit.\n // Hidden tabs skip the emit — their clock is already paused, and an empty\n // state map makes emit a no-op anyway.\n const heartbeat = setInterval(() => {\n if (doc.hidden || frozen) return;\n emit();\n // emit() pauses every running clock and only the tab-show handler restarts\n // them — here the page never went hidden, so restart the clock ourselves\n // or accumulation silently stops after the first heartbeat.\n const now = Date.now();\n for (const s of state.values()) if (s.intersecting) s.enterAt = now;\n }, HEARTBEAT_MS);\n\n // Per-section micro-signal detectors (opt-in; see EngagementCaptureOptions).\n // Attributed to the section's per-element nc-* id with no variant — they feed the\n // persona attention fallback and auto-discovery, never rewards.\n const detectorCleanups: Array<() => void> = [];\n if (opts.microSignals) {\n // tab_loss is a single document-level `visibilitychange` signal, so enabling\n // it on every section detector would emit one tab_loss per section\n // on a single tab-hide — attributing one page-level exit to every section\n // (audit M5). Enable it on only the first section so the exit is recorded\n // once, mirroring the per-option path in slot-signals.ts ({ tabLoss: index === 0 }).\n [...componentOf.entries()].forEach(([el, componentId], i) => {\n detectorCleanups.push(\n attachMicroSignalDetectors((signalType, extra = {}) => {\n try {\n client.track({\n projectId: opts.apiKey,\n componentId,\n eventType: 'micro_signal',\n payload: { signalType, ...extra },\n });\n } catch {\n /* fail-safe */\n }\n }, el, undefined, { tabLoss: i === 0 }),\n );\n });\n }\n\n // Cleanup: bank any remaining dwell, then detach everything (provider unmount\n // / consent re-init must not leak observers or listeners).\n return () => {\n emit();\n clearInterval(heartbeat);\n doc.removeEventListener('visibilitychange', onVisibility);\n win?.removeEventListener('pagehide', onPageHide);\n win?.removeEventListener('pageshow', onPageShow);\n for (const c of detectorCleanups) c();\n try { observer.disconnect(); } catch { /* ignore */ }\n };\n}\n"],"mappings":"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","names":["fnv1a","SECTION_SELECTOR","HEARTBEAT_MS","selectSections","doc","candidates","kept","el","k","registerSections","apiKey","apiBase","pageUrl","sections","e","NOOP","startEngagementCapture","client","opts","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","isDoNotTrackEnabled","els","componentOf","entries","explicit","markup","SEMANTIC_TYPES","f","featuresFromElement","type","classifyFeatures","locator","locatorFromElement","componentId","fnv1a","patternFlags","CONTENT_PATTERNS","re","t","__spreadProps","__spreadValues","state","get","id","s","observer","entry","emit","now","onVisibility","frozen","onPageHide","event","onPageShow","win","heartbeat","detectorCleanups","i","attachMicroSignalDetectors","signalType","extra","c"]}
@@ -1,5 +1,5 @@
1
- import { E as CompoundLocator, a6 as SentientConfig, a5 as SentientClient } from './index-Cd0gMdJv.cjs';
2
- export { A as AssignResult, a as Assignment, b as AssignmentCache, B as BLOCK_ALIGNS, c as BLOCK_EMPHASES, d as BLOCK_FITS, e as BLOCK_GAPS, f as BLOCK_GRID_COLUMNS, g as BLOCK_HEADING_LEVELS, h as BLOCK_JUSTIFIES, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_TEXT_ALIGNS, l as BLOCK_TONES, m as BLOCK_WEIGHTS, n as BadgeBlock, o as BlockAlign, p as BlockEmphasis, q as BlockFit, r as BlockGap, s as BlockJustify, t as BlockNode, u as BlockRatio, v as BlockSize, w as BlockTextAlign, x as BlockTone, y as BlockWeight, z as ButtonBlock, H as DecisionSnapshot, I as EventQueue, J as EventType, M as GraphClient, N as GraphConfig, O as GraphSnapshot, P as GridBlock, Q as HeadingBlock, R as ImageBlock, S as LEGACY_SESSION_COOKIE_NAME, U as LinkBlock, V as MAX_BLOCK_ARMS, W as MAX_BLOCK_CHILDREN, X as MAX_BLOCK_DEPTH, Y as MAX_BLOCK_NODES, Z as MAX_BLOCK_TEXT_LEN, _ as MicroSignalEmitter, $ as MicroSignalType, a1 as PageNode, a2 as QueueConfig, a3 as SNAPSHOT_STORAGE_KEY_PREFIX, a7 as SentientEvent, a8 as SessionConfig, a9 as SessionManager, aa as SitePalette, ab as SlotConfigEntry, ac as SlotOps, ad as SpacerBlock, ae as StackBlock, af as TextBlock, ai as attachMicroSignalDetectors, aj as grantConsent, al as isDoNotTrackEnabled, am as readSnapshot, an as renderPrePaintScript, ao as sanitizePageUrl, ap as sessionCookieName, aq as writeSnapshot } from './index-Cd0gMdJv.cjs';
1
+ import { E as CompoundLocator, a6 as SentientConfig, a5 as SentientClient } from './index-Ce3IPLrF.cjs';
2
+ export { A as AssignResult, a as Assignment, b as AssignmentCache, B as BLOCK_ALIGNS, c as BLOCK_EMPHASES, d as BLOCK_FITS, e as BLOCK_GAPS, f as BLOCK_GRID_COLUMNS, g as BLOCK_HEADING_LEVELS, h as BLOCK_JUSTIFIES, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_TEXT_ALIGNS, l as BLOCK_TONES, m as BLOCK_WEIGHTS, n as BadgeBlock, o as BlockAlign, p as BlockEmphasis, q as BlockFit, r as BlockGap, s as BlockJustify, t as BlockNode, u as BlockRatio, v as BlockSize, w as BlockTextAlign, x as BlockTone, y as BlockWeight, z as ButtonBlock, H as DecisionSnapshot, I as EventQueue, J as EventType, M as GraphClient, N as GraphConfig, O as GraphSnapshot, P as GridBlock, Q as HeadingBlock, R as ImageBlock, S as LEGACY_SESSION_COOKIE_NAME, U as LinkBlock, V as MAX_BLOCK_ARMS, W as MAX_BLOCK_CHILDREN, X as MAX_BLOCK_DEPTH, Y as MAX_BLOCK_NODES, Z as MAX_BLOCK_TEXT_LEN, _ as MicroSignalEmitter, $ as MicroSignalType, a1 as PageNode, a2 as QueueConfig, a3 as SNAPSHOT_STORAGE_KEY_PREFIX, a7 as SentientEvent, a8 as SessionConfig, a9 as SessionManager, aa as SitePalette, ab as SlotConfigEntry, ac as SlotOps, ad as SpacerBlock, ae as StackBlock, af as TextBlock, ai as attachMicroSignalDetectors, aj as grantConsent, al as isDoNotTrackEnabled, am as readSnapshot, an as renderPrePaintScript, ao as sanitizePageUrl, ap as sessionCookieName, aq as writeSnapshot } from './index-Ce3IPLrF.cjs';
3
3
  export { b as SlotDeclInput, e as armOfResult, f as baselineResultFor, g as baselineSlots, j as deriveSessionSegment, k as detectDeviceClass, l as detectTimeOfDay, m as detectTrafficSource, r as referrerDomainFromReferer, t as toWireSlot } from './session-meta-C-bMqVeq.cjs';
4
4
  export { SlotResult } from '@sentientui/policy';
5
5
 
@@ -1,5 +1,5 @@
1
- import { E as CompoundLocator, a6 as SentientConfig, a5 as SentientClient } from './index-BjVvN7cU.js';
2
- export { A as AssignResult, a as Assignment, b as AssignmentCache, B as BLOCK_ALIGNS, c as BLOCK_EMPHASES, d as BLOCK_FITS, e as BLOCK_GAPS, f as BLOCK_GRID_COLUMNS, g as BLOCK_HEADING_LEVELS, h as BLOCK_JUSTIFIES, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_TEXT_ALIGNS, l as BLOCK_TONES, m as BLOCK_WEIGHTS, n as BadgeBlock, o as BlockAlign, p as BlockEmphasis, q as BlockFit, r as BlockGap, s as BlockJustify, t as BlockNode, u as BlockRatio, v as BlockSize, w as BlockTextAlign, x as BlockTone, y as BlockWeight, z as ButtonBlock, H as DecisionSnapshot, I as EventQueue, J as EventType, M as GraphClient, N as GraphConfig, O as GraphSnapshot, P as GridBlock, Q as HeadingBlock, R as ImageBlock, S as LEGACY_SESSION_COOKIE_NAME, U as LinkBlock, V as MAX_BLOCK_ARMS, W as MAX_BLOCK_CHILDREN, X as MAX_BLOCK_DEPTH, Y as MAX_BLOCK_NODES, Z as MAX_BLOCK_TEXT_LEN, _ as MicroSignalEmitter, $ as MicroSignalType, a1 as PageNode, a2 as QueueConfig, a3 as SNAPSHOT_STORAGE_KEY_PREFIX, a7 as SentientEvent, a8 as SessionConfig, a9 as SessionManager, aa as SitePalette, ab as SlotConfigEntry, ac as SlotOps, ad as SpacerBlock, ae as StackBlock, af as TextBlock, ai as attachMicroSignalDetectors, aj as grantConsent, al as isDoNotTrackEnabled, am as readSnapshot, an as renderPrePaintScript, ao as sanitizePageUrl, ap as sessionCookieName, aq as writeSnapshot } from './index-BjVvN7cU.js';
1
+ import { E as CompoundLocator, a6 as SentientConfig, a5 as SentientClient } from './index-DubrRV6l.js';
2
+ export { A as AssignResult, a as Assignment, b as AssignmentCache, B as BLOCK_ALIGNS, c as BLOCK_EMPHASES, d as BLOCK_FITS, e as BLOCK_GAPS, f as BLOCK_GRID_COLUMNS, g as BLOCK_HEADING_LEVELS, h as BLOCK_JUSTIFIES, i as BLOCK_RATIOS, j as BLOCK_SIZES, k as BLOCK_TEXT_ALIGNS, l as BLOCK_TONES, m as BLOCK_WEIGHTS, n as BadgeBlock, o as BlockAlign, p as BlockEmphasis, q as BlockFit, r as BlockGap, s as BlockJustify, t as BlockNode, u as BlockRatio, v as BlockSize, w as BlockTextAlign, x as BlockTone, y as BlockWeight, z as ButtonBlock, H as DecisionSnapshot, I as EventQueue, J as EventType, M as GraphClient, N as GraphConfig, O as GraphSnapshot, P as GridBlock, Q as HeadingBlock, R as ImageBlock, S as LEGACY_SESSION_COOKIE_NAME, U as LinkBlock, V as MAX_BLOCK_ARMS, W as MAX_BLOCK_CHILDREN, X as MAX_BLOCK_DEPTH, Y as MAX_BLOCK_NODES, Z as MAX_BLOCK_TEXT_LEN, _ as MicroSignalEmitter, $ as MicroSignalType, a1 as PageNode, a2 as QueueConfig, a3 as SNAPSHOT_STORAGE_KEY_PREFIX, a7 as SentientEvent, a8 as SessionConfig, a9 as SessionManager, aa as SitePalette, ab as SlotConfigEntry, ac as SlotOps, ad as SpacerBlock, ae as StackBlock, af as TextBlock, ai as attachMicroSignalDetectors, aj as grantConsent, al as isDoNotTrackEnabled, am as readSnapshot, an as renderPrePaintScript, ao as sanitizePageUrl, ap as sessionCookieName, aq as writeSnapshot } from './index-DubrRV6l.js';
3
3
  export { b as SlotDeclInput, e as armOfResult, f as baselineResultFor, g as baselineSlots, j as deriveSessionSegment, k as detectDeviceClass, l as detectTimeOfDay, m as detectTrafficSource, r as referrerDomainFromReferer, t as toWireSlot } from './session-meta-C-bMqVeq.js';
4
4
  export { SlotResult } from '@sentientui/policy';
5
5
 
@@ -1,2 +1,2 @@
1
- "use strict";var Gt=Object.create;var ve=Object.defineProperty,$t=Object.defineProperties,Ut=Object.getOwnPropertyDescriptor,Ft=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertyNames,tt=Object.getOwnPropertySymbols,Wt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var nt=(e,t,n)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))rt.call(t,n)&&nt(e,n,t[n]);if(tt)for(var n of tt(t))Ht.call(t,n)&&nt(e,n,t[n]);return e},j=(e,t)=>$t(e,Ft(t));var zt=(e,t)=>{for(var n in t)ve(e,n,{get:t[n],enumerable:!0})},ot=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of jt(t))!rt.call(e,d)&&d!==n&&ve(e,d,{get:()=>t[d],enumerable:!(c=Ut(t,d))||c.enumerable});return e};var qt=(e,t,n)=>(n=e!=null?Gt(Wt(e)):{},ot(t||!e||!e.__esModule?ve(n,"default",{value:e,enumerable:!0}):n,e)),Qt=e=>ot(ve({},"__esModule",{value:!0}),e);var hr={};zt(hr,{BLOCK_ALIGNS:()=>hn,BLOCK_EMPHASES:()=>En,BLOCK_FITS:()=>In,BLOCK_GAPS:()=>yn,BLOCK_GRID_COLUMNS:()=>kn,BLOCK_HEADING_LEVELS:()=>Tn,BLOCK_JUSTIFIES:()=>Sn,BLOCK_RATIOS:()=>Cn,BLOCK_SIZES:()=>bn,BLOCK_TEXT_ALIGNS:()=>xn,BLOCK_TONES:()=>wn,BLOCK_WEIGHTS:()=>vn,LEGACY_SESSION_COOKIE_NAME:()=>we,MAX_BLOCK_ARMS:()=>On,MAX_BLOCK_CHILDREN:()=>Rn,MAX_BLOCK_DEPTH:()=>_n,MAX_BLOCK_NODES:()=>An,MAX_BLOCK_TEXT_LEN:()=>Pn,SNAPSHOT_STORAGE_KEY_PREFIX:()=>re,armOfResult:()=>Le,attachMicroSignalDetectors:()=>bt,baselineResultFor:()=>fe,baselineSlots:()=>ft,deriveSessionSegment:()=>We,detectDeviceClass:()=>le,detectTimeOfDay:()=>pe,detectTrafficSource:()=>de,grantConsent:()=>It,init:()=>Kt,isDoNotTrackEnabled:()=>Ce,locatorFromElement:()=>Ke,readSnapshot:()=>me,referrerDomainFromReferer:()=>ue,renderPrePaintScript:()=>mt,sanitizePageUrl:()=>Je,sessionCookieName:()=>ae,toWireSlot:()=>Ee,writeSnapshot:()=>ye});module.exports=Qt(hr);function Te(){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 ne(e){return e?`_${e.slice(0,12)}`:""}var we="_snt_uid";function ae(e){return`${we}${ne(e)}`}var Jt="_snt_uid",Xt=365,Ae="_snt_uid";function Yt(){return Te()}function st(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Vt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(c){}}function $e(e){try{return localStorage.getItem(e)}catch(t){return null}}function it(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function at(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Zt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function en(e){try{sessionStorage.removeItem(e)}catch(t){}}function tn(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 nn(e){try{localStorage.removeItem(e)}catch(t){}}function rn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var on={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function _e(e){var m,S,x,E,G,U,A;if(typeof window=="undefined")return on;let t=ne(e==null?void 0:e.apiKey),n=(m=e==null?void 0:e.cookieName)!=null?m:ae(e==null?void 0:e.apiKey),c=`${Ae}${t}`,d=`${Ae}_tomb${t}`,a=((S=e==null?void 0:e.cookieTTLDays)!=null?S:Xt)*24*60*60,l=I=>I&&I.length>0?I:null,u=()=>{var I,N;return t&&!(e!=null&&e.cookieName)&&$e(d)===null?(N=(I=l(st(Jt)))!=null?I:l($e(Ae)))!=null?N:l(at(Ae)):null},o=(A=(U=(G=(E=(x=l(st(n)))!=null?x:l($e(c)))!=null?E:l(at(c)))!=null?G:u())!=null?U:l(e==null?void 0:e.ssrSessionId))!=null?A:Yt();Vt(n,o,a);let r=it(c,o),s=tn(n),g=r?!1:Zt(c,o),p=!r&&!s&&!g;return{getSessionId:()=>o,isEphemeral:()=>p,destroy:()=>{o=null,rn(n),nn(c),en(c),t&&!(e!=null&&e.cookieName)&&it(d,"1")}}}function Y(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ce(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Re(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(e),c.slice(-t)):[]}catch(n){return[]}}function V(e,t,n){try{let c=(()=>{try{let i=localStorage.getItem(n);if(!i)return[];let a=JSON.parse(i);return Array.isArray(a)?a:[]}catch(i){return[]}})(),d=new Map;for(let i of c)d.set(i.id,i);for(let i of e)d.set(i.id,i);localStorage.setItem(n,JSON.stringify([...d.values()].slice(-t)))}catch(c){}}function Oe(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let d=new Set(e),i=c.filter(a=>!d.has(a.id));if(i.length===c.length)return;i.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(i))}catch(n){}}var sn=500,an=56*1024;function Ue(e){return`_snt_retry_${e.slice(0,12)}`}var cn={push:()=>{},flush:()=>{},destroy:()=>{}};function ct(e){var Z,M,oe;if(typeof window=="undefined")return cn;let t=(Z=e.flushIntervalMs)!=null?Z:5e3,n=(M=e.maxBatchSize)!=null?M:20,c=(oe=e.maxRetrySize)!=null?oe:100,d=e.ingestUrl,i=e.apiKey,a=Ue(i),l=[],u=new Set,o=[],r=h=>{for(let k of h)s.delete(k),!u.has(k)&&(u.add(k),o.push(k));for(;o.length>sn;){let k=o.shift();k&&u.delete(k)}Oe(h,a)},s=new Set,g=()=>{for(;l.length>c;){let h=l.shift();h&&s.delete(h.id)}},p=h=>{u.has(h.id)||s.has(h.id)||(s.add(h.id),l.push(h),g())},m=h=>{for(let k of h)u.has(k.id)||(s.add(k.id),l.push(k));g()},S=Re(a,c);for(let h of S)p(h);let x=0,E=0,G=(h,k=!0)=>{if(h.length===0)return;let H=JSON.stringify(h),ee=h.map(q=>q.id),F;try{F=fetch(d,{method:"POST",keepalive:!0,body:H,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(q){V(h,c,a),m(h),E++,x=Date.now()+Y(E);return}let he=q=>{if(ce(q)!=="retry"){if(!q.ok&&k){let se=h.filter(Q=>Q.eventType!=="pageview");if(se.length>0&&se.length<h.length){r(h.filter(Q=>Q.eventType==="pageview").map(Q=>Q.id)),G(se,!1);return}}r(ee),E=0,x=0;return}V(h,c,a),m(h),E++,x=Date.now()+Y(E)};F instanceof Promise?F.then(he).catch(()=>{V(h,c,a),m(h),E++,x=Date.now()+Y(E)}):he(F)},U=typeof TextEncoder!="undefined"?new TextEncoder:null,A=h=>U?U.encode(h).length:h.length,I=h=>{let k=[],H=2;for(let ee of h){let F=A(JSON.stringify(ee))+1;if(k.length>0&&H+F>an||k.length>=n)break;k.push(ee),H+=F}return k},N=()=>{try{if(Date.now()<x)return;for(;l.length>0&&!(Date.now()<x);){let h=l.filter(H=>!u.has(H.id));if(l.length=0,h.length===0)break;let k=I(h);if(k.length===0)break;k.length<h.length&&l.push(...h.slice(k.length)),G(k)}}catch(h){}},b=!0,R=null;R=setInterval(()=>{b&&N()},t);let B=()=>{document.visibilityState==="hidden"&&N()},W=()=>{N()};return document.addEventListener("visibilitychange",B),window.addEventListener("pagehide",W),{push(h){p(h),l.length>=n&&N()},flush:N,destroy(){b=!1,R!==null&&(clearInterval(R),R=null),document.removeEventListener("visibilitychange",B),window.removeEventListener("pagehide",W),N()}}}var ln=200;function Fe(e){return`_snt_goal_retry_${e.slice(0,12)}`}var dn={send:()=>{},flush:()=>{},destroy:()=>{}};function lt(e){var A,I,N;if(typeof window=="undefined")return dn;let t=(A=e.flushIntervalMs)!=null?A:5e3,n=(I=e.maxRetrySize)!=null?I:100,c=(N=e.maxPerFlush)!=null?N:5,d=Fe(e.apiKey),i=[],a=new Set,l=new Set,u=[],o=0,r=0,s=!1,g=b=>{for(a.delete(b.id),l.has(b.id)||(l.add(b.id),u.push(b.id));u.length>ln;){let R=u.shift();R&&l.delete(R)}Oe([b.id],d)},p=b=>{V([b],n,d),!l.has(b.id)&&!a.has(b.id)&&(a.add(b.id),i.push(b)),Date.now()>=o&&(r++,o=Date.now()+Y(r))},m=b=>{let R;try{R=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(W){p(b);return}let B=W=>{var M;let Z=ce(W);if(Z==="retry"){p(b);return}Z==="dropped"&&((M=e.onDrop)==null||M.call(e,b,W.status)),g(b),r=0,o=0};R instanceof Promise?R.then(B).catch(()=>p(b)):B(R)},S=()=>{try{if(s||Date.now()<o)return;let b=0;for(;i.length>0&&b<c&&!(Date.now()<o);){let R=i.shift();a.delete(R.id),!l.has(R.id)&&(b++,m(R))}}catch(b){}},x=Re(d,n);for(let b of x)a.has(b.id)||(a.add(b.id),i.push(b));x.length>0&&V(x,n,d);let E=setInterval(S,t),G=()=>{document.visibilityState==="hidden"&&S()},U=()=>S();return document.addEventListener("visibilitychange",G),window.addEventListener("pagehide",U),{send(b){if(!s&&!(l.has(b.id)||a.has(b.id))){if(Date.now()<o){V([b],n,d),a.add(b.id),i.push(b);return}m(b)}},flush:S,destroy(){clearInterval(E),document.removeEventListener("visibilitychange",G),window.removeEventListener("pagehide",U),S(),s=!0}}}var un=1800*1e3;function Pe(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function dt(e=un,t){let n=new Map,c=`_snt_asgn${ne(t)}_`,d=(o,r)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(r)}`,i=o=>{let r=o.slice(c.length),s=r.indexOf(":");if(s<0)return null;try{return{componentId:decodeURIComponent(r.slice(0,s)),segment:decodeURIComponent(r.slice(s+1))}}catch(g){return null}},a=()=>{try{let o=[];for(let r=0;r<localStorage.length;r++){let s=localStorage.key(r);s!=null&&s.startsWith(c)&&o.push(s)}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 a())try{let r=localStorage.getItem(o);if(!r)continue;let s=JSON.parse(r);if(l(s)){localStorage.removeItem(o);continue}let g=i(o);if(!g)continue;n.set(Pe(g.componentId,g.segment),s)}catch(r){}})(),{get(o,r){let s=n.get(Pe(o,r));return s?l(s)?(n.delete(Pe(o,r)),null):s:null},set(o,r,s){let g=Pe(o,r);n.set(g,s);try{localStorage.setItem(d(o,r),JSON.stringify(s))}catch(p){}},clear(){n.clear();for(let o of a())try{localStorage.removeItem(o)}catch(r){}}}}var ut=["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 Ne(e){return pt(e)!==null}function pt(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ut.find(c=>t.includes(c.toLowerCase())))!=null?n:null}function le(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 de(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(d){}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 ue(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var gt=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function je(e){let t={},n={};try{let c=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([d,i])=>{let a=Array.isArray(i)?i[0]:i;return a===void 0?[]:[[d,a]]});for(let[d,i]of c)d.startsWith("utm_")?d in t||(t[d]=i):gt.includes(d)&&(d in n||(n[d]=i))}catch(c){}return{utmParams:t,clickIds:n}}function pe(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function We(e){let t=pn("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function pn(e,t){var i,a,l,u,o,r,s,g;let n=(a=(i=t==null?void 0:t.userAgent)==null?void 0:i.trim())!=null?a:"",c=(u=(l=t==null?void 0:t.referer)==null?void 0:l.trim())!=null?u:"",d=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(r=t==null?void 0:t.utmParams)!=null?r:{},clickIds:(s=t==null?void 0:t.clickIds)!=null?s:{},deviceClass:n?le(n):"desktop",trafficSource:c?de(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:ue(c),timeOfDay:pe(d),dayOfWeek:(g=["sun","mon","tue","wed","thu","fri","sat"][d.getDay()])!=null?g:"sun",automation:(t==null?void 0:t.webdriver)===!0||Ne(n)}}var ge=require("@sentientui/policy");function Ee(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 fe(e){let t=Ee(e);return(0,ge.slotResultFor)(t,(0,ge.slotBaselineArm)(t))}function ft(e){let t={};for(let n of e)t[n.id]=fe(n);return t}function Le(e){return typeof e=="string"?e:(0,ge.canonicalArm)(e)}var re="_snt_snap:",gn=["low","medium","high"];function me(e){try{let t=localStorage.getItem(re+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"||!gn.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 ye(e,t){try{localStorage.setItem(re+e,JSON.stringify(t))}catch(n){}}function mt(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(re+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 ze=require("@sentientui/policy");var Be=require("@sentientui/policy");var yt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",fn="[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.",ht=!1,De=!1;function mn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function St(e){var o;let t=_e({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(o=t.getSessionId())!=null?o:"local",c=mn(),d=import("@sentientui/core/local").then(r=>{let s=r;return s.LOCAL_ENGINE_AVAILABLE?(ht||(ht=!0,console.info(fn)),s):(De||(De=!0,console.error(yt)),null)}).catch(()=>(De||(De=!0,console.error(yt)),null)),i=null,a={low:.15,medium:.5,high:.85},l=(()=>{var s;if(e.initialPersona)return v({},e.initialPersona);let r=me(e.apiKey||"local");return r?{persona:r.persona,confidence:(s=a[r.band])!=null?s:.15}:null})();function u(r){let s=document.documentElement;s.dataset.sentientPersona===void 0&&(s.dataset.sentientPersona=r.persona,s.dataset.sentientConfidence=(0,Be.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var p,m,S;let s=await d;if(!s)return null;let g=s.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return i=j(v({},g),{layoutOrder:(m=(p=g.layoutOrder)!=null?p:i==null?void 0:i.layoutOrder)!=null?m:null,slots:v(v({},(S=i==null?void 0:i.slots)!=null?S:{}),g.slots)}),ye(e.apiKey||"local",{v:1,persona:i.persona,band:(0,Be.confidenceBand)(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(g),g},getSlotResult(r){var s,g,p;return(p=(g=i==null?void 0:i.slots[r])!=null?g:(s=e.initialSlots)==null?void 0:s[r])!=null?p:null},getPersona(){let r=i!=null?i:l;return r?{persona:r.persona,confidence:r.confidence,band:(0,Be.confidenceBand)(r.confidence)}:null},async assign(r,s){var m;let g=await d;return!g||!s||s.length===0?s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null:{variantId:(m=g.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:s}]}).assignments[r])!=null?m:s[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var yn=["none","sm","md","lg"],hn=["start","center","end","stretch"],Sn=["start","center","end","between"],bn=["sm","md","lg"],vn=["normal","medium","bold"],wn=["default","muted","accent"],En=["primary","secondary","ghost"],xn=["left","center","right"],Cn=["auto","square","landscape","wide"],In=["cover","contain"],kn=[2,3,4],Tn=[2,3,4],An=64,_n=5,Rn=12,On=4,Pn=500;function bt(e,t,n,c){let d=[];{let l=!1,u=[],o=()=>{if(l)return;let r=Date.now();for(u.push(r);u.length>0&&r-u[0]>500;)u.shift();u.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",o),d.push(()=>t.removeEventListener("click",o))}{let i=!1,a=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let u=typeof window!="undefined"?window.getSelection():null,o=u?u.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",a),d.push(()=>document.removeEventListener("copy",a))}{let i=!1,a=!1,l=null,u=()=>{l!==null&&(clearTimeout(l),l=null)},o=()=>{i||!a||(u(),l=setTimeout(()=>{!i&&a&&(i=!0,e("scroll_hesitation"))},3e3))},r=()=>{u(),o()},s=p=>{for(let m of p)a=m.intersectionRatio>.3,a?o():u()},g=new IntersectionObserver(s,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",r,{passive:!0}),d.push(()=>{g.disconnect(),window.removeEventListener("scroll",r),u()})}if((c==null?void 0:c.tabLoss)!==!1){let i=!1,a=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let u=Date.now()-a;u<15e3&&(i=!0,e("tab_loss",{timeOnPage:u}))};document.addEventListener("visibilitychange",l),d.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of d)i()}}var vt="https://api.sentient-ui.com/v1/events",K=new Map,wt=null;function Et(e,t){let n=K.get(e);n&&n.upgrade&&(n.reinit=t)}function Nn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Ln=3;function He(){return Te()}function Me(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Dn(){let e=new WeakMap,t=new Map,n=!1,c=(l,u,o)=>{let r=l.get(u);return o===null?r?!0:(l.set(u,new Set),!1):r?r.has(o)?!0:(r.add(o),!1):(l.set(u,new Set([o])),!1)},d=typeof window!="undefined"&&"event"in window,i=()=>{if(!d)return;let l=window.event;return typeof Event=="function"&&l instanceof Event?l:void 0},a=()=>{if(d){Promise.resolve().then(()=>{n=!1,t.clear()});return}let l=!1,u=()=>{l||(l=!0,n=!1,t.clear())};if(setTimeout(u,0),typeof MessageChannel=="function"){let o=new MessageChannel;o.port1.onmessage=()=>{o.port1.close(),o.port2.close(),u()},o.port2.postMessage(0)}};return{firedBefore(l,u){let o=i();if(o){let s=e.get(o);return s||(s=new Map,e.set(o,s)),c(s,l,u)}let r=c(t,l,u);return!r&&!n&&(n=!0,a()),r}}}var xt=new Set;function Bn(e,t,n){let c=typeof window=="undefined"?null:window.history;if(!c)return()=>{};let d=!1,i,a=()=>{if(d)return;let o=Me();!o||o===i||(i=o,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${o}`))},l=[];for(let o of["pushState","replaceState"]){let r=c[o],s=function(...g){let p=r.apply(this,g);return a(),p};c[o]=s,l.push([o,r,s])}window.addEventListener("popstate",a);let u=Me();return u&&xt.has(`${t}:${u}`)?i=u:a(),()=>{if(!d){d=!0,window.removeEventListener("popstate",a);for(let[o,r,s]of l)c[o]===s&&(c[o]=r)}}}var xe={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 Mn(){try{return je(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Ct(e){return e.replace(/\/events\/?$/,"")}function Ce(){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){var u;if(typeof window=="undefined")return;let t=e!=null?e:wt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=K.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:d,reinit:i}=n;if(!d){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(c.respectDoNotTrack!==!1&&Ce())return;let a=(i!=null?i:Qe)(j(v({},c),{consent:!0}));d(a);let l=(u=K.get(t))==null?void 0:u.dispose;K.set(t,{config:j(v({},c),{consent:!0}),upgrade:null,dispose:l})}function Kn(e){var o;let t=e.preConsentBehavior==="statistical_winner",n=Ct((o=e.ingestUrl)!=null?o:vt),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},d=new Map,i=new Map,a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(r,s,g){if(!t)return Promise.resolve(null);let p=d.get(r);return p?Promise.resolve(p):qe(i,r,async()=>{try{let m=new URLSearchParams({componentId:r});for(let G of s!=null?s:[])m.append("variantIds[]",G);let S=await fetch(`${n}/winner?${m.toString()}`,{headers:c});if(!S.ok)return s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null;let E={variantId:(await S.json()).variantId,assignmentTtlMs:0};return d.set(r,E),E}catch(m){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:r=>a.track(r),goal:((r,s,g,p)=>a.goal(r,s,g,p)),componentGoal:(r,s,g)=>a.componentGoal(r,s,g),identify:r=>a.identify(r),getAssignment:(r,s)=>a.getAssignment(r,s),assign:(r,s,g,p)=>a.assign(r,s,g,p),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 u(r){a=r}return{proxy:l,setInner:u}}function qe(e,t,n){let c=e.get(t);if(c)return c;let d=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,d),d}function Qe(e){var k,H,ee,F,he,q,se,Q,Ve;if(typeof window=="undefined")return xe;wt=e.apiKey||"local";let t=K.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(f){}let n=e.respectDoNotTrack!==!1&&Ce(),c=e.consent===!1||n,d=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!d&&e.localMode!==!1)return K.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),c?xe:St(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."),K.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),xe;let{proxy:f,setInner:y}=Kn(e);return K.set(e.apiKey,{config:e,upgrade:n?null:y}),f}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."),xe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),xe;let i=(k=e.ingestUrl)!=null?k:vt,a=Date.now(),l=_e({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),u=dt(void 0,e.apiKey),o=ct({ingestUrl:i,apiKey:e.apiKey}),r=Ct(i),s={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=new Set,p=lt({url:`${r}/goals`,apiKey:e.apiKey,headers:s,onDrop:(f,y)=>{if(!e.debug){if(g.has(y))return;g.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),f)}}),m=le((H=navigator.userAgent)!=null?H:""),S=window.location.origin,x=de((ee=document.referrer)!=null?ee:"",S),E=(F=e.sessionSegment)!=null?F:`${m}:${x}`,G=new Map,U=new Map,A=new Map,I=null,N=f=>{for(let y of f)A.has(y.id)||A.set(y.id,fe(y))};if(e.initialSlots)for(let[f,y]of Object.entries(e.initialSlots))A.set(f,y);let b=me(e.apiKey);if(b)for(let[f,y]of Object.entries(b.slots))A.has(f)||A.set(f,y);let R={low:.15,medium:.5,high:.85};if(e.initialPersona)I=v({},e.initialPersona);else{let f=document.documentElement.dataset;f.sentientPersona?I={persona:f.sentientPersona,confidence:(q=R[(he=f.sentientConfidence)!=null?he:"low"])!=null?q:.15}:b&&(I={persona:b.persona,confidence:(se=R[b.band])!=null?se:.15})}if(e.initialAssignments)for(let[f,y]of Object.entries(e.initialAssignments))u.set(f,E,{variantId:y,assignedAt:Date.now(),segment:E,confidence:1});let B=Promise.resolve(),W=l.getSessionId();if(W){let f=ue((Q=document.referrer)!=null?Q:""),{utmParams:y,clickIds:C}=Mn(),O=v(v(v({sessionId:W,deviceClass:m,trafficSource:x,referrerDomain:f,utmParams:y,clickIds:C,timeOfDay:pe(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:l.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ne((Ve=navigator.userAgent)!=null?Ve:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),L=async()=>{for(let w=0;;w++){try{let _=await fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(O),headers:s});if(_.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");return}if(_.ok||ce(_)==="dropped")return}catch(_){}if(w>=Ln){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(_=>setTimeout(_,Y(w+1)))}};try{B=L()}catch(w){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let Z=Dn(),M=null,oe=!1,h={goal(f,y={},C=1,O=0){var Se,be,ie,T,z,ke,P;let L=l.getSessionId();if(!L)return;let w=Nn(y)?y:{metadata:y},_=[f,(Se=w.externalId)!=null?Se:"",(be=w.stepIndex)!=null?be:O,(ie=w.weight)!=null?ie:C].join("\0"),$=w.value!==void 0?`${w.value}\0${(T=w.currency)!=null?T:""}`:null;if(Z.firedBefore(_,$)){e.debug&&console.log(`[sentient] goal("${f}") already recorded for this action \u2014 not sent twice`);return}let D=He(),J={sessionId:L,name:f,metadata:(z=w.metadata)!=null?z:{},weight:(ke=w.weight)!=null?ke:C,stepIndex:(P=w.stepIndex)!=null?P:O,goalId:D,value:w.value,currency:w.currency,externalId:w.externalId};e.debug&&console.log("[sentient] goal",J);let te={id:D,body:JSON.stringify(J)};B.then(()=>p.send(te))},componentGoal(f,y,C){var D,J,te;let O=l.getSessionId();if(!O)return;let L=u.get(f,E),w=L?null:(D=A.get(f))!=null?D:null;if(!L&&w===null){e.debug&&console.warn(`[sentient] componentGoal("${f}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let _=L?L.variantId:Le(w),$={id:He(),sessionId:O,projectId:e.apiKey,componentId:f,variantId:_,eventType:"goal_achieved",goalType:y,payload:v({reward:(J=C==null?void 0:C.reward)!=null?J:1,goalValue:C==null?void 0:C.value,currency:C==null?void 0:C.currency},(te=C==null?void 0:C.metadata)!=null?te:{}),timestamp:Date.now(),timeInSession:Date.now()-a,path:Me()};e.debug&&console.log("[sentient] componentGoal",$),B.then(()=>o.push($))},identify(f){let y=l.getSessionId();y&&B.then(()=>{fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:f,ephemeral:l.isEphemeral()}),headers:s}).catch(()=>{})})},track(f){let y=l.getSessionId();if(!y)return;let C=j(v({path:Me()},f),{id:He(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-a});e.debug&&console.log("[sentient] track",C),B.then(()=>o.push(C))},getAssignment(f,y){return u.get(f,y)},async assign(f,y,C,O){let L=l.getSessionId();if(!L)return null;let w=u.get(f,E);if(w&&(y!=null&&y.length||w.content!==void 0)){let _=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:_,content:w.content}}return qe(G,f,async()=>{await B;try{let _={sessionId:L,componentId:f,variantIds:y};O!==void 0?_.agentDataByVariant=O:C!==void 0&&(_.agentData=C);let $=await fetch(`${r}/assign`,{method:"POST",body:JSON.stringify(_),headers:s});if(!$.ok)return null;let D=await $.json();return u.set(f,E,v({variantId:D.variantId,assignedAt:Date.now(),segment:E,confidence:1,content:D.content},D.assignmentTtlMs&&D.assignmentTtlMs>0?{ttlMs:D.assignmentTtlMs}:{})),D}catch(_){return null}})},async decide(f){var w,_;let y=l.getSessionId();if(!y)return null;let C=(w=f.slots)!=null?w:[],O={sessionId:y};f.sections&&f.sections.length>0&&(O.sections=f.sections.map($=>({id:$}))),O.components=(_=f.components)!=null?_:[],C.length>0&&(O.slots=C.map(Ee)),f.slotsFrom==="registry"&&(O.slotsFrom="registry"),f.v&&(O.v=f.v),e.persona&&(O.persona=e.persona);let L=JSON.stringify(O);return qe(U,L,async()=>{var $,D,J,te,Se,be;await B;try{let ie=await fetch(`${r}/decide`,{method:"POST",body:L,headers:s});if(!ie.ok)return N(C),null;let T=await ie.json(),z={};for(let P of C){let X=($=T.slots)==null?void 0:$[P.id];if(X!==void 0){z[P.id]=X,A.set(P.id,X);continue}let Ze=A.get(P.id);if(Ze!==void 0)z[P.id]=Ze;else{let et=fe(P);z[P.id]=et,A.set(P.id,et)}}if(T.slots)for(let[P,X]of Object.entries(T.slots))P in z||(z[P]=X,A.set(P,X));let ke=I!=null&&I.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&ke)?I={persona:T.persona,confidence:(D=T.confidence)!=null?D:0}:I||(I={persona:"unknown",confidence:0});for(let[P,X]of Object.entries((J=T.assignments)!=null?J:{}))u.set(P,E,{variantId:X,assignedAt:Date.now(),segment:E,confidence:1});return ye(e.apiKey,v(v({v:1,persona:I.persona,band:(0,ze.confidenceBand)(I.confidence),slots:Object.fromEntries(A),layoutOrder:(te=T.layoutOrder)!=null?te:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.palette?{palette:T.palette}:{})),v(v(v(v({layoutOrder:(Se=T.layoutOrder)!=null?Se:null,assignments:(be=T.assignments)!=null?be:{},slots:z,persona:I.persona,confidence:I.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{}),T.palette?{palette:T.palette}:{})}catch(ie){return N(C),null}})},getSlotResult(f){var y;return(y=A.get(f))!=null?y:null},getPersona(){return I?{persona:I.persona,confidence:I.confidence,band:(0,ze.confidenceBand)(I.confidence)}:null},async fetchWeights(){var f;try{let y=await fetch(`${r}/weights`,{headers:s});return y.ok?(f=(await y.json()).components)!=null?f:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var f;M==null||M(),oe=!0,o.destroy(),p.destroy(),((f=K.get(e.apiKey))==null?void 0:f.dispose)===h.dispose&&K.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var f;M==null||M(),oe=!0,o.destroy(),p.destroy(),l.destroy(),u.clear(),((f=K.get(e.apiKey))==null?void 0:f.dispose)===h.dispose&&K.delete(e.apiKey);try{localStorage.removeItem(re+e.apiKey),localStorage.removeItem(Ue(e.apiKey)),localStorage.removeItem(Fe(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(K.set(e.apiKey,{config:e,upgrade:null,dispose:h.dispose}),M=Bn(h,e.apiKey,f=>{B.then(()=>{oe||xt.add(f)})}),e.debug){let f=window;f.__sentient&&(f.__sentient.client=h)}return h}var kt="_snt_graph_edges",Gn={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function $n(e){var t;return(t=Gn[e])!=null?t:[]}function Un(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function Fn(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var jn=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Wn(e){return jn.has(e)?e:"generic"}function Je(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function Hn(e,t,n){let c=`${e}:${t}:${n.join(",")}`,d=5381;for(let i=0;i<c.length;i++)d=(d<<5)+d+c.charCodeAt(i)&4294967295;return(d>>>0).toString(16).padStart(8,"0")}function Tt(e){let t=new Map,n=new Map,c=`_snt_graph_nodes${ne(e==null?void 0:e.apiKey)}`,d=()=>{typeof window!="undefined"&&Fn(c,[...t.values()])};if(typeof window!="undefined"){let i=Un(c,[]);for(let a of i)t.set(a.componentId,a);try{localStorage.removeItem(kt)}catch(a){}}return{addPageNode(i){t.set(i.componentId,i),d()},addStructuralEdge(i){let a=`${i.fromComponentId}->${i.toComponentId}`;n.set(a,i)},syncOnce(){var a,l;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let i=[...t.values()];if(i.length!==0)try{let u=new Map;for(let p of i){let m=(a=u.get(p.semanticType))!=null?a:[];m.push(p),u.set(p.semanticType,m)}let o=[],r=new Set;for(let p of i)for(let m of $n(p.semanticType)){let S=(l=u.get(m))!=null?l:[];for(let x of S){if(x.componentId===p.componentId)continue;let E=`semantic:${p.componentId}->${x.componentId}`;r.has(E)||(r.add(E),o.push({fromComponentId:p.componentId,toComponentId:x.componentId,type:"semantic",weight:.4,confidence:.9}))}}let s=new Set(i.map(p=>p.componentId));for(let p of n.values()){if(!s.has(p.fromComponentId)||!s.has(p.toComponentId))continue;let m=`structural:${p.fromComponentId}->${p.toComponentId}`;r.has(m)||(r.add(m),o.push({fromComponentId:p.fromComponentId,toComponentId:p.toComponentId,type:"structural",weight:p.weight,confidence:1}))}let g=j(v(v({pageUrl:Je(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:i.map(p=>{let m=Wn(p.semanticType);return{componentId:p.componentId,semanticType:m,answers:p.answers,contentHash:Hn(p.componentId,m,p.answers),prominenceScore:p.prominenceScore,depthInPage:p.depth}}),edges:o});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:v({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(g)}).catch(()=>{})}catch(u){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},destroy(){if(typeof window!="undefined")try{localStorage.removeItem(c),localStorage.removeItem(kt)}catch(i){}}}}var zn=["data-testid","data-test","data-id","data-name","data-cy"];function Xe(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function qn(e){return{tag:e.tagName.toLowerCase(),text:Xe(e).slice(0,40)}}function At(e){return e.replace(/["\\\]]/g,"\\$&")}function Ie(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function _t(e,t){var a;let n=e.tagName.toLowerCase();if(!n)return null;let c=((a=e.getAttribute("class"))!=null?a:"").split(/\s+/).filter(l=>/^[a-zA-Z][\w-]*$/.test(l)),d=[n,...c.map(l=>`${n}.${l}`)];for(let l of d)if(Ie(t,l))return l;let i=e.parentElement;if(i&&i!==t){let l=_t(i,t);if(l){for(let s of d){let g=`${l} > ${s}`;if(Ie(t,g))return g}let u=Array.from(i.children).filter(s=>s.tagName.toLowerCase()===n),o=u.indexOf(e),r=u.some(s=>s!==e&&Xe(s)!==Xe(e));if(o>=0&&r){let s=`${l} > ${n}:nth-of-type(${o+1})`;if(Ie(t,s))return s}}}return null}function Ke(e,t){let n=qn(e),c=e.getAttribute("id");if(c&&Ie(t,`#${At(c)}`))return{v:1,id:c,fingerprint:n};for(let i of zn){let a=e.getAttribute(i);if(a&&Ie(t,`[${i}="${At(a)}"]`))return{v:1,dataAttr:{name:i,value:a},fingerprint:n}}let d=_t(e,t);return d?{v:1,selector:d,fingerprint:n}:null}var Ot=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Qn={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Jn(e){let t=e.ariaRole?Qn[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function Xn(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Yn=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],Vn=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],Rt={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Zn(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function er(e){var d,i;let t=Jn(e);if(t)return{type:(d=Rt[t])!=null?d:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[a,l]of Yn)if(l.test(n))return{type:a,strength:"strong"};for(let[a,l]of Vn)if(l.test(e.bodyText))return{type:a,strength:"strong"};let c=Xn(e);return{type:(i=Rt[c])!=null?i:"generic",strength:"weak"}}function tr(e){var c,d;let t=((c=e.textContent)!=null?c:"").replace(/\s+/g," ").trim(),n=e.getAttribute("role");return v({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((d=e.className)!=null?d:"")}`,headingText:Zn(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function Pt(e){return er(tr(e)).type}var nr=new Set(["SECTION","ARTICLE","MAIN","DIV","ASIDE"]),rr="h1, h2, h3",or="[data-sentient-id], section[aria-label], article[aria-label], main[aria-label], aside[aria-label]",Nt=30,sr=1500,ir={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function Lt(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function ar(e){var t,n,c;try{let d=e;for(let i of Object.keys(d)){if(!i.startsWith("__reactFiber")&&!i.startsWith("__reactInternalInstance"))continue;let a=d[i],l=(c=(t=a==null?void 0:a.type)==null?void 0:t.displayName)!=null?c:(n=a==null?void 0:a.type)==null?void 0:n.name;if(l&&l.length>1)return l}}catch(d){}}function cr(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var Dt=new Set(Ot);function lr(e){let t=e.getAttribute("data-sentient-type");if(t&&Dt.has(t))return t;let n=e.getAttribute("role");return n&&Dt.has(n)?n:Pt(e)}function dr(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 ur(e){let t=[],n=e;for(;n;){let c=n.parentElement;if(!c){t.push(n.tagName.toLowerCase());break}let d=Array.prototype.indexOf.call(c.children,n);t.push(`${n.tagName.toLowerCase()}[${d}]`),n=c}return t.reverse().join("/")}function pr(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${dr(ur(e))}`}function gr(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Ye(e,t){var c,d,i,a;let n=e.querySelector(rr);return{componentId:pr(e),semanticType:lr(e),ariaLabel:(c=e.getAttribute("aria-label"))!=null?c:void 0,headingText:(i=(d=n==null?void 0:n.textContent)==null?void 0:d.trim())!=null?i:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:gr(e),reactComponentName:ar(e),dataAttributes:cr(e),locator:(a=Ke(e,e.ownerDocument))!=null?a:void 0}}function Bt(e){var i;let t=[],n=new Set,c="__root__",d=new Map;for(let[a,l]of e){let u=a.parentElement,o=c;for(;u;){if(e.has(u)){o=e.get(u);let s=e.get(a),g=`${o}->${s}`;!n.has(g)&&o!==s&&(n.add(g),t.push({fromComponentId:o,toComponentId:s,weight:.6}));break}u=u.parentElement}let r=(i=d.get(o))!=null?i:[];r.push(a),d.set(o,r)}for(let a of d.values()){if(a.length<2)continue;let l=a.length>Nt?a.slice(0,Nt):a;for(let u=0;u<l.length;u++)for(let o=u+1;o<l.length;o++){if(t.length>=sr)return t;let r=e.get(l[u]),s=e.get(l[o]);if(r===s)continue;let g=`${r}->${s}::sib`,p=`${s}->${r}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:r,toComponentId:s,weight:.3})),n.has(p)||(n.add(p),t.push({fromComponentId:s,toComponentId:r,weight:.3}))}}return t}function fr(e){let t=[],n=new Set,c=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(a=>{if(a instanceof Element&&!n.has(a)){n.add(a);let l=Ye(a,e);t.push(l),c.set(a,l.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(a=>{if(!(a instanceof Element)||n.has(a))return;let l=a.hasAttribute("aria-label"),u=a.hasAttribute("data-sentient-id");if(!l&&!u)return;n.add(a);let o=Ye(a,e);t.push(o),c.set(a,o.componentId)}),{nodes:t,edges:Bt(c),elementToId:c}}function Mt(){if(typeof window=="undefined")return ir;let e=null,t=0,n=null,c=new Map,d=u=>{try{let o=window.getComputedStyle(u),r=parseFloat(o.fontSize)||12,s=parseFloat(o.zIndex)||0,g=u.getBoundingClientRect(),p=Math.max(g.top,0),m=window.innerHeight||1,S=1/(p/m+1),x=Lt(r,12,48)*.4+S*.4+Lt(s,0,100)*.2;return Math.max(0,Math.min(1,x))}catch(o){return .5}};return{scan:()=>new Promise(u=>{let o=()=>{let{nodes:r,edges:s,elementToId:g}=fr(d);c.clear();for(let[p,m]of g)c.set(p,m);u({nodes:r,edges:s,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(o,{timeout:100}):o()}catch(r){o()}}),observe:u=>{n=u;try{e=new MutationObserver(o=>{let r=[],s=new Set;for(let p of o)p.type==="childList"&&p.addedNodes.forEach(m=>{if(!(m instanceof Element))return;let S=[];nr.has(m.tagName)&&(m.hasAttribute("data-sentient-id")||m.hasAttribute("aria-label"))&&S.push(m);try{m.querySelectorAll(or).forEach(x=>S.push(x))}catch(x){}for(let x of S){if(c.has(x))continue;let E=Ye(x,d);r.push(E),s.add(E.componentId),c.set(x,E.componentId)}});if(r.length===0||!n)return;for(let p of[...c.keys()])p.isConnected||c.delete(p);let g=Bt(c).filter(p=>s.has(p.fromComponentId)||s.has(p.toComponentId));n({nodes:r,edges:g,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(o){}},getProminenceScore:d,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(u){}t=0,n=null,c.clear()}}}var mr="https://api.sentient-ui.com/v1/events";function yr(e){var n;let t=c=>{try{let d=document.cookie.match(new RegExp(`(?:^|; )${c}=([^;]*)`));return d?decodeURIComponent(d[1]):void 0}catch(d){return}};return(n=e?t(ae(e)):void 0)!=null?n:t(we)}var Ge=new Map;function Kt(e){var p;let t=Qe(e),n=e.respectDoNotTrack!==!1&&Ce(),c=e.consent===!1||n,d=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_"),i=e.localMode===!0||!d;if(!e.graph||i||typeof window=="undefined")return t;if(c)return n||Et(e.apiKey,m=>Kt(m)),t;let a=Ge.get(e.apiKey);if(a)try{a()}catch(m){}let l=Mt(),u=(p=e.ingestUrl)!=null?p:mr,o=Tt({syncUrl:u.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:yr(e.apiKey)});l.scan().then(m=>{for(let S of m.nodes)o.addPageNode({id:S.componentId,componentId:S.componentId,semanticType:S.semanticType,answers:e.captureDomText&&S.headingText?[S.headingText]:[],prominenceScore:S.prominenceScore,depth:S.depth});for(let S of m.edges)o.addStructuralEdge(S);o.syncOnce()});let r=null,s=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,o.syncOnce()},500)};l.observe(m=>{for(let S of m.nodes)o.addPageNode({id:S.componentId,componentId:S.componentId,semanticType:S.semanticType,answers:e.captureDomText&&S.headingText?[S.headingText]:[],prominenceScore:S.prominenceScore,depth:S.depth});for(let S of m.edges)o.addStructuralEdge(S);s()});let g=()=>{r!==null&&(clearTimeout(r),r=null),l.destroy(),o.destroy(),Ge.get(e.apiKey)===g&&Ge.delete(e.apiKey)};return Ge.set(e.apiKey,g),j(v({},t),{getGraph:()=>o.snapshot(),dispose:()=>{g(),t.dispose()},destroy:()=>{g(),t.destroy()}})}0&&(module.exports={BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,LEGACY_SESSION_COOKIE_NAME,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,SNAPSHOT_STORAGE_KEY_PREFIX,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,locatorFromElement,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,sanitizePageUrl,sessionCookieName,toWireSlot,writeSnapshot});
1
+ "use strict";var Gt=Object.create;var ve=Object.defineProperty,$t=Object.defineProperties,Ut=Object.getOwnPropertyDescriptor,Ft=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertyNames,tt=Object.getOwnPropertySymbols,Wt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable;var nt=(e,t,n)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,v=(e,t)=>{for(var n in t||(t={}))rt.call(t,n)&&nt(e,n,t[n]);if(tt)for(var n of tt(t))Ht.call(t,n)&&nt(e,n,t[n]);return e},j=(e,t)=>$t(e,Ft(t));var zt=(e,t)=>{for(var n in t)ve(e,n,{get:t[n],enumerable:!0})},ot=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of jt(t))!rt.call(e,d)&&d!==n&&ve(e,d,{get:()=>t[d],enumerable:!(c=Ut(t,d))||c.enumerable});return e};var qt=(e,t,n)=>(n=e!=null?Gt(Wt(e)):{},ot(t||!e||!e.__esModule?ve(n,"default",{value:e,enumerable:!0}):n,e)),Qt=e=>ot(ve({},"__esModule",{value:!0}),e);var hr={};zt(hr,{BLOCK_ALIGNS:()=>hn,BLOCK_EMPHASES:()=>En,BLOCK_FITS:()=>In,BLOCK_GAPS:()=>yn,BLOCK_GRID_COLUMNS:()=>kn,BLOCK_HEADING_LEVELS:()=>Tn,BLOCK_JUSTIFIES:()=>Sn,BLOCK_RATIOS:()=>Cn,BLOCK_SIZES:()=>bn,BLOCK_TEXT_ALIGNS:()=>xn,BLOCK_TONES:()=>wn,BLOCK_WEIGHTS:()=>vn,LEGACY_SESSION_COOKIE_NAME:()=>we,MAX_BLOCK_ARMS:()=>On,MAX_BLOCK_CHILDREN:()=>Rn,MAX_BLOCK_DEPTH:()=>_n,MAX_BLOCK_NODES:()=>An,MAX_BLOCK_TEXT_LEN:()=>Pn,SNAPSHOT_STORAGE_KEY_PREFIX:()=>re,armOfResult:()=>Le,attachMicroSignalDetectors:()=>bt,baselineResultFor:()=>fe,baselineSlots:()=>ft,deriveSessionSegment:()=>We,detectDeviceClass:()=>le,detectTimeOfDay:()=>pe,detectTrafficSource:()=>de,grantConsent:()=>It,init:()=>Kt,isDoNotTrackEnabled:()=>Ce,locatorFromElement:()=>Ke,readSnapshot:()=>me,referrerDomainFromReferer:()=>ue,renderPrePaintScript:()=>mt,sanitizePageUrl:()=>Je,sessionCookieName:()=>ae,toWireSlot:()=>Ee,writeSnapshot:()=>ye});module.exports=Qt(hr);function Te(){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 ne(e){return e?`_${e.slice(0,12)}`:""}var we="_snt_uid";function ae(e){return`${we}${ne(e)}`}var Jt="_snt_uid",Xt=365,Ae="_snt_uid";function Yt(){return Te()}function st(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]):null}catch(t){return null}}function Vt(e,t,n){try{document.cookie=`${e}=${encodeURIComponent(t)}; max-age=${n}; SameSite=strict; path=/`}catch(c){}}function $e(e){try{return localStorage.getItem(e)}catch(t){return null}}function it(e,t){try{return localStorage.setItem(e,t),!0}catch(n){return!1}}function at(e){try{return sessionStorage.getItem(e)}catch(t){return null}}function Zt(e,t){try{return sessionStorage.setItem(e,t),!0}catch(n){return!1}}function en(e){try{sessionStorage.removeItem(e)}catch(t){}}function tn(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 nn(e){try{localStorage.removeItem(e)}catch(t){}}function rn(e){try{document.cookie=`${e}=; max-age=0; SameSite=strict; path=/`}catch(t){}}var on={getSessionId:()=>null,isEphemeral:()=>!1,destroy:()=>{}};function _e(e){var m,S,x,E,G,U,A;if(typeof window=="undefined")return on;let t=ne(e==null?void 0:e.apiKey),n=(m=e==null?void 0:e.cookieName)!=null?m:ae(e==null?void 0:e.apiKey),c=`${Ae}${t}`,d=`${Ae}_tomb${t}`,a=((S=e==null?void 0:e.cookieTTLDays)!=null?S:Xt)*24*60*60,l=I=>I&&I.length>0?I:null,u=()=>{var I,N;return t&&!(e!=null&&e.cookieName)&&$e(d)===null?(N=(I=l(st(Jt)))!=null?I:l($e(Ae)))!=null?N:l(at(Ae)):null},o=(A=(U=(G=(E=(x=l(st(n)))!=null?x:l($e(c)))!=null?E:l(at(c)))!=null?G:u())!=null?U:l(e==null?void 0:e.ssrSessionId))!=null?A:Yt();Vt(n,o,a);let r=it(c,o),s=tn(n),g=r?!1:Zt(c,o),p=!r&&!s&&!g;return{getSessionId:()=>o,isEphemeral:()=>p,destroy:()=>{o=null,rn(n),nn(c),en(c),t&&!(e!=null&&e.cookieName)&&it(d,"1")}}}function Y(e){return Math.min(6e4,1e3*2**Math.min(e,6))}function ce(e){if(e.ok===!0)return"delivered";let{status:t}=e;return typeof t!="number"?"retry":t>=200&&t<300?"delivered":t>=400&&t<500&&t!==429?"dropped":"retry"}function Re(e,t){try{let n=localStorage.getItem(e);if(!n)return[];let c=JSON.parse(n);return Array.isArray(c)?(localStorage.removeItem(e),c.slice(-t)):[]}catch(n){return[]}}function V(e,t,n){try{let c=(()=>{try{let i=localStorage.getItem(n);if(!i)return[];let a=JSON.parse(i);return Array.isArray(a)?a:[]}catch(i){return[]}})(),d=new Map;for(let i of c)d.set(i.id,i);for(let i of e)d.set(i.id,i);localStorage.setItem(n,JSON.stringify([...d.values()].slice(-t)))}catch(c){}}function Oe(e,t){try{let n=localStorage.getItem(t);if(!n)return;let c=JSON.parse(n);if(!Array.isArray(c))return;let d=new Set(e),i=c.filter(a=>!d.has(a.id));if(i.length===c.length)return;i.length===0?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(i))}catch(n){}}var sn=500,an=56*1024;function Ue(e){return`_snt_retry_${e.slice(0,12)}`}var cn={push:()=>{},flush:()=>{},destroy:()=>{}};function ct(e){var Z,M,oe;if(typeof window=="undefined")return cn;let t=(Z=e.flushIntervalMs)!=null?Z:5e3,n=(M=e.maxBatchSize)!=null?M:20,c=(oe=e.maxRetrySize)!=null?oe:100,d=e.ingestUrl,i=e.apiKey,a=Ue(i),l=[],u=new Set,o=[],r=h=>{for(let k of h)s.delete(k),!u.has(k)&&(u.add(k),o.push(k));for(;o.length>sn;){let k=o.shift();k&&u.delete(k)}Oe(h,a)},s=new Set,g=()=>{for(;l.length>c;){let h=l.shift();h&&s.delete(h.id)}},p=h=>{u.has(h.id)||s.has(h.id)||(s.add(h.id),l.push(h),g())},m=h=>{for(let k of h)u.has(k.id)||(s.add(k.id),l.push(k));g()},S=Re(a,c);for(let h of S)p(h);let x=0,E=0,G=(h,k=!0)=>{if(h.length===0)return;let H=JSON.stringify(h),ee=h.map(q=>q.id),F;try{F=fetch(d,{method:"POST",keepalive:!0,body:H,headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`}})}catch(q){V(h,c,a),m(h),E++,x=Date.now()+Y(E);return}let he=q=>{if(ce(q)!=="retry"){if(!q.ok&&k){let se=h.filter(Q=>Q.eventType!=="pageview");if(se.length>0&&se.length<h.length){r(h.filter(Q=>Q.eventType==="pageview").map(Q=>Q.id)),G(se,!1);return}}r(ee),E=0,x=0;return}V(h,c,a),m(h),E++,x=Date.now()+Y(E)};F instanceof Promise?F.then(he).catch(()=>{V(h,c,a),m(h),E++,x=Date.now()+Y(E)}):he(F)},U=typeof TextEncoder!="undefined"?new TextEncoder:null,A=h=>U?U.encode(h).length:h.length,I=h=>{let k=[],H=2;for(let ee of h){let F=A(JSON.stringify(ee))+1;if(k.length>0&&H+F>an||k.length>=n)break;k.push(ee),H+=F}return k},N=()=>{try{if(Date.now()<x)return;for(;l.length>0&&!(Date.now()<x);){let h=l.filter(H=>!u.has(H.id));if(l.length=0,h.length===0)break;let k=I(h);if(k.length===0)break;k.length<h.length&&l.push(...h.slice(k.length)),G(k)}}catch(h){}},b=!0,R=null;R=setInterval(()=>{b&&N()},t);let B=()=>{document.visibilityState==="hidden"&&N()},W=()=>{N()};return document.addEventListener("visibilitychange",B),window.addEventListener("pagehide",W),{push(h){p(h),l.length>=n&&N()},flush:N,destroy(){b=!1,R!==null&&(clearInterval(R),R=null),document.removeEventListener("visibilitychange",B),window.removeEventListener("pagehide",W),N()}}}var ln=200;function Fe(e){return`_snt_goal_retry_${e.slice(0,12)}`}var dn={send:()=>{},flush:()=>{},destroy:()=>{}};function lt(e){var A,I,N;if(typeof window=="undefined")return dn;let t=(A=e.flushIntervalMs)!=null?A:5e3,n=(I=e.maxRetrySize)!=null?I:100,c=(N=e.maxPerFlush)!=null?N:5,d=Fe(e.apiKey),i=[],a=new Set,l=new Set,u=[],o=0,r=0,s=!1,g=b=>{for(a.delete(b.id),l.has(b.id)||(l.add(b.id),u.push(b.id));u.length>ln;){let R=u.shift();R&&l.delete(R)}Oe([b.id],d)},p=b=>{V([b],n,d),!l.has(b.id)&&!a.has(b.id)&&(a.add(b.id),i.push(b)),Date.now()>=o&&(r++,o=Date.now()+Y(r))},m=b=>{let R;try{R=fetch(e.url,{method:"POST",keepalive:!0,body:b.body,headers:e.headers})}catch(W){p(b);return}let B=W=>{var M;let Z=ce(W);if(Z==="retry"){p(b);return}Z==="dropped"&&((M=e.onDrop)==null||M.call(e,b,W.status)),g(b),r=0,o=0};R instanceof Promise?R.then(B).catch(()=>p(b)):B(R)},S=()=>{try{if(s||Date.now()<o)return;let b=0;for(;i.length>0&&b<c&&!(Date.now()<o);){let R=i.shift();a.delete(R.id),!l.has(R.id)&&(b++,m(R))}}catch(b){}},x=Re(d,n);for(let b of x)a.has(b.id)||(a.add(b.id),i.push(b));x.length>0&&V(x,n,d);let E=setInterval(S,t),G=()=>{document.visibilityState==="hidden"&&S()},U=()=>S();return document.addEventListener("visibilitychange",G),window.addEventListener("pagehide",U),{send(b){if(!s&&!(l.has(b.id)||a.has(b.id))){if(Date.now()<o){V([b],n,d),a.add(b.id),i.push(b);return}m(b)}},flush:S,destroy(){clearInterval(E),document.removeEventListener("visibilitychange",G),window.removeEventListener("pagehide",U),S(),s=!0}}}var un=1800*1e3;function Pe(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function dt(e=un,t){let n=new Map,c=`_snt_asgn${ne(t)}_`,d=(o,r)=>`${c}${encodeURIComponent(o)}:${encodeURIComponent(r)}`,i=o=>{let r=o.slice(c.length),s=r.indexOf(":");if(s<0)return null;try{return{componentId:decodeURIComponent(r.slice(0,s)),segment:decodeURIComponent(r.slice(s+1))}}catch(g){return null}},a=()=>{try{let o=[];for(let r=0;r<localStorage.length;r++){let s=localStorage.key(r);s!=null&&s.startsWith(c)&&o.push(s)}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 a())try{let r=localStorage.getItem(o);if(!r)continue;let s=JSON.parse(r);if(l(s)){localStorage.removeItem(o);continue}let g=i(o);if(!g)continue;n.set(Pe(g.componentId,g.segment),s)}catch(r){}})(),{get(o,r){let s=n.get(Pe(o,r));return s?l(s)?(n.delete(Pe(o,r)),null):s:null},set(o,r,s){let g=Pe(o,r);n.set(g,s);try{localStorage.setItem(d(o,r),JSON.stringify(s))}catch(p){}},clear(){n.clear();for(let o of a())try{localStorage.removeItem(o)}catch(r){}}}}var ut=["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 Ne(e){return pt(e)!==null}function pt(e){var n;if(!e)return null;let t=e.toLowerCase();return(n=ut.find(c=>t.includes(c.toLowerCase())))!=null?n:null}function le(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 de(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(d){}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 ue(e){if(!e)return null;try{return new URL(e).hostname}catch(t){return null}}var gt=["gclid","gbraid","wbraid","fbclid","ttclid","msclkid","twclid","li_fat_id"];function je(e){let t={},n={};try{let c=typeof e=="string"||e instanceof URLSearchParams?new URLSearchParams(e):Object.entries(e).flatMap(([d,i])=>{let a=Array.isArray(i)?i[0]:i;return a===void 0?[]:[[d,a]]});for(let[d,i]of c)d.startsWith("utm_")?d in t||(t[d]=i):gt.includes(d)&&(d in n||(n[d]=i))}catch(c){}return{utmParams:t,clickIds:n}}function pe(e){let t=e.getHours();return t<6?"night":t<12?"morning":t<18?"afternoon":"evening"}function We(e){let t=pn("__segment__",e);return`${t.deviceClass}:${t.trafficSource}`}function pn(e,t){var i,a,l,u,o,r,s,g;let n=(a=(i=t==null?void 0:t.userAgent)==null?void 0:i.trim())!=null?a:"",c=(u=(l=t==null?void 0:t.referer)==null?void 0:l.trim())!=null?u:"",d=(o=t==null?void 0:t.now)!=null?o:new Date;return{sessionId:e,ephemeral:!1,utmParams:(r=t==null?void 0:t.utmParams)!=null?r:{},clickIds:(s=t==null?void 0:t.clickIds)!=null?s:{},deviceClass:n?le(n):"desktop",trafficSource:c?de(c,t==null?void 0:t.appOrigin):"direct",referrerDomain:ue(c),timeOfDay:pe(d),dayOfWeek:(g=["sun","mon","tue","wed","thu","fri","sat"][d.getDay()])!=null?g:"sun",automation:(t==null?void 0:t.webdriver)===!0||Ne(n)}}var ge=require("@sentientui/policy");function Ee(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 fe(e){let t=Ee(e);return(0,ge.slotResultFor)(t,(0,ge.slotBaselineArm)(t))}function ft(e){let t={};for(let n of e)t[n.id]=fe(n);return t}function Le(e){return typeof e=="string"?e:(0,ge.canonicalArm)(e)}var re="_snt_snap:",gn=["low","medium","high"];function me(e){try{let t=localStorage.getItem(re+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"||!gn.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 ye(e,t){try{localStorage.setItem(re+e,JSON.stringify(t))}catch(n){}}function mt(e){return"(function(){try{var r=localStorage.getItem("+JSON.stringify(re+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 ze=require("@sentientui/policy");var Be=require("@sentientui/policy");var yt="[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.",fn="[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.",ht=!1,De=!1;function mn(){var e;try{return(e=new URLSearchParams(window.location.search).get("sentient_persona"))!=null?e:void 0}catch(t){return}}function St(e){var o;let t=_e({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),n=(o=t.getSessionId())!=null?o:"local",c=mn(),d=import("@sentientui/core/local").then(r=>{let s=r;return s.LOCAL_ENGINE_AVAILABLE?(ht||(ht=!0,console.info(fn)),s):(De||(De=!0,console.error(yt)),null)}).catch(()=>(De||(De=!0,console.error(yt)),null)),i=null,a={low:.15,medium:.5,high:.85},l=(()=>{var s;if(e.initialPersona)return v({},e.initialPersona);let r=me(e.apiKey||"local");return r?{persona:r.persona,confidence:(s=a[r.band])!=null?s:.15}:null})();function u(r){let s=document.documentElement;s.dataset.sentientPersona===void 0&&(s.dataset.sentientPersona=r.persona,s.dataset.sentientConfidence=(0,Be.confidenceBand)(r.confidence))}return{isLocal:!0,async decide(r){var p,m,S;let s=await d;if(!s)return null;let g=s.createLocalEngine({sessionId:n,forcedPersona:c}).decide(r);return i=j(v({},g),{layoutOrder:(m=(p=g.layoutOrder)!=null?p:i==null?void 0:i.layoutOrder)!=null?m:null,slots:v(v({},(S=i==null?void 0:i.slots)!=null?S:{}),g.slots)}),ye(e.apiKey||"local",{v:1,persona:i.persona,band:(0,Be.confidenceBand)(i.confidence),slots:i.slots,layoutOrder:i.layoutOrder,savedAt:Date.now()}),u(g),g},getSlotResult(r){var s,g,p;return(p=(g=i==null?void 0:i.slots[r])!=null?g:(s=e.initialSlots)==null?void 0:s[r])!=null?p:null},getPersona(){let r=i!=null?i:l;return r?{persona:r.persona,confidence:r.confidence,band:(0,Be.confidenceBand)(r.confidence)}:null},async assign(r,s){var m;let g=await d;return!g||!s||s.length===0?s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null:{variantId:(m=g.createLocalEngine({sessionId:n,forcedPersona:c}).decide({components:[{id:r,variantIds:s}]}).assignments[r])!=null?m:s[0],assignmentTtlMs:0}},track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),getGraph:()=>({pageNodes:[],capturedAt:0}),dispose:()=>{},destroy:()=>t.destroy()}}var yn=["none","sm","md","lg"],hn=["start","center","end","stretch"],Sn=["start","center","end","between"],bn=["sm","md","lg"],vn=["normal","medium","bold"],wn=["default","muted","accent"],En=["primary","secondary","ghost"],xn=["left","center","right"],Cn=["auto","square","landscape","wide"],In=["cover","contain"],kn=[2,3,4],Tn=[2,3,4],An=64,_n=5,Rn=12,On=4,Pn=500;function bt(e,t,n,c){let d=[];{let l=!1,u=[],o=()=>{if(l)return;let r=Date.now();for(u.push(r);u.length>0&&r-u[0]>500;)u.shift();u.length>=3&&(l=!0,e("rage_click"))};t.addEventListener("click",o),d.push(()=>t.removeEventListener("click",o))}{let i=!1,a=l=>{if(i||!(l.target instanceof Node)||!t.contains(l.target)&&t!==l.target)return;i=!0;let u=typeof window!="undefined"?window.getSelection():null,o=u?u.toString().length:0;e("text_copy",{selectionLength:o})};document.addEventListener("copy",a),d.push(()=>document.removeEventListener("copy",a))}{let i=!1,a=!1,l=null,u=()=>{l!==null&&(clearTimeout(l),l=null)},o=()=>{i||!a||(u(),l=setTimeout(()=>{!i&&a&&(i=!0,e("scroll_hesitation"))},3e3))},r=()=>{u(),o()},s=p=>{for(let m of p)a=m.intersectionRatio>.3,a?o():u()},g=new IntersectionObserver(s,{threshold:[.3]});g.observe(t),window.addEventListener("scroll",r,{passive:!0}),d.push(()=>{g.disconnect(),window.removeEventListener("scroll",r),u()})}if((c==null?void 0:c.tabLoss)!==!1){let i=!1,a=n!=null?n:Date.now(),l=()=>{if(i||document.visibilityState!=="hidden")return;let u=Date.now()-a;u<15e3&&(i=!0,e("tab_loss",{timeOnPage:u}))};document.addEventListener("visibilitychange",l),d.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let i of d)i()}}var vt="https://api.sentient-ui.com/v1/events",K=new Map,wt=null;function Et(e,t){let n=K.get(e);n&&n.upgrade&&(n.reinit=t)}function Nn(e){return"value"in e||"currency"in e||"externalId"in e||"metadata"in e||"weight"in e||"stepIndex"in e}var Ln=3;function He(){return Te()}function Me(){var e;if(typeof window!="undefined")return((e=window.location)==null?void 0:e.pathname)||void 0}function Dn(){let e=new WeakMap,t=new Map,n=!1,c=(l,u,o)=>{let r=l.get(u);return o===null?r?!0:(l.set(u,new Set),!1):r?r.has(o)?!0:(r.add(o),!1):(l.set(u,new Set([o])),!1)},d=typeof window!="undefined"&&"event"in window,i=()=>{if(!d)return;let l=window.event;return typeof Event=="function"&&l instanceof Event?l:void 0},a=()=>{if(d){Promise.resolve().then(()=>{n=!1,t.clear()});return}let l=!1,u=()=>{l||(l=!0,n=!1,t.clear())};if(setTimeout(u,0),typeof MessageChannel=="function"){let o=new MessageChannel;o.port1.onmessage=()=>{o.port1.close(),o.port2.close(),u()},o.port2.postMessage(0)}};return{firedBefore(l,u){let o=i();if(o){let s=e.get(o);return s||(s=new Map,e.set(o,s)),c(s,l,u)}let r=c(t,l,u);return!r&&!n&&(n=!0,a()),r}}}var xt=new Set;function Bn(e,t,n){let c=typeof window=="undefined"?null:window.history;if(!c)return()=>{};let d=!1,i,a=()=>{if(d)return;let o=Me();!o||o===i||(i=o,e.track({projectId:t,componentId:"__page__",eventType:"pageview",payload:{}}),n(`${t}:${o}`))},l=[];for(let o of["pushState","replaceState"]){let r=c[o],s=function(...g){let p=r.apply(this,g);return a(),p};c[o]=s,l.push([o,r,s])}window.addEventListener("popstate",a);let u=Me();return u&&xt.has(`${t}:${u}`)?i=u:a(),()=>{if(!d){d=!0,window.removeEventListener("popstate",a);for(let[o,r,s]of l)c[o]===s&&(c[o]=r)}}}var xe={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 Mn(){try{return je(window.location.search)}catch(e){return{utmParams:{},clickIds:{}}}}function Ct(e){return e.replace(/\/events\/?$/,"")}function Ce(){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){var u;if(typeof window=="undefined")return;let t=e!=null?e:wt;if(!t){console.warn("[sentient] grantConsent() called before init()");return}let n=K.get(t);if(!n){console.warn("[sentient] grantConsent() called before init()");return}let{config:c,upgrade:d,reinit:i}=n;if(!d){n.upgradeBlockedReason&&console.warn(n.upgradeBlockedReason);return}if(c.respectDoNotTrack!==!1&&Ce())return;let a=(i!=null?i:Qe)(j(v({},c),{consent:!0}));d(a);let l=(u=K.get(t))==null?void 0:u.dispose;K.set(t,{config:j(v({},c),{consent:!0}),upgrade:null,dispose:l})}function Kn(e){var o;let t=e.preConsentBehavior==="statistical_winner",n=Ct((o=e.ingestUrl)!=null?o:vt),c={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},d=new Map,i=new Map,a={track:()=>{},goal:()=>{},componentGoal:()=>{},identify:()=>{},getAssignment:()=>null,fetchWeights:()=>Promise.resolve([]),assign(r,s,g){if(!t)return Promise.resolve(null);let p=d.get(r);return p?Promise.resolve(p):qe(i,r,async()=>{try{let m=new URLSearchParams({componentId:r});for(let G of s!=null?s:[])m.append("variantIds[]",G);let S=await fetch(`${n}/winner?${m.toString()}`,{headers:c});if(!S.ok)return s!=null&&s[0]?{variantId:s[0],assignmentTtlMs:0}:null;let E={variantId:(await S.json()).variantId,assignmentTtlMs:0};return d.set(r,E),E}catch(m){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:r=>a.track(r),goal:((r,s,g,p)=>a.goal(r,s,g,p)),componentGoal:(r,s,g)=>a.componentGoal(r,s,g),identify:r=>a.identify(r),getAssignment:(r,s)=>a.getAssignment(r,s),assign:(r,s,g,p)=>a.assign(r,s,g,p),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 u(r){a=r}return{proxy:l,setInner:u}}function qe(e,t,n){let c=e.get(t);if(c)return c;let d=(async()=>{try{return await n()}finally{e.delete(t)}})();return e.set(t,d),d}function Qe(e){var k,H,ee,F,he,q,se,Q,Ve;if(typeof window=="undefined")return xe;wt=e.apiKey||"local";let t=K.get(e.apiKey||"local");if(t!=null&&t.dispose)try{t.dispose()}catch(f){}let n=e.respectDoNotTrack!==!1&&Ce(),c=e.consent===!1||n,d=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_");if(e.localMode===!0||!d&&e.localMode!==!1)return K.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): this client is keyless/local \u2014 there is no hosted client to upgrade to. Configure a pk_ API key to enable tracking."}),c?xe:St(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."),K.set(e.apiKey||"local",{config:e,upgrade:null,upgradeBlockedReason:"[sentient] grantConsent(): the client was initialized with an invalid apiKey (expected a pk_ public key) \u2014 consent cannot enable tracking."}),xe;let{proxy:f,setInner:y}=Kn(e);return K.set(e.apiKey,{config:e,upgrade:n?null:y}),f}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."),xe;if(e.ingestUrl==="")return console.warn("[sentient] init() called with an empty ingestUrl. SDK disabled."),xe;let i=(k=e.ingestUrl)!=null?k:vt,a=Date.now(),l=_e({ssrSessionId:e.ssrSessionId,apiKey:e.apiKey}),u=dt(void 0,e.apiKey),o=ct({ingestUrl:i,apiKey:e.apiKey}),r=Ct(i),s={"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},g=new Set,p=lt({url:`${r}/goals`,apiKey:e.apiKey,headers:s,onDrop:(f,y)=>{if(!e.debug){if(g.has(y))return;g.add(y)}console.warn(`[sentient] goal dropped (HTTP ${y}) \u2014 this will not be retried. `+(y===400?"The session was not found: call init() and let the session upsert complete before firing goals.":y===401||y===403?"Check the API key and that this origin is on the project allowlist.":"See the response status for the cause."),f)}}),m=le((H=navigator.userAgent)!=null?H:""),S=window.location.origin,x=de((ee=document.referrer)!=null?ee:"",S),E=(F=e.sessionSegment)!=null?F:`${m}:${x}`,G=new Map,U=new Map,A=new Map,I=null,N=f=>{for(let y of f)A.has(y.id)||A.set(y.id,fe(y))};if(e.initialSlots)for(let[f,y]of Object.entries(e.initialSlots))A.set(f,y);let b=me(e.apiKey);if(b)for(let[f,y]of Object.entries(b.slots))A.has(f)||A.set(f,y);let R={low:.15,medium:.5,high:.85};if(e.initialPersona)I=v({},e.initialPersona);else{let f=document.documentElement.dataset;f.sentientPersona?I={persona:f.sentientPersona,confidence:(q=R[(he=f.sentientConfidence)!=null?he:"low"])!=null?q:.15}:b&&(I={persona:b.persona,confidence:(se=R[b.band])!=null?se:.15})}if(e.initialAssignments)for(let[f,y]of Object.entries(e.initialAssignments))u.set(f,E,{variantId:y,assignedAt:Date.now(),segment:E,confidence:1});let B=Promise.resolve(),W=l.getSessionId();if(W){let f=ue((Q=document.referrer)!=null?Q:""),{utmParams:y,clickIds:C}=Mn(),O=v(v(v(v({sessionId:W,deviceClass:m,trafficSource:x,referrerDomain:f,utmParams:y,clickIds:C,timeOfDay:pe(new Date),dayOfWeek:["sun","mon","tue","wed","thu","fri","sat"][new Date().getDay()],ephemeral:l.isEphemeral(),automation:typeof navigator!="undefined"&&navigator.webdriver===!0||Ne((Ve=navigator.userAgent)!=null?Ve:"")},e.userId?{userId:e.userId}:{}),e.persona?{persona:e.persona}:{}),e.country?{country:e.country}:{}),e.sdk?{sdk:e.sdk.name,sdkVersion:e.sdk.version}:{}),L=async()=>{for(let w=0;;w++){try{let _=await fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify(O),headers:s});if(_.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");return}if(_.ok||ce(_)==="dropped")return}catch(_){}if(w>=Ln){console.warn("[SentientUI] Could not register the session after retries. Conversions in this visit may not be recorded.");return}await new Promise(_=>setTimeout(_,Y(w+1)))}};try{B=L()}catch(w){}}e.debug&&(console.log("[sentient] initialized",{context:e.context}),window.__sentient={client:null,queue:o});let Z=Dn(),M=null,oe=!1,h={goal(f,y={},C=1,O=0){var Se,be,ie,T,z,ke,P;let L=l.getSessionId();if(!L)return;let w=Nn(y)?y:{metadata:y},_=[f,(Se=w.externalId)!=null?Se:"",(be=w.stepIndex)!=null?be:O,(ie=w.weight)!=null?ie:C].join("\0"),$=w.value!==void 0?`${w.value}\0${(T=w.currency)!=null?T:""}`:null;if(Z.firedBefore(_,$)){e.debug&&console.log(`[sentient] goal("${f}") already recorded for this action \u2014 not sent twice`);return}let D=He(),J={sessionId:L,name:f,metadata:(z=w.metadata)!=null?z:{},weight:(ke=w.weight)!=null?ke:C,stepIndex:(P=w.stepIndex)!=null?P:O,goalId:D,value:w.value,currency:w.currency,externalId:w.externalId};e.debug&&console.log("[sentient] goal",J);let te={id:D,body:JSON.stringify(J)};B.then(()=>p.send(te))},componentGoal(f,y,C){var D,J,te;let O=l.getSessionId();if(!O)return;let L=u.get(f,E),w=L?null:(D=A.get(f))!=null?D:null;if(!L&&w===null){e.debug&&console.warn(`[sentient] componentGoal("${f}"): no assignment or slot decision yet \u2014 render its <Adaptive>/adaptive hook or call assign()/decide() before recording a goal.`);return}let _=L?L.variantId:Le(w),$={id:He(),sessionId:O,projectId:e.apiKey,componentId:f,variantId:_,eventType:"goal_achieved",goalType:y,payload:v({reward:(J=C==null?void 0:C.reward)!=null?J:1,goalValue:C==null?void 0:C.value,currency:C==null?void 0:C.currency},(te=C==null?void 0:C.metadata)!=null?te:{}),timestamp:Date.now(),timeInSession:Date.now()-a,path:Me()};e.debug&&console.log("[sentient] componentGoal",$),B.then(()=>o.push($))},identify(f){let y=l.getSessionId();y&&B.then(()=>{fetch(`${r}/sessions`,{method:"POST",keepalive:!0,body:JSON.stringify({sessionId:y,userId:f,ephemeral:l.isEphemeral()}),headers:s}).catch(()=>{})})},track(f){let y=l.getSessionId();if(!y)return;let C=j(v({path:Me()},f),{id:He(),sessionId:y,timestamp:Date.now(),timeInSession:Date.now()-a});e.debug&&console.log("[sentient] track",C),B.then(()=>o.push(C))},getAssignment(f,y){return u.get(f,y)},async assign(f,y,C,O){let L=l.getSessionId();if(!L)return null;let w=u.get(f,E);if(w&&(y!=null&&y.length||w.content!==void 0)){let _=w.ttlMs&&w.ttlMs>0?Math.max(0,w.assignedAt+w.ttlMs-Date.now()):0;return{variantId:w.variantId,assignmentTtlMs:_,content:w.content}}return qe(G,f,async()=>{await B;try{let _={sessionId:L,componentId:f,variantIds:y};O!==void 0?_.agentDataByVariant=O:C!==void 0&&(_.agentData=C);let $=await fetch(`${r}/assign`,{method:"POST",body:JSON.stringify(_),headers:s});if(!$.ok)return null;let D=await $.json();return u.set(f,E,v({variantId:D.variantId,assignedAt:Date.now(),segment:E,confidence:1,content:D.content},D.assignmentTtlMs&&D.assignmentTtlMs>0?{ttlMs:D.assignmentTtlMs}:{})),D}catch(_){return null}})},async decide(f){var w,_;let y=l.getSessionId();if(!y)return null;let C=(w=f.slots)!=null?w:[],O={sessionId:y};f.sections&&f.sections.length>0&&(O.sections=f.sections.map($=>({id:$}))),O.components=(_=f.components)!=null?_:[],C.length>0&&(O.slots=C.map(Ee)),f.slotsFrom==="registry"&&(O.slotsFrom="registry"),f.v&&(O.v=f.v),e.persona&&(O.persona=e.persona);let L=JSON.stringify(O);return qe(U,L,async()=>{var $,D,J,te,Se,be;await B;try{let ie=await fetch(`${r}/decide`,{method:"POST",body:L,headers:s});if(!ie.ok)return N(C),null;let T=await ie.json(),z={};for(let P of C){let X=($=T.slots)==null?void 0:$[P.id];if(X!==void 0){z[P.id]=X,A.set(P.id,X);continue}let Ze=A.get(P.id);if(Ze!==void 0)z[P.id]=Ze;else{let et=fe(P);z[P.id]=et,A.set(P.id,et)}}if(T.slots)for(let[P,X]of Object.entries(T.slots))P in z||(z[P]=X,A.set(P,X));let ke=I!=null&&I.persona!=="unknown";T.persona&&!(T.persona==="unknown"&&ke)?I={persona:T.persona,confidence:(D=T.confidence)!=null?D:0}:I||(I={persona:"unknown",confidence:0});for(let[P,X]of Object.entries((J=T.assignments)!=null?J:{}))u.set(P,E,{variantId:X,assignedAt:Date.now(),segment:E,confidence:1});return ye(e.apiKey,v(v({v:1,persona:I.persona,band:(0,ze.confidenceBand)(I.confidence),slots:Object.fromEntries(A),layoutOrder:(te=T.layoutOrder)!=null?te:null,savedAt:Date.now()},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.palette?{palette:T.palette}:{})),v(v(v(v({layoutOrder:(Se=T.layoutOrder)!=null?Se:null,assignments:(be=T.assignments)!=null?be:{},slots:z,persona:I.persona,confidence:I.confidence},T.slotConfig?{slotConfig:T.slotConfig}:{}),T.goals?{goals:T.goals}:{}),T.sectionMap?{sectionMap:T.sectionMap}:{}),T.palette?{palette:T.palette}:{})}catch(ie){return N(C),null}})},getSlotResult(f){var y;return(y=A.get(f))!=null?y:null},getPersona(){return I?{persona:I.persona,confidence:I.confidence,band:(0,ze.confidenceBand)(I.confidence)}:null},async fetchWeights(){var f;try{let y=await fetch(`${r}/weights`,{headers:s});return y.ok?(f=(await y.json()).components)!=null?f:[]:[]}catch(y){return[]}},getGraph(){return{pageNodes:[],capturedAt:0}},dispose(){var f;M==null||M(),oe=!0,o.destroy(),p.destroy(),((f=K.get(e.apiKey))==null?void 0:f.dispose)===h.dispose&&K.delete(e.apiKey),e.debug&&console.log("[sentient] disposed")},destroy(){var f;M==null||M(),oe=!0,o.destroy(),p.destroy(),l.destroy(),u.clear(),((f=K.get(e.apiKey))==null?void 0:f.dispose)===h.dispose&&K.delete(e.apiKey);try{localStorage.removeItem(re+e.apiKey),localStorage.removeItem(Ue(e.apiKey)),localStorage.removeItem(Fe(e.apiKey))}catch(y){}e.debug&&console.log("[sentient] destroyed")}};if(K.set(e.apiKey,{config:e,upgrade:null,dispose:h.dispose}),M=Bn(h,e.apiKey,f=>{B.then(()=>{oe||xt.add(f)})}),e.debug){let f=window;f.__sentient&&(f.__sentient.client=h)}return h}var kt="_snt_graph_edges",Gn={pricing:["features","faq"],features:["pricing"],faq:["pricing"],social_proof:["cta"],cta:["social_proof","hero","trust"],hero:["cta"],comparison:["pricing"],trust:["cta"]};function $n(e){var t;return(t=Gn[e])!=null?t:[]}function Un(e,t){try{let n=localStorage.getItem(e);return n?JSON.parse(n):t}catch(n){return t}}function Fn(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch(n){}}var jn=new Set(["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"]);function Wn(e){return jn.has(e)?e:"generic"}function Je(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch(t){return"/"}}function Hn(e,t,n){let c=`${e}:${t}:${n.join(",")}`,d=5381;for(let i=0;i<c.length;i++)d=(d<<5)+d+c.charCodeAt(i)&4294967295;return(d>>>0).toString(16).padStart(8,"0")}function Tt(e){let t=new Map,n=new Map,c=`_snt_graph_nodes${ne(e==null?void 0:e.apiKey)}`,d=()=>{typeof window!="undefined"&&Fn(c,[...t.values()])};if(typeof window!="undefined"){let i=Un(c,[]);for(let a of i)t.set(a.componentId,a);try{localStorage.removeItem(kt)}catch(a){}}return{addPageNode(i){t.set(i.componentId,i),d()},addStructuralEdge(i){let a=`${i.fromComponentId}->${i.toComponentId}`;n.set(a,i)},syncOnce(){var a,l;if(!(e!=null&&e.syncUrl)||typeof window=="undefined")return;let i=[...t.values()];if(i.length!==0)try{let u=new Map;for(let p of i){let m=(a=u.get(p.semanticType))!=null?a:[];m.push(p),u.set(p.semanticType,m)}let o=[],r=new Set;for(let p of i)for(let m of $n(p.semanticType)){let S=(l=u.get(m))!=null?l:[];for(let x of S){if(x.componentId===p.componentId)continue;let E=`semantic:${p.componentId}->${x.componentId}`;r.has(E)||(r.add(E),o.push({fromComponentId:p.componentId,toComponentId:x.componentId,type:"semantic",weight:.4,confidence:.9}))}}let s=new Set(i.map(p=>p.componentId));for(let p of n.values()){if(!s.has(p.fromComponentId)||!s.has(p.toComponentId))continue;let m=`structural:${p.fromComponentId}->${p.toComponentId}`;r.has(m)||(r.add(m),o.push({fromComponentId:p.fromComponentId,toComponentId:p.toComponentId,type:"structural",weight:p.weight,confidence:1}))}let g=j(v(v({pageUrl:Je(window.location.href)},e.sessionId?{sessionId:e.sessionId}:{}),e.projectId?{projectId:e.projectId}:{}),{nodes:i.map(p=>{let m=Wn(p.semanticType);return{componentId:p.componentId,semanticType:m,answers:p.answers,contentHash:Hn(p.componentId,m,p.answers),prominenceScore:p.prominenceScore,depthInPage:p.depth}}),edges:o});fetch(e.syncUrl,{method:"POST",keepalive:!0,headers:v({"Content-Type":"application/json"},e.apiKey?{Authorization:`Bearer ${e.apiKey}`}:{}),body:JSON.stringify(g)}).catch(()=>{})}catch(u){}},snapshot(){return{pageNodes:[...t.values()],capturedAt:Date.now()}},destroy(){if(typeof window!="undefined")try{localStorage.removeItem(c),localStorage.removeItem(kt)}catch(i){}}}}var zn=["data-sentient-id","data-testid","data-test","data-id","data-name","data-cy"];function Xe(e){var t;return((t=e.textContent)!=null?t:"").replace(/\s+/g," ").trim()}function qn(e){return{tag:e.tagName.toLowerCase(),text:Xe(e).slice(0,40)}}function At(e){return e.replace(/["\\\]]/g,"\\$&")}function Ie(e,t){try{return e.querySelectorAll(t).length===1}catch(n){return!1}}function _t(e,t){var a;let n=e.tagName.toLowerCase();if(!n)return null;let c=((a=e.getAttribute("class"))!=null?a:"").split(/\s+/).filter(l=>/^[a-zA-Z][\w-]*$/.test(l)),d=[n,...c.map(l=>`${n}.${l}`)];for(let l of d)if(Ie(t,l))return l;let i=e.parentElement;if(i&&i!==t){let l=_t(i,t);if(l){for(let s of d){let g=`${l} > ${s}`;if(Ie(t,g))return g}let u=Array.from(i.children).filter(s=>s.tagName.toLowerCase()===n),o=u.indexOf(e),r=u.some(s=>s!==e&&Xe(s)!==Xe(e));if(o>=0&&r){let s=`${l} > ${n}:nth-of-type(${o+1})`;if(Ie(t,s))return s}}}return null}function Ke(e,t){let n=qn(e),c=e.getAttribute("id");if(c&&Ie(t,`#${At(c)}`))return{v:1,id:c,fingerprint:n};for(let i of zn){let a=e.getAttribute(i);if(a&&Ie(t,`[${i}="${At(a)}"]`))return{v:1,dataAttr:{name:i,value:a},fingerprint:n}}let d=_t(e,t);return d?{v:1,selector:d,fingerprint:n}:null}var Ot=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Qn={banner:"hero",navigation:"navigation",contentinfo:"footer"};function Jn(e){let t=e.ariaRole?Qn[e.ariaRole.toLowerCase()]:void 0;if(t)return t;if(e.tag==="nav")return"navigation";if(e.tag==="footer")return"footer";if(e.tag==="header")return e.actionCount>=5?"navigation":"hero";let n=`${e.idClass} ${e.headingText}`.toLowerCase();return/\b(navbar|nav-bar|navigation|site-nav|main-nav|topbar|footer)\b/.test(n)?/footer/.test(n)?"footer":"navigation":/\b(hero|masthead|jumbotron)\b/i.test(e.idClass)?"hero":null}function Xn(e){return e.actionCount>=1&&e.textLength>0&&e.textLength<200?"cta":"generic"}var Yn=[["pricing",/\b(pricing|price list|per month|\/mo|subscriptions?)\b|\bplans?\b(?=[^.]{0,40}(from|start|month|year|[$€£]))/i],["faq",/\bfaq\b|frequently asked|common questions?/i],["comparison",/\b(compare|comparison|versus)\b|\bvs\./i],["social_proof",/\b(reviews?|ratings?|testimonial|brands?|galler(y|ies)|logos)\b|trusted by|loved by|case stud|what our customers say/i],["trust",/\b(insurance|warrant(y|ies)|guarantees?|certifi|accredit|security|privacy|compliance|gdpr|encrypt)\b|why choose|about us|our team/i],["cta",/\b(book|booking|reserve|appointments?|newsletter|subscribe)\b|contact us|get in touch|opening hours/i],["features",/\b(features?|benefits?|capabilit|services?|repairs?|menus?|products?)\b|how it works|our process|what we (do|offer)|what you get/i]],Vn=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|free returns?|returns? within|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]],Rt={navigation:"navigation",footer:"navigation",hero:"hero",cta:"cta",generic:"generic"};function Zn(e){var n;let t=e.querySelector("h1, h2, h3");return((n=t==null?void 0:t.textContent)!=null?n:"").slice(0,160)}function er(e){var d,i;let t=Jn(e);if(t)return{type:(d=Rt[t])!=null?d:"generic",strength:"strong"};let n=`${e.idClass} ${e.headingText}`.toLowerCase();for(let[a,l]of Yn)if(l.test(n))return{type:a,strength:"strong"};for(let[a,l]of Vn)if(l.test(e.bodyText))return{type:a,strength:"strong"};let c=Xn(e);return{type:(i=Rt[c])!=null?i:"generic",strength:"weak"}}function tr(e){var c,d;let t=((c=e.textContent)!=null?c:"").replace(/\s+/g," ").trim(),n=e.getAttribute("role");return v({tag:e.tagName.toLowerCase(),idClass:`${e.id} ${String((d=e.className)!=null?d:"")}`,headingText:Zn(e),bodyText:t.slice(0,2e3),actionCount:e.querySelectorAll('a, button, [role="button"]').length,textLength:t.length},n?{ariaRole:n}:{})}function Pt(e){return er(tr(e)).type}var nr=new Set(["SECTION","ARTICLE","MAIN","DIV","ASIDE"]),rr="h1, h2, h3",or="[data-sentient-id], section[aria-label], article[aria-label], main[aria-label], aside[aria-label]",Nt=30,sr=1500,ir={scan:async()=>({nodes:[],edges:[],scannedAt:0}),observe:()=>{},getProminenceScore:()=>0,destroy:()=>{}};function Lt(e,t,n){return n<=t?0:Math.max(0,Math.min(1,(e-t)/(n-t)))}function ar(e){var t,n,c;try{let d=e;for(let i of Object.keys(d)){if(!i.startsWith("__reactFiber")&&!i.startsWith("__reactInternalInstance"))continue;let a=d[i],l=(c=(t=a==null?void 0:a.type)==null?void 0:t.displayName)!=null?c:(n=a==null?void 0:a.type)==null?void 0:n.name;if(l&&l.length>1)return l}}catch(d){}}function cr(e){let t={};for(let n of Array.from(e.attributes))n.name.startsWith("data-")&&(t[n.name]=n.value);return t}var Dt=new Set(Ot);function lr(e){let t=e.getAttribute("data-sentient-type");if(t&&Dt.has(t))return t;let n=e.getAttribute("role");return n&&Dt.has(n)?n:Pt(e)}function dr(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 ur(e){let t=[],n=e;for(;n;){let c=n.parentElement;if(!c){t.push(n.tagName.toLowerCase());break}let d=Array.prototype.indexOf.call(c.children,n);t.push(`${n.tagName.toLowerCase()}[${d}]`),n=c}return t.reverse().join("/")}function pr(e){var n;let t=(n=e.getAttribute("data-sentient-id"))!=null?n:e.getAttribute("id");return t||`${e.tagName.toLowerCase()}-${dr(ur(e))}`}function gr(e){let t=0,n=e.parentElement;for(;n;)t++,n=n.parentElement;return t}function Ye(e,t){var c,d,i,a;let n=e.querySelector(rr);return{componentId:pr(e),semanticType:lr(e),ariaLabel:(c=e.getAttribute("aria-label"))!=null?c:void 0,headingText:(i=(d=n==null?void 0:n.textContent)==null?void 0:d.trim())!=null?i:void 0,isAboveFold:e.getBoundingClientRect().top<window.innerHeight,prominenceScore:t(e),depth:gr(e),reactComponentName:ar(e),dataAttributes:cr(e),locator:(a=Ke(e,e.ownerDocument))!=null?a:void 0}}function Bt(e){var i;let t=[],n=new Set,c="__root__",d=new Map;for(let[a,l]of e){let u=a.parentElement,o=c;for(;u;){if(e.has(u)){o=e.get(u);let s=e.get(a),g=`${o}->${s}`;!n.has(g)&&o!==s&&(n.add(g),t.push({fromComponentId:o,toComponentId:s,weight:.6}));break}u=u.parentElement}let r=(i=d.get(o))!=null?i:[];r.push(a),d.set(o,r)}for(let a of d.values()){if(a.length<2)continue;let l=a.length>Nt?a.slice(0,Nt):a;for(let u=0;u<l.length;u++)for(let o=u+1;o<l.length;o++){if(t.length>=sr)return t;let r=e.get(l[u]),s=e.get(l[o]);if(r===s)continue;let g=`${r}->${s}::sib`,p=`${s}->${r}::sib`;n.has(g)||(n.add(g),t.push({fromComponentId:r,toComponentId:s,weight:.3})),n.has(p)||(n.add(p),t.push({fromComponentId:s,toComponentId:r,weight:.3}))}}return t}function fr(e){let t=[],n=new Set,c=new Map;return document.querySelectorAll("[data-sentient-id]").forEach(a=>{if(a instanceof Element&&!n.has(a)){n.add(a);let l=Ye(a,e);t.push(l),c.set(a,l.componentId)}}),document.querySelectorAll("section, article, main, aside").forEach(a=>{if(!(a instanceof Element)||n.has(a))return;let l=a.hasAttribute("aria-label"),u=a.hasAttribute("data-sentient-id");if(!l&&!u)return;n.add(a);let o=Ye(a,e);t.push(o),c.set(a,o.componentId)}),{nodes:t,edges:Bt(c),elementToId:c}}function Mt(){if(typeof window=="undefined")return ir;let e=null,t=0,n=null,c=new Map,d=u=>{try{let o=window.getComputedStyle(u),r=parseFloat(o.fontSize)||12,s=parseFloat(o.zIndex)||0,g=u.getBoundingClientRect(),p=Math.max(g.top,0),m=window.innerHeight||1,S=1/(p/m+1),x=Lt(r,12,48)*.4+S*.4+Lt(s,0,100)*.2;return Math.max(0,Math.min(1,x))}catch(o){return .5}};return{scan:()=>new Promise(u=>{let o=()=>{let{nodes:r,edges:s,elementToId:g}=fr(d);c.clear();for(let[p,m]of g)c.set(p,m);u({nodes:r,edges:s,scannedAt:Date.now()})};try{typeof requestIdleCallback=="function"?t=requestIdleCallback(o,{timeout:100}):o()}catch(r){o()}}),observe:u=>{n=u;try{e=new MutationObserver(o=>{let r=[],s=new Set;for(let p of o)p.type==="childList"&&p.addedNodes.forEach(m=>{if(!(m instanceof Element))return;let S=[];nr.has(m.tagName)&&(m.hasAttribute("data-sentient-id")||m.hasAttribute("aria-label"))&&S.push(m);try{m.querySelectorAll(or).forEach(x=>S.push(x))}catch(x){}for(let x of S){if(c.has(x))continue;let E=Ye(x,d);r.push(E),s.add(E.componentId),c.set(x,E.componentId)}});if(r.length===0||!n)return;for(let p of[...c.keys()])p.isConnected||c.delete(p);let g=Bt(c).filter(p=>s.has(p.fromComponentId)||s.has(p.toComponentId));n({nodes:r,edges:g,addedAt:Date.now()})}),e.observe(document.body,{childList:!0,subtree:!0})}catch(o){}},getProminenceScore:d,destroy:()=>{if(e&&(e.disconnect(),e=null),t&&typeof cancelIdleCallback=="function")try{cancelIdleCallback(t)}catch(u){}t=0,n=null,c.clear()}}}var mr="https://api.sentient-ui.com/v1/events";function yr(e){var n;let t=c=>{try{let d=document.cookie.match(new RegExp(`(?:^|; )${c}=([^;]*)`));return d?decodeURIComponent(d[1]):void 0}catch(d){return}};return(n=e?t(ae(e)):void 0)!=null?n:t(we)}var Ge=new Map;function Kt(e){var p;let t=Qe(e),n=e.respectDoNotTrack!==!1&&Ce(),c=e.consent===!1||n,d=typeof e.apiKey=="string"&&e.apiKey.startsWith("pk_"),i=e.localMode===!0||!d;if(!e.graph||i||typeof window=="undefined")return t;if(c)return n||Et(e.apiKey,m=>Kt(m)),t;let a=Ge.get(e.apiKey);if(a)try{a()}catch(m){}let l=Mt(),u=(p=e.ingestUrl)!=null?p:mr,o=Tt({syncUrl:u.replace(/\/events\/?$/,"/graph/sync"),apiKey:e.apiKey,projectId:e.apiKey,sessionId:yr(e.apiKey)});l.scan().then(m=>{for(let S of m.nodes)o.addPageNode({id:S.componentId,componentId:S.componentId,semanticType:S.semanticType,answers:e.captureDomText&&S.headingText?[S.headingText]:[],prominenceScore:S.prominenceScore,depth:S.depth});for(let S of m.edges)o.addStructuralEdge(S);o.syncOnce()});let r=null,s=()=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,o.syncOnce()},500)};l.observe(m=>{for(let S of m.nodes)o.addPageNode({id:S.componentId,componentId:S.componentId,semanticType:S.semanticType,answers:e.captureDomText&&S.headingText?[S.headingText]:[],prominenceScore:S.prominenceScore,depth:S.depth});for(let S of m.edges)o.addStructuralEdge(S);s()});let g=()=>{r!==null&&(clearTimeout(r),r=null),l.destroy(),o.destroy(),Ge.get(e.apiKey)===g&&Ge.delete(e.apiKey)};return Ge.set(e.apiKey,g),j(v({},t),{getGraph:()=>o.snapshot(),dispose:()=>{g(),t.dispose()},destroy:()=>{g(),t.destroy()}})}0&&(module.exports={BLOCK_ALIGNS,BLOCK_EMPHASES,BLOCK_FITS,BLOCK_GAPS,BLOCK_GRID_COLUMNS,BLOCK_HEADING_LEVELS,BLOCK_JUSTIFIES,BLOCK_RATIOS,BLOCK_SIZES,BLOCK_TEXT_ALIGNS,BLOCK_TONES,BLOCK_WEIGHTS,LEGACY_SESSION_COOKIE_NAME,MAX_BLOCK_ARMS,MAX_BLOCK_CHILDREN,MAX_BLOCK_DEPTH,MAX_BLOCK_NODES,MAX_BLOCK_TEXT_LEN,SNAPSHOT_STORAGE_KEY_PREFIX,armOfResult,attachMicroSignalDetectors,baselineResultFor,baselineSlots,deriveSessionSegment,detectDeviceClass,detectTimeOfDay,detectTrafficSource,grantConsent,init,isDoNotTrackEnabled,locatorFromElement,readSnapshot,referrerDomainFromReferer,renderPrePaintScript,sanitizePageUrl,sessionCookieName,toWireSlot,writeSnapshot});
2
2
  //# sourceMappingURL=index-graph.js.map