import { unsafeCSS, LitElement, html } from "lit";
import { property } from "lit/decorators.js";
import "../../icons/icon-check-google.js";
import "../../icons/icon-close-google.js";
import "../toggle-button-group/toggle-button-group.js";
import { ObcToggleButtonOptionType } from "../toggle-button-option/toggle-button-option.js";
import componentStyle from "./toggle-button-three-state.css.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;
};
var ObcToggleButtonThreeStateValue = /* @__PURE__ */ ((ObcToggleButtonThreeStateValue2) => {
  ObcToggleButtonThreeStateValue2["noInput"] = "no-input";
  ObcToggleButtonThreeStateValue2["success"] = "success";
  ObcToggleButtonThreeStateValue2["error"] = "error";
  return ObcToggleButtonThreeStateValue2;
})(ObcToggleButtonThreeStateValue || {});
let ObcToggleButtonThreeState = class extends LitElement {
  constructor() {
    super(...arguments);
    this.state = "no-input";
    this.disabled = false;
  }
  updateState(next) {
    if (this.disabled || this.state === next) {
      return;
    }
    this.state = next;
    this.dispatchEvent(
      new CustomEvent("change", {
        detail: { state: this.state }
      })
    );
  }
  isValidState(value) {
    return Object.values(ObcToggleButtonThreeStateValue).includes(
      value
    );
  }
  handleValueChange(event) {
    if (this.disabled) {
      return;
    }
    const next = event.detail.value;
    if (this.isValidState(next)) {
      this.updateState(next);
    }
  }
  render() {
    return html`
      <obc-toggle-button-group
        .value=${this.state}
        .type=${ObcToggleButtonOptionType.icon}
        ?disabled=${this.disabled}
        hugText
        aria-label="Three state toggle"
        @value=${this.handleValueChange}
      >
        <obc-toggle-button-option
          class="segment error"
          .value=${"error"}
          aria-label="Error"
        >
          <obi-close-google slot="icon"></obi-close-google>
        </obc-toggle-button-option>
        <obc-toggle-button-option
          class="segment neutral"
          .value=${"no-input"}
          aria-label="No input"
        >
          <span class="dot" slot="icon" aria-hidden="true"></span>
        </obc-toggle-button-option>
        <obc-toggle-button-option
          class="segment success"
          .value=${"success"}
          aria-label="Success"
        >
          <obi-check-google slot="icon"></obi-check-google>
        </obc-toggle-button-option>
      </obc-toggle-button-group>
    `;
  }
};
ObcToggleButtonThreeState.styles = unsafeCSS(componentStyle);
__decorateClass([
  property({ type: String })
], ObcToggleButtonThreeState.prototype, "state", 2);
__decorateClass([
  property({ type: Boolean, reflect: true })
], ObcToggleButtonThreeState.prototype, "disabled", 2);
ObcToggleButtonThreeState = __decorateClass([
  customElement("obc-toggle-button-three-state")
], ObcToggleButtonThreeState);
export {
  ObcToggleButtonThreeState,
  ObcToggleButtonThreeStateValue
};
//# sourceMappingURL=toggle-button-three-state.js.map
