import { h } from "@stencil/core";
import { isNestedInIfxComponent } from "../..//shared/utils/dom-utils";
import { detectFramework } from "../..//shared/utils/framework-detection";
import { trackComponent } from "../../shared/utils/tracking";
export class Breadcrumb {
    el;
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent("ifx-breadcrumb", await framework);
        }
        const element = this.el.shadowRoot?.firstElementChild;
        if (element instanceof HTMLElement) {
            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: 'f9e3ab03f477edc2f42857d773c924845c1f1d2e', "aria-label": "Page navigation breadcrumb" }, h("ol", { key: 'c56109519419ef1e697065e611d6047c6f4285e3', class: "breadcrumb" }, h("slot", { key: '224406744edd734167bca7882e9da6381ee37bac' }))));
    }
    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
