"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 resource_monitoring_exports = {};
__export(resource_monitoring_exports, {
  ResourceMonitoring: () => ResourceMonitoring
});
module.exports = __toCommonJS(resource_monitoring_exports);
var import_MutableCluster = require("../cluster/mutation/MutableCluster.js");
var import_Cluster = require("../cluster/Cluster.js");
var import_TlvNumber = require("../tlv/TlvNumber.js");
var import_TlvArray = require("../tlv/TlvArray.js");
var import_TlvObject = require("../tlv/TlvObject.js");
var import_TlvString = require("../tlv/TlvString.js");
var import_BitmapSchema = require("../schema/BitmapSchema.js");
var import_TlvBoolean = require("../tlv/TlvBoolean.js");
var import_TlvNullable = require("../tlv/TlvNullable.js");
var import_TlvNoArguments = require("../tlv/TlvNoArguments.js");
/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var ResourceMonitoring;
((ResourceMonitoring2) => {
  let Feature;
  ((Feature2) => {
    Feature2["Condition"] = "Condition";
    Feature2["Warning"] = "Warning";
    Feature2["ReplacementProductList"] = "ReplacementProductList";
  })(Feature = ResourceMonitoring2.Feature || (ResourceMonitoring2.Feature = {}));
  let DegradationDirection;
  ((DegradationDirection2) => {
    DegradationDirection2[DegradationDirection2["Up"] = 0] = "Up";
    DegradationDirection2[DegradationDirection2["Down"] = 1] = "Down";
  })(DegradationDirection = ResourceMonitoring2.DegradationDirection || (ResourceMonitoring2.DegradationDirection = {}));
  let ProductIdentifierType;
  ((ProductIdentifierType2) => {
    ProductIdentifierType2[ProductIdentifierType2["Upc"] = 0] = "Upc";
    ProductIdentifierType2[ProductIdentifierType2["Gtin8"] = 1] = "Gtin8";
    ProductIdentifierType2[ProductIdentifierType2["Ean"] = 2] = "Ean";
    ProductIdentifierType2[ProductIdentifierType2["Gtin14"] = 3] = "Gtin14";
    ProductIdentifierType2[ProductIdentifierType2["Oem"] = 4] = "Oem";
  })(ProductIdentifierType = ResourceMonitoring2.ProductIdentifierType || (ResourceMonitoring2.ProductIdentifierType = {}));
  ResourceMonitoring2.TlvReplacementProduct = (0, import_TlvObject.TlvObject)({
    productIdentifierType: (0, import_TlvObject.TlvField)(0, (0, import_TlvNumber.TlvEnum)()),
    productIdentifierValue: (0, import_TlvObject.TlvField)(1, import_TlvString.TlvString.bound({ maxLength: 20 }))
  });
  let ChangeIndication;
  ((ChangeIndication2) => {
    ChangeIndication2[ChangeIndication2["Ok"] = 0] = "Ok";
    ChangeIndication2[ChangeIndication2["Warning"] = 1] = "Warning";
    ChangeIndication2[ChangeIndication2["Critical"] = 2] = "Critical";
  })(ChangeIndication = ResourceMonitoring2.ChangeIndication || (ResourceMonitoring2.ChangeIndication = {}));
  ResourceMonitoring2.ConditionComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the current condition of the resource in percent.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.6.1
       */
      condition: (0, import_Cluster.Attribute)(0, import_TlvNumber.TlvPercent),
      /**
       * Indicates the direction of change for the condition of the resource over time, which helps to determine
       * whether a higher or lower condition value is considered optimal.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.6.2
       */
      degradationDirection: (0, import_Cluster.FixedAttribute)(1, (0, import_TlvNumber.TlvEnum)())
    }
  });
  ResourceMonitoring2.ReplacementProductListComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the list of supported products that may be used as replacements for the current resource. Each
       * item in this list represents a unique ReplacementProductStruct.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.6.6
       */
      replacementProductList: (0, import_Cluster.FixedAttribute)(
        5,
        (0, import_TlvArray.TlvArray)(ResourceMonitoring2.TlvReplacementProduct, { maxLength: 5 }),
        { default: [] }
      )
    }
  });
  ResourceMonitoring2.Base = import_MutableCluster.MutableCluster.Component({
    features: {
      /**
       * Supports monitoring the condition of the resource in percentage
       */
      condition: (0, import_BitmapSchema.BitFlag)(0),
      /**
       * Supports warning indication
       */
      warning: (0, import_BitmapSchema.BitFlag)(1),
      /**
       * Supports specifying the list of replacement products
       */
      replacementProductList: (0, import_BitmapSchema.BitFlag)(2)
    },
    name: "ResourceMonitoring",
    revision: 1,
    attributes: {
      /**
       * This attribute shall be populated with a value from ChangeIndicationEnum that is indicative of the
       * current requirement to change the resource.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.6.3
       */
      changeIndication: (0, import_Cluster.Attribute)(2, (0, import_TlvNumber.TlvEnum)()),
      /**
       * Indicates whether a resource is currently installed. A value of true shall indicate that a resource is
       * installed. A value of false shall indicate that a resource is not installed.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.6.4
       */
      inPlaceIndicator: (0, import_Cluster.OptionalAttribute)(3, import_TlvBoolean.TlvBoolean),
      /**
       * This attribute may indicates the time at which the resource has been changed, if supported by the server.
       * The attribute shall be null if it was never set or is unknown.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.6.5
       */
      lastChangedTime: (0, import_Cluster.OptionalWritableAttribute)(
        4,
        (0, import_TlvNullable.TlvNullable)(import_TlvNumber.TlvEpochS),
        { persistent: true, default: null }
      )
    },
    commands: {
      /**
       * Upon receipt, the device shall reset the Condition and ChangeIndicator attributes, indicating full
       * resource availability and readiness for use, as initially configured. Invocation of this command may
       * cause the LastChangedTime to be updated automatically based on the clock of the server, if the server
       * supports setting the attribute.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 2.8.7.1
       */
      resetCondition: (0, import_Cluster.OptionalCommand)(0, import_TlvNoArguments.TlvNoArguments, 0, import_Cluster.TlvNoResponse)
    },
    /**
     * This metadata controls which ResourceMonitoringCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: import_MutableCluster.MutableCluster.Extensions(
      { flags: { condition: true }, component: ResourceMonitoring2.ConditionComponent },
      { flags: { replacementProductList: true }, component: ResourceMonitoring2.ReplacementProductListComponent }
    )
  });
  const CON = { condition: true };
  const REP = { replacementProductList: true };
  ResourceMonitoring2.CompleteInstance = import_MutableCluster.MutableCluster.Component({
    name: ResourceMonitoring2.Base.name,
    revision: ResourceMonitoring2.Base.revision,
    features: ResourceMonitoring2.Base.features,
    attributes: {
      ...ResourceMonitoring2.Base.attributes,
      condition: import_MutableCluster.MutableCluster.AsConditional(ResourceMonitoring2.ConditionComponent.attributes.condition, { mandatoryIf: [CON] }),
      degradationDirection: import_MutableCluster.MutableCluster.AsConditional(
        ResourceMonitoring2.ConditionComponent.attributes.degradationDirection,
        { mandatoryIf: [CON] }
      ),
      replacementProductList: import_MutableCluster.MutableCluster.AsConditional(
        ResourceMonitoring2.ReplacementProductListComponent.attributes.replacementProductList,
        { mandatoryIf: [REP] }
      )
    },
    commands: ResourceMonitoring2.Base.commands
  });
  ResourceMonitoring2.Complete = ResourceMonitoring2.CompleteInstance;
})(ResourceMonitoring || (ResourceMonitoring = {}));
//# sourceMappingURL=resource-monitoring.js.map
