import { jsxs, jsx } from "react/jsx-runtime";
import { tcv, Badge } from "@choiceform/design-system";
import { ToolbarSettings, InteractionTriggerAfterDelay, CircleRemove, CircleCirclehecirclek } from "@choiceform/icons-react";
import { memo } from "react";
import { t } from "../../../../i18n/index.js";
import { CodeBlock } from "../../../common/code-block/index.js";
const MessageToolCallTv = tcv({
  slots: {
    root: "tool-call-message flex flex-col gap-2",
    header: "flex items-center gap-1",
    icon: "text-icon-secondary flex size-5 items-center justify-center",
    toolName: "font-strong",
    content: "text-secondary-foreground",
    block: "flex flex-col gap-1",
    blockTitle: "font-strong",
    blockContent: "overflow-x-auto rounded"
  },
  variants: {
    status: {
      completed: {
        root: ""
      },
      failed: {
        root: ""
      },
      executing: {
        root: ""
      },
      pending: {
        root: ""
      }
    }
  },
  defaultVariants: {
    status: "executing"
  }
});
const MessageToolCall = memo(function MessageToolCall2(props) {
  const { children, className, toolCall } = props;
  if (!toolCall) {
    return null;
  }
  const getStatusIcon = (status) => {
    switch (status) {
      case "completed":
        return /* @__PURE__ */ jsx(CircleCirclehecirclek, {});
      case "failed":
        return /* @__PURE__ */ jsx(CircleRemove, {});
      case "executing":
        return /* @__PURE__ */ jsx(InteractionTriggerAfterDelay, {});
      default:
        return /* @__PURE__ */ jsx(ToolbarSettings, {});
    }
  };
  const toolCallToolName = t("response", "tool-call-tool-name");
  const toolCallArguments = t("response", "tool-call-arguments");
  const toolCallResult = t("response", "tool-call-result");
  const tv = MessageToolCallTv({ status: toolCall.status });
  return /* @__PURE__ */ jsxs("div", { className: tv.root(), children: [
    /* @__PURE__ */ jsxs("div", { className: tv.header(), children: [
      /* @__PURE__ */ jsx("div", { className: tv.icon(), children: getStatusIcon(toolCall.status) }),
      /* @__PURE__ */ jsxs("span", { className: tv.toolName(), children: [
        toolCallToolName,
        ": ",
        toolCall.toolName
      ] }),
      /* @__PURE__ */ jsx(Badge, { children: toolCall.status })
    ] }),
    children && /* @__PURE__ */ jsx("div", { className: tv.content(), children }),
    toolCall.arguments && /* @__PURE__ */ jsxs("div", { className: tv.block(), children: [
      /* @__PURE__ */ jsx("div", { className: tv.blockTitle(), children: toolCallArguments }),
      /* @__PURE__ */ jsxs(CodeBlock, { language: "json", children: [
        /* @__PURE__ */ jsx(CodeBlock.BlockCode, { code: JSON.stringify(toolCall.arguments, null, 2) }),
        /* @__PURE__ */ jsx(CodeBlock.Footer, {})
      ] })
    ] }),
    toolCall.result !== void 0 && /* @__PURE__ */ jsxs("div", { className: tv.block(), children: [
      /* @__PURE__ */ jsx("div", { className: tv.blockTitle(), children: toolCallResult }),
      /* @__PURE__ */ jsxs(CodeBlock, { language: "json", children: [
        /* @__PURE__ */ jsx(
          CodeBlock.BlockCode,
          {
            code: typeof toolCall.result === "string" ? toolCall.result : JSON.stringify(toolCall.result, null, 2)
          }
        ),
        /* @__PURE__ */ jsx(CodeBlock.Footer, {})
      ] })
    ] })
  ] });
});
export {
  MessageToolCall
};
//# sourceMappingURL=message-tool-call.js.map
