import { unsafeCSS, LitElement, html } from "lit";
import { customElement } from "../../decorator.js";
import { classMap } from "lit/directives/class-map.js";
import componentStyle from "./accordion-item.css.js";
import { property } from "lit/decorators.js";
import "../../icons/icon-chevron-down-google.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 ObcAccordionItem = class extends LitElement {
  constructor() {
    super(...arguments);
    this.title = "";
    this.open = false;
    this.disabled = false;
    this.showDivider = false;
  }
  handleToggle() {
    if (this.disabled) return;
    this.open = !this.open;
    this.dispatchEvent(
      new CustomEvent("accordion-item-toggle", {
        detail: {
          open: this.open,
          title: this.title
        }
      })
    );
  }
  renderContent() {
    return html`
      <div class="content">
        <div class="leading-content-container">
          <div class="label-frame">
            <div class="title">${this.title}</div>
          </div>
        </div>
        <div class="trailing-icon">
          <obi-chevron-down-google></obi-chevron-down-google>
        </div>
      </div>
    `;
  }
  renderExpandedContent() {
    if (!this.open) return "";
    return html`
      <div class="content-container">
        <slot name="expanded-content"></slot>
      </div>
    `;
  }
  renderDivider() {
    if (!this.showDivider) return "";
    return html`<div class="divider"></div>`;
  }
  render() {
    return html`
      <div
        class=${classMap({
      wrapper: true,
      "state-disabled": this.disabled,
      "open-true": this.open,
      "open-false": !this.open
    })}
      >
        <button
          class="content-button"
          @click=${this.handleToggle}
          ?disabled=${this.disabled}
          aria-expanded=${this.open}
        >
          ${this.renderContent()}
        </button>

        ${this.renderExpandedContent()} ${this.renderDivider()}
      </div>
    `;
  }
};
ObcAccordionItem.styles = unsafeCSS(componentStyle);
__decorateClass([
  property({ type: String })
], ObcAccordionItem.prototype, "title", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAccordionItem.prototype, "open", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAccordionItem.prototype, "disabled", 2);
__decorateClass([
  property({ type: Boolean })
], ObcAccordionItem.prototype, "showDivider", 2);
ObcAccordionItem = __decorateClass([
  customElement("obc-accordion-item")
], ObcAccordionItem);
export {
  ObcAccordionItem
};
//# sourceMappingURL=accordion-item.js.map
