@cedros/pay-react 1.1.24 → 1.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
- package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-DELur7D2.js} +1 -1
- package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
- package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
- package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
- package/dist/ComplianceSection-CemgfDrL.mjs +650 -0
- package/dist/ComplianceSection-DP2a9-S0.js +1 -0
- package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/CustomersSection-CBwy_waO.js +1 -0
- package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
- package/dist/DisputesSection-BLjIk60n.js +1 -0
- package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
- package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
- package/dist/{FAQSection-BmgmzDN5.js → FAQSection-wNeH0i6Q.js} +1 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
- package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
- package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
- package/dist/InventorySection-zV6lTmue.js +1 -0
- package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
- package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-B_wdFR0j.js} +1 -1
- package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-Bj8bPdg8.mjs} +6 -6
- package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-Dw2FX-1d.js} +1 -1
- package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
- package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
- package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
- package/dist/ReturnsSection-D_pJVxuG.js +1 -0
- package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-KYdEizq_.mjs} +19 -13
- package/dist/SettingsSection-vdYFSNxB.js +1 -0
- package/dist/ShippingSection-1DRSTu49.js +1 -0
- package/dist/ShippingSection-BOgto6_9.mjs +434 -0
- package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
- package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-suJ8z9d8.mjs} +4 -4
- package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
- package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-RumGkb3C.js} +1 -1
- package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
- package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-D60qrX9a.mjs} +7 -7
- package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
- package/dist/TaxSection-Dt1DnM51.js +1 -0
- package/dist/Token22Section-CrHLQ0EB.mjs +2260 -0
- package/dist/Token22Section-DY3mUwTY.js +1 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
- package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/index-C0g-JxJk.js +84 -0
- package/dist/{index-BHF82XBB.mjs → index-DXnuQp5x.mjs} +8643 -7678
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-C1rb9YRh.mjs → sections-C1NpK7hk.mjs} +2 -2
- package/dist/{sections-8e5Y3ukY.js → sections-DVVSZBhW.js} +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +40 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
- package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
- package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
- package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/CustomersSection.d.ts +3 -0
- package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
- package/dist/src/components/admin/DisputesSection.d.ts +3 -0
- package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/ImagesSection.d.ts +3 -0
- package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
- package/dist/src/components/admin/InventorySection.d.ts +3 -0
- package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
- package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
- package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/ShippingSection.d.ts +3 -0
- package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
- package/dist/src/components/admin/TaxSection.d.ts +3 -0
- package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
- package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
- package/dist/src/components/admin/complianceTypes.d.ts +74 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
- package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
- package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +12 -2
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +1 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-cKF0tLnS.js +0 -1
- package/dist/Token22Section-DUUl59dZ.js +0 -1
- package/dist/Token22Section-HygkDNtL.mjs +0 -1685
- package/dist/index-OaWkrl0G.js +0 -84
- package/dist/styles-21F1-oqx.js +0 -1
package/dist/index-OaWkrl0G.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),_=require("react"),Zf=require("@solana/wallet-adapter-react"),Ve=require("./CedrosContext-7dwmEeUY.js"),qf=require("@cedros/login-react"),di=require("./index-WcOlBYZJ.js"),Yo=require("react-dom"),Gf=require("./styles-21F1-oqx.js");function Dc(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=Dc(_),vs=Dc(Yo);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"})]}),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 Yf({serverUrl:e,productId:t,apiKey:n,authManager:s}){const[o,a]=_.useState(null),[i,c]=_.useState(!1),[l,d]=_.useState(!1),[f,u]=_.useState(null),g=_.useCallback(async()=>{if(t){c(!0),u(null);try{let x;if(s?.isAuthenticated())x=await s.fetchWithAuth(`/admin/products/${t}/variations`);else{const h={"Content-Type":"application/json"};n&&(h["X-API-Key"]=n);const v=await fetch(`${e}/admin/products/${t}/variations`,{headers:h});if(!v.ok)throw new Error(`Failed to fetch variations: ${v.status}`);x=await v.json()}x.variationConfig||(x.variationConfig={variationTypes:[]}),x.variants||(x.variants=[]),a(x)}catch(x){const h=x instanceof Error?x.message:"Failed to fetch variations";u(h),a({productId:t,variationConfig:{variationTypes:[]},variants:[]})}finally{c(!1)}}},[e,t,n,s]),p=_.useCallback(async x=>{if(!t)return null;d(!0),u(null);try{let h;if(s?.isAuthenticated())h=await s.fetchWithAuth(`/admin/products/${t}/variations`,{method:"PUT",body:JSON.stringify(x)});else{const v={"Content-Type":"application/json"};n&&(v["X-API-Key"]=n);const k=await fetch(`${e}/admin/products/${t}/variations`,{method:"PUT",headers:v,body:JSON.stringify(x)});if(!k.ok)throw new Error(`Failed to save variations: ${k.status}`);h=await k.json()}return a({productId:t,variationConfig:h.variationConfig,variants:h.variants}),{variantsCreated:h.variantsCreated}}catch(h){const v=h instanceof Error?h.message:"Failed to save variations";return u(v),null}finally{d(!1)}},[e,t,n,s]),b=_.useCallback(async x=>{if(!t||x.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:x})});else{const h={"Content-Type":"application/json"};n&&(h["X-API-Key"]=n);const v=await fetch(`${e}/admin/products/${t}/variants/inventory`,{method:"PUT",headers:h,body:JSON.stringify({updates:x})});if(!v.ok)throw new Error(`Failed to update inventory: ${v.status}`)}if(o){const h=new Map(x.map(v=>[v.variantId,v]));a({...o,variants:o.variants.map(v=>{const k=h.get(v.id);return k?{...v,inventoryQuantity:k.inventoryQuantity,inventoryStatus:k.inventoryStatus??v.inventoryStatus}:v})})}return!0}catch(h){const v=h instanceof Error?h.message:"Failed to update inventory";return u(v),!1}finally{d(!1)}},[e,t,n,s,o]);return{data:o,isLoading:i,error:f,fetch:g,save:p,bulkUpdateInventory:b,isSaving:l}}function ui(){return`var_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Qf({value:e,onChange:t,maxTypes:n=5,maxValuesPerType:s=20,disabled:o=!1}){const[a,i]=_.useState(null),[c,l]=_.useState(""),[d,f]=_.useState({}),u=e.variationTypes,g=_.useCallback(()=>{if(!c.trim()||u.length>=n)return;const w={id:ui(),name:c.trim(),displayOrder:u.length,values:[]};t({variationTypes:[...u,w]}),l(""),i(w.id)},[c,u,n,t]),p=_.useCallback(w=>{t({variationTypes:u.filter(y=>y.id!==w).map((y,j)=>({...y,displayOrder:j}))}),a===w&&i(null)},[u,t,a]),b=_.useCallback((w,y)=>{t({variationTypes:u.map(j=>j.id===w?{...j,name:y}:j)})},[u,t]),x=_.useCallback((w,y)=>{const j=u.findIndex(C=>C.id===w);if(j===-1||y==="up"&&j===0||y==="down"&&j===u.length-1)return;const R=[...u],E=y==="up"?j-1:j+1;[R[j],R[E]]=[R[E],R[j]],t({variationTypes:R.map((C,A)=>({...C,displayOrder:A}))})},[u,t]),h=_.useCallback(w=>{const y=(d[w]||"").trim();if(!y)return;const j=u.find(E=>E.id===w);if(!j||j.values.length>=s)return;const R={id:ui(),label:y};t({variationTypes:u.map(E=>E.id===w?{...E,values:[...E.values,R]}:E)}),f(E=>({...E,[w]:""}))},[u,d,s,t]),v=_.useCallback((w,y)=>{t({variationTypes:u.map(j=>j.id===w?{...j,values:j.values.filter(R=>R.id!==y)}:j)})},[u,t]),k=_.useCallback((w,y,j)=>{t({variationTypes:u.map(R=>R.id===w?{...R,values:R.values.map(E=>E.id===y?{...E,label:j}:E)}:R)})},[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((w,y)=>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:()=>x(w.id,"up"),disabled:o||y===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:()=>x(w.id,"down"),disabled:o||y===u.length-1,title:"Move down",children:J.arrowDown})]}),r.jsx("input",{type:"text",className:"cedros-admin__input cedros-admin__variation-type-name",value:w.name,onChange:j=>b(w.id,j.target.value),disabled:o,placeholder:"Type name"}),r.jsxs("span",{className:"cedros-admin__variation-value-count",children:[w.values.length," values"]}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>i(a===w.id?null:w.id),children:a===w.id?"Collapse":"Edit values"}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--danger",onClick:()=>p(w.id),disabled:o,title:"Remove type",children:J.delete})]}),a===w.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 "',w.name,'"']}),r.jsxs("span",{style:{fontSize:11,opacity:.7},children:[w.values.length,"/",s]})]}),w.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:w.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:R=>k(w.id,j.id,R.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:()=>v(w.id,j.id),disabled:o,title:"Remove value",children:J.close})]},j.id))}),w.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[w.id]||"",onChange:j=>f(R=>({...R,[w.id]:j.target.value})),placeholder:"Add value...",disabled:o,onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),h(w.id))}}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--secondary cedros-admin__button--sm",onClick:()=>h(w.id),disabled:o||!d[w.id]?.trim(),children:"Add"})]})]})]},w.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:w=>l(w.target.value),placeholder:"New variation type (e.g., Size, Color)",disabled:o,onKeyDown:w=>{w.key==="Enter"&&(w.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 $c({value:e,onChange:t,options:n,placeholder:s="Filter",disabled:o}){const[a,i]=_.useState(!1),c=_.useRef(null),d=n.find(f=>f.value===e)?.label||s;return _.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]),_.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 It({value:e,onChange:t,options:n,label:s,description:o,disabled:a,className:i,style:c}){const[l,d]=_.useState(!1),f=_.useRef(null),g=n.find(p=>p.value===e)?.label||"Select...";return _.useEffect(()=>{const p=b=>{f.current&&!f.current.contains(b.target)&&d(!1)};if(l)return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),_.useEffect(()=>{const p=b=>{b.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 fi(){return`variant_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Kf(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 Jf(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 Xf({variationConfig:e,variants:t,onChange:n,defaultPrice:s=0,currencySymbol:o="$",maxVariants:a=100,disabled:i=!1}){const c=_.useMemo(()=>Kf(e.variationTypes),[e.variationTypes]),l=_.useMemo(()=>{const x=new Map;for(const h of t)x.set(Jf(h),h);return x},[t]),{existingRows:d,possibleRows:f}=_.useMemo(()=>{const x=[],h=[];for(const v of c){const k=l.get(v.key);k?x.push({combo:v,variant:k}):h.push(v)}return{existingRows:x,possibleRows:h}},[c,l]),u=_.useCallback((x,h)=>{n(t.map(v=>v.id===x?{...v,...h}:v))},[t,n]),g=_.useCallback(x=>{n(t.filter(h=>h.id!==x))},[t,n]),p=_.useCallback(x=>{if(t.length>=a)return;const h={id:fi(),title:x.title,options:x.options,optionValueIds:x.optionValueIds,price:s,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!1};n([...t,h])},[t,n,a,s]),b=_.useCallback(()=>{const x=a-t.length,v=f.slice(0,x).map(k=>({id:fi(),title:k.title,options:k.options,optionValueIds:k.optionValueIds,price:s,inventoryQuantity:0,inventoryStatus:"in_stock",autoGenerated:!0}));n([...t,...v])},[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:b,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:x,variant:h})=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[r.jsx("span",{style:{fontWeight:600},children:x.title}),r.jsx("span",{style:{fontSize:11,opacity:.6},children:Object.entries(x.options).map(([v,k])=>`${v}: ${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:h.price??"",onChange:v=>u(h.id,{price:v.target.value===""?void 0:parseFloat(v.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:h.inventoryQuantity??"",onChange:v=>u(h.id,{inventoryQuantity:v.target.value===""?void 0:parseInt(v.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:h.sku??"",onChange:v=>u(h.id,{sku:v.target.value||void 0}),disabled:i,placeholder:"SKU",style:{width:80}})}),r.jsx("td",{children:r.jsx($c,{value:h.inventoryStatus??"in_stock",onChange:v=>u(h.id,{inventoryStatus:v}),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(h.id),disabled:i,title:"Remove variant",children:J.trash})})]},h.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(x=>r.jsxs("tr",{className:"cedros-admin__variant-possible",children:[r.jsx("td",{children:r.jsx("span",{style:{opacity:.6},children:x.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(x),disabled:i,title:"Create variant",children:J.plus})})]},x.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 em({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}=Yf({serverUrl:e,productId:t,apiKey:a,authManager:i}),[b,x]=_.useState({variationTypes:[]}),[h,v]=_.useState([]),[k,w]=_.useState(!1),[y,j]=_.useState(!1);_.useEffect(()=>{u()},[u]),_.useEffect(()=>{l&&(x(l.variationConfig),v(l.variants),w(!1))},[l]);const R=_.useCallback(A=>{x(A),w(!0),j(!1)},[]),E=_.useCallback(A=>{v(A),w(!0),j(!1)},[]),C=_.useCallback(async()=>{const A=new Set((l?.variants??[]).map($=>$.id)),O=h.filter($=>!A.has($.id)),U=h.filter($=>A.has($.id)),M=(l?.variants??[]).filter($=>!h.some(q=>q.id===$.id)).map($=>$.id);await g({variationConfig:b,createVariants:O.map($=>({optionValueIds:$.optionValueIds??[],inventoryQuantity:$.inventoryQuantity,sku:$.sku,price:$.price})),updateVariants:U.map($=>({id:$.id,inventoryQuantity:$.inventoryQuantity,sku:$.sku,price:$.price,inventoryStatus:$.inventoryStatus})),deleteVariantIds:M.length>0?M:void 0})&&(w(!1),j(!0),setTimeout(()=>j(!1),3e3))},[b,h,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:[y&&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:C,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(Qf,{value:b,onChange:R,disabled:p})}),b.variationTypes.length>0&&r.jsx("div",{className:"cedros-admin__variations-editor-section",children:r.jsx(Xf,{variationConfig:b,variants:h,onChange:E,defaultPrice:s,currencySymbol:o,disabled:p})})]})]})}function zc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=_.useState([]),[i,c]=_.useState(!0),[l,d]=_.useState(!1),[f,u]=_.useState(!1),[g,p]=_.useState(null),[b,x]=_.useState(null),[h,v]=_.useState(null),[k,w]=_.useState(null),[y,j]=_.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}),R=N=>{const I=N.tagsCsv.split(",").map(P=>P.trim()).filter(Boolean),G=N.categoryIdsCsv.split(",").map(P=>P.trim()).filter(Boolean),xe={email:N.checkoutEmail,name:N.checkoutName,phone:N.checkoutPhone,shippingAddress:N.checkoutShippingAddress,billingAddress:N.checkoutBillingAddress},W=N.fulfillmentType==="shipping"?"physical":"digital",Q={title:N.title,slug:N.slug||N.id,shipping_profile:W,inventory_status:N.inventoryStatus,checkout_requirements:JSON.stringify(xe),fulfillment_type:N.fulfillmentType};N.imageUrl&&(Q.image_url=N.imageUrl);const K=N.compareAtUsd?Math.round(Number(N.compareAtUsd)*100):0;K&&(Q.compare_at_amount_cents=String(K)),I.length&&(Q.tags=JSON.stringify(I)),G.length&&(Q.category_ids=JSON.stringify(G)),N.fulfillmentNotes&&(Q.fulfillment_notes=N.fulfillmentNotes);const le=N.shippingCountriesCsv.split(",").map(P=>P.trim().toUpperCase()).filter(Boolean);return le.length&&(Q.shippingCountries=le.join(","),Q.shipping_countries=le.join(",")),Q},[E,C]=_.useState([]),A=N=>N.metadata?.title||N.description||N.id,O=N=>N.metadata?.image_url,U=_.useCallback(async()=>{try{w(null);let N;if(s?.isAuthenticated())N=await s.fetchWithAuth(`/admin/products?limit=${n}`);else{const I={"Content-Type":"application/json"};t&&(I["X-API-Key"]=t);const G=await fetch(`${e}/admin/products?limit=${n}`,{headers:I});if(!G.ok)throw new Error(`Failed to fetch products: ${G.status}`);N=await G.json()}a(N.products||[])}catch{a([]),w("Failed to load products")}finally{c(!1)}},[e,t,n,s]);_.useEffect(()=>{U(),(async()=>{try{let N;if(s?.isAuthenticated())N=await s.fetchWithAuth("/admin/collections");else{const I={"Content-Type":"application/json"};t&&(I["X-API-Key"]=t);const G=await fetch(`${e}/admin/collections`,{headers:I});if(!G.ok)return;N=await G.json()}C((N.collections||[]).filter(I=>I.tokenizationConfig).map(I=>({id:I.id,name:I.name})))}catch{}})()},[U,e,t,s]);const M=async N=>{if(N.preventDefault(),!(!y.id||!y.description)){if(p(null),y.fulfillmentType==="shipping"&&y.checkoutShippingAddress&&!y.shippingCountriesCsv.split(",").map(G=>G.trim()).filter(Boolean).length){p("Shipping countries are required when collecting shipping address. Example: US,CA");return}u(!0);try{const{productType:I}=y,G=y.inventoryQuantity===""?void 0:Number.isFinite(Number(y.inventoryQuantity))?Number(y.inventoryQuantity):void 0,xe=Number(y.priceUsd)||0,W=Math.round(xe*100),Q=Math.round(xe*1e6),K={id:y.id,description:y.description,fiatAmountCents:W,fiatCurrency:y.fiatCurrency,cryptoAtomicAmount:Q,cryptoToken:y.cryptoToken,...G!==void 0?{inventoryQuantity:G}:{},metadata:{...I?{product_type:I}:{},...R(y)}};if(I==="gift_card"&&y.giftCardConfig&&(K.giftCardConfig=y.giftCardConfig),I==="tokenized_asset"&&y.tokenizedAssetConfig&&(K.tokenizedAssetConfig=y.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 P=await fetch(`${e}/admin/products`,{method:"POST",headers:le,body:JSON.stringify(K)});if(!P.ok)throw new Error(`Failed to create product: ${P.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),U()}catch(I){p(I instanceof Error?I.message:"Failed to create product")}finally{u(!1)}}},B=N=>`$${(N/100).toFixed(2)}`,$=N=>{switch(N){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"}},q=_.useMemo(()=>{const N=o.filter(G=>G.active).length,I=o.reduce((G,xe)=>{const W=xe.variations?.length??0;return G+(W>0?W:1)},0);return{activeCount:N,totalSkus:I}},[o]),F=N=>{v(I=>!I||I.key!==N?{key:N,direction:"asc"}:{key:N,direction:I.direction==="asc"?"desc":"asc"})},Z=N=>!h||h.key!==N?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:h.direction==="asc"?J.chevronUp:J.chevronDown}),D=_.useMemo(()=>{if(!h)return o;const N=h.direction==="asc"?1:-1,I=G=>{switch(h.key){case"product":return A(G);case"type":return $(G.metadata?.product_type);case"price":return G.fiatAmountCents??0;case"status":return G.active?1:0;case"id":default:return G.id}};return[...o].sort((G,xe)=>{const W=I(G),Q=I(xe);return typeof W=="number"&&typeof Q=="number"?(W-Q)*N:String(W).localeCompare(String(Q),void 0,{sensitivity:"base"})*N})},[o,h]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:k,onRetry:U}),r.jsx(Cr,{stats:[{label:"Total Products",value:o.length},{label:"Active",value:q.activeCount,variant:q.activeCount>0?"success":"muted"},{label:"Total SKUs",value:q.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:M,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:y.id,onChange:N=>j(I=>({...I,id:N.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:y.title,onChange:N=>j(I=>({...I,title:N.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:y.slug,onChange:N=>j(I=>({...I,slug:N.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:y.imageUrl,onChange:N=>j(I=>({...I,imageUrl:N.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:y.description,onChange:N=>j(I=>({...I,description:N.target.value})),placeholder:"e.g., Midweight fleece with relaxed fit",required:!0})]})}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(It,{value:y.productType,onChange:N=>j(I=>({...I,productType:N,giftCardConfig:N==="gift_card"?I.giftCardConfig??{faceValueCents:0,currency:"usd",secondaryMarket:!1,expiresInDays:null}:null,tokenizedAssetConfig:N==="tokenized_asset"?I.tokenizedAssetConfig??{assetClassCollectionId:"",backingValueCents:0,backingCurrency:"usd",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(It,{value:y.fulfillmentType,onChange:N=>{const I=N;j(G=>({...G,fulfillmentType:I,checkoutShippingAddress:I==="shipping"?G.checkoutShippingAddress:!1}))},options:[{value:"shipping",label:"Physical (shipped)"},{value:"digital_download",label:"Digital download"},{value:"service",label:"Service"}],label:"Fulfillment"})]}),y.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:y.giftCardConfig?.faceValueCents??"",onChange:N=>j(I=>({...I,giftCardConfig:{faceValueCents:parseInt(N.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:y.giftCardConfig?.currency??"",onChange:N=>j(I=>({...I,giftCardConfig:{faceValueCents:I.giftCardConfig?.faceValueCents??0,currency:N.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:y.giftCardConfig?.expiresInDays??"",onChange:N=>j(I=>({...I,giftCardConfig:{faceValueCents:I.giftCardConfig?.faceValueCents??0,currency:I.giftCardConfig?.currency??"usd",secondaryMarket:I.giftCardConfig?.secondaryMarket??!1,expiresInDays:N.target.value===""?null:parseInt(N.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:y.giftCardConfig?.secondaryMarket??!1,onChange:N=>j(I=>({...I,giftCardConfig:{faceValueCents:I.giftCardConfig?.faceValueCents??0,currency:I.giftCardConfig?.currency??"usd",secondaryMarket:N.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."})]})]})]}),y.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"}),E.length>0?r.jsxs("select",{className:"cedros-admin__input",value:y.tokenizedAssetConfig?.assetClassCollectionId??"",onChange:N=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,assetClassCollectionId:N.target.value}})),required:!0,children:[r.jsx("option",{value:"",children:"Select asset class..."}),E.map(N=>r.jsx("option",{value:N.id,children:N.name},N.id))]}):r.jsx("input",{type:"text",className:"cedros-admin__input",value:y.tokenizedAssetConfig?.assetClassCollectionId??"",onChange:N=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,assetClassCollectionId:N.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:y.tokenizedAssetConfig?.backingValueCents??0,onChange:N=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,backingValueCents:Number(N.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:"Tokens per unit"}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:y.tokenizedAssetConfig?.tokensPerUnit??1,onChange:N=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,tokensPerUnit:Number(N.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:y.tokenizedAssetConfig?.custodyProofUrl??"",onChange:N=>j(I=>({...I,tokenizedAssetConfig:{...I.tokenizedAssetConfig,custodyProofUrl:N.target.value||null}})),placeholder:"https://..."})]})]})]}),y.fulfillmentType==="shipping"&&r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(It,{value:y.inventoryStatus,onChange:N=>j(I=>({...I,inventoryStatus:N})),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:y.inventoryQuantity,onChange:N=>j(I=>({...I,inventoryQuantity:N.target.value===""?"":parseInt(N.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:y.compareAtUsd===""?"":y.compareAtUsd,onChange:N=>j(I=>({...I,compareAtUsd:N.target.value===""?"":parseFloat(N.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:y.priceUsd===""?"":y.priceUsd,onChange:N=>j(I=>({...I,priceUsd:N.target.value===""?"":parseFloat(N.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:y.tagsCsv,onChange:N=>j(I=>({...I,tagsCsv:N.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:y.categoryIdsCsv,onChange:N=>j(I=>({...I,categoryIdsCsv:N.target.value})),placeholder:"e.g., cat_apparel, cat_accessories"})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(It,{value:y.checkoutEmail,onChange:N=>j(I=>({...I,checkoutEmail:N})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Email"}),r.jsx(It,{value:y.checkoutName,onChange:N=>j(I=>({...I,checkoutName:N})),options:[{value:"none",label:"None"},{value:"optional",label:"Optional"},{value:"required",label:"Required"}],label:"Checkout: Name"}),r.jsx(It,{value:y.checkoutPhone,onChange:N=>j(I=>({...I,checkoutPhone:N})),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:[y.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:y.checkoutShippingAddress,onChange:N=>j(I=>({...I,checkoutShippingAddress:N.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:y.checkoutBillingAddress,onChange:N=>j(I=>({...I,checkoutBillingAddress:N.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:y.fulfillmentNotes,onChange:N=>j(I=>({...I,fulfillmentNotes:N.target.value})),placeholder:y.fulfillmentType==="shipping"?"e.g., Ships within 3-5 business days":"e.g., Downloadable from your account after purchase"})]})}),y.fulfillmentType==="shipping"&&y.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:y.shippingCountriesCsv,onChange:N=>j(I=>({...I,shippingCountriesCsv:N.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":h?.key==="id"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>F("id"),children:["ID",Z("id")]})}),r.jsx("th",{"aria-sort":h?.key==="product"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>F("product"),children:["Product",Z("product")]})}),r.jsx("th",{"aria-sort":h?.key==="type"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>F("type"),children:["Type",Z("type")]})}),r.jsx("th",{"aria-sort":h?.key==="price"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>F("price"),children:["Price",Z("price")]})}),r.jsx("th",{"aria-sort":h?.key==="status"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>F("status"),children:["Status",Z("status")]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:D.map(N=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:N.id})}),r.jsx("td",{children:r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[O(N)?r.jsx("img",{src:O(N),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:A(N)}),r.jsx("span",{style:{opacity:.8},children:N.description})]})]})}),r.jsx("td",{children:$(N.metadata?.product_type)}),r.jsx("td",{children:B(N.fiatAmountCents)}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge ${N.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:N.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:()=>x(N),children:"Variations"})})})]},N.id))})]})}),b&&r.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>x(null),children:r.jsx("div",{className:"cedros-admin__modal cedros-admin__modal--lg",onClick:N=>N.stopPropagation(),children:r.jsx(em,{serverUrl:e,productId:b.id,productTitle:A(b),defaultPrice:b.fiatAmountCents/100,apiKey:t,authManager:s,onClose:()=>x(null)})})})]})}function Fc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=_.useState([]),[i,c]=_.useState(null),[l,d]=_.useState(!0),[f,u]=_.useState(!0),[g,p]=_.useState(null),[b,x]=_.useState(""),[h,v]=_.useState(null),k=_.useCallback(async()=>{u(!0);try{p(null);let C;if(s?.isAuthenticated())C=await s.fetchWithAuth("/admin/stats");else{const A={"Content-Type":"application/json"};t&&(A["X-API-Key"]=t);const O=await fetch(`${e}/admin/stats`,{headers:A});if(!O.ok)throw new Error(`Failed to fetch stats: ${O.status}`);C=await O.json()}c(C)}catch{c(null),p("Failed to load payment stats")}finally{u(!1)}},[e,t,s]);_.useEffect(()=>{k()},[k]);const w=_.useCallback(async()=>{try{p(null);let C;const A=new URLSearchParams({limit:n.toString()});b&&A.set("method",b);const O=`/admin/transactions?${A}`;if(s?.isAuthenticated())C=await s.fetchWithAuth(O);else{const U={"Content-Type":"application/json"};t&&(U["X-API-Key"]=t);const M=await fetch(`${e}${O}`,{headers:U});if(!M.ok)throw new Error(`Failed to fetch transactions: ${M.status}`);C=await M.json()}a(C.transactions||[])}catch{a([]),p("Failed to load transactions")}finally{d(!1)}},[e,t,n,b,s]);_.useEffect(()=>{w()},[w]);const y=(C,A="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:A}).format(C),j=C=>{v(A=>!A||A.key!==C?{key:C,direction:"asc"}:{key:C,direction:A.direction==="asc"?"desc":"asc"})},R=C=>!h||h.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:h.direction==="asc"?J.chevronUp:J.chevronDown}),E=_.useMemo(()=>{if(!h)return o;const C=h.direction==="asc"?1:-1,A=O=>{switch(h.key){case"resource":return O.resourceId;case"method":return O.method;case"amount":return O.amount;case"status":return O.status;case"date":return new Date(O.paidAt).getTime();case"id":default:return O.id}};return[...o].sort((O,U)=>{const M=A(O),B=A(U);return typeof M=="number"&&typeof B=="number"?(M-B)*C:String(M).localeCompare(String(B),void 0,{sensitivity:"base"})*C})},[o,h]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:g,onRetry:()=>{k(),w()}}),r.jsx(Cr,{stats:[{label:"Revenue",value:y(i?.totalRevenue??0)},{label:"Orders",value:i?.totalTransactions??0},{label:"Card",value:y(i?.revenueByMethod.stripe??0),description:`${i?.transactionsByMethod.stripe??0} orders`},{label:"Crypto",value:y(i?.revenueByMethod.x402??0),description:`${i?.transactionsByMethod.x402??0} orders`},{label:"Credits",value:y(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($c,{value:b,onChange:x,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":h?.key==="id"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("id"),children:["ID",R("id")]})}),r.jsx("th",{"aria-sort":h?.key==="resource"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("resource"),children:["Resource",R("resource")]})}),r.jsx("th",{"aria-sort":h?.key==="method"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("method"),children:["Method",R("method")]})}),r.jsx("th",{"aria-sort":h?.key==="amount"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("amount"),children:["Amount",R("amount")]})}),r.jsx("th",{"aria-sort":h?.key==="status"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("status"),children:["Status",R("status")]})}),r.jsx("th",{"aria-sort":h?.key==="date"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>j("date"),children:["Date",R("date")]})})]})}),r.jsx("tbody",{children:E.map(C=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:C.id})}),r.jsx("td",{children:C.resourceId}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${C.method}`,children:C.method})}),r.jsxs("td",{children:["$",C.amount.toFixed(2)," ",C.currency.toUpperCase()]}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${C.status}`,children:C.status})}),r.jsx("td",{children:dr(C.paidAt)})]},C.id))})]})})]})}function Uc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=_.useState([]),[i,c]=_.useState(!0),[l,d]=_.useState(!1),[f,u]=_.useState(!1),[g,p]=_.useState(null),[b,x]=_.useState(null),[h,v]=_.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=_.useCallback(async()=>{try{x(null);let A;const O=`/admin/coupons?limit=${n}`;if(s?.isAuthenticated())A=await s.fetchWithAuth(O);else{const U={"Content-Type":"application/json"};t&&(U["X-API-Key"]=t);const M=await fetch(`${e}${O}`,{headers:U});if(!M.ok)throw new Error(`Failed to fetch coupons: ${M.status}`);A=await M.json()}a(A.coupons||[])}catch(A){Ve.getLogger().error("[CouponsSection] Failed to fetch coupons:",A,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),x("Failed to load coupons")}finally{c(!1)}},[e,t,n,s]);_.useEffect(()=>{k()},[k]);const w=async A=>{if(A.preventDefault(),!(!h.code||h.discountValue<=0)){u(!0);try{const O=h.minimumAmountUsd?Math.round(Number(h.minimumAmountUsd)*100):void 0,U=h.productIdsCsv.split(",").map($=>$.trim()).filter(Boolean),M=h.categoryIdsCsv.split(",").map($=>$.trim()).filter(Boolean),B={code:h.code,discountType:h.discountType,discountValue:h.discountValue,usageLimit:h.usageLimit,active:!0,usageCount:0,scope:h.scope,...U.length?{productIds:U}:{},...M.length?{categoryIds:M}:{},...h.paymentMethod!=="any"?{paymentMethod:h.paymentMethod}:{},...h.autoApply?{autoApply:!0}:{},...h.appliesAt!=="both"?{appliesAt:h.appliesAt}:{},...h.startsAt?{startsAt:h.startsAt}:{},...h.expiresAt?{expiresAt:h.expiresAt}:{},...O?{minimumAmountCents:O}:{},...h.usageLimitPerCustomer?{usageLimitPerCustomer:h.usageLimitPerCustomer}:{},...h.firstPurchaseOnly?{firstPurchaseOnly:!0}:{}};if(s?.isAuthenticated())await s.fetchWithAuth("/admin/coupons",{method:"POST",body:JSON.stringify(B)});else{const $={"Content-Type":"application/json"};t&&($["X-API-Key"]=t);const q=await fetch(`${e}/admin/coupons`,{method:"POST",headers:$,body:JSON.stringify(B)});if(!q.ok)throw new Error(`Failed to create coupon: ${q.status}`)}v({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(O){Ve.getLogger().error("[CouponsSection] Failed to add coupon:",O,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),x("Failed to create coupon")}finally{u(!1)}}},y=o.filter(A=>A.active).length,j=o.reduce((A,O)=>A+(O.usageCount??0),0),R=A=>{p(O=>!O||O.key!==A?{key:A,direction:"asc"}:{key:A,direction:O.direction==="asc"?"desc":"asc"})},E=A=>!g||g.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:g.direction==="asc"?J.chevronUp:J.chevronDown}),C=_.useMemo(()=>{if(!g)return o;const A=g.direction==="asc"?1:-1,O=U=>{switch(g.key){case"discount":return U.discountValue??0;case"usage":return U.usageCount??0;case"status":return U.active?1:0;case"code":default:return U.code}};return[...o].sort((U,M)=>{const B=O(U),$=O(M);return typeof B=="number"&&typeof $=="number"?(B-$)*A:String(B).localeCompare(String($),void 0,{sensitivity:"base"})*A})},[o,g]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:b,onRetry:k}),r.jsx(Cr,{stats:[{label:"Total Coupons",value:o.length},{label:"Active",value:y,variant:y>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:w,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:h.code,onChange:A=>v(O=>({...O,code:A.target.value.toUpperCase()})),placeholder:"e.g., SAVE20",required:!0})]}),r.jsx(It,{value:h.discountType,onChange:A=>v(O=>({...O,discountType:A})),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 ",h.discountType==="percentage"?"(%)":"($)"]}),r.jsx("input",{type:"number",className:"cedros-admin__input",value:h.discountValue||"",onChange:A=>v(O=>({...O,discountValue:parseFloat(A.target.value)||0})),placeholder:h.discountType==="percentage"?"e.g., 20":"e.g., 10.00",min:"0",step:h.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:h.usageLimit||"",onChange:A=>v(O=>({...O,usageLimit:A.target.value?parseInt(A.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:h.expiresAt,onChange:A=>v(O=>({...O,expiresAt:A.target.value}))})]})]}),r.jsxs("div",{className:"cedros-admin__form-row",children:[r.jsx(It,{value:h.scope,onChange:A=>v(O=>({...O,scope:A})),options:[{value:"all_products",label:"All Products"},{value:"specific_products",label:"Specific Products"},{value:"specific_categories",label:"Specific Categories"}],label:"Scope"}),r.jsx(It,{value:h.paymentMethod,onChange:A=>v(O=>({...O,paymentMethod:A})),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(It,{value:h.appliesAt,onChange:A=>v(O=>({...O,appliesAt:A})),options:[{value:"both",label:"Cart & Checkout"},{value:"cart",label:"Cart Only"},{value:"checkout",label:"Checkout Only"}],label:"Applies At"})]}),h.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:h.productIdsCsv,onChange:A=>v(O=>({...O,productIdsCsv:A.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:h.startsAt,onChange:A=>v(O=>({...O,startsAt:A.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:h.autoApply,onChange:A=>v(O=>({...O,autoApply:A.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:h.minimumAmountUsd===""?"":h.minimumAmountUsd,onChange:A=>v(O=>({...O,minimumAmountUsd:A.target.value===""?"":parseFloat(A.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:h.usageLimitPerCustomer||"",onChange:A=>v(O=>({...O,usageLimitPerCustomer:A.target.value?parseInt(A.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:h.firstPurchaseOnly,onChange:A=>v(O=>({...O,firstPurchaseOnly:A.target.checked}))}),"New customers only"]})]})]}),h.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:h.categoryIdsCsv,onChange:A=>v(O=>({...O,categoryIdsCsv:A.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:()=>R("code"),children:["Code",E("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:()=>R("discount"),children:["Discount",E("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:()=>R("usage"),children:["Usage",E("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:()=>R("status"),children:["Status",E("status")]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:C.map(A=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:A.code})}),r.jsx("td",{children:A.discountType==="percentage"?`${A.discountValue}%`:`$${A.discountValue.toFixed(2)}`}),r.jsxs("td",{children:[A.usageCount,A.usageLimit?` / ${A.usageLimit}`:""]}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge ${A.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:A.active?"Active":"Inactive"})}),r.jsx("td",{children:r.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",children:"Edit"})})]},A.code))})]})})]})}function Bc({serverUrl:e,apiKey:t,pageSize:n=20,authManager:s}){const[o,a]=_.useState([]),[i,c]=_.useState(!0),[l,d]=_.useState(null),[f,u]=_.useState([]),[g,p]=_.useState(!0),[b,x]=_.useState(null),[h,v]=_.useState(null),[k,w]=_.useState([]),[y,j]=_.useState(!0),[R,E]=_.useState(null),[C,A]=_.useState(null),[O,U]=_.useState(null),[M,B]=_.useState(""),[$,q]=_.useState(null),F=_.useCallback(async()=>{try{let T;const ee=`/admin/refunds?limit=${n}`;if(s?.isAuthenticated())T=await s.fetchWithAuth(ee);else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${ee}`,{headers:se});if(!ve.ok)throw new Error(`Failed to fetch x402 refunds: ${ve.status}`);T=await ve.json()}a(T.refunds||[])}catch(T){Ve.getLogger().error("[RefundsSection] Failed to fetch x402 refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),a([]),q("Failed to load x402 refunds")}finally{c(!1)}},[e,t,n,s]);_.useEffect(()=>{F()},[F]);const Z=_.useCallback(async()=>{try{let T;const ee=`/admin/credits/refund-requests?status=pending&limit=${n}&offset=0`;if(s?.isAuthenticated())T=await s.fetchWithAuth(ee);else{const ve={"Content-Type":"application/json"};t&&(ve["X-API-Key"]=t);const ye=await fetch(`${e}${ee}`,{headers:ve});if(!ye.ok)throw new Error(`Failed to fetch credits refund requests: ${ye.status}`);T=await ye.json()}const se=Array.isArray(T)?T:"refundRequests"in T?T.refundRequests:T.requests||[];u(se)}catch(T){Ve.getLogger().error("[RefundsSection] Failed to fetch credits refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),u([]),q("Failed to load credits refunds")}finally{p(!1)}},[e,t,n,s]);_.useEffect(()=>{Z()},[Z]);const D=async T=>{x(T.id);try{const ee=`/admin/credits/refund-requests/${T.id}/process`,se=JSON.stringify({amountLamports:T.amountLamports,reason:T.reason});if(s?.isAuthenticated())await s.fetchWithAuth(ee,{method:"POST",body:se});else{const ve={"Content-Type":"application/json"};t&&(ve["X-API-Key"]=t);const ye=await fetch(`${e}${ee}`,{method:"POST",headers:ve,body:se});if(!ye.ok)throw new Error(`Failed to process credits refund: ${ye.status}`)}await Z()}catch(ee){Ve.getLogger().error("[RefundsSection] Failed to process credits refund:",ee,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,requestId:T.id}),q("Failed to process credits refund")}finally{x(null)}},N=T=>{B(T.reason??""),U(T)},I=()=>{U(null),B("")},G=async()=>{if(!O)return;const T=O,ee=M;I(),x(T.id);try{const se=`/admin/credits/refund-requests/${T.id}/reject`,ve=JSON.stringify({reason:ee});if(s?.isAuthenticated())await s.fetchWithAuth(se,{method:"POST",body:ve});else{const ye={"Content-Type":"application/json"};t&&(ye["X-API-Key"]=t);const Pe=await fetch(`${e}${se}`,{method:"POST",headers:ye,body:ve});if(!Pe.ok)throw new Error(`Failed to reject credits refund: ${Pe.status}`)}await Z()}catch(se){Ve.getLogger().error("[RefundsSection] Failed to reject credits refund:",se,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,requestId:T.id}),q("Failed to reject credits refund")}finally{x(null)}},xe=_.useCallback(async()=>{try{let T;const ee=`/admin/stripe/refunds?limit=${n}`;if(s?.isAuthenticated())T=await s.fetchWithAuth(ee);else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${ee}`,{headers:se});if(!ve.ok)throw new Error(`Failed to fetch Stripe refunds: ${ve.status}`);T=await ve.json()}w(T.refunds||[])}catch(T){Ve.getLogger().error("[RefundsSection] Failed to fetch Stripe refunds:",T,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t}),w([]),q("Failed to load Stripe refunds")}finally{j(!1)}},[e,t,n,s]);_.useEffect(()=>{xe()},[xe]);const W=async T=>{E(T);try{const ee=`/admin/stripe/refunds/${T}/process`;if(s?.isAuthenticated())await s.fetchWithAuth(ee,{method:"POST"});else{const se={"Content-Type":"application/json"};t&&(se["X-API-Key"]=t);const ve=await fetch(`${e}${ee}`,{method:"POST",headers:se});if(!ve.ok)throw new Error(`Failed to process refund: ${ve.status}`)}await xe()}catch(ee){Ve.getLogger().error("[RefundsSection] Failed to process Stripe refund:",ee,{serverUrl:e.slice(0,20)+"...",hasApiKey:!!t,refundId:T}),q("Failed to process Stripe refund")}finally{E(null)}},Q=(T,ee)=>new Intl.NumberFormat("en-US",{style:"currency",currency:ee}).format(T/100),K=T=>T?T.replace(/_/g," ").replace(/\b\w/g,ee=>ee.toUpperCase()):"—",le=T=>{switch(T){case"processed":return"success";case"pending":return"pending";case"rejected":default:return"muted"}},P=(T,ee)=>ee?ee.toLowerCase()==="usd"?`${new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(T/1e6)} (USD credits)`:`${T.toLocaleString()} ${ee.toUpperCase()} (atomic)`:`${T.toLocaleString()} (atomic)`,Y=T=>{switch(T){case"succeeded":return"success";case"failed":return"failed";case"pending":case"requires_action":return"pending";case"canceled":default:return"muted"}},ue=T=>T.stripeRefundId??"—",V=T=>T.chargeId??"—",ae=k.filter(T=>T.status==="pending"||T.status==="requires_action").length,ce=f.filter(T=>T.status==="pending").length,we=o.filter(T=>T.status==="pending").length,Te=ae+ce+we,We=k.filter(T=>T.status==="succeeded").reduce((T,ee)=>T+ee.amount,0),Qe=f.filter(T=>T.status==="processed").reduce((T,ee)=>T+ee.amountLamports,0),He=o.filter(T=>T.status==="completed").reduce((T,ee)=>T+ee.amount,0),St=We/100+Qe/1e6+He,Ke=T=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(T),nn=y||g||i,bt=T=>{A(ee=>!ee||ee.key!==T?{key:T,direction:"asc"}:{key:T,direction:ee.direction==="asc"?"desc":"asc"})},je=T=>{v(ee=>!ee||ee.key!==T?{key:T,direction:"asc"}:{key:T,direction:ee.direction==="asc"?"desc":"asc"})},nt=T=>{d(ee=>!ee||ee.key!==T?{key:T,direction:"asc"}:{key:T,direction:ee.direction==="asc"?"desc":"asc"})},ke=(T,ee)=>!T||!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}),qt=_.useMemo(()=>{if(!C)return k;const T=C.direction==="asc"?1:-1,ee=se=>{switch(C.key){case"stripe":return se.stripeRefundId??"";case"charge":return se.chargeId??"";case"amount":return se.amount??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...k].sort((se,ve)=>{const ye=ee(se),Pe=ee(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[k,C]),pt=_.useMemo(()=>{if(!h)return f;const T=h.direction==="asc"?1:-1,ee=se=>{switch(h.key){case"original":return se.originalTransactionId??"";case"user":return se.userId??"";case"amount":return se.amountLamports??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...f].sort((se,ve)=>{const ye=ee(se),Pe=ee(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[f,h]),ct=_.useMemo(()=>{if(!l)return o;const T=l.direction==="asc"?1:-1,ee=se=>{switch(l.key){case"transaction":return se.transactionId??"";case"amount":return se.amount??0;case"reason":return se.reason??"";case"status":return se.status??"";case"date":return new Date(se.createdAt).getTime();case"id":default:return se.id}};return[...o].sort((se,ve)=>{const ye=ee(se),Pe=ee(ve);return typeof ye=="number"&&typeof Pe=="number"?(ye-Pe)*T:String(ye).localeCompare(String(Pe),void 0,{sensitivity:"base"})*T})},[o,l]);return r.jsxs("div",{className:"cedros-admin__page",children:[r.jsx(Sr,{message:$,onRetry:()=>{F(),Z(),xe()}}),r.jsx(Cr,{stats:[{label:"Pending",value:Te,variant:Te>0?"warning":"muted"},{label:"Card Pending",value:ae,description:"Stripe"},{label:"Credits Pending",value:ce},{label:"Crypto Pending",value:we,description:"x402"},{label:"Total Refunded",value:Ke(St),variant:"success"}],isLoading:nn}),r.jsx("div",{className:"cedros-admin__section-header",children:r.jsx("h3",{className:"cedros-admin__section-title",children:"Stripe Refund Requests"})}),y?r.jsxs("div",{className:"cedros-admin__loading",children:[J.loading," Loading Stripe refunds..."]}):k.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":C?.key==="id"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("id"),children:["Request ID",ke(C?.key==="id",C?.direction)]})}),r.jsx("th",{"aria-sort":C?.key==="stripe"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("stripe"),children:["Stripe Refund ID",ke(C?.key==="stripe",C?.direction)]})}),r.jsx("th",{"aria-sort":C?.key==="charge"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("charge"),children:["Charge",ke(C?.key==="charge",C?.direction)]})}),r.jsx("th",{"aria-sort":C?.key==="amount"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("amount"),children:["Amount",ke(C?.key==="amount",C?.direction)]})}),r.jsx("th",{"aria-sort":C?.key==="reason"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("reason"),children:["Reason",ke(C?.key==="reason",C?.direction)]})}),r.jsx("th",{"aria-sort":C?.key==="status"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("status"),children:["Status",ke(C?.key==="status",C?.direction)]})}),r.jsx("th",{"aria-sort":C?.key==="date"?C?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>bt("date"),children:["Date",ke(C?.key==="date",C?.direction)]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:qt.map(T=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:T.id})}),r.jsx("td",{children:r.jsx("code",{children:ue(T)})}),r.jsx("td",{children:r.jsx("code",{children:V(T)})}),r.jsx("td",{children:Q(T.amount,T.currency)}),r.jsx("td",{children:K(T.reason)}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${Y(T.status)}`,children:T.status})}),r.jsx("td",{children:dr(T.createdAt)}),r.jsx("td",{children:(T.status==="pending"||T.status==="requires_action")&&r.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>W(T.id),disabled:R===T.id,children:R===T.id?"Processing...":"Process"})})]},T.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"})}),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":h?.key==="id"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("id"),children:["Request ID",ke(h?.key==="id",h?.direction)]})}),r.jsx("th",{"aria-sort":h?.key==="original"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("original"),children:["Original Tx",ke(h?.key==="original",h?.direction)]})}),r.jsx("th",{"aria-sort":h?.key==="user"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("user"),children:["User",ke(h?.key==="user",h?.direction)]})}),r.jsx("th",{"aria-sort":h?.key==="amount"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("amount"),children:["Amount",ke(h?.key==="amount",h?.direction)]})}),r.jsx("th",{"aria-sort":h?.key==="reason"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("reason"),children:["Reason",ke(h?.key==="reason",h?.direction)]})}),r.jsx("th",{"aria-sort":h?.key==="status"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("status"),children:["Status",ke(h?.key==="status",h?.direction)]})}),r.jsx("th",{"aria-sort":h?.key==="date"?h?.direction==="asc"?"ascending":"descending":"none",children:r.jsxs("button",{type:"button",className:"cedros-admin__table-sort",onClick:()=>je("date"),children:["Date",ke(h?.key==="date",h?.direction)]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:pt.map(T=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:T.id})}),r.jsx("td",{children:r.jsx("code",{children:T.originalTransactionId})}),r.jsx("td",{children:r.jsx("code",{children:T.userId??"—"})}),r.jsx("td",{children:P(T.amountLamports,T.currency)}),r.jsx("td",{children:T.reason??"—"}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${le(T.status)}`,children:T.status})}),r.jsx("td",{children:dr(T.createdAt)}),r.jsx("td",{children:T.status==="pending"?r.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[r.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>D(T),disabled:b===T.id,children:b===T.id?"Processing...":"Process"}),r.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>N(T),disabled:b===T.id,children:"Reject"})]}):null})]},T.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"})}),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:()=>nt("id"),children:["ID",ke(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:()=>nt("transaction"),children:["Transaction",ke(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:()=>nt("amount"),children:["Amount",ke(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:()=>nt("reason"),children:["Reason",ke(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:()=>nt("status"),children:["Status",ke(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:()=>nt("date"),children:["Date",ke(l?.key==="date",l?.direction)]})}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:ct.map(T=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("code",{children:T.id})}),r.jsx("td",{children:r.jsx("code",{children:T.transactionId})}),r.jsxs("td",{children:["$",T.amount.toFixed(2)]}),r.jsx("td",{children:T.reason||"—"}),r.jsx("td",{children:r.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${T.status}`,children:T.status})}),r.jsx("td",{children:dr(T.createdAt)}),r.jsx("td",{})]},T.id))})]})}),O&&r.jsx("div",{className:"cedros-admin__modal-overlay",onClick:I,children:r.jsxs("div",{className:"cedros-admin__modal",onClick:T=>T.stopPropagation(),children:[r.jsxs("div",{className:"cedros-admin__modal-header",children:[r.jsx("h3",{className:"cedros-admin__modal-title",children:"Reject Refund Request"}),r.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:I,"aria-label":"Close",children:J.close})]}),r.jsxs("div",{className:"cedros-admin__modal-body",children:[r.jsxs("p",{style:{marginBottom:"1rem",color:"var(--admin-muted)"},children:["Rejecting refund request ",r.jsx("code",{children:O.id})," for ",P(O.amountLamports,O.currency),"."]}),r.jsxs("label",{className:"cedros-admin__form-field",children:[r.jsx("span",{className:"cedros-admin__form-label",children:"Reason (optional)"}),r.jsx("textarea",{className:"cedros-admin__input",value:M,onChange:T=>B(T.target.value),placeholder:"Enter rejection reason...",rows:3,style:{resize:"vertical"}})]})]}),r.jsxs("div",{className:"cedros-admin__modal-footer",children:[r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:I,children:"Cancel"}),r.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--danger",onClick:G,children:"Reject Refund"})]})]})})]})}const tm=_.lazy(()=>Promise.resolve().then(()=>require("./SettingsSection-cKF0tLnS.js")).then(e=>({default:e.SettingsSection})));function Vc(e){return r.jsx(_.Suspense,{fallback:null,children:r.jsx(tm,{...e})})}class Wc{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,Ve.getLogger().debug("[AdminAuthManager] Wallet signer updated:",!!t?.publicKey)}setCedrosLoginAuth(t,n){this.jwtToken=t,this.isAdminUser=n??!1,Ve.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_id),o=await this.walletSigner.signMessage(s),a=di.bs58.encode(this.walletSigner.publicKey.toBytes()),i=di.bs58.encode(o);return{"X-Signer":a,"X-Message":n.nonce_id,"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`;Ve.getLogger().debug("[AdminAuthManager] Fetching nonce for purpose:",t);const s=await Ve.fetchWithTimeout(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({purpose:t})});if(!s.ok){const o=await s.text();throw new Error(`Failed to fetch nonce: ${s.status} ${o}`)}return await s.json()}async fetchWithAuth(t,n={}){if(this.getAuthMethod()==="none")throw new Error("No admin authentication configured");const o=this.getPurposeFromPath(t,n.method||"GET"),a=await this.createAuthHeaders(o),i=(n.method||"GET").toUpperCase(),c={...i!=="GET"&&i!=="HEAD"?{"Content-Type":"application/json"}:{},...n.headers||{},...a},l=await Ve.fetchWithTimeout(`${this.serverUrl}${t}`,{...n,headers:c});if(!l.ok){let d=`Admin API error ${l.status}`;try{const f=await l.json();f&&typeof f.error=="string"?d=f.error:f&&typeof f.message=="string"&&(d=f.message)}catch{}throw new Error(d)}return await l.json()}getPurposeFromPath(t,n){const o={"/admin/stats":{GET:"admin_stats"},"/admin/products":{GET:"admin_products_list",POST:"admin_products_create"},"/admin/transactions":{GET:"admin_transactions_list"},"/admin/coupons":{GET:"admin_coupons_list",POST:"admin_coupons_create"},"/admin/refunds":{GET:"admin_refunds_list"},"/admin/config":{GET:"admin_config_list"}}[t];if(o?.[n])return o[n];if(t.startsWith("/admin/products/")){if(n==="PUT")return"admin_products_update";if(n==="DELETE")return"admin_products_delete"}if(t.startsWith("/admin/coupons/")){if(n==="PUT")return"admin_coupons_update";if(n==="DELETE")return"admin_coupons_delete"}if(t.startsWith("/admin/refunds/")&&t.includes("/process"))return"admin_refunds_process";if(t.startsWith("/admin/config/")){if(n==="GET")return"admin_config_get";if(n==="PUT")return"admin_config_update";if(n==="PATCH")return"admin_config_patch"}return`admin_${n.toLowerCase()}`}}const nm={publicKey:null};function rm({serverUrl:e,cedrosLoginToken:t,isAdmin:n=!1,wallet:s=nm}){const o=_.useMemo(()=>{const u=new Wc(e);return u.setCedrosLoginAuth(t??null,n),u},[e,t,n]);_.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,d=_.useMemo(()=>{if(!s.publicKey)return null;const u=s.publicKey.toBase58();return`${u.slice(0,4)}...${u.slice(-4)}`},[s.publicKey]),f=_.useCallback((u,g)=>o.fetchWithAuth(u,g),[o]);return{authMethod:a,isAuthenticated:i,walletConnected:c,walletAddress:d,cedrosLoginAvailable:l,authManager:o,fetchWithAuth:f}}const sm=_.lazy(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-Dn5SY6S_.js")).then(e=>({default:e.SubscriptionsSection}))),om=_.lazy(()=>Promise.resolve().then(()=>require("./StorefrontSection-C9DzCmOf.js")).then(e=>({default:e.StorefrontSection}))),am=_.lazy(()=>Promise.resolve().then(()=>require("./AISettingsSection-IXS1Wt_1.js")).then(e=>({default:e.AISettingsSection}))),im=_.lazy(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-BTEn9Dxb.js")).then(e=>({default:e.PaymentSettingsSection}))),cm=_.lazy(()=>Promise.resolve().then(()=>require("./MessagingSection-CWLZcg11.js")).then(e=>({default:e.MessagingSection}))),lm=_.lazy(()=>Promise.resolve().then(()=>require("./FAQSection-BmgmzDN5.js")).then(e=>({default:e.FAQSection}))),dm=_.lazy(()=>Promise.resolve().then(()=>require("./Token22Section-DUUl59dZ.js")).then(e=>({default:e.Token22Section}))),um=_.lazy(()=>Promise.resolve().then(()=>require("./OrdersSection-BKOxsZw0.js")).then(e=>({default:e.OrdersSection}))),Hc=[{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}]},{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}]}],fm=Hc.flatMap(e=>e.sections);function mm(){const[e,t]=_.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return _.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 pm(e,t,n){return e!=="system"?e:t||n}function hm({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]=_.useState(o),[b]=_.useState(!1),[x,h]=_.useState(new Set),v=_.useCallback(M=>{h(B=>{const $=new Set(B);return $.has(M)?$.delete(M):$.add(M),$})},[]),k=Ve.useCedrosThemeOptional(),w=mm(),j=pm(u,k?.mode??null,w)==="dark"?"cedros-admin--dark":"",R=Zf.useWallet(),{authManager:E,isAuthenticated:C}=rm({serverUrl:e,cedrosLoginToken:d,isAdmin:f,wallet:R}),A=_.useCallback(M=>{p(M),c?.(M)},[c]),U=fm.filter(M=>s.includes(M.id)).find(M=>M.id===g);return b?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..."})]}):C?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:Hc.map(M=>{const B=M.sections.filter(q=>s.includes(q.id));if(B.length===0)return null;const $=M.collapsible&&x.has(M.label);return r.jsxs("div",{className:"cedros-admin__nav-group",children:[M.collapsible?r.jsxs("button",{type:"button",className:"cedros-admin__nav-label cedros-admin__nav-label--collapsible",onClick:()=>v(M.label),"aria-expanded":!$,children:[M.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:M.label}),!$&&B.map(q=>r.jsxs("button",{type:"button",className:`cedros-admin__nav-item ${g===q.id?"cedros-admin__nav-item--active":""}`,onClick:()=>A(q.id),"aria-current":g===q.id?"page":void 0,children:[r.jsx("span",{className:"cedros-admin__nav-icon",children:q.icon}),r.jsx("span",{className:"cedros-admin__nav-text",children:q.label})]},q.id))]},M.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:U?.label})]})}),r.jsxs("div",{className:"cedros-admin__content",children:[g==="products"&&r.jsx(zc,{serverUrl:e,apiKey:t,pageSize:i,authManager:E}),g==="subscriptions"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(sm,{serverUrl:e,apiKey:t,authManager:E})}),g==="transactions"&&r.jsx(Fc,{serverUrl:e,apiKey:t,pageSize:i,authManager:E}),g==="orders"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(um,{serverUrl:e,apiKey:t,pageSize:i,authManager:E})}),g==="coupons"&&r.jsx(Uc,{serverUrl:e,apiKey:t,pageSize:i,authManager:E}),g==="refunds"&&r.jsx(Bc,{serverUrl:e,apiKey:t,pageSize:i,authManager:E}),g==="storefront"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(om,{serverUrl:e,apiKey:t,authManager:E})}),g==="ai-settings"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(am,{serverUrl:e,apiKey:t,authManager:E})}),g==="faqs"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(lm,{serverUrl:e,apiKey:t,pageSize:i,authManager:E})}),g==="payment-settings"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(im,{serverUrl:e,apiKey:t,authManager:E})}),g==="messaging"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(cm,{serverUrl:e,apiKey:t,authManager:E})}),g==="token22"&&r.jsx(_.Suspense,{fallback:r.jsx("div",{className:"cedros-admin__loading-text",children:"Loading section..."}),children:r.jsx(dm,{serverUrl:e,apiKey:t,authManager:E})}),g==="settings"&&r.jsx(Vc,{serverUrl:e,apiKey:t,authManager:E})]})]})]}):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 Ct=e=>_.lazy(async()=>{const s=(await e()).default;return{default:({pluginContext:a})=>{const c=qf.useCedrosLogin()?._internal?.getAccessToken()??a.getAccessToken(),l=_.useMemo(()=>{const f=new Wc(a.serverUrl);return f.setCedrosLoginAuth(c??null,!!c),f},[a.serverUrl,c]),d={serverUrl:a.serverUrl,authManager:l};return r.jsx(s,{...d})}}}),gm={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:"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:Ct(()=>Promise.resolve().then(()=>require("./sections-8e5Y3ukY.js")).then(e=>({default:e.ProductsSection}))),subscriptions:Ct(()=>Promise.resolve().then(()=>require("./SubscriptionsSection-Dn5SY6S_.js")).then(e=>({default:e.SubscriptionsSection}))),transactions:Ct(()=>Promise.resolve().then(()=>require("./sections-8e5Y3ukY.js")).then(e=>({default:e.TransactionsSection}))),coupons:Ct(()=>Promise.resolve().then(()=>require("./sections-8e5Y3ukY.js")).then(e=>({default:e.CouponsSection}))),refunds:Ct(()=>Promise.resolve().then(()=>require("./sections-8e5Y3ukY.js")).then(e=>({default:e.RefundsSection}))),storefront:Ct(()=>Promise.resolve().then(()=>require("./StorefrontSection-C9DzCmOf.js")).then(e=>({default:e.StorefrontSection}))),"ai-settings":Ct(()=>Promise.resolve().then(()=>require("./AISettingsSection-IXS1Wt_1.js")).then(e=>({default:e.AISettingsSection}))),faqs:Ct(()=>Promise.resolve().then(()=>require("./FAQSection-BmgmzDN5.js")).then(e=>({default:e.FAQSection}))),"payment-settings":Ct(()=>Promise.resolve().then(()=>require("./PaymentSettingsSection-BTEn9Dxb.js")).then(e=>({default:e.PaymentSettingsSection}))),messaging:Ct(()=>Promise.resolve().then(()=>require("./MessagingSection-CWLZcg11.js")).then(e=>({default:e.MessagingSection}))),settings:Ct(()=>Promise.resolve().then(()=>require("./SettingsSection-cKF0tLnS.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):!!(t.cedrosLogin?.user||t.cedrosPay?.jwtToken||t.cedrosPay?.walletAddress)},cssNamespace:"cedros-dashboard"},Zc=[{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"]}],xm=Zc.map(e=>e.qualifiedId),vm=[{id:"Store",label:"Store",order:1,defaultCollapsed:!1},{id:"Configuration",label:"Configuration",order:2,defaultCollapsed:!0}];function qc(e){const{creditsManager:t}=Ve.useCedrosContext(),[n,s]=_.useState({available:0,held:0,currency:"",loading:!1,error:null}),o=_.useRef(!0);_.useEffect(()=>(o.current=!0,()=>{o.current=!1}),[]);const a=_.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 _.useEffect(()=>{a()},[a]),{...n,refresh:a}}function ym({authToken:e,className:t="",formatBalance:n,showHeld:s=!1}){const o=Ve.useCedrosTheme(),{available:a,held:i,currency:c,loading:l,error:d,refresh:f}=qc(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 Qo=_.createContext(null);function Ee(){const e=_.useContext(Qo);if(!e)throw new Error("useCedrosShop must be used within CedrosShopProvider");return e}function Ko(){return _.useContext(Qo)}function bm({config:e,children:t}){const n=_.useMemo(()=>({config:e}),[e]);return r.jsx(Qo.Provider,{value:n,children:t})}function Nt(e){return new Promise(t=>setTimeout(t,e))}const Gc=[{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."}],es=[{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 wm(e,t){let n=e;if(t.category&&t.category!=="all"){const l=Gc.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 km(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 _m(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 jm(e){const t=new Date().toISOString(),n=e.cart.map(o=>{const a=es.find(i=>i.id===o.resource||i.slug===o.resource)??es[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 Sm(){let e=[];const t={};return{async listProducts(n){await Nt(150);const s=n.page??1,o=n.pageSize??24,a=wm(es,n),i=km(a,n.sort);return _m(i,s,o)},async getProductBySlug(n){return await Nt(100),es.find(s=>s.slug===n)??null},async listCategories(){return await Nt(80),Gc},async getOrderHistory(){return await Nt(120),e},async getCart({customerId:n}){return await Nt(80),t[n]??{items:[]}},async mergeCart({customerId:n,cart:s}){await Nt(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 Nt(60),t[n]=s},async createCheckoutSession(n){await Nt(250);const s=jm(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 Nt(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 Nt(80),{isActive:!1}},async createSubscriptionCheckoutSession(n){return await Nt(200),n.successUrl?{kind:"redirect",url:n.successUrl}:{kind:"custom",data:n}}}}const mi=50,Cm=4,Nm=5,Am=1e4,Em={maxRetries:2,initialDelayMs:100,backoffFactor:2,maxDelayMs:500,jitter:!1};function Yc(e){return e.replace(/[_-]+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function Im(e){return e?e.toUpperCase():"USD"}function Tm(e){if(e&&(e==="in_stock"||e==="low"||e==="out_of_stock"||e==="backorder"))return e}function Pm(e){if(e&&(e==="physical"||e==="digital"))return e}function Rm(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 Pn(e){const t=Im(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=Rm(a);return{id:e.id,slug:e.slug??e.id,title:e.title??Yc(e.id),description:e.description??"",images:n,price:s/100,currency:t,tags:e.tags??[],categoryIds:e.categoryIds??[],inventoryStatus:Tm(e.inventoryStatus),inventoryQuantity:typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0,compareAtPrice:typeof o=="number"?o/100:void 0,shippingProfile:Pm(e.shippingProfile),checkoutRequirements:e.checkoutRequirements,fulfillment:e.fulfillment,tokenizedAssetConfig:e.tokenizedAssetConfig,attributes:i.length?{shippingCountries:i.join(",")}:void 0}}function qr(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 Jt(e,t,n,s={}){const{body:o,headers:a,method:i="GET",retryableRead:c=!1,timeoutMs:l=Am}=s,d={};n&&(d["X-API-Key"]=n),a&&Object.assign(d,a);const f=async()=>{const u=await Ve.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?Ve.retryWithBackoff(f,{...Em,name:`paywall-read-${i.toLowerCase()}`}):f()}async function Om(e,t,n,s){const o=await Jt(e,`/paywall/v1/products?limit=${n}&offset=${s}`,t,{retryableRead:!0});return qr(o)}async function pi(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 Om(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 Mm(e){const t=async d=>{const f=d.page??1,u=d.pageSize??24,g=u,p=(f-1)*u,b=new URLSearchParams;b.set("limit",String(g)),b.set("offset",String(p)),d.search&&b.set("search",d.search),d.category&&b.set("category",d.category),d.sort&&b.set("sort",d.sort),d.filters?.inStock&&b.set("in_stock","true"),d.filters?.minPrice!=null&&b.set("min_price",String(d.filters.minPrice)),d.filters?.maxPrice!=null&&b.set("max_price",String(d.filters.maxPrice));const x=d.filters?.tags,h=Array.isArray(x)?x:typeof x=="string"?[x]:[];h.length&&b.set("tags",h.join(","));const v=await Jt(e.serverUrl,`/paywall/v1/products?${b.toString()}`,e.apiKey,{retryableRead:!0}),{products:k,total:w}=qr(v);return{items:k.map(Pn),page:f,pageSize:u,total:w,hasNextPage:typeof w=="number"?p+g<w:k.length===g}},n=async d=>{try{const f=await Jt(e.serverUrl,`/paywall/v1/products/by-slug/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Pn(f)}catch(f){const u=f?.status;if(u!==404&&u!==405)throw f;try{const g=await Jt(e.serverUrl,`/paywall/v1/products/${encodeURIComponent(d)}`,e.apiKey,{retryableRead:!0});return Pn(g)}catch(g){const p=g?.status;if(p!==404&&p!==405)throw g;let b;return await pi(e.serverUrl,e.apiKey,{maxPages:Cm,pageSize:mi},x=>(b=x.find(h=>h.slug===d||h.id===d),!!b)),b?Pn(b):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 b=new URLSearchParams;b.set("ids",f.join(",")),b.set("limit",String(f.length)),b.set("offset","0");const x=await Jt(e.serverUrl,`/paywall/v1/products?${b.toString()}`,e.apiKey,{retryableRead:!0}),{products:h}=qr(x);for(const v of h){const k=Pn(v);u.set(k.id,k),k.slug&&k.slug!==k.id&&u.set(k.slug,k)}}catch{}const g=f.filter(b=>!u.has(b));if(g.length===0)return u;let p=g;try{const b=new Set(p);if(await pi(e.serverUrl,e.apiKey,{maxPages:Nm,pageSize:mi},x=>{for(const h of x){const v=Pn(h);!b.has(v.id)&&!(v.slug&&b.has(v.slug))||(u.set(v.id,v),v.slug&&v.slug!==v.id&&u.set(v.slug,v),b.delete(v.id),v.slug&&b.delete(v.slug))}return b.size===0}),p=Array.from(b),p.length===0)return u}catch{}for(const b of p)try{const x=await n(b);x&&(u.set(x.id,x),x.slug&&x.slug!==x.id&&u.set(x.slug,x))}catch{}return u},listCategories:async()=>{const d=await Jt(e.serverUrl,"/paywall/v1/products?limit=500&offset=0",e.apiKey,{retryableRead:!0}),{products:f}=qr(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:Yc(g)}))},getOrderHistory:async()=>[],createCheckoutSession:async d=>{throw new Error("createCheckoutSession is not implemented for paywall adapter")},getStorefrontSettings:async()=>{try{return(await Jt(e.serverUrl,"/paywall/v1/storefront",e.apiKey,{retryableRead:!0})).config??null}catch{return null}},getPaymentMethodsConfig:async()=>{try{const f=(await Jt(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=>Jt(e.serverUrl,"/admin/ai/related-products",e.apiKey,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},retryableRead:!1})}}function Lm(e){throw new Error(`Unhandled cart action: ${JSON.stringify(e)}`)}function vn(e){return`${e.productId}::${e.variantId??""}`}const Dm={items:[]};function $m(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=vn(t.item);return e.items.find(a=>vn(a)===s)?{...e,items:e.items.map(a=>vn(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=>vn(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=>vn(o)!==s)}:{...e,items:e.items.map(o=>vn(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=>vn(s)===n?{...s,holdId:t.holdId,holdExpiresAt:t.holdExpiresAt}:s)}}default:return Lm(t)}}function zm(e){return e.reduce((t,n)=>t+n.qty,0)}function Fm(e){return e.reduce((t,n)=>t+n.qty*n.unitPrice,0)}function hi(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Um(e,t){try{const n=e.getItem(t);return n?JSON.parse(n):null}catch{return null}}function Bm(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 Qc=_.createContext(null);function Ot(){const e=_.useContext(Qc);if(!e)throw new Error("useCart must be used within CartProvider");return e}function gi(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 Vm({children:e}){const{config:t}=Ee(),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]=_.useReducer($m,Dm),d=_.useRef(c);d.current=c;const[f,u]=_.useState(!1),g=_.useRef(!1),p=_.useRef(null),b=_.useRef(null);_.useEffect(()=>{const k=hi();if(!k)return;const w=Um(k,n);if(w&&Array.isArray(w.items)){const y=w.items.filter(gi);l({type:"cart/hydrate",state:{items:y,promoCode:typeof w.promoCode=="string"?w.promoCode:void 0}})}u(!0)},[n]),_.useEffect(()=>{if(!f)return;const k=hi();k&&Bm(k,n,c)},[c,n,f]),_.useEffect(()=>{if(!f||!o||!s||!t.adapter.mergeCart&&!t.adapter.getCart||(b.current!==s&&(g.current=!1,p.current=null,b.current=s),g.current))return;let k=!1;return(async()=>{try{const w=t.adapter.mergeCart?await t.adapter.mergeCart({customerId:s,cart:d.current}):await t.adapter.getCart({customerId:s});if(k)return;if(w&&Array.isArray(w.items)){g.current=!0;const y={...w,items:w.items.filter(gi)};l({type:"cart/hydrate",state:y}),p.current=JSON.stringify(y)}}catch{k||(g.current=!1)}})(),()=>{k=!0}},[t.adapter,s,f,o]),_.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 w=window.setTimeout(()=>{t.adapter.updateCart({customerId:s,cart:c}).then(()=>{p.current=k}).catch(y=>{console.warn("[CedrosPay] Cart server sync failed:",y instanceof Error?y.message:y)})},a);return()=>window.clearTimeout(w)},[t.adapter,s,f,o,c,a]);const x=_.useCallback((k,w)=>{const y=c.items.find(j=>j.productId===k&&j.variantId===w);if(y)return{holdId:y.holdId,expiresAt:y.holdExpiresAt}},[c.items]),h=_.useCallback((k,w,y)=>{l({type:"cart/updateHold",productId:k,variantId:w,holdExpiresAt:y})},[]),v=_.useMemo(()=>{const k=zm(c.items),w=Fm(c.items);return{items:c.items,promoCode:c.promoCode,count:k,subtotal:w,addItem:(y,j)=>l({type:"cart/add",item:y,qty:j}),removeItem:(y,j)=>l({type:"cart/remove",productId:y,variantId:j}),setQty:(y,j,R)=>l({type:"cart/setQty",productId:y,variantId:j,qty:R}),clear:()=>l({type:"cart/clear"}),setPromoCode:y=>l({type:"cart/setPromoCode",promoCode:y}),holdsSupported:i,getItemHold:x,updateItemHold:h}},[c.items,c.promoCode,i,x,h]);return r.jsx(Qc.Provider,{value:v,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 $n extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Kc extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Jc={};function bn(e){return Jc}function Xc(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 No(e,t){return typeof t=="bigint"?t.toString():t}function Jo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Xo(e){return e==null}function ea(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Wm(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 xi=Symbol("evaluating");function be(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==xi)return s===void 0&&(s=xi,s=n()),s},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Cn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function un(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function vi(e){return JSON.stringify(e)}function Hm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const el="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ts(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Zm=Jo(()=>{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(ts(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ts(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tl(e){return pr(e)?{...e}:Array.isArray(e)?[...e]:e}const qm=new Set(["string","number","symbol"]);function Un(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fn(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(s._zod.parent=e),s}function ie(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 Gm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Ym={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 Qm(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=un(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 Cn(this,"shape",i),i},checks:[]});return fn(e,a)}function Km(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=un(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 Cn(this,"shape",i),i},checks:[]});return fn(e,a)}function Jm(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=un(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Cn(this,"shape",a),a}});return fn(e,o)}function Xm(e,t){if(!pr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=un(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Cn(this,"shape",s),s}});return fn(e,n)}function ep(e,t){const n=un(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Cn(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return fn(e,n)}function tp(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=un(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 Cn(this,"shape",l),l},checks:[]});return fn(t,i)}function np(e,t,n){const s=un(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 Cn(this,"shape",a),a}});return fn(t,s)}function Dn(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 nl(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function Tr(e){return typeof e=="string"?e:e?.message}function wn(e,t,n){const s={...e,path:e.path??[]};if(!e.message){const o=Tr(e.inst?._zod.def?.error?.(e))??Tr(t?.error?.(e))??Tr(n.customError?.(e))??Tr(n.localeError?.(e))??"Invalid input";s.message=o}return delete s.inst,delete s.continue,t?.reportInput||delete s.input,s}function ta(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 rl=(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,No,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},sl=z("$ZodError",rl),ol=z("$ZodError",rl,{Parent:Error});function rp(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 sp(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 na=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 $n;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(l=>wn(l,a,bn())));throw el(c,o?.callee),c}return i.value},ra=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=>wn(l,a,bn())));throw el(c,o?.callee),c}return i.value},ys=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 $n;return a.issues.length?{success:!1,error:new(e??sl)(a.issues.map(i=>wn(i,o,bn())))}:{success:!0,data:a.value}},op=ys(ol),bs=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=>wn(i,o,bn())))}:{success:!0,data:a.value}},ap=bs(ol),ip=e=>(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return na(e)(t,n,o)},cp=e=>(t,n,s)=>na(e)(t,n,s),lp=e=>async(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ra(e)(t,n,o)},dp=e=>async(t,n,s)=>ra(e)(t,n,s),up=e=>(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ys(e)(t,n,o)},fp=e=>(t,n,s)=>ys(e)(t,n,s),mp=e=>async(t,n,s)=>{const o=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return bs(e)(t,n,o)},pp=e=>async(t,n,s)=>bs(e)(t,n,s),hp=/^[cC][^\s-]{8,}$/,gp=/^[0-9a-z]+$/,xp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,vp=/^[0-9a-vA-V]{20}$/,yp=/^[A-Za-z0-9]{27}$/,bp=/^[a-zA-Z0-9_-]{21}$/,wp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kp=/^([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})$/,yi=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)$/,_p=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,jp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Sp(){return new RegExp(jp,"u")}const Cp=/^(?:(?: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])$/,Np=/^(([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}|:))$/,Ap=/^((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])$/,Ep=/^(([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])$/,Ip=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,al=/^[A-Za-z0-9_-]*$/,Tp=/^\+[1-9]\d{6,14}$/,il="(?:(?:\\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])))",Pp=new RegExp(`^${il}$`);function cl(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 Rp(e){return new RegExp(`^${cl(e)}$`)}function Op(e){const t=cl({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(`^${il}T(?:${s})$`)}const Mp=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Lp=/^-?\d+$/,Dp=/^-?\d+(?:\.\d+)?$/,$p=/^[^A-Z]*$/,zp=/^[^a-z]*$/,mt=z("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ll={number:"number",bigint:"bigint",object:"date"},dl=z("$ZodCheckLessThan",(e,t)=>{mt.init(e,t);const n=ll[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})}}),ul=z("$ZodCheckGreaterThan",(e,t)=>{mt.init(e,t);const n=ll[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})}}),Fp=z("$ZodCheckMultipleOf",(e,t)=>{mt.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):Wm(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})}}),Up=z("$ZodCheckNumberFormat",(e,t)=>{mt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),s=n?"int":"number",[o,a]=Ym[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=Lp)}),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})}}),Bp=z("$ZodCheckMaxLength",(e,t)=>{var n;mt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!Xo(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=ta(o);s.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Vp=z("$ZodCheckMinLength",(e,t)=>{var n;mt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!Xo(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=ta(o);s.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Wp=z("$ZodCheckLengthEquals",(e,t)=>{var n;mt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const o=s.value;return!Xo(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=ta(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})}}),ws=z("$ZodCheckStringFormat",(e,t)=>{var n,s;mt.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=()=>{})}),Hp=z("$ZodCheckRegex",(e,t)=>{ws.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})}}),Zp=z("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$p),ws.init(e,t)}),qp=z("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zp),ws.init(e,t)}),Gp=z("$ZodCheckIncludes",(e,t)=>{mt.init(e,t);const n=Un(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})}}),Yp=z("$ZodCheckStartsWith",(e,t)=>{mt.init(e,t);const n=new RegExp(`^${Un(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})}}),Qp=z("$ZodCheckEndsWith",(e,t)=>{mt.init(e,t);const n=new RegExp(`.*${Un(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})}}),Kp=z("$ZodCheckOverwrite",(e,t)=>{mt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Jp{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 Xp={major:4,minor:3,patch:6},Me=z("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xp;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=Dn(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 $n;if(f||p instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await p,i.issues.length!==g&&(d||(d=Dn(i,g)))});else{if(i.issues.length===g)continue;d||(d=Dn(i,g))}}return f?f.then(()=>i):i},a=(i,c,l)=>{if(Dn(i))return i.aborted=!0,i;const d=o(c,s,l);if(d instanceof Promise){if(l.async===!1)throw new $n;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 $n;return l.then(d=>o(d,s,c))}return o(l,s,c)}}be(e,"~standard",()=>({validate:o=>{try{const a=op(e,o);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return ap(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),sa=z("$ZodString",(e,t)=>{Me.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Mp(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}}),Ne=z("$ZodStringFormat",(e,t)=>{ws.init(e,t),sa.init(e,t)}),eh=z("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=kp),Ne.init(e,t)}),th=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=yi(s))}else t.pattern??(t.pattern=yi());Ne.init(e,t)}),nh=z("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_p),Ne.init(e,t)}),rh=z("$ZodURL",(e,t)=>{Ne.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})}}}),sh=z("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Sp()),Ne.init(e,t)}),oh=z("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=bp),Ne.init(e,t)}),ah=z("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=hp),Ne.init(e,t)}),ih=z("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gp),Ne.init(e,t)}),ch=z("$ZodULID",(e,t)=>{t.pattern??(t.pattern=xp),Ne.init(e,t)}),lh=z("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vp),Ne.init(e,t)}),dh=z("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yp),Ne.init(e,t)}),uh=z("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Op(t)),Ne.init(e,t)}),fh=z("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Pp),Ne.init(e,t)}),mh=z("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Rp(t)),Ne.init(e,t)}),ph=z("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wp),Ne.init(e,t)}),hh=z("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Cp),Ne.init(e,t),e._zod.bag.format="ipv4"}),gh=z("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Np),Ne.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})}}}),xh=z("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ap),Ne.init(e,t)}),vh=z("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ep),Ne.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 fl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const yh=z("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ip),Ne.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{fl(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function bh(e){if(!al.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return fl(n)}const wh=z("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=al),Ne.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{bh(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),kh=z("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Tp),Ne.init(e,t)});function _h(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 jh=z("$ZodJWT",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{_h(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ml=z("$ZodNumber",(e,t)=>{Me.init(e,t),e._zod.pattern=e._zod.bag.pattern??Dp,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}}),Sh=z("$ZodNumberFormat",(e,t)=>{Up.init(e,t),ml.init(e,t)}),Ch=z("$ZodUnknown",(e,t)=>{Me.init(e,t),e._zod.parse=n=>n}),Nh=z("$ZodNever",(e,t)=>{Me.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function bi(e,t,n){e.issues.length&&t.issues.push(...nl(n,e.issues)),t.value[n]=e.value}const Ah=z("$ZodArray",(e,t)=>{Me.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=>bi(d,n,i))):bi(l,n,i)}return a.length?Promise.all(a).then(()=>n):n}});function ns(e,t,n,s,o){if(e.issues.length){if(o&&!(n in s))return;t.issues.push(...nl(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function pl(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=Gm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function hl(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=>ns(p,n,u,t,f))):ns(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 Eh=z("$ZodObject",(e,t)=>{if(Me.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=Jo(()=>pl(t));be(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=ts,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],b=p._zod.optout==="optional",x=p._zod.run({value:d[g],issues:[]},l);x instanceof Promise?f.push(x.then(h=>ns(h,c,g,d,b))):ns(x,c,g,d,b)}return a?hl(f,d,c,l,s.value,e):f.length?Promise.all(f).then(()=>c):c}}),Ih=z("$ZodObjectJIT",(e,t)=>{Eh.init(e,t);const n=e._zod.parse,s=Jo(()=>pl(t)),o=g=>{const p=new Jp(["shape","payload","ctx"]),b=s.value,x=w=>{const y=vi(w);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};p.write("const input = payload.value;");const h=Object.create(null);let v=0;for(const w of b.keys)h[w]=`key_${v++}`;p.write("const newResult = {};");for(const w of b.keys){const y=h[w],j=vi(w),E=g[w]?._zod?.optout==="optional";p.write(`const ${y} = ${x(w)};`),E?p.write(`
|
|
4
|
-
if (${y}.issues.length) {
|
|
5
|
-
if (${j} in input) {
|
|
6
|
-
payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
|
|
7
|
-
...iss,
|
|
8
|
-
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
9
|
-
})));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (${y}.value === undefined) {
|
|
14
|
-
if (${j} in input) {
|
|
15
|
-
newResult[${j}] = undefined;
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
newResult[${j}] = ${y}.value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
`):p.write(`
|
|
22
|
-
if (${y}.issues.length) {
|
|
23
|
-
payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
|
|
24
|
-
...iss,
|
|
25
|
-
path: iss.path ? [${j}, ...iss.path] : [${j}]
|
|
26
|
-
})));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (${y}.value === undefined) {
|
|
30
|
-
if (${j} in input) {
|
|
31
|
-
newResult[${j}] = undefined;
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
newResult[${j}] = ${y}.value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
`)}p.write("payload.value = newResult;"),p.write("return payload;");const k=p.compile();return(w,y)=>k(g,w,y)};let a;const i=ts,c=!Jc.jitless,d=c&&Zm.value,f=t.catchall;let u;e._zod.parse=(g,p)=>{u??(u=s.value);const b=g.value;return i(b)?c&&d&&p?.async===!1&&p.jitless!==!0?(a||(a=o(t.shape)),g=a(g,p),f?hl([],b,g,p,u,e):g):n(g,p):(g.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),g)}});function wi(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=>!Dn(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=>wn(i,s,bn())))}),t)}const Th=z("$ZodUnion",(e,t)=>{Me.init(e,t),be(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),be(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),be(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),be(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=>ea(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=>wi(l,o,e,a)):wi(c,o,e,a)}}),Ph=z("$ZodIntersection",(e,t)=>{Me.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])=>ki(n,l,d)):ki(n,a,i)}});function Ao(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=Ao(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=Ao(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 ki(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}),Dn(e))return e;const i=Ao(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 Rh=z("$ZodEnum",(e,t)=>{Me.init(e,t);const n=Xc(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(o=>qm.has(typeof o)).map(o=>typeof o=="string"?Un(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}}),Oh=z("$ZodLiteral",(e,t)=>{if(Me.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"?Un(s):s?Un(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}}),Mh=z("$ZodTransform",(e,t)=>{Me.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Kc(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 $n;return n.value=o,n}});function _i(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const gl=z("$ZodOptional",(e,t)=>{Me.init(e,t),e._zod.optin="optional",e._zod.optout="optional",be(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ea(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=>_i(a,n.value)):_i(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),Lh=z("$ZodExactOptional",(e,t)=>{gl.init(e,t),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),Dh=z("$ZodNullable",(e,t)=>{Me.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ea(n.source)}|null)$`):void 0}),be(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)}),$h=z("$ZodDefault",(e,t)=>{Me.init(e,t),e._zod.optin="optional",be(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=>ji(a,t)):ji(o,t)}});function ji(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const zh=z("$ZodPrefault",(e,t)=>{Me.init(e,t),e._zod.optin="optional",be(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))}),Fh=z("$ZodNonOptional",(e,t)=>{Me.init(e,t),be(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=>Si(a,e)):Si(o,e)}});function Si(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 Uh=z("$ZodCatch",(e,t)=>{Me.init(e,t),be(e._zod,"optin",()=>t.innerType._zod.optin),be(e._zod,"optout",()=>t.innerType._zod.optout),be(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=>wn(i,s,bn()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(a=>wn(a,s,bn()))},input:n.value}),n.issues=[]),n)}}),Bh=z("$ZodPipe",(e,t)=>{Me.init(e,t),be(e._zod,"values",()=>t.in._zod.values),be(e._zod,"optin",()=>t.in._zod.optin),be(e._zod,"optout",()=>t.out._zod.optout),be(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=>Pr(i,t.in,s)):Pr(a,t.in,s)}const o=t.in._zod.run(n,s);return o instanceof Promise?o.then(a=>Pr(a,t.out,s)):Pr(o,t.out,s)}});function Pr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Vh=z("$ZodReadonly",(e,t)=>{Me.init(e,t),be(e._zod,"propValues",()=>t.innerType._zod.propValues),be(e._zod,"values",()=>t.innerType._zod.values),be(e._zod,"optin",()=>t.innerType?._zod?.optin),be(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(Ci):Ci(o)}});function Ci(e){return e.value=Object.freeze(e.value),e}const Wh=z("$ZodCustom",(e,t)=>{mt.init(e,t),Me.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=>Ni(a,n,s,e));Ni(o,n,s,e)}});function Ni(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 Ai;class Hh{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 Zh(){return new Hh}(Ai=globalThis).__zod_globalRegistry??(Ai.__zod_globalRegistry=Zh());const cr=globalThis.__zod_globalRegistry;function qh(e,t){return new e({type:"string",...ie(t)})}function Gh(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ie(t)})}function Ei(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ie(t)})}function Yh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ie(t)})}function Qh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ie(t)})}function Kh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ie(t)})}function Jh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ie(t)})}function Xh(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ie(t)})}function eg(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ie(t)})}function tg(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ie(t)})}function ng(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ie(t)})}function rg(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ie(t)})}function sg(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ie(t)})}function og(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ie(t)})}function ag(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ie(t)})}function ig(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ie(t)})}function cg(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ie(t)})}function lg(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ie(t)})}function dg(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ie(t)})}function ug(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ie(t)})}function fg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ie(t)})}function mg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ie(t)})}function pg(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ie(t)})}function hg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ie(t)})}function gg(e,t){return new e({type:"string",format:"date",check:"string_format",...ie(t)})}function xg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ie(t)})}function vg(e,t){return new e({type:"string",format:"duration",check:"string_format",...ie(t)})}function yg(e,t){return new e({type:"number",checks:[],...ie(t)})}function bg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ie(t)})}function wg(e){return new e({type:"unknown"})}function kg(e,t){return new e({type:"never",...ie(t)})}function Ii(e,t){return new dl({check:"less_than",...ie(t),value:e,inclusive:!1})}function no(e,t){return new dl({check:"less_than",...ie(t),value:e,inclusive:!0})}function Ti(e,t){return new ul({check:"greater_than",...ie(t),value:e,inclusive:!1})}function ro(e,t){return new ul({check:"greater_than",...ie(t),value:e,inclusive:!0})}function Pi(e,t){return new Fp({check:"multiple_of",...ie(t),value:e})}function xl(e,t){return new Bp({check:"max_length",...ie(t),maximum:e})}function rs(e,t){return new Vp({check:"min_length",...ie(t),minimum:e})}function vl(e,t){return new Wp({check:"length_equals",...ie(t),length:e})}function _g(e,t){return new Hp({check:"string_format",format:"regex",...ie(t),pattern:e})}function jg(e){return new Zp({check:"string_format",format:"lowercase",...ie(e)})}function Sg(e){return new qp({check:"string_format",format:"uppercase",...ie(e)})}function Cg(e,t){return new Gp({check:"string_format",format:"includes",...ie(t),includes:e})}function Ng(e,t){return new Yp({check:"string_format",format:"starts_with",...ie(t),prefix:e})}function Ag(e,t){return new Qp({check:"string_format",format:"ends_with",...ie(t),suffix:e})}function Wn(e){return new Kp({check:"overwrite",tx:e})}function Eg(e){return Wn(t=>t.normalize(e))}function Ig(){return Wn(e=>e.trim())}function Tg(){return Wn(e=>e.toLowerCase())}function Pg(){return Wn(e=>e.toUpperCase())}function Rg(){return Wn(e=>Hm(e))}function Og(e,t,n){return new e({type:"array",element:t,...ie(n)})}function Mg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ie(n)})}function Lg(e){const t=Dg(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 Dg(e,t){const n=new mt({check:"custom",...ie(t)});return n._zod.check=e,n}function yl(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"&&ot(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 bl(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??(b=>b);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 wl(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 x in l)x==="$ref"||x==="allOf"||x in d||delete l[x];if(p.$ref&&g.def)for(const x in l)x==="$ref"||x==="allOf"||x in g.def&&JSON.stringify(l[x])===JSON.stringify(g.def[x])&&delete l[x]}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:ss(t,"input",e.processors),output:ss(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function ot(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 ot(s.element,n);if(s.type==="set")return ot(s.valueType,n);if(s.type==="lazy")return ot(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 ot(s.innerType,n);if(s.type==="intersection")return ot(s.left,n)||ot(s.right,n);if(s.type==="record"||s.type==="map")return ot(s.keyType,n)||ot(s.valueType,n);if(s.type==="pipe")return ot(s.in,n)||ot(s.out,n);if(s.type==="object"){for(const o in s.shape)if(ot(s.shape[o],n))return!0;return!1}if(s.type==="union"){for(const o of s.options)if(ot(o,n))return!0;return!1}if(s.type==="tuple"){for(const o of s.items)if(ot(o,n))return!0;return!!(s.rest&&ot(s.rest,n))}return!1}const $g=(e,t={})=>n=>{const s=yl({...n,processors:t});return Ge(e,s),bl(s,e),wl(s,e)},ss=(e,t,n={})=>s=>{const{libraryOptions:o,target:a}=s??{},i=yl({...o??{},target:a,io:t,processors:n});return Ge(e,i),bl(i,e),wl(i,e)},zg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Fg=(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=zg[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}))])}},Ug=(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)},Bg=(e,t,n,s)=>{n.not={}},Vg=(e,t,n,s)=>{},Wg=(e,t,n,s)=>{const o=e._zod.def,a=Xc(o.entries);a.every(i=>typeof i=="number")&&(n.type="number"),a.every(i=>typeof i=="string")&&(n.type="string"),n.enum=a},Hg=(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},Zg=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},qg=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Gg=(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"]})},Yg=(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)},Qg=(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},Kg=(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},Jg=(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"}]},Xg=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType},ex=(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))},tx=(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)))},nx=(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},rx=(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},sx=(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},kl=(e,t,n,s)=>{const o=e._zod.def;Ge(o.innerType,t,s);const a=t.seen.get(e);a.ref=o.innerType},ox=z("ZodISODateTime",(e,t)=>{uh.init(e,t),Ie.init(e,t)});function ax(e){return hg(ox,e)}const ix=z("ZodISODate",(e,t)=>{fh.init(e,t),Ie.init(e,t)});function cx(e){return gg(ix,e)}const lx=z("ZodISOTime",(e,t)=>{mh.init(e,t),Ie.init(e,t)});function dx(e){return xg(lx,e)}const ux=z("ZodISODuration",(e,t)=>{ph.init(e,t),Ie.init(e,t)});function fx(e){return vg(ux,e)}const mx=(e,t)=>{sl.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>sp(e,n)},flatten:{value:n=>rp(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,No,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,No,2)}},isEmpty:{get(){return e.issues.length===0}}})},jt=z("ZodError",mx,{Parent:Error}),px=na(jt),hx=ra(jt),gx=ys(jt),xx=bs(jt),vx=ip(jt),yx=cp(jt),bx=lp(jt),wx=dp(jt),kx=up(jt),_x=fp(jt),jx=mp(jt),Sx=pp(jt),Le=z("ZodType",(e,t)=>(Me.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ss(e,"input"),output:ss(e,"output")}}),e.toJSONSchema=$g(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(un(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)=>fn(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>px(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>gx(e,n,s),e.parseAsync=async(n,s)=>hx(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>xx(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>vx(e,n,s),e.decode=(n,s)=>yx(e,n,s),e.encodeAsync=async(n,s)=>bx(e,n,s),e.decodeAsync=async(n,s)=>wx(e,n,s),e.safeEncode=(n,s)=>kx(e,n,s),e.safeDecode=(n,s)=>_x(e,n,s),e.safeEncodeAsync=async(n,s)=>jx(e,n,s),e.safeDecodeAsync=async(n,s)=>Sx(e,n,s),e.refine=(n,s)=>e.check(b0(n,s)),e.superRefine=n=>e.check(w0(n)),e.overwrite=n=>e.check(Wn(n)),e.optional=()=>Di(e),e.exactOptional=()=>i0(e),e.nullable=()=>$i(e),e.nullish=()=>Di($i(e)),e.nonoptional=n=>m0(e,n),e.array=()=>Qx(e),e.or=n=>Xx([e,n]),e.and=n=>t0(e,n),e.transform=n=>zi(e,o0(n)),e.default=n=>d0(e,n),e.prefault=n=>f0(e,n),e.catch=n=>h0(e,n),e.pipe=n=>zi(e,n),e.readonly=()=>v0(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)),_l=z("_ZodString",(e,t)=>{sa.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(s,o,a)=>Fg(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(_g(...s)),e.includes=(...s)=>e.check(Cg(...s)),e.startsWith=(...s)=>e.check(Ng(...s)),e.endsWith=(...s)=>e.check(Ag(...s)),e.min=(...s)=>e.check(rs(...s)),e.max=(...s)=>e.check(xl(...s)),e.length=(...s)=>e.check(vl(...s)),e.nonempty=(...s)=>e.check(rs(1,...s)),e.lowercase=s=>e.check(jg(s)),e.uppercase=s=>e.check(Sg(s)),e.trim=()=>e.check(Ig()),e.normalize=(...s)=>e.check(Eg(...s)),e.toLowerCase=()=>e.check(Tg()),e.toUpperCase=()=>e.check(Pg()),e.slugify=()=>e.check(Rg())}),Cx=z("ZodString",(e,t)=>{sa.init(e,t),_l.init(e,t),e.email=n=>e.check(Gh(Nx,n)),e.url=n=>e.check(Xh(Ax,n)),e.jwt=n=>e.check(pg(Vx,n)),e.emoji=n=>e.check(eg(Ex,n)),e.guid=n=>e.check(Ei(Ri,n)),e.uuid=n=>e.check(Yh(Rr,n)),e.uuidv4=n=>e.check(Qh(Rr,n)),e.uuidv6=n=>e.check(Kh(Rr,n)),e.uuidv7=n=>e.check(Jh(Rr,n)),e.nanoid=n=>e.check(tg(Ix,n)),e.guid=n=>e.check(Ei(Ri,n)),e.cuid=n=>e.check(ng(Tx,n)),e.cuid2=n=>e.check(rg(Px,n)),e.ulid=n=>e.check(sg(Rx,n)),e.base64=n=>e.check(ug(Fx,n)),e.base64url=n=>e.check(fg(Ux,n)),e.xid=n=>e.check(og(Ox,n)),e.ksuid=n=>e.check(ag(Mx,n)),e.ipv4=n=>e.check(ig(Lx,n)),e.ipv6=n=>e.check(cg(Dx,n)),e.cidrv4=n=>e.check(lg($x,n)),e.cidrv6=n=>e.check(dg(zx,n)),e.e164=n=>e.check(mg(Bx,n)),e.datetime=n=>e.check(ax(n)),e.date=n=>e.check(cx(n)),e.time=n=>e.check(dx(n)),e.duration=n=>e.check(fx(n))});function et(e){return qh(Cx,e)}const Ie=z("ZodStringFormat",(e,t)=>{Ne.init(e,t),_l.init(e,t)}),Nx=z("ZodEmail",(e,t)=>{nh.init(e,t),Ie.init(e,t)}),Ri=z("ZodGUID",(e,t)=>{eh.init(e,t),Ie.init(e,t)}),Rr=z("ZodUUID",(e,t)=>{th.init(e,t),Ie.init(e,t)}),Ax=z("ZodURL",(e,t)=>{rh.init(e,t),Ie.init(e,t)}),Ex=z("ZodEmoji",(e,t)=>{sh.init(e,t),Ie.init(e,t)}),Ix=z("ZodNanoID",(e,t)=>{oh.init(e,t),Ie.init(e,t)}),Tx=z("ZodCUID",(e,t)=>{ah.init(e,t),Ie.init(e,t)}),Px=z("ZodCUID2",(e,t)=>{ih.init(e,t),Ie.init(e,t)}),Rx=z("ZodULID",(e,t)=>{ch.init(e,t),Ie.init(e,t)}),Ox=z("ZodXID",(e,t)=>{lh.init(e,t),Ie.init(e,t)}),Mx=z("ZodKSUID",(e,t)=>{dh.init(e,t),Ie.init(e,t)}),Lx=z("ZodIPv4",(e,t)=>{hh.init(e,t),Ie.init(e,t)}),Dx=z("ZodIPv6",(e,t)=>{gh.init(e,t),Ie.init(e,t)}),$x=z("ZodCIDRv4",(e,t)=>{xh.init(e,t),Ie.init(e,t)}),zx=z("ZodCIDRv6",(e,t)=>{vh.init(e,t),Ie.init(e,t)}),Fx=z("ZodBase64",(e,t)=>{yh.init(e,t),Ie.init(e,t)}),Ux=z("ZodBase64URL",(e,t)=>{wh.init(e,t),Ie.init(e,t)}),Bx=z("ZodE164",(e,t)=>{kh.init(e,t),Ie.init(e,t)}),Vx=z("ZodJWT",(e,t)=>{jh.init(e,t),Ie.init(e,t)}),jl=z("ZodNumber",(e,t)=>{ml.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(s,o,a)=>Ug(e,s,o),e.gt=(s,o)=>e.check(Ti(s,o)),e.gte=(s,o)=>e.check(ro(s,o)),e.min=(s,o)=>e.check(ro(s,o)),e.lt=(s,o)=>e.check(Ii(s,o)),e.lte=(s,o)=>e.check(no(s,o)),e.max=(s,o)=>e.check(no(s,o)),e.int=s=>e.check(Oi(s)),e.safe=s=>e.check(Oi(s)),e.positive=s=>e.check(Ti(0,s)),e.nonnegative=s=>e.check(ro(0,s)),e.negative=s=>e.check(Ii(0,s)),e.nonpositive=s=>e.check(no(0,s)),e.multipleOf=(s,o)=>e.check(Pi(s,o)),e.step=(s,o)=>e.check(Pi(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 Wx(e){return yg(jl,e)}const Hx=z("ZodNumberFormat",(e,t)=>{Sh.init(e,t),jl.init(e,t)});function Oi(e){return bg(Hx,e)}const Zx=z("ZodUnknown",(e,t)=>{Ch.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Vg()});function Mi(){return wg(Zx)}const qx=z("ZodNever",(e,t)=>{Nh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Bg(e,n,s)});function Gx(e){return kg(qx,e)}const Yx=z("ZodArray",(e,t)=>{Ah.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Gg(e,n,s,o),e.element=t.element,e.min=(n,s)=>e.check(rs(n,s)),e.nonempty=n=>e.check(rs(1,n)),e.max=(n,s)=>e.check(xl(n,s)),e.length=(n,s)=>e.check(vl(n,s)),e.unwrap=()=>e.element});function Qx(e,t){return Og(Yx,e,t)}const Kx=z("ZodObject",(e,t)=>{Ih.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Yg(e,n,s,o),be(e,"shape",()=>t.shape),e.keyof=()=>n0(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Mi()}),e.loose=()=>e.clone({...e._zod.def,catchall:Mi()}),e.strict=()=>e.clone({...e._zod.def,catchall:Gx()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Jm(e,n),e.safeExtend=n=>Xm(e,n),e.merge=n=>ep(e,n),e.pick=n=>Qm(e,n),e.omit=n=>Km(e,n),e.partial=(...n)=>tp(Cl,e,n[0]),e.required=(...n)=>np(Nl,e,n[0])});function Sl(e,t){const n={type:"object",shape:e??{},...ie(t)};return new Kx(n)}const Jx=z("ZodUnion",(e,t)=>{Th.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Qg(e,n,s,o),e.options=t.options});function Xx(e,t){return new Jx({type:"union",options:e,...ie(t)})}const e0=z("ZodIntersection",(e,t)=>{Ph.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Kg(e,n,s,o)});function t0(e,t){return new e0({type:"intersection",left:e,right:t})}const Eo=z("ZodEnum",(e,t)=>{Rh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(s,o,a)=>Wg(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 Eo({...t,checks:[],...ie(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 Eo({...t,checks:[],...ie(o),entries:a})}});function n0(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new Eo({type:"enum",entries:n,...ie(t)})}const r0=z("ZodLiteral",(e,t)=>{Oh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Hg(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 Li(e,t){return new r0({type:"literal",values:Array.isArray(e)?e:[e],...ie(t)})}const s0=z("ZodTransform",(e,t)=>{Mh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>qg(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new Kc(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 o0(e){return new s0({type:"transform",transform:e})}const Cl=z("ZodOptional",(e,t)=>{gl.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>kl(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function Di(e){return new Cl({type:"optional",innerType:e})}const a0=z("ZodExactOptional",(e,t)=>{Lh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>kl(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function i0(e){return new a0({type:"optional",innerType:e})}const c0=z("ZodNullable",(e,t)=>{Dh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Jg(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function $i(e){return new c0({type:"nullable",innerType:e})}const l0=z("ZodDefault",(e,t)=>{$h.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>ex(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function d0(e,t){return new l0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tl(t)}})}const u0=z("ZodPrefault",(e,t)=>{zh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>tx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function f0(e,t){return new u0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tl(t)}})}const Nl=z("ZodNonOptional",(e,t)=>{Fh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Xg(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function m0(e,t){return new Nl({type:"nonoptional",innerType:e,...ie(t)})}const p0=z("ZodCatch",(e,t)=>{Uh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>nx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function h0(e,t){return new p0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const g0=z("ZodPipe",(e,t)=>{Bh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>rx(e,n,s,o),e.in=t.in,e.out=t.out});function zi(e,t){return new g0({type:"pipe",in:e,out:t})}const x0=z("ZodReadonly",(e,t)=>{Vh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>sx(e,n,s,o),e.unwrap=()=>e._zod.def.innerType});function v0(e){return new x0({type:"readonly",innerType:e})}const y0=z("ZodCustom",(e,t)=>{Wh.init(e,t),Le.init(e,t),e._zod.processJSONSchema=(n,s,o)=>Zg(e,n)});function b0(e,t={}){return Mg(y0,e,t)}function w0(e){return Lg(e)}const Or=Sl({line1:et().min(1,"Address line 1 is required"),line2:et().optional(),city:et().min(1,"City is required"),state:et().optional(),postalCode:et().min(1,"Postal code is required"),country:et().min(2,"Country is required")});function k0(e){return Sl({email:e.requireEmail?et().email("Valid email required"):et().email("Valid email required").or(Li("")).optional(),name:e.requireName?et().min(1,"Name is required"):et().optional(),phone:e.requirePhone?et().min(6,"Phone is required"):et().optional(),notes:et().max(500).optional(),shippingAddress:e.requireShippingAddress?Or:Or.optional(),billingAddress:e.requireBillingAddress?Or:Or.optional(),recipientEmail:et().email("Valid recipient email required").or(Li("")).optional(),discountCode:et().optional(),tipAmount:Wx().min(0).optional(),shippingMethodId:et().optional()})}const Fi={none:0,optional:1,required:2};function so(e,t){return Fi[e]>=Fi[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 Gr(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=so(a,p.email)),p.name&&(i=so(i,p.name)),p.phone&&(c=so(c,p.phone)),typeof p.shippingAddress=="boolean"&&(l=l||p.shippingAddress),typeof p.billingAddress=="boolean"&&(d=d||p.billingAddress));const b=u.metadata?.fulfillmentNotes;b&&o.add(b)}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 Al=_.createContext(null);function El(){const{config:e}=Ee(),t=Ot(),n=_.useMemo(()=>({line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"}),[]),s=_.useMemo(()=>{const w=Gr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});return k0({requireEmail:w.email==="required",requireName:w.name==="required",requirePhone:w.phone==="required",requireShippingAddress:w.shippingAddress,requireBillingAddress:w.billingAddress})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail]),[o,a]=_.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:""}));_.useEffect(()=>{const w=Gr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1});a(y=>{const j={...y};return w.email==="required"&&!j.email&&(j.email=""),w.shippingAddress&&!j.shippingAddress&&(j.shippingAddress=n),w.billingAddress&&!j.billingAddress&&(j.billingAddress=n),w.shippingAddress||(j.shippingAddress=void 0),w.billingAddress||(j.billingAddress=void 0),j})},[t.items,e.checkout.allowShipping,e.checkout.mode,e.checkout.requireEmail,n]);const i=_.useRef(!1),[c,l]=_.useState({}),[d,f]=_.useState("idle"),[u,g]=_.useState(null),[p,b]=_.useState(null),x=_.useCallback(()=>{l({}),f("idle"),g(null),b(null)},[]),h=_.useCallback((w,y)=>{a(j=>({...j,[w]:y}))},[]),v=_.useCallback(()=>{f("validating"),g(null);const w=s.safeParse(o);if(w.success)return l({}),f("idle"),{ok:!0,values:w.data};const y={};for(const j of w.error.issues)y[j.path.join(".")]=j.message;return l(y),f("error"),g("Please fix the highlighted fields."),{ok:!1}},[s,o]),k=_.useCallback(async w=>{if(i.current)return{ok:!1};const y=v();if(!y.ok)return{ok:!1};i.current=!0,f("creating_session"),g(null),b(null);const j=t.items.map(A=>({resource:A.paymentResource??A.productId,quantity:A.qty,variantId:A.variantId})),R=Gr(t.items,{requireEmail:e.checkout.requireEmail??!0,defaultMode:e.checkout.mode,allowShipping:e.checkout.allowShipping??!1}),E=new Set;if(R.shippingAddress)for(const A of t.items){const O=A.metadata?.shippingCountries;if(O)for(const U of O.split(",")){const M=U.trim().toUpperCase();M&&E.add(M)}}const C={...E.size?{shippingCountries:Array.from(E).join(","),shipping_countries:Array.from(E).join(",")}:{},...y.values.recipientEmail?{recipient_email:y.values.recipientEmail}:{}};try{const A=await e.adapter.createCheckoutSession({cart:j,customer:{email:y.values.email||void 0,name:y.values.name||void 0,phone:y.values.phone||void 0,notes:y.values.notes||void 0,shippingAddress:y.values.shippingAddress,billingAddress:y.values.billingAddress},options:{currency:e.currency,successUrl:e.checkout.successUrl,cancelUrl:e.checkout.cancelUrl,allowPromoCodes:e.checkout.allowPromoCodes,metadata:Object.keys(C).length?C:void 0,discountCode:(e.checkout.allowPromoCodes?y.values.discountCode||t.promoCode:void 0)||void 0,tipAmount:e.checkout.allowTipping&&y.values.tipAmount||void 0,shippingMethodId:e.checkout.allowShipping&&y.values.shippingMethodId||void 0,paymentMethodId:w?.paymentMethodId}});return A.kind==="redirect"?(b(A),f("redirecting"),typeof window<"u"&&window.location.assign(A.url),{ok:!0,session:A}):(b(A),f("success"),{ok:!0,session:A})}catch(A){return f("error"),g(A instanceof Error?A.message:"Checkout failed"),{ok:!1}}finally{i.current=!1}},[t.items,t.promoCode,e.adapter,e.checkout,e.currency,v]);return{values:o,setValues:a,setField:h,fieldErrors:c,status:d,error:u,session:p,reset:x,validate:v,createCheckoutSession:k}}function Il({children:e}){const t=El();return r.jsx(Al.Provider,{value:t,children:e})}function ks(){const e=_.useContext(Al);if(!e)throw new Error("useCheckout must be used within CheckoutProvider");return e}function j0(){return El()}function oa(){const{config:e}=Ee(),[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 _s(e){const{config:t}=Ee(),[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 Tl(e){const{config:t}=Ee(),[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 Pl(){const{config:e}=Ee(),[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 Rl(){const{config:e}=Ee(),[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 Ol({enabled:e,customer:t}){const{config:n}=Ee(),[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 aa(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 S0(e){const t={};return e.forEach((n,s)=>{t[s]=n}),t}function ia(){const{config:e}=Ee(),[t,n]=m.useState({kind:"idle"});return m.useEffect(()=>{if(typeof window>"u")return;const s=new URLSearchParams(window.location.search),o=S0(s);(async()=>{try{const a=e.adapter.resolveCheckoutReturn?await e.adapter.resolveCheckoutReturn({query:o}):aa(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 Io(e){if(!e)return;const t=Number(e);return Number.isFinite(t)?t:void 0}function C0(e){const t=e.get("tags"),n=t?t.split(",").map(c=>c.trim()).filter(Boolean):void 0,s=Io(e.get("min")),o=Io(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 N0(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 ca({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=Io(t.get("page"))??1,a=C0(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 la(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")),N0(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])}function Ui(e,t){return`${e}::${t??""}`}function A0(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 E0(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}=A0(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 da({items:e,refreshInterval:t=3e4,skip:n=!1}){const{config:s}=Ee(),[o,a]=m.useState(new Map),[i,c]=m.useState(!1),[l,d]=m.useState(null),f=m.useRef(e);f.current=e;const u=m.useMemo(()=>{const v=new Set;for(const k of e)v.add(k.productId);return v},[e]),g=m.useMemo(()=>Array.from(u).sort().join(","),[u]),p=m.useMemo(()=>Array.from(u),[u]),b=m.useCallback(async()=>{if(n||p.length===0){a(new Map);return}c(!0),d(null);try{let v=new Map;if(s.adapter.getProductsByIds)v=await s.adapter.getProductsByIds(p);else{const w=await Promise.all(p.map(async y=>{try{return await s.adapter.getProductBySlug(y)}catch{return null}}));v=new Map;for(const y of w)y&&(v.set(y.id,y),y.slug&&y.slug!==y.id&&v.set(y.slug,y))}const k=new Map;for(const w of f.current){const y=Ui(w.productId,w.variantId),j=v.get(w.productId)??null;k.set(y,E0(w,j))}a(k)}catch(v){d(v instanceof Error?v.message:"Failed to check inventory")}finally{c(!1)}},[s.adapter,g,n]);m.useEffect(()=>{b()},[b]),m.useEffect(()=>{if(n||t<=0||p.length===0)return;const v=setInterval(b,t);return()=>clearInterval(v)},[b,p.length,t,n]);const x=m.useCallback((v,k)=>o.get(Ui(v,k)),[o]),h=m.useMemo(()=>{for(const v of o.values())if(v.isOutOfStock||v.exceedsAvailable)return!0;return!1},[o]);return{inventory:o,isLoading:i,error:l,refresh:b,getItemInventory:x,hasIssues:h}}function I0(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 T0(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 P0(e,t){const n=T0(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}=I0(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 Ml({items:e}){const{config:t}=Ee(),[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 b=await Promise.all(l.map(async x=>{try{return await t.adapter.getProductBySlug(x)}catch{return null}}));u=new Map;for(const x of b)x&&(u.set(x.id,x),x.slug&&x.slug!==x.id&&u.set(x.slug,x))}const g=[];for(const b of e){const x=u.get(b.productId)??null,h=P0(b,x);h&&g.push(h)}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 R0({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,b=[],x=[];for(const h of d){if(!h.holdExpiresAt)continue;const v=new Date(h.holdExpiresAt),k=v.getTime()-g,w=`${h.productId}::${h.variantId??""}`;k<=0?(b.push({productId:h.productId,variantId:h.variantId}),c.current.has(w)||(c.current.add(w),l.current?.({productId:h.productId,variantId:h.variantId,title:h.titleSnapshot,expiredAt:v}))):k<=p&&x.push({productId:h.productId,variantId:h.variantId,expiresAt:v,remainingMs:k})}o(b),i(x)};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 _e={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 O0(e){return{relatedProducts:{mode:e.relatedProducts?.mode||_e.relatedProducts.mode,maxItems:e.relatedProducts?.maxItems||_e.relatedProducts.maxItems,layout:{layout:e.relatedProducts?.layout?.layout??_e.relatedProducts.layout.layout,imageCrop:e.relatedProducts?.layout?.imageCrop??_e.relatedProducts.layout.imageCrop}},catalog:{filters:{tags:e.catalog?.filters?.tags??_e.catalog.filters.tags,priceRange:e.catalog?.filters?.priceRange??_e.catalog.filters.priceRange,inStock:e.catalog?.filters?.inStock??_e.catalog.filters.inStock},sort:{featured:e.catalog?.sort?.featured??_e.catalog.sort.featured,priceAsc:e.catalog?.sort?.priceAsc??_e.catalog.sort.priceAsc,priceDesc:e.catalog?.sort?.priceDesc??_e.catalog.sort.priceDesc}},checkout:{promoCodes:e.checkout?.promoCodes??_e.checkout.promoCodes},shopLayout:{layout:e.shopLayout?.layout??_e.shopLayout.layout,imageCrop:e.shopLayout?.imageCrop??_e.shopLayout.imageCrop},categoryLayout:{layout:e.categoryLayout?.layout??_e.categoryLayout.layout,imageCrop:e.categoryLayout?.imageCrop??_e.categoryLayout.imageCrop},sections:{showDescription:e.sections?.showDescription??_e.sections.showDescription,showSpecs:e.sections?.showSpecs??_e.sections.showSpecs,showShipping:e.sections?.showShipping??_e.sections.showShipping,showRelatedProducts:e.sections?.showRelatedProducts??_e.sections.showRelatedProducts},inventory:{preCheckoutVerification:e.inventory?.preCheckoutVerification??_e.inventory.preCheckoutVerification,holdsEnabled:e.inventory?.holdsEnabled??_e.inventory.holdsEnabled,holdDurationMinutes:e.inventory?.holdDurationMinutes??_e.inventory.holdDurationMinutes},shopPage:{title:e.shopPage?.title??_e.shopPage.title,description:e.shopPage?.description??_e.shopPage.description}}}function Hn(e={}){const n=Ko()?.config?.adapter,[s,o]=_.useState(_e),[a,i]=_.useState(!!n?.getStorefrontSettings);return _.useEffect(()=>{if(!n?.getStorefrontSettings){i(!1);return}let c=!1;async function l(){try{const d=await n.getStorefrontSettings();!c&&d&&o(O0(d))}catch{}finally{c||i(!1)}}return l(),()=>{c=!0}},[n]),{settings:s,isLoading:a}}const M0={card:!0,crypto:!0,credits:!1};function Ll(){const t=Ko()?.config?.adapter,[n,s]=_.useState(M0),[o,a]=_.useState(!!t?.getPaymentMethodsConfig);return _.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 L0=50,tr=new Map;function D0(e){return e.productId?`id:${e.productId}`:e.name?`name:${e.name}`:""}function Dl(e={}){const{productId:t,product:n,enabled:s=!0}=e,a=Ko()?.config?.adapter,[i,c]=_.useState(null),[l,d]=_.useState(null),[f,u]=_.useState(!1),[g,p]=_.useState(null),b=_.useRef(0),x=_.useCallback(async()=>{const h=t?{productId:t}:n?{name:n.name,description:n.description,tags:n.tags,categoryIds:n.categoryIds}:{};if(!h.productId&&!h.name)return;if(!a?.getAIRelatedProducts){p("AI recommendations not available");return}const v=D0(h),k=tr.get(v);if(k){c(k.relatedProductIds),d(k.reasoning),p(null);return}const w=++b.current;u(!0),p(null);try{const y=await a.getAIRelatedProducts(h);if(w===b.current&&(c(y.relatedProductIds),d(y.reasoning),p(null),v)){if(tr.size>=L0){const j=tr.keys().next().value;j!==void 0&&tr.delete(j)}tr.set(v,y)}}catch(y){if(w===b.current){const j=y instanceof Error?y.message:"Failed to get AI recommendations";p(j),c(null),d(null)}}finally{w===b.current&&u(!1)}},[a,t,n]);return _.useEffect(()=>{s&&(!t&&!n?.name||x())},[s,t,n?.name,x]),{relatedProductIds:i,reasoning:l,isLoading:f,error:g,refetch:x}}function Ae(e,t){if(!e)throw new Error(t)}function At(e){return typeof e=="string"&&e.trim().length>0}async function $0(e,t={}){const n=t.pageSize??10,s=await e.listCategories();Ae(Array.isArray(s),"listCategories() must return an array");for(const i of s)Ae(At(i.id),"Category.id is required"),Ae(At(i.slug),"Category.slug is required"),Ae(At(i.name),"Category.name is required");const o=await e.listProducts({page:1,pageSize:n});if(Ae(o&&Array.isArray(o.items),"listProducts() must return { items: Product[] }"),Ae(typeof o.page=="number","listProducts().page must be a number"),Ae(typeof o.pageSize=="number","listProducts().pageSize must be a number"),o.items.length>0){const i=o.items[0];Ae(At(i.id),"Product.id is required"),Ae(At(i.slug),"Product.slug is required"),Ae(At(i.title),"Product.title is required"),Ae(typeof i.description=="string","Product.description must be a string"),Ae(Array.isArray(i.images),"Product.images must be an array"),Ae(typeof i.price=="number","Product.price must be a number"),Ae(At(i.currency),"Product.currency is required"),Ae(Array.isArray(i.tags),"Product.tags must be an array"),Ae(Array.isArray(i.categoryIds),"Product.categoryIds must be an array");const c=await e.getProductBySlug(i.slug);Ae(c===null||At(c.id),"getProductBySlug() must return Product or null")}const a=await e.getOrderHistory();Ae(Array.isArray(a),"getOrderHistory() must return an array");for(const i of a)Ae(At(i.id),"Order.id is required"),Ae(At(i.createdAt),"Order.createdAt is required"),Ae(typeof i.total=="number","Order.total must be a number"),Ae(At(i.currency),"Order.currency is required"),Ae(Array.isArray(i.items),"Order.items must be an array")}function Bi(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Zn(...e){return t=>{let n=!1;const s=e.map(o=>{const a=Bi(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():Bi(e[o],null)}}}}function Ce(...e){return m.useCallback(Zn(...e),e)}var z0=Symbol.for("react.lazy"),os=m[" use ".trim().toString()];function F0(e){return typeof e=="object"&&e!==null&&"then"in e}function $l(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===z0&&"_payload"in e&&F0(e._payload)}function zl(e){const t=B0(e),n=m.forwardRef((s,o)=>{let{children:a,...i}=s;$l(a)&&typeof os=="function"&&(a=os(a._payload));const c=m.Children.toArray(a),l=c.find(W0);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 U0=zl("Slot");function B0(e){const t=m.forwardRef((n,s)=>{let{children:o,...a}=n;if($l(o)&&typeof os=="function"&&(o=os(o._payload)),m.isValidElement(o)){const i=Z0(o),c=H0(a,o.props);return o.type!==m.Fragment&&(c.ref=s?Zn(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 V0=Symbol("radix.slottable");function W0(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===V0}function H0(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 Z0(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 Fl(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=Fl(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function Ul(){for(var e,t,n=0,s="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Fl(e))&&(s&&(s+=" "),s+=t);return s}const Vi=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Wi=Ul,ua=(e,t)=>n=>{var s;if(t?.variants==null)return Wi(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=Vi(f)||Vi(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(b=>{let[x,h]=b;return Array.isArray(h)?h.includes({...a,...c}[x]):{...a,...c}[x]===h})?[...d,u,g]:d},[]);return Wi(e,i,l,n?.class,n?.className)},q0=(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},G0=(e,t)=>({classGroupId:e,validator:t}),Bl=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),as="-",Hi=[],Y0="arbitrary..",Q0=e=>{const t=J0(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return K0(i);const c=i.split(as),l=c[0]===""&&c.length>1?1:0;return Vl(c,l,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const l=s[i],d=n[i];return l?d?q0(d,l):l:d||Hi}return n[i]||Hi}}},Vl=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const o=e[t],a=n.nextPart.get(o);if(a){const d=Vl(e,t+1,a);if(d)return d}const i=n.validators;if(i===null)return;const c=t===0?e.join(as):e.slice(t).join(as),l=i.length;for(let d=0;d<l;d++){const f=i[d];if(f.validator(c))return f.classGroupId}},K0=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?Y0+s:void 0})(),J0=e=>{const{theme:t,classGroups:n}=e;return X0(n,t)},X0=(e,t)=>{const n=Bl();for(const s in e){const o=e[s];fa(o,n,s,t)}return n},fa=(e,t,n,s)=>{const o=e.length;for(let a=0;a<o;a++){const i=e[a];ev(i,t,n,s)}},ev=(e,t,n,s)=>{if(typeof e=="string"){tv(e,t,n);return}if(typeof e=="function"){nv(e,t,n,s);return}rv(e,t,n,s)},tv=(e,t,n)=>{const s=e===""?t:Wl(t,e);s.classGroupId=n},nv=(e,t,n,s)=>{if(sv(e)){fa(e(s),t,n,s);return}t.validators===null&&(t.validators=[]),t.validators.push(G0(n,e))},rv=(e,t,n,s)=>{const o=Object.entries(e),a=o.length;for(let i=0;i<a;i++){const[c,l]=o[i];fa(l,Wl(t,c),n,s)}},Wl=(e,t)=>{let n=e;const s=t.split(as),o=s.length;for(let a=0;a<o;a++){const i=s[a];let c=n.nextPart.get(i);c||(c=Bl(),n.nextPart.set(i,c)),n=c}return n},sv=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,ov=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)}}},To="!",Zi=":",av=[],qi=(e,t,n,s,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:s,isExternal:o}),iv=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 x=0;x<f;x++){const h=o[x];if(i===0&&c===0){if(h===Zi){a.push(o.slice(l,x)),l=x+1;continue}if(h==="/"){d=x;continue}}h==="["?i++:h==="]"?i--:h==="("?c++:h===")"&&c--}const u=a.length===0?o:o.slice(l);let g=u,p=!1;u.endsWith(To)?(g=u.slice(0,-1),p=!0):u.startsWith(To)&&(g=u.slice(1),p=!0);const b=d&&d>l?d-l:void 0;return qi(a,p,g,b)};if(t){const o=t+Zi,a=s;s=i=>i.startsWith(o)?a(i.slice(o.length)):qi(av,!1,i,void 0,!0)}if(n){const o=s;s=a=>n({className:a,parseClassName:o})}return s},cv=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}},lv=e=>({cache:ov(e.cacheSize),parseClassName:iv(e),sortModifiers:cv(e),...Q0(e)}),dv=/\s+/,uv=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:o,sortModifiers:a}=t,i=[],c=e.trim().split(dv);let l="";for(let d=c.length-1;d>=0;d-=1){const f=c[d],{isExternal:u,modifiers:g,hasImportantModifier:p,baseClassName:b,maybePostfixModifierPosition:x}=n(f);if(u){l=f+(l.length>0?" "+l:l);continue}let h=!!x,v=s(h?b.substring(0,x):b);if(!v){if(!h){l=f+(l.length>0?" "+l:l);continue}if(v=s(b),!v){l=f+(l.length>0?" "+l:l);continue}h=!1}const k=g.length===0?"":g.length===1?g[0]:a(g).join(":"),w=p?k+To:k,y=w+v;if(i.indexOf(y)>-1)continue;i.push(y);const j=o(v,h);for(let R=0;R<j.length;++R){const E=j[R];i.push(w+E)}l=f+(l.length>0?" "+l:l)}return l},fv=(...e)=>{let t=0,n,s,o="";for(;t<e.length;)(n=e[t++])&&(s=Hl(n))&&(o&&(o+=" "),o+=s);return o},Hl=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=Hl(e[s]))&&(n&&(n+=" "),n+=t);return n},mv=(e,...t)=>{let n,s,o,a;const i=l=>{const d=t.reduce((f,u)=>u(f),e());return n=lv(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=uv(l,n);return o(l,f),f};return a=i,(...l)=>a(fv(...l))},pv=[],Ue=e=>{const t=n=>n[e]||pv;return t.isThemeGetter=!0,t},Zl=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,ql=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hv=/^\d+\/\d+$/,gv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,xv=/\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$/,vv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,yv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rn=e=>hv.test(e),fe=e=>!!e&&!Number.isNaN(Number(e)),sn=e=>!!e&&Number.isInteger(Number(e)),oo=e=>e.endsWith("%")&&fe(e.slice(0,-1)),Kt=e=>gv.test(e),wv=()=>!0,kv=e=>xv.test(e)&&!vv.test(e),Gl=()=>!1,_v=e=>yv.test(e),jv=e=>bv.test(e),Sv=e=>!te(e)&&!ne(e),Cv=e=>qn(e,Kl,Gl),te=e=>Zl.test(e),yn=e=>qn(e,Jl,kv),ao=e=>qn(e,Tv,fe),Gi=e=>qn(e,Yl,Gl),Nv=e=>qn(e,Ql,jv),Mr=e=>qn(e,Xl,_v),ne=e=>ql.test(e),nr=e=>Gn(e,Jl),Av=e=>Gn(e,Pv),Yi=e=>Gn(e,Yl),Ev=e=>Gn(e,Kl),Iv=e=>Gn(e,Ql),Lr=e=>Gn(e,Xl,!0),qn=(e,t,n)=>{const s=Zl.exec(e);return s?s[1]?t(s[1]):n(s[2]):!1},Gn=(e,t,n=!1)=>{const s=ql.exec(e);return s?s[1]?t(s[1]):n:!1},Yl=e=>e==="position"||e==="percentage",Ql=e=>e==="image"||e==="url",Kl=e=>e==="length"||e==="size"||e==="bg-size",Jl=e=>e==="length",Tv=e=>e==="number",Pv=e=>e==="family-name",Xl=e=>e==="shadow",Rv=()=>{const e=Ue("color"),t=Ue("font"),n=Ue("text"),s=Ue("font-weight"),o=Ue("tracking"),a=Ue("leading"),i=Ue("breakpoint"),c=Ue("container"),l=Ue("spacing"),d=Ue("radius"),f=Ue("shadow"),u=Ue("inset-shadow"),g=Ue("text-shadow"),p=Ue("drop-shadow"),b=Ue("blur"),x=Ue("perspective"),h=Ue("aspect"),v=Ue("ease"),k=Ue("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...y(),ne,te],R=()=>["auto","hidden","clip","visible","scroll"],E=()=>["auto","contain","none"],C=()=>[ne,te,l],A=()=>[Rn,"full","auto",...C()],O=()=>[sn,"none","subgrid",ne,te],U=()=>["auto",{span:["full",sn,ne,te]},sn,ne,te],M=()=>[sn,"auto",ne,te],B=()=>["auto","min","max","fr",ne,te],$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],F=()=>["auto",...C()],Z=()=>[Rn,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],D=()=>[e,ne,te],N=()=>[...y(),Yi,Gi,{position:[ne,te]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],G=()=>["auto","cover","contain",Ev,Cv,{size:[ne,te]}],xe=()=>[oo,nr,yn],W=()=>["","none","full",d,ne,te],Q=()=>["",fe,nr,yn],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"],P=()=>[fe,oo,Yi,Gi],Y=()=>["","none",b,ne,te],ue=()=>["none",fe,ne,te],V=()=>["none",fe,ne,te],ae=()=>[fe,ne,te],ce=()=>[Rn,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Kt],breakpoint:[Kt],color:[wv],container:[Kt],"drop-shadow":[Kt],ease:["in","out","in-out"],font:[Sv],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Kt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Kt],shadow:[Kt],spacing:["px",fe],text:[Kt],"text-shadow":[Kt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Rn,te,ne,h]}],container:["container"],columns:[{columns:[fe,te,ne,c]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"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:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[sn,"auto",ne,te]}],basis:[{basis:[Rn,"full","auto",c,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[fe,Rn,"auto","initial","none",te]}],grow:[{grow:["",fe,ne,te]}],shrink:[{shrink:["",fe,ne,te]}],order:[{order:[sn,"first","last","none",ne,te]}],"grid-cols":[{"grid-cols":O()}],"col-start-end":[{col:U()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":O()}],"row-start-end":[{row:U()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":B()}],"auto-rows":[{"auto-rows":B()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...$(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...$()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":$()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:F()}],mx:[{mx:F()}],my:[{my:F()}],ms:[{ms:F()}],me:[{me:F()}],mt:[{mt:F()}],mr:[{mr:F()}],mb:[{mb:F()}],ml:[{ml:F()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:Z()}],w:[{w:[c,"screen",...Z()]}],"min-w":[{"min-w":[c,"screen","none",...Z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...Z()]}],h:[{h:["screen","lh",...Z()]}],"min-h":[{"min-h":["screen","lh","none",...Z()]}],"max-h":[{"max-h":["screen","lh",...Z()]}],"font-size":[{text:["base",n,nr,yn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[s,ne,ao]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",oo,te]}],"font-family":[{font:[Av,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":[fe,"none",ne,ao]}],leading:[{leading:[a,...C()]}],"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:[fe,"from-font","auto",ne,yn]}],"text-decoration-color":[{decoration:D()}],"underline-offset":[{"underline-offset":[fe,"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:C()}],"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:N()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:G()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},sn,ne,te],radial:["",ne,te],conic:[sn,ne,te]},Iv,Nv]}],"bg-color":[{bg:D()}],"gradient-from-pos":[{from:xe()}],"gradient-via-pos":[{via:xe()}],"gradient-to-pos":[{to:xe()}],"gradient-from":[{from:D()}],"gradient-via":[{via:D()}],"gradient-to":[{to:D()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"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":[fe,ne,te]}],"outline-w":[{outline:["",fe,nr,yn]}],"outline-color":[{outline:D()}],shadow:[{shadow:["","none",f,Lr,Mr]}],"shadow-color":[{shadow:D()}],"inset-shadow":[{"inset-shadow":["none",u,Lr,Mr]}],"inset-shadow-color":[{"inset-shadow":D()}],"ring-w":[{ring:Q()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:D()}],"ring-offset-w":[{"ring-offset":[fe,yn]}],"ring-offset-color":[{"ring-offset":D()}],"inset-ring-w":[{"inset-ring":Q()}],"inset-ring-color":[{"inset-ring":D()}],"text-shadow":[{"text-shadow":["none",g,Lr,Mr]}],"text-shadow-color":[{"text-shadow":D()}],opacity:[{opacity:[fe,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":[fe]}],"mask-image-linear-from-pos":[{"mask-linear-from":P()}],"mask-image-linear-to-pos":[{"mask-linear-to":P()}],"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":P()}],"mask-image-t-to-pos":[{"mask-t-to":P()}],"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":P()}],"mask-image-r-to-pos":[{"mask-r-to":P()}],"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":P()}],"mask-image-b-to-pos":[{"mask-b-to":P()}],"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":P()}],"mask-image-l-to-pos":[{"mask-l-to":P()}],"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":P()}],"mask-image-x-to-pos":[{"mask-x-to":P()}],"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":P()}],"mask-image-y-to-pos":[{"mask-y-to":P()}],"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":P()}],"mask-image-radial-to-pos":[{"mask-radial-to":P()}],"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":y()}],"mask-image-conic-pos":[{"mask-conic":[fe]}],"mask-image-conic-from-pos":[{"mask-conic-from":P()}],"mask-image-conic-to-pos":[{"mask-conic-to":P()}],"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:N()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:G()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ne,te]}],filter:[{filter:["","none",ne,te]}],blur:[{blur:Y()}],brightness:[{brightness:[fe,ne,te]}],contrast:[{contrast:[fe,ne,te]}],"drop-shadow":[{"drop-shadow":["","none",p,Lr,Mr]}],"drop-shadow-color":[{"drop-shadow":D()}],grayscale:[{grayscale:["",fe,ne,te]}],"hue-rotate":[{"hue-rotate":[fe,ne,te]}],invert:[{invert:["",fe,ne,te]}],saturate:[{saturate:[fe,ne,te]}],sepia:[{sepia:["",fe,ne,te]}],"backdrop-filter":[{"backdrop-filter":["","none",ne,te]}],"backdrop-blur":[{"backdrop-blur":Y()}],"backdrop-brightness":[{"backdrop-brightness":[fe,ne,te]}],"backdrop-contrast":[{"backdrop-contrast":[fe,ne,te]}],"backdrop-grayscale":[{"backdrop-grayscale":["",fe,ne,te]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[fe,ne,te]}],"backdrop-invert":[{"backdrop-invert":["",fe,ne,te]}],"backdrop-opacity":[{"backdrop-opacity":[fe,ne,te]}],"backdrop-saturate":[{"backdrop-saturate":[fe,ne,te]}],"backdrop-sepia":[{"backdrop-sepia":["",fe,ne,te]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"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:[fe,"initial",ne,te]}],ease:[{ease:["linear","initial",v,ne,te]}],delay:[{delay:[fe,ne,te]}],animate:[{animate:["none",k,ne,te]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,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:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:ae()}],"skew-x":[{"skew-x":ae()}],"skew-y":[{"skew-y":ae()}],transform:[{transform:[ne,te,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ce()}],"translate-x":[{"translate-x":ce()}],"translate-y":[{"translate-y":ce()}],"translate-z":[{"translate-z":ce()}],"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":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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:[fe,nr,yn,ao]}],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"]}},Ov=mv(Rv);function L(...e){return Ov(Ul(e))}const Mv=ua("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?U0:"button";return r.jsx(i,{className:L(Mv({variant:t,size:n}),e),ref:a,...o})});X.displayName="Button";const Lv=ua("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 Xt({className:e,variant:t,...n}){return r.jsx("div",{className:L(Lv({variant:t}),e),...n})}const kt=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:L("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}));kt.displayName="Card";const gr=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:L("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:L("text-lg font-semibold leading-none tracking-tight",e),...t}));xr.displayName="CardTitle";const ed=m.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));ed.displayName="CardDescription";const Tt=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:L("p-6 pt-0",e),...t}));Tt.displayName="CardContent";const td=m.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:L("flex items-center p-6 pt-0",e),...t}));td.displayName="CardFooter";const Oe=m.forwardRef(({className:e,...t},n)=>r.jsx("input",{ref:n,className:L("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}));Oe.displayName="Input";const tt=m.forwardRef(({className:e,...t},n)=>r.jsx("label",{ref:n,className:L("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));tt.displayName="Label";var Dv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$v=Dv.reduce((e,t)=>{const n=zl(`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}},{}),zv="Separator",Qi="horizontal",Fv=["horizontal","vertical"],nd=m.forwardRef((e,t)=>{const{decorative:n,orientation:s=Qi,...o}=e,a=Uv(s)?s:Qi,c=n?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return r.jsx($v.div,{"data-orientation":a,...c,...o,ref:t})});nd.displayName=zv;function Uv(e){return Fv.includes(e)}var rd=nd;const ft=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...s},o)=>r.jsx(rd,{ref:o,decorative:n,orientation:t,className:L("shrink-0 bg-neutral-200 dark:bg-neutral-800",t==="horizontal"?"h-px w-full":"h-full w-px",e),...s}));ft.displayName=rd.displayName;function Re({className:e,...t}){return r.jsx("div",{className:L("animate-pulse rounded-md bg-neutral-100 dark:bg-neutral-800",e),...t})}function Ki(e,[t,n]){return Math.min(n,Math.max(t,e))}function ge(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o.defaultPrevented)return t?.(o)}}function Bv(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 mn(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,...b}=u,x=g?.[e]?.[l]||c,h=m.useMemo(()=>b,Object.values(b));return r.jsx(x.Provider,{value:h,children:p})};d.displayName=a+"Provider";function f(u,g){const p=g?.[e]?.[l]||c,b=m.useContext(p);if(b)return b;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,Vv(o,...t)]}function Vv(...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 Ji(e){const t=Wv(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(Zv);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 Wv(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Gv(o),c=qv(a,o.props);return o.type!==m.Fragment&&(c.ref=s?Zn(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 Hv=Symbol("radix.slottable");function Zv(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hv}function qv(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 Gv(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 ma(e){const t=e+"CollectionProvider",[n,s]=mn(t),[o,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:h,children:v}=x,k=_.useRef(null),w=_.useRef(new Map).current;return r.jsx(o,{scope:h,itemMap:w,collectionRef:k,children:v})};i.displayName=t;const c=e+"CollectionSlot",l=Ji(c),d=_.forwardRef((x,h)=>{const{scope:v,children:k}=x,w=a(c,v),y=Ce(h,w.collectionRef);return r.jsx(l,{ref:y,children:k})});d.displayName=c;const f=e+"CollectionItemSlot",u="data-radix-collection-item",g=Ji(f),p=_.forwardRef((x,h)=>{const{scope:v,children:k,...w}=x,y=_.useRef(null),j=Ce(h,y),R=a(f,v);return _.useEffect(()=>(R.itemMap.set(y,{ref:y,...w}),()=>void R.itemMap.delete(y))),r.jsx(g,{[u]:"",ref:j,children:k})});p.displayName=f;function b(x){const h=a(e+"CollectionConsumer",x);return _.useCallback(()=>{const k=h.collectionRef.current;if(!k)return[];const w=Array.from(k.querySelectorAll(`[${u}]`));return Array.from(h.itemMap.values()).sort((R,E)=>w.indexOf(R.ref.current)-w.indexOf(E.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:i,Slot:d,ItemSlot:p},b,s]}var Yv=m.createContext(void 0);function js(e){const t=m.useContext(Yv);return e||t||"ltr"}function Qv(e){const t=Kv(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(Xv);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 Kv(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=ty(o),c=ey(a,o.props);return o.type!==m.Fragment&&(c.ref=s?Zn(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 Jv=Symbol("radix.slottable");function Xv(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Jv}function ey(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 ty(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 ny=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pe=ny.reduce((e,t)=>{const n=Qv(`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 ry(e,t){e&&vs.flushSync(()=>e.dispatchEvent(t))}function an(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function sy(e,t=globalThis?.document){const n=an(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 oy="DismissableLayer",Po="dismissableLayer.update",ay="dismissableLayer.pointerDownOutside",iy="dismissableLayer.focusOutside",Xi,sd=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pa=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:c,...l}=e,d=m.useContext(sd),[f,u]=m.useState(null),g=f?.ownerDocument??globalThis?.document,[,p]=m.useState({}),b=Ce(t,E=>u(E)),x=Array.from(d.layers),[h]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=x.indexOf(h),k=f?x.indexOf(f):-1,w=d.layersWithOutsidePointerEventsDisabled.size>0,y=k>=v,j=dy(E=>{const C=E.target,A=[...d.branches].some(O=>O.contains(C));!y||A||(o?.(E),i?.(E),E.defaultPrevented||c?.())},g),R=uy(E=>{const C=E.target;[...d.branches].some(O=>O.contains(C))||(a?.(E),i?.(E),E.defaultPrevented||c?.())},g);return sy(E=>{k===d.layers.size-1&&(s?.(E),!E.defaultPrevented&&c&&(E.preventDefault(),c()))},g),m.useEffect(()=>{if(f)return n&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(Xi=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),ec(),()=>{n&&d.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Xi)}},[f,g,n,d]),m.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),ec())},[f,d]),m.useEffect(()=>{const E=()=>p({});return document.addEventListener(Po,E),()=>document.removeEventListener(Po,E)},[]),r.jsx(pe.div,{...l,ref:b,style:{pointerEvents:w?y?"auto":"none":void 0,...e.style},onFocusCapture:ge(e.onFocusCapture,R.onFocusCapture),onBlurCapture:ge(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:ge(e.onPointerDownCapture,j.onPointerDownCapture)})});pa.displayName=oy;var cy="DismissableLayerBranch",ly=m.forwardRef((e,t)=>{const n=m.useContext(sd),s=m.useRef(null),o=Ce(t,s);return m.useEffect(()=>{const a=s.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),r.jsx(pe.div,{...e,ref:o})});ly.displayName=cy;function dy(e,t=globalThis?.document){const n=an(e),s=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const a=c=>{if(c.target&&!s.current){let l=function(){od(ay,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 uy(e,t=globalThis?.document){const n=an(e),s=m.useRef(!1);return m.useEffect(()=>{const o=a=>{a.target&&!s.current&&od(iy,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 ec(){const e=new CustomEvent(Po);document.dispatchEvent(e)}function od(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?ry(o,a):o.dispatchEvent(a)}var io=0;function ad(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??tc()),document.body.insertAdjacentElement("beforeend",e[1]??tc()),io++,()=>{io===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),io--}},[])}function tc(){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 co="focusScope.autoFocusOnMount",lo="focusScope.autoFocusOnUnmount",nc={bubbles:!1,cancelable:!0},fy="FocusScope",ha=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[c,l]=m.useState(null),d=an(o),f=an(a),u=m.useRef(null),g=Ce(t,x=>l(x)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(s){let x=function(w){if(p.paused||!c)return;const y=w.target;c.contains(y)?u.current=y:on(u.current,{select:!0})},h=function(w){if(p.paused||!c)return;const y=w.relatedTarget;y!==null&&(c.contains(y)||on(u.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const j of w)j.removedNodes.length>0&&on(c)};document.addEventListener("focusin",x),document.addEventListener("focusout",h);const k=new MutationObserver(v);return c&&k.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",h),k.disconnect()}}},[s,c,p.paused]),m.useEffect(()=>{if(c){sc.add(p);const x=document.activeElement;if(!c.contains(x)){const v=new CustomEvent(co,nc);c.addEventListener(co,d),c.dispatchEvent(v),v.defaultPrevented||(my(vy(id(c)),{select:!0}),document.activeElement===x&&on(c))}return()=>{c.removeEventListener(co,d),setTimeout(()=>{const v=new CustomEvent(lo,nc);c.addEventListener(lo,f),c.dispatchEvent(v),v.defaultPrevented||on(x??document.body,{select:!0}),c.removeEventListener(lo,f),sc.remove(p)},0)}}},[c,d,f,p]);const b=m.useCallback(x=>{if(!n&&!s||p.paused)return;const h=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,v=document.activeElement;if(h&&v){const k=x.currentTarget,[w,y]=py(k);w&&y?!x.shiftKey&&v===y?(x.preventDefault(),n&&on(w,{select:!0})):x.shiftKey&&v===w&&(x.preventDefault(),n&&on(y,{select:!0})):v===k&&x.preventDefault()}},[n,s,p.paused]);return r.jsx(pe.div,{tabIndex:-1,...i,ref:g,onKeyDown:b})});ha.displayName=fy;function my(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(on(s,{select:t}),document.activeElement!==n)return}function py(e){const t=id(e),n=rc(t,e),s=rc(t.reverse(),e);return[n,s]}function id(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 rc(e,t){for(const n of e)if(!hy(n,{upTo:t}))return n}function hy(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 gy(e){return e instanceof HTMLInputElement&&"select"in e}function on(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&gy(e)&&t&&e.select()}}var sc=xy();function xy(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=oc(e,t),e.unshift(t)},remove(t){e=oc(e,t),e[0]?.resume()}}}function oc(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function vy(e){return e.filter(t=>t.tagName!=="A")}var Ye=globalThis?.document?m.useLayoutEffect:()=>{},yy=m[" useId ".trim().toString()]||(()=>{}),by=0;function Bt(e){const[t,n]=m.useState(yy());return Ye(()=>{n(s=>s??String(by++))},[e]),e||(t?`radix-${t}`:"")}const wy=["top","right","bottom","left"],cn=Math.min,vt=Math.max,is=Math.round,Dr=Math.floor,Vt=e=>({x:e,y:e}),ky={left:"right",right:"left",bottom:"top",top:"bottom"},_y={start:"end",end:"start"};function Ro(e,t,n){return vt(e,cn(t,n))}function en(e,t){return typeof e=="function"?e(t):e}function tn(e){return e.split("-")[0]}function Yn(e){return e.split("-")[1]}function ga(e){return e==="x"?"y":"x"}function xa(e){return e==="y"?"height":"width"}const jy=new Set(["top","bottom"]);function Ut(e){return jy.has(tn(e))?"y":"x"}function va(e){return ga(Ut(e))}function Sy(e,t,n){n===void 0&&(n=!1);const s=Yn(e),o=va(e),a=xa(o);let i=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=cs(i)),[i,cs(i)]}function Cy(e){const t=cs(e);return[Oo(e),t,Oo(t)]}function Oo(e){return e.replace(/start|end/g,t=>_y[t])}const ac=["left","right"],ic=["right","left"],Ny=["top","bottom"],Ay=["bottom","top"];function Ey(e,t,n){switch(e){case"top":case"bottom":return n?t?ic:ac:t?ac:ic;case"left":case"right":return t?Ny:Ay;default:return[]}}function Iy(e,t,n,s){const o=Yn(e);let a=Ey(tn(e),n==="start",s);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Oo)))),a}function cs(e){return e.replace(/left|right|bottom|top/g,t=>ky[t])}function Ty(e){return{top:0,right:0,bottom:0,left:0,...e}}function cd(e){return typeof e!="number"?Ty(e):{top:e,right:e,bottom:e,left:e}}function ls(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 cc(e,t,n){let{reference:s,floating:o}=e;const a=Ut(t),i=va(t),c=xa(i),l=tn(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(Yn(t)){case"start":p[i]-=g*(n&&d?-1:1);break;case"end":p[i]+=g*(n&&d?-1:1);break}return p}const Py=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}=cc(d,s,l),g=s,p={},b=0;for(let x=0;x<c.length;x++){const{name:h,fn:v}=c[x],{x:k,y:w,data:y,reset:j}=await v({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=w??u,p={...p,[h]:{...p[h],...y}},j&&b<=50&&(b++,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}=cc(d,g,l)),x=-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}=en(t,e),b=cd(p),h=c[g?u==="floating"?"reference":"floating":u],v=ls(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(h)))==null||n?h:h.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,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),y=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},j=ls(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:k,offsetParent:w,strategy:l}):k);return{top:(v.top-j.top+b.top)/y.y,bottom:(j.bottom-v.bottom+b.bottom)/y.y,left:(v.left-j.left+b.left)/y.x,right:(j.right-v.right+b.right)/y.x}}const Ry=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}=en(e,t)||{};if(d==null)return{};const u=cd(f),g={x:n,y:s},p=va(o),b=xa(p),x=await i.getDimensions(d),h=p==="y",v=h?"top":"left",k=h?"bottom":"right",w=h?"clientHeight":"clientWidth",y=a.reference[b]+a.reference[p]-g[p]-a.floating[b],j=g[p]-a.reference[p],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let E=R?R[w]:0;(!E||!await(i.isElement==null?void 0:i.isElement(R)))&&(E=c.floating[w]||a.floating[b]);const C=y/2-j/2,A=E/2-x[b]/2-1,O=cn(u[v],A),U=cn(u[k],A),M=O,B=E-x[b]-U,$=E/2-x[b]/2+C,q=Ro(M,$,B),F=!l.arrow&&Yn(o)!=null&&$!==q&&a.reference[b]/2-($<M?O:U)-x[b]/2<0,Z=F?$<M?$-M:$-B:0;return{[p]:g[p]+Z,data:{[p]:q,centerOffset:$-q-Z,...F&&{alignmentOffset:Z}},reset:F}}}),Oy=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:b="none",flipAlignment:x=!0,...h}=en(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=tn(o),k=Ut(c),w=tn(c)===c,y=await(l.isRTL==null?void 0:l.isRTL(d.floating)),j=g||(w||!x?[cs(c)]:Cy(c)),R=b!=="none";!g&&R&&j.push(...Iy(c,x,b,y));const E=[c,...j],C=await vr(t,h),A=[];let O=((s=a.flip)==null?void 0:s.overflows)||[];if(f&&A.push(C[v]),u){const $=Sy(o,i,y);A.push(C[$[0]],C[$[1]])}if(O=[...O,{placement:o,overflows:A}],!A.every($=>$<=0)){var U,M;const $=(((U=a.flip)==null?void 0:U.index)||0)+1,q=E[$];if(q&&(!(u==="alignment"?k!==Ut(q):!1)||O.every(D=>Ut(D.placement)===k?D.overflows[0]>0:!0)))return{data:{index:$,overflows:O},reset:{placement:q}};let F=(M=O.filter(Z=>Z.overflows[0]<=0).sort((Z,D)=>Z.overflows[1]-D.overflows[1])[0])==null?void 0:M.placement;if(!F)switch(p){case"bestFit":{var B;const Z=(B=O.filter(D=>{if(R){const N=Ut(D.placement);return N===k||N==="y"}return!0}).map(D=>[D.placement,D.overflows.filter(N=>N>0).reduce((N,I)=>N+I,0)]).sort((D,N)=>D[1]-N[1])[0])==null?void 0:B[0];Z&&(F=Z);break}case"initialPlacement":F=c;break}if(o!==F)return{reset:{placement:F}}}return{}}}};function lc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function dc(e){return wy.some(t=>e[t]>=0)}const My=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:s="referenceHidden",...o}=en(e,t);switch(s){case"referenceHidden":{const a=await vr(t,{...o,elementContext:"reference"}),i=lc(a,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:dc(i)}}}case"escaped":{const a=await vr(t,{...o,altBoundary:!0}),i=lc(a,n.floating);return{data:{escapedOffsets:i,escaped:dc(i)}}}default:return{}}}}},ld=new Set(["left","top"]);async function Ly(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),i=tn(n),c=Yn(n),l=Ut(n)==="y",d=ld.has(i)?-1:1,f=a&&l?-1:1,u=en(t,e);let{mainAxis:g,crossAxis:p,alignmentAxis:b}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof b=="number"&&(p=c==="end"?b*-1:b),l?{x:p*f,y:g*d}:{x:g*d,y:p*f}}const Dy=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 Ly(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}}}}},$y=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:h=>{let{x:v,y:k}=h;return{x:v,y:k}}},...l}=en(e,t),d={x:n,y:s},f=await vr(t,l),u=Ut(tn(o)),g=ga(u);let p=d[g],b=d[u];if(a){const h=g==="y"?"top":"left",v=g==="y"?"bottom":"right",k=p+f[h],w=p-f[v];p=Ro(k,p,w)}if(i){const h=u==="y"?"top":"left",v=u==="y"?"bottom":"right",k=b+f[h],w=b-f[v];b=Ro(k,b,w)}const x=c.fn({...t,[g]:p,[u]:b});return{...x,data:{x:x.x-n,y:x.y-s,enabled:{[g]:a,[u]:i}}}}}},zy=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}=en(e,t),f={x:n,y:s},u=Ut(o),g=ga(u);let p=f[g],b=f[u];const x=en(c,t),h=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const w=g==="y"?"height":"width",y=a.reference[g]-a.floating[w]+h.mainAxis,j=a.reference[g]+a.reference[w]-h.mainAxis;p<y?p=y:p>j&&(p=j)}if(d){var v,k;const w=g==="y"?"width":"height",y=ld.has(tn(o)),j=a.reference[u]-a.floating[w]+(y&&((v=i.offset)==null?void 0:v[u])||0)+(y?0:h.crossAxis),R=a.reference[u]+a.reference[w]+(y?0:((k=i.offset)==null?void 0:k[u])||0)-(y?h.crossAxis:0);b<j?b=j:b>R&&(b=R)}return{[g]:p,[u]:b}}}},Fy=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}=en(e,t),f=await vr(t,d),u=tn(o),g=Yn(o),p=Ut(o)==="y",{width:b,height:x}=a.floating;let h,v;u==="top"||u==="bottom"?(h=u,v=g===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(v=u,h=g==="end"?"top":"bottom");const k=x-f.top-f.bottom,w=b-f.left-f.right,y=cn(x-f[h],k),j=cn(b-f[v],w),R=!t.middlewareData.shift;let E=y,C=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(C=w),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(E=k),R&&!g){const O=vt(f.left,0),U=vt(f.right,0),M=vt(f.top,0),B=vt(f.bottom,0);p?C=b-2*(O!==0||U!==0?O+U:vt(f.left,f.right)):E=x-2*(M!==0||B!==0?M+B:vt(f.top,f.bottom))}await l({...t,availableWidth:C,availableHeight:E});const A=await i.getDimensions(c.floating);return b!==A.width||x!==A.height?{reset:{rects:!0}}:{}}}};function Ss(){return typeof window<"u"}function Qn(e){return dd(e)?(e.nodeName||"").toLowerCase():"#document"}function yt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Zt(e){var t;return(t=(dd(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function dd(e){return Ss()?e instanceof Node||e instanceof yt(e).Node:!1}function Pt(e){return Ss()?e instanceof Element||e instanceof yt(e).Element:!1}function Ht(e){return Ss()?e instanceof HTMLElement||e instanceof yt(e).HTMLElement:!1}function uc(e){return!Ss()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof yt(e).ShadowRoot}const Uy=new Set(["inline","contents"]);function Nr(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Rt(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!Uy.has(o)}const By=new Set(["table","td","th"]);function Vy(e){return By.has(Qn(e))}const Wy=[":popover-open",":modal"];function Cs(e){return Wy.some(t=>{try{return e.matches(t)}catch{return!1}})}const Hy=["transform","translate","scale","rotate","perspective"],Zy=["transform","translate","scale","rotate","perspective","filter"],qy=["paint","layout","strict","content"];function ya(e){const t=ba(),n=Pt(e)?Rt(e):e;return Hy.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)||Zy.some(s=>(n.willChange||"").includes(s))||qy.some(s=>(n.contain||"").includes(s))}function Gy(e){let t=ln(e);for(;Ht(t)&&!Bn(t);){if(ya(t))return t;if(Cs(t))return null;t=ln(t)}return null}function ba(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Yy=new Set(["html","body","#document"]);function Bn(e){return Yy.has(Qn(e))}function Rt(e){return yt(e).getComputedStyle(e)}function Ns(e){return Pt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ln(e){if(Qn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||uc(e)&&e.host||Zt(e);return uc(t)?t.host:t}function ud(e){const t=ln(e);return Bn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ht(t)&&Nr(t)?t:ud(t)}function yr(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ud(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),i=yt(o);if(a){const c=Mo(i);return t.concat(i,i.visualViewport||[],Nr(o)?o:[],c&&n?yr(c):[])}return t.concat(o,yr(o,[],n))}function Mo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function fd(e){const t=Rt(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Ht(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:s,c=is(n)!==a||is(s)!==i;return c&&(n=a,s=i),{width:n,height:s,$:c}}function wa(e){return Pt(e)?e:e.contextElement}function zn(e){const t=wa(e);if(!Ht(t))return Vt(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=fd(t);let i=(a?is(n.width):n.width)/s,c=(a?is(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const Qy=Vt(0);function md(e){const t=yt(e);return!ba()||!t.visualViewport?Qy:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ky(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==yt(e)?!1:t}function kn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=wa(e);let i=Vt(1);t&&(s?Pt(s)&&(i=zn(s)):i=zn(e));const c=Ky(a,n,s)?md(a):Vt(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=yt(a),p=s&&Pt(s)?yt(s):s;let b=g,x=Mo(b);for(;x&&s&&p!==b;){const h=zn(x),v=x.getBoundingClientRect(),k=Rt(x),w=v.left+(x.clientLeft+parseFloat(k.paddingLeft))*h.x,y=v.top+(x.clientTop+parseFloat(k.paddingTop))*h.y;l*=h.x,d*=h.y,f*=h.x,u*=h.y,l+=w,d+=y,b=yt(x),x=Mo(b)}}return ls({width:f,height:u,x:l,y:d})}function As(e,t){const n=Ns(e).scrollLeft;return t?t.left+n:kn(Zt(e)).left+n}function pd(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-As(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function Jy(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",i=Zt(s),c=t?Cs(t.floating):!1;if(s===i||c&&a)return n;let l={scrollLeft:0,scrollTop:0},d=Vt(1);const f=Vt(0),u=Ht(s);if((u||!u&&!a)&&((Qn(s)!=="body"||Nr(i))&&(l=Ns(s)),Ht(s))){const p=kn(s);d=zn(s),f.x=p.x+s.clientLeft,f.y=p.y+s.clientTop}const g=i&&!u&&!a?pd(i,l):Vt(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 Xy(e){return Array.from(e.getClientRects())}function eb(e){const t=Zt(e),n=Ns(e),s=e.ownerDocument.body,o=vt(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=vt(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+As(e);const c=-n.scrollTop;return Rt(s).direction==="rtl"&&(i+=vt(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:i,y:c}}const fc=25;function tb(e,t){const n=yt(e),s=Zt(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=ba();(!f||f&&t==="fixed")&&(c=o.offsetLeft,l=o.offsetTop)}const d=As(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,b=Math.abs(s.clientWidth-u.clientWidth-p);b<=fc&&(a-=b)}else d<=fc&&(a+=d);return{width:a,height:i,x:c,y:l}}const nb=new Set(["absolute","fixed"]);function rb(e,t){const n=kn(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=Ht(e)?zn(e):Vt(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 mc(e,t,n){let s;if(t==="viewport")s=tb(e,n);else if(t==="document")s=eb(Zt(e));else if(Pt(t))s=rb(t,n);else{const o=md(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ls(s)}function hd(e,t){const n=ln(e);return n===t||!Pt(n)||Bn(n)?!1:Rt(n).position==="fixed"||hd(n,t)}function sb(e,t){const n=t.get(e);if(n)return n;let s=yr(e,[],!1).filter(c=>Pt(c)&&Qn(c)!=="body"),o=null;const a=Rt(e).position==="fixed";let i=a?ln(e):e;for(;Pt(i)&&!Bn(i);){const c=Rt(i),l=ya(i);!l&&c.position==="fixed"&&(o=null),(a?!l&&!o:!l&&c.position==="static"&&!!o&&nb.has(o.position)||Nr(i)&&!l&&hd(e,i))?s=s.filter(f=>f!==i):o=c,i=ln(i)}return t.set(e,s),s}function ob(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const i=[...n==="clippingAncestors"?Cs(t)?[]:sb(t,this._c):[].concat(n),s],c=i[0],l=i.reduce((d,f)=>{const u=mc(t,f,o);return d.top=vt(u.top,d.top),d.right=cn(u.right,d.right),d.bottom=cn(u.bottom,d.bottom),d.left=vt(u.left,d.left),d},mc(t,c,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ab(e){const{width:t,height:n}=fd(e);return{width:t,height:n}}function ib(e,t,n){const s=Ht(t),o=Zt(t),a=n==="fixed",i=kn(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const l=Vt(0);function d(){l.x=As(o)}if(s||!s&&!a)if((Qn(t)!=="body"||Nr(o))&&(c=Ns(t)),s){const p=kn(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?pd(o,c):Vt(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 uo(e){return Rt(e).position==="static"}function pc(e,t){if(!Ht(e)||Rt(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Zt(e)===n&&(n=n.ownerDocument.body),n}function gd(e,t){const n=yt(e);if(Cs(e))return n;if(!Ht(e)){let o=ln(e);for(;o&&!Bn(o);){if(Pt(o)&&!uo(o))return o;o=ln(o)}return n}let s=pc(e,t);for(;s&&Vy(s)&&uo(s);)s=pc(s,t);return s&&Bn(s)&&uo(s)&&!ya(s)?n:s||Gy(e)||n}const cb=async function(e){const t=this.getOffsetParent||gd,n=this.getDimensions,s=await n(e.floating);return{reference:ib(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function lb(e){return Rt(e).direction==="rtl"}const db={convertOffsetParentRelativeRectToViewportRelativeRect:Jy,getDocumentElement:Zt,getClippingRect:ob,getOffsetParent:gd,getElementRects:cb,getClientRects:Xy,getDimensions:ab,getScale:zn,isElement:Pt,isRTL:lb};function xd(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ub(e,t){let n=null,s;const o=Zt(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 b=Dr(u),x=Dr(o.clientWidth-(f+g)),h=Dr(o.clientHeight-(u+p)),v=Dr(f),w={rootMargin:-b+"px "+-x+"px "+-h+"px "+-v+"px",threshold:vt(0,cn(1,l))||1};let y=!0;function j(R){const E=R[0].intersectionRatio;if(E!==l){if(!y)return i();E?i(!1,E):s=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!xd(d,e.getBoundingClientRect())&&i(),y=!1}try{n=new IntersectionObserver(j,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(j,w)}n.observe(e)}return i(!0),a}function fb(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=wa(e),f=o||a?[...d?yr(d):[],...yr(t)]:[];f.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const u=d&&c?ub(d,n):null;let g=-1,p=null;i&&(p=new ResizeObserver(v=>{let[k]=v;k&&k.target===d&&p&&(p.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var w;(w=p)==null||w.observe(t)})),n()}),d&&!l&&p.observe(d),p.observe(t));let b,x=l?kn(e):null;l&&h();function h(){const v=kn(e);x&&!xd(x,v)&&n(),x=v,b=requestAnimationFrame(h)}return n(),()=>{var v;f.forEach(k=>{o&&k.removeEventListener("scroll",n),a&&k.removeEventListener("resize",n)}),u?.(),(v=p)==null||v.disconnect(),p=null,l&&cancelAnimationFrame(b)}}const mb=Dy,pb=$y,hb=Oy,gb=Fy,xb=My,hc=Ry,vb=zy,yb=(e,t,n)=>{const s=new Map,o={platform:db,...n},a={...o.platform,_c:s};return Py(e,t,{...o,platform:a})};var bb=typeof document<"u",wb=function(){},Yr=bb?_.useLayoutEffect:wb;function ds(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(!ds(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)&&!ds(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function vd(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gc(e,t){const n=vd(e);return Math.round(t*n)/n}function fo(e){const t=m.useRef(e);return Yr(()=>{t.current=e}),t}function kb(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);ds(g,s)||p(s);const[b,x]=m.useState(null),[h,v]=m.useState(null),k=m.useCallback(D=>{D!==R.current&&(R.current=D,x(D))},[]),w=m.useCallback(D=>{D!==E.current&&(E.current=D,v(D))},[]),y=a||b,j=i||h,R=m.useRef(null),E=m.useRef(null),C=m.useRef(f),A=l!=null,O=fo(l),U=fo(o),M=fo(d),B=m.useCallback(()=>{if(!R.current||!E.current)return;const D={placement:t,strategy:n,middleware:g};U.current&&(D.platform=U.current),yb(R.current,E.current,D).then(N=>{const I={...N,isPositioned:M.current!==!1};$.current&&!ds(C.current,I)&&(C.current=I,vs.flushSync(()=>{u(I)}))})},[g,t,n,U,M]);Yr(()=>{d===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,u(D=>({...D,isPositioned:!1})))},[d]);const $=m.useRef(!1);Yr(()=>($.current=!0,()=>{$.current=!1}),[]),Yr(()=>{if(y&&(R.current=y),j&&(E.current=j),y&&j){if(O.current)return O.current(y,j,B);B()}},[y,j,B,O,A]);const q=m.useMemo(()=>({reference:R,floating:E,setReference:k,setFloating:w}),[k,w]),F=m.useMemo(()=>({reference:y,floating:j}),[y,j]),Z=m.useMemo(()=>{const D={position:n,left:0,top:0};if(!F.floating)return D;const N=gc(F.floating,f.x),I=gc(F.floating,f.y);return c?{...D,transform:"translate("+N+"px, "+I+"px)",...vd(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:I}},[n,c,F.floating,f.x,f.y]);return m.useMemo(()=>({...f,update:B,refs:q,elements:F,floatingStyles:Z}),[f,B,q,F,Z])}const _b=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?hc({element:s.current,padding:o}).fn(n):{}:s?hc({element:s,padding:o}).fn(n):{}}}},jb=(e,t)=>({...mb(e),options:[e,t]}),Sb=(e,t)=>({...pb(e),options:[e,t]}),Cb=(e,t)=>({...vb(e),options:[e,t]}),Nb=(e,t)=>({...hb(e),options:[e,t]}),Ab=(e,t)=>({...gb(e),options:[e,t]}),Eb=(e,t)=>({...xb(e),options:[e,t]}),Ib=(e,t)=>({..._b(e),options:[e,t]});var Tb="Arrow",yd=m.forwardRef((e,t)=>{const{children:n,width:s=10,height:o=5,...a}=e;return r.jsx(pe.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"})})});yd.displayName=Tb;var Pb=yd;function Rb(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 ka="Popper",[bd,wd]=mn(ka),[Ob,kd]=bd(ka),_d=e=>{const{__scopePopper:t,children:n}=e,[s,o]=m.useState(null);return r.jsx(Ob,{scope:t,anchor:s,onAnchorChange:o,children:n})};_d.displayName=ka;var jd="PopperAnchor",Sd=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...o}=e,a=kd(jd,n),i=m.useRef(null),c=Ce(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(pe.div,{...o,ref:c})});Sd.displayName=jd;var _a="PopperContent",[Mb,Lb]=bd(_a),Cd=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:b,...x}=e,h=kd(_a,n),[v,k]=m.useState(null),w=Ce(t,P=>k(P)),[y,j]=m.useState(null),R=Rb(y),E=R?.width??0,C=R?.height??0,A=s+(a!=="center"?"-"+a:""),O=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},U=Array.isArray(d)?d:[d],M=U.length>0,B={padding:O,boundary:U.filter($b),altBoundary:M},{refs:$,floatingStyles:q,placement:F,isPositioned:Z,middlewareData:D}=kb({strategy:"fixed",placement:A,whileElementsMounted:(...P)=>fb(...P,{animationFrame:p==="always"}),elements:{reference:h.anchor},middleware:[jb({mainAxis:o+C,alignmentAxis:i}),l&&Sb({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Cb():void 0,...B}),l&&Nb({...B}),Ab({...B,apply:({elements:P,rects:Y,availableWidth:ue,availableHeight:V})=>{const{width:ae,height:ce}=Y.reference,we=P.floating.style;we.setProperty("--radix-popper-available-width",`${ue}px`),we.setProperty("--radix-popper-available-height",`${V}px`),we.setProperty("--radix-popper-anchor-width",`${ae}px`),we.setProperty("--radix-popper-anchor-height",`${ce}px`)}}),y&&Ib({element:y,padding:c}),zb({arrowWidth:E,arrowHeight:C}),g&&Eb({strategy:"referenceHidden",...B})]}),[N,I]=Ed(F),G=an(b);Ye(()=>{Z&&G?.()},[Z,G]);const xe=D.arrow?.x,W=D.arrow?.y,Q=D.arrow?.centerOffset!==0,[K,le]=m.useState();return Ye(()=>{v&&le(window.getComputedStyle(v).zIndex)},[v]),r.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...q,transform:Z?q.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(Mb,{scope:n,placedSide:N,onArrowChange:j,arrowX:xe,arrowY:W,shouldHideArrow:Q,children:r.jsx(pe.div,{"data-side":N,"data-align":I,...x,ref:w,style:{...x.style,animation:Z?void 0:"none"}})})})});Cd.displayName=_a;var Nd="PopperArrow",Db={top:"bottom",right:"left",bottom:"top",left:"right"},Ad=m.forwardRef(function(t,n){const{__scopePopper:s,...o}=t,a=Lb(Nd,s),i=Db[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(Pb,{...o,ref:n,style:{...o.style,display:"block"}})})});Ad.displayName=Nd;function $b(e){return e!==null}var zb=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]=Ed(n),u={start:"0%",center:"50%",end:"100%"}[f],g=(o.arrow?.x??0)+c/2,p=(o.arrow?.y??0)+l/2;let b="",x="";return d==="bottom"?(b=i?u:`${g}px`,x=`${-l}px`):d==="top"?(b=i?u:`${g}px`,x=`${s.floating.height+l}px`):d==="right"?(b=`${-l}px`,x=i?u:`${p}px`):d==="left"&&(b=`${s.floating.width+l}px`,x=i?u:`${p}px`),{data:{x:b,y:x}}}});function Ed(e){const[t,n="center"]=e.split("-");return[t,n]}var Fb=_d,Ub=Sd,Bb=Cd,Vb=Ad,Wb="Portal",ja=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?Yo.createPortal(r.jsx(pe.div,{...s,ref:t}),i):null});ja.displayName=Wb;function Hb(e){const t=Zb(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(Gb);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 Zb(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Qb(o),c=Yb(a,o.props);return o.type!==m.Fragment&&(c.ref=s?Zn(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 qb=Symbol("radix.slottable");function Gb(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qb}function Yb(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 Qb(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 Kb=m[" useInsertionEffect ".trim().toString()]||Ye;function dn({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[o,a,i]=Jb({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=Xb(f)?f(e):f;u!==e&&i.current?.(u)}else a(f)},[c,e,a,i]);return[l,d]}function Jb({defaultProp:e,onChange:t}){const[n,s]=m.useState(e),o=m.useRef(n),a=m.useRef(t);return Kb(()=>{a.current=t},[t]),m.useEffect(()=>{o.current!==n&&(a.current?.(n),o.current=n)},[n,o]),[n,s,a]}function Xb(e){return typeof e=="function"}function ew(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 Id=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"}),tw="VisuallyHidden",nw=m.forwardRef((e,t)=>r.jsx(pe.span,{...e,ref:t,style:{...Id,...e.style}}));nw.displayName=tw;var rw=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},On=new WeakMap,$r=new WeakMap,zr={},mo=0,Td=function(e){return e&&(e.host||Td(e.parentNode))},sw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Td(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})},ow=function(e,t,n,s){var o=sw(t,Array.isArray(e)?e:[e]);zr[n]||(zr[n]=new WeakMap);var a=zr[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),b=p!==null&&p!=="false",x=(On.get(g)||0)+1,h=(a.get(g)||0)+1;On.set(g,x),a.set(g,h),i.push(g),x===1&&b&&$r.set(g,!0),h===1&&g.setAttribute(n,"true"),b||g.setAttribute(s,"true")}catch(v){console.error("aria-hidden: cannot operate on ",g,v)}})};return f(t),c.clear(),mo++,function(){i.forEach(function(u){var g=On.get(u)-1,p=a.get(u)-1;On.set(u,g),a.set(u,p),g||($r.has(u)||u.removeAttribute(s),$r.delete(u)),p||u.removeAttribute(n)}),mo--,mo||(On=new WeakMap,On=new WeakMap,$r=new WeakMap,zr={})}},Pd=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),o=rw(e);return o?(s.push.apply(s,Array.from(o.querySelectorAll("[aria-live], script"))),ow(s,o,n,"aria-hidden")):function(){return null}},Ft=function(){return Ft=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},Ft.apply(this,arguments)};function Rd(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 aw(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 Qr="right-scroll-bar-position",Kr="width-before-scroll-bar",iw="with-scroll-bars-hidden",cw="--removed-body-scroll-bar-size";function po(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function lw(e,t){var n=_.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 dw=typeof window<"u"?m.useLayoutEffect:m.useEffect,xc=new WeakMap;function uw(e,t){var n=lw(null,function(s){return e.forEach(function(o){return po(o,s)})});return dw(function(){var s=xc.get(n);if(s){var o=new Set(s),a=new Set(e),i=n.current;o.forEach(function(c){a.has(c)||po(c,null)}),a.forEach(function(c){o.has(c)||po(c,i)})}xc.set(n,e)},[e]),n}function fw(e){return e}function mw(e,t){t===void 0&&(t=fw);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 pw(e){e===void 0&&(e={});var t=mw(null);return t.options=Ft({async:!0,ssr:!1},e),t}var Od=function(e){var t=e.sideCar,n=Rd(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,Ft({},n))};Od.isSideCarExport=!0;function hw(e,t){return e.useMedium(t),Od}var Md=pw(),ho=function(){},Es=m.forwardRef(function(e,t){var n=m.useRef(null),s=m.useState({onScrollCapture:ho,onWheelCapture:ho,onTouchMoveCapture:ho}),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,b=e.noIsolation,x=e.inert,h=e.allowPinchZoom,v=e.as,k=v===void 0?"div":v,w=e.gapMode,y=Rd(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=g,R=uw([n,t]),E=Ft(Ft({},y),o);return m.createElement(m.Fragment,null,f&&m.createElement(j,{sideCar:Md,removeScrollBar:d,shards:u,noRelative:p,noIsolation:b,inert:x,setCallbacks:a,allowPinchZoom:!!h,lockRef:n,gapMode:w}),i?m.cloneElement(m.Children.only(c),Ft(Ft({},E),{ref:R})):m.createElement(k,Ft({},E,{className:l,ref:R}),c))});Es.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Es.classNames={fullWidth:Kr,zeroRight:Qr};var gw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function xw(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=gw();return t&&e.setAttribute("nonce",t),e}function vw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function yw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var bw=function(){var e=0,t=null;return{add:function(n){e==0&&(t=xw())&&(vw(t,n),yw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},ww=function(){var e=bw();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Ld=function(){var e=ww(),t=function(n){var s=n.styles,o=n.dynamic;return e(s,o),null};return t},kw={left:0,top:0,right:0,gap:0},go=function(e){return parseInt(e||"",10)||0},_w=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[go(n),go(s),go(o)]},jw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return kw;var t=_w(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])}},Sw=Ld(),Fn="data-scroll-locked",Cw=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(iw,` {
|
|
41
|
-
overflow: hidden `).concat(s,`;
|
|
42
|
-
padding-right: `).concat(c,"px ").concat(s,`;
|
|
43
|
-
}
|
|
44
|
-
body[`).concat(Fn,`] {
|
|
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(Qr,` {
|
|
58
|
-
right: `).concat(c,"px ").concat(s,`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.`).concat(Kr,` {
|
|
62
|
-
margin-right: `).concat(c,"px ").concat(s,`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.`).concat(Qr," .").concat(Qr,` {
|
|
66
|
-
right: 0 `).concat(s,`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.`).concat(Kr," .").concat(Kr,` {
|
|
70
|
-
margin-right: 0 `).concat(s,`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
body[`).concat(Fn,`] {
|
|
74
|
-
`).concat(cw,": ").concat(c,`px;
|
|
75
|
-
}
|
|
76
|
-
`)},vc=function(){var e=parseInt(document.body.getAttribute(Fn)||"0",10);return isFinite(e)?e:0},Nw=function(){m.useEffect(function(){return document.body.setAttribute(Fn,(vc()+1).toString()),function(){var e=vc()-1;e<=0?document.body.removeAttribute(Fn):document.body.setAttribute(Fn,e.toString())}},[])},Aw=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,o=s===void 0?"margin":s;Nw();var a=m.useMemo(function(){return jw(o)},[o]);return m.createElement(Sw,{styles:Cw(a,!t,o,n?"":"!important")})},Lo=!1;if(typeof window<"u")try{var Fr=Object.defineProperty({},"passive",{get:function(){return Lo=!0,!0}});window.addEventListener("test",Fr,Fr),window.removeEventListener("test",Fr,Fr)}catch{Lo=!1}var Mn=Lo?{passive:!1}:!1,Ew=function(e){return e.tagName==="TEXTAREA"},Dd=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ew(e)&&n[t]==="visible")},Iw=function(e){return Dd(e,"overflowY")},Tw=function(e){return Dd(e,"overflowX")},yc=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var o=$d(e,s);if(o){var a=zd(e,s),i=a[1],c=a[2];if(i>c)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},Pw=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Rw=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},$d=function(e,t){return e==="v"?Iw(t):Tw(t)},zd=function(e,t){return e==="v"?Pw(t):Rw(t)},Ow=function(e,t){return e==="h"&&t==="rtl"?-1:1},Mw=function(e,t,n,s,o){var a=Ow(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=zd(e,c),b=p[0],x=p[1],h=p[2],v=x-h-a*b;(b||v)&&$d(e,c)&&(u+=v,g+=b);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]},bc=function(e){return[e.deltaX,e.deltaY]},wc=function(e){return e&&"current"in e?e.current:e},Lw=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Dw=function(e){return`
|
|
77
|
-
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
78
|
-
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
79
|
-
`)},$w=0,Ln=[];function zw(e){var t=m.useRef([]),n=m.useRef([0,0]),s=m.useRef(),o=m.useState($w++)[0],a=m.useState(Ld)[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 x=aw([e.lockRef.current],(e.shards||[]).map(wc),!0).filter(Boolean);return x.forEach(function(h){return h.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),x.forEach(function(h){return h.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var c=m.useCallback(function(x,h){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var v=Ur(x),k=n.current,w="deltaX"in x?x.deltaX:k[0]-v[0],y="deltaY"in x?x.deltaY:k[1]-v[1],j,R=x.target,E=Math.abs(w)>Math.abs(y)?"h":"v";if("touches"in x&&E==="h"&&R.type==="range")return!1;var C=window.getSelection(),A=C&&C.anchorNode,O=A?A===R||A.contains(R):!1;if(O)return!1;var U=yc(E,R);if(!U)return!0;if(U?j=E:(j=E==="v"?"h":"v",U=yc(E,R)),!U)return!1;if(!s.current&&"changedTouches"in x&&(w||y)&&(s.current=j),!j)return!0;var M=s.current||j;return Mw(M,h,x,M==="h"?w:y)},[]),l=m.useCallback(function(x){var h=x;if(!(!Ln.length||Ln[Ln.length-1]!==a)){var v="deltaY"in h?bc(h):Ur(h),k=t.current.filter(function(j){return j.name===h.type&&(j.target===h.target||h.target===j.shadowParent)&&Lw(j.delta,v)})[0];if(k&&k.should){h.cancelable&&h.preventDefault();return}if(!k){var w=(i.current.shards||[]).map(wc).filter(Boolean).filter(function(j){return j.contains(h.target)}),y=w.length>0?c(h,w[0]):!i.current.noIsolation;y&&h.cancelable&&h.preventDefault()}}},[]),d=m.useCallback(function(x,h,v,k){var w={name:x,delta:h,target:v,should:k,shadowParent:Fw(v)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(y){return y!==w})},1)},[]),f=m.useCallback(function(x){n.current=Ur(x),s.current=void 0},[]),u=m.useCallback(function(x){d(x.type,bc(x),x.target,c(x,e.lockRef.current))},[]),g=m.useCallback(function(x){d(x.type,Ur(x),x.target,c(x,e.lockRef.current))},[]);m.useEffect(function(){return Ln.push(a),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:g}),document.addEventListener("wheel",l,Mn),document.addEventListener("touchmove",l,Mn),document.addEventListener("touchstart",f,Mn),function(){Ln=Ln.filter(function(x){return x!==a}),document.removeEventListener("wheel",l,Mn),document.removeEventListener("touchmove",l,Mn),document.removeEventListener("touchstart",f,Mn)}},[]);var p=e.removeScrollBar,b=e.inert;return m.createElement(m.Fragment,null,b?m.createElement(a,{styles:Dw(o)}):null,p?m.createElement(Aw,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Fw(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Uw=hw(Md,zw);var Sa=m.forwardRef(function(e,t){return m.createElement(Es,Ft({},e,{ref:t,sideCar:Uw}))});Sa.classNames=Es.classNames;var Bw=[" ","Enter","ArrowUp","ArrowDown"],Vw=[" ","Enter"],_n="Select",[Is,Ts,Ww]=ma(_n),[Kn]=mn(_n,[Ww,wd]),Ps=wd(),[Hw,pn]=Kn(_n),[Zw,qw]=Kn(_n),Fd=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:b}=e,x=Ps(t),[h,v]=m.useState(null),[k,w]=m.useState(null),[y,j]=m.useState(!1),R=js(d),[E,C]=dn({prop:s,defaultProp:o??!1,onChange:a,caller:_n}),[A,O]=dn({prop:i,defaultProp:c,onChange:l,caller:_n}),U=m.useRef(null),M=h?b||!!h.closest("form"):!0,[B,$]=m.useState(new Set),q=Array.from(B).map(F=>F.props.value).join(";");return r.jsx(Fb,{...x,children:r.jsxs(Hw,{required:p,scope:t,trigger:h,onTriggerChange:v,valueNode:k,onValueNodeChange:w,valueNodeHasChildren:y,onValueNodeHasChildrenChange:j,contentId:Bt(),value:A,onValueChange:O,open:E,onOpenChange:C,dir:R,triggerPointerDownPosRef:U,disabled:g,children:[r.jsx(Is.Provider,{scope:t,children:r.jsx(Zw,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(F=>{$(Z=>new Set(Z).add(F))},[]),onNativeOptionRemove:m.useCallback(F=>{$(Z=>{const D=new Set(Z);return D.delete(F),D})},[]),children:n})}),M?r.jsxs(au,{"aria-hidden":!0,required:p,tabIndex:-1,name:f,autoComplete:u,value:A,onChange:F=>O(F.target.value),disabled:g,form:b,children:[A===void 0?r.jsx("option",{value:""}):null,Array.from(B)]},q):null]})})};Fd.displayName=_n;var Ud="SelectTrigger",Bd=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...o}=e,a=Ps(n),i=pn(Ud,n),c=i.disabled||s,l=Ce(t,i.onTriggerChange),d=Ts(n),f=m.useRef("touch"),[u,g,p]=cu(x=>{const h=d().filter(w=>!w.disabled),v=h.find(w=>w.value===i.value),k=lu(h,x,v);k!==void 0&&i.onValueChange(k.value)}),b=x=>{c||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return r.jsx(Ub,{asChild:!0,...a,children:r.jsx(pe.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":iu(i.value)?"":void 0,...o,ref:l,onClick:ge(o.onClick,x=>{x.currentTarget.focus(),f.current!=="mouse"&&b(x)}),onPointerDown:ge(o.onPointerDown,x=>{f.current=x.pointerType;const h=x.target;h.hasPointerCapture(x.pointerId)&&h.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(b(x),x.preventDefault())}),onKeyDown:ge(o.onKeyDown,x=>{const h=u.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&g(x.key),!(h&&x.key===" ")&&Bw.includes(x.key)&&(b(),x.preventDefault())})})})});Bd.displayName=Ud;var Vd="SelectValue",Wd=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,children:a,placeholder:i="",...c}=e,l=pn(Vd,n),{onValueNodeHasChildrenChange:d}=l,f=a!==void 0,u=Ce(t,l.onValueNodeChange);return Ye(()=>{d(f)},[d,f]),r.jsx(pe.span,{...c,ref:u,style:{pointerEvents:"none"},children:iu(l.value)?r.jsx(r.Fragment,{children:i}):a})});Wd.displayName=Vd;var Gw="SelectIcon",Hd=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...o}=e;return r.jsx(pe.span,{"aria-hidden":!0,...o,ref:t,children:s||"▼"})});Hd.displayName=Gw;var Yw="SelectPortal",Zd=e=>r.jsx(ja,{asChild:!0,...e});Zd.displayName=Yw;var jn="SelectContent",qd=m.forwardRef((e,t)=>{const n=pn(jn,e.__scopeSelect),[s,o]=m.useState();if(Ye(()=>{o(new DocumentFragment)},[]),!n.open){const a=s;return a?vs.createPortal(r.jsx(Gd,{scope:e.__scopeSelect,children:r.jsx(Is.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),a):null}return r.jsx(Yd,{...e,ref:t})});qd.displayName=jn;var Et=10,[Gd,hn]=Kn(jn),Qw="SelectContentImpl",Kw=Hb("SelectContent.RemoveScroll"),Yd=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:b,hideWhenDetached:x,avoidCollisions:h,...v}=e,k=pn(jn,n),[w,y]=m.useState(null),[j,R]=m.useState(null),E=Ce(t,P=>y(P)),[C,A]=m.useState(null),[O,U]=m.useState(null),M=Ts(n),[B,$]=m.useState(!1),q=m.useRef(!1);m.useEffect(()=>{if(w)return Pd(w)},[w]),ad();const F=m.useCallback(P=>{const[Y,...ue]=M().map(ce=>ce.ref.current),[V]=ue.slice(-1),ae=document.activeElement;for(const ce of P)if(ce===ae||(ce?.scrollIntoView({block:"nearest"}),ce===Y&&j&&(j.scrollTop=0),ce===V&&j&&(j.scrollTop=j.scrollHeight),ce?.focus(),document.activeElement!==ae))return},[M,j]),Z=m.useCallback(()=>F([C,w]),[F,C,w]);m.useEffect(()=>{B&&Z()},[B,Z]);const{onOpenChange:D,triggerPointerDownPosRef:N}=k;m.useEffect(()=>{if(w){let P={x:0,y:0};const Y=V=>{P={x:Math.abs(Math.round(V.pageX)-(N.current?.x??0)),y:Math.abs(Math.round(V.pageY)-(N.current?.y??0))}},ue=V=>{P.x<=10&&P.y<=10?V.preventDefault():w.contains(V.target)||D(!1),document.removeEventListener("pointermove",Y),N.current=null};return N.current!==null&&(document.addEventListener("pointermove",Y),document.addEventListener("pointerup",ue,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Y),document.removeEventListener("pointerup",ue,{capture:!0})}}},[w,D,N]),m.useEffect(()=>{const P=()=>D(!1);return window.addEventListener("blur",P),window.addEventListener("resize",P),()=>{window.removeEventListener("blur",P),window.removeEventListener("resize",P)}},[D]);const[I,G]=cu(P=>{const Y=M().filter(ae=>!ae.disabled),ue=Y.find(ae=>ae.ref.current===document.activeElement),V=lu(Y,P,ue);V&&setTimeout(()=>V.ref.current.focus())}),xe=m.useCallback((P,Y,ue)=>{const V=!q.current&&!ue;(k.value!==void 0&&k.value===Y||V)&&(A(P),V&&(q.current=!0))},[k.value]),W=m.useCallback(()=>w?.focus(),[w]),Q=m.useCallback((P,Y,ue)=>{const V=!q.current&&!ue;(k.value!==void 0&&k.value===Y||V)&&U(P)},[k.value]),K=s==="popper"?Do:Qd,le=K===Do?{side:c,sideOffset:l,align:d,alignOffset:f,arrowPadding:u,collisionBoundary:g,collisionPadding:p,sticky:b,hideWhenDetached:x,avoidCollisions:h}:{};return r.jsx(Gd,{scope:n,content:w,viewport:j,onViewportChange:R,itemRefCallback:xe,selectedItem:C,onItemLeave:W,itemTextRefCallback:Q,focusSelectedItem:Z,selectedItemText:O,position:s,isPositioned:B,searchRef:I,children:r.jsx(Sa,{as:Kw,allowPinchZoom:!0,children:r.jsx(ha,{asChild:!0,trapped:k.open,onMountAutoFocus:P=>{P.preventDefault()},onUnmountAutoFocus:ge(o,P=>{k.trigger?.focus({preventScroll:!0}),P.preventDefault()}),children:r.jsx(pa,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:P=>P.preventDefault(),onDismiss:()=>k.onOpenChange(!1),children:r.jsx(K,{role:"listbox",id:k.contentId,"data-state":k.open?"open":"closed",dir:k.dir,onContextMenu:P=>P.preventDefault(),...v,...le,onPlaced:()=>$(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:ge(v.onKeyDown,P=>{const Y=P.ctrlKey||P.altKey||P.metaKey;if(P.key==="Tab"&&P.preventDefault(),!Y&&P.key.length===1&&G(P.key),["ArrowUp","ArrowDown","Home","End"].includes(P.key)){let V=M().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);if(["ArrowUp","End"].includes(P.key)&&(V=V.slice().reverse()),["ArrowUp","ArrowDown"].includes(P.key)){const ae=P.target,ce=V.indexOf(ae);V=V.slice(ce+1)}setTimeout(()=>F(V)),P.preventDefault()}})})})})})})});Yd.displayName=Qw;var Jw="SelectItemAlignedPosition",Qd=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...o}=e,a=pn(jn,n),i=hn(jn,n),[c,l]=m.useState(null),[d,f]=m.useState(null),u=Ce(t,E=>f(E)),g=Ts(n),p=m.useRef(!1),b=m.useRef(!0),{viewport:x,selectedItem:h,selectedItemText:v,focusSelectedItem:k}=i,w=m.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&d&&x&&h&&v){const E=a.trigger.getBoundingClientRect(),C=d.getBoundingClientRect(),A=a.valueNode.getBoundingClientRect(),O=v.getBoundingClientRect();if(a.dir!=="rtl"){const ae=O.left-C.left,ce=A.left-ae,we=E.left-ce,Te=E.width+we,We=Math.max(Te,C.width),Qe=window.innerWidth-Et,He=Ki(ce,[Et,Math.max(Et,Qe-We)]);c.style.minWidth=Te+"px",c.style.left=He+"px"}else{const ae=C.right-O.right,ce=window.innerWidth-A.right-ae,we=window.innerWidth-E.right-ce,Te=E.width+we,We=Math.max(Te,C.width),Qe=window.innerWidth-Et,He=Ki(ce,[Et,Math.max(Et,Qe-We)]);c.style.minWidth=Te+"px",c.style.right=He+"px"}const U=g(),M=window.innerHeight-Et*2,B=x.scrollHeight,$=window.getComputedStyle(d),q=parseInt($.borderTopWidth,10),F=parseInt($.paddingTop,10),Z=parseInt($.borderBottomWidth,10),D=parseInt($.paddingBottom,10),N=q+F+B+D+Z,I=Math.min(h.offsetHeight*5,N),G=window.getComputedStyle(x),xe=parseInt(G.paddingTop,10),W=parseInt(G.paddingBottom,10),Q=E.top+E.height/2-Et,K=M-Q,le=h.offsetHeight/2,P=h.offsetTop+le,Y=q+F+P,ue=N-Y;if(Y<=Q){const ae=U.length>0&&h===U[U.length-1].ref.current;c.style.bottom="0px";const ce=d.clientHeight-x.offsetTop-x.offsetHeight,we=Math.max(K,le+(ae?W:0)+ce+Z),Te=Y+we;c.style.height=Te+"px"}else{const ae=U.length>0&&h===U[0].ref.current;c.style.top="0px";const we=Math.max(Q,q+x.offsetTop+(ae?xe:0)+le)+ue;c.style.height=we+"px",x.scrollTop=Y-Q+x.offsetTop}c.style.margin=`${Et}px 0`,c.style.minHeight=I+"px",c.style.maxHeight=M+"px",s?.(),requestAnimationFrame(()=>p.current=!0)}},[g,a.trigger,a.valueNode,c,d,x,h,v,a.dir,s]);Ye(()=>w(),[w]);const[y,j]=m.useState();Ye(()=>{d&&j(window.getComputedStyle(d).zIndex)},[d]);const R=m.useCallback(E=>{E&&b.current===!0&&(w(),k?.(),b.current=!1)},[w,k]);return r.jsx(ek,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:p,onScrollButtonChange:R,children:r.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:y},children:r.jsx(pe.div,{...o,ref:u,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Qd.displayName=Jw;var Xw="SelectPopperPosition",Do=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:o=Et,...a}=e,i=Ps(n);return r.jsx(Bb,{...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)"}})});Do.displayName=Xw;var[ek,Ca]=Kn(jn,{}),$o="SelectViewport",Kd=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...o}=e,a=hn($o,n),i=Ca($o,n),c=Ce(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(Is.Slot,{scope:n,children:r.jsx(pe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ge(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 b=window.innerHeight-Et*2,x=parseFloat(u.style.minHeight),h=parseFloat(u.style.height),v=Math.max(x,h);if(v<b){const k=v+p,w=Math.min(b,k),y=k-w;u.style.height=w+"px",u.style.bottom==="0px"&&(f.scrollTop=y>0?y:0,u.style.justifyContent="flex-end")}}}l.current=f.scrollTop})})})]})});Kd.displayName=$o;var Jd="SelectGroup",[tk,nk]=Kn(Jd),Xd=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Bt();return r.jsx(tk,{scope:n,id:o,children:r.jsx(pe.div,{role:"group","aria-labelledby":o,...s,ref:t})})});Xd.displayName=Jd;var eu="SelectLabel",rk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=nk(eu,n);return r.jsx(pe.div,{id:o.id,...s,ref:t})});rk.displayName=eu;var us="SelectItem",[sk,tu]=Kn(us),nu=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:o=!1,textValue:a,...i}=e,c=pn(us,n),l=hn(us,n),d=c.value===s,[f,u]=m.useState(a??""),[g,p]=m.useState(!1),b=Ce(t,k=>l.itemRefCallback?.(k,s,o)),x=Bt(),h=m.useRef("touch"),v=()=>{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(sk,{scope:n,value:s,disabled:o,textId:x,isSelected:d,onItemTextChange:m.useCallback(k=>{u(w=>w||(k?.textContent??"").trim())},[]),children:r.jsx(Is.ItemSlot,{scope:n,value:s,disabled:o,textValue:f,children:r.jsx(pe.div,{role:"option","aria-labelledby":x,"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:b,onFocus:ge(i.onFocus,()=>p(!0)),onBlur:ge(i.onBlur,()=>p(!1)),onClick:ge(i.onClick,()=>{h.current!=="mouse"&&v()}),onPointerUp:ge(i.onPointerUp,()=>{h.current==="mouse"&&v()}),onPointerDown:ge(i.onPointerDown,k=>{h.current=k.pointerType}),onPointerMove:ge(i.onPointerMove,k=>{h.current=k.pointerType,o?l.onItemLeave?.():h.current==="mouse"&&k.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ge(i.onPointerLeave,k=>{k.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:ge(i.onKeyDown,k=>{l.searchRef?.current!==""&&k.key===" "||(Vw.includes(k.key)&&v(),k.key===" "&&k.preventDefault())})})})})});nu.displayName=us;var lr="SelectItemText",ru=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:o,...a}=e,i=pn(lr,n),c=hn(lr,n),l=tu(lr,n),d=qw(lr,n),[f,u]=m.useState(null),g=Ce(t,v=>u(v),l.onItemTextChange,v=>c.itemTextRefCallback?.(v,l.value,l.disabled)),p=f?.textContent,b=m.useMemo(()=>r.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:h}=d;return Ye(()=>(x(b),()=>h(b)),[x,h,b]),r.jsxs(r.Fragment,{children:[r.jsx(pe.span,{id:l.textId,...a,ref:g}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?vs.createPortal(a.children,i.valueNode):null]})});ru.displayName=lr;var su="SelectItemIndicator",ok=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return tu(su,n).isSelected?r.jsx(pe.span,{"aria-hidden":!0,...s,ref:t}):null});ok.displayName=su;var zo="SelectScrollUpButton",ak=m.forwardRef((e,t)=>{const n=hn(zo,e.__scopeSelect),s=Ca(zo,e.__scopeSelect),[o,a]=m.useState(!1),i=Ce(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(ou,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop-l.offsetHeight)}}):null});ak.displayName=zo;var Fo="SelectScrollDownButton",ik=m.forwardRef((e,t)=>{const n=hn(Fo,e.__scopeSelect),s=Ca(Fo,e.__scopeSelect),[o,a]=m.useState(!1),i=Ce(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(ou,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:l}=n;c&&l&&(c.scrollTop=c.scrollTop+l.offsetHeight)}}):null});ik.displayName=Fo;var ou=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...o}=e,a=hn("SelectScrollButton",n),i=m.useRef(null),c=Ts(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(pe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ge(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(s,50))}),onPointerMove:ge(o.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(s,50))}),onPointerLeave:ge(o.onPointerLeave,()=>{l()})})}),ck="SelectSeparator",lk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(pe.div,{"aria-hidden":!0,...s,ref:t})});lk.displayName=ck;var Uo="SelectArrow",dk=m.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,o=Ps(n),a=pn(Uo,n),i=hn(Uo,n);return a.open&&i.position==="popper"?r.jsx(Vb,{...o,...s,ref:t}):null});dk.displayName=Uo;var uk="SelectBubbleInput",au=m.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const o=m.useRef(null),a=Ce(s,o),i=ew(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(pe.select,{...n,style:{...Id,...n.style},ref:a,defaultValue:t})});au.displayName=uk;function iu(e){return e===""||e===void 0}function cu(e){const t=an(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 lu(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=fk(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 fk(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var mk=Fd,du=Bd,pk=Wd,hk=Hd,gk=Zd,uu=qd,xk=Kd,vk=Xd,fu=nu,yk=ru;const fs=mk,bk=vk,ms=pk,br=m.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(du,{ref:s,className:L("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(hk,{className:"ml-2 text-neutral-500 dark:text-neutral-400",children:"▾"})]}));br.displayName=du.displayName;const wr=m.forwardRef(({className:e,children:t,position:n="popper",...s},o)=>r.jsx(gk,{children:r.jsx(uu,{ref:o,position:n,className:L("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(xk,{className:L("p-1",n==="popper"?"w-full":void 0),children:t})})}));wr.displayName=uu.displayName;const kr=m.forwardRef(({className:e,children:t,...n},s)=>r.jsx(fu,{ref:s,className:L("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(yk,{children:t})}));kr.displayName=fu.displayName;function wk(e,t){return m.useReducer((n,s)=>t[n][s]??n,e)}var Jn=e=>{const{present:t,children:n}=e,s=kk(t),o=typeof n=="function"?n({present:s.isPresent}):m.Children.only(n),a=Ce(s.ref,_k(o));return typeof n=="function"||s.isPresent?m.cloneElement(o,{ref:a}):null};Jn.displayName="Presence";function kk(e){const[t,n]=m.useState(),s=m.useRef(null),o=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[c,l]=wk(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const d=Br(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=Br(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 x=Br(s.current).includes(CSS.escape(p.animationName));if(p.target===t&&x&&(l("ANIMATION_END"),!o.current)){const h=t.style.animationFillMode;t.style.animationFillMode="forwards",d=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=h)})}},g=p=>{p.target===t&&(a.current=Br(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 Br(e){return e?.animationName||"none"}function _k(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 jk(e){const t=Sk(e),n=m.forwardRef((s,o)=>{const{children:a,...i}=s,c=m.Children.toArray(a),l=c.find(Nk);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 Sk(e){const t=m.forwardRef((n,s)=>{const{children:o,...a}=n;if(m.isValidElement(o)){const i=Ek(o),c=Ak(a,o.props);return o.type!==m.Fragment&&(c.ref=s?Zn(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 Ck=Symbol("radix.slottable");function Nk(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ck}function Ak(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 Ek(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 Rs="Dialog",[mu]=mn(Rs),[Ik,Mt]=mu(Rs),pu=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]=dn({prop:s,defaultProp:o??!1,onChange:a,caller:Rs});return r.jsx(Ik,{scope:t,triggerRef:c,contentRef:l,contentId:Bt(),titleId:Bt(),descriptionId:Bt(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:n})};pu.displayName=Rs;var hu="DialogTrigger",gu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Mt(hu,n),a=Ce(t,o.triggerRef);return r.jsx(pe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Ea(o.open),...s,ref:a,onClick:ge(e.onClick,o.onOpenToggle)})});gu.displayName=hu;var Na="DialogPortal",[Tk,xu]=mu(Na,{forceMount:void 0}),vu=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:o}=e,a=Mt(Na,t);return r.jsx(Tk,{scope:t,forceMount:n,children:m.Children.map(s,i=>r.jsx(Jn,{present:n||a.open,children:r.jsx(ja,{asChild:!0,container:o,children:i})}))})};vu.displayName=Na;var ps="DialogOverlay",yu=m.forwardRef((e,t)=>{const n=xu(ps,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Mt(ps,e.__scopeDialog);return a.modal?r.jsx(Jn,{present:s||a.open,children:r.jsx(Rk,{...o,ref:t})}):null});yu.displayName=ps;var Pk=jk("DialogOverlay.RemoveScroll"),Rk=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Mt(ps,n);return r.jsx(Sa,{as:Pk,allowPinchZoom:!0,shards:[o.contentRef],children:r.jsx(pe.div,{"data-state":Ea(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),Sn="DialogContent",bu=m.forwardRef((e,t)=>{const n=xu(Sn,e.__scopeDialog),{forceMount:s=n.forceMount,...o}=e,a=Mt(Sn,e.__scopeDialog);return r.jsx(Jn,{present:s||a.open,children:a.modal?r.jsx(Ok,{...o,ref:t}):r.jsx(Mk,{...o,ref:t})})});bu.displayName=Sn;var Ok=m.forwardRef((e,t)=>{const n=Mt(Sn,e.__scopeDialog),s=m.useRef(null),o=Ce(t,n.contentRef,s);return m.useEffect(()=>{const a=s.current;if(a)return Pd(a)},[]),r.jsx(wu,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ge(e.onCloseAutoFocus,a=>{a.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ge(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:ge(e.onFocusOutside,a=>a.preventDefault())})}),Mk=m.forwardRef((e,t)=>{const n=Mt(Sn,e.__scopeDialog),s=m.useRef(!1),o=m.useRef(!1);return r.jsx(wu,{...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()}})}),wu=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,c=Mt(Sn,n),l=m.useRef(null),d=Ce(t,l);return ad(),r.jsxs(r.Fragment,{children:[r.jsx(ha,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:r.jsx(pa,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Ea(c.open),...i,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(Lk,{titleId:c.titleId}),r.jsx($k,{contentRef:l,descriptionId:c.descriptionId})]})]})}),Aa="DialogTitle",ku=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Mt(Aa,n);return r.jsx(pe.h2,{id:o.titleId,...s,ref:t})});ku.displayName=Aa;var _u="DialogDescription",ju=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Mt(_u,n);return r.jsx(pe.p,{id:o.descriptionId,...s,ref:t})});ju.displayName=_u;var Su="DialogClose",Cu=m.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,o=Mt(Su,n);return r.jsx(pe.button,{type:"button",...s,ref:t,onClick:ge(e.onClick,()=>o.onOpenChange(!1))})});Cu.displayName=Su;function Ea(e){return e?"open":"closed"}var Nu="DialogTitleWarning",[uS,Au]=Bv(Nu,{contentName:Sn,titleName:Aa,docsSlug:"dialog"}),Lk=({titleId:e})=>{const t=Au(Nu),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},Dk="DialogDescriptionWarning",$k=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Au(Dk).contentName}}.`;return m.useEffect(()=>{const o=e.current?.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Eu=pu,Iu=gu,Tu=vu,Os=yu,Ms=bu,Ls=ku,Ds=ju,Pu=Cu;const Ia=Eu,zk=Iu,Ru=Tu,Fk=Pu,Ta=m.forwardRef(({className:e,...t},n)=>r.jsx(Os,{ref:n,className:L("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}));Ta.displayName=Os.displayName;const $s=m.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Ru,{children:[r.jsx(Ta,{}),r.jsx(Ms,{ref:s,className:L("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})]}));$s.displayName=Ms.displayName;const Pa=({className:e,...t})=>r.jsx("div",{className:L("flex flex-col space-y-2 text-center sm:text-left",e),...t}),Ou=({className:e,...t})=>r.jsx("div",{className:L("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),zs=m.forwardRef(({className:e,...t},n)=>r.jsx(Ls,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));zs.displayName=Ls.displayName;const Ra=m.forwardRef(({className:e,...t},n)=>r.jsx(Ds,{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Ra.displayName=Ds.displayName;const Fs=Eu,Us=Iu,Mu=Pu,Lu=Tu,Oa=m.forwardRef(({className:e,...t},n)=>r.jsx(Os,{ref:n,className:L("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}));Oa.displayName=Os.displayName;const Uk=ua("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"}}),Ar=m.forwardRef(({side:e="right",className:t,children:n,overlayClassName:s,...o},a)=>r.jsxs(Lu,{children:[r.jsx(Oa,{className:s}),r.jsx(Ms,{ref:a,className:L(Uk({side:e}),t),...o,children:n})]}));Ar.displayName=Ms.displayName;const Bs=({className:e,...t})=>r.jsx("div",{className:L("flex flex-col space-y-2 text-left",e),...t}),Vs=m.forwardRef(({className:e,...t},n)=>r.jsx(Ls,{ref:n,className:L("text-lg font-semibold leading-none tracking-tight",e),...t}));Vs.displayName=Ls.displayName;const Du=m.forwardRef(({className:e,...t},n)=>r.jsx(Ds,{ref:n,className:L("text-sm text-neutral-500 dark:text-neutral-400",e),...t}));Du.displayName=Ds.displayName;var Ws="Collapsible",[Bk,$u]=mn(Ws),[Vk,Ma]=Bk(Ws),zu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:s,defaultOpen:o,disabled:a,onOpenChange:i,...c}=e,[l,d]=dn({prop:s,defaultProp:o??!1,onChange:i,caller:Ws});return r.jsx(Vk,{scope:n,disabled:a,contentId:Bt(),open:l,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),children:r.jsx(pe.div,{"data-state":Da(l),"data-disabled":a?"":void 0,...c,ref:t})})});zu.displayName=Ws;var Fu="CollapsibleTrigger",Uu=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...s}=e,o=Ma(Fu,n);return r.jsx(pe.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":Da(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...s,ref:t,onClick:ge(e.onClick,o.onOpenToggle)})});Uu.displayName=Fu;var La="CollapsibleContent",Bu=m.forwardRef((e,t)=>{const{forceMount:n,...s}=e,o=Ma(La,e.__scopeCollapsible);return r.jsx(Jn,{present:n||o.open,children:({present:a})=>r.jsx(Wk,{...s,ref:t,present:a})})});Bu.displayName=La;var Wk=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:s,children:o,...a}=e,i=Ma(La,n),[c,l]=m.useState(s),d=m.useRef(null),f=Ce(t,d),u=m.useRef(0),g=u.current,p=m.useRef(0),b=p.current,x=i.open||c,h=m.useRef(x),v=m.useRef(void 0);return m.useEffect(()=>{const k=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(k)},[]),Ye(()=>{const k=d.current;if(k){v.current=v.current||{transitionDuration:k.style.transitionDuration,animationName:k.style.animationName},k.style.transitionDuration="0s",k.style.animationName="none";const w=k.getBoundingClientRect();u.current=w.height,p.current=w.width,h.current||(k.style.transitionDuration=v.current.transitionDuration,k.style.animationName=v.current.animationName),l(s)}},[i.open,s]),r.jsx(pe.div,{"data-state":Da(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...a,ref:f,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:x&&o})});function Da(e){return e?"open":"closed"}var Hk=zu,Zk=Uu,qk=Bu,Lt="Accordion",Gk=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[$a,Yk,Qk]=ma(Lt),[Hs]=mn(Lt,[Qk,$u]),za=$u(),Vu=_.forwardRef((e,t)=>{const{type:n,...s}=e,o=s,a=s;return r.jsx($a.Provider,{scope:e.__scopeAccordion,children:n==="multiple"?r.jsx(e_,{...a,ref:t}):r.jsx(Xk,{...o,ref:t})})});Vu.displayName=Lt;var[Wu,Kk]=Hs(Lt),[Hu,Jk]=Hs(Lt,{collapsible:!1}),Xk=_.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:o=()=>{},collapsible:a=!1,...i}=e,[c,l]=dn({prop:n,defaultProp:s??"",onChange:o,caller:Lt});return r.jsx(Wu,{scope:e.__scopeAccordion,value:_.useMemo(()=>c?[c]:[],[c]),onItemOpen:l,onItemClose:_.useCallback(()=>a&&l(""),[a,l]),children:r.jsx(Hu,{scope:e.__scopeAccordion,collapsible:a,children:r.jsx(Zu,{...i,ref:t})})})}),e_=_.forwardRef((e,t)=>{const{value:n,defaultValue:s,onValueChange:o=()=>{},...a}=e,[i,c]=dn({prop:n,defaultProp:s??[],onChange:o,caller:Lt}),l=_.useCallback(f=>c((u=[])=>[...u,f]),[c]),d=_.useCallback(f=>c((u=[])=>u.filter(g=>g!==f)),[c]);return r.jsx(Wu,{scope:e.__scopeAccordion,value:i,onItemOpen:l,onItemClose:d,children:r.jsx(Hu,{scope:e.__scopeAccordion,collapsible:!0,children:r.jsx(Zu,{...a,ref:t})})})}),[t_,Zs]=Hs(Lt),Zu=_.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:s,dir:o,orientation:a="vertical",...i}=e,c=_.useRef(null),l=Ce(c,t),d=Yk(n),u=js(o)==="ltr",g=ge(e.onKeyDown,p=>{if(!Gk.includes(p.key))return;const b=p.target,x=d().filter(C=>!C.ref.current?.disabled),h=x.findIndex(C=>C.ref.current===b),v=x.length;if(h===-1)return;p.preventDefault();let k=h;const w=0,y=v-1,j=()=>{k=h+1,k>y&&(k=w)},R=()=>{k=h-1,k<w&&(k=y)};switch(p.key){case"Home":k=w;break;case"End":k=y;break;case"ArrowRight":a==="horizontal"&&(u?j():R());break;case"ArrowDown":a==="vertical"&&j();break;case"ArrowLeft":a==="horizontal"&&(u?R():j());break;case"ArrowUp":a==="vertical"&&R();break}const E=k%v;x[E].ref.current?.focus()});return r.jsx(t_,{scope:n,disabled:s,direction:o,orientation:a,children:r.jsx($a.Slot,{scope:n,children:r.jsx(pe.div,{...i,"data-orientation":a,ref:l,onKeyDown:s?void 0:g})})})}),hs="AccordionItem",[n_,Fa]=Hs(hs),qu=_.forwardRef((e,t)=>{const{__scopeAccordion:n,value:s,...o}=e,a=Zs(hs,n),i=Kk(hs,n),c=za(n),l=Bt(),d=s&&i.value.includes(s)||!1,f=a.disabled||e.disabled;return r.jsx(n_,{scope:n,open:d,disabled:f,triggerId:l,children:r.jsx(Hk,{"data-orientation":a.orientation,"data-state":Xu(d),...c,...o,ref:t,disabled:f,open:d,onOpenChange:u=>{u?i.onItemOpen(s):i.onItemClose(s)}})})});qu.displayName=hs;var Gu="AccordionHeader",Yu=_.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Zs(Lt,n),a=Fa(Gu,n);return r.jsx(pe.h3,{"data-orientation":o.orientation,"data-state":Xu(a.open),"data-disabled":a.disabled?"":void 0,...s,ref:t})});Yu.displayName=Gu;var Bo="AccordionTrigger",Qu=_.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Zs(Lt,n),a=Fa(Bo,n),i=Jk(Bo,n),c=za(n);return r.jsx($a.ItemSlot,{scope:n,children:r.jsx(Zk,{"aria-disabled":a.open&&!i.collapsible||void 0,"data-orientation":o.orientation,id:a.triggerId,...c,...s,ref:t})})});Qu.displayName=Bo;var Ku="AccordionContent",Ju=_.forwardRef((e,t)=>{const{__scopeAccordion:n,...s}=e,o=Zs(Lt,n),a=Fa(Ku,n),i=za(n);return r.jsx(qk,{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}})});Ju.displayName=Ku;function Xu(e){return e?"open":"closed"}var r_=Vu,ef=qu,s_=Yu,tf=Qu,nf=Ju;const rf=r_,ur=m.forwardRef(({className:e,...t},n)=>r.jsx(ef,{ref:n,className:L("border-b border-neutral-200 dark:border-neutral-800",e),...t}));ur.displayName=ef.displayName;const fr=m.forwardRef(({className:e,children:t,...n},s)=>r.jsx(s_,{className:"flex",children:r.jsxs(tf,{ref:s,className:L("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=tf.displayName;const mr=m.forwardRef(({className:e,children:t,...n},s)=>r.jsx(nf,{ref:s,className:L("overflow-hidden text-sm",e),...n,children:r.jsx("div",{className:"pb-4 pt-0",children:t})}));mr.displayName=nf.displayName;var xo="rovingFocusGroup.onEntryFocus",o_={bubbles:!1,cancelable:!0},Er="RovingFocusGroup",[Vo,sf,a_]=ma(Er),[i_,of]=mn(Er,[a_]),[c_,l_]=i_(Er),af=m.forwardRef((e,t)=>r.jsx(Vo.Provider,{scope:e.__scopeRovingFocusGroup,children:r.jsx(Vo.Slot,{scope:e.__scopeRovingFocusGroup,children:r.jsx(d_,{...e,ref:t})})}));af.displayName=Er;var d_=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=Ce(t,g),b=js(a),[x,h]=dn({prop:i,defaultProp:c??null,onChange:l,caller:Er}),[v,k]=m.useState(!1),w=an(d),y=sf(n),j=m.useRef(!1),[R,E]=m.useState(0);return m.useEffect(()=>{const C=g.current;if(C)return C.addEventListener(xo,w),()=>C.removeEventListener(xo,w)},[w]),r.jsx(c_,{scope:n,orientation:s,dir:b,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(C=>h(C),[h]),onItemShiftTab:m.useCallback(()=>k(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(C=>C+1),[]),onFocusableItemRemove:m.useCallback(()=>E(C=>C-1),[]),children:r.jsx(pe.div,{tabIndex:v||R===0?-1:0,"data-orientation":s,...u,ref:p,style:{outline:"none",...e.style},onMouseDown:ge(e.onMouseDown,()=>{j.current=!0}),onFocus:ge(e.onFocus,C=>{const A=!j.current;if(C.target===C.currentTarget&&A&&!v){const O=new CustomEvent(xo,o_);if(C.currentTarget.dispatchEvent(O),!O.defaultPrevented){const U=y().filter(F=>F.focusable),M=U.find(F=>F.active),B=U.find(F=>F.id===x),q=[M,B,...U].filter(Boolean).map(F=>F.ref.current);df(q,f)}}j.current=!1}),onBlur:ge(e.onBlur,()=>k(!1))})})}),cf="RovingFocusGroupItem",lf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:s=!0,active:o=!1,tabStopId:a,children:i,...c}=e,l=Bt(),d=a||l,f=l_(cf,n),u=f.currentTabStopId===d,g=sf(n),{onFocusableItemAdd:p,onFocusableItemRemove:b,currentTabStopId:x}=f;return m.useEffect(()=>{if(s)return p(),()=>b()},[s,p,b]),r.jsx(Vo.ItemSlot,{scope:n,id:d,focusable:s,active:o,children:r.jsx(pe.span,{tabIndex:u?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:ge(e.onMouseDown,h=>{s?f.onItemFocus(d):h.preventDefault()}),onFocus:ge(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:ge(e.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){f.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const v=m_(h,f.orientation,f.dir);if(v!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let w=g().filter(y=>y.focusable).map(y=>y.ref.current);if(v==="last")w.reverse();else if(v==="prev"||v==="next"){v==="prev"&&w.reverse();const y=w.indexOf(h.currentTarget);w=f.loop?p_(w,y+1):w.slice(y+1)}setTimeout(()=>df(w))}}),children:typeof i=="function"?i({isCurrentTabStop:u,hasTabStop:x!=null}):i})})});lf.displayName=cf;var u_={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function f_(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function m_(e,t,n){const s=f_(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return u_[s]}function df(e,t=!1){const n=document.activeElement;for(const s of e)if(s===n||(s.focus({preventScroll:t}),document.activeElement!==n))return}function p_(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var h_=af,g_=lf,qs="Tabs",[x_]=mn(qs,[of]),uf=of(),[v_,Ua]=x_(qs),ff=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,onValueChange:o,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:l="automatic",...d}=e,f=js(c),[u,g]=dn({prop:s,onChange:o,defaultProp:a??"",caller:qs});return r.jsx(v_,{scope:n,baseId:Bt(),value:u,onValueChange:g,orientation:i,dir:f,activationMode:l,children:r.jsx(pe.div,{dir:f,"data-orientation":i,...d,ref:t})})});ff.displayName=qs;var mf="TabsList",pf=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:s=!0,...o}=e,a=Ua(mf,n),i=uf(n);return r.jsx(h_,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:s,children:r.jsx(pe.div,{role:"tablist","aria-orientation":a.orientation,...o,ref:t})})});pf.displayName=mf;var hf="TabsTrigger",gf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,disabled:o=!1,...a}=e,i=Ua(hf,n),c=uf(n),l=yf(i.baseId,s),d=bf(i.baseId,s),f=s===i.value;return r.jsx(g_,{asChild:!0,...c,focusable:!o,active:f,children:r.jsx(pe.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:ge(e.onMouseDown,u=>{!o&&u.button===0&&u.ctrlKey===!1?i.onValueChange(s):u.preventDefault()}),onKeyDown:ge(e.onKeyDown,u=>{[" ","Enter"].includes(u.key)&&i.onValueChange(s)}),onFocus:ge(e.onFocus,()=>{const u=i.activationMode!=="manual";!f&&!o&&u&&i.onValueChange(s)})})})});gf.displayName=hf;var xf="TabsContent",vf=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:s,forceMount:o,children:a,...i}=e,c=Ua(xf,n),l=yf(c.baseId,s),d=bf(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(Jn,{present:o||f,children:({present:g})=>r.jsx(pe.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})})});vf.displayName=xf;function yf(e,t){return`${e}-trigger-${t}`}function bf(e,t){return`${e}-content-${t}`}var y_=ff,wf=pf,kf=gf,_f=vf;const Ba=y_,Gs=m.forwardRef(({className:e,...t},n)=>r.jsx(wf,{ref:n,className:L("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}));Gs.displayName=wf.displayName;const _r=m.forwardRef(({className:e,...t},n)=>r.jsx(kf,{ref:n,className:L("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=kf.displayName;const jf=m.forwardRef(({className:e,...t},n)=>r.jsx(_f,{ref:n,className:L("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}));jf.displayName=_f.displayName;function Vn({title:e,description:t,actionLabel:n,onAction:s,className:o}){return r.jsx("div",{className:L("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 Wt({title:e,description:t,onRetry:n,className:s}){return r.jsxs("div",{className:L("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 b_ 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(Wt,{description:this.state.error.message}):this.props.children}}function w_(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 k_=e=>{switch(e){case"success":return S_;case"info":return N_;case"warning":return C_;case"error":return A_;default:return null}},__=Array(12).fill(0),j_=({visible:e,className:t})=>_.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},_.createElement("div",{className:"sonner-spinner"},__.map((n,s)=>_.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),S_=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),C_=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},_.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"})),N_=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),A_=_.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},_.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"})),E_=_.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"},_.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),_.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),I_=()=>{const[e,t]=_.useState(document.hidden);return _.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Wo=1;class T_{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:Wo++,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],_.isValidElement(d))a=!1,this.create({id:s,type:"default",message:d});else if(R_(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,b=typeof u=="object"&&!_.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:g,...b})}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,b=typeof u=="object"&&!_.isValidElement(u)?u:{message:u};this.create({id:s,type:"error",description:g,...b})}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,b=typeof u=="object"&&!_.isValidElement(u)?u:{message:u};this.create({id:s,type:"success",description:g,...b})}}).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"&&!_.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||Wo++;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 ut=new T_,P_=(e,t)=>{const n=t?.id||Wo++;return ut.addToast({title:e,...t,id:n}),n},R_=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",O_=P_,M_=()=>ut.toasts,L_=()=>ut.getActiveToasts(),D_=Object.assign(O_,{success:ut.success,info:ut.info,warning:ut.warning,error:ut.error,custom:ut.custom,message:ut.message,promise:ut.promise,dismiss:ut.dismiss,loading:ut.loading},{getHistory:M_,getToasts:L_});w_("[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 Vr(e){return e.label!==void 0}const $_=3,z_="24px",F_="16px",kc=4e3,U_=356,B_=14,V_=45,W_=200;function $t(...e){return e.filter(Boolean).join(" ")}function H_(e){const[t,n]=e.split("-"),s=[];return t&&s.push(t),n&&s.push(n),s}const Z_=e=>{var t,n,s,o,a,i,c,l,d;const{invert:f,toast:u,unstyled:g,interacting:p,setHeights:b,visibleToasts:x,heights:h,index:v,toasts:k,expanded:w,removeToast:y,defaultRichColors:j,closeButton:R,style:E,cancelButtonStyle:C,actionButtonStyle:A,className:O="",descriptionClassName:U="",duration:M,position:B,gap:$,expandByDefault:q,classNames:F,icons:Z,closeButtonAriaLabel:D="Close toast"}=e,[N,I]=_.useState(null),[G,xe]=_.useState(null),[W,Q]=_.useState(!1),[K,le]=_.useState(!1),[P,Y]=_.useState(!1),[ue,V]=_.useState(!1),[ae,ce]=_.useState(!1),[we,Te]=_.useState(0),[We,Qe]=_.useState(0),He=_.useRef(u.duration||M||kc),St=_.useRef(null),Ke=_.useRef(null),nn=v===0,bt=v+1<=x,je=u.type,nt=u.dismissible!==!1,ke=u.className||"",qt=u.descriptionClassName||"",pt=_.useMemo(()=>h.findIndex(de=>de.toastId===u.id)||0,[h,u.id]),ct=_.useMemo(()=>{var de;return(de=u.closeButton)!=null?de:R},[u.closeButton,R]),T=_.useMemo(()=>u.duration||M||kc,[u.duration,M]),ee=_.useRef(0),se=_.useRef(0),ve=_.useRef(0),ye=_.useRef(null),[Pe,Nn]=B.split("-"),wt=_.useMemo(()=>h.reduce((de,De,he)=>he>=pt?de:de+De.height,0),[h,pt]),Gt=I_(),Xn=u.invert||f,gn=je==="loading";se.current=_.useMemo(()=>pt*$+wt,[pt,wt]),_.useEffect(()=>{He.current=T},[T]),_.useEffect(()=>{Q(!0)},[]),_.useEffect(()=>{const de=Ke.current;if(de){const De=de.getBoundingClientRect().height;return Qe(De),b(he=>[{toastId:u.id,height:De,position:u.position},...he]),()=>b(he=>he.filter($e=>$e.toastId!==u.id))}},[b,u.id]),_.useLayoutEffect(()=>{if(!W)return;const de=Ke.current,De=de.style.height;de.style.height="auto";const he=de.getBoundingClientRect().height;de.style.height=De,Qe(he),b($e=>$e.find(ze=>ze.toastId===u.id)?$e.map(ze=>ze.toastId===u.id?{...ze,height:he}:ze):[{toastId:u.id,height:he,position:u.position},...$e])},[W,u.title,u.description,b,u.id,u.jsx,u.action,u.cancel]);const Dt=_.useCallback(()=>{le(!0),Te(se.current),b(de=>de.filter(De=>De.toastId!==u.id)),setTimeout(()=>{y(u)},W_)},[u,y,b,se]);_.useEffect(()=>{if(u.promise&&je==="loading"||u.duration===1/0||u.type==="loading")return;let de;return w||p||Gt?(()=>{if(ve.current<ee.current){const $e=new Date().getTime()-ee.current;He.current=He.current-$e}ve.current=new Date().getTime()})():(()=>{He.current!==1/0&&(ee.current=new Date().getTime(),de=setTimeout(()=>{u.onAutoClose==null||u.onAutoClose.call(u,u),Dt()},He.current))})(),()=>clearTimeout(de)},[w,p,u,je,Gt,Dt]),_.useEffect(()=>{u.delete&&(Dt(),u.onDismiss==null||u.onDismiss.call(u,u))},[Dt,u.delete]);function An(){var de;if(Z?.loading){var De;return _.createElement("div",{className:$t(F?.loader,u==null||(De=u.classNames)==null?void 0:De.loader,"sonner-loader"),"data-visible":je==="loading"},Z.loading)}return _.createElement(j_,{className:$t(F?.loader,u==null||(de=u.classNames)==null?void 0:de.loader),visible:je==="loading"})}const En=u.icon||Z?.[je]||k_(je);var Ir,rn;return _.createElement("li",{tabIndex:0,ref:Ke,className:$t(O,ke,F?.toast,u==null||(t=u.classNames)==null?void 0:t.toast,F?.default,F?.[je],u==null||(n=u.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(Ir=u.richColors)!=null?Ir:j,"data-styled":!(u.jsx||u.unstyled||g),"data-mounted":W,"data-promise":!!u.promise,"data-swiped":ae,"data-removed":K,"data-visible":bt,"data-y-position":Pe,"data-x-position":Nn,"data-index":v,"data-front":nn,"data-swiping":P,"data-dismissible":nt,"data-type":je,"data-invert":Xn,"data-swipe-out":ue,"data-swipe-direction":G,"data-expanded":!!(w||q&&W),"data-testid":u.testId,style:{"--index":v,"--toasts-before":v,"--z-index":k.length-v,"--offset":`${K?we:se.current}px`,"--initial-height":q?"auto":`${We}px`,...E,...u.style},onDragEnd:()=>{Y(!1),I(null),ye.current=null},onPointerDown:de=>{de.button!==2&&(gn||!nt||(St.current=new Date,Te(se.current),de.target.setPointerCapture(de.pointerId),de.target.tagName!=="BUTTON"&&(Y(!0),ye.current={x:de.clientX,y:de.clientY})))},onPointerUp:()=>{var de,De,he;if(ue||!nt)return;ye.current=null;const $e=Number(((de=Ke.current)==null?void 0:de.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),In=Number(((De=Ke.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ze=new Date().getTime()-((he=St.current)==null?void 0:he.getTime()),Je=N==="x"?$e:In,xn=Math.abs(Je)/ze;if(Math.abs(Je)>=V_||xn>.11){Te(se.current),u.onDismiss==null||u.onDismiss.call(u,u),xe(N==="x"?$e>0?"right":"left":In>0?"down":"up"),Dt(),V(!0);return}else{var lt,ht;(lt=Ke.current)==null||lt.style.setProperty("--swipe-amount-x","0px"),(ht=Ke.current)==null||ht.style.setProperty("--swipe-amount-y","0px")}ce(!1),Y(!1),I(null)},onPointerMove:de=>{var De,he,$e;if(!ye.current||!nt||((De=window.getSelection())==null?void 0:De.toString().length)>0)return;const ze=de.clientY-ye.current.y,Je=de.clientX-ye.current.x;var xn;const lt=(xn=e.swipeDirections)!=null?xn:H_(B);!N&&(Math.abs(Je)>1||Math.abs(ze)>1)&&I(Math.abs(Je)>Math.abs(ze)?"x":"y");let ht={x:0,y:0};const gt=rt=>1/(1.5+Math.abs(rt)/20);if(N==="y"){if(lt.includes("top")||lt.includes("bottom"))if(lt.includes("top")&&ze<0||lt.includes("bottom")&&ze>0)ht.y=ze;else{const rt=ze*gt(ze);ht.y=Math.abs(rt)<Math.abs(ze)?rt:ze}}else if(N==="x"&&(lt.includes("left")||lt.includes("right")))if(lt.includes("left")&&Je<0||lt.includes("right")&&Je>0)ht.x=Je;else{const rt=Je*gt(Je);ht.x=Math.abs(rt)<Math.abs(Je)?rt:Je}(Math.abs(ht.x)>0||Math.abs(ht.y)>0)&&ce(!0),(he=Ke.current)==null||he.style.setProperty("--swipe-amount-x",`${ht.x}px`),($e=Ke.current)==null||$e.style.setProperty("--swipe-amount-y",`${ht.y}px`)}},ct&&!u.jsx&&je!=="loading"?_.createElement("button",{"aria-label":D,"data-disabled":gn,"data-close-button":!0,onClick:gn||!nt?()=>{}:()=>{Dt(),u.onDismiss==null||u.onDismiss.call(u,u)},className:$t(F?.closeButton,u==null||(s=u.classNames)==null?void 0:s.closeButton)},(rn=Z?.close)!=null?rn:E_):null,(je||u.icon||u.promise)&&u.icon!==null&&(Z?.[je]!==null||u.icon)?_.createElement("div",{"data-icon":"",className:$t(F?.icon,u==null||(o=u.classNames)==null?void 0:o.icon)},u.promise||u.type==="loading"&&!u.icon?u.icon||An():null,u.type!=="loading"?En:null):null,_.createElement("div",{"data-content":"",className:$t(F?.content,u==null||(a=u.classNames)==null?void 0:a.content)},_.createElement("div",{"data-title":"",className:$t(F?.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?_.createElement("div",{"data-description":"",className:$t(U,qt,F?.description,u==null||(c=u.classNames)==null?void 0:c.description)},typeof u.description=="function"?u.description():u.description):null),_.isValidElement(u.cancel)?u.cancel:u.cancel&&Vr(u.cancel)?_.createElement("button",{"data-button":!0,"data-cancel":!0,style:u.cancelButtonStyle||C,onClick:de=>{Vr(u.cancel)&&nt&&(u.cancel.onClick==null||u.cancel.onClick.call(u.cancel,de),Dt())},className:$t(F?.cancelButton,u==null||(l=u.classNames)==null?void 0:l.cancelButton)},u.cancel.label):null,_.isValidElement(u.action)?u.action:u.action&&Vr(u.action)?_.createElement("button",{"data-button":!0,"data-action":!0,style:u.actionButtonStyle||A,onClick:de=>{Vr(u.action)&&(u.action.onClick==null||u.action.onClick.call(u.action,de),!de.defaultPrevented&&Dt())},className:$t(F?.actionButton,u==null||(d=u.classNames)==null?void 0:d.actionButton)},u.action.label):null)};function _c(){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 q_(e,t){const n={};return[e,t].forEach((s,o)=>{const a=o===1,i=a?"--mobile-offset":"--offset",c=a?F_:z_;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 G_=_.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:b,style:x,visibleToasts:h=$_,toastOptions:v,dir:k=_c(),gap:w=B_,icons:y,containerAriaLabel:j="Notifications"}=t,[R,E]=_.useState([]),C=_.useMemo(()=>s?R.filter(W=>W.toasterId===s):R.filter(W=>!W.toasterId),[R,s]),A=_.useMemo(()=>Array.from(new Set([a].concat(C.filter(W=>W.position).map(W=>W.position)))),[C,a]),[O,U]=_.useState([]),[M,B]=_.useState(!1),[$,q]=_.useState(!1),[F,Z]=_.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),D=_.useRef(null),N=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),I=_.useRef(null),G=_.useRef(!1),xe=_.useCallback(W=>{E(Q=>{var K;return(K=Q.find(le=>le.id===W.id))!=null&&K.delete||ut.dismiss(W.id),Q.filter(({id:le})=>le!==W.id)})},[]);return _.useEffect(()=>ut.subscribe(W=>{if(W.dismiss){requestAnimationFrame(()=>{E(Q=>Q.map(K=>K.id===W.id?{...K,delete:!0}:K))});return}setTimeout(()=>{Yo.flushSync(()=>{E(Q=>{const K=Q.findIndex(le=>le.id===W.id);return K!==-1?[...Q.slice(0,K),{...Q[K],...W},...Q.slice(K+1)]:[W,...Q]})})})}),[R]),_.useEffect(()=>{if(g!=="system"){Z(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const W=window.matchMedia("(prefers-color-scheme: dark)");try{W.addEventListener("change",({matches:Q})=>{Z(Q?"dark":"light")})}catch{W.addListener(({matches:K})=>{try{Z(K?"dark":"light")}catch(le){console.error(le)}})}},[g]),_.useEffect(()=>{R.length<=1&&B(!1)},[R]),_.useEffect(()=>{const W=Q=>{var K;if(i.every(Y=>Q[Y]||Q.code===Y)){var P;B(!0),(P=D.current)==null||P.focus()}Q.code==="Escape"&&(document.activeElement===D.current||(K=D.current)!=null&&K.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[i]),_.useEffect(()=>{if(D.current)return()=>{I.current&&(I.current.focus({preventScroll:!0}),I.current=null,G.current=!1)}},[D.current]),_.createElement("section",{ref:n,"aria-label":`${j} ${N}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((W,Q)=>{var K;const[le,P]=W.split("-");return C.length?_.createElement("ol",{key:W,dir:k==="auto"?_c():k,tabIndex:-1,ref:D,className:d,"data-sonner-toaster":!0,"data-sonner-theme":F,"data-y-position":le,"data-x-position":P,style:{"--front-toast-height":`${((K=O[0])==null?void 0:K.height)||0}px`,"--width":`${U_}px`,"--gap":`${w}px`,...x,...q_(f,u)},onBlur:Y=>{G.current&&!Y.currentTarget.contains(Y.relatedTarget)&&(G.current=!1,I.current&&(I.current.focus({preventScroll:!0}),I.current=null))},onFocus:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||G.current||(G.current=!0,I.current=Y.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{$||B(!1)},onDragEnd:()=>B(!1),onPointerDown:Y=>{Y.target instanceof HTMLElement&&Y.target.dataset.dismissible==="false"||q(!0)},onPointerUp:()=>q(!1)},C.filter(Y=>!Y.position&&Q===0||Y.position===W).map((Y,ue)=>{var V,ae;return _.createElement(Z_,{key:Y.id,icons:y,index:ue,toast:Y,defaultRichColors:p,duration:(V=v?.duration)!=null?V:b,className:v?.className,descriptionClassName:v?.descriptionClassName,invert:o,visibleToasts:h,closeButton:(ae=v?.closeButton)!=null?ae:l,interacting:$,position:W,style:v?.style,unstyled:v?.unstyled,classNames:v?.classNames,cancelButtonStyle:v?.cancelButtonStyle,actionButtonStyle:v?.actionButtonStyle,closeButtonAriaLabel:v?.closeButtonAriaLabel,removeToast:xe,toasts:C.filter(ce=>ce.position==Y.position),heights:O.filter(ce=>ce.position==Y.position),setHeights:U,expandByDefault:c,gap:w,expanded:M,swipeDirections:t.swipeDirections})})):null}))}),Va=m.createContext(null);function Y_(){const e=m.useContext(Va);if(!e)throw new Error("useToast must be used within ToastProvider");return e}function Ys(){return m.useContext(Va)}function Q_({children:e}){const t=m.useCallback(n=>{const s=n.title??"",o=n.description;D_(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(Va.Provider,{value:{toast:t},children:[e,r.jsx(G_,{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:Sf,setPrototypeOf:jc,isFrozen:K_,getPrototypeOf:J_,getOwnPropertyDescriptor:X_}=Object;let{freeze:at,seal:_t,create:Jr}=Object,{apply:Ho,construct:Zo}=typeof Reflect<"u"&&Reflect;at||(at=function(t){return t});_t||(_t=function(t){return t});Ho||(Ho=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)});Zo||(Zo=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 Wr=it(Array.prototype.forEach),ej=it(Array.prototype.lastIndexOf),Sc=it(Array.prototype.pop),rr=it(Array.prototype.push),tj=it(Array.prototype.splice),Xr=it(String.prototype.toLowerCase),vo=it(String.prototype.toString),yo=it(String.prototype.match),sr=it(String.prototype.replace),nj=it(String.prototype.indexOf),rj=it(String.prototype.trim),xt=it(Object.prototype.hasOwnProperty),st=it(RegExp.prototype.test),or=sj(TypeError);function it(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 Ho(e,t,s)}}function sj(e){return function(){for(var t=arguments.length,n=new Array(t),s=0;s<t;s++)n[s]=arguments[s];return Zo(e,n)}}function me(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xr;jc&&jc(e,null);let s=t.length;for(;s--;){let o=t[s];if(typeof o=="string"){const a=n(o);a!==o&&(K_(t)||(t[s]=a),o=a)}e[o]=!0}return e}function oj(e){for(let t=0;t<e.length;t++)xt(e,t)||(e[t]=null);return e}function zt(e){const t=Jr(null);for(const[n,s]of Sf(e))xt(e,n)&&(Array.isArray(s)?t[n]=oj(s):s&&typeof s=="object"&&s.constructor===Object?t[n]=zt(s):t[n]=s);return t}function ar(e,t){for(;e!==null;){const s=X_(e,t);if(s){if(s.get)return it(s.get);if(typeof s.value=="function")return it(s.value)}e=J_(e)}function n(){return null}return n}const Cc=at(["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"]),bo=at(["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"]),wo=at(["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"]),aj=at(["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"]),ko=at(["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"]),ij=at(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Nc=at(["#text"]),Ac=at(["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"]),_o=at(["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"]),Ec=at(["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=at(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),cj=_t(/\{\{[\w\W]*|[\w\W]*\}\}/gm),lj=_t(/<%[\w\W]*|[\w\W]*%>/gm),dj=_t(/\$\{[\w\W]*/gm),uj=_t(/^data-[\-\w.\u00B7-\uFFFF]+$/),fj=_t(/^aria-[\-\w]+$/),Cf=_t(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mj=_t(/^(?:\w+script|data):/i),pj=_t(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nf=_t(/^html$/i),hj=_t(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ic=Object.freeze({__proto__:null,ARIA_ATTR:fj,ATTR_WHITESPACE:pj,CUSTOM_ELEMENT:hj,DATA_ATTR:uj,DOCTYPE_NAME:Nf,ERB_EXPR:lj,IS_ALLOWED_URI:Cf,IS_SCRIPT_OR_DATA:mj,MUSTACHE_EXPR:cj,TMPLIT_EXPR:dj});const ir={element:1,text:3,progressingInstruction:7,comment:8,document:9},gj=function(){return typeof window>"u"?null:window},xj=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}},Tc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Af(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:gj();const t=oe=>Af(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,b=l.prototype,x=ar(b,"cloneNode"),h=ar(b,"remove"),v=ar(b,"nextSibling"),k=ar(b,"childNodes"),w=ar(b,"parentNode");if(typeof i=="function"){const oe=n.createElement("template");oe.content&&oe.content.ownerDocument&&(n=oe.content.ownerDocument)}let y,j="";const{implementation:R,createNodeIterator:E,createDocumentFragment:C,getElementsByTagName:A}=n,{importNode:O}=s;let U=Tc();t.isSupported=typeof Sf=="function"&&typeof w=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:M,ERB_EXPR:B,TMPLIT_EXPR:$,DATA_ATTR:q,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:Z,ATTR_WHITESPACE:D,CUSTOM_ELEMENT:N}=Ic;let{IS_ALLOWED_URI:I}=Ic,G=null;const xe=me({},[...Cc,...bo,...wo,...ko,...Nc]);let W=null;const Q=me({},[...Ac,..._o,...Ec,...Hr]);let K=Object.seal(Jr(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,P=null;const Y=Object.seal(Jr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ue=!0,V=!0,ae=!1,ce=!0,we=!1,Te=!0,We=!1,Qe=!1,He=!1,St=!1,Ke=!1,nn=!1,bt=!0,je=!1;const nt="user-content-";let ke=!0,qt=!1,pt={},ct=null;const T=me({},["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 ee=null;const se=me({},["audio","video","img","source","image","track"]);let ve=null;const ye=me({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Pe="http://www.w3.org/1998/Math/MathML",Nn="http://www.w3.org/2000/svg",wt="http://www.w3.org/1999/xhtml";let Gt=wt,Xn=!1,gn=null;const Dt=me({},[Pe,Nn,wt],vo);let An=me({},["mi","mo","mn","ms","mtext"]),En=me({},["annotation-xml"]);const Ir=me({},["title","style","font","a","script"]);let rn=null;const de=["application/xhtml+xml","text/html"],De="text/html";let he=null,$e=null;const In=n.createElement("form"),ze=function(S){return S instanceof RegExp||S instanceof Function},Je=function(){let S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!($e&&$e===S)){if((!S||typeof S!="object")&&(S={}),S=zt(S),rn=de.indexOf(S.PARSER_MEDIA_TYPE)===-1?De:S.PARSER_MEDIA_TYPE,he=rn==="application/xhtml+xml"?vo:Xr,G=xt(S,"ALLOWED_TAGS")?me({},S.ALLOWED_TAGS,he):xe,W=xt(S,"ALLOWED_ATTR")?me({},S.ALLOWED_ATTR,he):Q,gn=xt(S,"ALLOWED_NAMESPACES")?me({},S.ALLOWED_NAMESPACES,vo):Dt,ve=xt(S,"ADD_URI_SAFE_ATTR")?me(zt(ye),S.ADD_URI_SAFE_ATTR,he):ye,ee=xt(S,"ADD_DATA_URI_TAGS")?me(zt(se),S.ADD_DATA_URI_TAGS,he):se,ct=xt(S,"FORBID_CONTENTS")?me({},S.FORBID_CONTENTS,he):T,le=xt(S,"FORBID_TAGS")?me({},S.FORBID_TAGS,he):zt({}),P=xt(S,"FORBID_ATTR")?me({},S.FORBID_ATTR,he):zt({}),pt=xt(S,"USE_PROFILES")?S.USE_PROFILES:!1,ue=S.ALLOW_ARIA_ATTR!==!1,V=S.ALLOW_DATA_ATTR!==!1,ae=S.ALLOW_UNKNOWN_PROTOCOLS||!1,ce=S.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=S.SAFE_FOR_TEMPLATES||!1,Te=S.SAFE_FOR_XML!==!1,We=S.WHOLE_DOCUMENT||!1,St=S.RETURN_DOM||!1,Ke=S.RETURN_DOM_FRAGMENT||!1,nn=S.RETURN_TRUSTED_TYPE||!1,He=S.FORCE_BODY||!1,bt=S.SANITIZE_DOM!==!1,je=S.SANITIZE_NAMED_PROPS||!1,ke=S.KEEP_CONTENT!==!1,qt=S.IN_PLACE||!1,I=S.ALLOWED_URI_REGEXP||Cf,Gt=S.NAMESPACE||wt,An=S.MATHML_TEXT_INTEGRATION_POINTS||An,En=S.HTML_INTEGRATION_POINTS||En,K=S.CUSTOM_ELEMENT_HANDLING||{},S.CUSTOM_ELEMENT_HANDLING&&ze(S.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(K.tagNameCheck=S.CUSTOM_ELEMENT_HANDLING.tagNameCheck),S.CUSTOM_ELEMENT_HANDLING&&ze(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),we&&(V=!1),Ke&&(St=!0),pt&&(G=me({},Nc),W=Jr(null),pt.html===!0&&(me(G,Cc),me(W,Ac)),pt.svg===!0&&(me(G,bo),me(W,_o),me(W,Hr)),pt.svgFilters===!0&&(me(G,wo),me(W,_o),me(W,Hr)),pt.mathMl===!0&&(me(G,ko),me(W,Ec),me(W,Hr))),xt(S,"ADD_TAGS")||(Y.tagCheck=null),xt(S,"ADD_ATTR")||(Y.attributeCheck=null),S.ADD_TAGS&&(typeof S.ADD_TAGS=="function"?Y.tagCheck=S.ADD_TAGS:(G===xe&&(G=zt(G)),me(G,S.ADD_TAGS,he))),S.ADD_ATTR&&(typeof S.ADD_ATTR=="function"?Y.attributeCheck=S.ADD_ATTR:(W===Q&&(W=zt(W)),me(W,S.ADD_ATTR,he))),S.ADD_URI_SAFE_ATTR&&me(ve,S.ADD_URI_SAFE_ATTR,he),S.FORBID_CONTENTS&&(ct===T&&(ct=zt(ct)),me(ct,S.FORBID_CONTENTS,he)),S.ADD_FORBID_CONTENTS&&(ct===T&&(ct=zt(ct)),me(ct,S.ADD_FORBID_CONTENTS,he)),ke&&(G["#text"]=!0),We&&me(G,["html","head","body"]),G.table&&(me(G,["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.');y=S.TRUSTED_TYPES_POLICY,j=y.createHTML("")}else y===void 0&&(y=xj(p,o)),y!==null&&typeof j=="string"&&(j=y.createHTML(""));at&&at(S),$e=S}},xn=me({},[...bo,...wo,...aj]),lt=me({},[...ko,...ij]),ht=function(S){let H=w(S);(!H||!H.tagName)&&(H={namespaceURI:Gt,tagName:"template"});const re=Xr(S.tagName),Se=Xr(H.tagName);return gn[S.namespaceURI]?S.namespaceURI===Nn?H.namespaceURI===wt?re==="svg":H.namespaceURI===Pe?re==="svg"&&(Se==="annotation-xml"||An[Se]):!!xn[re]:S.namespaceURI===Pe?H.namespaceURI===wt?re==="math":H.namespaceURI===Nn?re==="math"&&En[Se]:!!lt[re]:S.namespaceURI===wt?H.namespaceURI===Nn&&!En[Se]||H.namespaceURI===Pe&&!An[Se]?!1:!lt[re]&&(Ir[re]||!xn[re]):!!(rn==="application/xhtml+xml"&&gn[S.namespaceURI]):!1},gt=function(S){rr(t.removed,{element:S});try{w(S).removeChild(S)}catch{h(S)}},rt=function(S,H){try{rr(t.removed,{attribute:H.getAttributeNode(S),from:H})}catch{rr(t.removed,{attribute:null,from:H})}if(H.removeAttribute(S),S==="is")if(St||Ke)try{gt(H)}catch{}else try{H.setAttribute(S,"")}catch{}},Xs=function(S){let H=null,re=null;if(He)S="<remove></remove>"+S;else{const Fe=yo(S,/^[\r\n\t ]+/);re=Fe&&Fe[0]}rn==="application/xhtml+xml"&&Gt===wt&&(S='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+S+"</body></html>");const Se=y?y.createHTML(S):S;if(Gt===wt)try{H=new g().parseFromString(Se,rn)}catch{}if(!H||!H.documentElement){H=R.createDocument(Gt,"template",null);try{H.documentElement.innerHTML=Xn?j:Se}catch{}}const Xe=H.body||H.documentElement;return S&&re&&Xe.insertBefore(n.createTextNode(re),Xe.childNodes[0]||null),Gt===wt?A.call(H,We?"html":"body")[0]:We?H.documentElement:Xe},ni=function(S){return E.call(S.ownerDocument||S,S,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},eo=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")},ri=function(S){return typeof c=="function"&&S instanceof c};function Yt(oe,S,H){Wr(oe,re=>{re.call(t,S,H,$e)})}const si=function(S){let H=null;if(Yt(U.beforeSanitizeElements,S,null),eo(S))return gt(S),!0;const re=he(S.nodeName);if(Yt(U.uponSanitizeElement,S,{tagName:re,allowedTags:G}),Te&&S.hasChildNodes()&&!ri(S.firstElementChild)&&st(/<[/\w!]/g,S.innerHTML)&&st(/<[/\w!]/g,S.textContent)||S.nodeType===ir.progressingInstruction||Te&&S.nodeType===ir.comment&&st(/<[/\w]/g,S.data))return gt(S),!0;if(!(Y.tagCheck instanceof Function&&Y.tagCheck(re))&&(!G[re]||le[re])){if(!le[re]&&ai(re)&&(K.tagNameCheck instanceof RegExp&&st(K.tagNameCheck,re)||K.tagNameCheck instanceof Function&&K.tagNameCheck(re)))return!1;if(ke&&!ct[re]){const Se=w(S)||S.parentNode,Xe=k(S)||S.childNodes;if(Xe&&Se){const Fe=Xe.length;for(let dt=Fe-1;dt>=0;--dt){const Qt=x(Xe[dt],!0);Qt.__removalCount=(S.__removalCount||0)+1,Se.insertBefore(Qt,v(S))}}}return gt(S),!0}return S instanceof l&&!ht(S)||(re==="noscript"||re==="noembed"||re==="noframes")&&st(/<\/no(script|embed|frames)/i,S.innerHTML)?(gt(S),!0):(we&&S.nodeType===ir.text&&(H=S.textContent,Wr([M,B,$],Se=>{H=sr(H,Se," ")}),S.textContent!==H&&(rr(t.removed,{element:S.cloneNode()}),S.textContent=H)),Yt(U.afterSanitizeElements,S,null),!1)},oi=function(S,H,re){if(P[H]||bt&&(H==="id"||H==="name")&&(re in n||re in In))return!1;if(!(V&&!P[H]&&st(q,H))){if(!(ue&&st(F,H))){if(!(Y.attributeCheck instanceof Function&&Y.attributeCheck(H,S))){if(!W[H]||P[H]){if(!(ai(S)&&(K.tagNameCheck instanceof RegExp&&st(K.tagNameCheck,S)||K.tagNameCheck instanceof Function&&K.tagNameCheck(S))&&(K.attributeNameCheck instanceof RegExp&&st(K.attributeNameCheck,H)||K.attributeNameCheck instanceof Function&&K.attributeNameCheck(H,S))||H==="is"&&K.allowCustomizedBuiltInElements&&(K.tagNameCheck instanceof RegExp&&st(K.tagNameCheck,re)||K.tagNameCheck instanceof Function&&K.tagNameCheck(re))))return!1}else if(!ve[H]){if(!st(I,sr(re,D,""))){if(!((H==="src"||H==="xlink:href"||H==="href")&&S!=="script"&&nj(re,"data:")===0&&ee[S])){if(!(ae&&!st(Z,sr(re,D,"")))){if(re)return!1}}}}}}}return!0},ai=function(S){return S!=="annotation-xml"&&yo(S,N)},ii=function(S){Yt(U.beforeSanitizeAttributes,S,null);const{attributes:H}=S;if(!H||eo(S))return;const re={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let Se=H.length;for(;Se--;){const Xe=H[Se],{name:Fe,namespaceURI:dt,value:Qt}=Xe,Tn=he(Fe),to=Qt;let Ze=Fe==="value"?to:rj(to);if(re.attrName=Tn,re.attrValue=Ze,re.keepAttr=!0,re.forceKeepAttr=void 0,Yt(U.uponSanitizeAttribute,S,re),Ze=re.attrValue,je&&(Tn==="id"||Tn==="name")&&(rt(Fe,S),Ze=nt+Ze),Te&&st(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ze)){rt(Fe,S);continue}if(Tn==="attributename"&&yo(Ze,"href")){rt(Fe,S);continue}if(re.forceKeepAttr)continue;if(!re.keepAttr){rt(Fe,S);continue}if(!ce&&st(/\/>/i,Ze)){rt(Fe,S);continue}we&&Wr([M,B,$],li=>{Ze=sr(Ze,li," ")});const ci=he(S.nodeName);if(!oi(ci,Tn,Ze)){rt(Fe,S);continue}if(y&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!dt)switch(p.getAttributeType(ci,Tn)){case"TrustedHTML":{Ze=y.createHTML(Ze);break}case"TrustedScriptURL":{Ze=y.createScriptURL(Ze);break}}if(Ze!==to)try{dt?S.setAttributeNS(dt,Fe,Ze):S.setAttribute(Fe,Ze),eo(S)?gt(S):Sc(t.removed)}catch{rt(Fe,S)}}Yt(U.afterSanitizeAttributes,S,null)},Hf=function oe(S){let H=null;const re=ni(S);for(Yt(U.beforeSanitizeShadowDOM,S,null);H=re.nextNode();)Yt(U.uponSanitizeShadowNode,H,null),si(H),ii(H),H.content instanceof a&&oe(H.content);Yt(U.afterSanitizeShadowDOM,S,null)};return t.sanitize=function(oe){let S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},H=null,re=null,Se=null,Xe=null;if(Xn=!oe,Xn&&(oe="<!-->"),typeof oe!="string"&&!ri(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||Je(S),t.removed=[],typeof oe=="string"&&(qt=!1),qt){if(oe.nodeName){const Qt=he(oe.nodeName);if(!G[Qt]||le[Qt])throw or("root node is forbidden and cannot be sanitized in-place")}}else if(oe instanceof c)H=Xs("<!---->"),re=H.ownerDocument.importNode(oe,!0),re.nodeType===ir.element&&re.nodeName==="BODY"||re.nodeName==="HTML"?H=re:H.appendChild(re);else{if(!St&&!we&&!We&&oe.indexOf("<")===-1)return y&&nn?y.createHTML(oe):oe;if(H=Xs(oe),!H)return St?null:nn?j:""}H&&He&>(H.firstChild);const Fe=ni(qt?oe:H);for(;Se=Fe.nextNode();)si(Se),ii(Se),Se.content instanceof a&&Hf(Se.content);if(qt)return oe;if(St){if(Ke)for(Xe=C.call(H.ownerDocument);H.firstChild;)Xe.appendChild(H.firstChild);else Xe=H;return(W.shadowroot||W.shadowrootmode)&&(Xe=O.call(s,Xe,!0)),Xe}let dt=We?H.outerHTML:H.innerHTML;return We&&G["!doctype"]&&H.ownerDocument&&H.ownerDocument.doctype&&H.ownerDocument.doctype.name&&st(Nf,H.ownerDocument.doctype.name)&&(dt="<!DOCTYPE "+H.ownerDocument.doctype.name+`>
|
|
84
|
-
`+dt),we&&Wr([M,B,$],Qt=>{dt=sr(dt,Qt," ")}),y&&nn?y.createHTML(dt):dt},t.setConfig=function(){let oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Je(oe),Qe=!0},t.clearConfig=function(){$e=null,Qe=!1},t.isValidAttribute=function(oe,S,H){$e||Je({});const re=he(oe),Se=he(S);return oi(re,Se,H)},t.addHook=function(oe,S){typeof S=="function"&&rr(U[oe],S)},t.removeHook=function(oe,S){if(S!==void 0){const H=ej(U[oe],S);return H===-1?void 0:tj(U[oe],H,1)[0]}return Sc(U[oe])},t.removeHooks=function(oe){U[oe]=[]},t.removeAllHooks=function(){U=Tc()},t}var jo=Af();function Ef({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:L("border border-neutral-200 rounded-lg overflow-hidden dark:border-neutral-800",t),children:[r.jsxs("button",{type:"button",onClick:u,className:L("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:L("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:(()=>{jo.addHook("afterSanitizeAttributes",p=>{p.tagName==="A"&&p.setAttribute("rel","noopener noreferrer")});const g=jo.sanitize(e.answer,{ALLOWED_TAGS:["b","i","em","strong","a","p","br","ul","ol","li"],ALLOWED_ATTR:["href","target","rel"]});return jo.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 vj({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:L("text-center py-8 text-neutral-500 dark:text-neutral-400",t),children:a}):r.jsx("div",{className:L("space-y-2",t),children:l.map(d=>r.jsx(Ef,{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 Be({amount:e,currency:t}){return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e)}function Qs({amount:e,currency:t,compareAt:n,className:s,size:o="default"}){const a=typeof n=="number"&&n>e;return r.jsxs("div",{className:L("flex items-baseline gap-2 tabular-nums",s),children:[r.jsx("span",{className:L("font-semibold",o==="sm"?"text-sm":"text-base"),children:Be({amount:e,currency:t})}),a?r.jsx("span",{className:L("text-neutral-500 line-through dark:text-neutral-400",o==="sm"?"text-xs":"text-sm"),children:Be({amount:n,currency:t})}):null]})}const yj={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"}},bj={label:"Tokenized Asset",className:"bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300"};function Wa({assetClass:e}){const{label:t,className:n}=yj[e.toLowerCase()]??bj;return r.jsx(Xt,{className:n,children:t})}const Pc={large:"aspect-[4/5]",square:"aspect-square",compact:"aspect-[3/4]"},Rc={center:"object-center",top:"object-top",bottom:"object-bottom",left:"object-left",right:"object-right"};function If({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(kt,{className:L("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:L("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Pc[a]),children:r.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:L("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Rc[i]),loading:"lazy"})})}):r.jsx("div",{className:L("overflow-hidden bg-neutral-100 dark:bg-neutral-900",Pc[a]),children:r.jsx("img",{src:e.images[0]?.url,alt:e.images[0]?.alt??e.title,className:L("h-full w-full object-cover transition-transform duration-300 group-hover:scale-[1.03]",Rc[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(Xt,{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(Wa,{assetClass:e.tokenizedAssetConfig?.assetClass??""})}):null,c?r.jsx("div",{className:"pointer-events-none absolute left-3 top-3",children:r.jsx(Xt,{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(Xt,{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:L("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:L("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(Qs,{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:L("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 Ks({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"},b=L("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:L(b,a),children:e.map(x=>r.jsx(If,{product:x,href:o?o(x):void 0,onAddToCart:n,onQuickView:s,layout:i,imageCrop:c},x.id))})}function Ha({images:e,className:t}){const[n,s]=m.useState(0),o=e[n];return e.length===0?r.jsx("div",{className:L("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:L("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:L("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 wj(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 kj(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 Oc(e,t){return e.find(n=>Object.entries(t).every(([s,o])=>n.options[s]===o))??null}function Tf(e){return e.inventoryStatus==="out_of_stock"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity<=0}function _j(e){return e.inventoryStatus==="low"||typeof e.inventoryQuantity=="number"&&e.inventoryQuantity>0&&e.inventoryQuantity<=5}function jj(e){const t=Tf(e),n=!t&&_j(e),s=typeof e.inventoryQuantity=="number"?e.inventoryQuantity:void 0;return{isOutOfStock:t,isLow:n,quantity:s}}function Sj(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=>!Tf(i))}function Za({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(()=>wj(i),[i]),l=m.useMemo(()=>Oc(i,t.selectedOptions),[i,t.selectedOptions]),d=m.useMemo(()=>l?jj(l):null,[l]);return i.length===0||c.length===0?null:r.jsxs("div",{className:L("space-y-4",s),children:[c.map(f=>{const u=kj(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 b=p===g,x=Sj(i,t.selectedOptions,f,p),h=a&&!x;return r.jsxs(X,{type:"button",size:"sm",variant:b?"default":"outline",onClick:()=>{const v={...t.selectedOptions,[f]:p},k=Oc(i,v);n({selectedOptions:v,variant:k})},"aria-pressed":b,disabled:h,className:L(!x&&!h&&"opacity-50 line-through"),children:[p,!x&&!h&&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 qa({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:L("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(Oe,{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 Ga({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 x=e.variants[0];d({selectedOptions:{...x.options},variant:x})}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,b=l.variant?g:p;return r.jsx(Ia,{open:t,onOpenChange:n,children:r.jsxs($s,{className:L("max-w-3xl",a),children:[r.jsx(Pa,{children:r.jsxs(zs,{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(Ha,{images:e.images}),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{children:[r.jsx(Qs,{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(Za,{product:e,value:{selectedOptions:l.selectedOptions,variantId:l.variant?.id},onChange:x=>d(x)}),r.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[r.jsx(qa,{qty:i,onChange:c}),r.jsx(X,{type:"button",className:"flex-1",disabled:b,onClick:()=>{o(e,l.variant,i),n(!1)},children:b?"Out of stock":"Add to cart"})]}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:b?"Out of stock":"In stock"})]})]})]})})}function qo({categories:e,activeSlug:t,onSelect:n,className:s}){return r.jsx("nav",{className:L("space-y-1",s),"aria-label":"Categories",children:e.map(o=>{const a=t===o.slug;return r.jsxs("button",{type:"button",className:L("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 Ya({items:e,className:t}){return r.jsx("nav",{className:L("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 Qa({value:e,onChange:t,placeholder:n="Search products…",className:s}){return r.jsxs("div",{className:L("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(Oe,{value:e,onChange:o=>t(o.target.value),placeholder:n,className:"pl-9","aria-label":"Search"})]})}function gs({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:L("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(ft,{}),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 b=new Set(c);p.target.checked?b.add(g):b.delete(g),n({...t,tags:Array.from(b)})}}),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(tt,{className:"text-xs",htmlFor:"price-min",children:"Min"}),r.jsx(Oe,{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(tt,{className:"text-xs",htmlFor:"price-max",children:"Max"}),r.jsx(Oe,{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 Mc(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 Cj(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 Ka({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:L("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:Be({amount:i,currency:e.currency})}),u&&r.jsxs("div",{className:L("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(Mc,{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(Cj,{className:"h-4 w-4"}):"-"}),r.jsx(Oe,{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 b=Math.max(1,d?Math.min(d,p):p);n(b)},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:L("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:Be({amount:i,currency:e.currency})})]}),r.jsxs("div",{className:"mt-1 text-xs text-neutral-600 dark:text-neutral-400",children:[Be({amount:e.unitPrice,currency:e.currency})," each"]}),u&&r.jsxs("div",{className:L("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(Mc,{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(Oe,{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 b=Math.max(1,d?Math.min(d,p):p);n(b)},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:Be({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 Ja({currency:e,subtotal:t,itemCount:n,onCheckout:s,isCheckoutDisabled:o,checkoutDisabledReason:a,onRemoveUnavailable:i,className:c}){return r.jsxs("div",{className:L("space-y-4",c),children:[r.jsx(ft,{}),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:Be({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 Pf({onCheckout:e,className:t}){const{config:n}=Ee(),s=Ot(),{getItemInventory:o,hasIssues:a}=da({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(Vn,{title:"Cart is empty",description:"Add items from the catalog to check out.",className:t}):r.jsxs("div",{className:L("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(Ka,{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(Ja,{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 Rf=m.forwardRef(({className:e,...t},n)=>r.jsx("textarea",{ref:n,className:L("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}));Rf.displayName="Textarea";function Nj(){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 Lc({children:e,className:t}){const n=m.useRef(null),s=Nj();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 So(){return`${Date.now()}_${Math.random().toString(16).slice(2)}`}function Of({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:So(),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 b=0;const x=window.setInterval(()=>{b=(b+1)%p.length,l(p[b])},450);return()=>window.clearInterval(x)},[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 b=120;p.style.height="0px";const x=Math.min(b,Math.max(40,p.scrollHeight));p.style.height=`${x}px`,p.style.overflowY=p.scrollHeight>b?"auto":"hidden"},[]);m.useEffect(()=>{u()},[t,u]);const g=m.useCallback(()=>{const p=t.trim();p&&(i(b=>[...b,{id:So(),role:"user",text:p,createdAt:Date.now()}]),n(""),o(!0),window.setTimeout(()=>{i(b=>[...b,{id:So(),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:L("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(Lc,{className:L("flex",p.role==="user"?"justify-end":"justify-start"),children:r.jsx("div",{className:L("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(Lc,{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(Rf,{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(Fs,{modal:!1,open:n,onOpenChange:s,children:[e?r.jsx(Us,{asChild:!0,children:e}):null,r.jsxs(Ar,{side:t,overlayClassName:t==="popup"?"pointer-events-none bg-transparent backdrop-blur-none":"pointer-events-none bg-neutral-950/40 backdrop-blur-none",className:L(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(Bs,{className:"space-y-0",children:r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx(Ba,{value:c,onValueChange:d=>l(d),children:r.jsxs(Gs,{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(Mu,{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(Of,{className:"h-full"})})]}):r.jsx(Pf,{onCheckout:()=>{o(),s?.(!1)},className:"h-full border-0 bg-transparent p-0 shadow-none"})})]})]})}function Xa({value:e,onApply:t,className:n}){const[s,o]=m.useState(e??"");return m.useEffect(()=>{o(e??"")},[e]),r.jsxs("div",{className:L("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(Oe,{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 Mf({onCheckout:e,showPromoCode:t,className:n}){const{config:s}=Ee(),o=Ot(),{getItemInventory:a,hasIssues:i}=da({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(Vn,{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:L("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(Ka,{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(ft,{className:"my-4"}),r.jsxs("div",{className:"space-y-4",children:[t?r.jsx(Xa,{value:o.promoCode,onApply:o.setPromoCode}):null,r.jsx(Ja,{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 Lf({left:e,right:t,className:n}){return r.jsxs("div",{className:L("grid items-start gap-8 lg:grid-cols-[1fr_420px]",n),children:[r.jsx("div",{children:e}),r.jsx("div",{children:t})]})}function Go({title:e,value:t,onChange:n,errors:s,className:o}){return r.jsxs("section",{className:L("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(tt,{htmlFor:`${e}-line1`,children:"Address line 1"}),r.jsx(Oe,{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(tt,{htmlFor:`${e}-line2`,children:"Address line 2"}),r.jsx(Oe,{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(tt,{htmlFor:`${e}-city`,children:"City"}),r.jsx(Oe,{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(tt,{htmlFor:`${e}-state`,children:"State"}),r.jsx(Oe,{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(tt,{htmlFor:`${e}-postal`,children:"Postal code"}),r.jsx(Oe,{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(tt,{htmlFor:`${e}-country`,children:"Country"}),r.jsx(Oe,{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 Df({methods:e,value:t,onChange:n,currency:s,className:o}){return e.length===0?null:r.jsxs("section",{className:L("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:Be({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 $f({className:e}){const{config:t}=Ee(),n=ks(),s=Ot(),o=t.checkout.mode,a=m.useMemo(()=>Gr(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(p=>p.metadata?.product_type==="gift_card"),d={line1:"",line2:"",city:"",state:"",postalCode:"",country:"US"},f=n.values.shippingAddress??d,u=n.values.billingAddress??d,g=Ol({enabled:!!t.adapter.getShippingMethods&&i,customer:{email:n.values.email||void 0,name:n.values.name||void 0,shippingAddress:f}});return r.jsxs("form",{className:L("space-y-6",e),onSubmit:p=>p.preventDefault(),children:[a.isDigitalOnly?r.jsx(kt,{className:"rounded-2xl",children:r.jsxs(Tt,{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(kt,{className:"rounded-2xl border-red-200 bg-red-50 dark:border-red-900/40 dark:bg-red-950/30",children:r.jsxs(Tt,{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(tt,{htmlFor:"checkout-email",children:"Email"}),r.jsx(Oe,{id:"checkout-email",value:n.values.email??"",onChange:p=>n.setField("email",p.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(tt,{htmlFor:"checkout-name",children:"Name"}),r.jsx(Oe,{id:"checkout-name",value:n.values.name??"",onChange:p=>n.setField("name",p.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(tt,{htmlFor:"checkout-phone",children:"Phone"}),r.jsx(Oe,{id:"checkout-phone",value:n.values.phone??"",onChange:p=>n.setField("phone",p.target.value),placeholder:"Phone number","aria-invalid":!!n.fieldErrors.phone,required:a.phone==="required"}),r.jsx(Zr,{message:n.fieldErrors.phone})]}):null]})]}):null,l?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:"Gift card recipient"}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Optional"})]}),r.jsxs("div",{className:"grid gap-2",children:[r.jsx(tt,{htmlFor:"checkout-recipient-email",children:"Recipient email"}),r.jsx(Oe,{id:"checkout-recipient-email",type:"email",value:n.values.recipientEmail??"",onChange:p=>n.setField("recipientEmail",p.target.value),placeholder:"recipient@example.com","aria-invalid":!!n.fieldErrors.recipientEmail}),r.jsx(Zr,{message:n.fieldErrors.recipientEmail}),r.jsx("div",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:"Leave blank to credit your own account. If provided, the gift card value will be credited to the recipient's account."})]})]}):null,i?r.jsx(Go,{title:"Shipping address",value:f,onChange:p=>n.setField("shippingAddress",p),errors:{line1:n.fieldErrors["shippingAddress.line1"],city:n.fieldErrors["shippingAddress.city"],postalCode:n.fieldErrors["shippingAddress.postalCode"],country:n.fieldErrors["shippingAddress.country"]}}):null,i&&g.methods.length?r.jsx(Df,{methods:g.methods,value:n.values.shippingMethodId,onChange:p=>n.setField("shippingMethodId",p),currency:t.currency}):null,o==="full"?r.jsx(Go,{title:"Billing address",value:u,onChange:p=>n.setField("billingAddress",p)}):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(tt,{htmlFor:"checkout-tip",children:["Tip amount (",t.currency,")"]}),r.jsx(Oe,{id:"checkout-tip",inputMode:"decimal",value:String(n.values.tipAmount??0),onChange:p=>n.setField("tipAmount",Number(p.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(tt,{htmlFor:"checkout-notes",children:"Order notes (optional)"}),r.jsx(Oe,{id:"checkout-notes",value:n.values.notes??"",onChange:p=>n.setField("notes",p.target.value),placeholder:"Delivery instructions, gift note…"})]})]}):null]})}function Aj(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 Ej(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 zf({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(Ia,{open:e,onOpenChange:t,children:r.jsxs($s,{className:L("sm:max-w-lg",i),children:[r.jsxs(Pa,{children:[r.jsxs(zs,{className:"flex items-center gap-2",children:[r.jsx(Aj,{className:"h-5 w-5 text-amber-500"}),"Inventory Update"]}),r.jsx(Ra,{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(Ij,{issue:l,onRemove:()=>s(l.productId,l.variantId),onUpdateQty:d=>o(l.productId,l.variantId,d)},`${l.productId}::${l.variantId??""}`))}),r.jsxs(Ou,{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 Ij({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:L("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(Ej,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Remove"})]})]})]})}function Ff({className:e,ctaLabel:t,renderEmbedded:n,embeddedFallback:s,renderCustom:o,customFallback:a}){const{config:i}=Ee(),c=Ot(),l=ks(),{config:d,isLoading:f}=Ll(),[u,g]=m.useState(!1);m.useEffect(()=>{let M=!0;return Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js")).then(B=>{M&&g(B.detectSolanaWallets())}),()=>{M=!1}},[]);const p=Ml({items:c.items}),[b,x]=m.useState(!1),h=m.useMemo(()=>i.checkout.paymentMethods&&i.checkout.paymentMethods.length?i.checkout.paymentMethods:[{id:"card",label:"Card",ctaLabel:"Pay now"}],[i.checkout.paymentMethods]),v=m.useMemo(()=>h.filter(B=>!(B.id==="card"&&!d.card||B.id==="crypto"&&!d.crypto||B.id==="credits"&&!d.credits||B.id==="crypto"&&!u)),[u,h,d]),[k,w]=m.useState((v[0]??h[0])?.id??"card");m.useEffect(()=>{v.length&&(v.some(M=>M.id===k)||w(v[0].id))},[k,v]),m.useEffect(()=>{l.reset()},[k]);const y=v.find(M=>M.id===k)??h.find(M=>M.id===k)??h[0]??{ctaLabel:"Pay now"},j=y.description??(k==="crypto"?"Pay using a connected wallet.":void 0),R=k==="crypto"&&!u,E=f||l.status==="validating"||l.status==="creating_session"||l.status==="redirecting"||p.isVerifying,C=t??y.ctaLabel??(i.checkout.mode==="none"?"Continue to payment":"Pay now"),A=m.useCallback(async M=>{const B=await p.verify();if(!B.ok&&B.issues.length>0){x(!0);return}l.createCheckoutSession({paymentMethodId:M})},[l,p]),O=l.session?.kind==="embedded"?l.session:null,U=l.session?.kind==="custom"?l.session:null;return r.jsxs("div",{className:L("space-y-3",e),children:[v.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(Ba,{value:k,onValueChange:w,children:r.jsx(Gs,{className:"w-full",children:v.map(M=>r.jsx(_r,{value:M.id,className:"flex-1",disabled:E,children:M.label},M.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,U?r.jsx("div",{className:"space-y-3",children:o?o(U):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."})}):O?r.jsx("div",{className:"space-y-3",children:n?n(O):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||E||R,onClick:()=>{A(k)},children:p.isVerifying?"Checking availability…":E?"Processing…":C}),!O&&!U?r.jsx("p",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:R?"Install a browser wallet to enable crypto payments.":j??"You will be redirected to complete your payment."}):null,r.jsx(zf,{open:b,onOpenChange:M=>{x(M),M||p.reset()},issues:p.result?.issues??[],onRemoveItem:(M,B)=>{c.removeItem(M,B)},onUpdateQuantity:(M,B,$)=>{c.setQty(M,B,$)}})]})}function Uf({className:e}){const{config:t}=Ee(),n=Ot(),s=ks(),{settings:o}=Hn(),a=(t.checkout.allowPromoCodes??!1)&&o.checkout.promoCodes;return r.jsxs("div",{className:L("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(ft,{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:Be({amount:i.unitPrice*i.qty,currency:i.currency})})]},`${i.productId}::${i.variantId??""}`))}),r.jsx(ft,{className:"my-3"}),a?r.jsx(Xa,{value:s.values.discountCode??n.promoCode,onApply:i=>{s.setField("discountCode",i??""),n.setPromoCode(i)}}):null,a?r.jsx(ft,{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:Be({amount:n.subtotal,currency:t.currency})})]})]})}function qe(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 Co(e){const t={"Content-Type":"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t}function Tj({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(Xt,{className:t[e]??"bg-neutral-100 text-neutral-700",children:n})}function Pj({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:L(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 ei({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,b]=m.useState(null),x=m.useCallback((v,k)=>{f(w=>({...w,[v]:k}))},[]);m.useEffect(()=>{if(s!=="already_submitted"&&s!=="success")return;const v=Co(n),w=setInterval(async()=>{try{const y=await fetch(`${e}/paywall/v1/asset-redemption/${t}/status`,{headers:v});if(!y.ok)return;const j=await y.json();j.redemptions?.length&&(l(j.redemptions[0].status),s==="success"&&o("already_submitted"))}catch{}},3e4);return()=>clearInterval(w)},[s,e,t,n]),m.useEffect(()=>{let v=!1;const k=Co(n);async function w(){try{const y=await fetch(`${e}/paywall/v1/asset-redemption/${t}/status`,{headers:k});if(!v&&y.ok){const E=await y.json();if(E.redemptions?.length){l(E.redemptions[0].status),o("already_submitted");return}}const j=await fetch(`${e}/paywall/v1/asset-redemption/${t}/form`,{headers:k});if(v)return;if(!j.ok)throw new Error(`Server error: ${j.status}`);const R=await j.json();if(!R.redemptionConfig){o("no_config");return}i(R.redemptionConfig),o("form")}catch(y){v||(b(y instanceof Error?y.message:"Failed to load redemption form."),o("form"))}}return w(),()=>{v=!0}},[e,t,n]);const h=m.useCallback(async v=>{v.preventDefault(),g(!0),b(null);try{const k=await fetch(`${e}/paywall/v1/asset-redemption/${t}/submit`,{method:"POST",headers:Co(n),body:JSON.stringify({formData:d})});if(!k.ok){const w=await k.text();throw new Error(w||`Server error: ${k.status}`)}o("success")}catch(k){b(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(Tj,{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:v=>{h(v)},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(v=>r.jsxs("div",{className:"space-y-1.5",children:[r.jsxs("label",{htmlFor:v.id,className:"block text-sm font-medium text-neutral-900 dark:text-neutral-50",children:[v.label,v.required?r.jsx("span",{className:"ml-1 text-red-500","aria-hidden":"true",children:"*"}):null]}),r.jsx(Pj,{field:v,value:d[v.id]??"",onChange:k=>x(v.id,k)})]},v.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 Js({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:L("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:Be({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:[qe(e.order.receiptUrl)?r.jsx("a",{href:qe(e.order.receiptUrl),className:"hover:underline",children:"Receipt"}):null,qe(e.order.invoiceUrl)?r.jsx("a",{href:qe(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(ei,{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:L("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:L("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 Rj({onContinueShopping:e,onViewOrders:t,className:n,receiptClassName:s,serverUrl:o,authToken:a,tokenizedProductIds:i}){const c=ia();return c.kind==="idle"?r.jsx("div",{className:L("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:L("flex min-h-[50vh] items-center justify-center p-4",n),children:r.jsx(Js,{result:c,onContinueShopping:e,onViewOrders:t,className:L("w-full max-w-lg",s),serverUrl:o,authToken:a,tokenizedProductIds:i})})}function Oj({onContinueShopping:e,className:t,receiptClassName:n}){const s={kind:"cancel"};return r.jsx("div",{className:L("flex min-h-[50vh] items-center justify-center p-4",t),children:r.jsx(Js,{result:s,onContinueShopping:e,className:L("w-full max-w-lg",n)})})}function Mj(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 Bf({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(kt,{className:L("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(Tt,{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(Xt,{variant:Mj(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:Be({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:[qe(e.receiptUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:qe(e.receiptUrl),target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,qe(e.invoiceUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:qe(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 Vf({orders:e,onView:t,className:n}){return r.jsx("div",{className:L("grid gap-4",n),children:e.map(s=>r.jsx(Bf,{order:s,onView:t},s.id))})}function Lj(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 Wf({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(l=>l.tokenizedAsset&&l.productId);return r.jsx(kt,{className:L("overflow-hidden rounded-2xl border-neutral-200/70 bg-white shadow-sm dark:border-neutral-800 dark:bg-neutral-950",n),children:r.jsxs(Tt,{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(Xt,{variant:Lj(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(ft,{className:"my-5"}),r.jsx("div",{className:"space-y-3",children:e.items.map((l,d)=>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:l.title}),r.jsxs("div",{className:"mt-0.5 text-xs text-neutral-600 dark:text-neutral-400",children:["Qty ",l.qty]})]}),r.jsx("div",{className:"text-right text-sm font-semibold text-neutral-950 dark:text-neutral-50",children:Be({amount:l.unitPrice*l.qty,currency:l.currency})})]},`${l.title}-${d}`))}),e.metadata?.recipient_email?r.jsxs(r.Fragment,{children:[r.jsx(ft,{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(ft,{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(l=>r.jsxs("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("div",{className:"mb-2 text-xs font-medium text-neutral-600 dark:text-neutral-400",children:l.title}),r.jsx(ei,{serverUrl:s,productId:l.productId,authToken:o})]},l.productId))]})]}):null,r.jsx(ft,{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:Be({amount:e.total,currency:e.currency})})]}),qe(e.receiptUrl)||qe(e.invoiceUrl)?r.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[qe(e.receiptUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:qe(e.receiptUrl),target:"_blank",rel:"noreferrer",children:"Receipt"})}):null,qe(e.invoiceUrl)?r.jsx(X,{asChild:!0,type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:r.jsx("a",{href:qe(e.invoiceUrl),target:"_blank",rel:"noreferrer",children:"Invoice"})}):null]}):null]})})}function xs(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 Dj({serverUrl:e,token:t,authToken:n,onSignIn:s,onContinueShopping:o,className:a}){const[i,c]=_.useState({kind:"loading"}),l=_.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]);_.useEffect(()=>{l()},[l]);const d=_.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:L("flex min-h-[50vh] items-center justify-center p-4",a),children:r.jsx(kt,{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(Tt,{className:"p-8",children:i.kind==="loading"?r.jsx($j,{}):i.kind==="not-found"?r.jsx(zj,{}):i.kind==="error"?r.jsx(Fj,{message:i.message,onRetry:l}):i.kind==="already-claimed"?r.jsx(Uj,{data:i.data,onContinueShopping:o}):i.kind==="info"?r.jsx(Bj,{data:i.data,isAuthenticated:!!n,onClaim:d,onSignIn:s}):i.kind==="claiming"?r.jsx(Vj,{}):r.jsx(Wj,{result:i.result,onContinueShopping:o})})})})}function $j(){return r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Loading gift card details..."})}function zj(){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 Fj({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 Uj({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 ",xs(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 Bj({data:e,isAuthenticated:t,onClaim:n,onSignIn:s}){const o=xs(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 Vj(){return r.jsx("div",{className:"text-center text-neutral-600 dark:text-neutral-400",children:"Claiming your gift card..."})}function Wj({result:e,onContinueShopping:t}){const n=xs(e.creditsAdded,e.currency),s=xs(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 ti(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"),Object.keys(t).length?t:void 0}function Hj(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 Zj={shop:"/shop",category:e=>`/shop/${e}`,product:e=>`/product/${e}`,cart:"/cart",checkout:"/checkout",orders:"/account/orders",subscribe:"/subscribe"};function qj(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 Gj({className:e,routes:t,initialCategorySlug:n}){const{config:s}=Ee(),o=Ot(),a=Ys(),i={...Zj,...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 P=window.matchMedia?.("(min-width: 1024px)");if(!P)return;const Y=()=>f(P.matches);return Y(),P.addEventListener?.("change",Y),()=>P.removeEventListener?.("change",Y)},[]);const{categories:u,isLoading:g,error:p}=oa(),b=m.useMemo(()=>ca({includeCategory:!0}),[]),[x,h]=m.useState(b?.search??""),[v,k]=m.useState(n??b?.category),[w,y]=m.useState(b?.page??1),[j,R]=m.useState(b?.sort??"featured"),[E,C]=m.useState(b?.filters??{}),{data:A,isLoading:O,error:U}=_s({category:v,search:x.trim()||void 0,filters:E,sort:j,page:w,pageSize:24}),M=m.useMemo(()=>qj(A?.items??[]),[A?.items]),{settings:B}=Hn(),$=B.catalog.filters,q=B.catalog.sort,F=m.useMemo(()=>{const P=[];return q.featured&&P.push({value:"featured",label:"Featured"}),q.priceAsc&&P.push({value:"price_asc",label:"Price: Low to High"}),q.priceDesc&&P.push({value:"price_desc",label:"Price: High to Low"}),P.length===0&&P.push({value:"featured",label:"Featured"}),P},[q]);m.useEffect(()=>{F.some(P=>P.value===j)||R(F[0].value)},[F,j]),la({search:x,sort:j,page:w,category:v,filters:E},{includeCategory:!0});const[Z,D]=m.useState(!1),[N,I]=m.useState(!1),[G,xe]=m.useState(null),[W,Q]=m.useState(!1),K=P=>{k(P.slug),y(1),D(!1)},le=m.useCallback((P,Y,ue)=>{o.addItem({productId:P.id,variantId:Y?.id,unitPrice:P.price,currency:P.currency,titleSnapshot:Y?`${P.title} — ${Y.title}`:P.title,imageSnapshot:P.images[0]?.url,paymentResource:P.id,metadata:ti(P)},ue),a?.toast({title:"Added to cart",description:P.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:L("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(Qa,{value:x,onChange:h})}),r.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[r.jsxs(Fs,{open:Z,onOpenChange:D,children:[r.jsx(Us,{asChild:!0,children:r.jsx(X,{type:"button",variant:"outline",children:"Filters"})}),r.jsxs(Ar,{side:"left",children:[r.jsx(Bs,{children:r.jsx(Vs,{children:"Browse"})}),r.jsxs("div",{className:"mt-4",children:[p?r.jsx(Wt,{description:p}):null,g?r.jsxs("div",{className:"space-y-2",children:[r.jsx(Re,{className:"h-9"}),r.jsx(Re,{className:"h-9"}),r.jsx(Re,{className:"h-9"})]}):r.jsxs("div",{className:"space-y-6",children:[r.jsx(qo,{categories:u,activeSlug:v,onSelect:K}),r.jsx(gs,{facets:M,value:E,onChange:P=>{C(P),y(1)},onClear:()=>{C({}),y(1)},enabledFilters:$}),F.length>1&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-sm font-semibold",children:"Sort"}),r.jsxs(fs,{value:j,onValueChange:P=>{R(P),y(1)},children:[r.jsx(br,{"aria-label":"Sort",children:r.jsx(ms,{placeholder:"Sort"})}),r.jsx(wr,{children:F.map(P=>r.jsx(kr,{value:P.value,children:P.label},P.value))})]})]})]})]})]})]}),r.jsx(jr,{open:!d&&N,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&&N,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:L("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",N?"lg:hidden":void 0),onClick:()=>{l("chat"),I(!0)},"aria-label":"Open chat",children:[r.jsx(Hj,{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(kt,{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(Tt,{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(Wt,{className:"mt-3",description:p}):null,g?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsx(Re,{className:"h-9"}),r.jsx(Re,{className:"h-9"}),r.jsx(Re,{className:"h-9"})]}):r.jsx("div",{className:"mt-3",children:r.jsx(qo,{categories:u,activeSlug:v,onSelect:K})})]}),F.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(fs,{value:j,onValueChange:P=>{R(P),y(1)},children:[r.jsx(br,{"aria-label":"Sort",children:r.jsx(ms,{placeholder:"Sort"})}),r.jsx(wr,{children:F.map(P=>r.jsx(kr,{value:P.value,children:P.label},P.value))})]})})]}),r.jsx(gs,{facets:M,value:E,onChange:P=>{C(P),y(1)},onClear:()=>{C({}),y(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:B.shopPage.title||"Shop"}),B.shopPage.description&&r.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:B.shopPage.description})]})}),U?r.jsx(Wt,{className:"mt-6",description:U}):null,O?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((P,Y)=>r.jsx(Re,{className:"aspect-[4/5] rounded-2xl"},Y))}):r.jsxs("div",{className:"mt-6",children:[r.jsx(Ks,{products:A?.items??[],columns:s.ui?.productGrid?.columns,getProductHref:P=>i.product(P.slug),onAddToCart:P=>le(P,null,1),onQuickView:P=>{xe(P),Q(!0)},layout:B.shopLayout.layout,imageCrop:B.shopLayout.imageCrop}),r.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[r.jsx(X,{type:"button",variant:"outline",disabled:w<=1,onClick:()=>y(P=>Math.max(1,P-1)),children:"Previous"}),r.jsxs("div",{className:"text-xs text-neutral-600 dark:text-neutral-400",children:["Page ",w]}),r.jsx(X,{type:"button",variant:"outline",disabled:!A?.hasNextPage,onClick:()=>y(P=>P+1),children:"Next"})]})]})]})]}),r.jsx(Ga,{product:G,open:W,onOpenChange:Q,productHref:P=>i.product(P),onAddToCart:(P,Y,ue)=>le(P,Y,ue)})]})}function Yj(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 Qj({categorySlug:e,className:t,routes:n}){const{config:s}=Ee(),o=Ot(),a=Ys(),{categories:i}=oa(),[c,l]=m.useState(()=>typeof window>"u"?!1:window.matchMedia?.("(min-width: 1024px)")?.matches??!1);m.useEffect(()=>{if(typeof window>"u")return;const V=window.matchMedia?.("(min-width: 1024px)");if(!V)return;const ae=()=>l(V.matches);return ae(),V.addEventListener?.("change",ae),()=>V.removeEventListener?.("change",ae)},[]);const[d,f]=m.useState(!1),[u,g]=m.useState(!1),[p,b]=m.useState("cart"),x=m.useMemo(()=>ca({includeCategory:!1}),[]),[h,v]=m.useState(x?.search??""),[k,w]=m.useState(x?.page??1),[y,j]=m.useState(x?.sort??"featured"),[R,E]=m.useState(x?.filters??{}),[C,A]=m.useState(null),[O,U]=m.useState(!1),M=i.find(V=>V.slug===e)??null,{data:B,isLoading:$,error:q}=_s({category:e,search:h.trim()||void 0,filters:R,sort:y,page:k,pageSize:24}),F=n?.product??(V=>`/product/${V}`),Z=n?.shop??"/shop",D=n?.cart??"/cart",N=n?.checkout??"/checkout",I=m.useMemo(()=>{const V=B?.items??[],ae=new Set;let ce=Number.POSITIVE_INFINITY,we=0;for(const Qe of V){for(const He of Qe.tags??[])ae.add(He);ce=Math.min(ce,Qe.price),we=Math.max(we,Qe.price)}const Te=Array.from(ae).slice(0,12),We=Number.isFinite(ce)?{min:ce,max:we}:void 0;return{tags:Te,price:We}},[B?.items]),{settings:G}=Hn(),xe=G.catalog.filters,W=G.catalog.sort,Q=m.useMemo(()=>{const V=[];return W.featured&&V.push({value:"featured",label:"Featured"}),W.priceAsc&&V.push({value:"price_asc",label:"Price: Low to High"}),W.priceDesc&&V.push({value:"price_desc",label:"Price: High to Low"}),V.length===0&&V.push({value:"featured",label:"Featured"}),V},[W]);m.useEffect(()=>{Q.some(V=>V.value===y)||j(Q[0].value)},[Q,y]),la({search:h,sort:y,page:k,filters:R},{includeCategory:!1});const K=m.useCallback((V,ae,ce)=>{o.addItem({productId:V.id,variantId:ae?.id,unitPrice:V.price,currency:V.currency,titleSnapshot:ae?`${V.title} — ${ae.title}`:V.title,imageSnapshot:V.images[0]?.url,paymentResource:V.id,metadata:ti(V)},ce),a?.toast({title:"Added to cart",description:V.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&(window.matchMedia?.("(min-width: 1024px)").matches?window.location.assign(D):(b("cart"),g(!0)))}})},[o,D,a]),le=V=>{E(V),w(1)},P=()=>{E({}),w(1)},Y=V=>{j(V),w(1)},ue=r.jsx(kt,{className:"flex max-h-[calc(100vh-6rem)] flex-col rounded-2xl",children:r.jsxs(Tt,{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:Z,children:"All categories"})})]}),r.jsx("div",{className:"text-base font-semibold text-neutral-950 dark:text-neutral-50",children:M?.name??e}),r.jsx("div",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:M?.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(fs,{value:y,onValueChange:Y,children:[r.jsx(br,{"aria-label":"Sort",children:r.jsx(ms,{placeholder:"Sort"})}),r.jsx(wr,{children:Q.map(V=>r.jsx(kr,{value:V.value,children:V.label},V.value))})]})]}),r.jsx(ft,{}),r.jsx(gs,{facets:I,value:R,onChange:le,onClear:P,enabledFilters:xe})]})});return r.jsxs("div",{className:L("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:Z,className:"text-sm font-semibold tracking-tight",children:s.brand?.name??"Shop"}),r.jsx("div",{className:"flex-1",children:r.jsx(Qa,{value:h,onChange:v})}),r.jsxs("div",{className:"flex items-center gap-2 lg:hidden",children:[r.jsxs(Fs,{open:d,onOpenChange:f,children:[r.jsx(Us,{asChild:!0,children:r.jsx(X,{type:"button",variant:"outline",children:"Filters"})}),r.jsxs(Ar,{side:"left",children:[r.jsx(Bs,{children:r.jsx(Vs,{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(N)},trigger:r.jsxs(X,{type:"button",variant:"default",onClick:()=>b("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(N)},trigger:r.jsxs(X,{type:"button",variant:"outline",onClick:()=>b("cart"),children:["Cart (",o.count,")"]})}),r.jsx(X,{type:"button",variant:"default",onClick:()=>{typeof window<"u"&&window.location.assign(N)},children:"Checkout"})]})]})}),r.jsxs(X,{type:"button",variant:"ghost",className:L("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:()=>{b("chat"),g(!0)},"aria-label":"Open chat",children:[r.jsx(Yj,{className:"h-4 w-4"}),"Chat"]}),r.jsxs("main",{className:"mx-auto max-w-7xl px-4 py-8",children:[r.jsx(Ya,{items:[{label:"Shop",href:Z},{label:M?.name??e}]}),r.jsxs("div",{className:"mt-6",children:[r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:M?.name??"Category"}),r.jsx("p",{className:"mt-1 text-sm text-neutral-600 dark:text-neutral-400",children:M?.description??"Browse products in this category."})]}),q?r.jsx(Wt,{className:"mt-6",description:q}):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((V,ae)=>r.jsx(Re,{className:"aspect-[4/5] rounded-2xl"},ae))}):r.jsxs("div",{className:"mt-6",children:[r.jsx(Ks,{products:B?.items??[],columns:s.ui?.productGrid?.columns,getProductHref:V=>F(V.slug),onAddToCart:V=>K(V,null,1),onQuickView:V=>{A(V),U(!0)},layout:G.categoryLayout.layout,imageCrop:G.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(V=>Math.max(1,V-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:!B?.hasNextPage,onClick:()=>w(V=>V+1),children:"Next"})]})]})})]}),r.jsx(Ga,{product:C,open:O,onOpenChange:U,productHref:V=>F(V),onAddToCart:(V,ae,ce)=>K(V,ae,ce)})]})]})}function Kj(e){return!e||typeof e!="string"?[]:e.split(",").map(t=>t.trim()).filter(Boolean)}function Jj({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:Be({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,qe(e.custodyProofUrl)?r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{children:"Custody proof"}),r.jsx("a",{href:qe(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 Xj({slug:e,className:t,routes:n}){const s=Ot(),o=Ys(),{product:a,isLoading:i,error:c}=Tl(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}=Hn(),{mode:p,maxItems:b}=g.relatedProducts,x=Dl({productId:a?.id,enabled:p==="ai"&&!!a?.id}),h=m.useMemo(()=>p==="by_category"&&a?.categoryIds?.length?{category:a.categoryIds[0],page:1,pageSize:b+1}:{page:1,pageSize:b+4},[p,b,a?.categoryIds]),v=_s(h),k=m.useMemo(()=>{const q=(v.data?.items??[]).filter(F=>F.slug!==e);if(p==="manual"&&a){const F=a.attributes?.relatedProductIds||a.attributes?.related_product_ids;if(F){const Z=Kj(String(F));if(Z.length>0){const D=new Map(q.map(I=>[I.id,I]));return Z.map(I=>D.get(I)).filter(I=>!!I).slice(0,b)}}}if(p==="ai"&&x.relatedProductIds&&x.relatedProductIds.length>0){const F=new Map(q.map(D=>[D.id,D])),Z=x.relatedProductIds.map(D=>F.get(D)).filter(D=>!!D);if(Z.length>0)return Z.slice(0,b)}return q.slice(0,b)},[v.data?.items,e,p,b,a,x.relatedProductIds]),w=n?.shop??"/shop",y=n?.checkout??"/checkout",j=n?.cart??"/cart",R=n?.product??($=>`/product/${$}`);if(i)return r.jsx("div",{className:L("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(Re,{className:"h-5 w-40"}),r.jsxs("div",{className:"mt-6 grid gap-8 lg:grid-cols-2",children:[r.jsx(Re,{className:"aspect-square rounded-2xl"}),r.jsxs("div",{className:"space-y-4",children:[r.jsx(Re,{className:"h-8 w-2/3"}),r.jsx(Re,{className:"h-6 w-32"}),r.jsx(Re,{className:"h-20"}),r.jsx(Re,{className:"h-11"})]})]})]})});if(c)return r.jsx("div",{className:L("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(Wt,{description:c})})});if(!a)return r.jsx("div",{className:L("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(Wt,{description:"Product not found."})})});const E=f.variant?.price??a.price,C=f.variant?.compareAtPrice??a.compareAtPrice,A=f.variant?.inventoryStatus==="out_of_stock"||typeof f.variant?.inventoryQuantity=="number"&&f.variant.inventoryQuantity<=0,O=a.inventoryStatus==="out_of_stock"||typeof a.inventoryQuantity=="number"&&a.inventoryQuantity<=0,U=f.variant?A:O,M=()=>{U||(s.addItem({productId:a.id,variantId:f.variant?.id,unitPrice:E,currency:a.currency,titleSnapshot:f.variant?`${a.title} — ${f.variant.title}`:a.title,imageSnapshot:a.images[0]?.url,paymentResource:a.id,metadata:ti(a)},l),o?.toast({title:"Added to cart",description:a.title,actionLabel:"View cart",onAction:()=>{typeof window<"u"&&window.location.assign(j)}}))},B=()=>{U||(M(),typeof window<"u"&&window.location.assign(y))};return r.jsx("div",{className:L("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(Ya,{items:[{label:"Shop",href:w},{label:a.title}]}),r.jsxs("div",{className:"mt-6 grid gap-10 lg:grid-cols-2",children:[r.jsx(Ha,{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(Wa,{assetClass:a.tokenizedAssetConfig.assetClass}):null]}),r.jsx("div",{className:"mt-3",children:r.jsx(Qs,{amount:E,currency:a.currency,compareAt:C})}),U?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(Jj,{config:a.tokenizedAssetConfig,currency:a.currency}):null]}),r.jsx(Za,{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(qa,{qty:l,onChange:d}),r.jsx(X,{type:"button",onClick:M,className:"flex-1",disabled:U,children:U?"Out of stock":"Add to cart"}),r.jsx(X,{type:"button",variant:"outline",onClick:B,disabled:U,children:"Buy now"})]}),(g.sections.showDescription||g.sections.showSpecs||g.sections.showShipping)&&r.jsxs(rf,{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(([$,q])=>r.jsxs("div",{children:[r.jsxs("span",{className:"font-medium text-neutral-950 dark:text-neutral-50",children:[$,":"]})," ",String(q)]},$))}):"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(Ks,{products:k,columns:{base:2,md:4,lg:4},layout:g.relatedProducts.layout.layout,imageCrop:g.relatedProducts.layout.imageCrop,getProductHref:$=>R($.slug),onAddToCart:$=>s.addItem({productId:$.id,unitPrice:$.price,currency:$.currency,titleSnapshot:$.title,imageSnapshot:$.images[0]?.url,paymentResource:$.id},1)})})]}):null]})})}function eS({className:e,checkoutHref:t}){const{config:n}=Ee(),{settings:s}=Hn(),o=t??"/checkout",a=n.checkout.allowPromoCodes&&s.checkout.promoCodes;return r.jsx("div",{className:L("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(Mf,{onCheckout:()=>{typeof window<"u"&&window.location.assign(o)},showPromoCode:a})})]})})}function tS({className:e,routes:t}){const{config:n}=Ee(),s=Ot(),o=ia(),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:L("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(Js,{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(Il,{children:c?r.jsxs(kt,{className:"rounded-2xl",children:[r.jsx(gr,{className:"pb-4",children:r.jsx(xr,{className:"text-base",children:"Sign in required"})}),r.jsxs(Tt,{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(Lf,{left:r.jsxs("div",{className:"space-y-6",children:[r.jsx($f,{}),r.jsxs(kt,{className:"rounded-2xl",children:[r.jsx(gr,{className:"pb-4",children:r.jsx(xr,{className:"text-base",children:"Payment"})}),r.jsxs(Tt,{children:[r.jsx(ft,{className:"mb-4"}),r.jsx(Ff,{})]})]})]}),right:r.jsx("div",{className:"lg:sticky lg:top-24",children:r.jsx(Uf,{})})})})})]}):null]})})}function nS({className:e,isSignedIn:t=!0,onLogin:n,serverUrl:s,authToken:o}){const{orders:a,isLoading:i,error:c}=Pl(),[l,d]=m.useState(null);return t?r.jsx("div",{className:L("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(Wt,{className:"mt-8",description:c}):null,i?r.jsxs("div",{className:"mt-8 grid gap-4",children:[r.jsx(Re,{className:"h-32 rounded-2xl"}),r.jsx(Re,{className:"h-32 rounded-2xl"}),r.jsx(Re,{className:"h-32 rounded-2xl"})]}):a.length===0?r.jsx("div",{className:"mt-8",children:r.jsx(Vn,{title:"No orders yet",description:"When you purchase something, it will show up here."})}):l?r.jsx("div",{className:"mt-8",children:r.jsx(Wf,{order:l,onBack:()=>d(null),serverUrl:s,authToken:o})}):r.jsx("div",{className:"mt-8",children:r.jsx(Vf,{orders:a,onView:d})})]})}):r.jsx("div",{className:L("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(Vn,{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 rS({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 sS({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 oS(e){switch(e){case"x402":return"Crypto (x402)";case"credits":return"Credits";case"stripe":return"Card";default:return"Payment"}}function aS({order:e,source:t,purchaseId:n,customerEmail:s,customerName:o,className:a,onBack:i}){const{config:c}=Ee(),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,b=()=>{typeof window<"u"&&window.print()},x=new Date(e.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"}),h=new Date(e.createdAt).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});return r.jsxs("div",{className:L("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(sS,{className:"mr-1"})," Back"]}):r.jsx("div",{}),r.jsxs(X,{type:"button",variant:"outline",size:"sm",onClick:b,children:[r.jsx(rS,{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:x}),r.jsx("div",{className:"text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:h})]}),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:oS(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(Xt,{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((v,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:v.title})}),r.jsx("td",{className:"py-3 text-center text-neutral-600 dark:text-neutral-400 print:dark:text-neutral-600",children:v.qty}),r.jsx("td",{className:"py-3 text-right",children:Be({amount:v.unitPrice*v.qty,currency:v.currency})})]},`${v.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:Be({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:Be({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 iS({className:e}){return r.jsx("svg",{className:L("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 cS({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}=Ee(),{tiers:c,status:l,isLoading:d,error:f}=Rl(),[u,g]=m.useState("monthly"),p=!!i.adapter.createSubscriptionCheckoutSession,b=async x=>{if(!i.adapter.createSubscriptionCheckoutSession)return;const h=await i.adapter.createSubscriptionCheckoutSession({tierId:x,interval:u,successUrl:i.checkout.successUrl,cancelUrl:i.checkout.cancelUrl});h.kind==="redirect"&&typeof window<"u"&&window.location.assign(h.url)};return r.jsx("div",{className:L("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:L("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:L("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:L("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(Wt,{className:"mt-10",description:f}):null,d?r.jsxs("div",{className:"mt-12 grid gap-6 md:grid-cols-3",children:[r.jsx(Re,{className:"h-[480px] rounded-2xl"}),r.jsx(Re,{className:"h-[480px] rounded-2xl"}),r.jsx(Re,{className:"h-[480px] rounded-2xl"})]}):c.length===0?r.jsx("div",{className:"mt-12",children:r.jsx(Vn,{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(x=>{const h=l?.isActive&&l.currentTierId===x.id,v=u==="annual"&&x.priceAnnual?x.priceAnnual:x.priceMonthly,k=x.isPopular,w=x.inventoryQuantity!=null,y=w?Math.max(0,(x.inventoryQuantity??0)-(x.inventorySold??0)):null,j=w&&y===0,R=w&&y!=null&&y>0&&y<=5,[E,...C]=x.features;return r.jsxs("div",{className:L("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:x.title}),x.description&&r.jsx("p",{className:L("mt-2 text-sm leading-relaxed",k?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:x.description})]}),r.jsxs("div",{className:"mb-6",children:[r.jsx("div",{className:"text-5xl font-bold tracking-tight",children:Be({amount:v,currency:x.currency||i.currency})}),r.jsxs("div",{className:L("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"]})]}),w&&r.jsx("div",{className:L("mb-3 text-xs font-medium",j?"text-red-600 dark:text-red-400":R?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":`${y} remaining`}),r.jsx(X,{type:"button",className:L("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:h||!p||j,onClick:()=>void b(x.id),children:j?"Sold Out":h?"Current Plan":"Purchase"}),E&&r.jsx("div",{className:L("mb-4 text-sm font-semibold",k?"":"text-neutral-900 dark:text-white"),children:E}),C.length>0&&r.jsx("ul",{className:"space-y-3",children:C.map((A,O)=>r.jsxs("li",{className:"flex items-start gap-3",children:[r.jsx(iS,{className:L("mt-0.5",k?"text-neutral-400 dark:text-neutral-500":"text-neutral-500 dark:text-neutral-400")}),r.jsx("span",{className:L("text-sm leading-relaxed",k?"text-neutral-300 dark:text-neutral-600":"text-neutral-600 dark:text-neutral-400"),children:A})]},O))})]},x.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 lS(e){const{processCartCheckout:t}=Gf.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 aa(n)}}),[e,t])}const dS=Object.freeze(Object.defineProperty({__proto__:null,Accordion:rf,AccordionContent:mr,AccordionItem:ur,AccordionTrigger:fr,AddressForm:Go,AssetBadge:Wa,Badge:Xt,Breadcrumbs:Ya,Button:X,Card:kt,CardContent:Tt,CardDescription:ed,CardFooter:td,CardHeader:gr,CardTitle:xr,CartLineItem:Ka,CartPageContent:Mf,CartPanel:Pf,CartProvider:Vm,CartSidebar:jr,CartSummary:Ja,CartTemplate:eS,CategoryNav:qo,CategoryTemplate:Qj,CedrosShopProvider:bm,CheckoutCancelPage:Oj,CheckoutForm:$f,CheckoutLayout:Lf,CheckoutProvider:Il,CheckoutReceipt:Js,CheckoutSuccessPage:Rj,CheckoutTemplate:tS,Dialog:Ia,DialogClose:Fk,DialogContent:$s,DialogDescription:Ra,DialogFooter:Ou,DialogHeader:Pa,DialogOverlay:Ta,DialogPortal:Ru,DialogTitle:zs,DialogTrigger:zk,EmptyState:Vn,ErrorBoundary:b_,ErrorState:Wt,FAQItem:Ef,FAQList:vj,FilterPanel:gs,GiftCardRedemptionPage:Dj,Input:Oe,InventoryVerificationDialog:zf,Label:tt,OrderCard:Bf,OrderDetails:Wf,OrderList:Vf,OrderReview:Uf,PaymentStep:Ff,Price:Qs,ProductCard:If,ProductGallery:Ha,ProductGrid:Ks,ProductTemplate:Xj,PromoCodeInput:Xa,PurchaseHistoryTemplate:nS,QuantitySelector:qa,QuickViewDialog:Ga,ReceiptTemplate:aS,RedemptionForm:ei,SearchInput:Qa,Select:fs,SelectContent:wr,SelectGroup:bk,SelectItem:kr,SelectTrigger:br,SelectValue:ms,Separator:ft,Sheet:Fs,SheetClose:Mu,SheetContent:Ar,SheetDescription:Du,SheetHeader:Bs,SheetOverlay:Oa,SheetPortal:Lu,SheetTitle:Vs,SheetTrigger:Us,ShippingMethodSelector:Df,ShopChatPanel:Of,ShopTemplate:Gj,Skeleton:Re,SubscriptionTemplate:cS,Tabs:Ba,TabsContent:jf,TabsList:Gs,TabsTrigger:_r,ToastProvider:Q_,VariantSelector:Za,createMockCommerceAdapter:Sm,createPaywallCommerceAdapter:Mm,parseCheckoutReturn:aa,readCatalogUrlState:ca,useAIRelatedProducts:Dl,useCart:Ot,useCartInventory:da,useCatalogUrlSync:la,useCategories:oa,useCedrosPayCheckoutAdapter:lS,useCedrosShop:Ee,useCheckout:ks,useCheckoutResultFromUrl:ia,useHoldExpiry:R0,useInventoryVerification:Ml,useOptionalToast:Ys,useOrders:Pl,usePaymentMethodsConfig:Ll,useProduct:Tl,useProducts:_s,useShippingMethods:Ol,useStandaloneCheckout:j0,useStorefrontSettings:Hn,useSubscriptionData:Rl,useToast:Y_,validateCommerceAdapterContract:$0},Symbol.toStringTag,{value:"Module"}));exports.CEDROS_PAY_GROUPS=vm;exports.CEDROS_PAY_SECTIONS=Zc;exports.CEDROS_PAY_SECTION_IDS=xm;exports.CedrosPayAdminDashboard=hm;exports.CouponsSection=Uc;exports.CreditsBalance=ym;exports.ErrorBanner=Sr;exports.FormDropdown=It;exports.Icons=J;exports.ProductsSection=zc;exports.RefundsSection=Bc;exports.SettingsSection=Vc;exports.StatsBar=Cr;exports.TransactionsSection=Fc;exports.cedrosPayPlugin=gm;exports.formatDateTime=dr;exports.index=dS;exports.safeHref=qe;exports.useCreditsBalance=qc;
|