@cedros/pay-react 1.1.28 → 1.1.30

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 (181) hide show
  1. package/README.md +8 -0
  2. package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-BMh3hAb5.mjs} +6 -4
  3. package/dist/{AISettingsSection-DELur7D2.js → AISettingsSection-C0zqPbd6.js} +2 -2
  4. package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-3ctAnz8Y.mjs} +1 -1
  5. package/dist/{AutosaveIndicator-Dn_qA2hK.js → AutosaveIndicator-DXRPr4P7.js} +1 -1
  6. package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
  7. package/dist/CedrosContext-CCakH2SZ.js +3 -0
  8. package/dist/CedrosPayAdminDashboard-DaJ9JoGn.mjs +250 -0
  9. package/dist/CedrosPayAdminDashboard-Uvyh9p7A.js +1 -0
  10. package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-BtJixYAp.mjs} +19 -17
  11. package/dist/ChatLogsSection-FC3O536G.js +1 -0
  12. package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-BMnb1p4w.mjs} +18 -15
  13. package/dist/ComplianceSection-BioTKm7k.js +1 -0
  14. package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
  15. package/dist/CryptoButton-DxFCYDlJ.js +1 -0
  16. package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-dmwoBhcf.mjs} +21 -19
  17. package/dist/CustomersSection-z6ARxuex.js +1 -0
  18. package/dist/DisputesSection-BjHHQAi7.js +1 -0
  19. package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-CHyLne76.mjs} +19 -17
  20. package/dist/Dropdown-BRSZlhik.mjs +111 -0
  21. package/dist/Dropdown-j8o0OO5L.js +1 -0
  22. package/dist/ErrorBanner-CAgPnj62.js +1 -0
  23. package/dist/ErrorBanner-lZJhCmDX.mjs +22 -0
  24. package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Di2xE9Sm.mjs} +8 -6
  25. package/dist/FAQSection-b34DMzgV.js +1 -0
  26. package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-D63PEjR6.mjs} +6 -4
  27. package/dist/ImagesSection-DGBA7iKY.js +1 -0
  28. package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-Dp5Yu4TA.mjs} +25 -23
  29. package/dist/InventorySection-bVCECzX5.js +1 -0
  30. package/dist/LazyCedrosPayAdminDashboard-BqJDNrDI.mjs +9 -0
  31. package/dist/LazyCedrosPayAdminDashboard-CpfTtOBc.js +1 -0
  32. package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-BLCnCpEv.mjs} +5 -4
  33. package/dist/MessagingSection-DU0dYNMy.js +1 -0
  34. package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-Bd56F3cj.mjs} +27 -24
  35. package/dist/OrdersSection-FOFEAgs1.js +1 -0
  36. package/dist/PaymentSettingsSection-52iw47Su.mjs +648 -0
  37. package/dist/PaymentSettingsSection-B5J56VAk.js +1 -0
  38. package/dist/ReturnsSection-BjpIVFfN.js +1 -0
  39. package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-DUVeKrCd.mjs} +11 -9
  40. package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-DKkHykaC.js} +1 -1
  41. package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-vK9WIwXE.mjs} +1 -1
  42. package/dist/ShippingSection-B5lk7zpS.js +1 -0
  43. package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-CZRrXrlh.mjs} +5 -3
  44. package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-C8xJ47_T.mjs} +143 -140
  45. package/dist/SingleCategorySettings-g7D-9lG1.js +3 -0
  46. package/dist/StatsBar-CWXw2ZT3.js +1 -0
  47. package/dist/StatsBar-D4cOKG2e.mjs +25 -0
  48. package/dist/StorefrontSection-BWnMB9k-.js +1 -0
  49. package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-uXSVbEAa.mjs} +121 -119
  50. package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-Ci_AZrWA.mjs} +11 -9
  51. package/dist/SubscriptionsSection-DQfXkuDv.js +1 -0
  52. package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-BTukS_cU.mjs} +23 -21
  53. package/dist/TaxSection-cuPQISxZ.js +1 -0
  54. package/dist/ThemeContext-CFXyYx7A.js +1 -0
  55. package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
  56. package/dist/Token22Section-CCfkDm8W.js +1 -0
  57. package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DRsPJuTq.mjs} +7 -6
  58. package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
  59. package/dist/WalletManager-DXChB9LA.js +1 -0
  60. package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-A8Y4ZGcj.mjs} +40 -38
  61. package/dist/WebhooksSection-CnEmaGH1.js +1 -0
  62. package/dist/admin.d.ts +2 -0
  63. package/dist/admin.js +1 -0
  64. package/dist/admin.mjs +7 -0
  65. package/dist/configApi-BS5UJfzm.js +1 -0
  66. package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
  67. package/dist/crypto-only.js +1 -1
  68. package/dist/crypto-only.mjs +215 -202
  69. package/dist/dateHelpers-BKW_lGND.js +1 -0
  70. package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
  71. package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
  72. package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
  73. package/dist/icons-C3yDMnKE.mjs +235 -0
  74. package/dist/icons-Cjgd9YVo.js +1 -0
  75. package/dist/index-9QF_UfSN.mjs +18668 -0
  76. package/dist/index-Cq9ya93W.js +84 -0
  77. package/dist/index.js +1 -1
  78. package/dist/index.mjs +74 -63
  79. package/dist/safeHref-DqJPLPl5.mjs +12 -0
  80. package/dist/safeHref-DyHIpVjY.js +1 -0
  81. package/dist/sectionIds-D46-_-h-.js +1 -0
  82. package/dist/sectionIds-YktNxmRt.mjs +124 -0
  83. package/dist/sections-511_XBh4.js +1 -0
  84. package/dist/sections-CRaMa8ZB.mjs +9 -0
  85. package/dist/sections-more-Cgw2qJlA.js +1 -0
  86. package/dist/sections-more-Ixw6mM6R.mjs +3082 -0
  87. package/dist/src/admin/index.d.ts +3 -3
  88. package/dist/src/admin/index.d.ts.map +1 -1
  89. package/dist/src/admin/plugin.d.ts.map +1 -1
  90. package/dist/src/admin/types.d.ts +2 -6
  91. package/dist/src/admin/types.d.ts.map +1 -1
  92. package/dist/src/admin.d.ts +9 -0
  93. package/dist/src/admin.d.ts.map +1 -0
  94. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
  95. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
  96. package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
  97. package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
  98. package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
  99. package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
  100. package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
  101. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  102. package/dist/src/components/admin/configApi.d.ts +1 -1
  103. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  104. package/dist/src/components/admin/icons.d.ts +3 -50
  105. package/dist/src/components/admin/icons.d.ts.map +1 -1
  106. package/dist/src/components/admin/index.d.ts +1 -1
  107. package/dist/src/components/admin/index.d.ts.map +1 -1
  108. package/dist/src/components/admin/types.d.ts +43 -0
  109. package/dist/src/components/admin/types.d.ts.map +1 -1
  110. package/dist/src/context/CedrosContext.d.ts +2 -0
  111. package/dist/src/context/CedrosContext.d.ts.map +1 -1
  112. package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
  113. package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
  114. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  115. package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
  116. package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
  117. package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
  118. package/dist/src/ecommerce/config/context.d.ts +2 -0
  119. package/dist/src/ecommerce/config/context.d.ts.map +1 -1
  120. package/dist/src/ecommerce/config/types.d.ts +2 -0
  121. package/dist/src/ecommerce/config/types.d.ts.map +1 -1
  122. package/dist/src/ecommerce/index.d.ts +2 -0
  123. package/dist/src/ecommerce/index.d.ts.map +1 -1
  124. package/dist/src/featureFlags.d.ts +41 -0
  125. package/dist/src/featureFlags.d.ts.map +1 -0
  126. package/dist/src/index.d.ts +4 -2
  127. package/dist/src/index.d.ts.map +1 -1
  128. package/dist/src/managers/StripeManager.d.ts.map +1 -1
  129. package/dist/src/managers/SubscriptionManager.d.ts +1 -0
  130. package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
  131. package/dist/src/standalone-admin.d.ts +8 -0
  132. package/dist/src/standalone-admin.d.ts.map +1 -0
  133. package/dist/src/types/index.d.ts +14 -1
  134. package/dist/src/types/index.d.ts.map +1 -1
  135. package/dist/src/types/subscription.d.ts +47 -1
  136. package/dist/src/types/subscription.d.ts.map +1 -1
  137. package/dist/src/utils/validateConfig.d.ts.map +1 -1
  138. package/dist/standalone-admin.d.ts +2 -0
  139. package/dist/standalone-admin.js +1 -0
  140. package/dist/standalone-admin.mjs +4 -0
  141. package/dist/stripe-only.js +1 -1
  142. package/dist/stripe-only.mjs +35 -33
  143. package/dist/styles--fxb3lCl.js +1 -0
  144. package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
  145. package/dist/testing/index.js +1 -1
  146. package/dist/testing/index.mjs +1 -1
  147. package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
  148. package/dist/tokenMintValidator-DNBhoefh.js +4 -0
  149. package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
  150. package/dist/walletPool-BjTXX6Vn.js +1 -0
  151. package/package.json +9 -3
  152. package/dist/CedrosContext-C2RjHLaQ.js +0 -6
  153. package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
  154. package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
  155. package/dist/ComplianceSection-DP2a9-S0.js +0 -1
  156. package/dist/CryptoButton-DpiCnyXE.js +0 -1
  157. package/dist/CustomersSection-CBwy_waO.js +0 -1
  158. package/dist/DisputesSection-BLjIk60n.js +0 -1
  159. package/dist/FAQSection-wNeH0i6Q.js +0 -1
  160. package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
  161. package/dist/InventorySection-zV6lTmue.js +0 -1
  162. package/dist/MessagingSection-B_wdFR0j.js +0 -1
  163. package/dist/OrdersSection-Dw2FX-1d.js +0 -1
  164. package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
  165. package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
  166. package/dist/ReturnsSection-D_pJVxuG.js +0 -1
  167. package/dist/ShippingSection-1DRSTu49.js +0 -1
  168. package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
  169. package/dist/StorefrontSection-RumGkb3C.js +0 -1
  170. package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
  171. package/dist/TaxSection-Dt1DnM51.js +0 -1
  172. package/dist/Token22Section-DY3mUwTY.js +0 -1
  173. package/dist/WalletManager-B3UdQ5pQ.js +0 -1
  174. package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
  175. package/dist/configApi-DkduMQg1.js +0 -1
  176. package/dist/index-C0g-JxJk.js +0 -84
  177. package/dist/index-DXnuQp5x.mjs +0 -22128
  178. package/dist/sections-C1NpK7hk.mjs +0 -9
  179. package/dist/sections-DVVSZBhW.js +0 -1
  180. package/dist/styles-BT4bhFey.js +0 -1
  181. package/dist/walletPool-IS7R3MR1.js +0 -1
@@ -0,0 +1,3 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),k=require("./icons-Cjgd9YVo.js"),K=require("./ErrorBanner-CAgPnj62.js"),N=require("./configApi-BS5UJfzm.js"),L=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-DXRPr4P7.js"),J=require("./Dropdown-j8o0OO5L.js"),V=require("./tokenMintValidator-DNBhoefh.js"),P=require("./dateHelpers-BKW_lGND.js"),Z=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function M(b){return!b||b.trim()===""?{valid:!0}:Z.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function X({label:b,value:f,onChange:h,decimals:n,onDecimalsChange:j,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],S=v||!!f&&!y,C=t=>{if(t==="custom")E(!0),y&&h("");else{E(!1),h(t);const s=V.STABLECOIN_METADATA[t];s&&j&&j(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:()=>C(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:()=>C("custom"),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:S?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:S?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:S?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),S&&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=>j?.(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 Y({label:b,value:f,onChange:h,disabled:n=!1,description:j}){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]||"")},S=()=>{d!==null&&(I(d,c),u(null),x(""))},C=()=>{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:[k.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"&&S(),i.key==="Escape"&&C()}}),e.jsx("button",{type:"button",onClick:S,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:k.Icons.check}),e.jsx("button",{type:"button",onClick:C,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:k.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?k.Icons.eyeOff:k.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:k.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:k.Icons.trash})]})},s)})]}),j&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:j})]})}function H(b,f,h){const n=N.isSecretField(b,f),j=f.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),a=N.CONFIG_CATEGORIES[b]?.fields?.[f],d={isSecret:n,label:j,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 Q({category:b,config:f,originalConfig:h,isLoading:n=!1,onSave:j}){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}=L.useAutosave({data:c,onSave:j,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=H(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(X,{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||"",w=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 ${w.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:w.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:i&&w.valid?"2rem":void 0}}),i&&w.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:"✓"})]}),!w.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:w.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(Y,{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:w=>p(t,w.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?k.Icons.eyeOff:k.Icons.eye})]}),y(r.description)]})},S=Object.keys(o),C=t=>{const s=H(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:S.filter(C).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($.AutosaveIndicator,{status:v,error:E})})})]})}function ee({serverUrl:b,apiKey:f,authManager:h,category:n,title:j,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),[S,C]=l.useState(null),[t,s]=l.useState(null),[r,g]=l.useState(!1),_=N.CONFIG_CATEGORIES[n]||{label:n,icon:"⚙️"},i=j||_.label,w=o||_.description,D=l.useCallback(async()=>{T(!0),C(null);try{const m=await u.getConfig(n,!0);x(m)}catch{x(null),C("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(q){x({...c,config:{...c.config,[a]:m}}),C(q instanceof Error?q.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:[k.Icons.loading," Loading ",i," settings..."]})}):e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx(K.ErrorBanner,{message:S,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]}),w&&e.jsx("p",{className:"cedros-admin__text-muted",style:{marginTop:"0.25rem"},children:w})]}),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(Q,{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:[P.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=ee;
@@ -0,0 +1 @@
1
+ "use strict";const s=require("react/jsx-runtime"),n=require("./icons-Cjgd9YVo.js");function i({stats:c,isLoading:e=!1,onRefresh:r}){return s.jsxs("div",{className:"cedros-admin__stats-bar",children:[s.jsx("div",{className:"cedros-admin__stats-bar-grid",children:c.map((a,d)=>s.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[s.jsx("span",{className:"cedros-admin__stats-bar-label",children:a.label}),s.jsx("span",{className:`cedros-admin__stats-bar-value ${a.variant?`cedros-admin__stats-bar-value--${a.variant}`:""}`,children:e?s.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):a.value}),a.description&&s.jsx("span",{className:"cedros-admin__stats-bar-desc",children:a.description})]},d))}),r&&s.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:r,disabled:e,title:"Refresh stats",children:e?n.Icons.loading:n.Icons.refresh})]})}exports.StatsBar=i;
@@ -0,0 +1,25 @@
1
+ import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
+ import { I as n } from "./icons-C3yDMnKE.mjs";
3
+ function m({ stats: c, isLoading: e = !1, onRefresh: r }) {
4
+ return /* @__PURE__ */ d("div", { className: "cedros-admin__stats-bar", children: [
5
+ /* @__PURE__ */ s("div", { className: "cedros-admin__stats-bar-grid", children: c.map((a, i) => /* @__PURE__ */ d("div", { className: "cedros-admin__stats-bar-item", children: [
6
+ /* @__PURE__ */ s("span", { className: "cedros-admin__stats-bar-label", children: a.label }),
7
+ /* @__PURE__ */ s("span", { className: `cedros-admin__stats-bar-value ${a.variant ? `cedros-admin__stats-bar-value--${a.variant}` : ""}`, children: e ? /* @__PURE__ */ s("span", { className: "cedros-admin__skeleton cedros-admin__skeleton--value" }) : a.value }),
8
+ a.description && /* @__PURE__ */ s("span", { className: "cedros-admin__stats-bar-desc", children: a.description })
9
+ ] }, i)) }),
10
+ r && /* @__PURE__ */ s(
11
+ "button",
12
+ {
13
+ type: "button",
14
+ className: "cedros-admin__stats-bar-refresh",
15
+ onClick: r,
16
+ disabled: e,
17
+ title: "Refresh stats",
18
+ children: e ? n.loading : n.refresh
19
+ }
20
+ )
21
+ ] });
22
+ }
23
+ export {
24
+ m as S
25
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),O=require("./icons-Cjgd9YVo.js"),q=require("./ErrorBanner-CAgPnj62.js"),j=require("./Dropdown-j8o0OO5L.js"),o=require("./Toggle-CsPSF8Dr.js"),M=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-DXRPr4P7.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:""}},H=[{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"}],V=[{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 X({serverUrl:g,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),[D,u]=l.useState(null),y=l.useCallback(async()=>{try{u(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(`${g}${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),u("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[g,d,c]);l.useEffect(()=>{y()},[y]);const L=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(`${g}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw u("Failed to save storefront settings"),new Error("Save failed")}},[g,d,c]),{status:N,error:R}=M.useAutosave({data:a,onSave:L,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}}}))},x=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},f=(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}}))},h=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},v=(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:[O.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:[V.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($.AutosaveIndicator,{status:N,error:R})]}),e.jsx(q.ErrorBanner,{message:D,onRetry:y}),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=>x("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=>x("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=>x("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=>f("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=>f("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=>f("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(j.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(j.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:H.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(j.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=>h("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=>h("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=>h("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=>h("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=>v("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=>v("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=>v("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=X;