@cedros/pay-react 1.1.22 → 1.1.23
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-BtOxEweU.js → AISettingsSection-DAztmwnN.js} +1 -1
- package/dist/{AISettingsSection-p3iikbSw.mjs → AISettingsSection-DpMIk431.mjs} +2 -2
- package/dist/{AutosaveIndicator-CWbb-VXf.mjs → AutosaveIndicator-BRCqAWqP.mjs} +1 -1
- package/dist/{AutosaveIndicator-C-CH-obR.js → AutosaveIndicator-BnQkKxzr.js} +1 -1
- package/dist/{CedrosContext-D-lnoEkR.js → CedrosContext-7dwmEeUY.js} +2 -2
- package/dist/{CedrosContext-BE6P5PQ0.mjs → CedrosContext-BlArEF7k.mjs} +95 -78
- package/dist/{CryptoButton-Dy-g3bR0.js → CryptoButton-C1AAOOfj.js} +1 -1
- package/dist/{CryptoButton-CksMkZjL.mjs → CryptoButton-CREryx1l.mjs} +2 -2
- package/dist/{FAQSection-byh7zfqI.mjs → FAQSection-Ruzs7a-0.mjs} +1 -1
- package/dist/{FAQSection-DQpF7hVx.js → FAQSection-yw64HLy3.js} +1 -1
- package/dist/{MessagingSection-CK208brx.mjs → MessagingSection-BLRjfBQT.mjs} +2 -2
- package/dist/{MessagingSection-B6EHvjDw.js → MessagingSection-Dp_SaXsv.js} +1 -1
- package/dist/OrdersSection-C2dyWqrR.js +1 -0
- package/dist/OrdersSection-l-MtP9EN.mjs +233 -0
- package/dist/{PaymentSettingsSection-B9H253x1.mjs → PaymentSettingsSection-Bbq93UtC.mjs} +1 -1
- package/dist/{PaymentSettingsSection-Cmmuhmd4.js → PaymentSettingsSection-C5bhLgU7.js} +1 -1
- package/dist/{SettingsSection-DrzGdvHH.js → SettingsSection-D_pKPRrP.js} +1 -1
- package/dist/{SettingsSection-DDLMaEPo.mjs → SettingsSection-DorqCFXE.mjs} +1 -1
- package/dist/SingleCategorySettings-BAND8Zkw.mjs +1006 -0
- package/dist/SingleCategorySettings-Cg-zuJfr.js +3 -0
- package/dist/{StorefrontSection-Dr2ciBVg.mjs → StorefrontSection-FSOxBclu.mjs} +2 -2
- package/dist/{StorefrontSection-DTpZ_GgO.js → StorefrontSection-QZPEZ6Lz.js} +1 -1
- package/dist/{SubscriptionsSection-CU3Ce8r9.mjs → SubscriptionsSection-C4TDXCX2.mjs} +1 -1
- package/dist/{SubscriptionsSection-CYJpArJ8.js → SubscriptionsSection-DYr99VzB.js} +1 -1
- package/dist/Token22Section-Cmn2lKcd.mjs +1685 -0
- package/dist/Token22Section-D3nnUyim.js +1 -0
- package/dist/{WalletManager-QcfgQmap.js → WalletManager-Bwk3rgr1.js} +1 -1
- package/dist/{WalletManager-D78miaJ2.mjs → WalletManager-peBN6RDH.mjs} +1 -1
- package/dist/bn-CHdpZHQm.mjs +1185 -0
- package/dist/bn-RbgIlcHc.js +1 -0
- package/dist/configApi-Ch0Rr7TD.mjs +554 -0
- package/dist/configApi-CxEbCAgG.js +1 -0
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +54 -52
- package/dist/{index-CufXF9Yd.mjs → index-CKNB7XsA.mjs} +6709 -5888
- package/dist/index-vEe2Y39x.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +34 -32
- package/dist/pay-react_false-CPX8Vyp9.mjs +5 -0
- package/dist/pay-react_false-DaeIe3_l.js +1 -0
- package/dist/{sections-CR7NRsjq.js → sections-Cklkxd85.js} +1 -1
- package/dist/{sections-Bc6ARlND.mjs → sections-Dt6vxDU4.mjs} +1 -1
- package/dist/src/components/CreditsBalance.d.ts +24 -0
- package/dist/src/components/CreditsBalance.d.ts.map +1 -0
- package/dist/src/components/admin/AssetClassesTab.d.ts +20 -0
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -0
- package/dist/src/components/admin/AssetRedemptionManager.d.ts +21 -0
- package/dist/src/components/admin/AssetRedemptionManager.d.ts.map +1 -0
- 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/GiftCardComplianceTab.d.ts +3 -0
- package/dist/src/components/admin/GiftCardComplianceTab.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts +11 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -0
- package/dist/src/components/admin/OrdersSection.d.ts +3 -0
- package/dist/src/components/admin/OrdersSection.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RedemptionFormBuilder.d.ts +25 -0
- package/dist/src/components/admin/RedemptionFormBuilder.d.ts.map +1 -0
- package/dist/src/components/admin/Token22Section.d.ts +3 -0
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/index.d.ts +3 -0
- package/dist/src/components/admin/index.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/mock/mockAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/AssetBadge.d.ts +13 -0
- package/dist/src/ecommerce/components/catalog/AssetBadge.d.ts.map +1 -0
- package/dist/src/ecommerce/components/catalog/ProductCard.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutReceipt.d.ts +9 -2
- package/dist/src/ecommerce/components/checkout/CheckoutReceipt.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/CheckoutSuccessPage.d.ts +7 -1
- package/dist/src/ecommerce/components/checkout/CheckoutSuccessPage.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/RedemptionForm.d.ts +22 -0
- package/dist/src/ecommerce/components/checkout/RedemptionForm.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardRedemptionPage.d.ts +36 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardRedemptionPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderCard.d.ts.map +1 -1
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts +5 -1
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +6 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +1 -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/templates/ProductTemplate.d.ts.map +1 -1
- package/dist/src/ecommerce/templates/PurchaseHistoryTemplate.d.ts +5 -1
- package/dist/src/ecommerce/templates/PurchaseHistoryTemplate.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +20 -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/ecommerce/utils/safeHref.d.ts +9 -0
- package/dist/src/ecommerce/utils/safeHref.d.ts.map +1 -0
- package/dist/src/hooks/useCreditsBalance.d.ts +32 -0
- package/dist/src/hooks/useCreditsBalance.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts +15 -0
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/MeteoraPoolManager.d.ts +86 -0
- package/dist/src/managers/MeteoraPoolManager.d.ts.map +1 -0
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/{styles-BWrLnaUW.js → styles-21F1-oqx.js} +1 -1
- package/dist/{styles--eKKnfdj.mjs → styles-2VMpwuaI.mjs} +3 -3
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-BqNfOhB0.js → walletPool-Ddv33tej.js} +1 -1
- package/dist/{walletPool-DShNjCQ6.mjs → walletPool-DgQsh7Se.mjs} +1 -1
- package/package.json +5 -1
- package/dist/SingleCategorySettings-BU98SRFV.mjs +0 -1418
- package/dist/SingleCategorySettings-DqcXe-q4.js +0 -3
- package/dist/index-IZ4WcMd7.js +0 -84
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var $e=Object.create;var ye=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var Fe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ze(t))!Oe.call(e,n)&&n!==r&&ye(e,n,{get:()=>t[n],enumerable:!(s=Ae(t,n))||s.enumerable});return e};var We=(e,t,r)=>(r=e!=null?$e(Ue(e)):{},Fe(t||!e||!e.__esModule?ye(r,"default",{value:e,enumerable:!0}):r,e));const S=require("./CedrosContext-D-lnoEkR.js"),i=require("react/jsx-runtime"),f=require("react");function He(e){return!e||!e.coupon_codes?[]:e.coupon_codes.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Ye(e,t=", "){return e.join(t)}function Qe(e,t){return e<=0?0:(e-t)/e*100}function Ve(e,t){if(!t||t.length===0)return e;let r=e,s=0;for(const n of t)if(n.discountType==="percentage"){const d=1-n.discountValue/100;r=r*d}else n.discountType==="fixed"&&(s+=n.discountValue);return r=r-s,r<0&&(r=0),Math.ceil(r*100)/100}function Ce(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return 1;const r=Math.floor(t);return r>0?r:1}function ie(e){return e.map(t=>({resource:t.resource,quantity:Ce(t.quantity),variantId:t.variantId,metadata:t.metadata}))}function ee(e){return e.reduce((t,r)=>t+Ce(r.quantity),0)}function Ge(e){return!!(e&&e.length>0&&(e.length>1||e.length===1&&(e[0].quantity??1)>1))}const G=new Map,le=new Map,H=new Map,ae=1e3,xe=200,ue=2e3;function Ke(e){const t=H.get(e);return t?Date.now()<t?!0:(H.delete(e),!1):!1}function Xe(e,t=xe){const r=Date.now()+t;if(H.set(e,r),H.size>ae){const s=Array.from(H.keys()).slice(0,H.size-ae);for(const n of s)H.delete(n)}}function Je(e,t=ue){const r=G.get(e);if(!r)return!1;const n=Date.now()-r;return n<t?(S.getLogger().debug(`[Deduplication] Duplicate request blocked: ${e} (${n}ms ago)`),!0):!1}function Ze(e){if(G.set(e,Date.now()),G.size>ae){const t=Array.from(G.keys()).slice(0,G.size-ae);for(const r of t)G.delete(r)}}function et(e){return le.get(e)||null}function tt(e,t){le.set(e,t);const r=()=>{le.delete(e),Ze(e)};return t.then(r,r),t}async function rt(e,t,r={}){const{windowMs:s=ue,throwOnDuplicate:n=!0}=r,d=et(e);if(d)return S.getLogger().debug(`[Deduplication] Reusing in-flight request: ${e}`),d;if(Je(e,s)){if(n)throw new Error(`Duplicate request blocked: ${e}`);S.getLogger().warn(`[Deduplication] Duplicate request blocked but not throwing: ${e}`);return}const h=t();return tt(e,h)}function K(e,t,r={}){const{cooldownMs:s=xe,deduplicationWindowMs:n=ue}=r;return async()=>{if(Ke(e)){S.getLogger().debug(`[Deduplication] Button in cooldown: ${e}`);return}Xe(e,s);try{await rt(e,async()=>{const d=t();d instanceof Promise&&await d},{windowMs:n,throwOnDuplicate:!1})}catch(d){if(d instanceof Error&&d.message.includes("Duplicate request"))return;throw d}}}function we(e){return{background:"none",border:"none",fontSize:"1.5rem",cursor:"pointer",color:e,opacity:.6,padding:"0.25rem",lineHeight:1}}const W={PAYMENT_START:"cedros:payment:start",WALLET_CONNECT:"cedros:wallet:connect",WALLET_CONNECTED:"cedros:wallet:connected",WALLET_ERROR:"cedros:wallet:error",PAYMENT_PROCESSING:"cedros:payment:processing",PAYMENT_SUCCESS:"cedros:payment:success",PAYMENT_ERROR:"cedros:payment:error"};function Q(e,t){if(typeof window>"u")return;const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!1});window.dispatchEvent(r)}function X(e,t,r){Q(W.PAYMENT_START,{timestamp:Date.now(),method:e,resource:t,itemCount:r})}function st(e){Q(W.WALLET_CONNECT,{timestamp:Date.now(),wallet:e})}function nt(e,t){Q(W.WALLET_CONNECTED,{timestamp:Date.now(),wallet:e,publicKey:t})}function ot(e,t){Q(W.WALLET_ERROR,{timestamp:Date.now(),wallet:t,error:e})}function J(e,t,r){Q(W.PAYMENT_PROCESSING,{timestamp:Date.now(),method:e,resource:t,itemCount:r})}function Z(e,t,r,s){Q(W.PAYMENT_SUCCESS,{timestamp:Date.now(),method:e,transactionId:t,resource:r,itemCount:s})}function F(e,t,r,s){Q(W.PAYMENT_ERROR,{timestamp:Date.now(),method:e,error:t,resource:r,itemCount:s})}function it(e){return e instanceof S.PaymentError&&e.canRetry()}function at(e){return e instanceof S.PaymentError?e.getUserMessage():e instanceof Error?e.message:String(e)}function ct(e){switch(e){case"mainnet-beta":return"https://api.mainnet-beta.solana.com";case"devnet":return"https://api.devnet.solana.com";case"testnet":return"https://api.testnet.solana.com";default:return"https://api.mainnet-beta.solana.com"}}function lt(e){try{const t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e}}function Se(e={}){const{solanaCluster:t="mainnet-beta",solanaEndpoint:r,customRpcProviders:s=[],allowUnsafeScripts:n=!1,additionalScriptSrc:d=[],additionalConnectSrc:h=[],additionalFrameSrc:C=[],includeStripe:y=!0,includeSolana:l=!0}=e;n&&console.warn("[CedrosPay] SECURITY WARNING: allowUnsafeScripts is enabled. This adds 'unsafe-inline' and 'unsafe-eval' to script-src, which significantly weakens CSP protection against XSS attacks. Only use this in development or if absolutely required by your framework.");const a=["'self'"];n&&a.push("'unsafe-inline'","'unsafe-eval'"),y&&a.push("https://js.stripe.com"),a.push(...d);const o=["'self'"];if(y&&o.push("https://api.stripe.com","https://*.stripe.com"),l){const c=ct(t);if(o.push(c),r){const u=lt(r);o.includes(u)||o.push(u)}s.forEach(u=>{o.includes(u)||o.push(u)})}o.push(...h);const p=["'self'"];return y&&p.push("https://js.stripe.com","https://checkout.stripe.com"),p.push(...C),{scriptSrc:a,connectSrc:o,frameSrc:p}}function ve(e,t="header"){const{scriptSrc:r,connectSrc:s,frameSrc:n}=e;switch(t){case"header":case"meta":case"nextjs":case"nginx":{const d=[];return r.length>0&&d.push(`script-src ${r.join(" ")}`),s.length>0&&d.push(`connect-src ${s.join(" ")}`),n.length>0&&d.push(`frame-src ${n.join(" ")}`),d.join("; ")}case"helmet":{const d={};return r.length>0&&(d.scriptSrc=r),s.length>0&&(d.connectSrc=s),n.length>0&&(d.frameSrc=n),d}case"directives":return{scriptSrc:r,connectSrc:s,frameSrc:n};default:throw new Error(`Unknown CSP format: ${t}`)}}function ut(e={},t="header"){const r=Se(e);return ve(r,t)}const dt={HELIUS:"https://*.helius-rpc.com",QUICKNODE:"https://*.quicknode.pro",ALCHEMY:"https://*.alchemy.com",ANKR:"https://rpc.ankr.com",TRITON:"https://*.rpcpool.com"},pt={MAINNET_CUSTOM_RPC:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,allowUnsafeScripts:!1}),MAINNET_NEXTJS:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,allowUnsafeScripts:!1}),DEVNET:()=>({solanaCluster:"devnet",allowUnsafeScripts:!1}),CRYPTO_ONLY:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,includeStripe:!1}),STRIPE_ONLY:()=>({includeStripe:!0,includeSolana:!1})};function de(){const{stripeManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,transactionId:null}),s=f.useRef(!1),n=f.useCallback(async(C,y,l,a,o,p)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null});const c={resource:C,successUrl:y,cancelUrl:l,metadata:a,customerEmail:o,couponCode:p};try{const u=await e.processPayment(c);return r({status:u.success?"success":"error",error:u.success?null:u.error||"Payment failed",transactionId:u.success&&u.transactionId||null}),u}catch(u){const g=u instanceof Error?u.message:"Payment failed";return r({status:"error",error:g,transactionId:null}),{success:!1,error:g}}finally{s.current=!1}},[e]),d=f.useCallback(async(C,y,l,a,o,p,c,u,g,m,w,b,E)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null});const P=ie(C);try{const k=await e.processCartCheckout({items:P,successUrl:y,cancelUrl:l,metadata:a,customerEmail:o,customerName:c,customerPhone:u,shippingAddress:g,billingAddress:m,couponCode:p,tipAmount:w,shippingMethodId:b,paymentMethodId:E});return r({status:k.success?"success":"error",error:k.success?null:k.error||"Cart checkout failed",transactionId:k.success&&k.transactionId||null}),k}catch(k){const T=k instanceof Error?k.message:"Cart checkout failed";return r({status:"error",error:T,transactionId:null}),{success:!1,error:T}}finally{s.current=!1}},[e]),h=f.useCallback(()=>{r({status:"idle",error:null,transactionId:null}),s.current=!1},[]);return{...t,processPayment:n,processCartCheckout:d,reset:h}}function te(e,t){return f.useMemo(()=>{const r=Ge(t),s=e||(t?.length===1?t[0].resource:"");return{isCartMode:r,effectiveResource:s}},[e,t])}const ft=(e,t,r)=>{const s=e[t];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((n,d)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(d.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},ce=new Map;let oe=null;async function be(e){if(ce.has(e))return ce.get(e);try{const t=await ft(Object.assign({"./translations/ar.json":()=>Promise.resolve().then(()=>require("./ar-LVoQZTFI.js")),"./translations/bn.json":()=>Promise.resolve().then(()=>require("./bn-BR5Cv1T4.js")),"./translations/de.json":()=>Promise.resolve().then(()=>require("./de-pQxy-oD1.js")),"./translations/en.json":()=>Promise.resolve().then(()=>require("./en-Yikrt96u.js")),"./translations/es.json":()=>Promise.resolve().then(()=>require("./es-D24cg8dD.js")),"./translations/fil.json":()=>Promise.resolve().then(()=>require("./fil-BOBft9G-.js")),"./translations/fr.json":()=>Promise.resolve().then(()=>require("./fr-Ct9ub8Fa.js")),"./translations/he.json":()=>Promise.resolve().then(()=>require("./he-DtQqRKRq.js")),"./translations/id.json":()=>Promise.resolve().then(()=>require("./id-CiM2mL7C.js")),"./translations/in.json":()=>Promise.resolve().then(()=>require("./in-Bzcjmxcc.js")),"./translations/it.json":()=>Promise.resolve().then(()=>require("./it-Blb_pIJl.js")),"./translations/jp.json":()=>Promise.resolve().then(()=>require("./jp-9NHyIuwY.js")),"./translations/kr.json":()=>Promise.resolve().then(()=>require("./kr-DvzJ-0yX.js")),"./translations/ms.json":()=>Promise.resolve().then(()=>require("./ms-BOAu5pUB.js")),"./translations/nl.json":()=>Promise.resolve().then(()=>require("./nl-WHh_DfO8.js")),"./translations/pa.json":()=>Promise.resolve().then(()=>require("./pa-B7kIhZCF.js")),"./translations/pl.json":()=>Promise.resolve().then(()=>require("./pl-H0hBKdvF.js")),"./translations/pt.json":()=>Promise.resolve().then(()=>require("./pt-DwGrViQ3.js")),"./translations/ru.json":()=>Promise.resolve().then(()=>require("./ru-CB2m0UDT.js")),"./translations/ta.json":()=>Promise.resolve().then(()=>require("./ta-CAS197uN.js")),"./translations/th.json":()=>Promise.resolve().then(()=>require("./th-Cpz2cFcg.js")),"./translations/tr.json":()=>Promise.resolve().then(()=>require("./tr-hQrEFk86.js")),"./translations/uk.json":()=>Promise.resolve().then(()=>require("./uk-DrK2Sv8C.js")),"./translations/ur.json":()=>Promise.resolve().then(()=>require("./ur-D5-7mN9a.js")),"./translations/vn.json":()=>Promise.resolve().then(()=>require("./vn-B_iut9YL.js")),"./translations/zh.json":()=>Promise.resolve().then(()=>require("./zh-PR82dCHr.js"))}),`./translations/${e}.json`,3),r=t.default||t;return ce.set(e,r),r}catch{return null}}async function gt(){if(oe)return oe;const e=Object.assign({"./translations/ar.json":()=>Promise.resolve().then(()=>require("./ar-LVoQZTFI.js")),"./translations/bn.json":()=>Promise.resolve().then(()=>require("./bn-BR5Cv1T4.js")),"./translations/de.json":()=>Promise.resolve().then(()=>require("./de-pQxy-oD1.js")),"./translations/en.json":()=>Promise.resolve().then(()=>require("./en-Yikrt96u.js")),"./translations/es.json":()=>Promise.resolve().then(()=>require("./es-D24cg8dD.js")),"./translations/fil.json":()=>Promise.resolve().then(()=>require("./fil-BOBft9G-.js")),"./translations/fr.json":()=>Promise.resolve().then(()=>require("./fr-Ct9ub8Fa.js")),"./translations/he.json":()=>Promise.resolve().then(()=>require("./he-DtQqRKRq.js")),"./translations/id.json":()=>Promise.resolve().then(()=>require("./id-CiM2mL7C.js")),"./translations/in.json":()=>Promise.resolve().then(()=>require("./in-Bzcjmxcc.js")),"./translations/it.json":()=>Promise.resolve().then(()=>require("./it-Blb_pIJl.js")),"./translations/jp.json":()=>Promise.resolve().then(()=>require("./jp-9NHyIuwY.js")),"./translations/kr.json":()=>Promise.resolve().then(()=>require("./kr-DvzJ-0yX.js")),"./translations/ms.json":()=>Promise.resolve().then(()=>require("./ms-BOAu5pUB.js")),"./translations/nl.json":()=>Promise.resolve().then(()=>require("./nl-WHh_DfO8.js")),"./translations/pa.json":()=>Promise.resolve().then(()=>require("./pa-B7kIhZCF.js")),"./translations/pl.json":()=>Promise.resolve().then(()=>require("./pl-H0hBKdvF.js")),"./translations/pt.json":()=>Promise.resolve().then(()=>require("./pt-DwGrViQ3.js")),"./translations/ru.json":()=>Promise.resolve().then(()=>require("./ru-CB2m0UDT.js")),"./translations/ta.json":()=>Promise.resolve().then(()=>require("./ta-CAS197uN.js")),"./translations/th.json":()=>Promise.resolve().then(()=>require("./th-Cpz2cFcg.js")),"./translations/tr.json":()=>Promise.resolve().then(()=>require("./tr-hQrEFk86.js")),"./translations/uk.json":()=>Promise.resolve().then(()=>require("./uk-DrK2Sv8C.js")),"./translations/ur.json":()=>Promise.resolve().then(()=>require("./ur-D5-7mN9a.js")),"./translations/vn.json":()=>Promise.resolve().then(()=>require("./vn-B_iut9YL.js")),"./translations/zh.json":()=>Promise.resolve().then(()=>require("./zh-PR82dCHr.js"))}),t=[];for(const r in e){const s=r.match(/\.\/translations\/([a-z]{2,3}(?:-[A-Z]{2})?)\.json$/);s&&t.push(s[1])}return oe=t.length>0?t:["en"],oe}function Pe(){return typeof navigator>"u"?"en":(navigator.language||navigator.userLanguage||"en").split("-")[0].toLowerCase()}async function je(e){let t=await be(e);if(t||(t=await be("en"),t))return t;throw new Error("Critical: No translation files found, not even en.json")}function ke(e){return(t,r)=>{const s=t.split(".");let n=e;for(const d of s)if(n&&typeof n=="object"&&d in n)n=n[d];else return t;return typeof n!="string"?t:r?Object.entries(r).reduce((d,[h,C])=>d.replace(new RegExp(`\\{${h}\\}`,"g"),C),n):n}}function mt(e,t,r=!0){const s=t.errors[e];if(!s){const n=S.getUserFriendlyError(e);return r&&n.action?`${n.message} ${n.action}`:n.message}return r&&s.action?`${s.message} ${s.action}`:s.message}function V(e){const[t,r]=f.useState(null),[s,n]=f.useState(!0),d=f.useMemo(()=>e||Pe(),[e]);return f.useEffect(()=>{let C=!1;return(async()=>{n(!0);try{const l=await je(d);C||(r(l),n(!1))}catch(l){console.error("[CedrosPay] Failed to load translations:",l),C||n(!1)}})(),()=>{C=!0}},[d]),{t:f.useMemo(()=>t?ke(t):C=>({"ui.purchase":"Purchase","ui.pay_with_card":"Pay with Card","ui.pay_with_crypto":"Pay with USDC","ui.pay_with_usdc":"Pay with USDC","ui.card":"Card","ui.usdc_solana":"USDC (Solana)","ui.crypto":"Crypto","ui.processing":"Processing...","ui.loading":"Loading...","ui.connect_wallet":"Connect Wallet","ui.connecting":"Connecting..."})[C]||C,[t]),locale:d,isLoading:s,translations:t}}function ht(e,t=!0){const{translations:r}=V();if(!r){const n=S.getUserFriendlyError(e);return t&&n.action?`${n.message} ${n.action}`:n.message}const s=r.errors[e];if(!s){const n=S.getUserFriendlyError(e);return t&&n.action?`${n.message} ${n.action}`:n.message}return t&&s.action?`${s.message} ${s.action}`:s.message}function pe({resource:e,items:t,successUrl:r,cancelUrl:s,metadata:n,customerEmail:d,couponCode:h,label:C,disabled:y=!1,onAttempt:l,onSuccess:a,onError:o,className:p=""}){const{status:c,error:u,transactionId:g,processPayment:m,processCartCheckout:w}=de(),b=S.useCedrosTheme(),{isCartMode:E,effectiveResource:P}=te(e,t),{t:k,translations:T}=V(),D=C||k("ui.pay_with_card"),$=b.unstyled?p:`${b.className} cedros-theme__stripe-button ${p}`.trim(),A=u&&typeof u!="string"?u?.code??null:null,x=u?typeof u=="string"?u:(j=>{if(!j||!T)return"";const R=T.errors[j];return R?R.action?`${R.message} ${R.action}`:R.message:""})(A):null,M=f.useCallback(async()=>{S.getLogger().debug("[StripeButton] executePayment with couponCode:",h);const j=E&&t?ee(t):void 0;if(X("stripe",P,j),l&&l("stripe"),!E&&!P){const U="Invalid payment configuration: missing resource or items";S.getLogger().error("[StripeButton]",U),F("stripe",U,P,j),o&&o(U);return}let R;J("stripe",P,j),E&&t?(S.getLogger().debug("[StripeButton] Processing cart checkout with coupon:",h),R=await w(t,r,s,n,d,h)):P&&(S.getLogger().debug("[StripeButton] Processing single payment with coupon:",h),R=await m(P,r,s,n,d,h)),R&&R.success&&R.transactionId?(Z("stripe",R.transactionId,P,j),a&&a(R.transactionId)):R&&!R.success&&R.error&&(F("stripe",R.error,P,j),o&&o(R.error))},[h,E,P,t,r,s,n,d,w,m,l,a,o]),B=f.useMemo(()=>E&&t?`stripe-cart-${t.map(j=>j.resource).join("-")}`:`stripe-${P||"unknown"}`,[E,t,P]),_=f.useMemo(()=>K(B,M),[B,M]),I=c==="loading",v=y||I;return i.jsxs("div",{className:$,style:b.unstyled?{}:b.style,children:[i.jsx("button",{onClick:_,disabled:v,className:b.unstyled?p:"cedros-theme__button cedros-theme__stripe",type:"button",children:I?k("ui.processing"):D}),x&&i.jsx("div",{className:b.unstyled?"":"cedros-theme__error",children:x}),g&&i.jsx("div",{className:b.unstyled?"":"cedros-theme__success",children:k("ui.payment_successful")})]})}function Ee(){const{creditsManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,transactionId:null,requirement:null,holdId:null}),s=f.useRef(!1),n=f.useCallback(async(l,a)=>{r(o=>({...o,status:"loading",error:null}));try{const o=await e.requestQuote(l,a);return r(p=>({...p,status:"idle",requirement:o})),o}catch(o){const p=o instanceof Error?o.message:"Failed to fetch credits quote";return r(c=>({...c,status:"error",error:p})),null}},[e]),d=f.useCallback(async(l,a)=>{r(o=>({...o,status:"loading",error:null}));try{const o=ie(l),p=await e.requestCartQuote(o,a);return r(c=>({...c,status:"idle"})),p}catch(o){const p=o instanceof Error?o.message:"Failed to fetch cart credits quote";return r(c=>({...c,status:"error",error:p})),null}},[e]),h=f.useCallback(async(l,a,o,p)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null,requirement:null,holdId:null});try{const c=await e.processPayment(l,a,o,p);return r({status:c.success?"success":"error",error:c.success?null:c.error||"Credits payment failed",transactionId:c.success&&c.transactionId||null,requirement:null,holdId:null}),c}catch(c){const u=c instanceof Error?c.message:"Credits payment failed";return r({status:"error",error:u,transactionId:null,requirement:null,holdId:null}),{success:!1,error:u}}finally{s.current=!1}},[e]),C=f.useCallback(async(l,a,o,p)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null,requirement:null,holdId:null});let c=null;try{const u=ie(l),g=await e.requestCartQuote(u,o);if(!g)return r({status:"error",error:"Credits payment not available for this cart",transactionId:null,requirement:null,holdId:null}),{success:!1,error:"Credits payment not available"};c=(await e.createCartHold({cartId:g.cartId,authToken:a})).holdId,r(b=>({...b,holdId:c}));const w=await e.authorizeCartPayment({cartId:g.cartId,holdId:c,authToken:a,metadata:p});if(!w.success&&c)try{await e.releaseHold(c,a)}catch(b){S.getLogger().warn("[useCreditsPayment] Hold release failed, will expire server-side",{holdId:c,error:b instanceof Error?b.message:String(b)})}return r({status:w.success?"success":"error",error:w.success?null:w.error||"Cart credits payment failed",transactionId:w.success&&w.transactionId||null,requirement:null,holdId:null}),{success:w.success,transactionId:w.transactionId,error:w.error}}catch(u){const g=u instanceof Error?u.message:"Cart credits payment failed";if(c)try{await e.releaseHold(c,a)}catch(m){S.getLogger().warn("[useCreditsPayment] Hold release failed, will expire server-side",{holdId:c,error:m instanceof Error?m.message:String(m)})}return r({status:"error",error:g,transactionId:null,requirement:null,holdId:null}),{success:!1,error:g}}finally{s.current=!1}},[e]),y=f.useCallback(()=>{r({status:"idle",error:null,transactionId:null,requirement:null,holdId:null}),s.current=!1},[]);return{...t,fetchQuote:n,fetchCartQuote:d,processPayment:h,processCartPayment:C,reset:y}}function fe({resource:e,items:t,authToken:r,metadata:s,couponCode:n,label:d,disabled:h=!1,onAttempt:C,onSuccess:y,onError:l,className:a=""}){const{status:o,error:p,transactionId:c,processPayment:u,processCartPayment:g}=Ee(),m=S.useCedrosTheme(),{isCartMode:w,effectiveResource:b}=te(e,t),{t:E,translations:P}=V(),k=d||E("ui.pay_with_credits")||"Pay with Credits",T=m.unstyled?a:`${m.className} cedros-theme__credits-button ${a}`.trim(),D=p&&typeof p!="string"?p?.code??null:null,A=p?typeof p=="string"?p:(I=>{if(!I||!P)return"";const v=P.errors[I];return v?v.action?`${v.message} ${v.action}`:v.message:""})(D):null,q=f.useCallback(async()=>{S.getLogger().debug("[CreditsButton] executePayment");const I=w&&t?ee(t):void 0;if(X("credits",b,I),C&&C("credits"),!r){const j="Authentication required: please log in to pay with credits";S.getLogger().error("[CreditsButton]",j),F("credits",j,b,I),l&&l(j);return}if(!w&&!b){const j="Invalid payment configuration: missing resource";S.getLogger().error("[CreditsButton]",j),F("credits",j,b,I),l&&l(j);return}let v;J("credits",b,I),w&&t?(S.getLogger().debug("[CreditsButton] Processing cart checkout"),v=await g(t,r,n,s)):b&&(S.getLogger().debug("[CreditsButton] Processing single payment"),v=await u(b,r,n,s)),v&&v.success&&v.transactionId?(Z("credits",v.transactionId,b,I),y&&y(v.transactionId)):v&&!v.success&&v.error&&(F("credits",v.error,b,I),l&&l(v.error))},[r,w,b,t,n,s,u,g,C,y,l]),x=f.useMemo(()=>w&&t?`credits-cart-${t.map(I=>I.resource).join("-")}`:`credits-${b||"unknown"}`,[w,t,b]),M=f.useMemo(()=>K(x,q),[x,q]),B=o==="loading",_=h||B;return i.jsxs("div",{className:T,style:m.unstyled?{}:m.style,children:[i.jsx("button",{onClick:M,disabled:_,className:m.unstyled?a:"cedros-theme__button cedros-theme__credits",type:"button",children:B?E("ui.processing"):k}),A&&i.jsx("div",{className:m.unstyled?"":"cedros-theme__error",children:A}),c&&i.jsx("div",{className:m.unstyled?"":"cedros-theme__success",children:E("ui.payment_successful")})]})}const yt=f.lazy(()=>Promise.resolve().then(()=>require("./CryptoButton-Dy-g3bR0.js")).then(e=>e.CryptoButton$1).then(e=>({default:e.CryptoButton}))),Me=({isOpen:e,onClose:t,resource:r,items:s,cardLabel:n="Card",cryptoLabel:d="USDC (Solana)",creditsLabel:h="Pay with Credits",showCard:C=!0,showCrypto:y=!0,showCredits:l=!1,onPaymentAttempt:a,onPaymentSuccess:o,onPaymentError:p,onStripeSuccess:c,onCryptoSuccess:u,onCreditsSuccess:g,onStripeError:m,onCryptoError:w,onCreditsError:b,customerEmail:E,successUrl:P,cancelUrl:k,metadata:T,couponCode:D,authToken:$,testPageUrl:A,hideMessages:q=!1})=>{const{tokens:x}=S.useCedrosTheme();return f.useEffect(()=>{const M=B=>{B.key==="Escape"&&e&&t()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e,t]),f.useEffect(()=>{if(e){const M=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${M}px`,document.body.style.width="100%",document.body.style.overflowY="scroll",()=>{const B=document.body.style.top?Math.abs(parseInt(document.body.style.top.replace("px",""),10)):0;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflowY="",window.scrollTo(0,B)}}},[e]),e?i.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:x.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:t,children:i.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:x.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${x.modalBorder}`},onClick:M=>M.stopPropagation(),children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[i.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:x.surfaceText},children:"Choose Payment Method"}),i.jsx("button",{type:"button",onClick:t,style:we(x.surfaceText),"aria-label":"Close modal",children:"×"})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[C&&i.jsx(pe,{resource:r,items:s,label:n,onAttempt:a,onSuccess:c||o,onError:m||p,customerEmail:E,successUrl:P,cancelUrl:k,metadata:T,couponCode:D}),y&&i.jsx(f.Suspense,{fallback:null,children:i.jsx(yt,{resource:r,items:s,label:d,onAttempt:a,onSuccess:u||o,onError:w||p,testPageUrl:A,hideMessages:q,metadata:T,couponCode:D})}),l&&i.jsx(fe,{resource:r,items:s,label:h,authToken:$,onAttempt:a?()=>a("credits"):void 0,onSuccess:g||o,onError:b||p,metadata:T,couponCode:D})]})]})}):null},Re=({resource:e,items:t,label:r,cardLabel:s,cryptoLabel:n,creditsLabel:d,showCard:h=!0,showCrypto:C=!0,showCredits:y=!1,onPaymentAttempt:l,onPaymentSuccess:a,onPaymentError:o,onStripeSuccess:p,onCryptoSuccess:c,onCreditsSuccess:u,onStripeError:g,onCryptoError:m,onCreditsError:w,customerEmail:b,successUrl:E,cancelUrl:P,metadata:k,couponCode:T,authToken:D,autoDetectWallets:$=!0,testPageUrl:A,hideMessages:q=!1,renderModal:x})=>{const M=S.useCedrosTheme(),[B,_]=f.useState(!1),{status:I,processPayment:v,processCartCheckout:j}=de(),{isCartMode:R,effectiveResource:U}=te(e,t),{t:L}=V(),O=r||L("ui.purchase"),Le=s||L("ui.card"),Ne=n||L("ui.usdc_solana"),De=d||L("ui.pay_with_credits")||"Pay with Credits",ge=f.useCallback(async()=>{if($&&h){const{detectSolanaWallets:N}=await Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js"));if(!N()){const se=R?void 0:U,ne=R&&t?ee(t):void 0;X("stripe",se,ne),l&&l("stripe"),J("stripe",se,ne);let z;R&&t?z=await j(t,E,P,k,b,T):U&&(z=await v(U,E,P,k,b,T)),z&&z.success&&z.transactionId?(Z("stripe",z.transactionId,se,ne),p?p(z.transactionId):a&&a(z.transactionId)):z&&!z.success&&z.error&&(F("stripe",z.error,se,ne),g?g(z.error):o&&o(z.error));return}}_(!0)},[$,h,R,t,U,j,v,E,P,k,b,T,a,o,p,g,l]),me=f.useMemo(()=>R&&t?`purchase-cart-${t.map(N=>N.resource).join("-")}`:`purchase-${U||"unknown"}`,[R,t,U]),Be=f.useMemo(()=>K(me,ge),[me,ge]),re=I==="loading",he={isOpen:B,onClose:()=>_(!1),resource:R?void 0:U,items:R?t:void 0,cardLabel:Le,cryptoLabel:Ne,creditsLabel:De,showCard:h,showCrypto:C,showCredits:y,onPaymentAttempt:l,onPaymentSuccess:N=>{_(!1),a?.(N)},onPaymentError:N=>{_(!1),o?.(N)},onStripeSuccess:N=>{_(!1),p?.(N)},onCryptoSuccess:N=>{_(!1),c?.(N)},onCreditsSuccess:N=>{_(!1),u?.(N)},onStripeError:N=>{_(!1),g?.(N)},onCryptoError:N=>{_(!1),m?.(N)},onCreditsError:N=>{_(!1),w?.(N)},customerEmail:b,successUrl:E,cancelUrl:P,metadata:k,couponCode:T,authToken:D,testPageUrl:A,hideMessages:q};return i.jsxs("div",{className:M.unstyled?"":M.className,style:M.unstyled?{}:M.style,children:[i.jsx("button",{onClick:Be,disabled:re,className:M.unstyled?"":"cedros-theme__button cedros-theme__stripe",style:{width:"100%",cursor:re?"not-allowed":"pointer",opacity:re?.6:1},type:"button",children:re?L("ui.processing"):O}),x?x(he):i.jsx(Me,{...he})]})},bt={"mainnet-beta":"https://api.mainnet-beta.solana.com",devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com"};function Ct(){const[e,t]=f.useState(null);return f.useEffect(()=>{let r=!1;return import("@solana/wallet-adapter-react").then(s=>{r||t(s)}),()=>{r=!0}},[]),e}function xt({endpoint:e,wallets:t,children:r}){const s=Ct();if(!s)return i.jsx(i.Fragment,{children:r});const{ConnectionProvider:n,WalletProvider:d}=s;return i.jsx(n,{endpoint:e,children:i.jsx(d,{wallets:t,autoConnect:!1,children:r})})}const wt=f.lazy(()=>Promise.resolve().then(()=>require("./CryptoButton-Dy-g3bR0.js")).then(e=>e.CryptoButton$1).then(e=>({default:e.CryptoButton})));function St(e){const{resource:t,items:r,checkout:s={},display:n={},callbacks:d={},advanced:h={}}=e,{config:C,walletPool:y}=S.useCedrosContext(),l=S.useCedrosTheme(),{isCartMode:a}=te(t,r),o=n.showCrypto??!0,p=f.useMemo(()=>({marginTop:"0.5rem",fontSize:"0.875rem",color:l.tokens.surfaceText,opacity:.7,textAlign:"center"}),[l.tokens.surfaceText]),c=f.useMemo(()=>o?h.wallets&&h.wallets.length>0?h.wallets:y.getAdapters():[],[h.wallets,y,o]),u=f.useMemo(()=>r?ee(r):0,[r]),{onPaymentSuccess:g,onPaymentError:m,onPaymentAttempt:w}=d,b=f.useCallback(j=>g?.({transactionId:j,method:"stripe"}),[g]),E=f.useCallback(j=>g?.({transactionId:j,method:"crypto"}),[g]),P=f.useCallback(j=>m?.({message:j,method:"stripe"}),[m]),k=f.useCallback(j=>m?.({message:j,method:"crypto"}),[m]),T=f.useCallback(j=>g?.({transactionId:j,method:"credits"}),[g]),D=f.useCallback(j=>m?.({message:j,method:"credits"}),[m]),$=f.useCallback(()=>w?.("credits"),[w]),A=o?C.solanaEndpoint??bt[C.solanaCluster]:"";if(!t&&(!r||r.length===0))return S.getLogger().error('CedrosPay: Must provide either "resource" or "items" prop'),i.jsx("div",{className:n.className,style:{color:l.tokens.errorText},children:"Configuration error: No resource or items provided"});const q=n.showCard??!0,x=n.showCredits??!1,M=n.showPurchaseButton??!1,B=n.layout??"vertical",_=n.hideMessages??!1,I=h.autoDetectWallets??!0,v=i.jsx("div",{className:l.unstyled?n.className:`cedros-theme__pay ${n.className||""}`,children:i.jsxs("div",{className:l.unstyled?"":`cedros-theme__pay-content cedros-theme__pay-content--${B}`,children:[M?i.jsx(Re,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,label:n.purchaseLabel,cardLabel:n.cardLabel,cryptoLabel:n.cryptoLabel,showCard:q,showCrypto:o,onPaymentAttempt:d.onPaymentAttempt,onPaymentSuccess:b,onPaymentError:P,onStripeSuccess:b,onCryptoSuccess:E,onStripeError:P,onCryptoError:k,customerEmail:s.customerEmail,successUrl:s.successUrl,cancelUrl:s.cancelUrl,metadata:s.metadata,couponCode:s.couponCode,autoDetectWallets:I,testPageUrl:h.testPageUrl,hideMessages:_,renderModal:n.renderModal}):i.jsxs(i.Fragment,{children:[q&&i.jsx(pe,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,customerEmail:s.customerEmail,successUrl:s.successUrl,cancelUrl:s.cancelUrl,metadata:s.metadata,couponCode:s.couponCode,label:n.cardLabel,onAttempt:d.onPaymentAttempt,onSuccess:b,onError:P}),o&&i.jsx(f.Suspense,{fallback:null,children:i.jsx(wt,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,metadata:s.metadata,couponCode:s.couponCode,label:n.cryptoLabel,onAttempt:d.onPaymentAttempt,onSuccess:E,onError:k,testPageUrl:h.testPageUrl,hideMessages:_})}),x&&i.jsx(fe,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,authToken:s.authToken,metadata:s.metadata,couponCode:s.couponCode,label:n.creditsLabel,onAttempt:$,onSuccess:T,onError:D})]}),a&&r&&r.length>1&&!_&&i.jsxs("div",{style:p,children:["Checking out ",u," items"]})]})});return i.jsx("div",{className:l.unstyled?n.className:l.className,style:l.unstyled?{}:l.style,children:i.jsx(xt,{endpoint:A||"https://api.devnet.solana.com",wallets:c,children:v})})}function vt({product:e,paymentMethod:t,showOriginalPrice:r=!1,className:s="",style:n={}}){const d=t==="stripe",h=d?e.fiatAmount:e.cryptoAmount,C=d?e.effectiveFiatAmount:e.effectiveCryptoAmount,y=d?e.fiatCurrency.toUpperCase():e.cryptoToken,l=d?e.hasStripeCoupon:e.hasCryptoCoupon,a=d?e.stripeDiscountPercent:e.cryptoDiscountPercent;return i.jsxs("div",{className:s,style:n,children:[r&&l&&i.jsxs("span",{style:{textDecoration:"line-through",opacity:.6,marginRight:"0.5rem",fontSize:"0.875em"},children:[h.toFixed(2)," ",y]}),i.jsxs("span",{style:{fontWeight:600},children:[C.toFixed(2)," ",y]}),l&&a>0&&i.jsxs("span",{style:{marginLeft:"0.5rem",padding:"0.125rem 0.375rem",backgroundColor:"#10b981",color:"white",borderRadius:"0.25rem",fontSize:"0.75em",fontWeight:600},children:[a,"% OFF"]})]})}function Pt({product:e,paymentMethod:t,className:r="",style:s={}}){const n=t==="stripe",d=n?e.hasStripeCoupon:e.hasCryptoCoupon,h=n?e.stripeDiscountPercent:e.cryptoDiscountPercent,C=n?e.stripeCouponCode:e.cryptoCouponCode;if(!d||h===0)return null;const y=n?`${h}% off with card!`:`${h}% off with crypto!`;return i.jsxs("div",{className:r,style:{display:"inline-flex",alignItems:"center",padding:"0.5rem 0.75rem",backgroundColor:n?"#6366f1":"#10b981",color:"white",borderRadius:"0.375rem",fontSize:"0.875rem",fontWeight:600,...s},children:[y,C&&i.jsxs("span",{style:{marginLeft:"0.5rem",opacity:.8,fontSize:"0.75em",fontWeight:400},children:["(",C,")"]})]})}function Te(){const{subscriptionManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),s=f.useRef(!1),n=f.useCallback(async y=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r(l=>({...l,status:"loading",error:null}));try{const l=await e.processSubscription(y);return r(a=>({...a,status:l.success?"success":"error",error:l.success?null:l.error||"Subscription failed",sessionId:l.success&&l.transactionId||null})),l}catch(l){const a=S.formatError(l,"Subscription failed");return r(o=>({...o,status:"error",error:a})),{success:!1,error:a}}finally{s.current=!1}},[e]),d=f.useCallback(async y=>{r(l=>({...l,status:"checking",error:null}));try{const l=await e.checkSubscriptionStatus(y);return r(a=>({...a,status:l.active?"success":"idle",subscriptionStatus:l.status,expiresAt:l.expiresAt||l.currentPeriodEnd||null})),l}catch(l){const a=l instanceof Error?l.message:"Failed to check subscription status";throw r(o=>({...o,status:"error",error:a})),l}},[e]),h=f.useCallback(async(y,l,a)=>{r(o=>({...o,status:"loading",error:null}));try{const o=await e.requestSubscriptionQuote(y,l,a);return r(p=>({...p,status:"idle"})),o}catch(o){const p=o instanceof Error?o.message:"Failed to get subscription quote";throw r(c=>({...c,status:"error",error:p})),o}},[e]),C=f.useCallback(()=>{r({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null})},[]);return{...t,processSubscription:n,checkStatus:d,requestQuote:h,reset:C}}function jt({resource:e,interval:t,intervalDays:r,trialDays:s,successUrl:n,cancelUrl:d,metadata:h,customerEmail:C,couponCode:y,label:l,disabled:a=!1,onAttempt:o,onSuccess:p,onError:c,className:u=""}){const{status:g,error:m,sessionId:w,processSubscription:b}=Te(),E=S.useCedrosTheme(),{t:P,translations:k}=V(),T=l||P("ui.subscribe"),D=E.unstyled?u:`${E.className} cedros-theme__stripe-button ${u}`.trim(),$=m&&typeof m!="string"?m?.code??null:null,q=m?typeof m=="string"?m:(v=>{if(!v||!k)return"";const j=k.errors[v];return j?j.action?`${j.message} ${j.action}`:j.message:""})($):null,x=f.useCallback(async()=>{S.getLogger().debug("[SubscribeButton] executeSubscription:",{resource:e,interval:t,intervalDays:r,trialDays:s,couponCode:y}),X("stripe",e),o&&o("stripe"),J("stripe",e);const v=await b({resource:e,interval:t,intervalDays:r,trialDays:s,customerEmail:C,metadata:h,couponCode:y,successUrl:n,cancelUrl:d});v.success&&v.transactionId?(Z("stripe",v.transactionId,e),p&&p(v.transactionId)):!v.success&&v.error&&(F("stripe",v.error,e),c&&c(v.error))},[e,t,r,s,C,h,y,n,d,b,o,p,c]),M=f.useMemo(()=>`subscribe-${e}-${t}`,[e,t]),B=f.useMemo(()=>K(M,x),[M,x]),_=g==="loading",I=a||_;return i.jsxs("div",{className:D,style:E.unstyled?{}:E.style,children:[i.jsx("button",{onClick:B,disabled:I,className:E.unstyled?u:"cedros-theme__button cedros-theme__stripe",type:"button",children:_?P("ui.processing"):T}),q&&i.jsx("div",{className:E.unstyled?"":"cedros-theme__error",children:q}),w&&i.jsx("div",{className:E.unstyled?"":"cedros-theme__success",children:P("ui.redirecting_to_checkout")})]})}function _e(){const{subscriptionManager:e,creditsManager:t}=S.useCedrosContext(),[r,s]=f.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null,creditsRequirement:null}),n=f.useRef(!1),d=f.useCallback(async(l,a)=>{s(o=>({...o,status:"checking",error:null}));try{const o=await e.checkSubscriptionStatus({resource:l,userId:a});return s(p=>({...p,status:o.active?"success":"idle",subscriptionStatus:o.status,expiresAt:o.expiresAt||o.currentPeriodEnd||null})),o}catch(o){const p=S.formatError(o,"Failed to check subscription status");return s(c=>({...c,status:"error",error:p})),null}},[e]),h=f.useCallback(async(l,a,o)=>{s(p=>({...p,status:"loading",error:null}));try{const p=await t.requestQuote(l,o?.couponCode);return s(c=>({...c,status:"idle",creditsRequirement:p})),p}catch(p){const c=S.formatError(p,"Failed to get subscription quote");return s(u=>({...u,status:"error",error:c})),null}},[t]),C=f.useCallback(async(l,a,o,p)=>{if(n.current)return{success:!1,error:"Payment already in progress"};if(!o){const c="Authentication required for credits payment";return s(u=>({...u,status:"error",error:c})),{success:!1,error:c}}n.current=!0,s(c=>({...c,status:"loading",error:null}));try{const c=await t.processPayment(l,o,p?.couponCode,{interval:a,...p?.intervalDays&&{intervalDays:String(p.intervalDays)}});return c.success?s({status:"success",error:null,sessionId:c.transactionId||null,subscriptionStatus:"active",expiresAt:null,creditsRequirement:null}):s(u=>({...u,status:"error",error:c.error||"Credits subscription payment failed"})),c}catch(c){const u=S.formatError(c,"Credits subscription payment failed");return s(g=>({...g,status:"error",error:u})),{success:!1,error:u}}finally{n.current=!1}},[t]),y=f.useCallback(()=>{s({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null,creditsRequirement:null})},[]);return{...r,checkStatus:d,requestQuote:h,processPayment:C,reset:y}}function kt({resource:e,interval:t,intervalDays:r,authToken:s,userId:n,couponCode:d,label:h,disabled:C=!1,onAttempt:y,onSuccess:l,onError:a,className:o="",hideMessages:p=!1,autoCheckStatus:c=!1}){const{status:u,error:g,subscriptionStatus:m,expiresAt:w,checkStatus:b,processPayment:E}=_e(),P=S.useCedrosTheme(),{t:k,translations:T}=V(),D=f.useRef(b);f.useEffect(()=>{D.current=b},[b]),f.useEffect(()=>{c&&n&&(S.getLogger().debug("[CreditsSubscribeButton] Auto-checking subscription status",{resource:e,userId:n}),D.current(e,n))},[c,n,e]);const $=h||k("ui.subscribe_with_credits")||"Subscribe with Credits",A=g&&typeof g!="string"?g?.code??null:null,x=g?typeof g=="string"?g:(L=>{if(!L||!T)return"";const O=T.errors[L];return O?O.action?`${O.message} ${O.action}`:O.message:""})(A):null,M=f.useCallback(async()=>{if(S.getLogger().debug("[CreditsSubscribeButton] executeSubscriptionFlow",{resource:e,interval:t,intervalDays:r,hasAuthToken:!!s}),X("credits",e),y&&y("credits"),!s){const O="Authentication required: please log in to subscribe with credits";S.getLogger().error("[CreditsSubscribeButton]",O),F("credits",O,e),a&&a(O);return}J("credits",e);const L=await E(e,t,s,{couponCode:d,intervalDays:r});L.success&&L.transactionId?(Z("credits",L.transactionId,e),l&&l(L.transactionId)):!L.success&&L.error&&(F("credits",L.error,e),a&&a(L.error))},[e,t,r,s,d,E,y,l,a]),B=f.useMemo(()=>`credits-subscribe-${e}-${t}`,[e,t]),_=f.useMemo(()=>K(B,M,{cooldownMs:200,deduplicationWindowMs:0}),[B,M]),I=u==="loading"||u==="checking",v=m==="active"||m==="trialing",j=C||I||v;let R=$;if(I)R=k("ui.processing");else if(v&&w){const L=new Date(w).toLocaleDateString();R=`${k("ui.subscribed_until")} ${L}`}else v&&(R=k("ui.subscribed"));const U=P.unstyled?o:`${P.className} cedros-theme__credits-button ${o}`.trim();return i.jsxs("div",{className:U,style:P.unstyled?{}:P.style,children:[i.jsx("button",{onClick:_,disabled:j,className:P.unstyled?o:"cedros-theme__button cedros-theme__credits",type:"button",children:R}),!p&&x&&i.jsx("div",{className:P.unstyled?"":"cedros-theme__error",children:x}),!p&&v&&i.jsx("div",{className:P.unstyled?"":"cedros-theme__success",children:k("ui.subscription_active")})]})}function Ie(){const{subscriptionChangeManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,subscription:null,changePreview:null,userId:null}),s=f.useRef(t);s.current=t;const n=f.useCallback(async(o,p)=>{r(c=>({...c,status:"loading",error:null}));try{const c=await e.getDetails(o,p);return r(u=>({...u,status:"success",subscription:c,userId:p})),c}catch(c){const u=c instanceof Error?c.message:"Failed to load subscription";return r(g=>({...g,status:"error",error:u})),null}},[e]),d=f.useCallback(async(o,p,c,u)=>{r(g=>({...g,status:"loading",error:null}));try{const g={currentResource:o,newResource:p,userId:c,newInterval:u},m=await e.previewChange(g);return r(w=>({...w,status:"idle",changePreview:m})),m}catch(g){const m=g instanceof Error?g.message:"Failed to preview change";return r(w=>({...w,status:"error",error:m})),null}},[e]),h=f.useCallback(async o=>{const{subscription:p,userId:c}=s.current;if(!p||!c)return r(u=>({...u,status:"error",error:"No subscription loaded"})),null;r(u=>({...u,status:"loading",error:null}));try{const u={currentResource:p.resource,newResource:o.newResource,userId:c,newInterval:o.newInterval,prorationBehavior:o.prorationBehavior,immediate:o.immediate},g=await e.changeSubscription(u);return g.success?r(m=>({...m,status:"success",subscription:m.subscription?{...m.subscription,resource:g.newResource,interval:g.newInterval,status:g.status}:null,changePreview:null})):r(m=>({...m,status:"error",error:g.error||"Failed to change subscription"})),g}catch(u){const g=u instanceof Error?u.message:"Failed to change subscription";return r(m=>({...m,status:"error",error:g})),null}},[e]),C=f.useCallback(async o=>{const{subscription:p,userId:c}=s.current;if(!p||!c)return r(u=>({...u,status:"error",error:"No subscription loaded"})),null;r(u=>({...u,status:"loading",error:null}));try{const u={resource:p.resource,userId:c,immediate:o},g=await e.cancel(u);if(g.success){const m=o?"canceled":p.status;r(w=>({...w,status:"success",subscription:w.subscription?{...w.subscription,status:m,cancelAtPeriodEnd:!o}:null}))}else r(m=>({...m,status:"error",error:g.error||"Failed to cancel subscription"}));return g}catch(u){const g=u instanceof Error?u.message:"Failed to cancel subscription";return r(m=>({...m,status:"error",error:g})),null}},[e]),y=f.useCallback(async(o,p)=>{r(c=>({...c,status:"loading",error:null}));try{const c=await e.getBillingPortalUrl({userId:o,returnUrl:p});try{if(new URL(c.url).protocol!=="https:")throw new Error("Billing portal URL must use HTTPS")}catch{throw new Error("Invalid billing portal URL")}return window.location.href=c.url,c}catch(c){const u=c instanceof Error?c.message:"Failed to open billing portal";return r(g=>({...g,status:"error",error:u})),null}},[e]),l=f.useCallback(()=>{r(o=>({...o,changePreview:null}))},[]),a=f.useCallback(()=>{r({status:"idle",error:null,subscription:null,changePreview:null,userId:null})},[]);return{...t,loadSubscription:n,previewChange:d,changeSubscription:h,cancelSubscription:C,openBillingPortal:y,clearPreview:l,reset:a}}const Et={bg:"#fff",bgMuted:"#f9fafb",bgHighlight:"#eff6ff",text:"#111827",textMuted:"#6b7280",textFaint:"#9ca3af",border:"#e5e7eb",borderLight:"#f3f4f6",primary:"#3b82f6",error:"#ef4444",errorBg:"#fef2f2",errorBorder:"#fecaca",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",buttonBg:"#f3f4f6",buttonBorder:"#d1d5db",buttonText:"#374151"},Mt={bg:"#1e293b",bgMuted:"#334155",bgHighlight:"rgba(59, 130, 246, 0.15)",text:"#f1f5f9",textMuted:"#94a3b8",textFaint:"#64748b",border:"#475569",borderLight:"#334155",primary:"#3b82f6",error:"#ef4444",errorBg:"rgba(239, 68, 68, 0.15)",errorBorder:"rgba(239, 68, 68, 0.3)",warningBg:"rgba(245, 158, 11, 0.15)",warningBorder:"rgba(245, 158, 11, 0.3)",warningText:"#fbbf24",buttonBg:"#334155",buttonBorder:"#475569",buttonText:"#e2e8f0"};function Rt(e){const t=e?Mt:Et;return{container:{padding:"24px",backgroundColor:t.bg,borderRadius:"8px",border:`1px solid ${t.border}`,fontFamily:"system-ui, -apple-system, sans-serif",color:t.text},error:{padding:"12px 16px",backgroundColor:t.errorBg,border:`1px solid ${t.errorBorder}`,borderRadius:"6px",color:t.error,marginBottom:"16px"},loading:{padding:"24px",textAlign:"center",color:t.textMuted},details:{marginBottom:"24px"},title:{margin:"0 0 16px 0",fontSize:"18px",fontWeight:600,color:t.text},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:`1px solid ${t.borderLight}`},label:{color:t.textMuted,fontSize:"14px"},value:{color:t.text,fontSize:"14px",fontWeight:500},statusBadge:{padding:"4px 8px",borderRadius:"4px",color:"#fff",fontSize:"12px",fontWeight:500,textTransform:"capitalize"},cancelNotice:{marginTop:"12px",padding:"8px 12px",backgroundColor:t.warningBg,border:`1px solid ${t.warningBorder}`,borderRadius:"6px",color:t.warningText,fontSize:"13px"},prorationPreview:{padding:"16px",backgroundColor:t.bgMuted,borderRadius:"8px",marginBottom:"24px"},previewTitle:{margin:"0 0 12px 0",fontSize:"16px",fontWeight:600,color:t.text},previewDetails:{marginBottom:"16px"},previewRow:{display:"flex",justifyContent:"space-between",padding:"6px 0",fontSize:"14px",color:t.textMuted},previewTotal:{borderTop:`1px solid ${t.border}`,marginTop:"8px",paddingTop:"12px",fontWeight:600,color:t.text},previewActions:{display:"flex",gap:"12px",justifyContent:"flex-end"},cancelButton:{padding:"8px 16px",backgroundColor:t.bg,border:`1px solid ${t.buttonBorder}`,borderRadius:"6px",color:t.buttonText,cursor:"pointer",fontSize:"14px"},confirmButton:{padding:"8px 16px",backgroundColor:t.primary,border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500},plansSection:{marginBottom:"24px"},plansTitle:{margin:"0 0 12px 0",fontSize:"16px",fontWeight:600,color:t.text},plansList:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px"},planCard:{padding:"16px",backgroundColor:t.bg,border:`1px solid ${t.border}`,borderRadius:"8px",textAlign:"center"},currentPlan:{borderColor:t.primary,backgroundColor:t.bgHighlight},planName:{fontSize:"16px",fontWeight:600,color:t.text,marginBottom:"4px"},planPrice:{fontSize:"14px",color:t.textMuted,marginBottom:"8px"},planDescription:{fontSize:"12px",color:t.textFaint,marginBottom:"12px"},currentBadge:{display:"inline-block",padding:"4px 8px",backgroundColor:t.primary,color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:500},changePlanButton:{padding:"8px 16px",backgroundColor:t.buttonBg,border:`1px solid ${t.buttonBorder}`,borderRadius:"6px",color:t.buttonText,cursor:"pointer",fontSize:"14px",width:"100%"},actions:{display:"flex",gap:"12px",justifyContent:"flex-end",paddingTop:"16px",borderTop:`1px solid ${t.border}`},portalButton:{padding:"10px 20px",backgroundColor:t.primary,border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500},cancelSubscriptionButton:{padding:"10px 20px",backgroundColor:t.bg,border:`1px solid ${t.error}`,borderRadius:"6px",color:t.error,cursor:"pointer",fontSize:"14px"}}}function Y(e,t){return new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function qe(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function Tt(e){switch(e){case"active":return"#22c55e";case"trialing":return"#3b82f6";case"past_due":return"#f59e0b";case"canceled":case"expired":return"#ef4444";default:return"#6b7280"}}function _t({preview:e,onConfirm:t,onCancel:r,isLoading:s,styles:n}){const d=e.immediateAmount<0;return i.jsxs("div",{className:"cedros-proration-preview",style:n.prorationPreview,children:[i.jsx("h4",{style:n.previewTitle,children:"Change Preview"}),i.jsxs("div",{style:n.previewDetails,children:[i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Current plan:"}),i.jsxs("span",{children:[Y(e.currentPlanPrice,e.currency),"/period"]})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"New plan:"}),i.jsxs("span",{children:[Y(e.newPlanPrice,e.currency),"/period"]})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Days remaining:"}),i.jsxs("span",{children:[e.daysRemaining," days"]})]}),e.prorationDetails&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Unused credit:"}),i.jsxs("span",{children:["-",Y(e.prorationDetails.unusedCredit,e.currency)]})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"New plan cost:"}),i.jsx("span",{children:Y(e.prorationDetails.newPlanCost,e.currency)})]})]}),i.jsxs("div",{style:{...n.previewRow,...n.previewTotal},children:[i.jsx("span",{children:d?"Credit to account:":"Amount due now:"}),i.jsx("span",{style:{color:d?"#22c55e":"#ef4444"},children:Y(Math.abs(e.immediateAmount),e.currency)})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Effective date:"}),i.jsx("span",{children:qe(e.effectiveDate)})]})]}),i.jsxs("div",{style:n.previewActions,children:[i.jsx("button",{onClick:r,style:n.cancelButton,disabled:s,children:"Cancel"}),i.jsx("button",{onClick:t,style:n.confirmButton,disabled:s,children:s?"Processing...":"Confirm Change"})]})]})}function It({resource:e,userId:t,availablePlans:r=[],onSubscriptionChanged:s,onSubscriptionCanceled:n,billingPortalReturnUrl:d,showBillingPortal:h=!1,className:C,style:y}){const{mode:l}=S.useCedrosTheme(),a=f.useMemo(()=>Rt(l==="dark"),[l]),{subscription:o,changePreview:p,status:c,error:u,loadSubscription:g,previewChange:m,changeSubscription:w,cancelSubscription:b,openBillingPortal:E,clearPreview:P}=Ie();f.useEffect(()=>{g(e,t)},[e,t,g]);const k=f.useRef(null),T=f.useCallback(async(x,M)=>{k.current={resource:x,interval:M},await m(e,x,t,M)},[e,t,m]),D=f.useCallback(async()=>{if(!p)return;const x=k.current;(await w({newResource:x?.resource||e,newInterval:x?.interval,immediate:!0}))?.success&&x&&x.interval&&(s?.(x.resource,x.interval),k.current=null)},[p,e,w,s]),$=f.useCallback(async x=>{(await b(x))?.success&&n?.()},[b,n]),A=f.useCallback(()=>{E(t,d)},[t,d,E]),q=c==="loading";return i.jsxs("div",{className:`cedros-subscription-panel ${C||""}`,style:{...a.container,...y},children:[u&&i.jsx("div",{className:"cedros-subscription-error",style:a.error,children:u}),q&&!o&&i.jsx("div",{className:"cedros-subscription-loading",style:a.loading,children:"Loading subscription..."}),o&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"cedros-subscription-details",style:a.details,children:[i.jsx("h3",{style:a.title,children:"Current Subscription"}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Plan:"}),i.jsx("span",{style:a.value,children:o.resource})]}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Status:"}),i.jsx("span",{style:{...a.statusBadge,backgroundColor:Tt(o.status)},children:o.status})]}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Price:"}),i.jsxs("span",{style:a.value,children:[Y(o.pricePerPeriod,o.currency),"/",o.interval]})]}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Current period ends:"}),i.jsx("span",{style:a.value,children:qe(o.currentPeriodEnd)})]}),o.cancelAtPeriodEnd&&i.jsx("div",{style:a.cancelNotice,children:"Subscription will cancel at end of current period"})]}),p&&i.jsx(_t,{preview:p,onConfirm:D,onCancel:P,isLoading:q,styles:a}),r.length>0&&!p&&i.jsxs("div",{className:"cedros-available-plans",style:a.plansSection,children:[i.jsx("h4",{style:a.plansTitle,children:"Available Plans"}),i.jsx("div",{style:a.plansList,children:r.map(x=>{const M=x.resource===o.resource;return i.jsxs("div",{style:{...a.planCard,...M?a.currentPlan:{}},children:[i.jsx("div",{style:a.planName,children:x.name}),i.jsxs("div",{style:a.planPrice,children:[Y(x.price,x.currency),"/",x.interval]}),x.description&&i.jsx("div",{style:a.planDescription,children:x.description}),M?i.jsx("span",{style:a.currentBadge,children:"Current Plan"}):i.jsx("button",{onClick:()=>T(x.resource,x.interval),style:a.changePlanButton,disabled:q,children:x.price>o.pricePerPeriod?"Upgrade":"Downgrade"})]},x.resource)})})]}),i.jsxs("div",{className:"cedros-subscription-actions",style:a.actions,children:[h&&o.paymentMethod==="stripe"&&i.jsx("button",{onClick:A,style:a.portalButton,disabled:q,children:"Manage Billing"}),o.status==="active"&&!o.cancelAtPeriodEnd&&i.jsx("button",{onClick:()=>$(!1),style:a.cancelSubscriptionButton,disabled:q,children:"Cancel Subscription"})]})]})]})}function qt(){if(typeof window>"u")return{passed:!0,severity:"info",message:"HTTPS check skipped (SSR environment)"};const e=window.location.protocol==="https:",t=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1";return e||t?{passed:!0,severity:"info",message:"HTTPS enforced"}:{passed:!1,severity:"error",message:"Page not served over HTTPS",recommendation:"Enable HTTPS for all payment pages. Stripe.js requires HTTPS in production."}}function Lt(){return typeof document>"u"?{passed:!0,severity:"info",message:"CSP check skipped (SSR environment)"}:document.querySelector('meta[http-equiv="Content-Security-Policy"]')?{passed:!0,severity:"info",message:"Content Security Policy detected"}:{passed:!1,severity:"warning",message:"No Content Security Policy detected",recommendation:"Configure CSP headers to protect against XSS and CDN compromise. Use generateCSP() helper from @cedros/pay-react."}}function Nt(){return process.env.NODE_ENV==="development"||typeof window<"u"&&window.location.hostname==="localhost"?{passed:!0,severity:"info",message:"Running in development mode (some security checks relaxed)"}:{passed:!0,severity:"info",message:"Running in production mode"}}function Dt(){return{passed:!0,severity:"info",message:"Stripe.js loaded via @stripe/stripe-js package (CSP recommended, not SRI)",recommendation:"Ensure CSP script-src includes https://js.stripe.com"}}function Bt(){return typeof window>"u"?{passed:!0,severity:"info",message:"Mixed content check skipped (SSR environment)"}:window.location.protocol==="https:"?{passed:!0,severity:"info",message:"Mixed content protection active (HTTPS page)"}:{passed:!0,severity:"info",message:"Mixed content check skipped (HTTP page)"}}function $t(){const e=[qt(),Lt(),Nt(),Dt(),Bt()],t=e.some(d=>d.severity==="error"&&!d.passed),r=e.some(d=>d.severity==="warning"&&!d.passed);let s,n;return t?(s="vulnerable",n="Security issues detected. Review errors and apply recommendations."):r?(s="warnings",n="Minor security warnings detected. Consider applying recommendations."):(s="secure",n="All security checks passed."),{checks:e,overallStatus:s,summary:n}}function At(e){process.env.NODE_ENV!=="production"&&(console.group("🔒 Cedros Pay Security Report"),console.log(`Status: ${e.overallStatus.toUpperCase()}`),console.log(`Summary: ${e.summary}`),console.log(""),e.checks.forEach(t=>{const r=t.passed?"✅":t.severity==="error"?"❌":"⚠️";console.log(`${r} ${t.message}`),t.recommendation&&console.log(` → ${t.recommendation}`)}),console.groupEnd())}const zt={CSP:"Use generateCSP() from @cedros/pay-react to generate Content Security Policy headers",HTTPS:"Always serve payment pages over HTTPS in production",PACKAGE_UPDATES:"Keep @stripe/stripe-js and @cedros/pay-react updated for security patches",AUDIT:"Run npm audit regularly to check for known vulnerabilities",MONITORING:"Monitor Stripe security advisories and apply updates promptly",NO_SRI:"Do NOT use SRI hashes for Stripe.js - use CSP instead"};exports.CEDROS_EVENTS=W;exports.CSP_PRESETS=pt;exports.CedrosPay=St;exports.CreditsButton=fe;exports.CreditsSubscribeButton=kt;exports.PaymentMethodBadge=Pt;exports.PaymentModal=Me;exports.ProductPrice=vt;exports.PurchaseButton=Re;exports.RPC_PROVIDERS=dt;exports.SECURITY_RECOMMENDATIONS=zt;exports.StripeButton=pe;exports.SubscribeButton=jt;exports.SubscriptionManagementPanel=It;exports.calculateDiscountPercentage=Qe;exports.createDedupedClickHandler=K;exports.createTranslator=ke;exports.detectLocale=Pe;exports.emitPaymentError=F;exports.emitPaymentProcessing=J;exports.emitPaymentStart=X;exports.emitPaymentSuccess=Z;exports.emitWalletConnect=st;exports.emitWalletConnected=nt;exports.emitWalletError=ot;exports.formatCSP=ve;exports.formatCouponCodes=Ye;exports.generateCSP=ut;exports.generateCSPDirectives=Se;exports.getAvailableLocales=gt;exports.getCartItemCount=ee;exports.getLocalizedError=mt;exports.getModalCloseButtonStyles=we;exports.getUserErrorMessage=at;exports.isRetryableError=it;exports.loadLocale=je;exports.logSecurityReport=At;exports.normalizeCartItems=ie;exports.parseCouponCodes=He;exports.stackCheckoutCoupons=Ve;exports.useCreditsPayment=Ee;exports.useCreditsSubscription=_e;exports.useLocalizedError=ht;exports.usePaymentMode=te;exports.useStripeCheckout=de;exports.useSubscription=Te;exports.useSubscriptionManagement=Ie;exports.useTranslation=V;exports.validateSecurity=$t;
|
|
1
|
+
"use strict";var $e=Object.create;var ye=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var Fe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ze(t))!Oe.call(e,n)&&n!==r&&ye(e,n,{get:()=>t[n],enumerable:!(s=Ae(t,n))||s.enumerable});return e};var We=(e,t,r)=>(r=e!=null?$e(Ue(e)):{},Fe(t||!e||!e.__esModule?ye(r,"default",{value:e,enumerable:!0}):r,e));const S=require("./CedrosContext-7dwmEeUY.js"),i=require("react/jsx-runtime"),f=require("react");function He(e){return!e||!e.coupon_codes?[]:e.coupon_codes.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function Ye(e,t=", "){return e.join(t)}function Qe(e,t){return e<=0?0:(e-t)/e*100}function Ve(e,t){if(!t||t.length===0)return e;let r=e,s=0;for(const n of t)if(n.discountType==="percentage"){const d=1-n.discountValue/100;r=r*d}else n.discountType==="fixed"&&(s+=n.discountValue);return r=r-s,r<0&&(r=0),Math.ceil(r*100)/100}function Ce(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return 1;const r=Math.floor(t);return r>0?r:1}function ie(e){return e.map(t=>({resource:t.resource,quantity:Ce(t.quantity),variantId:t.variantId,metadata:t.metadata}))}function ee(e){return e.reduce((t,r)=>t+Ce(r.quantity),0)}function Ge(e){return!!(e&&e.length>0&&(e.length>1||e.length===1&&(e[0].quantity??1)>1))}const G=new Map,le=new Map,H=new Map,ae=1e3,xe=200,ue=2e3;function Ke(e){const t=H.get(e);return t?Date.now()<t?!0:(H.delete(e),!1):!1}function Xe(e,t=xe){const r=Date.now()+t;if(H.set(e,r),H.size>ae){const s=Array.from(H.keys()).slice(0,H.size-ae);for(const n of s)H.delete(n)}}function Je(e,t=ue){const r=G.get(e);if(!r)return!1;const n=Date.now()-r;return n<t?(S.getLogger().debug(`[Deduplication] Duplicate request blocked: ${e} (${n}ms ago)`),!0):!1}function Ze(e){if(G.set(e,Date.now()),G.size>ae){const t=Array.from(G.keys()).slice(0,G.size-ae);for(const r of t)G.delete(r)}}function et(e){return le.get(e)||null}function tt(e,t){le.set(e,t);const r=()=>{le.delete(e),Ze(e)};return t.then(r,r),t}async function rt(e,t,r={}){const{windowMs:s=ue,throwOnDuplicate:n=!0}=r,d=et(e);if(d)return S.getLogger().debug(`[Deduplication] Reusing in-flight request: ${e}`),d;if(Je(e,s)){if(n)throw new Error(`Duplicate request blocked: ${e}`);S.getLogger().warn(`[Deduplication] Duplicate request blocked but not throwing: ${e}`);return}const h=t();return tt(e,h)}function K(e,t,r={}){const{cooldownMs:s=xe,deduplicationWindowMs:n=ue}=r;return async()=>{if(Ke(e)){S.getLogger().debug(`[Deduplication] Button in cooldown: ${e}`);return}Xe(e,s);try{await rt(e,async()=>{const d=t();d instanceof Promise&&await d},{windowMs:n,throwOnDuplicate:!1})}catch(d){if(d instanceof Error&&d.message.includes("Duplicate request"))return;throw d}}}function we(e){return{background:"none",border:"none",fontSize:"1.5rem",cursor:"pointer",color:e,opacity:.6,padding:"0.25rem",lineHeight:1}}const W={PAYMENT_START:"cedros:payment:start",WALLET_CONNECT:"cedros:wallet:connect",WALLET_CONNECTED:"cedros:wallet:connected",WALLET_ERROR:"cedros:wallet:error",PAYMENT_PROCESSING:"cedros:payment:processing",PAYMENT_SUCCESS:"cedros:payment:success",PAYMENT_ERROR:"cedros:payment:error"};function Q(e,t){if(typeof window>"u")return;const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!1});window.dispatchEvent(r)}function X(e,t,r){Q(W.PAYMENT_START,{timestamp:Date.now(),method:e,resource:t,itemCount:r})}function st(e){Q(W.WALLET_CONNECT,{timestamp:Date.now(),wallet:e})}function nt(e,t){Q(W.WALLET_CONNECTED,{timestamp:Date.now(),wallet:e,publicKey:t})}function ot(e,t){Q(W.WALLET_ERROR,{timestamp:Date.now(),wallet:t,error:e})}function J(e,t,r){Q(W.PAYMENT_PROCESSING,{timestamp:Date.now(),method:e,resource:t,itemCount:r})}function Z(e,t,r,s){Q(W.PAYMENT_SUCCESS,{timestamp:Date.now(),method:e,transactionId:t,resource:r,itemCount:s})}function F(e,t,r,s){Q(W.PAYMENT_ERROR,{timestamp:Date.now(),method:e,error:t,resource:r,itemCount:s})}function it(e){return e instanceof S.PaymentError&&e.canRetry()}function at(e){return e instanceof S.PaymentError?e.getUserMessage():e instanceof Error?e.message:String(e)}function ct(e){switch(e){case"mainnet-beta":return"https://api.mainnet-beta.solana.com";case"devnet":return"https://api.devnet.solana.com";case"testnet":return"https://api.testnet.solana.com";default:return"https://api.mainnet-beta.solana.com"}}function lt(e){try{const t=new URL(e);return`${t.protocol}//${t.host}`}catch{return e}}function Se(e={}){const{solanaCluster:t="mainnet-beta",solanaEndpoint:r,customRpcProviders:s=[],allowUnsafeScripts:n=!1,additionalScriptSrc:d=[],additionalConnectSrc:h=[],additionalFrameSrc:C=[],includeStripe:y=!0,includeSolana:l=!0}=e;n&&console.warn("[CedrosPay] SECURITY WARNING: allowUnsafeScripts is enabled. This adds 'unsafe-inline' and 'unsafe-eval' to script-src, which significantly weakens CSP protection against XSS attacks. Only use this in development or if absolutely required by your framework.");const a=["'self'"];n&&a.push("'unsafe-inline'","'unsafe-eval'"),y&&a.push("https://js.stripe.com"),a.push(...d);const o=["'self'"];if(y&&o.push("https://api.stripe.com","https://*.stripe.com"),l){const c=ct(t);if(o.push(c),r){const u=lt(r);o.includes(u)||o.push(u)}s.forEach(u=>{o.includes(u)||o.push(u)})}o.push(...h);const p=["'self'"];return y&&p.push("https://js.stripe.com","https://checkout.stripe.com"),p.push(...C),{scriptSrc:a,connectSrc:o,frameSrc:p}}function ve(e,t="header"){const{scriptSrc:r,connectSrc:s,frameSrc:n}=e;switch(t){case"header":case"meta":case"nextjs":case"nginx":{const d=[];return r.length>0&&d.push(`script-src ${r.join(" ")}`),s.length>0&&d.push(`connect-src ${s.join(" ")}`),n.length>0&&d.push(`frame-src ${n.join(" ")}`),d.join("; ")}case"helmet":{const d={};return r.length>0&&(d.scriptSrc=r),s.length>0&&(d.connectSrc=s),n.length>0&&(d.frameSrc=n),d}case"directives":return{scriptSrc:r,connectSrc:s,frameSrc:n};default:throw new Error(`Unknown CSP format: ${t}`)}}function ut(e={},t="header"){const r=Se(e);return ve(r,t)}const dt={HELIUS:"https://*.helius-rpc.com",QUICKNODE:"https://*.quicknode.pro",ALCHEMY:"https://*.alchemy.com",ANKR:"https://rpc.ankr.com",TRITON:"https://*.rpcpool.com"},pt={MAINNET_CUSTOM_RPC:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,allowUnsafeScripts:!1}),MAINNET_NEXTJS:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,allowUnsafeScripts:!1}),DEVNET:()=>({solanaCluster:"devnet",allowUnsafeScripts:!1}),CRYPTO_ONLY:e=>({solanaCluster:"mainnet-beta",solanaEndpoint:e,includeStripe:!1}),STRIPE_ONLY:()=>({includeStripe:!0,includeSolana:!1})};function de(){const{stripeManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,transactionId:null}),s=f.useRef(!1),n=f.useCallback(async(C,y,l,a,o,p)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null});const c={resource:C,successUrl:y,cancelUrl:l,metadata:a,customerEmail:o,couponCode:p};try{const u=await e.processPayment(c);return r({status:u.success?"success":"error",error:u.success?null:u.error||"Payment failed",transactionId:u.success&&u.transactionId||null}),u}catch(u){const g=u instanceof Error?u.message:"Payment failed";return r({status:"error",error:g,transactionId:null}),{success:!1,error:g}}finally{s.current=!1}},[e]),d=f.useCallback(async(C,y,l,a,o,p,c,u,g,m,w,b,E)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null});const P=ie(C);try{const k=await e.processCartCheckout({items:P,successUrl:y,cancelUrl:l,metadata:a,customerEmail:o,customerName:c,customerPhone:u,shippingAddress:g,billingAddress:m,couponCode:p,tipAmount:w,shippingMethodId:b,paymentMethodId:E});return r({status:k.success?"success":"error",error:k.success?null:k.error||"Cart checkout failed",transactionId:k.success&&k.transactionId||null}),k}catch(k){const T=k instanceof Error?k.message:"Cart checkout failed";return r({status:"error",error:T,transactionId:null}),{success:!1,error:T}}finally{s.current=!1}},[e]),h=f.useCallback(()=>{r({status:"idle",error:null,transactionId:null}),s.current=!1},[]);return{...t,processPayment:n,processCartCheckout:d,reset:h}}function te(e,t){return f.useMemo(()=>{const r=Ge(t),s=e||(t?.length===1?t[0].resource:"");return{isCartMode:r,effectiveResource:s}},[e,t])}const ft=(e,t,r)=>{const s=e[t];return s?typeof s=="function"?s():Promise.resolve(s):new Promise((n,d)=>{(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(d.bind(null,new Error("Unknown variable dynamic import: "+t+(t.split("/").length!==r?". Note that variables only represent file names one level deep.":""))))})},ce=new Map;let oe=null;async function be(e){if(ce.has(e))return ce.get(e);try{const t=await ft(Object.assign({"./translations/ar.json":()=>Promise.resolve().then(()=>require("./ar-LVoQZTFI.js")),"./translations/bn.json":()=>Promise.resolve().then(()=>require("./bn-BR5Cv1T4.js")),"./translations/de.json":()=>Promise.resolve().then(()=>require("./de-pQxy-oD1.js")),"./translations/en.json":()=>Promise.resolve().then(()=>require("./en-Yikrt96u.js")),"./translations/es.json":()=>Promise.resolve().then(()=>require("./es-D24cg8dD.js")),"./translations/fil.json":()=>Promise.resolve().then(()=>require("./fil-BOBft9G-.js")),"./translations/fr.json":()=>Promise.resolve().then(()=>require("./fr-Ct9ub8Fa.js")),"./translations/he.json":()=>Promise.resolve().then(()=>require("./he-DtQqRKRq.js")),"./translations/id.json":()=>Promise.resolve().then(()=>require("./id-CiM2mL7C.js")),"./translations/in.json":()=>Promise.resolve().then(()=>require("./in-Bzcjmxcc.js")),"./translations/it.json":()=>Promise.resolve().then(()=>require("./it-Blb_pIJl.js")),"./translations/jp.json":()=>Promise.resolve().then(()=>require("./jp-9NHyIuwY.js")),"./translations/kr.json":()=>Promise.resolve().then(()=>require("./kr-DvzJ-0yX.js")),"./translations/ms.json":()=>Promise.resolve().then(()=>require("./ms-BOAu5pUB.js")),"./translations/nl.json":()=>Promise.resolve().then(()=>require("./nl-WHh_DfO8.js")),"./translations/pa.json":()=>Promise.resolve().then(()=>require("./pa-B7kIhZCF.js")),"./translations/pl.json":()=>Promise.resolve().then(()=>require("./pl-H0hBKdvF.js")),"./translations/pt.json":()=>Promise.resolve().then(()=>require("./pt-DwGrViQ3.js")),"./translations/ru.json":()=>Promise.resolve().then(()=>require("./ru-CB2m0UDT.js")),"./translations/ta.json":()=>Promise.resolve().then(()=>require("./ta-CAS197uN.js")),"./translations/th.json":()=>Promise.resolve().then(()=>require("./th-Cpz2cFcg.js")),"./translations/tr.json":()=>Promise.resolve().then(()=>require("./tr-hQrEFk86.js")),"./translations/uk.json":()=>Promise.resolve().then(()=>require("./uk-DrK2Sv8C.js")),"./translations/ur.json":()=>Promise.resolve().then(()=>require("./ur-D5-7mN9a.js")),"./translations/vn.json":()=>Promise.resolve().then(()=>require("./vn-B_iut9YL.js")),"./translations/zh.json":()=>Promise.resolve().then(()=>require("./zh-PR82dCHr.js"))}),`./translations/${e}.json`,3),r=t.default||t;return ce.set(e,r),r}catch{return null}}async function gt(){if(oe)return oe;const e=Object.assign({"./translations/ar.json":()=>Promise.resolve().then(()=>require("./ar-LVoQZTFI.js")),"./translations/bn.json":()=>Promise.resolve().then(()=>require("./bn-BR5Cv1T4.js")),"./translations/de.json":()=>Promise.resolve().then(()=>require("./de-pQxy-oD1.js")),"./translations/en.json":()=>Promise.resolve().then(()=>require("./en-Yikrt96u.js")),"./translations/es.json":()=>Promise.resolve().then(()=>require("./es-D24cg8dD.js")),"./translations/fil.json":()=>Promise.resolve().then(()=>require("./fil-BOBft9G-.js")),"./translations/fr.json":()=>Promise.resolve().then(()=>require("./fr-Ct9ub8Fa.js")),"./translations/he.json":()=>Promise.resolve().then(()=>require("./he-DtQqRKRq.js")),"./translations/id.json":()=>Promise.resolve().then(()=>require("./id-CiM2mL7C.js")),"./translations/in.json":()=>Promise.resolve().then(()=>require("./in-Bzcjmxcc.js")),"./translations/it.json":()=>Promise.resolve().then(()=>require("./it-Blb_pIJl.js")),"./translations/jp.json":()=>Promise.resolve().then(()=>require("./jp-9NHyIuwY.js")),"./translations/kr.json":()=>Promise.resolve().then(()=>require("./kr-DvzJ-0yX.js")),"./translations/ms.json":()=>Promise.resolve().then(()=>require("./ms-BOAu5pUB.js")),"./translations/nl.json":()=>Promise.resolve().then(()=>require("./nl-WHh_DfO8.js")),"./translations/pa.json":()=>Promise.resolve().then(()=>require("./pa-B7kIhZCF.js")),"./translations/pl.json":()=>Promise.resolve().then(()=>require("./pl-H0hBKdvF.js")),"./translations/pt.json":()=>Promise.resolve().then(()=>require("./pt-DwGrViQ3.js")),"./translations/ru.json":()=>Promise.resolve().then(()=>require("./ru-CB2m0UDT.js")),"./translations/ta.json":()=>Promise.resolve().then(()=>require("./ta-CAS197uN.js")),"./translations/th.json":()=>Promise.resolve().then(()=>require("./th-Cpz2cFcg.js")),"./translations/tr.json":()=>Promise.resolve().then(()=>require("./tr-hQrEFk86.js")),"./translations/uk.json":()=>Promise.resolve().then(()=>require("./uk-DrK2Sv8C.js")),"./translations/ur.json":()=>Promise.resolve().then(()=>require("./ur-D5-7mN9a.js")),"./translations/vn.json":()=>Promise.resolve().then(()=>require("./vn-B_iut9YL.js")),"./translations/zh.json":()=>Promise.resolve().then(()=>require("./zh-PR82dCHr.js"))}),t=[];for(const r in e){const s=r.match(/\.\/translations\/([a-z]{2,3}(?:-[A-Z]{2})?)\.json$/);s&&t.push(s[1])}return oe=t.length>0?t:["en"],oe}function Pe(){return typeof navigator>"u"?"en":(navigator.language||navigator.userLanguage||"en").split("-")[0].toLowerCase()}async function je(e){let t=await be(e);if(t||(t=await be("en"),t))return t;throw new Error("Critical: No translation files found, not even en.json")}function ke(e){return(t,r)=>{const s=t.split(".");let n=e;for(const d of s)if(n&&typeof n=="object"&&d in n)n=n[d];else return t;return typeof n!="string"?t:r?Object.entries(r).reduce((d,[h,C])=>d.replace(new RegExp(`\\{${h}\\}`,"g"),C),n):n}}function mt(e,t,r=!0){const s=t.errors[e];if(!s){const n=S.getUserFriendlyError(e);return r&&n.action?`${n.message} ${n.action}`:n.message}return r&&s.action?`${s.message} ${s.action}`:s.message}function V(e){const[t,r]=f.useState(null),[s,n]=f.useState(!0),d=f.useMemo(()=>e||Pe(),[e]);return f.useEffect(()=>{let C=!1;return(async()=>{n(!0);try{const l=await je(d);C||(r(l),n(!1))}catch(l){console.error("[CedrosPay] Failed to load translations:",l),C||n(!1)}})(),()=>{C=!0}},[d]),{t:f.useMemo(()=>t?ke(t):C=>({"ui.purchase":"Purchase","ui.pay_with_card":"Pay with Card","ui.pay_with_crypto":"Pay with USDC","ui.pay_with_usdc":"Pay with USDC","ui.card":"Card","ui.usdc_solana":"USDC (Solana)","ui.crypto":"Crypto","ui.processing":"Processing...","ui.loading":"Loading...","ui.connect_wallet":"Connect Wallet","ui.connecting":"Connecting..."})[C]||C,[t]),locale:d,isLoading:s,translations:t}}function ht(e,t=!0){const{translations:r}=V();if(!r){const n=S.getUserFriendlyError(e);return t&&n.action?`${n.message} ${n.action}`:n.message}const s=r.errors[e];if(!s){const n=S.getUserFriendlyError(e);return t&&n.action?`${n.message} ${n.action}`:n.message}return t&&s.action?`${s.message} ${s.action}`:s.message}function pe({resource:e,items:t,successUrl:r,cancelUrl:s,metadata:n,customerEmail:d,couponCode:h,label:C,disabled:y=!1,onAttempt:l,onSuccess:a,onError:o,className:p=""}){const{status:c,error:u,transactionId:g,processPayment:m,processCartCheckout:w}=de(),b=S.useCedrosTheme(),{isCartMode:E,effectiveResource:P}=te(e,t),{t:k,translations:T}=V(),D=C||k("ui.pay_with_card"),$=b.unstyled?p:`${b.className} cedros-theme__stripe-button ${p}`.trim(),A=u&&typeof u!="string"?u?.code??null:null,x=u?typeof u=="string"?u:(j=>{if(!j||!T)return"";const R=T.errors[j];return R?R.action?`${R.message} ${R.action}`:R.message:""})(A):null,M=f.useCallback(async()=>{S.getLogger().debug("[StripeButton] executePayment with couponCode:",h);const j=E&&t?ee(t):void 0;if(X("stripe",P,j),l&&l("stripe"),!E&&!P){const U="Invalid payment configuration: missing resource or items";S.getLogger().error("[StripeButton]",U),F("stripe",U,P,j),o&&o(U);return}let R;J("stripe",P,j),E&&t?(S.getLogger().debug("[StripeButton] Processing cart checkout with coupon:",h),R=await w(t,r,s,n,d,h)):P&&(S.getLogger().debug("[StripeButton] Processing single payment with coupon:",h),R=await m(P,r,s,n,d,h)),R&&R.success&&R.transactionId?(Z("stripe",R.transactionId,P,j),a&&a(R.transactionId)):R&&!R.success&&R.error&&(F("stripe",R.error,P,j),o&&o(R.error))},[h,E,P,t,r,s,n,d,w,m,l,a,o]),B=f.useMemo(()=>E&&t?`stripe-cart-${t.map(j=>j.resource).join("-")}`:`stripe-${P||"unknown"}`,[E,t,P]),_=f.useMemo(()=>K(B,M),[B,M]),I=c==="loading",v=y||I;return i.jsxs("div",{className:$,style:b.unstyled?{}:b.style,children:[i.jsx("button",{onClick:_,disabled:v,className:b.unstyled?p:"cedros-theme__button cedros-theme__stripe",type:"button",children:I?k("ui.processing"):D}),x&&i.jsx("div",{className:b.unstyled?"":"cedros-theme__error",children:x}),g&&i.jsx("div",{className:b.unstyled?"":"cedros-theme__success",children:k("ui.payment_successful")})]})}function Ee(){const{creditsManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,transactionId:null,requirement:null,holdId:null}),s=f.useRef(!1),n=f.useCallback(async(l,a)=>{r(o=>({...o,status:"loading",error:null}));try{const o=await e.requestQuote(l,a);return r(p=>({...p,status:"idle",requirement:o})),o}catch(o){const p=o instanceof Error?o.message:"Failed to fetch credits quote";return r(c=>({...c,status:"error",error:p})),null}},[e]),d=f.useCallback(async(l,a)=>{r(o=>({...o,status:"loading",error:null}));try{const o=ie(l),p=await e.requestCartQuote(o,a);return r(c=>({...c,status:"idle"})),p}catch(o){const p=o instanceof Error?o.message:"Failed to fetch cart credits quote";return r(c=>({...c,status:"error",error:p})),null}},[e]),h=f.useCallback(async(l,a,o,p)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null,requirement:null,holdId:null});try{const c=await e.processPayment(l,a,o,p);return r({status:c.success?"success":"error",error:c.success?null:c.error||"Credits payment failed",transactionId:c.success&&c.transactionId||null,requirement:null,holdId:null}),c}catch(c){const u=c instanceof Error?c.message:"Credits payment failed";return r({status:"error",error:u,transactionId:null,requirement:null,holdId:null}),{success:!1,error:u}}finally{s.current=!1}},[e]),C=f.useCallback(async(l,a,o,p)=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r({status:"loading",error:null,transactionId:null,requirement:null,holdId:null});let c=null;try{const u=ie(l),g=await e.requestCartQuote(u,o);if(!g)return r({status:"error",error:"Credits payment not available for this cart",transactionId:null,requirement:null,holdId:null}),{success:!1,error:"Credits payment not available"};c=(await e.createCartHold({cartId:g.cartId,authToken:a})).holdId,r(b=>({...b,holdId:c}));const w=await e.authorizeCartPayment({cartId:g.cartId,holdId:c,authToken:a,metadata:p});if(!w.success&&c)try{await e.releaseHold(c,a)}catch(b){S.getLogger().warn("[useCreditsPayment] Hold release failed, will expire server-side",{holdId:c,error:b instanceof Error?b.message:String(b)})}return r({status:w.success?"success":"error",error:w.success?null:w.error||"Cart credits payment failed",transactionId:w.success&&w.transactionId||null,requirement:null,holdId:null}),{success:w.success,transactionId:w.transactionId,error:w.error}}catch(u){const g=u instanceof Error?u.message:"Cart credits payment failed";if(c)try{await e.releaseHold(c,a)}catch(m){S.getLogger().warn("[useCreditsPayment] Hold release failed, will expire server-side",{holdId:c,error:m instanceof Error?m.message:String(m)})}return r({status:"error",error:g,transactionId:null,requirement:null,holdId:null}),{success:!1,error:g}}finally{s.current=!1}},[e]),y=f.useCallback(()=>{r({status:"idle",error:null,transactionId:null,requirement:null,holdId:null}),s.current=!1},[]);return{...t,fetchQuote:n,fetchCartQuote:d,processPayment:h,processCartPayment:C,reset:y}}function fe({resource:e,items:t,authToken:r,metadata:s,couponCode:n,label:d,disabled:h=!1,onAttempt:C,onSuccess:y,onError:l,className:a=""}){const{status:o,error:p,transactionId:c,processPayment:u,processCartPayment:g}=Ee(),m=S.useCedrosTheme(),{isCartMode:w,effectiveResource:b}=te(e,t),{t:E,translations:P}=V(),k=d||E("ui.pay_with_credits")||"Pay with Credits",T=m.unstyled?a:`${m.className} cedros-theme__credits-button ${a}`.trim(),D=p&&typeof p!="string"?p?.code??null:null,A=p?typeof p=="string"?p:(I=>{if(!I||!P)return"";const v=P.errors[I];return v?v.action?`${v.message} ${v.action}`:v.message:""})(D):null,q=f.useCallback(async()=>{S.getLogger().debug("[CreditsButton] executePayment");const I=w&&t?ee(t):void 0;if(X("credits",b,I),C&&C("credits"),!r){const j="Authentication required: please log in to pay with credits";S.getLogger().error("[CreditsButton]",j),F("credits",j,b,I),l&&l(j);return}if(!w&&!b){const j="Invalid payment configuration: missing resource";S.getLogger().error("[CreditsButton]",j),F("credits",j,b,I),l&&l(j);return}let v;J("credits",b,I),w&&t?(S.getLogger().debug("[CreditsButton] Processing cart checkout"),v=await g(t,r,n,s)):b&&(S.getLogger().debug("[CreditsButton] Processing single payment"),v=await u(b,r,n,s)),v&&v.success&&v.transactionId?(Z("credits",v.transactionId,b,I),y&&y(v.transactionId)):v&&!v.success&&v.error&&(F("credits",v.error,b,I),l&&l(v.error))},[r,w,b,t,n,s,u,g,C,y,l]),x=f.useMemo(()=>w&&t?`credits-cart-${t.map(I=>I.resource).join("-")}`:`credits-${b||"unknown"}`,[w,t,b]),M=f.useMemo(()=>K(x,q),[x,q]),B=o==="loading",_=h||B;return i.jsxs("div",{className:T,style:m.unstyled?{}:m.style,children:[i.jsx("button",{onClick:M,disabled:_,className:m.unstyled?a:"cedros-theme__button cedros-theme__credits",type:"button",children:B?E("ui.processing"):k}),A&&i.jsx("div",{className:m.unstyled?"":"cedros-theme__error",children:A}),c&&i.jsx("div",{className:m.unstyled?"":"cedros-theme__success",children:E("ui.payment_successful")})]})}const yt=f.lazy(()=>Promise.resolve().then(()=>require("./CryptoButton-C1AAOOfj.js")).then(e=>e.CryptoButton$1).then(e=>({default:e.CryptoButton}))),Me=({isOpen:e,onClose:t,resource:r,items:s,cardLabel:n="Card",cryptoLabel:d="USDC (Solana)",creditsLabel:h="Pay with Credits",showCard:C=!0,showCrypto:y=!0,showCredits:l=!1,onPaymentAttempt:a,onPaymentSuccess:o,onPaymentError:p,onStripeSuccess:c,onCryptoSuccess:u,onCreditsSuccess:g,onStripeError:m,onCryptoError:w,onCreditsError:b,customerEmail:E,successUrl:P,cancelUrl:k,metadata:T,couponCode:D,authToken:$,testPageUrl:A,hideMessages:q=!1})=>{const{tokens:x}=S.useCedrosTheme();return f.useEffect(()=>{const M=B=>{B.key==="Escape"&&e&&t()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e,t]),f.useEffect(()=>{if(e){const M=window.scrollY;return document.body.style.position="fixed",document.body.style.top=`-${M}px`,document.body.style.width="100%",document.body.style.overflowY="scroll",()=>{const B=document.body.style.top?Math.abs(parseInt(document.body.style.top.replace("px",""),10)):0;document.body.style.position="",document.body.style.top="",document.body.style.width="",document.body.style.overflowY="",window.scrollTo(0,B)}}},[e]),e?i.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:x.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:t,children:i.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:x.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${x.modalBorder}`},onClick:M=>M.stopPropagation(),children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[i.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:x.surfaceText},children:"Choose Payment Method"}),i.jsx("button",{type:"button",onClick:t,style:we(x.surfaceText),"aria-label":"Close modal",children:"×"})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[C&&i.jsx(pe,{resource:r,items:s,label:n,onAttempt:a,onSuccess:c||o,onError:m||p,customerEmail:E,successUrl:P,cancelUrl:k,metadata:T,couponCode:D}),y&&i.jsx(f.Suspense,{fallback:null,children:i.jsx(yt,{resource:r,items:s,label:d,onAttempt:a,onSuccess:u||o,onError:w||p,testPageUrl:A,hideMessages:q,metadata:T,couponCode:D})}),l&&i.jsx(fe,{resource:r,items:s,label:h,authToken:$,onAttempt:a?()=>a("credits"):void 0,onSuccess:g||o,onError:b||p,metadata:T,couponCode:D})]})]})}):null},Re=({resource:e,items:t,label:r,cardLabel:s,cryptoLabel:n,creditsLabel:d,showCard:h=!0,showCrypto:C=!0,showCredits:y=!1,onPaymentAttempt:l,onPaymentSuccess:a,onPaymentError:o,onStripeSuccess:p,onCryptoSuccess:c,onCreditsSuccess:u,onStripeError:g,onCryptoError:m,onCreditsError:w,customerEmail:b,successUrl:E,cancelUrl:P,metadata:k,couponCode:T,authToken:D,autoDetectWallets:$=!0,testPageUrl:A,hideMessages:q=!1,renderModal:x})=>{const M=S.useCedrosTheme(),[B,_]=f.useState(!1),{status:I,processPayment:v,processCartCheckout:j}=de(),{isCartMode:R,effectiveResource:U}=te(e,t),{t:L}=V(),O=r||L("ui.purchase"),Le=s||L("ui.card"),Ne=n||L("ui.usdc_solana"),De=d||L("ui.pay_with_credits")||"Pay with Credits",ge=f.useCallback(async()=>{if($&&h){const{detectSolanaWallets:N}=await Promise.resolve().then(()=>require("./walletDetection-bNmV5ItZ.js"));if(!N()){const se=R?void 0:U,ne=R&&t?ee(t):void 0;X("stripe",se,ne),l&&l("stripe"),J("stripe",se,ne);let z;R&&t?z=await j(t,E,P,k,b,T):U&&(z=await v(U,E,P,k,b,T)),z&&z.success&&z.transactionId?(Z("stripe",z.transactionId,se,ne),p?p(z.transactionId):a&&a(z.transactionId)):z&&!z.success&&z.error&&(F("stripe",z.error,se,ne),g?g(z.error):o&&o(z.error));return}}_(!0)},[$,h,R,t,U,j,v,E,P,k,b,T,a,o,p,g,l]),me=f.useMemo(()=>R&&t?`purchase-cart-${t.map(N=>N.resource).join("-")}`:`purchase-${U||"unknown"}`,[R,t,U]),Be=f.useMemo(()=>K(me,ge),[me,ge]),re=I==="loading",he={isOpen:B,onClose:()=>_(!1),resource:R?void 0:U,items:R?t:void 0,cardLabel:Le,cryptoLabel:Ne,creditsLabel:De,showCard:h,showCrypto:C,showCredits:y,onPaymentAttempt:l,onPaymentSuccess:N=>{_(!1),a?.(N)},onPaymentError:N=>{_(!1),o?.(N)},onStripeSuccess:N=>{_(!1),p?.(N)},onCryptoSuccess:N=>{_(!1),c?.(N)},onCreditsSuccess:N=>{_(!1),u?.(N)},onStripeError:N=>{_(!1),g?.(N)},onCryptoError:N=>{_(!1),m?.(N)},onCreditsError:N=>{_(!1),w?.(N)},customerEmail:b,successUrl:E,cancelUrl:P,metadata:k,couponCode:T,authToken:D,testPageUrl:A,hideMessages:q};return i.jsxs("div",{className:M.unstyled?"":M.className,style:M.unstyled?{}:M.style,children:[i.jsx("button",{onClick:Be,disabled:re,className:M.unstyled?"":"cedros-theme__button cedros-theme__stripe",style:{width:"100%",cursor:re?"not-allowed":"pointer",opacity:re?.6:1},type:"button",children:re?L("ui.processing"):O}),x?x(he):i.jsx(Me,{...he})]})},bt={"mainnet-beta":"https://api.mainnet-beta.solana.com",devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com"};function Ct(){const[e,t]=f.useState(null);return f.useEffect(()=>{let r=!1;return import("@solana/wallet-adapter-react").then(s=>{r||t(s)}),()=>{r=!0}},[]),e}function xt({endpoint:e,wallets:t,children:r}){const s=Ct();if(!s)return i.jsx(i.Fragment,{children:r});const{ConnectionProvider:n,WalletProvider:d}=s;return i.jsx(n,{endpoint:e,children:i.jsx(d,{wallets:t,autoConnect:!1,children:r})})}const wt=f.lazy(()=>Promise.resolve().then(()=>require("./CryptoButton-C1AAOOfj.js")).then(e=>e.CryptoButton$1).then(e=>({default:e.CryptoButton})));function St(e){const{resource:t,items:r,checkout:s={},display:n={},callbacks:d={},advanced:h={}}=e,{config:C,walletPool:y}=S.useCedrosContext(),l=S.useCedrosTheme(),{isCartMode:a}=te(t,r),o=n.showCrypto??!0,p=f.useMemo(()=>({marginTop:"0.5rem",fontSize:"0.875rem",color:l.tokens.surfaceText,opacity:.7,textAlign:"center"}),[l.tokens.surfaceText]),c=f.useMemo(()=>o?h.wallets&&h.wallets.length>0?h.wallets:y.getAdapters():[],[h.wallets,y,o]),u=f.useMemo(()=>r?ee(r):0,[r]),{onPaymentSuccess:g,onPaymentError:m,onPaymentAttempt:w}=d,b=f.useCallback(j=>g?.({transactionId:j,method:"stripe"}),[g]),E=f.useCallback(j=>g?.({transactionId:j,method:"crypto"}),[g]),P=f.useCallback(j=>m?.({message:j,method:"stripe"}),[m]),k=f.useCallback(j=>m?.({message:j,method:"crypto"}),[m]),T=f.useCallback(j=>g?.({transactionId:j,method:"credits"}),[g]),D=f.useCallback(j=>m?.({message:j,method:"credits"}),[m]),$=f.useCallback(()=>w?.("credits"),[w]),A=o?C.solanaEndpoint??bt[C.solanaCluster]:"";if(!t&&(!r||r.length===0))return S.getLogger().error('CedrosPay: Must provide either "resource" or "items" prop'),i.jsx("div",{className:n.className,style:{color:l.tokens.errorText},children:"Configuration error: No resource or items provided"});const q=n.showCard??!0,x=n.showCredits??!1,M=n.showPurchaseButton??!1,B=n.layout??"vertical",_=n.hideMessages??!1,I=h.autoDetectWallets??!0,v=i.jsx("div",{className:l.unstyled?n.className:`cedros-theme__pay ${n.className||""}`,children:i.jsxs("div",{className:l.unstyled?"":`cedros-theme__pay-content cedros-theme__pay-content--${B}`,children:[M?i.jsx(Re,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,label:n.purchaseLabel,cardLabel:n.cardLabel,cryptoLabel:n.cryptoLabel,showCard:q,showCrypto:o,onPaymentAttempt:d.onPaymentAttempt,onPaymentSuccess:b,onPaymentError:P,onStripeSuccess:b,onCryptoSuccess:E,onStripeError:P,onCryptoError:k,customerEmail:s.customerEmail,successUrl:s.successUrl,cancelUrl:s.cancelUrl,metadata:s.metadata,couponCode:s.couponCode,autoDetectWallets:I,testPageUrl:h.testPageUrl,hideMessages:_,renderModal:n.renderModal}):i.jsxs(i.Fragment,{children:[q&&i.jsx(pe,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,customerEmail:s.customerEmail,successUrl:s.successUrl,cancelUrl:s.cancelUrl,metadata:s.metadata,couponCode:s.couponCode,label:n.cardLabel,onAttempt:d.onPaymentAttempt,onSuccess:b,onError:P}),o&&i.jsx(f.Suspense,{fallback:null,children:i.jsx(wt,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,metadata:s.metadata,couponCode:s.couponCode,label:n.cryptoLabel,onAttempt:d.onPaymentAttempt,onSuccess:E,onError:k,testPageUrl:h.testPageUrl,hideMessages:_})}),x&&i.jsx(fe,{resource:a?void 0:t||r?.[0]?.resource,items:a?r:void 0,authToken:s.authToken,metadata:s.metadata,couponCode:s.couponCode,label:n.creditsLabel,onAttempt:$,onSuccess:T,onError:D})]}),a&&r&&r.length>1&&!_&&i.jsxs("div",{style:p,children:["Checking out ",u," items"]})]})});return i.jsx("div",{className:l.unstyled?n.className:l.className,style:l.unstyled?{}:l.style,children:i.jsx(xt,{endpoint:A||"https://api.devnet.solana.com",wallets:c,children:v})})}function vt({product:e,paymentMethod:t,showOriginalPrice:r=!1,className:s="",style:n={}}){const d=t==="stripe",h=d?e.fiatAmount:e.cryptoAmount,C=d?e.effectiveFiatAmount:e.effectiveCryptoAmount,y=d?e.fiatCurrency.toUpperCase():e.cryptoToken,l=d?e.hasStripeCoupon:e.hasCryptoCoupon,a=d?e.stripeDiscountPercent:e.cryptoDiscountPercent;return i.jsxs("div",{className:s,style:n,children:[r&&l&&i.jsxs("span",{style:{textDecoration:"line-through",opacity:.6,marginRight:"0.5rem",fontSize:"0.875em"},children:[h.toFixed(2)," ",y]}),i.jsxs("span",{style:{fontWeight:600},children:[C.toFixed(2)," ",y]}),l&&a>0&&i.jsxs("span",{style:{marginLeft:"0.5rem",padding:"0.125rem 0.375rem",backgroundColor:"#10b981",color:"white",borderRadius:"0.25rem",fontSize:"0.75em",fontWeight:600},children:[a,"% OFF"]})]})}function Pt({product:e,paymentMethod:t,className:r="",style:s={}}){const n=t==="stripe",d=n?e.hasStripeCoupon:e.hasCryptoCoupon,h=n?e.stripeDiscountPercent:e.cryptoDiscountPercent,C=n?e.stripeCouponCode:e.cryptoCouponCode;if(!d||h===0)return null;const y=n?`${h}% off with card!`:`${h}% off with crypto!`;return i.jsxs("div",{className:r,style:{display:"inline-flex",alignItems:"center",padding:"0.5rem 0.75rem",backgroundColor:n?"#6366f1":"#10b981",color:"white",borderRadius:"0.375rem",fontSize:"0.875rem",fontWeight:600,...s},children:[y,C&&i.jsxs("span",{style:{marginLeft:"0.5rem",opacity:.8,fontSize:"0.75em",fontWeight:400},children:["(",C,")"]})]})}function Te(){const{subscriptionManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),s=f.useRef(!1),n=f.useCallback(async y=>{if(s.current)return{success:!1,error:"Payment already in progress"};s.current=!0,r(l=>({...l,status:"loading",error:null}));try{const l=await e.processSubscription(y);return r(a=>({...a,status:l.success?"success":"error",error:l.success?null:l.error||"Subscription failed",sessionId:l.success&&l.transactionId||null})),l}catch(l){const a=S.formatError(l,"Subscription failed");return r(o=>({...o,status:"error",error:a})),{success:!1,error:a}}finally{s.current=!1}},[e]),d=f.useCallback(async y=>{r(l=>({...l,status:"checking",error:null}));try{const l=await e.checkSubscriptionStatus(y);return r(a=>({...a,status:l.active?"success":"idle",subscriptionStatus:l.status,expiresAt:l.expiresAt||l.currentPeriodEnd||null})),l}catch(l){const a=l instanceof Error?l.message:"Failed to check subscription status";throw r(o=>({...o,status:"error",error:a})),l}},[e]),h=f.useCallback(async(y,l,a)=>{r(o=>({...o,status:"loading",error:null}));try{const o=await e.requestSubscriptionQuote(y,l,a);return r(p=>({...p,status:"idle"})),o}catch(o){const p=o instanceof Error?o.message:"Failed to get subscription quote";throw r(c=>({...c,status:"error",error:p})),o}},[e]),C=f.useCallback(()=>{r({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null})},[]);return{...t,processSubscription:n,checkStatus:d,requestQuote:h,reset:C}}function jt({resource:e,interval:t,intervalDays:r,trialDays:s,successUrl:n,cancelUrl:d,metadata:h,customerEmail:C,couponCode:y,label:l,disabled:a=!1,onAttempt:o,onSuccess:p,onError:c,className:u=""}){const{status:g,error:m,sessionId:w,processSubscription:b}=Te(),E=S.useCedrosTheme(),{t:P,translations:k}=V(),T=l||P("ui.subscribe"),D=E.unstyled?u:`${E.className} cedros-theme__stripe-button ${u}`.trim(),$=m&&typeof m!="string"?m?.code??null:null,q=m?typeof m=="string"?m:(v=>{if(!v||!k)return"";const j=k.errors[v];return j?j.action?`${j.message} ${j.action}`:j.message:""})($):null,x=f.useCallback(async()=>{S.getLogger().debug("[SubscribeButton] executeSubscription:",{resource:e,interval:t,intervalDays:r,trialDays:s,couponCode:y}),X("stripe",e),o&&o("stripe"),J("stripe",e);const v=await b({resource:e,interval:t,intervalDays:r,trialDays:s,customerEmail:C,metadata:h,couponCode:y,successUrl:n,cancelUrl:d});v.success&&v.transactionId?(Z("stripe",v.transactionId,e),p&&p(v.transactionId)):!v.success&&v.error&&(F("stripe",v.error,e),c&&c(v.error))},[e,t,r,s,C,h,y,n,d,b,o,p,c]),M=f.useMemo(()=>`subscribe-${e}-${t}`,[e,t]),B=f.useMemo(()=>K(M,x),[M,x]),_=g==="loading",I=a||_;return i.jsxs("div",{className:D,style:E.unstyled?{}:E.style,children:[i.jsx("button",{onClick:B,disabled:I,className:E.unstyled?u:"cedros-theme__button cedros-theme__stripe",type:"button",children:_?P("ui.processing"):T}),q&&i.jsx("div",{className:E.unstyled?"":"cedros-theme__error",children:q}),w&&i.jsx("div",{className:E.unstyled?"":"cedros-theme__success",children:P("ui.redirecting_to_checkout")})]})}function _e(){const{subscriptionManager:e,creditsManager:t}=S.useCedrosContext(),[r,s]=f.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null,creditsRequirement:null}),n=f.useRef(!1),d=f.useCallback(async(l,a)=>{s(o=>({...o,status:"checking",error:null}));try{const o=await e.checkSubscriptionStatus({resource:l,userId:a});return s(p=>({...p,status:o.active?"success":"idle",subscriptionStatus:o.status,expiresAt:o.expiresAt||o.currentPeriodEnd||null})),o}catch(o){const p=S.formatError(o,"Failed to check subscription status");return s(c=>({...c,status:"error",error:p})),null}},[e]),h=f.useCallback(async(l,a,o)=>{s(p=>({...p,status:"loading",error:null}));try{const p=await t.requestQuote(l,o?.couponCode);return s(c=>({...c,status:"idle",creditsRequirement:p})),p}catch(p){const c=S.formatError(p,"Failed to get subscription quote");return s(u=>({...u,status:"error",error:c})),null}},[t]),C=f.useCallback(async(l,a,o,p)=>{if(n.current)return{success:!1,error:"Payment already in progress"};if(!o){const c="Authentication required for credits payment";return s(u=>({...u,status:"error",error:c})),{success:!1,error:c}}n.current=!0,s(c=>({...c,status:"loading",error:null}));try{const c=await t.processPayment(l,o,p?.couponCode,{interval:a,...p?.intervalDays&&{intervalDays:String(p.intervalDays)}});return c.success?s({status:"success",error:null,sessionId:c.transactionId||null,subscriptionStatus:"active",expiresAt:null,creditsRequirement:null}):s(u=>({...u,status:"error",error:c.error||"Credits subscription payment failed"})),c}catch(c){const u=S.formatError(c,"Credits subscription payment failed");return s(g=>({...g,status:"error",error:u})),{success:!1,error:u}}finally{n.current=!1}},[t]),y=f.useCallback(()=>{s({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null,creditsRequirement:null})},[]);return{...r,checkStatus:d,requestQuote:h,processPayment:C,reset:y}}function kt({resource:e,interval:t,intervalDays:r,authToken:s,userId:n,couponCode:d,label:h,disabled:C=!1,onAttempt:y,onSuccess:l,onError:a,className:o="",hideMessages:p=!1,autoCheckStatus:c=!1}){const{status:u,error:g,subscriptionStatus:m,expiresAt:w,checkStatus:b,processPayment:E}=_e(),P=S.useCedrosTheme(),{t:k,translations:T}=V(),D=f.useRef(b);f.useEffect(()=>{D.current=b},[b]),f.useEffect(()=>{c&&n&&(S.getLogger().debug("[CreditsSubscribeButton] Auto-checking subscription status",{resource:e,userId:n}),D.current(e,n))},[c,n,e]);const $=h||k("ui.subscribe_with_credits")||"Subscribe with Credits",A=g&&typeof g!="string"?g?.code??null:null,x=g?typeof g=="string"?g:(L=>{if(!L||!T)return"";const O=T.errors[L];return O?O.action?`${O.message} ${O.action}`:O.message:""})(A):null,M=f.useCallback(async()=>{if(S.getLogger().debug("[CreditsSubscribeButton] executeSubscriptionFlow",{resource:e,interval:t,intervalDays:r,hasAuthToken:!!s}),X("credits",e),y&&y("credits"),!s){const O="Authentication required: please log in to subscribe with credits";S.getLogger().error("[CreditsSubscribeButton]",O),F("credits",O,e),a&&a(O);return}J("credits",e);const L=await E(e,t,s,{couponCode:d,intervalDays:r});L.success&&L.transactionId?(Z("credits",L.transactionId,e),l&&l(L.transactionId)):!L.success&&L.error&&(F("credits",L.error,e),a&&a(L.error))},[e,t,r,s,d,E,y,l,a]),B=f.useMemo(()=>`credits-subscribe-${e}-${t}`,[e,t]),_=f.useMemo(()=>K(B,M,{cooldownMs:200,deduplicationWindowMs:0}),[B,M]),I=u==="loading"||u==="checking",v=m==="active"||m==="trialing",j=C||I||v;let R=$;if(I)R=k("ui.processing");else if(v&&w){const L=new Date(w).toLocaleDateString();R=`${k("ui.subscribed_until")} ${L}`}else v&&(R=k("ui.subscribed"));const U=P.unstyled?o:`${P.className} cedros-theme__credits-button ${o}`.trim();return i.jsxs("div",{className:U,style:P.unstyled?{}:P.style,children:[i.jsx("button",{onClick:_,disabled:j,className:P.unstyled?o:"cedros-theme__button cedros-theme__credits",type:"button",children:R}),!p&&x&&i.jsx("div",{className:P.unstyled?"":"cedros-theme__error",children:x}),!p&&v&&i.jsx("div",{className:P.unstyled?"":"cedros-theme__success",children:k("ui.subscription_active")})]})}function Ie(){const{subscriptionChangeManager:e}=S.useCedrosContext(),[t,r]=f.useState({status:"idle",error:null,subscription:null,changePreview:null,userId:null}),s=f.useRef(t);s.current=t;const n=f.useCallback(async(o,p)=>{r(c=>({...c,status:"loading",error:null}));try{const c=await e.getDetails(o,p);return r(u=>({...u,status:"success",subscription:c,userId:p})),c}catch(c){const u=c instanceof Error?c.message:"Failed to load subscription";return r(g=>({...g,status:"error",error:u})),null}},[e]),d=f.useCallback(async(o,p,c,u)=>{r(g=>({...g,status:"loading",error:null}));try{const g={currentResource:o,newResource:p,userId:c,newInterval:u},m=await e.previewChange(g);return r(w=>({...w,status:"idle",changePreview:m})),m}catch(g){const m=g instanceof Error?g.message:"Failed to preview change";return r(w=>({...w,status:"error",error:m})),null}},[e]),h=f.useCallback(async o=>{const{subscription:p,userId:c}=s.current;if(!p||!c)return r(u=>({...u,status:"error",error:"No subscription loaded"})),null;r(u=>({...u,status:"loading",error:null}));try{const u={currentResource:p.resource,newResource:o.newResource,userId:c,newInterval:o.newInterval,prorationBehavior:o.prorationBehavior,immediate:o.immediate},g=await e.changeSubscription(u);return g.success?r(m=>({...m,status:"success",subscription:m.subscription?{...m.subscription,resource:g.newResource,interval:g.newInterval,status:g.status}:null,changePreview:null})):r(m=>({...m,status:"error",error:g.error||"Failed to change subscription"})),g}catch(u){const g=u instanceof Error?u.message:"Failed to change subscription";return r(m=>({...m,status:"error",error:g})),null}},[e]),C=f.useCallback(async o=>{const{subscription:p,userId:c}=s.current;if(!p||!c)return r(u=>({...u,status:"error",error:"No subscription loaded"})),null;r(u=>({...u,status:"loading",error:null}));try{const u={resource:p.resource,userId:c,immediate:o},g=await e.cancel(u);if(g.success){const m=o?"canceled":p.status;r(w=>({...w,status:"success",subscription:w.subscription?{...w.subscription,status:m,cancelAtPeriodEnd:!o}:null}))}else r(m=>({...m,status:"error",error:g.error||"Failed to cancel subscription"}));return g}catch(u){const g=u instanceof Error?u.message:"Failed to cancel subscription";return r(m=>({...m,status:"error",error:g})),null}},[e]),y=f.useCallback(async(o,p)=>{r(c=>({...c,status:"loading",error:null}));try{const c=await e.getBillingPortalUrl({userId:o,returnUrl:p});try{if(new URL(c.url).protocol!=="https:")throw new Error("Billing portal URL must use HTTPS")}catch{throw new Error("Invalid billing portal URL")}return window.location.href=c.url,c}catch(c){const u=c instanceof Error?c.message:"Failed to open billing portal";return r(g=>({...g,status:"error",error:u})),null}},[e]),l=f.useCallback(()=>{r(o=>({...o,changePreview:null}))},[]),a=f.useCallback(()=>{r({status:"idle",error:null,subscription:null,changePreview:null,userId:null})},[]);return{...t,loadSubscription:n,previewChange:d,changeSubscription:h,cancelSubscription:C,openBillingPortal:y,clearPreview:l,reset:a}}const Et={bg:"#fff",bgMuted:"#f9fafb",bgHighlight:"#eff6ff",text:"#111827",textMuted:"#6b7280",textFaint:"#9ca3af",border:"#e5e7eb",borderLight:"#f3f4f6",primary:"#3b82f6",error:"#ef4444",errorBg:"#fef2f2",errorBorder:"#fecaca",warningBg:"#fef3c7",warningBorder:"#fcd34d",warningText:"#92400e",buttonBg:"#f3f4f6",buttonBorder:"#d1d5db",buttonText:"#374151"},Mt={bg:"#1e293b",bgMuted:"#334155",bgHighlight:"rgba(59, 130, 246, 0.15)",text:"#f1f5f9",textMuted:"#94a3b8",textFaint:"#64748b",border:"#475569",borderLight:"#334155",primary:"#3b82f6",error:"#ef4444",errorBg:"rgba(239, 68, 68, 0.15)",errorBorder:"rgba(239, 68, 68, 0.3)",warningBg:"rgba(245, 158, 11, 0.15)",warningBorder:"rgba(245, 158, 11, 0.3)",warningText:"#fbbf24",buttonBg:"#334155",buttonBorder:"#475569",buttonText:"#e2e8f0"};function Rt(e){const t=e?Mt:Et;return{container:{padding:"24px",backgroundColor:t.bg,borderRadius:"8px",border:`1px solid ${t.border}`,fontFamily:"system-ui, -apple-system, sans-serif",color:t.text},error:{padding:"12px 16px",backgroundColor:t.errorBg,border:`1px solid ${t.errorBorder}`,borderRadius:"6px",color:t.error,marginBottom:"16px"},loading:{padding:"24px",textAlign:"center",color:t.textMuted},details:{marginBottom:"24px"},title:{margin:"0 0 16px 0",fontSize:"18px",fontWeight:600,color:t.text},detailRow:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:`1px solid ${t.borderLight}`},label:{color:t.textMuted,fontSize:"14px"},value:{color:t.text,fontSize:"14px",fontWeight:500},statusBadge:{padding:"4px 8px",borderRadius:"4px",color:"#fff",fontSize:"12px",fontWeight:500,textTransform:"capitalize"},cancelNotice:{marginTop:"12px",padding:"8px 12px",backgroundColor:t.warningBg,border:`1px solid ${t.warningBorder}`,borderRadius:"6px",color:t.warningText,fontSize:"13px"},prorationPreview:{padding:"16px",backgroundColor:t.bgMuted,borderRadius:"8px",marginBottom:"24px"},previewTitle:{margin:"0 0 12px 0",fontSize:"16px",fontWeight:600,color:t.text},previewDetails:{marginBottom:"16px"},previewRow:{display:"flex",justifyContent:"space-between",padding:"6px 0",fontSize:"14px",color:t.textMuted},previewTotal:{borderTop:`1px solid ${t.border}`,marginTop:"8px",paddingTop:"12px",fontWeight:600,color:t.text},previewActions:{display:"flex",gap:"12px",justifyContent:"flex-end"},cancelButton:{padding:"8px 16px",backgroundColor:t.bg,border:`1px solid ${t.buttonBorder}`,borderRadius:"6px",color:t.buttonText,cursor:"pointer",fontSize:"14px"},confirmButton:{padding:"8px 16px",backgroundColor:t.primary,border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500},plansSection:{marginBottom:"24px"},plansTitle:{margin:"0 0 12px 0",fontSize:"16px",fontWeight:600,color:t.text},plansList:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px"},planCard:{padding:"16px",backgroundColor:t.bg,border:`1px solid ${t.border}`,borderRadius:"8px",textAlign:"center"},currentPlan:{borderColor:t.primary,backgroundColor:t.bgHighlight},planName:{fontSize:"16px",fontWeight:600,color:t.text,marginBottom:"4px"},planPrice:{fontSize:"14px",color:t.textMuted,marginBottom:"8px"},planDescription:{fontSize:"12px",color:t.textFaint,marginBottom:"12px"},currentBadge:{display:"inline-block",padding:"4px 8px",backgroundColor:t.primary,color:"#fff",borderRadius:"4px",fontSize:"12px",fontWeight:500},changePlanButton:{padding:"8px 16px",backgroundColor:t.buttonBg,border:`1px solid ${t.buttonBorder}`,borderRadius:"6px",color:t.buttonText,cursor:"pointer",fontSize:"14px",width:"100%"},actions:{display:"flex",gap:"12px",justifyContent:"flex-end",paddingTop:"16px",borderTop:`1px solid ${t.border}`},portalButton:{padding:"10px 20px",backgroundColor:t.primary,border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:500},cancelSubscriptionButton:{padding:"10px 20px",backgroundColor:t.bg,border:`1px solid ${t.error}`,borderRadius:"6px",color:t.error,cursor:"pointer",fontSize:"14px"}}}function Y(e,t){return new Intl.NumberFormat("en-US",{style:"currency",currency:t.toUpperCase()}).format(e/100)}function qe(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function Tt(e){switch(e){case"active":return"#22c55e";case"trialing":return"#3b82f6";case"past_due":return"#f59e0b";case"canceled":case"expired":return"#ef4444";default:return"#6b7280"}}function _t({preview:e,onConfirm:t,onCancel:r,isLoading:s,styles:n}){const d=e.immediateAmount<0;return i.jsxs("div",{className:"cedros-proration-preview",style:n.prorationPreview,children:[i.jsx("h4",{style:n.previewTitle,children:"Change Preview"}),i.jsxs("div",{style:n.previewDetails,children:[i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Current plan:"}),i.jsxs("span",{children:[Y(e.currentPlanPrice,e.currency),"/period"]})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"New plan:"}),i.jsxs("span",{children:[Y(e.newPlanPrice,e.currency),"/period"]})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Days remaining:"}),i.jsxs("span",{children:[e.daysRemaining," days"]})]}),e.prorationDetails&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Unused credit:"}),i.jsxs("span",{children:["-",Y(e.prorationDetails.unusedCredit,e.currency)]})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"New plan cost:"}),i.jsx("span",{children:Y(e.prorationDetails.newPlanCost,e.currency)})]})]}),i.jsxs("div",{style:{...n.previewRow,...n.previewTotal},children:[i.jsx("span",{children:d?"Credit to account:":"Amount due now:"}),i.jsx("span",{style:{color:d?"#22c55e":"#ef4444"},children:Y(Math.abs(e.immediateAmount),e.currency)})]}),i.jsxs("div",{style:n.previewRow,children:[i.jsx("span",{children:"Effective date:"}),i.jsx("span",{children:qe(e.effectiveDate)})]})]}),i.jsxs("div",{style:n.previewActions,children:[i.jsx("button",{onClick:r,style:n.cancelButton,disabled:s,children:"Cancel"}),i.jsx("button",{onClick:t,style:n.confirmButton,disabled:s,children:s?"Processing...":"Confirm Change"})]})]})}function It({resource:e,userId:t,availablePlans:r=[],onSubscriptionChanged:s,onSubscriptionCanceled:n,billingPortalReturnUrl:d,showBillingPortal:h=!1,className:C,style:y}){const{mode:l}=S.useCedrosTheme(),a=f.useMemo(()=>Rt(l==="dark"),[l]),{subscription:o,changePreview:p,status:c,error:u,loadSubscription:g,previewChange:m,changeSubscription:w,cancelSubscription:b,openBillingPortal:E,clearPreview:P}=Ie();f.useEffect(()=>{g(e,t)},[e,t,g]);const k=f.useRef(null),T=f.useCallback(async(x,M)=>{k.current={resource:x,interval:M},await m(e,x,t,M)},[e,t,m]),D=f.useCallback(async()=>{if(!p)return;const x=k.current;(await w({newResource:x?.resource||e,newInterval:x?.interval,immediate:!0}))?.success&&x&&x.interval&&(s?.(x.resource,x.interval),k.current=null)},[p,e,w,s]),$=f.useCallback(async x=>{(await b(x))?.success&&n?.()},[b,n]),A=f.useCallback(()=>{E(t,d)},[t,d,E]),q=c==="loading";return i.jsxs("div",{className:`cedros-subscription-panel ${C||""}`,style:{...a.container,...y},children:[u&&i.jsx("div",{className:"cedros-subscription-error",style:a.error,children:u}),q&&!o&&i.jsx("div",{className:"cedros-subscription-loading",style:a.loading,children:"Loading subscription..."}),o&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"cedros-subscription-details",style:a.details,children:[i.jsx("h3",{style:a.title,children:"Current Subscription"}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Plan:"}),i.jsx("span",{style:a.value,children:o.resource})]}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Status:"}),i.jsx("span",{style:{...a.statusBadge,backgroundColor:Tt(o.status)},children:o.status})]}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Price:"}),i.jsxs("span",{style:a.value,children:[Y(o.pricePerPeriod,o.currency),"/",o.interval]})]}),i.jsxs("div",{style:a.detailRow,children:[i.jsx("span",{style:a.label,children:"Current period ends:"}),i.jsx("span",{style:a.value,children:qe(o.currentPeriodEnd)})]}),o.cancelAtPeriodEnd&&i.jsx("div",{style:a.cancelNotice,children:"Subscription will cancel at end of current period"})]}),p&&i.jsx(_t,{preview:p,onConfirm:D,onCancel:P,isLoading:q,styles:a}),r.length>0&&!p&&i.jsxs("div",{className:"cedros-available-plans",style:a.plansSection,children:[i.jsx("h4",{style:a.plansTitle,children:"Available Plans"}),i.jsx("div",{style:a.plansList,children:r.map(x=>{const M=x.resource===o.resource;return i.jsxs("div",{style:{...a.planCard,...M?a.currentPlan:{}},children:[i.jsx("div",{style:a.planName,children:x.name}),i.jsxs("div",{style:a.planPrice,children:[Y(x.price,x.currency),"/",x.interval]}),x.description&&i.jsx("div",{style:a.planDescription,children:x.description}),M?i.jsx("span",{style:a.currentBadge,children:"Current Plan"}):i.jsx("button",{onClick:()=>T(x.resource,x.interval),style:a.changePlanButton,disabled:q,children:x.price>o.pricePerPeriod?"Upgrade":"Downgrade"})]},x.resource)})})]}),i.jsxs("div",{className:"cedros-subscription-actions",style:a.actions,children:[h&&o.paymentMethod==="stripe"&&i.jsx("button",{onClick:A,style:a.portalButton,disabled:q,children:"Manage Billing"}),o.status==="active"&&!o.cancelAtPeriodEnd&&i.jsx("button",{onClick:()=>$(!1),style:a.cancelSubscriptionButton,disabled:q,children:"Cancel Subscription"})]})]})]})}function qt(){if(typeof window>"u")return{passed:!0,severity:"info",message:"HTTPS check skipped (SSR environment)"};const e=window.location.protocol==="https:",t=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1";return e||t?{passed:!0,severity:"info",message:"HTTPS enforced"}:{passed:!1,severity:"error",message:"Page not served over HTTPS",recommendation:"Enable HTTPS for all payment pages. Stripe.js requires HTTPS in production."}}function Lt(){return typeof document>"u"?{passed:!0,severity:"info",message:"CSP check skipped (SSR environment)"}:document.querySelector('meta[http-equiv="Content-Security-Policy"]')?{passed:!0,severity:"info",message:"Content Security Policy detected"}:{passed:!1,severity:"warning",message:"No Content Security Policy detected",recommendation:"Configure CSP headers to protect against XSS and CDN compromise. Use generateCSP() helper from @cedros/pay-react."}}function Nt(){return process.env.NODE_ENV==="development"||typeof window<"u"&&window.location.hostname==="localhost"?{passed:!0,severity:"info",message:"Running in development mode (some security checks relaxed)"}:{passed:!0,severity:"info",message:"Running in production mode"}}function Dt(){return{passed:!0,severity:"info",message:"Stripe.js loaded via @stripe/stripe-js package (CSP recommended, not SRI)",recommendation:"Ensure CSP script-src includes https://js.stripe.com"}}function Bt(){return typeof window>"u"?{passed:!0,severity:"info",message:"Mixed content check skipped (SSR environment)"}:window.location.protocol==="https:"?{passed:!0,severity:"info",message:"Mixed content protection active (HTTPS page)"}:{passed:!0,severity:"info",message:"Mixed content check skipped (HTTP page)"}}function $t(){const e=[qt(),Lt(),Nt(),Dt(),Bt()],t=e.some(d=>d.severity==="error"&&!d.passed),r=e.some(d=>d.severity==="warning"&&!d.passed);let s,n;return t?(s="vulnerable",n="Security issues detected. Review errors and apply recommendations."):r?(s="warnings",n="Minor security warnings detected. Consider applying recommendations."):(s="secure",n="All security checks passed."),{checks:e,overallStatus:s,summary:n}}function At(e){process.env.NODE_ENV!=="production"&&(console.group("🔒 Cedros Pay Security Report"),console.log(`Status: ${e.overallStatus.toUpperCase()}`),console.log(`Summary: ${e.summary}`),console.log(""),e.checks.forEach(t=>{const r=t.passed?"✅":t.severity==="error"?"❌":"⚠️";console.log(`${r} ${t.message}`),t.recommendation&&console.log(` → ${t.recommendation}`)}),console.groupEnd())}const zt={CSP:"Use generateCSP() from @cedros/pay-react to generate Content Security Policy headers",HTTPS:"Always serve payment pages over HTTPS in production",PACKAGE_UPDATES:"Keep @stripe/stripe-js and @cedros/pay-react updated for security patches",AUDIT:"Run npm audit regularly to check for known vulnerabilities",MONITORING:"Monitor Stripe security advisories and apply updates promptly",NO_SRI:"Do NOT use SRI hashes for Stripe.js - use CSP instead"};exports.CEDROS_EVENTS=W;exports.CSP_PRESETS=pt;exports.CedrosPay=St;exports.CreditsButton=fe;exports.CreditsSubscribeButton=kt;exports.PaymentMethodBadge=Pt;exports.PaymentModal=Me;exports.ProductPrice=vt;exports.PurchaseButton=Re;exports.RPC_PROVIDERS=dt;exports.SECURITY_RECOMMENDATIONS=zt;exports.StripeButton=pe;exports.SubscribeButton=jt;exports.SubscriptionManagementPanel=It;exports.calculateDiscountPercentage=Qe;exports.createDedupedClickHandler=K;exports.createTranslator=ke;exports.detectLocale=Pe;exports.emitPaymentError=F;exports.emitPaymentProcessing=J;exports.emitPaymentStart=X;exports.emitPaymentSuccess=Z;exports.emitWalletConnect=st;exports.emitWalletConnected=nt;exports.emitWalletError=ot;exports.formatCSP=ve;exports.formatCouponCodes=Ye;exports.generateCSP=ut;exports.generateCSPDirectives=Se;exports.getAvailableLocales=gt;exports.getCartItemCount=ee;exports.getLocalizedError=mt;exports.getModalCloseButtonStyles=we;exports.getUserErrorMessage=at;exports.isRetryableError=it;exports.loadLocale=je;exports.logSecurityReport=At;exports.normalizeCartItems=ie;exports.parseCouponCodes=He;exports.stackCheckoutCoupons=Ve;exports.useCreditsPayment=Ee;exports.useCreditsSubscription=_e;exports.useLocalizedError=ht;exports.usePaymentMode=te;exports.useStripeCheckout=de;exports.useSubscription=Te;exports.useSubscriptionManagement=Ie;exports.useTranslation=V;exports.validateSecurity=$t;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as j, P as ke, u as re, o as be, a as V, m as pe } from "./CedrosContext-
|
|
1
|
+
import { i as j, P as ke, u as re, o as be, a as V, m as pe } from "./CedrosContext-BlArEF7k.mjs";
|
|
2
2
|
import { jsxs as S, jsx as f, Fragment as me } from "react/jsx-runtime";
|
|
3
3
|
import q, { useState as Q, useRef as X, useCallback as I, useMemo as F, useEffect as te } from "react";
|
|
4
4
|
function xt(e) {
|
|
@@ -858,7 +858,7 @@ function Te({
|
|
|
858
858
|
] });
|
|
859
859
|
}
|
|
860
860
|
const tt = q.lazy(
|
|
861
|
-
() => import("./CryptoButton-
|
|
861
|
+
() => import("./CryptoButton-CREryx1l.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
|
|
862
862
|
), rt = ({
|
|
863
863
|
isOpen: e,
|
|
864
864
|
onClose: t,
|
|
@@ -1171,7 +1171,7 @@ function at({
|
|
|
1171
1171
|
return /* @__PURE__ */ f(s, { endpoint: e, children: /* @__PURE__ */ f(u, { wallets: t, autoConnect: !1, children: r }) });
|
|
1172
1172
|
}
|
|
1173
1173
|
const it = q.lazy(
|
|
1174
|
-
() => import("./CryptoButton-
|
|
1174
|
+
() => import("./CryptoButton-CREryx1l.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
|
|
1175
1175
|
);
|
|
1176
1176
|
function qt(e) {
|
|
1177
1177
|
const { resource: t, items: r, checkout: n = {}, display: s = {}, callbacks: u = {}, advanced: g = {} } = e, { config: b, walletPool: h } = re(), c = V(), { isCartMode: a } = he(t, r), o = s.showCrypto ?? !0, d = q.useMemo(() => ({
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wr=require("react/jsx-runtime"),Wu=require("../CedrosContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wr=require("react/jsx-runtime"),Wu=require("../CedrosContext-7dwmEeUY.js");var xs={reset:[0,0],bold:[1,22,"\x1B[22m\x1B[1m"],dim:[2,22,"\x1B[22m\x1B[2m"],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]};function yo(e){return String(e)}yo.open="";yo.close="";function Vu(){let e=typeof process<"u"?process:void 0,t=e?.env||{},n=t.FORCE_TTY!=="false",r=e?.argv||[];return!("NO_COLOR"in t||r.includes("--no-color"))&&("FORCE_COLOR"in t||r.includes("--color")||e?.platform==="win32"||n&&t.TERM!=="dumb"||"CI"in t)||typeof window<"u"&&!!window.chrome}function Uu(){let e=Vu(),t=(s,i,a,u)=>{let c="",l=0;do c+=s.substring(l,u)+a,l=u+i.length,u=s.indexOf(i,l);while(~u);return c+s.substring(l)},n=(s,i,a=s)=>{let u=c=>{let l=String(c),f=l.indexOf(i,s.length);return~f?s+t(l,i,a,f)+i:s+l+i};return u.open=s,u.close=i,u},r={isColorSupported:e},o=s=>`\x1B[${s}m`;for(let s in xs){let i=xs[s];r[s]=e?n(o(i[0]),o(i[1]),i[2]):yo}return r}var ce=Uu();function Pc(e,t){return t.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(r){if(r!=="default"&&!(r in e)){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}})}),Object.freeze(e)}function Ku(e,t){const n=Object.keys(e),r=t===null?n:n.sort(t);if(Object.getOwnPropertySymbols)for(const o of Object.getOwnPropertySymbols(e))Object.getOwnPropertyDescriptor(e,o).enumerable&&r.push(o);return r}function rn(e,t,n,r,o,s,i=": "){let a="",u=0,c=e.next();if(!c.done){a+=t.spacingOuter;const l=n+t.indent;for(;!c.done;){if(a+=l,u++===t.maxWidth){a+="…";break}const f=s(c.value[0],t,l,r,o),h=s(c.value[1],t,l,r,o);a+=f+i+h,c=e.next(),c.done?t.min||(a+=","):a+=`,${t.spacingInner}`}a+=t.spacingOuter+n}return a}function bo(e,t,n,r,o,s){let i="",a=0,u=e.next();if(!u.done){i+=t.spacingOuter;const c=n+t.indent;for(;!u.done;){if(i+=c,a++===t.maxWidth){i+="…";break}i+=s(u.value,t,c,r,o),u=e.next(),u.done?t.min||(i+=","):i+=`,${t.spacingInner}`}i+=t.spacingOuter+n}return i}function $n(e,t,n,r,o,s){let i="";e=e instanceof ArrayBuffer?new DataView(e):e;const a=c=>c instanceof DataView,u=a(e)?e.byteLength:e.length;if(u>0){i+=t.spacingOuter;const c=n+t.indent;for(let l=0;l<u;l++){if(i+=c,l===t.maxWidth){i+="…";break}(a(e)||l in e)&&(i+=s(a(e)?e.getInt8(l):e[l],t,c,r,o)),l<u-1?i+=`,${t.spacingInner}`:t.min||(i+=",")}i+=t.spacingOuter+n}return i}function wo(e,t,n,r,o,s){let i="";const a=Ku(e,t.compareKeys);if(a.length>0){i+=t.spacingOuter;const u=n+t.indent;for(let c=0;c<a.length;c++){const l=a[c],f=s(l,t,u,r,o),h=s(e[l],t,u,r,o);i+=`${u+f}: ${h}`,c<a.length-1?i+=`,${t.spacingInner}`:t.min||(i+=",")}i+=t.spacingOuter+n}return i}const Gu=typeof Symbol=="function"&&Symbol.for?Symbol.for("jest.asymmetricMatcher"):1267621,fn=" ",Yu=(e,t,n,r,o,s)=>{const i=e.toString();if(i==="ArrayContaining"||i==="ArrayNotContaining")return++r>t.maxDepth?`[${i}]`:`${i+fn}[${$n(e.sample,t,n,r,o,s)}]`;if(i==="ObjectContaining"||i==="ObjectNotContaining")return++r>t.maxDepth?`[${i}]`:`${i+fn}{${wo(e.sample,t,n,r,o,s)}}`;if(i==="StringMatching"||i==="StringNotMatching"||i==="StringContaining"||i==="StringNotContaining")return i+fn+s(e.sample,t,n,r,o);if(typeof e.toAsymmetricMatcher!="function")throw new TypeError(`Asymmetric matcher ${e.constructor.name} does not implement toAsymmetricMatcher()`);return e.toAsymmetricMatcher()},Ju=e=>e&&e.$$typeof===Gu,Xu={serialize:Yu,test:Ju},Hu=" ",Ic=new Set(["DOMStringMap","NamedNodeMap"]),Zu=/^(?:HTML\w*Collection|NodeList)$/;function Qu(e){return Ic.has(e)||Zu.test(e)}const el=e=>e&&e.constructor&&!!e.constructor.name&&Qu(e.constructor.name);function tl(e){return e.constructor.name==="NamedNodeMap"}const nl=(e,t,n,r,o,s)=>{const i=e.constructor.name;return++r>t.maxDepth?`[${i}]`:(t.min?"":i+Hu)+(Ic.has(i)?`{${wo(tl(e)?[...e].reduce((a,u)=>(a[u.name]=u.value,a),{}):{...e},t,n,r,o,s)}}`:`[${$n([...e],t,n,r,o,s)}]`)},rl={serialize:nl,test:el};function Nc(e){return e.replaceAll("<","<").replaceAll(">",">")}function To(e,t,n,r,o,s,i){const a=r+n.indent,u=n.colors;return e.map(c=>{const l=t[c];let f=i(l,n,a,o,s);return typeof l!="string"&&(f.includes(`
|
|
2
2
|
`)&&(f=n.spacingOuter+a+f+n.spacingOuter+r),f=`{${f}}`),`${n.spacingInner+r+u.prop.open+c+u.prop.close}=${u.value.open}${f}${u.value.close}`}).join("")}function Rn(e,t,n,r,o,s){return e.map(i=>t.spacingOuter+n+(typeof i=="string"?jc(i,t):s(i,t,n,r,o))).join("")}function ol(e,t,n,r,o,s){return t.printShadowRoot===!1?"":[`${t.spacingOuter+n}#shadow-root`,Rn(e,t,n+t.indent,r,o,s)].join("")}function jc(e,t){const n=t.colors.content;return n.open+Nc(e)+n.close}function sl(e,t){const n=t.colors.comment;return`${n.open}<!--${Nc(e)}-->${n.close}`}function So(e,t,n,r,o){const s=r.colors.tag;return`${s.open}<${e}${t&&s.close+t+r.spacingOuter+o+s.open}${n?`>${s.close}${n}${r.spacingOuter}${o}${s.open}</${e}`:`${t&&!r.min?"":" "}/`}>${s.close}`}function Eo(e,t){const n=t.colors.tag;return`${n.open}<${e}${n.close} …${n.open} />${n.close}`}const il=1,Rc=3,Fc=8,Dc=11,cl=/^(?:(?:HTML|SVG)\w*)?Element$/;function al(e){try{return typeof e.hasAttribute=="function"&&e.hasAttribute("is")}catch{return!1}}function ul(e){const t=e.constructor.name,{nodeType:n,tagName:r}=e,o=typeof r=="string"&&r.includes("-")||al(e);return n===il&&(cl.test(t)||o)||n===Rc&&t==="Text"||n===Fc&&t==="Comment"||n===Dc&&t==="DocumentFragment"}const ll=e=>e?.constructor?.name&&ul(e);function fl(e){return e.nodeType===Rc}function hl(e){return e.nodeType===Fc}function hn(e){return e.nodeType===Dc}const pl=(e,t,n,r,o,s)=>{if(fl(e))return jc(e.data,t);if(hl(e))return sl(e.data,t);const i=hn(e)?"DocumentFragment":e.tagName.toLowerCase();return++r>t.maxDepth?Eo(i,t):So(i,To(hn(e)?[]:Array.from(e.attributes,a=>a.name).sort(),hn(e)?{}:[...e.attributes].reduce((a,u)=>(a[u.name]=u.value,a),{}),t,n+t.indent,r,o,s),(hn(e)||!e.shadowRoot?"":ol(Array.prototype.slice.call(e.shadowRoot.children),t,n+t.indent,r,o,s))+Rn(Array.prototype.slice.call(e.childNodes||e.children),t,n+t.indent,r,o,s),t,n)},dl={serialize:pl,test:ll},ml="@@__IMMUTABLE_ITERABLE__@@",gl="@@__IMMUTABLE_LIST__@@",yl="@@__IMMUTABLE_KEYED__@@",bl="@@__IMMUTABLE_MAP__@@",Ms="@@__IMMUTABLE_ORDERED__@@",wl="@@__IMMUTABLE_RECORD__@@",Tl="@@__IMMUTABLE_SEQ__@@",Sl="@@__IMMUTABLE_SET__@@",El="@@__IMMUTABLE_STACK__@@",At=e=>`Immutable.${e}`,Fn=e=>`[${e}]`,Qt=" ",_s="…";function vl(e,t,n,r,o,s,i){return++r>t.maxDepth?Fn(At(i)):`${At(i)+Qt}{${rn(e.entries(),t,n,r,o,s)}}`}function $l(e){let t=0;return{next(){if(t<e._keys.length){const n=e._keys[t++];return{done:!1,value:[n,e.get(n)]}}return{done:!0,value:void 0}}}}function xl(e,t,n,r,o,s){const i=At(e._name||"Record");return++r>t.maxDepth?Fn(i):`${i+Qt}{${rn($l(e),t,n,r,o,s)}}`}function Ml(e,t,n,r,o,s){const i=At("Seq");return++r>t.maxDepth?Fn(i):e[yl]?`${i+Qt}{${e._iter||e._object?rn(e.entries(),t,n,r,o,s):_s}}`:`${i+Qt}[${e._iter||e._array||e._collection||e._iterable?bo(e.values(),t,n,r,o,s):_s}]`}function sr(e,t,n,r,o,s,i){return++r>t.maxDepth?Fn(At(i)):`${At(i)+Qt}[${bo(e.values(),t,n,r,o,s)}]`}const _l=(e,t,n,r,o,s)=>e[bl]?vl(e,t,n,r,o,s,e[Ms]?"OrderedMap":"Map"):e[gl]?sr(e,t,n,r,o,s,"List"):e[Sl]?sr(e,t,n,r,o,s,e[Ms]?"OrderedSet":"Set"):e[El]?sr(e,t,n,r,o,s,"Stack"):e[Tl]?Ml(e,t,n,r,o,s):xl(e,t,n,r,o,s),Ol=e=>e&&(e[ml]===!0||e[wl]===!0),kl={serialize:_l,test:Ol};function Lc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ir={exports:{}},Z={};var Os;function Al(){if(Os)return Z;Os=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function d(g){if(typeof g=="object"&&g!==null){var w=g.$$typeof;switch(w){case e:switch(g=g.type,g){case n:case o:case r:case u:case c:case h:return g;default:switch(g=g&&g.$$typeof,g){case i:case a:case f:case l:return g;case s:return g;default:return w}}case t:return w}}}return Z.ContextConsumer=s,Z.ContextProvider=i,Z.Element=e,Z.ForwardRef=a,Z.Fragment=n,Z.Lazy=f,Z.Memo=l,Z.Portal=t,Z.Profiler=o,Z.StrictMode=r,Z.Suspense=u,Z.SuspenseList=c,Z.isContextConsumer=function(g){return d(g)===s},Z.isContextProvider=function(g){return d(g)===i},Z.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===e},Z.isForwardRef=function(g){return d(g)===a},Z.isFragment=function(g){return d(g)===n},Z.isLazy=function(g){return d(g)===f},Z.isMemo=function(g){return d(g)===l},Z.isPortal=function(g){return d(g)===t},Z.isProfiler=function(g){return d(g)===o},Z.isStrictMode=function(g){return d(g)===r},Z.isSuspense=function(g){return d(g)===u},Z.isSuspenseList=function(g){return d(g)===c},Z.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===n||g===o||g===r||g===u||g===c||typeof g=="object"&&g!==null&&(g.$$typeof===f||g.$$typeof===l||g.$$typeof===i||g.$$typeof===s||g.$$typeof===a||g.$$typeof===p||g.getModuleId!==void 0)},Z.typeOf=d,Z}var ks;function Cl(){return ks||(ks=1,ir.exports=Al()),ir.exports}var qc=Cl(),Pl=Lc(qc),Il=Pc({__proto__:null,default:Pl},[qc]),cr={exports:{}},J={};var As;function Nl(){if(As)return J;As=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),d;d=Symbol.for("react.module.reference");function g(w){if(typeof w=="object"&&w!==null){var T=w.$$typeof;switch(T){case e:switch(w=w.type,w){case n:case o:case r:case c:case l:return w;default:switch(w=w&&w.$$typeof,w){case a:case i:case u:case h:case f:case s:return w;default:return T}}case t:return T}}}return J.ContextConsumer=i,J.ContextProvider=s,J.Element=e,J.ForwardRef=u,J.Fragment=n,J.Lazy=h,J.Memo=f,J.Portal=t,J.Profiler=o,J.StrictMode=r,J.Suspense=c,J.SuspenseList=l,J.isAsyncMode=function(){return!1},J.isConcurrentMode=function(){return!1},J.isContextConsumer=function(w){return g(w)===i},J.isContextProvider=function(w){return g(w)===s},J.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},J.isForwardRef=function(w){return g(w)===u},J.isFragment=function(w){return g(w)===n},J.isLazy=function(w){return g(w)===h},J.isMemo=function(w){return g(w)===f},J.isPortal=function(w){return g(w)===t},J.isProfiler=function(w){return g(w)===o},J.isStrictMode=function(w){return g(w)===r},J.isSuspense=function(w){return g(w)===c},J.isSuspenseList=function(w){return g(w)===l},J.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===n||w===o||w===r||w===c||w===l||w===p||typeof w=="object"&&w!==null&&(w.$$typeof===h||w.$$typeof===f||w.$$typeof===s||w.$$typeof===i||w.$$typeof===u||w.$$typeof===d||w.getModuleId!==void 0)},J.typeOf=g,J}var Cs;function jl(){return Cs||(Cs=1,cr.exports=Nl()),cr.exports}var Bc=jl(),Rl=Lc(Bc),Fl=Pc({__proto__:null,default:Rl},[Bc]);const Dl=["isAsyncMode","isConcurrentMode","isContextConsumer","isContextProvider","isElement","isForwardRef","isFragment","isLazy","isMemo","isPortal","isProfiler","isStrictMode","isSuspense","isSuspenseList","isValidElementType"],ut=Object.fromEntries(Dl.map(e=>[e,t=>Fl[e](t)||Il[e](t)]));function zc(e,t=[]){if(Array.isArray(e))for(const n of e)zc(n,t);else e!=null&&e!==!1&&e!==""&&t.push(e);return t}function Ps(e){const t=e.type;if(typeof t=="string")return t;if(typeof t=="function")return t.displayName||t.name||"Unknown";if(ut.isFragment(e))return"React.Fragment";if(ut.isSuspense(e))return"React.Suspense";if(typeof t=="object"&&t!==null){if(ut.isContextProvider(e))return"Context.Provider";if(ut.isContextConsumer(e))return"Context.Consumer";if(ut.isForwardRef(e)){if(t.displayName)return t.displayName;const n=t.render.displayName||t.render.name||"";return n===""?"ForwardRef":`ForwardRef(${n})`}if(ut.isMemo(e)){const n=t.displayName||t.type.displayName||t.type.name||"";return n===""?"Memo":`Memo(${n})`}}return"UNDEFINED"}function Ll(e){const{props:t}=e;return Object.keys(t).filter(n=>n!=="children"&&t[n]!==void 0).sort()}const ql=(e,t,n,r,o,s)=>++r>t.maxDepth?Eo(Ps(e),t):So(Ps(e),To(Ll(e),e.props,t,n+t.indent,r,o,s),Rn(zc(e.props.children),t,n+t.indent,r,o,s),t,n),Bl=e=>e!=null&&ut.isElement(e),zl={serialize:ql,test:Bl},Wl=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.test.json"):245830487;function Vl(e){const{props:t}=e;return t?Object.keys(t).filter(n=>t[n]!==void 0).sort():[]}const Ul=(e,t,n,r,o,s)=>++r>t.maxDepth?Eo(e.type,t):So(e.type,e.props?To(Vl(e),e.props,t,n+t.indent,r,o,s):"",e.children?Rn(e.children,t,n+t.indent,r,o,s):"",t,n),Kl=e=>e&&e.$$typeof===Wl,Gl={serialize:Ul,test:Kl},Wc=Object.prototype.toString,Yl=Date.prototype.toISOString,Jl=Error.prototype.toString,Is=RegExp.prototype.toString;function bn(e){return typeof e.constructor=="function"&&e.constructor.name||"Object"}function Xl(e){return typeof window<"u"&&e===window}const Hl=/^Symbol\((.*)\)(.*)$/,Zl=/\n/g;class Vc extends Error{constructor(t,n){super(t),this.stack=n,this.name=this.constructor.name}}function Ql(e){return e==="[object Array]"||e==="[object ArrayBuffer]"||e==="[object DataView]"||e==="[object Float32Array]"||e==="[object Float64Array]"||e==="[object Int8Array]"||e==="[object Int16Array]"||e==="[object Int32Array]"||e==="[object Uint8Array]"||e==="[object Uint8ClampedArray]"||e==="[object Uint16Array]"||e==="[object Uint32Array]"}function ef(e){return Object.is(e,-0)?"-0":String(e)}function tf(e){return`${e}n`}function Ns(e,t){return t?`[Function ${e.name||"anonymous"}]`:"[Function]"}function js(e){return String(e).replace(Hl,"Symbol($1)")}function Rs(e){return`[${Jl.call(e)}]`}function Uc(e,t,n,r){if(e===!0||e===!1)return`${e}`;if(e===void 0)return"undefined";if(e===null)return"null";const o=typeof e;if(o==="number")return ef(e);if(o==="bigint")return tf(e);if(o==="string")return r?`"${e.replaceAll(/"|\\/g,"\\$&")}"`:`"${e}"`;if(o==="function")return Ns(e,t);if(o==="symbol")return js(e);const s=Wc.call(e);return s==="[object WeakMap]"?"WeakMap {}":s==="[object WeakSet]"?"WeakSet {}":s==="[object Function]"||s==="[object GeneratorFunction]"?Ns(e,t):s==="[object Symbol]"?js(e):s==="[object Date]"?Number.isNaN(+e)?"Date { NaN }":Yl.call(e):s==="[object Error]"?Rs(e):s==="[object RegExp]"?n?Is.call(e).replaceAll(/[$()*+.?[\\\]^{|}]/g,"\\$&"):Is.call(e):e instanceof Error?Rs(e):null}function Kc(e,t,n,r,o,s){if(o.includes(e))return"[Circular]";o=[...o],o.push(e);const i=++r>t.maxDepth,a=t.min;if(t.callToJSON&&!i&&e.toJSON&&typeof e.toJSON=="function"&&!s)return tt(e.toJSON(),t,n,r,o,!0);const u=Wc.call(e);return u==="[object Arguments]"?i?"[Arguments]":`${a?"":"Arguments "}[${$n(e,t,n,r,o,tt)}]`:Ql(u)?i?`[${e.constructor.name}]`:`${a||!t.printBasicPrototype&&e.constructor.name==="Array"?"":`${e.constructor.name} `}[${$n(e,t,n,r,o,tt)}]`:u==="[object Map]"?i?"[Map]":`Map {${rn(e.entries(),t,n,r,o,tt," => ")}}`:u==="[object Set]"?i?"[Set]":`Set {${bo(e.values(),t,n,r,o,tt)}}`:i||Xl(e)?`[${bn(e)}]`:`${a||!t.printBasicPrototype&&bn(e)==="Object"?"":`${bn(e)} `}{${wo(e,t,n,r,o,tt)}}`}const nf={test:e=>e&&e instanceof Error,serialize(e,t,n,r,o,s){if(o.includes(e))return"[Circular]";o=[...o,e];const i=++r>t.maxDepth,{message:a,cause:u,...c}=e,l={message:a,...typeof u<"u"?{cause:u}:{},...e instanceof AggregateError?{errors:e.errors}:{},...c},f=e.name!=="Error"?e.name:bn(e);return i?`[${f}]`:`${f} {${rn(Object.entries(l).values(),t,n,r,o,s)}}`}};function rf(e){return e.serialize!=null}function Gc(e,t,n,r,o,s){let i;try{i=rf(e)?e.serialize(t,n,r,o,s,tt):e.print(t,a=>tt(a,n,r,o,s),a=>{const u=r+n.indent;return u+a.replaceAll(Zl,`
|
|
3
3
|
${u}`)},{edgeSpacing:n.spacingOuter,min:n.min,spacing:n.spacingInner},n.colors)}catch(a){throw new Vc(a.message,a.stack)}if(typeof i!="string")throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof i}".`);return i}function Yc(e,t){for(const n of e)try{if(n.test(t))return n}catch(r){throw new Vc(r.message,r.stack)}return null}function tt(e,t,n,r,o,s){const i=Yc(t.plugins,e);if(i!==null)return Gc(i,e,t,n,r,o);const a=Uc(e,t.printFunctionName,t.escapeRegex,t.escapeString);return a!==null?a:Kc(e,t,n,r,o,s)}const vo={comment:"gray",content:"reset",prop:"yellow",tag:"cyan",value:"green"},Jc=Object.keys(vo),Fe={callToJSON:!0,compareKeys:void 0,escapeRegex:!1,escapeString:!0,highlight:!1,indent:2,maxDepth:Number.POSITIVE_INFINITY,maxWidth:Number.POSITIVE_INFINITY,min:!1,plugins:[],printBasicPrototype:!0,printFunctionName:!0,printShadowRoot:!0,theme:vo};function of(e){for(const t of Object.keys(e))if(!Object.hasOwn(Fe,t))throw new Error(`pretty-format: Unknown option "${t}".`);if(e.min&&e.indent!==void 0&&e.indent!==0)throw new Error('pretty-format: Options "min" and "indent" cannot be used together.')}function sf(){return Jc.reduce((e,t)=>{const n=vo[t],r=n&&ce[n];if(r&&typeof r.close=="string"&&typeof r.open=="string")e[t]=r;else throw new Error(`pretty-format: Option "theme" has a key "${t}" whose value "${n}" is undefined in ansi-styles.`);return e},Object.create(null))}function cf(){return Jc.reduce((e,t)=>(e[t]={close:"",open:""},e),Object.create(null))}function Xc(e){return e?.printFunctionName??Fe.printFunctionName}function Hc(e){return e?.escapeRegex??Fe.escapeRegex}function Zc(e){return e?.escapeString??Fe.escapeString}function Fs(e){return{callToJSON:e?.callToJSON??Fe.callToJSON,colors:e?.highlight?sf():cf(),compareKeys:typeof e?.compareKeys=="function"||e?.compareKeys===null?e.compareKeys:Fe.compareKeys,escapeRegex:Hc(e),escapeString:Zc(e),indent:e?.min?"":af(e?.indent??Fe.indent),maxDepth:e?.maxDepth??Fe.maxDepth,maxWidth:e?.maxWidth??Fe.maxWidth,min:e?.min??Fe.min,plugins:e?.plugins??Fe.plugins,printBasicPrototype:e?.printBasicPrototype??!0,printFunctionName:Xc(e),printShadowRoot:e?.printShadowRoot??!0,spacingInner:e?.min?" ":`
|
|
4
4
|
`,spacingOuter:e?.min?"":`
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@solana/wallet-adapter-wallets"),e=require("./CedrosContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@solana/wallet-adapter-wallets"),e=require("./CedrosContext-7dwmEeUY.js");class r{adapters=null;poolId;isCleanedUp=!1;constructor(l){this.poolId=l??`pool_${Date.now()}_${Math.random().toString(36).slice(2,11)}`,e.getLogger().debug(`[WalletPool] Created pool: ${this.poolId}`)}getAdapters(){return typeof window>"u"?[]:this.isCleanedUp?(e.getLogger().warn(`[WalletPool] Attempted to use pool after cleanup: ${this.poolId}`),[]):this.adapters!==null?this.adapters:(e.getLogger().debug(`[WalletPool] Initializing adapters for pool: ${this.poolId}`),this.adapters=[new a.PhantomWalletAdapter,new a.SolflareWalletAdapter],this.adapters)}async cleanup(){if(this.isCleanedUp){e.getLogger().debug(`[WalletPool] Pool already cleaned up: ${this.poolId}`);return}if(e.getLogger().debug(`[WalletPool] Cleaning up pool: ${this.poolId}`),this.isCleanedUp=!0,this.adapters===null)return;const l=this.adapters.map(async t=>{try{t.connected&&(e.getLogger().debug(`[WalletPool] Disconnecting wallet: ${t.name}`),await t.disconnect())}catch(n){e.getLogger().warn(`[WalletPool] Failed to disconnect wallet ${t.name}:`,n)}});await Promise.allSettled(l),this.adapters=null,e.getLogger().debug(`[WalletPool] Pool cleanup complete: ${this.poolId}`)}isInitialized(){return this.adapters!==null}getId(){return this.poolId}}function i(o){return new r(o)}exports.WalletPool=r;exports.createWalletPool=i;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedros/pay-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.23",
|
|
4
4
|
"description": "React frontend library for Cedros Pay - unified Stripe and Solana x402 payments",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"@solana/wallet-adapter-react-ui": "^0.9.39",
|
|
73
73
|
"@solana/wallet-adapter-wallets": "^0.19.32",
|
|
74
74
|
"@solana/web3.js": "^1.95.0",
|
|
75
|
+
"@meteora-ag/dlmm": ">=1.0.0",
|
|
75
76
|
"react": "^18.0.0 || ^19.0.0",
|
|
76
77
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
77
78
|
},
|
|
@@ -96,6 +97,9 @@
|
|
|
96
97
|
},
|
|
97
98
|
"@solana/web3.js": {
|
|
98
99
|
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"@meteora-ag/dlmm": {
|
|
102
|
+
"optional": true
|
|
99
103
|
}
|
|
100
104
|
},
|
|
101
105
|
"dependencies": {
|