@cedros/pay-react 1.1.22 → 1.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/{AISettingsSection-p3iikbSw.mjs → AISettingsSection-Dw0ZlxMf.mjs} +2 -2
  2. package/dist/{AISettingsSection-BtOxEweU.js → AISettingsSection-IXS1Wt_1.js} +1 -1
  3. package/dist/{AutosaveIndicator-CWbb-VXf.mjs → AutosaveIndicator-BJsg_kFZ.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-C-CH-obR.js → AutosaveIndicator-CY_YHM1D.js} +1 -1
  5. package/dist/{CedrosContext-D-lnoEkR.js → CedrosContext-7dwmEeUY.js} +2 -2
  6. package/dist/{CedrosContext-BE6P5PQ0.mjs → CedrosContext-DQUbL8yP.mjs} +105 -88
  7. package/dist/{CryptoButton-Dy-g3bR0.js → CryptoButton-C1AAOOfj.js} +1 -1
  8. package/dist/{CryptoButton-CksMkZjL.mjs → CryptoButton-D1BCZBk4.mjs} +51 -51
  9. package/dist/{FAQSection-DQpF7hVx.js → FAQSection-BmgmzDN5.js} +1 -1
  10. package/dist/{FAQSection-byh7zfqI.mjs → FAQSection-C78MnK4k.mjs} +1 -1
  11. package/dist/{MessagingSection-B6EHvjDw.js → MessagingSection-CWLZcg11.js} +1 -1
  12. package/dist/{MessagingSection-CK208brx.mjs → MessagingSection-De3t8bSI.mjs} +2 -2
  13. package/dist/OrdersSection-BKOxsZw0.js +1 -0
  14. package/dist/OrdersSection-_xKVzjSZ.mjs +233 -0
  15. package/dist/{PaymentSettingsSection-Cmmuhmd4.js → PaymentSettingsSection-BTEn9Dxb.js} +1 -1
  16. package/dist/{PaymentSettingsSection-B9H253x1.mjs → PaymentSettingsSection-KjU_dN_d.mjs} +1 -1
  17. package/dist/{SettingsSection-DDLMaEPo.mjs → SettingsSection-8QHZB59k.mjs} +1 -1
  18. package/dist/{SettingsSection-DrzGdvHH.js → SettingsSection-cKF0tLnS.js} +1 -1
  19. package/dist/SingleCategorySettings--LK0TZW0.mjs +1006 -0
  20. package/dist/SingleCategorySettings-CRXTMTo5.js +3 -0
  21. package/dist/{StorefrontSection-DTpZ_GgO.js → StorefrontSection-C9DzCmOf.js} +1 -1
  22. package/dist/{StorefrontSection-Dr2ciBVg.mjs → StorefrontSection-CeCpr8hn.mjs} +2 -2
  23. package/dist/{SubscriptionsSection-CU3Ce8r9.mjs → SubscriptionsSection-C2xk8ApF.mjs} +1 -1
  24. package/dist/{SubscriptionsSection-CYJpArJ8.js → SubscriptionsSection-Dn5SY6S_.js} +1 -1
  25. package/dist/Token22Section-DUUl59dZ.js +1 -0
  26. package/dist/Token22Section-HygkDNtL.mjs +1685 -0
  27. package/dist/{WalletManager-QcfgQmap.js → WalletManager-Bwk3rgr1.js} +1 -1
  28. package/dist/{WalletManager-D78miaJ2.mjs → WalletManager-CXvQ0Zu9.mjs} +1 -1
  29. package/dist/bn-Bv2sKQMU.mjs +1185 -0
  30. package/dist/bn-CHyy7EgJ.js +1 -0
  31. package/dist/configApi-Ch0Rr7TD.mjs +554 -0
  32. package/dist/configApi-CxEbCAgG.js +1 -0
  33. package/dist/crypto-only.js +1 -1
  34. package/dist/crypto-only.mjs +54 -52
  35. package/dist/{index-CufXF9Yd.mjs → index-BHF82XBB.mjs} +6687 -5866
  36. package/dist/index-OaWkrl0G.js +84 -0
  37. package/dist/index.js +1 -1
  38. package/dist/index.mjs +34 -32
  39. package/dist/pay-react_false-CPX8Vyp9.mjs +5 -0
  40. package/dist/pay-react_false-DaeIe3_l.js +1 -0
  41. package/dist/{sections-CR7NRsjq.js → sections-8e5Y3ukY.js} +1 -1
  42. package/dist/sections-C1rb9YRh.mjs +9 -0
  43. package/dist/src/components/CreditsBalance.d.ts +24 -0
  44. package/dist/src/components/CreditsBalance.d.ts.map +1 -0
  45. package/dist/src/components/admin/AssetClassesTab.d.ts +20 -0
  46. package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -0
  47. package/dist/src/components/admin/AssetRedemptionManager.d.ts +21 -0
  48. package/dist/src/components/admin/AssetRedemptionManager.d.ts.map +1 -0
  49. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  50. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  51. package/dist/src/components/admin/GiftCardComplianceTab.d.ts +3 -0
  52. package/dist/src/components/admin/GiftCardComplianceTab.d.ts.map +1 -0
  53. package/dist/src/components/admin/LiquidityPoolTab.d.ts +11 -0
  54. package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -0
  55. package/dist/src/components/admin/OrdersSection.d.ts +3 -0
  56. package/dist/src/components/admin/OrdersSection.d.ts.map +1 -0
  57. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  58. package/dist/src/components/admin/RedemptionFormBuilder.d.ts +25 -0
  59. package/dist/src/components/admin/RedemptionFormBuilder.d.ts.map +1 -0
  60. package/dist/src/components/admin/Token22Section.d.ts +3 -0
  61. package/dist/src/components/admin/Token22Section.d.ts.map +1 -0
  62. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  63. package/dist/src/components/admin/index.d.ts +3 -0
  64. package/dist/src/components/admin/index.d.ts.map +1 -1
  65. package/dist/src/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
  66. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  67. package/dist/src/ecommerce/components/catalog/AssetBadge.d.ts +13 -0
  68. package/dist/src/ecommerce/components/catalog/AssetBadge.d.ts.map +1 -0
  69. package/dist/src/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
  70. package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
  71. package/dist/src/ecommerce/components/checkout/CheckoutReceipt.d.ts +9 -2
  72. package/dist/src/ecommerce/components/checkout/CheckoutReceipt.d.ts.map +1 -1
  73. package/dist/src/ecommerce/components/checkout/CheckoutSuccessPage.d.ts +7 -1
  74. package/dist/src/ecommerce/components/checkout/CheckoutSuccessPage.d.ts.map +1 -1
  75. package/dist/src/ecommerce/components/checkout/RedemptionForm.d.ts +22 -0
  76. package/dist/src/ecommerce/components/checkout/RedemptionForm.d.ts.map +1 -0
  77. package/dist/src/ecommerce/components/gift-cards/GiftCardRedemptionPage.d.ts +36 -0
  78. package/dist/src/ecommerce/components/gift-cards/GiftCardRedemptionPage.d.ts.map +1 -0
  79. package/dist/src/ecommerce/components/orders/OrderCard.d.ts.map +1 -1
  80. package/dist/src/ecommerce/components/orders/OrderDetails.d.ts +5 -1
  81. package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
  82. package/dist/src/ecommerce/index.d.ts +6 -0
  83. package/dist/src/ecommerce/index.d.ts.map +1 -1
  84. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +1 -0
  85. package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
  86. package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
  87. package/dist/src/ecommerce/templates/ProductTemplate.d.ts.map +1 -1
  88. package/dist/src/ecommerce/templates/PurchaseHistoryTemplate.d.ts +5 -1
  89. package/dist/src/ecommerce/templates/PurchaseHistoryTemplate.d.ts.map +1 -1
  90. package/dist/src/ecommerce/types.d.ts +20 -0
  91. package/dist/src/ecommerce/types.d.ts.map +1 -1
  92. package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
  93. package/dist/src/ecommerce/utils/safeHref.d.ts +9 -0
  94. package/dist/src/ecommerce/utils/safeHref.d.ts.map +1 -0
  95. package/dist/src/hooks/useCreditsBalance.d.ts +32 -0
  96. package/dist/src/hooks/useCreditsBalance.d.ts.map +1 -0
  97. package/dist/src/index.d.ts +4 -0
  98. package/dist/src/index.d.ts.map +1 -1
  99. package/dist/src/managers/CreditsManager.d.ts +15 -0
  100. package/dist/src/managers/CreditsManager.d.ts.map +1 -1
  101. package/dist/src/managers/MeteoraPoolManager.d.ts +86 -0
  102. package/dist/src/managers/MeteoraPoolManager.d.ts.map +1 -0
  103. package/dist/stripe-only.js +1 -1
  104. package/dist/stripe-only.mjs +2 -2
  105. package/dist/{styles-BWrLnaUW.js → styles-21F1-oqx.js} +1 -1
  106. package/dist/{styles--eKKnfdj.mjs → styles-Ag-7ZvAB.mjs} +46 -46
  107. package/dist/testing/index.js +1 -1
  108. package/dist/testing/index.mjs +1 -1
  109. package/dist/{walletPool-DShNjCQ6.mjs → walletPool-C_0P4mTw.mjs} +1 -1
  110. package/dist/{walletPool-BqNfOhB0.js → walletPool-Ddv33tej.js} +1 -1
  111. package/package.json +10 -1
  112. package/dist/SingleCategorySettings-BU98SRFV.mjs +0 -1418
  113. package/dist/SingleCategorySettings-DqcXe-q4.js +0 -3
  114. package/dist/index-IZ4WcMd7.js +0 -84
  115. package/dist/sections-Bc6ARlND.mjs +0 -8
@@ -0,0 +1,3 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),j=require("./index-OaWkrl0G.js"),N=require("./configApi-CxEbCAgG.js"),K=require("./useAutosave-B2p6iwh8.js"),L=require("./AutosaveIndicator-CY_YHM1D.js"),V=require("./CedrosContext-7dwmEeUY.js"),J=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function M(b){return!b||b.trim()===""?{valid:!0}:J.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function P({label:b,value:f,onChange:h,decimals:n,onDecimalsChange:S,disabled:o=!1,description:a,customSymbol:d="",customIcon:u="",onCustomSymbolChange:c,onCustomIconChange:x}){const[v,E]=l.useState(!1),p=Object.entries(V.STABLECOIN_METADATA),y=!!V.STABLECOIN_METADATA[f],C=v||!!f&&!y,w=t=>{if(t==="custom")E(!0),y&&h("");else{E(!1),h(t);const s=V.STABLECOIN_METADATA[t];s&&S&&S(s.decimals),c&&c(""),x&&x("")}};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:b}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:[p.map(([t,s])=>e.jsxs("button",{type:"button",onClick:()=>w(t),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:f===t?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:f===t?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:f===t?600:400},children:[e.jsx("img",{src:s.icon,alt:s.symbol,style:{width:20,height:20,borderRadius:"50%"},onError:r=>{r.target.style.display="none"}}),e.jsx("span",{children:s.symbol})]},t)),e.jsxs("button",{type:"button",onClick:()=>w("custom"),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:C?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:C?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:C?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Mint Address"}),(()=>{const t=M(f);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${t.valid?"":"cedros-admin__input--error"}`,value:f,onChange:s=>h(s.target.value),placeholder:"e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",disabled:o,style:{fontFamily:"monospace",fontSize:"0.875rem",borderColor:t.valid?void 0:"var(--cedros-admin-error, #dc2626)"}}),!t.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:t.error})]})})()]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:d,onChange:t=>c?.(t.target.value),placeholder:"e.g., MYTOKEN",disabled:o,style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Icon URL"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:u,onChange:t=>x?.(t.target.value),placeholder:"https://example.com/token-logo.png",disabled:o,style:{flex:1}}),u&&e.jsx("img",{src:u,alt:"Token icon preview",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--cedros-admin-border, #e5e7eb)",objectFit:"cover"},onError:t=>{t.target.style.display="none"}})]}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Shown to customers during checkout"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n??6,onChange:t=>S?.(parseInt(t.target.value,10)||0),min:0,max:18,disabled:o,style:{width:"100px"}}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Most SPL tokens use 6 decimals (like USDC)"})]})]}),f&&y&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",fontFamily:"monospace",wordBreak:"break-all"},children:f}),a&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:a})]})]})}function Z({label:b,value:f,onChange:h,disabled:n=!1,description:S}){const[o,a]=l.useState(new Set),[d,u]=l.useState(null),[c,x]=l.useState(""),v=Array.isArray(f)?f:[],E=t=>{a(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},p=()=>{h([...v,""]),u(v.length),x("")},I=(t,s)=>{const r=[...v];r[t]=s,h(r)},y=t=>{const s=v.filter((r,g)=>g!==t);h(s),a(r=>{const g=new Set;return r.forEach(_=>{_<t?g.add(_):_>t&&g.add(_-1)}),g})},T=t=>{u(t),x(v[t]||"")},C=()=>{d!==null&&(I(d,c),u(null),x(""))},w=()=>{d!==null&&v[d]===""&&y(d),u(null),x("")};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",style:{marginBottom:0},children:b}),e.jsxs("button",{type:"button",onClick:p,disabled:n,style:{display:"flex",alignItems:"center",gap:"0.25rem",padding:"0.25rem 0.5rem",fontSize:"0.75rem",border:"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.375rem",background:"var(--cedros-admin-bg, #fff)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:[j.Icons.plus,"Add"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[v.length===0&&e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.875rem",border:"1px dashed var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem"},children:'No items. Click "Add" to create one.'}),v.map((t,s)=>{const r=o.has(s),g=d===s,_=t===N.REDACTED_VALUE;return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.375rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:i=>x(i.target.value),placeholder:"Enter wallet keypair...",autoFocus:!0,style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem"},onKeyDown:i=>{i.key==="Enter"&&C(),i.key==="Escape"&&w()}}),e.jsx("button",{type:"button",onClick:C,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:j.Icons.check}),e.jsx("button",{type:"button",onClick:w,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:j.Icons.close})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r&&!_?t:_?"[REDACTED]":"••••••••••••••••••••"}),e.jsx("button",{type:"button",onClick:()=>E(s),disabled:n||_,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n||_?"not-allowed":"pointer",opacity:n||_?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:r?"Hide":"Show",children:r?j.Icons.eyeOff:j.Icons.eye}),e.jsx("button",{type:"button",onClick:()=>T(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:"Edit",children:j.Icons.settings}),e.jsx("button",{type:"button",onClick:()=>y(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-error, #ef4444)"},title:"Delete",children:j.Icons.trash})]})},s)})]}),S&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:S})]})}function q(b,f,h){const n=N.isSecretField(b,f),S=f.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),a=N.CONFIG_CATEGORIES[b]?.fields?.[f],d={isSecret:n,label:S,description:a?.description,hidden:a?.hidden,showWhen:a?.showWhen};return a?.type==="dropdown"&&a.options?{...d,type:"dropdown",options:a.options}:a?.type==="token_mint"?{...d,type:"token_mint"}:a?.type==="toggle"?{...d,type:"toggle"}:a?.type==="secret_array"?{...d,type:"secret_array",isSecret:!0}:a?.type==="solana_address"?{...d,type:"solana_address"}:a?.type==="number"?{...d,type:"number",unit:a.unit}:typeof h=="boolean"?{...d,type:"boolean"}:typeof h=="number"?{...d,type:"number",unit:a?.unit}:Array.isArray(h)?{...d,type:"array"}:typeof h=="object"&&h!==null?{...d,type:"object"}:{...d,type:"string"}}function X({category:b,config:f,originalConfig:h,isLoading:n=!1,onSave:S}){const[o,a]=l.useState(f),[d,u]=l.useState(new Set);l.useEffect(()=>{a(f)},[f]);const c=l.useMemo(()=>{const t={...o};for(const s of Object.keys(t))if(N.isSecretField(b,s)){const r=h[s],g=t[s];(g===N.REDACTED_VALUE||g===r)&&(t[s]=N.REDACTED_VALUE)}return t},[o,h,b]),x=l.useMemo(()=>{const t=o.token_mint;return typeof t!="string"||!t?!1:!M(t).valid},[o]),{status:v,error:E}=K.useAutosave({data:c,onSave:S,debounceMs:1500,enabled:!x}),p=l.useCallback((t,s)=>{a(r=>({...r,[t]:s}))},[]),I=l.useCallback(t=>{u(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),y=t=>t?e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:t}):null,T=(t,s)=>{const r=q(b,t,h[t]??s);if(r.type==="dropdown"&&r.options)return e.jsx(j.FormDropdown,{value:s,onChange:i=>p(t,i),options:r.options.map(i=>({value:i,label:i})),label:r.label,description:r.description,disabled:n});if(r.type==="token_mint")return e.jsx(P,{label:r.label,value:s,onChange:i=>p(t,i),decimals:o.token_decimals??6,onDecimalsChange:i=>p("token_decimals",i),disabled:n,description:r.description,customSymbol:o.custom_token_symbol||"",customIcon:o.custom_token_icon||"",onCustomSymbolChange:i=>p("custom_token_symbol",i),onCustomIconChange:i=>p("custom_token_icon",i)});if(r.type==="toggle")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>p(t,!s),disabled:n,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:n?"not-allowed":"pointer",position:"relative",transition:"background-color 0.2s",opacity:n?.5:1,flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:2,left:s?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{className:"cedros-admin__field-label",style:{marginBottom:0},children:r.label})]}),y(r.description)]});if(r.type==="solana_address"){const i=s||"",k=M(i);return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${k.valid?"":"cedros-admin__input--error"}`,value:i,onChange:D=>p(t,D.target.value),disabled:n,placeholder:"e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",style:{width:"100%",fontFamily:"monospace",fontSize:"0.875rem",borderColor:k.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:i&&k.valid?"2rem":void 0}}),i&&k.valid&&e.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:"var(--cedros-admin-success, #16a34a)",fontSize:"1rem"},title:"Valid Solana address",children:"✓"})]}),!k.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:k.error}),y(r.description)]})}if(r.type==="boolean")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:i=>p(t,i.target.checked),disabled:n}),r.label]}),y(r.description)]});if(r.type==="number")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.unit&&e.jsxs("span",{className:"cedros-admin__field-unit",children:[" (",r.unit,")"]})]}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s,onChange:i=>p(t,parseFloat(i.target.value)||0),disabled:n}),y(r.description)]});if(r.type==="secret_array")return e.jsx(Z,{label:r.label,value:s,onChange:i=>p(t,i),disabled:n,description:r.description});if(r.type==="array"){const i=s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea",value:i.join(`
2
+ `),onChange:k=>p(t,k.target.value.split(`
3
+ `).filter(Boolean)),placeholder:"One item per line",rows:3,disabled:n}),y(r.description)]})}if(r.type==="object")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea cedros-admin__textarea--mono",value:JSON.stringify(s,null,2),onChange:i=>{try{p(t,JSON.parse(i.target.value))}catch{}},rows:5,disabled:n}),y(r.description)]});const g=d.has(t),_=r.isSecret&&!g&&s===N.REDACTED_VALUE?N.REDACTED_VALUE:s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.isSecret&&e.jsx("span",{className:"cedros-admin__field-secret",children:" (secret)"})]}),e.jsxs("div",{className:"cedros-admin__input-group",children:[e.jsx("input",{type:r.isSecret&&!g?"password":"text",className:"cedros-admin__input",value:_,onChange:i=>p(t,i.target.value),disabled:n,placeholder:r.isSecret?"••••••••":""}),r.isSecret&&e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>I(t),style:{padding:"0.5rem",minWidth:"auto"},title:g?"Hide":"Show",children:g?j.Icons.eyeOff:j.Icons.eye})]}),y(r.description)]})},C=Object.keys(o),w=t=>{const s=q(b,t,h[t]??o[t]);if(s.hidden||s.showWhen&&!o[s.showWhen])return!1;if(t==="token_decimals"){const r=o.token_mint;if(r&&V.STABLECOIN_METADATA[r])return!1}return!0};return e.jsxs("div",{className:"cedros-admin__config-editor",children:[e.jsx("div",{className:"cedros-admin__config-fields",children:C.filter(w).map(t=>e.jsx("div",{className:"cedros-admin__config-field",children:T(t,o[t])},t))}),e.jsx("div",{className:"cedros-admin__config-actions",children:e.jsx("div",{className:"cedros-admin__autosave-status",children:e.jsx(L.AutosaveIndicator,{status:v,error:E})})})]})}function Y({serverUrl:b,apiKey:f,authManager:h,category:n,title:S,description:o,enabledField:a="enabled",showEnabledToggle:d=!1}){const u=l.useMemo(()=>new N.ConfigApiClient(b,void 0,h),[b,h]),[c,x]=l.useState(null),[v,E]=l.useState([]),[p,I]=l.useState(!1),[y,T]=l.useState(!0),[C,w]=l.useState(null),[t,s]=l.useState(null),[r,g]=l.useState(!1),_=N.CONFIG_CATEGORIES[n]||{label:n,icon:"⚙️"},i=S||_.label,k=o||_.description,D=l.useCallback(async()=>{T(!0),w(null);try{const m=await u.getConfig(n,!0);x(m)}catch{x(null),w("Failed to load settings")}finally{T(!1)}},[u,n]);l.useEffect(()=>{D()},[D]);const B=l.useCallback(async()=>{try{const m=await u.getHistory(n,20);E(m.history)}catch{E([])}},[u,n]);l.useEffect(()=>{p&&B()},[p,B]);const U=l.useCallback(async m=>{await u.updateConfig(n,m,"Updated via admin dashboard")},[u,n]),F=l.useCallback(async m=>u.validateConfig(n,m),[u,n]),[z,O]=l.useState(!1),G=l.useCallback(async()=>{if(!c||z)return;const m=!!c.config[a],R=!m,W={...c.config,[a]:R};O(!0),x({...c,config:W});try{await u.updateConfig(n,W,`${R?"Enabled":"Disabled"} via admin dashboard`)}catch(H){x({...c,config:{...c.config,[a]:m}}),w(H instanceof Error?H.message:"Failed to save enabled state")}finally{O(!1)}},[c,u,n,a,z]),A=!!c?.config[a];return y&&!c?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[j.Icons.loading," Loading ",i," settings..."]})}):e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx(j.ErrorBanner,{message:C,onRetry:D}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[e.jsx("span",{style:{marginRight:"0.5rem"},children:_.icon}),i]}),k&&e.jsx("p",{className:"cedros-admin__text-muted",style:{marginTop:"0.25rem"},children:k})]}),d&&c&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:A?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:A?"Enabled":"Disabled"}),e.jsx("button",{type:"button",role:"switch","aria-checked":A,onClick:G,disabled:z,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:A?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:z?"wait":"pointer",position:"relative",transition:"background-color 0.2s",flexShrink:0,opacity:z?.6:1},children:e.jsx("span",{style:{position:"absolute",top:2,left:A?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})]}),c&&e.jsxs("div",{className:"cedros-admin__settings-editor",style:{marginTop:"1rem",opacity:d&&!A?.6:1,pointerEvents:d&&!A?"none":"auto"},children:[d&&!A&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)",pointerEvents:"auto"},children:"This payment method is disabled. Enable it using the toggle above to accept payments."}),e.jsx(X,{category:c.category,config:c.config,originalConfig:c.config,onSave:U,onValidate:F})]}),p&&e.jsxs("div",{className:"cedros-admin__settings-history",style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{marginBottom:"0.75rem",fontWeight:600},children:"Change History"}),v.length===0?e.jsx("p",{className:"cedros-admin__text-muted",children:"No history entries found."}):e.jsx("div",{className:"cedros-admin__settings-timeline",children:v.map(m=>e.jsxs("div",{className:"cedros-admin__settings-timeline-item",children:[e.jsx("div",{className:"cedros-admin__settings-timeline-dot"}),e.jsxs("div",{className:"cedros-admin__settings-timeline-content",children:[e.jsxs("div",{className:"cedros-admin__settings-timeline-header",children:[e.jsx("code",{children:m.configKey}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${m.action.toLowerCase()}`,children:m.action})]}),e.jsxs("div",{className:"cedros-admin__settings-timeline-meta",children:[j.formatDateTime(m.changedAt)," by ",m.changedBy]})]})]},m.id))})]}),t&&e.jsx("div",{style:{marginTop:"1rem",padding:"0.75rem 1rem",borderRadius:"0.375rem",backgroundColor:t.valid?"var(--cedros-admin-success-bg, #dcfce7)":"var(--cedros-admin-error-bg, #fef2f2)",border:`1px solid ${t.valid?"var(--cedros-admin-success-border, #86efac)":"var(--cedros-admin-error-border, #fecaca)"}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:t.valid?"var(--cedros-admin-success, #16a34a)":"var(--cedros-admin-error, #dc2626)",marginBottom:t.errors.length>0||t.warnings.length>0?"0.5rem":0},children:t.valid?"✓ Configuration is valid":"✗ Validation failed"}),t.errors.length>0&&e.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.875rem"},children:t.errors.map((m,R)=>e.jsx("li",{children:m},R))}),t.warnings.length>0&&e.jsx("ul",{style:{margin:t.errors.length>0?"0.5rem 0 0":0,paddingLeft:"1.25rem",color:"var(--cedros-admin-warning, #ca8a04)",fontSize:"0.875rem"},children:t.warnings.map((m,R)=>e.jsx("li",{children:m},R))})]}),e.jsx("button",{type:"button",onClick:()=>s(null),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"1.25rem",lineHeight:1},title:"Dismiss",children:"×"})]})}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>I(!p),children:p?"Hide History":"History"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r||!c,onClick:async()=>{if(c){g(!0),s(null);try{const m=await F(c.config);s(m)}catch(m){s({valid:!1,errors:[m instanceof Error?m.message:"Validation failed"],warnings:[]})}finally{g(!1)}}},children:r?"Validating...":"Validate"})]})]})}exports.SingleCategorySettings=Y;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-IZ4WcMd7.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-C-CH-obR.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-OaWkrl0G.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-CY_YHM1D.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
@@ -1,9 +1,9 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
2
  import { useState as h, useCallback as z, useEffect as j } from "react";
3
- import { I as H, E as V, F as x } from "./index-CufXF9Yd.mjs";
3
+ import { I as H, E as V, F as x } from "./index-BHF82XBB.mjs";
4
4
  import { T as d } from "./Toggle-DAxIdpY4.mjs";
5
5
  import { u as q } from "./useAutosave-YwMqRzqy.mjs";
6
- import { A as X } from "./AutosaveIndicator-CWbb-VXf.mjs";
6
+ import { A as X } from "./AutosaveIndicator-BJsg_kFZ.mjs";
7
7
  const C = {
8
8
  enabled: !0,
9
9
  relatedProducts: {
@@ -1,6 +1,6 @@
1
1
  import { jsx as a, jsxs as i } from "react/jsx-runtime";
2
2
  import { useState as g, useCallback as F, useEffect as D, useMemo as E } from "react";
3
- import { I as h, E as Z, f as K } from "./index-CufXF9Yd.mjs";
3
+ import { I as h, E as Z, g as K } from "./index-BHF82XBB.mjs";
4
4
  const l = {
5
5
  enabled: !1,
6
6
  plans: [],
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-IZ4WcMd7.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),m({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),m({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return j("Failed to save subscription settings"),!1}},[f,b,v]),E=d.useMemo(()=>x.enabled!==l.enabled||x.pageTitle!==l.pageTitle||x.pageSubtitle!==l.pageSubtitle||x.annualSavingsBadge!==l.annualSavingsBadge||x.popularBadgeText!==l.popularBadgeText||x.footerNotice!==l.footerNotice,[l,x]),D=d.useMemo(()=>JSON.stringify(r.plans),[r.plans]),U=d.useMemo(()=>F!==D,[D,F]),S=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await I(e);h(e),t&&(P({enabled:e.enabled,pageTitle:e.pageTitle,pageSubtitle:e.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge,popularBadgeText:e.popularBadgeText,footerNotice:e.footerNotice}),C(JSON.stringify(e.plans))),B(t?"saved":"error"),setTimeout(()=>B("idle"),1500)},[l,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(g=>g.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>m(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>m(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>m(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>m(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>m(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?u.Icons.chevronDown:u.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:u.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:u.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:u.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>Q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:g=>J(e.id,o,g.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-OaWkrl0G.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),m({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),m({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return j("Failed to save subscription settings"),!1}},[f,b,v]),E=d.useMemo(()=>x.enabled!==l.enabled||x.pageTitle!==l.pageTitle||x.pageSubtitle!==l.pageSubtitle||x.annualSavingsBadge!==l.annualSavingsBadge||x.popularBadgeText!==l.popularBadgeText||x.footerNotice!==l.footerNotice,[l,x]),D=d.useMemo(()=>JSON.stringify(r.plans),[r.plans]),U=d.useMemo(()=>F!==D,[D,F]),S=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await I(e);h(e),t&&(P({enabled:e.enabled,pageTitle:e.pageTitle,pageSubtitle:e.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge,popularBadgeText:e.popularBadgeText,footerNotice:e.footerNotice}),C(JSON.stringify(e.plans))),B(t?"saved":"error"),setTimeout(()=>B("idle"),1500)},[l,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(g=>g.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>m(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>m(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>m(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>m(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>m(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?u.Icons.chevronDown:u.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:u.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:u.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:u.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>Q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:g=>J(e.id,o,g.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
@@ -0,0 +1 @@
1
+ "use strict";var Se=Object.create;var ue=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ae=(t,s,n,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of ke(s))!Te.call(t,r)&&r!==n&&ue(t,r,{get:()=>s[r],enumerable:!(i=Ce(s,r))||i.enumerable});return t};var me=(t,s,n)=>(n=t!=null?Se(we(t)):{},Ae(s||!t||!t.__esModule?ue(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),pe=require("./index-OaWkrl0G.js"),re=require("./configApi-CxEbCAgG.js"),be=[{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"}],he={fields:[],requiresApproval:!0},E={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},O={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Y={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function Ne(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function ge({field:t,onSave:s,onCancel:n}){const[i,r]=d.useState(t),[o,u]=d.useState(""),m=l=>r(h=>({...h,...l})),y=()=>{const l=o.trim();l&&(m({options:[...i.options,l]}),u(""))};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:O,children:"Label *"}),e.jsx("input",{style:E,value:i.label,onChange:l=>m({label:l.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Field Type"}),e.jsx("select",{style:E,value:i.fieldType,onChange:l=>m({fieldType:l.target.value,options:[]}),children:be.map(l=>e.jsx("option",{value:l.value,children:l.label},l.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:O,children:"Placeholder"}),e.jsx("input",{style:E,value:i.placeholder??"",onChange:l=>m({placeholder:l.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:i.required,onChange:l=>m({required:l.target.checked})})," Required"]})]}),i.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:O,children:"Options"}),i.options.map((l,h)=>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:l}),e.jsx("button",{type:"button",onClick:()=>m({options:i.options.filter((f,_)=>_!==h)}),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"})]},h)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...E,flex:1},value:o,onChange:l=>u(l.target.value),onKeyDown:l=>l.key==="Enter"&&(l.preventDefault(),y()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:y,style:Y,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>s(i),disabled:!i.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:i.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:i.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Y,children:"Cancel"})]})]})}function ze({fields:t,instructions:s}){const n={...E,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"}),s&&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:s}),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(i=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[i.label||"Unlabelled field",i.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),i.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:i.placeholder??"",style:{...n,resize:"none"}}),i.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"}),i.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:i.placeholder||"Select..."}),i.options.map((r,o)=>e.jsx("option",{children:r},o))]}),!["textarea","file_upload","dropdown"].includes(i.fieldType)&&e.jsx("input",{disabled:!0,type:i.fieldType==="email"?"email":i.fieldType==="phone"?"tel":"text",placeholder:i.placeholder??"",style:n})]},i.id))]})}function Be({value:t,onChange:s}){const n=t!==null,i=t??he,[r,o]=d.useState(null),[u,m]=d.useState(null),[y,l]=d.useState(!1),h=p=>s({...i,...p}),f=()=>{o(null),m(null)},_=p=>{s(p?{...he}:null),f()},b=()=>{const p=Ne();m(p),o("new")},g=p=>{m({...p}),o(p.id)},j=p=>{h({fields:r==="new"?[...i.fields,p]:i.fields.map(C=>C.id===p.id?p:C)}),f()},k=p=>{r===p&&f(),h({fields:i.fields.filter(C=>C.id!==p)})};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:p=>_(p.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:O,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:i.instructions??"",onChange:p=>h({instructions:p.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...E,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:i.requiresApproval,onChange:p=>h({requiresApproval:p.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:i.estimatedProcessingDays??"",onChange:p=>h({estimatedProcessingDays:p.target.value?Number(p.target.value):void 0}),placeholder:"e.g., 5",style:{...E,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",i.fields.length,")"]}),i.fields.length===0&&r!=="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:[i.fields.map(p=>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:p.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:be.find(C=>C.value===p.fieldType)?.label??p.fieldType}),p.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:()=>g(p),style:{...Y,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(p.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"})]})]}),r===p.id&&u&&e.jsx(ge,{field:u,onSave:j,onCancel:f})]},p.id)),r==="new"&&u&&e.jsx(ge,{field:u,onSave:j,onCancel:f})]}),r===null&&e.jsx("button",{type:"button",onClick:b,style:{...Y,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>l(p=>!p),style:{...Y,background:y?"rgba(0,0,0,0.05)":"white"},children:y?"Hide Preview":"Show Preview"}),y&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(ze,{fields:i.fields,instructions:i.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 De({c:t,onDeployPool:s,onEdit:n,onDelete:i}){const r=t.tokenizationConfig,o=Me(r.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:o?"#dbeafe":"#fef3c7",color:o?"#1d4ed8":"#92400e"},children:r.assetClass}),r.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:r.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[r.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),o&&r.mintAddress&&(r.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",r.liquidityPoolAddress.slice(0,4),"...",r.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:s,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: ",r.transferFeeBps," bps"]}),r.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",r.treasuryAddress.slice(0,8),"..."]}),r.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[r.allowedJurisdictions.length," jurisdiction",r.allowedJurisdictions.length!==1?"s":"",": ",r.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"}),i&&e.jsx("button",{type:"button",onClick:i,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 ne={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Re({serverUrl:t,apiKey:s,authManager:n,onNavigateToLiquidity:i}){const[r,o]=d.useState([]),[u,m]=d.useState(!0),[y,l]=d.useState(null),[h,f]=d.useState(!1),[_,b]=d.useState(!1),[g,j]=d.useState(ne),[k,p]=d.useState(null),C=d.useCallback(async(c,x)=>{if(n?.isAuthenticated())return n.fetchWithAuth(c,x);const D={"Content-Type":"application/json"};s&&(D["X-API-Key"]=s);const v=await fetch(`${t}${c}`,{...x,headers:{...D,...x?.headers}});if(!v.ok){const N=await v.text().catch(()=>`HTTP ${v.status}`);throw new Error(N)}return v.json()},[t,s,n]),w=d.useCallback(async()=>{try{m(!0),l(null);const c=await C("/admin/collections");o((c.collections||[]).filter(x=>x.tokenizationConfig))}catch(c){l(c instanceof Error?c.message:"Failed to load asset classes")}finally{m(!1)}},[C]);d.useEffect(()=>{w()},[w]);const a=()=>({name:g.name.trim(),description:g.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:g.assetClass,tokenSymbol:g.tokenSymbol||void 0,tokenDecimals:g.tokenDecimals,transferFeeBps:g.transferFeeBps,maxTransferFee:g.maxTransferFee,treasuryAddress:g.treasuryAddress||void 0,regulatoryNotice:g.regulatoryNotice||void 0,allowedJurisdictions:g.jurisdictions?g.jurisdictions.split(",").map(c=>c.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:g.redemptionConfig||void 0}}),S=async()=>{if(g.name.trim()){b(!0),l(null);try{k?await C(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(a())}):await C("/admin/collections",{method:"POST",body:JSON.stringify(a())}),j(ne),f(!1),p(null),await w()}catch(c){l(c instanceof Error?c.message:`Failed to ${k?"update":"create"} asset class`)}finally{b(!1)}}},A=c=>{const x=c.tokenizationConfig;j({name:c.name,description:c.description??"",assetClass:x.assetClass,tokenSymbol:x.tokenSymbol??"",tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee,treasuryAddress:x.treasuryAddress??"",regulatoryNotice:x.regulatoryNotice??"",jurisdictions:x.allowedJurisdictions.join(", "),redemptionConfig:null}),p(c.id),f(!0)},T=async c=>{if(window.confirm(`Delete asset class "${c.name}"? This cannot be undone.`)){l(null);try{await C(`/admin/collections/${encodeURIComponent(c.id)}`,{method:"DELETE"}),await w()}catch(x){l(x instanceof Error?x.message:"Failed to delete asset class")}}};return u?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[y&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:y}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",r.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{f(!h),h&&(p(null),j(ne))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:h?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:h?"Cancel":"+ New Asset Class"})]}),h&&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:g.name,onChange:c=>j(x=>({...x,name:c.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:g.assetClass,onChange:c=>j(x=>({...x,assetClass:c.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(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})]})]}),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:g.tokenSymbol,onChange:c=>j(x=>({...x,tokenSymbol:c.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:g.transferFeeBps,onChange:c=>j(x=>({...x,transferFeeBps:Number(c.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:g.treasuryAddress,onChange:c=>j(x=>({...x,treasuryAddress:c.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:g.jurisdictions,onChange:c=>j(x=>({...x,jurisdictions:c.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:g.regulatoryNotice,onChange:c=>j(x=>({...x,regulatoryNotice:c.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(Be,{value:g.redemptionConfig,onChange:c=>j(x=>({...x,redemptionConfig:c}))})]}),e.jsx("button",{type:"button",onClick:S,disabled:_||!g.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:_?"wait":"pointer",fontSize:"0.9rem",opacity:_?.6:1},children:_?"Saving...":k?"Save Changes":"Create Asset Class"})]}),r.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:r.map(c=>e.jsx(De,{c,onDeployPool:i,onEdit:()=>A(c),onDelete:()=>T(c)},c.id))})]})}const Ie=[{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 Fe(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 Le(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ee(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function q(t){return t.length>12?`${t.slice(0,8)}…`:t}function ye(t){return`https://solscan.io/tx/${t}`}function Oe({redemption:t,onAction:s,onComplete:n,actionBusy:i}){const[r,o]=d.useState(t.adminNotes??""),u=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"}),u.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:u.map(([m,y])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:m},`k-${m}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(y??"—")},`v-${m}`)]}))}),(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:ye(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:q(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:ye(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:q(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:r,onChange:m=>o(m.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:i,onClick:()=>s(t.id,"under_review",r),children:i?"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:i,onClick:()=>s(t.id,"approved",r),children:i?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"rejected",r),children:i?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>n(t.id),children:i?"Processing...":"Complete"})]})]})]})})}function qe({serverUrl:t,apiKey:s,authManager:n}){const[i,r]=d.useState([]),[o,u]=d.useState(!0),[m,y]=d.useState(null),[l,h]=d.useState(""),[f,_]=d.useState(null),[b,g]=d.useState(null),j=d.useCallback(async(a,S)=>{if(n?.isAuthenticated())return n.fetchWithAuth(a,S);const A={"Content-Type":"application/json"};s&&(A["X-API-Key"]=s);const T=await fetch(`${t}${a}`,{...S,headers:{...A,...S?.headers}});if(!T.ok){const c=await T.text().catch(()=>`HTTP ${T.status}`);throw new Error(c)}return T.json()},[t,s,n]),k=d.useCallback(async()=>{u(!0),y(null);try{const a=l?`?status=${encodeURIComponent(l)}&limit=50&offset=0`:"?limit=50&offset=0",S=await j(`/admin/asset-redemptions${a}`);r(S.redemptions??[])}catch(a){y(a instanceof Error?a.message:"Failed to load redemptions")}finally{u(!1)}},[j,l]);d.useEffect(()=>{k()},[k]);const p=d.useCallback(async(a,S,A)=>{g(a),y(null);try{await j(`/admin/asset-redemptions/${a}/status`,{method:"PATCH",body:JSON.stringify({status:S,adminNotes:A})}),_(null),await k()}catch(T){y(T instanceof Error?T.message:"Failed to update status")}finally{g(null)}},[j,k]),C=d.useCallback(async a=>{g(a),y(null);try{await j(`/admin/asset-redemptions/${a}/complete`,{method:"POST"}),_(null),await k()}catch(S){y(S instanceof Error?S.message:"Failed to complete redemption")}finally{g(null)}},[j,k]),w=a=>{_(S=>S===a?null:a)};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:l,onChange:a=>{h(a.target.value),_(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:Ie.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:o,children:o?"Loading...":"Refresh"})})]}),m&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:m}),o?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):i.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:i.map(a=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>w(a.id),children:[e.jsx("td",{children:Ee(a.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:a.orderId,children:q(a.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:a.productId,children:q(a.productId)})}),e.jsx("td",{children:e.jsx("code",{title:a.collectionId,children:q(a.collectionId)})}),e.jsx("td",{children:a.userId?e.jsx("code",{title:a.userId,children:q(a.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:Fe(a.status),children:Le(a.status)})}),e.jsx("td",{onClick:S=>S.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(a.status==="info_submitted"||a.status==="under_review"||a.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(a.id),children:f===a.id?"Close":"Review"}),a.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:b===a.id,onClick:()=>p(a.id,"approved",a.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:b===a.id,onClick:()=>p(a.id,"rejected",a.adminNotes??""),children:"Reject"})]}),a.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:b===a.id,onClick:()=>C(a.id),children:b===a.id?"Processing...":"Complete"})]})})]},a.id),f===a.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(Oe,{redemption:a,onAction:p,onComplete:C,actionBusy:b===a.id})})},`${a.id}-detail`)]}))})]})})]})}const $e={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}},ae={escheatmentYears:5},V=1e6,We={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 Ye({serverUrl:t,authManager:s}){const[n,i]=d.useState(null),[r,o]=d.useState(null),[u,m]=d.useState(null),[y,l]=d.useState(!0),h=d.useCallback(async()=>{try{const j=(await new re.ConfigApiClient(t,void 0,s).getConfig("gift_cards")).config??{};i(j.business_state||null),o(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),m(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{l(!1)}},[t,s]);if(d.useEffect(()=>{h()},[h]),y)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const f=n?$e[n]??ae:null,_=n?We[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 — ",_]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Ke,{reg:f,minValueCents:r}),e.jsx(He,{reg:f}),e.jsx(Ge,{reg:f}),e.jsx(Je,{maxValueCents:u})]}),e.jsx(Ve,{reg:f,minValueCents:r,maxValueCents:u})]}):e.jsx(Ue,{})})}function Ue(){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 U({title:t,children:s}){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:s})]})}function Ke({reg:t,minValueCents:s}){if(!t.cashOutCents)return e.jsx(U,{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),i=s!=null&&s>t.cashOutCents;return e.jsxs(U,{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."]}),i?e.jsxs(X,{ok:!0,children:["Min value ($",((s??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(X,{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 He({reg:t}){return e.jsx(U,{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 Ge({reg:t}){const s=t.escheatmentYears??ae.escheatmentYears;return e.jsxs(U,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[s," 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 Je({maxValueCents:t}){const s=t??V,n=s<=V;return e.jsxs(U,{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(X,{ok:!0,children:["Max value ($",(s/100).toFixed(2),") within AML limit"]}):e.jsxs(X,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function X({ok:t,children:s}){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?"✓":"⚠"}),s]})}function Ve({reg:t,minValueCents:s,maxValueCents:n}){const r=[{label:"AML: Max card value ≤ $10,000",ok:(n??V)<=V},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:s!=null&&s>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ae.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:r.map((o,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:o.ok?"#16a34a":"#d97706",fontWeight:600},children:o.ok?"✓":"⚠"}),e.jsx("span",{children:o.label})]},u))})]})}const Xe=0;class Ze{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const s=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=s.default??s,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 s=await Promise.resolve().then(()=>require("./bn-CHyy7EgJ.js")).then(n=>n.bn);return this.bnClass=s.default??s,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:s}=await import("@solana/web3.js");return this.keypairClass=s,this.keypairClass}async computeBinId(s,n,i,r=1){const o=await this.loadDLMM(),u=o.getPricePerLamport(n,i,s);return o.getBinIdFromPrice(u,r,!0)}async findPresetParameter(s,n,i){const r=await this.loadDLMM(),o=i?{cluster:i}:void 0,{presetParameter2:u}=await r.getAllPresetParameters(s,o),m=u.find(y=>y.account.binStep===n);if(!m)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${u.map(y=>y.account.binStep).join(", ")}`);return m.publicKey}async createPool(s,n,i,r,o,u=1,m){const y=await this.loadDLMM(),l=await this.loadBN(),h=m?{cluster:m}:void 0,f=await this.findPresetParameter(s,u,m),_=await y.createLbPair2(s,n,i,r,f,new l(o),h),b=_.instructions[0]?.keys?.[1]?.pubkey;if(!b)throw new Error("Failed to extract pool address from transaction");return{transaction:_,poolAddress:b}}async addBuybackLiquidity(s,n,i,r,o,u){const m=await this.loadDLMM(),y=await this.loadBN(),l=await this.loadKeypair(),h=u?{cluster:u}:void 0,f=await m.create(s,i,h),_=l.generate(),b=o-1,g=o;return{transaction:await f.initializePositionAndAddLiquidityByStrategy({positionPubKey:_.publicKey,totalXAmount:new y(0),totalYAmount:new y(r),strategy:{maxBinId:g,minBinId:b,strategyType:Xe},user:n,slippage:1}),positionKeypair:_}}async getPoolStatus(s,n,i){const r=await this.loadDLMM(),o=i?{cluster:i}:void 0,u=await r.create(s,n,o),m=await u.getActiveBin();return{address:n.toBase58(),activeBinId:m.binId,activeBinPrice:m.price,binStep:u.lbPair.binStep}}}const W=6,ie=1,Qe="https://solscan.io/account",et="https://app.meteora.ag/dlmm";function tt({serverUrl:t,authManager:s,mintConfigured:n,mintAddress:i,tokenDecimals:r=2}){const[o,u]=d.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[m,y]=d.useState(!0),[l,h]=d.useState(80),[f,_]=d.useState(250),[b,g]=d.useState("idle"),[j,k]=d.useState(null),[p,C]=d.useState(null),[w,a]=d.useState(null),S=d.useRef(new Ze),A=d.useCallback(async()=>{try{const z=new re.ConfigApiClient(t,void 0,s),[R,F]=await Promise.all([z.getConfig("gift_cards"),z.getConfig("x402")]),B=R.config??{},P=F.config??{},M=B.liquidity_pool_address||null;u({liquidityPoolAddress:M,buybackRateBps:B.buyback_rate_bps!=null?Number(B.buyback_rate_bps):null,rpcUrl:P.rpc_url||null,usdcMint:P.token_mint||null,usdcAmount:B.liquidity_usdc_amount!=null?Number(B.liquidity_usdc_amount):null,deployedAt:B.liquidity_deployed_at||null}),M&&C(M),B.buyback_rate_bps!=null&&h(Number(B.buyback_rate_bps)/100)}catch{}finally{y(!1)}},[t,s]);d.useEffect(()=>{A()},[A]);const T=typeof window<"u"&&!!window.solana?.publicKey,c=!!o.rpcUrl,x=!!o.usdcMint,D=n&&T&&c&&x&&b==="idle",v=async z=>{if(!(!i||!o.rpcUrl||!o.usdcMint)){g(z),k(null),a(null);try{const{Connection:R,PublicKey:F,Keypair:B}=await import("@solana/web3.js"),P=new R(o.rpcUrl,"confirmed"),M=window.solana;if(!M?.publicKey||!M.signTransaction)throw new Error("Wallet not connected");const H=S.current,oe=new F(M.publicKey.toBase58()),je=l/100,ve=await H.computeBinId(je,r,W,ie);let L=p;if(z==="creating_pool"){const $=new F(i),Z=new F(o.usdcMint),G=await H.computeBinId(1,r,W,ie),{transaction:Q,poolAddress:ee}=await H.createPool(P,oe,$,Z,G,ie),te=await M.signTransaction(Q),se=await P.sendRawTransaction(te.serialize());await P.confirmTransaction(se,"confirmed"),L=ee.toBase58(),C(L)}if(z==="creating_pool"||z==="adding_liquidity"){if(g("adding_liquidity"),!L)throw new Error("Pool address not available");const $=new F(L),Z=Math.round(f*10**W),{transaction:G,positionKeypair:Q}=await H.addBuybackLiquidity(P,oe,$,Z,ve),ee=B.fromSecretKey(Q.secretKey);G.partialSign(ee);const te=await M.signTransaction(G),se=await P.sendRawTransaction(te.serialize());await P.confirmTransaction(se,"confirmed")}if(g("saving_config"),!L)throw new Error("Pool address not available");const _e=new re.ConfigApiClient(t,void 0,s),le=Math.round(l*100),de=Math.round(f*10**W),ce=new Date().toISOString();await _e.patchConfig("gift_cards",{liquidity_pool_address:L,buyback_rate_bps:le,liquidity_usdc_amount:de,liquidity_deployed_at:ce},"Meteora DLMM pool deployed for gift card buyback"),u($=>({...$,liquidityPoolAddress:L,buybackRateBps:le,usdcAmount:de,deployedAt:ce})),g("done")}catch(R){a(b==="idle"?z:b),k(R instanceof Error?R.message:"Deployment failed"),g("error")}}},N=()=>{D&&v("creating_pool")},K=()=>{!w||w==="idle"||w==="done"||w==="error"||v(w)};return m?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):o.liquidityPoolAddress?e.jsx(it,{poolAddress:o.liquidityPoolAddress,buybackRateBps:o.buybackRateBps,usdcAmount:o.usdcAmount,deployedAt:o.deployedAt}):b!=="idle"&&b!=="error"?e.jsx(nt,{step:b,poolAddress:p}):e.jsx(st,{buybackCents:l,setBuybackCents:h,usdcAmount:f,setUsdcAmount:_,mintConfigured:n,walletConnected:T,hasRpcUrl:c,hasUsdcMint:x,canDeploy:D,onDeploy:N,errorMessage:j,canRetry:!!w&&w!=="creating_pool",onRetry:K})}function st({buybackCents:t,setBuybackCents:s,usdcAmount:n,setUsdcAmount:i,mintConfigured:r,walletConnected:o,hasRpcUrl:u,hasUsdcMint:m,canDeploy:y,onDeploy:l,errorMessage:h,canRetry:f,onRetry:_}){const b=((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:g=>s(Math.max(1,Math.min(99,parseInt(g.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",b," 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:g=>i(Math.max(1,parseFloat(g.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(J,{label:"Token-22 mint initialized",met:r}),e.jsx(J,{label:"Wallet connected",met:o}),e.jsx(J,{label:"RPC URL configured",met:u}),e.jsx(J,{label:"USDC mint configured",met:m})]}),h&&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:h}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:f?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:_,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:l,disabled:!y,children:"Deploy Liquidity Pool"})})]})}const xe=[{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 nt({step:t,poolAddress:s}){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:xe.map((n,i)=>{const r=xe.findIndex(y=>y.key===t),o=i,u=o<r||t==="done",m=o===r&&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:u?"✓":m?"▶":"○"}),e.jsx("span",{style:{opacity:u||m?1:.4},children:n.label})]},n.key)})}),s&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:s})]})]})}function it({poolAddress:t,buybackRateBps:s,usdcAmount:n,deployedAt:i}){const r=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",o=n!=null?`$${(n/10**W).toFixed(2)}`:null,u=i?new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,m=t.length>16?`${t.slice(0,8)}...${t.slice(-8)}`:t;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:[m,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(rt,{text:t}),e.jsx(fe,{href:`${Qe}/${t}`,label:"Solscan"}),e.jsx(fe,{href:`${et}/${t}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[r," per $1.00"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:o})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:u})]})]})]})}function J({label:t,met:s}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:s?"#16a34a":"#dc2626",fontWeight:600},children:s?"✓":"✗"}),e.jsx("span",{style:{opacity:s?.8:.5},children:t})]})}function rt({text:t}){const[s,n]=d.useState(!1),i=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:i,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:s?"Copied":"Copy"})}function fe({href:t,label:s}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:s})}function at({serverUrl:t,apiKey:s,authManager:n}){const[i,r]=d.useState(null),[o,u]=d.useState([]),[m,y]=d.useState(!0),[l,h]=d.useState(null),[f,_]=d.useState("mint"),[b,g]=d.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=d.useState(!1),[p,C]=d.useState(!1),[w,a]=d.useState(null),S=d.useCallback(async(v,N)=>{if(n?.isAuthenticated())return n.fetchWithAuth(v,N);const K={"Content-Type":"application/json"};s&&(K["X-API-Key"]=s);const z=await fetch(`${t}${v}`,{...N,headers:{...K,...N?.headers}});if(!z.ok){const R=await z.text().catch(()=>`HTTP ${z.status}`);throw new Error(R)}return z.json()},[t,s,n]),A=d.useCallback(async()=>{try{h(null);const v=await S("/admin/token22/status");r(v)}catch{h("Failed to load Token-22 status")}finally{y(!1)}},[S]),T=d.useCallback(async()=>{try{const v=await S("/admin/gift-card-redemptions?limit=50");u(v.redemptions||[])}catch{u([])}},[S]);d.useEffect(()=>{A(),T()},[A,T]);const c=async v=>{if(v.preventDefault(),!!b.treasuryAddress){k(!0),a(null);try{const N=await S("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:b.treasuryAddress,tokenSymbol:b.tokenSymbol,tokenDecimals:b.tokenDecimals,transferFeeBps:b.transferFeeBps,maxTransferFee:b.maxTransferFee})});a(`Mint created: ${N.mintAddress}`),A()}catch(N){a(`Error: ${N instanceof Error?N.message:"Failed to initialize"}`)}finally{k(!1)}}},x=async()=>{C(!0),a(null);try{const v=await S("/admin/token22/harvest-fees",{method:"POST"});a(v.message)}catch(v){a(`Error: ${v instanceof Error?v.message:"Failed to harvest"}`)}finally{C(!1)}},D=v=>{try{return new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return v}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(pe.ErrorBanner,{message:l,onRetry:A}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(v=>{const N={mint:"Token-22 Mint",redemptions:"Gift Card Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>_(v),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:f===v?"2px solid currentColor":"2px solid transparent",fontWeight:f===v?600:400,cursor:"pointer",opacity:f===v?1:.6},children:N[v]},v)})}),m?e.jsxs("div",{className:"cedros-admin__loading",children:[pe.Icons.loading," Loading..."]}):f==="mint"?e.jsx(ot,{mintStatus:i,initForm:b,setInitForm:g,isInitializing:j,isHarvesting:p,actionMessage:w,onInitialize:c,onHarvestFees:x,formatDate:D}):f==="redemptions"?e.jsx(lt,{redemptions:o,formatDate:D}):f==="compliance"?e.jsx(Ye,{serverUrl:t,apiKey:s,authManager:n}):f==="liquidity"?e.jsx(tt,{serverUrl:t,authManager:n,mintConfigured:!!i?.configured,mintAddress:i?.mintAddress,tokenDecimals:i?.tokenDecimals}):f==="asset-classes"?e.jsx(Re,{serverUrl:t,apiKey:s,authManager:n,onNavigateToLiquidity:()=>_("liquidity")}):e.jsx(qe,{serverUrl:t,apiKey:s,authManager:n})]})}function ot({mintStatus:t,initForm:s,setInitForm:n,isInitializing:i,isHarvesting:r,actionMessage:o,onInitialize:u,onHarvestFees:m,formatDate:y}){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(I,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(I,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(I,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(I,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(I,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(I,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(I,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(I,{label:"Created",value:t.createdAt?y(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:m,disabled:r,children:r?"Harvesting...":"Harvest Transfer Fees"}),o&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:o})]})]}):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:u,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:s.treasuryAddress,onChange:l=>n(h=>({...h,treasuryAddress:l.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:s.tokenSymbol,onChange:l=>n(h=>({...h,tokenSymbol:l.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:s.tokenDecimals,onChange:l=>n(h=>({...h,tokenDecimals:parseInt(l.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:s.transferFeeBps,onChange:l=>n(h=>({...h,transferFeeBps:parseInt(l.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:s.maxTransferFee,onChange:l=>n(h=>({...h,maxTransferFee:parseInt(l.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:i,children:i?"Creating Mint...":"Initialize Mint"}),o&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:o})]})]})]})}function I({label:t,value:s,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:s?1:.5},children:s||"—"})]})}function lt({redemptions:t,formatDate:s}){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:s(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=at;