@guidelytech/sdk-core 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/authoring.ts","../src/snapshot.ts","../src/storage.ts","../src/autocapture.ts","../src/context.ts","../src/heatmap.ts","../src/errors.ts","../src/emitter.ts","../src/frequency.ts","../src/http.ts","../src/messenger-api.ts","../src/navigation.ts","../src/page-tracking.ts","../src/queue.ts","../src/load-recorder.ts"],"sourcesContent":["/**\n * @guidelytech/sdk-core — framework-independent Guidely browser SDK.\n *\n * SSR-safe to import: nothing touches `window` at module scope. Create a client in the browser\n * with {@link createGuidely} (or `Guidely.init` for script-tag installs).\n */\nimport { GuidelyClient, createGuidely, SDK_VERSION } from \"./client\";\n\nexport { GuidelyClient, createGuidely, SDK_NAME, SDK_VERSION, DEFAULT_API_URL } from \"./client\";\nexport type { GuidelyOptions, GuidelyEvents, GuidelyEventName, GuidelyUser, GuidelyAccount, GuidelyEnvironment, ConsentState, ChecklistProgressState, PersistedState, SessionState, GuideStepInfo } from \"./types\";\nexport { isFrequencyEligible, isExclusiveGuide, areMutuallyExclusive, isWithinSchedule } from \"./frequency\";\nexport type { GuideLocalState } from \"./frequency\";\nexport { detectDevice, buildContext } from \"./context\";\nexport type { DeviceInfo, ContextInput } from \"./context\";\nexport { EventQueue } from \"./queue\";\nexport type { EventQueueOptions } from \"./queue\";\nexport { watchNavigation } from \"./navigation\";\nexport { createStorage, KEYS } from \"./storage\";\nexport type { KeyValueStore, StorageKind } from \"./storage\";\nexport { AUTHORING_PARAM, HEARTBEAT_MS } from \"./authoring\";\nexport { captureSnapshot } from \"./snapshot\";\nexport type { AuthoringIncomingMessage, AuthoringOutgoingMessage } from \"./authoring\";\nexport type { AppSnapshot, PublishedGuide, SdkConfigResponse, SdkEvent, TargetingContext, GuideConfig, GuideStep, AutocaptureSettings, ExceptionProperties, StackFrame } from \"@guidelytech/shared\";\nexport type { ClickProperties } from \"./autocapture\";\nexport type { PageLeaveInfo } from \"./page-tracking\";\n\n/** Global-style API used by the script-tag embed: `Guidely.init(options)` / `Guidely.get()`. */\nexport const Guidely = {\n init: (options: Parameters<typeof GuidelyClient.init>[0]) => GuidelyClient.init(options),\n get: () => GuidelyClient.get(),\n createGuidely,\n version: SDK_VERSION,\n};\n\nexport default Guidely;\n","import { evaluateRules, randomId, rolloutBucket, sanitizeProperties, supportsPlatform, type ExceptionProperties } from \"@guidelytech/shared/runtime\";\nimport {\n type AutocaptureSettings,\n type ChecklistTask,\n type EventName,\n type IdentifyRequest,\n type IdentifyResponse,\n type PublishedGuide,\n type ResourceCenterArticle,\n type SdkConfigResponse,\n type SdkEvent,\n type TargetingContext,\n} from \"@guidelytech/shared\";\nimport {\n destroyHost,\n isChecklistComplete,\n renderChecklist,\n renderResourceCenter,\n renderSurvey,\n runGuide,\n urlMatches,\n waitForTarget,\n type ChecklistWidget,\n type GuideController,\n type ResourceCenterWidget,\n type SurveyWidget,\n} from \"@guidelytech/guide-runtime\";\nimport { createScope } from \"@guidelytech/guide-runtime\";\nimport type { MessengerTab, MessengerWidget } from \"@guidelytech/guide-runtime/messenger\";\nimport { AuthoringBridge } from \"./authoring\";\nimport { DEFAULT_MASK_SELECTORS, describeClick, interactiveElement, isIgnoredElement, RageClickDetector, validSelectors } from \"./autocapture\";\nimport { buildContext, detectDevice } from \"./context\";\nimport { HeatmapBuffer, heatmapPoint, movementBin } from \"./heatmap\";\nimport { errorEventToException, exceptionFromError, ExceptionThrottle, isGuidelyException, rejectionToException } from \"./errors\";\nimport { Emitter } from \"./emitter\";\nimport { areMutuallyExclusive, isExclusiveGuide, isFrequencyEligible, isWithinSchedule, type GuideLocalState } from \"./frequency\";\nimport { Api, postWithRetry } from \"./http\";\nimport { createMessengerTransport, forgetConversations } from \"./messenger-api\";\nimport { watchNavigation } from \"./navigation\";\nimport { PageTracker } from \"./page-tracking\";\nimport { EventQueue } from \"./queue\";\nimport { loadRecorder } from \"./load-recorder\";\nimport type { ReplayController, ReplayRecordingConfig } from \"./replay\";\nimport { createStorage, KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\nimport type { ChecklistProgressState, ConsentState, GuidelyAccount, GuidelyEvents, GuidelyOptions, GuidelyUser, PersistedState, SessionState } from \"./types\";\n\nexport const SDK_NAME = \"@guidelytech/sdk-core\";\nexport const SDK_VERSION = \"0.5.0\";\nexport const DEFAULT_API_URL = \"https://api.guidely.app\";\n\ntype EvalReason = \"ready\" | \"navigation\" | \"event\" | \"click\" | \"visible\" | \"identify\" | \"after_guide\" | \"timer\" | \"manual\";\ninterface EvalDetail {\n eventName?: string;\n target?: Element | null;\n guideId?: string;\n endedGuide?: PublishedGuide;\n newAudiences?: Set<string>;\n}\n\ninterface ActiveGuide {\n guide: PublishedGuide;\n controller?: GuideController;\n survey?: SurveyWidget;\n scope?: { destroy(): void };\n manual: boolean;\n startUrl: string;\n}\n\ninterface QueuedGuide {\n guide: PublishedGuide;\n url: string;\n pageScoped: boolean;\n}\n\nconst PAGE_SCOPED = new Set([\"page_load\", \"url_match\", \"element_click\", \"element_visible\", \"delay\"]);\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst MAX_SESSION_EXCEPTIONS = 100;\n\nfunction isBrowser(): boolean {\n return typeof window !== \"undefined\" && typeof document !== \"undefined\";\n}\n\nfunction nowIso(): string {\n return new Date().toISOString();\n}\n\nfunction emptyState(): PersistedState {\n return { guides: {}, checklists: {}, surveysSubmitted: [], audienceIds: [] };\n}\n\nfunction newSession(now = Date.now()): SessionState {\n return { id: `s_${randomId(16)}`, startedAt: new Date(now).toISOString(), shownGuides: [], events: [], lastActivityAt: now };\n}\n\n/**\n * Framework-independent Guidely client. Create one per page with {@link createGuidely} or\n * {@link GuidelyClient.init}; adapters (`@guidelytech/react`, `@guidelytech/svelte`) wrap it.\n */\nexport class GuidelyClient {\n readonly options: Readonly<Required<Pick<GuidelyOptions, \"projectId\" | \"environment\" | \"apiUrl\" | \"analytics\" | \"consent\" | \"storage\" | \"configRefreshMs\" | \"pollIntervalMs\" | \"debug\">>> & GuidelyOptions;\n private readonly api: Api;\n private readonly store: KeyValueStore;\n private readonly sessionStore: KeyValueStore;\n private readonly emitter: Emitter<GuidelyEvents>;\n private readonly queue: EventQueue;\n private config: SdkConfigResponse | null = null;\n private etag: string | null = null;\n private anonymousId: string;\n private user: GuidelyUser | null = null;\n private state: PersistedState;\n private session: SessionState;\n private consent: ConsentState;\n private readyPromise: Promise<void> | null = null;\n private resolveReady: (() => void) | null = null;\n private isReady = false;\n private destroyed = false;\n private active: ActiveGuide | null = null;\n private queued: QueuedGuide[] = [];\n private widgets = new Map<string, { destroy(): void; checklist?: ChecklistWidget; scope?: { destroy(): void }; controller?: GuideController; manual?: boolean }>();\n private resourceCenter: ResourceCenterWidget | null = null;\n private resourceCenterScope: { destroy(): void } | null = null;\n private messenger: MessengerWidget | null = null;\n private messengerScope: { destroy(): void } | null = null;\n private messengerLoading: Promise<MessengerWidget | null> | null = null;\n private cleanups: Array<() => void> = [];\n private timers = new Set<ReturnType<typeof setTimeout>>();\n private visibilityObservers = new Map<string, () => void>();\n private firedDelays = new Set<string>();\n private firstVisit: boolean;\n private lastUrl: string;\n private authoring: AuthoringBridge | null = null;\n private lastAudiences = new Set<string>();\n /** Set once the app calls identify()/reset(); bootstrap then leaves identity alone instead of re-identifying. */\n private identitySettled = false;\n // Product analytics (autocapture, error tracking, session replay)\n /** Created once the recorder chunk has loaded (it carries the replay controller). */\n private replay: ReplayController | null = null;\n private replayLoading = false;\n private readonly pageTracker = new PageTracker();\n private readonly rage = new RageClickDetector();\n private readonly heatmap = new HeatmapBuffer();\n private readonly exceptionThrottle = new ExceptionThrottle();\n /** Exceptions seen before the config was loaded (reported once it is known whether the server accepts them). */\n private earlyExceptions: Array<[ExceptionProperties, Record<string, unknown> | undefined]> = [];\n private initialPageViewSent = false;\n private pageViewUrl: string | null = null;\n private pageLeft = false;\n\n constructor(options: GuidelyOptions) {\n if (!isBrowser()) throw new Error(\"[Guidely] createGuidely() must be called in the browser. Create the client inside useEffect / onMount, or use the framework adapters.\");\n if (!options || !options.projectId) throw new Error(\"[Guidely] `projectId` (your environment public key, e.g. pk_dev_…) is required.\");\n this.options = {\n ...options,\n environment: options.environment ?? (options.projectId.startsWith(\"pk_prod\") ? \"production\" : options.projectId.startsWith(\"pk_stag\") ? \"staging\" : \"development\"),\n apiUrl: options.apiUrl ?? DEFAULT_API_URL,\n analytics: options.analytics ?? true,\n consent: options.consent ?? \"granted\",\n storage: options.storage ?? \"local\",\n configRefreshMs: options.configRefreshMs ?? 5 * 60 * 1000,\n pollIntervalMs: options.pollIntervalMs ?? 1000,\n debug: options.debug ?? false,\n };\n this.consent = this.options.consent;\n this.emitter = new Emitter<GuidelyEvents>((err) => this.reportError(err));\n this.api = new Api(this.options.apiUrl, this.options.projectId, options.fetch);\n this.store = createStorage(this.options.storage);\n this.sessionStore = this.options.storage === \"memory\" ? this.store : createStorage(\"session\");\n this.anonymousId = this.store.get(KEYS.anon) || \"\";\n if (!this.anonymousId) {\n this.anonymousId = `anon_${randomId(20)}`;\n this.store.set(KEYS.anon, this.anonymousId);\n }\n this.firstVisit = !this.store.get(KEYS.seen);\n this.store.set(KEYS.seen, nowIso());\n this.state = { ...emptyState(), ...readJson<Partial<PersistedState>>(this.store, KEYS.state(this.options.projectId), {}) };\n this.user = readJson<GuidelyUser | null>(this.store, KEYS.user(this.options.projectId), null);\n const session = readJson<SessionState | null>(this.sessionStore, KEYS.session, null);\n this.session = session && session.id ? session : newSession();\n this.persistSession();\n this.lastUrl = location.href;\n this.lastAudiences = new Set(this.state.audienceIds);\n this.queue = new EventQueue({\n store: this.store,\n storageKey: KEYS.queue(this.options.projectId),\n enabled: () => this.analyticsEnabled(),\n send: async (events) => {\n const res = await this.api.post<{ accepted: number }>(\"/events\", { events, sentAt: nowIso(), sdk: { name: SDK_NAME, version: SDK_VERSION } }, { keepalive: true });\n return { ok: res.ok, retry: !(res.status >= 400 && res.status < 500 && res.status !== 429) };\n },\n beacon: (events) => this.api.beacon(\"/events\", { events, sentAt: nowIso(), sdk: { name: SDK_NAME, version: SDK_VERSION } }),\n onError: (err) => this.reportError(err),\n });\n if (options.user) this.user = { ...options.user };\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /** Loads config (cache first, then network), wires listeners and evaluates triggers. Idempotent. */\n init(): Promise<void> {\n if (this.readyPromise) return this.readyPromise;\n this.readyPromise = new Promise<void>((resolve) => {\n this.resolveReady = resolve;\n });\n void this.bootstrap();\n return this.readyPromise;\n }\n\n /** Resolves once the client is ready (alias of `init()`). */\n ready(): Promise<void> {\n return this.init();\n }\n\n private async bootstrap(): Promise<void> {\n this.wireErrorListeners();\n try {\n const cached = readJson<SdkConfigResponse | null>(this.store, KEYS.config(this.options.projectId), null);\n this.etag = this.store.get(KEYS.etag(this.options.projectId));\n if (cached && cached.guides) this.config = webOnly(cached);\n await this.fetchConfig();\n if (this.destroyed) return;\n this.wireListeners();\n if (!this.identitySettled) {\n if (this.options.user) await this.identify(this.options.user.id, this.options.user.traits, this.options.user.account);\n else if (this.user?.id) await this.identify(this.user.id, this.user.traits, this.user.account);\n }\n if (this.destroyed) return;\n this.isReady = true;\n if (this.config) this.emitter.emit(\"ready\", this.config);\n this.resolveReady?.();\n this.renderPersistentWidgets();\n this.resumeActiveGuide();\n this.evaluate(\"ready\");\n if (!this.options.disableAuthoring) this.maybeStartAuthoring();\n this.pageTracker.start(location.href);\n this.touchSession(); // a page load is activity: rotate an expired session before capture starts\n this.syncCapture();\n } catch (err) {\n this.reportError(err);\n this.isReady = true;\n this.resolveReady?.();\n }\n }\n\n private async fetchConfig(): Promise<boolean> {\n try {\n const res = await this.api.get<SdkConfigResponse>(\"/config\", { etag: this.etag, params: { platform: \"web\" } });\n if (res.status === 304) return true;\n if (res.ok && res.data && Array.isArray(res.data.guides)) {\n this.config = webOnly(res.data);\n this.etag = res.etag;\n writeJson(this.store, KEYS.config(this.options.projectId), res.data);\n if (res.etag) this.store.set(KEYS.etag(this.options.projectId), res.etag);\n else this.store.remove(KEYS.etag(this.options.projectId));\n this.emitter.emit(\"config\", res.data);\n this.log(\"config loaded\", res.data.configVersion, `${res.data.guides.length} guides`);\n return true;\n }\n this.reportError(new Error(`[Guidely] config request failed (${res.status})${this.config ? \"; using cached config\" : \"\"}`));\n return false;\n } catch (err) {\n this.reportError(new Error(`[Guidely] config request failed: ${err instanceof Error ? err.message : String(err)}${this.config ? \"; using cached config\" : \"\"}`));\n return false;\n }\n }\n\n private wireListeners(): void {\n const doc = document;\n const win = window;\n this.cleanups.push(watchNavigation((url) => this.handleNavigation(url)));\n const onClick = (e: Event) => this.handleDocumentClick(e);\n doc.addEventListener(\"click\", onClick, true);\n this.cleanups.push(() => doc.removeEventListener(\"click\", onClick, true));\n const onVisibility = () => {\n const hidden = doc.visibilityState === \"hidden\";\n this.pageTracker.setHidden(hidden);\n if (!hidden) return;\n this.replay?.flushOnHide();\n this.queue.flushSync();\n };\n const onPageHide = () => {\n this.flushHeatmap();\n if (!this.pageLeft) this.leavePage(null);\n this.pageLeft = true;\n this.replay?.flushOnHide();\n this.queue.flushSync();\n };\n const onPageShow = (e: PageTransitionEvent) => {\n if (!e.persisted || !this.pageLeft) return;\n this.pageLeft = false;\n this.pageTracker.start(location.href);\n };\n // Activity keeps the session alive (and rotates it after the inactivity timeout).\n let lastScroll = 0;\n const onScroll = () => {\n const now = Date.now();\n if (now - lastScroll < 250) return;\n lastScroll = now;\n this.pageTracker.measureScroll();\n this.touchSession();\n };\n const onKey = () => this.touchSession();\n // Mouse-movement heatmap: one sample (the latest position) per 200ms while the pointer moves; fine pointers only.\n let move: MouseEvent | null = null;\n let moveTimer: ReturnType<typeof setTimeout> | null = null;\n const onMove = (e: MouseEvent) => {\n move = e;\n moveTimer ??= setTimeout(() => {\n moveTimer = null;\n if (move) this.sampleMove(move);\n move = null;\n }, 200);\n };\n if (win.matchMedia?.(\"(pointer: fine)\").matches) {\n doc.addEventListener(\"mousemove\", onMove, { passive: true });\n this.cleanups.push(() => {\n doc.removeEventListener(\"mousemove\", onMove);\n if (moveTimer) clearTimeout(moveTimer);\n });\n }\n doc.addEventListener(\"visibilitychange\", onVisibility);\n win.addEventListener(\"pagehide\", onPageHide);\n win.addEventListener(\"pageshow\", onPageShow);\n win.addEventListener(\"scroll\", onScroll, { passive: true });\n doc.addEventListener(\"keydown\", onKey, true);\n this.cleanups.push(() => {\n doc.removeEventListener(\"visibilitychange\", onVisibility);\n win.removeEventListener(\"pagehide\", onPageHide);\n win.removeEventListener(\"pageshow\", onPageShow);\n win.removeEventListener(\"scroll\", onScroll);\n doc.removeEventListener(\"keydown\", onKey, true);\n });\n const refresh = setInterval(() => void this.refresh(), this.options.configRefreshMs);\n this.cleanups.push(() => clearInterval(refresh));\n // Idle re-check: DOM can change without navigation (lazy content), so re-arm element-visibility\n // observers for eligible guides and drain the queue.\n const poll = setInterval(() => {\n if (!this.isReady || !this.config || this.authoring?.isActive() || doc.visibilityState === \"hidden\") return;\n const url = location.href;\n const ctx = this.getContext();\n for (const guide of this.config.guides) {\n if (guide.config.trigger.type === \"element_visible\" && guide.config.trigger.value) this.armVisibility(guide, ctx, url);\n }\n this.drainQueue(url, ctx);\n }, Math.max(250, this.options.pollIntervalMs));\n this.cleanups.push(() => clearInterval(poll));\n const onMessage = (e: MessageEvent) => this.authoring?.handleMessage(e);\n win.addEventListener(\"message\", onMessage);\n this.cleanups.push(() => win.removeEventListener(\"message\", onMessage));\n }\n\n /** Uncaught errors + unhandled rejections; attached before the config loads so boot errors are kept. */\n private wireErrorListeners(): void {\n const win = window;\n const onError = (e: ErrorEvent) => this.captureGlobalException(errorEventToException(e));\n const onRejection = (e: PromiseRejectionEvent) => this.captureGlobalException(rejectionToException(e));\n win.addEventListener(\"error\", onError);\n win.addEventListener(\"unhandledrejection\", onRejection);\n this.cleanups.push(() => {\n win.removeEventListener(\"error\", onError);\n win.removeEventListener(\"unhandledrejection\", onRejection);\n });\n }\n\n /** Re-fetches the published config and re-evaluates triggers. */\n async refresh(): Promise<void> {\n if (this.destroyed) return;\n const before = this.config?.configVersion;\n await this.fetchConfig();\n if (this.config && this.config.configVersion !== before) {\n this.renderPersistentWidgets();\n this.evaluate(\"ready\");\n }\n this.syncCapture();\n }\n\n /** Tears everything down: guides, widgets, listeners, timers, host element. Re-init is allowed via a new client. */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.active?.controller?.destroy();\n this.active?.survey?.destroy();\n this.active?.scope?.destroy();\n this.active = null;\n this.queued = [];\n this.widgets.forEach((w) => w.destroy());\n this.widgets.clear();\n this.resourceCenter?.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n this.destroyMessenger();\n this.visibilityObservers.forEach((stop) => stop());\n this.visibilityObservers.clear();\n this.timers.forEach((t) => clearTimeout(t));\n this.timers.clear();\n this.cleanups.splice(0).forEach((fn) => fn());\n this.authoring?.stop();\n this.authoring = null;\n this.replay?.destroy();\n this.replay = null;\n this.queue.flushSync();\n this.queue.destroy();\n this.emitter.clear();\n destroyHost();\n if (current === this) current = null;\n }\n\n // ---------------------------------------------------------------------------\n // Identity\n // ---------------------------------------------------------------------------\n\n /** Identifies the end user and loads server-held state (audiences, guide history, checklist progress). */\n async identify(userId: string, traits?: Record<string, unknown>, account?: GuidelyAccount): Promise<void> {\n if (this.destroyed) return;\n this.identitySettled = true;\n this.user = { id: String(userId), traits: { ...(this.user?.id === String(userId) ? this.user.traits : {}), ...(traits || {}) }, account: account ?? (this.user?.id === String(userId) ? this.user.account : undefined) };\n writeJson(this.store, KEYS.user(this.options.projectId), this.user);\n this.enqueue(\"identify\", { properties: { traits: sanitizeProperties(this.user.traits) } });\n await this.syncIdentify();\n this.emitter.emit(\"identify\", { userId: this.user.id, anonymousId: this.anonymousId });\n if (this.isReady) this.evaluate(\"identify\");\n }\n\n private async syncIdentify(): Promise<void> {\n const body: IdentifyRequest = { anonymousId: this.anonymousId, userId: this.user?.id ?? null, traits: this.user?.traits, account: this.user?.account ? { id: this.user.account.id, traits: this.user.account.traits } : null, sessionId: this.session.id, url: this.collectUrls() ? location.href : undefined };\n const res = await postWithRetry<IdentifyResponse>(this.api, \"/identify\", body, 2);\n if (res?.ok && res.data) this.mergeServerState(res.data);\n }\n\n private mergeServerState(data: IdentifyResponse): void {\n const guides = { ...this.state.guides };\n for (const [id, s] of Object.entries(data.guideState || {})) {\n const local = guides[id];\n guides[id] = {\n impressions: Math.max(local?.impressions ?? 0, s.impressions ?? 0),\n completedAt: local?.completedAt ?? s.completedAt ?? null,\n dismissedAt: local?.dismissedAt ?? s.dismissedAt ?? null,\n lastShownAt: local?.lastShownAt ?? s.lastShownAt ?? null,\n };\n }\n const checklists = { ...this.state.checklists };\n for (const [id, p] of Object.entries(data.checklistProgress || {})) {\n const local = checklists[id];\n checklists[id] = {\n completedTaskIds: Array.from(new Set([...(local?.completedTaskIds ?? []), ...(p.completedTaskIds ?? [])])),\n completedAt: local?.completedAt ?? p.completedAt ?? null,\n dismissedAt: local?.dismissedAt ?? p.dismissedAt ?? null,\n };\n }\n this.state = {\n guides,\n checklists,\n surveysSubmitted: Array.from(new Set([...this.state.surveysSubmitted, ...(data.surveysSubmitted || [])])),\n audienceIds: data.audienceIds || [],\n firstSeenAt: this.state.firstSeenAt ?? data.firstSeenAt,\n };\n if (data.firstSeenAt && Date.now() - Date.parse(data.firstSeenAt) > 60_000) this.firstVisit = false;\n this.persistState();\n this.widgets.forEach((w, id) => {\n const g = this.findGuide(id);\n if (w.checklist && g) w.checklist.setProgress(this.getChecklistProgress(g.id));\n });\n }\n\n /** Sets or replaces the account (company/organisation) for the current user. */\n async setAccount(account: GuidelyAccount): Promise<void> {\n if (!this.user) {\n this.user = { id: \"\", account };\n writeJson(this.store, KEYS.user(this.options.projectId), this.user);\n return;\n }\n await this.identify(this.user.id, undefined, account);\n }\n\n /** Merges additional traits into the current user. */\n async updateTraits(traits: Record<string, unknown>): Promise<void> {\n if (!this.user?.id) {\n this.user = { id: \"\", traits: { ...(this.user?.traits || {}), ...traits } };\n return;\n }\n await this.identify(this.user.id, traits, this.user.account);\n }\n\n /** Forgets the user: new anonymous id, cleared local guide/checklist state, triggers re-evaluated. */\n reset(): void {\n this.identitySettled = true;\n this.stopGuide();\n this.user = null;\n this.store.remove(KEYS.user(this.options.projectId));\n this.anonymousId = `anon_${randomId(20)}`;\n this.store.set(KEYS.anon, this.anonymousId);\n this.state = emptyState();\n this.persistState();\n this.session = newSession();\n this.persistSession();\n this.sessionStore.remove(KEYS.active);\n this.replay?.stop(); // the recording belongs to the previous user; restarted below when eligible\n this.syncCapture();\n this.lastAudiences = new Set();\n this.firedDelays.clear();\n this.widgets.forEach((w) => w.destroy());\n this.widgets.clear();\n // Conversations belong to the previous user: forget their tokens and rebuild the messenger.\n forgetConversations(this.store, this.options.projectId);\n this.destroyMessenger();\n this.emitter.emit(\"identify\", { userId: null, anonymousId: this.anonymousId });\n if (this.isReady) {\n this.renderPersistentWidgets();\n this.evaluate(\"identify\");\n }\n }\n\n // ---------------------------------------------------------------------------\n // Events\n // ---------------------------------------------------------------------------\n\n /** Updates consent at runtime (`granted` flushes buffered events; `denied` drops them). */\n setConsent(consent: ConsentState): void {\n this.consent = consent;\n if (consent === \"denied\") this.queue.clear();\n else if (consent === \"granted\") void this.queue.flush();\n if (consent !== \"granted\") this.replay?.stop({ discard: true });\n this.syncCapture();\n }\n\n private analyticsEnabled(): boolean {\n return this.options.analytics && this.consent === \"granted\" && (this.config?.settings?.analyticsEnabled ?? true);\n }\n\n private collectUrls(): boolean {\n return this.config?.settings?.collectUrls ?? true;\n }\n\n private enqueue(name: EventName, extra: Partial<SdkEvent> = {}): SdkEvent | null {\n if (this.consent === \"denied\" || !this.options.analytics) return null;\n if (name !== \"page_leave\" && name !== \"heatmap\") this.touchSession();\n const event: SdkEvent = {\n eventId: randomId(24),\n name,\n occurredAt: nowIso(),\n anonymousId: this.anonymousId,\n userId: this.user?.id || null,\n accountId: this.user?.account?.id || null,\n sessionId: this.session.id,\n url: this.collectUrls() ? location.href : undefined,\n ...extra,\n };\n if (extra.properties) event.properties = sanitizeProperties(extra.properties);\n this.queue.enqueue(event);\n this.replay?.addCustomEvent(\"guidely\", { name, customName: event.customName, guideId: event.guideId });\n this.emitter.emit(\"track\", event);\n return event;\n }\n\n /** Tracks a custom event. Events drive `event` triggers, `advanceOn: \"event\"` steps and checklist tasks. */\n track(name: string, properties?: Record<string, unknown>): void {\n if (this.destroyed || !name) return;\n if (!this.session.events.includes(name)) {\n this.session.events.push(name);\n this.persistSession();\n }\n this.enqueue(\"custom\", { customName: name.slice(0, 120), properties: properties ?? {} });\n this.customListeners.get(name)?.forEach((cb) => {\n try {\n cb();\n } catch (err) {\n this.reportError(err);\n }\n });\n this.completeChecklistTasksBy(\"event\", name);\n if (this.isReady) this.evaluate(\"event\", { eventName: name });\n }\n\n /** Records a page view and re-evaluates triggers. Called automatically on SPA navigation. */\n page(url: string = location.href): void {\n if (this.destroyed) return;\n this.leavePage(url);\n this.trackPageView(url);\n this.handleNavigation(url, true);\n }\n\n private readonly customListeners = new Map<string, Set<() => void>>();\n private readonly eventBus = {\n on: (name: string, cb: () => void) => {\n let set = this.customListeners.get(name);\n if (!set) {\n set = new Set();\n this.customListeners.set(name, set);\n }\n set.add(cb);\n return () => {\n set?.delete(cb);\n };\n },\n };\n\n private handleNavigation(url: string, explicit = false): void {\n if (this.destroyed) return;\n const changed = url !== this.lastUrl;\n this.lastUrl = url;\n if (!explicit && changed) {\n this.leavePage(url);\n this.trackPageView(url);\n }\n this.completeChecklistTasksBy(\"url_visited\", url);\n this.active?.controller?.resume();\n if (this.active?.controller) {\n const st = this.active.controller.getState();\n if (st.status === \"running\" && !this.active.manual) {\n const g = this.active.guide;\n if (g.config.urlPatterns.length && !g.config.urlPatterns.some((p) => urlMatches(p, url))) this.active.controller.destroy();\n }\n }\n // Banners and hotspots are page-scoped too: close the ones whose URL patterns no longer match.\n this.widgets.forEach((w, id) => {\n if (!w.controller || w.manual) return;\n const g = this.findGuide(id);\n if (g?.config.urlPatterns.length && !g.config.urlPatterns.some((p) => urlMatches(p, url))) w.controller.destroy();\n });\n this.firedDelays.clear();\n if (this.isReady) this.evaluate(\"navigation\");\n if (changed) void this.queue.flush();\n }\n\n private handleDocumentClick(e: Event): void {\n const target = e.target as Element | null;\n if (!target || typeof target.closest !== \"function\") return;\n this.autocaptureClick(e as MouseEvent, target);\n this.completeChecklistTasksBy(\"click\", target);\n if (this.isReady) this.evaluate(\"click\", { target });\n }\n\n // ---------------------------------------------------------------------------\n // Product analytics: sessions, page views, clicks, errors, session replay\n // ---------------------------------------------------------------------------\n\n /** Records activity; starts a new session after `sessionTimeoutMinutes` of inactivity or 24h. */\n private touchSession(): void {\n const now = Date.now();\n const s = this.session;\n const timeout = Math.max(1, this.config?.settings?.sessionTimeoutMinutes ?? 30) * 60_000;\n const last = s.lastActivityAt ?? now;\n if (now - last > timeout || now - (Date.parse(s.startedAt) || now) > DAY_MS) return this.rotateSession(now);\n if (now - (s.lastActivityAt ?? 0) < 1000) return;\n s.lastActivityAt = now;\n this.persistSession();\n }\n\n private rotateSession(now: number): void {\n this.session = newSession(now);\n this.persistSession();\n this.log(\"session rotated\", this.session.id);\n if (this.replay?.activeSessionId) this.replay.stop();\n this.syncReplay();\n }\n\n /** Autocapture, error tracking and replay need analytics on, consent granted and no authoring session. */\n private captureAllowed(): boolean {\n return !this.destroyed && this.analyticsEnabled() && !this.authoring?.isActive();\n }\n\n /** A capability is on when the project enables it (absent on old servers → off) and no option turns it off. */\n private autocaptureOn(key: keyof AutocaptureSettings): boolean {\n const o = this.options.autocapture;\n return !!this.config?.settings?.autocapture?.[key] && o !== false && !(typeof o === \"object\" && o[key] === false) && this.captureAllowed();\n }\n\n /** Page views on SPA navigation predate autocapture: only an explicit opt-out stops them. */\n private pageviewsOn(): boolean {\n const o = this.options.autocapture;\n return this.config?.settings?.autocapture?.pageviews !== false && o !== false && !(typeof o === \"object\" && o.pageviews === false) && !this.authoring?.isActive();\n }\n\n private trackPageView(url: string): void {\n if (url === this.pageViewUrl || !this.pageviewsOn()) return;\n this.pageViewUrl = url;\n this.touchSession();\n const collect = this.collectUrls();\n const device = detectDevice(navigator.userAgent, window.innerWidth);\n const props: Record<string, unknown> = { deviceType: device.type, browser: device.browser, os: device.os, screenWidth: window.screen?.width, viewportWidth: window.innerWidth };\n if (collect) {\n props.path = pathOf(url);\n props.title = (document.title || \"\").slice(0, 200);\n const ref = !this.session.pageViews ? externalReferrer() : undefined;\n if (ref) props.referrer = ref;\n }\n this.session.pageViews = (this.session.pageViews ?? 0) + 1;\n this.persistSession();\n this.enqueue(\"page_view\", { url: collect ? url : undefined, properties: props });\n }\n\n /** Emits `page_leave` for the page being left and starts measuring `nextUrl` (null: page unload). */\n private leavePage(nextUrl: string | null): void {\n const t = this.pageTracker;\n if (!t.url || t.url === nextUrl) return;\n this.flushHeatmap();\n if (!this.pageLeft && this.autocaptureOn(\"pageLeave\")) {\n const info = t.leave();\n const collect = this.collectUrls();\n this.enqueue(\"page_leave\", { url: collect ? info.url : undefined, properties: { ...(collect ? { path: pathOf(info.url) } : {}), durationMs: info.durationMs, scrollDepth: info.scrollDepth } });\n }\n if (nextUrl !== null) {\n t.start(nextUrl);\n this.pageLeft = false;\n }\n }\n\n private autocaptureClick(e: MouseEvent, target: Element): void {\n const clicks = this.autocaptureOn(\"clicks\");\n const rage = this.autocaptureOn(\"rageClicks\");\n const heat = this.autocaptureOn(\"heatmaps\");\n if ((!clicks && !rage && !heat) || isIgnoredElement(target)) return;\n this.touchSession();\n const el = interactiveElement(target);\n const opts = { mask: this.maskSelector(), maskAll: this.maskAllText(), collectUrls: this.collectUrls() };\n if (clicks && el) this.enqueue(\"click\", { properties: { ...describeClick(el, e, opts) } });\n const count = this.rage.add(e.pageX ?? 0, e.pageY ?? 0, Date.now());\n if (rage && count) this.enqueue(\"rage_click\", { properties: { ...describeClick(el ?? target, e, opts), count } });\n if (!heat) return;\n const url = location.href;\n if (this.heatmap.url !== url) this.flushHeatmap();\n if (this.heatmap.add(url, heatmapPoint(el ?? target, e, this.rage.burst > 0), this.rage.burst)) this.flushHeatmap();\n }\n\n /** Bins one pointer sample into the heatmap buffer. Not session activity. */\n private sampleMove(e: MouseEvent): void {\n const target = e.target as Element | null;\n if (document.visibilityState === \"hidden\" || !target?.closest || !this.autocaptureOn(\"mouseMovement\") || isIgnoredElement(target)) return;\n const url = location.href;\n if (this.heatmap.url !== url) this.flushHeatmap();\n if (this.heatmap.move(url, movementBin(interactiveElement(target) ?? target, e))) this.flushHeatmap();\n }\n\n /** Sends the buffered heatmap clicks as one `heatmap` event attributed to the page they happened on. */\n private flushHeatmap(): void {\n const batch = this.heatmap.take();\n if (!batch || !this.captureAllowed()) return;\n const collect = this.collectUrls();\n const de = document.documentElement;\n const properties = { path: collect ? pathOf(batch.url) : undefined, viewportWidth: window.innerWidth, viewportHeight: window.innerHeight, pageHeight: Math.max(de.scrollHeight, document.body?.scrollHeight || 0), points: batch.points };\n if (!collect) delete properties.path;\n this.enqueue(\"heatmap\", { url: collect ? batch.url : undefined, properties });\n }\n\n private captureGlobalException(props: ExceptionProperties | null): void {\n if (!props || isGuidelyException(props) || this.options.captureErrors === false) return;\n if (!this.config) {\n if (this.earlyExceptions.length < 10) this.earlyExceptions.push([props, undefined]);\n return;\n }\n this.sendException(props);\n }\n\n /**\n * Reports a caught error as an `exception` event (`source: \"manual\"`, `handled: true`), grouped\n * into an issue on the Errors page. Extra properties are attached to the occurrence. Needs the\n * project's error tracking on (plus analytics + consent); `captureErrors: false` does not stop it.\n */\n captureException(error: unknown, properties?: Record<string, unknown>): void {\n if (this.destroyed) return;\n const props = exceptionFromError(error, \"manual\", true);\n if (!this.config) {\n if (this.earlyExceptions.length < 10) this.earlyExceptions.push([props, properties]);\n return;\n }\n this.sendException(props, properties);\n }\n\n private sendException(props: ExceptionProperties, extra?: Record<string, unknown>): void {\n // Error tracking off (or a server that predates it and would reject the event): nothing is sent.\n if (!this.config?.settings?.errorTracking?.enabled || !this.captureAllowed() || !this.exceptionThrottle.allow(props)) return;\n const count = this.session.exceptions ?? 0;\n if (count >= MAX_SESSION_EXCEPTIONS) return;\n const properties: Record<string, unknown> = { ...props };\n if (this.options.release) properties.release = String(this.options.release).slice(0, 100);\n for (const [k, v] of Object.entries(extra ?? {})) if (!(k in properties)) properties[k] = v;\n this.enqueue(\"exception\", { properties });\n this.session.exceptions = count + 1;\n this.persistSession();\n }\n\n private maskSelector(): string {\n return validSelectors([...DEFAULT_MASK_SELECTORS, ...(this.config?.settings?.maskSelectors || []), ...(this.options.maskSelectors || [])]).join(\",\");\n }\n\n private maskAllText(): boolean {\n const o = this.options.sessionReplay;\n return !!this.config?.settings?.replay?.maskAllText || (typeof o === \"object\" && !!o.maskAllText);\n }\n\n /** Replay settings for this installation, or null when the project (or an option) disables replay. */\n private replayConfig(): { sampleRate: number; config: ReplayRecordingConfig } | null {\n const r = this.config?.settings?.replay;\n const o = this.options.sessionReplay;\n if (!r?.enabled || o === false) return null;\n const opt = typeof o === \"object\" ? o : {};\n const extra = opt.blockSelectors || [];\n return {\n sampleRate: r.sampleRate ?? 100,\n config: {\n recordConsole: r.recordConsole !== false,\n maskTextSelector: this.maskAllText() ? \"*\" : this.maskSelector(),\n blockSelector: validSelectors([\"[data-guidely-block]\", ...(r.blockSelectors || []), ...extra]).join(\",\"),\n network: r.recordNetwork && opt.recordNetwork !== false ? { payloads: !!r.recordNetworkPayloads && opt.recordNetworkPayloads !== false, apiUrl: this.options.apiUrl, mask: opt.maskNetworkRequest } : null,\n },\n };\n }\n\n /** Reconciles capture with the current config / consent / authoring state. Idempotent. */\n private syncCapture(): void {\n if (!this.isReady || this.destroyed) return;\n if (this.config && !this.initialPageViewSent && this.config.settings?.autocapture) {\n this.initialPageViewSent = true;\n this.trackPageView(location.href);\n }\n if (this.config) {\n for (const [props, extra] of this.earlyExceptions.splice(0)) {\n if (props.handled) this.sendException(props, extra);\n else this.captureGlobalException(props);\n }\n }\n this.syncReplay();\n }\n\n private syncReplay(): void {\n const cfg = this.isReady && this.captureAllowed() ? this.replayConfig() : null;\n if (cfg && this.session.replay === undefined) {\n this.session.replay = rolloutBucket(this.session.id, \"replay\") < cfg.sampleRate;\n this.persistSession();\n }\n if (!cfg || !this.session.replay) {\n if (this.replay?.activeSessionId) this.replay.stop({ discard: !this.analyticsEnabled() });\n return;\n }\n if (this.replay) return this.replay.start(this.session.id, cfg.config);\n if (this.replayLoading) return;\n this.replayLoading = true;\n loadRecorder().then(\n (api) => {\n this.replayLoading = false;\n if (this.destroyed || this.replay) return;\n this.replay = api.createReplay({\n url: (params) => this.api.url(\"/replay\", params),\n fetch: () => this.options.fetch ?? (typeof fetch === \"function\" ? fetch.bind(globalThis) : null),\n meta: () => {\n const device = detectDevice(navigator.userAgent, window.innerWidth);\n return {\n anonymousId: this.anonymousId,\n userId: this.user?.id || null,\n url: this.collectUrls() ? location.href : undefined,\n device: { type: device.type, browser: device.browser, os: device.os },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n sdk: { name: SDK_NAME, version: SDK_VERSION },\n };\n },\n onDisabled: (sessionId) => {\n if (sessionId !== this.session.id) return;\n this.session.replay = false;\n this.persistSession();\n this.replay?.stop({ discard: true });\n },\n onError: (err) => this.reportError(err),\n });\n this.syncReplay(); // re-decide: consent, session or settings may have changed while loading\n },\n (err) => {\n this.replayLoading = false;\n this.reportError(err);\n },\n );\n }\n\n /**\n * Records this session even when it was not sampled, provided the project has session replay\n * enabled (and analytics + consent allow it). The decision sticks for the rest of the session.\n */\n startSessionRecording(): void {\n if (this.destroyed) return;\n this.session.replay = true;\n this.persistSession();\n this.syncReplay();\n }\n\n /** Stops recording for the rest of this session (what was recorded so far is uploaded). */\n stopSessionRecording(): void {\n this.session.replay = false;\n this.persistSession();\n this.replay?.stop();\n }\n\n /** True while the session is being recorded. */\n isRecording(): boolean {\n return !!this.replay?.isRecording();\n }\n\n /** The current analytics session id (rotates after inactivity; also the replay id). */\n getSessionId(): string {\n return this.session.id;\n }\n\n // ---------------------------------------------------------------------------\n // Targeting + triggers\n // ---------------------------------------------------------------------------\n\n /** Builds the targeting context for the current moment. */\n getContext(): TargetingContext {\n const guides = this.state.guides;\n const completedChecklists = Object.entries(this.state.checklists).filter(([, p]) => !!p.completedAt).map(([id]) => id);\n const keysOf = (ids: string[]) => ids.flatMap((id) => [id, this.findGuide(id)?.key ?? id]);\n return buildContext({\n anonymousId: this.anonymousId,\n userId: this.user?.id || null,\n userAttributes: this.user?.traits ?? {},\n accountAttributes: this.user?.account?.traits ?? {},\n url: location.href,\n firstVisit: this.firstVisit,\n eventsSeen: this.session.events,\n completedGuides: keysOf(Object.keys(guides).filter((id) => guides[id]?.completedAt)),\n dismissedGuides: keysOf(Object.keys(guides).filter((id) => guides[id]?.dismissedAt)),\n seenGuides: keysOf(Object.keys(guides).filter((id) => (guides[id]?.impressions ?? 0) > 0)),\n completedChecklists: keysOf(completedChecklists),\n audienceIds: this.state.audienceIds,\n environment: this.options.environment,\n platform: \"web\",\n });\n }\n\n private isTargeted(guide: PublishedGuide, ctx: TargetingContext, url: string): boolean {\n const c = guide.config;\n if (c.urlPatterns.length && !c.urlPatterns.some((p) => urlMatches(p, url))) return false;\n if (c.trigger.urlPattern && !urlMatches(c.trigger.urlPattern, url)) return false;\n if (!isWithinSchedule(guide)) return false;\n if (guide.kind === \"survey\" && (this.state.surveysSubmitted.includes(guide.id) || this.state.surveysSubmitted.includes(guide.key))) return false;\n ctx.rolloutSalt = guide.id;\n return evaluateRules(c.targeting, ctx);\n }\n\n private isEligible(guide: PublishedGuide, ctx: TargetingContext, url: string): boolean {\n if (!this.isTargeted(guide, ctx, url)) return false;\n const shownThisSession = this.session.shownGuides.includes(guide.id);\n if (guide.kind === \"checklist\") {\n const p = this.state.checklists[guide.id];\n return !p?.dismissedAt;\n }\n return isFrequencyEligible(guide.config.frequency, this.state.guides[guide.id], shownThisSession);\n }\n\n private triggerFires(guide: PublishedGuide, reason: EvalReason, detail: EvalDetail): boolean {\n const t = guide.config.trigger;\n switch (t.type) {\n case \"page_load\":\n // A delayed page_load re-evaluates from its own timer.\n if (t.delayMs > 0) return reason === \"timer\" && detail.guideId === guide.id;\n return reason === \"ready\" || reason === \"navigation\" || reason === \"identify\";\n case \"url_match\":\n return (reason === \"ready\" || reason === \"navigation\" || reason === \"identify\") && urlMatches(t.value, location.href);\n case \"event\":\n return reason === \"event\" && !!t.value && detail.eventName === t.value;\n case \"element_click\":\n if (reason !== \"click\" || !t.value || !detail.target) return false;\n try {\n return !!detail.target.closest(t.value);\n } catch {\n return false;\n }\n case \"element_visible\":\n return reason === \"visible\" && detail.guideId === guide.id;\n case \"delay\":\n return reason === \"timer\" && detail.guideId === guide.id;\n case \"after_guide\":\n return reason === \"after_guide\" && !!detail.endedGuide && (detail.endedGuide.id === t.value || detail.endedGuide.key === t.value);\n case \"segment_enter\":\n return reason === \"identify\" && !!t.value && !!detail.newAudiences?.has(t.value);\n case \"manual\":\n default:\n return false;\n }\n }\n\n private evaluate(reason: EvalReason, detail: EvalDetail = {}): void {\n if (!this.config || this.destroyed || this.authoring?.isActive()) return;\n const url = location.href;\n const ctx = this.getContext();\n if (reason === \"identify\") {\n const current = new Set(this.state.audienceIds);\n detail.newAudiences = new Set(Array.from(current).filter((a) => !this.lastAudiences.has(a)));\n this.lastAudiences = current;\n }\n const candidates: PublishedGuide[] = [];\n for (const guide of this.config.guides) {\n const t = guide.config.trigger;\n if (detail.endedGuide && detail.endedGuide.id === guide.id) continue; // never re-show the guide that just ended\n // Arm element-visibility observers and delay timers on page-level evaluations.\n if (reason === \"ready\" || reason === \"navigation\") {\n if (t.type === \"element_visible\" && t.value) this.armVisibility(guide, ctx, url);\n if ((t.type === \"delay\" || (t.type === \"page_load\" && t.delayMs > 0)) && !this.firedDelays.has(guide.id)) {\n if (!this.isEligible(guide, ctx, url)) continue;\n this.firedDelays.add(guide.id);\n this.setTimer(() => this.evaluate(\"timer\", { guideId: guide.id }), t.delayMs);\n continue;\n }\n }\n if (t.type === \"page_load\" && t.delayMs > 0 && reason !== \"timer\") continue;\n if (t.type === \"page_load\" && t.delayMs > 0 && reason === \"timer\" && detail.guideId !== guide.id) continue;\n if (!this.triggerFires(guide, reason, detail)) continue;\n if (!this.isEligible(guide, ctx, url)) continue;\n candidates.push(guide);\n }\n if (reason === \"after_guide\" || reason === \"navigation\") this.drainQueue(url, ctx);\n if (!candidates.length) return;\n candidates.sort((a, b) => a.config.frequency.priority - b.config.frequency.priority);\n for (const guide of candidates) {\n if (this.widgets.has(guide.id) || this.active?.guide.id === guide.id) continue;\n const delay = guide.config.trigger.type !== \"delay\" && guide.config.trigger.type !== \"page_load\" ? guide.config.trigger.delayMs : 0;\n if (delay > 0) {\n this.setTimer(() => this.tryShow(guide, url, false), delay);\n continue;\n }\n this.tryShow(guide, url, false);\n }\n }\n\n private armVisibility(guide: PublishedGuide, ctx: TargetingContext, url: string): void {\n const selector = guide.config.trigger.value;\n if (!selector || this.visibilityObservers.has(guide.id)) return;\n if (!this.isEligible(guide, ctx, url)) return;\n const ac = new AbortController();\n let io: IntersectionObserver | null = null;\n const stop = () => {\n ac.abort();\n io?.disconnect();\n this.visibilityObservers.delete(guide.id);\n };\n this.visibilityObservers.set(guide.id, stop);\n waitForTarget([{ kind: \"css\", value: selector }], { timeoutMs: 0, signal: ac.signal })\n .then((el) => {\n if (ac.signal.aborted) return;\n const fire = () => {\n stop();\n this.evaluate(\"visible\", { guideId: guide.id });\n };\n if (typeof IntersectionObserver === \"undefined\") return fire();\n io = new IntersectionObserver((entries) => {\n if (entries.some((e) => e.isIntersecting)) fire();\n });\n io.observe(el);\n })\n .catch(() => stop());\n }\n\n private setTimer(fn: () => void, ms: number): void {\n const t = setTimeout(() => {\n this.timers.delete(t);\n if (!this.destroyed) fn();\n }, ms);\n this.timers.add(t);\n }\n\n /** Decides whether a guide can show now, otherwise queues it. */\n private tryShow(guide: PublishedGuide, url: string, manual: boolean): boolean {\n if (this.destroyed) return false;\n if (!isExclusiveGuide(guide)) {\n if (this.widgets.has(guide.id)) return false;\n this.show(guide, manual);\n return true;\n }\n if (this.active) {\n if (this.active.guide.id === guide.id) return false;\n if (manual) this.stopGuide();\n else {\n if (!this.queued.some((q) => q.guide.id === guide.id)) this.queued.push({ guide, url, pageScoped: PAGE_SCOPED.has(guide.config.trigger.type) });\n this.log(\"queued\", guide.key, \"behind\", this.active.guide.key);\n return false;\n }\n }\n const blocked = Array.from(this.widgets.keys()).map((id) => this.findGuide(id)).some((g) => g && areMutuallyExclusive(g, guide));\n if (blocked && !manual) {\n if (!this.queued.some((q) => q.guide.id === guide.id)) this.queued.push({ guide, url, pageScoped: true });\n return false;\n }\n this.show(guide, manual);\n return true;\n }\n\n private drainQueue(url: string, ctx: TargetingContext): void {\n if (this.active) return;\n this.queued = this.queued.filter((q) => !(q.pageScoped && q.url !== url));\n while (this.queued.length) {\n const next = this.queued.shift() as QueuedGuide;\n if (!this.isEligible(next.guide, ctx, url)) continue;\n if (this.tryShow(next.guide, url, false)) return;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Showing guides\n // ---------------------------------------------------------------------------\n\n private findGuide(idOrKey: string): PublishedGuide | undefined {\n return this.config?.guides.find((g) => g.id === idOrKey || g.key === idOrKey);\n }\n\n private guideState(id: string): GuideLocalState {\n return this.state.guides[id] ?? (this.state.guides[id] = { impressions: 0 });\n }\n\n private recordImpression(guide: PublishedGuide): void {\n const s = this.guideState(guide.id);\n s.impressions += 1;\n s.lastShownAt = nowIso();\n if (!this.session.shownGuides.includes(guide.id)) this.session.shownGuides.push(guide.id);\n this.persistState();\n this.persistSession();\n this.syncGuideState(guide.id, { impression: true });\n }\n\n private recordEnd(guide: PublishedGuide, reason: \"completed\" | \"dismissed\" | \"skipped\"): void {\n const s = this.guideState(guide.id);\n if (reason === \"completed\") s.completedAt = nowIso();\n else s.dismissedAt = nowIso();\n this.persistState();\n this.syncGuideState(guide.id, reason === \"completed\" ? { completed: true } : { dismissed: true });\n if (reason === \"completed\") this.completeChecklistTasksBy(\"guide_completed\", guide);\n }\n\n private syncGuideState(guideId: string, update: { impression?: boolean; completed?: boolean; dismissed?: boolean }): void {\n void postWithRetry(this.api, \"/guide-state\", { anonymousId: this.anonymousId, userId: this.user?.id || null, updates: [{ guideId, ...update }] });\n }\n\n private show(guide: PublishedGuide, manual: boolean, stepId?: string): void {\n try {\n if (guide.kind === \"checklist\" && guide.config.checklist) return this.showChecklist(guide);\n if (guide.kind === \"survey\" && guide.config.survey) return this.showSurvey(guide, manual);\n this.showFlow(guide, manual, stepId);\n } catch (err) {\n this.reportError(err);\n }\n }\n\n private showFlow(guide: PublishedGuide, manual: boolean, stepId?: string): void {\n if (this.authoring?.isActive()) return; // authoring mode renders previews only\n const exclusive = isExclusiveGuide(guide);\n const entry: ActiveGuide = { guide, manual, startUrl: location.href };\n const controller = runGuide(guide, {\n theme: this.theme(),\n ctx: () => this.getContext(),\n startAtStep: stepId,\n eventBus: this.eventBus,\n onError: (err) => this.reportError(err),\n onEvent: (e) => {\n const step = e.stepId ? guide.config.steps.find((s) => s.id === e.stepId) : undefined;\n this.enqueue(e.name, { guideId: guide.id, guideVersion: guide.version, stepId: e.stepId, stepIndex: e.stepIndex, properties: e.properties });\n if (e.name === \"guide_started\") {\n this.recordImpression(guide);\n this.emitter.emit(\"guide:start\", guide);\n }\n if (e.name === \"step_viewed\" && step) {\n if (exclusive) writeJson(this.sessionStore, KEYS.active, { guideId: guide.id, stepId: step.id, manual });\n this.emitter.emit(\"guide:step\", { guide, stepId: step.id, stepIndex: e.stepIndex ?? 0 });\n }\n if (e.name === \"guide_completed\") {\n this.recordEnd(guide, \"completed\");\n this.emitter.emit(\"guide:complete\", guide);\n }\n if (e.name === \"guide_dismissed\") {\n this.recordEnd(guide, \"dismissed\");\n this.emitter.emit(\"guide:dismiss\", guide);\n }\n if (e.name === \"guide_skipped\") {\n this.recordEnd(guide, \"skipped\");\n this.emitter.emit(\"guide:skip\", guide);\n }\n },\n onNavigate: (url, newTab) => this.navigate(url, newTab),\n onAction: (action, value) => {\n if (action === \"start_guide\" && value) this.setTimer(() => this.startGuide(value), 0);\n else if (action === \"event\" && value) this.track(value);\n else if (action === \"open_resource_center\") this.openResourceCenter();\n },\n onEnd: (reason) => {\n if (exclusive) {\n if (this.active?.controller === controller) this.active = null;\n this.sessionStore.remove(KEYS.active);\n } else this.widgets.delete(guide.id);\n if (reason !== \"destroyed\" && !this.destroyed) this.setTimer(() => this.evaluate(\"after_guide\", { endedGuide: guide }), 0);\n },\n });\n entry.controller = controller;\n if (exclusive) this.active = entry;\n else this.widgets.set(guide.id, { destroy: () => controller.destroy(), controller, manual });\n controller.start();\n if (controller.getState().status === \"ended\") {\n if (exclusive && this.active === entry) this.active = null;\n this.widgets.delete(guide.id);\n }\n }\n\n private showChecklist(guide: PublishedGuide): void {\n if (this.authoring?.isActive()) return; // authoring mode renders previews only\n const config = guide.config.checklist;\n if (!config || this.widgets.has(guide.id)) return;\n const scope = createScope(this.theme(), guide.config.appearance);\n const progress = this.getChecklistProgress(guide.id);\n const first = !this.state.guides[guide.id]?.impressions;\n const widget = renderChecklist({\n scope: scope.el,\n config,\n progress,\n open: config.autoOpen && first && !progress.completedAt,\n onTaskClick: (task) => this.handleChecklistTaskClick(guide, task),\n onDismiss: () => this.dismissChecklist(guide),\n onOpen: () => this.enqueue(\"guide_viewed\", { guideId: guide.id, guideVersion: guide.version }),\n });\n this.widgets.set(guide.id, { destroy: () => { widget.destroy(); scope.destroy(); }, checklist: widget, scope });\n if (first) this.recordImpression(guide);\n }\n\n private showSurvey(guide: PublishedGuide, manual: boolean): void {\n if (this.authoring?.isActive()) return; // authoring mode renders previews only\n const config = guide.config.survey;\n if (!config) return;\n const scope = createScope(this.theme(), guide.config.appearance);\n const entry: ActiveGuide = { guide, manual, startUrl: location.href, scope };\n const finish = (reason: \"submitted\" | \"dismissed\") => {\n widget.destroy();\n scope.destroy();\n if (this.active === entry) this.active = null;\n if (reason === \"dismissed\") {\n this.enqueue(\"survey_dismissed\", { guideId: guide.id, guideVersion: guide.version });\n this.recordEnd(guide, \"dismissed\");\n this.emitter.emit(\"guide:dismiss\", guide);\n }\n this.setTimer(() => this.evaluate(\"after_guide\", { endedGuide: guide }), 0);\n };\n const widget = renderSurvey({\n scope: scope.el,\n config,\n title: guide.name,\n onDismiss: () => finish(this.state.surveysSubmitted.includes(guide.id) ? \"submitted\" : \"dismissed\"),\n onSubmit: (answers) => {\n const responseId = randomId(24);\n this.state.surveysSubmitted.push(guide.id);\n this.persistState();\n this.recordEnd(guide, \"completed\");\n this.enqueue(\"survey_submitted\", { guideId: guide.id, guideVersion: guide.version, properties: { responseId } });\n void postWithRetry(this.api, `/surveys/${encodeURIComponent(guide.id)}/responses`, { anonymousId: this.anonymousId, userId: this.user?.id || null, accountId: this.user?.account?.id || null, guideVersion: guide.version, answers, responseId });\n this.emitter.emit(\"survey:submit\", { guide, answers, responseId });\n this.emitter.emit(\"guide:complete\", guide);\n widget.showThankYou();\n },\n });\n entry.survey = widget;\n this.active = entry;\n this.recordImpression(guide);\n this.enqueue(\"survey_displayed\", { guideId: guide.id, guideVersion: guide.version });\n this.emitter.emit(\"guide:start\", guide);\n }\n\n private theme() {\n return { ...(this.config?.theme || {}), ...(this.options.theme || {}) };\n }\n\n private navigate(url: string, newTab?: boolean): void {\n try {\n if (newTab) window.open(url, \"_blank\", \"noopener\");\n else location.assign(url);\n } catch (err) {\n this.reportError(err);\n }\n }\n\n private renderPersistentWidgets(): void {\n if (!this.config) return;\n const rc = this.config.resourceCenter;\n if (this.config.messenger?.enabled) {\n // One launcher: the messenger's Help tab replaces the resource center.\n if (this.resourceCenter) {\n this.resourceCenter.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n }\n if (!this.messenger) void this.loadMessenger();\n return;\n }\n this.destroyMessenger();\n if (rc && rc.enabled && !this.resourceCenter) {\n const scope = createScope(this.theme());\n this.resourceCenterScope = scope;\n this.resourceCenter = renderResourceCenter({\n scope: scope.el,\n config: rc,\n guides: this.config.guides.map((g) => ({ id: g.id, key: g.key, name: g.name, kind: g.kind })),\n search: (q) => this.searchResourceCenter(q),\n audienceIds: () => this.state.audienceIds,\n loadArticle: (id) => this.loadArticle(id),\n onStartGuide: (id) => this.startGuide(id),\n onOpenChecklist: (id) => this.openChecklist(id),\n onArticleView: (a) => this.enqueue(\"article_viewed\", { properties: { articleId: a.id, slug: a.slug } }),\n onOpen: () => {\n this.enqueue(\"resource_center_opened\");\n this.emitter.emit(\"resource-center:open\");\n },\n });\n } else if ((!rc || !rc.enabled) && this.resourceCenter) {\n this.resourceCenter.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n }\n }\n\n private resumeActiveGuide(): void {\n const saved = readJson<{ guideId: string; stepId: string; manual?: boolean } | null>(this.sessionStore, KEYS.active, null);\n if (!saved) return;\n this.sessionStore.remove(KEYS.active);\n const guide = this.findGuide(saved.guideId);\n if (!guide || !guide.config.steps.some((s) => s.id === saved.stepId)) return;\n this.showFlow(guide, saved.manual ?? false, saved.stepId);\n }\n\n /** Loads the messenger widget on demand (it is a separate chunk) and renders it. */\n private loadMessenger(): Promise<MessengerWidget | null> {\n if (this.messenger) return Promise.resolve(this.messenger);\n if (this.messengerLoading) return this.messengerLoading;\n this.messengerLoading = import(\"@guidelytech/guide-runtime/messenger\")\n .then(({ renderMessenger }) => {\n const cfg = this.config?.messenger;\n if (this.destroyed || !this.config || !cfg?.enabled || this.messenger) return this.messenger;\n const scope = createScope(this.theme());\n this.messengerScope = scope;\n this.messenger = renderMessenger({\n scope: scope.el,\n config: cfg,\n api: createMessengerTransport({\n api: this.api,\n store: this.store,\n projectId: this.options.projectId,\n anonymousId: () => this.anonymousId,\n userId: () => this.user?.id || null,\n pageUrl: () => (this.collectUrls() ? location.href : undefined),\n }),\n resourceCenter: this.config.resourceCenter,\n audienceIds: () => this.state.audienceIds,\n guides: this.config.guides.map((g) => ({ id: g.id, key: g.key, name: g.name, kind: g.kind })),\n onStartGuide: (idOrKey) => this.startGuide(idOrKey),\n onOpenChecklist: (id) => this.openChecklist(id),\n onArticleView: (a) => this.enqueue(\"article_viewed\", { properties: { articleId: a.id, slug: a.slug } }),\n onOpen: () => {\n this.enqueue(\"messenger_opened\");\n this.emitter.emit(\"messenger:open\");\n },\n onMessage: (message, conversation) => this.emitter.emit(\"conversation:message\", { message, conversation }),\n });\n return this.messenger;\n })\n .catch((err) => {\n this.reportError(err);\n return null;\n })\n .finally(() => {\n this.messengerLoading = null;\n });\n return this.messengerLoading;\n }\n\n private destroyMessenger(): void {\n this.messenger?.destroy();\n this.messengerScope?.destroy();\n this.messenger = null;\n this.messengerScope = null;\n }\n\n private async loadArticle(id: string): Promise<ResourceCenterArticle | null> {\n try {\n const res = await this.api.get<{ article: ResourceCenterArticle }>(`/articles/${encodeURIComponent(id)}`);\n return res.ok && res.data ? res.data.article : null;\n } catch {\n return null;\n }\n }\n\n private async searchResourceCenter(q: string): Promise<ResourceCenterArticle[]> {\n try {\n const res = await this.api.get<{ articles: ResourceCenterArticle[] }>(\"/resource-center/search\", { params: { q } });\n return res.ok && res.data ? res.data.articles : [];\n } catch {\n return [];\n }\n }\n\n // ---------------------------------------------------------------------------\n // Checklists\n // ---------------------------------------------------------------------------\n\n /** Current progress for a checklist guide (by id or key). */\n getChecklistProgress(idOrKey: string): ChecklistProgressState {\n const guide = this.findGuide(idOrKey);\n const id = guide?.id ?? idOrKey;\n const p = this.state.checklists[id];\n return p ? { completedTaskIds: [...p.completedTaskIds], completedAt: p.completedAt ?? null, dismissedAt: p.dismissedAt ?? null } : { completedTaskIds: [], completedAt: null, dismissedAt: null };\n }\n\n /** Marks a checklist task complete (manual completion) and syncs progress. */\n completeChecklistTask(idOrKey: string, taskId: string): void {\n const guide = this.findGuide(idOrKey);\n if (!guide?.config.checklist) return;\n const task = guide.config.checklist.tasks.find((t) => t.id === taskId);\n if (task) this.markTaskDone(guide, task);\n }\n\n private markTaskDone(guide: PublishedGuide, task: ChecklistTask): void {\n const config = guide.config.checklist;\n if (!config) return;\n const progress = this.state.checklists[guide.id] ?? (this.state.checklists[guide.id] = { completedTaskIds: [] });\n if (progress.completedTaskIds.includes(task.id)) return;\n progress.completedTaskIds.push(task.id);\n this.enqueue(\"checklist_task_completed\", { guideId: guide.id, guideVersion: guide.version, properties: { taskId: task.id } });\n const complete = isChecklistComplete(config, progress) && !progress.completedAt;\n if (complete) {\n progress.completedAt = nowIso();\n this.enqueue(\"checklist_completed\", { guideId: guide.id, guideVersion: guide.version });\n }\n this.persistState();\n this.widgets.get(guide.id)?.checklist?.setProgress(this.getChecklistProgress(guide.id));\n void postWithRetry(this.api, `/checklists/${encodeURIComponent(guide.id)}/progress`, { anonymousId: this.anonymousId, userId: this.user?.id || null, guideVersion: guide.version, completedTaskIds: progress.completedTaskIds, completed: !!progress.completedAt });\n this.emitter.emit(\"checklist:task\", { guide, task, progress: this.getChecklistProgress(guide.id) });\n if (complete) {\n this.emitter.emit(\"checklist:complete\", guide);\n this.widgets.get(guide.id)?.checklist?.open();\n }\n }\n\n private completeChecklistTasksBy(kind: ChecklistTask[\"completion\"], value: string | Element | PublishedGuide): void {\n if (!this.config) return;\n for (const guide of this.config.guides) {\n const tasks = guide.config.checklist?.tasks;\n if (!tasks) continue;\n for (const task of tasks) {\n if (task.completion !== kind || !task.completionValue) continue;\n let hit = false;\n if (kind === \"event\") hit = value === task.completionValue;\n else if (kind === \"url_visited\") hit = urlMatches(task.completionValue, value as string);\n else if (kind === \"guide_completed\") hit = (value as PublishedGuide).id === task.completionValue || (value as PublishedGuide).key === task.completionValue;\n else if (kind === \"click\") {\n try {\n hit = !!(value as Element).closest(task.completionValue);\n } catch {\n hit = false;\n }\n }\n if (hit) this.markTaskDone(guide, task);\n }\n }\n }\n\n private handleChecklistTaskClick(guide: PublishedGuide, task: ChecklistTask): void {\n if (task.completion === \"manual\") this.markTaskDone(guide, task);\n if (task.action === \"start_guide\" && task.actionValue) this.startGuide(task.actionValue);\n else if (task.action === \"url\" && task.actionValue) this.navigate(task.actionValue);\n else if (task.action === \"event\" && task.actionValue) this.track(task.actionValue);\n }\n\n private dismissChecklist(guide: PublishedGuide): void {\n const progress = this.state.checklists[guide.id] ?? (this.state.checklists[guide.id] = { completedTaskIds: [] });\n progress.dismissedAt = nowIso();\n this.persistState();\n this.enqueue(\"checklist_dismissed\", { guideId: guide.id, guideVersion: guide.version });\n void postWithRetry(this.api, `/checklists/${encodeURIComponent(guide.id)}/progress`, { anonymousId: this.anonymousId, userId: this.user?.id || null, guideVersion: guide.version, completedTaskIds: progress.completedTaskIds, dismissed: true });\n this.widgets.get(guide.id)?.destroy();\n this.widgets.delete(guide.id);\n }\n\n /** Opens (rendering if needed) the checklist panel. */\n openChecklist(idOrKey: string): void {\n const guide = this.findGuide(idOrKey);\n if (!guide?.config.checklist) return;\n if (!this.widgets.has(guide.id)) {\n const p = this.state.checklists[guide.id];\n if (p?.dismissedAt) {\n delete p.dismissedAt;\n this.persistState();\n }\n this.showChecklist(guide);\n }\n this.widgets.get(guide.id)?.checklist?.open();\n }\n\n closeChecklist(idOrKey: string): void {\n const guide = this.findGuide(idOrKey);\n if (guide) this.widgets.get(guide.id)?.checklist?.close();\n }\n\n // ---------------------------------------------------------------------------\n // Public guide controls\n // ---------------------------------------------------------------------------\n\n /** Starts a guide by id or key, bypassing targeting and frequency rules. */\n startGuide(idOrKey: string, options: { stepId?: string } = {}): boolean {\n const guide = this.findGuide(idOrKey);\n if (!guide) {\n this.reportError(new Error(`[Guidely] startGuide: unknown guide \"${idOrKey}\"`));\n return false;\n }\n if (guide.kind === \"checklist\") {\n this.openChecklist(guide.id);\n return true;\n }\n if (this.active) this.stopGuide();\n this.widgets.get(guide.id)?.destroy();\n this.widgets.delete(guide.id);\n this.show(guide, true, options.stepId);\n return true;\n }\n\n /** Stops the active guide silently (no dismiss event). */\n stopGuide(): void {\n const a = this.active;\n if (!a) return;\n this.active = null;\n a.controller?.destroy();\n a.survey?.destroy();\n a.scope?.destroy();\n this.sessionStore.remove(KEYS.active);\n }\n\n /** Dismisses the active guide (records a dismissal). */\n dismissGuide(): void {\n const a = this.active;\n if (!a) return;\n if (a.controller) a.controller.dismiss();\n else {\n this.stopGuide();\n this.recordEnd(a.guide, \"dismissed\");\n this.emitter.emit(\"guide:dismiss\", a.guide);\n }\n }\n\n getActiveGuide(): PublishedGuide | null {\n return this.active?.guide ?? null;\n }\n\n /** Published guides for this environment (read-only). */\n getGuides(): ReadonlyArray<PublishedGuide> {\n return this.config?.guides ?? [];\n }\n\n isGuideCompleted(idOrKey: string): boolean {\n const guide = this.findGuide(idOrKey);\n return !!this.state.guides[guide?.id ?? idOrKey]?.completedAt;\n }\n\n openResourceCenter(): void {\n if (this.config?.messenger?.enabled) return this.openMessenger(\"help\");\n if (!this.resourceCenter) this.renderPersistentWidgets();\n this.resourceCenter?.open();\n }\n\n closeResourceCenter(): void {\n if (this.messenger) return this.closeMessenger();\n this.resourceCenter?.close();\n }\n\n /** Opens the Scout messenger (when enabled for the project), optionally on a tab. */\n openMessenger(tab?: MessengerTab): void {\n if (!this.config?.messenger?.enabled) return;\n void this.loadMessenger().then((m) => m?.open(tab));\n }\n\n closeMessenger(): void {\n this.messenger?.close();\n }\n\n /** Opens a new messenger conversation, optionally pre-filling the message. */\n showNewMessage(text?: string): void {\n if (!this.config?.messenger?.enabled) return;\n void this.loadMessenger().then((m) => m?.showNewMessage(text));\n }\n\n on<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): () => void {\n return this.emitter.on(event, cb);\n }\n\n off<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): void {\n this.emitter.off(event, cb);\n }\n\n /** Snapshot for debugging / devtools. */\n getState() {\n return {\n ready: this.isReady,\n destroyed: this.destroyed,\n anonymousId: this.anonymousId,\n user: this.user,\n consent: this.consent,\n configVersion: this.config?.configVersion ?? null,\n guides: this.getGuides().map((g) => ({ id: g.id, key: g.key, kind: g.kind })),\n activeGuide: this.active ? { id: this.active.guide.id, key: this.active.guide.key, ...(this.active.controller?.getState() ?? {}) } : null,\n queued: this.queued.map((q) => q.guide.key),\n widgets: Array.from(this.widgets.keys()),\n guideState: this.state.guides,\n checklists: this.state.checklists,\n audienceIds: this.state.audienceIds,\n session: this.session,\n pendingEvents: this.queue.size,\n authoring: !!this.authoring?.isActive(),\n };\n }\n\n // ---------------------------------------------------------------------------\n // Authoring\n // ---------------------------------------------------------------------------\n\n private maybeStartAuthoring(): void {\n try {\n const bridge = new AuthoringBridge({\n api: this.api,\n sessionStore: this.sessionStore,\n theme: () => this.theme(),\n ctx: () => this.getContext(),\n maskSelectors: [...(this.options.maskSelectors || []), ...(this.config?.settings?.maskSelectors || [])],\n onError: (err) => this.reportError(err),\n onActive: (active) => {\n this.emitter.emit(\"authoring\", { active });\n if (active) this.replay?.stop({ discard: true });\n else this.syncCapture();\n if (active) {\n this.stopGuide();\n this.widgets.forEach((w) => w.destroy());\n this.widgets.clear();\n } else this.evaluate(\"ready\");\n },\n });\n if (bridge.detect()) this.authoring = bridge;\n } catch (err) {\n this.reportError(err);\n }\n }\n\n // ---------------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------------\n\n private persistState(): void {\n writeJson(this.store, KEYS.state(this.options.projectId), this.state);\n }\n\n private persistSession(): void {\n writeJson(this.sessionStore, KEYS.session, this.session);\n }\n\n private reportError(err: unknown): void {\n const error = err instanceof Error ? err : new Error(String(err));\n this.log(\"error\", error.message);\n try {\n this.options.onError?.(error);\n } catch {\n /* ignore */\n }\n this.emitter.emit(\"error\", error);\n }\n\n private log(...args: unknown[]): void {\n if (this.options.debug && typeof console !== \"undefined\") console.debug(\"[Guidely]\", ...args);\n }\n\n // ---------------------------------------------------------------------------\n // Static helpers (used by the embed)\n // ---------------------------------------------------------------------------\n\n /** Creates (or returns the existing) client and starts initialisation. */\n static init(options: GuidelyOptions): GuidelyClient {\n if (current && !current.destroyed && current.options.projectId === options.projectId) return current;\n current?.destroy();\n current = new GuidelyClient(options);\n void current.init();\n return current;\n }\n\n /** The most recently created client, if any. */\n static get(): GuidelyClient | null {\n return current && !current.destroyed ? current : null;\n }\n}\n\nlet current: GuidelyClient | null = null;\n\n/** Mobile-only guides never run in the browser (older servers ignore `?platform=web`). */\nfunction webOnly(config: SdkConfigResponse): SdkConfigResponse {\n return config.guides.every((g) => supportsPlatform(g.config, \"web\")) ? config : { ...config, guides: config.guides.filter((g) => supportsPlatform(g.config, \"web\")) };\n}\n\nfunction pathOf(url: string): string {\n try {\n return new URL(url, \"http://localhost\").pathname;\n } catch {\n return url.replace(/[?#].*$/, \"\");\n }\n}\n\n/** `document.referrer` as origin + path, only when it is another site. */\nfunction externalReferrer(): string | undefined {\n try {\n if (!document.referrer) return undefined;\n const u = new URL(document.referrer);\n return u.origin === location.origin ? undefined : u.origin + u.pathname;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Creates a Guidely client and starts loading configuration. Throws a friendly error when called\n * during server-side rendering; framework adapters guard this for you.\n */\nexport function createGuidely(options: GuidelyOptions): GuidelyClient {\n const client = new GuidelyClient(options);\n current = client;\n void client.init();\n return client;\n}\n","import { type AppSnapshot, type AuthoringPick, type AuthoringSessionInfo, type ProjectTheme, type SelectorStrategy, type TargetingContext } from \"@guidelytech/shared\";\nimport { highlightSelectors, previewStep, runGuide, startAuthoring, type AuthoringSession, type GuideController, type PreviewHandle, type RunnableGuide } from \"@guidelytech/guide-runtime\";\nimport type { Api } from \"./http\";\nimport { captureSnapshot } from \"./snapshot\";\nimport { KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\n\n/** Schemas are only needed in authoring mode; load them lazily so the normal runtime stays zod-free. */\nasync function loadSchemas() {\n const m = await import(\"@guidelytech/shared\");\n return { StepSchema: m.StepSchema, GuideConfigSchema: m.GuideConfigSchema };\n}\n\nexport const AUTHORING_PARAM = \"guidely_authoring\";\nexport const HEARTBEAT_MS = 15000;\n/** Quiet period after DOM changes / navigation before a new page snapshot is sent. */\nexport const SNAPSHOT_DEBOUNCE_MS = 800;\n/** Upper bound on how long continuous DOM churn can delay a snapshot. */\nexport const SNAPSHOT_MAX_WAIT_MS = 4000;\n\n/** Messages the SDK posts to the dashboard window (`window.opener`). */\nexport type AuthoringOutgoingMessage =\n | { type: \"guidely:authoring-ready\"; sessionId: string; url: string }\n | { type: \"guidely:pick\"; sessionId: string; pick: AuthoringPick }\n | { type: \"guidely:highlight-result\"; sessionId: string; counts: number[]; resolved: boolean }\n | { type: \"guidely:preview-ended\"; sessionId: string; reason: string }\n | { type: \"guidely:exit\"; sessionId: string }\n | { type: \"guidely:pong\"; sessionId: string; url: string }\n | { type: \"guidely:snapshot\"; sessionId: string; snapshot: AppSnapshot };\n\n/** Messages the dashboard may post to the app window (origin-checked against `dashboardOrigin`). */\nexport type AuthoringIncomingMessage =\n | { type: \"guidely:preview-step\"; step: unknown; theme?: Partial<ProjectTheme> | null; appearance?: unknown }\n | { type: \"guidely:preview-guide\"; guide: { id?: string; key?: string; name?: string; kind?: string; version?: number; config: unknown } }\n | { type: \"guidely:highlight\"; selectors: SelectorStrategy[] }\n | { type: \"guidely:stop-preview\" }\n | { type: \"guidely:ping\" }\n | { type: \"guidely:request-snapshot\" }\n | { type: \"guidely:exit\" };\n\nexport interface AuthoringBridgeOptions {\n api: Api;\n sessionStore: KeyValueStore;\n theme: () => Partial<ProjectTheme>;\n ctx: () => TargetingContext;\n maskSelectors: string[];\n onError: (err: unknown) => void;\n onActive: (active: boolean) => void;\n}\n\n/**\n * Detects `?guidely_authoring=<token>`, verifies the session with the public API, runs the\n * runtime's element picker and bridges picks/previews with the dashboard via `postMessage`.\n */\nexport class AuthoringBridge {\n private token: string | null = null;\n private info: AuthoringSessionInfo | null = null;\n private session: AuthoringSession | null = null;\n private heartbeat: ReturnType<typeof setInterval> | null = null;\n private preview: PreviewHandle | null = null;\n private previewGuide: GuideController | null = null;\n private active = false;\n private observer: MutationObserver | null = null;\n private snapshotTimer: ReturnType<typeof setTimeout> | null = null;\n private snapshotDue = 0;\n private lastSnapshot = \"\";\n\n constructor(private readonly opts: AuthoringBridgeOptions) {}\n\n isActive(): boolean {\n return this.active;\n }\n\n /** Returns true when a token was found (in the URL or the session marker) and verification started. */\n detect(): boolean {\n if (typeof window === \"undefined\") return false;\n let token: string | null = null;\n try {\n const url = new URL(window.location.href);\n token = url.searchParams.get(AUTHORING_PARAM);\n if (token) {\n url.searchParams.delete(AUTHORING_PARAM);\n window.history.replaceState(window.history.state, \"\", url.toString());\n }\n } catch {\n token = null;\n }\n if (!token) {\n const marker = readJson<{ token?: string } | null>(this.opts.sessionStore, KEYS.authoring, null);\n token = marker?.token ?? null;\n }\n if (!token) return false;\n this.token = token;\n writeJson(this.opts.sessionStore, KEYS.authoring, { token });\n void this.start();\n return true;\n }\n\n private async start(): Promise<void> {\n if (!this.token) return;\n try {\n const res = await this.opts.api.get<AuthoringSessionInfo>(\"/authoring/session\", { params: { token: this.token } });\n if (!res.ok || !res.data) {\n this.opts.sessionStore.remove(KEYS.authoring);\n this.opts.onError(new Error(`[Guidely] authoring session invalid or expired (${res.status})`));\n return;\n }\n this.info = res.data;\n if (Date.parse(this.info.expiresAt) < Date.now()) {\n this.opts.sessionStore.remove(KEYS.authoring);\n this.opts.onError(new Error(\"[Guidely] authoring session expired\"));\n return;\n }\n this.active = true;\n this.opts.onActive(true);\n this.session = startAuthoring({\n dashboardOrigin: this.info.dashboardOrigin,\n onPick: (pick) => this.sendPick(pick),\n onExit: () => this.stop(),\n });\n this.heartbeat = setInterval(() => {\n void this.opts.api.post(\"/authoring/session/heartbeat\", {}, { params: { token: this.token ?? undefined } }).catch(() => {});\n }, HEARTBEAT_MS);\n this.post({ type: \"guidely:authoring-ready\", sessionId: this.info.id, url: window.location.href });\n this.watchPage();\n } catch (err) {\n this.opts.onError(err);\n }\n }\n\n private masked(el: Element): boolean {\n return this.opts.maskSelectors.some((sel) => {\n try {\n return !!el.closest(sel);\n } catch {\n return false;\n }\n });\n }\n\n private sendPick(raw: AuthoringPick & { element: Element }): void {\n if (!this.info || !this.token) return;\n const { element, ...rest } = raw;\n const pick: AuthoringPick = this.masked(element) ? { ...rest, textSnapshot: \"\", selectors: rest.selectors.filter((s) => s.kind !== \"text\") } : rest;\n pick.url = window.location.href;\n this.post({ type: \"guidely:pick\", sessionId: this.info.id, pick });\n void this.opts.api.post(\"/authoring/session/picks\", pick, { params: { token: this.token } }).catch((err) => this.opts.onError(err));\n }\n\n /** Sends a snapshot now and again whenever the page settles after DOM changes or navigation. */\n private watchPage(): void {\n this.scheduleSnapshot();\n if (typeof MutationObserver === \"undefined\") return;\n this.observer = new MutationObserver(() => this.scheduleSnapshot());\n this.observer.observe(document.documentElement, { subtree: true, childList: true, attributes: true, characterData: true });\n }\n\n private scheduleSnapshot(): void {\n const now = Date.now();\n if (!this.snapshotTimer) this.snapshotDue = now + SNAPSHOT_MAX_WAIT_MS;\n else clearTimeout(this.snapshotTimer);\n this.snapshotTimer = setTimeout(() => this.sendSnapshot(), Math.max(0, Math.min(SNAPSHOT_DEBOUNCE_MS, this.snapshotDue - now)));\n }\n\n private sendSnapshot(): void {\n if (this.snapshotTimer) clearTimeout(this.snapshotTimer);\n this.snapshotTimer = null;\n if (!this.info || !this.active) return;\n try {\n const snapshot = captureSnapshot(document, this.opts.maskSelectors);\n if (!snapshot || snapshot.html === this.lastSnapshot) return;\n this.lastSnapshot = snapshot.html;\n this.post({ type: \"guidely:snapshot\", sessionId: this.info.id, snapshot });\n } catch (err) {\n this.opts.onError(err);\n }\n }\n\n private post(message: AuthoringOutgoingMessage): void {\n if (!this.info) return;\n try {\n window.opener?.postMessage(message, this.info.dashboardOrigin);\n } catch {\n /* opener may be gone */\n }\n }\n\n private stopPreview(): void {\n this.preview?.destroy();\n this.preview = null;\n this.previewGuide?.destroy();\n this.previewGuide = null;\n this.session?.setPicking(true);\n }\n\n /** Handles `message` events; ignores anything not from `dashboardOrigin`. */\n async handleMessage(e: MessageEvent): Promise<void> {\n if (!this.active || !this.info) return;\n if (e.origin !== this.info.dashboardOrigin) return;\n const msg = e.data as AuthoringIncomingMessage | null;\n if (!msg || typeof msg !== \"object\" || typeof msg.type !== \"string\") return;\n try {\n switch (msg.type) {\n case \"guidely:preview-step\": {\n this.stopPreview();\n const { StepSchema, GuideConfigSchema } = await loadSchemas();\n const step = StepSchema.parse(msg.step);\n const appearance = msg.appearance ? GuideConfigSchema.shape.appearance.parse(msg.appearance) : undefined;\n this.session?.setPicking(false);\n this.session?.setStatus(`Previewing step “${step.title || step.id}” — close it to continue picking`);\n this.preview = previewStep(step, { ...this.opts.theme(), ...(msg.theme || {}) }, {\n appearance,\n onEnd: () => {\n this.preview = null;\n this.session?.setPicking(true);\n this.session?.setStatus(\"Guidely authoring — hover an element and click to select · Esc to cancel\");\n this.post({ type: \"guidely:preview-ended\", sessionId: this.info!.id, reason: \"step\" });\n },\n });\n break;\n }\n case \"guidely:preview-guide\": {\n this.stopPreview();\n const g = msg.guide;\n const guide: RunnableGuide = { id: g.id || \"preview\", key: g.key || \"preview\", name: g.name || \"Preview\", kind: g.kind || \"flow\", version: g.version ?? 0, config: (await loadSchemas()).GuideConfigSchema.parse(g.config) };\n this.session?.setPicking(false);\n this.session?.setStatus(`Previewing “${guide.name}”`);\n this.previewGuide = runGuide(guide, {\n theme: this.opts.theme(),\n ctx: this.opts.ctx,\n onNavigate: (url, newTab) => (newTab ? window.open(url, \"_blank\", \"noopener\") : window.location.assign(url)),\n onEnd: (reason) => {\n this.previewGuide = null;\n this.session?.setPicking(true);\n this.post({ type: \"guidely:preview-ended\", sessionId: this.info!.id, reason });\n },\n });\n this.previewGuide.start();\n break;\n }\n case \"guidely:highlight\": {\n const result = highlightSelectors(Array.isArray(msg.selectors) ? msg.selectors : [], { durationMs: 3000 });\n this.post({ type: \"guidely:highlight-result\", sessionId: this.info.id, counts: result.counts, resolved: !!result.resolved });\n break;\n }\n case \"guidely:stop-preview\":\n this.stopPreview();\n break;\n case \"guidely:request-snapshot\":\n this.lastSnapshot = \"\";\n this.sendSnapshot();\n break;\n case \"guidely:ping\":\n this.post({ type: \"guidely:pong\", sessionId: this.info.id, url: window.location.href });\n break;\n case \"guidely:exit\":\n this.stop();\n break;\n default:\n break;\n }\n } catch (err) {\n this.opts.onError(err);\n }\n }\n\n /** Leaves authoring mode and clears the session marker. */\n stop(): void {\n if (!this.active) return;\n this.active = false;\n this.stopPreview();\n this.observer?.disconnect();\n this.observer = null;\n if (this.snapshotTimer) clearTimeout(this.snapshotTimer);\n this.snapshotTimer = null;\n if (this.heartbeat) clearInterval(this.heartbeat);\n this.heartbeat = null;\n this.session?.stop();\n this.session = null;\n this.opts.sessionStore.remove(KEYS.authoring);\n if (this.info) this.post({ type: \"guidely:exit\", sessionId: this.info.id });\n this.opts.onActive(false);\n }\n}\n","import type { AppSnapshot } from \"@guidelytech/shared\";\n\n/** Snapshots larger than this are not sent (postMessage copies the string). */\nexport const MAX_SNAPSHOT_BYTES = 6 * 1024 * 1024;\n\nconst STRIP = \"script, noscript, template, #guidely-root, [data-guidely], meta[http-equiv], link[rel~='preload'], link[rel~='modulepreload'], link[rel~='prefetch'], link[rel~='manifest'], link[rel~='serviceworker']\";\n\n/** Text of a stylesheet built through the CSSOM (CSS-in-JS often leaves `<style>` empty). */\nfunction rulesText(sheet: CSSStyleSheet | null | undefined): string | null {\n if (!sheet) return null;\n try {\n return Array.from(sheet.cssRules, (r) => r.cssText).join(\"\\n\");\n } catch {\n return null; // cross-origin sheet\n }\n}\n\n/** Replaces text inside masked elements with bullets of the same length, keeping the layout. */\nfunction maskText(root: Element): void {\n const walker = root.ownerDocument.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n for (let n = walker.nextNode(); n; n = walker.nextNode()) {\n n.textContent = (n.textContent ?? \"\").replace(/\\S/g, \"•\");\n }\n}\n\n/**\n * Serializes the current page into a static HTML document for the dashboard's editor canvas.\n * Scripts, event handlers, Guidely's own UI and form values are dropped; `maskSelectors` text is\n * replaced with bullets. Same-origin CSSOM rules are inlined; everything else resolves through a\n * `<base href>` so stylesheets and images load from the app.\n */\nexport function captureSnapshot(doc: Document, maskSelectors: string[], maxBytes = MAX_SNAPSHOT_BYTES): AppSnapshot | null {\n const win = doc.defaultView;\n if (!win || !doc.documentElement) return null;\n const clone = doc.documentElement.cloneNode(true) as HTMLElement;\n\n // Elements whose state lives outside their markup are matched to the clone by document order,\n // so do this before anything is removed from the clone.\n const origStyles = doc.documentElement.querySelectorAll(\"style\");\n clone.querySelectorAll(\"style\").forEach((el, i) => {\n const css = rulesText(origStyles[i]?.sheet as CSSStyleSheet | null);\n if (css !== null && css.length > (el.textContent ?? \"\").length) el.textContent = css;\n });\n const origFrames = doc.documentElement.querySelectorAll(\"iframe, canvas, video, embed, object\");\n clone.querySelectorAll(\"iframe, canvas, video, embed, object\").forEach((el, i) => {\n const r = origFrames[i]?.getBoundingClientRect();\n const box = doc.createElement(\"div\");\n box.setAttribute(\"style\", `${el.getAttribute(\"style\") ?? \"\"};width:${r?.width ?? 0}px;height:${r?.height ?? 0}px;background:#e2e8f0;border-radius:4px`);\n if (el.getAttribute(\"class\")) box.setAttribute(\"class\", el.getAttribute(\"class\")!);\n el.replaceWith(box);\n });\n\n clone.querySelectorAll(STRIP).forEach((el) => el.remove());\n for (const sel of maskSelectors) {\n try {\n clone.querySelectorAll(sel).forEach(maskText);\n } catch {\n /* invalid selector */\n }\n }\n clone.querySelectorAll(\"*\").forEach((el) => {\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name.toLowerCase();\n if (name.startsWith(\"on\") || ((name === \"href\" || name === \"src\" || name === \"action\") && /^\\s*javascript:/i.test(attr.value))) el.removeAttribute(attr.name);\n }\n if (el instanceof HTMLInputElement) {\n el.removeAttribute(\"value\");\n el.removeAttribute(\"checked\");\n } else if (el instanceof HTMLTextAreaElement) {\n el.textContent = \"\";\n }\n el.removeAttribute(\"autofocus\");\n });\n\n const adopted = Array.from((doc as Document & { adoptedStyleSheets?: CSSStyleSheet[] }).adoptedStyleSheets ?? [])\n .map(rulesText)\n .filter(Boolean)\n .join(\"\\n\");\n let head = clone.querySelector(\"head\");\n if (!head) {\n head = doc.createElement(\"head\");\n clone.prepend(head);\n }\n if (adopted) {\n const style = doc.createElement(\"style\");\n style.textContent = adopted;\n head.append(style);\n }\n clone.querySelectorAll(\"base\").forEach((el) => el.remove());\n const base = doc.createElement(\"base\");\n base.setAttribute(\"href\", doc.baseURI || win.location.href);\n base.setAttribute(\"target\", \"_blank\");\n head.prepend(base);\n\n const html = `<!DOCTYPE html>\\n${clone.outerHTML}`;\n if (html.length > maxBytes) return null;\n return { html, url: win.location.href, title: doc.title, width: win.innerWidth, height: win.innerHeight, capturedAt: new Date().toISOString() };\n}\n","export type StorageKind = \"local\" | \"session\" | \"memory\";\n\n/** Minimal synchronous key/value store; never throws (private mode, quota, SSR). */\nexport interface KeyValueStore {\n get(key: string): string | null;\n set(key: string, value: string): void;\n remove(key: string): void;\n}\n\nexport function memoryStore(): KeyValueStore {\n const map = new Map<string, string>();\n return { get: (k) => map.get(k) ?? null, set: (k, v) => void map.set(k, v), remove: (k) => void map.delete(k) };\n}\n\nfunction webStore(area: \"localStorage\" | \"sessionStorage\"): KeyValueStore | null {\n try {\n if (typeof window === \"undefined\") return null;\n const s = window[area];\n if (!s) return null;\n const probe = \"__guidely_probe__\";\n s.setItem(probe, \"1\");\n s.removeItem(probe);\n return {\n get: (k) => {\n try {\n return s.getItem(k);\n } catch {\n return null;\n }\n },\n set: (k, v) => {\n try {\n s.setItem(k, v);\n } catch {\n /* quota / private mode */\n }\n },\n remove: (k) => {\n try {\n s.removeItem(k);\n } catch {\n /* ignore */\n }\n },\n };\n } catch {\n return null;\n }\n}\n\n/** Creates a store of the requested kind, degrading to memory when unavailable. */\nexport function createStorage(kind: StorageKind = \"local\"): KeyValueStore {\n if (kind === \"memory\") return memoryStore();\n return webStore(kind === \"local\" ? \"localStorage\" : \"sessionStorage\") ?? memoryStore();\n}\n\nexport function readJson<T>(store: KeyValueStore, key: string, fallback: T): T {\n const raw = store.get(key);\n if (raw == null) return fallback;\n try {\n return JSON.parse(raw) as T;\n } catch {\n return fallback;\n }\n}\n\nexport function writeJson(store: KeyValueStore, key: string, value: unknown): void {\n try {\n store.set(key, JSON.stringify(value));\n } catch {\n /* ignore */\n }\n}\n\n/** Storage keys used by the SDK (documented for integrators). */\nexport const KEYS = {\n anon: \"guidely:anon\",\n seen: \"guidely:seen\",\n config: (key: string) => `guidely:config:${key}`,\n etag: (key: string) => `guidely:etag:${key}`,\n state: (key: string) => `guidely:state:${key}`,\n user: (key: string) => `guidely:user:${key}`,\n queue: (key: string) => `guidely:queue:${key}`,\n session: \"guidely:session\",\n active: \"guidely:active\",\n authoring: \"guidely:authoring\",\n /** Messenger conversations this browser can read: [{ id, token }]. */\n conversations: (key: string) => `guidely:conversations:${key}`,\n} as const;\n","import { isGuidelyElement, isStableId } from \"@guidelytech/guide-runtime\";\n\n/** Elements whose clicks are autocaptured (the click may land on a descendant). */\nexport const INTERACTIVE_SELECTOR =\n \"a,button,input[type=button],input[type=submit],input[type=reset],input[type=checkbox],input[type=radio],select,summary,label,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch],[role=option],[onclick],[data-guidely-track]\";\n\n/** Always-on mask selectors (text never captured, masked in replays). */\nexport const DEFAULT_MASK_SELECTORS = [\"[data-guidely-mask]\", \".guidely-mask\"];\n\n/** `click` / `rage_click` event properties. */\nexport interface ClickProperties {\n tag: string;\n text?: string;\n selector: string;\n href?: string;\n x: number;\n y: number;\n count?: number;\n}\n\nconst PREFERRED_ATTRS = [\"data-testid\", \"data-test-id\", \"data-test\", \"data-cy\", \"data-qa\", \"data-guidely-track\", \"data-tour\"];\nconst NOISY_DATA_ATTR = /^data-(state|v-|react|radix|headlessui|svelte|orientation|highlighted|focus|key|index|side|align|disabled|selected|active|open|guidely-(mask|ignore|block))/i;\n\n/** Drops empty and syntactically invalid CSS selectors. */\nexport function validSelectors(list: Array<string | null | undefined>): string[] {\n const out: string[] = [];\n const probe = typeof document !== \"undefined\" ? document.createDocumentFragment() : null;\n for (const raw of list) {\n const s = (raw || \"\").trim();\n if (!s || out.includes(s)) continue;\n try {\n probe?.querySelector(s);\n out.push(s);\n } catch {\n /* invalid selector */\n }\n }\n return out;\n}\n\n/** True for clicks Guidely must never capture: its own UI and anything under `[data-guidely-ignore]`. */\nexport function isIgnoredElement(el: Element): boolean {\n return isGuidelyElement(el) || !!el.closest(\"[data-guidely-ignore]\");\n}\n\n/** The interactive element a click landed on (or inside), if any. */\nexport function interactiveElement(target: Element): Element | null {\n try {\n return target.closest(INTERACTIVE_SELECTOR);\n } catch {\n return null;\n }\n}\n\nfunction esc(value: string): string {\n const g = globalThis as { CSS?: { escape?: (v: string) => string } };\n return g.CSS?.escape ? g.CSS.escape(value) : value.replace(/[^\\w-]/g, (c) => `\\\\${c}`);\n}\n\nconst attr = (tag: string, name: string, value: string) => (value ? `${tag}[${name}=\"${value.replace(/[\"\\\\]/g, \"\\\\$&\")}\"]` : `${tag}[${name}]`);\n\n/** Stable selector: id → test/tracking data attributes → other data-* → aria-label → short CSS path. */\nexport function elementSelector(el: Element): string {\n const tag = el.tagName.toLowerCase();\n if (el.id && isStableId(el.id)) return `#${esc(el.id)}`;\n for (const name of PREFERRED_ATTRS) if (el.hasAttribute(name)) return attr(tag, name, el.getAttribute(name) || \"\").slice(0, 300);\n for (const a of Array.from(el.attributes)) {\n if (a.name.startsWith(\"data-\") && !NOISY_DATA_ATTR.test(a.name) && a.value && a.value.length <= 60) return attr(tag, a.name, a.value).slice(0, 300);\n }\n const label = el.getAttribute(\"aria-label\");\n if (label && label.length <= 80) return attr(tag, \"aria-label\", label).slice(0, 300);\n const parts: string[] = [];\n let cur: Element | null = el;\n while (cur && parts.length < 4) {\n const t = cur.tagName.toLowerCase();\n if (t === \"html\" || t === \"body\") break;\n if (cur !== el && cur.id && isStableId(cur.id)) {\n parts.unshift(`#${esc(cur.id)}`);\n break;\n }\n const parent: Element | null = cur.parentElement;\n const node: Element = cur;\n const same = parent ? Array.from(parent.children).filter((c) => c.tagName === node.tagName) : [];\n parts.unshift(same.length > 1 ? `${t}:nth-of-type(${same.indexOf(node) + 1})` : t);\n cur = parent;\n }\n return (parts.join(\" > \") || tag).slice(0, 300);\n}\n\nfunction matches(el: Element, selector: string, deep: boolean): boolean {\n if (!selector) return false;\n try {\n return !!el.closest(selector) || (deep && !!el.querySelector(selector));\n } catch {\n return false;\n }\n}\n\n/**\n * Visible text of a clicked element (≤100 chars, whitespace collapsed). Never the value of a form\n * field (only button-like inputs), and nothing when the element is (or contains) masked content.\n */\nexport function elementText(el: Element, mask: string, maskAll: boolean): string | undefined {\n if (maskAll || matches(el, mask, true)) return undefined;\n const tag = el.tagName.toLowerCase();\n let text = \"\";\n if (tag === \"input\") {\n if (!/^(button|submit|reset)$/i.test((el as HTMLInputElement).type || \"\")) return undefined;\n text = (el as HTMLInputElement).value;\n } else if (tag === \"select\" || tag === \"textarea\") return undefined;\n else text = (el as HTMLElement).innerText ?? el.textContent ?? \"\";\n text = (text || el.getAttribute(\"aria-label\") || el.getAttribute(\"title\") || \"\").replace(/\\s+/g, \" \").trim();\n return text ? text.slice(0, 100) : undefined;\n}\n\n/** Link target for analytics: the path for same-origin links, only the origin otherwise. */\nexport function linkHref(el: Element): string | undefined {\n const a = el.closest(\"a[href]\");\n if (!a) return undefined;\n try {\n const u = new URL(a.getAttribute(\"href\") || \"\", location.href);\n if (!/^https?:$/.test(u.protocol)) return undefined;\n return u.origin === location.origin ? u.pathname : u.origin;\n } catch {\n return undefined;\n }\n}\n\n/** Builds `click` properties for an element. */\nexport function describeClick(el: Element, e: MouseEvent, opts: { mask: string; maskAll: boolean; collectUrls: boolean }): ClickProperties {\n const props: ClickProperties = { tag: el.tagName.toLowerCase(), selector: elementSelector(el), x: Math.round(e.pageX ?? 0) || 0, y: Math.round(e.pageY ?? 0) || 0 };\n const text = elementText(el, opts.mask, opts.maskAll);\n if (text) props.text = text;\n const href = opts.collectUrls ? linkHref(el) : undefined;\n if (href) props.href = href;\n return props;\n}\n\n/** Detects rage clicks: 3+ clicks within 1s and 30px of each other, reported once per burst. */\nexport class RageClickDetector {\n private clicks: Array<{ x: number; y: number; t: number }> = [];\n private fired = false;\n\n constructor(\n private readonly threshold = 3,\n private readonly windowMs = 1000,\n private readonly radius = 30,\n ) {}\n\n /** Clicks in the current burst once it has fired (rage), otherwise 0. */\n get burst(): number {\n return this.fired ? this.clicks.length : 0;\n }\n\n /** Records a click; returns the click count when it completes a burst, otherwise 0. */\n add(x: number, y: number, t: number): number {\n const first = this.clicks[0];\n const last = this.clicks[this.clicks.length - 1];\n if (!first || !last || t - last.t > this.windowMs || Math.hypot(x - first.x, y - first.y) > this.radius) {\n this.clicks = [];\n this.fired = false;\n }\n this.clicks = this.clicks.filter((c) => t - c.t <= this.windowMs);\n this.clicks.push({ x, y, t });\n if (this.fired || this.clicks.length < this.threshold) return 0;\n this.fired = true;\n return this.clicks.length;\n }\n}\n","import type { TargetingContext } from \"@guidelytech/shared\";\n\nexport interface DeviceInfo {\n type: \"desktop\" | \"tablet\" | \"mobile\";\n browser?: string;\n os?: string;\n}\n\n/** Lightweight UA sniffing (good enough for targeting; not for feature detection). */\nexport function detectDevice(ua: string, width: number): DeviceInfo {\n const u = ua || \"\";\n let type: DeviceInfo[\"type\"] = \"desktop\";\n if (/iPad|Tablet|PlayBook|Silk/i.test(u) || (/Android/i.test(u) && !/Mobile/i.test(u))) type = \"tablet\";\n else if (/Mobi|iPhone|iPod|Android.*Mobile|Windows Phone/i.test(u)) type = \"mobile\";\n else if (width > 0 && width < 768) type = \"mobile\";\n else if (width > 0 && width < 1024) type = \"tablet\";\n let browser: string | undefined;\n if (/Edg\\//i.test(u)) browser = \"edge\";\n else if (/OPR\\/|Opera/i.test(u)) browser = \"opera\";\n else if (/SamsungBrowser/i.test(u)) browser = \"samsung\";\n else if (/Chrome\\/|CriOS/i.test(u)) browser = \"chrome\";\n else if (/Firefox\\/|FxiOS/i.test(u)) browser = \"firefox\";\n else if (/Safari\\//i.test(u) && /Version\\//i.test(u)) browser = \"safari\";\n else if (/MSIE|Trident/i.test(u)) browser = \"ie\";\n let os: string | undefined;\n if (/Windows/i.test(u)) os = \"windows\";\n else if (/iPhone|iPad|iPod/i.test(u)) os = \"ios\";\n else if (/Mac OS X|Macintosh/i.test(u)) os = \"macos\";\n else if (/Android/i.test(u)) os = \"android\";\n else if (/CrOS/i.test(u)) os = \"chromeos\";\n else if (/Linux/i.test(u)) os = \"linux\";\n return { type, browser, os };\n}\n\nexport interface ContextInput {\n anonymousId: string;\n userId?: string | null;\n userAttributes: Record<string, unknown>;\n accountAttributes: Record<string, unknown>;\n url: string;\n firstVisit: boolean;\n eventsSeen: Iterable<string>;\n completedGuides: Iterable<string>;\n dismissedGuides: Iterable<string>;\n seenGuides: Iterable<string>;\n completedChecklists: Iterable<string>;\n audienceIds: Iterable<string>;\n environment: string;\n locale?: string;\n device?: DeviceInfo;\n now?: Date;\n platform?: string;\n screen?: string;\n appVersion?: string;\n}\n\n/** Builds the `TargetingContext` consumed by `evaluateRules`. */\nexport function buildContext(input: ContextInput): TargetingContext {\n let path = \"\";\n const query: Record<string, string> = {};\n try {\n const u = new URL(input.url, \"http://localhost\");\n path = u.pathname;\n u.searchParams.forEach((v, k) => {\n query[k] = v;\n });\n } catch {\n path = input.url;\n }\n const device = input.device ?? (typeof navigator !== \"undefined\" ? detectDevice(navigator.userAgent, typeof window !== \"undefined\" ? window.innerWidth : 0) : { type: \"desktop\" });\n return {\n anonymousId: input.anonymousId,\n userId: input.userId ?? null,\n userAttributes: input.userAttributes,\n accountAttributes: input.accountAttributes,\n url: input.url,\n path,\n query,\n device,\n firstVisit: input.firstVisit,\n eventsSeen: new Set(input.eventsSeen),\n completedGuides: new Set(input.completedGuides),\n dismissedGuides: new Set(input.dismissedGuides),\n seenGuides: new Set(input.seenGuides),\n completedChecklists: new Set(input.completedChecklists),\n audienceIds: new Set(input.audienceIds),\n now: input.now ?? new Date(),\n environment: input.environment,\n locale: input.locale ?? (typeof navigator !== \"undefined\" ? navigator.language : undefined),\n platform: input.platform ?? \"web\",\n ...(input.screen !== undefined ? { screen: input.screen } : {}),\n ...(input.appVersion !== undefined ? { appVersion: input.appVersion } : {}),\n };\n}\n","import type { HeatmapPoint } from \"@guidelytech/shared\";\nimport { elementSelector } from \"./autocapture\";\n\n/** Points per `heatmap` event, and the JSON size at which a batch is sent early (properties cap at 8KB). */\nexport const HEATMAP_MAX_POINTS = 40;\nexport const HEATMAP_MAX_BYTES = 6000;\n/** Movement bins per batch before it is sent. */\nexport const HEATMAP_MAX_BINS = 60;\n\nconst r2 = (n: number) => Math.round(Math.min(1, Math.max(0, n)) * 100) / 100;\n\n/** One heatmap point: page coordinates, a stable selector and the position inside the element (0–1). */\nexport function heatmapPoint(el: Element, e: MouseEvent, rage: boolean): HeatmapPoint {\n const p: HeatmapPoint = { k: rage ? \"r\" : \"c\", x: Math.round(e.pageX ?? 0) || 0, y: Math.round(e.pageY ?? 0) || 0 };\n const s = elementSelector(el).slice(0, 120);\n if (s) p.s = s;\n const rect = el.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n p.rx = r2((e.clientX - rect.left) / rect.width);\n p.ry = r2((e.clientY - rect.top) / rect.height);\n }\n return p;\n}\n\nconst selectors = new WeakMap<Element, string>();\nconst r1 = (n: number) => Math.round(Math.min(1, Math.max(0, n)) * 10) / 10;\n\n/**\n * Movement bin for a pointer sample: per element at 0.1 of the element box (selectors cached per\n * element), or a 16px page-grid cell for `html`/`body` and elements without a box or selector.\n */\nexport function movementBin(el: Element, e: MouseEvent): [string, HeatmapPoint] {\n const p: HeatmapPoint = { k: \"m\", x: Math.round(e.pageX ?? 0) || 0, y: Math.round(e.pageY ?? 0) || 0 };\n let s = /^(HTML|BODY)$/.test(el.tagName) ? \"\" : selectors.get(el);\n if (s === undefined) selectors.set(el, (s = elementSelector(el).slice(0, 120)));\n const rect = s ? el.getBoundingClientRect() : null;\n if (!rect || !(rect.width > 0 && rect.height > 0)) return [`${p.x >> 4},${p.y >> 4}`, p];\n p.s = s;\n p.rx = r1((e.clientX - rect.left) / rect.width);\n p.ry = r1((e.clientY - rect.top) / rect.height);\n return [`${s} ${p.rx},${p.ry}`, p];\n}\n\n/** Click positions and movement bins on the current page, sent as one `heatmap` event per batch. */\nexport class HeatmapBuffer {\n /** The page the buffered points belong to. */\n url = \"\";\n points: HeatmapPoint[] = [];\n private bins = new Map<string, HeatmapPoint>();\n private bytes = 0;\n\n /** Adds a click (`burst` > 0 marks it and the burst's previous clicks as rage); true when the batch is full. */\n add(url: string, point: HeatmapPoint, burst: number): boolean {\n this.url = url;\n for (let i = Math.max(0, this.points.length - burst + 1); i < this.points.length; i++) (this.points[i] as HeatmapPoint).k = \"r\";\n this.points.push(point);\n this.bytes += JSON.stringify(point).length + 1;\n return this.full();\n }\n\n /** Adds a movement sample to its bin (weight +1); true when the batch is full. */\n move(url: string, [key, point]: [string, HeatmapPoint]): boolean {\n this.url = url;\n const bin = this.bins.get(key);\n if (bin) bin.w = (bin.w ?? 1) + 1;\n else {\n this.bins.set(key, point);\n this.bytes += JSON.stringify(point).length + 8; // + room for \"w\"\n }\n return this.full();\n }\n\n private full(): boolean {\n return this.points.length >= HEATMAP_MAX_POINTS || this.bins.size > HEATMAP_MAX_BINS || this.bytes >= HEATMAP_MAX_BYTES;\n }\n\n /** Empties the buffer, returning what was in it (clicks first, then movement bins). */\n take(): { url: string; points: HeatmapPoint[] } | null {\n const points = [...this.points, ...this.bins.values()];\n this.points = [];\n this.bins = new Map();\n this.bytes = 0;\n return points.length ? { url: this.url, points } : null;\n }\n}\n","import { parseStack, type ExceptionProperties, type StackFrame } from \"@guidelytech/shared/runtime\";\n\n/** Byte budget for the `frames` property (the event's properties are capped at 8KB). */\nconst MAX_FRAMES_BYTES = 6000;\n\nfunction fitFrames(frames: StackFrame[]): StackFrame[] {\n const out = frames.slice(0, 30);\n while (out.length > 1 && JSON.stringify(out).length > MAX_FRAMES_BYTES) out.pop();\n return out;\n}\n\nfunction describe(value: unknown): string {\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value) ?? String(value);\n } catch {\n return String(value);\n }\n}\n\n/** Converts anything thrown into `exception` properties. */\nexport function exceptionFromError(error: unknown, source: string, handled: boolean, fallbackType = \"Error\"): ExceptionProperties {\n const isError = error instanceof Error || (!!error && typeof error === \"object\" && typeof (error as Error).message === \"string\" && typeof (error as Error).stack === \"string\");\n const e = error as Error;\n return {\n type: (isError && e.name) || fallbackType,\n message: (isError ? e.message : describe(error)).slice(0, 1000),\n frames: isError ? fitFrames(parseStack(e.stack)) : [],\n source,\n handled,\n };\n}\n\n/** `window` `error` event → exception; `null` for resource-load errors and opaque \"Script error.\" reports. */\nexport function errorEventToException(e: ErrorEvent): ExceptionProperties | null {\n const target = e.target as unknown;\n if (target && typeof Element !== \"undefined\" && target instanceof Element) return null;\n if (e.error != null) return exceptionFromError(e.error, \"onerror\", false);\n const message = e.message || \"\";\n if (!message || /^script error\\.?$/i.test(message.trim())) return null;\n const m = /^(?:Uncaught )?([A-Z]\\w*(?:Error|Exception)):\\s*([\\s\\S]*)$/.exec(message);\n return {\n type: m?.[1] ?? \"Error\",\n message: (m?.[2] ?? message).slice(0, 1000),\n frames: e.filename ? [{ file: e.filename.slice(0, 500), line: e.lineno || undefined, col: e.colno || undefined }] : [],\n source: \"onerror\",\n handled: false,\n };\n}\n\n/** `unhandledrejection` → exception (`UnhandledRejection` for non-Error reasons). */\nexport function rejectionToException(e: PromiseRejectionEvent): ExceptionProperties {\n return exceptionFromError(e.reason, \"unhandledrejection\", false, \"UnhandledRejection\");\n}\n\nconst GUIDELY_SCRIPT = /\\/guidely(-recorder)?(\\.min)?\\.js$/i;\n\n/** Errors raised by Guidely itself (\"[Guidely] …\" messages, or thrown from the script-tag bundle). */\nexport function isGuidelyException(props: ExceptionProperties): boolean {\n if (props.message.startsWith(\"[Guidely]\")) return true;\n const file = props.frames[0]?.file;\n if (!file) return false;\n try {\n return GUIDELY_SCRIPT.test(new URL(file).pathname);\n } catch {\n return GUIDELY_SCRIPT.test(file.replace(/[?#].*$/, \"\"));\n }\n}\n\n/** Per-page-load throttle: the same exception (type + message + top frame) at most `max` times. */\nexport class ExceptionThrottle {\n private seen = new Map<string, number>();\n\n constructor(private readonly max = 5) {}\n\n allow(props: ExceptionProperties): boolean {\n const top = props.frames[0];\n const key = `${props.type}|${props.message}|${top ? `${top.file}:${top.line}:${top.col}` : \"\"}`;\n const n = this.seen.get(key) ?? 0;\n if (n >= this.max) return false;\n if (this.seen.size > 500) this.seen.clear();\n this.seen.set(key, n + 1);\n return true;\n }\n}\n","type AnyFn = (...args: any[]) => void;\n\n/** Tiny typed event emitter. Listener errors are reported, never thrown into the caller. */\nexport class Emitter<Events extends { [K in keyof Events]: AnyFn }> {\n private listeners = new Map<keyof Events, Set<AnyFn>>();\n constructor(private readonly onError?: (err: unknown) => void) {}\n\n on<K extends keyof Events>(event: K, cb: Events[K]): () => void {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(cb);\n return () => this.off(event, cb);\n }\n\n off<K extends keyof Events>(event: K, cb: Events[K]): void {\n this.listeners.get(event)?.delete(cb);\n }\n\n emit<K extends keyof Events>(event: K, ...args: Parameters<Events[K]>): void {\n const set = this.listeners.get(event);\n if (!set) return;\n for (const cb of Array.from(set)) {\n try {\n cb(...args);\n } catch (err) {\n this.onError?.(err);\n }\n }\n }\n\n clear(): void {\n this.listeners.clear();\n }\n}\n","import type { FrequencyConfig, PublishedGuide } from \"@guidelytech/shared\";\n\n/** Per-guide state kept locally and merged with the server's `IdentifyResponse.guideState`. */\nexport interface GuideLocalState {\n impressions: number;\n completedAt?: string | null;\n dismissedAt?: string | null;\n lastShownAt?: string | null;\n}\n\nconst HOUR = 3600 * 1000;\n\n/**\n * Pure frequency evaluation. `shownThisSession` comes from session storage.\n * - `once`: a single impression ever (unless `reshowAfterDismiss` and it was only dismissed).\n * - `once_per_session`: at most once per browser session.\n * - `every_time`: on every trigger (still blocked by completion/dismissal rules below).\n * - `interval`: at most once every `intervalHours`.\n * `maxImpressions` caps total impressions; dismissal blocks re-showing unless `reshowAfterDismiss`\n * (then `cooldownHours` must have elapsed); completion blocks unless mode is `every_time`.\n */\nexport function isFrequencyEligible(freq: FrequencyConfig, state: GuideLocalState | undefined, shownThisSession: boolean, now: number = Date.now()): boolean {\n const s = state ?? { impressions: 0 };\n if (freq.maxImpressions != null && s.impressions >= freq.maxImpressions) return false;\n if (s.completedAt && freq.mode !== \"every_time\") return false;\n if (s.dismissedAt) {\n if (!freq.reshowAfterDismiss) return false;\n if (freq.cooldownHours > 0 && now - Date.parse(s.dismissedAt) < freq.cooldownHours * HOUR) return false;\n }\n switch (freq.mode) {\n case \"once\":\n return s.impressions === 0 || (!!s.dismissedAt && freq.reshowAfterDismiss);\n case \"once_per_session\":\n return !shownThisSession;\n case \"interval\": {\n if (!s.lastShownAt) return true;\n const hours = freq.intervalHours ?? 24;\n return now - Date.parse(s.lastShownAt) >= hours * HOUR;\n }\n case \"every_time\":\n default:\n return true;\n }\n}\n\n/**\n * Exclusive guides (flows, modals, tooltips, announcements, surveys) run one at a time.\n * Banners, checklists and hotspot-only tooltips can coexist with an active flow.\n */\nexport function isExclusiveGuide(guide: PublishedGuide): boolean {\n if (guide.kind === \"banner\" || guide.kind === \"checklist\") return false;\n const steps = guide.config.steps;\n if (steps.length > 0 && steps.every((s) => s.type === \"hotspot\" || s.type === \"banner\")) return false;\n return true;\n}\n\n/** Is `a` mutually exclusive with `b` (by id or key, in either direction)? */\nexport function areMutuallyExclusive(a: PublishedGuide, b: PublishedGuide): boolean {\n const la = a.config.frequency.mutuallyExclusiveWith;\n const lb = b.config.frequency.mutuallyExclusiveWith;\n return la.includes(b.id) || la.includes(b.key) || lb.includes(a.id) || lb.includes(a.key);\n}\n\n/** Survey scheduling window. */\nexport function isWithinSchedule(guide: PublishedGuide, now: number = Date.now()): boolean {\n const s = guide.config.survey;\n if (!s) return true;\n if (s.startAt && now < Date.parse(s.startAt)) return false;\n if (s.endAt && now > Date.parse(s.endAt)) return false;\n return true;\n}\n","export interface ApiResponse<T> {\n status: number;\n ok: boolean;\n data: T | null;\n etag: string | null;\n}\n\nexport type FetchLike = typeof fetch;\n\n/** Thin HTTP client for the public SDK API. Adds the public key as query + header. */\nexport class Api {\n constructor(\n private readonly baseUrl: string,\n private readonly key: string,\n private readonly fetchImpl?: FetchLike,\n ) {}\n\n url(path: string, params: Record<string, string | undefined> = {}): string {\n // Built by hand rather than with URL/searchParams, which React Native does not implement.\n const query = Object.entries({ key: this.key, ...params })\n .filter((e): e is [string, string] => e[1] != null)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n return `${this.baseUrl.replace(/\\/$/, \"\")}/api/v1/sdk${path}?${query}`;\n }\n\n private get fetcher(): FetchLike | null {\n if (this.fetchImpl) return this.fetchImpl;\n return typeof fetch === \"function\" ? fetch.bind(globalThis) : null;\n }\n\n async request<T>(method: \"GET\" | \"POST\", path: string, options: { body?: unknown; etag?: string | null; params?: Record<string, string | undefined>; keepalive?: boolean; timeoutMs?: number; headers?: Record<string, string> } = {}): Promise<ApiResponse<T>> {\n const f = this.fetcher;\n if (!f) throw new Error(\"fetch is not available\");\n const headers: Record<string, string> = { ...options.headers, \"X-Guidely-Key\": this.key, Accept: \"application/json\" };\n if (options.body !== undefined) headers[\"Content-Type\"] = \"application/json\";\n if (options.etag) headers[\"If-None-Match\"] = options.etag;\n const ac = typeof AbortController !== \"undefined\" ? new AbortController() : null;\n const timer = ac ? setTimeout(() => ac.abort(), options.timeoutMs ?? 10000) : null;\n try {\n const res = await f(this.url(path, options.params), {\n method,\n headers,\n body: options.body === undefined ? undefined : JSON.stringify(options.body),\n keepalive: options.keepalive,\n signal: ac?.signal,\n credentials: \"omit\",\n mode: \"cors\",\n });\n let data: T | null = null;\n if (res.status !== 304 && res.status !== 204) {\n try {\n data = (await res.json()) as T;\n } catch {\n data = null;\n }\n }\n return { status: res.status, ok: res.ok, data, etag: res.headers?.get?.(\"etag\") ?? null };\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n get<T>(path: string, options?: { etag?: string | null; params?: Record<string, string | undefined>; headers?: Record<string, string> }): Promise<ApiResponse<T>> {\n return this.request<T>(\"GET\", path, options);\n }\n\n post<T>(path: string, body: unknown, options?: { params?: Record<string, string | undefined>; keepalive?: boolean; headers?: Record<string, string> }): Promise<ApiResponse<T>> {\n return this.request<T>(\"POST\", path, { body, ...options });\n }\n\n /**\n * POST that may answer with server-sent events. Each event is passed to `onEvent`; a JSON answer is\n * returned instead. No timeout: Scout replies can take a while and the server keeps the stream alive.\n */\n async stream<T>(path: string, body: unknown, onEvent: (event: string, data: unknown) => void, headers: Record<string, string> = {}): Promise<ApiResponse<T>> {\n const f = this.fetcher;\n if (!f) throw new Error(\"fetch is not available\");\n const res = await f(this.url(path), {\n method: \"POST\",\n headers: { ...headers, \"X-Guidely-Key\": this.key, Accept: \"text/event-stream, application/json\", \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n credentials: \"omit\",\n mode: \"cors\",\n });\n const type = res.headers?.get?.(\"content-type\") ?? \"\";\n if (!type.includes(\"text/event-stream\") || !res.body) {\n let data: T | null = null;\n try {\n data = (await res.json()) as T;\n } catch {\n data = null;\n }\n return { status: res.status, ok: res.ok, data, etag: null };\n }\n await readEventStream(res.body, onEvent);\n return { status: res.status, ok: res.ok, data: null, etag: null };\n }\n\n /** `navigator.sendBeacon` when available (page unload); returns false when it could not be queued. */\n beacon(path: string, body: unknown): boolean {\n try {\n if (typeof navigator === \"undefined\" || typeof navigator.sendBeacon !== \"function\") return false;\n // text/plain is a CORS-safelisted type: cross-origin beacons need no preflight (which\n // browsers drop during unload). The API parses the body regardless of content type.\n const blob = new Blob([JSON.stringify(body)], { type: \"text/plain;charset=UTF-8\" });\n return navigator.sendBeacon(this.url(path), blob);\n } catch {\n return false;\n }\n }\n}\n\nexport const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));\n\n/** Exponential backoff helper: 1s → 2s → 4s … capped. */\nexport function backoffMs(attempt: number, baseMs = 1000, maxMs = 30000): number {\n return Math.min(maxMs, baseMs * 2 ** Math.max(0, attempt));\n}\n\n/** Fire-and-forget POST with bounded retries (used for state sync; never blocks UI). */\nexport async function postWithRetry<T>(api: Api, path: string, body: unknown, attempts = 3, baseMs = 500): Promise<ApiResponse<T> | null> {\n for (let i = 0; i < attempts; i++) {\n try {\n const res = await api.post<T>(path, body);\n if (res.ok || (res.status >= 400 && res.status < 500 && res.status !== 429)) return res;\n } catch {\n /* network error → retry */\n }\n if (i < attempts - 1) await sleep(backoffMs(i, baseMs, 8000));\n }\n return null;\n}\n\n/** Parses a `text/event-stream` body (`event:` + single-line JSON `data:`; comment lines ignored). */\nexport async function readEventStream(body: ReadableStream<Uint8Array>, onEvent: (event: string, data: unknown) => void): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n const dispatch = (raw: string) => {\n let event = \"message\";\n const data: string[] = [];\n for (const line of raw.split(\"\\n\")) {\n if (!line || line.startsWith(\":\")) continue;\n const i = line.indexOf(\":\");\n const field = i < 0 ? line : line.slice(0, i);\n const value = i < 0 ? \"\" : line.slice(i + 1).replace(/^ /, \"\");\n if (field === \"event\") event = value;\n else if (field === \"data\") data.push(value);\n }\n if (!data.length) return;\n try {\n onEvent(event, JSON.parse(data.join(\"\\n\")));\n } catch {\n /* ignore malformed events */\n }\n };\n for (;;) {\n const { done, value } = await reader.read();\n if (value) buffer += decoder.decode(value, { stream: true }).replace(/\\r\\n?/g, \"\\n\");\n let sep: number;\n while ((sep = buffer.indexOf(\"\\n\\n\")) >= 0) {\n dispatch(buffer.slice(0, sep));\n buffer = buffer.slice(sep + 2);\n }\n if (done) break;\n }\n if (buffer.trim()) dispatch(buffer);\n}\n","import type {\n ConversationLookupResponse,\n ConversationMessagesResponse,\n MessengerConversation,\n MessengerMessage,\n ResourceCenterArticle,\n SdkArticlesResponse,\n StartConversationResponse,\n} from \"@guidelytech/shared\";\nimport type { MessengerApi, MessengerStreamHandlers } from \"@guidelytech/guide-runtime/messenger\";\nimport type { Api } from \"./http\";\nimport { KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\n\ninterface StoredConversation {\n id: string;\n token: string;\n}\n\nconst MAX_STORED = 50;\nconst TOKEN_HEADER = \"X-Guidely-Conversation\";\n\nexport interface MessengerTransportOptions {\n api: Api;\n store: KeyValueStore;\n projectId: string;\n anonymousId: () => string;\n userId: () => string | null;\n /** Page URL to attach to new conversations (omitted when URL collection is off). */\n pageUrl: () => string | undefined;\n}\n\n/** Conversation tokens this browser holds (the only way to read a conversation). */\nexport function storedConversations(store: KeyValueStore, projectId: string): StoredConversation[] {\n const list = readJson<StoredConversation[]>(store, KEYS.conversations(projectId), []);\n return Array.isArray(list) ? list.filter((c) => c && typeof c.id === \"string\" && typeof c.token === \"string\") : [];\n}\n\nexport function forgetConversations(store: KeyValueStore, projectId: string) {\n store.remove(KEYS.conversations(projectId));\n}\n\nclass HttpError extends Error {\n constructor(readonly status: number) {\n super(`Request failed (${status})`);\n }\n}\n\n/** The messenger's server access over the public SDK API. */\nexport function createMessengerTransport(opts: MessengerTransportOptions): MessengerApi {\n const { api, store, projectId } = opts;\n const tokenFor = (id: string) => storedConversations(store, projectId).find((c) => c.id === id)?.token ?? \"\";\n const remember = (id: string, token: string) => {\n const rest = storedConversations(store, projectId).filter((c) => c.id !== id);\n writeJson(store, KEYS.conversations(projectId), [{ id, token }, ...rest].slice(0, MAX_STORED));\n };\n const forget = (id: string) => writeJson(store, KEYS.conversations(projectId), storedConversations(store, projectId).filter((c) => c.id !== id));\n\n /** Dispatches either SSE events or a JSON answer to the stream handlers. */\n async function exchange(path: string, body: unknown, headers: Record<string, string>, h: MessengerStreamHandlers, onStarted?: (r: StartConversationResponse) => void) {\n let finished = false;\n const res = await api.stream<StartConversationResponse | ConversationMessagesResponse>(\n path,\n body,\n (event, data) => {\n if (event === \"conversation\") {\n const d = data as StartConversationResponse;\n onStarted?.(d);\n h.onConversation?.(d.conversation);\n d.messages.forEach((m) => h.onMessage(m));\n } else if (event === \"message\") h.onMessage(data as MessengerMessage);\n else if (event === \"delta\") {\n const d = data as { messageId: string; text: string };\n h.onDelta(d.messageId, d.text);\n } else if (event === \"done\") {\n const d = data as { message: MessengerMessage | null; conversation: MessengerConversation };\n finished = true;\n h.onDone(d.message, d.conversation);\n } else if (event === \"error\") h.onError((data as { message?: string })?.message ?? \"Something went wrong\");\n },\n headers,\n );\n if (!res.ok) throw new HttpError(res.status);\n if (res.data) {\n // JSON answer (no Scout reply): the stored messages and the conversation.\n const d = res.data;\n if (\"token\" in d) {\n onStarted?.(d);\n h.onConversation?.(d.conversation);\n }\n d.messages.forEach((m) => h.onMessage(m));\n h.onDone(d.messages.at(-1) ?? null, d.conversation);\n } else if (!finished) h.onError(\"The reply was interrupted\");\n }\n\n return {\n async listConversations() {\n const tokens = storedConversations(store, projectId).map((c) => c.token);\n if (!tokens.length) return [];\n const res = await api.post<ConversationLookupResponse>(\"/conversations/lookup\", { tokens });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n // Drop tokens the server no longer knows (deleted by retention).\n const known = new Set(res.data.conversations.map((c) => c.id));\n for (const c of storedConversations(store, projectId)) if (!known.has(c.id)) forget(c.id);\n return res.data.conversations.map(({ token: _token, ...c }) => c);\n },\n async loadMessages(id, since) {\n const res = await api.get<ConversationMessagesResponse>(`/conversations/${encodeURIComponent(id)}/messages`, { params: { since: since ?? undefined }, headers: { [TOKEN_HEADER]: tokenFor(id) } });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n start(text, h) {\n return exchange(\"/conversations\", { anonymousId: opts.anonymousId(), userId: opts.userId(), message: text, pageUrl: opts.pageUrl() }, {}, h, (r) => remember(r.conversation.id, r.token));\n },\n send(id, text, h) {\n return exchange(`/conversations/${encodeURIComponent(id)}/messages`, { message: text }, { [TOKEN_HEADER]: tokenFor(id) }, h);\n },\n async handoff(id) {\n const res = await api.post<ConversationMessagesResponse>(`/conversations/${encodeURIComponent(id)}/handoff`, {}, { headers: { [TOKEN_HEADER]: tokenFor(id) } });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n async rate(id, rating) {\n const res = await api.post(`/conversations/${encodeURIComponent(id)}/rating`, { rating }, { headers: { [TOKEN_HEADER]: tokenFor(id) } });\n if (!res.ok) throw new HttpError(res.status);\n },\n async listArticles() {\n const res = await api.get<SdkArticlesResponse>(\"/articles\");\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n async getArticle(id) {\n const res = await api.get<{ article: ResourceCenterArticle }>(`/articles/${encodeURIComponent(id)}`);\n return res.ok && res.data ? res.data.article : null;\n },\n async searchArticles(q) {\n const res = await api.get<{ articles: ResourceCenterArticle[] }>(\"/resource-center/search\", { params: { q } });\n return res.ok && res.data ? res.data.articles : [];\n },\n };\n}\n","type Listener = (url: string) => void;\n\ninterface PatchedHistory extends History {\n __guidelyPatched?: { count: number; pushState: History[\"pushState\"]; replaceState: History[\"replaceState\"] };\n}\n\n/**\n * Detects SPA navigation: patches `history.pushState`/`replaceState` (reference counted, restored\n * on the last unwatch), listens to `popstate` and `hashchange`, and debounces into one callback.\n */\nexport function watchNavigation(listener: Listener, debounceMs = 50): () => void {\n if (typeof window === \"undefined\") return () => {};\n const win = window;\n const hist = win.history as PatchedHistory;\n let last = win.location.href;\n let timer: ReturnType<typeof setTimeout> | null = null;\n const check = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n timer = null;\n const href = win.location.href;\n if (href !== last) {\n last = href;\n listener(href);\n }\n }, debounceMs);\n };\n if (!hist.__guidelyPatched) {\n const pushState = hist.pushState;\n const replaceState = hist.replaceState;\n hist.__guidelyPatched = { count: 0, pushState, replaceState };\n hist.pushState = function (this: History, ...args: Parameters<History[\"pushState\"]>) {\n const r = pushState.apply(this, args);\n win.dispatchEvent(new Event(\"guidely:navigate\"));\n return r;\n };\n hist.replaceState = function (this: History, ...args: Parameters<History[\"replaceState\"]>) {\n const r = replaceState.apply(this, args);\n win.dispatchEvent(new Event(\"guidely:navigate\"));\n return r;\n };\n }\n hist.__guidelyPatched.count += 1;\n win.addEventListener(\"guidely:navigate\", check);\n win.addEventListener(\"popstate\", check);\n win.addEventListener(\"hashchange\", check);\n return () => {\n if (timer) clearTimeout(timer);\n win.removeEventListener(\"guidely:navigate\", check);\n win.removeEventListener(\"popstate\", check);\n win.removeEventListener(\"hashchange\", check);\n const p = hist.__guidelyPatched;\n if (p) {\n p.count -= 1;\n if (p.count <= 0) {\n hist.pushState = p.pushState;\n hist.replaceState = p.replaceState;\n delete hist.__guidelyPatched;\n }\n }\n };\n}\n","/** What `page_leave` reports for the page being left. */\nexport interface PageLeaveInfo {\n url: string;\n /** Time the page was visible (pauses while `document.hidden`). */\n durationMs: number;\n /** Furthest point scrolled to, as a percentage (0–100) of the page height. */\n scrollDepth: number;\n}\n\n/** Current scroll depth (0–100): the bottom of the viewport relative to the page height. */\nexport function scrollDepth(): number {\n const de = document.documentElement;\n const height = Math.max(de?.scrollHeight || 0, document.body?.scrollHeight || 0);\n const view = window.innerHeight || de?.clientHeight || 0;\n if (height <= 0 || height <= view) return 100;\n const y = window.scrollY || de?.scrollTop || 0;\n return Math.max(0, Math.min(100, Math.round(((y + view) / height) * 100)));\n}\n\n/** Tracks visible time and maximum scroll depth of the current page (for `page_leave`). */\nexport class PageTracker {\n url = \"\";\n private visibleMs = 0;\n private visibleSince: number | null = null;\n private maxScroll = 0;\n\n /** Starts measuring a new page. */\n start(url: string, now = Date.now()): void {\n this.url = url;\n this.visibleMs = 0;\n this.visibleSince = typeof document !== \"undefined\" && document.visibilityState === \"hidden\" ? null : now;\n this.maxScroll = 0;\n this.measureScroll();\n }\n\n /** Pauses / resumes the visible-time clock. */\n setHidden(hidden: boolean, now = Date.now()): void {\n if (hidden && this.visibleSince !== null) {\n this.visibleMs += Math.max(0, now - this.visibleSince);\n this.visibleSince = null;\n } else if (!hidden && this.visibleSince === null) this.visibleSince = now;\n }\n\n measureScroll(): void {\n try {\n this.maxScroll = Math.max(this.maxScroll, scrollDepth());\n } catch {\n /* no layout */\n }\n }\n\n /** Final numbers for the current page. */\n leave(now = Date.now()): PageLeaveInfo {\n this.measureScroll();\n const running = this.visibleSince !== null ? Math.max(0, now - this.visibleSince) : 0;\n return { url: this.url, durationMs: Math.round(this.visibleMs + running), scrollDepth: this.maxScroll };\n }\n}\n","import type { SdkEvent } from \"@guidelytech/shared\";\nimport { backoffMs } from \"./http\";\nimport { readJson, writeJson, type KeyValueStore } from \"./storage\";\n\nexport interface EventQueueOptions {\n store: KeyValueStore;\n storageKey: string;\n /** Sends one batch. Resolve `{ ok: true }` on success, `{ ok: false, retry }` otherwise. */\n send: (events: SdkEvent[]) => Promise<{ ok: boolean; retry?: boolean }>;\n /** Synchronous best-effort send used on page hide. */\n beacon?: (events: SdkEvent[]) => boolean;\n /** Should events be flushed right now? (analytics enabled + consent granted). */\n enabled: () => boolean;\n flushIntervalMs?: number;\n maxQueue?: number;\n batchSize?: number;\n maxAttempts?: number;\n onError?: (err: unknown) => void;\n}\n\n/**\n * Bounded, persisted event queue. Batches ≤50 events every 2s (or on demand), dedupes by\n * `eventId`, retries with exponential backoff (1s→30s, 5 attempts) and keeps failed events for\n * the next flush. Drops the oldest events once the queue exceeds 200.\n */\nexport class EventQueue {\n private events: SdkEvent[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private retryTimer: ReturnType<typeof setTimeout> | null = null;\n private inflight = false;\n private inflightIds = new Set<string>();\n private attempt = 0;\n private destroyed = false;\n private readonly flushIntervalMs: number;\n private readonly maxQueue: number;\n private readonly batchSize: number;\n private readonly maxAttempts: number;\n\n constructor(private readonly opts: EventQueueOptions) {\n this.flushIntervalMs = opts.flushIntervalMs ?? 2000;\n this.maxQueue = opts.maxQueue ?? 200;\n this.batchSize = opts.batchSize ?? 50;\n this.maxAttempts = opts.maxAttempts ?? 5;\n const persisted = readJson<SdkEvent[]>(opts.store, opts.storageKey, []);\n if (Array.isArray(persisted)) this.events = persisted.filter((e) => e && typeof e.eventId === \"string\").slice(-this.maxQueue);\n // Events left over from a previous page load are flushed on the next tick.\n if (this.events.length) this.schedule();\n }\n\n get size(): number {\n return this.events.length;\n }\n\n /** Pending events (read-only copy, for debugging). */\n peek(): SdkEvent[] {\n return this.events.slice();\n }\n\n enqueue(event: SdkEvent): void {\n if (this.destroyed) return;\n if (this.events.some((e) => e.eventId === event.eventId)) return;\n this.events.push(event);\n if (this.events.length > this.maxQueue) this.events.splice(0, this.events.length - this.maxQueue);\n this.persist();\n this.schedule();\n }\n\n private persist(): void {\n writeJson(this.opts.store, this.opts.storageKey, this.events);\n }\n\n private schedule(): void {\n if (this.timer || this.retryTimer || this.destroyed) return;\n this.timer = setTimeout(() => {\n this.timer = null;\n void this.flush();\n }, this.flushIntervalMs);\n }\n\n /** Sends queued events now (one batch at a time). Safe to call at any time. */\n async flush(): Promise<void> {\n if (this.destroyed || this.inflight || !this.events.length || !this.opts.enabled()) return;\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n this.inflight = true;\n const batch = this.events.slice(0, this.batchSize);\n this.inflightIds = new Set(batch.map((e) => e.eventId));\n let ok = false;\n let retry = true;\n try {\n const res = await this.opts.send(batch);\n ok = res.ok;\n retry = res.retry ?? !res.ok;\n } catch (err) {\n this.opts.onError?.(err);\n }\n this.inflight = false;\n this.inflightIds.clear();\n if (this.destroyed) return;\n if (ok || !retry) {\n const ids = new Set(batch.map((e) => e.eventId));\n this.events = this.events.filter((e) => !ids.has(e.eventId));\n this.attempt = 0;\n this.persist();\n if (this.events.length) this.schedule();\n return;\n }\n this.attempt += 1;\n if (this.attempt >= this.maxAttempts) {\n // Give up for now; events stay queued until the next flush trigger (navigation, timer, unload).\n this.attempt = 0;\n return;\n }\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n void this.flush();\n }, backoffMs(this.attempt - 1));\n }\n\n /** Best-effort synchronous flush on unload using `sendBeacon`. */\n flushSync(): void {\n if (this.destroyed || !this.opts.enabled() || !this.opts.beacon) return;\n // Events already in flight (fetch with keepalive) survive unload; only beacon the rest to avoid duplicate batches.\n const batch = this.events.filter((e) => !this.inflightIds.has(e.eventId)).slice(0, this.batchSize);\n if (!batch.length) return;\n if (this.opts.beacon(batch)) {\n const ids = new Set(batch.map((e) => e.eventId));\n this.events = this.events.filter((e) => !ids.has(e.eventId));\n this.persist();\n }\n }\n\n clear(): void {\n this.events = [];\n this.persist();\n }\n\n destroy(): void {\n this.destroyed = true;\n if (this.timer) clearTimeout(this.timer);\n if (this.retryTimer) clearTimeout(this.retryTimer);\n this.timer = null;\n this.retryTimer = null;\n this.persist();\n }\n}\n","import type { RecorderApi } from \"./recorder-types\";\n\n/**\n * Loads the session-replay chunk on demand. The import is rewritten per build: `./recorder.js`\n * (npm; consumers' bundlers code-split it) or, in the script-tag build, a loader that injects\n * `guidely-recorder.js` and resolves `window.__guidelyRecorder` (`recorder` is a thenable there).\n */\nexport const loadRecorder = async (): Promise<RecorderApi> => (await import(\"./recorder\")).recorder;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAAuH;AAavH,IAAAC,wBAaO;AACP,IAAAA,wBAA4B;;;AC1B5B,2BAA+J;;;ACExJ,IAAM,qBAAqB,IAAI,OAAO;AAE7C,IAAM,QAAQ;AAGd,SAAS,UAAU,OAAwD;AACzE,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI;AACF,WAAO,MAAM,KAAK,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,EA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5pDO,IAAM,UAAU;AAAA,EACrB,MAAM,CAAC,YAAsD,cAAc,KAAK,OAAO;AAAA,EACvF,KAAK,MAAM,cAAc,IAAI;AAAA,EAC7B;AAAA,EACA,SAAS;AACX;AAEA,IAAO,gBAAQ;","names":["import_runtime","import_guide_runtime","attr","import_guide_runtime","import_runtime","current"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/client.ts","../src/authoring.ts","../src/snapshot.ts","../src/storage.ts","../src/capture-token.ts","../src/load-capture.ts","../src/autocapture.ts","../src/context.ts","../src/heatmap.ts","../src/errors.ts","../src/emitter.ts","../src/frequency.ts","../src/http.ts","../src/messenger-api.ts","../src/messenger-visitor.ts","../src/navigation.ts","../src/page-tracking.ts","../src/queue.ts","../src/load-recorder.ts"],"sourcesContent":["/**\n * @guidelytech/sdk-core — framework-independent Guidely browser SDK.\n *\n * SSR-safe to import: nothing touches `window` at module scope. Create a client in the browser\n * with {@link createGuidely} (or `Guidely.init` for script-tag installs).\n */\nimport { GuidelyClient, createGuidely, SDK_VERSION } from \"./client\";\n\nexport { GuidelyClient, createGuidely, SDK_NAME, SDK_VERSION, DEFAULT_API_URL } from \"./client\";\nexport type { GuidelyOptions, GuidelyEvents, GuidelyEventName, GuidelyUser, GuidelyAccount, GuidelyEnvironment, ConsentState, ChecklistProgressState, PersistedState, SessionState, GuideStepInfo } from \"./types\";\nexport { isFrequencyEligible, isExclusiveGuide, areMutuallyExclusive, isWithinSchedule } from \"./frequency\";\nexport type { GuideLocalState } from \"./frequency\";\nexport { detectDevice, buildContext } from \"./context\";\nexport type { DeviceInfo, ContextInput } from \"./context\";\nexport { EventQueue } from \"./queue\";\nexport type { EventQueueOptions } from \"./queue\";\nexport { watchNavigation } from \"./navigation\";\nexport { createStorage, KEYS } from \"./storage\";\nexport type { KeyValueStore, StorageKind } from \"./storage\";\nexport { AUTHORING_PARAM, HEARTBEAT_MS } from \"./authoring\";\nexport { captureSnapshot } from \"./snapshot\";\nexport type { AuthoringIncomingMessage, AuthoringOutgoingMessage } from \"./authoring\";\nexport { CAPTURE_PARAM } from \"./capture-token\";\nexport type { CaptureMarker } from \"./capture-token\";\nexport type { CaptureOutgoingMessage } from \"./capture\";\nexport type { AppSnapshot, PublishedGuide, SdkConfigResponse, SdkEvent, TargetingContext, GuideConfig, GuideStep, AutocaptureSettings, ExceptionProperties, StackFrame } from \"@guidelytech/shared\";\nexport type { ClickProperties } from \"./autocapture\";\nexport type { PageLeaveInfo } from \"./page-tracking\";\n\n/** Global-style API used by the script-tag embed: `Guidely.init(options)` / `Guidely.get()`. */\nexport const Guidely = {\n init: (options: Parameters<typeof GuidelyClient.init>[0]) => GuidelyClient.init(options),\n get: () => GuidelyClient.get(),\n createGuidely,\n version: SDK_VERSION,\n};\n\nexport default Guidely;\n","import { evaluateRules, randomId, rolloutBucket, sanitizeProperties, supportsPlatform, type ExceptionProperties } from \"@guidelytech/shared/runtime\";\nimport {\n type AutocaptureSettings,\n type ChecklistTask,\n type EventName,\n type IdentifyRequest,\n type IdentifyResponse,\n type PublishedGuide,\n type ResourceCenterArticle,\n type SdkConfigResponse,\n type SdkEvent,\n type TargetingContext,\n} from \"@guidelytech/shared\";\nimport {\n destroyHost,\n isChecklistComplete,\n renderChecklist,\n renderResourceCenter,\n renderSurvey,\n runGuide,\n urlMatches,\n waitForTarget,\n type ChecklistWidget,\n type GuideController,\n type ResourceCenterWidget,\n type SurveyWidget,\n} from \"@guidelytech/guide-runtime\";\nimport { createScope } from \"@guidelytech/guide-runtime\";\nimport type { MessengerTab, MessengerWidget } from \"@guidelytech/guide-runtime/messenger\";\nimport { AuthoringBridge } from \"./authoring\";\nimport type { CaptureBridge } from \"./capture\";\nimport { takeCaptureToken } from \"./capture-token\";\nimport { loadCapture } from \"./load-capture\";\nimport { DEFAULT_MASK_SELECTORS, describeClick, interactiveElement, isIgnoredElement, RageClickDetector, validSelectors } from \"./autocapture\";\nimport { buildContext, detectDevice } from \"./context\";\nimport { HeatmapBuffer, heatmapPoint, movementBin } from \"./heatmap\";\nimport { errorEventToException, exceptionFromError, ExceptionThrottle, isGuidelyException, rejectionToException } from \"./errors\";\nimport { Emitter } from \"./emitter\";\nimport { areMutuallyExclusive, isExclusiveGuide, isFrequencyEligible, isWithinSchedule, type GuideLocalState } from \"./frequency\";\nimport { Api, postWithRetry } from \"./http\";\nimport { createMessengerTransport, forgetConversations } from \"./messenger-api\";\nimport { buildMessengerVisitor } from \"./messenger-visitor\";\nimport { watchNavigation } from \"./navigation\";\nimport { PageTracker } from \"./page-tracking\";\nimport { EventQueue } from \"./queue\";\nimport { loadRecorder } from \"./load-recorder\";\nimport type { ReplayController, ReplayRecordingConfig } from \"./replay\";\nimport { createStorage, KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\nimport type { ChecklistProgressState, ConsentState, GuidelyAccount, GuidelyEvents, GuidelyOptions, GuidelyUser, PersistedState, SessionState } from \"./types\";\n\nexport const SDK_NAME = \"@guidelytech/sdk-core\";\nexport const SDK_VERSION = \"0.6.1\";\nexport const DEFAULT_API_URL = \"https://api.guidely.app\";\n\ntype EvalReason = \"ready\" | \"navigation\" | \"event\" | \"click\" | \"visible\" | \"identify\" | \"after_guide\" | \"timer\" | \"manual\";\ninterface EvalDetail {\n eventName?: string;\n target?: Element | null;\n guideId?: string;\n endedGuide?: PublishedGuide;\n newAudiences?: Set<string>;\n}\n\ninterface ActiveGuide {\n guide: PublishedGuide;\n controller?: GuideController;\n survey?: SurveyWidget;\n scope?: { destroy(): void };\n manual: boolean;\n startUrl: string;\n}\n\ninterface QueuedGuide {\n guide: PublishedGuide;\n url: string;\n pageScoped: boolean;\n}\n\nconst PAGE_SCOPED = new Set([\"page_load\", \"url_match\", \"element_click\", \"element_visible\", \"delay\"]);\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst MAX_SESSION_EXCEPTIONS = 100;\n\nfunction isBrowser(): boolean {\n return typeof window !== \"undefined\" && typeof document !== \"undefined\";\n}\n\nfunction nowIso(): string {\n return new Date().toISOString();\n}\n\nfunction emptyState(): PersistedState {\n return { guides: {}, checklists: {}, surveysSubmitted: [], audienceIds: [] };\n}\n\nfunction newSession(now = Date.now()): SessionState {\n return { id: `s_${randomId(16)}`, startedAt: new Date(now).toISOString(), shownGuides: [], events: [], lastActivityAt: now };\n}\n\n/**\n * Framework-independent Guidely client. Create one per page with {@link createGuidely} or\n * {@link GuidelyClient.init}; adapters (`@guidelytech/react`, `@guidelytech/svelte`) wrap it.\n */\nexport class GuidelyClient {\n readonly options: Readonly<Required<Pick<GuidelyOptions, \"projectId\" | \"environment\" | \"apiUrl\" | \"analytics\" | \"consent\" | \"storage\" | \"configRefreshMs\" | \"pollIntervalMs\" | \"debug\">>> & GuidelyOptions;\n private readonly api: Api;\n private readonly store: KeyValueStore;\n private readonly sessionStore: KeyValueStore;\n private readonly emitter: Emitter<GuidelyEvents>;\n private readonly queue: EventQueue;\n private config: SdkConfigResponse | null = null;\n private etag: string | null = null;\n private anonymousId: string;\n private user: GuidelyUser | null = null;\n private state: PersistedState;\n private session: SessionState;\n private consent: ConsentState;\n private readyPromise: Promise<void> | null = null;\n private resolveReady: (() => void) | null = null;\n private isReady = false;\n private destroyed = false;\n private active: ActiveGuide | null = null;\n private queued: QueuedGuide[] = [];\n private widgets = new Map<string, { destroy(): void; checklist?: ChecklistWidget; scope?: { destroy(): void }; controller?: GuideController; manual?: boolean }>();\n private resourceCenter: ResourceCenterWidget | null = null;\n private resourceCenterScope: { destroy(): void } | null = null;\n private messenger: MessengerWidget | null = null;\n private messengerScope: { destroy(): void } | null = null;\n private messengerLoading: Promise<MessengerWidget | null> | null = null;\n private cleanups: Array<() => void> = [];\n private timers = new Set<ReturnType<typeof setTimeout>>();\n private visibilityObservers = new Map<string, () => void>();\n private firedDelays = new Set<string>();\n private firstVisit: boolean;\n private lastUrl: string;\n private authoring: AuthoringBridge | null = null;\n private capture: CaptureBridge | null = null;\n /** A capture token was found and the (lazily loaded) capture bridge is starting. */\n private captureStarting = false;\n private lastAudiences = new Set<string>();\n /** Set once the app calls identify()/reset(); bootstrap then leaves identity alone instead of re-identifying. */\n private identitySettled = false;\n // Product analytics (autocapture, error tracking, session replay)\n /** Created once the recorder chunk has loaded (it carries the replay controller). */\n private replay: ReplayController | null = null;\n private replayLoading = false;\n private readonly pageTracker = new PageTracker();\n private readonly rage = new RageClickDetector();\n private readonly heatmap = new HeatmapBuffer();\n private readonly exceptionThrottle = new ExceptionThrottle();\n /** Exceptions seen before the config was loaded (reported once it is known whether the server accepts them). */\n private earlyExceptions: Array<[ExceptionProperties, Record<string, unknown> | undefined]> = [];\n private initialPageViewSent = false;\n private pageViewUrl: string | null = null;\n private pageLeft = false;\n\n constructor(options: GuidelyOptions) {\n if (!isBrowser()) throw new Error(\"[Guidely] createGuidely() must be called in the browser. Create the client inside useEffect / onMount, or use the framework adapters.\");\n if (!options || !options.projectId) throw new Error(\"[Guidely] `projectId` (your environment public key, e.g. pk_dev_…) is required.\");\n this.options = {\n ...options,\n environment: options.environment ?? (options.projectId.startsWith(\"pk_prod\") ? \"production\" : options.projectId.startsWith(\"pk_stag\") ? \"staging\" : \"development\"),\n apiUrl: options.apiUrl ?? DEFAULT_API_URL,\n analytics: options.analytics ?? true,\n consent: options.consent ?? \"granted\",\n storage: options.storage ?? \"local\",\n configRefreshMs: options.configRefreshMs ?? 5 * 60 * 1000,\n pollIntervalMs: options.pollIntervalMs ?? 1000,\n debug: options.debug ?? false,\n };\n this.consent = this.options.consent;\n this.emitter = new Emitter<GuidelyEvents>((err) => this.reportError(err));\n this.api = new Api(this.options.apiUrl, this.options.projectId, options.fetch);\n this.store = createStorage(this.options.storage);\n this.sessionStore = this.options.storage === \"memory\" ? this.store : createStorage(\"session\");\n this.anonymousId = this.store.get(KEYS.anon) || \"\";\n if (!this.anonymousId) {\n this.anonymousId = `anon_${randomId(20)}`;\n this.store.set(KEYS.anon, this.anonymousId);\n }\n this.firstVisit = !this.store.get(KEYS.seen);\n this.store.set(KEYS.seen, nowIso());\n this.state = { ...emptyState(), ...readJson<Partial<PersistedState>>(this.store, KEYS.state(this.options.projectId), {}) };\n this.user = readJson<GuidelyUser | null>(this.store, KEYS.user(this.options.projectId), null);\n const session = readJson<SessionState | null>(this.sessionStore, KEYS.session, null);\n this.session = session && session.id ? session : newSession();\n this.persistSession();\n this.lastUrl = location.href;\n this.lastAudiences = new Set(this.state.audienceIds);\n this.queue = new EventQueue({\n store: this.store,\n storageKey: KEYS.queue(this.options.projectId),\n enabled: () => this.analyticsEnabled(),\n send: async (events) => {\n const res = await this.api.post<{ accepted: number }>(\"/events\", { events, sentAt: nowIso(), sdk: { name: SDK_NAME, version: SDK_VERSION } }, { keepalive: true });\n return { ok: res.ok, retry: !(res.status >= 400 && res.status < 500 && res.status !== 429) };\n },\n beacon: (events) => this.api.beacon(\"/events\", { events, sentAt: nowIso(), sdk: { name: SDK_NAME, version: SDK_VERSION } }),\n onError: (err) => this.reportError(err),\n });\n if (options.user) this.user = { ...options.user };\n }\n\n // ---------------------------------------------------------------------------\n // Lifecycle\n // ---------------------------------------------------------------------------\n\n /** Loads config (cache first, then network), wires listeners and evaluates triggers. Idempotent. */\n init(): Promise<void> {\n if (this.readyPromise) return this.readyPromise;\n this.readyPromise = new Promise<void>((resolve) => {\n this.resolveReady = resolve;\n });\n void this.bootstrap();\n return this.readyPromise;\n }\n\n /** Resolves once the client is ready (alias of `init()`). */\n ready(): Promise<void> {\n return this.init();\n }\n\n private async bootstrap(): Promise<void> {\n this.wireErrorListeners();\n try {\n const cached = readJson<SdkConfigResponse | null>(this.store, KEYS.config(this.options.projectId), null);\n this.etag = this.store.get(KEYS.etag(this.options.projectId));\n if (cached && cached.guides) this.config = webOnly(cached);\n await this.fetchConfig();\n if (this.destroyed) return;\n this.wireListeners();\n if (!this.identitySettled) {\n if (this.options.user) await this.identify(this.options.user.id, this.options.user.traits, this.options.user.account);\n else if (this.user?.id) await this.identify(this.user.id, this.user.traits, this.user.account);\n }\n if (this.destroyed) return;\n this.isReady = true;\n if (this.config) this.emitter.emit(\"ready\", this.config);\n this.resolveReady?.();\n // Capture is detected before anything renders, so guides and widgets never appear in its screenshots.\n const capturing = !this.options.disableAuthoring && this.maybeStartCapture();\n this.renderPersistentWidgets();\n this.resumeActiveGuide();\n this.evaluate(\"ready\");\n if (!this.options.disableAuthoring && !capturing) this.maybeStartAuthoring();\n this.pageTracker.start(location.href);\n this.touchSession(); // a page load is activity: rotate an expired session before capture starts\n this.syncCapture();\n } catch (err) {\n this.reportError(err);\n this.isReady = true;\n this.resolveReady?.();\n }\n }\n\n private async fetchConfig(): Promise<boolean> {\n try {\n const res = await this.api.get<SdkConfigResponse>(\"/config\", { etag: this.etag, params: { platform: \"web\" } });\n if (res.status === 304) return true;\n if (res.ok && res.data && Array.isArray(res.data.guides)) {\n this.config = webOnly(res.data);\n this.etag = res.etag;\n writeJson(this.store, KEYS.config(this.options.projectId), res.data);\n if (res.etag) this.store.set(KEYS.etag(this.options.projectId), res.etag);\n else this.store.remove(KEYS.etag(this.options.projectId));\n this.emitter.emit(\"config\", res.data);\n this.log(\"config loaded\", res.data.configVersion, `${res.data.guides.length} guides`);\n return true;\n }\n this.reportError(new Error(`[Guidely] config request failed (${res.status})${this.config ? \"; using cached config\" : \"\"}`));\n return false;\n } catch (err) {\n this.reportError(new Error(`[Guidely] config request failed: ${err instanceof Error ? err.message : String(err)}${this.config ? \"; using cached config\" : \"\"}`));\n return false;\n }\n }\n\n private wireListeners(): void {\n const doc = document;\n const win = window;\n this.cleanups.push(watchNavigation((url) => this.handleNavigation(url)));\n const onClick = (e: Event) => this.handleDocumentClick(e);\n doc.addEventListener(\"click\", onClick, true);\n this.cleanups.push(() => doc.removeEventListener(\"click\", onClick, true));\n const onVisibility = () => {\n const hidden = doc.visibilityState === \"hidden\";\n this.pageTracker.setHidden(hidden);\n if (!hidden) return;\n this.replay?.flushOnHide();\n this.queue.flushSync();\n };\n const onPageHide = () => {\n this.flushHeatmap();\n if (!this.pageLeft) this.leavePage(null);\n this.pageLeft = true;\n this.replay?.flushOnHide();\n this.queue.flushSync();\n };\n const onPageShow = (e: PageTransitionEvent) => {\n if (!e.persisted || !this.pageLeft) return;\n this.pageLeft = false;\n this.pageTracker.start(location.href);\n };\n // Activity keeps the session alive (and rotates it after the inactivity timeout).\n let lastScroll = 0;\n const onScroll = () => {\n const now = Date.now();\n if (now - lastScroll < 250) return;\n lastScroll = now;\n this.pageTracker.measureScroll();\n this.touchSession();\n };\n const onKey = () => this.touchSession();\n // Mouse-movement heatmap: one sample (the latest position) per 200ms while the pointer moves; fine pointers only.\n let move: MouseEvent | null = null;\n let moveTimer: ReturnType<typeof setTimeout> | null = null;\n const onMove = (e: MouseEvent) => {\n move = e;\n moveTimer ??= setTimeout(() => {\n moveTimer = null;\n if (move) this.sampleMove(move);\n move = null;\n }, 200);\n };\n if (win.matchMedia?.(\"(pointer: fine)\").matches) {\n doc.addEventListener(\"mousemove\", onMove, { passive: true });\n this.cleanups.push(() => {\n doc.removeEventListener(\"mousemove\", onMove);\n if (moveTimer) clearTimeout(moveTimer);\n });\n }\n doc.addEventListener(\"visibilitychange\", onVisibility);\n win.addEventListener(\"pagehide\", onPageHide);\n win.addEventListener(\"pageshow\", onPageShow);\n win.addEventListener(\"scroll\", onScroll, { passive: true });\n doc.addEventListener(\"keydown\", onKey, true);\n this.cleanups.push(() => {\n doc.removeEventListener(\"visibilitychange\", onVisibility);\n win.removeEventListener(\"pagehide\", onPageHide);\n win.removeEventListener(\"pageshow\", onPageShow);\n win.removeEventListener(\"scroll\", onScroll);\n doc.removeEventListener(\"keydown\", onKey, true);\n });\n const refresh = setInterval(() => void this.refresh(), this.options.configRefreshMs);\n this.cleanups.push(() => clearInterval(refresh));\n // Idle re-check: DOM can change without navigation (lazy content), so re-arm element-visibility\n // observers for eligible guides and drain the queue.\n const poll = setInterval(() => {\n if (!this.isReady || !this.config || this.editing() || doc.visibilityState === \"hidden\") return;\n const url = location.href;\n const ctx = this.getContext();\n for (const guide of this.config.guides) {\n if (guide.config.trigger.type === \"element_visible\" && guide.config.trigger.value) this.armVisibility(guide, ctx, url);\n }\n this.drainQueue(url, ctx);\n }, Math.max(250, this.options.pollIntervalMs));\n this.cleanups.push(() => clearInterval(poll));\n const onMessage = (e: MessageEvent) => this.authoring?.handleMessage(e);\n win.addEventListener(\"message\", onMessage);\n this.cleanups.push(() => win.removeEventListener(\"message\", onMessage));\n }\n\n /** Uncaught errors + unhandled rejections; attached before the config loads so boot errors are kept. */\n private wireErrorListeners(): void {\n const win = window;\n const onError = (e: ErrorEvent) => this.captureGlobalException(errorEventToException(e));\n const onRejection = (e: PromiseRejectionEvent) => this.captureGlobalException(rejectionToException(e));\n win.addEventListener(\"error\", onError);\n win.addEventListener(\"unhandledrejection\", onRejection);\n this.cleanups.push(() => {\n win.removeEventListener(\"error\", onError);\n win.removeEventListener(\"unhandledrejection\", onRejection);\n });\n }\n\n /** Re-fetches the published config and re-evaluates triggers. */\n async refresh(): Promise<void> {\n if (this.destroyed) return;\n const before = this.config?.configVersion;\n await this.fetchConfig();\n if (this.config && this.config.configVersion !== before) {\n this.renderPersistentWidgets();\n this.evaluate(\"ready\");\n }\n this.syncCapture();\n }\n\n /** Tears everything down: guides, widgets, listeners, timers, host element. Re-init is allowed via a new client. */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.active?.controller?.destroy();\n this.active?.survey?.destroy();\n this.active?.scope?.destroy();\n this.active = null;\n this.queued = [];\n this.widgets.forEach((w) => w.destroy());\n this.widgets.clear();\n this.resourceCenter?.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n this.destroyMessenger();\n this.visibilityObservers.forEach((stop) => stop());\n this.visibilityObservers.clear();\n this.timers.forEach((t) => clearTimeout(t));\n this.timers.clear();\n this.cleanups.splice(0).forEach((fn) => fn());\n this.authoring?.stop();\n this.authoring = null;\n this.capture?.destroy();\n this.capture = null;\n this.replay?.destroy();\n this.replay = null;\n this.queue.flushSync();\n this.queue.destroy();\n this.emitter.clear();\n destroyHost();\n if (current === this) current = null;\n }\n\n // ---------------------------------------------------------------------------\n // Identity\n // ---------------------------------------------------------------------------\n\n /** Identifies the end user and loads server-held state (audiences, guide history, checklist progress). */\n async identify(userId: string, traits?: Record<string, unknown>, account?: GuidelyAccount): Promise<void> {\n if (this.destroyed) return;\n this.identitySettled = true;\n this.user = { id: String(userId), traits: { ...(this.user?.id === String(userId) ? this.user.traits : {}), ...(traits || {}) }, account: account ?? (this.user?.id === String(userId) ? this.user.account : undefined) };\n writeJson(this.store, KEYS.user(this.options.projectId), this.user);\n this.enqueue(\"identify\", { properties: { traits: sanitizeProperties(this.user.traits) } });\n await this.syncIdentify();\n this.emitter.emit(\"identify\", { userId: this.user.id, anonymousId: this.anonymousId });\n if (this.isReady) this.evaluate(\"identify\");\n }\n\n private async syncIdentify(): Promise<void> {\n const body: IdentifyRequest = { anonymousId: this.anonymousId, userId: this.user?.id ?? null, traits: this.user?.traits, account: this.user?.account ? { id: this.user.account.id, traits: this.user.account.traits } : null, sessionId: this.session.id, url: this.collectUrls() ? location.href : undefined };\n const res = await postWithRetry<IdentifyResponse>(this.api, \"/identify\", body, 2);\n if (res?.ok && res.data) this.mergeServerState(res.data);\n }\n\n private mergeServerState(data: IdentifyResponse): void {\n const guides = { ...this.state.guides };\n for (const [id, s] of Object.entries(data.guideState || {})) {\n const local = guides[id];\n guides[id] = {\n ...local,\n impressions: Math.max(local?.impressions ?? 0, s.impressions ?? 0),\n completedAt: local?.completedAt ?? s.completedAt ?? null,\n dismissedAt: local?.dismissedAt ?? s.dismissedAt ?? null,\n lastShownAt: local?.lastShownAt ?? s.lastShownAt ?? null,\n };\n }\n const checklists = { ...this.state.checklists };\n for (const [id, p] of Object.entries(data.checklistProgress || {})) {\n const local = checklists[id];\n checklists[id] = {\n completedTaskIds: Array.from(new Set([...(local?.completedTaskIds ?? []), ...(p.completedTaskIds ?? [])])),\n completedAt: local?.completedAt ?? p.completedAt ?? null,\n dismissedAt: local?.dismissedAt ?? p.dismissedAt ?? null,\n };\n }\n this.state = {\n guides,\n checklists,\n surveysSubmitted: Array.from(new Set([...this.state.surveysSubmitted, ...(data.surveysSubmitted || [])])),\n audienceIds: data.audienceIds || [],\n firstSeenAt: this.state.firstSeenAt ?? data.firstSeenAt,\n };\n if (data.firstSeenAt && Date.now() - Date.parse(data.firstSeenAt) > 60_000) this.firstVisit = false;\n this.persistState();\n this.widgets.forEach((w, id) => {\n const g = this.findGuide(id);\n if (w.checklist && g) w.checklist.setProgress(this.getChecklistProgress(g.id));\n });\n // Name, audiences and progress may have changed.\n this.messenger?.refresh();\n }\n\n /** Sets or replaces the account (company/organisation) for the current user. */\n async setAccount(account: GuidelyAccount): Promise<void> {\n if (!this.user) {\n this.user = { id: \"\", account };\n writeJson(this.store, KEYS.user(this.options.projectId), this.user);\n return;\n }\n await this.identify(this.user.id, undefined, account);\n }\n\n /** Merges additional traits into the current user. */\n async updateTraits(traits: Record<string, unknown>): Promise<void> {\n if (!this.user?.id) {\n this.user = { id: \"\", traits: { ...(this.user?.traits || {}), ...traits } };\n return;\n }\n await this.identify(this.user.id, traits, this.user.account);\n }\n\n /** Forgets the user: new anonymous id, cleared local guide/checklist state, triggers re-evaluated. */\n reset(): void {\n this.identitySettled = true;\n this.stopGuide();\n this.user = null;\n this.store.remove(KEYS.user(this.options.projectId));\n this.anonymousId = `anon_${randomId(20)}`;\n this.store.set(KEYS.anon, this.anonymousId);\n this.state = emptyState();\n this.persistState();\n this.session = newSession();\n this.persistSession();\n this.sessionStore.remove(KEYS.active);\n this.replay?.stop(); // the recording belongs to the previous user; restarted below when eligible\n this.syncCapture();\n this.lastAudiences = new Set();\n this.firedDelays.clear();\n this.widgets.forEach((w) => w.destroy());\n this.widgets.clear();\n // Conversations belong to the previous user: forget their tokens and rebuild the messenger.\n forgetConversations(this.store, this.options.projectId);\n this.destroyMessenger();\n this.emitter.emit(\"identify\", { userId: null, anonymousId: this.anonymousId });\n if (this.isReady) {\n this.renderPersistentWidgets();\n this.evaluate(\"identify\");\n }\n }\n\n // ---------------------------------------------------------------------------\n // Events\n // ---------------------------------------------------------------------------\n\n /** Updates consent at runtime (`granted` flushes buffered events; `denied` drops them). */\n setConsent(consent: ConsentState): void {\n this.consent = consent;\n if (consent === \"denied\") this.queue.clear();\n else if (consent === \"granted\") void this.queue.flush();\n if (consent !== \"granted\") this.replay?.stop({ discard: true });\n this.syncCapture();\n }\n\n private analyticsEnabled(): boolean {\n return this.options.analytics && this.consent === \"granted\" && (this.config?.settings?.analyticsEnabled ?? true);\n }\n\n private collectUrls(): boolean {\n return this.config?.settings?.collectUrls ?? true;\n }\n\n private enqueue(name: EventName, extra: Partial<SdkEvent> = {}): SdkEvent | null {\n if (this.consent === \"denied\" || !this.options.analytics) return null;\n if (name !== \"page_leave\" && name !== \"heatmap\") this.touchSession();\n const event: SdkEvent = {\n eventId: randomId(24),\n name,\n occurredAt: nowIso(),\n anonymousId: this.anonymousId,\n userId: this.user?.id || null,\n accountId: this.user?.account?.id || null,\n sessionId: this.session.id,\n url: this.collectUrls() ? location.href : undefined,\n ...extra,\n };\n if (extra.properties) event.properties = sanitizeProperties(extra.properties);\n this.queue.enqueue(event);\n this.replay?.addCustomEvent(\"guidely\", { name, customName: event.customName, guideId: event.guideId });\n this.emitter.emit(\"track\", event);\n return event;\n }\n\n /** Tracks a custom event. Events drive `event` triggers, `advanceOn: \"event\"` steps and checklist tasks. */\n track(name: string, properties?: Record<string, unknown>): void {\n if (this.destroyed || !name) return;\n if (!this.session.events.includes(name)) {\n this.session.events.push(name);\n this.persistSession();\n }\n this.enqueue(\"custom\", { customName: name.slice(0, 120), properties: properties ?? {} });\n this.customListeners.get(name)?.forEach((cb) => {\n try {\n cb();\n } catch (err) {\n this.reportError(err);\n }\n });\n this.completeChecklistTasksBy(\"event\", name);\n if (this.isReady) this.evaluate(\"event\", { eventName: name });\n }\n\n /** Records a page view and re-evaluates triggers. Called automatically on SPA navigation. */\n page(url: string = location.href): void {\n if (this.destroyed) return;\n this.leavePage(url);\n this.trackPageView(url);\n this.handleNavigation(url, true);\n }\n\n private readonly customListeners = new Map<string, Set<() => void>>();\n private readonly eventBus = {\n on: (name: string, cb: () => void) => {\n let set = this.customListeners.get(name);\n if (!set) {\n set = new Set();\n this.customListeners.set(name, set);\n }\n set.add(cb);\n return () => {\n set?.delete(cb);\n };\n },\n };\n\n private handleNavigation(url: string, explicit = false): void {\n if (this.destroyed) return;\n const changed = url !== this.lastUrl;\n this.lastUrl = url;\n if (!explicit && changed) {\n this.leavePage(url);\n this.trackPageView(url);\n }\n this.completeChecklistTasksBy(\"url_visited\", url);\n this.active?.controller?.resume();\n if (this.active?.controller) {\n const st = this.active.controller.getState();\n if (st.status === \"running\" && !this.active.manual) {\n const g = this.active.guide;\n if (g.config.urlPatterns.length && !g.config.urlPatterns.some((p) => urlMatches(p, url))) this.active.controller.destroy();\n }\n }\n // Banners and hotspots are page-scoped too: close the ones whose URL patterns no longer match.\n this.widgets.forEach((w, id) => {\n if (!w.controller || w.manual) return;\n const g = this.findGuide(id);\n if (g?.config.urlPatterns.length && !g.config.urlPatterns.some((p) => urlMatches(p, url))) w.controller.destroy();\n });\n this.firedDelays.clear();\n if (this.isReady) this.evaluate(\"navigation\");\n if (changed) this.messenger?.refresh();\n if (changed) void this.queue.flush();\n }\n\n private handleDocumentClick(e: Event): void {\n const target = e.target as Element | null;\n if (!target || typeof target.closest !== \"function\") return;\n this.autocaptureClick(e as MouseEvent, target);\n this.completeChecklistTasksBy(\"click\", target);\n if (this.isReady) this.evaluate(\"click\", { target });\n }\n\n // ---------------------------------------------------------------------------\n // Product analytics: sessions, page views, clicks, errors, session replay\n // ---------------------------------------------------------------------------\n\n /** Records activity; starts a new session after `sessionTimeoutMinutes` of inactivity or 24h. */\n private touchSession(): void {\n const now = Date.now();\n const s = this.session;\n const timeout = Math.max(1, this.config?.settings?.sessionTimeoutMinutes ?? 30) * 60_000;\n const last = s.lastActivityAt ?? now;\n if (now - last > timeout || now - (Date.parse(s.startedAt) || now) > DAY_MS) return this.rotateSession(now);\n if (now - (s.lastActivityAt ?? 0) < 1000) return;\n s.lastActivityAt = now;\n this.persistSession();\n }\n\n private rotateSession(now: number): void {\n this.session = newSession(now);\n this.persistSession();\n this.log(\"session rotated\", this.session.id);\n if (this.replay?.activeSessionId) this.replay.stop();\n this.syncReplay();\n }\n\n /** Autocapture, error tracking and replay need analytics on, consent granted and no authoring or how-to capture session. */\n private captureAllowed(): boolean {\n return !this.destroyed && this.analyticsEnabled() && !this.editing();\n }\n\n /** Authoring or how-to capture is running: no guides, widgets, replay or autocapture. */\n private editing(): boolean {\n return !!this.authoring?.isActive() || this.captureStarting || !!this.capture?.isActive();\n }\n\n /** A capability is on when the project enables it (absent on old servers → off) and no option turns it off. */\n private autocaptureOn(key: keyof AutocaptureSettings): boolean {\n const o = this.options.autocapture;\n return !!this.config?.settings?.autocapture?.[key] && o !== false && !(typeof o === \"object\" && o[key] === false) && this.captureAllowed();\n }\n\n /** Page views on SPA navigation predate autocapture: only an explicit opt-out stops them. */\n private pageviewsOn(): boolean {\n const o = this.options.autocapture;\n return this.config?.settings?.autocapture?.pageviews !== false && o !== false && !(typeof o === \"object\" && o.pageviews === false) && !this.editing();\n }\n\n private trackPageView(url: string): void {\n if (url === this.pageViewUrl || !this.pageviewsOn()) return;\n this.pageViewUrl = url;\n this.touchSession();\n const collect = this.collectUrls();\n const device = detectDevice(navigator.userAgent, window.innerWidth);\n const props: Record<string, unknown> = { deviceType: device.type, browser: device.browser, os: device.os, screenWidth: window.screen?.width, viewportWidth: window.innerWidth };\n if (collect) {\n props.path = pathOf(url);\n props.title = (document.title || \"\").slice(0, 200);\n const ref = !this.session.pageViews ? externalReferrer() : undefined;\n if (ref) props.referrer = ref;\n }\n this.session.pageViews = (this.session.pageViews ?? 0) + 1;\n this.persistSession();\n this.enqueue(\"page_view\", { url: collect ? url : undefined, properties: props });\n }\n\n /** Emits `page_leave` for the page being left and starts measuring `nextUrl` (null: page unload). */\n private leavePage(nextUrl: string | null): void {\n const t = this.pageTracker;\n if (!t.url || t.url === nextUrl) return;\n this.flushHeatmap();\n if (!this.pageLeft && this.autocaptureOn(\"pageLeave\")) {\n const info = t.leave();\n const collect = this.collectUrls();\n this.enqueue(\"page_leave\", { url: collect ? info.url : undefined, properties: { ...(collect ? { path: pathOf(info.url) } : {}), durationMs: info.durationMs, scrollDepth: info.scrollDepth } });\n }\n if (nextUrl !== null) {\n t.start(nextUrl);\n this.pageLeft = false;\n }\n }\n\n private autocaptureClick(e: MouseEvent, target: Element): void {\n const clicks = this.autocaptureOn(\"clicks\");\n const rage = this.autocaptureOn(\"rageClicks\");\n const heat = this.autocaptureOn(\"heatmaps\");\n if ((!clicks && !rage && !heat) || isIgnoredElement(target)) return;\n this.touchSession();\n const el = interactiveElement(target);\n const opts = { mask: this.maskSelector(), maskAll: this.maskAllText(), collectUrls: this.collectUrls() };\n if (clicks && el) this.enqueue(\"click\", { properties: { ...describeClick(el, e, opts) } });\n const count = this.rage.add(e.pageX ?? 0, e.pageY ?? 0, Date.now());\n if (rage && count) this.enqueue(\"rage_click\", { properties: { ...describeClick(el ?? target, e, opts), count } });\n if (!heat) return;\n const url = location.href;\n if (this.heatmap.url !== url) this.flushHeatmap();\n if (this.heatmap.add(url, heatmapPoint(el ?? target, e, this.rage.burst > 0), this.rage.burst)) this.flushHeatmap();\n }\n\n /** Bins one pointer sample into the heatmap buffer. Not session activity. */\n private sampleMove(e: MouseEvent): void {\n const target = e.target as Element | null;\n if (document.visibilityState === \"hidden\" || !target?.closest || !this.autocaptureOn(\"mouseMovement\") || isIgnoredElement(target)) return;\n const url = location.href;\n if (this.heatmap.url !== url) this.flushHeatmap();\n if (this.heatmap.move(url, movementBin(interactiveElement(target) ?? target, e))) this.flushHeatmap();\n }\n\n /** Sends the buffered heatmap clicks as one `heatmap` event attributed to the page they happened on. */\n private flushHeatmap(): void {\n const batch = this.heatmap.take();\n if (!batch || !this.captureAllowed()) return;\n const collect = this.collectUrls();\n const de = document.documentElement;\n const properties = { path: collect ? pathOf(batch.url) : undefined, viewportWidth: window.innerWidth, viewportHeight: window.innerHeight, pageHeight: Math.max(de.scrollHeight, document.body?.scrollHeight || 0), points: batch.points };\n if (!collect) delete properties.path;\n this.enqueue(\"heatmap\", { url: collect ? batch.url : undefined, properties });\n }\n\n private captureGlobalException(props: ExceptionProperties | null): void {\n if (!props || isGuidelyException(props) || this.options.captureErrors === false) return;\n if (!this.config) {\n if (this.earlyExceptions.length < 10) this.earlyExceptions.push([props, undefined]);\n return;\n }\n this.sendException(props);\n }\n\n /**\n * Reports a caught error as an `exception` event (`source: \"manual\"`, `handled: true`), grouped\n * into an issue on the Errors page. Extra properties are attached to the occurrence. Needs the\n * project's error tracking on (plus analytics + consent); `captureErrors: false` does not stop it.\n */\n captureException(error: unknown, properties?: Record<string, unknown>): void {\n if (this.destroyed) return;\n const props = exceptionFromError(error, \"manual\", true);\n if (!this.config) {\n if (this.earlyExceptions.length < 10) this.earlyExceptions.push([props, properties]);\n return;\n }\n this.sendException(props, properties);\n }\n\n private sendException(props: ExceptionProperties, extra?: Record<string, unknown>): void {\n // Error tracking off (or a server that predates it and would reject the event): nothing is sent.\n if (!this.config?.settings?.errorTracking?.enabled || !this.captureAllowed() || !this.exceptionThrottle.allow(props)) return;\n const count = this.session.exceptions ?? 0;\n if (count >= MAX_SESSION_EXCEPTIONS) return;\n const properties: Record<string, unknown> = { ...props };\n if (this.options.release) properties.release = String(this.options.release).slice(0, 100);\n for (const [k, v] of Object.entries(extra ?? {})) if (!(k in properties)) properties[k] = v;\n this.enqueue(\"exception\", { properties });\n this.session.exceptions = count + 1;\n this.persistSession();\n }\n\n private maskSelector(): string {\n return validSelectors([...DEFAULT_MASK_SELECTORS, ...(this.config?.settings?.maskSelectors || []), ...(this.options.maskSelectors || [])]).join(\",\");\n }\n\n private maskAllText(): boolean {\n const o = this.options.sessionReplay;\n return !!this.config?.settings?.replay?.maskAllText || (typeof o === \"object\" && !!o.maskAllText);\n }\n\n /** Replay settings for this installation, or null when the project (or an option) disables replay. */\n private replayConfig(): { sampleRate: number; config: ReplayRecordingConfig } | null {\n const r = this.config?.settings?.replay;\n const o = this.options.sessionReplay;\n if (!r?.enabled || o === false) return null;\n const opt = typeof o === \"object\" ? o : {};\n const extra = opt.blockSelectors || [];\n return {\n sampleRate: r.sampleRate ?? 100,\n config: {\n recordConsole: r.recordConsole !== false,\n maskTextSelector: this.maskAllText() ? \"*\" : this.maskSelector(),\n blockSelector: validSelectors([\"[data-guidely-block]\", ...(r.blockSelectors || []), ...extra]).join(\",\"),\n network: r.recordNetwork && opt.recordNetwork !== false ? { payloads: !!r.recordNetworkPayloads && opt.recordNetworkPayloads !== false, apiUrl: this.options.apiUrl, mask: opt.maskNetworkRequest } : null,\n },\n };\n }\n\n /** Reconciles capture with the current config / consent / authoring state. Idempotent. */\n private syncCapture(): void {\n if (!this.isReady || this.destroyed) return;\n if (this.config && !this.initialPageViewSent && this.config.settings?.autocapture) {\n this.initialPageViewSent = true;\n this.trackPageView(location.href);\n }\n if (this.config) {\n for (const [props, extra] of this.earlyExceptions.splice(0)) {\n if (props.handled) this.sendException(props, extra);\n else this.captureGlobalException(props);\n }\n }\n this.syncReplay();\n }\n\n private syncReplay(): void {\n const cfg = this.isReady && this.captureAllowed() ? this.replayConfig() : null;\n if (cfg && this.session.replay === undefined) {\n this.session.replay = rolloutBucket(this.session.id, \"replay\") < cfg.sampleRate;\n this.persistSession();\n }\n if (!cfg || !this.session.replay) {\n if (this.replay?.activeSessionId) this.replay.stop({ discard: !this.analyticsEnabled() });\n return;\n }\n if (this.replay) return this.replay.start(this.session.id, cfg.config);\n if (this.replayLoading) return;\n this.replayLoading = true;\n loadRecorder().then(\n (api) => {\n this.replayLoading = false;\n if (this.destroyed || this.replay) return;\n this.replay = api.createReplay({\n url: (params) => this.api.url(\"/replay\", params),\n fetch: () => this.options.fetch ?? (typeof fetch === \"function\" ? fetch.bind(globalThis) : null),\n meta: () => {\n const device = detectDevice(navigator.userAgent, window.innerWidth);\n return {\n anonymousId: this.anonymousId,\n userId: this.user?.id || null,\n url: this.collectUrls() ? location.href : undefined,\n device: { type: device.type, browser: device.browser, os: device.os },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n sdk: { name: SDK_NAME, version: SDK_VERSION },\n };\n },\n onDisabled: (sessionId) => {\n if (sessionId !== this.session.id) return;\n this.session.replay = false;\n this.persistSession();\n this.replay?.stop({ discard: true });\n },\n onError: (err) => this.reportError(err),\n });\n this.syncReplay(); // re-decide: consent, session or settings may have changed while loading\n },\n (err) => {\n this.replayLoading = false;\n this.reportError(err);\n },\n );\n }\n\n /**\n * Records this session even when it was not sampled, provided the project has session replay\n * enabled (and analytics + consent allow it). The decision sticks for the rest of the session.\n */\n startSessionRecording(): void {\n if (this.destroyed) return;\n this.session.replay = true;\n this.persistSession();\n this.syncReplay();\n }\n\n /** Stops recording for the rest of this session (what was recorded so far is uploaded). */\n stopSessionRecording(): void {\n this.session.replay = false;\n this.persistSession();\n this.replay?.stop();\n }\n\n /** True while the session is being recorded. */\n isRecording(): boolean {\n return !!this.replay?.isRecording();\n }\n\n /** The current analytics session id (rotates after inactivity; also the replay id). */\n getSessionId(): string {\n return this.session.id;\n }\n\n // ---------------------------------------------------------------------------\n // Targeting + triggers\n // ---------------------------------------------------------------------------\n\n /** Builds the targeting context for the current moment. */\n getContext(): TargetingContext {\n const guides = this.state.guides;\n const completedChecklists = Object.entries(this.state.checklists).filter(([, p]) => !!p.completedAt).map(([id]) => id);\n const keysOf = (ids: string[]) => ids.flatMap((id) => [id, this.findGuide(id)?.key ?? id]);\n return buildContext({\n anonymousId: this.anonymousId,\n userId: this.user?.id || null,\n userAttributes: this.user?.traits ?? {},\n accountAttributes: this.user?.account?.traits ?? {},\n url: location.href,\n firstVisit: this.firstVisit,\n eventsSeen: this.session.events,\n completedGuides: keysOf(Object.keys(guides).filter((id) => guides[id]?.completedAt)),\n dismissedGuides: keysOf(Object.keys(guides).filter((id) => guides[id]?.dismissedAt)),\n seenGuides: keysOf(Object.keys(guides).filter((id) => (guides[id]?.impressions ?? 0) > 0)),\n completedChecklists: keysOf(completedChecklists),\n audienceIds: this.state.audienceIds,\n environment: this.options.environment,\n platform: \"web\",\n });\n }\n\n private isTargeted(guide: PublishedGuide, ctx: TargetingContext, url: string): boolean {\n const c = guide.config;\n if (c.urlPatterns.length && !c.urlPatterns.some((p) => urlMatches(p, url))) return false;\n if (c.trigger.urlPattern && !urlMatches(c.trigger.urlPattern, url)) return false;\n if (!isWithinSchedule(guide)) return false;\n if (guide.kind === \"survey\" && (this.state.surveysSubmitted.includes(guide.id) || this.state.surveysSubmitted.includes(guide.key))) return false;\n ctx.rolloutSalt = guide.id;\n return evaluateRules(c.targeting, ctx);\n }\n\n private isEligible(guide: PublishedGuide, ctx: TargetingContext, url: string): boolean {\n if (!this.isTargeted(guide, ctx, url)) return false;\n const shownThisSession = this.session.shownGuides.includes(guide.id);\n if (guide.kind === \"checklist\") {\n const p = this.state.checklists[guide.id];\n return !p?.dismissedAt;\n }\n return isFrequencyEligible(guide.config.frequency, this.state.guides[guide.id], shownThisSession);\n }\n\n private triggerFires(guide: PublishedGuide, reason: EvalReason, detail: EvalDetail): boolean {\n const t = guide.config.trigger;\n switch (t.type) {\n case \"page_load\":\n // A delayed page_load re-evaluates from its own timer.\n if (t.delayMs > 0) return reason === \"timer\" && detail.guideId === guide.id;\n return reason === \"ready\" || reason === \"navigation\" || reason === \"identify\";\n case \"url_match\":\n return (reason === \"ready\" || reason === \"navigation\" || reason === \"identify\") && urlMatches(t.value, location.href);\n case \"event\":\n return reason === \"event\" && !!t.value && detail.eventName === t.value;\n case \"element_click\":\n if (reason !== \"click\" || !t.value || !detail.target) return false;\n try {\n return !!detail.target.closest(t.value);\n } catch {\n return false;\n }\n case \"element_visible\":\n return reason === \"visible\" && detail.guideId === guide.id;\n case \"delay\":\n return reason === \"timer\" && detail.guideId === guide.id;\n case \"after_guide\":\n return reason === \"after_guide\" && !!detail.endedGuide && (detail.endedGuide.id === t.value || detail.endedGuide.key === t.value);\n case \"segment_enter\":\n return reason === \"identify\" && !!t.value && !!detail.newAudiences?.has(t.value);\n case \"manual\":\n default:\n return false;\n }\n }\n\n private evaluate(reason: EvalReason, detail: EvalDetail = {}): void {\n if (!this.config || this.destroyed || this.editing()) return;\n const url = location.href;\n const ctx = this.getContext();\n if (reason === \"identify\") {\n const current = new Set(this.state.audienceIds);\n detail.newAudiences = new Set(Array.from(current).filter((a) => !this.lastAudiences.has(a)));\n this.lastAudiences = current;\n }\n const candidates: PublishedGuide[] = [];\n for (const guide of this.config.guides) {\n const t = guide.config.trigger;\n if (detail.endedGuide && detail.endedGuide.id === guide.id) continue; // never re-show the guide that just ended\n // Arm element-visibility observers and delay timers on page-level evaluations.\n if (reason === \"ready\" || reason === \"navigation\") {\n if (t.type === \"element_visible\" && t.value) this.armVisibility(guide, ctx, url);\n if ((t.type === \"delay\" || (t.type === \"page_load\" && t.delayMs > 0)) && !this.firedDelays.has(guide.id)) {\n if (!this.isEligible(guide, ctx, url)) continue;\n this.firedDelays.add(guide.id);\n this.setTimer(() => this.evaluate(\"timer\", { guideId: guide.id }), t.delayMs);\n continue;\n }\n }\n if (t.type === \"page_load\" && t.delayMs > 0 && reason !== \"timer\") continue;\n if (t.type === \"page_load\" && t.delayMs > 0 && reason === \"timer\" && detail.guideId !== guide.id) continue;\n if (!this.triggerFires(guide, reason, detail)) continue;\n if (!this.isEligible(guide, ctx, url)) continue;\n candidates.push(guide);\n }\n if (reason === \"after_guide\" || reason === \"navigation\") this.drainQueue(url, ctx);\n if (!candidates.length) return;\n candidates.sort((a, b) => a.config.frequency.priority - b.config.frequency.priority);\n for (const guide of candidates) {\n if (this.widgets.has(guide.id) || this.active?.guide.id === guide.id) continue;\n const delay = guide.config.trigger.type !== \"delay\" && guide.config.trigger.type !== \"page_load\" ? guide.config.trigger.delayMs : 0;\n if (delay > 0) {\n this.setTimer(() => this.tryShow(guide, url, false), delay);\n continue;\n }\n this.tryShow(guide, url, false);\n }\n }\n\n private armVisibility(guide: PublishedGuide, ctx: TargetingContext, url: string): void {\n const selector = guide.config.trigger.value;\n if (!selector || this.visibilityObservers.has(guide.id)) return;\n if (!this.isEligible(guide, ctx, url)) return;\n const ac = new AbortController();\n let io: IntersectionObserver | null = null;\n const stop = () => {\n ac.abort();\n io?.disconnect();\n this.visibilityObservers.delete(guide.id);\n };\n this.visibilityObservers.set(guide.id, stop);\n waitForTarget([{ kind: \"css\", value: selector }], { timeoutMs: 0, signal: ac.signal })\n .then((el) => {\n if (ac.signal.aborted) return;\n const fire = () => {\n stop();\n this.evaluate(\"visible\", { guideId: guide.id });\n };\n if (typeof IntersectionObserver === \"undefined\") return fire();\n io = new IntersectionObserver((entries) => {\n if (entries.some((e) => e.isIntersecting)) fire();\n });\n io.observe(el);\n })\n .catch(() => stop());\n }\n\n private setTimer(fn: () => void, ms: number): void {\n const t = setTimeout(() => {\n this.timers.delete(t);\n if (!this.destroyed) fn();\n }, ms);\n this.timers.add(t);\n }\n\n /** Decides whether a guide can show now, otherwise queues it. */\n private tryShow(guide: PublishedGuide, url: string, manual: boolean): boolean {\n if (this.destroyed) return false;\n if (!isExclusiveGuide(guide)) {\n if (this.widgets.has(guide.id)) return false;\n this.show(guide, manual);\n return true;\n }\n if (this.active) {\n if (this.active.guide.id === guide.id) return false;\n if (manual) this.stopGuide();\n else {\n if (!this.queued.some((q) => q.guide.id === guide.id)) this.queued.push({ guide, url, pageScoped: PAGE_SCOPED.has(guide.config.trigger.type) });\n this.log(\"queued\", guide.key, \"behind\", this.active.guide.key);\n return false;\n }\n }\n const blocked = Array.from(this.widgets.keys()).map((id) => this.findGuide(id)).some((g) => g && areMutuallyExclusive(g, guide));\n if (blocked && !manual) {\n if (!this.queued.some((q) => q.guide.id === guide.id)) this.queued.push({ guide, url, pageScoped: true });\n return false;\n }\n this.show(guide, manual);\n return true;\n }\n\n private drainQueue(url: string, ctx: TargetingContext): void {\n if (this.active) return;\n this.queued = this.queued.filter((q) => !(q.pageScoped && q.url !== url));\n while (this.queued.length) {\n const next = this.queued.shift() as QueuedGuide;\n if (!this.isEligible(next.guide, ctx, url)) continue;\n if (this.tryShow(next.guide, url, false)) return;\n }\n }\n\n // ---------------------------------------------------------------------------\n // Showing guides\n // ---------------------------------------------------------------------------\n\n private findGuide(idOrKey: string): PublishedGuide | undefined {\n return this.config?.guides.find((g) => g.id === idOrKey || g.key === idOrKey);\n }\n\n private guideState(id: string): GuideLocalState {\n return this.state.guides[id] ?? (this.state.guides[id] = { impressions: 0 });\n }\n\n private recordImpression(guide: PublishedGuide): void {\n const s = this.guideState(guide.id);\n s.impressions += 1;\n s.lastShownAt = nowIso();\n if (!this.session.shownGuides.includes(guide.id)) this.session.shownGuides.push(guide.id);\n this.persistState();\n this.persistSession();\n this.syncGuideState(guide.id, { impression: true });\n }\n\n private recordEnd(guide: PublishedGuide, reason: \"completed\" | \"dismissed\" | \"skipped\"): void {\n const s = this.guideState(guide.id);\n if (reason === \"completed\") s.completedAt = nowIso();\n else s.dismissedAt = nowIso();\n this.persistState();\n this.syncGuideState(guide.id, reason === \"completed\" ? { completed: true } : { dismissed: true });\n if (reason === \"completed\") this.completeChecklistTasksBy(\"guide_completed\", guide);\n }\n\n private syncGuideState(guideId: string, update: { impression?: boolean; completed?: boolean; dismissed?: boolean }): void {\n void postWithRetry(this.api, \"/guide-state\", { anonymousId: this.anonymousId, userId: this.user?.id || null, updates: [{ guideId, ...update }] });\n }\n\n private show(guide: PublishedGuide, manual: boolean, stepId?: string): void {\n try {\n if (guide.kind === \"checklist\" && guide.config.checklist) return this.showChecklist(guide);\n if (guide.kind === \"survey\" && guide.config.survey) return this.showSurvey(guide, manual);\n this.showFlow(guide, manual, stepId);\n } catch (err) {\n this.reportError(err);\n }\n }\n\n private showFlow(guide: PublishedGuide, manual: boolean, stepId?: string): void {\n if (this.editing()) return; // authoring mode renders previews only; capture renders nothing\n const exclusive = isExclusiveGuide(guide);\n const entry: ActiveGuide = { guide, manual, startUrl: location.href };\n const controller = runGuide(guide, {\n theme: this.theme(),\n ctx: () => this.getContext(),\n startAtStep: stepId,\n eventBus: this.eventBus,\n onError: (err) => this.reportError(err),\n onEvent: (e) => {\n const step = e.stepId ? guide.config.steps.find((s) => s.id === e.stepId) : undefined;\n this.enqueue(e.name, { guideId: guide.id, guideVersion: guide.version, stepId: e.stepId, stepIndex: e.stepIndex, properties: e.properties });\n if (e.name === \"guide_started\") {\n this.recordImpression(guide);\n this.emitter.emit(\"guide:start\", guide);\n }\n if (e.name === \"step_viewed\" && step) {\n if (exclusive) writeJson(this.sessionStore, KEYS.active, { guideId: guide.id, stepId: step.id, manual });\n if (guide.kind === \"flow\" && guide.config.steps.length > 1) {\n this.guideState(guide.id).lastStepId = step.id;\n this.persistState();\n }\n this.emitter.emit(\"guide:step\", { guide, stepId: step.id, stepIndex: e.stepIndex ?? 0 });\n }\n if (e.name === \"guide_completed\") {\n this.recordEnd(guide, \"completed\");\n this.emitter.emit(\"guide:complete\", guide);\n }\n if (e.name === \"guide_dismissed\") {\n this.recordEnd(guide, \"dismissed\");\n this.emitter.emit(\"guide:dismiss\", guide);\n }\n if (e.name === \"guide_skipped\") {\n this.recordEnd(guide, \"skipped\");\n this.emitter.emit(\"guide:skip\", guide);\n }\n },\n onNavigate: (url, newTab) => this.navigate(url, newTab),\n onAction: (action, value) => {\n if (action === \"start_guide\" && value) this.setTimer(() => this.startGuide(value), 0);\n else if (action === \"event\" && value) this.track(value);\n else if (action === \"open_resource_center\") this.openResourceCenter();\n },\n onEnd: (reason) => {\n if (exclusive) {\n if (this.active?.controller === controller) this.active = null;\n this.sessionStore.remove(KEYS.active);\n } else this.widgets.delete(guide.id);\n if (reason !== \"destroyed\" && !this.destroyed) this.setTimer(() => this.evaluate(\"after_guide\", { endedGuide: guide }), 0);\n },\n });\n entry.controller = controller;\n if (exclusive) this.active = entry;\n else this.widgets.set(guide.id, { destroy: () => controller.destroy(), controller, manual });\n controller.start();\n if (controller.getState().status === \"ended\") {\n if (exclusive && this.active === entry) this.active = null;\n this.widgets.delete(guide.id);\n }\n }\n\n private showChecklist(guide: PublishedGuide): void {\n if (this.editing()) return; // authoring mode renders previews only; capture renders nothing\n const config = guide.config.checklist;\n if (!config || this.widgets.has(guide.id)) return;\n const scope = createScope(this.theme(), guide.config.appearance);\n const progress = this.getChecklistProgress(guide.id);\n const first = !this.state.guides[guide.id]?.impressions;\n const widget = renderChecklist({\n scope: scope.el,\n config,\n progress,\n open: config.autoOpen && first && !progress.completedAt,\n onTaskClick: (task) => this.handleChecklistTaskClick(guide, task),\n onDismiss: () => this.dismissChecklist(guide),\n onOpen: () => this.enqueue(\"guide_viewed\", { guideId: guide.id, guideVersion: guide.version }),\n });\n this.widgets.set(guide.id, { destroy: () => { widget.destroy(); scope.destroy(); }, checklist: widget, scope });\n if (first) this.recordImpression(guide);\n }\n\n private showSurvey(guide: PublishedGuide, manual: boolean): void {\n if (this.editing()) return; // authoring mode renders previews only; capture renders nothing\n const config = guide.config.survey;\n if (!config) return;\n const scope = createScope(this.theme(), guide.config.appearance);\n const entry: ActiveGuide = { guide, manual, startUrl: location.href, scope };\n const finish = (reason: \"submitted\" | \"dismissed\") => {\n widget.destroy();\n scope.destroy();\n if (this.active === entry) this.active = null;\n if (reason === \"dismissed\") {\n this.enqueue(\"survey_dismissed\", { guideId: guide.id, guideVersion: guide.version });\n this.recordEnd(guide, \"dismissed\");\n this.emitter.emit(\"guide:dismiss\", guide);\n }\n this.setTimer(() => this.evaluate(\"after_guide\", { endedGuide: guide }), 0);\n };\n const widget = renderSurvey({\n scope: scope.el,\n config,\n title: guide.name,\n onDismiss: () => finish(this.state.surveysSubmitted.includes(guide.id) ? \"submitted\" : \"dismissed\"),\n onSubmit: (answers) => {\n const responseId = randomId(24);\n this.state.surveysSubmitted.push(guide.id);\n this.persistState();\n this.recordEnd(guide, \"completed\");\n this.enqueue(\"survey_submitted\", { guideId: guide.id, guideVersion: guide.version, properties: { responseId } });\n void postWithRetry(this.api, `/surveys/${encodeURIComponent(guide.id)}/responses`, { anonymousId: this.anonymousId, userId: this.user?.id || null, accountId: this.user?.account?.id || null, guideVersion: guide.version, answers, responseId });\n this.emitter.emit(\"survey:submit\", { guide, answers, responseId });\n this.emitter.emit(\"guide:complete\", guide);\n widget.showThankYou();\n },\n });\n entry.survey = widget;\n this.active = entry;\n this.recordImpression(guide);\n this.enqueue(\"survey_displayed\", { guideId: guide.id, guideVersion: guide.version });\n this.emitter.emit(\"guide:start\", guide);\n }\n\n private theme() {\n return { ...(this.config?.theme || {}), ...(this.options.theme || {}) };\n }\n\n private navigate(url: string, newTab?: boolean): void {\n try {\n if (newTab) window.open(url, \"_blank\", \"noopener\");\n else location.assign(url);\n } catch (err) {\n this.reportError(err);\n }\n }\n\n private renderPersistentWidgets(): void {\n if (!this.config || this.captureStarting || this.capture?.isActive()) return;\n const rc = this.config.resourceCenter;\n if (this.config.messenger?.enabled) {\n // One launcher: the messenger's Help tab replaces the resource center.\n if (this.resourceCenter) {\n this.resourceCenter.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n }\n if (!this.messenger) void this.loadMessenger();\n return;\n }\n this.destroyMessenger();\n if (rc && rc.enabled && !this.resourceCenter) {\n const scope = createScope(this.theme());\n this.resourceCenterScope = scope;\n this.resourceCenter = renderResourceCenter({\n scope: scope.el,\n config: rc,\n guides: this.config.guides.map((g) => ({ id: g.id, key: g.key, name: g.name, kind: g.kind })),\n search: (q) => this.searchResourceCenter(q),\n audienceIds: () => this.state.audienceIds,\n loadArticle: (id) => this.loadArticle(id),\n onStartGuide: (id) => this.startGuide(id),\n onOpenChecklist: (id) => this.openChecklist(id),\n onArticleView: (a) => this.enqueue(\"article_viewed\", { properties: { articleId: a.id, slug: a.slug } }),\n onOpen: () => {\n this.enqueue(\"resource_center_opened\");\n this.emitter.emit(\"resource-center:open\");\n },\n });\n } else if ((!rc || !rc.enabled) && this.resourceCenter) {\n this.resourceCenter.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n }\n }\n\n private resumeActiveGuide(): void {\n const saved = readJson<{ guideId: string; stepId: string; manual?: boolean } | null>(this.sessionStore, KEYS.active, null);\n if (!saved) return;\n this.sessionStore.remove(KEYS.active);\n const guide = this.findGuide(saved.guideId);\n if (!guide || !guide.config.steps.some((s) => s.id === saved.stepId)) return;\n this.showFlow(guide, saved.manual ?? false, saved.stepId);\n }\n\n /** Loads the messenger widget on demand (it is a separate chunk) and renders it. */\n private loadMessenger(): Promise<MessengerWidget | null> {\n if (this.messenger) return Promise.resolve(this.messenger);\n if (this.messengerLoading) return this.messengerLoading;\n this.messengerLoading = import(\"@guidelytech/guide-runtime/messenger\")\n .then(({ renderMessenger }) => {\n const cfg = this.config?.messenger;\n if (this.destroyed || !this.config || !cfg?.enabled || this.messenger) return this.messenger;\n const scope = createScope(this.theme());\n this.messengerScope = scope;\n this.messenger = renderMessenger({\n scope: scope.el,\n config: cfg,\n api: createMessengerTransport({\n api: this.api,\n store: this.store,\n projectId: this.options.projectId,\n anonymousId: () => this.anonymousId,\n userId: () => this.user?.id || null,\n pageUrl: () => (this.collectUrls() ? location.href : undefined),\n }),\n visitor: () => this.messengerVisitor(),\n brand: { logoUrl: this.theme().logoUrl ?? null, name: this.theme().brandName ?? null },\n onResumeGuide: (guideId, stepId) => this.startGuide(guideId, { stepId }),\n onNewsSeen: (ids) => {\n const seen = readJson<string[]>(this.store, KEYS.newsSeen(this.options.projectId), []);\n writeJson(this.store, KEYS.newsSeen(this.options.projectId), Array.from(new Set([...ids, ...(Array.isArray(seen) ? seen : [])])).slice(0, 200));\n },\n resourceCenter: this.config.resourceCenter,\n audienceIds: () => this.state.audienceIds,\n guides: this.config.guides.map((g) => ({ id: g.id, key: g.key, name: g.name, kind: g.kind })),\n onStartGuide: (idOrKey) => this.startGuide(idOrKey),\n onOpenChecklist: (id) => this.openChecklist(id),\n onArticleView: (a) => this.enqueue(\"article_viewed\", { properties: { articleId: a.id, slug: a.slug } }),\n onOpen: () => {\n this.enqueue(\"messenger_opened\");\n this.emitter.emit(\"messenger:open\");\n },\n onMessage: (message, conversation) => this.emitter.emit(\"conversation:message\", { message, conversation }),\n });\n return this.messenger;\n })\n .catch((err) => {\n this.reportError(err);\n return null;\n })\n .finally(() => {\n this.messengerLoading = null;\n });\n return this.messengerLoading;\n }\n\n /** What the messenger personalises from, computed fresh on every render. */\n private messengerVisitor() {\n const ctx = this.getContext();\n const url = location.href;\n const seen = readJson<string[]>(this.store, KEYS.newsSeen(this.options.projectId), []);\n return buildMessengerVisitor({\n guides: this.config?.guides ?? [],\n state: this.state,\n traits: this.user?.traits,\n url,\n isTargeted: (g) => this.isTargeted(g, ctx, url),\n isAudienceTargeted: (g) => {\n if (!isWithinSchedule(g)) return false;\n ctx.rolloutSalt = g.id;\n return evaluateRules(g.config.targeting, ctx);\n },\n newsSeen: Array.isArray(seen) ? seen : [],\n });\n }\n\n private destroyMessenger(): void {\n this.messenger?.destroy();\n this.messengerScope?.destroy();\n this.messenger = null;\n this.messengerScope = null;\n }\n\n private async loadArticle(id: string): Promise<ResourceCenterArticle | null> {\n try {\n const res = await this.api.get<{ article: ResourceCenterArticle }>(`/articles/${encodeURIComponent(id)}`);\n return res.ok && res.data ? res.data.article : null;\n } catch {\n return null;\n }\n }\n\n private async searchResourceCenter(q: string): Promise<ResourceCenterArticle[]> {\n try {\n const res = await this.api.get<{ articles: ResourceCenterArticle[] }>(\"/resource-center/search\", { params: { q } });\n return res.ok && res.data ? res.data.articles : [];\n } catch {\n return [];\n }\n }\n\n // ---------------------------------------------------------------------------\n // Checklists\n // ---------------------------------------------------------------------------\n\n /** Current progress for a checklist guide (by id or key). */\n getChecklistProgress(idOrKey: string): ChecklistProgressState {\n const guide = this.findGuide(idOrKey);\n const id = guide?.id ?? idOrKey;\n const p = this.state.checklists[id];\n return p ? { completedTaskIds: [...p.completedTaskIds], completedAt: p.completedAt ?? null, dismissedAt: p.dismissedAt ?? null } : { completedTaskIds: [], completedAt: null, dismissedAt: null };\n }\n\n /** Marks a checklist task complete (manual completion) and syncs progress. */\n completeChecklistTask(idOrKey: string, taskId: string): void {\n const guide = this.findGuide(idOrKey);\n if (!guide?.config.checklist) return;\n const task = guide.config.checklist.tasks.find((t) => t.id === taskId);\n if (task) this.markTaskDone(guide, task);\n }\n\n private markTaskDone(guide: PublishedGuide, task: ChecklistTask): void {\n const config = guide.config.checklist;\n if (!config) return;\n const progress = this.state.checklists[guide.id] ?? (this.state.checklists[guide.id] = { completedTaskIds: [] });\n if (progress.completedTaskIds.includes(task.id)) return;\n progress.completedTaskIds.push(task.id);\n this.enqueue(\"checklist_task_completed\", { guideId: guide.id, guideVersion: guide.version, properties: { taskId: task.id } });\n const complete = isChecklistComplete(config, progress) && !progress.completedAt;\n if (complete) {\n progress.completedAt = nowIso();\n this.enqueue(\"checklist_completed\", { guideId: guide.id, guideVersion: guide.version });\n }\n this.persistState();\n this.widgets.get(guide.id)?.checklist?.setProgress(this.getChecklistProgress(guide.id));\n void postWithRetry(this.api, `/checklists/${encodeURIComponent(guide.id)}/progress`, { anonymousId: this.anonymousId, userId: this.user?.id || null, guideVersion: guide.version, completedTaskIds: progress.completedTaskIds, completed: !!progress.completedAt });\n this.emitter.emit(\"checklist:task\", { guide, task, progress: this.getChecklistProgress(guide.id) });\n if (complete) {\n this.emitter.emit(\"checklist:complete\", guide);\n this.widgets.get(guide.id)?.checklist?.open();\n }\n }\n\n private completeChecklistTasksBy(kind: ChecklistTask[\"completion\"], value: string | Element | PublishedGuide): void {\n if (!this.config) return;\n for (const guide of this.config.guides) {\n const tasks = guide.config.checklist?.tasks;\n if (!tasks) continue;\n for (const task of tasks) {\n if (task.completion !== kind || !task.completionValue) continue;\n let hit = false;\n if (kind === \"event\") hit = value === task.completionValue;\n else if (kind === \"url_visited\") hit = urlMatches(task.completionValue, value as string);\n else if (kind === \"guide_completed\") hit = (value as PublishedGuide).id === task.completionValue || (value as PublishedGuide).key === task.completionValue;\n else if (kind === \"click\") {\n try {\n hit = !!(value as Element).closest(task.completionValue);\n } catch {\n hit = false;\n }\n }\n if (hit) this.markTaskDone(guide, task);\n }\n }\n }\n\n private handleChecklistTaskClick(guide: PublishedGuide, task: ChecklistTask): void {\n if (task.completion === \"manual\") this.markTaskDone(guide, task);\n if (task.action === \"start_guide\" && task.actionValue) this.startGuide(task.actionValue);\n else if (task.action === \"url\" && task.actionValue) this.navigate(task.actionValue);\n else if (task.action === \"event\" && task.actionValue) this.track(task.actionValue);\n }\n\n private dismissChecklist(guide: PublishedGuide): void {\n const progress = this.state.checklists[guide.id] ?? (this.state.checklists[guide.id] = { completedTaskIds: [] });\n progress.dismissedAt = nowIso();\n this.persistState();\n this.enqueue(\"checklist_dismissed\", { guideId: guide.id, guideVersion: guide.version });\n void postWithRetry(this.api, `/checklists/${encodeURIComponent(guide.id)}/progress`, { anonymousId: this.anonymousId, userId: this.user?.id || null, guideVersion: guide.version, completedTaskIds: progress.completedTaskIds, dismissed: true });\n this.widgets.get(guide.id)?.destroy();\n this.widgets.delete(guide.id);\n }\n\n /** Opens (rendering if needed) the checklist panel. */\n openChecklist(idOrKey: string): void {\n const guide = this.findGuide(idOrKey);\n if (!guide?.config.checklist) return;\n if (!this.widgets.has(guide.id)) {\n const p = this.state.checklists[guide.id];\n if (p?.dismissedAt) {\n delete p.dismissedAt;\n this.persistState();\n }\n this.showChecklist(guide);\n }\n this.widgets.get(guide.id)?.checklist?.open();\n }\n\n closeChecklist(idOrKey: string): void {\n const guide = this.findGuide(idOrKey);\n if (guide) this.widgets.get(guide.id)?.checklist?.close();\n }\n\n // ---------------------------------------------------------------------------\n // Public guide controls\n // ---------------------------------------------------------------------------\n\n /** Starts a guide by id or key, bypassing targeting and frequency rules. */\n startGuide(idOrKey: string, options: { stepId?: string } = {}): boolean {\n const guide = this.findGuide(idOrKey);\n if (!guide) {\n this.reportError(new Error(`[Guidely] startGuide: unknown guide \"${idOrKey}\"`));\n return false;\n }\n if (guide.kind === \"checklist\") {\n this.openChecklist(guide.id);\n return true;\n }\n if (this.active) this.stopGuide();\n this.widgets.get(guide.id)?.destroy();\n this.widgets.delete(guide.id);\n this.show(guide, true, options.stepId);\n return true;\n }\n\n /** Stops the active guide silently (no dismiss event). */\n stopGuide(): void {\n const a = this.active;\n if (!a) return;\n this.active = null;\n a.controller?.destroy();\n a.survey?.destroy();\n a.scope?.destroy();\n this.sessionStore.remove(KEYS.active);\n }\n\n /** Dismisses the active guide (records a dismissal). */\n dismissGuide(): void {\n const a = this.active;\n if (!a) return;\n if (a.controller) a.controller.dismiss();\n else {\n this.stopGuide();\n this.recordEnd(a.guide, \"dismissed\");\n this.emitter.emit(\"guide:dismiss\", a.guide);\n }\n }\n\n getActiveGuide(): PublishedGuide | null {\n return this.active?.guide ?? null;\n }\n\n /** Published guides for this environment (read-only). */\n getGuides(): ReadonlyArray<PublishedGuide> {\n return this.config?.guides ?? [];\n }\n\n isGuideCompleted(idOrKey: string): boolean {\n const guide = this.findGuide(idOrKey);\n return !!this.state.guides[guide?.id ?? idOrKey]?.completedAt;\n }\n\n openResourceCenter(): void {\n if (this.config?.messenger?.enabled) return this.openMessenger(\"help\");\n if (!this.resourceCenter) this.renderPersistentWidgets();\n this.resourceCenter?.open();\n }\n\n closeResourceCenter(): void {\n if (this.messenger) return this.closeMessenger();\n this.resourceCenter?.close();\n }\n\n /** Opens the Scout messenger (when enabled for the project), optionally on a tab. */\n openMessenger(tab?: MessengerTab): void {\n if (!this.config?.messenger?.enabled) return;\n void this.loadMessenger().then((m) => m?.open(tab));\n }\n\n closeMessenger(): void {\n this.messenger?.close();\n }\n\n /** Opens a new messenger conversation, optionally pre-filling the message. */\n showNewMessage(text?: string): void {\n if (!this.config?.messenger?.enabled) return;\n void this.loadMessenger().then((m) => m?.showNewMessage(text));\n }\n\n on<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): () => void {\n return this.emitter.on(event, cb);\n }\n\n off<K extends keyof GuidelyEvents>(event: K, cb: GuidelyEvents[K]): void {\n this.emitter.off(event, cb);\n }\n\n /** Snapshot for debugging / devtools. */\n getState() {\n return {\n ready: this.isReady,\n destroyed: this.destroyed,\n anonymousId: this.anonymousId,\n user: this.user,\n consent: this.consent,\n configVersion: this.config?.configVersion ?? null,\n guides: this.getGuides().map((g) => ({ id: g.id, key: g.key, kind: g.kind })),\n activeGuide: this.active ? { id: this.active.guide.id, key: this.active.guide.key, ...(this.active.controller?.getState() ?? {}) } : null,\n queued: this.queued.map((q) => q.guide.key),\n widgets: Array.from(this.widgets.keys()),\n guideState: this.state.guides,\n checklists: this.state.checklists,\n audienceIds: this.state.audienceIds,\n session: this.session,\n pendingEvents: this.queue.size,\n authoring: !!this.authoring?.isActive(),\n capture: !!this.capture?.isActive(),\n };\n }\n\n // ---------------------------------------------------------------------------\n // Authoring\n // ---------------------------------------------------------------------------\n\n private maybeStartAuthoring(): void {\n try {\n const bridge = new AuthoringBridge({\n api: this.api,\n sessionStore: this.sessionStore,\n theme: () => this.theme(),\n ctx: () => this.getContext(),\n maskSelectors: [...(this.options.maskSelectors || []), ...(this.config?.settings?.maskSelectors || [])],\n onError: (err) => this.reportError(err),\n onActive: (active) => this.setEditing(\"authoring\", active),\n });\n if (bridge.detect()) this.authoring = bridge;\n } catch (err) {\n this.reportError(err);\n }\n }\n\n /** Authoring or capture started / ended: pause everything a visitor would see or be recorded by. */\n private setEditing(kind: \"authoring\" | \"capture\", active: boolean): void {\n this.emitter.emit(kind, { active });\n if (active) {\n this.replay?.stop({ discard: true });\n this.stopGuide();\n this.widgets.forEach((w) => w.destroy());\n this.widgets.clear();\n if (kind === \"capture\") this.hidePersistentWidgets();\n } else {\n this.syncCapture();\n this.renderPersistentWidgets();\n this.evaluate(\"ready\");\n }\n }\n\n private hidePersistentWidgets(): void {\n this.resourceCenter?.destroy();\n this.resourceCenterScope?.destroy();\n this.resourceCenter = null;\n this.resourceCenterScope = null;\n this.destroyMessenger();\n }\n\n // ---------------------------------------------------------------------------\n // How-to capture\n // ---------------------------------------------------------------------------\n\n /**\n * Starts how-to capture when the URL carries `guidely_capture` (or this tab is mid-recording).\n * The bridge, toolbar and screenshot code are a separate chunk loaded only then.\n */\n private maybeStartCapture(): boolean {\n let marker: ReturnType<typeof takeCaptureToken> = null;\n try {\n marker = takeCaptureToken(this.sessionStore);\n } catch (err) {\n this.reportError(err);\n }\n if (!marker) return false;\n const found = marker;\n this.captureStarting = true;\n this.replay?.stop({ discard: true });\n loadCapture()\n .then(async (capture) => {\n if (this.destroyed) return;\n const bridge = capture.createBridge({\n api: this.api,\n sessionStore: this.sessionStore,\n marker: found,\n maskSelector: this.maskSelector(),\n onError: (err) => this.reportError(err),\n onActive: (active) => {\n this.captureStarting = false;\n this.setEditing(\"capture\", active);\n },\n });\n this.capture = bridge;\n await bridge.start();\n })\n .catch((err) => this.reportError(err))\n .finally(() => {\n if (!this.captureStarting) return;\n // The session was rejected (or failed to load): carry on as a normal page.\n this.captureStarting = false;\n if (this.destroyed) return;\n this.syncCapture();\n this.renderPersistentWidgets();\n this.evaluate(\"ready\");\n });\n return true;\n }\n\n // ---------------------------------------------------------------------------\n // Internals\n // ---------------------------------------------------------------------------\n\n private persistState(): void {\n writeJson(this.store, KEYS.state(this.options.projectId), this.state);\n }\n\n private persistSession(): void {\n writeJson(this.sessionStore, KEYS.session, this.session);\n }\n\n private reportError(err: unknown): void {\n const error = err instanceof Error ? err : new Error(String(err));\n this.log(\"error\", error.message);\n try {\n this.options.onError?.(error);\n } catch {\n /* ignore */\n }\n this.emitter.emit(\"error\", error);\n }\n\n private log(...args: unknown[]): void {\n if (this.options.debug && typeof console !== \"undefined\") console.debug(\"[Guidely]\", ...args);\n }\n\n // ---------------------------------------------------------------------------\n // Static helpers (used by the embed)\n // ---------------------------------------------------------------------------\n\n /** Creates (or returns the existing) client and starts initialisation. */\n static init(options: GuidelyOptions): GuidelyClient {\n if (current && !current.destroyed && current.options.projectId === options.projectId) return current;\n current?.destroy();\n current = new GuidelyClient(options);\n void current.init();\n return current;\n }\n\n /** The most recently created client, if any. */\n static get(): GuidelyClient | null {\n return current && !current.destroyed ? current : null;\n }\n}\n\nlet current: GuidelyClient | null = null;\n\n/** Mobile-only guides never run in the browser (older servers ignore `?platform=web`). */\nfunction webOnly(config: SdkConfigResponse): SdkConfigResponse {\n return config.guides.every((g) => supportsPlatform(g.config, \"web\")) ? config : { ...config, guides: config.guides.filter((g) => supportsPlatform(g.config, \"web\")) };\n}\n\nfunction pathOf(url: string): string {\n try {\n return new URL(url, \"http://localhost\").pathname;\n } catch {\n return url.replace(/[?#].*$/, \"\");\n }\n}\n\n/** `document.referrer` as origin + path, only when it is another site. */\nfunction externalReferrer(): string | undefined {\n try {\n if (!document.referrer) return undefined;\n const u = new URL(document.referrer);\n return u.origin === location.origin ? undefined : u.origin + u.pathname;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Creates a Guidely client and starts loading configuration. Throws a friendly error when called\n * during server-side rendering; framework adapters guard this for you.\n */\nexport function createGuidely(options: GuidelyOptions): GuidelyClient {\n const client = new GuidelyClient(options);\n current = client;\n void client.init();\n return client;\n}\n","import { type AppSnapshot, type AuthoringPick, type AuthoringSessionInfo, type ProjectTheme, type SelectorStrategy, type TargetingContext } from \"@guidelytech/shared\";\nimport { highlightSelectors, previewStep, runGuide, startAuthoring, type AuthoringSession, type GuideController, type PreviewHandle, type RunnableGuide } from \"@guidelytech/guide-runtime\";\nimport type { Api } from \"./http\";\nimport { captureSnapshot } from \"./snapshot\";\nimport { KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\n\n/** Schemas are only needed in authoring mode; load them lazily so the normal runtime stays zod-free. */\nasync function loadSchemas() {\n const m = await import(\"@guidelytech/shared\");\n return { StepSchema: m.StepSchema, GuideConfigSchema: m.GuideConfigSchema };\n}\n\nexport const AUTHORING_PARAM = \"guidely_authoring\";\nexport const HEARTBEAT_MS = 15000;\n/** Quiet period after DOM changes / navigation before a new page snapshot is sent. */\nexport const SNAPSHOT_DEBOUNCE_MS = 800;\n/** Upper bound on how long continuous DOM churn can delay a snapshot. */\nexport const SNAPSHOT_MAX_WAIT_MS = 4000;\n\n/** Messages the SDK posts to the dashboard window (`window.opener`). */\nexport type AuthoringOutgoingMessage =\n | { type: \"guidely:authoring-ready\"; sessionId: string; url: string }\n | { type: \"guidely:pick\"; sessionId: string; pick: AuthoringPick }\n | { type: \"guidely:highlight-result\"; sessionId: string; counts: number[]; resolved: boolean }\n | { type: \"guidely:preview-ended\"; sessionId: string; reason: string }\n | { type: \"guidely:exit\"; sessionId: string }\n | { type: \"guidely:pong\"; sessionId: string; url: string }\n | { type: \"guidely:snapshot\"; sessionId: string; snapshot: AppSnapshot };\n\n/** Messages the dashboard may post to the app window (origin-checked against `dashboardOrigin`). */\nexport type AuthoringIncomingMessage =\n | { type: \"guidely:preview-step\"; step: unknown; theme?: Partial<ProjectTheme> | null; appearance?: unknown }\n | { type: \"guidely:preview-guide\"; guide: { id?: string; key?: string; name?: string; kind?: string; version?: number; config: unknown } }\n | { type: \"guidely:highlight\"; selectors: SelectorStrategy[] }\n | { type: \"guidely:stop-preview\" }\n | { type: \"guidely:ping\" }\n | { type: \"guidely:request-snapshot\" }\n | { type: \"guidely:exit\" };\n\nexport interface AuthoringBridgeOptions {\n api: Api;\n sessionStore: KeyValueStore;\n theme: () => Partial<ProjectTheme>;\n ctx: () => TargetingContext;\n maskSelectors: string[];\n onError: (err: unknown) => void;\n onActive: (active: boolean) => void;\n}\n\n/**\n * Detects `?guidely_authoring=<token>`, verifies the session with the public API, runs the\n * runtime's element picker and bridges picks/previews with the dashboard via `postMessage`.\n */\nexport class AuthoringBridge {\n private token: string | null = null;\n private info: AuthoringSessionInfo | null = null;\n private session: AuthoringSession | null = null;\n private heartbeat: ReturnType<typeof setInterval> | null = null;\n private preview: PreviewHandle | null = null;\n private previewGuide: GuideController | null = null;\n private active = false;\n private observer: MutationObserver | null = null;\n private snapshotTimer: ReturnType<typeof setTimeout> | null = null;\n private snapshotDue = 0;\n private lastSnapshot = \"\";\n\n constructor(private readonly opts: AuthoringBridgeOptions) {}\n\n isActive(): boolean {\n return this.active;\n }\n\n /** Returns true when a token was found (in the URL or the session marker) and verification started. */\n detect(): boolean {\n if (typeof window === \"undefined\") return false;\n let token: string | null = null;\n try {\n const url = new URL(window.location.href);\n token = url.searchParams.get(AUTHORING_PARAM);\n if (token) {\n url.searchParams.delete(AUTHORING_PARAM);\n window.history.replaceState(window.history.state, \"\", url.toString());\n }\n } catch {\n token = null;\n }\n if (!token) {\n const marker = readJson<{ token?: string } | null>(this.opts.sessionStore, KEYS.authoring, null);\n token = marker?.token ?? null;\n }\n if (!token) return false;\n this.token = token;\n writeJson(this.opts.sessionStore, KEYS.authoring, { token });\n void this.start();\n return true;\n }\n\n private async start(): Promise<void> {\n if (!this.token) return;\n try {\n const res = await this.opts.api.get<AuthoringSessionInfo>(\"/authoring/session\", { params: { token: this.token } });\n if (!res.ok || !res.data) {\n this.opts.sessionStore.remove(KEYS.authoring);\n this.opts.onError(new Error(`[Guidely] authoring session invalid or expired (${res.status})`));\n return;\n }\n this.info = res.data;\n if (Date.parse(this.info.expiresAt) < Date.now()) {\n this.opts.sessionStore.remove(KEYS.authoring);\n this.opts.onError(new Error(\"[Guidely] authoring session expired\"));\n return;\n }\n this.active = true;\n this.opts.onActive(true);\n this.session = startAuthoring({\n dashboardOrigin: this.info.dashboardOrigin,\n onPick: (pick) => this.sendPick(pick),\n onExit: () => this.stop(),\n });\n this.heartbeat = setInterval(() => {\n void this.opts.api.post(\"/authoring/session/heartbeat\", {}, { params: { token: this.token ?? undefined } }).catch(() => {});\n }, HEARTBEAT_MS);\n this.post({ type: \"guidely:authoring-ready\", sessionId: this.info.id, url: window.location.href });\n this.watchPage();\n } catch (err) {\n this.opts.onError(err);\n }\n }\n\n private masked(el: Element): boolean {\n return this.opts.maskSelectors.some((sel) => {\n try {\n return !!el.closest(sel);\n } catch {\n return false;\n }\n });\n }\n\n private sendPick(raw: AuthoringPick & { element: Element }): void {\n if (!this.info || !this.token) return;\n const { element, ...rest } = raw;\n const pick: AuthoringPick = this.masked(element) ? { ...rest, textSnapshot: \"\", selectors: rest.selectors.filter((s) => s.kind !== \"text\") } : rest;\n pick.url = window.location.href;\n this.post({ type: \"guidely:pick\", sessionId: this.info.id, pick });\n void this.opts.api.post(\"/authoring/session/picks\", pick, { params: { token: this.token } }).catch((err) => this.opts.onError(err));\n }\n\n /** Sends a snapshot now and again whenever the page settles after DOM changes or navigation. */\n private watchPage(): void {\n this.scheduleSnapshot();\n if (typeof MutationObserver === \"undefined\") return;\n this.observer = new MutationObserver(() => this.scheduleSnapshot());\n this.observer.observe(document.documentElement, { subtree: true, childList: true, attributes: true, characterData: true });\n }\n\n private scheduleSnapshot(): void {\n const now = Date.now();\n if (!this.snapshotTimer) this.snapshotDue = now + SNAPSHOT_MAX_WAIT_MS;\n else clearTimeout(this.snapshotTimer);\n this.snapshotTimer = setTimeout(() => this.sendSnapshot(), Math.max(0, Math.min(SNAPSHOT_DEBOUNCE_MS, this.snapshotDue - now)));\n }\n\n private sendSnapshot(): void {\n if (this.snapshotTimer) clearTimeout(this.snapshotTimer);\n this.snapshotTimer = null;\n if (!this.info || !this.active) return;\n try {\n const snapshot = captureSnapshot(document, this.opts.maskSelectors);\n if (!snapshot || snapshot.html === this.lastSnapshot) return;\n this.lastSnapshot = snapshot.html;\n this.post({ type: \"guidely:snapshot\", sessionId: this.info.id, snapshot });\n } catch (err) {\n this.opts.onError(err);\n }\n }\n\n private post(message: AuthoringOutgoingMessage): void {\n if (!this.info) return;\n try {\n window.opener?.postMessage(message, this.info.dashboardOrigin);\n } catch {\n /* opener may be gone */\n }\n }\n\n private stopPreview(): void {\n this.preview?.destroy();\n this.preview = null;\n this.previewGuide?.destroy();\n this.previewGuide = null;\n this.session?.setPicking(true);\n }\n\n /** Handles `message` events; ignores anything not from `dashboardOrigin`. */\n async handleMessage(e: MessageEvent): Promise<void> {\n if (!this.active || !this.info) return;\n if (e.origin !== this.info.dashboardOrigin) return;\n const msg = e.data as AuthoringIncomingMessage | null;\n if (!msg || typeof msg !== \"object\" || typeof msg.type !== \"string\") return;\n try {\n switch (msg.type) {\n case \"guidely:preview-step\": {\n this.stopPreview();\n const { StepSchema, GuideConfigSchema } = await loadSchemas();\n const step = StepSchema.parse(msg.step);\n const appearance = msg.appearance ? GuideConfigSchema.shape.appearance.parse(msg.appearance) : undefined;\n this.session?.setPicking(false);\n this.session?.setStatus(`Previewing step “${step.title || step.id}” — close it to continue picking`);\n this.preview = previewStep(step, { ...this.opts.theme(), ...(msg.theme || {}) }, {\n appearance,\n onEnd: () => {\n this.preview = null;\n this.session?.setPicking(true);\n this.session?.setStatus(\"Guidely authoring — hover an element and click to select · Esc to cancel\");\n this.post({ type: \"guidely:preview-ended\", sessionId: this.info!.id, reason: \"step\" });\n },\n });\n break;\n }\n case \"guidely:preview-guide\": {\n this.stopPreview();\n const g = msg.guide;\n const guide: RunnableGuide = { id: g.id || \"preview\", key: g.key || \"preview\", name: g.name || \"Preview\", kind: g.kind || \"flow\", version: g.version ?? 0, config: (await loadSchemas()).GuideConfigSchema.parse(g.config) };\n this.session?.setPicking(false);\n this.session?.setStatus(`Previewing “${guide.name}”`);\n this.previewGuide = runGuide(guide, {\n theme: this.opts.theme(),\n ctx: this.opts.ctx,\n onNavigate: (url, newTab) => (newTab ? window.open(url, \"_blank\", \"noopener\") : window.location.assign(url)),\n onEnd: (reason) => {\n this.previewGuide = null;\n this.session?.setPicking(true);\n this.post({ type: \"guidely:preview-ended\", sessionId: this.info!.id, reason });\n },\n });\n this.previewGuide.start();\n break;\n }\n case \"guidely:highlight\": {\n const result = highlightSelectors(Array.isArray(msg.selectors) ? msg.selectors : [], { durationMs: 3000 });\n this.post({ type: \"guidely:highlight-result\", sessionId: this.info.id, counts: result.counts, resolved: !!result.resolved });\n break;\n }\n case \"guidely:stop-preview\":\n this.stopPreview();\n break;\n case \"guidely:request-snapshot\":\n this.lastSnapshot = \"\";\n this.sendSnapshot();\n break;\n case \"guidely:ping\":\n this.post({ type: \"guidely:pong\", sessionId: this.info.id, url: window.location.href });\n break;\n case \"guidely:exit\":\n this.stop();\n break;\n default:\n break;\n }\n } catch (err) {\n this.opts.onError(err);\n }\n }\n\n /** Leaves authoring mode and clears the session marker. */\n stop(): void {\n if (!this.active) return;\n this.active = false;\n this.stopPreview();\n this.observer?.disconnect();\n this.observer = null;\n if (this.snapshotTimer) clearTimeout(this.snapshotTimer);\n this.snapshotTimer = null;\n if (this.heartbeat) clearInterval(this.heartbeat);\n this.heartbeat = null;\n this.session?.stop();\n this.session = null;\n this.opts.sessionStore.remove(KEYS.authoring);\n if (this.info) this.post({ type: \"guidely:exit\", sessionId: this.info.id });\n this.opts.onActive(false);\n }\n}\n","import type { AppSnapshot } from \"@guidelytech/shared\";\n\n/** Snapshots larger than this are not sent (postMessage copies the string). */\nexport const MAX_SNAPSHOT_BYTES = 6 * 1024 * 1024;\n\nconst STRIP = \"script, noscript, template, #guidely-root, [data-guidely], meta[http-equiv], link[rel~='preload'], link[rel~='modulepreload'], link[rel~='prefetch'], link[rel~='manifest'], link[rel~='serviceworker']\";\n\n/** Text of a stylesheet built through the CSSOM (CSS-in-JS often leaves `<style>` empty). */\nfunction rulesText(sheet: CSSStyleSheet | null | undefined): string | null {\n if (!sheet) return null;\n try {\n return Array.from(sheet.cssRules, (r) => r.cssText).join(\"\\n\");\n } catch {\n return null; // cross-origin sheet\n }\n}\n\n/** Replaces text inside masked elements with bullets of the same length, keeping the layout. */\nfunction maskText(root: Element): void {\n const walker = root.ownerDocument.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n for (let n = walker.nextNode(); n; n = walker.nextNode()) {\n n.textContent = (n.textContent ?? \"\").replace(/\\S/g, \"•\");\n }\n}\n\n/**\n * Serializes the current page into a static HTML document for the dashboard's editor canvas.\n * Scripts, event handlers, Guidely's own UI and form values are dropped; `maskSelectors` text is\n * replaced with bullets. Same-origin CSSOM rules are inlined; everything else resolves through a\n * `<base href>` so stylesheets and images load from the app.\n */\nexport function captureSnapshot(doc: Document, maskSelectors: string[], maxBytes = MAX_SNAPSHOT_BYTES): AppSnapshot | null {\n const win = doc.defaultView;\n if (!win || !doc.documentElement) return null;\n const clone = doc.documentElement.cloneNode(true) as HTMLElement;\n\n // Elements whose state lives outside their markup are matched to the clone by document order,\n // so do this before anything is removed from the clone.\n const origStyles = doc.documentElement.querySelectorAll(\"style\");\n clone.querySelectorAll(\"style\").forEach((el, i) => {\n const css = rulesText(origStyles[i]?.sheet as CSSStyleSheet | null);\n if (css !== null && css.length > (el.textContent ?? \"\").length) el.textContent = css;\n });\n const origFrames = doc.documentElement.querySelectorAll(\"iframe, canvas, video, embed, object\");\n clone.querySelectorAll(\"iframe, canvas, video, embed, object\").forEach((el, i) => {\n const r = origFrames[i]?.getBoundingClientRect();\n const box = doc.createElement(\"div\");\n box.setAttribute(\"style\", `${el.getAttribute(\"style\") ?? \"\"};width:${r?.width ?? 0}px;height:${r?.height ?? 0}px;background:#e2e8f0;border-radius:4px`);\n if (el.getAttribute(\"class\")) box.setAttribute(\"class\", el.getAttribute(\"class\")!);\n el.replaceWith(box);\n });\n\n clone.querySelectorAll(STRIP).forEach((el) => el.remove());\n for (const sel of maskSelectors) {\n try {\n clone.querySelectorAll(sel).forEach(maskText);\n } catch {\n /* invalid selector */\n }\n }\n clone.querySelectorAll(\"*\").forEach((el) => {\n for (const attr of Array.from(el.attributes)) {\n const name = attr.name.toLowerCase();\n if (name.startsWith(\"on\") || ((name === \"href\" || name === \"src\" || name === \"action\") && /^\\s*javascript:/i.test(attr.value))) el.removeAttribute(attr.name);\n }\n if (el instanceof HTMLInputElement) {\n el.removeAttribute(\"value\");\n el.removeAttribute(\"checked\");\n } else if (el instanceof HTMLTextAreaElement) {\n el.textContent = \"\";\n }\n el.removeAttribute(\"autofocus\");\n });\n\n const adopted = Array.from((doc as Document & { adoptedStyleSheets?: CSSStyleSheet[] }).adoptedStyleSheets ?? [])\n .map(rulesText)\n .filter(Boolean)\n .join(\"\\n\");\n let head = clone.querySelector(\"head\");\n if (!head) {\n head = doc.createElement(\"head\");\n clone.prepend(head);\n }\n if (adopted) {\n const style = doc.createElement(\"style\");\n style.textContent = adopted;\n head.append(style);\n }\n clone.querySelectorAll(\"base\").forEach((el) => el.remove());\n const base = doc.createElement(\"base\");\n base.setAttribute(\"href\", doc.baseURI || win.location.href);\n base.setAttribute(\"target\", \"_blank\");\n head.prepend(base);\n\n const html = `<!DOCTYPE html>\\n${clone.outerHTML}`;\n if (html.length > maxBytes) return null;\n return { html, url: win.location.href, title: doc.title, width: win.innerWidth, height: win.innerHeight, capturedAt: new Date().toISOString() };\n}\n","export type StorageKind = \"local\" | \"session\" | \"memory\";\n\n/** Minimal synchronous key/value store; never throws (private mode, quota, SSR). */\nexport interface KeyValueStore {\n get(key: string): string | null;\n set(key: string, value: string): void;\n remove(key: string): void;\n}\n\nexport function memoryStore(): KeyValueStore {\n const map = new Map<string, string>();\n return { get: (k) => map.get(k) ?? null, set: (k, v) => void map.set(k, v), remove: (k) => void map.delete(k) };\n}\n\nfunction webStore(area: \"localStorage\" | \"sessionStorage\"): KeyValueStore | null {\n try {\n if (typeof window === \"undefined\") return null;\n const s = window[area];\n if (!s) return null;\n const probe = \"__guidely_probe__\";\n s.setItem(probe, \"1\");\n s.removeItem(probe);\n return {\n get: (k) => {\n try {\n return s.getItem(k);\n } catch {\n return null;\n }\n },\n set: (k, v) => {\n try {\n s.setItem(k, v);\n } catch {\n /* quota / private mode */\n }\n },\n remove: (k) => {\n try {\n s.removeItem(k);\n } catch {\n /* ignore */\n }\n },\n };\n } catch {\n return null;\n }\n}\n\n/** Creates a store of the requested kind, degrading to memory when unavailable. */\nexport function createStorage(kind: StorageKind = \"local\"): KeyValueStore {\n if (kind === \"memory\") return memoryStore();\n return webStore(kind === \"local\" ? \"localStorage\" : \"sessionStorage\") ?? memoryStore();\n}\n\nexport function readJson<T>(store: KeyValueStore, key: string, fallback: T): T {\n const raw = store.get(key);\n if (raw == null) return fallback;\n try {\n return JSON.parse(raw) as T;\n } catch {\n return fallback;\n }\n}\n\nexport function writeJson(store: KeyValueStore, key: string, value: unknown): void {\n try {\n store.set(key, JSON.stringify(value));\n } catch {\n /* ignore */\n }\n}\n\n/** Storage keys used by the SDK (documented for integrators). */\nexport const KEYS = {\n anon: \"guidely:anon\",\n seen: \"guidely:seen\",\n config: (key: string) => `guidely:config:${key}`,\n etag: (key: string) => `guidely:etag:${key}`,\n state: (key: string) => `guidely:state:${key}`,\n user: (key: string) => `guidely:user:${key}`,\n queue: (key: string) => `guidely:queue:${key}`,\n session: \"guidely:session\",\n active: \"guidely:active\",\n authoring: \"guidely:authoring\",\n /** How-to capture session marker ({ token, … }) and its not-yet-uploaded steps. */\n capture: \"guidely:capture\",\n capturePending: \"guidely:capture:pending\",\n /** Messenger conversations this browser can read: [{ id, token }]. */\n conversations: (key: string) => `guidely:conversations:${key}`,\n /** Announcement ids opened in the messenger's News tab. */\n newsSeen: (key: string) => `guidely:news:${key}`,\n} as const;\n","import { CAPTURE_PARAM } from \"@guidelytech/shared/runtime\";\nimport { AUTHORING_PARAM } from \"./authoring\";\nimport { KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\n\nexport { CAPTURE_PARAM };\n\n/** What the SDK remembers about a capture session in this tab (`guidely:capture` in sessionStorage). */\nexport interface CaptureMarker {\n token: string;\n /** Recording has started (a page load continues it instead of showing \"Start recording\"). */\n started?: boolean;\n /** The user chose to take screenshots. */\n screenshots?: boolean;\n /** Epoch ms and action of the last recorded step. */\n lastStepAt?: number;\n lastAction?: string;\n}\n\n/**\n * Finds a capture token in the URL (and strips it) or in this tab's session marker. A capture\n * param wins over an authoring param; a leftover marker does not win over a fresh authoring link.\n */\nexport function takeCaptureToken(sessionStore: KeyValueStore): CaptureMarker | null {\n if (typeof window === \"undefined\") return null;\n let token: string | null = null;\n let authoringLink = false;\n try {\n const url = new URL(window.location.href);\n token = url.searchParams.get(CAPTURE_PARAM);\n authoringLink = url.searchParams.has(AUTHORING_PARAM);\n if (token) {\n url.searchParams.delete(CAPTURE_PARAM);\n window.history.replaceState(window.history.state, \"\", url.toString());\n }\n } catch {\n token = null;\n }\n const saved = readJson<CaptureMarker | null>(sessionStore, KEYS.capture, null);\n let marker: CaptureMarker | null = null;\n if (token) marker = saved?.token === token ? saved : { token };\n else if (saved?.token && !authoringLink) marker = saved;\n if (!marker) {\n if (saved) {\n sessionStore.remove(KEYS.capture);\n sessionStore.remove(KEYS.capturePending);\n }\n return null;\n }\n if (token && saved?.token !== token) sessionStore.remove(KEYS.capturePending);\n writeJson(sessionStore, KEYS.capture, marker);\n sessionStore.remove(KEYS.authoring);\n return marker;\n}\n","import type { CaptureApi } from \"./capture\";\n\n/**\n * Loads the how-to capture chunk on demand (only in a capture session). Like the replay recorder,\n * the import is rewritten per build: `./capture.js` (npm; consumers' bundlers code-split it) or, in\n * the script-tag build, a loader that injects `guidely-capture.js` and resolves `window.__guidelyCapture`.\n */\nexport const loadCapture = async (): Promise<CaptureApi> => (await import(\"./capture\")).capture;\n","import { isGuidelyElement, isStableId } from \"@guidelytech/guide-runtime\";\n\n/** Elements whose clicks are autocaptured (the click may land on a descendant). */\nexport const INTERACTIVE_SELECTOR =\n \"a,button,input[type=button],input[type=submit],input[type=reset],input[type=checkbox],input[type=radio],select,summary,label,[role=button],[role=link],[role=tab],[role=menuitem],[role=checkbox],[role=switch],[role=option],[onclick],[data-guidely-track]\";\n\n/** Always-on mask selectors (text never captured, masked in replays). */\nexport const DEFAULT_MASK_SELECTORS = [\"[data-guidely-mask]\", \".guidely-mask\"];\n\n/** `click` / `rage_click` event properties. */\nexport interface ClickProperties {\n tag: string;\n text?: string;\n selector: string;\n href?: string;\n x: number;\n y: number;\n count?: number;\n}\n\nconst PREFERRED_ATTRS = [\"data-testid\", \"data-test-id\", \"data-test\", \"data-cy\", \"data-qa\", \"data-guidely-track\", \"data-tour\"];\nconst NOISY_DATA_ATTR = /^data-(state|v-|react|radix|headlessui|svelte|orientation|highlighted|focus|key|index|side|align|disabled|selected|active|open|guidely-(mask|ignore|block))/i;\n\n/** Drops empty and syntactically invalid CSS selectors. */\nexport function validSelectors(list: Array<string | null | undefined>): string[] {\n const out: string[] = [];\n const probe = typeof document !== \"undefined\" ? document.createDocumentFragment() : null;\n for (const raw of list) {\n const s = (raw || \"\").trim();\n if (!s || out.includes(s)) continue;\n try {\n probe?.querySelector(s);\n out.push(s);\n } catch {\n /* invalid selector */\n }\n }\n return out;\n}\n\n/** True for clicks Guidely must never capture: its own UI and anything under `[data-guidely-ignore]`. */\nexport function isIgnoredElement(el: Element): boolean {\n return isGuidelyElement(el) || !!el.closest(\"[data-guidely-ignore]\");\n}\n\n/** The interactive element a click landed on (or inside), if any. */\nexport function interactiveElement(target: Element): Element | null {\n try {\n return target.closest(INTERACTIVE_SELECTOR);\n } catch {\n return null;\n }\n}\n\nfunction esc(value: string): string {\n const g = globalThis as { CSS?: { escape?: (v: string) => string } };\n return g.CSS?.escape ? g.CSS.escape(value) : value.replace(/[^\\w-]/g, (c) => `\\\\${c}`);\n}\n\nconst attr = (tag: string, name: string, value: string) => (value ? `${tag}[${name}=\"${value.replace(/[\"\\\\]/g, \"\\\\$&\")}\"]` : `${tag}[${name}]`);\n\n/** Stable selector: id → test/tracking data attributes → other data-* → aria-label → short CSS path. */\nexport function elementSelector(el: Element): string {\n const tag = el.tagName.toLowerCase();\n if (el.id && isStableId(el.id)) return `#${esc(el.id)}`;\n for (const name of PREFERRED_ATTRS) if (el.hasAttribute(name)) return attr(tag, name, el.getAttribute(name) || \"\").slice(0, 300);\n for (const a of Array.from(el.attributes)) {\n if (a.name.startsWith(\"data-\") && !NOISY_DATA_ATTR.test(a.name) && a.value && a.value.length <= 60) return attr(tag, a.name, a.value).slice(0, 300);\n }\n const label = el.getAttribute(\"aria-label\");\n if (label && label.length <= 80) return attr(tag, \"aria-label\", label).slice(0, 300);\n const parts: string[] = [];\n let cur: Element | null = el;\n while (cur && parts.length < 4) {\n const t = cur.tagName.toLowerCase();\n if (t === \"html\" || t === \"body\") break;\n if (cur !== el && cur.id && isStableId(cur.id)) {\n parts.unshift(`#${esc(cur.id)}`);\n break;\n }\n const parent: Element | null = cur.parentElement;\n const node: Element = cur;\n const same = parent ? Array.from(parent.children).filter((c) => c.tagName === node.tagName) : [];\n parts.unshift(same.length > 1 ? `${t}:nth-of-type(${same.indexOf(node) + 1})` : t);\n cur = parent;\n }\n return (parts.join(\" > \") || tag).slice(0, 300);\n}\n\nfunction matches(el: Element, selector: string, deep: boolean): boolean {\n if (!selector) return false;\n try {\n return !!el.closest(selector) || (deep && !!el.querySelector(selector));\n } catch {\n return false;\n }\n}\n\n/**\n * Visible text of a clicked element (≤100 chars, whitespace collapsed). Never the value of a form\n * field (only button-like inputs), and nothing when the element is (or contains) masked content.\n */\nexport function elementText(el: Element, mask: string, maskAll: boolean): string | undefined {\n if (maskAll || matches(el, mask, true)) return undefined;\n const tag = el.tagName.toLowerCase();\n let text = \"\";\n if (tag === \"input\") {\n if (!/^(button|submit|reset)$/i.test((el as HTMLInputElement).type || \"\")) return undefined;\n text = (el as HTMLInputElement).value;\n } else if (tag === \"select\" || tag === \"textarea\") return undefined;\n else text = (el as HTMLElement).innerText ?? el.textContent ?? \"\";\n text = (text || el.getAttribute(\"aria-label\") || el.getAttribute(\"title\") || \"\").replace(/\\s+/g, \" \").trim();\n return text ? text.slice(0, 100) : undefined;\n}\n\n/** Link target for analytics: the path for same-origin links, only the origin otherwise. */\nexport function linkHref(el: Element): string | undefined {\n const a = el.closest(\"a[href]\");\n if (!a) return undefined;\n try {\n const u = new URL(a.getAttribute(\"href\") || \"\", location.href);\n if (!/^https?:$/.test(u.protocol)) return undefined;\n return u.origin === location.origin ? u.pathname : u.origin;\n } catch {\n return undefined;\n }\n}\n\n/** Builds `click` properties for an element. */\nexport function describeClick(el: Element, e: MouseEvent, opts: { mask: string; maskAll: boolean; collectUrls: boolean }): ClickProperties {\n const props: ClickProperties = { tag: el.tagName.toLowerCase(), selector: elementSelector(el), x: Math.round(e.pageX ?? 0) || 0, y: Math.round(e.pageY ?? 0) || 0 };\n const text = elementText(el, opts.mask, opts.maskAll);\n if (text) props.text = text;\n const href = opts.collectUrls ? linkHref(el) : undefined;\n if (href) props.href = href;\n return props;\n}\n\n/** Detects rage clicks: 3+ clicks within 1s and 30px of each other, reported once per burst. */\nexport class RageClickDetector {\n private clicks: Array<{ x: number; y: number; t: number }> = [];\n private fired = false;\n\n constructor(\n private readonly threshold = 3,\n private readonly windowMs = 1000,\n private readonly radius = 30,\n ) {}\n\n /** Clicks in the current burst once it has fired (rage), otherwise 0. */\n get burst(): number {\n return this.fired ? this.clicks.length : 0;\n }\n\n /** Records a click; returns the click count when it completes a burst, otherwise 0. */\n add(x: number, y: number, t: number): number {\n const first = this.clicks[0];\n const last = this.clicks[this.clicks.length - 1];\n if (!first || !last || t - last.t > this.windowMs || Math.hypot(x - first.x, y - first.y) > this.radius) {\n this.clicks = [];\n this.fired = false;\n }\n this.clicks = this.clicks.filter((c) => t - c.t <= this.windowMs);\n this.clicks.push({ x, y, t });\n if (this.fired || this.clicks.length < this.threshold) return 0;\n this.fired = true;\n return this.clicks.length;\n }\n}\n","import type { TargetingContext } from \"@guidelytech/shared\";\n\nexport interface DeviceInfo {\n type: \"desktop\" | \"tablet\" | \"mobile\";\n browser?: string;\n os?: string;\n}\n\n/** Lightweight UA sniffing (good enough for targeting; not for feature detection). */\nexport function detectDevice(ua: string, width: number): DeviceInfo {\n const u = ua || \"\";\n let type: DeviceInfo[\"type\"] = \"desktop\";\n if (/iPad|Tablet|PlayBook|Silk/i.test(u) || (/Android/i.test(u) && !/Mobile/i.test(u))) type = \"tablet\";\n else if (/Mobi|iPhone|iPod|Android.*Mobile|Windows Phone/i.test(u)) type = \"mobile\";\n else if (width > 0 && width < 768) type = \"mobile\";\n else if (width > 0 && width < 1024) type = \"tablet\";\n let browser: string | undefined;\n if (/Edg\\//i.test(u)) browser = \"edge\";\n else if (/OPR\\/|Opera/i.test(u)) browser = \"opera\";\n else if (/SamsungBrowser/i.test(u)) browser = \"samsung\";\n else if (/Chrome\\/|CriOS/i.test(u)) browser = \"chrome\";\n else if (/Firefox\\/|FxiOS/i.test(u)) browser = \"firefox\";\n else if (/Safari\\//i.test(u) && /Version\\//i.test(u)) browser = \"safari\";\n else if (/MSIE|Trident/i.test(u)) browser = \"ie\";\n let os: string | undefined;\n if (/Windows/i.test(u)) os = \"windows\";\n else if (/iPhone|iPad|iPod/i.test(u)) os = \"ios\";\n else if (/Mac OS X|Macintosh/i.test(u)) os = \"macos\";\n else if (/Android/i.test(u)) os = \"android\";\n else if (/CrOS/i.test(u)) os = \"chromeos\";\n else if (/Linux/i.test(u)) os = \"linux\";\n return { type, browser, os };\n}\n\nexport interface ContextInput {\n anonymousId: string;\n userId?: string | null;\n userAttributes: Record<string, unknown>;\n accountAttributes: Record<string, unknown>;\n url: string;\n firstVisit: boolean;\n eventsSeen: Iterable<string>;\n completedGuides: Iterable<string>;\n dismissedGuides: Iterable<string>;\n seenGuides: Iterable<string>;\n completedChecklists: Iterable<string>;\n audienceIds: Iterable<string>;\n environment: string;\n locale?: string;\n device?: DeviceInfo;\n now?: Date;\n platform?: string;\n screen?: string;\n appVersion?: string;\n}\n\n/** Builds the `TargetingContext` consumed by `evaluateRules`. */\nexport function buildContext(input: ContextInput): TargetingContext {\n let path = \"\";\n const query: Record<string, string> = {};\n try {\n const u = new URL(input.url, \"http://localhost\");\n path = u.pathname;\n u.searchParams.forEach((v, k) => {\n query[k] = v;\n });\n } catch {\n path = input.url;\n }\n const device = input.device ?? (typeof navigator !== \"undefined\" ? detectDevice(navigator.userAgent, typeof window !== \"undefined\" ? window.innerWidth : 0) : { type: \"desktop\" });\n return {\n anonymousId: input.anonymousId,\n userId: input.userId ?? null,\n userAttributes: input.userAttributes,\n accountAttributes: input.accountAttributes,\n url: input.url,\n path,\n query,\n device,\n firstVisit: input.firstVisit,\n eventsSeen: new Set(input.eventsSeen),\n completedGuides: new Set(input.completedGuides),\n dismissedGuides: new Set(input.dismissedGuides),\n seenGuides: new Set(input.seenGuides),\n completedChecklists: new Set(input.completedChecklists),\n audienceIds: new Set(input.audienceIds),\n now: input.now ?? new Date(),\n environment: input.environment,\n locale: input.locale ?? (typeof navigator !== \"undefined\" ? navigator.language : undefined),\n platform: input.platform ?? \"web\",\n ...(input.screen !== undefined ? { screen: input.screen } : {}),\n ...(input.appVersion !== undefined ? { appVersion: input.appVersion } : {}),\n };\n}\n","import type { HeatmapPoint } from \"@guidelytech/shared\";\nimport { elementSelector } from \"./autocapture\";\n\n/** Points per `heatmap` event, and the JSON size at which a batch is sent early (properties cap at 8KB). */\nexport const HEATMAP_MAX_POINTS = 40;\nexport const HEATMAP_MAX_BYTES = 6000;\n/** Movement bins per batch before it is sent. */\nexport const HEATMAP_MAX_BINS = 60;\n\nconst r2 = (n: number) => Math.round(Math.min(1, Math.max(0, n)) * 100) / 100;\n\n/** One heatmap point: page coordinates, a stable selector and the position inside the element (0–1). */\nexport function heatmapPoint(el: Element, e: MouseEvent, rage: boolean): HeatmapPoint {\n const p: HeatmapPoint = { k: rage ? \"r\" : \"c\", x: Math.round(e.pageX ?? 0) || 0, y: Math.round(e.pageY ?? 0) || 0 };\n const s = elementSelector(el).slice(0, 120);\n if (s) p.s = s;\n const rect = el.getBoundingClientRect();\n if (rect.width > 0 && rect.height > 0) {\n p.rx = r2((e.clientX - rect.left) / rect.width);\n p.ry = r2((e.clientY - rect.top) / rect.height);\n }\n return p;\n}\n\nconst selectors = new WeakMap<Element, string>();\nconst r1 = (n: number) => Math.round(Math.min(1, Math.max(0, n)) * 10) / 10;\n\n/**\n * Movement bin for a pointer sample: per element at 0.1 of the element box (selectors cached per\n * element), or a 16px page-grid cell for `html`/`body` and elements without a box or selector.\n */\nexport function movementBin(el: Element, e: MouseEvent): [string, HeatmapPoint] {\n const p: HeatmapPoint = { k: \"m\", x: Math.round(e.pageX ?? 0) || 0, y: Math.round(e.pageY ?? 0) || 0 };\n let s = /^(HTML|BODY)$/.test(el.tagName) ? \"\" : selectors.get(el);\n if (s === undefined) selectors.set(el, (s = elementSelector(el).slice(0, 120)));\n const rect = s ? el.getBoundingClientRect() : null;\n if (!rect || !(rect.width > 0 && rect.height > 0)) return [`${p.x >> 4},${p.y >> 4}`, p];\n p.s = s;\n p.rx = r1((e.clientX - rect.left) / rect.width);\n p.ry = r1((e.clientY - rect.top) / rect.height);\n return [`${s} ${p.rx},${p.ry}`, p];\n}\n\n/** Click positions and movement bins on the current page, sent as one `heatmap` event per batch. */\nexport class HeatmapBuffer {\n /** The page the buffered points belong to. */\n url = \"\";\n points: HeatmapPoint[] = [];\n private bins = new Map<string, HeatmapPoint>();\n private bytes = 0;\n\n /** Adds a click (`burst` > 0 marks it and the burst's previous clicks as rage); true when the batch is full. */\n add(url: string, point: HeatmapPoint, burst: number): boolean {\n this.url = url;\n for (let i = Math.max(0, this.points.length - burst + 1); i < this.points.length; i++) (this.points[i] as HeatmapPoint).k = \"r\";\n this.points.push(point);\n this.bytes += JSON.stringify(point).length + 1;\n return this.full();\n }\n\n /** Adds a movement sample to its bin (weight +1); true when the batch is full. */\n move(url: string, [key, point]: [string, HeatmapPoint]): boolean {\n this.url = url;\n const bin = this.bins.get(key);\n if (bin) bin.w = (bin.w ?? 1) + 1;\n else {\n this.bins.set(key, point);\n this.bytes += JSON.stringify(point).length + 8; // + room for \"w\"\n }\n return this.full();\n }\n\n private full(): boolean {\n return this.points.length >= HEATMAP_MAX_POINTS || this.bins.size > HEATMAP_MAX_BINS || this.bytes >= HEATMAP_MAX_BYTES;\n }\n\n /** Empties the buffer, returning what was in it (clicks first, then movement bins). */\n take(): { url: string; points: HeatmapPoint[] } | null {\n const points = [...this.points, ...this.bins.values()];\n this.points = [];\n this.bins = new Map();\n this.bytes = 0;\n return points.length ? { url: this.url, points } : null;\n }\n}\n","import { parseStack, type ExceptionProperties, type StackFrame } from \"@guidelytech/shared/runtime\";\n\n/** Byte budget for the `frames` property (the event's properties are capped at 8KB). */\nconst MAX_FRAMES_BYTES = 6000;\n\nfunction fitFrames(frames: StackFrame[]): StackFrame[] {\n const out = frames.slice(0, 30);\n while (out.length > 1 && JSON.stringify(out).length > MAX_FRAMES_BYTES) out.pop();\n return out;\n}\n\nfunction describe(value: unknown): string {\n if (typeof value === \"string\") return value;\n try {\n return JSON.stringify(value) ?? String(value);\n } catch {\n return String(value);\n }\n}\n\n/** Converts anything thrown into `exception` properties. */\nexport function exceptionFromError(error: unknown, source: string, handled: boolean, fallbackType = \"Error\"): ExceptionProperties {\n const isError = error instanceof Error || (!!error && typeof error === \"object\" && typeof (error as Error).message === \"string\" && typeof (error as Error).stack === \"string\");\n const e = error as Error;\n return {\n type: (isError && e.name) || fallbackType,\n message: (isError ? e.message : describe(error)).slice(0, 1000),\n frames: isError ? fitFrames(parseStack(e.stack)) : [],\n source,\n handled,\n };\n}\n\n/** `window` `error` event → exception; `null` for resource-load errors and opaque \"Script error.\" reports. */\nexport function errorEventToException(e: ErrorEvent): ExceptionProperties | null {\n const target = e.target as unknown;\n if (target && typeof Element !== \"undefined\" && target instanceof Element) return null;\n if (e.error != null) return exceptionFromError(e.error, \"onerror\", false);\n const message = e.message || \"\";\n if (!message || /^script error\\.?$/i.test(message.trim())) return null;\n const m = /^(?:Uncaught )?([A-Z]\\w*(?:Error|Exception)):\\s*([\\s\\S]*)$/.exec(message);\n return {\n type: m?.[1] ?? \"Error\",\n message: (m?.[2] ?? message).slice(0, 1000),\n frames: e.filename ? [{ file: e.filename.slice(0, 500), line: e.lineno || undefined, col: e.colno || undefined }] : [],\n source: \"onerror\",\n handled: false,\n };\n}\n\n/** `unhandledrejection` → exception (`UnhandledRejection` for non-Error reasons). */\nexport function rejectionToException(e: PromiseRejectionEvent): ExceptionProperties {\n return exceptionFromError(e.reason, \"unhandledrejection\", false, \"UnhandledRejection\");\n}\n\nconst GUIDELY_SCRIPT = /\\/guidely(-recorder)?(\\.min)?\\.js$/i;\n\n/** Errors raised by Guidely itself (\"[Guidely] …\" messages, or thrown from the script-tag bundle). */\nexport function isGuidelyException(props: ExceptionProperties): boolean {\n if (props.message.startsWith(\"[Guidely]\")) return true;\n const file = props.frames[0]?.file;\n if (!file) return false;\n try {\n return GUIDELY_SCRIPT.test(new URL(file).pathname);\n } catch {\n return GUIDELY_SCRIPT.test(file.replace(/[?#].*$/, \"\"));\n }\n}\n\n/** Per-page-load throttle: the same exception (type + message + top frame) at most `max` times. */\nexport class ExceptionThrottle {\n private seen = new Map<string, number>();\n\n constructor(private readonly max = 5) {}\n\n allow(props: ExceptionProperties): boolean {\n const top = props.frames[0];\n const key = `${props.type}|${props.message}|${top ? `${top.file}:${top.line}:${top.col}` : \"\"}`;\n const n = this.seen.get(key) ?? 0;\n if (n >= this.max) return false;\n if (this.seen.size > 500) this.seen.clear();\n this.seen.set(key, n + 1);\n return true;\n }\n}\n","type AnyFn = (...args: any[]) => void;\n\n/** Tiny typed event emitter. Listener errors are reported, never thrown into the caller. */\nexport class Emitter<Events extends { [K in keyof Events]: AnyFn }> {\n private listeners = new Map<keyof Events, Set<AnyFn>>();\n constructor(private readonly onError?: (err: unknown) => void) {}\n\n on<K extends keyof Events>(event: K, cb: Events[K]): () => void {\n let set = this.listeners.get(event);\n if (!set) {\n set = new Set();\n this.listeners.set(event, set);\n }\n set.add(cb);\n return () => this.off(event, cb);\n }\n\n off<K extends keyof Events>(event: K, cb: Events[K]): void {\n this.listeners.get(event)?.delete(cb);\n }\n\n emit<K extends keyof Events>(event: K, ...args: Parameters<Events[K]>): void {\n const set = this.listeners.get(event);\n if (!set) return;\n for (const cb of Array.from(set)) {\n try {\n cb(...args);\n } catch (err) {\n this.onError?.(err);\n }\n }\n }\n\n clear(): void {\n this.listeners.clear();\n }\n}\n","import type { FrequencyConfig, PublishedGuide } from \"@guidelytech/shared\";\n\n/** Per-guide state kept locally and merged with the server's `IdentifyResponse.guideState`. */\nexport interface GuideLocalState {\n impressions: number;\n completedAt?: string | null;\n dismissedAt?: string | null;\n lastShownAt?: string | null;\n /** Last step reached in a multi-step flow (local only), so the messenger can offer to resume it. */\n lastStepId?: string | null;\n}\n\nconst HOUR = 3600 * 1000;\n\n/**\n * Pure frequency evaluation. `shownThisSession` comes from session storage.\n * - `once`: a single impression ever (unless `reshowAfterDismiss` and it was only dismissed).\n * - `once_per_session`: at most once per browser session.\n * - `every_time`: on every trigger (still blocked by completion/dismissal rules below).\n * - `interval`: at most once every `intervalHours`.\n * `maxImpressions` caps total impressions; dismissal blocks re-showing unless `reshowAfterDismiss`\n * (then `cooldownHours` must have elapsed); completion blocks unless mode is `every_time`.\n */\nexport function isFrequencyEligible(freq: FrequencyConfig, state: GuideLocalState | undefined, shownThisSession: boolean, now: number = Date.now()): boolean {\n const s = state ?? { impressions: 0 };\n if (freq.maxImpressions != null && s.impressions >= freq.maxImpressions) return false;\n if (s.completedAt && freq.mode !== \"every_time\") return false;\n if (s.dismissedAt) {\n if (!freq.reshowAfterDismiss) return false;\n if (freq.cooldownHours > 0 && now - Date.parse(s.dismissedAt) < freq.cooldownHours * HOUR) return false;\n }\n switch (freq.mode) {\n case \"once\":\n return s.impressions === 0 || (!!s.dismissedAt && freq.reshowAfterDismiss);\n case \"once_per_session\":\n return !shownThisSession;\n case \"interval\": {\n if (!s.lastShownAt) return true;\n const hours = freq.intervalHours ?? 24;\n return now - Date.parse(s.lastShownAt) >= hours * HOUR;\n }\n case \"every_time\":\n default:\n return true;\n }\n}\n\n/**\n * Exclusive guides (flows, modals, tooltips, announcements, surveys) run one at a time.\n * Banners, checklists and hotspot-only tooltips can coexist with an active flow.\n */\nexport function isExclusiveGuide(guide: PublishedGuide): boolean {\n if (guide.kind === \"banner\" || guide.kind === \"checklist\") return false;\n const steps = guide.config.steps;\n if (steps.length > 0 && steps.every((s) => s.type === \"hotspot\" || s.type === \"banner\")) return false;\n return true;\n}\n\n/** Is `a` mutually exclusive with `b` (by id or key, in either direction)? */\nexport function areMutuallyExclusive(a: PublishedGuide, b: PublishedGuide): boolean {\n const la = a.config.frequency.mutuallyExclusiveWith;\n const lb = b.config.frequency.mutuallyExclusiveWith;\n return la.includes(b.id) || la.includes(b.key) || lb.includes(a.id) || lb.includes(a.key);\n}\n\n/** Survey scheduling window. */\nexport function isWithinSchedule(guide: PublishedGuide, now: number = Date.now()): boolean {\n const s = guide.config.survey;\n if (!s) return true;\n if (s.startAt && now < Date.parse(s.startAt)) return false;\n if (s.endAt && now > Date.parse(s.endAt)) return false;\n return true;\n}\n","export interface ApiResponse<T> {\n status: number;\n ok: boolean;\n data: T | null;\n etag: string | null;\n}\n\nexport type FetchLike = typeof fetch;\n\n/** Thin HTTP client for the public SDK API. Adds the public key as query + header. */\nexport class Api {\n constructor(\n private readonly baseUrl: string,\n private readonly key: string,\n private readonly fetchImpl?: FetchLike,\n ) {}\n\n url(path: string, params: Record<string, string | undefined> = {}): string {\n // Built by hand rather than with URL/searchParams, which React Native does not implement.\n const query = Object.entries({ key: this.key, ...params })\n .filter((e): e is [string, string] => e[1] != null)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)\n .join(\"&\");\n return `${this.baseUrl.replace(/\\/$/, \"\")}/api/v1/sdk${path}?${query}`;\n }\n\n private get fetcher(): FetchLike | null {\n if (this.fetchImpl) return this.fetchImpl;\n return typeof fetch === \"function\" ? fetch.bind(globalThis) : null;\n }\n\n async request<T>(method: \"GET\" | \"POST\", path: string, options: { body?: unknown; etag?: string | null; params?: Record<string, string | undefined>; keepalive?: boolean; timeoutMs?: number; headers?: Record<string, string> } = {}): Promise<ApiResponse<T>> {\n const f = this.fetcher;\n if (!f) throw new Error(\"fetch is not available\");\n const headers: Record<string, string> = { ...options.headers, \"X-Guidely-Key\": this.key, Accept: \"application/json\" };\n // Multipart bodies set their own Content-Type (with the boundary).\n const form = typeof FormData !== \"undefined\" && options.body instanceof FormData;\n if (options.body !== undefined && !form) headers[\"Content-Type\"] = \"application/json\";\n if (options.etag) headers[\"If-None-Match\"] = options.etag;\n const ac = typeof AbortController !== \"undefined\" ? new AbortController() : null;\n const timer = ac ? setTimeout(() => ac.abort(), options.timeoutMs ?? 10000) : null;\n try {\n const res = await f(this.url(path, options.params), {\n method,\n headers,\n body: options.body === undefined ? undefined : form ? (options.body as FormData) : JSON.stringify(options.body),\n keepalive: options.keepalive,\n signal: ac?.signal,\n credentials: \"omit\",\n mode: \"cors\",\n });\n let data: T | null = null;\n if (res.status !== 304 && res.status !== 204) {\n try {\n data = (await res.json()) as T;\n } catch {\n data = null;\n }\n }\n return { status: res.status, ok: res.ok, data, etag: res.headers?.get?.(\"etag\") ?? null };\n } finally {\n if (timer) clearTimeout(timer);\n }\n }\n\n get<T>(path: string, options?: { etag?: string | null; params?: Record<string, string | undefined>; headers?: Record<string, string> }): Promise<ApiResponse<T>> {\n return this.request<T>(\"GET\", path, options);\n }\n\n post<T>(path: string, body: unknown, options?: { params?: Record<string, string | undefined>; keepalive?: boolean; headers?: Record<string, string> }): Promise<ApiResponse<T>> {\n return this.request<T>(\"POST\", path, { body, ...options });\n }\n\n /** Multipart POST (file uploads). No Content-Type header: the browser adds it with the boundary. */\n postForm<T>(path: string, form: FormData, options?: { params?: Record<string, string | undefined>; timeoutMs?: number }): Promise<ApiResponse<T>> {\n return this.request<T>(\"POST\", path, { body: form, ...options });\n }\n\n /**\n * POST that may answer with server-sent events. Each event is passed to `onEvent`; a JSON answer is\n * returned instead. No timeout: Scout replies can take a while and the server keeps the stream alive.\n */\n async stream<T>(path: string, body: unknown, onEvent: (event: string, data: unknown) => void, headers: Record<string, string> = {}): Promise<ApiResponse<T>> {\n const f = this.fetcher;\n if (!f) throw new Error(\"fetch is not available\");\n const res = await f(this.url(path), {\n method: \"POST\",\n headers: { ...headers, \"X-Guidely-Key\": this.key, Accept: \"text/event-stream, application/json\", \"Content-Type\": \"application/json\" },\n body: JSON.stringify(body),\n credentials: \"omit\",\n mode: \"cors\",\n });\n const type = res.headers?.get?.(\"content-type\") ?? \"\";\n if (!type.includes(\"text/event-stream\") || !res.body) {\n let data: T | null = null;\n try {\n data = (await res.json()) as T;\n } catch {\n data = null;\n }\n return { status: res.status, ok: res.ok, data, etag: null };\n }\n await readEventStream(res.body, onEvent);\n return { status: res.status, ok: res.ok, data: null, etag: null };\n }\n\n /** `navigator.sendBeacon` when available (page unload); returns false when it could not be queued. */\n beacon(path: string, body: unknown): boolean {\n try {\n if (typeof navigator === \"undefined\" || typeof navigator.sendBeacon !== \"function\") return false;\n // text/plain is a CORS-safelisted type: cross-origin beacons need no preflight (which\n // browsers drop during unload). The API parses the body regardless of content type.\n const blob = new Blob([JSON.stringify(body)], { type: \"text/plain;charset=UTF-8\" });\n return navigator.sendBeacon(this.url(path), blob);\n } catch {\n return false;\n }\n }\n}\n\nexport const sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));\n\n/** Exponential backoff helper: 1s → 2s → 4s … capped. */\nexport function backoffMs(attempt: number, baseMs = 1000, maxMs = 30000): number {\n return Math.min(maxMs, baseMs * 2 ** Math.max(0, attempt));\n}\n\n/**\n * Sends with bounded retries: network errors, 429 and 5xx are retried with backoff; success and\n * other 4xx answers are returned as they are. Null when every attempt failed.\n */\nexport async function withRetry<T>(send: () => Promise<ApiResponse<T>>, attempts = 3, baseMs = 500): Promise<ApiResponse<T> | null> {\n for (let i = 0; i < attempts; i++) {\n try {\n const res = await send();\n if (res.ok || (res.status >= 400 && res.status < 500 && res.status !== 429)) return res;\n } catch {\n /* network error → retry */\n }\n if (i < attempts - 1) await sleep(backoffMs(i, baseMs, 8000));\n }\n return null;\n}\n\n/** Fire-and-forget POST with bounded retries (used for state sync; never blocks UI). */\nexport function postWithRetry<T>(api: Api, path: string, body: unknown, attempts = 3, baseMs = 500): Promise<ApiResponse<T> | null> {\n return withRetry(() => api.post<T>(path, body), attempts, baseMs);\n}\n\n/** Parses a `text/event-stream` body (`event:` + single-line JSON `data:`; comment lines ignored). */\nexport async function readEventStream(body: ReadableStream<Uint8Array>, onEvent: (event: string, data: unknown) => void): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n const dispatch = (raw: string) => {\n let event = \"message\";\n const data: string[] = [];\n for (const line of raw.split(\"\\n\")) {\n if (!line || line.startsWith(\":\")) continue;\n const i = line.indexOf(\":\");\n const field = i < 0 ? line : line.slice(0, i);\n const value = i < 0 ? \"\" : line.slice(i + 1).replace(/^ /, \"\");\n if (field === \"event\") event = value;\n else if (field === \"data\") data.push(value);\n }\n if (!data.length) return;\n try {\n onEvent(event, JSON.parse(data.join(\"\\n\")));\n } catch {\n /* ignore malformed events */\n }\n };\n for (;;) {\n const { done, value } = await reader.read();\n if (value) buffer += decoder.decode(value, { stream: true }).replace(/\\r\\n?/g, \"\\n\");\n let sep: number;\n while ((sep = buffer.indexOf(\"\\n\\n\")) >= 0) {\n dispatch(buffer.slice(0, sep));\n buffer = buffer.slice(sep + 2);\n }\n if (done) break;\n }\n if (buffer.trim()) dispatch(buffer);\n}\n","import type {\n ConversationLookupResponse,\n ConversationMessagesResponse,\n MessengerConversation,\n MessengerPageContent,\n MessengerMessage,\n ResourceCenterArticle,\n SdkArticlesResponse,\n SdkHowTo,\n SdkHowTosResponse,\n StartConversationResponse,\n} from \"@guidelytech/shared\";\nimport type { MessengerApi, MessengerStreamHandlers } from \"@guidelytech/guide-runtime/messenger\";\nimport type { Api } from \"./http\";\nimport { KEYS, readJson, writeJson, type KeyValueStore } from \"./storage\";\n\ninterface StoredConversation {\n id: string;\n token: string;\n}\n\nconst MAX_STORED = 50;\nconst TOKEN_HEADER = \"X-Guidely-Conversation\";\n\nexport interface MessengerTransportOptions {\n api: Api;\n store: KeyValueStore;\n projectId: string;\n anonymousId: () => string;\n userId: () => string | null;\n /** Page URL to attach to messages (omitted when URL collection is off). */\n pageUrl: () => string | undefined;\n}\n\n/** The path of a page URL (plus a `#/` route), without origin or query: all how-to matching needs. */\nexport function pagePath(url: string | undefined): string | undefined {\n if (!url) return undefined;\n try {\n const u = new URL(url);\n return (u.pathname + (/^#!?\\//.test(u.hash) ? u.hash.split(\"?\")[0] : \"\")).slice(0, 2000);\n } catch {\n return undefined;\n }\n}\n\n/** Conversation tokens this browser holds (the only way to read a conversation). */\nexport function storedConversations(store: KeyValueStore, projectId: string): StoredConversation[] {\n const list = readJson<StoredConversation[]>(store, KEYS.conversations(projectId), []);\n return Array.isArray(list) ? list.filter((c) => c && typeof c.id === \"string\" && typeof c.token === \"string\") : [];\n}\n\nexport function forgetConversations(store: KeyValueStore, projectId: string) {\n store.remove(KEYS.conversations(projectId));\n}\n\nclass HttpError extends Error {\n constructor(readonly status: number) {\n super(`Request failed (${status})`);\n }\n}\n\n/** The messenger's server access over the public SDK API. */\nexport function createMessengerTransport(opts: MessengerTransportOptions): MessengerApi {\n const { api, store, projectId } = opts;\n const tokenFor = (id: string) => storedConversations(store, projectId).find((c) => c.id === id)?.token ?? \"\";\n const remember = (id: string, token: string) => {\n const rest = storedConversations(store, projectId).filter((c) => c.id !== id);\n writeJson(store, KEYS.conversations(projectId), [{ id, token }, ...rest].slice(0, MAX_STORED));\n };\n const forget = (id: string) => writeJson(store, KEYS.conversations(projectId), storedConversations(store, projectId).filter((c) => c.id !== id));\n\n /** Dispatches either SSE events or a JSON answer to the stream handlers. */\n async function exchange(path: string, body: unknown, headers: Record<string, string>, h: MessengerStreamHandlers, onStarted?: (r: StartConversationResponse) => void) {\n let finished = false;\n const res = await api.stream<StartConversationResponse | ConversationMessagesResponse>(\n path,\n body,\n (event, data) => {\n if (event === \"conversation\") {\n const d = data as StartConversationResponse;\n onStarted?.(d);\n h.onConversation?.(d.conversation);\n d.messages.forEach((m) => h.onMessage(m));\n } else if (event === \"message\") h.onMessage(data as MessengerMessage);\n else if (event === \"delta\") {\n const d = data as { messageId: string; text: string };\n h.onDelta(d.messageId, d.text);\n } else if (event === \"done\") {\n const d = data as { message: MessengerMessage | null; conversation: MessengerConversation };\n finished = true;\n h.onDone(d.message, d.conversation);\n } else if (event === \"error\") h.onError((data as { message?: string })?.message ?? \"Something went wrong\");\n },\n headers,\n );\n if (!res.ok) throw new HttpError(res.status);\n if (res.data) {\n // JSON answer (no Scout reply): the stored messages and the conversation.\n const d = res.data;\n if (\"token\" in d) {\n onStarted?.(d);\n h.onConversation?.(d.conversation);\n }\n d.messages.forEach((m) => h.onMessage(m));\n h.onDone(d.messages.at(-1) ?? null, d.conversation);\n } else if (!finished) h.onError(\"The reply was interrupted\");\n }\n\n return {\n async listConversations() {\n const tokens = storedConversations(store, projectId).map((c) => c.token);\n if (!tokens.length) return [];\n const res = await api.post<ConversationLookupResponse>(\"/conversations/lookup\", { tokens });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n // Drop tokens the server no longer knows (deleted by retention).\n const known = new Set(res.data.conversations.map((c) => c.id));\n for (const c of storedConversations(store, projectId)) if (!known.has(c.id)) forget(c.id);\n return res.data.conversations.map(({ token: _token, ...c }) => c);\n },\n async loadMessages(id, since) {\n const res = await api.get<ConversationMessagesResponse>(`/conversations/${encodeURIComponent(id)}/messages`, { params: { since: since ?? undefined }, headers: { [TOKEN_HEADER]: tokenFor(id) } });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n start(text, h) {\n return exchange(\"/conversations\", { anonymousId: opts.anonymousId(), userId: opts.userId(), message: text, pageUrl: opts.pageUrl() }, {}, h, (r) => remember(r.conversation.id, r.token));\n },\n send(id, text, h) {\n return exchange(`/conversations/${encodeURIComponent(id)}/messages`, { message: text, pageUrl: opts.pageUrl() }, { [TOKEN_HEADER]: tokenFor(id) }, h);\n },\n async handoff(id) {\n const res = await api.post<ConversationMessagesResponse>(`/conversations/${encodeURIComponent(id)}/handoff`, {}, { headers: { [TOKEN_HEADER]: tokenFor(id) } });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n async rate(id, rating) {\n const res = await api.post(`/conversations/${encodeURIComponent(id)}/rating`, { rating }, { headers: { [TOKEN_HEADER]: tokenFor(id) } });\n if (!res.ok) throw new HttpError(res.status);\n },\n async listArticles() {\n const res = await api.get<SdkArticlesResponse>(\"/articles\");\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n async getArticle(id) {\n const res = await api.get<{ article: ResourceCenterArticle }>(`/articles/${encodeURIComponent(id)}`);\n return res.ok && res.data ? res.data.article : null;\n },\n async pageContent(path) {\n // Only the path is sent (never the query or fragment) and nothing is stored: it picks what to suggest.\n const res = await api.post<MessengerPageContent>(\"/messenger/page\", { anonymousId: opts.anonymousId(), userId: opts.userId(), path: path.split(/[?#]/)[0] || \"/\" });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n async searchArticles(q) {\n const res = await api.get<{ articles: ResourceCenterArticle[] }>(\"/resource-center/search\", { params: { q } });\n return res.ok && res.data ? res.data.articles : [];\n },\n async listHowTos() {\n const res = await api.get<SdkHowTosResponse>(\"/how-tos\", { params: { url: pagePath(opts.pageUrl()) } });\n if (!res.ok || !res.data) throw new HttpError(res.status);\n return res.data;\n },\n async getHowTo(id) {\n const res = await api.get<{ howTo: SdkHowTo }>(`/how-tos/${encodeURIComponent(id)}`);\n return res.ok && res.data ? res.data.howTo : null;\n },\n };\n}\n","import type { PublishedGuide } from \"@guidelytech/shared\";\nimport { firstNameFromTraits } from \"@guidelytech/shared/runtime\";\nimport { urlMatches } from \"@guidelytech/guide-runtime\";\nimport type { MessengerChecklistProgress, MessengerNewsItem, MessengerResumeGuide, MessengerVisitor } from \"@guidelytech/guide-runtime/messenger\";\nimport { isWithinSchedule } from \"./frequency\";\nimport type { PersistedState } from \"./types\";\n\n/** Guide kinds the messenger offers to start for a page (announcements go to News instead). */\nconst PAGE_GUIDE_KINDS = new Set([\"flow\", \"tooltip\", \"modal\"]);\n/** URL patterns that match every page say nothing about a page. */\nconst CATCH_ALL = new Set([\"\", \"*\", \"**\", \"/*\", \"/**\", \"/\"]);\nconst RESUME_WITHIN_MS = 14 * 86_400_000;\nconst NEWS_WITHIN_MS = 90 * 86_400_000;\nconst MAX_NEWS = 10;\n\nexport interface VisitorInput {\n guides: PublishedGuide[];\n state: PersistedState;\n traits: Record<string, unknown> | undefined;\n /** `location.href`. */\n url: string;\n /** Full targeting for the current page (URL patterns, schedule, rules). */\n isTargeted: (guide: PublishedGuide) => boolean;\n /** Schedule and rules only: for content that isn't tied to the current page (news, progress). */\n isAudienceTargeted: (guide: PublishedGuide) => boolean;\n /** Announcement ids already seen in the News tab. */\n newsSeen: readonly string[];\n now?: number;\n}\n\nfunction pathOf(url: string): string | null {\n try {\n return new URL(url, \"http://x.invalid\").pathname || \"/\";\n } catch {\n return null;\n }\n}\n\n/** True when the guide names this page explicitly (URL patterns, a URL trigger, or its first step's page). */\nexport function targetsPage(guide: PublishedGuide, url: string): boolean {\n const c = guide.config;\n const checks: string[] = [...c.urlPatterns, ...(c.trigger.urlPattern ? [c.trigger.urlPattern] : []), ...(c.trigger.type === \"url_match\" && c.trigger.value ? [c.trigger.value] : []), ...(c.steps[0]?.url ? [c.steps[0].url] : [])];\n const specific = checks.filter((p) => !CATCH_ALL.has(p.trim()));\n // Every page reference must match (they are all requirements), and at least one must be specific.\n return specific.length > 0 && checks.every((p) => urlMatches(p, url));\n}\n\n/** Rich text from a guide step as plain text for a news card. */\nexport function plainText(html: string, max = 280): string {\n const text = html\n .replace(/<(br|\\/p|\\/div|\\/li|\\/h[1-6])\\s*\\/?>/gi, \" \")\n .replace(/<[^>]*>/g, \"\")\n .replace(/&nbsp;/g, \" \")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&amp;/g, \"&\")\n .replace(/\\s+/g, \" \")\n .trim();\n return text.length > max ? `${text.slice(0, max - 1).trimEnd()}…` : text;\n}\n\n/** Everything the messenger personalises from: name, page guides, progress and announcements. */\nexport function buildMessengerVisitor(input: VisitorInput): MessengerVisitor {\n const now = input.now ?? Date.now();\n const { guides, state } = input;\n const done = (g: PublishedGuide) => !!state.guides[g.id]?.completedAt;\n\n const pageGuides = guides\n .filter((g) => PAGE_GUIDE_KINDS.has(g.kind) && g.config.steps.length > 0 && !done(g) && targetsPage(g, input.url) && input.isTargeted(g))\n .slice(0, 3)\n .map((g) => ({ id: g.id, key: g.key, name: g.name, kind: g.kind }));\n\n let resumeGuide: MessengerResumeGuide | null = null;\n let resumeAt = 0;\n for (const g of guides) {\n const s = state.guides[g.id];\n if (g.kind !== \"flow\" || !s?.lastStepId || s.completedAt || g.config.steps.length < 2) continue;\n const at = Date.parse(s.lastShownAt ?? \"\");\n if (!Number.isFinite(at) || now - at > RESUME_WITHIN_MS || at <= resumeAt) continue;\n const stepIndex = g.config.steps.findIndex((st) => st.id === s.lastStepId);\n // Only once they got past the first step; the step must still exist in the live version. Auto-show\n // targeting (\"first visit\") doesn't apply: they already started it, and resuming starts it by hand.\n if (stepIndex < 1 || !isWithinSchedule(g)) continue;\n resumeGuide = { id: g.id, name: g.name, stepId: s.lastStepId, stepIndex, stepCount: g.config.steps.length };\n resumeAt = at;\n }\n\n let checklist: MessengerChecklistProgress | null = null;\n for (const g of guides) {\n const tasks = g.config.checklist?.tasks;\n if (g.kind !== \"checklist\" || !tasks?.length) continue;\n const p = state.checklists[g.id];\n if (p?.completedAt || p?.dismissedAt || !input.isAudienceTargeted(g)) continue;\n const completed = new Set(p?.completedTaskIds ?? []);\n const doneCount = tasks.filter((t) => completed.has(t.id)).length;\n if (doneCount >= tasks.length) continue;\n checklist = { id: g.id, name: g.name, done: doneCount, total: tasks.length, nextTask: tasks.find((t) => !completed.has(t.id))?.title ?? null };\n break;\n }\n\n const seen = new Set(input.newsSeen);\n const news: MessengerNewsItem[] = guides\n .filter((g) => g.kind === \"announcement\" && g.config.steps.length > 0 && now - Date.parse(g.publishedAt) <= NEWS_WITHIN_MS && input.isAudienceTargeted(g))\n .sort((a, b) => b.publishedAt.localeCompare(a.publishedAt))\n .slice(0, MAX_NEWS)\n .map((g) => {\n const step = g.config.steps[0]!;\n return {\n id: g.id,\n key: g.key,\n title: step.title || g.name,\n body: plainText(step.body ?? \"\"),\n imageUrl: step.imageUrl || null,\n publishedAt: g.publishedAt,\n // Read once opened in the News tab, or once the announcement itself was shown.\n unread: !seen.has(g.id) && !(state.guides[g.id]?.impressions ?? 0),\n };\n });\n\n return { firstName: firstNameFromTraits(input.traits), path: pathOf(input.url), pageGuides, resumeGuide, checklist, news };\n}\n","type Listener = (url: string) => void;\n\ninterface PatchedHistory extends History {\n __guidelyPatched?: { count: number; pushState: History[\"pushState\"]; replaceState: History[\"replaceState\"] };\n}\n\n/**\n * Detects SPA navigation: patches `history.pushState`/`replaceState` (reference counted, restored\n * on the last unwatch), listens to `popstate` and `hashchange`, and debounces into one callback.\n */\nexport function watchNavigation(listener: Listener, debounceMs = 50): () => void {\n if (typeof window === \"undefined\") return () => {};\n const win = window;\n const hist = win.history as PatchedHistory;\n let last = win.location.href;\n let timer: ReturnType<typeof setTimeout> | null = null;\n const check = () => {\n if (timer) clearTimeout(timer);\n timer = setTimeout(() => {\n timer = null;\n const href = win.location.href;\n if (href !== last) {\n last = href;\n listener(href);\n }\n }, debounceMs);\n };\n if (!hist.__guidelyPatched) {\n const pushState = hist.pushState;\n const replaceState = hist.replaceState;\n hist.__guidelyPatched = { count: 0, pushState, replaceState };\n hist.pushState = function (this: History, ...args: Parameters<History[\"pushState\"]>) {\n const r = pushState.apply(this, args);\n win.dispatchEvent(new Event(\"guidely:navigate\"));\n return r;\n };\n hist.replaceState = function (this: History, ...args: Parameters<History[\"replaceState\"]>) {\n const r = replaceState.apply(this, args);\n win.dispatchEvent(new Event(\"guidely:navigate\"));\n return r;\n };\n }\n hist.__guidelyPatched.count += 1;\n win.addEventListener(\"guidely:navigate\", check);\n win.addEventListener(\"popstate\", check);\n win.addEventListener(\"hashchange\", check);\n return () => {\n if (timer) clearTimeout(timer);\n win.removeEventListener(\"guidely:navigate\", check);\n win.removeEventListener(\"popstate\", check);\n win.removeEventListener(\"hashchange\", check);\n const p = hist.__guidelyPatched;\n if (p) {\n p.count -= 1;\n if (p.count <= 0) {\n hist.pushState = p.pushState;\n hist.replaceState = p.replaceState;\n delete hist.__guidelyPatched;\n }\n }\n };\n}\n","/** What `page_leave` reports for the page being left. */\nexport interface PageLeaveInfo {\n url: string;\n /** Time the page was visible (pauses while `document.hidden`). */\n durationMs: number;\n /** Furthest point scrolled to, as a percentage (0–100) of the page height. */\n scrollDepth: number;\n}\n\n/** Current scroll depth (0–100): the bottom of the viewport relative to the page height. */\nexport function scrollDepth(): number {\n const de = document.documentElement;\n const height = Math.max(de?.scrollHeight || 0, document.body?.scrollHeight || 0);\n const view = window.innerHeight || de?.clientHeight || 0;\n if (height <= 0 || height <= view) return 100;\n const y = window.scrollY || de?.scrollTop || 0;\n return Math.max(0, Math.min(100, Math.round(((y + view) / height) * 100)));\n}\n\n/** Tracks visible time and maximum scroll depth of the current page (for `page_leave`). */\nexport class PageTracker {\n url = \"\";\n private visibleMs = 0;\n private visibleSince: number | null = null;\n private maxScroll = 0;\n\n /** Starts measuring a new page. */\n start(url: string, now = Date.now()): void {\n this.url = url;\n this.visibleMs = 0;\n this.visibleSince = typeof document !== \"undefined\" && document.visibilityState === \"hidden\" ? null : now;\n this.maxScroll = 0;\n this.measureScroll();\n }\n\n /** Pauses / resumes the visible-time clock. */\n setHidden(hidden: boolean, now = Date.now()): void {\n if (hidden && this.visibleSince !== null) {\n this.visibleMs += Math.max(0, now - this.visibleSince);\n this.visibleSince = null;\n } else if (!hidden && this.visibleSince === null) this.visibleSince = now;\n }\n\n measureScroll(): void {\n try {\n this.maxScroll = Math.max(this.maxScroll, scrollDepth());\n } catch {\n /* no layout */\n }\n }\n\n /** Final numbers for the current page. */\n leave(now = Date.now()): PageLeaveInfo {\n this.measureScroll();\n const running = this.visibleSince !== null ? Math.max(0, now - this.visibleSince) : 0;\n return { url: this.url, durationMs: Math.round(this.visibleMs + running), scrollDepth: this.maxScroll };\n }\n}\n","import type { SdkEvent } from \"@guidelytech/shared\";\nimport { backoffMs } from \"./http\";\nimport { readJson, writeJson, type KeyValueStore } from \"./storage\";\n\nexport interface EventQueueOptions {\n store: KeyValueStore;\n storageKey: string;\n /** Sends one batch. Resolve `{ ok: true }` on success, `{ ok: false, retry }` otherwise. */\n send: (events: SdkEvent[]) => Promise<{ ok: boolean; retry?: boolean }>;\n /** Synchronous best-effort send used on page hide. */\n beacon?: (events: SdkEvent[]) => boolean;\n /** Should events be flushed right now? (analytics enabled + consent granted). */\n enabled: () => boolean;\n flushIntervalMs?: number;\n maxQueue?: number;\n batchSize?: number;\n maxAttempts?: number;\n onError?: (err: unknown) => void;\n}\n\n/**\n * Bounded, persisted event queue. Batches ≤50 events every 2s (or on demand), dedupes by\n * `eventId`, retries with exponential backoff (1s→30s, 5 attempts) and keeps failed events for\n * the next flush. Drops the oldest events once the queue exceeds 200.\n */\nexport class EventQueue {\n private events: SdkEvent[] = [];\n private timer: ReturnType<typeof setTimeout> | null = null;\n private retryTimer: ReturnType<typeof setTimeout> | null = null;\n private inflight = false;\n private inflightIds = new Set<string>();\n private attempt = 0;\n private destroyed = false;\n private readonly flushIntervalMs: number;\n private readonly maxQueue: number;\n private readonly batchSize: number;\n private readonly maxAttempts: number;\n\n constructor(private readonly opts: EventQueueOptions) {\n this.flushIntervalMs = opts.flushIntervalMs ?? 2000;\n this.maxQueue = opts.maxQueue ?? 200;\n this.batchSize = opts.batchSize ?? 50;\n this.maxAttempts = opts.maxAttempts ?? 5;\n const persisted = readJson<SdkEvent[]>(opts.store, opts.storageKey, []);\n if (Array.isArray(persisted)) this.events = persisted.filter((e) => e && typeof e.eventId === \"string\").slice(-this.maxQueue);\n // Events left over from a previous page load are flushed on the next tick.\n if (this.events.length) this.schedule();\n }\n\n get size(): number {\n return this.events.length;\n }\n\n /** Pending events (read-only copy, for debugging). */\n peek(): SdkEvent[] {\n return this.events.slice();\n }\n\n enqueue(event: SdkEvent): void {\n if (this.destroyed) return;\n if (this.events.some((e) => e.eventId === event.eventId)) return;\n this.events.push(event);\n if (this.events.length > this.maxQueue) this.events.splice(0, this.events.length - this.maxQueue);\n this.persist();\n this.schedule();\n }\n\n private persist(): void {\n writeJson(this.opts.store, this.opts.storageKey, this.events);\n }\n\n private schedule(): void {\n if (this.timer || this.retryTimer || this.destroyed) return;\n this.timer = setTimeout(() => {\n this.timer = null;\n void this.flush();\n }, this.flushIntervalMs);\n }\n\n /** Sends queued events now (one batch at a time). Safe to call at any time. */\n async flush(): Promise<void> {\n if (this.destroyed || this.inflight || !this.events.length || !this.opts.enabled()) return;\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n this.inflight = true;\n const batch = this.events.slice(0, this.batchSize);\n this.inflightIds = new Set(batch.map((e) => e.eventId));\n let ok = false;\n let retry = true;\n try {\n const res = await this.opts.send(batch);\n ok = res.ok;\n retry = res.retry ?? !res.ok;\n } catch (err) {\n this.opts.onError?.(err);\n }\n this.inflight = false;\n this.inflightIds.clear();\n if (this.destroyed) return;\n if (ok || !retry) {\n const ids = new Set(batch.map((e) => e.eventId));\n this.events = this.events.filter((e) => !ids.has(e.eventId));\n this.attempt = 0;\n this.persist();\n if (this.events.length) this.schedule();\n return;\n }\n this.attempt += 1;\n if (this.attempt >= this.maxAttempts) {\n // Give up for now; events stay queued until the next flush trigger (navigation, timer, unload).\n this.attempt = 0;\n return;\n }\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n void this.flush();\n }, backoffMs(this.attempt - 1));\n }\n\n /** Best-effort synchronous flush on unload using `sendBeacon`. */\n flushSync(): void {\n if (this.destroyed || !this.opts.enabled() || !this.opts.beacon) return;\n // Events already in flight (fetch with keepalive) survive unload; only beacon the rest to avoid duplicate batches.\n const batch = this.events.filter((e) => !this.inflightIds.has(e.eventId)).slice(0, this.batchSize);\n if (!batch.length) return;\n if (this.opts.beacon(batch)) {\n const ids = new Set(batch.map((e) => e.eventId));\n this.events = this.events.filter((e) => !ids.has(e.eventId));\n this.persist();\n }\n }\n\n clear(): void {\n this.events = [];\n this.persist();\n }\n\n destroy(): void {\n this.destroyed = true;\n if (this.timer) clearTimeout(this.timer);\n if (this.retryTimer) clearTimeout(this.retryTimer);\n this.timer = null;\n this.retryTimer = null;\n this.persist();\n }\n}\n","import type { RecorderApi } from \"./recorder-types\";\n\n/**\n * Loads the session-replay chunk on demand. The import is rewritten per build: `./recorder.js`\n * (npm; consumers' bundlers code-split it) or, in the script-tag build, a loader that injects\n * `guidely-recorder.js` and resolves `window.__guidelyRecorder` (`recorder` is a thenable there).\n */\nexport const loadRecorder = async (): Promise<RecorderApi> => (await import(\"./recorder\")).recorder;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,mBAAuH;AAavH,IAAAC,wBAaO;AACP,IAAAA,wBAA4B;;;AC1B5B,2BAA+J;;;ACExJ,IAAM,qBAAqB,IAAI,OAAO;AAE7C,IAAM,QAAQ;AAGd,SAAS,UAAU,OAAwD;AACzE,MAAI,CAAC,MAAO,QAAO;AACnB,MAAI;AACF,WAAO,MAAM,KAAK,MAAM,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,IAAI;AAAA,EAC/D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGA,SAAS,SAAS,MAAqB;AACrC,QAAM,SAAS,KAAK,cAAc,iBAAiB,MAAM,WAAW,SAAS;AAC7E,WAAS,IAAI,OAAO,SAAS,GAAG,GAAG,IAAI,OAAO,SAAS,GAAG;AACxD,MAAE,eAAe,EAAE,eAAe,IAAI,QAAQ,OAAO,QAAG;AAAA,EAC1D;AACF;AAQO,SAAS,gBAAgB,KAAe,eAAyB,WAAW,oBAAwC;AACzH,QAAM,MAAM,IAAI;AAChB,MAAI,CAAC,OAAO,CAAC,IAAI,gBAAiB,QAAO;AACzC,QAAM,QAAQ,IAAI,gBAAgB,UA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xC,YAAU;AACV,OAAK,OAAO,KAAK;AACjB,SAAO;AACT;;;AD7wDO,IAAM,UAAU;AAAA,EACrB,MAAM,CAAC,YAAsD,cAAc,KAAK,OAAO;AAAA,EACvF,KAAK,MAAM,cAAc,IAAI;AAAA,EAC7B;AAAA,EACA,SAAS;AACX;AAEA,IAAO,gBAAQ;","names":["import_runtime","import_guide_runtime","attr","import_runtime","import_guide_runtime","import_runtime","import_runtime","import_guide_runtime","pathOf","current"]}