import { h, Host } from "@stencil/core";
import { AttachmentsItemClass } from "./constants";
import { validateAccessibleLabel } from "../../helpers/Validate/wcag";
import { canValidateWcagOnRender } from "../../helpers/Dom/win";
import { delay } from "../../utils/utils";
import { govHost } from "../../helpers/Dom/template";
import { isString } from "../../utils/helpers.types";
export class GovAttachmentsItem {
    constructor() {
        /**
         * Adds accessible label for the remove button that is only shown for screen readers.
         */
        this.accessibleRemoveLabel = "Odebrat soubor {FILE_NAME}";
        this.h = govHost(this.host);
    }
    async componentDidRender() {
        if (canValidateWcagOnRender()) {
            await delay(500);
            await this.validateAccessibility();
        }
    }
    render() {
        return (h(Host, { key: '2b75f45ecc4b9a72a0e471c4f92588e0df19bfb6', class: this.h.classes(AttachmentsItemClass.root), role: "listitem" }, h("div", { key: '472c55271bc6a0c10c315e44053ca30a41d667ab', class: AttachmentsItemClass.file }, h("div", { key: '13f199a67dcbb07226451d67dc4e0ff242f7b66f', class: AttachmentsItemClass.name }, h("gov-tooltip", { key: 'b65c03b2f2838b74e163f89ac171eeee527e16c6', position: "top", icon: true }, h("slot", { key: '6c273a499bfeb40859ad5ffe79181df25250290d' }), h("gov-tooltip-content", { key: '82ecb87b7f00bcc56a122c54706e9ba614e04bb8' }, this.h.getSlotContent(`name`))), h("slot", { key: 'a43693ee308113468fa7083771d89f668fbeef53', name: "info" })), h("gov-button", { key: 'a735520757a7140199c182e46cedcb3b549796d3', color: "primary", type: "base", size: "s", "aria-label": isString(this.accessibleRemoveLabel) ? this.accessibleRemoveLabel.replace('{FILE_NAME}', this.h.getSlotContent(`name`) || '').trim() : null, "aria-labelledby": this.accessibleRemoveLabelledBy, "on-gov-click": this.govRemove.emit }, h("gov-icon", { key: 'c130f0225431f0b522e0ddbc3e59bb50aa234857', slot: "icon-start", name: "x-lg", type: "components" }))), this.h.hasSlot('message') && (h("div", { key: 'e3779227622c456d014bd118ab3b9886fd799f57', class: AttachmentsItemClass.messages }, h("slot", { key: 'eef992883000f87ac5bcd460e53078c08839c920', name: "message" })))));
    }
    /**
     * Validate the accessible attributes of the component
     */
    async validateAccessibility() {
        validateAccessibleLabel(this.accessibleRemoveLabel, this.accessibleRemoveLabelledBy, AttachmentsItemClass.root, this.host);
    }
    static get is() { return "gov-attachments-item"; }
    static get originalStyleUrls() {
        return {
            "$": ["gov-attachments-item.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["gov-attachments-item.css"]
        };
    }
    static get properties() {
        return {
            "accessibleRemoveLabel": {
                "type": "string",
                "attribute": "accessible-remove-label",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Adds accessible label for the remove button that is only shown for screen readers."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "\"Odebrat soubor {FILE_NAME}\""
            },
            "accessibleRemoveLabelledBy": {
                "type": "string",
                "attribute": "accessible-remove-labelledby",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Indicates the id of a component that labels the remove button."
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get events() {
        return [{
                "method": "govRemove",
                "name": "gov-remove",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Emitted when the file is removed"
                },
                "complexType": {
                    "original": "PointerEvent",
                    "resolved": "PointerEvent",
                    "references": {
                        "PointerEvent": {
                            "location": "global",
                            "id": "global::PointerEvent"
                        }
                    }
                }
            }];
    }
    static get methods() {
        return {
            "validateAccessibility": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Validate the accessible attributes of the component",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "host"; }
}
//# sourceMappingURL=gov-attachments-item.js.map
