import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
import {
  DataSpaceSelector,
  MasterDetailTable,
  PanelContainer,
  useDevtoolsState
} from "./chunk-DWYIZZUB.mjs";

// src/panels/echo/MembersPanel/MembersPanel.tsx
import React, { useMemo } from "react";
import { Format } from "@dxos/echo/internal";
import { SpaceMember, useMembers } from "@dxos/react-client/echo";
import { Toolbar } from "@dxos/react-ui";
var MembersPanel = (props) => {
  const state = useDevtoolsState();
  const space = props.space ?? state.space;
  const members = useMembers(space?.key);
  const properties = useMemo(() => [
    {
      name: "identityKey",
      format: Format.TypeFormat.DID
    },
    {
      name: "displayName",
      format: Format.TypeFormat.String
    },
    {
      name: "status",
      format: Format.TypeFormat.SingleSelect,
      config: {
        options: [
          {
            id: "online",
            title: "online",
            color: "green"
          },
          {
            id: "offline",
            title: "offline",
            color: "neutral"
          },
          {
            id: "unknown",
            title: "unknown",
            color: "red"
          }
        ]
      }
    }
  ], []);
  const data = useMemo(() => {
    return members.map((member) => {
      let status = "unknown";
      switch (member.presence) {
        case SpaceMember.PresenceState.ONLINE:
          status = "online";
          break;
        case SpaceMember.PresenceState.OFFLINE:
          status = "offline";
          break;
      }
      return {
        id: member.identity.identityKey.toString(),
        identityKey: member.identity.identityKey,
        displayName: member.identity.profile?.displayName,
        status,
        _original: member
      };
    });
  }, [
    members
  ]);
  return /* @__PURE__ */ React.createElement(PanelContainer, {
    toolbar: props.space ? void 0 : /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(DataSpaceSelector, null))
  }, /* @__PURE__ */ React.createElement(MasterDetailTable, {
    properties,
    data,
    detailsTransform: (item) => item._original,
    detailsPosition: "bottom"
  }));
};

// src/panels/echo/MembersPanel/index.ts
var MembersPanel_default = MembersPanel;
export {
  MembersPanel_default as default
};
//# sourceMappingURL=MembersPanel-MCIZEFNM.mjs.map
