/*!
 * Built by ShiftSoftware
 * Copyright (c)
 */
import { h } from "@stencil/core";
import cn from "../../global/lib/cn";
import { ChevronLeftIcon } from "../../global/assets/chevron-left-icon";
import { ChevronRightIcon } from "../../global/assets/chevron-right-icon";
const buttonSubscriberKey = 'stepper-control-button';
export class FormStepperControl {
    constructor() {
        this.submitTextKey = 'submit';
        this.localization = {};
    }
    async componentWillLoad() {
        this.form.subscribe(buttonSubscriberKey, this);
        this.form.backButtonContexts.push(this);
    }
    async disconnectedCallback() {
        this.form.backButtonContexts = this.form.backButtonContexts.filter(back => back !== this);
        this.form.unsubscribe(buttonSubscriberKey);
    }
    render() {
        var _a, _b, _c;
        const [locale, language] = this.form.getFormLocale();
        const currentStep = (_b = (_a = this.form) === null || _a === void 0 ? void 0 : _a.formStructure) === null || _b === void 0 ? void 0 : _b.currentStep;
        const direction = (_c = locale === null || locale === void 0 ? void 0 : locale.sharedFormLocales) === null || _c === void 0 ? void 0 : _c.direction;
        let step = this.form.getStepLabels(language, currentStep);
        const text = (step === null || step === void 0 ? void 0 : step.back) || '';
        return (h("button", { key: '1ac2e6d390239d6a02dd7070b858e9c6b9c9dbf9', type: "button", formnovalidate: true, disabled: this.isLoading, onClick: () => this.form.updateStep(-1), part: cn('stepper-control', `stepper-control-${direction}`, buttonSubscriberKey, `stepper-control-step-${currentStep}`), class: cn('transition-all duration-700 text-[16px] flex gap-1 items-center stepper-control', {
                'loading': this.isLoading,
                'pointer-events-none': currentStep === 10,
            }) }, h("div", { key: '776edcaf9a2b6303a8eec5c96b396a808ea760cd', part: cn('stepper-control-icon', `stepper-control-icon-${direction}`) }, direction === 'ltr' && h(ChevronLeftIcon, { key: '0715917895f98c3a26e598b3190764ab9f4d0d7f', class: "size-5" }), direction === 'rtl' && h(ChevronRightIcon, { key: 'dad717c0407606ae3440b7a9c773a61da796ba33', class: "size-5" })), text));
    }
    static get is() { return "form-stepper-control"; }
    static get originalStyleUrls() {
        return {
            "$": ["form-inputs.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["form-inputs.css"]
        };
    }
    static get properties() {
        return {
            "language": {
                "type": "string",
                "attribute": "language",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "wrapperId": {
                "type": "string",
                "attribute": "wrapper-id",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "isLoading": {
                "type": "boolean",
                "attribute": "is-loading",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "form": {
                "type": "unknown",
                "attribute": "form",
                "mutable": false,
                "complexType": {
                    "original": "FormHook<any>",
                    "resolved": "FormHook<any>",
                    "references": {
                        "FormHook": {
                            "location": "import",
                            "path": "~features/form-hook",
                            "id": "src/features/form-hook/index.ts::FormHook"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "wrapperClass": {
                "type": "string",
                "attribute": "wrapper-class",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "submitTextKey": {
                "type": "string",
                "attribute": "submit-text-key",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "'submit'"
            },
            "localization": {
                "type": "unknown",
                "attribute": "localization",
                "mutable": false,
                "complexType": {
                    "original": "FormInputLocalization",
                    "resolved": "{ [lang: string]: { label?: string; placeholder?: string; require?: string; format?: string; minMessage: string; maxMessage: string; betweenMessage: string; }; }",
                    "references": {
                        "FormInputLocalization": {
                            "location": "import",
                            "path": "~features/form-hook",
                            "id": "src/features/form-hook/index.ts::FormInputLocalization"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "defaultValue": "{}"
            }
        };
    }
}
