"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 ClientGroupInteraction_exports = {};
__export(ClientGroupInteraction_exports, {
  ClientGroupInteraction: () => ClientGroupInteraction,
  InvalidGroupOperationError: () => InvalidGroupOperationError
});
module.exports = __toCommonJS(ClientGroupInteraction_exports);
var import_general = require("#general");
var import_ClientNodeInteraction = require("./ClientNodeInteraction.js");
/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class InvalidGroupOperationError extends import_general.ImplementationError {
}
class ClientGroupInteraction extends import_ClientNodeInteraction.ClientNodeInteraction {
  /** Groups do not support reading or subscribing to attributes */
  read(_request, _context) {
    throw new InvalidGroupOperationError("Groups do not support reading attributes");
  }
  /** Groups do not support reading or subscribing to attributes */
  async subscribe(_request, _context) {
    throw new InvalidGroupOperationError("Groups do not support subscribing to attributes");
  }
  async write(request, context) {
    if (request.timedRequest) {
      throw new InvalidGroupOperationError("Timed requests are not supported for group address writes.");
    }
    if (request.suppressResponse === false) {
      throw new InvalidGroupOperationError("Writing attributes on a group address can not return a response.");
    }
    if (request.writeRequests.some(
      ({ path: { endpointId, clusterId, attributeId } }) => endpointId !== void 0 || clusterId === void 0 || attributeId === void 0
    )) {
      throw new InvalidGroupOperationError("Not all attribute write paths are valid for group address writes.");
    }
    return super.write({ ...request, suppressResponse: true }, context);
  }
  invoke(request, context) {
    if (request.invokeRequests.some(({ commandPath: { endpointId } }) => endpointId !== void 0)) {
      throw new InvalidGroupOperationError("Invoking a concrete command on a group address is not supported.");
    }
    if (request.timedRequest) {
      throw new InvalidGroupOperationError("Timed requests are not supported for group address invokes.");
    }
    request.suppressResponse = true;
    return super.invoke(request, context);
  }
}
//# sourceMappingURL=ClientGroupInteraction.js.map
