import OpticReadFailureSchemaError from "./OpticReadFailureSchemaError.js";
export default class OpticRecoveryHint {
    operation;
    constructor(operation) {
        if (!isOpticRecoveryOperation(operation)) {
            throw new OpticReadFailureSchemaError('unsupported optic recovery operation', { operation });
        }
        this.operation = operation;
        Object.freeze(this);
    }
    static createIndexedBasis() {
        return new OpticRecoveryHint('plumber.checkpoint.createIndexedBasis');
    }
    static prewarmIndex() {
        return new OpticRecoveryHint('plumber.checkpoint.prewarmIndex');
    }
    static retryWithExtendedBudget() {
        return new OpticRecoveryHint('plumber.optic.retryWithExtendedBudget');
    }
    toContextValue() {
        return Object.freeze({
            operation: this.operation,
            retryMaySucceedAfterRecovery: true,
            requiresCallerConsent: true,
        });
    }
}
function isOpticRecoveryOperation(value) {
    return value === 'plumber.checkpoint.createIndexedBasis'
        || value === 'plumber.checkpoint.prewarmIndex'
        || value === 'plumber.optic.retryWithExtendedBudget';
}
