{"version":3,"file":"HasCluster.cjs","sources":["../../../../src/methods/ESPRMMatterNode/HasCluster.ts"],"sourcesContent":["/*\n * SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD\n *\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ESPRMMatterNode } from \"../../ESPRMMatterNode\";\n\ntype MatterClusterSide = \"server\" | \"client\";\n\n/**\n * Augments the ESPRMMatterNode class with the `hasCluster` method.\n */\ndeclare module \"../../ESPRMMatterNode\" {\n  interface ESPRMMatterNode {\n    /**\n     * Checks whether any endpoint exposes the given cluster.\n     *\n     * By default, searches server clusters. Pass `\"client\"` as the second argument to\n     * search client clusters instead.\n     *\n     * @param clusterId - Cluster ID to look for.\n     * @param clusterType - `\"server\"` (default) or `\"client\"`.\n     * @returns `true` if at least one endpoint exposes the cluster.\n     *\n     * @example\n     * ```typescript\n     * import { ESPRMMatterNode } from \"@espressif/rainmaker-matter-sdk\";\n     *\n     * const node = ESPRMMatterNode.fromMatterMetaData(nodeDetails);\n     *\n     * const supportsOnOff = await node.hasCluster(6);\n     * // supportsOnOff === true\n     * ```\n     */\n    hasCluster(\n      clusterId: number,\n      clusterType?: MatterClusterSide\n    ): Promise<boolean>;\n\n    /**\n     * Checks whether a specific endpoint exposes the given cluster.\n     *\n     * @param endpointId - Endpoint ID to inspect (`0` is root, `1+` are application endpoints).\n     * @param clusterId - Cluster ID to look for.\n     * @param clusterType - `\"server\"` (default) or `\"client\"`.\n     * @returns `true` if the endpoint exposes the cluster.\n     *\n     * @example\n     * ```typescript\n     * import { ESPRMMatterNode } from \"@espressif/rainmaker-matter-sdk\";\n     *\n     * const node = ESPRMMatterNode.fromMatterMetaData(nodeDetails);\n     *\n     * const onOffOnEp1 = await node.hasCluster(1, 6);\n     * const onOffOnEp0 = await node.hasCluster(0, 6);\n     * // onOffOnEp1 === true, onOffOnEp0 === false\n     * ```\n     */\n    hasCluster(\n      endpointId: number,\n      clusterId: number,\n      clusterType?: MatterClusterSide\n    ): Promise<boolean>;\n  }\n}\n\nESPRMMatterNode.prototype.hasCluster = async function (\n  clusterIdOrEndpointId: number,\n  clusterIdOrClusterType?: number | MatterClusterSide,\n  clusterType: MatterClusterSide = \"server\"\n): Promise<boolean> {\n  if (typeof clusterIdOrClusterType === \"number\") {\n    const endpointId = clusterIdOrEndpointId;\n    const clusterId = clusterIdOrClusterType;\n    const side =\n      typeof arguments[2] === \"string\"\n        ? (arguments[2] as MatterClusterSide)\n        : clusterType;\n\n    const clusters =\n      side === \"server\"\n        ? await this.getServerClusters(endpointId)\n        : await this.getClientClusters(endpointId);\n\n    return clusters.includes(clusterId);\n  }\n\n  const clusterId = clusterIdOrEndpointId;\n  const side =\n    typeof clusterIdOrClusterType === \"string\"\n      ? clusterIdOrClusterType\n      : clusterType;\n\n  return this.endpoints.some((endpoint) => {\n    const clusters =\n      side === \"server\" ? endpoint.serverClusters : endpoint.clientClusters;\n    return clusters.includes(clusterId);\n  });\n};\n"],"names":["ESPRMMatterNode"],"mappings":";;;;AAAA;;;;AAIG;AA+DHA,+BAAe,CAAC,SAAS,CAAC,UAAU,GAAG,gBACrC,qBAA6B,EAC7B,sBAAmD,EACnD,WAAA,GAAiC,QAAQ,EAAA;AAEzC,IAAA,IAAI,OAAO,sBAAsB,KAAK,QAAQ,EAAE;QAC9C,MAAM,UAAU,GAAG,qBAAqB;QACxC,MAAM,SAAS,GAAG,sBAAsB;QACxC,MAAM,IAAI,GACR,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK;AACtB,cAAG,SAAS,CAAC,CAAC;cACZ,WAAW;AAEjB,QAAA,MAAM,QAAQ,GACZ,IAAI,KAAK;AACP,cAAE,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU;cACvC,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;AAE9C,QAAA,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;IACrC;IAEA,MAAM,SAAS,GAAG,qBAAqB;AACvC,IAAA,MAAM,IAAI,GACR,OAAO,sBAAsB,KAAK;AAChC,UAAE;UACA,WAAW;IAEjB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAI;AACtC,QAAA,MAAM,QAAQ,GACZ,IAAI,KAAK,QAAQ,GAAG,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc;AACvE,QAAA,OAAO,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;AACrC,IAAA,CAAC,CAAC;AACJ,CAAC;;"}