@cedros/pay-react 1.1.23 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-DAztmwnN.js → AISettingsSection-BvSSiK2G.js} +1 -1
- package/dist/{AISettingsSection-DpMIk431.mjs → AISettingsSection-Dg1kazTI.mjs} +2 -2
- package/dist/{AutosaveIndicator-BRCqAWqP.mjs → AutosaveIndicator-BHfkV59p.mjs} +1 -1
- package/dist/{AutosaveIndicator-BnQkKxzr.js → AutosaveIndicator-D2l7U8R1.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-BlArEF7k.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ComplianceSection-BSE2f3Wo.mjs +534 -0
- package/dist/ComplianceSection-D6ETKG6b.js +1 -0
- package/dist/{CryptoButton-CREryx1l.mjs → CryptoButton-BV9owVe2.mjs} +51 -51
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/{FAQSection-yw64HLy3.js → FAQSection-6nGI0FK9.js} +1 -1
- package/dist/{FAQSection-Ruzs7a-0.mjs → FAQSection-uZG5V3pJ.mjs} +1 -1
- package/dist/{MessagingSection-Dp_SaXsv.js → MessagingSection-DrXb578q.js} +1 -1
- package/dist/{MessagingSection-BLRjfBQT.mjs → MessagingSection-M0lj5yo4.mjs} +2 -2
- package/dist/{OrdersSection-l-MtP9EN.mjs → OrdersSection-DteItv_O.mjs} +6 -6
- package/dist/{OrdersSection-C2dyWqrR.js → OrdersSection-_-rIw6XW.js} +1 -1
- package/dist/{PaymentSettingsSection-Bbq93UtC.mjs → PaymentSettingsSection-CdtdLFTg.mjs} +1 -1
- package/dist/{PaymentSettingsSection-C5bhLgU7.js → PaymentSettingsSection-enTbUI95.js} +1 -1
- package/dist/SettingsSection-DUTEd6uV.js +1 -0
- package/dist/{SettingsSection-DorqCFXE.mjs → SettingsSection-mcT4LEhO.mjs} +19 -13
- package/dist/{SingleCategorySettings-BAND8Zkw.mjs → SingleCategorySettings-BvHBVfSe.mjs} +4 -4
- package/dist/{SingleCategorySettings-Cg-zuJfr.js → SingleCategorySettings-D2LVM5mn.js} +1 -1
- package/dist/{StorefrontSection-FSOxBclu.mjs → StorefrontSection-BqQ36JIS.mjs} +2 -2
- package/dist/{StorefrontSection-QZPEZ6Lz.js → StorefrontSection-Du7hV2Gc.js} +1 -1
- package/dist/{SubscriptionsSection-C4TDXCX2.mjs → SubscriptionsSection-BYiCBwKZ.mjs} +7 -7
- package/dist/{SubscriptionsSection-DYr99VzB.js → SubscriptionsSection-C4BRN1dP.js} +1 -1
- package/dist/Token22Section-0c22NM5G.js +1 -0
- package/dist/Token22Section-BHvOhz5d.mjs +2260 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-peBN6RDH.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/{bn-CHdpZHQm.mjs → bn-Bv2sKQMU.mjs} +1 -1
- package/dist/{bn-RbgIlcHc.js → bn-CHyy7EgJ.js} +1 -1
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/{index-CKNB7XsA.mjs → index-BkDimQDF.mjs} +7988 -7323
- package/dist/index-C7MWL6O8.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-Cklkxd85.js → sections-5jO2aHAo.js} +1 -1
- package/dist/sections-By4H1baL.mjs +9 -0
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +38 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/complianceTypes.d.ts +60 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +10 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-2VMpwuaI.mjs → styles-D4SQkuV3.mjs} +647 -650
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-DgQsh7Se.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +6 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-D_pKPRrP.js +0 -1
- package/dist/Token22Section-Cmn2lKcd.mjs +0 -1685
- package/dist/Token22Section-D3nnUyim.js +0 -1
- package/dist/index-vEe2Y39x.js +0 -84
- package/dist/sections-Dt6vxDU4.mjs +0 -8
- package/dist/styles-21F1-oqx.js +0 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),w=require("react"),Jf=require("@solana/wallet-adapter-react"),Ie=require("./CedrosContext-C2RjHLaQ.js"),Xf=require("@cedros/login-react"),em=require("./index-WcOlBYZJ.js"),ea=require("react-dom"),tm=require("./styles-BT4bhFey.js");function Bc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Bc(w),bs=Bc(ea);function dr(e){return new Date(e).toLocaleString()}const J={products:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M20 7.5v9l-4 2.25M4 7.5v9l4 2.25"}),r.jsx("path",{d:"m20 7.5-8-4.5-8 4.5"}),r.jsx("path",{d:"m12 12 8-4.5M12 12v9.5M12 12 4 7.5"})]}),transactions:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})}),coupons:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),r.jsx("path",{d:"M13 5v2M13 17v2M13 11v2"})]}),refunds:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),r.jsx("path",{d:"M3 3v5h5"}),r.jsx("path",{d:"M12 7v5l4 2"})]}),settings:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),wallet:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),r.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m9 18 6-6-6-6"})}),loading:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"cedros-admin__spinner",children:r.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),refresh:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),r.jsx("path",{d:"M21 3v5h-5"}),r.jsx("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),r.jsx("path",{d:"M8 16H3v5"})]}),check:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 6 9 17l-5-5"})}),subscriptions:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"}),r.jsx("path",{d:"M12 2v2M12 20v2M2 12H4M20 12h2"})]}),trash:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})}),plus:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 5v14M5 12h14"})}),chevronDown:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m6 9 6 6 6-6"})}),chevronUp:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m18 15-6-6-6 6"})}),storefront:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 9h18v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9Z"}),r.jsx("path",{d:"m3 9 2.45-4.9A2 2 0 0 1 7.24 3h9.52a2 2 0 0 1 1.8 1.1L21 9"}),r.jsx("path",{d:"M12 3v6"})]}),arrowUp:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m5 12 7-7 7 7"}),r.jsx("path",{d:"M12 19V5"})]}),arrowDown:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m5 12 7 7 7-7"}),r.jsx("path",{d:"M12 5v14"})]}),delete:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M3 6h18M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"}),r.jsx("path",{d:"M10 11v6M14 11v6"})]}),close:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M18 6 6 18M6 6l12 12"})}),edit:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),r.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),faq:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"}),r.jsx("path",{d:"M12 17h.01"})]}),chat:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m3 21 1.9-5.7a8.5 8.5 0 1 1 3.8 3.8z"})}),globe:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),r.jsx("path",{d:"M2 12h20"})]}),ai:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2a4 4 0 0 1 4 4v2a4 4 0 0 1-8 0V6a4 4 0 0 1 4-4Z"}),r.jsx("path",{d:"M10 10v.5"}),r.jsx("path",{d:"M14 10v.5"}),r.jsx("path",{d:"M12 14v2"}),r.jsx("path",{d:"M8 18h8"}),r.jsx("path",{d:"M6 18a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2"}),r.jsx("path",{d:"M6 12v6"}),r.jsx("path",{d:"M18 12v6"})]}),notifications:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"}),r.jsx("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"})]}),eye:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),eyeOff:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24"}),r.jsx("path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"}),r.jsx("path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"}),r.jsx("line",{x1:"2",x2:"22",y1:"2",y2:"22"})]}),creditCard:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}),r.jsx("line",{x1:"2",x2:"22",y1:"10",y2:"10"})]}),mail:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),r.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),server:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),r.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),r.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),r.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),calendarRepeat:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",ry:"2"}),r.jsx("line",{x1:"16",x2:"16",y1:"2",y2:"6"}),r.jsx("line",{x1:"8",x2:"8",y1:"2",y2:"6"}),r.jsx("line",{x1:"3",x2:"21",y1:"10",y2:"10"}),r.jsx("path",{d:"M11 14h1.5a1.5 1.5 0 0 1 0 3H11v2"}),r.jsx("path",{d:"M16 14v3a1 1 0 0 0 1 1h1"})]}),shield:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),brain:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"}),r.jsx("path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"}),r.jsx("path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"}),r.jsx("path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375"}),r.jsx("path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5"}),r.jsx("path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396"}),r.jsx("path",{d:"M19.938 10.5a4 4 0 0 1 .585.396"}),r.jsx("path",{d:"M6 18a4 4 0 0 1-1.967-.516"}),r.jsx("path",{d:"M19.967 17.484A4 4 0 0 1 18 18"})]})};function Sr({message:e,onRetry:t}){return e?r.jsxs("div",{className:"cedros-admin__error-banner",children:[r.jsx("span",{children:e}),t&&r.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:t,children:[J.refresh," Retry"]})]}):null}function Cr({stats:e,isLoading:t=!1,onRefresh:n}){return r.jsxs("div",{className:"cedros-admin__stats-bar",children:[r.jsx("div",{className:"cedros-admin__stats-bar-grid",children:e.map((s,o)=>r.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[r.jsx("span",{className:"cedros-admin__stats-bar-label",children:s.label}),r.jsx("span",{className:`cedros-admin__stats-bar-value ${s.variant?`cedros-admin__stats-bar-value--${s.variant}`:""}`,children:t?r.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):s.value}),s.description&&r.jsx("span",{className:"cedros-admin__stats-bar-desc",children:s.description})]},o))}),n&&r.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:n,disabled:t,title:"Refresh stats",children:t?J.loading:J.refresh})]})}function nm({serverUrl:e,productId:t,apiKey:n,authManager:s}){const[o,a]=w.useState(null),[i,c]=w.useState(!1),[l,d]=w.useState(!1),[f,u]=w.useState(null),g=w.useCallback(async()=>{if(t){c(!0),u(null);try{let h;if(s?.isAuthenticated())h=await s.fetchWithAuth(`/admin/products/${t}/variations`);else{const v={"Content-Type":"application/json"};n&&(v["X-API-Key"]=n);const y=await fetch(`${e}/admin/products/${t}/variations`,{headers:v});if(!y.ok)throw new Error(`Failed to fetch variations: ${y.status}`);h=await y.json()}h.variationConfig||(h.variationConfig={variationTypes:[]}),h.variants||(h.variants=[]),a(h)}catch(h){const v=h instanceof Error?h.message:"Failed to fetch variations";u(v),a({productId:t,variationConfig:{variationTypes:[]},variants:[]})}finally{c(!1)}}},[e,t,n,s]),p=w.useCallback(async h=>{if(!t)return null;d(!0),u(null);try{let v;if(s?.isAuthenticated())v=await s.fetchWithAuth(`/admin/products/${t}/variations`,{method:"PUT",body:JSON.stringify(h)});else{const y={"Content-Type":"application/json"};n&&(y["X-API-Key"]=n);const k=await fetch(`${e}/admin/products/${t}/variations`,{method:"PUT",headers:y,body:JSON.stringify(h)});if(!k.ok)throw new Error(`Failed to save variations: ${k.status}`);v=await k.json()}return a({productId:t,variationConfig:v.variationConfig,variants:v.variants}),{variantsCreated:v.variantsCreated}}catch(v){const y=v instanceof Error?v.message:"Failed to save variations";return u(y),null}finally{d(!1)}},[e,t,n,s]),x=w.useCallback(async h=>{if(!t||h.length===0)return!1;d(!0),u(null);try{if(s?.isAuthenticated())await s.fetchWithAuth(`/admin/products/${t}/variants/inventory`,{method:"PUT",body:JSON.stringify({updates:h})});else{const v={"Content-Type":"application/json"};n&&(v["X-API-Key"]=n);const y=await fetch(`${e}/admin/products/${t}/variants/inventory`,{method:"PUT",headers:v,body:JSON.stringify({updates:h})});if(!y.ok)throw new Error(`Failed to update inventory: ${y.status}`)}if(o){const v=new Map(h.map(y=>[y.variantId,y]));a({...o,variants:o.variants.map(y=>{const k=v.get(y.id);return k?{...y,inventoryQuantity:k.inventoryQuantity,inventoryStatus:k.inventoryStatus??y.inventoryStatus}:y})})}return!0}catch(v){const y=v instanceof Error?v.message:"Failed to update inventory";return u(y),!1}finally{d(!1)}},[e,t,n,s,o]);return{data:o,isLoading:i,error:f,fetch:g,save:p,bulkUpdateInventory:x,isSaving:l}}function hi(){return`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function rm({value:e,onChange:t,maxTypes:n=5,maxValuesPerType:s=20,disabled:o=!1}){const[a,i]=w.useState(null),[c,l]=w.useState(""),[d,f]=w.useState({}),u=e.variationTypes,g=w.useCallback(()=>{if(!c.trim()||u.length>=n)return;const _={id:hi(),name:c.trim(),displayOrder:u.length,values:[]};t({variationTypes:[...u,_]}),l(""),i(_.id)},[c,u,n,t]),p=w.useCallback(_=>{t({variationTypes:u.filter(b=>b.id!==_).map((b,j)=>({...b,displayOrder:j}))}),a===_&&i(null)},[u,t,a]),x=w.useCallback((_,b)=>{t({variationTypes:u.map(j=>j.id===_?{...j,name:b}:j)})},[u,t]),h=w.useCallback((_,b)=>{const j=u.findIndex(A=>A.id===_);if(j===-1||b==="up"&&j===0||b==="down"&&j===u.length-1)return;const N=[...u],T=b==="up"?j-1:j+1;[N[j],N[T]]=[N[T],N[j]],t({variationTypes:N.map((A,E)=>({...A,displayOrder:E}))})},[u,t]),v=w.useCallback(_=>{const b=(d[_]||"").trim();if(!b)return;const j=u.find(T=>T.id===_);if(!j||j.values.length>=s)return;const N={id:hi(),label:b};t({variationTypes:u.map(T=>T.id===_?{...T,values:[...T.values,N]}:T)}),f(T=>({...T,[_]:""}))},[u,d,s,t]),y=w.useCallback((_,b)=>{t({variationTypes:u.map(j=>j.id===_?{...j,values:j.values.filter(N=>N.id!==b)}:j)})},[u,t]),k=w.useCallback((_,b,j)=>{t({variationTypes:u.map(N=>N.id===_?{...N,values:N.values.map(T=>T.id===b?{...T,label:j}:T)}:N)})},[u,t]);return r.jsxs("div",{className:"cedros-admin__variation-editor",children:[r.jsxs("div",{className:"cedros-admin__variation-editor-header",children:[r.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variation Types"}),r.jsxs("span",{style:{fontSize:12,opacity:.7},children:[u.length,"/",n," types"]})]}),u.length===0?r.jsx("div",{className:"cedros-admin__variation-empty",children:'No variation types defined. Add types like "Size" or "Color" to create product variants.'}):r.jsx("div",{className:"cedros-admin__variation-type-list",children:u.map((_,b)=>r.jsxs("div",{className:"cedros-admin__variation-type-item",children:[r.jsxs("div",{className:"cedros-admin__variation-type-header",children:[r.jsxs("div",{className:"cedros-admin__variation-type-controls",children:[r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>h(_.id,"up"),disabled:o||b===0,title:"Move up",children:J.arrowUp}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>h(_.id,"down"),disabled:o||b===u.length-1,title:"Move down",children:J.arrowDown})]}),r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__variation-type-name",value:_.name,onChange:j=>x(_.id,j.target.value),disabled:o,placeholder:"Type name"}),r.jsxs("span",{className:"cedros-admin__variation-value-count",children:[_.values.length," values"]}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>i(a===_.id?null:_.id),children:a===_.id?"Collapse":"Edit values"}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>p(_.id),disabled:o,title:"Remove type",children:J.delete})]}),a===_.id&&r.jsxs("div",{className:"cedros-admin__variation-values",children:[r.jsxs("div",{className:"cedros-admin__variation-values-header",children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600},children:['Values for "',_.name,'"']}),r.jsxs("span",{style:{fontSize:11,opacity:.7},children:[_.values.length,"/",s]})]}),_.values.length===0?r.jsx("div",{className:"cedros-admin__variation-empty",style:{padding:"8px 0"},children:'No values yet. Add values like "Small", "Medium", "Large".'}):r.jsx("div",{className:"cedros-admin__variation-value-list",children:_.values.map(j=>r.jsxs("div",{className:"cedros-admin__variation-value-item",children:[r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:j.label,onChange:N=>k(_.id,j.id,N.target.value),disabled:o}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>y(_.id,j.id),disabled:o,title:"Remove value",children:J.close})]},j.id))}),_.values.length<s&&r.jsxs("div",{className:"cedros-admin__variation-add-value",children:[r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:d[_.id]||"",onChange:j=>f(N=>({...N,[_.id]:j.target.value})),placeholder:"Add value...",disabled:o,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),v(_.id))}}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary cedros-admin__button--sm",onClick:()=>v(_.id),disabled:o||!d[_.id]?.trim(),children:"Add"})]})]})]},_.id))}),u.length<n&&r.jsxs("div",{className:"cedros-admin__variation-add-type",children:[r.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:_=>l(_.target.value),placeholder:"New variation type (e.g., Size, Color)",disabled:o,onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),g())}}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:g,disabled:o||!c.trim(),children:"Add Type"})]})]})}function Uc({value:e,onChange:t,options:n,placeholder:s="Filter",disabled:o}){const[a,i]=w.useState(!1),c=w.useRef(null),d=n.find(f=>f.value===e)?.label||s;return w.useEffect(()=>{const f=u=>{c.current&&!c.current.contains(u.target)&&i(!1)};if(a)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a]),w.useEffect(()=>{const f=u=>{u.key==="Escape"&&i(!1)};if(a)return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[a]),r.jsxs("div",{className:"cedros-admin__dropdown",ref:c,children:[r.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!o&&i(!a),"aria-expanded":a,"aria-haspopup":"listbox",disabled:o,children:[r.jsx("span",{children:d}),r.jsx("span",{className:`cedros-admin__dropdown-chevron ${a?"cedros-admin__dropdown-chevron--open":""}`,children:J.chevronDown})]}),a&&r.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:n.map(f=>r.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${f.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{f.disabled||(t(f.value),i(!1))},role:"option","aria-selected":f.value===e,disabled:f.disabled,children:[f.label,f.value===e&&r.jsx("span",{className:"cedros-admin__dropdown-check",children:J.check})]},f.value))})]})}function Ct({value:e,onChange:t,options:n,label:s,description:o,disabled:a,className:i,style:c}){const[l,d]=w.useState(!1),f=w.useRef(null),g=n.find(p=>p.value===e)?.label||"Select...";return w.useEffect(()=>{const p=x=>{f.current&&!f.current.contains(x.target)&&d(!1)};if(l)return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),w.useEffect(()=>{const p=x=>{x.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[l]),r.jsxs("div",{className:`cedros-admin__field ${i||""}`,style:c,children:[r.jsx("label",{className:"cedros-admin__field-label",children:s}),r.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:f,children:[r.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!a&&d(!l),"aria-expanded":l,"aria-haspopup":"listbox",disabled:a,children:[r.jsx("span",{children:g}),r.jsx("span",{className:`cedros-admin__dropdown-chevron ${l?"cedros-admin__dropdown-chevron--open":""}`,children:J.chevronDown})]}),l&&r.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:n.map(p=>r.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${p.value===e?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{p.disabled||(t(p.value),d(!1))},role:"option","aria-selected":p.value===e,disabled:p.disabled,children:[p.label,p.value===e&&r.jsx("span",{className:"cedros-admin__dropdown-check",children:J.check})]},p.value))})]}),o&&r.jsx("p",{className:"cedros-admin__field-description",children:o})]})}function gi(){return`variant_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function sm(e){if(e.length===0)return[];const t=[...e].sort((s,o)=>s.displayOrder-o.displayOrder),n=(s,o)=>{if(s>=t.length){const c=o.valueIds.sort().join("|"),l=Object.values(o.options).join(" / ");return[{key:c,title:l,optionValueIds:[...o.valueIds],options:{...o.options}}]}const a=t[s],i=[];for(const c of a.values)i.push(...n(s+1,{valueIds:[...o.valueIds,c.id],options:{...o.options,[a.name]:c.label}}));return i};return n(0,{valueIds:[],options:{}})}function om(e){return e.optionValueIds?.length?[...e.optionValueIds].sort().join("|"):Object.entries(e.options).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${t}:${n}`).join("|")}function am({variationConfig:e,variants:t,onChange:n,defaultPrice:s=0,currencySymbol:o="$",maxVariants:a=100,disabled:i=!1}){const c=w.useMemo(()=>sm(e.variationTypes),[e.variationTypes]),l=w.useMemo(()=>{const h=new Map;for(const v of t)h.set(om(v),v);return h},[t]),{existingRows:d,possibleRows:f}=w.useMemo(()=>{const h=[],v=[];for(const y of c){const k=l.get(y.key);k?h.push({combo:y,variant:k}):v.push(y)}return{existingRows:h,possibleRows:v}},[c,l]),u=w.useCallback((h,v)=>{n(t.map(y=>y.id===h?{...y,...v}:y))},[t,n]),g=w.useCallback(h=>{n(t.filter(v=>v.id!==h))},[t,n]),p=w.useCallback(h=>{if(t.length>=a)return;const v={id:gi(),title:h.title,options:h.options,optionValueIds:h.optionValueIds,price:s,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!1};n([...t,v])},[t,n,a,s]),x=w.useCallback(()=>{const h=a-t.length,y=f.slice(0,h).map(k=>({id:gi(),title:k.title,options:k.options,optionValueIds:k.optionValueIds,price:s,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!0}));n([...t,...y])},[t,n,f,a,s]);return e.variationTypes.length===0?r.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add variation types above to create product variants."}):c.length===0?r.jsx("div",{className:"cedros-admin__variant-grid-empty",children:"Add values to your variation types to create product variants."}):r.jsxs("div",{className:"cedros-admin__variant-grid",children:[r.jsxs("div",{className:"cedros-admin__variant-grid-header",children:[r.jsx("h4",{className:"cedros-admin__field-label",style:{marginBottom:0},children:"Variants"}),r.jsxs("span",{style:{fontSize:12,opacity:.7},children:[t.length,"/",a," variants (",c.length," ","possible)"]})]}),f.length>0&&t.length<a&&r.jsxs("div",{className:"cedros-admin__variant-grid-actions",children:[r.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary",onClick:x,disabled:i,children:["Generate All (",Math.min(f.length,a-t.length),")"]}),r.jsx("span",{style:{fontSize:11,opacity:.7},children:"Creates variants with default price and 0 inventory"})]}),r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table cedros-admin__variant-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Variant"}),r.jsx("th",{style:{width:100},children:"Price"}),r.jsx("th",{style:{width:80},children:"Qty"}),r.jsx("th",{style:{width:100},children:"SKU"}),r.jsx("th",{style:{width:100},children:"Status"}),r.jsx("th",{style:{width:80},children:"Actions"})]})}),r.jsxs("tbody",{children:[d.map(({combo:h,variant:v})=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[r.jsx("span",{style:{fontWeight:600},children:h.title}),r.jsx("span",{style:{fontSize:11,opacity:.6},children:Object.entries(h.options).map(([y,k])=>`${y}: ${k}`).join(", ")})]})}),r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[r.jsx("span",{children:o}),r.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:v.price??"",onChange:y=>u(v.id,{price:y.target.value===""?void 0:parseFloat(y.target.value)||0}),disabled:i,min:"0",step:"0.01",style:{width:70}})]})}),r.jsx("td",{children:r.jsx("input",{type:"number",className:"cedros-admin__input cedros-admin__input--sm",value:v.inventoryQuantity??"",onChange:y=>u(v.id,{inventoryQuantity:y.target.value===""?void 0:parseInt(y.target.value)||0}),disabled:i,min:"0",style:{width:60}})}),r.jsx("td",{children:r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__input--sm",value:v.sku??"",onChange:y=>u(v.id,{sku:y.target.value||void 0}),disabled:i,placeholder:"SKU",style:{width:80}})}),r.jsx("td",{children:r.jsx(Uc,{value:v.inventoryStatus??"in_stock",onChange:y=>u(v.id,{inventoryStatus:y}),options:[{value:"in_stock",label:"In stock"},{value:"low",label:"Low"},{value:"out_of_stock",label:"Out of stock"},{value:"backorder",label:"Backorder"}],disabled:i})}),r.jsx("td",{children:r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon cedros-admin__button--danger",onClick:()=>g(v.id),disabled:i,title:"Remove variant",children:J.trash})})]},v.id)),f.length>0&&t.length<a&&r.jsxs(r.Fragment,{children:[r.jsx("tr",{className:"cedros-admin__variant-separator",children:r.jsx("td",{colSpan:6,children:r.jsxs("span",{style:{fontSize:11,opacity:.6},children:["Uncreated combinations (",f.length,")"]})})}),f.slice(0,10).map(h=>r.jsxs("tr",{className:"cedros-admin__variant-possible",children:[r.jsx("td",{children:r.jsx("span",{style:{opacity:.6},children:h.title})}),r.jsx("td",{colSpan:4,style:{opacity:.5},children:"Not created"}),r.jsx("td",{children:r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--icon",onClick:()=>p(h),disabled:i,title:"Create variant",children:J.plus})})]},h.key)),f.length>10&&r.jsx("tr",{className:"cedros-admin__variant-more",children:r.jsxs("td",{colSpan:6,style:{textAlign:"center",opacity:.6},children:["+",f.length-10," more combinations"]})})]})]})]})})]})}function im({serverUrl:e,productId:t,productTitle:n,defaultPrice:s=0,currencySymbol:o="$",apiKey:a,authManager:i,onClose:c}){const{data:l,isLoading:d,error:f,fetch:u,save:g,isSaving:p}=nm({serverUrl:e,productId:t,apiKey:a,authManager:i}),[x,h]=w.useState({variationTypes:[]}),[v,y]=w.useState([]),[k,_]=w.useState(!1),[b,j]=w.useState(!1);w.useEffect(()=>{u()},[u]),w.useEffect(()=>{l&&(h(l.variationConfig),y(l.variants),_(!1))},[l]);const N=w.useCallback(E=>{h(E),_(!0),j(!1)},[]),T=w.useCallback(E=>{y(E),_(!0),j(!1)},[]),A=w.useCallback(async()=>{const E=new Set((l?.variants??[]).map($=>$.id)),P=v.filter($=>!E.has($.id)),F=v.filter($=>E.has($.id)),L=(l?.variants??[]).filter($=>!v.some(Y=>Y.id===$.id)).map($=>$.id);await g({variationConfig:x,createVariants:P.map($=>({optionValueIds:$.optionValueIds??[],inventoryQuantity:$.inventoryQuantity,sku:$.sku,price:$.price})),updateVariants:F.map($=>({id:$.id,inventoryQuantity:$.inventoryQuantity,sku:$.sku,price:$.price,inventoryStatus:$.inventoryStatus})),deleteVariantIds:L.length>0?L:void 0})&&(_(!1),j(!0),setTimeout(()=>j(!1),3e3))},[x,v,l?.variants,g]);return d?r.jsxs("div",{className:"cedros-admin__variations-editor",children:[r.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),c&&r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:J.close})]}),r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading variations..."]})]}):r.jsxs("div",{className:"cedros-admin__variations-editor",children:[r.jsxs("div",{className:"cedros-admin__variations-editor-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:n?`Variations: ${n}`:"Product Variations"}),r.jsxs("div",{className:"cedros-admin__variations-editor-actions",children:[b&&r.jsxs("span",{className:"cedros-admin__success-text",children:[J.check," Saved"]}),k&&r.jsx("span",{className:"cedros-admin__unsaved-text",children:"Unsaved changes"}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:A,disabled:p||!k,children:p?"Saving...":"Save Changes"}),c&&r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:c,children:J.close})]})]}),f&&r.jsx("div",{className:"cedros-admin__error-banner",children:f}),r.jsxs("div",{className:"cedros-admin__variations-editor-content",children:[r.jsx("div",{className:"cedros-admin__variations-editor-section",children:r.jsx(rm,{value:x,onChange:N,disabled:p})}),x.variationTypes.length>0&&r.jsx("div",{className:"cedros-admin__variations-editor-section",children:r.jsx(am,{variationConfig:x,variants:v,onChange:T,defaultPrice:s,currencySymbol:o,disabled:p})})]})]})}function Vc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=w.useState([]),[i,c]=w.useState(!0),[l,d]=w.useState(!1),[f,u]=w.useState(!1),[g,p]=w.useState(null),[x,h]=w.useState(null),[v,y]=w.useState(null),[k,_]=w.useState(null),[b,j]=w.useState({id:"",title:"",slug:"",imageUrl:"",description:"",productType:"one_time",priceUsd:"",fiatCurrency:"usd",cryptoToken:"USDC",inventoryStatus:"in_stock",compareAtUsd:"",tagsCsv:"",categoryIdsCsv:"",checkoutEmail:"required",checkoutName:"optional",checkoutPhone:"none",checkoutShippingAddress:!1,checkoutBillingAddress:!1,fulfillmentType:"shipping",fulfillmentNotes:"",shippingCountriesCsv:"",inventoryQuantity:"",giftCardConfig:null,tokenizedAssetConfig:null}),N=C=>{const I=C.tagsCsv.split(",").map(R=>R.trim()).filter(Boolean),Z=C.categoryIdsCsv.split(",").map(R=>R.trim()).filter(Boolean),ve={email:C.checkoutEmail,name:C.checkoutName,phone:C.checkoutPhone,shippingAddress:C.checkoutShippingAddress,billingAddress:C.checkoutBillingAddress},V=C.fulfillmentType==="shipping"?"physical":"digital",Q={title:C.title,slug:C.slug||C.id,shipping_profile:V,inventory_status:C.inventoryStatus,checkout_requirements:JSON.stringify(ve),fulfillment_type:C.fulfillmentType};C.imageUrl&&(Q.image_url=C.imageUrl);const K=C.compareAtUsd?Math.round(Number(C.compareAtUsd)*100):0;K&&(Q.compare_at_amount_cents=String(K)),I.length&&(Q.tags=JSON.stringify(I)),Z.length&&(Q.category_ids=JSON.stringify(Z)),C.fulfillmentNotes&&(Q.fulfillment_notes=C.fulfillmentNotes);const le=C.shippingCountriesCsv.split(",").map(R=>R.trim().toUpperCase()).filter(Boolean);return le.length&&(Q.shippingCountries=le.join(","),Q.shipping_countries=le.join(",")),Q},[T,A]=w.useState([]),E=C=>C.metadata?.title||C.description||C.id,P=C=>C.metadata?.image_url,F=w.useCallback(async()=>{try{_(null);let C;if(s?.isAuthenticated())C=await s.fetchWithAuth(`/admin/products?limit=${n}`);else{const I={"Content-Type":"application/json"};t&&(I["X-API-Key"]=t);const Z=await fetch(`${e}/admin/products?limit=${n}`,{headers:I});if(!Z.ok)throw new Error(`Failed to fetch products: ${Z.status}`);C=await Z.json()}a(C.products||[])}catch{a([]),_("Failed to load products")}finally{c(!1)}},[e,t,n,s]);w.useEffect(()=>{F(),(async()=>{try{let C;if(s?.isAuthenticated())C=await s.fetchWithAuth("/admin/collections");else{const I={"Content-Type":"application/json"};t&&(I["X-API-Key"]=t);const Z=await fetch(`${e}/admin/collections`,{headers:I});if(!Z.ok)return;C=await Z.json()}A((C.collections||[]).filter(I=>I.tokenizationConfig).map(I=>({id:I.id,name:I.name})))}catch{}})()},[F,e,t,s]);const L=async C=>{if(C.preventDefault(),!(!b.id||!b.description)){if(p(null),b.fulfillmentType==="shipping"&&b.checkoutShippingAddress&&!b.shippingCountriesCsv.split(",").map(Z=>Z.trim()).filter(Boolean).length){p("Shipping countries are required when collecting shipping address. Example: US,CA");return}u(!0);try{const{productType:I}=b,Z=b.inventoryQuantity===""?void 0:Number.isFinite(Number(b.inventoryQuantity))?Number(b.inventoryQuantity):void 0,ve=Number(b.priceUsd)||0,V=Math.round(ve*100),Q=Math.round(ve*1e6),K={id:b.id,description:b.description,fiatAmountCents:V,fiatCurrency:b.fiatCurrency,cryptoAtomicAmount:Q,cryptoToken:b.cryptoToken,...Z!==void 0?{inventoryQuantity:Z}:{},metadata:{...I?{product_type:I}:{},...N(b)}};if(I==="gift_card"&&b.giftCardConfig&&(K.giftCardConfig=b.giftCardConfig),I==="tokenized_asset"&&b.tokenizedAssetConfig&&(K.tokenizedAssetConfig=b.tokenizedAssetConfig),s?.isAuthenticated())await s.fetchWithAuth("/admin/products",{method:"POST",body:JSON.stringify(K)});else{const le={"Content-Type":"application/json"};t&&(le["X-API-Key"]=t);const R=await fetch(`${e}/admin/products`,{method:"POST",headers:le,body:JSON.stringify(K)});if(!R.ok)throw new Error(`Failed to create product: ${R.status}`)}j({id:"",title:"",slug:"",imageUrl:"",description:"",productType:"one_time",priceUsd:"",fiatCurrency:"usd",cryptoToken:"USDC",inventoryStatus:"in_stock",compareAtUsd:"",tagsCsv:"",categoryIdsCsv:"",checkoutEmail:"required",checkoutName:"optional",checkoutPhone:"none",checkoutShippingAddress:!1,checkoutBillingAddress:!1,fulfillmentType:"shipping",fulfillmentNotes:"",shippingCountriesCsv:"",inventoryQuantity:"",giftCardConfig:null,tokenizedAssetConfig:null}),d(!1),F()}catch(I){p(I instanceof Error?I.message:"Failed to create product")}finally{u(!1)}}},U=C=>`$${(C/100).toFixed(2)}`,$=C=>{switch(C){case"subscription":return"Subscription";case"pay_per_access":return"Pay per access";case"one_time":return"One-time purchase";case"gift_card":return"Gift card";default:return"One-time purchase"}},Y=w.useMemo(()=>{const C=o.filter(Z=>Z.active).length,I=o.reduce((Z,ve)=>{const V=ve.variations?.length??0;return Z+(V>0?V:1)},0);return{activeCount:C,totalSkus:I}},[o]),B=C=>{y(I=>!I||I.key!==C?{key:C,direction:"asc"}:{key:C,direction:I.direction==="asc"?"desc":"asc"})},H=C=>!v||v.key!==C?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:J.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:v.direction==="asc"?J.chevronUp:J.chevronDown}),D=w.useMemo(()=>{if(!v)return o;const C=v.direction==="asc"?1:-1,I=Z=>{switch(v.key){case"product":return E(Z);case"type":return $(Z.metadata?.product_type);case"price":return Z.fiatAmountCents??0;case"status":return Z.active?1:0;case"id":default:return Z.id}};return[...o].sort((Z,ve)=>{const V=I(Z),Q=I(ve);return typeof V=="number"&&typeof Q=="number"?(V-Q)*C:String(V).localeCompare(String(Q),void 0,{sensitivity:"base"})*C})},[o,v]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:k,onRetry:F}),r.jsx(Cr,{stats:[{label:"Total Products",value:o.length},{label:"Active",value:Y.activeCount,variant:Y.activeCount>0?"success":"muted"},{label:"Total SKUs",value:Y.totalSkus}],isLoading:i}),r.jsxs("div",{className:"cedros-admin__section-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:"Paywall Products"}),r.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>{p(null),d(!l)},children:[l?J.close:J.plus,l?"Cancel":"Add Product"]})]}),l&&r.jsxs("form",{onSubmit:L,className:"cedros-admin__add-form",children:[g&&r.jsx("div",{style:{marginBottom:"0.75rem",color:"#B42318",fontWeight:600},children:g}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Product ID"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.id,onChange:C=>j(I=>({...I,id:C.target.value})),placeholder:"e.g., premium-article",required:!0})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Product name"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.title,onChange:C=>j(I=>({...I,title:C.target.value})),placeholder:"e.g., Cedros Hoodie"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Slug"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.slug,onChange:C=>j(I=>({...I,slug:C.target.value})),placeholder:"e.g., cedros-hoodie (defaults to ID)"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Primary image URL"}),r.jsx("input",{type:"url",className:"cedros-admin__input",value:b.imageUrl,onChange:C=>j(I=>({...I,imageUrl:C.target.value})),placeholder:"https://..."})]})]}),r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Short description"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.description,onChange:C=>j(I=>({...I,description:C.target.value})),placeholder:"e.g., Midweight fleece with relaxed fit",required:!0})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:b.productType,onChange:C=>j(I=>({...I,productType:C,giftCardConfig:C==="gift_card"?I.giftCardConfig??{faceValueCents:0,currency:"usd",secondaryMarket:!1,expiresInDays:null}:null,tokenizedAssetConfig:C==="tokenized_asset"?I.tokenizedAssetConfig??{assetClassCollectionId:"",backingValueCents:0,backingCurrency:"usd",assetIdentifier:"",tokensPerUnit:1,custodyProofUrl:null}:null})),options:[{value:"one_time",label:"One-time purchase"},{value:"pay_per_access",label:"Pay per access"},{value:"subscription",label:"Subscription"},{value:"gift_card",label:"Gift card"},{value:"tokenized_asset",label:"Tokenized asset"}],label:"Product Type"}),r.jsx(Ct,{value:b.fulfillmentType,onChange:C=>{const I=C;j(Z=>({...Z,fulfillmentType:I,checkoutShippingAddress:I==="shipping"?Z.checkoutShippingAddress:!1}))},options:[{value:"shipping",label:"Physical (shipped)"},{value:"digital_download",label:"Digital download"},{value:"service",label:"Service"}],label:"Fulfillment"})]}),b.productType==="gift_card"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Gift card face value (USD cents)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.giftCardConfig?.faceValueCents??"",onChange:C=>j(I=>({...I,giftCardConfig:{faceValueCents:parseInt(C.target.value)||0,currency:I.giftCardConfig?.currency??"usd",secondaryMarket:I.giftCardConfig?.secondaryMarket??!1,expiresInDays:I.giftCardConfig?.expiresInDays??null}})),placeholder:"e.g., 5000 for $50.00",min:"1",required:!0}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Face value in cents (e.g. 5000 = $50.00). Must be greater than 0."})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Gift card currency"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.giftCardConfig?.currency??"",onChange:C=>j(I=>({...I,giftCardConfig:{faceValueCents:I.giftCardConfig?.faceValueCents??0,currency:C.target.value.toLowerCase().slice(0,3),secondaryMarket:I.giftCardConfig?.secondaryMarket??!1,expiresInDays:I.giftCardConfig?.expiresInDays??null}})),placeholder:"usd",maxLength:3,required:!0}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"ISO 4217 3-letter currency code (e.g. usd, eur, gbp)."})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Expiration (days)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.giftCardConfig?.expiresInDays??"",onChange:C=>j(I=>({...I,giftCardConfig:{faceValueCents:I.giftCardConfig?.faceValueCents??0,currency:I.giftCardConfig?.currency??"usd",secondaryMarket:I.giftCardConfig?.secondaryMarket??!1,expiresInDays:C.target.value===""?null:parseInt(C.target.value)||0}})),placeholder:"Leave blank for no expiry",min:"0"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Number of days until gift card expires. Leave blank for no expiry."})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Secondary market (Token-22)"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:8},children:[r.jsx("input",{type:"checkbox",checked:b.giftCardConfig?.secondaryMarket??!1,onChange:C=>j(I=>({...I,giftCardConfig:{faceValueCents:I.giftCardConfig?.faceValueCents??0,currency:I.giftCardConfig?.currency??"usd",secondaryMarket:C.target.checked,expiresInDays:I.giftCardConfig?.expiresInDays??null}}))}),"Enable Token-22 secondary market trading"]}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Mints store credit tokens to recipient's embedded wallet for peer-to-peer trading with transfer fees."})]})]})]}),b.productType==="tokenized_asset"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Asset class collection"}),T.length>0?r.jsxs("select",{className:"cedros-admin__input",value:b.tokenizedAssetConfig?.assetClassCollectionId??"",onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,assetClassCollectionId:C.target.value}})),required:!0,children:[r.jsx("option",{value:"",children:"Select asset class..."}),T.map(C=>r.jsx("option",{value:C.id,children:C.name},C.id))]}):r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tokenizedAssetConfig?.assetClassCollectionId??"",onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,assetClassCollectionId:C.target.value}})),placeholder:"Collection ID of the asset class",required:!0})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Backing value (cents)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.tokenizedAssetConfig?.backingValueCents??0,onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,backingValueCents:Number(C.target.value)}})),min:0})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Backing currency"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tokenizedAssetConfig?.backingCurrency??"usd",onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,backingCurrency:C.target.value}})),placeholder:"usd",maxLength:3})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Asset identifier"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tokenizedAssetConfig?.assetIdentifier??"",onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,assetIdentifier:C.target.value}})),placeholder:"e.g., ISIN, lot number"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Tokens per unit"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.tokenizedAssetConfig?.tokensPerUnit??1,onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,tokensPerUnit:Number(C.target.value)}})),min:1})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Custody proof URL"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tokenizedAssetConfig?.custodyProofUrl??"",onChange:C=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,custodyProofUrl:C.target.value||null}})),placeholder:"https://..."})]})]})]}),b.fulfillmentType==="shipping"&&r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:b.inventoryStatus,onChange:C=>j(I=>({...I,inventoryStatus:C})),options:[{value:"in_stock",label:"In stock"},{value:"low",label:"Low"},{value:"out_of_stock",label:"Out of stock"},{value:"backorder",label:"Backorder"}],label:"Inventory status"}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Inventory quantity (tracked)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.inventoryQuantity,onChange:C=>j(I=>({...I,inventoryQuantity:C.target.value===""?"":parseInt(C.target.value)||0})),placeholder:"Leave blank for untracked",min:"0"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Compare-at price (USD)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.compareAtUsd===""?"":b.compareAtUsd,onChange:C=>j(I=>({...I,compareAtUsd:C.target.value===""?"":parseFloat(C.target.value)||0})),placeholder:"e.g., 78.00",min:"0",step:"0.01"})]})]}),r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Price (USD)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:b.priceUsd===""?"":b.priceUsd,onChange:C=>j(I=>({...I,priceUsd:C.target.value===""?"":parseFloat(C.target.value)||0})),placeholder:"e.g., 5.00",min:"0",step:"0.01",required:!0})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Tags (comma-separated)"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.tagsCsv,onChange:C=>j(I=>({...I,tagsCsv:C.target.value})),placeholder:"e.g., core, new, gift"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs (comma-separated)"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.categoryIdsCsv,onChange:C=>j(I=>({...I,categoryIdsCsv:C.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:b.checkoutEmail,onChange:C=>j(I=>({...I,checkoutEmail:C})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Email"}),r.jsx(Ct,{value:b.checkoutName,onChange:C=>j(I=>({...I,checkoutName:C})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Name"}),r.jsx(Ct,{value:b.checkoutPhone,onChange:C=>j(I=>({...I,checkoutPhone:C})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Phone"})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[b.fulfillmentType==="shipping"&&r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Shipping address"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:b.checkoutShippingAddress,onChange:C=>j(I=>({...I,checkoutShippingAddress:C.target.checked}))}),"Collect shipping address"]})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Checkout: Billing address"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:b.checkoutBillingAddress,onChange:C=>j(I=>({...I,checkoutBillingAddress:C.target.checked}))}),"Collect billing address"]})]})]}),r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Fulfillment notes"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.fulfillmentNotes,onChange:C=>j(I=>({...I,fulfillmentNotes:C.target.value})),placeholder:b.fulfillmentType==="shipping"?"e.g., Ships within 3-5 business days":"e.g., Downloadable from your account after purchase"})]})}),b.fulfillmentType==="shipping"&&b.checkoutShippingAddress&&r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Shipping countries"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:b.shippingCountriesCsv,onChange:C=>j(I=>({...I,shippingCountriesCsv:C.target.value})),placeholder:"e.g., US,CA"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"ISO 2-letter country codes, comma-separated. Required for shipping address collection."})]})}),r.jsx("div",{className:"cedros-admin__form-actions",children:r.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:f,children:f?"Creating...":"Create Product"})})]}),i?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading products..."]}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":v?.key==="id"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>B("id"),children:["ID",H("id")]})}),r.jsx("th",{"aria-sort":v?.key==="product"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>B("product"),children:["Product",H("product")]})}),r.jsx("th",{"aria-sort":v?.key==="type"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>B("type"),children:["Type",H("type")]})}),r.jsx("th",{"aria-sort":v?.key==="price"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>B("price"),children:["Price",H("price")]})}),r.jsx("th",{"aria-sort":v?.key==="status"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>B("status"),children:["Status",H("status")]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:D.map(C=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:C.id})}),r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[P(C)?r.jsx("img",{src:P(C),alt:"",style:{width:28,height:28,borderRadius:6,objectFit:"cover"}}):r.jsx("div",{style:{width:28,height:28,borderRadius:6,background:"rgba(0,0,0,0.06)"}}),r.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[r.jsx("span",{style:{fontWeight:600},children:E(C)}),r.jsx("span",{style:{opacity:.8},children:C.description})]})]})}),r.jsx("td",{children:$(C.metadata?.product_type)}),r.jsx("td",{children:U(C.fiatAmountCents)}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge ${C.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:C.active?"Active":"Inactive"})}),r.jsx("td",{children:r.jsx("div",{style:{display:"flex",gap:"0.25rem"},children:r.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>h(C),children:"Variations"})})})]},C.id))})]})}),x&&r.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>h(null),children:r.jsx("div",{className:"cedros-admin__modal cedros-admin__modal--lg",onClick:C=>C.stopPropagation(),children:r.jsx(im,{serverUrl:e,productId:x.id,productTitle:E(x),defaultPrice:x.fiatAmountCents/100,apiKey:t,authManager:s,onClose:()=>h(null)})})})]})}function Wc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=w.useState([]),[i,c]=w.useState(null),[l,d]=w.useState(!0),[f,u]=w.useState(!0),[g,p]=w.useState(null),[x,h]=w.useState(""),[v,y]=w.useState(null),k=w.useCallback(async()=>{u(!0);try{p(null);let A;if(s?.isAuthenticated())A=await s.fetchWithAuth("/admin/stats");else{const E={"Content-Type":"application/json"};t&&(E["X-API-Key"]=t);const P=await fetch(`${e}/admin/stats`,{headers:E});if(!P.ok)throw new Error(`Failed to fetch stats: ${P.status}`);A=await P.json()}c(A)}catch{c(null),p("Failed to load payment stats")}finally{u(!1)}},[e,t,s]);w.useEffect(()=>{k()},[k]);const _=w.useCallback(async()=>{try{p(null);let A;const E=new URLSearchParams({limit:n.toString()});x&&E.set("method",x);const P=`/admin/transactions?${E}`;if(s?.isAuthenticated())A=await s.fetchWithAuth(P);else{const F={"Content-Type":"application/json"};t&&(F["X-API-Key"]=t);const L=await fetch(`${e}${P}`,{headers:F});if(!L.ok)throw new Error(`Failed to fetch transactions: ${L.status}`);A=await L.json()}a(A.transactions||[])}catch{a([]),p("Failed to load transactions")}finally{d(!1)}},[e,t,n,x,s]);w.useEffect(()=>{_()},[_]);const b=(A,E="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:E}).format(A),j=A=>{y(E=>!E||E.key!==A?{key:A,direction:"asc"}:{key:A,direction:E.direction==="asc"?"desc":"asc"})},N=A=>!v||v.key!==A?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:J.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:v.direction==="asc"?J.chevronUp:J.chevronDown}),T=w.useMemo(()=>{if(!v)return o;const A=v.direction==="asc"?1:-1,E=P=>{switch(v.key){case"resource":return P.resourceId;case"method":return P.method;case"amount":return P.amount;case"status":return P.status;case"date":return new Date(P.paidAt).getTime();case"id":default:return P.id}};return[...o].sort((P,F)=>{const L=E(P),U=E(F);return typeof L=="number"&&typeof U=="number"?(L-U)*A:String(L).localeCompare(String(U),void 0,{sensitivity:"base"})*A})},[o,v]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:g,onRetry:()=>{k(),_()}}),r.jsx(Cr,{stats:[{label:"Revenue",value:b(i?.totalRevenue??0)},{label:"Orders",value:i?.totalTransactions??0},{label:"Card",value:b(i?.revenueByMethod.stripe??0),description:`${i?.transactionsByMethod.stripe??0} orders`},{label:"Crypto",value:b(i?.revenueByMethod.x402??0),description:`${i?.transactionsByMethod.x402??0} orders`},{label:"Credits",value:b(i?.revenueByMethod.credits??0),description:`${i?.transactionsByMethod.credits??0} orders`}],isLoading:f,onRefresh:k}),r.jsxs("div",{className:"cedros-admin__section-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:"Transaction History"}),r.jsx(Uc,{value:x,onChange:h,options:[{value:"",label:"All"},{value:"stripe",label:"Card"},{value:"x402",label:"Crypto"},{value:"credits",label:"Credits"}]})]}),l?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading transactions..."]}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":v?.key==="id"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("id"),children:["ID",N("id")]})}),r.jsx("th",{"aria-sort":v?.key==="resource"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("resource"),children:["Resource",N("resource")]})}),r.jsx("th",{"aria-sort":v?.key==="method"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("method"),children:["Method",N("method")]})}),r.jsx("th",{"aria-sort":v?.key==="amount"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("amount"),children:["Amount",N("amount")]})}),r.jsx("th",{"aria-sort":v?.key==="status"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("status"),children:["Status",N("status")]})}),r.jsx("th",{"aria-sort":v?.key==="date"?v?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("date"),children:["Date",N("date")]})})]})}),r.jsx("tbody",{children:T.map(A=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:A.id})}),r.jsx("td",{children:A.resourceId}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${A.method}`,children:A.method})}),r.jsxs("td",{children:["$",A.amount.toFixed(2)," ",A.currency.toUpperCase()]}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${A.status}`,children:A.status})}),r.jsx("td",{children:dr(A.paidAt)})]},A.id))})]})})]})}function qc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=w.useState([]),[i,c]=w.useState(!0),[l,d]=w.useState(!1),[f,u]=w.useState(!1),[g,p]=w.useState(null),[x,h]=w.useState(null),[v,y]=w.useState({code:"",discountType:"percentage",discountValue:0,usageLimit:void 0,expiresAt:"",scope:"all_products",productIdsCsv:"",categoryIdsCsv:"",paymentMethod:"any",autoApply:!1,appliesAt:"both",startsAt:"",minimumAmountUsd:"",usageLimitPerCustomer:void 0,firstPurchaseOnly:!1}),k=w.useCallback(async()=>{try{h(null);let E;const P=`/admin/coupons?limit=${n}`;if(s?.isAuthenticated())E=await s.fetchWithAuth(P);else{const F={"Content-Type":"application/json"};t&&(F["X-API-Key"]=t);const L=await fetch(`${e}${P}`,{headers:F});if(!L.ok)throw new Error(`Failed to fetch coupons: ${L.status}`);E=await L.json()}a(E.coupons||[])}catch(E){Ie.getLogger().error("[CouponsSection] Failed to fetch coupons:",E,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),h("Failed to load coupons")}finally{c(!1)}},[e,t,n,s]);w.useEffect(()=>{k()},[k]);const _=async E=>{if(E.preventDefault(),!(!v.code||v.discountValue<=0)){u(!0);try{const P=v.minimumAmountUsd?Math.round(Number(v.minimumAmountUsd)*100):void 0,F=v.productIdsCsv.split(",").map($=>$.trim()).filter(Boolean),L=v.categoryIdsCsv.split(",").map($=>$.trim()).filter(Boolean),U={code:v.code,discountType:v.discountType,discountValue:v.discountValue,usageLimit:v.usageLimit,active:!0,usageCount:0,scope:v.scope,...F.length?{productIds:F}:{},...L.length?{categoryIds:L}:{},...v.paymentMethod!=="any"?{paymentMethod:v.paymentMethod}:{},...v.autoApply?{autoApply:!0}:{},...v.appliesAt!=="both"?{appliesAt:v.appliesAt}:{},...v.startsAt?{startsAt:v.startsAt}:{},...v.expiresAt?{expiresAt:v.expiresAt}:{},...P?{minimumAmountCents:P}:{},...v.usageLimitPerCustomer?{usageLimitPerCustomer:v.usageLimitPerCustomer}:{},...v.firstPurchaseOnly?{firstPurchaseOnly:!0}:{}};if(s?.isAuthenticated())await s.fetchWithAuth("/admin/coupons",{method:"POST",body:JSON.stringify(U)});else{const $={"Content-Type":"application/json"};t&&($["X-API-Key"]=t);const Y=await fetch(`${e}/admin/coupons`,{method:"POST",headers:$,body:JSON.stringify(U)});if(!Y.ok)throw new Error(`Failed to create coupon: ${Y.status}`)}y({code:"",discountType:"percentage",discountValue:0,usageLimit:void 0,expiresAt:"",scope:"all_products",productIdsCsv:"",categoryIdsCsv:"",paymentMethod:"any",autoApply:!1,appliesAt:"both",startsAt:"",minimumAmountUsd:"",usageLimitPerCustomer:void 0,firstPurchaseOnly:!1}),d(!1),k()}catch(P){Ie.getLogger().error("[CouponsSection] Failed to add coupon:",P,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),h("Failed to create coupon")}finally{u(!1)}}},b=o.filter(E=>E.active).length,j=o.reduce((E,P)=>E+(P.usageCount??0),0),N=E=>{p(P=>!P||P.key!==E?{key:E,direction:"asc"}:{key:E,direction:P.direction==="asc"?"desc":"asc"})},T=E=>!g||g.key!==E?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:J.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:g.direction==="asc"?J.chevronUp:J.chevronDown}),A=w.useMemo(()=>{if(!g)return o;const E=g.direction==="asc"?1:-1,P=F=>{switch(g.key){case"discount":return F.discountValue??0;case"usage":return F.usageCount??0;case"status":return F.active?1:0;case"code":default:return F.code}};return[...o].sort((F,L)=>{const U=P(F),$=P(L);return typeof U=="number"&&typeof $=="number"?(U-$)*E:String(U).localeCompare(String($),void 0,{sensitivity:"base"})*E})},[o,g]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:x,onRetry:k}),r.jsx(Cr,{stats:[{label:"Total Coupons",value:o.length},{label:"Active",value:b,variant:b>0?"success":"muted"},{label:"Redemptions",value:j}],isLoading:i}),r.jsxs("div",{className:"cedros-admin__section-header",children:[r.jsx("h3",{className:"cedros-admin__section-title",children:"Discount Coupons"}),r.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:()=>d(!l),children:[l?J.close:J.plus,l?"Cancel":"Add Coupon"]})]}),l&&r.jsxs("form",{onSubmit:_,className:"cedros-admin__add-form",children:[r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Coupon Code"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:v.code,onChange:E=>y(P=>({...P,code:E.target.value.toUpperCase()})),placeholder:"e.g., SAVE20",required:!0})]}),r.jsx(Ct,{value:v.discountType,onChange:E=>y(P=>({...P,discountType:E})),options:[{value:"percentage",label:"Percentage (%)"},{value:"fixed",label:"Fixed Amount ($)"}],label:"Discount Type"})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsxs("label",{className:"cedros-admin__field-label",children:["Discount Value ",v.discountType==="percentage"?"(%)":"($)"]}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:v.discountValue||"",onChange:E=>y(P=>({...P,discountValue:parseFloat(E.target.value)||0})),placeholder:v.discountType==="percentage"?"e.g., 20":"e.g., 10.00",min:"0",step:v.discountType==="percentage"?"1":"0.01",required:!0})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Usage Limit (optional)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:v.usageLimit||"",onChange:E=>y(P=>({...P,usageLimit:E.target.value?parseInt(E.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Expiration Date (optional)"}),r.jsx("input",{type:"date",className:"cedros-admin__input",value:v.expiresAt,onChange:E=>y(P=>({...P,expiresAt:E.target.value}))})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(Ct,{value:v.scope,onChange:E=>y(P=>({...P,scope:E})),options:[{value:"all_products",label:"All Products"},{value:"specific_products",label:"Specific Products"},{value:"specific_categories",label:"Specific Categories"}],label:"Scope"}),r.jsx(Ct,{value:v.paymentMethod,onChange:E=>y(P=>({...P,paymentMethod:E})),options:[{value:"any",label:"Any Payment Method"},{value:"stripe",label:"Stripe (Card) Only"},{value:"x402",label:"Crypto (x402) Only"},{value:"credits",label:"Credits Only"}],label:"Payment Method"}),r.jsx(Ct,{value:v.appliesAt,onChange:E=>y(P=>({...P,appliesAt:E})),options:[{value:"both",label:"Cart & Checkout"},{value:"cart",label:"Cart Only"},{value:"checkout",label:"Checkout Only"}],label:"Applies At"})]}),v.scope==="specific_products"&&r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Product IDs"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:v.productIdsCsv,onChange:E=>y(P=>({...P,productIdsCsv:E.target.value})),placeholder:"e.g., prod_123, prod_456"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated product IDs this coupon applies to."})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Start Date (optional)"}),r.jsx("input",{type:"date",className:"cedros-admin__input",value:v.startsAt,onChange:E=>y(P=>({...P,startsAt:E.target.value}))})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Auto Apply"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:v.autoApply,onChange:E=>y(P=>({...P,autoApply:E.target.checked}))}),"Automatically apply when conditions met"]})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Minimum Purchase (USD)"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:v.minimumAmountUsd===""?"":v.minimumAmountUsd,onChange:E=>y(P=>({...P,minimumAmountUsd:E.target.value===""?"":parseFloat(E.target.value)||0})),placeholder:"e.g., 50.00",min:"0",step:"0.01"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Per-Customer Limit"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:v.usageLimitPerCustomer||"",onChange:E=>y(P=>({...P,usageLimitPerCustomer:E.target.value?parseInt(E.target.value):void 0})),placeholder:"Leave empty for unlimited",min:"1"})]}),r.jsxs("div",{className:"cedros-admin__field",children:[r.jsx("label",{className:"cedros-admin__field-label",children:"First Purchase Only"}),r.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[r.jsx("input",{type:"checkbox",checked:v.firstPurchaseOnly,onChange:E=>y(P=>({...P,firstPurchaseOnly:E.target.checked}))}),"New customers only"]})]})]}),v.scope==="specific_categories"&&r.jsx("div",{className:"cedros-admin__form-row",children:r.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[r.jsx("label",{className:"cedros-admin__field-label",children:"Category IDs"}),r.jsx("input",{type:"text",className:"cedros-admin__input",value:v.categoryIdsCsv,onChange:E=>y(P=>({...P,categoryIdsCsv:E.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"}),r.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Comma-separated category IDs this coupon applies to."})]})}),r.jsx("div",{className:"cedros-admin__form-actions",children:r.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:f,children:f?"Creating...":"Create Coupon"})})]}),i?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading coupons..."]}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":g?.key==="code"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>N("code"),children:["Code",T("code")]})}),r.jsx("th",{"aria-sort":g?.key==="discount"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>N("discount"),children:["Discount",T("discount")]})}),r.jsx("th",{"aria-sort":g?.key==="usage"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>N("usage"),children:["Usage",T("usage")]})}),r.jsx("th",{"aria-sort":g?.key==="status"?g?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>N("status"),children:["Status",T("status")]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:A.map(E=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:E.code})}),r.jsx("td",{children:E.discountType==="percentage"?`${E.discountValue}%`:`$${E.discountValue.toFixed(2)}`}),r.jsxs("td",{children:[E.usageCount,E.usageLimit?` / ${E.usageLimit}`:""]}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge ${E.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:E.active?"Active":"Inactive"})}),r.jsx("td",{children:r.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",children:"Edit"})})]},E.code))})]})})]})}function Hc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=w.useState([]),[i,c]=w.useState(!0),[l,d]=w.useState(null),[f,u]=w.useState([]),[g,p]=w.useState(!0),[x,h]=w.useState(null),[v,y]=w.useState([]),[k,_]=w.useState(!0),[b,j]=w.useState(null),[N,T]=w.useState(null),[A,E]=w.useState(null),P=w.useCallback(async()=>{try{let M;const ee=`/admin/refunds?limit=${n}`;if(s?.isAuthenticated())M=await s.fetchWithAuth(ee);else{const ce={"Content-Type":"application/json"};t&&(ce["X-API-Key"]=t);const _e=await fetch(`${e}${ee}`,{headers:ce});if(!_e.ok)throw new Error(`Failed to fetch x402 refunds: ${_e.status}`);M=await _e.json()}a(M.refunds||[])}catch(M){Ie.getLogger().error("[RefundsSection] Failed to fetch x402 refunds:",M,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),E("Failed to load x402 refunds")}finally{c(!1)}},[e,t,n,s]);w.useEffect(()=>{P()},[P]);const F=w.useCallback(async()=>{try{let M;const ee=`/admin/credits/refund-requests?status=pending&limit=${n}&offset=0`;if(s?.isAuthenticated())M=await s.fetchWithAuth(ee);else{const _e={"Content-Type":"application/json"};t&&(_e["X-API-Key"]=t);const be=await fetch(`${e}${ee}`,{headers:_e});if(!be.ok)throw new Error(`Failed to fetch credits refund requests: ${be.status}`);M=await be.json()}const ce=Array.isArray(M)?M:"refundRequests"in M?M.refundRequests:M.requests||[];u(ce)}catch(M){Ie.getLogger().error("[RefundsSection] Failed to fetch credits refunds:",M,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),u([]),E("Failed to load credits refunds")}finally{p(!1)}},[e,t,n,s]);w.useEffect(()=>{F()},[F]);const L=w.useCallback(async()=>{try{let M;const ee=`/admin/stripe/refunds?limit=${n}`;if(s?.isAuthenticated())M=await s.fetchWithAuth(ee);else{const ce={"Content-Type":"application/json"};t&&(ce["X-API-Key"]=t);const _e=await fetch(`${e}${ee}`,{headers:ce});if(!_e.ok)throw new Error(`Failed to fetch Stripe refunds: ${_e.status}`);M=await _e.json()}y(M.refunds||[])}catch(M){Ie.getLogger().error("[RefundsSection] Failed to fetch Stripe refunds:",M,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),y([]),E("Failed to load Stripe refunds")}finally{_(!1)}},[e,t,n,s]);w.useEffect(()=>{L()},[L]);const U=async M=>{j(M);try{const ee=`/admin/stripe/refunds/${M}/process`;if(s?.isAuthenticated())await s.fetchWithAuth(ee,{method:"POST"});else{const ce={"Content-Type":"application/json"};t&&(ce["X-API-Key"]=t);const _e=await fetch(`${e}${ee}`,{method:"POST",headers:ce});if(!_e.ok)throw new Error(`Failed to process refund: ${_e.status}`)}await L()}catch(ee){Ie.getLogger().error("[RefundsSection] Failed to process Stripe refund:",ee,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,refundId:M}),E("Failed to process Stripe refund")}finally{j(null)}},$=(M,ee)=>new Intl.NumberFormat("en-US",{style:"currency",currency:ee}).format(M/100),Y=M=>M?M.replace(/_/g," ").replace(/\b\w/g,ee=>ee.toUpperCase()):"—",B=M=>{switch(M){case"processed":return"success";case"pending":return"pending";case"rejected":default:return"muted"}},H=(M,ee)=>ee?ee.toLowerCase()==="usd"?`${new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(M/1e6)} (USD credits)`:`${M.toLocaleString()} ${ee.toUpperCase()} (atomic)`:`${M.toLocaleString()} (atomic)`,D=M=>{switch(M){case"succeeded":return"success";case"failed":return"failed";case"pending":case"requires_action":return"pending";case"canceled":default:return"muted"}},C=M=>M.stripeRefundId??"—",I=M=>M.chargeId??"—",Z=v.filter(M=>M.status==="pending"||M.status==="requires_action").length,ve=f.filter(M=>M.status==="pending").length,V=o.filter(M=>M.status==="pending").length,Q=Z+ve+V,K=v.filter(M=>M.status==="succeeded").reduce((M,ee)=>M+ee.amount,0),le=f.filter(M=>M.status==="processed").reduce((M,ee)=>M+ee.amountLamports,0),R=o.filter(M=>M.status==="completed").reduce((M,ee)=>M+ee.amount,0),G=K/100+le/1e6+R,ue=M=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(M),W=k||g||i,se=M=>{T(ee=>!ee||ee.key!==M?{key:M,direction:"asc"}:{key:M,direction:ee.direction==="asc"?"desc":"asc"})},ie=M=>{h(ee=>!ee||ee.key!==M?{key:M,direction:"asc"}:{key:M,direction:ee.direction==="asc"?"desc":"asc"})},ye=M=>{d(ee=>!ee||ee.key!==M?{key:M,direction:"asc"}:{key:M,direction:ee.direction==="asc"?"desc":"asc"})},fe=(M,ee)=>!M||!ee?r.jsx("span",{className:"cedros-admin__sort-icon cedros-admin__sort-icon--idle",children:J.chevronUp}):r.jsx("span",{className:"cedros-admin__sort-icon",children:ee==="asc"?J.chevronUp:J.chevronDown}),Ue=w.useMemo(()=>{if(!N)return v;const M=N.direction==="asc"?1:-1,ee=ce=>{switch(N.key){case"stripe":return ce.stripeRefundId??"";case"charge":return ce.chargeId??"";case"amount":return ce.amount??0;case"reason":return ce.reason??"";case"status":return ce.status??"";case"date":return new Date(ce.createdAt).getTime();case"id":default:return ce.id}};return[...v].sort((ce,_e)=>{const be=ee(ce),Me=ee(_e);return typeof be=="number"&&typeof Me=="number"?(be-Me)*M:String(be).localeCompare(String(Me),void 0,{sensitivity:"base"})*M})},[v,N]),Qe=w.useMemo(()=>{if(!x)return f;const M=x.direction==="asc"?1:-1,ee=ce=>{switch(x.key){case"original":return ce.originalTransactionId??"";case"user":return ce.userId??"";case"amount":return ce.amountLamports??0;case"reason":return ce.reason??"";case"status":return ce.status??"";case"date":return new Date(ce.createdAt).getTime();case"id":default:return ce.id}};return[...f].sort((ce,_e)=>{const be=ee(ce),Me=ee(_e);return typeof be=="number"&&typeof Me=="number"?(be-Me)*M:String(be).localeCompare(String(Me),void 0,{sensitivity:"base"})*M})},[f,x]),Ve=w.useMemo(()=>{if(!l)return o;const M=l.direction==="asc"?1:-1,ee=ce=>{switch(l.key){case"transaction":return ce.transactionId??"";case"amount":return ce.amount??0;case"reason":return ce.reason??"";case"status":return ce.status??"";case"date":return new Date(ce.createdAt).getTime();case"id":default:return ce.id}};return[...o].sort((ce,_e)=>{const be=ee(ce),Me=ee(_e);return typeof be=="number"&&typeof Me=="number"?(be-Me)*M:String(be).localeCompare(String(Me),void 0,{sensitivity:"base"})*M})},[o,l]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:A,onRetry:()=>{P(),F(),L()}}),r.jsx(Cr,{stats:[{label:"Pending",value:Q,variant:Q>0?"warning":"muted"},{label:"Card Pending",value:Z,description:"Stripe"},{label:"Credits Pending",value:ve},{label:"Crypto Pending",value:V,description:"x402"},{label:"Total Refunded",value:ue(G),variant:"success"}],isLoading:W}),r.jsx("div",{className:"cedros-admin__section-header",children:r.jsx("h3",{className:"cedros-admin__section-title",children:"Stripe Refund Requests"})}),k?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading Stripe refunds..."]}):v.length===0?r.jsx("div",{className:"cedros-admin__empty",children:"No Stripe refund requests found."}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":N?.key==="id"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("id"),children:["Request ID",fe(N?.key==="id",N?.direction)]})}),r.jsx("th",{"aria-sort":N?.key==="stripe"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("stripe"),children:["Stripe Refund ID",fe(N?.key==="stripe",N?.direction)]})}),r.jsx("th",{"aria-sort":N?.key==="charge"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("charge"),children:["Charge",fe(N?.key==="charge",N?.direction)]})}),r.jsx("th",{"aria-sort":N?.key==="amount"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("amount"),children:["Amount",fe(N?.key==="amount",N?.direction)]})}),r.jsx("th",{"aria-sort":N?.key==="reason"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("reason"),children:["Reason",fe(N?.key==="reason",N?.direction)]})}),r.jsx("th",{"aria-sort":N?.key==="status"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("status"),children:["Status",fe(N?.key==="status",N?.direction)]})}),r.jsx("th",{"aria-sort":N?.key==="date"?N?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>se("date"),children:["Date",fe(N?.key==="date",N?.direction)]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:Ue.map(M=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:M.id})}),r.jsx("td",{children:r.jsx("code",{children:C(M)})}),r.jsx("td",{children:r.jsx("code",{children:I(M)})}),r.jsx("td",{children:$(M.amount,M.currency)}),r.jsx("td",{children:Y(M.reason)}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${D(M.status)}`,children:M.status})}),r.jsx("td",{children:dr(M.createdAt)}),r.jsx("td",{children:(M.status==="pending"||M.status==="requires_action")&&r.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>U(M.id),disabled:b===M.id,children:b===M.id?"Processing...":"Process"})})]},M.id))})]})}),r.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:r.jsx("h3",{className:"cedros-admin__section-title",children:"Credits Refund Requests"})}),r.jsx("p",{className:"cedros-admin__hint",style:{marginBottom:"0.75rem"},children:"Credits refund requests are read-only in this admin surface."}),g?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading credits refunds..."]}):f.length===0?r.jsx("div",{className:"cedros-admin__empty",children:"No credits refund requests found."}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":x?.key==="id"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("id"),children:["Request ID",fe(x?.key==="id",x?.direction)]})}),r.jsx("th",{"aria-sort":x?.key==="original"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("original"),children:["Original Tx",fe(x?.key==="original",x?.direction)]})}),r.jsx("th",{"aria-sort":x?.key==="user"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("user"),children:["User",fe(x?.key==="user",x?.direction)]})}),r.jsx("th",{"aria-sort":x?.key==="amount"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("amount"),children:["Amount",fe(x?.key==="amount",x?.direction)]})}),r.jsx("th",{"aria-sort":x?.key==="reason"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("reason"),children:["Reason",fe(x?.key==="reason",x?.direction)]})}),r.jsx("th",{"aria-sort":x?.key==="status"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("status"),children:["Status",fe(x?.key==="status",x?.direction)]})}),r.jsx("th",{"aria-sort":x?.key==="date"?x?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ie("date"),children:["Date",fe(x?.key==="date",x?.direction)]})})]})}),r.jsx("tbody",{children:Qe.map(M=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:M.id})}),r.jsx("td",{children:r.jsx("code",{children:M.originalTransactionId})}),r.jsx("td",{children:r.jsx("code",{children:M.userId??"—"})}),r.jsx("td",{children:H(M.amountLamports,M.currency)}),r.jsx("td",{children:M.reason??"—"}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${B(M.status)}`,children:M.status})}),r.jsx("td",{children:dr(M.createdAt)})]},M.id))})]})}),r.jsx("div",{className:"cedros-admin__section-header",style:{marginTop:"2rem"},children:r.jsx("h3",{className:"cedros-admin__section-title",children:"x402 Refund Requests"})}),r.jsx("p",{className:"cedros-admin__hint",style:{marginBottom:"0.75rem"},children:"x402 refund approvals use the signed refund workflow, not this dashboard table."}),i?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading x402 refunds..."]}):o.length===0?r.jsx("div",{className:"cedros-admin__empty",children:"No x402 refund requests found."}):r.jsx("div",{className:"cedros-admin__table-container",children:r.jsxs("table",{className:"cedros-admin__table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{"aria-sort":l?.key==="id"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("id"),children:["ID",fe(l?.key==="id",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="transaction"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("transaction"),children:["Transaction",fe(l?.key==="transaction",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="amount"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("amount"),children:["Amount",fe(l?.key==="amount",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="reason"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("reason"),children:["Reason",fe(l?.key==="reason",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="status"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("status"),children:["Status",fe(l?.key==="status",l?.direction)]})}),r.jsx("th",{"aria-sort":l?.key==="date"?l?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>ye("date"),children:["Date",fe(l?.key==="date",l?.direction)]})})]})}),r.jsx("tbody",{children:Ve.map(M=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:M.id})}),r.jsx("td",{children:r.jsx("code",{children:M.transactionId})}),r.jsxs("td",{children:["$",M.amount.toFixed(2)]}),r.jsx("td",{children:M.reason||"—"}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${M.status}`,children:M.status})}),r.jsx("td",{children:dr(M.createdAt)})]},M.id))})]})})]})}const cm=w.lazy(()=>Promise.resolve().then(()=>require("./SettingsSection-DUTEd6uV.js")).then(e=>({default:e.SettingsSection})));function Zc(e){return r.jsx(w.Suspense,{fallback:null,children:r.jsx(cm,{...e})})}class Gc{serverUrl;walletSigner=null;jwtToken=null;isAdminUser=!1;constructor(t){this.serverUrl=t}getAuthMethod(){return this.walletSigner?.publicKey&&this.walletSigner.signMessage?"wallet":this.jwtToken&&this.isAdminUser?"cedros-login":"none"}isAuthenticated(){return this.getAuthMethod()!=="none"}setWalletSigner(t){this.walletSigner=t,Ie.getLogger().debug("[AdminAuthManager] Wallet signer updated:",!!t?.publicKey)}setCedrosLoginAuth(t,n){this.jwtToken=t,this.isAdminUser=n??!1,Ie.getLogger().debug("[AdminAuthManager] Cedros-login auth updated:",{hasToken:!!t,isAdmin:this.isAdminUser})}async createAuthHeaders(t){const n=this.getAuthMethod();if(n==="wallet")return this.createWalletAuthHeaders(t);if(n==="cedros-login")return this.createJwtAuthHeaders();throw new Error("No admin authentication configured. Connect a wallet or sign in as admin.")}async createWalletAuthHeaders(t){if(!this.walletSigner?.publicKey||!this.walletSigner.signMessage)throw new Error("Wallet not connected or does not support message signing");const n=await this.fetchNonce(t),s=new TextEncoder().encode(n.nonce),o=await this.walletSigner.signMessage(s),a=em.bs58.encode(this.walletSigner.publicKey.toBytes()),i=Ie.gBase64.fromUint8Array(o);return{"X-Signer":a,"X-Message":n.nonce,"X-Signature":i}}createJwtAuthHeaders(){if(!this.jwtToken)throw new Error("No JWT token available");return{Authorization:`Bearer ${this.jwtToken}`}}async fetchNonce(t){const n=`${this.serverUrl}/paywall/v1/nonce`,s=typeof t=="string"?{purpose:t}:{path:t.path,method:t.method.toUpperCase()};Ie.getLogger().debug("[AdminAuthManager] Fetching nonce:",s);const o=await Ie.fetchWithTimeout(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok){const a=await o.text();throw new Error(`Failed to fetch nonce: ${o.status} ${a}`)}return await o.json()}async fetchWithAuth(t,n={}){if(this.getAuthMethod()==="none")throw new Error("No admin authentication configured");const o=(n.method||"GET").toUpperCase(),a=await this.createAuthHeaders({path:t,method:o}),i={...o!=="GET"&&o!=="HEAD"?{"Content-Type":"application/json"}:{},...n.headers||{},...a},c=await Ie.fetchWithTimeout(`${this.serverUrl}${t}`,{...n,headers:i});if(!c.ok){let l=`Admin API error ${c.status}`;try{const d=await c.json();d&&typeof d.error=="string"?l=d.error:d&&typeof d.message=="string"&&(l=d.message)}catch{}throw new Error(l)}return await c.json()}}const lm={publicKey:null};function dm({serverUrl:e,cedrosLoginToken:t,isAdmin:n=!1,wallet:s=lm}){const o=w.useMemo(()=>{const u=new Gc(e);return u.setCedrosLoginAuth(t??null,n),u},[e,t,n]);w.useEffect(()=>{s.publicKey&&s.signMessage?o.setWalletSigner({publicKey:s.publicKey,signMessage:s.signMessage}):o.setWalletSigner(null)},[o,s.publicKey,s.signMessage]);const a=o.getAuthMethod(),i=o.isAuthenticated(),c=!!(s.publicKey&&s.signMessage),l=!!(t&&n),d=w.useMemo(()=>{if(!s.publicKey)return null;const u=s.publicKey.toBase58();return`${u.slice(0,4)}...${u.slice(-4)}`},[s.publicKey]),f=w.useCallback((u,g)=>o.fetchWithAuth(u,g),[o]);return{authMethod:a,isAuthenticated:i,walletConnected:c,walletAddress:d,cedrosLoginAvailable:l,authManager:o,fetchWithAuth:f}}const um=w.lazy(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-C4BRN1dP.js")).then(e=>({default:e.SubscriptionsSection}))),fm=w.lazy(()=>Promise.resolve().then(()=>require("./StorefrontSection-Du7hV2Gc.js")).then(e=>({default:e.StorefrontSection}))),mm=w.lazy(()=>Promise.resolve().then(()=>require("./AISettingsSection-BvSSiK2G.js")).then(e=>({default:e.AISettingsSection}))),pm=w.lazy(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-enTbUI95.js")).then(e=>({default:e.PaymentSettingsSection}))),hm=w.lazy(()=>Promise.resolve().then(()=>require("./MessagingSection-DrXb578q.js")).then(e=>({default:e.MessagingSection}))),gm=w.lazy(()=>Promise.resolve().then(()=>require("./FAQSection-6nGI0FK9.js")).then(e=>({default:e.FAQSection}))),xm=w.lazy(()=>Promise.resolve().then(()=>require("./Token22Section-0c22NM5G.js")).then(e=>({default:e.Token22Section}))),vm=w.lazy(()=>Promise.resolve().then(()=>require("./OrdersSection-_-rIw6XW.js")).then(e=>({default:e.OrdersSection}))),ym=w.lazy(()=>Promise.resolve().then(()=>require("./ComplianceSection-D6ETKG6b.js")).then(e=>({default:e.ComplianceSection}))),Yc=[{label:"Menu",sections:[{id:"transactions",label:"Transactions",icon:J.transactions},{id:"orders",label:"Orders",icon:J.transactions},{id:"products",label:"Products",icon:J.products},{id:"subscriptions",label:"Subscriptions",icon:J.calendarRepeat},{id:"coupons",label:"Coupons",icon:J.coupons},{id:"refunds",label:"Refunds",icon:J.refunds},{id:"compliance",label:"Compliance",icon:J.shield}]},{label:"Configuration",collapsible:!0,sections:[{id:"storefront",label:"Storefront",icon:J.storefront},{id:"ai-settings",label:"Store AI",icon:J.brain},{id:"faqs",label:"Knowledge Base",icon:J.faq},{id:"payment-settings",label:"Payment Options",icon:J.creditCard},{id:"token22",label:"Gift Cards & Token-22",icon:J.wallet},{id:"messaging",label:"Store Messages",icon:J.mail},{id:"settings",label:"Store Server",icon:J.server}]}],bm=Yc.flatMap(e=>e.sections);function wm(){const[e,t]=w.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return w.useEffect(()=>{const n=window.matchMedia("(prefers-color-scheme: dark)"),s=o=>t(o.matches?"dark":"light");return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[]),e}function km(e,t,n){return e!=="system"?e:t||n}function _m({serverUrl:e,apiKey:t,title:n="Cedros Pay",sections:s=["transactions","orders","products","subscriptions","coupons","refunds","storefront","ai-settings","faqs","payment-settings","messaging","settings"],defaultSection:o="transactions",refreshInterval:a=3e4,pageSize:i=20,onSectionChange:c,className:l="",cedrosLoginToken:d,isAdmin:f=!1,theme:u="system"}){const[g,p]=w.useState(o),[x]=w.useState(!1),[h,v]=w.useState(new Set),y=w.useCallback(L=>{v(U=>{const $=new Set(U);return $.has(L)?$.delete(L):$.add(L),$})},[]),k=Ie.useCedrosThemeOptional(),_=wm(),j=km(u,k?.mode??null,_)==="dark"?"cedros-admin--dark":"",N=Jf.useWallet(),{authManager:T,isAuthenticated:A}=dm({serverUrl:e,cedrosLoginToken:d,isAdmin:f,wallet:N}),E=w.useCallback(L=>{p(L),c?.(L)},[c]),F=bm.filter(L=>s.includes(L.id)).find(L=>L.id===g);return x?r.jsxs("div",{className:`cedros-admin cedros-admin--loading ${j} ${l}`,children:[J.loading,r.jsx("span",{className:"cedros-admin__loading-text",children:"Loading dashboard..."})]}):A?r.jsxs("div",{className:`cedros-admin ${j} ${l}`,children:[r.jsxs("aside",{className:"cedros-admin__sidebar",children:[r.jsx("div",{className:"cedros-admin__sidebar-header",children:r.jsxs("div",{className:"cedros-admin__logo",children:[J.wallet,r.jsx("span",{className:"cedros-admin__logo-text",children:n})]})}),r.jsx("nav",{className:"cedros-admin__nav",children:Yc.map(L=>{const U=L.sections.filter(Y=>s.includes(Y.id));if(U.length===0)return null;const $=L.collapsible&&h.has(L.label);return r.jsxs("div",{className:"cedros-admin__nav-group",children:[L.collapsible?r.jsxs("button",{type:"button",className:"cedros-admin__nav-label cedros-admin__nav-label--collapsible",onClick:()=>y(L.label),"aria-expanded":!$,children:[L.label,r.jsx("span",{className:`cedros-admin__nav-label-icon ${$?"":"cedros-admin__nav-label-icon--expanded"}`,children:J.chevronRight})]}):r.jsx("span",{className:"cedros-admin__nav-label",children:L.label}),!$&&U.map(Y=>r.jsxs("button",{type:"button",className:`cedros-admin__nav-item ${g===Y.id?"cedros-admin__nav-item--active":""}`,onClick:()=>E(Y.id),"aria-current":g===Y.id?"page":void 0,children:[r.jsx("span",{className:"cedros-admin__nav-icon",children:Y.icon}),r.jsx("span",{className:"cedros-admin__nav-text",children:Y.label})]},Y.id))]},L.label)})})]}),r.jsxs("main",{className:"cedros-admin__main",children:[r.jsx("header",{className:"cedros-admin__header",children:r.jsxs("div",{className:"cedros-admin__breadcrumb",children:[r.jsx("span",{className:"cedros-admin__breadcrumb-root",children:n}),r.jsx("span",{className:"cedros-admin__breadcrumb-sep",children:J.chevronRight}),r.jsx("span",{className:"cedros-admin__breadcrumb-current",children:F?.label})]})}),r.jsxs("div",{className:"cedros-admin__content",children:[g==="products"&&r.jsx(Vc,{serverUrl:e,apiKey:t,pageSize:i,authManager:T}),g==="subscriptions"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(um,{serverUrl:e,apiKey:t,authManager:T})}),g==="transactions"&&r.jsx(Wc,{serverUrl:e,apiKey:t,pageSize:i,authManager:T}),g==="orders"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(vm,{serverUrl:e,apiKey:t,pageSize:i,authManager:T})}),g==="coupons"&&r.jsx(qc,{serverUrl:e,apiKey:t,pageSize:i,authManager:T}),g==="refunds"&&r.jsx(Hc,{serverUrl:e,apiKey:t,pageSize:i,authManager:T}),g==="storefront"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(fm,{serverUrl:e,apiKey:t,authManager:T})}),g==="ai-settings"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(mm,{serverUrl:e,apiKey:t,authManager:T})}),g==="faqs"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(gm,{serverUrl:e,apiKey:t,pageSize:i,authManager:T})}),g==="payment-settings"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(pm,{serverUrl:e,apiKey:t,authManager:T})}),g==="messaging"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(hm,{serverUrl:e,apiKey:t,authManager:T})}),g==="compliance"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(ym,{serverUrl:e,apiKey:t,pageSize:i,authManager:T})}),g==="token22"&&r.jsx(w.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(xm,{serverUrl:e,apiKey:t,authManager:T})}),g==="settings"&&r.jsx(Zc,{serverUrl:e,apiKey:t,authManager:T})]})]})]}):r.jsx("div",{className:`cedros-admin cedros-admin--unauthenticated ${j} ${l}`,children:r.jsx("p",{className:"cedros-admin__auth-prompt",children:"Please connect a wallet or sign in as admin to access the dashboard."})})}const yt=e=>w.lazy(async()=>{const s=(await e()).default;return{default:({pluginContext:a})=>{const c=Xf.useCedrosLogin()?._internal?.getAccessToken()??a.getAccessToken(),l=a.hasPermission("cedros-pay:admin")||a.hasPermission("admin"),d=w.useMemo(()=>{const u=new Gc(a.serverUrl);return u.setCedrosLoginAuth(c??null,l),u},[l,a.serverUrl,c]),f={serverUrl:a.serverUrl,authManager:d};return r.jsx(s,{...f})}}}),jm={id:"cedros-pay",name:"Cedros Pay",version:"1.0.0",sections:[{id:"transactions",label:"Transactions",icon:J.transactions,group:"Store",order:0},{id:"products",label:"Products",icon:J.products,group:"Store",order:1},{id:"subscriptions",label:"Subscriptions",icon:J.subscriptions,group:"Store",order:2},{id:"coupons",label:"Coupons",icon:J.coupons,group:"Store",order:3},{id:"refunds",label:"Refunds",icon:J.refunds,group:"Store",order:4},{id:"compliance",label:"Compliance",icon:J.shield,group:"Store",order:5},{id:"storefront",label:"Storefront",icon:J.storefront,group:"Configuration",order:10},{id:"ai-settings",label:"Store AI",icon:J.ai,group:"Configuration",order:11},{id:"faqs",label:"Knowledge Base",icon:J.faq,group:"Configuration",order:12},{id:"payment-settings",label:"Payment Options",icon:J.wallet,group:"Configuration",order:13},{id:"messaging",label:"Store Messages",icon:J.notifications,group:"Configuration",order:14},{id:"settings",label:"Store Server",icon:J.settings,group:"Configuration",order:15}],groups:[{id:"Store",label:"Store",order:1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}],components:{products:yt(()=>Promise.resolve().then(()=>require("./sections-5jO2aHAo.js")).then(e=>({default:e.ProductsSection}))),subscriptions:yt(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-C4BRN1dP.js")).then(e=>({default:e.SubscriptionsSection}))),transactions:yt(()=>Promise.resolve().then(()=>require("./sections-5jO2aHAo.js")).then(e=>({default:e.TransactionsSection}))),coupons:yt(()=>Promise.resolve().then(()=>require("./sections-5jO2aHAo.js")).then(e=>({default:e.CouponsSection}))),refunds:yt(()=>Promise.resolve().then(()=>require("./sections-5jO2aHAo.js")).then(e=>({default:e.RefundsSection}))),compliance:yt(()=>Promise.resolve().then(()=>require("./ComplianceSection-D6ETKG6b.js")).then(e=>({default:e.ComplianceSection}))),storefront:yt(()=>Promise.resolve().then(()=>require("./StorefrontSection-Du7hV2Gc.js")).then(e=>({default:e.StorefrontSection}))),"ai-settings":yt(()=>Promise.resolve().then(()=>require("./AISettingsSection-BvSSiK2G.js")).then(e=>({default:e.AISettingsSection}))),faqs:yt(()=>Promise.resolve().then(()=>require("./FAQSection-6nGI0FK9.js")).then(e=>({default:e.FAQSection}))),"payment-settings":yt(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-enTbUI95.js")).then(e=>({default:e.PaymentSettingsSection}))),messaging:yt(()=>Promise.resolve().then(()=>require("./MessagingSection-DrXb578q.js")).then(e=>({default:e.MessagingSection}))),settings:yt(()=>Promise.resolve().then(()=>require("./SettingsSection-DUTEd6uV.js")).then(e=>({default:e.SettingsSection})))},createPluginContext(e){const t=e.cedrosPay,n=e.cedrosLogin;return{serverUrl:t?.serverUrl||n?.serverUrl||"",userId:n?.user?.id,getAccessToken:()=>n?.getAccessToken?.()||t?.jwtToken||null,hasPermission:o=>this.checkPermission(o,e),orgId:e.org?.orgId,pluginData:{walletAddress:t?.walletAddress}}},checkPermission(e,t){return t.org?.permissions?t.org.permissions.includes(e):!1},cssNamespace:"cedros-dashboard"},Qc=[{id:"transactions",qualifiedId:"cedros-pay:transactions",label:"Transactions",group:"Store",order:0,endpoints:["GET /admin/transactions"]},{id:"products",qualifiedId:"cedros-pay:products",label:"Products",group:"Store",order:1,endpoints:["GET /admin/products","POST /admin/products","PUT /admin/products/{id}","DELETE /admin/products/{id}"]},{id:"subscriptions",qualifiedId:"cedros-pay:subscriptions",label:"Subscriptions",group:"Store",order:2,endpoints:["GET /admin/subscriptions","POST /admin/subscriptions","PUT /admin/subscriptions/{id}"]},{id:"coupons",qualifiedId:"cedros-pay:coupons",label:"Coupons",group:"Store",order:3,endpoints:["GET /admin/coupons","POST /admin/coupons","PUT /admin/coupons/{id}","DELETE /admin/coupons/{id}"]},{id:"refunds",qualifiedId:"cedros-pay:refunds",label:"Refunds",group:"Store",order:4,endpoints:["GET /admin/refunds","POST /admin/refunds/{id}/approve","POST /admin/refunds/{id}/deny"]},{id:"storefront",qualifiedId:"cedros-pay:storefront",label:"Storefront",group:"Configuration",order:10,endpoints:["GET /admin/config/shop","PUT /admin/config/shop"]},{id:"ai-settings",qualifiedId:"cedros-pay:ai-settings",label:"Store AI",group:"Configuration",order:11,endpoints:["GET /admin/config/ai","PUT /admin/config/ai/api-key","PUT /admin/config/ai/assignment","PUT /admin/config/ai/prompt"]},{id:"faqs",qualifiedId:"cedros-pay:faqs",label:"Knowledge Base",group:"Configuration",order:12,endpoints:["GET /admin/faqs","POST /admin/faqs","PUT /admin/faqs/{id}","DELETE /admin/faqs/{id}"]},{id:"payment-settings",qualifiedId:"cedros-pay:payment-settings",label:"Payment Options",group:"Configuration",order:13,endpoints:["GET /admin/config/stripe","PUT /admin/config/stripe","GET /admin/config/x402","PUT /admin/config/x402","GET /admin/config/cedros_login","PUT /admin/config/cedros_login"]},{id:"messaging",qualifiedId:"cedros-pay:messaging",label:"Store Messages",group:"Configuration",order:14,endpoints:["GET /admin/config/messaging","PUT /admin/config/messaging"]},{id:"settings",qualifiedId:"cedros-pay:settings",label:"Store Server",group:"Configuration",order:15,endpoints:["GET /admin/config/server","PUT /admin/config/server"]}],Sm=Qc.map(e=>e.qualifiedId),Cm=[{id:"Store",label:"Store",order:1,defaultCollapsed:!1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}];function Kc(){const{config:e}=Ie.useCedrosContext(),[t,n]=w.useState(!1),[s,o]=w.useState(null),[a,i]=w.useState(null);return{checkCompliance:w.useCallback(async(l,d)=>{n(!0),i(null),o(null);try{const u=`${e.serverUrl||window.location.origin}/paywall/v1/compliance-check`,g={"Content-Type":"application/json"};d&&(g.Authorization=`Bearer ${d}`);const p=await Ie.fetchWithTimeout(u,{method:"POST",headers:g,body:JSON.stringify({resources:l})});if(!p.ok){const h=await Ie.parseErrorResponse(p,"Compliance check failed");throw new Error(h)}const x=await p.json();return o(x),x}catch(f){const u=f instanceof Error?f.message:"Compliance check failed";Ie.getLogger().error("[useComplianceCheck]",u),i(u);const g={cleared:!0};return o(g),g}finally{n(!1)}},[e.serverUrl]),loading:t,result:s,error:a}}function Nm({resources:e,onCleared:t,onBlocked:n,onCancel:s,authToken:o,children:a}){const i=Ie.useCedrosTheme(),{checkCompliance:c,loading:l,result:d,error:f}=Kc(),u=w.useRef(!1);w.useEffect(()=>{u.current||e.length===0||(u.current=!0,c(e,o))},[e,o,c]),w.useEffect(()=>{d&&(d.cleared?t():d.reasons?.length&&n?.(d.reasons))},[d,t,n]);const g=i.unstyled?"":`${i.className} cedros-theme__compliance-gate`,p=i.unstyled?{}:i.style;return l||!d?r.jsx("div",{className:g,style:p,children:a??r.jsx("div",{className:i.unstyled?"":"cedros-theme__compliance-checking",children:r.jsx("p",{children:"Verifying purchase eligibility..."})})}):d.cleared?null:r.jsx("div",{className:g,style:p,children:r.jsxs("div",{className:i.unstyled?"":"cedros-theme__compliance-blocked",children:[r.jsx("h3",{children:"Purchase Not Available"}),r.jsx("ul",{children:d.reasons?.map((x,h)=>r.jsx("li",{children:x},h))}),f&&r.jsx("p",{className:i.unstyled?"":"cedros-theme__error",children:f}),s&&r.jsx("button",{type:"button",onClick:s,className:i.unstyled?"":"cedros-theme__button",children:"Go back"})]})})}function Jc(e){const{creditsManager:t}=Ie.useCedrosContext(),[n,s]=w.useState({available:0,held:0,currency:"",loading:!1,error:null}),o=w.useRef(!0);w.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]);const a=w.useCallback(async()=>{if(e){s(i=>({...i,loading:!0,error:null}));try{const i=await t.getBalance(e);if(!o.current)return;s(i?{available:i.available,held:i.held,currency:i.currency,loading:!1,error:null}:c=>({...c,loading:!1}))}catch(i){if(!o.current)return;s(c=>({...c,loading:!1,error:i instanceof Error?i.message:"Failed to fetch balance"}))}}},[e,t]);return w.useEffect(()=>{a()},[a]),{...n,refresh:a}}function Am({authToken:e,className:t="",formatBalance:n,showHeld:s=!1}){const o=Ie.useCedrosTheme(),{available:a,held:i,currency:c,loading:l,error:d,refresh:f}=Jc(e),u=o.unstyled?t:`${o.className} cedros-theme__credits-balance ${t}`.trim();if(!e)return null;const g=n?n(a,c):`${a} ${c}`;return r.jsxs("div",{className:u,style:o.unstyled?{}:o.style,children:[r.jsx("div",{className:o.unstyled?"":"cedros-theme__credits-balance-amount",children:l?"Loading…":g}),s&&i>0&&!l&&r.jsxs("div",{className:o.unstyled?"":"cedros-theme__credits-balance-held",children:[i," ",c," held"]}),d&&r.jsx("div",{className:o.unstyled?"":"cedros-theme__error",children:d}),!l&&r.jsx("button",{type:"button",onClick:f,className:o.unstyled?"":"cedros-theme__credits-balance-refresh","aria-label":"Refresh balance",children:"↻"})]})}const ta=w.createContext(null);function Ae(){const e=w.useContext(ta);if(!e)throw new Error("useCedrosShop must be used within CedrosShopProvider");return e}function na(){return w.useContext(ta)}function Em({config:e,children:t}){const n=w.useMemo(()=>({config:e}),[e]);return r.jsx(ta.Provider,{value:n,children:t})}function _t(e){return new Promise(t=>setTimeout(t,e))}const Xc=[{id:"cat_all",slug:"all",name:"All Products",description:"Everything in the catalog."},{id:"cat_apparel",slug:"apparel",name:"Apparel",description:"Soft goods and daily wear."},{id:"cat_accessories",slug:"accessories",name:"Accessories",description:"Carry, attach, decorate."}],ns=[{id:"p_tee",slug:"cedros-tee",title:"Cedros Tee",description:"A heavyweight tee with a clean silhouette.",images:[{url:"https://picsum.photos/seed/cedros-tee/900/900",alt:"Cedros Tee"},{url:"https://picsum.photos/seed/cedros-tee-2/900/900",alt:"Cedros Tee detail"}],price:38,currency:"USD",tags:["new","cotton"],categoryIds:["cat_apparel"],compareAtPrice:48,inventoryStatus:"in_stock",variants:[{id:"v_tee_s",title:"Small / Black",options:{Size:"S",Color:"Black"}},{id:"v_tee_m",title:"Medium / Black",options:{Size:"M",Color:"Black"}},{id:"v_tee_l",title:"Large / Black",options:{Size:"L",Color:"Black"}}],shippingProfile:"physical"},{id:"p_crewneck",slug:"cedros-crewneck",title:"Cedros Crewneck",description:"Midweight fleece with a relaxed fit and embroidered mark.",images:[{url:"https://picsum.photos/seed/cedros-crewneck/900/900",alt:"Cedros Crewneck"}],price:64,currency:"USD",tags:["fleece","core"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",compareAtPrice:78,variants:[{id:"v_crew_s",title:"Small / Heather",options:{Size:"S",Color:"Heather"}},{id:"v_crew_m",title:"Medium / Heather",options:{Size:"M",Color:"Heather"}},{id:"v_crew_l",title:"Large / Heather",options:{Size:"L",Color:"Heather"}}],shippingProfile:"physical"},{id:"p_hoodie",slug:"cedros-hoodie",title:"Cedros Hoodie",description:"Pullover hoodie with soft interior and structured hood.",images:[{url:"https://picsum.photos/seed/cedros-hoodie/900/900",alt:"Cedros Hoodie"},{url:"https://picsum.photos/seed/cedros-hoodie-2/900/900",alt:"Cedros Hoodie detail"}],price:74,currency:"USD",tags:["fleece","new"],categoryIds:["cat_apparel"],inventoryStatus:"low",variants:[{id:"v_hoodie_s",title:"Small / Black",options:{Size:"S",Color:"Black"}},{id:"v_hoodie_m",title:"Medium / Black",options:{Size:"M",Color:"Black"}},{id:"v_hoodie_l",title:"Large / Black",options:{Size:"L",Color:"Black"}}],shippingProfile:"physical"},{id:"p_cap",slug:"cedros-cap",title:"Cedros Cap",description:"Unstructured cap with adjustable strap and curved brim.",images:[{url:"https://picsum.photos/seed/cedros-cap/900/900",alt:"Cedros Cap"}],price:28,currency:"USD",tags:["core"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_socks",slug:"cedros-socks",title:"Cedros Socks",description:"Rib-knit socks designed for everyday comfort.",images:[{url:"https://picsum.photos/seed/cedros-socks/900/900",alt:"Cedros Socks"}],price:14,currency:"USD",tags:["cotton"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_tote",slug:"cedros-tote",title:"Cedros Tote",description:"Heavy canvas tote with reinforced handles.",images:[{url:"https://picsum.photos/seed/cedros-tote/900/900",alt:"Cedros Tote"}],price:32,currency:"USD",tags:["gift","canvas"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_stickers",slug:"cedros-sticker-pack",title:"Sticker Pack",description:"Five durable vinyl stickers for laptops and water bottles.",images:[{url:"https://picsum.photos/seed/cedros-stickers/900/900",alt:"Sticker Pack"}],price:8,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_keychain",slug:"cedros-keychain",title:"Enamel Keychain",description:"Polished enamel keychain with a subtle mark.",images:[{url:"https://picsum.photos/seed/cedros-keychain/900/900",alt:"Enamel Keychain"}],price:12,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_lanyard",slug:"cedros-lanyard",title:"Woven Lanyard",description:"Soft woven lanyard with swivel clasp.",images:[{url:"https://picsum.photos/seed/cedros-lanyard/900/900",alt:"Woven Lanyard"}],price:10,currency:"USD",tags:["core"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_notebook",slug:"cedros-notebook",title:"Dot Grid Notebook",description:"Lay-flat notebook for sketches, notes, and plans.",images:[{url:"https://picsum.photos/seed/cedros-notebook/900/900",alt:"Dot Grid Notebook"}],price:18,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_waterbottle",slug:"cedros-water-bottle",title:"Insulated Bottle",description:"Vacuum-insulated bottle that keeps drinks cold for hours.",images:[{url:"https://picsum.photos/seed/cedros-bottle/900/900",alt:"Insulated Bottle"}],price:36,currency:"USD",tags:["gift","new"],categoryIds:["cat_accessories"],inventoryStatus:"backorder",shippingProfile:"physical"},{id:"p_posters",slug:"cedros-poster-set",title:"Poster Set",description:"Two prints on thick matte stock.",images:[{url:"https://picsum.photos/seed/cedros-posters/900/900",alt:"Poster Set"}],price:24,currency:"USD",tags:["gift","limited"],categoryIds:["cat_accessories"],inventoryStatus:"out_of_stock",shippingProfile:"physical"},{id:"p_pins",slug:"cedros-pin-set",title:"Pin Set",description:"Two enamel pins with rubber backings.",images:[{url:"https://picsum.photos/seed/cedros-pins/900/900",alt:"Pin Set"}],price:16,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_brandbook",slug:"cedros-brand-book",title:"Brand Book (PDF)",description:"A compact brand book: typography, color, layout, and voice.",images:[{url:"https://picsum.photos/seed/cedros-brandbook/900/900",alt:"Brand Book cover"}],price:19,currency:"USD",tags:["digital"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital",checkoutRequirements:{email:"optional",name:"none",phone:"none",shippingAddress:!1,billingAddress:!1},fulfillment:{type:"digital_download",notes:"This is a digital product and will be downloadable from your account after purchase."}},{id:"p_wallpaper",slug:"cedros-wallpaper-pack",title:"Wallpaper Pack",description:"A set of desktop + mobile wallpapers in multiple colorways.",images:[{url:"https://picsum.photos/seed/cedros-wallpaper/900/900",alt:"Wallpaper Pack"}],price:6,currency:"USD",tags:["digital","new"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital"},{id:"p_longsleeve",slug:"cedros-long-sleeve",title:"Long Sleeve Tee",description:"Soft long sleeve tee with rib cuff and relaxed drape.",images:[{url:"https://picsum.photos/seed/cedros-longsleeve/900/900",alt:"Long Sleeve Tee"}],price:44,currency:"USD",tags:["cotton"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_shorts",slug:"cedros-shorts",title:"Everyday Shorts",description:"Lightweight shorts with a comfortable waistband.",images:[{url:"https://picsum.photos/seed/cedros-shorts/900/900",alt:"Everyday Shorts"}],price:40,currency:"USD",tags:["new"],categoryIds:["cat_apparel"],inventoryStatus:"in_stock",shippingProfile:"physical"},{id:"p_beanie",slug:"cedros-beanie",title:"Rib Beanie",description:"Warm rib beanie with a clean folded cuff.",images:[{url:"https://picsum.photos/seed/cedros-beanie/900/900",alt:"Rib Beanie"}],price:20,currency:"USD",tags:["core"],categoryIds:["cat_apparel"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_jacket",slug:"cedros-coach-jacket",title:"Coach Jacket",description:"Lightweight jacket with snap front and subtle sheen.",images:[{url:"https://picsum.photos/seed/cedros-jacket/900/900",alt:"Coach Jacket"}],price:96,currency:"USD",tags:["limited"],categoryIds:["cat_apparel"],inventoryStatus:"backorder",shippingProfile:"physical"},{id:"p_mug",slug:"cedros-mug",title:"Cedros Mug",description:"Stoneware mug with a satin glaze.",images:[{url:"https://picsum.photos/seed/cedros-mug/900/900",alt:"Cedros Mug"}],price:22,currency:"USD",tags:["gift"],categoryIds:["cat_accessories"],inventoryStatus:"low",shippingProfile:"physical"},{id:"p_guide",slug:"cedros-field-guide",title:"Field Guide (Digital)",description:"A short digital guide to shipping delightful checkout flows.",images:[{url:"https://picsum.photos/seed/cedros-guide/900/900",alt:"Field Guide cover"}],price:12,currency:"USD",tags:["digital"],categoryIds:["cat_accessories"],inventoryStatus:"in_stock",shippingProfile:"digital"}];function Im(e,t){let n=e;if(t.category&&t.category!=="all"){const l=Xc.find(d=>d.slug===t.category||d.id===t.category);l&&(n=n.filter(d=>d.categoryIds.includes(l.id)))}if(t.search){const l=t.search.toLowerCase();n=n.filter(d=>d.title.toLowerCase().includes(l)||d.description.toLowerCase().includes(l))}const s=t.filters??{},o=s.tags;if(Array.isArray(o)&&o.length>0){const l=new Set(o.map(String));n=n.filter(d=>d.tags?.some(f=>l.has(f)))}const a=typeof s.priceMin=="number"?s.priceMin:void 0,i=typeof s.priceMax=="number"?s.priceMax:void 0;return typeof a=="number"&&(n=n.filter(l=>l.price>=a)),typeof i=="number"&&(n=n.filter(l=>l.price<=i)),(typeof s.inStock=="boolean"?s.inStock:void 0)===!0&&(n=n.filter(l=>l.inventoryStatus!=="out_of_stock")),n}function Tm(e,t){if(!t||t==="featured")return e;const n=[...e];return t==="price_asc"&&n.sort((s,o)=>s.price-o.price),t==="price_desc"&&n.sort((s,o)=>o.price-s.price),n}function Pm(e,t,n){const s=(t-1)*n;return{items:e.slice(s,s+n),page:t,pageSize:n,total:e.length,hasNextPage:s+n<e.length}}function Rm(e){const t=new Date().toISOString(),n=e.cart.map(o=>{const a=ns.find(i=>i.id===o.resource||i.slug===o.resource)??ns[0];return{title:a.title,qty:o.quantity,unitPrice:a.price,currency:e.options.currency,imageUrl:a.images[0]?.url,productId:a.id,tokenizedAsset:!!a.tokenizedAssetConfig}}),s=n.reduce((o,a)=>o+a.qty*a.unitPrice,0);return{id:`ord_${Math.random().toString(16).slice(2)}`,createdAt:t,status:"paid",total:s,currency:e.options.currency,items:n,receiptUrl:e.options.successUrl}}function Om(){let e=[];const t={};return{async listProducts(n){await _t(150);const s=n.page??1,o=n.pageSize??24,a=Im(ns,n),i=Tm(a,n.sort);return Pm(i,s,o)},async getProductBySlug(n){return await _t(100),ns.find(s=>s.slug===n)??null},async listCategories(){return await _t(80),Xc},async getOrderHistory(){return await _t(120),e},async getCart({customerId:n}){return await _t(80),t[n]??{items:[]}},async mergeCart({customerId:n,cart:s}){await _t(120);const o=t[n]??{items:[]},a=new Map,i=l=>{const d=`${l.productId}::${l.variantId??""}`,f=a.get(d);f?a.set(d,{...f,qty:f.qty+l.qty}):a.set(d,l)};for(const l of o.items)i(l);for(const l of s.items)i(l);const c={items:Array.from(a.values()),promoCode:s.promoCode??o.promoCode};return t[n]=c,c},async updateCart({customerId:n,cart:s}){await _t(60),t[n]=s},async createCheckoutSession(n){await _t(250);const s=Rm(n);if(e=[s,...e].slice(0,25),n.options.successUrl){const o=new URL(n.options.successUrl,"http://localhost");return o.searchParams.set("demoOrderId",s.id),{kind:"redirect",url:o.toString().replace("http://localhost","")}}return{kind:"custom",data:{orderId:s.id}}},async listSubscriptionTiers(){return await _t(80),[{id:"tier_starter",title:"Starter",description:"For small shops getting started.",priceMonthly:19,priceAnnual:190,currency:"USD",features:["Basic analytics","Email support","1 storefront"]},{id:"tier_growth",title:"Growth",description:"For teams iterating fast.",priceMonthly:49,priceAnnual:490,currency:"USD",features:["Advanced analytics","Priority support","3 storefronts"],isPopular:!0},{id:"tier_enterprise",title:"Enterprise",description:"For high volume and custom needs.",priceMonthly:199,priceAnnual:1990,currency:"USD",features:["SLA","Dedicated success","Unlimited storefronts"]}]},async getSubscriptionStatus(){return await _t(80),{isActive:!1}},async createSubscriptionCheckoutSession(n){return await _t(200),n.successUrl?{kind:"redirect",url:n.successUrl}:{kind:"custom",data:n}}}}const xi=50,Mm=4,Lm=5,Dm=1e4,$m={maxRetries:2,initialDelayMs:100,backoffFactor:2,maxDelayMs:500,jitter:!1};function el(e){return e.replace(/[_-]+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function zm(e){return e?e.toUpperCase():"USD"}function Fm(e){if(e&&(e==="in_stock"||e==="low"||e==="out_of_stock"||e==="backorder"))return e}function Bm(e){if(e&&(e==="physical"||e==="digital"))return e}function Um(e){const t=[];if(Array.isArray(e))for(const n of e)typeof n=="string"&&t.push(n);else if(typeof e=="string"){const n=e.trim();if(n.startsWith("["))try{const s=JSON.parse(n);if(Array.isArray(s))for(const o of s)typeof o=="string"&&t.push(o);else t.push(e)}catch{t.push(e)}else t.push(e)}return t.flatMap(n=>n.split(",")).map(n=>n.trim().toUpperCase()).filter(Boolean)}function Tn(e){const t=zm(e.fiatCurrency),n=e.images&&e.images.length?e.images:e.imageUrl?[{url:e.imageUrl,alt:e.title}]:[],s=e.effectiveFiatAmountCents??e.fiatAmountCents??0,o=e.compareAtAmountCents,a=e.metadata?.shippingCountries??e.metadata?.shipping_countries,i=Um(a);return{id:e.id,slug:e.slug??e.id,title:e.title??el(e.id),description:e.description??"",images:n,price:s/100,currency:t,tags:e.tags??[],categoryIds:e.categoryIds??[],inventoryStatus:Fm(e.inventoryStatus),inventoryQuantity:typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0,compareAtPrice:typeof o=="number"?o/100:void 0,shippingProfile:Bm(e.shippingProfile),checkoutRequirements:e.checkoutRequirements,fulfillment:e.fulfillment,tokenizedAssetConfig:e.tokenizedAssetConfig,attributes:i.length?{shippingCountries:i.join(",")}:void 0}}function Yr(e){if(Array.isArray(e))return{products:e};const t=e.products??e.items??[],n=e.total??e.count;return{products:t,total:n}}async function Gt(e,t,n,s={}){const{body:o,headers:a,method:i="GET",retryableRead:c=!1,timeoutMs:l=Dm}=s,d={};n&&(d["X-API-Key"]=n),a&&Object.assign(d,a);const f=async()=>{const u=await Ie.fetchWithTimeout(`${e}${t}`,{body:o,headers:d,method:i},l);if(!u.ok){const g=await u.text().catch(()=>""),p=new Error(`Request failed (${u.status}): ${g}`);throw p.status=u.status,p}return u.json()};return c?Ie.retryWithBackoff(f,{...$m,name:`paywall-read-${i.toLowerCase()}`}):f()}async function Vm(e,t,n,s){const o=await Gt(e,`/paywall/v1/products?limit=${n}&offset=${s}`,t,{retryableRead:!0});return Yr(o)}async function vi(e,t,n,s){const{maxPages:o,pageSize:a}=n;for(let i=0;i<o;i+=1){const c=i*a,{products:l,total:d}=await Vm(e,t,a,c);if(l.length===0||s(l))return;const f=typeof d=="number"&&c+l.length>=d,u=l.length<a;if(f||u)return}}function Wm(e){const t=async d=>{const f=d.page??1,u=d.pageSize??24,g=u,p=(f-1)*u,x=new URLSearchParams;x.set("limit",String(g)),x.set("offset",String(p)),d.search&&x.set("search",d.search),d.category&&x.set("category",d.category),d.sort&&x.set("sort",d.sort),d.filters?.inStock&&x.set("in_stock","true"),d.filters?.minPrice!=null&&x.set("min_price",String(d.filters.minPrice)),d.filters?.maxPrice!=null&&x.set("max_price",String(d.filters.maxPrice));const h=d.filters?.tags,v=Array.isArray(h)?h:typeof h=="string"?[h]:[];v.length&&x.set("tags",v.join(","));const y=await Gt(e.serverUrl,`/paywall/v1/products?${x.toString()}`,e.apiKey,{retryableRead:!0}),{products:k,total:_}=Yr(y);return{items:k.map(Tn),page:f,pageSize:u,total:_,hasNextPage:typeof _=="number"?p+g<_:k.length===g}},n=async d=>{try{const f=await Gt(e.serverUrl,`/paywall/v1/products/by-slug/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Tn(f)}catch(f){const u=f?.status;if(u!==404&&u!==405)throw f;try{const g=await Gt(e.serverUrl,`/paywall/v1/products/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Tn(g)}catch(g){const p=g?.status;if(p!==404&&p!==405)throw g;let x;return await vi(e.serverUrl,e.apiKey,{maxPages:Mm,pageSize:xi},h=>(x=h.find(v=>v.slug===d||v.id===d),!!x)),x?Tn(x):null}}};return{listProducts:t,getProductBySlug:n,getProductsByIds:async d=>{const f=Array.from(new Set(d.filter(Boolean)));if(f.length===0)return new Map;const u=new Map;try{const x=new URLSearchParams;x.set("ids",f.join(",")),x.set("limit",String(f.length)),x.set("offset","0");const h=await Gt(e.serverUrl,`/paywall/v1/products?${x.toString()}`,e.apiKey,{retryableRead:!0}),{products:v}=Yr(h);for(const y of v){const k=Tn(y);u.set(k.id,k),k.slug&&k.slug!==k.id&&u.set(k.slug,k)}}catch{}const g=f.filter(x=>!u.has(x));if(g.length===0)return u;let p=g;try{const x=new Set(p);if(await vi(e.serverUrl,e.apiKey,{maxPages:Lm,pageSize:xi},h=>{for(const v of h){const y=Tn(v);!x.has(y.id)&&!(y.slug&&x.has(y.slug))||(u.set(y.id,y),y.slug&&y.slug!==y.id&&u.set(y.slug,y),x.delete(y.id),y.slug&&x.delete(y.slug))}return x.size===0}),p=Array.from(x),p.length===0)return u}catch{}for(const x of p)try{const h=await n(x);h&&(u.set(h.id,h),h.slug&&h.slug!==h.id&&u.set(h.slug,h))}catch{}return u},listCategories:async()=>{const d=await Gt(e.serverUrl,"/paywall/v1/products?limit=500&offset=0",e.apiKey,{retryableRead:!0}),{products:f}=Yr(d),u=new Set;for(const g of f)for(const p of g.categoryIds??[])u.add(p);return Array.from(u).map(g=>({id:g,slug:g,name:el(g)}))},getOrderHistory:async()=>[],createCheckoutSession:async d=>{throw new Error("createCheckoutSession is not implemented for paywall adapter")},getStorefrontSettings:async()=>{try{return(await Gt(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).config??null}catch{return null}},getPaymentMethodsConfig:async()=>{try{const f=(await Gt(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).paymentMethods;return f?{card:!!f.stripe,crypto:!!f.x402,credits:!!f.credits}:null}catch{return null}},getAIRelatedProducts:async d=>Gt(e.serverUrl,"/admin/ai/related-products",e.apiKey,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},retryableRead:!1})}}function qm(e){throw new Error(`Unhandled cart action: ${JSON.stringify(e)}`)}function mn(e){return`${e.productId}::${e.variantId??""}`}const Hm={items:[]};function Zm(e,t){switch(t.type){case"cart/hydrate":return t.state;case"cart/add":{const n=Math.max(1,Math.floor(t.qty??1)),s=mn(t.item);return e.items.find(a=>mn(a)===s)?{...e,items:e.items.map(a=>mn(a)===s?{...a,qty:a.qty+n}:a)}:{...e,items:[...e.items,{...t.item,qty:n}]}}case"cart/remove":{const n=`${t.productId}::${t.variantId??""}`;return{...e,items:e.items.filter(s=>mn(s)!==n)}}case"cart/setQty":{const n=Math.max(0,Math.floor(t.qty)),s=`${t.productId}::${t.variantId??""}`;return n===0?{...e,items:e.items.filter(o=>mn(o)!==s)}:{...e,items:e.items.map(o=>mn(o)===s?{...o,qty:n}:o)}}case"cart/clear":return{items:[],promoCode:void 0};case"cart/setPromoCode":return{...e,promoCode:t.promoCode||void 0};case"cart/updateHold":{const n=`${t.productId}::${t.variantId??""}`;return{...e,items:e.items.map(s=>mn(s)===n?{...s,holdId:t.holdId,holdExpiresAt:t.holdExpiresAt}:s)}}default:return qm(t)}}function Gm(e){return e.reduce((t,n)=>t+n.qty,0)}function Ym(e){return e.reduce((t,n)=>t+n.qty*n.unitPrice,0)}function yi(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Qm(e,t){try{const n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}function Km(e,t,n){try{return e.setItem(t,JSON.stringify(n)),!0}catch(s){return console.warn(`[cedros] Failed to write "${t}" to storage`,s),!1}}const tl=w.createContext(null);function Et(){const e=w.useContext(tl);if(!e)throw new Error("useCart must be used within CartProvider");return e}function bi(e){return!!e&&typeof e=="object"&&typeof e.productId=="string"&&e.productId.length>0&&typeof e.qty=="number"&&e.qty>0&&typeof e.unitPrice=="number"&&typeof e.currency=="string"&&typeof e.titleSnapshot=="string"}function Jm({children:e}){const{config:t}=Ae(),n=t.cart?.storageKey??"cedros_shop_cart_v1",s=t.customer?.id,o=t.customer?.isSignedIn??!!s,a=t.cart?.syncDebounceMs??800,i=!!t.adapter.getCartInventoryStatus,[c,l]=w.useReducer(Zm,Hm),d=w.useRef(c);d.current=c;const[f,u]=w.useState(!1),g=w.useRef(!1),p=w.useRef(null),x=w.useRef(null);w.useEffect(()=>{const k=yi();if(!k)return;const _=Qm(k,n);if(_&&Array.isArray(_.items)){const b=_.items.filter(bi);l({type:"cart/hydrate",state:{items:b,promoCode:typeof _.promoCode=="string"?_.promoCode:void 0}})}u(!0)},[n]),w.useEffect(()=>{if(!f)return;const k=yi();k&&Km(k,n,c)},[c,n,f]),w.useEffect(()=>{if(!f||!o||!s||!t.adapter.mergeCart&&!t.adapter.getCart||(x.current!==s&&(g.current=!1,p.current=null,x.current=s),g.current))return;let k=!1;return(async()=>{try{const _=t.adapter.mergeCart?await t.adapter.mergeCart({customerId:s,cart:d.current}):await t.adapter.getCart({customerId:s});if(k)return;if(_&&Array.isArray(_.items)){g.current=!0;const b={..._,items:_.items.filter(bi)};l({type:"cart/hydrate",state:b}),p.current=JSON.stringify(b)}}catch{k||(g.current=!1)}})(),()=>{k=!0}},[t.adapter,s,f,o]),w.useEffect(()=>{if(!f||!o||!s||!t.adapter.updateCart||!g.current||typeof window>"u")return;const k=JSON.stringify(c);if(p.current===k)return;const _=window.setTimeout(()=>{t.adapter.updateCart({customerId:s,cart:c}).then(()=>{p.current=k}).catch(b=>{console.warn("[CedrosPay] Cart server sync failed:",b instanceof Error?b.message:b)})},a);return()=>window.clearTimeout(_)},[t.adapter,s,f,o,c,a]);const h=w.useCallback((k,_)=>{const b=c.items.find(j=>j.productId===k&&j.variantId===_);if(b)return{holdId:b.holdId,expiresAt:b.holdExpiresAt}},[c.items]),v=w.useCallback((k,_,b)=>{l({type:"cart/updateHold",productId:k,variantId:_,holdExpiresAt:b})},[]),y=w.useMemo(()=>{const k=Gm(c.items),_=Ym(c.items);return{items:c.items,promoCode:c.promoCode,count:k,subtotal:_,addItem:(b,j)=>l({type:"cart/add",item:b,qty:j}),removeItem:(b,j)=>l({type:"cart/remove",productId:b,variantId:j}),setQty:(b,j,N)=>l({type:"cart/setQty",productId:b,variantId:j,qty:N}),clear:()=>l({type:"cart/clear"}),setPromoCode:b=>l({type:"cart/setPromoCode",promoCode:b}),holdsSupported:i,getItemHold:h,updateItemHold:v}},[c.items,c.promoCode,i,h,v]);return r.jsx(tl.Provider,{value:y,children:e})}function z(e,t,n){function s(c,l){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:l,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);const d=i.prototype,f=Object.keys(d);for(let u=0;u<f.length;u++){const g=f[u];g in c||(c[g]=d[g].bind(c))}}const o=n?.Parent??Object;class a extends o{}Object.defineProperty(a,"name",{value:e});function i(c){var l;const d=n?.Parent?new a:this;s(d,c),(l=d._zod).deferred??(l.deferred=[]);for(const f of d._zod.deferred)f();return d}return Object.defineProperty(i,"init",{value:s}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class Dn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class nl extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const rl={};function hn(e){return rl}function sl(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,o])=>t.indexOf(+s)===-1).map(([s,o])=>o)}function Po(e,t){return typeof t=="bigint"?t.toString():t}function ra(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function sa(e){return e==null}function oa(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Xm(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let o=(s.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(s)){const l=s.match(/\d?e-(\d?)/);l?.[1]&&(o=Number.parseInt(l[1]))}const a=n>o?n:o,i=Number.parseInt(e.toFixed(a).replace(".","")),c=Number.parseInt(t.toFixed(a).replace(".",""));return i%c/10**a}const wi=Symbol("evaluating");function we(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==wi)return s===void 0&&(s=wi,s=n()),s},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function wn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function sn(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function ki(e){return JSON.stringify(e)}function ep(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ol="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const tp=ra(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function pr(e){if(rs(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(rs(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function al(e){return pr(e)?{...e}:Array.isArray(e)?[...e]:e}const np=new Set(["string","number","symbol"]);function Fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function on(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function ae(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function rp(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const sp={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function op(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const a=sn(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return wn(this,"shape",i),i},checks:[]});return on(e,a)}function ap(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const a=sn(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return wn(this,"shape",i),i},checks:[]});return on(e,a)}function ip(e,t){if(!pr(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const a=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(a,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=sn(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return wn(this,"shape",a),a}});return on(e,o)}function cp(e,t){if(!pr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return wn(this,"shape",s),s}});return on(e,n)}function lp(e,t){const n=sn(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return wn(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return on(e,n)}function dp(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=sn(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(n)for(const d in n){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return wn(this,"shape",l),l},checks:[]});return on(t,i)}function up(e,t,n){const s=sn(t._zod.def,{get shape(){const o=t._zod.def.shape,a={...o};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(a[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)a[i]=new e({type:"nonoptional",innerType:o[i]});return wn(this,"shape",a),a}});return on(t,s)}function Ln(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function il(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function Pr(e){return typeof e=="string"?e:e?.message}function gn(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const o=Pr(e.inst?._zod.def?.error?.(e))??Pr(t?.error?.(e))??Pr(n.customError?.(e))??Pr(n.localeError?.(e))??"Invalid input";s.message=o}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function aa(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function hr(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const cl=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Po,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ll=z("$ZodError",cl),dl=z("$ZodError",cl,{Parent:Error});function fp(e,t=n=>n.message){const n={},s=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):s.push(t(o));return{formErrors:s,fieldErrors:n}}function mp(e,t=n=>n.message){const n={_errors:[]},s=o=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(i=>s({issues:i}));else if(a.code==="invalid_key")s({issues:a.issues});else if(a.code==="invalid_element")s({issues:a.issues});else if(a.path.length===0)n._errors.push(t(a));else{let i=n,c=0;for(;c<a.path.length;){const l=a.path[c];c===a.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(t(a))):i[l]=i[l]||{_errors:[]},i=i[l],c++}}};return s(e),n}const ia=e=>(t,n,s,o)=>{const a=s?Object.assign(s,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise)throw new Dn;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>gn(l,a,hn())));throw ol(c,o?.callee),c}return i.value},ca=e=>async(t,n,s,o)=>{const a=s?Object.assign(s,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>gn(l,a,hn())));throw ol(c,o?.callee),c}return i.value},ws=e=>(t,n,s)=>{const o=s?{...s,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new Dn;return a.issues.length?{success:!1,error:new(e??ll)(a.issues.map(i=>gn(i,o,hn())))}:{success:!0,data:a.value}},pp=ws(dl),ks=e=>async(t,n,s)=>{const o=s?Object.assign(s,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},o);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(i=>gn(i,o,hn())))}:{success:!0,data:a.value}},hp=ks(dl),gp=e=>(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ia(e)(t,n,o)},xp=e=>(t,n,s)=>ia(e)(t,n,s),vp=e=>async(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ca(e)(t,n,o)},yp=e=>async(t,n,s)=>ca(e)(t,n,s),bp=e=>(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ws(e)(t,n,o)},wp=e=>(t,n,s)=>ws(e)(t,n,s),kp=e=>async(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ks(e)(t,n,o)},_p=e=>async(t,n,s)=>ks(e)(t,n,s),jp=/^[cC][^\s-]{8,}$/,Sp=/^[0-9a-z]+$/,Cp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Np=/^[0-9a-vA-V]{20}$/,Ap=/^[A-Za-z0-9]{27}$/,Ep=/^[a-zA-Z0-9_-]{21}$/,Ip=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Tp=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,_i=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Pp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Rp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Op(){return new RegExp(Rp,"u")}const Mp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Lp=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Dp=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,$p=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ul=/^[A-Za-z0-9_-]*$/,Fp=/^\+[1-9]\d{6,14}$/,fl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Bp=new RegExp(`^${fl}$`);function ml(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Up(e){return new RegExp(`^${ml(e)}$`)}function Vp(e){const t=ml({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${fl}T(?:${s})$`)}const Wp=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},qp=/^-?\d+$/,Hp=/^-?\d+(?:\.\d+)?$/,Zp=/^(?:true|false)$/i,Gp=/^[^A-Z]*$/,Yp=/^[^a-z]*$/,dt=z("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),pl={number:"number",bigint:"bigint",object:"date"},hl=z("$ZodCheckLessThan",(e,t)=>{dt.init(e,t);const n=pl[typeof t.value];e._zod.onattach.push(s=>{const o=s._zod.bag,a=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<a&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gl=z("$ZodCheckGreaterThan",(e,t)=>{dt.init(e,t);const n=pl[typeof t.value];e._zod.onattach.push(s=>{const o=s._zod.bag,a=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>a&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Qp=z("$ZodCheckMultipleOf",(e,t)=>{dt.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Xm(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Kp=z("$ZodCheckNumberFormat",(e,t)=>{dt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[o,a]=sp[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=a,n&&(c.pattern=qp)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>a&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Jp=z("$ZodCheckMaxLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const o=s.value;if(o.length<=t.maximum)return;const i=aa(o);s.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xp=z("$ZodCheckMinLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const o=s.value;if(o.length>=t.minimum)return;const i=aa(o);s.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),eh=z("$ZodCheckLengthEquals",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!sa(o)&&o.length!==void 0}),e._zod.onattach.push(s=>{const o=s._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=s=>{const o=s.value,a=o.length;if(a===t.length)return;const i=aa(o),c=a>t.length;s.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),_s=z("$ZodCheckStringFormat",(e,t)=>{var n,s;dt.init(e,t),e._zod.onattach.push(o=>{const a=o._zod.bag;a.format=t.format,t.pattern&&(a.patterns??(a.patterns=new Set),a.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),th=z("$ZodCheckRegex",(e,t)=>{_s.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),nh=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Gp),_s.init(e,t)}),rh=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Yp),_s.init(e,t)}),sh=z("$ZodCheckIncludes",(e,t)=>{dt.init(e,t);const n=Fn(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(o=>{const a=o._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(s)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),oh=z("$ZodCheckStartsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`^${Fn(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),ah=z("$ZodCheckEndsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`.*${Fn(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),ih=z("$ZodCheckOverwrite",(e,t)=>{dt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ch{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const s=t.split(`
|
|
2
|
+
`).filter(i=>i),o=Math.min(...s.map(i=>i.length-i.trimStart().length)),a=s.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of a)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(a=>` ${a}`)];return new t(...n,o.join(`
|
|
3
|
+
`))}}const lh={major:4,minor:3,patch:6},Pe=z("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=lh;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const o of s)for(const a of o._zod.onattach)a(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,l)=>{let d=Ln(i),f;for(const u of c){if(u._zod.def.when){if(!u._zod.def.when(i))continue}else if(d)continue;const g=i.issues.length,p=u._zod.check(i);if(p instanceof Promise&&l?.async===!1)throw new Dn;if(f||p instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await p,i.issues.length!==g&&(d||(d=Ln(i,g)))});else{if(i.issues.length===g)continue;d||(d=Ln(i,g))}}return f?f.then(()=>i):i},a=(i,c,l)=>{if(Ln(i))return i.aborted=!0,i;const d=o(c,s,l);if(d instanceof Promise){if(l.async===!1)throw new Dn;return d.then(f=>e._zod.parse(f,l))}return e._zod.parse(d,l)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const d=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(f=>a(f,i,c)):a(d,i,c)}const l=e._zod.parse(i,c);if(l instanceof Promise){if(c.async===!1)throw new Dn;return l.then(d=>o(d,s,c))}return o(l,s,c)}}we(e,"~standard",()=>({validate:o=>{try{const a=pp(e,o);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return hp(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),la=z("$ZodString",(e,t)=>{Pe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Wp(e._zod.bag),e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ce=z("$ZodStringFormat",(e,t)=>{_s.init(e,t),la.init(e,t)}),dh=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Tp),Ce.init(e,t)}),uh=z("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=_i(s))}else t.pattern??(t.pattern=_i());Ce.init(e,t)}),fh=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Pp),Ce.init(e,t)}),mh=z("$ZodURL",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),o=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ph=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Op()),Ce.init(e,t)}),hh=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ep),Ce.init(e,t)}),gh=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=jp),Ce.init(e,t)}),xh=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Sp),Ce.init(e,t)}),vh=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Cp),Ce.init(e,t)}),yh=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Np),Ce.init(e,t)}),bh=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ap),Ce.init(e,t)}),wh=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Vp(t)),Ce.init(e,t)}),kh=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Bp),Ce.init(e,t)}),_h=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Up(t)),Ce.init(e,t)}),jh=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ip),Ce.init(e,t)}),Sh=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Mp),Ce.init(e,t),e._zod.bag.format="ipv4"}),Ch=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Lp),Ce.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Nh=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Dp),Ce.init(e,t)}),Ah=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=$p),Ce.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[o,a]=s;if(!a)throw new Error;const i=Number(a);if(`${i}`!==a)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function xl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Eh=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=zp),Ce.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{xl(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ih(e){if(!ul.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return xl(n)}const Th=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ul),Ce.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Ih(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Ph=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Fp),Ce.init(e,t)});function Rh(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const o=JSON.parse(atob(s));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Oh=z("$ZodJWT",(e,t)=>{Ce.init(e,t),e._zod.check=n=>{Rh(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vl=z("$ZodNumber",(e,t)=>{Pe.init(e,t),e._zod.pattern=e._zod.bag.pattern??Hp,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const a=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...a?{received:a}:{}}),n}}),Mh=z("$ZodNumberFormat",(e,t)=>{Kp.init(e,t),vl.init(e,t)}),Lh=z("$ZodBoolean",(e,t)=>{Pe.init(e,t),e._zod.pattern=Zp,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Dh=z("$ZodUnknown",(e,t)=>{Pe.init(e,t),e._zod.parse=n=>n}),$h=z("$ZodNever",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ji(e,t,n){e.issues.length&&t.issues.push(...il(n,e.issues)),t.value[n]=e.value}const zh=z("$ZodArray",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const a=[];for(let i=0;i<o.length;i++){const c=o[i],l=t.element._zod.run({value:c,issues:[]},s);l instanceof Promise?a.push(l.then(d=>ji(d,n,i))):ji(l,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function ss(e,t,n,s,o){if(e.issues.length){if(o&&!(n in s))return;t.issues.push(...il(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function yl(e){const t=Object.keys(e.shape);for(const s of t)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=rp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function bl(e,t,n,s,o,a){const i=[],c=o.keySet,l=o.catchall._zod,d=l.def.type,f=l.optout==="optional";for(const u in t){if(c.has(u))continue;if(d==="never"){i.push(u);continue}const g=l.run({value:t[u],issues:[]},s);g instanceof Promise?e.push(g.then(p=>ss(p,n,u,t,f))):ss(g,n,u,t,f)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const Fh=z("$ZodObject",(e,t)=>{if(Pe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}const s=ra(()=>yl(t));we(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const f=c[d]._zod;if(f.values){l[d]??(l[d]=new Set);for(const u of f.values)l[d].add(u)}}return l});const o=rs,a=t.catchall;let i;e._zod.parse=(c,l)=>{i??(i=s.value);const d=c.value;if(!o(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const f=[],u=i.shape;for(const g of i.keys){const p=u[g],x=p._zod.optout==="optional",h=p._zod.run({value:d[g],issues:[]},l);h instanceof Promise?f.push(h.then(v=>ss(v,c,g,d,x))):ss(h,c,g,d,x)}return a?bl(f,d,c,l,s.value,e):f.length?Promise.all(f).then(()=>c):c}}),Bh=z("$ZodObjectJIT",(e,t)=>{Fh.init(e,t);const n=e._zod.parse,s=ra(()=>yl(t)),o=g=>{const p=new ch(["shape","payload","ctx"]),x=s.value,h=_=>{const b=ki(_);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};p.write("const input = payload.value;");const v=Object.create(null);let y=0;for(const _ of x.keys)v[_]=`key_${y++}`;p.write("const newResult = {};");for(const _ of x.keys){const b=v[_],j=ki(_),T=g[_]?._zod?.optout==="optional";p.write(`const ${b} = ${h(_)};`),T?p.write(`
|
|
4
|
+
if (${b}.issues.length) {
|
|
5
|
+
if (${j} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
7
|
+
...iss,
|
|
8
|
+
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (${b}.value === undefined) {
|
|
14
|
+
if (${j} in input) {
|
|
15
|
+
newResult[${j}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
newResult[${j}] = ${b}.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
`):p.write(`
|
|
22
|
+
if (${b}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
24
|
+
...iss,
|
|
25
|
+
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${b}.value === undefined) {
|
|
30
|
+
if (${j} in input) {
|
|
31
|
+
newResult[${j}] = undefined;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
newResult[${j}] = ${b}.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const k=p.compile();return(_,b)=>k(g,_,b)};let a;const i=rs,c=!rl.jitless,d=c&&tp.value,f=t.catchall;let u;e._zod.parse=(g,p)=>{u??(u=s.value);const x=g.value;return i(x)?c&&d&&p?.async===!1&&p.jitless!==!0?(a||(a=o(t.shape)),g=a(g,p),f?bl([],x,g,p,u,e):g):n(g,p):(g.issues.push({expected:"object",code:"invalid_type",input:x,inst:e}),g)}});function Si(e,t,n,s){for(const a of e)if(a.issues.length===0)return t.value=a.value,t;const o=e.filter(a=>!Ln(a));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(a=>a.issues.map(i=>gn(i,s,hn())))}),t)}const Uh=z("$ZodUnion",(e,t)=>{Pe.init(e,t),we(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),we(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),we(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),we(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(a=>a._zod.pattern);return new RegExp(`^(${o.map(a=>oa(a.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(o,a)=>{if(n)return s(o,a);let i=!1;const c=[];for(const l of t.options){const d=l._zod.run({value:o.value,issues:[]},a);if(d instanceof Promise)c.push(d),i=!0;else{if(d.issues.length===0)return d;c.push(d)}}return i?Promise.all(c).then(l=>Si(l,o,e,a)):Si(c,o,e,a)}}),Vh=z("$ZodIntersection",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>{const o=n.value,a=t.left._zod.run({value:o,issues:[]},s),i=t.right._zod.run({value:o,issues:[]},s);return a instanceof Promise||i instanceof Promise?Promise.all([a,i]).then(([l,d])=>Ci(n,l,d)):Ci(n,a,i)}});function Ro(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(pr(e)&&pr(t)){const n=Object.keys(t),s=Object.keys(e).filter(a=>n.indexOf(a)!==-1),o={...e,...t};for(const a of s){const i=Ro(e[a],t[a]);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};o[a]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],i=Ro(o,a);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ci(e,t,n){const s=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const l of c.keys)s.has(l)||s.set(l,{}),s.get(l).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const l of c.keys)s.has(l)||s.set(l,{}),s.get(l).r=!0;else e.issues.push(c);const a=[...s].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length&&o&&e.issues.push({...o,keys:a}),Ln(e))return e;const i=Ro(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Wh=z("$ZodEnum",(e,t)=>{Pe.init(e,t);const n=sl(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(o=>np.has(typeof o)).map(o=>typeof o=="string"?Fn(o):o.toString()).join("|")})$`),e._zod.parse=(o,a)=>{const i=o.value;return s.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),qh=z("$ZodLiteral",(e,t)=>{if(Pe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?Fn(s):s?Fn(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,o)=>{const a=s.value;return n.has(a)||s.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),s}}),Hh=z("$ZodTransform",(e,t)=>{Pe.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new nl(e.constructor.name);const o=t.transform(n.value,n);if(s.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Dn;return n.value=o,n}});function Ni(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const wl=z("$ZodOptional",(e,t)=>{Pe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",we(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),we(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${oa(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>Ni(a,n.value)):Ni(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),Zh=z("$ZodExactOptional",(e,t)=>{wl.init(e,t),we(e._zod,"values",()=>t.innerType._zod.values),we(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),Gh=z("$ZodNullable",(e,t)=>{Pe.init(e,t),we(e._zod,"optin",()=>t.innerType._zod.optin),we(e._zod,"optout",()=>t.innerType._zod.optout),we(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${oa(n.source)}|null)$`):void 0}),we(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),Yh=z("$ZodDefault",(e,t)=>{Pe.init(e,t),e._zod.optin="optional",we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>Ai(a,t)):Ai(o,t)}});function Ai(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Qh=z("$ZodPrefault",(e,t)=>{Pe.init(e,t),e._zod.optin="optional",we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),Kh=z("$ZodNonOptional",(e,t)=>{Pe.init(e,t),we(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>Ei(a,e)):Ei(o,e)}});function Ei(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Jh=z("$ZodCatch",(e,t)=>{Pe.init(e,t),we(e._zod,"optin",()=>t.innerType._zod.optin),we(e._zod,"optout",()=>t.innerType._zod.optout),we(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(a=>(n.value=a.value,a.issues.length&&(n.value=t.catchValue({...n,error:{issues:a.issues.map(i=>gn(i,s,hn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>gn(a,s,hn()))},input:n.value}),n.issues=[]),n)}}),Xh=z("$ZodPipe",(e,t)=>{Pe.init(e,t),we(e._zod,"values",()=>t.in._zod.values),we(e._zod,"optin",()=>t.in._zod.optin),we(e._zod,"optout",()=>t.out._zod.optout),we(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const a=t.out._zod.run(n,s);return a instanceof Promise?a.then(i=>Rr(i,t.in,s)):Rr(a,t.in,s)}const o=t.in._zod.run(n,s);return o instanceof Promise?o.then(a=>Rr(a,t.out,s)):Rr(o,t.out,s)}});function Rr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const eg=z("$ZodReadonly",(e,t)=>{Pe.init(e,t),we(e._zod,"propValues",()=>t.innerType._zod.propValues),we(e._zod,"values",()=>t.innerType._zod.values),we(e._zod,"optin",()=>t.innerType?._zod?.optin),we(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const o=t.innerType._zod.run(n,s);return o instanceof Promise?o.then(Ii):Ii(o)}});function Ii(e){return e.value=Object.freeze(e.value),e}const tg=z("$ZodCustom",(e,t)=>{dt.init(e,t),Pe.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,o=t.fn(s);if(o instanceof Promise)return o.then(a=>Ti(a,n,s,e));Ti(o,n,s,e)}});function Ti(e,t,n,s){if(!e){const o={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(o.params=s._zod.def.params),t.issues.push(hr(o))}}var Pi;class ng{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const s={...this.get(n)??{}};delete s.id;const o={...s,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function rg(){return new ng}(Pi=globalThis).__zod_globalRegistry??(Pi.__zod_globalRegistry=rg());const cr=globalThis.__zod_globalRegistry;function sg(e,t){return new e({type:"string",...ae(t)})}function og(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ae(t)})}function Ri(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ae(t)})}function ag(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ae(t)})}function ig(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ae(t)})}function cg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ae(t)})}function lg(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ae(t)})}function dg(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ae(t)})}function ug(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ae(t)})}function fg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ae(t)})}function mg(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ae(t)})}function pg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ae(t)})}function hg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ae(t)})}function gg(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ae(t)})}function xg(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ae(t)})}function vg(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ae(t)})}function yg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ae(t)})}function bg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ae(t)})}function wg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ae(t)})}function kg(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ae(t)})}function _g(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ae(t)})}function jg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ae(t)})}function Sg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ae(t)})}function Cg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ae(t)})}function Ng(e,t){return new e({type:"string",format:"date",check:"string_format",...ae(t)})}function Ag(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ae(t)})}function Eg(e,t){return new e({type:"string",format:"duration",check:"string_format",...ae(t)})}function Ig(e,t){return new e({type:"number",checks:[],...ae(t)})}function Tg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ae(t)})}function Pg(e,t){return new e({type:"boolean",...ae(t)})}function Rg(e){return new e({type:"unknown"})}function Og(e,t){return new e({type:"never",...ae(t)})}function Oi(e,t){return new hl({check:"less_than",...ae(t),value:e,inclusive:!1})}function so(e,t){return new hl({check:"less_than",...ae(t),value:e,inclusive:!0})}function Mi(e,t){return new gl({check:"greater_than",...ae(t),value:e,inclusive:!1})}function oo(e,t){return new gl({check:"greater_than",...ae(t),value:e,inclusive:!0})}function Li(e,t){return new Qp({check:"multiple_of",...ae(t),value:e})}function kl(e,t){return new Jp({check:"max_length",...ae(t),maximum:e})}function os(e,t){return new Xp({check:"min_length",...ae(t),minimum:e})}function _l(e,t){return new eh({check:"length_equals",...ae(t),length:e})}function Mg(e,t){return new th({check:"string_format",format:"regex",...ae(t),pattern:e})}function Lg(e){return new nh({check:"string_format",format:"lowercase",...ae(e)})}function Dg(e){return new rh({check:"string_format",format:"uppercase",...ae(e)})}function $g(e,t){return new sh({check:"string_format",format:"includes",...ae(t),includes:e})}function zg(e,t){return new oh({check:"string_format",format:"starts_with",...ae(t),prefix:e})}function Fg(e,t){return new ah({check:"string_format",format:"ends_with",...ae(t),suffix:e})}function Vn(e){return new ih({check:"overwrite",tx:e})}function Bg(e){return Vn(t=>t.normalize(e))}function Ug(){return Vn(e=>e.trim())}function Vg(){return Vn(e=>e.toLowerCase())}function Wg(){return Vn(e=>e.toUpperCase())}function qg(){return Vn(e=>ep(e))}function Hg(e,t,n){return new e({type:"array",element:t,...ae(n)})}function Zg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ae(n)})}function Gg(e){const t=Yg(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(hr(s,n.value,t._zod.def));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(hr(o))}},e(n.value,n)));return t}function Yg(e,t){const n=new dt({check:"custom",...ae(t)});return n._zod.check=e,n}function jl(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??cr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ge(e,t,n={path:[],schemaPath:[]}){var s;const o=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,f);else{const g=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,g,f)}const u=e._zod.parent;u&&(i.ref||(i.ref=u),Ge(u,t,f),t.seen.get(u).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(i.schema,l),t.io==="input"&&nt(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((s=i.schema).default??(s.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Sl(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const l=s.get(c);if(l&&l!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(c,i[0])}}const o=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const u=e.external.registry.get(i[0])?.id,g=e.external.uri??(x=>x);if(u)return{ref:g(u)};const p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${g("__shared")}#/${c}/${p}`}}if(i[1]===n)return{ref:"#"};const d=`#/${c}/`,f=i[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:d+f}},a=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:l,defId:d}=o(i);c.def={...c.schema},d&&(c.defId=d);const f=c.schema;for(const u in f)delete f[u];f.$ref=l};if(e.cycles==="throw")for(const i of e.seen.entries()){const c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
38
|
+
|
|
39
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){a(i);continue}if(e.external){const d=e.external.registry.get(i[0])?.id;if(t!==i[0]&&d){a(i);continue}}if(e.metadataRegistry.get(i[0])?.id){a(i);continue}if(c.cycle){a(i);continue}if(c.count>1&&e.reused==="ref"){a(i);continue}}}function Cl(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=i=>{const c=e.seen.get(i);if(c.ref===null)return;const l=c.def??c.schema,d={...l},f=c.ref;if(c.ref=null,f){s(f);const g=e.seen.get(f),p=g.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(p)):Object.assign(l,p),Object.assign(l,d),i._zod.parent===f)for(const h in l)h==="$ref"||h==="allOf"||h in d||delete l[h];if(p.$ref&&g.def)for(const h in l)h==="$ref"||h==="allOf"||h in g.def&&JSON.stringify(l[h])===JSON.stringify(g.def[h])&&delete l[h]}const u=i._zod.parent;if(u&&u!==f){s(u);const g=e.seen.get(u);if(g?.schema.$ref&&(l.$ref=g.schema.$ref,g.def))for(const p in l)p==="$ref"||p==="allOf"||p in g.def&&JSON.stringify(l[p])===JSON.stringify(g.def[p])&&delete l[p]}e.override({zodSchema:i,jsonSchema:l,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())s(i[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(i)}Object.assign(o,n.def??n.schema);const a=e.external?.defs??{};for(const i of e.seen.entries()){const c=i[1];c.def&&c.defId&&(a[c.defId]=c.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const i=JSON.parse(JSON.stringify(o));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:as(t,"input",e.processors),output:as(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function nt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return nt(s.element,n);if(s.type==="set")return nt(s.valueType,n);if(s.type==="lazy")return nt(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return nt(s.innerType,n);if(s.type==="intersection")return nt(s.left,n)||nt(s.right,n);if(s.type==="record"||s.type==="map")return nt(s.keyType,n)||nt(s.valueType,n);if(s.type==="pipe")return nt(s.in,n)||nt(s.out,n);if(s.type==="object"){for(const o in s.shape)if(nt(s.shape[o],n))return!0;return!1}if(s.type==="union"){for(const o of s.options)if(nt(o,n))return!0;return!1}if(s.type==="tuple"){for(const o of s.items)if(nt(o,n))return!0;return!!(s.rest&&nt(s.rest,n))}return!1}const Qg=(e,t={})=>n=>{const s=jl({...n,processors:t});return Ge(e,s),Sl(s,e),Cl(s,e)},as=(e,t,n={})=>s=>{const{libraryOptions:o,target:a}=s??{},i=jl({...o??{},target:a,io:t,processors:n});return Ge(e,i),Sl(i,e),Cl(i,e)},Kg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Jg=(e,t,n,s)=>{const o=n;o.type="string";const{minimum:a,maximum:i,format:c,patterns:l,contentEncoding:d}=e._zod.bag;if(typeof a=="number"&&(o.minLength=a),typeof i=="number"&&(o.maxLength=i),c&&(o.format=Kg[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),d&&(o.contentEncoding=d),l&&l.size>0){const f=[...l];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(u=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:u.source}))])}},Xg=(e,t,n,s)=>{const o=n,{minimum:a,maximum:i,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof a=="number"&&(o.minimum=a,typeof f=="number"&&t.target!=="draft-04"&&(f>=a?delete o.minimum:delete o.exclusiveMinimum)),typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d),typeof i=="number"&&(o.maximum=i,typeof d=="number"&&t.target!=="draft-04"&&(d<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof l=="number"&&(o.multipleOf=l)},ex=(e,t,n,s)=>{n.type="boolean"},tx=(e,t,n,s)=>{n.not={}},nx=(e,t,n,s)=>{},rx=(e,t,n,s)=>{const o=e._zod.def,a=sl(o.entries);a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),n.enum=a},sx=(e,t,n,s)=>{const o=e._zod.def,a=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(i))}else a.push(i);if(a.length!==0)if(a.length===1){const i=a[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),a.every(i=>typeof i=="boolean")&&(n.type="boolean"),a.every(i=>i===null)&&(n.type="null"),n.enum=a},ox=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},ax=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},ix=(e,t,n,s)=>{const o=n,a=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=Ge(a.element,t,{...s,path:[...s.path,"items"]})},cx=(e,t,n,s)=>{const o=n,a=e._zod.def;o.type="object",o.properties={};const i=a.shape;for(const d in i)o.properties[d]=Ge(i[d],t,{...s,path:[...s.path,"properties",d]});const c=new Set(Object.keys(i)),l=new Set([...c].filter(d=>{const f=a.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));l.size>0&&(o.required=Array.from(l)),a.catchall?._zod.def.type==="never"?o.additionalProperties=!1:a.catchall?a.catchall&&(o.additionalProperties=Ge(a.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},lx=(e,t,n,s)=>{const o=e._zod.def,a=o.inclusive===!1,i=o.options.map((c,l)=>Ge(c,t,{...s,path:[...s.path,a?"oneOf":"anyOf",l]}));a?n.oneOf=i:n.anyOf=i},dx=(e,t,n,s)=>{const o=e._zod.def,a=Ge(o.left,t,{...s,path:[...s.path,"allOf",0]}),i=Ge(o.right,t,{...s,path:[...s.path,"allOf",1]}),c=d=>"allOf"in d&&Object.keys(d).length===1,l=[...c(a)?a.allOf:[a],...c(i)?i.allOf:[i]];n.allOf=l},ux=(e,t,n,s)=>{const o=e._zod.def,a=Ge(o.innerType,t,s),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[a,{type:"null"}]},fx=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType},mx=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},px=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},hx=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},gx=(e,t,n,s)=>{const o=e._zod.def,a=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;Ge(a,t,s);const i=t.seen.get(e);i.ref=a},xx=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType,n.readOnly=!0},Nl=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType},vx=z("ZodISODateTime",(e,t)=>{wh.init(e,t),Ee.init(e,t)});function yx(e){return Cg(vx,e)}const bx=z("ZodISODate",(e,t)=>{kh.init(e,t),Ee.init(e,t)});function wx(e){return Ng(bx,e)}const kx=z("ZodISOTime",(e,t)=>{_h.init(e,t),Ee.init(e,t)});function _x(e){return Ag(kx,e)}const jx=z("ZodISODuration",(e,t)=>{jh.init(e,t),Ee.init(e,t)});function Sx(e){return Eg(jx,e)}const Cx=(e,t)=>{ll.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>mp(e,n)},flatten:{value:n=>fp(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Po,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Po,2)}},isEmpty:{get(){return e.issues.length===0}}})},wt=z("ZodError",Cx,{Parent:Error}),Nx=ia(wt),Ax=ca(wt),Ex=ws(wt),Ix=ks(wt),Tx=gp(wt),Px=xp(wt),Rx=vp(wt),Ox=yp(wt),Mx=bp(wt),Lx=wp(wt),Dx=kp(wt),$x=_p(wt),Re=z("ZodType",(e,t)=>(Pe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:as(e,"input"),output:as(e,"output")}}),e.toJSONSchema=Qg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(sn(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>on(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>Nx(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>Ex(e,n,s),e.parseAsync=async(n,s)=>Ax(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>Ix(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>Tx(e,n,s),e.decode=(n,s)=>Px(e,n,s),e.encodeAsync=async(n,s)=>Rx(e,n,s),e.decodeAsync=async(n,s)=>Ox(e,n,s),e.safeEncode=(n,s)=>Mx(e,n,s),e.safeDecode=(n,s)=>Lx(e,n,s),e.safeEncodeAsync=async(n,s)=>Dx(e,n,s),e.safeDecodeAsync=async(n,s)=>$x(e,n,s),e.refine=(n,s)=>e.check(M0(n,s)),e.superRefine=n=>e.check(L0(n)),e.overwrite=n=>e.check(Vn(n)),e.optional=()=>Fi(e),e.exactOptional=()=>k0(e),e.nullable=()=>Bi(e),e.nullish=()=>Fi(Bi(e)),e.nonoptional=n=>A0(e,n),e.array=()=>u0(e),e.or=n=>p0([e,n]),e.and=n=>g0(e,n),e.transform=n=>Ui(e,b0(n)),e.default=n=>S0(e,n),e.prefault=n=>N0(e,n),e.catch=n=>I0(e,n),e.pipe=n=>Ui(e,n),e.readonly=()=>R0(e),e.describe=n=>{const s=e.clone();return cr.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){return cr.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return cr.get(e);const s=e.clone();return cr.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Al=z("_ZodString",(e,t)=>{la.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(s,o,a)=>Jg(e,s,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(Mg(...s)),e.includes=(...s)=>e.check($g(...s)),e.startsWith=(...s)=>e.check(zg(...s)),e.endsWith=(...s)=>e.check(Fg(...s)),e.min=(...s)=>e.check(os(...s)),e.max=(...s)=>e.check(kl(...s)),e.length=(...s)=>e.check(_l(...s)),e.nonempty=(...s)=>e.check(os(1,...s)),e.lowercase=s=>e.check(Lg(s)),e.uppercase=s=>e.check(Dg(s)),e.trim=()=>e.check(Ug()),e.normalize=(...s)=>e.check(Bg(...s)),e.toLowerCase=()=>e.check(Vg()),e.toUpperCase=()=>e.check(Wg()),e.slugify=()=>e.check(qg())}),zx=z("ZodString",(e,t)=>{la.init(e,t),Al.init(e,t),e.email=n=>e.check(og(Fx,n)),e.url=n=>e.check(dg(Bx,n)),e.jwt=n=>e.check(Sg(n0,n)),e.emoji=n=>e.check(ug(Ux,n)),e.guid=n=>e.check(Ri(Di,n)),e.uuid=n=>e.check(ag(Or,n)),e.uuidv4=n=>e.check(ig(Or,n)),e.uuidv6=n=>e.check(cg(Or,n)),e.uuidv7=n=>e.check(lg(Or,n)),e.nanoid=n=>e.check(fg(Vx,n)),e.guid=n=>e.check(Ri(Di,n)),e.cuid=n=>e.check(mg(Wx,n)),e.cuid2=n=>e.check(pg(qx,n)),e.ulid=n=>e.check(hg(Hx,n)),e.base64=n=>e.check(kg(Xx,n)),e.base64url=n=>e.check(_g(e0,n)),e.xid=n=>e.check(gg(Zx,n)),e.ksuid=n=>e.check(xg(Gx,n)),e.ipv4=n=>e.check(vg(Yx,n)),e.ipv6=n=>e.check(yg(Qx,n)),e.cidrv4=n=>e.check(bg(Kx,n)),e.cidrv6=n=>e.check(wg(Jx,n)),e.e164=n=>e.check(jg(t0,n)),e.datetime=n=>e.check(yx(n)),e.date=n=>e.check(wx(n)),e.time=n=>e.check(_x(n)),e.duration=n=>e.check(Sx(n))});function qe(e){return sg(zx,e)}const Ee=z("ZodStringFormat",(e,t)=>{Ce.init(e,t),Al.init(e,t)}),Fx=z("ZodEmail",(e,t)=>{fh.init(e,t),Ee.init(e,t)}),Di=z("ZodGUID",(e,t)=>{dh.init(e,t),Ee.init(e,t)}),Or=z("ZodUUID",(e,t)=>{uh.init(e,t),Ee.init(e,t)}),Bx=z("ZodURL",(e,t)=>{mh.init(e,t),Ee.init(e,t)}),Ux=z("ZodEmoji",(e,t)=>{ph.init(e,t),Ee.init(e,t)}),Vx=z("ZodNanoID",(e,t)=>{hh.init(e,t),Ee.init(e,t)}),Wx=z("ZodCUID",(e,t)=>{gh.init(e,t),Ee.init(e,t)}),qx=z("ZodCUID2",(e,t)=>{xh.init(e,t),Ee.init(e,t)}),Hx=z("ZodULID",(e,t)=>{vh.init(e,t),Ee.init(e,t)}),Zx=z("ZodXID",(e,t)=>{yh.init(e,t),Ee.init(e,t)}),Gx=z("ZodKSUID",(e,t)=>{bh.init(e,t),Ee.init(e,t)}),Yx=z("ZodIPv4",(e,t)=>{Sh.init(e,t),Ee.init(e,t)}),Qx=z("ZodIPv6",(e,t)=>{Ch.init(e,t),Ee.init(e,t)}),Kx=z("ZodCIDRv4",(e,t)=>{Nh.init(e,t),Ee.init(e,t)}),Jx=z("ZodCIDRv6",(e,t)=>{Ah.init(e,t),Ee.init(e,t)}),Xx=z("ZodBase64",(e,t)=>{Eh.init(e,t),Ee.init(e,t)}),e0=z("ZodBase64URL",(e,t)=>{Th.init(e,t),Ee.init(e,t)}),t0=z("ZodE164",(e,t)=>{Ph.init(e,t),Ee.init(e,t)}),n0=z("ZodJWT",(e,t)=>{Oh.init(e,t),Ee.init(e,t)}),El=z("ZodNumber",(e,t)=>{vl.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(s,o,a)=>Xg(e,s,o),e.gt=(s,o)=>e.check(Mi(s,o)),e.gte=(s,o)=>e.check(oo(s,o)),e.min=(s,o)=>e.check(oo(s,o)),e.lt=(s,o)=>e.check(Oi(s,o)),e.lte=(s,o)=>e.check(so(s,o)),e.max=(s,o)=>e.check(so(s,o)),e.int=s=>e.check($i(s)),e.safe=s=>e.check($i(s)),e.positive=s=>e.check(Mi(0,s)),e.nonnegative=s=>e.check(oo(0,s)),e.negative=s=>e.check(Oi(0,s)),e.nonpositive=s=>e.check(so(0,s)),e.multipleOf=(s,o)=>e.check(Li(s,o)),e.step=(s,o)=>e.check(Li(s,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function r0(e){return Ig(El,e)}const s0=z("ZodNumberFormat",(e,t)=>{Mh.init(e,t),El.init(e,t)});function $i(e){return Tg(s0,e)}const o0=z("ZodBoolean",(e,t)=>{Lh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ex(e,n,s)});function a0(e){return Pg(o0,e)}const i0=z("ZodUnknown",(e,t)=>{Dh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>nx()});function zi(){return Rg(i0)}const c0=z("ZodNever",(e,t)=>{$h.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>tx(e,n,s)});function l0(e){return Og(c0,e)}const d0=z("ZodArray",(e,t)=>{zh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ix(e,n,s,o),e.element=t.element,e.min=(n,s)=>e.check(os(n,s)),e.nonempty=n=>e.check(os(1,n)),e.max=(n,s)=>e.check(kl(n,s)),e.length=(n,s)=>e.check(_l(n,s)),e.unwrap=()=>e.element});function u0(e,t){return Hg(d0,e,t)}const f0=z("ZodObject",(e,t)=>{Bh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>cx(e,n,s,o),we(e,"shape",()=>t.shape),e.keyof=()=>x0(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:zi()}),e.loose=()=>e.clone({...e._zod.def,catchall:zi()}),e.strict=()=>e.clone({...e._zod.def,catchall:l0()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>ip(e,n),e.safeExtend=n=>cp(e,n),e.merge=n=>lp(e,n),e.pick=n=>op(e,n),e.omit=n=>ap(e,n),e.partial=(...n)=>dp(Tl,e,n[0]),e.required=(...n)=>up(Pl,e,n[0])});function Il(e,t){const n={type:"object",shape:e??{},...ae(t)};return new f0(n)}const m0=z("ZodUnion",(e,t)=>{Uh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>lx(e,n,s,o),e.options=t.options});function p0(e,t){return new m0({type:"union",options:e,...ae(t)})}const h0=z("ZodIntersection",(e,t)=>{Vh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>dx(e,n,s,o)});function g0(e,t){return new h0({type:"intersection",left:e,right:t})}const Oo=z("ZodEnum",(e,t)=>{Wh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(s,o,a)=>rx(e,s,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,o)=>{const a={};for(const i of s)if(n.has(i))a[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Oo({...t,checks:[],...ae(o),entries:a})},e.exclude=(s,o)=>{const a={...t.entries};for(const i of s)if(n.has(i))delete a[i];else throw new Error(`Key ${i} not found in enum`);return new Oo({...t,checks:[],...ae(o),entries:a})}});function x0(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Oo({type:"enum",entries:n,...ae(t)})}const v0=z("ZodLiteral",(e,t)=>{qh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>sx(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ao(e,t){return new v0({type:"literal",values:Array.isArray(e)?e:[e],...ae(t)})}const y0=z("ZodTransform",(e,t)=>{Hh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ax(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new nl(e.constructor.name);n.addIssue=a=>{if(typeof a=="string")n.issues.push(hr(a,n.value,t));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(hr(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(a=>(n.value=a,n)):(n.value=o,n)}});function b0(e){return new y0({type:"transform",transform:e})}const Tl=z("ZodOptional",(e,t)=>{wl.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Nl(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Fi(e){return new Tl({type:"optional",innerType:e})}const w0=z("ZodExactOptional",(e,t)=>{Zh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Nl(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function k0(e){return new w0({type:"optional",innerType:e})}const _0=z("ZodNullable",(e,t)=>{Gh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ux(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Bi(e){return new _0({type:"nullable",innerType:e})}const j0=z("ZodDefault",(e,t)=>{Yh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>mx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function S0(e,t){return new j0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():al(t)}})}const C0=z("ZodPrefault",(e,t)=>{Qh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>px(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function N0(e,t){return new C0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():al(t)}})}const Pl=z("ZodNonOptional",(e,t)=>{Kh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>fx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function A0(e,t){return new Pl({type:"nonoptional",innerType:e,...ae(t)})}const E0=z("ZodCatch",(e,t)=>{Jh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>hx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function I0(e,t){return new E0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const T0=z("ZodPipe",(e,t)=>{Xh.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>gx(e,n,s,o),e.in=t.in,e.out=t.out});function Ui(e,t){return new T0({type:"pipe",in:e,out:t})}const P0=z("ZodReadonly",(e,t)=>{eg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>xx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function R0(e){return new P0({type:"readonly",innerType:e})}const O0=z("ZodCustom",(e,t)=>{tg.init(e,t),Re.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ox(e,n)});function M0(e,t={}){return Zg(O0,e,t)}function L0(e){return Gg(e)}const Mr=Il({line1:qe().min(1,"Address line 1 is required"),line2:qe().optional(),city:qe().min(1,"City is required"),state:qe().optional(),postalCode:qe().min(1,"Postal code is required"),country:qe().min(2,"Country is required")});function D0(e){return Il({email:e.requireEmail?qe().email("Valid email required"):qe().email("Valid email required").or(ao("")).optional(),name:e.requireName?qe().min(1,"Name is required"):qe().optional(),phone:e.requirePhone?qe().min(6,"Phone is required"):qe().optional(),notes:qe().max(500).optional(),shippingAddress:e.requireShippingAddress?Mr:Mr.optional(),billingAddress:e.requireBillingAddress?Mr:Mr.optional(),recipientEmail:qe().email("Valid recipient email required").or(ao("")).optional(),giftMessage:qe().max(500).optional(),discountCode:qe().optional(),tipAmount:r0().min(0).optional(),shippingMethodId:qe().optional(),regulatoryConsent:e.requireRegulatoryConsent?ao(!0,{message:"You must acknowledge the regulatory notice"}):a0().optional()})}const Vi={none:0,optional:1,required:2};function io(e,t){return Vi[e]>=Vi[t]?e:t}function $0(e){if(!e)return null;try{const t=JSON.parse(e);return!t||typeof t!="object"?null:t}catch{return null}}function Qr(e,t){let n=!1,s=!1;const o=new Set;let a=t.requireEmail?"required":"none",i=t.defaultMode==="none"?"none":"optional",c=t.defaultMode==="full"?"optional":"none",l=t.allowShipping&&(t.defaultMode==="shipping"||t.defaultMode==="full"),d=t.defaultMode==="full";for(const u of e){u.metadata?.shippingProfile==="digital"?n=!0:s=!0;const p=$0(u.metadata?.checkoutRequirements);p&&(p.email&&(a=io(a,p.email)),p.name&&(i=io(i,p.name)),p.phone&&(c=io(c,p.phone)),typeof p.shippingAddress=="boolean"&&(l=l||p.shippingAddress),typeof p.billingAddress=="boolean"&&(d=d||p.billingAddress));const x=u.metadata?.fulfillmentNotes;x&&o.add(x)}const f=n&&!s;return f&&(l=!1),{email:a,name:i,phone:c,shippingAddress:l,billingAddress:d,fulfillmentNotes:Array.from(o).join(" "),isDigitalOnly:f,hasPhysical:s}}const Rl=w.createContext(null);function Ol(){const{config:e}=Ae(),t=Et(),n=w.useMemo(()=>({line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"}),[]),s=t.items.some(b=>!!b.metadata?.regulatoryNotice),o=w.useMemo(()=>{const b=Qr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});return D0({requireEmail:b.email==="required",requireName:b.name==="required",requirePhone:b.phone==="required",requireShippingAddress:b.shippingAddress,requireBillingAddress:b.billingAddress,requireRegulatoryConsent:s})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,s]),[a,i]=w.useState(()=>({email:e.checkout.requireEmail??!0?"":void 0,name:"",phone:"",notes:"",shippingAddress:e.checkout.mode==="shipping"||e.checkout.mode==="full"?n:void 0,billingAddress:e.checkout.mode==="full"?n:void 0,discountCode:"",tipAmount:0,shippingMethodId:"",regulatoryConsent:void 0}));w.useEffect(()=>{const b=Qr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});i(j=>{const N={...j};return b.email==="required"&&!N.email&&(N.email=""),b.shippingAddress&&!N.shippingAddress&&(N.shippingAddress=n),b.billingAddress&&!N.billingAddress&&(N.billingAddress=n),b.shippingAddress||(N.shippingAddress=void 0),b.billingAddress||(N.billingAddress=void 0),N})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,n]);const c=w.useRef(!1),[l,d]=w.useState({}),[f,u]=w.useState("idle"),[g,p]=w.useState(null),[x,h]=w.useState(null),v=w.useCallback(()=>{d({}),u("idle"),p(null),h(null)},[]),y=w.useCallback((b,j)=>{i(N=>({...N,[b]:j}))},[]),k=w.useCallback(()=>{u("validating"),p(null);const b=o.safeParse(a);if(b.success)return d({}),u("idle"),{ok:!0,values:b.data};const j={};for(const N of b.error.issues)j[N.path.join(".")]=N.message;return d(j),u("error"),p("Please fix the highlighted fields."),{ok:!1}},[o,a]),_=w.useCallback(async b=>{if(c.current)return{ok:!1};const j=k();if(!j.ok)return{ok:!1};c.current=!0,u("creating_session"),p(null),h(null);const N=t.items.map(P=>({resource:P.paymentResource??P.productId,quantity:P.qty,variantId:P.variantId})),T=Qr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1}),A=new Set;if(T.shippingAddress)for(const P of t.items){const F=P.metadata?.shippingCountries;if(F)for(const L of F.split(",")){const U=L.trim().toUpperCase();U&&A.add(U)}}const E={...A.size?{shippingCountries:Array.from(A).join(","),shipping_countries:Array.from(A).join(",")}:{},...j.values.recipientEmail?{recipient_email:j.values.recipientEmail}:{},...j.values.giftMessage?{gift_message:j.values.giftMessage}:{},...j.values.regulatoryConsent?{regulatory_consent:"true"}:{}};try{const P=await e.adapter.createCheckoutSession({cart:N,customer:{email:j.values.email||void 0,name:j.values.name||void 0,phone:j.values.phone||void 0,notes:j.values.notes||void 0,shippingAddress:j.values.shippingAddress,billingAddress:j.values.billingAddress},options:{currency:e.currency,successUrl:e.checkout.successUrl,cancelUrl:e.checkout.cancelUrl,allowPromoCodes:e.checkout.allowPromoCodes,metadata:Object.keys(E).length?E:void 0,discountCode:(e.checkout.allowPromoCodes?j.values.discountCode||t.promoCode:void 0)||void 0,tipAmount:e.checkout.allowTipping&&j.values.tipAmount||void 0,shippingMethodId:e.checkout.allowShipping&&j.values.shippingMethodId||void 0,paymentMethodId:b?.paymentMethodId}});return P.kind==="redirect"?(h(P),u("redirecting"),typeof window<"u"&&window.location.assign(P.url),{ok:!0,session:P}):(h(P),u("success"),{ok:!0,session:P})}catch(P){return u("error"),p(P instanceof Error?P.message:"Checkout failed"),{ok:!1}}finally{c.current=!1}},[t.items,t.promoCode,e.adapter,e.checkout,e.currency,k]);return{values:a,setValues:i,setField:y,fieldErrors:l,status:f,error:g,session:x,reset:v,validate:k,createCheckoutSession:_}}function Ml({children:e}){const t=Ol();return r.jsx(Rl.Provider,{value:t,children:e})}function Nr(){const e=w.useContext(Rl);if(!e)throw new Error("useCheckout must be used within CheckoutProvider");return e}function z0(){return Ol()}function da(){const{config:e}=Ae(),[t,n]=m.useState([]),[s,o]=m.useState(!0),[a,i]=m.useState(null);return m.useEffect(()=>{let c=!1;return o(!0),i(null),e.adapter.listCategories().then(l=>{c||n(l)}).catch(l=>{c||i(l instanceof Error?l.message:"Failed to load categories")}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e.adapter]),{categories:t,isLoading:s,error:a}}function js(e){const{config:t}=Ae(),[n,s]=m.useState(null),[o,a]=m.useState(!0),[i,c]=m.useState(null),l=m.useMemo(()=>JSON.stringify(e.filters??{}),[e.filters]);return m.useEffect(()=>{let d=!1;return a(!0),c(null),t.adapter.listProducts(e).then(f=>{d||s(f)}).catch(f=>{d||c(f instanceof Error?f.message:"Failed to load products")}).finally(()=>{d||a(!1)}),()=>{d=!0}},[t.adapter,e.category,e.search,e.sort,e.page,e.pageSize,l]),{data:n,isLoading:o,error:i}}function Ll(e){const{config:t}=Ae(),[n,s]=m.useState(null),[o,a]=m.useState(!0),[i,c]=m.useState(null);return m.useEffect(()=>{let l=!1;return a(!0),c(null),t.adapter.getProductBySlug(e).then(d=>{l||s(d)}).catch(d=>{l||c(d instanceof Error?d.message:"Failed to load product")}).finally(()=>{l||a(!1)}),()=>{l=!0}},[t.adapter,e]),{product:n,isLoading:o,error:i}}function Dl(){const{config:e}=Ae(),[t,n]=m.useState([]),[s,o]=m.useState(!0),[a,i]=m.useState(null);return m.useEffect(()=>{let c=!1;return o(!0),i(null),e.adapter.getOrderHistory().then(l=>{c||n(l)}).catch(l=>{c||i(l instanceof Error?l.message:"Failed to load orders")}).finally(()=>{c||o(!1)}),()=>{c=!0}},[e.adapter]),{orders:t,isLoading:s,error:a}}function $l(){const{config:e}=Ae(),[t,n]=m.useState([]),[s,o]=m.useState(null),[a,i]=m.useState(!0),[c,l]=m.useState(null);return m.useEffect(()=>{let d=!1;async function f(){i(!0),l(null);try{const[u,g]=await Promise.all([e.adapter.listSubscriptionTiers?.()??Promise.resolve([]),e.adapter.getSubscriptionStatus?.()??Promise.resolve(null)]);if(d)return;n(u),o(g)}catch(u){if(d)return;l(u instanceof Error?u.message:"Failed to load subscriptions")}finally{d||i(!1)}}return f(),()=>{d=!0}},[e.adapter]),{tiers:t,status:s,isLoading:a,error:c}}function zl({enabled:e,customer:t}){const{config:n}=Ae(),[s,o]=m.useState([]),[a,i]=m.useState(!1),[c,l]=m.useState(null),d=JSON.stringify(t.shippingAddress??{});return m.useEffect(()=>{let f=!1;if(!e||!n.adapter.getShippingMethods){o([]);return}return i(!0),l(null),n.adapter.getShippingMethods({currency:n.currency,customer:t}).then(u=>{f||o(u)}).catch(u=>{f||l(u instanceof Error?u.message:"Failed to load shipping methods")}).finally(()=>{f||i(!1)}),()=>{f=!0}},[n.adapter,n.currency,e,t.email,t.name,d]),{methods:s,isLoading:a,error:c}}function er(e,...t){for(const n of t){const s=e[n];if(s)return s}}function ua(e){const t=er(e,"error","error_message","message");if(t)return{kind:"error",message:t};const n=er(e,"canceled","cancelled","cancel","canceled_at");if(n&&n!=="0"&&n!=="false")return{kind:"cancel"};const s=er(e,"orderId","order_id","demoOrderId"),o=er(e,"session_id","checkout_session_id");if(s||o)return{kind:"success",orderId:s??o};const a=(er(e,"status","checkout")??"").toLowerCase();return a==="success"?{kind:"success",orderId:s}:a==="cancel"||a==="canceled"?{kind:"cancel"}:a==="error"?{kind:"error"}:{kind:"idle"}}function F0(e){const t={};return e.forEach((n,s)=>{t[s]=n}),t}function fa(){const{config:e}=Ae(),[t,n]=m.useState({kind:"idle"});return m.useEffect(()=>{if(typeof window>"u")return;const s=new URLSearchParams(window.location.search),o=F0(s);(async()=>{try{const a=e.adapter.resolveCheckoutReturn?await e.adapter.resolveCheckoutReturn({query:o}):ua(o);if(a.kind==="success"&&a.orderId&&e.adapter.getOrderById){const i=await e.adapter.getOrderById(a.orderId);if(i){n({kind:"success",orderId:a.orderId,order:i});return}}n(a)}catch(a){n({kind:"error",message:a instanceof Error?a.message:"Failed to resolve checkout"})}})()},[e.adapter]),t}function Mo(e){if(!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function B0(e){const t=e.get("tags"),n=t?t.split(",").map(c=>c.trim()).filter(Boolean):void 0,s=Mo(e.get("min")),o=Mo(e.get("max")),a=e.get("inStock"),i=a==="1"?!0:a==="0"?!1:void 0;return{tags:n&&n.length?n:void 0,priceMin:s,priceMax:o,inStock:i}}function U0(e,t){t.tags?.length?e.set("tags",t.tags.join(",")):e.delete("tags"),typeof t.priceMin=="number"?e.set("min",String(t.priceMin)):e.delete("min"),typeof t.priceMax=="number"?e.set("max",String(t.priceMax)):e.delete("max"),typeof t.inStock=="boolean"?e.set("inStock",t.inStock?"1":"0"):e.delete("inStock")}function ma({includeCategory:e}){if(typeof window>"u")return null;const t=new URLSearchParams(window.location.search),n=t.get("q")??"",s=t.get("sort")??"featured",o=Mo(t.get("page"))??1,a=B0(t),i=e?t.get("cat")??void 0:void 0;return{search:n,sort:s,page:Math.max(1,Math.floor(o)),category:i,filters:a}}function pa(e,{includeCategory:t}){const n=e.filters.tags?.join(",")??"";m.useEffect(()=>{if(typeof window>"u")return;const s=window.setTimeout(()=>{const o=new URL(window.location.href),a=o.searchParams;e.search.trim()?a.set("q",e.search.trim()):a.delete("q"),e.sort&&e.sort!=="featured"?a.set("sort",e.sort):a.delete("sort"),e.page&&e.page!==1?a.set("page",String(e.page)):a.delete("page"),t&&(e.category?a.set("cat",e.category):a.delete("cat")),U0(a,e.filters);const i=`${o.pathname}?${a.toString()}${o.hash}`,c=`${window.location.pathname}${window.location.search}${window.location.hash}`;i!==c&&window.history.replaceState({},"",i)},250);return()=>window.clearTimeout(s)},[t,e.category,e.page,e.search,e.sort,n,e.filters.priceMin,e.filters.priceMax,e.filters.inStock])}const Wi=2;function qi(e,t){return`${e}::${t??""}`}function V0(e,t){if(t&&e.variants?.length){const n=e.variants.find(s=>s.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function W0(e,t){const n={productId:e.productId,variantId:e.variantId,isOutOfStock:!1,exceedsAvailable:!1,isLowStock:!1};if(!t)return{...n,isOutOfStock:!0,message:"This product is no longer available"};const{qty:s,status:o}=V0(t,e.variantId);return n.availableQty=s,n.status=o,o==="out_of_stock"||typeof s=="number"&&s<=0?{...n,isOutOfStock:!0,message:"Out of stock"}:typeof s=="number"&&e.qty>s?{...n,exceedsAvailable:!0,message:s===0?"Out of stock":`Only ${s} available (you have ${e.qty} in cart)`}:o==="low"||typeof s=="number"&&s>0&&s<=5?{...n,isLowStock:!0,message:typeof s=="number"?`Only ${s} left`:"Low stock"}:n}function q0(e,t){if(e.size!==t.size)return!1;for(const[n,s]of e){const o=t.get(n);if(!o||s.productId!==o.productId||s.variantId!==o.variantId||s.availableQty!==o.availableQty||s.status!==o.status||s.isOutOfStock!==o.isOutOfStock||s.exceedsAvailable!==o.exceedsAvailable||s.isLowStock!==o.isLowStock||s.message!==o.message)return!1}return!0}async function H0(e,t){const n=new Map;for(let s=0;s<e.length;s+=Wi){const o=e.slice(s,s+Wi),a=await Promise.all(o.map(async i=>{try{return await t(i)}catch{return null}}));for(const i of a)i&&(n.set(i.id,i),i.slug&&i.slug!==i.id&&n.set(i.slug,i))}return n}function ha({items:e,refreshInterval:t=3e4,skip:n=!1}){const{config:s}=Ae(),[o,a]=m.useState(new Map),[i,c]=m.useState(!1),[l,d]=m.useState(null),f=m.useRef(null),u=m.useRef(e);u.current=e;const g=m.useRef([]),p=m.useMemo(()=>{const _=new Set;for(const b of e)_.add(b.productId);return _},[e]),x=m.useMemo(()=>Array.from(p).sort().join(","),[p]),h=m.useMemo(()=>Array.from(p),[p]);g.current=h;const v=m.useCallback(async()=>{if(n||g.current.length===0){d(null),c(!1),a(j=>j.size===0?j:new Map);return}if(f.current)return f.current;const b=(async()=>{c(!0),d(null);try{const j=g.current,N=s.adapter.getProductsByIds?await s.adapter.getProductsByIds(j):await H0(j,s.adapter.getProductBySlug),T=new Map;for(const A of u.current){const E=qi(A.productId,A.variantId),P=N.get(A.productId)??null;T.set(E,W0(A,P))}a(A=>q0(A,T)?A:T)}catch(j){d(j instanceof Error?j.message:"Failed to check inventory")}finally{c(!1),f.current=null}})();return f.current=b,b},[s.adapter,x,n]);m.useEffect(()=>{v()},[v]),m.useEffect(()=>{if(n||t<=0||h.length===0)return;let _=!1,b=null;const j=()=>{b=setTimeout(async()=>{await v(),_||j()},t)};return j(),()=>{_=!0,b&&clearTimeout(b)}},[v,h.length,t,n]);const y=m.useCallback((_,b)=>o.get(qi(_,b)),[o]),k=m.useMemo(()=>{for(const _ of o.values())if(_.isOutOfStock||_.exceedsAvailable)return!0;return!1},[o]);return{inventory:o,isLoading:i,error:l,refresh:v,getItemInventory:y,hasIssues:k}}function Z0(e,t){if(t&&e.variants?.length){const n=e.variants.find(s=>s.id===t);if(n)return{qty:n.inventoryQuantity,status:n.inventoryStatus}}return{qty:e.inventoryQuantity,status:e.inventoryStatus}}function G0(e,t,n){if(!t)return e.titleSnapshot??"Unknown Product";const s=t.title??e.titleSnapshot??"Product";if(n&&t.variants?.length){const o=t.variants.find(a=>a.id===n);if(o?.title)return`${s} - ${o.title}`}return s}function Y0(e,t){const n=G0(e,t,e.variantId);if(!t)return{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:0,type:"product_unavailable",message:"This product is no longer available"};const{qty:s,status:o}=Z0(t,e.variantId);return o==="out_of_stock"||typeof s=="number"&&s<=0?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:0,type:"out_of_stock",message:"This item is out of stock"}:typeof s=="number"&&e.qty>s?{productId:e.productId,variantId:e.variantId,title:n,requestedQty:e.qty,availableQty:s,type:"insufficient_stock",message:s===0?"This item is out of stock":`Only ${s} available`}:null}function Fl({items:e}){const{config:t}=Ae(),[n,s]=m.useState(null),[o,a]=m.useState(!1),[i,c]=m.useState(null),l=m.useMemo(()=>{const u=new Set;for(const g of e)u.add(g.productId);return Array.from(u)},[e]),d=m.useCallback(async()=>{if(e.length===0){const u={ok:!0,issues:[],verifiedAt:new Date};return s(u),u}a(!0),c(null);try{let u=new Map;if(t.adapter.getProductsByIds)u=await t.adapter.getProductsByIds(l);else{const x=await Promise.all(l.map(async h=>{try{return await t.adapter.getProductBySlug(h)}catch{return null}}));u=new Map;for(const h of x)h&&(u.set(h.id,h),h.slug&&h.slug!==h.id&&u.set(h.slug,h))}const g=[];for(const x of e){const h=u.get(x.productId)??null,v=Y0(x,h);v&&g.push(v)}const p={ok:g.length===0,issues:g,verifiedAt:new Date};return s(p),a(!1),p}catch(u){const g=u instanceof Error?u.message:"Failed to verify inventory";c(g),a(!1);const p={ok:!1,issues:[],verifiedAt:new Date};return s(p),p}},[t.adapter,e,l]),f=m.useCallback(()=>{s(null),c(null)},[]);return{result:n,isVerifying:o,error:i,verify:d,reset:f}}function Q0({items:e,onExpiry:t,enabled:n=!0}){const[s,o]=m.useState([]),[a,i]=m.useState([]),c=m.useRef(new Set),l=m.useRef(t);l.current=t;const d=m.useMemo(()=>n?e.filter(f=>f.holdId&&f.holdExpiresAt):[],[e,n]);return m.useEffect(()=>{if(!n||d.length===0){o([]),i([]);return}const f=()=>{const g=Date.now(),p=120*1e3,x=[],h=[];for(const v of d){if(!v.holdExpiresAt)continue;const y=new Date(v.holdExpiresAt),k=y.getTime()-g,_=`${v.productId}::${v.variantId??""}`;k<=0?(x.push({productId:v.productId,variantId:v.variantId}),c.current.has(_)||(c.current.add(_),l.current?.({productId:v.productId,variantId:v.variantId,title:v.titleSnapshot,expiredAt:y}))):k<=p&&h.push({productId:v.productId,variantId:v.variantId,expiresAt:y,remainingMs:k})}o(x),i(h)};f();const u=setInterval(f,1e4);return()=>clearInterval(u)},[n,d]),m.useEffect(()=>{const f=new Set(d.map(u=>`${u.productId}::${u.variantId??""}`));for(const u of c.current)f.has(u)||c.current.delete(u)},[d]),{expiringItems:a,expiredItems:s}}const ke={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:""}};function K0(e){return{relatedProducts:{mode:e.relatedProducts?.mode||ke.relatedProducts.mode,maxItems:e.relatedProducts?.maxItems||ke.relatedProducts.maxItems,layout:{layout:e.relatedProducts?.layout?.layout??ke.relatedProducts.layout.layout,imageCrop:e.relatedProducts?.layout?.imageCrop??ke.relatedProducts.layout.imageCrop}},catalog:{filters:{tags:e.catalog?.filters?.tags??ke.catalog.filters.tags,priceRange:e.catalog?.filters?.priceRange??ke.catalog.filters.priceRange,inStock:e.catalog?.filters?.inStock??ke.catalog.filters.inStock},sort:{featured:e.catalog?.sort?.featured??ke.catalog.sort.featured,priceAsc:e.catalog?.sort?.priceAsc??ke.catalog.sort.priceAsc,priceDesc:e.catalog?.sort?.priceDesc??ke.catalog.sort.priceDesc}},checkout:{promoCodes:e.checkout?.promoCodes??ke.checkout.promoCodes},shopLayout:{layout:e.shopLayout?.layout??ke.shopLayout.layout,imageCrop:e.shopLayout?.imageCrop??ke.shopLayout.imageCrop},categoryLayout:{layout:e.categoryLayout?.layout??ke.categoryLayout.layout,imageCrop:e.categoryLayout?.imageCrop??ke.categoryLayout.imageCrop},sections:{showDescription:e.sections?.showDescription??ke.sections.showDescription,showSpecs:e.sections?.showSpecs??ke.sections.showSpecs,showShipping:e.sections?.showShipping??ke.sections.showShipping,showRelatedProducts:e.sections?.showRelatedProducts??ke.sections.showRelatedProducts},inventory:{preCheckoutVerification:e.inventory?.preCheckoutVerification??ke.inventory.preCheckoutVerification,holdsEnabled:e.inventory?.holdsEnabled??ke.inventory.holdsEnabled,holdDurationMinutes:e.inventory?.holdDurationMinutes??ke.inventory.holdDurationMinutes},shopPage:{title:e.shopPage?.title??ke.shopPage.title,description:e.shopPage?.description??ke.shopPage.description}}}function Wn(e={}){const n=na()?.config?.adapter,[s,o]=w.useState(ke),[a,i]=w.useState(!!n?.getStorefrontSettings);return w.useEffect(()=>{if(!n?.getStorefrontSettings){i(!1);return}let c=!1;async function l(){try{const d=await n.getStorefrontSettings();!c&&d&&o(K0(d))}catch{}finally{c||i(!1)}}return l(),()=>{c=!0}},[n]),{settings:s,isLoading:a}}const J0={card:!0,crypto:!0,credits:!1};function Bl(){const t=na()?.config?.adapter,[n,s]=w.useState(J0),[o,a]=w.useState(!!t?.getPaymentMethodsConfig);return w.useEffect(()=>{if(!t?.getPaymentMethodsConfig){a(!1);return}let i=!1;async function c(){try{const l=await t.getPaymentMethodsConfig();!i&&l&&s(l)}catch{}finally{i||a(!1)}}return c(),()=>{i=!0}},[t]),{config:n,isLoading:o}}const X0=50,tr=new Map;function ev(e){return e.productId?`id:${e.productId}`:e.name?`name:${e.name}`:""}function Ul(e={}){const{productId:t,product:n,enabled:s=!0}=e,a=na()?.config?.adapter,[i,c]=w.useState(null),[l,d]=w.useState(null),[f,u]=w.useState(!1),[g,p]=w.useState(null),x=w.useRef(0),h=w.useCallback(async()=>{const v=t?{productId:t}:n?{name:n.name,description:n.description,tags:n.tags,categoryIds:n.categoryIds}:{};if(!v.productId&&!v.name)return;if(!a?.getAIRelatedProducts){p("AI recommendations not available");return}const y=ev(v),k=tr.get(y);if(k){c(k.relatedProductIds),d(k.reasoning),p(null);return}const _=++x.current;u(!0),p(null);try{const b=await a.getAIRelatedProducts(v);if(_===x.current&&(c(b.relatedProductIds),d(b.reasoning),p(null),y)){if(tr.size>=X0){const j=tr.keys().next().value;j!==void 0&&tr.delete(j)}tr.set(y,b)}}catch(b){if(_===x.current){const j=b instanceof Error?b.message:"Failed to get AI recommendations";p(j),c(null),d(null)}}finally{_===x.current&&u(!1)}},[a,t,n]);return w.useEffect(()=>{s&&(!t&&!n?.name||h())},[s,t,n?.name,h]),{relatedProductIds:i,reasoning:l,isLoading:f,error:g,refetch:h}}function Ne(e,t){if(!e)throw new Error(t)}function jt(e){return typeof e=="string"&&e.trim().length>0}async function tv(e,t={}){const n=t.pageSize??10,s=await e.listCategories();Ne(Array.isArray(s),"listCategories() must return an array");for(const i of s)Ne(jt(i.id),"Category.id is required"),Ne(jt(i.slug),"Category.slug is required"),Ne(jt(i.name),"Category.name is required");const o=await e.listProducts({page:1,pageSize:n});if(Ne(o&&Array.isArray(o.items),"listProducts() must return { items: Product[] }"),Ne(typeof o.page=="number","listProducts().page must be a number"),Ne(typeof o.pageSize=="number","listProducts().pageSize must be a number"),o.items.length>0){const i=o.items[0];Ne(jt(i.id),"Product.id is required"),Ne(jt(i.slug),"Product.slug is required"),Ne(jt(i.title),"Product.title is required"),Ne(typeof i.description=="string","Product.description must be a string"),Ne(Array.isArray(i.images),"Product.images must be an array"),Ne(typeof i.price=="number","Product.price must be a number"),Ne(jt(i.currency),"Product.currency is required"),Ne(Array.isArray(i.tags),"Product.tags must be an array"),Ne(Array.isArray(i.categoryIds),"Product.categoryIds must be an array");const c=await e.getProductBySlug(i.slug);Ne(c===null||jt(c.id),"getProductBySlug() must return Product or null")}const a=await e.getOrderHistory();Ne(Array.isArray(a),"getOrderHistory() must return an array");for(const i of a)Ne(jt(i.id),"Order.id is required"),Ne(jt(i.createdAt),"Order.createdAt is required"),Ne(typeof i.total=="number","Order.total must be a number"),Ne(jt(i.currency),"Order.currency is required"),Ne(Array.isArray(i.items),"Order.items must be an array")}function Hi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function qn(...e){return t=>{let n=!1;const s=e.map(o=>{const a=Hi(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<s.length;o++){const a=s[o];typeof a=="function"?a():Hi(e[o],null)}}}}function Se(...e){return m.useCallback(qn(...e),e)}var nv=Symbol.for("react.lazy"),is=m[" use ".trim().toString()];function rv(e){return typeof e=="object"&&e!==null&&"then"in e}function Vl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===nv&&"_payload"in e&&rv(e._payload)}function Wl(e){const t=ov(e),n=m.forwardRef((s,o)=>{let{children:a,...i}=s;Vl(a)&&typeof is=="function"&&(a=is(a._payload));const c=m.Children.toArray(a),l=c.find(iv);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return r.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}var sv=Wl("Slot");function ov(e){const t=m.forwardRef((n,s)=>{let{children:o,...a}=n;if(Vl(o)&&typeof is=="function"&&(o=is(o._payload)),m.isValidElement(o)){const i=lv(o),c=cv(a,o.props);return o.type!==m.Fragment&&(c.ref=s?qn(s,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var av=Symbol("radix.slottable");function iv(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===av}function cv(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function lv(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ql(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=ql(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function Hl(){for(var e,t,n=0,s="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=ql(e))&&(s&&(s+=" "),s+=t);return s}const Zi=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Gi=Hl,ga=(e,t)=>n=>{var s;if(t?.variants==null)return Gi(e,n?.class,n?.className);const{variants:o,defaultVariants:a}=t,i=Object.keys(o).map(d=>{const f=n?.[d],u=a?.[d];if(f===null)return null;const g=Zi(f)||Zi(u);return o[d][g]}),c=n&&Object.entries(n).reduce((d,f)=>{let[u,g]=f;return g===void 0||(d[u]=g),d},{}),l=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((d,f)=>{let{class:u,className:g,...p}=f;return Object.entries(p).every(x=>{let[h,v]=x;return Array.isArray(v)?v.includes({...a,...c}[h]):{...a,...c}[h]===v})?[...d,u,g]:d},[]);return Gi(e,i,l,n?.class,n?.className)},dv=(e,t)=>{const n=new Array(e.length+t.length);for(let s=0;s<e.length;s++)n[s]=e[s];for(let s=0;s<t.length;s++)n[e.length+s]=t[s];return n},uv=(e,t)=>({classGroupId:e,validator:t}),Zl=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),cs="-",Yi=[],fv="arbitrary..",mv=e=>{const t=hv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return pv(i);const c=i.split(cs),l=c[0]===""&&c.length>1?1:0;return Gl(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=s[i],d=n[i];return l?d?dv(d,l):l:d||Yi}return n[i]||Yi}}},Gl=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],a=n.nextPart.get(o);if(a){const d=Gl(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const c=t===0?e.join(cs):e.slice(t).join(cs),l=i.length;for(let d=0;d<l;d++){const f=i[d];if(f.validator(c))return f.classGroupId}},pv=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),s=t.slice(0,n);return s?fv+s:void 0})(),hv=e=>{const{theme:t,classGroups:n}=e;return gv(n,t)},gv=(e,t)=>{const n=Zl();for(const s in e){const o=e[s];xa(o,n,s,t)}return n},xa=(e,t,n,s)=>{const o=e.length;for(let a=0;a<o;a++){const i=e[a];xv(i,t,n,s)}},xv=(e,t,n,s)=>{if(typeof e=="string"){vv(e,t,n);return}if(typeof e=="function"){yv(e,t,n,s);return}bv(e,t,n,s)},vv=(e,t,n)=>{const s=e===""?t:Yl(t,e);s.classGroupId=n},yv=(e,t,n,s)=>{if(wv(e)){xa(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(uv(n,e))},bv=(e,t,n,s)=>{const o=Object.entries(e),a=o.length;for(let i=0;i<a;i++){const[c,l]=o[i];xa(l,Yl(t,c),n,s)}},Yl=(e,t)=>{let n=e;const s=t.split(cs),o=s.length;for(let a=0;a<o;a++){const i=s[a];let c=n.nextPart.get(i);c||(c=Zl(),n.nextPart.set(i,c)),n=c}return n},wv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,kv=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),s=Object.create(null);const o=(a,i)=>{n[a]=i,t++,t>e&&(t=0,s=n,n=Object.create(null))};return{get(a){let i=n[a];if(i!==void 0)return i;if((i=s[a])!==void 0)return o(a,i),i},set(a,i){a in n?n[a]=i:o(a,i)}}},Lo="!",Qi=":",_v=[],Ki=(e,t,n,s,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:o}),jv=e=>{const{prefix:t,experimentalParseClassName:n}=e;let s=o=>{const a=[];let i=0,c=0,l=0,d;const f=o.length;for(let h=0;h<f;h++){const v=o[h];if(i===0&&c===0){if(v===Qi){a.push(o.slice(l,h)),l=h+1;continue}if(v==="/"){d=h;continue}}v==="["?i++:v==="]"?i--:v==="("?c++:v===")"&&c--}const u=a.length===0?o:o.slice(l);let g=u,p=!1;u.endsWith(Lo)?(g=u.slice(0,-1),p=!0):u.startsWith(Lo)&&(g=u.slice(1),p=!0);const x=d&&d>l?d-l:void 0;return Ki(a,p,g,x)};if(t){const o=t+Qi,a=s;s=i=>i.startsWith(o)?a(i.slice(o.length)):Ki(_v,!1,i,void 0,!0)}if(n){const o=s;s=a=>n({className:a,parseClassName:o})}return s},Sv=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,s)=>{t.set(n,1e6+s)}),n=>{const s=[];let o=[];for(let a=0;a<n.length;a++){const i=n[a],c=i[0]==="[",l=t.has(i);c||l?(o.length>0&&(o.sort(),s.push(...o),o=[]),s.push(i)):o.push(i)}return o.length>0&&(o.sort(),s.push(...o)),s}},Cv=e=>({cache:kv(e.cacheSize),parseClassName:jv(e),sortModifiers:Sv(e),...mv(e)}),Nv=/\s+/,Av=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],c=e.trim().split(Nv);let l="";for(let d=c.length-1;d>=0;d-=1){const f=c[d],{isExternal:u,modifiers:g,hasImportantModifier:p,baseClassName:x,maybePostfixModifierPosition:h}=n(f);if(u){l=f+(l.length>0?" "+l:l);continue}let v=!!h,y=s(v?x.substring(0,h):x);if(!y){if(!v){l=f+(l.length>0?" "+l:l);continue}if(y=s(x),!y){l=f+(l.length>0?" "+l:l);continue}v=!1}const k=g.length===0?"":g.length===1?g[0]:a(g).join(":"),_=p?k+Lo:k,b=_+y;if(i.indexOf(b)>-1)continue;i.push(b);const j=o(y,v);for(let N=0;N<j.length;++N){const T=j[N];i.push(_+T)}l=f+(l.length>0?" "+l:l)}return l},Ev=(...e)=>{let t=0,n,s,o="";for(;t<e.length;)(n=e[t++])&&(s=Ql(n))&&(o&&(o+=" "),o+=s);return o},Ql=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=Ql(e[s]))&&(n&&(n+=" "),n+=t);return n},Iv=(e,...t)=>{let n,s,o,a;const i=l=>{const d=t.reduce((f,u)=>u(f),e());return n=Cv(d),s=n.cache.get,o=n.cache.set,a=c,c(l)},c=l=>{const d=s(l);if(d)return d;const f=Av(l,n);return o(l,f),f};return a=i,(...l)=>a(Ev(...l))},Tv=[],Be=e=>{const t=n=>n[e]||Tv;return t.isThemeGetter=!0,t},Kl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jl=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Pv=/^\d+\/\d+$/,Rv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ov=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Mv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Lv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Dv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Pn=e=>Pv.test(e),me=e=>!!e&&!Number.isNaN(Number(e)),Jt=e=>!!e&&Number.isInteger(Number(e)),co=e=>e.endsWith("%")&&me(e.slice(0,-1)),Zt=e=>Rv.test(e),$v=()=>!0,zv=e=>Ov.test(e)&&!Mv.test(e),Xl=()=>!1,Fv=e=>Lv.test(e),Bv=e=>Dv.test(e),Uv=e=>!te(e)&&!ne(e),Vv=e=>Hn(e,nd,Xl),te=e=>Kl.test(e),pn=e=>Hn(e,rd,zv),lo=e=>Hn(e,Gv,me),Ji=e=>Hn(e,ed,Xl),Wv=e=>Hn(e,td,Bv),Lr=e=>Hn(e,sd,Fv),ne=e=>Jl.test(e),nr=e=>Zn(e,rd),qv=e=>Zn(e,Yv),Xi=e=>Zn(e,ed),Hv=e=>Zn(e,nd),Zv=e=>Zn(e,td),Dr=e=>Zn(e,sd,!0),Hn=(e,t,n)=>{const s=Kl.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},Zn=(e,t,n=!1)=>{const s=Jl.exec(e);return s?s[1]?t(s[1]):n:!1},ed=e=>e==="position"||e==="percentage",td=e=>e==="image"||e==="url",nd=e=>e==="length"||e==="size"||e==="bg-size",rd=e=>e==="length",Gv=e=>e==="number",Yv=e=>e==="family-name",sd=e=>e==="shadow",Qv=()=>{const e=Be("color"),t=Be("font"),n=Be("text"),s=Be("font-weight"),o=Be("tracking"),a=Be("leading"),i=Be("breakpoint"),c=Be("container"),l=Be("spacing"),d=Be("radius"),f=Be("shadow"),u=Be("inset-shadow"),g=Be("text-shadow"),p=Be("drop-shadow"),x=Be("blur"),h=Be("perspective"),v=Be("aspect"),y=Be("ease"),k=Be("animate"),_=()=>["auto","avoid","all","avoid-page","page","left","right","column"],b=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...b(),ne,te],N=()=>["auto","hidden","clip","visible","scroll"],T=()=>["auto","contain","none"],A=()=>[ne,te,l],E=()=>[Pn,"full","auto",...A()],P=()=>[Jt,"none","subgrid",ne,te],F=()=>["auto",{span:["full",Jt,ne,te]},Jt,ne,te],L=()=>[Jt,"auto",ne,te],U=()=>["auto","min","max","fr",ne,te],$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...A()],H=()=>[Pn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...A()],D=()=>[e,ne,te],C=()=>[...b(),Xi,Ji,{position:[ne,te]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],Z=()=>["auto","cover","contain",Hv,Vv,{size:[ne,te]}],ve=()=>[co,nr,pn],V=()=>["","none","full",d,ne,te],Q=()=>["",me,nr,pn],K=()=>["solid","dashed","dotted","double"],le=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],R=()=>[me,co,Xi,Ji],G=()=>["","none",x,ne,te],ue=()=>["none",me,ne,te],W=()=>["none",me,ne,te],se=()=>[me,ne,te],ie=()=>[Pn,"full",...A()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Zt],breakpoint:[Zt],color:[$v],container:[Zt],"drop-shadow":[Zt],ease:["in","out","in-out"],font:[Uv],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Zt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Zt],shadow:[Zt],spacing:["px",me],text:[Zt],"text-shadow":[Zt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Pn,te,ne,v]}],container:["container"],columns:[{columns:[me,te,ne,c]}],"break-after":[{"break-after":_()}],"break-before":[{"break-before":_()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:E()}],"inset-x":[{"inset-x":E()}],"inset-y":[{"inset-y":E()}],start:[{start:E()}],end:[{end:E()}],top:[{top:E()}],right:[{right:E()}],bottom:[{bottom:E()}],left:[{left:E()}],visibility:["visible","invisible","collapse"],z:[{z:[Jt,"auto",ne,te]}],basis:[{basis:[Pn,"full","auto",c,...A()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[me,Pn,"auto","initial","none",te]}],grow:[{grow:["",me,ne,te]}],shrink:[{shrink:["",me,ne,te]}],order:[{order:[Jt,"first","last","none",ne,te]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:F()}],"col-start":[{"col-start":L()}],"col-end":[{"col-end":L()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:F()}],"row-start":[{"row-start":L()}],"row-end":[{"row-end":L()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":U()}],"auto-rows":[{"auto-rows":U()}],gap:[{gap:A()}],"gap-x":[{"gap-x":A()}],"gap-y":[{"gap-y":A()}],"justify-content":[{justify:[...$(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...$()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":$()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:A()}],px:[{px:A()}],py:[{py:A()}],ps:[{ps:A()}],pe:[{pe:A()}],pt:[{pt:A()}],pr:[{pr:A()}],pb:[{pb:A()}],pl:[{pl:A()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":A()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":A()}],"space-y-reverse":["space-y-reverse"],size:[{size:H()}],w:[{w:[c,"screen",...H()]}],"min-w":[{"min-w":[c,"screen","none",...H()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...H()]}],h:[{h:["screen","lh",...H()]}],"min-h":[{"min-h":["screen","lh","none",...H()]}],"max-h":[{"max-h":["screen","lh",...H()]}],"font-size":[{text:["base",n,nr,pn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,ne,lo]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",co,te]}],"font-family":[{font:[qv,te,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,ne,te]}],"line-clamp":[{"line-clamp":[me,"none",ne,lo]}],leading:[{leading:[a,...A()]}],"list-image":[{"list-image":["none",ne,te]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ne,te]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:D()}],"text-color":[{text:D()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:[me,"from-font","auto",ne,pn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[me,"auto",ne,te]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ne,te]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ne,te]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:C()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:Z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Jt,ne,te],radial:["",ne,te],conic:[Jt,ne,te]},Zv,Wv]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:ve()}],"gradient-via-pos":[{via:ve()}],"gradient-to-pos":[{to:ve()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:Q()}],"border-w-x":[{"border-x":Q()}],"border-w-y":[{"border-y":Q()}],"border-w-s":[{"border-s":Q()}],"border-w-e":[{"border-e":Q()}],"border-w-t":[{"border-t":Q()}],"border-w-r":[{"border-r":Q()}],"border-w-b":[{"border-b":Q()}],"border-w-l":[{"border-l":Q()}],"divide-x":[{"divide-x":Q()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Q()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...K(),"hidden","none"]}],"divide-style":[{divide:[...K(),"hidden","none"]}],"border-color":[{border:D()}],"border-color-x":[{"border-x":D()}],"border-color-y":[{"border-y":D()}],"border-color-s":[{"border-s":D()}],"border-color-e":[{"border-e":D()}],"border-color-t":[{"border-t":D()}],"border-color-r":[{"border-r":D()}],"border-color-b":[{"border-b":D()}],"border-color-l":[{"border-l":D()}],"divide-color":[{divide:D()}],"outline-style":[{outline:[...K(),"none","hidden"]}],"outline-offset":[{"outline-offset":[me,ne,te]}],"outline-w":[{outline:["",me,nr,pn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Dr,Lr]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",u,Dr,Lr]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[me,pn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",g,Dr,Lr]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[me,ne,te]}],"mix-blend":[{"mix-blend":[...le(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":le()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[me]}],"mask-image-linear-from-pos":[{"mask-linear-from":R()}],"mask-image-linear-to-pos":[{"mask-linear-to":R()}],"mask-image-linear-from-color":[{"mask-linear-from":D()}],"mask-image-linear-to-color":[{"mask-linear-to":D()}],"mask-image-t-from-pos":[{"mask-t-from":R()}],"mask-image-t-to-pos":[{"mask-t-to":R()}],"mask-image-t-from-color":[{"mask-t-from":D()}],"mask-image-t-to-color":[{"mask-t-to":D()}],"mask-image-r-from-pos":[{"mask-r-from":R()}],"mask-image-r-to-pos":[{"mask-r-to":R()}],"mask-image-r-from-color":[{"mask-r-from":D()}],"mask-image-r-to-color":[{"mask-r-to":D()}],"mask-image-b-from-pos":[{"mask-b-from":R()}],"mask-image-b-to-pos":[{"mask-b-to":R()}],"mask-image-b-from-color":[{"mask-b-from":D()}],"mask-image-b-to-color":[{"mask-b-to":D()}],"mask-image-l-from-pos":[{"mask-l-from":R()}],"mask-image-l-to-pos":[{"mask-l-to":R()}],"mask-image-l-from-color":[{"mask-l-from":D()}],"mask-image-l-to-color":[{"mask-l-to":D()}],"mask-image-x-from-pos":[{"mask-x-from":R()}],"mask-image-x-to-pos":[{"mask-x-to":R()}],"mask-image-x-from-color":[{"mask-x-from":D()}],"mask-image-x-to-color":[{"mask-x-to":D()}],"mask-image-y-from-pos":[{"mask-y-from":R()}],"mask-image-y-to-pos":[{"mask-y-to":R()}],"mask-image-y-from-color":[{"mask-y-from":D()}],"mask-image-y-to-color":[{"mask-y-to":D()}],"mask-image-radial":[{"mask-radial":[ne,te]}],"mask-image-radial-from-pos":[{"mask-radial-from":R()}],"mask-image-radial-to-pos":[{"mask-radial-to":R()}],"mask-image-radial-from-color":[{"mask-radial-from":D()}],"mask-image-radial-to-color":[{"mask-radial-to":D()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[me]}],"mask-image-conic-from-pos":[{"mask-conic-from":R()}],"mask-image-conic-to-pos":[{"mask-conic-to":R()}],"mask-image-conic-from-color":[{"mask-conic-from":D()}],"mask-image-conic-to-color":[{"mask-conic-to":D()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:C()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:Z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ne,te]}],filter:[{filter:["","none",ne,te]}],blur:[{blur:G()}],brightness:[{brightness:[me,ne,te]}],contrast:[{contrast:[me,ne,te]}],"drop-shadow":[{"drop-shadow":["","none",p,Dr,Lr]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",me,ne,te]}],"hue-rotate":[{"hue-rotate":[me,ne,te]}],invert:[{invert:["",me,ne,te]}],saturate:[{saturate:[me,ne,te]}],sepia:[{sepia:["",me,ne,te]}],"backdrop-filter":[{"backdrop-filter":["","none",ne,te]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[me,ne,te]}],"backdrop-contrast":[{"backdrop-contrast":[me,ne,te]}],"backdrop-grayscale":[{"backdrop-grayscale":["",me,ne,te]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[me,ne,te]}],"backdrop-invert":[{"backdrop-invert":["",me,ne,te]}],"backdrop-opacity":[{"backdrop-opacity":[me,ne,te]}],"backdrop-saturate":[{"backdrop-saturate":[me,ne,te]}],"backdrop-sepia":[{"backdrop-sepia":["",me,ne,te]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":A()}],"border-spacing-x":[{"border-spacing-x":A()}],"border-spacing-y":[{"border-spacing-y":A()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ne,te]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[me,"initial",ne,te]}],ease:[{ease:["linear","initial",y,ne,te]}],delay:[{delay:[me,ne,te]}],animate:[{animate:["none",k,ne,te]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[h,ne,te]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:W()}],"scale-x":[{"scale-x":W()}],"scale-y":[{"scale-y":W()}],"scale-z":[{"scale-z":W()}],"scale-3d":["scale-3d"],skew:[{skew:se()}],"skew-x":[{"skew-x":se()}],"skew-y":[{"skew-y":se()}],transform:[{transform:[ne,te,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],accent:[{accent:D()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:D()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ne,te]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ne,te]}],fill:[{fill:["none",...D()]}],"stroke-w":[{stroke:[me,nr,pn,lo]}],stroke:[{stroke:["none",...D()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Kv=Iv(Qv);function O(...e){return Kv(Hl(e))}const Jv=ga("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:pointer-events-none disabled:opacity-50 dark:focus-visible:ring-neutral-50/20",{variants:{variant:{default:"bg-neutral-900 text-neutral-50 hover:bg-neutral-900/90 dark:bg-neutral-50 dark:text-neutral-900 dark:hover:bg-neutral-50/90",secondary:"bg-neutral-100 text-neutral-900 hover:bg-neutral-100/80 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800/80",outline:"border border-neutral-200 bg-transparent text-neutral-900 hover:bg-neutral-100 dark:border-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-800",ghost:"bg-transparent text-neutral-900 hover:bg-neutral-100 dark:text-neutral-50 dark:hover:bg-neutral-800",destructive:"bg-red-600 text-neutral-50 hover:bg-red-600/90 dark:bg-red-500 dark:hover:bg-red-500/90",link:"bg-transparent text-neutral-900 underline-offset-4 hover:underline dark:text-neutral-50"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-6",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),X=m.forwardRef(({className:e,variant:t,size:n,asChild:s,...o},a)=>{const i=s?sv:"button";return r.jsx(i,{className:O(Jv({variant:t,size:n}),e),ref:a,...o})});X.displayName="Button";const Xv=ga("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors",{variants:{variant:{default:"border-transparent bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900",secondary:"border-transparent bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",outline:"border-neutral-200 text-neutral-900 dark:border-neutral-800 dark:text-neutral-50"}},defaultVariants:{variant:"secondary"}});function ht({className:e,variant:t,...n}){return r.jsx("div",{className:O(Xv({variant:t}),e),...n})}const Xe=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("rounded-xl border border-neutral-200 bg-white text-neutral-950 shadow-sm dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",e),...t}));Xe.displayName="Card";const gr=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("flex flex-col space-y-1.5 p-6",e),...t}));gr.displayName="CardHeader";const xr=m.forwardRef(({className:e,...t},n)=>r.jsx("h3",{ref:n,className:O("text-lg font-semibold leading-none tracking-tight",e),...t}));xr.displayName="CardTitle";const od=m.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:O("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));od.displayName="CardDescription";const rt=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("p-6 pt-0",e),...t}));rt.displayName="CardContent";const ad=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:O("flex items-center p-6 pt-0",e),...t}));ad.displayName="CardFooter";const Te=m.forwardRef(({className:e,...t},n)=>r.jsx("input",{ref:n,className:O("flex h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-neutral-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400 dark:focus-visible:ring-neutral-50/20",e),...t}));Te.displayName="Input";const He=m.forwardRef(({className:e,...t},n)=>r.jsx("label",{ref:n,className:O("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));He.displayName="Label";var ey=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ty=ey.reduce((e,t)=>{const n=Wl(`Primitive.${t}`),s=m.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(l,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),ny="Separator",ec="horizontal",ry=["horizontal","vertical"],id=m.forwardRef((e,t)=>{const{decorative:n,orientation:s=ec,...o}=e,a=sy(s)?s:ec,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return r.jsx(ty.div,{"data-orientation":a,...c,...o,ref:t})});id.displayName=ny;function sy(e){return ry.includes(e)}var cd=id;const lt=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...s},o)=>r.jsx(cd,{ref:o,decorative:n,orientation:t,className:O("shrink-0 bg-neutral-200 dark:bg-neutral-800",t==="horizontal"?"h-px w-full":"h-full w-px",e),...s}));lt.displayName=cd.displayName;function Oe({className:e,...t}){return r.jsx("div",{className:O("animate-pulse rounded-md bg-neutral-100 dark:bg-neutral-800",e),...t})}function tc(e,[t,n]){return Math.min(n,Math.max(t,e))}function xe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function oy(e,t){const n=m.createContext(t),s=a=>{const{children:i,...c}=a,l=m.useMemo(()=>c,Object.values(c));return r.jsx(n.Provider,{value:l,children:i})};s.displayName=e+"Provider";function o(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[s,o]}function an(e,t=[]){let n=[];function s(a,i){const c=m.createContext(i),l=n.length;n=[...n,i];const d=u=>{const{scope:g,children:p,...x}=u,h=g?.[e]?.[l]||c,v=m.useMemo(()=>x,Object.values(x));return r.jsx(h.Provider,{value:v,children:p})};d.displayName=a+"Provider";function f(u,g){const p=g?.[e]?.[l]||c,x=m.useContext(p);if(x)return x;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[d,f]}const o=()=>{const a=n.map(i=>m.createContext(i));return function(c){const l=c?.[e]||a;return m.useMemo(()=>({[`__scope${e}`]:{...c,[e]:l}}),[c,l])}};return o.scopeName=e,[s,ay(o,...t)]}function ay(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=s.reduce((c,{useScope:l,scopeName:d})=>{const u=l(a)[`__scope${d}`];return{...c,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function nc(e){const t=iy(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(ly);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return r.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function iy(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=uy(o),c=dy(a,o.props);return o.type!==m.Fragment&&(c.ref=s?qn(s,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var cy=Symbol("radix.slottable");function ly(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===cy}function dy(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function uy(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function va(e){const t=e+"CollectionProvider",[n,s]=an(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=h=>{const{scope:v,children:y}=h,k=w.useRef(null),_=w.useRef(new Map).current;return r.jsx(o,{scope:v,itemMap:_,collectionRef:k,children:y})};i.displayName=t;const c=e+"CollectionSlot",l=nc(c),d=w.forwardRef((h,v)=>{const{scope:y,children:k}=h,_=a(c,y),b=Se(v,_.collectionRef);return r.jsx(l,{ref:b,children:k})});d.displayName=c;const f=e+"CollectionItemSlot",u="data-radix-collection-item",g=nc(f),p=w.forwardRef((h,v)=>{const{scope:y,children:k,..._}=h,b=w.useRef(null),j=Se(v,b),N=a(f,y);return w.useEffect(()=>(N.itemMap.set(b,{ref:b,..._}),()=>void N.itemMap.delete(b))),r.jsx(g,{[u]:"",ref:j,children:k})});p.displayName=f;function x(h){const v=a(e+"CollectionConsumer",h);return w.useCallback(()=>{const k=v.collectionRef.current;if(!k)return[];const _=Array.from(k.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((N,T)=>_.indexOf(N.ref.current)-_.indexOf(T.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:d,ItemSlot:p},x,s]}var fy=m.createContext(void 0);function Ss(e){const t=m.useContext(fy);return e||t||"ltr"}function my(e){const t=py(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(gy);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return r.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function py(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=vy(o),c=xy(a,o.props);return o.type!==m.Fragment&&(c.ref=s?qn(s,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var hy=Symbol("radix.slottable");function gy(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hy}function xy(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function vy(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yy=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],he=yy.reduce((e,t)=>{const n=my(`Primitive.${t}`),s=m.forwardRef((o,a)=>{const{asChild:i,...c}=o,l=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(l,{...c,ref:a})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function by(e,t){e&&bs.flushSync(()=>e.dispatchEvent(t))}function en(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function wy(e,t=globalThis?.document){const n=en(e);m.useEffect(()=>{const s=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var ky="DismissableLayer",Do="dismissableLayer.update",_y="dismissableLayer.pointerDownOutside",jy="dismissableLayer.focusOutside",rc,ld=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ya=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...l}=e,d=m.useContext(ld),[f,u]=m.useState(null),g=f?.ownerDocument??globalThis?.document,[,p]=m.useState({}),x=Se(t,T=>u(T)),h=Array.from(d.layers),[v]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(v),k=f?h.indexOf(f):-1,_=d.layersWithOutsidePointerEventsDisabled.size>0,b=k>=y,j=Ny(T=>{const A=T.target,E=[...d.branches].some(P=>P.contains(A));!b||E||(o?.(T),i?.(T),T.defaultPrevented||c?.())},g),N=Ay(T=>{const A=T.target;[...d.branches].some(P=>P.contains(A))||(a?.(T),i?.(T),T.defaultPrevented||c?.())},g);return wy(T=>{k===d.layers.size-1&&(s?.(T),!T.defaultPrevented&&c&&(T.preventDefault(),c()))},g),m.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(rc=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),sc(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=rc)}},[f,g,n,d]),m.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),sc())},[f,d]),m.useEffect(()=>{const T=()=>p({});return document.addEventListener(Do,T),()=>document.removeEventListener(Do,T)},[]),r.jsx(he.div,{...l,ref:x,style:{pointerEvents:_?b?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,j.onPointerDownCapture)})});ya.displayName=ky;var Sy="DismissableLayerBranch",Cy=m.forwardRef((e,t)=>{const n=m.useContext(ld),s=m.useRef(null),o=Se(t,s);return m.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(he.div,{...e,ref:o})});Cy.displayName=Sy;function Ny(e,t=globalThis?.document){const n=en(e),s=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let l=function(){dd(_y,n,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=l,t.addEventListener("click",o.current,{once:!0})):l()}else t.removeEventListener("click",o.current);s.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function Ay(e,t=globalThis?.document){const n=en(e),s=m.useRef(!1);return m.useEffect(()=>{const o=a=>{a.target&&!s.current&&dd(jy,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function sc(){const e=new CustomEvent(Do);document.dispatchEvent(e)}function dd(e,t,n,{discrete:s}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),s?by(o,a):o.dispatchEvent(a)}var uo=0;function ud(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??oc()),document.body.insertAdjacentElement("beforeend",e[1]??oc()),uo++,()=>{uo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),uo--}},[])}function oc(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var fo="focusScope.autoFocusOnMount",mo="focusScope.autoFocusOnUnmount",ac={bubbles:!1,cancelable:!0},Ey="FocusScope",ba=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,l]=m.useState(null),d=en(o),f=en(a),u=m.useRef(null),g=Se(t,h=>l(h)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(s){let h=function(_){if(p.paused||!c)return;const b=_.target;c.contains(b)?u.current=b:Xt(u.current,{select:!0})},v=function(_){if(p.paused||!c)return;const b=_.relatedTarget;b!==null&&(c.contains(b)||Xt(u.current,{select:!0}))},y=function(_){if(document.activeElement===document.body)for(const j of _)j.removedNodes.length>0&&Xt(c)};document.addEventListener("focusin",h),document.addEventListener("focusout",v);const k=new MutationObserver(y);return c&&k.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",v),k.disconnect()}}},[s,c,p.paused]),m.useEffect(()=>{if(c){cc.add(p);const h=document.activeElement;if(!c.contains(h)){const y=new CustomEvent(fo,ac);c.addEventListener(fo,d),c.dispatchEvent(y),y.defaultPrevented||(Iy(My(fd(c)),{select:!0}),document.activeElement===h&&Xt(c))}return()=>{c.removeEventListener(fo,d),setTimeout(()=>{const y=new CustomEvent(mo,ac);c.addEventListener(mo,f),c.dispatchEvent(y),y.defaultPrevented||Xt(h??document.body,{select:!0}),c.removeEventListener(mo,f),cc.remove(p)},0)}}},[c,d,f,p]);const x=m.useCallback(h=>{if(!n&&!s||p.paused)return;const v=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(v&&y){const k=h.currentTarget,[_,b]=Ty(k);_&&b?!h.shiftKey&&y===b?(h.preventDefault(),n&&Xt(_,{select:!0})):h.shiftKey&&y===_&&(h.preventDefault(),n&&Xt(b,{select:!0})):y===k&&h.preventDefault()}},[n,s,p.paused]);return r.jsx(he.div,{tabIndex:-1,...i,ref:g,onKeyDown:x})});ba.displayName=Ey;function Iy(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Xt(s,{select:t}),document.activeElement!==n)return}function Ty(e){const t=fd(e),n=ic(t,e),s=ic(t.reverse(),e);return[n,s]}function fd(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ic(e,t){for(const n of e)if(!Py(n,{upTo:t}))return n}function Py(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ry(e){return e instanceof HTMLInputElement&&"select"in e}function Xt(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ry(e)&&t&&e.select()}}var cc=Oy();function Oy(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=lc(e,t),e.unshift(t)},remove(t){e=lc(e,t),e[0]?.resume()}}}function lc(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function My(e){return e.filter(t=>t.tagName!=="A")}var Ye=globalThis?.document?m.useLayoutEffect:()=>{},Ly=m[" useId ".trim().toString()]||(()=>{}),Dy=0;function Dt(e){const[t,n]=m.useState(Ly());return Ye(()=>{n(s=>s??String(Dy++))},[e]),e||(t?`radix-${t}`:"")}const $y=["top","right","bottom","left"],tn=Math.min,pt=Math.max,ls=Math.round,$r=Math.floor,$t=e=>({x:e,y:e}),zy={left:"right",right:"left",bottom:"top",top:"bottom"},Fy={start:"end",end:"start"};function $o(e,t,n){return pt(e,tn(t,n))}function Yt(e,t){return typeof e=="function"?e(t):e}function Qt(e){return e.split("-")[0]}function Gn(e){return e.split("-")[1]}function wa(e){return e==="x"?"y":"x"}function ka(e){return e==="y"?"height":"width"}const By=new Set(["top","bottom"]);function Lt(e){return By.has(Qt(e))?"y":"x"}function _a(e){return wa(Lt(e))}function Uy(e,t,n){n===void 0&&(n=!1);const s=Gn(e),o=_a(e),a=ka(o);let i=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ds(i)),[i,ds(i)]}function Vy(e){const t=ds(e);return[zo(e),t,zo(t)]}function zo(e){return e.replace(/start|end/g,t=>Fy[t])}const dc=["left","right"],uc=["right","left"],Wy=["top","bottom"],qy=["bottom","top"];function Hy(e,t,n){switch(e){case"top":case"bottom":return n?t?uc:dc:t?dc:uc;case"left":case"right":return t?Wy:qy;default:return[]}}function Zy(e,t,n,s){const o=Gn(e);let a=Hy(Qt(e),n==="start",s);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(zo)))),a}function ds(e){return e.replace(/left|right|bottom|top/g,t=>zy[t])}function Gy(e){return{top:0,right:0,bottom:0,left:0,...e}}function md(e){return typeof e!="number"?Gy(e):{top:e,right:e,bottom:e,left:e}}function us(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function fc(e,t,n){let{reference:s,floating:o}=e;const a=Lt(t),i=_a(t),c=ka(i),l=Qt(t),d=a==="y",f=s.x+s.width/2-o.width/2,u=s.y+s.height/2-o.height/2,g=s[c]/2-o[c]/2;let p;switch(l){case"top":p={x:f,y:s.y-o.height};break;case"bottom":p={x:f,y:s.y+s.height};break;case"right":p={x:s.x+s.width,y:u};break;case"left":p={x:s.x-o.width,y:u};break;default:p={x:s.x,y:s.y}}switch(Gn(t)){case"start":p[i]-=g*(n&&d?-1:1);break;case"end":p[i]+=g*(n&&d?-1:1);break}return p}const Yy=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:u}=fc(d,s,l),g=s,p={},x=0;for(let h=0;h<c.length;h++){const{name:v,fn:y}=c[h],{x:k,y:_,data:b,reset:j}=await y({x:f,y:u,initialPlacement:s,placement:g,strategy:o,middlewareData:p,rects:d,platform:i,elements:{reference:e,floating:t}});f=k??f,u=_??u,p={...p,[v]:{...p[v],...b}},j&&x<=50&&(x++,typeof j=="object"&&(j.placement&&(g=j.placement),j.rects&&(d=j.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):j.rects),{x:f,y:u}=fc(d,g,l)),h=-1)}return{x:f,y:u,placement:g,strategy:o,middlewareData:p}};async function vr(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:i,elements:c,strategy:l}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:g=!1,padding:p=0}=Yt(t,e),x=md(p),v=c[g?u==="floating"?"reference":"floating":u],y=us(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:f,strategy:l})),k=u==="floating"?{x:s,y:o,width:i.floating.width,height:i.floating.height}:i.reference,_=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),b=await(a.isElement==null?void 0:a.isElement(_))?await(a.getScale==null?void 0:a.getScale(_))||{x:1,y:1}:{x:1,y:1},j=us(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:k,offsetParent:_,strategy:l}):k);return{top:(y.top-j.top+x.top)/b.y,bottom:(j.bottom-y.bottom+x.bottom)/b.y,left:(y.left-j.left+x.left)/b.x,right:(j.right-y.right+x.right)/b.x}}const Qy=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:i,elements:c,middlewareData:l}=t,{element:d,padding:f=0}=Yt(e,t)||{};if(d==null)return{};const u=md(f),g={x:n,y:s},p=_a(o),x=ka(p),h=await i.getDimensions(d),v=p==="y",y=v?"top":"left",k=v?"bottom":"right",_=v?"clientHeight":"clientWidth",b=a.reference[x]+a.reference[p]-g[p]-a.floating[x],j=g[p]-a.reference[p],N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let T=N?N[_]:0;(!T||!await(i.isElement==null?void 0:i.isElement(N)))&&(T=c.floating[_]||a.floating[x]);const A=b/2-j/2,E=T/2-h[x]/2-1,P=tn(u[y],E),F=tn(u[k],E),L=P,U=T-h[x]-F,$=T/2-h[x]/2+A,Y=$o(L,$,U),B=!l.arrow&&Gn(o)!=null&&$!==Y&&a.reference[x]/2-($<L?P:F)-h[x]/2<0,H=B?$<L?$-L:$-U:0;return{[p]:g[p]+H,data:{[p]:Y,centerOffset:$-Y-H,...B&&{alignmentOffset:H}},reset:B}}}),Ky=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:l,elements:d}=t,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:g,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:h=!0,...v}=Yt(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=Qt(o),k=Lt(c),_=Qt(c)===c,b=await(l.isRTL==null?void 0:l.isRTL(d.floating)),j=g||(_||!h?[ds(c)]:Vy(c)),N=x!=="none";!g&&N&&j.push(...Zy(c,h,x,b));const T=[c,...j],A=await vr(t,v),E=[];let P=((s=a.flip)==null?void 0:s.overflows)||[];if(f&&E.push(A[y]),u){const $=Uy(o,i,b);E.push(A[$[0]],A[$[1]])}if(P=[...P,{placement:o,overflows:E}],!E.every($=>$<=0)){var F,L;const $=(((F=a.flip)==null?void 0:F.index)||0)+1,Y=T[$];if(Y&&(!(u==="alignment"?k!==Lt(Y):!1)||P.every(D=>Lt(D.placement)===k?D.overflows[0]>0:!0)))return{data:{index:$,overflows:P},reset:{placement:Y}};let B=(L=P.filter(H=>H.overflows[0]<=0).sort((H,D)=>H.overflows[1]-D.overflows[1])[0])==null?void 0:L.placement;if(!B)switch(p){case"bestFit":{var U;const H=(U=P.filter(D=>{if(N){const C=Lt(D.placement);return C===k||C==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(C=>C>0).reduce((C,I)=>C+I,0)]).sort((D,C)=>D[1]-C[1])[0])==null?void 0:U[0];H&&(B=H);break}case"initialPlacement":B=c;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function mc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pc(e){return $y.some(t=>e[t]>=0)}const Jy=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...o}=Yt(e,t);switch(s){case"referenceHidden":{const a=await vr(t,{...o,elementContext:"reference"}),i=mc(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pc(i)}}}case"escaped":{const a=await vr(t,{...o,altBoundary:!0}),i=mc(a,n.floating);return{data:{escapedOffsets:i,escaped:pc(i)}}}default:return{}}}}},pd=new Set(["left","top"]);async function Xy(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),i=Qt(n),c=Gn(n),l=Lt(n)==="y",d=pd.has(i)?-1:1,f=a&&l?-1:1,u=Yt(t,e);let{mainAxis:g,crossAxis:p,alignmentAxis:x}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof x=="number"&&(p=c==="end"?x*-1:x),l?{x:p*f,y:g*d}:{x:g*d,y:p*f}}const eb=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:i,middlewareData:c}=t,l=await Xy(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+l.x,y:a+l.y,data:{...l,placement:i}}}}},tb=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:y,y:k}=v;return{x:y,y:k}}},...l}=Yt(e,t),d={x:n,y:s},f=await vr(t,l),u=Lt(Qt(o)),g=wa(u);let p=d[g],x=d[u];if(a){const v=g==="y"?"top":"left",y=g==="y"?"bottom":"right",k=p+f[v],_=p-f[y];p=$o(k,p,_)}if(i){const v=u==="y"?"top":"left",y=u==="y"?"bottom":"right",k=x+f[v],_=x-f[y];x=$o(k,x,_)}const h=c.fn({...t,[g]:p,[u]:x});return{...h,data:{x:h.x-n,y:h.y-s,enabled:{[g]:a,[u]:i}}}}}},nb=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:o,rects:a,middlewareData:i}=t,{offset:c=0,mainAxis:l=!0,crossAxis:d=!0}=Yt(e,t),f={x:n,y:s},u=Lt(o),g=wa(u);let p=f[g],x=f[u];const h=Yt(c,t),v=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const _=g==="y"?"height":"width",b=a.reference[g]-a.floating[_]+v.mainAxis,j=a.reference[g]+a.reference[_]-v.mainAxis;p<b?p=b:p>j&&(p=j)}if(d){var y,k;const _=g==="y"?"width":"height",b=pd.has(Qt(o)),j=a.reference[u]-a.floating[_]+(b&&((y=i.offset)==null?void 0:y[u])||0)+(b?0:v.crossAxis),N=a.reference[u]+a.reference[_]+(b?0:((k=i.offset)==null?void 0:k[u])||0)-(b?v.crossAxis:0);x<j?x=j:x>N&&(x=N)}return{[g]:p,[u]:x}}}},rb=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:o,rects:a,platform:i,elements:c}=t,{apply:l=()=>{},...d}=Yt(e,t),f=await vr(t,d),u=Qt(o),g=Gn(o),p=Lt(o)==="y",{width:x,height:h}=a.floating;let v,y;u==="top"||u==="bottom"?(v=u,y=g===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(y=u,v=g==="end"?"top":"bottom");const k=h-f.top-f.bottom,_=x-f.left-f.right,b=tn(h-f[v],k),j=tn(x-f[y],_),N=!t.middlewareData.shift;let T=b,A=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=_),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(T=k),N&&!g){const P=pt(f.left,0),F=pt(f.right,0),L=pt(f.top,0),U=pt(f.bottom,0);p?A=x-2*(P!==0||F!==0?P+F:pt(f.left,f.right)):T=h-2*(L!==0||U!==0?L+U:pt(f.top,f.bottom))}await l({...t,availableWidth:A,availableHeight:T});const E=await i.getDimensions(c.floating);return x!==E.width||h!==E.height?{reset:{rects:!0}}:{}}}};function Cs(){return typeof window<"u"}function Yn(e){return hd(e)?(e.nodeName||"").toLowerCase():"#document"}function gt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Bt(e){var t;return(t=(hd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function hd(e){return Cs()?e instanceof Node||e instanceof gt(e).Node:!1}function Nt(e){return Cs()?e instanceof Element||e instanceof gt(e).Element:!1}function Ft(e){return Cs()?e instanceof HTMLElement||e instanceof gt(e).HTMLElement:!1}function hc(e){return!Cs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof gt(e).ShadowRoot}const sb=new Set(["inline","contents"]);function Ar(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=At(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!sb.has(o)}const ob=new Set(["table","td","th"]);function ab(e){return ob.has(Yn(e))}const ib=[":popover-open",":modal"];function Ns(e){return ib.some(t=>{try{return e.matches(t)}catch{return!1}})}const cb=["transform","translate","scale","rotate","perspective"],lb=["transform","translate","scale","rotate","perspective","filter"],db=["paint","layout","strict","content"];function ja(e){const t=Sa(),n=Nt(e)?At(e):e;return cb.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||lb.some(s=>(n.willChange||"").includes(s))||db.some(s=>(n.contain||"").includes(s))}function ub(e){let t=nn(e);for(;Ft(t)&&!Bn(t);){if(ja(t))return t;if(Ns(t))return null;t=nn(t)}return null}function Sa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const fb=new Set(["html","body","#document"]);function Bn(e){return fb.has(Yn(e))}function At(e){return gt(e).getComputedStyle(e)}function As(e){return Nt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function nn(e){if(Yn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||hc(e)&&e.host||Bt(e);return hc(t)?t.host:t}function gd(e){const t=nn(e);return Bn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ft(t)&&Ar(t)?t:gd(t)}function yr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=gd(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),i=gt(o);if(a){const c=Fo(i);return t.concat(i,i.visualViewport||[],Ar(o)?o:[],c&&n?yr(c):[])}return t.concat(o,yr(o,[],n))}function Fo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xd(e){const t=At(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Ft(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:s,c=ls(n)!==a||ls(s)!==i;return c&&(n=a,s=i),{width:n,height:s,$:c}}function Ca(e){return Nt(e)?e:e.contextElement}function $n(e){const t=Ca(e);if(!Ft(t))return $t(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=xd(t);let i=(a?ls(n.width):n.width)/s,c=(a?ls(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const mb=$t(0);function vd(e){const t=gt(e);return!Sa()||!t.visualViewport?mb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==gt(e)?!1:t}function xn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=Ca(e);let i=$t(1);t&&(s?Nt(s)&&(i=$n(s)):i=$n(e));const c=pb(a,n,s)?vd(a):$t(0);let l=(o.left+c.x)/i.x,d=(o.top+c.y)/i.y,f=o.width/i.x,u=o.height/i.y;if(a){const g=gt(a),p=s&&Nt(s)?gt(s):s;let x=g,h=Fo(x);for(;h&&s&&p!==x;){const v=$n(h),y=h.getBoundingClientRect(),k=At(h),_=y.left+(h.clientLeft+parseFloat(k.paddingLeft))*v.x,b=y.top+(h.clientTop+parseFloat(k.paddingTop))*v.y;l*=v.x,d*=v.y,f*=v.x,u*=v.y,l+=_,d+=b,x=gt(h),h=Fo(x)}}return us({width:f,height:u,x:l,y:d})}function Es(e,t){const n=As(e).scrollLeft;return t?t.left+n:xn(Bt(e)).left+n}function yd(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Es(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function hb(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",i=Bt(s),c=t?Ns(t.floating):!1;if(s===i||c&&a)return n;let l={scrollLeft:0,scrollTop:0},d=$t(1);const f=$t(0),u=Ft(s);if((u||!u&&!a)&&((Yn(s)!=="body"||Ar(i))&&(l=As(s)),Ft(s))){const p=xn(s);d=$n(s),f.x=p.x+s.clientLeft,f.y=p.y+s.clientTop}const g=i&&!u&&!a?yd(i,l):$t(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-l.scrollLeft*d.x+f.x+g.x,y:n.y*d.y-l.scrollTop*d.y+f.y+g.y}}function gb(e){return Array.from(e.getClientRects())}function xb(e){const t=Bt(e),n=As(e),s=e.ownerDocument.body,o=pt(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=pt(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Es(e);const c=-n.scrollTop;return At(s).direction==="rtl"&&(i+=pt(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:i,y:c}}const gc=25;function vb(e,t){const n=gt(e),s=Bt(e),o=n.visualViewport;let a=s.clientWidth,i=s.clientHeight,c=0,l=0;if(o){a=o.width,i=o.height;const f=Sa();(!f||f&&t==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}const d=Es(s);if(d<=0){const f=s.ownerDocument,u=f.body,g=getComputedStyle(u),p=f.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,x=Math.abs(s.clientWidth-u.clientWidth-p);x<=gc&&(a-=x)}else d<=gc&&(a+=d);return{width:a,height:i,x:c,y:l}}const yb=new Set(["absolute","fixed"]);function bb(e,t){const n=xn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=Ft(e)?$n(e):$t(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,l=o*a.x,d=s*a.y;return{width:i,height:c,x:l,y:d}}function xc(e,t,n){let s;if(t==="viewport")s=vb(e,n);else if(t==="document")s=xb(Bt(e));else if(Nt(t))s=bb(t,n);else{const o=vd(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return us(s)}function bd(e,t){const n=nn(e);return n===t||!Nt(n)||Bn(n)?!1:At(n).position==="fixed"||bd(n,t)}function wb(e,t){const n=t.get(e);if(n)return n;let s=yr(e,[],!1).filter(c=>Nt(c)&&Yn(c)!=="body"),o=null;const a=At(e).position==="fixed";let i=a?nn(e):e;for(;Nt(i)&&!Bn(i);){const c=At(i),l=ja(i);!l&&c.position==="fixed"&&(o=null),(a?!l&&!o:!l&&c.position==="static"&&!!o&&yb.has(o.position)||Ar(i)&&!l&&bd(e,i))?s=s.filter(f=>f!==i):o=c,i=nn(i)}return t.set(e,s),s}function kb(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const i=[...n==="clippingAncestors"?Ns(t)?[]:wb(t,this._c):[].concat(n),s],c=i[0],l=i.reduce((d,f)=>{const u=xc(t,f,o);return d.top=pt(u.top,d.top),d.right=tn(u.right,d.right),d.bottom=tn(u.bottom,d.bottom),d.left=pt(u.left,d.left),d},xc(t,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function _b(e){const{width:t,height:n}=xd(e);return{width:t,height:n}}function jb(e,t,n){const s=Ft(t),o=Bt(t),a=n==="fixed",i=xn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=$t(0);function d(){l.x=Es(o)}if(s||!s&&!a)if((Yn(t)!=="body"||Ar(o))&&(c=As(t)),s){const p=xn(t,!0,a,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&d();a&&!s&&o&&d();const f=o&&!s&&!a?yd(o,c):$t(0),u=i.left+c.scrollLeft-l.x-f.x,g=i.top+c.scrollTop-l.y-f.y;return{x:u,y:g,width:i.width,height:i.height}}function po(e){return At(e).position==="static"}function vc(e,t){if(!Ft(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Bt(e)===n&&(n=n.ownerDocument.body),n}function wd(e,t){const n=gt(e);if(Ns(e))return n;if(!Ft(e)){let o=nn(e);for(;o&&!Bn(o);){if(Nt(o)&&!po(o))return o;o=nn(o)}return n}let s=vc(e,t);for(;s&&ab(s)&&po(s);)s=vc(s,t);return s&&Bn(s)&&po(s)&&!ja(s)?n:s||ub(e)||n}const Sb=async function(e){const t=this.getOffsetParent||wd,n=this.getDimensions,s=await n(e.floating);return{reference:jb(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function Cb(e){return At(e).direction==="rtl"}const Nb={convertOffsetParentRelativeRectToViewportRelativeRect:hb,getDocumentElement:Bt,getClippingRect:kb,getOffsetParent:wd,getElementRects:Sb,getClientRects:gb,getDimensions:_b,getScale:$n,isElement:Nt,isRTL:Cb};function kd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Ab(e,t){let n=null,s;const o=Bt(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),a();const d=e.getBoundingClientRect(),{left:f,top:u,width:g,height:p}=d;if(c||t(),!g||!p)return;const x=$r(u),h=$r(o.clientWidth-(f+g)),v=$r(o.clientHeight-(u+p)),y=$r(f),_={rootMargin:-x+"px "+-h+"px "+-v+"px "+-y+"px",threshold:pt(0,tn(1,l))||1};let b=!0;function j(N){const T=N[0].intersectionRatio;if(T!==l){if(!b)return i();T?i(!1,T):s=setTimeout(()=>{i(!1,1e-7)},1e3)}T===1&&!kd(d,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(j,{..._,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,_)}n.observe(e)}return i(!0),a}function Eb(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=s,d=Ca(e),f=o||a?[...d?yr(d):[],...yr(t)]:[];f.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const u=d&&c?Ab(d,n):null;let g=-1,p=null;i&&(p=new ResizeObserver(y=>{let[k]=y;k&&k.target===d&&p&&(p.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var _;(_=p)==null||_.observe(t)})),n()}),d&&!l&&p.observe(d),p.observe(t));let x,h=l?xn(e):null;l&&v();function v(){const y=xn(e);h&&!kd(h,y)&&n(),h=y,x=requestAnimationFrame(v)}return n(),()=>{var y;f.forEach(k=>{o&&k.removeEventListener("scroll",n),a&&k.removeEventListener("resize",n)}),u?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(x)}}const Ib=eb,Tb=tb,Pb=Ky,Rb=rb,Ob=Jy,yc=Qy,Mb=nb,Lb=(e,t,n)=>{const s=new Map,o={platform:Nb,...n},a={...o.platform,_c:s};return Yy(e,t,{...o,platform:a})};var Db=typeof document<"u",$b=function(){},Kr=Db?w.useLayoutEffect:$b;function fs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!fs(e[s],t[s]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,o[s]))return!1;for(s=n;s--!==0;){const a=o[s];if(!(a==="_owner"&&e.$$typeof)&&!fs(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function _d(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function bc(e,t){const n=_d(e);return Math.round(t*n)/n}function ho(e){const t=m.useRef(e);return Kr(()=>{t.current=e}),t}function zb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:o,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:l,open:d}=e,[f,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,p]=m.useState(s);fs(g,s)||p(s);const[x,h]=m.useState(null),[v,y]=m.useState(null),k=m.useCallback(D=>{D!==N.current&&(N.current=D,h(D))},[]),_=m.useCallback(D=>{D!==T.current&&(T.current=D,y(D))},[]),b=a||x,j=i||v,N=m.useRef(null),T=m.useRef(null),A=m.useRef(f),E=l!=null,P=ho(l),F=ho(o),L=ho(d),U=m.useCallback(()=>{if(!N.current||!T.current)return;const D={placement:t,strategy:n,middleware:g};F.current&&(D.platform=F.current),Lb(N.current,T.current,D).then(C=>{const I={...C,isPositioned:L.current!==!1};$.current&&!fs(A.current,I)&&(A.current=I,bs.flushSync(()=>{u(I)}))})},[g,t,n,F,L]);Kr(()=>{d===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,u(D=>({...D,isPositioned:!1})))},[d]);const $=m.useRef(!1);Kr(()=>($.current=!0,()=>{$.current=!1}),[]),Kr(()=>{if(b&&(N.current=b),j&&(T.current=j),b&&j){if(P.current)return P.current(b,j,U);U()}},[b,j,U,P,E]);const Y=m.useMemo(()=>({reference:N,floating:T,setReference:k,setFloating:_}),[k,_]),B=m.useMemo(()=>({reference:b,floating:j}),[b,j]),H=m.useMemo(()=>{const D={position:n,left:0,top:0};if(!B.floating)return D;const C=bc(B.floating,f.x),I=bc(B.floating,f.y);return c?{...D,transform:"translate("+C+"px, "+I+"px)",..._d(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:C,top:I}},[n,c,B.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:U,refs:Y,elements:B,floatingStyles:H}),[f,U,Y,B,H])}const Fb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:o}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?yc({element:s.current,padding:o}).fn(n):{}:s?yc({element:s,padding:o}).fn(n):{}}}},Bb=(e,t)=>({...Ib(e),options:[e,t]}),Ub=(e,t)=>({...Tb(e),options:[e,t]}),Vb=(e,t)=>({...Mb(e),options:[e,t]}),Wb=(e,t)=>({...Pb(e),options:[e,t]}),qb=(e,t)=>({...Rb(e),options:[e,t]}),Hb=(e,t)=>({...Ob(e),options:[e,t]}),Zb=(e,t)=>({...Fb(e),options:[e,t]});var Gb="Arrow",jd=m.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(he.svg,{...a,ref:t,width:s,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});jd.displayName=Gb;var Yb=jd;function Qb(e){const[t,n]=m.useState(void 0);return Ye(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,c;if("borderBoxSize"in a){const l=a.borderBoxSize,d=Array.isArray(l)?l[0]:l;i=d.inlineSize,c=d.blockSize}else i=e.offsetWidth,c=e.offsetHeight;n({width:i,height:c})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}var Na="Popper",[Sd,Cd]=an(Na),[Kb,Nd]=Sd(Na),Ad=e=>{const{__scopePopper:t,children:n}=e,[s,o]=m.useState(null);return r.jsx(Kb,{scope:t,anchor:s,onAnchorChange:o,children:n})};Ad.displayName=Na;var Ed="PopperAnchor",Id=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=Nd(Ed,n),i=m.useRef(null),c=Se(t,i),l=m.useRef(null);return m.useEffect(()=>{const d=l.current;l.current=s?.current||i.current,d!==l.current&&a.onAnchorChange(l.current)}),s?null:r.jsx(he.div,{...o,ref:c})});Id.displayName=Ed;var Aa="PopperContent",[Jb,Xb]=Sd(Aa),Td=m.forwardRef((e,t)=>{const{__scopePopper:n,side:s="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:u="partial",hideWhenDetached:g=!1,updatePositionStrategy:p="optimized",onPlaced:x,...h}=e,v=Nd(Aa,n),[y,k]=m.useState(null),_=Se(t,R=>k(R)),[b,j]=m.useState(null),N=Qb(b),T=N?.width??0,A=N?.height??0,E=s+(a!=="center"?"-"+a:""),P=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},F=Array.isArray(d)?d:[d],L=F.length>0,U={padding:P,boundary:F.filter(tw),altBoundary:L},{refs:$,floatingStyles:Y,placement:B,isPositioned:H,middlewareData:D}=zb({strategy:"fixed",placement:E,whileElementsMounted:(...R)=>Eb(...R,{animationFrame:p==="always"}),elements:{reference:v.anchor},middleware:[Bb({mainAxis:o+A,alignmentAxis:i}),l&&Ub({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Vb():void 0,...U}),l&&Wb({...U}),qb({...U,apply:({elements:R,rects:G,availableWidth:ue,availableHeight:W})=>{const{width:se,height:ie}=G.reference,ye=R.floating.style;ye.setProperty("--radix-popper-available-width",`${ue}px`),ye.setProperty("--radix-popper-available-height",`${W}px`),ye.setProperty("--radix-popper-anchor-width",`${se}px`),ye.setProperty("--radix-popper-anchor-height",`${ie}px`)}}),b&&Zb({element:b,padding:c}),nw({arrowWidth:T,arrowHeight:A}),g&&Hb({strategy:"referenceHidden",...U})]}),[C,I]=Od(B),Z=en(x);Ye(()=>{H&&Z?.()},[H,Z]);const ve=D.arrow?.x,V=D.arrow?.y,Q=D.arrow?.centerOffset!==0,[K,le]=m.useState();return Ye(()=>{y&&le(window.getComputedStyle(y).zIndex)},[y]),r.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:H?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:K,"--radix-popper-transform-origin":[D.transformOrigin?.x,D.transformOrigin?.y].join(" "),...D.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(Jb,{scope:n,placedSide:C,onArrowChange:j,arrowX:ve,arrowY:V,shouldHideArrow:Q,children:r.jsx(he.div,{"data-side":C,"data-align":I,...h,ref:_,style:{...h.style,animation:H?void 0:"none"}})})})});Td.displayName=Aa;var Pd="PopperArrow",ew={top:"bottom",right:"left",bottom:"top",left:"right"},Rd=m.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=Xb(Pd,s),i=ew[a.placedSide];return r.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:r.jsx(Yb,{...o,ref:n,style:{...o.style,display:"block"}})})});Rd.displayName=Pd;function tw(e){return e!==null}var nw=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:s,middlewareData:o}=t,i=o.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[d,f]=Od(n),u={start:"0%",center:"50%",end:"100%"}[f],g=(o.arrow?.x??0)+c/2,p=(o.arrow?.y??0)+l/2;let x="",h="";return d==="bottom"?(x=i?u:`${g}px`,h=`${-l}px`):d==="top"?(x=i?u:`${g}px`,h=`${s.floating.height+l}px`):d==="right"?(x=`${-l}px`,h=i?u:`${p}px`):d==="left"&&(x=`${s.floating.width+l}px`,h=i?u:`${p}px`),{data:{x,y:h}}}});function Od(e){const[t,n="center"]=e.split("-");return[t,n]}var rw=Ad,sw=Id,ow=Td,aw=Rd,iw="Portal",Ea=m.forwardRef((e,t)=>{const{container:n,...s}=e,[o,a]=m.useState(!1);Ye(()=>a(!0),[]);const i=n||o&&globalThis?.document?.body;return i?ea.createPortal(r.jsx(he.div,{...s,ref:t}),i):null});Ea.displayName=iw;function cw(e){const t=lw(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(uw);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return r.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function lw(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=mw(o),c=fw(a,o.props);return o.type!==m.Fragment&&(c.ref=s?qn(s,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var dw=Symbol("radix.slottable");function uw(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===dw}function fw(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function mw(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var pw=m[" useInsertionEffect ".trim().toString()]||Ye;function rn({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,i]=hw({defaultProp:t,onChange:n}),c=e!==void 0,l=c?e:o;{const f=m.useRef(e!==void 0);m.useEffect(()=>{const u=f.current;u!==c&&console.warn(`${s} is changing from ${u?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=c},[c,s])}const d=m.useCallback(f=>{if(c){const u=gw(f)?f(e):f;u!==e&&i.current?.(u)}else a(f)},[c,e,a,i]);return[l,d]}function hw({defaultProp:e,onChange:t}){const[n,s]=m.useState(e),o=m.useRef(n),a=m.useRef(t);return pw(()=>{a.current=t},[t]),m.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,s,a]}function gw(e){return typeof e=="function"}function xw(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Md=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),vw="VisuallyHidden",yw=m.forwardRef((e,t)=>r.jsx(he.span,{...e,ref:t,style:{...Md,...e.style}}));yw.displayName=vw;var bw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Rn=new WeakMap,zr=new WeakMap,Fr={},go=0,Ld=function(e){return e&&(e.host||Ld(e.parentNode))},ww=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Ld(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},kw=function(e,t,n,s){var o=ww(t,Array.isArray(e)?e:[e]);Fr[n]||(Fr[n]=new WeakMap);var a=Fr[n],i=[],c=new Set,l=new Set(o),d=function(u){!u||c.has(u)||(c.add(u),d(u.parentNode))};o.forEach(d);var f=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(g){if(c.has(g))f(g);else try{var p=g.getAttribute(s),x=p!==null&&p!=="false",h=(Rn.get(g)||0)+1,v=(a.get(g)||0)+1;Rn.set(g,h),a.set(g,v),i.push(g),h===1&&x&&zr.set(g,!0),v===1&&g.setAttribute(n,"true"),x||g.setAttribute(s,"true")}catch(y){console.error("aria-hidden: cannot operate on ",g,y)}})};return f(t),c.clear(),go++,function(){i.forEach(function(u){var g=Rn.get(u)-1,p=a.get(u)-1;Rn.set(u,g),a.set(u,p),g||(zr.has(u)||u.removeAttribute(s),zr.delete(u)),p||u.removeAttribute(n)}),go--,go||(Rn=new WeakMap,Rn=new WeakMap,zr=new WeakMap,Fr={})}},Dd=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=bw(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),kw(s,o,n,"aria-hidden")):function(){return null}},Mt=function(){return Mt=Object.assign||function(t){for(var n,s=1,o=arguments.length;s<o;s++){n=arguments[s];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Mt.apply(this,arguments)};function $d(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(n[s[o]]=e[s[o]]);return n}function _w(e,t,n){if(n||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}var Jr="right-scroll-bar-position",Xr="width-before-scroll-bar",jw="with-scroll-bars-hidden",Sw="--removed-body-scroll-bar-size";function xo(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Cw(e,t){var n=w.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var o=n.value;o!==s&&(n.value=s,n.callback(s,o))}}}})[0];return n.callback=t,n.facade}var Nw=typeof window<"u"?m.useLayoutEffect:m.useEffect,wc=new WeakMap;function Aw(e,t){var n=Cw(null,function(s){return e.forEach(function(o){return xo(o,s)})});return Nw(function(){var s=wc.get(n);if(s){var o=new Set(s),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||xo(c,null)}),a.forEach(function(c){o.has(c)||xo(c,i)})}wc.set(n,e)},[e]),n}function Ew(e){return e}function Iw(e,t){t===void 0&&(t=Ew);var n=[],s=!1,o={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,s);return n.push(i),function(){n=n.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(s=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(c){return a(c)},filter:function(){return n}}},assignMedium:function(a){s=!0;var i=[];if(n.length){var c=n;n=[],c.forEach(a),i=n}var l=function(){var f=i;i=[],f.forEach(a)},d=function(){return Promise.resolve().then(l)};d(),n={push:function(f){i.push(f),d()},filter:function(f){return i=i.filter(f),n}}}};return o}function Tw(e){e===void 0&&(e={});var t=Iw(null);return t.options=Mt({async:!0,ssr:!1},e),t}var zd=function(e){var t=e.sideCar,n=$d(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return m.createElement(s,Mt({},n))};zd.isSideCarExport=!0;function Pw(e,t){return e.useMedium(t),zd}var Fd=Tw(),vo=function(){},Is=m.forwardRef(function(e,t){var n=m.useRef(null),s=m.useState({onScrollCapture:vo,onWheelCapture:vo,onTouchMoveCapture:vo}),o=s[0],a=s[1],i=e.forwardProps,c=e.children,l=e.className,d=e.removeScrollBar,f=e.enabled,u=e.shards,g=e.sideCar,p=e.noRelative,x=e.noIsolation,h=e.inert,v=e.allowPinchZoom,y=e.as,k=y===void 0?"div":y,_=e.gapMode,b=$d(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=g,N=Aw([n,t]),T=Mt(Mt({},b),o);return m.createElement(m.Fragment,null,f&&m.createElement(j,{sideCar:Fd,removeScrollBar:d,shards:u,noRelative:p,noIsolation:x,inert:h,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:_}),i?m.cloneElement(m.Children.only(c),Mt(Mt({},T),{ref:N})):m.createElement(k,Mt({},T,{className:l,ref:N}),c))});Is.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Is.classNames={fullWidth:Xr,zeroRight:Jr};var Rw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ow(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Rw();return t&&e.setAttribute("nonce",t),e}function Mw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Lw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Dw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ow())&&(Mw(t,n),Lw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$w=function(){var e=Dw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Bd=function(){var e=$w(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},zw={left:0,top:0,right:0,gap:0},yo=function(e){return parseInt(e||"",10)||0},Fw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[yo(n),yo(s),yo(o)]},Bw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return zw;var t=Fw(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},Uw=Bd(),zn="data-scroll-locked",Vw=function(e,t,n,s){var o=e.left,a=e.top,i=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
40
|
+
.`.concat(jw,` {
|
|
41
|
+
overflow: hidden `).concat(s,`;
|
|
42
|
+
padding-right: `).concat(c,"px ").concat(s,`;
|
|
43
|
+
}
|
|
44
|
+
body[`).concat(zn,`] {
|
|
45
|
+
overflow: hidden `).concat(s,`;
|
|
46
|
+
overscroll-behavior: contain;
|
|
47
|
+
`).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
|
|
48
|
+
padding-left: `.concat(o,`px;
|
|
49
|
+
padding-top: `).concat(a,`px;
|
|
50
|
+
padding-right: `).concat(i,`px;
|
|
51
|
+
margin-left:0;
|
|
52
|
+
margin-top:0;
|
|
53
|
+
margin-right: `).concat(c,"px ").concat(s,`;
|
|
54
|
+
`),n==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.`).concat(Jr,` {
|
|
58
|
+
right: `).concat(c,"px ").concat(s,`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.`).concat(Xr,` {
|
|
62
|
+
margin-right: `).concat(c,"px ").concat(s,`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.`).concat(Jr," .").concat(Jr,` {
|
|
66
|
+
right: 0 `).concat(s,`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.`).concat(Xr," .").concat(Xr,` {
|
|
70
|
+
margin-right: 0 `).concat(s,`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
body[`).concat(zn,`] {
|
|
74
|
+
`).concat(Sw,": ").concat(c,`px;
|
|
75
|
+
}
|
|
76
|
+
`)},kc=function(){var e=parseInt(document.body.getAttribute(zn)||"0",10);return isFinite(e)?e:0},Ww=function(){m.useEffect(function(){return document.body.setAttribute(zn,(kc()+1).toString()),function(){var e=kc()-1;e<=0?document.body.removeAttribute(zn):document.body.setAttribute(zn,e.toString())}},[])},qw=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;Ww();var a=m.useMemo(function(){return Bw(o)},[o]);return m.createElement(Uw,{styles:Vw(a,!t,o,n?"":"!important")})},Bo=!1;if(typeof window<"u")try{var Br=Object.defineProperty({},"passive",{get:function(){return Bo=!0,!0}});window.addEventListener("test",Br,Br),window.removeEventListener("test",Br,Br)}catch{Bo=!1}var On=Bo?{passive:!1}:!1,Hw=function(e){return e.tagName==="TEXTAREA"},Ud=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Hw(e)&&n[t]==="visible")},Zw=function(e){return Ud(e,"overflowY")},Gw=function(e){return Ud(e,"overflowX")},_c=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=Vd(e,s);if(o){var a=Wd(e,s),i=a[1],c=a[2];if(i>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},Yw=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Qw=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Vd=function(e,t){return e==="v"?Zw(t):Gw(t)},Wd=function(e,t){return e==="v"?Yw(t):Qw(t)},Kw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Jw=function(e,t,n,s,o){var a=Kw(e,window.getComputedStyle(t).direction),i=a*s,c=n.target,l=t.contains(c),d=!1,f=i>0,u=0,g=0;do{if(!c)break;var p=Wd(e,c),x=p[0],h=p[1],v=p[2],y=h-v-a*x;(x||y)&&Vd(e,c)&&(u+=y,g+=x);var k=c.parentNode;c=k&&k.nodeType===Node.DOCUMENT_FRAGMENT_NODE?k.host:k}while(!l&&c!==document.body||l&&(t.contains(c)||t===c));return(f&&Math.abs(u)<1||!f&&Math.abs(g)<1)&&(d=!0),d},Ur=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},jc=function(e){return[e.deltaX,e.deltaY]},Sc=function(e){return e&&"current"in e?e.current:e},Xw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ek=function(e){return`
|
|
77
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
+
`)},tk=0,Mn=[];function nk(e){var t=m.useRef([]),n=m.useRef([0,0]),s=m.useRef(),o=m.useState(tk++)[0],a=m.useState(Bd)[0],i=m.useRef(e);m.useEffect(function(){i.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var h=_w([e.lockRef.current],(e.shards||[]).map(Sc),!0).filter(Boolean);return h.forEach(function(v){return v.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),h.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=m.useCallback(function(h,v){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!i.current.allowPinchZoom;var y=Ur(h),k=n.current,_="deltaX"in h?h.deltaX:k[0]-y[0],b="deltaY"in h?h.deltaY:k[1]-y[1],j,N=h.target,T=Math.abs(_)>Math.abs(b)?"h":"v";if("touches"in h&&T==="h"&&N.type==="range")return!1;var A=window.getSelection(),E=A&&A.anchorNode,P=E?E===N||E.contains(N):!1;if(P)return!1;var F=_c(T,N);if(!F)return!0;if(F?j=T:(j=T==="v"?"h":"v",F=_c(T,N)),!F)return!1;if(!s.current&&"changedTouches"in h&&(_||b)&&(s.current=j),!j)return!0;var L=s.current||j;return Jw(L,v,h,L==="h"?_:b)},[]),l=m.useCallback(function(h){var v=h;if(!(!Mn.length||Mn[Mn.length-1]!==a)){var y="deltaY"in v?jc(v):Ur(v),k=t.current.filter(function(j){return j.name===v.type&&(j.target===v.target||v.target===j.shadowParent)&&Xw(j.delta,y)})[0];if(k&&k.should){v.cancelable&&v.preventDefault();return}if(!k){var _=(i.current.shards||[]).map(Sc).filter(Boolean).filter(function(j){return j.contains(v.target)}),b=_.length>0?c(v,_[0]):!i.current.noIsolation;b&&v.cancelable&&v.preventDefault()}}},[]),d=m.useCallback(function(h,v,y,k){var _={name:h,delta:v,target:y,should:k,shadowParent:rk(y)};t.current.push(_),setTimeout(function(){t.current=t.current.filter(function(b){return b!==_})},1)},[]),f=m.useCallback(function(h){n.current=Ur(h),s.current=void 0},[]),u=m.useCallback(function(h){d(h.type,jc(h),h.target,c(h,e.lockRef.current))},[]),g=m.useCallback(function(h){d(h.type,Ur(h),h.target,c(h,e.lockRef.current))},[]);m.useEffect(function(){return Mn.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:g}),document.addEventListener("wheel",l,On),document.addEventListener("touchmove",l,On),document.addEventListener("touchstart",f,On),function(){Mn=Mn.filter(function(h){return h!==a}),document.removeEventListener("wheel",l,On),document.removeEventListener("touchmove",l,On),document.removeEventListener("touchstart",f,On)}},[]);var p=e.removeScrollBar,x=e.inert;return m.createElement(m.Fragment,null,x?m.createElement(a,{styles:ek(o)}):null,p?m.createElement(qw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function rk(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const sk=Pw(Fd,nk);var Ia=m.forwardRef(function(e,t){return m.createElement(Is,Mt({},e,{ref:t,sideCar:sk}))});Ia.classNames=Is.classNames;var ok=[" ","Enter","ArrowUp","ArrowDown"],ak=[" ","Enter"],vn="Select",[Ts,Ps,ik]=va(vn),[Qn]=an(vn,[ik,Cd]),Rs=Cd(),[ck,cn]=Qn(vn),[lk,dk]=Qn(vn),qd=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:o,onOpenChange:a,value:i,defaultValue:c,onValueChange:l,dir:d,name:f,autoComplete:u,disabled:g,required:p,form:x}=e,h=Rs(t),[v,y]=m.useState(null),[k,_]=m.useState(null),[b,j]=m.useState(!1),N=Ss(d),[T,A]=rn({prop:s,defaultProp:o??!1,onChange:a,caller:vn}),[E,P]=rn({prop:i,defaultProp:c,onChange:l,caller:vn}),F=m.useRef(null),L=v?x||!!v.closest("form"):!0,[U,$]=m.useState(new Set),Y=Array.from(U).map(B=>B.props.value).join(";");return r.jsx(rw,{...h,children:r.jsxs(ck,{required:p,scope:t,trigger:v,onTriggerChange:y,valueNode:k,onValueNodeChange:_,valueNodeHasChildren:b,onValueNodeHasChildrenChange:j,contentId:Dt(),value:E,onValueChange:P,open:T,onOpenChange:A,dir:N,triggerPointerDownPosRef:F,disabled:g,children:[r.jsx(Ts.Provider,{scope:t,children:r.jsx(lk,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(B=>{$(H=>new Set(H).add(B))},[]),onNativeOptionRemove:m.useCallback(B=>{$(H=>{const D=new Set(H);return D.delete(B),D})},[]),children:n})}),L?r.jsxs(uu,{"aria-hidden":!0,required:p,tabIndex:-1,name:f,autoComplete:u,value:E,onChange:B=>P(B.target.value),disabled:g,form:x,children:[E===void 0?r.jsx("option",{value:""}):null,Array.from(U)]},Y):null]})})};qd.displayName=vn;var Hd="SelectTrigger",Zd=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Rs(n),i=cn(Hd,n),c=i.disabled||s,l=Se(t,i.onTriggerChange),d=Ps(n),f=m.useRef("touch"),[u,g,p]=mu(h=>{const v=d().filter(_=>!_.disabled),y=v.find(_=>_.value===i.value),k=pu(v,h,y);k!==void 0&&i.onValueChange(k.value)}),x=h=>{c||(i.onOpenChange(!0),p()),h&&(i.triggerPointerDownPosRef.current={x:Math.round(h.pageX),y:Math.round(h.pageY)})};return r.jsx(sw,{asChild:!0,...a,children:r.jsx(he.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":fu(i.value)?"":void 0,...o,ref:l,onClick:xe(o.onClick,h=>{h.currentTarget.focus(),f.current!=="mouse"&&x(h)}),onPointerDown:xe(o.onPointerDown,h=>{f.current=h.pointerType;const v=h.target;v.hasPointerCapture(h.pointerId)&&v.releasePointerCapture(h.pointerId),h.button===0&&h.ctrlKey===!1&&h.pointerType==="mouse"&&(x(h),h.preventDefault())}),onKeyDown:xe(o.onKeyDown,h=>{const v=u.current!=="";!(h.ctrlKey||h.altKey||h.metaKey)&&h.key.length===1&&g(h.key),!(v&&h.key===" ")&&ok.includes(h.key)&&(x(),h.preventDefault())})})})});Zd.displayName=Hd;var Gd="SelectValue",Yd=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:i="",...c}=e,l=cn(Gd,n),{onValueNodeHasChildrenChange:d}=l,f=a!==void 0,u=Se(t,l.onValueNodeChange);return Ye(()=>{d(f)},[d,f]),r.jsx(he.span,{...c,ref:u,style:{pointerEvents:"none"},children:fu(l.value)?r.jsx(r.Fragment,{children:i}):a})});Yd.displayName=Gd;var uk="SelectIcon",Qd=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(he.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});Qd.displayName=uk;var fk="SelectPortal",Kd=e=>r.jsx(Ea,{asChild:!0,...e});Kd.displayName=fk;var yn="SelectContent",Jd=m.forwardRef((e,t)=>{const n=cn(yn,e.__scopeSelect),[s,o]=m.useState();if(Ye(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?bs.createPortal(r.jsx(Xd,{scope:e.__scopeSelect,children:r.jsx(Ts.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(eu,{...e,ref:t})});Jd.displayName=yn;var St=10,[Xd,ln]=Qn(yn),mk="SelectContentImpl",pk=cw("SelectContent.RemoveScroll"),eu=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:g,collisionPadding:p,sticky:x,hideWhenDetached:h,avoidCollisions:v,...y}=e,k=cn(yn,n),[_,b]=m.useState(null),[j,N]=m.useState(null),T=Se(t,R=>b(R)),[A,E]=m.useState(null),[P,F]=m.useState(null),L=Ps(n),[U,$]=m.useState(!1),Y=m.useRef(!1);m.useEffect(()=>{if(_)return Dd(_)},[_]),ud();const B=m.useCallback(R=>{const[G,...ue]=L().map(ie=>ie.ref.current),[W]=ue.slice(-1),se=document.activeElement;for(const ie of R)if(ie===se||(ie?.scrollIntoView({block:"nearest"}),ie===G&&j&&(j.scrollTop=0),ie===W&&j&&(j.scrollTop=j.scrollHeight),ie?.focus(),document.activeElement!==se))return},[L,j]),H=m.useCallback(()=>B([A,_]),[B,A,_]);m.useEffect(()=>{U&&H()},[U,H]);const{onOpenChange:D,triggerPointerDownPosRef:C}=k;m.useEffect(()=>{if(_){let R={x:0,y:0};const G=W=>{R={x:Math.abs(Math.round(W.pageX)-(C.current?.x??0)),y:Math.abs(Math.round(W.pageY)-(C.current?.y??0))}},ue=W=>{R.x<=10&&R.y<=10?W.preventDefault():_.contains(W.target)||D(!1),document.removeEventListener("pointermove",G),C.current=null};return C.current!==null&&(document.addEventListener("pointermove",G),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",G),document.removeEventListener("pointerup",ue,{capture:!0})}}},[_,D,C]),m.useEffect(()=>{const R=()=>D(!1);return window.addEventListener("blur",R),window.addEventListener("resize",R),()=>{window.removeEventListener("blur",R),window.removeEventListener("resize",R)}},[D]);const[I,Z]=mu(R=>{const G=L().filter(se=>!se.disabled),ue=G.find(se=>se.ref.current===document.activeElement),W=pu(G,R,ue);W&&setTimeout(()=>W.ref.current.focus())}),ve=m.useCallback((R,G,ue)=>{const W=!Y.current&&!ue;(k.value!==void 0&&k.value===G||W)&&(E(R),W&&(Y.current=!0))},[k.value]),V=m.useCallback(()=>_?.focus(),[_]),Q=m.useCallback((R,G,ue)=>{const W=!Y.current&&!ue;(k.value!==void 0&&k.value===G||W)&&F(R)},[k.value]),K=s==="popper"?Uo:tu,le=K===Uo?{side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:g,collisionPadding:p,sticky:x,hideWhenDetached:h,avoidCollisions:v}:{};return r.jsx(Xd,{scope:n,content:_,viewport:j,onViewportChange:N,itemRefCallback:ve,selectedItem:A,onItemLeave:V,itemTextRefCallback:Q,focusSelectedItem:H,selectedItemText:P,position:s,isPositioned:U,searchRef:I,children:r.jsx(Ia,{as:pk,allowPinchZoom:!0,children:r.jsx(ba,{asChild:!0,trapped:k.open,onMountAutoFocus:R=>{R.preventDefault()},onUnmountAutoFocus:xe(o,R=>{k.trigger?.focus({preventScroll:!0}),R.preventDefault()}),children:r.jsx(ya,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:R=>R.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:r.jsx(K,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:R=>R.preventDefault(),...y,...le,onPlaced:()=>$(!0),ref:T,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:xe(y.onKeyDown,R=>{const G=R.ctrlKey||R.altKey||R.metaKey;if(R.key==="Tab"&&R.preventDefault(),!G&&R.key.length===1&&Z(R.key),["ArrowUp","ArrowDown","Home","End"].includes(R.key)){let W=L().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(R.key)&&(W=W.slice().reverse()),["ArrowUp","ArrowDown"].includes(R.key)){const se=R.target,ie=W.indexOf(se);W=W.slice(ie+1)}setTimeout(()=>B(W)),R.preventDefault()}})})})})})})});eu.displayName=mk;var hk="SelectItemAlignedPosition",tu=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=cn(yn,n),i=ln(yn,n),[c,l]=m.useState(null),[d,f]=m.useState(null),u=Se(t,T=>f(T)),g=Ps(n),p=m.useRef(!1),x=m.useRef(!0),{viewport:h,selectedItem:v,selectedItemText:y,focusSelectedItem:k}=i,_=m.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&d&&h&&v&&y){const T=a.trigger.getBoundingClientRect(),A=d.getBoundingClientRect(),E=a.valueNode.getBoundingClientRect(),P=y.getBoundingClientRect();if(a.dir!=="rtl"){const se=P.left-A.left,ie=E.left-se,ye=T.left-ie,fe=T.width+ye,Ue=Math.max(fe,A.width),Qe=window.innerWidth-St,Ve=tc(ie,[St,Math.max(St,Qe-Ue)]);c.style.minWidth=fe+"px",c.style.left=Ve+"px"}else{const se=A.right-P.right,ie=window.innerWidth-E.right-se,ye=window.innerWidth-T.right-ie,fe=T.width+ye,Ue=Math.max(fe,A.width),Qe=window.innerWidth-St,Ve=tc(ie,[St,Math.max(St,Qe-Ue)]);c.style.minWidth=fe+"px",c.style.right=Ve+"px"}const F=g(),L=window.innerHeight-St*2,U=h.scrollHeight,$=window.getComputedStyle(d),Y=parseInt($.borderTopWidth,10),B=parseInt($.paddingTop,10),H=parseInt($.borderBottomWidth,10),D=parseInt($.paddingBottom,10),C=Y+B+U+D+H,I=Math.min(v.offsetHeight*5,C),Z=window.getComputedStyle(h),ve=parseInt(Z.paddingTop,10),V=parseInt(Z.paddingBottom,10),Q=T.top+T.height/2-St,K=L-Q,le=v.offsetHeight/2,R=v.offsetTop+le,G=Y+B+R,ue=C-G;if(G<=Q){const se=F.length>0&&v===F[F.length-1].ref.current;c.style.bottom="0px";const ie=d.clientHeight-h.offsetTop-h.offsetHeight,ye=Math.max(K,le+(se?V:0)+ie+H),fe=G+ye;c.style.height=fe+"px"}else{const se=F.length>0&&v===F[0].ref.current;c.style.top="0px";const ye=Math.max(Q,Y+h.offsetTop+(se?ve:0)+le)+ue;c.style.height=ye+"px",h.scrollTop=G-Q+h.offsetTop}c.style.margin=`${St}px 0`,c.style.minHeight=I+"px",c.style.maxHeight=L+"px",s?.(),requestAnimationFrame(()=>p.current=!0)}},[g,a.trigger,a.valueNode,c,d,h,v,y,a.dir,s]);Ye(()=>_(),[_]);const[b,j]=m.useState();Ye(()=>{d&&j(window.getComputedStyle(d).zIndex)},[d]);const N=m.useCallback(T=>{T&&x.current===!0&&(_(),k?.(),x.current=!1)},[_,k]);return r.jsx(xk,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:p,onScrollButtonChange:N,children:r.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:b},children:r.jsx(he.div,{...o,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});tu.displayName=hk;var gk="SelectPopperPosition",Uo=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=St,...a}=e,i=Rs(n);return r.jsx(ow,{...i,...a,ref:t,align:s,collisionPadding:o,style:{boxSizing:"border-box",...a.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Uo.displayName=gk;var[xk,Ta]=Qn(yn,{}),Vo="SelectViewport",nu=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=ln(Vo,n),i=Ta(Vo,n),c=Se(t,a.onViewportChange),l=m.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),r.jsx(Ts.Slot,{scope:n,children:r.jsx(he.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:xe(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:u,shouldExpandOnScrollRef:g}=i;if(g?.current&&u){const p=Math.abs(l.current-f.scrollTop);if(p>0){const x=window.innerHeight-St*2,h=parseFloat(u.style.minHeight),v=parseFloat(u.style.height),y=Math.max(h,v);if(y<x){const k=y+p,_=Math.min(x,k),b=k-_;u.style.height=_+"px",u.style.bottom==="0px"&&(f.scrollTop=b>0?b:0,u.style.justifyContent="flex-end")}}}l.current=f.scrollTop})})})]})});nu.displayName=Vo;var ru="SelectGroup",[vk,yk]=Qn(ru),su=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Dt();return r.jsx(vk,{scope:n,id:o,children:r.jsx(he.div,{role:"group","aria-labelledby":o,...s,ref:t})})});su.displayName=ru;var ou="SelectLabel",bk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=yk(ou,n);return r.jsx(he.div,{id:o.id,...s,ref:t})});bk.displayName=ou;var ms="SelectItem",[wk,au]=Qn(ms),iu=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...i}=e,c=cn(ms,n),l=ln(ms,n),d=c.value===s,[f,u]=m.useState(a??""),[g,p]=m.useState(!1),x=Se(t,k=>l.itemRefCallback?.(k,s,o)),h=Dt(),v=m.useRef("touch"),y=()=>{o||(c.onValueChange(s),c.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(wk,{scope:n,value:s,disabled:o,textId:h,isSelected:d,onItemTextChange:m.useCallback(k=>{u(_=>_||(k?.textContent??"").trim())},[]),children:r.jsx(Ts.ItemSlot,{scope:n,value:s,disabled:o,textValue:f,children:r.jsx(he.div,{role:"option","aria-labelledby":h,"data-highlighted":g?"":void 0,"aria-selected":d&&g,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:x,onFocus:xe(i.onFocus,()=>p(!0)),onBlur:xe(i.onBlur,()=>p(!1)),onClick:xe(i.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:xe(i.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:xe(i.onPointerDown,k=>{v.current=k.pointerType}),onPointerMove:xe(i.onPointerMove,k=>{v.current=k.pointerType,o?l.onItemLeave?.():v.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(i.onPointerLeave,k=>{k.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:xe(i.onKeyDown,k=>{l.searchRef?.current!==""&&k.key===" "||(ak.includes(k.key)&&y(),k.key===" "&&k.preventDefault())})})})})});iu.displayName=ms;var lr="SelectItemText",cu=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,i=cn(lr,n),c=ln(lr,n),l=au(lr,n),d=dk(lr,n),[f,u]=m.useState(null),g=Se(t,y=>u(y),l.onItemTextChange,y=>c.itemTextRefCallback?.(y,l.value,l.disabled)),p=f?.textContent,x=m.useMemo(()=>r.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:v}=d;return Ye(()=>(h(x),()=>v(x)),[h,v,x]),r.jsxs(r.Fragment,{children:[r.jsx(he.span,{id:l.textId,...a,ref:g}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?bs.createPortal(a.children,i.valueNode):null]})});cu.displayName=lr;var lu="SelectItemIndicator",kk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return au(lu,n).isSelected?r.jsx(he.span,{"aria-hidden":!0,...s,ref:t}):null});kk.displayName=lu;var Wo="SelectScrollUpButton",_k=m.forwardRef((e,t)=>{const n=ln(Wo,e.__scopeSelect),s=Ta(Wo,e.__scopeSelect),[o,a]=m.useState(!1),i=Se(t,s.onScrollButtonChange);return Ye(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=l.scrollTop>0;a(d)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(du,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop-l.offsetHeight)}}):null});_k.displayName=Wo;var qo="SelectScrollDownButton",jk=m.forwardRef((e,t)=>{const n=ln(qo,e.__scopeSelect),s=Ta(qo,e.__scopeSelect),[o,a]=m.useState(!1),i=Se(t,s.onScrollButtonChange);return Ye(()=>{if(n.viewport&&n.isPositioned){let c=function(){const d=l.scrollHeight-l.clientHeight,f=Math.ceil(l.scrollTop)<d;a(f)};const l=n.viewport;return c(),l.addEventListener("scroll",c),()=>l.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),o?r.jsx(du,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop+l.offsetHeight)}}):null});jk.displayName=qo;var du=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=ln("SelectScrollButton",n),i=m.useRef(null),c=Ps(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Ye(()=>{c().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),r.jsx(he.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:xe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(s,50))}),onPointerMove:xe(o.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(s,50))}),onPointerLeave:xe(o.onPointerLeave,()=>{l()})})}),Sk="SelectSeparator",Ck=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(he.div,{"aria-hidden":!0,...s,ref:t})});Ck.displayName=Sk;var Ho="SelectArrow",Nk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Rs(n),a=cn(Ho,n),i=ln(Ho,n);return a.open&&i.position==="popper"?r.jsx(aw,{...o,...s,ref:t}):null});Nk.displayName=Ho;var Ak="SelectBubbleInput",uu=m.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=m.useRef(null),a=Se(s,o),i=xw(t);return m.useEffect(()=>{const c=o.current;if(!c)return;const l=window.HTMLSelectElement.prototype,f=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&f){const u=new Event("change",{bubbles:!0});f.call(c,t),c.dispatchEvent(u)}},[i,t]),r.jsx(he.select,{...n,style:{...Md,...n.style},ref:a,defaultValue:t})});uu.displayName=Ak;function fu(e){return e===""||e===void 0}function mu(e){const t=en(e),n=m.useRef(""),s=m.useRef(0),o=m.useCallback(i=>{const c=n.current+i;t(c),(function l(d){n.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>l(""),1e3))})(c)},[t]),a=m.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,o,a]}function pu(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,a=n?e.indexOf(n):-1;let i=Ek(e,Math.max(a,0));o.length===1&&(i=i.filter(d=>d!==n));const l=i.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Ek(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var Ik=qd,hu=Zd,Tk=Yd,Pk=Qd,Rk=Kd,gu=Jd,Ok=nu,Mk=su,xu=iu,Lk=cu;const ps=Ik,Dk=Mk,hs=Tk,br=m.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(hu,{ref:s,className:O("flex h-10 w-full items-center justify-between rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:focus-visible:ring-neutral-50/20",e),...n,children:[t,r.jsx(Pk,{className:"ml-2 text-neutral-500 dark:text-neutral-400",children:"▾"})]}));br.displayName=hu.displayName;const wr=m.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(Rk,{children:r.jsx(gu,{ref:o,position:n,className:O("z-50 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow-md dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",e),...s,children:r.jsx(Ok,{className:O("p-1",n==="popper"?"w-full":void 0),children:t})})}));wr.displayName=gu.displayName;const kr=m.forwardRef(({className:e,children:t,...n},s)=>r.jsx(xu,{ref:s,className:O("relative flex w-full cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-neutral-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:focus:bg-neutral-800",e),...n,children:r.jsx(Lk,{children:t})}));kr.displayName=xu.displayName;function $k(e,t){return m.useReducer((n,s)=>t[n][s]??n,e)}var Kn=e=>{const{present:t,children:n}=e,s=zk(t),o=typeof n=="function"?n({present:s.isPresent}):m.Children.only(n),a=Se(s.ref,Fk(o));return typeof n=="function"||s.isPresent?m.cloneElement(o,{ref:a}):null};Kn.displayName="Presence";function zk(e){const[t,n]=m.useState(),s=m.useRef(null),o=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[c,l]=$k(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const d=Vr(s.current);a.current=c==="mounted"?d:"none"},[c]),Ye(()=>{const d=s.current,f=o.current;if(f!==e){const g=a.current,p=Vr(d);e?l("MOUNT"):p==="none"||d?.display==="none"?l("UNMOUNT"):l(f&&g!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),Ye(()=>{if(t){let d;const f=t.ownerDocument.defaultView??window,u=p=>{const h=Vr(s.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!o.current)){const v=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=v)})}},g=p=>{p.target===t&&(a.current=Vr(s.current))};return t.addEventListener("animationstart",g),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{f.clearTimeout(d),t.removeEventListener("animationstart",g),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:m.useCallback(d=>{s.current=d?getComputedStyle(d):null,n(d)},[])}}function Vr(e){return e?.animationName||"none"}function Fk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Bk(e){const t=Uk(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(Wk);if(l){const d=l.props.children,f=c.map(u=>u===l?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:u);return r.jsx(t,{...i,ref:o,children:m.isValidElement(d)?m.cloneElement(d,void 0,f):null})}return r.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function Uk(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Hk(o),c=qk(a,o.props);return o.type!==m.Fragment&&(c.ref=s?qn(s,i):i),m.cloneElement(o,c)}return m.Children.count(o)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Vk=Symbol("radix.slottable");function Wk(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Vk}function qk(e,t){const n={...t};for(const s in t){const o=e[s],a=t[s];/^on[A-Z]/.test(s)?o&&a?n[s]=(...c)=>{const l=a(...c);return o(...c),l}:o&&(n[s]=o):s==="style"?n[s]={...o,...a}:s==="className"&&(n[s]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function Hk(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Os="Dialog",[vu]=an(Os),[Zk,It]=vu(Os),yu=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,c=m.useRef(null),l=m.useRef(null),[d,f]=rn({prop:s,defaultProp:o??!1,onChange:a,caller:Os});return r.jsx(Zk,{scope:t,triggerRef:c,contentRef:l,contentId:Dt(),titleId:Dt(),descriptionId:Dt(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:n})};yu.displayName=Os;var bu="DialogTrigger",wu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(bu,n),a=Se(t,o.triggerRef);return r.jsx(he.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Oa(o.open),...s,ref:a,onClick:xe(e.onClick,o.onOpenToggle)})});wu.displayName=bu;var Pa="DialogPortal",[Gk,ku]=vu(Pa,{forceMount:void 0}),_u=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=It(Pa,t);return r.jsx(Gk,{scope:t,forceMount:n,children:m.Children.map(s,i=>r.jsx(Kn,{present:n||a.open,children:r.jsx(Ea,{asChild:!0,container:o,children:i})}))})};_u.displayName=Pa;var gs="DialogOverlay",ju=m.forwardRef((e,t)=>{const n=ku(gs,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=It(gs,e.__scopeDialog);return a.modal?r.jsx(Kn,{present:s||a.open,children:r.jsx(Qk,{...o,ref:t})}):null});ju.displayName=gs;var Yk=Bk("DialogOverlay.RemoveScroll"),Qk=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(gs,n);return r.jsx(Ia,{as:Yk,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(he.div,{"data-state":Oa(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),bn="DialogContent",Su=m.forwardRef((e,t)=>{const n=ku(bn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=It(bn,e.__scopeDialog);return r.jsx(Kn,{present:s||a.open,children:a.modal?r.jsx(Kk,{...o,ref:t}):r.jsx(Jk,{...o,ref:t})})});Su.displayName=bn;var Kk=m.forwardRef((e,t)=>{const n=It(bn,e.__scopeDialog),s=m.useRef(null),o=Se(t,n.contentRef,s);return m.useEffect(()=>{const a=s.current;if(a)return Dd(a)},[]),r.jsx(Cu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:xe(e.onFocusOutside,a=>a.preventDefault())})}),Jk=m.forwardRef((e,t)=>{const n=It(bn,e.__scopeDialog),s=m.useRef(!1),o=m.useRef(!1);return r.jsx(Cu,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(s.current||n.triggerRef.current?.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;n.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),Cu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=It(bn,n),l=m.useRef(null),d=Se(t,l);return ud(),r.jsxs(r.Fragment,{children:[r.jsx(ba,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(ya,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Oa(c.open),...i,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(Xk,{titleId:c.titleId}),r.jsx(t_,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Ra="DialogTitle",Nu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(Ra,n);return r.jsx(he.h2,{id:o.titleId,...s,ref:t})});Nu.displayName=Ra;var Au="DialogDescription",Eu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(Au,n);return r.jsx(he.p,{id:o.descriptionId,...s,ref:t})});Eu.displayName=Au;var Iu="DialogClose",Tu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=It(Iu,n);return r.jsx(he.button,{type:"button",...s,ref:t,onClick:xe(e.onClick,()=>o.onOpenChange(!1))})});Tu.displayName=Iu;function Oa(e){return e?"open":"closed"}var Pu="DialogTitleWarning",[US,Ru]=oy(Pu,{contentName:bn,titleName:Ra,docsSlug:"dialog"}),Xk=({titleId:e})=>{const t=Ru(Pu),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
80
|
+
|
|
81
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
82
|
+
|
|
83
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},e_="DialogDescriptionWarning",t_=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ru(e_).contentName}}.`;return m.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Ou=yu,Mu=wu,Lu=_u,Ms=ju,Ls=Su,Ds=Nu,$s=Eu,Du=Tu;const Ma=Ou,n_=Mu,$u=Lu,r_=Du,La=m.forwardRef(({className:e,...t},n)=>r.jsx(Ms,{ref:n,className:O("fixed inset-0 z-50 bg-neutral-950/40 backdrop-blur-sm transition-opacity data-[state=closed]:opacity-0 data-[state=open]:opacity-100",e),...t}));La.displayName=Ms.displayName;const zs=m.forwardRef(({className:e,children:t,...n},s)=>r.jsxs($u,{children:[r.jsx(La,{}),r.jsx(Ls,{ref:s,className:O("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border border-neutral-200 bg-white p-6 shadow-lg outline-none transition data-[state=closed]:opacity-0 data-[state=closed]:scale-95 data-[state=open]:opacity-100 data-[state=open]:scale-100 dark:border-neutral-800 dark:bg-neutral-950","rounded-2xl",e),...n,children:t})]}));zs.displayName=Ls.displayName;const Da=({className:e,...t})=>r.jsx("div",{className:O("flex flex-col space-y-2 text-center sm:text-left",e),...t}),zu=({className:e,...t})=>r.jsx("div",{className:O("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),Fs=m.forwardRef(({className:e,...t},n)=>r.jsx(Ds,{ref:n,className:O("text-lg font-semibold leading-none tracking-tight",e),...t}));Fs.displayName=Ds.displayName;const $a=m.forwardRef(({className:e,...t},n)=>r.jsx($s,{ref:n,className:O("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));$a.displayName=$s.displayName;const Bs=Ou,Us=Mu,Fu=Du,Bu=Lu,za=m.forwardRef(({className:e,...t},n)=>r.jsx(Ms,{ref:n,className:O("fixed inset-0 z-50 bg-neutral-950/40 backdrop-blur-sm transition-opacity data-[state=closed]:opacity-0 data-[state=open]:opacity-100",e),...t}));za.displayName=Ms.displayName;const s_=ga("fixed z-50 gap-4 bg-white p-6 shadow-lg outline-none transition duration-200 ease-out dark:bg-neutral-950",{variants:{side:{top:"inset-x-0 top-0 border-b border-neutral-200 data-[state=closed]:-translate-y-full data-[state=open]:translate-y-0 dark:border-neutral-800",bottom:"inset-x-0 bottom-0 border-t border-neutral-200 data-[state=closed]:translate-y-full data-[state=open]:translate-y-0 dark:border-neutral-800",left:"inset-y-0 left-0 h-full w-3/4 border-r border-neutral-200 data-[state=closed]:-translate-x-full data-[state=open]:translate-x-0 sm:max-w-sm dark:border-neutral-800",right:"inset-y-0 right-0 h-full w-3/4 border-l border-neutral-200 data-[state=closed]:translate-x-full data-[state=open]:translate-x-0 sm:max-w-sm dark:border-neutral-800",popup:"bottom-4 right-4 w-[420px] max-w-[calc(100vw-2rem)] max-h-[calc(100vh-2rem)] overflow-hidden rounded-2xl border border-neutral-200 p-4 data-[state=closed]:translate-y-2 data-[state=open]:translate-y-0 data-[state=closed]:opacity-0 data-[state=open]:opacity-100 data-[state=closed]:scale-95 data-[state=open]:scale-100 dark:border-neutral-800"}},defaultVariants:{side:"right"}}),Er=m.forwardRef(({side:e="right",className:t,children:n,overlayClassName:s,...o},a)=>r.jsxs(Bu,{children:[r.jsx(za,{className:s}),r.jsx(Ls,{ref:a,className:O(s_({side:e}),t),...o,children:n})]}));Er.displayName=Ls.displayName;const Vs=({className:e,...t})=>r.jsx("div",{className:O("flex flex-col space-y-2 text-left",e),...t}),Ws=m.forwardRef(({className:e,...t},n)=>r.jsx(Ds,{ref:n,className:O("text-lg font-semibold leading-none tracking-tight",e),...t}));Ws.displayName=Ds.displayName;const Uu=m.forwardRef(({className:e,...t},n)=>r.jsx($s,{ref:n,className:O("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Uu.displayName=$s.displayName;var qs="Collapsible",[o_,Vu]=an(qs),[a_,Fa]=o_(qs),Wu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:o,disabled:a,onOpenChange:i,...c}=e,[l,d]=rn({prop:s,defaultProp:o??!1,onChange:i,caller:qs});return r.jsx(a_,{scope:n,disabled:a,contentId:Dt(),open:l,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),children:r.jsx(he.div,{"data-state":Ua(l),"data-disabled":a?"":void 0,...c,ref:t})})});Wu.displayName=qs;var qu="CollapsibleTrigger",Hu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,o=Fa(qu,n);return r.jsx(he.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Ua(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:xe(e.onClick,o.onOpenToggle)})});Hu.displayName=qu;var Ba="CollapsibleContent",Zu=m.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Fa(Ba,e.__scopeCollapsible);return r.jsx(Kn,{present:n||o.open,children:({present:a})=>r.jsx(i_,{...s,ref:t,present:a})})});Zu.displayName=Ba;var i_=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:o,...a}=e,i=Fa(Ba,n),[c,l]=m.useState(s),d=m.useRef(null),f=Se(t,d),u=m.useRef(0),g=u.current,p=m.useRef(0),x=p.current,h=i.open||c,v=m.useRef(h),y=m.useRef(void 0);return m.useEffect(()=>{const k=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(k)},[]),Ye(()=>{const k=d.current;if(k){y.current=y.current||{transitionDuration:k.style.transitionDuration,animationName:k.style.animationName},k.style.transitionDuration="0s",k.style.animationName="none";const _=k.getBoundingClientRect();u.current=_.height,p.current=_.width,v.current||(k.style.transitionDuration=y.current.transitionDuration,k.style.animationName=y.current.animationName),l(s)}},[i.open,s]),r.jsx(he.div,{"data-state":Ua(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!h,...a,ref:f,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":x?`${x}px`:void 0,...e.style},children:h&&o})});function Ua(e){return e?"open":"closed"}var c_=Wu,l_=Hu,d_=Zu,Tt="Accordion",u_=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Va,f_,m_]=va(Tt),[Hs]=an(Tt,[m_,Vu]),Wa=Vu(),Gu=w.forwardRef((e,t)=>{const{type:n,...s}=e,o=s,a=s;return r.jsx(Va.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?r.jsx(x_,{...a,ref:t}):r.jsx(g_,{...o,ref:t})})});Gu.displayName=Tt;var[Yu,p_]=Hs(Tt),[Qu,h_]=Hs(Tt,{collapsible:!1}),g_=w.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:o=()=>{},collapsible:a=!1,...i}=e,[c,l]=rn({prop:n,defaultProp:s??"",onChange:o,caller:Tt});return r.jsx(Yu,{scope:e.__scopeAccordion,value:w.useMemo(()=>c?[c]:[],[c]),onItemOpen:l,onItemClose:w.useCallback(()=>a&&l(""),[a,l]),children:r.jsx(Qu,{scope:e.__scopeAccordion,collapsible:a,children:r.jsx(Ku,{...i,ref:t})})})}),x_=w.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:o=()=>{},...a}=e,[i,c]=rn({prop:n,defaultProp:s??[],onChange:o,caller:Tt}),l=w.useCallback(f=>c((u=[])=>[...u,f]),[c]),d=w.useCallback(f=>c((u=[])=>u.filter(g=>g!==f)),[c]);return r.jsx(Yu,{scope:e.__scopeAccordion,value:i,onItemOpen:l,onItemClose:d,children:r.jsx(Qu,{scope:e.__scopeAccordion,collapsible:!0,children:r.jsx(Ku,{...a,ref:t})})})}),[v_,Zs]=Hs(Tt),Ku=w.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:s,dir:o,orientation:a="vertical",...i}=e,c=w.useRef(null),l=Se(c,t),d=f_(n),u=Ss(o)==="ltr",g=xe(e.onKeyDown,p=>{if(!u_.includes(p.key))return;const x=p.target,h=d().filter(A=>!A.ref.current?.disabled),v=h.findIndex(A=>A.ref.current===x),y=h.length;if(v===-1)return;p.preventDefault();let k=v;const _=0,b=y-1,j=()=>{k=v+1,k>b&&(k=_)},N=()=>{k=v-1,k<_&&(k=b)};switch(p.key){case"Home":k=_;break;case"End":k=b;break;case"ArrowRight":a==="horizontal"&&(u?j():N());break;case"ArrowDown":a==="vertical"&&j();break;case"ArrowLeft":a==="horizontal"&&(u?N():j());break;case"ArrowUp":a==="vertical"&&N();break}const T=k%y;h[T].ref.current?.focus()});return r.jsx(v_,{scope:n,disabled:s,direction:o,orientation:a,children:r.jsx(Va.Slot,{scope:n,children:r.jsx(he.div,{...i,"data-orientation":a,ref:l,onKeyDown:s?void 0:g})})})}),xs="AccordionItem",[y_,qa]=Hs(xs),Ju=w.forwardRef((e,t)=>{const{__scopeAccordion:n,value:s,...o}=e,a=Zs(xs,n),i=p_(xs,n),c=Wa(n),l=Dt(),d=s&&i.value.includes(s)||!1,f=a.disabled||e.disabled;return r.jsx(y_,{scope:n,open:d,disabled:f,triggerId:l,children:r.jsx(c_,{"data-orientation":a.orientation,"data-state":sf(d),...c,...o,ref:t,disabled:f,open:d,onOpenChange:u=>{u?i.onItemOpen(s):i.onItemClose(s)}})})});Ju.displayName=xs;var Xu="AccordionHeader",ef=w.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Zs(Tt,n),a=qa(Xu,n);return r.jsx(he.h3,{"data-orientation":o.orientation,"data-state":sf(a.open),"data-disabled":a.disabled?"":void 0,...s,ref:t})});ef.displayName=Xu;var Zo="AccordionTrigger",tf=w.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Zs(Tt,n),a=qa(Zo,n),i=h_(Zo,n),c=Wa(n);return r.jsx(Va.ItemSlot,{scope:n,children:r.jsx(l_,{"aria-disabled":a.open&&!i.collapsible||void 0,"data-orientation":o.orientation,id:a.triggerId,...c,...s,ref:t})})});tf.displayName=Zo;var nf="AccordionContent",rf=w.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Zs(Tt,n),a=qa(nf,n),i=Wa(n);return r.jsx(d_,{role:"region","aria-labelledby":a.triggerId,"data-orientation":o.orientation,...i,...s,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});rf.displayName=nf;function sf(e){return e?"open":"closed"}var b_=Gu,of=Ju,w_=ef,af=tf,cf=rf;const lf=b_,ur=m.forwardRef(({className:e,...t},n)=>r.jsx(of,{ref:n,className:O("border-b border-neutral-200 dark:border-neutral-800",e),...t}));ur.displayName=of.displayName;const fr=m.forwardRef(({className:e,children:t,...n},s)=>r.jsx(w_,{className:"flex",children:r.jsxs(af,{ref:s,className:O("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline",e),...n,children:[t,r.jsx("span",{className:"ml-3 text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"▾"})]})}));fr.displayName=af.displayName;const mr=m.forwardRef(({className:e,children:t,...n},s)=>r.jsx(cf,{ref:s,className:O("overflow-hidden text-sm",e),...n,children:r.jsx("div",{className:"pb-4 pt-0",children:t})}));mr.displayName=cf.displayName;var bo="rovingFocusGroup.onEntryFocus",k_={bubbles:!1,cancelable:!0},Ir="RovingFocusGroup",[Go,df,__]=va(Ir),[j_,uf]=an(Ir,[__]),[S_,C_]=j_(Ir),ff=m.forwardRef((e,t)=>r.jsx(Go.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Go.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(N_,{...e,ref:t})})}));ff.displayName=Ir;var N_=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:s,loop:o=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...u}=e,g=m.useRef(null),p=Se(t,g),x=Ss(a),[h,v]=rn({prop:i,defaultProp:c??null,onChange:l,caller:Ir}),[y,k]=m.useState(!1),_=en(d),b=df(n),j=m.useRef(!1),[N,T]=m.useState(0);return m.useEffect(()=>{const A=g.current;if(A)return A.addEventListener(bo,_),()=>A.removeEventListener(bo,_)},[_]),r.jsx(S_,{scope:n,orientation:s,dir:x,loop:o,currentTabStopId:h,onItemFocus:m.useCallback(A=>v(A),[v]),onItemShiftTab:m.useCallback(()=>k(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>T(A=>A-1),[]),children:r.jsx(he.div,{tabIndex:y||N===0?-1:0,"data-orientation":s,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{j.current=!0}),onFocus:xe(e.onFocus,A=>{const E=!j.current;if(A.target===A.currentTarget&&E&&!y){const P=new CustomEvent(bo,k_);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const F=b().filter(B=>B.focusable),L=F.find(B=>B.active),U=F.find(B=>B.id===h),Y=[L,U,...F].filter(Boolean).map(B=>B.ref.current);hf(Y,f)}}j.current=!1}),onBlur:xe(e.onBlur,()=>k(!1))})})}),mf="RovingFocusGroupItem",pf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,l=Dt(),d=a||l,f=C_(mf,n),u=f.currentTabStopId===d,g=df(n),{onFocusableItemAdd:p,onFocusableItemRemove:x,currentTabStopId:h}=f;return m.useEffect(()=>{if(s)return p(),()=>x()},[s,p,x]),r.jsx(Go.ItemSlot,{scope:n,id:d,focusable:s,active:o,children:r.jsx(he.span,{tabIndex:u?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:xe(e.onMouseDown,v=>{s?f.onItemFocus(d):v.preventDefault()}),onFocus:xe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:xe(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){f.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=I_(v,f.orientation,f.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let _=g().filter(b=>b.focusable).map(b=>b.ref.current);if(y==="last")_.reverse();else if(y==="prev"||y==="next"){y==="prev"&&_.reverse();const b=_.indexOf(v.currentTarget);_=f.loop?T_(_,b+1):_.slice(b+1)}setTimeout(()=>hf(_))}}),children:typeof i=="function"?i({isCurrentTabStop:u,hasTabStop:h!=null}):i})})});pf.displayName=mf;var A_={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function E_(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function I_(e,t,n){const s=E_(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return A_[s]}function hf(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function T_(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var P_=ff,R_=pf,Gs="Tabs",[O_]=an(Gs,[uf]),gf=uf(),[M_,Ha]=O_(Gs),xf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:l="automatic",...d}=e,f=Ss(c),[u,g]=rn({prop:s,onChange:o,defaultProp:a??"",caller:Gs});return r.jsx(M_,{scope:n,baseId:Dt(),value:u,onValueChange:g,orientation:i,dir:f,activationMode:l,children:r.jsx(he.div,{dir:f,"data-orientation":i,...d,ref:t})})});xf.displayName=Gs;var vf="TabsList",yf=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Ha(vf,n),i=gf(n);return r.jsx(P_,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(he.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});yf.displayName=vf;var bf="TabsTrigger",wf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=Ha(bf,n),c=gf(n),l=jf(i.baseId,s),d=Sf(i.baseId,s),f=s===i.value;return r.jsx(R_,{asChild:!0,...c,focusable:!o,active:f,children:r.jsx(he.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...a,ref:t,onMouseDown:xe(e.onMouseDown,u=>{!o&&u.button===0&&u.ctrlKey===!1?i.onValueChange(s):u.preventDefault()}),onKeyDown:xe(e.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&i.onValueChange(s)}),onFocus:xe(e.onFocus,()=>{const u=i.activationMode!=="manual";!f&&!o&&u&&i.onValueChange(s)})})})});wf.displayName=bf;var kf="TabsContent",_f=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=Ha(kf,n),l=jf(c.baseId,s),d=Sf(c.baseId,s),f=s===c.value,u=m.useRef(f);return m.useEffect(()=>{const g=requestAnimationFrame(()=>u.current=!1);return()=>cancelAnimationFrame(g)},[]),r.jsx(Kn,{present:o||f,children:({present:g})=>r.jsx(he.div,{"data-state":f?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":l,hidden:!g,id:d,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:u.current?"0s":void 0},children:g&&a})})});_f.displayName=kf;function jf(e,t){return`${e}-trigger-${t}`}function Sf(e,t){return`${e}-content-${t}`}var L_=xf,Cf=yf,Nf=wf,Af=_f;const Za=L_,Ys=m.forwardRef(({className:e,...t},n)=>r.jsx(Cf,{ref:n,className:O("inline-flex h-10 items-center justify-center rounded-md bg-neutral-100 p-1 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400",e),...t}));Ys.displayName=Cf.displayName;const _r=m.forwardRef(({className:e,...t},n)=>r.jsx(Nf,{ref:n,className:O("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-white data-[state=active]:text-neutral-950 data-[state=active]:shadow-sm dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-50/20 dark:data-[state=active]:bg-neutral-950 dark:data-[state=active]:text-neutral-50",e),...t}));_r.displayName=Nf.displayName;const Ef=m.forwardRef(({className:e,...t},n)=>r.jsx(Af,{ref:n,className:O("mt-2 ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 dark:ring-offset-neutral-950 dark:focus-visible:ring-neutral-50/20",e),...t}));Ef.displayName=Af.displayName;function Un({title:e,description:t,actionLabel:n,onAction:s,className:o}){return r.jsx("div",{className:O("flex flex-col items-center justify-center rounded-xl border border-neutral-200 bg-white p-10 text-center dark:border-neutral-800 dark:bg-neutral-950",o),children:r.jsxs("div",{className:"max-w-sm",children:[r.jsx("h3",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:e}),t?r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}):null,n&&s?r.jsx("div",{className:"mt-5",children:r.jsx(X,{type:"button",onClick:s,variant:"secondary",children:n})}):null]})})}function zt({title:e,description:t,onRetry:n,className:s}){return r.jsxs("div",{className:O("rounded-xl border border-neutral-200 bg-white p-6 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",s),children:[r.jsx("h3",{className:"text-sm font-semibold",children:e??"Something went wrong"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:t}),n?r.jsx("div",{className:"mt-4",children:r.jsx(X,{type:"button",variant:"outline",onClick:n,children:"Try again"})}):null]})}class D_ extends m.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error):r.jsx(zt,{description:this.state.error.message}):this.props.children}}function $_(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const z_=e=>{switch(e){case"success":return U_;case"info":return W_;case"warning":return V_;case"error":return q_;default:return null}},F_=Array(12).fill(0),B_=({visible:e,className:t})=>w.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},w.createElement("div",{className:"sonner-spinner"},F_.map((n,s)=>w.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),U_=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),V_=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),W_=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),q_=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),H_=w.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Z_=()=>{const[e,t]=w.useState(document.hidden);return w.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Yo=1;class G_{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:s,...o}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Yo++,i=this.toasts.find(l=>l.id===a),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:s}),{...l,...t,id:a,dismissible:c,title:s}):l):this.addToast({title:s,...o,dismissible:c,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(s=>s({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let s;n.loading!==void 0&&(s=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const o=Promise.resolve(t instanceof Function?t():t);let a=s!==void 0,i;const c=o.then(async d=>{if(i=["resolve",d],w.isValidElement(d))a=!1,this.create({id:s,type:"default",message:d});else if(Q_(d)&&!d.ok){a=!1;const u=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,x=typeof u=="object"&&!w.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:g,...x})}else if(d instanceof Error){a=!1;const u=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,x=typeof u=="object"&&!w.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:g,...x})}else if(n.success!==void 0){a=!1;const u=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,x=typeof u=="object"&&!w.isValidElement(u)?u:{message:u};this.create({id:s,type:"success",description:g,...x})}}).catch(async d=>{if(i=["reject",d],n.error!==void 0){a=!1;const f=typeof n.error=="function"?await n.error(d):n.error,u=typeof n.description=="function"?await n.description(d):n.description,p=typeof f=="object"&&!w.isValidElement(f)?f:{message:f};this.create({id:s,type:"error",description:u,...p})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((d,f)=>c.then(()=>i[0]==="reject"?f(i[1]):d(i[1])).catch(f));return typeof s!="string"&&typeof s!="number"?{unwrap:l}:Object.assign(s,{unwrap:l})},this.custom=(t,n)=>{const s=n?.id||Yo++;return this.create({jsx:t(s),id:s,...n}),s},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const ct=new G_,Y_=(e,t)=>{const n=t?.id||Yo++;return ct.addToast({title:e,...t,id:n}),n},Q_=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",K_=Y_,J_=()=>ct.toasts,X_=()=>ct.getActiveToasts(),ej=Object.assign(K_,{success:ct.success,info:ct.info,warning:ct.warning,error:ct.error,custom:ct.custom,message:ct.message,promise:ct.promise,dismiss:ct.dismiss,loading:ct.loading},{getHistory:J_,getToasts:X_});$_("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Wr(e){return e.label!==void 0}const tj=3,nj="24px",rj="16px",Cc=4e3,sj=356,oj=14,aj=45,ij=200;function Rt(...e){return e.filter(Boolean).join(" ")}function cj(e){const[t,n]=e.split("-"),s=[];return t&&s.push(t),n&&s.push(n),s}const lj=e=>{var t,n,s,o,a,i,c,l,d;const{invert:f,toast:u,unstyled:g,interacting:p,setHeights:x,visibleToasts:h,heights:v,index:y,toasts:k,expanded:_,removeToast:b,defaultRichColors:j,closeButton:N,style:T,cancelButtonStyle:A,actionButtonStyle:E,className:P="",descriptionClassName:F="",duration:L,position:U,gap:$,expandByDefault:Y,classNames:B,icons:H,closeButtonAriaLabel:D="Close toast"}=e,[C,I]=w.useState(null),[Z,ve]=w.useState(null),[V,Q]=w.useState(!1),[K,le]=w.useState(!1),[R,G]=w.useState(!1),[ue,W]=w.useState(!1),[se,ie]=w.useState(!1),[ye,fe]=w.useState(0),[Ue,Qe]=w.useState(0),Ve=w.useRef(u.duration||L||Cc),M=w.useRef(null),ee=w.useRef(null),ce=y===0,_e=y+1<=h,be=u.type,Me=u.dismissible!==!1,Jn=u.className||"",dn=u.descriptionClassName||"",kt=w.useMemo(()=>v.findIndex(de=>de.toastId===u.id)||0,[v,u.id]),xt=w.useMemo(()=>{var de;return(de=u.closeButton)!=null?de:N},[u.closeButton,N]),kn=w.useMemo(()=>u.duration||L||Cc,[u.duration,L]),_n=w.useRef(0),Ut=w.useRef(0),jn=w.useRef(0),Vt=w.useRef(null),[Sn,Cn]=U.split("-"),vt=w.useMemo(()=>v.reduce((de,Le,ge)=>ge>=kt?de:de+Le.height,0),[v,kt]),Wt=Z_(),Xn=u.invert||f,un=be==="loading";Ut.current=w.useMemo(()=>kt*$+vt,[kt,vt]),w.useEffect(()=>{Ve.current=kn},[kn]),w.useEffect(()=>{Q(!0)},[]),w.useEffect(()=>{const de=ee.current;if(de){const Le=de.getBoundingClientRect().height;return Qe(Le),x(ge=>[{toastId:u.id,height:Le,position:u.position},...ge]),()=>x(ge=>ge.filter(De=>De.toastId!==u.id))}},[x,u.id]),w.useLayoutEffect(()=>{if(!V)return;const de=ee.current,Le=de.style.height;de.style.height="auto";const ge=de.getBoundingClientRect().height;de.style.height=Le,Qe(ge),x(De=>De.find($e=>$e.toastId===u.id)?De.map($e=>$e.toastId===u.id?{...$e,height:ge}:$e):[{toastId:u.id,height:ge,position:u.position},...De])},[V,u.title,u.description,x,u.id,u.jsx,u.action,u.cancel]);const Pt=w.useCallback(()=>{le(!0),fe(Ut.current),x(de=>de.filter(Le=>Le.toastId!==u.id)),setTimeout(()=>{b(u)},ij)},[u,b,x,Ut]);w.useEffect(()=>{if(u.promise&&be==="loading"||u.duration===1/0||u.type==="loading")return;let de;return _||p||Wt?(()=>{if(jn.current<_n.current){const De=new Date().getTime()-_n.current;Ve.current=Ve.current-De}jn.current=new Date().getTime()})():(()=>{Ve.current!==1/0&&(_n.current=new Date().getTime(),de=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Pt()},Ve.current))})(),()=>clearTimeout(de)},[_,p,u,be,Wt,Pt]),w.useEffect(()=>{u.delete&&(Pt(),u.onDismiss==null||u.onDismiss.call(u,u))},[Pt,u.delete]);function Nn(){var de;if(H?.loading){var Le;return w.createElement("div",{className:Rt(B?.loader,u==null||(Le=u.classNames)==null?void 0:Le.loader,"sonner-loader"),"data-visible":be==="loading"},H.loading)}return w.createElement(B_,{className:Rt(B?.loader,u==null||(de=u.classNames)==null?void 0:de.loader),visible:be==="loading"})}const An=u.icon||H?.[be]||z_(be);var Tr,Kt;return w.createElement("li",{tabIndex:0,ref:ee,className:Rt(P,Jn,B?.toast,u==null||(t=u.classNames)==null?void 0:t.toast,B?.default,B?.[be],u==null||(n=u.classNames)==null?void 0:n[be]),"data-sonner-toast":"","data-rich-colors":(Tr=u.richColors)!=null?Tr:j,"data-styled":!(u.jsx||u.unstyled||g),"data-mounted":V,"data-promise":!!u.promise,"data-swiped":se,"data-removed":K,"data-visible":_e,"data-y-position":Sn,"data-x-position":Cn,"data-index":y,"data-front":ce,"data-swiping":R,"data-dismissible":Me,"data-type":be,"data-invert":Xn,"data-swipe-out":ue,"data-swipe-direction":Z,"data-expanded":!!(_||Y&&V),"data-testid":u.testId,style:{"--index":y,"--toasts-before":y,"--z-index":k.length-y,"--offset":`${K?ye:Ut.current}px`,"--initial-height":Y?"auto":`${Ue}px`,...T,...u.style},onDragEnd:()=>{G(!1),I(null),Vt.current=null},onPointerDown:de=>{de.button!==2&&(un||!Me||(M.current=new Date,fe(Ut.current),de.target.setPointerCapture(de.pointerId),de.target.tagName!=="BUTTON"&&(G(!0),Vt.current={x:de.clientX,y:de.clientY})))},onPointerUp:()=>{var de,Le,ge;if(ue||!Me)return;Vt.current=null;const De=Number(((de=ee.current)==null?void 0:de.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),En=Number(((Le=ee.current)==null?void 0:Le.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),$e=new Date().getTime()-((ge=M.current)==null?void 0:ge.getTime()),Ke=C==="x"?De:En,fn=Math.abs(Ke)/$e;if(Math.abs(Ke)>=aj||fn>.11){fe(Ut.current),u.onDismiss==null||u.onDismiss.call(u,u),ve(C==="x"?De>0?"right":"left":En>0?"down":"up"),Pt(),W(!0);return}else{var at,ut;(at=ee.current)==null||at.style.setProperty("--swipe-amount-x","0px"),(ut=ee.current)==null||ut.style.setProperty("--swipe-amount-y","0px")}ie(!1),G(!1),I(null)},onPointerMove:de=>{var Le,ge,De;if(!Vt.current||!Me||((Le=window.getSelection())==null?void 0:Le.toString().length)>0)return;const $e=de.clientY-Vt.current.y,Ke=de.clientX-Vt.current.x;var fn;const at=(fn=e.swipeDirections)!=null?fn:cj(U);!C&&(Math.abs(Ke)>1||Math.abs($e)>1)&&I(Math.abs(Ke)>Math.abs($e)?"x":"y");let ut={x:0,y:0};const ft=et=>1/(1.5+Math.abs(et)/20);if(C==="y"){if(at.includes("top")||at.includes("bottom"))if(at.includes("top")&&$e<0||at.includes("bottom")&&$e>0)ut.y=$e;else{const et=$e*ft($e);ut.y=Math.abs(et)<Math.abs($e)?et:$e}}else if(C==="x"&&(at.includes("left")||at.includes("right")))if(at.includes("left")&&Ke<0||at.includes("right")&&Ke>0)ut.x=Ke;else{const et=Ke*ft(Ke);ut.x=Math.abs(et)<Math.abs(Ke)?et:Ke}(Math.abs(ut.x)>0||Math.abs(ut.y)>0)&&ie(!0),(ge=ee.current)==null||ge.style.setProperty("--swipe-amount-x",`${ut.x}px`),(De=ee.current)==null||De.style.setProperty("--swipe-amount-y",`${ut.y}px`)}},xt&&!u.jsx&&be!=="loading"?w.createElement("button",{"aria-label":D,"data-disabled":un,"data-close-button":!0,onClick:un||!Me?()=>{}:()=>{Pt(),u.onDismiss==null||u.onDismiss.call(u,u)},className:Rt(B?.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(Kt=H?.close)!=null?Kt:H_):null,(be||u.icon||u.promise)&&u.icon!==null&&(H?.[be]!==null||u.icon)?w.createElement("div",{"data-icon":"",className:Rt(B?.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||Nn():null,u.type!=="loading"?An:null):null,w.createElement("div",{"data-content":"",className:Rt(B?.content,u==null||(a=u.classNames)==null?void 0:a.content)},w.createElement("div",{"data-title":"",className:Rt(B?.title,u==null||(i=u.classNames)==null?void 0:i.title)},u.jsx?u.jsx:typeof u.title=="function"?u.title():u.title),u.description?w.createElement("div",{"data-description":"",className:Rt(F,dn,B?.description,u==null||(c=u.classNames)==null?void 0:c.description)},typeof u.description=="function"?u.description():u.description):null),w.isValidElement(u.cancel)?u.cancel:u.cancel&&Wr(u.cancel)?w.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||A,onClick:de=>{Wr(u.cancel)&&Me&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,de),Pt())},className:Rt(B?.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,w.isValidElement(u.action)?u.action:u.action&&Wr(u.action)?w.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||E,onClick:de=>{Wr(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,de),!de.defaultPrevented&&Pt())},className:Rt(B?.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function Nc(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function dj(e,t){const n={};return[e,t].forEach((s,o)=>{const a=o===1,i=a?"--mobile-offset":"--offset",c=a?rj:nj;function l(d){["top","right","bottom","left"].forEach(f=>{n[`${i}-${f}`]=typeof d=="number"?`${d}px`:d})}typeof s=="number"||typeof s=="string"?l(s):typeof s=="object"?["top","right","bottom","left"].forEach(d=>{s[d]===void 0?n[`${i}-${d}`]=c:n[`${i}-${d}`]=typeof s[d]=="number"?`${s[d]}px`:s[d]}):l(c)}),n}const uj=w.forwardRef(function(t,n){const{id:s,invert:o,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:c,closeButton:l,className:d,offset:f,mobileOffset:u,theme:g="light",richColors:p,duration:x,style:h,visibleToasts:v=tj,toastOptions:y,dir:k=Nc(),gap:_=oj,icons:b,containerAriaLabel:j="Notifications"}=t,[N,T]=w.useState([]),A=w.useMemo(()=>s?N.filter(V=>V.toasterId===s):N.filter(V=>!V.toasterId),[N,s]),E=w.useMemo(()=>Array.from(new Set([a].concat(A.filter(V=>V.position).map(V=>V.position)))),[A,a]),[P,F]=w.useState([]),[L,U]=w.useState(!1),[$,Y]=w.useState(!1),[B,H]=w.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=w.useRef(null),C=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=w.useRef(null),Z=w.useRef(!1),ve=w.useCallback(V=>{T(Q=>{var K;return(K=Q.find(le=>le.id===V.id))!=null&&K.delete||ct.dismiss(V.id),Q.filter(({id:le})=>le!==V.id)})},[]);return w.useEffect(()=>ct.subscribe(V=>{if(V.dismiss){requestAnimationFrame(()=>{T(Q=>Q.map(K=>K.id===V.id?{...K,delete:!0}:K))});return}setTimeout(()=>{ea.flushSync(()=>{T(Q=>{const K=Q.findIndex(le=>le.id===V.id);return K!==-1?[...Q.slice(0,K),{...Q[K],...V},...Q.slice(K+1)]:[V,...Q]})})})}),[N]),w.useEffect(()=>{if(g!=="system"){H(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window>"u")return;const V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:Q})=>{H(Q?"dark":"light")})}catch{V.addListener(({matches:K})=>{try{H(K?"dark":"light")}catch(le){console.error(le)}})}},[g]),w.useEffect(()=>{N.length<=1&&U(!1)},[N]),w.useEffect(()=>{const V=Q=>{var K;if(i.every(G=>Q[G]||Q.code===G)){var R;U(!0),(R=D.current)==null||R.focus()}Q.code==="Escape"&&(document.activeElement===D.current||(K=D.current)!=null&&K.contains(document.activeElement))&&U(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[i]),w.useEffect(()=>{if(D.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,Z.current=!1)}},[D.current]),w.createElement("section",{ref:n,"aria-label":`${j} ${C}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map((V,Q)=>{var K;const[le,R]=V.split("-");return A.length?w.createElement("ol",{key:V,dir:k==="auto"?Nc():k,tabIndex:-1,ref:D,className:d,"data-sonner-toaster":!0,"data-sonner-theme":B,"data-y-position":le,"data-x-position":R,style:{"--front-toast-height":`${((K=P[0])==null?void 0:K.height)||0}px`,"--width":`${sj}px`,"--gap":`${_}px`,...h,...dj(f,u)},onBlur:G=>{Z.current&&!G.currentTarget.contains(G.relatedTarget)&&(Z.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||Z.current||(Z.current=!0,I.current=G.relatedTarget)},onMouseEnter:()=>U(!0),onMouseMove:()=>U(!0),onMouseLeave:()=>{$||U(!1)},onDragEnd:()=>U(!1),onPointerDown:G=>{G.target instanceof HTMLElement&&G.target.dataset.dismissible==="false"||Y(!0)},onPointerUp:()=>Y(!1)},A.filter(G=>!G.position&&Q===0||G.position===V).map((G,ue)=>{var W,se;return w.createElement(lj,{key:G.id,icons:b,index:ue,toast:G,defaultRichColors:p,duration:(W=y?.duration)!=null?W:x,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:o,visibleToasts:v,closeButton:(se=y?.closeButton)!=null?se:l,interacting:$,position:V,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:ve,toasts:A.filter(ie=>ie.position==G.position),heights:P.filter(ie=>ie.position==G.position),setHeights:F,expandByDefault:c,gap:_,expanded:L,swipeDirections:t.swipeDirections})})):null}))}),Ga=m.createContext(null);function fj(){const e=m.useContext(Ga);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Qs(){return m.useContext(Ga)}function mj({children:e}){const t=m.useCallback(n=>{const s=n.title??"",o=n.description;ej(s||o||"Notification",{description:s?o:void 0,duration:n.durationMs??5e3,action:n.actionLabel&&n.onAction?{label:n.actionLabel,onClick:()=>n.onAction?.()}:void 0})},[]);return r.jsxs(Ga.Provider,{value:{toast:t},children:[e,r.jsx(uj,{position:"top-center",closeButton:!0,expand:!0,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:pointer-events-auto group-[.toaster]:w-full group-[.toaster]:rounded-xl group-[.toaster]:border group-[.toaster]:border-neutral-200 group-[.toaster]:bg-white group-[.toaster]:p-4 group-[.toaster]:shadow-lg dark:group-[.toaster]:border-neutral-800 dark:group-[.toaster]:bg-neutral-950",title:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",description:"text-sm text-neutral-600 dark:text-neutral-400",actionButton:"h-8 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-900 shadow-sm hover:bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:hover:bg-neutral-900",cancelButton:"h-8 rounded-md bg-neutral-100 px-3 text-xs font-medium text-neutral-900 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-50 dark:hover:bg-neutral-700",closeButton:"rounded-md text-neutral-600 opacity-0 transition-opacity hover:bg-neutral-100 hover:text-neutral-900 group-hover:opacity-100 dark:text-neutral-400 dark:hover:bg-neutral-800 dark:hover:text-neutral-50"}}})]})}const{entries:If,setPrototypeOf:Ac,isFrozen:pj,getPrototypeOf:hj,getOwnPropertyDescriptor:gj}=Object;let{freeze:st,seal:bt,create:es}=Object,{apply:Qo,construct:Ko}=typeof Reflect<"u"&&Reflect;st||(st=function(t){return t});bt||(bt=function(t){return t});Qo||(Qo=function(t,n){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];return t.apply(n,o)});Ko||(Ko=function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return new t(...s)});const qr=ot(Array.prototype.forEach),xj=ot(Array.prototype.lastIndexOf),Ec=ot(Array.prototype.pop),rr=ot(Array.prototype.push),vj=ot(Array.prototype.splice),ts=ot(String.prototype.toLowerCase),wo=ot(String.prototype.toString),ko=ot(String.prototype.match),sr=ot(String.prototype.replace),yj=ot(String.prototype.indexOf),bj=ot(String.prototype.trim),mt=ot(Object.prototype.hasOwnProperty),tt=ot(RegExp.prototype.test),or=wj(TypeError);function ot(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o<n;o++)s[o-1]=arguments[o];return Qo(e,t,s)}}function wj(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Ko(e,n)}}function pe(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ts;Ac&&Ac(e,null);let s=t.length;for(;s--;){let o=t[s];if(typeof o=="string"){const a=n(o);a!==o&&(pj(t)||(t[s]=a),o=a)}e[o]=!0}return e}function kj(e){for(let t=0;t<e.length;t++)mt(e,t)||(e[t]=null);return e}function Ot(e){const t=es(null);for(const[n,s]of If(e))mt(e,n)&&(Array.isArray(s)?t[n]=kj(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=Ot(s):t[n]=s);return t}function ar(e,t){for(;e!==null;){const s=gj(e,t);if(s){if(s.get)return ot(s.get);if(typeof s.value=="function")return ot(s.value)}e=hj(e)}function n(){return null}return n}const Ic=st(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),_o=st(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),jo=st(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_j=st(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),So=st(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),jj=st(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Tc=st(["#text"]),Pc=st(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Co=st(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Rc=st(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Hr=st(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Sj=bt(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Cj=bt(/<%[\w\W]*|[\w\W]*%>/gm),Nj=bt(/\$\{[\w\W]*/gm),Aj=bt(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ej=bt(/^aria-[\-\w]+$/),Tf=bt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ij=bt(/^(?:\w+script|data):/i),Tj=bt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pf=bt(/^html$/i),Pj=bt(/^[a-z][.\w]*(-[.\w]+)+$/i);var Oc=Object.freeze({__proto__:null,ARIA_ATTR:Ej,ATTR_WHITESPACE:Tj,CUSTOM_ELEMENT:Pj,DATA_ATTR:Aj,DOCTYPE_NAME:Pf,ERB_EXPR:Cj,IS_ALLOWED_URI:Tf,IS_SCRIPT_OR_DATA:Ij,MUSTACHE_EXPR:Sj,TMPLIT_EXPR:Nj});const ir={element:1,text:3,progressingInstruction:7,comment:8,document:9},Rj=function(){return typeof window>"u"?null:window},Oj=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let s=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(s=n.getAttribute(o));const a="dompurify"+(s?"#"+s:"");try{return t.createPolicy(a,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},Mc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Rf(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rj();const t=oe=>Rf(oe);if(t.version="3.3.2",t.removed=[],!e||!e.document||e.document.nodeType!==ir.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e;const s=n,o=s.currentScript,{DocumentFragment:a,HTMLTemplateElement:i,Node:c,Element:l,NodeFilter:d,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:u,DOMParser:g,trustedTypes:p}=e,x=l.prototype,h=ar(x,"cloneNode"),v=ar(x,"remove"),y=ar(x,"nextSibling"),k=ar(x,"childNodes"),_=ar(x,"parentNode");if(typeof i=="function"){const oe=n.createElement("template");oe.content&&oe.content.ownerDocument&&(n=oe.content.ownerDocument)}let b,j="";const{implementation:N,createNodeIterator:T,createDocumentFragment:A,getElementsByTagName:E}=n,{importNode:P}=s;let F=Mc();t.isSupported=typeof If=="function"&&typeof _=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:L,ERB_EXPR:U,TMPLIT_EXPR:$,DATA_ATTR:Y,ARIA_ATTR:B,IS_SCRIPT_OR_DATA:H,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:C}=Oc;let{IS_ALLOWED_URI:I}=Oc,Z=null;const ve=pe({},[...Ic,..._o,...jo,...So,...Tc]);let V=null;const Q=pe({},[...Pc,...Co,...Rc,...Hr]);let K=Object.seal(es(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),le=null,R=null;const G=Object.seal(es(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ue=!0,W=!0,se=!1,ie=!0,ye=!1,fe=!0,Ue=!1,Qe=!1,Ve=!1,M=!1,ee=!1,ce=!1,_e=!0,be=!1;const Me="user-content-";let Jn=!0,dn=!1,kt={},xt=null;const kn=pe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let _n=null;const Ut=pe({},["audio","video","img","source","image","track"]);let jn=null;const Vt=pe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Sn="http://www.w3.org/1998/Math/MathML",Cn="http://www.w3.org/2000/svg",vt="http://www.w3.org/1999/xhtml";let Wt=vt,Xn=!1,un=null;const Pt=pe({},[Sn,Cn,vt],wo);let Nn=pe({},["mi","mo","mn","ms","mtext"]),An=pe({},["annotation-xml"]);const Tr=pe({},["title","style","font","a","script"]);let Kt=null;const de=["application/xhtml+xml","text/html"],Le="text/html";let ge=null,De=null;const En=n.createElement("form"),$e=function(S){return S instanceof RegExp||S instanceof Function},Ke=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(De&&De===S)){if((!S||typeof S!="object")&&(S={}),S=Ot(S),Kt=de.indexOf(S.PARSER_MEDIA_TYPE)===-1?Le:S.PARSER_MEDIA_TYPE,ge=Kt==="application/xhtml+xml"?wo:ts,Z=mt(S,"ALLOWED_TAGS")?pe({},S.ALLOWED_TAGS,ge):ve,V=mt(S,"ALLOWED_ATTR")?pe({},S.ALLOWED_ATTR,ge):Q,un=mt(S,"ALLOWED_NAMESPACES")?pe({},S.ALLOWED_NAMESPACES,wo):Pt,jn=mt(S,"ADD_URI_SAFE_ATTR")?pe(Ot(Vt),S.ADD_URI_SAFE_ATTR,ge):Vt,_n=mt(S,"ADD_DATA_URI_TAGS")?pe(Ot(Ut),S.ADD_DATA_URI_TAGS,ge):Ut,xt=mt(S,"FORBID_CONTENTS")?pe({},S.FORBID_CONTENTS,ge):kn,le=mt(S,"FORBID_TAGS")?pe({},S.FORBID_TAGS,ge):Ot({}),R=mt(S,"FORBID_ATTR")?pe({},S.FORBID_ATTR,ge):Ot({}),kt=mt(S,"USE_PROFILES")?S.USE_PROFILES:!1,ue=S.ALLOW_ARIA_ATTR!==!1,W=S.ALLOW_DATA_ATTR!==!1,se=S.ALLOW_UNKNOWN_PROTOCOLS||!1,ie=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ye=S.SAFE_FOR_TEMPLATES||!1,fe=S.SAFE_FOR_XML!==!1,Ue=S.WHOLE_DOCUMENT||!1,M=S.RETURN_DOM||!1,ee=S.RETURN_DOM_FRAGMENT||!1,ce=S.RETURN_TRUSTED_TYPE||!1,Ve=S.FORCE_BODY||!1,_e=S.SANITIZE_DOM!==!1,be=S.SANITIZE_NAMED_PROPS||!1,Jn=S.KEEP_CONTENT!==!1,dn=S.IN_PLACE||!1,I=S.ALLOWED_URI_REGEXP||Tf,Wt=S.NAMESPACE||vt,Nn=S.MATHML_TEXT_INTEGRATION_POINTS||Nn,An=S.HTML_INTEGRATION_POINTS||An,K=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&$e(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(K.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&$e(S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(K.attributeNameCheck=S.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),S.CUSTOM_ELEMENT_HANDLING&&typeof S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(K.allowCustomizedBuiltInElements=S.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ye&&(W=!1),ee&&(M=!0),kt&&(Z=pe({},Tc),V=es(null),kt.html===!0&&(pe(Z,Ic),pe(V,Pc)),kt.svg===!0&&(pe(Z,_o),pe(V,Co),pe(V,Hr)),kt.svgFilters===!0&&(pe(Z,jo),pe(V,Co),pe(V,Hr)),kt.mathMl===!0&&(pe(Z,So),pe(V,Rc),pe(V,Hr))),mt(S,"ADD_TAGS")||(G.tagCheck=null),mt(S,"ADD_ATTR")||(G.attributeCheck=null),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?G.tagCheck=S.ADD_TAGS:(Z===ve&&(Z=Ot(Z)),pe(Z,S.ADD_TAGS,ge))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?G.attributeCheck=S.ADD_ATTR:(V===Q&&(V=Ot(V)),pe(V,S.ADD_ATTR,ge))),S.ADD_URI_SAFE_ATTR&&pe(jn,S.ADD_URI_SAFE_ATTR,ge),S.FORBID_CONTENTS&&(xt===kn&&(xt=Ot(xt)),pe(xt,S.FORBID_CONTENTS,ge)),S.ADD_FORBID_CONTENTS&&(xt===kn&&(xt=Ot(xt)),pe(xt,S.ADD_FORBID_CONTENTS,ge)),Jn&&(Z["#text"]=!0),Ue&&pe(Z,["html","head","body"]),Z.table&&(pe(Z,["tbody"]),delete le.tbody),S.TRUSTED_TYPES_POLICY){if(typeof S.TRUSTED_TYPES_POLICY.createHTML!="function")throw or('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof S.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw or('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');b=S.TRUSTED_TYPES_POLICY,j=b.createHTML("")}else b===void 0&&(b=Oj(p,o)),b!==null&&typeof j=="string"&&(j=b.createHTML(""));st&&st(S),De=S}},fn=pe({},[..._o,...jo,..._j]),at=pe({},[...So,...jj]),ut=function(S){let q=_(S);(!q||!q.tagName)&&(q={namespaceURI:Wt,tagName:"template"});const re=ts(S.tagName),je=ts(q.tagName);return un[S.namespaceURI]?S.namespaceURI===Cn?q.namespaceURI===vt?re==="svg":q.namespaceURI===Sn?re==="svg"&&(je==="annotation-xml"||Nn[je]):!!fn[re]:S.namespaceURI===Sn?q.namespaceURI===vt?re==="math":q.namespaceURI===Cn?re==="math"&&An[je]:!!at[re]:S.namespaceURI===vt?q.namespaceURI===Cn&&!An[je]||q.namespaceURI===Sn&&!Nn[je]?!1:!at[re]&&(Tr[re]||!fn[re]):!!(Kt==="application/xhtml+xml"&&un[S.namespaceURI]):!1},ft=function(S){rr(t.removed,{element:S});try{_(S).removeChild(S)}catch{v(S)}},et=function(S,q){try{rr(t.removed,{attribute:q.getAttributeNode(S),from:q})}catch{rr(t.removed,{attribute:null,from:q})}if(q.removeAttribute(S),S==="is")if(M||ee)try{ft(q)}catch{}else try{q.setAttribute(S,"")}catch{}},to=function(S){let q=null,re=null;if(Ve)S="<remove></remove>"+S;else{const ze=ko(S,/^[\r\n\t ]+/);re=ze&&ze[0]}Kt==="application/xhtml+xml"&&Wt===vt&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const je=b?b.createHTML(S):S;if(Wt===vt)try{q=new g().parseFromString(je,Kt)}catch{}if(!q||!q.documentElement){q=N.createDocument(Wt,"template",null);try{q.documentElement.innerHTML=Xn?j:je}catch{}}const Je=q.body||q.documentElement;return S&&re&&Je.insertBefore(n.createTextNode(re),Je.childNodes[0]||null),Wt===vt?E.call(q,Ue?"html":"body")[0]:Ue?q.documentElement:Je},ii=function(S){return T.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},no=function(S){return S instanceof u&&(typeof S.nodeName!="string"||typeof S.textContent!="string"||typeof S.removeChild!="function"||!(S.attributes instanceof f)||typeof S.removeAttribute!="function"||typeof S.setAttribute!="function"||typeof S.namespaceURI!="string"||typeof S.insertBefore!="function"||typeof S.hasChildNodes!="function")},ci=function(S){return typeof c=="function"&&S instanceof c};function qt(oe,S,q){qr(oe,re=>{re.call(t,S,q,De)})}const li=function(S){let q=null;if(qt(F.beforeSanitizeElements,S,null),no(S))return ft(S),!0;const re=ge(S.nodeName);if(qt(F.uponSanitizeElement,S,{tagName:re,allowedTags:Z}),fe&&S.hasChildNodes()&&!ci(S.firstElementChild)&&tt(/<[/\w!]/g,S.innerHTML)&&tt(/<[/\w!]/g,S.textContent)||S.nodeType===ir.progressingInstruction||fe&&S.nodeType===ir.comment&&tt(/<[/\w]/g,S.data))return ft(S),!0;if(!(G.tagCheck instanceof Function&&G.tagCheck(re))&&(!Z[re]||le[re])){if(!le[re]&&ui(re)&&(K.tagNameCheck instanceof RegExp&&tt(K.tagNameCheck,re)||K.tagNameCheck instanceof Function&&K.tagNameCheck(re)))return!1;if(Jn&&!xt[re]){const je=_(S)||S.parentNode,Je=k(S)||S.childNodes;if(Je&&je){const ze=Je.length;for(let it=ze-1;it>=0;--it){const Ht=h(Je[it],!0);Ht.__removalCount=(S.__removalCount||0)+1,je.insertBefore(Ht,y(S))}}}return ft(S),!0}return S instanceof l&&!ut(S)||(re==="noscript"||re==="noembed"||re==="noframes")&&tt(/<\/no(script|embed|frames)/i,S.innerHTML)?(ft(S),!0):(ye&&S.nodeType===ir.text&&(q=S.textContent,qr([L,U,$],je=>{q=sr(q,je," ")}),S.textContent!==q&&(rr(t.removed,{element:S.cloneNode()}),S.textContent=q)),qt(F.afterSanitizeElements,S,null),!1)},di=function(S,q,re){if(R[q]||_e&&(q==="id"||q==="name")&&(re in n||re in En))return!1;if(!(W&&!R[q]&&tt(Y,q))){if(!(ue&&tt(B,q))){if(!(G.attributeCheck instanceof Function&&G.attributeCheck(q,S))){if(!V[q]||R[q]){if(!(ui(S)&&(K.tagNameCheck instanceof RegExp&&tt(K.tagNameCheck,S)||K.tagNameCheck instanceof Function&&K.tagNameCheck(S))&&(K.attributeNameCheck instanceof RegExp&&tt(K.attributeNameCheck,q)||K.attributeNameCheck instanceof Function&&K.attributeNameCheck(q,S))||q==="is"&&K.allowCustomizedBuiltInElements&&(K.tagNameCheck instanceof RegExp&&tt(K.tagNameCheck,re)||K.tagNameCheck instanceof Function&&K.tagNameCheck(re))))return!1}else if(!jn[q]){if(!tt(I,sr(re,D,""))){if(!((q==="src"||q==="xlink:href"||q==="href")&&S!=="script"&&yj(re,"data:")===0&&_n[S])){if(!(se&&!tt(H,sr(re,D,"")))){if(re)return!1}}}}}}}return!0},ui=function(S){return S!=="annotation-xml"&&ko(S,C)},fi=function(S){qt(F.beforeSanitizeAttributes,S,null);const{attributes:q}=S;if(!q||no(S))return;const re={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let je=q.length;for(;je--;){const Je=q[je],{name:ze,namespaceURI:it,value:Ht}=Je,In=ge(ze),ro=Ht;let We=ze==="value"?ro:bj(ro);if(re.attrName=In,re.attrValue=We,re.keepAttr=!0,re.forceKeepAttr=void 0,qt(F.uponSanitizeAttribute,S,re),We=re.attrValue,be&&(In==="id"||In==="name")&&(et(ze,S),We=Me+We),fe&&tt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,We)){et(ze,S);continue}if(In==="attributename"&&ko(We,"href")){et(ze,S);continue}if(re.forceKeepAttr)continue;if(!re.keepAttr){et(ze,S);continue}if(!ie&&tt(/\/>/i,We)){et(ze,S);continue}ye&&qr([L,U,$],pi=>{We=sr(We,pi," ")});const mi=ge(S.nodeName);if(!di(mi,In,We)){et(ze,S);continue}if(b&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!it)switch(p.getAttributeType(mi,In)){case"TrustedHTML":{We=b.createHTML(We);break}case"TrustedScriptURL":{We=b.createScriptURL(We);break}}if(We!==ro)try{it?S.setAttributeNS(it,ze,We):S.setAttribute(ze,We),no(S)?ft(S):Ec(t.removed)}catch{et(ze,S)}}qt(F.afterSanitizeAttributes,S,null)},Kf=function oe(S){let q=null;const re=ii(S);for(qt(F.beforeSanitizeShadowDOM,S,null);q=re.nextNode();)qt(F.uponSanitizeShadowNode,q,null),li(q),fi(q),q.content instanceof a&&oe(q.content);qt(F.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(oe){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},q=null,re=null,je=null,Je=null;if(Xn=!oe,Xn&&(oe="<!-->"),typeof oe!="string"&&!ci(oe))if(typeof oe.toString=="function"){if(oe=oe.toString(),typeof oe!="string")throw or("dirty is not a string, aborting")}else throw or("toString is not a function");if(!t.isSupported)return oe;if(Qe||Ke(S),t.removed=[],typeof oe=="string"&&(dn=!1),dn){if(oe.nodeName){const Ht=ge(oe.nodeName);if(!Z[Ht]||le[Ht])throw or("root node is forbidden and cannot be sanitized in-place")}}else if(oe instanceof c)q=to("<!---->"),re=q.ownerDocument.importNode(oe,!0),re.nodeType===ir.element&&re.nodeName==="BODY"||re.nodeName==="HTML"?q=re:q.appendChild(re);else{if(!M&&!ye&&!Ue&&oe.indexOf("<")===-1)return b&&ce?b.createHTML(oe):oe;if(q=to(oe),!q)return M?null:ce?j:""}q&&Ve&&ft(q.firstChild);const ze=ii(dn?oe:q);for(;je=ze.nextNode();)li(je),fi(je),je.content instanceof a&&Kf(je.content);if(dn)return oe;if(M){if(ee)for(Je=A.call(q.ownerDocument);q.firstChild;)Je.appendChild(q.firstChild);else Je=q;return(V.shadowroot||V.shadowrootmode)&&(Je=P.call(s,Je,!0)),Je}let it=Ue?q.outerHTML:q.innerHTML;return Ue&&Z["!doctype"]&&q.ownerDocument&&q.ownerDocument.doctype&&q.ownerDocument.doctype.name&&tt(Pf,q.ownerDocument.doctype.name)&&(it="<!DOCTYPE "+q.ownerDocument.doctype.name+`>
|
|
84
|
+
`+it),ye&&qr([L,U,$],Ht=>{it=sr(it,Ht," ")}),b&&ce?b.createHTML(it):it},t.setConfig=function(){let oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ke(oe),Qe=!0},t.clearConfig=function(){De=null,Qe=!1},t.isValidAttribute=function(oe,S,q){De||Ke({});const re=ge(oe),je=ge(S);return di(re,je,q)},t.addHook=function(oe,S){typeof S=="function"&&rr(F[oe],S)},t.removeHook=function(oe,S){if(S!==void 0){const q=xj(F[oe],S);return q===-1?void 0:vj(F[oe],q,1)[0]}return Ec(F[oe])},t.removeHooks=function(oe){F[oe]=[]},t.removeAllHooks=function(){F=Mc()},t}var No=Rf();function Of({faq:e,className:t,expanded:n,defaultExpanded:s=!1,onExpandedChange:o,showKeywords:a=!1,dangerouslySetAnswerHTML:i=!1}){const[c,l]=m.useState(s),d=n!==void 0,f=d?n:c,u=()=>{const g=!f;d||l(g),o?.(g)};return r.jsxs("div",{className:O("border border-neutral-200 rounded-lg overflow-hidden dark:border-neutral-800",t),children:[r.jsxs("button",{type:"button",onClick:u,className:O("w-full flex items-center justify-between px-4 py-3 text-left","bg-neutral-50 hover:bg-neutral-100 dark:bg-neutral-900 dark:hover:bg-neutral-800","transition-colors duration-150"),"aria-expanded":f,children:[r.jsx("span",{className:"font-medium text-neutral-900 dark:text-neutral-100 pr-4",children:e.question}),r.jsx("svg",{className:O("w-5 h-5 text-neutral-500 transition-transform duration-200 flex-shrink-0",f&&"rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),f&&r.jsxs("div",{className:"px-4 py-3 bg-white dark:bg-neutral-950",children:[i?r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 prose prose-sm dark:prose-invert max-w-none",dangerouslySetInnerHTML:{__html:(()=>{No.addHook("afterSanitizeAttributes",p=>{p.tagName==="A"&&p.setAttribute("rel","noopener noreferrer")});const g=No.sanitize(e.answer,{ALLOWED_TAGS:["b","i","em","strong","a","p","br","ul","ol","li"],ALLOWED_ATTR:["href","target","rel"]});return No.removeAllHooks(),g})()}}):r.jsx("p",{className:"text-sm text-neutral-600 dark:text-neutral-400 whitespace-pre-wrap",children:e.answer}),a&&e.keywords&&e.keywords.length>0&&r.jsx("div",{className:"mt-3 flex flex-wrap gap-1",children:e.keywords.map(g=>r.jsx("span",{className:"px-2 py-0.5 text-xs bg-neutral-100 text-neutral-600 rounded dark:bg-neutral-800 dark:text-neutral-400",children:g},g))})]})]})}function Mj({faqs:e,className:t,accordion:n=!1,showKeywords:s=!1,dangerouslySetAnswerHTML:o=!1,emptyMessage:a="No FAQs available."}){const[i,c]=m.useState(null),l=e.filter(d=>d.active!==!1);return l.length===0?r.jsx("div",{className:O("text-center py-8 text-neutral-500 dark:text-neutral-400",t),children:a}):r.jsx("div",{className:O("space-y-2",t),children:l.map(d=>r.jsx(Of,{faq:d,showKeywords:s,dangerouslySetAnswerHTML:o,expanded:n?i===d.id:void 0,onExpandedChange:n?f=>c(f?d.id:null):void 0},d.id))})}function Fe({amount:e,currency:t}){return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e)}function Ks({amount:e,currency:t,compareAt:n,className:s,size:o="default"}){const a=typeof n=="number"&&n>e;return r.jsxs("div",{className:O("flex items-baseline gap-2 tabular-nums",s),children:[r.jsx("span",{className:O("font-semibold",o==="sm"?"text-sm":"text-base"),children:Fe({amount:e,currency:t})}),a?r.jsx("span",{className:O("text-neutral-500 line-through dark:text-neutral-400",o==="sm"?"text-xs":"text-sm"),children:Fe({amount:n,currency:t})}):null]})}const Lj={securities:{label:"Security",className:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200"},commodities:{label:"Commodity",className:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},property:{label:"Property",className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200"},collectibles:{label:"Collectible",className:"bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200"}},Dj={label:"Tokenized Asset",className:"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300"};function Ya({assetClass:e}){const{label:t,className:n}=Lj[e.toLowerCase()]??Dj;return r.jsx(ht,{className:n,children:t})}const Lc={large:"aspect-[4/5]",square:"aspect-square",compact:"aspect-[3/4]"},Dc={center:"object-center",top:"object-top",bottom:"object-bottom",left:"object-left",right:"object-right"};function Mf({product:e,href:t,onAddToCart:n,onQuickView:s,className:o,layout:a="large",imageCrop:i="center"}){const c=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,l=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:null;return r.jsxs(Xe,{className:O("group flex h-full flex-col overflow-hidden rounded-2xl",o),children:[r.jsxs("div",{className:"relative",children:[t?r.jsx("a",{href:t,className:"block","aria-label":`View ${e.title}`,children:r.jsx("div",{className:O("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Lc[a]),children:r.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:O("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Dc[i]),loading:"lazy"})})}):r.jsx("div",{className:O("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Lc[a]),children:r.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:O("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Dc[i]),loading:"lazy"})}),a!=="compact"&&e.tags?.length?r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 flex gap-1 p-3",children:e.tags.slice(0,2).map(d=>r.jsx(ht,{className:"pointer-events-none bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:d},d))}):null,e.tokenizedAssetConfig?r.jsx("div",{className:"pointer-events-none absolute right-3 bottom-3",children:r.jsx(Ya,{assetClass:e.tokenizedAssetConfig?.assetClass??""})}):null,c?r.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:r.jsx(ht,{variant:"secondary",className:"bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:"Out of stock"})}):l!=null&&l>0&&l<=5?r.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:r.jsxs(ht,{variant:"secondary",className:"bg-white/90 text-neutral-900 backdrop-blur dark:bg-neutral-950/80 dark:text-neutral-50",children:["Only ",l," left"]})}):null,s?r.jsx("div",{className:"absolute right-3 top-3 opacity-0 transition-opacity group-hover:opacity-100",children:r.jsx(X,{type:"button",size:"sm",variant:"secondary",className:"h-9",onClick:()=>s(e),children:"Quick view"})}):null]}),r.jsxs("div",{className:O("flex flex-1 flex-col",a==="compact"?"p-3":"p-4"),children:[r.jsx("div",{className:"flex items-start justify-between gap-3",children:r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:O("line-clamp-1 font-medium text-neutral-950 dark:text-neutral-50",a==="compact"?"text-xs":"text-sm"),children:e.title}),r.jsx("div",{className:"mt-1",children:r.jsx(Ks,{amount:e.price,currency:e.currency,compareAt:e.compareAtPrice,size:a==="compact"?"sm":"default"})})]})}),a==="large"&&r.jsx("p",{className:"mt-2 line-clamp-2 min-h-8 text-xs leading-4 text-neutral-600 dark:text-neutral-400",children:e.description}),r.jsx("div",{className:O("mt-auto",a==="compact"?"pt-3":"pt-4"),children:r.jsx(X,{type:"button",className:"w-full",size:a==="compact"?"sm":"default",onClick:()=>n?.(e,null),disabled:c,children:c?"Out of stock":"Add to cart"})})]})]})}function Js({products:e,columns:t,onAddToCart:n,onQuickView:s,getProductHref:o,className:a,layout:i,imageCrop:c}){const l=t?.base??2,d=t?.md??3,f=t?.lg??3,u={1:"grid-cols-1",2:"grid-cols-2",3:"grid-cols-3",4:"grid-cols-4"},g={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-4"},p={1:"lg:grid-cols-1",2:"lg:grid-cols-2",3:"lg:grid-cols-3",4:"lg:grid-cols-4"},x=O("grid gap-4",u[Math.min(4,Math.max(1,l))],g[Math.min(4,Math.max(1,d))],p[Math.min(4,Math.max(1,f))]);return r.jsx("div",{className:O(x,a),children:e.map(h=>r.jsx(Mf,{product:h,href:o?o(h):void 0,onAddToCart:n,onQuickView:s,layout:i,imageCrop:c},h.id))})}function Qa({images:e,className:t}){const[n,s]=m.useState(0),o=e[n];return e.length===0?r.jsx("div",{className:O("aspect-square w-full rounded-xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",t)}):r.jsxs("div",{className:O("space-y-3",t),children:[r.jsx("div",{className:"aspect-square overflow-hidden rounded-2xl border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:r.jsx("img",{src:o?.url,alt:o?.alt??"",className:"h-full w-full object-cover",loading:"eager"})}),e.length>1?r.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:e.map((a,i)=>{const c=i===n;return r.jsx("button",{type:"button",className:O("h-16 w-16 shrink-0 overflow-hidden rounded-lg border",c?"border-neutral-900 dark:border-neutral-50":"border-neutral-200 dark:border-neutral-800"),onClick:()=>s(i),"aria-label":`View image ${i+1}`,children:r.jsx("img",{src:a.url,alt:a.alt??"",className:"h-full w-full object-cover",loading:"lazy"})},a.url)})}):null]})}function $j(e){const t=new Set;for(const n of e)for(const s of Object.keys(n.options))t.add(s);return Array.from(t)}function zj(e,t){const n=new Set;for(const s of e){const o=s.options[t];o&&n.add(o)}return Array.from(n)}function $c(e,t){return e.find(n=>Object.entries(t).every(([s,o])=>n.options[s]===o))??null}function Lf(e){return e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0}function Fj(e){return e.inventoryStatus==="low"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity>0&&e.inventoryQuantity<=5}function Bj(e){const t=Lf(e),n=!t&&Fj(e),s=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0;return{isOutOfStock:t,isLow:n,quantity:s}}function Uj(e,t,n,s){const o={...t,[n]:s},a=e.filter(i=>Object.entries(o).every(([c,l])=>i.options[c]===l));return a.length===0?!1:a.some(i=>!Lf(i))}function Ka({product:e,value:t,onChange:n,className:s,showInventory:o=!0,disableOutOfStock:a=!1}){const i=m.useMemo(()=>e.variants??[],[e.variants]),c=m.useMemo(()=>$j(i),[i]),l=m.useMemo(()=>$c(i,t.selectedOptions),[i,t.selectedOptions]),d=m.useMemo(()=>l?Bj(l):null,[l]);return i.length===0||c.length===0?null:r.jsxs("div",{className:O("space-y-4",s),children:[c.map(f=>{const u=zj(i,f),g=t.selectedOptions[f];return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-baseline justify-between",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:f}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:g||"Select"})]}),r.jsx("div",{className:"flex flex-wrap gap-2",children:u.map(p=>{const x=p===g,h=Uj(i,t.selectedOptions,f,p),v=a&&!h;return r.jsxs(X,{type:"button",size:"sm",variant:x?"default":"outline",onClick:()=>{const y={...t.selectedOptions,[f]:p},k=$c(i,y);n({selectedOptions:y,variant:k})},"aria-pressed":x,disabled:v,className:O(!h&&!v&&"opacity-50 line-through"),children:[p,!h&&!v&&r.jsx("span",{className:"ml-1 text-[10px] opacity-70",children:"(Out)"})]},p)})})]},f)}),o&&l&&d&&r.jsx("div",{className:"pt-2",children:d.isOutOfStock?r.jsx("div",{className:"text-sm font-medium text-red-600 dark:text-red-400",children:"Out of stock"}):d.isLow&&d.quantity!==void 0?r.jsxs("div",{className:"text-sm text-amber-600 dark:text-amber-400",children:["Only ",r.jsx("span",{className:"font-semibold",children:d.quantity})," left"]}):null})]})}function Ja({qty:e,onChange:t,min:n=1,max:s,className:o}){const a=Number.isFinite(e)?Math.max(n,Math.floor(e)):n,i=a>n,c=typeof s=="number"?a<s:!0;return r.jsxs("div",{className:O("flex items-center gap-2",o),children:[r.jsx(X,{type:"button",size:"icon",variant:"outline",onClick:()=>t(Math.max(n,a-1)),disabled:!i,"aria-label":"Decrease quantity",children:"-"}),r.jsx(Te,{inputMode:"numeric",pattern:"[0-9]*",value:String(a),onChange:l=>{const d=Math.floor(Number(l.target.value));if(!Number.isFinite(d))return;const f=Math.max(n,typeof s=="number"?Math.min(s,d):d);t(f)},className:"h-10 w-16 text-center","aria-label":"Quantity"}),r.jsx(X,{type:"button",size:"icon",variant:"outline",onClick:()=>t(a+1),disabled:!c,"aria-label":"Increase quantity",children:"+"})]})}function Xa({product:e,open:t,onOpenChange:n,productHref:s,onAddToCart:o,className:a}){const[i,c]=m.useState(1),[l,d]=m.useState({selectedOptions:{},variant:null});if(m.useEffect(()=>{if(e)if(c(1),e.variants?.length){const h=e.variants[0];d({selectedOptions:{...h.options},variant:h})}else d({selectedOptions:{},variant:null})},[e?.id]),!e)return null;const f=l.variant?.price??e.price,u=l.variant?.compareAtPrice??e.compareAtPrice,g=l.variant?.inventoryStatus==="out_of_stock"||typeof l.variant?.inventoryQuantity=="number"&&l.variant.inventoryQuantity<=0,p=e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0,x=l.variant?g:p;return r.jsx(Ma,{open:t,onOpenChange:n,children:r.jsxs(zs,{className:O("max-w-3xl",a),children:[r.jsx(Da,{children:r.jsxs(Fs,{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"truncate",children:e.title}),s?r.jsx("a",{href:s(e.slug),className:"text-sm font-normal text-neutral-700 hover:underline dark:text-neutral-300",children:"View details"}):null]})}),r.jsxs("div",{className:"grid gap-8 md:grid-cols-2",children:[r.jsx(Qa,{images:e.images}),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx(Ks,{amount:f,currency:e.currency,compareAt:u}),r.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:e.description})]}),r.jsx(Ka,{product:e,value:{selectedOptions:l.selectedOptions,variantId:l.variant?.id},onChange:h=>d(h)}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(Ja,{qty:i,onChange:c}),r.jsx(X,{type:"button",className:"flex-1",disabled:x,onClick:()=>{o(e,l.variant,i),n(!1)},children:x?"Out of stock":"Add to cart"})]}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:x?"Out of stock":"In stock"})]})]})]})})}function Jo({categories:e,activeSlug:t,onSelect:n,className:s}){return r.jsx("nav",{className:O("space-y-1",s),"aria-label":"Categories",children:e.map(o=>{const a=t===o.slug;return r.jsxs("button",{type:"button",className:O("flex w-full items-center justify-between rounded-md px-3 py-2 text-sm transition-colors",a?"bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900":"text-neutral-700 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800"),onClick:()=>n?.(o),"aria-current":a?"page":void 0,children:[r.jsx("span",{className:"truncate",children:o.name}),r.jsx("span",{className:"text-xs opacity-70",children:"›"})]},o.id)})})}function ei({items:e,className:t}){return r.jsx("nav",{className:O("flex items-center gap-2 text-xs text-neutral-600 dark:text-neutral-400",t),"aria-label":"Breadcrumb",children:e.map((n,s)=>r.jsxs("span",{className:"flex items-center gap-2",children:[n.href?r.jsx("a",{href:n.href,className:"hover:underline",children:n.label}):r.jsx("span",{className:"text-neutral-900 dark:text-neutral-50",children:n.label}),s<e.length-1?r.jsx("span",{"aria-hidden":!0,children:"·"}):null]},`${n.label}-${s}`))})}function ti({value:e,onChange:t,placeholder:n="Search products…",className:s}){return r.jsxs("div",{className:O("relative",s),children:[r.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-3 flex items-center text-neutral-500 dark:text-neutral-400","aria-hidden":!0,children:"⌕"}),r.jsx(Te,{value:e,onChange:o=>t(o.target.value),placeholder:n,className:"pl-9","aria-label":"Search"})]})}function vs({facets:e,value:t,onChange:n,onClear:s,className:o,enabledFilters:a}){const i=e.tags??[],c=new Set(t.tags??[]),l=a?.tags??!0,d=a?.priceRange??!0,f=a?.inStock??!0;return l||d||f?r.jsxs("div",{className:O("space-y-4",o),children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Filters"}),r.jsx(X,{type:"button",variant:"ghost",className:"h-8 px-2 text-xs",onClick:s,children:"Clear"})]}),r.jsx(lt,{}),l&&i.length?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Tags"}),r.jsx("div",{className:"space-y-2",children:i.map(g=>r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[r.jsx("input",{type:"checkbox",checked:c.has(g),onChange:p=>{const x=new Set(c);p.target.checked?x.add(g):x.delete(g),n({...t,tags:Array.from(x)})}}),g]},g))})]}):null,d&&e.price?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Price"}),r.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-1",children:[r.jsx(He,{className:"text-xs",htmlFor:"price-min",children:"Min"}),r.jsx(Te,{id:"price-min",inputMode:"decimal",placeholder:String(e.price.min),value:t.priceMin??"",onChange:g=>{const p=Number(g.target.value);n({...t,priceMin:Number.isFinite(p)&&g.target.value!==""?p:void 0})}})]}),r.jsxs("div",{className:"grid gap-1",children:[r.jsx(He,{className:"text-xs",htmlFor:"price-max",children:"Max"}),r.jsx(Te,{id:"price-max",inputMode:"decimal",placeholder:String(e.price.max),value:t.priceMax??"",onChange:g=>{const p=Number(g.target.value);n({...t,priceMax:Number.isFinite(p)&&g.target.value!==""?p:void 0})}})]})]})]}):null,f?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium",children:"Availability"}),r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-neutral-700 dark:text-neutral-300",children:[r.jsx("input",{type:"checkbox",checked:t.inStock??!1,onChange:g=>n({...t,inStock:g.target.checked})}),"In stock"]})]}):null]}):null}function zc(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function Vj(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M8 6V4h8v2"}),r.jsx("path",{d:"M6 6l1 16h10l1-16"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"})]})}function ni({item:e,onRemove:t,onSetQty:n,variant:s="table",className:o,inventory:a}){const i=e.unitPrice*e.qty,[c,l]=m.useState(!1),d=m.useMemo(()=>{if(a?.availableQty)return a.availableQty},[a?.availableQty]),f=!a?.isOutOfStock&&(d===void 0||e.qty<d),u=m.useMemo(()=>a?a.isOutOfStock?{type:"error",message:a.message||"Out of stock"}:a.exceedsAvailable?{type:"warning",message:a.message||"Quantity exceeds available stock"}:a.isLowStock?{type:"info",message:a.message||"Low stock"}:null:null,[a]);return m.useEffect(()=>{c&&e.qty!==1&&l(!1)},[c,e.qty]),s==="compact"?r.jsxs("div",{className:O("flex items-start gap-3",o),children:[r.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:e.imageSnapshot?r.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),r.jsx("div",{className:"min-w-0 flex-1",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),r.jsx("div",{className:"mt-0.5 text-xs tabular-nums text-neutral-600 dark:text-neutral-400",children:Fe({amount:i,currency:e.currency})}),u&&r.jsxs("div",{className:O("mt-1 flex items-center gap-1 text-[11px]",u.type==="error"&&"text-red-600 dark:text-red-400",u.type==="warning"&&"text-amber-600 dark:text-amber-400",u.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(zc,{className:"h-3 w-3 shrink-0"}),r.jsx("span",{children:u.message})]})]}),r.jsx("div",{className:"flex h-12 w-[140px] shrink-0 items-center justify-end",children:c?r.jsxs("div",{className:"flex w-full flex-col items-center justify-center gap-2",children:[r.jsx("div",{className:"text-center text-[11px] font-medium leading-none text-neutral-600 dark:text-neutral-400",children:"Remove item?"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{type:"button",variant:"outline",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:()=>l(!1),children:"Cancel"}),r.jsx(X,{type:"button",variant:"destructive",className:"h-7 w-[62px] px-0 text-[11px] leading-none",onClick:t,children:"Confirm"})]})]}):r.jsxs("div",{className:"flex items-center justify-end gap-1.5 whitespace-nowrap",children:[r.jsx(X,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":e.qty===1?"Remove item":"Decrease quantity",onClick:()=>{if(e.qty===1){l(!0);return}n(e.qty-1)},children:e.qty===1?r.jsx(Vj,{className:"h-4 w-4"}):"-"}),r.jsx(Te,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:g=>{const p=Math.floor(Number(g.target.value));if(!Number.isFinite(p))return;const x=Math.max(1,d?Math.min(d,p):p);n(x)},className:"h-8 w-11 px-2 text-center","aria-label":"Quantity"}),r.jsx(X,{type:"button",size:"icon",variant:"outline",className:"h-8 w-8","aria-label":"Increase quantity",onClick:()=>n(d?Math.min(d,e.qty+1):e.qty+1),disabled:!f,children:"+"})]})})]})})]}):r.jsxs("div",{className:O("grid grid-cols-[64px_1fr] items-start gap-x-4 gap-y-3 sm:grid-cols-[64px_1fr_176px_120px]",o),children:[r.jsx("div",{className:"h-16 w-16 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:e.imageSnapshot?r.jsx("img",{src:e.imageSnapshot,alt:e.titleSnapshot,className:"h-full w-full object-cover"}):null}),r.jsxs("div",{className:"col-start-2 row-start-1 min-w-0",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsx("div",{className:"truncate text-sm font-medium text-neutral-950 dark:text-neutral-50",children:e.titleSnapshot}),r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50 sm:hidden",children:Fe({amount:i,currency:e.currency})})]}),r.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[Fe({amount:e.unitPrice,currency:e.currency})," each"]}),u&&r.jsxs("div",{className:O("mt-1.5 flex items-center gap-1 text-xs",u.type==="error"&&"text-red-600 dark:text-red-400",u.type==="warning"&&"text-amber-600 dark:text-amber-400",u.type==="info"&&"text-blue-600 dark:text-blue-400"),children:[r.jsx(zc,{className:"h-3.5 w-3.5 shrink-0"}),r.jsx("span",{children:u.message})]})]}),r.jsxs("div",{className:"col-span-2 col-start-1 row-start-2 flex items-center justify-between gap-3 sm:col-span-1 sm:col-start-3 sm:row-start-1 sm:justify-center",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(X,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Decrease quantity",onClick:()=>n(Math.max(1,e.qty-1)),children:"-"}),r.jsx(Te,{inputMode:"numeric",pattern:"[0-9]*",value:String(e.qty),onChange:g=>{const p=Math.floor(Number(g.target.value));if(!Number.isFinite(p))return;const x=Math.max(1,d?Math.min(d,p):p);n(x)},className:"h-9 w-14 text-center","aria-label":"Quantity"}),r.jsx(X,{type:"button",size:"icon",variant:"outline",className:"h-9 w-9","aria-label":"Increase quantity",onClick:()=>n(d?Math.min(d,e.qty+1):e.qty+1),disabled:!f,children:"+"})]}),r.jsx(X,{type:"button",variant:"ghost",className:"h-9 px-2 text-xs text-red-600 dark:text-red-400 sm:hidden",onClick:t,children:"Remove"})]}),r.jsxs("div",{className:"hidden sm:col-start-4 sm:row-start-1 sm:flex sm:flex-col sm:items-center sm:text-center",children:[r.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Fe({amount:i,currency:e.currency})}),r.jsx(X,{type:"button",variant:"ghost",className:"mt-1 h-8 px-2 text-xs text-red-600 dark:text-red-400",onClick:t,children:"Remove"})]})]})}function ri({currency:e,subtotal:t,itemCount:n,onCheckout:s,isCheckoutDisabled:o,checkoutDisabledReason:a,onRemoveUnavailable:i,className:c}){return r.jsxs("div",{className:O("space-y-4",c),children:[r.jsx(lt,{}),r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsxs("div",{className:"flex items-center gap-2 text-neutral-600 dark:text-neutral-400",children:[r.jsx("span",{children:"Subtotal"}),typeof n=="number"?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),r.jsxs("span",{className:"tabular-nums",children:[n," item",n===1?"":"s"]})]}):null]}),r.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:t,currency:e})})]}),r.jsx(X,{type:"button",onClick:s,disabled:o,className:"w-full",children:"Checkout"}),o&&a&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-center text-xs text-amber-600 dark:text-amber-400",children:a}),i&&r.jsx("button",{type:"button",onClick:i,className:"mx-auto block text-xs text-neutral-500 underline underline-offset-2 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-300",children:"Remove unavailable items"})]})]})}function Df({onCheckout:e,className:t}){const{config:n}=Ae(),s=Et(),{getItemInventory:o,hasIssues:a}=ha({items:s.items,refreshInterval:3e4,skip:s.items.length===0}),i=()=>{for(const c of s.items){const l=o(c.productId,c.variantId);(l?.isOutOfStock||l?.exceedsAvailable)&&s.removeItem(c.productId,c.variantId)}};return s.items.length===0?r.jsx(Un,{title:"Cart is empty",description:"Add items from the catalog to check out.",className:t}):r.jsxs("div",{className:O("flex h-full flex-col rounded-xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-950",t),children:[r.jsx("div",{className:"-mr-4 min-h-0 flex-1 overflow-y-auto overflow-x-hidden pr-4",children:r.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:s.items.map(c=>r.jsx("div",{className:"py-3",children:r.jsx(ni,{variant:"compact",item:c,onRemove:()=>s.removeItem(c.productId,c.variantId),onSetQty:l=>s.setQty(c.productId,c.variantId,l),inventory:o(c.productId,c.variantId)})},`${c.productId}::${c.variantId??""}`))})}),r.jsx("div",{className:"mt-4 space-y-4",children:r.jsx(ri,{currency:n.currency,subtotal:s.subtotal,itemCount:s.count,onCheckout:e,isCheckoutDisabled:s.items.length===0||a,checkoutDisabledReason:a?"Some items have inventory issues":void 0,onRemoveUnavailable:a?i:void 0})})]})}const $f=m.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{ref:n,className:O("flex min-h-10 w-full rounded-md border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-950 shadow-sm transition-colors placeholder:text-neutral-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-900/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-400 dark:focus-visible:ring-neutral-50/20",e),...t}));$f.displayName="Textarea";function Wj(){const[e,t]=m.useState(!1);return m.useEffect(()=>{const n=window.matchMedia?.("(prefers-reduced-motion: reduce)");if(!n)return;const s=()=>t(n.matches);return s(),n.addEventListener?.("change",s),()=>n.removeEventListener?.("change",s)},[]),e}function Fc({children:e,className:t}){const n=m.useRef(null),s=Wj();return m.useEffect(()=>{const o=n.current;!o||s||o.animate([{opacity:0,transform:"translateY(6px)"},{opacity:1,transform:"translateY(0px)"}],{duration:180,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)",fill:"both"})},[s]),r.jsx("div",{ref:n,className:t,children:e})}function Ao(){return`${Date.now()}_${Math.random().toString(16).slice(2)}`}function zf({className:e}){m.useEffect(()=>{console.warn("[ShopChatPanel] This component is experimental and has no backend configured. Messages are handled locally and will not be sent to any server.")},[]);const[t,n]=m.useState(""),[s,o]=m.useState(!1),[a,i]=m.useState(()=>[{id:Ao(),role:"agent",text:"Hi! How can we help today? We can recommend products or answer support questions.",createdAt:Date.now()}]),[c,l]=m.useState("…");m.useEffect(()=>{if(!s)return;const p=[".","..","..."];let x=0;const h=window.setInterval(()=>{x=(x+1)%p.length,l(p[x])},450);return()=>window.clearInterval(h)},[s]);const d=m.useRef(null),f=m.useRef(null);m.useEffect(()=>{const p=d.current;p&&(p.scrollTop=p.scrollHeight)},[a.length]);const u=m.useCallback(()=>{const p=f.current;if(!p)return;const x=120;p.style.height="0px";const h=Math.min(x,Math.max(40,p.scrollHeight));p.style.height=`${h}px`,p.style.overflowY=p.scrollHeight>x?"auto":"hidden"},[]);m.useEffect(()=>{u()},[t,u]);const g=m.useCallback(()=>{const p=t.trim();p&&(i(x=>[...x,{id:Ao(),role:"user",text:p,createdAt:Date.now()}]),n(""),o(!0),window.setTimeout(()=>{i(x=>[...x,{id:Ao(),role:"agent",text:"Got it. Want recommendations, sizing help, or help with an order?",createdAt:Date.now()}]),o(!1)},450))},[t]);return r.jsxs("div",{className:O("flex h-full min-h-0 flex-col",e),children:[r.jsxs("div",{ref:d,className:"min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain rounded-2xl border border-neutral-200 bg-white p-4 dark:border-neutral-800 dark:bg-neutral-950",children:[a.map(p=>r.jsx(Fc,{className:O("flex",p.role==="user"?"justify-end":"justify-start"),children:r.jsx("div",{className:O("max-w-[85%] rounded-2xl px-3 py-2 text-sm leading-5",p.role==="user"?"bg-neutral-900 text-neutral-50 dark:bg-neutral-50 dark:text-neutral-900":"bg-neutral-100 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50"),children:r.jsx("span",{className:"whitespace-pre-wrap break-words",children:p.text})})},p.id)),s?r.jsx(Fc,{className:"flex justify-start",children:r.jsx("div",{className:"max-w-[85%] rounded-2xl bg-neutral-100 px-3 py-2 text-sm leading-5 text-neutral-900 dark:bg-neutral-800 dark:text-neutral-50",children:c})}):null]}),r.jsxs("div",{className:"mt-3 flex shrink-0 items-end gap-2",children:[r.jsx($f,{ref:f,rows:1,value:t,onChange:p=>n(p.target.value),placeholder:"Type a message…",className:"max-h-[120px] resize-none",onKeyDown:p=>{p.key==="Enter"&&(p.shiftKey||(p.preventDefault(),g()))}}),r.jsx(X,{type:"button",onClick:g,disabled:!t.trim(),className:"h-10 shrink-0",children:"Send"})]})]})}function jr({trigger:e,side:t="right",open:n,onOpenChange:s,onCheckout:o,preferredTab:a,className:i}){const[c,l]=m.useState(a??"cart");return m.useEffect(()=>{n&&l(a??"cart")},[n,a]),r.jsxs(Bs,{modal:!1,open:n,onOpenChange:s,children:[e?r.jsx(Us,{asChild:!0,children:e}):null,r.jsxs(Er,{side:t,overlayClassName:t==="popup"?"pointer-events-none bg-transparent backdrop-blur-none":"pointer-events-none bg-neutral-950/40 backdrop-blur-none",className:O(t==="bottom"?"h-[85vh] rounded-t-2xl":void 0,t==="popup"?"shadow-xl":"w-full sm:max-w-md",t==="popup"?"h-[min(640px,calc(100vh-2rem))]":void 0,t==="popup"?void 0:"p-4","flex flex-col overflow-hidden",i),children:[r.jsx(Vs,{className:"space-y-0",children:r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(Za,{value:c,onValueChange:d=>l(d),children:r.jsxs(Ys,{className:"h-9",children:[r.jsx(_r,{value:"cart",className:"text-sm",children:"Cart"}),r.jsx(_r,{value:"chat",className:"text-sm",children:"Chat"})]})}),r.jsx(Fu,{asChild:!0,children:r.jsx(X,{type:"button",size:"icon",variant:"ghost",className:"h-9 w-9 rounded-full text-lg leading-none","aria-label":"Close cart",children:"X"})})]})}),r.jsx("div",{className:"mt-3 min-h-0 flex-1 overflow-hidden",children:c==="chat"?r.jsxs("div",{className:"flex h-full flex-col",children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Get help finding a product or ask us any questions. We’re both your shopping assistant and support chat."}),r.jsx("div",{className:"mt-3 min-h-0 flex-1",children:r.jsx(zf,{className:"h-full"})})]}):r.jsx(Df,{onCheckout:()=>{o(),s?.(!1)},className:"h-full border-0 bg-transparent p-0 shadow-none"})})]})]})}function si({value:e,onApply:t,className:n}){const[s,o]=m.useState(e??"");return m.useEffect(()=>{o(e??"")},[e]),r.jsxs("div",{className:O("space-y-2",n),children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:"Promo code"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Te,{value:s,onChange:a=>o(a.target.value),placeholder:"SAVE10","aria-label":"Promo code"}),r.jsx(X,{type:"button",variant:"outline",onClick:()=>t(s.trim()||void 0),children:"Apply"})]})]})}function Ff({onCheckout:e,showPromoCode:t,className:n}){const{config:s}=Ae(),o=Et(),{getItemInventory:a,hasIssues:i}=ha({items:o.items,refreshInterval:3e4,skip:o.items.length===0}),c=()=>{for(const l of o.items){const d=a(l.productId,l.variantId);(d?.isOutOfStock||d?.exceedsAvailable)&&o.removeItem(l.productId,l.variantId)}};return o.items.length===0?r.jsx(Un,{title:"Your cart is empty",description:"Add a few products and come back here when you're ready to check out.",className:n}):r.jsxs("div",{className:O("grid items-start gap-6 lg:grid-cols-[1fr_360px]",n),children:[r.jsxs("div",{className:"self-start rounded-2xl border border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsxs("div",{className:"hidden grid-cols-[64px_1fr_176px_120px] gap-x-4 px-5 py-3 text-xs font-medium text-neutral-500 dark:text-neutral-400 sm:grid",children:[r.jsx("div",{}),r.jsx("div",{children:"Item"}),r.jsx("div",{className:"text-center",children:"Qty"}),r.jsx("div",{className:"text-center",children:"Total"})]}),r.jsx("div",{className:"divide-y divide-neutral-200 dark:divide-neutral-800",children:o.items.map(l=>r.jsx("div",{className:"px-4 py-4 sm:px-5",children:r.jsx(ni,{item:l,onRemove:()=>o.removeItem(l.productId,l.variantId),onSetQty:d=>o.setQty(l.productId,l.variantId,d),inventory:a(l.productId,l.variantId)})},`${l.productId}::${l.variantId??""}`))})]}),r.jsx("div",{className:"lg:sticky lg:top-24 self-start",children:r.jsxs("div",{className:"rounded-2xl border border-neutral-200 bg-white p-5 shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Summary"}),r.jsx(lt,{className:"my-4"}),r.jsxs("div",{className:"space-y-4",children:[t?r.jsx(si,{value:o.promoCode,onApply:o.setPromoCode}):null,r.jsx(ri,{currency:s.currency,subtotal:o.subtotal,onCheckout:e,isCheckoutDisabled:o.items.length===0||i,checkoutDisabledReason:i?"Some items have inventory issues":void 0,onRemoveUnavailable:i?c:void 0})]})]})})]})}function Bf({left:e,right:t,className:n}){return r.jsxs("div",{className:O("grid items-start gap-8 lg:grid-cols-[1fr_420px]",n),children:[r.jsx("div",{children:e}),r.jsx("div",{children:t})]})}function Xo({title:e,value:t,onChange:n,errors:s,className:o}){return r.jsxs("section",{className:O("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:e}),r.jsxs("div",{className:"grid gap-3",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-line1`,children:"Address line 1"}),r.jsx(Te,{id:`${e}-line1`,value:t.line1,onChange:a=>n({...t,line1:a.target.value}),"aria-invalid":!!s?.line1}),s?.line1?r.jsx("div",{className:"text-xs text-red-600",children:s.line1}):null]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-line2`,children:"Address line 2"}),r.jsx(Te,{id:`${e}-line2`,value:t.line2??"",onChange:a=>n({...t,line2:a.target.value})})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-city`,children:"City"}),r.jsx(Te,{id:`${e}-city`,value:t.city,onChange:a=>n({...t,city:a.target.value}),"aria-invalid":!!s?.city}),s?.city?r.jsx("div",{className:"text-xs text-red-600",children:s.city}):null]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-state`,children:"State"}),r.jsx(Te,{id:`${e}-state`,value:t.state??"",onChange:a=>n({...t,state:a.target.value})})]})]}),r.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-postal`,children:"Postal code"}),r.jsx(Te,{id:`${e}-postal`,value:t.postalCode,onChange:a=>n({...t,postalCode:a.target.value}),"aria-invalid":!!s?.postalCode}),s?.postalCode?r.jsx("div",{className:"text-xs text-red-600",children:s.postalCode}):null]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:`${e}-country`,children:"Country"}),r.jsx(Te,{id:`${e}-country`,value:t.country,onChange:a=>n({...t,country:a.target.value}),"aria-invalid":!!s?.country}),s?.country?r.jsx("div",{className:"text-xs text-red-600",children:s.country}):null]})]})]})]})}function qj({message:e}){return e?r.jsx("div",{className:"text-xs text-red-600",children:e}):null}function Uf({defaultOpen:e=!1,label:t="Send as a gift"}){const n=Nr(),[s,o]=w.useState(e||!!(n.values.recipientEmail||n.values.giftMessage)),a=()=>{const i=!s;o(i),i||(n.setField("recipientEmail",""),n.setField("giftMessage",""))};return r.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsxs("label",{className:"flex cursor-pointer items-center gap-3",children:[r.jsx("input",{type:"checkbox",checked:s,onChange:a,className:"h-4 w-4 rounded border-neutral-300 text-neutral-900 focus:ring-neutral-500 dark:border-neutral-600 dark:bg-neutral-800"}),r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:t})]}),s&&r.jsxs("div",{className:"grid gap-3 pl-7",children:[r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"gift-recipient-email",children:"Recipient email"}),r.jsx(Te,{id:"gift-recipient-email",type:"email",value:n.values.recipientEmail??"",onChange:i=>n.setField("recipientEmail",i.target.value),placeholder:"recipient@example.com","aria-invalid":!!n.fieldErrors.recipientEmail}),r.jsx(qj,{message:n.fieldErrors.recipientEmail}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"The recipient will receive an email with details on how to claim their gift."})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"gift-message",children:"Gift message (optional)"}),r.jsx("textarea",{id:"gift-message",value:n.values.giftMessage??"",onChange:i=>n.setField("giftMessage",i.target.value),placeholder:"Add a personal message...",maxLength:500,rows:3,className:"w-full resize-y rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-2 focus:ring-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder-neutral-500"}),n.values.giftMessage&&r.jsxs("div",{className:"text-right text-xs text-neutral-400",children:[n.values.giftMessage.length,"/500"]})]})]})]})}function Vf({methods:e,value:t,onChange:n,currency:s,className:o}){return e.length===0?null:r.jsxs("section",{className:O("space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",o),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Shipping method"}),r.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=a.id===t;return r.jsxs(X,{type:"button",variant:i?"default":"outline",className:"h-auto w-full justify-between px-4 py-3",onClick:()=>n(a.id),"aria-pressed":i,children:[r.jsxs("div",{className:"text-left",children:[r.jsx("div",{className:"text-sm font-medium",children:a.label}),a.detail?r.jsx("div",{className:"text-xs opacity-80",children:a.detail}):null]}),r.jsx("div",{className:"text-sm font-semibold",children:Fe({amount:a.price,currency:a.currency||s})})]},a.id)})})]})}function Zr({message:e}){return e?r.jsx("div",{className:"text-xs text-red-600",children:e}):null}function Wf({className:e}){const{config:t}=Ae(),n=Nr(),s=Et(),o=t.checkout.mode,a=m.useMemo(()=>Qr(s.items,{requireEmail:t.checkout.requireEmail??!0,defaultMode:o,allowShipping:t.checkout.allowShipping??!1}),[s.items,t.checkout.allowShipping,t.checkout.requireEmail,o]),i=(t.checkout.allowShipping??!1)&&a.shippingAddress&&(o==="shipping"||o==="full"),c=a.email!=="none"||a.name!=="none"||a.phone!=="none",l=s.items.some(x=>x.metadata?.product_type==="gift_card"),d=m.useMemo(()=>{const x=new Set;for(const h of s.items)h.metadata?.regulatoryNotice&&x.add(h.metadata.regulatoryNotice);return Array.from(x)},[s.items]),f={line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"},u=n.values.shippingAddress??f,g=n.values.billingAddress??f,p=zl({enabled:!!t.adapter.getShippingMethods&&i,customer:{email:n.values.email||void 0,name:n.values.name||void 0,shippingAddress:u}});return r.jsxs("form",{className:O("space-y-6",e),onSubmit:x=>x.preventDefault(),children:[a.isDigitalOnly?r.jsx(Xe,{className:"rounded-2xl",children:r.jsxs(rt,{className:"p-5",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Digital delivery"}),r.jsx("div",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:a.fulfillmentNotes||"This is a digital product and will be available from your account after purchase."})]})}):null,a.hasPhysical&&!(t.checkout.allowShipping??!1)?r.jsx(Xe,{className:"rounded-2xl border-red-200 bg-red-50 dark:border-red-900/40 dark:bg-red-950/30",children:r.jsxs(rt,{className:"p-5",children:[r.jsx("div",{className:"text-sm font-semibold text-red-900 dark:text-red-200",children:"Shipping required"}),r.jsx("div",{className:"mt-1 text-sm text-red-800/90 dark:text-red-200/80",children:"Your cart contains shippable items, but shipping is disabled for this checkout."})]})}):null,c?r.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Contact"}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:a.email==="required"||a.name==="required"||a.phone==="required"?"Required":"Optional"})]}),r.jsxs("div",{className:"grid gap-3",children:[a.email!=="none"?r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-email",children:"Email"}),r.jsx(Te,{id:"checkout-email",value:n.values.email??"",onChange:x=>n.setField("email",x.target.value),placeholder:"you@company.com","aria-invalid":!!n.fieldErrors.email,required:a.email==="required"}),r.jsx(Zr,{message:n.fieldErrors.email})]}):null,a.name!=="none"?r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-name",children:"Name"}),r.jsx(Te,{id:"checkout-name",value:n.values.name??"",onChange:x=>n.setField("name",x.target.value),placeholder:"Full name","aria-invalid":!!n.fieldErrors.name,required:a.name==="required"}),r.jsx(Zr,{message:n.fieldErrors.name})]}):null,a.phone!=="none"?r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-phone",children:"Phone"}),r.jsx(Te,{id:"checkout-phone",value:n.values.phone??"",onChange:x=>n.setField("phone",x.target.value),placeholder:"Phone number","aria-invalid":!!n.fieldErrors.phone,required:a.phone==="required"}),r.jsx(Zr,{message:n.fieldErrors.phone})]}):null]})]}):null,r.jsx(Uf,{defaultOpen:l,label:l?"Send gift card to someone":"Send as a gift"}),d.length>0?r.jsxs("section",{className:"space-y-3 rounded-2xl border border-amber-200 bg-amber-50 p-5 dark:border-amber-900/40 dark:bg-amber-950/30",children:[r.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-200",children:"Regulatory notice"}),d.map((x,h)=>r.jsx("div",{className:"text-xs text-amber-800/90 dark:text-amber-200/80",children:x},h)),r.jsxs("label",{className:"flex items-start gap-2 pt-1",children:[r.jsx("input",{type:"checkbox",checked:n.values.regulatoryConsent===!0,onChange:x=>n.setField("regulatoryConsent",x.target.checked),className:"mt-0.5 h-4 w-4 rounded border-amber-300 accent-amber-700"}),r.jsx("span",{className:"text-xs font-medium text-amber-900 dark:text-amber-200",children:"I acknowledge and accept the regulatory terms above"})]}),r.jsx(Zr,{message:n.fieldErrors.regulatoryConsent})]}):null,i?r.jsx(Xo,{title:"Shipping address",value:u,onChange:x=>n.setField("shippingAddress",x),errors:{line1:n.fieldErrors["shippingAddress.line1"],city:n.fieldErrors["shippingAddress.city"],postalCode:n.fieldErrors["shippingAddress.postalCode"],country:n.fieldErrors["shippingAddress.country"]}}):null,i&&p.methods.length?r.jsx(Vf,{methods:p.methods,value:n.values.shippingMethodId,onChange:x=>n.setField("shippingMethodId",x),currency:t.currency}):null,o==="full"?r.jsx(Xo,{title:"Billing address",value:g,onChange:x=>n.setField("billingAddress",x)}):null,t.checkout.allowTipping?r.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Tip"}),r.jsxs("div",{className:"grid gap-2",children:[r.jsxs(He,{htmlFor:"checkout-tip",children:["Tip amount (",t.currency,")"]}),r.jsx(Te,{id:"checkout-tip",inputMode:"decimal",value:String(n.values.tipAmount??0),onChange:x=>n.setField("tipAmount",Number(x.target.value)||0)})]})]}):null,o==="full"?r.jsxs("section",{className:"space-y-4 rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Notes"}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(He,{htmlFor:"checkout-notes",children:"Order notes (optional)"}),r.jsx(Te,{id:"checkout-notes",value:n.values.notes??"",onChange:x=>n.setField("notes",x.target.value),placeholder:"Delivery instructions, gift note…"})]})]}):null]})}function Hj(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function Zj(e){return r.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:[r.jsx("path",{d:"M3 6h18"}),r.jsx("path",{d:"M8 6V4h8v2"}),r.jsx("path",{d:"M6 6l1 16h10l1-16"})]})}function qf({open:e,onOpenChange:t,issues:n,onRemoveItem:s,onUpdateQuantity:o,onGoToCart:a,className:i}){const c=n.some(l=>l.type==="out_of_stock"||l.type==="product_unavailable");return r.jsx(Ma,{open:e,onOpenChange:t,children:r.jsxs(zs,{className:O("sm:max-w-lg",i),children:[r.jsxs(Da,{children:[r.jsxs(Fs,{className:"flex items-center gap-2",children:[r.jsx(Hj,{className:"h-5 w-5 text-amber-500"}),"Inventory Update"]}),r.jsx($a,{children:c?"Some items in your cart are no longer available.":"Some items in your cart have limited availability."})]}),r.jsx("div",{className:"my-4 divide-y divide-neutral-200 dark:divide-neutral-800",children:n.map(l=>r.jsx(Gj,{issue:l,onRemove:()=>s(l.productId,l.variantId),onUpdateQty:d=>o(l.productId,l.variantId,d)},`${l.productId}::${l.variantId??""}`))}),r.jsxs(zu,{className:"flex-col gap-2 sm:flex-row",children:[a?r.jsx(X,{type:"button",variant:"outline",onClick:()=>{t(!1),a()},children:"Go to Cart"}):null,r.jsx(X,{type:"button",onClick:()=>t(!1),children:"Continue"})]})]})})}function Gj({issue:e,onRemove:t,onUpdateQty:n}){const s=e.type==="out_of_stock"||e.type==="product_unavailable";return r.jsxs("div",{className:"flex items-start gap-3 py-3",children:[r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:e.title}),r.jsx("div",{className:O("mt-0.5 text-sm",s?"text-red-600 dark:text-red-400":"text-amber-600 dark:text-amber-400"),children:e.message}),e.type==="insufficient_stock"&&e.availableQty>0?r.jsxs("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:["You requested ",e.requestedQty,", but only ",e.availableQty," available"]}):null]}),r.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.type==="insufficient_stock"&&e.availableQty>0?r.jsxs(X,{type:"button",size:"sm",variant:"outline",onClick:()=>n(e.availableQty),children:["Update to ",e.availableQty]}):null,r.jsxs(X,{type:"button",size:"sm",variant:"ghost",className:"text-red-600 hover:bg-red-50 hover:text-red-700 dark:text-red-400 dark:hover:bg-red-950/30 dark:hover:text-red-300",onClick:t,children:[r.jsx(Zj,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Remove"})]})]})]})}function Hf({className:e,ctaLabel:t,renderEmbedded:n,embeddedFallback:s,renderCustom:o,customFallback:a}){const{config:i}=Ae(),c=Et(),l=Nr(),{config:d,isLoading:f}=Bl(),[u,g]=m.useState(!1);m.useEffect(()=>{let L=!0;return Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js")).then(U=>{L&&g(U.detectSolanaWallets())}),()=>{L=!1}},[]);const p=Fl({items:c.items}),[x,h]=m.useState(!1),v=m.useMemo(()=>i.checkout.paymentMethods&&i.checkout.paymentMethods.length?i.checkout.paymentMethods:[{id:"card",label:"Card",ctaLabel:"Pay now"}],[i.checkout.paymentMethods]),y=m.useMemo(()=>v.filter(U=>!(U.id==="card"&&!d.card||U.id==="crypto"&&!d.crypto||U.id==="credits"&&!d.credits||U.id==="crypto"&&!u)),[u,v,d]),[k,_]=m.useState((y[0]??v[0])?.id??"card");m.useEffect(()=>{y.length&&(y.some(L=>L.id===k)||_(y[0].id))},[k,y]),m.useEffect(()=>{l.reset()},[k]);const b=y.find(L=>L.id===k)??v.find(L=>L.id===k)??v[0]??{ctaLabel:"Pay now"},j=b.description??(k==="crypto"?"Pay using a connected wallet.":void 0),N=k==="crypto"&&!u,T=f||l.status==="validating"||l.status==="creating_session"||l.status==="redirecting"||p.isVerifying,A=t??b.ctaLabel??(i.checkout.mode==="none"?"Continue to payment":"Pay now"),E=m.useCallback(async L=>{const U=await p.verify();if(!U.ok&&U.issues.length>0){h(!0);return}l.createCheckoutSession({paymentMethodId:L})},[l,p]),P=l.session?.kind==="embedded"?l.session:null,F=l.session?.kind==="custom"?l.session:null;return r.jsxs("div",{className:O("space-y-3",e),children:[y.length>1?r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400",children:"Payment method"}),r.jsx(Za,{value:k,onValueChange:_,children:r.jsx(Ys,{className:"w-full",children:y.map(L=>r.jsx(_r,{value:L.id,className:"flex-1",disabled:T,children:L.label},L.id))})})]}):null,l.error?r.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:l.error}):null,F?r.jsx("div",{className:"space-y-3",children:o?o(F):a??r.jsx("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300",children:"Checkout session created. Provide `renderCustom` to render a custom payment UI."})}):P?r.jsx("div",{className:"space-y-3",children:n?n(P):s??r.jsx("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 p-4 text-sm text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900/40 dark:text-neutral-300",children:"Embedded checkout session created. Provide `renderEmbedded` to render your payment UI."})}):r.jsx(X,{type:"button",className:"w-full",disabled:c.items.length===0||T||N,onClick:()=>{E(k)},children:p.isVerifying?"Checking availability…":T?"Processing…":A}),!P&&!F?r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:N?"Install a browser wallet to enable crypto payments.":j??"You will be redirected to complete your payment."}):null,r.jsx(qf,{open:x,onOpenChange:L=>{h(L),L||p.reset()},issues:p.result?.issues??[],onRemoveItem:(L,U)=>{c.removeItem(L,U)},onUpdateQuantity:(L,U,$)=>{c.setQty(L,U,$)}})]})}function Zf({className:e}){const{config:t}=Ae(),n=Et(),s=Nr(),{settings:o}=Wn(),a=(t.checkout.allowPromoCodes??!1)&&o.checkout.promoCodes;return r.jsxs("div",{className:O("rounded-2xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-950",e),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order review"}),r.jsx(lt,{className:"my-3"}),r.jsx("div",{className:"space-y-3",children:n.items.map(i=>r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.jsx("div",{className:"h-10 w-10 shrink-0 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-100 dark:border-neutral-800 dark:bg-neutral-900",children:i.imageSnapshot?r.jsx("img",{src:i.imageSnapshot,alt:i.titleSnapshot,className:"h-full w-full object-cover"}):null}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"line-clamp-1 text-sm text-neutral-950 dark:text-neutral-50",children:i.titleSnapshot}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",i.qty]})]})]}),r.jsx("div",{className:"text-sm font-semibold tabular-nums text-neutral-950 dark:text-neutral-50",children:Fe({amount:i.unitPrice*i.qty,currency:i.currency})})]},`${i.productId}::${i.variantId??""}`))}),r.jsx(lt,{className:"my-3"}),a?r.jsx(si,{value:s.values.discountCode??n.promoCode,onApply:i=>{s.setField("discountCode",i??""),n.setPromoCode(i)}}):null,a?r.jsx(lt,{className:"my-3"}):null,r.jsxs("div",{className:"flex items-center justify-between text-sm",children:[r.jsx("span",{className:"text-neutral-600 dark:text-neutral-400",children:"Subtotal"}),r.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:n.subtotal,currency:t.currency})})]})]})}function Ze(e){if(e)try{const t=new URL(e,"https://placeholder.invalid");return t.protocol==="https:"||t.protocol==="http:"?e:void 0}catch{return}}function Eo(e){const t={"Content-Type":"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t}function Yj({status:e}){const t={info_submitted:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200",approved:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",rejected:"bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-200",processing:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200"},n=e.replace(/_/g," ");return r.jsx(ht,{className:t[e]??"bg-neutral-100 text-neutral-700",children:n})}function Qj({field:e,value:t,onChange:n}){const s="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-2 focus:ring-neutral-500 dark:border-neutral-700 dark:bg-neutral-900 dark:text-neutral-50 dark:placeholder-neutral-500";if(e.fieldType==="dropdown"&&e.options?.length)return r.jsxs("select",{id:e.id,required:e.required,value:t,onChange:a=>n(a.target.value),className:s,children:[r.jsx("option",{value:"",children:"Select…"}),e.options.map(a=>r.jsx("option",{value:a,children:a},a))]});if(e.fieldType==="address"||e.fieldType==="textarea")return r.jsx("textarea",{id:e.id,required:e.required,value:t,placeholder:e.placeholder,rows:3,onChange:a=>n(a.target.value),className:O(s,"resize-y")});if(e.fieldType==="file_upload"){const a=i=>{const c=i.target.files?.[0];if(!c){n("");return}if(c.size>1572864){n(""),i.target.value="",alert("File must be under 1.5 MB.");return}const l=new FileReader;l.onload=()=>{const d=l.result,f=c.name.replace(/[^a-zA-Z0-9._\-() ]/g,"_").slice(0,200);n(JSON.stringify({name:f,data:d}))},l.readAsDataURL(c)};return r.jsx("input",{id:e.id,type:"file",required:e.required,onChange:a,className:"w-full text-sm text-neutral-700 file:mr-3 file:rounded file:border-0 file:bg-neutral-100 file:px-3 file:py-1.5 file:text-sm file:font-medium dark:text-neutral-300 dark:file:bg-neutral-800 dark:file:text-neutral-200"})}const o={email:"email",phone:"tel",text:"text"};return r.jsx("input",{id:e.id,type:o[e.fieldType]??"text",required:e.required,value:t,placeholder:e.placeholder,onChange:a=>n(a.target.value),className:s})}function Xs({serverUrl:e,productId:t,authToken:n}){const[s,o]=m.useState("loading"),[a,i]=m.useState(null),[c,l]=m.useState(null),[d,f]=m.useState({}),[u,g]=m.useState(!1),[p,x]=m.useState(null),h=m.useCallback((y,k)=>{f(_=>({..._,[y]:k}))},[]);m.useEffect(()=>{if(s!=="already_submitted"&&s!=="success")return;const y=Eo(n),_=setInterval(async()=>{try{const b=await fetch(`${e}/paywall/v1/asset-redemption/${t}/status`,{headers:y});if(!b.ok)return;const j=await b.json();j.redemptions?.length&&(l(j.redemptions[0].status),s==="success"&&o("already_submitted"))}catch{}},3e4);return()=>clearInterval(_)},[s,e,t,n]),m.useEffect(()=>{let y=!1;const k=Eo(n);async function _(){try{const b=await fetch(`${e}/paywall/v1/asset-redemption/${t}/status`,{headers:k});if(!y&&b.ok){const T=await b.json();if(T.redemptions?.length){l(T.redemptions[0].status),o("already_submitted");return}}const j=await fetch(`${e}/paywall/v1/asset-redemption/${t}/form`,{headers:k});if(y)return;if(!j.ok)throw new Error(`Server error: ${j.status}`);const N=await j.json();if(!N.redemptionConfig){o("no_config");return}i(N.redemptionConfig),o("form")}catch(b){y||(x(b instanceof Error?b.message:"Failed to load redemption form."),o("form"))}}return _(),()=>{y=!0}},[e,t,n]);const v=m.useCallback(async y=>{y.preventDefault(),g(!0),x(null);try{const k=await fetch(`${e}/paywall/v1/asset-redemption/${t}/submit`,{method:"POST",headers:Eo(n),body:JSON.stringify({formData:d})});if(!k.ok){const _=await k.text();throw new Error(_||`Server error: ${k.status}`)}o("success")}catch(k){x(k instanceof Error?k.message:"Submission failed. Please try again.")}finally{g(!1)}},[e,t,n,d]);return s==="loading"?r.jsx("div",{className:"py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",children:"Loading redemption form..."}):s==="no_config"?r.jsx("div",{className:"py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",children:"Redemption not available for this product."}):s==="already_submitted"?r.jsxs("div",{className:"space-y-3 rounded-xl border border-neutral-200 bg-neutral-50 p-5 dark:border-neutral-800 dark:bg-neutral-900/50",children:[r.jsx("p",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-50",children:"Redemption request status"}),c?r.jsx(Yj,{status:c}):null,r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"You have already submitted redemption information. We will notify you of any updates."})]}):s==="success"?r.jsx("div",{className:"rounded-xl border border-emerald-200 bg-emerald-50 p-5 text-sm text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/30 dark:text-emerald-200",children:"Redemption submitted! You will be notified when reviewed."}):r.jsxs("form",{onSubmit:y=>{v(y)},className:"space-y-5",children:[a?.instructions?r.jsx("p",{className:"text-sm text-neutral-700 dark:text-neutral-300",children:a.instructions}):null,p?r.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:p}):null,a?.fields.map(y=>r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{htmlFor:y.id,className:"block text-sm font-medium text-neutral-900 dark:text-neutral-50",children:[y.label,y.required?r.jsx("span",{className:"ml-1 text-red-500","aria-hidden":"true",children:"*"}):null]}),r.jsx(Qj,{field:y,value:d[y.id]??"",onChange:k=>h(y.id,k)})]},y.id)),a?.estimatedProcessingDays?r.jsxs("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:["Estimated processing time: ",a.estimatedProcessingDays," business day",a.estimatedProcessingDays!==1?"s":"","."]}):null,r.jsx(X,{type:"submit",className:"w-full",disabled:u,children:u?"Submitting...":"Submit redemption info"})]})}function eo({result:e,onContinueShopping:t,onViewOrders:n,className:s,serverUrl:o,authToken:a,tokenizedProductIds:i}){return e.kind==="idle"?null:e.kind==="success"?r.jsxs("div",{className:O("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",s),children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-600 dark:text-neutral-400",children:"Receipt"}),r.jsx("h2",{className:"mt-2 text-2xl font-semibold",children:"Payment successful"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Thanks for your purchase. You'll receive a confirmation email shortly."}),e.order?.metadata?.recipient_email?r.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsx("div",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:"Gift card sent"}),r.jsxs("div",{className:"mt-1 text-sm text-emerald-800/90 dark:text-emerald-200/80",children:["A gift card has been sent to"," ",r.jsx("span",{className:"font-medium",children:e.order.metadata.recipient_email}),"."," ","The recipient will receive credits in their account."]})]}):e.order?.items.some(c=>c.title.toLowerCase().includes("gift card"))?r.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsx("div",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:"Gift card credits added"}),r.jsx("div",{className:"mt-1 text-sm text-emerald-800/90 dark:text-emerald-200/80",children:"Your gift card credits have been added to your account and are ready to use."})]}):null,e.order?r.jsxs("div",{className:"mt-5 rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:["Order ",e.order.id]}),r.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[new Date(e.order.createdAt).toLocaleString()," · ",e.order.status]})]}),r.jsx("div",{className:"text-sm font-semibold",children:Fe({amount:e.order.total,currency:e.order.currency})})]}),r.jsxs("div",{className:"mt-3 space-y-2",children:[e.order.items.slice(0,4).map((c,l)=>r.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[r.jsx("div",{className:"min-w-0 truncate",children:c.title}),r.jsxs("div",{className:"shrink-0 text-neutral-600 dark:text-neutral-400",children:["Qty ",c.qty]})]},`${c.title}-${l}`)),e.order.items.length>4?r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["+",e.order.items.length-4," more item(s)"]}):null]}),r.jsxs("div",{className:"mt-3 flex gap-3 text-sm",children:[Ze(e.order.receiptUrl)?r.jsx("a",{href:Ze(e.order.receiptUrl),className:"hover:underline",children:"Receipt"}):null,Ze(e.order.invoiceUrl)?r.jsx("a",{href:Ze(e.order.invoiceUrl),className:"hover:underline",children:"Invoice"}):null]})]}):e.orderId?r.jsxs("p",{className:"mt-4 text-xs text-neutral-500 dark:text-neutral-400",children:["Session/Order ID: ",r.jsx("span",{className:"font-mono",children:e.orderId})]}):null,(()=>{const c=i??e.order?.items.filter(l=>l.tokenizedAsset&&l.productId).map(l=>l.productId)??[];return!o||c.length===0?null:r.jsxs("div",{className:"mt-5 space-y-4",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-900 dark:text-neutral-50",children:"Complete your asset redemption"}),r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Your tokenized asset was minted on-chain. Submit your redemption information below."}),c.map(l=>r.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:r.jsx(Xs,{serverUrl:o,productId:l,authToken:a})},l))]})})(),r.jsxs("div",{className:"mt-6 flex flex-col gap-2 sm:flex-row",children:[t?r.jsx(X,{type:"button",onClick:t,children:"Continue shopping"}):null,n?r.jsx(X,{type:"button",variant:"outline",onClick:n,children:"View orders"}):null]})]}):e.kind==="cancel"?r.jsxs("div",{className:O("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",s),children:[r.jsx("h2",{className:"text-2xl font-semibold",children:"Checkout cancelled"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"No charges were made. You can continue shopping and try again."}),t?r.jsx("div",{className:"mt-6",children:r.jsx(X,{type:"button",onClick:t,children:"Back to shop"})}):null]}):r.jsxs("div",{className:O("rounded-2xl border border-neutral-200 bg-white p-8 text-neutral-950 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",s),children:[r.jsx("h2",{className:"text-2xl font-semibold",children:"Payment failed"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:e.message??"Something went wrong while processing your payment."}),t?r.jsx("div",{className:"mt-6",children:r.jsx(X,{type:"button",onClick:t,children:"Back to shop"})}):null]})}function Kj({onContinueShopping:e,onViewOrders:t,className:n,receiptClassName:s,serverUrl:o,authToken:a,tokenizedProductIds:i}){const c=fa();return c.kind==="idle"?r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",n),children:r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading order details..."})}):r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",n),children:r.jsx(eo,{result:c,onContinueShopping:e,onViewOrders:t,className:O("w-full max-w-lg",s),serverUrl:o,authToken:a,tokenizedProductIds:i})})}function Jj({onContinueShopping:e,className:t,receiptClassName:n}){const s={kind:"cancel"};return r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",t),children:r.jsx(eo,{result:s,onContinueShopping:e,className:O("w-full max-w-lg",n)})})}function Xj(e){switch(e){case"created":return"secondary";case"paid":return"default";case"processing":return"secondary";case"fulfilled":return"outline";case"shipped":return"default";case"delivered":return"outline";case"cancelled":return"outline";case"refunded":return"outline";default:return"secondary"}}function Gf({order:e,onView:t,className:n}){const s=`${e.items.length} item${e.items.length===1?"":"s"}`,o=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),a=e.status.charAt(0).toUpperCase()+e.status.slice(1);return r.jsx(Xe,{className:O("group overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm transition-shadow hover:shadow-md dark:border-neutral-800 dark:bg-neutral-950",n),children:r.jsx(rt,{className:"p-5",children:r.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-x-4 gap-y-2",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),r.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),r.jsx("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:o})]}),r.jsx("div",{className:"flex items-start justify-end",children:r.jsx(ht,{variant:Xj(e.status),className:"capitalize",children:a})}),r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:s}),r.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.total,currency:e.currency})}),r.jsxs("div",{className:"col-span-2 mt-3 flex items-center justify-between gap-3 border-t border-neutral-200/70 pt-3 dark:border-neutral-800",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[Ze(e.receiptUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.receiptUrl),target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,Ze(e.invoiceUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.invoiceUrl),target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}),t?r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:()=>t(e),children:"Details"}):null]})]})})})}function Yf({orders:e,onView:t,className:n}){return r.jsx("div",{className:O("grid gap-4",n),children:e.map(s=>r.jsx(Gf,{order:s,onView:t},s.id))})}function Io(e,t,n){const s="https://explorer.solana.com",o=n==="mainnet-beta"?"":`?cluster=${n}`;return`${s}/${e}/${t}${o}`}function To(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function eS(e,t){const n=e/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(n)}catch{return`${n.toFixed(2)} ${t}`}}const tS={securities:"Security Token",commodities:"Commodity Token",property:"Property Token",collectibles:"Collectible NFT"};function oi({mintAddress:e,mintSignature:t,burnSignature:n,assetClass:s,backingValueCents:o,backingCurrency:a,cluster:i="mainnet-beta",className:c}){if(!e&&!t)return null;const l=s?tS[s.toLowerCase()]??"Tokenized Asset":"Tokenized Asset",d=!!n;return r.jsx(Xe,{className:O("overflow-hidden rounded-xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",c),children:r.jsxs(rt,{className:"p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(nS,{}),r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:l})]}),d?r.jsx(ht,{className:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200",children:"redeemed"}):r.jsx(ht,{className:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",children:"on-chain"})]}),r.jsxs("div",{className:"mt-3 space-y-2 text-sm",children:[e&&r.jsx(Gr,{label:"Token address",value:To(e),href:Io("address",e,i),mono:!0}),t&&r.jsx(Gr,{label:"Mint transaction",value:To(t),href:Io("tx",t,i),mono:!0}),n&&r.jsx(Gr,{label:"Burn transaction",value:To(n),href:Io("tx",n,i),mono:!0}),o!=null&&a&&r.jsx(Gr,{label:"Backing value",value:eS(o,a)})]})]})})}function Gr({label:e,value:t,href:n,mono:s}){return r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:e}),n?r.jsx("a",{href:n,target:"_blank",rel:"noreferrer",className:O("text-blue-600 underline decoration-blue-600/30 hover:decoration-blue-600 dark:text-blue-400",s&&"font-mono text-xs"),children:t}):r.jsx("span",{className:O("text-neutral-950 dark:text-neutral-50",s&&"font-mono text-xs"),children:t})]})}function nS(){return r.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-neutral-400 dark:text-neutral-500",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function rS(e){switch(e){case"paid":return"default";case"processing":return"secondary";case"fulfilled":return"outline";case"cancelled":return"outline";case"refunded":return"outline";default:return"secondary"}}function Qf({order:e,onBack:t,className:n,serverUrl:s,authToken:o}){const a=new Date(e.createdAt).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),i=e.status.charAt(0).toUpperCase()+e.status.slice(1),c=e.items.filter(u=>u.tokenizedAsset&&u.productId),[l,d]=w.useState({}),f=w.useCallback(async()=>{if(!s||!c.length)return;const u={"Content-Type":"application/json"};o&&(u.Authorization=`Bearer ${o}`);const g={};await Promise.all(c.map(async p=>{try{const x=await fetch(`${s}/paywall/v1/asset-redemption/${encodeURIComponent(p.productId)}/status`,{headers:u});if(x.ok){const v=(await x.json()).redemptions?.[0];v&&(g[p.productId]={mintSignature:v.tokenMintSignature??void 0,burnSignature:v.tokenBurnSignature??void 0,status:v.status??void 0})}}catch{}})),d(g)},[s,o,c.map(u=>u.productId).join(",")]);return w.useEffect(()=>{f()},[f]),r.jsx(Xe,{className:O("overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",n),children:r.jsxs(rt,{className:"p-6",children:[r.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:"Order"}),r.jsx("span",{className:"truncate font-mono text-sm font-semibold text-neutral-950/80 dark:text-neutral-50/80",children:e.id})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-neutral-600 dark:text-neutral-400",children:[r.jsx("span",{children:a}),r.jsx("span",{className:"text-neutral-300 dark:text-neutral-700",children:"·"}),r.jsx("span",{children:i})]})]}),r.jsxs("div",{className:"flex items-center gap-2 sm:justify-end",children:[r.jsx(ht,{variant:rS(e.status),className:"capitalize",children:i}),t?r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"h-8",onClick:t,children:"Back"}):null]})]}),r.jsx(lt,{className:"my-5"}),r.jsx("div",{className:"space-y-3",children:e.items.map((u,g)=>r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"truncate text-sm text-neutral-950 dark:text-neutral-50",children:u.title}),r.jsxs("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",u.qty]})]}),r.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:u.unitPrice*u.qty,currency:u.currency})})]},`${u.title}-${g}`))}),e.metadata?.recipient_email?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"my-5"}),r.jsxs("div",{className:"rounded-xl border border-emerald-200 bg-emerald-50 p-3 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsx("div",{className:"text-xs font-semibold text-emerald-900 dark:text-emerald-200",children:"Gift card"}),r.jsxs("div",{className:"mt-1 text-xs text-emerald-800/90 dark:text-emerald-200/80",children:["Sent to ",r.jsx("span",{className:"font-medium",children:e.metadata.recipient_email})]})]})]}):null,s&&c.length>0?r.jsxs(r.Fragment,{children:[r.jsx(lt,{className:"my-5"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-900 dark:text-neutral-50",children:"Asset redemption"}),c.map(u=>{const g=l[u.productId];return r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"text-xs font-medium text-neutral-600 dark:text-neutral-400",children:u.title}),g?.mintSignature&&r.jsx(oi,{mintSignature:g.mintSignature,burnSignature:g.burnSignature,assetClass:u.assetClass,backingValueCents:u.backingValueCents,backingCurrency:u.backingCurrency}),r.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:r.jsx(Xs,{serverUrl:s,productId:u.productId,authToken:o})})]},u.productId)})]})]}):null,r.jsx(lt,{className:"my-5"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Total"}),r.jsx("span",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.total,currency:e.currency})})]}),Ze(e.receiptUrl)||Ze(e.invoiceUrl)?r.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[Ze(e.receiptUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.receiptUrl),target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,Ze(e.invoiceUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:Ze(e.invoiceUrl),target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}):null]})})}const sS={pending_info:"bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200",info_submitted:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200",approved:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",completed:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200",processing:"bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200",rejected:"bg-red-100 text-red-800 dark:bg-red-900/50 dark:text-red-200"};function oS({status:e}){const t=e.replace(/_/g," ");return r.jsx(ht,{className:sS[e]??"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300",children:t})}function aS({orders:e,serverUrl:t,authToken:n,className:s}){const[o,a]=w.useState({}),[i,c]=w.useState(!0),[l,d]=w.useState(null),f=e.flatMap(x=>x.items.filter(h=>h.tokenizedAsset&&h.productId).map(h=>h.productId)),u=[...new Set(f)],g=w.useCallback(async()=>{if(!u.length){c(!1);return}c(!0);const x={"Content-Type":"application/json"};n&&(x.Authorization=`Bearer ${n}`);const h={};await Promise.all(u.map(async v=>{try{const y=await fetch(`${t}/paywall/v1/asset-redemption/${encodeURIComponent(v)}/status`,{headers:x});if(y.ok){const k=await y.json();h[v]=(k.redemptions??[]).map(_=>({..._,productId:v}))}}catch{}})),a(h),c(!1)},[t,n,u.join(",")]);w.useEffect(()=>{g()},[g]);const p=[];for(const x of e){x.metadata?.recipient_email&&p.push({kind:"gift-card",order:x,recipientEmail:x.metadata.recipient_email});for(const h of x.items)if(h.tokenizedAsset&&h.productId){const v=o[h.productId]??[];if(v.length)for(const y of v)p.push({kind:"asset",order:x,item:h,status:y.status,redemptionId:y.redemptionId});else p.push({kind:"asset",order:x,item:h,status:null,redemptionId:null})}}return p.sort((x,h)=>{const v=new Date(x.order.createdAt).getTime();return new Date(h.order.createdAt).getTime()-v}),i?r.jsx("div",{className:O("py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",s),children:"Loading redemptions..."}):p.length?r.jsxs("div",{className:O("space-y-3",s),children:[r.jsx("h2",{className:"text-lg font-semibold text-neutral-950 dark:text-neutral-50",children:"My Redemptions"}),p.map((x,h)=>x.kind==="gift-card"?r.jsx(iS,{order:x.order,recipientEmail:x.recipientEmail},`gc-${x.order.id}-${h}`):r.jsx(cS,{order:x.order,item:x.item,status:x.status,isExpanded:l===x.item.productId,onToggle:()=>d(v=>v===x.item.productId?null:x.item.productId),serverUrl:t,authToken:n},`ar-${x.order.id}-${x.item.productId}-${h}`))]}):r.jsxs("div",{className:O("py-12 text-center",s),children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:"No redemptions yet"}),r.jsx("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"Redemptions from tokenized asset purchases and gift card claims will appear here."})]})}function iS({order:e,recipientEmail:t}){return r.jsx(Xe,{className:"rounded-xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:r.jsx(rt,{className:"p-4",children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:"Gift card sent"}),r.jsxs("div",{className:"mt-0.5 text-xs text-neutral-500 dark:text-neutral-400",children:["To ",t]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.total,currency:e.currency})}),r.jsx("div",{className:"mt-0.5 text-xs text-neutral-400",children:new Date(e.createdAt).toLocaleDateString()})]})]})})})}function cS({order:e,item:t,status:n,isExpanded:s,onToggle:o,serverUrl:a,authToken:i}){return r.jsx(Xe,{className:"rounded-xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:r.jsxs(rt,{className:"p-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:t.title}),r.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-xs text-neutral-500 dark:text-neutral-400",children:[r.jsxs("span",{children:["Order ",e.id.slice(0,8),"..."]}),r.jsx("span",{children:new Date(e.createdAt).toLocaleDateString()})]})]}),r.jsx("div",{className:"flex items-center gap-2",children:n?r.jsx(oS,{status:n}):r.jsx(ht,{className:"bg-neutral-100 text-neutral-600 dark:bg-neutral-800 dark:text-neutral-400",children:"awaiting info"})})]}),(!n||n==="pending_info")&&r.jsxs("div",{className:"mt-3",children:[r.jsx(X,{type:"button",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:o,children:s?"Hide form":"Submit redemption info"}),s&&t.productId&&r.jsx("div",{className:"mt-3 rounded-lg border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:r.jsx(Xs,{serverUrl:a,productId:t.productId,authToken:i})})]})]})})}function lS({orders:e,serverUrl:t,authToken:n,cluster:s="mainnet-beta",className:o}){const[a,i]=w.useState({}),[c,l]=w.useState(!0),d=e.flatMap(p=>p.items.filter(x=>x.tokenizedAsset&&x.productId).map(x=>x.productId)),f=[...new Set(d)],u=w.useCallback(async()=>{if(!f.length){l(!1);return}l(!0);const p={"Content-Type":"application/json"};n&&(p.Authorization=`Bearer ${n}`);const x={};await Promise.all(f.map(async h=>{try{const v=await fetch(`${t}/paywall/v1/asset-redemption/${encodeURIComponent(h)}/status`,{headers:p});if(v.ok){const k=(await v.json()).redemptions?.[0];k&&(x[h]={tokenMintSignature:k.tokenMintSignature??void 0,tokenBurnSignature:k.tokenBurnSignature??void 0,status:k.status??void 0})}}catch{}})),i(x),l(!1)},[t,n,f.join(",")]);w.useEffect(()=>{u()},[u]);const g=[];for(const p of e)for(const x of p.items)if(x.tokenizedAsset&&x.productId){const h=a[x.productId];g.push({order:p,item:x,mintSignature:h?.tokenMintSignature,burnSignature:h?.tokenBurnSignature,status:h?.status})}return g.sort((p,x)=>{const h=new Date(p.order.createdAt).getTime();return new Date(x.order.createdAt).getTime()-h}),c?r.jsx("div",{className:O("py-8 text-center text-sm text-neutral-500 dark:text-neutral-400",o),children:"Loading tokens..."}):g.length?r.jsxs("div",{className:O("space-y-4",o),children:[r.jsx("h2",{className:"text-lg font-semibold text-neutral-950 dark:text-neutral-50",children:"My Tokens"}),r.jsxs("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:[g.length," token",g.length===1?"":"s"]}),r.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:g.map((p,x)=>r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-950 dark:text-neutral-50",children:p.item.title}),r.jsxs("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:["Order ",p.order.id.slice(0,8),"... ·"," ",new Date(p.order.createdAt).toLocaleDateString()]}),r.jsx(oi,{mintSignature:p.mintSignature,burnSignature:p.burnSignature,assetClass:p.item.assetClass,backingValueCents:p.item.backingValueCents,backingCurrency:p.item.backingCurrency,cluster:s})]},`${p.item.productId}-${x}`))})]}):r.jsxs("div",{className:O("py-12 text-center",o),children:[r.jsx("div",{className:"text-sm font-medium text-neutral-900 dark:text-neutral-100",children:"No tokens yet"}),r.jsx("div",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-400",children:"Tokens from tokenized asset purchases will appear here."})]})}function ys(e,t){const n=e/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(n)}catch{return`${n.toFixed(2)} ${t}`}}function dS({serverUrl:e,token:t,authToken:n,onSignIn:s,onContinueShopping:o,className:a}){const[i,c]=w.useState({kind:"loading"}),l=w.useCallback(async()=>{c({kind:"loading"});try{const f=await fetch(`${e}/paywall/v1/gift-card/claim/${encodeURIComponent(t)}`);if(f.status===404){c({kind:"not-found"});return}if(!f.ok){const g=await f.text().catch(()=>`HTTP ${f.status}`);c({kind:"error",message:g});return}const u=await f.json();u.claimed?c({kind:"already-claimed",data:u}):c({kind:"info",data:u})}catch(f){c({kind:"error",message:f instanceof Error?f.message:"Network error"})}},[e,t]);w.useEffect(()=>{l()},[l]);const d=w.useCallback(async()=>{if(n){c({kind:"claiming"});try{const f=await fetch(`${e}/paywall/v1/gift-card/claim/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`}});if(!f.ok){const g=await f.text().catch(()=>`HTTP ${f.status}`);c({kind:"error",message:g});return}const u=await f.json();c({kind:"claimed",result:u})}catch(f){c({kind:"error",message:f instanceof Error?f.message:"Network error"})}}},[e,t,n]);return r.jsx("div",{className:O("flex min-h-[50vh] items-center justify-center p-4",a),children:r.jsx(Xe,{className:"w-full max-w-md overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",children:r.jsx(rt,{className:"p-8",children:i.kind==="loading"?r.jsx(uS,{}):i.kind==="not-found"?r.jsx(fS,{}):i.kind==="error"?r.jsx(mS,{message:i.message,onRetry:l}):i.kind==="already-claimed"?r.jsx(pS,{data:i.data,onContinueShopping:o}):i.kind==="info"?r.jsx(hS,{data:i.data,isAuthenticated:!!n,onClaim:d,onSignIn:s}):i.kind==="claiming"?r.jsx(gS,{}):r.jsx(xS,{result:i.result,onContinueShopping:o})})})})}function uS(){return r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading gift card details..."})}function fS(){return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Gift card not found"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"This gift card link is invalid or has expired. Please check the link and try again."})]})}function mS({message:e,onRetry:t}){return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Something went wrong"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:e}),r.jsx("div",{className:"mt-4",children:r.jsx(X,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Try again"})})]})}function pS({data:e,onContinueShopping:t}){return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Already claimed"}),r.jsxs("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:["This ",ys(e.faceValueCents,e.currency)," gift card has already been redeemed. The credits are in your account."]}),t?r.jsx("div",{className:"mt-6",children:r.jsx(X,{type:"button",onClick:t,children:"Continue shopping"})}):null]})}function hS({data:e,isAuthenticated:t,onClaim:n,onSignIn:s}){const o=ys(e.faceValueCents,e.currency);return r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-sm font-semibold text-emerald-700 dark:text-emerald-400",children:"Gift card"}),r.jsx("div",{className:"mt-2 text-4xl font-bold text-neutral-950 dark:text-neutral-50",children:o}),r.jsx("p",{className:"mt-3 text-sm text-neutral-600 dark:text-neutral-400",children:e.recipientEmail?`A gift card for ${e.recipientEmail} is ready to claim.`:"You have a gift card ready to claim."}),r.jsx("p",{className:"mt-1 text-xs text-neutral-500 dark:text-neutral-500",children:"Credits will be added to your account and can be used for purchases."}),r.jsx("div",{className:"mt-6",children:t?r.jsxs(X,{type:"button",onClick:n,className:"w-full",children:["Claim ",o," credits"]}):r.jsxs(r.Fragment,{children:[r.jsx(X,{type:"button",onClick:s,className:"w-full",children:"Sign in to claim"}),r.jsx("p",{className:"mt-2 text-xs text-neutral-500 dark:text-neutral-500",children:"You need to sign in or create an account to receive your credits."})]})})]})}function gS(){return r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Claiming your gift card..."})}function xS({result:e,onContinueShopping:t}){const n=ys(e.creditsAdded,e.currency),s=ys(e.newBalance,e.currency);return r.jsxs("div",{className:"text-center",children:[r.jsx("h2",{className:"text-xl font-semibold text-neutral-950 dark:text-neutral-50",children:"Gift card claimed"}),r.jsxs("div",{className:"mt-4 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-900/40 dark:bg-emerald-950/30",children:[r.jsxs("div",{className:"text-sm font-semibold text-emerald-900 dark:text-emerald-200",children:[n," credits added"]}),r.jsxs("div",{className:"mt-1 text-xs text-emerald-800/90 dark:text-emerald-200/80",children:["Your new balance is ",s]})]}),t?r.jsx("div",{className:"mt-6",children:r.jsx(X,{type:"button",onClick:t,children:"Start shopping"})}):null]})}function vS(e,t){const n=e/100;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(n)}catch{return`${n.toFixed(2)} ${t}`}}function yS(e){try{return new Date(e).toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})}catch{return e}}function bS({serverUrl:e,className:t}){const[n,s]=w.useState(""),[o,a]=w.useState({kind:"idle"}),i=w.useCallback(async c=>{c.preventDefault();const l=n.trim();if(l){a({kind:"loading"});try{const d=await fetch(`${e}/paywall/v1/gift-card/balance/${encodeURIComponent(l)}`);if(d.status===404){a({kind:"not-found"});return}if(!d.ok){const u=await d.text().catch(()=>`HTTP ${d.status}`);a({kind:"error",message:u});return}const f=await d.json();a({kind:"result",data:f})}catch(d){a({kind:"error",message:d instanceof Error?d.message:"Network error"})}}},[e,n]);return r.jsx(Xe,{className:O("w-full max-w-md overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",t),children:r.jsxs(rt,{className:"p-6",children:[r.jsx("h2",{className:"mb-4 text-lg font-semibold text-neutral-950 dark:text-neutral-50",children:"Check gift card balance"}),r.jsxs("form",{onSubmit:c=>void i(c),className:"space-y-3",children:[r.jsx(Te,{type:"text",value:n,onChange:c=>s(c.target.value),placeholder:"Enter gift card code",required:!0,className:"font-mono tracking-wide uppercase"}),r.jsx(X,{type:"submit",className:"w-full",disabled:o.kind==="loading"||!n.trim(),children:o.kind==="loading"?"Checking...":"Check balance"})]}),o.kind==="result"&&r.jsx(wS,{data:o.data}),o.kind==="not-found"&&r.jsx("div",{className:"mt-4 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900/40 dark:bg-amber-950/30 dark:text-amber-200",children:"No gift card found with that code. Please check the code and try again."}),o.kind==="error"&&r.jsx("div",{className:"mt-4 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-800 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-200",children:o.message})]})})}function wS({data:e}){const t=e.expiresAt&&new Date(e.expiresAt)<=new Date,n=e.active&&!t&&e.balance>0;return r.jsxs("div",{className:"mt-4 space-y-3",children:[r.jsxs("div",{className:O("rounded-xl border p-4 text-center",n?"border-emerald-200 bg-emerald-50 dark:border-emerald-900/40 dark:bg-emerald-950/30":"border-neutral-200 bg-neutral-50 dark:border-neutral-800 dark:bg-neutral-900/50"),children:[r.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-neutral-500 dark:text-neutral-400",children:"Available balance"}),r.jsx("div",{className:O("mt-1 text-3xl font-bold",n?"text-emerald-700 dark:text-emerald-300":"text-neutral-400 dark:text-neutral-600"),children:vS(e.balance,e.currency)})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[r.jsx("div",{className:"text-neutral-500 dark:text-neutral-400",children:"Status"}),r.jsx("div",{className:"text-right",children:e.active?t?r.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Expired"}):e.balance===0?r.jsx("span",{className:"text-neutral-500 dark:text-neutral-400",children:"Fully used"}):r.jsx("span",{className:"text-emerald-600 dark:text-emerald-400",children:"Active"}):r.jsx("span",{className:"text-red-600 dark:text-red-400",children:"Inactive"})}),e.expiresAt&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-neutral-500 dark:text-neutral-400",children:"Expires"}),r.jsx("div",{className:O("text-right",t?"text-amber-600 dark:text-amber-400":"text-neutral-900 dark:text-neutral-100"),children:yS(e.expiresAt)})]})]})]})}function ai(e){const t={};e.shippingProfile&&(t.shippingProfile=e.shippingProfile),e.checkoutRequirements&&(t.checkoutRequirements=JSON.stringify(e.checkoutRequirements)),e.fulfillment?.type&&(t.fulfillmentType=e.fulfillment.type),e.fulfillment?.notes&&(t.fulfillmentNotes=e.fulfillment.notes);const n=e.attributes?.shippingCountries;return typeof n=="string"&&n.trim()&&(t.shippingCountries=n),e.tokenizedAssetConfig&&(t.tokenizedAsset="true",e.tokenizedAssetConfig.regulatoryNotice&&(t.regulatoryNotice=e.tokenizedAssetConfig.regulatoryNotice),e.tokenizedAssetConfig.assetClass&&(t.assetClass=e.tokenizedAssetConfig.assetClass),e.tokenizedAssetConfig.backingValueCents!=null&&(t.backingValueCents=String(e.tokenizedAssetConfig.backingValueCents)),e.tokenizedAssetConfig.backingCurrency&&(t.backingCurrency=e.tokenizedAssetConfig.backingCurrency)),Object.keys(t).length?t:void 0}function kS(e){return r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:r.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}const _S={shop:"/shop",category:e=>`/shop/${e}`,product:e=>`/product/${e}`,cart:"/cart",checkout:"/checkout",orders:"/account/orders",subscribe:"/subscribe"};function jS(e){const t=new Set;let n=Number.POSITIVE_INFINITY,s=0;for(const i of e){for(const c of i.tags??[])t.add(c);n=Math.min(n,i.price),s=Math.max(s,i.price)}const o=Array.from(t).slice(0,12),a=Number.isFinite(n)?{min:n,max:s}:void 0;return{tags:o,price:a}}function SS({className:e,routes:t,initialCategorySlug:n}){const{config:s}=Ae(),o=Et(),a=Qs(),i={..._S,...t},[c,l]=m.useState("cart"),[d,f]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const R=window.matchMedia?.("(min-width: 1024px)");if(!R)return;const G=()=>f(R.matches);return G(),R.addEventListener?.("change",G),()=>R.removeEventListener?.("change",G)},[]);const{categories:u,isLoading:g,error:p}=da(),x=m.useMemo(()=>ma({includeCategory:!0}),[]),[h,v]=m.useState(x?.search??""),[y,k]=m.useState(n??x?.category),[_,b]=m.useState(x?.page??1),[j,N]=m.useState(x?.sort??"featured"),[T,A]=m.useState(x?.filters??{}),{data:E,isLoading:P,error:F}=js({category:y,search:h.trim()||void 0,filters:T,sort:j,page:_,pageSize:24}),L=m.useMemo(()=>jS(E?.items??[]),[E?.items]),{settings:U}=Wn(),$=U.catalog.filters,Y=U.catalog.sort,B=m.useMemo(()=>{const R=[];return Y.featured&&R.push({value:"featured",label:"Featured"}),Y.priceAsc&&R.push({value:"price_asc",label:"Price: Low to High"}),Y.priceDesc&&R.push({value:"price_desc",label:"Price: High to Low"}),R.length===0&&R.push({value:"featured",label:"Featured"}),R},[Y]);m.useEffect(()=>{B.some(R=>R.value===j)||N(B[0].value)},[B,j]),pa({search:h,sort:j,page:_,category:y,filters:T},{includeCategory:!0});const[H,D]=m.useState(!1),[C,I]=m.useState(!1),[Z,ve]=m.useState(null),[V,Q]=m.useState(!1),K=R=>{k(R.slug),b(1),D(!1)},le=m.useCallback((R,G,ue)=>{o.addItem({productId:R.id,variantId:G?.id,unitPrice:R.price,currency:R.currency,titleSnapshot:G?`${R.title} — ${G.title}`:R.title,imageSnapshot:R.images[0]?.url,paymentResource:R.id,metadata:ai(R)},ue),a?.toast({title:"Added to cart",description:R.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(i.cart):(l("cart"),I(!0)))}})},[o,i.cart,a]);return r.jsxs("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:[r.jsx("header",{className:"sticky top-0 z-40 border-b border-neutral-200 bg-neutral-50/80 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/70",children:r.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[r.jsx("a",{href:i.shop,className:"text-sm font-semibold tracking-tight",children:s.brand?.name??"Shop"}),r.jsx("div",{className:"flex-1",children:r.jsx(ti,{value:h,onChange:v})}),r.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[r.jsxs(Bs,{open:H,onOpenChange:D,children:[r.jsx(Us,{asChild:!0,children:r.jsx(X,{type:"button",variant:"outline",children:"Filters"})}),r.jsxs(Er,{side:"left",children:[r.jsx(Vs,{children:r.jsx(Ws,{children:"Browse"})}),r.jsxs("div",{className:"mt-4",children:[p?r.jsx(zt,{description:p}):null,g?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"})]}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(Jo,{categories:u,activeSlug:y,onSelect:K}),r.jsx(vs,{facets:L,value:T,onChange:R=>{A(R),b(1)},onClear:()=>{A({}),b(1)},enabledFilters:$}),B.length>1&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsxs(ps,{value:j,onValueChange:R=>{N(R),b(1)},children:[r.jsx(br,{"aria-label":"Sort",children:r.jsx(hs,{placeholder:"Sort"})}),r.jsx(wr,{children:B.map(R=>r.jsx(kr,{value:R.value,children:R.label},R.value))})]})]})]})]})]})]}),r.jsx(jr,{open:!d&&C,onOpenChange:I,side:"bottom",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:r.jsxs(X,{type:"button",variant:"default",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})})]}),r.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[r.jsx(jr,{open:d&&C,onOpenChange:I,side:"popup",preferredTab:c,onCheckout:()=>{typeof window<"u"&&window.location.assign(i.checkout)},trigger:r.jsxs(X,{type:"button",variant:"outline",onClick:()=>l("cart"),children:["Cart (",o.count,")"]})}),r.jsx(X,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(i.checkout)},children:"Checkout"})]})]})}),r.jsxs(X,{type:"button",variant:"ghost",className:O("fixed bottom-4 right-4 z-30 hidden items-center gap-2 rounded-full border border-neutral-200 bg-white/90 px-3 py-2 text-xs font-medium text-neutral-900 shadow-sm backdrop-blur hover:bg-white dark:border-neutral-800 dark:bg-neutral-950/80 dark:text-neutral-50 dark:hover:bg-neutral-950 lg:flex",C?"lg:hidden":void 0),onClick:()=>{l("chat"),I(!0)},"aria-label":"Open chat",children:[r.jsx(kS,{className:"h-4 w-4"}),"Chat"]}),r.jsxs("main",{className:"mx-auto grid max-w-7xl items-start gap-6 px-4 py-6 lg:grid-cols-[280px_1fr]",children:[r.jsx("aside",{className:"hidden lg:block",children:r.jsx("div",{className:"sticky top-24",children:r.jsxs(Xe,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:[r.jsx(gr,{className:"pb-4",children:r.jsx(xr,{className:"text-base",children:"Browse"})}),r.jsxs(rt,{className:"flex-1 space-y-6 overflow-y-auto pr-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Categories"}),p?r.jsx(zt,{className:"mt-3",description:p}):null,g?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"}),r.jsx(Oe,{className:"h-9"})]}):r.jsx("div",{className:"mt-3",children:r.jsx(Jo,{categories:u,activeSlug:y,onSelect:K})})]}),B.length>1&&r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsx("div",{className:"mt-2",children:r.jsxs(ps,{value:j,onValueChange:R=>{N(R),b(1)},children:[r.jsx(br,{"aria-label":"Sort",children:r.jsx(hs,{placeholder:"Sort"})}),r.jsx(wr,{children:B.map(R=>r.jsx(kr,{value:R.value,children:R.label},R.value))})]})})]}),r.jsx(vs,{facets:L,value:T,onChange:R=>{A(R),b(1)},onClear:()=>{A({}),b(1)},enabledFilters:$})]})]})})}),r.jsxs("section",{children:[r.jsx("div",{className:"flex items-end justify-between gap-3",children:r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:U.shopPage.title||"Shop"}),U.shopPage.description&&r.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:U.shopPage.description})]})}),F?r.jsx(zt,{className:"mt-6",description:F}):null,P?r.jsx("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((R,G)=>r.jsx(Oe,{className:"aspect-[4/5] rounded-2xl"},G))}):r.jsxs("div",{className:"mt-6",children:[r.jsx(Js,{products:E?.items??[],columns:s.ui?.productGrid?.columns,getProductHref:R=>i.product(R.slug),onAddToCart:R=>le(R,null,1),onQuickView:R=>{ve(R),Q(!0)},layout:U.shopLayout.layout,imageCrop:U.shopLayout.imageCrop}),r.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[r.jsx(X,{type:"button",variant:"outline",disabled:_<=1,onClick:()=>b(R=>Math.max(1,R-1)),children:"Previous"}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",_]}),r.jsx(X,{type:"button",variant:"outline",disabled:!E?.hasNextPage,onClick:()=>b(R=>R+1),children:"Next"})]})]})]})]}),r.jsx(Xa,{product:Z,open:V,onOpenChange:Q,productHref:R=>i.product(R),onAddToCart:(R,G,ue)=>le(R,G,ue)})]})}function CS(e){return r.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e,children:r.jsx("path",{d:"M21 15a4 4 0 0 1-4 4H8l-5 3V7a4 4 0 0 1 4-4h10a4 4 0 0 1 4 4z"})})}function NS({categorySlug:e,className:t,routes:n}){const{config:s}=Ae(),o=Et(),a=Qs(),{categories:i}=da(),[c,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const W=window.matchMedia?.("(min-width: 1024px)");if(!W)return;const se=()=>l(W.matches);return se(),W.addEventListener?.("change",se),()=>W.removeEventListener?.("change",se)},[]);const[d,f]=m.useState(!1),[u,g]=m.useState(!1),[p,x]=m.useState("cart"),h=m.useMemo(()=>ma({includeCategory:!1}),[]),[v,y]=m.useState(h?.search??""),[k,_]=m.useState(h?.page??1),[b,j]=m.useState(h?.sort??"featured"),[N,T]=m.useState(h?.filters??{}),[A,E]=m.useState(null),[P,F]=m.useState(!1),L=i.find(W=>W.slug===e)??null,{data:U,isLoading:$,error:Y}=js({category:e,search:v.trim()||void 0,filters:N,sort:b,page:k,pageSize:24}),B=n?.product??(W=>`/product/${W}`),H=n?.shop??"/shop",D=n?.cart??"/cart",C=n?.checkout??"/checkout",I=m.useMemo(()=>{const W=U?.items??[],se=new Set;let ie=Number.POSITIVE_INFINITY,ye=0;for(const Qe of W){for(const Ve of Qe.tags??[])se.add(Ve);ie=Math.min(ie,Qe.price),ye=Math.max(ye,Qe.price)}const fe=Array.from(se).slice(0,12),Ue=Number.isFinite(ie)?{min:ie,max:ye}:void 0;return{tags:fe,price:Ue}},[U?.items]),{settings:Z}=Wn(),ve=Z.catalog.filters,V=Z.catalog.sort,Q=m.useMemo(()=>{const W=[];return V.featured&&W.push({value:"featured",label:"Featured"}),V.priceAsc&&W.push({value:"price_asc",label:"Price: Low to High"}),V.priceDesc&&W.push({value:"price_desc",label:"Price: High to Low"}),W.length===0&&W.push({value:"featured",label:"Featured"}),W},[V]);m.useEffect(()=>{Q.some(W=>W.value===b)||j(Q[0].value)},[Q,b]),pa({search:v,sort:b,page:k,filters:N},{includeCategory:!1});const K=m.useCallback((W,se,ie)=>{o.addItem({productId:W.id,variantId:se?.id,unitPrice:W.price,currency:W.currency,titleSnapshot:se?`${W.title} — ${se.title}`:W.title,imageSnapshot:W.images[0]?.url,paymentResource:W.id,metadata:ai(W)},ie),a?.toast({title:"Added to cart",description:W.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(D):(x("cart"),g(!0)))}})},[o,D,a]),le=W=>{T(W),_(1)},R=()=>{T({}),_(1)},G=W=>{j(W),_(1)},ue=r.jsx(Xe,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:r.jsxs(rt,{className:"flex-1 space-y-5 overflow-y-auto pr-2 pt-6",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-neutral-500 dark:text-neutral-400",children:"Category"}),r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",children:r.jsx("a",{href:H,children:"All categories"})})]}),r.jsx("div",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:L?.name??e}),r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:L?.description??"Browse products in this category."})]}),Q.length>1&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsxs(ps,{value:b,onValueChange:G,children:[r.jsx(br,{"aria-label":"Sort",children:r.jsx(hs,{placeholder:"Sort"})}),r.jsx(wr,{children:Q.map(W=>r.jsx(kr,{value:W.value,children:W.label},W.value))})]})]}),r.jsx(lt,{}),r.jsx(vs,{facets:I,value:N,onChange:le,onClear:R,enabledFilters:ve})]})});return r.jsxs("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:[r.jsx("header",{className:"sticky top-0 z-40 border-b border-neutral-200 bg-neutral-50/80 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/70",children:r.jsxs("div",{className:"mx-auto flex max-w-7xl items-center gap-3 px-4 py-3",children:[r.jsx("a",{href:H,className:"text-sm font-semibold tracking-tight",children:s.brand?.name??"Shop"}),r.jsx("div",{className:"flex-1",children:r.jsx(ti,{value:v,onChange:y})}),r.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[r.jsxs(Bs,{open:d,onOpenChange:f,children:[r.jsx(Us,{asChild:!0,children:r.jsx(X,{type:"button",variant:"outline",children:"Filters"})}),r.jsxs(Er,{side:"left",children:[r.jsx(Vs,{children:r.jsx(Ws,{children:"Filters"})}),r.jsx("div",{className:"mt-4",children:ue})]})]}),r.jsx(jr,{open:!c&&u,onOpenChange:g,side:"bottom",preferredTab:p,onCheckout:()=>{typeof window<"u"&&window.location.assign(C)},trigger:r.jsxs(X,{type:"button",variant:"default",onClick:()=>x("cart"),children:["Cart (",o.count,")"]})})]}),r.jsxs("div",{className:"hidden lg:flex items-center gap-2",children:[r.jsx(jr,{open:c&&u,onOpenChange:g,side:"popup",preferredTab:p,onCheckout:()=>{typeof window<"u"&&window.location.assign(C)},trigger:r.jsxs(X,{type:"button",variant:"outline",onClick:()=>x("cart"),children:["Cart (",o.count,")"]})}),r.jsx(X,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(C)},children:"Checkout"})]})]})}),r.jsxs(X,{type:"button",variant:"ghost",className:O("fixed bottom-4 right-4 z-30 hidden items-center gap-2 rounded-full border border-neutral-200 bg-white/90 px-3 py-2 text-xs font-medium text-neutral-900 shadow-sm backdrop-blur hover:bg-white dark:border-neutral-800 dark:bg-neutral-950/80 dark:text-neutral-50 dark:hover:bg-neutral-950 lg:flex",u?"lg:hidden":void 0),onClick:()=>{x("chat"),g(!0)},"aria-label":"Open chat",children:[r.jsx(CS,{className:"h-4 w-4"}),"Chat"]}),r.jsxs("main",{className:"mx-auto max-w-7xl px-4 py-8",children:[r.jsx(ei,{items:[{label:"Shop",href:H},{label:L?.name??e}]}),r.jsxs("div",{className:"mt-6",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:L?.name??"Category"}),r.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:L?.description??"Browse products in this category."})]}),Y?r.jsx(zt,{className:"mt-6",description:Y}):null,r.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-[280px_1fr]",children:[r.jsx("aside",{className:"hidden lg:block",children:r.jsx("div",{className:"sticky top-24",children:ue})}),r.jsx("div",{children:$?r.jsx("div",{className:"mt-6 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((W,se)=>r.jsx(Oe,{className:"aspect-[4/5] rounded-2xl"},se))}):r.jsxs("div",{className:"mt-6",children:[r.jsx(Js,{products:U?.items??[],columns:s.ui?.productGrid?.columns,getProductHref:W=>B(W.slug),onAddToCart:W=>K(W,null,1),onQuickView:W=>{E(W),F(!0)},layout:Z.categoryLayout.layout,imageCrop:Z.categoryLayout.imageCrop}),r.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[r.jsx(X,{type:"button",variant:"outline",disabled:k<=1,onClick:()=>_(W=>Math.max(1,W-1)),children:"Previous"}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",k]}),r.jsx(X,{type:"button",variant:"outline",disabled:!U?.hasNextPage,onClick:()=>_(W=>W+1),children:"Next"})]})]})})]}),r.jsx(Xa,{product:A,open:P,onOpenChange:F,productHref:W=>B(W),onAddToCart:(W,se,ie)=>K(W,se,ie)})]})]})}function AS(e){return!e||typeof e!="string"?[]:e.split(",").map(t=>t.trim()).filter(Boolean)}function ES({config:e,currency:t}){return r.jsxs("div",{className:"mt-4 rounded-xl border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/40",children:[r.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-neutral-500 dark:text-neutral-400",children:"Tokenized Asset"}),r.jsxs("div",{className:"mt-2 space-y-1.5 text-sm text-neutral-700 dark:text-neutral-300",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Backing value"}),r.jsx("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:Fe({amount:e.backingValueCents/100,currency:e.backingCurrency||t})})]}),e.assetIdentifier?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Asset ID"}),r.jsx("span",{className:"font-mono text-xs text-neutral-950 dark:text-neutral-50",children:e.assetIdentifier})]}):null,e.tokensPerUnit>1?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Tokens per unit"}),r.jsx("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:e.tokensPerUnit})]}):null,Ze(e.custodyProofUrl)?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Custody proof"}),r.jsx("a",{href:Ze(e.custodyProofUrl),target:"_blank",rel:"noreferrer",className:"text-xs font-medium underline underline-offset-2",children:"View document"})]}):null,e.nftMintAddress?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"On-chain token"}),r.jsxs("a",{href:`https://solscan.io/account/${e.nftMintAddress}`,target:"_blank",rel:"noreferrer",className:"font-mono text-xs font-medium underline underline-offset-2",children:[e.nftMintAddress.slice(0,4),"...",e.nftMintAddress.slice(-4)]})]}):null]}),e.regulatoryNotice?r.jsx("div",{className:"mt-3 rounded-lg border border-amber-200 bg-amber-50 p-3 text-xs text-amber-900 dark:border-amber-900/40 dark:bg-amber-950/30 dark:text-amber-200",children:e.regulatoryNotice}):null]})}function IS({slug:e,className:t,routes:n}){const s=Et(),o=Qs(),{product:a,isLoading:i,error:c}=Ll(e),[l,d]=m.useState(1),[f,u]=m.useState({selectedOptions:{},variant:null});m.useEffect(()=>{if(!a||!a.variants?.length)return;const $=a.variants[0];u({selectedOptions:{...$.options},variant:$})},[a?.id]);const{settings:g}=Wn(),{mode:p,maxItems:x}=g.relatedProducts,h=Ul({productId:a?.id,enabled:p==="ai"&&!!a?.id}),v=m.useMemo(()=>p==="by_category"&&a?.categoryIds?.length?{category:a.categoryIds[0],page:1,pageSize:x+1}:{page:1,pageSize:x+4},[p,x,a?.categoryIds]),y=js(v),k=m.useMemo(()=>{const Y=(y.data?.items??[]).filter(B=>B.slug!==e);if(p==="manual"&&a){const B=a.attributes?.relatedProductIds||a.attributes?.related_product_ids;if(B){const H=AS(String(B));if(H.length>0){const D=new Map(Y.map(I=>[I.id,I]));return H.map(I=>D.get(I)).filter(I=>!!I).slice(0,x)}}}if(p==="ai"&&h.relatedProductIds&&h.relatedProductIds.length>0){const B=new Map(Y.map(D=>[D.id,D])),H=h.relatedProductIds.map(D=>B.get(D)).filter(D=>!!D);if(H.length>0)return H.slice(0,x)}return Y.slice(0,x)},[y.data?.items,e,p,x,a,h.relatedProductIds]),_=n?.shop??"/shop",b=n?.checkout??"/checkout",j=n?.cart??"/cart",N=n?.product??($=>`/product/${$}`);if(i)return r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:r.jsxs("div",{className:"mx-auto max-w-6xl",children:[r.jsx(Oe,{className:"h-5 w-40"}),r.jsxs("div",{className:"mt-6 grid gap-8 lg:grid-cols-2",children:[r.jsx(Oe,{className:"aspect-square rounded-2xl"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx(Oe,{className:"h-8 w-2/3"}),r.jsx(Oe,{className:"h-6 w-32"}),r.jsx(Oe,{className:"h-20"}),r.jsx(Oe,{className:"h-11"})]})]})]})});if(c)return r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:r.jsx("div",{className:"mx-auto max-w-6xl",children:r.jsx(zt,{description:c})})});if(!a)return r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-6 dark:bg-neutral-950",t),children:r.jsx("div",{className:"mx-auto max-w-6xl",children:r.jsx(zt,{description:"Product not found."})})});const T=f.variant?.price??a.price,A=f.variant?.compareAtPrice??a.compareAtPrice,E=f.variant?.inventoryStatus==="out_of_stock"||typeof f.variant?.inventoryQuantity=="number"&&f.variant.inventoryQuantity<=0,P=a.inventoryStatus==="out_of_stock"||typeof a.inventoryQuantity=="number"&&a.inventoryQuantity<=0,F=f.variant?E:P,L=()=>{F||(s.addItem({productId:a.id,variantId:f.variant?.id,unitPrice:T,currency:a.currency,titleSnapshot:f.variant?`${a.title} — ${f.variant.title}`:a.title,imageSnapshot:a.images[0]?.url,paymentResource:a.id,metadata:ai(a)},l),o?.toast({title:"Added to cart",description:a.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&window.location.assign(j)}}))},U=()=>{F||(L(),typeof window<"u"&&window.location.assign(b))};return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",t),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-8",children:[r.jsx(ei,{items:[{label:"Shop",href:_},{label:a.title}]}),r.jsxs("div",{className:"mt-6 grid gap-10 lg:grid-cols-2",children:[r.jsx(Qa,{images:a.images}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:a.title}),a.tokenizedAssetConfig?.assetClass?r.jsx(Ya,{assetClass:a.tokenizedAssetConfig.assetClass}):null]}),r.jsx("div",{className:"mt-3",children:r.jsx(Ks,{amount:T,currency:a.currency,compareAt:A})}),F?r.jsx("div",{className:"mt-2 text-sm font-medium text-red-700 dark:text-red-300",children:"Out of stock"}):typeof a.inventoryQuantity=="number"&&a.inventoryQuantity>0&&a.inventoryQuantity<=5?r.jsxs("div",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:["Only ",r.jsx("span",{className:"font-semibold text-neutral-950 dark:text-neutral-50",children:a.inventoryQuantity})," left"]}):null,r.jsx("p",{className:"mt-4 text-sm text-neutral-600 dark:text-neutral-400",children:a.description}),a.tokenizedAssetConfig?r.jsx(ES,{config:a.tokenizedAssetConfig,currency:a.currency}):null]}),r.jsx(Ka,{product:a,value:{selectedOptions:f.selectedOptions,variantId:f.variant?.id},onChange:$=>u($)}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(Ja,{qty:l,onChange:d}),r.jsx(X,{type:"button",onClick:L,className:"flex-1",disabled:F,children:F?"Out of stock":"Add to cart"}),r.jsx(X,{type:"button",variant:"outline",onClick:U,disabled:F,children:"Buy now"})]}),(g.sections.showDescription||g.sections.showSpecs||g.sections.showShipping)&&r.jsxs(lf,{type:"single",collapsible:!0,defaultValue:g.sections.showDescription?"desc":void 0,children:[g.sections.showDescription&&r.jsxs(ur,{value:"desc",children:[r.jsx(fr,{children:"Description"}),r.jsx(mr,{children:r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.description})})]}),g.sections.showSpecs&&r.jsxs(ur,{value:"specs",children:[r.jsx(fr,{children:"Specs"}),r.jsx(mr,{children:r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:a.attributes?r.jsx("div",{className:"space-y-1",children:Object.entries(a.attributes).map(([$,Y])=>r.jsxs("div",{children:[r.jsxs("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:[$,":"]})," ",String(Y)]},$))}):"No specs provided."})})]}),g.sections.showShipping&&r.jsxs(ur,{value:"ship",children:[r.jsx(fr,{children:"Shipping & returns"}),r.jsx(mr,{children:r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"Ships in 2–3 business days. Easy returns within 30 days."})})]})]})]})]}),g.sections.showRelatedProducts&&k.length?r.jsxs("section",{className:"mt-12",children:[r.jsx("h2",{className:"text-lg font-semibold",children:"Related products"}),r.jsx("div",{className:"mt-4",children:r.jsx(Js,{products:k,columns:{base:2,md:4,lg:4},layout:g.relatedProducts.layout.layout,imageCrop:g.relatedProducts.layout.imageCrop,getProductHref:$=>N($.slug),onAddToCart:$=>s.addItem({productId:$.id,unitPrice:$.price,currency:$.currency,titleSnapshot:$.title,imageSnapshot:$.images[0]?.url,paymentResource:$.id},1)})})]}):null]})})}function TS({className:e,checkoutHref:t}){const{config:n}=Ae(),{settings:s}=Wn(),o=t??"/checkout",a=n.checkout.allowPromoCodes&&s.checkout.promoCodes;return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Cart"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"Review items, adjust quantities, then check out."}),r.jsx("div",{className:"mt-8",children:r.jsx(Ff,{onCheckout:()=>{typeof window<"u"&&window.location.assign(o)},showPromoCode:a})})]})})}function PS({className:e,routes:t}){const{config:n}=Ae(),s=Et(),o=fa(),a=n.customer?.isSignedIn??!!n.customer?.id,c=!(n.checkout.requireAccount?!1:n.checkout.guestCheckout??!0)&&!a;m.useEffect(()=>{o.kind==="success"&&s.clear()},[o.kind]);const l=t?.shop??"/shop",d=t?.orders??"/account/orders",f=t?.login;return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-10",children:[r.jsx(eo,{result:o,onContinueShopping:()=>{typeof window<"u"&&window.location.assign(l)},onViewOrders:()=>{typeof window<"u"&&window.location.assign(d)}}),o.kind==="idle"?r.jsxs(r.Fragment,{children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Checkout"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:n.checkout.mode==="none"?"Confirm and pay.":"Enter details, then complete payment."})]}),r.jsx("div",{className:"mt-8",children:r.jsx(Ml,{children:c?r.jsxs(Xe,{className:"rounded-2xl",children:[r.jsx(gr,{className:"pb-4",children:r.jsx(xr,{className:"text-base",children:"Sign in required"})}),r.jsxs(rt,{children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:"This store requires an account to complete checkout."}),f?r.jsx("div",{className:"mt-4",children:r.jsx(X,{type:"button",onClick:()=>{typeof window<"u"&&window.location.assign(f)},children:"Sign in"})}):null]})]}):r.jsx(Bf,{left:r.jsxs("div",{className:"space-y-6",children:[r.jsx(Wf,{}),r.jsxs(Xe,{className:"rounded-2xl",children:[r.jsx(gr,{className:"pb-4",children:r.jsx(xr,{className:"text-base",children:"Payment"})}),r.jsxs(rt,{children:[r.jsx(lt,{className:"mb-4"}),r.jsx(Hf,{})]})]})]}),right:r.jsx("div",{className:"lg:sticky lg:top-24",children:r.jsx(Zf,{})})})})})]}):null]})})}function RS({className:e,isSignedIn:t=!0,onLogin:n,serverUrl:s,authToken:o}){const{orders:a,isLoading:i,error:c}=Dl(),[l,d]=m.useState(null);return t?r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-5xl px-4 py-10 sm:py-12",children:[r.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Orders"}),r.jsx("p",{className:"mt-2 text-sm text-neutral-600 dark:text-neutral-400",children:"View past purchases and receipts."})]}),!i&&!c&&!l&&a.length>0?r.jsxs("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:[a.length," order",a.length===1?"":"s"]}):null]}),c?r.jsx(zt,{className:"mt-8",description:c}):null,i?r.jsxs("div",{className:"mt-8 grid gap-4",children:[r.jsx(Oe,{className:"h-32 rounded-2xl"}),r.jsx(Oe,{className:"h-32 rounded-2xl"}),r.jsx(Oe,{className:"h-32 rounded-2xl"})]}):a.length===0?r.jsx("div",{className:"mt-8",children:r.jsx(Un,{title:"No orders yet",description:"When you purchase something, it will show up here."})}):l?r.jsx("div",{className:"mt-8",children:r.jsx(Qf,{order:l,onBack:()=>d(null),serverUrl:s,authToken:o})}):r.jsx("div",{className:"mt-8",children:r.jsx(Yf,{orders:a,onView:d})})]})}):r.jsx("div",{className:O("min-h-screen bg-neutral-50 p-10 dark:bg-neutral-950",e),children:r.jsx("div",{className:"mx-auto max-w-4xl",children:r.jsx(Un,{title:"Sign in to view your orders",description:"Your purchase history will appear here once you're logged in.",actionLabel:n?"Sign in":void 0,onAction:n})})})}function OS({className:e}){return r.jsxs("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),r.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),r.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}function MS({className:e}){return r.jsx("svg",{className:e,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"m15 18-6-6 6-6"})})}function LS(e){switch(e){case"x402":return"Crypto (x402)";case"credits":return"Credits";case"stripe":return"Card";default:return"Payment"}}function DS({order:e,source:t,purchaseId:n,customerEmail:s,customerName:o,className:a,onBack:i}){const{config:c}=Ae(),l=t??e.source,d=n??e.purchaseId,f=s??e.customerEmail,u=o??e.customerName,g=c.brand?.name??"Store",p=c.brand?.logoUrl,x=()=>{typeof window<"u"&&window.print()},h=new Date(e.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}),v=new Date(e.createdAt).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return r.jsxs("div",{className:O("min-h-screen bg-neutral-100 dark:bg-neutral-900 print:bg-white print:dark:bg-white",a),children:[r.jsx("div",{className:"border-b border-neutral-200 bg-white px-4 py-3 dark:border-neutral-800 dark:bg-neutral-950 print:hidden",children:r.jsxs("div",{className:"mx-auto flex max-w-2xl items-center justify-between",children:[i?r.jsxs(X,{type:"button",variant:"ghost",size:"sm",onClick:i,children:[r.jsx(MS,{className:"mr-1"})," Back"]}):r.jsx("div",{}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:x,children:[r.jsx(OS,{className:"mr-2"})," Print Receipt"]})]})}),r.jsx("div",{className:"mx-auto max-w-2xl px-4 py-8 print:max-w-none print:px-0 print:py-0",children:r.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white p-8 shadow-sm dark:border-neutral-800 dark:bg-neutral-950 print:border-0 print:shadow-none print:dark:bg-white print:dark:text-neutral-950",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-neutral-200 pb-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[p?r.jsx("img",{src:p,alt:g,className:"h-10 w-10 rounded-lg object-contain"}):null,r.jsx("div",{className:"text-xl font-semibold",children:g})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Receipt"}),r.jsx("div",{className:"mt-1 font-mono text-sm",children:e.id})]})]}),r.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-4 text-sm sm:grid-cols-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Date"}),r.jsx("div",{className:"mt-1 font-medium",children:h}),r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:v})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Payment Method"}),r.jsx("div",{className:"mt-1 font-medium",children:LS(l)})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Status"}),r.jsx("div",{className:"mt-1",children:r.jsx(ht,{variant:"outline",className:"capitalize print:border-neutral-300",children:e.status})})]})]}),(u||f)&&r.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Customer"}),u&&r.jsx("div",{className:"mt-1 font-medium",children:u}),f&&r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:f})]}),r.jsx("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-neutral-200 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("th",{className:"pb-3 text-left font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Item"}),r.jsx("th",{className:"pb-3 text-center font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Qty"}),r.jsx("th",{className:"pb-3 text-right font-medium text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Price"})]})}),r.jsx("tbody",{children:e.items.map((y,k)=>r.jsxs("tr",{className:"border-b border-neutral-100 dark:border-neutral-800/50 print:dark:border-neutral-100",children:[r.jsx("td",{className:"py-3",children:r.jsx("div",{className:"font-medium",children:y.title})}),r.jsx("td",{className:"py-3 text-center text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:y.qty}),r.jsx("td",{className:"py-3 text-right",children:Fe({amount:y.unitPrice*y.qty,currency:y.currency})})]},`${y.title}-${k}`))})]})}),r.jsxs("div",{className:"mt-4 flex flex-col items-end gap-2 text-sm",children:[r.jsxs("div",{className:"flex w-48 justify-between",children:[r.jsx("span",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Subtotal"}),r.jsx("span",{children:Fe({amount:e.total,currency:e.currency})})]}),r.jsxs("div",{className:"flex w-48 justify-between border-t border-neutral-200 pt-2 text-base font-semibold dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("span",{children:"Total"}),r.jsx("span",{children:Fe({amount:e.total,currency:e.currency})})]})]}),d&&r.jsxs("div",{className:"mt-6 border-t border-neutral-200 pt-6 dark:border-neutral-800 print:dark:border-neutral-200",children:[r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:"Transaction ID"}),r.jsx("div",{className:"mt-1 break-all font-mono text-xs",children:d})]}),r.jsxs("div",{className:"mt-8 border-t border-neutral-200 pt-6 text-center text-xs text-neutral-500 dark:border-neutral-800 dark:text-neutral-400 print:dark:border-neutral-200 print:dark:text-neutral-500",children:[r.jsx("p",{children:"Thank you for your purchase!"}),r.jsx("p",{className:"mt-1",children:"If you have any questions, please contact support."})]})]})})]})}function $S({className:e}){return r.jsx("svg",{className:O("h-4 w-4 flex-shrink-0",e),viewBox:"0 0 20 20",fill:"currentColor",children:r.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})}function zS({className:e,title:t="Choose Your Plan",subtitle:n="Select the plan that best fits your needs.",annualSavingsBadge:s="2 months free",popularBadgeText:o="Best Deal",footerNotice:a}){const{config:i}=Ae(),{tiers:c,status:l,isLoading:d,error:f}=$l(),[u,g]=m.useState("monthly"),p=!!i.adapter.createSubscriptionCheckoutSession,x=async h=>{if(!i.adapter.createSubscriptionCheckoutSession)return;const v=await i.adapter.createSubscriptionCheckoutSession({tierId:h,interval:u,successUrl:i.checkout.successUrl,cancelUrl:i.checkout.cancelUrl});v.kind==="redirect"&&typeof window<"u"&&window.location.assign(v.url)};return r.jsx("div",{className:O("min-h-screen bg-neutral-50 text-neutral-950 dark:bg-neutral-950 dark:text-neutral-50",e),children:r.jsxs("main",{className:"mx-auto max-w-6xl px-4 py-16",children:[r.jsxs("div",{className:"text-center",children:[r.jsx("h1",{className:"text-5xl font-bold tracking-tight",children:t}),r.jsx("p",{className:"mt-4 text-base text-neutral-600 dark:text-neutral-400",children:n})]}),r.jsx("div",{className:"mt-10 flex justify-center",children:r.jsxs("div",{className:"inline-flex items-center rounded-full bg-neutral-200/60 p-1 dark:bg-neutral-800/60",children:[r.jsxs("button",{type:"button",onClick:()=>g("annual"),className:O("relative flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-all",u==="annual"?"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900":"text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"),children:["Yearly",s&&r.jsx("span",{className:O("rounded-full px-2 py-0.5 text-xs font-medium",u==="annual"?"bg-white/20 text-white dark:bg-neutral-900/20 dark:text-neutral-900":"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900"),children:s})]}),r.jsx("button",{type:"button",onClick:()=>g("monthly"),className:O("rounded-full px-4 py-2 text-sm font-medium transition-all",u==="monthly"?"bg-neutral-900 text-white dark:bg-white dark:text-neutral-900":"text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-white"),children:"Monthly"})]})}),f?r.jsx(zt,{className:"mt-10",description:f}):null,d?r.jsxs("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:[r.jsx(Oe,{className:"h-[480px] rounded-2xl"}),r.jsx(Oe,{className:"h-[480px] rounded-2xl"}),r.jsx(Oe,{className:"h-[480px] rounded-2xl"})]}):c.length===0?r.jsx("div",{className:"mt-12",children:r.jsx(Un,{title:"No plans available",description:"Subscription plans will appear here once configured."})}):r.jsx("div",{className:"mt-12 grid gap-6 md:grid-cols-3 items-start",children:c.map(h=>{const v=l?.isActive&&l.currentTierId===h.id,y=u==="annual"&&h.priceAnnual?h.priceAnnual:h.priceMonthly,k=h.isPopular,_=h.inventoryQuantity!=null,b=_?Math.max(0,(h.inventoryQuantity??0)-(h.inventorySold??0)):null,j=_&&b===0,N=_&&b!=null&&b>0&&b<=5,[T,...A]=h.features;return r.jsxs("div",{className:O("relative flex flex-col rounded-2xl border p-6 transition-shadow",k?"border-neutral-900 bg-neutral-900 text-white shadow-xl dark:border-white dark:bg-white dark:text-neutral-900":"border-neutral-200 bg-white dark:border-neutral-800 dark:bg-neutral-900"),children:[k&&o&&r.jsx("div",{className:"absolute -top-3 right-4",children:r.jsx("span",{className:"rounded-full bg-neutral-100 px-3 py-1 text-xs font-semibold text-neutral-900 shadow-sm dark:bg-neutral-800 dark:text-white",children:o})}),r.jsxs("div",{className:"mb-6",children:[r.jsx("h3",{className:"text-xl font-bold",children:h.title}),h.description&&r.jsx("p",{className:O("mt-2 text-sm leading-relaxed",k?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:h.description})]}),r.jsxs("div",{className:"mb-6",children:[r.jsx("div",{className:"text-5xl font-bold tracking-tight",children:Fe({amount:y,currency:h.currency||i.currency})}),r.jsxs("div",{className:O("mt-2 text-sm",k?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:["Per ",u==="annual"?"year":"month",", billed ",u==="annual"?"annually":"monthly"]})]}),_&&r.jsx("div",{className:O("mb-3 text-xs font-medium",j?"text-red-600 dark:text-red-400":N?k?"text-amber-300 dark:text-amber-600":"text-amber-600 dark:text-amber-400":k?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400"),children:j?"Sold out":`${b} remaining`}),r.jsx(X,{type:"button",className:O("mb-6 w-full rounded-full py-3 font-medium",k?"bg-white text-neutral-900 hover:bg-neutral-100 dark:bg-neutral-900 dark:text-white dark:hover:bg-neutral-800":""),variant:k?"default":"outline",disabled:v||!p||j,onClick:()=>void x(h.id),children:j?"Sold Out":v?"Current Plan":"Purchase"}),T&&r.jsx("div",{className:O("mb-4 text-sm font-semibold",k?"":"text-neutral-900 dark:text-white"),children:T}),A.length>0&&r.jsx("ul",{className:"space-y-3",children:A.map((E,P)=>r.jsxs("li",{className:"flex items-start gap-3",children:[r.jsx($S,{className:O("mt-0.5",k?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")}),r.jsx("span",{className:O("text-sm leading-relaxed",k?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:E})]},P))})]},h.id)})}),a&&r.jsx("div",{className:"mt-12 text-center",children:r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400 leading-relaxed max-w-2xl mx-auto",children:a})})]})})}function FS(e){const{processCartCheckout:t}=tm.useStripeCheckout();return m.useMemo(()=>({...e,async createCheckoutSession(n){const{customer:s,options:o}=n,a=s.shippingAddress?s.shippingAddress:void 0,i=s.billingAddress?s.billingAddress:void 0,c=await t(n.cart,o.successUrl,o.cancelUrl,o.metadata,s.email,o.discountCode,s.name,s.phone,a,i,o.tipAmount,o.shippingMethodId,o.paymentMethodId);if(!c.success)throw new Error(c.error||"Checkout failed");return{kind:"redirect",url:n.options.successUrl??"/"}},async resolveCheckoutReturn({query:n}){return ua(n)}}),[e,t])}const BS=Object.freeze(Object.defineProperty({__proto__:null,Accordion:lf,AccordionContent:mr,AccordionItem:ur,AccordionTrigger:fr,AddressForm:Xo,AssetBadge:Ya,Badge:ht,Breadcrumbs:ei,Button:X,Card:Xe,CardContent:rt,CardDescription:od,CardFooter:ad,CardHeader:gr,CardTitle:xr,CartLineItem:ni,CartPageContent:Ff,CartPanel:Df,CartProvider:Jm,CartSidebar:jr,CartSummary:ri,CartTemplate:TS,CategoryNav:Jo,CategoryTemplate:NS,CedrosShopProvider:Em,CheckoutCancelPage:Jj,CheckoutForm:Wf,CheckoutLayout:Bf,CheckoutProvider:Ml,CheckoutReceipt:eo,CheckoutSuccessPage:Kj,CheckoutTemplate:PS,Dialog:Ma,DialogClose:r_,DialogContent:zs,DialogDescription:$a,DialogFooter:zu,DialogHeader:Da,DialogOverlay:La,DialogPortal:$u,DialogTitle:Fs,DialogTrigger:n_,EmptyState:Un,ErrorBoundary:D_,ErrorState:zt,FAQItem:Of,FAQList:Mj,FilterPanel:vs,GiftCardBalanceChecker:bS,GiftCardRedemptionPage:dS,Input:Te,InventoryVerificationDialog:qf,Label:He,MyRedemptionsPage:aS,MyTokensPage:lS,OrderCard:Gf,OrderDetails:Qf,OrderList:Yf,OrderReview:Zf,PaymentStep:Hf,Price:Ks,ProductCard:Mf,ProductGallery:Qa,ProductGrid:Js,ProductTemplate:IS,PromoCodeInput:si,PurchaseHistoryTemplate:RS,QuantitySelector:Ja,QuickViewDialog:Xa,ReceiptTemplate:DS,RedemptionForm:Xs,SearchInput:ti,Select:ps,SelectContent:wr,SelectGroup:Dk,SelectItem:kr,SelectTrigger:br,SelectValue:hs,SendAsGiftSection:Uf,Separator:lt,Sheet:Bs,SheetClose:Fu,SheetContent:Er,SheetDescription:Uu,SheetHeader:Vs,SheetOverlay:za,SheetPortal:Bu,SheetTitle:Ws,SheetTrigger:Us,ShippingMethodSelector:Vf,ShopChatPanel:zf,ShopTemplate:SS,Skeleton:Oe,SubscriptionTemplate:zS,Tabs:Za,TabsContent:Ef,TabsList:Ys,TabsTrigger:_r,ToastProvider:mj,TokenDisplay:oi,VariantSelector:Ka,createMockCommerceAdapter:Om,createPaywallCommerceAdapter:Wm,parseCheckoutReturn:ua,readCatalogUrlState:ma,useAIRelatedProducts:Ul,useCart:Et,useCartInventory:ha,useCatalogUrlSync:pa,useCategories:da,useCedrosPayCheckoutAdapter:FS,useCedrosShop:Ae,useCheckout:Nr,useCheckoutResultFromUrl:fa,useHoldExpiry:Q0,useInventoryVerification:Fl,useOptionalToast:Qs,useOrders:Dl,usePaymentMethodsConfig:Bl,useProduct:Ll,useProducts:js,useShippingMethods:zl,useStandaloneCheckout:z0,useStorefrontSettings:Wn,useSubscriptionData:$l,useToast:fj,validateCommerceAdapterContract:tv},Symbol.toStringTag,{value:"Module"}));exports.CEDROS_PAY_GROUPS=Cm;exports.CEDROS_PAY_SECTIONS=Qc;exports.CEDROS_PAY_SECTION_IDS=Sm;exports.CedrosPayAdminDashboard=_m;exports.ComplianceGatePage=Nm;exports.CouponsSection=qc;exports.CreditsBalance=Am;exports.ErrorBanner=Sr;exports.FormDropdown=Ct;exports.Icons=J;exports.ProductsSection=Vc;exports.RefundsSection=Hc;exports.SettingsSection=Zc;exports.StatsBar=Cr;exports.TransactionsSection=Wc;exports.cedrosPayPlugin=jm;exports.formatDateTime=dr;exports.index=BS;exports.safeHref=Ze;exports.useComplianceCheck=Kc;exports.useCreditsBalance=Jc;
|