// retoor <retoor@molodetz.nl>

import { Component } from "./Component.js";

export class AiStatus extends Component {
  static get observedAttributes() {
    return ["state", "message"];
  }

  connectedCallback() {
    this.classList.add("ai-status");
    this.setAttribute("aria-live", "polite");
    this._render();
  }

  attributeChangedCallback() {
    this._render();
  }

  _render() {
    const state = this.attr("state", "open");
    const message = this.attr("message", state);
    this.dataset.state = state;
    this.textContent = message;
  }
}

if (!customElements.get("ai-status")) {
  customElements.define("ai-status", AiStatus);
}

export default AiStatus;
