// Adapted from jalcoui (MIT) — github.com/jal-co/ui
'use client';
import * as React from 'react';
import { useStylePresets } from '@djangocfg/ui-core/styles/palette';
import { cn } from '@djangocfg/ui-core/lib';
import type { NetworkRequest } from '../types';
import { EmptyState } from './EmptyState';
import { formatDuration } from './utils';
/**
* Categorical palette for timing phases (DNS, TCP, TLS, …). Stages are not
* statuses, so we route through `useStylePresets()` — 8 distinguishable hex
* colors that respect the active theme. Indices wrap modulo length.
*/
function useStagePalette(): string[] {
const presets = useStylePresets();
return React.useMemo(
() => [
presets.primary.fill,
presets.success.fill,
presets.warning.fill,
presets.danger.fill,
presets.info.fill,
presets.chart3.fill,
presets.chart4.fill,
presets.chart5.fill,
],
[presets],
);
}
export function TimingTab({ request }: { request: NetworkRequest }) {
const stagePalette = useStagePalette();
if (!request.timing || request.timing.length === 0) {
return