'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-75aef097.js');

const breadcrumbCss = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}:host(.breadcrumb){display:flex;flex-wrap:wrap;align-items:center;gap:var(--spacing-gap-xs);margin:0;padding-block:var(--spacing-padding-xs);padding-inline:0;list-style:none}.list{display:contents}.list-item{display:inline-flex;align-items:center;gap:var(--spacing-gap-xs);list-style:none}.separator{color:var(--color-text-neutral-subtle);padding-inline:var(--spacing-padding-xs);user-select:none;pointer-events:none;opacity:0.85}";

var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _GxIdeBreadcrumb_isItemSelected, _GxIdeBreadcrumb_handleListClick;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/icon",
    "utils/link",
    "utils/typography",
    "utils/spacing"
];
const DEFAULT_SELECTED_LINK = { link: { url: undefined } };
const GxIdeBreadcrumb = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.hyperlinkClick = index.createEvent(this, "hyperlinkClick", 7);
        this.buttonClick = index.createEvent(this, "buttonClick", 7);
        _GxIdeBreadcrumb_isItemSelected.set(this, (item) => {
            var _a, _b, _c, _d, _e;
            if (!this.selectedLinkIndicator)
                return false;
            const sel = (_a = this.selectedLink) !== null && _a !== void 0 ? _a : DEFAULT_SELECTED_LINK;
            const matchById = sel.id !== undefined && item.id === sel.id;
            const matchByUrl = ((_b = sel.link) === null || _b === void 0 ? void 0 : _b.url) !== undefined &&
                ((_c = sel.link) === null || _c === void 0 ? void 0 : _c.url) !== "" &&
                ((_d = item.link) === null || _d === void 0 ? void 0 : _d.url) === ((_e = sel.link) === null || _e === void 0 ? void 0 : _e.url);
            return matchById || matchByUrl;
        });
        _GxIdeBreadcrumb_handleListClick.set(this, (event) => {
            var _a, _b, _c, _d, _e;
            if (this.disabled)
                return;
            const target = event.target;
            const itemEl = (_a = target.closest) === null || _a === void 0 ? void 0 : _a.call(target, "gx-ide-breadcrumb-item");
            if (!itemEl)
                return;
            const itemId = (_b = itemEl.getAttribute) === null || _b === void 0 ? void 0 : _b.call(itemEl, "data-item-id");
            const hasLink = ((_c = itemEl.getAttribute) === null || _c === void 0 ? void 0 : _c.call(itemEl, "data-has-link")) === "true";
            if (!itemId || !this.model)
                return;
            const item = this.model.find(i => i.id === itemId);
            if (!item)
                return;
            if (hasLink) {
                event.preventDefault();
                (_d = this.hyperlinkClick) === null || _d === void 0 ? void 0 : _d.emit(item);
                return;
            }
            (_e = this.buttonClick) === null || _e === void 0 ? void 0 : _e.emit(item);
        });
        this.model = undefined;
        this.accessibleName = undefined;
        this.disabled = false;
        this.separator = "›";
        this.selectedLink = DEFAULT_SELECTED_LINK;
        this.selectedLinkIndicator = false;
        this.getImagePathCallback = undefined;
    }
    render() {
        var _a, _b;
        const items = (_a = this.model) !== null && _a !== void 0 ? _a : [];
        const separator = this.separator;
        const ariaLabel = (_b = this.accessibleName) !== null && _b !== void 0 ? _b : undefined;
        return (index.h(index.Host, { class: "breadcrumb", role: "navigation", "aria-label": ariaLabel }, index.h("ch-theme", { model: CSS_BUNDLES }), index.h("ol", { class: "list", onClick: __classPrivateFieldGet(this, _GxIdeBreadcrumb_handleListClick, "f") }, items.map((item, index$1) => (index.h("li", { key: item.id, class: "list-item", role: "presentation" }, index.h("gx-ide-breadcrumb-item", { itemId: item.id, model: item, caption: item.caption, accessibleName: item.accessibleName, disabled: this.disabled || item.disabled, link: item.link, selected: __classPrivateFieldGet(this, _GxIdeBreadcrumb_isItemSelected, "f").call(this, item), selectedLinkIndicator: this.selectedLinkIndicator, startImgSrc: item.startImgSrc, startImgType: item.startImgType, getImagePathCallback: this.getImagePathCallback }), index$1 < items.length - 1 && (index.h("span", { class: "separator body-regular-s", "aria-hidden": "true" }, separator))))))));
    }
    get el() { return index.getElement(this); }
};
_GxIdeBreadcrumb_isItemSelected = new WeakMap(), _GxIdeBreadcrumb_handleListClick = new WeakMap();
GxIdeBreadcrumb.style = breadcrumbCss;

exports.gx_ide_breadcrumb = GxIdeBreadcrumb;

//# sourceMappingURL=gx-ide-breadcrumb.cjs.entry.js.map