"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Types_1 = require("../../Types");
var SnapMatch_1 = require("./SnapMatch");
var StrongChildMatch_1 = require("./StrongChildMatch");
/**
 * Class representing child matches that are existing on the screen
 */
var ScreenBasedChildMatch = /** @class */ (function (_super) {
    tslib_1.__extends(ScreenBasedChildMatch, _super);
    function ScreenBasedChildMatch(child, parent, childId, parentId, childScreenPos, parentScreenPos) {
        var _this = _super.call(this, child, parent, childId, parentId) || this;
        _this.snapMode = Types_1.SnapMode.Strong;
        _this.isCoreMatch = ScreenBasedChildMatch.isCoreMatch(child, parent);
        _this.canIntersectSnappedTo = true;
        var diffX = childScreenPos.x - parentScreenPos.x;
        var diffY = childScreenPos.y - parentScreenPos.y;
        _this.screenDistance = Math.sqrt(diffX * diffX + diffY * diffY);
        return _this;
    }
    ScreenBasedChildMatch.prototype.isValid = function () {
        if (!this.isCoreMatch) {
            return false;
        }
        if (this.screenDistance > ScreenBasedChildMatch.maximumScreenDistance) {
            return false;
        }
        return true;
    };
    /**
     * Check if the two points are a core match
     * @param child the child point
     * @param parent the parent point
     */
    ScreenBasedChildMatch.isCoreMatch = function (child, parent) {
        return StrongChildMatch_1.StrongChildMatch.isCoreMatch(child, parent);
    };
    ScreenBasedChildMatch.maximumScreenDistance = 4;
    return ScreenBasedChildMatch;
}(SnapMatch_1.SnapMatch));
exports.ScreenBasedChildMatch = ScreenBasedChildMatch;
