'use strict';

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

const index = require('./index-58ea899e.js');
const log = require('./global-slimmer-registry-7bbdb1f2.js');
const ui = require('./ui-fe7a2158.js');
const injectVegaSlimmer = require('./inject-vega-slimmer-26fffae4.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-b717b38b.js');
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-26bc0450.js');
const vegaEventId = require('./vega-event-id-c08ce3d3.js');
const component = require('./component-334e6818.js');
const childNodesEventPreventSlimmer = require('./child-nodes-event-prevent-slimmer-09ceefa4.js');
const eventEmitSlimmer = require('./event-emit-slimmer-8422724f.js');
const componentGlobalStyleSlimmer = require('./component-global-style-slimmer-38ab8cc9.js');
require('./change-manager-72f643de.js');
require('./observer-f49483e8.js');
require('./dom-node-subject-factory-36b5fdbc.js');
require('./internal-vega-event-manager-f8bdaa58.js');
require('./vega-env-manager-23b8b23c.js');
require('./feature-flag-controller-09933b7a.js');
require('./index-f054eb5d.js');
require('./dynamic-slimmer-0050c489.js');
require('./try-get-document-c0ebd39a.js');
require('./vega-nonce-manager-55854929.js');
require('./index-592b4052.js');

var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaBreadcrumbRenderer extends log.VegaSlimmer {
  /**
   * get the component container div element
   *
   * @returns {HTMLDivElement} the container element ref
   */
  getBreadcrumbContainerRef() {
    return this.vegaBreadcrumbContainerRef;
  }
  render() {
    return (index.h("div", { class: {
        'vega-breadcrumb': true,
        'compact-mode': this.isCompactMode,
        'last-item-clickable': this.lastItemClickable,
        'collapsed': this.isCollapsed(),
        'single': this.items.length === 1,
      }, ref: (node) => (this.vegaBreadcrumbContainerRef = node) }, this.renderItems()));
  }
  renderItems() {
    const htmlItems = this.items.map((item, index) => this.itemRenderer.render(item, {
      isCompactMode: this.isCompactMode,
      isLastItem: this.items.length === index + 1,
    }));
    if (this.isCollapsed()) {
      htmlItems.splice(1, 0, this.collapsedItemRenderer.render(this.items.slice(1, this.items.length - 1)));
    }
    return index.h(index.Fragment, null, htmlItems);
  }
  isCollapsed() {
    return (!this.isCompactMode &&
      this.maxItems !== 'none' &&
      this.maxItems >= 4 &&
      this.items.length > this.maxItems);
  }
  // True when device is mobile and compact mode is enabled.
  // Used to switch into the compact single-item mobile rendering mode.
  get isCompactMode() {
    return this.compactOnMobile && ui.getDeviceType() === ui.DeviceType.MOBILE;
  }
}
__decorate$3([
  log.MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "items", void 0);
__decorate$3([
  log.MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "compactOnMobile", void 0);
__decorate$3([
  log.MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "lastItemClickable", void 0);
__decorate$3([
  log.MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "maxItems", void 0);
__decorate$3([
  log.MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "itemRenderer", void 0);
__decorate$3([
  log.MapToComponentField()
], VegaBreadcrumbRenderer.prototype, "collapsedItemRenderer", void 0);

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaBreadcrumbCollapsedItemRenderer extends log.VegaSlimmer {
  render(items) {
    return (index.h("div", { class: "vega-breadcrumb-item" },
      index.h("vega-dropdown", { placement: ['bottom'], alignment: 'center', maxHeight: 200 },
        index.h("vega-text", null, "..."),
        index.h("vega-box", { slot: "items" }, items.map((item) => (index.h("vega-dropdown-item", { key: item.label, label: item.label }, this.itemRenderer.render(item, { isInDropdown: true })))))),
      index.h("vega-icon", { icon: "chevron-right-rounded", size: "size-12", color: "text-secondary" })));
  }
}
__decorate$2([
  log.MapToComponentField()
], VegaBreadcrumbCollapsedItemRenderer.prototype, "itemRenderer", void 0);

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
class VegaBreadcrumbItemRenderer extends log.VegaSlimmer {
  constructor() {
    super(...arguments);
    this.onButtonLinkClick = (payload, item) => {
      const event = this.clickEventEmitter.emit(item);
      if (event && event.defaultPrevented) {
        payload.preventDefault();
      }
    };
  }
  render(item, options) {
    return (index.h("div", { class: "vega-breadcrumb-item", key: item.label }, this.renderContent(item, options)));
  }
  renderContent(item, options) {
    if (options.isCompactMode && (!options.isLastItem || this.lastItemClickable)) {
      return (index.h(index.Fragment, null,
        this.renderIcon('chevron-left-rounded', 'text-link'),
        this.renderLabel(item)));
    }
    else if (options.isLastItem) {
      return this.renderLabel(item, !this.lastItemClickable);
    }
    else if (options.isInDropdown) {
      return this.renderLink(item, false, true);
    }
    else {
      return (index.h(index.Fragment, null,
        this.renderLabel(item),
        this.renderIcon('chevron-right-rounded', 'text-secondary')));
    }
  }
  renderIcon(icon, color) {
    return index.h("vega-icon", { icon: icon, size: "size-12", color: color });
  }
  renderLabel(item, isPlainLabel) {
    return item.tooltip ? (index.h("vega-tooltip", { text: item.tooltip, placement: ['bottom'] }, this.renderLink(item, isPlainLabel))) : (this.renderLink(item, isPlainLabel));
  }
  renderLink(item, isPlainLabel, isInDropdown = false) {
    return isPlainLabel ? (index.h("span", { class: "vega-breadcrumb-last-label" }, item.label)) : (index.h("vega-button-link", { label: item.label, link: item.href, eventful: true, class: {
        'vega-breadcrumb-dropdown-link': isInDropdown,
      }, ref: (ref) => {
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaEventId.VegaClick, (payload) => {
          this.onButtonLinkClick(payload, item);
        });
      } }));
  }
}
__decorate$1([
  log.MapToComponentField()
], VegaBreadcrumbItemRenderer.prototype, "lastItemClickable", void 0);
__decorate$1([
  log.MapToComponentField()
], VegaBreadcrumbItemRenderer.prototype, "clickEventEmitter", void 0);

const vegaBreadcrumbGlobalCss = ".vega-breadcrumb-dropdown-link::part(label-text){color:rgba(var(--v-text-primary, 32, 54, 69, 1));font-size:16px;font-weight:400;line-height:24px;letter-spacing:0px}";

const vegaBreadcrumbCss = ":host{display:block}:host .vega-breadcrumb{display:flex;gap:8px;flex-wrap:wrap}:host .vega-breadcrumb-hidden{display:none !important}:host .vega-breadcrumb-item{display:flex;gap:8px;align-items:center}:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb-item vega-button-link::part(label-text){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb-item vega-dropdown vega-text{cursor:pointer;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-link, 19, 98, 226, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb-item vega-dropdown vega-text{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb-item vega-dropdown vega-text{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb-item vega-dropdown vega-text{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb-item vega-icon{flex-shrink:0}:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb-item .vega-breadcrumb-last-label{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb-item vega-button-link::part(label-container){text-decoration:none}:host .vega-breadcrumb.compact-mode>.vega-breadcrumb-item{display:none}:host .vega-breadcrumb.compact-mode .vega-breadcrumb-item:nth-last-child(2){display:flex}:host .vega-breadcrumb.compact-mode.last-item-clickable .vega-breadcrumb-item:nth-last-child(2){display:none}:host .vega-breadcrumb.compact-mode.last-item-clickable .vega-breadcrumb-item:last-child{display:flex}:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{display:flex;font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px;color:rgba(var(--v-text-primary, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-breadcrumb.compact-mode.single .vega-breadcrumb-item{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host .vega-breadcrumb.collapsed .vega-breadcrumb-item:nth-child(n+3):not(:last-child){display:none}";

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const VegaBreadcrumb = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.vegaClick = index.createEvent(this, "vegaClick", 7);
    this.click = index.createEvent(this, "click", 7);
    this.globalSlimmers = {};
    this.renderer = new VegaBreadcrumbRenderer();
    this.collapsedItemRenderer = new VegaBreadcrumbCollapsedItemRenderer();
    this.itemRenderer = new VegaBreadcrumbItemRenderer();
    this.eventsPrevent = new childNodesEventPreventSlimmer.ChildNodesEventPreventSlimmer([vegaEventId.VegaClick], () => this.renderer.getBreadcrumbContainerRef());
    this.clickEventEmitter = eventEmitSlimmer.createEventEmitSlimmer(VegaBreadcrumb, vegaEventId.VegaClick);
    this.componentGlobalStyleSlimmer = new componentGlobalStyleSlimmer.ComponentGlobalStyleSlimmer(vegaBreadcrumbGlobalCss);
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Determines the maximum number of visible items in the `vega-breadcrumb` component,
     *   primarily in desktop mode.
  
     * When the number of items exceeds this limit, the component automatically
     *   collapses the center items, rendering only the first and last items visible.
  
     * If you set this value to `none`, all items will remain expanded.
  
     * The minimum allowed value for this property is 4.
     *
     * @vegaVersion 1.41.0
     */
    this.maxItems = 4;
    /**
     * Represents the individual elements within the `vega-breadcrumb` component.
     *
     * @vegaVersion 1.41.0
     */
    this.items = [];
    /**
     * Compact mode toggle for mobile viewport.
     *
     * When `true` (default), the breadcrumb displays only the last clickable
     * item on mobile devices to save horizontal space.
     * When `false`, the full multi-item layout is shown on mobile, identical to
     * desktop behavior (still subject to collapsing based on `maxItems`).
     *
     * @vegaVersion 2.66.0
     */
    this.compactOnMobile = true;
    /**
     * Determines whether the last breadcrumb item is clickable.
     *
     * When `false` (default), the last item is rendered as plain text.
     * When `true`, the last item becomes a clickable link, styled
     * the same as the other breadcrumb items.
     *
     * @vegaVersion 2.81.0
     */
    this.lastItemClickable = false;
  }
  render() {
    return component.sanitizeVegaComponent(index.h(index.Host, null, this.renderer.render()), this.host);
  }
  get host() { return index.getElement(this); }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaBreadcrumb.prototype, "globalSlimmers", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "renderer", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "collapsedItemRenderer", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "itemRenderer", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "eventsPrevent", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "clickEventEmitter", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "componentGlobalStyleSlimmer", void 0);
__decorate([
  injectVegaSlimmer.InjectVegaSlimmer()
], VegaBreadcrumb.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaBreadcrumb.style = vegaBreadcrumbCss;

exports.vega_breadcrumb = VegaBreadcrumb;
