/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { FixedAttribute, Command, TlvNoResponse, Attribute, Event } from "../cluster/Cluster.js";
import { BitFlag } from "../schema/BitmapSchema.js";
import { TlvUInt32, TlvBitmap } from "../tlv/TlvNumber.js";
import { TlvField, TlvObject } from "../tlv/TlvObject.js";
import { Priority } from "../globals/Priority.js";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var RefrigeratorAlarm;
((RefrigeratorAlarm2) => {
  let Feature;
  ((Feature2) => {
    Feature2["Reset"] = "Reset";
  })(Feature = RefrigeratorAlarm2.Feature || (RefrigeratorAlarm2.Feature = {}));
  RefrigeratorAlarm2.Alarm = {
    /**
     * The cabinet’s door has been open for a vendor defined amount of time.
     */
    doorOpen: BitFlag(0)
  };
  RefrigeratorAlarm2.TlvResetRequest = TlvObject({
    /**
     * This field shall indicate a bitmap where each bit set in this field corresponds to an alarm that shall be
     * reset to inactive in the State attribute unless the alarm definition requires manual intervention. If the
     * alarms indicated are successfully reset, the response status code shall be SUCCESS, otherwise, the response
     * status code shall be FAILURE.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 1.15.7.1.1
     */
    alarms: TlvField(0, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm))
  });
  RefrigeratorAlarm2.TlvNotifyEvent = TlvObject({
    /**
     * This field shall indicate those alarms that have become active.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 1.15.8.1.1
     */
    active: TlvField(0, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm)),
    /**
     * This field shall indicate those alarms that have become inactive.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 1.15.8.1.2
     */
    inactive: TlvField(1, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm)),
    /**
     * This field shall be a copy of the new State attribute value that resulted in the event being generated. That
     * is, this field shall have all the bits in Active set and shall NOT have any of the bits in Inactive set.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 1.15.8.1.4
     */
    state: TlvField(2, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm)),
    /**
     * This field shall be a copy of the Mask attribute when this event was generated.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 1.15.8.1.3
     */
    mask: TlvField(3, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm))
  });
  RefrigeratorAlarm2.ResetComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates a bitmap where each bit set in the Latch attribute shall indicate that the corresponding alarm
       * will be latched when set, and will not reset to inactive when the underlying condition which caused the
       * alarm is no longer present, and so requires an explicit reset using the Reset command.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 1.15.6.2
       */
      latch: FixedAttribute(1, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm))
    },
    commands: {
      /**
       * This command resets active and latched alarms (if possible). Any generated Notify event shall contain
       * fields that represent the state of the server after the command has been processed.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 1.15.7.1
       */
      reset: Command(0, RefrigeratorAlarm2.TlvResetRequest, 0, TlvNoResponse)
    }
  });
  RefrigeratorAlarm2.Base = MutableCluster.Component({
    id: 87,
    name: "RefrigeratorAlarm",
    revision: 1,
    features: {
      /**
       * Supports the ability to reset alarms
       */
      reset: BitFlag(0)
    },
    attributes: {
      /**
       * Indicates a bitmap where each bit set in the Mask attribute corresponds to an alarm that shall be
       * enabled.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 1.15.6.1
       */
      mask: Attribute(0, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm)),
      /**
       * Indicates a bitmap where each bit shall represent the state of an alarm. The value of true means the
       * alarm is active, otherwise the alarm is inactive.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 1.15.6.3
       */
      state: Attribute(2, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm)),
      /**
       * Indicates a bitmap where each bit shall represent whether or not an alarm is supported. The value of true
       * means the alarm is supported, otherwise the alarm is not supported.
       *
       * If an alarm is not supported, the corresponding bit in Mask, Latch, and State shall be false.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 1.15.6.4
       */
      supported: FixedAttribute(3, TlvBitmap(TlvUInt32, RefrigeratorAlarm2.Alarm))
    },
    events: {
      /**
       * This event shall be generated when one or more alarms change state.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 1.15.8.1
       */
      notify: Event(0, Priority.Info, RefrigeratorAlarm2.TlvNotifyEvent)
    },
    /**
     * This metadata controls which RefrigeratorAlarmCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: MutableCluster.Extensions(
      { flags: { reset: true }, component: RefrigeratorAlarm2.ResetComponent },
      { flags: { reset: true }, component: false }
    )
  });
  RefrigeratorAlarm2.ClusterInstance = MutableCluster(RefrigeratorAlarm2.Base);
  RefrigeratorAlarm2.Cluster = RefrigeratorAlarm2.ClusterInstance;
  const RESET = { reset: true };
  RefrigeratorAlarm2.CompleteInstance = MutableCluster({
    id: RefrigeratorAlarm2.Cluster.id,
    name: RefrigeratorAlarm2.Cluster.name,
    revision: RefrigeratorAlarm2.Cluster.revision,
    features: RefrigeratorAlarm2.Cluster.features,
    attributes: {
      ...RefrigeratorAlarm2.Cluster.attributes,
      latch: MutableCluster.AsConditional(RefrigeratorAlarm2.ResetComponent.attributes.latch, { mandatoryIf: [RESET] })
    },
    commands: { reset: MutableCluster.AsConditional(RefrigeratorAlarm2.ResetComponent.commands.reset, { mandatoryIf: [RESET] }) },
    events: RefrigeratorAlarm2.Cluster.events
  });
  RefrigeratorAlarm2.Complete = RefrigeratorAlarm2.CompleteInstance;
})(RefrigeratorAlarm || (RefrigeratorAlarm = {}));
const RefrigeratorAlarmCluster = RefrigeratorAlarm.Cluster;
ClusterRegistry.register(RefrigeratorAlarm.Complete);
export {
  RefrigeratorAlarm,
  RefrigeratorAlarmCluster
};
//# sourceMappingURL=refrigerator-alarm.js.map
