'use strict';

var index = require('./index-BEF5cZxd.js');
var wcag = require('./wcag-Bvzxnp5D.js');
var gov_log = require('./gov.log-C5EH15b_.js');
var utils = require('./utils-NnC78QR3.js');
var template = require('./template-Cj6PcLmR.js');
var helpers_types = require('./helpers.types-vap8QfRH.js');
var constants = require('./constants-DcKnOyW4.js');
var props = require('./props-CPENhBnM.js');
var string_utils = require('./string.utils-BG4pUfEi.js');
require('./colors-DgrrxjsX.js');
require('./sizes-D5zsw2g5.js');

const AttachmentsClass = {
    root: 'gov-attachments',
    label: 'gov-attachments__label',
    list: 'gov-attachments__list',
};
const AttachmentsItemClass = {
    root: 'gov-attachments-item',
    name: 'gov-attachments-item__name',
    file: 'gov-attachments-item__file',
    messages: 'gov-attachments-item__messages',
};

const GovAttachments = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.h = template.govHost(this.host);
    }
    async componentDidRender() {
        if (gov_log.canValidateWcagOnRender()) {
            await utils.delay(500);
            await this.validateWcag();
        }
    }
    render() {
        return (index.h(index.Host, { key: '80effc5b697215f9a0cf731b6562c137edbc0efa', class: this.h.classes(AttachmentsClass.root) }, this.label ? index.h("p", { class: AttachmentsClass.label }, this.label) : null, index.h("div", { key: '3b7388299a3da27be78732562ded94bb6581525b', class: AttachmentsClass.list, role: "list", "aria-label": this.wcagLabel }, index.h("slot", { key: '38c1592a7501f166a462fbb70eef92d6c855d0ec' }))));
    }
    /**
     * Validate the WCAG attributes of the component
     */
    async validateWcag() {
        wcag.validateWcagProp(this.wcagLabel, 'wcag-label', AttachmentsClass.root);
    }
    get host() { return index.getElement(this); }
};

const govAttachmentsItemCss = "gov-attachments-item,.gov-attachments-item{display:flex;flex-direction:column}gov-attachments-item__messages>*:last-child,.gov-attachments-item__messages>*:last-child{margin-bottom:0}gov-attachments-item__messages>*,.gov-attachments-item__messages>*{position:relative;top:calc(-1 * var(--spacing-xs))}gov-attachments-item__file,.gov-attachments-item__file{display:flex;gap:var(--spacing-s);max-width:100%}gov-attachments-item__name,.gov-attachments-item__name{display:flex;-moz-column-gap:var(--spacing-s);column-gap:var(--spacing-s);align-items:center;max-width:calc(100% - var(--spacing-s) - var(--icon-size-s) - (var(--spacing-s-nudge) + var(--border-width, 0.0625rem)) * 2);margin:0}gov-attachments-item__name>gov-tooltip,gov-attachments-item__name .gov-tooltip,.gov-attachments-item__name>gov-tooltip,.gov-attachments-item__name .gov-tooltip{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;color:var(--name-color, var(--text-primary))}gov-attachments-item__name span[slot=info],.gov-attachments-item__name span[slot=info]{font-size:var(--font-size-body-xs);line-height:150%;font-weight:400;color:var(--decor-color, var(--text-secondary));white-space:nowrap}";

const GovAttachmentsItem = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.govRemove = index.createEvent(this, "gov-remove");
        /**
         * Adds accessible label for the remove button that is only shown for screen readers.
         */
        this.accessibleRemoveLabel = "Odebrat soubor {FILE_NAME}";
        this.h = template.govHost(this.host);
    }
    async componentDidRender() {
        if (gov_log.canValidateWcagOnRender()) {
            await utils.delay(500);
            await this.validateAccessibility();
        }
    }
    render() {
        return (index.h(index.Host, { key: '2b75f45ecc4b9a72a0e471c4f92588e0df19bfb6', class: this.h.classes(AttachmentsItemClass.root), role: "listitem" }, index.h("div", { key: '472c55271bc6a0c10c315e44053ca30a41d667ab', class: AttachmentsItemClass.file }, index.h("div", { key: '13f199a67dcbb07226451d67dc4e0ff242f7b66f', class: AttachmentsItemClass.name }, index.h("gov-tooltip", { key: 'b65c03b2f2838b74e163f89ac171eeee527e16c6', position: "top", icon: true }, index.h("slot", { key: '6c273a499bfeb40859ad5ffe79181df25250290d' }), index.h("gov-tooltip-content", { key: '82ecb87b7f00bcc56a122c54706e9ba614e04bb8' }, this.h.getSlotContent(`name`))), index.h("slot", { key: 'a43693ee308113468fa7083771d89f668fbeef53', name: "info" })), index.h("gov-button", { key: 'a735520757a7140199c182e46cedcb3b549796d3', color: "primary", type: "base", size: "s", "aria-label": helpers_types.isString(this.accessibleRemoveLabel) ? this.accessibleRemoveLabel.replace('{FILE_NAME}', this.h.getSlotContent(`name`) || '').trim() : null, "aria-labelledby": this.accessibleRemoveLabelledBy, "on-gov-click": this.govRemove.emit }, index.h("gov-icon", { key: 'c130f0225431f0b522e0ddbc3e59bb50aa234857', slot: "icon-start", name: "x-lg", type: "components" }))), this.h.hasSlot('message') && (index.h("div", { key: 'e3779227622c456d014bd118ab3b9886fd799f57', class: AttachmentsItemClass.messages }, index.h("slot", { key: 'eef992883000f87ac5bcd460e53078c08839c920', name: "message" })))));
    }
    /**
     * Validate the accessible attributes of the component
     */
    async validateAccessibility() {
        wcag.validateAccessibleLabel(this.accessibleRemoveLabel, this.accessibleRemoveLabelledBy, AttachmentsItemClass.root, this.host);
    }
    get host() { return index.getElement(this); }
};
GovAttachmentsItem.style = govAttachmentsItemCss;

const GovFormMessage = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        /**
         * Style variation of the message.
         */
        this.color = 'neutral';
        /**
         * Message's size.
         */
        this.size = 'm';
        this.h = template.govHost(this.host);
        this.messageId = string_utils.createID('GovFormMessage');
    }
    validateColor(newValue) {
        props.validateProp(constants.FormMessageColors, newValue, constants.FormMessageClass.root);
    }
    componentWillLoad() {
        this.validateColor(this.color);
    }
    render() {
        return (index.h(index.Host, { key: 'f23989a9ea8f6c47ae43cbc8655a9c7d281d36e6', class: this.h.classes(constants.FormMessageClass.root), color: this.color, size: this.size }, this.h.hasSlot('icon') && (index.h("slot", { key: '0cfae3a030761bbd352411054f2a89a13da07bee', name: "icon" })), index.h("span", { key: 'f2d7c7a835f38b3bfe006c75fae9f8a25db7e5e1', id: this.messageId, class: constants.FormMessageClass.content }, index.h("slot", { key: 'c6e752c2143d5002a50c233a1ea6cd73ef5e61b9' }))));
    }
    /**
     * Returns unique identifier of message
     */
    async identifier() {
        return this.messageId;
    }
    get host() { return index.getElement(this); }
    static get watchers() { return {
        "color": ["validateColor"]
    }; }
};

exports.gov_attachments = GovAttachments;
exports.gov_attachments_item = GovAttachmentsItem;
exports.gov_form_message = GovFormMessage;
//# sourceMappingURL=gov-attachments.gov-attachments-item.gov-form-message.entry.cjs.js.map

//# sourceMappingURL=gov-attachments_3.cjs.entry.js.map