@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.
- package/dist/AISettingsSection-C-thWh51.js +51 -0
- package/dist/AISettingsSection-CD9IRyR1.mjs +539 -0
- package/dist/AutosaveIndicator-DxemlKnX.js +1 -0
- package/dist/AutosaveIndicator-G2CRN8hH.mjs +35 -0
- package/dist/{CedrosContext-D7nh5-Zh.mjs → CedrosContext-BnJ2Cf7R.mjs} +1179 -642
- package/dist/CedrosContext-C26DlvLF.js +6 -0
- package/dist/CryptoButton-BdOtL7w-.mjs +542 -0
- package/dist/CryptoButton-N8kRfNDO.js +1 -0
- package/dist/FAQSection-CyYK9OAN.mjs +366 -0
- package/dist/FAQSection-_pm1ekTe.js +1 -0
- package/dist/MessagingSection-BHzf1Mhu.js +1 -0
- package/dist/MessagingSection-DO2yPTvs.mjs +347 -0
- package/dist/PaymentSettingsSection--Aqlne1F.mjs +94 -0
- package/dist/PaymentSettingsSection-DpENgoca.js +1 -0
- package/dist/SettingsSection-CGKKGXWz.mjs +57 -0
- package/dist/SettingsSection-DNoODw7i.js +1 -0
- package/dist/SingleCategorySettings-8DCtLcow.mjs +1421 -0
- package/dist/SingleCategorySettings-NLBYxM0O.js +3 -0
- package/dist/StorefrontSection-BEOMtSAg.js +1 -0
- package/dist/StorefrontSection-Mzr1H51w.mjs +765 -0
- package/dist/SubscriptionsSection-4b29i-41.js +1 -0
- package/dist/SubscriptionsSection-Dy1e15fe.mjs +616 -0
- package/dist/Toggle-CsPSF8Dr.js +1 -0
- package/dist/Toggle-DAxIdpY4.mjs +48 -0
- package/dist/WalletManager-D6BYTwXn.js +1 -0
- package/dist/{WalletManager-oEjZhaFk.mjs → WalletManager-HXXyARQ7.mjs} +36 -32
- package/dist/components/CedrosPay.d.ts.map +1 -1
- package/dist/components/CryptoSubscribeButton.d.ts.map +1 -1
- package/dist/components/PaymentModal.d.ts.map +1 -1
- package/dist/components/SubscriptionManagementPanel.d.ts.map +1 -1
- package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
- package/dist/components/admin/AdminAuthManager.d.ts +2 -1
- package/dist/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/components/admin/AutosaveIndicator.d.ts +7 -0
- package/dist/components/admin/AutosaveIndicator.d.ts.map +1 -0
- package/dist/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/components/admin/ConfigEditor.d.ts +0 -2
- package/dist/components/admin/ConfigEditor.d.ts.map +1 -1
- package/dist/components/admin/MessagingSection.d.ts.map +1 -1
- package/dist/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/components/admin/SecretArrayEditor.d.ts +16 -0
- package/dist/components/admin/SecretArrayEditor.d.ts.map +1 -0
- package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
- package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
- package/dist/components/admin/Toggle.d.ts +14 -0
- package/dist/components/admin/Toggle.d.ts.map +1 -0
- package/dist/components/admin/TokenMintSelector.d.ts +27 -0
- package/dist/components/admin/TokenMintSelector.d.ts.map +1 -0
- package/dist/components/admin/configApi.d.ts +5 -3
- package/dist/components/admin/configApi.d.ts.map +1 -1
- package/dist/components/admin/index.d.ts +8 -9
- package/dist/components/admin/index.d.ts.map +1 -1
- package/dist/components/admin/sections-more.d.ts +2 -9
- package/dist/components/admin/sections-more.d.ts.map +1 -1
- package/dist/context/CedrosContext.d.ts +1 -1
- package/dist/context/CedrosContext.d.ts.map +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +391 -380
- package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/inventoryHooks.test.d.ts.map +1 -0
- package/dist/ecommerce/__tests__/storage.test.d.ts +2 -0
- package/dist/ecommerce/__tests__/storage.test.d.ts.map +1 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts +5 -0
- package/dist/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts +2 -0
- package/dist/ecommerce/adapters/paywall/paywallAdapter.test.d.ts.map +1 -0
- package/dist/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
- package/dist/ecommerce/components/catalog/QuickViewDialog.d.ts.map +1 -1
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts +4 -0
- package/dist/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/ecommerce/components/checkout/PaymentStep.d.ts.map +1 -1
- package/dist/ecommerce/components/faq/FAQItem.d.ts.map +1 -1
- package/dist/ecommerce/config/context.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useAIRelatedProducts.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useHoldExpiry.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useInventoryVerification.d.ts.map +1 -1
- package/dist/ecommerce/hooks/useProducts.d.ts.map +1 -1
- package/dist/ecommerce/index.d.ts +2 -0
- package/dist/ecommerce/index.d.ts.map +1 -1
- package/dist/ecommerce/integrations/cedros-pay/useCedrosPayCheckoutAdapter.d.ts.map +1 -1
- package/dist/ecommerce/state/cart/CartProvider.d.ts.map +1 -1
- package/dist/ecommerce/state/checkout/checkoutSchema.d.ts +1 -1
- package/dist/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
- package/dist/ecommerce/utils/storage.d.ts +1 -1
- package/dist/ecommerce/utils/storage.d.ts.map +1 -1
- package/dist/hooks/useCreditsPayment.d.ts.map +1 -1
- package/dist/hooks/useCreditsSubscription.d.ts.map +1 -1
- package/dist/hooks/useCryptoSubscription.d.ts.map +1 -1
- package/dist/hooks/useRefundVerification.d.ts.map +1 -1
- package/dist/hooks/useStripeCheckout.d.ts +1 -1
- package/dist/hooks/useStripeCheckout.d.ts.map +1 -1
- package/dist/hooks/useSubscription.d.ts.map +1 -1
- package/dist/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/hooks/useX402Payment.d.ts.map +1 -1
- package/dist/index-B-0trqeD.js +84 -0
- package/dist/index-bbSf3B7-.mjs +22915 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +67 -72
- package/dist/managers/CreditsManager.d.ts +6 -0
- package/dist/managers/CreditsManager.d.ts.map +1 -1
- package/dist/managers/ManagerCache.d.ts.map +1 -1
- package/dist/managers/RouteDiscoveryManager.d.ts +3 -0
- package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -1
- package/dist/managers/StripeManager.d.ts +15 -0
- package/dist/managers/StripeManager.d.ts.map +1 -1
- package/dist/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/managers/SubscriptionManager.d.ts +7 -14
- package/dist/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/managers/WalletManager.d.ts +2 -1
- package/dist/managers/WalletManager.d.ts.map +1 -1
- package/dist/managers/X402Manager.d.ts.map +1 -1
- package/dist/{sections-CL3lbNui.js → sections-CKwGmrzV.js} +1 -1
- package/dist/{sections-DnmB0qdx.mjs → sections-DpEdFL1B.mjs} +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +67 -72
- package/dist/telemetry.js +1 -1
- package/dist/telemetry.mjs +23 -25
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/types/index.d.ts +13 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/useAutosave-B2p6iwh8.js +1 -0
- package/dist/useAutosave-YwMqRzqy.mjs +44 -0
- package/dist/utils/circuitBreaker.d.ts +3 -1
- package/dist/utils/circuitBreaker.d.ts.map +1 -1
- package/dist/utils/cspHelper.d.ts +6 -0
- package/dist/utils/cspHelper.d.ts.map +1 -1
- package/dist/utils/csvHelpers.d.ts +0 -41
- package/dist/utils/csvHelpers.d.ts.map +1 -1
- package/dist/utils/errorHandling.d.ts.map +1 -1
- package/dist/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/utils/requestDeduplication.d.ts.map +1 -1
- package/dist/utils/telemetry.d.ts.map +1 -1
- package/dist/utils/validateConfig.d.ts +1 -1
- package/dist/utils/validateConfig.d.ts.map +1 -1
- package/dist/walletDetection-JZR3UCOa.mjs +27 -0
- package/dist/walletDetection-bNmV5ItZ.js +1 -0
- package/dist/{walletPool-BR6etEiq.mjs → walletPool-BV_z1lEA.mjs} +1 -1
- package/dist/{walletPool-BZyAG4YS.js → walletPool-DjA7J3a9.js} +1 -1
- package/package.json +8 -7
- package/dist/CedrosContext-C2v_s8cc.js +0 -6
- package/dist/WalletManager-B5KLZK2D.js +0 -1
- package/dist/index-BU0vgA-7.js +0 -136
- package/dist/index-DWXEBUbu.mjs +0 -27912
|
@@ -0,0 +1,1421 @@
|
|
|
1
|
+
import { jsxs as o, jsx as t, Fragment as U } from "react/jsx-runtime";
|
|
2
|
+
import { useState as k, useEffect as V, useMemo as H, useCallback as M } from "react";
|
|
3
|
+
import { $ as T, a2 as Z, a0 as Q, a7 as ee } from "./index-bbSf3B7-.mjs";
|
|
4
|
+
import { u as te } from "./useAutosave-YwMqRzqy.mjs";
|
|
5
|
+
import { A as re } from "./AutosaveIndicator-G2CRN8hH.mjs";
|
|
6
|
+
import { S as O } from "./CedrosContext-BnJ2Cf7R.mjs";
|
|
7
|
+
import { PublicKey as ie } from "@solana/web3.js";
|
|
8
|
+
class ne {
|
|
9
|
+
constructor(s, d, n) {
|
|
10
|
+
this._serverUrl = s, this.auth = d, this.authManager = n;
|
|
11
|
+
}
|
|
12
|
+
/** Server URL passed at construction (retained for API compatibility). */
|
|
13
|
+
get serverUrl() {
|
|
14
|
+
return this._serverUrl;
|
|
15
|
+
}
|
|
16
|
+
async fetch(s, d = {}) {
|
|
17
|
+
if (this.authManager?.isAuthenticated())
|
|
18
|
+
return this.authManager.fetchWithAuth(s, d);
|
|
19
|
+
throw this.auth ? new Error(
|
|
20
|
+
"Legacy AdminAuth is no longer supported due to replay vulnerability. Use IAdminAuthManager instead."
|
|
21
|
+
) : new Error(
|
|
22
|
+
"Admin authentication required. Provide an IAdminAuthManager to ConfigApi."
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
/** List all config categories */
|
|
26
|
+
async listCategories(s = 100) {
|
|
27
|
+
return this.fetch(`/admin/config?limit=${s}`);
|
|
28
|
+
}
|
|
29
|
+
/** Get config for a category */
|
|
30
|
+
async getConfig(s, d = !0) {
|
|
31
|
+
return this.fetch(`/admin/config/${s}?redact_secrets=${d}`);
|
|
32
|
+
}
|
|
33
|
+
/** Full update - replace entire category config */
|
|
34
|
+
async updateConfig(s, d, n) {
|
|
35
|
+
await this.fetch(`/admin/config/${s}`, {
|
|
36
|
+
method: "PUT",
|
|
37
|
+
body: JSON.stringify({ config: d, description: n })
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** Partial update - update specific keys */
|
|
41
|
+
async patchConfig(s, d, n) {
|
|
42
|
+
await this.fetch(`/admin/config/${s}`, {
|
|
43
|
+
method: "PATCH",
|
|
44
|
+
body: JSON.stringify({ updates: d, description: n })
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Batch update multiple categories */
|
|
48
|
+
async batchUpdate(s) {
|
|
49
|
+
await this.fetch("/admin/config/batch", {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify({ updates: s })
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** Validate config before saving */
|
|
55
|
+
async validateConfig(s, d) {
|
|
56
|
+
return this.fetch("/admin/config/validate", {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: JSON.stringify({ category: s, config: d })
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Get config change history */
|
|
62
|
+
async getHistory(s, d = 50) {
|
|
63
|
+
const n = new URLSearchParams({ limit: d.toString() });
|
|
64
|
+
return s && n.set("category", s), this.fetch(`/admin/config/history?${n}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const L = {
|
|
68
|
+
server: {
|
|
69
|
+
label: "Server",
|
|
70
|
+
secrets: [],
|
|
71
|
+
icon: "🖥️",
|
|
72
|
+
fields: {
|
|
73
|
+
admin_metrics_api_key: { hidden: !0 },
|
|
74
|
+
// Moved to metrics tab
|
|
75
|
+
cors_allowed_origins: { hidden: !0 }
|
|
76
|
+
// Moved to security tab
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
security: {
|
|
80
|
+
label: "Security",
|
|
81
|
+
description: "Configure CORS, rate limiting, and other security settings",
|
|
82
|
+
secrets: [],
|
|
83
|
+
icon: "🔒",
|
|
84
|
+
fields: {
|
|
85
|
+
cors_allowed_origins: {
|
|
86
|
+
description: 'List of allowed origins for CORS requests. Use ["*"] to allow all origins (not recommended for production).'
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
metrics: {
|
|
91
|
+
label: "Metrics",
|
|
92
|
+
description: "Configure metrics collection and API access",
|
|
93
|
+
secrets: ["admin_metrics_api_key"],
|
|
94
|
+
icon: "📊",
|
|
95
|
+
fields: {
|
|
96
|
+
admin_metrics_api_key: {
|
|
97
|
+
description: "API key for accessing the admin metrics endpoint. Keep this secret."
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
logging: {
|
|
102
|
+
label: "Logging",
|
|
103
|
+
secrets: [],
|
|
104
|
+
icon: "📝",
|
|
105
|
+
fields: {
|
|
106
|
+
level: { type: "dropdown", options: ["trace", "debug", "info", "warn", "error"] },
|
|
107
|
+
format: { hidden: !0 },
|
|
108
|
+
// Developer setting
|
|
109
|
+
environment: { hidden: !0 }
|
|
110
|
+
// Developer setting
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
stripe: {
|
|
114
|
+
label: "Stripe",
|
|
115
|
+
secrets: ["secret_key", "webhook_secret"],
|
|
116
|
+
icon: "💳",
|
|
117
|
+
fields: {
|
|
118
|
+
enabled: { hidden: !0 },
|
|
119
|
+
// Shown in header toggle
|
|
120
|
+
secret_key: {
|
|
121
|
+
description: "Stripe Dashboard → Developers → API keys → Secret key. Use the test key (sk_test_...) for testing, or the live key (sk_live_...) for production."
|
|
122
|
+
},
|
|
123
|
+
publishable_key: {
|
|
124
|
+
description: "Stripe Dashboard → Developers → API keys → Publishable key. Starts with pk_test_... or pk_live_..."
|
|
125
|
+
},
|
|
126
|
+
mode: {
|
|
127
|
+
type: "dropdown",
|
|
128
|
+
options: ["test", "live"],
|
|
129
|
+
description: 'Use "test" mode with test API keys during development, then switch to "live" with live keys for real payments.'
|
|
130
|
+
},
|
|
131
|
+
webhook_url: {
|
|
132
|
+
description: "The full URL Stripe sends webhook events to. Default is your server URL + /webhook/stripe (e.g. https://example.com/webhook/stripe). Only change this if you've customized the route in your cedros-pay server."
|
|
133
|
+
},
|
|
134
|
+
webhook_secret: {
|
|
135
|
+
description: `Stripe Dashboard → Developers → Webhooks → "Create an event destination" → select events: checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.paid, invoice.payment_failed → Continue → choose "Webhook endpoint" → enter your server's webhook endpoint, e.g. https://example.com/webhook/stripe (your server URL + /webhook/stripe) → after creating, click the endpoint and "Click to reveal" the signing secret. Starts with whsec_...`
|
|
136
|
+
},
|
|
137
|
+
tax_rate_id: {
|
|
138
|
+
description: `Stripe Dashboard → More → Product catalog → Tax rates → "+ New" → set the percentage, region, and whether tax is inclusive or exclusive → Save → copy the tax rate ID from the detail page (starts with txr_...). Leave empty if you don't collect tax.`
|
|
139
|
+
},
|
|
140
|
+
success_url: { hidden: !0 },
|
|
141
|
+
// Library provides default pages
|
|
142
|
+
cancel_url: { hidden: !0 }
|
|
143
|
+
// Library provides default pages
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
x402: {
|
|
147
|
+
label: "X402 (Crypto)",
|
|
148
|
+
secrets: ["server_wallets"],
|
|
149
|
+
icon: "⚡",
|
|
150
|
+
fields: {
|
|
151
|
+
enabled: { hidden: !0 },
|
|
152
|
+
// Shown in header toggle
|
|
153
|
+
payment_address: {
|
|
154
|
+
type: "solana_address",
|
|
155
|
+
description: "The Solana wallet address where payments are received. This is where customer funds are sent."
|
|
156
|
+
},
|
|
157
|
+
token_mint: {
|
|
158
|
+
type: "token_mint",
|
|
159
|
+
description: "The SPL token used for payments. Most commonly USDC."
|
|
160
|
+
},
|
|
161
|
+
token_decimals: {
|
|
162
|
+
type: "number",
|
|
163
|
+
description: "Number of decimal places for the token (e.g., USDC has 6 decimals).",
|
|
164
|
+
hidden: !0
|
|
165
|
+
// Managed by token_mint selector
|
|
166
|
+
},
|
|
167
|
+
custom_token_symbol: {
|
|
168
|
+
description: 'Display symbol for your custom token (e.g., "MYTOKEN").',
|
|
169
|
+
hidden: !0
|
|
170
|
+
// Managed by token_mint selector
|
|
171
|
+
},
|
|
172
|
+
custom_token_icon: {
|
|
173
|
+
description: "URL to your token's icon image.",
|
|
174
|
+
hidden: !0
|
|
175
|
+
// Managed by token_mint selector
|
|
176
|
+
},
|
|
177
|
+
rpc_url: {
|
|
178
|
+
description: "Custom Solana RPC endpoint. Leave empty to use the default public RPC."
|
|
179
|
+
},
|
|
180
|
+
gasless_enabled: {
|
|
181
|
+
type: "toggle",
|
|
182
|
+
description: "When enabled, your server pays transaction fees so customers don't need SOL."
|
|
183
|
+
},
|
|
184
|
+
server_wallets: {
|
|
185
|
+
type: "secret_array",
|
|
186
|
+
description: "Server keypair(s) used to sign and pay for transactions. Required for gasless payments.",
|
|
187
|
+
showWhen: "gasless_enabled"
|
|
188
|
+
},
|
|
189
|
+
rounding_mode: {
|
|
190
|
+
type: "dropdown",
|
|
191
|
+
options: ["nearest", "up", "down"],
|
|
192
|
+
description: "How to round fractional token amounts: nearest (default), up (always round up), or down (always round down)."
|
|
193
|
+
},
|
|
194
|
+
network: { hidden: !0 },
|
|
195
|
+
ws_url: { hidden: !0 },
|
|
196
|
+
// Derived from rpc_url
|
|
197
|
+
skip_preflight: { hidden: !0 },
|
|
198
|
+
// Always false; not a user decision
|
|
199
|
+
commitment: { hidden: !0 },
|
|
200
|
+
// Internal Solana parameter
|
|
201
|
+
compute_unit_limit: { hidden: !0 },
|
|
202
|
+
// Internal Solana parameter
|
|
203
|
+
compute_unit_price: { hidden: !0 }
|
|
204
|
+
// Internal Solana parameter
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
paywall: {
|
|
208
|
+
label: "Paywall",
|
|
209
|
+
secrets: [],
|
|
210
|
+
icon: "🚪",
|
|
211
|
+
fields: {
|
|
212
|
+
product_cache_ttl: { type: "number", unit: "seconds" }
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
coupons: {
|
|
216
|
+
label: "Coupons",
|
|
217
|
+
secrets: [],
|
|
218
|
+
icon: "🎟️",
|
|
219
|
+
fields: {
|
|
220
|
+
cache_ttl: { type: "number", unit: "seconds" }
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
subscriptions: {
|
|
224
|
+
label: "Subscriptions",
|
|
225
|
+
secrets: [],
|
|
226
|
+
icon: "🔄",
|
|
227
|
+
fields: {
|
|
228
|
+
grace_period_hours: { type: "number", unit: "hours" }
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
callbacks: {
|
|
232
|
+
label: "Callbacks",
|
|
233
|
+
secrets: ["hmac_secret"],
|
|
234
|
+
icon: "🔔"
|
|
235
|
+
},
|
|
236
|
+
email: {
|
|
237
|
+
label: "Email",
|
|
238
|
+
description: "Email receipts for customers after purchase",
|
|
239
|
+
secrets: ["smtp_password"],
|
|
240
|
+
icon: "📧",
|
|
241
|
+
fields: {
|
|
242
|
+
enabled: { hidden: !0 },
|
|
243
|
+
// Shown in header toggle
|
|
244
|
+
provider: {
|
|
245
|
+
type: "dropdown",
|
|
246
|
+
options: ["sendgrid", "mailgun", "postmark", "ses", "resend", "custom"],
|
|
247
|
+
description: "Email service provider."
|
|
248
|
+
},
|
|
249
|
+
smtp_host: {
|
|
250
|
+
description: "SMTP server hostname.",
|
|
251
|
+
showWhen: "provider"
|
|
252
|
+
},
|
|
253
|
+
smtp_port: {
|
|
254
|
+
type: "number",
|
|
255
|
+
description: "SMTP server port (typically 587 for TLS).",
|
|
256
|
+
showWhen: "provider"
|
|
257
|
+
},
|
|
258
|
+
smtp_user: {
|
|
259
|
+
description: "SMTP authentication username or API key name.",
|
|
260
|
+
showWhen: "provider"
|
|
261
|
+
},
|
|
262
|
+
smtp_password: {
|
|
263
|
+
description: "SMTP password or API key.",
|
|
264
|
+
showWhen: "provider"
|
|
265
|
+
},
|
|
266
|
+
from_address: {
|
|
267
|
+
description: "Sender email address (e.g., orders@yourstore.com)."
|
|
268
|
+
},
|
|
269
|
+
from_name: {
|
|
270
|
+
description: 'Sender display name (e.g., "Your Store").'
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
webhook: {
|
|
275
|
+
label: "Webhook",
|
|
276
|
+
description: "HTTP notifications when purchases occur",
|
|
277
|
+
secrets: ["secret"],
|
|
278
|
+
icon: "🔔",
|
|
279
|
+
fields: {
|
|
280
|
+
enabled: { hidden: !0 },
|
|
281
|
+
// Shown in header toggle
|
|
282
|
+
url: {
|
|
283
|
+
description: "URL to receive POST notifications (e.g., https://api.yoursite.com/webhooks/orders)."
|
|
284
|
+
},
|
|
285
|
+
secret: {
|
|
286
|
+
description: "Shared secret for HMAC-SHA256 signature verification."
|
|
287
|
+
},
|
|
288
|
+
retry_attempts: {
|
|
289
|
+
type: "number",
|
|
290
|
+
description: "Number of retry attempts on failure (default: 3)."
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
messaging: {
|
|
295
|
+
label: "Messaging",
|
|
296
|
+
description: "Email and webhook notifications for purchases",
|
|
297
|
+
secrets: ["smtp_password", "webhook_secret"],
|
|
298
|
+
icon: "📬",
|
|
299
|
+
fields: {
|
|
300
|
+
// Email settings
|
|
301
|
+
email_enabled: {
|
|
302
|
+
type: "boolean",
|
|
303
|
+
description: "Send order confirmation emails to customers."
|
|
304
|
+
},
|
|
305
|
+
smtp_host: {
|
|
306
|
+
description: "SMTP server hostname.",
|
|
307
|
+
showWhen: "email_enabled"
|
|
308
|
+
},
|
|
309
|
+
smtp_port: {
|
|
310
|
+
type: "number",
|
|
311
|
+
description: "SMTP server port (typically 587 for TLS).",
|
|
312
|
+
showWhen: "email_enabled"
|
|
313
|
+
},
|
|
314
|
+
smtp_username: {
|
|
315
|
+
description: "SMTP authentication username or API key.",
|
|
316
|
+
showWhen: "email_enabled"
|
|
317
|
+
},
|
|
318
|
+
smtp_password: {
|
|
319
|
+
description: "SMTP password or API key.",
|
|
320
|
+
showWhen: "email_enabled"
|
|
321
|
+
},
|
|
322
|
+
from_email: {
|
|
323
|
+
description: "Sender email address (e.g., orders@yourstore.com).",
|
|
324
|
+
showWhen: "email_enabled"
|
|
325
|
+
},
|
|
326
|
+
from_name: {
|
|
327
|
+
description: 'Sender display name (e.g., "Your Store").',
|
|
328
|
+
showWhen: "email_enabled"
|
|
329
|
+
},
|
|
330
|
+
// Webhook settings
|
|
331
|
+
webhook_enabled: {
|
|
332
|
+
type: "boolean",
|
|
333
|
+
description: "Send webhook notifications when purchases complete."
|
|
334
|
+
},
|
|
335
|
+
webhook_url: {
|
|
336
|
+
description: "URL to receive POST notifications.",
|
|
337
|
+
showWhen: "webhook_enabled"
|
|
338
|
+
},
|
|
339
|
+
webhook_secret: {
|
|
340
|
+
description: "Shared secret for HMAC-SHA256 signature verification.",
|
|
341
|
+
showWhen: "webhook_enabled"
|
|
342
|
+
},
|
|
343
|
+
webhook_timeout: {
|
|
344
|
+
type: "number",
|
|
345
|
+
description: "Request timeout in seconds (default: 30).",
|
|
346
|
+
showWhen: "webhook_enabled"
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
monitoring: {
|
|
351
|
+
label: "Monitoring",
|
|
352
|
+
secrets: [],
|
|
353
|
+
icon: "📊",
|
|
354
|
+
fields: {
|
|
355
|
+
check_interval: { type: "number", unit: "seconds" },
|
|
356
|
+
low_balance_threshold: { type: "number", unit: "SOL" }
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
rate_limit: {
|
|
360
|
+
label: "Rate Limiting",
|
|
361
|
+
secrets: [],
|
|
362
|
+
icon: "⏱️"
|
|
363
|
+
},
|
|
364
|
+
circuit_breaker: {
|
|
365
|
+
label: "Circuit Breaker",
|
|
366
|
+
secrets: [],
|
|
367
|
+
icon: "🔌"
|
|
368
|
+
},
|
|
369
|
+
admin: {
|
|
370
|
+
label: "Admin Keys",
|
|
371
|
+
secrets: [],
|
|
372
|
+
icon: "👤"
|
|
373
|
+
},
|
|
374
|
+
api_keys: {
|
|
375
|
+
label: "API Keys",
|
|
376
|
+
secrets: [],
|
|
377
|
+
icon: "🔐"
|
|
378
|
+
},
|
|
379
|
+
cedros_login: {
|
|
380
|
+
label: "Cedros Login",
|
|
381
|
+
secrets: ["api_key"],
|
|
382
|
+
icon: "🔑",
|
|
383
|
+
fields: {
|
|
384
|
+
enabled: { hidden: !0 },
|
|
385
|
+
// Shown in header toggle
|
|
386
|
+
credits_enabled: { hidden: !0 },
|
|
387
|
+
// Shown in header toggle when relevant
|
|
388
|
+
base_url: { hidden: !0 },
|
|
389
|
+
// Deployment setting
|
|
390
|
+
timeout: { hidden: !0 },
|
|
391
|
+
// Developer setting
|
|
392
|
+
jwt_issuer: { hidden: !0 },
|
|
393
|
+
// Internal auth config
|
|
394
|
+
jwt_audience: { hidden: !0 }
|
|
395
|
+
// Internal auth config
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
shop: {
|
|
399
|
+
label: "Storefront",
|
|
400
|
+
description: "Product pages & display settings",
|
|
401
|
+
secrets: [],
|
|
402
|
+
icon: "🏪",
|
|
403
|
+
fields: {
|
|
404
|
+
enabled: { hidden: !0 },
|
|
405
|
+
// Shown in StorefrontSection header toggle
|
|
406
|
+
"relatedProducts.mode": {
|
|
407
|
+
type: "dropdown",
|
|
408
|
+
options: ["most_recent", "by_category", "manual", "ai"]
|
|
409
|
+
},
|
|
410
|
+
"relatedProducts.maxItems": { type: "number" }
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
function G(b, s) {
|
|
415
|
+
return L[b]?.secrets.includes(s) ?? !1;
|
|
416
|
+
}
|
|
417
|
+
const z = "[REDACTED]";
|
|
418
|
+
function B(b) {
|
|
419
|
+
if (!b || b.trim() === "")
|
|
420
|
+
return { valid: !0 };
|
|
421
|
+
try {
|
|
422
|
+
return new ie(b.trim()), { valid: !0 };
|
|
423
|
+
} catch {
|
|
424
|
+
return { valid: !1, error: "Invalid Solana address" };
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function oe({
|
|
428
|
+
label: b,
|
|
429
|
+
value: s,
|
|
430
|
+
onChange: d,
|
|
431
|
+
decimals: n,
|
|
432
|
+
onDecimalsChange: S,
|
|
433
|
+
disabled: c = !1,
|
|
434
|
+
description: l,
|
|
435
|
+
customSymbol: m = "",
|
|
436
|
+
customIcon: h = "",
|
|
437
|
+
onCustomSymbolChange: p,
|
|
438
|
+
onCustomIconChange: g
|
|
439
|
+
}) {
|
|
440
|
+
const [w, A] = k(!1), f = Object.entries(O), _ = !!O[s], x = w || !!s && !_, C = (e) => {
|
|
441
|
+
if (e === "custom")
|
|
442
|
+
A(!0), _ && d("");
|
|
443
|
+
else {
|
|
444
|
+
A(!1), d(e);
|
|
445
|
+
const i = O[e];
|
|
446
|
+
i && S && S(i.decimals), p && p(""), g && g("");
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
450
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: b }),
|
|
451
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
452
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.5rem" }, children: [
|
|
453
|
+
f.map(([e, i]) => /* @__PURE__ */ o(
|
|
454
|
+
"button",
|
|
455
|
+
{
|
|
456
|
+
type: "button",
|
|
457
|
+
onClick: () => C(e),
|
|
458
|
+
disabled: c,
|
|
459
|
+
style: {
|
|
460
|
+
display: "flex",
|
|
461
|
+
alignItems: "center",
|
|
462
|
+
gap: "0.5rem",
|
|
463
|
+
padding: "0.5rem 0.75rem",
|
|
464
|
+
border: s === e ? "2px solid var(--cedros-admin-primary, #171717)" : "1px solid var(--cedros-admin-border, #d4d4d4)",
|
|
465
|
+
borderRadius: "0.5rem",
|
|
466
|
+
background: s === e ? "var(--cedros-admin-primary-bg, #f5f5f5)" : "var(--cedros-admin-bg, #fff)",
|
|
467
|
+
cursor: c ? "not-allowed" : "pointer",
|
|
468
|
+
opacity: c ? 0.5 : 1,
|
|
469
|
+
fontWeight: s === e ? 600 : 400
|
|
470
|
+
},
|
|
471
|
+
children: [
|
|
472
|
+
/* @__PURE__ */ t(
|
|
473
|
+
"img",
|
|
474
|
+
{
|
|
475
|
+
src: i.icon,
|
|
476
|
+
alt: i.symbol,
|
|
477
|
+
style: { width: 20, height: 20, borderRadius: "50%" },
|
|
478
|
+
onError: (r) => {
|
|
479
|
+
r.target.style.display = "none";
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
),
|
|
483
|
+
/* @__PURE__ */ t("span", { children: i.symbol })
|
|
484
|
+
]
|
|
485
|
+
},
|
|
486
|
+
e
|
|
487
|
+
)),
|
|
488
|
+
/* @__PURE__ */ o(
|
|
489
|
+
"button",
|
|
490
|
+
{
|
|
491
|
+
type: "button",
|
|
492
|
+
onClick: () => C("custom"),
|
|
493
|
+
disabled: c,
|
|
494
|
+
style: {
|
|
495
|
+
display: "flex",
|
|
496
|
+
alignItems: "center",
|
|
497
|
+
gap: "0.5rem",
|
|
498
|
+
padding: "0.5rem 0.75rem",
|
|
499
|
+
border: x ? "2px solid var(--cedros-admin-primary, #171717)" : "1px solid var(--cedros-admin-border, #d4d4d4)",
|
|
500
|
+
borderRadius: "0.5rem",
|
|
501
|
+
background: x ? "var(--cedros-admin-primary-bg, #f5f5f5)" : "var(--cedros-admin-bg, #fff)",
|
|
502
|
+
cursor: c ? "not-allowed" : "pointer",
|
|
503
|
+
opacity: c ? 0.5 : 1,
|
|
504
|
+
fontWeight: x ? 600 : 400
|
|
505
|
+
},
|
|
506
|
+
children: [
|
|
507
|
+
/* @__PURE__ */ t("span", { style: { fontSize: "1rem" }, children: "+" }),
|
|
508
|
+
/* @__PURE__ */ t("span", { children: "Custom" })
|
|
509
|
+
]
|
|
510
|
+
}
|
|
511
|
+
)
|
|
512
|
+
] }),
|
|
513
|
+
x && /* @__PURE__ */ o("div", { style: {
|
|
514
|
+
display: "flex",
|
|
515
|
+
flexDirection: "column",
|
|
516
|
+
gap: "0.75rem",
|
|
517
|
+
padding: "1rem",
|
|
518
|
+
background: "var(--cedros-admin-bg-muted, #f9fafb)",
|
|
519
|
+
borderRadius: "0.5rem",
|
|
520
|
+
border: "1px solid var(--cedros-admin-border, #e5e7eb)"
|
|
521
|
+
}, children: [
|
|
522
|
+
/* @__PURE__ */ o("div", { children: [
|
|
523
|
+
/* @__PURE__ */ t("label", { style: {
|
|
524
|
+
display: "block",
|
|
525
|
+
fontSize: "0.75rem",
|
|
526
|
+
fontWeight: 500,
|
|
527
|
+
marginBottom: "0.25rem",
|
|
528
|
+
color: "var(--cedros-admin-text-muted, #64748b)"
|
|
529
|
+
}, children: "Token Mint Address" }),
|
|
530
|
+
(() => {
|
|
531
|
+
const e = B(s);
|
|
532
|
+
return /* @__PURE__ */ o(U, { children: [
|
|
533
|
+
/* @__PURE__ */ t(
|
|
534
|
+
"input",
|
|
535
|
+
{
|
|
536
|
+
type: "text",
|
|
537
|
+
className: `cedros-admin__input ${e.valid ? "" : "cedros-admin__input--error"}`,
|
|
538
|
+
value: s,
|
|
539
|
+
onChange: (i) => d(i.target.value),
|
|
540
|
+
placeholder: "e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
|
541
|
+
disabled: c,
|
|
542
|
+
style: {
|
|
543
|
+
fontFamily: "monospace",
|
|
544
|
+
fontSize: "0.875rem",
|
|
545
|
+
borderColor: e.valid ? void 0 : "var(--cedros-admin-error, #dc2626)"
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
),
|
|
549
|
+
!e.valid && /* @__PURE__ */ t("span", { style: { color: "var(--cedros-admin-error, #dc2626)", fontSize: "0.75rem", marginTop: "0.25rem", display: "block" }, children: e.error })
|
|
550
|
+
] });
|
|
551
|
+
})()
|
|
552
|
+
] }),
|
|
553
|
+
/* @__PURE__ */ o("div", { children: [
|
|
554
|
+
/* @__PURE__ */ t("label", { style: {
|
|
555
|
+
display: "block",
|
|
556
|
+
fontSize: "0.75rem",
|
|
557
|
+
fontWeight: 500,
|
|
558
|
+
marginBottom: "0.25rem",
|
|
559
|
+
color: "var(--cedros-admin-text-muted, #64748b)"
|
|
560
|
+
}, children: "Token Symbol" }),
|
|
561
|
+
/* @__PURE__ */ t(
|
|
562
|
+
"input",
|
|
563
|
+
{
|
|
564
|
+
type: "text",
|
|
565
|
+
className: "cedros-admin__input",
|
|
566
|
+
value: m,
|
|
567
|
+
onChange: (e) => p?.(e.target.value),
|
|
568
|
+
placeholder: "e.g., MYTOKEN",
|
|
569
|
+
disabled: c,
|
|
570
|
+
style: { textTransform: "uppercase" }
|
|
571
|
+
}
|
|
572
|
+
)
|
|
573
|
+
] }),
|
|
574
|
+
/* @__PURE__ */ o("div", { children: [
|
|
575
|
+
/* @__PURE__ */ t("label", { style: {
|
|
576
|
+
display: "block",
|
|
577
|
+
fontSize: "0.75rem",
|
|
578
|
+
fontWeight: 500,
|
|
579
|
+
marginBottom: "0.25rem",
|
|
580
|
+
color: "var(--cedros-admin-text-muted, #64748b)"
|
|
581
|
+
}, children: "Token Icon URL" }),
|
|
582
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center" }, children: [
|
|
583
|
+
/* @__PURE__ */ t(
|
|
584
|
+
"input",
|
|
585
|
+
{
|
|
586
|
+
type: "text",
|
|
587
|
+
className: "cedros-admin__input",
|
|
588
|
+
value: h,
|
|
589
|
+
onChange: (e) => g?.(e.target.value),
|
|
590
|
+
placeholder: "https://example.com/token-logo.png",
|
|
591
|
+
disabled: c,
|
|
592
|
+
style: { flex: 1 }
|
|
593
|
+
}
|
|
594
|
+
),
|
|
595
|
+
h && /* @__PURE__ */ t(
|
|
596
|
+
"img",
|
|
597
|
+
{
|
|
598
|
+
src: h,
|
|
599
|
+
alt: "Token icon preview",
|
|
600
|
+
style: {
|
|
601
|
+
width: 32,
|
|
602
|
+
height: 32,
|
|
603
|
+
borderRadius: "50%",
|
|
604
|
+
border: "1px solid var(--cedros-admin-border, #e5e7eb)",
|
|
605
|
+
objectFit: "cover"
|
|
606
|
+
},
|
|
607
|
+
onError: (e) => {
|
|
608
|
+
e.target.style.display = "none";
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
)
|
|
612
|
+
] }),
|
|
613
|
+
/* @__PURE__ */ t("div", { style: {
|
|
614
|
+
fontSize: "0.7rem",
|
|
615
|
+
color: "var(--cedros-admin-text-muted, #94a3b8)",
|
|
616
|
+
marginTop: "0.25rem"
|
|
617
|
+
}, children: "Shown to customers during checkout" })
|
|
618
|
+
] }),
|
|
619
|
+
/* @__PURE__ */ o("div", { children: [
|
|
620
|
+
/* @__PURE__ */ t("label", { style: {
|
|
621
|
+
display: "block",
|
|
622
|
+
fontSize: "0.75rem",
|
|
623
|
+
fontWeight: 500,
|
|
624
|
+
marginBottom: "0.25rem",
|
|
625
|
+
color: "var(--cedros-admin-text-muted, #64748b)"
|
|
626
|
+
}, children: "Token Decimals" }),
|
|
627
|
+
/* @__PURE__ */ t(
|
|
628
|
+
"input",
|
|
629
|
+
{
|
|
630
|
+
type: "number",
|
|
631
|
+
className: "cedros-admin__input",
|
|
632
|
+
value: n ?? 6,
|
|
633
|
+
onChange: (e) => S?.(parseInt(e.target.value, 10) || 0),
|
|
634
|
+
min: 0,
|
|
635
|
+
max: 18,
|
|
636
|
+
disabled: c,
|
|
637
|
+
style: { width: "100px" }
|
|
638
|
+
}
|
|
639
|
+
),
|
|
640
|
+
/* @__PURE__ */ t("div", { style: {
|
|
641
|
+
fontSize: "0.7rem",
|
|
642
|
+
color: "var(--cedros-admin-text-muted, #94a3b8)",
|
|
643
|
+
marginTop: "0.25rem"
|
|
644
|
+
}, children: "Most SPL tokens use 6 decimals (like USDC)" })
|
|
645
|
+
] })
|
|
646
|
+
] }),
|
|
647
|
+
s && _ && /* @__PURE__ */ t("div", { style: {
|
|
648
|
+
fontSize: "0.75rem",
|
|
649
|
+
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
650
|
+
fontFamily: "monospace",
|
|
651
|
+
wordBreak: "break-all"
|
|
652
|
+
}, children: s }),
|
|
653
|
+
l && /* @__PURE__ */ t("div", { style: {
|
|
654
|
+
fontSize: "0.75rem",
|
|
655
|
+
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
656
|
+
marginTop: "0.25rem"
|
|
657
|
+
}, children: l })
|
|
658
|
+
] })
|
|
659
|
+
] });
|
|
660
|
+
}
|
|
661
|
+
function se({
|
|
662
|
+
label: b,
|
|
663
|
+
value: s,
|
|
664
|
+
onChange: d,
|
|
665
|
+
disabled: n = !1,
|
|
666
|
+
description: S
|
|
667
|
+
}) {
|
|
668
|
+
const [c, l] = k(/* @__PURE__ */ new Set()), [m, h] = k(null), [p, g] = k(""), w = Array.isArray(s) ? s : [], A = (e) => {
|
|
669
|
+
l((i) => {
|
|
670
|
+
const r = new Set(i);
|
|
671
|
+
return r.has(e) ? r.delete(e) : r.add(e), r;
|
|
672
|
+
});
|
|
673
|
+
}, f = () => {
|
|
674
|
+
d([...w, ""]), h(w.length), g("");
|
|
675
|
+
}, I = (e, i) => {
|
|
676
|
+
const r = [...w];
|
|
677
|
+
r[e] = i, d(r);
|
|
678
|
+
}, _ = (e) => {
|
|
679
|
+
const i = w.filter((r, y) => y !== e);
|
|
680
|
+
d(i), l((r) => {
|
|
681
|
+
const y = /* @__PURE__ */ new Set();
|
|
682
|
+
return r.forEach((v) => {
|
|
683
|
+
v < e ? y.add(v) : v > e && y.add(v - 1);
|
|
684
|
+
}), y;
|
|
685
|
+
});
|
|
686
|
+
}, R = (e) => {
|
|
687
|
+
h(e), g(w[e] || "");
|
|
688
|
+
}, x = () => {
|
|
689
|
+
m !== null && (I(m, p), h(null), g(""));
|
|
690
|
+
}, C = () => {
|
|
691
|
+
m !== null && w[m] === "" && _(m), h(null), g("");
|
|
692
|
+
};
|
|
693
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
694
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "0.5rem" }, children: [
|
|
695
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", style: { marginBottom: 0 }, children: b }),
|
|
696
|
+
/* @__PURE__ */ o(
|
|
697
|
+
"button",
|
|
698
|
+
{
|
|
699
|
+
type: "button",
|
|
700
|
+
onClick: f,
|
|
701
|
+
disabled: n,
|
|
702
|
+
style: {
|
|
703
|
+
display: "flex",
|
|
704
|
+
alignItems: "center",
|
|
705
|
+
gap: "0.25rem",
|
|
706
|
+
padding: "0.25rem 0.5rem",
|
|
707
|
+
fontSize: "0.75rem",
|
|
708
|
+
border: "1px solid var(--cedros-admin-border, #d4d4d4)",
|
|
709
|
+
borderRadius: "0.375rem",
|
|
710
|
+
background: "var(--cedros-admin-bg, #fff)",
|
|
711
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
712
|
+
opacity: n ? 0.5 : 1
|
|
713
|
+
},
|
|
714
|
+
children: [
|
|
715
|
+
T.plus,
|
|
716
|
+
"Add"
|
|
717
|
+
]
|
|
718
|
+
}
|
|
719
|
+
)
|
|
720
|
+
] }),
|
|
721
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
722
|
+
w.length === 0 && /* @__PURE__ */ t("div", { style: {
|
|
723
|
+
padding: "1rem",
|
|
724
|
+
textAlign: "center",
|
|
725
|
+
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
726
|
+
fontSize: "0.875rem",
|
|
727
|
+
border: "1px dashed var(--cedros-admin-border, #d4d4d4)",
|
|
728
|
+
borderRadius: "0.5rem"
|
|
729
|
+
}, children: 'No items. Click "Add" to create one.' }),
|
|
730
|
+
w.map((e, i) => {
|
|
731
|
+
const r = c.has(i), y = m === i, v = e === z;
|
|
732
|
+
return /* @__PURE__ */ t(
|
|
733
|
+
"div",
|
|
734
|
+
{
|
|
735
|
+
style: {
|
|
736
|
+
display: "flex",
|
|
737
|
+
alignItems: "center",
|
|
738
|
+
gap: "0.5rem",
|
|
739
|
+
padding: "0.5rem",
|
|
740
|
+
background: "var(--cedros-admin-bg-muted, #f9fafb)",
|
|
741
|
+
borderRadius: "0.375rem",
|
|
742
|
+
border: "1px solid var(--cedros-admin-border, #e5e7eb)"
|
|
743
|
+
},
|
|
744
|
+
children: y ? /* @__PURE__ */ o(U, { children: [
|
|
745
|
+
/* @__PURE__ */ t(
|
|
746
|
+
"input",
|
|
747
|
+
{
|
|
748
|
+
type: "text",
|
|
749
|
+
className: "cedros-admin__input",
|
|
750
|
+
value: p,
|
|
751
|
+
onChange: (a) => g(a.target.value),
|
|
752
|
+
placeholder: "Enter wallet keypair...",
|
|
753
|
+
autoFocus: !0,
|
|
754
|
+
style: { flex: 1, fontFamily: "monospace", fontSize: "0.75rem" },
|
|
755
|
+
onKeyDown: (a) => {
|
|
756
|
+
a.key === "Enter" && x(), a.key === "Escape" && C();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
),
|
|
760
|
+
/* @__PURE__ */ t(
|
|
761
|
+
"button",
|
|
762
|
+
{
|
|
763
|
+
type: "button",
|
|
764
|
+
onClick: x,
|
|
765
|
+
style: {
|
|
766
|
+
padding: "0.375rem",
|
|
767
|
+
border: "none",
|
|
768
|
+
background: "var(--cedros-admin-success, #22c55e)",
|
|
769
|
+
color: "#fff",
|
|
770
|
+
borderRadius: "0.25rem",
|
|
771
|
+
cursor: "pointer"
|
|
772
|
+
},
|
|
773
|
+
title: "Save",
|
|
774
|
+
children: T.check
|
|
775
|
+
}
|
|
776
|
+
),
|
|
777
|
+
/* @__PURE__ */ t(
|
|
778
|
+
"button",
|
|
779
|
+
{
|
|
780
|
+
type: "button",
|
|
781
|
+
onClick: C,
|
|
782
|
+
style: {
|
|
783
|
+
padding: "0.375rem",
|
|
784
|
+
border: "none",
|
|
785
|
+
background: "var(--cedros-admin-text-muted, #64748b)",
|
|
786
|
+
color: "#fff",
|
|
787
|
+
borderRadius: "0.25rem",
|
|
788
|
+
cursor: "pointer"
|
|
789
|
+
},
|
|
790
|
+
title: "Cancel",
|
|
791
|
+
children: T.close
|
|
792
|
+
}
|
|
793
|
+
)
|
|
794
|
+
] }) : /* @__PURE__ */ o(U, { children: [
|
|
795
|
+
/* @__PURE__ */ t("div", { style: {
|
|
796
|
+
flex: 1,
|
|
797
|
+
fontFamily: "monospace",
|
|
798
|
+
fontSize: "0.75rem",
|
|
799
|
+
overflow: "hidden",
|
|
800
|
+
textOverflow: "ellipsis",
|
|
801
|
+
whiteSpace: "nowrap"
|
|
802
|
+
}, children: r && !v ? e : v ? "[REDACTED]" : "••••••••••••••••••••" }),
|
|
803
|
+
/* @__PURE__ */ t(
|
|
804
|
+
"button",
|
|
805
|
+
{
|
|
806
|
+
type: "button",
|
|
807
|
+
onClick: () => A(i),
|
|
808
|
+
disabled: n || v,
|
|
809
|
+
style: {
|
|
810
|
+
padding: "0.375rem",
|
|
811
|
+
border: "none",
|
|
812
|
+
background: "transparent",
|
|
813
|
+
cursor: n || v ? "not-allowed" : "pointer",
|
|
814
|
+
opacity: n || v ? 0.5 : 1,
|
|
815
|
+
color: "var(--cedros-admin-text-muted, #64748b)"
|
|
816
|
+
},
|
|
817
|
+
title: r ? "Hide" : "Show",
|
|
818
|
+
children: r ? T.eyeOff : T.eye
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
/* @__PURE__ */ t(
|
|
822
|
+
"button",
|
|
823
|
+
{
|
|
824
|
+
type: "button",
|
|
825
|
+
onClick: () => R(i),
|
|
826
|
+
disabled: n,
|
|
827
|
+
style: {
|
|
828
|
+
padding: "0.375rem",
|
|
829
|
+
border: "none",
|
|
830
|
+
background: "transparent",
|
|
831
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
832
|
+
opacity: n ? 0.5 : 1,
|
|
833
|
+
color: "var(--cedros-admin-text-muted, #64748b)"
|
|
834
|
+
},
|
|
835
|
+
title: "Edit",
|
|
836
|
+
children: T.settings
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
/* @__PURE__ */ t(
|
|
840
|
+
"button",
|
|
841
|
+
{
|
|
842
|
+
type: "button",
|
|
843
|
+
onClick: () => _(i),
|
|
844
|
+
disabled: n,
|
|
845
|
+
style: {
|
|
846
|
+
padding: "0.375rem",
|
|
847
|
+
border: "none",
|
|
848
|
+
background: "transparent",
|
|
849
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
850
|
+
opacity: n ? 0.5 : 1,
|
|
851
|
+
color: "var(--cedros-admin-error, #ef4444)"
|
|
852
|
+
},
|
|
853
|
+
title: "Delete",
|
|
854
|
+
children: T.trash
|
|
855
|
+
}
|
|
856
|
+
)
|
|
857
|
+
] })
|
|
858
|
+
},
|
|
859
|
+
i
|
|
860
|
+
);
|
|
861
|
+
})
|
|
862
|
+
] }),
|
|
863
|
+
S && /* @__PURE__ */ t("div", { style: {
|
|
864
|
+
fontSize: "0.75rem",
|
|
865
|
+
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
866
|
+
marginTop: "0.5rem"
|
|
867
|
+
}, children: S })
|
|
868
|
+
] });
|
|
869
|
+
}
|
|
870
|
+
function J(b, s, d) {
|
|
871
|
+
const n = G(b, s), S = s.replace(/_/g, " ").replace(/\b\w/g, (h) => h.toUpperCase()), l = L[b]?.fields?.[s], m = {
|
|
872
|
+
isSecret: n,
|
|
873
|
+
label: S,
|
|
874
|
+
description: l?.description,
|
|
875
|
+
hidden: l?.hidden,
|
|
876
|
+
showWhen: l?.showWhen
|
|
877
|
+
};
|
|
878
|
+
return l?.type === "dropdown" && l.options ? { ...m, type: "dropdown", options: l.options } : l?.type === "token_mint" ? { ...m, type: "token_mint" } : l?.type === "toggle" ? { ...m, type: "toggle" } : l?.type === "secret_array" ? { ...m, type: "secret_array", isSecret: !0 } : l?.type === "solana_address" ? { ...m, type: "solana_address" } : l?.type === "number" ? { ...m, type: "number", unit: l.unit } : typeof d == "boolean" ? { ...m, type: "boolean" } : typeof d == "number" ? { ...m, type: "number", unit: l?.unit } : Array.isArray(d) ? { ...m, type: "array" } : typeof d == "object" && d !== null ? { ...m, type: "object" } : { ...m, type: "string" };
|
|
879
|
+
}
|
|
880
|
+
function ae({
|
|
881
|
+
category: b,
|
|
882
|
+
config: s,
|
|
883
|
+
originalConfig: d,
|
|
884
|
+
isLoading: n = !1,
|
|
885
|
+
onSave: S
|
|
886
|
+
}) {
|
|
887
|
+
const [c, l] = k(s), [m, h] = k(/* @__PURE__ */ new Set());
|
|
888
|
+
V(() => {
|
|
889
|
+
l(s);
|
|
890
|
+
}, [s]);
|
|
891
|
+
const p = H(() => {
|
|
892
|
+
const e = { ...c };
|
|
893
|
+
for (const i of Object.keys(e))
|
|
894
|
+
if (G(b, i)) {
|
|
895
|
+
const r = d[i], y = e[i];
|
|
896
|
+
(y === z || y === r) && (e[i] = z);
|
|
897
|
+
}
|
|
898
|
+
return e;
|
|
899
|
+
}, [c, d, b]), g = H(() => {
|
|
900
|
+
const e = c.token_mint;
|
|
901
|
+
return typeof e != "string" || !e ? !1 : !B(e).valid;
|
|
902
|
+
}, [c]), { status: w, error: A } = te({
|
|
903
|
+
data: p,
|
|
904
|
+
onSave: S,
|
|
905
|
+
debounceMs: 1500,
|
|
906
|
+
enabled: !g
|
|
907
|
+
}), f = M((e, i) => {
|
|
908
|
+
l((r) => ({ ...r, [e]: i }));
|
|
909
|
+
}, []), I = M((e) => {
|
|
910
|
+
h((i) => {
|
|
911
|
+
const r = new Set(i);
|
|
912
|
+
return r.has(e) ? r.delete(e) : r.add(e), r;
|
|
913
|
+
});
|
|
914
|
+
}, []), _ = (e) => e ? /* @__PURE__ */ t("div", { style: {
|
|
915
|
+
fontSize: "0.75rem",
|
|
916
|
+
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
917
|
+
marginTop: "0.25rem"
|
|
918
|
+
}, children: e }) : null, R = (e, i) => {
|
|
919
|
+
const r = J(b, e, d[e] ?? i);
|
|
920
|
+
if (r.type === "dropdown" && r.options)
|
|
921
|
+
return /* @__PURE__ */ t(
|
|
922
|
+
Z,
|
|
923
|
+
{
|
|
924
|
+
value: i,
|
|
925
|
+
onChange: (a) => f(e, a),
|
|
926
|
+
options: r.options.map((a) => ({ value: a, label: a })),
|
|
927
|
+
label: r.label,
|
|
928
|
+
description: r.description,
|
|
929
|
+
disabled: n
|
|
930
|
+
}
|
|
931
|
+
);
|
|
932
|
+
if (r.type === "token_mint")
|
|
933
|
+
return /* @__PURE__ */ t(
|
|
934
|
+
oe,
|
|
935
|
+
{
|
|
936
|
+
label: r.label,
|
|
937
|
+
value: i,
|
|
938
|
+
onChange: (a) => f(e, a),
|
|
939
|
+
decimals: c.token_decimals ?? 6,
|
|
940
|
+
onDecimalsChange: (a) => f("token_decimals", a),
|
|
941
|
+
disabled: n,
|
|
942
|
+
description: r.description,
|
|
943
|
+
customSymbol: c.custom_token_symbol || "",
|
|
944
|
+
customIcon: c.custom_token_icon || "",
|
|
945
|
+
onCustomSymbolChange: (a) => f("custom_token_symbol", a),
|
|
946
|
+
onCustomIconChange: (a) => f("custom_token_icon", a)
|
|
947
|
+
}
|
|
948
|
+
);
|
|
949
|
+
if (r.type === "toggle")
|
|
950
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
951
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
|
|
952
|
+
/* @__PURE__ */ t(
|
|
953
|
+
"button",
|
|
954
|
+
{
|
|
955
|
+
type: "button",
|
|
956
|
+
role: "switch",
|
|
957
|
+
"aria-checked": i,
|
|
958
|
+
onClick: () => f(e, !i),
|
|
959
|
+
disabled: n,
|
|
960
|
+
style: {
|
|
961
|
+
width: 44,
|
|
962
|
+
height: 24,
|
|
963
|
+
borderRadius: 12,
|
|
964
|
+
border: "none",
|
|
965
|
+
backgroundColor: i ? "var(--cedros-admin-primary, #171717)" : "var(--cedros-admin-border, #d4d4d4)",
|
|
966
|
+
cursor: n ? "not-allowed" : "pointer",
|
|
967
|
+
position: "relative",
|
|
968
|
+
transition: "background-color 0.2s",
|
|
969
|
+
opacity: n ? 0.5 : 1,
|
|
970
|
+
flexShrink: 0
|
|
971
|
+
},
|
|
972
|
+
children: /* @__PURE__ */ t(
|
|
973
|
+
"span",
|
|
974
|
+
{
|
|
975
|
+
style: {
|
|
976
|
+
position: "absolute",
|
|
977
|
+
top: 2,
|
|
978
|
+
left: i ? 22 : 2,
|
|
979
|
+
width: 20,
|
|
980
|
+
height: 20,
|
|
981
|
+
borderRadius: "50%",
|
|
982
|
+
backgroundColor: "#fff",
|
|
983
|
+
transition: "left 0.2s",
|
|
984
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
)
|
|
988
|
+
}
|
|
989
|
+
),
|
|
990
|
+
/* @__PURE__ */ t("span", { className: "cedros-admin__field-label", style: { marginBottom: 0 }, children: r.label })
|
|
991
|
+
] }),
|
|
992
|
+
_(r.description)
|
|
993
|
+
] });
|
|
994
|
+
if (r.type === "solana_address") {
|
|
995
|
+
const a = i || "", N = B(a);
|
|
996
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
997
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: r.label }),
|
|
998
|
+
/* @__PURE__ */ o("div", { style: { position: "relative" }, children: [
|
|
999
|
+
/* @__PURE__ */ t(
|
|
1000
|
+
"input",
|
|
1001
|
+
{
|
|
1002
|
+
type: "text",
|
|
1003
|
+
className: `cedros-admin__input ${N.valid ? "" : "cedros-admin__input--error"}`,
|
|
1004
|
+
value: a,
|
|
1005
|
+
onChange: (D) => f(e, D.target.value),
|
|
1006
|
+
disabled: n,
|
|
1007
|
+
placeholder: "e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
|
|
1008
|
+
style: {
|
|
1009
|
+
width: "100%",
|
|
1010
|
+
fontFamily: "monospace",
|
|
1011
|
+
fontSize: "0.875rem",
|
|
1012
|
+
borderColor: N.valid ? void 0 : "var(--cedros-admin-error, #dc2626)",
|
|
1013
|
+
paddingRight: a && N.valid ? "2rem" : void 0
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
),
|
|
1017
|
+
a && N.valid && /* @__PURE__ */ t(
|
|
1018
|
+
"span",
|
|
1019
|
+
{
|
|
1020
|
+
style: {
|
|
1021
|
+
position: "absolute",
|
|
1022
|
+
right: 10,
|
|
1023
|
+
top: "50%",
|
|
1024
|
+
transform: "translateY(-50%)",
|
|
1025
|
+
color: "var(--cedros-admin-success, #16a34a)",
|
|
1026
|
+
fontSize: "1rem"
|
|
1027
|
+
},
|
|
1028
|
+
title: "Valid Solana address",
|
|
1029
|
+
children: "✓"
|
|
1030
|
+
}
|
|
1031
|
+
)
|
|
1032
|
+
] }),
|
|
1033
|
+
!N.valid && /* @__PURE__ */ t("span", { style: { color: "var(--cedros-admin-error, #dc2626)", fontSize: "0.75rem", marginTop: "0.25rem", display: "block" }, children: N.error }),
|
|
1034
|
+
_(r.description)
|
|
1035
|
+
] });
|
|
1036
|
+
}
|
|
1037
|
+
if (r.type === "boolean")
|
|
1038
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
1039
|
+
/* @__PURE__ */ o("label", { className: "cedros-admin__checkbox", children: [
|
|
1040
|
+
/* @__PURE__ */ t(
|
|
1041
|
+
"input",
|
|
1042
|
+
{
|
|
1043
|
+
type: "checkbox",
|
|
1044
|
+
checked: i,
|
|
1045
|
+
onChange: (a) => f(e, a.target.checked),
|
|
1046
|
+
disabled: n
|
|
1047
|
+
}
|
|
1048
|
+
),
|
|
1049
|
+
r.label
|
|
1050
|
+
] }),
|
|
1051
|
+
_(r.description)
|
|
1052
|
+
] });
|
|
1053
|
+
if (r.type === "number")
|
|
1054
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
1055
|
+
/* @__PURE__ */ o("label", { className: "cedros-admin__field-label", children: [
|
|
1056
|
+
r.label,
|
|
1057
|
+
r.unit && /* @__PURE__ */ o("span", { className: "cedros-admin__field-unit", children: [
|
|
1058
|
+
" (",
|
|
1059
|
+
r.unit,
|
|
1060
|
+
")"
|
|
1061
|
+
] })
|
|
1062
|
+
] }),
|
|
1063
|
+
/* @__PURE__ */ t(
|
|
1064
|
+
"input",
|
|
1065
|
+
{
|
|
1066
|
+
type: "number",
|
|
1067
|
+
className: "cedros-admin__input",
|
|
1068
|
+
value: i,
|
|
1069
|
+
onChange: (a) => f(e, parseFloat(a.target.value) || 0),
|
|
1070
|
+
disabled: n
|
|
1071
|
+
}
|
|
1072
|
+
),
|
|
1073
|
+
_(r.description)
|
|
1074
|
+
] });
|
|
1075
|
+
if (r.type === "secret_array")
|
|
1076
|
+
return /* @__PURE__ */ t(
|
|
1077
|
+
se,
|
|
1078
|
+
{
|
|
1079
|
+
label: r.label,
|
|
1080
|
+
value: i,
|
|
1081
|
+
onChange: (a) => f(e, a),
|
|
1082
|
+
disabled: n,
|
|
1083
|
+
description: r.description
|
|
1084
|
+
}
|
|
1085
|
+
);
|
|
1086
|
+
if (r.type === "array") {
|
|
1087
|
+
const a = i;
|
|
1088
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
1089
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: r.label }),
|
|
1090
|
+
/* @__PURE__ */ t(
|
|
1091
|
+
"textarea",
|
|
1092
|
+
{
|
|
1093
|
+
className: "cedros-admin__textarea",
|
|
1094
|
+
value: a.join(`
|
|
1095
|
+
`),
|
|
1096
|
+
onChange: (N) => f(e, N.target.value.split(`
|
|
1097
|
+
`).filter(Boolean)),
|
|
1098
|
+
placeholder: "One item per line",
|
|
1099
|
+
rows: 3,
|
|
1100
|
+
disabled: n
|
|
1101
|
+
}
|
|
1102
|
+
),
|
|
1103
|
+
_(r.description)
|
|
1104
|
+
] });
|
|
1105
|
+
}
|
|
1106
|
+
if (r.type === "object")
|
|
1107
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
1108
|
+
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: r.label }),
|
|
1109
|
+
/* @__PURE__ */ t(
|
|
1110
|
+
"textarea",
|
|
1111
|
+
{
|
|
1112
|
+
className: "cedros-admin__textarea cedros-admin__textarea--mono",
|
|
1113
|
+
value: JSON.stringify(i, null, 2),
|
|
1114
|
+
onChange: (a) => {
|
|
1115
|
+
try {
|
|
1116
|
+
f(e, JSON.parse(a.target.value));
|
|
1117
|
+
} catch {
|
|
1118
|
+
}
|
|
1119
|
+
},
|
|
1120
|
+
rows: 5,
|
|
1121
|
+
disabled: n
|
|
1122
|
+
}
|
|
1123
|
+
),
|
|
1124
|
+
_(r.description)
|
|
1125
|
+
] });
|
|
1126
|
+
const y = m.has(e), v = r.isSecret && !y && i === z ? z : i;
|
|
1127
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__field", children: [
|
|
1128
|
+
/* @__PURE__ */ o("label", { className: "cedros-admin__field-label", children: [
|
|
1129
|
+
r.label,
|
|
1130
|
+
r.isSecret && /* @__PURE__ */ t("span", { className: "cedros-admin__field-secret", children: " (secret)" })
|
|
1131
|
+
] }),
|
|
1132
|
+
/* @__PURE__ */ o("div", { className: "cedros-admin__input-group", children: [
|
|
1133
|
+
/* @__PURE__ */ t(
|
|
1134
|
+
"input",
|
|
1135
|
+
{
|
|
1136
|
+
type: r.isSecret && !y ? "password" : "text",
|
|
1137
|
+
className: "cedros-admin__input",
|
|
1138
|
+
value: v,
|
|
1139
|
+
onChange: (a) => f(e, a.target.value),
|
|
1140
|
+
disabled: n,
|
|
1141
|
+
placeholder: r.isSecret ? "••••••••" : ""
|
|
1142
|
+
}
|
|
1143
|
+
),
|
|
1144
|
+
r.isSecret && /* @__PURE__ */ t(
|
|
1145
|
+
"button",
|
|
1146
|
+
{
|
|
1147
|
+
type: "button",
|
|
1148
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
1149
|
+
onClick: () => I(e),
|
|
1150
|
+
style: { padding: "0.5rem", minWidth: "auto" },
|
|
1151
|
+
title: y ? "Hide" : "Show",
|
|
1152
|
+
children: y ? T.eyeOff : T.eye
|
|
1153
|
+
}
|
|
1154
|
+
)
|
|
1155
|
+
] }),
|
|
1156
|
+
_(r.description)
|
|
1157
|
+
] });
|
|
1158
|
+
}, x = Object.keys(c), C = (e) => {
|
|
1159
|
+
const i = J(b, e, d[e] ?? c[e]);
|
|
1160
|
+
if (i.hidden || i.showWhen && !c[i.showWhen])
|
|
1161
|
+
return !1;
|
|
1162
|
+
if (e === "token_decimals") {
|
|
1163
|
+
const r = c.token_mint;
|
|
1164
|
+
if (r && O[r])
|
|
1165
|
+
return !1;
|
|
1166
|
+
}
|
|
1167
|
+
return !0;
|
|
1168
|
+
};
|
|
1169
|
+
return /* @__PURE__ */ o("div", { className: "cedros-admin__config-editor", children: [
|
|
1170
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__config-fields", children: x.filter(C).map((e) => /* @__PURE__ */ t("div", { className: "cedros-admin__config-field", children: R(e, c[e]) }, e)) }),
|
|
1171
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__config-actions", children: /* @__PURE__ */ t("div", { className: "cedros-admin__autosave-status", children: /* @__PURE__ */ t(re, { status: w, error: A }) }) })
|
|
1172
|
+
] });
|
|
1173
|
+
}
|
|
1174
|
+
function fe({
|
|
1175
|
+
serverUrl: b,
|
|
1176
|
+
apiKey: s,
|
|
1177
|
+
authManager: d,
|
|
1178
|
+
category: n,
|
|
1179
|
+
title: S,
|
|
1180
|
+
description: c,
|
|
1181
|
+
enabledField: l = "enabled",
|
|
1182
|
+
showEnabledToggle: m = !1
|
|
1183
|
+
}) {
|
|
1184
|
+
const h = H(
|
|
1185
|
+
() => new ne(b, void 0, d),
|
|
1186
|
+
[b, d]
|
|
1187
|
+
), [p, g] = k(null), [w, A] = k([]), [f, I] = k(!1), [_, R] = k(!0), [x, C] = k(null), [e, i] = k(null), [r, y] = k(!1), v = L[n] || { label: n, icon: "⚙️" }, a = S || v.label, N = c || v.description, D = M(async () => {
|
|
1188
|
+
R(!0), C(null);
|
|
1189
|
+
try {
|
|
1190
|
+
const u = await h.getConfig(n, !0);
|
|
1191
|
+
g(u);
|
|
1192
|
+
} catch {
|
|
1193
|
+
g(null), C("Failed to load settings");
|
|
1194
|
+
} finally {
|
|
1195
|
+
R(!1);
|
|
1196
|
+
}
|
|
1197
|
+
}, [h, n]);
|
|
1198
|
+
V(() => {
|
|
1199
|
+
D();
|
|
1200
|
+
}, [D]);
|
|
1201
|
+
const j = M(async () => {
|
|
1202
|
+
try {
|
|
1203
|
+
const u = await h.getHistory(n, 20);
|
|
1204
|
+
A(u.history);
|
|
1205
|
+
} catch {
|
|
1206
|
+
A([]);
|
|
1207
|
+
}
|
|
1208
|
+
}, [h, n]);
|
|
1209
|
+
V(() => {
|
|
1210
|
+
f && j();
|
|
1211
|
+
}, [f, j]);
|
|
1212
|
+
const Y = M(async (u) => {
|
|
1213
|
+
await h.updateConfig(n, u, "Updated via admin dashboard");
|
|
1214
|
+
}, [h, n]), F = M(async (u) => h.validateConfig(n, u), [h, n]), [W, K] = k(!1), X = M(async () => {
|
|
1215
|
+
if (!p || W) return;
|
|
1216
|
+
const u = !!p.config[l], P = !u, $ = { ...p.config, [l]: P };
|
|
1217
|
+
K(!0), g({ ...p, config: $ });
|
|
1218
|
+
try {
|
|
1219
|
+
await h.updateConfig(n, $, `${P ? "Enabled" : "Disabled"} via admin dashboard`);
|
|
1220
|
+
} catch (q) {
|
|
1221
|
+
g({ ...p, config: { ...p.config, [l]: u } }), C(q instanceof Error ? q.message : "Failed to save enabled state");
|
|
1222
|
+
} finally {
|
|
1223
|
+
K(!1);
|
|
1224
|
+
}
|
|
1225
|
+
}, [p, h, n, l, W]), E = !!p?.config[l];
|
|
1226
|
+
return _ && !p ? /* @__PURE__ */ t("div", { className: "cedros-admin__section", children: /* @__PURE__ */ o("div", { className: "cedros-admin__loading", children: [
|
|
1227
|
+
T.loading,
|
|
1228
|
+
" Loading ",
|
|
1229
|
+
a,
|
|
1230
|
+
" settings..."
|
|
1231
|
+
] }) }) : /* @__PURE__ */ o("div", { className: "cedros-admin__section", children: [
|
|
1232
|
+
/* @__PURE__ */ t(Q, { message: x, onRetry: D }),
|
|
1233
|
+
/* @__PURE__ */ o("div", { className: "cedros-admin__section-header", children: [
|
|
1234
|
+
/* @__PURE__ */ o("div", { children: [
|
|
1235
|
+
/* @__PURE__ */ o("h3", { className: "cedros-admin__section-title", children: [
|
|
1236
|
+
/* @__PURE__ */ t("span", { style: { marginRight: "0.5rem" }, children: v.icon }),
|
|
1237
|
+
a
|
|
1238
|
+
] }),
|
|
1239
|
+
N && /* @__PURE__ */ t("p", { className: "cedros-admin__text-muted", style: { marginTop: "0.25rem" }, children: N })
|
|
1240
|
+
] }),
|
|
1241
|
+
m && p && /* @__PURE__ */ o("div", { style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
|
|
1242
|
+
/* @__PURE__ */ t("span", { style: { fontSize: "0.875rem", color: E ? "var(--cedros-admin-text, #171717)" : "var(--cedros-admin-muted, #737373)" }, children: E ? "Enabled" : "Disabled" }),
|
|
1243
|
+
/* @__PURE__ */ t(
|
|
1244
|
+
"button",
|
|
1245
|
+
{
|
|
1246
|
+
type: "button",
|
|
1247
|
+
role: "switch",
|
|
1248
|
+
"aria-checked": E,
|
|
1249
|
+
onClick: X,
|
|
1250
|
+
disabled: W,
|
|
1251
|
+
style: {
|
|
1252
|
+
width: 44,
|
|
1253
|
+
height: 24,
|
|
1254
|
+
borderRadius: 12,
|
|
1255
|
+
border: "none",
|
|
1256
|
+
backgroundColor: E ? "var(--cedros-admin-primary, #171717)" : "var(--cedros-admin-border, #d4d4d4)",
|
|
1257
|
+
cursor: W ? "wait" : "pointer",
|
|
1258
|
+
position: "relative",
|
|
1259
|
+
transition: "background-color 0.2s",
|
|
1260
|
+
flexShrink: 0,
|
|
1261
|
+
opacity: W ? 0.6 : 1
|
|
1262
|
+
},
|
|
1263
|
+
children: /* @__PURE__ */ t(
|
|
1264
|
+
"span",
|
|
1265
|
+
{
|
|
1266
|
+
style: {
|
|
1267
|
+
position: "absolute",
|
|
1268
|
+
top: 2,
|
|
1269
|
+
left: E ? 22 : 2,
|
|
1270
|
+
width: 20,
|
|
1271
|
+
height: 20,
|
|
1272
|
+
borderRadius: "50%",
|
|
1273
|
+
backgroundColor: "#fff",
|
|
1274
|
+
transition: "left 0.2s",
|
|
1275
|
+
boxShadow: "0 1px 3px rgba(0,0,0,0.2)"
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
)
|
|
1279
|
+
}
|
|
1280
|
+
)
|
|
1281
|
+
] })
|
|
1282
|
+
] }),
|
|
1283
|
+
p && /* @__PURE__ */ o(
|
|
1284
|
+
"div",
|
|
1285
|
+
{
|
|
1286
|
+
className: "cedros-admin__settings-editor",
|
|
1287
|
+
style: {
|
|
1288
|
+
marginTop: "1rem",
|
|
1289
|
+
opacity: m && !E ? 0.6 : 1,
|
|
1290
|
+
pointerEvents: m && !E ? "none" : "auto"
|
|
1291
|
+
},
|
|
1292
|
+
children: [
|
|
1293
|
+
m && !E && /* @__PURE__ */ t(
|
|
1294
|
+
"div",
|
|
1295
|
+
{
|
|
1296
|
+
style: {
|
|
1297
|
+
padding: "0.75rem 1rem",
|
|
1298
|
+
marginBottom: "1rem",
|
|
1299
|
+
backgroundColor: "var(--cedros-admin-warning-bg, #fef3c7)",
|
|
1300
|
+
border: "1px solid var(--cedros-admin-warning-border, #f59e0b)",
|
|
1301
|
+
borderRadius: "0.375rem",
|
|
1302
|
+
fontSize: "0.875rem",
|
|
1303
|
+
color: "var(--cedros-admin-warning-text, #92400e)",
|
|
1304
|
+
pointerEvents: "auto"
|
|
1305
|
+
},
|
|
1306
|
+
children: "This payment method is disabled. Enable it using the toggle above to accept payments."
|
|
1307
|
+
}
|
|
1308
|
+
),
|
|
1309
|
+
/* @__PURE__ */ t(
|
|
1310
|
+
ae,
|
|
1311
|
+
{
|
|
1312
|
+
category: p.category,
|
|
1313
|
+
config: p.config,
|
|
1314
|
+
originalConfig: p.config,
|
|
1315
|
+
onSave: Y,
|
|
1316
|
+
onValidate: F
|
|
1317
|
+
}
|
|
1318
|
+
)
|
|
1319
|
+
]
|
|
1320
|
+
}
|
|
1321
|
+
),
|
|
1322
|
+
f && /* @__PURE__ */ o("div", { className: "cedros-admin__settings-history", style: { marginTop: "1.5rem" }, children: [
|
|
1323
|
+
/* @__PURE__ */ t("h4", { style: { marginBottom: "0.75rem", fontWeight: 600 }, children: "Change History" }),
|
|
1324
|
+
w.length === 0 ? /* @__PURE__ */ t("p", { className: "cedros-admin__text-muted", children: "No history entries found." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__settings-timeline", children: w.map((u) => /* @__PURE__ */ o("div", { className: "cedros-admin__settings-timeline-item", children: [
|
|
1325
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__settings-timeline-dot" }),
|
|
1326
|
+
/* @__PURE__ */ o("div", { className: "cedros-admin__settings-timeline-content", children: [
|
|
1327
|
+
/* @__PURE__ */ o("div", { className: "cedros-admin__settings-timeline-header", children: [
|
|
1328
|
+
/* @__PURE__ */ t("code", { children: u.configKey }),
|
|
1329
|
+
/* @__PURE__ */ t("span", { className: `cedros-admin__badge cedros-admin__badge--${u.action.toLowerCase()}`, children: u.action })
|
|
1330
|
+
] }),
|
|
1331
|
+
/* @__PURE__ */ o("div", { className: "cedros-admin__settings-timeline-meta", children: [
|
|
1332
|
+
ee(u.changedAt),
|
|
1333
|
+
" by ",
|
|
1334
|
+
u.changedBy
|
|
1335
|
+
] })
|
|
1336
|
+
] })
|
|
1337
|
+
] }, u.id)) })
|
|
1338
|
+
] }),
|
|
1339
|
+
e && /* @__PURE__ */ t(
|
|
1340
|
+
"div",
|
|
1341
|
+
{
|
|
1342
|
+
style: {
|
|
1343
|
+
marginTop: "1rem",
|
|
1344
|
+
padding: "0.75rem 1rem",
|
|
1345
|
+
borderRadius: "0.375rem",
|
|
1346
|
+
backgroundColor: e.valid ? "var(--cedros-admin-success-bg, #dcfce7)" : "var(--cedros-admin-error-bg, #fef2f2)",
|
|
1347
|
+
border: `1px solid ${e.valid ? "var(--cedros-admin-success-border, #86efac)" : "var(--cedros-admin-error-border, #fecaca)"}`
|
|
1348
|
+
},
|
|
1349
|
+
children: /* @__PURE__ */ o("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start" }, children: [
|
|
1350
|
+
/* @__PURE__ */ o("div", { style: { flex: 1 }, children: [
|
|
1351
|
+
/* @__PURE__ */ t("div", { style: {
|
|
1352
|
+
fontWeight: 600,
|
|
1353
|
+
color: e.valid ? "var(--cedros-admin-success, #16a34a)" : "var(--cedros-admin-error, #dc2626)",
|
|
1354
|
+
marginBottom: e.errors.length > 0 || e.warnings.length > 0 ? "0.5rem" : 0
|
|
1355
|
+
}, children: e.valid ? "✓ Configuration is valid" : "✗ Validation failed" }),
|
|
1356
|
+
e.errors.length > 0 && /* @__PURE__ */ t("ul", { style: { margin: 0, paddingLeft: "1.25rem", color: "var(--cedros-admin-error, #dc2626)", fontSize: "0.875rem" }, children: e.errors.map((u, P) => /* @__PURE__ */ t("li", { children: u }, P)) }),
|
|
1357
|
+
e.warnings.length > 0 && /* @__PURE__ */ t("ul", { style: { margin: e.errors.length > 0 ? "0.5rem 0 0" : 0, paddingLeft: "1.25rem", color: "var(--cedros-admin-warning, #ca8a04)", fontSize: "0.875rem" }, children: e.warnings.map((u, P) => /* @__PURE__ */ t("li", { children: u }, P)) })
|
|
1358
|
+
] }),
|
|
1359
|
+
/* @__PURE__ */ t(
|
|
1360
|
+
"button",
|
|
1361
|
+
{
|
|
1362
|
+
type: "button",
|
|
1363
|
+
onClick: () => i(null),
|
|
1364
|
+
style: {
|
|
1365
|
+
background: "none",
|
|
1366
|
+
border: "none",
|
|
1367
|
+
cursor: "pointer",
|
|
1368
|
+
padding: "0.25rem",
|
|
1369
|
+
color: "var(--cedros-admin-text-muted, #64748b)",
|
|
1370
|
+
fontSize: "1.25rem",
|
|
1371
|
+
lineHeight: 1
|
|
1372
|
+
},
|
|
1373
|
+
title: "Dismiss",
|
|
1374
|
+
children: "×"
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
] })
|
|
1378
|
+
}
|
|
1379
|
+
),
|
|
1380
|
+
/* @__PURE__ */ o("div", { style: { marginTop: "1.5rem", display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
1381
|
+
/* @__PURE__ */ t(
|
|
1382
|
+
"button",
|
|
1383
|
+
{
|
|
1384
|
+
type: "button",
|
|
1385
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
1386
|
+
onClick: () => I(!f),
|
|
1387
|
+
children: f ? "Hide History" : "History"
|
|
1388
|
+
}
|
|
1389
|
+
),
|
|
1390
|
+
/* @__PURE__ */ t(
|
|
1391
|
+
"button",
|
|
1392
|
+
{
|
|
1393
|
+
type: "button",
|
|
1394
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
1395
|
+
disabled: r || !p,
|
|
1396
|
+
onClick: async () => {
|
|
1397
|
+
if (p) {
|
|
1398
|
+
y(!0), i(null);
|
|
1399
|
+
try {
|
|
1400
|
+
const u = await F(p.config);
|
|
1401
|
+
i(u);
|
|
1402
|
+
} catch (u) {
|
|
1403
|
+
i({
|
|
1404
|
+
valid: !1,
|
|
1405
|
+
errors: [u instanceof Error ? u.message : "Validation failed"],
|
|
1406
|
+
warnings: []
|
|
1407
|
+
});
|
|
1408
|
+
} finally {
|
|
1409
|
+
y(!1);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
},
|
|
1413
|
+
children: r ? "Validating..." : "Validate"
|
|
1414
|
+
}
|
|
1415
|
+
)
|
|
1416
|
+
] })
|
|
1417
|
+
] });
|
|
1418
|
+
}
|
|
1419
|
+
export {
|
|
1420
|
+
fe as S
|
|
1421
|
+
};
|