@openrails/billing-ui 0.274.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 (176) hide show
  1. package/dist/admin/context.d.ts +14 -0
  2. package/dist/admin/lib/api/endpoints.d.ts +2 -1
  3. package/dist/admin/lib/api/index.d.ts +1 -0
  4. package/dist/admin/lib/api/order-endpoints.d.ts +1 -0
  5. package/dist/admin/lib/api/types.d.ts +2 -12
  6. package/dist/admin/lib/format.d.ts +5 -1
  7. package/dist/admin/lib/order-queries.d.ts +3 -0
  8. package/dist/admin/lib/queries.d.ts +3 -0
  9. package/dist/admin/messages.d.ts +13 -8
  10. package/dist/admin/pages/dashboard/lib.d.ts +1 -0
  11. package/dist/admin/pages/imports/shared.d.ts +1 -0
  12. package/dist/admin/pages/subscriptions/change-subscription-dialog.d.ts +4 -7
  13. package/dist/admin/pages/subscriptions/subscription-change-options.d.ts +6 -15
  14. package/dist/{admin-attempts-Dzipkstg.js → admin-attempts-CP5CWyNR.js} +28 -28
  15. package/dist/{admin-attempts-Dzipkstg.js.map → admin-attempts-CP5CWyNR.js.map} +1 -1
  16. package/dist/{admin-auth-BCl_Tv3t.js → admin-auth-DlIOmwPo.js} +2 -2
  17. package/dist/{admin-auth-BCl_Tv3t.js.map → admin-auth-DlIOmwPo.js.map} +1 -1
  18. package/dist/{admin-badge-kmYQM9Ge.js → admin-badge-DR_8AhdC.js} +2 -2
  19. package/dist/{admin-badge-kmYQM9Ge.js.map → admin-badge-DR_8AhdC.js.map} +1 -1
  20. package/dist/{admin-button-Cq9ZfX4R.js → admin-button-DBzTD6By.js} +2 -2
  21. package/dist/{admin-button-Cq9ZfX4R.js.map → admin-button-DBzTD6By.js.map} +1 -1
  22. package/dist/{admin-capabilities-k5fQZhN9.js → admin-capabilities-CZdT1Pxe.js} +2 -2
  23. package/dist/{admin-capabilities-k5fQZhN9.js.map → admin-capabilities-CZdT1Pxe.js.map} +1 -1
  24. package/dist/{admin-card-C8k67jJv.js → admin-card-mZl4-s5d.js} +2 -2
  25. package/dist/{admin-card-C8k67jJv.js.map → admin-card-mZl4-s5d.js.map} +1 -1
  26. package/dist/{admin-catalog-CON-GwKL.js → admin-catalog-DpTjS0Yo.js} +38 -38
  27. package/dist/{admin-catalog-CON-GwKL.js.map → admin-catalog-DpTjS0Yo.js.map} +1 -1
  28. package/dist/{admin-cursor-pager-DqFruoNu.js → admin-cursor-pager-C-KjCIy9.js} +4 -4
  29. package/dist/{admin-cursor-pager-DqFruoNu.js.map → admin-cursor-pager-C-KjCIy9.js.map} +1 -1
  30. package/dist/{admin-customers-CWWOrcVR.js → admin-customers-BE3N839X.js} +12 -12
  31. package/dist/{admin-customers-CWWOrcVR.js.map → admin-customers-BE3N839X.js.map} +1 -1
  32. package/dist/{admin-dashboard-BiShWFk2.js → admin-dashboard-BxjkV15J.js} +25 -17
  33. package/dist/admin-dashboard-BxjkV15J.js.map +1 -0
  34. package/dist/{admin-data-table-CdsjYJh5.js → admin-data-table-D89AwWz_.js} +5 -5
  35. package/dist/{admin-data-table-CdsjYJh5.js.map → admin-data-table-D89AwWz_.js.map} +1 -1
  36. package/dist/{admin-detail-BWSC1aCH.js → admin-detail-BKe9xqPd.js} +41 -41
  37. package/dist/{admin-detail-BWSC1aCH.js.map → admin-detail-BKe9xqPd.js.map} +1 -1
  38. package/dist/admin-detail-C8lD7U2t.js +699 -0
  39. package/dist/admin-detail-C8lD7U2t.js.map +1 -0
  40. package/dist/{admin-detail-CMmhZQ2A.js → admin-detail-D6zD085K.js} +45 -37
  41. package/dist/admin-detail-D6zD085K.js.map +1 -0
  42. package/dist/{admin-detail-Cyuf_i9U.js → admin-detail-Ln56otK0.js} +40 -40
  43. package/dist/{admin-detail-Cyuf_i9U.js.map → admin-detail-Ln56otK0.js.map} +1 -1
  44. package/dist/{admin-detail-CiONe1Pt.js → admin-detail-P-UnNvXJ.js} +171 -171
  45. package/dist/admin-detail-P-UnNvXJ.js.map +1 -0
  46. package/dist/{admin-dialog-Ch7rTOCr.js → admin-dialog-Dn2FRJu4.js} +3 -3
  47. package/dist/{admin-dialog-Ch7rTOCr.js.map → admin-dialog-Dn2FRJu4.js.map} +1 -1
  48. package/dist/{admin-dropdown-menu-Bah3f8AZ.js → admin-dropdown-menu-DLUn6Uj3.js} +2 -2
  49. package/dist/{admin-dropdown-menu-Bah3f8AZ.js.map → admin-dropdown-menu-DLUn6Uj3.js.map} +1 -1
  50. package/dist/{admin-dunning-B2zgtrOo.js → admin-dunning-COaHzrmN.js} +2 -2
  51. package/dist/{admin-dunning-B2zgtrOo.js.map → admin-dunning-COaHzrmN.js.map} +1 -1
  52. package/dist/{admin-fact-card-Bt__Cd_U.js → admin-fact-card-DKvBnUXB.js} +2 -2
  53. package/dist/{admin-fact-card-Bt__Cd_U.js.map → admin-fact-card-DKvBnUXB.js.map} +1 -1
  54. package/dist/admin-format-BbiTCqUG.js +171 -0
  55. package/dist/admin-format-BbiTCqUG.js.map +1 -0
  56. package/dist/{admin-health-pzTO6_0v.js → admin-health-DmnI4e8K.js} +10 -10
  57. package/dist/{admin-health-pzTO6_0v.js.map → admin-health-DmnI4e8K.js.map} +1 -1
  58. package/dist/{admin-imports-tT5et8-V.js → admin-imports-C0aMP6sj.js} +18 -18
  59. package/dist/{admin-imports-tT5et8-V.js.map → admin-imports-C0aMP6sj.js.map} +1 -1
  60. package/dist/{admin-input-DvRZy_2a.js → admin-input-JKrQIGfD.js} +2 -2
  61. package/dist/{admin-input-DvRZy_2a.js.map → admin-input-JKrQIGfD.js.map} +1 -1
  62. package/dist/{admin-label-QZtWJGH-.js → admin-label-CHWsVIZC.js} +2 -2
  63. package/dist/{admin-label-QZtWJGH-.js.map → admin-label-CHWsVIZC.js.map} +1 -1
  64. package/dist/{admin-linked-table-row-6jkCKwMn.js → admin-linked-table-row-BMZYYsuk.js} +3 -3
  65. package/dist/{admin-linked-table-row-6jkCKwMn.js.map → admin-linked-table-row-BMZYYsuk.js.map} +1 -1
  66. package/dist/{admin-map-dialog-BV54mvMQ.js → admin-map-dialog-BHUGdCcv.js} +10 -10
  67. package/dist/{admin-map-dialog-BV54mvMQ.js.map → admin-map-dialog-BHUGdCcv.js.map} +1 -1
  68. package/dist/{admin-metering-Bv5EcX6M.js → admin-metering-CDqueHUh.js} +15 -15
  69. package/dist/{admin-metering-Bv5EcX6M.js.map → admin-metering-CDqueHUh.js.map} +1 -1
  70. package/dist/{admin-missing-record-BXqGFDt3.js → admin-missing-record-BPFs3MmO.js} +2 -2
  71. package/dist/{admin-missing-record-BXqGFDt3.js.map → admin-missing-record-BPFs3MmO.js.map} +1 -1
  72. package/dist/{admin-ops-h3RjpcNu.js → admin-ops-CL2kjDwi.js} +18 -15
  73. package/dist/admin-ops-CL2kjDwi.js.map +1 -0
  74. package/dist/admin-orders-C1Sf2qhc.js +192 -0
  75. package/dist/admin-orders-C1Sf2qhc.js.map +1 -0
  76. package/dist/admin-parked-a0tB5bhG.js +193 -0
  77. package/dist/admin-parked-a0tB5bhG.js.map +1 -0
  78. package/dist/admin-payments-DJcjwRA4.js +221 -0
  79. package/dist/admin-payments-DJcjwRA4.js.map +1 -0
  80. package/dist/{admin-price-detail-BjWYU5A-.js → admin-price-detail-BOmeWw15.js} +15 -15
  81. package/dist/{admin-price-detail-BjWYU5A-.js.map → admin-price-detail-BOmeWw15.js.map} +1 -1
  82. package/dist/{admin-price-format-BVUpDoSC.js → admin-price-format-CqOmHrIn.js} +2 -2
  83. package/dist/{admin-price-format-BVUpDoSC.js.map → admin-price-format-CqOmHrIn.js.map} +1 -1
  84. package/dist/{admin-price-wizard-CTbkbmYc.js → admin-price-wizard-B6s5OJeO.js} +9 -9
  85. package/dist/{admin-price-wizard-CTbkbmYc.js.map → admin-price-wizard-B6s5OJeO.js.map} +1 -1
  86. package/dist/{admin-proposals-Ci9Q8j7Y.js → admin-proposals-DVrl-ym4.js} +20 -20
  87. package/dist/{admin-proposals-Ci9Q8j7Y.js.map → admin-proposals-DVrl-ym4.js.map} +1 -1
  88. package/dist/admin-provider-prices-BVVogH7Q.js +241 -0
  89. package/dist/admin-provider-prices-BVVogH7Q.js.map +1 -0
  90. package/dist/{admin-range-picker-nfflPp21.js → admin-range-picker-C6BtSm2B.js} +5 -5
  91. package/dist/{admin-range-picker-nfflPp21.js.map → admin-range-picker-C6BtSm2B.js.map} +1 -1
  92. package/dist/{admin-records-CrTCorWH.js → admin-records-DKtcgN11.js} +19 -19
  93. package/dist/{admin-records-CrTCorWH.js.map → admin-records-DKtcgN11.js.map} +1 -1
  94. package/dist/{admin-reports-BO6wrvtw.js → admin-reports-CtPoiceH.js} +8 -8
  95. package/dist/{admin-reports-BO6wrvtw.js.map → admin-reports-CtPoiceH.js.map} +1 -1
  96. package/dist/{admin-select-DvfJ80Rg.js → admin-select-6Yuh5M1Q.js} +2 -2
  97. package/dist/{admin-select-DvfJ80Rg.js.map → admin-select-6Yuh5M1Q.js.map} +1 -1
  98. package/dist/{admin-settings-BOoTzhyf.js → admin-settings-DscHu4ww.js} +560 -550
  99. package/dist/admin-settings-DscHu4ww.js.map +1 -0
  100. package/dist/{admin-shared-BbGT_qTo.js → admin-shared-BywM-MMp.js} +13 -9
  101. package/dist/{admin-shared-BbGT_qTo.js.map → admin-shared-BywM-MMp.js.map} +1 -1
  102. package/dist/{admin-skeleton-B2a4ScVE.js → admin-skeleton-lndmw89u.js} +2 -2
  103. package/dist/{admin-skeleton-B2a4ScVE.js.map → admin-skeleton-lndmw89u.js.map} +1 -1
  104. package/dist/{admin-status-badge-Bp6cssXY.js → admin-status-badge-IL8ofZ_6.js} +3 -3
  105. package/dist/{admin-status-badge-Bp6cssXY.js.map → admin-status-badge-IL8ofZ_6.js.map} +1 -1
  106. package/dist/{admin-subscriptions-D9JmoicC.js → admin-subscriptions-Cd5CGrue.js} +83 -87
  107. package/dist/admin-subscriptions-Cd5CGrue.js.map +1 -0
  108. package/dist/{admin-switch-DBBxJRZP.js → admin-switch-DpwQSzEm.js} +2 -2
  109. package/dist/{admin-switch-DBBxJRZP.js.map → admin-switch-DpwQSzEm.js.map} +1 -1
  110. package/dist/{admin-table-CPDoVfK4.js → admin-table-D-GdGM1m.js} +2 -2
  111. package/dist/{admin-table-CPDoVfK4.js.map → admin-table-D-GdGM1m.js.map} +1 -1
  112. package/dist/admin-tabs-B--1flzO.js +158 -0
  113. package/dist/admin-tabs-B--1flzO.js.map +1 -0
  114. package/dist/{admin-textarea-d3fu_waS.js → admin-textarea-xsp5V9xM.js} +2 -2
  115. package/dist/{admin-textarea-d3fu_waS.js.map → admin-textarea-xsp5V9xM.js.map} +1 -1
  116. package/dist/{admin-typed-confirm-dialog-BVklYjFo.js → admin-typed-confirm-dialog-NiEDwX_0.js} +6 -6
  117. package/dist/{admin-typed-confirm-dialog-BVklYjFo.js.map → admin-typed-confirm-dialog-NiEDwX_0.js.map} +1 -1
  118. package/dist/{admin-utils-DTT53IpS.js → admin-utils-wuPUD0uh.js} +152 -137
  119. package/dist/admin-utils-wuPUD0uh.js.map +1 -0
  120. package/dist/{admin-widget-viz-Exsqz3Dw.js → admin-widget-viz-kHHVmDEx.js} +215 -187
  121. package/dist/admin-widget-viz-kHHVmDEx.js.map +1 -0
  122. package/dist/admin.css +1 -1
  123. package/dist/admin.js +49 -44
  124. package/dist/admin.js.map +1 -1
  125. package/dist/client/generated/routes.d.ts +17 -0
  126. package/dist/client/generated/wire.d.ts +4 -0
  127. package/dist/client/types.d.ts +6 -0
  128. package/dist/{client-BYgnI6_h.js → client-ctrbivyN.js} +3 -2
  129. package/dist/client-ctrbivyN.js.map +1 -0
  130. package/dist/client.js +1 -1
  131. package/dist/{hooks-t2tSrCpa.js → hooks-KpTetx6F.js} +2 -2
  132. package/dist/{hooks-t2tSrCpa.js.map → hooks-KpTetx6F.js.map} +1 -1
  133. package/dist/index.js +750 -711
  134. package/dist/index.js.map +1 -1
  135. package/dist/lib/card-brands.d.ts +1 -0
  136. package/dist/locales/de.js +3 -0
  137. package/dist/locales/de.js.map +1 -1
  138. package/dist/locales/en.d.ts +3 -0
  139. package/dist/locales/en.js +3 -0
  140. package/dist/locales/en.js.map +1 -1
  141. package/dist/locales/es.js +3 -0
  142. package/dist/locales/es.js.map +1 -1
  143. package/dist/locales/ja.js +3 -0
  144. package/dist/locales/ja.js.map +1 -1
  145. package/dist/locales/ko.js +3 -0
  146. package/dist/locales/ko.js.map +1 -1
  147. package/dist/locales/zh.js +3 -0
  148. package/dist/locales/zh.js.map +1 -1
  149. package/dist/react.js +1 -1
  150. package/dist/styles.css +1 -1
  151. package/package.json +1 -1
  152. package/dist/admin-customer-search-CJHB80rg.js +0 -117
  153. package/dist/admin-customer-search-CJHB80rg.js.map +0 -1
  154. package/dist/admin-dashboard-BiShWFk2.js.map +0 -1
  155. package/dist/admin-detail-CKRtK43V.js +0 -728
  156. package/dist/admin-detail-CKRtK43V.js.map +0 -1
  157. package/dist/admin-detail-CMmhZQ2A.js.map +0 -1
  158. package/dist/admin-detail-CiONe1Pt.js.map +0 -1
  159. package/dist/admin-format-DoohJ7Fg.js +0 -136
  160. package/dist/admin-format-DoohJ7Fg.js.map +0 -1
  161. package/dist/admin-ops-h3RjpcNu.js.map +0 -1
  162. package/dist/admin-orders-DYxPiuTl.js +0 -192
  163. package/dist/admin-orders-DYxPiuTl.js.map +0 -1
  164. package/dist/admin-parked-ClKA60d5.js +0 -193
  165. package/dist/admin-parked-ClKA60d5.js.map +0 -1
  166. package/dist/admin-payments-BlIuy3wL.js +0 -220
  167. package/dist/admin-payments-BlIuy3wL.js.map +0 -1
  168. package/dist/admin-provider-prices-B6Ayq-eN.js +0 -246
  169. package/dist/admin-provider-prices-B6Ayq-eN.js.map +0 -1
  170. package/dist/admin-settings-BOoTzhyf.js.map +0 -1
  171. package/dist/admin-subscriptions-D9JmoicC.js.map +0 -1
  172. package/dist/admin-tabs-DDUv3kiu.js +0 -46
  173. package/dist/admin-tabs-DDUv3kiu.js.map +0 -1
  174. package/dist/admin-utils-DTT53IpS.js.map +0 -1
  175. package/dist/admin-widget-viz-Exsqz3Dw.js.map +0 -1
  176. package/dist/client-BYgnI6_h.js.map +0 -1
@@ -0,0 +1,699 @@
1
+ import { E as e, O as t, _ as n, c as r, p as i, r as a, s as o, w as s } from "./admin-utils-wuPUD0uh.js";
2
+ import { t as c } from "./admin-button-DBzTD6By.js";
3
+ import { t as l } from "./admin-input-JKrQIGfD.js";
4
+ import { a as u } from "./admin-capabilities-CZdT1Pxe.js";
5
+ import { d, i as f, o as p, r as m, s as h } from "./admin-format-BbiTCqUG.js";
6
+ import { t as g } from "./admin-badge-DR_8AhdC.js";
7
+ import { t as _ } from "./admin-status-badge-IL8ofZ_6.js";
8
+ import { t as v } from "./admin-form-field-errors-hbUMIriS.js";
9
+ import { a as y, i as ee, n as b, r as x, t as te } from "./admin-select-6Yuh5M1Q.js";
10
+ import { a as S, n as C, o as w, r as T, s as ne, t as re } from "./admin-table-D-GdGM1m.js";
11
+ import { a as E, i as ie, n as D, o as O, r as ae, s as k, t as A } from "./admin-dialog-Dn2FRJu4.js";
12
+ import { t as j } from "./admin-label-CHWsVIZC.js";
13
+ import { i as oe, r as se } from "./admin-dialog-width-CC7QHT1p.js";
14
+ import { n as ce } from "./admin-price-format-CqOmHrIn.js";
15
+ import { a as M, o as N, r as le, t as ue } from "./admin-card-mZl4-s5d.js";
16
+ import { t as P } from "./admin-fact-card-DKvBnUXB.js";
17
+ import { t as F } from "./admin-tile-grids-CzGpidd9.js";
18
+ import { t as I } from "./admin-dunning-COaHzrmN.js";
19
+ import { t as de } from "./admin-missing-record-BPFs3MmO.js";
20
+ import { t as L } from "./admin-typed-confirm-dialog-NiEDwX_0.js";
21
+ import * as R from "react";
22
+ import { useMutation as z, useQuery as B, useQueryClient as V } from "@tanstack/react-query";
23
+ import { Fragment as H, jsx as U, jsxs as W } from "react/jsx-runtime";
24
+ import { HugeiconsIcon as G } from "@hugeicons/react";
25
+ import { ArrowLeft01Icon as K } from "@hugeicons/core-free-icons";
26
+ import { useForm as q, useStore as J } from "@tanstack/react-form";
27
+ //#region src/admin/pages/subscriptions/subscription-change-options.ts
28
+ function fe(e) {
29
+ let t = e.price, n = `${h(t.unit_amount, t.currency)}${t.quantity ? " per seat" : ""}`;
30
+ return [
31
+ e.product.display_name,
32
+ e.direction,
33
+ `${n} ${ce(t)}`,
34
+ t.key
35
+ ].join(" · ");
36
+ }
37
+ function pe(e, t) {
38
+ let n = e.quantity;
39
+ return n ? t !== null && t >= n.min && t <= n.max ? t : n.min : null;
40
+ }
41
+ function me({ product: e, price: t, scheduledChange: n, targets: r }) {
42
+ return (e && t && (t.quantity || n) ? [{
43
+ direction: "current",
44
+ price: t,
45
+ product: e
46
+ }] : []).concat(r.map((t) => ({
47
+ direction: e && t.product.tier_rank < e.tier_rank ? "downgrade" : "upgrade",
48
+ price: t.price,
49
+ product: t.product
50
+ })));
51
+ }
52
+ //#endregion
53
+ //#region src/admin/pages/subscriptions/change-subscription-dialog.tsx
54
+ function Y(e) {
55
+ let { selectedMerchant: t } = i();
56
+ return /* @__PURE__ */ U(he, { ...e }, `${t() ?? ""}:${e.subscriptionId}`);
57
+ }
58
+ function he({ subscriptionId: r, customerId: a, product: o, price: u, quantity: d, scheduledChange: f }) {
59
+ let { toast: m, toastApiError: _, adminMutations: v, adminQueries: S } = i(), { id: C, text: w } = t(), [T, ne] = R.useState(!1), [re, se] = R.useState(""), [ce, M] = R.useState(""), [N, le] = R.useState(""), [ue, P] = R.useState(""), F = R.useRef(/* @__PURE__ */ new Map()), I = R.useRef(0);
60
+ R.useEffect(() => () => {
61
+ I.current++;
62
+ }, []);
63
+ let de = V(), L = z(v.previewSubscriptionChange(r)), H = z(v.changeSubscription(de, r, a)), G = B(S.subscriptionChangeOptions(r)), K = me({
64
+ product: o,
65
+ price: u,
66
+ scheduledChange: f,
67
+ targets: G.data?.data ?? []
68
+ }), q = K.find((e) => e.price.id === re), J = q?.price.quantity, Y = Number(ce), he = !J || Number.isInteger(Y) && Y >= J.min && Y <= J.max, X = q && he ? {
69
+ price_id: q.price.id,
70
+ ...J ? { quantity: Y } : {}
71
+ } : void 0, ge = q?.direction === "current" && !f && (!J || Y === d), Z = X ? JSON.stringify(X) : "", Q = Z && ue === Z ? L.data : void 0, _e = G.isPending ? w("Loading plans…") : G.isError ? n(G.error).text : K.length === 0 ? w("No eligible recurring plans share this tier group and currency.") : void 0, $ = (e) => {
72
+ I.current++, ne(e);
73
+ }, ve = (e) => {
74
+ I.current++;
75
+ let t = K.find((t) => t.price.id === e)?.price;
76
+ se(e ?? ""), M(String(t ? pe(t, d) ?? "" : "")), P(""), L.reset(), H.reset();
77
+ }, ye = (e) => {
78
+ I.current++, M(e), P(""), L.reset(), H.reset();
79
+ }, be = L.error instanceof Error ? L.error.message : "", xe = H.error instanceof Error ? H.error.message : "", Se = H.data?.message, Ce = H.data?.next_action?.url ?? void 0;
80
+ return /* @__PURE__ */ W(A, {
81
+ open: T,
82
+ onOpenChange: $,
83
+ children: [/* @__PURE__ */ U(k, { render: /* @__PURE__ */ U(c, {
84
+ variant: "outline",
85
+ size: "sm",
86
+ disabled: !!_e && !H.variables,
87
+ title: _e,
88
+ children: /* @__PURE__ */ U(e, { id: "Change subscription" })
89
+ }) }), /* @__PURE__ */ W(D, {
90
+ className: oe,
91
+ children: [
92
+ /* @__PURE__ */ W(E, { children: [/* @__PURE__ */ U(O, { children: /* @__PURE__ */ U(e, { id: "Change subscription" }) }), /* @__PURE__ */ U(ae, { children: /* @__PURE__ */ U(e, { id: "Schedule the customer's plan or seats for the next renewal. No card is charged now. Choosing the current plan and seats clears a pending change. The customer is told." }) })] }),
93
+ /* @__PURE__ */ W("div", {
94
+ className: "grid gap-5",
95
+ children: [
96
+ /* @__PURE__ */ W("div", {
97
+ className: "grid gap-1.5",
98
+ children: [
99
+ /* @__PURE__ */ U(j, {
100
+ htmlFor: C("subscription-tier"),
101
+ children: /* @__PURE__ */ U(e, { id: "New plan" })
102
+ }),
103
+ /* @__PURE__ */ W(te, {
104
+ value: re,
105
+ onValueChange: ve,
106
+ children: [/* @__PURE__ */ U(ee, {
107
+ id: C("subscription-tier"),
108
+ className: "w-full",
109
+ disabled: G.isPending,
110
+ children: /* @__PURE__ */ U(y, { placeholder: G.isPending ? "Loading plans…" : "Choose a plan" })
111
+ }), /* @__PURE__ */ U(b, { children: K.map((e) => /* @__PURE__ */ U(x, {
112
+ value: e.price.id,
113
+ children: fe(e)
114
+ }, e.price.id)) })]
115
+ }),
116
+ G.isSuccess && K.length === 0 && /* @__PURE__ */ U("p", {
117
+ className: "text-xs text-muted-foreground",
118
+ children: /* @__PURE__ */ U(e, { id: "No eligible recurring plans share this tier group and currency." })
119
+ }),
120
+ G.isError && /* @__PURE__ */ U("p", {
121
+ className: "text-xs text-destructive",
122
+ role: "alert",
123
+ children: /* @__PURE__ */ U(e, { id: "Could not load the available plans." })
124
+ })
125
+ ]
126
+ }),
127
+ J && /* @__PURE__ */ W("div", {
128
+ className: "grid gap-1.5",
129
+ children: [
130
+ /* @__PURE__ */ U(j, {
131
+ htmlFor: C("subscription-seats"),
132
+ children: /* @__PURE__ */ U(e, { id: "Seats" })
133
+ }),
134
+ /* @__PURE__ */ U(l, {
135
+ id: C("subscription-seats"),
136
+ type: "number",
137
+ inputMode: "numeric",
138
+ min: J.min,
139
+ max: J.max,
140
+ value: ce,
141
+ onChange: (e) => ye(e.target.value)
142
+ }),
143
+ /* @__PURE__ */ W("p", {
144
+ className: "text-xs text-muted-foreground",
145
+ children: [
146
+ J.min,
147
+ /* @__PURE__ */ U(e, { id: " to " }),
148
+ J.max,
149
+ /* @__PURE__ */ U(e, { id: " seats." })
150
+ ]
151
+ })
152
+ ]
153
+ }),
154
+ /* @__PURE__ */ W("div", {
155
+ className: "grid gap-1.5",
156
+ children: [
157
+ /* @__PURE__ */ U(j, {
158
+ htmlFor: C("subscription-change-reason"),
159
+ children: /* @__PURE__ */ U(e, { id: "Reason" })
160
+ }),
161
+ /* @__PURE__ */ U(l, {
162
+ id: C("subscription-change-reason"),
163
+ value: N,
164
+ maxLength: 500,
165
+ placeholder: w("What the customer asked for"),
166
+ onChange: (e) => le(e.target.value)
167
+ }),
168
+ /* @__PURE__ */ U("p", {
169
+ className: "text-xs text-muted-foreground",
170
+ children: /* @__PURE__ */ U(e, { id: "Kept with the scheduled change." })
171
+ })
172
+ ]
173
+ }),
174
+ Q && q && /* @__PURE__ */ W("div", {
175
+ className: "grid gap-3",
176
+ "aria-live": "polite",
177
+ children: [
178
+ /* @__PURE__ */ W("div", {
179
+ className: "flex items-center justify-between gap-4",
180
+ children: [/* @__PURE__ */ U("span", {
181
+ className: "text-sm font-medium",
182
+ children: /* @__PURE__ */ U(e, { id: "Review" })
183
+ }), /* @__PURE__ */ U(g, {
184
+ variant: "secondary",
185
+ children: Q.effective === "now" ? "Immediate" : "At renewal"
186
+ })]
187
+ }),
188
+ /* @__PURE__ */ W("dl", {
189
+ className: "grid grid-cols-2 gap-x-8 gap-y-3 border-y py-4 text-sm",
190
+ children: [
191
+ Q.quantity !== null && /* @__PURE__ */ W("div", {
192
+ className: "grid gap-1",
193
+ children: [/* @__PURE__ */ U("dt", {
194
+ className: "text-xs text-muted-foreground",
195
+ children: /* @__PURE__ */ U(e, { id: "Seats" })
196
+ }), /* @__PURE__ */ U("dd", {
197
+ className: "font-medium tabular-nums",
198
+ children: Q.quantity
199
+ })]
200
+ }),
201
+ /* @__PURE__ */ W("div", {
202
+ className: "grid gap-1",
203
+ children: [/* @__PURE__ */ U("dt", {
204
+ className: "text-xs text-muted-foreground",
205
+ children: /* @__PURE__ */ U(e, { id: "Due now" })
206
+ }), /* @__PURE__ */ U("dd", {
207
+ className: "font-medium tabular-nums",
208
+ children: h(Q.amount_due_now, Q.currency)
209
+ })]
210
+ }),
211
+ /* @__PURE__ */ W("div", {
212
+ className: "grid gap-1",
213
+ children: [/* @__PURE__ */ U("dt", {
214
+ className: "text-xs text-muted-foreground",
215
+ children: /* @__PURE__ */ U(e, { id: "Next charge" })
216
+ }), /* @__PURE__ */ U("dd", {
217
+ className: "font-medium tabular-nums",
218
+ children: h(Q.next_charge_amount, Q.currency)
219
+ })]
220
+ }),
221
+ /* @__PURE__ */ W("div", {
222
+ className: "grid gap-1",
223
+ children: [/* @__PURE__ */ U("dt", {
224
+ className: "text-xs text-muted-foreground",
225
+ children: /* @__PURE__ */ U(e, { id: "Effective" })
226
+ }), /* @__PURE__ */ U("dd", {
227
+ className: "font-medium",
228
+ children: Q.effective === "now" ? "Immediately" : p(Q.next_charge_date)
229
+ })]
230
+ }),
231
+ /* @__PURE__ */ W("div", {
232
+ className: "grid gap-1",
233
+ children: [/* @__PURE__ */ U("dt", {
234
+ className: "text-xs text-muted-foreground",
235
+ children: /* @__PURE__ */ U(e, { id: "Next billing date" })
236
+ }), /* @__PURE__ */ U("dd", {
237
+ className: "font-medium tabular-nums",
238
+ children: p(Q.next_charge_date)
239
+ })]
240
+ })
241
+ ]
242
+ }),
243
+ Q.is_estimate && /* @__PURE__ */ U("p", {
244
+ className: "text-xs text-muted-foreground",
245
+ children: /* @__PURE__ */ U(e, { id: "The payment provider calculates the final prorated amount." })
246
+ })
247
+ ]
248
+ }),
249
+ (be || xe) && /* @__PURE__ */ U("p", {
250
+ className: "text-sm text-destructive",
251
+ role: "alert",
252
+ children: xe || be
253
+ }),
254
+ H.data && H.data.status !== "succeeded" && /* @__PURE__ */ W("div", {
255
+ className: "grid gap-2 rounded-lg bg-muted px-3 py-2.5 text-sm",
256
+ "aria-live": "polite",
257
+ children: [/* @__PURE__ */ U("p", { children: Se ?? "This change needs another step." }), Ce && /* @__PURE__ */ U("a", {
258
+ href: Ce,
259
+ target: "_blank",
260
+ rel: "noreferrer",
261
+ className: "w-fit font-medium text-primary underline underline-offset-4",
262
+ children: /* @__PURE__ */ U(e, { id: "Continue with payment provider" })
263
+ })]
264
+ })
265
+ ]
266
+ }),
267
+ /* @__PURE__ */ W(ie, { children: [/* @__PURE__ */ U(c, {
268
+ type: "button",
269
+ variant: "outline",
270
+ onClick: () => $(!1),
271
+ children: /* @__PURE__ */ U(e, { id: "Cancel" })
272
+ }), Q ? /* @__PURE__ */ U(c, {
273
+ type: "button",
274
+ disabled: H.isPending || !N.trim() || !!H.data && H.data?.status !== "processing",
275
+ onClick: async () => {
276
+ if (!X) return;
277
+ let e = I.current, t = F.current.get(Z) ?? crypto.randomUUID();
278
+ F.current.set(Z, t);
279
+ let n = () => {
280
+ F.current.get(Z) === t && F.current.delete(Z);
281
+ };
282
+ try {
283
+ let r = await H.mutateAsync({
284
+ change: {
285
+ ...X,
286
+ reason: N.trim()
287
+ },
288
+ idempotencyKey: t
289
+ });
290
+ if ((r.status === "succeeded" || r.status === "blocked") && n(), I.current !== e) return;
291
+ r.status === "succeeded" && (m.success(r.effective === "now" ? "Subscription changed" : "Change scheduled for the next renewal"), $(!1), se(""), M(""), le(""), P(""), L.reset(), H.reset()), r.status === "processing" && m.info("The provider is still confirming this change. Check again to read the result.");
292
+ } catch (t) {
293
+ t instanceof s && (t.status === 402 || t.status === 409 && (t.code === "subscription_change_refused" || t.code === "subscription_change_idempotency_conflict")) && n(), I.current === e && _(t, "Change subscription");
294
+ }
295
+ },
296
+ children: H.isPending ? "Applying…" : H.data ? H.data.status === "processing" ? "Check result" : H.data.status === "blocked" ? "Change blocked" : "Action required" : "Confirm change"
297
+ }) : /* @__PURE__ */ U(c, {
298
+ type: "button",
299
+ disabled: !X || ge || L.isPending,
300
+ onClick: async () => {
301
+ if (!X) return;
302
+ let e = I.current;
303
+ try {
304
+ if (await L.mutateAsync(X), I.current !== e) return;
305
+ P(Z);
306
+ } catch (t) {
307
+ I.current === e && _(t, "Preview subscription change");
308
+ }
309
+ },
310
+ children: L.isPending ? "Reviewing…" : "Review change"
311
+ })] })
312
+ ]
313
+ })]
314
+ });
315
+ }
316
+ //#endregion
317
+ //#region src/admin/pages/subscriptions/detail.tsx
318
+ var X = (e) => new Date(e).toLocaleDateString(void 0, { dateStyle: "medium" });
319
+ function ge() {
320
+ let { text: n } = t(), { adminQueries: s } = i(), l = u(), { id: f = "" } = r(), v = o(), { data: y, isPending: ee, error: b } = B(s.subscription(f)), { data: x } = B(s.payments({ subscription_id: f }, 20)), te = x?.data ?? [], { data: E } = B(s.customer(y?.customer_id ?? ""));
321
+ if (ee) return /* @__PURE__ */ U("p", {
322
+ className: "text-sm text-muted-foreground",
323
+ children: /* @__PURE__ */ U(e, { id: "Loading…" })
324
+ });
325
+ if (!y) return /* @__PURE__ */ U(de, {
326
+ title: "Subscription not found",
327
+ error: b,
328
+ back: "/subscriptions",
329
+ backLabel: "Subscriptions"
330
+ });
331
+ let ie = y.status === "active" || y.status === "past_due" || y.status === "awaiting_method" || y.status === "unverified", D = y.status === "active" || y.status === "past_due", O = D || y.status === "awaiting_method", ae = y.collection_policy === "engine" ? (y.rail === "nmi" || y.rail === "stripe") && (O || y.resumable) : y.rail === "nmi" && O, k = E ? m(E) : void 0, A = y.product?.display_name;
332
+ return /* @__PURE__ */ W("div", {
333
+ className: "flex flex-col gap-4",
334
+ children: [
335
+ /* @__PURE__ */ W("div", {
336
+ className: "flex flex-wrap items-center gap-3",
337
+ children: [
338
+ /* @__PURE__ */ U(c, {
339
+ variant: "ghost",
340
+ size: "icon",
341
+ onClick: () => v(-1),
342
+ "aria-label": n("Back"),
343
+ children: /* @__PURE__ */ U(G, {
344
+ icon: K,
345
+ className: "size-4"
346
+ })
347
+ }),
348
+ /* @__PURE__ */ W("div", {
349
+ className: "min-w-0",
350
+ children: [/* @__PURE__ */ W("h1", {
351
+ className: "flex flex-wrap items-center gap-2 text-2xl font-semibold tracking-tight",
352
+ children: [A ?? n("Subscription"), /* @__PURE__ */ U(_, { status: y.status })]
353
+ }), /* @__PURE__ */ W("p", {
354
+ className: "text-xs [overflow-wrap:anywhere] text-muted-foreground",
355
+ children: [
356
+ y.id,
357
+ " · ",
358
+ y.rail,
359
+ y.rail_subscription_id ? ` · ${y.rail_subscription_id}` : ""
360
+ ]
361
+ })]
362
+ }),
363
+ /* @__PURE__ */ W("div", {
364
+ className: "flex flex-wrap gap-2 sm:ml-auto",
365
+ children: [
366
+ l && y.resumable && /* @__PURE__ */ U(_e, {
367
+ id: y.id,
368
+ customerId: y.customer_id
369
+ }),
370
+ l && D && /* @__PURE__ */ U(Y, {
371
+ subscriptionId: y.id,
372
+ customerId: y.customer_id,
373
+ product: y.product,
374
+ price: y.price,
375
+ quantity: y.quantity,
376
+ scheduledChange: y.scheduled_change
377
+ }),
378
+ l && ae && /* @__PURE__ */ U(ve, {
379
+ subscriptionId: y.id,
380
+ customerId: y.customer_id,
381
+ rail: y.rail
382
+ }),
383
+ l && ie && /* @__PURE__ */ U(Q, {
384
+ id: y.id,
385
+ customerId: y.customer_id,
386
+ customer: k,
387
+ plan: A,
388
+ periodEnd: y.current_period_ends_at
389
+ })
390
+ ]
391
+ })
392
+ ]
393
+ }),
394
+ /* @__PURE__ */ W("div", {
395
+ className: F,
396
+ children: [
397
+ /* @__PURE__ */ U(P, {
398
+ label: n("Customer"),
399
+ children: y.customer_id ? /* @__PURE__ */ U(a, {
400
+ className: "text-xs underline-offset-2 hover:underline",
401
+ to: `/customers/${y.customer_id}`,
402
+ children: k ?? d(y.customer_id, 13)
403
+ }) : "—"
404
+ }),
405
+ /* @__PURE__ */ U(P, {
406
+ label: n("Started"),
407
+ children: p(y.started_at)
408
+ }),
409
+ /* @__PURE__ */ W(P, {
410
+ label: n("Current period"),
411
+ children: [
412
+ p(y.current_period_starts_at),
413
+ " →",
414
+ " ",
415
+ p(y.current_period_ends_at)
416
+ ]
417
+ }),
418
+ /* @__PURE__ */ U(P, {
419
+ label: n("Price"),
420
+ children: /* @__PURE__ */ W("div", {
421
+ className: "flex flex-col gap-1",
422
+ children: [
423
+ /* @__PURE__ */ W("span", {
424
+ className: "flex items-center gap-2",
425
+ children: [y.price?.unit_amount !== void 0 && y.price?.currency ? /* @__PURE__ */ U(a, {
426
+ className: "underline-offset-2 hover:underline",
427
+ to: `/catalog/prices/${encodeURIComponent(y.price_id)}`,
428
+ children: h(y.price.unit_amount, y.price.currency)
429
+ }) : /* @__PURE__ */ U(a, {
430
+ className: "text-xs underline-offset-2 hover:underline",
431
+ to: `/catalog/prices/${encodeURIComponent(y.price_id)}`,
432
+ children: d(y.price_id ?? "—", 13)
433
+ }), y.price?.archived && /* @__PURE__ */ U(g, {
434
+ variant: "secondary",
435
+ title: n("Pinned to an archived (prior) version"),
436
+ children: /* @__PURE__ */ U(e, { id: "prior version" })
437
+ })]
438
+ }),
439
+ y.price?.key && /* @__PURE__ */ U("span", {
440
+ className: "text-xs text-muted-foreground",
441
+ children: y.price.key
442
+ }),
443
+ y.scheduled_change && /* @__PURE__ */ U(ye, { change: y.scheduled_change })
444
+ ]
445
+ })
446
+ }),
447
+ y.quantity !== null && /* @__PURE__ */ W(P, {
448
+ label: n("Seats"),
449
+ children: [y.quantity, y.scheduled_change?.quantity != null && ` → ${y.scheduled_change.quantity} at renewal`]
450
+ }),
451
+ /* @__PURE__ */ U(P, {
452
+ label: n("Dunning"),
453
+ children: y.dunning ? I(y.dunning) : "—"
454
+ }),
455
+ /* @__PURE__ */ U(P, {
456
+ label: y.dunning?.waiting_for_new_card ? "Card deadline" : "Final retry",
457
+ children: p(y.dunning?.final_retry_at)
458
+ }),
459
+ /* @__PURE__ */ U(P, {
460
+ label: n("Last decline"),
461
+ children: y.dunning?.last_failure_reason ?? "—"
462
+ }),
463
+ /* @__PURE__ */ U(P, {
464
+ label: n("Canceled"),
465
+ children: y.canceled_at ? /* @__PURE__ */ W(H, { children: [p(y.canceled_at), y.cancel_type && /* @__PURE__ */ U("span", {
466
+ className: "block text-xs text-muted-foreground",
467
+ children: n(Z[y.cancel_type] ?? y.cancel_type)
468
+ })] }) : "—"
469
+ })
470
+ ]
471
+ }),
472
+ /* @__PURE__ */ W(ue, { children: [/* @__PURE__ */ U(M, { children: /* @__PURE__ */ U(N, {
473
+ className: "text-sm",
474
+ children: /* @__PURE__ */ U(e, { id: "Payments" })
475
+ }) }), /* @__PURE__ */ U(le, { children: te.length ? /* @__PURE__ */ W(re, { children: [/* @__PURE__ */ U(w, { children: /* @__PURE__ */ W(ne, {
476
+ className: "hover:bg-transparent",
477
+ children: [
478
+ /* @__PURE__ */ U(S, {
479
+ className: "text-muted-foreground",
480
+ children: /* @__PURE__ */ U(e, { id: "Payment" })
481
+ }),
482
+ /* @__PURE__ */ U(S, {
483
+ className: "text-muted-foreground",
484
+ children: /* @__PURE__ */ U(e, { id: "Status" })
485
+ }),
486
+ /* @__PURE__ */ U(S, {
487
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
488
+ children: /* @__PURE__ */ U(e, { id: "Kind" })
489
+ }),
490
+ /* @__PURE__ */ U(S, {
491
+ className: "text-muted-foreground",
492
+ children: /* @__PURE__ */ U(e, { id: "Amount" })
493
+ }),
494
+ /* @__PURE__ */ U(S, {
495
+ className: "text-muted-foreground @max-[36rem]/page:hidden",
496
+ children: /* @__PURE__ */ U(e, { id: "Created" })
497
+ })
498
+ ]
499
+ }) }), /* @__PURE__ */ U(C, { children: te.map((e) => /* @__PURE__ */ W(ne, { children: [
500
+ /* @__PURE__ */ U(T, { children: /* @__PURE__ */ U(a, {
501
+ className: "text-xs underline-offset-2 hover:underline",
502
+ to: `/payments/${e.id}`,
503
+ children: d(e.id, 13)
504
+ }) }),
505
+ /* @__PURE__ */ U(T, { children: /* @__PURE__ */ U(_, { status: e.status }) }),
506
+ /* @__PURE__ */ U(T, {
507
+ className: "@max-[36rem]/page:hidden",
508
+ children: e.kind
509
+ }),
510
+ /* @__PURE__ */ U(T, { children: h(e.amount, e.currency) }),
511
+ /* @__PURE__ */ U(T, {
512
+ className: "@max-[36rem]/page:hidden",
513
+ children: p(e.created_at)
514
+ })
515
+ ] }, e.id)) })] }) : /* @__PURE__ */ U("p", {
516
+ className: "text-sm text-muted-foreground",
517
+ children: /* @__PURE__ */ U(e, { id: "No payments recorded." })
518
+ }) })] })
519
+ ]
520
+ });
521
+ }
522
+ var Z = {
523
+ user: "By the customer",
524
+ merchant: "By staff",
525
+ expired: "Renewal payment failed",
526
+ chargeback: "After a chargeback",
527
+ upgrade: "Replaced by an upgrade"
528
+ };
529
+ function Q({ id: n, customerId: r, customer: a, plan: o, periodEnd: s }) {
530
+ let { toast: u, toastApiError: d, adminMutations: f } = i(), { text: p, id: m } = t(), [h, g] = R.useState(!1), _ = V(), v = z(f.cancelSubscription(_, n, r)), y = q({ defaultValues: {
531
+ reason: "",
532
+ revokeAccess: !1
533
+ } }), ee = J(y.store, (e) => e.values.revokeAccess), b = a ?? p("The customer"), x = o ?? p("their access");
534
+ return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(c, {
535
+ variant: "destructive",
536
+ size: "sm",
537
+ onClick: () => g(!0),
538
+ children: /* @__PURE__ */ U(e, { id: "Cancel membership" })
539
+ }), /* @__PURE__ */ U(L, {
540
+ open: h,
541
+ onOpenChange: (e) => {
542
+ g(e), e || (y.reset(), v.reset());
543
+ },
544
+ title: p("Cancel this membership?"),
545
+ description: `${p("Renewal stops now and can't be restarted from here.")} ${ee ? `${b} ${p("loses")} ${x} ${p("now. No refund is made.")}` : `${b} ${p("keeps")} ${x} ${s ? `${p("until")} ${X(s)}.` : p("until the current period ends.")}`}`,
546
+ confirmationWord: "CANCEL",
547
+ actionLabel: p("Cancel membership"),
548
+ onConfirm: async () => {
549
+ try {
550
+ await v.mutateAsync(y.state.values), u.success("Subscription canceled");
551
+ } catch (e) {
552
+ throw d(e, "Cancel subscription"), e;
553
+ }
554
+ },
555
+ children: /* @__PURE__ */ W("div", {
556
+ className: "grid gap-3",
557
+ children: [/* @__PURE__ */ U(y.Field, {
558
+ name: "reason",
559
+ children: (t) => /* @__PURE__ */ W("div", {
560
+ className: "grid gap-1.5",
561
+ children: [/* @__PURE__ */ U(j, {
562
+ htmlFor: m("cancel-reason"),
563
+ children: /* @__PURE__ */ U(e, { id: "Reason" })
564
+ }), /* @__PURE__ */ U(l, {
565
+ id: m("cancel-reason"),
566
+ value: t.state.value,
567
+ onBlur: t.handleBlur,
568
+ onChange: (e) => t.handleChange(e.target.value),
569
+ placeholder: p("why is this being canceled?")
570
+ })]
571
+ })
572
+ }), /* @__PURE__ */ U(y.Field, {
573
+ name: "revokeAccess",
574
+ children: (t) => /* @__PURE__ */ W(j, {
575
+ className: "flex min-h-10 items-center gap-2 font-normal",
576
+ children: [/* @__PURE__ */ U("input", {
577
+ type: "checkbox",
578
+ className: "size-4 accent-destructive",
579
+ checked: t.state.value,
580
+ onChange: (e) => t.handleChange(e.target.checked)
581
+ }), /* @__PURE__ */ U(e, { id: "End access now instead (no refund is made)" })]
582
+ })
583
+ })]
584
+ })
585
+ })] });
586
+ }
587
+ function _e({ id: e, customerId: t }) {
588
+ let { toast: n, toastApiError: r, adminMutations: a } = i(), o = V(), s = z(a.resumeSubscription(o, e, t));
589
+ return /* @__PURE__ */ U(c, {
590
+ variant: "outline",
591
+ size: "sm",
592
+ disabled: s.isPending,
593
+ onClick: async () => {
594
+ try {
595
+ await s.mutateAsync(), n.success("Resume queued");
596
+ } catch (e) {
597
+ r(e, "Resume subscription");
598
+ }
599
+ },
600
+ children: s.isPending ? "Queuing…" : "Resume"
601
+ });
602
+ }
603
+ var $ = "default";
604
+ function ve({ subscriptionId: n, customerId: r, rail: a }) {
605
+ let { toast: o, toastApiError: s, adminMutations: l, adminQueries: u } = i(), { id: d, text: p } = t(), [m, h] = R.useState(!1), g = V(), _ = z(l.changeSubscriptionPaymentMethod(g, n, r)), { data: S } = B(u.customerPaymentMethods(m ? r : void 0)), C = q({
606
+ defaultValues: { paymentMethodId: "" },
607
+ onSubmit: async ({ value: e }) => {
608
+ try {
609
+ await _.mutateAsync(e.paymentMethodId === $ ? null : e.paymentMethodId), o.success("Payment method updated"), w(!1);
610
+ } catch (e) {
611
+ s(e, "Change payment method");
612
+ }
613
+ }
614
+ }), w = (e) => {
615
+ h(e), e || (C.reset(), _.reset());
616
+ };
617
+ return /* @__PURE__ */ W(A, {
618
+ open: m,
619
+ onOpenChange: w,
620
+ children: [/* @__PURE__ */ U(k, { render: /* @__PURE__ */ U(c, {
621
+ variant: "outline",
622
+ size: "sm",
623
+ children: /* @__PURE__ */ U(e, { id: "Change payment method" })
624
+ }) }), /* @__PURE__ */ W(D, {
625
+ className: se,
626
+ children: [/* @__PURE__ */ W(E, { children: [/* @__PURE__ */ U(O, { children: /* @__PURE__ */ U(e, { id: "Change payment method" }) }), /* @__PURE__ */ U(ae, { children: /* @__PURE__ */ U(e, { id: "Points future renewals of this subscription at another of the customer's stored cards (same rail), or back at their default card for its currency." }) })] }), /* @__PURE__ */ W("form", {
627
+ onSubmit: (e) => {
628
+ e.preventDefault(), e.stopPropagation(), C.handleSubmit();
629
+ },
630
+ className: "grid gap-4",
631
+ children: [/* @__PURE__ */ U(C.Field, {
632
+ name: "paymentMethodId",
633
+ validators: { onChange: ({ value: e }) => e ? void 0 : "Pick a stored payment method" },
634
+ children: (t) => /* @__PURE__ */ W("div", {
635
+ className: "grid gap-1.5",
636
+ children: [
637
+ /* @__PURE__ */ U(j, {
638
+ htmlFor: d("subscription-payment-method"),
639
+ children: /* @__PURE__ */ U(e, { id: "Payment method" })
640
+ }),
641
+ /* @__PURE__ */ W(te, {
642
+ value: t.state.value,
643
+ onValueChange: (e) => t.handleChange(e ?? ""),
644
+ children: [/* @__PURE__ */ U(ee, {
645
+ className: "w-full",
646
+ id: d("subscription-payment-method"),
647
+ "aria-invalid": t.state.meta.errors.length > 0,
648
+ children: /* @__PURE__ */ U(y, { placeholder: p("Pick a stored payment method") })
649
+ }), /* @__PURE__ */ W(b, { children: [/* @__PURE__ */ U(x, {
650
+ value: $,
651
+ children: /* @__PURE__ */ U(e, { id: "The customer's default card" })
652
+ }), (S ?? []).filter((e) => e.rail === a).map((e) => /* @__PURE__ */ W(x, {
653
+ value: e.id,
654
+ children: [
655
+ f(e.card),
656
+ " (",
657
+ e.rail,
658
+ ")"
659
+ ]
660
+ }, e.id))] })]
661
+ }),
662
+ /* @__PURE__ */ U(v, { errors: t.state.meta.errors })
663
+ ]
664
+ })
665
+ }), /* @__PURE__ */ U(ie, { children: /* @__PURE__ */ U(C.Subscribe, {
666
+ selector: (e) => [
667
+ e.values.paymentMethodId,
668
+ e.canSubmit,
669
+ e.isSubmitting
670
+ ],
671
+ children: ([e, t, n]) => /* @__PURE__ */ U(c, {
672
+ type: "submit",
673
+ disabled: !e || !t || n,
674
+ children: n ? "Updating…" : "Update"
675
+ })
676
+ }) })]
677
+ })]
678
+ })]
679
+ });
680
+ }
681
+ function ye({ change: t }) {
682
+ let { adminQueries: n } = i(), { data: r } = B(n.price(t.price_id));
683
+ return /* @__PURE__ */ W(g, {
684
+ className: "bg-held-surface text-held",
685
+ children: [
686
+ t.source === "migration" ? "migrates" : "changes",
687
+ /* @__PURE__ */ U(e, { id: " to" }),
688
+ " ",
689
+ r ? h(r.unit_amount, r.currency) : d(t.price_id, 9),
690
+ " ",
691
+ /* @__PURE__ */ U(e, { id: "at the first renewal from " }),
692
+ p(t.effective_at)
693
+ ]
694
+ });
695
+ }
696
+ //#endregion
697
+ export { ge as SubscriptionDetailPage };
698
+
699
+ //# sourceMappingURL=admin-detail-C8lD7U2t.js.map