"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 IcdManagement_exports = {};
__export(IcdManagement_exports, {
  IcdManagement: () => IcdManagement
});
module.exports = __toCommonJS(IcdManagement_exports);
var import_MatterDefinition = require("../MatterDefinition.js");
var import_elements = require("../../elements/index.js");
/**
 * @license
 * Copyright 2022-2024 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
const IcdManagement = (0, import_elements.ClusterElement)({
  name: "IcdManagement",
  id: 70,
  classification: "node",
  pics: "ICDM",
  details: "ICD Management Cluster enables configuration of the ICD\u2019s behavior and ensuring that listed clients can be notified when an intermittently connected device, ICD, is available for communication.\nThe cluster implements the requirements of the Check-In Protocol that enables the ICD Check-In use case.\nNOTE This feature is provisional.",
  xref: { document: "core", section: "9.17" },
  children: [
    (0, import_elements.AttributeElement)({ name: "ClusterRevision", id: 65533, type: "ClusterRevision", default: 2 }),
    (0, import_elements.AttributeElement)({
      name: "FeatureMap",
      id: 65532,
      type: "FeatureMap",
      xref: { document: "core", section: "9.17.4" },
      children: [
        (0, import_elements.FieldElement)({
          name: "CIP",
          conformance: "P, LITS, O",
          constraint: "0",
          description: "CheckInProtocolSupport",
          details: "When this feature is supported, the device shall support all the associated commands and attributes to properly support the Check-In Protocol.",
          xref: { document: "core", section: "9.17.4.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "UAT",
          conformance: "P, LITS, O",
          constraint: "1",
          description: "UserActiveModeTrigger",
          details: "This feature is supported if and only if the device has a user active mode trigger.",
          xref: { document: "core", section: "9.17.4.2" }
        }),
        (0, import_elements.FieldElement)({
          name: "LITS",
          conformance: "P, O",
          constraint: "2",
          description: "LongIdleTimeSupport",
          details: "This feature is supported if and only the device is a Long Idle Time ICD.\nNOTE In this version of the specification, the support for the feature is provisional.",
          xref: { document: "core", section: "9.17.4.3" }
        })
      ]
    }),
    (0, import_elements.AttributeElement)({
      name: "IdleModeDuration",
      id: 0,
      type: "uint32",
      access: "R V",
      conformance: "M",
      constraint: "1 to 64800",
      default: 1,
      quality: "F",
      details: "Indicates the maximum interval in seconds the server can stay in idle mode. The IdleModeDuration shall NOT be smaller than the ActiveModeDuration.",
      xref: { document: "core", section: "9.17.6.1" }
    }),
    (0, import_elements.AttributeElement)({
      name: "ActiveModeDuration",
      id: 1,
      type: "uint32",
      access: "R V",
      conformance: "M",
      default: 300,
      quality: "F",
      details: "Indicates the minimum interval in milliseconds the server typically will stay in active mode after initial transition out of idle mode. The ActiveModeDuration does not include the ActiveModeThreshold.",
      xref: { document: "core", section: "9.17.6.2" }
    }),
    (0, import_elements.AttributeElement)({
      name: "ActiveModeThreshold",
      id: 2,
      type: "uint16",
      access: "R V",
      conformance: "M",
      default: 300,
      quality: "F",
      details: "Indicates the minimum amount of time in milliseconds the server typically will stay active after network activity when in active mode.",
      xref: { document: "core", section: "9.17.6.3" }
    }),
    (0, import_elements.AttributeElement)({
      name: "RegisteredClients",
      id: 3,
      type: "list",
      access: "R F A",
      conformance: "CIP",
      constraint: "desc",
      default: [],
      quality: "N",
      details: "This attribute shall contain all clients registered to receive notification if their subscription is lost. The maximum number of entries that can be in the list shall be ClientsSupportedPerFabric for each fabric supported on the server, as indicated by the value of the SupportedFabrics attribute in the Operational Credentials cluster.",
      xref: { document: "core", section: "9.17.6.4" },
      children: [(0, import_elements.FieldElement)({ name: "entry", type: "MonitoringRegistrationStruct" })]
    }),
    (0, import_elements.AttributeElement)({
      name: "IcdCounter",
      id: 4,
      type: "uint32",
      access: "R A",
      conformance: "CIP",
      default: 0,
      quality: "N C",
      details: "This attribute returns the value of the ICD Counter.",
      xref: { document: "core", section: "9.17.6.5" }
    }),
    (0, import_elements.AttributeElement)({
      name: "ClientsSupportedPerFabric",
      id: 5,
      type: "uint16",
      access: "R V",
      conformance: "CIP",
      constraint: "min 1",
      default: 1,
      quality: "F",
      details: "Indicates the maximum number of entries that the server is able to store for each fabric in the RegisteredClients attribute.",
      xref: { document: "core", section: "9.17.6.6" }
    }),
    (0, import_elements.AttributeElement)({
      name: "UserActiveModeTriggerHint",
      id: 6,
      type: "UserActiveModeTriggerBitmap",
      access: "R V",
      conformance: "P, UAT",
      constraint: "desc",
      default: 0,
      quality: "F",
      details: "Indicates which user action(s) will trigger the ICD to switch to Active mode. If the attribute indicates support for a trigger that is dependent on the UserActiveModeTriggerInstruction in the UserActiveModeTriggerHint table, the UserActiveModeTriggerInstruction attribute shall be implemented and shall provide the required information, unless specified otherwise in the requirement column of the UserActiveModeTriggerHint table.\nActuateSensorLightsBlink, ResetButtonLightsBlink and SetupButtonLightsBlink (i.e. bits 7, 9 and 14) have a dependency on the UserActiveModeTriggerInstruction attribute but do not require the attribute to be present.\nAn ICD can indicate multiple ways of being put into Active Mode by setting multiple bits in the bitmap at the same time. However, a device shall NOT set more than one bit which has a dependency on the UserActiveModeTriggerInstruction attribute.",
      xref: { document: "core", section: "9.17.6.7" }
    }),
    (0, import_elements.AttributeElement)({
      name: "UserActiveModeTriggerInstruction",
      id: 7,
      type: "string",
      access: "R V",
      conformance: "P, desc",
      constraint: "max 128",
      default: "",
      quality: "F",
      details: 'The meaning of the attribute is dependent upon the UserActiveModeTriggerHint attribute value, and the conformance is in indicated in the "dependency" column in UserActiveModeTriggerHint table. The UserActiveModeTriggerInstruction attribute may give additional information on how to transition the device to Active Mode. If the attribute is present, the value shall be encoded as a valid UTF-8 string with a maximum length of 128 bytes. If the UserActiveModeTriggerHint has the ActuateSensorSeconds, ActuateSensorTimes, ResetButtonSeconds, ResetButtonTimes, SetupButtonSeconds or SetupButtonTimes set, the string shall consist solely of an encoding of N as a decimal\nunsigned integer using the ASCII digits 0-9, and without leading zeros.\nFor example, given UserActiveModeTriggerHint="2048", ResetButtonTimes is set which indicates "Press Reset Button for N seconds". Therefore, a value of UserActiveModeTriggerInstruction="10" would indicate that N is 10 in that context.\nWhen CustomInstruction is set by the UserActiveModeTriggerHint attribute, indicating presence of a custom string, the ICD SHOULD perform localization (translation to user\u2019s preferred language, as indicated in the Device\u2019s currently configured locale). The Custom Instruction option SHOULD NOT be used by an ICD that does not have knowledge of the user\u2019s language preference.\n### When the UserActiveModeTriggerHint key indicates a light to blink (ActuateSensorLightsBlink, ResetButtonLightsBlink or SetupButtonLightsBlink), information on color of light may be made available via the UserActiveModeTriggerInstruction attribute. When using such color indication in the UserActiveModeTriggerInstruction attribute, only basic primary and secondary colors that could unambiguously be decoded by a commissioner and understood by an end-user, but without worry of localization, SHOULD be used, e.g. white, red, green, blue, orange, yellow, purple. The length of the attribute SHOULD be kept small.',
      xref: { document: "core", section: "9.17.6.8" }
    }),
    (0, import_elements.AttributeElement)({
      name: "OperatingMode",
      id: 8,
      type: "OperatingModeEnum",
      access: "R V",
      conformance: "P, LITS",
      details: "Indicates the operating mode of the ICD as specified in the OperatingModeEnum.\n  \u2022 If the ICD is operating as a LIT ICD, OperatingMode shall be LIT.\n  \u2022 If the ICD is operating as a SIT ICD, OperatingMode shall be SIT.",
      xref: { document: "core", section: "9.17.6.9" }
    }),
    (0, import_elements.CommandElement)({
      name: "RegisterClient",
      id: 0,
      access: "F M",
      conformance: "CIP",
      direction: "request",
      response: "RegisterClientResponse",
      details: "This command allows a client to register itself with the ICD to be notified when the device is available for communication.",
      xref: { document: "core", section: "9.17.7.1" },
      children: [
        (0, import_elements.FieldElement)({
          name: "CheckInNodeId",
          id: 0,
          type: "node-id",
          conformance: "M",
          details: "This field shall provide the node ID to which a Check-In message will be sent if there are no active subscriptions matching MonitoredSubject.",
          xref: { document: "core", section: "9.17.7.1.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "MonitoredSubject",
          id: 1,
          type: "subject-id",
          conformance: "M",
          details: "This field shall provide the monitored subject ID.",
          xref: { document: "core", section: "9.17.7.1.2" }
        }),
        (0, import_elements.FieldElement)({
          name: "Key",
          id: 2,
          type: "octstr",
          conformance: "M",
          constraint: "16",
          details: "This field shall provide the shared secret between the client and the ICD to encrypt the Check-In message.",
          xref: { document: "core", section: "9.17.7.1.3" }
        }),
        (0, import_elements.FieldElement)({
          name: "VerificationKey",
          id: 3,
          type: "octstr",
          conformance: "O",
          constraint: "16",
          details: "This field shall provide the verification key. The verification key represents the key already stored on the server. The verification key provided in this field shall be used by the server to guarantee that a client with manage permissions can only modify entries that contain a Key equal to the verification key. The verification key shall be provided for clients with manage permissions. The verification key SHOULD NOT be provided by clients with administrator permissions for the server cluster. The verification key shall be ignored by the server if it is provided by a client with administrator permissions for the server cluster.",
          xref: { document: "core", section: "9.17.7.1.4" }
        })
      ]
    }),
    (0, import_elements.CommandElement)({
      name: "RegisterClientResponse",
      id: 1,
      conformance: "CIP",
      direction: "response",
      details: "This command shall be sent by the ICD Management Cluster server in response to a successful RegisterClient command.",
      xref: { document: "core", section: "9.17.7.2" },
      children: [(0, import_elements.FieldElement)({ name: "IcdCounter", id: 0, type: "uint32", conformance: "M" })]
    }),
    (0, import_elements.CommandElement)({
      name: "UnregisterClient",
      id: 2,
      access: "F M",
      conformance: "CIP",
      direction: "request",
      response: "status",
      details: "This command allows a client to unregister itself with the ICD. Example: a client that is leaving the network (e.g. running on a phone which is leaving the home) can (and should) remove its subscriptions and send this UnregisterClient command before leaving to prevent the burden on the ICD of an absent client.",
      xref: { document: "core", section: "9.17.7.3" },
      children: [
        (0, import_elements.FieldElement)({
          name: "CheckInNodeId",
          id: 0,
          type: "node-id",
          conformance: "M",
          details: "This field shall provide the registered client node ID to remove from storage.",
          xref: { document: "core", section: "9.17.7.3.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "VerificationKey",
          id: 1,
          type: "octstr",
          conformance: "O",
          constraint: "16",
          details: "This field shall provide the verification key associated with the CheckInNodeID to remove from storage. The verification key represents the key already stored on the server. The verification key provided in this field shall be used by the server to guarantee that a client with manage permissions can only remove entries that contain a Key equal to the stored key. The verification key shall be provided for clients with manage permissions. The verification key SHOULD NOT be provided by clients with administrator permissions for the server cluster. The verification key shall be ignored by the server if it is provided by a client with administrator permissions for the server cluster.",
          xref: { document: "core", section: "9.17.7.3.2" }
        })
      ]
    }),
    (0, import_elements.CommandElement)({
      name: "StayActiveRequest",
      id: 3,
      access: "O",
      conformance: "LITS, O",
      direction: "request",
      response: "StayActiveResponse",
      details: "This command allows a client to request that the server stays in active mode for at least a given time duration (in milliseconds) from when this command is received.\nThis StayActiveDuration may be longer than the ActiveModeThreshold value and would, typically, be used by the client to request the server to stay active and responsive for this period to allow a sequence of message exchanges during that period. The client may slightly overestimate the duration it wants the ICD to be active for, in order to account for network delays.",
      xref: { document: "core", section: "9.17.7.4" },
      children: [(0, import_elements.FieldElement)({ name: "StayActiveDuration", id: 0, type: "uint32", conformance: "M" })]
    }),
    (0, import_elements.CommandElement)({
      name: "StayActiveResponse",
      id: 4,
      conformance: "LITS, O",
      direction: "response",
      details: "This message shall be sent by the ICD in response to the StayActiveRequest command and shall contain the computed duration (in milliseconds) that the ICD intends to stay active for.",
      xref: { document: "core", section: "9.17.7.5" },
      children: [(0, import_elements.FieldElement)({
        name: "PromisedActiveDuration",
        id: 0,
        type: "uint32",
        conformance: "M",
        constraint: "desc",
        details: "This field shall provide the actual duration that the ICD server can stay active from the time it receives the StayActiveRequest command.\n### Minimum Value for PromisedActiveDuration\nThe minimum value of the PromisedActiveDuration field shall be equal to either 30000 milliseconds or StayActiveDuration (from the received StayActiveRequest command), whichever is smaller.",
        xref: { document: "core", section: "9.17.7.5.1" }
      })]
    }),
    (0, import_elements.DatatypeElement)({
      name: "UserActiveModeTriggerBitmap",
      type: "map32",
      details: "See the UserActiveModeTriggerHint table for requirements associated to each bit.",
      xref: { document: "core", section: "9.17.5.1" },
      children: [
        (0, import_elements.FieldElement)({
          name: "PowerCycle",
          constraint: "0",
          description: "Power Cycle to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "SettingsMenu",
          constraint: "1",
          description: "Settings menu on the device informs how to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "CustomInstruction",
          constraint: "2",
          description: "Custom Instruction on how to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "DeviceManual",
          constraint: "3",
          description: "Device Manual informs how to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ActuateSensor",
          constraint: "4",
          description: "Actuate Sensor to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ActuateSensorSeconds",
          constraint: "5",
          description: "Actuate Sensor for N seconds to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ActuateSensorTimes",
          constraint: "6",
          description: "Actuate Sensor N times to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ActuateSensorLightsBlink",
          constraint: "7",
          description: "Actuate Sensor until light blinks to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ResetButton",
          constraint: "8",
          description: "Press Reset Button to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ResetButtonLightsBlink",
          constraint: "9",
          description: "Press Reset Button until light blinks to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ResetButtonSeconds",
          constraint: "10",
          description: "Press Reset Button for N seconds to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "ResetButtonTimes",
          constraint: "11",
          description: "Press Reset Button N times to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "SetupButton",
          constraint: "12",
          description: "Press Setup Button to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "SetupButtonSeconds",
          constraint: "13",
          description: "Press Setup Button for N seconds to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "SetupButtonLightsBlink",
          constraint: "14",
          description: "Press Setup Button until light blinks to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "SetupButtonTimes",
          constraint: "15",
          description: "Press Setup Button N times to transition the device to ActiveMode"
        }),
        (0, import_elements.FieldElement)({
          name: "AppDefinedButton",
          constraint: "16",
          description: "Press the N Button to transition the device to ActiveMode"
        })
      ]
    }),
    (0, import_elements.DatatypeElement)({
      name: "MonitoringRegistrationStruct",
      type: "struct",
      xref: { document: "core", section: "9.17.5.2" },
      children: [
        (0, import_elements.FieldElement)({
          name: "CheckInNodeId",
          id: 1,
          type: "node-id",
          access: "S",
          conformance: "M",
          quality: "N",
          details: "This field shall indicate the NodeID of the Node to which Check-In messages will be sent when the MonitoredSubject is not subscribed.",
          xref: { document: "core", section: "9.17.5.2.1" }
        }),
        (0, import_elements.FieldElement)({
          name: "MonitoredSubject",
          id: 2,
          type: "subject-id",
          access: "S",
          conformance: "M",
          quality: "N",
          details: "This field shall indicate the monitored Subject ID. This field shall be used to determine if a particular client has an active subscription for the given entry. The MonitoredSubject, when it is a NodeID, may be the same as the CheckInNodeID. The MonitoredSubject gives the registering client the flexibility of having a different CheckInNodeID from the MonitoredSubject. A subscription shall count as an active subscription for this entry if:\n  \u2022 It is on the associated fabric of this entry, and\n  \u2022 The subject of this entry matches the ISD of the SubscriptionRequest message that created the     subscription. Matching shall be determined using the subject_matches function defined in the     Access Control Privilege Granting Algorithm.\nFor example, if the MonitoredSubject is Node ID 0x1111_2222_3333_AAAA, and one of the subscribers to the server on the entry\u2019s associated fabric bears that Node ID, then the entry matches.\nAnother example is if the MonitoredSubject has the value 0xFFFF_FFFD_AA12_0002, and one of the subscribers to the server on the entry\u2019s associated fabric bears the CASE Authenticated TAG value 0xAA12 and the version 0x0002 or higher within its NOC, then the entry matches.",
          xref: { document: "core", section: "9.17.5.2.2" }
        }),
        (0, import_elements.FieldElement)({ name: "Key", id: 3, access: "F", conformance: "D" }),
        (0, import_elements.FieldElement)({ name: "FabricIndex", id: 254, type: "FabricIndex" })
      ]
    }),
    (0, import_elements.DatatypeElement)({
      name: "OperatingModeEnum",
      type: "enum8",
      xref: { document: "core", section: "9.17.5.3" },
      children: [
        (0, import_elements.FieldElement)({
          name: "Sit",
          id: 0,
          conformance: "M",
          description: "ICD is operating as a Short Idle Time ICD."
        }),
        (0, import_elements.FieldElement)({ name: "Lit", id: 1, conformance: "M", description: "ICD is operating as a Long Idle Time ICD." })
      ]
    })
  ]
});
import_MatterDefinition.MatterDefinition.children.push(IcdManagement);
//# sourceMappingURL=IcdManagement.js.map
