import { h } from "@stencil/core";
import { trackComponent } from "../../global/utils/tracking";
import { isNestedInIfxComponent } from "../../global/utils/dom-utils";
import { detectFramework } from "../../global/utils/framework-detection";
export class Breadcrumb {
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent('ifx-breadcrumb', await framework);
        }
        const element = this.el.shadowRoot.firstChild;
        this.validateBreadcrumbItemStructure(element);
    }
    validateBreadcrumbItemStructure(element) {
        if (!element) {
            console.error('element not found');
            return;
        }
        const slot = element.querySelector('slot');
        if (slot) {
            const assignedNodes = slot.assignedNodes();
            for (let i = 0; i < assignedNodes.length; i++) {
                const node = assignedNodes[i];
                if (node.nodeName === 'IFX-BREADCRUMB-ITEM') {
                    const breadcrumbItem = node;
                    const breadcrumbItemLabel = breadcrumbItem.querySelector('ifx-breadcrumb-item-label');
                    const breadcrumbDropdown = breadcrumbItem.querySelector('ifx-dropdown-menu');
                    if (breadcrumbItemLabel.hasAttribute('href') && breadcrumbDropdown) {
                        throw new Error('ifx-breadcrumb-item cannot have both a href and a dropdown menu.');
                    }
                }
            }
        }
    }
    render() {
        return (h("nav", { key: 'edf76204e96413a39d1a543735bbb0a2530d8348', "aria-label": "Page navigation breadcrumb" }, h("ol", { key: '1b64075586076eb4f6ca73cf41202a52a180d1c3', class: "breadcrumb" }, h("slot", { key: '352a0be161eb7b0ab45bdbbb59d023bd9da6ff73' }))));
    }
    static get is() { return "ifx-breadcrumb"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["breadcrumb.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["breadcrumb.css"]
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=breadcrumb.js.map
