import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
import { h as heading2 } from './parts.js';
import { d as defineCustomElement$5 } from './custom-popper2.js';
import { d as defineCustomElement$4 } from './form-address-fields2.js';
import { d as defineCustomElement$3 } from './form-control-select2.js';
import { d as defineCustomElement$2 } from './form-control-text2.js';
import { d as defineCustomElement$1 } from './form-control-tooltip2.js';

const LegalAddressForm = /*@__PURE__*/ proxyCustomElement(class LegalAddressForm extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.errors = {};
        this.inputHandler = this.inputHandler.bind(this);
    }
    componentDidLoad() {
        this.formController.errors.subscribe(errors => (this.errors = Object.assign({}, errors)));
        this.formController.values.subscribe(values => (this.legal_address = Object.assign({}, values.legal_address)));
    }
    inputHandler(name, value) {
        this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { legal_address: Object.assign(Object.assign({}, this.formController.values.getValue().legal_address), { [name]: value }) }));
    }
    render() {
        var _a;
        const legalAddressDefaultValue = this.formController.getInitialValues().legal_address;
        return (h(Host, { key: '856cd25caef521b651b9dd8a40dc6f9f0c727706' }, h("fieldset", { key: '150ad1f56747aae80ae8d2610fa08fcabee27c87' }, h("legend", { key: '565a46bd0977680e400663ef0590d65e977135be', part: heading2 }, "Business Legal Address"), h("form-address-fields", { key: 'c2ce05c006ec80c5319b30b40387e400ec52ab86', country: this.country, errors: (_a = this.errors) === null || _a === void 0 ? void 0 : _a.legal_address, defaultValues: legalAddressDefaultValue, inputHandler: this.inputHandler }))));
    }
}, [256, "legal-address-form", {
        "formController": [16],
        "country": [1],
        "errors": [32],
        "legal_address": [32]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["legal-address-form", "custom-popper", "form-address-fields", "form-control-select", "form-control-text", "form-control-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "legal-address-form":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, LegalAddressForm);
            }
            break;
        case "custom-popper":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "form-address-fields":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "form-control-select":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "form-control-text":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "form-control-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { LegalAddressForm as L, defineCustomElement as d };
