/**
* @license
* Copyright 2025-2026 Open Home Foundation
* SPDX-License-Identifier: Apache-2.0
*/
import { provide } from "@lit/context";
import "@material/web/button/outlined-button";
import "@material/web/divider/divider";
import "@material/web/iconbutton/icon-button";
import "@material/web/list/list";
import "@material/web/list/list-item";
import { consume } from "@lit/context";
import { MatterClient, MatterNode, isTestNodeId } from "@matter-server/ws-client";
import { mdiAlertCircleOutline, mdiChevronRight } from "@mdi/js";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property } from "lit/decorators.js";
import { guard } from "lit/directives/guard.js";
import "./cluster-commands/clusters/binding-commands.js";
import { clientContext, tickContext } from "../client/client-context.js";
import { clusters } from "../client/models/descriptions.js";
import "../components/ha-svg-icon";
import { getEndpointDeviceTypes } from "../util/endpoints.js";
import { formatHex, formatNodeAddress, getEffectiveFabricIndex } from "../util/format_hex.js";
import { notFoundStyles } from "../util/shared-styles.js";
import { bindingContext } from "./components/context.js";
declare global {
interface HTMLElementTagNameMap {
"matter-endpoint-view": MatterEndpointView;
}
}
function getUniqueClusters(node: MatterNode, endpoint: number) {
return Array.from(
new Set(
Object.keys(node.attributes)
.filter(key => key.startsWith(`${endpoint.toString()}/`))
.map(key => Number(key.split("/")[1])),
),
).sort((a, b) => {
return a - b;
});
}
export { getEndpointDeviceTypes };
@customElement("matter-endpoint-view")
class MatterEndpointView extends LitElement {
@consume({ context: clientContext })
public client!: MatterClient;
@consume({ context: tickContext, subscribe: true })
protected _tick = 0;
@property()
public node?: MatterNode;
@provide({ context: bindingContext })
@property()
public endpoint!: number;
override render() {
if (!this.node || this.endpoint == undefined) {
return html`
Node or endpoint not found