import MemoryBudgetError from "../errors/MemoryBudgetError.js";
export const MEMORY_CAPABILITY_SAFE = 'safe';
export const MEMORY_CAPABILITY_TRANSITIONAL = 'transitional';
export const MEMORY_CAPABILITY_DIAGNOSTIC = 'diagnostic';
export const MEMORY_CAPABILITY_LEGACY = 'legacy';
const MEMORY_CAPABILITY_POSTURES = Object.freeze([
    MEMORY_CAPABILITY_SAFE,
    MEMORY_CAPABILITY_TRANSITIONAL,
    MEMORY_CAPABILITY_DIAGNOSTIC,
    MEMORY_CAPABILITY_LEGACY,
]);
/** Runtime-backed bounded-memory capability posture token. */
export default class MemoryCapabilityPosture {
    value;
    constructor(value) {
        this.value = requireMemoryCapabilityPosture(value);
        Object.freeze(this);
    }
    isSafe() {
        return this.value === MEMORY_CAPABILITY_SAFE;
    }
    isTransitional() {
        return this.value === MEMORY_CAPABILITY_TRANSITIONAL;
    }
    isDiagnostic() {
        return this.value === MEMORY_CAPABILITY_DIAGNOSTIC;
    }
    isLegacy() {
        return this.value === MEMORY_CAPABILITY_LEGACY;
    }
    toString() {
        return this.value;
    }
}
function requireMemoryCapabilityPosture(value) {
    const posture = MEMORY_CAPABILITY_POSTURES.find((candidate) => candidate === value);
    if (posture !== undefined) {
        return posture;
    }
    throw new MemoryBudgetError('Memory capability posture is not supported', {
        code: 'E_MEMORY_CAPABILITY_INVALID',
        context: { field: 'posture', value },
    });
}
