import DataType from "../../../../parser/simple/DataType.js";
import { ReactiveBinaryExpression } from "../ReactiveBinaryExpression.js";

export class ReactiveLessThanOrEqual extends ReactiveBinaryExpression {
    /**
     *
     * @param {number} left
     * @param {number} right
     * @returns {boolean}
     */
    transform(left, right) {
        return left <= right;
    }

    /**
     *
     * @return {ReactiveLessThanOrEqual}
     */
    clone() {
        const r = new ReactiveLessThanOrEqual();

        r.copy(this);

        return r;
    }

    equals(other) {
        return (other.isReactiveLessThanOrEqual === true) && super.equals(other);
    }

    toCode() {
        return `( ${this.left.toCode()} <= ${this.right.toCode()} )`
    }

    /**
     *
     * @param {ReactiveExpression} left
     * @param {ReactiveExpression} right
     * @returns {ReactiveLessThanOrEqual}
     */
    static from(left, right) {
        const r = new ReactiveLessThanOrEqual();

        r.connect(left, right);

        return r;
    }

}

/**
 * @readonly
 * @type {DataType|string}
 */
ReactiveLessThanOrEqual.prototype.dataType = DataType.Boolean;

/**
 * @readonly
 * @type {boolean}
 */
ReactiveLessThanOrEqual.prototype.isComparativeExpression = true;

/**
 * @readonly
 * @type {boolean}
 */
ReactiveLessThanOrEqual.prototype.isReactiveLessThanOrEqual = true;
