@cedros/pay-react 1.1.24 → 1.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
- package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
- package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
- package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
- package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
- package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
- package/dist/ComplianceSection-DP2a9-S0.js +1 -0
- package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/CustomersSection-CBwy_waO.js +1 -0
- package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
- package/dist/DisputesSection-BLjIk60n.js +1 -0
- package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
- package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
- package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
- package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
- package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
- package/dist/InventorySection-zV6lTmue.js +1 -0
- package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
- package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
- package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
- package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
- package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
- package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
- package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
- package/dist/ReturnsSection-D_pJVxuG.js +1 -0
- package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
- package/dist/SettingsSection-vdYFSNxB.js +1 -0
- package/dist/ShippingSection-1DRSTu49.js +1 -0
- package/dist/ShippingSection-BOgto6_9.mjs +434 -0
- package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
- package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
- package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
- package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
- package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
- package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
- package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
- package/dist/TaxSection-Dt1DnM51.js +1 -0
- package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
- package/dist/Token22Section-DY3mUwTY.js +1 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
- package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/index-C0g-JxJk.js +84 -0
- package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
- package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +40 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
- package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/CustomersSection.d.ts +3 -0
- package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
- package/dist/src/components/admin/DisputesSection.d.ts +3 -0
- package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/ImagesSection.d.ts +3 -0
- package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
- package/dist/src/components/admin/InventorySection.d.ts +3 -0
- package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
- package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
- package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ShippingSection.d.ts +3 -0
- package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
- package/dist/src/components/admin/TaxSection.d.ts +3 -0
- package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
- package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
- package/dist/src/components/admin/complianceTypes.d.ts +74 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +12 -2
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +1 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-cKF0tLnS.js +0 -1
- package/dist/Token22Section-DUUl59dZ.js +0 -1
- package/dist/Token22Section-HygkDNtL.mjs +0 -1685
- package/dist/index-OaWkrl0G.js +0 -84
- package/dist/styles-21F1-oqx.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ke=Object.create;var xe=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Re=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of Te(i))!Be.call(t,a)&&a!==n&&xe(t,a,{get:()=>i[a],enumerable:!(s=Ae(i,a))||s.enumerable});return t};var me=(t,i,n)=>(n=t!=null?ke(Ne(t)):{},Re(i||!t||!t.__esModule?xe(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),fe=require("./index-C0g-JxJk.js"),ee=require("./configApi-DkduMQg1.js"),Ce=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"address",label:"Address"},{value:"textarea",label:"Long Text"},{value:"dropdown",label:"Dropdown"},{value:"file_upload",label:"File Upload"}],be={fields:[],requiresApproval:!0},U={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},G={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Q={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function ze(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function je({field:t,onSave:i,onCancel:n}){const[s,a]=r.useState(t),[c,y]=r.useState(""),p=o=>a(d=>({...d,...o})),b=()=>{const o=c.trim();o&&(p({options:[...s.options,o]}),y(""))};return e.jsxs("div",{style:{padding:"0.75rem",border:"1px solid rgba(37,99,235,0.3)",borderRadius:6,background:"#eff6ff",marginTop:6},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.6rem",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Label *"}),e.jsx("input",{style:U,value:s.label,onChange:o=>p({label:o.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Field Type"}),e.jsx("select",{style:U,value:s.fieldType,onChange:o=>p({fieldType:o.target.value,options:[]}),children:Ce.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"0.6rem",alignItems:"end",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Placeholder"}),e.jsx("input",{style:U,value:s.placeholder??"",onChange:o=>p({placeholder:o.target.value}),placeholder:"Optional hint text"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",paddingBottom:2},children:[e.jsx("input",{type:"checkbox",checked:s.required,onChange:o=>p({required:o.target.checked})})," Required"]})]}),s.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:G,children:"Options"}),s.options.map((o,d)=>e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("span",{style:{flex:1,fontSize:"0.85rem",padding:"0.25rem 0.5rem",background:"white",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4},children:o}),e.jsx("button",{type:"button",onClick:()=>p({options:s.options.filter((u,v)=>v!==d)}),style:{padding:"0.2rem 0.5rem",borderRadius:4,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"x"})]},d)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...U,flex:1},value:c,onChange:o=>y(o.target.value),onKeyDown:o=>o.key==="Enter"&&(o.preventDefault(),b()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:b,style:Q,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>i(s),disabled:!s.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:s.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:s.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Q,children:"Cancel"})]})]})}function Ie({fields:t,instructions:i}){const n={...U,fontSize:"0.85rem",background:"white",opacity:.6};return e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"rgba(0,0,0,0.02)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"rgba(0,0,0,0.4)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"0.75rem"},children:"Preview — Redeemer View"}),i&&e.jsx("div",{style:{padding:"0.6rem 0.75rem",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,fontSize:"0.85rem",marginBottom:"0.75rem",color:"#92400e"},children:i}),t.length===0&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic"},children:"No fields added yet."}),t.map(s=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[s.label||"Unlabelled field",s.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),s.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:s.placeholder??"",style:{...n,resize:"none"}}),s.fieldType==="file_upload"&&e.jsx("div",{style:{padding:"0.5rem",border:"1px dashed rgba(0,0,0,0.25)",borderRadius:4,fontSize:"0.8rem",color:"rgba(0,0,0,0.4)",textAlign:"center"},children:"File upload"}),s.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:s.placeholder||"Select..."}),s.options.map((a,c)=>e.jsx("option",{children:a},c))]}),!["textarea","file_upload","dropdown"].includes(s.fieldType)&&e.jsx("input",{disabled:!0,type:s.fieldType==="email"?"email":s.fieldType==="phone"?"tel":"text",placeholder:s.placeholder??"",style:n})]},s.id))]})}function De({value:t,onChange:i}){const n=t!==null,s=t??be,[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!1),d=h=>i({...s,...h}),u=()=>{c(null),p(null)},v=h=>{i(h?{...be}:null),u()},x=()=>{const h=ze();p(h),c("new")},f=h=>{p({...h}),c(h.id)},j=h=>{d({fields:a==="new"?[...s.fields,h]:s.fields.map(S=>S.id===h.id?h:S)}),u()},k=h=>{a===h&&u(),d({fields:s.fields.filter(S=>S.id!==h)})};return e.jsxs("div",{children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",marginBottom:n?"1rem":4,fontSize:"0.9rem",fontWeight:500},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:h=>v(h.target.checked)}),"Enable Redemption Form"]}),!n&&e.jsx("div",{style:{fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:"No redemption form — token holders cannot request physical redemption."}),n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:s.instructions??"",onChange:h=>d({instructions:h.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...U,resize:"vertical"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"1rem",alignItems:"center",padding:"0.6rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"rgba(0,0,0,0.02)"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",whiteSpace:"nowrap"},children:[e.jsx("input",{type:"checkbox",checked:s.requiresApproval,onChange:h=>d({requiresApproval:h.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:s.estimatedProcessingDays??"",onChange:h=>d({estimatedProcessingDays:h.target.value?Number(h.target.value):void 0}),placeholder:"e.g., 5",style:{...U,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",s.fields.length,")"]}),s.fields.length===0&&a!=="new"&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic",marginBottom:"0.5rem"},children:"No fields yet. Add fields below."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem"},children:[s.fields.map(h=>e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"0.5rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"white",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.9rem"},children:h.label||e.jsx("em",{style:{color:"rgba(0,0,0,0.35)"},children:"Unlabelled"})}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dbeafe",color:"#1d4ed8",fontSize:"0.75rem"},children:Ce.find(S=>S.value===h.fieldType)?.label??h.fieldType}),h.required&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#fef3c7",color:"#92400e",fontSize:"0.75rem"},children:"required"})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",onClick:()=>f(h),style:{...Q,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(h.id),style:{padding:"0.25rem 0.6rem",borderRadius:4,border:"1px solid rgba(220,38,38,0.3)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"Delete"})]})]}),a===h.id&&y&&e.jsx(je,{field:y,onSave:j,onCancel:u})]},h.id)),a==="new"&&y&&e.jsx(je,{field:y,onSave:j,onCancel:u})]}),a===null&&e.jsx("button",{type:"button",onClick:x,style:{...Q,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>o(h=>!h),style:{...Q,background:b?"rgba(0,0,0,0.05)":"white"},children:b?"Hide Preview":"Show Preview"}),b&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(Ie,{fields:s.fields,instructions:s.instructions})})]})]})]})}const Pe=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Me=t=>t==="securities"||t==="commodities";function Fe({c:t,onDeployPool:i,onEdit:n,onDelete:s}){const a=t.tokenizationConfig,c=Me(a.assetClass);return e.jsxs("div",{style:{padding:"0.75rem 1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"white"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{style:{marginLeft:8,fontSize:"0.8rem",padding:"2px 8px",borderRadius:10,background:c?"#dbeafe":"#fef3c7",color:c?"#1d4ed8":"#92400e"},children:a.assetClass}),a.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:a.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[a.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),c&&a.mintAddress&&(a.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",a.liquidityPoolAddress.slice(0,4),"...",a.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:i,style:{padding:0,border:"none",background:"none",color:"#2563eb",cursor:"pointer",fontSize:"0.8rem",textDecoration:"underline"},children:"Deploy Pool"}))]})]}),t.description&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.5)",marginTop:4},children:t.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6},children:[e.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:[e.jsxs("span",{children:["Fee: ",a.transferFeeBps," bps"]}),a.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",a.treasuryAddress.slice(0,8),"..."]}),a.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[a.allowedJurisdictions.length," jurisdiction",a.allowedJurisdictions.length!==1?"s":"",": ",a.allowedJurisdictions.join(", ")]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#2563eb"},children:"Edit"}),s&&e.jsx("button",{type:"button",onClick:s,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#dc2626"},children:"Delete"})]})]})]})}const pe={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Ee({serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:s}){const[a,c]=r.useState([]),[y,p]=r.useState(!0),[b,o]=r.useState(null),[d,u]=r.useState(!1),[v,x]=r.useState(!1),[f,j]=r.useState(pe),[k,h]=r.useState(null),S=r.useCallback(async(g,m)=>{if(n?.isAuthenticated())return n.fetchWithAuth(g,m);const N={"Content-Type":"application/json"};i&&(N["X-API-Key"]=i);const C=await fetch(`${t}${g}`,{...m,headers:{...N,...m?.headers}});if(!C.ok){const z=await C.text().catch(()=>`HTTP ${C.status}`);throw new Error(z)}return C.json()},[t,i,n]),T=r.useCallback(async()=>{try{p(!0),o(null);const g=await S("/admin/collections");c((g.collections||[]).filter(m=>m.tokenizationConfig))}catch(g){o(g instanceof Error?g.message:"Failed to load asset classes")}finally{p(!1)}},[S]);r.useEffect(()=>{T()},[T]);const l=()=>({name:f.name.trim(),description:f.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:f.assetClass,tokenSymbol:f.tokenSymbol||void 0,tokenDecimals:f.tokenDecimals,transferFeeBps:f.transferFeeBps,maxTransferFee:f.maxTransferFee,treasuryAddress:f.treasuryAddress||void 0,regulatoryNotice:f.regulatoryNotice||void 0,allowedJurisdictions:f.jurisdictions?f.jurisdictions.split(",").map(g=>g.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:f.redemptionConfig||void 0}}),w=async()=>{if(f.name.trim()){x(!0),o(null);try{k?await S(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(l())}):await S("/admin/collections",{method:"POST",body:JSON.stringify(l())}),j(pe),u(!1),h(null),await T()}catch(g){o(g instanceof Error?g.message:`Failed to ${k?"update":"create"} asset class`)}finally{x(!1)}}},_=g=>{const m=g.tokenizationConfig;j({name:g.name,description:g.description??"",assetClass:m.assetClass,tokenSymbol:m.tokenSymbol??"",tokenDecimals:m.tokenDecimals,transferFeeBps:m.transferFeeBps,maxTransferFee:m.maxTransferFee,treasuryAddress:m.treasuryAddress??"",regulatoryNotice:m.regulatoryNotice??"",jurisdictions:m.allowedJurisdictions.join(", "),redemptionConfig:m.redemptionConfig??null}),h(g.id),u(!0)},A=async g=>{if(window.confirm(`Delete asset class "${g.name}"? This cannot be undone.`)){o(null);try{await S(`/admin/collections/${encodeURIComponent(g.id)}`,{method:"DELETE"}),await T()}catch(m){o(m instanceof Error?m.message:"Failed to delete asset class")}}};return y?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[b&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:b}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",a.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{u(!d),d&&(h(null),j(pe))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:d?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:d?"Cancel":"+ New Asset Class"})]}),d&&e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,marginBottom:"1rem",background:"rgba(0,0,0,0.02)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Name *"}),e.jsx("input",{type:"text",value:f.name,onChange:g=>j(m=>({...m,name:g.target.value})),placeholder:"e.g., Gold Tokens",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Asset Class *"}),e.jsx("select",{value:f.assetClass,onChange:g=>j(m=>({...m,assetClass:g.target.value})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"},children:Pe.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Description"}),e.jsx("input",{type:"text",value:f.description,onChange:g=>j(m=>({...m,description:g.target.value})),placeholder:"Brief description of this asset class",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Token Symbol"}),e.jsx("input",{type:"text",value:f.tokenSymbol,onChange:g=>j(m=>({...m,tokenSymbol:g.target.value})),placeholder:"e.g., GOLD",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Transfer Fee (bps)"}),e.jsx("input",{type:"number",value:f.transferFeeBps,onChange:g=>j(m=>({...m,transferFeeBps:Number(g.target.value)})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Treasury Address"}),e.jsx("input",{type:"text",value:f.treasuryAddress,onChange:g=>j(m=>({...m,treasuryAddress:g.target.value})),placeholder:"Solana address",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Allowed Jurisdictions"}),e.jsx("input",{type:"text",value:f.jurisdictions,onChange:g=>j(m=>({...m,jurisdictions:g.target.value})),placeholder:"US, CA, GB (comma-separated, leave empty for all)",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Regulatory Notice"}),e.jsx("textarea",{value:f.regulatoryNotice,onChange:g=>j(m=>({...m,regulatoryNotice:g.target.value})),placeholder:"Shown to buyers before purchase",rows:2,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:600,marginBottom:8},children:"Redemption Form"}),e.jsx(De,{value:f.redemptionConfig,onChange:g=>j(m=>({...m,redemptionConfig:g}))})]}),e.jsx("button",{type:"button",onClick:w,disabled:v||!f.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:v?"wait":"pointer",fontSize:"0.9rem",opacity:v?.6:1},children:v?"Saving...":k?"Save Changes":"Create Asset Class"})]}),a.length===0?e.jsx("div",{style:{padding:"2rem",textAlign:"center",color:"rgba(0,0,0,0.4)",fontSize:"0.9rem"},children:"No asset classes configured. Create one to start tokenizing off-chain assets."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:a.map(g=>e.jsx(Fe,{c:g,onDeployPool:s,onEdit:()=>_(g),onDelete:()=>A(g)},g.id))})]})}const Le=[{value:"",label:"All statuses"},{value:"pending_info",label:"Pending Info"},{value:"info_submitted",label:"Info Submitted"},{value:"under_review",label:"Under Review"},{value:"approved",label:"Approved"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}];function $e(t){switch(t){case"pending_info":return"cedros-admin__badge cedros-admin__badge--muted";case"info_submitted":return"cedros-admin__badge cedros-admin__badge--info";case"under_review":return"cedros-admin__badge cedros-admin__badge--warning";case"approved":return"cedros-admin__badge cedros-admin__badge--success";case"completed":return"cedros-admin__badge cedros-admin__badge--success";case"rejected":return"cedros-admin__badge cedros-admin__badge--failed";default:return"cedros-admin__badge cedros-admin__badge--muted"}}function qe(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Oe(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function K(t){return t.length>12?`${t.slice(0,8)}…`:t}function _e(t){return`https://solscan.io/tx/${t}`}function We({redemption:t,onAction:i,onComplete:n,actionBusy:s}){const[a,c]=r.useState(t.adminNotes??""),y=Object.entries(t.formData??{});return e.jsx("div",{style:{padding:"1rem 1.25rem",background:"rgba(0,0,0,0.02)",borderTop:"1px solid rgba(0,0,0,0.08)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"0.8rem",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em",opacity:.6},children:"Form Data"}),y.length===0?e.jsx("div",{style:{fontSize:"0.85rem",opacity:.5},children:"No form data submitted."}):e.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:"0.85rem"},children:y.map(([p,b])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:p},`k-${p}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(b??"—")},`v-${p}`)]}))}),(t.tokenMintSignature||t.tokenBurnSignature)&&e.jsxs("div",{style:{marginTop:12,fontSize:"0.8rem"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4,opacity:.6,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Signatures"}),t.tokenMintSignature&&e.jsxs("div",{children:["Mint:"," ",e.jsx("a",{href:_e(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:_e(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenBurnSignature)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Admin Notes"}),e.jsx("textarea",{value:a,onChange:p=>c(p.target.value),rows:4,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.85rem",resize:"vertical",boxSizing:"border-box"},placeholder:"Internal notes (not shown to user)..."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:8,flexWrap:"wrap"},children:[t.status==="info_submitted"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"under_review",a),children:s?"Saving...":"Mark Under Review"}),t.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"approved",a),children:s?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"rejected",a),children:s?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>n(t.id),children:s?"Processing...":"Complete"})]})]})]})})}function Ue({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState(""),[u,v]=r.useState(null),[x,f]=r.useState(null),j=r.useCallback(async(l,w)=>{if(n?.isAuthenticated())return n.fetchWithAuth(l,w);const _={"Content-Type":"application/json"};i&&(_["X-API-Key"]=i);const A=await fetch(`${t}${l}`,{...w,headers:{..._,...w?.headers}});if(!A.ok){const g=await A.text().catch(()=>`HTTP ${A.status}`);throw new Error(g)}return A.json()},[t,i,n]),k=r.useCallback(async()=>{y(!0),b(null);try{const l=o?`?status=${encodeURIComponent(o)}&limit=50&offset=0`:"?limit=50&offset=0",w=await j(`/admin/asset-redemptions${l}`);a(w.redemptions??[])}catch(l){b(l instanceof Error?l.message:"Failed to load redemptions")}finally{y(!1)}},[j,o]);r.useEffect(()=>{k()},[k]);const h=r.useCallback(async(l,w,_)=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/status`,{method:"PATCH",body:JSON.stringify({status:w,adminNotes:_})}),v(null),await k()}catch(A){b(A instanceof Error?A.message:"Failed to update status")}finally{f(null)}},[j,k]),S=r.useCallback(async l=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/complete`,{method:"POST"}),v(null),await k()}catch(w){b(w instanceof Error?w.message:"Failed to complete redemption")}finally{f(null)}},[j,k]),T=l=>{v(w=>w===l?null:l)};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Status"}),e.jsx("select",{value:o,onChange:l=>{d(l.target.value),v(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:Le.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:c,children:c?"Loading...":"Refresh"})})]}),p&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:p}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):s.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No redemption requests found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:s.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>T(l.id),children:[e.jsx("td",{children:Oe(l.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:l.orderId,children:K(l.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:l.productId,children:K(l.productId)})}),e.jsx("td",{children:e.jsx("code",{title:l.collectionId,children:K(l.collectionId)})}),e.jsx("td",{children:l.userId?e.jsx("code",{title:l.userId,children:K(l.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:$e(l.status),children:qe(l.status)})}),e.jsx("td",{onClick:w=>w.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(l.status==="info_submitted"||l.status==="under_review"||l.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>T(l.id),children:u===l.id?"Close":"Review"}),l.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"approved",l.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"rejected",l.adminNotes??""),children:"Reject"})]}),l.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>S(l.id),children:x===l.id?"Processing...":"Complete"})]})})]},l.id),u===l.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(We,{redemption:l,onAction:h,onComplete:S,actionBusy:x===l.id})})},`${l.id}-detail`)]}))})]})})]})}const Ye={CA:{cashOutCents:1500,expirationProhibited:!0,escheatmentYears:3,notes:"Cash-out threshold increases to $15 on April 1, 2026."},CO:{cashOutCents:500,escheatmentYears:5},CT:{cashOutCents:300,escheatmentYears:3},FL:{expirationProhibited:!0,escheatmentYears:5},ME:{cashOutCents:500,escheatmentYears:3},MA:{cashOutCents:500,escheatmentYears:3,notes:"Cash-out also required when 90% of value is used."},MT:{cashOutCents:500,escheatmentYears:5},NJ:{cashOutCents:500,escheatmentYears:3},OR:{cashOutCents:500,escheatmentYears:3,notes:"May require at least one prior transaction."},RI:{cashOutCents:100,escheatmentYears:3},TX:{cashOutCents:250,escheatmentYears:3},VT:{cashOutCents:100,escheatmentYears:3},WA:{cashOutCents:500,escheatmentYears:5},PR:{cashOutCents:500,escheatmentYears:5}},ye={escheatmentYears:5},re=1e6,Ge={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"};function Ke({serverUrl:t,authManager:i}){const[n,s]=r.useState(null),[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!0),d=r.useCallback(async()=>{try{const j=(await new ee.ConfigApiClient(t,void 0,i).getConfig("gift_cards")).config??{};s(j.business_state||null),c(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),p(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{o(!1)}},[t,i]);if(r.useEffect(()=>{d()},[d]),b)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const u=n?Ye[n]??ye:null,v=n?Ge[n]??n:null;return e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:["Compliance Guidance — ",v]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Je,{reg:u,minValueCents:a}),e.jsx(Ve,{reg:u}),e.jsx(Xe,{reg:u}),e.jsx(Ze,{maxValueCents:y})]}),e.jsx(Qe,{reg:u,minValueCents:a,maxValueCents:y})]}):e.jsx(He,{})})}function He(){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:15,opacity:.7,marginBottom:"0.5rem"},children:"No business state configured."}),e.jsxs("p",{style:{fontSize:13,opacity:.5},children:["Set your ",e.jsx("strong",{children:"business_state"})," in the Gift Cards config category to see state-specific compliance guidance."]})]})}function te({title:t,children:i}){return e.jsxs("div",{style:{border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,padding:"1rem 1.25rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:14,fontWeight:600},children:t}),e.jsx("div",{style:{fontSize:13,lineHeight:1.6},children:i})]})}function Je({reg:t,minValueCents:i}){if(!t.cashOutCents)return e.jsx(te,{title:"Cash-Out Threshold",children:e.jsx("p",{style:{margin:0},children:"Your state does not have a specific cash-out threshold for gift cards. Federal law does not require cash redemption."})});const n=(t.cashOutCents/100).toFixed(2),s=i!=null&&i>t.cashOutCents;return e.jsxs(te,{title:"Cash-Out Threshold",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Your state requires cash redemption for gift cards with a remaining balance of ",e.jsxs("strong",{children:["$",n]})," or less."]}),e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Since this system uses ",e.jsx("strong",{children:"one-shot full redemption"})," (entire gift card value is converted to credits at once), cash-out is avoided by setting the minimum gift card face value above the threshold."]}),s?e.jsxs(oe,{ok:!0,children:["Min value ($",((i??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(oe,{ok:!1,children:["Set ",e.jsx("code",{children:"min_gift_card_value_cents"})," above ",t.cashOutCents," to avoid cash-out obligations"]}),t.notes&&e.jsx("p",{style:{margin:"0.5rem 0 0",opacity:.7,fontStyle:"italic"},children:t.notes})]})}function Ve({reg:t}){return e.jsx(te,{title:"Expiration Rules",children:t.expirationProhibited?e.jsxs("p",{style:{margin:0},children:["Your state ",e.jsx("strong",{children:"prohibits"})," gift card expiration. Do not set expiration dates on gift cards."]}):e.jsxs("p",{style:{margin:0},children:["Federal law (CARD Act) requires gift cards to remain valid for at least ",e.jsx("strong",{children:"5 years"})," from purchase or last reload. Your state follows the federal minimum."]})})}function Xe({reg:t}){const i=t.escheatmentYears??ye.escheatmentYears;return e.jsxs(te,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[i," years"]})," may need to be reported and remitted to the state as unclaimed property."]}),e.jsxs("p",{style:{margin:0,opacity:.7},children:["The system tracks ",e.jsx("code",{children:"last_activity_at"})," on gift card redemptions to help identify dormant balances approaching the escheatment window."]})]})}function Ze({maxValueCents:t}){const i=t??re,n=i<=re;return e.jsxs(te,{title:"Anti-Money Laundering (AML)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["FinCEN requires closed-loop prepaid cards to stay at or below ",e.jsx("strong",{children:"$10,000"})," per card. The server enforces this cap on product creation."]}),n?e.jsxs(oe,{ok:!0,children:["Max value ($",(i/100).toFixed(2),") within AML limit"]}):e.jsxs(oe,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function oe({ok:t,children:i}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:6,fontSize:13,fontWeight:500,background:t?"rgba(34,197,94,0.1)":"rgba(234,179,8,0.15)",color:t?"#16a34a":"#a16207"},children:[e.jsx("span",{children:t?"✓":"⚠"}),i]})}function Qe({reg:t,minValueCents:i,maxValueCents:n}){const a=[{label:"AML: Max card value ≤ $10,000",ok:(n??re)<=re},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:i!=null&&i>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ye.escheatmentYears}-year dormancy tracking enabled`,ok:!0}];return e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{fontSize:14,fontWeight:600,marginBottom:"0.75rem"},children:"Compliance Checklist"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.map((c,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:c.ok?"#16a34a":"#d97706",fontWeight:600},children:c.ok?"✓":"⚠"}),e.jsx("span",{children:c.label})]},y))})]})}function et({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState(!0),[p,b]=r.useState(null),o=r.useCallback(async x=>{if(n?.isAuthenticated())return n.fetchWithAuth(x);const f={"Content-Type":"application/json"};i&&(f["X-API-Key"]=i);const j=await fetch(`${t}${x}`,{headers:f});if(!j.ok)throw new Error(`HTTP ${j.status}`);return j.json()},[t,i,n]),d=r.useCallback(async()=>{y(!0),b(null);try{const[x,f]=await Promise.all([o("/admin/gift-cards?limit=50"),o("/admin/gift-card-redemptions?limit=50").catch(()=>({redemptions:[]}))]),j=x.giftCards??[],k=f.redemptions??[],h=new Date,S=j.filter(m=>m.active&&(!m.expiresAt||new Date(m.expiresAt)>h)).length,T=j.filter(m=>m.expiresAt&&new Date(m.expiresAt)<=h).length,l=j.reduce((m,N)=>m+N.initialBalance,0),w=j.reduce((m,N)=>m+N.balance,0),_=k.reduce((m,N)=>m+N.faceValueCents,0),A=k.filter(m=>m.tokenMinted).length,g=j[0]?.currency||k[0]?.currency||"USD";a({totalCards:j.length,activeCards:S,expiredCards:T,totalIssuedCents:l,totalRemainingCents:w,totalRedeemedCents:_,redemptionCount:k.length,tokensMinted:A,currency:g.toUpperCase()})}catch(x){b(x instanceof Error?x.message:"Failed to load analytics")}finally{y(!1)}},[o]);r.useEffect(()=>{d()},[d]);const u=x=>`$${(x/100).toFixed(2)}`;if(c)return e.jsx("div",{className:"cedros-admin__loading",children:"Loading analytics..."});if(p)return e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:d,children:"Retry"})]});if(!s)return null;const v=s.totalIssuedCents>0?((s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100).toFixed(1):"0.0";return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Gift Card & Token Analytics"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[e.jsx($,{label:"Total Cards",value:String(s.totalCards)}),e.jsx($,{label:"Active",value:String(s.activeCards),accent:"green"}),e.jsx($,{label:"Expired",value:String(s.expiredCards),accent:s.expiredCards>0?"amber":void 0}),e.jsx($,{label:"Total Issued",value:u(s.totalIssuedCents),sub:s.currency}),e.jsx($,{label:"Remaining Balance",value:u(s.totalRemainingCents),sub:s.currency}),e.jsx($,{label:"Usage Rate",value:`${v}%`,sub:"issued vs. spent"}),e.jsx($,{label:"Redemptions",value:String(s.redemptionCount)}),e.jsx($,{label:"Tokens Minted",value:String(s.tokensMinted),sub:`of ${s.redemptionCount} redemptions`})]}),s.totalIssuedCents>0&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Balance Breakdown"}),e.jsxs("div",{style:{display:"flex",height:24,borderRadius:6,overflow:"hidden",background:"rgba(0,0,0,0.05)"},children:[e.jsx("div",{style:{width:`${(s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100}%`,background:"#2563eb",minWidth:2},title:`Spent: ${u(s.totalIssuedCents-s.totalRemainingCents)}`}),e.jsx("div",{style:{width:`${s.totalRemainingCents/s.totalIssuedCents*100}%`,background:"#60a5fa",minWidth:2},title:`Remaining: ${u(s.totalRemainingCents)}`})]}),e.jsxs("div",{style:{display:"flex",gap:"1rem",marginTop:6,fontSize:12,opacity:.7},children:[e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#2563eb",borderRadius:2,marginRight:4}}),"Spent"]}),e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#60a5fa",borderRadius:2,marginRight:4}}),"Remaining"]})]})]})]})}function $({label:t,value:i,sub:n,accent:s}){const a=s==="green"?"#166534":s==="amber"?"#92400e":void 0;return e.jsxs("div",{style:{padding:"0.75rem 1rem",borderRadius:8,border:"1px solid rgba(0,0,0,0.08)",background:"rgba(0,0,0,0.01)"},children:[e.jsx("div",{style:{fontSize:12,opacity:.6,marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:a},children:i}),n&&e.jsx("div",{style:{fontSize:11,opacity:.5,marginTop:2},children:n})]})}function tt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState("list"),[u,v]=r.useState(null),[x,f]=r.useState(!1),[j,k]=r.useState(null),h=r.useCallback(async(_,A)=>{if(n?.isAuthenticated())return n.fetchWithAuth(_,A);const g={"Content-Type":"application/json"};i&&(g["X-API-Key"]=i);const m=await fetch(`${t}${_}`,{...A,headers:{...g,...A?.headers}});if(!m.ok){const N=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(N)}return m.json()},[t,i,n]),S=r.useCallback(async()=>{y(!0),b(null);try{const A=await h(`/admin/gift-cards${x?"?activeOnly=true&limit=50":"?limit=50"}`);a(A.giftCards??[])}catch(_){b(_ instanceof Error?_.message:"Failed to load gift cards")}finally{y(!1)}},[h,x]);r.useEffect(()=>{S()},[S]);const T=(_,A)=>`$${(_/100).toFixed(2)} ${A.toUpperCase()}`,l=_=>{try{return new Date(_).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}catch{return _}},w=_=>{v(_),d("adjust"),k(null)};return o==="create"?e.jsx(st,{onSubmit:async _=>{await h("/admin/gift-cards",{method:"POST",body:JSON.stringify(_)}),d("list"),S()},onCancel:()=>d("list")}):o==="adjust"&&u?e.jsx(nt,{card:u,formatCents:T,onSubmit:async _=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}/adjust`,{method:"POST",body:JSON.stringify({newBalance:_})}),d("list"),S()},onToggleActive:async()=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}`,{method:"PUT",body:JSON.stringify({initialBalance:u.initialBalance,balance:u.balance,currency:u.currency,active:!u.active,expiresAt:u.expiresAt,metadata:u.metadata})}),d("list"),S()},onCancel:()=>{d("list"),v(null)}}):e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{margin:0},children:"Gift Card Inventory"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("label",{style:{fontSize:13,display:"flex",alignItems:"center",gap:4},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:_=>f(_.target.checked)}),"Active only"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{d("create"),k(null)},children:"+ New Gift Card"})]})]}),p&&e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:S,children:"Retry"})]}),j&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(22,163,74,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#166534"},children:j}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading..."}):s.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Code"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:"Initial"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map(_=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[_.code.slice(0,12),"..."]})}),e.jsx("td",{style:{fontWeight:600},children:T(_.balance,_.currency)}),e.jsx("td",{style:{opacity:.7},children:T(_.initialBalance,_.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${_.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:_.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:13},children:_.expiresAt?l(_.expiresAt):"—"}),e.jsx("td",{style:{fontSize:13},children:l(_.createdAt)}),e.jsx("td",{children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(_),children:"Manage"})})]},_.code))})]})}):e.jsx("div",{className:"cedros-admin__empty",style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift cards found."})]})}function st({onSubmit:t,onCancel:i}){const[n,s]=r.useState({code:"",initialBalance:"",currency:"USD",expiresAt:""}),[a,c]=r.useState(!1),[y,p]=r.useState(null),b=async o=>{o.preventDefault();const d=Math.round(parseFloat(n.initialBalance)*100);if(!d||d<0){p("Initial balance must be positive");return}c(!0),p(null);try{await t({...n.code.trim()?{code:n.code.trim().toUpperCase()}:{},initialBalance:d,currency:n.currency.toUpperCase(),...n.expiresAt?{expiresAt:new Date(n.expiresAt).toISOString()}:{}})}catch(u){p(u instanceof Error?u.message:"Failed to create gift card")}finally{c(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Create Gift Card"}),y&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:y}),e.jsxs("form",{onSubmit:b,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Code (optional, auto-generated if empty)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.code,onChange:o=>s(d=>({...d,code:o.target.value})),placeholder:"Leave blank to auto-generate"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Initial Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n.initialBalance,onChange:o=>s(d=>({...d,initialBalance:o.target.value})),placeholder:"25.00",step:"0.01",min:"0",required:!0})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.currency,onChange:o=>s(d=>({...d,currency:o.target.value})),maxLength:3,required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Expiration date (optional)"}),e.jsx("input",{type:"date",className:"cedros-admin__input",value:n.expiresAt,onChange:o=>s(d=>({...d,expiresAt:o.target.value}))})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:a,children:a?"Creating...":"Create Gift Card"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:i,children:"Cancel"})]})]})]})}function nt({card:t,formatCents:i,onSubmit:n,onToggleActive:s,onCancel:a}){const[c,y]=r.useState((t.balance/100).toFixed(2)),[p,b]=r.useState(!1),[o,d]=r.useState(null),u=async x=>{x.preventDefault();const f=Math.round(parseFloat(c)*100);if(isNaN(f)||f<0){d("Balance must be >= 0");return}b(!0),d(null);try{await n(f)}catch(j){d(j instanceof Error?j.message:"Failed to adjust balance")}finally{b(!1)}},v=async()=>{b(!0),d(null);try{await s()}catch(x){d(x instanceof Error?x.message:"Failed to update status"),b(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Manage Gift Card"}),o&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:o}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem",maxWidth:500,marginBottom:"1.5rem",fontSize:13},children:[e.jsx("div",{style:{fontWeight:500},children:"Code"}),e.jsx("div",{style:{fontFamily:"monospace",wordBreak:"break-all"},children:t.code}),e.jsx("div",{style:{fontWeight:500},children:"Current Balance"}),e.jsx("div",{style:{fontWeight:600},children:i(t.balance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Initial Balance"}),e.jsx("div",{children:i(t.initialBalance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Status"}),e.jsx("div",{children:e.jsx("span",{className:`cedros-admin__badge ${t.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:t.active?"Active":"Inactive"})}),t.expiresAt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500},children:"Expires"}),e.jsx("div",{children:new Date(t.expiresAt).toLocaleDateString()})]})]}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:250},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:c,onChange:x=>y(x.target.value),step:"0.01",min:"0",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:p,children:p?"Saving...":"Adjust Balance"}),e.jsx("button",{type:"button",className:`cedros-admin__button ${t.active?"cedros-admin__button--danger":"cedros-admin__button--outline"}`,onClick:v,disabled:p,children:t.active?"Deactivate":"Reactivate"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:a,children:"Back"})]})]})]})}const it=0;class we{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const i=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=i.default??i,this.dlmmModule}catch{throw new Error("Install @meteora-ag/dlmm to enable pool deployment: npm install @meteora-ag/dlmm")}}async loadBN(){if(this.bnClass)return this.bnClass;const i=await Promise.resolve().then(()=>require("./bn-CHyy7EgJ.js")).then(n=>n.bn);return this.bnClass=i.default??i,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:i}=await import("@solana/web3.js");return this.keypairClass=i,this.keypairClass}async computeBinId(i,n,s,a=1){const c=await this.loadDLMM(),y=c.getPricePerLamport(n,s,i);return c.getBinIdFromPrice(y,a,!0)}async findPresetParameter(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,{presetParameter2:y}=await a.getAllPresetParameters(i,c),p=y.find(b=>b.account.binStep===n);if(!p)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${y.map(b=>b.account.binStep).join(", ")}`);return p.publicKey}async createPool(i,n,s,a,c,y=1,p){const b=await this.loadDLMM(),o=await this.loadBN(),d=p?{cluster:p}:void 0,u=await this.findPresetParameter(i,y,p),v=await b.createLbPair2(i,n,s,a,u,new o(c),d),x=v.instructions[0]?.keys?.[1]?.pubkey;if(!x)throw new Error("Failed to extract pool address from transaction");return{transaction:v,poolAddress:x}}async addBuybackLiquidity(i,n,s,a,c,y){const p=await this.loadDLMM(),b=await this.loadBN(),o=await this.loadKeypair(),d=y?{cluster:y}:void 0,u=await p.create(i,s,d),v=o.generate(),x=c-1,f=c;return{transaction:await u.initializePositionAndAddLiquidityByStrategy({positionPubKey:v.publicKey,totalXAmount:new b(0),totalYAmount:new b(a),strategy:{maxBinId:f,minBinId:x,strategyType:it},user:n,slippage:1}),positionKeypair:v}}async getPoolStatus(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,y=await a.create(i,n,c),p=await y.getActiveBin();return{address:n.toBase58(),activeBinId:p.binId,activeBinPrice:p.price,binStep:y.lbPair.binStep}}}const he=6,at=1,rt="https://solscan.io/account",ot="https://app.meteora.ag/dlmm";function lt({serverUrl:t,authManager:i,poolAddress:n,buybackRateBps:s,usdcAmount:a,deployedAt:c,mintAddress:y,tokenDecimals:p=2,onConfigUpdated:b}){const[o,d]=r.useState("none"),[u,v]=r.useState(s!=null?s/100:80),[x,f]=r.useState(100),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),[w,_]=r.useState(null),A=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",g=a!=null?`$${(a/10**he).toFixed(2)}`:null,m=c?new Date(c).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,N=n.length>16?`${n.slice(0,8)}...${n.slice(-8)}`:n,C=async()=>{k(!0),_(null),l(null);try{const B=new ee.ConfigApiClient(t,void 0,i),R=Math.round(u*100);await B.patchConfig("gift_cards",{buyback_rate_bps:R},`Buyback rate adjusted to ${u} cents`),l("Buyback rate updated"),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to update rate")}finally{k(!1)}},z=async()=>{if(y){S(!0),_(null),l(null);try{const{Connection:B,PublicKey:R,Keypair:M}=await import("@solana/web3.js"),F=new ee.ConfigApiClient(t,void 0,i),I=await F.getConfig("x402"),D=I.config?.rpc_url||"",P=I.config?.token_mint||"";if(!D||!P)throw new Error("RPC URL or USDC mint not configured");const L=new B(D,"confirmed"),O=window.solana;if(!O?.publicKey||!O.signTransaction)throw new Error("Wallet not connected");const se=new we,le=new R(O.publicKey.toBase58()),E=u/100,de=await se.computeBinId(E,p,he,at),ne=new R(n),H=Math.round(x*10**he),{transaction:J,positionKeypair:W}=await se.addBuybackLiquidity(L,le,ne,H,de),V=M.fromSecretKey(W.secretKey);J.partialSign(V);const Y=await O.signTransaction(J),X=await L.sendRawTransaction(Y.serialize());await L.confirmTransaction(X,"confirmed");const Z=a??0;await F.patchConfig("gift_cards",{liquidity_usdc_amount:Z+H},`Added ${x} USDC liquidity`),l(`Added $${x} USDC liquidity`),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to add liquidity")}finally{S(!1)}}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Liquidity Pool Active"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Pool Address"}),e.jsxs("div",{style:{fontSize:13,fontFamily:"monospace",wordBreak:"break-all"},children:[N,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(dt,{text:n}),e.jsx(ve,{href:`${rt}/${n}`,label:"Solscan"}),e.jsx(ve,{href:`${ot}/${n}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[A," per $1.00"]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:g})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:m})]})]}),e.jsxs("div",{style:{marginTop:"1.25rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="adjust_rate"?"none":"adjust_rate"),disabled:h||j,children:"Adjust Rate"}),e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="add_liquidity"?"none":"add_liquidity"),disabled:h||j||!y,children:"Add Liquidity"})]}),o==="adjust_rate"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:u,onChange:B=>v(Math.max(1,Math.min(99,parseInt(B.target.value)||80))),min:"1",max:"99",style:{maxWidth:200}}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["Profit per redemption: $",((100-u)/100).toFixed(2)]})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:j,style:{marginTop:"0.75rem"},children:j?"Saving...":"Save Rate"})]}),o==="add_liquidity"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount to add"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:x,onChange:B=>f(Math.max(1,parseFloat(B.target.value)||100)),min:"1",step:"1",style:{maxWidth:200}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:z,disabled:h,style:{marginTop:"0.75rem"},children:h?"Adding liquidity...":`Add $${x} USDC`}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Requires a connected wallet and USDC balance."})]}),T&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(22,163,74,0.1)",color:"#16a34a",fontSize:13},children:T}),w&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:w})]})}function dt({text:t}){const[i,n]=r.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:s,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:i?"Copied":"Copy"})}function ve({href:t,label:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:i})}const ie=6,ge=1;function ct({serverUrl:t,authManager:i,mintConfigured:n,mintAddress:s,tokenDecimals:a=2}){const[c,y]=r.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[p,b]=r.useState(!0),[o,d]=r.useState(80),[u,v]=r.useState(250),[x,f]=r.useState("idle"),[j,k]=r.useState(null),[h,S]=r.useState(null),[T,l]=r.useState(null),w=r.useRef(new we),_=r.useCallback(async()=>{try{const R=new ee.ConfigApiClient(t,void 0,i),[M,F]=await Promise.all([R.getConfig("gift_cards"),R.getConfig("x402")]),I=M.config??{},D=F.config??{},P=I.liquidity_pool_address||null;y({liquidityPoolAddress:P,buybackRateBps:I.buyback_rate_bps!=null?Number(I.buyback_rate_bps):null,rpcUrl:D.rpc_url||null,usdcMint:D.token_mint||null,usdcAmount:I.liquidity_usdc_amount!=null?Number(I.liquidity_usdc_amount):null,deployedAt:I.liquidity_deployed_at||null}),P&&S(P),I.buyback_rate_bps!=null&&d(Number(I.buyback_rate_bps)/100)}catch{}finally{b(!1)}},[t,i]);r.useEffect(()=>{_()},[_]);const A=typeof window<"u"&&!!window.solana?.publicKey,g=!!c.rpcUrl,m=!!c.usdcMint,N=n&&A&&g&&m&&x==="idle",C=async R=>{if(!(!s||!c.rpcUrl||!c.usdcMint)){f(R),k(null),l(null);try{const{Connection:M,PublicKey:F,Keypair:I}=await import("@solana/web3.js"),D=new M(c.rpcUrl,"confirmed"),P=window.solana;if(!P?.publicKey||!P.signTransaction)throw new Error("Wallet not connected");const L=w.current,O=new F(P.publicKey.toBase58()),se=o/100,le=await L.computeBinId(se,a,ie,ge);let E=h;if(R==="creating_pool"){const W=new F(s),V=new F(c.usdcMint),Y=await L.computeBinId(1,a,ie,ge),{transaction:X,poolAddress:Z}=await L.createPool(D,O,W,V,Y,ge),ce=await P.signTransaction(X),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed"),E=Z.toBase58(),S(E)}if(R==="creating_pool"||R==="adding_liquidity"){if(f("adding_liquidity"),!E)throw new Error("Pool address not available");const W=new F(E),V=Math.round(u*10**ie),{transaction:Y,positionKeypair:X}=await L.addBuybackLiquidity(D,O,W,V,le),Z=I.fromSecretKey(X.secretKey);Y.partialSign(Z);const ce=await P.signTransaction(Y),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed")}if(f("saving_config"),!E)throw new Error("Pool address not available");const de=new ee.ConfigApiClient(t,void 0,i),ne=Math.round(o*100),H=Math.round(u*10**ie),J=new Date().toISOString();await de.patchConfig("gift_cards",{liquidity_pool_address:E,buyback_rate_bps:ne,liquidity_usdc_amount:H,liquidity_deployed_at:J},"Meteora DLMM pool deployed for gift card buyback"),y(W=>({...W,liquidityPoolAddress:E,buybackRateBps:ne,usdcAmount:H,deployedAt:J})),f("done")}catch(M){l(x==="idle"?R:x),k(M instanceof Error?M.message:"Deployment failed"),f("error")}}},z=()=>{N&&C("creating_pool")},B=()=>{!T||T==="idle"||T==="done"||T==="error"||C(T)};return p?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):c.liquidityPoolAddress?e.jsx(lt,{serverUrl:t,authManager:i,poolAddress:c.liquidityPoolAddress,buybackRateBps:c.buybackRateBps,usdcAmount:c.usdcAmount,deployedAt:c.deployedAt,mintAddress:s,tokenDecimals:a,onConfigUpdated:_}):x!=="idle"&&x!=="error"?e.jsx(mt,{step:x,poolAddress:h}):e.jsx(ut,{buybackCents:o,setBuybackCents:d,usdcAmount:u,setUsdcAmount:v,mintConfigured:n,walletConnected:A,hasRpcUrl:g,hasUsdcMint:m,canDeploy:N,onDeploy:z,errorMessage:j,canRetry:!!T&&T!=="creating_pool",onRetry:B})}function ut({buybackCents:t,setBuybackCents:i,usdcAmount:n,setUsdcAmount:s,mintConfigured:a,walletConnected:c,hasRpcUrl:y,hasUsdcMint:p,canDeploy:b,onDeploy:o,errorMessage:d,canRetry:u,onRetry:v}){const x=((100-t)/100).toFixed(2);return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Deploy Buyback Liquidity Pool"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Meteora DLMM pool to buy back gift card tokens at a discount. You earn the spread when tokens are resold at face value."}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:t,onChange:f=>i(Math.max(1,Math.min(99,parseInt(f.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",x," profit per gift card redeemed"]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n,onChange:f=>s(Math.max(1,parseFloat(f.target.value)||250)),min:"1",step:"1"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Minimum recommended: $250"})]})]}),e.jsxs("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",gap:6},children:[e.jsx(ae,{label:"Token-22 mint initialized",met:a}),e.jsx(ae,{label:"Wallet connected",met:c}),e.jsx(ae,{label:"RPC URL configured",met:y}),e.jsx(ae,{label:"USDC mint configured",met:p})]}),d&&e.jsx("div",{style:{padding:"0.5rem 0.75rem",marginBottom:"0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:d}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:u?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:v,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:o,disabled:!b,children:"Deploy Liquidity Pool"})})]})}const Se=[{key:"creating_pool",label:"Creating DLMM pool..."},{key:"adding_liquidity",label:"Depositing USDC liquidity..."},{key:"saving_config",label:"Saving configuration..."},{key:"done",label:"Complete"}];function mt({step:t,poolAddress:i}){return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Deploying Pool..."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:Se.map((n,s)=>{const a=Se.findIndex(b=>b.key===t),c=s,y=c<a||t==="done",p=c===a&&t!=="done";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontWeight:600},children:y?"✓":p?"▶":"○"}),e.jsx("span",{style:{opacity:y||p?1:.4},children:n.label})]},n.key)})}),i&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:i})]})]})}function ae({label:t,met:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:i?"#16a34a":"#dc2626",fontWeight:600},children:i?"✓":"✗"}),e.jsx("span",{style:{opacity:i?.8:.5},children:t})]})}function pt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState([]),[p,b]=r.useState(!0),[o,d]=r.useState(null),[u,v]=r.useState("mint"),[x,f]=r.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),w=r.useCallback(async(C,z)=>{if(n?.isAuthenticated())return n.fetchWithAuth(C,z);const B={"Content-Type":"application/json"};i&&(B["X-API-Key"]=i);const R=await fetch(`${t}${C}`,{...z,headers:{...B,...z?.headers}});if(!R.ok){const M=await R.text().catch(()=>`HTTP ${R.status}`);throw new Error(M)}return R.json()},[t,i,n]),_=r.useCallback(async()=>{try{d(null);const C=await w("/admin/token22/status");a(C)}catch{d("Failed to load Token-22 status")}finally{b(!1)}},[w]),A=r.useCallback(async()=>{try{const C=await w("/admin/gift-card-redemptions?limit=50");y(C.redemptions||[])}catch{y([])}},[w]);r.useEffect(()=>{_(),A()},[_,A]);const g=async C=>{if(C.preventDefault(),!!x.treasuryAddress){k(!0),l(null);try{const z=await w("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:x.treasuryAddress,tokenSymbol:x.tokenSymbol,tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee})});l(`Mint created: ${z.mintAddress}`),_()}catch(z){l(`Error: ${z instanceof Error?z.message:"Failed to initialize"}`)}finally{k(!1)}}},m=async()=>{S(!0),l(null);try{const C=await w("/admin/token22/harvest-fees",{method:"POST"});l(C.message)}catch(C){l(`Error: ${C instanceof Error?C.message:"Failed to harvest"}`)}finally{S(!1)}},N=C=>{try{return new Date(C).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return C}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(fe.ErrorBanner,{message:o,onRetry:_}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","inventory","analytics","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(C=>{const z={mint:"Token-22 Mint",inventory:"Gift Cards",analytics:"Analytics",redemptions:"Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>v(C),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:u===C?"2px solid currentColor":"2px solid transparent",fontWeight:u===C?600:400,cursor:"pointer",opacity:u===C?1:.6},children:z[C]},C)})}),p?e.jsxs("div",{className:"cedros-admin__loading",children:[fe.Icons.loading," Loading..."]}):u==="mint"?e.jsx(ht,{mintStatus:s,initForm:x,setInitForm:f,isInitializing:j,isHarvesting:h,actionMessage:T,onInitialize:g,onHarvestFees:m,formatDate:N}):u==="inventory"?e.jsx(tt,{serverUrl:t,apiKey:i,authManager:n}):u==="analytics"?e.jsx(et,{serverUrl:t,apiKey:i,authManager:n}):u==="redemptions"?e.jsx(gt,{redemptions:c,formatDate:N}):u==="compliance"?e.jsx(Ke,{serverUrl:t,apiKey:i,authManager:n}):u==="liquidity"?e.jsx(ct,{serverUrl:t,authManager:n,mintConfigured:!!s?.configured,mintAddress:s?.mintAddress,tokenDecimals:s?.tokenDecimals}):u==="asset-classes"?e.jsx(Ee,{serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:()=>v("liquidity")}):e.jsx(Ue,{serverUrl:t,apiKey:i,authManager:n})]})}function ht({mintStatus:t,initForm:i,setInitForm:n,isInitializing:s,isHarvesting:a,actionMessage:c,onInitialize:y,onHarvestFees:p,formatDate:b}){return t?.configured?e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Token-22 Mint Status"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx(q,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(q,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(q,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(q,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(q,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(q,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(q,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(q,{label:"Created",value:t.createdAt?b(t.createdAt):"—"})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem",alignItems:"center"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:p,disabled:a,children:a?"Harvesting...":"Harvest Transfer Fees"}),c&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:c})]})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Initialize Token-22 Mint"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Token-22 mint with transfer fee extension for the secondary market. This is a one-time operation per tenant."}),e.jsxs("form",{onSubmit:y,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Treasury address (Solana)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.treasuryAddress,onChange:o=>n(d=>({...d,treasuryAddress:o.target.value})),placeholder:"e.g., 7xKX...",required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.tokenSymbol,onChange:o=>n(d=>({...d,tokenSymbol:o.target.value})),placeholder:"storeUSD"})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.tokenDecimals,onChange:o=>n(d=>({...d,tokenDecimals:parseInt(o.target.value)||2})),min:"0",max:"9"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Transfer fee (basis points)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.transferFeeBps,onChange:o=>n(d=>({...d,transferFeeBps:parseInt(o.target.value)||0})),min:"0",max:"10000"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"e.g., 250 = 2.5% fee on secondary market transfers"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max transfer fee (atomic)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.maxTransferFee,onChange:o=>n(d=>({...d,maxTransferFee:parseInt(o.target.value)||0})),min:"0"})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:s,children:s?"Creating Mint...":"Initialize Mint"}),c&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:c})]})]})]})}function q({label:t,value:i,mono:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:t}),e.jsx("div",{style:{fontSize:13,fontFamily:n?"monospace":"inherit",wordBreak:n?"break-all":"normal",opacity:i?1:.5},children:i||"—"})]})}function gt({redemptions:t,formatDate:i}){return t.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Buyer"}),e.jsx("th",{children:"Recipient"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Token Minted"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:i(n.createdAt)}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.orderId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:12},children:n.productId})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.buyerUserId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.recipientUserId.slice(0,8),"..."]})}),e.jsxs("td",{children:["$",(n.faceValueCents/100).toFixed(2)," ",n.currency.toUpperCase()]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${n.tokenMinted?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:n.tokenMinted?"Yes":"No"})})]},n.id))})]})}):e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift card redemptions yet."})}exports.Token22Section=pt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@solana/web3.js"),w=require("@solana/spl-token"),t=require("./CedrosContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@solana/web3.js"),w=require("@solana/spl-token"),t=require("./CedrosContext-C2RjHLaQ.js"),h=require("./index-WcOlBYZJ.js");class p{connection;cluster;endpoint;allowUnknownMint;rpcRateLimiter=t.createRateLimiter({maxRequests:50,windowMs:6e4});rpcCircuitBreaker=t.createCircuitBreaker({failureThreshold:5,timeout:1e4,name:"solana-rpc"});constructor(r="mainnet-beta",e,n=!1){this.cluster=r,this.endpoint=e,this.allowUnknownMint=n,this.connection=this.createConnection()}createConnection(){const r=this.endpoint??o.clusterApiUrl(this.cluster);return new o.Connection(r,"confirmed")}transformRpcError(r){const e=r instanceof Error?r.message:typeof r=="string"?r:String(r);return e.includes("403")||e.includes("Access forbidden")?new Error("Public Solana RPC access denied. Please configure a custom RPC endpoint (e.g., from Helius, QuickNode, or Alchemy) in your CedrosProvider config using the solanaEndpoint option."):e.includes("429")||e.includes("Too Many Requests")?new Error("Solana RPC rate limit exceeded. Please configure a custom RPC endpoint with higher limits in your CedrosProvider config using the solanaEndpoint option."):r instanceof Error?r:new Error(e)}async buildTransaction(r){const{requirement:e,payerPublicKey:n,blockhash:a}=r;if(!e||!e.payTo)throw new Error("Invalid requirement: missing payTo");t.getLogger().debug("[WalletManager] Building transaction for resource:",e.resource);const i=new o.Transaction,u=this.resolveAmountInMinorUnits(e),c=e.asset;if(!c)throw new Error("asset is required in x402 requirement");const l=t.validateX402Asset(c,e.resource,this.allowUnknownMint);if(!l.isValid&&l.error)throw new Error(l.error);l.warning&&t.getLogger().warn(l.warning);const y=new o.PublicKey(c),m=await w.getAssociatedTokenAddress(y,n);if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded. Please try again in a moment.");let d;try{d=await this.rpcCircuitBreaker.execute(async()=>await t.retryWithBackoff(async()=>await this.connection.getAccountInfo(m),{...t.RETRY_PRESETS.QUICK,name:"rpc-get-account-info"}))}catch(s){throw s instanceof t.CircuitBreakerOpenError?new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments."):this.transformRpcError(s)}if(!d)throw new Error("Payer is missing an associated token account for this mint");let f;try{f=e.extra?.recipientTokenAccount?new o.PublicKey(e.extra.recipientTokenAccount):new o.PublicKey(e.payTo)}catch(s){throw t.getLogger().warn("[WalletManager] Failed to resolve recipient address:",s),new Error("We are currently unable to process payment, please try again later")}if(i.add(w.createTransferInstruction(m,f,n,u)),e.extra?.memo){const s=new o.TransactionInstruction({keys:[],programId:new o.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),data:Buffer.from(e.extra.memo,"utf8")});i.add(s)}let g;if(a)g=a;else{if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded. Please try again in a moment.");try{g=(await this.rpcCircuitBreaker.execute(async()=>await t.retryWithBackoff(async()=>await this.connection.getLatestBlockhash(),{...t.RETRY_PRESETS.QUICK,name:"rpc-get-blockhash"}))).blockhash}catch(s){throw s instanceof t.CircuitBreakerOpenError?new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments."):this.transformRpcError(s)}}return i.recentBlockhash=g,e.extra?.feePayer?i.feePayer=new o.PublicKey(e.extra.feePayer):i.feePayer=n,i}resolveAmountInMinorUnits(r){const e=r.maxAmountRequired;if(!/^\d+$/.test(e))throw new Error("Invalid maxAmountRequired in requirement: must be a non-negative integer string");const n=BigInt(e);if(n<=0n)throw new Error("Invalid maxAmountRequired in requirement");return n}buildPaymentPayload(r){const{requirement:e,signedTx:n,payerPublicKey:a}=r;return{x402Version:0,scheme:e.scheme,network:e.network,payload:{signature:n.signature,transaction:n.serialized,payer:a.toString(),memo:e.extra?.memo,recipientTokenAccount:e.extra?.recipientTokenAccount}}}async signTransaction(r){const{transaction:e,signTransaction:n}=r;t.getLogger().debug("[WalletManager] Requesting wallet to sign transaction");const a=await n(e),i=a.serialize(),u=a.signatures[0]?.signature;if(!u)throw new Error("Signed transaction missing signature");const c=h.bs58.encode(u);return t.getLogger().debug("[WalletManager] Transaction signed with signature:",c.substring(0,20)+"..."),{serialized:t.gBase64.fromUint8Array(i),signature:c}}deserializeTransaction(r){try{const e=t.gBase64.toUint8Array(r);return o.Transaction.from(e)}catch(e){throw new Error(`Failed to deserialize transaction: ${t.formatError(e,"Unknown error")}`)}}async partiallySignTransaction(r){const{transaction:e,signTransaction:n,blockhash:a}=r;a&&e.recentBlockhash!==a&&(e.recentBlockhash=a);const i=await n(e),u=i.signatures[0]?.signature;if(u){const l=h.bs58.encode(u);t.getLogger().debug("[WalletManager] Partially signed with signature:",l.substring(0,20)+"...")}const c=i.serialize({requireAllSignatures:!1,verifySignatures:!1});return t.gBase64.fromUint8Array(c)}async getBalance(r){if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded. Please try again in a moment.");try{return await this.rpcCircuitBreaker.execute(async()=>await t.retryWithBackoff(async()=>await this.connection.getBalance(r),{...t.RETRY_PRESETS.QUICK,name:"rpc-get-balance"}))/o.LAMPORTS_PER_SOL}catch(e){throw e instanceof t.CircuitBreakerOpenError?new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments."):this.transformRpcError(e)}}async verifyTransaction(r){if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded for transaction verification");try{return!!(await this.rpcCircuitBreaker.execute(async()=>await t.retryWithBackoff(async()=>await this.connection.getSignatureStatus(r),{...t.RETRY_PRESETS.QUICK,name:"rpc-verify-tx"}))).value?.confirmationStatus}catch(e){return e instanceof t.CircuitBreakerOpenError&&t.getLogger().warn("[WalletManager] Circuit breaker OPEN - cannot verify transaction"),!1}}}exports.WalletManager=p;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clusterApiUrl as C, Connection as b, Transaction as P, PublicKey as l, TransactionInstruction as R, LAMPORTS_PER_SOL as x } from "@solana/web3.js";
|
|
2
2
|
import { getAssociatedTokenAddress as T, createTransferInstruction as A } from "@solana/spl-token";
|
|
3
|
-
import { h as v, f as B, i as u, k as S, r as m, e as g, b as w, l as f, m as M } from "./CedrosContext-
|
|
3
|
+
import { h as v, f as B, i as u, k as S, r as m, e as g, b as w, l as f, m as M } from "./CedrosContext-CY6zvjvJ.mjs";
|
|
4
4
|
import { b as k } from "./index-BFt38o8Q.mjs";
|
|
5
5
|
class z {
|
|
6
6
|
connection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),a=require("./index-C0g-JxJk.js"),Q=n=>n==="success"?"success":n==="failed"?"failed":n==="pending"||n==="processing"?"pending":"muted",j=(n,d=48)=>n.length>d?`${n.slice(0,d)}…`:n;function P({serverUrl:n,apiKey:d,authManager:b}){const[l,q]=s.useState("active"),[p,f]=s.useState([]),[h,E]=s.useState(0),[m,L]=s.useState("all"),[W,_]=s.useState(!0),[g,k]=s.useState([]),[v,C]=s.useState(0),[N,S]=s.useState(!1),[T,F]=s.useState(!1),[w,c]=s.useState(null),[A,o]=s.useState(null),r=s.useCallback(async(t,i)=>{if(b?.isAuthenticated())return b.fetchWithAuth(t,i);const D={"Content-Type":"application/json"};d&&(D["X-API-Key"]=d);const x=await fetch(`${n}${t}`,{...i,headers:{...D,...i?.headers}});if(!x.ok)throw new Error(`Request failed: ${x.status}`);if(x.status!==204)return x.json()},[n,d,b]),u=s.useCallback(async()=>{_(!0),c(null);try{const t=new URLSearchParams({limit:"100"});m!=="all"&&t.set("status",m);const i=await r(`/admin/webhooks?${t.toString()}`);f(i.webhooks??[]),E(i.count??0)}catch{c("Failed to load webhooks"),f([])}finally{_(!1)}},[r,m]);s.useEffect(()=>{u()},[u]);const y=s.useCallback(async()=>{S(!0),c(null);try{const t=await r("/admin/webhooks/dlq?limit=100");k(t.webhooks??[]),C(t.count??0),F(!0)}catch{c("Failed to load DLQ webhooks"),k([])}finally{S(!1)}},[r]),$=t=>{q(t),c(null),o(null),t==="dlq"&&!T&&y()},z=async t=>{o(null);try{await r(`/admin/webhooks/${encodeURIComponent(t)}/retry`,{method:"POST"}),u()}catch{o("Failed to retry webhook")}},R=async t=>{if(window.confirm("Delete this webhook?")){o(null);try{await r(`/admin/webhooks/${encodeURIComponent(t)}`,{method:"DELETE"}),u()}catch{o("Failed to delete webhook")}}},I=async t=>{o(null);try{await r(`/admin/webhooks/dlq/${encodeURIComponent(t)}/retry`,{method:"POST"}),y()}catch{o("Failed to retry DLQ webhook")}},B=async t=>{if(window.confirm("Delete this DLQ entry?")){o(null);try{await r(`/admin/webhooks/dlq/${encodeURIComponent(t)}`,{method:"DELETE"}),y()}catch{o("Failed to delete DLQ entry")}}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Webhooks"})}),e.jsx(a.ErrorBanner,{message:w}),e.jsx(a.ErrorBanner,{message:A}),e.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"1rem",borderBottom:"1px solid var(--cedros-admin-border, #e0e0e0)"},children:["active","dlq"].map(t=>e.jsx("button",{type:"button",onClick:()=>$(t),style:{padding:"0.5rem 1rem",fontSize:"0.85rem",fontWeight:l===t?600:400,background:"none",border:"none",borderBottom:l===t?"2px solid var(--cedros-admin-primary, #000)":"2px solid transparent",cursor:"pointer",color:l===t?"var(--cedros-admin-text, #333)":"var(--cedros-admin-text-muted, #888)",marginBottom:"-1px"},children:t==="active"?`Active Webhooks${h>0?` (${h})`:""}`:`Dead Letter Queue${v>0?` (${v})`:""}`},t))}),l==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:m,onChange:t=>{L(t.target.value)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"success",children:"Success"})]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[h," webhook",h!==1?"s":""]})]}),W?e.jsxs("div",{className:"cedros-admin__loading",children:[a.Icons.loading," Loading webhooks..."]}):p.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No webhooks found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Event Type"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Attempts"}),e.jsx("th",{children:"Last Error"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:p.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{maxWidth:"200px"},children:e.jsx("span",{title:t.url,style:{fontSize:"0.8rem",fontFamily:"monospace"},children:j(t.url,40)})}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.eventType}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${Q(t.status)}`,children:t.status})}),e.jsxs("td",{style:{fontSize:"0.85rem"},children:[t.attempts,"/",t.maxAttempts]}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"180px",color:"var(--cedros-admin-text-muted, #888)"},children:t.lastError?e.jsx("span",{title:t.lastError,children:j(t.lastError,40)}):"—"}),e.jsx("td",{style:{fontSize:"0.8rem"},children:a.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>z(t.id),children:"Retry"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>R(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]}),l==="dlq"&&e.jsx(e.Fragment,{children:N?e.jsxs("div",{className:"cedros-admin__loading",children:[a.Icons.loading," Loading DLQ..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"Dead Letter Queue is empty."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Event Type"}),e.jsx("th",{children:"Attempts"}),e.jsx("th",{children:"Final Error"}),e.jsx("th",{children:"Moved to DLQ"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{maxWidth:"200px"},children:e.jsx("span",{title:t.url,style:{fontSize:"0.8rem",fontFamily:"monospace"},children:j(t.url,40)})}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.eventType}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.totalAttempts}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",color:"var(--cedros-admin-text-muted, #888)"},children:e.jsx("span",{title:t.finalError,children:j(t.finalError,40)})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:a.formatDateTime(t.movedToDlqAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>I(t.id),children:"Retry"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>B(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})})]})}exports.WebhooksSection=P;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { jsxs as n, jsx as t, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as r, useCallback as _, useEffect as G } from "react";
|
|
3
|
+
import { E as W, I as C, k as N } from "./index-DXnuQp5x.mjs";
|
|
4
|
+
const H = (o) => o === "success" ? "success" : o === "failed" ? "failed" : o === "pending" || o === "processing" ? "pending" : "muted", y = (o, s = 48) => o.length > s ? `${o.slice(0, s)}…` : o;
|
|
5
|
+
function Z({ serverUrl: o, apiKey: s, authManager: p }) {
|
|
6
|
+
const [a, w] = r("active"), [g, k] = r([]), [h, A] = r(0), [m, F] = r("all"), [T, v] = r(!0), [x, D] = r([]), [E, $] = r(0), [z, S] = r(!1), [I, R] = r(!1), [Q, c] = r(null), [B, d] = r(null), i = _(async (e, l) => {
|
|
7
|
+
if (p?.isAuthenticated())
|
|
8
|
+
return p.fetchWithAuth(e, l);
|
|
9
|
+
const L = { "Content-Type": "application/json" };
|
|
10
|
+
s && (L["X-API-Key"] = s);
|
|
11
|
+
const b = await fetch(`${o}${e}`, { ...l, headers: { ...L, ...l?.headers } });
|
|
12
|
+
if (!b.ok) throw new Error(`Request failed: ${b.status}`);
|
|
13
|
+
if (b.status !== 204)
|
|
14
|
+
return b.json();
|
|
15
|
+
}, [o, s, p]), u = _(async () => {
|
|
16
|
+
v(!0), c(null);
|
|
17
|
+
try {
|
|
18
|
+
const e = new URLSearchParams({ limit: "100" });
|
|
19
|
+
m !== "all" && e.set("status", m);
|
|
20
|
+
const l = await i(
|
|
21
|
+
`/admin/webhooks?${e.toString()}`
|
|
22
|
+
);
|
|
23
|
+
k(l.webhooks ?? []), A(l.count ?? 0);
|
|
24
|
+
} catch {
|
|
25
|
+
c("Failed to load webhooks"), k([]);
|
|
26
|
+
} finally {
|
|
27
|
+
v(!1);
|
|
28
|
+
}
|
|
29
|
+
}, [i, m]);
|
|
30
|
+
G(() => {
|
|
31
|
+
u();
|
|
32
|
+
}, [u]);
|
|
33
|
+
const f = _(async () => {
|
|
34
|
+
S(!0), c(null);
|
|
35
|
+
try {
|
|
36
|
+
const e = await i(
|
|
37
|
+
"/admin/webhooks/dlq?limit=100"
|
|
38
|
+
);
|
|
39
|
+
D(e.webhooks ?? []), $(e.count ?? 0), R(!0);
|
|
40
|
+
} catch {
|
|
41
|
+
c("Failed to load DLQ webhooks"), D([]);
|
|
42
|
+
} finally {
|
|
43
|
+
S(!1);
|
|
44
|
+
}
|
|
45
|
+
}, [i]), P = (e) => {
|
|
46
|
+
w(e), c(null), d(null), e === "dlq" && !I && f();
|
|
47
|
+
}, U = async (e) => {
|
|
48
|
+
d(null);
|
|
49
|
+
try {
|
|
50
|
+
await i(`/admin/webhooks/${encodeURIComponent(e)}/retry`, { method: "POST" }), u();
|
|
51
|
+
} catch {
|
|
52
|
+
d("Failed to retry webhook");
|
|
53
|
+
}
|
|
54
|
+
}, j = async (e) => {
|
|
55
|
+
if (window.confirm("Delete this webhook?")) {
|
|
56
|
+
d(null);
|
|
57
|
+
try {
|
|
58
|
+
await i(`/admin/webhooks/${encodeURIComponent(e)}`, { method: "DELETE" }), u();
|
|
59
|
+
} catch {
|
|
60
|
+
d("Failed to delete webhook");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}, O = async (e) => {
|
|
64
|
+
d(null);
|
|
65
|
+
try {
|
|
66
|
+
await i(`/admin/webhooks/dlq/${encodeURIComponent(e)}/retry`, { method: "POST" }), f();
|
|
67
|
+
} catch {
|
|
68
|
+
d("Failed to retry DLQ webhook");
|
|
69
|
+
}
|
|
70
|
+
}, X = async (e) => {
|
|
71
|
+
if (window.confirm("Delete this DLQ entry?")) {
|
|
72
|
+
d(null);
|
|
73
|
+
try {
|
|
74
|
+
await i(`/admin/webhooks/dlq/${encodeURIComponent(e)}`, { method: "DELETE" }), f();
|
|
75
|
+
} catch {
|
|
76
|
+
d("Failed to delete DLQ entry");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ n("div", { children: [
|
|
81
|
+
/* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Webhooks" }) }),
|
|
82
|
+
/* @__PURE__ */ t(W, { message: Q }),
|
|
83
|
+
/* @__PURE__ */ t(W, { message: B }),
|
|
84
|
+
/* @__PURE__ */ t("div", { style: { display: "flex", gap: "0.25rem", marginBottom: "1rem", borderBottom: "1px solid var(--cedros-admin-border, #e0e0e0)" }, children: ["active", "dlq"].map((e) => /* @__PURE__ */ t(
|
|
85
|
+
"button",
|
|
86
|
+
{
|
|
87
|
+
type: "button",
|
|
88
|
+
onClick: () => P(e),
|
|
89
|
+
style: {
|
|
90
|
+
padding: "0.5rem 1rem",
|
|
91
|
+
fontSize: "0.85rem",
|
|
92
|
+
fontWeight: a === e ? 600 : 400,
|
|
93
|
+
background: "none",
|
|
94
|
+
border: "none",
|
|
95
|
+
borderBottom: a === e ? "2px solid var(--cedros-admin-primary, #000)" : "2px solid transparent",
|
|
96
|
+
cursor: "pointer",
|
|
97
|
+
color: a === e ? "var(--cedros-admin-text, #333)" : "var(--cedros-admin-text-muted, #888)",
|
|
98
|
+
marginBottom: "-1px"
|
|
99
|
+
},
|
|
100
|
+
children: e === "active" ? `Active Webhooks${h > 0 ? ` (${h})` : ""}` : `Dead Letter Queue${E > 0 ? ` (${E})` : ""}`
|
|
101
|
+
},
|
|
102
|
+
e
|
|
103
|
+
)) }),
|
|
104
|
+
a === "active" && /* @__PURE__ */ n(q, { children: [
|
|
105
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: [
|
|
106
|
+
/* @__PURE__ */ n(
|
|
107
|
+
"select",
|
|
108
|
+
{
|
|
109
|
+
className: "cedros-admin__input",
|
|
110
|
+
value: m,
|
|
111
|
+
onChange: (e) => {
|
|
112
|
+
F(e.target.value);
|
|
113
|
+
},
|
|
114
|
+
style: { width: "auto", fontSize: "0.85rem" },
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ t("option", { value: "all", children: "All statuses" }),
|
|
117
|
+
/* @__PURE__ */ t("option", { value: "pending", children: "Pending" }),
|
|
118
|
+
/* @__PURE__ */ t("option", { value: "processing", children: "Processing" }),
|
|
119
|
+
/* @__PURE__ */ t("option", { value: "failed", children: "Failed" }),
|
|
120
|
+
/* @__PURE__ */ t("option", { value: "success", children: "Success" })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ n("span", { style: { fontSize: "0.85rem", color: "var(--cedros-admin-text-muted, #888)" }, children: [
|
|
125
|
+
h,
|
|
126
|
+
" webhook",
|
|
127
|
+
h !== 1 ? "s" : ""
|
|
128
|
+
] })
|
|
129
|
+
] }),
|
|
130
|
+
T ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
131
|
+
C.loading,
|
|
132
|
+
" Loading webhooks..."
|
|
133
|
+
] }) : g.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No webhooks found." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
134
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
135
|
+
/* @__PURE__ */ t("th", { children: "URL" }),
|
|
136
|
+
/* @__PURE__ */ t("th", { children: "Event Type" }),
|
|
137
|
+
/* @__PURE__ */ t("th", { children: "Status" }),
|
|
138
|
+
/* @__PURE__ */ t("th", { children: "Attempts" }),
|
|
139
|
+
/* @__PURE__ */ t("th", { children: "Last Error" }),
|
|
140
|
+
/* @__PURE__ */ t("th", { children: "Created" }),
|
|
141
|
+
/* @__PURE__ */ t("th", {})
|
|
142
|
+
] }) }),
|
|
143
|
+
/* @__PURE__ */ t("tbody", { children: g.map((e) => /* @__PURE__ */ n("tr", { children: [
|
|
144
|
+
/* @__PURE__ */ t("td", { style: { maxWidth: "200px" }, children: /* @__PURE__ */ t("span", { title: e.url, style: { fontSize: "0.8rem", fontFamily: "monospace" }, children: y(e.url, 40) }) }),
|
|
145
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.eventType }),
|
|
146
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("span", { className: `cedros-admin__badge cedros-admin__badge--${H(e.status)}`, children: e.status }) }),
|
|
147
|
+
/* @__PURE__ */ n("td", { style: { fontSize: "0.85rem" }, children: [
|
|
148
|
+
e.attempts,
|
|
149
|
+
"/",
|
|
150
|
+
e.maxAttempts
|
|
151
|
+
] }),
|
|
152
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "180px", color: "var(--cedros-admin-text-muted, #888)" }, children: e.lastError ? /* @__PURE__ */ t("span", { title: e.lastError, children: y(e.lastError, 40) }) : "—" }),
|
|
153
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.8rem" }, children: N(e.createdAt) }),
|
|
154
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.25rem" }, children: [
|
|
155
|
+
/* @__PURE__ */ t(
|
|
156
|
+
"button",
|
|
157
|
+
{
|
|
158
|
+
type: "button",
|
|
159
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
160
|
+
onClick: () => U(e.id),
|
|
161
|
+
children: "Retry"
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
/* @__PURE__ */ t(
|
|
165
|
+
"button",
|
|
166
|
+
{
|
|
167
|
+
type: "button",
|
|
168
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
169
|
+
onClick: () => j(e.id),
|
|
170
|
+
style: { color: "var(--cedros-admin-danger, #c00)" },
|
|
171
|
+
children: "Delete"
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
] }) })
|
|
175
|
+
] }, e.id)) })
|
|
176
|
+
] }) })
|
|
177
|
+
] }),
|
|
178
|
+
a === "dlq" && /* @__PURE__ */ t(q, { children: z ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
179
|
+
C.loading,
|
|
180
|
+
" Loading DLQ..."
|
|
181
|
+
] }) : x.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "Dead Letter Queue is empty." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
182
|
+
/* @__PURE__ */ t("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
183
|
+
/* @__PURE__ */ t("th", { children: "URL" }),
|
|
184
|
+
/* @__PURE__ */ t("th", { children: "Event Type" }),
|
|
185
|
+
/* @__PURE__ */ t("th", { children: "Attempts" }),
|
|
186
|
+
/* @__PURE__ */ t("th", { children: "Final Error" }),
|
|
187
|
+
/* @__PURE__ */ t("th", { children: "Moved to DLQ" }),
|
|
188
|
+
/* @__PURE__ */ t("th", {})
|
|
189
|
+
] }) }),
|
|
190
|
+
/* @__PURE__ */ t("tbody", { children: x.map((e) => /* @__PURE__ */ n("tr", { children: [
|
|
191
|
+
/* @__PURE__ */ t("td", { style: { maxWidth: "200px" }, children: /* @__PURE__ */ t("span", { title: e.url, style: { fontSize: "0.8rem", fontFamily: "monospace" }, children: y(e.url, 40) }) }),
|
|
192
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.eventType }),
|
|
193
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.totalAttempts }),
|
|
194
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "200px", color: "var(--cedros-admin-text-muted, #888)" }, children: /* @__PURE__ */ t("span", { title: e.finalError, children: y(e.finalError, 40) }) }),
|
|
195
|
+
/* @__PURE__ */ t("td", { style: { fontSize: "0.8rem" }, children: N(e.movedToDlqAt) }),
|
|
196
|
+
/* @__PURE__ */ t("td", { children: /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.25rem" }, children: [
|
|
197
|
+
/* @__PURE__ */ t(
|
|
198
|
+
"button",
|
|
199
|
+
{
|
|
200
|
+
type: "button",
|
|
201
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
202
|
+
onClick: () => O(e.id),
|
|
203
|
+
children: "Retry"
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
/* @__PURE__ */ t(
|
|
207
|
+
"button",
|
|
208
|
+
{
|
|
209
|
+
type: "button",
|
|
210
|
+
className: "cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",
|
|
211
|
+
onClick: () => X(e.id),
|
|
212
|
+
style: { color: "var(--cedros-admin-danger, #c00)" },
|
|
213
|
+
children: "Delete"
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
] }) })
|
|
217
|
+
] }, e.id)) })
|
|
218
|
+
] }) }) })
|
|
219
|
+
] });
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
Z as WebhooksSection
|
|
223
|
+
};
|
|
@@ -526,6 +526,37 @@ const r = {
|
|
|
526
526
|
require_custody_proof: { type: "toggle", description: "Require a custody proof URL before an asset class can be activated." }
|
|
527
527
|
}
|
|
528
528
|
},
|
|
529
|
+
storage: {
|
|
530
|
+
label: "Image Storage",
|
|
531
|
+
description: "S3-compatible storage for product images",
|
|
532
|
+
secrets: ["access_key_id", "secret_access_key"],
|
|
533
|
+
icon: "🗄️",
|
|
534
|
+
fields: {
|
|
535
|
+
provider: {
|
|
536
|
+
type: "dropdown",
|
|
537
|
+
options: ["digitalocean", "aws", "other"],
|
|
538
|
+
description: "Storage provider (DigitalOcean Spaces, AWS S3, or other S3-compatible)."
|
|
539
|
+
},
|
|
540
|
+
endpoint_url: {
|
|
541
|
+
description: "S3-compatible endpoint URL (e.g., https://nyc3.digitaloceanspaces.com for DO Spaces)."
|
|
542
|
+
},
|
|
543
|
+
bucket_name: {
|
|
544
|
+
description: "Storage bucket name."
|
|
545
|
+
},
|
|
546
|
+
region: {
|
|
547
|
+
description: "Bucket region (e.g., us-east-1, nyc3). Defaults to us-east-1."
|
|
548
|
+
},
|
|
549
|
+
access_key_id: {
|
|
550
|
+
description: "Access key ID for S3-compatible API authentication."
|
|
551
|
+
},
|
|
552
|
+
secret_access_key: {
|
|
553
|
+
description: "Secret access key for S3-compatible API authentication."
|
|
554
|
+
},
|
|
555
|
+
cdn_url: {
|
|
556
|
+
description: "CDN URL prefix for serving images (e.g., https://cdn.example.com). If empty, images are served from the S3 endpoint directly."
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
},
|
|
529
560
|
shop: {
|
|
530
561
|
label: "Storefront",
|
|
531
562
|
description: "Product pages & display settings",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";class o{constructor(e,t,i){this._serverUrl=e,this.auth=t,this.authManager=i}get serverUrl(){return this._serverUrl}async fetch(e,t={}){if(this.authManager?.isAuthenticated())return this.authManager.fetchWithAuth(e,t);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(e=100){return this.fetch(`/admin/config?limit=${e}`)}async getConfig(e,t=!0){return this.fetch(`/admin/config/${e}?redact_secrets=${t}`)}async updateConfig(e,t,i){await this.fetch(`/admin/config/${e}`,{method:"PUT",body:JSON.stringify({config:t,description:i})})}async patchConfig(e,t,i){await this.fetch(`/admin/config/${e}`,{method:"PATCH",body:JSON.stringify({updates:t,description:i})})}async batchUpdate(e){await this.fetch("/admin/config/batch",{method:"POST",body:JSON.stringify({updates:e})})}async validateConfig(e,t){return this.fetch("/admin/config/validate",{method:"POST",body:JSON.stringify({category:e,config:t})})}async getHistory(e,t=50){const i=new URLSearchParams({limit:t.toString()});return e&&i.set("category",e),this.fetch(`/admin/config/history?${i}`)}}const r={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:"Solana RPC endpoint URL. Required for crypto payment verification (e.g., from Helius, QuickNode, or Alchemy)."},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}}},gift_cards:{label:"Gift Cards",description:"Gift card issuance, expiry, and Token-22 secondary market settings",secrets:[],icon:"🎁",fields:{enabled:{hidden:!0},secondary_market_enabled:{type:"toggle",description:"Enable Token-22 secondary market for gift card store credit tokens."},transfer_fee_bps:{type:"number",description:"Transfer fee in basis points charged on secondary market trades (e.g. 250 = 2.5%)."},max_transfer_fee:{type:"number",description:"Maximum transfer fee in token atomic units (e.g. 500 = $5.00 with 2 decimals)."},treasury_address:{type:"solana_address",description:"Solana wallet address where collected transfer fees are sent."},token_name:{description:'Display name for the store credit token (e.g. "Store Credits USD").'},token_symbol:{description:'Token symbol for the store credit token (e.g. "storeUSD").'},token_decimals:{type:"number",description:"Number of decimal places for the token (default: 2 for cent precision)."},mint_address:{type:"solana_address",description:"Solana Token-22 mint address (auto-populated after initialization)."},business_state:{type:"dropdown",options:["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC","PR"],description:"US state where your business is registered. Determines applicable gift card regulations."},min_gift_card_value_cents:{type:"number",description:"Minimum gift card face value in cents. Auto-suggested based on state cash-out threshold."},max_gift_card_value_cents:{type:"number",description:"Maximum gift card face value in cents. Default $10,000 (AML compliance)."},liquidity_pool_address:{type:"solana_address",description:"Meteora DLMM pool address for gift card secondary market buyback."},buyback_rate_bps:{type:"number",description:"Buyback rate in basis points (8000 = 80 cents on the dollar)."},liquidity_usdc_amount:{type:"number",description:"USDC amount deposited into the liquidity pool (in atomic units).",hidden:!0},liquidity_deployed_at:{description:"ISO timestamp when the liquidity pool was deployed.",hidden:!0}}},tokenization:{label:"Asset Tokenization",description:"Settings for tokenized asset classes and on-chain minting",secrets:[],icon:"🪙",fields:{enabled:{type:"toggle",description:"Enable asset tokenization features."},default_transfer_fee_bps:{type:"number",description:"Default transfer fee in basis points for tokenized asset transfers (e.g. 250 = 2.5%)."},require_custody_proof:{type:"toggle",description:"Require a custody proof URL before an asset class can be activated."}}},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 n(s,e){return r[s]?.secrets.includes(e)??!1}const a="[REDACTED]";exports.CONFIG_CATEGORIES=r;exports.ConfigApiClient=o;exports.REDACTED_VALUE=a;exports.isSecretField=n;
|
|
1
|
+
"use strict";class o{constructor(e,t,i){this._serverUrl=e,this.auth=t,this.authManager=i}get serverUrl(){return this._serverUrl}async fetch(e,t={}){if(this.authManager?.isAuthenticated())return this.authManager.fetchWithAuth(e,t);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(e=100){return this.fetch(`/admin/config?limit=${e}`)}async getConfig(e,t=!0){return this.fetch(`/admin/config/${e}?redact_secrets=${t}`)}async updateConfig(e,t,i){await this.fetch(`/admin/config/${e}`,{method:"PUT",body:JSON.stringify({config:t,description:i})})}async patchConfig(e,t,i){await this.fetch(`/admin/config/${e}`,{method:"PATCH",body:JSON.stringify({updates:t,description:i})})}async batchUpdate(e){await this.fetch("/admin/config/batch",{method:"POST",body:JSON.stringify({updates:e})})}async validateConfig(e,t){return this.fetch("/admin/config/validate",{method:"POST",body:JSON.stringify({category:e,config:t})})}async getHistory(e,t=50){const i=new URLSearchParams({limit:t.toString()});return e&&i.set("category",e),this.fetch(`/admin/config/history?${i}`)}}const r={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:"Solana RPC endpoint URL. Required for crypto payment verification (e.g., from Helius, QuickNode, or Alchemy)."},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}}},gift_cards:{label:"Gift Cards",description:"Gift card issuance, expiry, and Token-22 secondary market settings",secrets:[],icon:"🎁",fields:{enabled:{hidden:!0},secondary_market_enabled:{type:"toggle",description:"Enable Token-22 secondary market for gift card store credit tokens."},transfer_fee_bps:{type:"number",description:"Transfer fee in basis points charged on secondary market trades (e.g. 250 = 2.5%)."},max_transfer_fee:{type:"number",description:"Maximum transfer fee in token atomic units (e.g. 500 = $5.00 with 2 decimals)."},treasury_address:{type:"solana_address",description:"Solana wallet address where collected transfer fees are sent."},token_name:{description:'Display name for the store credit token (e.g. "Store Credits USD").'},token_symbol:{description:'Token symbol for the store credit token (e.g. "storeUSD").'},token_decimals:{type:"number",description:"Number of decimal places for the token (default: 2 for cent precision)."},mint_address:{type:"solana_address",description:"Solana Token-22 mint address (auto-populated after initialization)."},business_state:{type:"dropdown",options:["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC","PR"],description:"US state where your business is registered. Determines applicable gift card regulations."},min_gift_card_value_cents:{type:"number",description:"Minimum gift card face value in cents. Auto-suggested based on state cash-out threshold."},max_gift_card_value_cents:{type:"number",description:"Maximum gift card face value in cents. Default $10,000 (AML compliance)."},liquidity_pool_address:{type:"solana_address",description:"Meteora DLMM pool address for gift card secondary market buyback."},buyback_rate_bps:{type:"number",description:"Buyback rate in basis points (8000 = 80 cents on the dollar)."},liquidity_usdc_amount:{type:"number",description:"USDC amount deposited into the liquidity pool (in atomic units).",hidden:!0},liquidity_deployed_at:{description:"ISO timestamp when the liquidity pool was deployed.",hidden:!0}}},tokenization:{label:"Asset Tokenization",description:"Settings for tokenized asset classes and on-chain minting",secrets:[],icon:"🪙",fields:{enabled:{type:"toggle",description:"Enable asset tokenization features."},default_transfer_fee_bps:{type:"number",description:"Default transfer fee in basis points for tokenized asset transfers (e.g. 250 = 2.5%)."},require_custody_proof:{type:"toggle",description:"Require a custody proof URL before an asset class can be activated."}}},storage:{label:"Image Storage",description:"S3-compatible storage for product images",secrets:["access_key_id","secret_access_key"],icon:"🗄️",fields:{provider:{type:"dropdown",options:["digitalocean","aws","other"],description:"Storage provider (DigitalOcean Spaces, AWS S3, or other S3-compatible)."},endpoint_url:{description:"S3-compatible endpoint URL (e.g., https://nyc3.digitaloceanspaces.com for DO Spaces)."},bucket_name:{description:"Storage bucket name."},region:{description:"Bucket region (e.g., us-east-1, nyc3). Defaults to us-east-1."},access_key_id:{description:"Access key ID for S3-compatible API authentication."},secret_access_key:{description:"Secret access key for S3-compatible API authentication."},cdn_url:{description:"CDN URL prefix for serving images (e.g., https://cdn.example.com). If empty, images are served from the S3 endpoint directly."}}},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 n(s,e){return r[s]?.secrets.includes(e)??!1}const a="[REDACTED]";exports.CONFIG_CATEGORIES=r;exports.ConfigApiClient=o;exports.REDACTED_VALUE=a;exports.isSecretField=n;
|