import { isFeatureId } from './featureIds.js';
function splitIds(raw) {
    return raw
        .split(',')
        .map((value) => value.trim())
        .filter((value) => value.length > 0);
}
function normalizeIds(raw) {
    if (typeof raw !== 'string')
        return [];
    const out = [];
    const seen = new Set();
    for (const candidate of splitIds(raw)) {
        if (!isFeatureId(candidate))
            continue;
        if (seen.has(candidate))
            continue;
        seen.add(candidate);
        out.push(candidate);
    }
    return out;
}
export function parseFeatureBuildPolicy(input) {
    return {
        allow: normalizeIds(input.allowRaw),
        deny: normalizeIds(input.denyRaw),
    };
}
export function evaluateFeatureBuildPolicy(policy, featureId) {
    if (policy.deny.includes(featureId))
        return 'deny';
    if (policy.allow.includes(featureId))
        return 'allow';
    if (policy.allow.length > 0)
        return 'deny';
    return 'neutral';
}
//# sourceMappingURL=buildPolicy.js.map