@openrails/billing-ui 0.268.3 → 0.270.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 (143) hide show
  1. package/dist/admin/context.d.ts +164 -62
  2. package/dist/admin/lib/api/endpoints.d.ts +3 -7
  3. package/dist/admin/lib/api/import-endpoints.d.ts +44 -0
  4. package/dist/admin/lib/api/index.d.ts +17 -7
  5. package/dist/admin/lib/api/types.d.ts +0 -29
  6. package/dist/admin/lib/import-queries.d.ts +66 -0
  7. package/dist/admin/lib/mutations.d.ts +1 -5
  8. package/dist/admin/lib/queries.d.ts +6 -20
  9. package/dist/admin/messages.d.ts +176 -7
  10. package/dist/admin/pages/catalog/index.d.ts +0 -1
  11. package/dist/admin/pages/imports/detail.d.ts +2 -0
  12. package/dist/admin/pages/imports/index.d.ts +2 -0
  13. package/dist/admin/pages/imports/mapping-csv.d.ts +10 -0
  14. package/dist/admin/pages/imports/progress.d.ts +21 -0
  15. package/dist/admin/pages/imports/records.d.ts +2 -0
  16. package/dist/admin/pages/imports/shared.d.ts +22 -0
  17. package/dist/admin/pages/parked/index.d.ts +2 -0
  18. package/dist/admin/pages/proposals/grouping.d.ts +13 -0
  19. package/dist/admin/pages/proposals/index.d.ts +2 -0
  20. package/dist/admin/pages/provider-prices/index.d.ts +2 -0
  21. package/dist/admin/pages/provider-prices/map-dialog.d.ts +11 -0
  22. package/dist/admin/routes.d.ts +1 -1
  23. package/dist/{admin-attempts-BLeeKABa.js → admin-attempts-DyDDt-qw.js} +81 -82
  24. package/dist/admin-attempts-DyDDt-qw.js.map +1 -0
  25. package/dist/{admin-auth-DWVWxDup.js → admin-auth-1aZIgXiS.js} +2 -2
  26. package/dist/{admin-auth-DWVWxDup.js.map → admin-auth-1aZIgXiS.js.map} +1 -1
  27. package/dist/{admin-badge-CrEqD9Ew.js → admin-badge-pgG6D9-a.js} +2 -2
  28. package/dist/{admin-badge-CrEqD9Ew.js.map → admin-badge-pgG6D9-a.js.map} +1 -1
  29. package/dist/{admin-button-a7bDFgp0.js → admin-button-CrcYk5r0.js} +2 -2
  30. package/dist/{admin-button-a7bDFgp0.js.map → admin-button-CrcYk5r0.js.map} +1 -1
  31. package/dist/{admin-capabilities-QYUuJXvG.js → admin-capabilities-BDcZeHL_.js} +2 -2
  32. package/dist/{admin-capabilities-QYUuJXvG.js.map → admin-capabilities-BDcZeHL_.js.map} +1 -1
  33. package/dist/{admin-card-D1tz8Lbh.js → admin-card-DvTMc5Se.js} +2 -2
  34. package/dist/{admin-card-D1tz8Lbh.js.map → admin-card-DvTMc5Se.js.map} +1 -1
  35. package/dist/{admin-catalog-ggiDgWsR.js → admin-catalog-BlF5mnu4.js} +285 -382
  36. package/dist/admin-catalog-BlF5mnu4.js.map +1 -0
  37. package/dist/{admin-dom-VkcwevWr.js → admin-cursor-pager-CIb3Jw2F.js} +20 -25
  38. package/dist/admin-cursor-pager-CIb3Jw2F.js.map +1 -0
  39. package/dist/{admin-customers-BVMg-gUv.js → admin-customers-EpfoWDh-.js} +13 -13
  40. package/dist/{admin-customers-BVMg-gUv.js.map → admin-customers-EpfoWDh-.js.map} +1 -1
  41. package/dist/{admin-dashboard-Cc13i8i9.js → admin-dashboard-CJE63yz4.js} +46 -46
  42. package/dist/{admin-dashboard-Cc13i8i9.js.map → admin-dashboard-CJE63yz4.js.map} +1 -1
  43. package/dist/{admin-data-table-BL84xKKF.js → admin-data-table-hvFcJepL.js} +16 -16
  44. package/dist/{admin-data-table-BL84xKKF.js.map → admin-data-table-hvFcJepL.js.map} +1 -1
  45. package/dist/{admin-detail-CaEwBdX9.js → admin-detail-BRP6pL7t.js} +51 -51
  46. package/dist/{admin-detail-CaEwBdX9.js.map → admin-detail-BRP6pL7t.js.map} +1 -1
  47. package/dist/{admin-detail-9YAep3ts.js → admin-detail-CRzFb_pa.js} +232 -232
  48. package/dist/{admin-detail-9YAep3ts.js.map → admin-detail-CRzFb_pa.js.map} +1 -1
  49. package/dist/admin-detail-Ceod8AXy.js +299 -0
  50. package/dist/admin-detail-Ceod8AXy.js.map +1 -0
  51. package/dist/{admin-detail-C8t5jBps.js → admin-detail-QLxU8r-5.js} +62 -62
  52. package/dist/{admin-detail-C8t5jBps.js.map → admin-detail-QLxU8r-5.js.map} +1 -1
  53. package/dist/admin-detail-pPC8Q9l-.js +710 -0
  54. package/dist/{admin-detail-D2zcz_Xm.js.map → admin-detail-pPC8Q9l-.js.map} +1 -1
  55. package/dist/{admin-dialog-CiAw5vx-.js → admin-dialog-BSRf9Zre.js} +24 -24
  56. package/dist/{admin-dialog-CiAw5vx-.js.map → admin-dialog-BSRf9Zre.js.map} +1 -1
  57. package/dist/admin-dom-C7Y7A6Wa.js +8 -0
  58. package/dist/admin-dom-C7Y7A6Wa.js.map +1 -0
  59. package/dist/{admin-dropdown-menu-CYJbmqK2.js → admin-dropdown-menu-D0E5rwmn.js} +2 -2
  60. package/dist/{admin-dropdown-menu-CYJbmqK2.js.map → admin-dropdown-menu-D0E5rwmn.js.map} +1 -1
  61. package/dist/{admin-fact-card-BHTpDlaX.js → admin-fact-card-BPSVhS15.js} +2 -2
  62. package/dist/{admin-fact-card-BHTpDlaX.js.map → admin-fact-card-BPSVhS15.js.map} +1 -1
  63. package/dist/{admin-health-BUnjbvYR.js → admin-health-D0L5Kig7.js} +84 -84
  64. package/dist/{admin-health-BUnjbvYR.js.map → admin-health-D0L5Kig7.js.map} +1 -1
  65. package/dist/admin-imports-TCOljTgw.js +269 -0
  66. package/dist/admin-imports-TCOljTgw.js.map +1 -0
  67. package/dist/{admin-input-C-S_RGGo.js → admin-input-DJAK9nmk.js} +2 -2
  68. package/dist/{admin-input-C-S_RGGo.js.map → admin-input-DJAK9nmk.js.map} +1 -1
  69. package/dist/{admin-label-DPVYDdSO.js → admin-label-aviN9Gng.js} +2 -2
  70. package/dist/{admin-label-DPVYDdSO.js.map → admin-label-aviN9Gng.js.map} +1 -1
  71. package/dist/{admin-linked-table-row-D-gbTT7a.js → admin-linked-table-row-BGr7JXeM.js} +6 -6
  72. package/dist/{admin-linked-table-row-D-gbTT7a.js.map → admin-linked-table-row-BGr7JXeM.js.map} +1 -1
  73. package/dist/admin-map-dialog-DpGaIq52.js +135 -0
  74. package/dist/admin-map-dialog-DpGaIq52.js.map +1 -0
  75. package/dist/admin-mapping-csv-FtkyTBmk.js +56 -0
  76. package/dist/admin-mapping-csv-FtkyTBmk.js.map +1 -0
  77. package/dist/{admin-metering-BjbL0jjT.js → admin-metering-D-e-37Jn.js} +285 -285
  78. package/dist/{admin-metering-BjbL0jjT.js.map → admin-metering-D-e-37Jn.js.map} +1 -1
  79. package/dist/admin-ops-CQP4TzWM.js +235 -0
  80. package/dist/admin-ops-CQP4TzWM.js.map +1 -0
  81. package/dist/{admin-orders-BVW9-Fs9.js → admin-orders-BJ7W5S8P.js} +32 -32
  82. package/dist/{admin-orders-BVW9-Fs9.js.map → admin-orders-BJ7W5S8P.js.map} +1 -1
  83. package/dist/admin-parked-7HL8mOjw.js +193 -0
  84. package/dist/admin-parked-7HL8mOjw.js.map +1 -0
  85. package/dist/{admin-payments-C5MsFFmm.js → admin-payments-CzkzqYA1.js} +17 -17
  86. package/dist/{admin-payments-C5MsFFmm.js.map → admin-payments-CzkzqYA1.js.map} +1 -1
  87. package/dist/{admin-price-detail-D517JYHB.js → admin-price-detail-CSI5oKdb.js} +74 -74
  88. package/dist/{admin-price-detail-D517JYHB.js.map → admin-price-detail-CSI5oKdb.js.map} +1 -1
  89. package/dist/{admin-price-wizard-bj36o3ux.js → admin-price-wizard-CBEcNGvP.js} +38 -38
  90. package/dist/{admin-price-wizard-bj36o3ux.js.map → admin-price-wizard-CBEcNGvP.js.map} +1 -1
  91. package/dist/admin-proposals-dtgijWKz.js +375 -0
  92. package/dist/admin-proposals-dtgijWKz.js.map +1 -0
  93. package/dist/admin-provider-prices-ChuponcZ.js +246 -0
  94. package/dist/admin-provider-prices-ChuponcZ.js.map +1 -0
  95. package/dist/{admin-range-picker-D2aFF8IV.js → admin-range-picker-De36L-AP.js} +12 -12
  96. package/dist/{admin-range-picker-D2aFF8IV.js.map → admin-range-picker-De36L-AP.js.map} +1 -1
  97. package/dist/admin-records-CUHUOXAU.js +391 -0
  98. package/dist/admin-records-CUHUOXAU.js.map +1 -0
  99. package/dist/{admin-reports-D-ob04d4.js → admin-reports-BFGS_PWf.js} +45 -45
  100. package/dist/{admin-reports-D-ob04d4.js.map → admin-reports-BFGS_PWf.js.map} +1 -1
  101. package/dist/{admin-select-C8O7nx72.js → admin-select-BUcEU5Rg.js} +2 -2
  102. package/dist/{admin-select-C8O7nx72.js.map → admin-select-BUcEU5Rg.js.map} +1 -1
  103. package/dist/{admin-settings-Bs6cLcqi.js → admin-settings-DYC-c7mJ.js} +296 -296
  104. package/dist/{admin-settings-Bs6cLcqi.js.map → admin-settings-DYC-c7mJ.js.map} +1 -1
  105. package/dist/admin-shared-CzG8Pan3.js +222 -0
  106. package/dist/admin-shared-CzG8Pan3.js.map +1 -0
  107. package/dist/{admin-skeleton-wfocg2PJ.js → admin-skeleton-B0yzYY_X.js} +2 -2
  108. package/dist/{admin-skeleton-wfocg2PJ.js.map → admin-skeleton-B0yzYY_X.js.map} +1 -1
  109. package/dist/{admin-status-badge-D_gDMrht.js → admin-status-badge-0-K37EfN.js} +7 -2
  110. package/dist/admin-status-badge-0-K37EfN.js.map +1 -0
  111. package/dist/{admin-subscriptions-DYR1RGMO.js → admin-subscriptions-CvW-YFs0.js} +74 -74
  112. package/dist/{admin-subscriptions-DYR1RGMO.js.map → admin-subscriptions-CvW-YFs0.js.map} +1 -1
  113. package/dist/{admin-switch-F5D0AYjT.js → admin-switch-DDorugaw.js} +2 -2
  114. package/dist/{admin-switch-F5D0AYjT.js.map → admin-switch-DDorugaw.js.map} +1 -1
  115. package/dist/{admin-table-nUij5fLc.js → admin-table-BU6Tie69.js} +2 -2
  116. package/dist/{admin-table-nUij5fLc.js.map → admin-table-BU6Tie69.js.map} +1 -1
  117. package/dist/{admin-tabs-C3myjKdr.js → admin-tabs-D5lqdVcC.js} +2 -2
  118. package/dist/{admin-tabs-C3myjKdr.js.map → admin-tabs-D5lqdVcC.js.map} +1 -1
  119. package/dist/{admin-textarea-v-L-PXIc.js → admin-textarea-Dc6lnEub.js} +2 -2
  120. package/dist/{admin-textarea-v-L-PXIc.js.map → admin-textarea-Dc6lnEub.js.map} +1 -1
  121. package/dist/{admin-typed-confirm-dialog-BLgpuikW.js → admin-typed-confirm-dialog-Bk6XxmPb.js} +6 -6
  122. package/dist/{admin-typed-confirm-dialog-BLgpuikW.js.map → admin-typed-confirm-dialog-Bk6XxmPb.js.map} +1 -1
  123. package/dist/{admin-utils-6yE4YIVI.js → admin-utils-B9eEBNsR.js} +398 -146
  124. package/dist/admin-utils-B9eEBNsR.js.map +1 -0
  125. package/dist/{admin-widget-viz-BiEfckd4.js → admin-widget-viz-8aukE3v_.js} +34 -34
  126. package/dist/{admin-widget-viz-BiEfckd4.js.map → admin-widget-viz-8aukE3v_.js.map} +1 -1
  127. package/dist/admin.css +1 -1
  128. package/dist/admin.js +489 -265
  129. package/dist/admin.js.map +1 -1
  130. package/dist/client/generated/error-codes.d.ts +1 -1
  131. package/dist/client/generated/routes.d.ts +94 -22
  132. package/dist/client/generated/wire.d.ts +90 -22
  133. package/dist/index.js +1 -1
  134. package/dist/styles.css +1 -1
  135. package/package.json +2 -2
  136. package/dist/admin-attempts-BLeeKABa.js.map +0 -1
  137. package/dist/admin-catalog-ggiDgWsR.js.map +0 -1
  138. package/dist/admin-detail-D2zcz_Xm.js +0 -710
  139. package/dist/admin-dom-VkcwevWr.js.map +0 -1
  140. package/dist/admin-ops-DT8epiXg.js +0 -217
  141. package/dist/admin-ops-DT8epiXg.js.map +0 -1
  142. package/dist/admin-status-badge-D_gDMrht.js.map +0 -1
  143. package/dist/admin-utils-6yE4YIVI.js.map +0 -1
@@ -1,11 +1,11 @@
1
- import { E as e, p as t, w as n } from "./admin-utils-6yE4YIVI.js";
2
- import { t as r } from "./admin-button-a7bDFgp0.js";
3
- import { t as i } from "./admin-input-C-S_RGGo.js";
1
+ import { D as e, T as t, p as n } from "./admin-utils-B9eEBNsR.js";
2
+ import { t as r } from "./admin-button-CrcYk5r0.js";
3
+ import { t as i } from "./admin-input-DJAK9nmk.js";
4
4
  import { c as a, l as o, s } from "./admin-format-DoohJ7Fg.js";
5
5
  import { t as c } from "./admin-form-field-errors-hbUMIriS.js";
6
- import { t as l } from "./admin-badge-CrEqD9Ew.js";
7
- import { a as u, i as d, n as f, o as ee, r as p, s as m, t as h } from "./admin-dialog-CiAw5vx-.js";
8
- import { t as g } from "./admin-label-DPVYDdSO.js";
6
+ import { t as l } from "./admin-badge-pgG6D9-a.js";
7
+ import { a as u, i as d, n as f, o as ee, r as p, s as m, t as h } from "./admin-dialog-BSRf9Zre.js";
8
+ import { t as g } from "./admin-label-aviN9Gng.js";
9
9
  import { n as _ } from "./admin-dialog-width-BPrgdYlj.js";
10
10
  import { n as v } from "./admin-price-format-BVUpDoSC.js";
11
11
  import * as y from "react";
@@ -51,7 +51,7 @@ var N = (e) => e.toISOString().slice(0, 10), P = (e, t) => ({
51
51
  effectiveAt: t?.migration?.effective_at ? N(new Date(t.migration.effective_at)) : ""
52
52
  });
53
53
  function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
54
- let { toast: re, toastApiError: L, adminMutations: R, adminQueries: z } = t(), { id: B } = e(), V = x(), [H, U] = y.useState(() => !!I), [W, G] = y.useState(() => I ? 3 : 1), K = b(R.previewPriceChange()), q = b(R.changePrice(V)), J = K.data?.matched ?? I?.affected_count ?? null, { data: Y } = te({
54
+ let { toast: re, toastApiError: L, adminMutations: R, adminQueries: z } = n(), { id: B } = e(), V = x(), [H, U] = y.useState(() => !!I), [W, G] = y.useState(() => I ? 3 : 1), K = b(R.previewPriceChange()), q = b(R.changePrice(V)), J = K.data?.matched ?? I?.affected_count ?? null, { data: Y } = te({
55
55
  ...z.merchantConfiguration(),
56
56
  enabled: H
57
57
  }), X = Y?.reprice_notice_window_days ?? 30, [Z] = y.useState(() => /* @__PURE__ */ new Date()), Q = T({
@@ -100,14 +100,14 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
100
100
  size: "sm",
101
101
  disabled: !0,
102
102
  title: o.customer_amount ? "This price lets customers choose an amount. Change its limits through a catalog application or the client." : o.archived ? "This is an archived version. Change the current price for this key instead." : "Load the product before changing its price.",
103
- children: /* @__PURE__ */ C(n, { id: "Change price" })
103
+ children: /* @__PURE__ */ C(t, { id: "Change price" })
104
104
  }) : /* @__PURE__ */ w(h, {
105
105
  open: H,
106
106
  onOpenChange: $,
107
107
  children: [!I && /* @__PURE__ */ C(m, { render: /* @__PURE__ */ C(r, {
108
108
  variant: "outline",
109
109
  size: "sm",
110
- children: /* @__PURE__ */ C(n, { id: "Change price" })
110
+ children: /* @__PURE__ */ C(t, { id: "Change price" })
111
111
  }) }), /* @__PURE__ */ C(f, {
112
112
  className: _,
113
113
  children: /* @__PURE__ */ C("form", {
@@ -117,23 +117,23 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
117
117
  },
118
118
  children: /* @__PURE__ */ C(Q.Subscribe, {
119
119
  selector: (e) => [e.values, e.isSubmitting],
120
- children: ([e, t]) => {
120
+ children: ([e, n]) => {
121
121
  let f = a(e.amountInput, o.currency) ?? o.unit_amount, m = E(f, o.unit_amount), h = O(m, Z, X), _ = e.mode !== "migrate" || !!e.effectiveAt && A(m, new Date(e.effectiveAt), Z, X);
122
122
  return /* @__PURE__ */ w(S, { children: [
123
123
  /* @__PURE__ */ w(u, { children: [/* @__PURE__ */ w(ee, {
124
124
  className: "flex items-center gap-2",
125
125
  children: [
126
- /* @__PURE__ */ C(n, { id: "Change price for " }),
126
+ /* @__PURE__ */ C(t, { id: "Change price for " }),
127
127
  j,
128
128
  I && /* @__PURE__ */ C(l, {
129
129
  variant: "secondary",
130
- children: /* @__PURE__ */ C(n, { id: "drafted by copilot" })
130
+ children: /* @__PURE__ */ C(t, { id: "drafted by copilot" })
131
131
  })
132
132
  ]
133
133
  }), /* @__PURE__ */ w(p, { children: [
134
- /* @__PURE__ */ C(n, { id: "Step " }),
134
+ /* @__PURE__ */ C(t, { id: "Step " }),
135
135
  W,
136
- /* @__PURE__ */ C(n, { id: " of 3:" }),
136
+ /* @__PURE__ */ C(t, { id: " of 3:" }),
137
137
  " ",
138
138
  W === 1 ? "new amount" : W === 2 ? "migration plan" : "review"
139
139
  ] })] }),
@@ -144,13 +144,13 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
144
144
  className: "grid grid-cols-2 gap-3 text-sm",
145
145
  children: [/* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
146
146
  className: "text-xs text-muted-foreground uppercase",
147
- children: /* @__PURE__ */ C(n, { id: "Current amount" })
147
+ children: /* @__PURE__ */ C(t, { id: "Current amount" })
148
148
  }), /* @__PURE__ */ C("p", {
149
149
  className: "font-medium",
150
150
  children: s(o.unit_amount, o.currency)
151
151
  })] }), /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C("p", {
152
152
  className: "text-xs text-muted-foreground uppercase",
153
- children: /* @__PURE__ */ C(n, { id: "Currency · interval" })
153
+ children: /* @__PURE__ */ C(t, { id: "Currency · interval" })
154
154
  }), /* @__PURE__ */ w("p", {
155
155
  className: "font-medium",
156
156
  children: [
@@ -172,7 +172,7 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
172
172
  children: [
173
173
  /* @__PURE__ */ C(g, {
174
174
  htmlFor: B("wiz-amount"),
175
- children: /* @__PURE__ */ C(n, { id: "New amount (major units)" })
175
+ children: /* @__PURE__ */ C(t, { id: "New amount (major units)" })
176
176
  }),
177
177
  /* @__PURE__ */ C(i, {
178
178
  id: B("wiz-amount"),
@@ -191,13 +191,13 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
191
191
  m !== "unchanged" && /* @__PURE__ */ w("p", {
192
192
  className: "text-sm text-muted-foreground",
193
193
  children: [
194
- /* @__PURE__ */ C(n, { id: "This is a price" }),
194
+ /* @__PURE__ */ C(t, { id: "This is a price" }),
195
195
  " ",
196
196
  /* @__PURE__ */ C("span", {
197
197
  className: "font-medium text-foreground",
198
198
  children: m === "increase" ? "increase" : "decrease"
199
199
  }),
200
- /* @__PURE__ */ C(n, { id: ". Currency and interval stay locked to the current price." })
200
+ /* @__PURE__ */ C(t, { id: ". Currency and interval stay locked to the current price." })
201
201
  ]
202
202
  })
203
203
  ]
@@ -224,14 +224,14 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
224
224
  }), /* @__PURE__ */ w("span", { children: [
225
225
  /* @__PURE__ */ C("span", {
226
226
  className: "font-medium",
227
- children: /* @__PURE__ */ C(n, { id: "Grandfather." })
227
+ children: /* @__PURE__ */ C(t, { id: "Grandfather." })
228
228
  }),
229
229
  " ",
230
- /* @__PURE__ */ C(n, { id: "Existing subscribers keep the current price." }),
230
+ /* @__PURE__ */ C(t, { id: "Existing subscribers keep the current price." }),
231
231
  m === "increase" && /* @__PURE__ */ C(l, {
232
232
  variant: "secondary",
233
233
  className: "ml-2",
234
- children: /* @__PURE__ */ C(n, { id: "default" })
234
+ children: /* @__PURE__ */ C(t, { id: "default" })
235
235
  })
236
236
  ] })]
237
237
  }), /* @__PURE__ */ w("label", {
@@ -245,14 +245,14 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
245
245
  }), /* @__PURE__ */ w("span", { children: [
246
246
  /* @__PURE__ */ C("span", {
247
247
  className: "font-medium",
248
- children: /* @__PURE__ */ C(n, { id: "Migrate." })
248
+ children: /* @__PURE__ */ C(t, { id: "Migrate." })
249
249
  }),
250
250
  " ",
251
- /* @__PURE__ */ C(n, { id: "Move everyone to the new price at their first renewal on or after a date you choose." }),
251
+ /* @__PURE__ */ C(t, { id: "Move everyone to the new price at their first renewal on or after a date you choose." }),
252
252
  m === "decrease" && /* @__PURE__ */ C(l, {
253
253
  variant: "secondary",
254
254
  className: "ml-2",
255
- children: /* @__PURE__ */ C(n, { id: "default" })
255
+ children: /* @__PURE__ */ C(t, { id: "default" })
256
256
  })
257
257
  ] })]
258
258
  })]
@@ -265,7 +265,7 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
265
265
  children: [
266
266
  /* @__PURE__ */ C(g, {
267
267
  htmlFor: B("wiz-effective"),
268
- children: /* @__PURE__ */ C(n, { id: "Effective date" })
268
+ children: /* @__PURE__ */ C(t, { id: "Effective date" })
269
269
  }),
270
270
  /* @__PURE__ */ C(i, {
271
271
  id: B("wiz-effective"),
@@ -278,22 +278,22 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
278
278
  m === "increase" ? /* @__PURE__ */ w("p", {
279
279
  className: "text-xs text-muted-foreground",
280
280
  children: [
281
- /* @__PURE__ */ C(n, { id: "Must be at least " }),
281
+ /* @__PURE__ */ C(t, { id: "Must be at least " }),
282
282
  X,
283
- /* @__PURE__ */ C(n, { id: " days away. Card networks require that much notice before a price goes up. You can change the number in Settings." })
283
+ /* @__PURE__ */ C(t, { id: " days away. Card networks require that much notice before a price goes up. You can change the number in Settings." })
284
284
  ]
285
285
  }) : /* @__PURE__ */ C("p", {
286
286
  className: "text-xs text-muted-foreground",
287
- children: /* @__PURE__ */ C(n, { id: "A price going down needs no notice, so today is fine." })
287
+ children: /* @__PURE__ */ C(t, { id: "A price going down needs no notice, so today is fine." })
288
288
  }),
289
289
  !_ && /* @__PURE__ */ C("p", {
290
290
  className: "text-xs text-destructive",
291
291
  role: "alert",
292
- children: /* @__PURE__ */ C(n, { id: "Pick a later date." })
292
+ children: /* @__PURE__ */ C(t, { id: "Pick a later date." })
293
293
  }),
294
294
  /* @__PURE__ */ C("p", {
295
295
  className: "text-xs text-muted-foreground",
296
- children: /* @__PURE__ */ C(n, { id: "A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm." })
296
+ children: /* @__PURE__ */ C(t, { id: "A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm." })
297
297
  })
298
298
  ]
299
299
  })
@@ -321,26 +321,26 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
321
321
  W > 1 && /* @__PURE__ */ C(r, {
322
322
  type: "button",
323
323
  variant: "outline",
324
- disabled: t,
324
+ disabled: n,
325
325
  onClick: () => G((e) => e - 1),
326
- children: /* @__PURE__ */ C(n, { id: "Back" })
326
+ children: /* @__PURE__ */ C(t, { id: "Back" })
327
327
  }),
328
328
  W === 1 && /* @__PURE__ */ C(r, {
329
329
  type: "button",
330
330
  disabled: !e.amountInput || m === "unchanged" || BigInt(f) <= 0n,
331
331
  onClick: ae,
332
- children: /* @__PURE__ */ C(n, { id: "Next" })
332
+ children: /* @__PURE__ */ C(t, { id: "Next" })
333
333
  }),
334
334
  W === 2 && /* @__PURE__ */ C(r, {
335
335
  type: "button",
336
336
  disabled: !_ || K.isPending,
337
337
  onClick: () => G(3),
338
- children: /* @__PURE__ */ C(n, { id: "Next" })
338
+ children: /* @__PURE__ */ C(t, { id: "Next" })
339
339
  }),
340
340
  W === 3 && /* @__PURE__ */ C(r, {
341
341
  type: "submit",
342
- disabled: t,
343
- children: t ? "Working…" : "Confirm"
342
+ disabled: n,
343
+ children: n ? "Working…" : "Confirm"
344
344
  })
345
345
  ] })
346
346
  ] });
@@ -353,4 +353,4 @@ function F({ price: o, productName: j, productKey: F, draft: I, onDone: ne }) {
353
353
  //#endregion
354
354
  export { F as t };
355
355
 
356
- //# sourceMappingURL=admin-price-wizard-bj36o3ux.js.map
356
+ //# sourceMappingURL=admin-price-wizard-CBEcNGvP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin-price-wizard-bj36o3ux.js","names":[],"sources":["../src/admin/pages/catalog/price-wizard-logic.ts","../src/admin/pages/catalog/price-wizard.tsx"],"sourcesContent":["// Pure logic for the price-change wizard, kept apart from React for unit tests.\nimport { formatNativeAmount } from \"#orck/admin/lib/format\"\n\nexport type PriceDirection = \"increase\" | \"decrease\" | \"unchanged\"\n\nexport function detectDirection(\n newAmount: string,\n currentAmount: string\n): PriceDirection {\n const next = BigInt(newAmount)\n const current = BigInt(currentAmount)\n if (next > current) return \"increase\"\n if (next < current) return \"decrease\"\n return \"unchanged\"\n}\n\nexport type MigrationMode = \"grandfather\" | \"migrate\"\n\n// DEFAULT_NOTICE_WINDOW_DAYS is the fallback until the merchant's\n// reprice_notice_window_days loads; it mirrors\n// subscriptions.DefaultPriceIncreaseNoticeDays so the UI never under-gates.\n// The server enforces the window too (price_increase_notice_too_short).\nexport const DEFAULT_NOTICE_WINDOW_DAYS = 30\n\n// defaultMigrationMode is the direction-aware Step 2 default: an increase\n// grandfathers (no new action), a decrease migrates now (never grandfathered).\nexport function defaultMigrationMode(direction: PriceDirection): MigrationMode {\n return direction === \"decrease\" ? \"migrate\" : \"grandfather\"\n}\n\n// minEffectiveDate is the earliest allowed migration date, or null when there\n// is no minimum (a decrease needs no notice).\nexport function minEffectiveDate(\n direction: PriceDirection,\n now: Date,\n noticeWindowDays: number\n): Date | null {\n if (direction !== \"increase\") return null\n const min = new Date(now)\n min.setUTCDate(min.getUTCDate() + noticeWindowDays)\n return min\n}\n\n// defaultEffectiveDate is Step 2's pre-filled migration date: the notice\n// window's floor for an increase, \"now\" for a decrease.\nexport function defaultEffectiveDate(\n direction: PriceDirection,\n now: Date,\n noticeWindowDays: number\n): Date {\n return minEffectiveDate(direction, now, noticeWindowDays) ?? now\n}\n\n// isEffectiveDateValid enforces the console-side notice-window gate: an\n// increase+migrate plan may not pick a date inside the notice window.\nexport function isEffectiveDateValid(\n direction: PriceDirection,\n effectiveAt: Date,\n now: Date,\n noticeWindowDays: number\n): boolean {\n const min = minEffectiveDate(direction, now, noticeWindowDays)\n return !min || effectiveAt.getTime() >= min.getTime()\n}\n\nexport interface MigrationPlan {\n mode: MigrationMode\n // ISO instant; only meaningful when mode === \"migrate\".\n effectiveAt: string\n}\n\nconst dateLabel = (iso: string) =>\n new Date(iso).toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n })\n\n// buildReviewText renders Step 3's plan in words, e.g. \"New subscribers pay $12\n// immediately. 1,204 existing subscribers keep $10 until Sep 1, then move to\n// $12 at their next renewal. Notices go out on confirm.\"\nexport function buildReviewText(params: {\n newAmount: string\n currentAmount: string\n currency: string\n affectedCount: number\n plan: MigrationPlan\n now: Date\n}): string {\n const { newAmount, currentAmount, currency, affectedCount, plan, now } =\n params\n const newLabel = formatNativeAmount(newAmount, currency)\n const oldLabel = formatNativeAmount(currentAmount, currency)\n const lead = `New subscribers pay ${newLabel} immediately.`\n\n if (affectedCount === 0) {\n return `${lead} No existing subscribers are on a prior version of this price.`\n }\n const subj = `${affectedCount.toLocaleString()} existing subscriber${affectedCount === 1 ? \"\" : \"s\"}`\n\n if (plan.mode === \"grandfather\") {\n return `${lead} ${subj} keep ${oldLabel} forever (grandfathered).`\n }\n\n // The engine notifies each affected subscriber at schedule time, however\n // far out effective_at is: always say so.\n const effective = new Date(plan.effectiveAt)\n const immediate = effective.getTime() <= now.getTime()\n if (immediate) {\n return `${lead} ${subj} move to ${newLabel} at their next renewal. Notices go out on confirm.`\n }\n return `${lead} ${subj} keep ${oldLabel} until ${dateLabel(plan.effectiveAt)}, then move to ${newLabel} at their next renewal. Notices go out on confirm.`\n}\n","import { AdminMessage, useAdminUI } from \"#orck/admin/ui-context\"\nimport { useAdminServices } from \"#orck/admin/context\"\nimport * as React from \"react\"\n\nimport { useForm } from \"@tanstack/react-form\"\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nimport { FormFieldErrors } from \"#orck/admin/components/form-field-errors\"\nimport { Badge } from \"#orck/admin/components/ui/badge\"\nimport { Button } from \"#orck/admin/components/ui/button\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"#orck/admin/components/ui/dialog\"\nimport { Input } from \"#orck/admin/components/ui/input\"\nimport { Label } from \"#orck/admin/components/ui/label\"\nimport type { PriceChangeDraft } from \"#orck/admin/lib/api/copilot\"\nimport { DIALOG_FORM } from \"#orck/admin/lib/dialog-width\"\nimport type { Price } from \"#orck/client/generated/wire\"\nimport {\n formatNativeAmount,\n nativeAmountFromInput,\n nativeAmountToInput,\n} from \"#orck/admin/lib/format\"\n\nimport { priceIntervalLabel } from \"#orck/admin/pages/catalog/price-format\"\nimport {\n buildReviewText,\n defaultEffectiveDate,\n defaultMigrationMode,\n DEFAULT_NOTICE_WINDOW_DAYS,\n detectDirection,\n isEffectiveDateValid,\n minEffectiveDate,\n type MigrationMode,\n} from \"#orck/admin/pages/catalog/price-wizard-logic\"\n\nconst toDateInputValue = (d: Date) => d.toISOString().slice(0, 10)\n\nconst priceChangeFormValues = (price: Price, draft?: PriceChangeDraft) => ({\n amountInput: nativeAmountToInput(\n draft?.new_amount ?? price.unit_amount,\n price.currency\n ),\n mode: (draft?.migration ? \"migrate\" : \"grandfather\") as MigrationMode,\n effectiveAt: draft?.migration?.effective_at\n ? toDateInputValue(new Date(draft.migration.effective_at))\n : \"\",\n})\n\n// PriceChangeWizard is the #777 console price-change wizard — the ONLY\n// amount-edit affordance on a price. Three steps: new amount -> migration\n// plan (direction-aware defaults, live affected-count preview, notice-window\n// gate on increase+migrate) -> review in words, then confirm applies the\n// catalog price update followed (if migrating) by the price migration.\n//\n// draft (#779): when the catalog copilot proposed this change, the dialog\n// opens PRE-FILLED straight at Step 3 (review) — the affected count already\n// rode in the draft, so no extra preview call is needed. Confirm behaves\n// EXACTLY as a hand-typed change (the same create-price and price-migration\n// calls).\nexport function PriceChangeWizard({\n price,\n productName,\n productKey,\n draft,\n onDone,\n}: {\n price: Price\n productName: string\n productKey: string | undefined\n draft?: PriceChangeDraft\n onDone?: () => void\n}) {\n const { toast, toastApiError, adminMutations, adminQueries } =\n useAdminServices()\n\n const { id: adminId } = useAdminUI()\n\n const queryClient = useQueryClient()\n const [open, setOpen] = React.useState(() => !!draft)\n const [step, setStep] = React.useState<1 | 2 | 3>(() => (draft ? 3 : 1))\n const previewPriceChange = useMutation(adminMutations.previewPriceChange())\n const changePrice = useMutation(adminMutations.changePrice(queryClient))\n const affectedCount =\n previewPriceChange.data?.matched ?? draft?.affected_count ?? null\n const { data: configuration } = useQuery({\n ...adminQueries.merchantConfiguration(),\n enabled: open,\n })\n const noticeWindowDays =\n configuration?.reprice_notice_window_days ?? DEFAULT_NOTICE_WINDOW_DAYS\n\n const [now] = React.useState(() => new Date())\n const form = useForm({\n defaultValues: priceChangeFormValues(price, draft),\n onSubmit: async ({ value }) => {\n if (!productKey || price.customer_amount) return\n const newAmount = nativeAmountFromInput(value.amountInput, price.currency)\n if (newAmount === null || BigInt(newAmount) <= 0n) return\n\n try {\n await changePrice.mutateAsync({\n price: {\n product_id: price.product_id,\n unit_amount: newAmount,\n currency: price.currency,\n access_duration_hours: price.access_duration_hours ?? undefined,\n billing_interval_hours: price.billing_interval_hours ?? undefined,\n trial_unit_amount: price.trial_unit_amount ?? undefined,\n trial_duration_hours: price.trial_duration_hours ?? undefined,\n key: price.key,\n sell_via: price.sell_via ?? undefined,\n expected_revision: price.revision,\n },\n migration:\n value.mode === \"migrate\"\n ? {\n productKey,\n priceKey: price.key,\n effectiveAt: new Date(value.effectiveAt).toISOString(),\n }\n : undefined,\n })\n toast.success(\n value.mode === \"migrate\"\n ? \"Price updated and migration scheduled\"\n : \"Price updated\"\n )\n handleOpenChange(false)\n onDone?.()\n } catch (err) {\n toastApiError(err, \"Change price\")\n }\n },\n })\n\n const reset = () => {\n setStep(1)\n form.reset(priceChangeFormValues(price))\n previewPriceChange.reset()\n }\n\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n reset()\n }\n setOpen(next)\n }\n\n const enterStep2 = () => {\n if (!productKey || price.customer_amount) return\n const amount = nativeAmountFromInput(\n form.state.values.amountInput,\n price.currency\n )\n const direction = detectDirection(\n amount ?? price.unit_amount,\n price.unit_amount\n )\n form.setFieldValue(\"mode\", defaultMigrationMode(direction))\n form.setFieldValue(\n \"effectiveAt\",\n toDateInputValue(defaultEffectiveDate(direction, now, noticeWindowDays))\n )\n setStep(2)\n previewPriceChange.reset()\n previewPriceChange.mutate(\n { productKey, priceKey: price.key },\n { onError: (err) => toastApiError(err, \"Preview affected subscribers\") }\n )\n }\n\n // Archived (prior-version) rows are history, not the editable current\n // price. Each product/key pair has exactly one live edit target.\n // Wait for the product before allowing previews or scheduling a migration.\n if (price.archived || !productKey || price.customer_amount) {\n return (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled\n title={\n price.customer_amount\n ? \"This price lets customers choose an amount. Change its limits through a catalog application or the client.\"\n : price.archived\n ? \"This is an archived version. Change the current price for this key instead.\"\n : \"Load the product before changing its price.\"\n }\n >\n <AdminMessage id={\"Change price\"} />\n </Button>\n )\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n {!draft && (\n <DialogTrigger\n render={\n <Button variant=\"outline\" size=\"sm\">\n <AdminMessage id={\"Change price\"} />\n </Button>\n }\n />\n )}\n <DialogContent className={DIALOG_FORM}>\n <form\n className=\"grid gap-4\"\n onSubmit={(event) => {\n event.preventDefault()\n event.stopPropagation()\n if (step !== 3) return\n void form.handleSubmit()\n }}\n >\n <form.Subscribe\n selector={(state) => [state.values, state.isSubmitting] as const}\n >\n {([values, isSubmitting]) => {\n const newAmount =\n nativeAmountFromInput(values.amountInput, price.currency) ??\n price.unit_amount\n const direction = detectDirection(newAmount, price.unit_amount)\n const minDate = minEffectiveDate(direction, now, noticeWindowDays)\n const dateValid =\n values.mode !== \"migrate\" ||\n (!!values.effectiveAt &&\n isEffectiveDateValid(\n direction,\n new Date(values.effectiveAt),\n now,\n noticeWindowDays\n ))\n\n return (\n <>\n <DialogHeader>\n <DialogTitle className=\"flex items-center gap-2\">\n <AdminMessage id={\"Change price for \"} />\n {productName}\n {draft && (\n <Badge variant=\"secondary\">\n <AdminMessage id={\"drafted by copilot\"} />\n </Badge>\n )}\n </DialogTitle>\n <DialogDescription>\n <AdminMessage id={\"Step \"} />\n {step}\n <AdminMessage id={\" of 3:\"} />{\" \"}\n {step === 1\n ? \"new amount\"\n : step === 2\n ? \"migration plan\"\n : \"review\"}\n </DialogDescription>\n </DialogHeader>\n\n {step === 1 && (\n <div className=\"grid gap-3\">\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <p className=\"text-xs text-muted-foreground uppercase\">\n <AdminMessage id={\"Current amount\"} />\n </p>\n <p className=\"font-medium\">\n {formatNativeAmount(\n price.unit_amount,\n price.currency\n )}\n </p>\n </div>\n <div>\n <p className=\"text-xs text-muted-foreground uppercase\">\n <AdminMessage id={\"Currency · interval\"} />\n </p>\n <p className=\"font-medium\">\n {price.currency.toUpperCase()} ·{\" \"}\n {priceIntervalLabel(price)}\n </p>\n </div>\n </div>\n <form.Field\n name=\"amountInput\"\n validators={{\n onBlur: ({ value }) => {\n const amount = nativeAmountFromInput(\n value,\n price.currency\n )\n if (amount === null || BigInt(amount) <= 0n) {\n return \"Enter an amount greater than zero.\"\n }\n return undefined\n },\n }}\n >\n {(field) => (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(\"wiz-amount\")}>\n <AdminMessage id={\"New amount (major units)\"} />\n </Label>\n <Input\n id={adminId(\"wiz-amount\")}\n type=\"number\"\n step=\"any\"\n min=\"0\"\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n autoFocus\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </div>\n )}\n </form.Field>\n {direction !== \"unchanged\" && (\n <p className=\"text-sm text-muted-foreground\">\n <AdminMessage id={\"This is a price\"} />{\" \"}\n <span className=\"font-medium text-foreground\">\n {direction === \"increase\" ? \"increase\" : \"decrease\"}\n </span>\n <AdminMessage\n id={\n \". Currency and interval stay locked to the current price.\"\n }\n />\n </p>\n )}\n </div>\n )}\n\n {step === 2 && (\n <div className=\"grid gap-3\">\n <p className=\"text-sm\">\n {affectedCount === null && previewPriceChange.isPending\n ? \"Checking affected subscribers…\"\n : `${(affectedCount ?? 0).toLocaleString()} active subscription${affectedCount === 1 ? \"\" : \"s\"} on prior versions of ${price.key}.`}\n </p>\n <form.Field name=\"mode\">\n {(field) => (\n <div className=\"grid gap-2\">\n <label className=\"flex items-start gap-2 rounded-md border p-3 text-sm\">\n <input\n type=\"radio\"\n name={field.name}\n className=\"mt-1\"\n checked={field.state.value === \"grandfather\"}\n onChange={() =>\n field.handleChange(\"grandfather\")\n }\n />\n <span>\n <span className=\"font-medium\">\n <AdminMessage id={\"Grandfather.\"} />\n </span>{\" \"}\n <AdminMessage\n id={\n \"Existing subscribers keep the current price.\"\n }\n />\n {direction === \"increase\" && (\n <Badge variant=\"secondary\" className=\"ml-2\">\n <AdminMessage id={\"default\"} />\n </Badge>\n )}\n </span>\n </label>\n <label className=\"flex items-start gap-2 rounded-md border p-3 text-sm\">\n <input\n type=\"radio\"\n name={field.name}\n className=\"mt-1\"\n checked={field.state.value === \"migrate\"}\n onChange={() => field.handleChange(\"migrate\")}\n />\n <span>\n <span className=\"font-medium\">\n <AdminMessage id={\"Migrate.\"} />\n </span>{\" \"}\n <AdminMessage\n id={\n \"Move everyone to the new price at their first renewal on or after a date you choose.\"\n }\n />\n {direction === \"decrease\" && (\n <Badge variant=\"secondary\" className=\"ml-2\">\n <AdminMessage id={\"default\"} />\n </Badge>\n )}\n </span>\n </label>\n </div>\n )}\n </form.Field>\n {values.mode === \"migrate\" && (\n <form.Field name=\"effectiveAt\">\n {(field) => (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(\"wiz-effective\")}>\n <AdminMessage id={\"Effective date\"} />\n </Label>\n <Input\n id={adminId(\"wiz-effective\")}\n type=\"date\"\n value={field.state.value}\n min={\n minDate\n ? toDateInputValue(minDate)\n : undefined\n }\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n />\n {direction === \"increase\" ? (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage id={\"Must be at least \"} />\n {noticeWindowDays}\n <AdminMessage\n id={\n \" days away. Card networks require that much notice before a price goes up. You can change the number in Settings.\"\n }\n />\n </p>\n ) : (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage\n id={\n \"A price going down needs no notice, so today is fine.\"\n }\n />\n </p>\n )}\n {!dateValid && (\n <p\n className=\"text-xs text-destructive\"\n role=\"alert\"\n >\n <AdminMessage id={\"Pick a later date.\"} />\n </p>\n )}\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage\n id={\n \"A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm.\"\n }\n />\n </p>\n </div>\n )}\n </form.Field>\n )}\n </div>\n )}\n\n {step === 3 && (\n <div className=\"grid gap-3\">\n <p className=\"rounded-md border bg-muted/40 p-3 text-sm\">\n {buildReviewText({\n newAmount,\n currentAmount: price.unit_amount,\n currency: price.currency,\n affectedCount: affectedCount ?? 0,\n plan: {\n mode: values.mode,\n effectiveAt:\n values.mode === \"migrate\"\n ? new Date(values.effectiveAt).toISOString()\n : \"\",\n },\n now,\n })}\n </p>\n </div>\n )}\n\n <DialogFooter>\n {step > 1 && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={isSubmitting}\n onClick={() => setStep((value) => (value - 1) as 1 | 2)}\n >\n <AdminMessage id={\"Back\"} />\n </Button>\n )}\n {step === 1 && (\n <Button\n type=\"button\"\n disabled={\n !values.amountInput ||\n direction === \"unchanged\" ||\n BigInt(newAmount) <= 0n\n }\n onClick={enterStep2}\n >\n <AdminMessage id={\"Next\"} />\n </Button>\n )}\n {step === 2 && (\n <Button\n type=\"button\"\n disabled={!dateValid || previewPriceChange.isPending}\n onClick={() => setStep(3)}\n >\n <AdminMessage id={\"Next\"} />\n </Button>\n )}\n {step === 3 && (\n <Button type=\"submit\" disabled={isSubmitting}>\n {isSubmitting ? \"Working…\" : \"Confirm\"}\n </Button>\n )}\n </DialogFooter>\n </>\n )\n }}\n </form.Subscribe>\n </form>\n </DialogContent>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AG,WAAU;SACV,UAAA,EAAgB;UACf;UACA,eAAe,EAAM;UACrB,UAAU,EAAM;UAChB,eAAe,KAAiB;UAChC,MAAM;WACJ,MAAM,EAAO;WACb,aACE,EAAO,SAAS,YACZ,IAAI,KAAK,EAAO,WAAW,CAAC,CAAC,YAAY,IACzC;UACR;UACA;SACF,CAAC;QACA,CAAA;OACA,CAAA;OAGP,kBAAC,GAAD,EAAA,UAAA;QACG,IAAO,KACN,kBAAC,GAAD;SACE,MAAK;SACL,SAAQ;SACR,UAAU;SACV,eAAe,GAAS,MAAW,IAAQ,CAAW;SAEtD,UAAA,kBAAC,GAAD,EAAc,IAAI,OAAS,CAAA;QACrB,CAAA;QAET,MAAS,KACR,kBAAC,GAAD;SACE,MAAK;SACL,UACE,CAAC,EAAO,eACR,MAAc,eACd,OAAO,CAAS,KAAK;SAEvB,SAAS;SAET,UAAA,kBAAC,GAAD,EAAc,IAAI,OAAS,CAAA;QACrB,CAAA;QAET,MAAS,KACR,kBAAC,GAAD;SACE,MAAK;SACL,UAAU,CAAC,KAAa,EAAmB;SAC3C,eAAe,EAAQ,CAAC;SAExB,UAAA,kBAAC,GAAD,EAAc,IAAI,OAAS,CAAA;QACrB,CAAA;QAET,MAAS,KACR,kBAAC,GAAD;SAAQ,MAAK;SAAS,UAAU;SAC7B,UAAA,IAAe,aAAa;QACvB,CAAA;OAEE,EAAA,CAAA;MACd,EAAA,CAAA;KAEN;IACc,CAAA;GACZ,CAAA;EACO,CAAA,CACT;;AAEZ"}
1
+ {"version":3,"file":"admin-price-wizard-CBEcNGvP.js","names":[],"sources":["../src/admin/pages/catalog/price-wizard-logic.ts","../src/admin/pages/catalog/price-wizard.tsx"],"sourcesContent":["// Pure logic for the price-change wizard, kept apart from React for unit tests.\nimport { formatNativeAmount } from \"#orck/admin/lib/format\"\n\nexport type PriceDirection = \"increase\" | \"decrease\" | \"unchanged\"\n\nexport function detectDirection(\n newAmount: string,\n currentAmount: string\n): PriceDirection {\n const next = BigInt(newAmount)\n const current = BigInt(currentAmount)\n if (next > current) return \"increase\"\n if (next < current) return \"decrease\"\n return \"unchanged\"\n}\n\nexport type MigrationMode = \"grandfather\" | \"migrate\"\n\n// DEFAULT_NOTICE_WINDOW_DAYS is the fallback until the merchant's\n// reprice_notice_window_days loads; it mirrors\n// subscriptions.DefaultPriceIncreaseNoticeDays so the UI never under-gates.\n// The server enforces the window too (price_increase_notice_too_short).\nexport const DEFAULT_NOTICE_WINDOW_DAYS = 30\n\n// defaultMigrationMode is the direction-aware Step 2 default: an increase\n// grandfathers (no new action), a decrease migrates now (never grandfathered).\nexport function defaultMigrationMode(direction: PriceDirection): MigrationMode {\n return direction === \"decrease\" ? \"migrate\" : \"grandfather\"\n}\n\n// minEffectiveDate is the earliest allowed migration date, or null when there\n// is no minimum (a decrease needs no notice).\nexport function minEffectiveDate(\n direction: PriceDirection,\n now: Date,\n noticeWindowDays: number\n): Date | null {\n if (direction !== \"increase\") return null\n const min = new Date(now)\n min.setUTCDate(min.getUTCDate() + noticeWindowDays)\n return min\n}\n\n// defaultEffectiveDate is Step 2's pre-filled migration date: the notice\n// window's floor for an increase, \"now\" for a decrease.\nexport function defaultEffectiveDate(\n direction: PriceDirection,\n now: Date,\n noticeWindowDays: number\n): Date {\n return minEffectiveDate(direction, now, noticeWindowDays) ?? now\n}\n\n// isEffectiveDateValid enforces the console-side notice-window gate: an\n// increase+migrate plan may not pick a date inside the notice window.\nexport function isEffectiveDateValid(\n direction: PriceDirection,\n effectiveAt: Date,\n now: Date,\n noticeWindowDays: number\n): boolean {\n const min = minEffectiveDate(direction, now, noticeWindowDays)\n return !min || effectiveAt.getTime() >= min.getTime()\n}\n\nexport interface MigrationPlan {\n mode: MigrationMode\n // ISO instant; only meaningful when mode === \"migrate\".\n effectiveAt: string\n}\n\nconst dateLabel = (iso: string) =>\n new Date(iso).toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n })\n\n// buildReviewText renders Step 3's plan in words, e.g. \"New subscribers pay $12\n// immediately. 1,204 existing subscribers keep $10 until Sep 1, then move to\n// $12 at their next renewal. Notices go out on confirm.\"\nexport function buildReviewText(params: {\n newAmount: string\n currentAmount: string\n currency: string\n affectedCount: number\n plan: MigrationPlan\n now: Date\n}): string {\n const { newAmount, currentAmount, currency, affectedCount, plan, now } =\n params\n const newLabel = formatNativeAmount(newAmount, currency)\n const oldLabel = formatNativeAmount(currentAmount, currency)\n const lead = `New subscribers pay ${newLabel} immediately.`\n\n if (affectedCount === 0) {\n return `${lead} No existing subscribers are on a prior version of this price.`\n }\n const subj = `${affectedCount.toLocaleString()} existing subscriber${affectedCount === 1 ? \"\" : \"s\"}`\n\n if (plan.mode === \"grandfather\") {\n return `${lead} ${subj} keep ${oldLabel} forever (grandfathered).`\n }\n\n // The engine notifies each affected subscriber at schedule time, however\n // far out effective_at is: always say so.\n const effective = new Date(plan.effectiveAt)\n const immediate = effective.getTime() <= now.getTime()\n if (immediate) {\n return `${lead} ${subj} move to ${newLabel} at their next renewal. Notices go out on confirm.`\n }\n return `${lead} ${subj} keep ${oldLabel} until ${dateLabel(plan.effectiveAt)}, then move to ${newLabel} at their next renewal. Notices go out on confirm.`\n}\n","import { AdminMessage, useAdminUI } from \"#orck/admin/ui-context\"\nimport { useAdminServices } from \"#orck/admin/context\"\nimport * as React from \"react\"\n\nimport { useForm } from \"@tanstack/react-form\"\nimport { useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\"\n\nimport { FormFieldErrors } from \"#orck/admin/components/form-field-errors\"\nimport { Badge } from \"#orck/admin/components/ui/badge\"\nimport { Button } from \"#orck/admin/components/ui/button\"\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"#orck/admin/components/ui/dialog\"\nimport { Input } from \"#orck/admin/components/ui/input\"\nimport { Label } from \"#orck/admin/components/ui/label\"\nimport type { PriceChangeDraft } from \"#orck/admin/lib/api/copilot\"\nimport { DIALOG_FORM } from \"#orck/admin/lib/dialog-width\"\nimport type { Price } from \"#orck/client/generated/wire\"\nimport {\n formatNativeAmount,\n nativeAmountFromInput,\n nativeAmountToInput,\n} from \"#orck/admin/lib/format\"\n\nimport { priceIntervalLabel } from \"#orck/admin/pages/catalog/price-format\"\nimport {\n buildReviewText,\n defaultEffectiveDate,\n defaultMigrationMode,\n DEFAULT_NOTICE_WINDOW_DAYS,\n detectDirection,\n isEffectiveDateValid,\n minEffectiveDate,\n type MigrationMode,\n} from \"#orck/admin/pages/catalog/price-wizard-logic\"\n\nconst toDateInputValue = (d: Date) => d.toISOString().slice(0, 10)\n\nconst priceChangeFormValues = (price: Price, draft?: PriceChangeDraft) => ({\n amountInput: nativeAmountToInput(\n draft?.new_amount ?? price.unit_amount,\n price.currency\n ),\n mode: (draft?.migration ? \"migrate\" : \"grandfather\") as MigrationMode,\n effectiveAt: draft?.migration?.effective_at\n ? toDateInputValue(new Date(draft.migration.effective_at))\n : \"\",\n})\n\n// PriceChangeWizard is the #777 console price-change wizard — the ONLY\n// amount-edit affordance on a price. Three steps: new amount -> migration\n// plan (direction-aware defaults, live affected-count preview, notice-window\n// gate on increase+migrate) -> review in words, then confirm applies the\n// catalog price update followed (if migrating) by the price migration.\n//\n// draft (#779): when the catalog copilot proposed this change, the dialog\n// opens PRE-FILLED straight at Step 3 (review) — the affected count already\n// rode in the draft, so no extra preview call is needed. Confirm behaves\n// EXACTLY as a hand-typed change (the same create-price and price-migration\n// calls).\nexport function PriceChangeWizard({\n price,\n productName,\n productKey,\n draft,\n onDone,\n}: {\n price: Price\n productName: string\n productKey: string | undefined\n draft?: PriceChangeDraft\n onDone?: () => void\n}) {\n const { toast, toastApiError, adminMutations, adminQueries } =\n useAdminServices()\n\n const { id: adminId } = useAdminUI()\n\n const queryClient = useQueryClient()\n const [open, setOpen] = React.useState(() => !!draft)\n const [step, setStep] = React.useState<1 | 2 | 3>(() => (draft ? 3 : 1))\n const previewPriceChange = useMutation(adminMutations.previewPriceChange())\n const changePrice = useMutation(adminMutations.changePrice(queryClient))\n const affectedCount =\n previewPriceChange.data?.matched ?? draft?.affected_count ?? null\n const { data: configuration } = useQuery({\n ...adminQueries.merchantConfiguration(),\n enabled: open,\n })\n const noticeWindowDays =\n configuration?.reprice_notice_window_days ?? DEFAULT_NOTICE_WINDOW_DAYS\n\n const [now] = React.useState(() => new Date())\n const form = useForm({\n defaultValues: priceChangeFormValues(price, draft),\n onSubmit: async ({ value }) => {\n if (!productKey || price.customer_amount) return\n const newAmount = nativeAmountFromInput(value.amountInput, price.currency)\n if (newAmount === null || BigInt(newAmount) <= 0n) return\n\n try {\n await changePrice.mutateAsync({\n price: {\n product_id: price.product_id,\n unit_amount: newAmount,\n currency: price.currency,\n access_duration_hours: price.access_duration_hours ?? undefined,\n billing_interval_hours: price.billing_interval_hours ?? undefined,\n trial_unit_amount: price.trial_unit_amount ?? undefined,\n trial_duration_hours: price.trial_duration_hours ?? undefined,\n key: price.key,\n sell_via: price.sell_via ?? undefined,\n expected_revision: price.revision,\n },\n migration:\n value.mode === \"migrate\"\n ? {\n productKey,\n priceKey: price.key,\n effectiveAt: new Date(value.effectiveAt).toISOString(),\n }\n : undefined,\n })\n toast.success(\n value.mode === \"migrate\"\n ? \"Price updated and migration scheduled\"\n : \"Price updated\"\n )\n handleOpenChange(false)\n onDone?.()\n } catch (err) {\n toastApiError(err, \"Change price\")\n }\n },\n })\n\n const reset = () => {\n setStep(1)\n form.reset(priceChangeFormValues(price))\n previewPriceChange.reset()\n }\n\n const handleOpenChange = (next: boolean) => {\n if (!next) {\n reset()\n }\n setOpen(next)\n }\n\n const enterStep2 = () => {\n if (!productKey || price.customer_amount) return\n const amount = nativeAmountFromInput(\n form.state.values.amountInput,\n price.currency\n )\n const direction = detectDirection(\n amount ?? price.unit_amount,\n price.unit_amount\n )\n form.setFieldValue(\"mode\", defaultMigrationMode(direction))\n form.setFieldValue(\n \"effectiveAt\",\n toDateInputValue(defaultEffectiveDate(direction, now, noticeWindowDays))\n )\n setStep(2)\n previewPriceChange.reset()\n previewPriceChange.mutate(\n { productKey, priceKey: price.key },\n { onError: (err) => toastApiError(err, \"Preview affected subscribers\") }\n )\n }\n\n // Archived (prior-version) rows are history, not the editable current\n // price. Each product/key pair has exactly one live edit target.\n // Wait for the product before allowing previews or scheduling a migration.\n if (price.archived || !productKey || price.customer_amount) {\n return (\n <Button\n variant=\"outline\"\n size=\"sm\"\n disabled\n title={\n price.customer_amount\n ? \"This price lets customers choose an amount. Change its limits through a catalog application or the client.\"\n : price.archived\n ? \"This is an archived version. Change the current price for this key instead.\"\n : \"Load the product before changing its price.\"\n }\n >\n <AdminMessage id={\"Change price\"} />\n </Button>\n )\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n {!draft && (\n <DialogTrigger\n render={\n <Button variant=\"outline\" size=\"sm\">\n <AdminMessage id={\"Change price\"} />\n </Button>\n }\n />\n )}\n <DialogContent className={DIALOG_FORM}>\n <form\n className=\"grid gap-4\"\n onSubmit={(event) => {\n event.preventDefault()\n event.stopPropagation()\n if (step !== 3) return\n void form.handleSubmit()\n }}\n >\n <form.Subscribe\n selector={(state) => [state.values, state.isSubmitting] as const}\n >\n {([values, isSubmitting]) => {\n const newAmount =\n nativeAmountFromInput(values.amountInput, price.currency) ??\n price.unit_amount\n const direction = detectDirection(newAmount, price.unit_amount)\n const minDate = minEffectiveDate(direction, now, noticeWindowDays)\n const dateValid =\n values.mode !== \"migrate\" ||\n (!!values.effectiveAt &&\n isEffectiveDateValid(\n direction,\n new Date(values.effectiveAt),\n now,\n noticeWindowDays\n ))\n\n return (\n <>\n <DialogHeader>\n <DialogTitle className=\"flex items-center gap-2\">\n <AdminMessage id={\"Change price for \"} />\n {productName}\n {draft && (\n <Badge variant=\"secondary\">\n <AdminMessage id={\"drafted by copilot\"} />\n </Badge>\n )}\n </DialogTitle>\n <DialogDescription>\n <AdminMessage id={\"Step \"} />\n {step}\n <AdminMessage id={\" of 3:\"} />{\" \"}\n {step === 1\n ? \"new amount\"\n : step === 2\n ? \"migration plan\"\n : \"review\"}\n </DialogDescription>\n </DialogHeader>\n\n {step === 1 && (\n <div className=\"grid gap-3\">\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <p className=\"text-xs text-muted-foreground uppercase\">\n <AdminMessage id={\"Current amount\"} />\n </p>\n <p className=\"font-medium\">\n {formatNativeAmount(\n price.unit_amount,\n price.currency\n )}\n </p>\n </div>\n <div>\n <p className=\"text-xs text-muted-foreground uppercase\">\n <AdminMessage id={\"Currency · interval\"} />\n </p>\n <p className=\"font-medium\">\n {price.currency.toUpperCase()} ·{\" \"}\n {priceIntervalLabel(price)}\n </p>\n </div>\n </div>\n <form.Field\n name=\"amountInput\"\n validators={{\n onBlur: ({ value }) => {\n const amount = nativeAmountFromInput(\n value,\n price.currency\n )\n if (amount === null || BigInt(amount) <= 0n) {\n return \"Enter an amount greater than zero.\"\n }\n return undefined\n },\n }}\n >\n {(field) => (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(\"wiz-amount\")}>\n <AdminMessage id={\"New amount (major units)\"} />\n </Label>\n <Input\n id={adminId(\"wiz-amount\")}\n type=\"number\"\n step=\"any\"\n min=\"0\"\n value={field.state.value}\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n autoFocus\n />\n <FormFieldErrors errors={field.state.meta.errors} />\n </div>\n )}\n </form.Field>\n {direction !== \"unchanged\" && (\n <p className=\"text-sm text-muted-foreground\">\n <AdminMessage id={\"This is a price\"} />{\" \"}\n <span className=\"font-medium text-foreground\">\n {direction === \"increase\" ? \"increase\" : \"decrease\"}\n </span>\n <AdminMessage\n id={\n \". Currency and interval stay locked to the current price.\"\n }\n />\n </p>\n )}\n </div>\n )}\n\n {step === 2 && (\n <div className=\"grid gap-3\">\n <p className=\"text-sm\">\n {affectedCount === null && previewPriceChange.isPending\n ? \"Checking affected subscribers…\"\n : `${(affectedCount ?? 0).toLocaleString()} active subscription${affectedCount === 1 ? \"\" : \"s\"} on prior versions of ${price.key}.`}\n </p>\n <form.Field name=\"mode\">\n {(field) => (\n <div className=\"grid gap-2\">\n <label className=\"flex items-start gap-2 rounded-md border p-3 text-sm\">\n <input\n type=\"radio\"\n name={field.name}\n className=\"mt-1\"\n checked={field.state.value === \"grandfather\"}\n onChange={() =>\n field.handleChange(\"grandfather\")\n }\n />\n <span>\n <span className=\"font-medium\">\n <AdminMessage id={\"Grandfather.\"} />\n </span>{\" \"}\n <AdminMessage\n id={\n \"Existing subscribers keep the current price.\"\n }\n />\n {direction === \"increase\" && (\n <Badge variant=\"secondary\" className=\"ml-2\">\n <AdminMessage id={\"default\"} />\n </Badge>\n )}\n </span>\n </label>\n <label className=\"flex items-start gap-2 rounded-md border p-3 text-sm\">\n <input\n type=\"radio\"\n name={field.name}\n className=\"mt-1\"\n checked={field.state.value === \"migrate\"}\n onChange={() => field.handleChange(\"migrate\")}\n />\n <span>\n <span className=\"font-medium\">\n <AdminMessage id={\"Migrate.\"} />\n </span>{\" \"}\n <AdminMessage\n id={\n \"Move everyone to the new price at their first renewal on or after a date you choose.\"\n }\n />\n {direction === \"decrease\" && (\n <Badge variant=\"secondary\" className=\"ml-2\">\n <AdminMessage id={\"default\"} />\n </Badge>\n )}\n </span>\n </label>\n </div>\n )}\n </form.Field>\n {values.mode === \"migrate\" && (\n <form.Field name=\"effectiveAt\">\n {(field) => (\n <div className=\"grid gap-1.5\">\n <Label htmlFor={adminId(\"wiz-effective\")}>\n <AdminMessage id={\"Effective date\"} />\n </Label>\n <Input\n id={adminId(\"wiz-effective\")}\n type=\"date\"\n value={field.state.value}\n min={\n minDate\n ? toDateInputValue(minDate)\n : undefined\n }\n onBlur={field.handleBlur}\n onChange={(event) =>\n field.handleChange(event.target.value)\n }\n />\n {direction === \"increase\" ? (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage id={\"Must be at least \"} />\n {noticeWindowDays}\n <AdminMessage\n id={\n \" days away. Card networks require that much notice before a price goes up. You can change the number in Settings.\"\n }\n />\n </p>\n ) : (\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage\n id={\n \"A price going down needs no notice, so today is fine.\"\n }\n />\n </p>\n )}\n {!dateValid && (\n <p\n className=\"text-xs text-destructive\"\n role=\"alert\"\n >\n <AdminMessage id={\"Pick a later date.\"} />\n </p>\n )}\n <p className=\"text-xs text-muted-foreground\">\n <AdminMessage\n id={\n \"A reprice_scheduled notice is queued for every affected subscriber as soon as you confirm.\"\n }\n />\n </p>\n </div>\n )}\n </form.Field>\n )}\n </div>\n )}\n\n {step === 3 && (\n <div className=\"grid gap-3\">\n <p className=\"rounded-md border bg-muted/40 p-3 text-sm\">\n {buildReviewText({\n newAmount,\n currentAmount: price.unit_amount,\n currency: price.currency,\n affectedCount: affectedCount ?? 0,\n plan: {\n mode: values.mode,\n effectiveAt:\n values.mode === \"migrate\"\n ? new Date(values.effectiveAt).toISOString()\n : \"\",\n },\n now,\n })}\n </p>\n </div>\n )}\n\n <DialogFooter>\n {step > 1 && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={isSubmitting}\n onClick={() => setStep((value) => (value - 1) as 1 | 2)}\n >\n <AdminMessage id={\"Back\"} />\n </Button>\n )}\n {step === 1 && (\n <Button\n type=\"button\"\n disabled={\n !values.amountInput ||\n direction === \"unchanged\" ||\n BigInt(newAmount) <= 0n\n }\n onClick={enterStep2}\n >\n <AdminMessage id={\"Next\"} />\n </Button>\n )}\n {step === 2 && (\n <Button\n type=\"button\"\n disabled={!dateValid || previewPriceChange.isPending}\n onClick={() => setStep(3)}\n >\n <AdminMessage id={\"Next\"} />\n </Button>\n )}\n {step === 3 && (\n <Button type=\"submit\" disabled={isSubmitting}>\n {isSubmitting ? \"Working…\" : \"Confirm\"}\n </Button>\n )}\n </DialogFooter>\n </>\n )\n }}\n </form.Subscribe>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,SAAgB,EACd,GACA,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