import WarpError from "../errors/WarpError.js";
const NATIVE_ORIGIN = 'native';
const TRANSLATED_ORIGIN = 'translated';
const FIXTURE_ORIGIN = 'fixture';
const SYNTHETIC_ORIGIN = 'synthetic';
const DESCRIPTOR_ORIGIN = 'descriptor';
export const CONTINUUM_EVIDENCE_ORIGINS = Object.freeze([
    NATIVE_ORIGIN,
    TRANSLATED_ORIGIN,
    FIXTURE_ORIGIN,
    SYNTHETIC_ORIGIN,
    DESCRIPTOR_ORIGIN,
]);
/** Origin coordinate for a Continuum evidence posture. */
export default class ContinuumEvidenceOrigin {
    value;
    constructor(value) {
        this.value = requireContinuumEvidenceOriginValue(value);
        Object.freeze(this);
    }
    static native() {
        return new ContinuumEvidenceOrigin(NATIVE_ORIGIN);
    }
    static translated() {
        return new ContinuumEvidenceOrigin(TRANSLATED_ORIGIN);
    }
    static fixture() {
        return new ContinuumEvidenceOrigin(FIXTURE_ORIGIN);
    }
    static synthetic() {
        return new ContinuumEvidenceOrigin(SYNTHETIC_ORIGIN);
    }
    static descriptor() {
        return new ContinuumEvidenceOrigin(DESCRIPTOR_ORIGIN);
    }
    isNative() {
        return this.value === NATIVE_ORIGIN;
    }
    isTranslated() {
        return this.value === TRANSLATED_ORIGIN;
    }
    isReplayOrigin() {
        return this.isNative() || this.isTranslated();
    }
    equals(other) {
        return this.value === other.value;
    }
    toString() {
        return this.value;
    }
}
export function requireContinuumEvidenceOriginValue(value) {
    if (typeof value !== 'string') {
        throw new WarpError(`Continuum evidence origin must be one of: ${CONTINUUM_EVIDENCE_ORIGINS.join(', ')}`, 'E_VALIDATION');
    }
    const valid = CONTINUUM_EVIDENCE_ORIGINS.find((candidate) => candidate === value);
    if (valid === undefined) {
        throw new WarpError(`Continuum evidence origin must be one of: ${CONTINUUM_EVIDENCE_ORIGINS.join(', ')}`, 'E_VALIDATION');
    }
    return valid;
}
