import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { c as checkPkgVersion } from './check-pkg-version.js';
import { J as JustifiAnalytics } from './Analytics.js';
import { w as waitForConfig } from './config-state.js';
import { S as StyledHost } from './styled-host.js';
import './justifi-details2.js';
import './event-types.js';
import './justifi-radio-list-item2.js';
import { d as defineCustomElement$4 } from './bank-account-form2.js';
import { d as defineCustomElement$3 } from './hidden-input2.js';
import { d as defineCustomElement$2 } from './iframe-input2.js';

const JustifiBankAccountForm$1 = /*@__PURE__*/ proxyCustomElement(class JustifiBankAccountForm extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.__attachShadow();
    }
    async componentWillLoad() {
        await waitForConfig();
        checkPkgVersion();
        this.analytics = new JustifiAnalytics(this);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.analytics) === null || _a === void 0 ? void 0 : _a.cleanup();
    }
    async validate() {
        if (!this.bankAccountFormElement) {
            return false;
        }
        return this.bankAccountFormElement.validate();
    }
    async tokenize({ clientId, paymentMethodMetadata, account }) {
        if (!this.bankAccountFormElement) {
            return {
                error: {
                    message: 'Bank account form is not available.',
                },
            };
        }
        return this.bankAccountFormElement.tokenize({ clientId, paymentMethodMetadata, account });
    }
    render() {
        return (h(StyledHost, { key: '3c8a48f6060f14433ae94399fc48097cb138e301' }, h("bank-account-form", { key: '30cd40b60629f5c7f874194dd7641ee3737e8b69', ref: (el) => (this.bankAccountFormElement = el) })));
    }
}, [257, "justifi-bank-account-form", {
        "validate": [64],
        "tokenize": [64]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["justifi-bank-account-form", "bank-account-form", "hidden-input", "iframe-input"];
    components.forEach(tagName => { switch (tagName) {
        case "justifi-bank-account-form":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, JustifiBankAccountForm$1);
            }
            break;
        case "bank-account-form":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "hidden-input":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "iframe-input":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}
defineCustomElement$1();

const JustifiBankAccountForm = JustifiBankAccountForm$1;
const defineCustomElement = defineCustomElement$1;

export { JustifiBankAccountForm, defineCustomElement };
