"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NullCutProviderData = exports.UnscaledFixedCutProviderData = exports.FixedCutProviderData = exports.CutProviderData = void 0;
const utils = __importStar(require("@applitools/utils"));
class CutProviderData {
    constructor(rectOrRegionOrTop, bottom, left, right) {
        if (utils.types.isNumber(rectOrRegionOrTop)) {
            this._rect = { top: rectOrRegionOrTop, bottom: bottom, left: left, right: right };
        }
        else if (utils.types.has(rectOrRegionOrTop, ['top', 'right', 'bottom', 'left'])) {
            this._rect = rectOrRegionOrTop;
        }
        else if (utils.types.has(rectOrRegionOrTop, ['width', 'height', 'x', 'y'])) {
            this._region = rectOrRegionOrTop;
        }
    }
    get top() {
        if (!this._rect)
            return undefined;
        return this._rect.top;
    }
    get right() {
        if (!this._rect)
            return undefined;
        return this._rect.right;
    }
    get bottom() {
        if (!this._rect)
            return undefined;
        return this._rect.bottom;
    }
    get left() {
        if (!this._rect)
            return undefined;
        return this._rect.left;
    }
    get width() {
        if (!this._region)
            return undefined;
        return this._region.width;
    }
    get height() {
        if (!this._region)
            return undefined;
        return this._region.height;
    }
    get x() {
        if (!this._region)
            return undefined;
        return this._region.x;
    }
    get y() {
        if (!this._region)
            return undefined;
        return this._region.y;
    }
    scale(scaleRatio) {
        if (this._rect) {
            return new CutProviderData({
                top: this._rect.top * scaleRatio,
                right: this._rect.right * scaleRatio,
                bottom: this._rect.bottom * scaleRatio,
                left: this._rect.left * scaleRatio,
            });
        }
        else if (this._region) {
            return new CutProviderData({
                width: this._region.width * scaleRatio,
                height: this._region.height * scaleRatio,
                x: this._region.x * scaleRatio,
                y: this._region.y * scaleRatio,
            });
        }
        else {
            return new CutProviderData({ top: 0, right: 0, bottom: 0, left: 0 });
        }
    }
    /** @internal */
    toObject() {
        var _a;
        return ((_a = this._region) !== null && _a !== void 0 ? _a : this._rect);
    }
    /** @internal */
    toJSON() {
        var _a;
        return utils.general.toJSON(((_a = this._region) !== null && _a !== void 0 ? _a : this._rect));
    }
    /** @internal */
    toString() {
        return utils.general.toString(this);
    }
}
exports.CutProviderData = CutProviderData;
class FixedCutProviderData extends CutProviderData {
}
exports.FixedCutProviderData = FixedCutProviderData;
/** @undocumented */
class UnscaledFixedCutProviderData extends CutProviderData {
    scale() {
        return new UnscaledFixedCutProviderData(this);
    }
}
exports.UnscaledFixedCutProviderData = UnscaledFixedCutProviderData;
class NullCutProviderData extends CutProviderData {
    constructor() {
        super({ top: 0, right: 0, bottom: 0, left: 0 });
    }
}
exports.NullCutProviderData = NullCutProviderData;
