"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var HumidityControlOperatingStateCC_exports = {};
__export(HumidityControlOperatingStateCC_exports, {
  HumidityControlOperatingStateCC: () => HumidityControlOperatingStateCC,
  HumidityControlOperatingStateCCAPI: () => HumidityControlOperatingStateCCAPI,
  HumidityControlOperatingStateCCGet: () => HumidityControlOperatingStateCCGet,
  HumidityControlOperatingStateCCReport: () => HumidityControlOperatingStateCCReport,
  HumidityControlOperatingStateCCValues: () => import_CCValues_generated.HumidityControlOperatingStateCCValues
});
module.exports = __toCommonJS(HumidityControlOperatingStateCC_exports);
var import_tslib = require("tslib");
var import_core = require("@zwave-js/core");
var import_shared = require("@zwave-js/shared");
var import_API = require("../lib/API.js");
var import_CommandClass = require("../lib/CommandClass.js");
var import_CommandClassDecorators = require("../lib/CommandClassDecorators.js");
var import_Types = require("../lib/_Types.js");
var import_CCValues_generated = require("./_CCValues.generated.js");
let HumidityControlOperatingStateCCAPI = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.API)(import_core.CommandClasses["Humidity Control Operating State"])];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_API.CCAPI;
  var HumidityControlOperatingStateCCAPI2 = class extends _classSuper {
    static {
      __name(this, "HumidityControlOperatingStateCCAPI");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      HumidityControlOperatingStateCCAPI2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
    supportsCommand(cmd) {
      switch (cmd) {
        case import_Types.HumidityControlOperatingStateCommand.Get:
          return this.isSinglecast();
      }
      return super.supportsCommand(cmd);
    }
    get [import_API.POLL_VALUE]() {
      return async function({ property }) {
        switch (property) {
          case "state":
            return this.get();
          default:
            (0, import_API.throwUnsupportedProperty)(this.ccId, property);
        }
      };
    }
    async get() {
      this.assertSupportsCommand(import_Types.HumidityControlOperatingStateCommand, import_Types.HumidityControlOperatingStateCommand.Get);
      const cc = new HumidityControlOperatingStateCCGet({
        nodeId: this.endpoint.nodeId,
        endpointIndex: this.endpoint.index
      });
      const response = await this.host.sendCommand(cc, this.commandOptions);
      if (response) {
        return response?.state;
      }
    }
  };
  return HumidityControlOperatingStateCCAPI2 = _classThis;
})();
let HumidityControlOperatingStateCC = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.commandClass)(import_core.CommandClasses["Humidity Control Operating State"]), (0, import_CommandClassDecorators.implementedVersion)(1), (0, import_CommandClassDecorators.ccValues)(import_CCValues_generated.HumidityControlOperatingStateCCValues)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_CommandClass.CommandClass;
  var HumidityControlOperatingStateCC2 = class extends _classSuper {
    static {
      __name(this, "HumidityControlOperatingStateCC");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      HumidityControlOperatingStateCC2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
    async interview(ctx) {
      const node = this.getNode(ctx);
      ctx.logNode(node.id, {
        endpoint: this.endpointIndex,
        message: `Interviewing ${this.ccName}...`,
        direction: "none"
      });
      await this.refreshValues(ctx);
      this.setInterviewComplete(ctx, true);
    }
    async refreshValues(ctx, options) {
      const node = this.getNode(ctx);
      const endpoint = this.getEndpoint(ctx);
      const api = import_API.CCAPI.create(import_core.CommandClasses["Humidity Control Operating State"], ctx, endpoint).withOptions({
        priority: options?.priority ?? import_core.MessagePriority.NodeQuery
      });
      ctx.logNode(node.id, {
        endpoint: this.endpointIndex,
        message: "querying current humidity control operating state...",
        direction: "outbound"
      });
      const currentStatus = await api.get();
      if (currentStatus) {
        ctx.logNode(node.id, {
          endpoint: this.endpointIndex,
          message: "received current humidity control operating state: " + (0, import_shared.getEnumMemberName)(import_Types.HumidityControlOperatingState, currentStatus),
          direction: "inbound"
        });
      }
    }
  };
  return HumidityControlOperatingStateCC2 = _classThis;
})();
let HumidityControlOperatingStateCCReport = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.HumidityControlOperatingStateCommand.Report), (0, import_CommandClassDecorators.ccValueProperty)("state", import_CCValues_generated.HumidityControlOperatingStateCCValues.state)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = HumidityControlOperatingStateCC;
  var HumidityControlOperatingStateCCReport2 = class extends _classSuper {
    static {
      __name(this, "HumidityControlOperatingStateCCReport");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      HumidityControlOperatingStateCCReport2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
    constructor(options) {
      super(options);
      this.state = options.state;
    }
    static from(raw, ctx) {
      (0, import_core.validatePayload)(raw.payload.length >= 1);
      const state = raw.payload[0] & 15;
      return new this({
        nodeId: ctx.sourceNodeId,
        state
      });
    }
    state;
    toLogEntry(ctx) {
      return {
        ...super.toLogEntry(ctx),
        message: {
          state: (0, import_shared.getEnumMemberName)(import_Types.HumidityControlOperatingState, this.state)
        }
      };
    }
  };
  return HumidityControlOperatingStateCCReport2 = _classThis;
})();
let HumidityControlOperatingStateCCGet = (() => {
  let _classDecorators = [(0, import_CommandClassDecorators.CCCommand)(import_Types.HumidityControlOperatingStateCommand.Get), (0, import_CommandClassDecorators.expectedCCResponse)(HumidityControlOperatingStateCCReport)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = HumidityControlOperatingStateCC;
  var HumidityControlOperatingStateCCGet2 = class extends _classSuper {
    static {
      __name(this, "HumidityControlOperatingStateCCGet");
    }
    static {
      _classThis = this;
    }
    static {
      const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
      (0, import_tslib.__esDecorate)(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
      HumidityControlOperatingStateCCGet2 = _classThis = _classDescriptor.value;
      if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
      (0, import_tslib.__runInitializers)(_classThis, _classExtraInitializers);
    }
  };
  return HumidityControlOperatingStateCCGet2 = _classThis;
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  HumidityControlOperatingStateCC,
  HumidityControlOperatingStateCCAPI,
  HumidityControlOperatingStateCCGet,
  HumidityControlOperatingStateCCReport,
  HumidityControlOperatingStateCCValues
});
//# sourceMappingURL=HumidityControlOperatingStateCC.js.map
