/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { Attribute, OptionalAttribute, FixedAttribute } from "../cluster/Cluster.js";
import { TlvFloat, TlvEnum, TlvUInt32 } from "../tlv/TlvNumber.js";
import { TlvNullable } from "../tlv/TlvNullable.js";
import { BitFlag } from "../schema/BitmapSchema.js";
var ConcentrationMeasurement;
((ConcentrationMeasurement2) => {
  let Feature;
  ((Feature2) => {
    Feature2["NumericMeasurement"] = "NumericMeasurement";
    Feature2["LevelIndication"] = "LevelIndication";
    Feature2["MediumLevel"] = "MediumLevel";
    Feature2["CriticalLevel"] = "CriticalLevel";
    Feature2["PeakMeasurement"] = "PeakMeasurement";
    Feature2["AverageMeasurement"] = "AverageMeasurement";
  })(Feature = ConcentrationMeasurement2.Feature || (ConcentrationMeasurement2.Feature = {}));
  let MeasurementUnit;
  ((MeasurementUnit2) => {
    MeasurementUnit2[MeasurementUnit2["Ppm"] = 0] = "Ppm";
    MeasurementUnit2[MeasurementUnit2["Ppb"] = 1] = "Ppb";
    MeasurementUnit2[MeasurementUnit2["Ppt"] = 2] = "Ppt";
    MeasurementUnit2[MeasurementUnit2["Mgm3"] = 3] = "Mgm3";
    MeasurementUnit2[MeasurementUnit2["Ugm3"] = 4] = "Ugm3";
    MeasurementUnit2[MeasurementUnit2["Ngm3"] = 5] = "Ngm3";
    MeasurementUnit2[MeasurementUnit2["Pm3"] = 6] = "Pm3";
    MeasurementUnit2[MeasurementUnit2["Bqm3"] = 7] = "Bqm3";
  })(MeasurementUnit = ConcentrationMeasurement2.MeasurementUnit || (ConcentrationMeasurement2.MeasurementUnit = {}));
  let LevelValue;
  ((LevelValue2) => {
    LevelValue2[LevelValue2["Unknown"] = 0] = "Unknown";
    LevelValue2[LevelValue2["Low"] = 1] = "Low";
    LevelValue2[LevelValue2["Medium"] = 2] = "Medium";
    LevelValue2[LevelValue2["High"] = 3] = "High";
    LevelValue2[LevelValue2["Critical"] = 4] = "Critical";
  })(LevelValue = ConcentrationMeasurement2.LevelValue || (ConcentrationMeasurement2.LevelValue = {}));
  let MeasurementMedium;
  ((MeasurementMedium2) => {
    MeasurementMedium2[MeasurementMedium2["Air"] = 0] = "Air";
    MeasurementMedium2[MeasurementMedium2["Water"] = 1] = "Water";
    MeasurementMedium2[MeasurementMedium2["Soil"] = 2] = "Soil";
  })(MeasurementMedium = ConcentrationMeasurement2.MeasurementMedium || (ConcentrationMeasurement2.MeasurementMedium = {}));
  ConcentrationMeasurement2.NumericMeasurementComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the most recent measurement as a single-precision floating-point number. MeasuredValue’s unit
       * is represented by MeasurementUnit.
       *
       * A value of null indicates that the measurement is unknown or outside the valid range. MinMeasuredValue
       * and MaxMeasuredValue define the valid range for MeasuredValue.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.1
       */
      measuredValue: Attribute(0, TlvNullable(TlvFloat)),
      /**
       * Indicates the minimum value of MeasuredValue that is capable of being measured. A MinMeasuredValue of
       * null indicates that the MinMeasuredValue is not defined.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.2
       */
      minMeasuredValue: Attribute(1, TlvNullable(TlvFloat)),
      /**
       * Indicates the maximum value of MeasuredValue that is capable of being measured. A MaxMeasuredValue of
       * null indicates that the MaxMeasuredValue is not defined.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.3
       */
      maxMeasuredValue: Attribute(2, TlvNullable(TlvFloat)),
      /**
       * Indicates the range of error or deviation that can be found in MeasuredValue and PeakMeasuredValue. This
       * is considered a +/- value and should be considered to be in MeasurementUnit.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.8
       */
      uncertainty: OptionalAttribute(7, TlvFloat),
      /**
       * Indicates the unit of MeasuredValue. See MeasurementUnitEnum.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.9
       */
      measurementUnit: FixedAttribute(8, TlvEnum())
    }
  });
  ConcentrationMeasurement2.PeakMeasurementComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the maximum value of MeasuredValue that has been measured during the PeakMeasuredValueWindow.
       * If this attribute is provided, the PeakMeasuredValueWindow attribute shall also be provided.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.4
       */
      peakMeasuredValue: Attribute(3, TlvNullable(TlvFloat)),
      /**
       * Indicates the window of time used for determining the PeakMeasuredValue. The value is in seconds.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.5
       */
      peakMeasuredValueWindow: Attribute(4, TlvUInt32.bound({ max: 604800 }))
    }
  });
  ConcentrationMeasurement2.AverageMeasurementComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the average value of MeasuredValue that has been measured during the
       * AverageMeasuredValueWindow. If this attribute is provided, the AverageMeasuredValueWindow attribute shall
       * also be provided.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.6
       */
      averageMeasuredValue: Attribute(5, TlvNullable(TlvFloat)),
      /**
       * Indicates the window of time used for determining the AverageMeasuredValue. The value is in seconds.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.7
       */
      averageMeasuredValueWindow: Attribute(6, TlvUInt32.bound({ max: 604800 }))
    }
  });
  ConcentrationMeasurement2.LevelIndicationComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the level of the substance detected. See LevelValueEnum.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.11
       */
      levelValue: Attribute(10, TlvEnum())
    }
  });
  ConcentrationMeasurement2.Base = MutableCluster.Component({
    features: {
      /**
       * Cluster supports numeric measurement of substance
       */
      numericMeasurement: BitFlag(0),
      /**
       * Cluster supports basic level indication for substance using the ConcentrationLevel enum
       */
      levelIndication: BitFlag(1),
      /**
       * Cluster supports the Medium Concentration Level
       */
      mediumLevel: BitFlag(2),
      /**
       * Cluster supports the Critical Concentration Level
       */
      criticalLevel: BitFlag(3),
      /**
       * Cluster supports peak numeric measurement of substance
       */
      peakMeasurement: BitFlag(4),
      /**
       * Cluster supports average numeric measurement of substance
       */
      averageMeasurement: BitFlag(5)
    },
    name: "ConcentrationMeasurement",
    revision: 3,
    attributes: {
      /**
       * Indicates the medium in which MeasuredValue or LevelValue is being measured. See MeasurementMediumEnum.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.10.6.10
       */
      measurementMedium: FixedAttribute(9, TlvEnum())
    },
    /**
     * This metadata controls which ConcentrationMeasurementCluster elements matter.js activates for specific
     * feature combinations.
     */
    extensions: MutableCluster.Extensions(
      { flags: { numericMeasurement: true }, component: ConcentrationMeasurement2.NumericMeasurementComponent },
      { flags: { peakMeasurement: true }, component: ConcentrationMeasurement2.PeakMeasurementComponent },
      { flags: { averageMeasurement: true }, component: ConcentrationMeasurement2.AverageMeasurementComponent },
      { flags: { levelIndication: true }, component: ConcentrationMeasurement2.LevelIndicationComponent },
      { flags: { mediumLevel: true, levelIndication: false }, component: false },
      { flags: { criticalLevel: true, levelIndication: false }, component: false },
      { flags: { peakMeasurement: true, numericMeasurement: false }, component: false },
      { flags: { averageMeasurement: true, numericMeasurement: false }, component: false },
      { flags: { numericMeasurement: false, levelIndication: false }, component: false }
    )
  });
  const MEA = { numericMeasurement: true };
  const PEA = { peakMeasurement: true };
  const AVG = { averageMeasurement: true };
  const LEV = { levelIndication: true };
  ConcentrationMeasurement2.CompleteInstance = MutableCluster.Component({
    name: ConcentrationMeasurement2.Base.name,
    revision: ConcentrationMeasurement2.Base.revision,
    features: ConcentrationMeasurement2.Base.features,
    attributes: {
      ...ConcentrationMeasurement2.Base.attributes,
      measuredValue: MutableCluster.AsConditional(
        ConcentrationMeasurement2.NumericMeasurementComponent.attributes.measuredValue,
        { mandatoryIf: [MEA] }
      ),
      minMeasuredValue: MutableCluster.AsConditional(
        ConcentrationMeasurement2.NumericMeasurementComponent.attributes.minMeasuredValue,
        { mandatoryIf: [MEA] }
      ),
      maxMeasuredValue: MutableCluster.AsConditional(
        ConcentrationMeasurement2.NumericMeasurementComponent.attributes.maxMeasuredValue,
        { mandatoryIf: [MEA] }
      ),
      peakMeasuredValue: MutableCluster.AsConditional(
        ConcentrationMeasurement2.PeakMeasurementComponent.attributes.peakMeasuredValue,
        { mandatoryIf: [PEA] }
      ),
      peakMeasuredValueWindow: MutableCluster.AsConditional(
        ConcentrationMeasurement2.PeakMeasurementComponent.attributes.peakMeasuredValueWindow,
        { mandatoryIf: [PEA] }
      ),
      averageMeasuredValue: MutableCluster.AsConditional(
        ConcentrationMeasurement2.AverageMeasurementComponent.attributes.averageMeasuredValue,
        { mandatoryIf: [AVG] }
      ),
      averageMeasuredValueWindow: MutableCluster.AsConditional(
        ConcentrationMeasurement2.AverageMeasurementComponent.attributes.averageMeasuredValueWindow,
        { mandatoryIf: [AVG] }
      ),
      uncertainty: MutableCluster.AsConditional(
        ConcentrationMeasurement2.NumericMeasurementComponent.attributes.uncertainty,
        { optionalIf: [MEA] }
      ),
      measurementUnit: MutableCluster.AsConditional(
        ConcentrationMeasurement2.NumericMeasurementComponent.attributes.measurementUnit,
        { mandatoryIf: [MEA] }
      ),
      levelValue: MutableCluster.AsConditional(
        ConcentrationMeasurement2.LevelIndicationComponent.attributes.levelValue,
        { mandatoryIf: [LEV] }
      )
    }
  });
  ConcentrationMeasurement2.Complete = ConcentrationMeasurement2.CompleteInstance;
})(ConcentrationMeasurement || (ConcentrationMeasurement = {}));
export {
  ConcentrationMeasurement
};
//# sourceMappingURL=concentration-measurement.js.map
