'use strict';

class Command {
  // #region fields
  _enabled;
  _checked;
  _fn;
  // #endregion
  // #region properties
  getEnabled() {
    return this._enabled;
  }
  setEnabled(value) {
    const newState = Boolean(value);
    if (this._enabled !== newState) {
      this._enabled = newState;
    }
    $(this).trigger("enabledChanged", this._enabled);
    return this;
  }
  getChecked() {
    return this._checked;
  }
  setChecked(value) {
    const newState = Boolean(value);
    if (this._checked !== newState) {
      this._checked = newState;
    }
    $(this).trigger("checkedChanged", this._checked);
    return this;
  }
  // #endregion
  // #region constructor
  constructor(fn) {
    this._enabled = true;
    this._checked = false;
    this._fn = fn;
  }
  // #endregion
  // #region methods
  exec(...args) {
    if (typeof this._fn === "function") {
      this._fn.apply(this, args);
    }
  }
  // #endregion
}

exports.Command = Command;
