@arcblock/payment-service 1.29.9 → 1.29.10
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.js +51 -51
- package/dist/index.js +195 -43
- package/package.json +3 -3
- package/web/assets/{account-Clbqiiw3.js → account-DrsnH5wP.js} +1 -1
- package/web/assets/{action-DENqSeOa.js → action-C2c0yWuW.js} +1 -1
- package/web/assets/{actions-CDsj5j8l.js → actions--FNKSNIs.js} +1 -1
- package/web/assets/{actions-BJDN6Op2.js → actions-BEUwbsq1.js} +1 -1
- package/web/assets/{actions-CSpJGOX7.js → actions-C9AfME83.js} +1 -1
- package/web/assets/{actions-BD9BAp3M.js → actions-D2-s31n3.js} +1 -1
- package/web/assets/{actions-BSNy5bOd.js → actions-DXMceTgd.js} +1 -1
- package/web/assets/{actions-0iWP2mcx.js → actions-DeCPtfTK.js} +1 -1
- package/web/assets/{actions-DGQs8fFF.js → actions-DtNZGZWf.js} +1 -1
- package/web/assets/{actions-D3tJgrUn.js → actions-JHsqbHpB.js} +1 -1
- package/web/assets/{actions-CZL47E9r.js → actions-izdZ2Mn4.js} +1 -1
- package/web/assets/{add-price-BpnICuHO.js → add-price-TdXAR3NW.js} +1 -1
- package/web/assets/{admin-CD8ViZ7D.js → admin-BpFv3eF5.js} +1 -1
- package/web/assets/{assign-0vMUDW_C.js → assign-DKRfmN7W.js} +1 -1
- package/web/assets/{attempts-CKlxkJuE.js → attempts-BfbYfiJa.js} +1 -1
- package/web/assets/browser-DF2vfpBa.js +1 -0
- package/web/assets/{change-payment-gAlRmJpv.js → change-payment-j5UC8_h0.js} +1 -1
- package/web/assets/{change-plan-C47wfWH8.js → change-plan-CtXvsIDw.js} +1 -1
- package/web/assets/{click-boundary-CafubiPp.js → click-boundary-Bi28Y0Fq.js} +1 -1
- package/web/assets/{connect-BHHzrwLA.js → connect-CXek4LAE.js} +1 -1
- package/web/assets/{copyable-QrCyyiou.js → copyable-CprMHdhV.js} +1 -1
- package/web/assets/{create-ke4FrPx1.js → create-B-Ubepl_.js} +1 -1
- package/web/assets/{create-DNar5UQD.js → create-BVt_sQ_7.js} +1 -1
- package/web/assets/{create-0PUtkJZY.js → create-BWviSWbC.js} +1 -1
- package/web/assets/{create-BJ1asdcy.js → create-C6jihslA.js} +1 -1
- package/web/assets/{create-C7GOgZZM.js → create-IaalYGmm.js} +1 -1
- package/web/assets/{create-Bgv5ux17.js → create-jzl1m8ZK.js} +1 -1
- package/web/assets/{credit-grant-item-list-CeDAM3qV.js → credit-grant-item-list-DQcvdSRs.js} +1 -1
- package/web/assets/{credit-overview-4zh0H02x.js → credit-overview-CPId2vzk.js} +1 -1
- package/web/assets/{currency-restrictions-BcEm8W45.js → currency-restrictions-Dsupz2ce.js} +1 -1
- package/web/assets/{currency-select-B4ieQBvv.js → currency-select-C8j7QQMP.js} +1 -1
- package/web/assets/{dayjs-DUTDpcNU.js → dayjs-DUNWtvju.js} +1 -1
- package/web/assets/{description-SnR5WxWT.js → description-BHxdy5I3.js} +1 -1
- package/web/assets/{detail-DNcp_u5S.js → detail-B17BN6kU.js} +1 -1
- package/web/assets/detail-BJ-hl5PK.js +10 -0
- package/web/assets/{detail-46aLUdJj.js → detail-BJEqTXDS.js} +1 -1
- package/web/assets/{detail-BQpDGZJQ.js → detail-BdC9VIc6.js} +1 -1
- package/web/assets/{detail-DbU3p040.js → detail-BkRkrKyw.js} +1 -1
- package/web/assets/{detail-DACnmls3.js → detail-BvcI9cB_.js} +1 -1
- package/web/assets/detail-C--ATvwm.js +24 -0
- package/web/assets/{detail-Cg505nKX.js → detail-CHJqYZ0W.js} +1 -1
- package/web/assets/{detail-B0IHl4MI.js → detail-CfvKZ7IV.js} +1 -1
- package/web/assets/{detail-Ct5QNBqu.js → detail-CmIweOLE.js} +1 -1
- package/web/assets/{detail-BXTsnQny.js → detail-D729Bgs6.js} +1 -1
- package/web/assets/{detail-C_Zdfa0y.js → detail-DD1YBtex.js} +1 -1
- package/web/assets/detail-DOcm4Kqg.js +15 -0
- package/web/assets/{detail-Bfnkg0A1.js → detail-DQj1mbhA.js} +1 -1
- package/web/assets/detail-DTXDMIR9.js +15 -0
- package/web/assets/{detail-CsGZMimg.js → detail-DUAJzKsu.js} +1 -1
- package/web/assets/{detail-BwH0DwAi.js → detail-De8PyTyx.js} +1 -1
- package/web/assets/{detail-B_lpOomD.js → detail-DqfxOHky.js} +1 -1
- package/web/assets/{detail-CMBRd4Ct.js → detail-Dzt5tfyZ.js} +1 -1
- package/web/assets/{detail-Tn2R5C8i.js → detail-H0dkKVyS.js} +1 -1
- package/web/assets/{detail-CyMhK5K_.js → detail-MgdgGj5J.js} +1 -1
- package/web/assets/{detail-DCTb8R7F.js → detail-WAmPM6yq.js} +1 -1
- package/web/assets/{detail-B-ceWfZr.js → detail-g6el9Fxj.js} +1 -1
- package/web/assets/did-Bqcz-NjH.js +1 -0
- package/web/assets/{drawer-form-DspWWj3x.js → drawer-form-CQjNFFWk.js} +1 -1
- package/web/assets/{edit-Bkj-OTJh.js → edit-DAU8AWzT.js} +1 -1
- package/web/assets/{editor-AmthipP2.js → editor-vZvxDUTl.js} +1 -1
- package/web/assets/{embed-rRKjDoHi.js → embed-ClYNqZbf.js} +1 -1
- package/web/assets/{filter-toolbar-DXGSTq57.js → filter-toolbar-VvmMATj0.js} +1 -1
- package/web/assets/{form-BmQlJZ84.js → form-4_MzglPj.js} +1 -1
- package/web/assets/{form-cX026J4G.js → form-AFzUvoFE.js} +1 -1
- package/web/assets/{form-B5WW-lS5.js → form-Bro99BjK.js} +1 -1
- package/web/assets/{form-CAPjlw7l.js → form-CnrBCyTJ.js} +1 -1
- package/web/assets/form-Cuvruf4H.js +16 -0
- package/web/assets/{gas-nyR96dB0.js → gas-kw2KMH1u.js} +1 -1
- package/web/assets/{generateCategoricalChart-BadryV3H.js → generateCategoricalChart-BCpuUeC_.js} +1 -1
- package/web/assets/{home-_eX1aim8.js → home-ZNJREzbw.js} +1 -1
- package/web/assets/{index-CbSXdD6E.js → index-ASk8vU2H.js} +1 -1
- package/web/assets/{index-ajD9Iotk.js → index-B4n6PvPu.js} +1 -1
- package/web/assets/{index-BarN7DfU.js → index-B4yaPb7B.js} +5 -5
- package/web/assets/{index-DSe7Dot_.js → index-BHwID_s4.js} +1 -1
- package/web/assets/index-BMcnd_jZ.js +1 -0
- package/web/assets/{index-BTfJ08JU.js → index-BRmN8ViQ.js} +1 -1
- package/web/assets/index-BdbLl6St.js +1 -0
- package/web/assets/{index-CCVDDX0c.js → index-BjKRyxNQ.js} +1 -1
- package/web/assets/index-BjLJQRKY.js +1 -0
- package/web/assets/index-BkNCPnTn.js +1 -0
- package/web/assets/index-BlAwTTmu.js +1 -0
- package/web/assets/{index-C136x0O2.js → index-BtWfmATr.js} +1 -1
- package/web/assets/{index-DNGmCIRP.js → index-C-5n472s.js} +1 -1
- package/web/assets/{index-CW8VfoJO.js → index-C3AP4jq0.js} +1 -1
- package/web/assets/{index-C-RT84yb.js → index-C3Rh1SaB.js} +1 -1
- package/web/assets/index-CDyxbCzc.js +1 -0
- package/web/assets/{index-SOzRg0yJ.js → index-CH_k9MVv.js} +1 -1
- package/web/assets/{index-XaFn2ySq.js → index-CKPfOW6M.js} +1 -1
- package/web/assets/{index-BQjlhCSt.js → index-CPFlZhA2.js} +1 -1
- package/web/assets/{index-Du0Ieh1F.js → index-CPyGjEd3.js} +2 -2
- package/web/assets/index-ChC-jsE2.js +1 -0
- package/web/assets/{index-D-bx9Kam.js → index-CiWvs3j9.js} +1 -1
- package/web/assets/{index-mn5Zdrtn.js → index-D6gv9jHh.js} +1 -1
- package/web/assets/{index-Cd_BD9TM.js → index-D7pWd60Z.js} +1 -1
- package/web/assets/{index-YG5oc8O3.js → index-DAen2-cr.js} +1 -1
- package/web/assets/{index-BRENdB5m.js → index-DNobX-Tr.js} +1 -1
- package/web/assets/{index-Kd_qCyRG.js → index-DY-g0BPU.js} +1 -1
- package/web/assets/{index-D0mynT6_.js → index-DZkpxY-C.js} +1 -1
- package/web/assets/{index-DcddP3R9.js → index-Dh9agU9O.js} +1 -1
- package/web/assets/{index-BBHMsIxJ.js → index-Dju8k6mq.js} +1 -1
- package/web/assets/{index-DeK5Pqjv.js → index-DwDNPqjF.js} +1 -1
- package/web/assets/{index-DEiuhiEo.js → index-Dze0CpfQ.js} +1 -1
- package/web/assets/{index-UYeD8rTJ.js → index-eDERHpkr.js} +1 -1
- package/web/assets/{index-BzABukCz.js → index-mgPU1lyd.js} +1 -1
- package/web/assets/{index-W2uZUlFs.js → index-olGOY5KB.js} +1 -1
- package/web/assets/{index-DoX0A-rP.js → index-oy7LrXGT.js} +1 -1
- package/web/assets/{index-qulrJQ4J.js → index-x7sBb6oM.js} +1 -1
- package/web/assets/{index.es-C8dcCHdW.js → index.es-C2Q6Owow.js} +1 -1
- package/web/assets/{info-card-BvIMFQo5.js → info-card-C9dRgztS.js} +1 -1
- package/web/assets/{info-metric-Dl4ZDm0Z.js → info-metric-ukWq8INi.js} +1 -1
- package/web/assets/{info-row-jI0h_hv4.js → info-row-CaPaNF4L.js} +1 -1
- package/web/assets/{info-row-group-CFuMWJf1.js → info-row-group-Cxo-4Gk5.js} +1 -1
- package/web/assets/{libphonenumber-Qs8PCdM-.js → libphonenumber-CTvobi0D.js} +1 -1
- package/web/assets/{link-CmPoIweR.js → link-DsltSF2Q.js} +1 -1
- package/web/assets/{list-CkHExntK.js → list-B2b-s8wM.js} +1 -1
- package/web/assets/{list-DLB_hd0Q.js → list-BzgF4i3i.js} +1 -1
- package/web/assets/{list-BdSkPjIa.js → list-Cd1O-aDi.js} +1 -1
- package/web/assets/{list-DaK9287Y.js → list-CvM46TsP.js} +1 -1
- package/web/assets/{list-CWMEf-_C.js → list-DtEjqlED.js} +1 -1
- package/web/assets/{list-DVFJwd_I.js → list-O_uCSLFq.js} +1 -1
- package/web/assets/{list-DghnUOc4.js → list-YNWVqjwW.js} +1 -1
- package/web/assets/{list-eFkvVlp5.js → list-ZaBapEXW.js} +1 -1
- package/web/assets/{metadata-BmQTVFku.js → metadata-_hV0ZaVh.js} +1 -1
- package/web/assets/{meter-event-B1JIhVpb.js → meter-event-CPVBpekF.js} +1 -1
- package/web/assets/{metrics-UvxyQbUF.js → metrics-DVPdwpyf.js} +1 -1
- package/web/assets/{overview-Cxc6WKba.js → overview-CGdVIJrJ.js} +1 -1
- package/web/assets/{overview-DrMaIptb.js → overview-CN59I5Sc.js} +1 -1
- package/web/assets/{past-due-CUXkxns0.js → past-due-C3PtU8uo.js} +1 -1
- package/web/assets/pay-XVdSNq__.js +4 -0
- package/web/assets/{payment-method-info-Bsf89VxV.js → payment-method-info-D_qR04xC.js} +1 -1
- package/web/assets/{preview-C-H8pGVw.js → preview-Bdtbh-xk.js} +1 -1
- package/web/assets/{preview-BifsgUGT.js → preview-F3lma170.js} +1 -1
- package/web/assets/{pricing-table-BUJdtkMq.js → pricing-table-Bt2WljzE.js} +1 -1
- package/web/assets/{pricing-table-B3QOaAB5.js → pricing-table-D9FGYBVa.js} +1 -1
- package/web/assets/{product-select-ChEyoJqJ.js → product-select-_72p-5lF.js} +1 -1
- package/web/assets/{recharge-BVT4USAO.js → recharge-CSlKshbU.js} +1 -1
- package/web/assets/{related-credit-grants-JV2ICsR5.js → related-credit-grants-DnKdAit6.js} +3 -3
- package/web/assets/{safe-did-address-CiG_V6Gy.js → safe-did-address-CRTPYo34.js} +1 -1
- package/web/assets/{source-data-viewer-i1q9wNIG.js → source-data-viewer-D1GShrs5.js} +1 -1
- package/web/assets/{status-CUVYrUIG.js → status-3Swm2gK5.js} +1 -1
- package/web/assets/subscription-BX00k6FU.js +1 -0
- package/web/assets/{subscription-DrnSPIfs.js → subscription-Bzeblscr.js} +1 -1
- package/web/assets/table-BN3WBnr3.js +1 -0
- package/web/assets/{tax-code-select-TS07I0rB.js → tax-code-select-j2arPbaE.js} +1 -1
- package/web/assets/{tax-utils-bPjALcVG.js → tax-utils-B8J0Kfnz.js} +1 -1
- package/web/assets/{uploader-CsQNHG4I.js → uploader-BLdAbLR6.js} +1 -1
- package/web/assets/{usage-records-DAUQMJAW.js → usage-records-BAwNs1y8.js} +1 -1
- package/web/assets/{util-DxXTXkeY.js → util-B8B3fsMa.js} +1 -1
- package/web/assets/{vendor-arcblock-BTCAQSUK.js → vendor-arcblock-D1drrE7q.js} +1 -1
- package/web/assets/{vendor-blocklet-DcLR2Cyf.js → vendor-blocklet-B67R14so.js} +2 -2
- package/web/index.html +1 -1
- package/web/assets/browser-DDv4_sgY.js +0 -1
- package/web/assets/detail-B8eOBVSQ.js +0 -15
- package/web/assets/detail-BO3zglCn.js +0 -15
- package/web/assets/detail-C1FupF1D.js +0 -24
- package/web/assets/detail-wU4wNf4s.js +0 -10
- package/web/assets/form-DD-EiA7W.js +0 -16
- package/web/assets/index-BhcoukR2.js +0 -1
- package/web/assets/index-BturOfxo.js +0 -1
- package/web/assets/index-CDVogp6E.js +0 -1
- package/web/assets/index-DcrGSDby.js +0 -1
- package/web/assets/index-Dybqd298.js +0 -1
- package/web/assets/index-EXZPddtw.js +0 -1
- package/web/assets/index-brUCsnBA.js +0 -1
- package/web/assets/pay-omLYkqRA.js +0 -4
- package/web/assets/subscription-BYz_k9dq.js +0 -1
- package/web/assets/table-BrtHemkA.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as Y,j as e,A as se,a3 as g,q as y,x as ne,a_ as $e,aX as D,a$ as M,a2 as Me,B as G,O as ce,ai as be,by as Ue,$ as te,bg as ae,bl as re,a1 as fe,aQ as Ve,w as qe,b4 as He,bH as Ge}from"./vendor-mui-BXZut9Pz.js";import{V as ie,P as W,$ as Ne,F as V,Z as v,H as O,G as L,ap as Ye,L as Ke,Y as Xe,a6 as Qe,a7 as Ze}from"./vendor-blocklet-DcLR2Cyf.js";import{a as Fe,D as Je,q as et,L as tt,e as S,k as U,l as ve,E as Le,j as Se,C as Pe,d as nt,h as Te,S as ot,G as at,F as rt,H as st,I as ct,O as it,i as _e}from"./index-BarN7DfU.js";import{C as lt}from"./currency-GstdXsJf.js";import{f as dt}from"./dayjs-DUTDpcNU.js";import{M as ge,a as ut,i as Ae}from"./util-DxXTXkeY.js";import{A as Ie}from"./actions-BJDN6Op2.js";import{u as mt}from"./subscription-DrnSPIfs.js";import{a as ht}from"./vendor-react-BPknnnEA.js";const pt=async t=>{const o=`/api/subscriptions/${t.subscriptionId}`;return(await S.get(t.authToken?V(o,`?authToken=${t.authToken}`):o)).data},xt=async t=>{const o=`/api/subscriptions/${t.subscriptionId}/recover-info`;return(await S.get(t.authToken?V(o,`?authToken=${t.authToken}`):o)).data},ft=async t=>{const o=`/api/subscriptions/${t.subscriptionId}/recover`;return(await S.put(t.authToken?V(o,`?authToken=${t.authToken}`):o)).data};function gt({subscriptionId:t,dialogProps:o={open:!0},onResumed:p=()=>{},successToast:d=!0,authToken:w=void 0}){const{t:x,locale:b}=ie(),{connect:a}=Fe(),[P,j]=Y.useState(!1),[s,N]=Y.useState(o.open||!1),{data:_,error:T,loading:q}=W(()=>xt({subscriptionId:t,authToken:w}),{ready:!!t}),c=Je(),R=_?.needStake??!1,z=async()=>{try{const m=await pt({subscriptionId:t,authToken:w});d&&v.success(x("payment.customer.recover.success")),N(!1),p(m),j(!1)}catch(m){console.error("Failed to fetch updated subscription:",m),v.error(U(m)),j(!1)}},H=()=>{j(!0);try{a.open({locale:b,containerEl:void 0,saveConnect:!1,action:"re-stake",prefix:V(ve(),"/api/did"),useSocket:!c,extraParams:{subscriptionId:t},messages:{scan:x("common.connect.defaultScan"),title:x("payment.customer.recover.reStakeTitle"),confirm:x("common.connect.confirm")},onSuccess:z,onClose:()=>{a.close(),j(!1)},onError:m=>{v.error(U(m)),j(!1)}})}catch(m){v.error(U(m)),j(!1)}},h=async()=>{j(!0);try{const m=await ft({subscriptionId:t,authToken:w});if(m.needStake){H();return}const{subscription:$}=m;d&&v.success(x("payment.customer.recover.success")),N(!1),p($),j(!1)}catch(m){v.error(U(m)),j(!1)}},C=()=>{R?H():h()},A=()=>{N(!1),o.onClose?.()};return q?null:e.jsx(Ne,{PaperProps:{style:{minHeight:"auto"}},...o||{},open:s,title:o?.title||x("payment.customer.recover.title"),sx:{"& .MuiDialogContent-root":{pt:0}},onClose:A,children:T?e.jsx(se,{severity:"error",children:T.message}):e.jsxs(g,{sx:{gap:2},children:[e.jsx(y,{variant:"body2",sx:{color:"text.secondary"},children:x("payment.customer.recover.description",{date:et(Number(_?.subscription?.current_period_end||"0")*1e3)})}),R&&e.jsx(se,{severity:"warning",children:x("payment.customer.recover.stakeRequiredDescription")}),e.jsxs(g,{direction:"row",sx:{justifyContent:"flex-end",gap:2,mt:2},children:[e.jsx(ne,{variant:"outlined",color:"primary",onClick:A,children:x("common.cancel")}),e.jsx(tt,{variant:"contained",size:"small",loading:P,onClick:C,children:x("common.confirm")})]})]})})}function yt({data:t}){const{t:o}=ie(),{control:p}=Le();return e.jsxs(g,{direction:"column",spacing:1,sx:{alignItems:"flex-start"},children:[e.jsx(y,{children:t.status==="trialing"?o("payment.customer.cancel.trialDescription"):o("payment.customer.cancel.description",{date:Se(t.current_period_end*1e3)})}),e.jsx(Pe,{name:"cancel.feedback",control:p,render:({field:d})=>e.jsxs($e,{...d,sx:{ml:"5px !important"},children:[e.jsx(D,{value:"too_expensive",control:e.jsx(M,{checked:d.value==="too_expensive"}),label:o("payment.customer.cancel.feedback.too_expensive")}),e.jsx(D,{value:"missing_features",control:e.jsx(M,{checked:d.value==="missing_features"}),label:o("payment.customer.cancel.feedback.missing_features",{date:Se(new Date(t.current_period_end*1e3))})}),e.jsx(D,{value:"switched_service",control:e.jsx(M,{checked:d.value==="switched_service"}),label:o("payment.customer.cancel.feedback.switched_service")}),e.jsx(D,{value:"unused",control:e.jsx(M,{checked:d.value==="unused"}),label:o("payment.customer.cancel.feedback.unused")}),e.jsx(D,{value:"customer_service",control:e.jsx(M,{checked:d.value==="customer_service"}),label:o("payment.customer.cancel.feedback.customer_service")}),e.jsx(D,{value:"too_complex",control:e.jsx(M,{checked:d.value==="too_complex"}),label:o("payment.customer.cancel.feedback.too_complex")}),e.jsx(D,{value:"low_quality",control:e.jsx(M,{checked:d.value==="low_quality"}),label:o("payment.customer.cancel.feedback.low_quality")}),e.jsx(D,{value:"other",control:e.jsx(M,{checked:d.value==="other"}),label:o("payment.customer.cancel.feedback.other")})]})}),e.jsx(Pe,{name:"cancel.comment",control:p,rules:{maxLength:{value:200,message:o("common.maxLength",{len:200})}},render:({field:d})=>e.jsx(Me,{variant:"outlined",size:"small",fullWidth:!0,multiline:!0,minRows:2,maxRows:4,placeholder:o("payment.customer.cancel.comment"),...d,slotProps:{htmlInput:{maxLength:200}}})})]})}const bt=(t,o)=>S.get(`/api/subscriptions/${t}/cycle-amount`,{params:o}).then(p=>p.data);function De(t,...o){if(!o.length)return"0";const p=t?.decimal||18,d=o.reduce((w,x)=>{if(!x||typeof x!="string"||!/^-?\d*\.?\d*$/.test(x.trim()))return w;const b=x.trim();if(b===""||b==="-")return w;try{const a=Ke(b,p);return new L(w).add(new L(a))}catch{return w}},new L(0));return O(d.toString(),p)}function vt({value:t,loading:o,onSave:p,onCancel:d,open:w,stakingAddress:x="",payerAddress:b="",currency:a,subscription:P,initValues:j=null}){const{t:s,locale:N}=ie(),{isMobile:_}=nt(),[T,q]=Y.useState(!1),[c,R]=Y.useState([]),{data:z={amount:"0",gas:"0"},loading:H}=W(()=>bt(P.id,{overdraftProtection:!0}),{refreshDeps:[P.id],onSuccess:l=>{const k=(()=>{const{interval:u,interval_count:r}=P.pending_invoice_item_interval;switch(u){case"hour":return[{cycles:Math.ceil(24/r),label:"1 day"},{cycles:Math.ceil(168/r),label:"1 week"},{cycles:Math.ceil(720/r),label:"1 month"},{cycles:Math.ceil(2160/r),label:"3 months"},{cycles:Math.ceil(4320/r),label:"6 months"}];case"day":return[{cycles:Math.ceil(7/r),label:"1 week"},{cycles:Math.ceil(30/r),label:"1 month"},{cycles:Math.ceil(90/r),label:"3 months"},{cycles:Math.ceil(180/r),label:"6 months"},{cycles:Math.ceil(365/r),label:"1 year"}];default:return[{cycles:1,label:"1x"},{cycles:2,label:"2x"},{cycles:3,label:"6x"},{cycles:6,label:"6x"},{cycles:12,label:"12x"}]}})(),F=u=>O(new L(l.amount).mul(new L(u)).toString(),l?.currency?.decimal);R(k.map(({cycles:u,label:r})=>({amount:F(u),cycles:u,label:r})))}}),h=Te({defaultValues:{enabled:!!P.overdraft_protection?.enabled,return_stake:!1,amount:"0",...j||{}},mode:"onChange"}),C=h.watch("enabled"),A=h.watch("amount"),m=O(z.amount,a?.decimal),$=O(t.unused,a?.decimal),K=O(t.used,a?.decimal),f=O(new L(z.amount).sub(new L(t.unused)).toString(),a?.decimal),B=()=>{q(!0),h.setValue("amount",Number(f)<0?m:f)},le=()=>{h.handleSubmit(async l=>{await p(l)})()},X=l=>{const{interval:k,interval_count:F}=P.pending_invoice_item_interval,u=l*F;return["hour","day","week","month","year"].includes(k)?s("common.estimatedDuration",{duration:dt(u,k,{t:s})}):s("customer.overdraftProtection.estimatedDuration",{duration:u,unit:s("customer.overdraftProtection.intervals").toLowerCase()})},de=()=>V(P.paymentMethod?.settings.arcblock?.explorer_host,"/stakes",x,"/tokens");Ye(()=>{h&&h.reset()});const Q=l=>{h.reset(),d(l)};return e.jsx(Ne,{open:w,onClose:Q,maxWidth:"sm",fullWidth:!0,className:"base-dialog",title:e.jsxs(g,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(y,{variant:"h6",component:"span",children:s("customer.overdraftProtection.setting")}),e.jsx(be,{href:"https://www.arcblock.io/content/blog/en/payment-kit-v117-sub-guard#listen-to-the-audio-overview",target:"_blank",rel:"noopener noreferrer",underline:"hover",sx:{display:"flex",alignItems:"center",gap:.5,fontSize:"14px",fontWeight:"normal",ml:1,color:"text.link","&:hover":{color:"primary.main"},..._?{fontSize:"12px"}:{}},children:e.jsx(ce,{title:s("customer.overdraftProtection.learnMore"),placement:"top",children:e.jsx(He,{fontSize:"small",sx:{fontSize:"16px",color:"text.secondary",cursor:"pointer","&:hover":{color:"primary.main"}}})})})]}),actions:e.jsxs(g,{direction:"row",spacing:2,children:[e.jsx(ne,{variant:"outlined",onClick:Q,children:s("common.cancel")}),e.jsxs(ne,{variant:"contained",color:"primary",disabled:o,onClick:le,children:[o&&e.jsx(qe,{size:20,sx:{mr:1}}),s("common.submit")]})]}),children:e.jsxs(g,{sx:{gap:2},children:[e.jsx(se,{severity:"info",children:t.used!=="0"&&!C?e.jsx(e.Fragment,{children:s("customer.overdraftProtection.disableConfirm")}):e.jsxs(G,{children:[s("customer.overdraftProtection.tip"),e.jsx(ce,{title:s("customer.overdraftProtection.ruleTip",{gas:O(z.gas,a?.decimal),symbol:a.symbol}),placement:"top",children:e.jsx(y,{variant:"body2",sx:{color:"text.link",cursor:"pointer",mt:1},children:s("customer.overdraftProtection.rule")})})]})}),e.jsxs(g,{spacing:2,direction:"row",sx:{alignItems:"center"},children:[e.jsx(y,{variant:"subtitle1",sx:{color:"text.secondary"},children:s("customer.overdraftProtection.title")}),e.jsx(D,{control:e.jsx(ot,{checked:C,onChange:l=>h.setValue("enabled",l.target.checked)}),label:""})]}),C?e.jsxs(g,{sx:{gap:1,mt:"-8px"},children:[b&&e.jsxs(g,{sx:_?{flexDirection:"column",gap:1}:{flexDirection:"row",alignItems:"center",gap:2},children:[e.jsx(y,{variant:"subtitle2",sx:{color:"text.secondary"},children:s("customer.overdraftProtection.payerAddress")}),e.jsx(y,{variant:"body2",sx:{wordBreak:"break-all",fontFamily:"monospace",fontWeight:"700"},children:b})]}),x&&e.jsxs(g,{sx:_?{flexDirection:"column",gap:1}:{flexDirection:"row",alignItems:"center",gap:2},children:[e.jsx(y,{variant:"subtitle2",sx:{color:"text.secondary"},children:s("customer.overdraftProtection.stakingAddress")}),e.jsxs(be,{href:de(),target:"_blank",rel:"noopener noreferrer",sx:{wordBreak:"break-all",fontFamily:"monospace",fontWeight:"700",textDecoration:"none",color:"text.link",display:"flex",flexWrap:"wrap",alignItems:"center",gap:1},children:[x,!_&&e.jsx(Ue,{fontSize:"small"})]})]}),e.jsx(y,{variant:"body2",sx:{color:"text.secondary"},children:Number(K)>0&&!t.enabled?s("customer.overdraftProtection.remainingNotEnough",{due:K,symbol:a.symbol,min:Number(f)<0?m:f,unused:$}):t.remaining==="0"?s("customer.overdraftProtection.noRemaining",{estimateAmount:m,symbol:a.symbol}):s("customer.overdraftProtection.remaining",{amount:$,symbol:a.symbol,estimateAmount:m})}),e.jsx(te,{container:!0,spacing:2,sx:{ml:-2,mt:-1},children:H?e.jsxs(e.Fragment,{children:[[1,2,3,4,5].map(l=>e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%"},children:e.jsx(re,{sx:{height:"100%",p:1},children:e.jsxs(g,{spacing:1,sx:{alignItems:"center"},children:[e.jsx(fe,{variant:"rectangular",width:80,height:32}),e.jsx(fe,{width:100})]})})})},l)),e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%"},children:e.jsx(re,{sx:{height:"100%",p:2},children:e.jsx(g,{spacing:1,sx:{alignItems:"center"},children:e.jsx(fe,{variant:"rectangular",width:80,height:24})})})})})]}):e.jsxs(e.Fragment,{children:[c.map(({amount:l,cycles:k})=>e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%",transition:"all 0.3s",cursor:"pointer","&:hover":{transform:"translateY(-4px)",boxShadow:3},...A===l&&!T?{borderColor:"primary.main",borderWidth:1}:{}},children:e.jsx(re,{onClick:()=>{h.setValue("amount",l),q(!1)},sx:{height:"100%",p:1},children:e.jsxs(g,{spacing:1,sx:{alignItems:"center"},children:[e.jsxs(y,{variant:"h6",sx:{fontWeight:600},children:[l," ",a.symbol]}),e.jsx(y,{variant:"caption",sx:{color:"text.secondary"},children:X(k)})]})})})},l)),e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%",transition:"all 0.3s",cursor:"pointer","&:hover":{transform:"translateY(-4px)",boxShadow:3},...T?{borderColor:"primary.main",borderWidth:1}:{}},children:e.jsx(re,{onClick:B,sx:{height:"100%",p:2},children:e.jsx(g,{spacing:1,sx:{alignItems:"center"},children:e.jsx(y,{variant:"h6",sx:{fontWeight:600},children:s("common.custom")})})})})})]})}),T&&e.jsx(g,{spacing:2,sx:{mt:1},children:e.jsx(Ve,{fullWidth:!0,children:e.jsx(Me,{...h.register("amount",{required:!0,validate:l=>{const k=Number(f)<0?Number(m):Number(f);if(Number(l)<k)return s("customer.overdraftProtection.min",{min:k,symbol:a.symbol});if(Number(l)>ge)return s("common.maxAmount",{max:ge});const F=at(l.toString(),N,a?.maximum_precision||6);return F||!0}}),label:s("common.amount"),type:"number",error:!!h.formState.errors.amount,helperText:h.formState.errors.amount?.message,fullWidth:!0,variant:"outlined",slotProps:{input:{endAdornment:e.jsx(G,{sx:{ml:1,display:"flex",alignItems:"center"},children:e.jsx(lt,{logo:a.logo,name:a.symbol})})},htmlInput:{min:0,max:ge,step:Number(m)}}})})}),A&&Number(A)>0&&Number(m)>0&&!h.formState.errors.amount&&e.jsxs(y,{variant:"body2",sx:{fontSize:12,color:"text.lighter",mt:"8px !important"},children:[s("customer.overdraftProtection.total",{total:De(a,A,$),symbol:a.symbol}),X(Math.floor(Number(De(a,A,$))/Number(m)))]})]}):Number($)>0&&e.jsxs(g,{direction:"row",sx:{alignItems:"flex-start",gap:2},children:[e.jsx(y,{variant:"subtitle2",sx:{color:"text.secondary",height:39,display:"flex",alignItems:"center",width:56},children:s("customer.overdraftProtection.stake")}),e.jsxs($e,{"aria-labelledby":"return-stake-group-label",value:h.watch("return_stake"),onChange:l=>h.setValue("return_stake",l.target.value==="true"),children:[e.jsx(D,{value:!1,control:e.jsx(M,{}),label:s("customer.overdraftProtection.keepStake")}),e.jsx(D,{value:!0,control:e.jsx(M,{color:"warning"}),label:s("customer.overdraftProtection.returnStake")})]})]})]})})}const jt=async t=>{try{return!!(await S.get(`/api/subscriptions/${t}/change-plan`)).data}catch{return!1}},kt=async t=>{try{const o=await S.get(`/api/subscriptions/${t}/summary`);return!Qe(o.data)&&Object.keys(o.data).length===1?Object.keys(o.data)[0]:""}catch{return""}},ye=t=>["active","trialing","past_due"].includes(t?.status)&&["arcblock","ethereum","base"].includes(t?.paymentMethod?.type)&&t.paymentCurrency?.type!=="credit";function wt({subscription:t,showExtra:o=!1,showRecharge:p=!1,showOverdraftProtection:d=!1,showDelegation:w=!1,showUnsubscribe:x=!0,onChange:b=void 0,actionProps:a={},mode:P="all-buttons",setUp:j=void 0,showBalanceInfo:s=!1,includeActions:N=null,excludeActions:_=null,forceShowDetailAction:T=!1,buttonSize:q="small"}){const{t:c,locale:R}=ie(),{reset:z,getValues:H}=Le(),h=ht(),{connect:C,session:A}=Fe(),[m,$]=Y.useState(t),{checkUnpaidInvoices:K}=mt(t.id,!0),f=st(m,a??{}),B=i=>_&&_.length>0?!_.includes(i):N&&N.length>0?N.includes(i):!0,le=i=>{const I=i?.metadata?.credit_config?.schedule;return I?.enabled&&I?.delivery_mode==="schedule"},X=(t.items||[]).some(i=>le(i.price)),{data:de=!1}=W(()=>jt(t.id),{ready:!!o&&ut(t)&&!X}),{data:Q=""}=W(()=>kt(t.id),{ready:!!o}),{data:l={}}=W(()=>S.get(`/api/subscriptions/${t.id}/upcoming`).then(i=>i.data),{ready:B("recharge")&&!!(p&&ye(t))&&s}),{data:k={}}=W(()=>S.get(`/api/subscriptions/${t.id}/payer-token`).then(i=>i.data),{ready:B("recharge")&&!!(p&&ye(t))&&s}),F=l?.amount&&k?.token&&new L(k.token||"0").lt(new L(l.amount||"0")),[u,r]=Xe({action:"",subscription:"",loading:!1,openProtection:!1,protectionLoading:!1,protectionInitValues:null,batchPay:!1}),je=w&&["active","trialing","past_due"].includes(t?.status),ue=(typeof d=="boolean"&&d||typeof d=="object"&&d.show)&&t?.paymentMethod?.type==="arcblock"&&["active","trialing","past_due"].includes(t?.status)&&B("protection"),{data:me={sufficient:!0},refresh:Re}=W(()=>S.get(`/api/subscriptions/${t.id}/delegation`).then(i=>i.data),{ready:B("delegation")&&je,refreshDeps:[t.id,je]}),We=me&&typeof me=="object"&&!me.sufficient,{data:ke={enabled:!1,remaining:"0"},refresh:he}=W(()=>S.get(`/api/subscriptions/${t.id}/overdraft-protection`).then(i=>i.data),{ready:ue,refreshDeps:[t.id,ue]});Y.useEffect(()=>{j&&j({openOverdraftProtection:i=>r({openProtection:!0,protectionInitValues:i})})},[j]);const ze=async()=>{try{if(await K()){r({action:""});return}r({loading:!0});const I=await S.put(`/api/subscriptions/${u.subscription}/cancel`,{at:"current_period_end",...H().cancel,cancel_from:"customer"}).then(Z=>Z.data);$(I),v.success(c("common.saved")),b&&b(u.action)}catch(i){console.error(i),v.error(U(i))}finally{r({loading:!1,action:"",subscription:""}),z()}},Be=()=>{C.open({containerEl:void 0,saveConnect:!1,action:"delegation",locale:R,prefix:V(ve(),"/api/did"),extraParams:{subscriptionId:t.id,sessionUserDid:A.user.did},messages:{scan:c("common.connect.defaultScan"),title:c("customer.delegation.title"),confirm:c("common.connect.confirm")},onSuccess:()=>{C.close(),v.success(c("customer.delegation.success")),Re()},onClose:()=>{C.close()},onError:i=>{v.error(U(i))}})},Ee=async i=>{try{if(!i.enabled&&await K()){r({openProtection:!1});return}r({protectionLoading:!0});const I=await S.post(`/api/subscriptions/${t.id}/overdraft-protection`,i).then(pe=>pe.data),{open:Z,amount:oe}=I;if(i.return_stake&&ke.remaining!=="0"){v.success(c("customer.overdraftProtection.applyRemainingSuccess")),r({openProtection:!1}),he(),d?.onChange?.(),b?.();return}Z?C.open({containerEl:void 0,saveConnect:!1,locale:R,action:"overdraft-protection",prefix:V(ve(),"/api/did"),extraParams:{subscriptionId:t.id,amount:oe,sessionUserDid:A.user.did},messages:{scan:c("common.connect.defaultScan"),title:c("customer.overdraftProtection.title"),confirm:c("common.connect.confirm")},onSuccess:()=>{C.close(),t.overdraft_protection?.enabled?v.success(c("customer.overdraftProtection.settingSuccess")):v.success(c("customer.overdraftProtection.openSuccess")),r({openProtection:!1}),he(),d?.onChange?.(),b?.()},onClose:()=>{C.close(),r({protectionLoading:!1})}}):(v.success(c("customer.overdraftProtection.closeSuccess")),r({openProtection:!1}),he(),d?.onChange?.(),b?.())}catch(I){throw v.error(U(I)||c("customer.overdraftProtection.settingError")),I}finally{r({protectionLoading:!1})}},Oe=()=>{const i=f?.action==="cancel"&&x,I=f&&(f?.action!=="cancel"||i),Z=Ae(t)&&f?.action==="recover",oe=t.service_actions?.filter(n=>n?.type!=="notification")||[],J=[{key:"delegation",show:w&&We,label:c("customer.delegation.btn"),tooltip:c("customer.delegation.title"),onClick:Be,variant:a?.delegation?.variant||"outlined",color:a?.delegation?.color||"primary",primary:!0},{key:"protection",show:ue,label:c("customer.overdraftProtection.setting"),onClick:()=>r({openProtection:!0,protectionInitValues:null}),variant:a?.protection?.variant||"outlined",color:a?.protection?.color||"primary"},{key:"recharge",show:!!(p&&ye(t)),label:()=>{const n=e.jsxs(g,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx(Ge,{fontSize:"small"}),c("customer.recharge.title")]});if(s&&t.paymentCurrency){const E=_e(k?.token||"0",t.paymentCurrency.decimal),ee=_e(l?.amount||"0",t.paymentCurrency.decimal);return e.jsx(ce,{title:e.jsxs(G,{children:[F&&e.jsx(se,{severity:"error",sx:{py:0,mb:1},children:c("admin.subscription.insufficientBalance")}),e.jsxs(g,{spacing:.5,children:[e.jsxs(G,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y,{sx:{color:"text.secondary"},variant:"body2",children:c("admin.subscription.currentBalance")}),e.jsxs(y,{variant:"body2",children:[E," ",t.paymentCurrency.symbol]})]}),e.jsxs(G,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y,{sx:{color:"text.secondary"},variant:"body2",children:c("admin.subscription.nextInvoiceAmount")}),e.jsxs(y,{variant:"body2",children:[ee," ",t.paymentCurrency.symbol]})]}),e.jsxs(G,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y,{sx:{color:"text.secondary"},variant:"body2",children:c("admin.subscription.paymentAddress")}),e.jsx(Ze,{did:k?.paymentAddress,responsive:!1,compact:!0,showAvatar:!1})]})]})]}),placement:"top",slotProps:{tooltip:{sx:{bgcolor:"background.paper",color:"text.primary",boxShadow:2,padding:"10px 16px",maxWidth:480,minWidth:350,wordBreak:"break-word"}}},children:n})}return n},labelText:c("customer.recharge.title"),onClick:n=>{n?.stopPropagation(),h(`/customer/subscription/${t.id}/recharge`)},variant:a?.recharge?.variant||"outlined",color:a?.recharge?.color||"primary",primary:!Ae(t),sx:F||k.token==="0"?{"&::before":{content:'""',backgroundColor:"error.main",borderRadius:"50%",position:"absolute",top:"3px",right:"-3px",width:"6px",height:"6px",zIndex:1},...a?.recharge?.sx||{}}:a?.recharge?.sx||{}},{key:"changePlan",show:de&&!X,label:f?.text||c("payment.customer.changePlan.button"),onClick:n=>{n?.stopPropagation(),h(`/customer/subscription/${t.id}/change-plan`)},variant:a?.changePlan?.variant||"contained",color:a?.changePlan?.color||"primary",sx:a?.changePlan?.sx},{key:"batchPay",show:!!Q,label:f?.text||c("admin.subscription.batchPay.button"),onClick:n=>{n?.stopPropagation(),r({batchPay:!0})},variant:a?.batchPay?.variant||"outlined",color:a?.batchPay?.color||"error",sx:a?.batchPay?.sx,primary:!0},{key:"mainAction",show:!!(!Q&&I),label:f?.text||c(`payment.customer.${f?.action}.button`),onClick:n=>{n?.stopPropagation(),f?.action==="pastDue"?h(`/customer/invoice/past-due?subscription=${t.id}`):f?.action==="recover"&&!t.paymentMethodDetails?v.error(c("admin.subscription.bindPaymentMethodFirst")):r({action:f?.action,subscription:t.id})},variant:f?.variant||"outlined",color:f?.color||"primary",sx:f?.sx,divider:oe.length>0,primary:Z},...oe.map(n=>({key:n.name,show:!0,label:n.text[R]||n.text.en||n.name,onClick:()=>window.open(n.link,"_blank"),variant:n?.variant||"contained",color:n?.color||"primary",component:be,href:n.link,target:"_blank",sx:{textDecoration:"none !important"}}))].filter(n=>n.show&&B(n.key)),we=n=>({label:n.labelText||(typeof n.label=="function"?n.label():n.label),handler:n.onClick,color:n.color,divider:n.divider}),xe=T&&e.jsx(ne,{className:"action-button",sx:a?.detail?.sx||{},variant:a?.detail?.variant||"outlined",color:a?.detail?.color||"primary",onClick:()=>h(`/customer/subscription/${t.id}`),children:c("customer.subscription.manage")},"detail"),Ce=n=>{const E=typeof n.label=="function"?n.label():n.label;return e.jsx(ne,{variant:n.variant,color:n.color,onClick:n.onClick,component:n.component,href:n.href,target:n.target,sx:n.sx,className:"action-button",size:q,children:n.tooltip?e.jsx(ce,{title:n.tooltip,children:e.jsx("span",{children:E})}):E},n.key)};if(P==="menu-only")return e.jsxs(e.Fragment,{children:[xe,J.length>0&&e.jsx(Ie,{actions:J.map(we),variant:"outlined",sx:a?.menu?.sx||{}})]});if(P==="primary-buttons"){const n=J.filter(ee=>ee.primary),E=J.filter(ee=>!ee.primary);return e.jsxs(e.Fragment,{children:[xe,n.map(Ce),E.length>0&&e.jsx(Ie,{actions:E.map(we),variant:"outlined",sx:a?.menu?.sx||{}})]})}return e.jsxs(e.Fragment,{children:[xe,J.map(Ce)]})};return e.jsxs(g,{direction:"row",sx:{alignItems:"center",gap:1,flexWrap:"wrap"},children:[Oe(),u.action==="cancel"&&u.subscription&&e.jsx(ct,{onConfirm:ze,onCancel:i=>{i.stopPropagation(),r({action:"",subscription:""})},title:c("payment.customer.cancel.title"),message:e.jsx(yt,{data:t}),loading:u.loading}),u.action==="recover"&&u.subscription&&e.jsx(gt,{subscriptionId:u.subscription,onResumed:i=>{r({action:"",subscription:""}),b?.(u.action),$(i)},dialogProps:{open:!0,onClose:()=>r({action:"",subscription:""})}}),u.openProtection&&e.jsx(vt,{value:ke,onSave:Ee,open:u.openProtection,payerAddress:t.overdraft_protection?.payment_details?.arcblock?.payer,stakingAddress:t.overdraft_protection?.payment_details?.arcblock?.staking?.address,currency:t.paymentCurrency,subscription:t,loading:u.protectionLoading,onCancel:()=>r({openProtection:!1}),initValues:u.protectionInitValues}),u.batchPay&&e.jsx(it,{subscriptionId:t.id,onPaid:()=>{r({batchPay:!1}),b?.("batch-pay")},detailLinkOptions:{enabled:!1},dialogProps:{open:u.batchPay,onClose:()=>r({batchPay:!1})}})]})}function Nt(t){const o=Object.assign({showExtra:!1,showRecharge:!1,showBalanceInfo:!1,showOverdraftProtection:!1,showDelegation:!1,onChange:null,actionProps:{},mode:"all-buttons",setUp:null,showUnsubscribe:!0,includeActions:null,excludeActions:null,forceShowDetailAction:!1,buttonSize:"small"},t),p=Te({defaultValues:{cancel:{at:"current_period_end",feedback:"unused",comment:""}}});return e.jsx(rt,{...p,children:e.jsx(wt,{...o})})}export{Nt as S};
|
|
1
|
+
import{r as Y,j as e,A as se,a3 as g,q as y,x as ne,a_ as $e,aX as D,a$ as M,a2 as Me,B as G,O as ce,ai as be,by as Ue,$ as te,bg as ae,bl as re,a1 as fe,aQ as Ve,w as qe,b4 as He,bH as Ge}from"./vendor-mui-BXZut9Pz.js";import{V as ie,P as W,$ as Ne,F as V,Z as v,H as O,G as L,ap as Ye,L as Ke,Y as Xe,a6 as Qe,a7 as Ze}from"./vendor-blocklet-B67R14so.js";import{a as Fe,D as Je,q as et,L as tt,e as S,k as U,l as ve,E as Le,j as Se,C as Pe,d as nt,h as Te,S as ot,G as at,F as rt,H as st,I as ct,O as it,i as _e}from"./index-B4yaPb7B.js";import{C as lt}from"./currency-GstdXsJf.js";import{f as dt}from"./dayjs-DUNWtvju.js";import{M as ge,a as ut,i as Ae}from"./util-B8B3fsMa.js";import{A as Ie}from"./actions-BEUwbsq1.js";import{u as mt}from"./subscription-Bzeblscr.js";import{a as ht}from"./vendor-react-BPknnnEA.js";const pt=async t=>{const o=`/api/subscriptions/${t.subscriptionId}`;return(await S.get(t.authToken?V(o,`?authToken=${t.authToken}`):o)).data},xt=async t=>{const o=`/api/subscriptions/${t.subscriptionId}/recover-info`;return(await S.get(t.authToken?V(o,`?authToken=${t.authToken}`):o)).data},ft=async t=>{const o=`/api/subscriptions/${t.subscriptionId}/recover`;return(await S.put(t.authToken?V(o,`?authToken=${t.authToken}`):o)).data};function gt({subscriptionId:t,dialogProps:o={open:!0},onResumed:p=()=>{},successToast:d=!0,authToken:w=void 0}){const{t:x,locale:b}=ie(),{connect:a}=Fe(),[P,j]=Y.useState(!1),[s,N]=Y.useState(o.open||!1),{data:_,error:T,loading:q}=W(()=>xt({subscriptionId:t,authToken:w}),{ready:!!t}),c=Je(),R=_?.needStake??!1,z=async()=>{try{const m=await pt({subscriptionId:t,authToken:w});d&&v.success(x("payment.customer.recover.success")),N(!1),p(m),j(!1)}catch(m){console.error("Failed to fetch updated subscription:",m),v.error(U(m)),j(!1)}},H=()=>{j(!0);try{a.open({locale:b,containerEl:void 0,saveConnect:!1,action:"re-stake",prefix:V(ve(),"/api/did"),useSocket:!c,extraParams:{subscriptionId:t},messages:{scan:x("common.connect.defaultScan"),title:x("payment.customer.recover.reStakeTitle"),confirm:x("common.connect.confirm")},onSuccess:z,onClose:()=>{a.close(),j(!1)},onError:m=>{v.error(U(m)),j(!1)}})}catch(m){v.error(U(m)),j(!1)}},h=async()=>{j(!0);try{const m=await ft({subscriptionId:t,authToken:w});if(m.needStake){H();return}const{subscription:$}=m;d&&v.success(x("payment.customer.recover.success")),N(!1),p($),j(!1)}catch(m){v.error(U(m)),j(!1)}},C=()=>{R?H():h()},A=()=>{N(!1),o.onClose?.()};return q?null:e.jsx(Ne,{PaperProps:{style:{minHeight:"auto"}},...o||{},open:s,title:o?.title||x("payment.customer.recover.title"),sx:{"& .MuiDialogContent-root":{pt:0}},onClose:A,children:T?e.jsx(se,{severity:"error",children:T.message}):e.jsxs(g,{sx:{gap:2},children:[e.jsx(y,{variant:"body2",sx:{color:"text.secondary"},children:x("payment.customer.recover.description",{date:et(Number(_?.subscription?.current_period_end||"0")*1e3)})}),R&&e.jsx(se,{severity:"warning",children:x("payment.customer.recover.stakeRequiredDescription")}),e.jsxs(g,{direction:"row",sx:{justifyContent:"flex-end",gap:2,mt:2},children:[e.jsx(ne,{variant:"outlined",color:"primary",onClick:A,children:x("common.cancel")}),e.jsx(tt,{variant:"contained",size:"small",loading:P,onClick:C,children:x("common.confirm")})]})]})})}function yt({data:t}){const{t:o}=ie(),{control:p}=Le();return e.jsxs(g,{direction:"column",spacing:1,sx:{alignItems:"flex-start"},children:[e.jsx(y,{children:t.status==="trialing"?o("payment.customer.cancel.trialDescription"):o("payment.customer.cancel.description",{date:Se(t.current_period_end*1e3)})}),e.jsx(Pe,{name:"cancel.feedback",control:p,render:({field:d})=>e.jsxs($e,{...d,sx:{ml:"5px !important"},children:[e.jsx(D,{value:"too_expensive",control:e.jsx(M,{checked:d.value==="too_expensive"}),label:o("payment.customer.cancel.feedback.too_expensive")}),e.jsx(D,{value:"missing_features",control:e.jsx(M,{checked:d.value==="missing_features"}),label:o("payment.customer.cancel.feedback.missing_features",{date:Se(new Date(t.current_period_end*1e3))})}),e.jsx(D,{value:"switched_service",control:e.jsx(M,{checked:d.value==="switched_service"}),label:o("payment.customer.cancel.feedback.switched_service")}),e.jsx(D,{value:"unused",control:e.jsx(M,{checked:d.value==="unused"}),label:o("payment.customer.cancel.feedback.unused")}),e.jsx(D,{value:"customer_service",control:e.jsx(M,{checked:d.value==="customer_service"}),label:o("payment.customer.cancel.feedback.customer_service")}),e.jsx(D,{value:"too_complex",control:e.jsx(M,{checked:d.value==="too_complex"}),label:o("payment.customer.cancel.feedback.too_complex")}),e.jsx(D,{value:"low_quality",control:e.jsx(M,{checked:d.value==="low_quality"}),label:o("payment.customer.cancel.feedback.low_quality")}),e.jsx(D,{value:"other",control:e.jsx(M,{checked:d.value==="other"}),label:o("payment.customer.cancel.feedback.other")})]})}),e.jsx(Pe,{name:"cancel.comment",control:p,rules:{maxLength:{value:200,message:o("common.maxLength",{len:200})}},render:({field:d})=>e.jsx(Me,{variant:"outlined",size:"small",fullWidth:!0,multiline:!0,minRows:2,maxRows:4,placeholder:o("payment.customer.cancel.comment"),...d,slotProps:{htmlInput:{maxLength:200}}})})]})}const bt=(t,o)=>S.get(`/api/subscriptions/${t}/cycle-amount`,{params:o}).then(p=>p.data);function De(t,...o){if(!o.length)return"0";const p=t?.decimal||18,d=o.reduce((w,x)=>{if(!x||typeof x!="string"||!/^-?\d*\.?\d*$/.test(x.trim()))return w;const b=x.trim();if(b===""||b==="-")return w;try{const a=Ke(b,p);return new L(w).add(new L(a))}catch{return w}},new L(0));return O(d.toString(),p)}function vt({value:t,loading:o,onSave:p,onCancel:d,open:w,stakingAddress:x="",payerAddress:b="",currency:a,subscription:P,initValues:j=null}){const{t:s,locale:N}=ie(),{isMobile:_}=nt(),[T,q]=Y.useState(!1),[c,R]=Y.useState([]),{data:z={amount:"0",gas:"0"},loading:H}=W(()=>bt(P.id,{overdraftProtection:!0}),{refreshDeps:[P.id],onSuccess:l=>{const k=(()=>{const{interval:u,interval_count:r}=P.pending_invoice_item_interval;switch(u){case"hour":return[{cycles:Math.ceil(24/r),label:"1 day"},{cycles:Math.ceil(168/r),label:"1 week"},{cycles:Math.ceil(720/r),label:"1 month"},{cycles:Math.ceil(2160/r),label:"3 months"},{cycles:Math.ceil(4320/r),label:"6 months"}];case"day":return[{cycles:Math.ceil(7/r),label:"1 week"},{cycles:Math.ceil(30/r),label:"1 month"},{cycles:Math.ceil(90/r),label:"3 months"},{cycles:Math.ceil(180/r),label:"6 months"},{cycles:Math.ceil(365/r),label:"1 year"}];default:return[{cycles:1,label:"1x"},{cycles:2,label:"2x"},{cycles:3,label:"6x"},{cycles:6,label:"6x"},{cycles:12,label:"12x"}]}})(),F=u=>O(new L(l.amount).mul(new L(u)).toString(),l?.currency?.decimal);R(k.map(({cycles:u,label:r})=>({amount:F(u),cycles:u,label:r})))}}),h=Te({defaultValues:{enabled:!!P.overdraft_protection?.enabled,return_stake:!1,amount:"0",...j||{}},mode:"onChange"}),C=h.watch("enabled"),A=h.watch("amount"),m=O(z.amount,a?.decimal),$=O(t.unused,a?.decimal),K=O(t.used,a?.decimal),f=O(new L(z.amount).sub(new L(t.unused)).toString(),a?.decimal),B=()=>{q(!0),h.setValue("amount",Number(f)<0?m:f)},le=()=>{h.handleSubmit(async l=>{await p(l)})()},X=l=>{const{interval:k,interval_count:F}=P.pending_invoice_item_interval,u=l*F;return["hour","day","week","month","year"].includes(k)?s("common.estimatedDuration",{duration:dt(u,k,{t:s})}):s("customer.overdraftProtection.estimatedDuration",{duration:u,unit:s("customer.overdraftProtection.intervals").toLowerCase()})},de=()=>V(P.paymentMethod?.settings.arcblock?.explorer_host,"/stakes",x,"/tokens");Ye(()=>{h&&h.reset()});const Q=l=>{h.reset(),d(l)};return e.jsx(Ne,{open:w,onClose:Q,maxWidth:"sm",fullWidth:!0,className:"base-dialog",title:e.jsxs(g,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(y,{variant:"h6",component:"span",children:s("customer.overdraftProtection.setting")}),e.jsx(be,{href:"https://www.arcblock.io/content/blog/en/payment-kit-v117-sub-guard#listen-to-the-audio-overview",target:"_blank",rel:"noopener noreferrer",underline:"hover",sx:{display:"flex",alignItems:"center",gap:.5,fontSize:"14px",fontWeight:"normal",ml:1,color:"text.link","&:hover":{color:"primary.main"},..._?{fontSize:"12px"}:{}},children:e.jsx(ce,{title:s("customer.overdraftProtection.learnMore"),placement:"top",children:e.jsx(He,{fontSize:"small",sx:{fontSize:"16px",color:"text.secondary",cursor:"pointer","&:hover":{color:"primary.main"}}})})})]}),actions:e.jsxs(g,{direction:"row",spacing:2,children:[e.jsx(ne,{variant:"outlined",onClick:Q,children:s("common.cancel")}),e.jsxs(ne,{variant:"contained",color:"primary",disabled:o,onClick:le,children:[o&&e.jsx(qe,{size:20,sx:{mr:1}}),s("common.submit")]})]}),children:e.jsxs(g,{sx:{gap:2},children:[e.jsx(se,{severity:"info",children:t.used!=="0"&&!C?e.jsx(e.Fragment,{children:s("customer.overdraftProtection.disableConfirm")}):e.jsxs(G,{children:[s("customer.overdraftProtection.tip"),e.jsx(ce,{title:s("customer.overdraftProtection.ruleTip",{gas:O(z.gas,a?.decimal),symbol:a.symbol}),placement:"top",children:e.jsx(y,{variant:"body2",sx:{color:"text.link",cursor:"pointer",mt:1},children:s("customer.overdraftProtection.rule")})})]})}),e.jsxs(g,{spacing:2,direction:"row",sx:{alignItems:"center"},children:[e.jsx(y,{variant:"subtitle1",sx:{color:"text.secondary"},children:s("customer.overdraftProtection.title")}),e.jsx(D,{control:e.jsx(ot,{checked:C,onChange:l=>h.setValue("enabled",l.target.checked)}),label:""})]}),C?e.jsxs(g,{sx:{gap:1,mt:"-8px"},children:[b&&e.jsxs(g,{sx:_?{flexDirection:"column",gap:1}:{flexDirection:"row",alignItems:"center",gap:2},children:[e.jsx(y,{variant:"subtitle2",sx:{color:"text.secondary"},children:s("customer.overdraftProtection.payerAddress")}),e.jsx(y,{variant:"body2",sx:{wordBreak:"break-all",fontFamily:"monospace",fontWeight:"700"},children:b})]}),x&&e.jsxs(g,{sx:_?{flexDirection:"column",gap:1}:{flexDirection:"row",alignItems:"center",gap:2},children:[e.jsx(y,{variant:"subtitle2",sx:{color:"text.secondary"},children:s("customer.overdraftProtection.stakingAddress")}),e.jsxs(be,{href:de(),target:"_blank",rel:"noopener noreferrer",sx:{wordBreak:"break-all",fontFamily:"monospace",fontWeight:"700",textDecoration:"none",color:"text.link",display:"flex",flexWrap:"wrap",alignItems:"center",gap:1},children:[x,!_&&e.jsx(Ue,{fontSize:"small"})]})]}),e.jsx(y,{variant:"body2",sx:{color:"text.secondary"},children:Number(K)>0&&!t.enabled?s("customer.overdraftProtection.remainingNotEnough",{due:K,symbol:a.symbol,min:Number(f)<0?m:f,unused:$}):t.remaining==="0"?s("customer.overdraftProtection.noRemaining",{estimateAmount:m,symbol:a.symbol}):s("customer.overdraftProtection.remaining",{amount:$,symbol:a.symbol,estimateAmount:m})}),e.jsx(te,{container:!0,spacing:2,sx:{ml:-2,mt:-1},children:H?e.jsxs(e.Fragment,{children:[[1,2,3,4,5].map(l=>e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%"},children:e.jsx(re,{sx:{height:"100%",p:1},children:e.jsxs(g,{spacing:1,sx:{alignItems:"center"},children:[e.jsx(fe,{variant:"rectangular",width:80,height:32}),e.jsx(fe,{width:100})]})})})},l)),e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%"},children:e.jsx(re,{sx:{height:"100%",p:2},children:e.jsx(g,{spacing:1,sx:{alignItems:"center"},children:e.jsx(fe,{variant:"rectangular",width:80,height:24})})})})})]}):e.jsxs(e.Fragment,{children:[c.map(({amount:l,cycles:k})=>e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%",transition:"all 0.3s",cursor:"pointer","&:hover":{transform:"translateY(-4px)",boxShadow:3},...A===l&&!T?{borderColor:"primary.main",borderWidth:1}:{}},children:e.jsx(re,{onClick:()=>{h.setValue("amount",l),q(!1)},sx:{height:"100%",p:1},children:e.jsxs(g,{spacing:1,sx:{alignItems:"center"},children:[e.jsxs(y,{variant:"h6",sx:{fontWeight:600},children:[l," ",a.symbol]}),e.jsx(y,{variant:"caption",sx:{color:"text.secondary"},children:X(k)})]})})})},l)),e.jsx(te,{size:{xs:6,sm:4},children:e.jsx(ae,{variant:"outlined",sx:{height:"100%",transition:"all 0.3s",cursor:"pointer","&:hover":{transform:"translateY(-4px)",boxShadow:3},...T?{borderColor:"primary.main",borderWidth:1}:{}},children:e.jsx(re,{onClick:B,sx:{height:"100%",p:2},children:e.jsx(g,{spacing:1,sx:{alignItems:"center"},children:e.jsx(y,{variant:"h6",sx:{fontWeight:600},children:s("common.custom")})})})})})]})}),T&&e.jsx(g,{spacing:2,sx:{mt:1},children:e.jsx(Ve,{fullWidth:!0,children:e.jsx(Me,{...h.register("amount",{required:!0,validate:l=>{const k=Number(f)<0?Number(m):Number(f);if(Number(l)<k)return s("customer.overdraftProtection.min",{min:k,symbol:a.symbol});if(Number(l)>ge)return s("common.maxAmount",{max:ge});const F=at(l.toString(),N,a?.maximum_precision||6);return F||!0}}),label:s("common.amount"),type:"number",error:!!h.formState.errors.amount,helperText:h.formState.errors.amount?.message,fullWidth:!0,variant:"outlined",slotProps:{input:{endAdornment:e.jsx(G,{sx:{ml:1,display:"flex",alignItems:"center"},children:e.jsx(lt,{logo:a.logo,name:a.symbol})})},htmlInput:{min:0,max:ge,step:Number(m)}}})})}),A&&Number(A)>0&&Number(m)>0&&!h.formState.errors.amount&&e.jsxs(y,{variant:"body2",sx:{fontSize:12,color:"text.lighter",mt:"8px !important"},children:[s("customer.overdraftProtection.total",{total:De(a,A,$),symbol:a.symbol}),X(Math.floor(Number(De(a,A,$))/Number(m)))]})]}):Number($)>0&&e.jsxs(g,{direction:"row",sx:{alignItems:"flex-start",gap:2},children:[e.jsx(y,{variant:"subtitle2",sx:{color:"text.secondary",height:39,display:"flex",alignItems:"center",width:56},children:s("customer.overdraftProtection.stake")}),e.jsxs($e,{"aria-labelledby":"return-stake-group-label",value:h.watch("return_stake"),onChange:l=>h.setValue("return_stake",l.target.value==="true"),children:[e.jsx(D,{value:!1,control:e.jsx(M,{}),label:s("customer.overdraftProtection.keepStake")}),e.jsx(D,{value:!0,control:e.jsx(M,{color:"warning"}),label:s("customer.overdraftProtection.returnStake")})]})]})]})})}const jt=async t=>{try{return!!(await S.get(`/api/subscriptions/${t}/change-plan`)).data}catch{return!1}},kt=async t=>{try{const o=await S.get(`/api/subscriptions/${t}/summary`);return!Qe(o.data)&&Object.keys(o.data).length===1?Object.keys(o.data)[0]:""}catch{return""}},ye=t=>["active","trialing","past_due"].includes(t?.status)&&["arcblock","ethereum","base"].includes(t?.paymentMethod?.type)&&t.paymentCurrency?.type!=="credit";function wt({subscription:t,showExtra:o=!1,showRecharge:p=!1,showOverdraftProtection:d=!1,showDelegation:w=!1,showUnsubscribe:x=!0,onChange:b=void 0,actionProps:a={},mode:P="all-buttons",setUp:j=void 0,showBalanceInfo:s=!1,includeActions:N=null,excludeActions:_=null,forceShowDetailAction:T=!1,buttonSize:q="small"}){const{t:c,locale:R}=ie(),{reset:z,getValues:H}=Le(),h=ht(),{connect:C,session:A}=Fe(),[m,$]=Y.useState(t),{checkUnpaidInvoices:K}=mt(t.id,!0),f=st(m,a??{}),B=i=>_&&_.length>0?!_.includes(i):N&&N.length>0?N.includes(i):!0,le=i=>{const I=i?.metadata?.credit_config?.schedule;return I?.enabled&&I?.delivery_mode==="schedule"},X=(t.items||[]).some(i=>le(i.price)),{data:de=!1}=W(()=>jt(t.id),{ready:!!o&&ut(t)&&!X}),{data:Q=""}=W(()=>kt(t.id),{ready:!!o}),{data:l={}}=W(()=>S.get(`/api/subscriptions/${t.id}/upcoming`).then(i=>i.data),{ready:B("recharge")&&!!(p&&ye(t))&&s}),{data:k={}}=W(()=>S.get(`/api/subscriptions/${t.id}/payer-token`).then(i=>i.data),{ready:B("recharge")&&!!(p&&ye(t))&&s}),F=l?.amount&&k?.token&&new L(k.token||"0").lt(new L(l.amount||"0")),[u,r]=Xe({action:"",subscription:"",loading:!1,openProtection:!1,protectionLoading:!1,protectionInitValues:null,batchPay:!1}),je=w&&["active","trialing","past_due"].includes(t?.status),ue=(typeof d=="boolean"&&d||typeof d=="object"&&d.show)&&t?.paymentMethod?.type==="arcblock"&&["active","trialing","past_due"].includes(t?.status)&&B("protection"),{data:me={sufficient:!0},refresh:Re}=W(()=>S.get(`/api/subscriptions/${t.id}/delegation`).then(i=>i.data),{ready:B("delegation")&&je,refreshDeps:[t.id,je]}),We=me&&typeof me=="object"&&!me.sufficient,{data:ke={enabled:!1,remaining:"0"},refresh:he}=W(()=>S.get(`/api/subscriptions/${t.id}/overdraft-protection`).then(i=>i.data),{ready:ue,refreshDeps:[t.id,ue]});Y.useEffect(()=>{j&&j({openOverdraftProtection:i=>r({openProtection:!0,protectionInitValues:i})})},[j]);const ze=async()=>{try{if(await K()){r({action:""});return}r({loading:!0});const I=await S.put(`/api/subscriptions/${u.subscription}/cancel`,{at:"current_period_end",...H().cancel,cancel_from:"customer"}).then(Z=>Z.data);$(I),v.success(c("common.saved")),b&&b(u.action)}catch(i){console.error(i),v.error(U(i))}finally{r({loading:!1,action:"",subscription:""}),z()}},Be=()=>{C.open({containerEl:void 0,saveConnect:!1,action:"delegation",locale:R,prefix:V(ve(),"/api/did"),extraParams:{subscriptionId:t.id,sessionUserDid:A.user.did},messages:{scan:c("common.connect.defaultScan"),title:c("customer.delegation.title"),confirm:c("common.connect.confirm")},onSuccess:()=>{C.close(),v.success(c("customer.delegation.success")),Re()},onClose:()=>{C.close()},onError:i=>{v.error(U(i))}})},Ee=async i=>{try{if(!i.enabled&&await K()){r({openProtection:!1});return}r({protectionLoading:!0});const I=await S.post(`/api/subscriptions/${t.id}/overdraft-protection`,i).then(pe=>pe.data),{open:Z,amount:oe}=I;if(i.return_stake&&ke.remaining!=="0"){v.success(c("customer.overdraftProtection.applyRemainingSuccess")),r({openProtection:!1}),he(),d?.onChange?.(),b?.();return}Z?C.open({containerEl:void 0,saveConnect:!1,locale:R,action:"overdraft-protection",prefix:V(ve(),"/api/did"),extraParams:{subscriptionId:t.id,amount:oe,sessionUserDid:A.user.did},messages:{scan:c("common.connect.defaultScan"),title:c("customer.overdraftProtection.title"),confirm:c("common.connect.confirm")},onSuccess:()=>{C.close(),t.overdraft_protection?.enabled?v.success(c("customer.overdraftProtection.settingSuccess")):v.success(c("customer.overdraftProtection.openSuccess")),r({openProtection:!1}),he(),d?.onChange?.(),b?.()},onClose:()=>{C.close(),r({protectionLoading:!1})}}):(v.success(c("customer.overdraftProtection.closeSuccess")),r({openProtection:!1}),he(),d?.onChange?.(),b?.())}catch(I){throw v.error(U(I)||c("customer.overdraftProtection.settingError")),I}finally{r({protectionLoading:!1})}},Oe=()=>{const i=f?.action==="cancel"&&x,I=f&&(f?.action!=="cancel"||i),Z=Ae(t)&&f?.action==="recover",oe=t.service_actions?.filter(n=>n?.type!=="notification")||[],J=[{key:"delegation",show:w&&We,label:c("customer.delegation.btn"),tooltip:c("customer.delegation.title"),onClick:Be,variant:a?.delegation?.variant||"outlined",color:a?.delegation?.color||"primary",primary:!0},{key:"protection",show:ue,label:c("customer.overdraftProtection.setting"),onClick:()=>r({openProtection:!0,protectionInitValues:null}),variant:a?.protection?.variant||"outlined",color:a?.protection?.color||"primary"},{key:"recharge",show:!!(p&&ye(t)),label:()=>{const n=e.jsxs(g,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx(Ge,{fontSize:"small"}),c("customer.recharge.title")]});if(s&&t.paymentCurrency){const E=_e(k?.token||"0",t.paymentCurrency.decimal),ee=_e(l?.amount||"0",t.paymentCurrency.decimal);return e.jsx(ce,{title:e.jsxs(G,{children:[F&&e.jsx(se,{severity:"error",sx:{py:0,mb:1},children:c("admin.subscription.insufficientBalance")}),e.jsxs(g,{spacing:.5,children:[e.jsxs(G,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y,{sx:{color:"text.secondary"},variant:"body2",children:c("admin.subscription.currentBalance")}),e.jsxs(y,{variant:"body2",children:[E," ",t.paymentCurrency.symbol]})]}),e.jsxs(G,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y,{sx:{color:"text.secondary"},variant:"body2",children:c("admin.subscription.nextInvoiceAmount")}),e.jsxs(y,{variant:"body2",children:[ee," ",t.paymentCurrency.symbol]})]}),e.jsxs(G,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(y,{sx:{color:"text.secondary"},variant:"body2",children:c("admin.subscription.paymentAddress")}),e.jsx(Ze,{did:k?.paymentAddress,responsive:!1,compact:!0,showAvatar:!1})]})]})]}),placement:"top",slotProps:{tooltip:{sx:{bgcolor:"background.paper",color:"text.primary",boxShadow:2,padding:"10px 16px",maxWidth:480,minWidth:350,wordBreak:"break-word"}}},children:n})}return n},labelText:c("customer.recharge.title"),onClick:n=>{n?.stopPropagation(),h(`/customer/subscription/${t.id}/recharge`)},variant:a?.recharge?.variant||"outlined",color:a?.recharge?.color||"primary",primary:!Ae(t),sx:F||k.token==="0"?{"&::before":{content:'""',backgroundColor:"error.main",borderRadius:"50%",position:"absolute",top:"3px",right:"-3px",width:"6px",height:"6px",zIndex:1},...a?.recharge?.sx||{}}:a?.recharge?.sx||{}},{key:"changePlan",show:de&&!X,label:f?.text||c("payment.customer.changePlan.button"),onClick:n=>{n?.stopPropagation(),h(`/customer/subscription/${t.id}/change-plan`)},variant:a?.changePlan?.variant||"contained",color:a?.changePlan?.color||"primary",sx:a?.changePlan?.sx},{key:"batchPay",show:!!Q,label:f?.text||c("admin.subscription.batchPay.button"),onClick:n=>{n?.stopPropagation(),r({batchPay:!0})},variant:a?.batchPay?.variant||"outlined",color:a?.batchPay?.color||"error",sx:a?.batchPay?.sx,primary:!0},{key:"mainAction",show:!!(!Q&&I),label:f?.text||c(`payment.customer.${f?.action}.button`),onClick:n=>{n?.stopPropagation(),f?.action==="pastDue"?h(`/customer/invoice/past-due?subscription=${t.id}`):f?.action==="recover"&&!t.paymentMethodDetails?v.error(c("admin.subscription.bindPaymentMethodFirst")):r({action:f?.action,subscription:t.id})},variant:f?.variant||"outlined",color:f?.color||"primary",sx:f?.sx,divider:oe.length>0,primary:Z},...oe.map(n=>({key:n.name,show:!0,label:n.text[R]||n.text.en||n.name,onClick:()=>window.open(n.link,"_blank"),variant:n?.variant||"contained",color:n?.color||"primary",component:be,href:n.link,target:"_blank",sx:{textDecoration:"none !important"}}))].filter(n=>n.show&&B(n.key)),we=n=>({label:n.labelText||(typeof n.label=="function"?n.label():n.label),handler:n.onClick,color:n.color,divider:n.divider}),xe=T&&e.jsx(ne,{className:"action-button",sx:a?.detail?.sx||{},variant:a?.detail?.variant||"outlined",color:a?.detail?.color||"primary",onClick:()=>h(`/customer/subscription/${t.id}`),children:c("customer.subscription.manage")},"detail"),Ce=n=>{const E=typeof n.label=="function"?n.label():n.label;return e.jsx(ne,{variant:n.variant,color:n.color,onClick:n.onClick,component:n.component,href:n.href,target:n.target,sx:n.sx,className:"action-button",size:q,children:n.tooltip?e.jsx(ce,{title:n.tooltip,children:e.jsx("span",{children:E})}):E},n.key)};if(P==="menu-only")return e.jsxs(e.Fragment,{children:[xe,J.length>0&&e.jsx(Ie,{actions:J.map(we),variant:"outlined",sx:a?.menu?.sx||{}})]});if(P==="primary-buttons"){const n=J.filter(ee=>ee.primary),E=J.filter(ee=>!ee.primary);return e.jsxs(e.Fragment,{children:[xe,n.map(Ce),E.length>0&&e.jsx(Ie,{actions:E.map(we),variant:"outlined",sx:a?.menu?.sx||{}})]})}return e.jsxs(e.Fragment,{children:[xe,J.map(Ce)]})};return e.jsxs(g,{direction:"row",sx:{alignItems:"center",gap:1,flexWrap:"wrap"},children:[Oe(),u.action==="cancel"&&u.subscription&&e.jsx(ct,{onConfirm:ze,onCancel:i=>{i.stopPropagation(),r({action:"",subscription:""})},title:c("payment.customer.cancel.title"),message:e.jsx(yt,{data:t}),loading:u.loading}),u.action==="recover"&&u.subscription&&e.jsx(gt,{subscriptionId:u.subscription,onResumed:i=>{r({action:"",subscription:""}),b?.(u.action),$(i)},dialogProps:{open:!0,onClose:()=>r({action:"",subscription:""})}}),u.openProtection&&e.jsx(vt,{value:ke,onSave:Ee,open:u.openProtection,payerAddress:t.overdraft_protection?.payment_details?.arcblock?.payer,stakingAddress:t.overdraft_protection?.payment_details?.arcblock?.staking?.address,currency:t.paymentCurrency,subscription:t,loading:u.protectionLoading,onCancel:()=>r({openProtection:!1}),initValues:u.protectionInitValues}),u.batchPay&&e.jsx(it,{subscriptionId:t.id,onPaid:()=>{r({batchPay:!1}),b?.("batch-pay")},detailLinkOptions:{enabled:!1},dialogProps:{open:u.batchPay,onClose:()=>r({batchPay:!1})}})]})}function Nt(t){const o=Object.assign({showExtra:!1,showRecharge:!1,showBalanceInfo:!1,showOverdraftProtection:!1,showDelegation:!1,onChange:null,actionProps:{},mode:"all-buttons",setUp:null,showUnsubscribe:!0,includeActions:null,excludeActions:null,forceShowDetailAction:!1,buttonSize:"small"},t),p=Te({defaultValues:{cancel:{at:"current_period_end",feedback:"unused",comment:""}}});return e.jsx(rt,{...p,children:e.jsx(wt,{...o})})}export{Nt as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,r as R,a3 as S,a_ as P,aX as c,a$ as p,aQ as $,a2 as C,aZ as w,aR as N}from"./vendor-mui-BXZut9Pz.js";import{V as v,Y as T,P as V,Z as y,H as E}from"./vendor-blocklet-
|
|
1
|
+
import{j as e,r as R,a3 as S,a_ as P,aX as c,a$ as p,aQ as $,a2 as C,aZ as w,aR as N}from"./vendor-mui-BXZut9Pz.js";import{V as v,Y as T,P as V,Z as y,H as E}from"./vendor-blocklet-B67R14so.js";import{h as H,F as B,E as I,I as L,e as F,C as b,k as W,G as z}from"./index-B4yaPb7B.js";import{A as D}from"./actions-BEUwbsq1.js";import{C as G}from"./click-boundary-Bi28Y0Fq.js";import{a as O}from"./vendor-react-BPknnnEA.js";function _(n,a,t=6){if(!n)return"0";const o=E(n,a),[s="0",u=""]=o.split(".");if(t<=0)return s;const m=u.substring(0,t).replace(/0+$/,"");return m?`${s}.${m}`:s}const U=n=>F.get(`/api/payment-intents/${n}/refundable-amount`).then(a=>a.data);function Z({data:n,refundMaxAmount:a}){const{t,locale:o}=v(),{control:s,setValue:u,formState:{errors:m}}=I(),x=r=>{if(Number(r)<=0||Number(r)>Number(a))return t("admin.paymentIntent.refundForm.amountRange",{min:0,max:a,symbol:n.paymentCurrency.symbol});const l=z(r.toString(),o,n.paymentCurrency.maximum_precision||6);return l||!0};return e.jsxs(S,{direction:"column",spacing:1,sx:{alignItems:"flex-start",width:400},children:[e.jsx(b,{name:"refund.reason",control:s,render:({field:r})=>e.jsxs(P,{...r,sx:{ml:"5px !important"},children:[e.jsx(c,{value:"duplicate",control:e.jsx(p,{checked:r.value==="duplicate"}),label:t("admin.paymentIntent.refundForm.duplicate"),onClick:()=>u("refund.reason","duplicate")}),e.jsx(c,{value:"requested_by_customer",control:e.jsx(p,{checked:r.value==="requested_by_customer"}),label:t("admin.paymentIntent.refundForm.requestedByCustomer"),onClick:()=>u("refund.reason","requested_by_customer")}),e.jsx(c,{value:"requested_by_admin",control:e.jsx(p,{checked:r.value==="requested_by_admin"}),label:t("admin.paymentIntent.refundForm.requestedByAdmin"),onClick:()=>u("refund.reason","requested_by_admin")}),e.jsx(c,{value:"fraudulent",control:e.jsx(p,{checked:r.value==="fraudulent"}),label:t("admin.paymentIntent.refundForm.fraudulent"),onClick:()=>u("refund.reason","fraudulent")}),e.jsx(c,{value:"expired_uncaptured_charge",control:e.jsx(p,{checked:r.value==="expired_uncaptured_charge"}),label:t("admin.paymentIntent.refundForm.expiredUncapturedCharge"),onClick:()=>u("refund.reason","expired_uncaptured_charge")})]})}),e.jsxs($,{fullWidth:!0,component:"fieldset",variant:"outlined",children:[e.jsx(b,{name:"refund.amount",control:s,rules:{validate:x},render:({field:r})=>e.jsx(C,{...r,variant:"outlined",size:"small",type:"number",fullWidth:!0,placeholder:t("admin.paymentIntent.refundForm.amount"),error:!!m?.refund?.amount,helperText:m?.refund?.amount?.message,slotProps:{input:{endAdornment:e.jsx(w,{position:"end",children:n.paymentCurrency.symbol})}}})}),e.jsx(N,{children:t("admin.paymentIntent.refundForm.amountHelper",{min:0,max:a,symbol:n.paymentCurrency.symbol})})]}),e.jsx(b,{name:"refund.description",control:s,rules:{required:t("common.required"),validate:r=>r.trim()!==""||t("common.required")},render:({field:r})=>e.jsx(C,{...r,variant:"outlined",size:"small",fullWidth:!0,multiline:!0,minRows:2,maxRows:4,placeholder:t("admin.paymentIntent.refundForm.description"),error:!!m?.refund?.description,helperText:m?.refund?.description?.message,slotProps:{htmlInput:{maxLength:200}}})})]})}function M({data:n,variant:a="compact",onChange:t}){const{t:o}=v(),s=O(),{reset:u,getValues:m,setValue:x,handleSubmit:r}=I(),[l,f]=T({action:"",loading:!1}),[j,k]=R.useState("0"),A=n.payment_details?.arcblock?.type==="slash"&&n.paymentMethod?.type==="arcblock",{runAsync:h}=V(()=>A?Promise.resolve({amount:"0"}):U(n.id),{onSuccess:d=>{const i=_(d?.amount,n.paymentCurrency.decimal);k(i)},manual:!0}),q=async()=>{const{refund:d}=m();if(!d.amount||!d.reason||!d.description){y.warning(o("admin.paymentIntent.refundForm.required"));return}try{f({loading:!0}),await F.put(`/api/payment-intents/${n.id}/refund`,d).then(i=>i.data),y.success(o("admin.paymentIntent.refundSuccess")),t("refund"),h()}catch(i){console.error(i),y.error(W(i))}finally{f({loading:!1,action:""})}},g=[{label:o("admin.paymentIntent.refund"),handler:()=>{h().then(d=>{u();const i=_(d?.amount,n.paymentCurrency.decimal);if(Number(i)<=0){y.info(o("admin.paymentIntent.refundForm.empty"));return}x("refund.amount",i),f({action:"refund"})})},color:"primary",disabled:Number(j)<=0,divider:!0},{label:o("admin.customer.view"),handler:()=>s(`/admin/customers/${n.customer_id}`),color:"primary",disabled:!1}];return a==="compact"&&g.push({label:o("admin.paymentIntent.view"),handler:()=>s(`/admin/payments/${n.id}`),color:"primary",disabled:!1}),e.jsxs(G,{children:[e.jsx(D,{variant:a,actions:g,onOpenCallback:h}),l.action==="refund"&&e.jsx(L,{onConfirm:r(q),onCancel:()=>f({action:""}),title:o("admin.paymentIntent.refund"),message:e.jsx(Z,{data:n,refundMaxAmount:j}),loading:l.loading})]})}function ne(n){const a=Object.assign({variant:"compact"},n),t=H({mode:"onChange",defaultValues:{refund:{reason:"requested_by_admin",description:""}}});return e.jsx(B,{...t,children:e.jsx(M,{...a})})}export{ne as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,a3 as P,x as b,w as x}from"./vendor-mui-BXZut9Pz.js";import{V as L,$ as C,Y as j,Z as r,_ as S,F as f}from"./vendor-blocklet-
|
|
1
|
+
import{j as t,a3 as P,x as b,w as x}from"./vendor-mui-BXZut9Pz.js";import{V as L,$ as C,Y as j,Z as r,_ as S,F as f}from"./vendor-blocklet-B67R14so.js";import{h as M,F as T,aX as $,I as y,e as m,k as c}from"./index-B4yaPb7B.js";import{A}from"./actions-BEUwbsq1.js";import{C as F}from"./click-boundary-Bi28Y0Fq.js";import{A as E}from"./assign-DKRfmN7W.js";function R({data:a,loading:d,onSave:l,onCancel:n}){const{t:o}=L(),e=M({defaultValues:{name:a.name}}),{handleSubmit:k,reset:u}=e,h=()=>{k(async g=>{await l(g),u(),n(null)})()};return t.jsx(C,{open:!0,disableEscapeKeyDown:!0,fullWidth:!0,maxWidth:"sm",className:"base-dialog",onClose:()=>n(null),showCloseButton:!1,title:o("admin.paymentLink.rename"),actions:t.jsxs(P,{direction:"row",children:[t.jsx(b,{size:"small",sx:{mr:2},onClick:n,children:o("common.cancel")}),t.jsxs(b,{variant:"contained",color:"primary",size:"small",disabled:d,onClick:h,children:[d&&t.jsx(x,{size:"small"})," ",o("common.save")]})]}),children:t.jsx(T,{...e,children:t.jsx($,{name:"name",rules:{required:!0},label:o("admin.paymentLink.name.label"),placeholder:o("admin.paymentLink.name.placeholder"),autoFocus:!0})})})}function W({data:a,variant:d="compact",onChange:l}){const{t:n}=L(),[o,e]=j({action:"",loading:!1}),k=async i=>{try{e({loading:!0}),await m.put(`/api/payment-links/${a.id}`,i).then(s=>s.data),r.success(n("common.saved")),l(o.action)}catch(s){console.error(s),r.error(c(s))}finally{e({loading:!1,action:""})}},u=async()=>{try{e({loading:!0}),await m.put(`/api/payment-links/${a.id}/archive`).then(i=>i.data),r.success(n("common.saved")),l(o.action)}catch(i){console.error(i),r.error(c(i))}finally{e({loading:!1,action:""})}},h=async()=>{try{e({loading:!0}),await m.delete(`/api/payment-links/${a.id}`).then(i=>i.data),r.success(n("common.removed")),l(o.action)}catch(i){console.error(i),r.error(c(i))}finally{e({loading:!1,action:""})}},g=async()=>{try{e({loading:!0}),await m.put(`/api/payment-links/${a.id}`,{allow_promotion_codes:!a.allow_promotion_codes}).then(i=>i.data),r.success(n("common.saved")),l(o.action)}catch(i){console.error(i),r.error(c(i))}finally{e({loading:!1,action:""})}},w=async()=>{const i=a.metadata||{},s=i.allow_skip_payment_method==="true";try{e({loading:!0}),await m.put(`/api/payment-links/${a.id}`,{metadata:{...i,allow_skip_payment_method:s?"false":"true"}}).then(p=>p.data),r.success(n("common.saved")),l(o.action)}catch(p){console.error(p),r.error(c(p))}finally{e({loading:!1,action:""})}},_=()=>{S(f(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pay/${a.id}`)),r.success(n("common.copied"))},v=()=>{window.open(f(window.blocklet.appUrl,window.blocklet.prefix,`/checkout/pay/${a.id}`))};return t.jsxs(F,{children:[t.jsx(A,{variant:d,actions:[{label:n("admin.paymentLink.openLink"),handler:v,color:"primary"},{label:n("admin.paymentLink.copyLink"),handler:_,color:"primary"},{label:n("admin.paymentLink.rename"),handler:()=>e({action:"rename"}),color:"primary"},{label:n("admin.paymentLink.archive"),handler:()=>e({action:"archive"}),color:"primary"},{label:n("admin.paymentLink.remove"),handler:()=>e({action:"remove"}),color:"error",divider:!0},{label:a.allow_promotion_codes?n("admin.paymentLink.disablePromotionCodes"):n("admin.paymentLink.enablePromotionCodes"),handler:()=>e({action:"togglePromotionCodes"}),color:"primary"},{label:a.metadata?.allow_skip_payment_method==="true"?n("admin.paymentLink.disableSkipPaymentMethod"):n("admin.paymentLink.enableSkipPaymentMethod"),handler:()=>e({action:"toggleSkipPaymentMethod"}),color:"primary"},{label:n("admin.passport.assign"),handler:()=>e({action:"assign"}),color:"primary",disabled:!a.active}]}),o.action==="rename"&&t.jsx(R,{data:a,loading:o.loading,onSave:k,onCancel:()=>e({action:""})}),o.action==="assign"&&t.jsx(E,{id:a.id,onCancel:()=>e({action:""})}),o.action==="archive"&&t.jsx(y,{onConfirm:u,onCancel:()=>e({action:""}),title:n("admin.paymentLink.archive"),message:n("admin.paymentLink.archiveTip"),loading:o.loading}),o.action==="remove"&&t.jsx(y,{onConfirm:h,onCancel:()=>e({action:""}),title:n("admin.paymentLink.remove"),message:n("admin.paymentLink.removeTip"),loading:o.loading}),o.action==="toggleSkipPaymentMethod"&&t.jsx(y,{onConfirm:w,onCancel:()=>e({action:""}),title:a.metadata?.allow_skip_payment_method==="true"?n("admin.paymentLink.disableSkipPaymentMethod"):n("admin.paymentLink.enableSkipPaymentMethod"),message:a.metadata?.allow_skip_payment_method==="true"?n("admin.paymentLink.disableSkipPaymentMethodTip"):n("admin.paymentLink.enableSkipPaymentMethodTip"),loading:o.loading}),o.action==="togglePromotionCodes"&&t.jsx(y,{onConfirm:g,onCancel:()=>e({action:""}),title:a.allow_promotion_codes?n("admin.paymentLink.disablePromotionCodes"):n("admin.paymentLink.enablePromotionCodes"),message:a.allow_promotion_codes?n("admin.paymentLink.disablePromotionCodesTip"):n("admin.paymentLink.enablePromotionCodesTip"),loading:o.loading})]})}export{W as P};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s,a3 as h,x as a,w as f}from"./vendor-mui-BXZut9Pz.js";import{V as j,$ as p}from"./vendor-blocklet-
|
|
1
|
+
import{j as s,a3 as h,x as a,w as f}from"./vendor-mui-BXZut9Pz.js";import{V as j,$ as p}from"./vendor-blocklet-B67R14so.js";import{a as P,h as b,F as y}from"./index-B4yaPb7B.js";import{D as C,a as w}from"./form-AFzUvoFE.js";import{P as F}from"./product-select-_72p-5lF.js";function z({loading:o,onSave:i,onCancel:e,productType:n=""}){const{t:r}=j(),{settings:c}=P(),t=b({mode:"onChange",defaultValues:{...C,currency_id:c.baseCurrency.id}}),{handleSubmit:m,reset:l,formState:{errors:d}}=t,u=()=>{Object.keys(d).length>0||m(async x=>{await i(x),l(),e(null)})()};return s.jsx(p,{open:!0,disableEscapeKeyDown:!0,fullWidth:!0,maxWidth:"sm",className:"base-dialog",onClose:()=>e(null),showCloseButton:!1,title:r("admin.price.add"),actions:s.jsxs(h,{direction:"row",children:[s.jsx(a,{size:"small",sx:{mr:2},onClick:e,children:r("common.cancel")}),s.jsxs(a,{variant:"contained",color:"primary",size:"small",disabled:o,onClick:u,children:[o&&s.jsx(f,{size:"small"})," ",r("common.save")]})]}),children:s.jsx(y,{...t,children:s.jsx(F,{children:s.jsx(w,{productType:n})})})})}export{z as A};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as e,B as d,w as s,bf as p}from"./vendor-mui-BXZut9Pz.js";import{ar as c}from"./vendor-blocklet-
|
|
1
|
+
import{r as i,j as e,B as d,w as s,bf as p}from"./vendor-mui-BXZut9Pz.js";import{ar as c}from"./vendor-blocklet-B67R14so.js";import{u,P as g}from"./index-B4yaPb7B.js";function n(){return e.jsx(d,{sx:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(s,{})})}function l(){const o=window.blocklet;return!!(o&&o.appPid&&o.prefix)}const x=p(c)`
|
|
2
2
|
width: 100%;
|
|
3
3
|
background-color: ${({theme:o})=>o.palette.background.default};
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as s,A as f,w as h,B as j,q as p,aT as C,ad as y}from"./vendor-mui-BXZut9Pz.js";import{V as v,P as A,Z as d}from"./vendor-blocklet-
|
|
1
|
+
import{r as m,j as s,A as f,w as h,B as j,q as p,aT as C,ad as y}from"./vendor-mui-BXZut9Pz.js";import{V as v,P as A,Z as d}from"./vendor-blocklet-B67R14so.js";import{I as i,e as g}from"./index-B4yaPb7B.js";const E=()=>g.get("/api/passports").then(a=>a.data);function S(a){const{t:e}=v(),{loading:u,error:c,data:r}=A(E),[n,l]=m.useState("");m.useEffect(()=>{r&&r.length&&!n&&l(r[0].name)},[r]);const o=async()=>{if(!n){d.error(e("admin.passport.assignError"));return}await g.put("/api/passports/assign",{name:n,id:a.id}),d.success(e("common.saved")),a.onCancel()};if(c)return s.jsx(i,{title:e("admin.passport.assign"),message:s.jsx(f,{severity:"error",children:c.message}),onConfirm:o,onCancel:a.onCancel,color:"primary"});if(u||!r)return s.jsx(i,{title:e("admin.passport.assign"),message:s.jsx(h,{}),onConfirm:o,onCancel:a.onCancel,color:"primary"});const x=t=>{l(t.target.value)};return s.jsx(i,{title:e("admin.passport.assign"),message:s.jsxs(j,{children:[s.jsx(p,{children:e("admin.passport.assignTip")}),s.jsx(C,{value:n,onChange:x,size:"small",children:r.map(t=>s.jsx(y,{value:t.name,children:s.jsx(p,{color:n?"text.primary":"text.secondary",children:t.title})},t.name))})]}),onConfirm:o,onCancel:a.onCancel,color:"primary"})}export{S as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u,j as e,be as D,ab as M,a0 as P,q as l,w as B,$ as f,a8 as N,e as F,bN as H,a9 as T,af as _,aG as G,cE as J,cF as $,aH as Y,x as S,a3 as h,cG as U,B as v}from"./vendor-mui-BXZut9Pz.js";import{l as b}from"./vendor-arcblock-
|
|
1
|
+
import{r as u,j as e,be as D,ab as M,a0 as P,q as l,w as B,$ as f,a8 as N,e as F,bN as H,a9 as T,af as _,aG as G,cE as J,cF as $,aH as Y,x as S,a3 as h,cG as U,B as v}from"./vendor-mui-BXZut9Pz.js";import{l as b}from"./vendor-arcblock-D1drrE7q.js";import{V,ah as Z,Y as K,P as Q,Z as C}from"./vendor-blocklet-B67R14so.js";import{e as O,j as X,I as ee}from"./index-B4yaPb7B.js";import{l as te}from"./lodash-B4Ozcv0x.js";import{v as se}from"./util-B8B3fsMa.js";import{I as ne}from"./info-card-C9dRgztS.js";function k({requestInfo:r=void 0,request:o=void 0}){const[s,t]=u.useState(null),c=i=>{t(s?null:i.currentTarget)};return u.useEffect(()=>{const i=m=>{s&&!s.contains(m.target)&&!m.target.closest(".popper-content")&&t(null)},p=m=>{s&&!m.target?.closest(".popper-content")&&t(null)};return document.addEventListener("click",i),window.addEventListener("scroll",p,!0),()=>{document.removeEventListener("click",i),window.removeEventListener("scroll",p,!0)}},[s]),e.jsxs(e.Fragment,{children:[e.jsx(D,{fontSize:"small",onClick:i=>c(i),sx:{color:"text.secondary",opacity:.6,cursor:"pointer"}}),e.jsx(M,{open:!!s,anchorEl:s,placement:"right",sx:{zIndex:1e3,"@media (max-width: 600px)":{"& .MuiPaper-root":{width:"calc(100vw - 32px)",maxWidth:"none"}}},modifiers:[{name:"preventOverflow",options:{boundary:window,altAxis:!0,padding:16}},{name:"flip",options:{fallbackPlacements:["bottom"]}},{name:"matchWidth",enabled:!0,fn:({state:i})=>(window.innerWidth<=600&&(i.styles.popper={...i.styles.popper,width:"calc(100vw - 32px)",maxWidth:"none"}),i)}],children:e.jsx(P,{className:"popper-content",elevation:3,sx:{p:2,border:"1px solid",borderColor:"divider",maxWidth:360,"@media (max-width: 600px)":{maxWidth:"none",margin:"0 auto"}},children:r?e.jsxs(e.Fragment,{children:[e.jsx(l,{variant:"caption",sx:{color:"text.secondary",mb:1,display:"block"},children:"Requested by:"}),e.jsx(ne,{logo:r.avatar,name:r.email,description:r.did||o?.requested_by,size:40})]}):e.jsxs(l,{children:["Requested by: ",o?.requested_by||"system"]})})})]})}const re=(r={})=>{const o=new URLSearchParams;return Object.keys(r).forEach(s=>{o.set(s,String(r[s]))}),O.get(`/api/webhook-attempts?${o.toString()}`).then(s=>s.data)},oe=r=>{const o={};return r.forEach(s=>{const t=new Date(s.created_at).toLocaleDateString();o[t]||(o[t]=[]),o[t]?.push(s)}),o};function xe({event_id:r="",webhook_endpoint_id:o="",event:s=void 0}){const{t}=V(),{data:c,loadMore:i,loadingMore:p,loading:m,reload:L}=Z(n=>{const d=n?Math.ceil(n.list.length/15)+1:1;return re({page:d,size:15,event_id:r,webhook_endpoint_id:o})},{reloadDeps:[r,o]}),q=c?.list||[],[a,w]=u.useState(null),[g,j]=K({retryEventId:""}),E=oe(q),{loading:y,run:A}=Q(n=>O.post(`/api/events/${n}/retry-webhooks`).then(x=>x.data),{manual:!0,onSuccess:n=>{C.success(n.message||t("admin.event.retryOptions.success")),L()},onError:n=>{C.error(n.response?.data?.error||t("admin.event.retryOptions.error"))}});u.useEffect(()=>{!a&&c?.list.length&&w(c.list[0])},[c?.list.length,a]);const R=n=>{w(n)},z=n=>{j({retryEventId:n})},W=()=>{g.retryEventId&&(A(g.retryEventId),j({retryEventId:""}))};if(m)return e.jsx(B,{});const I=c&&c.list.length<c.count;return e.jsxs(f,{container:!0,spacing:2.5,children:[e.jsx(f,{size:{xs:12,md:4},className:"attempt-list",children:te.isEmpty(Object.keys(E))?e.jsx(l,{sx:{color:"text.secondary"},children:t("admin.event.noAttempts")}):e.jsxs(e.Fragment,{children:[e.jsx(N,{sx:{maxHeight:"64vh",overflowY:"scroll"},children:Object.entries(E).map(([n,x])=>e.jsxs(F.Fragment,{children:[e.jsx(H,{children:n}),x.map(d=>e.jsxs(T,{component:_,onClick:()=>R(d),selected:a===d,secondaryAction:e.jsx(l,{sx:{color:"text.secondary"},children:X(d.created_at,"HH:mm:ss A")}),children:[e.jsx(G,{children:se(d.response_status)===!1?e.jsx(J,{color:"error"}):e.jsx($,{color:"success"})}),e.jsx(Y,{primary:e.jsx(l,{sx:{color:"text.primary"},children:d.event.type})})]},d.id))]},n))}),I&&e.jsx(S,{variant:"text",type:"button",color:"inherit",onClick:i,disabled:p,children:t(p?"common.loading":"common.loadMore")}),!I&&e.jsx(l,{sx:{color:"text.secondary"},children:t("common.noMoreData")})]})}),e.jsxs(f,{size:{xs:12,md:8},children:[a&&e.jsxs(h,{direction:"column",spacing:2,sx:{pt:3,pl:3,borderLeft:"1px solid",borderColor:"divider"},children:[e.jsxs(h,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(l,{variant:"h6",children:r?a.endpoint.url:a.event.type}),e.jsx(S,{variant:"outlined",size:"small",startIcon:e.jsx(U,{}),onClick:()=>z(a.event_id),disabled:y,children:t(y?"admin.event.retrying":"admin.event.retry")})]}),g.retryEventId&&e.jsx(ee,{onConfirm:W,onCancel:()=>j({retryEventId:""}),title:t("admin.event.retryOptions.title"),message:t("admin.event.retryOptions.confirmMessage"),loading:y,color:"primary"}),e.jsxs(v,{children:[e.jsxs(l,{variant:"h6",children:[t("admin.event.response")," (",a.response_status,")"]}),e.jsx(b,{language:"json",children:JSON.stringify(a.response_body,null,2)})]}),e.jsxs(v,{children:[e.jsxs(h,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(l,{variant:"h6",children:t("admin.event.request")}),e.jsx(k,{requestInfo:a?.event?.requestInfo,request:a?.event.request})]}),e.jsx(b,{language:"json",children:JSON.stringify(a.event,null,2)})]})]}),c?.list.length===0&&s&&e.jsxs(v,{children:[e.jsxs(h,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(l,{variant:"h6",children:t("admin.event.eventData")}),e.jsx(k,{requestInfo:s.requestInfo,request:s.request})]}),e.jsx(b,{language:"json",children:JSON.stringify(s.data,null,2)})]})]})]})}export{xe as W};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a0 as r}from"./vendor-blocklet-B67R14so.js";function s(){return r().arcSphere}export{s as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,A as k,w as se,r as S,a3 as l,bv as ae,B as re,q as ie}from"./vendor-mui-BXZut9Pz.js";import{e as x,a as $,h as ce,R as oe,F as pe,E as de,U as le,V as me,W as ue,X as R,Y as U,Q as ye,Z as ge,C as he,_ as fe,$ as xe,L as _e,a0 as be,k as j,l as Ce,a1 as Se}from"./index-
|
|
1
|
+
import{j as t,A as k,w as se,r as S,a3 as l,bv as ae,B as re,q as ie}from"./vendor-mui-BXZut9Pz.js";import{e as x,a as $,h as ce,R as oe,F as pe,E as de,U as le,V as me,W as ue,X as R,Y as U,Q as ye,Z as ge,C as he,_ as fe,$ as xe,L as _e,a0 as be,k as j,l as Ce,a1 as Se}from"./index-B4yaPb7B.js";import{V as D,P as je,Y as Pe,Z as g,F as ve}from"./vendor-blocklet-B67R14so.js";import{e as Ie,a as we,b as ke}from"./vendor-react-BPknnnEA.js";import{S as A}from"./header-ivXuPt06.js";import{S as Fe}from"./description-BHxdy5I3.js";import{g as Me}from"./util-B8B3fsMa.js";import{u as Ee,b as Ne}from"./subscription-Bzeblscr.js";import{u as Re}from"./browser-DF2vfpBa.js";import"./lodash-B4Ozcv0x.js";const Ue=async e=>{const[i,r]=await Promise.all([x.get(`/api/subscriptions/${e}`).then(s=>s.data),x.get("/api/customers/me").then(s=>s.data)]);return{subscription:i,customer:r}},W={mode:"percent",percent:.5},Ae=e=>{if(!e||typeof e!="object")return W;const i=e.mode==="rate"?"rate":"percent",r=Number(e.percent),s=Number.isFinite(r)&&r>=0?r:W.percent,c=typeof e.min_acceptable_rate=="string"?e.min_acceptable_rate:void 0,d=typeof e.base_currency=="string"?e.base_currency:void 0,m=Number.isFinite(Number(e.updated_at_ms))?Number(e.updated_at_ms):void 0;return{mode:i,percent:s,...i==="rate"&&c?{min_acceptable_rate:c}:{},...d?{base_currency:d}:{},...m?{updated_at_ms:m}:{}}},We=async e=>{let i;return await Se(async()=>{const{data:r}=await x.get(`/api/subscriptions/${e}/change-payment`);if(r.setupIntent&&r.setupIntent.status==="requires_action"&&r.setupIntent.last_setup_error)throw new Error(r.setupIntent.last_setup_error.message);return i=r,r.setupIntent?.status==="succeeded"},{interval:2e3,timeout:180*1e3}),i};function $e({subscription:e,customer:i,onComplete:r}){const{t:s,locale:c}=D(),d=we(),[m]=ke(),{settings:u,connect:h}=$(),{checkUnpaidInvoices:V}=Ee(e.id),{control:P,setValue:v,handleSubmit:B}=de(),z=Re(),[O,q]=S.useState(()=>Ae(e?.slippage_config)),[p,o]=Pe({submitting:!1,paying:!1,paid:!1,stripePaying:!1,setupIntent:void 0,stripeContext:void 0,customer:i}),H=le(e.items),L=me(e.items[0]?.price).map(n=>n.currency_id),y=ue(u.paymentMethods).filter(n=>L.includes(n.id)),[I,T]=S.useState(y.findIndex(n=>n.id===e.currency_id)),_=R({control:P,name:"payment_currency"}),Y=R({control:P,name:"payment_method"});S.useEffect(()=>{v("payment_method",y[I].method.id),v("payment_currency",y[I]?.id)},[I,y,v]);const b=u.paymentMethods.find(n=>n.id===Y),F=_!==e.currency_id,Z=S.useMemo(()=>(e.items||[]).some(n=>{const a=n.upsell_price||n.price;return a&&a?.pricing_type==="dynamic"}),[e.items]),M=b?.type==="stripe",w=Z&&!M,{liveRateInfo:E,liveRateUnavailable:K}=Ne({subscriptionId:e.id,currencyId:_,enabled:w}),Q=async n=>{try{const a={...n,...n.base_currency?{}:{base_currency:E?.base_currency||"USD"}};await x.put(`/api/subscriptions/${e.id}/slippage`,{slippage_config:a}),q(a),g.success(s("common.saved"))}catch(a){console.error("Failed to update slippage",a),g.error(j(a))}},X=async()=>{await r();const n=m.get("redirectUrl");n?window.location.href=n:d(`/customer/subscription/${e.id}`)},C=async()=>{try{await We(e.id),o({paid:!0,paying:!1}),g.success(s("payment.customer.changePayment.completed",{time:e.current_period_end})),await X()}catch(n){g.error(j(n))}finally{o({paying:!1})}},G=async n=>{o({submitting:!0});try{const a=await x.post(`/api/subscriptions/${e.id}/change-payment`,n);o({setupIntent:a.data.setupIntent,stripeContext:a.data.stripeContext,submitting:!1}),["arcblock","ethereum","base"].includes(b.type)&&(o({paying:!0}),a.data.delegation?.sufficient?await C():h.open({locale:c,containerEl:void 0,action:"change-payment",prefix:ve(Ce(),"/api/did"),saveConnect:!1,extraParams:{subscriptionId:e.id},messages:{scan:s("common.connect.defaultScan"),title:s("payment.customer.changePayment.title"),confirm:s("common.connect.confirm")},onSuccess:async()=>{h.close(),await C()},onClose:()=>{h.close(),o({submitting:!1,paying:!1})},onError:f=>{console.error(f),o({submitting:!1,paying:!1}),g.error(j(f))}})),["stripe"].includes(b.type)&&(a.data.setupIntent?.status==="succeeded"?await C():a.data.stripeContext?.status==="succeeded"?o({paying:!0}):o({stripePaying:!0}))}catch(a){console.error(a),g.error(j(a))}finally{o({submitting:!1})}},J=async()=>{e.overdraft_protection?.enabled&&await V()||B(G)()},ee=async()=>{o({stripePaying:!1,paying:!0}),await C()},te=()=>{o({stripePaying:!1})},N=U(u.paymentMethods,_);return t.jsxs(l,{direction:"column",spacing:4,sx:{maxWidth:"540px"},children:[t.jsx(l,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:z?t.jsx(re,{}):t.jsxs(l,{direction:"row",onClick:()=>Me(`/customer/subscription/${e.id}`),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[t.jsx(ae,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),t.jsx(Fe,{subscription:e,variant:"h5"})]})}),t.jsx(k,{severity:"info",children:s("payment.customer.changePayment.limit")}),t.jsxs(l,{direction:"column",spacing:2,children:[t.jsx(A,{title:s("payment.customer.changePayment.review")}),t.jsx(ye,{items:e.items,currency:N,trialInDays:0,billingThreshold:0,showStaking:ge(b,N,!!e.billing_thresholds?.no_stake),liveRate:E,rateUnavailable:w&&K,slippageConfig:O,onSlippageChange:w?Q:void 0,isSubscription:!0,isStripePayment:M})]}),t.jsxs(l,{direction:"column",spacing:2,children:[t.jsx(A,{title:s("payment.customer.changePayment.select")}),t.jsx(he,{name:"payment_currency",control:P,render:({field:n})=>t.jsx(fe,{value:n.value,currencies:y,onChange:a=>{const f=y.findIndex(ne=>ne.id===a);f>=0&&T(f)}})}),e.paymentMethod.type!=="stripe"&&t.jsx(l,{direction:"column",className:"cko-payment-form",spacing:0,children:t.jsx(xe,{mode:"auto"})})]}),F&&t.jsxs(l,{className:"cko-payment-submit",children:[t.jsx(_e,{variant:"contained",color:"primary",size:"large",onClick:J,fullWidth:!0,loadingPosition:"end",disabled:!F||p.submitting||p.paying||p.stripePaying,loading:p.paying,children:p.paying?s("payment.checkout.processing"):s("payment.customer.changePayment.submit")}),t.jsx(ie,{sx:{mt:1,color:"text.secondary",fontSize:"0.7875rem",lineHeight:"0.9625rem",textAlign:"center"},children:s("payment.customer.changePayment.confirm",{payee:H,symbol:U(u.paymentMethods,_)?.symbol})})]}),p.stripePaying&&p.stripeContext&&t.jsx(be,{clientSecret:p.stripeContext.client_secret,intentType:p.stripeContext.intent_type,publicKey:p.stripeContext.publishable_key,customer:p.customer,mode:"setup",onConfirm:ee,onCancel:te,returnUrl:window.location.href.replace(/\/[^/]+$/,"")})]})}function De({subscription:e,customer:i,onComplete:r}){const{settings:s}=$(),c=e.currency_id,d=s.paymentMethods.find(u=>u.payment_currencies.some(h=>h.id===c))?.id,m=ce({defaultValues:{payment_method:d,payment_currency:c,billing_address:Object.assign({country:"",state:"",city:"",line1:"",line2:"",postal_code:""},i?.address||{},{country:oe(i?.address?.country||"")?i?.address?.country:"us"})}});return t.jsx(pe,{...m,children:t.jsx($e,{subscription:e,customer:i,onComplete:r})})}function Ke(){const{t:e}=D(),{id:i}=Ie(),{loading:r,error:s,data:c,runAsync:d}=je(()=>Ue(i));return s?t.jsx(k,{severity:"error",children:s.message}):r||!c?t.jsx(se,{}):c?t.jsx(De,{subscription:c.subscription,customer:c.customer,onComplete:d}):t.jsx(k,{severity:"error",children:e("payment.customer.changePlan.subscriptionNotFound")})}export{Ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as ve,j as B,A as we,w as Se,a3 as te,bv as Ie,B as De,Y as ye,q as Ee}from"./vendor-mui-BXZut9Pz.js";import{V as Be,P as Re,Y as Te,Z as ae}from"./vendor-blocklet-DcLR2Cyf.js";import{a as be,k as le,Q as Le,j as Me,L as Oe,e as de,i as Ue}from"./index-BarN7DfU.js";import{P as ke}from"./pricing-table-B3QOaAB5.js";import{a as je,e as qe,b as Fe}from"./vendor-react-BPknnnEA.js";import{S as Ae}from"./header-ivXuPt06.js";import{S as Ge}from"./description-SnR5WxWT.js";import{g as $e}from"./util-DxXTXkeY.js";import{u as He}from"./browser-DDv4_sgY.js";import{b as ze}from"./subscription-DrnSPIfs.js";import"./lodash-B4Ozcv0x.js";var Ve=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,_e=Math.ceil,V=Math.floor,$="[BigNumber Error] ",Pe=$+"Number primitive has more than 15 significant digits: ",Q=1e14,N=14,xe=9007199254740991,Ne=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],re=1e7,U=1e9;function Ce(w){var g,y,x,d=p.prototype={constructor:p,toString:null,valueOf:null},C=new p(1),A=20,S=4,L=-7,M=21,X=-1e7,G=1e7,O=!1,I=1,T=0,K={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},ee="0123456789abcdefghijklmnopqrstuvwxyz",se=!0;function p(e,t){var r,c,n,o,u,i,s,l,a=this;if(!(a instanceof p))return new p(e,t);if(t==null){if(e&&e._isBigNumber===!0){a.s=e.s,!e.c||e.e>G?a.c=a.e=null:e.e<X?a.c=[a.e=0]:(a.e=e.e,a.c=e.c.slice());return}if((i=typeof e=="number")&&e*0==0){if(a.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,u=e;u>=10;u/=10,o++);o>G?a.c=a.e=null:(a.e=o,a.c=[e]);return}l=String(e)}else{if(!Ve.test(l=String(e)))return x(a,l,i);a.s=l.charCodeAt(0)==45?(l=l.slice(1),-1):1}(o=l.indexOf("."))>-1&&(l=l.replace(".","")),(u=l.search(/e/i))>0?(o<0&&(o=u),o+=+l.slice(u+1),l=l.substring(0,u)):o<0&&(o=l.length)}else{if(R(t,2,ee.length,"Base"),t==10&&se)return a=new p(e),q(a,A+a.e+1,S);if(l=String(e),i=typeof e=="number"){if(e*0!=0)return x(a,l,i,t);if(a.s=1/e<0?(l=l.slice(1),-1):1,p.DEBUG&&l.replace(/^0\.0*|\./,"").length>15)throw Error(Pe+e)}else a.s=l.charCodeAt(0)===45?(l=l.slice(1),-1):1;for(r=ee.slice(0,t),o=u=0,s=l.length;u<s;u++)if(r.indexOf(c=l.charAt(u))<0){if(c=="."){if(u>o){o=s;continue}}else if(!n&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){n=!0,u=-1,o=0;continue}return x(a,String(e),i,t)}i=!1,l=y(l,t,10,a.s),(o=l.indexOf("."))>-1?l=l.replace(".",""):o=l.length}for(u=0;l.charCodeAt(u)===48;u++);for(s=l.length;l.charCodeAt(--s)===48;);if(l=l.slice(u,++s)){if(s-=u,i&&p.DEBUG&&s>15&&(e>xe||e!==V(e)))throw Error(Pe+a.s*e);if((o=o-u-1)>G)a.c=a.e=null;else if(o<X)a.c=[a.e=0];else{if(a.e=o,a.c=[],u=(o+1)%N,o<0&&(u+=N),u<s){for(u&&a.c.push(+l.slice(0,u)),s-=N;u<s;)a.c.push(+l.slice(u,u+=N));u=N-(l=l.slice(u)).length}else u-=s;for(;u--;l+="0");a.c.push(+l)}}else a.c=[a.e=0]}p.clone=Ce,p.ROUND_UP=0,p.ROUND_DOWN=1,p.ROUND_CEIL=2,p.ROUND_FLOOR=3,p.ROUND_HALF_UP=4,p.ROUND_HALF_DOWN=5,p.ROUND_HALF_EVEN=6,p.ROUND_HALF_CEIL=7,p.ROUND_HALF_FLOOR=8,p.EUCLID=9,p.config=p.set=function(e){var t,r;if(e!=null)if(typeof e=="object"){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(r=e[t],R(r,0,U,t),A=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(r=e[t],R(r,0,8,t),S=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(r=e[t],r&&r.pop?(R(r[0],-U,0,t),R(r[1],0,U,t),L=r[0],M=r[1]):(R(r,-U,U,t),L=-(M=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if(r=e[t],r&&r.pop)R(r[0],-U,-1,t),R(r[1],1,U,t),X=r[0],G=r[1];else if(R(r,-U,U,t),r)X=-(G=r<0?-r:r);else throw Error($+t+" cannot be zero: "+r);if(e.hasOwnProperty(t="CRYPTO"))if(r=e[t],r===!!r)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))O=r;else throw O=!r,Error($+"crypto unavailable");else O=r;else throw Error($+t+" not true or false: "+r);if(e.hasOwnProperty(t="MODULO_MODE")&&(r=e[t],R(r,0,9,t),I=r),e.hasOwnProperty(t="POW_PRECISION")&&(r=e[t],R(r,0,U,t),T=r),e.hasOwnProperty(t="FORMAT"))if(r=e[t],typeof r=="object")K=r;else throw Error($+t+" not an object: "+r);if(e.hasOwnProperty(t="ALPHABET"))if(r=e[t],typeof r=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(r))se=r.slice(0,10)=="0123456789",ee=r;else throw Error($+t+" invalid: "+r)}else throw Error($+"Object expected: "+e);return{DECIMAL_PLACES:A,ROUNDING_MODE:S,EXPONENTIAL_AT:[L,M],RANGE:[X,G],CRYPTO:O,MODULO_MODE:I,POW_PRECISION:T,FORMAT:K,ALPHABET:ee}},p.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!p.DEBUG)return!0;var t,r,c=e.c,n=e.e,o=e.s;e:if({}.toString.call(c)=="[object Array]"){if((o===1||o===-1)&&n>=-U&&n<=U&&n===V(n)){if(c[0]===0){if(n===0&&c.length===1)return!0;break e}if(t=(n+1)%N,t<1&&(t+=N),String(c[0]).length==t){for(t=0;t<c.length;t++)if(r=c[t],r<0||r>=Q||r!==V(r))break e;if(r!==0)return!0}}}else if(c===null&&n===null&&(o===null||o===1||o===-1))return!0;throw Error($+"Invalid BigNumber: "+e)},p.maximum=p.max=function(){return ie(arguments,-1)},p.minimum=p.min=function(){return ie(arguments,1)},p.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return V(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(r){var c,n,o,u,i,s=0,l=[],a=new p(C);if(r==null?r=A:R(r,0,U),u=_e(r/N),O)if(crypto.getRandomValues){for(c=crypto.getRandomValues(new Uint32Array(u*=2));s<u;)i=c[s]*131072+(c[s+1]>>>11),i>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),c[s]=n[0],c[s+1]=n[1]):(l.push(i%1e14),s+=2);s=u/2}else if(crypto.randomBytes){for(c=crypto.randomBytes(u*=7);s<u;)i=(c[s]&31)*281474976710656+c[s+1]*1099511627776+c[s+2]*4294967296+c[s+3]*16777216+(c[s+4]<<16)+(c[s+5]<<8)+c[s+6],i>=9e15?crypto.randomBytes(7).copy(c,s):(l.push(i%1e14),s+=7);s=u/7}else throw O=!1,Error($+"crypto unavailable");if(!O)for(;s<u;)i=t(),i<9e15&&(l[s++]=i%1e14);for(u=l[--s],r%=N,u&&r&&(i=Ne[N-r],l[s]=V(u/i)*i);l[s]===0;l.pop(),s--);if(s<0)l=[o=0];else{for(o=-1;l[0]===0;l.splice(0,1),o-=N);for(s=1,i=l[0];i>=10;i/=10,s++);s<N&&(o-=N-s)}return a.e=o,a.c=l,a}})(),p.sum=function(){for(var e=1,t=arguments,r=new p(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y=(function(){var e="0123456789";function t(r,c,n,o){for(var u,i=[0],s,l=0,a=r.length;l<a;){for(s=i.length;s--;i[s]*=c);for(i[0]+=o.indexOf(r.charAt(l++)),u=0;u<i.length;u++)i[u]>n-1&&(i[u+1]==null&&(i[u+1]=0),i[u+1]+=i[u]/n|0,i[u]%=n)}return i.reverse()}return function(r,c,n,o,u){var i,s,l,a,f,m,h,_,P=r.indexOf("."),v=A,E=S;for(P>=0&&(a=T,T=0,r=r.replace(".",""),_=new p(c),m=_.pow(r.length-P),T=a,_.c=t(J(z(m.c),m.e,"0"),10,n,e),_.e=_.c.length),h=t(r,c,n,u?(i=ee,e):(i=e,ee)),l=a=h.length;h[--a]==0;h.pop());if(!h[0])return i.charAt(0);if(P<0?--l:(m.c=h,m.e=l,m.s=o,m=g(m,_,v,E,n),h=m.c,f=m.r,l=m.e),s=l+v+1,P=h[s],a=n/2,f=f||s<0||h[s+1]!=null,f=E<4?(P!=null||f)&&(E==0||E==(m.s<0?3:2)):P>a||P==a&&(E==4||f||E==6&&h[s-1]&1||E==(m.s<0?8:7)),s<1||!h[0])r=f?J(i.charAt(1),-v,i.charAt(0)):i.charAt(0);else{if(h.length=s,f)for(--n;++h[--s]>n;)h[s]=0,s||(++l,h=[1].concat(h));for(a=h.length;!h[--a];);for(P=0,r="";P<=a;r+=i.charAt(h[P++]));r=J(r,l,i.charAt(0))}return r}})(),g=(function(){function e(c,n,o){var u,i,s,l,a=0,f=c.length,m=n%re,h=n/re|0;for(c=c.slice();f--;)s=c[f]%re,l=c[f]/re|0,u=h*s+l*m,i=m*s+u%re*re+a,a=(i/o|0)+(u/re|0)+h*l,c[f]=i%o;return a&&(c=[a].concat(c)),c}function t(c,n,o,u){var i,s;if(o!=u)s=o>u?1:-1;else for(i=s=0;i<o;i++)if(c[i]!=n[i]){s=c[i]>n[i]?1:-1;break}return s}function r(c,n,o,u){for(var i=0;o--;)c[o]-=i,i=c[o]<n[o]?1:0,c[o]=i*u+c[o]-n[o];for(;!c[0]&&c.length>1;c.splice(0,1));}return function(c,n,o,u,i){var s,l,a,f,m,h,_,P,v,E,D,j,fe,me,ge,Z,ce,H=c.s==n.s?1:-1,F=c.c,b=n.c;if(!F||!F[0]||!b||!b[0])return new p(!c.s||!n.s||(F?b&&F[0]==b[0]:!b)?NaN:F&&F[0]==0||!b?H*0:H/0);for(P=new p(H),v=P.c=[],l=c.e-n.e,H=o+l+1,i||(i=Q,l=W(c.e/N)-W(n.e/N),H=H/N|0),a=0;b[a]==(F[a]||0);a++);if(b[a]>(F[a]||0)&&l--,H<0)v.push(1),f=!0;else{for(me=F.length,Z=b.length,a=0,H+=2,m=V(i/(b[0]+1)),m>1&&(b=e(b,m,i),F=e(F,m,i),Z=b.length,me=F.length),fe=Z,E=F.slice(0,Z),D=E.length;D<Z;E[D++]=0);ce=b.slice(),ce=[0].concat(ce),ge=b[0],b[1]>=i/2&&ge++;do{if(m=0,s=t(b,E,Z,D),s<0){if(j=E[0],Z!=D&&(j=j*i+(E[1]||0)),m=V(j/ge),m>1)for(m>=i&&(m=i-1),h=e(b,m,i),_=h.length,D=E.length;t(h,E,_,D)==1;)m--,r(h,Z<_?ce:b,_,i),_=h.length,s=1;else m==0&&(s=m=1),h=b.slice(),_=h.length;if(_<D&&(h=[0].concat(h)),r(E,h,D,i),D=E.length,s==-1)for(;t(b,E,Z,D)<1;)m++,r(E,Z<D?ce:b,D,i),D=E.length}else s===0&&(m++,E=[0]);v[a++]=m,E[0]?E[D++]=F[fe]||0:(E=[F[fe]],D=1)}while((fe++<me||E[0]!=null)&&H--);f=E[0]!=null,v[0]||v.splice(0,1)}if(i==Q){for(a=1,H=v[0];H>=10;H/=10,a++);q(P,o+(P.e=a+l*N-1)+1,u,f)}else P.e=l,P.r=+f;return P}})();function oe(e,t,r,c){var n,o,u,i,s;if(r==null?r=S:R(r,0,8),!e.c)return e.toString();if(n=e.c[0],u=e.e,t==null)s=z(e.c),s=c==1||c==2&&(u<=L||u>=M)?he(s,u):J(s,u,"0");else if(e=q(new p(e),t,r),o=e.e,s=z(e.c),i=s.length,c==1||c==2&&(t<=o||o<=L)){for(;i<t;s+="0",i++);s=he(s,o)}else if(t-=u+(c===2&&o>u),s=J(s,o,"0"),o+1>i){if(--t>0)for(s+=".";t--;s+="0");}else if(t+=o-i,t>0)for(o+1==i&&(s+=".");t--;s+="0");return e.s<0&&n?"-"+s:s}function ie(e,t){for(var r,c,n=1,o=new p(e[0]);n<e.length;n++)c=new p(e[n]),(!c.s||(r=ne(o,c))===t||r===0&&o.s===t)&&(o=c);return o}function ue(e,t,r){for(var c=1,n=t.length;!t[--n];t.pop());for(n=t[0];n>=10;n/=10,c++);return(r=c+r*N-1)>G?e.c=e.e=null:r<X?e.c=[e.e=0]:(e.e=r,e.c=t),e}x=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,r=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,n=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,u,i,s){var l,a=i?u:u.replace(n,"");if(c.test(a))o.s=isNaN(a)?null:a<0?-1:1;else{if(!i&&(a=a.replace(e,function(f,m,h){return l=(h=h.toLowerCase())=="x"?16:h=="b"?2:8,!s||s==l?m:f}),s&&(l=s,a=a.replace(t,"$1").replace(r,"0.$1")),u!=a))return new p(a,l);if(p.DEBUG)throw Error($+"Not a"+(s?" base "+s:"")+" number: "+u);o.s=null}o.c=o.e=null}})();function q(e,t,r,c){var n,o,u,i,s,l,a,f=e.c,m=Ne;if(f){e:{for(n=1,i=f[0];i>=10;i/=10,n++);if(o=t-n,o<0)o+=N,u=t,s=f[l=0],a=V(s/m[n-u-1]%10);else if(l=_e((o+1)/N),l>=f.length)if(c){for(;f.length<=l;f.push(0));s=a=0,n=1,o%=N,u=o-N+1}else break e;else{for(s=i=f[l],n=1;i>=10;i/=10,n++);o%=N,u=o-N+n,a=u<0?0:V(s/m[n-u-1]%10)}if(c=c||t<0||f[l+1]!=null||(u<0?s:s%m[n-u-1]),c=r<4?(a||c)&&(r==0||r==(e.s<0?3:2)):a>5||a==5&&(r==4||c||r==6&&(o>0?u>0?s/m[n-u]:0:f[l-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=m[(N-t%N)%N],e.e=-t||0):f[0]=e.e=0,e;if(o==0?(f.length=l,i=1,l--):(f.length=l+1,i=m[N-o],f[l]=u>0?V(s/m[n-u]%m[u])*i:0),c)for(;;)if(l==0){for(o=1,u=f[0];u>=10;u/=10,o++);for(u=f[0]+=i,i=1;u>=10;u/=10,i++);o!=i&&(e.e++,f[0]==Q&&(f[0]=1));break}else{if(f[l]+=i,f[l]!=Q)break;f[l--]=0,i=1}for(o=f.length;f[--o]===0;f.pop());}e.e>G?e.c=e.e=null:e.e<X&&(e.c=[e.e=0])}return e}function Y(e){var t,r=e.e;return r===null?e.toString():(t=z(e.c),t=r<=L||r>=M?he(t,r):J(t,r,"0"),e.s<0?"-"+t:t)}return d.absoluteValue=d.abs=function(){var e=new p(this);return e.s<0&&(e.s=1),e},d.comparedTo=function(e,t){return ne(this,new p(e,t))},d.decimalPlaces=d.dp=function(e,t){var r,c,n,o=this;if(e!=null)return R(e,0,U),t==null?t=S:R(t,0,8),q(new p(o),e+o.e+1,t);if(!(r=o.c))return null;if(c=((n=r.length-1)-W(this.e/N))*N,n=r[n])for(;n%10==0;n/=10,c--);return c<0&&(c=0),c},d.dividedBy=d.div=function(e,t){return g(this,new p(e,t),A,S)},d.dividedToIntegerBy=d.idiv=function(e,t){return g(this,new p(e,t),0,1)},d.exponentiatedBy=d.pow=function(e,t){var r,c,n,o,u,i,s,l,a,f=this;if(e=new p(e),e.c&&!e.isInteger())throw Error($+"Exponent not an integer: "+Y(e));if(t!=null&&(t=new p(t)),i=e.e>14,!f.c||!f.c[0]||f.c[0]==1&&!f.e&&f.c.length==1||!e.c||!e.c[0])return a=new p(Math.pow(+Y(f),i?e.s*(2-pe(e)):+Y(e))),t?a.mod(t):a;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new p(NaN);c=!s&&f.isInteger()&&t.isInteger(),c&&(f=f.mod(t))}else{if(e.e>9&&(f.e>0||f.e<-1||(f.e==0?f.c[0]>1||i&&f.c[1]>=24e7:f.c[0]<8e13||i&&f.c[0]<=9999975e7)))return o=f.s<0&&pe(e)?-0:0,f.e>-1&&(o=1/o),new p(s?1/o:o);T&&(o=_e(T/N+2))}for(i?(r=new p(.5),s&&(e.s=1),l=pe(e)):(n=Math.abs(+Y(e)),l=n%2),a=new p(C);;){if(l){if(a=a.times(f),!a.c)break;o?a.c.length>o&&(a.c.length=o):c&&(a=a.mod(t))}if(n){if(n=V(n/2),n===0)break;l=n%2}else if(e=e.times(r),q(e,e.e+1,1),e.e>14)l=pe(e);else{if(n=+Y(e),n===0)break;l=n%2}f=f.times(f),o?f.c&&f.c.length>o&&(f.c.length=o):c&&(f=f.mod(t))}return c?a:(s&&(a=C.div(a)),t?a.mod(t):o?q(a,T,S,u):a)},d.integerValue=function(e){var t=new p(this);return e==null?e=S:R(e,0,8),q(t,t.e+1,e)},d.isEqualTo=d.eq=function(e,t){return ne(this,new p(e,t))===0},d.isFinite=function(){return!!this.c},d.isGreaterThan=d.gt=function(e,t){return ne(this,new p(e,t))>0},d.isGreaterThanOrEqualTo=d.gte=function(e,t){return(t=ne(this,new p(e,t)))===1||t===0},d.isInteger=function(){return!!this.c&&W(this.e/N)>this.c.length-2},d.isLessThan=d.lt=function(e,t){return ne(this,new p(e,t))<0},d.isLessThanOrEqualTo=d.lte=function(e,t){return(t=ne(this,new p(e,t)))===-1||t===0},d.isNaN=function(){return!this.s},d.isNegative=function(){return this.s<0},d.isPositive=function(){return this.s>0},d.isZero=function(){return!!this.c&&this.c[0]==0},d.minus=function(e,t){var r,c,n,o,u=this,i=u.s;if(e=new p(e,t),t=e.s,!i||!t)return new p(NaN);if(i!=t)return e.s=-t,u.plus(e);var s=u.e/N,l=e.e/N,a=u.c,f=e.c;if(!s||!l){if(!a||!f)return a?(e.s=-t,e):new p(f?u:NaN);if(!a[0]||!f[0])return f[0]?(e.s=-t,e):new p(a[0]?u:S==3?-0:0)}if(s=W(s),l=W(l),a=a.slice(),i=s-l){for((o=i<0)?(i=-i,n=a):(l=s,n=f),n.reverse(),t=i;t--;n.push(0));n.reverse()}else for(c=(o=(i=a.length)<(t=f.length))?i:t,i=t=0;t<c;t++)if(a[t]!=f[t]){o=a[t]<f[t];break}if(o&&(n=a,a=f,f=n,e.s=-e.s),t=(c=f.length)-(r=a.length),t>0)for(;t--;a[r++]=0);for(t=Q-1;c>i;){if(a[--c]<f[c]){for(r=c;r&&!a[--r];a[r]=t);--a[r],a[c]+=Q}a[c]-=f[c]}for(;a[0]==0;a.splice(0,1),--l);return a[0]?ue(e,a,l):(e.s=S==3?-1:1,e.c=[e.e=0],e)},d.modulo=d.mod=function(e,t){var r,c,n=this;return e=new p(e,t),!n.c||!e.s||e.c&&!e.c[0]?new p(NaN):!e.c||n.c&&!n.c[0]?new p(n):(I==9?(c=e.s,e.s=1,r=g(n,e,0,3),e.s=c,r.s*=c):r=g(n,e,0,I),e=n.minus(r.times(e)),!e.c[0]&&I==1&&(e.s=n.s),e)},d.multipliedBy=d.times=function(e,t){var r,c,n,o,u,i,s,l,a,f,m,h,_,P,v,E=this,D=E.c,j=(e=new p(e,t)).c;if(!D||!j||!D[0]||!j[0])return!E.s||!e.s||D&&!D[0]&&!j||j&&!j[0]&&!D?e.c=e.e=e.s=null:(e.s*=E.s,!D||!j?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(c=W(E.e/N)+W(e.e/N),e.s*=E.s,s=D.length,f=j.length,s<f&&(_=D,D=j,j=_,n=s,s=f,f=n),n=s+f,_=[];n--;_.push(0));for(P=Q,v=re,n=f;--n>=0;){for(r=0,m=j[n]%v,h=j[n]/v|0,u=s,o=n+u;o>n;)l=D[--u]%v,a=D[u]/v|0,i=h*l+a*m,l=m*l+i%v*v+_[o]+r,r=(l/P|0)+(i/v|0)+h*a,_[o--]=l%P;_[o]=r}return r?++c:_.splice(0,1),ue(e,_,c)},d.negated=function(){var e=new p(this);return e.s=-e.s||null,e},d.plus=function(e,t){var r,c=this,n=c.s;if(e=new p(e,t),t=e.s,!n||!t)return new p(NaN);if(n!=t)return e.s=-t,c.minus(e);var o=c.e/N,u=e.e/N,i=c.c,s=e.c;if(!o||!u){if(!i||!s)return new p(n/0);if(!i[0]||!s[0])return s[0]?e:new p(i[0]?c:n*0)}if(o=W(o),u=W(u),i=i.slice(),n=o-u){for(n>0?(u=o,r=s):(n=-n,r=i),r.reverse();n--;r.push(0));r.reverse()}for(n=i.length,t=s.length,n-t<0&&(r=s,s=i,i=r,t=n),n=0;t;)n=(i[--t]=i[t]+s[t]+n)/Q|0,i[t]=Q===i[t]?0:i[t]%Q;return n&&(i=[n].concat(i),++u),ue(e,i,u)},d.precision=d.sd=function(e,t){var r,c,n,o=this;if(e!=null&&e!==!!e)return R(e,1,U),t==null?t=S:R(t,0,8),q(new p(o),e,t);if(!(r=o.c))return null;if(n=r.length-1,c=n*N+1,n=r[n]){for(;n%10==0;n/=10,c--);for(n=r[0];n>=10;n/=10,c++);}return e&&o.e+1>c&&(c=o.e+1),c},d.shiftedBy=function(e){return R(e,-xe,xe),this.times("1e"+e)},d.squareRoot=d.sqrt=function(){var e,t,r,c,n,o=this,u=o.c,i=o.s,s=o.e,l=A+4,a=new p("0.5");if(i!==1||!u||!u[0])return new p(!i||i<0&&(!u||u[0])?NaN:u?o:1/0);if(i=Math.sqrt(+Y(o)),i==0||i==1/0?(t=z(u),(t.length+s)%2==0&&(t+="0"),i=Math.sqrt(+t),s=W((s+1)/2)-(s<0||s%2),i==1/0?t="5e"+s:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+s),r=new p(t)):r=new p(i+""),r.c[0]){for(s=r.e,i=s+l,i<3&&(i=0);;)if(n=r,r=a.times(n.plus(g(o,n,l,1))),z(n.c).slice(0,i)===(t=z(r.c)).slice(0,i))if(r.e<s&&--i,t=t.slice(i-3,i+1),t=="9999"||!c&&t=="4999"){if(!c&&(q(n,n.e+A+2,0),n.times(n).eq(o))){r=n;break}l+=4,i+=4,c=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(q(r,r.e+A+2,1),e=!r.times(r).eq(o));break}}return q(r,r.e+A+1,S,e)},d.toExponential=function(e,t){return e!=null&&(R(e,0,U),e++),oe(this,e,t,1)},d.toFixed=function(e,t){return e!=null&&(R(e,0,U),e=e+this.e+1),oe(this,e,t)},d.toFormat=function(e,t,r){var c,n=this;if(r==null)e!=null&&t&&typeof t=="object"?(r=t,t=null):e&&typeof e=="object"?(r=e,e=t=null):r=K;else if(typeof r!="object")throw Error($+"Argument not an object: "+r);if(c=n.toFixed(e,t),n.c){var o,u=c.split("."),i=+r.groupSize,s=+r.secondaryGroupSize,l=r.groupSeparator||"",a=u[0],f=u[1],m=n.s<0,h=m?a.slice(1):a,_=h.length;if(s&&(o=i,i=s,s=o,_-=o),i>0&&_>0){for(o=_%i||i,a=h.substr(0,o);o<_;o+=i)a+=l+h.substr(o,i);s>0&&(a+=l+h.slice(o)),m&&(a="-"+a)}c=f?a+(r.decimalSeparator||"")+((s=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+s+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):a}return(r.prefix||"")+c+(r.suffix||"")},d.toFraction=function(e){var t,r,c,n,o,u,i,s,l,a,f,m,h=this,_=h.c;if(e!=null&&(i=new p(e),!i.isInteger()&&(i.c||i.s!==1)||i.lt(C)))throw Error($+"Argument "+(i.isInteger()?"out of range: ":"not an integer: ")+Y(i));if(!_)return new p(h);for(t=new p(C),l=r=new p(C),c=s=new p(C),m=z(_),o=t.e=m.length-h.e-1,t.c[0]=Ne[(u=o%N)<0?N+u:u],e=!e||i.comparedTo(t)>0?o>0?t:l:i,u=G,G=1/0,i=new p(m),s.c[0]=0;a=g(i,t,0,1),n=r.plus(a.times(c)),n.comparedTo(e)!=1;)r=c,c=n,l=s.plus(a.times(n=l)),s=n,t=i.minus(a.times(n=t)),i=n;return n=g(e.minus(r),c,0,1),s=s.plus(n.times(l)),r=r.plus(n.times(c)),s.s=l.s=h.s,o=o*2,f=g(l,c,o,S).minus(h).abs().comparedTo(g(s,r,o,S).minus(h).abs())<1?[l,c]:[s,r],G=u,f},d.toNumber=function(){return+Y(this)},d.toPrecision=function(e,t){return e!=null&&R(e,1,U),oe(this,e,t,2)},d.toString=function(e){var t,r=this,c=r.s,n=r.e;return n===null?c?(t="Infinity",c<0&&(t="-"+t)):t="NaN":(e==null?t=n<=L||n>=M?he(z(r.c),n):J(z(r.c),n,"0"):e===10&&se?(r=q(new p(r),A+n+1,S),t=J(z(r.c),r.e,"0")):(R(e,2,ee.length,"Base"),t=y(J(z(r.c),n,"0"),10,e,c,!0)),c<0&&r.c[0]&&(t="-"+t)),t},d.valueOf=d.toJSON=function(){return Y(this)},d._isBigNumber=!0,d[Symbol.toStringTag]="BigNumber",d[Symbol.for("nodejs.util.inspect.custom")]=d.valueOf,w!=null&&p.set(w),p}function W(w){var g=w|0;return w>0||w===g?g:g-1}function z(w){for(var g,y,x=1,d=w.length,C=w[0]+"";x<d;){for(g=w[x++]+"",y=N-g.length;y--;g="0"+g);C+=g}for(d=C.length;C.charCodeAt(--d)===48;);return C.slice(0,d+1||1)}function ne(w,g){var y,x,d=w.c,C=g.c,A=w.s,S=g.s,L=w.e,M=g.e;if(!A||!S)return null;if(y=d&&!d[0],x=C&&!C[0],y||x)return y?x?0:-S:A;if(A!=S)return A;if(y=A<0,x=L==M,!d||!C)return x?0:!d^y?1:-1;if(!x)return L>M^y?1:-1;for(S=(L=d.length)<(M=C.length)?L:M,A=0;A<S;A++)if(d[A]!=C[A])return d[A]>C[A]^y?1:-1;return L==M?0:L>M^y?1:-1}function R(w,g,y,x){if(w<g||w>y||w!==V(w))throw Error($+(x||"Argument")+(typeof w=="number"?w<g||w>y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(w))}function pe(w){var g=w.c.length-1;return W(w.e/N)==g&&w.c[g]%2!=0}function he(w,g){return(w.length>1?w.charAt(0)+"."+w.slice(1):w)+(g<0?"e":"e+")+g}function J(w,g,y){var x,d;if(g<0){for(d=y+".";++g;d+=y);w=d+w}else if(x=w.length,++g>x){for(d=y,g-=x;--g;d+=y);w+=d}else g<x&&(w=w.slice(0,g)+"."+w.slice(g));return w}var k=Ce();const We=(w,g,y)=>{if(!w?.length)return null;let x=new k(0);if(w.some(C=>(C.upsell_price||C.price)?.pricing_type==="dynamic")&&!g)return null;for(const C of w){const A=C.upsell_price||C.price,S=C.quantity||1;if(A?.pricing_type==="dynamic"&&A?.base_amount&&g){const L=new k(A.base_amount),M=new k(g);if(M.gt(0)){const X=L.dividedBy(M).times(new k(10).pow(y)).times(S);x=x.plus(X.integerValue(k.ROUND_CEIL))}}else A?.unit_amount&&(x=x.plus(new k(A.unit_amount).times(S)))}return x.toString()},Xe=(w,g,y)=>w?.length?w.map(x=>{if(x.pricing_type==="dynamic"&&x.base_amount_usd&&x.proration_rate&&g){const d=new k(x.base_amount_usd),C=new k(g),A=new k(x.proration_rate);if(C.gt(0)){const S=d.dividedBy(C).times(A).times(x.quantity||1).times(new k(10).pow(y)).integerValue(k.ROUND_CEIL),L=new k(x.amount.replace("-","")),M=k.min(S,L);return{...x,amount:`-${M.toString()}`}}}return x}):[],Ye=async w=>{const[g,y]=await Promise.all([de.get(`/api/subscriptions/${w}`).then(x=>x.data),de.get(`/api/subscriptions/${w}/change-plan`).then(x=>x.data)]);return{subscription:g,table:y}},Qe=({id:w,items:g})=>de.post(`/api/subscriptions/${w}/change-plan`,{items:g}).then(y=>y.data);function at(){const w=je(),{id:g}=qe(),{t:y,locale:x}=Be(),{connect:d,session:C}=be(),[A]=Fe(),S=A.get("redirectUrl"),L=ve.useRef(null),M=He(),{loading:X,error:G,data:O}=Re(()=>Ye(g)),[I,T]=Te({loading:!1,priceId:"",total:"",due:"",newCredit:"",appliedCredit:"",setup:null,prorations:[],items:[],paying:!1,paid:!1});let K=[];I.items.length>0?K=I.items:O?.subscription?.items&&(K=O.subscription.items);const se=K?.length&&K.some(h=>(h.upsell_price||h.price)?.pricing_type==="dynamic")&&O?.subscription?.paymentMethod?.type!=="stripe",{liveRateInfo:p,liveRateUnavailable:oe}=ze({subscriptionId:O?.subscription?.id,currencyId:O?.subscription?.paymentCurrency?.id,enabled:!!se});if(G)return B.jsx(we,{severity:"error",children:le(G)});if(X||!O)return B.jsx(Se,{});if(!O.subscription)return B.jsx(we,{severity:"error",children:y("payment.customer.changePlan.subscriptionNotFound")});const ie=I.items.length?I.items:O.subscription.items,q=ie?.length&&ie.some(h=>(h.upsell_price||h.price)?.pricing_type==="dynamic")&&O.subscription.paymentMethod?.type!=="stripe",Y=async h=>{try{if(I.priceId===h)return;const _=O.subscription.items.find(v=>O.table.items.some(E=>E.price_id===v.price_id));if(_.price_id===h){T({priceId:"",total:"",due:"",setup:null,prorations:[],items:[]});return}const P=await Qe({id:O.subscription.id,items:[{id:_.id,deleted:!0,clear_usage:!1},{price_id:h,quantity:1}]});T({priceId:h,...P}),setTimeout(()=>L.current?.scrollIntoView({behavior:"smooth"}),100)}catch(_){ae.error(le(_)),T({priceId:"",total:"",due:"",setup:null,prorations:[],items:[]})}},e=()=>{S?window.location.href=S:w(`/customer/subscription/${O.subscription.id}`)},t=async()=>{try{T({loading:!0});const _=[{id:O.subscription.items.find(v=>O.table.items.some(E=>E.price_id===v.price_id)).id,deleted:!0,clear_usage:!1},{price_id:I.priceId,quantity:1}],P=await de.put(`/api/subscriptions/${g}`,{proration_behavior:"create_prorations",items:_});if(P.data.connectAction){T({paying:!0});try{T({paying:!0}),d.open({locale:x,action:P.data.connectAction,saveConnect:!1,messages:{title:y("payment.customer.changePlan.pay"),scan:y("payment.customer.changePlan.scan"),success:y("payment.customer.changePlan.success"),error:y("payment.customer.changePlan.error"),confirm:""},extraParams:{invoiceId:P.data.pending_update?.updates?.latest_invoice_id,subscriptionId:P.data.id,sessionUserDid:C?.user?.did},onSuccess:()=>{T({paid:!0,paying:!1}),setTimeout(()=>{d.close(),e()},2e3)},onClose:()=>{d.close(),T({paying:!1})},onError:v=>{T({paying:!1}),ae.error(le(v))}})}catch(v){ae.error(le(v))}finally{T({paying:!1})}}else ae.success(y("payment.customer.changePlan.success")),T({paid:!0}),setTimeout(e,2e3)}catch(h){console.error(h),ae.error(le(h))}finally{T({loading:!1})}},r={...O.table,currency:O.subscription.paymentCurrency};(r.items||[]).forEach(h=>{h.is_selected=h.price_id===I.priceId,O.subscription.items.find(_=>_.price_id===h.price_id)&&(h.is_highlight=!0,h.is_disabled=!0,h.highlight_text=y("payment.customer.changePlan.current"),I.priceId||(h.is_selected=!0))});const{recurring:c}=O.subscription.items.find(h=>h.price.type==="recurring")?.price||{},n=[c?.interval,c?.interval_count].join("-"),o=q&&p?.rate,u=o?Xe(I.prorations,p?.rate,O.subscription.paymentCurrency.decimal):I.prorations,s=(o?We(ie,p?.rate,O.subscription.paymentCurrency.decimal):null)||I.total,l=()=>{if(!o)return{due:I.due,newCredit:I.newCredit};const h=new k(s||"0"),_=u.reduce((E,D)=>E.plus(new k(D.amount||"0")),new k(0)),P=new k(I.appliedCredit||"0"),v=h.plus(_).minus(P);return v.lt(0)?{due:"0",newCredit:v.abs().toString()}:{due:v.toString(),newCredit:"0"}},{due:a,newCredit:f}=l(),m=(h,_,P)=>B.jsxs(te,{direction:"row",sx:{justifyContent:"space-between"},children:[B.jsx(Ee,{variant:"h6",sx:{fontWeight:"normal"},children:h}),B.jsxs(Ee,{component:"p",style:{fontWeight:"bold"},children:[P,Ue(_,O.subscription.paymentCurrency.decimal,2)," ",O.subscription.paymentCurrency.symbol]})]},_);return B.jsxs(te,{direction:"column",spacing:4,sx:{mb:4},children:[B.jsx(te,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:M?B.jsx(De,{}):B.jsxs(te,{direction:"row",onClick:()=>$e(`/customer/subscription/${O.subscription.id}`),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[B.jsx(Ie,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),B.jsx(Ge,{subscription:O.subscription,variant:"h5"})]})}),B.jsxs(te,{direction:"column",sx:{marginTop:32},children:[B.jsx(Ae,{title:y("payment.customer.changePlan.config")}),B.jsx(ke,{mode:"select",alignItems:"left",interval:n,table:r,onSelect:Y,hideCurrency:!0})]}),!O.table&&B.jsx(we,{severity:"error",children:y("payment.customer.changePlan.tableNotFound")}),I.priceId&&I.total&&I.setup&&B.jsxs(te,{direction:"column",spacing:3,sx:{maxWidth:640},children:[B.jsx(Ae,{title:y("payment.customer.changePlan.confirm")}),B.jsx(Le,{items:ie,currency:O.subscription.paymentCurrency,trialInDays:0,billingThreshold:0,showStaking:!1,liveRate:p,rateUnavailable:!!(q&&oe),action:y("payment.customer.changePlan.summary",{date:Me(I.setup.period.end*1e3,"lll",x)}),completed:!0,isStripePayment:O.subscription.paymentMethod?.type==="stripe"}),B.jsx(ye,{}),B.jsxs(te,{direction:"column",spacing:1,children:[m(y("payment.customer.changePlan.total"),s),u.map(h=>m(h.description,h.amount)),I.appliedCredit>"0"&&m(y("payment.customer.changePlan.appliedCredit"),I.appliedCredit,"-"),new k(f).gt(0)&&m(y("payment.customer.changePlan.newCredit"),f),B.jsx(ye,{}),m(y("payment.customer.changePlan.remaining"),a),B.jsx(ye,{}),B.jsxs(te,{direction:"row",spacing:2,sx:{alignItems:"center",justifyContent:"flex-end",pt:2},children:[B.jsx(Oe,{disabled:I.loading||I.paying,onClick:()=>T({priceId:""}),variant:"text",size:"large",children:y("common.cancel")}),B.jsx(Oe,{ref:L,onClick:t,variant:"contained",size:"large",sx:{width:150},loading:I.loading||I.paying,loadingPosition:"end",children:y("common.confirm")})]})]})]})]})}export{at as default};
|
|
1
|
+
import{r as ve,j as B,A as we,w as Se,a3 as te,bv as Ie,B as De,Y as ye,q as Ee}from"./vendor-mui-BXZut9Pz.js";import{V as Be,P as Re,Y as Te,Z as ae}from"./vendor-blocklet-B67R14so.js";import{a as be,k as le,Q as Le,j as Me,L as Oe,e as de,i as Ue}from"./index-B4yaPb7B.js";import{P as ke}from"./pricing-table-D9FGYBVa.js";import{a as je,e as qe,b as Fe}from"./vendor-react-BPknnnEA.js";import{S as Ae}from"./header-ivXuPt06.js";import{S as Ge}from"./description-BHxdy5I3.js";import{g as $e}from"./util-B8B3fsMa.js";import{u as He}from"./browser-DF2vfpBa.js";import{b as ze}from"./subscription-Bzeblscr.js";import"./lodash-B4Ozcv0x.js";var Ve=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,_e=Math.ceil,V=Math.floor,$="[BigNumber Error] ",Pe=$+"Number primitive has more than 15 significant digits: ",Q=1e14,N=14,xe=9007199254740991,Ne=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],re=1e7,U=1e9;function Ce(w){var g,y,x,d=p.prototype={constructor:p,toString:null,valueOf:null},C=new p(1),A=20,S=4,L=-7,M=21,X=-1e7,G=1e7,O=!1,I=1,T=0,K={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},ee="0123456789abcdefghijklmnopqrstuvwxyz",se=!0;function p(e,t){var r,c,n,o,u,i,s,l,a=this;if(!(a instanceof p))return new p(e,t);if(t==null){if(e&&e._isBigNumber===!0){a.s=e.s,!e.c||e.e>G?a.c=a.e=null:e.e<X?a.c=[a.e=0]:(a.e=e.e,a.c=e.c.slice());return}if((i=typeof e=="number")&&e*0==0){if(a.s=1/e<0?(e=-e,-1):1,e===~~e){for(o=0,u=e;u>=10;u/=10,o++);o>G?a.c=a.e=null:(a.e=o,a.c=[e]);return}l=String(e)}else{if(!Ve.test(l=String(e)))return x(a,l,i);a.s=l.charCodeAt(0)==45?(l=l.slice(1),-1):1}(o=l.indexOf("."))>-1&&(l=l.replace(".","")),(u=l.search(/e/i))>0?(o<0&&(o=u),o+=+l.slice(u+1),l=l.substring(0,u)):o<0&&(o=l.length)}else{if(R(t,2,ee.length,"Base"),t==10&&se)return a=new p(e),q(a,A+a.e+1,S);if(l=String(e),i=typeof e=="number"){if(e*0!=0)return x(a,l,i,t);if(a.s=1/e<0?(l=l.slice(1),-1):1,p.DEBUG&&l.replace(/^0\.0*|\./,"").length>15)throw Error(Pe+e)}else a.s=l.charCodeAt(0)===45?(l=l.slice(1),-1):1;for(r=ee.slice(0,t),o=u=0,s=l.length;u<s;u++)if(r.indexOf(c=l.charAt(u))<0){if(c=="."){if(u>o){o=s;continue}}else if(!n&&(l==l.toUpperCase()&&(l=l.toLowerCase())||l==l.toLowerCase()&&(l=l.toUpperCase()))){n=!0,u=-1,o=0;continue}return x(a,String(e),i,t)}i=!1,l=y(l,t,10,a.s),(o=l.indexOf("."))>-1?l=l.replace(".",""):o=l.length}for(u=0;l.charCodeAt(u)===48;u++);for(s=l.length;l.charCodeAt(--s)===48;);if(l=l.slice(u,++s)){if(s-=u,i&&p.DEBUG&&s>15&&(e>xe||e!==V(e)))throw Error(Pe+a.s*e);if((o=o-u-1)>G)a.c=a.e=null;else if(o<X)a.c=[a.e=0];else{if(a.e=o,a.c=[],u=(o+1)%N,o<0&&(u+=N),u<s){for(u&&a.c.push(+l.slice(0,u)),s-=N;u<s;)a.c.push(+l.slice(u,u+=N));u=N-(l=l.slice(u)).length}else u-=s;for(;u--;l+="0");a.c.push(+l)}}else a.c=[a.e=0]}p.clone=Ce,p.ROUND_UP=0,p.ROUND_DOWN=1,p.ROUND_CEIL=2,p.ROUND_FLOOR=3,p.ROUND_HALF_UP=4,p.ROUND_HALF_DOWN=5,p.ROUND_HALF_EVEN=6,p.ROUND_HALF_CEIL=7,p.ROUND_HALF_FLOOR=8,p.EUCLID=9,p.config=p.set=function(e){var t,r;if(e!=null)if(typeof e=="object"){if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(r=e[t],R(r,0,U,t),A=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(r=e[t],R(r,0,8,t),S=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&(r=e[t],r&&r.pop?(R(r[0],-U,0,t),R(r[1],0,U,t),L=r[0],M=r[1]):(R(r,-U,U,t),L=-(M=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if(r=e[t],r&&r.pop)R(r[0],-U,-1,t),R(r[1],1,U,t),X=r[0],G=r[1];else if(R(r,-U,U,t),r)X=-(G=r<0?-r:r);else throw Error($+t+" cannot be zero: "+r);if(e.hasOwnProperty(t="CRYPTO"))if(r=e[t],r===!!r)if(r)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))O=r;else throw O=!r,Error($+"crypto unavailable");else O=r;else throw Error($+t+" not true or false: "+r);if(e.hasOwnProperty(t="MODULO_MODE")&&(r=e[t],R(r,0,9,t),I=r),e.hasOwnProperty(t="POW_PRECISION")&&(r=e[t],R(r,0,U,t),T=r),e.hasOwnProperty(t="FORMAT"))if(r=e[t],typeof r=="object")K=r;else throw Error($+t+" not an object: "+r);if(e.hasOwnProperty(t="ALPHABET"))if(r=e[t],typeof r=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(r))se=r.slice(0,10)=="0123456789",ee=r;else throw Error($+t+" invalid: "+r)}else throw Error($+"Object expected: "+e);return{DECIMAL_PLACES:A,ROUNDING_MODE:S,EXPONENTIAL_AT:[L,M],RANGE:[X,G],CRYPTO:O,MODULO_MODE:I,POW_PRECISION:T,FORMAT:K,ALPHABET:ee}},p.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!p.DEBUG)return!0;var t,r,c=e.c,n=e.e,o=e.s;e:if({}.toString.call(c)=="[object Array]"){if((o===1||o===-1)&&n>=-U&&n<=U&&n===V(n)){if(c[0]===0){if(n===0&&c.length===1)return!0;break e}if(t=(n+1)%N,t<1&&(t+=N),String(c[0]).length==t){for(t=0;t<c.length;t++)if(r=c[t],r<0||r>=Q||r!==V(r))break e;if(r!==0)return!0}}}else if(c===null&&n===null&&(o===null||o===1||o===-1))return!0;throw Error($+"Invalid BigNumber: "+e)},p.maximum=p.max=function(){return ie(arguments,-1)},p.minimum=p.min=function(){return ie(arguments,1)},p.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return V(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(r){var c,n,o,u,i,s=0,l=[],a=new p(C);if(r==null?r=A:R(r,0,U),u=_e(r/N),O)if(crypto.getRandomValues){for(c=crypto.getRandomValues(new Uint32Array(u*=2));s<u;)i=c[s]*131072+(c[s+1]>>>11),i>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),c[s]=n[0],c[s+1]=n[1]):(l.push(i%1e14),s+=2);s=u/2}else if(crypto.randomBytes){for(c=crypto.randomBytes(u*=7);s<u;)i=(c[s]&31)*281474976710656+c[s+1]*1099511627776+c[s+2]*4294967296+c[s+3]*16777216+(c[s+4]<<16)+(c[s+5]<<8)+c[s+6],i>=9e15?crypto.randomBytes(7).copy(c,s):(l.push(i%1e14),s+=7);s=u/7}else throw O=!1,Error($+"crypto unavailable");if(!O)for(;s<u;)i=t(),i<9e15&&(l[s++]=i%1e14);for(u=l[--s],r%=N,u&&r&&(i=Ne[N-r],l[s]=V(u/i)*i);l[s]===0;l.pop(),s--);if(s<0)l=[o=0];else{for(o=-1;l[0]===0;l.splice(0,1),o-=N);for(s=1,i=l[0];i>=10;i/=10,s++);s<N&&(o-=N-s)}return a.e=o,a.c=l,a}})(),p.sum=function(){for(var e=1,t=arguments,r=new p(t[0]);e<t.length;)r=r.plus(t[e++]);return r},y=(function(){var e="0123456789";function t(r,c,n,o){for(var u,i=[0],s,l=0,a=r.length;l<a;){for(s=i.length;s--;i[s]*=c);for(i[0]+=o.indexOf(r.charAt(l++)),u=0;u<i.length;u++)i[u]>n-1&&(i[u+1]==null&&(i[u+1]=0),i[u+1]+=i[u]/n|0,i[u]%=n)}return i.reverse()}return function(r,c,n,o,u){var i,s,l,a,f,m,h,_,P=r.indexOf("."),v=A,E=S;for(P>=0&&(a=T,T=0,r=r.replace(".",""),_=new p(c),m=_.pow(r.length-P),T=a,_.c=t(J(z(m.c),m.e,"0"),10,n,e),_.e=_.c.length),h=t(r,c,n,u?(i=ee,e):(i=e,ee)),l=a=h.length;h[--a]==0;h.pop());if(!h[0])return i.charAt(0);if(P<0?--l:(m.c=h,m.e=l,m.s=o,m=g(m,_,v,E,n),h=m.c,f=m.r,l=m.e),s=l+v+1,P=h[s],a=n/2,f=f||s<0||h[s+1]!=null,f=E<4?(P!=null||f)&&(E==0||E==(m.s<0?3:2)):P>a||P==a&&(E==4||f||E==6&&h[s-1]&1||E==(m.s<0?8:7)),s<1||!h[0])r=f?J(i.charAt(1),-v,i.charAt(0)):i.charAt(0);else{if(h.length=s,f)for(--n;++h[--s]>n;)h[s]=0,s||(++l,h=[1].concat(h));for(a=h.length;!h[--a];);for(P=0,r="";P<=a;r+=i.charAt(h[P++]));r=J(r,l,i.charAt(0))}return r}})(),g=(function(){function e(c,n,o){var u,i,s,l,a=0,f=c.length,m=n%re,h=n/re|0;for(c=c.slice();f--;)s=c[f]%re,l=c[f]/re|0,u=h*s+l*m,i=m*s+u%re*re+a,a=(i/o|0)+(u/re|0)+h*l,c[f]=i%o;return a&&(c=[a].concat(c)),c}function t(c,n,o,u){var i,s;if(o!=u)s=o>u?1:-1;else for(i=s=0;i<o;i++)if(c[i]!=n[i]){s=c[i]>n[i]?1:-1;break}return s}function r(c,n,o,u){for(var i=0;o--;)c[o]-=i,i=c[o]<n[o]?1:0,c[o]=i*u+c[o]-n[o];for(;!c[0]&&c.length>1;c.splice(0,1));}return function(c,n,o,u,i){var s,l,a,f,m,h,_,P,v,E,D,j,fe,me,ge,Z,ce,H=c.s==n.s?1:-1,F=c.c,b=n.c;if(!F||!F[0]||!b||!b[0])return new p(!c.s||!n.s||(F?b&&F[0]==b[0]:!b)?NaN:F&&F[0]==0||!b?H*0:H/0);for(P=new p(H),v=P.c=[],l=c.e-n.e,H=o+l+1,i||(i=Q,l=W(c.e/N)-W(n.e/N),H=H/N|0),a=0;b[a]==(F[a]||0);a++);if(b[a]>(F[a]||0)&&l--,H<0)v.push(1),f=!0;else{for(me=F.length,Z=b.length,a=0,H+=2,m=V(i/(b[0]+1)),m>1&&(b=e(b,m,i),F=e(F,m,i),Z=b.length,me=F.length),fe=Z,E=F.slice(0,Z),D=E.length;D<Z;E[D++]=0);ce=b.slice(),ce=[0].concat(ce),ge=b[0],b[1]>=i/2&&ge++;do{if(m=0,s=t(b,E,Z,D),s<0){if(j=E[0],Z!=D&&(j=j*i+(E[1]||0)),m=V(j/ge),m>1)for(m>=i&&(m=i-1),h=e(b,m,i),_=h.length,D=E.length;t(h,E,_,D)==1;)m--,r(h,Z<_?ce:b,_,i),_=h.length,s=1;else m==0&&(s=m=1),h=b.slice(),_=h.length;if(_<D&&(h=[0].concat(h)),r(E,h,D,i),D=E.length,s==-1)for(;t(b,E,Z,D)<1;)m++,r(E,Z<D?ce:b,D,i),D=E.length}else s===0&&(m++,E=[0]);v[a++]=m,E[0]?E[D++]=F[fe]||0:(E=[F[fe]],D=1)}while((fe++<me||E[0]!=null)&&H--);f=E[0]!=null,v[0]||v.splice(0,1)}if(i==Q){for(a=1,H=v[0];H>=10;H/=10,a++);q(P,o+(P.e=a+l*N-1)+1,u,f)}else P.e=l,P.r=+f;return P}})();function oe(e,t,r,c){var n,o,u,i,s;if(r==null?r=S:R(r,0,8),!e.c)return e.toString();if(n=e.c[0],u=e.e,t==null)s=z(e.c),s=c==1||c==2&&(u<=L||u>=M)?he(s,u):J(s,u,"0");else if(e=q(new p(e),t,r),o=e.e,s=z(e.c),i=s.length,c==1||c==2&&(t<=o||o<=L)){for(;i<t;s+="0",i++);s=he(s,o)}else if(t-=u+(c===2&&o>u),s=J(s,o,"0"),o+1>i){if(--t>0)for(s+=".";t--;s+="0");}else if(t+=o-i,t>0)for(o+1==i&&(s+=".");t--;s+="0");return e.s<0&&n?"-"+s:s}function ie(e,t){for(var r,c,n=1,o=new p(e[0]);n<e.length;n++)c=new p(e[n]),(!c.s||(r=ne(o,c))===t||r===0&&o.s===t)&&(o=c);return o}function ue(e,t,r){for(var c=1,n=t.length;!t[--n];t.pop());for(n=t[0];n>=10;n/=10,c++);return(r=c+r*N-1)>G?e.c=e.e=null:r<X?e.c=[e.e=0]:(e.e=r,e.c=t),e}x=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,r=/^\.([^.]+)$/,c=/^-?(Infinity|NaN)$/,n=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(o,u,i,s){var l,a=i?u:u.replace(n,"");if(c.test(a))o.s=isNaN(a)?null:a<0?-1:1;else{if(!i&&(a=a.replace(e,function(f,m,h){return l=(h=h.toLowerCase())=="x"?16:h=="b"?2:8,!s||s==l?m:f}),s&&(l=s,a=a.replace(t,"$1").replace(r,"0.$1")),u!=a))return new p(a,l);if(p.DEBUG)throw Error($+"Not a"+(s?" base "+s:"")+" number: "+u);o.s=null}o.c=o.e=null}})();function q(e,t,r,c){var n,o,u,i,s,l,a,f=e.c,m=Ne;if(f){e:{for(n=1,i=f[0];i>=10;i/=10,n++);if(o=t-n,o<0)o+=N,u=t,s=f[l=0],a=V(s/m[n-u-1]%10);else if(l=_e((o+1)/N),l>=f.length)if(c){for(;f.length<=l;f.push(0));s=a=0,n=1,o%=N,u=o-N+1}else break e;else{for(s=i=f[l],n=1;i>=10;i/=10,n++);o%=N,u=o-N+n,a=u<0?0:V(s/m[n-u-1]%10)}if(c=c||t<0||f[l+1]!=null||(u<0?s:s%m[n-u-1]),c=r<4?(a||c)&&(r==0||r==(e.s<0?3:2)):a>5||a==5&&(r==4||c||r==6&&(o>0?u>0?s/m[n-u]:0:f[l-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,c?(t-=e.e+1,f[0]=m[(N-t%N)%N],e.e=-t||0):f[0]=e.e=0,e;if(o==0?(f.length=l,i=1,l--):(f.length=l+1,i=m[N-o],f[l]=u>0?V(s/m[n-u]%m[u])*i:0),c)for(;;)if(l==0){for(o=1,u=f[0];u>=10;u/=10,o++);for(u=f[0]+=i,i=1;u>=10;u/=10,i++);o!=i&&(e.e++,f[0]==Q&&(f[0]=1));break}else{if(f[l]+=i,f[l]!=Q)break;f[l--]=0,i=1}for(o=f.length;f[--o]===0;f.pop());}e.e>G?e.c=e.e=null:e.e<X&&(e.c=[e.e=0])}return e}function Y(e){var t,r=e.e;return r===null?e.toString():(t=z(e.c),t=r<=L||r>=M?he(t,r):J(t,r,"0"),e.s<0?"-"+t:t)}return d.absoluteValue=d.abs=function(){var e=new p(this);return e.s<0&&(e.s=1),e},d.comparedTo=function(e,t){return ne(this,new p(e,t))},d.decimalPlaces=d.dp=function(e,t){var r,c,n,o=this;if(e!=null)return R(e,0,U),t==null?t=S:R(t,0,8),q(new p(o),e+o.e+1,t);if(!(r=o.c))return null;if(c=((n=r.length-1)-W(this.e/N))*N,n=r[n])for(;n%10==0;n/=10,c--);return c<0&&(c=0),c},d.dividedBy=d.div=function(e,t){return g(this,new p(e,t),A,S)},d.dividedToIntegerBy=d.idiv=function(e,t){return g(this,new p(e,t),0,1)},d.exponentiatedBy=d.pow=function(e,t){var r,c,n,o,u,i,s,l,a,f=this;if(e=new p(e),e.c&&!e.isInteger())throw Error($+"Exponent not an integer: "+Y(e));if(t!=null&&(t=new p(t)),i=e.e>14,!f.c||!f.c[0]||f.c[0]==1&&!f.e&&f.c.length==1||!e.c||!e.c[0])return a=new p(Math.pow(+Y(f),i?e.s*(2-pe(e)):+Y(e))),t?a.mod(t):a;if(s=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new p(NaN);c=!s&&f.isInteger()&&t.isInteger(),c&&(f=f.mod(t))}else{if(e.e>9&&(f.e>0||f.e<-1||(f.e==0?f.c[0]>1||i&&f.c[1]>=24e7:f.c[0]<8e13||i&&f.c[0]<=9999975e7)))return o=f.s<0&&pe(e)?-0:0,f.e>-1&&(o=1/o),new p(s?1/o:o);T&&(o=_e(T/N+2))}for(i?(r=new p(.5),s&&(e.s=1),l=pe(e)):(n=Math.abs(+Y(e)),l=n%2),a=new p(C);;){if(l){if(a=a.times(f),!a.c)break;o?a.c.length>o&&(a.c.length=o):c&&(a=a.mod(t))}if(n){if(n=V(n/2),n===0)break;l=n%2}else if(e=e.times(r),q(e,e.e+1,1),e.e>14)l=pe(e);else{if(n=+Y(e),n===0)break;l=n%2}f=f.times(f),o?f.c&&f.c.length>o&&(f.c.length=o):c&&(f=f.mod(t))}return c?a:(s&&(a=C.div(a)),t?a.mod(t):o?q(a,T,S,u):a)},d.integerValue=function(e){var t=new p(this);return e==null?e=S:R(e,0,8),q(t,t.e+1,e)},d.isEqualTo=d.eq=function(e,t){return ne(this,new p(e,t))===0},d.isFinite=function(){return!!this.c},d.isGreaterThan=d.gt=function(e,t){return ne(this,new p(e,t))>0},d.isGreaterThanOrEqualTo=d.gte=function(e,t){return(t=ne(this,new p(e,t)))===1||t===0},d.isInteger=function(){return!!this.c&&W(this.e/N)>this.c.length-2},d.isLessThan=d.lt=function(e,t){return ne(this,new p(e,t))<0},d.isLessThanOrEqualTo=d.lte=function(e,t){return(t=ne(this,new p(e,t)))===-1||t===0},d.isNaN=function(){return!this.s},d.isNegative=function(){return this.s<0},d.isPositive=function(){return this.s>0},d.isZero=function(){return!!this.c&&this.c[0]==0},d.minus=function(e,t){var r,c,n,o,u=this,i=u.s;if(e=new p(e,t),t=e.s,!i||!t)return new p(NaN);if(i!=t)return e.s=-t,u.plus(e);var s=u.e/N,l=e.e/N,a=u.c,f=e.c;if(!s||!l){if(!a||!f)return a?(e.s=-t,e):new p(f?u:NaN);if(!a[0]||!f[0])return f[0]?(e.s=-t,e):new p(a[0]?u:S==3?-0:0)}if(s=W(s),l=W(l),a=a.slice(),i=s-l){for((o=i<0)?(i=-i,n=a):(l=s,n=f),n.reverse(),t=i;t--;n.push(0));n.reverse()}else for(c=(o=(i=a.length)<(t=f.length))?i:t,i=t=0;t<c;t++)if(a[t]!=f[t]){o=a[t]<f[t];break}if(o&&(n=a,a=f,f=n,e.s=-e.s),t=(c=f.length)-(r=a.length),t>0)for(;t--;a[r++]=0);for(t=Q-1;c>i;){if(a[--c]<f[c]){for(r=c;r&&!a[--r];a[r]=t);--a[r],a[c]+=Q}a[c]-=f[c]}for(;a[0]==0;a.splice(0,1),--l);return a[0]?ue(e,a,l):(e.s=S==3?-1:1,e.c=[e.e=0],e)},d.modulo=d.mod=function(e,t){var r,c,n=this;return e=new p(e,t),!n.c||!e.s||e.c&&!e.c[0]?new p(NaN):!e.c||n.c&&!n.c[0]?new p(n):(I==9?(c=e.s,e.s=1,r=g(n,e,0,3),e.s=c,r.s*=c):r=g(n,e,0,I),e=n.minus(r.times(e)),!e.c[0]&&I==1&&(e.s=n.s),e)},d.multipliedBy=d.times=function(e,t){var r,c,n,o,u,i,s,l,a,f,m,h,_,P,v,E=this,D=E.c,j=(e=new p(e,t)).c;if(!D||!j||!D[0]||!j[0])return!E.s||!e.s||D&&!D[0]&&!j||j&&!j[0]&&!D?e.c=e.e=e.s=null:(e.s*=E.s,!D||!j?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(c=W(E.e/N)+W(e.e/N),e.s*=E.s,s=D.length,f=j.length,s<f&&(_=D,D=j,j=_,n=s,s=f,f=n),n=s+f,_=[];n--;_.push(0));for(P=Q,v=re,n=f;--n>=0;){for(r=0,m=j[n]%v,h=j[n]/v|0,u=s,o=n+u;o>n;)l=D[--u]%v,a=D[u]/v|0,i=h*l+a*m,l=m*l+i%v*v+_[o]+r,r=(l/P|0)+(i/v|0)+h*a,_[o--]=l%P;_[o]=r}return r?++c:_.splice(0,1),ue(e,_,c)},d.negated=function(){var e=new p(this);return e.s=-e.s||null,e},d.plus=function(e,t){var r,c=this,n=c.s;if(e=new p(e,t),t=e.s,!n||!t)return new p(NaN);if(n!=t)return e.s=-t,c.minus(e);var o=c.e/N,u=e.e/N,i=c.c,s=e.c;if(!o||!u){if(!i||!s)return new p(n/0);if(!i[0]||!s[0])return s[0]?e:new p(i[0]?c:n*0)}if(o=W(o),u=W(u),i=i.slice(),n=o-u){for(n>0?(u=o,r=s):(n=-n,r=i),r.reverse();n--;r.push(0));r.reverse()}for(n=i.length,t=s.length,n-t<0&&(r=s,s=i,i=r,t=n),n=0;t;)n=(i[--t]=i[t]+s[t]+n)/Q|0,i[t]=Q===i[t]?0:i[t]%Q;return n&&(i=[n].concat(i),++u),ue(e,i,u)},d.precision=d.sd=function(e,t){var r,c,n,o=this;if(e!=null&&e!==!!e)return R(e,1,U),t==null?t=S:R(t,0,8),q(new p(o),e,t);if(!(r=o.c))return null;if(n=r.length-1,c=n*N+1,n=r[n]){for(;n%10==0;n/=10,c--);for(n=r[0];n>=10;n/=10,c++);}return e&&o.e+1>c&&(c=o.e+1),c},d.shiftedBy=function(e){return R(e,-xe,xe),this.times("1e"+e)},d.squareRoot=d.sqrt=function(){var e,t,r,c,n,o=this,u=o.c,i=o.s,s=o.e,l=A+4,a=new p("0.5");if(i!==1||!u||!u[0])return new p(!i||i<0&&(!u||u[0])?NaN:u?o:1/0);if(i=Math.sqrt(+Y(o)),i==0||i==1/0?(t=z(u),(t.length+s)%2==0&&(t+="0"),i=Math.sqrt(+t),s=W((s+1)/2)-(s<0||s%2),i==1/0?t="5e"+s:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+s),r=new p(t)):r=new p(i+""),r.c[0]){for(s=r.e,i=s+l,i<3&&(i=0);;)if(n=r,r=a.times(n.plus(g(o,n,l,1))),z(n.c).slice(0,i)===(t=z(r.c)).slice(0,i))if(r.e<s&&--i,t=t.slice(i-3,i+1),t=="9999"||!c&&t=="4999"){if(!c&&(q(n,n.e+A+2,0),n.times(n).eq(o))){r=n;break}l+=4,i+=4,c=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(q(r,r.e+A+2,1),e=!r.times(r).eq(o));break}}return q(r,r.e+A+1,S,e)},d.toExponential=function(e,t){return e!=null&&(R(e,0,U),e++),oe(this,e,t,1)},d.toFixed=function(e,t){return e!=null&&(R(e,0,U),e=e+this.e+1),oe(this,e,t)},d.toFormat=function(e,t,r){var c,n=this;if(r==null)e!=null&&t&&typeof t=="object"?(r=t,t=null):e&&typeof e=="object"?(r=e,e=t=null):r=K;else if(typeof r!="object")throw Error($+"Argument not an object: "+r);if(c=n.toFixed(e,t),n.c){var o,u=c.split("."),i=+r.groupSize,s=+r.secondaryGroupSize,l=r.groupSeparator||"",a=u[0],f=u[1],m=n.s<0,h=m?a.slice(1):a,_=h.length;if(s&&(o=i,i=s,s=o,_-=o),i>0&&_>0){for(o=_%i||i,a=h.substr(0,o);o<_;o+=i)a+=l+h.substr(o,i);s>0&&(a+=l+h.slice(o)),m&&(a="-"+a)}c=f?a+(r.decimalSeparator||"")+((s=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+s+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):a}return(r.prefix||"")+c+(r.suffix||"")},d.toFraction=function(e){var t,r,c,n,o,u,i,s,l,a,f,m,h=this,_=h.c;if(e!=null&&(i=new p(e),!i.isInteger()&&(i.c||i.s!==1)||i.lt(C)))throw Error($+"Argument "+(i.isInteger()?"out of range: ":"not an integer: ")+Y(i));if(!_)return new p(h);for(t=new p(C),l=r=new p(C),c=s=new p(C),m=z(_),o=t.e=m.length-h.e-1,t.c[0]=Ne[(u=o%N)<0?N+u:u],e=!e||i.comparedTo(t)>0?o>0?t:l:i,u=G,G=1/0,i=new p(m),s.c[0]=0;a=g(i,t,0,1),n=r.plus(a.times(c)),n.comparedTo(e)!=1;)r=c,c=n,l=s.plus(a.times(n=l)),s=n,t=i.minus(a.times(n=t)),i=n;return n=g(e.minus(r),c,0,1),s=s.plus(n.times(l)),r=r.plus(n.times(c)),s.s=l.s=h.s,o=o*2,f=g(l,c,o,S).minus(h).abs().comparedTo(g(s,r,o,S).minus(h).abs())<1?[l,c]:[s,r],G=u,f},d.toNumber=function(){return+Y(this)},d.toPrecision=function(e,t){return e!=null&&R(e,1,U),oe(this,e,t,2)},d.toString=function(e){var t,r=this,c=r.s,n=r.e;return n===null?c?(t="Infinity",c<0&&(t="-"+t)):t="NaN":(e==null?t=n<=L||n>=M?he(z(r.c),n):J(z(r.c),n,"0"):e===10&&se?(r=q(new p(r),A+n+1,S),t=J(z(r.c),r.e,"0")):(R(e,2,ee.length,"Base"),t=y(J(z(r.c),n,"0"),10,e,c,!0)),c<0&&r.c[0]&&(t="-"+t)),t},d.valueOf=d.toJSON=function(){return Y(this)},d._isBigNumber=!0,d[Symbol.toStringTag]="BigNumber",d[Symbol.for("nodejs.util.inspect.custom")]=d.valueOf,w!=null&&p.set(w),p}function W(w){var g=w|0;return w>0||w===g?g:g-1}function z(w){for(var g,y,x=1,d=w.length,C=w[0]+"";x<d;){for(g=w[x++]+"",y=N-g.length;y--;g="0"+g);C+=g}for(d=C.length;C.charCodeAt(--d)===48;);return C.slice(0,d+1||1)}function ne(w,g){var y,x,d=w.c,C=g.c,A=w.s,S=g.s,L=w.e,M=g.e;if(!A||!S)return null;if(y=d&&!d[0],x=C&&!C[0],y||x)return y?x?0:-S:A;if(A!=S)return A;if(y=A<0,x=L==M,!d||!C)return x?0:!d^y?1:-1;if(!x)return L>M^y?1:-1;for(S=(L=d.length)<(M=C.length)?L:M,A=0;A<S;A++)if(d[A]!=C[A])return d[A]>C[A]^y?1:-1;return L==M?0:L>M^y?1:-1}function R(w,g,y,x){if(w<g||w>y||w!==V(w))throw Error($+(x||"Argument")+(typeof w=="number"?w<g||w>y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(w))}function pe(w){var g=w.c.length-1;return W(w.e/N)==g&&w.c[g]%2!=0}function he(w,g){return(w.length>1?w.charAt(0)+"."+w.slice(1):w)+(g<0?"e":"e+")+g}function J(w,g,y){var x,d;if(g<0){for(d=y+".";++g;d+=y);w=d+w}else if(x=w.length,++g>x){for(d=y,g-=x;--g;d+=y);w+=d}else g<x&&(w=w.slice(0,g)+"."+w.slice(g));return w}var k=Ce();const We=(w,g,y)=>{if(!w?.length)return null;let x=new k(0);if(w.some(C=>(C.upsell_price||C.price)?.pricing_type==="dynamic")&&!g)return null;for(const C of w){const A=C.upsell_price||C.price,S=C.quantity||1;if(A?.pricing_type==="dynamic"&&A?.base_amount&&g){const L=new k(A.base_amount),M=new k(g);if(M.gt(0)){const X=L.dividedBy(M).times(new k(10).pow(y)).times(S);x=x.plus(X.integerValue(k.ROUND_CEIL))}}else A?.unit_amount&&(x=x.plus(new k(A.unit_amount).times(S)))}return x.toString()},Xe=(w,g,y)=>w?.length?w.map(x=>{if(x.pricing_type==="dynamic"&&x.base_amount_usd&&x.proration_rate&&g){const d=new k(x.base_amount_usd),C=new k(g),A=new k(x.proration_rate);if(C.gt(0)){const S=d.dividedBy(C).times(A).times(x.quantity||1).times(new k(10).pow(y)).integerValue(k.ROUND_CEIL),L=new k(x.amount.replace("-","")),M=k.min(S,L);return{...x,amount:`-${M.toString()}`}}}return x}):[],Ye=async w=>{const[g,y]=await Promise.all([de.get(`/api/subscriptions/${w}`).then(x=>x.data),de.get(`/api/subscriptions/${w}/change-plan`).then(x=>x.data)]);return{subscription:g,table:y}},Qe=({id:w,items:g})=>de.post(`/api/subscriptions/${w}/change-plan`,{items:g}).then(y=>y.data);function at(){const w=je(),{id:g}=qe(),{t:y,locale:x}=Be(),{connect:d,session:C}=be(),[A]=Fe(),S=A.get("redirectUrl"),L=ve.useRef(null),M=He(),{loading:X,error:G,data:O}=Re(()=>Ye(g)),[I,T]=Te({loading:!1,priceId:"",total:"",due:"",newCredit:"",appliedCredit:"",setup:null,prorations:[],items:[],paying:!1,paid:!1});let K=[];I.items.length>0?K=I.items:O?.subscription?.items&&(K=O.subscription.items);const se=K?.length&&K.some(h=>(h.upsell_price||h.price)?.pricing_type==="dynamic")&&O?.subscription?.paymentMethod?.type!=="stripe",{liveRateInfo:p,liveRateUnavailable:oe}=ze({subscriptionId:O?.subscription?.id,currencyId:O?.subscription?.paymentCurrency?.id,enabled:!!se});if(G)return B.jsx(we,{severity:"error",children:le(G)});if(X||!O)return B.jsx(Se,{});if(!O.subscription)return B.jsx(we,{severity:"error",children:y("payment.customer.changePlan.subscriptionNotFound")});const ie=I.items.length?I.items:O.subscription.items,q=ie?.length&&ie.some(h=>(h.upsell_price||h.price)?.pricing_type==="dynamic")&&O.subscription.paymentMethod?.type!=="stripe",Y=async h=>{try{if(I.priceId===h)return;const _=O.subscription.items.find(v=>O.table.items.some(E=>E.price_id===v.price_id));if(_.price_id===h){T({priceId:"",total:"",due:"",setup:null,prorations:[],items:[]});return}const P=await Qe({id:O.subscription.id,items:[{id:_.id,deleted:!0,clear_usage:!1},{price_id:h,quantity:1}]});T({priceId:h,...P}),setTimeout(()=>L.current?.scrollIntoView({behavior:"smooth"}),100)}catch(_){ae.error(le(_)),T({priceId:"",total:"",due:"",setup:null,prorations:[],items:[]})}},e=()=>{S?window.location.href=S:w(`/customer/subscription/${O.subscription.id}`)},t=async()=>{try{T({loading:!0});const _=[{id:O.subscription.items.find(v=>O.table.items.some(E=>E.price_id===v.price_id)).id,deleted:!0,clear_usage:!1},{price_id:I.priceId,quantity:1}],P=await de.put(`/api/subscriptions/${g}`,{proration_behavior:"create_prorations",items:_});if(P.data.connectAction){T({paying:!0});try{T({paying:!0}),d.open({locale:x,action:P.data.connectAction,saveConnect:!1,messages:{title:y("payment.customer.changePlan.pay"),scan:y("payment.customer.changePlan.scan"),success:y("payment.customer.changePlan.success"),error:y("payment.customer.changePlan.error"),confirm:""},extraParams:{invoiceId:P.data.pending_update?.updates?.latest_invoice_id,subscriptionId:P.data.id,sessionUserDid:C?.user?.did},onSuccess:()=>{T({paid:!0,paying:!1}),setTimeout(()=>{d.close(),e()},2e3)},onClose:()=>{d.close(),T({paying:!1})},onError:v=>{T({paying:!1}),ae.error(le(v))}})}catch(v){ae.error(le(v))}finally{T({paying:!1})}}else ae.success(y("payment.customer.changePlan.success")),T({paid:!0}),setTimeout(e,2e3)}catch(h){console.error(h),ae.error(le(h))}finally{T({loading:!1})}},r={...O.table,currency:O.subscription.paymentCurrency};(r.items||[]).forEach(h=>{h.is_selected=h.price_id===I.priceId,O.subscription.items.find(_=>_.price_id===h.price_id)&&(h.is_highlight=!0,h.is_disabled=!0,h.highlight_text=y("payment.customer.changePlan.current"),I.priceId||(h.is_selected=!0))});const{recurring:c}=O.subscription.items.find(h=>h.price.type==="recurring")?.price||{},n=[c?.interval,c?.interval_count].join("-"),o=q&&p?.rate,u=o?Xe(I.prorations,p?.rate,O.subscription.paymentCurrency.decimal):I.prorations,s=(o?We(ie,p?.rate,O.subscription.paymentCurrency.decimal):null)||I.total,l=()=>{if(!o)return{due:I.due,newCredit:I.newCredit};const h=new k(s||"0"),_=u.reduce((E,D)=>E.plus(new k(D.amount||"0")),new k(0)),P=new k(I.appliedCredit||"0"),v=h.plus(_).minus(P);return v.lt(0)?{due:"0",newCredit:v.abs().toString()}:{due:v.toString(),newCredit:"0"}},{due:a,newCredit:f}=l(),m=(h,_,P)=>B.jsxs(te,{direction:"row",sx:{justifyContent:"space-between"},children:[B.jsx(Ee,{variant:"h6",sx:{fontWeight:"normal"},children:h}),B.jsxs(Ee,{component:"p",style:{fontWeight:"bold"},children:[P,Ue(_,O.subscription.paymentCurrency.decimal,2)," ",O.subscription.paymentCurrency.symbol]})]},_);return B.jsxs(te,{direction:"column",spacing:4,sx:{mb:4},children:[B.jsx(te,{className:"page-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:M?B.jsx(De,{}):B.jsxs(te,{direction:"row",onClick:()=>$e(`/customer/subscription/${O.subscription.id}`),sx:{alignItems:"center",fontWeight:"normal",cursor:"pointer"},children:[B.jsx(Ie,{fontSize:"small",sx:{mr:.5,color:"text.secondary"}}),B.jsx(Ge,{subscription:O.subscription,variant:"h5"})]})}),B.jsxs(te,{direction:"column",sx:{marginTop:32},children:[B.jsx(Ae,{title:y("payment.customer.changePlan.config")}),B.jsx(ke,{mode:"select",alignItems:"left",interval:n,table:r,onSelect:Y,hideCurrency:!0})]}),!O.table&&B.jsx(we,{severity:"error",children:y("payment.customer.changePlan.tableNotFound")}),I.priceId&&I.total&&I.setup&&B.jsxs(te,{direction:"column",spacing:3,sx:{maxWidth:640},children:[B.jsx(Ae,{title:y("payment.customer.changePlan.confirm")}),B.jsx(Le,{items:ie,currency:O.subscription.paymentCurrency,trialInDays:0,billingThreshold:0,showStaking:!1,liveRate:p,rateUnavailable:!!(q&&oe),action:y("payment.customer.changePlan.summary",{date:Me(I.setup.period.end*1e3,"lll",x)}),completed:!0,isStripePayment:O.subscription.paymentMethod?.type==="stripe"}),B.jsx(ye,{}),B.jsxs(te,{direction:"column",spacing:1,children:[m(y("payment.customer.changePlan.total"),s),u.map(h=>m(h.description,h.amount)),I.appliedCredit>"0"&&m(y("payment.customer.changePlan.appliedCredit"),I.appliedCredit,"-"),new k(f).gt(0)&&m(y("payment.customer.changePlan.newCredit"),f),B.jsx(ye,{}),m(y("payment.customer.changePlan.remaining"),a),B.jsx(ye,{}),B.jsxs(te,{direction:"row",spacing:2,sx:{alignItems:"center",justifyContent:"flex-end",pt:2},children:[B.jsx(Oe,{disabled:I.loading||I.paying,onClick:()=>T({priceId:""}),variant:"text",size:"large",children:y("common.cancel")}),B.jsx(Oe,{ref:L,onClick:t,variant:"contained",size:"large",sx:{width:150},loading:I.loading||I.paying,loadingPosition:"end",children:y("common.confirm")})]})]})]})]})}export{at as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,B as t}from"./vendor-mui-BXZut9Pz.js";import"./vendor-blocklet-
|
|
1
|
+
import{j as r,B as t}from"./vendor-mui-BXZut9Pz.js";import"./vendor-blocklet-B67R14so.js";import{b4 as s}from"./index-B4yaPb7B.js";function p({children:o}){return r.jsx(t,{onClick:s,children:o})}export{p as C};
|