import { getMatches } from "../file-matching.js";
import { defineSource } from "../source.js";
import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import { parsePyproject } from "read-pyproject";
//#region src/lib/sources/python-pyproject-toml.ts
/**
* Parse pyproject.toml content and return structured metadata.
*/
function parse(content) {
	return parsePyproject(content, {
		camelCase: true,
		unknownKeyPolicy: "strip"
	});
}
const pythonPyprojectTomlSource = defineSource({
	async discover(context) {
		return getMatches(context.options, ["pyproject.toml"]);
	},
	key: "pythonPyprojectToml",
	async parse(input, context) {
		return {
			data: parse(await readFile(resolve(context.options.path, input), "utf8")),
			source: input
		};
	},
	phase: 1
});
//#endregion
export { pythonPyprojectTomlSource };
