import { r as registerInstance, c as createEvent, h, g as getElement } from './index-148a7577.js';
import { l as logger } from './logger.util-ede3c48a.js';
import { r as randomIdGenerator } from './randomIdGenerator.util-56406f2e.js';
import { _ as _t } from './text-26e02c8d.js';

const navigationBreadcrumbsCss = ".sc-digi-navigation-breadcrumbs-h{--digi--navigation-breadcrumbs--items--display:flex;--digi--navigation-breadcrumbs--items--flex-wrap:wrap;--digi--navigation-breadcrumbs--items--padding:0;--digi--navigation-breadcrumbs--items--margin:0;--digi--navigation-breadcrumbs--item--font-family:var(--digi--global--typography--font-family--default);--digi--navigation-breadcrumbs--item--font-size:var(--digi--typography--breadcrumbs--font-size--desktop);--digi--navigation-breadcrumbs--item--text-decoration:var(--digi--typography--breadcrumbs--text-decoration--desktop);--digi--navigation-breadcrumbs--item--color:var(--digi--color--text--primary);--digi--navigation-breadcrumbs--divider--padding:var(--digi--gutter--icon);--digi--navigation-breadcrumbs--link--visited--color:var(--digi--color--text--interactive--primary);--digi--navigation-breadcrumbs--link--hover--focus--color:var(--digi--color--text--interactive--primary);--digi--navigation-breadcrumbs--link--hover--text-decoration:underline;--digi--navigation-breadcrumbs--link--hover--text-decoration-thickness:var(--digi--typography--text-decoration-thickness--hover);--digi--navigation-breadcrumbs--link--color:var(--digi--color--text--interactive--primary)}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__items.sc-digi-navigation-breadcrumbs{list-style:none;display:var(--digi--navigation-breadcrumbs--items--display);flex-wrap:var(--digi--navigation-breadcrumbs--items--flex-wrap);margin:var(--digi--navigation-breadcrumbs--items--margin);padding:var(--digi--navigation-breadcrumbs--items--padding)}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__item.sc-digi-navigation-breadcrumbs{font-family:var(--digi--navigation-breadcrumbs--item--font-family);font-size:var(--digi--navigation-breadcrumbs--item--font-size);color:var(--digi--navigation-breadcrumbs--item--color);width:unset;margin-bottom:unset}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__item.sc-digi-navigation-breadcrumbs:not([aria-current=page])::after{content:\"/\";padding-inline:var(--digi--navigation-breadcrumbs--divider--padding)}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__link.sc-digi-navigation-breadcrumbs{color:var(--digi--navigation-breadcrumbs--link--color);font-size:var(--digi--navigation-breadcrumbs--item--font-size)}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__link.sc-digi-navigation-breadcrumbs:visited{color:var(--digi--navigation-breadcrumbs--link--color)}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__link.sc-digi-navigation-breadcrumbs:hover{text-decoration:var(--digi--navigation-breadcrumbs--link--hover--text-decoration);text-decoration-thickness:var(--digi--navigation-breadcrumbs--link--hover--text-decoration-thickness)}.sc-digi-navigation-breadcrumbs-h .digi-navigation-breadcrumbs__link.sc-digi-navigation-breadcrumbs:focus-visible{outline:2px solid black;outline-offset:2px;box-shadow:0px 0px 0px 5px white}";
const DigiNavigationBreadcrumbsStyle0 = navigationBreadcrumbsCss;

const NavigationBreadcrumbs = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.afOnClick = createEvent(this, "afOnClick", 7);
        this.linkItems = [];
        this.currentPage = undefined;
        this.afAriaLabel = _t.breadcrumbs;
        this.afId = randomIdGenerator('digi-navigation-breadcrumbs');
        this.afCurrentPage = undefined;
    }
    onAfCurrentPage(afCurrentPage) {
        this.currentPage = afCurrentPage;
    }
    componentDidLoad() {
        this.getBreadcrumbs();
    }
    getBreadcrumbs() {
        const elements = this._observer.children;
        if (!elements || (elements === null || elements === void 0 ? void 0 : elements.length) <= 0) {
            logger.warn(`The slot contains no link elements.`, this.hostElement);
            return;
        }
        this.linkItems = [...elements]
            .filter((element) => element.tagName.toLowerCase() === 'a')
            .map((element) => {
            return {
                text: element.textContent,
                href: element.getAttribute('href') || ''
            };
        });
    }
    clickHandler(e) {
        this.afOnClick.emit(e);
    }
    render() {
        var _a;
        return (h("nav", { key: '2eb7edfb17175dbbb23060e1ef082c26cc7ec00c', class: "digi-navigation-breadcrumbs", "aria-label": this.afAriaLabel }, h("ol", { key: 'c3324fc686e3399ee2d1a62b4a81704c35d0dd0f', class: "digi-navigation-breadcrumbs__items" }, this.linkItems.map((item) => {
            return (h("li", { class: "digi-navigation-breadcrumbs__item" }, h("a", { class: "digi-navigation-breadcrumbs__link", onClick: (e) => this.clickHandler(e), href: item.href }, item.text)));
        }), h("li", { key: 'b201285474d818da3a92c5182afe8d468cc9bb8e', class: "digi-navigation-breadcrumbs__item", "aria-current": "page" }, (_a = this.currentPage) !== null && _a !== void 0 ? _a : this.afCurrentPage), h("digi-util-mutation-observer", { key: '5fed828c087cb38c8e428f8343403f388d9c21c1', onAfOnChange: () => this.getBreadcrumbs(), ref: (el) => (this._observer = el), hidden: true }, h("slot", { key: 'beb32e05a1727e010ad5b169d6d335294ec4351b' })))));
    }
    get hostElement() { return getElement(this); }
    static get watchers() { return {
        "afCurrentPage": ["onAfCurrentPage"]
    }; }
};
NavigationBreadcrumbs.style = DigiNavigationBreadcrumbsStyle0;

export { NavigationBreadcrumbs as digi_navigation_breadcrumbs };
