import WarpError from "../errors/WarpError.js";
const GENERATED_ARTIFACT_AUTHORITY = 'generated-artifact';
const GENERATED_FIXTURE_AUTHORITY = 'generated-fixture';
const LOCAL_MIRROR_AUTHORITY = 'local-mirror';
const HANDWRITTEN_MIRROR_AUTHORITY = 'handwritten-mirror';
export const CONTINUUM_ARTIFACT_AUTHORITIES = Object.freeze([
    GENERATED_ARTIFACT_AUTHORITY,
    GENERATED_FIXTURE_AUTHORITY,
    LOCAL_MIRROR_AUTHORITY,
    HANDWRITTEN_MIRROR_AUTHORITY,
]);
/** Runtime-backed authority posture for an ingested Continuum artifact. */
export default class ContinuumArtifactAuthority {
    value;
    constructor(value) {
        this.value = requireContinuumArtifactAuthority(value);
        Object.freeze(this);
    }
    /** Returns true for Wesley-generated artifacts and documented fixtures. */
    isGeneratedAuthority() {
        return (this.value === GENERATED_ARTIFACT_AUTHORITY ||
            this.value === GENERATED_FIXTURE_AUTHORITY);
    }
    /** Returns the stable authority string. */
    toString() {
        return this.value;
    }
}
/** Validates a raw authority posture string. */
export function requireContinuumArtifactAuthority(value) {
    if (typeof value !== 'string') {
        throw new WarpError(`Continuum artifact authority must be one of: ${CONTINUUM_ARTIFACT_AUTHORITIES.join(', ')}`, 'E_VALIDATION');
    }
    const valid = CONTINUUM_ARTIFACT_AUTHORITIES.find((candidate) => candidate === value);
    if (valid === undefined) {
        throw new WarpError(`Continuum artifact authority must be one of: ${CONTINUUM_ARTIFACT_AUTHORITIES.join(', ')}`, 'E_VALIDATION');
    }
    return valid;
}
