"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpMore = void 0;
const AbstractPredicateOp_1 = require("./AbstractPredicateOp");
const json_pointer_1 = require("@jsonjoy.com/json-pointer");
const constants_1 = require("../constants");
/**
 * @category JSON Predicate
 */
class OpMore extends AbstractPredicateOp_1.AbstractPredicateOp {
    constructor(path, value) {
        super(path);
        this.value = value;
    }
    op() {
        return 'more';
    }
    code() {
        return constants_1.OPCODE.more;
    }
    test(doc) {
        const { val } = (0, json_pointer_1.find)(doc, this.path);
        if (typeof val !== 'number')
            return false;
        const test = val > this.value;
        return test;
    }
    toJson(parent) {
        const op = {
            op: 'more',
            path: (0, json_pointer_1.formatJsonPointer)(parent ? this.path.slice(parent.path.length) : this.path),
            value: this.value,
        };
        return op;
    }
    toCompact(parent, verbose) {
        const opcode = verbose ? 'more' : constants_1.OPCODE.more;
        return [opcode, parent ? this.path.slice(parent.path.length) : this.path, this.value];
    }
}
exports.OpMore = OpMore;
//# sourceMappingURL=OpMore.js.map