import { __extends } from "tslib";
import { SnapMode } from "../../Types";
import { SnapMatch } from "./SnapMatch";
import { CoreUtils } from "@intelligentgraphics/ig.gfx.core";
/**
 * Class representing matching of child - parent relations
 */
var StrongChildMatch = /** @class */ (function (_super) {
    __extends(StrongChildMatch, _super);
    /** The constructor */
    function StrongChildMatch(child, parent, childId, parentId) {
        var _this = _super.call(this, child, parent, childId, parentId) || this;
        _this.snapMode = SnapMode.Strong;
        _this.isCoreMatch = StrongChildMatch.isCoreMatch(child, parent);
        _this.canIntersectSnappedTo = true;
        return _this;
    }
    StrongChildMatch.prototype.isValid = function () {
        if (!this.isCoreMatch) {
            return false;
        }
        if (this.xzDistance > SnapMatch.maxDistance * 2) {
            return false;
        }
        return true;
    };
    StrongChildMatch.isCoreMatch = function (child, parent) {
        var matchingTypes = parent.type === "Child" && child.type === "Origin";
        if (matchingTypes) {
            var tRegExp = CoreUtils.createSaneRegExp(parent.foreign);
            if (tRegExp.test(child.key)) {
                var rxChild = CoreUtils.createSaneRegExp(child.foreign);
                if (rxChild.test(parent.key)) {
                    return true;
                }
            }
        }
        return false;
    };
    return StrongChildMatch;
}(SnapMatch));
export { StrongChildMatch };
