import { unsafeCSS, LitElement, nothing, html } from "lit";
import { property } from "lit/decorators.js";
import compentStyle from "./breadcrumb.css.js";
import "../../icons/icon-chevron-right-google.js";
import { customElement } from "../../decorator.js";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
let ObcBreadcrumb = class extends LitElement {
  constructor() {
    super(...arguments);
    this.items = [];
    this.iconOnly = false;
  }
  render() {
    return html`
      <nav aria-label="Breadcrumb" class="breadcrumb">
        <ol>
          ${this.items.map((item, i) => {
      const isLast = i === this.items.length - 1;
      return html`
              <li>
                ${i > 0 ? html`<span class="divider">
                      <obi-chevron-right-google class="icon">
                      </obi-chevron-right-google>
                    </span>` : nothing}
                ${isLast ? html` <div class="label-wrapper active">
                      <div class="visible-wrapper">
                        ${item.icon ? item.icon() : nothing}
                        ${this.iconOnly && !isLast ? nothing : html`<span class="label">${item.label}</span>`}
                      </div>
                    </div>` : html` <button
                      role="link"
                      @click=${() => this.handleClick(item)}
                      class="label-wrapper"
                    >
                      <div class="visible-wrapper">
                        ${item.icon ? item.icon() : nothing}
                        ${this.iconOnly && !isLast ? nothing : html`<span class="label">${item.label}</span>`}
                      </div>
                    </button>`}
              </li>
            `;
    })}
        </ol>
      </nav>
    `;
  }
  handleClick(item) {
    this.dispatchEvent(
      new CustomEvent("breadcrumb-click", { detail: item })
    );
  }
};
ObcBreadcrumb.styles = unsafeCSS(compentStyle);
__decorateClass([
  property({ attribute: false })
], ObcBreadcrumb.prototype, "items", 2);
__decorateClass([
  property({ attribute: false })
], ObcBreadcrumb.prototype, "iconOnly", 2);
ObcBreadcrumb = __decorateClass([
  customElement("obc-breadcrumb")
], ObcBreadcrumb);
export {
  ObcBreadcrumb
};
//# sourceMappingURL=breadcrumb.js.map
