/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { Attribute, OptionalAttribute } from "../cluster/Cluster.js";
import { TlvInt16, TlvUInt16, TlvInt8 } from "../tlv/TlvNumber.js";
import { TlvNullable } from "../tlv/TlvNullable.js";
import { BitFlag } from "../schema/BitmapSchema.js";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var PressureMeasurement;
((PressureMeasurement2) => {
  let Feature;
  ((Feature2) => {
    Feature2["Extended"] = "Extended";
  })(Feature = PressureMeasurement2.Feature || (PressureMeasurement2.Feature = {}));
  PressureMeasurement2.ExtendedComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the pressure in Pascals as follows:
       *
       * ScaledValue = 10Scale x Pressure [Pa]
       *
       * The null value indicates that the value is not available.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.5
       */
      scaledValue: Attribute(16, TlvNullable(TlvInt16)),
      /**
       * Indicates the minimum value of ScaledValue that can be measured. The null value indicates that the value
       * is not available.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.6
       */
      minScaledValue: Attribute(17, TlvNullable(TlvInt16.bound({ max: 32766 }))),
      /**
       * Indicates the maximum value of ScaledValue that can be measured. The null value indicates that the value
       * is not available.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.7
       */
      maxScaledValue: Attribute(18, TlvNullable(TlvInt16)),
      /**
       * Indicates the magnitude of the possible error that is associated with Scaled
       *
       * ### Value. The true value is located in the range
       *
       * (ScaledValue – ScaledTolerance) to (ScaledValue + ScaledTolerance).
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.8
       */
      scaledTolerance: OptionalAttribute(19, TlvUInt16.bound({ max: 2048 }), { default: 0 }),
      /**
       * Indicates the base 10 exponent used to obtain ScaledValue (see ScaledValue).
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.9
       */
      scale: Attribute(20, TlvInt8.bound({ min: -127 }))
    }
  });
  PressureMeasurement2.Base = MutableCluster.Component({
    id: 1027,
    name: "PressureMeasurement",
    revision: 3,
    features: {
      /**
       * Extended range and resolution
       */
      extended: BitFlag(0)
    },
    attributes: {
      /**
       * Indicates the pressure in kPa as follows:
       *
       * MeasuredValue = 10 x Pressure [kPa]
       *
       * The null value indicates that the value is not available.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.1
       */
      measuredValue: Attribute(0, TlvNullable(TlvInt16)),
      /**
       * Indicates the minimum value of MeasuredValue that can be measured. See Measured Value for more details.
       *
       * The null value indicates that the value is not available.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.2
       */
      minMeasuredValue: Attribute(1, TlvNullable(TlvInt16.bound({ max: 32766 }))),
      /**
       * Indicates the maximum value of MeasuredValue that can be measured. See Measured Value for more details.
       *
       * The null value indicates that the value is not available.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.3
       */
      maxMeasuredValue: Attribute(2, TlvNullable(TlvInt16)),
      /**
       * See Measured Value.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.4.5.4
       */
      tolerance: OptionalAttribute(3, TlvUInt16.bound({ max: 2048 }), { default: 0 })
    },
    /**
     * This metadata controls which PressureMeasurementCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: MutableCluster.Extensions({ flags: { extended: true }, component: PressureMeasurement2.ExtendedComponent })
  });
  PressureMeasurement2.ClusterInstance = MutableCluster(PressureMeasurement2.Base);
  PressureMeasurement2.Cluster = PressureMeasurement2.ClusterInstance;
  const EXT = { extended: true };
  PressureMeasurement2.CompleteInstance = MutableCluster({
    id: PressureMeasurement2.Cluster.id,
    name: PressureMeasurement2.Cluster.name,
    revision: PressureMeasurement2.Cluster.revision,
    features: PressureMeasurement2.Cluster.features,
    attributes: {
      ...PressureMeasurement2.Cluster.attributes,
      scaledValue: MutableCluster.AsConditional(PressureMeasurement2.ExtendedComponent.attributes.scaledValue, { mandatoryIf: [EXT] }),
      minScaledValue: MutableCluster.AsConditional(
        PressureMeasurement2.ExtendedComponent.attributes.minScaledValue,
        { mandatoryIf: [EXT] }
      ),
      maxScaledValue: MutableCluster.AsConditional(
        PressureMeasurement2.ExtendedComponent.attributes.maxScaledValue,
        { mandatoryIf: [EXT] }
      ),
      scaledTolerance: MutableCluster.AsConditional(
        PressureMeasurement2.ExtendedComponent.attributes.scaledTolerance,
        { optionalIf: [EXT] }
      ),
      scale: MutableCluster.AsConditional(PressureMeasurement2.ExtendedComponent.attributes.scale, { mandatoryIf: [EXT] })
    }
  });
  PressureMeasurement2.Complete = PressureMeasurement2.CompleteInstance;
})(PressureMeasurement || (PressureMeasurement = {}));
const PressureMeasurementCluster = PressureMeasurement.Cluster;
ClusterRegistry.register(PressureMeasurement.Complete);
export {
  PressureMeasurement,
  PressureMeasurementCluster
};
//# sourceMappingURL=pressure-measurement.js.map
