import { vi } from "vitest";

const hoistedMocks = vi.hoisted(() => ({
  totpValidateMock: vi.fn(),
}));

export const totpValidateMock = hoistedMocks.totpValidateMock;

vi.mock("@capakraken/application", async (importOriginal) => {
  const actual = await importOriginal<typeof import("@capakraken/application")>();
  return {
    ...actual,
    getDashboardBudgetForecast: vi.fn().mockResolvedValue([]),
    getDashboardPeakTimes: vi.fn().mockResolvedValue([]),
    listAssignmentBookings: vi.fn().mockResolvedValue([]),
  };
});

vi.mock("otpauth", () => {
  class Secret {
    base32: string;

    constructor() {
      this.base32 = "MOCKSECRET";
    }

    static fromBase32(value: string) {
      return value;
    }
  }

  class TOTP {
    validate(args: { token: string; window: number }) {
      return totpValidateMock(args);
    }

    toString() {
      return "otpauth://mock";
    }
  }

  return { Secret, TOTP };
});

import { executeTool as executeAssistantTool } from "../router/assistant-tools.js";

export { createToolContext } from "./assistant-tools-user-self-service-test-helpers.js";

export const executeTool = executeAssistantTool;
