import {NodeEvent as NodeEvent2} from "../../../poly/NodeEvent";
import {BaseState} from "./Base";
import {Poly as Poly2} from "../../../Poly";
export class ErrorState extends BaseState {
  set(message) {
    if (this._message != message) {
      if (message) {
        Poly2.warn(`[${this.node.fullPath()}] error: '${message}'`);
      }
      this._message = message;
      this.on_update();
    }
  }
  message() {
    return this._message;
  }
  clear() {
    this.set(void 0);
  }
  active() {
    return this._message != null;
  }
  on_update() {
    if (this._message != null) {
      this.node.setContainer(null, `from error '${this._message}'`);
    }
    this.node.emit(NodeEvent2.ERROR_UPDATED);
  }
}
