PageSourceSearch

https://portal.commoninterest.com/assets/index-DQlVSdao.js

js commoninterest.com collected 2026-09-24 13:27:56 UTC 66,345 bytes, 1 lines download raw bytes

1import{j as e,u as A,q as _,T as Y,r as p,aW as ne,bf as N,aP as be,k as J,B as X,W as dt,n as et,F as De,aE as tt,cf as _e,cC as ot,a9 as at,Y as Ne,aO as Xe,cc as ve,cb as we,I as he,bi as qe,cD as nt,ct as mt,cu as ut,cv as yt,U as Re,S as ge,M as pt,cE as ht,aA as gt,aB as bt,cF as xt,cG as ft,aC as jt,cH as Nt}from"./elements-DVh2jUIM.js";import{B as vt,M as wt,a as Ft}from"./BillingSideContentContainer-2GpqK0JI.js";import{R as St,S as Pt}from"./SupportLink-Bmmzei6G.js";import{t as Me}from"./trackEvent-CeNPAPKA.js";import{L as te,q as M,t as Mt,j as se,ae as Ct,T as j,A as st,N as Dt,aJ as It,aK as Tt,aL as At,aM as Lt,o as kt}from"./index-DeQvL4I7.js";import{C as rt,u as qt,a as $t,P as Et,E as Rt,l as Bt}from"./CreditCardOnlyNotice-CsSflxM6.js";import{u as re,a as P,b as Ve}from"./store-B67Q7V7g.js";import{u as lt,C as _t,a as Xt,b as Vt,d as Wt,g as Ut}from"./ClassifiedCardSummary-BDgGGGpz.js";import{i as Jt}from"./isSurchargedFunding-ChfbXkw5.js";import{u as Kt}from"./useIsMobile-Davbtvz5.js";import{S as zt}from"./SetupNewPaymentMethodForm-e9vzbtVx.js";import{u as Q}from"./useRedesign-DVyq07A4.js";import{A as We}from"./index-yG4hzqQn.js";import{U as Ue}from"./UpcomingCharges-Bw9OfKNs.js";import{S as Je}from"./SavedPaymentMethodOptions-D33lqfLB.js";import{R as Ke}from"./recurringIntervals-CtqK-wqt.js";import{i as Gt}from"./isSameDay-CQTDJwZ-.js";import{A as Ht}from"./authorization-CE7gncHO.js";import"./ManagePayment-DWws-XIx.js";import"./grids-DXrfAsUA.js";import"./startOfDay-AazlW55I.js";import"./index-BrZWKhU_.js";import"./index.esm-BsOhZrKM.js";import"./useAuthorization-D7B2eQha.js";function Ce({title:t,className:s="",containerClassName:l="",children:r}){return e.jsxs("section",{className:`${s} space-y-4`,children:[t&&e.jsx("h2",{className:"flex items-center gap-2 font-semibold leading-6",children:t}),e.jsx("div",{className:`${l} space-y-6`,children:r})]})}function it({checked:t,onChange:s,error:l,managementCompany:r}){const{t:m}=A();return e.jsxs("div",{className:"px-8 pt-6 pb-4",children:[e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t,"aria-invalid":l,"aria-describedby":"explicit-consent-error",onChange:n=>s(n.target.checked),className:_("mt-0.5 h-4 w-4 shrink-0 rounded-[2px] accent-primary border-2",l?"border-error":"border-base-border"),"data-qa":"explicit-consent-checkbox"}),e.jsx("span",{className:_("text-xs leading-[1.6]",l?"text-error":"text-base-fg"),children:e.jsx(Y,{i18nKey:"billing.confirmPayment.explicitConsent.label",values:{managementCompany:r},components:{Link:e.jsx(te,{to:"/billing/payment-consent",target:"_blank",className:"text-base-link hover:underline"})}})})]}),e.jsx("p",{id:"explicit-consent-error",className:_("mt-2 text-xs text-error",!l&&"invisible"),"aria-hidden":!l,"data-qa":"explicit-consent-error",children:m("billing.confirmPayment.explicitConsent.required")})]})}function xe(t,s){if(!t)return s==null?void 0:s.paymentMethod;if(t.type==="autoDraft")return"autoDraft";if("payment"in t&&t.payment.paymentMethod){const r=t.payment.paymentMethod.paymentMethodType;return r==="creditCard"||r==="debitCard"?r:r==="eCheck"||r==="ach"?"eCheck":r==="autoDraft"?"autoDraft":r}return s==null?void 0:s.paymentMethod}async function ct({startMonth:t,confirmation:s,stripe:l,elements:r}){var c;const m=s.payment.accounts.map(a=>a.id),n=s.payment.acknowledgementId,i=((c=s.payment.paymentMethod)==null?void 0:c.id)??await Ee({stripe:l,elements:r,clientSecret:s.payment.clientSecret??void 0});return await M.confirmAutoDraftEnrollment({ids:m,startMonth:t,paymentMethodId:i,acknowledgementId:n})}async function $e(t,s=void 0,l=void 0,r){if(!t)return await Promise.reject(new Error("No confirmation"));switch(t.type){case"payment":{if(t.payment.paymentMethod)return await M.confirmPayment(t.payment.id);if(r)return await M.confirmPayment(t.payment.id,{confirmationTokenId:r});if(!s)return await Promise.reject(new Error("No stripe"));if(!l)return await Promise.reject(new Error("No stripe"));const{error:m}=await s.confirmPayment({elements:l,clientSecret:t.payment.clientSecret,redirect:"if_required",confirmParams:{return_url:window.location.href}});return m?await Promise.reject(new Error(m.message)):void 0}case"recurringPayment":{if(t.payment.paymentMethod)return await M.confirmRecurringPayment(t.payment.id);const m=await Ee({stripe:s,elements:l,clientSecret:t.payment.clientSecret});return await M.confirmRecurringPayment(t.payment.id,{paymentMethodId:m})}case"futurePayment":{if(t.payment.paymentMethod)return await M.confirmFuturePayment(t.payment.id);const m=await Ee({stripe:s,elements:l,clientSecret:t.payment.clientSecret});return await M.confirmFuturePayment(t.payment.id,{paymentMethodId:m})}default:return await Promise.reject(new Error("Invalid confirmation type"))}}async function Ee({stripe:t,elements:s,clientSecret:l}){var c;if(!t||!s)return Promise.reject(new Error("No stripe"));if(!l)return Promise.reject(new Error("No client secret"));const r=await s.submit();if(r.error)return Promise.reject(new Error(r.error.message));const{error:m,setupIntent:n}=await t.confirmSetup({elements:s,clientSecret:l,redirect:"if_required",confirmParams:{return_url:window.location.href,expand:["payment_method"]}});if(m)return await Promise.reject(new Error(m.message));const i=typeof n.payment_method=="string"?n.payment_method:(c=n.payment_method)==null?void 0:c.id;return i||await Promise.reject(new Error("No payment method"))}function Zt({error:t}){return t?e.jsx("div",{className:_("px-4 py-2 border border-error roun
1ded","text-left font-semibold leading-5 text-sm text-error"),children:e.jsx("p",{children:t})}):null}function Yt({account:t,paymentType:s}){var c;const l=(t==null?void 0:t.accountNumber)??"",r=((c=t==null?void 0:t.subLedgerId)==null?void 0:c.toString())??"",n=new URLSearchParams({accountNumber:l,subLedgerId:r}).toString(),{t:i}=A();return e.jsx("div",{className:"px-8 mb-4",children:e.jsx(Y,{i18nKey:i("billing.paymentForm.submitPaymentConsentMessage.disclosure",{buttonType:s!=="recurringPayment"?"Confirm & Pay":"Schedule Payments"}),components:{Link:e.jsx(te,{target:"_blank",to:`/billing/payment-consent?${n}`,className:"text-base-link hover:underline"})}})})}function Be({paymentMethod:t}){const{t:s}=A();return e.jsxs(e.Fragment,{children:[(t==null?void 0:t.card)&&e.jsxs("p",{children:[s([`billing.cardType.${t.card.brand}`,"billing.cardType.default"])," ",t.card.last4]}),(t==null?void 0:t.bankAccount)&&e.jsxs("p",{children:[t.bankAccount.bankName," XXXX-XXXX-XXXX-",t.bankAccount.last4]})]})}function Qt({confirmation:t}){const{t:s}=A(),l=re(n=>n.setStartMonth),r=re(n=>n.startMonth),m=p.useMemo(()=>"availableStartMonths"in t.payment?t.payment.availableStartMonths.map(n=>({month:n,text:s("main.months."+(n-1).toString()).toString()})):[{month:1,text:s("main.months.0")},{month:2,text:s("main.months.1")},{month:3,text:s("main.months.2")},{month:4,text:s("main.months.3")},{month:5,text:s("main.months.4")},{month:6,text:s("main.months.5")},{month:7,text:s("main.months.6")},{month:8,text:s("main.months.7")},{month:9,text:s("main.months.8")},{month:10,text:s("main.months.9")},{month:11,text:s("main.months.10")},{month:12,text:s("main.months.11")}],[t.payment,s]);return p.useEffect(()=>{var n;return l((n=m[0])==null?void 0:n.month)},[m]),e.jsxs("div",{className:"text-left text-base-fg space-y-4 mb-8",children:[t.payment.accounts.map(n=>{var i;return e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold line-clamp-1 text-left",children:[n.accountWithSubCode," -"," ",ne(n.propertyAddress,"half")," |"," ",n.associationName]}),e.jsx("p",{children:s("billing.paymentForm.autoDraft.confirmFee",{fee:N((((i=n.autoDraftSettings)==null?void 0:i.applicationFee)??0)/100)})})]},n.accountWithSubCode)}),t.payment.paymentMethod&&e.jsx("div",{className:"font-semibold leading-5 text-sm text-gray-600",children:e.jsx(Be,{paymentMethod:t.payment.paymentMethod})}),e.jsx(be,{className:"md:w-1/2",label:s("billing.paymentForm.startMonth"),qaListAttribute:"auto-draft-month-list",qaListValue:n=>JSON.stringify({...m[n]}),qaOptionValue:n=>JSON.stringify({...m[n]}),value:r,options:m.map(n=>n.month),deriveKey:n=>n.toString(),displayOption:n=>{var i;return((i=m.find(c=>c.month===n))==null?void 0:i.text)??""},displaySelected:n=>{var i;return((i=m.find(c=>c.month===n))==null?void 0:i.text)??""},onChange:n=>l(n)})]})}function Ot({confirmation:t,paymentOption:s,feeQuote:l}){var v;const{t:r}=A(),m=lt(),n=((v=s==null?void 0:s.convenienceFee.type)==null?void 0:v.toLowerCase())==="flat"||s==null?void 0:s.convenienceFee.percentage,i=xe(t,s),c=i==="creditCard"||i==="debitCard",a=!c&&t.payment.amount>=2e5,o=a&&"largeTransactionFee"in t.payment&&t.payment.largeTransactionFee!==0;p.useEffect(()=>{a&&Me("payment:large-transaction-fee-seen",{enabled:o,paymentFrequency:"one-time"})},[a,o]);let x=null;switch(t==null?void 0:t.type){case"payment":x=new Date;break;case"futurePayment":x=t.payment.scheduledDate;break;case"recurringPayment":x=t.payment.anchorDate;break;default:x=new Date}const b=l?Jt(l.fundingType):!1,g=l?l.total:t.payment.total,d=!!l&&b,u=!l&&!!t.payment.convenienceFee;return e.jsxs("div",{className:"text-left text-base-fg space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-600 text-sm","data-qa":"account","data-qa-value":JSON.stringify({accountId:t.payment.account.accountWithSubCode}),children:`${t.payment.account.accountWithSubCode} | ${t.payment.account.associationName}`}),x&&e.jsx("p",{className:"font-semibold text-xl","data-qa":"payment-date","data-qa-value":JSON.stringify({paymentDate:J(x,{format:"numeric",timeZone:"UTC"})}),children:`${r("billing.confirmPayment.details.date")}: ${J(x,{format:"numeric",timeZone:"UTC"})}`}),e.jsx("p",{className:"font-semibold text-xl",children:r("billing.confirmPayment.details.totalAmount")}),e.jsx("p",{className:"text-3xl font-semibold","data-qa":"payment-amount-total","data-qa-value":JSON.stringify({paymentTotal:N(g/100)}),children:N(g/100)}),i==="creditCard"&&(m?e.jsx(_t,{className:"mt-2",feePercentage:n}):e.jsx(rt,{className:"mt-2"}))]}),e.jsxs("div",{className:"font-semibold leading-5 text-sm text-gray-600",children:[l&&!b&&e.jsx("p",{"data-qa":"fee-confirmation-no-surcharge",children:r("billing.feeConfirmation.debitNoSurcharge")}
1),d&&l&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{"data-qa":"payment-amount","data-qa-value":JSON.stringify({payment:N(l.amount/100)}),children:[r("billing.confirmPayment.details.amount"),":"," ",N(l.amount/100)]}),e.jsx("p",{"data-qa":"fee-amount","data-qa-value":JSON.stringify({fee:N(l.surchargeAmount/100)}),children:`${r("billing.confirmPayment.details.fee")}: ${N(l.surchargeAmount/100)}`})]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{"data-qa":"payment-amount","data-qa-value":JSON.stringify({payment:N(t.payment.amount/100)}),children:[r("billing.confirmPayment.details.amount"),":"," ",N(t.payment.amount/100)]}),e.jsx("p",{"data-qa":"fee-amount","data-qa-value":JSON.stringify({fee:N(t.payment.convenienceFee/100)}),children:`${r("billing.confirmPayment.details.fee")}: ${N(t.payment.convenienceFee/100)}`})]}),!c&&t.payment.amount>=2e5&&"largeTransactionFee"in t.payment&&t.payment.largeTransactionFee!==0&&e.jsx("p",{className:"pt-4 text-xs","data-qa":"large-transaction-fee",children:r("billing.paymentForm.additionalFeeDisclaimer",{largeAmountFee:t.payment.largeTransactionFee*100})})]}),e.jsx("div",{className:"font-semibold leading-5 text-sm text-gray-600",children:t.payment.paymentMethod&&e.jsx(Be,{paymentMethod:t.payment.paymentMethod})})]})}function ea({confirmation:t,paymentOption:s}){const{t:l}=A(),r=P(a=>a),m=xe(t,s),i=!(m==="creditCard"||m==="debitCard")&&t.payment.amount>=2e5,c=i&&"largeTransactionFee"in t.payment&&t.payment.largeTransactionFee!==0;return p.useEffect(()=>{i&&Me("payment:large-transaction-fee-seen",{enabled:c,paymentFrequency:"recurring"})},[i,c]),e.jsxs("div",{className:"flex flex-col gap-4 mb-2 text-base-fg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base-header font-semibold",children:t.payment.account.associationName}),e.jsx("p",{children:l("billing.paymentForm.recurringModalView.account")+": "+t.payment.account.accountWithSubCode})]}),t.payment.paymentMethod&&e.jsxs("div",{children:[e.jsx("p",{className:"text-base-header font-semibold",children:l("billing.paymentForm.recurringModalView.paymentMethod")}),e.jsx(Be,{paymentMethod:t.payment.paymentMethod})]}),r.scheduleInterval&&e.jsxs("div",{children:[e.jsx("p",{className:"text-base-header font-semibold",children:l("billing.paymentForm.recurringModalView.frequency")}),e.jsx("p",{children:r.scheduleStartDate?l("billing.paymentForm.recurringModalView.timeInterval",{interval:l(`billing.intervalSchedule.${r.scheduleInterval}`),date:J(r.scheduleStartDate)}):l(`billing.intervalSchedule.${r.scheduleInterval}`)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-base-header font-semibold",children:l("billing.paymentForm.recurringModalView.paymentAmount")}),e.jsx("p",{children:r.payFullBalance?`Full Balance${r.maxAmount?` Up To ${N(Number(r.maxAmount))}`:""}`:r.amount&&N(Number(r.amount))})]}),m==="creditCard"&&e.jsx(rt,{}),r.maxAmount&&e.jsx("p",{className:"text-xs",children:l("billing.paymentForm.recurringModalView.maxAmountDisclaimer",{maxAmount:N(Number(r.maxAmount))})}),(s==null?void 0:s.convenienceFee.type)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-base-header font-semibold",children:l("billing.paymentForm.recurringModalView.processingFee")}),e.jsx("p",{children:s!=null&&s.convenienceFee.percentage?l("billing.paymentForm.recurringModalView.fullBalancePercentage",{percentage:s.convenienceFee.percentage}):N(s==null?void 0:s.convenienceFee.flatFee)})]}),c&&"largeTransactionFee"in t.payment&&t.payment.largeTransactionFee!==0&&e.jsx("p",{className:"text-xs","data-qa":"large-transaction-fee",children:l("billing.paymentForm.additionalFeeDisclaimer",{largeAmountFee:t.payment.largeTransactionFee*100})}),e.jsxs("div",{className:"flex items-center justify-between font-semibold border-t border-base-border pt-4",children:[e.jsxs("p",{className:"text-lg text-base-header",children:[l("billing.paymentForm.recurringModalView.total"),":"]}),e.jsx("p",{className:"text-lg text-base-header","data-qa":"payment-amount-total",children:r.payFullBalance?l("billing.paymentForm.recurringModalView.amountVaries"):N(t.payment.total/100)})]})]})}function ta({confirmation:t,state:s,setState:l,onCancel:r,onError:m,onSubmit:n,consentRequired:i,consentGiven:c,onConsentMissing:a}){const{t:o}=A(),x=re(),b=Kt(),g=async()=>{!t||!("acknowledgementId"in t.payment)||await M.confirmAcknowledgement(t.payment.acknowledgementId)},d=(t==null?void 0:t.type)==="recurringPayment",u=()=>{if(t){if(i&&!c){a();return}l("loading"),g().then(()=>{(t.type==="autoDraft"?ct({startMonth:x.startMonth,confirmation:t}):$e(t)).then(n).catch(v=>m(v,!1))}).catch(v=>m(v,!1))}};return e.jsxs("div",{"data-qa":"make-payment__actions",className:_("border-t border-base-border px-8 py-4 flex items-center justify-start gap-4 flex-row-reverse flex-wrap",d&&"border-none pt-0"),children:[e.jsx(X,{type:"button",disabled:s==="loading"||s==="error",onClick:u,variant:"primary","data-qa":"confirm",size:b?"sm":"md",tabIndex:1,children:d?"Schedule Payments":o("billing.confirmPayment.submit",{context:(t==null?void 0:t.type)==="autoDraft"?"autoDraft":""})}),e.jsx(X,{type:"button",disabled:s==="loading",variant:"passiveOutline",onClick:r,"data-qa":"cancel",size:b?"sm":"md",children:o("billing.confirmPayment.cancel")})]})}function aa(t,s){return t==="confirm"?"pay":s?"classify":"submit"}function na({confirmation:t,paymentOption:s,state:l,setState:r,onCancel:m,onError:n,onSubmit:i,consentRequired:c,consentGiven:a,onConsentMissing:o,consentError:x,onConsentChange:b,managementCompany:g,onFeeQuoteChange:d,onErrorClear:u}){const{t:v}
1=A(),k=qt(),D=$t(),[y,$]=p.useState(!1),V=re(),E=t==null?void 0:t.type,w=(t==null?void 0:t.type)==="payment"?t.payment.setupFutureUsage:"offSession",C=E==="autoDraft"?"autoDraft":s==null?void 0:s.paymentMethod,B=E==="futurePayment"||E==="recurringPayment"||w==="offSession",S=E==="futurePayment"||E==="recurringPayment"||["eCheck","autoDraft"].includes(C??""),f=p.useRef(!1),[F,I]=p.useState(B),W=lt(),U=xe(t,s),K=U==="creditCard"||U==="debitCard",z=W&&(t==null?void 0:t.type)==="payment"&&K,Ie=p.useCallback(async R=>{if(!t||t.type!=="payment")throw new Error("Card fee classification is only supported for one-time card payments");const L=await M.updatePayment(t.payment.id,{confirmationTokenId:R,enforceConcurrencyGuard:!1});return{fundingType:L.fundingType??"undetermined",network:L.network??"",surchargeAmount:L.convenienceFee??0,total:L.total??t.payment.total}},[t]),{status:O,result:q,error:le,classify:ie,reclassify:fe,reset:ce}=Xt({stripe:k??void 0,elements:D??void 0,classifyOnBackend:Ie}),G=Wt(z,O);p.useEffect(()=>{if(d){if(G!=="confirm"||!q){d(null);return}d({fundingType:q.fundingType,amount:q.total-q.surchargeAmount,surchargeAmount:q.surchargeAmount,total:q.total})}},[G,q,d]),p.useEffect(()=>{z&&O==="error"&&le&&(n(le),ce())},[O,le]);const de=p.useRef(!1),ae=p.useRef(!1);p.useEffect(()=>{if(z){if(!y){de.current=!1;return}ae.current||de.current||O==="idle"&&(de.current=!0,u==null||u(),ie())}},[z,y,O,ie,u]);const oe=async()=>{!t||!("acknowledgementId"in t.payment)||await M.confirmAcknowledgement(t.payment.acknowledgementId)},me=()=>{if(!k||!D)return;if(!t){n(new Error("No confirmation"));return}if(c&&!a){o();return}r("loading");const R=()=>{oe().then(()=>{(t.type==="autoDraft"?ct({confirmation:t,stripe:k,elements:D,startMonth:V.startMonth}):$e(t,k,D)).then(i).catch(n)}).catch(L=>n(L,!1))};D.submit().then(L=>{if(L.error){n(new Error(L.error.message));return}R()}).catch(n)},Te=()=>{if(!(!k||!D)){if(!t||t.type!=="payment"){n(new Error("No confirmation"));return}if(q){if(c&&!a){o();return}u==null||u(),r("loading"),oe().then(()=>{$e(t,k,D,q.confirmationTokenId).then(i).catch(Ae)}).catch(R=>n(R,!1))}}},Ae=async R=>{if(Ut(R)==="PA072"&&await fe().catch(()=>!1)){r("idle"),et({type:"error",message:v("billing.feeConfirmation.feeChanged")});return}n(R)},Le=()=>{ae.current=!0,$(!1),ce(),u==null||u()},ue=()=>{if(ae.current=!1,u==null||u(),z){ie();return}me()};p.useEffect(()=>{if(t&&l==="idle"){if(!f.current){f.current=!0;return}t.type==="payment"&&M.updatePayment(t.payment.id,{setupFutureUsage:F?"offSession":"oneTime",enforceConcurrencyGuard:!1}).then(()=>D==null?void 0:D.fetchUpdates()).catch(n)}},[F]);const ke=R=>{const L=R.complete&&!R.empty;L||(ae.current=!1),$(L)},ye={pay:{qa:"fee-confirmation-pay",label:v("billing.feeConfirmation.payButton",{amount:N(((q==null?void 0:q.total)??0)/100)})},classify:{qa:"card-classify-next",label:v("billing.confirmPayment.next")},submit:{qa:"confirm",label:v("billing.confirmPayment.submit")}}[aa(G,z)];return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-8 pb-8 space-y-4",children:G==="confirm"&&q?e.jsx(Vt,{brand:q.brand,last4:q.last4,onEditCard:Le,disabled:l==="loading"}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{options:{},onChange:ke}),e.jsx(dt,{id:"save-payment-method",disabled:S,className:"space-x-2",value:F,onChange:I,label:v("billing.confirmPayment.saveToggleLabel").toString()}),S&&e.jsx("div",{className:"text-xs",children:v("billing.confirmPayment.futurePaymentToggleLabel")})]})}),c&&e.jsx(it,{checked:a,onChange:b,error:x,managementCompany:g}),e.jsxs("div",{"data-qa":"make-payment__actions",className:"border-t border-base-border px-8 py-4 flex items-center justify-start gap-4 flex-row-reverse",children:[e.jsx(X,{type:"button",disabled:l==="loading"||O==="classifying"||G!=="confirm"&&!y,onClick:G==="confirm"?Te:ue,variant:"primary","data-qa":ye.qa,tabIndex:1,children:ye.label}),e.jsx(X,{type:"button",disabled:l==="loading",variant:"passiveOutline",onClick:m,"data-qa":"cancel",children:v("billing.confirmPayment.cancel")})]})]})}const sa=Bt(Ct);function ra({confirmation:t,paymentOption:s,onCancel:l,onSubmit:r,setFormState:m,setModalState:n}){const[i,c]=p.useState("idle"),{payExplicitConsent:a}=Mt(),[o,x]=p.useState(!1),[b,g]=p.useState(!1),d=a===!0,u=se(f=>{var F,I,W,U;return((W=(I=(F=f.userSettings)==null?void 0:F.associations)==null?void 0:I.find(K=>K.id===f.selectedAssociationId))==null?void 0:W.companyName)??((U=f.userSettings)==null?void 0:U.companyName)??""}),[v,k]=p.useState(null),[D,y]=p.useState(null),{t:$}=A();p.useEffect(()=>{m(i==="loading"?"loading":"idle")},[i]);const V=t&&"clientSecret"in t.payment?t.payment.clientSecret:"",E=()=>{const f=xe(t,s);if(t&&f){let F;if((t==null?void 0:t.type)==="autoDraft")F=$("billing.paymentForm.success.autoDraft");else if(t.type==="recurringPayment"&&"payFullBalance"in t.payment&&t.payment.payFullBalance){const I=t.payment.amount>0;
1F=$(`billing.paymentForm.success.${I?"recurringPaymentFullBalanceWithMax":"recurringPaymentFullBalance"}.${f}`,I?{amount:N(t.payment.amount/100)}:void 0)}else F=$(`billing.paymentForm.success.${t.type}.${f}`,{amount:N(t.payment.total/100)});t.type!=="recurringPayment"&&n("success"),et({message:F,type:"success",duration:3e4})}r()},w=()=>{if(t)t.type==="recurringPayment"?M.cancelRecurringPayment(t.payment.id).then(l).catch(C):t.type==="futurePayment"?M.cancelFuturePayment(t.payment.id).then(l).catch(C):t.type==="payment"?M.cancelPayment(t.payment.id).then(l).catch(C):l();else return},C=(f,F=!0)=>{F&&k(f.message),c("idle"),console.error(f)},B=p.useCallback(()=>k(null),[]),S=()=>{if(t)switch(t.type){case"autoDraft":return e.jsx(Qt,{confirmation:t});case"recurringPayment":return e.jsx(ea,{confirmation:t,paymentOption:s});default:return e.jsx(Ot,{confirmation:t,paymentOption:s,feeQuote:D})}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-8 pt-4 space-y-4","data-qa":"error",children:[e.jsx(Zt,{error:v}),S()]}),d&&t!==null&&!!t.payment.paymentMethod&&e.jsx(it,{checked:o,onChange:f=>{x(f),f&&g(!1)},error:b,managementCompany:u}),t!=null&&t.payment.paymentMethod?e.jsx("div",{className:"mt-8",children:e.jsx(ta,{confirmation:t,state:i,setState:c,onCancel:w,onError:C,onSubmit:E,consentRequired:d,consentGiven:o,onConsentMissing:()=>g(!0)})}):e.jsx(Rt,{stripe:sa,options:{clientSecret:V??void 0,appearance:{theme:"stripe"}},children:e.jsx(na,{confirmation:t,paymentOption:s,state:i,setState:c,onCancel:w,onError:C,onSubmit:E,consentRequired:d,consentGiven:o,onConsentMissing:()=>g(!0),consentError:b,onConsentChange:f=>{x(f),f&&g(!1)},managementCompany:u,onFeeQuoteChange:y,onErrorClear:B})}),!d&&e.jsx(Yt,{account:(t==null?void 0:t.type)==="autoDraft"||t==null?void 0:t.payment.account,paymentType:t==null?void 0:t.type})]})}function la({account:t}){const{t:s}=A();return e.jsxs("dl",{children:[(t==null?void 0:t.ownerName)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"sr-only",children:s("billing.accountDetails.accountOwner")}),e.jsx("dd",{"data-qa":"name",children:t.ownerName})]}),(t==null?void 0:t.eMail)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"sr-only",children:s("billing.accountDetails.accountOwnerEmail")}),e.jsx("dd",{"data-qa":"email",children:t.eMail})]}),(t==null?void 0:t.phoneNumber)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"sr-only",children:s("billing.accountDetails.accountOwnerPhone")}),e.jsx("dd",{"data-qa":"phone",children:t.phoneNumber})]})]})}function ze({accounts:t}){const s=Q(),{t:l}=A(),r=P(n=>n.account),m=P(n=>n.set);return s?r&&e.jsx(be,{required:!0,options:t,buttonClassName:"mt-1",label:`${l("billing.paymentForm.account.inputLabel")}:`,deriveKey:n=>n.accountWithSubCode??"",qaListAttribute:"account",qaListValue:n=>JSON.stringify({accountId:n.accountNumber,subLedgerId:n.subLedgerId}),qaOptionValue:n=>JSON.stringify({accountId:n.accountNumber,subLedgerId:n.subLedgerId}),displaySelected:n=>`${n.accountWithSubCode} - ${ne(n.propertyAddress,"half")} | ${n.associationName}`,displayOption:n=>`${n.accountWithSubCode} - ${ne(n.propertyAddress,"half")} | ${n.associationName}`,value:r,onChange:n=>m({account:n})}):e.jsx(Ce,{title:l("billing.paymentForm.account.title").toString(),children:r&&e.jsxs(e.Fragment,{children:[e.jsx(be,{required:!0,options:t,label:`${l("billing.paymentForm.account.inputLabel")}:`,deriveKey:n=>n.accountWithSubCode??"",qaListAttribute:"account",qaListValue:n=>JSON.stringify({accountId:n.accountNumber,subLedgerId:n.subLedgerId}),qaOptionValue:n=>JSON.stringify({accountId:n.accountNumber,subLedgerId:n.subLedgerId}),displaySelected:n=>`${n.accountWithSubCode} - ${ne(n.propertyAddress,"half")} | ${n.associationName}`,displayOption:n=>`${n.accountWithSubCode} - ${ne(n.propertyAddress,"half")} | ${n.associationName}`,value:r,onChange:n=>m({account:n})}),e.jsx(la,{account:r})]})})}function Ge({onSetupPaymentMethod:t,onUnenroll:s}){const l=Q(),{t:r}=A(),m=re(a=>a.set),n=re(a=>a.paymentMethod),i=se(a=>a.paymentMethods),c=a=>{var o,x,b,g;if(!a)return r(["billing.paymentForm.method.addNewPaymentRadioLabel.ach","billing.paymentForm.method.addNewPaymentRadioLabel.default"]);
1switch(a.paymentMethodType){case"creditCard":case"debitCard":return a.card&&r([`billing.cardType.${(o=a.card)==null?void 0:o.brand}`,"billing.cardType.default"])+` XXXX-XXXX-XXXX-${(x=a.card)==null?void 0:x.last4}`;case"autoDraft":case"eCheck":return a.bankAccount&&`${(b=a.bankAccount)==null?void 0:b.bankName} XXXX-XXXX-XXXX-${(g=a.bankAccount)==null?void 0:g.last4}`;default:return r("billing.paymentMethod.none")}};return l?e.jsxs("div",{className:"flex flex-col space-y-4 w-full",children:[e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsxs("div",{className:"font-semibold space-y-3 mb-1",children:[e.jsxs("p",{children:[r("billing.paymentForm.method.methodSelectDescription")," "]}),e.jsxs("button",{onClick:t,type:"button","data-qa":"new-method",className:"text-base-link flex items-center gap-2 ml-[2px]",children:[e.jsx(De,{icon:tt}),r("billing.paymentForm.method.addNewPaymentMethodLabel.ach")]})]}),e.jsx(_e,{label:r("billing.paymentForm.method.methodSelectLabel").toString(),qaAttribute:"payment-methods",options:[...i.filter(a=>["ach","eCheck"].includes(a.paymentMethodType)),null],deriveId:a=>(a==null?void 0:a.id)??"",deriveLabel:a=>e.jsx("span",{className:"text-sm",children:c(a)}),value:n,onChange:a=>m({paymentMethod:a})})]}),e.jsx(We,{pageName:"billing",onUnenroll:s})]}):e.jsxs("div",{className:"flex flex-col space-y-4 w-full",children:[e.jsx("p",{className:"font-medium text-sm",children:e.jsx(Y,{i18nKey:"billing.paymentForm.autoDraft.feeDisclosure",components:{Link:e.jsx(te,{to:"/billing/payment-consent",className:"text-base-link hover:underline"})}})}),e.jsx("p",{className:"text-sm",children:r("billing.paymentForm.autoDraft.bankStored")}),e.jsx("p",{className:"text-sm",children:r("billing.paymentForm.autoDraft.frequency")}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsxs("p",{className:"font-semibold mr-2",children:[r("billing.paymentForm.method.methodSelectDescription"),e.jsx(X,{type:"button",variant:"primaryLink",size:"xs",onClick:t,className:"ml-4",children:r("billing.paymentForm.method.addNewPaymentMethodLabel.ach")})]}),e.jsx(_e,{label:r("billing.paymentForm.method.methodSelectLabel").toString(),qaAttribute:"payment-methods",options:[...i.filter(a=>["ach","eCheck"].includes(a.paymentMethodType)),null],deriveId:a=>(a==null?void 0:a.id)??"",deriveLabel:a=>e.jsx("span",{className:"text-sm",children:c(a)}),value:n,onChange:a=>m({paymentMethod:a})})]}),e.jsx(We,{pageName:"billing",onUnenroll:s})]})}const Fe=({payments:t})=>{const{t:s}=A();return t!=null&&t.length?e.jsxs("div",{className:"flex gap-3 p-4 rounded-md bg-amber-100","data-qa":"future-payments-list",children:[e.jsx("div",{children:e.jsx(De,{className:"text-warning h-5 w-5",icon:ot})}),e.jsx("div",{className:"flex flex-col gap-3",children:t==null?void 0:t.map(({id:l,futurePaymentType:r,scheduledDate:m,paymentMethod:n,amount:i,payFullBalance:c})=>e.jsxs("div",{className:"text-base","data-qa":"future-payment","data-qa-value":JSON.stringify({paymentType:r,amount:N((i??0)/100),date:m.toLocaleDateString()}),children:[r!=="autoDraft"&&n&&s(`billing.scheduled.${r}`,{paymentMethod:s(`billing.paymentMethods.${n.paymentMethodType}`).toLowerCase(),amount:c?`${s("billing.amount.balance")}${i?s("billing.amount.upTo",{amount:N(i/100)}):""}`:N((i??0)/100),nextPaymentDate:m.toLocaleString("en-US",{timeZone:"UTC",month:"long",day:"2-digit",year:"numeric"})}),r==="autoDraft"&&s(`billing.scheduled.${r}`,{nextPaymentDate:m.toLocaleString("en-us",{timeZone:"UTC",month:"long",day:"2-digit",year:"numeric"})})]},l))})]}):null};function Se({payments:t}){const{t:s}=A();return e.jsx("ul",{className:"space-y-2","data-qa":"future-payments-list",children:t==null?void 0:t.map(l=>e.jsxs("li",{className:"text-error","data-qa":"future-payment","data-qa-value":JSON.stringify({paymentType:l.futurePaymentType,amount:N((l.amount??0)/100),date:l.scheduledDate.toLocaleDateString()}),children:[l.futurePaymentType!=="autoDraft"&&l.paymentMethod&&s(`billing.scheduled.${l.futurePaymentType}`,{paymentMethod:s(`billing.paymentMethods.${l.paymentMethod.paymentMethodType}`).toLowerCase(),amount:l.payFullBalance?`your full balance${l.amount?` up to ${N(l.amount/100)}`:""}`:N((l.amount??0)/100),nextPaymentDate:l.scheduledDate.toLocaleStr
1ing("en-US",{timeZone:"UTC",month:"long",day:"2-digit",year:"numeric"})}),l.futurePaymentType==="autoDraft"&&s(`billing.scheduled.${l.futurePaymentType}`,{nextPaymentDate:l.scheduledDate.toLocaleString("en-us",{timeZone:"UTC",month:"long",day:"2-digit",year:"numeric"})})]},l.id))})}function ia(t){return!(t!=null&&t.maximumPaymentAmount)||t.maximumPaymentAmount<=0?25e3:Math.round(t.maximumPaymentAmount/100)}function He({onSetupPaymentMethod:t,minDate:s}){const l=Q(),[r,m]=p.useState([]),[n,i]=p.useState("payFull"),c=P(),a=P(y=>y.account),o=P(y=>y.paymentOption),x=P(y=>y.paymentType),b=P(y=>y.set),g=se(y=>y.futurePayments),d=se(y=>y.paymentMethods),u=d==null?void 0:d.filter(y=>o?["creditCard","debitCard"].includes(o.paymentMethod)?["creditCard","debitCard"].includes(y.paymentMethodType):["ach","eCheck"].includes(o.paymentMethod)?["ach","eCheck"].includes(y.paymentMethodType):!1:!1),v=(o==null?void 0:o.convenienceFee.type.toLowerCase())==="percentage"&&!!o.convenienceFee.percentage,k=(o==null?void 0:o.convenienceFee.type.toLowerCase())==="flat"&&!!o.convenienceFee.flatFee;p.useEffect(()=>{if(!a)return;b({amount:(a.balance>=0&&!a.blockLedger?a.balance:0).toFixed(2).toString()});const y=g.filter($=>$.account.accountNumber===a.accountNumber&&$.account.subLedgerId===a.subLedgerId);m(y)},[a,g]),p.useEffect(()=>{b(n==="payFull"?{payFullBalance:!0}:{payFullBalance:!1})},[n]),p.useEffect(()=>{s&&b({scheduleStartDate:s})},[c.paymentType]);const D=y=>a!=null&&a.nextChargeDate&&y.toDateString()===a.nextChargeDate.toDateString()?{classes:"!font-bold"}:{};return a?l?e.jsxs(e.Fragment,{children:[o&&(k||v)&&e.jsx("p",{"data-qa":"fee-disclosure","data-qa-value":JSON.stringify({fee:o.convenienceFee.percentage?`${o.convenienceFee.percentage}%`:`$${o.convenienceFee.flatFee}`}),children:o.convenienceFee.type.toLowerCase()==="percentage"?j("billing.paymentForm.convenienceFee.percentage",{percentage:o.convenienceFee.percentage}):j("billing.paymentForm.convenienceFee.flatFee",{flatFee:N(o.convenienceFee.flatFee)})}),e.jsx("span",{"data-qa":"payment-disclosure-link",children:e.jsx(Y,{i18nKey:"billing.paymentForm.convenienceFee.disclosure",components:{Link:e.jsx(te,{to:`/billing/payment-consent?accountNumber=${a.accountNumber}&subLedgerId=${a.subLedgerId}`,className:"text-base-link hover:underline"})}})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ze,{account:a}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"flex sm:space-x-2",children:a.blockLedger?e.jsx(at,{variant:"danger",children:a.blockLedgerMessage.length>0?a.blockLedgerMessage:j("billing.blockedLedgers.contactManagementCompany")}):e.jsx(Ue,{className:"pb-4 lg:pb-0",accountNumber:a.accountNumber,ownerId:a.ownerId,subLedgerId:a.subLedgerId,qaAttribute:"upcoming-charges"})}),r.length<=2&&(l?e.jsx(Fe,{payments:r}):e.jsx(Se,{payments:r}))]})]}),r.length>2&&(l?e.jsx(Fe,{payments:r}):e.jsx(Se,{payments:r})),e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"flex items-center gap-2 font-semibold leading-6",children:j("billing.paymentForm.method.selectPaymentAmount")}),l&&c.paymentType==="oneTime"?e.jsxs("div",{className:"w-full md:w-1/2 space-y-4",children:[e.jsx(Pe,{paymentType:x,selectedOption:n,setSelectedOption:y=>i(y)}),e.jsx(Ne,{id:"payment-schedule-start-date",className:"w-full",label:j("billing.paymentForm.method.oneTimeDateInputLabel").toString(),value:c.scheduleStartDate,minDate:s,disabled:a.blockPayments,onChange:y=>b({scheduleStartDate:y}),beforeShowDay:D})]}):e.jsx(Pe,{paymentType:x,selectedOption:n,setSelectedOption:y=>i(y)})]}),e.jsxs("div",{className:"text-sm flex flex-col",children:[e.jsxs("div",{className:"font-semibold space-y-3 mb-1",children:[e.jsxs("p",{children:[j("billing.paymentForm.method.methodSelectDescription")," "]}),e.jsxs("button",{onClick:t,type:"button","data-qa":"new-method",className:"text-base-link flex items-center gap-2 ml-[2px]",children:[e.jsx(De,{icon:tt}),j(`billing.paymentForm.method.addNewPaymentMethodLabel.${(o==null?void 0:o.paymentMethod)??"default"}`)]})]}),e.jsx(Je,{paymentOption:o==null?void 0:o.paymentMethod,paymentMethodOptions:u,selectedPaymentMethod:c.paymentMethod,onPaymentMethodSelected:y=>b({paymentMethod:y}),label:j("billing.paymentForm.method.methodSelectLabel").toString(),includeNewPaymentMethod:!0})]}),l&&c.paymentType==="recurring"&&e.jsx("div",{className:"col-span-1",children:e.jsx(Ne,{id:"payment-schedule-start-date",label:j("billing.paymentForm.method.dateInputLabel").toString(),value:c.scheduleStartDate,minDate:s,disabled:a.blockPayments,onChange:y=>b({scheduleStartDate:y}),beforeShowDay:D})}),c.paymentType==="recurring"&&e.jsx(be,{required:!0,qaListAttribute:"frequency",qaListValue:y=>JSON.stringify({interval:y}),qaOptionValue:y=>JSON.stringify({interval:y}),className:"col-start-1",options:Ke,label:`${j("billing.paymentForm.method.intervalInputLabel")}:`,deriveKey:y=>
1y??"",displaySelected:y=>j(`billing.intervalSchedule.${y}`),displayOption:y=>j(`billing.intervalSchedule.${y}`),disabled:a.blockPayments,value:c.scheduleInterval,onChange:y=>b({scheduleInterval:y})}),c.paymentType==="recurring"&&e.jsx("div",{className:"space-x-1",children:c.scheduleInterval&&e.jsx("span",{"data-qa":"enroll-disclaimer",children:e.jsx(Y,{i18nKey:`billing.paymentForm.enrollDisclaimer.${c.scheduleInterval}`,values:{day:J(c.scheduleStartDate??new Date,{format:"day-ordinal"}),quarterDay:J(c.scheduleStartDate??new Date,{format:"day-ordinal"}),month:J(c.scheduleStartDate??new Date,{format:"month"}),startDate:J(c.scheduleStartDate??new Date,{format:"full",month:"short",day:"numeric",year:"numeric"}),ordinal:!0},components:{Link:e.jsx(te,{to:`/billing/manage-account?accountNumber=${a.accountNumber??""}&subLedgerId=${a.subLedgerId??""}`,className:"text-base-link hover:underline"})}})})})]}):e.jsxs(e.Fragment,{children:[o&&(k||v)&&e.jsx("p",{"data-qa":"fee-disclosure","data-qa-value":JSON.stringify({fee:o.convenienceFee.percentage?`${o.convenienceFee.percentage}%`:`$${o.convenienceFee.flatFee}`}),children:o.convenienceFee.type.toLowerCase()==="percentage"?j("billing.paymentForm.convenienceFee.percentage",{percentage:o.convenienceFee.percentage}):j("billing.paymentForm.convenienceFee.flatFee",{flatFee:N(o.convenienceFee.flatFee)})}),e.jsx("span",{"data-qa":"payment-disclosure-link",children:e.jsx(Y,{i18nKey:"billing.paymentForm.convenienceFee.disclosure",components:{Link:e.jsx(te,{to:`/billing/payment-consent?accountNumber=${a.accountNumber}&subLedgerId=${a.subLedgerId}`,className:"text-base-link hover:underline"})}})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ze,{account:a}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx("div",{className:"flex sm:space-x-2",children:a.blockLedger?e.jsx("p",{className:"text-error",children:a.blockLedgerMessage}):e.jsx(Ue,{className:"pb-4 lg:pb-0",accountNumber:a.accountNumber,ownerId:a.ownerId,subLedgerId:a.subLedgerId,qaAttribute:"upcoming-charges"})}),r.length<=2&&(l?e.jsx(Fe,{payments:r}):e.jsx(Se,{payments:r}))]})]}),r.length>2&&(l?e.jsx(Fe,{payments:r}):e.jsx(Se,{payments:r})),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[c.paymentType==="oneTime"?e.jsxs("div",{className:"w-full md:w-1/2 space-y-4",children:[e.jsx(Pe,{paymentType:x,selectedOption:n,setSelectedOption:y=>i(y)}),e.jsx(Ne,{id:"payment-schedule-start-date",className:"w-full",label:j("billing.paymentForm.method.oneTimeDateInputLabel").toString(),value:c.scheduleStartDate,minDate:s,disabled:a.blockPayments,onChange:y=>b({scheduleStartDate:y}),beforeShowDay:D})]}):e.jsx(Pe,{paymentType:x,selectedOption:n,setSelectedOption:y=>i(y)}),c.paymentType==="recurring"&&e.jsx(be,{required:!0,qaListAttribute:"frequency",qaListValue:y=>JSON.stringify({interval:y}),qaOptionValue:y=>JSON.stringify({interval:y}),className:"col-start-1",options:Ke,label:`${j("billing.paymentForm.method.intervalInputLabel")}:`,deriveKey:y=>y??"",displaySelected:y=>j(`billing.intervalSchedule.${y}`),displayOption:y=>j(`billing.intervalSchedule.${y}`),disabled:a.blockPayments,value:c.scheduleInterval,onChange:y=>b({scheduleInterval:y})})]}),e.jsxs("div",{className:"text-sm space-y-2",children:[e.jsxs("p",{className:"font-semibold mr-2",children:[j("billing.paymentForm.method.methodSelectDescription")," ",e.jsxs(X,{onClick:t,className:"ml-4",type:"button",variant:"primaryLink",size:"xs","data-qa":"new-method",children:["+"," ",j(`billing.paymentForm.method.addNewPaymentMethodLabel.${(o==null?void 0:o.paymentMethod)??"default"}`)]})]}),e.jsx(Je,{paymentOption:o==null?void 0:o.paymentMethod,paymentMethodOptions:u,selectedPaymentMethod:c.paymentMethod,onPaymentMethodSelected:y=>b({paymentMethod:y}),label:j("billing.paymentForm.method.methodSelectLabel").toString(),includeNewPaymentMethod:!0})]}),c.paymentType==="recurring"&&e.jsx("div",{className:"col-span-1 md:w-1/2",children:e.jsx(Ne,{id:"payment-schedule-start-date",label:j("billing.paymentForm.method.dateInputLabel").toString(),value:c.scheduleStartDate,minDate:s,disabled:a.blockPayments,onChange:y=>b({scheduleStartDate:y}),beforeShowDay:D})}),c.paymentType==="recurring"&&e.jsxs("div",{className:"space-y-4",children:[c.scheduleInterval&&e.jsx("p",{"data-qa":"enroll-disclaimer",children:j(`billing.paymentForm.enrollDisclaimer.${c.scheduleInterval}V1`,{day:J(c.scheduleStartDate??new Date,{format:"day-ordinal"}),quarterDay:J(c.scheduleStartDate??new Date,{format:"day-ordinal"}),month:J(c.scheduleStartDate??new Date,{format:"month"}),ordinal:!0})}),e.jsx("p",{"data-qa":"manage-payments-link",children:e.jsx(Y,{i18nKey:"billing.paymentForm.enrollDisclaimer.edit",components:{Link:e.jsx(te,{to:`/billing/manage-account?accountNumber=${a.accountNumber??""}
1&subLedgerId=${a.subLedgerId??""}`,className:"text-base-link hover:underline"})}})})]})]}):e.jsx("div",{})}function Pe({paymentType:t,selectedOption:s,setSelectedOption:l}){const r=Q(),m=P(),n=P(a=>a.set),i=P(a=>a.account),c=p.useMemo(()=>ia(i),[i]);return t==="recurring"?e.jsx("div",{children:r?e.jsx(Xe,{value:s,onChange:l,className:"w-full",children:e.jsxs("div",{className:"flex flex-col gap-3 w-full",children:[e.jsx(ve,{value:"payFull",children:({checked:a})=>e.jsxs("div",{className:_(a?"text-base-header border-2 border-primary bg-primary/10 shadow-sm":"text-base-fg border border-base-border bg-transparent shadow-sm","cursor-pointer focus:outline-none rounded-md py-4 px-4 flex flex-col gap-3 text-sm font-medium min-h-[200px] w-full"),id:"pay-full-balance-radio",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:_(a&&"bg-primary",!a&&"border border-base-border","h-4 w-4 rounded-full flex items-center justify-center"),"aria-hidden":"true",children:a&&e.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),e.jsx(we,{className:"font-medium text-base",children:j("billing.paymentForm.method.payFullBalance")})]}),e.jsxs("div",{className:"flex flex-col gap-3 ml-7",children:[e.jsx("p",{className:"text-sm text-base-fg",children:j("billing.paymentForm.method.fullBalanceDescription")}),e.jsx(he,{labelClass:"font-normal text-xs",label:j("billing.paymentForm.method.maxAmount").toString(),id:"max-amount",type:"number",step:"0.01",min:m.maxAmount?"0.50":void 0,max:c,qaAttribute:"max-amount",value:m.maxAmount,disabled:(i==null?void 0:i.blockPayments)||!a,onWheel:o=>o.currentTarget.blur(),onChange:o=>{n({maxAmount:o.target.value})},startIcon:e.jsx("span",{className:"w-5 text-right",children:"$"}),className:"max-w-64",placeholder:"0.00"}),e.jsx("p",{className:"text-xs text-base-fg",children:j("billing.paymentForm.method.maxAmountDescription")})]})]})}),e.jsx(ve,{value:"payOther",children:({checked:a})=>e.jsxs("div",{className:_(a?"text-base-header border-2 border-primary bg-primary/10 shadow-sm":"text-base-fg border border-base-border bg-transparent shadow-sm","cursor-pointer focus:outline-none rounded-md py-4 px-4 flex items-center justify-between text-sm font-medium w-full"),id:"pay-other-amount-radio",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:_(a&&"bg-primary",!a&&"border border-base-border","h-4 w-4 rounded-full flex items-center justify-center"),"aria-hidden":"true",children:a&&e.jsx("span",{className:"rounded-full bg-white w-2 h-2"})}),e.jsx(we,{className:"font-medium text-base",children:j("billing.paymentForm.method.payOtherAmount")})]}),a&&e.jsx(he,{id:"other-amount",type:"number",step:"0.01",min:"0.50",max:c,qaAttribute:"amount",required:!0,value:m.amount,disabled:(i==null?void 0:i.blockPayments)||!a,startIcon:e.jsx("span",{className:"w-5 text-right",children:"$"}),onWheel:o=>o.currentTarget.blur(),onChange:o=>{n({amount:o.target.value})},className:"w-40",placeholder:"0.00"})]})})]})}):e.jsx(Xe,{value:s,onChange:l,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ve,{value:"payFull",children:({checked:a})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-3 items-center",id:"pay-full-balance-radio",children:[e.jsx("span",{className:_(a?"bg-input-active":"bg-input-border","h-4 w-4 rounded-full flex items-center justify-center gap-36 focus:ring-2 focus:ring-offset-2 focus:ring-input-active"),"aria-hidden":"true",children:e.jsx("span",{className:"rounded-full bg-white w-1.5 h-1.5"})}),e.jsx(we,{className:"font-medium",children:j("billing.paymentForm.method.payFullBalance")}),e.jsx(qe,{children:j("billing.paymentForm.method.fullBalanceInfo")})]}),e.jsx(he,{className:"ml-[28px]",labelClass:"font-normal",label:j("billing.paymentForm.method.maxAmount").toString(),id:"max-amount",type:"number",step:"0.01",min:m.maxAmount?"0.50":void 0,max:c,qaAttribute:"max-amount",value:m.maxAmount,disabled:(i==null?void 0:i.blockPayments)||!a,startIcon:e.jsx("span",{className:"w-5 text-right",children:m.maxAmount?"$":""}),onWheel:o=>o.currentTarget.blur(),onChange:o=>{n({maxAmount:o.target.value})}})]})}),e.jsx(ve,{value:"payOther",children:({checked:a})=>e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex gap-3 items-center",id:"pay-other-amount-radio",children:[e.jsx("span",{className:_(a?"bg-input-active":"bg-input-border","h-4 w-4 roun
1ded-full flex items-center justify-center gap-36 focus:ring-2 focus:ring-offset-2 focus:ring-input-active"),"aria-hidden":"true",children:e.jsx("span",{className:"rounded-full bg-white w-1.5 h-1.5"})}),e.jsx(we,{className:"font-medium",children:j("billing.paymentForm.method.payOtherAmount")})]}),e.jsx(he,{className:"ml-[28px]",id:"other-amount",type:"number",step:"0.01",min:"0.50",max:c,qaAttribute:"amount",required:!0,value:m.amount,disabled:(i==null?void 0:i.blockPayments)||!a,startIcon:e.jsx("span",{className:"w-5 text-right",children:m.amount?"$":""}),onWheel:o=>o.currentTarget.blur(),onChange:o=>{n({amount:o.target.value})}})]})})]})})}):e.jsx(he,{className:"w-full",label:j("billing.paymentForm.method.amountInputLabel").toString(),id:"amount",type:"number",step:"0.01",min:"0.50",max:c,qaAttribute:"amount",required:!0,value:m.amount,disabled:i==null?void 0:i.blockPayments,startIcon:e.jsx("span",{className:"w-5 text-right",children:"$"}),onWheel:a=>a.currentTarget.blur(),onChange:a=>{n({amount:a.target.value})}})}function Ze({account:t}){const s=Q(),{t:l}=A();return t.blockLedger?e.jsxs("div",{children:[e.jsxs("p",{"data-qa":"ledger-blocked",children:[l("billing.paymentForm.method.balanceDue"),":"," "]}),e.jsx("div",{className:"text-error text-xl font-semibold",children:l("billing.blockedLedgers.blocked")})]}):s?e.jsxs("div",{children:[e.jsx("p",{"data-qa":"balance-due","data-qa-value":JSON.stringify({balance:N(t.balance)}),children:l("billing.paymentForm.method.balanceDue")}),e.jsx("p",{className:"text-3xl font-semibold",children:N(t.balance)})]}):e.jsx("div",{children:e.jsxs("p",{"data-qa":"balance-due","data-qa-value":JSON.stringify({balance:N(t.balance)}),className:"flex items-center gap-2 font-semibold text-xl",children:[l("billing.paymentForm.method.balanceDue"),e.jsx("span",{children:N(t.balance)})]})})}function Ye({paymentOptions:t,paymentType:s,defaultPaymentOption:l,minDate:r}){const[m,n]=st(),i=m.get("paymentMethod")==="auto-draft",c=Q(),{t:a}=A(),o=P(u=>u.paymentOption),x=P(u=>u.set);p.useEffect(()=>{if(i){const u=t.find(({paymentMethod:v})=>v==="autoDraft");u&&(x({paymentOption:u}),m.delete("paymentMethod"),n(m))}else l&&!o&&x({paymentOption:l})},[l,i,o,t,m,n,x]),p.useEffect(()=>{x({scheduleStartDate:r})},[r,s,x]);const b=s==="oneTime"?t.filter(u=>!u.recurring):t.filter(u=>u.recurring),g=(o==null?void 0:o.paymentMethod)==="autoDraft",d={br:e.jsx("br",{})};return e.jsxs(e.Fragment,{children:[t&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(nt,{className:"mt-4",label:a("billing.paymentForm.method.paymentOptionSelectLabel"),options:b,deriveKey:u=>(u==null?void 0:u.settingId.toString())??"",qaAttribute:u=>u==null?void 0:u.paymentMethod,displayOption:u=>a(`billing.paymentMethod.${u.paymentMethod}`),value:o,onChange:u=>x({paymentOption:u}),useRedesign:c}),g&&c&&e.jsxs("div",{className:"flex justify-end items-center gap-4",children:[e.jsx("span",{className:"text-base-header font-normal",children:a("billing.paymentMethod.bankAccountOrAutoDraft")}),e.jsx(qe,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:a("billing.paymentMethod.infoPopup.bankAccount")}),e.jsx("p",{children:a("billing.paymentMethod.infoPopup.autoDraft")})]})})]})]}),s==="recurring"&&!c&&t.filter(u=>u.paymentMethod==="autoDraft").length>0&&e.jsxs("div",{className:"flex justify-end",children:[e.jsx("span",{className:"mr-2",children:a("billing.paymentForm.bankAccountOrAutoDraft")}),e.jsx(qe,{children:e.jsx(Y,{i18nKey:"billing.paymentForm.toolTipMessage.bankAccountOrAutoDraft",components:d})})]})]})}function Qe({paymentOptions:t,initialPaymentType:s}){const l=Q(),{t:r}=A(),m=P(a=>a.paymentType),n=P(a=>a.account),i=P(a=>a.set),c=p.useMemo(()=>{const a=[];return t.some(o=>o.recurring)&&a.push("recurring"),t.some(o=>!o.recurring)&&a.push("oneTime"),a},[t]);return p.useEffect(()=>{s&&i({paymentType:s})},[s,i]),p.useEffect(()=>{if(c.length>0){const a=c.includes("recurring")?"recurring":"oneTime";i({paymentType:a})}},[n,c,i]),e.jsx(Ce,{title:r("billing.paymentForm.paymentType.title").toString(),children:l?e.jsx("div",{className:"mt-4 w-full",children:e.jsx(mt,{selectedIndex:c.findIndex(a=>a===m),onChange:a=>i({paymentType:c[a]}),children:e.jsx(ut,{className:"flex w-full flex-row","data-qa":"payment-type-tabs",children:c.map(a=>e.jsx(yt,{as:"button","data-qa":`tab-${a}`,className:({selected:o})=>_("py-2 flex-1 text-center font-bold leading-5 text-input-fg underline-offset-4","focus:outline-none","border-b-2 hover:border-base-link",o&&"border-base-link text-base-link"),children:r(`billing.paymentType.${a}`)},`payment-type-${a}`))})})}):e.jsx(nt,{qaAttribute:a=>a,className:"mt-4",label:r("billing.paymentForm.paymentType.inputLabel"),options:c,deriveKey:a=>a,displayOption:a=>r(`billing.paymentType.${a}`),value:m,onChange:a=>i({paymentType:a})})})}function ca(t,s,l){return t.filter(m=>m.accountNumber===s&&m.subLedgerId===l).at(0)??t.at(0)}function Oe({loading:t,accounts:s,paymentOptions:l,initialPaymentSelections:r,onSubmit:m,onConfirmation:n,onAccountChange:i}){const c=Q(),{t:a}=A(),[o]=st(),x=P(h=>h.set),b=P(h=>h.account),g=P(h=>h.paymentType),d=P(h=>h.paymentOption),u=P(h=>h.paymentMethod),v=P(h=>h.amount),k=P(h=>h.maxAmount),D=P(h=>h.payFullBalance),{navigateToUrl:y}=Dt(),$=P(h=>h.scheduleInterval),V=P(h=>h.scheduleStartDate),E=Ve(),w=Ve(h=>h.confirmation),C=se(),[B,S]=p.useState("idle"),[f,F]=p.useState("closed"),[I,W]=p.useState(),[U,K]=p.useState(!1),[z,Ie]=p.useState(!1),[O,q]=p.useState([]),[le,ie]=p.useState(),fe=/^true$/i.test(o.get("instantPay")??""),ce=o.get("accountNumber")??void 0,G=o.has("subLedgerId")?Number(o.get("subLedgerId")):void 0,de=()=>{if((r==null?void 0:r.paymentMethod)==="autoDraft")return l.filter(T=>T.paymentMethod==="autoDraft");const h=g==="oneTime"?l.filter(T=>!T.recurring):l.filter(T=>T.recurring);
1switch(r==null?void 0:r.paymentMethod){case"creditCard":return h.filter(T=>T.paymentMethod==="creditCard"||T.paymentMethod==="debitCard");case"bankAccount":return h.filter(T=>T.paymentMethod==="eCheck");default:return h}},ae=()=>{const h=de(),T=C.paymentMethods??[],H=[];for(const ee of h)for(const je of T)ee.paymentMethod===je.paymentMethodType&&H.push({paymentOption:ee,paymentMethod:je});const pe=H.find(ee=>ee.paymentMethod.isDefaultPaymentMethod)??H.at(0);return pe||{paymentOption:h.at(0)}},oe=p.useMemo(ae,[g,l,C.paymentMethods]),me=oe.paymentOption,Te=oe.paymentMethod;p.useEffect(()=>i(b),[b]),p.useEffect(()=>{const h=l.find(({paymentMethod:T,recurring:H})=>g==="oneTime"?T===(d==null?void 0:d.paymentMethod)&&!H:T===(d==null?void 0:d.paymentMethod)&&H);x({paymentOption:h||me,paymentMethod:Te})},[g,l]),p.useEffect(()=>{const h=C.paymentMethods??[],T=d==null?void 0:d.paymentMethod,H=Z=>["creditCard","debitCard"].includes(Z),pe=Z=>["ach","eCheck"].includes(Z),ee=h.filter(Z=>T?H(T)?H(Z.paymentMethodType):pe(T)?pe(Z.paymentMethodType):Z.paymentMethodType===T:!1),je=ee.find(Z=>Z.isDefaultPaymentMethod)??ee.at(0)??null;x({paymentMethod:je})},[d,C.paymentMethods]),p.useEffect(()=>{S(t?"initializing":"idle")},[t]),p.useEffect(()=>{x({account:ca(s,ce,G)})},[s,ce,G,x]),p.useEffect(()=>{f!=="setupPaymentMethod"&&F(w===null?"closed":"confirmation")},[w]),p.useEffect(()=>{!z&&!t&&fe&&f==="closed"&&b&&g&&d&&d.paymentMethod!=="autoDraft"&&v&&v!=="0.00"&&(u||C.paymentMethods.length<=0)&&(Ie(!0),ue())},[t,fe,z,f,b,g,d,v,u,C.paymentMethods]);const Ae=()=>{(w==null?void 0:w.type)==="recurringPayment"&&E.setConfirmation(null),C.refreshPayments("autoDraftEnrollments").catch(console.error),(u==null?void 0:u.paymentMethodType)!=="autoDraft"&&(Promise.allSettled([C.refreshPayments("paymentMethods"),C.refreshPayments("futurePayments"),C.refreshPayments("recurringPayments")]).catch(console.error),S("reset"),x({amount:"0.00",paymentMethod:null,scheduleInterval:void 0,scheduleStartDate:new Date,payFullBalance:!0}),setTimeout(()=>S("idle")))},Le=()=>It&&g==="oneTime"&&((u==null?void 0:u.paymentMethodType)==="eCheck"||(u==null?void 0:u.paymentMethodType)==="autoDraft"||(d==null?void 0:d.paymentMethod)==="eCheck"||(d==null?void 0:d.paymentMethod)==="autoDraft")||Tt&&g==="recurring"&&((u==null?void 0:u.paymentMethodType)==="eCheck"||(u==null?void 0:u.paymentMethodType)==="autoDraft"||(d==null?void 0:d.paymentMethod)==="eCheck"||(d==null?void 0:d.paymentMethod)==="autoDraft")||At&&g==="oneTime"&&((u==null?void 0:u.paymentMethodType)==="creditCard"||(d==null?void 0:d.paymentMethod)==="creditCard"||(u==null?void 0:u.paymentMethodType)==="debitCard"||(d==null?void 0:d.paymentMethod)==="debitCard")||Lt&&g==="recurring"&&((u==null?void 0:u.paymentMethodType)==="creditCard"||(d==null?void 0:d.paymentMethod)==="creditCard"||(u==null?void 0:u.paymentMethodType)==="debitCard"||(d==null?void 0:d.paymentMethod)==="debitCard"),ue=()=>{if((d==null?void 0:d.paymentMethod)!=="autoDraft"){if(S("loading"),Le()){F("paymentsDisabled");return}oa({account:b,paymentType:g,scheduleStartDate:V}).then(h=>h.length?(q(h),F("duplicateWarning"),Promise.resolve()):ye().finally(()=>{S("idle"),m==null||m()})).catch(console.error)}},ke=()=>{S("loading"),K(!0),(d==null?void 0:d.paymentMethod)!=="autoDraft"&&ye().catch(console.error).finally(()=>{K(!1),S("idle"),m==null||m()})},ye=async()=>{ie(d);const h=await ua({account:b,amount:v,maxAmount:k,paymentMethod:u,paymentOption:d,paymentType:g,scheduleInterval:$,scheduleStartDate:V,payFullBalance:D});E.setConfirmation(h),F("confirmation")},R=()=>{F("setupPaymentMethod")},L=p.useMemo(()=>Re(g),[g]);return e.jsxs(e.Fragment,{children:[B!=="initializing"&&B!=="reset"&&e.jsx("div",{children:c?e.jsxs("form",{className:"p-4 tablet:p-8 w-full xl:max-w-[unset] space-y-6",onSubmit:h=>{h.preventDefault(),ue()},children:[e.jsx(ze,{accounts:s}),b!=null&&b.blockPayments?e.jsx("div",{className:"flex flex-col justify-start items-start mt-12 pt-8 border-t border-base-border",children:e.jsx(at,{variant:"danger",children:a("billing.paymentForm.paymentsToThisAccountAreBlocked")})}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{paymentOptions:l,initialPaymentType:r==null?void 0:r.paymentType}),b&&l.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(Ce,{title:a("billing.paymentForm.method.formSectionTitle").toString(),children:[e.jsx(Ye,{paymentOptions:l,paymentType:g,minDate:L,defaultPaymentOption:me}),(d==null?void 0:d.paymentMethod)==="autoDraft"?e.jsx(Ge,{onSetupPaymentMethod:R,onUnenroll:h=>{h.source==="bank"?y(`/Homeowner_v2/AutoDraftForm?oid=${h.ownerId}&subledgerID=${h.subLedgerId}`,"/billing/auto-draft"):(W(h),F("unenrollAutoDraft"))}}):e.jsx(He,{minDate:L,onSetupPaymentMethod:R})]}),e.jsx("div",{className:_("flex flex-col items-start mt-12 space-y-4","md:flex-row md:space-y-0 md:space-x-4 md:divide-x-2",(d==null?void 0:d.paymentMethod)==="autoDraft"?"justify-end":"justify-start"),children:(d==null?void 0:d.paymentMethod)!=="autoDraft"&&e.jsx(X,{type:"submit",className:"min-w-[8rem]",disabled:B==="loading",variant:"primary","data-qa":"continue-btn",children:B==="loading"?e.jsx("span",{className:"flex items-center justify-center",children:e.jsx(ge,{color:"white",className:"w-6 py-0 -my-2"})}):a(`billing.paymentForm.submit.${g}`)})})]})]})]}):e.jsxs("form",{className:"p-4 sm:p-8 max-w-[600px] xl:max-w-[unset]",onSubmit:h=>{h.preventDefault(),ue()},children:[e.jsx("p",{className:"mb-8",children:a("billing.paymentForm.description")}),e.jsx(ze,{accounts:s}),e.jsx("hr",{className:"my-6 bg-gray-200"}),b!=null&&b.blockPayments?e.jsx("div",{className:"flex flex-col justify-start items-start ml-4 mt-12 space-y-4",children:e.jsx("p",{className:"text-red-500",children:a("billing.paymentForm.blocked")})}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{paymentOptions:l,initialPaymentType:r==null?void 0:r.paymentType}),b&&l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"my-6 bg-gray-200"}),e.jsxs(Ce,{title:a("billing.paymentForm.method.formSectionTitle").toString(),children:[e.jsx(Ye,{paymentOptions:l,paymentType:g,minDate:L,defaultPaymentOption:me}),(d==null?void 0:d.paymentMethod)==="autoDraft"?e.jsx(Ge,{onSetupPaymentMethod:R,onUnenroll:h=>{h.source==="bank"?y(`/Homeowner_v2/AutoDraftForm?oid=${h.ownerId}&subledgerID=${h.subLedgerId}`,"/billing/auto-draft"):(W(h),F("unenrollAutoDraft"))}}):e.jsx(He,{minDate:L,onSetupPaymentMethod:R})]}),e.jsx("div",{className:_("flex flex-col items-start ml-4 mt-12 space-y-4","md:flex-row md:space-y-0 md:space-x-4 md:divide-x-2",(d==null?void 0:d.paymentMethod)==="autoDraft"?"justify-end":"justify-start"),children:(d==null?void 0:d.paymentMethod)!=="autoDraft"&&e.jsx(X,{type:"submit",className:"min-w-[8rem]",disabled:B==="loading",variant:"primary","data-qa":"continue-btn",children:B==="loading"?e.jsx("span",{className:"flex items-center justify-center",children:e.jsx(ge,{color:"white",className:"w-6 py-0 -my-2"})}):a(`billing.paymentForm.submit.${g}`)})})]})]})]})}),e.jsx(pt,{padded:!1,open:f!=="closed",onClose:()=>{(f==="confirmation"||f==="setupPaymentMethod")&&B==="loading"||(F("closed"),S("idle"),W(void 0),E.setConfirmation(null))},modalOverlay:(f==="confirmation"||f==="setupPaymentMethod")&&B==="loading"?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:a("billing.paymentForm.paymentProcessing")}),e.jsx(ge,{color:"white"})]}):null,title:{closed:"",confirmation:(w==null?void 0:w.type)!=="recurringPayment"?a("billing.confirmPayment.modalTitle").toString():a("billing.paymentForm.recurringModalView.reviewRecurringPayment").toString(),success:a("billing.paymentForm.paymentSuccess").toString(),duplicateWarning:a("billing.duplicateWarning.modalTitle").toString(),setupPaymentMethod:a("billing.setupPaymentMethod.modalTitle").toString(),unenrollAutoDraft:a("billing.manageAutoDraft.confirmDelete.title",{accountNumber:I==null?void 0:I.accountNumber,address:I?ne(I==null?void 0:I.propertyAddress,"half"):"",associationName:I==null?void 0:I.associationName}).toString(),paymentsDisabled:a("billing.paymentsDisabled.title").toString()}[f],textAlign:f==="confirmation"?"left":"default",children:{closed:e.jsx("div",{className:"h-48"}),success:e.jsxs("div",{children:[e.jsx("div",{className:"bg-success bg-opacity-30 h-16 flex justify-center items-center my-2 mx-4 px-1",children:e.jsx("p",{className:"text-sm font-base",children:(w==null?void 0:w.type)==="autoDraft"?a("billing.paymentForm.success.autoDraft"):(w==null?void 0:w.type)==="payment"||(w==null?void 0:w.type)==="futurePayment"?a(`billing.paymentForm.success.${w.type}.${xe(w,le)}`,{amount:N(w.payment.total/100)}):a("billing.paymentForm.success.autoDraft")})}),e.jsx("div",{className:"border-t border-base-border px-8 py-2 flex items-center justify-start gap-4 flex-row-reverse",children:e.jsx(X,{type:"button",className:"w-44",onClick:()=>{E.setConfirmation(null),S("idle"),F("closed")},variant:"primary","data-qa":"confirm",tabIndex:1,children:a("billing.paymentForm.success.continue")})})]}),confirmation:e.jsx(ra,{confirmation:w,paymentOption:d,onSubmit:()=>{Ae(),n==null||n(),Me("payment:submitted",{amount:v,paymentType:g,paymentMethod:(d==null?void 0:d.paymentMethod)??null,paymentInterval:$??null})},onCancel:()=>{E.setConfirmation(null),Me("payment:abandoned",{amount:v,paymentType:g,paymentMethod:(d==null?void 0:d.paymentMethod)??null,paymentInterval:$??null})},setFormState:S,setModalState:F}),duplicateWarning:e.jsx(da,{loading:U,duplicates:O,onConfirm:ke,onCancel:()=>{F("closed"),S("idle")},type:g==="oneTime"&&V&&V>new Date?"scheduled":g}),setupPaymentMethod:e.jsx(zt,{onSubmit:()=>
1{C.refreshPayments("paymentMethods").catch(console.error),F("closed")},onCancel:()=>{F("closed")},paymentMethodType:d==null?void 0:d.paymentMethod}),unenrollAutoDraft:e.jsxs("form",{onSubmit:h=>{h.preventDefault(),K(!0),M.cancelAutoDraft((I==null?void 0:I.id)??"").then(()=>{C.refreshPayments("autoDraftEnrollments").then(()=>{W(void 0),F("closed"),K(!1)}).catch(console.error)}).catch(console.error)},children:[e.jsx("div",{className:"p-8 flex flex-col gap-4",children:e.jsx("p",{children:a("billing.manageAutoDraft.confirmDelete.content")})}),e.jsxs("div",{className:"px-8 py-4 flex gap-4 border-t border-base-border flex-row-reverse",children:[e.jsxs(X,{type:"submit",disabled:U,variant:"primary",children:[U&&e.jsx(ge,{color:"white",className:"w-6 py-0 -my-2"}),!U&&a("billing.manageAutoDraft.confirmDelete.submit")]}),e.jsx(X,{type:"button",variant:"primaryOutline",disabled:U,onClick:()=>{F("closed"),W(void 0),K(!1)},children:a("billing.manageAutoDraft.confirmDelete.cancel")})]})]}),paymentsDisabled:e.jsx("div",{className:"p-8 flex flex-col gap-4",children:e.jsx("p",{children:a(`billing.paymentsDisabled.content.${(u==null?void 0:u.paymentMethodType)||"default"}`)})})}[f]})]})}function da({type:t,loading:s,duplicates:l=[],onConfirm:r,onCancel:m}){const{t:n}=A();return e.jsxs("div",{className:"space-y-6","data-qa":"duplicate-warning",children:[e.jsx("div",{className:"px-8 pt-4",children:e.jsx(Y,{i18nKey:`billing.duplicateWarning.modalContent.${t}`,components:{hr:e.jsx("hr",{className:"my-2 border-none"})}})}),e.jsx("div",{className:"space-y-2 px-8",children:e.jsxs(gt,{children:[e.jsx(bt,{className:"flex justify-between w-full text-left border rounded-md",children:({open:i})=>e.jsxs("p",{className:"w-full flex gap-2 items-center justify-between font-bold px-4 py-2",children:[e.jsx("span",{children:n("billing.duplicateWarning.accordionTitle")}),e.jsx(De,{className:"w-4 h-4 text-gray-400",icon:i?xt:ft})]})}),e.jsx(jt,{children:e.jsx("ul",{className:"px-4 space-y-2",children:l.map(i=>{var c,a;return e.jsxs("li",{className:"gap-2 grid grid-cols-3",children:[i.date?e.jsx("span",{className:"font-bold",children:J(i.date,{format:"numeric",naive:!0})}):null,e.jsx("span",{className:"text-emerald-500",children:i.amount?N(i.amount):"--"}),e.jsx("span",{children:i.description})]},(((c=i.date)==null?void 0:c.toString())??"")+(((a=i.amount)==null?void 0:a.toString())??"")+i.description)})})})]})}),e.jsxs("div",{className:"border-t border-base-border px-8 py-4 mt-4 flex items-center justify-start gap-4 flex-row-reverse",children:[e.jsx(X,{type:"button",disabled:s,onClick:r,variant:"primary",className:"min-w-[8rem]","data-qa":"confirm",tabIndex:1,children:s?e.jsx("span",{className:"flex items-center justify-center",children:e.jsx(ge,{color:"white",className:"w-6 py-0 -my-2"})}):n("billing.duplicateWarning.submit")}),e.jsx(X,{type:"button",disabled:s,variant:"primaryOutline",className:"min-w-[8rem]",onClick:m,"data-qa":"cancel",children:n("billing.duplicateWarning.cancel")})]})]})}async function oa({account:t,paymentType:s,scheduleStartDate:l}){if(t===void 0)throw new Error("Account not set");const r=new Date;return ht()&&r.setDate(r.getDate()+1),s==="oneTime"&&(!l||l<=r)?(await M.getPayments({ownerId:t.ownerId,subLedgerId:t.subLedgerId.toString(),"ledgerDate.after":new Date(Date.now()-432e5)})).member.map(i=>({date:i.date,amount:i.amount,description:i.paymentType??"One-Time Payment"})):s==="oneTime"&&l?(await M.getFuturePayments({accountNumber:t.accountNumber,subLedgerId:t.subLedgerId,nextPaymentDate:{after:l,before:l}})).map(i=>({date:i.scheduledDate,amount:i.amount/100,description:i.amount?"Scheduled Payment":"Auto-Draft"})):(await M.getRecurringPayments({accountNumber:t.accountNumber,subLedgerId:t.subLedgerId,nextPaymentDate:{after:l,before:l}})).map(n=>({date:n.nextPaymentDate,amount:n.amount?n.amount/100:void 0,description:n.amount?"Recurring Payment":"Auto-Draft"}))}function ma(t){return t?Gt(t,Re("oneTime")):!1}async function ua(t){var s,l,r,m;if(t.account===void 0)throw new Error("Account not set");if(t.paymentOption===void 0)throw new Error("Payment Option not set");if(t.paymentType==="recurring"){const n="recurringPayment",i=new Date(((s=t.scheduleStartDate)==null?void 0:s.setHours(12))??Re(t.paymentType)),c=await M.createRecurringPayment({amount:t.payFullBalance?Math.round(Number(t.maxAmount)*100):Math.round(Number(t.amount)*100),accountNumber:t.account.accountNumber,ownerId:t.account.ownerId,subLedgerId:t.account.subLedgerId,paymentMethodId:((l=t.paymentMethod)==null?void 0:l.id)??null,interval:t.scheduleInterval??"monthly",anchorDate:i,paymentOption:t.paymentOption.id,description:null,notes:"",payFullBalance:t.payFullBalance});return{type:n,payment:c}}else if(ma(t.scheduleStartDate)){const n="payment",i=await M.createPayment({amount:Math.round(Number(t.amount)*100),accountNumber:t.account.accountNumber,ownerId:t.account.ownerId,subLedgerId:t.account.subLedgerId,paymentMethodId:(r=t.paymentMethod)==null?void 0:r.id,setupOfflineUsage:!1,paymentOption:t.paymentOption.id});return{type:n,payment:i}}else if(t.scheduleStartDate){const n=(m=t.paymentMethod)==null?void 0:m.id,i="futurePayment",c=await M.createFuturePayment({amount:Math.round(Number(t.amount)*100),accountNumber:t.account.accountNumber,ownerId:t.account.ownerId,subLedgerId:Number(t.account.subLedgerId),paymentMethodId:n,scheduledDate:t.scheduleStartDate,paymentOption:t.paymentOption.id});return{type:i,payment:c}}throw new Error("Invalid payment type")}const Ea={title:"Make A Payment",showPropertySelector:!1,showAi:!1};function Ra(){const t=p.useRef(!1),[s,l]=p.useState(!0),[r,m]=p.useState(),[n,i]=p.useState([]),[c,a]=p.useState([]),o=se(),x=Q(),g=kt().state,[d,u]=p.useState([]),v=async S=>{if(S==null)return;const f=await M.getPaymentOptions(S.associationId);u(f)},k=S=>
1{m(S),Promise.allSettled([v(S)]).catch(console.error)},D=async()=>{t.current||(t.current=!0,await o.refreshPayments())};p.useEffect(()=>{l(!0),Promise.allSettled([v(r),D()]).finally(()=>l(!1))},[]);const y=()=>{var S;M.getPayments({ownerId:r==null?void 0:r.ownerId,subLedgerId:(S=r==null?void 0:r.subLedgerId)==null?void 0:S.toString()}).then(f=>a(f.member)).catch(console.error)};p.useEffect(y,[r]);const[$,V]=p.useState(0),[E,w]=p.useState(null),[C,B]=p.useState("");return Nt(()=>{if($>100||c[0]&&c[0].id!==C){V(0),w(null),o.refreshAccounts();return}V($+1),y()},E),p.useEffect(()=>{i(o.accounts.filter(S=>S.vantacaPayEnabled))},[o.accounts]),e.jsx(Ht,{controller:"Homeowner_v2",action:"Billing",children:x?e.jsxs("div",{className:"flex flex-col tablet:flex-row gap-6",children:[e.jsx("div",{className:"v3-widget flex-1 bg-base-fill rounded-xl",children:!s&&e.jsx(Oe,{accounts:n,paymentOptions:d,onAccountChange:k,onConfirmation:()=>{w(1e3),B(c.length>0?c[0].id:"")},loading:s,initialPaymentSelections:g})}),e.jsx(vt,{payments:c,selectedAccount:r})]}):e.jsxs("div",{className:"flex flex-col md:flex-row bg-base-fill rounded-xl",children:[e.jsx("div",{className:"flex-1",children:!s&&e.jsx(Oe,{accounts:n,paymentOptions:d,onAccountChange:k,onConfirmation:()=>{w(1e3),B(c.length>0?c[0].id:"")},loading:s,initialPaymentSelections:g})}),e.jsxs("aside",{className:"v3-widget p-horizontal-layout-sm sm:p-horizontal-layout mb-12 md:w-2/5 flex flex-col gap-10",children:[e.jsx(St,{payments:c}),r&&e.jsxs(e.Fragment,{children:[e.jsx(wt,{selectedAccount:r}),e.jsx(Ft,{})]})]}),e.jsx(Pt,{accountNumber:r==null?void 0:r.accountNumber,subLedgerId:r==null?void 0:r.subLedgerId})]})})}export{Ra as Component,Ea as handle};

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.