/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { WritableFabricScopedAttribute } from "../cluster/Cluster.js";
import { TlvArray } from "../tlv/TlvArray.js";
import { TlvOptionalField, TlvField, TlvObject } from "../tlv/TlvObject.js";
import { TlvNodeId } from "../datatype/NodeId.js";
import { TlvGroupId } from "../datatype/GroupId.js";
import { TlvEndpointNumber } from "../datatype/EndpointNumber.js";
import { TlvClusterId } from "../datatype/ClusterId.js";
import { TlvFabricIndex } from "../datatype/FabricIndex.js";
import { AccessLevel } from "#model";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var Binding;
((Binding2) => {
  Binding2.TlvTarget = TlvObject({
    /**
     * This field is the remote target node ID. If the Endpoint field is present, this field shall be present.
     *
     * @see {@link MatterSpecification.v142.Core} § 9.6.5.1.1
     */
    node: TlvOptionalField(1, TlvNodeId),
    /**
     * This field is the target group ID that represents remote endpoints. If the Endpoint field is present, this
     * field shall NOT be present.
     *
     * @see {@link MatterSpecification.v142.Core} § 9.6.5.1.2
     */
    group: TlvOptionalField(2, TlvGroupId),
    /**
     * This field is the remote endpoint that the local endpoint is bound to. If the Group field is present, this
     * field shall NOT be present.
     *
     * @see {@link MatterSpecification.v142.Core} § 9.6.5.1.3
     */
    endpoint: TlvOptionalField(3, TlvEndpointNumber),
    /**
     * This field is the cluster ID (client & server) on the local and target endpoint(s). If this field is present,
     * the client cluster shall also exist on this endpoint (with this Binding cluster). If this field is present,
     * the target shall be this cluster on the target endpoint(s).
     *
     * @see {@link MatterSpecification.v142.Core} § 9.6.5.1.4
     */
    cluster: TlvOptionalField(4, TlvClusterId),
    fabricIndex: TlvField(254, TlvFabricIndex)
  });
  Binding2.ClusterInstance = MutableCluster({
    id: 30,
    name: "Binding",
    revision: 1,
    attributes: {
      /**
       * Each entry shall represent a binding.
       *
       * @see {@link MatterSpecification.v142.Core} § 9.6.6.1
       */
      binding: WritableFabricScopedAttribute(
        0,
        TlvArray(Binding2.TlvTarget),
        { persistent: true, default: [], writeAcl: AccessLevel.Manage }
      )
    }
  });
  Binding2.Cluster = Binding2.ClusterInstance;
  Binding2.Complete = Binding2.Cluster;
})(Binding || (Binding = {}));
const BindingCluster = Binding.Cluster;
ClusterRegistry.register(Binding.Complete);
export {
  Binding,
  BindingCluster
};
//# sourceMappingURL=binding.js.map
