@burdenoff/website-sdk 2026.1031.3 → 2026.1101.2

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 (274) hide show
  1. package/README.md +42 -8
  2. package/dist/analytics/index.js +19 -69
  3. package/dist/analytics/index.js.map +1 -1
  4. package/dist/analytics/index.mjs +3 -69
  5. package/dist/analytics/index.mjs.map +1 -1
  6. package/dist/avatar-live/index.js +1 -0
  7. package/dist/avatar-live/index.js.map +1 -1
  8. package/dist/avatar-live/index.mjs +1 -0
  9. package/dist/avatar-live/index.mjs.map +1 -1
  10. package/dist/avatar-live-view/index.js +10 -30
  11. package/dist/avatar-live-view/index.js.map +1 -1
  12. package/dist/avatar-live-view/index.mjs +4 -24
  13. package/dist/avatar-live-view/index.mjs.map +1 -1
  14. package/dist/chunk-23H4JUL4.js +41 -0
  15. package/dist/chunk-23H4JUL4.js.map +1 -0
  16. package/dist/chunk-34RX5P75.mjs +25 -0
  17. package/dist/chunk-34RX5P75.mjs.map +1 -0
  18. package/dist/chunk-3LFFY7AZ.js +184 -0
  19. package/dist/chunk-3LFFY7AZ.js.map +1 -0
  20. package/dist/chunk-3X26GE4S.js +2794 -0
  21. package/dist/chunk-3X26GE4S.js.map +1 -0
  22. package/dist/chunk-45GCA4GG.js +85 -0
  23. package/dist/chunk-45GCA4GG.js.map +1 -0
  24. package/dist/chunk-4SAGVLHN.js +876 -0
  25. package/dist/chunk-4SAGVLHN.js.map +1 -0
  26. package/dist/chunk-4U6YAII5.js +218 -0
  27. package/dist/chunk-4U6YAII5.js.map +1 -0
  28. package/dist/chunk-5GMTBOO6.js +21 -0
  29. package/dist/chunk-5GMTBOO6.js.map +1 -0
  30. package/dist/chunk-5JRJ57CL.mjs +329 -0
  31. package/dist/chunk-5JRJ57CL.mjs.map +1 -0
  32. package/dist/chunk-6C2DKIC7.js +4 -0
  33. package/dist/chunk-6C2DKIC7.js.map +1 -0
  34. package/dist/chunk-6IBFBWC5.mjs +17 -0
  35. package/dist/chunk-6IBFBWC5.mjs.map +1 -0
  36. package/dist/chunk-6KY2ZRVI.js +116 -0
  37. package/dist/chunk-6KY2ZRVI.js.map +1 -0
  38. package/dist/chunk-6VJT3SM4.mjs +182 -0
  39. package/dist/chunk-6VJT3SM4.mjs.map +1 -0
  40. package/dist/chunk-6YZUFMK2.mjs +40 -0
  41. package/dist/chunk-6YZUFMK2.mjs.map +1 -0
  42. package/dist/chunk-7A6R7CGG.js +47 -0
  43. package/dist/chunk-7A6R7CGG.js.map +1 -0
  44. package/dist/chunk-7PWL4V2R.js +4 -0
  45. package/dist/chunk-7PWL4V2R.js.map +1 -0
  46. package/dist/chunk-AA33WDYS.js +161 -0
  47. package/dist/chunk-AA33WDYS.js.map +1 -0
  48. package/dist/chunk-AHRGFXV2.js +525 -0
  49. package/dist/chunk-AHRGFXV2.js.map +1 -0
  50. package/dist/chunk-B63XLDZH.mjs +109 -0
  51. package/dist/chunk-B63XLDZH.mjs.map +1 -0
  52. package/dist/chunk-BX2USEWF.mjs +35 -0
  53. package/dist/chunk-BX2USEWF.mjs.map +1 -0
  54. package/dist/chunk-BYSZT35R.js +150 -0
  55. package/dist/chunk-BYSZT35R.js.map +1 -0
  56. package/dist/chunk-C6OJIHNO.js +12 -0
  57. package/dist/chunk-C6OJIHNO.js.map +1 -0
  58. package/dist/chunk-COOELBX7.mjs +63 -0
  59. package/dist/chunk-COOELBX7.mjs.map +1 -0
  60. package/dist/chunk-D2TW7MNC.mjs +2771 -0
  61. package/dist/chunk-D2TW7MNC.mjs.map +1 -0
  62. package/dist/chunk-D5KEZ6V6.mjs +3 -0
  63. package/dist/chunk-D5KEZ6V6.mjs.map +1 -0
  64. package/dist/chunk-E3GUGJMY.js +46 -0
  65. package/dist/chunk-E3GUGJMY.js.map +1 -0
  66. package/dist/chunk-EBZ2HGJ2.mjs +52 -0
  67. package/dist/chunk-EBZ2HGJ2.mjs.map +1 -0
  68. package/dist/chunk-EDLTUOIA.mjs +210 -0
  69. package/dist/chunk-EDLTUOIA.mjs.map +1 -0
  70. package/dist/chunk-EJQSOT4X.js +4 -0
  71. package/dist/chunk-EJQSOT4X.js.map +1 -0
  72. package/dist/chunk-EUPFS6MZ.mjs +2019 -0
  73. package/dist/chunk-EUPFS6MZ.mjs.map +1 -0
  74. package/dist/chunk-F3XWDC3B.js +77 -0
  75. package/dist/chunk-F3XWDC3B.js.map +1 -0
  76. package/dist/chunk-FFADMVIK.mjs +5127 -0
  77. package/dist/chunk-FFADMVIK.mjs.map +1 -0
  78. package/dist/chunk-FJWS7BKT.mjs +3 -0
  79. package/dist/chunk-FJWS7BKT.mjs.map +1 -0
  80. package/dist/chunk-FJZJDUOR.mjs +3 -0
  81. package/dist/chunk-FJZJDUOR.mjs.map +1 -0
  82. package/dist/chunk-GCFLCO2Z.mjs +145 -0
  83. package/dist/chunk-GCFLCO2Z.mjs.map +1 -0
  84. package/dist/chunk-GEXC4LRP.js +61 -0
  85. package/dist/chunk-GEXC4LRP.js.map +1 -0
  86. package/dist/chunk-GTRAXQGC.mjs +3 -0
  87. package/dist/chunk-GTRAXQGC.mjs.map +1 -0
  88. package/dist/chunk-IKOIRUKW.js +270 -0
  89. package/dist/chunk-IKOIRUKW.js.map +1 -0
  90. package/dist/chunk-IXTWOPRN.js +45 -0
  91. package/dist/chunk-IXTWOPRN.js.map +1 -0
  92. package/dist/chunk-JDXOXGOK.js +547 -0
  93. package/dist/chunk-JDXOXGOK.js.map +1 -0
  94. package/dist/chunk-JSLDWYV7.mjs +558 -0
  95. package/dist/chunk-JSLDWYV7.mjs.map +1 -0
  96. package/dist/chunk-JXLSTVBK.js +336 -0
  97. package/dist/chunk-JXLSTVBK.js.map +1 -0
  98. package/dist/chunk-KHYXK7FG.mjs +49 -0
  99. package/dist/chunk-KHYXK7FG.mjs.map +1 -0
  100. package/dist/chunk-KSMBOWQQ.js +2034 -0
  101. package/dist/chunk-KSMBOWQQ.js.map +1 -0
  102. package/dist/chunk-KU2PXHGB.mjs +83 -0
  103. package/dist/chunk-KU2PXHGB.mjs.map +1 -0
  104. package/dist/chunk-KZANIV3S.mjs +37 -0
  105. package/dist/chunk-KZANIV3S.mjs.map +1 -0
  106. package/dist/chunk-L4BP6YOB.js +20 -0
  107. package/dist/chunk-L4BP6YOB.js.map +1 -0
  108. package/dist/chunk-MRKA2OAF.mjs +75 -0
  109. package/dist/chunk-MRKA2OAF.mjs.map +1 -0
  110. package/dist/chunk-N5EC53MH.mjs +80 -0
  111. package/dist/chunk-N5EC53MH.mjs.map +1 -0
  112. package/dist/chunk-NZANQGDM.mjs +34 -0
  113. package/dist/chunk-NZANQGDM.mjs.map +1 -0
  114. package/dist/chunk-O4GS3XPZ.js +10 -0
  115. package/dist/chunk-O4GS3XPZ.js.map +1 -0
  116. package/dist/chunk-O76QDGRM.js +5154 -0
  117. package/dist/chunk-O76QDGRM.js.map +1 -0
  118. package/dist/chunk-OYEUNZJY.js +114 -0
  119. package/dist/chunk-OYEUNZJY.js.map +1 -0
  120. package/dist/chunk-PHXAGQNB.js +74 -0
  121. package/dist/chunk-PHXAGQNB.js.map +1 -0
  122. package/dist/chunk-PIHHPP7J.mjs +16 -0
  123. package/dist/chunk-PIHHPP7J.mjs.map +1 -0
  124. package/dist/chunk-PXRHVVOU.mjs +499 -0
  125. package/dist/chunk-PXRHVVOU.mjs.map +1 -0
  126. package/dist/chunk-QMA6U6AU.js +36 -0
  127. package/dist/chunk-QMA6U6AU.js.map +1 -0
  128. package/dist/chunk-R6J7IULF.js +44 -0
  129. package/dist/chunk-R6J7IULF.js.map +1 -0
  130. package/dist/chunk-R7G6TWIS.mjs +10 -0
  131. package/dist/chunk-R7G6TWIS.mjs.map +1 -0
  132. package/dist/chunk-RUMGFI6L.mjs +544 -0
  133. package/dist/chunk-RUMGFI6L.mjs.map +1 -0
  134. package/dist/chunk-S54JWSJF.js +565 -0
  135. package/dist/chunk-S54JWSJF.js.map +1 -0
  136. package/dist/chunk-SK5UGG6A.js +2041 -0
  137. package/dist/chunk-SK5UGG6A.js.map +1 -0
  138. package/dist/chunk-SKIYDKIS.mjs +70 -0
  139. package/dist/chunk-SKIYDKIS.mjs.map +1 -0
  140. package/dist/chunk-SZNS5IK6.mjs +322 -0
  141. package/dist/chunk-SZNS5IK6.mjs.map +1 -0
  142. package/dist/chunk-T7JIPZAC.js +66 -0
  143. package/dist/chunk-T7JIPZAC.js.map +1 -0
  144. package/dist/chunk-TGYQHO2E.mjs +864 -0
  145. package/dist/chunk-TGYQHO2E.mjs.map +1 -0
  146. package/dist/chunk-TT3MHN42.mjs +8 -0
  147. package/dist/chunk-TT3MHN42.mjs.map +1 -0
  148. package/dist/chunk-UM55U65W.mjs +268 -0
  149. package/dist/chunk-UM55U65W.mjs.map +1 -0
  150. package/dist/chunk-UQ2HALUD.js +72 -0
  151. package/dist/chunk-UQ2HALUD.js.map +1 -0
  152. package/dist/chunk-UXWT7G77.js +82 -0
  153. package/dist/chunk-UXWT7G77.js.map +1 -0
  154. package/dist/chunk-VNS5WDWO.mjs +7 -0
  155. package/dist/chunk-VNS5WDWO.mjs.map +1 -0
  156. package/dist/chunk-VRWZLGR7.js +4 -0
  157. package/dist/chunk-VRWZLGR7.js.map +1 -0
  158. package/dist/chunk-VZLDSNH4.mjs +22 -0
  159. package/dist/chunk-VZLDSNH4.mjs.map +1 -0
  160. package/dist/chunk-W6P3YETJ.js +92 -0
  161. package/dist/chunk-W6P3YETJ.js.map +1 -0
  162. package/dist/chunk-WPKFFQCR.mjs +90 -0
  163. package/dist/chunk-WPKFFQCR.mjs.map +1 -0
  164. package/dist/chunk-WTVTI5TO.mjs +22 -0
  165. package/dist/chunk-WTVTI5TO.mjs.map +1 -0
  166. package/dist/chunk-XJOBZ4RJ.js +44 -0
  167. package/dist/chunk-XJOBZ4RJ.js.map +1 -0
  168. package/dist/chunk-XP2JDNDU.js +325 -0
  169. package/dist/chunk-XP2JDNDU.js.map +1 -0
  170. package/dist/chunk-Y4V5CEWD.mjs +112 -0
  171. package/dist/chunk-Y4V5CEWD.mjs.map +1 -0
  172. package/dist/chunk-YERN2UWM.js +116 -0
  173. package/dist/chunk-YERN2UWM.js.map +1 -0
  174. package/dist/chunk-ZKJQWFAA.mjs +114 -0
  175. package/dist/chunk-ZKJQWFAA.mjs.map +1 -0
  176. package/dist/chunk-ZOON3S3Y.mjs +138 -0
  177. package/dist/chunk-ZOON3S3Y.mjs.map +1 -0
  178. package/dist/chunk-ZP6QRAYC.mjs +2024 -0
  179. package/dist/chunk-ZP6QRAYC.mjs.map +1 -0
  180. package/dist/chunk-ZSTFX7FV.js +9 -0
  181. package/dist/chunk-ZSTFX7FV.js.map +1 -0
  182. package/dist/client/index.js +23 -331
  183. package/dist/client/index.js.map +1 -1
  184. package/dist/client/index.mjs +3 -330
  185. package/dist/client/index.mjs.map +1 -1
  186. package/dist/comparison/index.js +28 -111
  187. package/dist/comparison/index.js.map +1 -1
  188. package/dist/comparison/index.mjs +2 -107
  189. package/dist/comparison/index.mjs.map +1 -1
  190. package/dist/components/contact.js +21 -931
  191. package/dist/components/contact.js.map +1 -1
  192. package/dist/components/contact.mjs +12 -909
  193. package/dist/components/contact.mjs.map +1 -1
  194. package/dist/components/electron-download.js +12 -124
  195. package/dist/components/electron-download.js.map +1 -1
  196. package/dist/components/electron-download.mjs +4 -106
  197. package/dist/components/electron-download.mjs.map +1 -1
  198. package/dist/components/explore-cta.js +8 -112
  199. package/dist/components/explore-cta.js.map +1 -1
  200. package/dist/components/explore-cta.mjs +3 -114
  201. package/dist/components/explore-cta.mjs.map +1 -1
  202. package/dist/components/explore.js +62 -7833
  203. package/dist/components/explore.js.map +1 -1
  204. package/dist/components/explore.mjs +13 -7800
  205. package/dist/components/explore.mjs.map +1 -1
  206. package/dist/components/launch-countdown.js +8 -83
  207. package/dist/components/launch-countdown.js.map +1 -1
  208. package/dist/components/launch-countdown.mjs +3 -85
  209. package/dist/components/launch-countdown.mjs.map +1 -1
  210. package/dist/components/newsletter.js +20 -993
  211. package/dist/components/newsletter.js.map +1 -1
  212. package/dist/components/newsletter.mjs +11 -971
  213. package/dist/components/newsletter.mjs.map +1 -1
  214. package/dist/components/partners.js +24 -1302
  215. package/dist/components/partners.js.map +1 -1
  216. package/dist/components/partners.mjs +15 -1276
  217. package/dist/components/partners.mjs.map +1 -1
  218. package/dist/components/pricing.js +49 -1249
  219. package/dist/components/pricing.js.map +1 -1
  220. package/dist/components/pricing.mjs +8 -1226
  221. package/dist/components/pricing.mjs.map +1 -1
  222. package/dist/components/problems-solved.js +8 -150
  223. package/dist/components/problems-solved.js.map +1 -1
  224. package/dist/components/problems-solved.mjs +4 -133
  225. package/dist/components/problems-solved.mjs.map +1 -1
  226. package/dist/components/resource-links.js +8 -304
  227. package/dist/components/resource-links.js.map +1 -1
  228. package/dist/components/resource-links.mjs +5 -308
  229. package/dist/components/resource-links.mjs.map +1 -1
  230. package/dist/components/social-links.js +8 -343
  231. package/dist/components/social-links.js.map +1 -1
  232. package/dist/components/social-links.mjs +5 -347
  233. package/dist/components/social-links.mjs.map +1 -1
  234. package/dist/components/unsubscribe.js +10 -627
  235. package/dist/components/unsubscribe.js.map +1 -1
  236. package/dist/components/unsubscribe.mjs +6 -611
  237. package/dist/components/unsubscribe.mjs.map +1 -1
  238. package/dist/components/waitlist.js +21 -1001
  239. package/dist/components/waitlist.js.map +1 -1
  240. package/dist/components/waitlist.mjs +12 -982
  241. package/dist/components/waitlist.mjs.map +1 -1
  242. package/dist/components/website-switcher.js +12 -175
  243. package/dist/components/website-switcher.js.map +1 -1
  244. package/dist/components/website-switcher.mjs +4 -157
  245. package/dist/components/website-switcher.mjs.map +1 -1
  246. package/dist/content/index.js +118 -3616
  247. package/dist/content/index.js.map +1 -1
  248. package/dist/content/index.mjs +12 -3567
  249. package/dist/content/index.mjs.map +1 -1
  250. package/dist/hooks/index.js +37 -2321
  251. package/dist/hooks/index.js.map +1 -1
  252. package/dist/hooks/index.mjs +6 -2318
  253. package/dist/hooks/index.mjs.map +1 -1
  254. package/dist/index.js +4145 -20599
  255. package/dist/index.js.map +1 -1
  256. package/dist/index.mjs +3766 -20567
  257. package/dist/index.mjs.map +1 -1
  258. package/dist/product/index.js +20 -393
  259. package/dist/product/index.js.map +1 -1
  260. package/dist/product/index.mjs +5 -394
  261. package/dist/product/index.mjs.map +1 -1
  262. package/dist/seo/index.js +8 -76
  263. package/dist/seo/index.js.map +1 -1
  264. package/dist/seo/index.mjs +3 -78
  265. package/dist/seo/index.mjs.map +1 -1
  266. package/dist/store/index.js +51 -2650
  267. package/dist/store/index.js.map +1 -1
  268. package/dist/store/index.mjs +13 -2619
  269. package/dist/store/index.mjs.map +1 -1
  270. package/dist/utils/index.js +69 -134
  271. package/dist/utils/index.js.map +1 -1
  272. package/dist/utils/index.mjs +5 -122
  273. package/dist/utils/index.mjs.map +1 -1
  274. package/package.json +2 -1
@@ -1,973 +1,13 @@
1
- import * as React from 'react';
2
- import { createContext, useRef, useState, useContext, useEffect, useCallback } from 'react';
3
- import { zodResolver } from '@hookform/resolvers/zod';
4
- import ReCAPTCHA from 'react-google-recaptcha';
5
- import { useForm } from 'react-hook-form';
6
- import { toast } from 'sonner';
7
- import { z } from 'zod';
8
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
- import { Helmet } from 'react-helmet-async';
10
- import { Slot } from '@radix-ui/react-slot';
11
- import { cva } from 'class-variance-authority';
12
- import { clsx } from 'clsx';
13
- import { twMerge } from 'tailwind-merge';
14
- import * as LabelPrimitive from '@radix-ui/react-label';
15
-
16
- var __defProp = Object.defineProperty;
17
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
18
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
-
20
- // src/client/security.ts
21
- var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
22
- var RESERVED_HEADERS = /* @__PURE__ */ new Set([
23
- "authorization",
24
- "cookie",
25
- "x-actor-id",
26
- "x-actor-type",
27
- "x-consent-granted-by",
28
- "x-consent-scope",
29
- "x-consent-granted-at",
30
- "x-consent-expires-at"
31
- ]);
32
- function validateGatewayUrl(value) {
33
- let url;
34
- try {
35
- url = new URL(value);
36
- } catch {
37
- throw new Error("Gateway URL must be a valid absolute URL");
38
- }
39
- if (url.protocol === "https:") {
40
- return url.toString();
41
- }
42
- if (url.protocol === "http:" && LOOPBACK_HOSTS.has(url.hostname.toLowerCase())) {
43
- return url.toString();
44
- }
45
- throw new Error("Gateway URL must use HTTPS unless it targets localhost");
46
- }
47
- function sanitizeHeaders(headers) {
48
- if (!headers) return void 0;
49
- return Object.fromEntries(
50
- Object.entries(headers).filter(
51
- ([key]) => !RESERVED_HEADERS.has(key.toLowerCase())
52
- )
53
- );
54
- }
55
- var CF_ACCESS_GATED_HOSTS = /* @__PURE__ */ new Set([
56
- "alphagraphql.burdenoff.com",
57
- "alphagraphqlworkspaces.burdenoff.com"
58
- ]);
59
- function cfAccessHeaders(gatewayUrl, cfAccess) {
60
- const clientId = cfAccess?.clientId?.trim();
61
- const clientSecret = cfAccess?.clientSecret?.trim();
62
- if (!clientId || !clientSecret) return {};
63
- let host;
64
- try {
65
- host = new URL(gatewayUrl).hostname.toLowerCase();
66
- } catch {
67
- return {};
68
- }
69
- if (!CF_ACCESS_GATED_HOSTS.has(host)) return {};
70
- return {
71
- "CF-Access-Client-Id": clientId,
72
- "CF-Access-Client-Secret": clientSecret
73
- };
74
- }
75
-
76
- // src/client/graphql-client.ts
77
- var _WebSDKClient = class _WebSDKClient {
78
- constructor(config) {
79
- __publicField(this, "config");
80
- __publicField(this, "queryCache", /* @__PURE__ */ new Map());
81
- __publicField(this, "inflight", /* @__PURE__ */ new Map());
82
- this.config = {
83
- ...config,
84
- gatewayUrl: validateGatewayUrl(config.gatewayUrl),
85
- headers: sanitizeHeaders(config.headers)
86
- };
87
- }
88
- getConfig() {
89
- return this.config;
90
- }
91
- /**
92
- * Execute a GraphQL query (with deduplication and caching).
93
- *
94
- * Pass `{ cache: false }` to bypass the cache entirely — required for poll
95
- * loops, where every tick must reach the network.
96
- */
97
- async query(query, variables, options) {
98
- if (options?.cache === false) {
99
- return this.request(query, variables, true, options.timeoutMs);
100
- }
101
- const cacheKey = JSON.stringify({ query, variables });
102
- const cached = this.queryCache.get(cacheKey);
103
- if (cached) {
104
- if (Date.now() - cached.ts < _WebSDKClient.CACHE_TTL) {
105
- return cached.data;
106
- }
107
- this.queryCache.delete(cacheKey);
108
- }
109
- const existing = this.inflight.get(cacheKey);
110
- if (existing) {
111
- return existing;
112
- }
113
- const promise = this.request(query, variables, true, options?.timeoutMs).then((result) => {
114
- if (result.data && !result.errors?.length) {
115
- if (this.queryCache.size >= _WebSDKClient.MAX_CACHE_ENTRIES) {
116
- const oldestEntry = this.queryCache.keys().next().value;
117
- if (oldestEntry) {
118
- this.queryCache.delete(oldestEntry);
119
- }
120
- }
121
- this.queryCache.set(cacheKey, { data: result, ts: Date.now() });
122
- }
123
- return result;
124
- }).finally(() => {
125
- this.inflight.delete(cacheKey);
126
- });
127
- this.inflight.set(cacheKey, promise);
128
- return promise;
129
- }
130
- /**
131
- * Execute a GraphQL mutation
132
- */
133
- async mutate(mutation, variables, options) {
134
- return this.request(mutation, variables, false, options?.timeoutMs);
135
- }
136
- /** HTTP statuses worth another attempt — transient server/edge conditions. */
137
- static isRetriableStatus(status) {
138
- return status === 429 || status === 408 || status >= 500 && status < 600;
139
- }
140
- static sleep(ms) {
141
- return new Promise((resolve) => setTimeout(resolve, ms));
142
- }
143
- /**
144
- * Perform the HTTP call with a hard timeout. Every outcome resolves to a
145
- * GraphQLResponse — callers never hang, so a UI's `loading` state always
146
- * settles into data or a renderable error.
147
- */
148
- async attempt(query, variables, timeoutMs) {
149
- const controller = new AbortController();
150
- const timer = setTimeout(() => controller.abort(), timeoutMs);
151
- try {
152
- const response = await fetch(this.config.gatewayUrl, {
153
- method: "POST",
154
- headers: {
155
- "Content-Type": "application/json",
156
- "x-product-id": this.config.productId,
157
- ...this.config.headers,
158
- ...cfAccessHeaders(this.config.gatewayUrl, this.config.cfAccess)
159
- },
160
- body: JSON.stringify({ query, variables }),
161
- signal: controller.signal
162
- });
163
- if (!response.ok) {
164
- console.error(
165
- "[WebSDK] GraphQL request failed",
166
- response.status,
167
- response.statusText
168
- );
169
- return {
170
- res: {
171
- errors: [
172
- {
173
- message: `HTTP ${response.status}: ${response.statusText}`,
174
- extensions: { code: `HTTP_${response.status}` }
175
- }
176
- ]
177
- },
178
- retriable: _WebSDKClient.isRetriableStatus(response.status)
179
- };
180
- }
181
- return {
182
- res: await response.json(),
183
- retriable: false
184
- };
185
- } catch (error) {
186
- const aborted = error instanceof Error && (error.name === "AbortError" || controller.signal.aborted);
187
- const message = aborted ? `Request timed out after ${timeoutMs}ms` : error instanceof Error ? error.message : "Network error";
188
- console.error("[WebSDK] Network error", message);
189
- return {
190
- res: {
191
- errors: [
192
- {
193
- message,
194
- extensions: { code: aborted ? "TIMEOUT" : "NETWORK_ERROR" }
195
- }
196
- ]
197
- },
198
- // Transport-level failures are worth one more try; a genuine outage
199
- // just fails twice quickly and still renders an error state.
200
- retriable: true
201
- };
202
- } finally {
203
- clearTimeout(timer);
204
- }
205
- }
206
- async request(query, variables, retry = true, timeoutOverrideMs) {
207
- const timeoutMs = timeoutOverrideMs ?? this.config.timeoutMs ?? _WebSDKClient.DEFAULT_TIMEOUT_MS;
208
- const maxRetries = retry ? this.config.maxRetries ?? _WebSDKClient.DEFAULT_MAX_RETRIES : 0;
209
- let last;
210
- for (let i = 0; i <= maxRetries; i++) {
211
- const { res, retriable } = await this.attempt(
212
- query,
213
- variables,
214
- timeoutMs
215
- );
216
- if (!retriable || i === maxRetries) return res;
217
- last = res;
218
- await _WebSDKClient.sleep(
219
- _WebSDKClient.RETRY_BASE_DELAY_MS * (i + 1) + Math.random() * 200
220
- );
221
- }
222
- return last;
223
- }
224
- };
225
- __publicField(_WebSDKClient, "CACHE_TTL", 5 * 60 * 1e3);
226
- // 5 minutes
227
- __publicField(_WebSDKClient, "MAX_CACHE_ENTRIES", 100);
228
- __publicField(_WebSDKClient, "DEFAULT_TIMEOUT_MS", 12e3);
229
- __publicField(_WebSDKClient, "DEFAULT_MAX_RETRIES", 1);
230
- __publicField(_WebSDKClient, "RETRY_BASE_DELAY_MS", 400);
231
- var WebSDKContext = createContext(null);
232
- function useWebSDK() {
233
- const client = useContext(WebSDKContext);
234
- if (!client) {
235
- throw new Error("useWebSDK must be used within a WebSDKProvider");
236
- }
237
- return client;
238
- }
239
- function useWebSDKConfig() {
240
- const client = useWebSDK();
241
- return client.getConfig();
242
- }
243
- var RECAPTCHA_WIDGET_HEIGHT = 78;
244
- function useDeferredRecaptcha(siteKey) {
245
- const [engaged, setEngaged] = useState(false);
246
- const arm = useCallback(() => setEngaged(true), []);
247
- const enabled = siteKey.length > 0;
248
- return {
249
- armed: enabled && engaged,
250
- arm,
251
- formProps: enabled && !engaged ? { onFocus: arm, onPointerDown: arm } : {}
252
- };
253
- }
254
-
255
- // src/utils/product-slug.ts
256
- var PRODUCT_SLUG_RENAMES = Object.freeze(
257
- [Object.freeze({ legacy: "botlit", current: "botmanor" })]
258
- );
259
- Object.freeze(
260
- Object.fromEntries(PRODUCT_SLUG_RENAMES.map((r) => [r.legacy, r.current]))
261
- );
262
- var ProductContext = createContext({
263
- product: null,
264
- loading: true,
265
- error: null,
266
- hasProvider: false,
267
- refetch: () => {
268
- }
269
- });
270
- function useProduct() {
271
- return useContext(ProductContext);
272
- }
273
- function useProductConfig() {
274
- const { product } = useProduct();
275
- const config = useWebSDKConfig();
276
- return {
277
- // Prefer product-level config, fall back to SDK config
278
- recaptchaSiteKey: product?.recaptchaSiteKey ?? config.recaptchaSiteKey ?? null,
279
- rybbitSiteId: product?.rybbitSiteId ?? config.rybbitSiteId ?? null,
280
- contactEmail: product?.contactEmail ?? null,
281
- supportEmail: product?.supportEmail ?? null,
282
- notificationEmail: product?.notificationEmail ?? product?.contactEmail ?? null,
283
- productName: product?.name ?? null,
284
- logoUrl: product?.logoUrl ?? null
285
- };
286
- }
287
- function canonicalFromLocation() {
288
- if (typeof window === "undefined" || !window.location) return void 0;
289
- const { origin, pathname } = window.location;
290
- if (!origin || origin === "null") return void 0;
291
- const path = pathname === "/" ? "/" : pathname.replace(/\/+$/, "");
292
- return `${origin}${path}`;
293
- }
294
- function resolveImageUrl(image, base) {
295
- if (!image || /^https?:\/\//i.test(image)) return image;
296
- if (!base) return image;
297
- try {
298
- return new URL(image, base).toString();
299
- } catch {
300
- return image;
301
- }
302
- }
303
- function serializeJsonLd(data) {
304
- return JSON.stringify(data).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
305
- }
306
- function PageHead({
307
- title,
308
- description,
309
- productName,
310
- keywords,
311
- image,
312
- url,
313
- favicon,
314
- robots = "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1",
315
- locale = "en_US",
316
- twitterHandle,
317
- themeColor = "#000000",
318
- author,
319
- structuredData,
320
- additionalMeta
321
- }) {
322
- const fullTitle = productName && !title.includes(productName) ? `${title} | ${productName}` : title;
323
- const resolvedUrl = url ?? canonicalFromLocation();
324
- const fullImageUrl = resolveImageUrl(image, resolvedUrl);
325
- const structuredDataItems = structuredData ? Array.isArray(structuredData) ? structuredData : [structuredData] : [];
326
- return /* @__PURE__ */ jsxs(Helmet, { children: [
327
- /* @__PURE__ */ jsx("title", { children: fullTitle }),
328
- /* @__PURE__ */ jsx("meta", { name: "title", content: fullTitle }),
329
- description && /* @__PURE__ */ jsx("meta", { name: "description", content: description }),
330
- keywords && /* @__PURE__ */ jsx("meta", { name: "keywords", content: keywords }),
331
- author && /* @__PURE__ */ jsx("meta", { name: "author", content: author }),
332
- /* @__PURE__ */ jsx("meta", { name: "robots", content: robots }),
333
- resolvedUrl && /* @__PURE__ */ jsx("link", { rel: "canonical", href: resolvedUrl }),
334
- favicon && /* @__PURE__ */ jsx("link", { rel: "icon", href: favicon }),
335
- /* @__PURE__ */ jsx("meta", { property: "og:type", content: "website" }),
336
- /* @__PURE__ */ jsx("meta", { property: "og:title", content: fullTitle }),
337
- description && /* @__PURE__ */ jsx("meta", { property: "og:description", content: description }),
338
- fullImageUrl && /* @__PURE__ */ jsx("meta", { property: "og:image", content: fullImageUrl }),
339
- resolvedUrl && /* @__PURE__ */ jsx("meta", { property: "og:url", content: resolvedUrl }),
340
- /* @__PURE__ */ jsx("meta", { property: "og:locale", content: locale }),
341
- productName && /* @__PURE__ */ jsx("meta", { property: "og:site_name", content: productName }),
342
- /* @__PURE__ */ jsx("meta", { name: "twitter:card", content: "summary_large_image" }),
343
- /* @__PURE__ */ jsx("meta", { name: "twitter:title", content: fullTitle }),
344
- description && /* @__PURE__ */ jsx("meta", { name: "twitter:description", content: description }),
345
- fullImageUrl && /* @__PURE__ */ jsx("meta", { name: "twitter:image", content: fullImageUrl }),
346
- twitterHandle && /* @__PURE__ */ jsx("meta", { name: "twitter:creator", content: twitterHandle }),
347
- /* @__PURE__ */ jsx("meta", { name: "theme-color", content: themeColor }),
348
- structuredDataItems.map((data, index) => /* @__PURE__ */ jsx("script", { type: "application/ld+json", children: serializeJsonLd(data) }, `ld-${index}`)),
349
- additionalMeta?.map((meta, index) => /* @__PURE__ */ jsx(
350
- "meta",
351
- {
352
- ...meta.name ? { name: meta.name } : {},
353
- ...meta.property ? { property: meta.property } : {},
354
- content: meta.content
355
- },
356
- `meta-${index}`
357
- ))
358
- ] });
359
- }
360
- function cn(...inputs) {
361
- return twMerge(clsx(inputs));
362
- }
363
- var buttonVariants = cva(
364
- "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",
365
- {
366
- variants: {
367
- variant: {
368
- default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
369
- destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
370
- outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
371
- secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
372
- ghost: "hover:bg-accent hover:text-accent-foreground",
373
- link: "text-primary underline-offset-4 hover:underline"
374
- },
375
- size: {
376
- default: "h-9 px-4 py-2",
377
- sm: "h-8 rounded-md px-3 text-xs",
378
- lg: "h-10 rounded-md px-8",
379
- icon: "h-9 w-9"
380
- }
381
- },
382
- defaultVariants: {
383
- variant: "default",
384
- size: "default"
385
- }
386
- }
387
- );
388
- var Button = React.forwardRef(
389
- ({ className, variant, size, asChild = false, ...props }, ref) => {
390
- const Comp = asChild ? Slot : "button";
391
- return /* @__PURE__ */ jsx(
392
- Comp,
393
- {
394
- className: cn(buttonVariants({ variant, size, className })),
395
- ref,
396
- ...props
397
- }
398
- );
399
- }
400
- );
401
- Button.displayName = "Button";
402
- var Input = React.forwardRef(
403
- ({ className, type, ...props }, ref) => {
404
- return /* @__PURE__ */ jsx(
405
- "input",
406
- {
407
- type,
408
- className: cn(
409
- "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground 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",
410
- className
411
- ),
412
- ref,
413
- ...props
414
- }
415
- );
416
- }
417
- );
418
- Input.displayName = "Input";
419
- var labelVariants = cva(
420
- "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
421
- );
422
- var Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
423
- LabelPrimitive.Root,
424
- {
425
- ref,
426
- className: cn(labelVariants(), className),
427
- ...props
428
- }
429
- ));
430
- Label.displayName = LabelPrimitive.Root.displayName;
431
- var newsletterSchema = z.object({
432
- email: z.string().email("Please enter a valid email address")
433
- });
434
- var SUBSCRIBE_MUTATION = (
435
- /* GraphQL */
436
- `
437
- mutation Subscribe($input: SubscribeInput!) {
438
- subscribe(input: $input) {
439
- id
440
- email
441
- alreadySubscribed
442
- status
443
- subscribedAt
444
- }
445
- }
446
- `
447
- );
448
- async function subscribeNewsletter(client, email, productId, recaptchaToken) {
449
- try {
450
- const result = await client.mutate(SUBSCRIBE_MUTATION, {
451
- input: {
452
- email: email.trim().toLowerCase(),
453
- platformProductId: productId,
454
- metadata: {
455
- source: "website",
456
- referrer: typeof window !== "undefined" ? window.location.href : "",
457
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
458
- ...recaptchaToken ? { recaptchaToken } : {}
459
- }
460
- }
461
- });
462
- if (result.errors?.length) {
463
- const errorMsg = result.errors[0]?.message ?? "Subscription failed";
464
- const code = result.errors[0]?.extensions?.code;
465
- if (code === "DUPLICATE_SUBSCRIBER" || errorMsg.toLowerCase().includes("already subscribed")) {
466
- return {
467
- success: true,
468
- message: "You are already part of this newsletter."
469
- };
470
- }
471
- return { success: false, message: errorMsg };
472
- }
473
- if (result.data?.subscribe?.alreadySubscribed) {
474
- return {
475
- success: true,
476
- message: "You are already part of this newsletter."
477
- };
478
- }
479
- return { success: true };
480
- } catch (error) {
481
- console.error("Newsletter subscription error:", error);
482
- return { success: false, message: "Network error. Please try again." };
483
- }
484
- }
485
- function useRateLimit(maxAttempts, windowMinutes) {
486
- const rateLimitRef = useRef(null);
487
- const [isLimited, setIsLimited] = useState(false);
488
- const [resetTime, setResetTime] = useState(null);
489
- useEffect(() => {
490
- const state = rateLimitRef.current;
491
- if (state && Date.now() > state.resetTime) {
492
- rateLimitRef.current = null;
493
- setIsLimited(false);
494
- setResetTime(null);
495
- } else if (state && state.attempts >= maxAttempts) {
496
- setIsLimited(true);
497
- setResetTime(new Date(state.resetTime));
498
- }
499
- }, [maxAttempts]);
500
- function recordAttempt() {
501
- const now = Date.now();
502
- const state = rateLimitRef.current;
503
- if (state && now > state.resetTime) {
504
- rateLimitRef.current = null;
505
- }
506
- const current = rateLimitRef.current;
507
- if (!current) {
508
- rateLimitRef.current = {
509
- attempts: 1,
510
- resetTime: now + windowMinutes * 60 * 1e3
511
- };
512
- return false;
513
- }
514
- current.attempts += 1;
515
- if (current.attempts >= maxAttempts) {
516
- setIsLimited(true);
517
- setResetTime(new Date(current.resetTime));
518
- return true;
519
- }
520
- return false;
521
- }
522
- function checkLimit() {
523
- const state = rateLimitRef.current;
524
- if (!state) return false;
525
- if (Date.now() > state.resetTime) {
526
- rateLimitRef.current = null;
527
- setIsLimited(false);
528
- setResetTime(null);
529
- return false;
530
- }
531
- return state.attempts >= maxAttempts;
532
- }
533
- return { isLimited, resetTime, recordAttempt, checkLimit };
534
- }
535
- function NewsletterPage({
536
- productName,
537
- layout = "centered",
538
- rateLimitAttempts = 3,
539
- rateLimitWindowMinutes = 15,
540
- heroHeading = "Stay Updated",
541
- heroSubtitle = "Subscribe to our newsletter",
542
- heroDescription,
543
- features,
544
- successMessage = "Successfully subscribed to newsletter!",
545
- errorMessage = "Failed to subscribe. Please try again.",
546
- rateLimitMessage,
547
- className,
548
- seoTitle,
549
- seoDescription,
550
- seoKeywords,
551
- seoImage,
552
- seoUrl,
553
- recaptchaSiteKey
554
- }) {
555
- const client = useWebSDK();
556
- const config = useWebSDKConfig();
557
- const { product } = useProduct();
558
- const productConfig = useProductConfig();
559
- const effectiveProductId = product?.id || config.productId;
560
- const displayName = productName ?? product?.name ?? config.productId;
561
- const effectiveRecaptchaSiteKey = recaptchaSiteKey ?? productConfig.recaptchaSiteKey ?? config.recaptchaSiteKey ?? "";
562
- const recaptchaRef = useRef(null);
563
- const [isSubmitting, setIsSubmitting] = useState(false);
564
- const { isLimited, resetTime, recordAttempt, checkLimit } = useRateLimit(
565
- rateLimitAttempts,
566
- rateLimitWindowMinutes
567
- );
568
- const {
569
- register,
570
- handleSubmit,
571
- formState: { errors },
572
- reset
573
- } = useForm({
574
- resolver: zodResolver(newsletterSchema)
575
- });
576
- const onSubmit = async (data) => {
577
- const recaptchaToken = recaptchaRef.current?.getValue() ?? "";
578
- if (effectiveRecaptchaSiteKey && !recaptchaToken) {
579
- toast.error("Please complete the reCAPTCHA verification");
580
- return;
581
- }
582
- if (checkLimit()) {
583
- toast.error(
584
- rateLimitMessage ?? `Too many attempts. Please try again after ${resetTime?.toLocaleTimeString()}`
585
- );
586
- return;
587
- }
588
- setIsSubmitting(true);
589
- try {
590
- const result = await subscribeNewsletter(
591
- client,
592
- data.email,
593
- effectiveProductId,
594
- recaptchaToken || void 0
595
- );
596
- if (result.success) {
597
- if (result.message) {
598
- toast.info(result.message);
599
- } else {
600
- toast.success(successMessage);
601
- }
602
- reset();
603
- } else {
604
- toast.error(result.message ?? errorMessage);
605
- }
606
- recordAttempt();
607
- recaptchaRef.current?.reset();
608
- } catch (_error) {
609
- toast.error(errorMessage);
610
- recaptchaRef.current?.reset();
611
- } finally {
612
- setIsSubmitting(false);
613
- }
614
- };
615
- const defaultFeatures = [
616
- {
617
- icon: /* @__PURE__ */ jsx(
618
- "svg",
619
- {
620
- className: "h-6 w-6",
621
- fill: "none",
622
- stroke: "currentColor",
623
- viewBox: "0 0 24 24",
624
- children: /* @__PURE__ */ jsx(
625
- "path",
626
- {
627
- strokeLinecap: "round",
628
- strokeLinejoin: "round",
629
- strokeWidth: 2,
630
- d: "M13 10V3L4 14h7v7l9-11h-7z"
631
- }
632
- )
633
- }
634
- ),
635
- title: "Latest Updates",
636
- description: "Get the latest news and updates delivered to your inbox"
637
- },
638
- {
639
- icon: /* @__PURE__ */ jsx(
640
- "svg",
641
- {
642
- className: "h-6 w-6",
643
- fill: "none",
644
- stroke: "currentColor",
645
- viewBox: "0 0 24 24",
646
- children: /* @__PURE__ */ jsx(
647
- "path",
648
- {
649
- strokeLinecap: "round",
650
- strokeLinejoin: "round",
651
- strokeWidth: 2,
652
- d: "M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"
653
- }
654
- )
655
- }
656
- ),
657
- title: "Exclusive Content",
658
- description: "Access exclusive content and insights not available elsewhere"
659
- },
660
- {
661
- icon: /* @__PURE__ */ jsx(
662
- "svg",
663
- {
664
- className: "h-6 w-6",
665
- fill: "none",
666
- stroke: "currentColor",
667
- viewBox: "0 0 24 24",
668
- children: /* @__PURE__ */ jsx(
669
- "path",
670
- {
671
- strokeLinecap: "round",
672
- strokeLinejoin: "round",
673
- strokeWidth: 2,
674
- d: "M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
675
- }
676
- )
677
- }
678
- ),
679
- title: "Early Access",
680
- description: "Be the first to know about new features and product launches"
681
- }
682
- ];
683
- const displayFeatures = features ?? defaultFeatures;
684
- return /* @__PURE__ */ jsxs(Fragment, { children: [
685
- seoTitle && /* @__PURE__ */ jsx(
686
- PageHead,
687
- {
688
- title: seoTitle,
689
- description: seoDescription ?? heroDescription ?? heroSubtitle,
690
- productName: displayName,
691
- keywords: seoKeywords,
692
- image: seoImage,
693
- url: seoUrl
694
- }
695
- ),
696
- /* @__PURE__ */ jsx("div", { className, children: layout === "centered" ? (
697
- // Centered Layout
698
- /* @__PURE__ */ jsx("div", { className: "min-h-screen flex items-center justify-center px-4 py-12", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md w-full space-y-8", children: [
699
- /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
700
- /* @__PURE__ */ jsx("h1", { className: "text-4xl font-bold tracking-tight", children: heroHeading }),
701
- /* @__PURE__ */ jsx("p", { className: "mt-2 text-lg text-muted-foreground", children: heroSubtitle }),
702
- heroDescription && /* @__PURE__ */ jsx("p", { className: "mt-4 text-sm text-muted-foreground", children: heroDescription })
703
- ] }),
704
- /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit(onSubmit), className: "space-y-6", children: [
705
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
706
- /* @__PURE__ */ jsx(Label, { htmlFor: "email", children: "Email address" }),
707
- /* @__PURE__ */ jsx(
708
- Input,
709
- {
710
- id: "email",
711
- type: "email",
712
- placeholder: "you@example.com",
713
- disabled: isSubmitting || isLimited,
714
- ...register("email")
715
- }
716
- ),
717
- errors.email && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: errors.email.message })
718
- ] }),
719
- effectiveRecaptchaSiteKey && /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
720
- ReCAPTCHA,
721
- {
722
- ref: recaptchaRef,
723
- sitekey: effectiveRecaptchaSiteKey
724
- }
725
- ) }),
726
- /* @__PURE__ */ jsx(
727
- Button,
728
- {
729
- type: "submit",
730
- className: "w-full",
731
- disabled: isSubmitting || isLimited,
732
- children: isSubmitting ? "Subscribing..." : "Subscribe"
733
- }
734
- ),
735
- isLimited && resetTime && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground text-center", children: [
736
- "Rate limit reached. Try again after",
737
- " ",
738
- resetTime.toLocaleTimeString()
739
- ] })
740
- ] }),
741
- /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground text-center", children: [
742
- "By subscribing, you agree to receive emails from ",
743
- displayName,
744
- ". You can unsubscribe at any time."
745
- ] })
746
- ] }) })
747
- ) : (
748
- // Split Layout
749
- /* @__PURE__ */ jsxs("div", { className: "min-h-screen grid lg:grid-cols-2", children: [
750
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center px-4 py-12 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md w-full space-y-8", children: [
751
- /* @__PURE__ */ jsxs("div", { children: [
752
- /* @__PURE__ */ jsx("h1", { className: "text-4xl font-bold tracking-tight", children: heroHeading }),
753
- /* @__PURE__ */ jsx("p", { className: "mt-2 text-lg text-muted-foreground", children: heroSubtitle }),
754
- heroDescription && /* @__PURE__ */ jsx("p", { className: "mt-4 text-sm text-muted-foreground", children: heroDescription })
755
- ] }),
756
- /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit(onSubmit), className: "space-y-6", children: [
757
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
758
- /* @__PURE__ */ jsx(Label, { htmlFor: "email", children: "Email address" }),
759
- /* @__PURE__ */ jsx(
760
- Input,
761
- {
762
- id: "email",
763
- type: "email",
764
- placeholder: "you@example.com",
765
- disabled: isSubmitting || isLimited,
766
- ...register("email")
767
- }
768
- ),
769
- errors.email && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: errors.email.message })
770
- ] }),
771
- effectiveRecaptchaSiteKey && /* @__PURE__ */ jsx("div", { className: "flex justify-center sm:justify-start", children: /* @__PURE__ */ jsx(
772
- ReCAPTCHA,
773
- {
774
- ref: recaptchaRef,
775
- sitekey: effectiveRecaptchaSiteKey
776
- }
777
- ) }),
778
- /* @__PURE__ */ jsx(
779
- Button,
780
- {
781
- type: "submit",
782
- className: "w-full",
783
- disabled: isSubmitting || isLimited,
784
- children: isSubmitting ? "Subscribing..." : "Subscribe"
785
- }
786
- ),
787
- isLimited && resetTime && /* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground text-center", children: [
788
- "Rate limit reached. Try again after",
789
- " ",
790
- resetTime.toLocaleTimeString()
791
- ] })
792
- ] }),
793
- /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
794
- "By subscribing, you agree to receive emails from ",
795
- displayName,
796
- ". You can unsubscribe at any time."
797
- ] })
798
- ] }) }),
799
- /* @__PURE__ */ jsx("div", { className: "hidden lg:flex items-center justify-center bg-muted px-4 py-12 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxs("div", { className: "max-w-md space-y-8", children: [
800
- /* @__PURE__ */ jsx("h2", { className: "text-2xl font-bold", children: "Why Subscribe?" }),
801
- /* @__PURE__ */ jsx("div", { className: "space-y-6", children: displayFeatures.map((feature, index) => /* @__PURE__ */ jsxs("div", { className: "flex gap-4", children: [
802
- /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 text-primary", children: feature.icon }),
803
- /* @__PURE__ */ jsxs("div", { children: [
804
- /* @__PURE__ */ jsx("h3", { className: "font-semibold", children: feature.title }),
805
- /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: feature.description })
806
- ] })
807
- ] }, index)) })
808
- ] }) })
809
- ] })
810
- ) })
811
- ] });
812
- }
813
- function NewsletterForm({
814
- variant = "inline",
815
- showLabel = false,
816
- showDescription = false,
817
- description = "Subscribe to our newsletter for updates",
818
- buttonText = "Subscribe",
819
- className = "",
820
- recaptchaSiteKey
821
- }) {
822
- const client = useWebSDK();
823
- const config = useWebSDKConfig();
824
- const { product } = useProduct();
825
- const productConfig = useProductConfig();
826
- const effectiveProductId = product?.id || config.productId;
827
- const effectiveRecaptchaSiteKey = recaptchaSiteKey ?? productConfig.recaptchaSiteKey ?? config.recaptchaSiteKey ?? "";
828
- const recaptchaRef = useRef(null);
829
- const recaptchaGate = useDeferredRecaptcha(effectiveRecaptchaSiteKey);
830
- const [email, setEmail] = useState("");
831
- const [isLoading, setIsLoading] = useState(false);
832
- const handleSubmit = async (e) => {
833
- e.preventDefault();
834
- if (!email || !email.includes("@")) {
835
- toast.error("Please enter a valid email address");
836
- return;
837
- }
838
- const recaptchaToken = recaptchaRef.current?.getValue() ?? "";
839
- if (effectiveRecaptchaSiteKey && !recaptchaToken) {
840
- recaptchaGate.arm();
841
- toast.error("Please complete the reCAPTCHA verification");
842
- return;
843
- }
844
- setIsLoading(true);
845
- try {
846
- const result = await subscribeNewsletter(
847
- client,
848
- email,
849
- effectiveProductId,
850
- recaptchaToken || void 0
851
- );
852
- if (result.success) {
853
- if (result.message) {
854
- toast.info(result.message);
855
- } else {
856
- toast.success("Successfully subscribed!");
857
- }
858
- setEmail("");
859
- } else {
860
- toast.error(result.message ?? "Subscription failed");
861
- }
862
- recaptchaRef.current?.reset();
863
- } catch (_error) {
864
- toast.error("An error occurred. Please try again.");
865
- recaptchaRef.current?.reset();
866
- } finally {
867
- setIsLoading(false);
868
- }
869
- };
870
- const isInline = variant === "inline";
871
- return /* @__PURE__ */ jsxs("div", { className, style: { overflow: "visible" }, children: [
872
- showDescription && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-3", children: description }),
873
- /* @__PURE__ */ jsxs(
874
- "form",
875
- {
876
- onSubmit: handleSubmit,
877
- className: isInline ? "flex flex-col gap-2" : "flex flex-col gap-2",
878
- style: { overflow: "visible" },
879
- ...recaptchaGate.formProps,
880
- children: [
881
- /* @__PURE__ */ jsxs(
882
- "div",
883
- {
884
- className: isInline && !effectiveRecaptchaSiteKey ? "flex gap-2" : "flex flex-col gap-2",
885
- children: [
886
- /* @__PURE__ */ jsxs(
887
- "div",
888
- {
889
- className: isInline && !effectiveRecaptchaSiteKey ? "flex-1" : "w-full",
890
- children: [
891
- showLabel && /* @__PURE__ */ jsx(Label, { htmlFor: "newsletter-email", className: "text-sm mb-1 block", children: "Email" }),
892
- /* @__PURE__ */ jsx(
893
- Input,
894
- {
895
- id: "newsletter-email",
896
- type: "email",
897
- placeholder: "Enter your email",
898
- value: email,
899
- onChange: (e) => setEmail(e.target.value),
900
- disabled: isLoading,
901
- required: true,
902
- className: "w-full"
903
- }
904
- )
905
- ]
906
- }
907
- ),
908
- !effectiveRecaptchaSiteKey && /* @__PURE__ */ jsx(
909
- Button,
910
- {
911
- type: "submit",
912
- disabled: isLoading,
913
- className: isInline ? "whitespace-nowrap" : "w-full",
914
- children: isLoading ? "Subscribing..." : buttonText
915
- }
916
- )
917
- ]
918
- }
919
- ),
920
- effectiveRecaptchaSiteKey && /* @__PURE__ */ jsxs(Fragment, { children: [
921
- /* @__PURE__ */ jsx("style", { children: `
922
- body > div[style*="position: absolute"] > div > iframe[title*="recaptcha challenge"],
923
- body > div:not([class]):not([id]) > div > iframe[title*="recaptcha"] {
924
- position: fixed !important;
925
- top: 50% !important;
926
- left: 50% !important;
927
- transform: translate(-50%, -50%) !important;
928
- z-index: 99999 !important;
929
- }
930
- body > div[style*="position: absolute"]:has(iframe[title*="recaptcha challenge"]) {
931
- position: fixed !important;
932
- top: 0 !important;
933
- left: 0 !important;
934
- width: 100vw !important;
935
- height: 100vh !important;
936
- display: flex !important;
937
- align-items: center !important;
938
- justify-content: center !important;
939
- z-index: 99999 !important;
940
- background: rgba(0,0,0,0.3) !important;
941
- }
942
- ` }),
943
- /* @__PURE__ */ jsx(
944
- "div",
945
- {
946
- style: {
947
- position: "relative",
948
- zIndex: 50,
949
- display: "flex",
950
- justifyContent: "flex-start",
951
- minHeight: RECAPTCHA_WIDGET_HEIGHT
952
- },
953
- children: recaptchaGate.armed && /* @__PURE__ */ jsx(
954
- ReCAPTCHA,
955
- {
956
- ref: recaptchaRef,
957
- sitekey: effectiveRecaptchaSiteKey,
958
- size: "normal"
959
- }
960
- )
961
- }
962
- )
963
- ] }),
964
- effectiveRecaptchaSiteKey && /* @__PURE__ */ jsx(Button, { type: "submit", disabled: isLoading, className: "w-full", children: isLoading ? "Subscribing..." : buttonText })
965
- ]
966
- }
967
- )
968
- ] });
969
- }
970
-
971
- export { NewsletterForm, NewsletterPage };
1
+ export { NewsletterForm, NewsletterPage } from '../chunk-JSLDWYV7.mjs';
2
+ import '../chunk-6IBFBWC5.mjs';
3
+ import '../chunk-WTVTI5TO.mjs';
4
+ import '../chunk-34RX5P75.mjs';
5
+ import '../chunk-N5EC53MH.mjs';
6
+ import '../chunk-KHYXK7FG.mjs';
7
+ import '../chunk-R7G6TWIS.mjs';
8
+ import '../chunk-GCFLCO2Z.mjs';
9
+ import '../chunk-KZANIV3S.mjs';
10
+ import '../chunk-5JRJ57CL.mjs';
11
+ import '../chunk-VNS5WDWO.mjs';
972
12
  //# sourceMappingURL=newsletter.mjs.map
973
13
  //# sourceMappingURL=newsletter.mjs.map