import { o as _ } from "./rolldown-runtime.js";
import { i as k, t as w } from "./vendor/react.js";
import { t as h } from "./createLucideIcon.js";
import { t as A } from "./check.js";
import { t as T } from "./chevron-down.js";
import { t as O } from "./chevron-right.js";
import { t as j } from "./circle-alert.js";
import { t as z } from "./clock.js";
import { t as S } from "./proxy.js";
import { t as V } from "./AnimatePresence.js";
import { t as v } from "./dist.js";
import { t as o } from "./utils.js";
import { i as E, n as q, o as B, r as D, t as H } from "./_shared.js";
import { t as R } from "./use-controllable-state.js";
import { t as x } from "./AICodeBlock.js";
var W = [["path", {
  d: "m16 18 6-6-6-6",
  key: "eg8j8"
}], ["path", {
  d: "m8 6-6 6 6 6",
  key: "ppft3o"
}]], g = h("code", W), F = [["path", {
  d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",
  key: "1ngwbx"
}]], L = h("wrench", F), e = w(), M = v("overflow-hidden rounded-xl border transition-colors", {
  variants: { status: {
    pending: "border-border bg-muted",
    running: "border-primary bg-primary/10",
    success: "border-success/50 bg-success/10",
    error: "border-destructive/50 bg-destructive/10"
  } },
  defaultVariants: { status: "pending" }
}), J = v("size-4", {
  variants: { status: {
    pending: "text-muted-foreground",
    running: "text-primary animate-spin motion-reduce:animate-none",
    success: "text-success",
    error: "text-destructive"
  } },
  defaultVariants: { status: "pending" }
});
function N({ status: t, className: s }) {
  const a = o(J({ status: t }), s);
  switch (t) {
    case "running":
      return /* @__PURE__ */ (0, e.jsx)(z, { className: a });
    case "success":
      return /* @__PURE__ */ (0, e.jsx)(A, { className: o(a, "delight-check-bounce motion-reduce:!animate-none") });
    case "error":
      return /* @__PURE__ */ (0, e.jsx)(j, { className: o(a, "delight-shake motion-reduce:!animate-none") });
    default:
      return /* @__PURE__ */ (0, e.jsx)(L, { className: a });
  }
}
N.displayName = "StatusIcon";
function b({ toolName: t, status: s, isOpen: a, onToggle: r, className: n }) {
  return /* @__PURE__ */ (0, e.jsxs)("button", {
    type: "button",
    onClick: r,
    "aria-expanded": a,
    className: o("flex items-center justify-between w-full px-4 py-3 transition-colors hover:bg-foreground/5 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring", n),
    children: [/* @__PURE__ */ (0, e.jsxs)("div", {
      className: "flex items-center gap-3",
      children: [/* @__PURE__ */ (0, e.jsx)(N, {
        status: s,
        "aria-hidden": "true"
      }), /* @__PURE__ */ (0, e.jsxs)("div", {
        className: "flex flex-col items-start",
        children: [/* @__PURE__ */ (0, e.jsx)("span", {
          className: "text-sm font-medium text-foreground",
          children: t
        }), /* @__PURE__ */ (0, e.jsx)("span", {
          className: "text-xs text-quaternary-foreground",
          children: {
            pending: "Pending",
            running: "Running...",
            success: "Completed",
            error: "Failed"
          }[s]
        })]
      })]
    }), a ? /* @__PURE__ */ (0, e.jsx)(T, {
      className: "size-4 text-muted-foreground",
      "aria-hidden": "true"
    }) : /* @__PURE__ */ (0, e.jsx)(O, {
      className: "size-4 text-muted-foreground rtl:rotate-180",
      "aria-hidden": "true"
    })]
  });
}
b.displayName = "AIToolCallHeader";
function d({ title: t, icon: s, children: a, className: r }) {
  return /* @__PURE__ */ (0, e.jsxs)("div", {
    className: o("space-y-2", r),
    children: [/* @__PURE__ */ (0, e.jsxs)("div", {
      className: "flex items-center gap-2 text-xs font-medium text-quaternary-foreground uppercase tracking-wide",
      children: [s, t]
    }), a]
  });
}
d.displayName = "ToolCallSection";
function m({ toolPart: t, defaultOpen: s = !1, open: a, onOpenChange: r, className: n }) {
  const [i, y] = R({
    value: a,
    defaultValue: s,
    onChange: r
  }), p = t.status || "pending", I = () => {
    y(!i);
  }, f = (l) => typeof l == "string" ? l : JSON.stringify(l, null, 2);
  return /* @__PURE__ */ (0, e.jsxs)("div", {
    "data-slot": "ai-tool-call",
    className: o(M({ status: p }), n),
    children: [/* @__PURE__ */ (0, e.jsx)(b, {
      toolName: t.toolName,
      status: p,
      isOpen: i,
      onToggle: I
    }), /* @__PURE__ */ (0, e.jsx)(V, { children: i && /* @__PURE__ */ (0, e.jsx)(S.div, {
      initial: {
        height: 0,
        opacity: 0
      },
      animate: {
        height: "auto",
        opacity: 1
      },
      exit: {
        height: 0,
        opacity: 0
      },
      transition: { duration: 0.2 },
      className: "overflow-hidden",
      children: /* @__PURE__ */ (0, e.jsxs)("div", {
        className: "px-4 pb-4 space-y-4",
        children: [
          /* @__PURE__ */ (0, e.jsxs)("div", {
            className: "text-xs text-muted-foreground font-mono",
            children: ["ID: ", t.toolCallId]
          }),
          t.args && Object.keys(t.args).length > 0 && /* @__PURE__ */ (0, e.jsx)(d, {
            title: "Input",
            icon: /* @__PURE__ */ (0, e.jsx)(g, { className: "size-3" }),
            children: /* @__PURE__ */ (0, e.jsx)(x, {
              code: f(t.args),
              language: "json",
              showHeader: !1,
              showCopyButton: !0,
              size: "sm"
            })
          }),
          t.result !== void 0 && /* @__PURE__ */ (0, e.jsx)(d, {
            title: "Output",
            icon: /* @__PURE__ */ (0, e.jsx)(g, { className: "size-3" }),
            children: /* @__PURE__ */ (0, e.jsx)(x, {
              code: f(t.result),
              language: "json",
              showHeader: !1,
              showCopyButton: !0,
              size: "sm"
            })
          }),
          t.error && /* @__PURE__ */ (0, e.jsx)("div", {
            className: "p-3 rounded-lg bg-destructive/20 border border-destructive/50",
            children: /* @__PURE__ */ (0, e.jsxs)("div", {
              className: "flex items-start gap-2",
              children: [/* @__PURE__ */ (0, e.jsx)(j, { className: "size-4 text-destructive mt-0.5 shrink-0" }), /* @__PURE__ */ (0, e.jsx)("p", {
                className: "text-sm text-destructive",
                children: t.error
              })]
            })
          })
        ]
      })
    }) })]
  });
}
m.displayName = "AIToolCall";
function K({ toolCalls: t, defaultAllOpen: s = !1, className: a }) {
  return /* @__PURE__ */ (0, e.jsx)("div", {
    "data-slot": "ai-tool-call-list",
    className: o("space-y-2", a),
    children: t.map((r) => /* @__PURE__ */ (0, e.jsx)(m, {
      toolPart: r,
      defaultOpen: s
    }, r.toolCallId))
  });
}
K.displayName = "AIToolCallList";
var c = /* @__PURE__ */ _(k(), 1), u = {
  toolPart: "json",
  defaultOpen: "boolean",
  open: "boolean"
}, C = class extends H {
  get propDefs() {
    return u;
  }
  static get observedAttributes() {
    return Object.keys(u).map(q);
  }
  _renderReact() {
    const t = this._readAllProps(), s = t.toolPart;
    return !s || typeof s != "object" || !s.toolCallId ? c.createElement(c.Fragment) : c.createElement(m, {
      toolPart: s,
      defaultOpen: t.defaultOpen ?? !1,
      open: t.open,
      onOpenChange: (a) => D(this, "open-change", a)
    });
  }
};
E(C, u);
B("hf-ai-tool-call", C);
export {
  C as AIToolCallWC,
  C as default
};

//# sourceMappingURL=hf-ai-tool-call.js.map