import { it } from "vitest";
import { attachmentIdBelongsToThread, toSafeThreadAttachmentSegment } from "@t3tools/shared/attachmentIds";
import { compactDynamicToolOutput, htmlRenderFromToolItem } from "@t3tools/shared/toolOutput";
import { acpMcpToolCallOutput } from "../../wt/pr-17031/packages/provider-acp/src/server/adapter.ts";
import { extractMcpToolCallIdentity } from "../../wt/pr-17031/packages/provider-acp/src/server/runtimeModel.ts";
const N = 12_000;
const t = (name: string, f: () => unknown) => { const s = performance.now(); for (let i = 0; i < 10; i++) f(); console.log(name, ((performance.now() - s) / 10).toFixed(3), "ms"); };
it("bench", () => {
  const inputs = { dashes: "-_".repeat(N / 2) + "!", spaces: " ".repeat(N) + "x", uuidish: "a-" + "0".repeat(N), emdash: " — ".repeat(N / 3) };
  for (const [k, v] of Object.entries(inputs)) {
    t(`segment ${k}`, () => toSafeThreadAttachmentSegment(v));
    t(`belongs ${k}`, () => attachmentIdBelongsToThread(v, "a"));
    t(`belongs-id ${k}`, () => attachmentIdBelongsToThread("thread-1" + v, "thread-1"));
    t(`compact text-block ${k}`, () => compactDynamicToolOutput({ type: "text", text: "{" + v }));
    t(`compact content arr ${k}`, () => compactDynamicToolOutput(Array.from({ length: 32 }, () => ({ type: "content", content: { type: "text", text: v } }))));
    t(`execute ${k}`, () => htmlRenderFromToolItem({ toolName: "execute", output: JSON.stringify({ attachmentId: v + "-html", title: v, height: 1 }) }, v));
    t(`okay ${k}`, () => acpMcpToolCallOutput({ type: "MCP", output: { OkayOutput: v } }));
    t(`identity ${k}`, () => extractMcpToolCallIdentity({ data: { title: v + " — source file:" + v, rawInput: { toolName: v, tool_name: v, server_name: v }, meta: { "cognition.ai/inferenceToolName": "mcp__" + v } } } as never));
  }
});
