"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 HelloMessages_exports = {};
__export(HelloMessages_exports, {
  HelloRequest: () => HelloRequest,
  HelloResponse: () => HelloResponse
});
module.exports = __toCommonJS(HelloMessages_exports);
var import_tslib = require("tslib");
var import_core = require("@zwave-js/core");
var import_shared = require("@zwave-js/shared");
var import_ESPHomeMessage = require("./ESPHomeMessage.js");
var import_ProtobufHelpers = require("./ProtobufHelpers.js");
let HelloRequest = (() => {
  let _classDecorators = [(0, import_ESPHomeMessage.messageType)(import_ESPHomeMessage.ESPHomeMessageType.HelloRequest)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_ESPHomeMessage.ESPHomeMessage;
  var HelloRequest2 = class extends _classSuper {
    static {
      __name(this, "HelloRequest");
    }
    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);
      HelloRequest2 = _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.clientInfo = options.clientInfo;
      this.apiVersionMajor = options.apiVersionMajor;
      this.apiVersionMinor = options.apiVersionMinor;
    }
    static from(raw) {
      let clientInfo = "";
      let apiVersionMajor = 0;
      let apiVersionMinor = 0;
      (0, import_ProtobufHelpers.parseProtobufMessage)(raw.payload, (fieldNumber, wireType, data, offset) => {
        switch (fieldNumber) {
          case 1:
            if (wireType !== 2) {
              throw new import_core.ZWaveError("Invalid wire type for clientInfo", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const clientInfoResult = (0, import_ProtobufHelpers.decodeStringField)(data, offset);
            clientInfo = clientInfoResult.value;
            return offset + clientInfoResult.bytesRead;
          case 2:
            if (wireType !== 0) {
              throw new import_core.ZWaveError("Invalid wire type for apiVersionMajor", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const majorResult = (0, import_ProtobufHelpers.decodeVarInt)(data, offset);
            apiVersionMajor = majorResult.value;
            return offset + majorResult.bytesRead;
          case 3:
            if (wireType !== 0) {
              throw new import_core.ZWaveError("Invalid wire type for apiVersionMinor", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const minorResult = (0, import_ProtobufHelpers.decodeVarInt)(data, offset);
            apiVersionMinor = minorResult.value;
            return offset + minorResult.bytesRead;
          default:
            return (0, import_ProtobufHelpers.skipField)(data, offset, wireType);
        }
      });
      return new this({
        clientInfo,
        apiVersionMajor,
        apiVersionMinor
      });
    }
    clientInfo;
    apiVersionMajor;
    apiVersionMinor;
    serialize() {
      const parts = [];
      if (this.clientInfo) {
        parts.push((0, import_ProtobufHelpers.encodeStringField)(1, this.clientInfo));
      }
      parts.push((0, import_ProtobufHelpers.encodeVarintField)(2, this.apiVersionMajor));
      parts.push((0, import_ProtobufHelpers.encodeVarintField)(3, this.apiVersionMinor));
      this.payload = import_shared.Bytes.concat(parts);
      return super.serialize();
    }
  };
  return HelloRequest2 = _classThis;
})();
let HelloResponse = (() => {
  let _classDecorators = [(0, import_ESPHomeMessage.messageType)(import_ESPHomeMessage.ESPHomeMessageType.HelloResponse)];
  let _classDescriptor;
  let _classExtraInitializers = [];
  let _classThis;
  let _classSuper = import_ESPHomeMessage.ESPHomeMessage;
  var HelloResponse2 = class extends _classSuper {
    static {
      __name(this, "HelloResponse");
    }
    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);
      HelloResponse2 = _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.apiVersionMajor = options.apiVersionMajor;
      this.apiVersionMinor = options.apiVersionMinor;
      this.serverInfo = options.serverInfo;
      this.name = options.name;
    }
    static from(raw) {
      let apiVersionMajor = 0;
      let apiVersionMinor = 0;
      let serverInfo = "";
      let name = "";
      (0, import_ProtobufHelpers.parseProtobufMessage)(raw.payload, (fieldNumber, wireType, data, offset) => {
        switch (fieldNumber) {
          case 1:
            if (wireType !== 0) {
              throw new import_core.ZWaveError("Invalid wire type for apiVersionMajor", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const majorResult = (0, import_ProtobufHelpers.decodeVarInt)(data, offset);
            apiVersionMajor = majorResult.value;
            return offset + majorResult.bytesRead;
          case 2:
            if (wireType !== 0) {
              throw new import_core.ZWaveError("Invalid wire type for apiVersionMinor", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const minorResult = (0, import_ProtobufHelpers.decodeVarInt)(data, offset);
            apiVersionMinor = minorResult.value;
            return offset + minorResult.bytesRead;
          case 3:
            if (wireType !== 2) {
              throw new import_core.ZWaveError("Invalid wire type for serverInfo", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const serverInfoResult = (0, import_ProtobufHelpers.decodeStringField)(data, offset);
            serverInfo = serverInfoResult.value;
            return offset + serverInfoResult.bytesRead;
          case 4:
            if (wireType !== 2) {
              throw new import_core.ZWaveError("Invalid wire type for name", import_core.ZWaveErrorCodes.Argument_Invalid);
            }
            const nameResult = (0, import_ProtobufHelpers.decodeStringField)(data, offset);
            name = nameResult.value;
            return offset + nameResult.bytesRead;
          default:
            return (0, import_ProtobufHelpers.skipField)(data, offset, wireType);
        }
      });
      return new this({
        apiVersionMajor,
        apiVersionMinor,
        serverInfo,
        name
      });
    }
    apiVersionMajor;
    apiVersionMinor;
    serverInfo;
    name;
    serialize() {
      const parts = [];
      parts.push((0, import_ProtobufHelpers.encodeVarintField)(1, this.apiVersionMajor));
      parts.push((0, import_ProtobufHelpers.encodeVarintField)(2, this.apiVersionMinor));
      if (this.serverInfo) {
        parts.push((0, import_ProtobufHelpers.encodeStringField)(3, this.serverInfo));
      }
      if (this.name) {
        parts.push((0, import_ProtobufHelpers.encodeStringField)(4, this.name));
      }
      this.payload = import_shared.Bytes.concat(parts);
      return super.serialize();
    }
  };
  return HelloResponse2 = _classThis;
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  HelloRequest,
  HelloResponse
});
//# sourceMappingURL=HelloMessages.js.map
