//
// Copyright 2024 DXOS.org
//
import React from 'react';
import { Icon } from '@dxos/react-ui';
import { removeEmpty } from '../../../hooks';
import { Panel } from '../Panel';
import { Duration } from '../util';
// TODO(burdon): Sort by time? Filter inactive?
export const QueriesPanel = ({ queries, ...props }) => {
    if (!queries?.length) {
        return null;
    }
    return (React.createElement(Panel, { ...props, icon: 'ph--tree-view--regular', title: 'Queries', info: React.createElement("span", null, queries.length.toLocaleString()) },
        React.createElement("table", { className: 'table-fixed is-full text-xs font-mono' },
            React.createElement("tbody", null, queries.map((query, i) => (React.createElement("tr", { key: i },
                React.createElement("td", { className: 'p-1 is-[24px]' },
                    React.createElement(Icon, { icon: query.active ? 'ph--check--regular' : 'ph--x--regular', classNames: [!query.active && 'opacity-30'] })),
                React.createElement("td", { className: 'p-1 truncate', title: JSON.stringify(removeEmpty(query.filter), undefined, 2) }),
                React.createElement("td", { className: 'p-1 is-[80px] text-right' }, query.metrics.objectsReturned.toLocaleString()),
                React.createElement("td", { className: 'p-1 is-[80px] text-right' },
                    React.createElement(Duration, { duration: query.metrics.executionTime })))))))));
};
//# sourceMappingURL=QueriesPanel.js.map