// @bun
// src/components/integrations/organisms/KnowledgeSourceList.tsx
import { BookCopy, Plus, RefreshCcw } from "lucide-react";
import { jsx, jsxs } from "react/jsx-runtime";
function KnowledgeSourceList({
  sources,
  onRefresh,
  onDelete,
  onAdd
}) {
  return /* @__PURE__ */ jsxs("div", {
    className: "border-border bg-card space-y-4 rounded-2xl border p-4",
    children: [
      /* @__PURE__ */ jsxs("header", {
        className: "flex flex-wrap items-center justify-between gap-3",
        children: [
          /* @__PURE__ */ jsxs("div", {
            children: [
              /* @__PURE__ */ jsx("p", {
                className: "text-sm font-semibold tracking-wide uppercase",
                children: "Knowledge sources"
              }),
              /* @__PURE__ */ jsx("p", {
                className: "text-muted-foreground text-sm",
                children: "Manage documentation, specs, and repos powering Studio RAG flows."
              })
            ]
          }),
          /* @__PURE__ */ jsxs("button", {
            type: "button",
            className: "btn-primary inline-flex items-center gap-2",
            onClick: onAdd,
            children: [
              /* @__PURE__ */ jsx(Plus, {
                className: "h-4 w-4"
              }),
              "Add source"
            ]
          })
        ]
      }),
      /* @__PURE__ */ jsx("div", {
        className: "space-y-3",
        children: sources.length ? sources.map((source) => /* @__PURE__ */ jsxs("div", {
          className: "border-border bg-background flex flex-wrap items-center justify-between gap-3 rounded-xl border p-4",
          children: [
            /* @__PURE__ */ jsxs("div", {
              className: "flex items-center gap-3",
              children: [
                /* @__PURE__ */ jsx(BookCopy, {
                  className: "text-muted-foreground h-8 w-8"
                }),
                /* @__PURE__ */ jsxs("div", {
                  children: [
                    /* @__PURE__ */ jsx("p", {
                      className: "text-base font-semibold",
                      children: source.name
                    }),
                    /* @__PURE__ */ jsx("p", {
                      className: "text-muted-foreground text-sm",
                      children: source.type
                    }),
                    /* @__PURE__ */ jsx("p", {
                      className: "text-muted-foreground text-xs",
                      children: source.indexed ? `Indexed ${source.lastIndexed ? new Date(source.lastIndexed).toLocaleString() : ""}` : "Pending indexing"
                    })
                  ]
                })
              ]
            }),
            /* @__PURE__ */ jsxs("div", {
              className: "flex items-center gap-2",
              children: [
                /* @__PURE__ */ jsxs("button", {
                  type: "button",
                  className: "btn-ghost inline-flex items-center gap-1 text-sm",
                  onClick: () => onRefresh?.(source.id),
                  children: [
                    /* @__PURE__ */ jsx(RefreshCcw, {
                      className: "h-3.5 w-3.5"
                    }),
                    "Reindex"
                  ]
                }),
                /* @__PURE__ */ jsx("button", {
                  type: "button",
                  className: "btn-ghost text-destructive text-sm",
                  onClick: () => onDelete?.(source.id),
                  children: "Remove"
                })
              ]
            })
          ]
        }, source.id)) : /* @__PURE__ */ jsx("div", {
          className: "text-muted-foreground border-border rounded-xl border border-dashed p-6 text-center text-sm",
          children: "No knowledge sources added yet."
        })
      })
    ]
  });
}
export {
  KnowledgeSourceList
};
