/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { Attribute, WritableAttribute } from "../cluster/Cluster.js";
import { TlvArray } from "../tlv/TlvArray.js";
import { TlvString } from "../tlv/TlvString.js";
import { TlvUInt8, TlvEnum } from "../tlv/TlvNumber.js";
import { TlvNullable } from "../tlv/TlvNullable.js";
import { BitFlag } from "../schema/BitmapSchema.js";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var LaundryWasherControls;
((LaundryWasherControls2) => {
  let Feature;
  ((Feature2) => {
    Feature2["Spin"] = "Spin";
    Feature2["Rinse"] = "Rinse";
  })(Feature = LaundryWasherControls2.Feature || (LaundryWasherControls2.Feature = {}));
  let NumberOfRinses;
  ((NumberOfRinses2) => {
    NumberOfRinses2[NumberOfRinses2["None"] = 0] = "None";
    NumberOfRinses2[NumberOfRinses2["Normal"] = 1] = "Normal";
    NumberOfRinses2[NumberOfRinses2["Extra"] = 2] = "Extra";
    NumberOfRinses2[NumberOfRinses2["Max"] = 3] = "Max";
  })(NumberOfRinses = LaundryWasherControls2.NumberOfRinses || (LaundryWasherControls2.NumberOfRinses = {}));
  LaundryWasherControls2.SpinComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the list of spin speeds available to the appliance in the currently selected mode. The spin
       * speed values are determined by the manufacturer. At least one spin speed value shall be provided in the
       * SpinSpeeds list. The list of spin speeds may change depending on the currently selected Laundry Washer
       * mode. For example, Quick mode might have a completely different list of SpinSpeeds than Delicates mode.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.6.6.1
       */
      spinSpeeds: Attribute(0, TlvArray(TlvString, { maxLength: 16 }), { default: [] }),
      /**
       * Indicates the currently selected spin speed. It is the index into the SpinSpeeds list of the selected
       * spin speed, as such, this attribute can be an integer between 0 and the number of entries in SpinSpeeds -
       * 1. If a value is received that is outside of the defined constraints, a CONSTRAINT_ERROR shall be sent as
       * the response. If a value is attempted to be written that doesn’t match a valid index (e.g. an index of 5
       * when the list has 4 values), a CONSTRAINT_ERROR shall be
       *
       * sent as the response. If null is written to this attribute, there will be no spin speed for the selected
       * cycle. If the value is null, there will be no spin speed on the current mode.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.6.6.2
       */
      spinSpeedCurrent: WritableAttribute(1, TlvNullable(TlvUInt8.bound({ max: 15 })))
    }
  });
  LaundryWasherControls2.RinseComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates how many times a rinse cycle shall be performed on a device for the current mode of operation.
       * A value of None shall indicate that no rinse cycle will be performed. This value may be set by the client
       * to adjust the number of rinses that are performed for the current mode of operation. If the device is not
       * in a compatible state to accept the provided value, an INVALID_IN_STATE error shall be sent as the
       * response.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.6.6.3
       */
      numberOfRinses: WritableAttribute(2, TlvEnum()),
      /**
       * Indicates the amount of rinses allowed for a specific mode. Each entry shall indicate a
       * NumberOfRinsesEnum value that is possible in the selected mode on the device. The value of this attribute
       * may change at runtime based on the currently selected mode. Each entry shall be distinct.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.6.6.4
       */
      supportedRinses: Attribute(3, TlvArray(TlvEnum(), { maxLength: 4 }), { default: [] })
    }
  });
  LaundryWasherControls2.Base = MutableCluster.Component({
    id: 83,
    name: "LaundryWasherControls",
    revision: 2,
    features: {
      /**
       * This feature indicates multiple spin speeds are supported in at least one supported mode. Note that some
       * modes may not support multiple spin speeds even if this feature is supported.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.6.4.1
       */
      spin: BitFlag(0),
      /**
       * This feature indicates multiple rinse cycles are supported in at least one supported mode. Note that some
       * modes may not support selection of the number of rinse cycles even if this feature is supported.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.6.4.2
       */
      rinse: BitFlag(1)
    },
    /**
     * This metadata controls which LaundryWasherControlsCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: MutableCluster.Extensions(
      { flags: { spin: true }, component: LaundryWasherControls2.SpinComponent },
      { flags: { rinse: true }, component: LaundryWasherControls2.RinseComponent },
      { flags: { spin: false, rinse: false }, component: false }
    )
  });
  LaundryWasherControls2.ClusterInstance = MutableCluster.ExtensibleOnly(LaundryWasherControls2.Base);
  LaundryWasherControls2.Cluster = LaundryWasherControls2.ClusterInstance;
  const SPIN = { spin: true };
  const RINSE = { rinse: true };
  LaundryWasherControls2.CompleteInstance = MutableCluster({
    id: LaundryWasherControls2.Base.id,
    name: LaundryWasherControls2.Base.name,
    revision: LaundryWasherControls2.Base.revision,
    features: LaundryWasherControls2.Base.features,
    attributes: {
      spinSpeeds: MutableCluster.AsConditional(LaundryWasherControls2.SpinComponent.attributes.spinSpeeds, { mandatoryIf: [SPIN] }),
      spinSpeedCurrent: MutableCluster.AsConditional(
        LaundryWasherControls2.SpinComponent.attributes.spinSpeedCurrent,
        { mandatoryIf: [SPIN] }
      ),
      numberOfRinses: MutableCluster.AsConditional(
        LaundryWasherControls2.RinseComponent.attributes.numberOfRinses,
        { mandatoryIf: [RINSE] }
      ),
      supportedRinses: MutableCluster.AsConditional(
        LaundryWasherControls2.RinseComponent.attributes.supportedRinses,
        { mandatoryIf: [RINSE] }
      )
    }
  });
  LaundryWasherControls2.Complete = LaundryWasherControls2.CompleteInstance;
})(LaundryWasherControls || (LaundryWasherControls = {}));
const LaundryWasherControlsCluster = LaundryWasherControls.Cluster;
ClusterRegistry.register(LaundryWasherControls.Complete);
export {
  LaundryWasherControls,
  LaundryWasherControlsCluster
};
//# sourceMappingURL=laundry-washer-controls.js.map
