@sunboard/react 0.9.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +234 -26
- package/dist/index.d.mts +915 -305
- package/dist/index.mjs +4322 -1735
- package/dist/styles.css +1076 -727
- package/package.json +41 -35
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sunboard/react",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Product tours, tooltips and a Help launcher with an assistant, for your React app. Sunboard creates the guides from your docs and keeps them working as your app changes.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
6
|
"homepage": "https://sunboardhq.com",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"./dist/styles.css"
|
|
7
|
+
"keywords": [
|
|
8
|
+
"react",
|
|
9
|
+
"product-tour",
|
|
10
|
+
"onboarding",
|
|
11
|
+
"tooltip",
|
|
12
|
+
"walkthrough",
|
|
13
|
+
"in-app-guide",
|
|
14
|
+
"help",
|
|
15
|
+
"assistant",
|
|
16
|
+
"sunboard"
|
|
19
17
|
],
|
|
18
|
+
"type": "module",
|
|
20
19
|
"exports": {
|
|
21
20
|
".": {
|
|
22
21
|
"types": "./dist/index.d.mts",
|
|
@@ -24,36 +23,43 @@
|
|
|
24
23
|
},
|
|
25
24
|
"./styles.css": "./dist/styles.css"
|
|
26
25
|
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
27
34
|
"dependencies": {
|
|
28
|
-
"@floating-ui/react": "^0.27.19"
|
|
29
|
-
"@sunboard/core": "0.10.0"
|
|
35
|
+
"@floating-ui/react": "^0.27.19"
|
|
30
36
|
},
|
|
31
37
|
"peerDependencies": {
|
|
32
|
-
"react": ">=18
|
|
33
|
-
"react-dom": ">=18
|
|
38
|
+
"react": ">=18",
|
|
39
|
+
"react-dom": ">=18"
|
|
34
40
|
},
|
|
35
41
|
"devDependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@types/react": "19.2.
|
|
41
|
-
"@types/react-dom": "19.2.
|
|
42
|
+
"@repo/eslint-config": "0.0.0",
|
|
43
|
+
"@repo/typescript-config": "0.0.0",
|
|
44
|
+
"@sunboard/core": "0.0.0",
|
|
45
|
+
"@testing-library/react": "^16.3.2",
|
|
46
|
+
"@types/react": "^19.2.0",
|
|
47
|
+
"@types/react-dom": "^19.2.0",
|
|
42
48
|
"eslint": "^9.39.1",
|
|
43
|
-
"jsdom": "^
|
|
44
|
-
"react": "
|
|
45
|
-
"react-dom": "
|
|
46
|
-
"tsdown": "^0.
|
|
49
|
+
"jsdom": "^30.0.1",
|
|
50
|
+
"react": "19.2.4",
|
|
51
|
+
"react-dom": "19.2.4",
|
|
52
|
+
"tsdown": "^0.23.0",
|
|
47
53
|
"typescript": "5.9.2",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"@repo/typescript-config": "0.0.0"
|
|
54
|
+
"vite": "^8.2.1",
|
|
55
|
+
"vitest": "^4.0.15"
|
|
51
56
|
},
|
|
52
57
|
"scripts": {
|
|
53
|
-
"build": "tsdown &&
|
|
54
|
-
"
|
|
58
|
+
"build": "tsdown && node scripts/check-dist.mjs",
|
|
59
|
+
"dev": "tsdown --watch --on-success \"node scripts/yalc-push.mjs\"",
|
|
55
60
|
"check-types": "tsc --noEmit",
|
|
56
|
-
"lint": "eslint .",
|
|
57
|
-
"test": "vitest run"
|
|
61
|
+
"lint": "eslint --max-warnings 0 .",
|
|
62
|
+
"test": "vitest run",
|
|
63
|
+
"harness": "vite --config harness/vite.config.mts"
|
|
58
64
|
}
|
|
59
65
|
}
|
package/dist/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapters/navigation.ts","../src/lib/detect-identities.ts","../src/hooks/sunboard-context.ts","../src/components/SunboardProvider.tsx","../src/components/SunboardHotspots.tsx","../src/components/SunboardTooltips.tsx","../src/components/SunboardTour.tsx","../src/components/Sunboard.tsx","../src/hooks/useSunboard.ts","../src/hooks/useChecklist.ts","../src/hooks/useSurvey.ts","../src/hooks/useTooltips.ts"],"sourcesContent":[],"mappings":";;;;;;KAAY,gBAAA,2BAA2C;;;;;;;;;AAAvD;;;;ACkBA;;;;ACPA;AAOA;AAEA;AAIY,KDNA,cAAA,GAAiB,MCML,CAAA,MAAA,EAAA,MAAA,CAAA,GAAA,KAAA;;;KAbZ,YAAA;;;;EFXA,UAAA,CAAA,EEeG,MFfa,CAAA,MAAA,EAAA,OAA2B,CAAA;;KEkB3C,eAAA,GAAkB;KAElB,WAAA;EDFA,EAAA,EAAA,IAAA;;;;ACPZ,CAAA;AAOY,KAMA,YAAA,GANe;EAEf,EAAA,EAAA,IAAA;AAIZ,CAAA,GAAY;EAOA,EAAA,EAAA,KAAA;EAIA,MAAA,EAAA,WAAU,GAAA,cAAA,GAAA,YAAA,GAAA,eAAA;AAYtB,CAAA;AAIY,KApBA,UAAA,GAoBA;EAYA,EAAA,EAAA,IAAA;AAQZ,CAAA,GAAY;EACH,EAAA,EAAA,KAAA;EACA,MAAA,EAAA,WAAA,GAAA,cAAA,GAAA,cAAA;CAGY;AACA,KA1CT,UAAA,GA0CS;EAGP,EAAA,EAAA,IAAA;CAEC,GAAA;EACE,EAAA,EAAA,KAAA;EACF,MAAA,EA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EAGH;AAEZ;AAIA;AAOA;EAIY,QAAA,ESXA,WTWU,EAAA;EAYV;EAIA,QAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAsB,IAAA;EAYtB;EAQA,OAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAoB,GAAA,IAAA;EACvB;EACA,MAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAGY;;;;EAOJ,iBAAA,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA;CACF;;;;;AAO2B,iBSjD1B,WAAA,CAAA,CTiD0B,ESjDX,iBTiDW"}
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["identities: Record<string, string>","best: PosthogCandidate | undefined","found: PosthogCandidate[]","SunboardRuntimeClient","via: TooltipDismissVia","flat: FlatUser","current: unknown","interpolateOptional","next"],"sources":["../src/adapters/navigation.ts","../src/lib/detect-identities.ts","../src/hooks/sunboard-context.ts","../src/version.ts","../src/components/SunboardProvider.tsx","../src/lib/interpolate-tokens.ts","../src/hooks/useSunboard.ts","../src/hooks/useChecklist.ts","../src/hooks/useSurvey.ts","../src/icons/index.tsx","../src/components/ChecklistStep.tsx","../src/hooks/useInterpolated.ts","../src/hooks/useTargetElement.ts","../src/components/SunboardHotspots.tsx","../src/components/SunboardTooltips.tsx","../src/components/SunboardTour.tsx","../src/components/Sunboard.tsx","../src/hooks/useTooltips.ts"],"sourcesContent":["export type NavigateCallback = (url: string) => void | Promise<void>;\n\nexport async function navigateWithFallback(\n url: string,\n navigate?: NavigateCallback\n): Promise<void> {\n if (navigate) {\n await navigate(url);\n return;\n }\n\n if (typeof window !== \"undefined\") {\n window.location.assign(url);\n }\n}\n","/**\n * Best-effort probe of analytics providers on the host page, returning the id\n * each one files the current visitor under (e.g. PostHog's distinct_id). These\n * ride the bootstrap request so the server can join Sunboard's funnel data to\n * the customer's analytics; they are inert until the project connects the\n * provider in Sunboard.\n *\n * Everything here is defensive by construction: a broken or half-loaded\n * analytics snippet on the customer's page must never break onboarding, so\n * every probe is wrapped and failures return nothing.\n */\n\n/**\n * The `identities` prop accepted by SunboardProvider:\n * - omitted: providers are auto-detected on each bootstrap\n * - object: explicit ids, merged over (and winning against) detected ones\n * - `false`: detection disabled entirely, nothing is sent\n */\nexport type IdentitiesProp = Record<string, string> | false;\n\nexport function resolveIdentities(\n prop: IdentitiesProp | undefined\n): Record<string, string> | undefined {\n if (prop === false) {\n return undefined;\n }\n\n const detected = detectAnalyticsIdentities();\n const merged = { ...detected, ...prop };\n\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction detectAnalyticsIdentities(): Record<string, string> {\n const identities: Record<string, string> = {};\n\n if (typeof window === \"undefined\") {\n return identities;\n }\n\n const posthogId = detectPosthogId();\n if (posthogId) {\n identities.posthog = posthogId;\n }\n\n // Future providers (amplitude, mixpanel) add a probe here and nothing else;\n // the wire format and storage are already keyed by provider.\n\n return identities;\n}\n\nfunction detectPosthogId(): string | undefined {\n // A live instance is the most direct read, but only snippet installs assign\n // `window.posthog`; the posthog-js npm module (the common React setup) never\n // touches the global.\n const fromInstance = probe(() => {\n const posthog = (window as PosthogWindow).posthog;\n return typeof posthog?.get_distinct_id === \"function\"\n ? posthog.get_distinct_id()\n : undefined;\n });\n if (fromInstance) {\n return fromInstance;\n }\n\n // Fall back to the persistence posthog-js writes on init, keyed\n // `ph_<projectApiKey>_posthog` with the distinct_id inside: localStorage\n // for the default `localStorage`/`localStorage+cookie` modes, the cookie\n // for `cookie` mode. Several entries can coexist on one origin (every\n // PostHog project ever run there leaves one behind, localhost especially)\n // and each carries a different distinct_id, so pick the entry with the\n // most recent session activity: only the currently running project keeps\n // bumping its `$sesid` timestamp.\n const candidates = [\n ...posthogCandidatesFromLocalStorage(),\n ...posthogCandidatesFromCookie()\n ];\n\n let best: PosthogCandidate | undefined;\n for (const candidate of candidates) {\n if (!best || candidate.lastActivity > best.lastActivity) {\n best = candidate;\n }\n }\n return best?.distinctId;\n}\n\nconst POSTHOG_PERSISTENCE_KEY = /^ph_.+_posthog$/;\n\ntype PosthogCandidate = {\n distinctId: string;\n /** Last session activity (`$sesid[0]`); 0 when the entry has none. */\n lastActivity: number;\n};\n\nfunction posthogCandidatesFromLocalStorage(): PosthogCandidate[] {\n const found: PosthogCandidate[] = [];\n try {\n const storage = window.localStorage;\n for (let index = 0; index < storage.length; index += 1) {\n const key = storage.key(index);\n if (!key || !POSTHOG_PERSISTENCE_KEY.test(key)) {\n continue;\n }\n const candidate = parsePosthogPersistence(() => storage.getItem(key));\n if (candidate) {\n found.push(candidate);\n }\n }\n } catch {\n // localStorage can be blocked outright (privacy modes); nothing to read.\n }\n return found;\n}\n\nfunction posthogCandidatesFromCookie(): PosthogCandidate[] {\n const found: PosthogCandidate[] = [];\n try {\n for (const entry of document.cookie.split(\";\")) {\n const separator = entry.indexOf(\"=\");\n if (separator === -1) {\n continue;\n }\n const name = entry.slice(0, separator).trim();\n if (!POSTHOG_PERSISTENCE_KEY.test(name)) {\n continue;\n }\n const candidate = parsePosthogPersistence(() =>\n decodeURIComponent(entry.slice(separator + 1))\n );\n if (candidate) {\n found.push(candidate);\n }\n }\n } catch {\n // Cookie access can throw in exotic embeds; nothing to read.\n }\n return found;\n}\n\n/** One persistence entry -> candidate; malformed entries parse to nothing. */\nfunction parsePosthogPersistence(\n read: () => string | null\n): PosthogCandidate | undefined {\n try {\n const raw = read();\n if (!raw) {\n return undefined;\n }\n const parsed = JSON.parse(raw) as {\n distinct_id?: unknown;\n $sesid?: unknown;\n };\n if (\n typeof parsed.distinct_id !== \"string\" ||\n parsed.distinct_id.length === 0\n ) {\n return undefined;\n }\n const sesid = parsed.$sesid;\n return {\n distinctId: parsed.distinct_id,\n lastActivity:\n Array.isArray(sesid) && typeof sesid[0] === \"number\" ? sesid[0] : 0\n };\n } catch {\n return undefined;\n }\n}\n\n/** Run a probe, keeping only non-empty string results and swallowing throws. */\nfunction probe(read: () => unknown): string | undefined {\n try {\n const value = read();\n return typeof value === \"string\" && value.length > 0 ? value : undefined;\n } catch {\n return undefined;\n }\n}\n\ntype PosthogWindow = Window & {\n posthog?: {\n get_distinct_id?: () => unknown;\n };\n};\n","import { createContext } from \"react\";\nimport type {\n NormalizedSunboardSpec,\n SunboardHotspot,\n SunboardStep,\n SunboardTooltip,\n SunboardTourStep,\n TrackEventName\n} from \"@sunboard/core\";\nimport type { TooltipDismissVia } from \"@sunboard/core/runtime-api\";\n\nexport type SunboardUser = {\n id: string;\n email?: string | null;\n group?: string | null;\n properties?: Record<string, unknown>;\n};\n\nexport type TrackProperties = Record<string, unknown>;\n\nexport type TrackResult =\n | { ok: true }\n | { ok: false; reason: \"not-ready\" | \"missing-user\" | \"network-error\" };\n\nexport type SurveyResult =\n | { ok: true }\n | {\n ok: false;\n reason: \"not-ready\" | \"missing-user\" | \"not-survey\" | \"network-error\";\n };\n\nexport type TourResult =\n | { ok: true }\n | { ok: false; reason: \"not-ready\" | \"missing-user\" | \"missing-tour\" };\n\nexport type StepResult =\n | { ok: true }\n | {\n ok: false;\n reason:\n | \"not-ready\"\n | \"missing-user\"\n | \"missing-step\"\n | \"not-manual\"\n | \"network-error\";\n };\n\nexport type TooltipResult =\n | { ok: true }\n | { ok: false; reason: \"not-ready\" | \"missing-user\" | \"missing-tooltip\" };\n\nexport type VisibleSunboardTooltip = {\n key: string;\n tooltip: SunboardTooltip;\n /**\n * True when the user asked for this tooltip (a checklist step's\n * `openTooltip` action), false when it is showing proactively. A requested\n * tooltip shows even if it was dismissed before — the user explicitly asked\n * to be shown where the action happens.\n */\n requested: boolean;\n};\n\nexport type ActiveSunboardTour = {\n key: string;\n name: string;\n step: SunboardTourStep;\n stepIndex: number;\n totalSteps: number;\n};\n\nexport type SunboardContextValue = {\n spec?: NormalizedSunboardSpec | null;\n user?: SunboardUser | null;\n loading: boolean;\n route?: string;\n completedStepKeys: ReadonlySet<string>;\n completedTourKeys: ReadonlySet<string>;\n completedCount: number;\n totalSteps: number;\n activeTour: ActiveSunboardTour | null;\n track: (\n eventName: TrackEventName,\n properties?: TrackProperties\n ) => Promise<TrackResult>;\n /**\n * Submit survey answers for the active survey experience. On success the\n * runtime re-bootstraps so the freshly collected attributes route the user\n * into the next experience in-session.\n */\n submitSurvey: (answers: Record<string, unknown>) => Promise<SurveyResult>;\n startTour: (tourKey: string) => Promise<TourResult>;\n /**\n * Close the active tour. User-initiated dismissals are reported to the\n * runtime API as a negative signal (\"the user bailed at this step\");\n * pass `silent: true` for programmatic closes (e.g. a missing tour\n * target) that say nothing about the user's intent.\n */\n dismissTour: (options?: { silent?: boolean }) => Promise<TourResult>;\n advanceTour: () => Promise<TourResult>;\n navigateToStep: (step: SunboardStep) => Promise<void>;\n startChecklistStep: (\n step: SunboardStep\n ) => Promise<TourResult | TooltipResult | void>;\n /**\n * Complete a checklist step because the user checked it off. Only steps the\n * spec allows (`manual` not set to false) accept it; the completion is\n * recorded with a \"manual\" source, distinct from event/tour completions.\n */\n completeChecklistStep: (stepKey: string) => Promise<StepResult>;\n visibleHotspots: Array<{ key: string; hotspot: SunboardHotspot }>;\n dismissedTooltipKeys: ReadonlySet<string>;\n /**\n * Tooltips that qualify for the current route, requested-first. Renderers\n * show ONE at a time: the first entry whose target resolves.\n */\n visibleTooltips: VisibleSunboardTooltip[];\n /**\n * Open a tooltip on demand (the checklist's openTooltip action). Navigates\n * are the caller's job; this just marks the tooltip requested so it renders\n * once its route matches and its target is present, dismissal or not.\n */\n openTooltip: (tooltipKey: string) => Promise<TooltipResult>;\n /**\n * Never show this tooltip again. `via: \"close\"` is the negative signal (the\n * default); `via: \"action\"` records that the user took the tooltip's action;\n * `via: \"target\"` records that the user clicked the tooltip's target element.\n */\n dismissTooltip: (\n tooltipKey: string,\n options?: { via?: TooltipDismissVia }\n ) => Promise<TooltipResult>;\n /** Report that a tooltip actually reached the user's eyes (deduped per session). */\n markTooltipSeen: (tooltipKey: string) => void;\n};\n\nexport const SunboardContext = createContext<SunboardContextValue | null>(null);\n","export const SDK_VERSION = \"0.0.0\";\n","import {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n type Dispatch,\n type ReactNode,\n type SetStateAction\n} from \"react\";\nimport type {\n NormalizedSunboardSpec,\n SunboardStep,\n TrackEventName\n} from \"@sunboard/core\";\nimport {\n DEFAULT_RUNTIME_API_URL,\n SunboardRuntimeClient,\n type RuntimeExperience,\n type RuntimeProgress,\n type RuntimeSurvey,\n type TooltipDismissVia\n} from \"@sunboard/core/runtime-api\";\nimport {\n navigateWithFallback,\n type NavigateCallback\n} from \"../adapters/navigation\";\nimport { routeMatches } from \"../adapters/routes\";\nimport {\n resolveIdentities,\n type IdentitiesProp\n} from \"../lib/detect-identities\";\nimport {\n SunboardContext,\n type ActiveSunboardTour,\n type SunboardContextValue,\n type SunboardUser,\n type TrackProperties\n} from \"../hooks/sunboard-context\";\nimport { SDK_VERSION } from \"../version\";\n\nexport type SunboardProviderProps = {\n spec?: NormalizedSunboardSpec | null;\n user?: SunboardUser | null;\n loading?: boolean;\n route?: string;\n navigate?: NavigateCallback;\n /**\n * Override the runtime API host. Dev-only — leave unset in production so the\n * SDK targets the hosted Sunboard runtime API. Defaults to\n * `DEFAULT_RUNTIME_API_URL`.\n */\n apiUrl?: string;\n publishableKey?: string;\n /**\n * Analytics-provider ids for joining Sunboard's funnel data to your product\n * analytics. Omit it and installed providers (PostHog) are detected\n * automatically, on each bootstrap and for a few seconds after, so a\n * provider that initializes late is still captured. Pass explicit ids to\n * override detection; pass `false` to disable capture entirely. Captured ids\n * are inert until the provider is connected to the project in Sunboard.\n */\n identities?: IdentitiesProp;\n onTrack?: (\n eventName: TrackEventName,\n properties?: TrackProperties\n ) => void | Promise<void>;\n children: ReactNode;\n};\n\ntype ActiveTourState = {\n key: string;\n stepIndex: number;\n};\n\ntype BootstrapState = {\n experience: RuntimeExperience | null;\n survey: RuntimeSurvey | null;\n attributes: Record<string, unknown> | null;\n loading: boolean;\n};\n\nexport function SunboardProvider({\n spec: specProp,\n user,\n loading: loadingProp,\n route,\n navigate,\n apiUrl,\n publishableKey,\n identities: identitiesProp,\n onTrack,\n children\n}: SunboardProviderProps) {\n const currentRoute = route ?? getBrowserRoute();\n const currentOrigin = getBrowserOrigin();\n const client = useMemo(() => {\n if (!publishableKey) {\n return null;\n }\n\n // `apiUrl` is a dev-only override; production apps only supply a key and\n // talk to the hosted runtime API by default.\n return new SunboardRuntimeClient({\n apiKey: publishableKey,\n apiUrl: apiUrl || DEFAULT_RUNTIME_API_URL,\n sdkVersion: SDK_VERSION\n });\n }, [apiUrl, publishableKey]);\n // Bump to force a bootstrap refetch in-session (e.g. after a survey submit,\n // so freshly collected attributes route the user without a navigation).\n const [bootstrapNonce, setBootstrapNonce] = useState(0);\n const refreshBootstrap = useCallback(() => {\n setBootstrapNonce((nonce) => nonce + 1);\n }, []);\n\n const bootstrap = useSunboardBootstrap(client, {\n enabled: !specProp,\n identities: identitiesProp,\n nonce: bootstrapNonce,\n origin: currentOrigin,\n route: currentRoute,\n user\n });\n\n const activeExperience = bootstrap.experience;\n // A survey pre-empts experiences (the server returns no experiences while one\n // is owed). Render the survey's spec when present, otherwise the experience's.\n const activeSurvey = bootstrap.survey;\n const hostedSpec = activeSurvey?.spec ?? activeExperience?.spec ?? null;\n const resolvedSpec = specProp ?? hostedSpec;\n const resolvedLoading = loadingProp ?? bootstrap.loading;\n const hostedMode = client !== null && !specProp;\n\n // The user view used for token interpolation/display merges the server-owned\n // attributes (the `onboarding.*` namespace returned by bootstrap) into the\n // host user, so `{{user.onboarding.*}}` resolves. Network calls keep using\n // the original `user` — owned attributes must never be echoed back as host\n // properties (which bootstrap overwrites).\n const ownedAttributes = bootstrap.attributes;\n const effectiveUser = useMemo<SunboardUser | null | undefined>(() => {\n if (!user || !ownedAttributes || Object.keys(ownedAttributes).length === 0) {\n return user;\n }\n\n return {\n ...user,\n properties: { ...(user.properties ?? {}), ...ownedAttributes }\n };\n }, [user, ownedAttributes]);\n\n const [completedStepKeys, setCompletedStepKeys] = useState<Set<string>>(\n () => new Set()\n );\n const [completedTourKeys, setCompletedTourKeys] = useState<Set<string>>(\n () => new Set()\n );\n const [dismissedTooltipKeys, setDismissedTooltipKeys] = useState<Set<string>>(\n () => new Set()\n );\n const [activeTourState, setActiveTourState] = useState<ActiveTourState | null>(\n null\n );\n // A tooltip the user explicitly asked for (checklist openTooltip action).\n // Survives navigation so the tooltip can open once the destination renders.\n const [requestedTooltipKey, setRequestedTooltipKey] = useState<string | null>(\n null\n );\n // Session-level dedupe for tooltip \"seen\" reporting.\n const seenTooltipKeys = useRef<Set<string>>(new Set());\n const lastNavigatedTourStep = useRef<string | null>(null);\n const storageKey =\n !hostedMode && resolvedSpec && user\n ? completedToursStorageKey(resolvedSpec.key, user.id)\n : null;\n const tooltipStorageKey =\n !hostedMode && resolvedSpec && user\n ? dismissedTooltipsStorageKey(resolvedSpec.key, user.id)\n : null;\n const experienceKey =\n activeSurvey?.key ?? activeExperience?.key ?? resolvedSpec?.key ?? null;\n const versionId =\n activeSurvey?.version.id ?? activeExperience?.version.id ?? null;\n\n useEffect(() => {\n setCompletedStepKeys(new Set());\n setActiveTourState(null);\n setRequestedTooltipKey(null);\n seenTooltipKeys.current = new Set();\n lastNavigatedTourStep.current = null;\n\n setCompletedTourKeys(\n storageKey ? readStoredKeys(storageKey) : new Set()\n );\n setDismissedTooltipKeys(\n tooltipStorageKey ? readStoredKeys(tooltipStorageKey) : new Set()\n );\n }, [resolvedSpec?.key, storageKey, tooltipStorageKey, user?.id]);\n\n useEffect(() => {\n if (!hostedMode || !activeExperience) {\n return;\n }\n\n applyProgress(\n activeExperience.progress,\n setCompletedStepKeys,\n setCompletedTourKeys,\n setDismissedTooltipKeys\n );\n }, [activeExperience, hostedMode]);\n\n const effectiveCompletedStepKeys = useMemo(() => {\n if (!hostedMode || !activeExperience) {\n return completedStepKeys;\n }\n\n return mergeKeys(\n completedStepKeys,\n activeExperience.progress.completedStepKeys\n );\n }, [activeExperience, completedStepKeys, hostedMode]);\n\n const effectiveCompletedTourKeys = useMemo(() => {\n if (!hostedMode || !activeExperience) {\n return completedTourKeys;\n }\n\n return mergeKeys(\n completedTourKeys,\n activeExperience.progress.completedTourKeys\n );\n }, [activeExperience, completedTourKeys, hostedMode]);\n\n const effectiveDismissedTooltipKeys = useMemo(() => {\n if (!hostedMode || !activeExperience) {\n return dismissedTooltipKeys;\n }\n\n return mergeKeys(\n dismissedTooltipKeys,\n activeExperience.progress.dismissedTooltipKeys\n );\n }, [activeExperience, dismissedTooltipKeys, hostedMode]);\n\n useEffect(() => {\n if (!resolvedSpec) {\n return;\n }\n\n const tourCompletedStepKeys = (resolvedSpec.checklist?.steps ?? [])\n .filter(\n (step) =>\n step.completeWhen?.tour &&\n effectiveCompletedTourKeys.has(step.completeWhen.tour)\n )\n .map((step) => step.key);\n\n if (tourCompletedStepKeys.length === 0) {\n return;\n }\n\n setCompletedStepKeys((current) => mergeKeys(current, tourCompletedStepKeys));\n }, [effectiveCompletedTourKeys, resolvedSpec]);\n\n const activeTour = useMemo<ActiveSunboardTour | null>(() => {\n if (!resolvedSpec || !activeTourState) {\n return null;\n }\n\n const tour = resolvedSpec.tours[activeTourState.key];\n const step = tour?.steps[activeTourState.stepIndex];\n\n if (!tour || !step) {\n return null;\n }\n\n return {\n key: activeTourState.key,\n name: tour.name,\n step,\n stepIndex: activeTourState.stepIndex,\n totalSteps: tour.steps.length\n };\n }, [activeTourState, resolvedSpec]);\n\n useEffect(() => {\n if (!activeTour?.step.route || routeMatches(activeTour.step.route, currentRoute)) {\n return;\n }\n\n const navigationKey = `${activeTour.key}:${activeTour.step.key}:${activeTour.step.route}`;\n\n if (lastNavigatedTourStep.current === navigationKey) {\n return;\n }\n\n lastNavigatedTourStep.current = navigationKey;\n void navigateWithFallback(activeTour.step.route, navigate);\n }, [activeTour, currentRoute, navigate]);\n\n // Record per-step tour progress. Fires once per (tour, step) transition;\n // the dep array tracks step.key + tour key so re-renders don't spam the\n // endpoint and re-entries refresh `lastSeenAt` server-side.\n useEffect(() => {\n if (\n !hostedMode ||\n !client ||\n !activeTour ||\n !user ||\n !experienceKey\n ) {\n return;\n }\n\n void client\n .recordTourStep({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n stepKey: activeTour.step.key,\n tourKey: activeTour.key,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n })\n .catch(() => {\n // Best-effort tracking — never break the host app on a 4xx/5xx.\n });\n // Intentionally narrow deps to the tour/step identity. We do not refire\n // when `currentRoute` changes mid-step, because the route adapter scrolls\n // the same popover into a new viewport, not a new logical step.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [activeTour?.key, activeTour?.step.key, client, currentOrigin, experienceKey, hostedMode, user?.id]);\n\n const totalSteps = resolvedSpec?.checklist?.steps.length ?? 0;\n const completedCount =\n resolvedSpec?.checklist?.steps.filter((step) =>\n effectiveCompletedStepKeys.has(step.key)\n ).length ?? 0;\n\n const completeTour = useCallback(\n (tourKey: string) => {\n setCompletedTourKeys((current) => {\n const next = new Set(current);\n next.add(tourKey);\n\n if (storageKey) {\n writeStoredKeys(storageKey, next);\n }\n\n return next;\n });\n },\n [storageKey]\n );\n\n const track = useCallback<SunboardContextValue[\"track\"]>(\n async (eventName, properties) => {\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n // In hosted mode every track is durable history: with no resolved spec\n // (bootstrap in flight, or the user matches nothing) the event is still\n // sent, unscoped, so a checklist that resolves later can complete from\n // it. Only spec-prop mode has nowhere to send an event before the spec\n // exists.\n const ready = !resolvedLoading && !!resolvedSpec;\n\n if (!ready && !(hostedMode && client)) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n const matchingStepKeys = ready\n ? (resolvedSpec.checklist?.steps ?? [])\n .filter((step) => step.completeWhen?.event === eventName)\n .map((step) => step.key)\n : [];\n\n if (matchingStepKeys.length > 0) {\n // `mergeKeys` returns `current` unchanged when every key is already\n // present, so re-firing an already-completed step's event is a no-op\n // and does not churn state/recreate the context value. This is what\n // keeps a consumer that calls `track()` from an effect depending on the\n // whole context value from looping render→track→render.\n setCompletedStepKeys((current) => mergeKeys(current, matchingStepKeys));\n }\n\n let networkOk = true;\n\n if (hostedMode && client) {\n // Scope to the resolved experience so the event row is attributed to\n // it. Unscoped when nothing is resolved or when a survey is on screen\n // (surveys never own product events): the server records the event\n // unattached and fans step completions out across every experience\n // the user resolves to.\n const scopedKey =\n ready && resolvedSpec.type !== \"survey\" ? experienceKey : null;\n\n try {\n const response = await client.track({\n eventName,\n origin: currentOrigin,\n properties,\n route: currentRoute,\n user: toRuntimeUser(user),\n ...(scopedKey\n ? { experienceKey: scopedKey, versionId: versionId ?? undefined }\n : {})\n });\n // A scoped track always returns progress; an unscoped one returns\n // null (it may advance several experiences at once).\n if (response.progress) {\n applyProgress(\n response.progress,\n setCompletedStepKeys,\n setCompletedTourKeys,\n setDismissedTooltipKeys\n );\n }\n } catch {\n networkOk = false;\n }\n }\n\n try {\n await onTrack?.(eventName, properties);\n } catch {\n return { ok: false, reason: \"network-error\" };\n }\n\n if (!networkOk) {\n return { ok: false, reason: \"network-error\" };\n }\n\n return { ok: true };\n },\n [\n client,\n currentRoute,\n currentOrigin,\n experienceKey,\n hostedMode,\n onTrack,\n resolvedLoading,\n resolvedSpec,\n user,\n versionId\n ]\n );\n\n const completeChecklistStep = useCallback<\n SunboardContextValue[\"completeChecklistStep\"]\n >(\n async (stepKey) => {\n if (resolvedLoading || !resolvedSpec) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n const step = (resolvedSpec.checklist?.steps ?? []).find(\n (candidate) => candidate.key === stepKey\n );\n\n if (!step) {\n return { ok: false, reason: \"missing-step\" };\n }\n\n if (step.manual === false) {\n return { ok: false, reason: \"not-manual\" };\n }\n\n // Optimistic, like track(): `mergeKeys` is a no-op when already\n // complete, and the server response below re-applies truth.\n setCompletedStepKeys((current) => mergeKeys(current, [stepKey]));\n\n if (hostedMode && client && experienceKey) {\n try {\n const response = await client.completeStep({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n stepKey,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n });\n applyProgress(\n response.progress,\n setCompletedStepKeys,\n setCompletedTourKeys,\n setDismissedTooltipKeys\n );\n } catch {\n return { ok: false, reason: \"network-error\" };\n }\n }\n\n return { ok: true };\n },\n [\n client,\n currentOrigin,\n currentRoute,\n experienceKey,\n hostedMode,\n resolvedLoading,\n resolvedSpec,\n user,\n versionId\n ]\n );\n\n const submitSurvey = useCallback<SunboardContextValue[\"submitSurvey\"]>(\n async (answers) => {\n if (resolvedLoading || !resolvedSpec) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n if (resolvedSpec.type !== \"survey\" || !resolvedSpec.survey) {\n return { ok: false, reason: \"not-survey\" };\n }\n\n // Surveys are server-backed: a survey can only be answered when the\n // runtime resolved it for this user.\n if (!hostedMode || !client || !experienceKey) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n try {\n await client.submitSurvey({\n answers,\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n });\n } catch {\n return { ok: false, reason: \"network-error\" };\n }\n\n // Re-bootstrap so the freshly collected attributes route the user now.\n refreshBootstrap();\n return { ok: true };\n },\n [\n client,\n currentOrigin,\n currentRoute,\n experienceKey,\n hostedMode,\n refreshBootstrap,\n resolvedLoading,\n resolvedSpec,\n user,\n versionId\n ]\n );\n\n const navigateToStep = useCallback(\n async (step: SunboardStep) => {\n if (!step.route) {\n return;\n }\n\n await navigateWithFallback(step.route, navigate);\n },\n [navigate]\n );\n\n const startTour = useCallback<SunboardContextValue[\"startTour\"]>(\n async (tourKey) => {\n if (resolvedLoading || !resolvedSpec) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n if (!resolvedSpec.tours[tourKey]) {\n return { ok: false, reason: \"missing-tour\" };\n }\n\n lastNavigatedTourStep.current = null;\n setActiveTourState({ key: tourKey, stepIndex: 0 });\n\n // Fire-and-forget tour-start. The per-step record fires from the\n // useEffect below when activeTour resolves, so step[0] gets recorded\n // independently. We deliberately don't await — popover UX must not\n // block on network.\n if (hostedMode && client && experienceKey && user) {\n void client\n .startTour({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n tourKey,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n })\n .catch(() => {\n // Tracking is best-effort. Network failures shouldn't surface\n // to the host app.\n });\n }\n\n return { ok: true };\n },\n [\n client,\n currentRoute,\n currentOrigin,\n experienceKey,\n hostedMode,\n resolvedLoading,\n resolvedSpec,\n user,\n versionId\n ]\n );\n\n const dismissTour = useCallback<SunboardContextValue[\"dismissTour\"]>(\n async (options) => {\n // Capture what was on screen before clearing state — the dismissal\n // report needs the tour + step the user actually bailed on.\n const dismissed = activeTourState;\n const dismissedStepKey = dismissed\n ? resolvedSpec?.tours[dismissed.key]?.steps[dismissed.stepIndex]?.key\n : undefined;\n\n setActiveTourState(null);\n lastNavigatedTourStep.current = null;\n\n // Best-effort negative-signal tracking, same contract as startTour:\n // never block the UI on network, never surface failures to the host.\n // Silent dismissals (missing target etc.) are not user intent and are\n // deliberately not reported.\n if (\n !options?.silent &&\n hostedMode &&\n client &&\n experienceKey &&\n user &&\n dismissed &&\n dismissedStepKey\n ) {\n void client\n .dismissTour({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n stepKey: dismissedStepKey,\n tourKey: dismissed.key,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n })\n .catch(() => {\n // Tracking is best-effort.\n });\n }\n\n return { ok: true };\n },\n [\n activeTourState,\n client,\n currentOrigin,\n currentRoute,\n experienceKey,\n hostedMode,\n resolvedSpec,\n user,\n versionId\n ]\n );\n\n const finishActiveTour = useCallback(\n async (tourKey: string) => {\n completeTour(tourKey);\n\n if (!hostedMode || !client || !experienceKey || !user) {\n return;\n }\n\n try {\n const response = await client.completeTour({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n tourKey,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n });\n applyProgress(\n response.progress,\n setCompletedStepKeys,\n setCompletedTourKeys,\n setDismissedTooltipKeys\n );\n } catch {\n // Fail soft: keep local optimistic completion, never break the host app.\n }\n },\n [\n client,\n completeTour,\n currentRoute,\n currentOrigin,\n experienceKey,\n hostedMode,\n user,\n versionId\n ]\n );\n\n const advanceTour = useCallback<SunboardContextValue[\"advanceTour\"]>(\n async () => {\n if (resolvedLoading || !resolvedSpec || !activeTourState) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n const tour = resolvedSpec.tours[activeTourState.key];\n\n if (!tour) {\n return { ok: false, reason: \"missing-tour\" };\n }\n\n lastNavigatedTourStep.current = null;\n\n if (activeTourState.stepIndex >= tour.steps.length - 1) {\n const completedKey = activeTourState.key;\n setActiveTourState(null);\n await finishActiveTour(completedKey);\n return { ok: true };\n }\n\n setActiveTourState({\n key: activeTourState.key,\n stepIndex: activeTourState.stepIndex + 1\n });\n return { ok: true };\n },\n [activeTourState, finishActiveTour, resolvedLoading, resolvedSpec, user]\n );\n\n const openTooltip = useCallback<SunboardContextValue[\"openTooltip\"]>(\n async (tooltipKey) => {\n if (resolvedLoading || !resolvedSpec) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n if (!resolvedSpec.tooltips[tooltipKey]) {\n return { ok: false, reason: \"missing-tooltip\" };\n }\n\n setRequestedTooltipKey(tooltipKey);\n return { ok: true };\n },\n [resolvedLoading, resolvedSpec, user]\n );\n\n const dismissTooltip = useCallback<SunboardContextValue[\"dismissTooltip\"]>(\n async (tooltipKey, options) => {\n if (resolvedLoading || !resolvedSpec) {\n return { ok: false, reason: \"not-ready\" };\n }\n\n if (!user) {\n return { ok: false, reason: \"missing-user\" };\n }\n\n if (!resolvedSpec.tooltips[tooltipKey]) {\n return { ok: false, reason: \"missing-tooltip\" };\n }\n\n const via: TooltipDismissVia = options?.via ?? \"close\";\n\n setRequestedTooltipKey((current) =>\n current === tooltipKey ? null : current\n );\n setDismissedTooltipKeys((current) => {\n const next = mergeKeys(current, [tooltipKey]);\n\n if (tooltipStorageKey && next !== current) {\n writeStoredKeys(tooltipStorageKey, next);\n }\n\n return next;\n });\n\n // Best-effort persistence, same contract as tour dismissals: never block\n // the UI on network, never surface failures to the host.\n if (hostedMode && client && experienceKey) {\n void client\n .dismissTooltip({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n tooltipKey,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined,\n via\n })\n .catch(() => {\n // Tracking is best-effort.\n });\n }\n\n return { ok: true };\n },\n [\n client,\n currentOrigin,\n currentRoute,\n experienceKey,\n hostedMode,\n resolvedLoading,\n resolvedSpec,\n tooltipStorageKey,\n user,\n versionId\n ]\n );\n\n const markTooltipSeen = useCallback<SunboardContextValue[\"markTooltipSeen\"]>(\n (tooltipKey) => {\n if (\n !resolvedSpec?.tooltips[tooltipKey] ||\n seenTooltipKeys.current.has(tooltipKey)\n ) {\n return;\n }\n\n seenTooltipKeys.current.add(tooltipKey);\n\n if (hostedMode && client && experienceKey && user) {\n void client\n .recordTooltipSeen({\n experienceKey,\n origin: currentOrigin,\n route: currentRoute,\n tooltipKey,\n user: toRuntimeUser(user),\n versionId: versionId ?? undefined\n })\n .catch(() => {\n // Tracking is best-effort.\n });\n }\n },\n [\n client,\n currentOrigin,\n currentRoute,\n experienceKey,\n hostedMode,\n resolvedSpec,\n user,\n versionId\n ]\n );\n\n const startChecklistStep = useCallback<\n SunboardContextValue[\"startChecklistStep\"]\n >(\n async (step) => {\n if (step.action?.type === \"startTour\") {\n return startTour(step.action.tour);\n }\n\n if (step.action?.type === \"openTooltip\") {\n // Land the user where the action happens, then open the tooltip on\n // the element. The tooltip's own route is the destination of record;\n // the step's route is the fallback for an everywhere-tooltip.\n const tooltipKey = step.action.tooltip;\n const destination =\n resolvedSpec?.tooltips[tooltipKey]?.route ?? step.route;\n\n if (destination && !routeMatches(destination, currentRoute)) {\n await navigateWithFallback(destination, navigate);\n }\n\n return openTooltip(tooltipKey);\n }\n\n await navigateToStep(step);\n },\n [\n currentRoute,\n navigate,\n navigateToStep,\n openTooltip,\n resolvedSpec,\n startTour\n ]\n );\n\n const visibleHotspots = useMemo<SunboardContextValue[\"visibleHotspots\"]>(() => {\n if (!resolvedSpec || activeTour) {\n return [];\n }\n\n return Object.entries(resolvedSpec.hotspots)\n .filter(([, hotspot]) => routeMatches(hotspot.route, currentRoute))\n .filter(\n ([, hotspot]) =>\n hotspot.repeatable ||\n !effectiveCompletedTourKeys.has(hotspot.action.tour)\n )\n .map(([key, hotspot]) => ({ key, hotspot }));\n }, [activeTour, effectiveCompletedTourKeys, currentRoute, resolvedSpec]);\n\n const visibleTooltips = useMemo<SunboardContextValue[\"visibleTooltips\"]>(() => {\n if (!resolvedSpec || activeTour) {\n return [];\n }\n\n const requestedTooltip = requestedTooltipKey\n ? resolvedSpec.tooltips[requestedTooltipKey]\n : undefined;\n\n if (requestedTooltipKey && requestedTooltip) {\n // The user asked for this one. While it waits for its route (navigation\n // in flight), nothing else competes for the slot; a prior dismissal\n // does not suppress an explicit request.\n if (!routeMatches(requestedTooltip.route, currentRoute)) {\n return [];\n }\n\n return [\n { key: requestedTooltipKey, requested: true, tooltip: requestedTooltip }\n ];\n }\n\n return Object.entries(resolvedSpec.tooltips)\n .filter(\n ([key, tooltip]) =>\n routeMatches(tooltip.route, currentRoute) &&\n !effectiveDismissedTooltipKeys.has(key)\n )\n .map(([key, tooltip]) => ({ key, requested: false, tooltip }));\n }, [\n activeTour,\n currentRoute,\n effectiveDismissedTooltipKeys,\n requestedTooltipKey,\n resolvedSpec\n ]);\n\n const value = useMemo<SunboardContextValue>(\n () => ({\n spec: resolvedSpec,\n user: effectiveUser,\n loading: resolvedLoading,\n route: currentRoute,\n completedStepKeys: effectiveCompletedStepKeys,\n completedTourKeys: effectiveCompletedTourKeys,\n completedCount,\n totalSteps,\n activeTour,\n track,\n submitSurvey,\n startTour,\n dismissTour,\n advanceTour,\n navigateToStep,\n startChecklistStep,\n completeChecklistStep,\n visibleHotspots,\n dismissedTooltipKeys: effectiveDismissedTooltipKeys,\n visibleTooltips,\n openTooltip,\n dismissTooltip,\n markTooltipSeen\n }),\n [\n resolvedSpec,\n effectiveUser,\n resolvedLoading,\n currentRoute,\n effectiveCompletedStepKeys,\n effectiveCompletedTourKeys,\n completedCount,\n totalSteps,\n activeTour,\n track,\n submitSurvey,\n startTour,\n dismissTour,\n advanceTour,\n navigateToStep,\n startChecklistStep,\n completeChecklistStep,\n visibleHotspots,\n effectiveDismissedTooltipKeys,\n visibleTooltips,\n openTooltip,\n dismissTooltip,\n markTooltipSeen\n ]\n );\n\n return (\n <SunboardContext.Provider value={value}>\n {children}\n </SunboardContext.Provider>\n );\n}\n\nfunction useSunboardBootstrap(\n client: SunboardRuntimeClient | null,\n options: {\n enabled: boolean;\n identities?: IdentitiesProp;\n nonce: number;\n origin?: string;\n route: string;\n user?: SunboardUser | null;\n }\n): BootstrapState {\n const { enabled, identities: identitiesProp, nonce, origin, route, user } =\n options;\n // Read through a ref so the effect always sees the latest prop without the\n // object's identity churning the dep array (mirrors the `user` handling:\n // identities influence the next bootstrap, they don't trigger one).\n const identitiesRef = useRef(identitiesProp);\n identitiesRef.current = identitiesProp;\n const [state, setState] = useState<BootstrapState>({\n attributes: null,\n experience: null,\n loading: false,\n survey: null\n });\n const warnedSdkAdvisory = useRef(false);\n\n useEffect(() => {\n if (!client || !enabled || !user?.id) {\n setState({\n attributes: null,\n experience: null,\n loading: false,\n survey: null\n });\n return;\n }\n\n // TODO: plumb `controller.signal` through SunboardRuntimeClient.post into\n // the underlying fetch so aborted requests cancel at the network layer. In\n // React 19 dev StrictMode the provider mounts twice; the first effect's\n // fetch keeps flying and can surface as `TypeError: Failed to fetch` in the\n // browser console. Harmless (we guard with signal.aborted before touching\n // state) but noisy in dev.\n const controller = new AbortController();\n setState({\n attributes: null,\n experience: null,\n loading: true,\n survey: null\n });\n\n // Providers are probed at request time, on every bootstrap: the id can\n // change when an anonymous visitor identifies, and a snippet that loaded\n // late is picked up by the next bootstrap.\n const identities = resolveIdentities(identitiesRef.current);\n\n client\n .bootstrap({\n origin,\n route,\n user: toRuntimeUser(user),\n ...(identities ? { identities } : {})\n })\n .then((response) => {\n if (controller.signal.aborted) {\n return;\n }\n\n if (\n response.experiences.length === 0 &&\n !response.survey &&\n isDevEnvironment()\n ) {\n console.warn(\n `[sunboard] bootstrap returned no active experiences for route \"${route}\". Check the dashboard for an enabled deployment whose trigger.route matches (the publishable key selects the environment).`\n );\n }\n\n if (\n response.sdkAdvisory &&\n isDevEnvironment() &&\n !warnedSdkAdvisory.current\n ) {\n warnedSdkAdvisory.current = true;\n console.warn(`[sunboard] ${response.sdkAdvisory.message}`);\n }\n\n setState({\n attributes: response.attributes ?? null,\n experience: response.experiences[0] ?? null,\n loading: false,\n survey: response.survey ?? null\n });\n })\n .catch((error: unknown) => {\n if (controller.signal.aborted) {\n return;\n }\n\n if (isDevEnvironment()) {\n console.warn(\"[sunboard] bootstrap failed\", error);\n }\n\n setState({\n attributes: null,\n experience: null,\n loading: false,\n survey: null\n });\n });\n\n // The bootstrap often races the analytics snippet: posthog-js typically\n // initializes in a parent effect that runs after this one, so the probe\n // above finds nothing on the first (and usually only) bootstrap of a\n // session. Keep probing briefly and push a late capture through\n // `identify`; the server merges it per provider key, same as bootstrap.\n const cancelLateCapture = scheduleLateIdentityCapture({\n client,\n identitiesRef,\n origin,\n sent: identities,\n user\n });\n\n return () => {\n controller.abort();\n cancelLateCapture();\n };\n // user.id is the identity key; we deliberately do not refetch when the\n // user object reference changes without an id change. `route` is\n // intentionally excluded so navigation does not wipe the active experience\n // — per-route visibility is handled by the runtime via step/tour/hotspot\n // route matching.\n // `nonce` is included so an explicit refreshBootstrap() (e.g. after a survey\n // submit) refetches even though client/user/route are unchanged.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [client, enabled, nonce, origin, user?.id]);\n\n return state;\n}\n\n/** Late-capture probe cadence: ~10s of 1s ticks covers slow analytics init. */\nconst IDENTITY_CAPTURE_INTERVAL_MS = 1_000;\nconst IDENTITY_CAPTURE_MAX_ATTEMPTS = 10;\n\n/**\n * Keep probing for analytics-provider ids the bootstrap missed, and push the\n * first find through `identify`. One send per bootstrap: after a successful\n * capture the poll stops; the next bootstrap (new user/session) starts fresh.\n */\nfunction scheduleLateIdentityCapture(options: {\n client: SunboardRuntimeClient;\n identitiesRef: { readonly current: IdentitiesProp | undefined };\n origin?: string;\n sent: Record<string, string> | undefined;\n user: SunboardUser;\n}): () => void {\n const { client, identitiesRef, origin, sent, user } = options;\n let attempts = 0;\n\n const timer = setInterval(() => {\n attempts += 1;\n\n // Read the prop through the ref on every tick so flipping it to `false`\n // mid-poll stops the capture.\n if (identitiesRef.current === false) {\n clearInterval(timer);\n return;\n }\n\n const detected = resolveIdentities(identitiesRef.current);\n if (!detected || !hasUnsentIdentity(detected, sent)) {\n if (attempts >= IDENTITY_CAPTURE_MAX_ATTEMPTS) {\n clearInterval(timer);\n }\n return;\n }\n\n clearInterval(timer);\n client\n .identify({\n identities: detected,\n user: toRuntimeUser(user),\n ...(origin ? { origin } : {})\n })\n .catch((error: unknown) => {\n if (isDevEnvironment()) {\n console.warn(\"[sunboard] late identity capture failed\", error);\n }\n });\n }, IDENTITY_CAPTURE_INTERVAL_MS);\n\n return () => clearInterval(timer);\n}\n\nfunction hasUnsentIdentity(\n detected: Record<string, string>,\n sent: Record<string, string> | undefined\n): boolean {\n return Object.entries(detected).some(([provider, id]) => sent?.[provider] !== id);\n}\n\nfunction applyProgress(\n progress: RuntimeProgress,\n setSteps: Dispatch<SetStateAction<Set<string>>>,\n setTours: Dispatch<SetStateAction<Set<string>>>,\n setDismissedTooltips?: Dispatch<SetStateAction<Set<string>>>\n) {\n setSteps((current) => mergeKeys(current, progress.completedStepKeys));\n setTours((current) => mergeKeys(current, progress.completedTourKeys));\n setDismissedTooltips?.((current) =>\n mergeKeys(current, progress.dismissedTooltipKeys)\n );\n}\n\nfunction mergeKeys(current: Set<string>, incoming: string[]): Set<string> {\n if (incoming.length === 0) {\n return current;\n }\n\n const next = new Set(current);\n\n for (const key of incoming) {\n next.add(key);\n }\n\n if (next.size === current.size) {\n return current;\n }\n\n return next;\n}\n\nfunction isDevEnvironment(): boolean {\n if (typeof process === \"undefined\" || !process.env) {\n return false;\n }\n\n return process.env.NODE_ENV !== \"production\";\n}\n\nfunction toRuntimeUser(user: SunboardUser) {\n return {\n email: user.email ?? undefined,\n group: user.group ?? undefined,\n id: user.id,\n properties: user.properties\n };\n}\n\nfunction completedToursStorageKey(specKey: string, userId: string): string {\n return `sunboard:${specKey}:${userId}:completed-tours`;\n}\n\nfunction dismissedTooltipsStorageKey(specKey: string, userId: string): string {\n return `sunboard:${specKey}:${userId}:dismissed-tooltips`;\n}\n\nfunction getBrowserRoute(): string {\n if (typeof window === \"undefined\") {\n return \"/\";\n }\n\n return `${window.location.pathname}${window.location.search}`;\n}\n\nfunction getBrowserOrigin(): string | undefined {\n if (typeof window === \"undefined\") {\n return undefined;\n }\n\n return window.location.origin;\n}\n\nfunction readStoredKeys(storageKey: string): Set<string> {\n if (typeof window === \"undefined\") {\n return new Set();\n }\n\n try {\n const rawValue = window.localStorage.getItem(storageKey);\n const parsed = rawValue ? (JSON.parse(rawValue) as unknown) : [];\n\n if (!Array.isArray(parsed)) {\n return new Set();\n }\n\n return new Set(parsed.filter((value): value is string => typeof value === \"string\"));\n } catch {\n return new Set();\n }\n}\n\nfunction writeStoredKeys(storageKey: string, keys: Set<string>) {\n if (typeof window === \"undefined\") {\n return;\n }\n\n try {\n window.localStorage.setItem(storageKey, JSON.stringify([...keys].sort()));\n } catch {\n // Ignore storage failures; persistence should never break the host app.\n }\n}\n","import type { SunboardUser } from \"../hooks/sunboard-context\";\n\nconst TOKEN_PATTERN =\n /\\{\\{\\s*user\\.([\\w][\\w.]*)(?:\\s*\\|\\s*(?:\"([^\"]*)\"|'([^']*)'))?\\s*\\}\\}/g;\n\ntype FlatUser = Record<string, unknown>;\n\nfunction flattenUser(user: SunboardUser | null | undefined): FlatUser {\n if (!user) return {};\n const properties = (user.properties ?? {}) as Record<string, unknown>;\n const flat: FlatUser = { ...properties };\n flat.id = user.id;\n if (user.email !== undefined) flat.email = user.email;\n if (user.group !== undefined) flat.group = user.group;\n return flat;\n}\n\nfunction lookupPath(root: FlatUser, path: string): unknown {\n const segments = path.split(\".\");\n let current: unknown = root;\n for (const segment of segments) {\n if (current === null || current === undefined) return undefined;\n if (typeof current !== \"object\") return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n}\n\nfunction coerceValue(value: unknown): string | null {\n if (value === null || value === undefined) return null;\n if (typeof value === \"string\") return value.length > 0 ? value : null;\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n return null;\n}\n\nexport function interpolateTokens(\n template: string,\n user: SunboardUser | null | undefined\n): string {\n if (!template || !template.includes(\"{{\")) return template;\n const flat = flattenUser(user);\n return template.replace(\n TOKEN_PATTERN,\n (_match, path: string, doubleQuoted?: string, singleQuoted?: string) => {\n const resolved = coerceValue(lookupPath(flat, path));\n if (resolved !== null) return resolved;\n const fallback = doubleQuoted ?? singleQuoted;\n return fallback ?? \"\";\n }\n );\n}\n\nexport function extractUserTokens(template: string): string[] {\n if (!template || !template.includes(\"{{\")) return [];\n const paths: string[] = [];\n TOKEN_PATTERN.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = TOKEN_PATTERN.exec(template)) !== null) {\n const path = match[1];\n if (path) paths.push(path);\n }\n return paths;\n}\n","import { useContext } from \"react\";\nimport { SunboardContext, type SunboardContextValue } from \"./sunboard-context\";\n\nexport function useSunboard(): SunboardContextValue {\n const context = useContext(SunboardContext);\n\n if (!context) {\n throw new Error(\"useSunboard must be used within SunboardProvider.\");\n }\n\n return context;\n}\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { SunboardStep } from \"@sunboard/core\";\nimport { interpolateTokens } from \"../lib/interpolate-tokens\";\nimport { useSunboard } from \"./useSunboard\";\n\nexport type ChecklistViewStep = {\n key: string;\n title: string;\n description?: string;\n badge?: string;\n actionLabel?: string;\n /**\n * True when the user can complete this step by checking it off (the spec\n * default). False (`manual: false` in the spec) means the step completes\n * only through its instrumented rule; render its checkbox non-interactive.\n */\n manuallyCompletable: boolean;\n};\n\nexport type ChecklistCompletion = {\n title: string;\n subtitle?: string;\n message?: string;\n dismissAfterMs?: number;\n};\n\nexport type UseChecklistResult = {\n visible: boolean;\n title?: string;\n subtitle?: string;\n steps: ChecklistViewStep[];\n completedStepKeys: ReadonlySet<string>;\n completedCount: number;\n totalSteps: number;\n remainingCount: number;\n progress: number;\n isCompleted: (key: string) => boolean;\n hasAction: (step: ChecklistViewStep) => boolean;\n startStep: (step: ChecklistViewStep) => void;\n /**\n * Mark the step complete because the user checked it off. A no-op for\n * steps that are not manually completable or already complete.\n */\n completeStep: (step: ChecklistViewStep) => void;\n completion?: ChecklistCompletion;\n dismissCompletion: () => void;\n};\n\nfunction actionLabelFor(step: SunboardStep): string | undefined {\n if (step.action?.type === \"startTour\") return \"Start\";\n if (step.action?.type === \"openTooltip\") return \"Show me\";\n if (step.route) return \"Open\";\n return undefined;\n}\n\nfunction interpolateOptional(\n text: string | undefined,\n user: Parameters<typeof interpolateTokens>[1]\n): string | undefined {\n if (!text) return undefined;\n const interpolated = interpolateTokens(text, user);\n return interpolated || undefined;\n}\n\nexport function useChecklist(): UseChecklistResult {\n const {\n spec,\n user,\n loading,\n completedStepKeys,\n completedCount,\n totalSteps,\n startChecklistStep,\n completeChecklistStep\n } = useSunboard();\n\n const [dismissedKey, setDismissedKey] = useState<string | null>(null);\n\n // A guide renders whatever surfaces it actually declares, so the checklist\n // shows whenever the spec carries checklist steps — not based on the type.\n // (Surveys deliver through their own surface and never carry a checklist.)\n const hasChecklist = Boolean(spec && spec.checklist?.steps.length);\n const allCompleted = totalSteps > 0 && completedCount >= totalSteps;\n const ready = !loading && !!user && !!spec && hasChecklist;\n\n // The completion screen celebrates the *transition* from incomplete to\n // complete in this session — not the steady \"already done\" state. The server\n // already knows per-user completion via bootstrap, so a user who finished\n // on another device sees `allCompleted === true` from the first ready\n // render and we suppress the celebration. We only show it if we observed\n // them being incomplete first.\n //\n // Scoped to (spec, user) so switching either restarts the observation.\n const specKey = spec?.key ?? null;\n const userId = user?.id ?? null;\n const observationKey =\n ready && specKey && userId ? `${specKey}:${userId}` : null;\n const observationRef = useRef<{ key: string; sawIncomplete: boolean } | null>(\n null\n );\n if (observationKey && observationRef.current?.key !== observationKey) {\n observationRef.current = {\n key: observationKey,\n sawIncomplete: !allCompleted\n };\n } else if (observationKey && observationRef.current && !allCompleted) {\n observationRef.current.sawIncomplete = true;\n }\n const sawIncompleteFirst = observationRef.current?.sawIncomplete ?? false;\n\n const dismissed = dismissedKey !== null && dismissedKey === observationKey;\n\n const rawSteps = useMemo<SunboardStep[]>(\n () => spec?.checklist?.steps ?? [],\n [spec]\n );\n\n const title = useMemo(\n () => interpolateOptional(spec?.title, user ?? null),\n [spec?.title, user]\n );\n\n const subtitle = useMemo(\n () => interpolateOptional(spec?.subtitle, user ?? null),\n [spec?.subtitle, user]\n );\n\n const completion = useMemo<ChecklistCompletion | undefined>(() => {\n const raw = spec?.completion;\n if (!raw) return undefined;\n const interpolatedTitle = interpolateOptional(raw.title, user ?? null);\n if (!interpolatedTitle) return undefined;\n return {\n title: interpolatedTitle,\n subtitle: interpolateOptional(raw.subtitle, user ?? null),\n message: interpolateOptional(raw.message, user ?? null),\n dismissAfterMs: raw.dismissAfterMs\n };\n }, [spec?.completion, user]);\n\n const showingCompletion =\n ready && allCompleted && !!completion && sawIncompleteFirst && !dismissed;\n const visible = (ready && !allCompleted) || showingCompletion;\n\n const steps = useMemo<ChecklistViewStep[]>(() => {\n return rawSteps.map((step) => ({\n key: step.key,\n title: interpolateTokens(step.title, user ?? null),\n description: step.description\n ? interpolateTokens(step.description, user ?? null)\n : undefined,\n badge: step.badge\n ? interpolateTokens(step.badge, user ?? null)\n : undefined,\n actionLabel: actionLabelFor(step),\n manuallyCompletable: step.manual !== false\n }));\n }, [rawSteps, user]);\n\n const stepsByKey = useMemo(() => {\n const map = new Map<string, SunboardStep>();\n for (const step of rawSteps) {\n map.set(step.key, step);\n }\n return map;\n }, [rawSteps]);\n\n const remainingCount = Math.max(totalSteps - completedCount, 0);\n const progress =\n totalSteps > 0 ? Math.round((completedCount / totalSteps) * 100) : 0;\n\n const dismissCompletion = useCallback(() => {\n if (observationKey) {\n setDismissedKey(observationKey);\n }\n }, [observationKey]);\n\n return {\n visible,\n title,\n subtitle,\n steps,\n completedStepKeys,\n completedCount,\n totalSteps,\n remainingCount,\n progress,\n isCompleted: (key) => completedStepKeys.has(key),\n hasAction: (step) => step.actionLabel !== undefined,\n startStep: (step) => {\n const raw = stepsByKey.get(step.key);\n if (raw) {\n void startChecklistStep(raw);\n }\n },\n completeStep: (step) => {\n if (step.manuallyCompletable && !completedStepKeys.has(step.key)) {\n void completeChecklistStep(step.key);\n }\n },\n completion: showingCompletion ? completion : undefined,\n dismissCompletion\n };\n}\n","import { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { SurveyQuestionType } from \"@sunboard/core\";\nimport { interpolateTokens } from \"../lib/interpolate-tokens\";\nimport { useSunboard } from \"./useSunboard\";\n\nexport type SurveyViewOption = {\n value: string;\n label: string;\n};\n\nexport type SurveyViewQuestion = {\n key: string;\n prompt: string;\n type: SurveyQuestionType;\n required: boolean;\n options: SurveyViewOption[];\n};\n\nexport type SurveyViewStep = {\n title?: string;\n subtitle?: string;\n questions: SurveyViewQuestion[];\n};\n\nexport type UseSurveyResult = {\n visible: boolean;\n title?: string;\n subtitle?: string;\n /** Every question across all steps — for all-at-once renderers (the built-in modal). */\n questions: SurveyViewQuestion[];\n /** The authored step grouping (one question per step by default). */\n steps: SurveyViewStep[];\n /** Hook-owned navigation. */\n stepIndex: number;\n totalSteps: number;\n currentStep?: SurveyViewStep;\n progress: number; // 0..100, by step\n isFirstStep: boolean;\n isLastStep: boolean;\n /** True when the current step's required questions are answered. */\n canAdvance: boolean;\n /** Advance to the next step, or submit on the last step. */\n next: () => void;\n back: () => void;\n answers: Record<string, unknown>;\n setAnswer: (key: string, value: string) => void;\n toggleAnswer: (key: string, value: string) => void;\n isAnswered: (key: string) => boolean;\n /** True when every required question (across all steps) is answered. */\n canSubmit: boolean;\n submitting: boolean;\n error: string | null;\n submit: () => Promise<void>;\n};\n\nfunction interpolateOptional(\n text: string | undefined,\n user: Parameters<typeof interpolateTokens>[1]\n): string | undefined {\n if (!text) return undefined;\n const interpolated = interpolateTokens(text, user);\n return interpolated || undefined;\n}\n\nfunction answered(value: unknown): boolean {\n if (value === undefined || value === null) return false;\n if (typeof value === \"string\") return value.trim().length > 0;\n if (Array.isArray(value)) return value.length > 0;\n return true;\n}\n\nexport function useSurvey(): UseSurveyResult {\n const { spec, user, loading, submitSurvey } = useSunboard();\n\n const [answers, setAnswers] = useState<Record<string, unknown>>({});\n const [submitting, setSubmitting] = useState(false);\n const [submitted, setSubmitted] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [stepIndex, setStepIndex] = useState(0);\n\n const isSurvey = Boolean(spec && spec.type === \"survey\" && spec.survey);\n const ready = !loading && !!user && isSurvey;\n\n const title = useMemo(\n () => interpolateOptional(spec?.title, user ?? null),\n [spec?.title, user]\n );\n const subtitle = useMemo(\n () => interpolateOptional(spec?.subtitle, user ?? null),\n [spec?.subtitle, user]\n );\n\n const steps = useMemo<SurveyViewStep[]>(() => {\n const rawSteps = spec?.survey?.steps ?? [];\n return rawSteps.map((step) => ({\n title: interpolateOptional(step.title, user ?? null),\n subtitle: interpolateOptional(step.subtitle, user ?? null),\n questions: step.questions.map((question) => ({\n key: question.key,\n prompt: interpolateTokens(question.prompt, user ?? null),\n type: question.type,\n required: question.required,\n options: (question.options ?? []).map((option) => ({\n value: option.value,\n label: interpolateTokens(option.label, user ?? null)\n }))\n }))\n }));\n }, [spec?.survey, user]);\n\n const questions = useMemo<SurveyViewQuestion[]>(\n () => steps.flatMap((step) => step.questions),\n [steps]\n );\n\n // Restart at the first step whenever the question set changes (a new survey).\n const signature = questions.map((question) => question.key).join(\"|\");\n const signatureRef = useRef(signature);\n if (signatureRef.current !== signature) {\n signatureRef.current = signature;\n if (stepIndex !== 0) setStepIndex(0);\n }\n\n const totalSteps = steps.length;\n const safeIndex =\n totalSteps > 0 ? Math.min(stepIndex, totalSteps - 1) : 0;\n const currentStep = steps[safeIndex];\n\n const setAnswer = useCallback((key: string, value: string) => {\n setAnswers((current) => ({ ...current, [key]: value }));\n }, []);\n\n const toggleAnswer = useCallback((key: string, value: string) => {\n setAnswers((current) => {\n const existing = Array.isArray(current[key])\n ? (current[key] as string[])\n : [];\n const next = existing.includes(value)\n ? existing.filter((item) => item !== value)\n : [...existing, value];\n return { ...current, [key]: next };\n });\n }, []);\n\n const isAnswered = useCallback(\n (key: string) => answered(answers[key]),\n [answers]\n );\n\n const canSubmit = useMemo(() => {\n if (!ready || submitting) return false;\n return questions\n .filter((question) => question.required)\n .every((question) => answered(answers[question.key]));\n }, [answers, questions, ready, submitting]);\n\n const canAdvance = useMemo(() => {\n if (!currentStep) return false;\n return currentStep.questions\n .filter((question) => question.required)\n .every((question) => answered(answers[question.key]));\n }, [answers, currentStep]);\n\n const submit = useCallback(async () => {\n if (!canSubmit) return;\n setSubmitting(true);\n setError(null);\n\n const result = await submitSurvey(answers);\n setSubmitting(false);\n\n if (result.ok) {\n setSubmitted(true);\n return;\n }\n\n setError(\n result.reason === \"network-error\"\n ? \"Something went wrong. Please try again.\"\n : \"Survey is not ready.\"\n );\n }, [answers, canSubmit, submitSurvey]);\n\n const isLastStep = totalSteps === 0 || safeIndex >= totalSteps - 1;\n const isFirstStep = safeIndex === 0;\n\n const next = useCallback(() => {\n if (isLastStep) {\n void submit();\n } else {\n setStepIndex(safeIndex + 1);\n }\n }, [isLastStep, safeIndex, submit]);\n\n const back = useCallback(() => {\n setStepIndex((current) => Math.max(0, current - 1));\n }, []);\n\n return {\n visible: ready && !submitted,\n title,\n subtitle,\n questions,\n steps,\n stepIndex: safeIndex,\n totalSteps,\n currentStep,\n progress: totalSteps > 0 ? ((safeIndex + 1) / totalSteps) * 100 : 0,\n isFirstStep,\n isLastStep,\n canAdvance,\n next,\n back,\n answers,\n setAnswer,\n toggleAnswer,\n isAnswered,\n canSubmit,\n submitting,\n error,\n submit\n };\n}\n","\nexport const CheckIcon = () => {\n return <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"\n className=\"lucide lucide-check-icon lucide-check\"><path d=\"M20 6 9 17l-5-5\" /></svg>\n}\n\nexport const ListIcon = () => {\n return <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"\n className=\"lucide lucide-list-icon lucide-list\"><path d=\"M3 12h.01\" /><path d=\"M3 18h.01\" /><path d=\"M3 6h.01\" /><path d=\"M8 12h13\" /><path d=\"M8 18h13\" /><path d=\"M8 6h13\" /></svg>\n}\n\nexport const XIcon = () => {\n return <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"\n className=\"lucide lucide-x-icon lucide-x\"><path d=\"M18 6 6 18\" /><path d=\"m6 6 12 12\" /></svg>\n}\n\nexport const ChevronRightIcon = () => {\n return <svg xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\"\n stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\"\n className=\"lucide lucide-chevron-right-icon lucide-chevron-right\"><path d=\"m9 18 6-6-6-6\" /></svg>\n}\n","import { CheckIcon, ChevronRightIcon } from \"../icons\";\nimport type { ChecklistViewStep } from \"../hooks/useChecklist\";\n\ntype ChecklistStepProps = {\n completed: boolean;\n onComplete: () => void;\n onStart: () => void;\n step: ChecklistViewStep;\n};\n\nexport function ChecklistStep({\n completed,\n onComplete,\n onStart,\n step\n}: ChecklistStepProps) {\n const hasAction = step.actionLabel !== undefined;\n const checkable = step.manuallyCompletable && !completed;\n\n // The checkbox and the action area are sibling interactive elements (a\n // button cannot nest inside a button), so checking a step off never also\n // fires the step's action.\n const status = checkable ? (\n <button\n className=\"sunboard-step-status\"\n type=\"button\"\n onClick={onComplete}\n aria-label={`Mark ${step.title} complete`}\n >\n <CheckIcon />\n </button>\n ) : (\n <span\n className=\"sunboard-step-status\"\n data-locked={!completed && !step.manuallyCompletable ? \"true\" : undefined}\n aria-label={\n completed\n ? \"Completed\"\n : step.manuallyCompletable\n ? \"Incomplete\"\n : \"Completes automatically\"\n }\n >\n {completed ? <CheckIcon /> : null}\n </span>\n );\n\n const content = (\n <div className=\"sunboard-step-content\">\n <div className=\"sunboard-step-heading\">\n <h3 className=\"sunboard-step-title\">{step.title}</h3>\n {step.badge ? (\n <span className=\"sunboard-step-badge\">{step.badge}</span>\n ) : null}\n </div>\n\n {step.description ? (\n <p className=\"sunboard-step-description\">{step.description}</p>\n ) : null}\n </div>\n );\n\n return (\n <li className=\"sunboard-step\" data-completed={completed}>\n <div\n className=\"sunboard-step-row\"\n data-interactive={hasAction || checkable ? \"true\" : undefined}\n >\n {status}\n {hasAction ? (\n <button\n className=\"sunboard-step-main\"\n type=\"button\"\n onClick={onStart}\n aria-label={`${step.actionLabel} ${step.title}`}\n >\n {content}\n <span className=\"sunboard-step-arrow\" aria-hidden=\"true\">\n <ChevronRightIcon />\n </span>\n </button>\n ) : (\n content\n )}\n </div>\n </li>\n );\n}\n","import { useMemo } from \"react\";\nimport { interpolateTokens } from \"../lib/interpolate-tokens\";\nimport { useSunboard } from \"./useSunboard\";\n\nexport function useInterpolated(text: string): string;\nexport function useInterpolated(text: string | undefined): string | undefined;\nexport function useInterpolated(text: string | undefined): string | undefined {\n const { user } = useSunboard();\n return useMemo(() => {\n if (text === undefined) return undefined;\n return interpolateTokens(text, user);\n }, [text, user]);\n}\n","import { useEffect, useState } from \"react\";\n\nexport type TargetElementState = {\n element: HTMLElement | null;\n timedOut: boolean;\n};\n\nexport function useTargetElement(\n selector: string | null,\n enabled: boolean,\n timeoutMs = 5_000\n): TargetElementState {\n const [state, setState] = useState<TargetElementState>({\n element: null,\n timedOut: false\n });\n\n useEffect(() => {\n if (!enabled || !selector) {\n setState({ element: null, timedOut: false });\n return;\n }\n\n let cancelled = false;\n const startedAt = Date.now();\n\n const findTarget = () => {\n if (cancelled) {\n return;\n }\n\n const element = document.querySelector(selector);\n\n if (element instanceof HTMLElement) {\n setState({ element, timedOut: false });\n return;\n }\n\n if (Date.now() - startedAt >= timeoutMs) {\n setState({ element: null, timedOut: true });\n return;\n }\n\n window.setTimeout(findTarget, 100);\n };\n\n setState({ element: null, timedOut: false });\n findTarget();\n\n return () => {\n cancelled = true;\n };\n }, [enabled, selector, timeoutMs]);\n\n return state;\n}\n","import {\n FloatingPortal,\n autoUpdate,\n offset,\n useFloating\n} from \"@floating-ui/react\";\nimport { useEffect } from \"react\";\nimport type { SunboardHotspot } from \"@sunboard/core\";\nimport { useInterpolated } from \"../hooks/useInterpolated\";\nimport { useSunboard } from \"../hooks/useSunboard\";\nimport { useTargetElement } from \"../hooks/useTargetElement\";\n\ntype HotspotProps = {\n hotspot: SunboardHotspot;\n hotspotKey: string;\n};\n\nconst HOTSPOT_RADIUS_PX = 9;\n\nexport function SunboardHotspots() {\n const { visibleHotspots } = useSunboard();\n\n return (\n <>\n {visibleHotspots.map(({ key, hotspot }) => (\n <Hotspot hotspot={hotspot} hotspotKey={key} key={key} />\n ))}\n </>\n );\n}\n\nfunction Hotspot({ hotspot, hotspotKey }: HotspotProps) {\n const { startTour } = useSunboard();\n const label = useInterpolated(hotspot.label);\n const target = useTargetElement(hotspot.target, true);\n const { refs, floatingStyles } = useFloating({\n placement: hotspot.placement,\n strategy: \"fixed\",\n middleware: [offset(-HOTSPOT_RADIUS_PX)],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (!target.element) {\n return;\n }\n\n refs.setReference(target.element);\n }, [refs, target.element]);\n\n if (!target.element) {\n return null;\n }\n\n return (\n <FloatingPortal>\n <button\n aria-label={label ?? `Start ${hotspot.action.tour} tour`}\n className=\"sunboard-hotspot\"\n data-pulse={hotspot.pulse}\n data-sunboard-hotspot={hotspotKey}\n onClick={() => {\n void startTour(hotspot.action.tour);\n }}\n ref={refs.setFloating}\n style={floatingStyles}\n type=\"button\"\n >\n <span className=\"sunboard-hotspot-dot\" />\n </button>\n </FloatingPortal>\n );\n}\n","import {\n arrow,\n autoUpdate,\n FloatingArrow,\n FloatingPortal,\n flip,\n offset,\n shift,\n useFloating\n} from \"@floating-ui/react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { SunboardTooltip } from \"@sunboard/core\";\nimport { useInterpolated } from \"../hooks/useInterpolated\";\nimport { useSunboard } from \"../hooks/useSunboard\";\nimport { useTargetElement } from \"../hooks/useTargetElement\";\n\ntype TooltipProps = {\n tooltip: SunboardTooltip;\n tooltipKey: string;\n requested: boolean;\n onTargetMissing: () => void;\n};\n\n/**\n * Renders at most one tooltip: the first visible candidate whose target\n * resolves. A candidate whose selector never appears is skipped for the rest\n * of the session (without recording a dismissal — the user rejected nothing),\n * so one stale selector can't block the tooltips behind it.\n */\nexport function SunboardTooltips() {\n const { visibleTooltips } = useSunboard();\n const [skippedKeys, setSkippedKeys] = useState<Set<string>>(() => new Set());\n\n const active =\n visibleTooltips.find(({ key }) => !skippedKeys.has(key)) ?? null;\n\n if (!active) {\n return null;\n }\n\n return (\n <Tooltip\n key={active.key}\n onTargetMissing={() =>\n setSkippedKeys((current) => new Set(current).add(active.key))\n }\n requested={active.requested}\n tooltip={active.tooltip}\n tooltipKey={active.key}\n />\n );\n}\n\nfunction Tooltip({\n tooltip,\n tooltipKey,\n requested,\n onTargetMissing\n}: TooltipProps) {\n const { dismissTooltip, markTooltipSeen, startTour } = useSunboard();\n const arrowRef = useRef<SVGSVGElement | null>(null);\n const title = useInterpolated(tooltip.title);\n const body = useInterpolated(tooltip.body);\n const actionLabel = useInterpolated(tooltip.actionLabel) ?? \"Show me how\";\n const target = useTargetElement(tooltip.target, true);\n const { context, refs, floatingStyles, update } = useFloating({\n placement: tooltip.placement,\n middleware: [\n offset(12),\n flip(),\n shift({ padding: 12 }),\n arrow({ element: arrowRef })\n ],\n whileElementsMounted: autoUpdate\n });\n\n useEffect(() => {\n if (!target.timedOut) {\n return;\n }\n\n onTargetMissing();\n // `onTargetMissing` intentionally excluded: it is an inline closure whose\n // identity churns per render, and the skip must fire exactly once.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [target.timedOut]);\n\n useEffect(() => {\n if (!target.element) {\n return;\n }\n\n refs.setReference(target.element);\n void update();\n // The tooltip reached the user's eyes — this is the reach denominator for\n // \"did the nudge move the goal\".\n markTooltipSeen(tooltipKey);\n }, [markTooltipSeen, refs, target.element, tooltipKey, update]);\n\n useEffect(() => {\n const element = target.element;\n\n if (!element) {\n return;\n }\n\n // Clicking the target means the user did the thing the tooltip pointed\n // at: the nudge worked, retire it. Deferred (same as tour advancement)\n // so the app's own click handler runs before the dismissal re-renders.\n const dismissOnTargetClick = () => {\n window.setTimeout(() => {\n void dismissTooltip(tooltipKey, { via: \"target\" });\n }, 0);\n };\n\n element.addEventListener(\"click\", dismissOnTargetClick);\n\n return () => {\n element.removeEventListener(\"click\", dismissOnTargetClick);\n };\n }, [dismissTooltip, target.element, tooltipKey]);\n\n if (!target.element) {\n return null;\n }\n\n return (\n <FloatingPortal>\n <section\n aria-label={title}\n className=\"sunboard-tooltip\"\n data-sunboard-tooltip={tooltipKey}\n data-requested={requested}\n ref={refs.setFloating}\n role=\"dialog\"\n style={floatingStyles}\n >\n <FloatingArrow\n className=\"sunboard-tooltip-arrow\"\n context={context}\n fill=\"var(--sunboard-tour-background)\"\n ref={arrowRef}\n stroke=\"var(--sunboard-tour-border)\"\n strokeWidth={1}\n tipRadius={2}\n />\n <button\n aria-label={`Dismiss ${title}`}\n className=\"sunboard-tooltip-close\"\n onClick={() => void dismissTooltip(tooltipKey)}\n type=\"button\"\n >\n x\n </button>\n <h2 className=\"sunboard-tooltip-title\">{title}</h2>\n {body ? <p className=\"sunboard-tooltip-body\">{body}</p> : null}\n {tooltip.action ? (\n <div className=\"sunboard-tooltip-actions\">\n <button\n className=\"sunboard-tooltip-action\"\n onClick={() => {\n // Taking the action counts as engagement AND retires the\n // tooltip; the tour then owns the screen.\n void dismissTooltip(tooltipKey, { via: \"action\" });\n void startTour(tooltip.action!.tour);\n }}\n type=\"button\"\n >\n {actionLabel}\n </button>\n </div>\n ) : null}\n </section>\n </FloatingPortal>\n );\n}\n","import {\n arrow,\n FloatingArrow,\n FloatingPortal,\n flip,\n offset,\n shift,\n useFloating\n} from \"@floating-ui/react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { routeMatches } from \"../adapters/routes\";\nimport { useInterpolated } from \"../hooks/useInterpolated\";\nimport { useSunboard } from \"../hooks/useSunboard\";\nimport { useTargetElement } from \"../hooks/useTargetElement\";\n\nexport function SunboardTour() {\n const { activeTour, advanceTour, dismissTour, route } = useSunboard();\n const arrowRef = useRef<SVGSVGElement | null>(null);\n const [spotlightRect, setSpotlightRect] = useState<DOMRect | null>(null);\n const routeReady = routeMatches(activeTour?.step.route, route ?? \"/\");\n const target = useTargetElement(\n activeTour?.step.target ?? null,\n Boolean(activeTour) && routeReady,\n 1_000\n );\n const { context, refs, floatingStyles, update } = useFloating({\n placement: activeTour?.step.placement ?? \"bottom\",\n middleware: [\n offset(16),\n flip(),\n shift({ padding: 12 }),\n arrow({ element: arrowRef })\n ]\n });\n\n useEffect(() => {\n if (!activeTour || !routeReady || !target.timedOut) {\n return;\n }\n\n // The target is missing and the user didn't reject anything, so close\n // programmatically without recording a dismissal signal.\n void dismissTour({ silent: true });\n }, [activeTour, dismissTour, routeReady, target.timedOut]);\n\n useEffect(() => {\n if (!activeTour || !target.element) {\n return;\n }\n\n refs.setReference(target.element);\n target.element.scrollIntoView({ block: \"center\", inline: \"center\" });\n void update();\n }, [activeTour, refs, target.element, update]);\n\n useEffect(() => {\n if (!activeTour || !target.element) {\n setSpotlightRect(null);\n return;\n }\n\n const updateSpotlight = () => {\n setSpotlightRect(target.element?.getBoundingClientRect() ?? null);\n };\n\n updateSpotlight();\n window.addEventListener(\"resize\", updateSpotlight);\n window.addEventListener(\"scroll\", updateSpotlight, true);\n\n target.element.setAttribute(\"data-sunboard-tour-target\", \"true\");\n\n return () => {\n window.removeEventListener(\"resize\", updateSpotlight);\n window.removeEventListener(\"scroll\", updateSpotlight, true);\n target.element?.removeAttribute(\"data-sunboard-tour-target\");\n setSpotlightRect(null);\n };\n }, [activeTour, target.element]);\n\n useEffect(() => {\n if (!activeTour || !target.element) {\n return;\n }\n\n const advanceOnTargetClick = () => {\n window.setTimeout(() => {\n void advanceTour();\n }, 0);\n };\n\n target.element.addEventListener(\"click\", advanceOnTargetClick);\n\n return () => {\n target.element?.removeEventListener(\"click\", advanceOnTargetClick);\n };\n }, [activeTour, advanceTour, target.element]);\n\n const tourName = useInterpolated(activeTour?.name);\n const stepTitle = useInterpolated(activeTour?.step.title);\n const stepBody = useInterpolated(activeTour?.step.body);\n\n if (!activeTour) {\n return null;\n }\n\n if (!routeReady || !target.element) {\n return null;\n }\n\n const isLastStep = activeTour.stepIndex === activeTour.totalSteps - 1;\n\n return (\n <FloatingPortal>\n <SunboardTourScrim rect={spotlightRect} />\n <section\n aria-label={`${tourName} tour step`}\n className=\"sunboard-tour\"\n ref={refs.setFloating}\n role=\"dialog\"\n style={floatingStyles}\n >\n <FloatingArrow\n className=\"sunboard-tour-arrow\"\n context={context}\n fill=\"var(--sunboard-tour-background)\"\n ref={arrowRef}\n stroke=\"var(--sunboard-tour-border)\"\n strokeWidth={1}\n tipRadius={2}\n />\n <div className=\"sunboard-tour-meta\">\n {activeTour.stepIndex + 1} / {activeTour.totalSteps}\n </div>\n <h2 className=\"sunboard-tour-title\">{stepTitle}</h2>\n {stepBody ? (\n <p className=\"sunboard-tour-body\">{stepBody}</p>\n ) : null}\n <div className=\"sunboard-tour-actions\">\n <button\n className=\"sunboard-tour-secondary\"\n onClick={() => void dismissTour()}\n type=\"button\"\n >\n Dismiss\n </button>\n <button\n className=\"sunboard-tour-primary\"\n onClick={() => void advanceTour()}\n type=\"button\"\n >\n {isLastStep ? \"Finish\" : \"Next\"}\n </button>\n </div>\n </section>\n </FloatingPortal>\n );\n}\n\nfunction SunboardTourScrim({ rect }: { rect: DOMRect | null }) {\n if (!rect) {\n return <div className=\"sunboard-tour-scrim\" />;\n }\n\n const padding = 8;\n const radius = 12;\n const left = Math.max(rect.left - padding, 0);\n const top = Math.max(rect.top - padding, 0);\n const width = rect.width + padding * 2;\n const height = rect.height + padding * 2;\n const maskId = \"sunboard-tour-spotlight-mask\";\n\n return (\n <svg\n aria-hidden=\"true\"\n className=\"sunboard-tour-scrim sunboard-tour-spotlight\"\n focusable=\"false\"\n >\n <defs>\n <mask id={maskId}>\n <rect fill=\"white\" height=\"100%\" width=\"100%\" x=\"0\" y=\"0\" />\n <rect\n fill=\"black\"\n height={height}\n rx={radius}\n ry={radius}\n width={width}\n x={left}\n y={top}\n />\n </mask>\n </defs>\n <rect\n fill=\"var(--sunboard-overlay-color)\"\n height=\"100%\"\n mask={`url(#${maskId})`}\n width=\"100%\"\n x=\"0\"\n y=\"0\"\n />\n </svg>\n );\n}\n","import { useEffect, useState } from \"react\";\nimport { useChecklist } from \"../hooks/useChecklist\";\nimport { useSurvey } from \"../hooks/useSurvey\";\nimport { ListIcon, XIcon } from \"../icons\";\nimport { ChecklistStep } from \"./ChecklistStep\";\nimport { SunboardHotspots } from \"./SunboardHotspots\";\nimport { SunboardTooltips } from \"./SunboardTooltips\";\nimport { SunboardTour } from \"./SunboardTour\";\n\nexport function SunboardChecklist() {\n const [open, setOpen] = useState(true);\n const {\n visible,\n title,\n subtitle,\n steps,\n completedCount,\n totalSteps,\n remainingCount,\n progress,\n isCompleted,\n startStep,\n completeStep,\n completion,\n dismissCompletion\n } = useChecklist();\n\n // Auto-dismiss the completion screen after the spec-author-specified delay.\n // Lives in the widget rather than the hook so custom checklists can choose\n // their own timing UX (e.g. dismiss on tab change) without inheriting ours.\n useEffect(() => {\n if (!completion?.dismissAfterMs) return;\n const handle = window.setTimeout(dismissCompletion, completion.dismissAfterMs);\n return () => window.clearTimeout(handle);\n }, [completion, dismissCompletion]);\n\n if (!visible || !title) {\n return null;\n }\n\n if (completion) {\n return (\n <aside\n className=\"sunboard-root sunboard-root-completion\"\n aria-label={`${title} complete`}\n role=\"status\"\n aria-live=\"polite\"\n >\n <button\n className=\"sunboard-close sunboard-completion-close\"\n type=\"button\"\n onClick={dismissCompletion}\n aria-label=\"Dismiss completion message\"\n >\n <XIcon />\n </button>\n <div className=\"sunboard-completion\">\n <div className=\"sunboard-completion-check\" aria-hidden=\"true\">\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"5 12 10 17 19 8\" />\n </svg>\n </div>\n {completion.subtitle ? (\n <p className=\"sunboard-completion-subtitle\">{completion.subtitle}</p>\n ) : null}\n <h2 className=\"sunboard-completion-title\">{completion.title}</h2>\n {completion.message ? (\n <p className=\"sunboard-completion-message\">{completion.message}</p>\n ) : null}\n </div>\n </aside>\n );\n }\n\n if (!open) {\n return (\n <button\n className=\"sunboard-launcher\"\n type=\"button\"\n onClick={() => setOpen(true)}\n aria-label={`Open ${title} checklist, ${remainingCount} tasks remaining`}\n >\n {remainingCount > 0 ? (\n <span className=\"sunboard-launcher-badge\">{remainingCount}</span>\n ) : null}\n <ListIcon />\n </button>\n );\n }\n\n return (\n <aside className=\"sunboard-root\" aria-label={`${title} checklist`}>\n <div className=\"sunboard-header\">\n <div>\n {subtitle ? <p className=\"sunboard-eyebrow\">{subtitle}</p> : null}\n <h2 className=\"sunboard-title\">{title}</h2>\n </div>\n <div className=\"sunboard-header-actions\">\n <p\n className=\"sunboard-progress-count\"\n aria-label=\"Checklist progress\"\n >\n {completedCount} / {totalSteps}\n </p>\n <button\n className=\"sunboard-close\"\n type=\"button\"\n onClick={() => setOpen(false)}\n aria-label={`Close ${title} checklist`}\n >\n <XIcon />\n </button>\n </div>\n </div>\n\n <div\n className=\"sunboard-progress\"\n role=\"progressbar\"\n aria-label={`${title} progress`}\n aria-valuemin={0}\n aria-valuemax={totalSteps}\n aria-valuenow={completedCount}\n >\n <div\n className=\"sunboard-progress-fill\"\n style={{ width: `${progress}%` }}\n />\n </div>\n\n <ol className=\"sunboard-step-list\">\n {steps.map((step) => (\n <ChecklistStep\n completed={isCompleted(step.key)}\n key={step.key}\n onComplete={() => completeStep(step)}\n onStart={() => startStep(step)}\n step={step}\n />\n ))}\n </ol>\n </aside>\n );\n}\n\nexport function SunboardSurvey() {\n const {\n visible,\n title,\n subtitle,\n currentStep,\n stepIndex,\n totalSteps,\n progress,\n isFirstStep,\n isLastStep,\n canAdvance,\n canSubmit,\n next,\n back,\n answers,\n setAnswer,\n toggleAnswer,\n submitting,\n error\n } = useSurvey();\n\n if (!visible || !title || !currentStep) {\n return null;\n }\n\n const showProgress = totalSteps > 1;\n\n return (\n <div className=\"sunboard-survey-overlay\">\n <section\n className=\"sunboard-survey-card\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={`${title} survey`}\n >\n <div className=\"sunboard-survey-head\">\n {subtitle ? <p className=\"sunboard-eyebrow\">{subtitle}</p> : null}\n <h2 className=\"sunboard-title\">{title}</h2>\n </div>\n\n {showProgress ? (\n <div className=\"sunboard-survey-progress-row\">\n <p className=\"sunboard-survey-stepcount\">\n Step {stepIndex + 1} of {totalSteps}\n </p>\n <div\n className=\"sunboard-progress\"\n role=\"progressbar\"\n aria-label={`${title} progress`}\n aria-valuemin={1}\n aria-valuemax={totalSteps}\n aria-valuenow={stepIndex + 1}\n >\n <div\n className=\"sunboard-progress-fill\"\n style={{ width: `${progress}%` }}\n />\n </div>\n </div>\n ) : null}\n\n <form\n className=\"sunboard-survey-form\"\n onSubmit={(event) => {\n event.preventDefault();\n next();\n }}\n >\n {currentStep.title ? (\n <p className=\"sunboard-survey-step-title\">{currentStep.title}</p>\n ) : null}\n\n <ol className=\"sunboard-survey-questions\">\n {currentStep.questions.map((question) => (\n <li className=\"sunboard-survey-question\" key={question.key}>\n <p className=\"sunboard-survey-prompt\">\n {question.prompt}\n {question.required ? (\n <span aria-hidden=\"true\" className=\"sunboard-survey-required\">\n {\" *\"}\n </span>\n ) : null}\n </p>\n\n {question.type === \"text\" ? (\n <input\n className=\"sunboard-survey-input\"\n type=\"text\"\n value={\n typeof answers[question.key] === \"string\"\n ? (answers[question.key] as string)\n : \"\"\n }\n required={question.required}\n aria-label={question.prompt}\n onChange={(event) =>\n setAnswer(question.key, event.target.value)\n }\n />\n ) : (\n <div\n className=\"sunboard-survey-options\"\n role=\"group\"\n aria-label={question.prompt}\n >\n {question.options.map((option) => {\n const selected =\n question.type === \"multi-select\"\n ? Array.isArray(answers[question.key]) &&\n (answers[question.key] as string[]).includes(\n option.value\n )\n : answers[question.key] === option.value;\n\n return (\n <button\n className=\"sunboard-survey-option\"\n type=\"button\"\n key={option.value}\n aria-pressed={selected}\n data-selected={selected ? \"true\" : \"false\"}\n onClick={() =>\n question.type === \"multi-select\"\n ? toggleAnswer(question.key, option.value)\n : setAnswer(question.key, option.value)\n }\n >\n {option.label}\n </button>\n );\n })}\n </div>\n )}\n </li>\n ))}\n </ol>\n\n {error ? (\n <p className=\"sunboard-survey-error\" role=\"alert\">\n {error}\n </p>\n ) : null}\n\n <div className=\"sunboard-survey-nav\">\n {!isFirstStep ? (\n <button\n className=\"sunboard-survey-back\"\n type=\"button\"\n onClick={back}\n >\n Back\n </button>\n ) : (\n <span />\n )}\n <button\n className=\"sunboard-survey-submit\"\n type=\"submit\"\n disabled={isLastStep ? !canSubmit : !canAdvance}\n >\n {isLastStep ? (submitting ? \"Submitting…\" : \"Finish\") : \"Continue\"}\n </button>\n </div>\n </form>\n </section>\n </div>\n );\n}\n\nexport const Sunboard = Object.assign(SunboardChecklist, {\n Checklist: SunboardChecklist,\n Survey: SunboardSurvey,\n Hotspots: SunboardHotspots,\n Tooltips: SunboardTooltips,\n Tour: SunboardTour\n});\n","import { useCallback, useMemo } from \"react\";\nimport type { SunboardPlacement } from \"@sunboard/core\";\nimport { interpolateTokens } from \"../lib/interpolate-tokens\";\nimport { useSunboard } from \"./useSunboard\";\n\nexport type TooltipView = {\n key: string;\n title: string;\n body?: string;\n /** CSS selector of the element the tooltip points at. */\n target: string;\n placement: SunboardPlacement;\n /** True when a tour action is attached; `engage` starts it. */\n hasAction: boolean;\n actionLabel?: string;\n /** True when the user asked for this tooltip via a checklist step. */\n requested: boolean;\n};\n\nexport type UseTooltipsResult = {\n /**\n * Tooltips that qualify for the current route (undismissed, or explicitly\n * requested). Render ONE at a time — the first whose target you can anchor.\n */\n tooltips: TooltipView[];\n /** Report that a tooltip is actually on screen (deduped per session). */\n markSeen: (key: string) => void;\n /** Close without acting — the tooltip never shows again. */\n dismiss: (key: string) => void;\n /** Take the tooltip's action: starts its tour and retires the tooltip. */\n engage: (key: string) => void;\n /**\n * Report that the user clicked the tooltip's target element: the nudge\n * worked, so this retires the tooltip and records the engagement.\n */\n markTargetClicked: (key: string) => void;\n};\n\n/**\n * Headless counterpart of `<SunboardTooltips>`: the same visibility, seen,\n * dismissal, and engagement semantics with rendering left to the host.\n */\nexport function useTooltips(): UseTooltipsResult {\n const {\n user,\n visibleTooltips,\n markTooltipSeen,\n dismissTooltip,\n startTour\n } = useSunboard();\n\n const tooltips = useMemo<TooltipView[]>(\n () =>\n visibleTooltips.map(({ key, tooltip, requested }) => ({\n key,\n title: interpolateTokens(tooltip.title, user ?? null),\n body: tooltip.body\n ? interpolateTokens(tooltip.body, user ?? null)\n : undefined,\n target: tooltip.target,\n placement: tooltip.placement,\n hasAction: Boolean(tooltip.action),\n actionLabel: tooltip.actionLabel\n ? interpolateTokens(tooltip.actionLabel, user ?? null)\n : undefined,\n requested\n })),\n [user, visibleTooltips]\n );\n\n const engage = useCallback(\n (key: string) => {\n const entry = visibleTooltips.find((candidate) => candidate.key === key);\n\n void dismissTooltip(key, { via: \"action\" });\n\n if (entry?.tooltip.action) {\n void startTour(entry.tooltip.action.tour);\n }\n },\n [dismissTooltip, startTour, visibleTooltips]\n );\n\n return {\n tooltips,\n markSeen: markTooltipSeen,\n dismiss: (key) => {\n void dismissTooltip(key);\n },\n engage,\n markTargetClicked: (key) => {\n void dismissTooltip(key, { via: \"target\" });\n }\n };\n}\n"],"mappings":";;;;;;;;AAEA,eAAsB,qBACpB,KACA,UACe;AACf,KAAI,UAAU;AACZ,QAAM,SAAS,IAAI;AACnB;;AAGF,KAAI,OAAO,WAAW,YACpB,QAAO,SAAS,OAAO,IAAI;;;;;ACQ/B,SAAgB,kBACd,MACoC;AACpC,KAAI,SAAS,MACX;CAIF,MAAM,SAAS;EAAE,GADA,2BAA2B;EACd,GAAG;EAAM;AAEvC,QAAO,OAAO,KAAK,OAAO,CAAC,SAAS,IAAI,SAAS;;AAGnD,SAAS,4BAAoD;CAC3D,MAAMA,aAAqC,EAAE;AAE7C,KAAI,OAAO,WAAW,YACpB,QAAO;CAGT,MAAM,YAAY,i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