@arcblock/payment-service 1.29.7 → 1.29.9
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/cf.d.ts +31 -0
- package/dist/cf.js +79 -60
- package/dist/index.d.ts +17 -0
- package/dist/index.js +264 -73
- package/package.json +4 -4
- package/web/assets/{account-DETfFe4_.js → account-Clbqiiw3.js} +1 -1
- package/web/assets/{action-B_DQJlip.js → action-DENqSeOa.js} +1 -1
- package/web/assets/{actions-BtaoyTWt.js → actions-0iWP2mcx.js} +1 -1
- package/web/assets/{actions-QPa-8lfB.js → actions-BD9BAp3M.js} +1 -1
- package/web/assets/{actions-jxGAdGfb.js → actions-BJDN6Op2.js} +1 -1
- package/web/assets/{actions-DJyfN5OU.js → actions-BSNy5bOd.js} +1 -1
- package/web/assets/{actions-Bt_jST94.js → actions-CDsj5j8l.js} +1 -1
- package/web/assets/{actions-D9MHLBFH.js → actions-CSpJGOX7.js} +1 -1
- package/web/assets/{actions-BknL4OyZ.js → actions-CZL47E9r.js} +1 -1
- package/web/assets/{actions-EPYeS5p4.js → actions-D3tJgrUn.js} +1 -1
- package/web/assets/{actions-BaDh4xWX.js → actions-DGQs8fFF.js} +1 -1
- package/web/assets/{add-price-CD-utowo.js → add-price-BpnICuHO.js} +1 -1
- package/web/assets/{admin-_nEB-lHn.js → admin-CD8ViZ7D.js} +1 -1
- package/web/assets/{assign-CkV5Q2LP.js → assign-0vMUDW_C.js} +1 -1
- package/web/assets/{attempts-DySeqBYU.js → attempts-CKlxkJuE.js} +1 -1
- package/web/assets/browser-DDv4_sgY.js +1 -0
- package/web/assets/{change-payment-CPUCUEER.js → change-payment-gAlRmJpv.js} +1 -1
- package/web/assets/{change-plan-CxE-XfWc.js → change-plan-C47wfWH8.js} +1 -1
- package/web/assets/{click-boundary-y8dVA_tr.js → click-boundary-CafubiPp.js} +1 -1
- package/web/assets/{connect-CC_l_f6Q.js → connect-BHHzrwLA.js} +1 -1
- package/web/assets/{copyable-DpX04wZz.js → copyable-QrCyyiou.js} +1 -1
- package/web/assets/{create-3SsWCAOC.js → create-0PUtkJZY.js} +1 -1
- package/web/assets/{create-BkQAaSvD.js → create-BJ1asdcy.js} +1 -1
- package/web/assets/{create-kG09X9gl.js → create-Bgv5ux17.js} +1 -1
- package/web/assets/{create-BmcRybZ5.js → create-C7GOgZZM.js} +1 -1
- package/web/assets/{create-tYebjhr9.js → create-DNar5UQD.js} +1 -1
- package/web/assets/{create-Bs65p5Ne.js → create-ke4FrPx1.js} +1 -1
- package/web/assets/{credit-grant-item-list-Bk27jIc7.js → credit-grant-item-list-CeDAM3qV.js} +1 -1
- package/web/assets/{credit-overview-DmMSEs14.js → credit-overview-4zh0H02x.js} +2 -2
- package/web/assets/{currency-restrictions-DYLv4YyW.js → currency-restrictions-BcEm8W45.js} +1 -1
- package/web/assets/{currency-select-DGS-62-L.js → currency-select-B4ieQBvv.js} +1 -1
- package/web/assets/{dayjs-B9tvQIKg.js → dayjs-DUTDpcNU.js} +1 -1
- package/web/assets/{description-Ym17DL48.js → description-SnR5WxWT.js} +1 -1
- package/web/assets/detail-46aLUdJj.js +1 -0
- package/web/assets/{detail-Cr2wG4Th.js → detail-B-ceWfZr.js} +1 -1
- package/web/assets/detail-B0IHl4MI.js +1 -0
- package/web/assets/detail-B8eOBVSQ.js +15 -0
- package/web/assets/{detail-DE3OOC5M.js → detail-BO3zglCn.js} +1 -1
- package/web/assets/{detail-DG4l2CqN.js → detail-BQpDGZJQ.js} +1 -1
- package/web/assets/{detail-CxYQYu_l.js → detail-BXTsnQny.js} +1 -1
- package/web/assets/{detail-CT9Unyrf.js → detail-B_lpOomD.js} +1 -1
- package/web/assets/{detail-Do9QO5L2.js → detail-Bfnkg0A1.js} +1 -1
- package/web/assets/detail-BwH0DwAi.js +1 -0
- package/web/assets/{detail-OZeeKI69.js → detail-C1FupF1D.js} +2 -2
- package/web/assets/{detail-cwHZbY62.js → detail-CMBRd4Ct.js} +1 -1
- package/web/assets/detail-C_Zdfa0y.js +1 -0
- package/web/assets/{detail-Cb9HBSMw.js → detail-Cg505nKX.js} +1 -1
- package/web/assets/{detail-DB56SG-k.js → detail-CsGZMimg.js} +1 -1
- package/web/assets/{detail-K9EVY3r2.js → detail-Ct5QNBqu.js} +1 -1
- package/web/assets/{detail-DuO_Jn5X.js → detail-CyMhK5K_.js} +1 -1
- package/web/assets/{detail-DuWdZIyp.js → detail-DACnmls3.js} +1 -1
- package/web/assets/{detail-BJTcK7mx.js → detail-DCTb8R7F.js} +1 -1
- package/web/assets/{detail-DPCTQLOx.js → detail-DNcp_u5S.js} +1 -1
- package/web/assets/detail-DbU3p040.js +1 -0
- package/web/assets/{detail-D5KRrQDx.js → detail-Tn2R5C8i.js} +1 -1
- package/web/assets/{detail-15zxCbV9.js → detail-wU4wNf4s.js} +1 -1
- package/web/assets/{drawer-form-Cl0T1Yyt.js → drawer-form-DspWWj3x.js} +1 -1
- package/web/assets/{edit-3HUAnaXW.js → edit-Bkj-OTJh.js} +1 -1
- package/web/assets/{editor-BF5I0siU.js → editor-AmthipP2.js} +1 -1
- package/web/assets/{embed-CsNqeCd0.js → embed-rRKjDoHi.js} +1 -1
- package/web/assets/{filter-toolbar-BydfQ-79.js → filter-toolbar-DXGSTq57.js} +1 -1
- package/web/assets/{form-DSzMo9UD.js → form-B5WW-lS5.js} +1 -1
- package/web/assets/form-BmQlJZ84.js +9 -0
- package/web/assets/{form-BGm5NPDn.js → form-CAPjlw7l.js} +1 -1
- package/web/assets/{form-CKfKLGXP.js → form-DD-EiA7W.js} +3 -3
- package/web/assets/{form-P4luyUpY.js → form-cX026J4G.js} +1 -1
- package/web/assets/{gas-Qf0SSUfS.js → gas-nyR96dB0.js} +1 -1
- package/web/assets/{generateCategoricalChart-BaWwaXky.js → generateCategoricalChart-BadryV3H.js} +1 -1
- package/web/assets/{home-HbrLyxJL.js → home-_eX1aim8.js} +1 -1
- package/web/assets/index-BBHMsIxJ.js +1 -0
- package/web/assets/{index-Dr_MwbKt.js → index-BQjlhCSt.js} +1 -1
- package/web/assets/{index-DPodCQ9c.js → index-BRENdB5m.js} +1 -1
- package/web/assets/{index-9xBRL_33.js → index-BTfJ08JU.js} +1 -1
- package/web/assets/{index-DgSc1Qy8.js → index-BarN7DfU.js} +17 -17
- package/web/assets/index-BhcoukR2.js +1 -0
- package/web/assets/index-BturOfxo.js +1 -0
- package/web/assets/{index-SYTpMMMH.js → index-BzABukCz.js} +1 -1
- package/web/assets/{index-2l22EYw9.js → index-C-RT84yb.js} +1 -1
- package/web/assets/{index-C0JaS08f.js → index-C136x0O2.js} +1 -1
- package/web/assets/{index-Cw0ugaQL.js → index-CCVDDX0c.js} +1 -1
- package/web/assets/index-CDVogp6E.js +1 -0
- package/web/assets/{index-Br7_mvEw.js → index-CW8VfoJO.js} +1 -1
- package/web/assets/{index-BIoSdRvX.js → index-CbSXdD6E.js} +3 -3
- package/web/assets/{index-CdkYrABk.js → index-Cd_BD9TM.js} +1 -1
- package/web/assets/index-D-bx9Kam.js +1 -0
- package/web/assets/index-D0mynT6_.js +1 -0
- package/web/assets/index-DEiuhiEo.js +14 -0
- package/web/assets/{index-DE2KzqXl.js → index-DNGmCIRP.js} +1 -1
- package/web/assets/{index-CI_EY4YS.js → index-DSe7Dot_.js} +1 -1
- package/web/assets/{index-BFML4-2u.js → index-DcddP3R9.js} +1 -1
- package/web/assets/index-DcrGSDby.js +1 -0
- package/web/assets/{index-fByZjxLy.js → index-DeK5Pqjv.js} +1 -1
- package/web/assets/{index-Clbt8nRm.js → index-DoX0A-rP.js} +1 -1
- package/web/assets/index-Du0Ieh1F.js +49 -0
- package/web/assets/index-Dybqd298.js +1 -0
- package/web/assets/index-EXZPddtw.js +1 -0
- package/web/assets/{index-Drav4oDH.js → index-Kd_qCyRG.js} +2 -2
- package/web/assets/{index-Dc954mDP.js → index-SOzRg0yJ.js} +1 -1
- package/web/assets/{index-BMKZToMM.js → index-UYeD8rTJ.js} +2 -2
- package/web/assets/{index-DZpJPE1Z.js → index-W2uZUlFs.js} +1 -1
- package/web/assets/{index-1y9kjPIr.js → index-XaFn2ySq.js} +1 -1
- package/web/assets/{index-fswPX_qe.js → index-YG5oc8O3.js} +1 -1
- package/web/assets/{index-B1pTTyGZ.js → index-ajD9Iotk.js} +1 -1
- package/web/assets/index-brUCsnBA.js +1 -0
- package/web/assets/{index-BP53rZV9.js → index-mn5Zdrtn.js} +1 -1
- package/web/assets/index-qulrJQ4J.js +1 -0
- package/web/assets/{index.es-BWnfUzLb.js → index.es-C8dcCHdW.js} +1 -1
- package/web/assets/{info-card-C1yxhxJG.js → info-card-BvIMFQo5.js} +1 -1
- package/web/assets/{info-metric-CNse3r66.js → info-metric-Dl4ZDm0Z.js} +1 -1
- package/web/assets/{info-row-group-BeUhWnnY.js → info-row-group-CFuMWJf1.js} +1 -1
- package/web/assets/{info-row-DOK2whMn.js → info-row-jI0h_hv4.js} +1 -1
- package/web/assets/{libphonenumber-CyphiuxQ.js → libphonenumber-Qs8PCdM-.js} +1 -1
- package/web/assets/{link-3eeclTeS.js → link-CmPoIweR.js} +1 -1
- package/web/assets/{list-DnePqZ2K.js → list-BdSkPjIa.js} +1 -1
- package/web/assets/{list-jHj_5yy3.js → list-CWMEf-_C.js} +1 -1
- package/web/assets/{list-C521zE_7.js → list-CkHExntK.js} +1 -1
- package/web/assets/{list-CO0X4L3-.js → list-DLB_hd0Q.js} +1 -1
- package/web/assets/{list-D-I0msRW.js → list-DVFJwd_I.js} +2 -2
- package/web/assets/{list-D1aevUOI.js → list-DaK9287Y.js} +2 -2
- package/web/assets/{list-1OG83xc4.js → list-DghnUOc4.js} +1 -1
- package/web/assets/{list-CNmzJKIQ.js → list-eFkvVlp5.js} +1 -1
- package/web/assets/metadata-BmQTVFku.js +55 -0
- package/web/assets/{meter-event-lmNMgmIu.js → meter-event-B1JIhVpb.js} +1 -1
- package/web/assets/{metrics-C7U41HWk.js → metrics-UvxyQbUF.js} +1 -1
- package/web/assets/{overview-Cs3-8n4e.js → overview-Cxc6WKba.js} +1 -1
- package/web/assets/{overview-CH1HnSP-.js → overview-DrMaIptb.js} +1 -1
- package/web/assets/{past-due-CGGRZmXY.js → past-due-CUXkxns0.js} +1 -1
- package/web/assets/pay-omLYkqRA.js +4 -0
- package/web/assets/{payment-method-info-BsOBbA3m.js → payment-method-info-Bsf89VxV.js} +2 -2
- package/web/assets/{preview-DjYRpRA8.js → preview-BifsgUGT.js} +1 -1
- package/web/assets/{preview-CjYh9dTg.js → preview-C-H8pGVw.js} +1 -1
- package/web/assets/{pricing-table-C3Lkhq46.js → pricing-table-B3QOaAB5.js} +2 -2
- package/web/assets/{pricing-table-edE6TJGX.js → pricing-table-BUJdtkMq.js} +1 -1
- package/web/assets/{product-select-0ScZE2e8.js → product-select-ChEyoJqJ.js} +1 -1
- package/web/assets/{recharge-DcPtT8vt.js → recharge-BVT4USAO.js} +1 -1
- package/web/assets/{related-credit-grants-BygNGPfb.js → related-credit-grants-JV2ICsR5.js} +22 -22
- package/web/assets/{safe-did-address-B0fFbUph.js → safe-did-address-CiG_V6Gy.js} +1 -1
- package/web/assets/{source-data-viewer-By_Utay-.js → source-data-viewer-i1q9wNIG.js} +1 -1
- package/web/assets/{status-l6pD08fw.js → status-CUVYrUIG.js} +1 -1
- package/web/assets/subscription-BYz_k9dq.js +1 -0
- package/web/assets/{subscription-Dq22e3D1.js → subscription-DrnSPIfs.js} +1 -1
- package/web/assets/table-BrtHemkA.js +1 -0
- package/web/assets/{tax-code-select-CWhIIiXi.js → tax-code-select-TS07I0rB.js} +1 -1
- package/web/assets/{tax-utils-DqNX34-r.js → tax-utils-bPjALcVG.js} +1 -1
- package/web/assets/{uploader-DRXDz_r0.js → uploader-CsQNHG4I.js} +1 -1
- package/web/assets/{usage-records-jjJMZ6DI.js → usage-records-DAUQMJAW.js} +1 -1
- package/web/assets/{util-mDHAL0lx.js → util-DxXTXkeY.js} +1 -1
- package/web/assets/{vendor-arcblock-ChFCRdyx.js → vendor-arcblock-BTCAQSUK.js} +1 -1
- package/web/assets/{vendor-blocklet-D_i_QeSo.js → vendor-blocklet-DcLR2Cyf.js} +43 -43
- package/web/index.html +1 -1
- package/web/assets/browser-DSLTxXlL.js +0 -1
- package/web/assets/detail-ASPdMJoW.js +0 -1
- package/web/assets/detail-CIx9vkir.js +0 -1
- package/web/assets/detail-D5NbV29V.js +0 -1
- package/web/assets/detail-DVVzYhdV.js +0 -1
- package/web/assets/detail-Dqc0OfCQ.js +0 -1
- package/web/assets/detail-uhlID8jD.js +0 -15
- package/web/assets/form-BXAuSawq.js +0 -9
- package/web/assets/index-0HK7CYm4.js +0 -1
- package/web/assets/index-BJ_E6bEO.js +0 -1
- package/web/assets/index-Bnyh4rlV.js +0 -1
- package/web/assets/index-BoQ7wf3O.js +0 -1
- package/web/assets/index-C68x-aau.js +0 -1
- package/web/assets/index-C8s2QKoe.js +0 -1
- package/web/assets/index-Cn7O-OP7.js +0 -49
- package/web/assets/index-DU39aG5u.js +0 -1
- package/web/assets/index-DtbqgSK4.js +0 -1
- package/web/assets/index-DuRu9NWB.js +0 -14
- package/web/assets/index-WMKOiUez.js +0 -1
- package/web/assets/index-dmHgoplS.js +0 -1
- package/web/assets/index-txVTkoDD.js +0 -1
- package/web/assets/metadata-CMSHcSXi.js +0 -55
- package/web/assets/pay-CSpHBUh_.js +0 -4
- package/web/assets/subscription-DcwhSOpa.js +0 -1
- package/web/assets/table-BRU4Enia.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,A as y,w as v,B as r,a3 as a,bv as w,q as i,a7 as j,Y as m,O as C,be as _,bf as I}from"./vendor-mui-BXZut9Pz.js";import{V as N,
|
|
1
|
+
import{j as e,A as y,w as v,B as r,a3 as a,bv as w,q as i,a7 as j,Y as m,O as C,be as _,bf as I}from"./vendor-mui-BXZut9Pz.js";import{V as N,P as k}from"./vendor-blocklet-DcLR2Cyf.js";import{d as D,i as d,j as c,A as E,e as S}from"./index-BarN7DfU.js";import{L as h}from"./vendor-react-BPknnnEA.js";import{C as T}from"./copyable-QrCyyiou.js";import{C as $}from"./link-CmPoIweR.js";import{E as A}from"./list-DaK9287Y.js";import{I as n}from"./info-row-jI0h_hv4.js";import{I as l}from"./info-metric-Dl4ZDm0Z.js";import{S as x}from"./header-ivXuPt06.js";import{g as M}from"./util-DxXTXkeY.js";import{I as z}from"./info-row-group-CFuMWJf1.js";import{M as L}from"./list-CkHExntK.js";import"./table-BrtHemkA.js";import"./lodash-B4Ozcv0x.js";const O=o=>S.get(`/api/meter-events/${o}`).then(s=>s.data);function ee(o){const{t:s}=N(),{isMobile:u}=D(),{loading:g,error:p,data:t}=k(()=>O(o.id));if(p)return e.jsx(y,{severity:"error",children:p.message});if(g||!t)return e.jsx(v,{});const f=b=>{switch(b){case"pending":return"info";case"requires_action":return"warning";case"requires_capture":return"warning";case"completed":return"success";case"processing":return"info";default:return"default"}};return e.jsxs(W,{direction:"column",spacing:2.5,sx:{mb:4},children:[e.jsxs(r,{children:[e.jsx(a,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:e.jsxs(a,{direction:"row",onClick:()=>M("/admin/billing/meters"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(w,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(i,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("admin.meterEvents.title")})]})}),e.jsxs(r,{sx:{mt:4,mb:3,display:"flex",gap:{xs:2,sm:2,md:5},flexWrap:"wrap",flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:{xs:"flex-start",sm:"flex-start",md:"center"}},children:[e.jsx(a,{direction:"column",sx:{gap:1},children:e.jsx(T,{text:o.id})}),e.jsxs(a,{className:"section-body",sx:{justifyContent:"flex-start",flexWrap:"wrap","hr.MuiDivider-root:last-child":{display:"none"},flexDirection:{xs:"column",sm:"column",md:"row"},alignItems:"flex-start",gap:{xs:1,sm:1,md:3}},children:[e.jsx(l,{label:s("common.status"),value:e.jsx(j,{label:t.status,color:f(t.status),size:"small"}),divider:!0}),e.jsx(l,{label:s("common.meterEvent"),value:e.jsx(h,{to:`/admin/billing/meters/${t.meter.id}`,style:{color:"inherit"},children:e.jsx(i,{sx:{color:"text.link"},children:t.meter.event_name})}),divider:!0}),t.subscription&&e.jsx(l,{label:s("common.subscription"),value:e.jsx(h,{to:`/admin/billing/${t.subscription.id}`,style:{color:"inherit"},children:e.jsx(i,{sx:{color:"text.link"},children:t.subscription.description||t.subscription.id})}),divider:!0}),e.jsx(l,{label:s("admin.meterEvent.creditConsumed"),value:`${d(t.credit_consumed,t.paymentCurrency?.decimal)} ${t.paymentCurrency?.symbol}`,divider:!0}),t.credit_pending!=="0"&&e.jsx(l,{label:s("admin.customer.creditGrants.pendingAmount"),value:e.jsx(i,{sx:{color:"error.main"},children:`${d(t.credit_pending,t.paymentCurrency?.decimal)} ${t.paymentCurrency?.symbol}`}),divider:!0})]})]}),e.jsx(m,{})]}),e.jsxs(a,{sx:{flexDirection:{xs:"column",lg:"row"},gap:{xs:2.5,md:4},".meter-event-column-1":{minWidth:{xs:"100%",lg:"600px"}},".meter-event-column-2":{width:{xs:"100%",md:"100%",lg:"320px"},maxWidth:{xs:"100%",md:"33%"}}},children:[e.jsxs(r,{className:"meter-event-column-1",sx:{flex:1,gap:2.5,display:"flex",flexDirection:"column"},children:[e.jsxs(r,{className:"section",sx:{containerType:"inline-size"},children:[e.jsx(x,{title:s("admin.details")}),e.jsxs(z,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(1, 1fr)",xl:"repeat(2, 1fr)"},"@container (min-width: 1000px)":{gridTemplateColumns:"repeat(2, 1fr)"},".info-row-wrapper":{gap:1,flexDirection:{xs:"column",xl:"row"},alignItems:{xs:"flex-start",xl:"center"},"@container (min-width: 1000px)":{flexDirection:"row",alignItems:"center"}},".currency-name":{color:"text.secondary"}},children:[e.jsx(n,{label:s("admin.meterEvent.usageValue"),value:`${d(t.payload.value,t.paymentCurrency?.decimal)} ${t.paymentCurrency?.symbol}`}),e.jsx(n,{label:s("admin.meterEvent.reportedAt"),value:c(t.timestamp*1e3)}),e.jsx(n,{label:s("common.customer"),value:e.jsx($,{customer:t.customer,size:u?"default":"small"})}),e.jsx(n,{label:s("common.createdAt"),value:c(t.created_at)}),e.jsx(n,{label:s("common.status"),value:e.jsxs(a,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(j,{label:t.status,color:f(t.status),size:"small",sx:{textTransform:"capitalize"}}),t.metadata?.last_error&&e.jsx(C,{title:e.jsx("pre",{style:{whiteSpace:"break-spaces"},children:JSON.stringify({error:t.metadata.last_error,failed_at:t.metadata.failed_at?c(t.metadata.failed_at*1e3):void 0,attempt_count:t.attempt_count,next_attempt:t.next_attempt?c(t.next_attempt*1e3):void 0},null,2)}),children:e.jsx(_,{fontSize:"small",color:"error"})})]})})]})]}),e.jsx(m,{}),e.jsxs(r,{className:"section",children:[e.jsx(i,{variant:"h3",className:"section-header",children:s("admin.creditTransactions.title")}),e.jsx(r,{className:"section-body",children:e.jsx(E,{customer_id:t.payload.customer_id,source:t.id,showAdminColumns:!0,mode:"dashboard"})})]}),e.jsx(m,{}),e.jsxs(r,{className:"section",children:[e.jsx(x,{title:s("admin.events.title")}),e.jsx(r,{className:"section-body",children:e.jsx(A,{features:{toolbar:!1},object_id:t.id})})]})]}),u&&e.jsx(m,{}),e.jsx(r,{className:"meter-event-column-2",sx:{gap:2.5,display:"flex",flexDirection:"column"},children:t.metadata&&Object.keys(t.metadata).length>0&&e.jsxs(r,{className:"section",children:[e.jsx(x,{title:s("common.metadata.label")}),e.jsx(r,{className:"section-body",children:e.jsx(L,{data:t.metadata,handleEditMetadata:()=>{}})})]})})]})]})}const W=I(a)``;export{ee as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,q as c,O as x,be as b,a3 as g,bL as k,a1 as A,w as $,x as _,M,N as W,B as R}from"./vendor-mui-BXZut9Pz.js";import{V as
|
|
1
|
+
import{j as t,q as c,O as x,be as b,a3 as g,bL as k,a1 as A,w as $,x as _,M,N as W,B as R}from"./vendor-mui-BXZut9Pz.js";import{V as N,P as d,G as h}from"./vendor-blocklet-DcLR2Cyf.js";import{d as T,j as y,i as f,e as m}from"./index-BarN7DfU.js";import{I as r}from"./info-metric-Dl4ZDm0Z.js";import{S as F}from"./status-CUVYrUIG.js";import{a as L}from"./vendor-react-BPknnnEA.js";const O=e=>m.get(`/api/subscriptions/${e}/upcoming`).then(n=>n.data),P=e=>m.get(`/api/subscriptions/${e}/payer-token`).then(n=>n.data),V=({customerId:e,subscriptionId:n})=>m.get(`/api/credit-grants/summary?customer_id=${e}&subscription_id=${n}`).then(i=>i.data);function K({subscription:e,showBalance:n=!0,mode:i="portal"}){const{t:a}=N(),o=e.paymentCurrency?.type==="credit",{data:s,loading:j}=d(()=>O(e.id)),u=L(),{isMobile:v}=T(),{data:l,loading:p}=d(()=>P(e.id),{ready:n}),{data:S}=d(()=>V({customerId:e.customer_id,subscriptionId:e.id}),{ready:o}),C=n&&["arcblock","ethereum","base"].includes(e.paymentMethod.type),I=new h(l?.token||"0").lt(new h(s?.amount||"0")),B=()=>{o||i!=="portal"||u(`/customer/subscription/${e.id}/recharge`)},w=()=>{const z=o?S?.[e.paymentCurrency.id]?.remainingAmount:l?.token;return j||p?t.jsx($,{size:16}):I&&!o&&i==="portal"?t.jsxs(_,{component:"a",color:"error",sx:{height:24,pt:0,pb:0,...v?{textAlign:"right",maxWidth:160}:{}},onClick:()=>u(`/customer/subscription/${e.id}/recharge`),children:[a("admin.subscription.insufficientBalance"),t.jsx(M,{sx:{fontSize:14}})]}):t.jsxs(g,{sx:{flexDirection:"row",alignItems:"center",gap:.5,fontSize:"16px",fontWeight:500,cursor:"pointer","&:hover":{color:"primary.main"}},onClick:B,children:[t.jsx(W,{src:e.paymentCurrency?.logo,sx:{width:16,height:16},alt:e.paymentCurrency?.name}),t.jsxs(R,{sx:{display:"flex",alignItems:"baseline"},children:[f(z,e.paymentCurrency.decimal),t.jsx(c,{sx:{fontSize:14,ml:.5},children:e.paymentCurrency.symbol})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(r,{label:a("common.status"),value:t.jsx(F,{subscription:e}),divider:!0}),e.status==="active"&&!e.cancel_at&&t.jsx(r,{label:a("admin.subscription.nextInvoice"),value:y(e.current_period_end*1e3),divider:!0}),["active","trialing"].includes(e.status)&&s?.amount&&s.amount!=="0"&&t.jsx(r,{label:t.jsxs(c,{sx:{display:"flex",alignItems:"center",gap:.5,fontSize:14,fontWeight:500},children:[a("admin.subscription.nextInvoiceAmount"),t.jsx(x,{title:a("admin.subscription.nextInvoiceAmountTip"),placement:"top",arrow:!0,children:t.jsx(b,{fontSize:"small",sx:{color:"text.secondary",cursor:"pointer",fontSize:"16px"}})})]}),value:`${f(s.amount,e.paymentCurrency.decimal)} ${e.paymentCurrency.symbol} (${a("common.estimated")})`,divider:!0}),C&&["active","trialing"].includes(e.status)&&t.jsx(r,{label:t.jsxs(g,{direction:"row",spacing:1,sx:{alignItems:"center",fontWeight:500},children:[t.jsx(c,{sx:{fontWeight:500,fontSize:14},children:a("admin.subscription.currentBalance")}),t.jsx(x,{title:t.jsxs(c,{sx:{fontFamily:"monospace",fontSize:"13px"},children:[a("admin.subscription.paymentAddress"),":",p?t.jsx(A,{width:120}):l?.paymentAddress]}),placement:"top",arrow:!0,children:t.jsx(k,{sx:{fontSize:"16px",color:"text.secondary",cursor:"pointer","&:hover":{color:"primary.main"},display:{xs:"none",md:"block"}}})})]}),value:w(),divider:!0}),e.status==="canceled"&&e.canceled_at&&t.jsx(r,{label:a("admin.subscription.cancel.done"),value:y(e.canceled_at*1e3),divider:!0})]})}export{K as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as M,e as f,K as pt,u as Jt,j as l,a1 as ee,B as Y,a0 as Zt,$ as V,Y as Be,q as T,c8 as qn,a8 as Gn,a9 as Xn,aH as Kn,I as _e,c9 as Qn,aQ as St,aT as Pt,ad as jt,ca as Un,cb as Jn,cc as Zn,cd as er,ce as tr,cf as nr,ah as Z,aF as rr,a3 as _,x as Mt,cg as ar,bq as ir,bg as oe,N as Ze,M as Ct,bj as or,aV as sr,aW as cr,aN as lr,aM as et}from"./vendor-mui-BXZut9Pz.js";import{
|
|
1
|
+
import{r as M,e as f,K as pt,u as Jt,j as l,a1 as ee,B as Y,a0 as Zt,$ as V,Y as Be,q as T,c8 as qn,a8 as Gn,a9 as Xn,aH as Kn,I as _e,c9 as Qn,aQ as St,aT as Pt,ad as jt,ca as Un,cb as Jn,cc as Zn,cd as er,ce as tr,cf as nr,ah as Z,aF as rr,a3 as _,x as Mt,cg as ar,bq as ir,bg as oe,N as Ze,M as Ct,bj as or,aV as sr,aW as cr,aN as lr,aM as et}from"./vendor-mui-BXZut9Pz.js";import{cs as ur,c8 as De,bp as Et,V as dr,B as H,Y as hr,J as fr,P as tt,a7 as mr,G as gr}from"./vendor-blocklet-DcLR2Cyf.js";import{a as yr,e as nt,q as ct,i as rt,a3 as pr}from"./index-BarN7DfU.js";import{L as Fe}from"./vendor-react-BPknnnEA.js";import{w as Re,i as Le,a as vr,u as br,b as xr,c as wr,d as U,e as Dr,h as Or,j as en,k as tn,l as nn,C as rn,m as fe,L as Me,n as ze,o as at,A as kr,p as be,q as Sr,r as Pr,s as jr,t as Mr,G as Cr,v as At,x as Tt,D as Er,g as Ar,X as an,Y as on,f as Tr,T as Nr,y as Wr}from"./generateCategoricalChart-BadryV3H.js";import{h as Nt,s as Rr}from"./util-DxXTXkeY.js";import{C as _r}from"./currency-select-B4ieQBvv.js";function Ie(e){"@babel/helpers - typeof";return Ie=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ie(e)}function Wt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function $e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Wt(Object(n),!0).forEach(function(r){Ir(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wt(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Ir(e,t,n){return t=Yr(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yr(e){var t=Fr(e,"string");return Ie(t)=="symbol"?t:t+""}function Fr(e,t){if(Ie(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Ie(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Lr(e,t){return Br(e)||Hr(e,t)||$r(e,t)||zr()}function zr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $r(e,t){if(e){if(typeof e=="string")return Rt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Rt(e,t)}}function Rt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Hr(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,a,i,o,d=[],u=!0,h=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(u=(r=i.call(n)).done)&&(d.push(r.value),d.length!==t);u=!0);}catch(c){h=!0,a=c}finally{try{if(!u&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw a}}return d}}function Br(e){if(Array.isArray(e))return e}var Vr=M.forwardRef(function(e,t){var n=e.aspect,r=e.initialDimension,a=r===void 0?{width:-1,height:-1}:r,i=e.width,o=i===void 0?"100%":i,d=e.height,u=d===void 0?"100%":d,h=e.minWidth,c=h===void 0?0:h,m=e.minHeight,g=e.maxHeight,p=e.children,O=e.debounce,b=O===void 0?0:O,y=e.id,w=e.className,P=e.onResize,j=e.style,k=j===void 0?{}:j,x=M.useRef(null),C=M.useRef();C.current=P,M.useImperativeHandle(t,function(){return Object.defineProperty(x.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),x.current},configurable:!0})});var z=M.useState({containerWidth:a.width,containerHeight:a.height}),N=Lr(z,2),$=N[0],q=N[1],W=M.useCallback(function(X,Q){q(function(F){var v=Math.round(X),L=Math.round(Q);return F.containerWidth===v&&F.containerHeight===L?F:{containerWidth:v,containerHeight:L}})},[]);M.useEffect(function(){var X=function(ve){var ke,Se=ve[0].contentRect,Pe=Se.width,je=Se.height;W(Pe,je),(ke=C.current)===null||ke===void 0||ke.call(C,Pe,je)};b>0&&(X=ur(X,b,{trailing:!0,leading:!1}));var Q=new ResizeObserver(X),F=x.current.getBoundingClientRect(),v=F.width,L=F.height;return W(v,L),Q.observe(x.current),function(){Q.disconnect()}},[W,b]);var te=M.useMemo(function(){var X=$.containerWidth,Q=$.containerHeight;if(X<0||Q<0)return null;Re(Le(o)||Le(u),`The width(%s) and height(%s) are both fixed numbers,
|
|
3
3
|
maybe you don't need to use a ResponsiveContainer.`,o,u),Re(!n||n>0,"The aspect(%s) must be greater than zero.",n);var F=Le(o)?X:o,v=Le(u)?Q:u;n&&n>0&&(F?v=F/n:v&&(F=v*n),g&&v>g&&(v=g)),Re(F>0||v>0,`The width(%s) and height(%s) of chart should be greater than 0,
|
|
4
4
|
please check the style of container, or the props width(%s) and height(%s),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as g,j as t,B as n,q as o,$ as s,Y as h,O as m,ai as l,b4 as u,x as d,bS as f,cs as b,ct as j,cu as y,bW as v,cv as k,cw as w,cx as S}from"./vendor-mui-BXZut9Pz.js";import{V as C,$ as z}from"./vendor-blocklet-
|
|
1
|
+
import{r as g,j as t,B as n,q as o,$ as s,Y as h,O as m,ai as l,b4 as u,x as d,bS as f,cs as b,ct as j,cu as y,bW as v,cv as k,cw as w,cx as S}from"./vendor-mui-BXZut9Pz.js";import{V as C,$ as z}from"./vendor-blocklet-DcLR2Cyf.js";import{a as O}from"./vendor-react-BPknnnEA.js";const W=[{title:"integrations.features.products.title",description:"integrations.features.products.intro",icon:t.jsx(f,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products"},{title:"integrations.features.paymentLinks.title",description:"integrations.features.paymentLinks.intro",icon:t.jsx(b,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products/links"},{title:"integrations.features.pricingTables.title",description:"integrations.features.pricingTables.intro",icon:t.jsx(j,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products/pricing-tables"}],I=[{title:"integrations.features.metering.title",description:"integrations.features.metering.intro",icon:t.jsx(y,{sx:{fontSize:32,color:"text.lighter"}}),dialog:"metering",doc:{url:"https://www.arcblock.io/blog/en/payment-kit-enhanced-credit-management"}},{title:"integrations.features.promotions.title",description:"integrations.features.promotions.intro",icon:t.jsx(v,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/products/coupons",doc:{url:"https://www.arcblock.io/content/blog/en/payment-kit-promotion-code-discounts-support"}},{title:"integrations.features.donate.title",description:"integrations.features.donate.intro",icon:t.jsx(k,{sx:{fontSize:32,color:"text.lighter"}}),path:"/integrations/donations"},{title:"integrations.features.paymentMethods.title",description:"integrations.features.paymentMethods.intro",icon:t.jsx(w,{sx:{fontSize:32,color:"text.lighter"}}),path:"/admin/settings/payment-methods"},{title:"integrations.features.api.title",description:"integrations.features.api.intro",icon:t.jsx(S,{sx:{fontSize:32,color:"text.lighter"}}),path:"https://www.staging.arcblock.io/content/docs/payment-kit-sdk",external:!0}];function F(){const{t:i}=C(),a=O(),[x,r]=g.useState(!1),c=e=>{if(e.dialog==="metering"){r(!0);return}e.external?window.open(e.path,"_blank"):a(e.path)};return t.jsxs(n,{children:[t.jsx(n,{sx:{mb:4},children:t.jsx(o,{variant:"body2",sx:{color:"text.secondary",mb:2},children:i("common.welcomeDesc")})}),t.jsxs(o,{variant:"h3",gutterBottom:!0,sx:{mb:2},children:[i("integrations.basicFeatures")," 🚀"]}),t.jsx(s,{container:!0,spacing:2,sx:{mb:4,maxWidth:1200},children:W.map(e=>t.jsx(s,{size:{xs:12,sm:6,md:4},children:t.jsxs(n,{className:"base-card",onClick:()=>c(e),sx:{height:"100%",cursor:"pointer","&:hover":{boxShadow:2}},children:[t.jsxs(n,{sx:{mb:1},children:[e.icon,t.jsx(o,{variant:"h4",sx:{mt:1.5},children:i(e.title)})]}),t.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:i(e.description)})]})},e.path))}),t.jsx(h,{sx:{my:4}}),t.jsxs(o,{variant:"h3",gutterBottom:!0,sx:{mb:2},children:[i("integrations.advancedFeatures")," 🔥"]}),t.jsx(s,{container:!0,spacing:2,sx:{maxWidth:1200},children:I.map(e=>t.jsx(s,{size:{xs:12,sm:6,md:4},children:t.jsxs(n,{className:"base-card",onClick:()=>c(e),sx:{height:"100%",cursor:"pointer","&:hover":{boxShadow:2}},children:[t.jsxs(n,{sx:{mb:1},children:[e.icon,t.jsxs(n,{sx:{display:"flex",alignItems:"center",mt:1.5},children:[t.jsx(o,{variant:"h4",children:i(e.title)}),e.doc?.url&&t.jsx(m,{title:i("integrations.viewDocs"),placement:"top",children:t.jsx(l,{href:e.doc.url,target:"_blank",rel:"noopener",onClick:p=>p.stopPropagation(),sx:{display:"flex",alignItems:"center",ml:1,color:"text.secondary","&:hover":{color:"primary.main"}},children:t.jsx(u,{fontSize:"small",sx:{cursor:"pointer"}})})})]})]}),t.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:i(e.description)})]})},e.path))}),t.jsxs(z,{open:x,onClose:()=>r(!1),maxWidth:"sm",fullWidth:!0,className:"base-dialog",title:i("integrations.features.metering.dialog.title"),actions:t.jsxs(n,{sx:{display:"flex",gap:2},children:[t.jsx(d,{onClick:()=>r(!1),children:i("common.cancel")}),t.jsx(d,{onClick:()=>a("/admin/billing/meters"),variant:"contained",children:i("common.goToConfigure")})]}),children:[t.jsx(o,{variant:"body2",sx:{color:"text.secondary",mb:3},children:i("integrations.features.metering.dialog.description")}),t.jsx(n,{component:"ol",sx:{pl:0,mb:3,listStyle:"none",counterReset:"step-counter"},children:["step1","step2","step3","step4"].map(e=>t.jsx(n,{component:"li",sx:{mb:3,pl:3,position:"relative",counterIncrement:"step-counter","&::before":{content:"counter(step-counter)",position:"absolute",left:0,top:0,width:24,height:24,borderRadius:"50%",backgroundColor:"primary.main",color:"white",fontSize:"12px",fontWeight:"bold",display:"flex",alignItems:"center",justifyContent:"center"}},children:t.jsxs(n,{sx:{ml:.5},children:[t.jsx(o,{variant:"subtitle2",sx:{fontWeight:600,mb:.5},children:i(`integrations.features.metering.dialog.steps.${e}.title`)}),t.jsx(o,{variant:"body2",sx:{color:"text.secondary",lineHeight:1.5},children:i(`integrations.features.metering.dialog.steps.${e}.description`)})]})},e))}),t.jsx(n,{sx:{p:2,backgroundColor:"action.hover",borderRadius:1,border:"1px solid",borderColor:"divider"},children:t.jsx(l,{href:"https://www.staging.arcblock.io/content/docs/payment-kit-sdk/en/payment-kit-sdk-core-concepts-credit-billing",target:"_blank",rel:"noopener",underline:"hover",sx:{color:"primary.main",fontWeight:500,display:"flex",alignItems:"center",gap:.5},children:i("integrations.features.metering.dialog.docText")})})]})]})}export{F as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as e,A as l,w as
|
|
1
|
+
import{r as i,j as e,A as l,w as B,a3 as r,bv as O,q as A,B as m,x as D,bf as R}from"./vendor-mui-BXZut9Pz.js";import{V as _,P as z,Z as H,F as L}from"./vendor-blocklet-DcLR2Cyf.js";import{u as T,a as U,k as g,O as q,m as F,l as N,x as W,e as Q}from"./index-BarN7DfU.js";import{b as V}from"./vendor-react-BPknnnEA.js";import{l as Z}from"./lodash-B4Ozcv0x.js";import{S as G}from"./header-ivXuPt06.js";import{g as j}from"./util-DxXTXkeY.js";import{u as J}from"./browser-DDv4_sgY.js";const K=()=>Q.get("/api/customers/me").then(s=>s.data);function ne(){const{t:s,locale:v}=_(),{events:b}=T(),{connect:n,session:P}=U(),[u]=V(),w=J(),[d,p]=i.useState(!1),[f,a]=i.useState(!1),{loading:S,error:x,data:h,runAsync:C}=z(K);if(i.useEffect(()=>{b.on("switch-did",()=>{C().catch(console.error)})},[]),x)return e.jsx(l,{severity:"error",children:g(x)});if(S)return e.jsx(B,{});if(!h)return e.jsx(l,{sx:{mt:3},severity:"info",children:s("payment.customer.empty")});const t=u.get("subscription")||"",c=u.get("currency")||"",I=()=>{t&&c?n.open({containerEl:void 0,saveConnect:!1,action:"collect-batch",locale:v,prefix:L(N(),"/api/did"),extraParams:{subscriptionId:t,currencyId:c},messages:{scan:s("common.connect.defaultScan"),title:s("payment.customer.invoice.payBatch"),confirm:s("common.connect.confirm")},onSuccess:()=>{n.close()},onClose:()=>{n.close()},onError:o=>{H.error(g(o))}}):a(!0)},k=(o,E)=>{if(Z.isEmpty(o)||o?.count===0){if(p(!1),E?.count>0){const y=W(window.location.href)?.referer;y?window.location.replace(y):j("/customer")}return}p(!0)};return e.jsxs(r,{direction:"column",spacing:3,sx:{my:2},children:[e.jsx(r,{direction:"row",sx:{alignItems:"center",justifyContent:"space-between"},children:w?e.jsx(m,{}):e.jsxs(r,{direction:"row",onClick:()=>j("/customer"),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[e.jsx(O,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),e.jsx(A,{variant:"h6",sx:{color:"text.secondary",fontWeight:"normal"},children:s("common.previous")})]})}),e.jsxs(M,{direction:"column",spacing:3,children:[d&&e.jsx(l,{severity:"error",children:s("payment.customer.pastDue.warning")}),f&&e.jsx(q,{customerId:P.user.did,subscriptionId:t,onPaid:()=>{a(!1)},successToast:!1,dialogProps:{open:f,onClose:()=>a(!1)},detailLinkOptions:{enabled:!1}}),e.jsxs(m,{className:"section",children:[e.jsx(G,{title:s("payment.customer.pastDue.invoices"),mb:0,children:d&&e.jsx(D,{size:"small",variant:"contained",color:"primary",onClick:I,children:s("admin.subscription.batchPay.button")})}),e.jsx(m,{className:"section-body",children:e.jsx(F,{customer_id:h.id,subscription_id:t,currency_id:c,pageSize:10,status:"uncollectible",target:"_blank",action:"pay",type:"table",onTableDataChange:k,relatedSubscription:!0})})]})]})]})}const M=R(r)`
|
|
2
2
|
a {
|
|
3
3
|
text-decoration: underline;
|
|
4
4
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as p,j as t,u as We,B as _,ah as ce,p as An,a7 as Ke,a3 as D,N as Ce,bO as Jt,q as g,a1 as Ne,aV as Dn,i as mt,Q as Mn,bn as en,I as Ve,bo as zn,a2 as tn,bp as nn,aY as Nn,w as ft,bP as rn,x as Ee,bQ as Fn,L as sn,bj as $n,bR as xt,bS as Wn,bT as Pt,be as On,aZ as ht,o as on,A as Un,bs as Ln,bt as qn,bU as Bn,bV as Hn,aT as nt,ad as rt,b4 as Tt,Y as lt,O as Vn,bW as At,M as Qn,bX as Dt,F as Gn,bC as Kn}from"./vendor-mui-BXZut9Pz.js";import{a3 as q,aN as Yn,A as Xn,U as Zn,G as z,H as Te,L as Xe,ab as gt,Z as Fe,V as be,P as ut,W as Jn,F as an}from"./vendor-blocklet-DcLR2Cyf.js";import{ae as ee,af as X,ag as er,ah as tr,ai as nr,aj as rr,ak as ir,al as _e,am as Ie,an as yt,ao as sr,ap as or,d as Ze,aq as Ye,ar as He,as as Ae,at as $e,au as cn,av as xe,aw as ar,ax as ln,a as un,e as dt,ay as Be,i as cr,a8 as Re,a3 as lr,ad as ur,R as dr,az as pr,aA as dn,aa as mr,aB as fr,aC as xr,aD as hr,U as gr,O as yr,l as pn,a0 as br,aE as _r,I as Mt,aF as Sr,aG as mn,aH as zt,aI as wr}from"./index-BarN7DfU.js";import{b as vr}from"./vendor-react-BPknnnEA.js";function je(e){const n=e;return n?.response?.data?.error?n.response.data.error:e instanceof Error?e.message:typeof e=="string"?e:n?.message||"Unknown error"}function pt(e){const n=e,r=n?.response?.data;return{message:r?.error||n?.message||"Unknown error",code:r?.code,data:r,isCancelled:n?.name==="CanceledError"||n?.name==="AbortError"}}function kr(e){const n=e.line_items||[];if(n.length===0)return null;const r=n[0],i=r.upsell_price||r.price,s=i?.product;if(!s)return null;const o=i?.recurring,a=e.mode==="subscription"?"subscription":"payment",c={day:"daily",week:"weekly",month:"monthly",year:"yearly"};return{name:s.name||"",description:s.description||"",images:s.images||[],features:(s.features||[]).map(l=>({name:l.name||"",icon:l.icon})),billing:{mode:a,interval:o?.interval||null,intervalCount:o?.interval_count||1,displayInterval:o?c[o.interval]||o.interval:""},metadata:s.metadata||{}}}function jr(e){const n=e.subscription_data;return!n&&e.mode==="payment"?null:{mode:e.mode||"payment",showStake:!n?.no_stake,confirmMessage:""}}function Cr(e){const n=e.metadata,r=n?.page_info,i=n?.show_product_features??r?.show_product_features;return{formPurposeDescription:r?.form_purpose_description,showProductFeatures:`${i}`=="true"}}function Ir(e){const[n,r]=p.useState(!0),[i,s]=p.useState(null),[o,a]=p.useState(null),c=p.useRef(null),l=p.useRef(!0),u=p.useRef(null),f=e?.startsWith("plink_"),d=q(async()=>{if(!f)return e;if(u.current)return u.current;const{data:v}=await ee.post(X.START_PAYMENT_LINK(e)),C=v?.checkoutSession?.id;if(!C)throw new Error("Failed to start payment link session");return u.current=C,C}),m=q(async(v=!1)=>{if(c.current&&c.current.abort(),c.current=new AbortController,!e){r(!1),s("Session ID is required");return}try{v||r(!0),s(null);const C=await d(),E=v?`${X.RETRIEVE_SESSION(C)}?forceRefresh=1`:X.RETRIEVE_SESSION(C),{data:y}=await ee.get(E,{signal:c.current.signal});if(!l.current)return;const I=y?.checkoutSession;if(I){if(I.status!=="complete"&&I.expires_at&&I.expires_at<=Math.round(Date.now()/1e3)){s("SESSION_EXPIRED"),r(!1);return}if(!I.line_items?.length){s("EMPTY_LINE_ITEMS"),r(!1);return}}if(y?.stopAcceptingOrders&&I?.status!=="complete"){s("STOP_ACCEPTING_ORDERS"),r(!1);return}a(y),r(!1)}catch(C){if(!l.current)return;const{isCancelled:E,message:y}=pt(C);if(E)return;s(y||"Failed to load checkout session"),r(!1)}}),b=p.useCallback(async(v=!1)=>{await m(v)},[m]);p.useEffect(()=>(l.current=!0,m(),()=>{l.current=!1,c.current&&c.current.abort()}),[e]);const h=o?.checkoutSession,x=u.current||(f?"":e);let k=null;i==="SESSION_EXPIRED"?k="SESSION_EXPIRED":i==="EMPTY_LINE_ITEMS"?k="EMPTY_LINE_ITEMS":i==="STOP_ACCEPTING_ORDERS"&&(k="STOP_ACCEPTING_ORDERS");const F=h?.line_items?.reduce((v,C)=>v+(C?.price?.product?.vendor_config?.length||0),0)||0;return{isLoading:n,error:i,errorCode:k,refresh:b,setSessionData:a,sessionData:o,resolvedSessionId:x,vendorCount:F,product:h?kr(h):null,subscription:h?jr(h):null,pageInfo:h?Cr(h):null}}function Er(e){const n=[];return e.forEach(r=>{(r.payment_currencies||[]).forEach(s=>{const o={...s,method:{id:r.id,name:r.name,type:r.type}};n.push(o)})}),n}function Rr(e){return(e?.connectedAccounts||e?.extraConfigs?.connectedAccounts||[]).some(r=>r.provider==="wallet")}const Nt="payment-currency-preference";function fn(e){return e?`${Nt}:${e}`:Nt}function Ft(e,n){const r=new Set(n.flatMap(s=>(s.payment_currencies||[]).map(o=>o.id)).filter(Boolean)),i=s=>!!s&&r.has(s);if(e?.discounts?.length&&i(e.currency_id))return e.currency_id;if(typeof window<"u"){try{const o=new URLSearchParams(window.location.search),a=o.get("currencyId")||o.get("currency_id");if(i(a))return a}catch{}const s=e?.user;if(s&&!Rr(s)){const a=n.find(c=>c.type==="stripe")?.payment_currencies?.[0];if(i(a?.id))return a?.id}try{const o=e?.user?.did,a=localStorage.getItem(fn(o));if(i(a))return a}catch{}}return i(e?.currency_id)?e?.currency_id:n[0]?.payment_currencies?.[0]?.id||null}function $t(e,n){if(!n)return{method:null,currency:null};for(const i of e)for(const s of i.payment_currencies||[])if(s.id===n)return{method:i,currency:s};const r=e[0];return{method:r||null,currency:r?.payment_currencies?.[0]||null}}function Pr(e,n){const r=new Map;return e.forEach(i=>{const s=i.type==="stripe"?"stripe":"crypto";r.has(s)||r.set(s,{currencies:[],active:!1});const o=r.get(s),a=(i.payment_currencies||[]).map(c=>({...c,method:{id:i.id,name:i.name,type:i.type}}));o.currencies.push(...a),i===n&&(o.active=!0)}),Array.from(r.entries()).map(([i,s])=>({type:i,label:i==="stripe"?"Card":"Crypto",currencies:s.currencies,active:s.active}))}function Tr(e,n,r,i){const s=p.useMemo(()=>e?.paymentMethods||[],[e?.paymentMethods]),o=e?.checkoutSession,[a,c]=p.useState(()=>Ft(o,s)),[l,u]=p.useState(!1),f=p.useRef(null);p.useEffect(()=>{o&&!a&&c(Ft(o,s))},[o?.id]);const{method:d,currency:m}=p.useMemo(()=>$t(s,a),[s,a]),b=p.useMemo(()=>Er(s),[s]),h=d?.type==="stripe",x=d?.type!=="stripe"&&d?.type!==void 0,k=m?.type==="credit",F=p.useMemo(()=>Pr(s,d),[s,d]),v=q(async y=>{const I=s.find($=>y==="stripe"?$.type==="stripe":$.type!=="stripe");if(!I)return;const N=I.payment_currencies?.[0];N&&await C(N.id)}),C=q(async y=>{if(o?.status==="complete")return;const{method:I}=$t(s,y);if(!(!I||!n)){u(!0);try{const{data:N}=await ee.put(X.SWITCH_CURRENCY(n),{currency_id:y,payment_method_id:I.id});c(y);try{localStorage.setItem(fn(o?.user?.did),y)}catch{}e&&i?i({...e,checkoutSession:N,quotes:void 0}):await r(!0)}catch(N){console.error("Failed to switch currency:",je(N)),o?.currency_id&&c(o.currency_id)}finally{u(!1)}}});p.useEffect(()=>{if(!o?.id||!a||!s.length||f.current===o.id)return;f.current=o.id;const y=o.currency_id;o.status!=="complete"&&y&&y!==a&&C(a)},[o?.id,a,s.length]);const E=p.useMemo(()=>!d||d.type!=="stripe"?null:{publishableKey:d.settings?.stripe?.publishable_key||null,clientSecret:e?.paymentIntent?.client_secret||null,status:"idle"},[d,e?.paymentIntent]);return{current:d,currency:m,available:s,currencies:b,isStripe:h,isCrypto:x,isCredit:k,switching:l,setType:v,types:F,setCurrency:C,stripe:E}}const we=/^\d{4}$/,ve=/^\d{5}$/,Me=/^\d{6}$/,Ar={GB:/^GIR[ ]?0AA|((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))|BFPO[ ]?\d{1,4}$/i,JE:/^JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/i,GG:/^GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/i,IM:/^IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}$/i,US:/^\d{5}([ -]\d{4})?$/,CA:/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,DE:ve,JP:/^\d{3}-?\d{4}$/,FR:/^\d{2}[ ]?\d{3}$/,AU:we,IT:ve,CH:we,AT:we,ES:ve,NL:/^\d{4}[ ]?[A-Z]{2}$/i,BE:we,DK:we,SE:/^\d{3}[ ]?\d{2}$/,NO:we,BR:/^\d{5}-?\d{3}$/,PT:/^\d{4}(-\d{3})?$/,FI:ve,KR:ve,CN:Me,TW:/^\d{3}(\d{2})?$/,SG:Me,IN:/^[1-9]\d{5}$/,RU:Me,PL:/^\d{2}-\d{3}$/,CZ:/^\d{3}[ ]?\d{2}$/,HU:we,RO:Me,BG:we,HR:ve,SK:/^\d{3}[ ]?\d{2}$/,SI:we,TR:ve,IL:ve,ZA:we,MX:ve,AR:/^([A-HJ-NP-Z])?\d{4}([A-Z]{3})?$/i,CL:/^\d{7}$/,CO:Me,NZ:we,MY:ve,TH:ve,PH:we,ID:ve,VN:Me};function Dr(e,n){if(!e)return!0;try{const r=n?.toUpperCase();if(!r)return!1;const i=Ar[r];return!i||i.test(e)}catch{return!1}}function Pe(e,n,r="en"){if(!n||!n[e])return{};const i=n[e],s={};return i.pattern&&(s.pattern={value:new RegExp(i.pattern),message:i.pattern_message?.[r]||"Invalid format"}),s}let it=null;async function Mr(){if(!it){const e=await Xn(()=>import("./libphonenumber-Qs8PCdM-.js").then(r=>r.l),[]),n=(e.default||e)?.PhoneNumberUtil;if(!n)throw new Error("PhoneNumberUtil not found");it=n.getInstance()}return it}const zr=/^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,6}$/im;async function Nr(e){if(!e||e.trim()==="")return!1;try{const n=await Mr(),r=n.parseAndKeepRawInput(e);return n.isValidNumber(r)}catch{return zr.test(e)}}function Fr(e){return!e||e.trim()===""?!1:Yn(e)}async function st(e,n){const r={},{phoneEnabled:i,addressMode:s,fieldValidation:o,locale:a="en"}=n;if(!e)return{valid:!1,errors:{customer_name:"Required"}};const c=e.customer_name;if(!c||c.trim()==="")r.customer_name="Required";else{const x=Pe("customer_name",o,a);x.pattern&&!x.pattern.value.test(c)&&(r.customer_name=x.pattern.message)}const l=e.customer_email;if(!l||!Fr(l))r.customer_email=l?"Invalid email":"Required";else{const x=Pe("customer_email",o,a);x.pattern&&!x.pattern.value.test(l)&&(r.customer_email=x.pattern.message)}if(i){const x=e.customer_phone;if(!x||x.trim()==="")r.customer_phone="Required";else if(!await Nr(x))r.customer_phone="Invalid phone number";else{const k=Pe("customer_phone",o,a);k.pattern&&!k.pattern.value.test(x)&&(r.customer_phone=k.pattern.message)}}const u=e.billing_address,f=u?.postal_code,d=u?.country,m=u?.state,b=u?.line1,h=u?.city;if(!f)r["billing_address.postal_code"]="Required";else if(!Dr(f,d))r["billing_address.postal_code"]="Invalid postal code";else{const x=Pe("billing_address.postal_code",o,a);x.pattern&&!x.pattern.value.test(f)&&(r["billing_address.postal_code"]=x.pattern.message)}if(!m)r["billing_address.state"]="Required";else{const x=Pe("billing_address.state",o,a);x.pattern&&!x.pattern.value.test(m)&&(r["billing_address.state"]=x.pattern.message)}if(s==="required"){if(d||(r["billing_address.country"]="Required"),!b)r["billing_address.line1"]="Required";else{const x=Pe("billing_address.line1",o,a);x.pattern&&!x.pattern.value.test(b)&&(r["billing_address.line1"]=x.pattern.message)}if(!h)r["billing_address.city"]="Required";else{const x=Pe("billing_address.city",o,a);x.pattern&&!x.pattern.value.test(h)&&(r["billing_address.city"]=x.pattern.message)}}return{valid:Object.keys(r).length===0,errors:r}}function $r(e){const n=[];n.push({name:"customer_name",type:"text",required:!0}),n.push({name:"customer_email",type:"email",required:!0}),e?.phone_number_collection?.enabled&&n.push({name:"customer_phone",type:"phone",required:!0});const r=e?.billing_address_collection;return r==="required"?n.push({name:"billing_address.country",type:"country",required:!0,group:"address"},{name:"billing_address.line1",type:"text",required:!0,group:"address"},{name:"billing_address.city",type:"text",required:!0,group:"address"},{name:"billing_address.state",type:"text",required:!0,group:"address"},{name:"billing_address.postal_code",type:"text",required:!0,group:"address"}):r==="auto"&&n.push({name:"billing_address.state",type:"text",required:!1,group:"address"},{name:"billing_address.postal_code",type:"text",required:!1,group:"address"}),n}function Wt(e,n){return{customer_name:n?.name||"",customer_email:e?.customer_details?.email||n?.email||"",customer_phone:n?.phone||"",payment_method:"",payment_currency:e?.currency_id||"",billing_address:{country:n?.address?.country||"us",state:n?.address?.state||"",city:n?.address?.city||"",line1:n?.address?.line1||"",line2:n?.address?.line2||"",postal_code:n?.address?.postal_code||""}}}function xn(e,n,r){const i=n.split(".");if(i.length===1)return{...e,[n]:r};const[s,...o]=i;return{...e,[s]:xn(e[s]||{},o.join("."),r)}}function Wr(e,n,r){const i=e?.checkoutSession,s=e?.customer,o=p.useMemo(()=>$r(i),[i?.id]),[a,c]=p.useState(()=>Wt(i,s)),[l,u]=p.useState({}),[f,d]=p.useState({}),[m,b]=p.useState(!1);p.useEffect(()=>{i&&!m&&c(Wt(i,s))},[i?.id]),p.useEffect(()=>{(n||r)&&c(E=>({...E,...n&&{payment_currency:n},...r&&{payment_method:r}}))},[n,r]),p.useEffect(()=>{if(!i||m||i.status==="complete")return;(async()=>{try{const{data:y}=await ee.get(`${X.CUSTOMER_ME}?fallback=1&skipSummary=1`);y&&(b(!0),c(I=>({...I,customer_name:I.customer_name||y.name||"",customer_email:I.customer_email||y.email||"",customer_phone:I.customer_phone||y.phone||"",billing_address:{...I.billing_address,country:I.billing_address?.country||y.address?.country||"",state:I.billing_address?.state||y.address?.state||"",city:I.billing_address?.city||y.address?.city||"",line1:I.billing_address?.line1||y.address?.line1||"",line2:I.billing_address?.line2||y.address?.line2||"",postal_code:I.billing_address?.postal_code||y.address?.postal_code||""}})))}catch{b(!0)}})()},[i?.id]);const h=q((E,y)=>{c(I=>xn(I,E,y)),d(I=>({...I,[E]:!0}))}),x=q(()=>({phoneEnabled:!!i?.phone_number_collection?.enabled,addressMode:i?.billing_address_collection,fieldValidation:i?.metadata?.page_info?.field_validation})),k=q(async()=>{const E=await st(a,x());return u(E.errors),E.valid}),F=q(async()=>(await st(a,x())).valid),v=q(async E=>{const y=await st(a,x());u(I=>{const N={...I};return y.errors[E]?N[E]=y.errors[E]:delete N[E],N})}),C=q(async()=>{try{const{data:E}=await ee.get(`${X.CUSTOMER_ME}?fallback=1&skipSummary=1`);E&&(b(!0),c(y=>({...y,customer_name:E.name||y.customer_name||"",customer_email:E.email||y.customer_email||"",customer_phone:E.phone||y.customer_phone||"",billing_address:{...y.billing_address,country:E.address?.country||y.billing_address?.country||"",state:E.address?.state||y.billing_address?.state||"",city:E.address?.city||y.billing_address?.city||"",line1:E.address?.line1||y.billing_address?.line1||"",line2:E.address?.line2||y.billing_address?.line2||"",postal_code:E.address?.postal_code||y.billing_address?.postal_code||""}})))}catch{b(!0)}});return{fields:o,values:a,onChange:h,errors:l,touched:f,validate:k,checkValid:F,validateField:v,prefetched:m,refetchCustomer:C}}const Or=300*1e3;function Ur(e){return e<5e3?500:e<3e4?1500:3e3}const Lr=e=>new Promise(n=>setTimeout(n,e));async function qr(e){const n=Date.now();for(;;){const{data:i}=await ee.get(X.STATUS_SESSION(e));if(i.paymentIntent&&i.paymentIntent.status==="requires_action"&&i.paymentIntent.last_payment_error)throw new Error(i.paymentIntent.last_payment_error.message);if(i.checkoutSession?.status==="complete"&&["paid","no_payment_required"].includes(i.checkoutSession?.payment_status))break;const o=Date.now()-n;if(o>=Or)throw new Error("waitForCheckoutComplete: timed out");await Lr(Ur(o))}const{data:r}=await ee.get(X.RETRIEVE_SESSION(e));return r}function hn(e,n){return`${e}-${n}-${Date.now()}-${Math.random().toString(36).substring(2,10)}`}const Br=["QUOTE_LOCK_EXPIRED","QUOTE_AMOUNT_MISMATCH","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED","QUOTE_MAX_PAYABLE_EXCEEDED","quote_validation_failed"],Hr="/.well-known/service/relay";function gn(){const e=window.blocklet;return e?.appPid||e?.appId||""}function Ot(e){return`relay:${gn()}:${e}`}function Vr(){return window.location.protocol==="https:"?"wss:":"ws:"}function Qr(){return new URL(window.location.href).host}function Gr(e,n){if(!e)return"";const i=(e.line_items||[]).map(s=>`${s.upsell_price_id||s.price_id}:${s.quantity}`).join("|");return`${e.id}-${n}-${i}`}function Ut(e,n,r,i,s=!1,o){const l=(i?.line_items||[]).find(u=>u.exchange_rate)?.exchange_rate;return{...r,idempotency_key:o||hn(e,n||""),preview_rate:l||void 0,...s&&{price_confirmed:!0}}}function Lt(e){return Br.includes(e)||e==="QUOTE_UPDATED"}async function Kr(e){try{await ee.post(X.ABORT_STRIPE(e))}catch{}}async function qt(e,n,r){const i=n?X.DONATE_SUBMIT(e):X.SUBMIT(e),{data:s}=await ee.put(i,r);return s}async function ot(e){const{data:n}=await ee.post(X.FAST_CHECKOUT_CONFIRM(e),{});return n}async function Yr(e){const{data:n}=await ee.post(X.SKIP_PAYMENT_METHOD(e),{});return n}async function Xr(e,n){const{data:r}=await ee.put(X.SLIPPAGE(e),{slippage_config:n});return r}function Zr(e,n,r,i,s,o,a,c,l,u){const f=e?.checkoutSession,[d,m]=p.useState("idle"),[b,h]=p.useState(null),[x,k]=p.useState(null),[F,v]=p.useState(!1),C=q(()=>v(!0)),E=q(()=>v(!1)),y=p.useRef(!0),I=p.useRef(!1),N=p.useRef(null),$=p.useRef(null),P=p.useRef(null),[B,H]=p.useState(null),K=p.useRef(null),V=p.useRef(0),Q=2,te=p.useRef(""),U=p.useRef(""),re=p.useRef(!1);p.useEffect(()=>{if(re.current||!f||!e)return;f.status==="complete"&&["paid","no_payment_required"].includes(f.payment_status)&&d==="idle"&&(re.current=!0,k(e),m("completed"))},[f,e]),p.useEffect(()=>{if(y.current=!0,!n||!gn())return;const S=new Zn(`${Vr()}//${Qr()}${Hr}`,{longpollerTimeout:5e3,heartbeatIntervalMs:30*1e3});S.connect(),N.current=S;const R=S.subscribe(Ot("events"));return R.channel="events",$.current=R,()=>{y.current=!1,I.current=!0,$.current&&(S.unsubscribe(Ot($.current.channel)),$.current=null),S.disconnect(),N.current=null}},[n]);const Y=q(async({response:S})=>{S.id===n&&d!=="completed"&&(I.current=!0,await W())});p.useEffect(()=>{const S=$.current;return S&&S.on("checkout.session.completed",Y),()=>{if(S)try{S.off?.("checkout.session.completed",Y)}catch{}}},[$.current,d]);const W=q(async()=>{try{const S=await qr(n);if(!y.current)return;k(S),u?.(S),m("completed"),h(null)}catch(S){if(!y.current)return;m("failed"),h({type:"error",message:je(S)||"Payment verification failed"})}});p.useEffect(()=>{if(re.current||!n||d!=="idle"&&d!=="waiting_stripe")return;let S=null,R=!1;try{const O=new URLSearchParams(window.location.search);S=O.get("redirect_status"),R=!!O.get("payment_intent")}catch{return}if(!(!S&&!R)){if(re.current=!0,S==="failed"||S==="canceled"){m("failed"),h({type:"error",message:"Payment was not completed. Please try again."});return}m("submitting"),h(null),W()}},[n]),p.useEffect(()=>{if(d!=="completed"||!n||!f?.line_items?.some(ie=>!!ie?.price?.product?.vendor_config?.length))return;const R=Date.now(),O=async()=>{try{const{data:ie}=await ee.get(X.VENDOR_ORDER_STATUS(n));if(!y.current)return;const Z=Array.isArray(ie?.vendors)?ie.vendors:[],ge=Date.now()-R>6e3,ke=Z.every(M=>M.progress>=100),w=Z.some(M=>M.status==="failed"||ge&&!!M.error&&!!M.error_message);if(H({...ie,vendors:Z,isAllCompleted:!w&&ke,hasFailed:w}),w||ke)return;K.current=setTimeout(O,5e3)}catch{}};return O(),()=>{K.current&&clearTimeout(K.current)}},[d,n]);const oe=q(async(S,R)=>{try{if(await l(!0),!y.current)return}catch{}if(S==="QUOTE_UPDATED"&&R?.checkoutSession){V.current=0,m("failed"),h({type:"error",message:"Price updated, please resubmit",code:S});return}if(["QUOTE_LOCK_EXPIRED","QUOTE_EXPIRED_OR_USED","QUOTE_NOT_FOUND","QUOTE_REQUIRED"].includes(S)&&V.current<Q){V.current+=1,m("idle"),h(null),await L(!0);return}V.current=0,m("failed"),h({type:"error",message:"Price updated, please resubmit",code:S})}),J=q(async S=>{if(i){const Z=S.stripeContext;if(Z?.status==="succeeded"){await W();return}const ge=S.paymentIntent,ke=Z?.client_secret||ge?.client_secret;if(ke){const w=Z?.intent_type||"payment_intent";m("waiting_stripe"),h({type:"stripe",clientSecret:ke,intentType:w,noPaymentRequired:!!S.noPaymentRequired});return}if(S.noPaymentRequired)try{const w=await ot(n),M=w.checkoutSession;if(w.fastPaid||M?.status==="complete"){await W();return}}catch{}await W();return}if(S.noPaymentRequired){try{const Z=await ot(n),ge=Z.checkoutSession;Z.fastPaid||ge?.status==="complete"?await W():(m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}}))}catch{if(!y.current)return;m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}})}return}const R=S.fastPayInfo,O=S.balance,ie=S.delegation;if(s){if(S.creditSufficient===!0&&R){m("confirming_fast_pay"),h({type:"fast_pay",payType:"credit",amount:R.amount||"0",payer:R.payer||""});return}m("credit_insufficient"),h({type:"credit_insufficient",available:"0",required:"0"});return}if((O?.sufficient||ie?.sufficient)&&!o&&R){m("confirming_fast_pay"),h({type:"fast_pay",payType:R.type||"balance",amount:R.amount||"",payer:R.payer||""});return}m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}})}),ne=q(async S=>{const{code:R,data:O,message:ie}=pt(S);if(R&&Lt(R)){await oe(R,O);return}if(R==="RATE_BELOW_SLIPPAGE_LIMIT"){try{await l(!0)}catch{}if(!y.current)return;te.current="",U.current="",m("failed"),h({type:"error",message:O?.error||"Exchange rate below acceptable limit, please retry",code:R});return}if(R==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:O?.rateError||"Exchange rate unavailable",code:R});return}if(R==="PRICE_CHANGED"){m("confirming_price"),h({type:"price_change",changePercent:O?.change_percent||0});return}if(R==="PRICE_UNAVAILABLE"||R==="PRICE_UNSTABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:O?.error||"Price unavailable, please retry",code:R});return}if(R==="STOP_ACCEPTING_ORDERS"){m("service_suspended"),h({type:"service_suspended"});return}if(R==="UNIFIED_APP_REQUIRED"||R==="CUSTOMER_LIMITED"){m("failed"),h({type:"error",message:O?.error||ie||"Cannot complete payment",code:R});return}const Z=O?.error||ie||"Payment failed";m("failed"),h({type:"error",message:Z,code:R})}),L=q(async(S=!1)=>{if(!S&&d!=="idle")return;if(S||(V.current=0),!await c()){m("failed"),h({type:"error",message:"Please complete the required fields",code:"VALIDATION_FAILED"});return}if(!f?.user?.sourceAppPid&&f?.line_items?.some(ge=>!!ge?.price?.product?.vendor_config?.length)){m("failed"),h({type:"error",message:"Vendor account required",code:"VENDOR_ACCOUNT_REQUIRED"});return}m("submitting"),h(null),k(null),I.current=!1;const O=Gr(f,r);(O!==U.current||!te.current)&&(U.current=O,te.current=hn(n,r||""));const ie=Ut(n,r,a,f,!1,te.current);P.current=ie;try{const Z=await qt(n,o,ie);if(!y.current)return;await J(Z)}catch(Z){if(!y.current)return;await ne(Z)}}),pe=q(async()=>{if(d==="confirming_fast_pay"){m("submitting");try{const S=await ot(n);if(!y.current)return;S.fastPaid?await W():(m("waiting_did"),h({type:"did_connect",action:f?.mode||"payment",checkpointId:n,extraParams:{checkoutSessionId:n,sessionUserDid:f?.user?.did}}))}catch(S){if(!y.current)return;const{code:R,data:O,message:ie}=pt(S);if(R&&Lt(R)){await oe(R,O);return}if(R==="RATE_UNAVAILABLE"){try{await l(!0)}catch{}if(!y.current)return;m("failed"),h({type:"error",message:O?.rateError||"Exchange rate unavailable",code:R});return}m("failed"),h({type:"error",message:O?.error||ie||"Fast pay confirmation failed",code:R})}return}if(d==="confirming_price"){m("submitting"),h(null),I.current=!1;const S=Ut(n,r,a,f,!0,te.current);P.current=S;try{const R=await qt(n,o,S);if(!y.current)return;await J(R)}catch(R){if(!y.current)return;await ne(R)}}}),he=q(()=>{(d==="confirming_price"||d==="confirming_fast_pay"||d==="credit_insufficient"||d==="service_suspended")&&(m("idle"),h(null),E())}),le=q(async()=>{d==="failed"&&(m("idle"),h(null),k(null),await L(!0))}),T=q(()=>{I.current=!0,m("idle"),h(null),k(null),E()}),fe=q(async()=>{d==="waiting_stripe"&&(m("submitting"),h(null),await W())}),me=q(async()=>{d==="waiting_stripe"&&(await Kr(n),m("idle"),h(null))}),j=q(async()=>{if(d==="waiting_stripe")try{m("submitting");const S=await Yr(n);if(!y.current)return;S.skipped||S.checkoutSession?.status==="complete"?await W():(m("failed"),h({type:"error",message:"Failed to skip payment method",code:"SKIP_FAILED"}))}catch(S){if(!y.current)return;m("failed"),h({type:"error",message:S.message||"Failed to skip payment method",code:"SKIP_FAILED"})}}),G=q(async()=>{d==="submitting"||d==="completed"||(I.current=!1,m("submitting"),h(null),await W())});return{status:d,context:b,execute:L,confirm:pe,cancel:he,result:x,retry:le,reset:T,stripeConfirm:fe,stripeCancel:me,stripeSkip:j,didConnectComplete:G,vendorStatus:B,locked:F,lock:C}}const Jr=3e4;function ei(e){return e.some(n=>(n.upsell_price||n.price)?.pricing_type==="dynamic")}async function ti(e,n){const{data:r}=await ee.get(X.EXCHANGE_RATE(e),{params:n?{currency_id:n}:void 0}),i=r.rate||r.exchange_rate;if(i){const s=r.provider_display||r.provider_name||r.provider_id||null;return{rate:i,provider:r.provider_name||r.rate_provider_name||null,providerDisplay:s,fetchedAt:r.fetched_at||r.timestamp_ms||null}}return{rate:null,provider:null,providerDisplay:null,fetchedAt:null}}function ni(e){const n=e?.discounts||[];if(n.length===0)return null;const r=n[0],i=r.promotion_code_details,s=r.verification_data;return i?.code||s?.code||r.promotion_code||r.coupon||null}async function ri(e,n,r){try{const{data:i}=await ee.post(X.APPLY_PROMOTION(e),{promotion_code:n,currency_id:r});return i.error?{success:!1,error:i.error}:{success:!0}}catch(i){return{success:!1,error:je(i)||"Invalid promotion code"}}}async function ii(e){await ee.delete(X.REMOVE_PROMOTION(e))}async function si(e,n){const{data:r}=await ee.post(X.RECALCULATE_PROMOTION_SESSION(e),{currency_id:n});return r}function oi(e){return e?.allow_promotion_codes!==!1}function Je(e){return(e?.discounts||[]).length>0}async function De(e,n,r){if(!Je(e))return null;try{return await si(n,r)}catch{return null}}async function Bt(e,n,r,i,s,o,a,c){const{data:l}=await ee.put(X.ADJUST_QUANTITY(e),{itemId:n,quantity:r,currency_id:i});let u=l;if(l.discounts?.length||Je(s)){const f=await De(s,e,i);f&&(u=f)}a&&c?c({...a,checkoutSession:u,quotes:void 0}):await o(!0)}async function yn(e,n,r,i,s,o,a,c){if((i?.line_items?.length||0)>1)try{await ee.delete(X.CROSS_SELL(e))}catch{}const{data:l}=await ee.put(X.UPSELL(e),{from:n,to:r});let u=l;if(l.discounts?.length||Je(i)){const f=await De(i,e,s);f&&(u=f)}a&&c?c({...a,checkoutSession:u,quotes:void 0}):await o(!0)}async function bn(e,n,r,i,s,o,a){if((r?.line_items?.length||0)>1)try{await ee.delete(X.CROSS_SELL(e))}catch{}const{data:c}=await ee.put(X.DOWNSELL(e),{from:n});let l=c;if(c.discounts?.length||Je(r)){const u=await De(r,e,i);u&&(l=u)}o&&a?a({...o,checkoutSession:l,quotes:void 0}):await s(!0)}async function ai(e,n,r,i,s,o,a,c){const{data:l}=await ee.put(X.CHANGE_AMOUNT(e),{priceId:n,amount:r});let u=l;if(l?.discounts?.length){const f=await De(i,e,s);f&&(u=f)}a&&c?c({...a,checkoutSession:u,quotes:void 0}):await o(!0)}function ci(e){for(const n of e){const r=n.price?.cross_sell;if(r?.cross_sells_to)return r.cross_sells_to}return null}function li({sessionId:e,children:n}){const{isLoading:r,error:i,errorCode:s,refresh:o,setSessionData:a,sessionData:c,resolvedSessionId:l,vendorCount:u,product:f,subscription:d,pageInfo:m}=Ir(e),b=c?.checkoutSession,h=l||e,x=p.useMemo(()=>b?.line_items||[],[b?.line_items]),k=b?.submit_type==="donate",F=p.useMemo(()=>({sessionData:c,setSessionData:a,sessionId:e,effectiveSessionId:h,isLoading:r,error:i,errorCode:s,refresh:o,items:x,session:b||null,isDonation:k,vendorCount:u,product:f,subscription:d,pageInfo:m}),[c,a,e,h,r,i,s,o,x,b,k,u,f,d,m]),v=Tr(c,h,o,a),C=p.useRef(null);p.useEffect(()=>{const L=v.currency?.id||null;!L||!b||b.status==="complete"||(C.current===null||L!==C.current)&&(C.current=L,De(b,h,L).then(pe=>{pe&&o(!0)}))},[v.currency?.id,b?.id]);const E=p.useMemo(()=>({current:v.current,currency:v.currency,available:v.available,currencies:v.currencies,isStripe:v.isStripe,isCrypto:v.isCrypto,isCredit:v.isCredit,switching:v.switching,setType:v.setType,types:v.types,setCurrency:v.setCurrency,stripe:v.stripe}),[v.current,v.currency,v.available,v.currencies,v.isStripe,v.isCrypto,v.isCredit,v.switching,v.setType,v.types,v.setCurrency,v.stripe]),[y,I]=p.useState(null),[N,$]=p.useState(null),[P,B]=p.useState(null),[H,K]=p.useState(null),[V,Q]=p.useState("loading"),te=p.useRef(null),U=p.useRef(!1),re=p.useRef(!0),Y=p.useMemo(()=>ei(x),[x]),W=q(async()=>{if(!h||!Y||v.isStripe||v.switching){Q(Y?"unavailable":"available"),v.isStripe&&(I(null),$(null),B(null),K(null));return}if(!U.current){U.current=!0;try{Q("loading");const L=await ti(h,v.currency?.id);if(!re.current)return;L.rate?(I(L.rate),$(L.provider),B(L.providerDisplay),K(L.fetchedAt),Q("available")):Q("unavailable")}catch{if(!re.current)return;Q("unavailable")}finally{U.current=!1}}});p.useEffect(()=>{if(re.current=!0,!Y||v.isStripe||v.switching||!h||b?.status==="complete"){v.isStripe&&(I(null),$(null),B(null),K(null)),v.switching||(b?.status==="complete"?Q("available"):Q(Y?"unavailable":"available"));return}W(),te.current=setInterval(W,Jr);const L=()=>{document.hidden||W()};return document.addEventListener("visibilitychange",L),()=>{re.current=!1,te.current&&clearInterval(te.current),document.removeEventListener("visibilitychange",L)}},[Y,v.isStripe,v.switching,h,v.currency?.id,b?.status]);const oe=p.useMemo(()=>({rate:y,provider:N,providerDisplay:P,fetchedAt:H,status:V,hasDynamicPricing:Y,refresh:W}),[y,N,P,H,V,Y,W]),J=Wr(c,v.currency?.id||null,v.current?.id||null),ne=Zr(c,h,v.currency?.id||null,v.isStripe,v.isCredit,k,J.values,J.validate,o,a);return t.jsx(er.Provider,{value:F,children:t.jsx(tr.Provider,{value:E,children:t.jsx(nr.Provider,{value:oe,children:t.jsx(rr.Provider,{value:J,children:t.jsx(ir.Provider,{value:ne,children:n})})})})})}function at(e,n=6,r=!0,i=!0){if(!e||e==="0")return"0";const s=Number(e);if(!Number.isFinite(s))return"0";let o;if(i?o=s.toLocaleString("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}):o=s.toFixed(n),!r)return o;const[a,c]=o.split(".");if(!c)return a;const l=c.replace(/0+$/,"");return l?`${a}.${l}`:a}function ze(e,n,r=6,i=!0,s=!0){if(!n)return at(e,r,i,s);const o=Number(e);if(!Number.isFinite(o))return at(e,r,i,s);const a=Math.abs(o),c=a>0&&a<.01?r:2;return at(e,c,i,s)}const Ht=8;function Vt(e,n,r){if(!r&&r!=="0"||n==null)return null;try{const i=e instanceof z?e:new z(e||"0"),s=new z(10).pow(new z(n));if(s.isZero())return null;const o=new z(r.replace(".","")),a=r.includes(".")&&r.split(".")[1]?.length||0,c=new z(10).pow(new z(a)),l=new z(10).pow(new z(Ht)),u=i.mul(o).mul(l).div(s.mul(c));return Te(u.toString(),Ht)}catch{return null}}function Qt(e,n="en"){if(!e&&e!=="0")return null;const r=Number(e);return Number.isFinite(r)?new Intl.NumberFormat(n,{minimumFractionDigits:2,maximumFractionDigits:2}).format(r):null}function ui(e){if(!e&&e!=="0")return null;const n=String(e),r=Number(n);return Number.isFinite(r)?n:null}function di(e,n="USD",r=2){if(e==null)return null;const i=Number(e);if(!Number.isFinite(i))return null;const s=i.toFixed(r);return n==="USD"?`$${s}`:`${s} ${n}`}function pi(e){return Array.isArray(e.currency_options)?e.currency_options:[{currency_id:e.currency_id,unit_amount:e.unit_amount,custom_unit_amount:e.custom_unit_amount||null,tiers:null}]}function bt(e,n){const i=pi(e).find(s=>s.currency_id===n?.id);return i?i.custom_unit_amount?i.custom_unit_amount.preset||i.custom_unit_amount.presets[0]:i.unit_amount:e.currency_id===n?.id?e.custom_unit_amount?e.custom_unit_amount.preset||e.custom_unit_amount.presets[0]:e.unit_amount:"0"}function mi(e,n,{useUpsell:r=!0,exchangeRate:i=null}={}){if(!n)return{unitAmount:new z(0),totalAmount:new z(0),isDynamicQuote:!1};const s=r&&e.upsell_price||e.price,o=new z(e.quantity||0),a=e.quoted_amount,c=e.quote_currency_id,l=s?.pricing_type==="dynamic";if(l&&a&&c===n.id){const d=new z(a||"0");return{unitAmount:o.gt(new z(0))?d.add(o).sub(new z(1)).div(o):new z(0),totalAmount:d,isDynamicQuote:!0}}if(l&&i&&s?.base_amount){const d=Number(i);if(d>0&&Number.isFinite(d)){const m=Number(s.base_amount);if(m>0&&Number.isFinite(m)){const b=m/d,h=Xe(b.toFixed(n.decimal||8),n.decimal||8);return{unitAmount:h,totalAmount:h.mul(o),isDynamicQuote:!1}}}}if(!i&&s?.base_amount!=null){const d=Number(s.base_amount);if(d>=0&&Number.isFinite(d)){const m=n.decimal||2,b=Xe(d.toFixed(m),m);return{unitAmount:b,totalAmount:b.mul(o),isDynamicQuote:!1}}}const f=new z(bt(s,n));return{unitAmount:f,totalAmount:f.mul(o),isDynamicQuote:!1}}function _t(e,n,r=!1,i=!0,{exchangeRate:s=null}={}){let o=new z(0);const a=e.filter(c=>(i&&c.upsell_price||c.price)!=null).reduce((c,l)=>{const u=l.quote_currency_id;let f;l.custom_amount&&u&&u===n.id?f=new z(l.custom_amount):{totalAmount:f}=mi(l,n,{useUpsell:i,exchangeRate:s});const d=i&&l.upsell_price||l.price;return d?.type==="recurring"&&(o=o.add(f),r||d.recurring?.usage_type==="metered")?c:c.add(f)},new z(0)).toString();return{subtotal:a,total:a,renew:ze(o.toString(),!!s),discount:"0",shipping:"0",tax:"0"}}function fi(e,n,r=0){const i={licensed:new z(0),metered:new z(0)};return e.map(o=>o.upsell_price||o.price).filter(o=>o?.type==="recurring"&&o?.recurring).length>0?+r?Xe(r,n.decimal).toString():(e.forEach(o=>{const a=o.upsell_price||o.price,c=bt(a,n),l=new z(c).mul(new z(o.quantity));a?.type==="recurring"&&a?.recurring&&(a.recurring.usage_type==="licensed"&&(i.licensed=i.licensed.add(l)),a.recurring.usage_type==="metered"&&(i.metered=i.metered.add(l)))}),i.licensed.add(i.metered).toString()):"0"}function _n(e,n,r,i,s,o,a){const c=r?.discounts||[];if(c.length===0)return new z(0);const l=c[0].coupon_details||{};if(a&&l.duration==="once")return new z(0);const u=e.filter(m=>!(m.discountable===!1||(m.upsell_price||m.price)?.recurring?.usage_type==="metered")),f=_t(u,n,o,!0,{exchangeRate:i?s:null}),d=new z(f.total);if(d.lte(new z(0)))return new z(0);if(l.percent_off&&l.percent_off>0)return d.mul(new z(l.percent_off)).div(new z(100));if(l.amount_off&&l.amount_off!=="0"){const m=l.currency_options?.[n.id]?.amount_off||l.amount_off;if(m&&m!=="0"){const b=new z(m);return b.lt(d)?b:d}}return new z(0)}function xi(e,n,r,i,s,o){if(!n||e.length===0)return{subtotal:"0",paymentAmount:"0",total:"0",discount:null,tax:null,staking:null,usdEquivalent:null};const a=r?.subscription_data,l=Number(a?.trial_period_days||0)>0,u=_t(e,n,l,!0,{exchangeRate:s?i:null}),f=new z(u.total),d=_n(e,n,r,s,i,l,!1),m=d.gt(new z(0))?ze(Te(d.toString(),n.decimal),s):null,b=r?.total_details?.amount_tax,h=new z(b||"0"),x=r?.total_details,k=b&&b!=="0"?{amount:Te(b,n.decimal),rate:x?.tax_rate||0,inclusive:x?.tax_inclusive||!1}:null,F=a?.no_stake||!1,v=Math.max(Number(a?.billing_threshold_amount||0),Number(a?.min_stake_amount||0)),E=o==="arcblock"&&n.type!=="credit"&&!F?fi(e,n,v):"0",y=new z(E),I=f.add(y);let N=I.sub(d);h.gt(new z(0))&&!k?.inclusive&&(N=N.add(h)),N.isNeg()&&(N=new z(0));const $=ze(Te(N,n.decimal),s),P=I,B=ze(Te(P,n.decimal),s);let H=null,K=null;if(s&&i&&n){const Q=Vt(N.toString(),n.decimal,i);Q&&(H=Qt(Q)||null);const te=Vt(P.toString(),n.decimal,i);te&&(K=Qt(te)||null)}const V=y.gt(new z(0))?`${ze(Te(y.toString(),n.decimal),s)} ${n.symbol}`:null;return{subtotal:`${B} ${n.symbol}`,paymentAmount:`${$} ${n.symbol}`,total:`${$} ${n.symbol}`,discount:m?`${m} ${n.symbol}`:null,tax:k,staking:V,usdEquivalent:H?`$${H}`:null,subtotalUsdEquivalent:K?`$${K}`:null}}function Sn(e,n,r){if(!e.length||!n)return{locked:!1,lockedAt:null,expiresAt:null,expired:!1,baseCurrency:null,slippagePercent:null};const i=r?.checkoutSession;let s=null,o=null,a=null;e.forEach(b=>{const h=b.upsell_price||b.price;!s&&h?.base_currency&&(s=h.base_currency);const x=b.expires_at;x&&(o=o===null?x:Math.min(o,x));const k=b.slippage_percent;a===null&&Number.isFinite(Number(k))&&(a=Number(k))});const c=r?.paymentIntent?.created_at?new Date(r.paymentIntent.created_at).getTime():null,l=i?.quote_locked_at,u=c||l||null,f=!!u,d=Date.now(),m=o?d>o:!1;return{locked:f,lockedAt:u,expiresAt:o,expired:m,baseCurrency:s,slippagePercent:a}}function hi(e,n,r,i,s,o){const a=e?.subscription_data;let c=Number(a?.trial_period_days||0);if(c>0&&n){const d=(a?.trial_currency||"").split(",").map(m=>m.trim()).filter(Boolean);d.length>0&&!d.includes(n)&&(c=0)}const l=c>0;let u=null,f=null;if(l&&i&&r.length>0){const d=_t(r,i,!1,!0,{exchangeRate:s?o:null});let m=new z(d.total);const b=_n(r,i,e,s,o,!1,!0);b.gt(new z(0))&&(m=m.sub(b),m.isNeg()&&(m=new z(0))),u=`${ze(Te(m,i.decimal),s)} ${i.symbol}`;const h=r.find(x=>{const k=x.upsell_price||x.price;return k?.type==="recurring"&&k?.recurring});h&&(f=(h.upsell_price||h.price)?.recurring?.interval||null)}return{active:l,days:c,afterTrialPrice:u,afterTrialInterval:f}}async function gi(e,n,r,i,s,o,a){const{data:c}=await ee.put(X.CROSS_SELL(e),{to:n});let l=c;if(c.discounts?.length){const u=await De(r,e,i);u&&(l=u)}o&&a?a({...o,checkoutSession:l,quotes:void 0}):await s(!0)}async function yi(e,n,r,i,s,o){const{data:a}=await ee.delete(X.CROSS_SELL(e));let c=a;if(a.discounts?.length){const l=await De(n,e,r);l&&(c=l)}s&&o?o({...s,checkoutSession:c,quotes:void 0}):await i(!0)}const ct=new Map;function bi(e){const n=ct.get(e);if(n)return n;const r=(async()=>{try{const{data:i}=await ee.get(`${X.CROSS_SELL(e)}?skipError=true`);if(i&&!i.error)return i}catch{}return null})();return ct.set(e,r),r.finally(()=>ct.delete(e)),r}function _i(e){if(!e.length)return null;const n=e[0],r=n.upsell_price||n.price,i=r?.recurring;if(!i)return null;const s=i.interval,o=r?.upsell,a=o?.upsells_to,c=[];if(a?.recurring?.interval&&a.recurring.interval!==s&&c.push({interval:a.recurring.interval,priceId:o?.upsells_to_id||"",amount:a.unit_amount||"0",savings:null}),n.upsell_price_id&&n.price?.recurring){const l=n.price.recurring.interval;l&&l!==s&&c.push({interval:l,priceId:n.price_id,amount:n.price.unit_amount||"0",savings:null})}return c.length===0?null:{current:s,available:c,firstItem:n}}function wn(){const{product:e,subscription:n,pageInfo:r,vendorCount:i}=_e();return{product:e,subscription:n,pageInfo:r,vendorCount:i}}function St(){const{items:e,session:n,effectiveSessionId:r,isDonation:i,refresh:s,sessionData:o,setSessionData:a}=_e(),{currency:c}=Ie(),l=c?.id||null,u=p.useRef(!1);p.useEffect(()=>{if(!(u.current||!r||!e.length||!l||n?.status==="complete"))try{const P=new URLSearchParams(window.location.search);for(const B of e){const H=P.get(`qty_${B.price_id}`)||P.get(`qty_${B.price?.id}`)||P.get("qty");if(H){const K=Math.max(1,parseInt(H,10));if(Number.isFinite(K)&&K!==B.quantity){u.current=!0,Bt(r,B.price_id,K,l,n,s,o,a);break}}}}catch{}},[r,e,l]);const f=q(async(P,B)=>{if(n?.status!=="complete")try{await Bt(r,P,B,l,n,s,o,a)}catch(H){console.error("Failed to update quantity:",je(H))}}),d=q(async(P,B)=>{n?.status!=="complete"&&await yn(r,P,B,n,l,s,o,a)}),m=q(async P=>{n?.status!=="complete"&&await bn(r,P,n,l,s,o,a)}),b=p.useMemo(()=>ci(e),[e]),[h,x]=p.useState(null),k=p.useMemo(()=>e.map(P=>P.price_id).join(","),[e]),F=p.useMemo(()=>e.some(P=>P.cross_sell),[e]);p.useEffect(()=>{if(!r||!n||n.status==="complete")return;if(b){x(null);return}if(F)return;let P=!1;return bi(r).then(B=>{P||x(B)}),()=>{P=!0}},[r,n?.id,b,k,F]);const v=b||h,C=p.useMemo(()=>e.some(P=>P.cross_sell_required),[e]),E=q(async()=>{if(n?.status!=="complete"&&v)try{await gi(r,v.id,n,l,s,o,a)}catch(P){console.error("Failed to add cross-sell:",je(P))}}),y=q(async()=>{if(n?.status!=="complete")try{await yi(r,n,l,s,o,a)}catch(P){console.error("Failed to remove cross-sell:",je(P))}}),I=q(async(P,B)=>{if(n?.status!=="complete"&&i)try{await ai(r,P,B,n,l,s,o,a)}catch(H){console.error("Failed to change amount:",je(H))}}),N=p.useMemo(()=>e.map(P=>({...P,adjustable_quantity:P.adjustable_quantity})),[e]),$=p.useMemo(()=>e.every(P=>{const{price:B}=P;if(!B)return!0;const H=Number(P.quantity)||0,K=B.quantity_available||0,V=B.quantity_sold||0,Q=B.quantity_limit_per_checkout||0;return!(K>0&&V+H>K||Q>0&&Q<H)}),[e]);return{items:N,inventoryOk:$,updateQuantity:f,upsell:d,downsell:m,crossSellItem:v,crossSellRequired:C,addCrossSell:E,removeCrossSell:y,isDonation:i,setDonationAmount:I}}function Si(){const{items:e,session:n,effectiveSessionId:r,refresh:i,sessionData:s,setSessionData:o}=_e(),{currency:a}=Ie(),c=a?.id||null,[l,u]=p.useState(!1),[f,d]=p.useState(null),m=q(async(h,x)=>{try{await yn(r,h,x,n,c,i,s,o)}catch(k){console.error("Failed to upsell:",je(k))}}),b=q(async h=>{try{await bn(r,h,n,c,i,s,o)}catch(x){console.error("Failed to downsell:",je(x))}});return p.useMemo(()=>{const h=_i(e);return h?{current:f||h.current,available:h.available,switching:l,switch:async x=>{const k=h.available.find(F=>F.interval===x);if(!(!k||l)){d(x),u(!0);try{!h.firstItem.upsell_price_id&&k.priceId?await m(h.firstItem.price_id,k.priceId):h.firstItem.upsell_price_id&&await b(h.firstItem.upsell_price_id)}finally{u(!1),d(null)}}}}:null},[e,r,l,f])}function wi(){const{session:e,effectiveSessionId:n,refresh:r}=_e(),{currency:i}=Ie(),[s,o]=p.useState(null);p.useEffect(()=>{if(!e||s)return;const f=ni(e);f&&o(f)},[e?.id]);const a=q(async f=>{if(e?.status==="complete")return{success:!1,error:"Session already completed"};const d=await ri(n,f,i?.id);return d.success&&(o(f),await r(!0)),d}),c=q(async()=>{if(e?.status!=="complete")try{await ii(n),o(null),await r(!0)}catch{}}),l=(e?.discounts||[]).length>0,u=oi(e);return{applied:l,code:s,active:u,inactiveReason:u?null:"Promotions not allowed",apply:a,remove:c}}function wt(){const{rate:e,provider:n,providerDisplay:r,fetchedAt:i,status:s,hasDynamicPricing:o,refresh:a}=yt();return{value:ui(e),display:e?di(e):null,provider:n,providerDisplay:r,fetchedAt:i,status:s,hasDynamicPricing:o,refresh:a}}function vn(){const{items:e,sessionData:n,effectiveSessionId:r,refresh:i}=_e(),{hasDynamicPricing:s}=yt(),o=p.useMemo(()=>Sn(e,s,n),[e,s,n]),a=q(async c=>{try{const l=await Xr(r,c);(l?.checkoutSession||l?.quotes)&&await i(!0)}catch(l){console.error("Failed to update slippage:",je(l))}});return{percent:o.slippagePercent??.5,set:a}}function vt(){const{isLoading:e,error:n,errorCode:r,session:i,isDonation:s}=_e(),o=!e&&!n&&i?.status==="open",a=i?.status==="complete",c=!!i?.livemode;return{isLoading:e,error:n,errorCode:r,canSubmit:o,isCompleted:a,isDonation:s,livemode:c}}function kn(){const{items:e,session:n,sessionData:r,refresh:i}=_e(),{currency:s}=Ie(),{rate:o,hasDynamicPricing:a}=yt(),{current:c}=Ie(),l=p.useMemo(()=>xi(e,s,n,o,a,c?.type||null),[e,s,o,a,n,c?.type]),u=p.useMemo(()=>Sn(e,a,r),[e,a,r]);p.useEffect(()=>{!u.expired||!u.expiresAt||n?.status==="complete"||i(!0)},[u.expired]);const f=hi(n,s?.id,e,s,a,o);return{...l,hasDynamicPricing:a,quote:{locked:u.locked,lockedAt:u.lockedAt,expiresAt:u.expiresAt,expired:u.expired,baseCurrency:u.baseCurrency},trial:f}}function vi(){return Ie()}function jn(){return sr()}function et(){return or()}const ki={overflowY:"auto","&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},Gt={"@keyframes mobileFadeIn":{from:{opacity:0},to:{opacity:1}},animation:{xs:"mobileFadeIn 0.4s ease both",md:"none"}},Kt={"@keyframes fadeIn":{from:{opacity:0,transform:"translateY(12px)"},to:{opacity:1,transform:"translateY(0)"}},animation:{xs:"none",md:"fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s both"}},ji=typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent),Yt=ji?{"@keyframes panelFadeIn":{from:{opacity:0,transform:"translateX(24px)"},to:{opacity:1,transform:"none"}},animation:{xs:"none",md:"panelFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both"}}:{"@keyframes slideInRight":{from:{transform:"translateX(100%)"},to:{transform:"translateX(0)"}},animation:{xs:"none",md:"slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards"}};function Ci({left:e,right:n,mode:r="inline"}){const i=r==="standalone",{isMobile:s}=Ze(),o=We(),a=o.palette.mode==="dark",c=e===null,l={};if(s&&!c&&(l["& .cko-v2-submit-btn"]={position:"fixed",bottom:0,left:0,right:0,zIndex:999,bgcolor:a?"rgba(30,30,30,0.82)":"background.paper",backdropFilter:a?"blur(12px)":"none",p:1.5,borderTop:"1px solid",borderColor:"divider",boxShadow:a?"0 -4px 20px rgba(0,0,0,0.4)":"0 -2px 10px rgba(0,0,0,0.08)"}),!i)return t.jsxs(_,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},width:"100%",minHeight:{md:640},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",borderLeft:"4px solid",borderLeftColor:"primary.main",bgcolor:d=>d.palette.mode==="dark"?"background.default":"#f8faff",...Gt},children:[!c&&t.jsx(_,{sx:{flex:1,minWidth:0,bgcolor:d=>d.palette.mode==="dark"?"background.default":"#f8faff",p:{xs:3,md:5},pt:{xs:3,md:4},display:"flex",flexDirection:"column",...Kt},children:e}),t.jsx(_,{sx:{width:c?"100%":{xs:"100%",md:480},flexShrink:0,bgcolor:"background.paper",p:{xs:3,md:4},pt:{xs:3,md:4},display:"flex",flexDirection:"column",overflow:{md:"hidden"},...c?{}:Yt},children:n})]});const u=a?o.palette.background.default:o.palette.grey[100],f=a?o.palette.background.default:"#f8faff";return t.jsxs(_,{sx:{width:"100%",height:{xs:"auto",md:"100vh"},minHeight:{xs:"100vh"},overflow:{md:"hidden"},display:"flex",flexDirection:{xs:"column",md:"row"},position:"relative",background:s?u:`linear-gradient(160deg, ${ce(o.palette.primary.main,.03)} 0%, ${ce(o.palette.primary.main,.07)} 50%, ${ce(o.palette.primary.main,.04)} 100%)`,bgcolor:f,...Gt},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:d=>d.filter(b=>["locale-selector","theme-mode-toggle","session-user"].includes(b.key))}),!c&&t.jsx(_,{sx:{flex:{xs:"none",md:"0 0 50%"},width:{xs:"100%"},height:{xs:"auto",md:"100vh"},display:"flex",justifyContent:{md:"center"},...s?{bgcolor:"background.paper",mt:9}:{},...ki},children:t.jsx(_,{sx:{width:"100%",maxWidth:{md:640},p:{xs:3,md:5},pt:{xs:3,md:10},display:"flex",flexDirection:"column",flex:1,...Kt},children:e})}),t.jsx(_,{sx:{flex:c?"none":{xs:"none",md:"0 0 50%"},width:c?"100%":{xs:"100%"},height:c?"100vh":{xs:"auto",md:"100vh"},bgcolor:"background.paper",boxShadow:c?"none":{md:"-4px 0 16px rgba(0,0,0,0.04)"},position:"relative",display:"flex",flexDirection:"column",...c?{}:Yt,...s&&!c?{pb:"180px",mt:2}:{},overflowY:{xs:"auto",md:"hidden"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",...l},children:t.jsx(_,{sx:{width:"100%",maxWidth:{md:600},mx:"auto",p:{xs:3,md:4},pt:c?{xs:10,md:"10vh"}:{xs:3,md:"10vh"},display:"flex",flexDirection:"column",flex:1,minHeight:0,justifyContent:c?"center":void 0},children:n})})]})}function Ii(e,n){if(!e)return"composite";const r=n.length===1,i=e.mode==="payment",s=["subscription","setup"].includes(e.mode||"");if(r&&i){const o=n[0];if(o.price?.product?.type==="credit"&&o.price?.metadata?.credit_config)return"credit-topup"}return r&&s&&!n.some(o=>o.cross_sell)?"subscription":"composite"}function Ei({item:e,currency:n,discounts:r,exchangeRate:i,onQuantityChange:s,onUpsell:o,onDownsell:a,trialActive:c,trialDays:l,t:u,recommended:f=!1,hideUpsell:d=!1,isRateLoading:m=!1,showFeatures:b=!0,children:h=void 0}){const x=e.upsell_price||e.price,k=x?.product,F=k?.name||"Item",v=k?.images?.[0]||"",C=k?.features||[],E=x?.recurring,y=e.quantity||1,I=E?.usage_type==="metered",N=I?` ${u("common.metered")}`:"",$=Ye(x,n,i),P=!!E,B=u(P?"payment.checkout.typeBadge.subscription":"payment.checkout.typeBadge.oneTime"),H=E?.interval?` / ${u(`common.${E.interval}`)}`:"",K=y>1&&$&&n?`${y} × ${$} ${n.symbol}`:I?N.trim():"",V=(()=>{const w=e.quote_currency_id;if(e.custom_amount&&w&&w===n?.id)return He(e.custom_amount,n);if(x?.pricing_type==="dynamic"&&i&&x.base_amount){const M=Number(i);if(M>0&&Number.isFinite(M)){const se=Number(x.base_amount);if(se>0&&Number.isFinite(se)){const ae=se*y/M,ue=Math.abs(ae),de=ue>0&&ue<.01?6:2;return ae.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:de}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"}}}if(!i&&x?.base_amount!=null){const M=Number(x.base_amount);if(M>=0&&Number.isFinite(M))return(M*y).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}if(x&&n){const M=bt(x,n);if(M&&M!=="0"){const se=BigInt(M)*BigInt(y);return He(se.toString(),n)}}return"0"})(),Q=r?.[0],te=Q?.promotion_code_details?.code||Q?.verification_data?.code||Q?.promotion_code||"",U=(()=>{if(!te||!Q)return null;const w=Q?.coupon_details;if(w?.percent_off>0){const M=parseFloat(String(V).replace(/,/g,""));if(!Number.isNaN(M)&&M>0){const se=M*w.percent_off/100,ae=Math.abs(se),ue=ae>0&&ae<.01?6:2;return`${se.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:ue}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""}`}}return e.discount_amounts?.length>0&&n?`${He(e.discount_amounts[0].amount,n)} ${n.symbol}`:null})(),re=e.adjustable_quantity?.enabled,Y=e.adjustable_quantity?.minimum||1,W=e.adjustable_quantity?.maximum,[oe,J]=p.useState(String(y)),[ne,L]=p.useState(!1),pe=We(),he=An(pe.breakpoints.down("md")),[le,T]=p.useState(!he);p.useEffect(()=>{ne||J(String(y))},[y,ne]);const fe=p.useRef(null),me=p.useCallback((w,M)=>{fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{s(w,M)},400)},[s]);p.useEffect(()=>()=>{fe.current&&clearTimeout(fe.current)},[]);const j=!!e.price?.upsell?.upsells_to,G=!!e.upsell_price,S=e.price?.upsell?.upsells_to;let R=0;if(j&&S){const w=parseFloat(e.price?.base_amount||e.price?.unit_amount||"0"),M=parseFloat(S?.base_amount||S?.unit_amount||"0"),se=e.price?.recurring?.interval,ae=S?.recurring?.interval;if(w>0&&M>0&&se&&ae){const ue={day:365,week:52,month:12,year:1},de=w*(ue[se]||1),Se=M*(ue[ae]||1);de>Se&&(R=Math.round((de-Se)/de*100))}}const O=S?.recurring?.interval,ie=(()=>{if(!S)return"";const w=O?u("common.slash",{interval:u(`common.${O}`)}):"";if(S.pricing_type==="dynamic"&&S.base_amount&&i){const se=Number(i);if(se>0&&Number.isFinite(se)){const ae=parseFloat(S.base_amount);if(ae>0&&Number.isFinite(ae)){const ue=ae/se,de=Math.abs(ue),Se=de>0&&de<.01?6:2;return`${ue.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:Se}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""} ${w}`}}}if(S.pricing_type==="dynamic"&&S.base_amount&&S.base_currency==="USD")return`$${parseFloat(S.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${w}`;const M=Ye(S,n,i);return M?`${M} ${n?.symbol||""} ${w}`:""})(),Z=e.price?.recurring?.interval,ge=(()=>{if(!e.price||!G)return"";const w=e.price,M=Z?u("common.slash",{interval:u(`common.${Z}`)}):"";if(w.pricing_type==="dynamic"&&w.base_amount&&i){const ae=Number(i);if(ae>0&&Number.isFinite(ae)){const ue=parseFloat(w.base_amount);if(ue>0&&Number.isFinite(ue)){const de=ue/ae,Se=Math.abs(de),Oe=Se>0&&Se<.01?6:2;return`${de.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:Oe}).replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")||"0"} ${n?.symbol||""} ${M}`}}}if(w.pricing_type==="dynamic"&&w.base_amount&&w.base_currency==="USD")return`$${parseFloat(w.base_amount).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})} ${M}`;const se=Ye(w,n,i);return se?`${se} ${n?.symbol||""} ${M}`:""})(),ke=(()=>{if(G){const M=Z?u(Ae[Z]||""):"";return u("payment.checkout.upsell.revert",{recurring:M})}const w=O?u(Ae[O]||""):"";return u("payment.checkout.upsell.save",{recurring:w})})();return t.jsxs(_,{sx:{position:"relative"},children:[f&&t.jsx(Ke,{label:"RECOMMENDED",size:"small",sx:{position:"absolute",top:0,right:40,transform:"translateY(-50%)",zIndex:1,height:22,fontSize:9,fontWeight:900,letterSpacing:"0.12em",bgcolor:"primary.main",color:w=>$e(w),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsxs(_,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"1px solid",borderColor:"divider",boxShadow:w=>w.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)",transition:"all 0.3s ease",...j&&!d?{borderRadius:{xs:"16px 16px 0 0",md:"24px 24px 0 0"}}:{},"&:hover":{borderColor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.12)":"rgba(45,124,243,0.15)"}},children:[t.jsxs(D,{direction:"row",spacing:{xs:1.5,md:2.5},sx:{alignItems:"center",width:"100%"},children:[v?t.jsx(Ce,{src:v,alt:F,variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},flexShrink:0}}):t.jsx(Ce,{variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},bgcolor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.06)":"#eff6ff",flexShrink:0},children:t.jsx(Jt,{sx:{fontSize:{xs:22,md:28},color:"primary.main",opacity:.45}})}),t.jsx(_,{sx:{flex:1,minWidth:0,overflow:"hidden"},children:t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",sx:{mb:.25},children:[t.jsxs(_,{sx:{minWidth:0},children:[t.jsx(g,{sx:{color:"text.primary",fontWeight:800,fontSize:{xs:15,md:18},lineHeight:1.3},children:F}),t.jsx(g,{component:"span",sx:{display:"inline-block",mt:.5,fontSize:10,fontWeight:700,letterSpacing:"0.08em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:w=>w.palette.mode==="dark"?`${w.palette.primary.main}1A`:`${w.palette.primary.main}0D`,px:.75,py:.4,borderRadius:"3px"},children:B}),K&&t.jsx(g,{sx:{color:"text.disabled",fontSize:13,fontWeight:500,mt:.25},children:K})]}),t.jsx(D,{alignItems:"flex-end",sx:{flexShrink:0,ml:1.5},children:c&&P?t.jsx(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:cn(u,l,E?.interval||"day")}):m?t.jsx(Ne,{variant:"text",width:100,height:28}):t.jsxs(t.Fragment,{children:[t.jsxs(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18},transition:"opacity 0.3s ease"},children:[V," ",n?.symbol,H]}),i&&x?.base_amount&&t.jsxs(g,{sx:{fontSize:12,color:"text.disabled",fontWeight:600,lineHeight:1},children:["≈ $",(Number(x.base_amount)*y).toFixed(2)]})]})})]})})]}),b&&C.length>0&&t.jsxs(_,{sx:{mt:{xs:2,md:2.5},pt:{xs:2,md:2.5},borderTop:"1px solid",borderColor:w=>w.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.100"},children:[t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>T(w=>!w),sx:{cursor:"pointer",userSelect:"none",mb:le?1.25:0},children:[t.jsx(g,{sx:{fontSize:14,fontWeight:700,color:"text.primary"},children:u("payment.checkout.planFeatures")}),t.jsx(Dn,{sx:{fontSize:20,color:"text.secondary",transition:"transform 0.2s ease",transform:le?"rotate(0deg)":"rotate(180deg)"}})]}),t.jsx(mt,{in:le,children:t.jsx(D,{spacing:1.25,children:C.map(w=>t.jsxs(D,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx(_,{sx:{width:20,height:20,borderRadius:"50%",bgcolor:M=>M.palette.mode==="dark"?"rgba(16,185,129,0.15)":"rgba(16,185,129,0.1)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(Mn,{sx:{fontSize:14,color:"success.main"}})}),t.jsx(g,{sx:{fontSize:14,fontWeight:500,color:"text.secondary"},children:w.name})]},w.name))})})]}),te&&U&&t.jsx(_,{sx:{mt:1.5},children:m?t.jsx(Ne,{variant:"rounded",width:160,height:22,sx:{borderRadius:"6px"}}):t.jsx(Ke,{icon:t.jsx(en,{sx:{color:"warning.main",fontSize:"small"}}),label:`${te} (-${U})`,size:"small",sx:{height:22,borderRadius:"6px","& .MuiChip-label":{fontSize:12}}})}),re&&t.jsxs(D,{direction:"row",spacing:1,alignItems:"center",sx:{mt:2},children:[t.jsx(g,{sx:{color:"text.secondary",minWidth:"fit-content",fontSize:13,fontWeight:500},children:u("common.quantity")}),t.jsx(Ve,{size:"small",onClick:()=>{const M=(parseInt(oe,10)||y)-1;M<Y||(J(String(M)),me(e.price_id,M))},disabled:(parseInt(oe,10)||y)<=Y,sx:{width:36,height:36,border:"1px solid",borderColor:"divider",borderRadius:"50%","&:hover":{bgcolor:"action.hover"}},children:t.jsx(zn,{sx:{fontSize:20}})}),t.jsx(tn,{value:oe,size:"small",type:"number",slotProps:{htmlInput:{style:{textAlign:"center",padding:"6px 4px",fontWeight:700,fontSize:16,MozAppearance:"textfield"},min:Y,max:W||void 0}},sx:{minWidth:64,"& input":{textAlign:"center"},"& .MuiOutlinedInput-root":{borderRadius:"12px"},"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":{WebkitAppearance:"none",margin:0},"& input[type=number]":{MozAppearance:"textfield"}},onFocus:()=>L(!0),onChange:w=>J(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),w.stopPropagation(),w.target.blur())},onBlur:()=>{L(!1);const w=parseInt(oe,10);!Number.isNaN(w)&&w>=Y&&(!W||w<=W)&&w!==y?s(e.price_id,w):J(String(y))}}),t.jsx(Ve,{size:"small",onClick:()=>{const M=(parseInt(oe,10)||y)+1;W&&M>W||(J(String(M)),me(e.price_id,M))},disabled:W?(parseInt(oe,10)||y)>=W:!1,sx:{width:36,height:36,border:"1px solid",borderColor:"divider",borderRadius:"50%","&:hover":{bgcolor:"action.hover"}},children:t.jsx(nn,{sx:{fontSize:20}})})]}),h]}),j&&!d&&t.jsxs(_,{sx:{px:{xs:2,md:3},py:1.5,bgcolor:"background.paper",border:"1px solid",borderTop:0,borderColor:"divider",borderRadius:{xs:"0 0 16px 16px",md:"0 0 24px 24px"},boxShadow:w=>w.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)"},children:[t.jsx(_,{sx:{borderTop:"1px solid",borderColor:"divider",mb:1.5}}),t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,children:[t.jsx(Nn,{checked:G,onChange:async()=>{try{G?await a(e.upsell_price?.id||e.price.id):await o(e.price_id,S.id)}catch(w){Fe.error(w?.response?.data?.error||w?.message||"Failed")}},size:"small",sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#12b886"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"#12b886"}}}),t.jsx(g,{sx:{fontSize:13,color:"text.secondary",cursor:"pointer",fontWeight:600},onClick:async()=>{try{G?await a(e.upsell_price?.id||e.price.id):await o(e.price_id,S.id)}catch(w){Fe.error(w?.response?.data?.error||w?.message||"Failed")}},children:ke}),!G&&R>0&&t.jsx(Ke,{label:u("payment.checkout.upsell.off",{saving:R}),size:"small",sx:{height:22,fontSize:11,fontWeight:700,bgcolor:w=>w.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",border:"1px solid",borderColor:w=>w.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",borderRadius:"9999px","& .MuiChip-label":{px:1}}})]}),t.jsx(g,{sx:{fontSize:13,color:"text.primary",whiteSpace:"nowrap",fontWeight:700},children:G?ge:ie})]})]})]})}function Ri({billingInterval:e}){const{t:n}=be();if(!e?.available?.length||e.available.length<=1)return null;const r=e.available.reduce((i,s)=>Number(s.savings||0)>Number(i.savings||0)?s:i);return t.jsxs(D,{direction:"row",alignItems:"center",spacing:2,sx:{mb:3},children:[t.jsx(D,{direction:"row",alignItems:"center",sx:{bgcolor:"background.paper",borderRadius:"9999px",border:"1px solid",borderColor:"divider",p:"4px",display:"inline-flex",boxShadow:i=>i.palette.mode==="dark"?"0 1px 2px 0 rgba(0,0,0,0.3)":"0 1px 2px 0 rgba(0,0,0,0.05)"},children:e.available.map(i=>{const s=i.interval===e.current,o={bgcolor:c=>c.palette.mode==="dark"?"rgba(156,106,222,0.25)":"rgba(156,106,222,0.15)",color:"primary.main",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",boxShadow:c=>c.palette.mode==="dark"?"0 2px 8px rgba(156,106,222,0.2), inset 0 1px 0 rgba(255,255,255,0.06)":"0 2px 8px rgba(156,106,222,0.15), inset 0 1px 0 rgba(255,255,255,0.5)",border:"1px solid",borderColor:c=>c.palette.mode==="dark"?"rgba(156,106,222,0.3)":"rgba(156,106,222,0.2)"},a={color:"text.secondary",border:"1px solid transparent","&:hover":{color:"text.primary"}};return t.jsx(_,{onClick:()=>{i.interval!==e.current&&!e.switching&&e.switch(i.interval)},sx:{px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...s?o:a},children:e.switching&&s?t.jsx(ft,{size:14,color:"inherit",sx:{my:"1px"}}):t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:n(Ae[i.interval]||i.interval)})},i.interval)})}),r.savings&&Number(r.savings)>0&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:i=>i.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:i=>i.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",textTransform:"uppercase",letterSpacing:"0.05em"},children:[t.jsx(rn,{sx:{fontSize:14}}),t.jsxs(g,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit",color:"inherit",lineHeight:1},children:["SAVE ",r.savings,"%"]})]})]})}function Pi({crossSellItem:e,currency:n,exchangeRate:r,crossSellRequired:i,onAdd:s}){const{t:o}=be();if(!e)return null;const{product:a}=e,c=a?.images?.[0]||"",l=a?.name||o("payment.checkout.cross_sell.add"),{recurring:u}=e,f=u?.interval?Ae[u.interval]:null,d=a?.description||"",m=d&&d!==l?d:f?o(f):"";return t.jsxs(_,{sx:{position:"relative"},children:[i&&t.jsx(Ke,{label:xe(o,"payment.checkout.cross_sell.recommended","RECOMMENDED"),size:"small",sx:{position:"absolute",top:0,right:40,transform:"translateY(-50%)",zIndex:1,height:22,fontSize:9,fontWeight:900,letterSpacing:"0.12em",bgcolor:"primary.main",color:b=>$e(b),boxShadow:"0 4px 12px rgba(45,124,243,0.2)","& .MuiChip-label":{px:1.5}}}),t.jsx(_,{sx:{p:{xs:2,md:3},bgcolor:"background.paper",borderRadius:{xs:"16px",md:"24px"},border:"2px dashed",borderColor:b=>b.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(45,124,243,0.25)",boxShadow:b=>b.palette.mode==="dark"?"0 12px 40px -8px rgba(0,0,0,0.3)":"0 12px 40px -8px rgba(0,0,0,0.06)",transition:"all 0.3s ease",cursor:"pointer","&:hover":{borderColor:"primary.main",boxShadow:"0 12px 40px -8px rgba(0,0,0,0.1)"}},onClick:s,children:t.jsxs(D,{direction:"row",spacing:{xs:1.5,md:2.5},sx:{alignItems:"center",width:"100%"},children:[c?t.jsx(Ce,{src:c,variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},flexShrink:0}}):t.jsx(Ce,{variant:"rounded",sx:{width:{xs:44,md:64},height:{xs:44,md:64},borderRadius:{xs:"12px",md:"16px"},bgcolor:b=>b.palette.mode==="dark"?"rgba(255,255,255,0.06)":"#eff6ff",flexShrink:0},children:t.jsx(Jt,{sx:{fontSize:{xs:22,md:28},color:"primary.main",opacity:.45}})}),t.jsxs(_,{sx:{flex:1,minWidth:0},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"flex-start",sx:{mb:.25},children:[t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:15,md:18},color:"text.primary",lineHeight:1.3},children:l}),t.jsxs(D,{alignItems:"flex-end",sx:{flexShrink:0,ml:{xs:1,md:2}},children:[t.jsxs(g,{sx:{fontWeight:800,color:"text.primary",whiteSpace:"nowrap",fontSize:{xs:15,md:18}},children:[Ye(e,n,r)," ",n?.symbol]}),r&&e.base_amount&&t.jsxs(g,{sx:{fontSize:10,color:"text.disabled",fontWeight:700,lineHeight:1},children:["≈ $",Number(e.base_amount||0).toFixed(2)]})]})]}),m&&t.jsx(g,{sx:{fontSize:{xs:12,md:14},color:"text.secondary",fontWeight:500,lineHeight:1.4},noWrap:!0,children:m}),t.jsx(_,{sx:{pt:{xs:1.5,md:2}},children:t.jsx(Ee,{size:"small",variant:"outlined",startIcon:t.jsx(Fn,{sx:{fontSize:"14px !important"}}),sx:{textTransform:"none",fontSize:{xs:11,md:12},fontWeight:700,borderRadius:"8px",border:"1px solid",borderColor:"divider",color:"primary.main",bgcolor:"background.paper",boxShadow:1,px:1.5,py:.5,transition:"all 0.2s","&:hover":{bgcolor:"primary.main",color:b=>$e(b),borderColor:"primary.main"},"&:active":{transform:"scale(0.95)"}},onClick:b=>{b.stopPropagation(),s()},children:xe(o,"payment.checkout.cross_sell.addToOrder","Add to order")})})]})]})})]})}function Ti({trial:e,mode:n,items:r}){const{t:i}=be();if(e.active&&e.afterTrialPrice)return t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{borderTop:"1px solid",borderColor:"divider",pt:1,mt:1},children:[t.jsx(g,{sx:{color:"text.secondary",fontSize:14},children:i("common.nextCharge")}),t.jsxs(g,{sx:{fontSize:16,color:"text.secondary"},children:[e.afterTrialPrice,e.afterTrialInterval?` ${i(Ae[e.afterTrialInterval]||"")}`:""]})]});if(!e.active&&["subscription","setup"].includes(n)){const s=r.find(c=>(c.upsell_price||c.price)?.recurring?.usage_type==="metered");if(!s)return null;const o=(s.upsell_price||s.price)?.recurring?.interval;if(!o)return null;const a=i("common.per",{interval:i(`common.${o}`)});return t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{borderTop:"1px solid",borderColor:"divider",pt:1,mt:1},children:[t.jsx(g,{sx:{color:"text.secondary",fontSize:14,fontWeight:600},children:i("common.nextCharge")}),t.jsx(g,{sx:{fontSize:16,color:"text.secondary"},children:i("payment.checkout.metered",{recurring:a})})]})}return null}function Cn(){const{t:e}=be(),{session:n}=_e(),{currency:r,isStripe:i,switching:s}=Ie(),{livemode:o}=vt(),{product:a,pageInfo:c}=wn(),l=St(),u=Si(),f=kn(),d=wt(),m=vn(),{isMobile:b}=Ze(),h=n?.mode||"payment",x=n?.discounts||[],k=n?.app_name||n?.payment_link?.app_name||"",F=n?.app_logo||n?.payment_link?.app_logo||"",v=b||l.items.length>=4,[C,E]=p.useState(b?l.items.length<=1:l.items.length<4),y=l.crossSellItem&&!l.items.some(T=>T.price_id===l.crossSellItem?.id),I=l.items.filter(T=>!T.cross_sell),N=l.items.filter(T=>T.price?.upsell?.upsells_to),$=N.length===1?N[0]:null,P=$?$.price?.upsell?.upsells_to:null,B=I.length<=1,H=B&&!!$&&["subscription","setup"].includes(h),K=!!$?.upsell_price,[V,Q]=p.useState(!1),[te,U]=p.useState(null),re=te!==null?te:K,Y=H?$.price?.recurring?.interval:null,W=H?P?.recurring?.interval:null;let oe=0;if(H&&Y&&W){const T=parseFloat($.price?.base_amount||$.price?.unit_amount||"0"),fe=parseFloat(P?.base_amount||P?.unit_amount||"0"),me={day:365,week:52,month:12,year:1},j=T*(me[Y]||1),G=fe*(me[W]||1);j>G&&j>0&&(oe=Math.round((j-G)/j*100))}const J=p.useRef(d.status);p.useEffect(()=>{J.current!=="unavailable"&&d.status==="unavailable"&&!i&&Fe.error(e("payment.dynamicPricing.unavailable.message")),J.current=d.status},[d.status,i,e]);const ne=ar(e,n,a,l.items),L=l.items.length>1,pe={bgcolor:"primary.main",color:T=>$e(T),boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)"},he={color:"text.secondary","&:hover":{color:"text.primary"}},le=T=>({px:3.5,py:1,borderRadius:"9999px",cursor:"pointer",transition:"all 0.3s ease",userSelect:"none",...T?pe:he});return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",flex:1},children:[!b&&(k||F)&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:5},children:[F&&t.jsx(Ce,{src:F,alt:k,sx:{width:48,height:48,borderRadius:"16px",bgcolor:"background.paper",boxShadow:1,border:"1px solid",borderColor:"divider"}}),k&&t.jsx(g,{sx:{fontWeight:600,fontSize:15,color:"text.primary"},children:k})]}),!b&&t.jsx(_,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(_,{sx:{flexShrink:0},children:[t.jsxs(_,{sx:{mb:{xs:3,md:4}},children:[b&&(k||F)&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1},children:[F&&t.jsx(Ce,{src:F,alt:k,sx:{width:24,height:24,borderRadius:"6px"}}),k&&t.jsx(g,{sx:{fontWeight:600,fontSize:13,color:"text.secondary"},children:k})]}),t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.5},children:[t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:T=>T.palette.mode==="dark"?`${T.palette.primary.main}1A`:`${T.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:ne.badgeLabel}),f.trial.active&&f.trial.days>0&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:T=>T.palette.mode==="dark"?`${T.palette.primary.main}1A`:`${T.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:cn(e,f.trial.days,f.trial.afterTrialInterval||"day")}),!o&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:T=>T.palette.mode==="dark"?T.palette.grey[500]:T.palette.grey[400],bgcolor:T=>T.palette.mode==="dark"?"rgba(255,255,255,0.06)":T.palette.grey[100],px:1,py:.5,borderRadius:"4px"},children:e("common.livemode")})]}),t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:24,md:36},lineHeight:1.1,letterSpacing:"-0.03em",color:"text.primary",mb:.75},children:L?xe(e,"payment.checkout.orderSummary","Order Summary"):ne.title}),(L||ne.subtitle)&&t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:14,md:16},fontWeight:500,lineHeight:1.5},children:L?xe(e,"payment.checkout.orderSummarySubtitle","Items included in this purchase"):ne.subtitle}),H&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:2,sx:{mt:2.5},children:[t.jsxs(D,{direction:"row",alignItems:"center",sx:{bgcolor:"background.paper",borderRadius:"9999px",border:"1px solid",borderColor:"divider",p:"4px",display:"inline-flex",boxShadow:T=>T.palette.mode==="dark"?"0 1px 2px 0 rgba(0,0,0,0.3)":"0 1px 2px 0 rgba(0,0,0,0.05)"},children:[t.jsx(_,{onClick:async()=>{if(K&&!V){U(!1),Q(!0);try{await l.downsell($.upsell_price?.id||$.price_id)}catch(T){U(null),Fe.error(T?.response?.data?.error||T?.message||"Failed")}finally{Q(!1),U(null)}}},sx:le(!re),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[Y]||"")})}),t.jsx(_,{onClick:async()=>{if(!K&&!V){U(!0),Q(!0);try{await l.upsell($.price_id,P.id)}catch(T){U(null),Fe.error(T?.response?.data?.error||T?.message||"Failed")}finally{Q(!1),U(null)}}},sx:le(re),children:t.jsx(g,{component:"span",sx:{fontSize:14,fontWeight:700,color:"inherit",lineHeight:1},children:e(Ae[W]||"")})})]}),oe>0&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{px:1.5,py:.75,bgcolor:T=>T.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",color:"#12b886",fontSize:11,fontWeight:700,borderRadius:"9999px",border:"1px solid",borderColor:T=>T.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8",textTransform:"uppercase",letterSpacing:"0.05em"},children:[t.jsx(rn,{sx:{fontSize:14}}),t.jsxs(g,{component:"span",sx:{fontSize:"inherit",fontWeight:"inherit",color:"inherit",lineHeight:1},children:["SAVE ",oe,"%"]})]})]})]}),t.jsx(Ri,{billingInterval:u})]}),t.jsxs(_,{sx:{flexGrow:0,flexShrink:1,flexBasis:"auto",minHeight:{md:0},overflowY:{md:"auto"},"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[v&&t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"space-between",onClick:()=>E(!C),sx:{cursor:"pointer",mb:1.5},children:[t.jsx(g,{sx:{fontSize:14,fontWeight:600},children:e("payment.checkout.productListTotal",{total:l.items.length})}),t.jsx(sn,{sx:{transform:C?"rotate(180deg)":"rotate(0deg)",transition:"0.3s"}})]}),t.jsxs(mt,{in:C||!v,children:[t.jsx(D,{spacing:2,sx:{mb:2},children:l.items.map(T=>t.jsx(Ei,{item:T,currency:r,discounts:x,exchangeRate:d.value,onQuantityChange:l.updateQuantity,onUpsell:l.upsell,onDownsell:l.downsell,trialActive:f.trial.active,trialDays:f.trial.days,hideUpsell:H||!B,isRateLoading:s||d.hasDynamicPricing&&d.status==="loading",showFeatures:c?.showProductFeatures??!1,t:e,children:T.cross_sell&&t.jsx(Ee,{size:"small",color:"error",variant:"text",onClick:l.removeCrossSell,sx:{mt:1,ml:-.5,textTransform:"none",fontSize:12},children:e("payment.checkout.cross_sell.remove")})},T.id))}),y&&t.jsx(_,{sx:{mb:2},children:t.jsx(Pi,{crossSellItem:l.crossSellItem,currency:r,exchangeRate:d.value,crossSellRequired:l.crossSellRequired,onAdd:l.addCrossSell})})]})]}),t.jsx(_,{sx:{flexShrink:0},children:t.jsx(Ti,{trial:{active:f.trial.active,days:f.trial.days,afterTrialPrice:f.trial.afterTrialPrice,afterTrialInterval:f.trial.afterTrialInterval},mode:h,items:l.items})}),t.jsx(_,{sx:{flexGrow:1,flexShrink:1,flexBasis:0}}),t.jsxs(_,{sx:{flexShrink:0},children:[d.hasDynamicPricing&&d.status==="unavailable"&&!i&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:2},children:[t.jsx(g,{sx:{fontSize:13,color:"text.secondary",fontWeight:500},children:e("payment.dynamicPricing.unavailable.title")}),t.jsx(g,{component:"span",onClick:d.refresh,sx:{fontSize:13,color:"primary.main",fontWeight:600,cursor:"pointer","&:hover":{textDecoration:"underline"}},children:e("payment.dynamicPricing.unavailable.retry")})]}),t.jsx(ln,{hasDynamicPricing:d.hasDynamicPricing,rate:{value:d.value,display:d.display,provider:d.provider,providerDisplay:d.providerDisplay,fetchedAt:d.fetchedAt,status:d.status},slippage:{percent:m.percent,set:m.set},currencySymbol:r?.symbol||"",isSubscription:["subscription","setup"].includes(h)})]})]})}function Ai({livemode:e,label:n=void 0}){const{t:r}=be();return t.jsxs(D,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.5},children:[t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:"primary.main",bgcolor:i=>i.palette.mode==="dark"?`${i.palette.primary.main}1A`:`${i.palette.primary.main}0D`,px:1,py:.5,borderRadius:"4px"},children:n||xe(r,"payment.checkout.orderSummary","Order Summary")}),!e&&t.jsx(g,{component:"span",sx:{fontSize:10,fontWeight:700,letterSpacing:"0.1em",lineHeight:1,textTransform:"uppercase",color:i=>i.palette.mode==="dark"?i.palette.grey[500]:i.palette.grey[400],bgcolor:i=>i.palette.mode==="dark"?"rgba(255,255,255,0.06)":i.palette.grey[100],px:1,py:.5,borderRadius:"4px"},children:r("common.livemode")})]})}function Di(){const{t:e,locale:n}=be(),{session:r,sessionData:i}=_e(),{livemode:s}=vt(),{product:o}=wn(),{currency:a,isStripe:c}=Ie(),l=St(),u=wt(),f=vn(),{locked:d}=et(),m=l.items[0],b=m?m.upsell_price||m.price:null,h=b?.metadata?.credit_config,x=h?.credit_amount?Number(h.credit_amount):0,k=h?.currency_id,{session:F,getCurrency:v}=un(),C=k?v(k):null,E=F?.user?.did||i?.customer?.did,y=C?.decimal,I=C?.symbol||"Credits",N="Credits",$=b?.metadata?.meter_id,{data:P}=ut(async()=>{if(!$)return null;try{const{data:A}=await dt.get(`/api/meters/public/${$}`);return A}catch{return null}},{refreshDeps:[$]}),B=P?.name||o?.name||"Credits",H=h?.valid_duration_value,K=h?.valid_duration_unit||"days",V=h?.schedule,Q=V?.enabled&&V?.delivery_mode&&V.delivery_mode!=="invoice",te=H&&H>0,U=Math.max(x,1),re=m?.adjustable_quantity,Y=re?.enabled!==!1,W=Math.max(re?.minimum||1,1),oe=Math.min(b?.quantity_limit_per_checkout??1/0,b?.quantity_available??1/0),J=oe?Math.min(re?.maximum||1/0,oe):re?.maximum||1/0,{data:ne}=ut(async()=>{if(!h||!E||!k||y==null)return null;try{const{data:A}=await dt.get("/api/meter-events/pending-amount",{params:{customer_id:E,currency_id:k}});return A?.[k]}catch{return null}},{refreshDeps:[h,E,k,y]}),L=p.useMemo(()=>{if(!ne||!x||x<=0)return null;const A=new z(ne||"0");if(!A.gt(new z(0)))return null;const ye=Xe(x,y);return!ye||ye.isZero()?null:Math.ceil(A.mul(new z(100)).div(ye).toNumber()/100)},[ne,x,y]),pe=ne&&new z(ne||"0").gt(new z(0)),he=p.useMemo(()=>pe?Be(cr(ne,y),I,n):"",[pe,ne,y,I,n]),le=L?L*U:0,T=le?Be(Re(le),I,n):"",fe=p.useMemo(()=>{if(Q&&V){const A=V.interval_unit,ye=V.interval_value;let Le;V.amount_per_grant?Le=Number(V.amount_per_grant):Le=x;const qe=lr(Re(Le),N),Rt=ye===1?e(`common.${A}`):`${ye} ${e(`common.${A}s`)}`;return V.expire_with_next_grant?e("payment.checkout.credit.schedule.withRefresh",{amount:qe,interval:Rt}):e("payment.checkout.credit.schedule.periodic",{amount:qe,interval:Rt})}return""},[x,N,Q,V,e]),me=p.useMemo(()=>te?e("payment.checkout.creditTopup.validFor",{duration:H,unit:e(`common.${K}`)}):"",[te,H,K,e]),j=!!fe,G=m?.quantity||1,[S,R]=p.useState(G),[O,ie]=p.useState(G*U),[Z,ge]=p.useState(!1),[ke,w]=p.useState(""),M=p.useRef(null);p.useEffect(()=>{d||r?.status==="complete"||m?.quantity&&m.quantity!==S&&(R(m.quantity),ie(m.quantity*U))},[m?.quantity]);const se=p.useRef(!1);p.useEffect(()=>{if(!(d||r?.status==="complete")&&!se.current&&L&&L>S){se.current=!0;const A=Math.min(Math.max(L,W),J);R(A),ie(A*U),m&&l.updateQuantity(m.price_id,A)}},[L]);const ae=J*U,ue=W*U,de=p.useRef(null);p.useEffect(()=>()=>{de.current&&clearTimeout(de.current)},[]);const Se=p.useCallback(A=>{if(A<=0)return;const ye=Math.max(ue,Math.min(ae,A)),Le=Math.ceil(ye/U),qe=Math.max(W,Math.min(J,Le));R(qe),ie(ye),m&&(de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{l.updateQuantity(m.price_id,qe)},400))},[U,W,J,ue,ae,m,l]),Oe=p.useCallback(A=>{const ye=O+A*U;ye<U*W||Math.ceil(ye/U)>J||Se(ye)},[O,U,W,J,Se]),Ue=Math.max(W,Math.min(J,Math.ceil(O/U))),Qe=Ue*U,kt=Re(Qe,6,!0,!0),En=Re(O,6,!0,!0),jt=Y&&U>1,Rn=p.useMemo(()=>pe?Qe>=le?e("payment.checkout.creditTopup.pendingEnough",{pendingAmount:he,availableAmount:Be(Re(Qe-le),I,n)}):e("payment.checkout.creditTopup.pendingWarning",{pendingAmount:he,minCredits:T}):"",[pe,Qe,le,he,I,n,T,e]),Pn=p.useCallback(()=>{Y&&(w(String(O)),ge(!0),setTimeout(()=>M.current?.select(),0))},[Y,O]),tt=p.useCallback(()=>{ge(!1);const A=parseInt(ke.replace(/,/g,""),10);!Number.isFinite(A)||A<=0||Se(A)},[ke,Se]),Tn=p.useCallback(A=>{A.key==="Enter"?tt():A.key==="Escape"&&ge(!1)},[tt]),Ct={xs:48,md:72},It={fontSize:Ct,fontWeight:800,lineHeight:1,letterSpacing:"-0.03em"},Et={width:{xs:40,md:56},height:{xs:40,md:56},borderRadius:"50%",bgcolor:"background.paper",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.12)":"divider",color:"text.secondary",transition:"all 0.2s ease","&:hover":{borderColor:"primary.main",color:"primary.main",bgcolor:"background.paper"},"&.Mui-disabled":{borderColor:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",color:A=>A.palette.mode==="dark"?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)"}};return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsxs(_,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[t.jsx(Ai,{livemode:s,label:xe(e,"payment.checkout.typeBadge.topup","TOP-UP")}),t.jsx(g,{sx:{fontWeight:800,fontSize:{xs:28,md:48},lineHeight:1.1,letterSpacing:"-0.03em",color:"text.primary",mb:{xs:.5,md:1}},children:e("payment.checkout.creditTopup.title",{name:B})}),j&&t.jsx(_,{sx:{display:"flex",alignItems:"flex-start",gap:1,mb:{xs:1.5,md:2.5}},children:t.jsx(g,{sx:{fontSize:{xs:13,md:15},fontWeight:500,color:"text.secondary",lineHeight:1.5},children:fe})}),pe&&t.jsxs(D,{direction:"row",alignItems:"flex-start",spacing:1.5,sx:{mb:{xs:1.5,md:2.5},p:{xs:1.5,md:2},borderRadius:"12px",bgcolor:A=>A.palette.mode==="dark"?"rgba(255,152,0,0.12)":"rgba(255,152,0,0.08)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(255,152,0,0.25)":"rgba(255,152,0,0.2)"},children:[t.jsx($n,{sx:{fontSize:18,color:"warning.main",mt:.25,flexShrink:0}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:600,lineHeight:1.5,color:"text.primary"},children:Rn})]}),Y?t.jsxs(_,{sx:{display:"flex",flexDirection:"column",maxWidth:480},children:[t.jsx(g,{sx:{fontSize:{xs:14,md:17},fontWeight:700,color:"text.secondary",mt:{xs:3,md:5},mb:{xs:2,md:3}},children:e("payment.checkout.creditTopup.question",{symbol:N})}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:{xs:1.5,md:2}},children:[t.jsx(Ve,{onClick:()=>Oe(-1),disabled:Ue<=W,sx:Et,children:t.jsx(_,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1,mt:"-1px"},children:"−"})}),t.jsxs(_,{sx:{flex:1,minWidth:0,textAlign:"center",cursor:Y?"text":"default"},onClick:Pn,children:[t.jsx(_,{sx:{height:Ct,display:"flex",alignItems:"center",justifyContent:"center"},children:Z?t.jsx(xt,{inputRef:M,value:ke,onChange:A=>w(A.target.value.replace(/\D/g,"")),onBlur:tt,onKeyDown:Tn,autoFocus:!0,inputProps:{inputMode:"numeric",pattern:"[0-9]*"},sx:{width:"100%",bgcolor:"transparent","&.Mui-focused":{bgcolor:"transparent"},"& input":{textAlign:"center",...It,p:0,fontFamily:"inherit",bgcolor:"transparent","&:focus":{bgcolor:"transparent"}}}}):t.jsx(g,{sx:{...It,color:"text.primary",userSelect:"none"},children:En})}),t.jsx(_,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:.75,mt:1},children:t.jsx(g,{sx:{fontSize:{xs:12,md:14},fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:"0.05em"},children:N})})]}),t.jsx(Ve,{onClick:()=>Oe(1),disabled:Ue>=J,sx:Et,children:t.jsx(_,{component:"span",sx:{fontSize:{xs:22,md:28},fontWeight:300,lineHeight:1},children:"+"})})]}),U>1&&t.jsx(g,{sx:{fontSize:11,fontWeight:600,color:"grey.500",textTransform:"uppercase",letterSpacing:"0.08em",textAlign:"center",mt:{xs:1.5,md:2}},children:e("payment.checkout.creditTopup.increment",{step:Re(U,6,!0,!0),symbol:N})}),jt&&t.jsxs(_,{sx:{display:"flex",flexDirection:"column",mt:{xs:3,md:4},borderRadius:"20px",backdropFilter:"blur(12px)",bgcolor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.08)":"rgba(59,130,246,0.04)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.18)":"rgba(59,130,246,0.10)",boxShadow:A=>A.palette.mode==="dark"?"0 8px 32px rgba(59,130,246,0.06)":"0 8px 32px rgba(59,130,246,0.04)"},children:[t.jsxs(_,{sx:{p:{xs:2.5,md:3.5}},children:[t.jsxs(g,{sx:{fontSize:{xs:16,md:20},fontWeight:700,color:"primary.main",mb:.5},children:[e("payment.checkout.creditTopup.willReceive"),": ",t.jsx(_,{component:"span",sx:{fontWeight:800},children:Be(kt,N,n)})]}),t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,mb:.5},children:[t.jsx(Wn,{sx:{fontSize:16,color:"text.secondary"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:14},fontWeight:600,color:"text.secondary"},children:e("payment.checkout.creditTopup.packInfo",{packs:Ue,perPack:Re(U,6,!0,!0)})})]}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:e("payment.checkout.creditTopup.autoMatch")})]}),me&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,px:{xs:2.5,md:3.5},py:{xs:1.5,md:2},borderTop:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.15)":"rgba(59,130,246,0.08)"},children:[t.jsx(Pt,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:me})]})]}),!jt&&me&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,mt:{xs:2.5,md:3.5}},children:[t.jsx(On,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:me})]})]}):t.jsxs(_,{sx:{display:"flex",flexDirection:"column",mt:{xs:2,md:3},borderRadius:"20px",backdropFilter:"blur(12px)",bgcolor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.08)":"rgba(59,130,246,0.04)",border:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.18)":"rgba(59,130,246,0.10)",boxShadow:A=>A.palette.mode==="dark"?"0 8px 32px rgba(59,130,246,0.06)":"0 8px 32px rgba(59,130,246,0.04)"},children:[t.jsxs(_,{sx:{p:{xs:2.5,md:3.5}},children:[t.jsx(g,{sx:{fontSize:{xs:13,md:14},fontWeight:600,color:"text.secondary",mb:1},children:e("payment.checkout.creditTopup.willReceive")}),t.jsx(_,{sx:{display:"flex",alignItems:"center",gap:1.5},children:t.jsx(g,{sx:{fontSize:{xs:32,md:48},fontWeight:800,lineHeight:1,letterSpacing:"-0.03em",color:"primary.main"},children:Be(kt,N,n)})})]}),me&&t.jsxs(_,{sx:{display:"flex",alignItems:"center",gap:.75,px:{xs:2.5,md:3.5},py:{xs:1.5,md:2},borderTop:"1px solid",borderColor:A=>A.palette.mode==="dark"?"rgba(59,130,246,0.15)":"rgba(59,130,246,0.08)"},children:[t.jsx(Pt,{sx:{fontSize:14,color:"grey.500"}}),t.jsx(g,{sx:{fontSize:{xs:12,md:13},fontWeight:500,color:"grey.500"},children:me})]})]})]}),t.jsxs(_,{sx:{flexShrink:0},children:[u.hasDynamicPricing&&u.status==="unavailable"&&!c&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:2},children:[t.jsx(g,{sx:{fontSize:13,color:"text.secondary",fontWeight:500},children:e("payment.dynamicPricing.unavailable.title")}),t.jsx(g,{component:"span",onClick:u.refresh,sx:{fontSize:13,color:"primary.main",fontWeight:600,cursor:"pointer","&:hover":{textDecoration:"underline"}},children:e("payment.dynamicPricing.unavailable.retry")})]}),t.jsx(ln,{hasDynamicPricing:u.hasDynamicPricing,rate:{value:u.value,display:u.display,provider:u.provider,providerDisplay:u.providerDisplay,fetchedAt:u.fetchedAt,status:u.status},slippage:{percent:f.percent,set:f.set},currencySymbol:a?.symbol||"",isSubscription:["subscription","setup"].includes(r?.mode||"payment")})]})]})}const Mi=Cn;function zi(){const{session:e,items:n}=_e();switch(Ii(e,n)){case"subscription":return t.jsx(Mi,{});case"credit-topup":return t.jsx(Di,{});default:return t.jsx(Cn,{})}}function Ni({value:e,country:n,onChange:r,onCountryChange:i,label:s,error:o=void 0,onBlur:a=void 0}){const c=p.useRef(!1),l=p.useCallback(x=>{if(!c.current)try{c.current=!0,x()}finally{requestAnimationFrame(()=>{c.current=!1})}},[]),{phone:u,handlePhoneValueChange:f,inputRef:d,country:m,setCountry:b}=ur({defaultCountry:dr(n)?n:"us",value:e||"",countries:mr,onChange:x=>{l(()=>{r(x.phone),i(x.country)})}});Jn(()=>{pr().catch(x=>{console.error("Failed to preload phone validator:",x)})}),p.useEffect(()=>{!n||n===m||l(()=>{b(n)})},[n,m,b,l]);const h=p.useCallback(x=>{l(()=>{b(x),i(x)})},[b,l,i]);return t.jsxs(_,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:s}),t.jsx(xt,{fullWidth:!0,value:u,onChange:f,onBlur:a,type:"tel",inputRef:d,startAdornment:t.jsx(ht,{position:"start",sx:{mr:.25,ml:-.5},children:t.jsx(dn,{value:m,onChange:h,sx:{".MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{py:0,pr:"20px !important"}},showDialCode:!0})}),sx:{bgcolor:x=>x.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50",borderRadius:"8px",px:1.5,py:.75,fontSize:14,"& .MuiInputBase-input":{p:0}}}),o&&t.jsx(g,{sx:{fontSize:12,color:"error.main",mt:.25},children:o})]})}const Fi=e=>({customer_name:e("payment.checkout.customer.name"),customer_email:e("payment.checkout.customer.email"),customer_phone:e("payment.checkout.customer.phone"),"billing_address.country":e("payment.checkout.billing.country"),"billing_address.state":e("payment.checkout.billing.state"),"billing_address.city":e("payment.checkout.billing.city"),"billing_address.line1":e("payment.checkout.billing.line1"),"billing_address.line2":e("payment.checkout.billing.line2"),"billing_address.postal_code":e("payment.checkout.billing.postal_code")});function $i({form:e,isLoggedIn:n}){const{t:r}=be(),i=Fi(r),[s,o]=p.useState(!1),[a,c]=p.useState(!1),l=p.useRef(!1);p.useEffect(()=>{l.current||!e.prefetched&&!e.values.customer_name&&!e.values.customer_email||(l.current=!0,e.checkValid().then(f=>{o(!f),c(!0)}))},[e.prefetched]);const u=p.useCallback((f,d)=>e.onChange(f,d),[e.onChange]);return p.useEffect(()=>{a&&!s&&Object.keys(e.errors).length>0&&o(!0)},[e.errors]),!n||!a?null:s?t.jsxs(_,{sx:{mt:2},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.secondary"},children:r("payment.checkout.customerInfo")}),t.jsx(Ee,{size:"small",variant:"text",onClick:()=>o(!1),sx:{minWidth:0,fontSize:13,fontWeight:600,p:0},children:r("common.confirm")})]}),t.jsx(D,{spacing:0,sx:{p:2,backgroundColor:"background.paper",borderRadius:1,border:"1px solid",borderColor:"divider"},children:e.fields.filter(f=>f.name!=="billing_address.country").map(f=>{const{name:d}=f,m=i[d]||d,b=d.includes(".")?d.split(".").reduce((k,F)=>k?.[F],e.values):e.values[d],h=d==="billing_address.postal_code";return d==="customer_phone"?t.jsx(Ni,{value:b||"",country:e.values.billing_address?.country||"",onChange:k=>u("customer_phone",k),onCountryChange:k=>u("billing_address.country",k),onBlur:()=>e.validateField(d),label:m,error:e.errors[d]},d):t.jsxs(_,{sx:{mb:1.5},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.primary",mb:.5},children:m}),t.jsx(xt,{fullWidth:!0,value:b||"",onChange:k=>u(d,k.target.value),onBlur:()=>e.validateField(d),startAdornment:h?t.jsx(ht,{position:"start",sx:{mr:.5,ml:-.5},children:t.jsx(dn,{value:e.values.billing_address?.country||"",onChange:k=>u("billing_address.country",k),sx:{".MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{py:0,pr:"20px !important"}}})}):void 0,sx:{bgcolor:k=>k.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50",borderRadius:"8px",px:1.5,py:.75,fontSize:14,"& .MuiInputBase-input":{p:0}}}),e.errors[d]&&t.jsx(g,{sx:{fontSize:12,color:"error.main",mt:.25},children:e.errors[d]})]},d)})})]}):t.jsxs(_,{sx:{mt:2},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.secondary"},children:r("payment.checkout.customerInfo")}),t.jsx(Ee,{size:"small",variant:"text",onClick:()=>o(!0),sx:{minWidth:0,fontSize:13,fontWeight:600,p:0},children:r("common.edit")})]}),t.jsxs(D,{spacing:.5,sx:{p:2,backgroundColor:"background.paper",borderRadius:1,border:"1px solid",borderColor:"divider"},children:[e.values.customer_name&&t.jsx(g,{variant:"body2",sx:{color:"text.primary",fontWeight:600,fontSize:"0.9375rem"},children:e.values.customer_name}),e.values.customer_email&&t.jsx(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:e.values.customer_email}),e.fields.some(f=>f.name==="customer_phone")&&e.values.customer_phone&&t.jsx(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:e.values.customer_phone}),(e.values.billing_address?.country||e.values.billing_address?.state||e.values.billing_address?.postal_code)&&t.jsxs(D,{direction:"row",alignItems:"center",spacing:.75,children:[e.values.billing_address?.country&&t.jsx(_,{component:"span",sx:{fontSize:14,lineHeight:1},children:fr(e.values.billing_address.country)}),t.jsxs(g,{variant:"body2",sx:{color:"text.secondary",fontSize:"0.8125rem"},children:[e.values.billing_address?.state||"",e.values.billing_address?.postal_code?` [ ${r("payment.checkout.billing.postal_code")}: ${e.values.billing_address.postal_code} ]`:""]})]})]})]})}function Wi({mode:e,subscription:n,staking:r,appName:i}){const{t:s}=be();return!["subscription","setup"].includes(e)||!n?null:t.jsx(g,{sx:{mt:2.5,color:"text.secondary",fontSize:"0.7875rem",lineHeight:"0.9625rem"},children:n.confirmMessage||(n.showStake&&r?s("payment.checkout.confirm.withStake",{payee:i||"New Payment Kit"}):s("payment.checkout.confirm.withoutStake",{payee:i||"New Payment Kit"}))})}function Oi({status:e,context:n,onReset:r}){const{t:i}=be(),s=p.useRef(e);return p.useEffect(()=>{if(e!==s.current&&(s.current=e,e==="failed"&&n?.type==="error")){if(n.code==="CUSTOMER_LIMITED"||n.code==="STOP_ACCEPTING_ORDERS")return;Fe.error(n.message||"Payment failed"),r()}},[e,n,i,r]),null}function Xt({promotion:e,discounts:n,discountAmount:r,currency:i=null,initialShowInput:s=!1,isAmountLoading:o=!1}){const{t:a,locale:c}=be(),[l,u]=p.useState(!1),[f,d]=p.useState(""),[m,b]=p.useState(!1),[h,x]=p.useState(""),k=s||l,F=async()=>{if(!f.trim())return;b(!0),x("");const C=await e.apply(f.trim());C.success?(d(""),u(!1)):x(C.error||"Invalid code"),b(!1)},v=C=>{C.key==="Enter"&&!m&&f.trim()&&F()};return n?.length>0?t.jsx(_,{children:n.map((C,E)=>{const y=C.promotion_code_details?.code||C.verification_data?.code||C.promotion_code||"",I=C.coupon_details||{},N=I&&i?xr(I,i,c):"";return t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[t.jsxs(D,{direction:"row",alignItems:"center",spacing:.5,sx:{bgcolor:$=>$.palette.mode==="dark"?"rgba(18,184,134,0.1)":"#ebfef5",px:1.5,py:.5,borderRadius:"8px",border:"1px solid",borderColor:$=>$.palette.mode==="dark"?"rgba(18,184,134,0.2)":"#d3f9e8"},children:[t.jsx(en,{sx:{color:"#12b886",fontSize:14}}),t.jsx(g,{sx:{fontWeight:700,fontSize:13,color:"#12b886"},children:y}),N&&t.jsxs(g,{sx:{fontSize:12,color:"#12b886",fontWeight:500,opacity:.8},children:["· ",N]}),t.jsx(Ve,{size:"small",onClick:e.remove,sx:{width:18,height:18,ml:.25},children:t.jsx(on,{sx:{fontSize:12,color:"#12b886"}})})]}),o?t.jsx(Ne,{variant:"text",width:80,height:22}):t.jsxs(g,{sx:{color:"text.primary",fontWeight:600,fontSize:14},children:["-",r||"0"]})]},C.promotion_code||C.coupon||E)})}):e.active?t.jsx(_,{sx:{minHeight:36},children:k?t.jsxs(_,{onBlur:C=>{s||!C.currentTarget.contains(C.relatedTarget)&&!f.trim()&&u(!1)},children:[t.jsx(tn,{fullWidth:!0,size:"small",value:f,onChange:C=>d(C.target.value),onKeyPress:v,placeholder:a("payment.checkout.promotion.placeholder"),disabled:m,autoFocus:!0,slotProps:{input:{endAdornment:t.jsx(ht,{position:"end",children:t.jsx(Ee,{size:"small",onClick:F,disabled:!f.trim()||m,variant:"text",sx:{color:"primary.main",fontSize:13,textTransform:"none",minWidth:"auto",fontWeight:600},children:m?t.jsx(ft,{size:16}):a("payment.checkout.promotion.apply")})})}},sx:{"& .MuiOutlinedInput-root":{pr:1,borderRadius:"8px",height:36},"& .MuiOutlinedInput-input":{py:"6px",fontSize:13}}}),h&&t.jsx(Un,{severity:"error",sx:{mt:.5,py:0,fontSize:12,borderRadius:"6px"},children:h})]}):t.jsx(Ee,{onClick:()=>u(!0),startIcon:t.jsx(nn,{sx:{fontSize:18}}),variant:"text",sx:{fontWeight:600,fontSize:13,textTransform:"none",justifyContent:"flex-start",p:0,height:36,color:"primary.main","&:hover":{backgroundColor:"transparent",textDecoration:"underline"}},children:a("payment.checkout.promotion.add_code")})}):null}function Ui(){const{t:e,locale:n}=be(),{session:r,sessionData:i,subscription:s,refresh:o}=_e(),{isDonation:a}=vt(),c=vi(),l=jn(),u=et(),f=kn(),{session:d,connect:m,prefix:b}=un(),{inventoryOk:h}=St(),x=wi(),k=wt(),{isMobile:F}=Ze(),v=c.switching||k.hasDynamicPricing&&k.status==="loading",{currency:C,types:E,isStripe:y,isCrypto:I}=c,N=r?.mode||"payment",$=r?.discounts||[],P=!!d?.user,B=e(a?"payment.checkout.donate":`payment.checkout.${N}`),H=P?B:e("payment.checkout.connect",{action:B}),[K,V]=p.useState(!1),[Q,te]=p.useState(!1),[U,re]=p.useState(!1);p.useEffect(()=>{u.status==="failed"&&u.context?.code==="CUSTOMER_LIMITED"&&V(!0)},[u.status,u.context]);const Y=u.status==="idle"&&r?.status==="open"&&h,W=["submitting","waiting_did"].includes(u.status),oe=p.useCallback(()=>{if(Y){if(u.lock(),P||a){u.execute();return}d?.login?.(()=>{Promise.all([o(!0),l.refetchCustomer()]).then(()=>u.execute()).catch(j=>{console.error("Post-login refresh failed:",j)})})}},[Y,P,a,d,o,l,u]);p.useEffect(()=>{d?.user&&!u.status.startsWith("submitting")&&l.refetchCustomer()},[d?.user]);const J=E.find(j=>j.type==="crypto"),ne=p.useMemo(()=>c.available.filter(j=>j.type!=="stripe"),[c.available]),L=p.useMemo(()=>ne.length?ne.map(j=>({id:j.id,name:j.name,logo:j.logo||"",currencies:j.payment_currencies||[]})):[],[ne]),pe=c.current?.id||"";p.useEffect(()=>{const j=G=>{if(G.key==="Enter"&&Y&&u.status==="idle"){if(G.target?.tagName?.toLowerCase()==="textarea")return;oe()}};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[Y,u.status,oe]);const he=p.useRef(!1),le=p.useRef(!1),T=p.useRef(u.status);p.useEffect(()=>{T.current=u.status},[u.status]),p.useEffect(()=>{if(u.status!=="waiting_did"){he.current=!1,le.current=!1;return}const j=u.context;if(j?.type!=="did_connect"||!m||he.current)return;he.current=!0;const G=`${b||window.location.origin}/api/did`.replace(/([^:])\/\//g,"$1/");m.open({locale:n,action:j.action,prefix:G,saveConnect:!1,extraParams:j.extraParams,onSuccess:async()=>{le.current=!0,m.close(),await u.didConnectComplete()},onClose:()=>{m.close(),T.current==="waiting_did"&&(le.current||u.reset())},onError:S=>{console.error("DID Connect error:",S),T.current==="waiting_did"&&u.reset()},messages:{title:e("payment.checkout.connectModal.title",{action:H}),scan:e("payment.checkout.connectModal.scan"),confirm:e("payment.checkout.connectModal.confirm")}})},[u.status,u.context,m,n,e,H]);const fe=E.find(j=>j.active)?.type||"crypto",me=E.length>1;return t.jsxs(_,{sx:{display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[t.jsxs(_,{sx:{flex:1,display:"flex",flexDirection:"column",overflowY:"auto",minHeight:0,"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none"},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:700,letterSpacing:"0.02em",color:"text.primary",mb:2.5},children:e("payment.checkout.paymentDetails")}),me&&t.jsx(Ln,{value:fe,exclusive:!0,onChange:(j,G)=>G&&c.setType(G),fullWidth:!0,size:"small",sx:{mb:2.5,bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.100",borderRadius:"10px",p:.5,"& .MuiToggleButton-root":{textTransform:"none",borderRadius:"8px !important",py:.75,border:"none",fontSize:14,fontWeight:500,gap:.75,color:"text.secondary"},"& .Mui-selected":{bgcolor:"background.paper !important",color:"text.primary",fontWeight:600,boxShadow:j=>j.palette.mode==="dark"?"0 1px 3px rgba(0,0,0,0.3)":"0 1px 3px rgba(0,0,0,0.08)","&:hover":{bgcolor:"background.paper !important"}}},children:E.map(j=>t.jsxs(qn,{value:j.type,children:[j.type==="stripe"?t.jsx(Bn,{sx:{fontSize:18}}):t.jsx(Hn,{sx:{fontSize:18}}),j.label||(j.type==="stripe"?"Card":"Crypto")]},j.type))}),I&&L.length>0&&t.jsxs(D,{direction:"row",spacing:1.5,sx:{mb:2.5},children:[L.length>1&&t.jsxs(_,{sx:{flex:1},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.network")}),t.jsx(nt,{value:pe,onChange:j=>{const G=L.find(S=>S.id===j.target.value);G?.currencies?.[0]&&c.setCurrency(G.currencies[0].id)},fullWidth:!0,size:"small",sx:{borderRadius:"8px",bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50","& .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:1},"& .MuiSelect-select":{display:"flex",alignItems:"center",gap:1,py:1}},children:L.map(j=>t.jsxs(rt,{value:j.id,sx:{gap:1},children:[j.logo&&t.jsx(Ce,{src:j.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14},children:j.name})]},j.id))})]}),t.jsxs(_,{sx:{flex:1},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.currency")}),t.jsx(nt,{value:C?.id||"",onChange:j=>c.setCurrency(j.target.value),fullWidth:!0,size:"small",sx:{borderRadius:"8px",bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50","& .MuiOutlinedInput-notchedOutline":{borderColor:"transparent"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"divider"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main",borderWidth:1},"& .MuiSelect-select":{display:"flex",alignItems:"center",gap:1,py:1}},children:(I&&L.length>1?L.find(j=>j.id===pe)?.currencies||[]:J?.currencies||[]).map(j=>t.jsxs(rt,{value:j.id,sx:{gap:1},children:[j.logo&&t.jsx(Ce,{src:j.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14},children:j.symbol}),t.jsx(g,{sx:{fontSize:12,color:"text.secondary",ml:.5},children:j.name})]},j.id))})]})]}),y&&C&&t.jsxs(_,{sx:{mb:2.5},children:[t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"text.secondary",mb:.5,letterSpacing:"0.02em"},children:e("common.currency")}),t.jsx(nt,{value:C.id||"usd",readOnly:!0,fullWidth:!0,size:"small",IconComponent:()=>null,sx:{borderRadius:"8px",bgcolor:j=>j.palette.mode==="dark"?"rgba(255,255,255,0.06)":"grey.50","& .MuiOutlinedInput-notchedOutline":{borderColor:"transparent !important"},"& .MuiSelect-select":{display:"flex",alignItems:"center",gap:1,py:1}},children:t.jsxs(rt,{value:C.id||"usd",sx:{gap:1},children:[C.logo&&t.jsx(Ce,{src:C.logo,sx:{width:20,height:20}}),t.jsx(g,{sx:{fontSize:14,fontWeight:600},children:C.symbol}),t.jsx(g,{sx:{fontSize:12,color:"text.secondary",ml:.5},children:C.name})]})})]}),t.jsx($i,{form:l,isLoggedIn:P})]}),t.jsxs(_,{className:"cko-v2-submit-btn",sx:{flexShrink:0},children:[F&&f.staking&&t.jsxs(t.Fragment,{children:[t.jsxs(_,{onClick:()=>te(!Q),sx:{display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",mb:1},children:[t.jsx(g,{sx:{fontSize:13,fontWeight:600,color:"text.secondary"},children:e("payment.checkout.orderSummary")}),t.jsx(sn,{sx:{fontSize:18,color:"text.secondary",transition:"0.2s",transform:Q?"rotate(180deg)":"rotate(0deg)"}})]}),t.jsxs(mt,{in:Q,children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsxs(D,{direction:"row",spacing:.5,alignItems:"center",children:[t.jsx(g,{sx:{fontSize:13,color:"text.secondary"},children:e("payment.checkout.staking.title")}),t.jsx(Tt,{sx:{fontSize:14,color:"text.disabled"}})]}),v?t.jsx(Ne,{variant:"text",width:60,height:18}):t.jsxs(g,{sx:{fontSize:13,fontWeight:600},children:["+",f.staking]})]}),t.jsx(lt,{sx:{mb:1}})]})]}),!F&&t.jsxs(t.Fragment,{children:[t.jsx(lt,{sx:{mb:2}}),f.staking&&t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mb:1},children:[t.jsxs(D,{direction:"row",spacing:.5,alignItems:"center",children:[t.jsx(g,{sx:{fontSize:14,color:"text.secondary"},children:e("payment.checkout.staking.title")}),t.jsx(Vn,{title:e("payment.checkout.staking.tooltip"),placement:"top",arrow:!0,slotProps:{popper:{sx:hr}},children:t.jsx(Tt,{sx:{fontSize:16,color:"text.disabled"}})})]}),v?t.jsx(Ne,{variant:"text",width:80,height:22}):t.jsxs(g,{sx:{fontSize:14,fontWeight:600},children:["+",f.staking]})]}),t.jsx(Xt,{promotion:{applied:x.applied,code:x.code,active:x.active,inactiveReason:x.inactiveReason,apply:x.apply,remove:x.remove},discounts:$,discountAmount:f.discount,currency:C,isAmountLoading:v})]}),(()=>{const G=(f.total||"0").split(/\s+/),S=G[0]||"0",R=G.slice(1).join(" ")||C?.symbol||"",O=S.indexOf("."),ie=O>=0?S.slice(0,O):S,Z=O>=0?S.slice(O):"";return t.jsxs(_,{sx:{mb:F?1.5:2.5},children:[t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"flex-end",children:[t.jsx(g,{sx:{fontWeight:700,fontSize:14,color:"text.secondary",pb:.5},children:e("common.totalDue")}),v?t.jsx(Ne,{variant:"text",width:140,height:44}):t.jsxs(_,{sx:{textAlign:"right"},children:[t.jsx(g,{component:"span",sx:{fontSize:{xs:28,md:36},fontWeight:800,color:"text.primary",lineHeight:1,transition:"opacity 0.3s ease"},children:ie}),Z&&t.jsx(g,{component:"span",sx:{fontSize:{xs:16,md:20},fontWeight:700,color:"text.secondary",lineHeight:1},children:Z}),t.jsx(g,{component:"span",sx:{fontSize:{xs:14,md:16},fontWeight:600,color:"text.secondary",ml:.75},children:R})]})]}),(f.usdEquivalent||F&&x.active)&&!v&&t.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:.25},children:[F&&!x.applied&&x.active?t.jsxs(_,{onClick:()=>re(!0),sx:{display:"flex",alignItems:"center",gap:.5,cursor:"pointer"},children:[t.jsx(At,{sx:{fontSize:14,color:"primary.main"}}),t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"primary.main"},children:xe(e,"payment.checkout.promotion.add","Add promo code")})]}):F&&x.applied?t.jsxs(D,{direction:"row",alignItems:"center",spacing:.5,children:[t.jsx(At,{sx:{fontSize:14,color:"success.main"}}),t.jsx(g,{sx:{fontSize:12,fontWeight:600,color:"success.main"},children:x.code}),f.discount&&t.jsxs(g,{sx:{fontSize:11,color:"text.secondary"},children:["(-",f.discount,")"]}),t.jsx(on,{onClick:x.remove,sx:{fontSize:14,color:"error.main",cursor:"pointer",ml:.25}})]}):t.jsx(_,{}),f.usdEquivalent&&t.jsxs(g,{sx:{fontSize:13,color:"text.secondary"},children:["≈ ",f.usdEquivalent]})]})]})})(),t.jsxs(Ee,{variant:"contained",size:"large",fullWidth:!0,disabled:!Y||u.status==="waiting_stripe",onClick:oe,startIcon:W?t.jsx(ft,{size:20,color:"inherit"}):null,sx:{py:1.5,fontSize:"1.1rem",fontWeight:600,textTransform:"none",borderRadius:"12px",color:j=>$e(j),position:"relative",overflow:"hidden","&:hover":{bgcolor:"primary.main"},"&:hover .arrow-icon":{transform:"translateX(4px)"},"&:hover .shine-layer":{transform:"translateX(100%)"}},children:[t.jsx(_,{component:"span",sx:{position:"relative",zIndex:1},children:W?`${e("payment.checkout.processing")}...`:H}),!W&&t.jsx(Qn,{className:"arrow-icon",sx:{ml:1,position:"relative",zIndex:1,transition:"transform 0.2s ease"}}),t.jsx(_,{className:"shine-layer",sx:{position:"absolute",inset:0,background:"linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent)",transform:"translateX(-100%)",transition:"transform 0.7s ease",pointerEvents:"none"}})]}),F&&t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"center",spacing:.75,sx:{mt:1.5,opacity:.55},children:[t.jsx(Dt,{sx:{fontSize:13,color:"text.secondary"}}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"payment.checkout.ssl","SSL Secure")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"·"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.terms","Terms")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"|"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.privacy","Privacy")})]})]}),F&&t.jsxs(Gn,{anchor:"bottom",open:U,onClose:()=>re(!1),PaperProps:{sx:{borderRadius:"16px 16px 0 0",p:3,pb:4,minHeight:"30vh"}},children:[t.jsx(_,{sx:{width:40,height:4,bgcolor:"divider",borderRadius:2,mx:"auto",mb:3}}),t.jsx(g,{sx:{fontWeight:700,fontSize:16,mb:2},children:xe(e,"payment.checkout.promotion.add","Add promo code")}),t.jsx(Xt,{initialShowInput:!0,promotion:{applied:x.applied,code:x.code,active:x.active,inactiveReason:x.inactiveReason,apply:async(...j)=>{const G=await x.apply(...j);return G.success&&re(!1),G},remove:x.remove},discounts:$,discountAmount:f.discount,currency:C})]}),t.jsxs(_,{sx:{flexShrink:0},children:[t.jsx(Wi,{mode:N,subscription:s,staking:f.staking,appName:gr(r?.line_items||[])}),!F&&t.jsxs(D,{direction:"row",alignItems:"center",justifyContent:"center",spacing:.75,sx:{mt:2.5,opacity:.55},children:[t.jsx(Dt,{sx:{fontSize:13,color:"text.secondary"}}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"payment.checkout.ssl","SSL Secure")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"·"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.terms","Terms")}),t.jsx(g,{sx:{fontSize:11,color:"text.disabled"},children:"|"}),t.jsx(g,{sx:{fontSize:11,color:"text.secondary"},children:xe(e,"common.privacy","Privacy")})]})]}),t.jsx(Oi,{status:u.status,context:u.context,onReset:u.reset}),K&&t.jsx(yr,{customerId:i?.customer?.id||r?.user?.did,onPaid:()=>{V(!1),u.retry()},alertMessage:e("payment.customer.pastDue.alert.customMessage"),detailLinkOptions:{enabled:!0,onClick:()=>{V(!1),window.open(an(pn(),`/customer/invoice/past-due?referer=${encodeURIComponent(window.location.href)}`),"_self")}},dialogProps:{open:K,onClose:()=>{V(!1),u.reset()},title:e("payment.customer.pastDue.alert.title")}})]})}function Li(e){try{const r=new URLSearchParams(window.location.search).get("redirect");if(r)return decodeURIComponent(r)}catch{}if(e?.success_url)return e.success_url;if(e?.payment_link?.after_completion?.redirect?.url)return e.payment_link.after_completion.redirect.url}function qi(){const{t:e}=be(),{session:n}=_e(),{currency:r,stripe:i}=Ie(),s=et(),o=jn(),a=n?.mode||"payment",c=s.context?.type==="stripe"?s.context:null,l=s.status==="waiting_stripe"&&c?.clientSecret;return t.jsxs(t.Fragment,{children:[l&&t.jsx(br,{clientSecret:c.clientSecret,intentType:c.intentType||"payment_intent",publicKey:i?.publishableKey||"",mode:a,customer:{name:o.values.customer_name,email:o.values.customer_email,phone:o.values.customer_phone,address:o.values.billing_address},returnUrl:Li(n),onConfirm:s.stripeConfirm,onCancel:s.stripeCancel,onSkip:c.noPaymentRequired&&`${n?.metadata?.allow_skip_payment_method}`=="true"?s.stripeSkip:void 0}),s.status==="confirming_price"&&s.context?.type==="price_change"&&t.jsx(_r,{open:!0,changePercent:s.context.changePercent,onConfirm:s.confirm,onCancel:s.cancel,loading:!1}),s.status==="confirming_fast_pay"&&s.context?.type==="fast_pay"&&t.jsx(Mt,{onConfirm:s.confirm,onCancel:s.cancel,title:s.context.payType==="credit"?e("payment.checkout.fastPay.credit.title"):e("payment.checkout.fastPay.title"),message:s.context.payType==="credit"?t.jsx(g,{children:e("payment.checkout.fastPay.credit.meteringSubscriptionMessage",{available:`${He(s.context.amount||"0",r)} ${r?.symbol||""}`})}):t.jsxs(D,{children:[t.jsx(g,{children:e("payment.checkout.fastPay.autoPaymentReason")}),t.jsx(lt,{sx:{mt:1.5,mb:1.5}}),t.jsxs(D,{spacing:1,children:[t.jsxs(D,{sx:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[t.jsx(g,{sx:{color:"text.primary",whiteSpace:"nowrap"},children:e("payment.checkout.fastPay.payer")}),t.jsx(g,{sx:{color:"text.secondary",fontSize:14},children:s.context.payer?`${s.context.payer.slice(0,10)}...${s.context.payer.slice(-6)}`:""})]}),t.jsxs(D,{sx:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[t.jsx(g,{sx:{color:"text.primary"},children:e("payment.checkout.fastPay.amount")}),t.jsxs(g,{children:[He(s.context.amount||"0",r)," ",r?.symbol||""]})]})]})]}),loading:!1,color:"primary"}),s.context?.type==="service_suspended"&&t.jsx(Sr,{open:!0,onClose:s.cancel}),s.status==="credit_insufficient"&&s.context?.type==="credit_insufficient"&&t.jsx(Mt,{onConfirm:s.cancel,onCancel:s.cancel,title:e("payment.checkout.fastPay.credit.insufficientTitle"),message:t.jsx(g,{children:e("payment.checkout.fastPay.credit.insufficientMessage")}),confirm:e("common.confirm")})]})}function Bi(){return t.jsx(_,{sx:{display:"flex",gap:2,mt:4},children:[0,1,2].map(e=>t.jsx(_,{sx:{width:12,height:12,borderRadius:"50%",bgcolor:"primary.main",opacity:.4,animation:`pulse 1.4s ease-in-out ${e*.2}s infinite`,"@keyframes pulse":{"0%, 80%, 100%":{transform:"scale(0.6)",opacity:.3},"40%":{transform:"scale(1)",opacity:.7}}}},e))})}function Hi(){return t.jsxs(_,{sx:{position:"relative",width:{xs:160,md:200},height:{xs:160,md:200}},children:[t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:e=>`linear-gradient(45deg, ${ce(e.palette.primary.main,.1)}, ${ce(e.palette.primary.main,.03)})`,filter:"blur(1px)",animation:"spin 20s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:e=>`linear-gradient(135deg, ${ce(e.palette.primary.main,.07)}, ${ce(e.palette.primary.main,.01)})`,filter:"blur(1px)",transform:"scale(0.88)",opacity:.6,animation:"spinReverse 15s linear infinite","@keyframes spinReverse":{from:{transform:"scale(0.88) rotate(0deg)"},to:{transform:"scale(0.88) rotate(-360deg)"}}}})]})}function In({mode:e="inline"}){const n=e==="standalone",i=We().palette.primary.main,s={background:{xs:"none",md:`linear-gradient(160deg, ${ce(i,.03)} 0%, ${ce(i,.07)} 50%, ${ce(i,.04)} 100%)`},bgcolor:a=>a.palette.mode==="dark"?"background.default":"#f8faff"},o=t.jsxs(_,{sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1},children:[t.jsx(Hi,{}),t.jsx(Bi,{})]});return n?t.jsxs(_,{sx:{width:"100%",height:"100vh",minHeight:"100vh",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",...s},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:a=>a.filter(c=>["locale-selector","theme-mode-toggle","session-user"].includes(c.key))}),o]}):t.jsx(_,{sx:{display:"flex",width:"100%",minHeight:{xs:400,md:640},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",borderLeft:"4px solid",borderLeftColor:"primary.main",...s},children:o})}function Vi(){const e=We(),n=ce(e.palette.primary.main,.06);return t.jsxs(_,{sx:{position:"relative",width:{xs:200,md:260},height:{xs:200,md:260},mb:{xs:4,md:6}},children:[t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:r=>`linear-gradient(45deg, ${ce(r.palette.primary.main,.1)}, ${ce(r.palette.primary.main,.03)})`,filter:"blur(1px)",animation:"spin 20s linear infinite","@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",background:r=>`linear-gradient(135deg, ${ce(r.palette.primary.main,.07)}, ${ce(r.palette.primary.main,.01)})`,filter:"blur(1px)",transform:"scale(0.88)",opacity:.6,animation:"spinReverse 15s linear infinite","@keyframes spinReverse":{from:{transform:"scale(0.88) rotate(0deg)"},to:{transform:"scale(0.88) rotate(-360deg)"}}}}),t.jsx(_,{sx:{position:"absolute",inset:0,borderRadius:"38% 62% 63% 37% / 41% 44% 56% 59%",overflow:"hidden",animation:"spin 20s linear infinite"},children:t.jsxs("svg",{width:"100%",height:"100%",viewBox:"0 0 260 260",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{position:"absolute",inset:0},children:[[52,87,122,157,192].map(r=>t.jsx("line",{x1:"30",y1:r,x2:"230",y2:r,stroke:n,strokeWidth:"0.5"},`h${r}`)),[52,87,122,157,192].map(r=>t.jsx("line",{x1:r,y1:"30",x2:r,y2:"230",stroke:n,strokeWidth:"0.5"},`v${r}`)),t.jsx("line",{x1:"52",y1:"52",x2:"192",y2:"192",stroke:n,strokeWidth:"0.5"}),t.jsx("line",{x1:"192",y1:"52",x2:"52",y2:"192",stroke:n,strokeWidth:"0.5"}),t.jsx("circle",{cx:"130",cy:"130",r:"40",stroke:n,strokeWidth:"0.5"}),t.jsx("circle",{cx:"130",cy:"130",r:"75",stroke:n,strokeWidth:"0.5"}),[[122,87],[157,87],[87,122],[122,122],[157,122],[192,122],[87,157],[122,157],[157,157],[122,192],[157,192]].map(([r,i])=>t.jsx("circle",{cx:r,cy:i,r:"1.5",fill:n},`d${r}-${i}`))]})})]})}function Qi(e,n,r){return e==="SESSION_EXPIRED"?{title:r("payment.checkout.expired.title"),description:r("payment.checkout.expired.description"),color:"#f59e0b"}:e==="EMPTY_LINE_ITEMS"?{title:r("payment.checkout.emptyItems.title"),description:r("payment.checkout.emptyItems.description"),color:"#94a3b8"}:e==="STOP_ACCEPTING_ORDERS"?{title:r("payment.checkout.stopAcceptingOrders.title"),description:r("payment.checkout.stopAcceptingOrders.description"),color:"#f59e0b"}:{title:r("payment.checkout.error.title"),description:n,color:"#ef4444"}}function Zt({error:e,errorCode:n=void 0}){const{t:r}=be(),i=We(),{title:s,description:o}=Qi(n,e,r),a=i.palette.primary.main,c=typeof window<"u"?window.blocklet?.appUrl:"/";return t.jsxs(D,{alignItems:"center",justifyContent:"center",sx:{flex:1,textAlign:"center",px:3},children:[t.jsx(Vi,{}),t.jsx(g,{component:"h1",sx:{fontWeight:800,fontSize:{xs:36,md:52},lineHeight:1.05,letterSpacing:"-0.03em",color:"text.primary",mb:2},children:s}),t.jsx(g,{sx:{color:"text.secondary",fontSize:{xs:15,md:17},fontWeight:300,lineHeight:1.7,maxWidth:420,letterSpacing:"0.01em"},children:o}),c&&t.jsx(Ee,{href:c,variant:"contained",disableElevation:!0,startIcon:t.jsx(Kn,{sx:{fontSize:"20px !important"}}),sx:{mt:5,minWidth:240,height:56,px:6,borderRadius:"9999px",textTransform:"none",fontWeight:600,fontSize:16,letterSpacing:"0.02em",color:l=>$e(l),boxShadow:`0 8px 32px -4px ${ce(a,.3)}`,"&:hover":{boxShadow:`0 12px 40px -4px ${ce(a,.4)}`,transform:"translateY(-1px)"},transition:"all 0.2s ease"},children:r("common.back")})]})}function Gi({error:e,errorCode:n=void 0,mode:r="inline"}){const s=We().palette.primary.main,o=r==="standalone",a={bgcolor:c=>c.palette.mode==="dark"?"background.default":"#f8faff",backgroundImage:c=>c.palette.mode==="dark"?"none":`radial-gradient(at 0% 0%, ${ce(s,.06)} 0px, transparent 50%),
|
|
2
|
+
radial-gradient(at 100% 0%, ${ce(s,.04)} 0px, transparent 50%),
|
|
3
|
+
radial-gradient(at 100% 100%, ${ce(s,.06)} 0px, transparent 50%),
|
|
4
|
+
radial-gradient(at 0% 100%, rgba(203,213,225,0.3) 0px, transparent 50%)`};return o?t.jsxs(_,{sx:{width:"100%",height:"100vh",minHeight:"100vh",display:"flex",flexDirection:"column",position:"relative",overflow:"hidden",...a},children:[t.jsx(gt,{sx:{position:"absolute",top:20,left:0,right:0,zIndex:10,background:"transparent","& .header-container":{height:"auto"}},hideNavMenu:!0,brand:null,description:null,addons:c=>c.filter(l=>["locale-selector","theme-mode-toggle","session-user"].includes(l.key))}),t.jsx(Zt,{error:e,errorCode:n})]}):t.jsx(_,{sx:{display:"flex",width:"100%",minHeight:{xs:400,md:520},maxWidth:1120,mx:"auto",borderRadius:"16px",overflow:"hidden",boxShadow:1,border:1,borderColor:"divider",...a},children:t.jsx(_,{sx:{flex:1,p:{xs:4,md:6},display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:t.jsx(Zt,{error:e,errorCode:n})})})}const Ge={};function Ki(e,n){return Ge[e]||(Ge[e]=dt.post(`/api/checkout-sessions/start/${e}?${mn(n)}`).then(r=>r?.data).finally(()=>{setTimeout(()=>{delete Ge[e]},3e3)})),Ge[e]}function Yi({onPaid:e=void 0,onError:n=void 0,mode:r="inline"}){const{isLoading:i,error:s,errorCode:o,session:a}=_e(),c=et(),{isMobile:l}=Ze();if(p.useEffect(()=>{s&&n&&n(new Error(s))},[s,n]),p.useEffect(()=>{c.status==="completed"&&c.result&&e&&e(c.result)},[c.status,c.result,e]),i)return t.jsx(In,{mode:r});if(s)return t.jsx(Gi,{error:s,errorCode:o,mode:r});const u=c.status==="completed",f=u&&l;return t.jsxs(t.Fragment,{children:[t.jsx(Ci,{left:f?null:t.jsx(_,{sx:{flex:1,display:"flex",flexDirection:"column",...u?{opacity:.45,pointerEvents:"none",filter:"grayscale(0.3)",transition:"all 0.5s ease"}:{}},children:t.jsx(zi,{})}),right:u?t.jsx(wr,{submit:c,session:a}):t.jsx(Ui,{}),mode:r}),!u&&t.jsx(qi,{})]})}function Xi({id:e,onPaid:n,onError:r,theme:i="default",mode:s="inline",extraParams:o={}}){if(!e.startsWith("plink_")&&!e.startsWith("cs_"))throw new Error("Either a checkoutSession or a paymentLink id is required.");const a=e.startsWith("plink_"),[c,l]=p.useState(a?null:e);if(ut(async()=>{if(!a)return null;const f=await Ki(e,o),d=f?.checkoutSession?.id;return d&&(l(d),s==="standalone"&&window.history.replaceState(null,"",an(pn(),`/checkout/pay/${d}?${mn(o)}`))),f},{ready:a}),!c)return t.jsx(In,{mode:s});const u=t.jsx(li,{sessionId:c,children:t.jsx(Yi,{onPaid:n,onError:r,mode:s})});return i==="inherit"?u:i&&typeof i=="object"?t.jsx(zt,{theme:i,children:u}):t.jsx(zt,{children:u})}function ns({id:e}){const[n]=vr(),r=n.get("redirect"),i=s=>{if(s?.checkoutSession?.success_url){setTimeout(()=>{const o=new URL(s.checkoutSession.success_url,window.location.origin);o.searchParams.set("checkout_session_id",s.checkoutSession.id),window.location.replace(o.href)},1e3);return}if(s?.paymentLink&&s.paymentLink.after_completion?.type==="redirect"&&s.paymentLink.after_completion?.redirect?.url){setTimeout(()=>{const o=new URL(s.paymentLink?.after_completion?.redirect?.url,window.location.origin);o.searchParams.set("checkout_session_id",s.checkoutSession.id),window.location.replace(o.href)},1e3);return}r&&setTimeout(()=>{window.location.replace(r)},1e3)};return t.jsx(Xi,{mode:"standalone",id:e,onPaid:i})}export{ns as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,a3 as d,B as u,N as S,q as o,bf as
|
|
1
|
+
import{j as e,a3 as d,B as u,N as S,q as o,bf as N,O as C,I as P,c4 as K,c5 as V,bW as q,r as O,bU as U,c6 as H,c7 as Y}from"./vendor-mui-BXZut9Pz.js";import{V as _,F as L,Y as Z,a9 as D,Z as j,a7 as G}from"./vendor-blocklet-DcLR2Cyf.js";import{d as A,aM as R,f as I,T as J,a as E,v as z,Y as Q,j as B,a0 as X,e as ee,k as M}from"./index-BarN7DfU.js";import{L as $}from"./vendor-react-BPknnnEA.js";import{C as ne}from"./copyable-QrCyyiou.js";import{a as te,L as re}from"./usage-records-DAUQMJAW.js";const W={width:48,height:48};function ue({data:t,currency:s,mode:m="customer"}){const{t:a}=_(),{isMobile:c}=A(),r=m==="admin",i=[{label:a("admin.subscription.product"),name:"price_id",options:{customBodyRenderLite:(p,l)=>{const n=t[l];return e.jsxs(d,{sx:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:{xs:1,sm:2}},children:[e.jsx(u,{sx:{order:c?2:1},children:n.price.product.images.length>0?e.jsx(S,{src:n.price.product.images[0],alt:n.price.product.name,variant:"rounded",sx:W},n.price.product_id):e.jsx(S,{variant:"rounded",sx:W,children:n.price.product.name.slice(0,1)},n.price.product_id)}),e.jsx(u,{sx:{order:c?1:2},children:r?e.jsxs(e.Fragment,{children:[e.jsx(o,{sx:{color:"text.primary",fontWeight:600},children:e.jsx($,{to:`/admin/products/${n?.price.product_id}`,children:e.jsx(R,{text:n?.price.product.name,maxLength:c?20:50,useWidth:!0})})}),e.jsx(o,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:e.jsx($,{to:`/admin/products/${n?.price.id}`,children:I(n.price,s,n?.price.product.unit_label)})})]}):e.jsxs(u,{sx:c?{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:.5,flex:1}:{},children:[e.jsx(o,{sx:{color:"text.primary",fontWeight:600},children:e.jsx(R,{text:n?.price.product.name,maxLength:c?20:50,useWidth:!0})}),e.jsx(o,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:I(n.price,s,n?.price.product.unit_label)})]})})]})}}},{label:a("admin.subscription.itemId"),name:"id",options:{customBodyRenderLite:(p,l)=>{const n=t[l];return e.jsx(ne,{text:n.id})}}},s.type!=="credit"&&{label:a("common.quantity"),name:"quantity",options:{customBodyRenderLite:(p,l)=>{const n=t[l];return n.price.recurring?.usage_type==="metered"?e.jsx(te,{subscriptionId:n.subscription_id,id:n.id}):n.quantity}}},{label:a("common.total"),name:"id",align:"right",options:{sort:!1,customBodyRenderLite:(p,l)=>{const n=t[l];return n.price.recurring?.usage_type==="metered"?a("admin.subscription.usage.vary"):I(n.price,s,n?.price.product.unit_label,n?.quantity)}}},m==="admin"&&{label:a("common.actions"),name:"",align:"center",options:{sort:!1,customBodyRenderLite:(p,l)=>{const n=t[l];return e.jsx(re,{data:n})}}}].filter(Boolean);return e.jsx(ie,{children:e.jsx(J,{data:t,columns:i,loading:!1,footer:!1,toolbar:!1,components:{TableToolbar:()=>null,TableFooter:()=>null},mobileTDFlexDirection:"row",options:{count:t.length,page:0,rowsPerPage:100},emptyNodeText:a("customer.product.empty")})})}const ie=N(u)`
|
|
2
2
|
@media (max-width: ${({theme:t})=>t.breakpoints.values.md}px) {
|
|
3
3
|
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
4
4
|
align-items: center;
|
|
@@ -13,4 +13,4 @@ import{j as e,a3 as d,B as u,N as S,q as o,bf as F,O as C,I as P,c4 as K,c5 as V
|
|
|
13
13
|
padding-right: 20px;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
`;function me({vendorServices:t,subscriptionId:s,isOwner:m=!0,isCanceled:a}){const{t:c}=_();if(!t||t.length===0)return null;const r=window.blocklet.prefix||"/";return e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"h3",className:"section-header",sx:{mb:3},children:[c("admin.subscription.includedServices")," (",t.length,")"]}),e.jsx(u,{className:"section-body",children:e.jsx(d,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr",lg:"1fr 1fr 1fr"},gap:2},children:t.map((i,p)=>{const l=i.vendor_type==="launcher";return e.jsxs(u,{className:"vendor-service-item",sx:{p:2,display:"flex",alignItems:"center",border:"1px solid",borderColor:"divider",borderRadius:2,backgroundColor:"background.paper","&:hover":{backgroundColor:"action.hover"},transition:"background-color 0.2s ease"},children:[e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1},children:[e.jsx(u,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:a?"error.main":"success.main",flexShrink:0}}),e.jsx(o,{variant:"body1",sx:{fontWeight:600,fontSize:"1rem",color:"text.primary"},children:i.name||i.vendor_key})]}),l&&!a&&e.jsx(u,{children:e.jsxs(d,{direction:"row",spacing:.5,children:[e.jsx(C,{title:c("admin.subscription.serviceHome"),placement:"top",children:e.jsx(P,{size:"small",component:"a",href:L(r,"/api/vendors/open/",s,`?vendorId=${i.vendor_id}`),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main","&:hover":{backgroundColor:"primary.lighter"}},children:e.jsx(K,{fontSize:"small"})})}),m&&e.jsx(C,{title:c("admin.subscription.serviceDashboard"),placement:"top",children:e.jsx(P,{size:"small",component:"a",href:L(r,"/api/vendors/open/",s,`?vendorId=${i.vendor_id}&target=dashboard`),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main","&:hover":{backgroundColor:"primary.lighter"}},children:e.jsx(V,{fontSize:"small"})})})]})})]},i.vendor_key||p)})})})]})}function pe({discountStats:t=null}){const{t:s}=_(),{settings:m}=
|
|
16
|
+
`;function me({vendorServices:t,subscriptionId:s,isOwner:m=!0,isCanceled:a}){const{t:c}=_();if(!t||t.length===0)return null;const r=window.blocklet.prefix||"/";return e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"h3",className:"section-header",sx:{mb:3},children:[c("admin.subscription.includedServices")," (",t.length,")"]}),e.jsx(u,{className:"section-body",children:e.jsx(d,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr",lg:"1fr 1fr 1fr"},gap:2},children:t.map((i,p)=>{const l=i.vendor_type==="launcher";return e.jsxs(u,{className:"vendor-service-item",sx:{p:2,display:"flex",alignItems:"center",border:"1px solid",borderColor:"divider",borderRadius:2,backgroundColor:"background.paper","&:hover":{backgroundColor:"action.hover"},transition:"background-color 0.2s ease"},children:[e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1},children:[e.jsx(u,{sx:{width:8,height:8,borderRadius:"50%",bgcolor:a?"error.main":"success.main",flexShrink:0}}),e.jsx(o,{variant:"body1",sx:{fontWeight:600,fontSize:"1rem",color:"text.primary"},children:i.name||i.vendor_key})]}),l&&!a&&e.jsx(u,{children:e.jsxs(d,{direction:"row",spacing:.5,children:[e.jsx(C,{title:c("admin.subscription.serviceHome"),placement:"top",children:e.jsx(P,{size:"small",component:"a",href:L(r,"/api/vendors/open/",s,`?vendorId=${i.vendor_id}`),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main","&:hover":{backgroundColor:"primary.lighter"}},children:e.jsx(K,{fontSize:"small"})})}),m&&e.jsx(C,{title:c("admin.subscription.serviceDashboard"),placement:"top",children:e.jsx(P,{size:"small",component:"a",href:L(r,"/api/vendors/open/",s,`?vendorId=${i.vendor_id}&target=dashboard`),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main","&:hover":{backgroundColor:"primary.lighter"}},children:e.jsx(V,{fontSize:"small"})})})]})})]},i.vendor_key||p)})})})]})}function pe({discountStats:t=null}){const{t:s}=_(),{settings:m}=E(),{isMobile:a}=A();if(!t||t.total_discount_records===0)return null;const c=t.discount_records?.[0],r=c?.coupon;if(!r)return null;const i=r.name||s("admin.coupon.discount"),p=()=>{if(r.percent_off&&r.percent_off>0)return s("admin.coupon.couponTermsPercentage",{percent:r.percent_off});if(r.amount_off&&r.amount_off!=="0"){const x=Q(m.paymentMethods,r.currency_id)||m.baseCurrency;return s("admin.coupon.couponTermsFixedAmount",{amount:z(r.amount_off,x.decimal),symbol:x.symbol})}return s("admin.coupon.noDiscount")},l=()=>r.duration==="repeating"&&r.duration_in_months?s(`admin.coupon.couponTermsDuration.${r.duration}`,{months:r.duration_in_months}):s(`admin.coupon.couponTermsDuration.${r.duration}`),n=Object.entries(t.total_savings),h=n.length>0?n.map(([,x])=>`${z(x.amount,x.currency?.decimal||18)} ${x.currency?.symbol||""}`).join(", "):"--",b=()=>{if(r.duration!=="repeating")return"";if(c?.discount_start&&c?.discount_end){const x=B(c.discount_start*1e3),y=B(c.discount_end*1e3);return`${x} ~ ${y}`}return""};return e.jsx(u,{sx:{bgcolor:"grey.50",borderRadius:1.5,p:2.5,border:"1px solid",borderColor:"divider"},children:e.jsxs(d,{spacing:1,children:[e.jsxs(d,{direction:a?"column":"row",spacing:2,sx:{alignItems:a?"flex-start":"center"},children:[e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1},children:[e.jsx(q,{sx:{color:"primary.main",fontSize:20}}),e.jsx(o,{variant:"subtitle2",sx:{fontWeight:600,color:"text.primary"},children:i})]}),e.jsxs(u,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(o,{variant:"body2",sx:{fontWeight:500,color:"text.secondary"},children:p()}),l()&&e.jsxs(e.Fragment,{children:[e.jsx(o,{variant:"body2",sx:{color:"text.disabled"},children:"|"}),e.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:l()})]})]})]}),e.jsxs(d,{direction:a?"column":"row",spacing:2,sx:{alignItems:a?"flex-start":"center"},children:[e.jsx(u,{sx:{flex:1},children:e.jsxs(o,{variant:"body2",sx:{color:"text.secondary"},children:[s("admin.discount.totalSaved"),":"," ",e.jsx(o,{component:"span",sx:{color:"success.main",fontWeight:600,ml:.5},children:h})]})}),b()&&e.jsx(u,{children:e.jsxs(o,{variant:"body2",sx:{color:"text.primary"},children:[s("admin.coupon.discountPeriod"),": ",b()]})})]})]})})}function xe({subscriptionId:t,customer:s,paymentMethodDetails:m,editable:a=!1,onUpdate:c=()=>{},paymentMethodType:r}){const{t:i,locale:p}=_(),{connect:l}=E(),[n,h]=Z({editing:!1,submitting:!1,setupIntentId:null,clientSecret:null,publishableKey:null});O.useEffect(()=>{n.editing||h({clientSecret:null,publishableKey:null,setupIntentId:null})},[n.editing,h]);const b=async()=>{if(r==="stripe")try{h({submitting:!0});const{data:f}=await ee.post(`/api/subscriptions/${t}/update-stripe-payment-method`);h({editing:!0,clientSecret:f.client_secret,publishableKey:f.publishable_key,setupIntentId:f.setup_intent_id,submitting:!1})}catch(f){j.error(M(f)),h({submitting:!1})}else l.open({action:"change-payer",saveConnect:!1,locale:p,useSocket:!0,messages:{scan:"",title:i("admin.subscription.changePayer.connect.title"),success:i("admin.subscription.changePayer.connect.success"),error:i("admin.subscription.changePayer.connect.error"),confirm:""},extraParams:{subscriptionId:t},onSuccess:()=>{l.close(),j.success(i("admin.subscription.changePayer.connect.success")),c?.()},onClose:()=>{l.close()},onError:f=>{j.error(M(f))}})},x=()=>{setTimeout(()=>{j.success(i("admin.subscription.changePayer.connect.success")),h({editing:!1,submitting:!1}),c?.()},2e3)},y=()=>{h({editing:!1,clientSecret:null,publishableKey:null,setupIntentId:null})};if(n.editing&&n.clientSecret&&n.publishableKey)return e.jsx(u,{children:e.jsx(X,{clientSecret:n.clientSecret,intentType:"setup_intent",publicKey:n.publishableKey,customer:s,mode:"setup",onConfirm:x,onCancel:y,returnUrl:window.location.href})});if(!m)return a?e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:i("admin.subscription.noPaymentMethod",{defaultValue:"Not bound"})}),e.jsx(D,{variant:"text",size:"small",sx:{color:"text.link"},loading:n.submitting,onClick:b,children:i("admin.subscription.bindPaymentMethod",{defaultValue:"Bind now"})})]}):e.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:i("admin.subscription.noPaymentMethod",{defaultValue:"Not bound"})});const{card:v,link:w,us_bank_account:k,payer:T,type:g}=m,F=()=>g==="card"&&v?e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(U,{sx:{fontSize:16,color:"text.secondary"}}),e.jsxs(o,{variant:"body2",children:[v.brand.toUpperCase()," •••• ",v.last4]})]}):g==="link"&&w?e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(H,{sx:{fontSize:16,color:"text.secondary"}}),e.jsxs(o,{variant:"body2",children:[i("admin.subscription.changePayer.stripe.linkType")," (",w.email,")"]})]}):g==="us_bank_account"&&k?e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(Y,{sx:{fontSize:16,color:"text.secondary"}}),e.jsxs(o,{variant:"body2",children:[k.bank_name||i("admin.subscription.changePayer.stripe.bankAccount")," ••••"," ",k.last4]})]}):["arcblock","ethereum","base"].includes(g)&&T?e.jsx(G,{did:T,responsive:!1,compact:!0,copyable:!1}):e.jsx(o,{variant:"body2",sx:{color:"text.secondary"},children:g||"-"});return e.jsxs(d,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1},children:[F(),a&&e.jsx(D,{variant:"text",size:"small",sx:{color:"text.link"},loading:n.submitting,onClick:b,children:i("admin.subscription.changePayer.btn")})]})}export{pe as D,xe as P,ue as S,me as V};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,u,j as t}from"./vendor-mui-BXZut9Pz.js";import{
|
|
1
|
+
import{r as s,u,j as t}from"./vendor-mui-BXZut9Pz.js";import{bn as x,cz as g}from"./vendor-blocklet-DcLR2Cyf.js";import{I as l,C as w}from"./chrome-BPS46pXA.js";function $({ref:a=void 0,id:d,version:h=1}){const r=s.useRef(null),f=x(r),e=u(),[o,m]=s.useState(e.palette.mode),i=(f?.width||0)/1280,[n,{toggleFullscreen:p}]=g(r);s.useImperativeHandle(a,()=>({ref:r.current,fullscreen:n,toggleFullscreen:p})),s.useEffect(()=>{e.palette.mode!==o&&m(e.palette.mode)},[e.palette.mode,o]);const c=`${window.blocklet.prefix}checkout/pricing-table/${d}?preview=1&version=${h}&theme=${o}`;return t.jsx("div",{ref:r,children:n?t.jsx("div",{style:{width:"100%",height:"100%",background:e.palette.background.paper||"#fff"},children:t.jsx(l,{style:{width:"100%",height:"100vh",overflow:"hidden",border:"none"},src:c})}):t.jsx(w,{sx:{width:"100%",height:800*i},children:t.jsx(l,{style:{width:"1280px",height:"800px",transform:`scale(${i})`,transformOrigin:"top left",border:"none"},src:c})})})}export{$ as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as p,r as s,j as t}from"./vendor-mui-BXZut9Pz.js";import{
|
|
1
|
+
import{u as p,r as s,j as t}from"./vendor-mui-BXZut9Pz.js";import{bn as u,cz as x}from"./vendor-blocklet-DcLR2Cyf.js";import{I as c,C as w}from"./chrome-BPS46pXA.js";function k({ref:l=void 0,id:d,version:h=1}){const e=p(),r=s.useRef(null),i=(u(r)?.width||0)/1280,[o,f]=s.useState(e.palette.mode),[n,{toggleFullscreen:m}]=x(r);s.useImperativeHandle(l,()=>({ref:r.current,fullscreen:n,toggleFullscreen:m})),s.useEffect(()=>{e.palette.mode!==o&&f(e.palette.mode)},[e.palette.mode,o]);const a=`${window.blocklet.prefix}checkout/pay/${d}?preview=1&version=${h}&theme=${o}`;return t.jsx("div",{ref:r,children:n?t.jsx("div",{style:{width:"100%",height:"100%",background:e.palette.background.paper||"#fff"},children:t.jsx(c,{style:{width:"100%",height:"100vh",overflow:"hidden",border:"none"},src:a})}):t.jsx(w,{sx:{width:"100%",height:800*i},children:t.jsx(c,{style:{width:"1280px",height:"800px",transform:`scale(${i})`,transformOrigin:"top left",border:"none"},src:a})})})}export{k as P};
|