@bowlos/reservations 0.36.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/AGENTS.md +300 -0
  2. package/HEADLESS.md +534 -10
  3. package/README.md +242 -2
  4. package/dist/{data-BJkB-tvM.d.cts → account-DEX2Lr78.d.cts} +208 -1
  5. package/dist/{data-BJkB-tvM.d.ts → account-DEX2Lr78.d.ts} +208 -1
  6. package/dist/booking-change-4DGu-B08.d.ts +1282 -0
  7. package/dist/booking-change-aK6P37FZ.d.cts +1282 -0
  8. package/dist/{chunk-3JSVEOKG.js → chunk-44WKP6MW.js} +32 -5
  9. package/dist/chunk-44WKP6MW.js.map +1 -0
  10. package/dist/{chunk-TEHRROVY.js → chunk-BWJHRJN6.js} +47 -192
  11. package/dist/chunk-BWJHRJN6.js.map +1 -0
  12. package/dist/{chunk-Y3YSDO3H.js → chunk-FMFHNBDH.js} +56 -5
  13. package/dist/chunk-FMFHNBDH.js.map +1 -0
  14. package/dist/chunk-I37IJNYU.js +139 -0
  15. package/dist/chunk-I37IJNYU.js.map +1 -0
  16. package/dist/chunk-VJIS56OO.js +717 -0
  17. package/dist/chunk-VJIS56OO.js.map +1 -0
  18. package/dist/cli.cjs +29 -3
  19. package/dist/cli.cjs.map +1 -1
  20. package/dist/components.cjs +1595 -2
  21. package/dist/components.cjs.map +1 -1
  22. package/dist/components.d.cts +208 -7
  23. package/dist/components.d.ts +208 -7
  24. package/dist/components.js +1045 -7
  25. package/dist/components.js.map +1 -1
  26. package/dist/index.cjs +270 -3
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +56 -5
  29. package/dist/index.d.ts +56 -5
  30. package/dist/index.js +58 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/payments.cjs +203 -0
  33. package/dist/payments.cjs.map +1 -1
  34. package/dist/payments.d.cts +16 -2
  35. package/dist/payments.d.ts +16 -2
  36. package/dist/payments.js +78 -2
  37. package/dist/payments.js.map +1 -1
  38. package/dist/{react-0MyyTtE4.d.ts → react-CrRciA7I.d.ts} +2 -2
  39. package/dist/{react-CWAG4cW0.d.cts → react-QJrsaOnN.d.cts} +2 -2
  40. package/dist/react.cjs +758 -27
  41. package/dist/react.cjs.map +1 -1
  42. package/dist/react.d.cts +139 -12
  43. package/dist/react.d.ts +139 -12
  44. package/dist/react.js +72 -4
  45. package/dist/react.js.map +1 -1
  46. package/package.json +8 -2
  47. package/templates/center-site/README.md +5 -0
  48. package/templates/center-site/app/account/game-cards/page.tsx +17 -0
  49. package/templates/center-site/app/account/layout.tsx +16 -0
  50. package/templates/center-site/app/account/memberships/[id]/page.tsx +23 -0
  51. package/templates/center-site/app/account/memberships/page.tsx +33 -0
  52. package/templates/center-site/app/account/orders/page.tsx +17 -0
  53. package/templates/center-site/app/account/page.tsx +14 -0
  54. package/templates/center-site/app/account/payment-methods/page.tsx +23 -0
  55. package/templates/center-site/app/account/privacy/page.tsx +17 -0
  56. package/templates/center-site/app/account/profile/page.tsx +45 -0
  57. package/templates/center-site/app/account/reservations/[displayId]/change/page.tsx +46 -0
  58. package/templates/center-site/app/account/reservations/[displayId]/page.tsx +41 -0
  59. package/templates/center-site/app/account/reservations/page.tsx +35 -0
  60. package/templates/center-site/app/account/security/page.tsx +17 -0
  61. package/templates/center-site/app/events/[slug]/page.tsx +130 -0
  62. package/templates/center-site/app/events/page.tsx +57 -0
  63. package/templates/center-site/app/pay/[token]/page.tsx +53 -0
  64. package/templates/center-site/app/site-header.tsx +1 -0
  65. package/templates/center-site/lib/reservation.ts +14 -0
  66. package/templates/center-site/package.json +1 -1
  67. package/templates/center-site/tsconfig.json +7 -9
  68. package/dist/account-DfM2COaz.d.ts +0 -210
  69. package/dist/account-oCvYWmO9.d.cts +0 -210
  70. package/dist/catalog-DbhdwmnX.d.cts +0 -224
  71. package/dist/catalog-XkjgPI5C.d.ts +0 -224
  72. package/dist/chunk-3JSVEOKG.js.map +0 -1
  73. package/dist/chunk-TEHRROVY.js.map +0 -1
  74. package/dist/chunk-Y3YSDO3H.js.map +0 -1
package/dist/payments.cjs CHANGED
@@ -251,6 +251,209 @@ function PayForm({
251
251
  ] });
252
252
  }
253
253
 
254
+ // src/errors.ts
255
+ var BOWLOS_ERROR_CODES = {
256
+ // Gateway front door
257
+ API_KEY_MISSING: "API_KEY_MISSING",
258
+ API_KEY_INVALID: "API_KEY_INVALID",
259
+ ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED",
260
+ RATE_LIMITED: "RATE_LIMITED",
261
+ INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
262
+ PERMISSION_DENIED: "PERMISSION_DENIED",
263
+ SCOPE_REVOKED: "SCOPE_REVOKED"};
264
+ var BowlosApiError = class _BowlosApiError extends Error {
265
+ /** Stable, machine-readable code. Branch on this, not on `message`. */
266
+ code;
267
+ /** HTTP status (0 for a network failure before any response). */
268
+ status;
269
+ details;
270
+ /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */
271
+ retryAfterSeconds;
272
+ constructor(code, message, status, options = {}) {
273
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
274
+ this.name = "BowlosApiError";
275
+ this.code = code;
276
+ this.status = status;
277
+ this.details = options.details;
278
+ this.retryAfterSeconds = options.retryAfterSeconds;
279
+ Object.setPrototypeOf(this, _BowlosApiError.prototype);
280
+ }
281
+ /** Too many requests — caller should back off `retryAfterSeconds`. */
282
+ get isRateLimited() {
283
+ return this.code === BOWLOS_ERROR_CODES.RATE_LIMITED;
284
+ }
285
+ /** Bad/expired login. The session could not be established or has lapsed. */
286
+ get isAuthError() {
287
+ return this.code === BOWLOS_ERROR_CODES.INVALID_CREDENTIALS || this.code === BOWLOS_ERROR_CODES.PERMISSION_DENIED || this.code === BOWLOS_ERROR_CODES.SCOPE_REVOKED;
288
+ }
289
+ /** Wrong/missing API key or a disallowed origin — a site-config problem,
290
+ * not something the end customer can fix. */
291
+ get isConfigError() {
292
+ return this.code === BOWLOS_ERROR_CODES.API_KEY_MISSING || this.code === BOWLOS_ERROR_CODES.API_KEY_INVALID || this.code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED;
293
+ }
294
+ };
295
+ var BowlosContext = react.createContext(null);
296
+ react.createContext(null);
297
+ function useBowlosClient() {
298
+ const client = react.useContext(BowlosContext);
299
+ if (!client) {
300
+ throw new Error("useBowlosClient must be used within a <BowlosProvider>.");
301
+ }
302
+ return client;
303
+ }
304
+ function useBowlosMutation(name, options = {}) {
305
+ const client = useBowlosClient();
306
+ const auth = options.auth ?? false;
307
+ const [data, setData] = react.useState(null);
308
+ const [error, setError] = react.useState(null);
309
+ const [loading, setLoading] = react.useState(false);
310
+ const run = react.useCallback(
311
+ async (args) => {
312
+ setLoading(true);
313
+ setError(null);
314
+ try {
315
+ const result = await client.call(name, args, { auth });
316
+ setData(result);
317
+ return result;
318
+ } catch (e) {
319
+ if (e instanceof BowlosApiError) setError(e);
320
+ throw e;
321
+ } finally {
322
+ setLoading(false);
323
+ }
324
+ },
325
+ [client, name, auth]
326
+ );
327
+ const reset = react.useCallback(() => {
328
+ setData(null);
329
+ setError(null);
330
+ setLoading(false);
331
+ }, []);
332
+ return { run, data, error, loading, reset };
333
+ }
334
+
335
+ // src/hooks.tsx
336
+ function useCreateCardSetup() {
337
+ return useBowlosMutation("createSetupIntentForAddingCard", {
338
+ auth: true
339
+ });
340
+ }
341
+ function useAccountAction() {
342
+ const [busy, setBusy] = react.useState(false);
343
+ const [message, setMessage] = react.useState("");
344
+ const [failed, setFailed] = react.useState(false);
345
+ const alert = react.useRef(null);
346
+ const locked = react.useRef(false);
347
+ async function run(action, success = "") {
348
+ if (locked.current) return;
349
+ locked.current = true;
350
+ setBusy(true);
351
+ setMessage("");
352
+ setFailed(false);
353
+ try {
354
+ await action();
355
+ setMessage(success);
356
+ } catch (error) {
357
+ setFailed(true);
358
+ setMessage(error instanceof Error ? error.message : "Unable to complete this request.");
359
+ setTimeout(() => alert.current?.focus(), 0);
360
+ } finally {
361
+ locked.current = false;
362
+ setBusy(false);
363
+ }
364
+ }
365
+ return {
366
+ busy,
367
+ run,
368
+ feedback: message ? /* @__PURE__ */ jsxRuntime.jsx("p", { ref: alert, tabIndex: -1, role: failed ? "alert" : "status", children: message }) : null
369
+ };
370
+ }
371
+ function AccountPanel({
372
+ title,
373
+ children,
374
+ className
375
+ }) {
376
+ return /* @__PURE__ */ jsxRuntime.jsxs("section", { "aria-label": title, className, style: styles().panel, children: [
377
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { style: styles().heading, children: title }),
378
+ children
379
+ ] });
380
+ }
381
+ function AddCardForm({
382
+ brandId,
383
+ centerId,
384
+ onAdded,
385
+ appearance,
386
+ labels,
387
+ className
388
+ }) {
389
+ const t = {
390
+ title: "Add a card",
391
+ start: "Add card",
392
+ save: "Save card",
393
+ saved: "Card saved.",
394
+ error: "Unable to save this card.",
395
+ ...labels
396
+ };
397
+ const setup = useCreateCardSetup();
398
+ const action = useAccountAction();
399
+ const [intent, setIntent] = react.useState();
400
+ const stripe = react.useMemo(
401
+ () => intent ? stripeJs.loadStripe(intent.publishableKey, { stripeAccount: intent.stripeAccount }) : null,
402
+ [intent]
403
+ );
404
+ return /* @__PURE__ */ jsxRuntime.jsxs(AccountPanel, { title: t.title, className, children: [
405
+ !intent ? /* @__PURE__ */ jsxRuntime.jsx(
406
+ "button",
407
+ {
408
+ style: styles().primaryBtn,
409
+ disabled: action.busy,
410
+ onClick: () => void action.run(async () => setIntent(await setup.run({ brandId, centerId }))),
411
+ children: t.start
412
+ }
413
+ ) : /* @__PURE__ */ jsxRuntime.jsx(reactStripeJs.Elements, { stripe, options: { clientSecret: intent.clientSecret, appearance }, children: /* @__PURE__ */ jsxRuntime.jsx(
414
+ SetupForm,
415
+ {
416
+ labels: t,
417
+ onAdded: () => {
418
+ setIntent(void 0);
419
+ onAdded?.();
420
+ }
421
+ }
422
+ ) }),
423
+ action.feedback
424
+ ] });
425
+ }
426
+ function SetupForm({
427
+ labels,
428
+ onAdded
429
+ }) {
430
+ const stripe = reactStripeJs.useStripe();
431
+ const elements = reactStripeJs.useElements();
432
+ const action = useAccountAction();
433
+ return /* @__PURE__ */ jsxRuntime.jsxs(
434
+ "form",
435
+ {
436
+ style: styles().stack,
437
+ onSubmit: (e) => {
438
+ e.preventDefault();
439
+ if (!stripe || !elements) return;
440
+ void action.run(async () => {
441
+ const result = await stripe.confirmSetup({ elements, redirect: "if_required" });
442
+ if (result.error) throw new Error(result.error.message ?? labels.error);
443
+ if (result.setupIntent?.status !== "succeeded") throw new Error(labels.error);
444
+ onAdded();
445
+ }, labels.saved);
446
+ },
447
+ children: [
448
+ /* @__PURE__ */ jsxRuntime.jsx(reactStripeJs.PaymentElement, {}),
449
+ /* @__PURE__ */ jsxRuntime.jsx("button", { style: styles().primaryBtn, disabled: !stripe || !elements || action.busy, children: labels.save }),
450
+ action.feedback
451
+ ]
452
+ }
453
+ );
454
+ }
455
+
456
+ exports.AddCardForm = AddCardForm;
254
457
  exports.BowlosPaymentForm = BowlosPaymentForm;
255
458
  //# sourceMappingURL=payments.cjs.map
256
459
  //# sourceMappingURL=payments.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/theme.tsx","../src/components/shared.tsx","../src/components/payment-form.tsx"],"names":["useMemo","loadStripe","jsx","Elements","useStripe","useElements","useState","PaymentElement"],"mappings":";;;;;;;;AA6BA,IAAM,GAAA,GAA+C;AAAA,EACnD,YAAA,EAAc,wBAAA;AAAA,EACd,oBAAA,EAAsB,iCAAA;AAAA,EACtB,SAAA,EAAW,qBAAA;AAAA,EACX,UAAA,EAAY,sBAAA;AAAA,EACZ,OAAA,EAAS,mBAAA;AAAA,EACT,YAAA,EAAc,wBAAA;AAAA,EACd,WAAA,EAAa,uBAAA;AAAA,EACb,UAAA,EAAY,sBAAA;AAAA,EACZ,YAAA,EAAc,wBAAA;AAAA,EACd,MAAA,EAAQ,iBAAA;AAAA,EACR,UAAA,EAAY;AACd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,KAAA,CAAM,OAAA,IAAW,CAAA,CAAE,YAAA;AAC7B,MAAA,UAAA,CAAW,CAAC,CAAA;AACZ,MAAA,OAAA,GAAU,CAAC,CAAA;AACX,MAAA,aAAA,CAAc,KAAK,CAAA;AACnB,MAAA;AAAA,IACF;AAIA,IAAA,MAAA,EAAO;AAAA,EACT;AAEA,EAAA,MAAM,QAAA,GAAW,CAAA,CAAE,GAAA,CAAI,OAAA,CAAQ,UAAA,EAAY,WAAA,IAAe,IAAA,GAAO,WAAA,CAAY,WAAW,CAAA,GAAI,EAAE,CAAA,CAAE,IAAA,EAAK;AAErG,EAAA,uCACG,MAAA,EAAA,EAAK,QAAA,EAAU,cAAc,SAAA,EAAsB,KAAA,EAAO,EAAE,KAAA,EAC3D,QAAA,EAAA;AAAA,oBAAAJ,eAACK,4BAAA,EAAA,EAAe,CAAA;AAAA,oBAIhBL,cAAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,QAAA;AAAA,QACL,OAAO,CAAA,CAAE,UAAA;AAAA,QACT,QAAA,EAAU,CAAC,MAAA,IAAU,CAAC,QAAA,IAAY,UAAA;AAAA,QAEjC,QAAA,EAAA,UAAA,GAAa,EAAE,MAAA,GAAS;AAAA;AAAA,KAC3B;AAAA,IACC,OAAA,oBACCA,cAAAA,CAAC,GAAA,EAAA,EAAE,MAAK,OAAA,EAAQ,KAAA,EAAO,CAAA,CAAE,KAAA,EACtB,QAAA,EAAA,OAAA,EACH;AAAA,GAAA,EAEJ,CAAA;AAEJ","file":"payments.cjs","sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\n\n/**\n * Themeable design tokens for the `@bowlos/reservations/components` layer.\n *\n * Override any subset; the rest fall back to neutral, **white-label** defaults\n * (deliberately no BowlOS branding — these render on a center's own site).\n * Tokens are applied as CSS custom properties, so you can theme either with\n * `<BowlosTheme theme={...}>` or by setting the `--bowlos-*` variables yourself\n * in CSS.\n */\nexport interface BowlosThemeTokens {\n /** Accent color — buttons, highlights. */\n colorPrimary?: string;\n /** Text/icon color on top of `colorPrimary`. */\n colorPrimaryContrast?: string;\n colorText?: string;\n colorMuted?: string;\n colorBg?: string;\n colorSurface?: string;\n colorBorder?: string;\n colorError?: string;\n colorSuccess?: string;\n /** Corner radius (e.g. \"10px\", \"0.5rem\"). */\n radius?: string;\n /** Font family stack. */\n fontFamily?: string;\n}\n\nconst VAR: Record<keyof BowlosThemeTokens, string> = {\n colorPrimary: \"--bowlos-color-primary\",\n colorPrimaryContrast: \"--bowlos-color-primary-contrast\",\n colorText: \"--bowlos-color-text\",\n colorMuted: \"--bowlos-color-muted\",\n colorBg: \"--bowlos-color-bg\",\n colorSurface: \"--bowlos-color-surface\",\n colorBorder: \"--bowlos-color-border\",\n colorError: \"--bowlos-color-error\",\n colorSuccess: \"--bowlos-color-success\",\n radius: \"--bowlos-radius\",\n fontFamily: \"--bowlos-font\",\n};\n\n/** Neutral, white-label defaults — used as the CSS-var fallbacks, so components\n * look right even with no `<BowlosTheme>` wrapper. */\nexport const BOWLOS_DEFAULT_THEME: Required<BowlosThemeTokens> = {\n colorPrimary: \"#1f2937\",\n colorPrimaryContrast: \"#ffffff\",\n colorText: \"#111827\",\n colorMuted: \"#6b7280\",\n colorBg: \"#ffffff\",\n colorSurface: \"#f9fafb\",\n colorBorder: \"#e5e7eb\",\n colorError: \"#dc2626\",\n colorSuccess: \"#16a34a\",\n radius: \"10px\",\n fontFamily: \"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n};\n\nfunction themeToVars(theme: BowlosThemeTokens): CSSProperties {\n const out: Record<string, string> = {};\n for (const key of Object.keys(VAR) as (keyof BowlosThemeTokens)[]) {\n const value = theme[key];\n if (value) out[VAR[key]] = value;\n }\n return out as CSSProperties;\n}\n\n/**\n * Applies a theme by setting the `--bowlos-*` CSS variables on a wrapper, which\n * the components read. Children inherit them; nest another `<BowlosTheme>` to\n * override per-section. Optional — components fall back to neutral defaults\n * without it.\n */\nexport function BowlosTheme({\n theme = {},\n className,\n style,\n children,\n}: {\n theme?: BowlosThemeTokens;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}) {\n return (\n <div className={className} style={{ ...themeToVars(theme), ...style }}>\n {children}\n </div>\n );\n}\n\n/** A CSS-var reference for a token, with the neutral default baked in as the\n * fallback — components use this in inline styles. */\nexport function token(key: keyof BowlosThemeTokens): string {\n return `var(${VAR[key]}, ${BOWLOS_DEFAULT_THEME[key]})`;\n}\n","\"use client\";\n/**\n * Shared primitives for the `@bowlos/reservations/components` layer.\n *\n * One canonical set of themed style atoms + formatters, consumed by every\n * component (booking, account, flash) so there's a single source of truth for\n * the look — no per-surface copies. All visuals read the `--bowlos-*` CSS vars\n * via `token()`, so a `<BowlosTheme>` (or raw CSS) restyles every component at\n * once. White-label by design — neutral defaults, no BowlOS branding.\n */\nimport { useEffect, useState, type CSSProperties } from \"react\";\nimport { token } from \"./theme\";\n\n/** The canonical themed style atoms. Components pick the atoms they need. */\nexport function styles(): Record<string, CSSProperties> {\n return {\n // containers\n card: {\n fontFamily: token(\"fontFamily\"),\n color: token(\"colorText\"),\n background: token(\"colorBg\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n padding: \"1.25rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.75rem\",\n maxWidth: 380,\n },\n panel: {\n fontFamily: token(\"fontFamily\"),\n color: token(\"colorText\"),\n background: token(\"colorBg\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n padding: \"1rem 1.25rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.625rem\",\n },\n // text\n heading: { margin: \"0 0 0.25rem\", fontSize: \"1.25rem\" },\n sectionTitle: {\n margin: \"0 0 0.5rem\",\n fontSize: \"0.8rem\",\n fontWeight: 700,\n letterSpacing: \"0.04em\",\n textTransform: \"uppercase\",\n color: token(\"colorMuted\"),\n },\n body: { margin: 0, color: token(\"colorText\") },\n meta: { margin: 0, fontSize: \"0.9rem\", color: token(\"colorMuted\"), minHeight: \"1.2em\" },\n muted: { margin: 0, fontSize: \"0.9rem\", color: token(\"colorMuted\") },\n error: { margin: 0, color: token(\"colorError\"), fontSize: \"0.9rem\" },\n // form\n label: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.25rem\",\n fontSize: \"0.85rem\",\n color: token(\"colorMuted\"),\n },\n input: {\n padding: \"0.5rem 0.625rem\",\n fontSize: \"1rem\",\n color: token(\"colorText\"),\n background: token(\"colorSurface\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n },\n // layout\n row: { display: \"flex\", gap: \"0.5rem\", flexWrap: \"wrap\", alignItems: \"center\" },\n rowBetween: { display: \"flex\", gap: \"0.5rem\", justifyContent: \"space-between\", alignItems: \"center\" },\n stack: { display: \"flex\", flexDirection: \"column\", gap: \"0.75rem\" },\n // buttons\n primaryBtn: {\n padding: \"0.625rem 1rem\",\n fontSize: \"1rem\",\n fontWeight: 600,\n color: token(\"colorPrimaryContrast\"),\n background: token(\"colorPrimary\"),\n border: \"none\",\n borderRadius: token(\"radius\"),\n cursor: \"pointer\",\n },\n ghostBtn: {\n padding: \"0.625rem 1rem\",\n fontSize: \"1rem\",\n color: token(\"colorText\"),\n background: \"transparent\",\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n cursor: \"pointer\",\n },\n linkBtn: {\n padding: 0,\n fontSize: \"0.9rem\",\n color: token(\"colorPrimary\"),\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n textDecoration: \"underline\",\n },\n // list rows (reservations, memberships, ledger, passes, flash items)\n listItem: {\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"baseline\",\n gap: \"0.75rem\",\n padding: \"0.625rem 0\",\n borderTop: `1px solid ${token(\"colorBorder\")}`,\n },\n listTitle: { margin: 0, fontSize: \"1rem\", fontWeight: 600 },\n listMeta: { margin: 0, fontSize: \"0.85rem\", color: token(\"colorMuted\") },\n // badges + prices\n badge: {\n display: \"inline-block\",\n padding: \"0.125rem 0.5rem\",\n fontSize: \"0.75rem\",\n fontWeight: 600,\n color: token(\"colorMuted\"),\n background: token(\"colorSurface\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: \"999px\",\n whiteSpace: \"nowrap\",\n },\n priceSale: { fontSize: \"1.05rem\", fontWeight: 700, color: token(\"colorText\") },\n priceStrike: { fontSize: \"0.9rem\", color: token(\"colorMuted\"), textDecoration: \"line-through\" },\n // flash hero\n banner: {\n width: \"100%\",\n height: 140,\n objectFit: \"cover\",\n borderTopLeftRadius: token(\"radius\"),\n borderTopRightRadius: token(\"radius\"),\n display: \"block\",\n },\n countdown: { margin: 0, fontSize: \"0.95rem\", fontWeight: 600, color: token(\"colorPrimary\") },\n };\n}\n\n/** Format integer cents as USD. */\nexport function formatCents(cents: number): string {\n return (cents / 100).toLocaleString(undefined, { style: \"currency\", currency: \"USD\" });\n}\n\n/** A min–max money range, collapsing to one value when they're equal. */\nexport function formatCentsRange(minCents: number, maxCents: number): string {\n return maxCents > minCents ? `${formatCents(minCents)} – ${formatCents(maxCents)}` : formatCents(minCents);\n}\n\n/** Minute-of-day → \"HH:MM\" (24h, for `<input type=\"time\">`). */\nexport function minutesToTime(min: number): string {\n const h = Math.floor(min / 60)\n .toString()\n .padStart(2, \"0\");\n const m = (min % 60).toString().padStart(2, \"0\");\n return `${h}:${m}`;\n}\n\n/** \"HH:MM\" → minute-of-day. */\nexport function timeToMinutes(t: string): number {\n const [h, m] = t.split(\":\").map(Number);\n return (h ?? 0) * 60 + (m ?? 0);\n}\n\n/** Minute-of-day → friendly 12-hour label (\"6:00 PM\"), for time dropdowns. */\nexport function formatMinuteLabel(min: number): string {\n const h24 = Math.floor(min / 60) % 24;\n const m = min % 60;\n const period = h24 < 12 ? \"AM\" : \"PM\";\n const h12 = h24 % 12 === 0 ? 12 : h24 % 12;\n return `${h12}:${m.toString().padStart(2, \"0\")} ${period}`;\n}\n\n/**\n * A live countdown to `targetMs`, recomputed every second on the client.\n *\n * Returns `null` on the server / first client render (so SSR markup and the\n * first hydration pass match — no mismatch), then ticks once mounted. `ended`\n * flips true at/after the target. We derive this off a ticking timer rather\n * than a server-computed boolean so it stays live without a refetch.\n */\nexport function useCountdown(targetMs: number | null): { ended: boolean; label: string } | null {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => {\n if (targetMs === null) return;\n setNow(Date.now());\n const id = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(id);\n }, [targetMs]);\n\n if (now === null || targetMs === null) return null;\n const remaining = targetMs - now;\n if (remaining <= 0) return { ended: true, label: \"\" };\n return { ended: false, label: humanizeRemaining(remaining) };\n}\n\nfunction humanizeRemaining(ms: number): string {\n const totalSec = Math.floor(ms / 1000);\n const d = Math.floor(totalSec / 86400);\n const h = Math.floor((totalSec % 86400) / 3600);\n const m = Math.floor((totalSec % 3600) / 60);\n const s = totalSec % 60;\n if (d > 0) return `${d}d ${h}h ${m}m`;\n if (h > 0) return `${h}h ${m}m ${s}s`;\n if (m > 0) return `${m}m ${s}s`;\n return `${s}s`;\n}\n","\"use client\";\n/**\n * `<BowlosPaymentForm>` — the drop-in Stripe Connect checkout for `<BookingFlow>`.\n *\n * This is the ONE part of the SDK that loads Stripe.js, so it lives in its own\n * entry (`@bowlos/reservations/payments`) and Stripe is an OPTIONAL peer — the\n * core + components bundles never pull it. Wire it into `<BookingFlow>`'s\n * `renderPayment` slot and you never hand-build a Stripe Elements form per site:\n *\n * ```tsx\n * import { BowlosPaymentForm } from \"@bowlos/reservations/payments\";\n *\n * <BookingFlow\n * renderPayment={(ctx) => (\n * <BowlosPaymentForm {...ctx} publishableKey={process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!} />\n * )}\n * />\n * ```\n *\n * It initializes Stripe.js with the PLATFORM publishable key scoped to the\n * operator's CONNECTED account (`stripeAccount: connectedAccountId`), so the\n * charge lands directly on the operator's Stripe account (their name on the\n * statement/receipt — the white-label requirement). Saved cards + \"save for\n * future\" are enabled by default via the booking's customer session.\n */\nimport { useMemo, useState, type FormEvent } from \"react\";\nimport { loadStripe, type Appearance } from \"@stripe/stripe-js\";\nimport { Elements, PaymentElement, useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport type { ConnectedPaymentInput } from \"../data\";\nimport { formatCents, styles } from \"./shared\";\n\n/** Visible strings — override any subset for copy/i18n. */\nexport interface BowlosPaymentFormLabels {\n /** Button when idle. `{amount}` (if present) is replaced with the formatted total. */\n pay: string;\n paying: string;\n genericError: string;\n}\n\nconst DEFAULT_LABELS: BowlosPaymentFormLabels = {\n pay: \"Pay {amount}\",\n paying: \"Paying…\",\n genericError: \"Payment failed — please try again.\",\n};\n\nexport interface BowlosPaymentFormProps {\n /** The Connect payment to confirm — a booking's `PaymentIntentInfo`, a buy\n * flow's intent, or a subscription's first-invoice client secret. Any value\n * with `{ clientSecret, connectedAccountId, customerSessionClientSecret? }`. */\n paymentIntent: ConnectedPaymentInput;\n /** Your PLATFORM publishable key (browser-safe; e.g. `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`).\n * Used for live PaymentIntents (and as the sole key when `testPublishableKey`\n * is omitted — fully back-compatible with one-key sites). */\n publishableKey: string;\n /** Full Test Mode (2026-06-23): your platform TEST publishable key\n * (`pk_test_…`). When the PaymentIntent's `stripeMode` is \"test\" (an admin\n * Test-Account customer, or a Center in Full Test Mode), the form loads THIS\n * key instead of `publishableKey` — so a live site can confirm test PIs\n * concurrently. Omit it and the form always uses `publishableKey`. */\n testPublishableKey?: string;\n /** Called once the PaymentIntent confirms — start polling for the reservation. */\n onPaid: () => void;\n /** Called with a human-readable message when confirmation fails. */\n onError?: (message: string) => void;\n /** Total, for the button label (\"Pay $45.00\"). Omit to show a plain \"Pay\". */\n amountCents?: number;\n /**\n * Enable saved cards + a \"save for future\" option via the booking's customer\n * session (when the gateway provided one). Default `true`. Set `false` for a\n * one-off charge with no card on file.\n */\n saveCard?: boolean;\n /**\n * Stripe Elements appearance — theme the Payment Element to match your site\n * (e.g. `{ theme: \"night\", variables: { colorPrimary: \"#FFD500\" } }`). Without\n * it Stripe renders its default light theme, which looks off on a dark site.\n */\n appearance?: Appearance;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}\n\n/**\n * The Stripe Connect payment form. Renders the Payment Element scoped to the\n * operator's connected account and confirms the PaymentIntent on submit.\n */\nexport function BowlosPaymentForm({\n paymentIntent,\n publishableKey,\n testPublishableKey,\n onPaid,\n onError,\n amountCents,\n saveCard = true,\n appearance,\n labels,\n className,\n}: BowlosPaymentFormProps) {\n // Pick the publishable key matching the PaymentIntent's Stripe environment: a\n // test PI (Full Test Mode / Test-Account customer) confirms only with the test\n // key, a live PI only with the live key. Falls back to `publishableKey` when no\n // test key is supplied (one-key sites — unchanged behavior).\n const pk =\n paymentIntent.stripeMode === \"test\" && testPublishableKey\n ? testPublishableKey\n : publishableKey;\n // Platform key, scoped to the operator's connected account → the charge is\n // created directly on their Stripe account (white-label receipt/statement).\n const stripePromise = useMemo(\n () => loadStripe(pk, { stripeAccount: paymentIntent.connectedAccountId }),\n [pk, paymentIntent.connectedAccountId],\n );\n\n // Pass the customer session only when present + opted-in, so the Payment\n // Element can offer saved cards / \"save for future\" for this operator.\n const customerSessionClientSecret =\n saveCard && paymentIntent.customerSessionClientSecret\n ? paymentIntent.customerSessionClientSecret\n : undefined;\n\n return (\n <Elements\n stripe={stripePromise}\n options={{ clientSecret: paymentIntent.clientSecret, customerSessionClientSecret, appearance }}\n >\n <PayForm\n onPaid={onPaid}\n onError={onError}\n amountCents={amountCents}\n labels={labels}\n className={className}\n />\n </Elements>\n );\n}\n\nfunction PayForm({\n onPaid,\n onError,\n amountCents,\n labels,\n className,\n}: {\n onPaid: () => void;\n onError?: (message: string) => void;\n amountCents?: number;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const stripe = useStripe();\n const elements = useElements();\n const [submitting, setSubmitting] = useState(false);\n const [message, setMessage] = useState<string | null>(null);\n const s = styles();\n\n async function handleSubmit(e: FormEvent) {\n e.preventDefault();\n if (!stripe || !elements) return;\n setSubmitting(true);\n setMessage(null);\n\n // `redirect: \"if_required\"` keeps card payments on-page; wallets that need\n // a redirect still work.\n const { error } = await stripe.confirmPayment({ elements, redirect: \"if_required\" });\n\n if (error) {\n const m = error.message ?? t.genericError;\n setMessage(m);\n onError?.(m);\n setSubmitting(false);\n return;\n }\n\n // Paid. The gateway's Stripe webhook materializes the reservation\n // asynchronously, so hand control back so the flow can poll for it.\n onPaid();\n }\n\n const payLabel = t.pay.replace(\"{amount}\", amountCents != null ? formatCents(amountCents) : \"\").trim();\n\n return (\n <form onSubmit={handleSubmit} className={className} style={s.stack}>\n <PaymentElement />\n {/* v0.22.1: include !elements — the submit handler bails on a not-yet-\n mounted PaymentElement, so a click during mount was a silent no-op\n (the \"first click does nothing\" race a center site reproduced). */}\n <button\n type=\"submit\"\n style={s.primaryBtn}\n disabled={!stripe || !elements || submitting}\n >\n {submitting ? t.paying : payLabel}\n </button>\n {message && (\n <p role=\"alert\" style={s.error}>\n {message}\n </p>\n )}\n </form>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/components/theme.tsx","../src/components/shared.tsx","../src/components/payment-form.tsx","../src/errors.ts","../src/react.tsx","../src/hooks.tsx","../src/components/account-shared.tsx","../src/components/add-card-form.tsx"],"names":["useMemo","loadStripe","jsx","Elements","useStripe","useElements","useState","PaymentElement","createContext","useContext","useCallback","useRef","jsxs"],"mappings":";;;;;;;;AA6BA,IAAM,GAAA,GAA+C;AAAA,EACnD,YAAA,EAAc,wBAAA;AAAA,EACd,oBAAA,EAAsB,iCAAA;AAAA,EACtB,SAAA,EAAW,qBAAA;AAAA,EACX,UAAA,EAAY,sBAAA;AAAA,EACZ,OAAA,EAAS,mBAAA;AAAA,EACT,YAAA,EAAc,wBAAA;AAAA,EACd,WAAA,EAAa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AGG;AACD,EAAA,MAAM,SAASE,uBAAAA,EAAU;AACzB,EAAA,MAAM,WAAWC,yBAAAA,EAAY;AAC7B,EAAA,MAAM,SAAS,gBAAA,EAAiB;AAChC,EAAA,uBACEO,eAAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,QAAO,CAAE,KAAA;AAAA,MAChB,QAAA,EAAU,CAAC,CAAA,KAAM;AACf,QAAA,CAAA,CAAE,cAAA,EAAe;AACjB,QAAA,IAAI,CAAC,MAAA,IAAU,CAAC,QAAA,EAAU;AAC1B,QAAA,KAAK,MAAA,CAAO,IAAI,YAAY;AAC1B,UAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,YAAA,CAAa,EAAE,QAAA,EAAU,QAAA,EAAU,eAAe,CAAA;AAC9E,UAAA,IAAI,MAAA,CAAO,OAAO,MAAM,IAAI,MAAM,MAAA,CAAO,KAAA,CAAM,OAAA,IAAW,MAAA,CAAO,KAAK,CAAA;AACtE,UAAA,IAAI,MAAA,CAAO,aAAa,MAAA,KAAW,WAAA,QAAmB,IAAI,KAAA,CAAM,OAAO,KAAK,CAAA;AAC5E,UAAA,OAAA,EAAQ;AAAA,QACV,CAAA,EAAG,OAAO,KAAK,CAAA;AAAA,MACjB,CAAA;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAAV,cAAAA,CAACK,8BAAA,EAAe,CAAA;AAAA,wBAChBL,cAAAA,CAAC,QAAA,EAAA,EAAO,KAAA,EAAO,QAAO,CAAE,UAAA,EAAY,QAAA,EAAU,CAAC,UAAU,CAAC,QAAA,IAAY,MAAA,CAAO,IAAA,EAC1E,iBAAO,IAAA,EACV,CAAA;AAAA,QACC,MAAA,CAAO;AAAA;AAAA;AAAA,GACV;AAEJ","file":"payments.cjs","sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\n\n/**\n * Themeable design tokens for the `@bowlos/reservations/components` layer.\n *\n * Override any subset; the rest fall back to neutral, **white-label** defaults\n * (deliberately no BowlOS branding — these render on a center's own site).\n * Tokens are applied as CSS custom properties, so you can theme either with\n * `<BowlosTheme theme={...}>` or by setting the `--bowlos-*` variables yourself\n * in CSS.\n */\nexport interface BowlosThemeTokens {\n /** Accent color — buttons, highlights. */\n colorPrimary?: string;\n /** Text/icon color on top of `colorPrimary`. */\n colorPrimaryContrast?: string;\n colorText?: string;\n colorMuted?: string;\n colorBg?: string;\n colorSurface?: string;\n colorBorder?: string;\n colorError?: string;\n colorSuccess?: string;\n /** Corner radius (e.g. \"10px\", \"0.5rem\"). */\n radius?: string;\n /** Font family stack. */\n fontFamily?: string;\n}\n\nconst VAR: Record<keyof BowlosThemeTokens, string> = {\n colorPrimary: \"--bowlos-color-primary\",\n colorPrimaryContrast: \"--bowlos-color-primary-contrast\",\n colorText: \"--bowlos-color-text\",\n colorMuted: \"--bowlos-color-muted\",\n colorBg: \"--bowlos-color-bg\",\n colorSurface: \"--bowlos-color-surface\",\n colorBorder: \"--bowlos-color-border\",\n colorError: \"--bowlos-color-error\",\n colorSuccess: \"--bowlos-color-success\",\n radius: \"--bowlos-radius\",\n fontFamily: \"--bowlos-font\",\n};\n\n/** Neutral, white-label defaults — used as the CSS-var fallbacks, so components\n * look right even with no `<BowlosTheme>` wrapper. */\nexport const BOWLOS_DEFAULT_THEME: Required<BowlosThemeTokens> = {\n colorPrimary: \"#1f2937\",\n colorPrimaryContrast: \"#ffffff\",\n colorText: \"#111827\",\n colorMuted: \"#6b7280\",\n colorBg: \"#ffffff\",\n colorSurface: \"#f9fafb\",\n colorBorder: \"#e5e7eb\",\n colorError: \"#dc2626\",\n colorSuccess: \"#16a34a\",\n radius: \"10px\",\n fontFamily: \"system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif\",\n};\n\nfunction themeToVars(theme: BowlosThemeTokens): CSSProperties {\n const out: Record<string, string> = {};\n for (const key of Object.keys(VAR) as (keyof BowlosThemeTokens)[]) {\n const value = theme[key];\n if (value) out[VAR[key]] = value;\n }\n return out as CSSProperties;\n}\n\n/**\n * Applies a theme by setting the `--bowlos-*` CSS variables on a wrapper, which\n * the components read. Children inherit them; nest another `<BowlosTheme>` to\n * override per-section. Optional — components fall back to neutral defaults\n * without it.\n */\nexport function BowlosTheme({\n theme = {},\n className,\n style,\n children,\n}: {\n theme?: BowlosThemeTokens;\n className?: string;\n style?: CSSProperties;\n children: ReactNode;\n}) {\n return (\n <div className={className} style={{ ...themeToVars(theme), ...style }}>\n {children}\n </div>\n );\n}\n\n/** A CSS-var reference for a token, with the neutral default baked in as the\n * fallback — components use this in inline styles. */\nexport function token(key: keyof BowlosThemeTokens): string {\n return `var(${VAR[key]}, ${BOWLOS_DEFAULT_THEME[key]})`;\n}\n","\"use client\";\n/**\n * Shared primitives for the `@bowlos/reservations/components` layer.\n *\n * One canonical set of themed style atoms + formatters, consumed by every\n * component (booking, account, flash) so there's a single source of truth for\n * the look — no per-surface copies. All visuals read the `--bowlos-*` CSS vars\n * via `token()`, so a `<BowlosTheme>` (or raw CSS) restyles every component at\n * once. White-label by design — neutral defaults, no BowlOS branding.\n */\nimport { useEffect, useState, type CSSProperties } from \"react\";\nimport { token } from \"./theme\";\n\n/** The canonical themed style atoms. Components pick the atoms they need. */\nexport function styles(): Record<string, CSSProperties> {\n return {\n // containers\n card: {\n fontFamily: token(\"fontFamily\"),\n color: token(\"colorText\"),\n background: token(\"colorBg\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n padding: \"1.25rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.75rem\",\n maxWidth: 380,\n },\n panel: {\n fontFamily: token(\"fontFamily\"),\n color: token(\"colorText\"),\n background: token(\"colorBg\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n padding: \"1rem 1.25rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.625rem\",\n },\n // text\n heading: { margin: \"0 0 0.25rem\", fontSize: \"1.25rem\" },\n sectionTitle: {\n margin: \"0 0 0.5rem\",\n fontSize: \"0.8rem\",\n fontWeight: 700,\n letterSpacing: \"0.04em\",\n textTransform: \"uppercase\",\n color: token(\"colorMuted\"),\n },\n body: { margin: 0, color: token(\"colorText\") },\n meta: { margin: 0, fontSize: \"0.9rem\", color: token(\"colorMuted\"), minHeight: \"1.2em\" },\n muted: { margin: 0, fontSize: \"0.9rem\", color: token(\"colorMuted\") },\n error: { margin: 0, color: token(\"colorError\"), fontSize: \"0.9rem\" },\n // form\n label: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.25rem\",\n fontSize: \"0.85rem\",\n color: token(\"colorMuted\"),\n },\n input: {\n padding: \"0.5rem 0.625rem\",\n fontSize: \"1rem\",\n color: token(\"colorText\"),\n background: token(\"colorSurface\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n },\n // layout\n row: { display: \"flex\", gap: \"0.5rem\", flexWrap: \"wrap\", alignItems: \"center\" },\n rowBetween: { display: \"flex\", gap: \"0.5rem\", justifyContent: \"space-between\", alignItems: \"center\" },\n stack: { display: \"flex\", flexDirection: \"column\", gap: \"0.75rem\" },\n // buttons\n primaryBtn: {\n padding: \"0.625rem 1rem\",\n fontSize: \"1rem\",\n fontWeight: 600,\n color: token(\"colorPrimaryContrast\"),\n background: token(\"colorPrimary\"),\n border: \"none\",\n borderRadius: token(\"radius\"),\n cursor: \"pointer\",\n },\n ghostBtn: {\n padding: \"0.625rem 1rem\",\n fontSize: \"1rem\",\n color: token(\"colorText\"),\n background: \"transparent\",\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: token(\"radius\"),\n cursor: \"pointer\",\n },\n linkBtn: {\n padding: 0,\n fontSize: \"0.9rem\",\n color: token(\"colorPrimary\"),\n background: \"transparent\",\n border: \"none\",\n cursor: \"pointer\",\n textDecoration: \"underline\",\n },\n // list rows (reservations, memberships, ledger, passes, flash items)\n listItem: {\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"baseline\",\n gap: \"0.75rem\",\n padding: \"0.625rem 0\",\n borderTop: `1px solid ${token(\"colorBorder\")}`,\n },\n listTitle: { margin: 0, fontSize: \"1rem\", fontWeight: 600 },\n listMeta: { margin: 0, fontSize: \"0.85rem\", color: token(\"colorMuted\") },\n // badges + prices\n badge: {\n display: \"inline-block\",\n padding: \"0.125rem 0.5rem\",\n fontSize: \"0.75rem\",\n fontWeight: 600,\n color: token(\"colorMuted\"),\n background: token(\"colorSurface\"),\n border: `1px solid ${token(\"colorBorder\")}`,\n borderRadius: \"999px\",\n whiteSpace: \"nowrap\",\n },\n priceSale: { fontSize: \"1.05rem\", fontWeight: 700, color: token(\"colorText\") },\n priceStrike: { fontSize: \"0.9rem\", color: token(\"colorMuted\"), textDecoration: \"line-through\" },\n // flash hero\n banner: {\n width: \"100%\",\n height: 140,\n objectFit: \"cover\",\n borderTopLeftRadius: token(\"radius\"),\n borderTopRightRadius: token(\"radius\"),\n display: \"block\",\n },\n countdown: { margin: 0, fontSize: \"0.95rem\", fontWeight: 600, color: token(\"colorPrimary\") },\n };\n}\n\n/** Format integer cents as USD. */\nexport function formatCents(cents: number): string {\n return (cents / 100).toLocaleString(undefined, { style: \"currency\", currency: \"USD\" });\n}\n\n/** A min–max money range, collapsing to one value when they're equal. */\nexport function formatCentsRange(minCents: number, maxCents: number): string {\n return maxCents > minCents ? `${formatCents(minCents)} – ${formatCents(maxCents)}` : formatCents(minCents);\n}\n\n/** Minute-of-day → \"HH:MM\" (24h, for `<input type=\"time\">`). */\nexport function minutesToTime(min: number): string {\n const h = Math.floor(min / 60)\n .toString()\n .padStart(2, \"0\");\n const m = (min % 60).toString().padStart(2, \"0\");\n return `${h}:${m}`;\n}\n\n/** \"HH:MM\" → minute-of-day. */\nexport function timeToMinutes(t: string): number {\n const [h, m] = t.split(\":\").map(Number);\n return (h ?? 0) * 60 + (m ?? 0);\n}\n\n/** Minute-of-day → friendly 12-hour label (\"6:00 PM\"), for time dropdowns. */\nexport function formatMinuteLabel(min: number): string {\n const h24 = Math.floor(min / 60) % 24;\n const m = min % 60;\n const period = h24 < 12 ? \"AM\" : \"PM\";\n const h12 = h24 % 12 === 0 ? 12 : h24 % 12;\n return `${h12}:${m.toString().padStart(2, \"0\")} ${period}`;\n}\n\n/**\n * A live countdown to `targetMs`, recomputed every second on the client.\n *\n * Returns `null` on the server / first client render (so SSR markup and the\n * first hydration pass match — no mismatch), then ticks once mounted. `ended`\n * flips true at/after the target. We derive this off a ticking timer rather\n * than a server-computed boolean so it stays live without a refetch.\n */\nexport function useCountdown(targetMs: number | null): { ended: boolean; label: string } | null {\n const [now, setNow] = useState<number | null>(null);\n useEffect(() => {\n if (targetMs === null) return;\n setNow(Date.now());\n const id = setInterval(() => setNow(Date.now()), 1000);\n return () => clearInterval(id);\n }, [targetMs]);\n\n if (now === null || targetMs === null) return null;\n const remaining = targetMs - now;\n if (remaining <= 0) return { ended: true, label: \"\" };\n return { ended: false, label: humanizeRemaining(remaining) };\n}\n\nfunction humanizeRemaining(ms: number): string {\n const totalSec = Math.floor(ms / 1000);\n const d = Math.floor(totalSec / 86400);\n const h = Math.floor((totalSec % 86400) / 3600);\n const m = Math.floor((totalSec % 3600) / 60);\n const s = totalSec % 60;\n if (d > 0) return `${d}d ${h}h ${m}m`;\n if (h > 0) return `${h}h ${m}m ${s}s`;\n if (m > 0) return `${m}m ${s}s`;\n return `${s}s`;\n}\n","\"use client\";\n/**\n * `<BowlosPaymentForm>` — the drop-in Stripe Connect checkout for `<BookingFlow>`.\n *\n * This is the ONE part of the SDK that loads Stripe.js, so it lives in its own\n * entry (`@bowlos/reservations/payments`) and Stripe is an OPTIONAL peer — the\n * core + components bundles never pull it. Wire it into `<BookingFlow>`'s\n * `renderPayment` slot and you never hand-build a Stripe Elements form per site:\n *\n * ```tsx\n * import { BowlosPaymentForm } from \"@bowlos/reservations/payments\";\n *\n * <BookingFlow\n * renderPayment={(ctx) => (\n * <BowlosPaymentForm {...ctx} publishableKey={process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY!} />\n * )}\n * />\n * ```\n *\n * It initializes Stripe.js with the PLATFORM publishable key scoped to the\n * operator's CONNECTED account (`stripeAccount: connectedAccountId`), so the\n * charge lands directly on the operator's Stripe account (their name on the\n * statement/receipt — the white-label requirement). Saved cards + \"save for\n * future\" are enabled by default via the booking's customer session.\n */\nimport { useMemo, useState, type FormEvent } from \"react\";\nimport { loadStripe, type Appearance } from \"@stripe/stripe-js\";\nimport { Elements, PaymentElement, useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport type { ConnectedPaymentInput } from \"../data\";\nimport { formatCents, styles } from \"./shared\";\n\n/** Visible strings — override any subset for copy/i18n. */\nexport interface BowlosPaymentFormLabels {\n /** Button when idle. `{amount}` (if present) is replaced with the formatted total. */\n pay: string;\n paying: string;\n genericError: string;\n}\n\nconst DEFAULT_LABELS: BowlosPaymentFormLabels = {\n pay: \"Pay {amount}\",\n paying: \"Paying…\",\n genericError: \"Payment failed — please try again.\",\n};\n\nexport interface BowlosPaymentFormProps {\n /** The Connect payment to confirm — a booking's `PaymentIntentInfo`, a buy\n * flow's intent, or a subscription's first-invoice client secret. Any value\n * with `{ clientSecret, connectedAccountId, customerSessionClientSecret? }`. */\n paymentIntent: ConnectedPaymentInput;\n /** Your PLATFORM publishable key (browser-safe; e.g. `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY`).\n * Used for live PaymentIntents (and as the sole key when `testPublishableKey`\n * is omitted — fully back-compatible with one-key sites). */\n publishableKey: string;\n /** Full Test Mode (2026-06-23): your platform TEST publishable key\n * (`pk_test_…`). When the PaymentIntent's `stripeMode` is \"test\" (an admin\n * Test-Account customer, or a Center in Full Test Mode), the form loads THIS\n * key instead of `publishableKey` — so a live site can confirm test PIs\n * concurrently. Omit it and the form always uses `publishableKey`. */\n testPublishableKey?: string;\n /** Called once the PaymentIntent confirms — start polling for the reservation. */\n onPaid: () => void;\n /** Called with a human-readable message when confirmation fails. */\n onError?: (message: string) => void;\n /** Total, for the button label (\"Pay $45.00\"). Omit to show a plain \"Pay\". */\n amountCents?: number;\n /**\n * Enable saved cards + a \"save for future\" option via the booking's customer\n * session (when the gateway provided one). Default `true`. Set `false` for a\n * one-off charge with no card on file.\n */\n saveCard?: boolean;\n /**\n * Stripe Elements appearance — theme the Payment Element to match your site\n * (e.g. `{ theme: \"night\", variables: { colorPrimary: \"#FFD500\" } }`). Without\n * it Stripe renders its default light theme, which looks off on a dark site.\n */\n appearance?: Appearance;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}\n\n/**\n * The Stripe Connect payment form. Renders the Payment Element scoped to the\n * operator's connected account and confirms the PaymentIntent on submit.\n */\nexport function BowlosPaymentForm({\n paymentIntent,\n publishableKey,\n testPublishableKey,\n onPaid,\n onError,\n amountCents,\n saveCard = true,\n appearance,\n labels,\n className,\n}: BowlosPaymentFormProps) {\n // Pick the publishable key matching the PaymentIntent's Stripe environment: a\n // test PI (Full Test Mode / Test-Account customer) confirms only with the test\n // key, a live PI only with the live key. Falls back to `publishableKey` when no\n // test key is supplied (one-key sites — unchanged behavior).\n const pk =\n paymentIntent.stripeMode === \"test\" && testPublishableKey\n ? testPublishableKey\n : publishableKey;\n // Platform key, scoped to the operator's connected account → the charge is\n // created directly on their Stripe account (white-label receipt/statement).\n const stripePromise = useMemo(\n () => loadStripe(pk, { stripeAccount: paymentIntent.connectedAccountId }),\n [pk, paymentIntent.connectedAccountId],\n );\n\n // Pass the customer session only when present + opted-in, so the Payment\n // Element can offer saved cards / \"save for future\" for this operator.\n const customerSessionClientSecret =\n saveCard && paymentIntent.customerSessionClientSecret\n ? paymentIntent.customerSessionClientSecret\n : undefined;\n\n return (\n <Elements\n stripe={stripePromise}\n options={{ clientSecret: paymentIntent.clientSecret, customerSessionClientSecret, appearance }}\n >\n <PayForm\n onPaid={onPaid}\n onError={onError}\n amountCents={amountCents}\n labels={labels}\n className={className}\n />\n </Elements>\n );\n}\n\nfunction PayForm({\n onPaid,\n onError,\n amountCents,\n labels,\n className,\n}: {\n onPaid: () => void;\n onError?: (message: string) => void;\n amountCents?: number;\n labels?: Partial<BowlosPaymentFormLabels>;\n className?: string;\n}) {\n const t = { ...DEFAULT_LABELS, ...labels };\n const stripe = useStripe();\n const elements = useElements();\n const [submitting, setSubmitting] = useState(false);\n const [message, setMessage] = useState<string | null>(null);\n const s = styles();\n\n async function handleSubmit(e: FormEvent) {\n e.preventDefault();\n if (!stripe || !elements) return;\n setSubmitting(true);\n setMessage(null);\n\n // `redirect: \"if_required\"` keeps card payments on-page; wallets that need\n // a redirect still work.\n const { error } = await stripe.confirmPayment({ elements, redirect: \"if_required\" });\n\n if (error) {\n const m = error.message ?? t.genericError;\n setMessage(m);\n onError?.(m);\n setSubmitting(false);\n return;\n }\n\n // Paid. The gateway's Stripe webhook materializes the reservation\n // asynchronously, so hand control back so the flow can poll for it.\n onPaid();\n }\n\n const payLabel = t.pay.replace(\"{amount}\", amountCents != null ? formatCents(amountCents) : \"\").trim();\n\n return (\n <form onSubmit={handleSubmit} className={className} style={s.stack}>\n <PaymentElement />\n {/* v0.22.1: include !elements — the submit handler bails on a not-yet-\n mounted PaymentElement, so a click during mount was a silent no-op\n (the \"first click does nothing\" race a center site reproduced). */}\n <button\n type=\"submit\"\n style={s.primaryBtn}\n disabled={!stripe || !elements || submitting}\n >\n {submitting ? t.paying : payLabel}\n </button>\n {message && (\n <p role=\"alert\" style={s.error}>\n {message}\n </p>\n )}\n </form>\n );\n}\n","/**\n * Error model for the BowlOS Reservations SDK.\n *\n * Every failed gateway call surfaces as a single `BowlosApiError` carrying a\n * stable `code` (string), the HTTP `status`, and — for rate limits — a\n * `retryAfterSeconds`. The gateway normalizes the backend's two error\n * conventions (thrown ConvexError + `{ ok:false }` envelopes) into one JSON\n * shape; this class is the client-side mirror of that shape, so consumers\n * branch on `error.code`, never on message text.\n */\n\n/** Stable error codes the gateway / backend can return. Open set — treat\n * `code` as a string and match against these for known cases. */\nexport const BOWLOS_ERROR_CODES = {\n // Gateway front door\n API_KEY_MISSING: \"API_KEY_MISSING\",\n API_KEY_INVALID: \"API_KEY_INVALID\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n RATE_LIMITED: \"RATE_LIMITED\",\n // Auth\n PASSWORD_TOO_WEAK: \"PASSWORD_TOO_WEAK\",\n CURRENT_PASSWORD_INCORRECT: \"CURRENT_PASSWORD_INCORRECT\",\n CURRENT_PASSWORD_REQUIRED: \"CURRENT_PASSWORD_REQUIRED\",\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\n SIGNUP_FAILED: \"SIGNUP_FAILED\",\n // Shared backend codes\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n PERMISSION_DENIED: \"PERMISSION_DENIED\",\n SCOPE_REVOKED: \"SCOPE_REVOKED\",\n NOT_FOUND: \"NOT_FOUND\",\n VERSION_CONFLICT: \"VERSION_CONFLICT\",\n PRICING_SNAPSHOT_STALE: \"PRICING_SNAPSHOT_STALE\",\n PAYMENTS_NOT_CONNECTED: \"PAYMENTS_NOT_CONNECTED\",\n CONNECT_ACCOUNT_RESTRICTED: \"CONNECT_ACCOUNT_RESTRICTED\",\n BILLING_PORTAL_UNAVAILABLE: \"BILLING_PORTAL_UNAVAILABLE\",\n RETURN_URL_NOT_ALLOWED: \"RETURN_URL_NOT_ALLOWED\",\n CONFLICT_RETRY: \"CONFLICT_RETRY\",\n CHECKOUT_EXPIRED: \"CHECKOUT_EXPIRED\",\n // Client-side\n ROUTE_NOT_FOUND: \"ROUTE_NOT_FOUND\",\n NETWORK_ERROR: \"NETWORK_ERROR\",\n UNKNOWN: \"ERROR\",\n} as const;\n\nexport type BowlosErrorCode =\n | (typeof BOWLOS_ERROR_CODES)[keyof typeof BOWLOS_ERROR_CODES]\n | (string & {});\n\nexport interface BowlosApiErrorOptions {\n retryAfterSeconds?: number;\n cause?: unknown;\n details?: Record<string, string | number | boolean>;\n}\n\nexport class BowlosApiError extends Error {\n /** Stable, machine-readable code. Branch on this, not on `message`. */\n readonly code: BowlosErrorCode;\n /** HTTP status (0 for a network failure before any response). */\n readonly status: number;\n readonly details?: Record<string, string | number | boolean>;\n /** Seconds to wait before retrying — present only on `RATE_LIMITED`. */\n readonly retryAfterSeconds?: number;\n\n constructor(\n code: BowlosErrorCode,\n message: string,\n status: number,\n options: BowlosApiErrorOptions = {},\n ) {\n super(message, options.cause === undefined ? undefined : { cause: options.cause });\n this.name = \"BowlosApiError\";\n this.code = code;\n this.status = status;\n this.details = options.details;\n this.retryAfterSeconds = options.retryAfterSeconds;\n // Restore prototype chain for instanceof across transpile targets.\n Object.setPrototypeOf(this, BowlosApiError.prototype);\n }\n\n /** Too many requests — caller should back off `retryAfterSeconds`. */\n get isRateLimited(): boolean {\n return this.code === BOWLOS_ERROR_CODES.RATE_LIMITED;\n }\n\n /** Bad/expired login. The session could not be established or has lapsed. */\n get isAuthError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.INVALID_CREDENTIALS ||\n this.code === BOWLOS_ERROR_CODES.PERMISSION_DENIED ||\n this.code === BOWLOS_ERROR_CODES.SCOPE_REVOKED\n );\n }\n\n /** Wrong/missing API key or a disallowed origin — a site-config problem,\n * not something the end customer can fix. */\n get isConfigError(): boolean {\n return (\n this.code === BOWLOS_ERROR_CODES.API_KEY_MISSING ||\n this.code === BOWLOS_ERROR_CODES.API_KEY_INVALID ||\n this.code === BOWLOS_ERROR_CODES.ORIGIN_NOT_ALLOWED\n );\n }\n}\n","/**\n * React layer for @bowlos/reservations.\n *\n * `<BowlosProvider>` holds one `BowlosClient`; `useAccount()` manages the\n * customer session (probe on mount, sign-in/up/link/out, current customer);\n * `useBowlosQuery()` is the generic read hook the typed data hooks\n * (`useAvailability`, `useBookingFlow`, …) will build on next.\n *\n * Lives in its own module so non-React consumers of the core never pull React.\n * (The `@bowlos/reservations/react` export subpath is wired with the publish build.)\n */\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { BowlosClient, createBowlosClient } from \"./client\";\nimport { BowlosApiError } from \"./errors\";\nimport type { AuthState, BowlosClientConfig, Customer, LinkProfile } from \"./types\";\n\nconst BowlosContext = createContext<BowlosClient | null>(null);\nconst AccountContext = createContext<UseAccountResult | null>(null);\n\nexport interface BowlosProviderProps {\n /** A prebuilt client, or pass `config` to have one created and memoized. */\n client?: BowlosClient;\n config?: BowlosClientConfig;\n children: ReactNode;\n}\n\nexport function BowlosProvider({ client, config, children }: BowlosProviderProps) {\n const ref = useRef<BowlosClient | null>(client ?? null);\n if (!ref.current) {\n if (!config) {\n throw new Error(\"BowlosProvider requires either a `client` or a `config`.\");\n }\n ref.current = createBowlosClient(config);\n }\n const bowlosClient = ref.current as BowlosClient; // non-null after the guard above\n // Run the session machine ONCE here and share it via context, so every\n // useAccount() across the app sees the same session.\n const account = useAccountState(bowlosClient);\n return (\n <BowlosContext.Provider value={bowlosClient}>\n <AccountContext.Provider value={account}>{children}</AccountContext.Provider>\n </BowlosContext.Provider>\n );\n}\n\nexport function useBowlosClient(): BowlosClient {\n const client = useContext(BowlosContext);\n if (!client) {\n throw new Error(\"useBowlosClient must be used within a <BowlosProvider>.\");\n }\n return client;\n}\n\n// ── useAccount ──────────────────────────────────────────────────────────────\n\nexport type AccountStatus = \"loading\" | AuthState;\n\nexport interface UseAccountResult {\n status: AccountStatus;\n customer: Customer | null;\n error: BowlosApiError | null;\n signIn: (email: string, password: string) => Promise<void>;\n /** Atomic sign-up (preferred): login + customer profile in one call. */\n register: (\n email: string,\n password: string,\n profile: Omit<LinkProfile, \"email\">,\n ) => Promise<void>;\n signUp: (email: string, password: string) => Promise<void>;\n link: (profile: LinkProfile) => Promise<void>;\n /** Forgot-password step 1: email a reset code (no session change). Always\n * resolves — the server never reveals whether the email has an account. */\n requestPasswordReset: (email: string) => Promise<void>;\n /** Forgot-password step 2: verify the code + set a new password. On success\n * the customer is signed in (status flips to linked). */\n resetPassword: (\n email: string,\n code: string,\n newPassword: string,\n ) => Promise<void>;\n signOut: () => Promise<void>;\n refresh: () => Promise<void>;\n}\n\n/** The session state machine — runs ONCE inside `<BowlosProvider>` and is shared\n * via context. Probes once on mount; each action re-probes so `status`/`customer`\n * stay current. Consumers use `useAccount()`, never this directly. */\nfunction useAccountState(client: BowlosClient): UseAccountResult {\n const [status, setStatus] = useState<AccountStatus>(\"loading\");\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n\n const refresh = useCallback(async () => {\n try {\n const state = await client.probe();\n setStatus(state);\n setCustomer(state === \"linked\" ? await client.me() : null);\n setError(null);\n } catch (e) {\n setStatus(\"unauthenticated\");\n setCustomer(null);\n if (e instanceof BowlosApiError) setError(e);\n }\n }, [client]);\n\n useEffect(() => {\n void refresh();\n }, [refresh]);\n\n const run = useCallback(\n async (action: () => Promise<unknown>) => {\n setError(null);\n try {\n await action();\n await refresh();\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [refresh],\n );\n\n const signIn = useCallback(\n (email: string, password: string) => run(() => client.signIn(email, password)),\n [client, run],\n );\n const register = useCallback(\n (email: string, password: string, profile: Omit<LinkProfile, \"email\">) =>\n run(() => client.register(email, password, profile)),\n [client, run],\n );\n const signUp = useCallback(\n (email: string, password: string) => run(() => client.signUp(email, password)),\n [client, run],\n );\n const link = useCallback((profile: LinkProfile) => run(() => client.link(profile)), [client, run]);\n // Step 1 doesn't change the session, so it doesn't re-probe — just surfaces\n // errors. Step 2 signs the customer in, so it runs through `run` (re-probe).\n const requestPasswordReset = useCallback(\n async (email: string) => {\n setError(null);\n try {\n await client.requestPasswordReset(email);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n }\n },\n [client],\n );\n const resetPassword = useCallback(\n (email: string, code: string, newPassword: string) =>\n run(() => client.resetPassword(email, code, newPassword)),\n [client, run],\n );\n const signOut = useCallback(() => run(() => client.signOut()), [client, run]);\n\n return {\n status,\n customer,\n error,\n signIn,\n register,\n signUp,\n link,\n requestPasswordReset,\n resetPassword,\n signOut,\n refresh,\n };\n}\n\n/**\n * The customer session (state + actions), shared across the whole app. Every\n * call returns the SAME session — signing in or out anywhere updates the header,\n * the booking form, everywhere at once. Must be used within a `<BowlosProvider>`.\n */\nexport function useAccount(): UseAccountResult {\n const account = useContext(AccountContext);\n if (!account) {\n throw new Error(\"useAccount must be used within a <BowlosProvider>.\");\n }\n return account;\n}\n\n// ── useBowlosQuery ────────────────────────────────────────────────────────────\n\nexport interface UseQueryOptions {\n /** Send the customer bearer token (for session-scoped reads). */\n auth?: boolean;\n /** Skip fetching until true. Defaults to true. */\n enabled?: boolean;\n}\n\nexport interface UseQueryResult<T> {\n data: T | null;\n error: BowlosApiError | null;\n loading: boolean;\n refetch: () => Promise<void>;\n}\n\n/** Generic read hook over a gateway route. The typed data hooks\n * (`useAvailability`, etc.) will wrap this with route names + arg types. */\nexport function useBowlosQuery<T = unknown>(\n name: string,\n args: Record<string, unknown> = {},\n options: UseQueryOptions = {},\n): UseQueryResult<T> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const enabled = options.enabled ?? true;\n const [data, setData] = useState<T | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(enabled);\n // Stabilize the args object across renders so the effect doesn't loop.\n const argsKey = JSON.stringify(args);\n\n const refetch = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<T>(name, JSON.parse(argsKey) as Record<string, unknown>, {\n auth,\n });\n setData(result);\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n setData(null);\n } finally {\n setLoading(false);\n }\n }, [client, name, argsKey, auth]);\n\n useEffect(() => {\n if (enabled) void refetch();\n }, [enabled, refetch]);\n\n return { data, error, loading, refetch };\n}\n\n// ── useBowlosMutation ─────────────────────────────────────────────────────────\n\nexport interface UseMutationResult<TArgs, TData> {\n /** Fire the mutation. Resolves with the data, or throws BowlosApiError. */\n run: (args: TArgs) => Promise<TData>;\n data: TData | null;\n error: BowlosApiError | null;\n loading: boolean;\n reset: () => void;\n}\n\n/** Generic write hook over a gateway route. The typed mutation hooks\n * (`useCancelMyReservation`, etc.) wrap this with a route name + arg type. */\nexport function useBowlosMutation<TArgs extends Record<string, unknown>, TData = unknown>(\n name: string,\n options: { auth?: boolean } = {},\n): UseMutationResult<TArgs, TData> {\n const client = useBowlosClient();\n const auth = options.auth ?? false;\n const [data, setData] = useState<TData | null>(null);\n const [error, setError] = useState<BowlosApiError | null>(null);\n const [loading, setLoading] = useState<boolean>(false);\n\n const run = useCallback(\n async (args: TArgs) => {\n setLoading(true);\n setError(null);\n try {\n const result = await client.call<TData>(name, args, { auth });\n setData(result);\n return result;\n } catch (e) {\n if (e instanceof BowlosApiError) setError(e);\n throw e;\n } finally {\n setLoading(false);\n }\n },\n [client, name, auth],\n );\n\n const reset = useCallback(() => {\n setData(null);\n setError(null);\n setLoading(false);\n }, []);\n\n return { run, data, error, loading, reset };\n}\n","/**\n * Typed React data hooks for the booking funnel, built on `useBowlosQuery`.\n * Same arg/result types as the framework-agnostic functions in `data.ts`.\n */\nimport type {\n SavedCardScope,\n SavedCardArgs,\n SavedCardsResult,\n CardSetupResult,\n ChangePasswordArgs,\n} from \"./account\";\nimport { useCallback } from \"react\";\nimport {\n useBowlosClient,\n useBowlosQuery,\n useBowlosMutation,\n type UseQueryOptions,\n type UseQueryResult,\n type UseMutationResult,\n} from \"./react\";\nimport { useIdempotentMutation } from \"./idempotent-mutation\";\nimport type {\n CancelPreview,\n CancelResult,\n MyGameCard,\n ReservationCancelArgs,\n OrderCancelArgs,\n GameCardCancelArgs,\n} from \"./account\";\nimport type {\n AvailabilityArgs,\n AvailabilityResult,\n BookingPreviewArgs,\n BookingQuote,\n PublicAddon,\n StartTimesArgs,\n PackagePreviewArgs,\n PackagePreviewResult,\n GameCardPreviewArgs,\n GameCardPreviewResult,\n EventTicketPreviewArgs,\n EventTicketPreviewResult,\n MembershipPreviewArgs,\n MembershipPreviewResult,\n MembershipSubscriptionPreviewResult,\n} from \"./data\";\nimport type {\n BrandScoped,\n EventOrderDetailArgs,\n FlashBookingOptionsArgs,\n FlashSaleArgs,\n FlashSalesArgs,\n MembershipDetailArgs,\n ReservationDetailArgs,\n} from \"./account\";\nimport type {\n BrandCatalogArgs,\n CatalogArgs,\n CatalogResult,\n CenterScoped,\n PackageDetailArgs,\n CenterHoursArgs,\n RetailPricing,\n} from \"./catalog\";\n\n/** Live available-unit (unoccupied) count for a product / date / time window. */\nexport function useAvailability(\n args: AvailabilityArgs,\n options?: UseQueryOptions,\n): UseQueryResult<AvailabilityResult> {\n return useBowlosQuery<AvailabilityResult>(\"checkAvailability\", args, options);\n}\n\n/** Authoritative price quote for the chosen booking inputs. */\nexport function useBookingPreview(\n args: BookingPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<BookingQuote> {\n return useBowlosQuery<BookingQuote>(\"bookingPreview\", args, options);\n}\n\n/** Bookable add-ons (shoe rental, upgrades…) for a product. */\nexport function useAddons(\n args: { productId: string },\n options?: UseQueryOptions,\n): UseQueryResult<PublicAddon[]> {\n return useBowlosQuery<PublicAddon[]>(\"listPublicAddons\", args, options);\n}\n\n/** Bookable start times (minute-of-day) for a product on a date. */\nexport function useStartTimes(\n args: StartTimesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<number[]> {\n return useBowlosQuery<number[]>(\"availableStartTimes\", args, options);\n}\n\n// ── account (require a signed-in customer) ───────────────────────────────────\n// Results are generic (`<T = unknown>`) — parameterize with your own shape.\n\n/** The signed-in customer's reservations. */\nexport function useMyReservations<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyReservations\", args, { ...options, auth: true });\n}\n\n/** One of the customer's reservations, by displayId. */\nexport function useMyReservationDetail<T = unknown>(\n args: ReservationDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyReservationDetail\", args, { ...options, auth: true });\n}\n\n/** The signed-in customer's event ticket orders. */\nexport function useMyEventOrders<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyEventOrders\", args, { ...options, auth: true });\n}\n\n/** One of the customer's event ticket orders. */\nexport function useMyEventOrder<T = unknown>(\n args: EventOrderDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyEventOrder\", args, { ...options, auth: true });\n}\n\n/** The customer's memberships. */\nexport function useMyMemberships<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyMemberships\", args, { ...options, auth: true });\n}\n\n/** One membership's detail. */\nexport function useMyMembershipDetail<T = unknown>(\n args: MembershipDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyMembershipDetail\", args, { ...options, auth: true });\n}\n\n/** Loyalty tier + points. */\nexport function useMyLoyalty<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getMyLoyalty\", args, { ...options, auth: true });\n}\n\n/** Account credit balance + ledger. */\nexport function useMyCredits<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyCredits\", args, { ...options, auth: true });\n}\n\n/** Issued wallet passes. */\nexport function useMyPasses<T = unknown>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyPasses\", args, { ...options, auth: true });\n}\n\n/** The customer's game cards for this Brand (with the unused-only `cancellable`\n * flag), so a headless site can list them + drive cancel. */\nexport function useMyGameCards<T = MyGameCard[]>(\n args: BrandScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listMyGameCards\", args, { ...options, auth: true });\n}\n\n// ── self-serve cancel (v0.23.0): preview reads + cancel mutations ─────────────\n//\n// Per type: preview \"what you'll get back\" → confirm → cancel. The cancel hooks\n// retain an idempotencyKey across retries of the same action.\n// Game cards cancel only while fully unused (locked rule) → full credit.\n\n/** Preview the credit for cancelling a reservation (advisory; cancel re-computes). */\nexport function useReservationCancelPreview<T = CancelPreview>(\n args: { brandId: string; reservationId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling an event order. */\nexport function useEventOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyEventOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a package order. */\nexport function usePackageOrderCancelPreview<T = CancelPreview>(\n args: { brandId: string; orderId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyPackageOrderCancellation\", args, { ...options, auth: true });\n}\n/** Preview the credit for cancelling a game card (full credit only if unused). */\nexport function useGameCardCancelPreview<T = CancelPreview>(\n args: { brandId: string; cardId: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMyGameCardCancellation\", args, { ...options, auth: true });\n}\n\n/** Cancel a reservation → store credit per policy. Pass the `version` from the\n * list/detail as `expectedVersion`; the hook supplies the idempotency key. */\nexport function useCancelMyReservation() {\n return useIdempotentMutation<ReservationCancelArgs, CancelResult>(\"cancelMyReservation\", {\n auth: true,\n });\n}\n/** Cancel an event order → store credit per policy. */\nexport function useCancelMyEventOrder() {\n return useIdempotentMutation<OrderCancelArgs, CancelResult>(\"cancelMyEventOrder\", { auth: true });\n}\n/** Cancel a package order → store credit per policy; releases the slot. */\nexport function useCancelMyPackageOrder() {\n return useIdempotentMutation<OrderCancelArgs, CancelResult>(\"cancelMyPackageOrder\", {\n auth: true,\n });\n}\n/** Cancel a game card → full credit (unused cards only). */\nexport function useCancelMyGameCard() {\n return useIdempotentMutation<GameCardCancelArgs, CancelResult>(\"cancelMyGameCard\", {\n auth: true,\n });\n}\n\n// ── flash sales (session-aware: members see prices) ──────────────────────────\n\n/** The public flash-sale page (members see prices; anonymous gets the locked view). */\nexport function useFlashSale<T = unknown>(\n args: FlashSaleArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicFlashSaleBySlug\", args, { ...options, auth: true });\n}\n\n/** The public flash-sale index for a Brand (live + upcoming; no prices). Public. */\nexport function useFlashSales<T = unknown>(\n args: FlashSalesArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicFlashSales\", args, options);\n}\n\n/** Per-start-hour options for a flash-sale reservation item (members only). */\nexport function useFlashSaleBookingOptions<T = unknown>(\n args: FlashBookingOptionsArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getFlashSaleBookingOptions\", args, { ...options, auth: true });\n}\n\n// ── public catalog (anonymous; power `<BookingCatalog>`) ──────────────────────\n\n/**\n * The canonical public catalog for a surface — every category grouped, with the\n * Center admin's per-surface visibility already applied. Prefer this over the\n * per-category hooks below when you want the full, visibility-aware catalog\n * (it stays consistent with the white-label web + mobile surfaces). Anonymous.\n */\nexport function useCatalog<T = CatalogResult>(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicCatalog\", args, options);\n}\n\n/**\n * Full Test Mode (2026-06-23): is this Center in operator-enabled test mode?\n * Reads the same `listPublicCatalog` payload as `useCatalog`, so it's free when\n * you already render the catalog. Show `<MaintenanceBanner>` (or your own themed\n * notice) when `maintenanceMode` is true — normal-customer bookings are\n * server-refused in this state (`CENTER_IN_MAINTENANCE`); only admin\n * Test-Account customers transact.\n */\nexport function useTestMode(\n args: CatalogArgs,\n options?: UseQueryOptions,\n): { maintenanceMode: boolean; loading: boolean } {\n const res = useCatalog(args, options);\n return {\n maintenanceMode: res.data?.maintenanceMode === true,\n loading: res.loading,\n };\n}\n\n/** Bookable products at a Center (each carries `attractionTypeKey`). */\nexport function useProducts<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicProducts\", args, options);\n}\n\n/** Upcoming pricing events at a Center. */\nexport function useEvents<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEvents\", args, options);\n}\n\n/** Sellable event offers at a Center. Use these for the product lineup and\n * event landing pages; each row carries a slug and purchase mode. */\nexport function useEventOffers<T = import(\"./toolkit-types\").EventOffer[]>(\n args: CenterScoped & { includeWithoutLandingPage?: boolean },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicEventOffers\", args, options);\n}\n\n/** One sellable event offer by landing-page slug. */\nexport function useEventOffer<T = unknown>(\n args: { slug: string },\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicEventOffer\", args, options);\n}\n\n/** Purchasable packages at a Brand. */\nexport function usePackages<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicPackages\", args, options);\n}\n\n/** Full detail for one package (components, add-ons, allowed start times, …) —\n * drives the headless package config UI before `usePackagePurchase`. */\nexport function usePackage<T = unknown>(\n args: PackageDetailArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getPublicPackage\", args, options);\n}\n\n/** A Center's public price list — walk-in (matrix) rates grouped by attraction\n * plus opted-in \"website specials\". Anonymous, read-only; drives a printed-\n * menu-style pricing page (or the reference `<PricingTable>`). Not a booking\n * surface — render-only. */\nexport function useRetailPricing<T = RetailPricing>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listRetailPricing\", args, options);\n}\n\n/** A Center's open/close window for the given attraction types on a date — use\n * the package's component attraction-type keys to bound its bookable slots. */\nexport function useCenterHours<T = unknown>(\n args: CenterHoursArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"getCenterOperatingHoursForTypes\", args, options);\n}\n\n/** Itemized quote for a package order — base, add-ons, tax lines, the selling\n * Center's booking fee, and the authoritative grand total. Drives the headless\n * **Review** step. Requires a signed-in customer (tax exemptions are applied),\n * and is computed by the same engine as the PaymentIntent, so it never diverges\n * from what the customer is charged. */\nexport function usePackagePreview<T = PackagePreviewResult>(\n args: PackagePreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewPackageOrder\", args, { ...options, auth: true });\n}\n\n/** Purchasable memberships at a Center. */\nexport function usePublicMemberships<T = unknown>(\n args: CenterScoped,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicMemberships\", args, options);\n}\n\n/** Purchasable game cards / passes at a Brand. */\nexport function useGameCards<T = unknown>(\n args: BrandCatalogArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"listPublicGameCards\", args, options);\n}\n\n/** Itemized quote for a game-pass purchase — the base price, tax lines, the\n * selling Center's booking fee, and the authoritative grand total. Drives the\n * headless **Review** step. Requires a signed-in customer (tax exemptions are\n * applied + the home Center is resolved server-side), and is computed by the\n * same engine as the PaymentIntent, so it never diverges from what the\n * customer is charged. */\nexport function useGameCardPreview<T = GameCardPreviewResult>(\n args: GameCardPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewGameCardOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a ticket-mode event offer — base tickets, tax lines,\n * Center event fee, and authoritative grand total. Requires a signed-in\n * customer so tax exemptions match the eventual charge. */\nexport function useEventTicketPreview<T = EventTicketPreviewResult>(\n args: EventTicketPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewEventTicketOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a one-time membership purchase — dues, the one-time setup\n * fee, tax lines, the selling Center's booking fee, and the authoritative grand\n * total. Drives the headless **Review** step. Requires a signed-in customer (tax\n * exemptions are applied + the home Center is resolved server-side), and is\n * computed by the same engine as the PaymentIntent, so it never diverges from\n * what the customer is charged. */\nexport function useMembershipPreview<T = MembershipPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipOrder\", args, { ...options, auth: true });\n}\n\n/** Itemized quote for a RECURRING membership subscription — the one-time Review\n * fields (\"Due today\") PLUS `recurringTotalCents` + `cadence` (\"Auto-renews\n * at\"). Drives the recurring **Review** step. Requires a signed-in customer, and\n * is computed by the same engine as the subscription's first invoice, so it\n * never diverges from what the customer is charged. */\nexport function useMembershipSubscriptionPreview<T = MembershipSubscriptionPreviewResult>(\n args: MembershipPreviewArgs,\n options?: UseQueryOptions,\n): UseQueryResult<T> {\n return useBowlosQuery<T>(\"previewMembershipSubscriptionOrder\", args, {\n ...options,\n auth: true,\n });\n}\n\nexport function useSavedCards(\n args: SavedCardScope,\n options?: UseQueryOptions,\n): UseQueryResult<SavedCardsResult> {\n return useBowlosQuery<SavedCardsResult>(\"listMyPaymentMethods\", args, { ...options, auth: true });\n}\nexport function useCreateCardSetup(): UseMutationResult<SavedCardScope, CardSetupResult> {\n return useBowlosMutation<SavedCardScope, CardSetupResult>(\"createSetupIntentForAddingCard\", {\n auth: true,\n });\n}\nexport function useRemoveCard(): UseMutationResult<SavedCardArgs, { detached: boolean }> {\n return useBowlosMutation<SavedCardArgs, { detached: boolean }>(\"detachPaymentMethod\", {\n auth: true,\n });\n}\nexport function useSetDefaultCard(): UseMutationResult<SavedCardArgs, { ok: boolean }> {\n return useBowlosMutation<SavedCardArgs, { ok: boolean }>(\"setDefaultPaymentMethod\", {\n auth: true,\n });\n}\nexport function useChangePassword(): UseMutationResult<ChangePasswordArgs, { ok: true }> {\n const client = useBowlosClient();\n const mutation = useBowlosMutation<ChangePasswordArgs, { ok: true }>(\"changeMyPassword\", {\n auth: true,\n });\n const run = useCallback(\n async (args: ChangePasswordArgs) => {\n const result = await mutation.run(args);\n await client.signOut();\n return result;\n },\n [client, mutation.run],\n );\n return { ...mutation, run };\n}\n","\"use client\";\nimport { useRef, useState, type ReactNode } from \"react\";\nimport { styles } from \"./shared\";\n\n/** Shared status handling keeps rejected mutations in the page and focuses errors. */\nexport function useAccountAction() {\n const [busy, setBusy] = useState(false);\n const [message, setMessage] = useState(\"\");\n const [failed, setFailed] = useState(false);\n const alert = useRef<HTMLParagraphElement>(null);\n const locked = useRef(false);\n async function run(action: () => Promise<unknown>, success = \"\") {\n if (locked.current) return;\n locked.current = true;\n setBusy(true);\n setMessage(\"\");\n setFailed(false);\n try {\n await action();\n setMessage(success);\n } catch (error) {\n setFailed(true);\n setMessage(error instanceof Error ? error.message : \"Unable to complete this request.\");\n setTimeout(() => alert.current?.focus(), 0);\n } finally {\n locked.current = false;\n setBusy(false);\n }\n }\n return {\n busy,\n run,\n feedback: message ? (\n <p ref={alert} tabIndex={-1} role={failed ? \"alert\" : \"status\"}>\n {message}\n </p>\n ) : null,\n };\n}\n\nexport function AccountPanel({\n title,\n children,\n className,\n}: {\n title: string;\n children: ReactNode;\n className?: string;\n}) {\n return (\n <section aria-label={title} className={className} style={styles().panel}>\n <h2 style={styles().heading}>{title}</h2>\n {children}\n </section>\n );\n}\nexport function QueryState({\n loading,\n error,\n loadingLabel = \"Loading…\",\n}: {\n loading: boolean;\n error: { message: string } | null;\n loadingLabel?: string;\n}) {\n return error ? (\n <p role=\"alert\">{error.message}</p>\n ) : loading ? (\n <p role=\"status\">{loadingLabel}</p>\n ) : null;\n}\n","\"use client\";\nimport { useMemo, useState } from \"react\";\nimport { loadStripe, type Appearance } from \"@stripe/stripe-js\";\nimport { Elements, PaymentElement, useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport { useCreateCardSetup } from \"../hooks\";\nimport type { CardSetupResult, SavedCardScope } from \"../account\";\nimport { AccountPanel, useAccountAction } from \"./account-shared\";\nimport { styles } from \"./shared\";\nexport interface AddCardFormProps extends SavedCardScope {\n onAdded?: () => void;\n appearance?: Appearance;\n labels?: Partial<{ title: string; start: string; save: string; saved: string; error: string }>;\n className?: string;\n}\nexport function AddCardForm({\n brandId,\n centerId,\n onAdded,\n appearance,\n labels,\n className,\n}: AddCardFormProps) {\n const t = {\n title: \"Add a card\",\n start: \"Add card\",\n save: \"Save card\",\n saved: \"Card saved.\",\n error: \"Unable to save this card.\",\n ...labels,\n };\n const setup = useCreateCardSetup();\n const action = useAccountAction();\n const [intent, setIntent] = useState<CardSetupResult>();\n const stripe = useMemo(\n () =>\n intent ? loadStripe(intent.publishableKey, { stripeAccount: intent.stripeAccount }) : null,\n [intent],\n );\n return (\n <AccountPanel title={t.title} className={className}>\n {!intent ? (\n <button\n style={styles().primaryBtn}\n disabled={action.busy}\n onClick={() =>\n void action.run(async () => setIntent(await setup.run({ brandId, centerId })))\n }\n >\n {t.start}\n </button>\n ) : (\n <Elements stripe={stripe} options={{ clientSecret: intent.clientSecret, appearance }}>\n <SetupForm\n labels={t}\n onAdded={() => {\n setIntent(undefined);\n onAdded?.();\n }}\n />\n </Elements>\n )}\n {action.feedback}\n </AccountPanel>\n );\n}\nfunction SetupForm({\n labels,\n onAdded,\n}: {\n labels: { save: string; saved: string; error: string };\n onAdded: () => void;\n}) {\n const stripe = useStripe();\n const elements = useElements();\n const action = useAccountAction();\n return (\n <form\n style={styles().stack}\n onSubmit={(e) => {\n e.preventDefault();\n if (!stripe || !elements) return;\n void action.run(async () => {\n const result = await stripe.confirmSetup({ elements, redirect: \"if_required\" });\n if (result.error) throw new Error(result.error.message ?? labels.error);\n if (result.setupIntent?.status !== \"succeeded\") throw new Error(labels.error);\n onAdded();\n }, labels.saved);\n }}\n >\n <PaymentElement />\n <button style={styles().primaryBtn} disabled={!stripe || !elements || action.busy}>\n {labels.save}\n </button>\n {action.feedback}\n </form>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Appearance } from '@stripe/stripe-js';
3
- import { j as ConnectedPaymentInput } from './data-BJkB-tvM.cjs';
3
+ import { o as ConnectedPaymentInput, ad as SavedCardScope } from './account-DEX2Lr78.cjs';
4
4
 
5
5
  /** Visible strings — override any subset for copy/i18n. */
6
6
  interface BowlosPaymentFormLabels {
@@ -51,4 +51,18 @@ interface BowlosPaymentFormProps {
51
51
  */
52
52
  declare function BowlosPaymentForm({ paymentIntent, publishableKey, testPublishableKey, onPaid, onError, amountCents, saveCard, appearance, labels, className, }: BowlosPaymentFormProps): react_jsx_runtime.JSX.Element;
53
53
 
54
- export { BowlosPaymentForm, type BowlosPaymentFormLabels, type BowlosPaymentFormProps };
54
+ interface AddCardFormProps extends SavedCardScope {
55
+ onAdded?: () => void;
56
+ appearance?: Appearance;
57
+ labels?: Partial<{
58
+ title: string;
59
+ start: string;
60
+ save: string;
61
+ saved: string;
62
+ error: string;
63
+ }>;
64
+ className?: string;
65
+ }
66
+ declare function AddCardForm({ brandId, centerId, onAdded, appearance, labels, className, }: AddCardFormProps): react_jsx_runtime.JSX.Element;
67
+
68
+ export { AddCardForm, type AddCardFormProps, BowlosPaymentForm, type BowlosPaymentFormLabels, type BowlosPaymentFormProps };
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { Appearance } from '@stripe/stripe-js';
3
- import { j as ConnectedPaymentInput } from './data-BJkB-tvM.js';
3
+ import { o as ConnectedPaymentInput, ad as SavedCardScope } from './account-DEX2Lr78.js';
4
4
 
5
5
  /** Visible strings — override any subset for copy/i18n. */
6
6
  interface BowlosPaymentFormLabels {
@@ -51,4 +51,18 @@ interface BowlosPaymentFormProps {
51
51
  */
52
52
  declare function BowlosPaymentForm({ paymentIntent, publishableKey, testPublishableKey, onPaid, onError, amountCents, saveCard, appearance, labels, className, }: BowlosPaymentFormProps): react_jsx_runtime.JSX.Element;
53
53
 
54
- export { BowlosPaymentForm, type BowlosPaymentFormLabels, type BowlosPaymentFormProps };
54
+ interface AddCardFormProps extends SavedCardScope {
55
+ onAdded?: () => void;
56
+ appearance?: Appearance;
57
+ labels?: Partial<{
58
+ title: string;
59
+ start: string;
60
+ save: string;
61
+ saved: string;
62
+ error: string;
63
+ }>;
64
+ className?: string;
65
+ }
66
+ declare function AddCardForm({ brandId, centerId, onAdded, appearance, labels, className, }: AddCardFormProps): react_jsx_runtime.JSX.Element;
67
+
68
+ export { AddCardForm, type AddCardFormProps, BowlosPaymentForm, type BowlosPaymentFormLabels, type BowlosPaymentFormProps };
package/dist/payments.js CHANGED
@@ -1,4 +1,6 @@
1
- import { styles, formatCents } from './chunk-Y3YSDO3H.js';
1
+ import { styles, formatCents, useAccountAction, AccountPanel } from './chunk-FMFHNBDH.js';
2
+ import { useCreateCardSetup } from './chunk-BWJHRJN6.js';
3
+ import './chunk-44WKP6MW.js';
2
4
  import { useMemo, useState } from 'react';
3
5
  import { loadStripe } from '@stripe/stripe-js';
4
6
  import { Elements, useStripe, useElements, PaymentElement } from '@stripe/react-stripe-js';
@@ -88,7 +90,81 @@ function PayForm({
88
90
  message && /* @__PURE__ */ jsx("p", { role: "alert", style: s.error, children: message })
89
91
  ] });
90
92
  }
93
+ function AddCardForm({
94
+ brandId,
95
+ centerId,
96
+ onAdded,
97
+ appearance,
98
+ labels,
99
+ className
100
+ }) {
101
+ const t = {
102
+ title: "Add a card",
103
+ start: "Add card",
104
+ save: "Save card",
105
+ saved: "Card saved.",
106
+ error: "Unable to save this card.",
107
+ ...labels
108
+ };
109
+ const setup = useCreateCardSetup();
110
+ const action = useAccountAction();
111
+ const [intent, setIntent] = useState();
112
+ const stripe = useMemo(
113
+ () => intent ? loadStripe(intent.publishableKey, { stripeAccount: intent.stripeAccount }) : null,
114
+ [intent]
115
+ );
116
+ return /* @__PURE__ */ jsxs(AccountPanel, { title: t.title, className, children: [
117
+ !intent ? /* @__PURE__ */ jsx(
118
+ "button",
119
+ {
120
+ style: styles().primaryBtn,
121
+ disabled: action.busy,
122
+ onClick: () => void action.run(async () => setIntent(await setup.run({ brandId, centerId }))),
123
+ children: t.start
124
+ }
125
+ ) : /* @__PURE__ */ jsx(Elements, { stripe, options: { clientSecret: intent.clientSecret, appearance }, children: /* @__PURE__ */ jsx(
126
+ SetupForm,
127
+ {
128
+ labels: t,
129
+ onAdded: () => {
130
+ setIntent(void 0);
131
+ onAdded?.();
132
+ }
133
+ }
134
+ ) }),
135
+ action.feedback
136
+ ] });
137
+ }
138
+ function SetupForm({
139
+ labels,
140
+ onAdded
141
+ }) {
142
+ const stripe = useStripe();
143
+ const elements = useElements();
144
+ const action = useAccountAction();
145
+ return /* @__PURE__ */ jsxs(
146
+ "form",
147
+ {
148
+ style: styles().stack,
149
+ onSubmit: (e) => {
150
+ e.preventDefault();
151
+ if (!stripe || !elements) return;
152
+ void action.run(async () => {
153
+ const result = await stripe.confirmSetup({ elements, redirect: "if_required" });
154
+ if (result.error) throw new Error(result.error.message ?? labels.error);
155
+ if (result.setupIntent?.status !== "succeeded") throw new Error(labels.error);
156
+ onAdded();
157
+ }, labels.saved);
158
+ },
159
+ children: [
160
+ /* @__PURE__ */ jsx(PaymentElement, {}),
161
+ /* @__PURE__ */ jsx("button", { style: styles().primaryBtn, disabled: !stripe || !elements || action.busy, children: labels.save }),
162
+ action.feedback
163
+ ]
164
+ }
165
+ );
166
+ }
91
167
 
92
- export { BowlosPaymentForm };
168
+ export { AddCardForm, BowlosPaymentForm };
93
169
  //# sourceMappingURL=payments.js.map
94
170
  //# sourceMappingURL=payments.js.map