import WarpError from "../errors/WarpError.js";
const ADMITTED = 'admitted';
const STAGED = 'staged';
const PLURAL = 'plural';
const CONFLICT = 'conflict';
const OBSTRUCTION = 'obstruction';
export const GIT_WARP_WITNESSED_SUFFIX_ADMISSION_OUTCOMES = Object.freeze([
    ADMITTED,
    STAGED,
    PLURAL,
    CONFLICT,
    OBSTRUCTION,
]);
/** Runtime-backed admission result for a witnessed suffix shell import. */
export default class GitWarpWitnessedSuffixAdmissionOutcome {
    value;
    constructor(value) {
        this.value = requireGitWarpWitnessedSuffixAdmissionOutcomeValue(value);
        Object.freeze(this);
    }
    static admitted() {
        return new GitWarpWitnessedSuffixAdmissionOutcome(ADMITTED);
    }
    static staged() {
        return new GitWarpWitnessedSuffixAdmissionOutcome(STAGED);
    }
    static plural() {
        return new GitWarpWitnessedSuffixAdmissionOutcome(PLURAL);
    }
    static conflict() {
        return new GitWarpWitnessedSuffixAdmissionOutcome(CONFLICT);
    }
    static obstruction() {
        return new GitWarpWitnessedSuffixAdmissionOutcome(OBSTRUCTION);
    }
    isAdmitted() {
        return this.value === ADMITTED;
    }
    isStaged() {
        return this.value === STAGED;
    }
    requiresResolution() {
        return this.value === PLURAL || this.value === CONFLICT || this.value === OBSTRUCTION;
    }
    equals(other) {
        return this.value === other.value;
    }
    toString() {
        return this.value;
    }
}
export function requireGitWarpWitnessedSuffixAdmissionOutcomeValue(value) {
    if (typeof value !== 'string') {
        throw new WarpError(`GitWarp witnessed suffix admission outcome must be one of: ${GIT_WARP_WITNESSED_SUFFIX_ADMISSION_OUTCOMES.join(', ')}`, 'E_VALIDATION');
    }
    const valid = GIT_WARP_WITNESSED_SUFFIX_ADMISSION_OUTCOMES.find((candidate) => candidate === value);
    if (valid === undefined) {
        throw new WarpError(`GitWarp witnessed suffix admission outcome must be one of: ${GIT_WARP_WITNESSED_SUFFIX_ADMISSION_OUTCOMES.join(', ')}`, 'E_VALIDATION');
    }
    return valid;
}
