import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from "@stigmer/theme";
import { ChipSpinner, XIcon } from "./icons";
const CHIP_TYPE_LABELS = {
    agent: "Agent",
    workspace: "WS",
    mcp: "MCP",
    skill: "Skill",
    secret: "1-time",
    runner: "Runner",
};
export function ContextChip({ label, type, onRemove, disabled, status, detail, onClick, }) {
    const isTransient = status === "loading" || status === "submitting";
    const isWarning = status === "needsSetup";
    const labelContent = (_jsxs(_Fragment, { children: [isTransient && _jsx(ChipSpinner, {}), isWarning && (_jsx("span", { className: "inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-warning", "aria-hidden": "true" })), _jsx("span", { className: "text-[0.55rem] font-medium uppercase tracking-wider text-muted-foreground", children: CHIP_TYPE_LABELS[type] }), _jsx("span", { className: "max-w-[120px] truncate", title: label, children: label }), detail != null && (_jsx("span", { className: "shrink-0 text-[0.6rem] font-medium text-muted-foreground", children: detail }))] }));
    return (_jsxs("span", { className: cn("inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs text-foreground", isWarning
            ? "border border-warning/30 bg-warning/10"
            : "bg-muted-subtle", isTransient && "opacity-70"), children: [onClick ? (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, className: "inline-flex items-center gap-1 hover:opacity-80 disabled:pointer-events-none", "aria-label": `Configure ${label}`, children: labelContent })) : (_jsx("span", { className: "inline-flex items-center gap-1", children: labelContent })), _jsx("button", { type: "button", onClick: onRemove, disabled: disabled, className: "ml-0.5 shrink-0 text-muted-foreground hover:text-destructive disabled:pointer-events-none", "aria-label": `Remove ${label}`, children: _jsx(XIcon, {}) })] }));
}
//# sourceMappingURL=ContextChip.js.map