@usethrottle/auth 0.3.1 → 0.5.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.
@@ -79,7 +79,7 @@ __export(components_exports, {
79
79
  module.exports = __toCommonJS(components_exports);
80
80
 
81
81
  // src/react/components/provider.tsx
82
- var import_react32 = require("react");
82
+ var import_react31 = require("react");
83
83
 
84
84
  // src/errors.ts
85
85
  var ThrottleAuthError = class extends Error {
@@ -459,6 +459,8 @@ function createAccount(auth) {
459
459
  getInvoicePdfUrl: (id) => call("GET", `/me/invoices/${seg(id)}/pdf`),
460
460
  listSubscriptions: (page) => call("GET", `/me/subscriptions${query(page)}`),
461
461
  getSubscription: (id) => call("GET", `/me/subscriptions/${seg(id)}`),
462
+ cancelOrder: (id, opts) => call("POST", `/me/orders/${seg(id)}/cancel`, opts),
463
+ requestOrderReturn: (id, input) => call("POST", `/me/orders/${seg(id)}/return-request`, input),
462
464
  cancelSubscription: (id, opts) => call("POST", `/me/subscriptions/${seg(id)}/cancel`, opts),
463
465
  pauseSubscription: (id) => call("POST", `/me/subscriptions/${seg(id)}/pause`),
464
466
  resumeSubscription: (id) => call("POST", `/me/subscriptions/${seg(id)}/resume`),
@@ -771,6 +773,23 @@ var THROTTLE_ELEMENT_KEYS = [
771
773
  "orderDetail.payButton",
772
774
  "orderDetail.trackButton",
773
775
  "orderDetail.reorderButton",
776
+ // Two-column detail layout, shared by the order and invoice pages.
777
+ "orderDetail.layout",
778
+ "orderDetail.main",
779
+ "orderDetail.rail",
780
+ "orderDetail.cancelButton",
781
+ "orderDetail.returnButton",
782
+ "orderDetail.invoiceButton",
783
+ "orderDetail.actions",
784
+ "invoiceDetail.layout",
785
+ "invoiceDetail.main",
786
+ "invoiceDetail.rail",
787
+ "invoiceDetail.lineItems",
788
+ "invoiceDetail.lineItem",
789
+ "invoiceDetail.orderLink",
790
+ "invoiceDetail.subscriptionLink",
791
+ "invoiceDetail.payButton",
792
+ "invoiceDetail.actions",
774
793
  "fieldRow",
775
794
  "confirm.header",
776
795
  "confirm.title",
@@ -921,6 +940,23 @@ function messageForError(err) {
921
940
  return "We could not find that.";
922
941
  case "payment_method_in_use":
923
942
  return e.message || "That payment method is in use and cannot be removed.";
943
+ // Order and return refusals. Every one of these is a state the buyer can
944
+ // see and act on — the order shipped, the money was taken, that quantity
945
+ // is already on another return — and the server's message names which and
946
+ // what to do instead. Flattening them to "Something went wrong" sent a
947
+ // buyer to support for something the screen could have answered. Same
948
+ // argument as payment_method_in_use above.
949
+ case "order_not_cancellable":
950
+ case "order_already_paid":
951
+ case "order_not_returnable":
952
+ case "quantity_exceeds_returnable":
953
+ case "no_items":
954
+ case "unknown_line_item":
955
+ case "return_rejected":
956
+ return e.message || "That change is not possible for this order.";
957
+ case "orders_unavailable":
958
+ case "returns_unavailable":
959
+ return "That is unavailable right now. Please contact support.";
924
960
  case "validation_error": {
925
961
  const first2 = e.details?.[0];
926
962
  if (first2?.path && first2?.message) {
@@ -1091,6 +1127,17 @@ var enUS = {
1091
1127
  payNow: "Pay now",
1092
1128
  track: "Track shipment",
1093
1129
  reorder: "Order again",
1130
+ cancelOrder: "Cancel order",
1131
+ cancelOrderConfirm: "Cancel this order?",
1132
+ cancelOrderBody: "This cannot be undone. Nothing has been charged, so there is nothing to refund.",
1133
+ cancelOrderAction: "Cancel order",
1134
+ requestReturn: "Request a return",
1135
+ requestReturnConfirm: "Request a return for this order?",
1136
+ requestReturnBody: "The merchant reviews your request and will be in touch. Nothing is refunded until they approve it.",
1137
+ requestReturnAction: "Send request",
1138
+ returnRequested: "Return requested. The merchant will be in touch.",
1139
+ downloadInvoice: "Download invoice",
1140
+ summary: "Summary",
1094
1141
  empty: "No orders yet",
1095
1142
  emptyDescription: "Orders you place will appear here.",
1096
1143
  gatedDescription: "Verify your email to see your order history.",
@@ -1154,6 +1201,12 @@ var enUS = {
1154
1201
  refunded: "Refunded",
1155
1202
  period: "Period",
1156
1203
  downloadButton: "Download PDF",
1204
+ items: "Items",
1205
+ summary: "Summary",
1206
+ viewOrder: "View order",
1207
+ viewSubscription: "View subscription",
1208
+ payButton: "Pay this invoice",
1209
+ billedTo: "Billed to",
1157
1210
  /** Display copy for `invoice.status` — the wire values are paid|open|void. */
1158
1211
  statusLabels: { paid: "Paid", open: "Open", void: "Void" },
1159
1212
  downloadUnavailable: "This invoice is not available to download right now."
@@ -1468,11 +1521,13 @@ var THROTTLE_STYLES = `
1468
1521
  align-items: center;
1469
1522
  justify-content: center;
1470
1523
  cursor: pointer;
1524
+ /* A label that wraps turns a control into a two-line block of text. */
1525
+ white-space: nowrap;
1471
1526
  transition: opacity var(--throttle-transition), background-color var(--throttle-transition), border-color var(--throttle-transition), filter var(--throttle-transition), box-shadow var(--throttle-transition);
1472
1527
  }
1473
1528
  .throttle-button:disabled { opacity: .55; cursor: not-allowed; }
1474
1529
  .throttle-button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--throttle-color-background), 0 0 0 4px var(--throttle-color-primary); }
1475
- .throttle-button--primary { background: var(--throttle-color-primary); color: var(--throttle-color-primary-foreground); width: 100%; }
1530
+ .throttle-button--primary { background: var(--throttle-color-primary); color: var(--throttle-color-primary-foreground); width: var(--throttle-button-width, 100%); }
1476
1531
  .throttle-button--primary:hover:not(:disabled) { filter: brightness(0.92); }
1477
1532
  .throttle-button--secondary { background: var(--throttle-color-surface); color: var(--throttle-color-foreground); border-color: var(--throttle-color-border-control); }
1478
1533
  .throttle-button--secondary:hover:not(:disabled) { background: var(--throttle-color-muted); }
@@ -1639,6 +1694,10 @@ var THROTTLE_STYLES = `
1639
1694
  .throttle-addresses { grid-template-columns: 1fr; }
1640
1695
  .throttle-fieldrow { grid-template-columns: 1fr; }
1641
1696
  .throttle-tabs__rail { width: 100%; }
1697
+ /* One column, and the rail stops sticking \u2014 on a phone a sticky summary
1698
+ covers the very line items it is summarising. */
1699
+ .throttle-detail { grid-template-columns: 1fr; }
1700
+ .throttle-detail__rail { position: static; }
1642
1701
  }
1643
1702
 
1644
1703
  .throttle-table { width: 100%; border-collapse: collapse; text-align: left; }
@@ -1716,12 +1775,50 @@ var THROTTLE_STYLES = `
1716
1775
  padding: var(--throttle-space-3) 0;
1717
1776
  }
1718
1777
  .throttle-rowitem:first-child { border-top: none; padding-top: 0; }
1719
- .throttle-actions { display: flex; gap: var(--throttle-space-2); flex-wrap: wrap; }
1778
+ .throttle-actions {
1779
+ display: flex; gap: var(--throttle-space-2); flex-wrap: wrap; align-items: center;
1780
+ /* Primary buttons are full-width so a form's submit fills its card. In a row
1781
+ of sibling actions that same rule made every button claim 100% and then
1782
+ shrink to share the line, squeezing Resume to 59px so its label wrapped to
1783
+ two lines inside a 48px box. A custom property INHERITS to the buttons, so
1784
+ the row opts them back to content width without a descendant selector \u2014
1785
+ those outrank the merchant overrides in appearance.elements. */
1786
+ --throttle-button-width: auto;
1787
+ }
1720
1788
  .throttle-table__money { display: block; text-align: right; font-variant-numeric: tabular-nums; }
1721
- .throttle-lineitem { display: flex; align-items: center; gap: var(--throttle-space-3); padding: var(--throttle-space-2) 0; }
1789
+ .throttle-lineitem { display: flex; align-items: flex-start; gap: var(--throttle-space-3); padding: var(--throttle-space-2) 0; }
1790
+ /* The UA's 1em paragraph margins pushed a two-line item to 96px, so five
1791
+ items filled a screen with mostly whitespace. These carry the spacing
1792
+ instead. Separate classes, not a ".throttle-lineitem p" descendant
1793
+ selector -- those outrank the merchant's appearance.elements overrides. */
1794
+ .throttle-lineitem__desc { margin: var(--throttle-space-1) 0 0; color: var(--throttle-color-muted-foreground); }
1795
+ .throttle-lineitem__meta { margin: var(--throttle-space-1) 0 0; color: var(--throttle-color-muted-foreground); font-size: var(--throttle-font-size-sm); }
1722
1796
  .throttle-lineitem__image { width: 48px; height: 48px; object-fit: cover; border-radius: var(--throttle-radius-sm); flex: none; }
1723
1797
  .throttle-totals { display: flex; flex-direction: column; gap: var(--throttle-space-1); }
1724
1798
 
1799
+ /* Order and invoice detail: the record on the left, what it costs and what
1800
+ you can do about it on the right. The rail sticks so the total and the
1801
+ actions stay reachable on an order with thirty lines, which is exactly when
1802
+ a buyer most wants them. Collapses below, where a sticky rail would eat a
1803
+ phone screen. */
1804
+ .throttle-detail { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: var(--throttle-space-6); align-items: start; }
1805
+ .throttle-detail__main { display: flex; flex-direction: column; gap: var(--throttle-space-5); min-width: 0; }
1806
+ .throttle-detail__rail {
1807
+ display: flex; flex-direction: column; gap: var(--throttle-space-4);
1808
+ position: sticky; top: var(--throttle-space-4);
1809
+ padding: var(--throttle-space-4);
1810
+ border: var(--throttle-border-width) solid var(--throttle-color-border);
1811
+ border-radius: var(--throttle-radius-md);
1812
+ background: var(--throttle-color-surface);
1813
+ }
1814
+ /* The one number the buyer came for. */
1815
+ .throttle-detail__headline { font-size: var(--throttle-font-size-xl); font-weight: 600; line-height: 1.2; }
1816
+ .throttle-detail__section { display: flex; flex-direction: column; gap: var(--throttle-space-2); }
1817
+ .throttle-detail__label { font-size: var(--throttle-font-size-sm); font-weight: 500; color: var(--throttle-color-muted-foreground); letter-spacing: .04em; text-transform: uppercase; }
1818
+ /* A rail action column: full width, stacked, so the primary reads as primary. */
1819
+ .throttle-detail__actions { display: flex; flex-direction: column; gap: var(--throttle-space-2); --throttle-button-width: 100%; }
1820
+ .throttle-detail__link { display: inline-flex; align-items: center; gap: var(--throttle-space-1); }
1821
+
1725
1822
  @media (prefers-reduced-motion: reduce) {
1726
1823
  .throttle-button, .throttle-field__input, .throttle-dropdown__item, .throttle-dropdown__trigger, .throttle-tabs__tab, .throttle-table__row, .throttle-modal__close {
1727
1824
  transition: none;
@@ -1983,12 +2080,20 @@ function Modal(props) {
1983
2080
  var import_react9 = require("react");
1984
2081
  var import_jsx_runtime14 = require("react/jsx-runtime");
1985
2082
  var ConfirmContext = (0, import_react9.createContext)(null);
1986
- function ConfirmProvider({ children }) {
2083
+ function ConfirmProvider({
2084
+ children,
2085
+ stepUpOpen = false,
2086
+ onStepUpResolve
2087
+ }) {
1987
2088
  const [request2, setRequest] = (0, import_react9.useState)(null);
2089
+ const [password, setPassword] = (0, import_react9.useState)("");
1988
2090
  const { t } = useCopy();
1989
2091
  const a = useAppearance();
1990
2092
  const titleId = (0, import_react9.useId)();
1991
2093
  const settle = (0, import_react9.useRef)(null);
2094
+ (0, import_react9.useEffect)(() => {
2095
+ if (!stepUpOpen) setPassword("");
2096
+ }, [stepUpOpen]);
1992
2097
  const answer = (0, import_react9.useCallback)((value) => {
1993
2098
  settle.current?.(value);
1994
2099
  settle.current = null;
@@ -2001,9 +2106,47 @@ function ConfirmProvider({ children }) {
2001
2106
  settle.current = resolve;
2002
2107
  });
2003
2108
  }, []);
2109
+ const showStepUp = stepUpOpen && Boolean(onStepUpResolve);
2110
+ const open = showStepUp || request2 !== null;
2111
+ const close = () => {
2112
+ if (showStepUp) onStepUpResolve(null);
2113
+ else answer(false);
2114
+ };
2004
2115
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(ConfirmContext.Provider, { value: ask, children: [
2005
2116
  children,
2006
- request2 ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Modal, { open: true, onClose: () => answer(false), labelledBy: titleId, size: "compact", children: [
2117
+ open ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { open: true, onClose: close, labelledBy: titleId, size: "compact", children: showStepUp ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("form", { onSubmit: (e) => {
2118
+ e.preventDefault();
2119
+ onStepUpResolve(password);
2120
+ }, children: [
2121
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-modal__title"), children: t.stepUp.title }) }),
2122
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
2123
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "throttle-muted", children: t.stepUp.description }),
2124
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2125
+ Field,
2126
+ {
2127
+ label: t.stepUp.password,
2128
+ type: "password",
2129
+ autoComplete: "current-password",
2130
+ value: password,
2131
+ onChange: setPassword,
2132
+ required: true,
2133
+ elementKey: "stepUp.passwordField"
2134
+ }
2135
+ ),
2136
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "throttle-actions", children: [
2137
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
2138
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
2139
+ Button,
2140
+ {
2141
+ variant: "secondary",
2142
+ elementKey: "stepUp.cancelButton",
2143
+ onClick: () => onStepUpResolve(null),
2144
+ children: t.stepUp.cancelButton
2145
+ }
2146
+ )
2147
+ ] })
2148
+ ] })
2149
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
2007
2150
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { ...a.el("confirm.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h2", { id: titleId, ...a.el("confirm.title", "throttle-modal__title"), children: request2.title }) }),
2008
2151
  /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { ...a.el("confirm.body", "throttle-modal__body"), children: [
2009
2152
  request2.body ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "throttle-muted", children: request2.body }) : null,
@@ -2020,7 +2163,7 @@ function ConfirmProvider({ children }) {
2020
2163
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { elementKey: "confirm.cancelButton", variant: "secondary", onClick: () => answer(false), children: request2.cancelLabel ?? t.common.keepIt })
2021
2164
  ] })
2022
2165
  ] })
2023
- ] }) : null
2166
+ ] }) }) : null
2024
2167
  ] });
2025
2168
  }
2026
2169
  function useConfirm() {
@@ -2228,69 +2371,24 @@ function Badge(props) {
2228
2371
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { ...a.el(props.elementKey ?? "badge", base), children: props.children });
2229
2372
  }
2230
2373
 
2231
- // src/react/components/auth/StepUpDialog.tsx
2232
- var import_react11 = require("react");
2233
- var import_jsx_runtime21 = require("react/jsx-runtime");
2234
- function StepUpDialog(props) {
2235
- const a = useAppearance();
2236
- const cardClass = useCardClass();
2237
- const { t } = useCopy();
2238
- const [password, setPassword] = (0, import_react11.useState)("");
2239
- const titleId = (0, import_react11.useId)();
2240
- (0, import_react11.useEffect)(() => {
2241
- if (!props.open) setPassword("");
2242
- }, [props.open]);
2243
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Modal, { open: props.open, onClose: () => props.onResolve(null), labelledBy: titleId, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ...a.el("stepUp.root", cardClass), children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2244
- "form",
2245
- {
2246
- onSubmit: (e) => {
2247
- e.preventDefault();
2248
- props.onResolve(password);
2249
- },
2250
- children: [
2251
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "throttle-card__header", children: [
2252
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h2", { id: titleId, ...a.el("stepUp.title", "throttle-card__title"), children: t.stepUp.title }),
2253
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "throttle-card__description", children: t.stepUp.description })
2254
- ] }),
2255
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardBody, { children: [
2256
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2257
- Field,
2258
- {
2259
- label: t.stepUp.password,
2260
- type: "password",
2261
- autoComplete: "current-password",
2262
- value: password,
2263
- onChange: setPassword,
2264
- required: true,
2265
- elementKey: "stepUp.passwordField"
2266
- }
2267
- ),
2268
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", elementKey: "stepUp.submitButton", children: t.stepUp.submitButton }),
2269
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", elementKey: "stepUp.cancelButton", onClick: () => props.onResolve(null), children: t.stepUp.cancelButton })
2270
- ] })
2271
- ]
2272
- }
2273
- ) }) });
2274
- }
2275
-
2276
2374
  // src/react/components/auth/AuthModal.tsx
2277
- var import_react19 = require("react");
2375
+ var import_react18 = require("react");
2278
2376
 
2279
2377
  // src/react/components/auth/AuthFlow.tsx
2280
- var import_react18 = require("react");
2378
+ var import_react17 = require("react");
2281
2379
 
2282
2380
  // src/react/components/auth/SignIn.tsx
2283
- var import_react13 = require("react");
2381
+ var import_react12 = require("react");
2284
2382
 
2285
2383
  // src/react/components/useAction.ts
2286
- var import_react12 = require("react");
2384
+ var import_react11 = require("react");
2287
2385
  function useAction() {
2288
2386
  const { errorMessage } = useCopy();
2289
- const [submitting, setSubmitting] = (0, import_react12.useState)(false);
2290
- const [error, setError] = (0, import_react12.useState)(null);
2291
- const [notice, setNotice] = (0, import_react12.useState)(null);
2292
- const inFlight = (0, import_react12.useRef)(false);
2293
- const run = (0, import_react12.useCallback)(
2387
+ const [submitting, setSubmitting] = (0, import_react11.useState)(false);
2388
+ const [error, setError] = (0, import_react11.useState)(null);
2389
+ const [notice, setNotice] = (0, import_react11.useState)(null);
2390
+ const inFlight = (0, import_react11.useRef)(false);
2391
+ const run = (0, import_react11.useCallback)(
2294
2392
  async (fn) => {
2295
2393
  if (inFlight.current) return;
2296
2394
  inFlight.current = true;
@@ -2313,7 +2411,7 @@ function useAction() {
2313
2411
  }
2314
2412
 
2315
2413
  // src/react/components/auth/SignIn.tsx
2316
- var import_jsx_runtime22 = require("react/jsx-runtime");
2414
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2317
2415
  function SignIn(props) {
2318
2416
  const a = useAppearance(props.appearance);
2319
2417
  const cardClass = useCardClass();
@@ -2321,14 +2419,14 @@ function SignIn(props) {
2321
2419
  const { t } = useCopy(props.localization);
2322
2420
  const { auth } = useAuth();
2323
2421
  const { submitting, error, run } = useAction();
2324
- const [email, setEmail] = (0, import_react13.useState)("");
2325
- const [password, setPassword] = (0, import_react13.useState)("");
2422
+ const [email, setEmail] = (0, import_react12.useState)("");
2423
+ const [password, setPassword] = (0, import_react12.useState)("");
2326
2424
  const variant = props.variant ?? "quiet";
2327
2425
  const branded = variant === "branded";
2328
2426
  const grouped = variant === "grouped";
2329
2427
  const logo = useBrandLogo(props.logo);
2330
- const forgotLink = props.onForgotPassword ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { variant: "link", size: "xs", elementKey: "signIn.forgotLink", onClick: props.onForgotPassword, children: t.signIn.forgotLink }) : null;
2331
- const emailField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2428
+ const forgotLink = props.onForgotPassword ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", size: "xs", elementKey: "signIn.forgotLink", onClick: props.onForgotPassword, children: t.signIn.forgotLink }) : null;
2429
+ const emailField = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2332
2430
  Field,
2333
2431
  {
2334
2432
  label: t.signIn.email,
@@ -2341,7 +2439,7 @@ function SignIn(props) {
2341
2439
  grouped
2342
2440
  }
2343
2441
  );
2344
- const passwordField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2442
+ const passwordField = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2345
2443
  Field,
2346
2444
  {
2347
2445
  label: t.signIn.password,
@@ -2355,7 +2453,7 @@ function SignIn(props) {
2355
2453
  labelExtra: grouped ? void 0 : forgotLink
2356
2454
  }
2357
2455
  );
2358
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2456
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2359
2457
  "form",
2360
2458
  {
2361
2459
  ...a.el("signIn.root", cardClass),
@@ -2367,7 +2465,7 @@ function SignIn(props) {
2367
2465
  });
2368
2466
  },
2369
2467
  children: [
2370
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2468
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2371
2469
  CardHeader,
2372
2470
  {
2373
2471
  title: t.signIn.title,
@@ -2378,24 +2476,24 @@ function SignIn(props) {
2378
2476
  branded
2379
2477
  }
2380
2478
  ),
2381
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardBody, { children: [
2382
- grouped ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(FieldGroup, { children: [
2479
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardBody, { children: [
2480
+ grouped ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(FieldGroup, { children: [
2383
2481
  emailField,
2384
2482
  passwordField
2385
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
2483
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
2386
2484
  emailField,
2387
2485
  passwordField
2388
2486
  ] }),
2389
- grouped && forgotLink ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "throttle-field-group__forgot", children: forgotLink }) : null,
2390
- error ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "error", children: error }) : null,
2391
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signIn.submitButton", children: t.signIn.submitButton })
2487
+ grouped && forgotLink ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "throttle-field-group__forgot", children: forgotLink }) : null,
2488
+ error ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Alert, { tone: "error", children: error }) : null,
2489
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signIn.submitButton", children: t.signIn.submitButton })
2392
2490
  ] }),
2393
- props.onSignUp ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardFooter, { ruled: !branded, children: [
2394
- /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "throttle-muted", children: [
2491
+ props.onSignUp ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(CardFooter, { ruled: !branded, children: [
2492
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "throttle-muted", children: [
2395
2493
  t.signIn.switchPrompt,
2396
2494
  " "
2397
2495
  ] }),
2398
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { variant: "link", elementKey: "signIn.switchLink", onClick: props.onSignUp, children: t.signIn.switchLink })
2496
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Button, { variant: "link", elementKey: "signIn.switchLink", onClick: props.onSignUp, children: t.signIn.switchLink })
2399
2497
  ] }) : null
2400
2498
  ]
2401
2499
  }
@@ -2403,8 +2501,8 @@ function SignIn(props) {
2403
2501
  }
2404
2502
 
2405
2503
  // src/react/components/auth/SignUp.tsx
2406
- var import_react14 = require("react");
2407
- var import_jsx_runtime23 = require("react/jsx-runtime");
2504
+ var import_react13 = require("react");
2505
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2408
2506
  function SignUp(props) {
2409
2507
  const a = useAppearance(props.appearance);
2410
2508
  const cardClass = useCardClass();
@@ -2412,13 +2510,13 @@ function SignUp(props) {
2412
2510
  const { t } = useCopy(props.localization);
2413
2511
  const { auth } = useAuth();
2414
2512
  const { submitting, error, notice, run } = useAction();
2415
- const [email, setEmail] = (0, import_react14.useState)("");
2416
- const [password, setPassword] = (0, import_react14.useState)("");
2513
+ const [email, setEmail] = (0, import_react13.useState)("");
2514
+ const [password, setPassword] = (0, import_react13.useState)("");
2417
2515
  const variant = props.variant ?? "quiet";
2418
2516
  const branded = variant === "branded";
2419
2517
  const grouped = variant === "grouped";
2420
2518
  const logo = useBrandLogo(props.logo);
2421
- const emailField = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2519
+ const emailField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2422
2520
  Field,
2423
2521
  {
2424
2522
  label: t.signUp.email,
@@ -2431,7 +2529,7 @@ function SignUp(props) {
2431
2529
  grouped
2432
2530
  }
2433
2531
  );
2434
- const passwordField = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2532
+ const passwordField = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2435
2533
  Field,
2436
2534
  {
2437
2535
  label: t.signUp.password,
@@ -2444,7 +2542,7 @@ function SignUp(props) {
2444
2542
  grouped
2445
2543
  }
2446
2544
  );
2447
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2545
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
2448
2546
  "form",
2449
2547
  {
2450
2548
  ...a.el("signUp.root", cardClass),
@@ -2460,7 +2558,7 @@ function SignUp(props) {
2460
2558
  });
2461
2559
  },
2462
2560
  children: [
2463
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2561
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2464
2562
  CardHeader,
2465
2563
  {
2466
2564
  title: t.signUp.title,
@@ -2471,24 +2569,24 @@ function SignUp(props) {
2471
2569
  branded
2472
2570
  }
2473
2571
  ),
2474
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CardBody, { children: [
2475
- grouped ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(FieldGroup, { children: [
2572
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardBody, { children: [
2573
+ grouped ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(FieldGroup, { children: [
2476
2574
  emailField,
2477
2575
  passwordField
2478
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
2576
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
2479
2577
  emailField,
2480
2578
  passwordField
2481
2579
  ] }),
2482
- error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "error", children: error }) : null,
2483
- notice ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "info", children: notice }) : null,
2484
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signUp.submitButton", children: t.signUp.submitButton })
2580
+ error ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "error", children: error }) : null,
2581
+ notice ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Alert, { tone: "info", children: notice }) : null,
2582
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { type: "submit", loading: submitting, elementKey: "signUp.submitButton", children: t.signUp.submitButton })
2485
2583
  ] }),
2486
- props.onSignIn ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CardFooter, { ruled: !branded, children: [
2487
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "throttle-muted", children: [
2584
+ props.onSignIn ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(CardFooter, { ruled: !branded, children: [
2585
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { className: "throttle-muted", children: [
2488
2586
  t.signUp.switchPrompt,
2489
2587
  " "
2490
2588
  ] }),
2491
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "link", elementKey: "signUp.switchLink", onClick: props.onSignIn, children: t.signUp.switchLink })
2589
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Button, { variant: "link", elementKey: "signUp.switchLink", onClick: props.onSignIn, children: t.signUp.switchLink })
2492
2590
  ] }) : null
2493
2591
  ]
2494
2592
  }
@@ -2496,8 +2594,8 @@ function SignUp(props) {
2496
2594
  }
2497
2595
 
2498
2596
  // src/react/components/auth/ForgotPassword.tsx
2499
- var import_react15 = require("react");
2500
- var import_jsx_runtime24 = require("react/jsx-runtime");
2597
+ var import_react14 = require("react");
2598
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2501
2599
  function ForgotPassword(props) {
2502
2600
  const a = useAppearance(props.appearance);
2503
2601
  const cardClass = useCardClass();
@@ -2505,10 +2603,10 @@ function ForgotPassword(props) {
2505
2603
  const { t } = useCopy(props.localization);
2506
2604
  const { auth } = useAuth();
2507
2605
  const { submitting, error, notice, run } = useAction();
2508
- const [email, setEmail] = (0, import_react15.useState)("");
2606
+ const [email, setEmail] = (0, import_react14.useState)("");
2509
2607
  const branded = (props.variant ?? "quiet") === "branded";
2510
2608
  const logo = useBrandLogo(props.logo);
2511
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
2609
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
2512
2610
  "form",
2513
2611
  {
2514
2612
  ...a.el("forgotPassword.root", cardClass),
@@ -2520,7 +2618,7 @@ function ForgotPassword(props) {
2520
2618
  });
2521
2619
  },
2522
2620
  children: [
2523
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2621
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2524
2622
  CardHeader,
2525
2623
  {
2526
2624
  title: t.forgotPassword.title,
@@ -2531,8 +2629,8 @@ function ForgotPassword(props) {
2531
2629
  branded
2532
2630
  }
2533
2631
  ),
2534
- /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(CardBody, { children: [
2535
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2632
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(CardBody, { children: [
2633
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2536
2634
  Field,
2537
2635
  {
2538
2636
  label: t.forgotPassword.email,
@@ -2544,19 +2642,19 @@ function ForgotPassword(props) {
2544
2642
  elementKey: "forgotPassword.emailField"
2545
2643
  }
2546
2644
  ),
2547
- error ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: error }) : null,
2548
- notice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "success", children: notice }) : null,
2549
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { type: "submit", loading: submitting, elementKey: "forgotPassword.submitButton", children: t.forgotPassword.submitButton })
2645
+ error ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "error", children: error }) : null,
2646
+ notice ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Alert, { tone: "success", children: notice }) : null,
2647
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { type: "submit", loading: submitting, elementKey: "forgotPassword.submitButton", children: t.forgotPassword.submitButton })
2550
2648
  ] }),
2551
- props.onBack ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardFooter, { ruled: !branded, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { variant: "link", elementKey: "forgotPassword.backLink", onClick: props.onBack, children: t.forgotPassword.backLink }) }) : null
2649
+ props.onBack ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CardFooter, { ruled: !branded, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button, { variant: "link", elementKey: "forgotPassword.backLink", onClick: props.onBack, children: t.forgotPassword.backLink }) }) : null
2552
2650
  ]
2553
2651
  }
2554
2652
  ) }) });
2555
2653
  }
2556
2654
 
2557
2655
  // src/react/components/auth/ResetPassword.tsx
2558
- var import_react16 = require("react");
2559
- var import_jsx_runtime25 = require("react/jsx-runtime");
2656
+ var import_react15 = require("react");
2657
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2560
2658
  function ResetPassword(props) {
2561
2659
  const a = useAppearance(props.appearance);
2562
2660
  const cardClass = useCardClass();
@@ -2564,11 +2662,11 @@ function ResetPassword(props) {
2564
2662
  const { t } = useCopy(props.localization);
2565
2663
  const { auth } = useAuth();
2566
2664
  const { submitting, error, notice, run } = useAction();
2567
- const [password, setPassword] = (0, import_react16.useState)("");
2665
+ const [password, setPassword] = (0, import_react15.useState)("");
2568
2666
  const branded = (props.variant ?? "quiet") === "branded";
2569
2667
  const logo = useBrandLogo(props.logo);
2570
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { ...a.el("resetPassword.root", cardClass), children: [
2571
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2668
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { ...a.el("resetPassword.root", cardClass), children: [
2669
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2572
2670
  CardHeader,
2573
2671
  {
2574
2672
  title: t.resetPassword.title,
@@ -2578,11 +2676,11 @@ function ResetPassword(props) {
2578
2676
  branded
2579
2677
  }
2580
2678
  ),
2581
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CardBody, { children: !props.token ? (
2679
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(CardBody, { children: !props.token ? (
2582
2680
  // No form at all without a token. A submit button that can only
2583
2681
  // fail is worse than an explanation.
2584
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "error", children: t.resetPassword.missingToken })
2585
- ) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2682
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: t.resetPassword.missingToken })
2683
+ ) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2586
2684
  "form",
2587
2685
  {
2588
2686
  onSubmit: (e) => {
@@ -2593,8 +2691,8 @@ function ResetPassword(props) {
2593
2691
  return t.resetPassword.doneNotice;
2594
2692
  });
2595
2693
  },
2596
- children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "throttle-stack", children: [
2597
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2694
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "throttle-stack", children: [
2695
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2598
2696
  Field,
2599
2697
  {
2600
2698
  label: t.resetPassword.password,
@@ -2606,9 +2704,9 @@ function ResetPassword(props) {
2606
2704
  elementKey: "resetPassword.passwordField"
2607
2705
  }
2608
2706
  ),
2609
- error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "error", children: error }) : null,
2610
- notice ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: notice }) : null,
2611
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button, { type: "submit", loading: submitting, elementKey: "resetPassword.submitButton", children: t.resetPassword.submitButton })
2707
+ error ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "error", children: error }) : null,
2708
+ notice ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Alert, { tone: "success", children: notice }) : null,
2709
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button, { type: "submit", loading: submitting, elementKey: "resetPassword.submitButton", children: t.resetPassword.submitButton })
2612
2710
  ] })
2613
2711
  }
2614
2712
  ) })
@@ -2616,8 +2714,8 @@ function ResetPassword(props) {
2616
2714
  }
2617
2715
 
2618
2716
  // src/react/components/auth/VerifyEmail.tsx
2619
- var import_react17 = require("react");
2620
- var import_jsx_runtime26 = require("react/jsx-runtime");
2717
+ var import_react16 = require("react");
2718
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2621
2719
  function VerifyEmail(props) {
2622
2720
  const a = useAppearance(props.appearance);
2623
2721
  const cardClass = useCardClass();
@@ -2625,12 +2723,12 @@ function VerifyEmail(props) {
2625
2723
  const { t, errorMessage } = useCopy(props.localization);
2626
2724
  const { auth } = useAuth();
2627
2725
  const { submitting, notice, run } = useAction();
2628
- const [state, setState] = (0, import_react17.useState)(props.token ? "verifying" : "idle");
2629
- const [error, setError] = (0, import_react17.useState)(null);
2726
+ const [state, setState] = (0, import_react16.useState)(props.token ? "verifying" : "idle");
2727
+ const [error, setError] = (0, import_react16.useState)(null);
2630
2728
  const branded = (props.variant ?? "quiet") === "branded";
2631
2729
  const logo = useBrandLogo(props.logo);
2632
- const attempted = (0, import_react17.useRef)(null);
2633
- (0, import_react17.useEffect)(() => {
2730
+ const attempted = (0, import_react16.useRef)(null);
2731
+ (0, import_react16.useEffect)(() => {
2634
2732
  const token = props.token;
2635
2733
  if (!token || attempted.current === token) return;
2636
2734
  attempted.current = token;
@@ -2643,8 +2741,8 @@ function VerifyEmail(props) {
2643
2741
  setState("failed");
2644
2742
  });
2645
2743
  }, [props.token, auth]);
2646
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ...a.el("verifyEmail.root", cardClass), children: [
2647
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2744
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { ...a.el("verifyEmail.root", cardClass), children: [
2745
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2648
2746
  CardHeader,
2649
2747
  {
2650
2748
  title: t.verifyEmail.title,
@@ -2654,17 +2752,17 @@ function VerifyEmail(props) {
2654
2752
  branded
2655
2753
  }
2656
2754
  ),
2657
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(CardBody, { children: [
2658
- state === "verifying" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("p", { children: [
2659
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Spinner, {}),
2755
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(CardBody, { children: [
2756
+ state === "verifying" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { children: [
2757
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Spinner, {}),
2660
2758
  " ",
2661
2759
  t.verifyEmail.verifying
2662
2760
  ] }) : null,
2663
- state === "done" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Alert, { tone: "success", children: t.verifyEmail.success }) : null,
2664
- state === "failed" && error ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Alert, { tone: "error", children: error }) : null,
2665
- state === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "throttle-muted", children: t.verifyEmail.instructions }) : null,
2666
- notice ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Alert, { tone: "success", children: notice }) : null,
2667
- state !== "done" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2761
+ state === "done" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: t.verifyEmail.success }) : null,
2762
+ state === "failed" && error ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "error", children: error }) : null,
2763
+ state === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "throttle-muted", children: t.verifyEmail.instructions }) : null,
2764
+ notice ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Alert, { tone: "success", children: notice }) : null,
2765
+ state !== "done" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2668
2766
  Button,
2669
2767
  {
2670
2768
  variant: "secondary",
@@ -2682,7 +2780,7 @@ function VerifyEmail(props) {
2682
2780
  }
2683
2781
 
2684
2782
  // src/react/components/auth/AuthFlow.tsx
2685
- var import_jsx_runtime27 = require("react/jsx-runtime");
2783
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2686
2784
  var HASH_FOR = {
2687
2785
  signIn: "#/sign-in",
2688
2786
  signUp: "#/sign-up",
@@ -2708,9 +2806,9 @@ function readLocation() {
2708
2806
  function AuthFlow(props) {
2709
2807
  const a = useAppearance(props.appearance);
2710
2808
  const controlled = props.view !== void 0;
2711
- const [internal, setInternal] = (0, import_react18.useState)(props.initialView ?? "signIn");
2712
- const [urlToken, setUrlToken] = (0, import_react18.useState)(void 0);
2713
- (0, import_react18.useEffect)(() => {
2809
+ const [internal, setInternal] = (0, import_react17.useState)(props.initialView ?? "signIn");
2810
+ const [urlToken, setUrlToken] = (0, import_react17.useState)(void 0);
2811
+ (0, import_react17.useEffect)(() => {
2714
2812
  const found = readLocation();
2715
2813
  if (found.token) setUrlToken(found.token);
2716
2814
  if (found.view && !controlled && props.initialView === void 0) setInternal(found.view);
@@ -2724,7 +2822,7 @@ function AuthFlow(props) {
2724
2822
  window.location.hash = HASH_FOR[next];
2725
2823
  }
2726
2824
  };
2727
- (0, import_react18.useEffect)(() => {
2825
+ (0, import_react17.useEffect)(() => {
2728
2826
  if (props.routing !== "hash" || typeof window === "undefined") return;
2729
2827
  const onHashChange = () => {
2730
2828
  if (controlled) return;
@@ -2740,8 +2838,8 @@ function AuthFlow(props) {
2740
2838
  return () => window.removeEventListener("hashchange", onHashChange);
2741
2839
  }, [props.routing, controlled]);
2742
2840
  const shared = { appearance: props.appearance, localization: props.localization };
2743
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { ...a.el("authFlow.root"), children: [
2744
- view === "signIn" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2841
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { ...a.el("authFlow.root"), children: [
2842
+ view === "signIn" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2745
2843
  SignIn,
2746
2844
  {
2747
2845
  ...shared,
@@ -2750,19 +2848,19 @@ function AuthFlow(props) {
2750
2848
  onSignUp: () => go("signUp")
2751
2849
  }
2752
2850
  ) : null,
2753
- view === "signUp" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SignUp, { ...shared, onSuccess: props.afterSignUp, onSignIn: () => go("signIn") }) : null,
2754
- view === "forgotPassword" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ForgotPassword, { ...shared, onBack: () => go("signIn") }) : null,
2755
- view === "resetPassword" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ResetPassword, { ...shared, token, onSuccess: () => go("signIn") }) : null,
2756
- view === "verifyEmail" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(VerifyEmail, { ...shared, token }) : null
2851
+ view === "signUp" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(SignUp, { ...shared, onSuccess: props.afterSignUp, onSignIn: () => go("signIn") }) : null,
2852
+ view === "forgotPassword" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ForgotPassword, { ...shared, onBack: () => go("signIn") }) : null,
2853
+ view === "resetPassword" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ResetPassword, { ...shared, token, onSuccess: () => go("signIn") }) : null,
2854
+ view === "verifyEmail" ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(VerifyEmail, { ...shared, token }) : null
2757
2855
  ] }) });
2758
2856
  }
2759
2857
 
2760
2858
  // src/react/components/auth/AuthModal.tsx
2761
- var import_jsx_runtime28 = require("react/jsx-runtime");
2859
+ var import_jsx_runtime27 = require("react/jsx-runtime");
2762
2860
  function AuthModal(props) {
2763
2861
  const scoped = useAppearanceProviderValue(props.appearance);
2764
- const titleId = (0, import_react19.useId)();
2765
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
2862
+ const titleId = (0, import_react18.useId)();
2863
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2766
2864
  Modal,
2767
2865
  {
2768
2866
  open: props.open,
@@ -2772,8 +2870,8 @@ function AuthModal(props) {
2772
2870
  overlayKey: "authModal.overlay",
2773
2871
  containerKey: "authModal.container",
2774
2872
  children: [
2775
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("h2", { id: titleId, style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: "Account" }),
2776
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2873
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h2", { id: titleId, style: { position: "absolute", width: 1, height: 1, overflow: "hidden", clip: "rect(0 0 0 0)" }, children: "Account" }),
2874
+ /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2777
2875
  AuthFlow,
2778
2876
  {
2779
2877
  initialView: props.initialView,
@@ -2789,14 +2887,14 @@ function AuthModal(props) {
2789
2887
  }
2790
2888
 
2791
2889
  // src/react/components/account/AccountModal.tsx
2792
- var import_react31 = require("react");
2890
+ var import_react30 = require("react");
2793
2891
 
2794
2892
  // src/react/components/account/AccountDashboard.tsx
2795
- var import_react30 = require("react");
2893
+ var import_react29 = require("react");
2796
2894
 
2797
2895
  // src/react/components/account/VerifyEmailBanner.tsx
2798
- var import_react20 = require("react");
2799
- var import_jsx_runtime29 = require("react/jsx-runtime");
2896
+ var import_react19 = require("react");
2897
+ var import_jsx_runtime28 = require("react/jsx-runtime");
2800
2898
  var DISMISS_KEY = "throttle-auth:verify-banner-dismissed";
2801
2899
  function readDismissed() {
2802
2900
  try {
@@ -2817,14 +2915,14 @@ function VerifyEmailBanner(props) {
2817
2915
  const { t } = useCopy(props.localization);
2818
2916
  const { auth, status, emailVerified } = useAuth();
2819
2917
  const { submitting, notice, error, run } = useAction();
2820
- const [dismissed, setDismissed] = (0, import_react20.useState)(readDismissed);
2918
+ const [dismissed, setDismissed] = (0, import_react19.useState)(readDismissed);
2821
2919
  if (status !== "authenticated" || emailVerified || dismissed) return null;
2822
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { ...a.el("verifyBanner.root", "throttle-banner"), children: [
2823
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { ...a.el("verifyBanner.message"), children: t.verifyBanner.message }),
2824
- notice ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Alert, { tone: "success", children: notice }) : null,
2825
- error ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Alert, { tone: "error", children: error }) : null,
2826
- /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "throttle-actions", children: [
2827
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2920
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { ...a.el("verifyBanner.root", "throttle-banner"), children: [
2921
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { ...a.el("verifyBanner.message"), children: t.verifyBanner.message }),
2922
+ notice ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Alert, { tone: "success", children: notice }) : null,
2923
+ error ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Alert, { tone: "error", children: error }) : null,
2924
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "throttle-actions", children: [
2925
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2828
2926
  Button,
2829
2927
  {
2830
2928
  variant: "secondary",
@@ -2837,7 +2935,7 @@ function VerifyEmailBanner(props) {
2837
2935
  children: t.verifyBanner.resendButton
2838
2936
  }
2839
2937
  ),
2840
- /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2938
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
2841
2939
  Button,
2842
2940
  {
2843
2941
  variant: "link",
@@ -2854,9 +2952,9 @@ function VerifyEmailBanner(props) {
2854
2952
  }
2855
2953
 
2856
2954
  // src/react/components/account/icons.tsx
2857
- var import_jsx_runtime30 = require("react/jsx-runtime");
2955
+ var import_jsx_runtime29 = require("react/jsx-runtime");
2858
2956
  function Glyph(props) {
2859
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
2957
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2860
2958
  "svg",
2861
2959
  {
2862
2960
  className: "throttle-tabs__railicon",
@@ -2875,43 +2973,43 @@ function Glyph(props) {
2875
2973
  );
2876
2974
  }
2877
2975
  var ACCOUNT_ICONS = {
2878
- profile: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2879
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "12", cy: "8", r: "4" }),
2880
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M4 21c0-4 3.6-6 8-6s8 2 8 6" })
2976
+ profile: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
2977
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("circle", { cx: "12", cy: "8", r: "4" }),
2978
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M4 21c0-4 3.6-6 8-6s8 2 8 6" })
2881
2979
  ] }),
2882
- addresses: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2883
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M12 21s7-5.3 7-11a7 7 0 1 0-14 0c0 5.7 7 11 7 11Z" }),
2884
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "12", cy: "10", r: "2.5" })
2980
+ addresses: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
2981
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M12 21s7-5.3 7-11a7 7 0 1 0-14 0c0 5.7 7 11 7 11Z" }),
2982
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("circle", { cx: "12", cy: "10", r: "2.5" })
2885
2983
  ] }),
2886
- paymentMethods: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2887
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("rect", { x: "2.5", y: "5.5", width: "19", height: "13", rx: "2.5" }),
2888
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M2.5 10h19" })
2984
+ paymentMethods: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
2985
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("rect", { x: "2.5", y: "5.5", width: "19", height: "13", rx: "2.5" }),
2986
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M2.5 10h19" })
2889
2987
  ] }),
2890
- orders: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2891
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M4 7h16v13H4z" }),
2892
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M8 7V4h8v3" }),
2893
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M8 12h8" })
2988
+ orders: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
2989
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M4 7h16v13H4z" }),
2990
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M8 7V4h8v3" }),
2991
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M8 12h8" })
2894
2992
  ] }),
2895
- invoices: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2896
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M6 3h12v18l-3-2-3 2-3-2-3 2Z" }),
2897
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M9 8h6M9 12h6" })
2993
+ invoices: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
2994
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M6 3h12v18l-3-2-3 2-3-2-3 2Z" }),
2995
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M9 8h6M9 12h6" })
2898
2996
  ] }),
2899
- subscriptions: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2900
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M3 12a9 9 0 0 1 15.5-6.2" }),
2901
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M21 12a9 9 0 0 1-15.5 6.2" }),
2902
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M18 3v4h-4M6 21v-4h4" })
2997
+ subscriptions: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
2998
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M3 12a9 9 0 0 1 15.5-6.2" }),
2999
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M21 12a9 9 0 0 1-15.5 6.2" }),
3000
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M18 3v4h-4M6 21v-4h4" })
2903
3001
  ] }),
2904
- security: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Glyph, { children: [
2905
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M12 3 4 6.5V12c0 5 3.4 8.3 8 9 4.6-.7 8-4 8-9V6.5Z" }),
2906
- /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "m9 12 2 2 4-4" })
3002
+ security: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Glyph, { children: [
3003
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "M12 3 4 6.5V12c0 5 3.4 8.3 8 9 4.6-.7 8-4 8-9V6.5Z" }),
3004
+ /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("path", { d: "m9 12 2 2 4-4" })
2907
3005
  ] })
2908
3006
  };
2909
3007
 
2910
3008
  // src/react/components/account/ProfilePanel.tsx
2911
- var import_react22 = require("react");
3009
+ var import_react21 = require("react");
2912
3010
 
2913
3011
  // src/react/hooks.ts
2914
- var import_react21 = require("react");
3012
+ var import_react20 = require("react");
2915
3013
  function asError(err) {
2916
3014
  if (err instanceof ThrottleAuthError) return err;
2917
3015
  const anyErr = err;
@@ -2923,19 +3021,19 @@ function asError(err) {
2923
3021
  }
2924
3022
  function useResource(empty, load, deps) {
2925
3023
  const { status, emailVerified } = useAuth();
2926
- const [data, setData] = (0, import_react21.useState)(empty);
2927
- const [isLoading, setIsLoading] = (0, import_react21.useState)(status === "loading");
2928
- const [error, setError] = (0, import_react21.useState)(null);
2929
- const gen = (0, import_react21.useRef)(0);
2930
- const alive = (0, import_react21.useRef)(true);
2931
- (0, import_react21.useEffect)(() => {
3024
+ const [data, setData] = (0, import_react20.useState)(empty);
3025
+ const [isLoading, setIsLoading] = (0, import_react20.useState)(status === "loading");
3026
+ const [error, setError] = (0, import_react20.useState)(null);
3027
+ const gen = (0, import_react20.useRef)(0);
3028
+ const alive = (0, import_react20.useRef)(true);
3029
+ (0, import_react20.useEffect)(() => {
2932
3030
  alive.current = true;
2933
3031
  return () => {
2934
3032
  alive.current = false;
2935
3033
  gen.current++;
2936
3034
  };
2937
3035
  }, []);
2938
- const refetch = (0, import_react21.useCallback)(async () => {
3036
+ const refetch = (0, import_react20.useCallback)(async () => {
2939
3037
  const mine = ++gen.current;
2940
3038
  setIsLoading(true);
2941
3039
  try {
@@ -2950,7 +3048,7 @@ function useResource(empty, load, deps) {
2950
3048
  if (alive.current && gen.current === mine) setIsLoading(false);
2951
3049
  }
2952
3050
  }, deps);
2953
- (0, import_react21.useEffect)(() => {
3051
+ (0, import_react20.useEffect)(() => {
2954
3052
  if (status !== "authenticated") {
2955
3053
  gen.current++;
2956
3054
  setData(empty);
@@ -2965,7 +3063,7 @@ function useResource(empty, load, deps) {
2965
3063
  function useCustomer() {
2966
3064
  const { account } = useAuth();
2967
3065
  const res = useResource(null, () => account.getProfile(), [account]);
2968
- const update = (0, import_react21.useCallback)(async (patch) => {
3066
+ const update = (0, import_react20.useCallback)(async (patch) => {
2969
3067
  await account.updateProfile(patch);
2970
3068
  await res.refetch();
2971
3069
  }, [account, res]);
@@ -3034,32 +3132,32 @@ function useInvoice(id) {
3034
3132
  }
3035
3133
 
3036
3134
  // src/react/components/account/PanelState.tsx
3037
- var import_jsx_runtime31 = require("react/jsx-runtime");
3135
+ var import_jsx_runtime30 = require("react/jsx-runtime");
3038
3136
  function PanelState(props) {
3039
3137
  const { t, errorMessage } = useCopy();
3040
3138
  const { data, isLoading, error, refetch } = props.resource;
3041
3139
  const empty = props.isEmpty(data);
3042
- if (isLoading && empty) return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Skeleton, { count: props.skeletonRows ?? 3 });
3043
- const errorBanner = error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: "throttle-stack", children: [
3044
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "error", children: errorMessage(error) }),
3045
- /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Button, { variant: "secondary", onClick: () => void refetch(), children: t.common.retry })
3140
+ if (isLoading && empty) return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Skeleton, { count: props.skeletonRows ?? 3 });
3141
+ const errorBanner = error ? /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "throttle-stack", children: [
3142
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Alert, { tone: "error", children: errorMessage(error) }),
3143
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Button, { variant: "secondary", onClick: () => void refetch(), children: t.common.retry })
3046
3144
  ] }) : null;
3047
3145
  const gatedByVerification = error?.code === "verification_required";
3048
3146
  if (gatedByVerification && empty) {
3049
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription ?? props.emptyDescription });
3147
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription ?? props.emptyDescription });
3050
3148
  }
3051
3149
  if (error && empty) return errorBanner;
3052
3150
  if (empty) {
3053
- return props.gated ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(EmptyState, { title: props.emptyTitle, description: props.emptyDescription });
3151
+ return props.gated ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.gatedDescription }) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(EmptyState, { title: props.emptyTitle, description: props.emptyDescription });
3054
3152
  }
3055
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3153
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
3056
3154
  errorBanner,
3057
3155
  props.children(data)
3058
3156
  ] });
3059
3157
  }
3060
3158
 
3061
3159
  // src/react/components/account/ProfilePanel.tsx
3062
- var import_jsx_runtime32 = require("react/jsx-runtime");
3160
+ var import_jsx_runtime31 = require("react/jsx-runtime");
3063
3161
  function ProfilePanel(props) {
3064
3162
  const a = useAppearance(props.appearance);
3065
3163
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -3067,9 +3165,9 @@ function ProfilePanel(props) {
3067
3165
  const { status } = useAuth();
3068
3166
  const resource = useCustomer();
3069
3167
  const { submitting, error, notice, run } = useAction();
3070
- const [form, setForm] = (0, import_react22.useState)({ firstName: "", lastName: "", phone: "", company: "" });
3071
- const edited = (0, import_react22.useRef)(false);
3072
- (0, import_react22.useEffect)(() => {
3168
+ const [form, setForm] = (0, import_react21.useState)({ firstName: "", lastName: "", phone: "", company: "" });
3169
+ const edited = (0, import_react21.useRef)(false);
3170
+ (0, import_react21.useEffect)(() => {
3073
3171
  const c = resource.data;
3074
3172
  if (!c || edited.current) return;
3075
3173
  setForm({
@@ -3080,14 +3178,14 @@ function ProfilePanel(props) {
3080
3178
  });
3081
3179
  }, [resource.data]);
3082
3180
  if (status === "unauthenticated") return null;
3083
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ...a.el("profilePanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3181
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { ...a.el("profilePanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3084
3182
  PanelState,
3085
3183
  {
3086
3184
  resource,
3087
3185
  isEmpty: (c) => c === null,
3088
3186
  emptyTitle: t.common.somethingWentWrong,
3089
3187
  skeletonRows: 4,
3090
- children: (customer) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
3188
+ children: (customer) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3091
3189
  "form",
3092
3190
  {
3093
3191
  ...a.el("profilePanel.form", "throttle-stack"),
@@ -3105,7 +3203,7 @@ function ProfilePanel(props) {
3105
3203
  });
3106
3204
  },
3107
3205
  children: [
3108
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3206
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3109
3207
  Field,
3110
3208
  {
3111
3209
  label: t.profile.email,
@@ -3117,8 +3215,8 @@ function ProfilePanel(props) {
3117
3215
  hint: t.profile.emailReadOnly
3118
3216
  }
3119
3217
  ),
3120
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3121
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3218
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(FieldRow, { children: [
3219
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3122
3220
  Field,
3123
3221
  {
3124
3222
  label: t.profile.firstName,
@@ -3130,7 +3228,7 @@ function ProfilePanel(props) {
3130
3228
  }
3131
3229
  }
3132
3230
  ),
3133
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3231
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3134
3232
  Field,
3135
3233
  {
3136
3234
  label: t.profile.lastName,
@@ -3143,8 +3241,8 @@ function ProfilePanel(props) {
3143
3241
  }
3144
3242
  )
3145
3243
  ] }),
3146
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3147
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3244
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(FieldRow, { children: [
3245
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3148
3246
  Field,
3149
3247
  {
3150
3248
  label: t.profile.phone,
@@ -3157,7 +3255,7 @@ function ProfilePanel(props) {
3157
3255
  }
3158
3256
  }
3159
3257
  ),
3160
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3258
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3161
3259
  Field,
3162
3260
  {
3163
3261
  label: t.profile.company,
@@ -3170,9 +3268,9 @@ function ProfilePanel(props) {
3170
3268
  }
3171
3269
  )
3172
3270
  ] }),
3173
- error ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { tone: "error", children: error }) : null,
3174
- notice ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { tone: "success", children: notice }) : null,
3175
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
3271
+ error ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "error", children: error }) : null,
3272
+ notice ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Alert, { tone: "success", children: notice }) : null,
3273
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Button, { type: "submit", loading: submitting, elementKey: "profilePanel.submitButton", children: t.profile.saveButton })
3176
3274
  ]
3177
3275
  }
3178
3276
  )
@@ -3181,16 +3279,16 @@ function ProfilePanel(props) {
3181
3279
  }
3182
3280
 
3183
3281
  // src/react/components/account/AddressesPanel.tsx
3184
- var import_react24 = require("react");
3282
+ var import_react23 = require("react");
3185
3283
 
3186
3284
  // src/react/components/account/AddressForm.tsx
3187
- var import_react23 = require("react");
3188
- var import_jsx_runtime33 = require("react/jsx-runtime");
3285
+ var import_react22 = require("react");
3286
+ var import_jsx_runtime32 = require("react/jsx-runtime");
3189
3287
  function AddressForm(props) {
3190
3288
  const a = useAppearance();
3191
3289
  const { t } = useCopy();
3192
3290
  const i = props.initial;
3193
- const [form, setForm] = (0, import_react23.useState)({
3291
+ const [form, setForm] = (0, import_react22.useState)({
3194
3292
  label: i?.label ?? "",
3195
3293
  firstName: i?.firstName ?? "",
3196
3294
  lastName: i?.lastName ?? "",
@@ -3204,7 +3302,7 @@ function AddressForm(props) {
3204
3302
  phone: i?.phone ?? ""
3205
3303
  });
3206
3304
  const set = (key) => (value) => setForm((f) => ({ ...f, [key]: value }));
3207
- return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
3305
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
3208
3306
  "form",
3209
3307
  {
3210
3308
  ...a.el("addressesPanel.form", "throttle-stack"),
@@ -3226,15 +3324,15 @@ function AddressForm(props) {
3226
3324
  });
3227
3325
  },
3228
3326
  children: [
3229
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(FieldRow, { children: [
3230
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
3231
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" })
3327
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3328
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.label, value: form.label, onChange: set("label") }),
3329
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.company, value: form.company, onChange: set("company"), autoComplete: "organization" })
3232
3330
  ] }),
3233
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(FieldRow, { children: [
3234
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
3235
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" })
3331
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3332
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.firstName, value: form.firstName, onChange: set("firstName"), autoComplete: "given-name" }),
3333
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.lastName, value: form.lastName, onChange: set("lastName"), autoComplete: "family-name" })
3236
3334
  ] }),
3237
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3335
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3238
3336
  Field,
3239
3337
  {
3240
3338
  label: t.addresses.addressLine1,
@@ -3244,7 +3342,7 @@ function AddressForm(props) {
3244
3342
  autoComplete: "address-line1"
3245
3343
  }
3246
3344
  ),
3247
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3345
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3248
3346
  Field,
3249
3347
  {
3250
3348
  label: t.addresses.addressLine2,
@@ -3253,9 +3351,9 @@ function AddressForm(props) {
3253
3351
  autoComplete: "address-line2"
3254
3352
  }
3255
3353
  ),
3256
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(FieldRow, { children: [
3257
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
3258
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3354
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3355
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.city, value: form.city, onChange: set("city"), required: true, autoComplete: "address-level2" }),
3356
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3259
3357
  Field,
3260
3358
  {
3261
3359
  label: t.addresses.stateProvince,
@@ -3265,8 +3363,8 @@ function AddressForm(props) {
3265
3363
  }
3266
3364
  )
3267
3365
  ] }),
3268
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(FieldRow, { children: [
3269
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3366
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(FieldRow, { children: [
3367
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3270
3368
  Field,
3271
3369
  {
3272
3370
  label: t.addresses.postalCode,
@@ -3275,7 +3373,7 @@ function AddressForm(props) {
3275
3373
  autoComplete: "postal-code"
3276
3374
  }
3277
3375
  ),
3278
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3376
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3279
3377
  Field,
3280
3378
  {
3281
3379
  label: t.addresses.countryCode,
@@ -3287,11 +3385,11 @@ function AddressForm(props) {
3287
3385
  }
3288
3386
  )
3289
3387
  ] }),
3290
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Field, { label: t.addresses.phone, type: "tel", value: form.phone, onChange: set("phone"), autoComplete: "tel" }),
3291
- props.error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Alert, { tone: "error", children: props.error }) : null,
3292
- /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
3293
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Button, { type: "submit", loading: props.submitting, children: t.common.save }),
3294
- /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Button, { variant: "link", onClick: props.onCancel, children: t.common.cancel })
3388
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Field, { label: t.addresses.phone, type: "tel", value: form.phone, onChange: set("phone"), autoComplete: "tel" }),
3389
+ props.error ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Alert, { tone: "error", children: props.error }) : null,
3390
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "throttle-actions", children: [
3391
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { type: "submit", loading: props.submitting, children: t.common.save }),
3392
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Button, { variant: "link", onClick: props.onCancel, children: t.common.cancel })
3295
3393
  ] })
3296
3394
  ]
3297
3395
  }
@@ -3299,7 +3397,7 @@ function AddressForm(props) {
3299
3397
  }
3300
3398
 
3301
3399
  // src/react/components/account/AddressesPanel.tsx
3302
- var import_jsx_runtime34 = require("react/jsx-runtime");
3400
+ var import_jsx_runtime33 = require("react/jsx-runtime");
3303
3401
  function AddressesPanel(props) {
3304
3402
  const a = useAppearance(props.appearance);
3305
3403
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -3307,7 +3405,7 @@ function AddressesPanel(props) {
3307
3405
  const resource = useAddresses();
3308
3406
  const { submitting, error, run } = useAction();
3309
3407
  const confirm = useConfirm();
3310
- const [editing, setEditing] = (0, import_react24.useState)(null);
3408
+ const [editing, setEditing] = (0, import_react23.useState)(null);
3311
3409
  const variant = props.variant ?? "rows";
3312
3410
  const rowsVariant = variant === "rows";
3313
3411
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
@@ -3315,9 +3413,9 @@ function AddressesPanel(props) {
3315
3413
  const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
3316
3414
  const close = () => setEditing(null);
3317
3415
  const formatAddress = (address) => [address.addressLine2, address.city, address.stateProvince, address.postalCode, address.countryCode].filter(Boolean).join(", ");
3318
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { ...a.el("addressesPanel.root", "throttle-panel"), children: [
3319
- !editing && error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Alert, { tone: "error", children: error }) : null,
3320
- editing ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3416
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...a.el("addressesPanel.root", "throttle-panel"), children: [
3417
+ !editing && error ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Alert, { tone: "error", children: error }) : null,
3418
+ editing ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3321
3419
  AddressForm,
3322
3420
  {
3323
3421
  initial: editing === "new" ? void 0 : editing,
@@ -3330,16 +3428,16 @@ function AddressesPanel(props) {
3330
3428
  close();
3331
3429
  })
3332
3430
  }
3333
- ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
3334
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
3335
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3431
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
3432
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Button, { elementKey: "addressesPanel.addButton", variant: "secondary", onClick: () => setEditing("new"), children: t.addresses.addButton }) }),
3433
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3336
3434
  PanelState,
3337
3435
  {
3338
3436
  resource,
3339
3437
  isEmpty: (rows) => rows.length === 0,
3340
3438
  emptyTitle: t.addresses.empty,
3341
3439
  emptyDescription: t.addresses.emptyDescription,
3342
- children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3440
+ children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3343
3441
  DataTable,
3344
3442
  {
3345
3443
  tableKey: "addressesPanel.table",
@@ -3348,13 +3446,13 @@ function AddressesPanel(props) {
3348
3446
  rows,
3349
3447
  columns: [
3350
3448
  { key: "label", label: t.addresses.label, render: (address) => address.label || address.addressLine1 },
3351
- { key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
3449
+ { key: "address", label: t.addresses.columnAddress, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
3352
3450
  address.addressLine1,
3353
3451
  formatAddress(address) ? `, ${formatAddress(address)}` : ""
3354
3452
  ] }) },
3355
- { key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null },
3356
- { key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-actions", children: [
3357
- !address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3453
+ { key: "default", label: t.addresses.defaultBadge, render: (address) => address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null },
3454
+ { key: "actions", label: t.common.actions, render: (address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
3455
+ !address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3358
3456
  Button,
3359
3457
  {
3360
3458
  variant: "secondary",
@@ -3363,7 +3461,7 @@ function AddressesPanel(props) {
3363
3461
  children: t.addresses.makeDefault
3364
3462
  }
3365
3463
  ) : null,
3366
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3464
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3367
3465
  Button,
3368
3466
  {
3369
3467
  variant: "secondary",
@@ -3372,7 +3470,7 @@ function AddressesPanel(props) {
3372
3470
  children: t.common.edit
3373
3471
  }
3374
3472
  ),
3375
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3473
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3376
3474
  Button,
3377
3475
  {
3378
3476
  variant: "danger",
@@ -3388,17 +3486,17 @@ function AddressesPanel(props) {
3388
3486
  ] }) }
3389
3487
  ]
3390
3488
  }
3391
- ) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...a.el("addressesPanel.list", listBase), children: rows.map((address) => /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { ...a.el("addressesPanel.item", itemBase), children: [
3392
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { children: [
3393
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-row", children: [
3394
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("strong", { children: address.label || address.addressLine1 }),
3395
- address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null
3489
+ ) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ...a.el("addressesPanel.list", listBase), children: rows.map((address) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...a.el("addressesPanel.item", itemBase), children: [
3490
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { children: [
3491
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-row", children: [
3492
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("strong", { children: address.label || address.addressLine1 }),
3493
+ address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Badge, { tone: "success", children: t.addresses.defaultBadge }) : null
3396
3494
  ] }),
3397
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "throttle-muted", children: address.addressLine1 }),
3398
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("p", { className: "throttle-muted", children: formatAddress(address) })
3495
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "throttle-muted", children: address.addressLine1 }),
3496
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("p", { className: "throttle-muted", children: formatAddress(address) })
3399
3497
  ] }),
3400
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-actions", children: [
3401
- !address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3498
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "throttle-actions", children: [
3499
+ !address.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3402
3500
  Button,
3403
3501
  {
3404
3502
  variant: actionVariant("secondary"),
@@ -3407,7 +3505,7 @@ function AddressesPanel(props) {
3407
3505
  children: t.addresses.makeDefault
3408
3506
  }
3409
3507
  ) : null,
3410
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3508
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3411
3509
  Button,
3412
3510
  {
3413
3511
  variant: actionVariant("secondary"),
@@ -3416,7 +3514,7 @@ function AddressesPanel(props) {
3416
3514
  children: t.common.edit
3417
3515
  }
3418
3516
  ),
3419
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3517
+ /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3420
3518
  Button,
3421
3519
  {
3422
3520
  variant: actionVariant("danger"),
@@ -3438,23 +3536,23 @@ function AddressesPanel(props) {
3438
3536
  }
3439
3537
 
3440
3538
  // src/react/components/account/PaymentMethodsPanel.tsx
3441
- var import_react26 = require("react");
3539
+ var import_react25 = require("react");
3442
3540
 
3443
3541
  // src/react/components/account/AddCardDialog.tsx
3444
- var import_react25 = require("react");
3445
- var import_jsx_runtime35 = require("react/jsx-runtime");
3542
+ var import_react24 = require("react");
3543
+ var import_jsx_runtime34 = require("react/jsx-runtime");
3446
3544
  function AddCardDialog(props) {
3447
3545
  const { account } = useAuth();
3448
- const titleId = (0, import_react25.useId)();
3546
+ const titleId = (0, import_react24.useId)();
3449
3547
  const { t } = useCopy(props.localization);
3450
- const [src, setSrc] = (0, import_react25.useState)(null);
3451
- const [error, setError] = (0, import_react25.useState)(null);
3452
- const [busy, setBusy] = (0, import_react25.useState)(false);
3453
- const onAdded = (0, import_react25.useRef)(props.onAdded);
3454
- const onClose = (0, import_react25.useRef)(props.onClose);
3548
+ const [src, setSrc] = (0, import_react24.useState)(null);
3549
+ const [error, setError] = (0, import_react24.useState)(null);
3550
+ const [busy, setBusy] = (0, import_react24.useState)(false);
3551
+ const onAdded = (0, import_react24.useRef)(props.onAdded);
3552
+ const onClose = (0, import_react24.useRef)(props.onClose);
3455
3553
  onAdded.current = props.onAdded;
3456
3554
  onClose.current = props.onClose;
3457
- (0, import_react25.useEffect)(() => {
3555
+ (0, import_react24.useEffect)(() => {
3458
3556
  if (!props.open) {
3459
3557
  setSrc(null);
3460
3558
  setError(null);
@@ -3482,7 +3580,7 @@ function AddCardDialog(props) {
3482
3580
  live = false;
3483
3581
  };
3484
3582
  }, [props.open, account]);
3485
- (0, import_react25.useEffect)(() => {
3583
+ (0, import_react24.useEffect)(() => {
3486
3584
  if (!src) return;
3487
3585
  const frameOrigin = (() => {
3488
3586
  try {
@@ -3517,11 +3615,11 @@ function AddCardDialog(props) {
3517
3615
  return () => window.removeEventListener("message", onMessage);
3518
3616
  }, [src, account, t]);
3519
3617
  if (!props.open) return null;
3520
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
3521
- /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "throttle-modal__header", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h2", { id: titleId, className: "throttle-modal__title", children: t.paymentMethods.addTitle }) }),
3522
- /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-modal__body", children: [
3523
- error ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Alert, { tone: "error", children: error }) : null,
3524
- busy ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Spinner, {}) }) : src ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3618
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Modal, { open: true, onClose: props.onClose, labelledBy: titleId, children: [
3619
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-modal__header", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("h2", { id: titleId, className: "throttle-modal__title", children: t.paymentMethods.addTitle }) }),
3620
+ /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "throttle-modal__body", children: [
3621
+ error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Alert, { tone: "error", children: error }) : null,
3622
+ busy ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spinner, {}) }) : src ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3525
3623
  "iframe",
3526
3624
  {
3527
3625
  className: "throttle-cardframe",
@@ -3529,13 +3627,13 @@ function AddCardDialog(props) {
3529
3627
  title: t.paymentMethods.addTitle,
3530
3628
  sandbox: "allow-scripts allow-forms allow-same-origin"
3531
3629
  }
3532
- ) : !error ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Spinner, {}) }) : null
3630
+ ) : !error ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "throttle-centre", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Spinner, {}) }) : null
3533
3631
  ] })
3534
3632
  ] });
3535
3633
  }
3536
3634
 
3537
3635
  // src/react/components/account/PaymentMethodsPanel.tsx
3538
- var import_jsx_runtime36 = require("react/jsx-runtime");
3636
+ var import_jsx_runtime35 = require("react/jsx-runtime");
3539
3637
  function PaymentMethodsPanel(props) {
3540
3638
  const a = useAppearance(props.appearance);
3541
3639
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -3544,7 +3642,7 @@ function PaymentMethodsPanel(props) {
3544
3642
  const resource = useSavedCards();
3545
3643
  const { submitting, error, run } = useAction();
3546
3644
  const confirm = useConfirm();
3547
- const [adding, setAdding] = (0, import_react26.useState)(false);
3645
+ const [adding, setAdding] = (0, import_react25.useState)(false);
3548
3646
  const variant = props.variant ?? "rows";
3549
3647
  const rowsVariant = variant === "rows";
3550
3648
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
@@ -3552,10 +3650,10 @@ function PaymentMethodsPanel(props) {
3552
3650
  const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
3553
3651
  const cardLabel = (card) => `${(card.cardBrand ?? card.methodType).toUpperCase()} \u2022\u2022\u2022\u2022 ${card.cardLastFour ?? "____"}`;
3554
3652
  const expiryLabel = (card) => card.cardExpMonth && card.cardExpYear ? `${String(card.cardExpMonth).padStart(2, "0")}/${card.cardExpYear}` : "";
3555
- return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
3556
- error ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Alert, { tone: "error", children: error }) : null,
3557
- emailVerified ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
3558
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3653
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ...a.el("paymentMethodsPanel.root", "throttle-panel"), children: [
3654
+ error ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Alert, { tone: "error", children: error }) : null,
3655
+ emailVerified ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Button, { elementKey: "paymentMethodsPanel.addButton", variant: "secondary", onClick: () => setAdding(true), children: t.paymentMethods.addButton }) }) : null,
3656
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3559
3657
  AddCardDialog,
3560
3658
  {
3561
3659
  open: adding,
@@ -3566,7 +3664,7 @@ function PaymentMethodsPanel(props) {
3566
3664
  localization: props.localization
3567
3665
  }
3568
3666
  ),
3569
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3667
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3570
3668
  PanelState,
3571
3669
  {
3572
3670
  resource,
@@ -3575,7 +3673,7 @@ function PaymentMethodsPanel(props) {
3575
3673
  isEmpty: (rows) => rows.length === 0,
3576
3674
  emptyTitle: t.paymentMethods.empty,
3577
3675
  emptyDescription: t.paymentMethods.emptyDescription,
3578
- children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3676
+ children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3579
3677
  DataTable,
3580
3678
  {
3581
3679
  tableKey: "paymentMethodsPanel.table",
@@ -3585,9 +3683,9 @@ function PaymentMethodsPanel(props) {
3585
3683
  columns: [
3586
3684
  { key: "card", label: t.paymentMethods.columnCard, render: (card) => cardLabel(card) },
3587
3685
  { key: "expires", label: t.paymentMethods.expires, render: (card) => expiryLabel(card) },
3588
- { key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
3589
- { key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "throttle-actions", children: [
3590
- !card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3686
+ { key: "default", label: t.paymentMethods.defaultBadge, render: (card) => card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null },
3687
+ { key: "actions", label: t.common.actions, render: (card) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-actions", children: [
3688
+ !card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3591
3689
  Button,
3592
3690
  {
3593
3691
  variant: "secondary",
@@ -3597,7 +3695,7 @@ function PaymentMethodsPanel(props) {
3597
3695
  children: t.paymentMethods.makeDefault
3598
3696
  }
3599
3697
  ) : null,
3600
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3698
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3601
3699
  Button,
3602
3700
  {
3603
3701
  variant: "danger",
@@ -3613,13 +3711,13 @@ function PaymentMethodsPanel(props) {
3613
3711
  ] }) }
3614
3712
  ]
3615
3713
  }
3616
- ) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
3617
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { children: [
3618
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "throttle-row", children: [
3619
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("strong", { children: cardLabel(card) }),
3620
- card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
3714
+ ) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { ...a.el("paymentMethodsPanel.list", listBase), children: rows.map((card) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ...a.el("paymentMethodsPanel.item", itemBase), children: [
3715
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { children: [
3716
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-row", children: [
3717
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("strong", { children: cardLabel(card) }),
3718
+ card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Badge, { tone: "success", children: t.paymentMethods.defaultBadge }) : null
3621
3719
  ] }),
3622
- card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("p", { className: "throttle-muted", children: [
3720
+ card.cardExpMonth && card.cardExpYear ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("p", { className: "throttle-muted", children: [
3623
3721
  t.paymentMethods.expires,
3624
3722
  " ",
3625
3723
  String(card.cardExpMonth).padStart(2, "0"),
@@ -3627,8 +3725,8 @@ function PaymentMethodsPanel(props) {
3627
3725
  card.cardExpYear
3628
3726
  ] }) : null
3629
3727
  ] }),
3630
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "throttle-actions", children: [
3631
- !card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3728
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "throttle-actions", children: [
3729
+ !card.isDefault ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3632
3730
  Button,
3633
3731
  {
3634
3732
  variant: actionVariant("secondary"),
@@ -3638,7 +3736,7 @@ function PaymentMethodsPanel(props) {
3638
3736
  children: t.paymentMethods.makeDefault
3639
3737
  }
3640
3738
  ) : null,
3641
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3739
+ /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3642
3740
  Button,
3643
3741
  {
3644
3742
  variant: actionVariant("danger"),
@@ -3659,7 +3757,7 @@ function PaymentMethodsPanel(props) {
3659
3757
  }
3660
3758
 
3661
3759
  // src/react/components/account/OrdersPanel.tsx
3662
- var import_react27 = require("react");
3760
+ var import_react26 = require("react");
3663
3761
 
3664
3762
  // src/react/components/format.ts
3665
3763
  function formatMoney(minorUnits, currency, locale) {
@@ -3691,7 +3789,7 @@ function formatDate(value, locale) {
3691
3789
  }
3692
3790
 
3693
3791
  // src/react/components/account/OrderStatus.tsx
3694
- var import_jsx_runtime37 = require("react/jsx-runtime");
3792
+ var import_jsx_runtime36 = require("react/jsx-runtime");
3695
3793
  function copyKey(wire) {
3696
3794
  return wire.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
3697
3795
  }
@@ -3699,21 +3797,21 @@ var ATTENTION_PAYMENT_STATES = /* @__PURE__ */ new Set(["pending", "failed", "di
3699
3797
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["cancelled", "closed", "void", "expired", "voided"]);
3700
3798
  function StatusBadge(props) {
3701
3799
  const label = props.labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
3702
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
3800
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: label });
3703
3801
  }
3704
3802
  function OrderStatus(props) {
3705
3803
  const labels = props.t.orders.statusLabels;
3706
3804
  const payLabels = props.t.orders.paymentLabels;
3707
3805
  const lifecycle = labels[copyKey(props.status)] ?? props.status.replace(/_/g, " ");
3708
3806
  const money = props.paymentStatus ? payLabels[copyKey(props.paymentStatus)] : void 0;
3709
- return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3710
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
3711
- money ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
3807
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
3808
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: TERMINAL_STATUSES.has(props.status) ? "muted" : "neutral", children: lifecycle }),
3809
+ money ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Badge, { tone: ATTENTION_PAYMENT_STATES.has(props.paymentStatus) ? "warning" : "neutral", children: money }) : null
3712
3810
  ] });
3713
3811
  }
3714
3812
 
3715
3813
  // src/react/components/account/AddressBlock.tsx
3716
- var import_jsx_runtime38 = require("react/jsx-runtime");
3814
+ var import_jsx_runtime37 = require("react/jsx-runtime");
3717
3815
  function addressLines(address) {
3718
3816
  if (!address || typeof address !== "object") return [];
3719
3817
  const a = address;
@@ -3733,14 +3831,14 @@ function AddressBlock(props) {
3733
3831
  const a = useAppearance();
3734
3832
  const lines = addressLines(props.address);
3735
3833
  if (lines.length === 0) return null;
3736
- return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ...a.el(props.elementKey ?? "orderDetail.address", "throttle-addressblock"), children: [
3737
- /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
3738
- lines.map((l) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "throttle-addressblock__line throttle-muted", children: l }, l))
3834
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { ...a.el(props.elementKey ?? "orderDetail.address", "throttle-addressblock"), children: [
3835
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
3836
+ lines.map((l) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "throttle-addressblock__line throttle-muted", children: l }, l))
3739
3837
  ] });
3740
3838
  }
3741
3839
 
3742
3840
  // src/react/components/account/OrderTimeline.tsx
3743
- var import_jsx_runtime39 = require("react/jsx-runtime");
3841
+ var import_jsx_runtime38 = require("react/jsx-runtime");
3744
3842
  function orderTimeline(order, labels) {
3745
3843
  const entries = [{ label: labels.placed, at: order.createdAt }];
3746
3844
  if (order.completedAt) entries.push({ label: labels.completed, at: order.completedAt });
@@ -3751,32 +3849,40 @@ function orderTimeline(order, labels) {
3751
3849
  function OrderTimeline(props) {
3752
3850
  const a = useAppearance();
3753
3851
  if (props.entries.length <= 1) return null;
3754
- return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.timeline", "throttle-timeline"), children: [
3755
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
3756
- props.entries.map((e) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-timeline__row", children: [
3757
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-timeline__dot", "aria-hidden": "true" }),
3758
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-timeline__label", children: e.label }),
3759
- /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-muted", children: formatDate(e.at, props.locale) })
3852
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { ...a.el("orderDetail.timeline", "throttle-timeline"), children: [
3853
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h4", { className: "throttle-section__title", children: props.heading }),
3854
+ props.entries.map((e) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "throttle-timeline__row", children: [
3855
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-timeline__dot", "aria-hidden": "true" }),
3856
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-timeline__label", children: e.label }),
3857
+ /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "throttle-muted", children: formatDate(e.at, props.locale) })
3760
3858
  ] }, `${e.label}-${e.at}`))
3761
3859
  ] });
3762
3860
  }
3763
3861
 
3764
3862
  // src/react/components/account/OrderDetail.tsx
3765
- var import_jsx_runtime40 = require("react/jsx-runtime");
3863
+ var import_jsx_runtime39 = require("react/jsx-runtime");
3766
3864
  var CAN_PAY = /* @__PURE__ */ new Set(["draft", "pending"]);
3767
3865
  var CAN_REORDER = /* @__PURE__ */ new Set(["fulfilled", "cancelled", "closed"]);
3866
+ var CAN_CANCEL = /* @__PURE__ */ new Set(["draft", "pending", "processing"]);
3867
+ var SETTLED_PAYMENT = /* @__PURE__ */ new Set(["captured", "paid", "partially_refunded", "refunded"]);
3868
+ var CAN_RETURN = /* @__PURE__ */ new Set(["fulfilled", "partially_fulfilled", "closed"]);
3768
3869
  function Line(props) {
3769
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
3770
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "throttle-muted", children: props.label }),
3771
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { children: props.value })
3870
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
3871
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-muted", children: props.label }),
3872
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: props.strong ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: props.value }) : props.value })
3772
3873
  ] });
3773
3874
  }
3774
3875
  function OrderDetail(props) {
3775
3876
  const a = useAppearance(props.appearance);
3776
3877
  const scoped = useAppearanceProviderValue(props.appearance);
3777
3878
  const { t, locale } = useCopy(props.localization);
3879
+ const { account } = useAuth();
3778
3880
  const resource = useOrder(props.orderId);
3779
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
3881
+ const { submitting, error, run } = useAction();
3882
+ const confirm = useConfirm();
3883
+ const allowCancel = props.allowCancel ?? true;
3884
+ const allowReturn = props.allowReturn ?? true;
3885
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.root", "throttle-panel"), children: [
3780
3886
  props.onBack ? (
3781
3887
  // Wrapped on purpose. The panel is a column flex container, so a
3782
3888
  // direct child stretches to its full width however `width: auto`
@@ -3784,136 +3890,216 @@ function OrderDetail(props) {
3784
3890
  // centred label. The wrapper takes the stretch; the button keeps
3785
3891
  // its own width. A CSS fix would need a compound selector, and
3786
3892
  // those outrank the merchant overrides in `appearance.elements`.
3787
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
3893
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { variant: "link", elementKey: "orderDetail.backButton", onClick: props.onBack, children: t.common.back }) })
3788
3894
  ) : null,
3789
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3895
+ error ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Alert, { tone: "error", children: error }) : null,
3896
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3790
3897
  PanelState,
3791
3898
  {
3792
3899
  resource,
3793
3900
  isEmpty: (o) => o === null,
3794
3901
  emptyTitle: t.orders.empty,
3795
3902
  skeletonRows: 5,
3796
- children: (order) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
3797
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
3798
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { children: order.orderNumber }),
3799
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
3800
- ] }),
3801
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) }),
3802
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
3803
- item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
3804
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { style: { flex: 1 }, children: [
3805
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("strong", { children: item.name }),
3806
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: item.description }) : null,
3807
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "throttle-muted", children: [
3808
- t.orders.quantity,
3809
- " ",
3810
- item.quantity,
3811
- " \xD7 ",
3812
- formatMoney(item.unitPrice, order.currency, locale)
3813
- ] })
3814
- ] }),
3815
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { children: formatMoney(item.total, order.currency, locale) })
3816
- ] }, item.id)) }),
3817
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
3818
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Line, { label: t.orders.subtotal, value: formatMoney(order.subtotal, order.currency, locale) }),
3819
- order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Line, { label: t.orders.discount, value: formatMoney(-order.discountTotal, order.currency, locale) }) : null,
3820
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Line, { label: t.orders.shipping, value: formatMoney(order.shippingTotal, order.currency, locale) }),
3821
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Line, { label: t.orders.tax, value: formatMoney(order.taxTotal, order.currency, locale) }),
3822
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Line, { label: t.orders.total, value: formatMoney(order.total, order.currency, locale) })
3823
- ] }),
3824
- /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
3825
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3826
- AddressBlock,
3827
- {
3828
- heading: t.orders.shipTo,
3829
- address: order.shippingAddress,
3830
- elementKey: "orderDetail.shippingAddress"
3831
- }
3832
- ),
3833
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3834
- AddressBlock,
3835
- {
3836
- heading: t.orders.billTo,
3837
- address: order.billingAddress,
3838
- elementKey: "orderDetail.billingAddress"
3839
- }
3840
- )
3841
- ] }),
3842
- /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3843
- OrderTimeline,
3844
- {
3845
- heading: t.orders.history,
3846
- locale,
3847
- entries: orderTimeline(order, {
3848
- placed: t.orders.placed,
3849
- completed: t.orders.completed,
3850
- cancelled: t.orders.cancelledAt,
3851
- closed: t.orders.closedAt
3852
- })
3853
- }
3854
- ),
3855
- (() => {
3856
- const target = {
3857
- id: order.id,
3858
- orderNumber: order.orderNumber,
3859
- currency: order.currency,
3860
- lineItems: order.lineItems.map((li) => ({
3861
- name: li.name,
3862
- unitPrice: li.unitPrice,
3863
- quantity: li.quantity
3864
- }))
3865
- };
3866
- return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-actions", children: [
3867
- props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3868
- Button,
3869
- {
3870
- elementKey: "orderDetail.payButton",
3871
- onClick: () => props.onPayNow(target),
3872
- children: t.orders.payNow
3873
- }
3874
- ) : null,
3875
- props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3876
- Button,
3877
- {
3878
- variant: "secondary",
3879
- elementKey: "orderDetail.trackButton",
3880
- onClick: () => props.onTrackShipment(target),
3881
- children: t.orders.track
3882
- }
3883
- ) : null,
3884
- props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3885
- Button,
3903
+ children: (order) => {
3904
+ const target = {
3905
+ id: order.id,
3906
+ orderNumber: order.orderNumber,
3907
+ currency: order.currency,
3908
+ lineItems: order.lineItems.map((li) => ({
3909
+ name: li.name,
3910
+ unitPrice: li.unitPrice,
3911
+ quantity: li.quantity
3912
+ }))
3913
+ };
3914
+ const money = (v) => formatMoney(v, order.currency, locale);
3915
+ const paid = SETTLED_PAYMENT.has(order.paymentStatus);
3916
+ const showCancel = allowCancel && CAN_CANCEL.has(order.status) && !paid;
3917
+ const showReturn = allowReturn && CAN_RETURN.has(order.status);
3918
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.layout", "throttle-detail"), children: [
3919
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.main", "throttle-detail__main"), children: [
3920
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3921
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-row", children: [
3922
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h3", { children: order.orderNumber }),
3923
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OrderStatus, { status: order.status, paymentStatus: order.paymentStatus, t })
3924
+ ] }),
3925
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-muted", children: formatDate(order.createdAt, locale) })
3926
+ ] }),
3927
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3928
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.items }),
3929
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { ...a.el("orderDetail.lineItems", "throttle-stack"), children: order.lineItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.lineItem", "throttle-lineitem"), children: [
3930
+ item.imageUrl ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("img", { className: "throttle-lineitem__image", src: item.imageUrl, alt: "" }) : null,
3931
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { style: { flex: 1 }, children: [
3932
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("strong", { children: item.name }),
3933
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "throttle-lineitem__desc", children: item.description }) : null,
3934
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("p", { className: "throttle-lineitem__meta", children: [
3935
+ t.orders.quantity,
3936
+ " ",
3937
+ item.quantity,
3938
+ " \xD7 ",
3939
+ money(item.unitPrice)
3940
+ ] })
3941
+ ] }),
3942
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { children: money(item.total) })
3943
+ ] }, item.id)) })
3944
+ ] }),
3945
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3946
+ OrderTimeline,
3886
3947
  {
3887
- variant: "secondary",
3888
- elementKey: "orderDetail.reorderButton",
3889
- onClick: () => props.onReorder(target),
3890
- children: t.orders.reorder
3948
+ heading: t.orders.history,
3949
+ locale,
3950
+ entries: orderTimeline(order, {
3951
+ placed: t.orders.placed,
3952
+ completed: t.orders.completed,
3953
+ cancelled: t.orders.cancelledAt,
3954
+ closed: t.orders.closedAt
3955
+ })
3891
3956
  }
3892
- ) : null,
3893
- order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Button, { variant: "secondary", onClick: () => props.onViewSubscription(order.subscriptionId), children: t.orders.viewSubscription }) : null
3894
- ] });
3895
- })()
3896
- ] })
3957
+ ),
3958
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.addresses", "throttle-addresses"), children: [
3959
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3960
+ AddressBlock,
3961
+ {
3962
+ heading: t.orders.shipTo,
3963
+ address: order.shippingAddress,
3964
+ elementKey: "orderDetail.shippingAddress"
3965
+ }
3966
+ ),
3967
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3968
+ AddressBlock,
3969
+ {
3970
+ heading: t.orders.billTo,
3971
+ address: order.billingAddress,
3972
+ elementKey: "orderDetail.billingAddress"
3973
+ }
3974
+ )
3975
+ ] })
3976
+ ] }),
3977
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("aside", { ...a.el("orderDetail.rail", "throttle-detail__rail"), children: [
3978
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "throttle-detail__section", children: [
3979
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__label", children: t.orders.total }),
3980
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "throttle-detail__headline", children: money(order.total) })
3981
+ ] }),
3982
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.totals", "throttle-totals"), children: [
3983
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.subtotal, value: money(order.subtotal) }),
3984
+ order.discountTotal ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.discount, value: money(-order.discountTotal) }) : null,
3985
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.shipping, value: money(order.shippingTotal) }),
3986
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Line, { label: t.orders.tax, value: money(order.taxTotal) })
3987
+ ] }),
3988
+ /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { ...a.el("orderDetail.actions", "throttle-detail__actions"), children: [
3989
+ props.onPayNow && CAN_PAY.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Button, { elementKey: "orderDetail.payButton", onClick: () => props.onPayNow(target), children: t.orders.payNow }) : null,
3990
+ order.invoiceId ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3991
+ Button,
3992
+ {
3993
+ variant: "secondary",
3994
+ loading: submitting,
3995
+ elementKey: "orderDetail.invoiceButton",
3996
+ onClick: () => void run(async () => {
3997
+ const { url } = await account.getInvoicePdfUrl(order.invoiceId);
3998
+ const opened = window.open(url, "_blank", "noopener,noreferrer");
3999
+ if (!opened) window.location.assign(url);
4000
+ }),
4001
+ children: t.orders.downloadInvoice
4002
+ }
4003
+ ) : null,
4004
+ props.onTrackShipment && order.status === "partially_fulfilled" ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4005
+ Button,
4006
+ {
4007
+ variant: "secondary",
4008
+ elementKey: "orderDetail.trackButton",
4009
+ onClick: () => props.onTrackShipment(target),
4010
+ children: t.orders.track
4011
+ }
4012
+ ) : null,
4013
+ props.onReorder && CAN_REORDER.has(order.status) ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4014
+ Button,
4015
+ {
4016
+ variant: "secondary",
4017
+ elementKey: "orderDetail.reorderButton",
4018
+ onClick: () => props.onReorder(target),
4019
+ children: t.orders.reorder
4020
+ }
4021
+ ) : null,
4022
+ order.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4023
+ Button,
4024
+ {
4025
+ variant: "secondary",
4026
+ onClick: () => props.onViewSubscription(order.subscriptionId),
4027
+ children: t.orders.viewSubscription
4028
+ }
4029
+ ) : null,
4030
+ showReturn ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4031
+ Button,
4032
+ {
4033
+ variant: "secondary",
4034
+ disabled: submitting,
4035
+ elementKey: "orderDetail.returnButton",
4036
+ onClick: () => void (async () => {
4037
+ if (!await confirm({
4038
+ title: t.orders.requestReturnConfirm,
4039
+ body: t.orders.requestReturnBody,
4040
+ confirmLabel: t.orders.requestReturnAction
4041
+ })) return;
4042
+ await run(async () => {
4043
+ await account.requestOrderReturn(order.id, {
4044
+ items: order.lineItems.map((li) => ({
4045
+ lineItemId: li.id,
4046
+ quantity: li.quantity
4047
+ }))
4048
+ });
4049
+ await resource.refetch();
4050
+ });
4051
+ })(),
4052
+ children: t.orders.requestReturn
4053
+ }
4054
+ ) : null,
4055
+ showCancel ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4056
+ Button,
4057
+ {
4058
+ variant: "danger",
4059
+ disabled: submitting,
4060
+ elementKey: "orderDetail.cancelButton",
4061
+ onClick: () => void (async () => {
4062
+ if (!await confirm({
4063
+ title: t.orders.cancelOrderConfirm,
4064
+ body: t.orders.cancelOrderBody,
4065
+ confirmLabel: t.orders.cancelOrderAction,
4066
+ tone: "danger"
4067
+ })) return;
4068
+ await run(async () => {
4069
+ await account.cancelOrder(order.id);
4070
+ await resource.refetch();
4071
+ });
4072
+ })(),
4073
+ children: t.orders.cancelOrder
4074
+ }
4075
+ ) : null
4076
+ ] })
4077
+ ] })
4078
+ ] });
4079
+ }
3897
4080
  }
3898
4081
  )
3899
4082
  ] }) }) });
3900
4083
  }
3901
4084
 
3902
4085
  // src/react/components/account/OrdersPanel.tsx
3903
- var import_jsx_runtime41 = require("react/jsx-runtime");
4086
+ var import_jsx_runtime40 = require("react/jsx-runtime");
3904
4087
  function OrdersPanel(props) {
3905
4088
  const a = useAppearance(props.appearance);
3906
4089
  const scoped = useAppearanceProviderValue(props.appearance);
3907
4090
  const { t, locale } = useCopy(props.localization);
3908
4091
  const { emailVerified } = useAuth();
3909
4092
  const resource = useOrders();
3910
- const [openId, setOpenId] = (0, import_react27.useState)(null);
4093
+ const [openId, setOpenId] = (0, import_react26.useState)(props.initialOpenId ?? null);
4094
+ (0, import_react26.useEffect)(() => {
4095
+ if (props.initialOpenId) setOpenId(props.initialOpenId);
4096
+ }, [props.initialOpenId]);
3911
4097
  const variant = props.variant ?? "table";
3912
4098
  const rowsVariant = variant === "rows";
3913
4099
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
3914
4100
  const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
3915
4101
  if (openId) {
3916
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4102
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3917
4103
  OrderDetail,
3918
4104
  {
3919
4105
  orderId: openId,
@@ -3922,12 +4108,14 @@ function OrdersPanel(props) {
3922
4108
  onReorder: props.onReorder,
3923
4109
  onTrackShipment: props.onTrackShipment,
3924
4110
  onViewSubscription: props.onViewSubscription,
4111
+ allowCancel: props.allowCancel,
4112
+ allowReturn: props.allowReturn,
3925
4113
  appearance: props.appearance,
3926
4114
  localization: props.localization
3927
4115
  }
3928
4116
  );
3929
4117
  }
3930
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4118
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("ordersPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3931
4119
  PanelState,
3932
4120
  {
3933
4121
  resource,
@@ -3936,7 +4124,7 @@ function OrdersPanel(props) {
3936
4124
  isEmpty: (rows) => rows.length === 0,
3937
4125
  emptyTitle: t.orders.empty,
3938
4126
  emptyDescription: t.orders.emptyDescription,
3939
- children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4127
+ children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3940
4128
  DataTable,
3941
4129
  {
3942
4130
  tableKey: "ordersPanel.table",
@@ -3950,25 +4138,25 @@ function OrdersPanel(props) {
3950
4138
  {
3951
4139
  key: "status",
3952
4140
  label: t.orders.status,
3953
- render: (o) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
4141
+ render: (o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
3954
4142
  },
3955
4143
  {
3956
4144
  key: "total",
3957
4145
  label: t.orders.total,
3958
- render: (o) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
4146
+ render: (o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "throttle-table__money", children: formatMoney(o.total, o.currency, locale) })
3959
4147
  }
3960
4148
  ]
3961
4149
  }
3962
- ) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("ordersPanel.item", itemBase), children: [
3963
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { children: [
3964
- /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
3965
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: o.orderNumber }),
3966
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
4150
+ ) : /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { ...a.el("ordersPanel.list", listBase), children: rows.map((o) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { ...a.el("ordersPanel.item", itemBase), children: [
4151
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { children: [
4152
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "throttle-row", children: [
4153
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("strong", { children: o.orderNumber }),
4154
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OrderStatus, { status: o.status, paymentStatus: o.paymentStatus, t })
3967
4155
  ] }),
3968
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
3969
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
4156
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatDate(o.createdAt, locale) }),
4157
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "throttle-muted", children: formatMoney(o.total, o.currency, locale) })
3970
4158
  ] }),
3971
- /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4159
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3972
4160
  Button,
3973
4161
  {
3974
4162
  variant: rowsVariant ? "link" : "secondary",
@@ -3983,14 +4171,15 @@ function OrdersPanel(props) {
3983
4171
  }
3984
4172
 
3985
4173
  // src/react/components/account/InvoicesPanel.tsx
3986
- var import_react28 = require("react");
4174
+ var import_react27 = require("react");
3987
4175
 
3988
4176
  // src/react/components/account/InvoiceDetail.tsx
3989
- var import_jsx_runtime42 = require("react/jsx-runtime");
4177
+ var import_jsx_runtime41 = require("react/jsx-runtime");
4178
+ var PAYABLE = /* @__PURE__ */ new Set(["open"]);
3990
4179
  function Line2(props) {
3991
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "throttle-row", children: [
3992
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "throttle-muted", children: props.label }),
3993
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { children: props.value })
4180
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
4181
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-muted", children: props.label }),
4182
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: props.value })
3994
4183
  ] });
3995
4184
  }
3996
4185
  function InvoiceDetail(props) {
@@ -4000,84 +4189,147 @@ function InvoiceDetail(props) {
4000
4189
  const { account } = useAuth();
4001
4190
  const resource = useInvoice(props.invoiceId);
4002
4191
  const { submitting, error, run } = useAction();
4003
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
4192
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.root", "throttle-panel"), children: [
4004
4193
  props.onBack ? (
4005
- // Wrapped on purpose. The panel is a column flex container, so a
4006
- // direct child stretches to its full width however `width: auto`
4007
- // the link variant is — the control rendered 748px wide with a
4008
- // centred label. The wrapper takes the stretch; the button keeps
4009
- // its own width. A CSS fix would need a compound selector, and
4010
- // those outrank the merchant overrides in `appearance.elements`.
4011
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
4194
+ // Wrapped on purpose — see OrderDetail's back button for why a
4195
+ // direct flex child stretched to 748px.
4196
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Button, { variant: "link", elementKey: "invoiceDetail.backButton", onClick: props.onBack, children: t.common.back }) })
4012
4197
  ) : null,
4013
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
4014
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "throttle-row", children: [
4015
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h3", { children: invoice.number }),
4016
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
4017
- ] }),
4018
- /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
4019
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Line2, { label: t.invoices.issued, value: formatDate(invoice.issuedAt, locale) }),
4020
- invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
4021
- invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4022
- Line2,
4023
- {
4024
- label: t.invoices.period,
4025
- value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
4026
- }
4027
- ) : null,
4028
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Line2, { label: t.invoices.total, value: formatMoney(invoice.total, invoice.currency, locale) }),
4029
- invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4030
- Line2,
4031
- {
4032
- label: t.invoices.refunded,
4033
- value: formatMoney(invoice.amountRefunded, invoice.currency, locale)
4034
- }
4035
- ) : null
4036
- ] }),
4037
- error ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Alert, { tone: "error", children: error }) : null,
4038
- /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4039
- Button,
4040
- {
4041
- variant: "secondary",
4042
- loading: submitting,
4043
- elementKey: "invoiceDetail.downloadButton",
4044
- onClick: () => void run(async () => {
4045
- const { url } = await account.getInvoicePdfUrl(invoice.id);
4046
- const opened = window.open(url, "_blank", "noopener,noreferrer");
4047
- if (!opened) window.location.assign(url);
4048
- }),
4049
- children: t.invoices.downloadButton
4050
- }
4051
- )
4052
- ] }) })
4198
+ error ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Alert, { tone: "error", children: error }) : null,
4199
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(PanelState, { resource, isEmpty: (i) => i === null, emptyTitle: t.invoices.empty, skeletonRows: 4, children: (invoice) => {
4200
+ const money = (v) => formatMoney(v, invoice.currency, locale);
4201
+ const lines = invoice.lineItems ?? [];
4202
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.layout", "throttle-detail"), children: [
4203
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.main", "throttle-detail__main"), children: [
4204
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4205
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-row", children: [
4206
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { children: invoice.number }),
4207
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(StatusBadge, { status: invoice.status, labels: t.invoices.statusLabels })
4208
+ ] }),
4209
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-muted", children: [
4210
+ t.invoices.issued,
4211
+ " ",
4212
+ formatDate(invoice.issuedAt, locale)
4213
+ ] })
4214
+ ] }),
4215
+ lines.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4216
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.items }),
4217
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { ...a.el("invoiceDetail.lineItems", "throttle-stack"), children: lines.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.lineItem", "throttle-lineitem"), children: [
4218
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { style: { flex: 1 }, children: [
4219
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("strong", { children: item.name }),
4220
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "throttle-lineitem__desc", children: item.description }) : null,
4221
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("p", { className: "throttle-lineitem__meta", children: [
4222
+ t.orders.quantity,
4223
+ " ",
4224
+ item.quantity,
4225
+ " \xD7 ",
4226
+ money(item.unitPrice)
4227
+ ] })
4228
+ ] }),
4229
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { children: money(item.total) })
4230
+ ] }, i)) })
4231
+ ] }) : null
4232
+ ] }),
4233
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("aside", { ...a.el("invoiceDetail.rail", "throttle-detail__rail"), children: [
4234
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "throttle-detail__section", children: [
4235
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__label", children: t.invoices.total }),
4236
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "throttle-detail__headline", children: money(invoice.total) })
4237
+ ] }),
4238
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.totals", "throttle-totals"), children: [
4239
+ invoice.dueAt ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.due, value: formatDate(invoice.dueAt, locale) }) : null,
4240
+ invoice.periodStart && invoice.periodEnd ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4241
+ Line2,
4242
+ {
4243
+ label: t.invoices.period,
4244
+ value: `${formatDate(invoice.periodStart, locale)} \u2013 ${formatDate(invoice.periodEnd, locale)}`
4245
+ }
4246
+ ) : null,
4247
+ invoice.amountRefunded ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Line2, { label: t.invoices.refunded, value: money(invoice.amountRefunded) }) : null
4248
+ ] }),
4249
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { ...a.el("invoiceDetail.actions", "throttle-detail__actions"), children: [
4250
+ props.onPay && PAYABLE.has(invoice.status) ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4251
+ Button,
4252
+ {
4253
+ elementKey: "invoiceDetail.payButton",
4254
+ onClick: () => props.onPay({
4255
+ id: invoice.id,
4256
+ number: invoice.number,
4257
+ total: invoice.total,
4258
+ currency: invoice.currency
4259
+ }),
4260
+ children: t.invoices.payButton
4261
+ }
4262
+ ) : null,
4263
+ /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4264
+ Button,
4265
+ {
4266
+ variant: "secondary",
4267
+ loading: submitting,
4268
+ elementKey: "invoiceDetail.downloadButton",
4269
+ onClick: () => void run(async () => {
4270
+ const { url } = await account.getInvoicePdfUrl(invoice.id);
4271
+ const opened = window.open(url, "_blank", "noopener,noreferrer");
4272
+ if (!opened) window.location.assign(url);
4273
+ }),
4274
+ children: t.invoices.downloadButton
4275
+ }
4276
+ ),
4277
+ invoice.orderId && props.onViewOrder ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4278
+ Button,
4279
+ {
4280
+ variant: "secondary",
4281
+ elementKey: "invoiceDetail.orderLink",
4282
+ onClick: () => props.onViewOrder(invoice.orderId),
4283
+ children: invoice.orderNumber ? `${t.invoices.viewOrder} ${invoice.orderNumber}` : t.invoices.viewOrder
4284
+ }
4285
+ ) : null,
4286
+ invoice.subscriptionId && props.onViewSubscription ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4287
+ Button,
4288
+ {
4289
+ variant: "secondary",
4290
+ elementKey: "invoiceDetail.subscriptionLink",
4291
+ onClick: () => props.onViewSubscription(invoice.subscriptionId),
4292
+ children: t.invoices.viewSubscription
4293
+ }
4294
+ ) : null
4295
+ ] })
4296
+ ] })
4297
+ ] });
4298
+ } })
4053
4299
  ] }) }) });
4054
4300
  }
4055
4301
 
4056
4302
  // src/react/components/account/InvoicesPanel.tsx
4057
- var import_jsx_runtime43 = require("react/jsx-runtime");
4303
+ var import_jsx_runtime42 = require("react/jsx-runtime");
4058
4304
  function InvoicesPanel(props) {
4059
4305
  const a = useAppearance(props.appearance);
4060
4306
  const scoped = useAppearanceProviderValue(props.appearance);
4061
4307
  const { t, locale } = useCopy(props.localization);
4062
4308
  const { emailVerified } = useAuth();
4063
4309
  const resource = useInvoices();
4064
- const [openId, setOpenId] = (0, import_react28.useState)(null);
4310
+ const [openId, setOpenId] = (0, import_react27.useState)(props.initialOpenId ?? null);
4311
+ (0, import_react27.useEffect)(() => {
4312
+ if (props.initialOpenId) setOpenId(props.initialOpenId);
4313
+ }, [props.initialOpenId]);
4065
4314
  const variant = props.variant ?? "table";
4066
4315
  const rowsVariant = variant === "rows";
4067
4316
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
4068
4317
  const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
4069
4318
  if (openId) {
4070
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4319
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4071
4320
  InvoiceDetail,
4072
4321
  {
4073
4322
  invoiceId: openId,
4074
4323
  onBack: () => setOpenId(null),
4324
+ onViewOrder: props.onViewOrder,
4325
+ onViewSubscription: props.onViewSubscription,
4326
+ onPay: props.onPay,
4075
4327
  appearance: props.appearance,
4076
4328
  localization: props.localization
4077
4329
  }
4078
4330
  );
4079
4331
  }
4080
- return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4332
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("invoicesPanel.root", "throttle-panel"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4081
4333
  PanelState,
4082
4334
  {
4083
4335
  resource,
@@ -4086,7 +4338,7 @@ function InvoicesPanel(props) {
4086
4338
  isEmpty: (rows) => rows.length === 0,
4087
4339
  emptyTitle: t.invoices.empty,
4088
4340
  emptyDescription: t.invoices.emptyDescription,
4089
- children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4341
+ children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4090
4342
  DataTable,
4091
4343
  {
4092
4344
  tableKey: "invoicesPanel.table",
@@ -4097,24 +4349,24 @@ function InvoicesPanel(props) {
4097
4349
  columns: [
4098
4350
  { key: "number", label: t.invoices.number },
4099
4351
  { key: "issuedAt", label: t.invoices.issued, render: (i) => formatDate(i.issuedAt, locale) },
4100
- { key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
4352
+ { key: "status", label: t.invoices.status, render: (i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels }) },
4101
4353
  {
4102
4354
  key: "total",
4103
4355
  label: t.invoices.total,
4104
- render: (i) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
4356
+ render: (i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "throttle-table__money", children: formatMoney(i.total, i.currency, locale) })
4105
4357
  }
4106
4358
  ]
4107
4359
  }
4108
- ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("invoicesPanel.item", itemBase), children: [
4109
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
4110
- /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
4111
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("strong", { children: i.number }),
4112
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
4360
+ ) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { ...a.el("invoicesPanel.list", listBase), children: rows.map((i) => /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { ...a.el("invoicesPanel.item", itemBase), children: [
4361
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { children: [
4362
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "throttle-row", children: [
4363
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: i.number }),
4364
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(StatusBadge, { status: i.status, labels: t.invoices.statusLabels })
4113
4365
  ] }),
4114
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
4115
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
4366
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "throttle-muted", children: formatDate(i.issuedAt, locale) }),
4367
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "throttle-muted", children: formatMoney(i.total, i.currency, locale) })
4116
4368
  ] }),
4117
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4369
+ /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "throttle-actions", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4118
4370
  Button,
4119
4371
  {
4120
4372
  variant: rowsVariant ? "link" : "secondary",
@@ -4129,10 +4381,18 @@ function InvoicesPanel(props) {
4129
4381
  }
4130
4382
 
4131
4383
  // src/react/components/account/SubscriptionsPanel.tsx
4132
- var import_jsx_runtime44 = require("react/jsx-runtime");
4384
+ var import_jsx_runtime43 = require("react/jsx-runtime");
4133
4385
  var CAN_PAUSE = /* @__PURE__ */ new Set(["active", "trialing"]);
4134
4386
  var CAN_RESUME = /* @__PURE__ */ new Set(["paused"]);
4135
- var CAN_CANCEL = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
4387
+ var CAN_CANCEL2 = /* @__PURE__ */ new Set(["active", "trialing", "paused", "past_due", "unpaid"]);
4388
+ var INTERVAL_WORD = {
4389
+ weekly: "week",
4390
+ biweekly: "2 weeks",
4391
+ monthly: "month",
4392
+ quarterly: "quarter",
4393
+ yearly: "year"
4394
+ };
4395
+ var intervalWord = (interval) => INTERVAL_WORD[interval] ?? interval;
4136
4396
  function SubscriptionsPanel(props) {
4137
4397
  const a = useAppearance(props.appearance);
4138
4398
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -4145,17 +4405,17 @@ function SubscriptionsPanel(props) {
4145
4405
  const rowsVariant = variant === "rows";
4146
4406
  const listBase = rowsVariant ? "throttle-rows" : "throttle-stack";
4147
4407
  const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
4148
- const actionVariant = (base) => rowsVariant ? base === "danger" ? "linkDanger" : "link" : base;
4408
+ const actionVariant = (base) => base;
4149
4409
  const confirmThen = (fn, ask) => () => {
4150
4410
  void (async () => {
4151
4411
  if (!await confirm({ ...ask, tone: ask.tone ?? "neutral" })) return;
4152
4412
  await run(fn);
4153
4413
  })();
4154
4414
  };
4155
- const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${sub.interval}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
4415
+ const priceLabel = (sub) => `${formatMoney(sub.amount, sub.currency, locale)} / ${intervalWord(sub.interval)}${sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""}`;
4156
4416
  const renewsLabel = (sub) => formatDate(sub.status === "cancelled" ? sub.cancelledAt ?? sub.currentPeriodEnd : sub.currentPeriodEnd, locale);
4157
- const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-actions", children: [
4158
- CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4417
+ const lifecycleActions = (sub, variantFor) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-actions", children: [
4418
+ CAN_PAUSE.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4159
4419
  Button,
4160
4420
  {
4161
4421
  variant: variantFor("secondary"),
@@ -4168,7 +4428,7 @@ function SubscriptionsPanel(props) {
4168
4428
  children: t.subscriptions.pauseButton
4169
4429
  }
4170
4430
  ) : null,
4171
- CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4431
+ CAN_RESUME.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4172
4432
  Button,
4173
4433
  {
4174
4434
  variant: variantFor("secondary"),
@@ -4181,7 +4441,7 @@ function SubscriptionsPanel(props) {
4181
4441
  children: t.subscriptions.resumeButton
4182
4442
  }
4183
4443
  ) : null,
4184
- CAN_CANCEL.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4444
+ CAN_CANCEL2.has(sub.status) && !sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4185
4445
  Button,
4186
4446
  {
4187
4447
  variant: variantFor("secondary"),
@@ -4195,7 +4455,7 @@ function SubscriptionsPanel(props) {
4195
4455
  children: t.subscriptions.cancelAtPeriodEnd
4196
4456
  }
4197
4457
  ) : null,
4198
- CAN_CANCEL.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4458
+ CAN_CANCEL2.has(sub.status) ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4199
4459
  Button,
4200
4460
  {
4201
4461
  variant: variantFor("danger"),
@@ -4210,9 +4470,9 @@ function SubscriptionsPanel(props) {
4210
4470
  }
4211
4471
  ) : null
4212
4472
  ] });
4213
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
4214
- error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: error }) : null,
4215
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4473
+ return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("subscriptionsPanel.root", "throttle-panel"), children: [
4474
+ error ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Alert, { tone: "error", children: error }) : null,
4475
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4216
4476
  PanelState,
4217
4477
  {
4218
4478
  resource,
@@ -4221,7 +4481,7 @@ function SubscriptionsPanel(props) {
4221
4481
  isEmpty: (rows) => rows.length === 0,
4222
4482
  emptyTitle: t.subscriptions.empty,
4223
4483
  emptyDescription: t.subscriptions.emptyDescription,
4224
- children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4484
+ children: (rows) => variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4225
4485
  DataTable,
4226
4486
  {
4227
4487
  tableKey: "subscriptionsPanel.table",
@@ -4230,42 +4490,42 @@ function SubscriptionsPanel(props) {
4230
4490
  rows,
4231
4491
  columns: [
4232
4492
  { key: "plan", label: t.subscriptions.columnPlan, render: (sub) => sub.planName ?? sub.planReference },
4233
- { key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
4493
+ { key: "price", label: t.subscriptions.columnPrice, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "throttle-table__money", children: priceLabel(sub) }) },
4234
4494
  { key: "renews", label: t.subscriptions.columnRenews, render: (sub) => renewsLabel(sub) },
4235
- { key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
4236
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
4237
- sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
4495
+ { key: "status", label: t.subscriptions.columnStatus, render: (sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
4496
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels }),
4497
+ sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
4238
4498
  ] }) },
4239
4499
  { key: "actions", label: t.common.actions, render: (sub) => lifecycleActions(sub, (base) => base) }
4240
4500
  ]
4241
4501
  }
4242
- ) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
4243
- /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { children: [
4244
- /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
4245
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("strong", { children: sub.planName ?? sub.planReference }),
4246
- /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
4502
+ ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { ...a.el("subscriptionsPanel.list", listBase), children: rows.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { ...a.el("subscriptionsPanel.item", itemBase), children: [
4503
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
4504
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "throttle-row", children: [
4505
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("strong", { children: sub.planName ?? sub.planReference }),
4506
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(StatusBadge, { status: sub.status, labels: t.subscriptions.statusLabels })
4247
4507
  ] }),
4248
- /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
4508
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
4249
4509
  formatMoney(sub.amount, sub.currency, locale),
4250
4510
  " / ",
4251
- sub.interval,
4511
+ intervalWord(sub.interval),
4252
4512
  sub.quantity > 1 ? ` \xD7 ${sub.quantity}` : ""
4253
4513
  ] }),
4254
- sub.status === "cancelled" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
4514
+ sub.status === "cancelled" ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
4255
4515
  t.subscriptions.cancelledOn,
4256
4516
  " ",
4257
4517
  formatDate(sub.cancelledAt ?? sub.currentPeriodEnd, locale)
4258
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
4518
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
4259
4519
  sub.cancelAtPeriodEnd ? t.subscriptions.endsOn : t.subscriptions.renewsOn,
4260
4520
  " ",
4261
4521
  formatDate(sub.currentPeriodEnd, locale)
4262
4522
  ] }),
4263
- sub.trialEnd ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
4523
+ sub.trialEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("p", { className: "throttle-muted", children: [
4264
4524
  t.subscriptions.trialEnds,
4265
4525
  " ",
4266
4526
  formatDate(sub.trialEnd, locale)
4267
4527
  ] }) : null,
4268
- sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
4528
+ sub.cancelAtPeriodEnd ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Badge, { tone: "warning", children: t.subscriptions.cancelScheduled }) : null
4269
4529
  ] }),
4270
4530
  lifecycleActions(sub, actionVariant)
4271
4531
  ] }, sub.id)) })
@@ -4275,7 +4535,7 @@ function SubscriptionsPanel(props) {
4275
4535
  }
4276
4536
 
4277
4537
  // src/react/components/account/SecurityPanel.tsx
4278
- var import_react29 = require("react");
4538
+ var import_react28 = require("react");
4279
4539
 
4280
4540
  // src/react/components/account/device.ts
4281
4541
  var BROWSERS = [
@@ -4308,7 +4568,7 @@ function describeDevice(userAgent) {
4308
4568
  }
4309
4569
 
4310
4570
  // src/react/components/account/SecurityPanel.tsx
4311
- var import_jsx_runtime45 = require("react/jsx-runtime");
4571
+ var import_jsx_runtime44 = require("react/jsx-runtime");
4312
4572
  function SecurityPanel(props) {
4313
4573
  const a = useAppearance(props.appearance);
4314
4574
  const scoped = useAppearanceProviderValue(props.appearance);
@@ -4318,16 +4578,16 @@ function SecurityPanel(props) {
4318
4578
  const rowsVariant = variant === "rows";
4319
4579
  const itemBase = rowsVariant ? "throttle-rowitem" : "throttle-listitem";
4320
4580
  const revokeVariant = rowsVariant ? "linkDanger" : "danger";
4321
- const [password, setPassword] = (0, import_react29.useState)("");
4581
+ const [password, setPassword] = (0, import_react28.useState)("");
4322
4582
  const passwordAction = useAction();
4323
4583
  const sessionAction = useAction();
4324
- const [sessions, setSessions] = (0, import_react29.useState)(null);
4325
- const [listError, setListError] = (0, import_react29.useState)(null);
4326
- const errorMessageRef = (0, import_react29.useRef)(errorMessage);
4327
- (0, import_react29.useEffect)(() => {
4584
+ const [sessions, setSessions] = (0, import_react28.useState)(null);
4585
+ const [listError, setListError] = (0, import_react28.useState)(null);
4586
+ const errorMessageRef = (0, import_react28.useRef)(errorMessage);
4587
+ (0, import_react28.useEffect)(() => {
4328
4588
  errorMessageRef.current = errorMessage;
4329
4589
  });
4330
- const load = (0, import_react29.useCallback)(async () => {
4590
+ const load = (0, import_react28.useCallback)(async () => {
4331
4591
  try {
4332
4592
  setSessions(await auth.listSessions());
4333
4593
  setListError(null);
@@ -4335,12 +4595,12 @@ function SecurityPanel(props) {
4335
4595
  setListError(errorMessageRef.current(err));
4336
4596
  }
4337
4597
  }, [auth]);
4338
- (0, import_react29.useEffect)(() => {
4598
+ (0, import_react28.useEffect)(() => {
4339
4599
  void load();
4340
4600
  }, [load]);
4341
4601
  const others = (sessions ?? []).filter((s) => !s.current);
4342
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
4343
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4602
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.root", "throttle-panel"), children: [
4603
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
4344
4604
  "form",
4345
4605
  {
4346
4606
  ...a.el("securityPanel.passwordForm", "throttle-stack"),
@@ -4353,8 +4613,8 @@ function SecurityPanel(props) {
4353
4613
  });
4354
4614
  },
4355
4615
  children: [
4356
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h3", { children: t.security.passwordTitle }),
4357
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4616
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h3", { children: t.security.passwordTitle }),
4617
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4358
4618
  Field,
4359
4619
  {
4360
4620
  label: t.security.newPassword,
@@ -4365,21 +4625,21 @@ function SecurityPanel(props) {
4365
4625
  onChange: setPassword
4366
4626
  }
4367
4627
  ),
4368
- passwordAction.error ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Alert, { tone: "error", children: passwordAction.error }) : null,
4369
- passwordAction.notice ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Alert, { tone: "success", children: passwordAction.notice }) : null,
4370
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
4628
+ passwordAction.error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: passwordAction.error }) : null,
4629
+ passwordAction.notice ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "success", children: passwordAction.notice }) : null,
4630
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Button, { type: "submit", loading: passwordAction.submitting, elementKey: "securityPanel.passwordButton", children: t.security.changeButton })
4371
4631
  ]
4372
4632
  }
4373
4633
  ),
4374
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
4375
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h3", { children: t.security.sessionsTitle }),
4376
- listError ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4377
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Alert, { tone: "error", children: listError }),
4378
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
4634
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.sessionList", "throttle-stack"), children: [
4635
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("h3", { children: t.security.sessionsTitle }),
4636
+ listError ? /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
4637
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: listError }),
4638
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Button, { variant: "secondary", onClick: () => void load(), children: t.common.retry })
4379
4639
  ] }) : null,
4380
- sessionAction.error ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Alert, { tone: "error", children: sessionAction.error }) : null,
4381
- sessions === null && !listError ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Skeleton, { count: 2 }) : null,
4382
- sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4640
+ sessionAction.error ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Alert, { tone: "error", children: sessionAction.error }) : null,
4641
+ sessions === null && !listError ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Skeleton, { count: 2 }) : null,
4642
+ sessions !== null && !listError && variant === "table" ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4383
4643
  DataTable,
4384
4644
  {
4385
4645
  tableKey: "securityPanel.table",
@@ -4387,12 +4647,12 @@ function SecurityPanel(props) {
4387
4647
  rowKey: (session) => session.id,
4388
4648
  rows: sessions,
4389
4649
  columns: [
4390
- { key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "throttle-row", children: [
4391
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
4392
- session.current ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
4650
+ { key: "device", label: t.security.columnDevice, render: (session) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
4651
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
4652
+ session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
4393
4653
  ] }) },
4394
4654
  { key: "lastActive", label: t.security.lastActive, render: (session) => formatDate(session.lastUsedAt, locale) },
4395
- { key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4655
+ { key: "actions", label: t.common.actions, render: (session) => !session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4396
4656
  Button,
4397
4657
  {
4398
4658
  variant: "danger",
@@ -4407,19 +4667,19 @@ function SecurityPanel(props) {
4407
4667
  ) : null }
4408
4668
  ]
4409
4669
  }
4410
- ) : (sessions ?? []).map((session) => /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
4411
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { children: [
4412
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "throttle-row", children: [
4413
- /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
4414
- session.current ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
4670
+ ) : (sessions ?? []).map((session) => /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ...a.el("securityPanel.sessionItem", itemBase), children: [
4671
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { children: [
4672
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "throttle-row", children: [
4673
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("strong", { children: describeDevice(session.userAgent) || session.ipPrefix || session.id }),
4674
+ session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Badge, { tone: "success", children: t.security.thisDevice }) : null
4415
4675
  ] }),
4416
- /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "throttle-muted", children: [
4676
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("p", { className: "throttle-muted", children: [
4417
4677
  t.security.lastActive,
4418
4678
  " ",
4419
4679
  formatDate(session.lastUsedAt, locale)
4420
4680
  ] })
4421
4681
  ] }),
4422
- !session.current ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4682
+ !session.current ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4423
4683
  Button,
4424
4684
  {
4425
4685
  variant: revokeVariant,
@@ -4433,8 +4693,8 @@ function SecurityPanel(props) {
4433
4693
  }
4434
4694
  ) : null
4435
4695
  ] }, session.id)),
4436
- sessions !== null && others.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
4437
- others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4696
+ sessions !== null && others.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "throttle-muted", children: t.security.sessionsEmpty }) : null,
4697
+ others.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4438
4698
  Button,
4439
4699
  {
4440
4700
  variant: "danger",
@@ -4454,7 +4714,7 @@ function SecurityPanel(props) {
4454
4714
  }
4455
4715
 
4456
4716
  // src/react/components/account/AccountDashboard.tsx
4457
- var import_jsx_runtime46 = require("react/jsx-runtime");
4717
+ var import_jsx_runtime45 = require("react/jsx-runtime");
4458
4718
  var ACCOUNT_TABS = [
4459
4719
  "profile",
4460
4720
  "addresses",
@@ -4483,9 +4743,10 @@ function AccountDashboard(props) {
4483
4743
  const { status } = useAuth();
4484
4744
  const shown = props.tabs ?? [...ACCOUNT_TABS];
4485
4745
  const controlled = props.tab !== void 0;
4486
- const [internal, setInternal] = (0, import_react30.useState)(shown[0] ?? "profile");
4487
- const idBase = (0, import_react30.useId)();
4488
- (0, import_react30.useEffect)(() => {
4746
+ const [internal, setInternal] = (0, import_react29.useState)(shown[0] ?? "profile");
4747
+ const [openOrderId, setOpenOrderId] = (0, import_react29.useState)(null);
4748
+ const idBase = (0, import_react29.useId)();
4749
+ (0, import_react29.useEffect)(() => {
4489
4750
  if (props.routing !== "hash" || typeof window === "undefined") return;
4490
4751
  const apply = () => {
4491
4752
  const next = TAB_FOR_HASH[window.location.hash] ?? shown[0];
@@ -4506,7 +4767,7 @@ function AccountDashboard(props) {
4506
4767
  };
4507
4768
  const shared = { appearance: props.appearance, localization: props.localization };
4508
4769
  const sidebar = (props.layout ?? "sidebar") === "sidebar";
4509
- const nav = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4770
+ const nav = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4510
4771
  Tabs,
4511
4772
  {
4512
4773
  idBase,
@@ -4522,7 +4783,7 @@ function AccountDashboard(props) {
4522
4783
  }))
4523
4784
  }
4524
4785
  );
4525
- const panel = /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4786
+ const panel = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4526
4787
  "div",
4527
4788
  {
4528
4789
  ...a.el("accountDashboard.panel", sidebar ? "throttle-account__content" : "throttle-tabs__panel"),
@@ -4531,46 +4792,58 @@ function AccountDashboard(props) {
4531
4792
  "aria-labelledby": `${idBase}-tab-${active}`,
4532
4793
  tabIndex: 0,
4533
4794
  children: [
4534
- active === "profile" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ProfilePanel, { ...shared }) : null,
4535
- active === "addresses" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
4536
- active === "paymentMethods" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
4537
- active === "orders" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4795
+ active === "profile" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ProfilePanel, { ...shared }) : null,
4796
+ active === "addresses" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AddressesPanel, { ...shared, variant: props.panelVariant }) : null,
4797
+ active === "paymentMethods" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PaymentMethodsPanel, { ...shared, variant: props.panelVariant }) : null,
4798
+ active === "orders" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4538
4799
  OrdersPanel,
4539
4800
  {
4540
4801
  ...shared,
4541
4802
  variant: props.panelVariant,
4803
+ initialOpenId: openOrderId,
4542
4804
  onViewSubscription: () => go("subscriptions"),
4543
4805
  onPayNow: props.onPayNow,
4544
4806
  onReorder: props.onReorder,
4545
4807
  onTrackShipment: props.onTrackShipment
4546
4808
  }
4547
4809
  ) : null,
4548
- active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(InvoicesPanel, { ...shared, variant: props.panelVariant }) : null,
4549
- active === "subscriptions" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
4550
- active === "security" ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
4810
+ active === "invoices" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4811
+ InvoicesPanel,
4812
+ {
4813
+ ...shared,
4814
+ variant: props.panelVariant,
4815
+ onViewOrder: (orderId) => {
4816
+ setOpenOrderId(orderId);
4817
+ go("orders");
4818
+ },
4819
+ onViewSubscription: () => go("subscriptions")
4820
+ }
4821
+ ) : null,
4822
+ active === "subscriptions" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SubscriptionsPanel, { ...shared, variant: props.panelVariant }) : null,
4823
+ active === "security" ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SecurityPanel, { ...shared, variant: props.panelVariant }) : null
4551
4824
  ]
4552
4825
  }
4553
4826
  );
4554
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
4555
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(VerifyEmailBanner, { ...shared }),
4556
- sidebar ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "throttle-account", children: [
4557
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
4827
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.rootProps, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { ...a.el("accountDashboard.root", "throttle-panel throttle-account-root"), children: [
4828
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(VerifyEmailBanner, { ...shared }),
4829
+ sidebar ? /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "throttle-account", children: [
4830
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.el("accountDashboard.sidebar"), children: nav }),
4558
4831
  panel
4559
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
4560
- /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountDashboard.tabs"), children: nav }),
4832
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4833
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { ...a.el("accountDashboard.tabs"), children: nav }),
4561
4834
  panel
4562
4835
  ] })
4563
4836
  ] }) }) });
4564
4837
  }
4565
4838
 
4566
4839
  // src/react/components/account/AccountModal.tsx
4567
- var import_jsx_runtime47 = require("react/jsx-runtime");
4840
+ var import_jsx_runtime46 = require("react/jsx-runtime");
4568
4841
  function AccountModal(props) {
4569
4842
  const a = useAppearance(props.appearance);
4570
4843
  const scoped = useAppearanceProviderValue(props.appearance);
4571
4844
  const { t } = useCopy(props.localization);
4572
- const titleId = (0, import_react31.useId)();
4573
- return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
4845
+ const titleId = (0, import_react30.useId)();
4846
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AppearanceProvider, { value: scoped, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4574
4847
  Modal,
4575
4848
  {
4576
4849
  open: props.open,
@@ -4580,15 +4853,15 @@ function AccountModal(props) {
4580
4853
  overlayKey: "accountModal.overlay",
4581
4854
  containerKey: "accountModal.container",
4582
4855
  children: [
4583
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
4584
- /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
4856
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountModal.header", "throttle-modal__header"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h2", { id: titleId, ...a.el("accountModal.title", "throttle-modal__title"), children: t.account.title }) }),
4857
+ /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ...a.el("accountModal.body", "throttle-modal__body"), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(AccountDashboard, { tabs: props.tabs, appearance: props.appearance, localization: props.localization }) })
4585
4858
  ]
4586
4859
  }
4587
4860
  ) });
4588
4861
  }
4589
4862
 
4590
4863
  // src/react/components/provider.tsx
4591
- var import_jsx_runtime48 = require("react/jsx-runtime");
4864
+ var import_jsx_runtime47 = require("react/jsx-runtime");
4592
4865
  var warned = /* @__PURE__ */ new Set();
4593
4866
  function warnOnce(key, message) {
4594
4867
  if (process.env.NODE_ENV === "production") return;
@@ -4596,9 +4869,9 @@ function warnOnce(key, message) {
4596
4869
  warned.add(key);
4597
4870
  console.warn(`[@usethrottle/auth] ${message}`);
4598
4871
  }
4599
- var ThrottleUIContext = (0, import_react32.createContext)(null);
4872
+ var ThrottleUIContext = (0, import_react31.createContext)(null);
4600
4873
  function useThrottle() {
4601
- const ctx = (0, import_react32.useContext)(ThrottleUIContext);
4874
+ const ctx = (0, import_react31.useContext)(ThrottleUIContext);
4602
4875
  if (!ctx) {
4603
4876
  warnOnce(
4604
4877
  "use-throttle-no-provider",
@@ -4633,51 +4906,51 @@ function ThrottleProvider(props) {
4633
4906
  __captureStepUp
4634
4907
  } = props;
4635
4908
  useInjectStyles(injectStyles);
4636
- const [stepUpOpen, setStepUpOpen] = (0, import_react32.useState)(false);
4637
- const resolveStepUp = (0, import_react32.useRef)(null);
4638
- const claimRef = (0, import_react32.useRef)(claimCartOnSignIn);
4909
+ const [stepUpOpen, setStepUpOpen] = (0, import_react31.useState)(false);
4910
+ const resolveStepUp = (0, import_react31.useRef)(null);
4911
+ const claimRef = (0, import_react31.useRef)(claimCartOnSignIn);
4639
4912
  claimRef.current = claimCartOnSignIn;
4640
- const [overlay, setOverlay] = (0, import_react32.useState)(null);
4641
- const overlayRestoreFocus = (0, import_react32.useRef)(null);
4642
- const [accountTabs, setAccountTabs] = (0, import_react32.useState)(void 0);
4643
- const onOverlaySuccess = (0, import_react32.useRef)(null);
4644
- const openSignIn = (0, import_react32.useCallback)((onSuccess) => {
4913
+ const [overlay, setOverlay] = (0, import_react31.useState)(null);
4914
+ const overlayRestoreFocus = (0, import_react31.useRef)(null);
4915
+ const [accountTabs, setAccountTabs] = (0, import_react31.useState)(void 0);
4916
+ const onOverlaySuccess = (0, import_react31.useRef)(null);
4917
+ const openSignIn = (0, import_react31.useCallback)((onSuccess) => {
4645
4918
  onOverlaySuccess.current = onSuccess ?? null;
4646
4919
  setOverlay("signIn");
4647
4920
  }, []);
4648
- const openSignUp = (0, import_react32.useCallback)((onSuccess) => {
4921
+ const openSignUp = (0, import_react31.useCallback)((onSuccess) => {
4649
4922
  onOverlaySuccess.current = onSuccess ?? null;
4650
4923
  setOverlay("signUp");
4651
4924
  }, []);
4652
- const openAccount = (0, import_react32.useCallback)((opts) => {
4925
+ const openAccount = (0, import_react31.useCallback)((opts) => {
4653
4926
  onOverlaySuccess.current = null;
4654
4927
  overlayRestoreFocus.current = opts?.restoreFocusTo ?? null;
4655
4928
  setAccountTabs(opts?.tabs);
4656
4929
  setOverlay("account");
4657
4930
  }, []);
4658
- const closeOverlay = (0, import_react32.useCallback)(() => {
4931
+ const closeOverlay = (0, import_react31.useCallback)(() => {
4659
4932
  onOverlaySuccess.current = null;
4660
4933
  overlayRestoreFocus.current = null;
4661
4934
  setOverlay(null);
4662
4935
  }, []);
4663
- const handleOverlaySuccess = (0, import_react32.useCallback)(() => {
4936
+ const handleOverlaySuccess = (0, import_react31.useCallback)(() => {
4664
4937
  const fn = onOverlaySuccess.current;
4665
4938
  onOverlaySuccess.current = null;
4666
4939
  setOverlay(null);
4667
4940
  fn?.();
4668
4941
  }, []);
4669
- const ui = (0, import_react32.useMemo)(
4942
+ const ui = (0, import_react31.useMemo)(
4670
4943
  () => ({ overlay, openSignIn, openSignUp, openAccount, close: closeOverlay }),
4671
4944
  [overlay, openSignIn, openSignUp, openAccount, closeOverlay]
4672
4945
  );
4673
- const askForStepUp = (0, import_react32.useCallback)(
4946
+ const askForStepUp = (0, import_react31.useCallback)(
4674
4947
  () => new Promise((resolve) => {
4675
4948
  resolveStepUp.current = resolve;
4676
4949
  setStepUpOpen(true);
4677
4950
  }),
4678
4951
  []
4679
4952
  );
4680
- const auth = (0, import_react32.useMemo)(() => {
4953
+ const auth = (0, import_react31.useMemo)(() => {
4681
4954
  __captureStepUp?.(askForStepUp);
4682
4955
  const client = injected ?? createThrottleAuth({ publishableKey, baseUrl, storage, onStepUpRequired: askForStepUp });
4683
4956
  const account = createAccount(client);
@@ -4710,10 +4983,9 @@ function ThrottleProvider(props) {
4710
4983
  resolve?.(password);
4711
4984
  };
4712
4985
  const authOverlayOpen = overlay === "signIn" || overlay === "signUp";
4713
- return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ConfirmProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
4986
+ return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AppearanceProvider, { value: appearance ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(LocalizationProvider, { value: localization ?? {}, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(BrandLogoProvider, { value: logo ?? null, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ThrottleAuthProvider, { auth, publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ConfirmProvider, { stepUpOpen, onStepUpResolve: finishStepUp, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(ThrottleUIContext.Provider, { value: ui, children: [
4714
4987
  children,
4715
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(StepUpDialog, { open: stepUpOpen, onResolve: finishStepUp }),
4716
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4988
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
4717
4989
  AuthModal,
4718
4990
  {
4719
4991
  open: authOverlayOpen,
@@ -4724,10 +4996,14 @@ function ThrottleProvider(props) {
4724
4996
  },
4725
4997
  overlay === "signUp" ? "signUp" : "signIn"
4726
4998
  ),
4727
- /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
4999
+ /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(AccountModal, { open: overlay === "account", onClose: closeOverlay, tabs: accountTabs, restoreFocusTo: overlayRestoreFocus.current })
4728
5000
  ] }) }) }) }) }) });
4729
5001
  }
4730
5002
 
5003
+ // src/react/components/auth/StepUpDialog.tsx
5004
+ var import_react32 = require("react");
5005
+ var import_jsx_runtime48 = require("react/jsx-runtime");
5006
+
4731
5007
  // src/react/components/auth/SignInButton.tsx
4732
5008
  var import_react33 = require("react");
4733
5009
  var import_jsx_runtime49 = require("react/jsx-runtime");