'use strict';

var index = require('./index-BEF5cZxd.js');
var props = require('./props-CPENhBnM.js');
var constants = require('./constants-WvkMgj1j.js');
var template = require('./template-Cj6PcLmR.js');
var accessibility = require('./accessibility-BQJmIVWV.js');
var stencil_utils = require('./stencil.utils-8sCYbm34.js');
require('./gov.log-C5EH15b_.js');
require('./utils-NnC78QR3.js');
require('./sizes-D5zsw2g5.js');
require('./attribute-CH1-zDDl.js');

const GovAccordionItem = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.govChange = index.createEvent(this, "gov-change");
        this.inheritedAttributes = {};
        /**
         * Makes the button component disabled.
         */
        this.disabled = false;
        /**
         * Defines whether the accordion is open or closed by button
         */
        this.open = false;
        this.h = template.govHost(this.host);
    }
    validateSize(newValue) {
        props.validateProp(constants.AccordionSizes, newValue, constants.AccordionItemClass.root);
    }
    componentWillLoad() {
        this.validateSize(this.size);
        this.inheritedAttributes = accessibility.inheritAriaAttributes(this.host);
    }
    componentDidRender() {
        stencil_utils.tick(() => this.getPropsFromParents());
    }
    getPropsFromParents() {
        const accordion = this.h.getParent(constants.AccordionClass.root);
        if (accordion) {
            this.size = accordion.getAttribute("size");
        }
    }
    render() {
        return (index.h(index.Host, { key: '322aca243fd956d90542c23ffd384969a3e702ba', class: this.h.classes([constants.AccordionItemClass.root,
                this.disabled && constants.AccordionItemClass.disabled]), size: this.size, role: "listitem" }, index.h("details", { key: '80befb8ec6ecc9e1718d9e94fc693e382a384512', class: constants.AccordionItemClass.details, id: this.identifier, "aria-disabled": template.toBoolAttrIfDefined(this.disabled), open: this.open }, index.h("summary", Object.assign({ key: 'f04df2d0a5c29c9c6621e69ab15c1ac72bc95912', onClick: (e) => {
                e.stopPropagation();
                e.preventDefault();
                !this.disabled && this.toggle().finally();
            }, class: constants.AccordionItemClass.summary, tabIndex: this.disabled ? -1 : 0, "aria-expanded": template.booleanString(this.open) }, this.inheritedAttributes), this.h.hasSlot('icon') &&
            index.h("span", { key: '0889615c3b616615947e09cb7dc82a45f5bf3c36', class: constants.AccordionItemClass.icon }, index.h("slot", { key: '204ee8071c84d94fe44f06781a169c6ed6548748', name: "icon" })), index.h("span", { key: '2558df9bfa5b027fd78858bc07c59c812144f7b0', class: constants.AccordionItemClass.title }, index.h("slot", { key: 'ce4fc19e7bcd801e789fa920b75726ac2e6d64fa', name: "label" }), index.h("slot", { key: '6493bed9d3ff025212c6ddd483c6afc66e4e2555', name: "annotation" })), index.h("span", { key: '86bb4f277aa23a921803d1b15b19ddc1f9bef788', class: constants.AccordionItemClass.right }, index.h("slot", { key: '6125404df4e25f638b3c0a2dc10d13cc58d5a2db', name: "suffix" }), index.h("span", { key: '4ec7fde2af7b5648b033440a646af0fa9cdb575a', class: constants.AccordionItemClass.arrow }, index.h("slot", { key: 'cf5ace176c8c7cd53e8bad7c8155e396d37ca6fa', name: "toggle-icon" }, index.h("gov-icon", { key: '0d5e06a98c5ac069c3680ed5442064aed996eb46', name: "chevron-down", type: "components" }))))), index.h("div", { key: '6ce82f8da04142d8330f9da035f046272deffd4d', class: constants.AccordionItemClass.content }, index.h("slot", { key: '47790abbe664864a3cf1d456762fb414d7c63418' })))));
    }
    /**
     * Accordion switch
     */
    async toggle() {
        this.open = !this.open;
        this.govChange.emit({
            open: this.open,
            component: constants.AccordionItemClass.root,
            ref: this.host,
        });
    }
    /**
     * Returns the current state of the component
     */
    async currentState() {
        return this.open;
    }
    get host() { return index.getElement(this); }
    static get watchers() { return {
        "size": ["validateSize"]
    }; }
};

exports.gov_accordion_item = GovAccordionItem;
//# sourceMappingURL=gov-accordion-item.entry.cjs.js.map

//# sourceMappingURL=gov-accordion-item.cjs.entry.js.map