/**
 * MSW handlers for trace list and detail endpoints.
 * @module mocks/handlers/traces
 */
import { http, HttpResponse } from "msw";
import tracesData from "../fixtures/traces.json";
import traceDetailData from "../fixtures/trace-detail.json";
import { captureRequest } from "../request-log.js";

export const tracesHandlers = [
  http.get("/api/logs/:logId/traces/:traceId", ({ params }) => {
    captureRequest("GET", `/api/logs/${params.logId}/traces/${params.traceId}`);
    return HttpResponse.json(traceDetailData);
  }),

  http.get("/api/filters/:filterId/traces/:traceId", ({ params }) => {
    captureRequest("GET", `/api/filters/${params.filterId}/traces/${params.traceId}`);
    return HttpResponse.json(traceDetailData);
  }),

  http.get("/api/logs/:id/traces", ({ params }) => {
    captureRequest("GET", `/api/logs/${params.id}/traces`);
    return HttpResponse.json(tracesData);
  }),

  http.get("/api/filters/:id/traces", ({ params }) => {
    captureRequest("GET", `/api/filters/${params.id}/traces`);
    return HttpResponse.json(tracesData);
  }),

  http.get("/api/temp-filters/:id/traces", ({ params }) => {
    captureRequest("GET", `/api/temp-filters/${params.id}/traces`);
    return HttpResponse.json(tracesData);
  }),
];
