"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require$$0 = require("react/jsx-runtime");
const designSystem = require("@choiceform/design-system");
const iconsReact = require("@choiceform/icons-react");
const React = require("react");
const index = require("../../../../i18n/index.cjs");
const index$1 = require("../../../common/code-block/index.cjs");
const MessageToolCallTv = designSystem.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 = React.memo(function MessageToolCall2(props) {
  const { children, className, toolCall } = props;
  if (!toolCall) {
    return null;
  }
  const getStatusIcon = (status) => {
    switch (status) {
      case "completed":
        return /* @__PURE__ */ require$$0.jsx(iconsReact.CircleCirclehecirclek, {});
      case "failed":
        return /* @__PURE__ */ require$$0.jsx(iconsReact.CircleRemove, {});
      case "executing":
        return /* @__PURE__ */ require$$0.jsx(iconsReact.InteractionTriggerAfterDelay, {});
      default:
        return /* @__PURE__ */ require$$0.jsx(iconsReact.ToolbarSettings, {});
    }
  };
  const toolCallToolName = index.t("response", "tool-call-tool-name");
  const toolCallArguments = index.t("response", "tool-call-arguments");
  const toolCallResult = index.t("response", "tool-call-result");
  const tv = MessageToolCallTv({ status: toolCall.status });
  return /* @__PURE__ */ require$$0.jsxs("div", { className: tv.root(), children: [
    /* @__PURE__ */ require$$0.jsxs("div", { className: tv.header(), children: [
      /* @__PURE__ */ require$$0.jsx("div", { className: tv.icon(), children: getStatusIcon(toolCall.status) }),
      /* @__PURE__ */ require$$0.jsxs("span", { className: tv.toolName(), children: [
        toolCallToolName,
        ": ",
        toolCall.toolName
      ] }),
      /* @__PURE__ */ require$$0.jsx(designSystem.Badge, { children: toolCall.status })
    ] }),
    children && /* @__PURE__ */ require$$0.jsx("div", { className: tv.content(), children }),
    toolCall.arguments && /* @__PURE__ */ require$$0.jsxs("div", { className: tv.block(), children: [
      /* @__PURE__ */ require$$0.jsx("div", { className: tv.blockTitle(), children: toolCallArguments }),
      /* @__PURE__ */ require$$0.jsxs(index$1.CodeBlock, { language: "json", children: [
        /* @__PURE__ */ require$$0.jsx(index$1.CodeBlock.BlockCode, { code: JSON.stringify(toolCall.arguments, null, 2) }),
        /* @__PURE__ */ require$$0.jsx(index$1.CodeBlock.Footer, {})
      ] })
    ] }),
    toolCall.result !== void 0 && /* @__PURE__ */ require$$0.jsxs("div", { className: tv.block(), children: [
      /* @__PURE__ */ require$$0.jsx("div", { className: tv.blockTitle(), children: toolCallResult }),
      /* @__PURE__ */ require$$0.jsxs(index$1.CodeBlock, { language: "json", children: [
        /* @__PURE__ */ require$$0.jsx(
          index$1.CodeBlock.BlockCode,
          {
            code: typeof toolCall.result === "string" ? toolCall.result : JSON.stringify(toolCall.result, null, 2)
          }
        ),
        /* @__PURE__ */ require$$0.jsx(index$1.CodeBlock.Footer, {})
      ] })
    ] })
  ] });
});
exports.MessageToolCall = MessageToolCall;
//# sourceMappingURL=message-tool-call.cjs.map
