import { createFeishuLarkSdkPinoLogger } from "./lark-sdk-logger.js";
import * as lark from "@larksuiteoapi/node-sdk";
//#region extensions/feishu/src/transport/client/client.ts
function createFeishuClient(account) {
	const l = lark;
	const sdkLogger = createFeishuLarkSdkPinoLogger(account.accountId);
	const apiBaseUrl = resolveFeishuBaseUrl(account.domain);
	const api = new l.Client({
		appId: account.appId,
		appSecret: account.appSecret,
		logger: sdkLogger,
		loggerLevel: l.LoggerLevel.info,
		...apiBaseUrl ? { baseURL: apiBaseUrl } : {}
	});
	const dispatcher = new l.EventDispatcher({
		verifyChallenge: false,
		logger: sdkLogger,
		loggerLevel: l.LoggerLevel.info
	});
	return {
		wsClient: new l.WSClient({
			appId: account.appId,
			appSecret: account.appSecret,
			eventDispatcher: dispatcher,
			logger: sdkLogger,
			loggerLevel: l.LoggerLevel.info,
			...apiBaseUrl ? { baseURL: apiBaseUrl } : {}
		}),
		dispatcher,
		api
	};
}
function resolveFeishuBaseUrl(domain) {
	if (domain === "feishu") return "https://open.feishu.cn";
	if (domain === "lark") return "https://open.larksuite.com";
	if (domain && domain.startsWith("https://")) return domain;
}
//#endregion
export { createFeishuClient };

//# sourceMappingURL=client.js.map