"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 Subscribe_exports = {};
__export(Subscribe_exports, {
  Subscribe: () => Subscribe
});
module.exports = __toCommonJS(Subscribe_exports);
var import_general = require("@matter/general");
var import_MalformedRequestError = require("./MalformedRequestError.js");
var import_Read = require("./Read.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
function Subscribe(options, ...selectors) {
  const subscribe = (0, import_Read.Read)(options, ...selectors);
  const { keepSubscriptions, minIntervalFloor, maxIntervalCeiling } = options;
  subscribe.keepSubscriptions = keepSubscriptions ?? true;
  if (minIntervalFloor !== void 0) {
    if (minIntervalFloor < 0 || import_general.Seconds.of(minIntervalFloor) > import_general.UINT16_MAX) {
      throw new import_MalformedRequestError.MalformedRequestError(`Minimum interval floor ${import_general.Seconds.of(minIntervalFloor)} is out of range`);
    }
    subscribe.minIntervalFloor = minIntervalFloor;
  }
  if (maxIntervalCeiling !== void 0) {
    if (maxIntervalCeiling < 0 || import_general.Seconds.of(maxIntervalCeiling) > import_general.UINT16_MAX) {
      throw new import_MalformedRequestError.MalformedRequestError(
        `Maximum interval ceiling ${import_general.Seconds.of(maxIntervalCeiling)} is out of range`
      );
    }
    subscribe.maxIntervalCeiling = maxIntervalCeiling;
  }
  return subscribe;
}
//# sourceMappingURL=Subscribe.js.map
