@cedros/pay-react 1.1.28 → 1.1.29

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 (172) hide show
  1. package/dist/{AISettingsSection-DELur7D2.js → AISettingsSection-B7qrycfY.js} +2 -2
  2. package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-DtAgMsDw.mjs} +6 -4
  3. package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-BEvABoKU.mjs} +1 -1
  4. package/dist/AutosaveIndicator-DiyeAg93.js +1 -0
  5. package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
  6. package/dist/CedrosContext-CCakH2SZ.js +3 -0
  7. package/dist/CedrosPayAdminDashboard-CAwEvn66.js +1 -0
  8. package/dist/CedrosPayAdminDashboard-CBuvNAtB.mjs +250 -0
  9. package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-Ber5o8hF.mjs} +19 -17
  10. package/dist/ChatLogsSection-DLxMMi9I.js +1 -0
  11. package/dist/ComplianceSection-Buu0zTiL.js +1 -0
  12. package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-ZCr0wsvw.mjs} +18 -15
  13. package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
  14. package/dist/CryptoButton-DxFCYDlJ.js +1 -0
  15. package/dist/CustomersSection-BywmMLur.js +1 -0
  16. package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-D9UknSKC.mjs} +21 -19
  17. package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-C_eySK-W.mjs} +19 -17
  18. package/dist/DisputesSection-DwkHGv2a.js +1 -0
  19. package/dist/Dropdown-B90Zabxr.mjs +111 -0
  20. package/dist/Dropdown-CtY91emj.js +1 -0
  21. package/dist/ErrorBanner-CZXsHi3H.mjs +22 -0
  22. package/dist/ErrorBanner-Cx2dUhps.js +1 -0
  23. package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Bv_Hdt8B.mjs} +8 -6
  24. package/dist/FAQSection-DlPLnIJD.js +1 -0
  25. package/dist/ImagesSection-B4Jzet79.js +1 -0
  26. package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-DpdXQ6qu.mjs} +6 -4
  27. package/dist/InventorySection-BgRdpn1l.js +1 -0
  28. package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-DZMu9DMw.mjs} +25 -23
  29. package/dist/MessagingSection-CxV-pf-f.js +1 -0
  30. package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-D_cOBfFt.mjs} +5 -4
  31. package/dist/OrdersSection-BbAX79Ff.js +1 -0
  32. package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-wfPavit9.mjs} +27 -24
  33. package/dist/PaymentSettingsSection-BdBDgaRg.js +1 -0
  34. package/dist/PaymentSettingsSection-DunzBo9n.mjs +648 -0
  35. package/dist/ReturnsSection-7k4LZ8yp.js +1 -0
  36. package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-B4FL7bUv.mjs} +11 -9
  37. package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-Cz2Yjdhr.js} +1 -1
  38. package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-DoeNDbqd.mjs} +1 -1
  39. package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-BlVsYC6B.mjs} +5 -3
  40. package/dist/ShippingSection-C-HI8rOb.js +1 -0
  41. package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-B406nnF-.mjs} +143 -140
  42. package/dist/SingleCategorySettings-BqC2UXt3.js +3 -0
  43. package/dist/StatsBar-D4v-I_Dj.mjs +25 -0
  44. package/dist/StatsBar-m6GSRNxs.js +1 -0
  45. package/dist/StorefrontSection-Axvh_KeS.js +1 -0
  46. package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-BK_rhrAi.mjs} +121 -119
  47. package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-D8V9RBv-.mjs} +11 -9
  48. package/dist/SubscriptionsSection-EeULMWIB.js +1 -0
  49. package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-Cj6TXL6x.mjs} +23 -21
  50. package/dist/TaxSection-CzHPhaHl.js +1 -0
  51. package/dist/ThemeContext-CFXyYx7A.js +1 -0
  52. package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
  53. package/dist/Token22Section-DqRKVG_G.js +1 -0
  54. package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DtYAcT54.mjs} +7 -6
  55. package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
  56. package/dist/WalletManager-DXChB9LA.js +1 -0
  57. package/dist/WebhooksSection-D--iPZuM.js +1 -0
  58. package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-DBAIxtBy.mjs} +40 -38
  59. package/dist/admin.d.ts +2 -0
  60. package/dist/admin.js +1 -0
  61. package/dist/admin.mjs +8 -0
  62. package/dist/configApi-BS5UJfzm.js +1 -0
  63. package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
  64. package/dist/crypto-only.js +1 -1
  65. package/dist/crypto-only.mjs +214 -202
  66. package/dist/dateHelpers-BKW_lGND.js +1 -0
  67. package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
  68. package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
  69. package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
  70. package/dist/index-9QF_UfSN.mjs +18668 -0
  71. package/dist/index-Cq9ya93W.js +84 -0
  72. package/dist/index.js +1 -1
  73. package/dist/index.mjs +74 -64
  74. package/dist/safeHref-DqJPLPl5.mjs +12 -0
  75. package/dist/safeHref-DyHIpVjY.js +1 -0
  76. package/dist/sectionIds-B_tFiNvF.js +1 -0
  77. package/dist/sectionIds-DBavltrL.mjs +359 -0
  78. package/dist/sections-BHph7CYj.mjs +9 -0
  79. package/dist/sections-C2zEJr5G.js +1 -0
  80. package/dist/sections-more-C1VNVwkp.js +1 -0
  81. package/dist/sections-more-CMFgfU4d.mjs +3082 -0
  82. package/dist/src/admin/index.d.ts +3 -3
  83. package/dist/src/admin/index.d.ts.map +1 -1
  84. package/dist/src/admin/plugin.d.ts.map +1 -1
  85. package/dist/src/admin/types.d.ts +2 -6
  86. package/dist/src/admin/types.d.ts.map +1 -1
  87. package/dist/src/admin.d.ts +9 -0
  88. package/dist/src/admin.d.ts.map +1 -0
  89. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
  90. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
  91. package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
  92. package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
  93. package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
  94. package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
  95. package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
  96. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  97. package/dist/src/components/admin/configApi.d.ts +1 -1
  98. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  99. package/dist/src/components/admin/icons.d.ts +3 -50
  100. package/dist/src/components/admin/icons.d.ts.map +1 -1
  101. package/dist/src/components/admin/index.d.ts +1 -1
  102. package/dist/src/components/admin/index.d.ts.map +1 -1
  103. package/dist/src/components/admin/types.d.ts +43 -0
  104. package/dist/src/components/admin/types.d.ts.map +1 -1
  105. package/dist/src/context/CedrosContext.d.ts +2 -0
  106. package/dist/src/context/CedrosContext.d.ts.map +1 -1
  107. package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
  108. package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
  109. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  110. package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
  111. package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
  112. package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
  113. package/dist/src/ecommerce/config/context.d.ts +2 -0
  114. package/dist/src/ecommerce/config/context.d.ts.map +1 -1
  115. package/dist/src/ecommerce/config/types.d.ts +2 -0
  116. package/dist/src/ecommerce/config/types.d.ts.map +1 -1
  117. package/dist/src/ecommerce/index.d.ts +2 -0
  118. package/dist/src/ecommerce/index.d.ts.map +1 -1
  119. package/dist/src/featureFlags.d.ts +41 -0
  120. package/dist/src/featureFlags.d.ts.map +1 -0
  121. package/dist/src/index.d.ts +4 -2
  122. package/dist/src/index.d.ts.map +1 -1
  123. package/dist/src/managers/StripeManager.d.ts.map +1 -1
  124. package/dist/src/managers/SubscriptionManager.d.ts +1 -0
  125. package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
  126. package/dist/src/types/index.d.ts +14 -1
  127. package/dist/src/types/index.d.ts.map +1 -1
  128. package/dist/src/types/subscription.d.ts +47 -1
  129. package/dist/src/types/subscription.d.ts.map +1 -1
  130. package/dist/src/utils/validateConfig.d.ts.map +1 -1
  131. package/dist/stripe-only.js +1 -1
  132. package/dist/stripe-only.mjs +35 -33
  133. package/dist/styles--fxb3lCl.js +1 -0
  134. package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
  135. package/dist/testing/index.js +1 -1
  136. package/dist/testing/index.mjs +1 -1
  137. package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
  138. package/dist/tokenMintValidator-DNBhoefh.js +4 -0
  139. package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
  140. package/dist/walletPool-BjTXX6Vn.js +1 -0
  141. package/package.json +3 -3
  142. package/dist/AutosaveIndicator-Dn_qA2hK.js +0 -1
  143. package/dist/CedrosContext-C2RjHLaQ.js +0 -6
  144. package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
  145. package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
  146. package/dist/ComplianceSection-DP2a9-S0.js +0 -1
  147. package/dist/CryptoButton-DpiCnyXE.js +0 -1
  148. package/dist/CustomersSection-CBwy_waO.js +0 -1
  149. package/dist/DisputesSection-BLjIk60n.js +0 -1
  150. package/dist/FAQSection-wNeH0i6Q.js +0 -1
  151. package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
  152. package/dist/InventorySection-zV6lTmue.js +0 -1
  153. package/dist/MessagingSection-B_wdFR0j.js +0 -1
  154. package/dist/OrdersSection-Dw2FX-1d.js +0 -1
  155. package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
  156. package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
  157. package/dist/ReturnsSection-D_pJVxuG.js +0 -1
  158. package/dist/ShippingSection-1DRSTu49.js +0 -1
  159. package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
  160. package/dist/StorefrontSection-RumGkb3C.js +0 -1
  161. package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
  162. package/dist/TaxSection-Dt1DnM51.js +0 -1
  163. package/dist/Token22Section-DY3mUwTY.js +0 -1
  164. package/dist/WalletManager-B3UdQ5pQ.js +0 -1
  165. package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
  166. package/dist/configApi-DkduMQg1.js +0 -1
  167. package/dist/index-C0g-JxJk.js +0 -84
  168. package/dist/index-DXnuQp5x.mjs +0 -22128
  169. package/dist/sections-C1NpK7hk.mjs +0 -9
  170. package/dist/sections-DVVSZBhW.js +0 -1
  171. package/dist/styles-BT4bhFey.js +0 -1
  172. package/dist/walletPool-IS7R3MR1.js +0 -1
@@ -1,6 +1,8 @@
1
1
  import { jsx as e, jsxs as n, Fragment as U } from "react/jsx-runtime";
2
2
  import { useState as l, useCallback as R, useEffect as D } from "react";
3
- import { E as O, I as $, k as b } from "./index-DXnuQp5x.mjs";
3
+ import { I as O } from "./sectionIds-DBavltrL.mjs";
4
+ import { E as $ } from "./ErrorBanner-CZXsHi3H.mjs";
5
+ import { f as b } from "./dateHelpers-yvPkofYQ.mjs";
4
6
  const C = ["requested", "approved", "rejected", "received", "refunded"], W = (d) => {
5
7
  switch (d) {
6
8
  case "approved":
@@ -129,8 +131,8 @@ function q({ returnRequest: d, onBack: m, onStatusUpdated: c, onError: u, fetchW
129
131
  ] })
130
132
  ] });
131
133
  }
132
- function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
133
- const [s, r] = l([]), [v, _] = l(!0), [p, o] = l(null), [a, h] = l(0), [g, A] = l("all"), [x, N] = l(null), [k, I] = l(!1), y = R(async (t, i) => {
134
+ function z({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
135
+ const [s, r] = l([]), [v, _] = l(!0), [p, o] = l(null), [a, h] = l(0), [g, A] = l("all"), [x, N] = l(null), [j, I] = l(!1), y = R(async (t, i) => {
134
136
  if (u?.isAuthenticated())
135
137
  return u.fetchWithAuth(t, i);
136
138
  const f = { "Content-Type": "application/json" };
@@ -154,7 +156,7 @@ function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
154
156
  D(() => {
155
157
  w();
156
158
  }, [w]);
157
- const j = async (t) => {
159
+ const k = async (t) => {
158
160
  I(!0), o(null);
159
161
  try {
160
162
  const i = await y(`/admin/returns/${encodeURIComponent(t)}`);
@@ -178,7 +180,7 @@ function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
178
180
  }
179
181
  ) : /* @__PURE__ */ n("div", { children: [
180
182
  /* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Returns" }) }),
181
- /* @__PURE__ */ e(O, { message: p }),
183
+ /* @__PURE__ */ e($, { message: p }),
182
184
  /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: [
183
185
  /* @__PURE__ */ n(
184
186
  "select",
@@ -201,8 +203,8 @@ function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
201
203
  s.length !== 1 ? "s" : ""
202
204
  ] })
203
205
  ] }),
204
- v || k ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
205
- $.loading,
206
+ v || j ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
207
+ O.loading,
206
208
  " Loading returns..."
207
209
  ] }) : s.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No returns found." }) : /* @__PURE__ */ n(U, { children: [
208
210
  /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
@@ -225,7 +227,7 @@ function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
225
227
  {
226
228
  type: "button",
227
229
  className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
228
- onClick: () => j(t.id),
230
+ onClick: () => k(t.id),
229
231
  children: "View"
230
232
  }
231
233
  ) })
@@ -263,5 +265,5 @@ function T({ serverUrl: d, apiKey: m, pageSize: c = 20, authManager: u }) {
263
265
  ] });
264
266
  }
265
267
  export {
266
- T as ReturnsSection
268
+ z as ReturnsSection
267
269
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),d=require("./SingleCategorySettings-DwCnBdRf.js"),r=[{id:"logging",label:"Logging",category:"logging",description:"Configure log levels, format, and environment settings."},{id:"metrics",label:"Metrics",category:"metrics",description:"Configure metrics collection and API access for monitoring."},{id:"security",label:"Security",category:"security",description:"Configure CORS, rate limiting, and other security settings."},{id:"storage",label:"Storage",category:"storage",description:"Configure S3-compatible storage for product images."}];function l({serverUrl:n,apiKey:o,authManager:c}){const[s,a]=g.useState("logging"),t=r.find(i=>i.id===s);return e.jsxs("div",{className:"cedros-admin__server-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Server"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure logging, metrics, security, and storage settings."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:r.map(i=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${s===i.id?"cedros-admin__tab--active":""}`,onClick:()=>a(i.id),children:i.label},i.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(d.SingleCategorySettings,{serverUrl:n,apiKey:o,authManager:c,category:t.category,title:`${t.label} Settings`,description:t.description},t.category)})]})}exports.SettingsSection=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),d=require("./SingleCategorySettings-BqC2UXt3.js"),r=[{id:"logging",label:"Logging",category:"logging",description:"Configure log levels, format, and environment settings."},{id:"metrics",label:"Metrics",category:"metrics",description:"Configure metrics collection and API access for monitoring."},{id:"security",label:"Security",category:"security",description:"Configure CORS, rate limiting, and other security settings."},{id:"storage",label:"Storage",category:"storage",description:"Configure S3-compatible storage for product images."}];function l({serverUrl:n,apiKey:o,authManager:c}){const[s,a]=g.useState("logging"),t=r.find(i=>i.id===s);return e.jsxs("div",{className:"cedros-admin__server-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Server"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure logging, metrics, security, and storage settings."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:r.map(i=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${s===i.id?"cedros-admin__tab--active":""}`,onClick:()=>a(i.id),children:i.label},i.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(d.SingleCategorySettings,{serverUrl:n,apiKey:o,authManager:c,category:t.category,title:`${t.label} Settings`,description:t.description},t.category)})]})}exports.SettingsSection=l;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as s, jsx as i } from "react/jsx-runtime";
2
2
  import { useState as g } from "react";
3
- import { S as l } from "./SingleCategorySettings-suJ8z9d8.mjs";
3
+ import { S as l } from "./SingleCategorySettings-B406nnF-.mjs";
4
4
  const o = [
5
5
  {
6
6
  id: "logging",
@@ -1,8 +1,10 @@
1
1
  import { jsxs as a, jsx as t, Fragment as ae } from "react/jsx-runtime";
2
2
  import { useState as l, useCallback as w, useEffect as ne } from "react";
3
- import { E as x, I as q, k as J } from "./index-DXnuQp5x.mjs";
3
+ import { I as q } from "./sectionIds-DBavltrL.mjs";
4
+ import { E as x } from "./ErrorBanner-CZXsHi3H.mjs";
5
+ import { f as J } from "./dateHelpers-yvPkofYQ.mjs";
4
6
  const M = { name: "", description: "", countries: "", active: !0 }, G = { name: "", rateType: "flat", amountAtomic: "", currency: "USD", minSubtotal: "", maxSubtotal: "", active: !0 }, P = (f, h) => `${h.toUpperCase()} ${(f / 100).toFixed(2)}`;
5
- function re({ serverUrl: f, apiKey: h, authManager: C }) {
7
+ function ce({ serverUrl: f, apiKey: h, authManager: C }) {
6
8
  const [E, I] = l([]), [K, k] = l(!0), [F, p] = l(null), [T, r] = l(null), [X, b] = l(!1), [y, g] = l(null), [c, m] = l(M), [D, U] = l(!1), [d, $] = l(null), [L, z] = l([]), [H, O] = l(!1), [Q, u] = l(!1), [v, _] = l(null), [n, s] = l(G), [B, W] = l(!1), o = w(async (e, i) => {
7
9
  if (C?.isAuthenticated())
8
10
  return C.fetchWithAuth(e, i);
@@ -430,5 +432,5 @@ function re({ serverUrl: f, apiKey: h, authManager: C }) {
430
432
  ] });
431
433
  }
432
434
  export {
433
- re as ShippingSection
435
+ ce as ShippingSection
434
436
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),z=require("./sectionIds-B_tFiNvF.js"),v=require("./ErrorBanner-Cx2dUhps.js"),q=require("./dateHelpers-BKW_lGND.js"),W={name:"",description:"",countries:"",active:!0},J={name:"",rateType:"flat",amountAtomic:"",currency:"USD",minSubtotal:"",maxSubtotal:"",active:!0},A=(x,u)=>`${u.toUpperCase()} ${(x/100).toFixed(2)}`;function te({serverUrl:x,apiKey:u,authManager:S}){const[R,E]=a.useState([]),[M,P]=a.useState(!0),[w,h]=a.useState(null),[I,r]=a.useState(null),[G,_]=a.useState(!1),[f,b]=a.useState(null),[o,c]=a.useState(W),[k,T]=a.useState(!1),[n,F]=a.useState(null),[D,U]=a.useState([]),[H,$]=a.useState(!1),[K,m]=a.useState(!1),[g,p]=a.useState(null),[i,d]=a.useState(J),[B,L]=a.useState(!1),l=a.useCallback(async(t,s)=>{if(S?.isAuthenticated())return S.fetchWithAuth(t,s);const j={"Content-Type":"application/json"};u&&(j["X-API-Key"]=u);const C=await fetch(`${x}${t}`,{...s,headers:{...j,...s?.headers}});if(!C.ok)throw new Error(`Request failed: ${C.status}`);return C.json()},[x,u,S]),y=a.useCallback(async()=>{P(!0),h(null);try{const t=await l("/admin/shipping/profiles?limit=50&offset=0");E(t.profiles??[])}catch{h("Failed to load shipping profiles"),E([])}finally{P(!1)}},[l]);a.useEffect(()=>{y()},[y]);const X=t=>{b(t),c({name:t.name,description:t.description??"",countries:t.countries.join(", "),active:t.active}),_(!0)},Q=async t=>{t.preventDefault(),T(!0),r(null);try{const s={name:o.name,description:o.description||void 0,countries:o.countries.split(",").map(j=>j.trim()).filter(Boolean),active:o.active};f?await l(`/admin/shipping/profiles/${encodeURIComponent(f.id)}`,{method:"PUT",body:JSON.stringify(s)}):await l("/admin/shipping/profiles",{method:"POST",body:JSON.stringify(s)}),_(!1),b(null),y()}catch(s){r(s instanceof Error?s.message:"Failed to save profile")}finally{T(!1)}},V=async t=>{if(window.confirm("Delete this shipping profile?")){r(null);try{await l(`/admin/shipping/profiles/${encodeURIComponent(t)}`,{method:"DELETE"}),y()}catch{r("Failed to delete profile")}}},N=a.useCallback(async t=>{$(!0),h(null);try{const s=await l(`/admin/shipping/profiles/${encodeURIComponent(t.id)}/rates?limit=50&offset=0`);U(s.rates??[])}catch{h("Failed to load rates"),U([])}finally{$(!1)}},[l]),O=t=>{F(t),m(!1),p(null),N(t)},Y=t=>{p(t),d({name:t.name,rateType:t.rateType,amountAtomic:String(t.amountAtomic),currency:t.currency,minSubtotal:t.minSubtotal!=null?String(t.minSubtotal):"",maxSubtotal:t.maxSubtotal!=null?String(t.maxSubtotal):"",active:t.active}),m(!0)},Z=async t=>{if(t.preventDefault(),!!n){L(!0),r(null);try{const s={name:i.name,rateType:i.rateType,amountAtomic:parseInt(i.amountAtomic,10),currency:i.currency,active:i.active,profileId:n.id,minSubtotal:i.minSubtotal?parseInt(i.minSubtotal,10):void 0,maxSubtotal:i.maxSubtotal?parseInt(i.maxSubtotal,10):void 0};g?await l(`/admin/shipping/rates/${encodeURIComponent(g.id)}`,{method:"PUT",body:JSON.stringify(s)}):await l(`/admin/shipping/profiles/${encodeURIComponent(n.id)}/rates`,{method:"POST",body:JSON.stringify(s)}),m(!1),p(null),N(n)}catch(s){r(s instanceof Error?s.message:"Failed to save rate")}finally{L(!1)}}},ee=async t=>{if(!(!window.confirm("Delete this rate?")||!n)){r(null);try{await l(`/admin/shipping/rates/${encodeURIComponent(t)}`,{method:"DELETE"}),N(n)}catch{r("Failed to delete rate")}}};return n?e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>{F(null),m(!1),h(null),r(null)},style:{marginBottom:"1rem"},children:"← Back to profiles"}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[n.name,e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${n.active?"success":"muted"}`,style:{marginLeft:"0.5rem"},children:n.active?"Active":"Inactive"})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{p(null),d(J),m(!0)},children:"+ Add Rate"})]}),e.jsx(v.ErrorBanner,{message:w}),e.jsx(v.ErrorBanner,{message:I}),e.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",margin:"0 0 1rem"},children:[n.description&&e.jsxs(e.Fragment,{children:[n.description," · "]}),"Countries: ",n.countries.length>0?n.countries.join(", "):"All"]}),K&&e.jsxs("form",{onSubmit:Z,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"520px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:g?"Edit Rate":"New Rate"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",required:!0,value:i.name,onChange:t=>d(s=>({...s,name:t.target.value})),placeholder:"Standard Shipping"})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Rate Type *"}),e.jsxs("select",{className:"cedros-admin__input",value:i.rateType,onChange:t=>d(s=>({...s,rateType:t.target.value})),children:[e.jsx("option",{value:"flat",children:"Flat"}),e.jsx("option",{value:"price",children:"Price-based"}),e.jsx("option",{value:"weight",children:"Weight-based"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Amount (atomic) *"}),e.jsx("input",{type:"number",className:"cedros-admin__input",required:!0,min:0,value:i.amountAtomic,onChange:t=>d(s=>({...s,amountAtomic:t.target.value})),placeholder:"500"})]}),e.jsxs("div",{className:"cedros-admin__field",style:{width:"80px"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.currency,maxLength:3,onChange:t=>d(s=>({...s,currency:t.target.value.toUpperCase()})),placeholder:"USD"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Min Subtotal"}),e.jsx("input",{type:"number",className:"cedros-admin__input",min:0,value:i.minSubtotal,onChange:t=>d(s=>({...s,minSubtotal:t.target.value})),placeholder:"0"})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Subtotal"}),e.jsx("input",{type:"number",className:"cedros-admin__input",min:0,value:i.maxSubtotal,onChange:t=>d(s=>({...s,maxSubtotal:t.target.value})),placeholder:"10000"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"rate-active",checked:i.active,onChange:t=>d(s=>({...s,active:t.target.checked}))}),e.jsx("label",{htmlFor:"rate-active",className:"cedros-admin__field-label",style:{margin:0},children:"Active"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:B,children:B?"Saving...":g?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>{m(!1),p(null)},children:"Cancel"})]})]}),H?e.jsxs("div",{className:"cedros-admin__loading",children:[z.Icons.loading," Loading rates..."]}):D.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No rates yet. Add one above."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Min / Max Subtotal"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:D.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.rateType}),e.jsx("td",{style:{fontSize:"0.85rem"},children:A(t.amountAtomic,t.currency)}),e.jsxs("td",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)"},children:[t.minSubtotal!=null?A(t.minSubtotal,t.currency):"—"," / ",t.maxSubtotal!=null?A(t.maxSubtotal,t.currency):"—"]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:q.formatDateTime(t.updatedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>Y(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>ee(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Shipping"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{b(null),c(W),_(!0)},children:"+ Add Profile"})]}),e.jsx(v.ErrorBanner,{message:w}),e.jsx(v.ErrorBanner,{message:I}),G&&e.jsxs("form",{onSubmit:Q,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:f?"Edit Profile":"New Profile"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",required:!0,value:o.name,onChange:t=>c(s=>({...s,name:t.target.value})),placeholder:"Domestic Shipping"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:o.description,onChange:t=>c(s=>({...s,description:t.target.value})),placeholder:"Optional description"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Countries (comma-separated ISO codes)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:o.countries,onChange:t=>c(s=>({...s,countries:t.target.value})),placeholder:"US, CA, GB"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"profile-active",checked:o.active,onChange:t=>c(s=>({...s,active:t.target.checked}))}),e.jsx("label",{htmlFor:"profile-active",className:"cedros-admin__field-label",style:{margin:0},children:"Active"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:k,children:k?"Saving...":f?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>{_(!1),b(null)},children:"Cancel"})]})]}),M?e.jsxs("div",{className:"cedros-admin__loading",children:[z.Icons.loading," Loading profiles..."]}):R.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No shipping profiles found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Countries"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:R.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",fontWeight:600,padding:0,color:"var(--cedros-admin-text, #333)",fontSize:"0.9rem"},onClick:()=>O(t),children:t.name})}),e.jsx("td",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.countries.length>0?t.countries.join(", "):"All"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:q.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>O(t),children:"Rates"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>X(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>V(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]})}exports.ShippingSection=te;