import { parseFeatureBuildPolicy } from './buildPolicy.js';
import { EMBEDDED_FEATURE_BUILD_POLICY_RAW, } from './embeddedFeaturePolicies.generated.js';
export function resolveEmbeddedFeaturePolicyEnv(value) {
    if (typeof value !== 'string')
        return null;
    const normalized = value.trim().toLowerCase();
    if (!normalized)
        return null;
    if (normalized === 'production' || normalized === 'prod' || normalized === 'stable')
        return 'production';
    if (normalized === 'preview')
        return 'preview';
    return null;
}
export function resolveEmbeddedFeatureBuildPolicy(envName) {
    if (!envName) {
        return { allow: [], deny: [] };
    }
    const raw = EMBEDDED_FEATURE_BUILD_POLICY_RAW[envName];
    return parseFeatureBuildPolicy(raw);
}
export function mergeFeatureBuildPolicies(base, override) {
    return {
        allow: [...new Set([...base.allow, ...override.allow])],
        deny: [...new Set([...base.deny, ...override.deny])],
    };
}
export function resolveFeatureBuildPolicyFromEnvOrEmbedded(input) {
    const embedded = resolveEmbeddedFeatureBuildPolicy(input.embeddedEnv);
    const override = parseFeatureBuildPolicy({
        allowRaw: input.allowRaw,
        denyRaw: input.denyRaw,
    });
    return mergeFeatureBuildPolicies(embedded, override);
}
//# sourceMappingURL=embeddedFeaturePolicy.js.map