@cedros/pay-react 1.1.24 → 1.1.26

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 (174) hide show
  1. package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
  2. package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
  3. package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
  5. package/dist/CedrosContext-C2RjHLaQ.js +6 -0
  6. package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
  7. package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
  8. package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
  9. package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
  10. package/dist/ComplianceSection-DP2a9-S0.js +1 -0
  11. package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
  12. package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
  13. package/dist/CustomersSection-CBwy_waO.js +1 -0
  14. package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
  15. package/dist/DisputesSection-BLjIk60n.js +1 -0
  16. package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
  17. package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
  18. package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
  19. package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
  20. package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
  21. package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
  22. package/dist/InventorySection-zV6lTmue.js +1 -0
  23. package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
  24. package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
  25. package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
  26. package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
  27. package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
  28. package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
  29. package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
  30. package/dist/ReturnsSection-D_pJVxuG.js +1 -0
  31. package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
  32. package/dist/SettingsSection-vdYFSNxB.js +1 -0
  33. package/dist/ShippingSection-1DRSTu49.js +1 -0
  34. package/dist/ShippingSection-BOgto6_9.mjs +434 -0
  35. package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
  36. package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
  37. package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
  38. package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
  39. package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
  40. package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
  41. package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
  42. package/dist/TaxSection-Dt1DnM51.js +1 -0
  43. package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
  44. package/dist/Token22Section-DY3mUwTY.js +1 -0
  45. package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
  46. package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
  47. package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
  48. package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
  49. package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
  50. package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
  51. package/dist/crypto-only.js +1 -1
  52. package/dist/crypto-only.mjs +85 -83
  53. package/dist/index-C0g-JxJk.js +84 -0
  54. package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
  55. package/dist/index.js +1 -1
  56. package/dist/index.mjs +42 -40
  57. package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
  58. package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
  59. package/dist/src/admin/plugin.d.ts.map +1 -1
  60. package/dist/src/components/ComplianceGatePage.d.ts +40 -0
  61. package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
  62. package/dist/src/components/SubscribeButton.d.ts +1 -5
  63. package/dist/src/components/SubscribeButton.d.ts.map +1 -1
  64. package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
  65. package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
  66. package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
  67. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  68. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  69. package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
  70. package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
  71. package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
  72. package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
  73. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
  74. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
  75. package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
  76. package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
  77. package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
  78. package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
  79. package/dist/src/components/admin/CustomersSection.d.ts +3 -0
  80. package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
  81. package/dist/src/components/admin/DisputesSection.d.ts +3 -0
  82. package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
  83. package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
  84. package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
  85. package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
  86. package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
  87. package/dist/src/components/admin/ImagesSection.d.ts +3 -0
  88. package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
  89. package/dist/src/components/admin/InventorySection.d.ts +3 -0
  90. package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
  91. package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
  92. package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
  93. package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
  94. package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
  95. package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
  96. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  97. package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
  98. package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
  99. package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
  100. package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
  101. package/dist/src/components/admin/ShippingSection.d.ts +3 -0
  102. package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
  103. package/dist/src/components/admin/TaxSection.d.ts +3 -0
  104. package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
  105. package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
  106. package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
  107. package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
  108. package/dist/src/components/admin/complianceTypes.d.ts +74 -0
  109. package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
  110. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  111. package/dist/src/components/admin/icons.d.ts +1 -0
  112. package/dist/src/components/admin/icons.d.ts.map +1 -1
  113. package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
  114. package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
  115. package/dist/src/context/CedrosContext.d.ts.map +1 -1
  116. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
  117. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  118. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  119. package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
  120. package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
  121. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
  122. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  123. package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
  124. package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
  125. package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
  126. package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
  127. package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
  128. package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
  129. package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
  130. package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
  131. package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
  132. package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
  133. package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
  134. package/dist/src/ecommerce/index.d.ts +12 -2
  135. package/dist/src/ecommerce/index.d.ts.map +1 -1
  136. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
  137. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
  138. package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  139. package/dist/src/ecommerce/types.d.ts +6 -0
  140. package/dist/src/ecommerce/types.d.ts.map +1 -1
  141. package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
  142. package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
  143. package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
  144. package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
  145. package/dist/src/index.d.ts +4 -0
  146. package/dist/src/index.d.ts.map +1 -1
  147. package/dist/src/managers/CreditsManager.d.ts.map +1 -1
  148. package/dist/src/managers/ManagerCache.d.ts +2 -2
  149. package/dist/src/managers/ManagerCache.d.ts.map +1 -1
  150. package/dist/src/managers/StripeManager.d.ts +7 -1
  151. package/dist/src/managers/StripeManager.d.ts.map +1 -1
  152. package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
  153. package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
  154. package/dist/src/types/index.d.ts +14 -0
  155. package/dist/src/types/index.d.ts.map +1 -1
  156. package/dist/src/types/subscription.d.ts +21 -33
  157. package/dist/src/types/subscription.d.ts.map +1 -1
  158. package/dist/src/utils/exponentialBackoff.d.ts +22 -0
  159. package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
  160. package/dist/stripe-only.js +1 -1
  161. package/dist/stripe-only.mjs +2 -2
  162. package/dist/styles-BT4bhFey.js +1 -0
  163. package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
  164. package/dist/testing/index.js +1 -1
  165. package/dist/testing/index.mjs +1 -1
  166. package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
  167. package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
  168. package/package.json +1 -1
  169. package/dist/CedrosContext-7dwmEeUY.js +0 -6
  170. package/dist/SettingsSection-cKF0tLnS.js +0 -1
  171. package/dist/Token22Section-DUUl59dZ.js +0 -1
  172. package/dist/Token22Section-HygkDNtL.mjs +0 -1685
  173. package/dist/index-OaWkrl0G.js +0 -84
  174. package/dist/styles-21F1-oqx.js +0 -1
@@ -0,0 +1,434 @@
1
+ import { jsxs as a, jsx as t, Fragment as ae } from "react/jsx-runtime";
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";
4
+ 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 }) {
6
+ 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
+ if (C?.isAuthenticated())
8
+ return C.fetchWithAuth(e, i);
9
+ const S = { "Content-Type": "application/json" };
10
+ h && (S["X-API-Key"] = h);
11
+ const R = await fetch(`${f}${e}`, { ...i, headers: { ...S, ...i?.headers } });
12
+ if (!R.ok) throw new Error(`Request failed: ${R.status}`);
13
+ return R.json();
14
+ }, [f, h, C]), N = w(async () => {
15
+ k(!0), p(null);
16
+ try {
17
+ const e = await o("/admin/shipping/profiles?limit=50&offset=0");
18
+ I(e.profiles ?? []);
19
+ } catch {
20
+ p("Failed to load shipping profiles"), I([]);
21
+ } finally {
22
+ k(!1);
23
+ }
24
+ }, [o]);
25
+ ne(() => {
26
+ N();
27
+ }, [N]);
28
+ const V = (e) => {
29
+ g(e), m({ name: e.name, description: e.description ?? "", countries: e.countries.join(", "), active: e.active }), b(!0);
30
+ }, Y = async (e) => {
31
+ e.preventDefault(), U(!0), r(null);
32
+ try {
33
+ const i = {
34
+ name: c.name,
35
+ description: c.description || void 0,
36
+ countries: c.countries.split(",").map((S) => S.trim()).filter(Boolean),
37
+ active: c.active
38
+ };
39
+ y ? await o(`/admin/shipping/profiles/${encodeURIComponent(y.id)}`, { method: "PUT", body: JSON.stringify(i) }) : await o("/admin/shipping/profiles", { method: "POST", body: JSON.stringify(i) }), b(!1), g(null), N();
40
+ } catch (i) {
41
+ r(i instanceof Error ? i.message : "Failed to save profile");
42
+ } finally {
43
+ U(!1);
44
+ }
45
+ }, Z = async (e) => {
46
+ if (window.confirm("Delete this shipping profile?")) {
47
+ r(null);
48
+ try {
49
+ await o(`/admin/shipping/profiles/${encodeURIComponent(e)}`, { method: "DELETE" }), N();
50
+ } catch {
51
+ r("Failed to delete profile");
52
+ }
53
+ }
54
+ }, A = w(async (e) => {
55
+ O(!0), p(null);
56
+ try {
57
+ const i = await o(
58
+ `/admin/shipping/profiles/${encodeURIComponent(e.id)}/rates?limit=50&offset=0`
59
+ );
60
+ z(i.rates ?? []);
61
+ } catch {
62
+ p("Failed to load rates"), z([]);
63
+ } finally {
64
+ O(!1);
65
+ }
66
+ }, [o]), j = (e) => {
67
+ $(e), u(!1), _(null), A(e);
68
+ }, ee = (e) => {
69
+ _(e), s({
70
+ name: e.name,
71
+ rateType: e.rateType,
72
+ amountAtomic: String(e.amountAtomic),
73
+ currency: e.currency,
74
+ minSubtotal: e.minSubtotal != null ? String(e.minSubtotal) : "",
75
+ maxSubtotal: e.maxSubtotal != null ? String(e.maxSubtotal) : "",
76
+ active: e.active
77
+ }), u(!0);
78
+ }, te = async (e) => {
79
+ if (e.preventDefault(), !!d) {
80
+ W(!0), r(null);
81
+ try {
82
+ const i = {
83
+ name: n.name,
84
+ rateType: n.rateType,
85
+ amountAtomic: parseInt(n.amountAtomic, 10),
86
+ currency: n.currency,
87
+ active: n.active,
88
+ profileId: d.id,
89
+ minSubtotal: n.minSubtotal ? parseInt(n.minSubtotal, 10) : void 0,
90
+ maxSubtotal: n.maxSubtotal ? parseInt(n.maxSubtotal, 10) : void 0
91
+ };
92
+ v ? await o(`/admin/shipping/rates/${encodeURIComponent(v.id)}`, { method: "PUT", body: JSON.stringify(i) }) : await o(`/admin/shipping/profiles/${encodeURIComponent(d.id)}/rates`, { method: "POST", body: JSON.stringify(i) }), u(!1), _(null), A(d);
93
+ } catch (i) {
94
+ r(i instanceof Error ? i.message : "Failed to save rate");
95
+ } finally {
96
+ W(!1);
97
+ }
98
+ }
99
+ }, ie = async (e) => {
100
+ if (!(!window.confirm("Delete this rate?") || !d)) {
101
+ r(null);
102
+ try {
103
+ await o(`/admin/shipping/rates/${encodeURIComponent(e)}`, { method: "DELETE" }), A(d);
104
+ } catch {
105
+ r("Failed to delete rate");
106
+ }
107
+ }
108
+ };
109
+ return d ? /* @__PURE__ */ a("div", { children: [
110
+ /* @__PURE__ */ t(
111
+ "button",
112
+ {
113
+ type: "button",
114
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
115
+ onClick: () => {
116
+ $(null), u(!1), p(null), r(null);
117
+ },
118
+ style: { marginBottom: "1rem" },
119
+ children: "← Back to profiles"
120
+ }
121
+ ),
122
+ /* @__PURE__ */ a("div", { className: "cedros-admin__section-header", children: [
123
+ /* @__PURE__ */ a("h3", { className: "cedros-admin__section-title", children: [
124
+ d.name,
125
+ /* @__PURE__ */ t("span", { className: `cedros-admin__badge cedros-admin__badge--${d.active ? "success" : "muted"}`, style: { marginLeft: "0.5rem" }, children: d.active ? "Active" : "Inactive" })
126
+ ] }),
127
+ /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button cedros-admin__button--primary", onClick: () => {
128
+ _(null), s(G), u(!0);
129
+ }, children: "+ Add Rate" })
130
+ ] }),
131
+ /* @__PURE__ */ t(x, { message: F }),
132
+ /* @__PURE__ */ t(x, { message: T }),
133
+ /* @__PURE__ */ a("p", { style: { fontSize: "0.8rem", color: "var(--cedros-admin-text-muted, #888)", margin: "0 0 1rem" }, children: [
134
+ d.description && /* @__PURE__ */ a(ae, { children: [
135
+ d.description,
136
+ " · "
137
+ ] }),
138
+ "Countries: ",
139
+ d.countries.length > 0 ? d.countries.join(", ") : "All"
140
+ ] }),
141
+ Q && /* @__PURE__ */ a("form", { onSubmit: te, style: { border: "1px solid var(--cedros-admin-border, #e0e0e0)", borderRadius: "4px", padding: "1rem", marginBottom: "1.5rem", maxWidth: "520px" }, children: [
142
+ /* @__PURE__ */ t("h4", { style: { margin: "0 0 0.75rem", fontSize: "0.9rem", fontWeight: 600 }, children: v ? "Edit Rate" : "New Rate" }),
143
+ /* @__PURE__ */ a("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
144
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", children: [
145
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Name *" }),
146
+ /* @__PURE__ */ t(
147
+ "input",
148
+ {
149
+ type: "text",
150
+ className: "cedros-admin__input",
151
+ required: !0,
152
+ value: n.name,
153
+ onChange: (e) => s((i) => ({ ...i, name: e.target.value })),
154
+ placeholder: "Standard Shipping"
155
+ }
156
+ )
157
+ ] }),
158
+ /* @__PURE__ */ a("div", { style: { display: "flex", gap: "0.5rem" }, children: [
159
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
160
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Rate Type *" }),
161
+ /* @__PURE__ */ a(
162
+ "select",
163
+ {
164
+ className: "cedros-admin__input",
165
+ value: n.rateType,
166
+ onChange: (e) => s((i) => ({ ...i, rateType: e.target.value })),
167
+ children: [
168
+ /* @__PURE__ */ t("option", { value: "flat", children: "Flat" }),
169
+ /* @__PURE__ */ t("option", { value: "price", children: "Price-based" }),
170
+ /* @__PURE__ */ t("option", { value: "weight", children: "Weight-based" })
171
+ ]
172
+ }
173
+ )
174
+ ] }),
175
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
176
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Amount (atomic) *" }),
177
+ /* @__PURE__ */ t(
178
+ "input",
179
+ {
180
+ type: "number",
181
+ className: "cedros-admin__input",
182
+ required: !0,
183
+ min: 0,
184
+ value: n.amountAtomic,
185
+ onChange: (e) => s((i) => ({ ...i, amountAtomic: e.target.value })),
186
+ placeholder: "500"
187
+ }
188
+ )
189
+ ] }),
190
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", style: { width: "80px" }, children: [
191
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Currency" }),
192
+ /* @__PURE__ */ t(
193
+ "input",
194
+ {
195
+ type: "text",
196
+ className: "cedros-admin__input",
197
+ value: n.currency,
198
+ maxLength: 3,
199
+ onChange: (e) => s((i) => ({ ...i, currency: e.target.value.toUpperCase() })),
200
+ placeholder: "USD"
201
+ }
202
+ )
203
+ ] })
204
+ ] }),
205
+ /* @__PURE__ */ a("div", { style: { display: "flex", gap: "0.5rem" }, children: [
206
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
207
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Min Subtotal" }),
208
+ /* @__PURE__ */ t(
209
+ "input",
210
+ {
211
+ type: "number",
212
+ className: "cedros-admin__input",
213
+ min: 0,
214
+ value: n.minSubtotal,
215
+ onChange: (e) => s((i) => ({ ...i, minSubtotal: e.target.value })),
216
+ placeholder: "0"
217
+ }
218
+ )
219
+ ] }),
220
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", style: { flex: 1 }, children: [
221
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Max Subtotal" }),
222
+ /* @__PURE__ */ t(
223
+ "input",
224
+ {
225
+ type: "number",
226
+ className: "cedros-admin__input",
227
+ min: 0,
228
+ value: n.maxSubtotal,
229
+ onChange: (e) => s((i) => ({ ...i, maxSubtotal: e.target.value })),
230
+ placeholder: "10000"
231
+ }
232
+ )
233
+ ] })
234
+ ] }),
235
+ /* @__PURE__ */ a("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
236
+ /* @__PURE__ */ t(
237
+ "input",
238
+ {
239
+ type: "checkbox",
240
+ id: "rate-active",
241
+ checked: n.active,
242
+ onChange: (e) => s((i) => ({ ...i, active: e.target.checked }))
243
+ }
244
+ ),
245
+ /* @__PURE__ */ t("label", { htmlFor: "rate-active", className: "cedros-admin__field-label", style: { margin: 0 }, children: "Active" })
246
+ ] })
247
+ ] }),
248
+ /* @__PURE__ */ a("div", { style: { marginTop: "0.75rem", display: "flex", gap: "0.5rem" }, children: [
249
+ /* @__PURE__ */ t("button", { type: "submit", className: "cedros-admin__button cedros-admin__button--primary", disabled: B, children: B ? "Saving..." : v ? "Update" : "Create" }),
250
+ /* @__PURE__ */ t(
251
+ "button",
252
+ {
253
+ type: "button",
254
+ className: "cedros-admin__button cedros-admin__button--ghost",
255
+ onClick: () => {
256
+ u(!1), _(null);
257
+ },
258
+ children: "Cancel"
259
+ }
260
+ )
261
+ ] })
262
+ ] }),
263
+ H ? /* @__PURE__ */ a("div", { className: "cedros-admin__loading", children: [
264
+ q.loading,
265
+ " Loading rates..."
266
+ ] }) : L.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No rates yet. Add one above." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ a("table", { className: "cedros-admin__table", children: [
267
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ a("tr", { children: [
268
+ /* @__PURE__ */ t("th", { children: "Name" }),
269
+ /* @__PURE__ */ t("th", { children: "Type" }),
270
+ /* @__PURE__ */ t("th", { children: "Amount" }),
271
+ /* @__PURE__ */ t("th", { children: "Min / Max Subtotal" }),
272
+ /* @__PURE__ */ t("th", { children: "Status" }),
273
+ /* @__PURE__ */ t("th", { children: "Updated" }),
274
+ /* @__PURE__ */ t("th", {})
275
+ ] }) }),
276
+ /* @__PURE__ */ t("tbody", { children: L.map((e) => /* @__PURE__ */ a("tr", { children: [
277
+ /* @__PURE__ */ t("td", { children: e.name }),
278
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.rateType }),
279
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: P(e.amountAtomic, e.currency) }),
280
+ /* @__PURE__ */ a("td", { style: { fontSize: "0.8rem", color: "var(--cedros-admin-text-muted, #888)" }, children: [
281
+ e.minSubtotal != null ? P(e.minSubtotal, e.currency) : "—",
282
+ " / ",
283
+ e.maxSubtotal != null ? P(e.maxSubtotal, e.currency) : "—"
284
+ ] }),
285
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("span", { className: `cedros-admin__badge cedros-admin__badge--${e.active ? "success" : "muted"}`, children: e.active ? "Active" : "Inactive" }) }),
286
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem" }, children: J(e.updatedAt) }),
287
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ a("div", { style: { display: "flex", gap: "0.25rem" }, children: [
288
+ /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm", onClick: () => ee(e), children: "Edit" }),
289
+ /* @__PURE__ */ t(
290
+ "button",
291
+ {
292
+ type: "button",
293
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
294
+ onClick: () => ie(e.id),
295
+ style: { color: "var(--cedros-admin-danger, #c00)" },
296
+ children: "Delete"
297
+ }
298
+ )
299
+ ] }) })
300
+ ] }, e.id)) })
301
+ ] }) })
302
+ ] }) : /* @__PURE__ */ a("div", { children: [
303
+ /* @__PURE__ */ a("div", { className: "cedros-admin__section-header", children: [
304
+ /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Shipping" }),
305
+ /* @__PURE__ */ t(
306
+ "button",
307
+ {
308
+ type: "button",
309
+ className: "cedros-admin__button cedros-admin__button--primary",
310
+ onClick: () => {
311
+ g(null), m(M), b(!0);
312
+ },
313
+ children: "+ Add Profile"
314
+ }
315
+ )
316
+ ] }),
317
+ /* @__PURE__ */ t(x, { message: F }),
318
+ /* @__PURE__ */ t(x, { message: T }),
319
+ X && /* @__PURE__ */ a("form", { onSubmit: Y, style: { border: "1px solid var(--cedros-admin-border, #e0e0e0)", borderRadius: "4px", padding: "1rem", marginBottom: "1.5rem", maxWidth: "500px" }, children: [
320
+ /* @__PURE__ */ t("h4", { style: { margin: "0 0 0.75rem", fontSize: "0.9rem", fontWeight: 600 }, children: y ? "Edit Profile" : "New Profile" }),
321
+ /* @__PURE__ */ a("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
322
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", children: [
323
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Name *" }),
324
+ /* @__PURE__ */ t(
325
+ "input",
326
+ {
327
+ type: "text",
328
+ className: "cedros-admin__input",
329
+ required: !0,
330
+ value: c.name,
331
+ onChange: (e) => m((i) => ({ ...i, name: e.target.value })),
332
+ placeholder: "Domestic Shipping"
333
+ }
334
+ )
335
+ ] }),
336
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", children: [
337
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Description" }),
338
+ /* @__PURE__ */ t(
339
+ "input",
340
+ {
341
+ type: "text",
342
+ className: "cedros-admin__input",
343
+ value: c.description,
344
+ onChange: (e) => m((i) => ({ ...i, description: e.target.value })),
345
+ placeholder: "Optional description"
346
+ }
347
+ )
348
+ ] }),
349
+ /* @__PURE__ */ a("div", { className: "cedros-admin__field", children: [
350
+ /* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Countries (comma-separated ISO codes)" }),
351
+ /* @__PURE__ */ t(
352
+ "input",
353
+ {
354
+ type: "text",
355
+ className: "cedros-admin__input",
356
+ value: c.countries,
357
+ onChange: (e) => m((i) => ({ ...i, countries: e.target.value })),
358
+ placeholder: "US, CA, GB"
359
+ }
360
+ )
361
+ ] }),
362
+ /* @__PURE__ */ a("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
363
+ /* @__PURE__ */ t(
364
+ "input",
365
+ {
366
+ type: "checkbox",
367
+ id: "profile-active",
368
+ checked: c.active,
369
+ onChange: (e) => m((i) => ({ ...i, active: e.target.checked }))
370
+ }
371
+ ),
372
+ /* @__PURE__ */ t("label", { htmlFor: "profile-active", className: "cedros-admin__field-label", style: { margin: 0 }, children: "Active" })
373
+ ] })
374
+ ] }),
375
+ /* @__PURE__ */ a("div", { style: { marginTop: "0.75rem", display: "flex", gap: "0.5rem" }, children: [
376
+ /* @__PURE__ */ t("button", { type: "submit", className: "cedros-admin__button cedros-admin__button--primary", disabled: D, children: D ? "Saving..." : y ? "Update" : "Create" }),
377
+ /* @__PURE__ */ t(
378
+ "button",
379
+ {
380
+ type: "button",
381
+ className: "cedros-admin__button cedros-admin__button--ghost",
382
+ onClick: () => {
383
+ b(!1), g(null);
384
+ },
385
+ children: "Cancel"
386
+ }
387
+ )
388
+ ] })
389
+ ] }),
390
+ K ? /* @__PURE__ */ a("div", { className: "cedros-admin__loading", children: [
391
+ q.loading,
392
+ " Loading profiles..."
393
+ ] }) : E.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No shipping profiles found." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ a("table", { className: "cedros-admin__table", children: [
394
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ a("tr", { children: [
395
+ /* @__PURE__ */ t("th", { children: "Name" }),
396
+ /* @__PURE__ */ t("th", { children: "Countries" }),
397
+ /* @__PURE__ */ t("th", { children: "Status" }),
398
+ /* @__PURE__ */ t("th", { children: "Created" }),
399
+ /* @__PURE__ */ t("th", {})
400
+ ] }) }),
401
+ /* @__PURE__ */ t("tbody", { children: E.map((e) => /* @__PURE__ */ a("tr", { children: [
402
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t(
403
+ "button",
404
+ {
405
+ type: "button",
406
+ style: { background: "none", border: "none", cursor: "pointer", fontWeight: 600, padding: 0, color: "var(--cedros-admin-text, #333)", fontSize: "0.9rem" },
407
+ onClick: () => j(e),
408
+ children: e.name
409
+ }
410
+ ) }),
411
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", color: "var(--cedros-admin-text-muted, #888)", maxWidth: "200px", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: e.countries.length > 0 ? e.countries.join(", ") : "All" }),
412
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("span", { className: `cedros-admin__badge cedros-admin__badge--${e.active ? "success" : "muted"}`, children: e.active ? "Active" : "Inactive" }) }),
413
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem" }, children: J(e.createdAt) }),
414
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ a("div", { style: { display: "flex", gap: "0.25rem" }, children: [
415
+ /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm", onClick: () => j(e), children: "Rates" }),
416
+ /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm", onClick: () => V(e), children: "Edit" }),
417
+ /* @__PURE__ */ t(
418
+ "button",
419
+ {
420
+ type: "button",
421
+ className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
422
+ onClick: () => Z(e.id),
423
+ style: { color: "var(--cedros-admin-danger, #c00)" },
424
+ children: "Delete"
425
+ }
426
+ )
427
+ ] }) })
428
+ ] }, e.id)) })
429
+ ] }) })
430
+ ] });
431
+ }
432
+ export {
433
+ re as ShippingSection
434
+ };
@@ -1,3 +1,3 @@
1
- "use strict";const e=require("react/jsx-runtime"),l=require("react"),j=require("./index-OaWkrl0G.js"),N=require("./configApi-CxEbCAgG.js"),K=require("./useAutosave-B2p6iwh8.js"),L=require("./AutosaveIndicator-CY_YHM1D.js"),V=require("./CedrosContext-7dwmEeUY.js"),J=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function M(b){return!b||b.trim()===""?{valid:!0}:J.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function P({label:b,value:f,onChange:h,decimals:n,onDecimalsChange:S,disabled:o=!1,description:a,customSymbol:d="",customIcon:u="",onCustomSymbolChange:c,onCustomIconChange:x}){const[v,E]=l.useState(!1),p=Object.entries(V.STABLECOIN_METADATA),y=!!V.STABLECOIN_METADATA[f],C=v||!!f&&!y,w=t=>{if(t==="custom")E(!0),y&&h("");else{E(!1),h(t);const s=V.STABLECOIN_METADATA[t];s&&S&&S(s.decimals),c&&c(""),x&&x("")}};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:b}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:[p.map(([t,s])=>e.jsxs("button",{type:"button",onClick:()=>w(t),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:f===t?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:f===t?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:f===t?600:400},children:[e.jsx("img",{src:s.icon,alt:s.symbol,style:{width:20,height:20,borderRadius:"50%"},onError:r=>{r.target.style.display="none"}}),e.jsx("span",{children:s.symbol})]},t)),e.jsxs("button",{type:"button",onClick:()=>w("custom"),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:C?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:C?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:C?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Mint Address"}),(()=>{const t=M(f);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${t.valid?"":"cedros-admin__input--error"}`,value:f,onChange:s=>h(s.target.value),placeholder:"e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",disabled:o,style:{fontFamily:"monospace",fontSize:"0.875rem",borderColor:t.valid?void 0:"var(--cedros-admin-error, #dc2626)"}}),!t.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:t.error})]})})()]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:d,onChange:t=>c?.(t.target.value),placeholder:"e.g., MYTOKEN",disabled:o,style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Icon URL"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:u,onChange:t=>x?.(t.target.value),placeholder:"https://example.com/token-logo.png",disabled:o,style:{flex:1}}),u&&e.jsx("img",{src:u,alt:"Token icon preview",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--cedros-admin-border, #e5e7eb)",objectFit:"cover"},onError:t=>{t.target.style.display="none"}})]}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Shown to customers during checkout"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n??6,onChange:t=>S?.(parseInt(t.target.value,10)||0),min:0,max:18,disabled:o,style:{width:"100px"}}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Most SPL tokens use 6 decimals (like USDC)"})]})]}),f&&y&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",fontFamily:"monospace",wordBreak:"break-all"},children:f}),a&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:a})]})]})}function Z({label:b,value:f,onChange:h,disabled:n=!1,description:S}){const[o,a]=l.useState(new Set),[d,u]=l.useState(null),[c,x]=l.useState(""),v=Array.isArray(f)?f:[],E=t=>{a(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},p=()=>{h([...v,""]),u(v.length),x("")},I=(t,s)=>{const r=[...v];r[t]=s,h(r)},y=t=>{const s=v.filter((r,g)=>g!==t);h(s),a(r=>{const g=new Set;return r.forEach(_=>{_<t?g.add(_):_>t&&g.add(_-1)}),g})},T=t=>{u(t),x(v[t]||"")},C=()=>{d!==null&&(I(d,c),u(null),x(""))},w=()=>{d!==null&&v[d]===""&&y(d),u(null),x("")};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",style:{marginBottom:0},children:b}),e.jsxs("button",{type:"button",onClick:p,disabled:n,style:{display:"flex",alignItems:"center",gap:"0.25rem",padding:"0.25rem 0.5rem",fontSize:"0.75rem",border:"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.375rem",background:"var(--cedros-admin-bg, #fff)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:[j.Icons.plus,"Add"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[v.length===0&&e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.875rem",border:"1px dashed var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem"},children:'No items. Click "Add" to create one.'}),v.map((t,s)=>{const r=o.has(s),g=d===s,_=t===N.REDACTED_VALUE;return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.375rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:i=>x(i.target.value),placeholder:"Enter wallet keypair...",autoFocus:!0,style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem"},onKeyDown:i=>{i.key==="Enter"&&C(),i.key==="Escape"&&w()}}),e.jsx("button",{type:"button",onClick:C,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:j.Icons.check}),e.jsx("button",{type:"button",onClick:w,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:j.Icons.close})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r&&!_?t:_?"[REDACTED]":"••••••••••••••••••••"}),e.jsx("button",{type:"button",onClick:()=>E(s),disabled:n||_,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n||_?"not-allowed":"pointer",opacity:n||_?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:r?"Hide":"Show",children:r?j.Icons.eyeOff:j.Icons.eye}),e.jsx("button",{type:"button",onClick:()=>T(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:"Edit",children:j.Icons.settings}),e.jsx("button",{type:"button",onClick:()=>y(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-error, #ef4444)"},title:"Delete",children:j.Icons.trash})]})},s)})]}),S&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:S})]})}function q(b,f,h){const n=N.isSecretField(b,f),S=f.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),a=N.CONFIG_CATEGORIES[b]?.fields?.[f],d={isSecret:n,label:S,description:a?.description,hidden:a?.hidden,showWhen:a?.showWhen};return a?.type==="dropdown"&&a.options?{...d,type:"dropdown",options:a.options}:a?.type==="token_mint"?{...d,type:"token_mint"}:a?.type==="toggle"?{...d,type:"toggle"}:a?.type==="secret_array"?{...d,type:"secret_array",isSecret:!0}:a?.type==="solana_address"?{...d,type:"solana_address"}:a?.type==="number"?{...d,type:"number",unit:a.unit}:typeof h=="boolean"?{...d,type:"boolean"}:typeof h=="number"?{...d,type:"number",unit:a?.unit}:Array.isArray(h)?{...d,type:"array"}:typeof h=="object"&&h!==null?{...d,type:"object"}:{...d,type:"string"}}function X({category:b,config:f,originalConfig:h,isLoading:n=!1,onSave:S}){const[o,a]=l.useState(f),[d,u]=l.useState(new Set);l.useEffect(()=>{a(f)},[f]);const c=l.useMemo(()=>{const t={...o};for(const s of Object.keys(t))if(N.isSecretField(b,s)){const r=h[s],g=t[s];(g===N.REDACTED_VALUE||g===r)&&(t[s]=N.REDACTED_VALUE)}return t},[o,h,b]),x=l.useMemo(()=>{const t=o.token_mint;return typeof t!="string"||!t?!1:!M(t).valid},[o]),{status:v,error:E}=K.useAutosave({data:c,onSave:S,debounceMs:1500,enabled:!x}),p=l.useCallback((t,s)=>{a(r=>({...r,[t]:s}))},[]),I=l.useCallback(t=>{u(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),y=t=>t?e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:t}):null,T=(t,s)=>{const r=q(b,t,h[t]??s);if(r.type==="dropdown"&&r.options)return e.jsx(j.FormDropdown,{value:s,onChange:i=>p(t,i),options:r.options.map(i=>({value:i,label:i})),label:r.label,description:r.description,disabled:n});if(r.type==="token_mint")return e.jsx(P,{label:r.label,value:s,onChange:i=>p(t,i),decimals:o.token_decimals??6,onDecimalsChange:i=>p("token_decimals",i),disabled:n,description:r.description,customSymbol:o.custom_token_symbol||"",customIcon:o.custom_token_icon||"",onCustomSymbolChange:i=>p("custom_token_symbol",i),onCustomIconChange:i=>p("custom_token_icon",i)});if(r.type==="toggle")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>p(t,!s),disabled:n,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:n?"not-allowed":"pointer",position:"relative",transition:"background-color 0.2s",opacity:n?.5:1,flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:2,left:s?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{className:"cedros-admin__field-label",style:{marginBottom:0},children:r.label})]}),y(r.description)]});if(r.type==="solana_address"){const i=s||"",k=M(i);return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${k.valid?"":"cedros-admin__input--error"}`,value:i,onChange:D=>p(t,D.target.value),disabled:n,placeholder:"e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",style:{width:"100%",fontFamily:"monospace",fontSize:"0.875rem",borderColor:k.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:i&&k.valid?"2rem":void 0}}),i&&k.valid&&e.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:"var(--cedros-admin-success, #16a34a)",fontSize:"1rem"},title:"Valid Solana address",children:"✓"})]}),!k.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:k.error}),y(r.description)]})}if(r.type==="boolean")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:i=>p(t,i.target.checked),disabled:n}),r.label]}),y(r.description)]});if(r.type==="number")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.unit&&e.jsxs("span",{className:"cedros-admin__field-unit",children:[" (",r.unit,")"]})]}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s,onChange:i=>p(t,parseFloat(i.target.value)||0),disabled:n}),y(r.description)]});if(r.type==="secret_array")return e.jsx(Z,{label:r.label,value:s,onChange:i=>p(t,i),disabled:n,description:r.description});if(r.type==="array"){const i=s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea",value:i.join(`
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),j=require("./index-C0g-JxJk.js"),N=require("./configApi-DkduMQg1.js"),K=require("./useAutosave-B2p6iwh8.js"),L=require("./AutosaveIndicator-Dn_qA2hK.js"),V=require("./CedrosContext-C2RjHLaQ.js"),J=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function M(b){return!b||b.trim()===""?{valid:!0}:J.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function P({label:b,value:f,onChange:h,decimals:n,onDecimalsChange:S,disabled:o=!1,description:a,customSymbol:d="",customIcon:u="",onCustomSymbolChange:c,onCustomIconChange:x}){const[v,E]=l.useState(!1),p=Object.entries(V.STABLECOIN_METADATA),y=!!V.STABLECOIN_METADATA[f],C=v||!!f&&!y,w=t=>{if(t==="custom")E(!0),y&&h("");else{E(!1),h(t);const s=V.STABLECOIN_METADATA[t];s&&S&&S(s.decimals),c&&c(""),x&&x("")}};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:b}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:[p.map(([t,s])=>e.jsxs("button",{type:"button",onClick:()=>w(t),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:f===t?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:f===t?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:f===t?600:400},children:[e.jsx("img",{src:s.icon,alt:s.symbol,style:{width:20,height:20,borderRadius:"50%"},onError:r=>{r.target.style.display="none"}}),e.jsx("span",{children:s.symbol})]},t)),e.jsxs("button",{type:"button",onClick:()=>w("custom"),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:C?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:C?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:C?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Mint Address"}),(()=>{const t=M(f);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${t.valid?"":"cedros-admin__input--error"}`,value:f,onChange:s=>h(s.target.value),placeholder:"e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",disabled:o,style:{fontFamily:"monospace",fontSize:"0.875rem",borderColor:t.valid?void 0:"var(--cedros-admin-error, #dc2626)"}}),!t.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:t.error})]})})()]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:d,onChange:t=>c?.(t.target.value),placeholder:"e.g., MYTOKEN",disabled:o,style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Icon URL"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:u,onChange:t=>x?.(t.target.value),placeholder:"https://example.com/token-logo.png",disabled:o,style:{flex:1}}),u&&e.jsx("img",{src:u,alt:"Token icon preview",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--cedros-admin-border, #e5e7eb)",objectFit:"cover"},onError:t=>{t.target.style.display="none"}})]}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Shown to customers during checkout"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n??6,onChange:t=>S?.(parseInt(t.target.value,10)||0),min:0,max:18,disabled:o,style:{width:"100px"}}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Most SPL tokens use 6 decimals (like USDC)"})]})]}),f&&y&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",fontFamily:"monospace",wordBreak:"break-all"},children:f}),a&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:a})]})]})}function Z({label:b,value:f,onChange:h,disabled:n=!1,description:S}){const[o,a]=l.useState(new Set),[d,u]=l.useState(null),[c,x]=l.useState(""),v=Array.isArray(f)?f:[],E=t=>{a(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},p=()=>{h([...v,""]),u(v.length),x("")},I=(t,s)=>{const r=[...v];r[t]=s,h(r)},y=t=>{const s=v.filter((r,g)=>g!==t);h(s),a(r=>{const g=new Set;return r.forEach(_=>{_<t?g.add(_):_>t&&g.add(_-1)}),g})},T=t=>{u(t),x(v[t]||"")},C=()=>{d!==null&&(I(d,c),u(null),x(""))},w=()=>{d!==null&&v[d]===""&&y(d),u(null),x("")};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",style:{marginBottom:0},children:b}),e.jsxs("button",{type:"button",onClick:p,disabled:n,style:{display:"flex",alignItems:"center",gap:"0.25rem",padding:"0.25rem 0.5rem",fontSize:"0.75rem",border:"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.375rem",background:"var(--cedros-admin-bg, #fff)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:[j.Icons.plus,"Add"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[v.length===0&&e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.875rem",border:"1px dashed var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem"},children:'No items. Click "Add" to create one.'}),v.map((t,s)=>{const r=o.has(s),g=d===s,_=t===N.REDACTED_VALUE;return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.375rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:i=>x(i.target.value),placeholder:"Enter wallet keypair...",autoFocus:!0,style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem"},onKeyDown:i=>{i.key==="Enter"&&C(),i.key==="Escape"&&w()}}),e.jsx("button",{type:"button",onClick:C,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:j.Icons.check}),e.jsx("button",{type:"button",onClick:w,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:j.Icons.close})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r&&!_?t:_?"[REDACTED]":"••••••••••••••••••••"}),e.jsx("button",{type:"button",onClick:()=>E(s),disabled:n||_,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n||_?"not-allowed":"pointer",opacity:n||_?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:r?"Hide":"Show",children:r?j.Icons.eyeOff:j.Icons.eye}),e.jsx("button",{type:"button",onClick:()=>T(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:"Edit",children:j.Icons.settings}),e.jsx("button",{type:"button",onClick:()=>y(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-error, #ef4444)"},title:"Delete",children:j.Icons.trash})]})},s)})]}),S&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:S})]})}function q(b,f,h){const n=N.isSecretField(b,f),S=f.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),a=N.CONFIG_CATEGORIES[b]?.fields?.[f],d={isSecret:n,label:S,description:a?.description,hidden:a?.hidden,showWhen:a?.showWhen};return a?.type==="dropdown"&&a.options?{...d,type:"dropdown",options:a.options}:a?.type==="token_mint"?{...d,type:"token_mint"}:a?.type==="toggle"?{...d,type:"toggle"}:a?.type==="secret_array"?{...d,type:"secret_array",isSecret:!0}:a?.type==="solana_address"?{...d,type:"solana_address"}:a?.type==="number"?{...d,type:"number",unit:a.unit}:typeof h=="boolean"?{...d,type:"boolean"}:typeof h=="number"?{...d,type:"number",unit:a?.unit}:Array.isArray(h)?{...d,type:"array"}:typeof h=="object"&&h!==null?{...d,type:"object"}:{...d,type:"string"}}function X({category:b,config:f,originalConfig:h,isLoading:n=!1,onSave:S}){const[o,a]=l.useState(f),[d,u]=l.useState(new Set);l.useEffect(()=>{a(f)},[f]);const c=l.useMemo(()=>{const t={...o};for(const s of Object.keys(t))if(N.isSecretField(b,s)){const r=h[s],g=t[s];(g===N.REDACTED_VALUE||g===r)&&(t[s]=N.REDACTED_VALUE)}return t},[o,h,b]),x=l.useMemo(()=>{const t=o.token_mint;return typeof t!="string"||!t?!1:!M(t).valid},[o]),{status:v,error:E}=K.useAutosave({data:c,onSave:S,debounceMs:1500,enabled:!x}),p=l.useCallback((t,s)=>{a(r=>({...r,[t]:s}))},[]),I=l.useCallback(t=>{u(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),y=t=>t?e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:t}):null,T=(t,s)=>{const r=q(b,t,h[t]??s);if(r.type==="dropdown"&&r.options)return e.jsx(j.FormDropdown,{value:s,onChange:i=>p(t,i),options:r.options.map(i=>({value:i,label:i})),label:r.label,description:r.description,disabled:n});if(r.type==="token_mint")return e.jsx(P,{label:r.label,value:s,onChange:i=>p(t,i),decimals:o.token_decimals??6,onDecimalsChange:i=>p("token_decimals",i),disabled:n,description:r.description,customSymbol:o.custom_token_symbol||"",customIcon:o.custom_token_icon||"",onCustomSymbolChange:i=>p("custom_token_symbol",i),onCustomIconChange:i=>p("custom_token_icon",i)});if(r.type==="toggle")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>p(t,!s),disabled:n,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:n?"not-allowed":"pointer",position:"relative",transition:"background-color 0.2s",opacity:n?.5:1,flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:2,left:s?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{className:"cedros-admin__field-label",style:{marginBottom:0},children:r.label})]}),y(r.description)]});if(r.type==="solana_address"){const i=s||"",k=M(i);return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${k.valid?"":"cedros-admin__input--error"}`,value:i,onChange:D=>p(t,D.target.value),disabled:n,placeholder:"e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",style:{width:"100%",fontFamily:"monospace",fontSize:"0.875rem",borderColor:k.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:i&&k.valid?"2rem":void 0}}),i&&k.valid&&e.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:"var(--cedros-admin-success, #16a34a)",fontSize:"1rem"},title:"Valid Solana address",children:"✓"})]}),!k.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:k.error}),y(r.description)]})}if(r.type==="boolean")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:i=>p(t,i.target.checked),disabled:n}),r.label]}),y(r.description)]});if(r.type==="number")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.unit&&e.jsxs("span",{className:"cedros-admin__field-unit",children:[" (",r.unit,")"]})]}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s,onChange:i=>p(t,parseFloat(i.target.value)||0),disabled:n}),y(r.description)]});if(r.type==="secret_array")return e.jsx(Z,{label:r.label,value:s,onChange:i=>p(t,i),disabled:n,description:r.description});if(r.type==="array"){const i=s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea",value:i.join(`
2
2
  `),onChange:k=>p(t,k.target.value.split(`
3
3
  `).filter(Boolean)),placeholder:"One item per line",rows:3,disabled:n}),y(r.description)]})}if(r.type==="object")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea cedros-admin__textarea--mono",value:JSON.stringify(s,null,2),onChange:i=>{try{p(t,JSON.parse(i.target.value))}catch{}},rows:5,disabled:n}),y(r.description)]});const g=d.has(t),_=r.isSecret&&!g&&s===N.REDACTED_VALUE?N.REDACTED_VALUE:s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.isSecret&&e.jsx("span",{className:"cedros-admin__field-secret",children:" (secret)"})]}),e.jsxs("div",{className:"cedros-admin__input-group",children:[e.jsx("input",{type:r.isSecret&&!g?"password":"text",className:"cedros-admin__input",value:_,onChange:i=>p(t,i.target.value),disabled:n,placeholder:r.isSecret?"••••••••":""}),r.isSecret&&e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>I(t),style:{padding:"0.5rem",minWidth:"auto"},title:g?"Hide":"Show",children:g?j.Icons.eyeOff:j.Icons.eye})]}),y(r.description)]})},C=Object.keys(o),w=t=>{const s=q(b,t,h[t]??o[t]);if(s.hidden||s.showWhen&&!o[s.showWhen])return!1;if(t==="token_decimals"){const r=o.token_mint;if(r&&V.STABLECOIN_METADATA[r])return!1}return!0};return e.jsxs("div",{className:"cedros-admin__config-editor",children:[e.jsx("div",{className:"cedros-admin__config-fields",children:C.filter(w).map(t=>e.jsx("div",{className:"cedros-admin__config-field",children:T(t,o[t])},t))}),e.jsx("div",{className:"cedros-admin__config-actions",children:e.jsx("div",{className:"cedros-admin__autosave-status",children:e.jsx(L.AutosaveIndicator,{status:v,error:E})})})]})}function Y({serverUrl:b,apiKey:f,authManager:h,category:n,title:S,description:o,enabledField:a="enabled",showEnabledToggle:d=!1}){const u=l.useMemo(()=>new N.ConfigApiClient(b,void 0,h),[b,h]),[c,x]=l.useState(null),[v,E]=l.useState([]),[p,I]=l.useState(!1),[y,T]=l.useState(!0),[C,w]=l.useState(null),[t,s]=l.useState(null),[r,g]=l.useState(!1),_=N.CONFIG_CATEGORIES[n]||{label:n,icon:"⚙️"},i=S||_.label,k=o||_.description,D=l.useCallback(async()=>{T(!0),w(null);try{const m=await u.getConfig(n,!0);x(m)}catch{x(null),w("Failed to load settings")}finally{T(!1)}},[u,n]);l.useEffect(()=>{D()},[D]);const B=l.useCallback(async()=>{try{const m=await u.getHistory(n,20);E(m.history)}catch{E([])}},[u,n]);l.useEffect(()=>{p&&B()},[p,B]);const U=l.useCallback(async m=>{await u.updateConfig(n,m,"Updated via admin dashboard")},[u,n]),F=l.useCallback(async m=>u.validateConfig(n,m),[u,n]),[z,O]=l.useState(!1),G=l.useCallback(async()=>{if(!c||z)return;const m=!!c.config[a],R=!m,W={...c.config,[a]:R};O(!0),x({...c,config:W});try{await u.updateConfig(n,W,`${R?"Enabled":"Disabled"} via admin dashboard`)}catch(H){x({...c,config:{...c.config,[a]:m}}),w(H instanceof Error?H.message:"Failed to save enabled state")}finally{O(!1)}},[c,u,n,a,z]),A=!!c?.config[a];return y&&!c?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[j.Icons.loading," Loading ",i," settings..."]})}):e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx(j.ErrorBanner,{message:C,onRetry:D}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[e.jsx("span",{style:{marginRight:"0.5rem"},children:_.icon}),i]}),k&&e.jsx("p",{className:"cedros-admin__text-muted",style:{marginTop:"0.25rem"},children:k})]}),d&&c&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:A?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:A?"Enabled":"Disabled"}),e.jsx("button",{type:"button",role:"switch","aria-checked":A,onClick:G,disabled:z,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:A?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:z?"wait":"pointer",position:"relative",transition:"background-color 0.2s",flexShrink:0,opacity:z?.6:1},children:e.jsx("span",{style:{position:"absolute",top:2,left:A?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})]}),c&&e.jsxs("div",{className:"cedros-admin__settings-editor",style:{marginTop:"1rem",opacity:d&&!A?.6:1,pointerEvents:d&&!A?"none":"auto"},children:[d&&!A&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)",pointerEvents:"auto"},children:"This payment method is disabled. Enable it using the toggle above to accept payments."}),e.jsx(X,{category:c.category,config:c.config,originalConfig:c.config,onSave:U,onValidate:F})]}),p&&e.jsxs("div",{className:"cedros-admin__settings-history",style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{marginBottom:"0.75rem",fontWeight:600},children:"Change History"}),v.length===0?e.jsx("p",{className:"cedros-admin__text-muted",children:"No history entries found."}):e.jsx("div",{className:"cedros-admin__settings-timeline",children:v.map(m=>e.jsxs("div",{className:"cedros-admin__settings-timeline-item",children:[e.jsx("div",{className:"cedros-admin__settings-timeline-dot"}),e.jsxs("div",{className:"cedros-admin__settings-timeline-content",children:[e.jsxs("div",{className:"cedros-admin__settings-timeline-header",children:[e.jsx("code",{children:m.configKey}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${m.action.toLowerCase()}`,children:m.action})]}),e.jsxs("div",{className:"cedros-admin__settings-timeline-meta",children:[j.formatDateTime(m.changedAt)," by ",m.changedBy]})]})]},m.id))})]}),t&&e.jsx("div",{style:{marginTop:"1rem",padding:"0.75rem 1rem",borderRadius:"0.375rem",backgroundColor:t.valid?"var(--cedros-admin-success-bg, #dcfce7)":"var(--cedros-admin-error-bg, #fef2f2)",border:`1px solid ${t.valid?"var(--cedros-admin-success-border, #86efac)":"var(--cedros-admin-error-border, #fecaca)"}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:t.valid?"var(--cedros-admin-success, #16a34a)":"var(--cedros-admin-error, #dc2626)",marginBottom:t.errors.length>0||t.warnings.length>0?"0.5rem":0},children:t.valid?"✓ Configuration is valid":"✗ Validation failed"}),t.errors.length>0&&e.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.875rem"},children:t.errors.map((m,R)=>e.jsx("li",{children:m},R))}),t.warnings.length>0&&e.jsx("ul",{style:{margin:t.errors.length>0?"0.5rem 0 0":0,paddingLeft:"1.25rem",color:"var(--cedros-admin-warning, #ca8a04)",fontSize:"0.875rem"},children:t.warnings.map((m,R)=>e.jsx("li",{children:m},R))})]}),e.jsx("button",{type:"button",onClick:()=>s(null),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"1.25rem",lineHeight:1},title:"Dismiss",children:"×"})]})}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>I(!p),children:p?"Hide History":"History"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r||!c,onClick:async()=>{if(c){g(!0),s(null);try{const m=await F(c.config);s(m)}catch(m){s({valid:!1,errors:[m instanceof Error?m.message:"Validation failed"],warnings:[]})}finally{g(!1)}}},children:r?"Validating...":"Validate"})]})]})}exports.SingleCategorySettings=Y;
@@ -1,10 +1,10 @@
1
1
  import { jsxs as i, jsx as t, Fragment as W } from "react/jsx-runtime";
2
2
  import { useState as S, useEffect as j, useMemo as H, useCallback as z } from "react";
3
- import { I as E, F as Q, E as L, h as ee } from "./index-BHF82XBB.mjs";
4
- import { R as B, i as P, C as Z, a as te } from "./configApi-Ch0Rr7TD.mjs";
3
+ import { I as E, F as Q, E as L, k as ee } from "./index-DXnuQp5x.mjs";
4
+ import { R as B, i as P, C as Z, a as te } from "./configApi-6XhAJGKX.mjs";
5
5
  import { u as re } from "./useAutosave-YwMqRzqy.mjs";
6
- import { A as ne } from "./AutosaveIndicator-BJsg_kFZ.mjs";
7
- import { S as F } from "./CedrosContext-DQUbL8yP.mjs";
6
+ import { A as ne } from "./AutosaveIndicator-Bed0-ekg.mjs";
7
+ import { S as F } from "./CedrosContext-CY6zvjvJ.mjs";
8
8
  const ie = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
9
9
  function O(b) {
10
10
  return !b || b.trim() === "" ? { valid: !0 } : ie.test(b.trim()) ? { valid: !0 } : { valid: !1, error: "Invalid Solana address" };
@@ -1,9 +1,9 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
2
  import { useState as h, useCallback as z, useEffect as j } from "react";
3
- import { I as H, E as V, F as x } from "./index-BHF82XBB.mjs";
3
+ import { I as H, E as V, F as x } from "./index-DXnuQp5x.mjs";
4
4
  import { T as d } from "./Toggle-DAxIdpY4.mjs";
5
5
  import { u as q } from "./useAutosave-YwMqRzqy.mjs";
6
- import { A as X } from "./AutosaveIndicator-BJsg_kFZ.mjs";
6
+ import { A as X } from "./AutosaveIndicator-Bed0-ekg.mjs";
7
7
  const C = {
8
8
  enabled: !0,
9
9
  relatedProducts: {