@openrails/billing-ui 0.273.0 → 0.275.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/admin/components/customer-search.d.ts +5 -0
  2. package/dist/admin/components/missing-record.d.ts +6 -0
  3. package/dist/admin/components/status-badge.d.ts +1 -0
  4. package/dist/admin/context.d.ts +34 -2
  5. package/dist/admin/lib/api/endpoints.d.ts +4 -1
  6. package/dist/admin/lib/api/index.d.ts +3 -0
  7. package/dist/admin/lib/api/order-endpoints.d.ts +1 -0
  8. package/dist/admin/lib/api/types.d.ts +4 -12
  9. package/dist/admin/lib/capabilities.d.ts +4 -0
  10. package/dist/admin/lib/dialog-width.d.ts +4 -3
  11. package/dist/admin/lib/error-text.d.ts +4 -0
  12. package/dist/admin/lib/format.d.ts +5 -1
  13. package/dist/admin/lib/mutations.d.ts +6 -1
  14. package/dist/admin/lib/order-queries.d.ts +3 -0
  15. package/dist/admin/lib/queries.d.ts +6 -0
  16. package/dist/admin/lib/tile-grids.d.ts +6 -0
  17. package/dist/admin/messages.d.ts +102 -8
  18. package/dist/admin/pages/dashboard/lib.d.ts +1 -0
  19. package/dist/admin/pages/imports/shared.d.ts +1 -0
  20. package/dist/admin/pages/payments/index.d.ts +1 -2
  21. package/dist/admin/pages/subscriptions/change-subscription-dialog.d.ts +4 -7
  22. package/dist/admin/pages/subscriptions/index.d.ts +1 -2
  23. package/dist/admin/pages/subscriptions/subscription-change-options.d.ts +6 -15
  24. package/dist/admin-attempts-CP5CWyNR.js +419 -0
  25. package/dist/admin-attempts-CP5CWyNR.js.map +1 -0
  26. package/dist/{admin-auth-1aZIgXiS.js → admin-auth-DlIOmwPo.js} +2 -2
  27. package/dist/{admin-auth-1aZIgXiS.js.map → admin-auth-DlIOmwPo.js.map} +1 -1
  28. package/dist/{admin-badge-pgG6D9-a.js → admin-badge-DR_8AhdC.js} +2 -2
  29. package/dist/{admin-badge-pgG6D9-a.js.map → admin-badge-DR_8AhdC.js.map} +1 -1
  30. package/dist/{admin-button-CrcYk5r0.js → admin-button-DBzTD6By.js} +2 -2
  31. package/dist/{admin-button-CrcYk5r0.js.map → admin-button-DBzTD6By.js.map} +1 -1
  32. package/dist/{admin-capabilities-BDcZeHL_.js → admin-capabilities-CZdT1Pxe.js} +35 -14
  33. package/dist/admin-capabilities-CZdT1Pxe.js.map +1 -0
  34. package/dist/{admin-card-DvTMc5Se.js → admin-card-mZl4-s5d.js} +2 -2
  35. package/dist/{admin-card-DvTMc5Se.js.map → admin-card-mZl4-s5d.js.map} +1 -1
  36. package/dist/{admin-catalog-BlF5mnu4.js → admin-catalog-DpTjS0Yo.js} +298 -298
  37. package/dist/{admin-catalog-BlF5mnu4.js.map → admin-catalog-DpTjS0Yo.js.map} +1 -1
  38. package/dist/{admin-cursor-pager-CIb3Jw2F.js → admin-cursor-pager-C-KjCIy9.js} +6 -6
  39. package/dist/{admin-cursor-pager-CIb3Jw2F.js.map → admin-cursor-pager-C-KjCIy9.js.map} +1 -1
  40. package/dist/{admin-customers-EpfoWDh-.js → admin-customers-BE3N839X.js} +22 -21
  41. package/dist/{admin-customers-EpfoWDh-.js.map → admin-customers-BE3N839X.js.map} +1 -1
  42. package/dist/admin-dashboard-BxjkV15J.js +464 -0
  43. package/dist/admin-dashboard-BxjkV15J.js.map +1 -0
  44. package/dist/admin-data-table-D89AwWz_.js +107 -0
  45. package/dist/admin-data-table-D89AwWz_.js.map +1 -0
  46. package/dist/admin-detail-BKe9xqPd.js +338 -0
  47. package/dist/admin-detail-BKe9xqPd.js.map +1 -0
  48. package/dist/admin-detail-C8lD7U2t.js +699 -0
  49. package/dist/admin-detail-C8lD7U2t.js.map +1 -0
  50. package/dist/admin-detail-D6zD085K.js +354 -0
  51. package/dist/admin-detail-D6zD085K.js.map +1 -0
  52. package/dist/{admin-detail-3wFIDPNB.js → admin-detail-Ln56otK0.js} +83 -83
  53. package/dist/{admin-detail-3wFIDPNB.js.map → admin-detail-Ln56otK0.js.map} +1 -1
  54. package/dist/admin-detail-P-UnNvXJ.js +1357 -0
  55. package/dist/admin-detail-P-UnNvXJ.js.map +1 -0
  56. package/dist/{admin-dialog-BSRf9Zre.js → admin-dialog-Dn2FRJu4.js} +3 -3
  57. package/dist/{admin-dialog-BSRf9Zre.js.map → admin-dialog-Dn2FRJu4.js.map} +1 -1
  58. package/dist/admin-dialog-width-CC7QHT1p.js +6 -0
  59. package/dist/admin-dialog-width-CC7QHT1p.js.map +1 -0
  60. package/dist/{admin-dropdown-menu-D0E5rwmn.js → admin-dropdown-menu-DLUn6Uj3.js} +2 -2
  61. package/dist/{admin-dropdown-menu-D0E5rwmn.js.map → admin-dropdown-menu-DLUn6Uj3.js.map} +1 -1
  62. package/dist/{admin-dunning-B2zgtrOo.js → admin-dunning-COaHzrmN.js} +2 -2
  63. package/dist/{admin-dunning-B2zgtrOo.js.map → admin-dunning-COaHzrmN.js.map} +1 -1
  64. package/dist/{admin-fact-card-BPSVhS15.js → admin-fact-card-DKvBnUXB.js} +2 -2
  65. package/dist/{admin-fact-card-BPSVhS15.js.map → admin-fact-card-DKvBnUXB.js.map} +1 -1
  66. package/dist/admin-format-BbiTCqUG.js +171 -0
  67. package/dist/admin-format-BbiTCqUG.js.map +1 -0
  68. package/dist/{admin-health-D0L5Kig7.js → admin-health-DmnI4e8K.js} +249 -248
  69. package/dist/admin-health-DmnI4e8K.js.map +1 -0
  70. package/dist/{admin-imports-CgZB5JAV.js → admin-imports-C0aMP6sj.js} +65 -65
  71. package/dist/{admin-imports-CgZB5JAV.js.map → admin-imports-C0aMP6sj.js.map} +1 -1
  72. package/dist/{admin-input-DJAK9nmk.js → admin-input-JKrQIGfD.js} +2 -2
  73. package/dist/{admin-input-DJAK9nmk.js.map → admin-input-JKrQIGfD.js.map} +1 -1
  74. package/dist/{admin-label-aviN9Gng.js → admin-label-CHWsVIZC.js} +2 -2
  75. package/dist/{admin-label-aviN9Gng.js.map → admin-label-CHWsVIZC.js.map} +1 -1
  76. package/dist/{admin-linked-table-row-BGr7JXeM.js → admin-linked-table-row-BMZYYsuk.js} +4 -4
  77. package/dist/{admin-linked-table-row-BGr7JXeM.js.map → admin-linked-table-row-BMZYYsuk.js.map} +1 -1
  78. package/dist/{admin-map-dialog-DS2Wz6G3.js → admin-map-dialog-BHUGdCcv.js} +24 -24
  79. package/dist/{admin-map-dialog-DS2Wz6G3.js.map → admin-map-dialog-BHUGdCcv.js.map} +1 -1
  80. package/dist/{admin-metering-D-e-37Jn.js → admin-metering-CDqueHUh.js} +307 -307
  81. package/dist/{admin-metering-D-e-37Jn.js.map → admin-metering-CDqueHUh.js.map} +1 -1
  82. package/dist/admin-missing-record-BPFs3MmO.js +42 -0
  83. package/dist/admin-missing-record-BPFs3MmO.js.map +1 -0
  84. package/dist/admin-ops-CL2kjDwi.js +359 -0
  85. package/dist/admin-ops-CL2kjDwi.js.map +1 -0
  86. package/dist/admin-orders-C1Sf2qhc.js +192 -0
  87. package/dist/admin-orders-C1Sf2qhc.js.map +1 -0
  88. package/dist/admin-parked-a0tB5bhG.js +193 -0
  89. package/dist/admin-parked-a0tB5bhG.js.map +1 -0
  90. package/dist/admin-payments-DJcjwRA4.js +221 -0
  91. package/dist/admin-payments-DJcjwRA4.js.map +1 -0
  92. package/dist/{admin-price-detail-CSI5oKdb.js → admin-price-detail-BOmeWw15.js} +103 -103
  93. package/dist/{admin-price-detail-CSI5oKdb.js.map → admin-price-detail-BOmeWw15.js.map} +1 -1
  94. package/dist/{admin-price-format-BVUpDoSC.js → admin-price-format-CqOmHrIn.js} +2 -2
  95. package/dist/{admin-price-format-BVUpDoSC.js.map → admin-price-format-CqOmHrIn.js.map} +1 -1
  96. package/dist/{admin-price-wizard-CBEcNGvP.js → admin-price-wizard-B6s5OJeO.js} +63 -63
  97. package/dist/{admin-price-wizard-CBEcNGvP.js.map → admin-price-wizard-B6s5OJeO.js.map} +1 -1
  98. package/dist/{admin-proposals-Cuj7tvaM.js → admin-proposals-DVrl-ym4.js} +70 -70
  99. package/dist/{admin-proposals-Cuj7tvaM.js.map → admin-proposals-DVrl-ym4.js.map} +1 -1
  100. package/dist/admin-provider-prices-BVVogH7Q.js +241 -0
  101. package/dist/admin-provider-prices-BVVogH7Q.js.map +1 -0
  102. package/dist/{admin-range-picker-De36L-AP.js → admin-range-picker-C6BtSm2B.js} +9 -9
  103. package/dist/{admin-range-picker-De36L-AP.js.map → admin-range-picker-C6BtSm2B.js.map} +1 -1
  104. package/dist/{admin-records-H0MlhEVY.js → admin-records-DKtcgN11.js} +50 -50
  105. package/dist/{admin-records-H0MlhEVY.js.map → admin-records-DKtcgN11.js.map} +1 -1
  106. package/dist/{admin-reports-BFGS_PWf.js → admin-reports-CtPoiceH.js} +50 -50
  107. package/dist/{admin-reports-BFGS_PWf.js.map → admin-reports-CtPoiceH.js.map} +1 -1
  108. package/dist/{admin-select-BUcEU5Rg.js → admin-select-6Yuh5M1Q.js} +2 -2
  109. package/dist/{admin-select-BUcEU5Rg.js.map → admin-select-6Yuh5M1Q.js.map} +1 -1
  110. package/dist/admin-settings-DscHu4ww.js +1823 -0
  111. package/dist/admin-settings-DscHu4ww.js.map +1 -0
  112. package/dist/{admin-shared-lfIUEbPY.js → admin-shared-BywM-MMp.js} +28 -24
  113. package/dist/{admin-shared-lfIUEbPY.js.map → admin-shared-BywM-MMp.js.map} +1 -1
  114. package/dist/{admin-skeleton-B0yzYY_X.js → admin-skeleton-lndmw89u.js} +2 -2
  115. package/dist/{admin-skeleton-B0yzYY_X.js.map → admin-skeleton-lndmw89u.js.map} +1 -1
  116. package/dist/admin-status-badge-IL8ofZ_6.js +51 -0
  117. package/dist/admin-status-badge-IL8ofZ_6.js.map +1 -0
  118. package/dist/admin-subscriptions-Cd5CGrue.js +271 -0
  119. package/dist/admin-subscriptions-Cd5CGrue.js.map +1 -0
  120. package/dist/{admin-switch-DDorugaw.js → admin-switch-DpwQSzEm.js} +2 -2
  121. package/dist/{admin-switch-DDorugaw.js.map → admin-switch-DpwQSzEm.js.map} +1 -1
  122. package/dist/{admin-table-BU6Tie69.js → admin-table-D-GdGM1m.js} +2 -2
  123. package/dist/{admin-table-BU6Tie69.js.map → admin-table-D-GdGM1m.js.map} +1 -1
  124. package/dist/admin-tabs-B--1flzO.js +158 -0
  125. package/dist/admin-tabs-B--1flzO.js.map +1 -0
  126. package/dist/{admin-textarea-Dc6lnEub.js → admin-textarea-xsp5V9xM.js} +2 -2
  127. package/dist/{admin-textarea-Dc6lnEub.js.map → admin-textarea-xsp5V9xM.js.map} +1 -1
  128. package/dist/admin-tile-grids-CzGpidd9.js +6 -0
  129. package/dist/admin-tile-grids-CzGpidd9.js.map +1 -0
  130. package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js → admin-typed-confirm-dialog-NiEDwX_0.js} +11 -11
  131. package/dist/{admin-typed-confirm-dialog-Bk6XxmPb.js.map → admin-typed-confirm-dialog-NiEDwX_0.js.map} +1 -1
  132. package/dist/{admin-utils-B9eEBNsR.js → admin-utils-wuPUD0uh.js} +341 -283
  133. package/dist/admin-utils-wuPUD0uh.js.map +1 -0
  134. package/dist/admin-widget-viz-kHHVmDEx.js +646 -0
  135. package/dist/admin-widget-viz-kHHVmDEx.js.map +1 -0
  136. package/dist/admin.css +1 -1
  137. package/dist/admin.js +544 -413
  138. package/dist/admin.js.map +1 -1
  139. package/dist/client/generated/routes.d.ts +17 -0
  140. package/dist/client/generated/wire.d.ts +4 -0
  141. package/dist/client/types.d.ts +6 -0
  142. package/dist/{client-BYgnI6_h.js → client-ctrbivyN.js} +3 -2
  143. package/dist/client-ctrbivyN.js.map +1 -0
  144. package/dist/client.js +1 -1
  145. package/dist/{hooks-t2tSrCpa.js → hooks-KpTetx6F.js} +2 -2
  146. package/dist/{hooks-t2tSrCpa.js.map → hooks-KpTetx6F.js.map} +1 -1
  147. package/dist/index.js +750 -711
  148. package/dist/index.js.map +1 -1
  149. package/dist/lib/card-brands.d.ts +1 -0
  150. package/dist/locales/de.js +3 -0
  151. package/dist/locales/de.js.map +1 -1
  152. package/dist/locales/en.d.ts +3 -0
  153. package/dist/locales/en.js +3 -0
  154. package/dist/locales/en.js.map +1 -1
  155. package/dist/locales/es.js +3 -0
  156. package/dist/locales/es.js.map +1 -1
  157. package/dist/locales/ja.js +3 -0
  158. package/dist/locales/ja.js.map +1 -1
  159. package/dist/locales/ko.js +3 -0
  160. package/dist/locales/ko.js.map +1 -1
  161. package/dist/locales/zh.js +3 -0
  162. package/dist/locales/zh.js.map +1 -1
  163. package/dist/react.js +1 -1
  164. package/dist/styles.css +1 -1
  165. package/package.json +1 -1
  166. package/dist/admin-attempts-DyDDt-qw.js +0 -418
  167. package/dist/admin-attempts-DyDDt-qw.js.map +0 -1
  168. package/dist/admin-capabilities-BDcZeHL_.js.map +0 -1
  169. package/dist/admin-dashboard-CJE63yz4.js +0 -420
  170. package/dist/admin-dashboard-CJE63yz4.js.map +0 -1
  171. package/dist/admin-data-table-hvFcJepL.js +0 -96
  172. package/dist/admin-data-table-hvFcJepL.js.map +0 -1
  173. package/dist/admin-detail-BRP6pL7t.js +0 -328
  174. package/dist/admin-detail-BRP6pL7t.js.map +0 -1
  175. package/dist/admin-detail-CRzFb_pa.js +0 -1331
  176. package/dist/admin-detail-CRzFb_pa.js.map +0 -1
  177. package/dist/admin-detail-QLxU8r-5.js +0 -344
  178. package/dist/admin-detail-QLxU8r-5.js.map +0 -1
  179. package/dist/admin-detail-pPC8Q9l-.js +0 -710
  180. package/dist/admin-detail-pPC8Q9l-.js.map +0 -1
  181. package/dist/admin-dialog-width-BPrgdYlj.js +0 -6
  182. package/dist/admin-dialog-width-BPrgdYlj.js.map +0 -1
  183. package/dist/admin-format-DoohJ7Fg.js +0 -136
  184. package/dist/admin-format-DoohJ7Fg.js.map +0 -1
  185. package/dist/admin-health-D0L5Kig7.js.map +0 -1
  186. package/dist/admin-ops-CQP4TzWM.js +0 -235
  187. package/dist/admin-ops-CQP4TzWM.js.map +0 -1
  188. package/dist/admin-orders-BJ7W5S8P.js +0 -192
  189. package/dist/admin-orders-BJ7W5S8P.js.map +0 -1
  190. package/dist/admin-parked-B8xHkV2e.js +0 -193
  191. package/dist/admin-parked-B8xHkV2e.js.map +0 -1
  192. package/dist/admin-payments-CzkzqYA1.js +0 -246
  193. package/dist/admin-payments-CzkzqYA1.js.map +0 -1
  194. package/dist/admin-provider-prices-B6vwnVPi.js +0 -246
  195. package/dist/admin-provider-prices-B6vwnVPi.js.map +0 -1
  196. package/dist/admin-settings-DYC-c7mJ.js +0 -1813
  197. package/dist/admin-settings-DYC-c7mJ.js.map +0 -1
  198. package/dist/admin-status-badge-0-K37EfN.js +0 -43
  199. package/dist/admin-status-badge-0-K37EfN.js.map +0 -1
  200. package/dist/admin-subscriptions-CvW-YFs0.js +0 -301
  201. package/dist/admin-subscriptions-CvW-YFs0.js.map +0 -1
  202. package/dist/admin-tabs-D5lqdVcC.js +0 -46
  203. package/dist/admin-tabs-D5lqdVcC.js.map +0 -1
  204. package/dist/admin-utils-B9eEBNsR.js.map +0 -1
  205. package/dist/admin-widget-viz-8aukE3v_.js +0 -581
  206. package/dist/admin-widget-viz-8aukE3v_.js.map +0 -1
  207. package/dist/client-BYgnI6_h.js.map +0 -1
@@ -1,1813 +0,0 @@
1
- import { C as e, D as t, T as n, f as r, l as i, p as a } from "./admin-utils-B9eEBNsR.js";
2
- import { t as o } from "./admin-button-CrcYk5r0.js";
3
- import { t as s } from "./admin-input-DJAK9nmk.js";
4
- import { a as c, i as l, l as u, n as d, u as f } from "./admin-capabilities-BDcZeHL_.js";
5
- import { n as p, o as m, s as h, t as g } from "./admin-format-DoohJ7Fg.js";
6
- import { n as _ } from "./admin-confirm-katGq0Qo.js";
7
- import { t as v } from "./admin-form-field-errors-hbUMIriS.js";
8
- import { a as y, i as b, n as x, r as S, t as C } from "./admin-select-BUcEU5Rg.js";
9
- import { a as w, n as ee, o as te, r as T, s as E, t as ne } from "./admin-table-BU6Tie69.js";
10
- import { t as D } from "./admin-badge-pgG6D9-a.js";
11
- import { a as O, i as k, n as A, o as j, r as M, s as N, t as P } from "./admin-dialog-BSRf9Zre.js";
12
- import { t as F } from "./admin-label-aviN9Gng.js";
13
- import { t as re } from "./admin-switch-DDorugaw.js";
14
- import { n as I } from "./admin-dialog-width-BPrgdYlj.js";
15
- import { t as ie } from "./admin-typed-confirm-dialog-Bk6XxmPb.js";
16
- import { i as L, n as R, r as ae, t as oe } from "./admin-tabs-D5lqdVcC.js";
17
- import * as z from "react";
18
- import { useMutation as B, useQuery as V, useQueryClient as H } from "@tanstack/react-query";
19
- import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
20
- import { HugeiconsIcon as se } from "@hugeicons/react";
21
- import { Add01Icon as ce, Delete02Icon as le } from "@hugeicons/core-free-icons";
22
- import { useForm as K } from "@tanstack/react-form";
23
- //#region src/admin/pages/settings/configuration-edit.ts
24
- function q(t) {
25
- let { toast: n, toastApiError: r, toastStaleEdit: i, adminMutations: o } = a(), [s, c] = z.useState(null), l = H(), u = B(o.updateMerchantConfiguration(l));
26
- return {
27
- editing: s !== null,
28
- open: () => {
29
- t && c(t.revision);
30
- },
31
- close: () => c(null),
32
- save: async (t, a, o) => {
33
- if (s !== null) try {
34
- await u.mutateAsync({
35
- ...t,
36
- expected_revision: s
37
- }), n.success(a), c(null);
38
- } catch (t) {
39
- if (t instanceof e && t.revisionMismatch) {
40
- i("The configuration"), c(null);
41
- return;
42
- }
43
- r(t, o), t instanceof e && t.merchantConfigReadOnly && c(null);
44
- }
45
- }
46
- };
47
- }
48
- //#endregion
49
- //#region src/admin/pages/settings/setting-fields.tsx
50
- function J() {
51
- let { adminQueries: e } = a(), { data: t } = V(e.config());
52
- return !t || t.capabilities.features?.merchant_config_edits ? null : /* @__PURE__ */ W("p", {
53
- className: "rounded-md border px-3 py-2 text-sm text-muted-foreground",
54
- children: /* @__PURE__ */ W(n, { id: "Read-only: this merchant's configuration comes from a file. Change it there." })
55
- });
56
- }
57
- function Y({ edits: e, editing: t, form: r, saving: i, canSave: a = !0, onEdit: s, onCancel: c }) {
58
- return e ? t ? /* @__PURE__ */ G("div", {
59
- className: "flex items-center gap-2",
60
- children: [/* @__PURE__ */ W(o, {
61
- type: "button",
62
- variant: "outline",
63
- size: "sm",
64
- disabled: i,
65
- onClick: c,
66
- children: /* @__PURE__ */ W(n, { id: "Cancel" })
67
- }), /* @__PURE__ */ W(o, {
68
- type: "submit",
69
- size: "sm",
70
- form: r,
71
- disabled: !a || i,
72
- children: i ? "Saving…" : "Save"
73
- })]
74
- }) : /* @__PURE__ */ W(o, {
75
- type: "button",
76
- variant: "outline",
77
- size: "sm",
78
- onClick: s,
79
- children: /* @__PURE__ */ W(n, { id: "Edit" })
80
- }) : null;
81
- }
82
- function X({ label: e, value: t }) {
83
- return /* @__PURE__ */ G("div", {
84
- className: "grid gap-1.5 md:grid-cols-[11rem_minmax(0,1fr)] md:gap-6",
85
- children: [/* @__PURE__ */ W("dt", {
86
- className: "text-sm text-muted-foreground",
87
- children: e
88
- }), /* @__PURE__ */ W("dd", {
89
- className: t ? "min-w-0 text-sm break-words" : "text-sm text-muted-foreground",
90
- children: t || "Not set"
91
- })]
92
- });
93
- }
94
- function Z({ label: e, id: n, children: r }) {
95
- let { id: i } = t();
96
- return /* @__PURE__ */ G("div", {
97
- className: "grid gap-2 md:grid-cols-[11rem_minmax(0,1fr)] md:items-center md:gap-6",
98
- children: [/* @__PURE__ */ W(F, {
99
- htmlFor: i(n),
100
- children: e
101
- }), /* @__PURE__ */ W("div", {
102
- className: "min-w-0",
103
- children: r
104
- })]
105
- });
106
- }
107
- //#endregion
108
- //#region src/admin/pages/settings/notifications.tsx
109
- function ue() {
110
- let { adminQueries: e } = a(), t = V(e.merchantConfiguration("Load settings")), r = V(e.webhooks()), i = f(), o = r.data?.data ?? [];
111
- return /* @__PURE__ */ G("div", {
112
- className: "flex flex-col gap-10",
113
- children: [
114
- /* @__PURE__ */ W(J, {}),
115
- t.data ? /* @__PURE__ */ W(de, {
116
- configuration: t.data,
117
- edits: i
118
- }) : /* @__PURE__ */ W("p", {
119
- className: "text-sm text-muted-foreground",
120
- children: /* @__PURE__ */ W(n, { id: "Loading…" })
121
- }),
122
- /* @__PURE__ */ W(pe, {
123
- webhooks: o,
124
- loading: r.isPending,
125
- edits: i
126
- })
127
- ]
128
- });
129
- }
130
- function de({ configuration: e, edits: r }) {
131
- let { id: i, text: a } = t(), o = e.alert_email ?? "", c = q(e), l = K({
132
- defaultValues: { email: o },
133
- onSubmit: ({ value: e }) => c.save({ alert_email: e.email.trim() }, e.email.trim() ? "Alert email saved" : "Alert email cleared", "Save alert email")
134
- });
135
- return /* @__PURE__ */ G("section", {
136
- className: "grid gap-5",
137
- children: [/* @__PURE__ */ G("div", {
138
- className: "flex flex-wrap items-start justify-between gap-4",
139
- children: [/* @__PURE__ */ G("div", {
140
- className: "grid gap-1",
141
- children: [/* @__PURE__ */ W("h2", {
142
- className: "text-base font-semibold",
143
- children: /* @__PURE__ */ W(n, { id: "Email delivery" })
144
- }), /* @__PURE__ */ W("p", {
145
- className: "text-sm text-muted-foreground",
146
- children: /* @__PURE__ */ W(n, { id: "Send email alerts to this address." })
147
- })]
148
- }), /* @__PURE__ */ W(l.Subscribe, {
149
- selector: (e) => e.isSubmitting,
150
- children: (e) => /* @__PURE__ */ W(Y, {
151
- edits: r,
152
- editing: c.editing,
153
- form: "alert-email-form",
154
- saving: e,
155
- onEdit: () => {
156
- l.reset({ email: o }), c.open();
157
- },
158
- onCancel: c.close
159
- })
160
- })]
161
- }), c.editing ? /* @__PURE__ */ W("form", {
162
- id: i("alert-email-form"),
163
- onSubmit: (e) => {
164
- e.preventDefault(), e.stopPropagation(), l.handleSubmit();
165
- },
166
- children: /* @__PURE__ */ W(l.Field, {
167
- name: "email",
168
- children: (e) => /* @__PURE__ */ W(Z, {
169
- label: a("Alert email"),
170
- id: "alert-email",
171
- children: /* @__PURE__ */ W(s, {
172
- id: i("alert-email"),
173
- type: "email",
174
- placeholder: a("alerts@example.com"),
175
- value: e.state.value,
176
- onBlur: e.handleBlur,
177
- onChange: (t) => e.handleChange(t.target.value)
178
- })
179
- })
180
- })
181
- }) : /* @__PURE__ */ W("dl", { children: /* @__PURE__ */ W(X, {
182
- label: a("Alert email"),
183
- value: o
184
- }) })]
185
- });
186
- }
187
- var fe = [
188
- {
189
- value: "generic",
190
- label: "Generic (your own receiver)"
191
- },
192
- {
193
- value: "discord",
194
- label: "Discord"
195
- },
196
- {
197
- value: "slack",
198
- label: "Slack"
199
- }
200
- ];
201
- function pe({ webhooks: e, loading: t, edits: r }) {
202
- return /* @__PURE__ */ G("section", {
203
- className: "grid gap-5",
204
- children: [/* @__PURE__ */ G("div", {
205
- className: "flex flex-wrap items-start justify-between gap-4",
206
- children: [/* @__PURE__ */ G("div", {
207
- className: "grid max-w-2xl gap-1",
208
- children: [/* @__PURE__ */ W("h2", {
209
- className: "text-base font-semibold",
210
- children: /* @__PURE__ */ W(n, { id: "Webhooks" })
211
- }), /* @__PURE__ */ W("p", {
212
- className: "text-sm text-pretty text-muted-foreground",
213
- children: /* @__PURE__ */ W(n, { id: "Send alerts to Discord, Slack, or your own endpoint." })
214
- })]
215
- }), r && /* @__PURE__ */ W(he, {})]
216
- }), t ? /* @__PURE__ */ W("p", {
217
- className: "text-sm text-muted-foreground",
218
- children: /* @__PURE__ */ W(n, { id: "Loading…" })
219
- }) : e.length === 0 ? /* @__PURE__ */ W("p", {
220
- className: "py-2 text-sm text-muted-foreground",
221
- children: /* @__PURE__ */ W(n, { id: "No webhooks configured." })
222
- }) : /* @__PURE__ */ G(ne, {
223
- className: "min-w-[36rem]",
224
- children: [/* @__PURE__ */ W(te, { children: /* @__PURE__ */ G(E, {
225
- className: "hover:bg-transparent",
226
- children: [
227
- /* @__PURE__ */ W(w, {
228
- className: "text-muted-foreground",
229
- children: /* @__PURE__ */ W(n, { id: "Name" })
230
- }),
231
- /* @__PURE__ */ W(w, {
232
- className: "text-muted-foreground",
233
- children: /* @__PURE__ */ W(n, { id: "Format" })
234
- }),
235
- /* @__PURE__ */ W(w, {
236
- className: "text-muted-foreground",
237
- children: "URL"
238
- }),
239
- r && /* @__PURE__ */ W(w, {
240
- className: "text-right text-muted-foreground",
241
- children: /* @__PURE__ */ W(n, { id: "Action" })
242
- })
243
- ]
244
- }) }), /* @__PURE__ */ W(ee, { children: e.map((e) => /* @__PURE__ */ W(me, {
245
- webhook: e,
246
- edits: r
247
- }, e.id)) })]
248
- })]
249
- });
250
- }
251
- function me({ webhook: e, edits: r }) {
252
- let { toast: i, toastApiError: s, adminMutations: c } = a(), { text: l } = t(), [u, d] = z.useState(!1), f = H(), p = B(c.deleteWebhook(f)), m = e.name ?? e.destination_host;
253
- return /* @__PURE__ */ G(E, {
254
- className: e.enabled ? void 0 : "opacity-60",
255
- children: [
256
- /* @__PURE__ */ W(T, {
257
- className: "py-3 font-medium",
258
- children: m
259
- }),
260
- /* @__PURE__ */ W(T, {
261
- className: "py-3",
262
- children: /* @__PURE__ */ G("span", {
263
- className: "flex flex-wrap gap-1",
264
- children: [/* @__PURE__ */ W(D, {
265
- variant: "secondary",
266
- children: e.format
267
- }), !e.enabled && /* @__PURE__ */ W(D, {
268
- variant: "outline",
269
- children: /* @__PURE__ */ W(n, { id: "disabled" })
270
- })]
271
- })
272
- }),
273
- /* @__PURE__ */ W(T, {
274
- className: "max-w-[22rem] truncate py-3 text-xs text-muted-foreground",
275
- title: e.destination_host,
276
- children: e.destination_host
277
- }),
278
- r && /* @__PURE__ */ W(T, {
279
- className: "py-3 text-right",
280
- children: /* @__PURE__ */ G("div", {
281
- className: "flex justify-end gap-1",
282
- children: [
283
- /* @__PURE__ */ W(he, { webhook: e }),
284
- /* @__PURE__ */ W(o, {
285
- variant: "ghost",
286
- size: "icon",
287
- "aria-label": l("Delete webhook"),
288
- onClick: () => d(!0),
289
- children: /* @__PURE__ */ W(se, {
290
- icon: le,
291
- className: "size-4 text-muted-foreground"
292
- })
293
- }),
294
- /* @__PURE__ */ W(ie, {
295
- open: u,
296
- onOpenChange: d,
297
- title: `Delete "${m}"?`,
298
- description: l("Operational notifications will stop delivering to this webhook. This cannot be undone."),
299
- confirmationWord: "DELETE",
300
- actionLabel: "Delete webhook",
301
- onConfirm: async () => {
302
- try {
303
- await p.mutateAsync(e.id), i.success("Webhook deleted");
304
- } catch (e) {
305
- s(e, "Delete webhook");
306
- }
307
- }
308
- })
309
- ]
310
- })
311
- })
312
- ]
313
- });
314
- }
315
- function he({ webhook: e }) {
316
- let { toast: r, toastApiError: i, adminMutations: c } = a(), { id: l, text: u } = t(), [d, f] = z.useState(!1), p = H(), m = B(c.createWebhook(p)), h = B(c.updateWebhook(p)), g = () => ({
317
- name: e?.name ?? "",
318
- url: "",
319
- format: e?.format ?? "generic",
320
- enabled: e?.enabled ?? !0
321
- }), _ = K({
322
- defaultValues: g(),
323
- onSubmit: async ({ value: t }) => {
324
- let n = t.url.trim();
325
- try {
326
- e ? await h.mutateAsync({
327
- id: e.id,
328
- webhook: {
329
- name: t.name.trim() || null,
330
- format: t.format,
331
- enabled: t.enabled,
332
- ...n ? { url: n } : {}
333
- }
334
- }) : await m.mutateAsync({
335
- name: t.name.trim(),
336
- url: n,
337
- format: t.format
338
- }), r.success(e ? "Webhook saved" : "Webhook added"), w(!1);
339
- } catch (t) {
340
- i(t, e ? "Save webhook" : "Add webhook");
341
- }
342
- }
343
- }), w = (e) => {
344
- e ? _.reset(g()) : _.reset(), f(e);
345
- };
346
- return /* @__PURE__ */ G(P, {
347
- open: d,
348
- onOpenChange: w,
349
- children: [/* @__PURE__ */ W(N, { render: /* @__PURE__ */ G(o, {
350
- size: "sm",
351
- variant: "outline",
352
- children: [
353
- !e && /* @__PURE__ */ W(se, {
354
- icon: ce,
355
- className: "size-4"
356
- }),
357
- " ",
358
- e ? "Edit" : "Add webhook"
359
- ]
360
- }) }), /* @__PURE__ */ G(A, {
361
- className: I,
362
- children: [/* @__PURE__ */ G(O, { children: [/* @__PURE__ */ W(j, { children: e ? `Edit ${e.name ?? e.destination_host}` : "Add webhook" }), /* @__PURE__ */ W(M, { children: e ? "The current URL is never shown. Paste a new one to replace it, or leave it blank to keep it." : "Paste a webhook address from Discord, Slack, or your own alert receiver." })] }), /* @__PURE__ */ G("form", {
363
- onSubmit: (e) => {
364
- e.preventDefault(), e.stopPropagation(), _.handleSubmit();
365
- },
366
- className: "grid gap-4",
367
- children: [/* @__PURE__ */ G("div", {
368
- className: "grid gap-3",
369
- children: [
370
- /* @__PURE__ */ W(_.Field, {
371
- name: "name",
372
- validators: { onChange: ({ value: t }) => e || t.trim() ? void 0 : "Enter a webhook name" },
373
- children: (e) => /* @__PURE__ */ G("div", {
374
- className: "grid gap-1.5",
375
- children: [
376
- /* @__PURE__ */ W(F, {
377
- htmlFor: l("wh-name"),
378
- children: /* @__PURE__ */ W(n, { id: "Name" })
379
- }),
380
- /* @__PURE__ */ W(s, {
381
- id: l("wh-name"),
382
- placeholder: u("e.g. #billing-alerts"),
383
- value: e.state.value,
384
- onBlur: e.handleBlur,
385
- onChange: (t) => e.handleChange(t.target.value),
386
- "aria-invalid": e.state.meta.errors.length > 0
387
- }),
388
- /* @__PURE__ */ W(v, { errors: e.state.meta.errors })
389
- ]
390
- })
391
- }),
392
- /* @__PURE__ */ W(_.Field, {
393
- name: "format",
394
- children: (e) => /* @__PURE__ */ G("div", {
395
- className: "grid gap-1.5",
396
- children: [/* @__PURE__ */ W(F, {
397
- htmlFor: l("wh-format"),
398
- children: /* @__PURE__ */ W(n, { id: "Format" })
399
- }), /* @__PURE__ */ G(C, {
400
- value: e.state.value,
401
- onValueChange: (t) => e.handleChange(t),
402
- children: [/* @__PURE__ */ W(b, {
403
- id: l("wh-format"),
404
- className: "w-full",
405
- children: /* @__PURE__ */ W(y, {})
406
- }), /* @__PURE__ */ W(x, { children: fe.map((e) => /* @__PURE__ */ W(S, {
407
- value: e.value,
408
- children: e.label
409
- }, e.value)) })]
410
- })]
411
- })
412
- }),
413
- /* @__PURE__ */ W(_.Field, {
414
- name: "url",
415
- validators: { onChange: ({ value: t }) => {
416
- if (!t.trim()) return e ? void 0 : "Enter a webhook URL";
417
- try {
418
- new URL(t);
419
- return;
420
- } catch {
421
- return "Enter a valid webhook URL";
422
- }
423
- } },
424
- children: (t) => /* @__PURE__ */ G("div", {
425
- className: "grid gap-1.5",
426
- children: [
427
- /* @__PURE__ */ W(F, {
428
- htmlFor: l("wh-url"),
429
- children: /* @__PURE__ */ W(n, { id: "Webhook URL" })
430
- }),
431
- /* @__PURE__ */ W(s, {
432
- id: l("wh-url"),
433
- type: "url",
434
- autoComplete: "off",
435
- className: "text-xs",
436
- placeholder: e ? "unchanged" : "https://discord.com/api/webhooks/…",
437
- value: t.state.value,
438
- onBlur: t.handleBlur,
439
- onChange: (e) => t.handleChange(e.target.value),
440
- "aria-invalid": t.state.meta.errors.length > 0
441
- }),
442
- /* @__PURE__ */ W(v, { errors: t.state.meta.errors })
443
- ]
444
- })
445
- }),
446
- e && /* @__PURE__ */ W(_.Field, {
447
- name: "enabled",
448
- children: (e) => /* @__PURE__ */ G("div", {
449
- className: "flex items-center gap-2",
450
- children: [/* @__PURE__ */ W(re, {
451
- id: l("wh-enabled"),
452
- checked: e.state.value,
453
- onCheckedChange: e.handleChange
454
- }), /* @__PURE__ */ W(F, {
455
- htmlFor: l("wh-enabled"),
456
- children: /* @__PURE__ */ W(n, { id: "Enabled" })
457
- })]
458
- })
459
- })
460
- ]
461
- }), /* @__PURE__ */ W(k, { children: /* @__PURE__ */ W(_.Subscribe, {
462
- selector: (e) => [
463
- e.values.name,
464
- e.values.url,
465
- e.isDirty,
466
- e.canSubmit,
467
- e.isSubmitting
468
- ],
469
- children: ([t, n, r, i, a]) => /* @__PURE__ */ W(o, {
470
- type: "submit",
471
- disabled: (e ? !r : !t.trim() || !n.trim()) || !i || a,
472
- children: a ? "Saving…" : e ? "Save" : "Add webhook"
473
- })
474
- }) })]
475
- })]
476
- })]
477
- });
478
- }
479
- //#endregion
480
- //#region src/admin/pages/settings/custody.tsx
481
- function ge() {
482
- let e = a(), t = H(), n = f(), r = V(e.adminQueries.merchantConfiguration()), i = V(e.adminQueries.psps()), s = [...e.queryKeys.settings(), "custodians"], c = V({
483
- queryKey: s,
484
- queryFn: ({ signal: t }) => e.listCustodians(t)
485
- }), [l, u] = z.useState(null), [d] = z.useState(() => e.selectedMerchant()), p = () => t.invalidateQueries({ queryKey: e.queryKeys.settings() }), m = B({
486
- mutationFn: async ({ psp: t, custody: n }) => {
487
- if (d !== e.selectedMerchant()) throw Error("Merchant changed; reopen settings");
488
- let r = i.data?.data.find((e) => e.id === t);
489
- if (!r) throw Error("PSP is no longer available");
490
- return e.updatePSP(t, {
491
- expected_revision: r.revision,
492
- custodian: n
493
- });
494
- },
495
- onSuccess: p,
496
- onError: (t) => e.toastApiError(t, "Change card custody")
497
- }), h = B({
498
- mutationFn: async (t) => {
499
- if (!r.data || d !== e.selectedMerchant()) throw Error("Merchant changed; reopen settings");
500
- return e.updateMerchantConfiguration({
501
- expected_revision: r.data.revision,
502
- card_vault: String(t.get("card_vault") ?? ""),
503
- charge_psps: t.getAll("charge_psps").map(String)
504
- });
505
- },
506
- onSuccess: p,
507
- onError: (t) => e.toastApiError(t, "Save card routing")
508
- });
509
- if (!r.data || !i.data || !c.data) return null;
510
- let g = i.data.data.filter((e) => !e.archived && (e.rail === "nmi" || e.rail === "stripe"));
511
- return /* @__PURE__ */ G("section", {
512
- className: "grid gap-5",
513
- "aria-label": "Card vaults",
514
- children: [
515
- /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ W("h2", {
516
- className: "text-base font-semibold",
517
- children: "Card vaults"
518
- }), /* @__PURE__ */ W("p", {
519
- className: "text-sm text-muted-foreground",
520
- children: "Choose where new cards are stored and which accounts charge them. Existing cards and subscriptions keep their accepted custody."
521
- })] }),
522
- /* @__PURE__ */ W("ul", {
523
- className: "grid gap-2",
524
- children: c.data.data.map((e) => /* @__PURE__ */ G("li", {
525
- className: "flex flex-wrap items-center justify-between gap-3 rounded border p-3",
526
- children: [/* @__PURE__ */ G("div", { children: [
527
- /* @__PURE__ */ W("strong", { children: e.key }),
528
- " · Basis Theory · ",
529
- e.environment,
530
- /* @__PURE__ */ W("br", {}),
531
- /* @__PURE__ */ G("span", {
532
- className: "text-sm text-muted-foreground",
533
- children: [
534
- e.account_id,
535
- " ·",
536
- " ",
537
- e.credentials?.api_key?.configured ? "Credential configured" : "Credential missing"
538
- ]
539
- })
540
- ] }), n && !e.archived && /* @__PURE__ */ W(o, {
541
- size: "sm",
542
- variant: "outline",
543
- onClick: () => u(e),
544
- children: "Edit vault"
545
- })]
546
- }, e.key))
547
- }),
548
- n && /* @__PURE__ */ W(o, {
549
- className: "justify-self-start",
550
- variant: "outline",
551
- onClick: () => u("new"),
552
- children: "Add Basis Theory vault"
553
- }),
554
- l && /* @__PURE__ */ W(_e, {
555
- current: l === "new" ? void 0 : l,
556
- close: () => u(null),
557
- saved: p
558
- }, l === "new" ? "new" : `${l.key}:${l.revision}`),
559
- g.filter((e) => e.rail === "nmi").map((e) => /* @__PURE__ */ G(F, {
560
- className: "grid gap-2",
561
- children: [
562
- e.key,
563
- ": card storage",
564
- /* @__PURE__ */ G("select", {
565
- className: "rounded border bg-background p-2",
566
- "aria-label": `${e.key} card storage`,
567
- disabled: !n || m.isPending,
568
- value: e.custodian ?? "",
569
- onChange: (t) => m.mutate({
570
- psp: e.id,
571
- custody: t.target.value
572
- }),
573
- children: [/* @__PURE__ */ W("option", {
574
- value: "",
575
- children: "NMI customer vault"
576
- }), c.data.data.filter((t) => !t.archived && t.environment === e.environment).map((e) => /* @__PURE__ */ G("option", {
577
- value: e.key,
578
- children: [e.key, " · Basis Theory"]
579
- }, e.key))]
580
- })
581
- ]
582
- }, e.id)),
583
- /* @__PURE__ */ G("form", {
584
- className: "grid gap-3",
585
- onSubmit: (e) => {
586
- e.preventDefault(), h.mutate(new FormData(e.currentTarget));
587
- },
588
- children: [
589
- /* @__PURE__ */ G(F, {
590
- className: "grid gap-2",
591
- children: ["Vault for new cards", /* @__PURE__ */ G("select", {
592
- name: "card_vault",
593
- className: "rounded border bg-background p-2",
594
- defaultValue: r.data.card_vault ?? "",
595
- disabled: !n,
596
- children: [
597
- /* @__PURE__ */ W("option", {
598
- value: "",
599
- children: "No card vault selected"
600
- }),
601
- r.data.platform_vault.available && /* @__PURE__ */ W("option", {
602
- value: "platform",
603
- children: "Hosted vault · isolated to this merchant"
604
- }),
605
- g.map((e) => /* @__PURE__ */ G("option", {
606
- value: e.key,
607
- children: [
608
- e.key,
609
- " ·",
610
- " ",
611
- e.custodian ? "Basis Theory" : e.rail === "stripe" ? "Stripe" : "NMI customer vault"
612
- ]
613
- }, e.id))
614
- ]
615
- })]
616
- }),
617
- /* @__PURE__ */ G("fieldset", {
618
- className: "grid gap-2",
619
- disabled: !n,
620
- children: [
621
- /* @__PURE__ */ W("legend", {
622
- className: "mb-2 font-medium",
623
- children: "Charge PSPs"
624
- }),
625
- /* @__PURE__ */ W("p", {
626
- className: "text-sm text-muted-foreground",
627
- children: "Select the accounts allowed for new charges. With none selected, routing considers all eligible accounts."
628
- }),
629
- g.map((e) => /* @__PURE__ */ G(F, {
630
- className: "flex gap-2",
631
- children: [/* @__PURE__ */ W("input", {
632
- type: "checkbox",
633
- name: "charge_psps",
634
- value: e.key,
635
- defaultChecked: r.data?.charge_psps?.includes(e.key) ?? !1
636
- }), e.key]
637
- }, e.id))
638
- ]
639
- }),
640
- n && /* @__PURE__ */ W(o, {
641
- className: "justify-self-start",
642
- disabled: h.isPending,
643
- type: "submit",
644
- children: "Save card routing"
645
- })
646
- ]
647
- }, `routing:${r.data.revision}`)
648
- ]
649
- });
650
- }
651
- function _e({ current: e, close: t, saved: n }) {
652
- let r = a(), [i] = z.useState(() => r.selectedMerchant()), c = B({
653
- mutationFn: async (t) => {
654
- if (i !== r.selectedMerchant()) throw Error("Merchant changed; reopen this form");
655
- let n = String(t.get("private_key") ?? "").trim();
656
- return r.putCustodian(e?.key ?? String(t.get("key") ?? "").trim(), {
657
- expected_revision: e?.revision ?? 0,
658
- kind: "basis_theory",
659
- environment: e?.environment ?? String(t.get("environment") ?? "test"),
660
- account_id: e?.account_id ?? String(t.get("account_id") ?? "").trim(),
661
- settings: {
662
- ...e?.settings ?? {},
663
- public_api_key: String(t.get("public_key") ?? "").trim()
664
- },
665
- ...n ? { credentials: { api_key: n } } : {}
666
- });
667
- },
668
- onSuccess: async () => {
669
- await n(), t();
670
- },
671
- onError: (e) => r.toastApiError(e, "Configure vault")
672
- });
673
- return /* @__PURE__ */ G("form", {
674
- className: "grid gap-3 rounded border p-4",
675
- onSubmit: (e) => {
676
- e.preventDefault(), c.mutate(new FormData(e.currentTarget));
677
- },
678
- children: [
679
- /* @__PURE__ */ W("h3", {
680
- className: "font-medium",
681
- children: e ? `Edit ${e.key}` : "Add Basis Theory vault"
682
- }),
683
- !e && /* @__PURE__ */ G(U, { children: [
684
- /* @__PURE__ */ G(F, {
685
- className: "grid gap-1",
686
- children: ["Vault key", /* @__PURE__ */ W(s, {
687
- name: "key",
688
- required: !0,
689
- pattern: "[a-z0-9_-]{1,63}"
690
- })]
691
- }),
692
- /* @__PURE__ */ G(F, {
693
- className: "grid gap-1",
694
- children: ["Environment", /* @__PURE__ */ G("select", {
695
- name: "environment",
696
- className: "rounded border bg-background p-2",
697
- children: [/* @__PURE__ */ W("option", {
698
- value: "test",
699
- children: "Test"
700
- }), /* @__PURE__ */ W("option", {
701
- value: "live",
702
- children: "Live"
703
- })]
704
- })]
705
- }),
706
- /* @__PURE__ */ G(F, {
707
- className: "grid gap-1",
708
- children: ["Basis Theory tenant ID", /* @__PURE__ */ W(s, {
709
- name: "account_id",
710
- required: !0
711
- })]
712
- })
713
- ] }),
714
- /* @__PURE__ */ G(F, {
715
- className: "grid gap-1",
716
- children: ["Public collection key", /* @__PURE__ */ W(s, {
717
- name: "public_key",
718
- required: !0,
719
- defaultValue: String(e?.settings?.public_api_key ?? "")
720
- })]
721
- }),
722
- /* @__PURE__ */ G(F, {
723
- className: "grid gap-1",
724
- children: ["Private API key", /* @__PURE__ */ W(s, {
725
- type: "password",
726
- name: "private_key",
727
- autoComplete: "new-password",
728
- required: !e
729
- })]
730
- }),
731
- /* @__PURE__ */ W("p", {
732
- className: "text-sm text-muted-foreground",
733
- children: "Use a key that can read its application, manage the merchant’s card tokens and invoke the proxy. Existing credentials stay unchanged when left blank."
734
- }),
735
- /* @__PURE__ */ G("div", {
736
- className: "flex gap-2",
737
- children: [/* @__PURE__ */ W(o, {
738
- type: "submit",
739
- disabled: c.isPending,
740
- children: "Validate and save vault"
741
- }), /* @__PURE__ */ W(o, {
742
- type: "button",
743
- variant: "outline",
744
- onClick: t,
745
- children: "Cancel"
746
- })]
747
- })
748
- ]
749
- });
750
- }
751
- //#endregion
752
- //#region src/admin/pages/settings/index.tsx
753
- var Q = "flex-none px-0 after:bg-primary group-data-horizontal/tabs:after:bottom-[-1px]";
754
- function ve() {
755
- let [e, t] = i(), a = u(), o = l(), s = r().props.settingsTabs ?? [], c = s.map((e) => e.value), f = d(null, a, o, c), p = d(e.get("tab"), a, o, c);
756
- return /* @__PURE__ */ G(oe, {
757
- value: p,
758
- onValueChange: (n) => {
759
- let r = new URLSearchParams(e);
760
- !n || n === f ? r.delete("tab") : r.set("tab", n), t(r);
761
- },
762
- className: "flex flex-col gap-4",
763
- children: [
764
- /* @__PURE__ */ W("div", {
765
- className: "overflow-x-auto",
766
- children: /* @__PURE__ */ G(ae, {
767
- variant: "line",
768
- className: "w-max min-w-full justify-start gap-6 rounded-none p-0",
769
- children: [
770
- a && /* @__PURE__ */ W(L, {
771
- value: "merchant",
772
- className: Q,
773
- children: /* @__PURE__ */ W(n, { id: "Merchant" })
774
- }),
775
- a && /* @__PURE__ */ W(L, {
776
- value: "notifications",
777
- className: Q,
778
- children: /* @__PURE__ */ W(n, { id: "Notifications" })
779
- }),
780
- a && /* @__PURE__ */ W(L, {
781
- value: "psps",
782
- className: Q,
783
- children: /* @__PURE__ */ W(n, { id: "PSPs" })
784
- }),
785
- o && /* @__PURE__ */ W(L, {
786
- value: "customer-controls",
787
- className: Q,
788
- children: /* @__PURE__ */ W(n, { id: "Customer controls" })
789
- }),
790
- s.map((e) => /* @__PURE__ */ W(L, {
791
- value: e.value,
792
- className: Q,
793
- children: e.title
794
- }, e.value))
795
- ]
796
- })
797
- }),
798
- a && /* @__PURE__ */ W(R, {
799
- value: "merchant",
800
- children: /* @__PURE__ */ W(ye, {})
801
- }),
802
- a && /* @__PURE__ */ W(R, {
803
- value: "notifications",
804
- children: /* @__PURE__ */ W(ue, {})
805
- }),
806
- a && /* @__PURE__ */ W(R, {
807
- value: "psps",
808
- children: /* @__PURE__ */ W(Se, {})
809
- }),
810
- o && /* @__PURE__ */ W(R, {
811
- value: "customer-controls",
812
- children: /* @__PURE__ */ W(Pe, {})
813
- }),
814
- s.map((e) => /* @__PURE__ */ W(R, {
815
- value: e.value,
816
- children: e.element
817
- }, e.value))
818
- ]
819
- });
820
- }
821
- function ye() {
822
- let { adminQueries: e } = a(), { data: t } = V(e.merchantConfiguration("Load settings")), r = f();
823
- return t ? /* @__PURE__ */ G("div", {
824
- className: "grid gap-10",
825
- children: [
826
- /* @__PURE__ */ W(J, {}),
827
- /* @__PURE__ */ W(be, {
828
- configuration: t,
829
- edits: r
830
- }),
831
- /* @__PURE__ */ W(xe, {
832
- configuration: t,
833
- edits: r
834
- })
835
- ]
836
- }) : /* @__PURE__ */ W("p", {
837
- className: "text-sm text-muted-foreground",
838
- children: /* @__PURE__ */ W(n, { id: "Loading…" })
839
- });
840
- }
841
- function be({ configuration: e, edits: r }) {
842
- let { id: i, text: a } = t(), o = e.profile, c = () => ({
843
- displayName: e.display_name,
844
- fromEmail: o?.from_email ?? "",
845
- supportURL: o?.support_url ?? "",
846
- subscribeURL: o?.subscribe_url ?? "",
847
- billingURL: o?.billing_url ?? "",
848
- logoURL: o?.logo_url ?? ""
849
- }), l = q(e), u = K({
850
- defaultValues: c(),
851
- onSubmit: ({ value: e }) => l.save({
852
- display_name: e.displayName.trim(),
853
- profile: {
854
- from_email: e.fromEmail || void 0,
855
- support_url: e.supportURL || void 0,
856
- subscribe_url: e.subscribeURL || void 0,
857
- billing_url: e.billingURL || void 0,
858
- logo_url: e.logoURL || void 0
859
- }
860
- }, "Profile saved", "Save profile")
861
- });
862
- return /* @__PURE__ */ G("section", {
863
- className: "grid gap-5",
864
- children: [/* @__PURE__ */ G("div", {
865
- className: "flex flex-wrap items-start justify-between gap-4",
866
- children: [/* @__PURE__ */ G("div", {
867
- className: "grid gap-1",
868
- children: [/* @__PURE__ */ W("h2", {
869
- className: "text-base font-semibold",
870
- children: /* @__PURE__ */ W(n, { id: "Merchant profile" })
871
- }), /* @__PURE__ */ W("p", {
872
- className: "text-sm text-pretty text-muted-foreground",
873
- children: /* @__PURE__ */ W(n, { id: "Customer-facing merchant details used on invoices and emails." })
874
- })]
875
- }), /* @__PURE__ */ W(u.Subscribe, {
876
- selector: (e) => [e.canSubmit, e.isSubmitting],
877
- children: ([e, t]) => /* @__PURE__ */ W(Y, {
878
- edits: r,
879
- editing: l.editing,
880
- form: "merchant-profile-form",
881
- saving: t,
882
- canSave: e,
883
- onEdit: () => {
884
- u.reset(c()), l.open();
885
- },
886
- onCancel: l.close
887
- })
888
- })]
889
- }), l.editing ? /* @__PURE__ */ G("form", {
890
- id: i("merchant-profile-form"),
891
- onSubmit: (e) => {
892
- e.preventDefault(), e.stopPropagation(), u.handleSubmit();
893
- },
894
- className: "grid gap-4",
895
- children: [
896
- /* @__PURE__ */ W(u.Field, {
897
- name: "displayName",
898
- validators: { onChange: ({ value: e }) => e.trim() ? void 0 : "Enter the merchant's name" },
899
- children: (e) => /* @__PURE__ */ W(Z, {
900
- label: a("Display name"),
901
- id: "s-name",
902
- children: /* @__PURE__ */ G("div", {
903
- className: "grid gap-1.5",
904
- children: [/* @__PURE__ */ W(s, {
905
- id: i("s-name"),
906
- value: e.state.value,
907
- onBlur: e.handleBlur,
908
- onChange: (t) => e.handleChange(t.target.value),
909
- autoComplete: "organization",
910
- "aria-invalid": e.state.meta.errors.length > 0
911
- }), /* @__PURE__ */ W(v, { errors: e.state.meta.errors })]
912
- })
913
- })
914
- }),
915
- /* @__PURE__ */ W(u.Field, {
916
- name: "fromEmail",
917
- children: (e) => /* @__PURE__ */ W(Z, {
918
- label: a("From email"),
919
- id: "s-email",
920
- children: /* @__PURE__ */ W(s, {
921
- id: i("s-email"),
922
- type: "email",
923
- value: e.state.value,
924
- onBlur: e.handleBlur,
925
- onChange: (t) => e.handleChange(t.target.value),
926
- autoComplete: "email"
927
- })
928
- })
929
- }),
930
- /* @__PURE__ */ W(u.Field, {
931
- name: "supportURL",
932
- children: (e) => /* @__PURE__ */ W(Z, {
933
- label: a("Support URL"),
934
- id: "s-support",
935
- children: /* @__PURE__ */ W(s, {
936
- id: i("s-support"),
937
- type: "url",
938
- value: e.state.value,
939
- onBlur: e.handleBlur,
940
- onChange: (t) => e.handleChange(t.target.value),
941
- placeholder: a("https://example.com/support")
942
- })
943
- })
944
- }),
945
- /* @__PURE__ */ W(u.Field, {
946
- name: "subscribeURL",
947
- children: (e) => /* @__PURE__ */ W(Z, {
948
- label: a("Subscribe URL"),
949
- id: "s-subscribe",
950
- children: /* @__PURE__ */ W(s, {
951
- id: i("s-subscribe"),
952
- type: "url",
953
- value: e.state.value,
954
- onBlur: e.handleBlur,
955
- onChange: (t) => e.handleChange(t.target.value),
956
- placeholder: a("https://example.com/subscribe")
957
- })
958
- })
959
- }),
960
- /* @__PURE__ */ W(u.Field, {
961
- name: "billingURL",
962
- children: (e) => /* @__PURE__ */ W(Z, {
963
- label: a("Billing URL"),
964
- id: "s-billing",
965
- children: /* @__PURE__ */ W(s, {
966
- id: i("s-billing"),
967
- type: "url",
968
- value: e.state.value,
969
- onBlur: e.handleBlur,
970
- onChange: (t) => e.handleChange(t.target.value),
971
- placeholder: a("https://example.com/account")
972
- })
973
- })
974
- }),
975
- /* @__PURE__ */ W(u.Field, {
976
- name: "logoURL",
977
- children: (e) => /* @__PURE__ */ W(Z, {
978
- label: a("Logo URL"),
979
- id: "s-logo",
980
- children: /* @__PURE__ */ W(s, {
981
- id: i("s-logo"),
982
- type: "url",
983
- value: e.state.value,
984
- onBlur: e.handleBlur,
985
- onChange: (t) => e.handleChange(t.target.value),
986
- placeholder: a("https://example.com/logo.png")
987
- })
988
- })
989
- })
990
- ]
991
- }) : /* @__PURE__ */ G("dl", {
992
- className: "grid gap-4",
993
- children: [
994
- /* @__PURE__ */ W(X, {
995
- label: a("Display name"),
996
- value: e.display_name
997
- }),
998
- /* @__PURE__ */ W(X, {
999
- label: a("From email"),
1000
- value: o?.from_email
1001
- }),
1002
- /* @__PURE__ */ W(X, {
1003
- label: a("Support URL"),
1004
- value: o?.support_url
1005
- }),
1006
- /* @__PURE__ */ W(X, {
1007
- label: a("Subscribe URL"),
1008
- value: o?.subscribe_url
1009
- }),
1010
- /* @__PURE__ */ W(X, {
1011
- label: a("Billing URL"),
1012
- value: o?.billing_url
1013
- }),
1014
- /* @__PURE__ */ W(X, {
1015
- label: a("Logo URL"),
1016
- value: o?.logo_url
1017
- })
1018
- ]
1019
- })]
1020
- });
1021
- }
1022
- function xe({ configuration: e, edits: r }) {
1023
- let { id: i, text: a } = t(), o = e.reprice_notice_window_days ?? 30, c = q(e), l = K({
1024
- defaultValues: { days: String(o) },
1025
- onSubmit: ({ value: e }) => c.save({ reprice_notice_window_days: Number(e.days) }, "Notice window saved", "Save notice window")
1026
- });
1027
- return /* @__PURE__ */ G("section", {
1028
- className: "grid gap-5",
1029
- children: [/* @__PURE__ */ G("div", {
1030
- className: "flex flex-wrap items-start justify-between gap-4",
1031
- children: [/* @__PURE__ */ G("div", {
1032
- className: "grid max-w-2xl gap-1",
1033
- children: [/* @__PURE__ */ W("h2", {
1034
- className: "text-base font-semibold",
1035
- children: /* @__PURE__ */ W(n, { id: "Pricing policies" })
1036
- }), /* @__PURE__ */ W("p", {
1037
- className: "text-sm text-pretty text-muted-foreground",
1038
- children: /* @__PURE__ */ W(n, { id: "Set how much notice customers receive before a price increase." })
1039
- })]
1040
- }), /* @__PURE__ */ W(l.Subscribe, {
1041
- selector: (e) => [e.canSubmit, e.isSubmitting],
1042
- children: ([e, t]) => /* @__PURE__ */ W(Y, {
1043
- edits: r,
1044
- editing: c.editing,
1045
- form: "notice-window-form",
1046
- saving: t,
1047
- canSave: e,
1048
- onEdit: () => {
1049
- l.reset({ days: String(o) }), c.open();
1050
- },
1051
- onCancel: c.close
1052
- })
1053
- })]
1054
- }), c.editing ? /* @__PURE__ */ W("form", {
1055
- id: i("notice-window-form"),
1056
- onSubmit: (e) => {
1057
- e.preventDefault(), e.stopPropagation(), l.handleSubmit();
1058
- },
1059
- children: /* @__PURE__ */ W(l.Field, {
1060
- name: "days",
1061
- validators: { onChange: ({ value: e }) => {
1062
- let t = Number(e);
1063
- return e.trim() && Number.isInteger(t) && t >= 0 ? void 0 : "Enter a whole number of days";
1064
- } },
1065
- children: (e) => /* @__PURE__ */ W(Z, {
1066
- label: a("Notice period (days)"),
1067
- id: "s-notice-window",
1068
- children: /* @__PURE__ */ G("div", {
1069
- className: "grid gap-1.5",
1070
- children: [/* @__PURE__ */ W(s, {
1071
- id: i("s-notice-window"),
1072
- type: "number",
1073
- step: "1",
1074
- min: "0",
1075
- value: e.state.value,
1076
- onBlur: e.handleBlur,
1077
- onChange: (t) => e.handleChange(t.target.value),
1078
- "aria-invalid": e.state.meta.errors.length > 0
1079
- }), /* @__PURE__ */ W(v, { errors: e.state.meta.errors })]
1080
- })
1081
- })
1082
- })
1083
- }) : /* @__PURE__ */ W("dl", { children: /* @__PURE__ */ W(X, {
1084
- label: a("Notice period"),
1085
- value: `${o} ${o === 1 ? "day" : "days"}`
1086
- }) })]
1087
- });
1088
- }
1089
- function Se() {
1090
- let { selectedMerchant: e, adminQueries: t } = a(), r = V(t.psps()), i = V(t.rails()), o = f();
1091
- if (r.isPending || i.isPending) return /* @__PURE__ */ W("p", {
1092
- className: "text-sm text-muted-foreground",
1093
- children: /* @__PURE__ */ W(n, { id: "Loading…" })
1094
- });
1095
- let s = i.data ?? [];
1096
- return /* @__PURE__ */ G("div", {
1097
- className: "grid gap-6",
1098
- children: [
1099
- /* @__PURE__ */ W(J, {}),
1100
- /* @__PURE__ */ G("section", {
1101
- className: "grid gap-5",
1102
- children: [/* @__PURE__ */ G("div", {
1103
- className: "flex flex-wrap items-start justify-between gap-4",
1104
- children: [/* @__PURE__ */ G("div", {
1105
- className: "grid gap-1",
1106
- children: [/* @__PURE__ */ W("h2", {
1107
- className: "text-base font-semibold",
1108
- children: /* @__PURE__ */ W(n, { id: "PSPs" })
1109
- }), /* @__PURE__ */ W("p", {
1110
- className: "text-sm text-muted-foreground",
1111
- children: /* @__PURE__ */ W(n, { id: "The accounts this merchant takes payments through, one or more per rail." })
1112
- })]
1113
- }), o && /* @__PURE__ */ W(Ne, { railDefinitions: s }, e() ?? "")]
1114
- }), r.data?.data?.length ? /* @__PURE__ */ G(ne, {
1115
- className: "min-w-[44rem]",
1116
- children: [/* @__PURE__ */ W(te, { children: /* @__PURE__ */ G(E, {
1117
- className: "hover:bg-transparent",
1118
- children: [
1119
- /* @__PURE__ */ W(w, {
1120
- className: "text-muted-foreground",
1121
- children: "PSP"
1122
- }),
1123
- /* @__PURE__ */ W(w, {
1124
- className: "text-muted-foreground",
1125
- children: /* @__PURE__ */ W(n, { id: "Environment" })
1126
- }),
1127
- /* @__PURE__ */ W(w, {
1128
- className: "text-muted-foreground",
1129
- children: /* @__PURE__ */ W(n, { id: "Credentials" })
1130
- }),
1131
- /* @__PURE__ */ W(w, {
1132
- className: "text-muted-foreground",
1133
- children: /* @__PURE__ */ W(n, { id: "State" })
1134
- }),
1135
- o && /* @__PURE__ */ W(w, {
1136
- className: "text-right text-muted-foreground",
1137
- children: /* @__PURE__ */ W(n, { id: "Action" })
1138
- })
1139
- ]
1140
- }) }), /* @__PURE__ */ W(ee, { children: r.data.data.map((e) => /* @__PURE__ */ W(we, {
1141
- psp: e,
1142
- railDefinitions: s,
1143
- edits: o
1144
- }, e.id)) })]
1145
- }) : /* @__PURE__ */ W("p", {
1146
- className: "py-2 text-sm text-muted-foreground",
1147
- children: /* @__PURE__ */ W(n, { id: "No PSPs configured." })
1148
- })]
1149
- }),
1150
- /* @__PURE__ */ W(ge, {})
1151
- ]
1152
- });
1153
- }
1154
- function Ce(e) {
1155
- return e.validated_at ? `Validated ${m(e.validated_at)}` : e.configured ? "Configured" : "Not configured";
1156
- }
1157
- function we({ psp: r, railDefinitions: i, edits: s }) {
1158
- let { toast: c, toastApiError: l, toastStaleEdit: u, adminMutations: d, selectedMerchant: f } = a(), { text: p } = t(), m = H(), h = B(d.updatePSP(m)), [g, v] = z.useState(!1), y = _(), b = i.find((e) => e.rail === r.rail), x = b?.display_name ?? r.rail, S = r.credentials ?? {}, C = async (t) => {
1159
- if (!(!t && !await y({
1160
- title: `Archive ${r.key}?`,
1161
- description: "New purchase stops routing to it. Existing subscriptions, refunds and webhooks keep using it.",
1162
- confirmLabel: "Archive PSP"
1163
- }))) try {
1164
- await h.mutateAsync({
1165
- id: r.id,
1166
- psp: {
1167
- archived: !0,
1168
- expected_revision: r.revision,
1169
- ...t ? { allow_last: !0 } : {}
1170
- }
1171
- }), c.success("PSP archived");
1172
- } catch (n) {
1173
- if (n instanceof e && n.code === "psp_last_active") {
1174
- t ? l(n, "Archive PSP") : v(!0);
1175
- return;
1176
- }
1177
- if (n instanceof e && n.revisionMismatch) {
1178
- u(`PSP ${r.key}`);
1179
- return;
1180
- }
1181
- l(n, "Archive PSP");
1182
- }
1183
- };
1184
- return /* @__PURE__ */ G(E, {
1185
- className: r.archived ? "opacity-60" : void 0,
1186
- children: [
1187
- /* @__PURE__ */ W(T, {
1188
- className: "py-3",
1189
- children: /* @__PURE__ */ G("div", {
1190
- className: "grid min-w-0 leading-tight",
1191
- children: [/* @__PURE__ */ W("span", {
1192
- className: "font-medium",
1193
- children: r.key
1194
- }), /* @__PURE__ */ G("span", {
1195
- className: "truncate text-xs text-muted-foreground",
1196
- children: [
1197
- x,
1198
- " · ",
1199
- De(r)
1200
- ]
1201
- })]
1202
- })
1203
- }),
1204
- /* @__PURE__ */ W(T, {
1205
- className: "py-3 capitalize",
1206
- children: r.environment
1207
- }),
1208
- /* @__PURE__ */ W(T, {
1209
- className: "py-3",
1210
- children: Object.keys(S).length > 0 ? /* @__PURE__ */ W("span", {
1211
- className: "flex flex-wrap gap-1",
1212
- children: Object.entries(S).map(([e, t]) => /* @__PURE__ */ W(D, {
1213
- variant: "secondary",
1214
- className: t.configured ? "" : "bg-held-surface text-held",
1215
- title: Ce(t),
1216
- children: e
1217
- }, e))
1218
- }) : /* @__PURE__ */ W("span", {
1219
- className: "text-sm text-muted-foreground",
1220
- children: /* @__PURE__ */ W(n, { id: "None required" })
1221
- })
1222
- }),
1223
- /* @__PURE__ */ W(T, {
1224
- className: "py-3",
1225
- children: r.archived && r.open_obligations === 0 ? /* @__PURE__ */ W(D, {
1226
- variant: "secondary",
1227
- children: /* @__PURE__ */ W(n, { id: "archived" })
1228
- }) : r.archived ? /* @__PURE__ */ G(D, {
1229
- variant: "secondary",
1230
- className: "bg-held-surface text-held",
1231
- children: [
1232
- /* @__PURE__ */ W(n, { id: "draining (" }),
1233
- r.open_obligations,
1234
- ")"
1235
- ]
1236
- }) : /* @__PURE__ */ W(D, {
1237
- variant: "secondary",
1238
- className: "bg-settled-surface text-settled",
1239
- children: /* @__PURE__ */ W(n, { id: "active" })
1240
- })
1241
- }),
1242
- s && /* @__PURE__ */ W(T, {
1243
- className: "py-3 text-right",
1244
- children: !r.archived && /* @__PURE__ */ G("div", {
1245
- className: "flex justify-end gap-2",
1246
- children: [
1247
- /* @__PURE__ */ W(Te, {
1248
- psp: r,
1249
- credentialKeys: b?.credential_keys ?? Object.keys(S)
1250
- }, `${f() ?? ""}:${r.id}`),
1251
- /* @__PURE__ */ W(o, {
1252
- variant: "outline",
1253
- size: "sm",
1254
- disabled: h.isPending,
1255
- onClick: () => C(!1),
1256
- children: /* @__PURE__ */ W(n, { id: "Archive" })
1257
- }),
1258
- /* @__PURE__ */ W(ie, {
1259
- open: g,
1260
- onOpenChange: v,
1261
- title: `Archive the last active ${x} PSP?`,
1262
- description: p("New purchase on this rail is refused until another PSP is armed. Existing subscriptions, refunds and webhooks keep using this one."),
1263
- confirmationWord: "ARCHIVE",
1264
- actionLabel: "Archive PSP",
1265
- onConfirm: () => C(!0)
1266
- })
1267
- ]
1268
- })
1269
- })
1270
- ]
1271
- });
1272
- }
1273
- function Te({ psp: r, credentialKeys: i }) {
1274
- let { toast: c, toastApiError: l, toastStaleEdit: u, adminMutations: d, selectedMerchant: f } = a(), { id: p } = t(), [h, g] = z.useState(!1), [_] = z.useState(() => f() ?? ""), v = z.useRef(r.revision), y = H(), b = B(d.updatePSP(y)), x = r.credentials ?? {}, S = K({
1275
- defaultValues: { credentials: {} },
1276
- onSubmit: async ({ value: t }) => {
1277
- let n = Object.fromEntries(Object.entries(t.credentials).filter(([, e]) => e.trim()));
1278
- try {
1279
- if ((f() ?? "") !== _) throw Error("Merchant changed; reopen this form");
1280
- await b.mutateAsync({
1281
- id: r.id,
1282
- psp: {
1283
- expected_revision: v.current,
1284
- credentials: n
1285
- }
1286
- }), c.success(`${r.key} credentials validated and rotated`), C(!1);
1287
- } catch (t) {
1288
- if (t instanceof e && t.revisionMismatch) {
1289
- u(`PSP ${r.key}`), C(!1);
1290
- return;
1291
- }
1292
- l(t, "Rotate credentials");
1293
- } finally {
1294
- b.reset();
1295
- }
1296
- }
1297
- }), C = (e) => {
1298
- e || S.reset(), e && (v.current = r.revision), g(e);
1299
- };
1300
- return /* @__PURE__ */ G(P, {
1301
- open: h,
1302
- onOpenChange: C,
1303
- children: [/* @__PURE__ */ W(N, { render: /* @__PURE__ */ W(o, {
1304
- variant: "outline",
1305
- size: "sm",
1306
- children: /* @__PURE__ */ W(n, { id: "Rotate" })
1307
- }) }), /* @__PURE__ */ G(A, {
1308
- className: I,
1309
- children: [/* @__PURE__ */ G(O, { children: [/* @__PURE__ */ G(j, { children: [
1310
- /* @__PURE__ */ W(n, { id: "Rotate " }),
1311
- r.key,
1312
- /* @__PURE__ */ W(n, { id: " credentials · " }),
1313
- De(r)
1314
- ] }), /* @__PURE__ */ W(M, { children: /* @__PURE__ */ W(n, { id: "Current credentials are never shown. A new one is validated against the live provider before it is stored; if that check fails, nothing is written. Leave a field blank to keep the credential it holds now." }) })] }), /* @__PURE__ */ G("form", {
1315
- onSubmit: (e) => {
1316
- e.preventDefault(), e.stopPropagation(), S.handleSubmit();
1317
- },
1318
- className: "grid gap-4",
1319
- children: [/* @__PURE__ */ W(S.Field, {
1320
- name: "credentials",
1321
- children: (e) => /* @__PURE__ */ G("div", {
1322
- className: "grid gap-3",
1323
- children: [i.map((t) => {
1324
- let i = x[t];
1325
- return /* @__PURE__ */ G($, {
1326
- label: t,
1327
- id: `rot-${r.id}-${t}`,
1328
- children: [/* @__PURE__ */ W(s, {
1329
- id: p(`rot-${r.id}-${t}`),
1330
- type: "password",
1331
- autoComplete: "new-password",
1332
- placeholder: i?.configured ? "unchanged" : "not configured",
1333
- value: e.state.value[t] ?? "",
1334
- onChange: (n) => e.handleChange({
1335
- ...e.state.value,
1336
- [t]: n.target.value
1337
- })
1338
- }), i?.validated_at && /* @__PURE__ */ G("p", {
1339
- className: "text-xs text-muted-foreground",
1340
- children: [/* @__PURE__ */ W(n, { id: "Last validated " }), m(i.validated_at)]
1341
- })]
1342
- }, t);
1343
- }), /* @__PURE__ */ W("p", {
1344
- className: "text-xs text-muted-foreground",
1345
- children: /* @__PURE__ */ W(n, { id: "Once this succeeds, the new credential is used for the next charge and every one after it. Previous webhook signing secrets remain accepted while their required overlap is active." })
1346
- })]
1347
- })
1348
- }), /* @__PURE__ */ W(k, { children: /* @__PURE__ */ W(S.Subscribe, {
1349
- selector: (e) => [e.values.credentials, e.isSubmitting],
1350
- children: ([e, t]) => /* @__PURE__ */ W(o, {
1351
- type: "submit",
1352
- disabled: t || !Object.values(e).some((e) => e.trim()),
1353
- children: t ? "Validating…" : "Validate & rotate"
1354
- })
1355
- }) })]
1356
- })]
1357
- })]
1358
- });
1359
- }
1360
- var Ee = {
1361
- gateway_id: {
1362
- label: "Gateway ID",
1363
- hint: "The Gateway ID shown in your NMI dashboard."
1364
- },
1365
- account_id: {
1366
- label: "Account ID",
1367
- hint: "Your Stripe account ID. It starts with acct_."
1368
- },
1369
- client_accnum: {
1370
- label: "Client account number",
1371
- hint: "Your CCBill account number, such as 945280."
1372
- },
1373
- client_subacc: {
1374
- label: "Client subaccount",
1375
- hint: "Your CCBill subaccount number, such as 0000."
1376
- },
1377
- treasury: {
1378
- label: "Treasury",
1379
- hint: "The Solana address your payments land in."
1380
- }
1381
- };
1382
- function De(e) {
1383
- return e.client_accnum ? `${e.client_accnum}-${e.client_subacc ?? ""}` : e.gateway_id ?? e.account_id ?? e.treasury ?? "";
1384
- }
1385
- var Oe = {
1386
- live: "Live: real money",
1387
- test: "Test: the provider's own system, no money moves",
1388
- sandbox: "Sandbox: the provider's separate sandbox",
1389
- mainnet: "Mainnet: real money",
1390
- devnet: "Devnet: Solana's development network",
1391
- testnet: "Testnet: Solana's test network"
1392
- }, ke = {
1393
- nmi: "NMI",
1394
- ccbill: "CCBill",
1395
- stripe: "Stripe",
1396
- solana: "Solana"
1397
- };
1398
- function Ae(e, t) {
1399
- let n = ke[e] ?? e;
1400
- return !t || t.toLowerCase() === n.toLowerCase() ? n : `${t} (${n})`;
1401
- }
1402
- var je = {
1403
- api: "API",
1404
- id: "ID",
1405
- url: "URL"
1406
- };
1407
- function Me(e) {
1408
- return e.split(/[_-]+/).filter(Boolean).map((e, t) => je[e.toLowerCase()] || (t > 0 ? e.toLowerCase() : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase())).join(" ");
1409
- }
1410
- function Ne({ railDefinitions: e }) {
1411
- let { toast: r, toastApiError: i, adminMutations: c, selectedMerchant: l } = a(), { text: u, id: d } = t(), [f, p] = z.useState(!1), [m] = z.useState(() => l() ?? ""), h = H(), g = B(c.createPSP(h)), _ = K({
1412
- defaultValues: {
1413
- rail: "",
1414
- environment: "",
1415
- key: "",
1416
- account: {},
1417
- credentials: {}
1418
- },
1419
- onSubmit: async ({ value: t }) => {
1420
- let n = Object.fromEntries(Object.entries(t.credentials).filter(([, e]) => e !== ""));
1421
- try {
1422
- if ((l() ?? "") !== m) throw Error("Merchant changed; reopen this form");
1423
- let i = e.find((e) => e.rail === t.rail);
1424
- await g.mutateAsync({
1425
- key: t.key.trim().toLowerCase(),
1426
- rail: t.rail,
1427
- environment: t.environment,
1428
- ...Object.fromEntries((i?.account_fields ?? []).map((e) => [e, (t.account[e] ?? "").trim()])),
1429
- ...Object.keys(n).length ? { credentials: n } : {}
1430
- }), _.reset(), r.success("PSP added"), p(!1);
1431
- } catch (e) {
1432
- i(e, "Add PSP");
1433
- } finally {
1434
- g.reset();
1435
- }
1436
- }
1437
- }), w = (e) => {
1438
- e || _.reset(), p(e);
1439
- };
1440
- return /* @__PURE__ */ G(P, {
1441
- open: f,
1442
- onOpenChange: w,
1443
- children: [/* @__PURE__ */ W(N, { render: /* @__PURE__ */ W(o, {
1444
- size: "sm",
1445
- children: /* @__PURE__ */ W(n, { id: "Add PSP" })
1446
- }) }), /* @__PURE__ */ G(A, {
1447
- className: I,
1448
- children: [/* @__PURE__ */ G(O, { children: [/* @__PURE__ */ W(j, { children: /* @__PURE__ */ W(n, { id: "Add a PSP" }) }), /* @__PURE__ */ W(M, { children: /* @__PURE__ */ W(n, { id: "Connect the account that will take money for you. Credentials go straight into the secret store and are never shown again." }) })] }), /* @__PURE__ */ G("form", {
1449
- onSubmit: (e) => {
1450
- e.preventDefault(), e.stopPropagation(), _.handleSubmit();
1451
- },
1452
- className: "grid gap-4",
1453
- children: [/* @__PURE__ */ G("div", {
1454
- className: "grid gap-3",
1455
- children: [
1456
- /* @__PURE__ */ W(_.Field, {
1457
- name: "rail",
1458
- validators: { onChange: ({ value: e }) => e ? void 0 : "Choose a payment rail" },
1459
- children: (t) => /* @__PURE__ */ G($, {
1460
- label: u("Payment rail"),
1461
- id: "pv-rail",
1462
- children: [/* @__PURE__ */ G(C, {
1463
- items: e.map((e) => ({
1464
- value: e.rail,
1465
- label: Ae(e.rail, e.display_name)
1466
- })),
1467
- value: t.state.value || null,
1468
- onValueChange: (n) => {
1469
- t.handleChange(n ?? ""), _.setFieldValue("account", {}), _.setFieldValue("credentials", {}), _.setFieldValue("environment", e.find((e) => e.rail === n)?.environments[0] ?? "");
1470
- },
1471
- children: [/* @__PURE__ */ W(b, {
1472
- id: d("pv-rail"),
1473
- className: "w-full",
1474
- "aria-invalid": t.state.meta.errors.length > 0,
1475
- children: /* @__PURE__ */ W(y, { placeholder: u("Pick a rail…") })
1476
- }), /* @__PURE__ */ W(x, { children: e.map((e) => /* @__PURE__ */ W(S, {
1477
- value: e.rail,
1478
- children: Ae(e.rail, e.display_name)
1479
- }, e.rail)) })]
1480
- }), /* @__PURE__ */ W(v, { errors: t.state.meta.errors })]
1481
- })
1482
- }),
1483
- /* @__PURE__ */ W(_.Subscribe, {
1484
- selector: (e) => e.values.rail,
1485
- children: (t) => {
1486
- let n = e.find((e) => e.rail === t)?.environments ?? [];
1487
- return /* @__PURE__ */ W(_.Field, {
1488
- name: "environment",
1489
- validators: { onChange: ({ value: e }) => e ? void 0 : "Choose whether it moves real money" },
1490
- children: (e) => /* @__PURE__ */ G($, {
1491
- label: u("Environment"),
1492
- id: "pv-environment",
1493
- hint: "Whether this PSP moves real money. It is checked with the provider before the PSP is used.",
1494
- children: [/* @__PURE__ */ G(C, {
1495
- items: n.map((e) => ({
1496
- value: e,
1497
- label: u(Oe[e] ?? e)
1498
- })),
1499
- value: e.state.value || null,
1500
- onValueChange: (t) => e.handleChange(t ?? ""),
1501
- children: [/* @__PURE__ */ W(b, {
1502
- id: d("pv-environment"),
1503
- className: "w-full",
1504
- disabled: !t,
1505
- "aria-invalid": e.state.meta.errors.length > 0,
1506
- children: /* @__PURE__ */ W(y, { placeholder: u("Pick an environment…") })
1507
- }), /* @__PURE__ */ W(x, { children: n.map((e) => /* @__PURE__ */ W(S, {
1508
- value: e,
1509
- children: u(Oe[e] ?? e)
1510
- }, e)) })]
1511
- }), /* @__PURE__ */ W(v, { errors: e.state.meta.errors })]
1512
- })
1513
- });
1514
- }
1515
- }),
1516
- /* @__PURE__ */ W(_.Field, {
1517
- name: "key",
1518
- validators: { onChange: ({ value: e }) => /^[a-z0-9][a-z0-9_-]{0,62}$/.test(e.trim().toLowerCase()) ? void 0 : "Lowercase letters, digits, - or _" },
1519
- children: (e) => /* @__PURE__ */ G($, {
1520
- label: u("Key"),
1521
- id: "pv-key",
1522
- hint: "Your name for this PSP, such as mobius. Prices and purchase name it by this key.",
1523
- children: [/* @__PURE__ */ W(s, {
1524
- id: d("pv-key"),
1525
- value: e.state.value,
1526
- onBlur: e.handleBlur,
1527
- onChange: (t) => e.handleChange(t.target.value),
1528
- "aria-invalid": e.state.meta.errors.length > 0
1529
- }), /* @__PURE__ */ W(v, { errors: e.state.meta.errors })]
1530
- })
1531
- }),
1532
- /* @__PURE__ */ W(_.Subscribe, {
1533
- selector: (e) => e.values.rail,
1534
- children: (t) => /* @__PURE__ */ W(_.Field, {
1535
- name: "account",
1536
- children: (n) => /* @__PURE__ */ W(U, { children: e.find((e) => e.rail === t)?.account_fields.map((e) => /* @__PURE__ */ W($, {
1537
- label: u(Ee[e]?.label ?? Me(e)),
1538
- id: `pv-account-${e}`,
1539
- hint: Ee[e]?.hint,
1540
- children: /* @__PURE__ */ W(s, {
1541
- id: d(`pv-account-${e}`),
1542
- value: n.state.value[e] ?? "",
1543
- onBlur: n.handleBlur,
1544
- onChange: (t) => n.handleChange({
1545
- ...n.state.value,
1546
- [e]: t.target.value
1547
- })
1548
- })
1549
- }, e)) })
1550
- })
1551
- }),
1552
- /* @__PURE__ */ W(_.Subscribe, {
1553
- selector: (e) => e.values.rail,
1554
- children: (t) => {
1555
- let n = e.find((e) => e.rail === t);
1556
- return /* @__PURE__ */ W(_.Field, {
1557
- name: "credentials",
1558
- children: (e) => /* @__PURE__ */ W(U, { children: n?.credential_keys.map((t) => /* @__PURE__ */ W($, {
1559
- label: Me(t),
1560
- id: `pv-credential-${t}`,
1561
- children: /* @__PURE__ */ W(s, {
1562
- id: d(`pv-credential-${t}`),
1563
- type: "password",
1564
- autoComplete: "new-password",
1565
- value: e.state.value[t] ?? "",
1566
- onChange: (n) => e.handleChange({
1567
- ...e.state.value,
1568
- [t]: n.target.value
1569
- })
1570
- })
1571
- }, t)) })
1572
- });
1573
- }
1574
- })
1575
- ]
1576
- }), /* @__PURE__ */ W(k, { children: /* @__PURE__ */ W(_.Subscribe, {
1577
- selector: (e) => [
1578
- e.values.rail,
1579
- e.values.environment,
1580
- e.values.key,
1581
- e.values.account,
1582
- e.canSubmit,
1583
- e.isSubmitting
1584
- ],
1585
- children: ([t, r, i, a, s, c]) => /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(o, {
1586
- type: "button",
1587
- variant: "outline",
1588
- onClick: () => w(!1),
1589
- children: /* @__PURE__ */ W(n, { id: "Cancel" })
1590
- }), /* @__PURE__ */ W(o, {
1591
- type: "submit",
1592
- disabled: !t || !r || !i.trim() || !e.find((e) => e.rail === t)?.account_fields.every((e) => (a[e] ?? "").trim()) || !s || c,
1593
- children: c ? "Saving…" : "Add PSP"
1594
- })] })
1595
- }) })]
1596
- })]
1597
- })]
1598
- });
1599
- }
1600
- function Pe() {
1601
- let { toast: e, toastApiError: r, adminMutations: i } = a(), { text: l, id: u } = t(), [d, f] = z.useState(), m = B(i.lookupCustomerControls()), _ = B(i.setCreditLimit()), y = c(), b = K({
1602
- defaultValues: { newLimit: "" },
1603
- onSubmit: async ({ value: t }) => {
1604
- if (!d) return;
1605
- let n = p(d.currency), i = n === void 0 ? null : g(t.newLimit, n);
1606
- if (!(i === null || i.startsWith("-"))) try {
1607
- await _.mutateAsync({
1608
- customerId: d.customerID,
1609
- currency: d.currency,
1610
- amount: i
1611
- }), f((e) => e && {
1612
- ...e,
1613
- creditLimit: i
1614
- }), b.reset(), e.success("Credit limit updated");
1615
- } catch (e) {
1616
- r(e, "Set credit limit");
1617
- }
1618
- }
1619
- }), x = K({
1620
- defaultValues: {
1621
- customerID: "",
1622
- currency: "usd"
1623
- },
1624
- onSubmit: async ({ value: e }) => {
1625
- let t = e.customerID.trim(), n = e.currency.trim().toLowerCase();
1626
- try {
1627
- let e = await m.mutateAsync({
1628
- customerId: t,
1629
- currency: n
1630
- });
1631
- f({
1632
- customerID: t,
1633
- ...e
1634
- }), b.reset();
1635
- } catch (e) {
1636
- r(e, "Lookup customer controls"), f(void 0);
1637
- }
1638
- }
1639
- });
1640
- return /* @__PURE__ */ G("div", {
1641
- className: "grid gap-10",
1642
- children: [/* @__PURE__ */ G("section", {
1643
- className: "grid gap-5",
1644
- children: [/* @__PURE__ */ G("div", {
1645
- className: "grid gap-1",
1646
- children: [/* @__PURE__ */ W("h2", {
1647
- className: "text-base font-semibold",
1648
- children: /* @__PURE__ */ W(n, { id: "Customer lookup" })
1649
- }), /* @__PURE__ */ W("p", {
1650
- className: "text-sm text-muted-foreground",
1651
- children: /* @__PURE__ */ W(n, { id: "Find a customer by ID and currency." })
1652
- })]
1653
- }), /* @__PURE__ */ G("form", {
1654
- onSubmit: (e) => {
1655
- e.preventDefault(), e.stopPropagation(), x.handleSubmit();
1656
- },
1657
- className: "grid gap-4 md:grid-cols-[minmax(0,1fr)_10rem_auto] md:items-end",
1658
- children: [
1659
- /* @__PURE__ */ W(x.Field, {
1660
- name: "customerID",
1661
- validators: { onChange: ({ value: e }) => e.trim() ? void 0 : "Enter a customer ID" },
1662
- children: (e) => /* @__PURE__ */ G($, {
1663
- label: l("Customer ID"),
1664
- id: "customer-controls-id",
1665
- children: [/* @__PURE__ */ W(s, {
1666
- id: u("customer-controls-id"),
1667
- placeholder: l("Customer UUID"),
1668
- value: e.state.value,
1669
- onBlur: e.handleBlur,
1670
- onChange: (t) => e.handleChange(t.target.value),
1671
- "aria-invalid": e.state.meta.errors.length > 0
1672
- }), /* @__PURE__ */ W(v, { errors: e.state.meta.errors })]
1673
- })
1674
- }),
1675
- /* @__PURE__ */ W(x.Field, {
1676
- name: "currency",
1677
- validators: { onChange: ({ value: e }) => e.trim() ? void 0 : "Enter a currency" },
1678
- children: (e) => /* @__PURE__ */ G($, {
1679
- label: l("Currency"),
1680
- id: "customer-controls-currency",
1681
- children: [/* @__PURE__ */ W(s, {
1682
- id: u("customer-controls-currency"),
1683
- placeholder: l("USD"),
1684
- value: e.state.value,
1685
- onBlur: e.handleBlur,
1686
- onChange: (t) => e.handleChange(t.target.value),
1687
- "aria-invalid": e.state.meta.errors.length > 0
1688
- }), /* @__PURE__ */ W(v, { errors: e.state.meta.errors })]
1689
- })
1690
- }),
1691
- /* @__PURE__ */ W(x.Subscribe, {
1692
- selector: (e) => [
1693
- e.values.customerID,
1694
- e.values.currency,
1695
- e.canSubmit,
1696
- e.isSubmitting
1697
- ],
1698
- children: ([e, t, n, r]) => /* @__PURE__ */ W(o, {
1699
- type: "submit",
1700
- variant: "outline",
1701
- disabled: !e.trim() || !t.trim() || !n || r,
1702
- children: r ? "Looking up…" : "Look up"
1703
- })
1704
- })
1705
- ]
1706
- })]
1707
- }), d && /* @__PURE__ */ G("section", {
1708
- className: "grid gap-5",
1709
- children: [
1710
- /* @__PURE__ */ G("div", {
1711
- className: "grid gap-1",
1712
- children: [/* @__PURE__ */ W("h2", {
1713
- className: "text-base font-semibold",
1714
- children: /* @__PURE__ */ W(n, { id: "Credit and trust" })
1715
- }), /* @__PURE__ */ G("p", {
1716
- className: "text-sm text-muted-foreground",
1717
- children: [
1718
- /* @__PURE__ */ W("span", {
1719
- className: "font-mono text-xs break-all text-foreground",
1720
- children: d.customerID
1721
- }),
1722
- " ",
1723
- "· ",
1724
- d.currency.toUpperCase()
1725
- ]
1726
- })]
1727
- }),
1728
- /* @__PURE__ */ G("dl", {
1729
- className: "grid gap-4",
1730
- children: [/* @__PURE__ */ W(X, {
1731
- label: l("Trust level"),
1732
- value: d.trustLevel || "Default"
1733
- }), /* @__PURE__ */ W(X, {
1734
- label: l("Credit limit"),
1735
- value: d.creditLimit === "0" ? "Off" : h(d.creditLimit, d.currency)
1736
- })]
1737
- }),
1738
- y && /* @__PURE__ */ W("form", {
1739
- onSubmit: (e) => {
1740
- e.preventDefault(), e.stopPropagation(), b.handleSubmit();
1741
- },
1742
- children: /* @__PURE__ */ W(Z, {
1743
- label: `New limit (${d.currency.toUpperCase()})`,
1744
- id: "customer-controls-limit",
1745
- children: /* @__PURE__ */ W(b.Field, {
1746
- name: "newLimit",
1747
- validators: { onChange: ({ value: e }) => {
1748
- let t = p(d.currency), n = t === void 0 ? null : g(e, t);
1749
- return e !== "" && n !== null && !n.startsWith("-") ? void 0 : "Enter a valid amount";
1750
- } },
1751
- children: (e) => /* @__PURE__ */ G("div", {
1752
- className: "grid gap-1.5",
1753
- children: [
1754
- /* @__PURE__ */ G("div", {
1755
- className: "flex gap-2",
1756
- children: [/* @__PURE__ */ W(s, {
1757
- id: u("customer-controls-limit"),
1758
- placeholder: "0.00",
1759
- type: "number",
1760
- step: "any",
1761
- min: "0",
1762
- value: e.state.value,
1763
- onBlur: e.handleBlur,
1764
- onChange: (t) => e.handleChange(t.target.value),
1765
- "aria-invalid": e.state.meta.errors.length > 0
1766
- }), /* @__PURE__ */ W(b.Subscribe, {
1767
- selector: (e) => [
1768
- e.values.newLimit,
1769
- e.canSubmit,
1770
- e.isSubmitting
1771
- ],
1772
- children: ([e, t, n]) => /* @__PURE__ */ W(o, {
1773
- type: "submit",
1774
- disabled: !e || !t || n,
1775
- children: n ? "Updating…" : "Update"
1776
- })
1777
- })]
1778
- }),
1779
- /* @__PURE__ */ W(v, { errors: e.state.meta.errors }),
1780
- /* @__PURE__ */ W("p", {
1781
- className: "text-xs text-muted-foreground",
1782
- children: /* @__PURE__ */ W(n, { id: "Enter 0 to turn credit off." })
1783
- })
1784
- ]
1785
- })
1786
- })
1787
- })
1788
- })
1789
- ]
1790
- })]
1791
- });
1792
- }
1793
- function $({ label: e, id: n, hint: r, children: i }) {
1794
- let { id: a } = t();
1795
- return /* @__PURE__ */ G("div", {
1796
- className: "grid gap-1.5",
1797
- children: [
1798
- /* @__PURE__ */ W(F, {
1799
- htmlFor: a(n),
1800
- children: e
1801
- }),
1802
- r ? /* @__PURE__ */ W("p", {
1803
- className: "text-[13px] text-muted-foreground",
1804
- children: r
1805
- }) : null,
1806
- i
1807
- ]
1808
- });
1809
- }
1810
- //#endregion
1811
- export { ve as SettingsPage };
1812
-
1813
- //# sourceMappingURL=admin-settings-DYC-c7mJ.js.map