import{h as t,r as i}from"./p-CV0Pyo1O.js";import{S as s}from"./p-uZ5KAseb.js";import{w as e,c as a}from"./p-DVJaoI_m.js";import{e as r}from"./p-BXrbGZ_R.js";import{c as o}from"./p-Bo7v8x6H.js";import{c as n}from"./p-DyPk4BJt.js";import"./p-CPKMvyV_.js";import"./p-D8GTwl9v.js";import"./p-HXpYMWUU.js";import"./p-CqcLgdsl.js";import"./p-DkoufM1t.js";const c=i=>{const{isReady:e}=i;return e?null:t("div",{class:"container-fluid p-0"},t("div",{class:"row mb-3"},t("div",{class:"col-12 align-content-end"},t(s,{height:"18px",width:"120px"}),t(s,{height:"36px"}))),t("div",{class:"row"},t("div",{class:"col-12 align-content-end"},t(s,{height:"18px",width:"110px"}),t(s,{height:"36px"}))))},h=class{constructor(t){i(this,t),this.isReady=!1,this.hasLoggedAchDisabledWarning=!1}async componentWillLoad(){await e(),this.iframeOrigin=a.iframeOrigin,this.tabId=r(),o()}componentDidRender(){if(this.isAchDisabledForCheckout())return;const t=[this.accountNumberIframeElement,this.routingNumberIframeElement];t.every(Boolean)&&Promise.all(t.map((t=>new Promise((i=>{t.addEventListener("iframeLoaded",(()=>{i()}))}))))).then((()=>{this.isReady=!0}))}isAchDisabledForCheckout(){return n.checkoutLoaded&&!n.achPaymentsEnabled}async validate(){if(this.isAchDisabledForCheckout())return!1;const t=await this.accountNumberIframeElement.validate(),i=await this.routingNumberIframeElement.validate();return t&&i}async tokenize({clientId:t,paymentMethodMetadata:i,account:s}){return this.isAchDisabledForCheckout()?{error:{message:"ACH payments are disabled for this checkout (payment_settings.ach_payments=false)."}}:await this.accountNumberIframeElement.tokenize(t,i,s)}render(){return this.isAchDisabledForCheckout()?(this.hasLoggedAchDisabledWarning||(console.warn("[bank-account-form] ACH payments are disabled for this checkout (payment_settings.ach_payments=false)."),this.hasLoggedAchDisabledWarning=!0),null):t("div",null,t(c,{isReady:this.isReady}),t("hidden-input",null),t("div",{class:"container-fluid p-0",style:{opacity:this.isReady?"1":"0",height:this.isReady?"auto":"0"}},t("div",{class:"row mb-3"},t("iframe-input",{inputId:"accountNumber",ref:t=>this.accountNumberIframeElement=t,label:"Account Number",iframeOrigin:`${this.iframeOrigin}/v2/accountNumber?tabId=${this.tabId}`})),t("div",{class:"row"},t("iframe-input",{inputId:"routingNumber",ref:t=>this.routingNumberIframeElement=t,label:"Routing Number",iframeOrigin:`${this.iframeOrigin}/v2/routingNumber?tabId=${this.tabId}`}))))}};export{h as bank_account_form}