"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 RequestNodeInfoMessages_exports = {};
__export(RequestNodeInfoMessages_exports, {
  RequestNodeInfoRequest: () => RequestNodeInfoRequest,
  RequestNodeInfoResponse: () => RequestNodeInfoResponse
});
module.exports = __toCommonJS(RequestNodeInfoMessages_exports);
var import_tslib = require("tslib");
var import_core = require("@zwave-js/core");
var import_serial = require("@zwave-js/serial");
var import_shared = require("@zwave-js/shared");
var import_ApplicationUpdateRequest = require("../application/ApplicationUpdateRequest.js");
let RequestNodeInfoResponse = (() => {
  let _classDecorators = [(0, import_serial.messageTypes)(import_serial.MessageType.Response, import_serial.FunctionType.RequestNodeInfo)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_serial.Message;
  var RequestNodeInfoResponse2 = class extends _classSuper {
    static {
      __name(this, "RequestNodeInfoResponse");
    }
    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);
      RequestNodeInfoResponse2 = _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.wasSent = options.wasSent;
    }
    static from(raw, _ctx) {
      const wasSent = raw.payload[0] !== 0;
      return new this({
        wasSent
      });
    }
    wasSent;
    isOK() {
      return this.wasSent;
    }
    serialize(ctx) {
      this.payload = import_shared.Bytes.from([this.wasSent ? 1 : 0]);
      return super.serialize(ctx);
    }
    toLogEntry() {
      return {
        ...super.toLogEntry(),
        message: { "was sent": this.wasSent }
      };
    }
  };
  return RequestNodeInfoResponse2 = _classThis;
})();
function testCallbackForRequestNodeInfoRequest(sent, received) {
  return received instanceof import_ApplicationUpdateRequest.ApplicationUpdateRequestNodeInfoReceived && received.nodeId === sent.nodeId || received instanceof import_ApplicationUpdateRequest.ApplicationUpdateRequestNodeInfoRequestFailed;
}
__name(testCallbackForRequestNodeInfoRequest, "testCallbackForRequestNodeInfoRequest");
let RequestNodeInfoRequest = (() => {
  let _classDecorators = [(0, import_serial.messageTypes)(import_serial.MessageType.Request, import_serial.FunctionType.RequestNodeInfo), (0, import_serial.expectedResponse)(RequestNodeInfoResponse), (0, import_serial.expectedCallback)(testCallbackForRequestNodeInfoRequest), (0, import_serial.priority)(import_core.MessagePriority.NodeQuery)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_serial.Message;
  var RequestNodeInfoRequest2 = class extends _classSuper {
    static {
      __name(this, "RequestNodeInfoRequest");
    }
    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);
      RequestNodeInfoRequest2 = _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.nodeId = options.nodeId;
    }
    static from(raw, ctx) {
      const nodeId = (0, import_core.parseNodeID)(raw.payload, ctx.nodeIdType, 0).nodeId;
      return new this({
        nodeId
      });
    }
    nodeId;
    needsCallbackId() {
      return false;
    }
    serialize(ctx) {
      this.payload = (0, import_core.encodeNodeID)(this.nodeId, ctx.nodeIdType);
      return super.serialize(ctx);
    }
    toLogEntry() {
      return {
        ...super.toLogEntry(),
        message: { "node id": this.nodeId }
      };
    }
  };
  return RequestNodeInfoRequest2 = _classThis;
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  RequestNodeInfoRequest,
  RequestNodeInfoResponse
});
//# sourceMappingURL=RequestNodeInfoMessages.js.map
