import { g as resolveStateDir } from "./paths-mmi2xb99.js";
import "./globals-D5pM_phR.js";
import "./utils-3Lue6wVm.js";
import "./subsystem-_lp1q2Mi.js";
import "./boolean-BhvV-zDA.js";
import "./env-aEqmsXHj.js";
import "./config-VoJVjSgT.js";
import "./agent-scope-u760_XKU.js";
import "./exec-NeyMP-Tl.js";
import "./edwinpai-root-fGTEvnPp.js";
import "./model-selection-CMHF17-l.js";
import "./github-copilot-token-Bu-iLSUh.js";
import "./command-format-D8drL8c2.js";
import "./manifest-registry-Cobl4jxs.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 };