/*!
 * Built with Stencil
 * By PostNord.
 */
'use strict';

var index = require('./index-CfUQZtlH.js');

const pnAccordionCss = () => `${index.transformTag("pn-accordion")}{position:relative;background-color:#ffffff;display:flex;align-items:stretch;flex-direction:column;gap:0.25em}${index.transformTag("pn-accordion")}[data-transparent]{background-color:transparent}${index.transformTag("pn-accordion")}>${index.transformTag("pn-accordion-row")}+${index.transformTag("pn-accordion-row")}:after{content:"";position:absolute;top:-0.125em;left:0.25em;width:calc(100% - 0.5em);height:0;border-top:0.0625em solid #d3cecb}`;

const PnAccordion = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
    }
    mo;
    closeEvent = new CustomEvent('rowstate', { detail: false });
    get hostElement() { return index.getElement(this); }
    /** Only allow a single row to be open at once. @since v7.8.0 */
    single = false;
    /** Optional prop that removes the default white background on the accordion row. @since v7.10.0 */
    transparent = false;
    connectedCallback() {
        this.mo = new MutationObserver(() => index.forceUpdate(this.hostElement));
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        this.mo.disconnect();
    }
    handleSingleRow({ detail }) {
        if (!this.single)
            return;
        const element = detail.element;
        const activeRow = element.closest(`${index.transformTag("pn-accordion-row")}`);
        const rows = Array.from(this.hostElement.querySelectorAll(`${index.transformTag("pn-accordion-row")}`));
        rows.forEach(row => !row.isSameNode(activeRow) && row.dispatchEvent(this.closeEvent));
    }
    render() {
        return (index.h(index.Host, { key: 'd8cd9ef7bd0d93aafda0e6955a9ad35ec81d55ae', class: "pn-accordion", "data-transparent": this.transparent }, index.h("slot", { key: '43233bb6107dcc4608edb0086ef347d7c936556f' })));
    }
};
PnAccordion.style = pnAccordionCss();

exports.pn_accordion = PnAccordion;
