import { n as vi, r as afterEach } from "../test.p_J6dB8a-Dyq-JxSD.js";
//#region src/plugin-sdk/provider-http-test-mocks.ts
const providerHttpMocks = vi.hoisted(() => ({
	resolveApiKeyForProviderMock: vi.fn(async () => ({ apiKey: "provider-key" })),
	postJsonRequestMock: vi.fn(),
	fetchWithTimeoutMock: vi.fn(),
	fetchWithTimeoutGuardedMock: vi.fn(),
	assertOkOrThrowHttpErrorMock: vi.fn(async (_response, _label) => {}),
	resolveProviderHttpRequestConfigMock: vi.fn((...args) => ({
		baseUrl: "",
		allowPrivateNetwork: false,
		headers: new Headers(),
		dispatcherPolicy: void 0
	}))
}));
providerHttpMocks.fetchWithTimeoutGuardedMock.mockImplementation(async (...args) => {
	const [url, init, timeoutMs, fetchFn] = args;
	return {
		response: await providerHttpMocks.fetchWithTimeoutMock(url, init ?? {}, timeoutMs ?? 6e4, fetchFn),
		finalUrl: url,
		release: async () => {}
	};
});
vi.mock("kaijibot/plugin-sdk/provider-auth-runtime", () => ({ resolveApiKeyForProvider: providerHttpMocks.resolveApiKeyForProviderMock }));
vi.mock("kaijibot/plugin-sdk/provider-http", () => ({
	assertOkOrThrowHttpError: providerHttpMocks.assertOkOrThrowHttpErrorMock,
	fetchWithTimeout: providerHttpMocks.fetchWithTimeoutMock,
	fetchWithTimeoutGuarded: providerHttpMocks.fetchWithTimeoutGuardedMock,
	normalizeBaseUrl: (url) => url,
	postJsonRequest: providerHttpMocks.postJsonRequestMock,
	resolveProviderHttpRequestConfig: providerHttpMocks.resolveProviderHttpRequestConfigMock
}));
function getProviderHttpMocks() {
	return providerHttpMocks;
}
function installProviderHttpMockCleanup() {
	afterEach(() => {
		providerHttpMocks.resolveApiKeyForProviderMock.mockClear();
		providerHttpMocks.postJsonRequestMock.mockReset();
		providerHttpMocks.fetchWithTimeoutMock.mockReset();
		providerHttpMocks.fetchWithTimeoutGuardedMock.mockClear();
		providerHttpMocks.assertOkOrThrowHttpErrorMock.mockClear();
		providerHttpMocks.resolveProviderHttpRequestConfigMock.mockClear();
	});
}
//#endregion
export { getProviderHttpMocks, installProviderHttpMockCleanup };
