import MemoryBudgetError from "../errors/MemoryBudgetError.js";
export const MEMORY_BUDGET_UNIT_BYTE = 'byte';
export const MEMORY_BUDGET_UNIT_ENTRY = 'entry';
export const MEMORY_BUDGET_UNIT_PATCH = 'patch';
export const MEMORY_BUDGET_UNIT_FACT = 'fact';
export const MEMORY_BUDGET_UNIT_RESULT = 'result';
export const MEMORY_BUDGET_UNITS = Object.freeze([
    MEMORY_BUDGET_UNIT_BYTE,
    MEMORY_BUDGET_UNIT_ENTRY,
    MEMORY_BUDGET_UNIT_PATCH,
    MEMORY_BUDGET_UNIT_FACT,
    MEMORY_BUDGET_UNIT_RESULT,
]);
export function requireMemoryBudgetUnit(value) {
    const unit = MEMORY_BUDGET_UNITS.find((candidate) => candidate === value);
    if (unit !== undefined) {
        return unit;
    }
    throw new MemoryBudgetError('Memory budget unit is not supported', {
        code: 'E_MEMORY_BUDGET_INVALID',
        context: { field: 'unit', value },
    });
}
