// src/json-store.ts
import path from "path";
import { readFile, readdir } from "fs/promises";
async function listJsonFiles(dir) {
  try {
    const entries = await readdir(dir, { withFileTypes: true });
    const out = [];
    for (const entry of entries) {
      const fullPath = path.join(dir, entry.name);
      if (entry.isDirectory()) {
        out.push(...await listJsonFiles(fullPath));
      } else if (entry.isFile() && entry.name.endsWith(".json")) {
        out.push(fullPath);
      }
    }
    return out.sort();
  } catch {
    return [];
  }
}
async function listNamedFiles(dir, fileName) {
  try {
    const entries = await readdir(dir, { withFileTypes: true });
    const out = [];
    for (const entry of entries) {
      const fullPath = path.join(dir, entry.name);
      if (entry.isDirectory()) {
        out.push(...await listNamedFiles(fullPath, fileName));
      } else if (entry.isFile() && entry.name === fileName) {
        out.push(fullPath);
      }
    }
    return out.sort();
  } catch {
    return [];
  }
}
async function readJsonFile(filePath) {
  return JSON.parse(await readFile(filePath, "utf8"));
}

export {
  listJsonFiles,
  listNamedFiles,
  readJsonFile
};
//# sourceMappingURL=chunk-LPSF4OQH.js.map