//
// Copyright 2021 DXOS.org
//
import React from 'react';
import { ConnectionState } from '@dxos/network-manager';
import { Button } from '@dxos/react-ui';
// TODO(burdon): Convert to table.
export const SwarmInfoView = ({ swarmInfo, onConnectionClick, onReturn }) => (React.createElement("div", null,
    React.createElement("div", null,
        "Topic: ",
        swarmInfo.topic.toHex()),
    React.createElement("div", null,
        "Label: ",
        swarmInfo.label ? swarmInfo.label : 'No label'),
    React.createElement("div", null,
        "Active: ",
        swarmInfo.isActive ? 'yes' : 'no'),
    React.createElement("div", null,
        "Active connection count: ",
        swarmInfo.connections?.filter((c) => c.state !== ConnectionState.CLOSED).length),
    React.createElement("div", null,
        "Total connection count: ",
        swarmInfo.connections?.length),
    React.createElement("hr", null),
    React.createElement("div", null, "Connections:"),
    React.createElement("div", { className: 'grow overflow-hidden' }, swarmInfo.connections?.map((connection) => (React.createElement("div", { key: connection.sessionId.toHex(), className: 'grow overflow-hidden' },
        React.createElement("div", { className: 'inline-flex is-[100]' }, connection.remotePeerId.toHex()),
        React.createElement("div", { className: 'inline-flex m-1' },
            React.createElement(Button, { onClick: () => onConnectionClick?.(connection.sessionId), title: 'Details' }, "Details")))))),
    onReturn && (React.createElement(Button, { onClick: onReturn, title: 'Back' }, "Back"))));
//# sourceMappingURL=SwarmInfo.js.map