@cedros/pay-react 1.1.16 → 1.1.18

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 (149) hide show
  1. package/dist/AISettingsSection-C-thWh51.js +51 -0
  2. package/dist/AISettingsSection-CD9IRyR1.mjs +539 -0
  3. package/dist/AutosaveIndicator-DxemlKnX.js +1 -0
  4. package/dist/AutosaveIndicator-G2CRN8hH.mjs +35 -0
  5. package/dist/{CedrosContext-D7nh5-Zh.mjs → CedrosContext-BnJ2Cf7R.mjs} +1179 -642
  6. package/dist/CedrosContext-C26DlvLF.js +6 -0
  7. package/dist/CryptoButton-BdOtL7w-.mjs +542 -0
  8. package/dist/CryptoButton-N8kRfNDO.js +1 -0
  9. package/dist/FAQSection-CyYK9OAN.mjs +366 -0
  10. package/dist/FAQSection-_pm1ekTe.js +1 -0
  11. package/dist/MessagingSection-BHzf1Mhu.js +1 -0
  12. package/dist/MessagingSection-DO2yPTvs.mjs +347 -0
  13. package/dist/PaymentSettingsSection--Aqlne1F.mjs +94 -0
  14. package/dist/PaymentSettingsSection-DpENgoca.js +1 -0
  15. package/dist/SettingsSection-CGKKGXWz.mjs +57 -0
  16. package/dist/SettingsSection-DNoODw7i.js +1 -0
  17. package/dist/SingleCategorySettings-8DCtLcow.mjs +1421 -0
  18. package/dist/SingleCategorySettings-NLBYxM0O.js +3 -0
  19. package/dist/StorefrontSection-BEOMtSAg.js +1 -0
  20. package/dist/StorefrontSection-Mzr1H51w.mjs +765 -0
  21. package/dist/SubscriptionsSection-4b29i-41.js +1 -0
  22. package/dist/SubscriptionsSection-Dy1e15fe.mjs +616 -0
  23. package/dist/Toggle-CsPSF8Dr.js +1 -0
  24. package/dist/Toggle-DAxIdpY4.mjs +48 -0
  25. package/dist/WalletManager-D6BYTwXn.js +1 -0
  26. package/dist/{WalletManager-oEjZhaFk.mjs → WalletManager-HXXyARQ7.mjs} +36 -32
  27. package/dist/components/CedrosPay.d.ts.map +1 -1
  28. package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
  29. package/dist/components/PaymentModal.d.ts.map +1 -1
  30. package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
  31. package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
  32. package/dist/components/admin/AdminAuthManager.d.ts +2 -1
  33. package/dist/components/admin/AdminAuthManager.d.ts.map +1 -1
  34. package/dist/components/admin/AutosaveIndicator.d.ts +7 -0
  35. package/dist/components/admin/AutosaveIndicator.d.ts.map +1 -0
  36. package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  37. package/dist/components/admin/ConfigEditor.d.ts +0 -2
  38. package/dist/components/admin/ConfigEditor.d.ts.map +1 -1
  39. package/dist/components/admin/MessagingSection.d.ts.map +1 -1
  40. package/dist/components/admin/ProductsSection.d.ts.map +1 -1
  41. package/dist/components/admin/RefundsSection.d.ts.map +1 -1
  42. package/dist/components/admin/SecretArrayEditor.d.ts +16 -0
  43. package/dist/components/admin/SecretArrayEditor.d.ts.map +1 -0
  44. package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
  45. package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
  46. package/dist/components/admin/Toggle.d.ts +14 -0
  47. package/dist/components/admin/Toggle.d.ts.map +1 -0
  48. package/dist/components/admin/TokenMintSelector.d.ts +27 -0
  49. package/dist/components/admin/TokenMintSelector.d.ts.map +1 -0
  50. package/dist/components/admin/configApi.d.ts +5 -3
  51. package/dist/components/admin/configApi.d.ts.map +1 -1
  52. package/dist/components/admin/index.d.ts +8 -9
  53. package/dist/components/admin/index.d.ts.map +1 -1
  54. package/dist/components/admin/sections-more.d.ts +2 -9
  55. package/dist/components/admin/sections-more.d.ts.map +1 -1
  56. package/dist/context/CedrosContext.d.ts +1 -1
  57. package/dist/context/CedrosContext.d.ts.map +1 -1
  58. package/dist/crypto-only.js +1 -1
  59. package/dist/crypto-only.mjs +391 -380
  60. package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts +2 -0
  61. package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts.map +1 -0
  62. package/dist/ecommerce/__tests__/storage.test.d.ts +2 -0
  63. package/dist/ecommerce/__tests__/storage.test.d.ts.map +1 -0
  64. package/dist/ecommerce/adapters/CommerceAdapter.d.ts +5 -0
  65. package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  66. package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
  67. package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  68. package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts +2 -0
  69. package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts.map +1 -0
  70. package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
  71. package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -1
  72. package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
  73. package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  74. package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -1
  75. package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -1
  76. package/dist/ecommerce/config/context.d.ts.map +1 -1
  77. package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -1
  78. package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
  79. package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -1
  80. package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -1
  81. package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -1
  82. package/dist/ecommerce/index.d.ts +2 -0
  83. package/dist/ecommerce/index.d.ts.map +1 -1
  84. package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -1
  85. package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -1
  86. package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +1 -1
  87. package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  88. package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
  89. package/dist/ecommerce/utils/storage.d.ts +1 -1
  90. package/dist/ecommerce/utils/storage.d.ts.map +1 -1
  91. package/dist/hooks/useCreditsPayment.d.ts.map +1 -1
  92. package/dist/hooks/useCreditsSubscription.d.ts.map +1 -1
  93. package/dist/hooks/useCryptoSubscription.d.ts.map +1 -1
  94. package/dist/hooks/useRefundVerification.d.ts.map +1 -1
  95. package/dist/hooks/useStripeCheckout.d.ts +1 -1
  96. package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
  97. package/dist/hooks/useSubscription.d.ts.map +1 -1
  98. package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
  99. package/dist/hooks/useX402Payment.d.ts.map +1 -1
  100. package/dist/index-B-0trqeD.js +84 -0
  101. package/dist/index-bbSf3B7-.mjs +22915 -0
  102. package/dist/index.js +1 -1
  103. package/dist/index.mjs +67 -72
  104. package/dist/managers/CreditsManager.d.ts +6 -0
  105. package/dist/managers/CreditsManager.d.ts.map +1 -1
  106. package/dist/managers/ManagerCache.d.ts.map +1 -1
  107. package/dist/managers/RouteDiscoveryManager.d.ts +3 -0
  108. package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
  109. package/dist/managers/StripeManager.d.ts +15 -0
  110. package/dist/managers/StripeManager.d.ts.map +1 -1
  111. package/dist/managers/SubscriptionChangeManager.d.ts.map +1 -1
  112. package/dist/managers/SubscriptionManager.d.ts +7 -14
  113. package/dist/managers/SubscriptionManager.d.ts.map +1 -1
  114. package/dist/managers/WalletManager.d.ts +2 -1
  115. package/dist/managers/WalletManager.d.ts.map +1 -1
  116. package/dist/managers/X402Manager.d.ts.map +1 -1
  117. package/dist/{sections-CL3lbNui.js → sections-CKwGmrzV.js} +1 -1
  118. package/dist/{sections-DnmB0qdx.mjs → sections-DpEdFL1B.mjs} +1 -1
  119. package/dist/stripe-only.js +1 -1
  120. package/dist/stripe-only.mjs +67 -72
  121. package/dist/telemetry.js +1 -1
  122. package/dist/telemetry.mjs +23 -25
  123. package/dist/testing/index.js +1 -1
  124. package/dist/testing/index.mjs +1 -1
  125. package/dist/types/index.d.ts +13 -2
  126. package/dist/types/index.d.ts.map +1 -1
  127. package/dist/useAutosave-B2p6iwh8.js +1 -0
  128. package/dist/useAutosave-YwMqRzqy.mjs +44 -0
  129. package/dist/utils/circuitBreaker.d.ts +3 -1
  130. package/dist/utils/circuitBreaker.d.ts.map +1 -1
  131. package/dist/utils/cspHelper.d.ts +6 -0
  132. package/dist/utils/cspHelper.d.ts.map +1 -1
  133. package/dist/utils/csvHelpers.d.ts +0 -41
  134. package/dist/utils/csvHelpers.d.ts.map +1 -1
  135. package/dist/utils/errorHandling.d.ts.map +1 -1
  136. package/dist/utils/exponentialBackoff.d.ts.map +1 -1
  137. package/dist/utils/requestDeduplication.d.ts.map +1 -1
  138. package/dist/utils/telemetry.d.ts.map +1 -1
  139. package/dist/utils/validateConfig.d.ts +1 -1
  140. package/dist/utils/validateConfig.d.ts.map +1 -1
  141. package/dist/walletDetection-JZR3UCOa.mjs +27 -0
  142. package/dist/walletDetection-bNmV5ItZ.js +1 -0
  143. package/dist/{walletPool-BR6etEiq.mjs → walletPool-BV_z1lEA.mjs} +1 -1
  144. package/dist/{walletPool-BZyAG4YS.js → walletPool-DjA7J3a9.js} +1 -1
  145. package/package.json +8 -7
  146. package/dist/CedrosContext-C2v_s8cc.js +0 -6
  147. package/dist/WalletManager-B5KLZK2D.js +0 -1
  148. package/dist/index-BU0vgA-7.js +0 -136
  149. package/dist/index-DWXEBUbu.mjs +0 -27912
@@ -0,0 +1,366 @@
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
+ import { useState as r, useCallback as R, useEffect as V, useMemo as G } from "react";
3
+ import { a0 as H, a1 as Y, $ as l } from "./index-bbSf3B7-.mjs";
4
+ function M({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
5
+ const [_, F] = r([]), [$, C] = r(!0), [S, N] = r(!1), [v, k] = r(null), [Q, I] = r(!1), [y, E] = r(""), [f, x] = r("all"), [q, w] = r(null), [T, b] = r(null), [n, m] = r({
6
+ question: "",
7
+ answer: "",
8
+ keywordsCsv: "",
9
+ active: !0,
10
+ useInChat: !0,
11
+ displayOnPage: !0
12
+ }), p = R(async () => {
13
+ C(!0);
14
+ try {
15
+ b(null);
16
+ let e;
17
+ const s = `/admin/faqs?limit=${A}`;
18
+ if (o?.isAuthenticated())
19
+ e = await o.fetchWithAuth(s);
20
+ else {
21
+ const c = { "Content-Type": "application/json" };
22
+ d && (c["X-API-Key"] = d);
23
+ const i = await fetch(`${u}${s}`, { headers: c });
24
+ if (!i.ok) throw new Error(`Failed to fetch FAQs: ${i.status}`);
25
+ e = await i.json();
26
+ }
27
+ F(e.faqs || []);
28
+ } catch {
29
+ F([]), b("Failed to load FAQs");
30
+ } finally {
31
+ C(!1);
32
+ }
33
+ }, [u, d, A, o]);
34
+ V(() => {
35
+ p();
36
+ }, [p]);
37
+ const D = async (e) => {
38
+ if (e.preventDefault(), !(!n.question.trim() || !n.answer.trim())) {
39
+ I(!0);
40
+ try {
41
+ const s = n.keywordsCsv.split(",").map((i) => i.trim().toLowerCase()).filter(Boolean), c = {
42
+ question: n.question.trim(),
43
+ answer: n.answer.trim(),
44
+ keywords: s,
45
+ active: n.active,
46
+ useInChat: n.useInChat,
47
+ displayOnPage: n.displayOnPage
48
+ };
49
+ if (v) {
50
+ const i = `/admin/faqs/${v.id}`;
51
+ if (o?.isAuthenticated())
52
+ await o.fetchWithAuth(i, { method: "PUT", body: JSON.stringify(c) });
53
+ else {
54
+ const h = { "Content-Type": "application/json" };
55
+ d && (h["X-API-Key"] = d);
56
+ const O = await fetch(`${u}${i}`, { method: "PUT", headers: h, body: JSON.stringify(c) });
57
+ if (!O.ok) throw new Error(`Failed to update FAQ: ${O.status}`);
58
+ }
59
+ } else if (o?.isAuthenticated())
60
+ await o.fetchWithAuth("/admin/faqs", { method: "POST", body: JSON.stringify(c) });
61
+ else {
62
+ const i = { "Content-Type": "application/json" };
63
+ d && (i["X-API-Key"] = d);
64
+ const h = await fetch(`${u}/admin/faqs`, { method: "POST", headers: i, body: JSON.stringify(c) });
65
+ if (!h.ok) throw new Error(`Failed to create FAQ: ${h.status}`);
66
+ }
67
+ g(), p();
68
+ } catch {
69
+ b(v ? "Failed to update FAQ" : "Failed to create FAQ");
70
+ } finally {
71
+ I(!1);
72
+ }
73
+ }
74
+ }, j = async (e) => {
75
+ try {
76
+ const s = `/admin/faqs/${e}`;
77
+ if (o?.isAuthenticated())
78
+ await o.fetchWithAuth(s, { method: "DELETE" });
79
+ else {
80
+ const c = { "Content-Type": "application/json" };
81
+ d && (c["X-API-Key"] = d);
82
+ const i = await fetch(`${u}${s}`, { method: "DELETE", headers: c });
83
+ if (!i.ok) throw new Error(`Failed to delete FAQ: ${i.status}`);
84
+ }
85
+ p();
86
+ } catch {
87
+ b("Failed to delete FAQ");
88
+ }
89
+ w(null);
90
+ }, L = async (e) => {
91
+ try {
92
+ const s = `/admin/faqs/${e.id}`, c = { ...e, active: !e.active };
93
+ if (o?.isAuthenticated())
94
+ await o.fetchWithAuth(s, { method: "PUT", body: JSON.stringify(c) });
95
+ else {
96
+ const i = { "Content-Type": "application/json" };
97
+ d && (i["X-API-Key"] = d);
98
+ const h = await fetch(`${u}${s}`, { method: "PUT", headers: i, body: JSON.stringify(c) });
99
+ if (!h.ok) throw new Error(`Failed to update FAQ: ${h.status}`);
100
+ }
101
+ p();
102
+ } catch {
103
+ b("Failed to update FAQ status");
104
+ }
105
+ }, g = () => {
106
+ m({ question: "", answer: "", keywordsCsv: "", active: !0, useInChat: !0, displayOnPage: !0 }), k(null), N(!1);
107
+ }, W = (e) => {
108
+ m({
109
+ question: e.question,
110
+ answer: e.answer,
111
+ keywordsCsv: e.keywords.join(", "),
112
+ active: e.active,
113
+ useInChat: e.useInChat ?? !0,
114
+ displayOnPage: e.displayOnPage ?? !0
115
+ }), k(e), N(!0);
116
+ }, B = _.length, J = _.filter((e) => e.active).length, X = _.filter((e) => e.active && e.useInChat).length, U = _.filter((e) => e.active && e.displayOnPage).length, P = G(() => _.filter((e) => {
117
+ if (f === "active" && !e.active || f === "inactive" && e.active) return !1;
118
+ if (y) {
119
+ const s = y.toLowerCase();
120
+ return e.question.toLowerCase().includes(s) || e.answer.toLowerCase().includes(s) || e.keywords.some((c) => c.includes(s));
121
+ }
122
+ return !0;
123
+ }), [_, f, y]);
124
+ return /* @__PURE__ */ a("div", { className: "cedros-admin__faqs", children: [
125
+ /* @__PURE__ */ t(H, { message: T, onRetry: p }),
126
+ /* @__PURE__ */ t(
127
+ Y,
128
+ {
129
+ stats: [
130
+ { label: "Total FAQs", value: B },
131
+ { label: "Active", value: J, variant: "success" },
132
+ { label: "In Chat", value: X },
133
+ { label: "On Page", value: U }
134
+ ]
135
+ }
136
+ ),
137
+ /* @__PURE__ */ a("div", { className: "cedros-admin__section", children: [
138
+ /* @__PURE__ */ a("div", { className: "cedros-admin__section-header", children: [
139
+ /* @__PURE__ */ a("div", { className: "cedros-admin__section-header-left", children: [
140
+ /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Knowledge Base" }),
141
+ /* @__PURE__ */ t("p", { className: "cedros-admin__section-subtitle", children: "Manage FAQs for the AI chat assistant and public FAQ page." })
142
+ ] }),
143
+ /* @__PURE__ */ t("div", { className: "cedros-admin__section-header-right", children: /* @__PURE__ */ a(
144
+ "button",
145
+ {
146
+ className: "cedros-admin__button cedros-admin__button--primary",
147
+ onClick: () => {
148
+ g(), N(!0);
149
+ },
150
+ children: [
151
+ l.plus,
152
+ " Add FAQ"
153
+ ]
154
+ }
155
+ ) })
156
+ ] }),
157
+ /* @__PURE__ */ a("div", { className: "cedros-admin__filters", style: { display: "flex", gap: "1rem", marginBottom: "1rem" }, children: [
158
+ /* @__PURE__ */ t(
159
+ "input",
160
+ {
161
+ type: "text",
162
+ placeholder: "Search FAQs...",
163
+ value: y,
164
+ onChange: (e) => E(e.target.value),
165
+ className: "cedros-admin__input",
166
+ style: { flex: 1, maxWidth: 300 }
167
+ }
168
+ ),
169
+ /* @__PURE__ */ a(
170
+ "select",
171
+ {
172
+ value: f,
173
+ onChange: (e) => x(e.target.value),
174
+ className: "cedros-admin__select",
175
+ children: [
176
+ /* @__PURE__ */ t("option", { value: "all", children: "All Status" }),
177
+ /* @__PURE__ */ t("option", { value: "active", children: "Active Only" }),
178
+ /* @__PURE__ */ t("option", { value: "inactive", children: "Inactive Only" })
179
+ ]
180
+ }
181
+ )
182
+ ] }),
183
+ S && /* @__PURE__ */ t("div", { className: "cedros-admin__form-container", style: { marginBottom: "1.5rem" }, children: /* @__PURE__ */ a("form", { onSubmit: D, className: "cedros-admin__form", children: [
184
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-header", children: [
185
+ /* @__PURE__ */ t("h4", { children: v ? "Edit FAQ" : "Add New FAQ" }),
186
+ /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button--icon", onClick: g, children: l.close })
187
+ ] }),
188
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-group", children: [
189
+ /* @__PURE__ */ t("label", { className: "cedros-admin__label", children: "Question *" }),
190
+ /* @__PURE__ */ t(
191
+ "input",
192
+ {
193
+ type: "text",
194
+ value: n.question,
195
+ onChange: (e) => m((s) => ({ ...s, question: e.target.value })),
196
+ className: "cedros-admin__input",
197
+ placeholder: "What is your return policy?",
198
+ required: !0
199
+ }
200
+ )
201
+ ] }),
202
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-group", children: [
203
+ /* @__PURE__ */ t("label", { className: "cedros-admin__label", children: "Answer *" }),
204
+ /* @__PURE__ */ t(
205
+ "textarea",
206
+ {
207
+ value: n.answer,
208
+ onChange: (e) => m((s) => ({ ...s, answer: e.target.value })),
209
+ className: "cedros-admin__textarea",
210
+ placeholder: "We accept returns within 30 days...",
211
+ rows: 4,
212
+ required: !0
213
+ }
214
+ ),
215
+ /* @__PURE__ */ t("span", { className: "cedros-admin__hint", children: "Supports markdown formatting." })
216
+ ] }),
217
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-group", children: [
218
+ /* @__PURE__ */ t("label", { className: "cedros-admin__label", children: "Keywords" }),
219
+ /* @__PURE__ */ t(
220
+ "input",
221
+ {
222
+ type: "text",
223
+ value: n.keywordsCsv,
224
+ onChange: (e) => m((s) => ({ ...s, keywordsCsv: e.target.value })),
225
+ className: "cedros-admin__input",
226
+ placeholder: "returns, refund, policy"
227
+ }
228
+ ),
229
+ /* @__PURE__ */ t("span", { className: "cedros-admin__hint", children: "Comma-separated keywords to help AI find this FAQ." })
230
+ ] }),
231
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-group", children: [
232
+ /* @__PURE__ */ a("label", { className: "cedros-admin__checkbox-label", children: [
233
+ /* @__PURE__ */ t(
234
+ "input",
235
+ {
236
+ type: "checkbox",
237
+ checked: n.active,
238
+ onChange: (e) => m((s) => ({ ...s, active: e.target.checked }))
239
+ }
240
+ ),
241
+ /* @__PURE__ */ t("span", { children: "Active" })
242
+ ] }),
243
+ /* @__PURE__ */ t("span", { className: "cedros-admin__hint", children: "Inactive FAQs won't appear anywhere." })
244
+ ] }),
245
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-group", children: [
246
+ /* @__PURE__ */ t("label", { className: "cedros-admin__label", children: "Visibility" }),
247
+ /* @__PURE__ */ a("div", { className: "cedros-admin__checkbox-group", children: [
248
+ /* @__PURE__ */ a("label", { className: "cedros-admin__checkbox-label", children: [
249
+ /* @__PURE__ */ t(
250
+ "input",
251
+ {
252
+ type: "checkbox",
253
+ checked: n.useInChat,
254
+ onChange: (e) => m((s) => ({ ...s, useInChat: e.target.checked }))
255
+ }
256
+ ),
257
+ /* @__PURE__ */ t("span", { children: "Use in AI Chat" })
258
+ ] }),
259
+ /* @__PURE__ */ a("label", { className: "cedros-admin__checkbox-label", children: [
260
+ /* @__PURE__ */ t(
261
+ "input",
262
+ {
263
+ type: "checkbox",
264
+ checked: n.displayOnPage,
265
+ onChange: (e) => m((s) => ({ ...s, displayOnPage: e.target.checked }))
266
+ }
267
+ ),
268
+ /* @__PURE__ */ t("span", { children: "Display on FAQ Page" })
269
+ ] })
270
+ ] }),
271
+ /* @__PURE__ */ t("span", { className: "cedros-admin__hint", children: "Choose where this FAQ should appear." })
272
+ ] }),
273
+ /* @__PURE__ */ a("div", { className: "cedros-admin__form-actions", children: [
274
+ /* @__PURE__ */ t("button", { type: "button", className: "cedros-admin__button", onClick: g, children: "Cancel" }),
275
+ /* @__PURE__ */ t(
276
+ "button",
277
+ {
278
+ type: "submit",
279
+ className: "cedros-admin__button cedros-admin__button--primary",
280
+ disabled: Q || !n.question.trim() || !n.answer.trim(),
281
+ children: Q ? l.loading : v ? "Update FAQ" : "Create FAQ"
282
+ }
283
+ )
284
+ ] })
285
+ ] }) }),
286
+ $ ? /* @__PURE__ */ a("div", { className: "cedros-admin__loading", children: [
287
+ l.loading,
288
+ /* @__PURE__ */ t("span", { children: "Loading FAQs..." })
289
+ ] }) : P.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: /* @__PURE__ */ t("p", { children: y || f !== "all" ? "No FAQs match your filters." : "No FAQs yet. Add one to get started." }) }) : /* @__PURE__ */ t("div", { className: "cedros-admin__faq-list", children: P.map((e) => /* @__PURE__ */ a(
290
+ "div",
291
+ {
292
+ className: `cedros-admin__faq-item ${e.active ? "" : "cedros-admin__faq-item--inactive"}`,
293
+ children: [
294
+ /* @__PURE__ */ a("div", { className: "cedros-admin__faq-content", children: [
295
+ /* @__PURE__ */ a("div", { className: "cedros-admin__faq-question", children: [
296
+ /* @__PURE__ */ t("span", { className: `cedros-admin__status-dot ${e.active ? "cedros-admin__status-dot--active" : "cedros-admin__status-dot--inactive"}` }),
297
+ e.question
298
+ ] }),
299
+ /* @__PURE__ */ t("div", { className: "cedros-admin__faq-answer", children: e.answer }),
300
+ /* @__PURE__ */ a("div", { className: "cedros-admin__faq-meta", children: [
301
+ e.keywords.length > 0 && /* @__PURE__ */ t("div", { className: "cedros-admin__faq-keywords", children: e.keywords.map((s) => /* @__PURE__ */ t("span", { className: "cedros-admin__tag", children: s }, s)) }),
302
+ /* @__PURE__ */ a("div", { className: "cedros-admin__faq-visibility", children: [
303
+ e.useInChat && /* @__PURE__ */ a("span", { className: "cedros-admin__badge cedros-admin__badge--chat", title: "Used in AI Chat", children: [
304
+ l.chat,
305
+ " Chat"
306
+ ] }),
307
+ e.displayOnPage && /* @__PURE__ */ a("span", { className: "cedros-admin__badge cedros-admin__badge--page", title: "Displayed on FAQ Page", children: [
308
+ l.globe,
309
+ " Page"
310
+ ] })
311
+ ] })
312
+ ] })
313
+ ] }),
314
+ /* @__PURE__ */ a("div", { className: "cedros-admin__faq-actions", children: [
315
+ /* @__PURE__ */ t(
316
+ "button",
317
+ {
318
+ className: "cedros-admin__button--icon",
319
+ onClick: () => L(e),
320
+ title: e.active ? "Deactivate" : "Activate",
321
+ children: e.active ? l.eyeOff : l.eye
322
+ }
323
+ ),
324
+ /* @__PURE__ */ t(
325
+ "button",
326
+ {
327
+ className: "cedros-admin__button--icon",
328
+ onClick: () => W(e),
329
+ title: "Edit",
330
+ children: l.edit
331
+ }
332
+ ),
333
+ /* @__PURE__ */ t(
334
+ "button",
335
+ {
336
+ className: "cedros-admin__button--icon cedros-admin__btn--danger",
337
+ onClick: () => w(e.id),
338
+ title: "Delete",
339
+ children: l.trash
340
+ }
341
+ )
342
+ ] }),
343
+ q === e.id && /* @__PURE__ */ t("div", { className: "cedros-admin__confirm-overlay", children: /* @__PURE__ */ a("div", { className: "cedros-admin__confirm-dialog", children: [
344
+ /* @__PURE__ */ t("p", { children: "Delete this FAQ?" }),
345
+ /* @__PURE__ */ a("div", { className: "cedros-admin__confirm-actions", children: [
346
+ /* @__PURE__ */ t("button", { className: "cedros-admin__button", onClick: () => w(null), children: "Cancel" }),
347
+ /* @__PURE__ */ t(
348
+ "button",
349
+ {
350
+ className: "cedros-admin__button cedros-admin__button--danger",
351
+ onClick: () => j(e.id),
352
+ children: "Delete"
353
+ }
354
+ )
355
+ ] })
356
+ ] }) })
357
+ ]
358
+ },
359
+ e.id
360
+ )) })
361
+ ] })
362
+ ] });
363
+ }
364
+ export {
365
+ M as FAQSection
366
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),d=require("./index-B-0trqeD.js");function R({serverUrl:h,apiKey:o,pageSize:g=20,authManager:r}){const[u,N]=c.useState([]),[Q,w]=c.useState(!0),[S,f]=c.useState(!1),[p,A]=c.useState(null),[F,C]=c.useState(!1),[x,P]=c.useState(""),[v,O]=c.useState("all"),[q,b]=c.useState(null),[$,j]=c.useState(null),[n,l]=c.useState({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),_=c.useCallback(async()=>{w(!0);try{j(null);let s;const t=`/admin/faqs?limit=${g}`;if(r?.isAuthenticated())s=await r.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);const a=await fetch(`${h}${t}`,{headers:i});if(!a.ok)throw new Error(`Failed to fetch FAQs: ${a.status}`);s=await a.json()}N(s.faqs||[])}catch{N([]),j("Failed to load FAQs")}finally{w(!1)}},[h,o,g,r]);c.useEffect(()=>{_()},[_]);const E=async s=>{if(s.preventDefault(),!(!n.question.trim()||!n.answer.trim())){C(!0);try{const t=n.keywordsCsv.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),i={question:n.question.trim(),answer:n.answer.trim(),keywords:t,active:n.active,useInChat:n.useInChat,displayOnPage:n.displayOnPage};if(p){const a=`/admin/faqs/${p.id}`;if(r?.isAuthenticated())await r.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};o&&(m["X-API-Key"]=o);const I=await fetch(`${h}${a}`,{method:"PUT",headers:m,body:JSON.stringify(i)});if(!I.ok)throw new Error(`Failed to update FAQ: ${I.status}`)}}else if(r?.isAuthenticated())await r.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);const m=await fetch(`${h}/admin/faqs`,{method:"POST",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to create FAQ: ${m.status}`)}y(),_()}catch{j(p?"Failed to update FAQ":"Failed to create FAQ")}finally{C(!1)}}},T=async s=>{try{const t=`/admin/faqs/${s}`;if(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};o&&(i["X-API-Key"]=o);const a=await fetch(`${h}${t}`,{method:"DELETE",headers:i});if(!a.ok)throw new Error(`Failed to delete FAQ: ${a.status}`)}_()}catch{j("Failed to delete FAQ")}b(null)},D=async s=>{try{const t=`/admin/faqs/${s.id}`,i={...s,active:!s.active};if(r?.isAuthenticated())await r.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};o&&(a["X-API-Key"]=o);const m=await fetch(`${h}${t}`,{method:"PUT",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to update FAQ: ${m.status}`)}_()}catch{j("Failed to update FAQ status")}},y=()=>{l({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),A(null),f(!1)},L=s=>{l({question:s.question,answer:s.answer,keywordsCsv:s.keywords.join(", "),active:s.active,useInChat:s.useInChat??!0,displayOnPage:s.displayOnPage??!0}),A(s),f(!0)},W=u.length,B=u.filter(s=>s.active).length,J=u.filter(s=>s.active&&s.useInChat).length,X=u.filter(s=>s.active&&s.displayOnPage).length,k=c.useMemo(()=>u.filter(s=>{if(v==="active"&&!s.active||v==="inactive"&&s.active)return!1;if(x){const t=x.toLowerCase();return s.question.toLowerCase().includes(t)||s.answer.toLowerCase().includes(t)||s.keywords.some(i=>i.includes(t))}return!0}),[u,v,x]);return e.jsxs("div",{className:"cedros-admin__faqs",children:[e.jsx(d.ErrorBanner,{message:$,onRetry:_}),e.jsx(d.StatsBar,{stats:[{label:"Total FAQs",value:W},{label:"Active",value:B,variant:"success"},{label:"In Chat",value:J},{label:"On Page",value:X}]}),e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{className:"cedros-admin__section-header-left",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Knowledge Base"}),e.jsx("p",{className:"cedros-admin__section-subtitle",children:"Manage FAQs for the AI chat assistant and public FAQ page."})]}),e.jsx("div",{className:"cedros-admin__section-header-right",children:e.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{y(),f(!0)},children:[d.Icons.plus," Add FAQ"]})})]}),e.jsxs("div",{className:"cedros-admin__filters",style:{display:"flex",gap:"1rem",marginBottom:"1rem"},children:[e.jsx("input",{type:"text",placeholder:"Search FAQs...",value:x,onChange:s=>P(s.target.value),className:"cedros-admin__input",style:{flex:1,maxWidth:300}}),e.jsxs("select",{value:v,onChange:s=>O(s.target.value),className:"cedros-admin__select",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"active",children:"Active Only"}),e.jsx("option",{value:"inactive",children:"Inactive Only"})]})]}),S&&e.jsx("div",{className:"cedros-admin__form-container",style:{marginBottom:"1.5rem"},children:e.jsxs("form",{onSubmit:E,className:"cedros-admin__form",children:[e.jsxs("div",{className:"cedros-admin__form-header",children:[e.jsx("h4",{children:p?"Edit FAQ":"Add New FAQ"}),e.jsx("button",{type:"button",className:"cedros-admin__button--icon",onClick:y,children:d.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Question *"}),e.jsx("input",{type:"text",value:n.question,onChange:s=>l(t=>({...t,question:s.target.value})),className:"cedros-admin__input",placeholder:"What is your return policy?",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Answer *"}),e.jsx("textarea",{value:n.answer,onChange:s=>l(t=>({...t,answer:s.target.value})),className:"cedros-admin__textarea",placeholder:"We accept returns within 30 days...",rows:4,required:!0}),e.jsx("span",{className:"cedros-admin__hint",children:"Supports markdown formatting."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Keywords"}),e.jsx("input",{type:"text",value:n.keywordsCsv,onChange:s=>l(t=>({...t,keywordsCsv:s.target.value})),className:"cedros-admin__input",placeholder:"returns, refund, policy"}),e.jsx("span",{className:"cedros-admin__hint",children:"Comma-separated keywords to help AI find this FAQ."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:s=>l(t=>({...t,active:s.target.checked}))}),e.jsx("span",{children:"Active"})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Inactive FAQs won't appear anywhere."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Visibility"}),e.jsxs("div",{className:"cedros-admin__checkbox-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.useInChat,onChange:s=>l(t=>({...t,useInChat:s.target.checked}))}),e.jsx("span",{children:"Use in AI Chat"})]}),e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.displayOnPage,onChange:s=>l(t=>({...t,displayOnPage:s.target.checked}))}),e.jsx("span",{children:"Display on FAQ Page"})]})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Choose where this FAQ should appear."})]}),e.jsxs("div",{className:"cedros-admin__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-admin__button",onClick:y,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:F||!n.question.trim()||!n.answer.trim(),children:F?d.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[d.Icons.loading,e.jsx("span",{children:"Loading FAQs..."})]}):k.length===0?e.jsx("div",{className:"cedros-admin__empty",children:e.jsx("p",{children:x||v!=="all"?"No FAQs match your filters.":"No FAQs yet. Add one to get started."})}):e.jsx("div",{className:"cedros-admin__faq-list",children:k.map(s=>e.jsxs("div",{className:`cedros-admin__faq-item ${s.active?"":"cedros-admin__faq-item--inactive"}`,children:[e.jsxs("div",{className:"cedros-admin__faq-content",children:[e.jsxs("div",{className:"cedros-admin__faq-question",children:[e.jsx("span",{className:`cedros-admin__status-dot ${s.active?"cedros-admin__status-dot--active":"cedros-admin__status-dot--inactive"}`}),s.question]}),e.jsx("div",{className:"cedros-admin__faq-answer",children:s.answer}),e.jsxs("div",{className:"cedros-admin__faq-meta",children:[s.keywords.length>0&&e.jsx("div",{className:"cedros-admin__faq-keywords",children:s.keywords.map(t=>e.jsx("span",{className:"cedros-admin__tag",children:t},t))}),e.jsxs("div",{className:"cedros-admin__faq-visibility",children:[s.useInChat&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--chat",title:"Used in AI Chat",children:[d.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[d.Icons.globe," Page"]})]})]})]}),e.jsxs("div",{className:"cedros-admin__faq-actions",children:[e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>D(s),title:s.active?"Deactivate":"Activate",children:s.active?d.Icons.eyeOff:d.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:d.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:d.Icons.trash})]}),q===s.id&&e.jsx("div",{className:"cedros-admin__confirm-overlay",children:e.jsxs("div",{className:"cedros-admin__confirm-dialog",children:[e.jsx("p",{children:"Delete this FAQ?"}),e.jsxs("div",{className:"cedros-admin__confirm-actions",children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>b(null),children:"Cancel"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger",onClick:()=>T(s.id),children:"Delete"})]})]})})]},s.id))})]})]})}exports.FAQSection=R;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),v=require("./index-B-0trqeD.js"),j=require("./Toggle-CsPSF8Dr.js"),I=require("./useAutosave-B2p6iwh8.js"),P=require("./AutosaveIndicator-DxemlKnX.js"),g={email_enabled:!1,smtp_host:"",smtp_port:587,smtp_username:"",smtp_password:"",from_email:"",from_name:"",webhook_enabled:!1,webhook_url:"",webhook_secret:"",webhook_timeout:30};function W({serverUrl:h,apiKey:d,authManager:r}){const[l,_]=o.useState("messages"),[a,p]=o.useState(g),[y,w]=o.useState(!0),[N,S]=o.useState(!0),[k,b]=o.useState(null),[m,C]=o.useState(new Set),u=o.useCallback(async()=>{try{b(null);let s;const n="/admin/config/messaging";if(r?.isAuthenticated())s=await r.fetchWithAuth(n);else{const t={"Content-Type":"application/json"};d&&(t["X-API-Key"]=d);const c=await fetch(`${h}${n}`,{headers:t});if(!c.ok)throw new Error(`Failed to fetch: ${c.status}`);s=await c.json()}p({...g,...s.config})}catch{p(g),b("Could not load saved settings. Showing defaults.")}finally{w(!1),setTimeout(()=>S(!1),100)}},[h,d,r]);o.useEffect(()=>{u()},[u]);const E=o.useCallback(async s=>{const n="/admin/config/messaging",t={...s};m.has("smtp_password")||delete t.smtp_password,m.has("webhook_secret")||delete t.webhook_secret;const c=JSON.stringify({config:t});try{if(r?.isAuthenticated())await r.fetchWithAuth(n,{method:"PUT",body:c});else{const f={"Content-Type":"application/json"};d&&(f["X-API-Key"]=d);const x=await fetch(`${h}${n}`,{method:"PUT",headers:f,body:c});if(!x.ok)throw new Error(`Failed to save: ${x.status}`)}}catch{throw b("Failed to save messaging settings"),new Error("Save failed")}},[h,d,r,m]),{status:T,error:A}=I.useAutosave({data:a,onSave:E,debounceMs:1500,enabled:!N}),i=(s,n)=>{(s==="smtp_password"||s==="webhook_secret")&&C(t=>new Set(t).add(s)),p(t=>({...t,[s]:n}))};return y?e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__loading",style:{marginTop:"1rem"},children:[v.Icons.loading," Loading message settings..."]})]}):e.jsxs("div",{className:"cedros-admin__messaging-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Messages"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin__tab ${l==="messages"?"cedros-admin__tab--active":""}`,onClick:()=>_("messages"),children:"Messages"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${l==="email"?"cedros-admin__tab--active":""}`,onClick:()=>_("email"),children:"Email"}),e.jsx("button",{type:"button",className:`cedros-admin__tab ${l==="webhooks"?"cedros-admin__tab--active":""}`,onClick:()=>_("webhooks"),children:"Webhooks"}),e.jsx("div",{style:{flex:1}}),e.jsx(P.AutosaveIndicator,{status:T,error:A})]}),e.jsx(v.ErrorBanner,{message:k,onRetry:u}),e.jsxs("div",{className:"cedros-admin__tab-content",style:{marginTop:"1rem"},children:[l==="messages"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Enable or disable notification types. Configure the delivery settings in the Email or Webhooks tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(j.Toggle,{checked:a.email_enabled,onChange:s=>i("email_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Email Confirmation"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send order confirmation emails to customers after successful purchase."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Email configuration"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"1rem",padding:"1rem",border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:"0.5rem"},children:[e.jsx(j.Toggle,{checked:a.webhook_enabled,onChange:s=>i("webhook_enabled",s)}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:"Admin Purchase Notification"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.8125rem",opacity:.6},children:"Send webhook notifications to your server when a purchase is completed."}),e.jsx("p",{style:{margin:"0.5rem 0 0",fontSize:"0.75rem",opacity:.5},children:"Requires Webhook configuration"})]})]})]})]}),l==="email"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Configure your email provider for sending customer notifications."}),!a.email_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Email notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.email_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Host"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_host,onChange:s=>i("smtp_host",s.target.value),placeholder:"smtp.example.com",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Port"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.smtp_port,onChange:s=>i("smtp_port",parseInt(s.target.value)||587),placeholder:"587",disabled:!a.email_enabled,style:{maxWidth:120}})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Username"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.smtp_username,onChange:s=>i("smtp_username",s.target.value),placeholder:"username or API key",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"SMTP Password"}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:m.has("smtp_password")?a.smtp_password:"",onChange:s=>i("smtp_password",s.target.value),placeholder:a.smtp_password?"••••••••":"Enter password",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Email"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.from_email,onChange:s=>i("from_email",s.target.value),placeholder:"orders@yourstore.com",disabled:!a.email_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"From Name"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.from_name,onChange:s=>i("from_name",s.target.value),placeholder:"Your Store",disabled:!a.email_enabled})]})]})]}),l==="webhooks"&&e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:"0.875rem",opacity:.7},children:"Configure webhook endpoint for receiving purchase notifications."}),!a.webhook_enabled&&e.jsx("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #fef3c7)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-warning, #f59e0b)",fontSize:"0.875rem"},children:"Webhook notifications are disabled. Enable them in the Messages tab."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem",opacity:a.webhook_enabled?1:.5},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook URL"}),e.jsx("input",{type:"url",className:"cedros-admin__input",value:a.webhook_url,onChange:s=>i("webhook_url",s.target.value),placeholder:"https://api.yoursite.com/webhooks/orders",disabled:!a.webhook_enabled})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Webhook Secret"}),e.jsx("input",{type:"password",className:"cedros-admin__input",value:m.has("webhook_secret")?a.webhook_secret:"",onChange:s=>i("webhook_secret",s.target.value),placeholder:a.webhook_secret?"••••••••":"Enter secret for HMAC-SHA256",disabled:!a.webhook_enabled}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:"0.75rem",opacity:.6},children:"Used for HMAC-SHA256 signature verification"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Timeout (seconds)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.webhook_timeout,onChange:s=>i("webhook_timeout",parseInt(s.target.value)||30),placeholder:"30",disabled:!a.webhook_enabled,style:{maxWidth:120}})]})]})]})]})]})}exports.MessagingSection=W;