@cedros/pay-react 1.1.21 → 1.1.22
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-BXWZcMQT.js → AISettingsSection-BtOxEweU.js} +1 -1
- package/dist/{AISettingsSection-8eDaxYp8.mjs → AISettingsSection-p3iikbSw.mjs} +2 -2
- package/dist/{AutosaveIndicator-DW4IPbZ5.js → AutosaveIndicator-C-CH-obR.js} +1 -1
- package/dist/{AutosaveIndicator-3S7EvXip.mjs → AutosaveIndicator-CWbb-VXf.mjs} +1 -1
- package/dist/{FAQSection-r6eKjfdO.js → FAQSection-DQpF7hVx.js} +1 -1
- package/dist/{FAQSection-Dg-I7Z-N.mjs → FAQSection-byh7zfqI.mjs} +1 -1
- package/dist/{MessagingSection-Cld5Q7ZM.js → MessagingSection-B6EHvjDw.js} +1 -1
- package/dist/{MessagingSection-D39EuOLN.mjs → MessagingSection-CK208brx.mjs} +2 -2
- package/dist/{PaymentSettingsSection-CEGHN6VI.mjs → PaymentSettingsSection-B9H253x1.mjs} +1 -1
- package/dist/{PaymentSettingsSection-B-MRsh1K.js → PaymentSettingsSection-Cmmuhmd4.js} +1 -1
- package/dist/{SettingsSection-CPFOuoZG.mjs → SettingsSection-DDLMaEPo.mjs} +1 -1
- package/dist/{SettingsSection-ZrzfLBlS.js → SettingsSection-DrzGdvHH.js} +1 -1
- package/dist/{SingleCategorySettings-DhHGIGwB.mjs → SingleCategorySettings-BU98SRFV.mjs} +56 -56
- package/dist/SingleCategorySettings-DqcXe-q4.js +3 -0
- package/dist/{StorefrontSection-DGVcJu1T.js → StorefrontSection-DTpZ_GgO.js} +1 -1
- package/dist/{StorefrontSection-f54ySA6i.mjs → StorefrontSection-Dr2ciBVg.mjs} +2 -2
- package/dist/{SubscriptionsSection-F2IiU2jv.mjs → SubscriptionsSection-CU3Ce8r9.mjs} +1 -1
- package/dist/{SubscriptionsSection-fzbL5DGC.js → SubscriptionsSection-CYJpArJ8.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +1 -1
- package/dist/{index-bqhsxBTY.mjs → index-CufXF9Yd.mjs} +18 -18
- package/dist/{index-7YUxR4u5.js → index-IZ4WcMd7.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{sections-CiAMjlPd.mjs → sections-Bc6ARlND.mjs} +1 -1
- package/dist/{sections-Dh0qFSUW.js → sections-CR7NRsjq.js} +1 -1
- package/package.json +1 -1
- package/dist/SingleCategorySettings-DxjCafCk.js +0 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./styles-BWrLnaUW.js"),t=require("./CedrosContext-D-lnoEkR.js"),r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./styles-BWrLnaUW.js"),t=require("./CedrosContext-D-lnoEkR.js"),r=require("./index-IZ4WcMd7.js");exports.CEDROS_EVENTS=e.CEDROS_EVENTS;exports.CSP_PRESETS=e.CSP_PRESETS;exports.CedrosPay=e.CedrosPay;exports.CreditsButton=e.CreditsButton;exports.CreditsSubscribeButton=e.CreditsSubscribeButton;exports.PaymentMethodBadge=e.PaymentMethodBadge;exports.PaymentModal=e.PaymentModal;exports.ProductPrice=e.ProductPrice;exports.PurchaseButton=e.PurchaseButton;exports.RPC_PROVIDERS=e.RPC_PROVIDERS;exports.SECURITY_RECOMMENDATIONS=e.SECURITY_RECOMMENDATIONS;exports.StripeButton=e.StripeButton;exports.SubscribeButton=e.SubscribeButton;exports.SubscriptionManagementPanel=e.SubscriptionManagementPanel;exports.calculateDiscountPercentage=e.calculateDiscountPercentage;exports.createTranslator=e.createTranslator;exports.detectLocale=e.detectLocale;exports.emitPaymentError=e.emitPaymentError;exports.emitPaymentProcessing=e.emitPaymentProcessing;exports.emitPaymentStart=e.emitPaymentStart;exports.emitPaymentSuccess=e.emitPaymentSuccess;exports.emitWalletConnect=e.emitWalletConnect;exports.emitWalletConnected=e.emitWalletConnected;exports.emitWalletError=e.emitWalletError;exports.formatCSP=e.formatCSP;exports.formatCouponCodes=e.formatCouponCodes;exports.generateCSP=e.generateCSP;exports.generateCSPDirectives=e.generateCSPDirectives;exports.getAvailableLocales=e.getAvailableLocales;exports.getLocalizedError=e.getLocalizedError;exports.getUserErrorMessage=e.getUserErrorMessage;exports.isRetryableError=e.isRetryableError;exports.loadLocale=e.loadLocale;exports.logSecurityReport=e.logSecurityReport;exports.parseCouponCodes=e.parseCouponCodes;exports.stackCheckoutCoupons=e.stackCheckoutCoupons;exports.useCreditsPayment=e.useCreditsPayment;exports.useCreditsSubscription=e.useCreditsSubscription;exports.useLocalizedError=e.useLocalizedError;exports.usePaymentMode=e.usePaymentMode;exports.useStripeCheckout=e.useStripeCheckout;exports.useSubscription=e.useSubscription;exports.useSubscriptionManagement=e.useSubscriptionManagement;exports.useTranslation=e.useTranslation;exports.validateSecurity=e.validateSecurity;exports.CIRCUIT_BREAKER_PRESETS=t.CIRCUIT_BREAKER_PRESETS;exports.CedrosProvider=t.CedrosProvider;exports.CircuitBreakerOpenError=t.CircuitBreakerOpenError;exports.CircuitState=t.CircuitState;exports.ERROR_CATEGORIES=t.ERROR_CATEGORIES;exports.LogLevel=t.LogLevel;exports.Logger=t.Logger;exports.RATE_LIMITER_PRESETS=t.RATE_LIMITER_PRESETS;exports.RETRY_PRESETS=t.RETRY_PRESETS;exports.createCircuitBreaker=t.createCircuitBreaker;exports.createLogger=t.createLogger;exports.createRateLimiter=t.createRateLimiter;exports.getLogger=t.getLogger;exports.retryWithBackoff=t.retryWithBackoff;exports.useCedrosContext=t.useCedrosContext;exports.useCedrosTheme=t.useCedrosTheme;exports.validateConfig=t.validateConfig;exports.CEDROS_PAY_GROUPS=r.CEDROS_PAY_GROUPS;exports.CEDROS_PAY_SECTIONS=r.CEDROS_PAY_SECTIONS;exports.CEDROS_PAY_SECTION_IDS=r.CEDROS_PAY_SECTION_IDS;exports.CedrosPayAdminDashboard=r.CedrosPayAdminDashboard;exports.cedrosPayPlugin=r.cedrosPayPlugin;exports.ecommerce=r.index;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v as s, t, C as r, a as o, f as i, d as c, b as n, c as C, P as S, R as u, I as E, S as P, e as d, g as R, n as m, M as l, J as g, D as T, A as _, w as p, B as y, x as b, y as L, z as O, r as I, m as B, o as D, q as f, L as A, N as M, F as h, E as v, K as k, H as N, p as x, s as Y, h as U, k as W, Q as z, i as G, u as j, j as K, l as V, O as q, G as w } from "./styles--eKKnfdj.mjs";
|
|
2
2
|
import { f as H, C as J, e as Q, d as X, E as Z, L as $, h as aa, R as ea, g as sa, b as ta, j as ra, c as oa, i as ia, r as ca, u as na, a as Ca, v as Sa } from "./CedrosContext-BE6P5PQ0.mjs";
|
|
3
|
-
import { d as Ea, a as Pa, b as da, C as Ra, c as ma, i as la } from "./index-
|
|
3
|
+
import { d as Ea, a as Pa, b as da, C as Ra, c as ma, i as la } from "./index-CufXF9Yd.mjs";
|
|
4
4
|
export {
|
|
5
5
|
s as CEDROS_EVENTS,
|
|
6
6
|
Ea as CEDROS_PAY_GROUPS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-IZ4WcMd7.js");exports.CouponsSection=t.CouponsSection;exports.ProductsSection=t.ProductsSection;exports.RefundsSection=t.RefundsSection;exports.SettingsSection=t.SettingsSection;exports.TransactionsSection=t.TransactionsSection;
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),m=require("react"),w=require("./index-7YUxR4u5.js"),J=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-DW4IPbZ5.js"),P=require("./CedrosContext-D-lnoEkR.js");class G{constructor(n,a,i){this._serverUrl=n,this.auth=a,this.authManager=i}get serverUrl(){return this._serverUrl}async fetch(n,a={}){if(this.authManager?.isAuthenticated())return this.authManager.fetchWithAuth(n,a);throw this.auth?new Error("Legacy AdminAuth is no longer supported due to replay vulnerability. Use IAdminAuthManager instead."):new Error("Admin authentication required. Provide an IAdminAuthManager to ConfigApi.")}async listCategories(n=100){return this.fetch(`/admin/config?limit=${n}`)}async getConfig(n,a=!0){return this.fetch(`/admin/config/${n}?redact_secrets=${a}`)}async updateConfig(n,a,i){await this.fetch(`/admin/config/${n}`,{method:"PUT",body:JSON.stringify({config:a,description:i})})}async patchConfig(n,a,i){await this.fetch(`/admin/config/${n}`,{method:"PATCH",body:JSON.stringify({updates:a,description:i})})}async batchUpdate(n){await this.fetch("/admin/config/batch",{method:"POST",body:JSON.stringify({updates:n})})}async validateConfig(n,a){return this.fetch("/admin/config/validate",{method:"POST",body:JSON.stringify({category:n,config:a})})}async getHistory(n,a=50){const i=new URLSearchParams({limit:a.toString()});return n&&i.set("category",n),this.fetch(`/admin/config/history?${i}`)}}const O={server:{label:"Server",secrets:[],icon:"🖥️",fields:{admin_metrics_api_key:{hidden:!0},cors_allowed_origins:{hidden:!0}}},security:{label:"Security",description:"Configure CORS, rate limiting, and other security settings",secrets:[],icon:"🔒",fields:{cors_allowed_origins:{description:'List of allowed origins for CORS requests. Use ["*"] to allow all origins (not recommended for production).'}}},metrics:{label:"Metrics",description:"Configure metrics collection and API access",secrets:["admin_metrics_api_key"],icon:"📊",fields:{admin_metrics_api_key:{description:"API key for accessing the admin metrics endpoint. Keep this secret."}}},logging:{label:"Logging",secrets:[],icon:"📝",fields:{level:{type:"dropdown",options:["trace","debug","info","warn","error"]},format:{hidden:!0},environment:{hidden:!0}}},stripe:{label:"Stripe",secrets:["secret_key","webhook_secret"],icon:"💳",fields:{enabled:{hidden:!0},secret_key:{description:"Stripe Dashboard → Developers → API keys → Secret key. Use the test key (sk_test_...) for testing, or the live key (sk_live_...) for production."},publishable_key:{description:"Stripe Dashboard → Developers → API keys → Publishable key. Starts with pk_test_... or pk_live_..."},mode:{type:"dropdown",options:["test","live"],description:'Use "test" mode with test API keys during development, then switch to "live" with live keys for real payments.'},webhook_url:{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."},webhook_secret:{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_...`},tax_rate_id:{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.`},success_url:{hidden:!0},cancel_url:{hidden:!0}}},x402:{label:"X402 (Crypto)",secrets:["server_wallets"],icon:"⚡",fields:{enabled:{hidden:!0},payment_address:{type:"solana_address",description:"The Solana wallet address where payments are received. This is where customer funds are sent."},token_mint:{type:"token_mint",description:"The SPL token used for payments. Most commonly USDC."},token_decimals:{type:"number",description:"Number of decimal places for the token (e.g., USDC has 6 decimals).",hidden:!0},custom_token_symbol:{description:'Display symbol for your custom token (e.g., "MYTOKEN").',hidden:!0},custom_token_icon:{description:"URL to your token's icon image.",hidden:!0},rpc_url:{description:"Custom Solana RPC endpoint. Leave empty to use the default public RPC."},gasless_enabled:{type:"toggle",description:"When enabled, your server pays transaction fees so customers don't need SOL."},server_wallets:{type:"secret_array",description:"Server keypair(s) used to sign and pay for transactions. Required for gasless payments.",showWhen:"gasless_enabled"},rounding_mode:{type:"dropdown",options:["nearest","up","down"],description:"How to round fractional token amounts: nearest (default), up (always round up), or down (always round down)."},network:{hidden:!0},ws_url:{hidden:!0},skip_preflight:{hidden:!0},commitment:{hidden:!0},compute_unit_limit:{hidden:!0},compute_unit_price:{hidden:!0}}},paywall:{label:"Paywall",secrets:[],icon:"🚪",fields:{product_cache_ttl:{type:"number",unit:"seconds"}}},coupons:{label:"Coupons",secrets:[],icon:"🎟️",fields:{cache_ttl:{type:"number",unit:"seconds"}}},subscriptions:{label:"Subscriptions",secrets:[],icon:"🔄",fields:{grace_period_hours:{type:"number",unit:"hours"}}},callbacks:{label:"Callbacks",secrets:["hmac_secret"],icon:"🔔"},email:{label:"Email",description:"Email receipts for customers after purchase",secrets:["smtp_password"],icon:"📧",fields:{enabled:{hidden:!0},provider:{type:"dropdown",options:["sendgrid","mailgun","postmark","ses","resend","custom"],description:"Email service provider."},smtp_host:{description:"SMTP server hostname.",showWhen:"provider"},smtp_port:{type:"number",description:"SMTP server port (typically 587 for TLS).",showWhen:"provider"},smtp_user:{description:"SMTP authentication username or API key name.",showWhen:"provider"},smtp_password:{description:"SMTP password or API key.",showWhen:"provider"},from_address:{description:"Sender email address (e.g., orders@yourstore.com)."},from_name:{description:'Sender display name (e.g., "Your Store").'}}},webhook:{label:"Webhook",description:"HTTP notifications when purchases occur",secrets:["secret"],icon:"🔔",fields:{enabled:{hidden:!0},url:{description:"URL to receive POST notifications (e.g., https://api.yoursite.com/webhooks/orders)."},secret:{description:"Shared secret for HMAC-SHA256 signature verification."},retry_attempts:{type:"number",description:"Number of retry attempts on failure (default: 3)."}}},messaging:{label:"Messaging",description:"Email and webhook notifications for purchases",secrets:["smtp_password","webhook_secret"],icon:"📬",fields:{email_enabled:{type:"boolean",description:"Send order confirmation emails to customers."},email_provider:{description:"Email service provider (mailgun, sendgrid, postmark, ses, resend, custom).",showWhen:"email_enabled"},smtp_host:{description:"SMTP server hostname.",showWhen:"email_enabled"},smtp_port:{type:"number",description:"SMTP server port (typically 587 for TLS).",showWhen:"email_enabled"},smtp_username:{description:"SMTP authentication username or API key.",showWhen:"email_enabled"},smtp_password:{description:"SMTP password or API key.",showWhen:"email_enabled"},from_email:{description:"Sender email address (e.g., orders@yourstore.com).",showWhen:"email_enabled"},from_name:{description:'Sender display name (e.g., "Your Store").',showWhen:"email_enabled"},webhook_enabled:{type:"boolean",description:"Send webhook notifications when purchases complete."},webhook_url:{description:"URL to receive POST notifications.",showWhen:"webhook_enabled"},webhook_secret:{description:"Shared secret for HMAC-SHA256 signature verification.",showWhen:"webhook_enabled"},webhook_timeout:{type:"number",description:"Request timeout in seconds (default: 30).",showWhen:"webhook_enabled"}}},monitoring:{label:"Monitoring",secrets:[],icon:"📊",fields:{check_interval:{type:"number",unit:"seconds"},low_balance_threshold:{type:"number",unit:"SOL"}}},rate_limit:{label:"Rate Limiting",secrets:[],icon:"⏱️"},circuit_breaker:{label:"Circuit Breaker",secrets:[],icon:"🔌"},admin:{label:"Admin Keys",secrets:[],icon:"👤"},api_keys:{label:"API Keys",secrets:[],icon:"🔐"},cedros_login:{label:"Cedros Login",secrets:["api_key"],icon:"🔑",fields:{enabled:{hidden:!0},credits_enabled:{hidden:!0},base_url:{hidden:!0},timeout:{hidden:!0},jwt_issuer:{hidden:!0},jwt_audience:{hidden:!0}}},shop:{label:"Storefront",description:"Product pages & display settings",secrets:[],icon:"🏪",fields:{enabled:{hidden:!0},"relatedProducts.mode":{type:"dropdown",options:["most_recent","by_category","manual","ai"]},"relatedProducts.maxItems":{type:"number"}}}};function F(b,n){return O[b]?.secrets.includes(n)??!1}const D="[REDACTED]",Y=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function W(b){return!b||b.trim()===""?{valid:!0}:Y.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function X({label:b,value:n,onChange:a,decimals:i,onDecimalsChange:S,disabled:d=!1,description:c,customSymbol:l="",customIcon:h="",onCustomSymbolChange:p,onCustomIconChange:y}){const[x,N]=m.useState(!1),f=Object.entries(P.STABLECOIN_METADATA),_=!!P.STABLECOIN_METADATA[n],k=x||!!n&&!_,j=t=>{if(t==="custom")N(!0),_&&a("");else{N(!1),a(t);const s=P.STABLECOIN_METADATA[t];s&&S&&S(s.decimals),p&&p(""),y&&y("")}};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:b}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:[f.map(([t,s])=>e.jsxs("button",{type:"button",onClick:()=>j(t),disabled:d,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:n===t?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:n===t?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:d?"not-allowed":"pointer",opacity:d?.5:1,fontWeight:n===t?600:400},children:[e.jsx("img",{src:s.icon,alt:s.symbol,style:{width:20,height:20,borderRadius:"50%"},onError:r=>{r.target.style.display="none"}}),e.jsx("span",{children:s.symbol})]},t)),e.jsxs("button",{type:"button",onClick:()=>j("custom"),disabled:d,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:k?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:k?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:d?"not-allowed":"pointer",opacity:d?.5:1,fontWeight:k?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),k&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Mint Address"}),(()=>{const t=W(n);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${t.valid?"":"cedros-admin__input--error"}`,value:n,onChange:s=>a(s.target.value),placeholder:"e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",disabled:d,style:{fontFamily:"monospace",fontSize:"0.875rem",borderColor:t.valid?void 0:"var(--cedros-admin-error, #dc2626)"}}),!t.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:t.error})]})})()]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:l,onChange:t=>p?.(t.target.value),placeholder:"e.g., MYTOKEN",disabled:d,style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Icon URL"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:h,onChange:t=>y?.(t.target.value),placeholder:"https://example.com/token-logo.png",disabled:d,style:{flex:1}}),h&&e.jsx("img",{src:h,alt:"Token icon preview",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--cedros-admin-border, #e5e7eb)",objectFit:"cover"},onError:t=>{t.target.style.display="none"}})]}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Shown to customers during checkout"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i??6,onChange:t=>S?.(parseInt(t.target.value,10)||0),min:0,max:18,disabled:d,style:{width:"100px"}}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Most SPL tokens use 6 decimals (like USDC)"})]})]}),n&&_&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",fontFamily:"monospace",wordBreak:"break-all"},children:n}),c&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:c})]})]})}function Z({label:b,value:n,onChange:a,disabled:i=!1,description:S}){const[d,c]=m.useState(new Set),[l,h]=m.useState(null),[p,y]=m.useState(""),x=Array.isArray(n)?n:[],N=t=>{c(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},f=()=>{a([...x,""]),h(x.length),y("")},E=(t,s)=>{const r=[...x];r[t]=s,a(r)},_=t=>{const s=x.filter((r,g)=>g!==t);a(s),c(r=>{const g=new Set;return r.forEach(v=>{v<t?g.add(v):v>t&&g.add(v-1)}),g})},T=t=>{h(t),y(x[t]||"")},k=()=>{l!==null&&(E(l,p),h(null),y(""))},j=()=>{l!==null&&x[l]===""&&_(l),h(null),y("")};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",style:{marginBottom:0},children:b}),e.jsxs("button",{type:"button",onClick:f,disabled:i,style:{display:"flex",alignItems:"center",gap:"0.25rem",padding:"0.25rem 0.5rem",fontSize:"0.75rem",border:"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.375rem",background:"var(--cedros-admin-bg, #fff)",cursor:i?"not-allowed":"pointer",opacity:i?.5:1},children:[w.Icons.plus,"Add"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[x.length===0&&e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.875rem",border:"1px dashed var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem"},children:'No items. Click "Add" to create one.'}),x.map((t,s)=>{const r=d.has(s),g=l===s,v=t===D;return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.375rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:p,onChange:o=>y(o.target.value),placeholder:"Enter wallet keypair...",autoFocus:!0,style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem"},onKeyDown:o=>{o.key==="Enter"&&k(),o.key==="Escape"&&j()}}),e.jsx("button",{type:"button",onClick:k,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:w.Icons.check}),e.jsx("button",{type:"button",onClick:j,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:w.Icons.close})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r&&!v?t:v?"[REDACTED]":"••••••••••••••••••••"}),e.jsx("button",{type:"button",onClick:()=>N(s),disabled:i||v,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:i||v?"not-allowed":"pointer",opacity:i||v?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:r?"Hide":"Show",children:r?w.Icons.eyeOff:w.Icons.eye}),e.jsx("button",{type:"button",onClick:()=>T(s),disabled:i,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:i?"not-allowed":"pointer",opacity:i?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:"Edit",children:w.Icons.settings}),e.jsx("button",{type:"button",onClick:()=>_(s),disabled:i,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:i?"not-allowed":"pointer",opacity:i?.5:1,color:"var(--cedros-admin-error, #ef4444)"},title:"Delete",children:w.Icons.trash})]})},s)})]}),S&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:S})]})}function L(b,n,a){const i=F(b,n),S=n.replace(/_/g," ").replace(/\b\w/g,h=>h.toUpperCase()),c=O[b]?.fields?.[n],l={isSecret:i,label:S,description:c?.description,hidden:c?.hidden,showWhen:c?.showWhen};return c?.type==="dropdown"&&c.options?{...l,type:"dropdown",options:c.options}:c?.type==="token_mint"?{...l,type:"token_mint"}:c?.type==="toggle"?{...l,type:"toggle"}:c?.type==="secret_array"?{...l,type:"secret_array",isSecret:!0}:c?.type==="solana_address"?{...l,type:"solana_address"}:c?.type==="number"?{...l,type:"number",unit:c.unit}:typeof a=="boolean"?{...l,type:"boolean"}:typeof a=="number"?{...l,type:"number",unit:c?.unit}:Array.isArray(a)?{...l,type:"array"}:typeof a=="object"&&a!==null?{...l,type:"object"}:{...l,type:"string"}}function Q({category:b,config:n,originalConfig:a,isLoading:i=!1,onSave:S}){const[d,c]=m.useState(n),[l,h]=m.useState(new Set);m.useEffect(()=>{c(n)},[n]);const p=m.useMemo(()=>{const t={...d};for(const s of Object.keys(t))if(F(b,s)){const r=a[s],g=t[s];(g===D||g===r)&&(t[s]=D)}return t},[d,a,b]),y=m.useMemo(()=>{const t=d.token_mint;return typeof t!="string"||!t?!1:!W(t).valid},[d]),{status:x,error:N}=J.useAutosave({data:p,onSave:S,debounceMs:1500,enabled:!y}),f=m.useCallback((t,s)=>{c(r=>({...r,[t]:s}))},[]),E=m.useCallback(t=>{h(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),_=t=>t?e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:t}):null,T=(t,s)=>{const r=L(b,t,a[t]??s);if(r.type==="dropdown"&&r.options)return e.jsx(w.FormDropdown,{value:s,onChange:o=>f(t,o),options:r.options.map(o=>({value:o,label:o})),label:r.label,description:r.description,disabled:i});if(r.type==="token_mint")return e.jsx(X,{label:r.label,value:s,onChange:o=>f(t,o),decimals:d.token_decimals??6,onDecimalsChange:o=>f("token_decimals",o),disabled:i,description:r.description,customSymbol:d.custom_token_symbol||"",customIcon:d.custom_token_icon||"",onCustomSymbolChange:o=>f("custom_token_symbol",o),onCustomIconChange:o=>f("custom_token_icon",o)});if(r.type==="toggle")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>f(t,!s),disabled:i,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:i?"not-allowed":"pointer",position:"relative",transition:"background-color 0.2s",opacity:i?.5:1,flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:2,left:s?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{className:"cedros-admin__field-label",style:{marginBottom:0},children:r.label})]}),_(r.description)]});if(r.type==="solana_address"){const o=s||"",C=W(o);return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${C.valid?"":"cedros-admin__input--error"}`,value:o,onChange:R=>f(t,R.target.value),disabled:i,placeholder:"e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",style:{width:"100%",fontFamily:"monospace",fontSize:"0.875rem",borderColor:C.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:o&&C.valid?"2rem":void 0}}),o&&C.valid&&e.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:"var(--cedros-admin-success, #16a34a)",fontSize:"1rem"},title:"Valid Solana address",children:"✓"})]}),!C.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:C.error}),_(r.description)]})}if(r.type==="boolean")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:o=>f(t,o.target.checked),disabled:i}),r.label]}),_(r.description)]});if(r.type==="number")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.unit&&e.jsxs("span",{className:"cedros-admin__field-unit",children:[" (",r.unit,")"]})]}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s,onChange:o=>f(t,parseFloat(o.target.value)||0),disabled:i}),_(r.description)]});if(r.type==="secret_array")return e.jsx(Z,{label:r.label,value:s,onChange:o=>f(t,o),disabled:i,description:r.description});if(r.type==="array"){const o=s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea",value:o.join(`
|
|
2
|
-
`),onChange:C=>f(t,C.target.value.split(`
|
|
3
|
-
`).filter(Boolean)),placeholder:"One item per line",rows:3,disabled:i}),_(r.description)]})}if(r.type==="object")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea cedros-admin__textarea--mono",value:JSON.stringify(s,null,2),onChange:o=>{try{f(t,JSON.parse(o.target.value))}catch{}},rows:5,disabled:i}),_(r.description)]});const g=l.has(t),v=r.isSecret&&!g&&s===D?D:s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.isSecret&&e.jsx("span",{className:"cedros-admin__field-secret",children:" (secret)"})]}),e.jsxs("div",{className:"cedros-admin__input-group",children:[e.jsx("input",{type:r.isSecret&&!g?"password":"text",className:"cedros-admin__input",value:v,onChange:o=>f(t,o.target.value),disabled:i,placeholder:r.isSecret?"••••••••":""}),r.isSecret&&e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>E(t),style:{padding:"0.5rem",minWidth:"auto"},title:g?"Hide":"Show",children:g?w.Icons.eyeOff:w.Icons.eye})]}),_(r.description)]})},k=Object.keys(d),j=t=>{const s=L(b,t,a[t]??d[t]);if(s.hidden||s.showWhen&&!d[s.showWhen])return!1;if(t==="token_decimals"){const r=d.token_mint;if(r&&P.STABLECOIN_METADATA[r])return!1}return!0};return e.jsxs("div",{className:"cedros-admin__config-editor",children:[e.jsx("div",{className:"cedros-admin__config-fields",children:k.filter(j).map(t=>e.jsx("div",{className:"cedros-admin__config-field",children:T(t,d[t])},t))}),e.jsx("div",{className:"cedros-admin__config-actions",children:e.jsx("div",{className:"cedros-admin__autosave-status",children:e.jsx($.AutosaveIndicator,{status:x,error:N})})})]})}function ee({serverUrl:b,apiKey:n,authManager:a,category:i,title:S,description:d,enabledField:c="enabled",showEnabledToggle:l=!1}){const h=m.useMemo(()=>new G(b,void 0,a),[b,a]),[p,y]=m.useState(null),[x,N]=m.useState([]),[f,E]=m.useState(!1),[_,T]=m.useState(!0),[k,j]=m.useState(null),[t,s]=m.useState(null),[r,g]=m.useState(!1),v=O[i]||{label:i,icon:"⚙️"},o=S||v.label,C=d||v.description,R=m.useCallback(async()=>{T(!0),j(null);try{const u=await h.getConfig(i,!0);y(u)}catch{y(null),j("Failed to load settings")}finally{T(!1)}},[h,i]);m.useEffect(()=>{R()},[R]);const z=m.useCallback(async()=>{try{const u=await h.getHistory(i,20);N(u.history)}catch{N([])}},[h,i]);m.useEffect(()=>{f&&z()},[f,z]);const q=m.useCallback(async u=>{await h.updateConfig(i,u,"Updated via admin dashboard")},[h,i]),B=m.useCallback(async u=>h.validateConfig(i,u),[h,i]),[M,U]=m.useState(!1),K=m.useCallback(async()=>{if(!p||M)return;const u=!!p.config[c],I=!u,V={...p.config,[c]:I};U(!0),y({...p,config:V});try{await h.updateConfig(i,V,`${I?"Enabled":"Disabled"} via admin dashboard`)}catch(H){y({...p,config:{...p.config,[c]:u}}),j(H instanceof Error?H.message:"Failed to save enabled state")}finally{U(!1)}},[p,h,i,c,M]),A=!!p?.config[c];return _&&!p?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[w.Icons.loading," Loading ",o," settings..."]})}):e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx(w.ErrorBanner,{message:k,onRetry:R}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[e.jsx("span",{style:{marginRight:"0.5rem"},children:v.icon}),o]}),C&&e.jsx("p",{className:"cedros-admin__text-muted",style:{marginTop:"0.25rem"},children:C})]}),l&&p&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:A?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:A?"Enabled":"Disabled"}),e.jsx("button",{type:"button",role:"switch","aria-checked":A,onClick:K,disabled:M,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:A?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:M?"wait":"pointer",position:"relative",transition:"background-color 0.2s",flexShrink:0,opacity:M?.6:1},children:e.jsx("span",{style:{position:"absolute",top:2,left:A?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})]}),p&&e.jsxs("div",{className:"cedros-admin__settings-editor",style:{marginTop:"1rem",opacity:l&&!A?.6:1,pointerEvents:l&&!A?"none":"auto"},children:[l&&!A&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)",pointerEvents:"auto"},children:"This payment method is disabled. Enable it using the toggle above to accept payments."}),e.jsx(Q,{category:p.category,config:p.config,originalConfig:p.config,onSave:q,onValidate:B})]}),f&&e.jsxs("div",{className:"cedros-admin__settings-history",style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{marginBottom:"0.75rem",fontWeight:600},children:"Change History"}),x.length===0?e.jsx("p",{className:"cedros-admin__text-muted",children:"No history entries found."}):e.jsx("div",{className:"cedros-admin__settings-timeline",children:x.map(u=>e.jsxs("div",{className:"cedros-admin__settings-timeline-item",children:[e.jsx("div",{className:"cedros-admin__settings-timeline-dot"}),e.jsxs("div",{className:"cedros-admin__settings-timeline-content",children:[e.jsxs("div",{className:"cedros-admin__settings-timeline-header",children:[e.jsx("code",{children:u.configKey}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${u.action.toLowerCase()}`,children:u.action})]}),e.jsxs("div",{className:"cedros-admin__settings-timeline-meta",children:[w.formatDateTime(u.changedAt)," by ",u.changedBy]})]})]},u.id))})]}),t&&e.jsx("div",{style:{marginTop:"1rem",padding:"0.75rem 1rem",borderRadius:"0.375rem",backgroundColor:t.valid?"var(--cedros-admin-success-bg, #dcfce7)":"var(--cedros-admin-error-bg, #fef2f2)",border:`1px solid ${t.valid?"var(--cedros-admin-success-border, #86efac)":"var(--cedros-admin-error-border, #fecaca)"}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:t.valid?"var(--cedros-admin-success, #16a34a)":"var(--cedros-admin-error, #dc2626)",marginBottom:t.errors.length>0||t.warnings.length>0?"0.5rem":0},children:t.valid?"✓ Configuration is valid":"✗ Validation failed"}),t.errors.length>0&&e.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.875rem"},children:t.errors.map((u,I)=>e.jsx("li",{children:u},I))}),t.warnings.length>0&&e.jsx("ul",{style:{margin:t.errors.length>0?"0.5rem 0 0":0,paddingLeft:"1.25rem",color:"var(--cedros-admin-warning, #ca8a04)",fontSize:"0.875rem"},children:t.warnings.map((u,I)=>e.jsx("li",{children:u},I))})]}),e.jsx("button",{type:"button",onClick:()=>s(null),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"1.25rem",lineHeight:1},title:"Dismiss",children:"×"})]})}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>E(!f),children:f?"Hide History":"History"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r||!p,onClick:async()=>{if(p){g(!0),s(null);try{const u=await B(p.config);s(u)}catch(u){s({valid:!1,errors:[u instanceof Error?u.message:"Validation failed"],warnings:[]})}finally{g(!1)}}},children:r?"Validating...":"Validate"})]})]})}exports.SingleCategorySettings=ee;
|