@burdenoff/website-sdk 2026.824.2 → 2026.828.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.
Files changed (124) hide show
  1. package/README.md +88 -0
  2. package/dist/client/index.d.mts +2 -3
  3. package/dist/client/index.d.ts +2 -3
  4. package/dist/client/index.js +13 -7
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/client/index.mjs +13 -7
  7. package/dist/client/index.mjs.map +1 -1
  8. package/dist/components/contact.d.mts +2 -2
  9. package/dist/components/contact.d.ts +2 -2
  10. package/dist/components/contact.js +13 -7
  11. package/dist/components/contact.js.map +1 -1
  12. package/dist/components/contact.mjs +13 -7
  13. package/dist/components/contact.mjs.map +1 -1
  14. package/dist/components/electron-download.d.mts +2 -2
  15. package/dist/components/electron-download.d.ts +2 -2
  16. package/dist/components/explore-cta.d.mts +26 -0
  17. package/dist/components/explore-cta.d.ts +26 -0
  18. package/dist/components/explore-cta.js +95 -0
  19. package/dist/components/explore-cta.js.map +1 -0
  20. package/dist/components/explore-cta.mjs +93 -0
  21. package/dist/components/explore-cta.mjs.map +1 -0
  22. package/dist/components/explore.d.mts +43 -0
  23. package/dist/components/explore.d.ts +43 -0
  24. package/dist/components/explore.js +2219 -0
  25. package/dist/components/explore.js.map +1 -0
  26. package/dist/components/explore.mjs +2193 -0
  27. package/dist/components/explore.mjs.map +1 -0
  28. package/dist/components/launch-countdown.d.mts +2 -2
  29. package/dist/components/launch-countdown.d.ts +2 -2
  30. package/dist/components/newsletter.d.mts +3 -3
  31. package/dist/components/newsletter.d.ts +3 -3
  32. package/dist/components/newsletter.js +13 -7
  33. package/dist/components/newsletter.js.map +1 -1
  34. package/dist/components/newsletter.mjs +13 -7
  35. package/dist/components/newsletter.mjs.map +1 -1
  36. package/dist/components/partners.d.mts +2 -2
  37. package/dist/components/partners.d.ts +2 -2
  38. package/dist/components/partners.js +13 -7
  39. package/dist/components/partners.js.map +1 -1
  40. package/dist/components/partners.mjs +13 -7
  41. package/dist/components/partners.mjs.map +1 -1
  42. package/dist/components/pricing.d.mts +3 -3
  43. package/dist/components/pricing.d.ts +3 -3
  44. package/dist/components/pricing.js +13 -7
  45. package/dist/components/pricing.js.map +1 -1
  46. package/dist/components/pricing.mjs +13 -7
  47. package/dist/components/pricing.mjs.map +1 -1
  48. package/dist/components/problems-solved.d.mts +2 -2
  49. package/dist/components/problems-solved.d.ts +2 -2
  50. package/dist/components/resource-links.d.mts +2 -2
  51. package/dist/components/resource-links.d.ts +2 -2
  52. package/dist/components/resource-links.js +13 -7
  53. package/dist/components/resource-links.js.map +1 -1
  54. package/dist/components/resource-links.mjs +13 -7
  55. package/dist/components/resource-links.mjs.map +1 -1
  56. package/dist/components/social-links.d.mts +2 -2
  57. package/dist/components/social-links.d.ts +2 -2
  58. package/dist/components/social-links.js +13 -7
  59. package/dist/components/social-links.js.map +1 -1
  60. package/dist/components/social-links.mjs +13 -7
  61. package/dist/components/social-links.mjs.map +1 -1
  62. package/dist/components/unsubscribe.d.mts +2 -2
  63. package/dist/components/unsubscribe.d.ts +2 -2
  64. package/dist/components/unsubscribe.js +13 -7
  65. package/dist/components/unsubscribe.js.map +1 -1
  66. package/dist/components/unsubscribe.mjs +13 -7
  67. package/dist/components/unsubscribe.mjs.map +1 -1
  68. package/dist/components/waitlist.d.mts +3 -3
  69. package/dist/components/waitlist.d.ts +3 -3
  70. package/dist/components/waitlist.js +13 -7
  71. package/dist/components/waitlist.js.map +1 -1
  72. package/dist/components/waitlist.mjs +13 -7
  73. package/dist/components/waitlist.mjs.map +1 -1
  74. package/dist/components/website-switcher.d.mts +2 -2
  75. package/dist/components/website-switcher.d.ts +2 -2
  76. package/dist/content/index.d.mts +2 -3
  77. package/dist/content/index.d.ts +2 -3
  78. package/dist/content/index.js +13 -7
  79. package/dist/content/index.js.map +1 -1
  80. package/dist/content/index.mjs +13 -7
  81. package/dist/content/index.mjs.map +1 -1
  82. package/dist/{graphql-client-Cv6TO6hn.d.mts → graphql-client-BXn6RYV0.d.mts} +31 -4
  83. package/dist/{graphql-client-Cv6TO6hn.d.ts → graphql-client-BXn6RYV0.d.ts} +31 -4
  84. package/dist/hooks/index.d.mts +1 -0
  85. package/dist/hooks/index.d.ts +1 -0
  86. package/dist/hooks/index.js +1145 -0
  87. package/dist/hooks/index.js.map +1 -0
  88. package/dist/hooks/index.mjs +1140 -0
  89. package/dist/hooks/index.mjs.map +1 -0
  90. package/dist/{index-CFsUFxYo.d.ts → index-BXg7cQLm.d.ts} +11 -11
  91. package/dist/index-CUJTTlYx.d.mts +244 -0
  92. package/dist/index-CUJTTlYx.d.ts +244 -0
  93. package/dist/{index-CuMRiKGB.d.mts → index-DYxQiEm5.d.mts} +11 -11
  94. package/dist/index.d.mts +17 -15
  95. package/dist/index.d.ts +17 -15
  96. package/dist/index.js +1987 -426
  97. package/dist/index.js.map +1 -1
  98. package/dist/index.mjs +1977 -428
  99. package/dist/index.mjs.map +1 -1
  100. package/dist/product/index.d.mts +2 -2
  101. package/dist/product/index.d.ts +2 -2
  102. package/dist/product/index.js +13 -7
  103. package/dist/product/index.js.map +1 -1
  104. package/dist/product/index.mjs +13 -7
  105. package/dist/product/index.mjs.map +1 -1
  106. package/dist/{product-card-DL9O3Ez9.d.mts → product-card-CGxETsFa.d.mts} +7 -7
  107. package/dist/{product-card-DL9O3Ez9.d.ts → product-card-CGxETsFa.d.ts} +7 -7
  108. package/dist/{provider-D-Do5PmD.d.ts → provider-CUfI8meE.d.mts} +3 -3
  109. package/dist/{provider-BhsbxVPo.d.mts → provider-D_uUM7_e.d.ts} +3 -3
  110. package/dist/seo/index.d.mts +2 -2
  111. package/dist/seo/index.d.ts +2 -2
  112. package/dist/store/index.d.mts +3 -3
  113. package/dist/store/index.d.ts +3 -3
  114. package/dist/store/index.js +13 -7
  115. package/dist/store/index.js.map +1 -1
  116. package/dist/store/index.mjs +13 -7
  117. package/dist/store/index.mjs.map +1 -1
  118. package/dist/utils/index.d.mts +49 -1
  119. package/dist/utils/index.d.ts +49 -1
  120. package/dist/utils/index.js +70 -0
  121. package/dist/utils/index.js.map +1 -1
  122. package/dist/utils/index.mjs +68 -1
  123. package/dist/utils/index.mjs.map +1 -1
  124. package/package.json +40 -30
@@ -0,0 +1,2193 @@
1
+ import * as React from 'react';
2
+ import { createContext, useMemo, useState, useRef, useEffect, useCallback, useContext } from 'react';
3
+ import { Sparkles, RotateCcw, Square, ArrowUp, BookOpenText, Layers, Link2, TriangleAlert, ExternalLink } from 'lucide-react';
4
+ import ReactMarkdown from 'react-markdown';
5
+ import rehypeSanitize from 'rehype-sanitize';
6
+ import remarkGfm from 'remark-gfm';
7
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
+ import { Helmet } from 'react-helmet-async';
9
+ import { Slot } from '@radix-ui/react-slot';
10
+ import { cva } from 'class-variance-authority';
11
+ import { clsx } from 'clsx';
12
+ import { twMerge } from 'tailwind-merge';
13
+
14
+ var __defProp = Object.defineProperty;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
17
+ var defaultComponents = {
18
+ a: ({ href, children, ...props }) => {
19
+ const isExternal = typeof href === "string" && (href.startsWith("http://") || href.startsWith("https://"));
20
+ return /* @__PURE__ */ jsx(
21
+ "a",
22
+ {
23
+ href,
24
+ ...props,
25
+ ...isExternal ? { target: "_blank", rel: "noopener noreferrer" } : { rel: "noopener noreferrer" },
26
+ children
27
+ }
28
+ );
29
+ }
30
+ };
31
+ function Markdown({
32
+ children,
33
+ className,
34
+ inline,
35
+ components
36
+ }) {
37
+ const content = /* @__PURE__ */ jsx(
38
+ ReactMarkdown,
39
+ {
40
+ remarkPlugins: [remarkGfm],
41
+ rehypePlugins: [rehypeSanitize],
42
+ components: { ...defaultComponents, ...components },
43
+ ...inline ? { disallowedElements: ["p"], unwrapDisallowed: true } : {},
44
+ children
45
+ }
46
+ );
47
+ if (inline) {
48
+ return /* @__PURE__ */ jsx("span", { className, children: content });
49
+ }
50
+ return /* @__PURE__ */ jsx("div", { className, children: content });
51
+ }
52
+ var PROSE_CSS = `
53
+ .boff-prose {
54
+ max-width: none;
55
+ }
56
+
57
+ .boff-prose h1 {
58
+ font-size: 2.25rem;
59
+ font-weight: 800;
60
+ line-height: 1.2;
61
+ margin-top: 0;
62
+ margin-bottom: 1rem;
63
+ color: hsl(var(--foreground));
64
+ }
65
+
66
+ .boff-prose h2 {
67
+ font-size: 1.75rem;
68
+ font-weight: 700;
69
+ line-height: 1.3;
70
+ margin-top: 2rem;
71
+ margin-bottom: 1rem;
72
+ color: hsl(var(--foreground));
73
+ }
74
+
75
+ .boff-prose h3 {
76
+ font-size: 1.5rem;
77
+ font-weight: 600;
78
+ line-height: 1.4;
79
+ margin-top: 1.5rem;
80
+ margin-bottom: 0.75rem;
81
+ color: hsl(var(--foreground));
82
+ }
83
+
84
+ .boff-prose h4 {
85
+ font-size: 1.25rem;
86
+ font-weight: 600;
87
+ line-height: 1.5;
88
+ margin-top: 1.25rem;
89
+ margin-bottom: 0.5rem;
90
+ color: hsl(var(--foreground));
91
+ }
92
+
93
+ .boff-prose p {
94
+ margin-bottom: 1rem;
95
+ line-height: 1.75;
96
+ color: hsl(var(--foreground));
97
+ }
98
+
99
+ .boff-prose ul,
100
+ .boff-prose ol {
101
+ margin-bottom: 1rem;
102
+ padding-left: 1.5rem;
103
+ }
104
+
105
+ .boff-prose ul {
106
+ list-style-type: disc;
107
+ }
108
+
109
+ .boff-prose ol {
110
+ list-style-type: decimal;
111
+ }
112
+
113
+ .boff-prose li {
114
+ margin-bottom: 0.25rem;
115
+ line-height: 1.75;
116
+ color: hsl(var(--foreground));
117
+ }
118
+
119
+ .boff-prose li > ul,
120
+ .boff-prose li > ol {
121
+ margin-top: 0.25rem;
122
+ margin-bottom: 0.25rem;
123
+ }
124
+
125
+ .boff-prose a {
126
+ color: hsl(var(--primary));
127
+ text-decoration: underline;
128
+ text-underline-offset: 2px;
129
+ }
130
+
131
+ .boff-prose a:hover {
132
+ opacity: 0.8;
133
+ }
134
+
135
+ .boff-prose hr {
136
+ border: none;
137
+ height: 1px;
138
+ background-color: hsl(var(--border));
139
+ margin: 2rem 0;
140
+ }
141
+
142
+ .boff-prose blockquote {
143
+ border-left: 4px solid hsl(var(--border));
144
+ padding-left: 1rem;
145
+ margin: 1.5rem 0;
146
+ font-style: italic;
147
+ color: hsl(var(--muted-foreground));
148
+ }
149
+
150
+ .boff-prose strong {
151
+ font-weight: 700;
152
+ color: hsl(var(--foreground));
153
+ }
154
+
155
+ .boff-prose code {
156
+ background-color: hsl(var(--muted));
157
+ padding: 0.125rem 0.25rem;
158
+ border-radius: 0.25rem;
159
+ font-size: 0.875em;
160
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
161
+ }
162
+
163
+ .boff-prose pre {
164
+ background-color: hsl(var(--muted));
165
+ padding: 1rem;
166
+ border-radius: 0.5rem;
167
+ overflow-x: auto;
168
+ margin-bottom: 1rem;
169
+ }
170
+
171
+ .boff-prose pre code {
172
+ background-color: transparent;
173
+ padding: 0;
174
+ }
175
+
176
+ .boff-prose img {
177
+ max-width: 100%;
178
+ height: auto;
179
+ }
180
+
181
+ .boff-prose table {
182
+ width: 100%;
183
+ border-collapse: collapse;
184
+ margin-bottom: 1rem;
185
+ }
186
+
187
+ .boff-prose th,
188
+ .boff-prose td {
189
+ border: 1px solid hsl(var(--border));
190
+ padding: 0.5rem;
191
+ text-align: left;
192
+ }
193
+
194
+ .boff-prose th {
195
+ font-weight: 600;
196
+ background-color: hsl(var(--muted));
197
+ }
198
+
199
+ /* Smaller variant used inside cards and compact panels */
200
+ .boff-prose-sm {
201
+ font-size: 0.875rem;
202
+ }
203
+
204
+ .boff-prose-sm h1 {
205
+ font-size: 1.75rem;
206
+ }
207
+
208
+ .boff-prose-sm h2 {
209
+ font-size: 1.5rem;
210
+ }
211
+
212
+ .boff-prose-sm h3 {
213
+ font-size: 1.25rem;
214
+ }
215
+
216
+ .boff-prose-sm h4 {
217
+ font-size: 1.125rem;
218
+ }
219
+
220
+ .boff-prose-sm p,
221
+ .boff-prose-sm li {
222
+ line-height: 1.625;
223
+ }
224
+ `;
225
+ function ProseStyles() {
226
+ return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: PROSE_CSS } });
227
+ }
228
+
229
+ // src/client/security.ts
230
+ var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
231
+ var RESERVED_HEADERS = /* @__PURE__ */ new Set([
232
+ "authorization",
233
+ "cookie",
234
+ "x-actor-id",
235
+ "x-actor-type",
236
+ "x-consent-granted-by",
237
+ "x-consent-scope",
238
+ "x-consent-granted-at",
239
+ "x-consent-expires-at"
240
+ ]);
241
+ function validateGatewayUrl(value) {
242
+ let url;
243
+ try {
244
+ url = new URL(value);
245
+ } catch {
246
+ throw new Error("Gateway URL must be a valid absolute URL");
247
+ }
248
+ if (url.protocol === "https:") {
249
+ return url.toString();
250
+ }
251
+ if (url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname.toLowerCase())) {
252
+ return url.toString();
253
+ }
254
+ throw new Error("Gateway URL must use HTTPS unless it targets localhost");
255
+ }
256
+ function sanitizeHeaders(headers) {
257
+ if (!headers) return void 0;
258
+ return Object.fromEntries(
259
+ Object.entries(headers).filter(
260
+ ([key]) => !RESERVED_HEADERS.has(key.toLowerCase())
261
+ )
262
+ );
263
+ }
264
+
265
+ // src/client/graphql-client.ts
266
+ var _WebSDKClient = class _WebSDKClient {
267
+ constructor(config) {
268
+ __publicField(this, "config");
269
+ __publicField(this, "queryCache", /* @__PURE__ */ new Map());
270
+ __publicField(this, "inflight", /* @__PURE__ */ new Map());
271
+ this.config = {
272
+ ...config,
273
+ gatewayUrl: validateGatewayUrl(config.gatewayUrl),
274
+ headers: sanitizeHeaders(config.headers)
275
+ };
276
+ }
277
+ getConfig() {
278
+ return this.config;
279
+ }
280
+ /**
281
+ * Execute a GraphQL query (with deduplication and caching).
282
+ *
283
+ * Pass `{ cache: false }` to bypass the cache entirely — required for poll
284
+ * loops, where every tick must reach the network.
285
+ */
286
+ async query(query, variables, options) {
287
+ if (options?.cache === false) {
288
+ return this.request(query, variables, true, options.timeoutMs);
289
+ }
290
+ const cacheKey = JSON.stringify({ query, variables });
291
+ const cached = this.queryCache.get(cacheKey);
292
+ if (cached) {
293
+ if (Date.now() - cached.ts < _WebSDKClient.CACHE_TTL) {
294
+ return cached.data;
295
+ }
296
+ this.queryCache.delete(cacheKey);
297
+ }
298
+ const existing = this.inflight.get(cacheKey);
299
+ if (existing) {
300
+ return existing;
301
+ }
302
+ const promise = this.request(query, variables, true, options?.timeoutMs).then((result) => {
303
+ if (result.data && !result.errors?.length) {
304
+ if (this.queryCache.size >= _WebSDKClient.MAX_CACHE_ENTRIES) {
305
+ const oldestEntry = this.queryCache.keys().next().value;
306
+ if (oldestEntry) {
307
+ this.queryCache.delete(oldestEntry);
308
+ }
309
+ }
310
+ this.queryCache.set(cacheKey, { data: result, ts: Date.now() });
311
+ }
312
+ return result;
313
+ }).finally(() => {
314
+ this.inflight.delete(cacheKey);
315
+ });
316
+ this.inflight.set(cacheKey, promise);
317
+ return promise;
318
+ }
319
+ /**
320
+ * Execute a GraphQL mutation
321
+ */
322
+ async mutate(mutation, variables, options) {
323
+ return this.request(mutation, variables, false, options?.timeoutMs);
324
+ }
325
+ /** HTTP statuses worth another attempt — transient server/edge conditions. */
326
+ static isRetriableStatus(status) {
327
+ return status === 429 || status === 408 || status >= 500 && status < 600;
328
+ }
329
+ static sleep(ms) {
330
+ return new Promise((resolve) => setTimeout(resolve, ms));
331
+ }
332
+ /**
333
+ * Perform the HTTP call with a hard timeout. Every outcome resolves to a
334
+ * GraphQLResponse — callers never hang, so a UI's `loading` state always
335
+ * settles into data or a renderable error.
336
+ */
337
+ async attempt(query, variables, timeoutMs) {
338
+ const controller = new AbortController();
339
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
340
+ try {
341
+ const response = await fetch(this.config.gatewayUrl, {
342
+ method: "POST",
343
+ headers: {
344
+ "Content-Type": "application/json",
345
+ "x-product-id": this.config.productId,
346
+ ...this.config.headers
347
+ },
348
+ body: JSON.stringify({ query, variables }),
349
+ signal: controller.signal
350
+ });
351
+ if (!response.ok) {
352
+ console.error(
353
+ "[WebSDK] GraphQL request failed",
354
+ response.status,
355
+ response.statusText
356
+ );
357
+ return {
358
+ res: {
359
+ errors: [
360
+ {
361
+ message: `HTTP ${response.status}: ${response.statusText}`,
362
+ extensions: { code: `HTTP_${response.status}` }
363
+ }
364
+ ]
365
+ },
366
+ retriable: _WebSDKClient.isRetriableStatus(response.status)
367
+ };
368
+ }
369
+ return {
370
+ res: await response.json(),
371
+ retriable: false
372
+ };
373
+ } catch (error) {
374
+ const aborted = error instanceof Error && (error.name === "AbortError" || controller.signal.aborted);
375
+ const message = aborted ? `Request timed out after ${timeoutMs}ms` : error instanceof Error ? error.message : "Network error";
376
+ console.error("[WebSDK] Network error", message);
377
+ return {
378
+ res: {
379
+ errors: [
380
+ {
381
+ message,
382
+ extensions: { code: aborted ? "TIMEOUT" : "NETWORK_ERROR" }
383
+ }
384
+ ]
385
+ },
386
+ // Transport-level failures are worth one more try; a genuine outage
387
+ // just fails twice quickly and still renders an error state.
388
+ retriable: true
389
+ };
390
+ } finally {
391
+ clearTimeout(timer);
392
+ }
393
+ }
394
+ async request(query, variables, retry = true, timeoutOverrideMs) {
395
+ const timeoutMs = timeoutOverrideMs ?? this.config.timeoutMs ?? _WebSDKClient.DEFAULT_TIMEOUT_MS;
396
+ const maxRetries = retry ? this.config.maxRetries ?? _WebSDKClient.DEFAULT_MAX_RETRIES : 0;
397
+ let last;
398
+ for (let i = 0; i <= maxRetries; i++) {
399
+ const { res, retriable } = await this.attempt(
400
+ query,
401
+ variables,
402
+ timeoutMs
403
+ );
404
+ if (!retriable || i === maxRetries) return res;
405
+ last = res;
406
+ await _WebSDKClient.sleep(
407
+ _WebSDKClient.RETRY_BASE_DELAY_MS * (i + 1) + Math.random() * 200
408
+ );
409
+ }
410
+ return last;
411
+ }
412
+ };
413
+ __publicField(_WebSDKClient, "CACHE_TTL", 5 * 60 * 1e3);
414
+ // 5 minutes
415
+ __publicField(_WebSDKClient, "MAX_CACHE_ENTRIES", 100);
416
+ __publicField(_WebSDKClient, "DEFAULT_TIMEOUT_MS", 12e3);
417
+ __publicField(_WebSDKClient, "DEFAULT_MAX_RETRIES", 1);
418
+ __publicField(_WebSDKClient, "RETRY_BASE_DELAY_MS", 400);
419
+ var WebSDKContext = createContext(null);
420
+ function useWebSDK() {
421
+ const client = useContext(WebSDKContext);
422
+ if (!client) {
423
+ throw new Error("useWebSDK must be used within a WebSDKProvider");
424
+ }
425
+ return client;
426
+ }
427
+
428
+ // src/components/explore-types.ts
429
+ var EXPLORE_MESSAGE_FIELDS = (
430
+ /* GraphQL */
431
+ `
432
+ id
433
+ conversationId
434
+ role
435
+ status
436
+ content
437
+ partialContent
438
+ activity
439
+ references {
440
+ url
441
+ title
442
+ description
443
+ product
444
+ imageUrl
445
+ }
446
+ ctas {
447
+ kind
448
+ label
449
+ url
450
+ product
451
+ }
452
+ errorCode
453
+ createdAt
454
+ completedAt
455
+ `
456
+ );
457
+ var EXPLORE_CATALOG_QUERY = (
458
+ /* GraphQL */
459
+ `
460
+ query ExploreCatalog($productSlug: String) {
461
+ exploreCatalog(productSlug: $productSlug) {
462
+ enabled
463
+ products {
464
+ slug
465
+ name
466
+ tagline
467
+ website
468
+ }
469
+ examplePrompts
470
+ welcomeTitle
471
+ welcomeBody
472
+ limits {
473
+ maxMessageLength
474
+ maxTurnsPerConversation
475
+ messagesPerDay
476
+ historyTurns
477
+ }
478
+ captchaRequired
479
+ recaptchaSiteKey
480
+ }
481
+ }
482
+ `
483
+ );
484
+ var EXPLORE_MESSAGE_QUERY = (
485
+ /* GraphQL */
486
+ `
487
+ query ExploreMessage($conversationToken: String!, $id: ID!) {
488
+ exploreMessage(conversationToken: $conversationToken, id: $id) {
489
+ ${EXPLORE_MESSAGE_FIELDS}
490
+ }
491
+ }
492
+ `
493
+ );
494
+ var SEND_EXPLORE_MESSAGE_MUTATION = (
495
+ /* GraphQL */
496
+ `
497
+ mutation SendExploreMessage($input: SendExploreMessageInput!) {
498
+ sendExploreMessage(input: $input) {
499
+ conversation {
500
+ id
501
+ token
502
+ productSlug
503
+ turnCount
504
+ createdAt
505
+ }
506
+ userMessage {
507
+ ${EXPLORE_MESSAGE_FIELDS}
508
+ }
509
+ assistantMessage {
510
+ ${EXPLORE_MESSAGE_FIELDS}
511
+ }
512
+ remainingToday
513
+ }
514
+ }
515
+ `
516
+ );
517
+
518
+ // src/data/products.ts
519
+ var ECOSYSTEM_PRODUCTS = [
520
+ {
521
+ slug: "workspaces",
522
+ name: "Workspaces",
523
+ websiteUrl: "https://burdenoff.com"
524
+ },
525
+ {
526
+ slug: "vibecontrols",
527
+ name: "VibeControls",
528
+ websiteUrl: "https://vibecontrols.com"
529
+ },
530
+ {
531
+ slug: "fluidgrids",
532
+ name: "FluidGrids",
533
+ websiteUrl: "https://fluidgrids.com"
534
+ },
535
+ // Botlit ships on botlit.ai — botlit.com does not resolve.
536
+ { slug: "botlit", name: "Botlit", websiteUrl: "https://www.botlit.ai" },
537
+ {
538
+ slug: "bigconsole",
539
+ name: "BigConsole",
540
+ websiteUrl: "https://bigconsole.com"
541
+ },
542
+ {
543
+ slug: "semanticfed",
544
+ name: "SemanticFed",
545
+ websiteUrl: "https://semanticfed.com"
546
+ },
547
+ {
548
+ slug: "intelwatchtower",
549
+ name: "IntelWatchtower",
550
+ websiteUrl: "https://intelwatchtower.com"
551
+ },
552
+ { slug: "buildmyiq", name: "BuildMyIQ", websiteUrl: "https://buildmyiq.com" },
553
+ {
554
+ slug: "assethandler",
555
+ name: "AssetHandler",
556
+ websiteUrl: "https://assethandler.com"
557
+ },
558
+ {
559
+ slug: "crewfoundry",
560
+ name: "CrewFoundry",
561
+ websiteUrl: "https://crewfoundry.com"
562
+ },
563
+ {
564
+ slug: "planmagnet",
565
+ name: "PlanMagnet",
566
+ websiteUrl: "https://planmagnet.com"
567
+ },
568
+ {
569
+ slug: "eventfullymanaged",
570
+ name: "EventfullyManaged",
571
+ websiteUrl: "https://eventfullymanaged.com"
572
+ },
573
+ {
574
+ slug: "headshotmarketing",
575
+ name: "HeadshotMarketing",
576
+ websiteUrl: "https://headshotmarketing.com"
577
+ },
578
+ {
579
+ slug: "technospam",
580
+ name: "TechnoSpam",
581
+ websiteUrl: "https://technospam.com"
582
+ },
583
+ { slug: "kadaikodi", name: "Kadaikodi", websiteUrl: "https://kadaikodi.com" },
584
+ {
585
+ slug: "movethewheels",
586
+ name: "MoveTheWheels",
587
+ websiteUrl: "https://movethewheels.com"
588
+ },
589
+ {
590
+ slug: "healthybowl",
591
+ name: "Healthy Bowl",
592
+ websiteUrl: "https://gethealthybowl.com"
593
+ },
594
+ { slug: "ggnomad", name: "GGNomad", websiteUrl: "https://ggnomad.com" },
595
+ {
596
+ slug: "timecampus",
597
+ name: "TimeCampus",
598
+ websiteUrl: "https://timecampus.com"
599
+ },
600
+ {
601
+ slug: "manufacturedops",
602
+ name: "ManufacturedOps",
603
+ websiteUrl: "https://manufacturedops.com"
604
+ },
605
+ {
606
+ slug: "theglobalfuel",
607
+ name: "TheGlobalFuel",
608
+ websiteUrl: "https://theglobalfuel.com"
609
+ },
610
+ {
611
+ slug: "housingvista",
612
+ name: "HousingVista",
613
+ websiteUrl: "https://housingvista.com"
614
+ },
615
+ {
616
+ slug: "proserviceworld",
617
+ name: "ProServiceWorld",
618
+ websiteUrl: "https://proserviceworld.com"
619
+ },
620
+ {
621
+ slug: "mybodyshield",
622
+ name: "MyBodyShield",
623
+ websiteUrl: "https://mybodyshield.com"
624
+ },
625
+ {
626
+ slug: "artistrybase",
627
+ name: "ArtistryBase",
628
+ websiteUrl: "https://artistrybase.com"
629
+ },
630
+ {
631
+ slug: "theculturepost",
632
+ name: "TheCulturePost",
633
+ websiteUrl: "https://theculturepost.com"
634
+ },
635
+ { slug: "collabkin", name: "CollabKin", websiteUrl: "https://collabkin.com" },
636
+ {
637
+ slug: "comradecircle",
638
+ name: "ComradeCircle",
639
+ websiteUrl: "https://comradecircle.com"
640
+ },
641
+ {
642
+ slug: "brainyrich",
643
+ name: "BrainyRich",
644
+ websiteUrl: "https://brainyrich.com"
645
+ },
646
+ {
647
+ slug: "cosmicintersection",
648
+ name: "CosmicIntersection",
649
+ websiteUrl: "https://cosmicintersection.com"
650
+ },
651
+ {
652
+ slug: "govcitizenhub",
653
+ name: "GovCitizenHub",
654
+ websiteUrl: "https://govcitizenhub.com"
655
+ },
656
+ {
657
+ slug: "adaptercloud",
658
+ name: "AdapterCloud",
659
+ websiteUrl: "https://adaptercloud.com"
660
+ },
661
+ {
662
+ slug: "subscriberbot",
663
+ name: "Subscriber Bot",
664
+ websiteUrl: "https://subscriberbot.com"
665
+ },
666
+ {
667
+ slug: "hookmovies",
668
+ name: "HookMovies",
669
+ websiteUrl: "https://hookmovies.com"
670
+ },
671
+ {
672
+ slug: "coolandlovely",
673
+ name: "CoolAndLovely",
674
+ websiteUrl: "https://coolandlovely.com"
675
+ },
676
+ {
677
+ slug: "atheletebridge",
678
+ name: "AthleteBridge",
679
+ websiteUrl: "https://atheletebridge.com"
680
+ },
681
+ {
682
+ slug: "labsofscience",
683
+ name: "LabsOfScience",
684
+ websiteUrl: "https://labsofscience.com"
685
+ },
686
+ {
687
+ slug: "ecoimpacthub",
688
+ name: "EcoImpactHub",
689
+ websiteUrl: "https://ecoimpacthub.com"
690
+ }
691
+ ];
692
+
693
+ // src/utils/recaptcha-v3.ts
694
+ var SCRIPT_ID = "boff-recaptcha-v3";
695
+ var SCRIPT_SRC = "https://www.google.com/recaptcha/api.js?render=";
696
+ var EXPLORE_RECAPTCHA_ACTION = "explore_chat";
697
+ var loaders = /* @__PURE__ */ new Map();
698
+ function isBrowser() {
699
+ return typeof window !== "undefined" && typeof document !== "undefined";
700
+ }
701
+ function loadRecaptchaV3(siteKey) {
702
+ if (!siteKey) {
703
+ return Promise.reject(new Error("reCAPTCHA site key is required"));
704
+ }
705
+ if (!isBrowser()) {
706
+ return Promise.reject(
707
+ new Error("reCAPTCHA v3 can only be loaded in a browser")
708
+ );
709
+ }
710
+ const existing = loaders.get(siteKey);
711
+ if (existing) return existing;
712
+ const promise = new Promise((resolve, reject) => {
713
+ const ready = () => {
714
+ const api = window.grecaptcha;
715
+ if (!api) {
716
+ reject(new Error("reCAPTCHA loaded but grecaptcha is unavailable"));
717
+ return;
718
+ }
719
+ api.ready(() => resolve(api));
720
+ };
721
+ if (window.grecaptcha) {
722
+ ready();
723
+ return;
724
+ }
725
+ const scriptId = `${SCRIPT_ID}-${siteKey}`;
726
+ const found = document.getElementById(scriptId);
727
+ if (found) {
728
+ found.addEventListener("load", ready, { once: true });
729
+ found.addEventListener(
730
+ "error",
731
+ () => reject(new Error("Failed to load reCAPTCHA v3")),
732
+ { once: true }
733
+ );
734
+ return;
735
+ }
736
+ const script = document.createElement("script");
737
+ script.id = scriptId;
738
+ script.src = `${SCRIPT_SRC}${encodeURIComponent(siteKey)}`;
739
+ script.async = true;
740
+ script.defer = true;
741
+ script.addEventListener("load", ready, { once: true });
742
+ script.addEventListener(
743
+ "error",
744
+ () => {
745
+ loaders.delete(siteKey);
746
+ reject(new Error("Failed to load reCAPTCHA v3"));
747
+ },
748
+ { once: true }
749
+ );
750
+ document.head.appendChild(script);
751
+ });
752
+ loaders.set(siteKey, promise);
753
+ return promise;
754
+ }
755
+ async function getRecaptchaV3Token(siteKey, action = EXPLORE_RECAPTCHA_ACTION) {
756
+ const api = await loadRecaptchaV3(siteKey);
757
+ return api.execute(siteKey, { action });
758
+ }
759
+
760
+ // src/hooks/use-explore-chat.ts
761
+ var DEFAULT_STORAGE_KEY = "boff.explore.v1";
762
+ var DEFAULT_POLL_INTERVAL_MS = 1500;
763
+ var DEFAULT_POLL_TIMEOUT_MS = 9e4;
764
+ var POLL_REQUEST_TIMEOUT_MS = 1e4;
765
+ var SEND_REQUEST_TIMEOUT_MS = 18e3;
766
+ var MAX_CONSECUTIVE_POLL_FAILURES = 4;
767
+ var MAX_PERSISTED_MESSAGES = 40;
768
+ var FALLBACK_EXPLORE_LIMITS = {
769
+ maxMessageLength: 2e3,
770
+ maxTurnsPerConversation: 20,
771
+ messagesPerDay: 100,
772
+ historyTurns: 6
773
+ };
774
+ var DEFAULT_EXPLORE_EXAMPLE_PROMPTS = [
775
+ "What does this product actually do?",
776
+ "Which Burdenoff product fits my team?",
777
+ "How do I get started, step by step?",
778
+ "What does it integrate with?"
779
+ ];
780
+ var FALLBACK_WELCOME_TITLE = "Ask anything about our products";
781
+ var FALLBACK_WELCOME_BODY = "Get straight answers drawn from our product documentation and public pages \u2014 with links back to the exact page each answer came from.";
782
+ function buildFallbackCatalog(examplePrompts) {
783
+ return {
784
+ enabled: true,
785
+ products: ECOSYSTEM_PRODUCTS.map((p) => ({
786
+ slug: p.slug,
787
+ name: p.name,
788
+ tagline: null,
789
+ website: p.websiteUrl
790
+ })),
791
+ examplePrompts: examplePrompts?.length ? examplePrompts : DEFAULT_EXPLORE_EXAMPLE_PROMPTS,
792
+ welcomeTitle: FALLBACK_WELCOME_TITLE,
793
+ welcomeBody: FALLBACK_WELCOME_BODY,
794
+ limits: FALLBACK_EXPLORE_LIMITS,
795
+ captchaRequired: false,
796
+ recaptchaSiteKey: null
797
+ };
798
+ }
799
+ function normalizeCatalog(raw, fallback) {
800
+ return {
801
+ enabled: raw.enabled !== false,
802
+ products: raw.products?.length ? raw.products : fallback.products,
803
+ examplePrompts: raw.examplePrompts?.length ? raw.examplePrompts : fallback.examplePrompts,
804
+ welcomeTitle: raw.welcomeTitle || fallback.welcomeTitle,
805
+ welcomeBody: raw.welcomeBody || fallback.welcomeBody,
806
+ limits: {
807
+ maxMessageLength: raw.limits?.maxMessageLength || fallback.limits.maxMessageLength,
808
+ maxTurnsPerConversation: raw.limits?.maxTurnsPerConversation || fallback.limits.maxTurnsPerConversation,
809
+ messagesPerDay: raw.limits?.messagesPerDay || fallback.limits.messagesPerDay,
810
+ historyTurns: raw.limits?.historyTurns || fallback.limits.historyTurns
811
+ },
812
+ captchaRequired: raw.captchaRequired === true,
813
+ recaptchaSiteKey: raw.recaptchaSiteKey ?? null
814
+ };
815
+ }
816
+ var RATE_LIMIT_CODES = /* @__PURE__ */ new Set([
817
+ "RATE_LIMITED",
818
+ "HTTP_429",
819
+ "EXPLORE_GLOBAL_LIMIT"
820
+ ]);
821
+ var CAPTCHA_CODES = /* @__PURE__ */ new Set(["CAPTCHA_FAILED", "CAPTCHA_REQUIRED"]);
822
+ var NETWORK_CODES = /* @__PURE__ */ new Set([
823
+ "NETWORK_ERROR",
824
+ "UPSTREAM_UNAVAILABLE",
825
+ "CONVERSATION_BUSY",
826
+ "PROVIDER_ERROR",
827
+ "QUEUE_FULL"
828
+ ]);
829
+ var VALIDATION_CODES = /* @__PURE__ */ new Set([
830
+ "MESSAGE_TOO_LONG",
831
+ "MESSAGE_EMPTY",
832
+ "CONVERSATION_LIMIT",
833
+ "INVALID_INPUT"
834
+ ]);
835
+ function classifyExploreError(code, serverMessage) {
836
+ const c = code ?? "UNKNOWN";
837
+ if (RATE_LIMIT_CODES.has(c)) {
838
+ return {
839
+ kind: "rate-limit",
840
+ code: c,
841
+ message: "You've reached the message limit for now. Please try again later.",
842
+ retryable: false
843
+ };
844
+ }
845
+ if (CAPTCHA_CODES.has(c)) {
846
+ return {
847
+ kind: "captcha",
848
+ code: c,
849
+ message: "We couldn't verify that you're human. Please try sending that again.",
850
+ retryable: true
851
+ };
852
+ }
853
+ if (c === "TIMEOUT" || c === "TOOL_BUDGET") {
854
+ return {
855
+ kind: "timeout",
856
+ code: c,
857
+ message: "That answer took too long to come back. Try asking again.",
858
+ retryable: true
859
+ };
860
+ }
861
+ if (NETWORK_CODES.has(c)) {
862
+ return {
863
+ kind: "network",
864
+ code: c,
865
+ message: "We couldn't reach the assistant just now. Check your connection and try again.",
866
+ retryable: true
867
+ };
868
+ }
869
+ if (c === "EXPLORE_DISABLED") {
870
+ return {
871
+ kind: "disabled",
872
+ code: c,
873
+ message: "Explore is unavailable at the moment. Please check back soon.",
874
+ retryable: false
875
+ };
876
+ }
877
+ if (VALIDATION_CODES.has(c)) {
878
+ return {
879
+ kind: "validation",
880
+ code: c,
881
+ message: serverMessage || "That message couldn't be sent.",
882
+ retryable: false
883
+ };
884
+ }
885
+ if (c === "EMPTY_ANSWER") {
886
+ return {
887
+ kind: "unknown",
888
+ code: c,
889
+ message: "No answer came back for that one. Try rephrasing, or ask something more specific.",
890
+ retryable: true
891
+ };
892
+ }
893
+ return {
894
+ kind: "unknown",
895
+ code: c,
896
+ message: serverMessage || "Something went wrong. Please try again.",
897
+ retryable: true
898
+ };
899
+ }
900
+ function readPersisted(key) {
901
+ if (typeof window === "undefined") return null;
902
+ try {
903
+ const raw = window.sessionStorage.getItem(key);
904
+ if (!raw) return null;
905
+ const parsed = JSON.parse(raw);
906
+ if (!parsed || typeof parsed !== "object") return null;
907
+ const record = parsed;
908
+ return {
909
+ conversationToken: typeof record.conversationToken === "string" ? record.conversationToken : null,
910
+ messages: Array.isArray(record.messages) ? record.messages.slice(-MAX_PERSISTED_MESSAGES) : [],
911
+ focusProduct: typeof record.focusProduct === "string" ? record.focusProduct : null
912
+ };
913
+ } catch {
914
+ return null;
915
+ }
916
+ }
917
+ function visibleText(message) {
918
+ return message.content || message.partialContent || "";
919
+ }
920
+ function countUserTurns(messages) {
921
+ return messages.filter((m) => m.role === "USER").length;
922
+ }
923
+ function useExploreChat(options = {}) {
924
+ const {
925
+ productSlug,
926
+ pageUrl,
927
+ locale,
928
+ examplePrompts,
929
+ pollIntervalMs = DEFAULT_POLL_INTERVAL_MS,
930
+ pollTimeoutMs = DEFAULT_POLL_TIMEOUT_MS,
931
+ storageKey = DEFAULT_STORAGE_KEY,
932
+ persist = true,
933
+ onSend
934
+ } = options;
935
+ const client = useWebSDK();
936
+ const promptKey = JSON.stringify(examplePrompts ?? []);
937
+ const fallbackCatalog = useMemo(
938
+ () => buildFallbackCatalog(JSON.parse(promptKey)),
939
+ [promptKey]
940
+ );
941
+ const [catalog, setCatalog] = useState(fallbackCatalog);
942
+ const [messages, setMessages] = useState([]);
943
+ const [phase, setPhase] = useState("loading");
944
+ const [error, setError] = useState(null);
945
+ const [remainingToday, setRemainingToday] = useState(null);
946
+ const [focusProduct, setFocusProductState] = useState(null);
947
+ const [turnCount, setTurnCount] = useState(0);
948
+ const [hydrated, setHydrated] = useState(false);
949
+ const mountedRef = useRef(true);
950
+ const pollGenerationRef = useRef(0);
951
+ const pollTimerRef = useRef(null);
952
+ const conversationTokenRef = useRef(null);
953
+ const catalogRef = useRef(fallbackCatalog);
954
+ const turnCountRef = useRef(0);
955
+ const focusProductRef = useRef(null);
956
+ const lastSentTextRef = useRef(null);
957
+ const inFlightRef = useRef(false);
958
+ catalogRef.current = catalog;
959
+ const clearPollTimer = useCallback(() => {
960
+ if (pollTimerRef.current !== null) {
961
+ clearTimeout(pollTimerRef.current);
962
+ pollTimerRef.current = null;
963
+ }
964
+ }, []);
965
+ const cancelPolling = useCallback(() => {
966
+ pollGenerationRef.current += 1;
967
+ clearPollTimer();
968
+ }, [clearPollTimer]);
969
+ useEffect(() => {
970
+ mountedRef.current = true;
971
+ return () => {
972
+ mountedRef.current = false;
973
+ pollGenerationRef.current += 1;
974
+ if (pollTimerRef.current !== null) {
975
+ clearTimeout(pollTimerRef.current);
976
+ pollTimerRef.current = null;
977
+ }
978
+ };
979
+ }, []);
980
+ useEffect(() => {
981
+ if (!persist) {
982
+ setHydrated(true);
983
+ return;
984
+ }
985
+ const stored = readPersisted(storageKey);
986
+ if (stored) {
987
+ conversationTokenRef.current = stored.conversationToken;
988
+ focusProductRef.current = stored.focusProduct;
989
+ const settled = stored.messages.flatMap((m) => {
990
+ if (m.role !== "ASSISTANT") return [m];
991
+ if (m.status !== "PENDING" && m.status !== "RUNNING") return [m];
992
+ const text = visibleText(m);
993
+ if (!text) return [];
994
+ return [{ ...m, status: "COMPLETED", content: text }];
995
+ });
996
+ setMessages(settled);
997
+ setFocusProductState(stored.focusProduct);
998
+ const turns = countUserTurns(settled);
999
+ turnCountRef.current = turns;
1000
+ setTurnCount(turns);
1001
+ }
1002
+ setHydrated(true);
1003
+ }, [persist, storageKey]);
1004
+ useEffect(() => {
1005
+ if (!persist || !hydrated || typeof window === "undefined") return;
1006
+ try {
1007
+ const payload = {
1008
+ conversationToken: conversationTokenRef.current,
1009
+ messages: messages.slice(-MAX_PERSISTED_MESSAGES),
1010
+ focusProduct
1011
+ };
1012
+ if (!payload.conversationToken && payload.messages.length === 0 && !payload.focusProduct) {
1013
+ window.sessionStorage.removeItem(storageKey);
1014
+ return;
1015
+ }
1016
+ window.sessionStorage.setItem(storageKey, JSON.stringify(payload));
1017
+ } catch {
1018
+ }
1019
+ }, [persist, hydrated, storageKey, messages, focusProduct]);
1020
+ useEffect(() => {
1021
+ let cancelled = false;
1022
+ const load = async () => {
1023
+ const res = await client.query(
1024
+ EXPLORE_CATALOG_QUERY,
1025
+ { productSlug: productSlug ?? null }
1026
+ );
1027
+ if (cancelled || !mountedRef.current) return;
1028
+ const raw = res.data?.exploreCatalog;
1029
+ if (res.errors?.length || !raw) {
1030
+ console.warn(
1031
+ "[WebSDK] exploreCatalog unavailable \u2014 using the built-in fallback catalog",
1032
+ res.errors?.[0]?.message
1033
+ );
1034
+ setPhase((prev) => prev === "loading" ? "ready" : prev);
1035
+ return;
1036
+ }
1037
+ const next = normalizeCatalog(raw, fallbackCatalog);
1038
+ setCatalog(next);
1039
+ catalogRef.current = next;
1040
+ setPhase((prev) => {
1041
+ if (!next.enabled) return "disabled";
1042
+ return prev === "loading" ? "ready" : prev;
1043
+ });
1044
+ };
1045
+ void load();
1046
+ return () => {
1047
+ cancelled = true;
1048
+ };
1049
+ }, [client, productSlug, fallbackCatalog]);
1050
+ const startPolling = useCallback(
1051
+ (conversationToken, messageId) => {
1052
+ pollGenerationRef.current += 1;
1053
+ const generation = pollGenerationRef.current;
1054
+ const startedAt = Date.now();
1055
+ let consecutiveFailures = 0;
1056
+ const isStale = () => !mountedRef.current || generation !== pollGenerationRef.current;
1057
+ const finishWithError = (chatError) => {
1058
+ inFlightRef.current = false;
1059
+ setMessages(
1060
+ (prev) => prev.flatMap((m) => {
1061
+ if (m.id !== messageId) return [m];
1062
+ const text = visibleText(m);
1063
+ if (!text) return [];
1064
+ return [{ ...m, status: "FAILED", content: text }];
1065
+ })
1066
+ );
1067
+ setError(chatError);
1068
+ setPhase(chatError.kind === "rate-limit" ? "limited" : "error");
1069
+ };
1070
+ const tick = async () => {
1071
+ if (isStale()) return;
1072
+ if (Date.now() - startedAt > pollTimeoutMs) {
1073
+ finishWithError(classifyExploreError("TIMEOUT"));
1074
+ return;
1075
+ }
1076
+ const res = await client.query(
1077
+ EXPLORE_MESSAGE_QUERY,
1078
+ { conversationToken, id: messageId },
1079
+ { cache: false, timeoutMs: POLL_REQUEST_TIMEOUT_MS }
1080
+ );
1081
+ if (isStale()) return;
1082
+ const first = res.errors?.[0];
1083
+ if (first) {
1084
+ const code = typeof first.extensions?.code === "string" ? first.extensions.code : void 0;
1085
+ const classified = classifyExploreError(code, first.message);
1086
+ if (!classified.retryable) {
1087
+ finishWithError(classified);
1088
+ return;
1089
+ }
1090
+ consecutiveFailures += 1;
1091
+ if (consecutiveFailures >= MAX_CONSECUTIVE_POLL_FAILURES) {
1092
+ finishWithError(classified);
1093
+ return;
1094
+ }
1095
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
1096
+ return;
1097
+ }
1098
+ const message = res.data?.exploreMessage;
1099
+ if (!message) {
1100
+ consecutiveFailures += 1;
1101
+ if (consecutiveFailures >= MAX_CONSECUTIVE_POLL_FAILURES) {
1102
+ finishWithError(classifyExploreError("NOT_FOUND"));
1103
+ return;
1104
+ }
1105
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
1106
+ return;
1107
+ }
1108
+ consecutiveFailures = 0;
1109
+ setMessages(
1110
+ (prev) => prev.map((m) => m.id === messageId ? message : m)
1111
+ );
1112
+ if (message.status === "COMPLETED") {
1113
+ inFlightRef.current = false;
1114
+ setError(null);
1115
+ setPhase("ready");
1116
+ return;
1117
+ }
1118
+ if (message.status === "FAILED") {
1119
+ finishWithError(
1120
+ classifyExploreError(message.errorCode ?? "UPSTREAM_UNAVAILABLE")
1121
+ );
1122
+ return;
1123
+ }
1124
+ setPhase("streaming");
1125
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
1126
+ };
1127
+ pollTimerRef.current = setTimeout(() => void tick(), pollIntervalMs);
1128
+ },
1129
+ [client, pollIntervalMs, pollTimeoutMs]
1130
+ );
1131
+ const submit = useCallback(
1132
+ async (text, optimisticId, captchaAttempt) => {
1133
+ const activeCatalog = catalogRef.current;
1134
+ let recaptchaToken;
1135
+ if (activeCatalog.captchaRequired && activeCatalog.recaptchaSiteKey) {
1136
+ try {
1137
+ recaptchaToken = await getRecaptchaV3Token(
1138
+ activeCatalog.recaptchaSiteKey
1139
+ );
1140
+ } catch (err) {
1141
+ console.warn("[WebSDK] reCAPTCHA v3 token could not be minted", err);
1142
+ }
1143
+ }
1144
+ const input = {
1145
+ message: text,
1146
+ ...conversationTokenRef.current ? { conversationToken: conversationTokenRef.current } : {},
1147
+ ...focusProductRef.current || productSlug ? { productSlug: focusProductRef.current ?? productSlug } : {},
1148
+ ...recaptchaToken ? { recaptchaToken } : {},
1149
+ ...locale ? { locale } : {},
1150
+ ...pageUrl ? { pageUrl } : {}
1151
+ };
1152
+ const res = await client.mutate(
1153
+ SEND_EXPLORE_MESSAGE_MUTATION,
1154
+ { input },
1155
+ { timeoutMs: SEND_REQUEST_TIMEOUT_MS }
1156
+ );
1157
+ if (!mountedRef.current) return;
1158
+ const first = res.errors?.[0];
1159
+ const result = res.data?.sendExploreMessage;
1160
+ if (first || !result) {
1161
+ const code = typeof first?.extensions?.code === "string" ? first.extensions.code : void 0;
1162
+ const classified = classifyExploreError(code, first?.message);
1163
+ if (classified.kind === "captcha" && captchaAttempt === 0) {
1164
+ await submit(text, optimisticId, 1);
1165
+ return;
1166
+ }
1167
+ inFlightRef.current = false;
1168
+ setError(classified);
1169
+ setPhase(classified.kind === "rate-limit" ? "limited" : "error");
1170
+ return;
1171
+ }
1172
+ conversationTokenRef.current = result.conversation.token;
1173
+ turnCountRef.current = result.conversation.turnCount;
1174
+ setTurnCount(result.conversation.turnCount);
1175
+ setRemainingToday(result.remainingToday ?? null);
1176
+ const userMessage = result.userMessage;
1177
+ const assistantMessage = result.assistantMessage;
1178
+ setMessages((prev) => {
1179
+ const replaced = prev.some((m) => m.id === optimisticId) ? prev.map((m) => m.id === optimisticId ? userMessage : m) : [...prev, userMessage];
1180
+ return [...replaced, assistantMessage];
1181
+ });
1182
+ if (assistantMessage.status === "COMPLETED" || assistantMessage.status === "FAILED") {
1183
+ inFlightRef.current = false;
1184
+ if (assistantMessage.status === "FAILED") {
1185
+ const classified = classifyExploreError(
1186
+ assistantMessage.errorCode ?? "UPSTREAM_UNAVAILABLE"
1187
+ );
1188
+ setError(classified);
1189
+ setPhase("error");
1190
+ } else {
1191
+ setPhase("ready");
1192
+ }
1193
+ return;
1194
+ }
1195
+ setPhase("streaming");
1196
+ startPolling(result.conversation.token, assistantMessage.id);
1197
+ },
1198
+ [client, locale, pageUrl, productSlug, startPolling]
1199
+ );
1200
+ const send = useCallback(
1201
+ async (message) => {
1202
+ const text = message.trim();
1203
+ if (!text) return;
1204
+ if (inFlightRef.current) return;
1205
+ const activeCatalog = catalogRef.current;
1206
+ if (!activeCatalog.enabled) {
1207
+ setError(classifyExploreError("EXPLORE_DISABLED"));
1208
+ setPhase("disabled");
1209
+ return;
1210
+ }
1211
+ if (text.length > activeCatalog.limits.maxMessageLength) {
1212
+ setError({
1213
+ kind: "validation",
1214
+ code: "MESSAGE_TOO_LONG",
1215
+ message: `That message is ${text.length} characters \u2014 the limit is ${activeCatalog.limits.maxMessageLength}.`,
1216
+ retryable: false
1217
+ });
1218
+ return;
1219
+ }
1220
+ if (turnCountRef.current >= activeCatalog.limits.maxTurnsPerConversation) {
1221
+ setError({
1222
+ kind: "validation",
1223
+ code: "CONVERSATION_LIMIT",
1224
+ message: `This conversation has reached its ${activeCatalog.limits.maxTurnsPerConversation}-message limit. Start a new chat to keep going.`,
1225
+ retryable: false
1226
+ });
1227
+ return;
1228
+ }
1229
+ inFlightRef.current = true;
1230
+ lastSentTextRef.current = text;
1231
+ setError(null);
1232
+ setPhase("sending");
1233
+ cancelPolling();
1234
+ const optimistic = {
1235
+ id: makeOptimisticId(),
1236
+ conversationId: conversationTokenRef.current ?? "pending",
1237
+ role: "USER",
1238
+ status: "COMPLETED",
1239
+ content: text,
1240
+ partialContent: null,
1241
+ activity: [],
1242
+ references: [],
1243
+ ctas: [],
1244
+ errorCode: null,
1245
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1246
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
1247
+ };
1248
+ setMessages((prev) => [...prev, optimistic]);
1249
+ turnCountRef.current += 1;
1250
+ setTurnCount(turnCountRef.current);
1251
+ onSend?.(text);
1252
+ try {
1253
+ await submit(text, optimistic.id, 0);
1254
+ } catch (err) {
1255
+ if (!mountedRef.current) return;
1256
+ console.error("[WebSDK] Explore send failed", err);
1257
+ inFlightRef.current = false;
1258
+ setError(classifyExploreError("NETWORK_ERROR"));
1259
+ setPhase("error");
1260
+ }
1261
+ },
1262
+ [cancelPolling, onSend, submit]
1263
+ );
1264
+ const stop = useCallback(() => {
1265
+ cancelPolling();
1266
+ inFlightRef.current = false;
1267
+ setMessages(
1268
+ (prev) => prev.flatMap((m) => {
1269
+ if (m.role !== "ASSISTANT") return [m];
1270
+ if (m.status !== "PENDING" && m.status !== "RUNNING") return [m];
1271
+ const text = visibleText(m);
1272
+ if (!text) return [];
1273
+ return [
1274
+ {
1275
+ ...m,
1276
+ status: "COMPLETED",
1277
+ content: text,
1278
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
1279
+ }
1280
+ ];
1281
+ })
1282
+ );
1283
+ setPhase(
1284
+ (prev) => prev === "sending" || prev === "streaming" ? "ready" : prev
1285
+ );
1286
+ }, [cancelPolling]);
1287
+ const retry = useCallback(() => {
1288
+ const text = lastSentTextRef.current;
1289
+ if (!text) return;
1290
+ cancelPolling();
1291
+ inFlightRef.current = false;
1292
+ setMessages((prev) => {
1293
+ const next = [...prev];
1294
+ const last = next[next.length - 1];
1295
+ if (last?.role === "ASSISTANT" && last.status === "FAILED") next.pop();
1296
+ const prior = next[next.length - 1];
1297
+ if (prior?.role === "USER" && prior.content === text) next.pop();
1298
+ return next;
1299
+ });
1300
+ turnCountRef.current = Math.max(0, turnCountRef.current - 1);
1301
+ setTurnCount(turnCountRef.current);
1302
+ void send(text);
1303
+ }, [cancelPolling, send]);
1304
+ const reset = useCallback(() => {
1305
+ cancelPolling();
1306
+ inFlightRef.current = false;
1307
+ conversationTokenRef.current = null;
1308
+ lastSentTextRef.current = null;
1309
+ turnCountRef.current = 0;
1310
+ setTurnCount(0);
1311
+ setMessages([]);
1312
+ setError(null);
1313
+ setRemainingToday(null);
1314
+ setPhase(catalogRef.current.enabled ? "ready" : "disabled");
1315
+ if (typeof window !== "undefined") {
1316
+ try {
1317
+ window.sessionStorage.removeItem(storageKey);
1318
+ } catch {
1319
+ }
1320
+ }
1321
+ }, [cancelPolling, storageKey]);
1322
+ const setFocusProduct = useCallback((slug) => {
1323
+ focusProductRef.current = slug;
1324
+ setFocusProductState(slug);
1325
+ }, []);
1326
+ const activity = useMemo(() => {
1327
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
1328
+ const m = messages[i];
1329
+ if (!m || m.role !== "ASSISTANT") continue;
1330
+ if (m.status !== "PENDING" && m.status !== "RUNNING") return null;
1331
+ const lines = m.activity ?? [];
1332
+ return lines.length ? lines[lines.length - 1] ?? null : null;
1333
+ }
1334
+ return null;
1335
+ }, [messages]);
1336
+ const canSend = (phase === "ready" || phase === "error") && catalog.enabled && turnCount < catalog.limits.maxTurnsPerConversation;
1337
+ return {
1338
+ phase,
1339
+ catalog,
1340
+ messages,
1341
+ activity,
1342
+ remainingToday,
1343
+ error,
1344
+ focusProduct,
1345
+ setFocusProduct,
1346
+ send,
1347
+ stop,
1348
+ retry,
1349
+ reset,
1350
+ canSend
1351
+ };
1352
+ }
1353
+ var optimisticCounter = 0;
1354
+ function makeOptimisticId() {
1355
+ optimisticCounter += 1;
1356
+ return `boff-explore-local-${Date.now()}-${optimisticCounter}`;
1357
+ }
1358
+ function canonicalFromLocation() {
1359
+ if (typeof window === "undefined" || !window.location) return void 0;
1360
+ const { origin, pathname } = window.location;
1361
+ if (!origin || origin === "null") return void 0;
1362
+ const path = pathname === "/" ? "/" : pathname.replace(/\/+$/, "");
1363
+ return `${origin}${path}`;
1364
+ }
1365
+ function resolveImageUrl(image, base) {
1366
+ if (!image || /^https?:\/\//i.test(image)) return image;
1367
+ if (!base) return image;
1368
+ try {
1369
+ return new URL(image, base).toString();
1370
+ } catch {
1371
+ return image;
1372
+ }
1373
+ }
1374
+ function PageHead({
1375
+ title,
1376
+ description,
1377
+ productName,
1378
+ keywords,
1379
+ image,
1380
+ url,
1381
+ favicon,
1382
+ robots = "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1",
1383
+ locale = "en_US",
1384
+ twitterHandle,
1385
+ themeColor = "#000000",
1386
+ structuredData,
1387
+ additionalMeta
1388
+ }) {
1389
+ const fullTitle = productName && !title.includes(productName) ? `${title} | ${productName}` : title;
1390
+ const resolvedUrl = url ?? canonicalFromLocation();
1391
+ const fullImageUrl = resolveImageUrl(image, resolvedUrl);
1392
+ const structuredDataItems = structuredData ? Array.isArray(structuredData) ? structuredData : [structuredData] : [];
1393
+ return /* @__PURE__ */ jsxs(Helmet, { children: [
1394
+ /* @__PURE__ */ jsx("title", { children: fullTitle }),
1395
+ /* @__PURE__ */ jsx("meta", { name: "title", content: fullTitle }),
1396
+ description && /* @__PURE__ */ jsx("meta", { name: "description", content: description }),
1397
+ keywords && /* @__PURE__ */ jsx("meta", { name: "keywords", content: keywords }),
1398
+ /* @__PURE__ */ jsx("meta", { name: "author", content: "Burdenoff Consultancy Services Pvt Ltd" }),
1399
+ /* @__PURE__ */ jsx("meta", { name: "robots", content: robots }),
1400
+ resolvedUrl && /* @__PURE__ */ jsx("link", { rel: "canonical", href: resolvedUrl }),
1401
+ favicon && /* @__PURE__ */ jsx("link", { rel: "icon", href: favicon }),
1402
+ /* @__PURE__ */ jsx("meta", { property: "og:type", content: "website" }),
1403
+ /* @__PURE__ */ jsx("meta", { property: "og:title", content: fullTitle }),
1404
+ description && /* @__PURE__ */ jsx("meta", { property: "og:description", content: description }),
1405
+ fullImageUrl && /* @__PURE__ */ jsx("meta", { property: "og:image", content: fullImageUrl }),
1406
+ resolvedUrl && /* @__PURE__ */ jsx("meta", { property: "og:url", content: resolvedUrl }),
1407
+ /* @__PURE__ */ jsx("meta", { property: "og:locale", content: locale }),
1408
+ productName && /* @__PURE__ */ jsx("meta", { property: "og:site_name", content: productName }),
1409
+ /* @__PURE__ */ jsx("meta", { name: "twitter:card", content: "summary_large_image" }),
1410
+ /* @__PURE__ */ jsx("meta", { name: "twitter:title", content: fullTitle }),
1411
+ description && /* @__PURE__ */ jsx("meta", { name: "twitter:description", content: description }),
1412
+ fullImageUrl && /* @__PURE__ */ jsx("meta", { name: "twitter:image", content: fullImageUrl }),
1413
+ twitterHandle && /* @__PURE__ */ jsx("meta", { name: "twitter:creator", content: twitterHandle }),
1414
+ /* @__PURE__ */ jsx("meta", { name: "theme-color", content: themeColor }),
1415
+ structuredDataItems.map((data, index) => /* @__PURE__ */ jsx("script", { type: "application/ld+json", children: JSON.stringify(data) }, `ld-${index}`)),
1416
+ additionalMeta?.map((meta, index) => /* @__PURE__ */ jsx(
1417
+ "meta",
1418
+ {
1419
+ ...meta.name ? { name: meta.name } : {},
1420
+ ...meta.property ? { property: meta.property } : {},
1421
+ content: meta.content
1422
+ },
1423
+ `meta-${index}`
1424
+ ))
1425
+ ] });
1426
+ }
1427
+ function cn(...inputs) {
1428
+ return twMerge(clsx(inputs));
1429
+ }
1430
+ var buttonVariants = cva(
1431
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
1432
+ {
1433
+ variants: {
1434
+ variant: {
1435
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
1436
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
1437
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
1438
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
1439
+ ghost: "hover:bg-accent hover:text-accent-foreground",
1440
+ link: "text-primary underline-offset-4 hover:underline"
1441
+ },
1442
+ size: {
1443
+ default: "h-9 px-4 py-2",
1444
+ sm: "h-8 rounded-md px-3 text-xs",
1445
+ lg: "h-10 rounded-md px-8",
1446
+ icon: "h-9 w-9"
1447
+ }
1448
+ },
1449
+ defaultVariants: {
1450
+ variant: "default",
1451
+ size: "default"
1452
+ }
1453
+ }
1454
+ );
1455
+ var Button = React.forwardRef(
1456
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
1457
+ const Comp = asChild ? Slot : "button";
1458
+ return /* @__PURE__ */ jsx(
1459
+ Comp,
1460
+ {
1461
+ className: cn(buttonVariants({ variant, size, className })),
1462
+ ref,
1463
+ ...props
1464
+ }
1465
+ );
1466
+ }
1467
+ );
1468
+ Button.displayName = "Button";
1469
+ var Textarea = React.forwardRef(({ className, ...props }, ref) => {
1470
+ return /* @__PURE__ */ jsx(
1471
+ "textarea",
1472
+ {
1473
+ className: cn(
1474
+ "flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
1475
+ className
1476
+ ),
1477
+ ref,
1478
+ ...props
1479
+ }
1480
+ );
1481
+ });
1482
+ Textarea.displayName = "Textarea";
1483
+ var EXPLORE_CSS = `
1484
+ @keyframes boff-explore-pulse {
1485
+ 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
1486
+ 40% { opacity: 1; transform: translateY(-2px); }
1487
+ }
1488
+ .boff-explore-dot {
1489
+ display: inline-block;
1490
+ width: 5px;
1491
+ height: 5px;
1492
+ border-radius: 9999px;
1493
+ background-color: hsl(var(--muted-foreground));
1494
+ animation: boff-explore-pulse 1.2s ease-in-out infinite;
1495
+ }
1496
+ @keyframes boff-explore-caret {
1497
+ 0%, 45% { opacity: 1; }
1498
+ 50%, 100% { opacity: 0; }
1499
+ }
1500
+ .boff-explore-caret {
1501
+ display: inline-block;
1502
+ width: 2px;
1503
+ height: 1em;
1504
+ margin-left: 2px;
1505
+ vertical-align: text-bottom;
1506
+ background-color: hsl(var(--primary));
1507
+ animation: boff-explore-caret 1s step-end infinite;
1508
+ }
1509
+ @media (prefers-reduced-motion: reduce) {
1510
+ .boff-explore-dot,
1511
+ .boff-explore-caret { animation: none; }
1512
+ .boff-explore-dot { opacity: 0.6; }
1513
+ }
1514
+ .boff-explore-scroll {
1515
+ scrollbar-width: thin;
1516
+ scrollbar-color: hsl(var(--border)) transparent;
1517
+ }
1518
+ .boff-explore-scroll::-webkit-scrollbar { width: 10px; }
1519
+ .boff-explore-scroll::-webkit-scrollbar-track { background: transparent; }
1520
+ .boff-explore-scroll::-webkit-scrollbar-thumb {
1521
+ background-color: hsl(var(--border));
1522
+ border: 3px solid transparent;
1523
+ border-radius: 9999px;
1524
+ background-clip: content-box;
1525
+ }
1526
+ `;
1527
+ function ExploreStyles() {
1528
+ return /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: EXPLORE_CSS } });
1529
+ }
1530
+ var CAPABILITIES = [
1531
+ {
1532
+ icon: BookOpenText,
1533
+ title: "Grounded in our own docs",
1534
+ body: "Every answer comes from published product pages and documentation \u2014 never invented."
1535
+ },
1536
+ {
1537
+ icon: Layers,
1538
+ title: "Compare across the ecosystem",
1539
+ body: "Ask which product fits your team, or how two of them work together."
1540
+ },
1541
+ {
1542
+ icon: Link2,
1543
+ title: "Straight to the right page",
1544
+ body: "Get the sources and next steps \u2014 pricing, docs, a demo \u2014 without hunting."
1545
+ }
1546
+ ];
1547
+ var PRODUCT_CHIP_PREVIEW = 12;
1548
+ var CTA_VARIANTS = {
1549
+ CONTACT: "default",
1550
+ WAITLIST: "default",
1551
+ APP: "default",
1552
+ PRICING: "secondary",
1553
+ STORE: "secondary",
1554
+ PARTNERS: "secondary",
1555
+ DOCS: "outline",
1556
+ SERVICES: "outline",
1557
+ OTHER: "outline"
1558
+ };
1559
+ function normalizeOffset(offset) {
1560
+ if (offset === void 0) return "0px";
1561
+ return typeof offset === "number" ? `${offset}px` : offset;
1562
+ }
1563
+ function isInternalPath(url) {
1564
+ return url.startsWith("/") && !url.startsWith("//");
1565
+ }
1566
+ function hostnameOf(url) {
1567
+ try {
1568
+ return new URL(url).hostname.replace(/^www\./, "");
1569
+ } catch {
1570
+ return "";
1571
+ }
1572
+ }
1573
+ function initialOf(value, fallback) {
1574
+ const source = (value || fallback).trim();
1575
+ return source ? source.slice(0, 1).toUpperCase() : "?";
1576
+ }
1577
+ function ReferenceCard({ reference }) {
1578
+ const [imageFailed, setImageFailed] = useState(false);
1579
+ const host = hostnameOf(reference.url);
1580
+ const showImage = Boolean(reference.imageUrl) && !imageFailed;
1581
+ return /* @__PURE__ */ jsxs(
1582
+ "a",
1583
+ {
1584
+ "data-boff-explore": "reference",
1585
+ href: reference.url,
1586
+ target: "_blank",
1587
+ rel: "noopener noreferrer",
1588
+ className: "group flex flex-col overflow-hidden rounded-xl border border-border bg-card transition-colors hover:border-primary/40 hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
1589
+ children: [
1590
+ /* @__PURE__ */ jsx("div", { className: "relative aspect-[16/9] w-full overflow-hidden bg-muted", children: showImage ? /* @__PURE__ */ jsx(
1591
+ "img",
1592
+ {
1593
+ src: reference.imageUrl ?? "",
1594
+ alt: "",
1595
+ loading: "lazy",
1596
+ onError: () => setImageFailed(true),
1597
+ className: "h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
1598
+ }
1599
+ ) : (
1600
+ /* Graceful fallback: a token-derived gradient plate, so a missing or
1601
+ broken preview still reads as a deliberate card, not a hole. */
1602
+ /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center justify-center bg-gradient-to-br from-primary/25 via-primary/5 to-secondary", children: /* @__PURE__ */ jsx("span", { className: "text-2xl font-semibold text-primary/70", children: initialOf(reference.product, reference.title || host) }) })
1603
+ ) }),
1604
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col gap-1.5 p-3", children: [
1605
+ /* @__PURE__ */ jsx("p", { className: "line-clamp-2 text-sm font-semibold leading-snug text-card-foreground", children: reference.title || host || reference.url }),
1606
+ reference.description ? /* @__PURE__ */ jsx("p", { className: "line-clamp-2 text-xs leading-relaxed text-muted-foreground", children: reference.description }) : null,
1607
+ /* @__PURE__ */ jsxs("div", { className: "mt-auto flex items-center gap-2 pt-2", children: [
1608
+ reference.product ? /* @__PURE__ */ jsx("span", { className: "rounded-full bg-secondary px-2 py-0.5 text-xs font-medium text-secondary-foreground", children: reference.product }) : null,
1609
+ /* @__PURE__ */ jsxs("span", { className: "ml-auto inline-flex min-w-0 items-center gap-1 text-xs text-muted-foreground", children: [
1610
+ /* @__PURE__ */ jsx(ExternalLink, { className: "h-3 w-3 shrink-0" }),
1611
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: host })
1612
+ ] })
1613
+ ] })
1614
+ ] })
1615
+ ]
1616
+ }
1617
+ );
1618
+ }
1619
+ function CtaButton({
1620
+ cta,
1621
+ onNavigate
1622
+ }) {
1623
+ const variant = CTA_VARIANTS[cta.kind] ?? "outline";
1624
+ const internal = isInternalPath(cta.url);
1625
+ if (internal && onNavigate) {
1626
+ return /* @__PURE__ */ jsx(
1627
+ Button,
1628
+ {
1629
+ "data-boff-explore": "cta",
1630
+ "data-kind": cta.kind,
1631
+ type: "button",
1632
+ size: "sm",
1633
+ variant,
1634
+ onClick: () => onNavigate(cta.url),
1635
+ children: cta.label
1636
+ }
1637
+ );
1638
+ }
1639
+ return /* @__PURE__ */ jsx(Button, { asChild: true, size: "sm", variant, children: /* @__PURE__ */ jsxs(
1640
+ "a",
1641
+ {
1642
+ "data-boff-explore": "cta",
1643
+ "data-kind": cta.kind,
1644
+ href: cta.url,
1645
+ ...internal ? {} : { target: "_blank", rel: "noopener noreferrer" },
1646
+ children: [
1647
+ cta.label,
1648
+ internal ? null : /* @__PURE__ */ jsx(ExternalLink, { className: "ml-1 h-3 w-3" })
1649
+ ]
1650
+ }
1651
+ ) });
1652
+ }
1653
+ function ThinkingIndicator({ activity }) {
1654
+ return /* @__PURE__ */ jsxs(
1655
+ "div",
1656
+ {
1657
+ "data-boff-explore": "thinking",
1658
+ className: "flex items-center gap-2.5 rounded-2xl border border-border bg-muted/60 px-3.5 py-2.5 text-sm text-muted-foreground",
1659
+ children: [
1660
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", "aria-hidden": "true", children: [
1661
+ /* @__PURE__ */ jsx("span", { className: "boff-explore-dot" }),
1662
+ /* @__PURE__ */ jsx(
1663
+ "span",
1664
+ {
1665
+ className: "boff-explore-dot",
1666
+ style: { animationDelay: "150ms" }
1667
+ }
1668
+ ),
1669
+ /* @__PURE__ */ jsx(
1670
+ "span",
1671
+ {
1672
+ className: "boff-explore-dot",
1673
+ style: { animationDelay: "300ms" }
1674
+ }
1675
+ )
1676
+ ] }),
1677
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: activity || "Thinking\u2026" })
1678
+ ]
1679
+ }
1680
+ );
1681
+ }
1682
+ function UserBubble({ message }) {
1683
+ return /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
1684
+ "div",
1685
+ {
1686
+ "data-boff-explore": "user",
1687
+ className: "max-w-[85%] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-primary px-4 py-2.5 text-sm leading-relaxed text-primary-foreground shadow-sm",
1688
+ children: message.content
1689
+ }
1690
+ ) });
1691
+ }
1692
+ function AssistantBubble({
1693
+ message,
1694
+ activity,
1695
+ onNavigate
1696
+ }) {
1697
+ const streaming = message.status === "PENDING" || message.status === "RUNNING";
1698
+ const body = message.content || message.partialContent || "";
1699
+ const failed = message.status === "FAILED";
1700
+ return /* @__PURE__ */ jsxs(
1701
+ "div",
1702
+ {
1703
+ "data-boff-explore": "assistant",
1704
+ "data-status": message.status,
1705
+ className: "flex gap-3",
1706
+ children: [
1707
+ /* @__PURE__ */ jsx(
1708
+ "span",
1709
+ {
1710
+ "aria-hidden": "true",
1711
+ className: "mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",
1712
+ children: /* @__PURE__ */ jsx(Sparkles, { className: "h-4 w-4" })
1713
+ }
1714
+ ),
1715
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-3", children: [
1716
+ body ? /* @__PURE__ */ jsxs("div", { className: "rounded-2xl rounded-tl-md border border-border bg-card px-4 py-3 shadow-sm", children: [
1717
+ /* @__PURE__ */ jsx("div", { className: "boff-prose boff-prose-sm text-card-foreground", children: /* @__PURE__ */ jsx(Markdown, { children: body }) }),
1718
+ streaming ? /* @__PURE__ */ jsx("span", { className: "boff-explore-caret", "aria-hidden": "true" }) : null
1719
+ ] }) : null,
1720
+ streaming ? /* @__PURE__ */ jsx(ThinkingIndicator, { activity }) : null,
1721
+ failed && !body ? /* @__PURE__ */ jsx("div", { className: "rounded-2xl rounded-tl-md border border-border bg-muted px-4 py-3 text-sm text-muted-foreground", children: "That answer didn't come through. Try asking again." }) : null,
1722
+ message.references.length > 0 ? /* @__PURE__ */ jsxs("div", { children: [
1723
+ /* @__PURE__ */ jsx("p", { className: "mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Sources" }),
1724
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3", children: message.references.map((reference) => /* @__PURE__ */ jsx(ReferenceCard, { reference }, reference.url)) })
1725
+ ] }) : null,
1726
+ message.ctas.length > 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2 pt-0.5", children: message.ctas.map((cta) => /* @__PURE__ */ jsx(
1727
+ CtaButton,
1728
+ {
1729
+ cta,
1730
+ onNavigate
1731
+ },
1732
+ `${cta.kind}-${cta.url}`
1733
+ )) }) : null
1734
+ ] })
1735
+ ]
1736
+ }
1737
+ );
1738
+ }
1739
+ function ErrorBanner({
1740
+ error,
1741
+ onRetry,
1742
+ onReset
1743
+ }) {
1744
+ const showRetry = error.retryable;
1745
+ const showReset = error.code === "CONVERSATION_LIMIT";
1746
+ return /* @__PURE__ */ jsxs(
1747
+ "div",
1748
+ {
1749
+ "data-boff-explore": "error",
1750
+ "data-error-kind": error.kind,
1751
+ role: "alert",
1752
+ className: "mb-3 flex items-start gap-3 rounded-xl border border-destructive/40 bg-destructive/10 px-3 py-2.5",
1753
+ children: [
1754
+ /* @__PURE__ */ jsx(
1755
+ "span",
1756
+ {
1757
+ "aria-hidden": "true",
1758
+ className: "mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-destructive text-destructive-foreground",
1759
+ children: /* @__PURE__ */ jsx(TriangleAlert, { className: "h-3 w-3" })
1760
+ }
1761
+ ),
1762
+ /* @__PURE__ */ jsx("p", { className: "flex-1 text-sm leading-relaxed text-foreground", children: error.message }),
1763
+ showRetry ? /* @__PURE__ */ jsx(
1764
+ Button,
1765
+ {
1766
+ "data-boff-explore": "retry",
1767
+ type: "button",
1768
+ size: "sm",
1769
+ variant: "outline",
1770
+ onClick: onRetry,
1771
+ children: "Retry"
1772
+ }
1773
+ ) : null,
1774
+ showReset ? /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: onReset, children: "New chat" }) : null
1775
+ ]
1776
+ }
1777
+ );
1778
+ }
1779
+ function WelcomeState({
1780
+ title,
1781
+ body,
1782
+ prompts,
1783
+ products,
1784
+ focusProduct,
1785
+ onPrompt,
1786
+ onFocus,
1787
+ disabled
1788
+ }) {
1789
+ const [showAllProducts, setShowAllProducts] = useState(false);
1790
+ const visibleProducts = showAllProducts ? products : products.slice(0, PRODUCT_CHIP_PREVIEW);
1791
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-3xl px-4 py-10 sm:py-14", children: [
1792
+ /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
1793
+ /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1.5 rounded-full border border-border bg-muted px-3 py-1 text-xs font-medium text-muted-foreground", children: [
1794
+ /* @__PURE__ */ jsx(Sparkles, { className: "h-3.5 w-3.5" }),
1795
+ "AI answers, grounded in our documentation"
1796
+ ] }),
1797
+ /* @__PURE__ */ jsx("h1", { className: "mt-5 text-balance text-3xl font-bold tracking-tight sm:text-4xl", children: title }),
1798
+ /* @__PURE__ */ jsx("p", { className: "mx-auto mt-3 max-w-2xl text-pretty text-base leading-relaxed text-muted-foreground sm:text-lg", children: body })
1799
+ ] }),
1800
+ /* @__PURE__ */ jsx("ul", { className: "mt-9 grid gap-3 sm:grid-cols-3", children: CAPABILITIES.map(({ icon: Icon, title: capTitle, body: capBody }) => /* @__PURE__ */ jsxs(
1801
+ "li",
1802
+ {
1803
+ className: "rounded-xl border border-border bg-card p-4 text-left",
1804
+ children: [
1805
+ /* @__PURE__ */ jsx("span", { className: "mb-2.5 flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-primary", children: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }) }),
1806
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-card-foreground", children: capTitle }),
1807
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs leading-relaxed text-muted-foreground", children: capBody })
1808
+ ]
1809
+ },
1810
+ capTitle
1811
+ )) }),
1812
+ prompts.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-9", children: [
1813
+ /* @__PURE__ */ jsx("p", { className: "mb-2.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Try asking" }),
1814
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: prompts.map((prompt) => /* @__PURE__ */ jsxs(
1815
+ "button",
1816
+ {
1817
+ "data-boff-explore": "chip",
1818
+ "data-chip-kind": "prompt",
1819
+ type: "button",
1820
+ disabled,
1821
+ onClick: () => onPrompt(prompt),
1822
+ className: "group inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-card px-3.5 py-1.5 text-left text-sm text-card-foreground transition-colors hover:border-primary/40 hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
1823
+ children: [
1824
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: prompt }),
1825
+ /* @__PURE__ */ jsx(ArrowUp, { className: "h-3 w-3 shrink-0 rotate-45 text-muted-foreground transition-colors group-hover:text-primary" })
1826
+ ]
1827
+ },
1828
+ prompt
1829
+ )) })
1830
+ ] }) : null,
1831
+ products.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-8", children: [
1832
+ /* @__PURE__ */ jsx("p", { className: "mb-2.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: "Focus on a product" }),
1833
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
1834
+ /* @__PURE__ */ jsx(
1835
+ "button",
1836
+ {
1837
+ "data-boff-explore": "chip",
1838
+ "data-chip-kind": "product",
1839
+ "data-product": "all",
1840
+ type: "button",
1841
+ "aria-pressed": focusProduct === null,
1842
+ onClick: () => onFocus(null),
1843
+ className: cn(
1844
+ "rounded-full border px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
1845
+ focusProduct === null ? "border-primary bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:bg-accent hover:text-accent-foreground"
1846
+ ),
1847
+ children: "All products"
1848
+ }
1849
+ ),
1850
+ visibleProducts.map((product) => /* @__PURE__ */ jsx(
1851
+ "button",
1852
+ {
1853
+ "data-boff-explore": "chip",
1854
+ "data-chip-kind": "product",
1855
+ "data-product": product.slug,
1856
+ type: "button",
1857
+ "aria-pressed": focusProduct === product.slug,
1858
+ title: product.tagline ?? product.name,
1859
+ onClick: () => onFocus(focusProduct === product.slug ? null : product.slug),
1860
+ className: cn(
1861
+ "rounded-full border px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
1862
+ focusProduct === product.slug ? "border-primary bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground hover:bg-accent hover:text-accent-foreground"
1863
+ ),
1864
+ children: product.name
1865
+ },
1866
+ product.slug
1867
+ )),
1868
+ products.length > PRODUCT_CHIP_PREVIEW ? /* @__PURE__ */ jsx(
1869
+ "button",
1870
+ {
1871
+ type: "button",
1872
+ onClick: () => setShowAllProducts((v) => !v),
1873
+ className: "rounded-full px-3 py-1 text-xs font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
1874
+ children: showAllProducts ? "Show fewer" : `Show all ${products.length}`
1875
+ }
1876
+ ) : null
1877
+ ] })
1878
+ ] }) : null
1879
+ ] });
1880
+ }
1881
+ function ExplorePage({
1882
+ seo,
1883
+ productSlug,
1884
+ examplePrompts,
1885
+ className,
1886
+ heightMode = "viewport",
1887
+ viewportOffset,
1888
+ onNavigate,
1889
+ onSend,
1890
+ welcomeTitle,
1891
+ welcomeBody
1892
+ }) {
1893
+ const pageUrl = useMemo(
1894
+ () => typeof window === "undefined" ? void 0 : window.location.href,
1895
+ []
1896
+ );
1897
+ const {
1898
+ phase,
1899
+ catalog,
1900
+ messages,
1901
+ activity,
1902
+ remainingToday,
1903
+ error,
1904
+ focusProduct,
1905
+ setFocusProduct,
1906
+ send,
1907
+ stop,
1908
+ retry,
1909
+ reset,
1910
+ canSend
1911
+ } = useExploreChat({ productSlug, pageUrl, onSend, examplePrompts });
1912
+ const [draft, setDraft] = useState("");
1913
+ const textareaRef = useRef(null);
1914
+ const scrollRef = useRef(null);
1915
+ const stickToBottomRef = useRef(true);
1916
+ const composingRef = useRef(false);
1917
+ const busy = phase === "sending" || phase === "streaming";
1918
+ const showWelcome = messages.length === 0;
1919
+ const maxLength = catalog.limits.maxMessageLength;
1920
+ const overLimit = draft.length > maxLength;
1921
+ const canSubmit = canSend && draft.trim().length > 0 && !overLimit && !busy;
1922
+ const resolvedTitle = welcomeTitle ?? catalog.welcomeTitle;
1923
+ const resolvedBody = welcomeBody ?? catalog.welcomeBody;
1924
+ const prompts = catalog.examplePrompts;
1925
+ const focusedProductName = useMemo(
1926
+ () => catalog.products.find((p) => p.slug === focusProduct)?.name ?? null,
1927
+ [catalog.products, focusProduct]
1928
+ );
1929
+ useEffect(() => {
1930
+ const el = textareaRef.current;
1931
+ if (!el) return;
1932
+ el.style.height = "auto";
1933
+ el.style.height = `${Math.min(el.scrollHeight, 200)}px`;
1934
+ }, [draft]);
1935
+ const handleScroll = useCallback(() => {
1936
+ const el = scrollRef.current;
1937
+ if (!el) return;
1938
+ stickToBottomRef.current = el.scrollHeight - el.scrollTop - el.clientHeight < 80;
1939
+ }, []);
1940
+ useEffect(() => {
1941
+ if (!stickToBottomRef.current) return;
1942
+ const el = scrollRef.current;
1943
+ if (!el) return;
1944
+ el.scrollTop = el.scrollHeight;
1945
+ }, [messages, activity]);
1946
+ const submitDraft = useCallback(() => {
1947
+ const text = draft.trim();
1948
+ if (!text || overLimit || busy || !canSend) return;
1949
+ setDraft("");
1950
+ stickToBottomRef.current = true;
1951
+ void send(text);
1952
+ textareaRef.current?.focus();
1953
+ }, [busy, canSend, draft, overLimit, send]);
1954
+ const sendPrompt = useCallback(
1955
+ (prompt) => {
1956
+ if (!canSend || busy) return;
1957
+ setDraft("");
1958
+ stickToBottomRef.current = true;
1959
+ void send(prompt);
1960
+ },
1961
+ [busy, canSend, send]
1962
+ );
1963
+ const handleKeyDown = useCallback(
1964
+ (event) => {
1965
+ if (event.key !== "Enter" || event.shiftKey) return;
1966
+ if (composingRef.current || event.nativeEvent.isComposing) return;
1967
+ event.preventDefault();
1968
+ submitDraft();
1969
+ },
1970
+ [submitDraft]
1971
+ );
1972
+ const composerDisabled = phase === "limited" || phase === "disabled" || !catalog.enabled;
1973
+ const captchaOn = Boolean(
1974
+ catalog.captchaRequired && catalog.recaptchaSiteKey
1975
+ );
1976
+ const rootStyle = heightMode === "viewport" ? { height: `calc(100dvh - ${normalizeOffset(viewportOffset)})` } : void 0;
1977
+ return /* @__PURE__ */ jsxs(
1978
+ "div",
1979
+ {
1980
+ "data-boff-explore": "page",
1981
+ "data-phase": phase,
1982
+ className: cn(
1983
+ "flex w-full flex-col bg-background text-foreground",
1984
+ heightMode === "auto" && "min-h-[70vh]",
1985
+ className
1986
+ ),
1987
+ style: rootStyle,
1988
+ children: [
1989
+ seo ? /* @__PURE__ */ jsx(
1990
+ PageHead,
1991
+ {
1992
+ title: seo.title ?? "Explore \u2014 ask anything about our products",
1993
+ description: seo.description ?? "Ask questions in plain English and get answers drawn from our product documentation, with links to the exact pages they came from.",
1994
+ keywords: seo.keywords,
1995
+ image: seo.image,
1996
+ url: seo.url
1997
+ }
1998
+ ) : null,
1999
+ /* @__PURE__ */ jsx(ProseStyles, {}),
2000
+ /* @__PURE__ */ jsx(ExploreStyles, {}),
2001
+ !showWelcome ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 border-b border-border px-4 py-2.5", children: [
2002
+ /* @__PURE__ */ jsx(
2003
+ "span",
2004
+ {
2005
+ "aria-hidden": "true",
2006
+ className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",
2007
+ children: /* @__PURE__ */ jsx(Sparkles, { className: "h-4 w-4" })
2008
+ }
2009
+ ),
2010
+ /* @__PURE__ */ jsx("h1", { className: "truncate text-sm font-semibold", children: resolvedTitle }),
2011
+ focusedProductName ? /* @__PURE__ */ jsx("span", { className: "hidden shrink-0 rounded-full bg-secondary px-2 py-0.5 text-xs font-medium text-secondary-foreground sm:inline", children: focusedProductName }) : null,
2012
+ /* @__PURE__ */ jsxs(
2013
+ Button,
2014
+ {
2015
+ "data-boff-explore": "new-chat",
2016
+ type: "button",
2017
+ size: "sm",
2018
+ variant: "ghost",
2019
+ className: "ml-auto shrink-0 text-muted-foreground",
2020
+ onClick: reset,
2021
+ children: [
2022
+ /* @__PURE__ */ jsx(RotateCcw, { className: "h-3.5 w-3.5" }),
2023
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "New chat" })
2024
+ ]
2025
+ }
2026
+ )
2027
+ ] }) : null,
2028
+ /* @__PURE__ */ jsx(
2029
+ "div",
2030
+ {
2031
+ ref: scrollRef,
2032
+ onScroll: handleScroll,
2033
+ "data-boff-explore": "messages",
2034
+ role: "log",
2035
+ "aria-live": "polite",
2036
+ "aria-label": "Explore conversation",
2037
+ className: "boff-explore-scroll min-h-0 flex-1 overflow-y-auto",
2038
+ children: showWelcome ? /* @__PURE__ */ jsx(
2039
+ WelcomeState,
2040
+ {
2041
+ title: resolvedTitle,
2042
+ body: resolvedBody,
2043
+ prompts,
2044
+ products: catalog.products,
2045
+ focusProduct,
2046
+ onPrompt: sendPrompt,
2047
+ onFocus: setFocusProduct,
2048
+ disabled: !canSend || busy
2049
+ }
2050
+ ) : /* @__PURE__ */ jsx("div", { className: "mx-auto w-full max-w-3xl space-y-6 px-4 py-6", children: messages.map(
2051
+ (message) => message.role === "USER" ? /* @__PURE__ */ jsx(UserBubble, { message }, message.id) : /* @__PURE__ */ jsx(
2052
+ AssistantBubble,
2053
+ {
2054
+ message,
2055
+ activity,
2056
+ onNavigate
2057
+ },
2058
+ message.id
2059
+ )
2060
+ ) })
2061
+ }
2062
+ ),
2063
+ /* @__PURE__ */ jsx("div", { className: "border-t border-border bg-background px-4 pb-4 pt-3", children: /* @__PURE__ */ jsxs(
2064
+ "form",
2065
+ {
2066
+ "data-boff-explore": "composer",
2067
+ className: "mx-auto w-full max-w-3xl",
2068
+ onSubmit: (event) => {
2069
+ event.preventDefault();
2070
+ submitDraft();
2071
+ },
2072
+ children: [
2073
+ error ? /* @__PURE__ */ jsx(ErrorBanner, { error, onRetry: retry, onReset: reset }) : null,
2074
+ /* @__PURE__ */ jsxs(
2075
+ "div",
2076
+ {
2077
+ className: cn(
2078
+ "flex items-end gap-2 rounded-2xl border bg-card p-2 shadow-sm transition-colors",
2079
+ overLimit ? "border-destructive/60" : "border-border focus-within:border-primary/40 focus-within:ring-1 focus-within:ring-ring"
2080
+ ),
2081
+ children: [
2082
+ /* @__PURE__ */ jsx(
2083
+ Textarea,
2084
+ {
2085
+ ref: textareaRef,
2086
+ value: draft,
2087
+ rows: 1,
2088
+ disabled: composerDisabled,
2089
+ onChange: (event) => setDraft(event.target.value),
2090
+ onKeyDown: handleKeyDown,
2091
+ onCompositionStart: () => {
2092
+ composingRef.current = true;
2093
+ },
2094
+ onCompositionEnd: () => {
2095
+ composingRef.current = false;
2096
+ },
2097
+ "aria-label": "Ask a question",
2098
+ placeholder: composerDisabled ? phase === "limited" ? "Message limit reached \u2014 please try again later" : "Explore is unavailable right now" : focusedProductName ? `Ask about ${focusedProductName}\u2026` : "Ask anything about our products\u2026",
2099
+ className: "max-h-[200px] min-h-[44px] flex-1 resize-none border-0 bg-transparent px-2 py-2.5 text-sm shadow-none focus-visible:ring-0 md:text-sm"
2100
+ }
2101
+ ),
2102
+ busy ? /* @__PURE__ */ jsx(
2103
+ Button,
2104
+ {
2105
+ "data-boff-explore": "stop",
2106
+ type: "button",
2107
+ size: "icon",
2108
+ variant: "secondary",
2109
+ "aria-label": "Stop generating",
2110
+ onClick: stop,
2111
+ children: /* @__PURE__ */ jsx(Square, { className: "h-4 w-4" })
2112
+ }
2113
+ ) : /* @__PURE__ */ jsx(
2114
+ Button,
2115
+ {
2116
+ "data-boff-explore": "send",
2117
+ type: "submit",
2118
+ size: "icon",
2119
+ disabled: !canSubmit,
2120
+ "aria-label": "Send message",
2121
+ children: /* @__PURE__ */ jsx(ArrowUp, { className: "h-4 w-4" })
2122
+ }
2123
+ )
2124
+ ]
2125
+ }
2126
+ ),
2127
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground", children: [
2128
+ /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Enter to send \xB7 Shift + Enter for a new line" }),
2129
+ remainingToday !== null ? /* @__PURE__ */ jsxs("span", { "data-boff-explore": "remaining", children: [
2130
+ remainingToday,
2131
+ " message",
2132
+ remainingToday === 1 ? "" : "s",
2133
+ " left today"
2134
+ ] }) : null,
2135
+ /* @__PURE__ */ jsxs(
2136
+ "span",
2137
+ {
2138
+ className: cn(
2139
+ "ml-auto tabular-nums",
2140
+ overLimit && "font-medium text-destructive"
2141
+ ),
2142
+ children: [
2143
+ draft.length.toLocaleString(),
2144
+ " / ",
2145
+ maxLength.toLocaleString()
2146
+ ]
2147
+ }
2148
+ )
2149
+ ] }),
2150
+ /* @__PURE__ */ jsxs("p", { className: "mt-2 text-xs leading-relaxed text-muted-foreground", children: [
2151
+ "Answers are generated from our public documentation and can be imperfect \u2014 check anything important against the linked sources.",
2152
+ captchaOn ? /* @__PURE__ */ jsxs(Fragment, { children: [
2153
+ " ",
2154
+ "This site is protected by reCAPTCHA; the Google",
2155
+ " ",
2156
+ /* @__PURE__ */ jsx(
2157
+ "a",
2158
+ {
2159
+ href: "https://policies.google.com/privacy",
2160
+ target: "_blank",
2161
+ rel: "noopener noreferrer",
2162
+ className: "underline underline-offset-2 hover:text-foreground",
2163
+ children: "Privacy Policy"
2164
+ }
2165
+ ),
2166
+ " ",
2167
+ "and",
2168
+ " ",
2169
+ /* @__PURE__ */ jsx(
2170
+ "a",
2171
+ {
2172
+ href: "https://policies.google.com/terms",
2173
+ target: "_blank",
2174
+ rel: "noopener noreferrer",
2175
+ className: "underline underline-offset-2 hover:text-foreground",
2176
+ children: "Terms of Service"
2177
+ }
2178
+ ),
2179
+ " ",
2180
+ "apply."
2181
+ ] }) : null
2182
+ ] })
2183
+ ]
2184
+ }
2185
+ ) })
2186
+ ]
2187
+ }
2188
+ );
2189
+ }
2190
+
2191
+ export { ExplorePage };
2192
+ //# sourceMappingURL=explore.mjs.map
2193
+ //# sourceMappingURL=explore.mjs.map