1import{a2 as L,j as e,bp as R,G as k,v as b,c as h,r as p,a3 as w,B as o,n as f,M as n,h as j,dx as z,dy as E,dz as _,dA as T,u as N,dB as V}from"./index-B0C6QDQC.js";import{C as W}from"./Chip-BTDX7Kd6.js";import{U as H,N as F}from"./UserAreaLayout-DvE7aivj.js";import{C as S,u as O,a as U}from"./react-stripe.esm-B-yMBa37.js";import{N as $}from"./NoDataWarning-C04Fpe5o.js";const G=L(e.jsx("path",{d:"M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2m0 14H4v-6h16zm0-10H4V6h16z"}));function P({open:a}){return e.jsx(R,{sx:{zIndex:99},open:a,children:e.jsx(k,{color:"secondary"})})}function q(a){const r=b(),c=h(s=>s.accountReducer),d=h(s=>s.stripeAccountReducer.stripeInfo),[l,i]=p.useState(!1),m=()=>d.default_source===a.itemID?e.jsx(o,{sx:{padding:"4px 8px",textAlign:"left"},children:e.jsx(W,{color:"primary",label:e.jsx(n,{id:"account.DefaultLab"})})}):null,x=async s=>{i(!0),await r(z(d.id,s));const C=c.pendingPayments.map(g=>g.latest_invoice);await r(E(C)),i(!1)},u=async s=>{i(!0),await r(_(s.customer,s.id)),s.id===d.default_source&&c.userInfo&&await r(T({loginId:c.userInfo.LoginId})),i(!1)};return e.jsxs(w,{sx:{display:"flex",padding:"1rem",marginBottom:2,flexFlow:"wrap",justifyContent:"space-between"},children:[e.jsx(P,{open:l}),e.jsxs(o,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap"},children:[e.jsx(o,{sx:{flex:0,padding:"4px 8px",textAlign:"left"},children:e.jsx(G,{})}),e.jsxs(o,{sx:{padding:"4px 8px",textAlign:"left"},children:[e.jsxs(f,{children:[a.ccType," ",e.jsx(n,{id:"account.cardEndingIn"})," ",a.ccEnding]}),e.jsxs(f,{children:[e.jsx(n,{id:"account.cardExpires"}),a.ccExpirationDate]})]}),m()]}),e.jsxs(o,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap"},children:[d.default_source!==a.itemID&&e.jsx(j,{variant:"outlined",size:"small",style:{margin:8},onClick:()=>x(a.itemID),children:e.jsx(n,{id:"account.setAsDefault"})}),e.jsx(j,{size:"small",color:"secondary",onClick:()=>u(a.ITEM),"data-cy":"delete-card-button",children:e.jsx(n,{id:"common.delete"})})]})]})}const J=a=>e.jsx("fieldset",{style:{padding:8,margin:"0 auto",maxWidth:400,border:"1px solid #b2b8c3",borderRadius:4},children:e.jsx(S,{onReady:r=>r.focus(),onChange:a.handleOnChangeCardInput,options:{hidePostalCode:!0,style:{base:{color:"#fff",fontSize:"18px"}}}})}),K=()=>e.jsx(w,{sx:{bgcolor:"#fff7b3",p:2,mb:2},children:e.jsx(f,{sx:{color:"#222",fontWeight:500},children:e.jsx(n,{id:"notification.CardChangedCharges"})})});function te(){const a=N(),r=b(),c=O(),d=U(),l=h(t=>t.accountReducer),i=h(t=>t.stripeAccountReducer.stripeInfo),[m,x]=p.useState(!1),[u,s]=p.useState(!1),[C,g]=p.useState(!1),y=t=>s(!t),A=t=>{t.error||t.complete===!1?m&&x(!1):t.complete&&x(!0)},M=async()=>{if(g(!0),d&&c){const t=d.getElement(S);if(t){const I=await c.createToken(t,{name:l.userInfo?.LoginId});if(I.token){if(await r(V(i.id,I.token.id)),l.hasPendingPayments){const D=l.pendingPayments.map(B=>B.latest_invoice);await r(E(D))}t.clear(),y(u),x(!1)}}}g(!1)},v=t=>e.jsxs(p.Fragment,{children:[e.jsx(J,{handleOnChangeCardInput:A}),e.jsx(j,{variant:"contained",disabled:!t,style:{marginTop:"1rem"},onClick:M,"data-cy":"save-card-button",children:e.jsx(n,{id:"account.saveCard"})})]});return e.jsxs(H,{dataCy:"userArea-paymentMethod-container",children:[e.jsx(F,{title:a.formatMessage({id:"seo.userArea.editCard.title"}),description:a.formatMessage({id:"seo.userArea.editCard.description"})}),e.jsx(P,{open:C}),e.jsx(f,{variant:"h2",gutterBottom:!0,children:e.jsx(n,{id:"account.paymentMethod"})}),e.jsx(f,{gutterBottom:!0,children:e.jsx(n,{id:"account.PaymentMethodSubHead"})}),i?e.jsxs(e.Fragment,{children:[e.jsx(o,{sx:{m:"2rem auto"},children:i?.sources?.data?.map(t=>e.jsx(q,{ITEM:t,itemID:t.id,ccType:t.brand,ccEnding:t.last4,ccExpirationDate:`${t.exp_month}/${t.exp_year}`,isdefault:()=>t.id===i.default_source},t.id))}),l.hasPendingPayments&&e.jsx(K,{}),e.jsx(j,{color:"secondary",variant:"outlined","data-cy":"add-new-card-button",style:{marginBottom:"1rem"},onClick:()=>y(u),children:e.jsx(n,{id:u?"common.cancel":"account.insertNewCard"})}),u&&v(m)]}):e.jsx(o,{sx:{mt:4},children:e.jsx($,{})})]})}export{te as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.