import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { c as create$3, a as create$6, F as FormController } from './form.js';
import { D as DisputeResponseFormStep, f as fileInputHandler } from './file-input-handler.js';
import { a2 as heading5 } from './parts.js';
import { d as defineCustomElement$6 } from './custom-popper2.js';
import { d as defineCustomElement$5 } from './form-control-file-v22.js';
import { d as defineCustomElement$4 } from './form-control-help-text3.js';
import { d as defineCustomElement$3 } from './form-control-text2.js';
import { d as defineCustomElement$2 } from './form-control-textarea2.js';
import { d as defineCustomElement$1 } from './form-control-tooltip2.js';

const CustomerDetailsSchema = create$3({
    customer_name: create$6().nullable(),
    customer_email_address: create$6().nullable(),
    customer_billing_address: create$6().nullable(),
});

const CustomerDetails = /*@__PURE__*/ proxyCustomElement(class CustomerDetails extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.documentErrors = {};
        this.errors = {};
        this.documents = { customer_signature: [], customer_communication: [] };
        this.inputHandler = (name, value) => {
            this.form.setValues(Object.assign(Object.assign({}, this.form.values.getValue()), { [name]: value }));
        };
    }
    async validateAndSubmit(onSuccess) {
        const documentList = Object.values(this.documents).flat();
        this.form.validateAndSubmit((formData) => onSuccess(formData, documentList, DisputeResponseFormStep.customerDetails));
    }
    ;
    componentWillLoad() {
        this.form = new FormController(CustomerDetailsSchema);
    }
    componentDidLoad() {
        this.form.errors.subscribe(errors => {
            this.errors = Object.assign({}, errors);
        });
    }
    render() {
        var _a, _b, _c, _d, _e;
        return (h("div", { key: '91b627ab79cff98fc4bb2b76e9e9159b99bcdc44' }, h("div", { key: 'ddb074202926fca96c40fba3724b1a603ef29bf8', class: "row gy-3" }, h("div", { key: '680d03bb31e19a1ab7aa560195a802dc2a7f1bcf', class: "col-12" }, h("h2", { key: 'b9e47dc34c931a18373053384dac93ccd45e4823', class: "h5", part: heading5 }, "Customer Details")), h("div", { key: '286716947b073de829fe525eb855864f51d72234', class: "col-12" }, h("form-control-text", { key: '2b9369bfbb55fa87ee8448324f6ff8480679ba58', label: "Full Name", name: "customer_name", defaultValue: (_a = this.disputeResponse) === null || _a === void 0 ? void 0 : _a.customer_name, inputHandler: this.inputHandler, errorText: this.errors.customer_name })), h("div", { key: '89f384a11dcac912a189b4909586a3e1db603f25', class: "col-12" }, h("form-control-text", { key: 'c6dfbeb68b117d840a39bfe4e96be7d18d5395b7', label: "Email", name: "customer_email_address", defaultValue: (_b = this.disputeResponse) === null || _b === void 0 ? void 0 : _b.customer_email_address, inputHandler: this.inputHandler, errorText: this.errors.customer_email_address })), h("div", { key: '29c2e48fabafe27b878294e3267a9ec04a91a2a4', class: "col-12" }, h("form-control-textarea", { key: 'ec734cbef65f6263e462b86332be24c92a1173ad', label: "Billing Address", name: "customer_billing_address", defaultValue: (_c = this.disputeResponse) === null || _c === void 0 ? void 0 : _c.customer_billing_address, inputHandler: this.inputHandler, errorText: this.errors.customer_billing_address })), h("div", { key: 'f944aca1e6594cdcc20bb69bd1aa625536d05ac0', class: "col-12" }, h("form-control-file-v2", { key: 'f227a8b81e6b8409152f61ae6906319577663dd3', label: "Customer Signature", name: "customer_signature", onChange: (e) => fileInputHandler(e, this.documents), errorText: (_d = this.documentErrors) === null || _d === void 0 ? void 0 : _d.customer_signature })), h("div", { key: '4804ef68cc6f5d0006568aca8bc57086243af4de', class: "col-12" }, h("form-control-file-v2", { key: 'a0dba5cfa046de4bca065d7bb20ec2a5abd57fc9', label: "Customer Communication", name: "customer_communication", onChange: (e) => fileInputHandler(e, this.documents), errorText: (_e = this.documentErrors) === null || _e === void 0 ? void 0 : _e.customer_communication })))));
    }
}, [256, "customer-details", {
        "disputeResponse": [8, "dispute-response"],
        "documentErrors": [8, "document-errors"],
        "form": [32],
        "errors": [32],
        "documents": [32],
        "validateAndSubmit": [64]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["customer-details", "custom-popper", "form-control-file-v2", "form-control-help-text", "form-control-text", "form-control-textarea", "form-control-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "customer-details":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, CustomerDetails);
            }
            break;
        case "custom-popper":
            if (!customElements.get(tagName)) {
                defineCustomElement$6();
            }
            break;
        case "form-control-file-v2":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "form-control-help-text":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "form-control-text":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "form-control-textarea":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "form-control-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { CustomerDetails as C, defineCustomElement as d };
