import { g as resolveStateDir } from "./paths-mmi2xb99.js";
import "./subsystem-D4e4nOE7.js";
import "./utils-DLd4fFd2.js";
import "./boolean-Djq1Hgv8.js";
import "./env-Bdq5Y-tD.js";
import "./config-C9wUwpYY.js";
import "./agent-scope-BcV171ci.js";
import "./exec-B_ziy0Fn.js";
import "./edwinpai-root-BaNzp4sP.js";
import "./model-selection-ChysOie6.js";
import "./github-copilot-token-D-EydSr2.js";
import "./command-format-XQlUKdf6.js";
import "./manifest-registry-DThGPzHr.js";
import fs from "node:fs";
import path from "node:path";

//#region ../../src/infra/authorized-users.ts
function resolveAuthorizedUsersPath(stateDir) {
	const resolvedStateDir = stateDir ?? resolveStateDir(process.env);
	return path.join(resolvedStateDir, "authorized_users.json");
}
function loadAuthorizedKeysFromUsers(stateDir) {
	const usersPath = resolveAuthorizedUsersPath(stateDir);
	if (!fs.existsSync(usersPath)) return [];
	try {
		const raw = fs.readFileSync(usersPath, "utf-8");
		const users = JSON.parse(raw)?.users ?? {};
		const keys = /* @__PURE__ */ new Set();
		for (const [key, value] of Object.entries(users)) {
			if (typeof key === "string" && key.length > 0) keys.add(key);
			if (value?.pubkey && typeof value.pubkey === "string") keys.add(value.pubkey);
		}
		return Array.from(keys);
	} catch {
		return [];
	}
}

//#endregion
export { loadAuthorizedKeysFromUsers };