/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ValidationOutOfBoundsError, validatorOf } from "../common/ValidationError.js";
import { TlvUInt16 } from "../tlv/TlvNumber.js";
import { TlvWrapper } from "../tlv/TlvWrapper.js";
function EndpointNumber(endpointId, validate = true) {
  if (!validate || endpointId >= 0 && endpointId <= 65534) {
    return endpointId;
  }
  throw new ValidationOutOfBoundsError(`EndpointNumber must be between 0 and 0xFFFE, got ${endpointId}`);
}
((EndpointNumber2) => {
  EndpointNumber2.isValid = validatorOf(EndpointNumber2);
})(EndpointNumber || (EndpointNumber = {}));
const TlvEndpointNumber = new TlvWrapper(
  TlvUInt16,
  (endpointNumber) => endpointNumber,
  (value) => EndpointNumber(value, false)
  // No automatic validation on decode
);
export {
  EndpointNumber,
  TlvEndpointNumber
};
//# sourceMappingURL=EndpointNumber.js.map
