import { XMLParser } from 'fast-xml-parser';
import { defaultXmlParserOptions } from '../internal/xml-store.js';
export function getPomProperties(pomContent) {
    return new XMLParser(defaultXmlParserOptions).parse(pomContent).project.properties;
}
export function parseMavenPom(fileContent) {
    return new XMLParser(defaultXmlParserOptions).parse(fileContent);
}
export function getPomVersionProperties(pomContent) {
    if (typeof pomContent === 'string') {
        pomContent = parseMavenPom(pomContent);
    }
    const { properties, version, artifactId } = pomContent.project;
    const versions = Object.fromEntries(Object.entries(properties ?? [])
        .filter(([property]) => property.endsWith('.version'))
        .map(([property, value]) => [property.slice(0, -8), value]));
    if (version && artifactId) {
        versions[artifactId] = version;
    }
    return versions;
}
